1 ## -*- makefile -*- -------------------------------------------------------
3 ## Copyright 2008-2009 H. Peter Anvin - All Rights Reserved
4 ## Copyright 2009 Intel Corporation; author: H. Peter Anvin
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
9 ## Boston MA 02110-1301, USA; either version 2 of the License, or
10 ## (at your option) any later version; incorporated herein by reference.
12 ## -----------------------------------------------------------------------
15 ## COM32 common configurables
18 include $(MAKEDIR
)/syslinux.mk
20 # Support IA32 and x86_64 platforms with one build
21 # Set up architecture specifics; for cross compilation, set ARCH as apt
22 GCCOPT
:= $(call gcc_ok
,-std
=gnu99
,)
23 ifeq ($(strip $(ARCH
)),i386
)
24 GCCOPT
+= $(call gcc_ok
,-m32
,)
25 GCCOPT
+= $(call gcc_ok
,-march
=i386
)
26 GCCOPT
+= $(call gcc_ok
,-mpreferred-stack-boundary
=2,)
27 GCCOPT
+= $(call gcc_ok
,-incoming-stack-boundary
=2,)
29 ifeq ($(strip $(ARCH
)),x86_64
)
30 GCCOPT
+= $(call gcc_ok
,-m64
,)
31 GCCOPT
+= $(call gcc_ok
,-march
=x86-64
)
32 #let the stack-boundary default to whatever it is on 64bit
33 #GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=8,)
34 #GCCOPT += $(call gcc_ok,-incoming-stack-boundary=8,)
36 GCCOPT
+= $(call gcc_ok
,-fno-stack-protector
,)
37 GCCOPT
+= $(call gcc_ok
,-fwrapv
,)
38 GCCOPT
+= $(call gcc_ok
,-freg-struct-return
,)
40 # Note -fPIE does not work with ld on x86_64, try -fPIC instead
41 # Does BIOS build require -fPIE?
42 GCCOPT
+= $(call gcc_ok
,-fPIC
)
43 GCCOPT
+= $(call gcc_ok
,-fno-exceptions
,)
44 GCCOPT
+= $(call gcc_ok
,-fno-asynchronous-unwind-tables
,)
45 GCCOPT
+= $(call gcc_ok
,-fno-strict-aliasing
,)
46 GCCOPT
+= $(call gcc_ok
,-falign-functions
=0,-malign-functions
=0)
47 GCCOPT
+= $(call gcc_ok
,-falign-jumps
=0,-malign-jumps
=0)
48 GCCOPT
+= $(call gcc_ok
,-falign-labels
=0,-malign-labels
=0)
49 GCCOPT
+= $(call gcc_ok
,-falign-loops
=0,-malign-loops
=0)
52 GCCOPT
+= -mregparm
=3 -DREGPARM
=3
55 com32
:= $(topdir
)/com32
56 RELOCS
:= $(com32
)/tools
/relocs
59 GPLLIB
= $(com32
)/gpllib
/libcom32gpl.a
60 GPLINCLUDE
= -I
$(com32
)/gplinclude
66 CFLAGS
= $(GCCOPT
) $(GCCWARN
) \
67 -fomit-frame-pointer
-D__COM32__
-D__FIRMWARE_
$(FIRMWARE
)__ \
68 -nostdinc
-iwithprefix
include \
69 -I
$(com32
)/libutil
/include -I
$(com32
)/include \
70 -I
$(com32
)/include/sys
$(GPLINCLUDE
)
71 SFLAGS
= $(GCCOPT
) $(GCCWARN
) \
72 -fomit-frame-pointer
-D__COM32__
-D__FIRMWARE_
$(FIRMWARE
)__ \
73 -nostdinc
-iwithprefix
include \
74 -I
$(com32
)/libutil
/include -I
$(com32
)/include \
75 -I
$(com32
)/include/sys
$(GPLINCLUDE
)
77 COM32LD
= $(com32
)/lib
/$(ARCH
)/elf.
ld
78 LDFLAGS
= -m elf_
$(ARCH
) -shared
--hash-style
=gnu
-T
$(COM32LD
)
79 LIBGCC
:= $(shell $(CC
) $(GCCOPT
) --print-libgcc
)
81 LNXCFLAGS
= -I
$(com32
)/libutil
/include $(GCCWARN
) -O
-g \
82 -D_GNU_SOURCE
-D_FORTIFY_SOURCE
=0 -Wno-error
86 C_LIBS
= $(GPLLIB
) $(com32
)/lib
/libcom32.c32
$(LIBGCC
)
87 C_LNXLIBS
= $(com32
)/libutil
/libutil_lnx.a
89 .SUFFIXES
: .lss .c .lo .o .elf .c32 .lnx
93 $(CC
) $(MAKEDEPS
) $(SFLAGS
) -c
-o
$@
$<
97 $(CC
) $(MAKEDEPS
) $(CFLAGS
) -c
-o
$@
$<
100 %.elf
: %.o
$(LIBS
) $(C_LIBS
) $(COM32LD
)
101 $(LD
) $(LDFLAGS
) -o
$@
$(filter-out $(COM32LD
),$^
)
105 $(CC
) $(MAKEDEPS
) $(LNXSFLAGS
) -c
-o
$@
$<
109 $(CC
) $(MAKEDEPS
) $(LNXCFLAGS
) -c
-o
$@
$<
112 %.lnx
: %.lo
$(LNXLIBS
) $(C_LNXLIBS
)
113 $(CC
) $(LNXCFLAGS
) -o
$@
$^
116 $(OBJCOPY
) --strip-debug
--strip-unneeded
$< $@
117 ##$(OBJCOPY) -O binary $< $@
118 ##$(RELOCS) $< >> $@ || ( rm -f $@ ; false )