Merge pull request #56: Fix build for gcc >= 5.0.

gcc 5.0 defaults to -std=gnu11 meaning code which relies on implicit
ints will no longer compile. Passing -std=gnu89 restores the default
but causes problems because the system headers are written in gnu11.
Using -idirafter instead of -nostdinc resolves all problems and should
be compatible with old GCC versions (and clang).
This commit is contained in:
vak
2015-07-04 19:59:43 -07:00
parent 66cadb02a1
commit 0c3fffb6f6
2 changed files with 5 additions and 15 deletions

View File

@@ -2,20 +2,10 @@ TOPSRC = $(shell cd ..; pwd)
SUBDIR = startup libc libcurses libtermlib libwiznet
PROG = ar as aout ld nm ranlib size strip
# Build a list of the host include directories.
CPP = $(shell gcc -print-prog-name=cc1)
HOSTINC = $(addprefix -I,$(shell echo | $(CPP) -v 2>&1 | grep '^ /.*include'))
# Add system include path
ifeq (,$(wildcard /usr/include/i386-linux-gnu))
HOSTINC += -I/usr/include
else
HOSTINC += -I/usr/include/i386-linux-gnu
endif
CFLAGS += -nostdinc -fno-builtin -g -Werror -Wall -DCROSS -I. $(HOSTINC) \
-I$(TOPSRC)/include -I$(TOPSRC)/src/cmd/ar \
-I$(TOPSRC)/src/cmd/as
CFLAGS += -std=gnu89 -fno-builtin -g -Werror -Wall -DCROSS -I. \
-idirafter $(TOPSRC)/include \
-idirafter $(TOPSRC)/src/cmd/ar \
-idirafter $(TOPSRC)/src/cmd/as
LDFLAGS += -g
AR_OBJS = ar.o append.o archive.o contents.o delete.o extract.o \

View File

@@ -37,7 +37,7 @@ lint:
egrep -v '^(error|free|malloc)'
proctab.c: proc.c token.h awk.h
cc -Wall -Werror -o proc proc.c
cc -std=gnu89 -Wall -Werror -o proc proc.c
./proc > proctab.c
clean: