1 ## -----------------------------------------------------------------------
3 ## Copyright 1998-2009 H. Peter Anvin - All Rights Reserved
4 ## Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
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.
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")
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
)
45 $(error output directory
"$(OBJDIR)" does not exist
))
48 # These environment variables are exported to every invocation of
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
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
test unittest regression
77 ifeq ($(MAKECMDGOALS
),)
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
),)
95 ifeq ($(real-firmware
),)
96 real-firmware
= $(firmware
)
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
)
105 printf
"Executing unit tests\n"
106 $(MAKE
) -C core
/mem
/tests
all
107 $(MAKE
) -C com32
/lib
/syslinux
/tests
all
110 $(MAKE
) -C tests SRC
="$(topdir)/tests" OBJ
="$(topdir)/tests" \
112 -f
$(topdir
)/tests
/Makefile
all
114 test: unittest regression
116 # Hook to add private Makefile targets for the maintainer.
117 -include $(topdir
)/Makefile.private
119 else # ifeq ($(topdir),)
121 include $(MAKEDIR
)/syslinux.mk
123 # Hook to add private Makefile targets for the maintainer.
124 -include $(topdir
)/Makefile.private
127 # The BTARGET refers to objects that are derived from ldlinux.asm; we
128 # like to keep those uniform for debugging reasons; however, distributors
129 # want to recompile the installers (ITARGET).
131 # BOBJECTS and IOBJECTS are the same thing, except used for
132 # installation, so they include objects that may be in subdirectories
133 # with their own Makefiles. Finally, there is a list of those
138 MODULES
= memdisk
/memdisk memdump
/memdump.com \
139 com32
/menu
/*.c32 com32
/modules
/*.c32 com32
/mboot
/*.c32 \
140 com32
/hdt
/*.c32 com32
/rosh
/*.c32 com32
/gfxboot
/*.c32 \
141 com32
/sysdump
/*.c32 com32
/lua
/src
/*.c32 com32
/chain
/*.c32 \
142 com32
/lib
/*.c32 com32
/libutil
/*.c32 com32
/gpllib
/*.c32 \
143 com32
/elflink
/ldlinux
/*.c32 com32
/cmenu
/libmenu
/*.c32
145 # memdump is BIOS specific code exclude it for EFI
146 # FIXME: Prune other BIOS-centric modules
147 MODULES
= com32
/menu
/*.c32 com32
/modules
/*.c32 com32
/mboot
/*.c32 \
148 com32
/hdt
/*.c32 com32
/rosh
/*.c32 com32
/gfxboot
/*.c32 \
149 com32
/sysdump
/*.c32 com32
/lua
/src
/*.c32 com32
/chain
/*.c32 \
150 com32
/lib
/*.c32 com32
/libutil
/*.c32 com32
/gpllib
/*.c32 \
151 com32
/cmenu
/libmenu
/*.c32 com32
/elflink
/ldlinux
/$(LDLINUX
)
154 # List of module objects that should be installed for all derivatives
155 INSTALLABLE_MODULES
= $(MODULES
)
157 # syslinux.exe is BTARGET so as to not require everyone to have the
158 # mingw suite installed
159 BTARGET
= version.gen version.h
$(OBJDIR
)/version.mk
160 BOBJECTS
= $(BTARGET
) \
162 core
/pxelinux
.0 core
/lpxelinux
.0 \
163 core
/isolinux.bin core
/isolinux-debug.bin \
164 gpxe
/gpxelinux
.0 dos
/syslinux.com \
165 win32
/syslinux.exe win64
/syslinux64.exe \
166 dosutil
/*.com dosutil
/*.sys \
169 # BSUBDIRs build the on-target binary components.
170 # ISUBDIRs build the installer (host) components.
172 # Note: libinstaller is both a BSUBDIR and an ISUBDIR. It contains
173 # files that depend only on the B phase, but may have to be regenerated
174 # for "make installer".
178 BSUBDIRS
= codepage com32 lzo core mbr sample efi txt
183 NETINSTALLABLE
= efi
/syslinux.efi
$(INSTALLABLE_MODULES
)
187 BSUBDIRS
= codepage com32 lzo core memdisk mbr memdump gpxe sample \
188 diag libinstaller dos win32 win64 dosutil txt
191 IOBJECTS
= $(ITARGET
) \
192 utils
/gethostip utils
/isohybrid utils
/mkdiskimage \
193 mtools
/syslinux linux
/syslinux extlinux
/extlinux
194 ISUBDIRS
= libinstaller mtools linux extlinux utils
196 # Things to install in /usr/bin
197 INSTALL_BIN
= mtools
/syslinux
198 # Things to install in /sbin
199 INSTALL_SBIN
= extlinux
/extlinux
200 # Things to install in /usr/lib/syslinux
201 INSTALL_AUX
= core
/pxelinux
.0 gpxe
/gpxelinux
.0 gpxe
/gpxelinuxk
.0 \
202 core
/isolinux.bin core
/isolinux-debug.bin \
203 dos
/syslinux.com core
/lpxelinux
.0 \
204 mbr
/*.bin
$(INSTALLABLE_MODULES
)
205 INSTALL_AUX_OPT
= win32
/syslinux.exe win64
/syslinux64.exe
206 INSTALL_DIAG
= diag
/mbr
/handoff.bin \
207 diag
/geodsp
/geodsp1s.img.xz diag
/geodsp
/geodspms.img.xz
209 # These directories manage their own installables
210 INSTALLSUBDIRS
= com32 utils dosutil
212 # Things to install in /boot/extlinux
213 EXTBOOTINSTALL
= $(INSTALLABLE_MODULES
)
215 # Things to install in /tftpboot
216 NETINSTALLABLE
= core
/pxelinux
.0 gpxe
/gpxelinux
.0 core
/lpxelinux
.0 \
217 $(INSTALLABLE_MODULES
)
219 endif # ifdef EFI_BUILD
221 .PHONY
: subdirs
$(BSUBDIRS
) $(ISUBDIRS
) test
223 ifeq ($(HAVE_FIRMWARE
),)
225 firmware
= bios efi32 efi64
227 # If no firmware was specified the rest of MAKECMDGOALS applies to all
229 ifeq ($(filter $(firmware
),$(MAKECMDGOALS
)),)
230 all strip tidy
clean dist spotless
install installer netinstall
: bios efi32 efi64
234 # Don't do anything for the rest of MAKECMDGOALS at this level. It
235 # will be handled for each of $(firmware).
236 strip tidy
clean dist spotless
install installer netinstall
:
240 # Convert 'make bios strip' to 'make strip', etc for rest of the Makefiles.
241 MAKECMDGOALS
:= $(filter-out $(firmware
),$(MAKECMDGOALS
))
242 ifeq ($(MAKECMDGOALS
),)
247 # You'd think that we'd be able to use the 'define' directive to
248 # abstract the code for invoking make(1) in the output directory, but
249 # by using 'define' we lose the ability to build in parallel.
253 @mkdir
-p
$(OBJ
)/bios
254 $(MAKE
) -C
$(OBJ
)/bios
-f
$(SRC
)/Makefile SRC
="$(SRC)" \
255 objdir
=$(OBJ
)/bios OBJ
=$(OBJ
)/bios HAVE_FIRMWARE
=1 \
256 ARCH
=i386 LDLINUX
=ldlinux.c32
$(MAKECMDGOALS
)
259 @mkdir
-p
$(OBJ
)/efi32
260 $(MAKE
) -C
$(OBJ
)/efi32
-f
$(SRC
)/Makefile SRC
="$(SRC)" \
261 objdir
=$(OBJ
)/efi32 OBJ
=$(OBJ
)/efi32 HAVE_FIRMWARE
=1 \
262 ARCH
=i386 BITS
=32 EFI_BUILD
=1 LDLINUX
=ldlinux.e32 \
266 @mkdir
-p
$(OBJ
)/efi64
267 $(MAKE
) -C
$(OBJ
)/efi64
-f
$(SRC
)/Makefile SRC
="$(SRC)" \
268 objdir
=$(OBJ
)/efi64 OBJ
=$(OBJ
)/efi64 HAVE_FIRMWARE
=1 \
269 ARCH
=x86_64 BITS
=64 EFI_BUILD
=1 LDLINUX
=ldlinux.e64 \
272 else # ifeq($(HAVE_FIRMWARE),)
274 all: all-local subdirs
276 all-local
: $(BTARGET
) $(ITARGET
)
277 -ls
-l
$(BOBJECTS
) $(IOBJECTS
)
278 subdirs
: $(BSUBDIRS
) $(ISUBDIRS
)
280 $(sort $(ISUBDIRS
) $(BSUBDIRS
)):
282 $(MAKE
) -C
$@ SRC
="$(SRC)/$@" OBJ
="$(OBJ)/$@" \
283 -f
$(SRC
)/$@
/Makefile
$(MAKECMDGOALS
)
287 $(MAKE
) -C
$@ SRC
="$(SRC)/$@" OBJ
="$(OBJ)/$@" \
288 -f
$(SRC
)/$@
/Makefile
$(MAKECMDGOALS
)
292 $(MAKE
) -C
$@ SRC
="$(SRC)/$@" OBJ
="$(OBJ)/$@" \
293 -f
$(SRC
)/$@
/Makefile
$(MAKECMDGOALS
)
296 # List the dependencies to help out parallel builds.
297 dos extlinux linux mtools win32 win64
: libinstaller
304 installer
: installer-local
305 set
-e
; for i in
$(ISUBDIRS
); \
306 do
$(MAKE
) -C
$$i SRC
="$(SRC)/$$i" OBJ
="$(OBJ)/$$i" \
307 -f
$(SRC
)/$$i/Makefile
all; done
310 installer-local
: $(ITARGET
) $(BINFILES
)
313 set
-e
; for i in
$(ISUBDIRS
); \
314 do
$(MAKE
) -C
$$i SRC
="$(SRC)/$$i" OBJ
="$(OBJ)/$$i" \
315 -f
$(SRC
)/$$i/Makefile
strip; done
316 -ls
-l
$(BOBJECTS
) $(IOBJECTS
)
320 version.gen
: $(topdir
)/version
$(topdir
)/version.pl
321 $(PERL
) $(topdir
)/version.pl
$< $@
'%define < @'
322 version.h
: $(topdir
)/version
$(topdir
)/version.pl
323 $(PERL
) $(topdir
)/version.pl
$< $@
'#define < @'
325 local-install
: installer
326 mkdir
-m
755 -p
$(INSTALLROOT
)$(BINDIR
)
327 install -m
755 -c
$(INSTALL_BIN
) $(INSTALLROOT
)$(BINDIR
)
328 mkdir
-m
755 -p
$(INSTALLROOT
)$(SBINDIR
)
329 install -m
755 -c
$(INSTALL_SBIN
) $(INSTALLROOT
)$(SBINDIR
)
330 mkdir
-m
755 -p
$(INSTALLROOT
)$(AUXDIR
)
331 install -m
644 -c
$(INSTALL_AUX
) $(INSTALLROOT
)$(AUXDIR
)
332 -install -m
644 -c
$(INSTALL_AUX_OPT
) $(INSTALLROOT
)$(AUXDIR
)
333 mkdir
-m
755 -p
$(INSTALLROOT
)$(DIAGDIR
)
334 install -m
644 -c
$(INSTALL_DIAG
) $(INSTALLROOT
)$(DIAGDIR
)
335 mkdir
-m
755 -p
$(INSTALLROOT
)$(MANDIR
)/man1
336 install -m
644 -c
$(topdir
)/man
/*.1 $(INSTALLROOT
)$(MANDIR
)/man1
337 : mkdir
-m
755 -p
$(INSTALLROOT
)$(MANDIR
)/man8
338 : install -m
644 -c man
/*.8 $(INSTALLROOT
)$(MANDIR
)/man8
341 install: local-install
342 set
-e
; for i in
$(INSTALLSUBDIRS
) ; \
343 do
$(MAKE
) -C
$$i SRC
="$(SRC)/$$i" OBJ
="$(OBJ)/$$i" \
344 -f
$(SRC
)/$$i/Makefile
$@
; done
347 mkdir
-m
755 -p
$(INSTALLROOT
)$(AUXDIR
)/efi
$(BITS
)
348 set
-e
; for i in
$(INSTALLSUBDIRS
) ; \
349 do
$(MAKE
) -C
$$i SRC
="$(SRC)/$$i" OBJ
="$(OBJ)/$$i" \
350 BITS
="$(BITS)" AUXDIR
="$(AUXDIR)/efi$(BITS)" \
351 -f
$(SRC
)/$$i/Makefile
$@
; done
352 -install -m
644 $(INSTALLABLE_MODULES
) $(INSTALLROOT
)$(AUXDIR
)/efi
$(BITS
)
353 install -m
644 com32
/elflink
/ldlinux
/$(LDLINUX
) $(INSTALLROOT
)$(AUXDIR
)/efi
$(BITS
)
358 mkdir
-p
$(INSTALLROOT
)$(TFTPBOOT
)/efi
$(BITS
)
359 install -m
644 $(NETINSTALLABLE
) $(INSTALLROOT
)$(TFTPBOOT
)/efi
$(BITS
)
361 netinstall
: installer
362 mkdir
-p
$(INSTALLROOT
)$(TFTPBOOT
)
363 install -m
644 $(NETINSTALLABLE
) $(INSTALLROOT
)$(TFTPBOOT
)
366 extbootinstall
: installer
367 mkdir
-m
755 -p
$(INSTALLROOT
)$(EXTLINUXDIR
)
368 install -m
644 $(EXTBOOTINSTALL
) $(INSTALLROOT
)$(EXTLINUXDIR
)
370 install-all
: install netinstall extbootinstall
373 rm -f
*.o
*.elf
*_bin.c stupid.
* patch.offset
374 rm -f
*.lsr
*.lst
*.map
*.sec
*.tmp
377 tidy
: local-tidy
$(BESUBDIRS
) $(IESUBDIRS
) $(BSUBDIRS
) $(ISUBDIRS
)
382 clean: local-tidy local-clean
$(BESUBDIRS
) $(IESUBDIRS
) $(BSUBDIRS
) $(ISUBDIRS
)
385 find . \
( -name
'*~' -o
-name
'#*' -o
-name core \
386 -o
-name
'.*.d' -o
-name .depend \
) -type f
-print0 \
389 dist: local-dist local-tidy
$(BESUBDIRS
) $(IESUBDIRS
) $(BSUBDIRS
) $(ISUBDIRS
)
392 rm -f
$(BTARGET
) .depend
*.so.
*
394 spotless
: local-clean local-dist local-spotless
$(BESUBDIRS
) $(IESUBDIRS
) $(ISUBDIRS
) $(BSUBDIRS
)
396 # Shortcut to build linux/syslinux using klibc
399 $(MAKE
) CC
=klcc ITARGET
= ISUBDIRS
='linux extlinux' BSUBDIRS
=
400 endif # ifeq ($(HAVE_FIRMWARE),)
402 endif # ifeq ($(topdir),)
405 # Common rules that are needed by every invocation of make.
407 $(OBJDIR
)/version.mk
: $(topdir
)/version
$(topdir
)/version.pl
408 $(PERL
) $(topdir
)/version.pl
$< $@
'< := @'