Merge commit 'd76af0754db7ddd4c06215d922d213c93178c0af' into elflink
[syslinux/sherbszt.git] / mk / com32.mk
blob6e7e9a681e835a50bf32146304304d1c7a80e5ff
1 ## -*- makefile -*- -------------------------------------------------------
2 ##
3 ## Copyright 2008-2009 H. Peter Anvin - All Rights Reserved
4 ## Copyright 2009 Intel Corporation; author: H. Peter Anvin
5 ##
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 GCCOPT := $(call gcc_ok,-std=gnu99,)
21 GCCOPT += $(call gcc_ok,-m32,)
22 GCCOPT += $(call gcc_ok,-fno-stack-protector,)
23 GCCOPT += $(call gcc_ok,-fwrapv,)
24 GCCOPT += $(call gcc_ok,-freg-struct-return,)
25 GCCOPT += -mregparm=3 -DREGPARM=3 -march=i386 -Os
26 GCCOPT += $(call gcc_ok,-fPIE,-fPIC)
27 GCCOPT += $(call gcc_ok,-fno-exceptions,)
28 GCCOPT += $(call gcc_ok,-fno-asynchronous-unwind-tables,)
29 GCCOPT += $(call gcc_ok,-fno-strict-aliasing,)
30 GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0)
31 GCCOPT += $(call gcc_ok,-falign-jumps=0,-malign-jumps=0)
32 GCCOPT += $(call gcc_ok,-falign-labels=0,-malign-labels=0)
33 GCCOPT += $(call gcc_ok,-falign-loops=0,-malign-loops=0)
34 GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,)
35 GCCOPT += $(call gcc_ok,-incoming-stack-boundary=2,)
37 com32 := $(topdir)/com32
38 RELOCS := $(com32)/tools/relocs
40 ifneq ($(NOGPL),1)
41 GPLLIB = $(com32)/gpllib/libcom32gpl.a
42 GPLINCLUDE = -I$(com32)/gplinclude
43 else
44 GPLLIB =
45 GPLINCLUDE =
46 endif
48 CFLAGS = $(GCCOPT) $(GCCWARN) -march=i386 \
49 -fomit-frame-pointer -D__COM32__ \
50 -nostdinc -iwithprefix include \
51 -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE) \
52 -I../../core/include
53 SFLAGS = $(GCCOPT) $(GCCWARN) -march=i386 \
54 -fomit-frame-pointer -D__COM32__ \
55 -nostdinc -iwithprefix include \
56 -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE)
58 COM32LD = $(com32)/lib/elf32.ld
59 LDFLAGS = -m elf_i386 -shared --hash-style=gnu -T $(COM32LD)
60 LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc)
62 LNXCFLAGS = -I$(com32)/libutil/include $(GCCWARN) -O -g \
63 -D_GNU_SOURCE -D_FORTIFY_SOURCE=0 -Wno-error
64 LNXSFLAGS = -g
65 LNXLDFLAGS = -g
67 C_LIBS = $(com32)/libutil/libutil_com.a $(GPLLIB) \
68 $(com32)/lib/libcom32.c32 $(LIBGCC)
69 C_LNXLIBS = $(com32)/libutil/libutil_lnx.a
71 .SUFFIXES: .lss .c .lo .o .elf .c32 .lnx
73 .PRECIOUS: %.o
74 %.o: %.S
75 $(CC) $(MAKEDEPS) $(SFLAGS) -c -o $@ $<
77 .PRECIOUS: %.o
78 %.o: %.c
79 $(CC) $(MAKEDEPS) $(CFLAGS) -c -o $@ $<
81 .PRECIOUS: %.elf
82 %.elf: %.o $(LIBS) $(C_LIBS) $(COM32LD)
83 $(LD) $(LDFLAGS) -o $@ $(filter-out $(COM32LD),$^)
85 .PRECIOUS: %.lo
86 %.lo: %.S
87 $(CC) $(MAKEDEPS) $(LNXSFLAGS) -c -o $@ $<
89 .PRECIOUS: %.lo
90 %.lo: %.c
91 $(CC) $(MAKEDEPS) $(LNXCFLAGS) -c -o $@ $<
93 .PRECIOUS: %.lnx
94 %.lnx: %.lo $(LNXLIBS) $(C_LNXLIBS)
95 $(CC) $(LNXCFLAGS) -o $@ $^
97 %.c32: %.elf
98 $(OBJCOPY) --strip-debug --strip-unneeded $< $@
99 ##$(OBJCOPY) -O binary $< $@
100 ##$(RELOCS) $< >> $@ || ( rm -f $@ ; false )