1 ## -*- makefile -*- -------------------------------------------------------
3 ## Copyright 2008 H. Peter Anvin - All Rights Reserved
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., 51 Franklin St, Fifth Floor,
8 ## Boston MA 02110-1301, USA; either version 2 of the License, or
9 ## (at your option) any later version; incorporated herein by reference.
11 ## -----------------------------------------------------------------------
14 ## ELF common configurables
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 GCCOPT
:= $(call gcc_ok
,-std
=gnu99
,)
23 GCCOPT
+= $(call gcc_ok
,-m32
,)
24 GCCOPT
+= $(call gcc_ok
,-march
=i386
)
25 GCCOPT
+= $(call gcc_ok
,-mpreferred-stack-boundary
=2,)
28 GCCOPT
+= $(call gcc_ok
,-m64
,)
29 GCCOPT
+= $(call gcc_ok
,-march
=x86-64
)
30 #let preferred-stack-boundary be default (=4)
32 GCCOPT
+= -Os
-fomit-frame-pointer
33 GCCOPT
+= $(call gcc_ok
,-fno-stack-protector
,)
34 GCCOPT
+= $(call gcc_ok
,-fwrapv
,)
35 GCCOPT
+= $(call gcc_ok
,-freg-struct-return
,)
36 GCCOPT
+= $(call gcc_ok
,-fno-exceptions
,)
37 GCCOPT
+= $(call gcc_ok
,-fno-asynchronous-unwind-tables
,)
38 # Note -fPIE does not work with ld on x86_64, try -fPIC instead
39 # Does BIOS build depend on -fPIE?
40 GCCOPT
+= $(call gcc_ok
,-fPIC
)
41 GCCOPT
+= $(call gcc_ok
,-falign-functions
=0,-malign-functions
=0)
42 GCCOPT
+= $(call gcc_ok
,-falign-jumps
=0,-malign-jumps
=0)
43 GCCOPT
+= $(call gcc_ok
,-falign-labels
=0,-malign-labels
=0)
44 GCCOPT
+= $(call gcc_ok
,-falign-loops
=0,-malign-loops
=0)
46 com32
= $(topdir
)/com32
50 GPLLIB
= $(objdir
)/com32
/gpllib
/libgpl.c32
51 GPLINCLUDE
= -I
$(com32
)/gplinclude
57 CFLAGS
= $(GCCOPT
) $(GCCWARN
) -W
-Wall \
58 -fomit-frame-pointer
-D__COM32__
-DDYNAMIC_MODULE \
59 -nostdinc
-iwithprefix
include \
60 -I
$(com32
)/libutil
/include -I
$(com32
)/include \
61 -I
$(com32
)/include/sys
$(GPLINCLUDE
) -I
$(core
)/include \
62 -I
$(objdir
) -DLDLINUX
=\"$(LDLINUX
)\"
64 CFLAGS
+= -mregparm
=3 -DREGPARM
=3
67 SFLAGS
= $(GCCOPT
) -D__COM32__
68 LDFLAGS
= -m elf_
$(ARCH
) -shared
--hash-style
=gnu
-T
$(com32
)/lib
/$(ARCH
)/elf.
ld --as-needed
69 LIBGCC
:= $(shell $(CC
) $(GCCOPT
) --print-libgcc
)
71 LNXCFLAGS
= -I
$(com32
)/libutil
/include -W
-Wall
-O
-g
-D_GNU_SOURCE
75 C_LIBS
+= $(objdir
)/com32
/libutil
/libutil.c32
$(GPLLIB
) \
76 $(objdir
)/com32
/lib
/libcom32.c32
77 C_LNXLIBS
= $(objdir
)/com32
/libutil
/libutil_lnx.a \
78 $(objdir
)/com32
/elflink
/ldlinux
/ldlinux_lnx.a
84 $(CC
) $(SFLAGS
) -c
-o
$@
$<
88 $(CC
) $(CFLAGS
) -c
-o
$@
$<
92 $(CC
) $(LNXSFLAGS
) -c
-o
$@
$<
96 $(CC
) $(LNXCFLAGS
) -c
-o
$@
$<
99 %.lnx
: %.lo
$(LNXLIBS
) $(C_LNXLIBS
)
100 $(CC
) $(LNXCFLAGS
) -o
$@
$^
104 $(LD
) $(LDFLAGS
) -o
$@
$^
107 $(OBJCOPY
) --strip-debug
--strip-unneeded
$< $@