zonelist: allow syslinux_memmap_type() to demote SMT_FREE to SMT_TERMINAL
[syslinux.git] / Makefile
bloba9b515c3fd35df17a1c3f738847863526350c1c3
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/cmenu/libmenu/*.c32 com32/elflink/ldlinux/$(LDLINUX)
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 NETINSTALLABLE = efi/syslinux.efi $(INSTALLABLE_MODULES)
173 else
175 BSUBDIRS = codepage com32 lzo core memdisk mbr memdump gpxe sample \
176 diag libinstaller dos win32 win64 dosutil txt
178 ITARGET =
179 IOBJECTS = $(ITARGET) \
180 utils/gethostip utils/isohybrid utils/mkdiskimage \
181 mtools/syslinux linux/syslinux extlinux/extlinux
182 ISUBDIRS = libinstaller mtools linux extlinux utils
184 # Things to install in /usr/bin
185 INSTALL_BIN = mtools/syslinux
186 # Things to install in /sbin
187 INSTALL_SBIN = extlinux/extlinux
188 # Things to install in /usr/lib/syslinux
189 INSTALL_AUX = core/pxelinux.0 gpxe/gpxelinux.0 gpxe/gpxelinuxk.0 \
190 core/isolinux.bin core/isolinux-debug.bin \
191 dos/syslinux.com core/lpxelinux.0 \
192 mbr/*.bin $(INSTALLABLE_MODULES)
193 INSTALL_AUX_OPT = win32/syslinux.exe win64/syslinux64.exe
194 INSTALL_DIAG = diag/mbr/handoff.bin \
195 diag/geodsp/geodsp1s.img.xz diag/geodsp/geodspms.img.xz
197 # These directories manage their own installables
198 INSTALLSUBDIRS = com32 utils dosutil
200 # Things to install in /boot/extlinux
201 EXTBOOTINSTALL = $(INSTALLABLE_MODULES)
203 # Things to install in /tftpboot
204 NETINSTALLABLE = core/pxelinux.0 gpxe/gpxelinux.0 core/lpxelinux.0 \
205 $(INSTALLABLE_MODULES)
207 endif # ifdef EFI_BUILD
209 .PHONY: subdirs $(BSUBDIRS) $(ISUBDIRS)
211 ifeq ($(HAVE_FIRMWARE),)
213 firmware = bios efi32 efi64
215 # If no firmware was specified the rest of MAKECMDGOALS applies to all
216 # firmware.
217 ifeq ($(filter $(firmware),$(MAKECMDGOALS)),)
218 all strip tidy clean dist spotless install installer netinstall: bios efi32 efi64
220 else
222 # Don't do anything for the rest of MAKECMDGOALS at this level. It
223 # will be handled for each of $(firmware).
224 strip tidy clean dist spotless install installer netinstall:
226 endif
228 # Convert 'make bios strip' to 'make strip', etc for rest of the Makefiles.
229 MAKECMDGOALS := $(filter-out $(firmware),$(MAKECMDGOALS))
230 ifeq ($(MAKECMDGOALS),)
231 MAKECMDGOALS += all
232 endif
235 # You'd think that we'd be able to use the 'define' directive to
236 # abstract the code for invoking make(1) in the output directory, but
237 # by using 'define' we lose the ability to build in parallel.
239 .PHONY: $(firmware)
240 bios:
241 @mkdir -p $(OBJ)/bios
242 $(MAKE) -C $(OBJ)/bios -f $(SRC)/Makefile SRC="$(SRC)" \
243 objdir=$(OBJ)/bios OBJ=$(OBJ)/bios HAVE_FIRMWARE=1 \
244 ARCH=i386 LDLINUX=ldlinux.c32 $(MAKECMDGOALS)
246 efi32:
247 @mkdir -p $(OBJ)/efi32
248 $(MAKE) -C $(OBJ)/efi32 -f $(SRC)/Makefile SRC="$(SRC)" \
249 objdir=$(OBJ)/efi32 OBJ=$(OBJ)/efi32 HAVE_FIRMWARE=1 \
250 ARCH=i386 BITS=32 EFI_BUILD=1 LDLINUX=ldlinux.e32 \
251 $(MAKECMDGOALS)
253 efi64:
254 @mkdir -p $(OBJ)/efi64
255 $(MAKE) -C $(OBJ)/efi64 -f $(SRC)/Makefile SRC="$(SRC)" \
256 objdir=$(OBJ)/efi64 OBJ=$(OBJ)/efi64 HAVE_FIRMWARE=1 \
257 ARCH=x86_64 BITS=64 EFI_BUILD=1 LDLINUX=ldlinux.e64 \
258 $(MAKECMDGOALS)
260 else # ifeq($(HAVE_FIRMWARE),)
262 all: all-local subdirs
264 all-local: $(BTARGET) $(ITARGET)
265 -ls -l $(BOBJECTS) $(IOBJECTS)
266 subdirs: $(BSUBDIRS) $(ISUBDIRS)
268 $(sort $(ISUBDIRS) $(BSUBDIRS)):
269 @mkdir -p $@
270 $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
271 -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
273 $(ITARGET):
274 @mkdir -p $@
275 $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
276 -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
278 $(BINFILES):
279 @mkdir -p $@
280 $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
281 -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
284 # List the dependencies to help out parallel builds.
285 dos extlinux linux mtools win32 win64: libinstaller
286 libinstaller: core
287 utils: mbr
288 core: com32
289 efi: core
290 gpxe: core
292 installer: installer-local
293 set -e; for i in $(ISUBDIRS); \
294 do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
295 -f $(SRC)/$$i/Makefile all; done
298 installer-local: $(ITARGET) $(BINFILES)
300 strip: strip-local
301 set -e; for i in $(ISUBDIRS); \
302 do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
303 -f $(SRC)/$$i/Makefile strip; done
304 -ls -l $(BOBJECTS) $(IOBJECTS)
306 strip-local:
308 version.gen: $(topdir)/version $(topdir)/version.pl
309 $(PERL) $(topdir)/version.pl $< $@ '%define < @'
310 version.h: $(topdir)/version $(topdir)/version.pl
311 $(PERL) $(topdir)/version.pl $< $@ '#define < @'
313 local-install: installer
314 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
315 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
316 mkdir -m 755 -p $(INSTALLROOT)$(SBINDIR)
317 install -m 755 -c $(INSTALL_SBIN) $(INSTALLROOT)$(SBINDIR)
318 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
319 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
320 -install -m 644 -c $(INSTALL_AUX_OPT) $(INSTALLROOT)$(AUXDIR)
321 mkdir -m 755 -p $(INSTALLROOT)$(DIAGDIR)
322 install -m 644 -c $(INSTALL_DIAG) $(INSTALLROOT)$(DIAGDIR)
323 mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man1
324 install -m 644 -c $(topdir)/man/*.1 $(INSTALLROOT)$(MANDIR)/man1
325 : mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man8
326 : install -m 644 -c man/*.8 $(INSTALLROOT)$(MANDIR)/man8
328 ifndef EFI_BUILD
329 install: local-install
330 set -e ; for i in $(INSTALLSUBDIRS) ; \
331 do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
332 -f $(SRC)/$$i/Makefile $@; done
333 else
334 install:
335 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)/efi$(BITS)
336 set -e ; for i in $(INSTALLSUBDIRS) ; \
337 do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
338 BITS="$(BITS)" AUXDIR="$(AUXDIR)/efi$(BITS)" \
339 -f $(SRC)/$$i/Makefile $@; done
340 -install -m 644 $(INSTALLABLE_MODULES) $(INSTALLROOT)$(AUXDIR)/efi$(BITS)
341 install -m 644 com32/elflink/ldlinux/$(LDLINUX) $(INSTALLROOT)$(AUXDIR)/efi$(BITS)
342 endif
344 ifdef EFI_BUILD
345 netinstall:
346 mkdir -p $(INSTALLROOT)$(TFTPBOOT)/efi$(BITS)
347 install -m 644 $(NETINSTALLABLE) $(INSTALLROOT)$(TFTPBOOT)/efi$(BITS)
348 else
349 netinstall: installer
350 mkdir -p $(INSTALLROOT)$(TFTPBOOT)
351 install -m 644 $(NETINSTALLABLE) $(INSTALLROOT)$(TFTPBOOT)
352 endif
354 extbootinstall: installer
355 mkdir -m 755 -p $(INSTALLROOT)$(EXTLINUXDIR)
356 install -m 644 $(EXTBOOTINSTALL) $(INSTALLROOT)$(EXTLINUXDIR)
358 install-all: install netinstall extbootinstall
360 local-tidy:
361 rm -f *.o *.elf *_bin.c stupid.* patch.offset
362 rm -f *.lsr *.lst *.map *.sec *.tmp
363 rm -f $(OBSOLETE)
365 tidy: local-tidy $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS)
367 local-clean:
368 rm -f $(ITARGET)
370 clean: local-tidy local-clean $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS)
372 local-dist:
373 find . \( -name '*~' -o -name '#*' -o -name core \
374 -o -name '.*.d' -o -name .depend \) -type f -print0 \
375 | xargs -0rt rm -f
377 dist: local-dist local-tidy $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS)
379 local-spotless:
380 rm -f $(BTARGET) .depend *.so.*
382 spotless: local-clean local-dist local-spotless $(BESUBDIRS) $(IESUBDIRS) $(ISUBDIRS) $(BSUBDIRS)
384 # Shortcut to build linux/syslinux using klibc
385 klibc:
386 $(MAKE) clean
387 $(MAKE) CC=klcc ITARGET= ISUBDIRS='linux extlinux' BSUBDIRS=
388 endif # ifeq ($(HAVE_FIRMWARE),)
390 endif # ifeq ($(topdir),)
393 # Common rules that are needed by every invocation of make.
395 $(OBJDIR)/version.mk: $(topdir)/version $(topdir)/version.pl
396 $(PERL) $(topdir)/version.pl $< $@ '< := @'