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 17include $(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 23GCCOPT := 24ifeq ($(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,) 29endif 30ifeq ($(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) 36endif 37GCCOPT += $(call gcc_ok,-ffreestanding,) 38GCCOPT += $(call gcc_ok,-fno-stack-protector,) 39GCCOPT += $(call gcc_ok,-fwrapv,) 40GCCOPT += $(call gcc_ok,-freg-struct-return,) 41ifdef EFI_BUILD 42GCCOPT += -Os -fomit-frame-pointer -msoft-float 43else 44GCCOPT += -Os -fomit-frame-pointer -mregparm=3 -DREGPARM=3 \ 45 -msoft-float 46endif 47GCCOPT += $(call gcc_ok,-fno-exceptions,) 48GCCOPT += $(call gcc_ok,-fno-asynchronous-unwind-tables,) 49GCCOPT += $(call gcc_ok,-fno-strict-aliasing,) 50GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0) 51GCCOPT += $(call gcc_ok,-falign-jumps=0,-malign-jumps=0) 52GCCOPT += $(call gcc_ok,-falign-labels=0,-malign-labels=0) 53GCCOPT += $(call gcc_ok,-falign-loops=0,-malign-loops=0) 54GCCOPT += $(call gcc_ok,-fvisibility=hidden) 55 56LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc) 57 58LD += -m elf_$(ARCH) 59 60# Note: use += for CFLAGS and SFLAGS in case something is set in MCONFIG.local 61CFLAGS += $(GCCOPT) -g $(GCCWARN) -Wno-sign-compare $(OPTFLAGS) $(INCLUDES) 62SFLAGS += $(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