Adding upstream version 6.00+dfgs.
[syslinux-debian/hramrach.git] / core / Makefile
blobeaf12443802a282b509bc4258e6c67237554ce82
1 ## -----------------------------------------------------------------------
2 ##
3 ## Copyright 1998-2009 H. Peter Anvin - All Rights Reserved
4 ## Copyright 2009-2010 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., 53 Temple Place Ste 330,
9 ## Boston MA 02111-1307, USA; either version 2 of the License, or
10 ## (at your option) any later version; incorporated herein by reference.
12 ## -----------------------------------------------------------------------
15 # Makefile for the SYSLINUX core
18 VPATH = $(SRC)
20 # No builtin rules
21 MAKEFLAGS += -r
22 MAKE += -r
24 include $(MAKEDIR)/embedded.mk
25 -include $(objdir)/version.mk
27 OPTFLAGS =
28 INCLUDES = -I$(SRC)/include -I$(com32)/include -I$(com32)/include/sys -I$(com32)/lib \
29 -I$(SRC)/lwip/src/include -I$(SRC)/lwip/src/include/ipv4 -I$(SRC)/fs/pxe
31 # This is very similar to cp437; technically it's for Norway and Denmark,
32 # but it's unlikely the characters that are different will be used in
33 # filenames by other users.
34 CODEPAGE = cp865
36 # The targets to build in this directory...
37 BTARGET = kwdhash.gen \
38 ldlinux.bss ldlinux.sys ldlinux.bin \
39 isolinux.bin isolinux-debug.bin pxelinux.0 lpxelinux.0
41 # All primary source files for the main syslinux files
42 NASMSRC := $(wildcard $(SRC)/*.asm)
43 NASMHDR := $(wildcard $(SRC)/*.inc)
44 CSRC := $(shell find $(SRC) -name '*.c' -print)
45 SSRC := $(shell find $(SRC) -name '*.S' -print)
46 CHDR := $(shell find $(SRC) -name '*.h' -print)
47 OTHERSRC := keywords
48 ALLSRC = $(NASMSRC) $(NASMHDR) $(CSRC) $(SSRC) $(CHDR) $(OTHERSRC)
50 COBJ := $(subst $(SRC)/,,$(patsubst %.c,%.o,$(CSRC)))
51 SOBJ := $(subst $(SRC)/,,$(patsubst %.S,%.o,$(SSRC)))
53 # To make this compatible with the following $(filter-out), make sure
54 # we prefix everything with $(SRC)
55 CORE_PXE_CSRC = \
56 $(addprefix $(SRC)/fs/pxe/, dhcp_option.c pxe.c tftp.c urlparse.c bios.c)
58 LPXELINUX_CSRC = $(CORE_PXE_CSRC) \
59 $(shell find $(SRC)/lwip -name '*.c' -print) \
60 $(addprefix $(SRC)/fs/pxe/, \
61 core.c dnsresolv.c ftp.c ftp_readdir.c gpxeurl.c http.c \
62 http_readdir.c idle.c isr.c tcp.c)
64 PXELINUX_CSRC = $(CORE_PXE_CSRC) \
65 $(shell find $(SRC)/legacynet -name '*.c' -print)
67 LPXELINUX_OBJS = $(subst $(SRC)/,,$(LPXELINUX_CSRC:%.c=%.o))
68 PXELINUX_OBJS = $(subst $(SRC)/,,$(PXELINUX_CSRC:%.c=%.o))
70 # Don't include console and network stack specific objects
71 FILTER_OBJS = %rawcon.o %plaincon.o %pxelinux-c.o %ldlinux-c.o %isolinux-c.o \
72 $(subst $(OBJ)/,,$(LPXELINUX_OBJS)) \
73 $(subst $(OBJ)/,,$(PXELINUX_OBJS))
75 ifdef EFI_BUILD
76 # EFI is single-threaded.
77 FILTER_OBJS += $(subst $(SRC)/,, \
78 $(patsubst %.c,%.o, $(wildcard $(SRC)/thread/*.c)) \
79 $(patsubst %.S,%.o, $(wildcard $(SRC)/thread/*.S)))
80 endif
82 COBJS = $(filter-out $(FILTER_OBJS),$(COBJ))
83 SOBJS = $(filter-out $(FILTER_OBJS),$(SOBJ))
85 ifdef EFI_BUILD
86 COBJS += $(subst $(SRC)/,,$(CORE_PXE_CSRC:%.c=%.o) fs/pxe/ftp.o fs/pxe/ftp_readdir.o \
87 fs/pxe/http.o fs/pxe/http_readdir.o)
88 endif
90 LIB = libcom32.a
91 LIBS = $(LIB) --whole-archive $(objdir)/com32/lib/libcom32core.a
92 LIBDEP = $(filter-out -% %start%,$(LIBS))
93 LIBOBJS = $(COBJS) $(SOBJS)
95 NASMDEBUG = -g -F dwarf
96 NASMOPT += $(NASMDEBUG)
98 PREPCORE = $(OBJ)/../lzo/prepcore
100 CFLAGS += -D__SYSLINUX_CORE__ -I$(objdir) -DLDLINUX=\"$(LDLINUX)\"
102 # The DATE is set on the make command line when building binaries for
103 # official release. Otherwise, substitute a hex string that is pretty much
104 # guaranteed to be unique to be unique from build to build.
105 ifndef HEXDATE
106 HEXDATE := $(shell $(PERL) $(SRC)/../now.pl $(SRCS))
107 endif
108 ifndef DATE
109 DATE := $(shell sh $(SRC)/../gen-id.sh $(VERSION) $(HEXDATE))
110 endif
112 # Set up the NASM and LD options for the architecture
113 NASM_ELF = "unknown"
114 LD_PIE = "unknown"
115 ifeq ($(ARCH),i386)
116 NASM_ELF = elf
117 LD_PIE = -pie
118 endif
119 ifeq ($(ARCH),x86_64)
120 NASM_ELF = elf64
121 #LD_PIE = --pic-executable
122 LD_PIE =
123 endif
125 ifdef EFI_BUILD
126 all: makeoutputdirs $(filter-out %bios.o,$(COBJS) $(SOBJS)) codepage.o
127 else
128 all: makeoutputdirs $(BTARGET)
129 endif
131 makeoutputdirs:
132 @mkdir -p $(sort $(dir $(COBJ) $(SOBJ)))
134 kwdhash.gen: keywords genhash.pl
135 $(PERL) $(SRC)/genhash.pl < $(SRC)/keywords > $(OBJ)/kwdhash.gen
137 .PRECIOUS: %.elf
139 %.raw: %.elf
140 $(OBJCOPY) -O binary -S $< $(@:.bin=.raw)
142 # GNU make 3.82 gets confused by the first form
143 .PRECIOUS: $(OBJ)/%.raw
145 %.bin: %.raw $(PREPCORE)
146 $(PREPCORE) $< $@
148 %.o: %.asm kwdhash.gen $(OBJ)/../version.gen
149 $(NASM) -f $(NASM_ELF) $(NASMOPT) -DDATE_STR="'$(DATE)'" \
150 -DHEXDATE="$(HEXDATE)" \
151 -D$(ARCH) \
152 -I$(SRC)/ \
153 -l $(@:.o=.lsr) -o $@ -MP -MD $(dir $@).$(notdir $@).d $<
155 AUXLIBS = libisolinux.a libisolinux-debug.a libldlinux.a \
156 libpxelinux.a liblpxelinux.a
157 LDSCRIPT = $(SRC)/$(ARCH)/syslinux.ld
159 %.elf: %.o $(LIBDEP) $(LDSCRIPT) $(AUXLIBS)
160 $(LD) $(LDFLAGS) -Bsymbolic $(LD_PIE) -E --hash-style=gnu -T $(LDSCRIPT) -M -o $@ $< \
161 --start-group $(LIBS) $(subst $(*F).elf,lib$(*F).a,$@) --end-group \
162 > $(@:.elf=.map)
163 $(OBJDUMP) -h $@ > $(@:.elf=.sec)
164 $(PERL) $(SRC)/lstadjust.pl $(@:.elf=.lsr) $(@:.elf=.sec) $(@:.elf=.lst)
166 libisolinux.a: rawcon.o isolinux-c.o
167 rm -f $@
168 $(AR) cq $@ $^
169 $(RANLIB) $@
171 libisolinux-debug.a: libisolinux.a
172 cp $^ $@
174 # Legacy network stack
175 libpxelinux.a: rawcon.o pxelinux-c.o $(PXELINUX_OBJS)
176 rm -f $@
177 $(AR) cq $@ $^
178 $(RANLIB) $@
180 # LwIP network stack
181 liblpxelinux.a: rawcon.o pxelinux-c.o $(LPXELINUX_OBJS)
182 rm -f $@
183 $(AR) cq $@ $^
184 $(RANLIB) $@
186 libldlinux.a: plaincon.o ldlinux-c.o
187 rm -f $@
188 $(AR) cq $@ $^
189 $(RANLIB) $@
191 $(LIB): $(LIBOBJS)
192 rm -f $@
193 $(AR) cq $@ $^
194 $(RANLIB) $@
196 pxelinux.o: pxelinux.asm kwdhash.gen ../version.gen
197 $(NASM) -f $(NASM_ELF) $(NASMOPT) -DDATE_STR="'$(DATE)'" \
198 -DHEXDATE="$(HEXDATE)" \
199 -D$(ARCH) \
200 -I$(SRC)/ \
201 -DIS_LPXELINUX=0 \
202 -l $(@:.o=.lsr) -o $@ -MP -MD $(dir $@).$(notdir $@).d $<
204 pxelinux.0: pxelinux.bin
205 cp -f $< $@
207 lpxelinux.o: pxelinux.asm kwdhash.gen ../version.gen
208 $(NASM) -f $(NASM_ELF) $(NASMOPT) -DDATE_STR="'$(DATE)'" \
209 -DHEXDATE="$(HEXDATE)" \
210 -D$(ARCH) \
211 -I$(SRC)/ \
212 -DIS_LPXELINUX=1 \
213 -l $(@:.o=.lsr) -o $@ -MP -MD $(dir $@).$(notdir $@).d $<
215 lpxelinux.0: lpxelinux.bin
216 cp -f $< $@
218 ldlinux.bss: ldlinux.bin
219 dd if=$< of=$@ bs=512 count=1
221 ldlinux.sys: ldlinux.bin
222 dd if=$< of=$@ bs=512 skip=2
224 codepage.cp: $(OBJ)/../codepage/$(CODEPAGE).cp
225 cp -f $< $@
227 codepage.o: codepage.S codepage.cp
229 install: installer
231 install-lib: installer
233 install-all: install install-lib
235 netinstall: installer
237 tidy dist:
238 find . -type f \( -name '*.o' -o -name '*.a' -o -name '.*.d' \
239 -o -name '*.lst' \) -print | xargs -rt rm -f
240 rm -f codepage.cp *.elf stupid.* patch.offset .depend
241 rm -f *.elf.tmp *.sym
242 rm -f *.lsr *.map *.sec *.raw
243 rm -f $(OBSOLETE) $(LIB)
245 clean: tidy
247 spotless: clean
248 rm -f $(BTARGET) *.bin *_bin.c
250 # Include dependencies file
251 -include $(shell find . -name '.*.d' -print)