Detect GCC 3.x versus 4.x and use -I- or -isystem, respectively, to
[pintos-anon] / src / Make.config
index 8744f0da4a764c4022f72669668a498f271c6bea..f9822b66d468f3198b504056f538bbb8b09b08bb 100644 (file)
@@ -18,11 +18,21 @@ LD = i386-elf-ld
 OBJCOPY = i386-elf-objcopy
 endif
 
+# 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 -masm=intel
-CPPFLAGS = -nostdinc -I$(SRCDIR) -I- -I$(SRCDIR)/lib
+SYSINCDIRS = $(SRCDIR)/lib
+CPPFLAGS = -nostdinc -I$(SRCDIR) $(SYSINCFLAGS)
 ASFLAGS = -Wa,--gstabs -MMD
 LDFLAGS =