memdisk: Force ld output format to 32-bits
[syslinux.git] / mk / embedded.mk
blob488dc0fc56681649c16ba5a51ca8b15c52cad33f
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.
11 ## -----------------------------------------------------------------------
14 ## Make configuration for embedded directories
17 include $(MAKEDIR)/syslinux.mk
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 ifeq ($(FWCLASS),EFI)
42 GCCOPT += -Os -fomit-frame-pointer -msoft-float -mno-red-zone
43 else
44 GCCOPT += -Os -fomit-frame-pointer -mregparm=3 -DREGPARM=3 -msoft-float
45 endif
46 GCCOPT += $(call gcc_ok,-fno-exceptions,)
47 GCCOPT += $(call gcc_ok,-fno-asynchronous-unwind-tables,)
48 GCCOPT += $(call gcc_ok,-fno-strict-aliasing,)
49 GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0)
50 GCCOPT += $(call gcc_ok,-falign-jumps=0,-malign-jumps=0)
51 GCCOPT += $(call gcc_ok,-falign-labels=0,-malign-labels=0)
52 GCCOPT += $(call gcc_ok,-falign-loops=0,-malign-loops=0)
53 GCCOPT += $(call gcc_ok,-fvisibility=hidden)
55 LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc)
57 LD += -m elf_$(ARCH)
59 # Note: use += for CFLAGS and SFLAGS in case something is set in MCONFIG.local
60 CFLAGS += $(GCCOPT) -g $(GCCWARN) -Wno-sign-compare $(OPTFLAGS) $(INCLUDES)
61 SFLAGS += $(CFLAGS) -D__ASSEMBLY__
63 .SUFFIXES: .c .o .S .s .i .elf .com .bin .asm .lst .c32 .lss
65 %.o: %.c
66 $(CC) $(MAKEDEPS) $(CFLAGS) -c -o $@ $<
67 %.i: %.c
68 $(CC) $(MAKEDEPS) $(CFLAGS) -E -o $@ $<
69 %.s: %.c
70 $(CC) $(MAKEDEPS) $(CFLAGS) -S -o $@ $<
71 %.o: %.S
72 $(CC) $(MAKEDEPS) $(SFLAGS) -Wa,-a=$*.lst -c -o $@ $<
73 %.s: %.S
74 $(CC) $(MAKEDEPS) $(SFLAGS) -E -o $@ $<