Makefile: make gpxe/ depend on core/
[syslinux.git] / Makefile
blob107e5fa7a54df4004b2939d424bc15e50e0817d4
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 # Main Makefile for SYSLINUX
19 # topdir is only set when we are doing a recursive make. Do a bunch of
20 # initialisation if it's unset since this is the first invocation.
22 ifeq ($(topdir),)
24 topdir = $(CURDIR)
27 # Because we need to build modules multiple times, e.g. for BIOS,
28 # efi32, efi64, we output all object and executable files to a
29 # separate object directory for each firmware.
31 # The output directory can be customised by setting the O=/obj/path/
32 # variable when invoking make. If no value is specified the default
33 # directory is the top-level of the Syslinux source.
35 ifeq ("$(origin O)", "command line")
36 OBJDIR := $(O)
37 else
38 OBJDIR = $(topdir)
39 endif
41 # If the output directory does not exist we bail because that is the
42 # least surprising thing to do.
43 cd-output := $(shell cd $(OBJDIR) && /bin/pwd)
44 $(if $(cd-output),, \
45 $(error output directory "$(OBJDIR)" does not exist))
48 # These environment variables are exported to every invocation of
49 # make,
51 # 'topdir' - the top-level directory containing the Syslinux source
52 # 'objdir' - the top-level directory of output files for this firmware
53 # 'MAKEDIR' - contains Makefile fragments
54 # 'OBJDIR' - the top-level directory of output files
56 # There are also a handful of variables that are passed to each
57 # sub-make,
59 # SRC - source tree location of the module being compiled
60 # OBJ - output tree location of the module being compiled
62 # A couple of rules for writing Makefiles,
64 # - Do not use relative paths, use the above variables
65 # - You can write $(SRC) a lot less if you add it to VPATH
68 MAKEDIR = $(topdir)/mk
69 export MAKEDIR topdir OBJDIR
71 include $(MAKEDIR)/syslinux.mk
72 -include $(OBJDIR)/version.mk
74 private-targets = prerel unprerel official release burn isolinux.iso \
75 preupload upload
77 ifeq ($(MAKECMDGOALS),)
78 MAKECMDGOALS += all
79 endif
82 # The 'bios', 'efi32' and 'efi64' are dummy targets. Their only
83 # purpose is to instruct us which output directories need
84 # creating. Which means that we always need a *real* target, such as
85 # 'all', appended to the make goals.
87 firmware = bios efi32 efi64
88 real-target := $(filter-out $(firmware), $(MAKECMDGOALS))
89 real-firmware := $(filter $(firmware), $(MAKECMDGOALS))
91 ifeq ($(real-target),)
92 real-target = all
93 endif
95 ifeq ($(real-firmware),)
96 real-firmware = $(firmware)
97 endif
99 .PHONY: $(filter-out $(private-targets), $(MAKECMDGOALS))
100 $(filter-out $(private-targets), $(MAKECMDGOALS)):
101 $(MAKE) -C $(OBJDIR) -f $(CURDIR)/Makefile SRC="$(topdir)" \
102 OBJ=$(OBJDIR) objdir=$(OBJDIR) $(MAKECMDGOALS)
104 # Hook to add private Makefile targets for the maintainer.
105 -include $(topdir)/Makefile.private
107 else # ifeq ($(topdir),)
109 include $(MAKEDIR)/syslinux.mk
111 # Hook to add private Makefile targets for the maintainer.
112 -include $(topdir)/Makefile.private
115 # The BTARGET refers to objects that are derived from ldlinux.asm; we
116 # like to keep those uniform for debugging reasons; however, distributors
117 # want to recompile the installers (ITARGET).
119 # BOBJECTS and IOBJECTS are the same thing, except used for
120 # installation, so they include objects that may be in subdirectories
121 # with their own Makefiles. Finally, there is a list of those
122 # directories.
125 ifndef EFI_BUILD
126 MODULES = memdisk/memdisk memdump/memdump.com \
127 com32/menu/*.c32 com32/modules/*.c32 com32/mboot/*.c32 \
128 com32/hdt/*.c32 com32/rosh/*.c32 com32/gfxboot/*.c32 \
129 com32/sysdump/*.c32 com32/lua/src/*.c32 com32/chain/*.c32 \
130 com32/lib/*.c32 com32/libutil/*.c32 com32/gpllib/*.c32 \
131 com32/elflink/ldlinux/*.c32 com32/cmenu/libmenu/*.c32
132 else
133 # memdump is BIOS specific code exclude it for EFI
134 # FIXME: Prune other BIOS-centric modules
135 MODULES = com32/menu/*.c32 com32/modules/*.c32 com32/mboot/*.c32 \
136 com32/hdt/*.c32 com32/rosh/*.c32 com32/gfxboot/*.c32 \
137 com32/sysdump/*.c32 com32/lua/src/*.c32 com32/chain/*.c32 \
138 com32/lib/*.c32 com32/libutil/*.c32 com32/gpllib/*.c32 \
139 com32/elflink/ldlinux/*.c32 com32/cmenu/libmenu/*.c32
140 endif
142 # List of module objects that should be installed for all derivatives
143 INSTALLABLE_MODULES = $(MODULES)
145 # syslinux.exe is BTARGET so as to not require everyone to have the
146 # mingw suite installed
147 BTARGET = version.gen version.h $(OBJDIR)/version.mk
148 BOBJECTS = $(BTARGET) \
149 mbr/*.bin \
150 core/pxelinux.0 core/lpxelinux.0 \
151 core/isolinux.bin core/isolinux-debug.bin \
152 gpxe/gpxelinux.0 dos/syslinux.com \
153 win32/syslinux.exe win64/syslinux64.exe \
154 dosutil/*.com dosutil/*.sys \
155 $(MODULES)
157 # BSUBDIRs build the on-target binary components.
158 # ISUBDIRs build the installer (host) components.
160 # Note: libinstaller is both a BSUBDIR and an ISUBDIR. It contains
161 # files that depend only on the B phase, but may have to be regenerated
162 # for "make installer".
164 ifdef EFI_BUILD
166 BSUBDIRS = codepage com32 lzo core mbr sample efi txt
167 ISUBDIRS =
169 INSTALLSUBDIRS = efi
171 else
173 BSUBDIRS = codepage com32 lzo core memdisk mbr memdump gpxe sample \
174 diag libinstaller dos win32 win64 dosutil txt
176 ITARGET =
177 IOBJECTS = $(ITARGET) \
178 utils/gethostip utils/isohybrid utils/mkdiskimage \
179 mtools/syslinux linux/syslinux extlinux/extlinux
180 ISUBDIRS = libinstaller mtools linux extlinux utils
182 # Things to install in /usr/bin
183 INSTALL_BIN = mtools/syslinux
184 # Things to install in /sbin
185 INSTALL_SBIN = extlinux/extlinux
186 # Things to install in /usr/lib/syslinux
187 INSTALL_AUX = core/pxelinux.0 gpxe/gpxelinux.0 gpxe/gpxelinuxk.0 \
188 core/isolinux.bin core/isolinux-debug.bin \
189 dos/syslinux.com core/lpxelinux.0 \
190 mbr/*.bin $(INSTALLABLE_MODULES)
191 INSTALL_AUX_OPT = win32/syslinux.exe win64/syslinux64.exe
192 INSTALL_DIAG = diag/mbr/handoff.bin \
193 diag/geodsp/geodsp1s.img.xz diag/geodsp/geodspms.img.xz
195 # These directories manage their own installables
196 INSTALLSUBDIRS = com32 utils dosutil
198 # Things to install in /boot/extlinux
199 EXTBOOTINSTALL = $(INSTALLABLE_MODULES)
201 # Things to install in /tftpboot
202 NETINSTALLABLE = core/pxelinux.0 gpxe/gpxelinux.0 core/lpxelinux.0 \
203 $(INSTALLABLE_MODULES)
205 endif # ifdef EFI_BUILD
207 .PHONY: subdirs $(BSUBDIRS) $(ISUBDIRS)
209 ifeq ($(HAVE_FIRMWARE),)
211 firmware = bios efi32 efi64
213 # If no firmware was specified the rest of MAKECMDGOALS applies to all
214 # firmware.
215 ifeq ($(filter $(firmware),$(MAKECMDGOALS)),)
216 all strip tidy clean dist spotless install installer: bios efi32 efi64
218 else
220 # Don't do anything for the rest of MAKECMDGOALS at this level. It
221 # will be handled for each of $(firmware).
222 strip tidy clean dist spotless install installer:
224 endif
226 # Convert 'make bios strip' to 'make strip', etc for rest of the Makefiles.
227 MAKECMDGOALS := $(filter-out $(firmware),$(MAKECMDGOALS))
228 ifeq ($(MAKECMDGOALS),)
229 MAKECMDGOALS += all
230 endif
233 # You'd think that we'd be able to use the 'define' directive to
234 # abstract the code for invoking make(1) in the output directory, but
235 # by using 'define' we lose the ability to build in parallel.
237 .PHONY: $(firmware)
238 bios:
239 @mkdir -p $(OBJ)/bios
240 $(MAKE) -C $(OBJ)/bios -f $(SRC)/Makefile SRC="$(SRC)" \
241 objdir=$(OBJ)/bios OBJ=$(OBJ)/bios HAVE_FIRMWARE=1 \
242 ARCH=i386 LDLINUX=ldlinux.c32 $(MAKECMDGOALS)
244 efi32:
245 @mkdir -p $(OBJ)/efi32
246 $(MAKE) -C $(OBJ)/efi32 -f $(SRC)/Makefile SRC="$(SRC)" \
247 objdir=$(OBJ)/efi32 OBJ=$(OBJ)/efi32 HAVE_FIRMWARE=1 \
248 ARCH=i386 BITS=32 EFI_BUILD=1 LDLINUX=ldlinux.e32 \
249 $(MAKECMDGOALS)
251 efi64:
252 @mkdir -p $(OBJ)/efi64
253 $(MAKE) -C $(OBJ)/efi64 -f $(SRC)/Makefile SRC="$(SRC)" \
254 objdir=$(OBJ)/efi64 OBJ=$(OBJ)/efi64 HAVE_FIRMWARE=1 \
255 ARCH=x86_64 BITS=64 EFI_BUILD=1 LDLINUX=ldlinux.e64 \
256 $(MAKECMDGOALS)
258 else # ifeq($(HAVE_FIRMWARE),)
260 all: all-local subdirs
262 all-local: $(BTARGET) $(ITARGET)
263 -ls -l $(BOBJECTS) $(IOBJECTS)
264 subdirs: $(BSUBDIRS) $(ISUBDIRS)
266 $(sort $(ISUBDIRS) $(BSUBDIRS)):
267 @mkdir -p $@
268 $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
269 -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
271 $(ITARGET):
272 @mkdir -p $@
273 $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
274 -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
276 $(BINFILES):
277 @mkdir -p $@
278 $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
279 -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
282 # List the dependencies to help out parallel builds.
283 dos extlinux linux mtools win32 win64: libinstaller
284 libinstaller: core
285 utils: mbr
286 core: com32
287 efi: core
288 gpxe: core
290 installer: installer-local
291 set -e; for i in $(ISUBDIRS); \
292 do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
293 -f $(SRC)/$$i/Makefile all; done
296 installer-local: $(ITARGET) $(BINFILES)
298 strip: strip-local
299 set -e; for i in $(ISUBDIRS); \
300 do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
301 -f $(SRC)/$$i/Makefile strip; done
302 -ls -l $(BOBJECTS) $(IOBJECTS)
304 strip-local:
306 version.gen: $(topdir)/version $(topdir)/version.pl
307 $(PERL) $(topdir)/version.pl $< $@ '%define < @'
308 version.h: $(topdir)/version $(topdir)/version.pl
309 $(PERL) $(topdir)/version.pl $< $@ '#define < @'
311 local-install: installer
312 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
313 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
314 mkdir -m 755 -p $(INSTALLROOT)$(SBINDIR)
315 install -m 755 -c $(INSTALL_SBIN) $(INSTALLROOT)$(SBINDIR)
316 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
317 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
318 -install -m 644 -c $(INSTALL_AUX_OPT) $(INSTALLROOT)$(AUXDIR)
319 mkdir -m 755 -p $(INSTALLROOT)$(DIAGDIR)
320 install -m 644 -c $(INSTALL_DIAG) $(INSTALLROOT)$(DIAGDIR)
321 mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man1
322 install -m 644 -c $(topdir)/man/*.1 $(INSTALLROOT)$(MANDIR)/man1
323 : mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man8
324 : install -m 644 -c man/*.8 $(INSTALLROOT)$(MANDIR)/man8
326 ifndef EFI_BUILD
327 install: local-install
328 set -e ; for i in $(INSTALLSUBDIRS) ; \
329 do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
330 -f $(SRC)/$$i/Makefile $@; done
331 else
332 install:
333 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)/efi$(BITS)
334 set -e ; for i in $(INSTALLSUBDIRS) ; \
335 do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
336 BITS="$(BITS)" AUXDIR="$(AUXDIR)/efi$(BITS)" \
337 -f $(SRC)/$$i/Makefile $@; done
338 -install -m 644 $(INSTALLABLE_MODULES) $(INSTALLROOT)$(AUXDIR)/efi$(BITS)
339 install -m 644 com32/elflink/ldlinux/$(LDLINUX) $(INSTALLROOT)$(AUXDIR)/efi$(BITS)
340 endif
342 netinstall: installer
343 mkdir -p $(INSTALLROOT)$(TFTPBOOT)
344 install -m 644 $(NETINSTALLABLE) $(INSTALLROOT)$(TFTPBOOT)
346 extbootinstall: installer
347 mkdir -m 755 -p $(INSTALLROOT)$(EXTLINUXDIR)
348 install -m 644 $(EXTBOOTINSTALL) $(INSTALLROOT)$(EXTLINUXDIR)
350 install-all: install netinstall extbootinstall
352 local-tidy:
353 rm -f *.o *.elf *_bin.c stupid.* patch.offset
354 rm -f *.lsr *.lst *.map *.sec *.tmp
355 rm -f $(OBSOLETE)
357 tidy: local-tidy $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS)
359 local-clean:
360 rm -f $(ITARGET)
362 clean: local-tidy local-clean $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS)
364 local-dist:
365 find . \( -name '*~' -o -name '#*' -o -name core \
366 -o -name '.*.d' -o -name .depend \) -type f -print0 \
367 | xargs -0rt rm -f
369 dist: local-dist local-tidy $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS)
371 local-spotless:
372 rm -f $(BTARGET) .depend *.so.*
374 spotless: local-clean local-dist local-spotless $(BESUBDIRS) $(IESUBDIRS) $(ISUBDIRS) $(BSUBDIRS)
376 # Shortcut to build linux/syslinux using klibc
377 klibc:
378 $(MAKE) clean
379 $(MAKE) CC=klcc ITARGET= ISUBDIRS='linux extlinux' BSUBDIRS=
380 endif # ifeq ($(HAVE_FIRMWARE),)
382 endif # ifeq ($(topdir),)
385 # Common rules that are needed by every invocation of make.
387 $(OBJDIR)/version.mk: $(topdir)/version $(topdir)/version.pl
388 $(PERL) $(topdir)/version.pl $< $@ '< := @'