1 ## -*- makefile -*- ------------------------------------------------------ 2 ## 3 ## Copyright 2001-2008 H. Peter Anvin - All Rights Reserved 4 ## 5 ## This program is free software; you can redistribute it and/or modify 6 ## it under the terms of the GNU General Public License as published by 7 ## the Free Software Foundation, Inc., 53 Temple Place Ste 330, 8 ## Boston MA 02111-1307, USA; either version 2 of the License, or 9 ## (at your option) any later version; incorporated herein by reference. 10 ## 11 ## ----------------------------------------------------------------------- 12 13 ## 14 ## Make configuration for embedded directories 15 ## 16 17 include $(MAKEDIR)/syslinux.mk 18 19 # Support IA32 and x86_64 platforms with one build 20 # Set up architecture specifics; for cross compilation, set ARCH as apt 21 # Initialize GCCOPT to null to begin with. Without this, make generates 22 # recursive error for GCCOPT 23 GCCOPT := 24 ifeq ($(ARCH),i386) 25 GCCOPT := $(call gcc_ok,-m32) 26 GCCOPT += $(call gcc_ok,-march=i386) 27 GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,) 28 GCCOPT += $(call gcc_ok,-mincoming-stack-boundary=2,) 29 endif 30 ifeq ($(ARCH),x86_64) 31 GCCOPT := $(call gcc_ok,-m64) 32 GCCOPT += $(call gcc_ok,-march=x86-64) 33 #let preferred-stack-boundary and incoming-stack-boundary be default(=4) 34 # Somewhere down the line ld barfs requiring -fPIC 35 GCCOPT += $(call gcc_ok,-fPIC) 36 endif 37 GCCOPT += $(call gcc_ok,-ffreestanding,) 38 GCCOPT += $(call gcc_ok,-fno-stack-protector,) 39 GCCOPT += $(call gcc_ok,-fwrapv,) 40 GCCOPT += $(call gcc_ok,-freg-struct-return,) 41 ifdef EFI_BUILD 42 GCCOPT += -Os -fomit-frame-pointer -msoft-float 43 else 44 GCCOPT += -Os -fomit-frame-pointer -mregparm=3 -DREGPARM=3 \ 45 -msoft-float 46 endif 47 GCCOPT += $(call gcc_ok,-fno-exceptions,) 48 GCCOPT += $(call gcc_ok,-fno-asynchronous-unwind-tables,) 49 GCCOPT += $(call gcc_ok,-fno-strict-aliasing,) 50 GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0) 51 GCCOPT += $(call gcc_ok,-falign-jumps=0,-malign-jumps=0) 52 GCCOPT += $(call gcc_ok,-falign-labels=0,-malign-labels=0) 53 GCCOPT += $(call gcc_ok,-falign-loops=0,-malign-loops=0) 54 GCCOPT += $(call gcc_ok,-fvisibility=hidden) 55 56 LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc) 57 58 LD += -m elf_$(ARCH) 59 60 # Note: use += for CFLAGS and SFLAGS in case something is set in MCONFIG.local 61 CFLAGS += $(GCCOPT) -g $(GCCWARN) -Wno-sign-compare $(OPTFLAGS) $(INCLUDES) 62 SFLAGS += $(CFLAGS) -D__ASSEMBLY__ 63 64 .SUFFIXES: .c .o .S .s .i .elf .com .bin .asm .lst .c32 .lss 65 66 %.o: %.c 67 $(CC) $(MAKEDEPS) $(CFLAGS) -c -o $@ $< 68 %.i: %.c 69 $(CC) $(MAKEDEPS) $(CFLAGS) -E -o $@ $< 70 %.s: %.c 71 $(CC) $(MAKEDEPS) $(CFLAGS) -S -o $@ $< 72 %.o: %.S 73 $(CC) $(MAKEDEPS) $(SFLAGS) -Wa,-a=$*.lst -c -o $@ $< 74 %.s: %.S 75 $(CC) $(MAKEDEPS) $(SFLAGS) -E -o $@ $< 76