Updating bail out check for extlinux-update os-proper script.
[syslinux-debian/hramrach.git] / Makefile
blobe7d89d90401836b12ac72411744e43c784ed14b2
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/isolinux.bin core/isolinux-debug.bin \
151 gpxe/gpxelinux.0 dos/syslinux.com \
152 win32/syslinux.exe win64/syslinux64.exe \
153 dosutil/*.com dosutil/*.sys \
154 $(MODULES)
156 # BSUBDIRs build the on-target binary components.
157 # ISUBDIRs build the installer (host) components.
159 # Note: libinstaller is both a BSUBDIR and an ISUBDIR. It contains
160 # files that depend only on the B phase, but may have to be regenerated
161 # for "make installer".
163 ifdef EFI_BUILD
165 BSUBDIRS = codepage com32 lzo core mbr sample efi txt
166 ISUBDIRS = efi utils
168 INSTALLSUBDIRS = efi
170 else
172 BSUBDIRS = codepage com32 lzo core memdisk mbr memdump gpxe sample \
173 diag libinstaller dos win32 win64 dosutil txt
175 ITARGET =
176 IOBJECTS = $(ITARGET) \
177 utils/gethostip utils/isohybrid utils/mkdiskimage \
178 mtools/syslinux linux/syslinux extlinux/extlinux
179 ISUBDIRS = libinstaller mtools linux extlinux utils
181 # Things to install in /usr/bin
182 INSTALL_BIN = mtools/syslinux
183 # Things to install in /sbin
184 INSTALL_SBIN = extlinux/extlinux
185 # Things to install in /usr/lib/syslinux
186 INSTALL_AUX = core/pxelinux.0 gpxe/gpxelinux.0 gpxe/gpxelinuxk.0 \
187 core/isolinux.bin core/isolinux-debug.bin \
188 dos/syslinux.com \
189 mbr/*.bin $(INSTALLABLE_MODULES)
190 INSTALL_AUX_OPT = win32/syslinux.exe win64/syslinux64.exe
191 INSTALL_DIAG = diag/mbr/handoff.bin \
192 diag/geodsp/geodsp1s.img.xz diag/geodsp/geodspms.img.xz
194 # These directories manage their own installables
195 INSTALLSUBDIRS = com32 utils dosutil
197 # Things to install in /boot/extlinux
198 EXTBOOTINSTALL = $(INSTALLABLE_MODULES)
200 # Things to install in /tftpboot
201 NETINSTALLABLE = core/pxelinux.0 gpxe/gpxelinux.0 \
202 $(INSTALLABLE_MODULES)
204 endif # ifdef EFI_BUILD
206 .PHONY: subdirs $(BSUBDIRS) $(ISUBDIRS)
208 ifeq ($(HAVE_FIRMWARE),)
210 firmware = bios efi32 efi64
212 # If no firmware was specified the rest of MAKECMDGOALS applies to all
213 # firmware.
214 ifeq ($(filter $(firmware),$(MAKECMDGOALS)),)
215 all strip tidy clean dist spotless install installer: bios efi32 efi64
217 else
219 # Don't do anything for the rest of MAKECMDGOALS at this level. It
220 # will be handled for each of $(firmware).
221 strip tidy clean dist spotless install installer:
223 endif
225 # Convert 'make bios strip' to 'make strip', etc for rest of the Makefiles.
226 MAKECMDGOALS := $(filter-out $(firmware),$(MAKECMDGOALS))
227 ifeq ($(MAKECMDGOALS),)
228 MAKECMDGOALS += all
229 endif
232 # You'd think that we'd be able to use the 'define' directive to
233 # abstract the code for invoking make(1) in the output directory, but
234 # by using 'define' we lose the ability to build in parallel.
236 .PHONY: $(firmware)
237 bios:
238 @mkdir -p $(OBJ)/bios
239 $(MAKE) -C $(OBJ)/bios -f $(SRC)/Makefile SRC="$(SRC)" \
240 objdir=$(OBJ)/bios OBJ=$(OBJ)/bios HAVE_FIRMWARE=1 \
241 ARCH=i386 $(MAKECMDGOALS)
243 efi32:
244 @mkdir -p $(OBJ)/efi32
245 $(MAKE) -C $(OBJ)/efi32 -f $(SRC)/Makefile SRC="$(SRC)" \
246 objdir=$(OBJ)/efi32 OBJ=$(OBJ)/efi32 HAVE_FIRMWARE=1 \
247 ARCH=i386 BITS=32 EFI_BUILD=1 $(MAKECMDGOALS)
249 efi64:
250 @mkdir -p $(OBJ)/efi64
251 $(MAKE) -C $(OBJ)/efi64 -f $(SRC)/Makefile SRC="$(SRC)" \
252 objdir=$(OBJ)/efi64 OBJ=$(OBJ)/efi64 HAVE_FIRMWARE=1 \
253 ARCH=x86_64 BITS=64 EFI_BUILD=1 $(MAKECMDGOALS)
255 else # ifeq($(HAVE_FIRMWARE),)
257 all: all-local subdirs
259 all-local: $(BTARGET) $(ITARGET)
260 -ls -l $(BOBJECTS) $(IOBJECTS)
261 subdirs: $(BSUBDIRS) $(ISUBDIRS)
263 $(sort $(ISUBDIRS) $(BSUBDIRS)):
264 @mkdir -p $@
265 $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
266 -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
268 $(ITARGET):
269 @mkdir -p $@
270 $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
271 -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
273 $(BINFILES):
274 @mkdir -p $@
275 $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
276 -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
279 # List the dependencies to help out parallel builds.
280 dos extlinux linux mtools win32 win64: libinstaller
281 libinstaller: core
282 utils: mbr
283 core: com32
284 efi: core
286 installer: installer-local
287 set -e; for i in $(ISUBDIRS); \
288 do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
289 -f $(SRC)/$$i/Makefile all; done
292 installer-local: $(ITARGET) $(BINFILES)
294 strip: strip-local
295 set -e; for i in $(ISUBDIRS); \
296 do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
297 -f $(SRC)/$$i/Makefile strip; done
298 -ls -l $(BOBJECTS) $(IOBJECTS)
300 strip-local:
302 version.gen: $(topdir)/version $(topdir)/version.pl
303 $(PERL) $(topdir)/version.pl $< $@ '%define < @'
304 version.h: $(topdir)/version $(topdir)/version.pl
305 $(PERL) $(topdir)/version.pl $< $@ '#define < @'
307 local-install: installer
308 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
309 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
310 mkdir -m 755 -p $(INSTALLROOT)$(SBINDIR)
311 install -m 755 -c $(INSTALL_SBIN) $(INSTALLROOT)$(SBINDIR)
312 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
313 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
314 -install -m 644 -c $(INSTALL_AUX_OPT) $(INSTALLROOT)$(AUXDIR)
315 mkdir -m 755 -p $(INSTALLROOT)$(DIAGDIR)
316 install -m 644 -c $(INSTALL_DIAG) $(INSTALLROOT)$(DIAGDIR)
317 mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man1
318 install -m 644 -c $(topdir)/man/*.1 $(INSTALLROOT)$(MANDIR)/man1
319 : mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man8
320 : install -m 644 -c man/*.8 $(INSTALLROOT)$(MANDIR)/man8
322 ifndef EFI_BUILD
323 install: local-install
324 set -e ; for i in $(INSTALLSUBDIRS) ; \
325 do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
326 -f $(SRC)/$$i/Makefile $@; done
327 else
328 install:
329 set -e ; for i in $(INSTALLSUBDIRS) ; \
330 do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
331 BITS="$(BITS)" -f $(SRC)/$$i/Makefile $@; done
333 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)/efi$(BITS)
334 install -m 755 $(MODULES) $(INSTALLROOT)$(AUXDIR)/efi$(BITS)
335 endif
337 netinstall: installer
338 mkdir -p $(INSTALLROOT)$(TFTPBOOT)
339 install -m 644 $(NETINSTALLABLE) $(INSTALLROOT)$(TFTPBOOT)
341 extbootinstall: installer
342 mkdir -m 755 -p $(INSTALLROOT)$(EXTLINUXDIR)
343 install -m 644 $(EXTBOOTINSTALL) $(INSTALLROOT)$(EXTLINUXDIR)
345 install-all: install netinstall extbootinstall
347 local-tidy:
348 rm -f *.o *.elf *_bin.c stupid.* patch.offset
349 rm -f *.lsr *.lst *.map *.sec *.tmp
350 rm -f $(OBSOLETE)
352 tidy: local-tidy $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS)
354 local-clean:
355 rm -f $(ITARGET)
357 clean: local-tidy local-clean $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS)
359 local-dist:
360 find . \( -name '*~' -o -name '#*' -o -name core \
361 -o -name '.*.d' -o -name .depend \) -type f -print0 \
362 | xargs -0rt rm -f
364 dist: local-dist local-tidy $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS)
366 local-spotless:
367 rm -f $(BTARGET) .depend *.so.*
369 spotless: local-clean local-dist local-spotless $(BESUBDIRS) $(IESUBDIRS) $(ISUBDIRS) $(BSUBDIRS)
371 # Shortcut to build linux/syslinux using klibc
372 klibc:
373 $(MAKE) clean
374 $(MAKE) CC=klcc ITARGET= ISUBDIRS='linux extlinux' BSUBDIRS=
375 endif # ifeq ($(HAVE_FIRMWARE),)
377 endif # ifeq ($(topdir),)
380 # Common rules that are needed by every invocation of make.
382 $(OBJDIR)/version.mk: $(topdir)/version $(topdir)/version.pl
383 $(PERL) $(topdir)/version.pl $< $@ '< := @'