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 $(topdir)/MCONFIG
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
41 GPLLIB = $(com32)/gpllib/libcom32gpl.a
42 GPLINCLUDE = -I$(com32)/gplinclude
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 SFLAGS = $(GCCOPT) $(GCCWARN) -march=i386 \
53 -fomit-frame-pointer -D__COM32__ \
54 -nostdinc -iwithprefix include \
55 -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE)
57 COM32LD = $(com32)/lib/com32.ld
58 LDFLAGS = -m elf_i386 --emit-relocs -T $(COM32LD)
59 LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc)
61 LNXCFLAGS = -I$(com32)/libutil/include $(GCCWARN) -O -g \
62 -D_GNU_SOURCE -D_FORTIFY_SOURCE=0 -Wno-error
66 C_LIBS = $(com32)/libutil/libutil_com.a $(GPLLIB) \
67 $(com32)/lib/libcom32.a $(LIBGCC)
68 C_LNXLIBS = $(com32)/libutil/libutil_lnx.a
70 .SUFFIXES: .lss .c .lo .o .elf .c32 .lnx
74 $(CC) $(MAKEDEPS) $(SFLAGS) -c -o $@ $<
78 $(CC) $(MAKEDEPS) $(CFLAGS) -c -o $@ $<
81 %.elf: %.o $(LIBS) $(C_LIBS) $(COM32LD)
82 $(LD) $(LDFLAGS) -o $@ $(filter-out $(COM32LD),$^)
86 $(CC) $(MAKEDEPS) $(LNXSFLAGS) -c -o $@ $<
90 $(CC) $(MAKEDEPS) $(LNXCFLAGS) -c -o $@ $<
93 %.lnx: %.lo $(LNXLIBS) $(C_LNXLIBS)
94 $(CC) $(LNXCFLAGS) -o $@ $^
97 $(OBJCOPY) -O binary $< $@
98 $(RELOCS) $< >> $@ || ( rm -f $@ ; false )