dmi: check both the AC and ID flags at the same time
[syslinux.git] / Makefile
blobb472945b842ade88343bab8a4e8540135dc0f70c
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.
12 ## -----------------------------------------------------------------------
15 # Main Makefile for SYSLINUX
18 all_firmware := bios efi32 efi64
21 # topdir is only set when we are doing a recursive make. Do a bunch of
22 # initialisation if it's unset since this is the first invocation.
24 ifeq ($(topdir),)
26 topdir = $(CURDIR)
29 # Because we need to build modules multiple times, e.g. for BIOS,
30 # efi32, efi64, we output all object and executable files to a
31 # separate object directory for each firmware.
33 # The output directory can be customised by setting the O=/obj/path/
34 # variable when invoking make. If no value is specified the default
35 # directory is the top-level of the Syslinux source.
37 ifeq ("$(origin O)", "command line")
38 OBJDIR := $(O)
39 else
40 OBJDIR = $(topdir)
41 endif
43 # If the output directory does not exist we bail because that is the
44 # least surprising thing to do.
45 cd-output := $(shell cd $(OBJDIR) && /bin/pwd)
46 $(if $(cd-output),, \
47 $(error output directory "$(OBJDIR)" does not exist))
50 # These environment variables are exported to every invocation of
51 # make,
53 # 'topdir' - the top-level directory containing the Syslinux source
54 # 'objdir' - the top-level directory of output files for this firmware
55 # 'MAKEDIR' - contains Makefile fragments
56 # 'OBJDIR' - the top-level directory of output files
58 # There are also a handful of variables that are passed to each
59 # sub-make,
61 # SRC - source tree location of the module being compiled
62 # OBJ - output tree location of the module being compiled
64 # A couple of rules for writing Makefiles,
66 # - Do not use relative paths, use the above variables
67 # - You can write $(SRC) a lot less if you add it to VPATH
70 MAKEDIR = $(topdir)/mk
71 export MAKEDIR topdir OBJDIR
73 include $(MAKEDIR)/syslinux.mk
74 -include $(OBJDIR)/version.mk
76 private-targets = prerel unprerel official release burn isolinux.iso \
77 preupload upload test unittest regression spotless
79 ifeq ($(MAKECMDGOALS),)
80 MAKECMDGOALS += all
81 endif
84 # The 'bios', 'efi32' and 'efi64' are dummy targets. Their only
85 # purpose is to instruct us which output directories need
86 # creating. Which means that we always need a *real* target, such as
87 # 'all', appended to the make goals.
89 real-target := $(filter-out $(all_firmware), $(MAKECMDGOALS))
90 real-firmware := $(filter $(all_firmware), $(MAKECMDGOALS))
92 ifeq ($(real-target),)
93 real-target = all
94 endif
96 ifeq ($(real-firmware),)
97 real-firmware = $(firmware)
98 endif
100 .PHONY: $(filter-out $(private-targets), $(MAKECMDGOALS))
101 $(filter-out $(private-targets), $(MAKECMDGOALS)):
102 $(MAKE) -C $(OBJDIR) -f $(CURDIR)/Makefile SRC="$(topdir)" \
103 OBJ=$(OBJDIR) objdir=$(OBJDIR) $(BUILDOPTS) \
104 $(MAKECMDGOALS)
106 unittest:
107 printf "Executing unit tests\n"
108 $(MAKE) -C core/mem/tests all
109 $(MAKE) -C com32/lib/syslinux/tests all
111 regression:
112 $(MAKE) -C tests SRC="$(topdir)/tests" OBJ="$(topdir)/tests" \
113 objdir=$(OBJDIR) $(BUILDOPTS) \
114 -f $(topdir)/tests/Makefile all
116 test: unittest regression
118 # Hook to add private Makefile targets for the maintainer.
119 -include $(topdir)/Makefile.private
121 else # ifeq ($(topdir),)
123 include $(MAKEDIR)/syslinux.mk
125 # Hook to add private Makefile targets for the maintainer.
126 -include $(topdir)/Makefile.private
129 # The BTARGET refers to objects that are derived from ldlinux.asm; we
130 # like to keep those uniform for debugging reasons; however, distributors
131 # want to recompile the installers (ITARGET).
133 # BOBJECTS and IOBJECTS are the same thing, except used for
134 # installation, so they include objects that may be in subdirectories
135 # with their own Makefiles. Finally, there is a list of those
136 # directories.
139 ifeq ($(FWCLASS),BIOS)
140 MODULES = memdisk/memdisk \
141 com32/menu/*.c32 com32/modules/*.c32 com32/mboot/*.c32 \
142 com32/hdt/*.c32 com32/rosh/*.c32 com32/gfxboot/*.c32 \
143 com32/sysdump/*.c32 com32/lua/src/*.c32 com32/chain/*.c32 \
144 com32/lib/*.c32 com32/libutil/*.c32 com32/gpllib/*.c32 \
145 com32/elflink/ldlinux/*.c32 com32/cmenu/libmenu/*.c32
146 else
147 # FIXME: Prune other BIOS-centric modules
148 MODULES = com32/menu/*.c32 com32/modules/*.c32 com32/mboot/*.c32 \
149 com32/hdt/*.c32 com32/rosh/*.c32 com32/gfxboot/*.c32 \
150 com32/sysdump/*.c32 com32/lua/src/*.c32 com32/chain/*.c32 \
151 com32/lib/*.c32 com32/libutil/*.c32 com32/gpllib/*.c32 \
152 com32/cmenu/libmenu/*.c32 com32/elflink/ldlinux/$(LDLINUX)
153 endif
155 export FIRMWARE FWCLASS ARCH BITS
157 # List of module objects that should be installed for all derivatives
158 INSTALLABLE_MODULES = $(MODULES)
160 # syslinux.exe is BTARGET so as to not require everyone to have the
161 # mingw suite installed
162 BTARGET = version.gen version.h $(OBJDIR)/version.mk
163 BOBJECTS = $(BTARGET) \
164 mbr/*.bin \
165 core/pxelinux.0 core/lpxelinux.0 \
166 core/isolinux.bin core/isolinux-debug.bin \
167 dos/syslinux.com \
168 win32/syslinux.exe win64/syslinux64.exe \
169 dosutil/*.com dosutil/*.sys \
170 $(MODULES)
172 # BSUBDIRs build the on-target binary components.
173 # ISUBDIRs build the installer (host) components.
175 # Note: libinstaller is both a BSUBDIR and an ISUBDIR. It contains
176 # files that depend only on the B phase, but may have to be regenerated
177 # for "make installer".
179 ifeq ($(FWCLASS),EFI)
181 BSUBDIRS = codepage com32 lzo core mbr sample efi txt
182 ISUBDIRS =
184 INSTALLSUBDIRS = efi
186 NETINSTALLABLE = efi/syslinux.efi $(INSTALLABLE_MODULES)
188 else
190 BSUBDIRS = codepage com32 lzo core memdisk mbr sample \
191 diag libinstaller dos win32 win64 dosutil txt
193 ITARGET =
194 IOBJECTS = $(ITARGET) \
195 utils/gethostip utils/isohybrid utils/mkdiskimage \
196 mtools/syslinux linux/syslinux extlinux/extlinux
197 ISUBDIRS = libinstaller mtools linux extlinux utils
199 # Things to install in /usr/bin
200 INSTALL_BIN = mtools/syslinux
201 # Things to install in /sbin
202 INSTALL_SBIN = extlinux/extlinux
203 # Things to install in /usr/lib/syslinux
204 INSTALL_AUX = core/pxelinux.0 \
205 core/isolinux.bin core/isolinux-debug.bin \
206 dos/syslinux.com core/lpxelinux.0 \
207 mbr/*.bin $(INSTALLABLE_MODULES)
208 INSTALL_AUX_OPT = win32/syslinux.exe win64/syslinux64.exe
209 INSTALL_DIAG = diag/mbr/handoff.bin \
210 diag/geodsp/geodsp1s.img.xz diag/geodsp/geodspms.img.xz
212 # These directories manage their own installables
213 INSTALLSUBDIRS = com32 utils dosutil
215 # Things to install in /boot/extlinux
216 EXTBOOTINSTALL = $(INSTALLABLE_MODULES)
218 # Things to install in /tftpboot
219 NETINSTALLABLE = core/pxelinux.0 core/lpxelinux.0 \
220 $(INSTALLABLE_MODULES)
222 endif # ifeq ($(FWCLASS),EFI)
224 .PHONY: subdirs $(BSUBDIRS) $(ISUBDIRS) test
226 ifeq ($(FIRMWARE),)
228 firmware = $(all_firmware)
230 # If no firmware was specified the rest of MAKECMDGOALS applies to all
231 # firmware.
232 ifeq ($(filter $(firmware),$(MAKECMDGOALS)),)
233 all strip tidy clean dist install installer netinstall: $(all_firmware)
235 else
237 # Don't do anything for the rest of MAKECMDGOALS at this level. It
238 # will be handled for each of $(firmware).
239 strip tidy clean dist install installer netinstall:
241 endif
243 # Convert 'make bios strip' to 'make strip', etc for rest of the Makefiles.
244 MAKECMDGOALS := $(filter-out $(firmware),$(MAKECMDGOALS))
245 ifeq ($(MAKECMDGOALS),)
246 MAKECMDGOALS += all
247 endif
250 # You'd think that we'd be able to use the 'define' directive to
251 # abstract the code for invoking make(1) in the output directory, but
252 # by using 'define' we lose the ability to build in parallel.
254 .PHONY: $(firmware)
255 bios:
256 @mkdir -p $(OBJ)/bios
257 $(MAKE) -C $(OBJ)/bios -f $(SRC)/Makefile SRC="$(SRC)" \
258 objdir=$(OBJ)/bios OBJ=$(OBJ)/bios \
259 FIRMWARE=BIOS FWCLASS=BIOS \
260 ARCH=i386 LDLINUX=ldlinux.c32 $(MAKECMDGOALS)
262 efi32:
263 @mkdir -p $(OBJ)/efi32
264 $(MAKE) -C $(OBJ)/efi32 -f $(SRC)/Makefile SRC="$(SRC)" \
265 objdir=$(OBJ)/efi32 OBJ=$(OBJ)/efi32 \
266 ARCH=i386 BITS=32 LDLINUX=ldlinux.e32 \
267 FIRMWARE=EFI32 FWCLASS=EFI \
268 $(MAKECMDGOALS)
270 efi64:
271 @mkdir -p $(OBJ)/efi64
272 $(MAKE) -C $(OBJ)/efi64 -f $(SRC)/Makefile SRC="$(SRC)" \
273 objdir=$(OBJ)/efi64 OBJ=$(OBJ)/efi64 \
274 ARCH=x86_64 BITS=64 LDLINUX=ldlinux.e64 \
275 FIRMWARE=EFI64 FWCLASS=EFI \
276 $(MAKECMDGOALS)
278 else # FIRMWARE
280 all: all-local subdirs
282 all-local: $(BTARGET) $(ITARGET)
283 -ls -l $(BOBJECTS) $(IOBJECTS)
284 subdirs: $(BSUBDIRS) $(ISUBDIRS)
286 $(sort $(ISUBDIRS) $(BSUBDIRS)):
287 @mkdir -p $@
288 $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
289 -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
291 $(ITARGET):
292 @mkdir -p $@
293 $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
294 -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
296 $(BINFILES):
297 @mkdir -p $@
298 $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
299 -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
302 # List the dependencies to help out parallel builds.
303 dos extlinux linux mtools win32 win64: libinstaller
304 libinstaller: core
305 utils: mbr
306 core: com32
307 efi: core
309 installer: installer-local
310 set -e; for i in $(ISUBDIRS); \
311 do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
312 -f $(SRC)/$$i/Makefile all; done
315 installer-local: $(ITARGET) $(BINFILES)
317 strip: strip-local
318 set -e; for i in $(ISUBDIRS); \
319 do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
320 -f $(SRC)/$$i/Makefile strip; done
321 -ls -l $(BOBJECTS) $(IOBJECTS)
323 strip-local:
325 version.gen: $(topdir)/version $(topdir)/version.pl
326 $(PERL) $(topdir)/version.pl $< $@ '%define < @'
327 version.h: $(topdir)/version $(topdir)/version.pl
328 $(PERL) $(topdir)/version.pl $< $@ '#define < @'
330 local-install: installer
331 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
332 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
333 mkdir -m 755 -p $(INSTALLROOT)$(SBINDIR)
334 install -m 755 -c $(INSTALL_SBIN) $(INSTALLROOT)$(SBINDIR)
335 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
336 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
337 -install -m 644 -c $(INSTALL_AUX_OPT) $(INSTALLROOT)$(AUXDIR)
338 mkdir -m 755 -p $(INSTALLROOT)$(DIAGDIR)
339 install -m 644 -c $(INSTALL_DIAG) $(INSTALLROOT)$(DIAGDIR)
340 mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man1
341 install -m 644 -c $(topdir)/man/*.1 $(INSTALLROOT)$(MANDIR)/man1
342 : mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man8
343 : install -m 644 -c man/*.8 $(INSTALLROOT)$(MANDIR)/man8
345 ifneq ($(FWCLASS),EFI)
346 install: local-install
347 set -e ; for i in $(INSTALLSUBDIRS) ; \
348 do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
349 -f $(SRC)/$$i/Makefile $@; done
350 else
351 install:
352 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)/efi$(BITS)
353 set -e ; for i in $(INSTALLSUBDIRS) ; \
354 do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
355 BITS="$(BITS)" AUXDIR="$(AUXDIR)/efi$(BITS)" \
356 -f $(SRC)/$$i/Makefile $@; done
357 -install -m 644 $(INSTALLABLE_MODULES) $(INSTALLROOT)$(AUXDIR)/efi$(BITS)
358 install -m 644 com32/elflink/ldlinux/$(LDLINUX) $(INSTALLROOT)$(AUXDIR)/efi$(BITS)
359 endif
361 ifeq ($(FWCLASS),EFI)
362 netinstall:
363 mkdir -p $(INSTALLROOT)$(TFTPBOOT)/efi$(BITS)
364 install -m 644 $(NETINSTALLABLE) $(INSTALLROOT)$(TFTPBOOT)/efi$(BITS)
365 else
366 netinstall: installer
367 mkdir -p $(INSTALLROOT)$(TFTPBOOT)
368 install -m 644 $(NETINSTALLABLE) $(INSTALLROOT)$(TFTPBOOT)
369 endif
371 extbootinstall: installer
372 mkdir -m 755 -p $(INSTALLROOT)$(EXTLINUXDIR)
373 install -m 644 $(EXTBOOTINSTALL) $(INSTALLROOT)$(EXTLINUXDIR)
375 install-all: install netinstall extbootinstall
377 local-tidy:
378 rm -f *.o *.elf *_bin.c stupid.* patch.offset
379 rm -f *.lsr *.lst *.map *.sec *.tmp
380 rm -f $(OBSOLETE)
382 tidy: local-tidy $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS)
384 local-clean:
385 rm -f $(ITARGET)
387 clean: local-tidy local-clean $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS)
389 local-dist:
390 find . \( -name '*~' -o -name '#*' -o -name core \
391 -o -name '.*.d' -o -name .depend \) -type f -print0 \
392 | xargs -0rt rm -f
394 dist: local-dist local-tidy $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS)
396 # Shortcut to build linux/syslinux using klibc
397 klibc:
398 $(MAKE) clean
399 $(MAKE) CC=klcc ITARGET= ISUBDIRS='linux extlinux' BSUBDIRS=
400 endif # ifeq ($(FIRMWARE),)
402 endif # ifeq ($(topdir),)
404 local-spotless:
405 find . \( -name '*~' -o -name '#*' -o -name core \
406 -o -name '.*.d' -o -name .depend -o -name '*.so.*' \) \
407 -type f -print0 \
408 | xargs -0rt rm -f
410 spotless: local-spotless
411 rm -rf $(all_firmware)
414 # Common rules that are needed by every invocation of make.
416 $(OBJDIR)/version.mk: $(topdir)/version $(topdir)/version.pl
417 $(PERL) $(topdir)/version.pl $< $@ '< := @'