From 377d614c385f4416b0ee1b027580992f93551cbd Mon Sep 17 00:00:00 2001 From: Rainer Mueller Date: Sun, 31 Jul 2011 21:52:28 +0200 Subject: [PATCH] Fix build on Mac OS X The header stdio.h on Mac OS X includes some defines to do buffer overflow checks if using _FORTIFY_SOURCE > 2, which is the default. Defining _FORTIFY_SOURCE=0 disables this behavior. The Mac OS X linker ld64 has problem with common symbols in static archives. The workaround here is to run 'ranlib -c' on the static archive. --- firmware/Makefile.inc | 2 ++ firmware/Makefile.util | 1 + simulat0r/firmware/Makefile.inc | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/firmware/Makefile.inc b/firmware/Makefile.inc index 7085dd9..855d011 100644 --- a/firmware/Makefile.inc +++ b/firmware/Makefile.inc @@ -23,6 +23,8 @@ CC = $(CROSS_COMPILE)gcc LD = $(CROSS_COMPILE)ld REALLD = $(CROSS_COMPILE)ld SIZE = $(CROSS_COMPILE)size +AR = $(CROSS_COMPILE)ar +RANLIB = $(CROSS_COMPILE)ranlib OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump OUTFILE = firmware diff --git a/firmware/Makefile.util b/firmware/Makefile.util index 5e7916b..735c919 100644 --- a/firmware/Makefile.util +++ b/firmware/Makefile.util @@ -6,6 +6,7 @@ all: $(LIBFILE) $(LIBFILE): $(OBJS) $(AR) rcs $@ $(OBJS) + $(RANLIB) $(RANLIBFLAGS) $@ %.o : %.c $(CC) $(CFLAGS) -o $@ $< diff --git a/simulat0r/firmware/Makefile.inc b/simulat0r/firmware/Makefile.inc index cfa0f0a..98a0713 100644 --- a/simulat0r/firmware/Makefile.inc +++ b/simulat0r/firmware/Makefile.inc @@ -23,6 +23,8 @@ CC = $(CROSS_COMPILE)gcc LD = $(CROSS_COMPILE)ld REALLD = $(CROSS_COMPILE)ld SIZE = $(CROSS_COMPILE)size +AR = $(CROSS_COMPILE)ar +RANLIB = $(CROSS_COMPILE)ranlib OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump OUTFILE = firmware @@ -44,6 +46,12 @@ endif CFLAGS = -std=c99 -c -g -O0 $(INCLUDE_PATHS) -Wall -funsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -DRAMCODE=$(RAMCODE) -fno-builtin -DSIMULATOR -I$(ROOT_PATH)/../simcore -include libc-unc0llide.h $(CONFIG_GCC_SHOWCOLUMN) #LDFLAGS = -nostartfiles +ifeq ($(shell uname), Darwin) +# Mac OS X provides a stdio.h with unwanted defines +CFLAGS += -D_FORTIFY_SOURCE=0 +# ld64 has problems with common symbols , apply a workaround +RANLIBFLAGS = -c +endif CONFIG_MAKE_PRINTDIRECTORY = --no-print-directory CONFIG_GCC_SHOWCOLUMN =