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.
This commit is contained in:
Rainer Mueller 2011-07-31 21:52:28 +02:00 committed by Stefan `Sec` Zehl
parent d4c48f66c2
commit 377d614c38
3 changed files with 11 additions and 0 deletions

View File

@ -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

View File

@ -6,6 +6,7 @@ all: $(LIBFILE)
$(LIBFILE): $(OBJS)
$(AR) rcs $@ $(OBJS)
$(RANLIB) $(RANLIBFLAGS) $@
%.o : %.c
$(CC) $(CFLAGS) -o $@ $<

View File

@ -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 <rdar://problem/9870713>, apply a workaround
RANLIBFLAGS = -c
endif
CONFIG_MAKE_PRINTDIRECTORY = --no-print-directory
CONFIG_GCC_SHOWCOLUMN =