Detect GCC 3.x versus 4.x and use -I- or -isystem, respectively, to
[pintos-anon] / src / Make.config
index 63d6a226ea5fb3d61c33ae4ef5ce3f8175010e11..f9822b66d468f3198b504056f538bbb8b09b08bb 100644 (file)
@@ -2,6 +2,8 @@
 
 SHELL = /bin/sh
 
+VPATH = $(SRCDIR)
+
 # Binary utilities.
 # If the host appears to be x86, use the normal tools.
 # Otherwise assume cross-tools are installed as i386-elf-*.
@@ -16,15 +18,23 @@ LD = i386-elf-ld
 OBJCOPY = i386-elf-objcopy
 endif
 
-# Other utilities.
-DD = dd
-RM = rm
-CAT = cat
+# GCC 3.3 specifies directories for #include <> as "-I- -Idir"
+# GCC 4.x specifies directories for #include <> as "-isystem dir"
+# Figure out which format to use.
+ifeq (0, $(shell $(CC) -v 2>&1 | grep 'gcc version 4' >/dev/null 2>&1; echo $$?))
+SYSINCFLAGS = $(patsubst %,-isystem %,$(SYSINCDIRS))
+else
+SYSINCFLAGS = -I- $(patsubst %,-I%,$(SYSINCDIRS))
+endif
 
 # Compiler and assembler invocation.
+DEFINES =
 WARNINGS = -Wall -W -Wstrict-prototypes -Wmissing-prototypes -Wsystem-headers
-CFLAGS = -g -MMD -msoft-float
+CFLAGS = -g -MMD -msoft-float -masm=intel
+SYSINCDIRS = $(SRCDIR)/lib
+CPPFLAGS = -nostdinc -I$(SRCDIR) $(SYSINCFLAGS)
 ASFLAGS = -Wa,--gstabs -MMD
+LDFLAGS = 
 
 %.o: %.c
        $(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS) $(WARNINGS) $(DEFINES)