1 | ## ----------------------------------------------------------------------- |
---|
2 | ## |
---|
3 | ## Copyright 1998-2009 H. Peter Anvin - All Rights Reserved |
---|
4 | ## Copyright 2009-2014 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. |
---|
11 | ## |
---|
12 | ## ----------------------------------------------------------------------- |
---|
13 | |
---|
14 | # |
---|
15 | # Makefile for the SYSLINUX core |
---|
16 | # |
---|
17 | |
---|
18 | VPATH = $(SRC) |
---|
19 | |
---|
20 | # No builtin rules |
---|
21 | MAKEFLAGS += -r |
---|
22 | MAKE += -r |
---|
23 | |
---|
24 | include $(MAKEDIR)/embedded.mk |
---|
25 | -include $(objdir)/version.mk |
---|
26 | |
---|
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 |
---|
30 | |
---|
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 |
---|
35 | |
---|
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 |
---|
40 | |
---|
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) |
---|
49 | |
---|
50 | COBJ := $(subst $(SRC)/,,$(patsubst %.c,%.o,$(CSRC))) |
---|
51 | SOBJ := $(subst $(SRC)/,,$(patsubst %.S,%.o,$(SSRC))) |
---|
52 | |
---|
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) |
---|
57 | |
---|
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) |
---|
63 | |
---|
64 | PXELINUX_CSRC = $(CORE_PXE_CSRC) \ |
---|
65 | $(shell find $(SRC)/legacynet -name '*.c' -print) |
---|
66 | |
---|
67 | LPXELINUX_OBJS = $(subst $(SRC)/,,$(LPXELINUX_CSRC:%.c=%.o)) |
---|
68 | PXELINUX_OBJS = $(subst $(SRC)/,,$(PXELINUX_CSRC:%.c=%.o)) |
---|
69 | |
---|
70 | UNITTEST_CSRC = $(shell find $(SRC) -path '*/tests/*.c' -print) |
---|
71 | UNITTEST_OBJS = $(subst $(SRC)/,,$(UNITTEST_CSRC:%.c=%.o)) |
---|
72 | |
---|
73 | # Don't include console and network stack specific objects or unit tests |
---|
74 | FILTER_OBJS = %rawcon.o %plaincon.o %pxelinux-c.o %ldlinux-c.o \ |
---|
75 | %isolinux-c.o %localboot.o %pxeboot.o \ |
---|
76 | $(subst $(OBJ)/,,$(UNITTEST_OBJS)) \ |
---|
77 | $(subst $(OBJ)/,,$(LPXELINUX_OBJS)) \ |
---|
78 | $(subst $(OBJ)/,,$(PXELINUX_OBJS)) |
---|
79 | |
---|
80 | ifdef EFI_BUILD |
---|
81 | # EFI is single-threaded, and doesn't use the LZO assembly decoder |
---|
82 | FILTER_OBJS += $(subst $(SRC)/,, \ |
---|
83 | $(patsubst %.S,%.o, $(wildcard $(SRC)/lzo/*.S)) \ |
---|
84 | $(patsubst %.c,%.o, $(wildcard $(SRC)/thread/*.c)) \ |
---|
85 | $(patsubst %.S,%.o, $(wildcard $(SRC)/thread/*.S))) |
---|
86 | endif |
---|
87 | |
---|
88 | COBJS = $(filter-out $(FILTER_OBJS),$(COBJ)) |
---|
89 | SOBJS = $(filter-out $(FILTER_OBJS),$(SOBJ)) |
---|
90 | |
---|
91 | ifdef EFI_BUILD |
---|
92 | COBJS += $(subst $(SRC)/,,$(CORE_PXE_CSRC:%.c=%.o) fs/pxe/ftp.o fs/pxe/ftp_readdir.o \ |
---|
93 | fs/pxe/http.o fs/pxe/http_readdir.o) |
---|
94 | endif |
---|
95 | |
---|
96 | LIB = libcom32.a |
---|
97 | LIBS = $(LIB) --whole-archive $(objdir)/com32/lib/libcom32core.a |
---|
98 | LIBDEP = $(filter-out -% %start%,$(LIBS)) |
---|
99 | LIBOBJS = $(COBJS) $(SOBJS) |
---|
100 | |
---|
101 | NASMDEBUG = -g -F dwarf |
---|
102 | NASMOPT += $(NASMDEBUG) |
---|
103 | |
---|
104 | PREPCORE = $(OBJ)/../lzo/prepcore |
---|
105 | |
---|
106 | CFLAGS += -D__SYSLINUX_CORE__ -D__FIRMWARE_$(FIRMWARE)__ \ |
---|
107 | -I$(objdir) -DLDLINUX=\"$(LDLINUX)\" |
---|
108 | |
---|
109 | # The DATE is set on the make command line when building binaries for |
---|
110 | # official release. Otherwise, substitute a hex string that is pretty much |
---|
111 | # guaranteed to be unique to be unique from build to build. |
---|
112 | ifndef HEXDATE |
---|
113 | HEXDATE := $(shell $(PERL) $(SRC)/../now.pl $(SRCS)) |
---|
114 | endif |
---|
115 | ifndef DATE |
---|
116 | DATE := $(shell sh $(SRC)/../gen-id.sh $(VERSION) $(HEXDATE)) |
---|
117 | endif |
---|
118 | |
---|
119 | # Set up the NASM and LD options for the architecture |
---|
120 | NASM_ELF = "unknown" |
---|
121 | LD_PIE = "unknown" |
---|
122 | ifeq ($(ARCH),i386) |
---|
123 | NASM_ELF = elf |
---|
124 | LD_PIE = -pie |
---|
125 | endif |
---|
126 | ifeq ($(ARCH),x86_64) |
---|
127 | NASM_ELF = elf64 |
---|
128 | #LD_PIE = --pic-executable |
---|
129 | LD_PIE = |
---|
130 | endif |
---|
131 | |
---|
132 | ifdef EFI_BUILD |
---|
133 | all: makeoutputdirs $(filter-out %bios.o,$(COBJS) $(SOBJS)) codepage.o |
---|
134 | else |
---|
135 | all: makeoutputdirs $(BTARGET) |
---|
136 | endif |
---|
137 | |
---|
138 | makeoutputdirs: |
---|
139 | @mkdir -p $(sort $(dir $(COBJ) $(SOBJ))) |
---|
140 | |
---|
141 | kwdhash.gen: keywords genhash.pl |
---|
142 | $(PERL) $(SRC)/genhash.pl < $(SRC)/keywords > $(OBJ)/kwdhash.gen |
---|
143 | |
---|
144 | .PRECIOUS: %.elf |
---|
145 | |
---|
146 | %.raw: %.elf |
---|
147 | $(OBJCOPY) -O binary -S $< $(@:.bin=.raw) |
---|
148 | |
---|
149 | # GNU make 3.82 gets confused by the first form |
---|
150 | .PRECIOUS: $(OBJ)/%.raw |
---|
151 | |
---|
152 | %.bin: %.raw $(PREPCORE) |
---|
153 | $(PREPCORE) $< $@ |
---|
154 | |
---|
155 | %.o: %.asm kwdhash.gen $(OBJ)/../version.gen |
---|
156 | $(NASM) -f $(NASM_ELF) $(NASMOPT) -DDATE_STR="'$(DATE)'" \ |
---|
157 | -DHEXDATE="$(HEXDATE)" \ |
---|
158 | -D$(ARCH) \ |
---|
159 | -I$(SRC)/ \ |
---|
160 | -l $(@:.o=.lsr) -o $@ -MP -MD $(dir $@).$(notdir $@).d $< |
---|
161 | |
---|
162 | AUXLIBS = libisolinux.a libisolinux-debug.a libldlinux.a \ |
---|
163 | libpxelinux.a liblpxelinux.a |
---|
164 | LDSCRIPT = $(SRC)/$(ARCH)/syslinux.ld |
---|
165 | |
---|
166 | %.elf: %.o $(LIBDEP) $(LDSCRIPT) $(AUXLIBS) |
---|
167 | $(LD) $(LDFLAGS) -Bsymbolic $(LD_PIE) -E --hash-style=gnu -T $(LDSCRIPT) -M -o $@ $< \ |
---|
168 | --start-group $(LIBS) $(subst $(*F).elf,lib$(*F).a,$@) --end-group \ |
---|
169 | > $(@:.elf=.map) |
---|
170 | $(OBJDUMP) -h $@ > $(@:.elf=.sec) |
---|
171 | $(PERL) $(SRC)/lstadjust.pl $(@:.elf=.lsr) $(@:.elf=.sec) $(@:.elf=.lst) |
---|
172 | |
---|
173 | libisolinux.a: rawcon.o localboot.o isolinux-c.o |
---|
174 | rm -f $@ |
---|
175 | $(AR) cq $@ $^ |
---|
176 | $(RANLIB) $@ |
---|
177 | |
---|
178 | libisolinux-debug.a: libisolinux.a |
---|
179 | cp $^ $@ |
---|
180 | |
---|
181 | # Legacy network stack |
---|
182 | libpxelinux.a: rawcon.o pxeboot.o pxelinux-c.o $(PXELINUX_OBJS) |
---|
183 | rm -f $@ |
---|
184 | $(AR) cq $@ $^ |
---|
185 | $(RANLIB) $@ |
---|
186 | |
---|
187 | # LwIP network stack |
---|
188 | liblpxelinux.a: rawcon.o pxeboot.o pxelinux-c.o $(LPXELINUX_OBJS) |
---|
189 | rm -f $@ |
---|
190 | $(AR) cq $@ $^ |
---|
191 | $(RANLIB) $@ |
---|
192 | |
---|
193 | libldlinux.a: plaincon.o localboot.o ldlinux-c.o |
---|
194 | rm -f $@ |
---|
195 | $(AR) cq $@ $^ |
---|
196 | $(RANLIB) $@ |
---|
197 | |
---|
198 | $(LIB): $(LIBOBJS) |
---|
199 | rm -f $@ |
---|
200 | $(AR) cq $@ $^ |
---|
201 | $(RANLIB) $@ |
---|
202 | |
---|
203 | pxelinux.o: pxelinux.asm kwdhash.gen ../version.gen |
---|
204 | $(NASM) -f $(NASM_ELF) $(NASMOPT) -DDATE_STR="'$(DATE)'" \ |
---|
205 | -DHEXDATE="$(HEXDATE)" \ |
---|
206 | -D$(ARCH) \ |
---|
207 | -I$(SRC)/ \ |
---|
208 | -DIS_LPXELINUX=0 \ |
---|
209 | -l $(@:.o=.lsr) -o $@ -MP -MD $(dir $@).$(notdir $@).d $< |
---|
210 | |
---|
211 | pxelinux.0: pxelinux.bin |
---|
212 | cp -f $< $@ |
---|
213 | |
---|
214 | lpxelinux.o: pxelinux.asm kwdhash.gen ../version.gen |
---|
215 | $(NASM) -f $(NASM_ELF) $(NASMOPT) -DDATE_STR="'$(DATE)'" \ |
---|
216 | -DHEXDATE="$(HEXDATE)" \ |
---|
217 | -D$(ARCH) \ |
---|
218 | -I$(SRC)/ \ |
---|
219 | -DIS_LPXELINUX=1 \ |
---|
220 | -l $(@:.o=.lsr) -o $@ -MP -MD $(dir $@).$(notdir $@).d $< |
---|
221 | |
---|
222 | lpxelinux.0: lpxelinux.bin |
---|
223 | cp -f $< $@ |
---|
224 | |
---|
225 | ldlinux.bss: ldlinux.bin |
---|
226 | dd if=$< of=$@ bs=512 count=1 |
---|
227 | |
---|
228 | ldlinux.sys: ldlinux.bin |
---|
229 | dd if=$< of=$@ bs=512 skip=2 |
---|
230 | |
---|
231 | codepage.cp: $(OBJ)/../codepage/$(CODEPAGE).cp |
---|
232 | cp -f $< $@ |
---|
233 | |
---|
234 | codepage.o: codepage.S codepage.cp |
---|
235 | |
---|
236 | install: installer |
---|
237 | |
---|
238 | install-lib: installer |
---|
239 | |
---|
240 | install-all: install install-lib |
---|
241 | |
---|
242 | netinstall: installer |
---|
243 | |
---|
244 | tidy dist: |
---|
245 | find . -type f \( -name '*.o' -o -name '*.a' -o -name '.*.d' \ |
---|
246 | -o -name '*.lst' \) -print | xargs -rt rm -f |
---|
247 | rm -f codepage.cp *.elf stupid.* patch.offset .depend |
---|
248 | rm -f *.elf.tmp *.sym |
---|
249 | rm -f *.lsr *.map *.sec *.raw |
---|
250 | rm -f $(OBSOLETE) $(LIB) |
---|
251 | |
---|
252 | clean: tidy |
---|
253 | |
---|
254 | spotless: clean |
---|
255 | rm -f $(BTARGET) *.bin *_bin.c |
---|
256 | |
---|
257 | # Include dependencies file |
---|
258 | -include $(shell find . -name '.*.d' -print) |
---|