8 # If the host appears to be x86, use the normal tools.
9 # If it's x86-64, use the compiler and linker in 32-bit mode.
10 # Otherwise assume cross-tools are installed as i386-elf-*.
11 X86 = i.86\|pentium.*\|[pk][56]\|nexgen\|viac3\|6x86\|athlon.*\|i86pc
13 ifneq (0, $(shell expr `uname -m` : '$(X86)'))
18 ifneq (0, $(shell expr `uname -m` : '$(X86_64)'))
25 OBJCOPY = i386-elf-objcopy
29 ifeq ($(strip $(shell command -v $(CC) 2> /dev/null)),)
30 $(warning *** Compiler ($(CC)) not found. Did you set $$PATH properly? Please refer to the Getting Started section in the documentation for details. ***)
33 # Compiler and assembler invocation.
35 WARNINGS = -Wall -W -Wstrict-prototypes -Wmissing-prototypes -Wsystem-headers
36 CFLAGS = -g -msoft-float -O -march=i686
37 CPPFLAGS = -nostdinc -I$(SRCDIR) -I$(SRCDIR)/lib
38 ASFLAGS = -Wa,--gstabs
40 DEPS = -MMD -MF $(@:.o=.d)
42 # Turn off -fstack-protector, which we don't support.
43 ifeq ($(strip $(shell echo | $(CC) -fno-stack-protector -E - > /dev/null 2>&1; echo $$?)),0)
44 CFLAGS += -fno-stack-protector
47 # Turn off --build-id in the linker, which confuses the Pintos loader.
48 ifeq ($(strip $(shell $(LD) --help | grep -q build-id; echo $$?)),0)
49 LDFLAGS += -Wl,--build-id=none
53 $(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS) $(WARNINGS) $(DEFINES) $(DEPS)
56 $(CC) -c $< -o $@ $(ASFLAGS) $(CPPFLAGS) $(DEFINES) $(DEPS)