ldlinux: Fix OnError behaviour
[syslinux.git] / mk / elf.mk
blob160dadccf7082e6b8f8a12efdf59a6d702d35512
1 ## -*- makefile -*- -------------------------------------------------------
2 ##
3 ## Copyright 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., 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 GCCOPT := $(call gcc_ok,-std=gnu99,)
20 GCCOPT += $(call gcc_ok,-m32,)
21 GCCOPT += $(call gcc_ok,-fno-stack-protector,)
22 GCCOPT += $(call gcc_ok,-fwrapv,)
23 GCCOPT += $(call gcc_ok,-freg-struct-return,)
24 GCCOPT += -march=i386 -Os -fomit-frame-pointer -mregparm=3 -DREGPARM=3
25 GCCOPT += $(call gcc_ok,-fno-exceptions,)
26 GCCOPT += $(call gcc_ok,-fno-asynchronous-unwind-tables,)
27 GCCOPT += $(call gcc_ok,-fPIE,-fPIC)
28 GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0)
29 GCCOPT += $(call gcc_ok,-falign-jumps=0,-malign-jumps=0)
30 GCCOPT += $(call gcc_ok,-falign-labels=0,-malign-labels=0)
31 GCCOPT += $(call gcc_ok,-falign-loops=0,-malign-loops=0)
32 GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,)
34 com32 = $(topdir)/com32
35 core = $(topdir)/core
37 ifneq ($(NOGPL),1)
38 GPLLIB = $(com32)/gpllib/libcom32gpl.c32
39 GPLINCLUDE = -I$(com32)/gplinclude
40 else
41 GPLLIB =
42 GPLINCLUDE =
43 endif
45 CFLAGS = $(GCCOPT) -W -Wall -march=i386 \
46 -fomit-frame-pointer -D__COM32__ -DDYNAMIC_MODULE \
47 -nostdinc -iwithprefix include \
48 -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE) \
49 -I$(core)/include
50 SFLAGS = $(GCCOPT) -D__COM32__ -march=i386
51 LDFLAGS = -m elf_i386 -shared --hash-style=gnu -T $(com32)/lib/elf32.ld --as-needed
53 LNXCFLAGS = -I$(com32)/libutil/include -W -Wall -O -g -D_GNU_SOURCE
54 LNXSFLAGS = -g
55 LNXLDFLAGS = -g
57 C_LIBS = $(com32)/libutil/libutil_com.c32 $(GPLLIB) \
58 $(com32)/lib/libcom32.c32
59 C_LNXLIBS = $(com32)/libutil/libutil_lnx.a \
60 $(com32)/elflink/ldlinux/ldlinux_lnx.a
62 .SUFFIXES: .lss .c .o
64 .PRECIOUS: %.o
65 %.o: %.S
66 $(CC) $(SFLAGS) -c -o $@ $<
68 .PRECIOUS: %.o
69 %.o: %.c
70 $(CC) $(CFLAGS) -c -o $@ $<
72 .PRECIOUS: %.lo
73 %.lo: %.S
74 $(CC) $(LNXSFLAGS) -c -o $@ $<
76 .PRECIOUS: %.lo
77 %.lo: %.c
78 $(CC) $(LNXCFLAGS) -c -o $@ $<
80 .PRECIOUS: %.lnx
81 %.lnx: %.lo $(LNXLIBS) $(C_LNXLIBS)
82 $(CC) $(LNXCFLAGS) -o $@ $^
84 %.c32: %.o $(C_LIBS)
85 $(LD) $(LDFLAGS) -o $@ $^