1 ## -----------------------------------------------------------------------
3 ## Copyright 1998-2009 H. Peter Anvin - All Rights Reserved
4 ## Copyright 2009-2014 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
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.
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")
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
)
47 $(error output directory
"$(OBJDIR)" does not exist
))
50 # These environment variables are exported to every invocation of
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
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
),)
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 firmware
= $(all_firmware
)
90 real-target
:= $(filter-out $(firmware
), $(MAKECMDGOALS
))
91 real-firmware
:= $(filter $(firmware
), $(MAKECMDGOALS
))
93 ifeq ($(real-target
),)
97 ifeq ($(real-firmware
),)
98 do-spotless-gpxe
= no-fw
99 real-firmware
= $(firmware
)
102 .PHONY
: $(filter-out $(private-targets
), $(MAKECMDGOALS
))
103 $(filter-out $(private-targets
), $(MAKECMDGOALS
)):
104 $(MAKE
) -C
$(OBJDIR
) -f
$(CURDIR
)/Makefile SRC
="$(topdir)" \
105 OBJ
=$(OBJDIR
) objdir
=$(OBJDIR
) $(MAKECMDGOALS
)
108 printf
"Executing unit tests\n"
109 $(MAKE
) -C core
/mem
/tests
all
110 $(MAKE
) -C com32
/lib
/syslinux
/tests
all
113 $(MAKE
) -C tests SRC
="$(topdir)/tests" OBJ
="$(topdir)/tests" \
115 -f
$(topdir
)/tests
/Makefile
all
117 test: unittest regression
119 # Hook to add private Makefile targets for the maintainer.
120 -include $(topdir
)/Makefile.private
122 else # ifeq ($(topdir),)
124 include $(MAKEDIR
)/syslinux.mk
126 # Hook to add private Makefile targets for the maintainer.
127 -include $(topdir
)/Makefile.private
130 # The BTARGET refers to objects that are derived from ldlinux.asm; we
131 # like to keep those uniform for debugging reasons; however, distributors
132 # want to recompile the installers (ITARGET).
134 # BOBJECTS and IOBJECTS are the same thing, except used for
135 # installation, so they include objects that may be in subdirectories
136 # with their own Makefiles. Finally, there is a list of those
141 MODULES
= memdisk
/memdisk \
142 com32
/menu
/*.c32 com32
/modules
/*.c32 com32
/mboot
/*.c32 \
143 com32
/hdt
/*.c32 com32
/rosh
/*.c32 com32
/gfxboot
/*.c32 \
144 com32
/sysdump
/*.c32 com32
/lua
/src
/*.c32 com32
/chain
/*.c32 \
145 com32
/lib
/*.c32 com32
/libutil
/*.c32 com32
/gpllib
/*.c32 \
146 com32
/elflink
/ldlinux
/*.c32 com32
/cmenu
/libmenu
/*.c32
148 # FIXME: Prune other BIOS-centric modules
149 MODULES
= com32
/menu
/*.c32 com32
/modules
/*.c32 com32
/mboot
/*.c32 \
150 com32
/hdt
/*.c32 com32
/rosh
/*.c32 com32
/gfxboot
/*.c32 \
151 com32
/sysdump
/*.c32 com32
/lua
/src
/*.c32 com32
/chain
/*.c32 \
152 com32
/lib
/*.c32 com32
/libutil
/*.c32 com32
/gpllib
/*.c32 \
153 com32
/cmenu
/libmenu
/*.c32 com32
/elflink
/ldlinux
/$(LDLINUX
)
156 # List of module objects that should be installed for all derivatives
157 INSTALLABLE_MODULES
= $(MODULES
)
159 # syslinux.exe is BTARGET so as to not require everyone to have the
160 # mingw suite installed
161 BTARGET
= version.gen version.h
$(OBJDIR
)/version.mk
162 BOBJECTS
= $(BTARGET
) \
164 core
/pxelinux
.0 core
/lpxelinux
.0 \
165 core
/isolinux.bin core
/isolinux-debug.bin \
166 gpxe
/gpxelinux
.0 dos
/syslinux.com \
167 win32
/syslinux.exe win64
/syslinux64.exe \
168 dosutil
/*.com dosutil
/*.sys \
171 # BSUBDIRs build the on-target binary components.
172 # ISUBDIRs build the installer (host) components.
174 # Note: libinstaller is both a BSUBDIR and an ISUBDIR. It contains
175 # files that depend only on the B phase, but may have to be regenerated
176 # for "make installer".
180 BSUBDIRS
= codepage com32 lzo core mbr sample efi txt
185 NETINSTALLABLE
= efi
/syslinux.efi
$(INSTALLABLE_MODULES
)
189 BSUBDIRS
= codepage com32 lzo core memdisk mbr gpxe sample \
190 diag libinstaller dos win32 win64 dosutil txt
193 IOBJECTS
= $(ITARGET
) \
194 utils
/gethostip utils
/isohybrid utils
/mkdiskimage \
195 mtools
/syslinux linux
/syslinux extlinux
/extlinux
196 ISUBDIRS
= libinstaller mtools linux extlinux utils
198 # Things to install in /usr/bin
199 INSTALL_BIN
= mtools
/syslinux
200 # Things to install in /sbin
201 INSTALL_SBIN
= extlinux
/extlinux
202 # Things to install in /usr/lib/syslinux
203 INSTALL_AUX
= core
/pxelinux
.0 gpxe
/gpxelinux
.0 gpxe
/gpxelinuxk
.0 \
204 core
/isolinux.bin core
/isolinux-debug.bin \
205 dos
/syslinux.com core
/lpxelinux
.0 \
206 mbr
/*.bin
$(INSTALLABLE_MODULES
)
207 INSTALL_AUX_OPT
= win32
/syslinux.exe win64
/syslinux64.exe
208 INSTALL_DIAG
= diag
/mbr
/handoff.bin \
209 diag
/geodsp
/geodsp1s.img.xz diag
/geodsp
/geodspms.img.xz
211 # These directories manage their own installables
212 INSTALLSUBDIRS
= com32 utils dosutil
214 # Things to install in /boot/extlinux
215 EXTBOOTINSTALL
= $(INSTALLABLE_MODULES
)
217 # Things to install in /tftpboot
218 NETINSTALLABLE
= core
/pxelinux
.0 gpxe
/gpxelinux
.0 core
/lpxelinux
.0 \
219 $(INSTALLABLE_MODULES
)
221 endif # ifdef EFI_BUILD
223 .PHONY
: subdirs
$(BSUBDIRS
) $(ISUBDIRS
) test
225 ifeq ($(HAVE_FIRMWARE
),)
227 firmware
= $(all_firmware
)
229 # If no firmware was specified the rest of MAKECMDGOALS applies to all
231 ifeq ($(filter $(firmware
),$(MAKECMDGOALS
)),)
232 all strip tidy
clean dist install installer netinstall
: $(all_firmware
)
236 # Don't do anything for the rest of MAKECMDGOALS at this level. It
237 # will be handled for each of $(firmware).
238 strip tidy
clean dist install installer netinstall
:
242 # Convert 'make bios strip' to 'make strip', etc for rest of the Makefiles.
243 MAKECMDGOALS
:= $(filter-out $(firmware
),$(MAKECMDGOALS
))
244 ifeq ($(MAKECMDGOALS
),)
249 # You'd think that we'd be able to use the 'define' directive to
250 # abstract the code for invoking make(1) in the output directory, but
251 # by using 'define' we lose the ability to build in parallel.
255 @mkdir
-p
$(OBJ
)/bios
256 $(MAKE
) -C
$(OBJ
)/bios
-f
$(SRC
)/Makefile SRC
="$(SRC)" \
257 objdir
=$(OBJ
)/bios OBJ
=$(OBJ
)/bios HAVE_FIRMWARE
=1 \
259 ARCH
=i386 LDLINUX
=ldlinux.c32
$(MAKECMDGOALS
)
262 @mkdir
-p
$(OBJ
)/efi32
263 $(MAKE
) -C
$(OBJ
)/efi32
-f
$(SRC
)/Makefile SRC
="$(SRC)" \
264 objdir
=$(OBJ
)/efi32 OBJ
=$(OBJ
)/efi32 HAVE_FIRMWARE
=1 \
265 ARCH
=i386 BITS
=32 EFI_BUILD
=1 LDLINUX
=ldlinux.e32 \
270 @mkdir
-p
$(OBJ
)/efi64
271 $(MAKE
) -C
$(OBJ
)/efi64
-f
$(SRC
)/Makefile SRC
="$(SRC)" \
272 objdir
=$(OBJ
)/efi64 OBJ
=$(OBJ
)/efi64 HAVE_FIRMWARE
=1 \
273 ARCH
=x86_64 BITS
=64 EFI_BUILD
=1 LDLINUX
=ldlinux.e64 \
277 else # ifeq($(HAVE_FIRMWARE),)
279 all: all-local subdirs
281 all-local
: $(BTARGET
) $(ITARGET
)
282 -ls
-l
$(BOBJECTS
) $(IOBJECTS
)
283 subdirs
: $(BSUBDIRS
) $(ISUBDIRS
)
285 $(sort $(ISUBDIRS
) $(BSUBDIRS
)):
287 $(MAKE
) -C
$@ SRC
="$(SRC)/$@" OBJ
="$(OBJ)/$@" \
288 -f
$(SRC
)/$@
/Makefile
$(MAKECMDGOALS
)
292 $(MAKE
) -C
$@ SRC
="$(SRC)/$@" OBJ
="$(OBJ)/$@" \
293 -f
$(SRC
)/$@
/Makefile
$(MAKECMDGOALS
)
297 $(MAKE
) -C
$@ SRC
="$(SRC)/$@" OBJ
="$(OBJ)/$@" \
298 -f
$(SRC
)/$@
/Makefile
$(MAKECMDGOALS
)
301 # List the dependencies to help out parallel builds.
302 dos extlinux linux mtools win32 win64
: libinstaller
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
)
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
)
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
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
351 do-spotless-gpxe
= bios
354 mkdir
-m
755 -p
$(INSTALLROOT
)$(AUXDIR
)/efi
$(BITS
)
355 set
-e
; for i in
$(INSTALLSUBDIRS
) ; \
356 do
$(MAKE
) -C
$$i SRC
="$(SRC)/$$i" OBJ
="$(OBJ)/$$i" \
357 BITS
="$(BITS)" AUXDIR
="$(AUXDIR)/efi$(BITS)" \
358 -f
$(SRC
)/$$i/Makefile
$@
; done
359 -install -m
644 $(INSTALLABLE_MODULES
) $(INSTALLROOT
)$(AUXDIR
)/efi
$(BITS
)
360 install -m
644 com32
/elflink
/ldlinux
/$(LDLINUX
) $(INSTALLROOT
)$(AUXDIR
)/efi
$(BITS
)
365 mkdir
-p
$(INSTALLROOT
)$(TFTPBOOT
)/efi
$(BITS
)
366 install -m
644 $(NETINSTALLABLE
) $(INSTALLROOT
)$(TFTPBOOT
)/efi
$(BITS
)
368 netinstall
: installer
369 mkdir
-p
$(INSTALLROOT
)$(TFTPBOOT
)
370 install -m
644 $(NETINSTALLABLE
) $(INSTALLROOT
)$(TFTPBOOT
)
373 extbootinstall
: installer
374 mkdir
-m
755 -p
$(INSTALLROOT
)$(EXTLINUXDIR
)
375 install -m
644 $(EXTBOOTINSTALL
) $(INSTALLROOT
)$(EXTLINUXDIR
)
377 install-all
: install netinstall extbootinstall
380 rm -f
*.o
*.elf
*_bin.c stupid.
* patch.offset
381 rm -f
*.lsr
*.lst
*.map
*.sec
*.tmp
384 tidy
: local-tidy
$(BESUBDIRS
) $(IESUBDIRS
) $(BSUBDIRS
) $(ISUBDIRS
)
389 clean: local-tidy local-clean
$(BESUBDIRS
) $(IESUBDIRS
) $(BSUBDIRS
) $(ISUBDIRS
)
392 find . \
( -name
'*~' -o
-name
'#*' -o
-name core \
393 -o
-name
'.*.d' -o
-name .depend \
) -type f
-print0 \
396 dist: local-dist local-tidy
$(BESUBDIRS
) $(IESUBDIRS
) $(BSUBDIRS
) $(ISUBDIRS
)
398 # Shortcut to build linux/syslinux using klibc
401 $(MAKE
) CC
=klcc ITARGET
= ISUBDIRS
='linux extlinux' BSUBDIRS
=
402 endif # ifeq ($(HAVE_FIRMWARE),)
404 endif # ifeq ($(topdir),)
407 find . \
( -name
'*~' -o
-name
'#*' -o
-name core \
408 -o
-name
'.*.d' -o
-name .depend
-o
-name
'*.so.*' \
) \
412 ifeq ($(do-spotless-gpxe
),)
416 $(MAKE
) -C
"$(topdir)/gpxe" SRC
="$(topdir)/gpxe" spotless
419 spotless
: local-spotless spotless-gpxe
420 rm -rf
$(all_firmware
)
423 # Common rules that are needed by every invocation of make.
425 $(OBJDIR
)/version.mk
: $(topdir
)/version
$(topdir
)/version.pl
426 $(PERL
) $(topdir
)/version.pl
$< $@
'< := @'