Adding upstream version 6.01~pre5+dfsg.
[syslinux-debian/hramrach.git] / core / Makefile
blobf795a5c8502e79183acd343b39c2b906b3b8cf93
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 \
72 %isolinux-c.o %localboot.o %pxeboot.o \
73 $(subst $(OBJ)/,,$(LPXELINUX_OBJS)) \
74 $(subst $(OBJ)/,,$(PXELINUX_OBJS))
76 ifdef EFI_BUILD
77 # EFI is single-threaded.
78 FILTER_OBJS += $(subst $(SRC)/,, \
79 $(patsubst %.c,%.o, $(wildcard $(SRC)/thread/*.c)) \
80 $(patsubst %.S,%.o, $(wildcard $(SRC)/thread/*.S)))
81 endif
83 COBJS = $(filter-out $(FILTER_OBJS),$(COBJ))
84 SOBJS = $(filter-out $(FILTER_OBJS),$(SOBJ))
86 ifdef EFI_BUILD
87 COBJS += $(subst $(SRC)/,,$(CORE_PXE_CSRC:%.c=%.o) fs/pxe/ftp.o fs/pxe/ftp_readdir.o \
88 fs/pxe/http.o fs/pxe/http_readdir.o)
89 endif
91 LIB = libcom32.a
92 LIBS = $(LIB) --whole-archive $(objdir)/com32/lib/libcom32core.a
93 LIBDEP = $(filter-out -% %start%,$(LIBS))
94 LIBOBJS = $(COBJS) $(SOBJS)
96 NASMDEBUG = -g -F dwarf
97 NASMOPT += $(NASMDEBUG)
99 PREPCORE = $(OBJ)/../lzo/prepcore
101 CFLAGS += -D__SYSLINUX_CORE__ -I$(objdir) -DLDLINUX=\"$(LDLINUX)\"
103 # The DATE is set on the make command line when building binaries for
104 # official release. Otherwise, substitute a hex string that is pretty much
105 # guaranteed to be unique to be unique from build to build.
106 ifndef HEXDATE
107 HEXDATE := $(shell $(PERL) $(SRC)/../now.pl $(SRCS))
108 endif
109 ifndef DATE
110 DATE := $(shell sh $(SRC)/../gen-id.sh $(VERSION) $(HEXDATE))
111 endif
113 # Set up the NASM and LD options for the architecture
114 NASM_ELF = "unknown"
115 LD_PIE = "unknown"
116 ifeq ($(ARCH),i386)
117 NASM_ELF = elf
118 LD_PIE = -pie
119 endif
120 ifeq ($(ARCH),x86_64)
121 NASM_ELF = elf64
122 #LD_PIE = --pic-executable
123 LD_PIE =
124 endif
126 ifdef EFI_BUILD
127 all: makeoutputdirs $(filter-out %bios.o,$(COBJS) $(SOBJS)) codepage.o
128 else
129 all: makeoutputdirs $(BTARGET)
130 endif
132 makeoutputdirs:
133 @mkdir -p $(sort $(dir $(COBJ) $(SOBJ)))
135 kwdhash.gen: keywords genhash.pl
136 $(PERL) $(SRC)/genhash.pl < $(SRC)/keywords > $(OBJ)/kwdhash.gen
138 .PRECIOUS: %.elf
140 %.raw: %.elf
141 $(OBJCOPY) -O binary -S $< $(@:.bin=.raw)
143 # GNU make 3.82 gets confused by the first form
144 .PRECIOUS: $(OBJ)/%.raw
146 %.bin: %.raw $(PREPCORE)
147 $(PREPCORE) $< $@
149 %.o: %.asm kwdhash.gen $(OBJ)/../version.gen
150 $(NASM) -f $(NASM_ELF) $(NASMOPT) -DDATE_STR="'$(DATE)'" \
151 -DHEXDATE="$(HEXDATE)" \
152 -D$(ARCH) \
153 -I$(SRC)/ \
154 -l $(@:.o=.lsr) -o $@ -MP -MD $(dir $@).$(notdir $@).d $<
156 AUXLIBS = libisolinux.a libisolinux-debug.a libldlinux.a \
157 libpxelinux.a liblpxelinux.a
158 LDSCRIPT = $(SRC)/$(ARCH)/syslinux.ld
160 %.elf: %.o $(LIBDEP) $(LDSCRIPT) $(AUXLIBS)
161 $(LD) $(LDFLAGS) -Bsymbolic $(LD_PIE) -E --hash-style=gnu -T $(LDSCRIPT) -M -o $@ $< \
162 --start-group $(LIBS) $(subst $(*F).elf,lib$(*F).a,$@) --end-group \
163 > $(@:.elf=.map)
164 $(OBJDUMP) -h $@ > $(@:.elf=.sec)
165 $(PERL) $(SRC)/lstadjust.pl $(@:.elf=.lsr) $(@:.elf=.sec) $(@:.elf=.lst)
167 libisolinux.a: rawcon.o localboot.o isolinux-c.o
168 rm -f $@
169 $(AR) cq $@ $^
170 $(RANLIB) $@
172 libisolinux-debug.a: libisolinux.a
173 cp $^ $@
175 # Legacy network stack
176 libpxelinux.a: rawcon.o pxeboot.o pxelinux-c.o $(PXELINUX_OBJS)
177 rm -f $@
178 $(AR) cq $@ $^
179 $(RANLIB) $@
181 # LwIP network stack
182 liblpxelinux.a: rawcon.o pxeboot.o pxelinux-c.o $(LPXELINUX_OBJS)
183 rm -f $@
184 $(AR) cq $@ $^
185 $(RANLIB) $@
187 libldlinux.a: plaincon.o localboot.o ldlinux-c.o
188 rm -f $@
189 $(AR) cq $@ $^
190 $(RANLIB) $@
192 $(LIB): $(LIBOBJS)
193 rm -f $@
194 $(AR) cq $@ $^
195 $(RANLIB) $@
197 pxelinux.o: pxelinux.asm kwdhash.gen ../version.gen
198 $(NASM) -f $(NASM_ELF) $(NASMOPT) -DDATE_STR="'$(DATE)'" \
199 -DHEXDATE="$(HEXDATE)" \
200 -D$(ARCH) \
201 -I$(SRC)/ \
202 -DIS_LPXELINUX=0 \
203 -l $(@:.o=.lsr) -o $@ -MP -MD $(dir $@).$(notdir $@).d $<
205 pxelinux.0: pxelinux.bin
206 cp -f $< $@
208 lpxelinux.o: pxelinux.asm kwdhash.gen ../version.gen
209 $(NASM) -f $(NASM_ELF) $(NASMOPT) -DDATE_STR="'$(DATE)'" \
210 -DHEXDATE="$(HEXDATE)" \
211 -D$(ARCH) \
212 -I$(SRC)/ \
213 -DIS_LPXELINUX=1 \
214 -l $(@:.o=.lsr) -o $@ -MP -MD $(dir $@).$(notdir $@).d $<
216 lpxelinux.0: lpxelinux.bin
217 cp -f $< $@
219 ldlinux.bss: ldlinux.bin
220 dd if=$< of=$@ bs=512 count=1
222 ldlinux.sys: ldlinux.bin
223 dd if=$< of=$@ bs=512 skip=2
225 codepage.cp: $(OBJ)/../codepage/$(CODEPAGE).cp
226 cp -f $< $@
228 codepage.o: codepage.S codepage.cp
230 install: installer
232 install-lib: installer
234 install-all: install install-lib
236 netinstall: installer
238 tidy dist:
239 find . -type f \( -name '*.o' -o -name '*.a' -o -name '.*.d' \
240 -o -name '*.lst' \) -print | xargs -rt rm -f
241 rm -f codepage.cp *.elf stupid.* patch.offset .depend
242 rm -f *.elf.tmp *.sym
243 rm -f *.lsr *.map *.sec *.raw
244 rm -f $(OBSOLETE) $(LIB)
246 clean: tidy
248 spotless: clean
249 rm -f $(BTARGET) *.bin *_bin.c
251 # Include dependencies file
252 -include $(shell find . -name '.*.d' -print)