Support LOCALBOOT (ISOLINUX-style) in SYSLINUX/EXTLINUX
[syslinux.git] / Makefile
blob643076048c6d146fc1505c03c77269cf22e0e244
1 ## -----------------------------------------------------------------------
2 ##
3 ## Copyright 1998-2008 H. Peter Anvin - All Rights Reserved
4 ##
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 ## Boston MA 02111-1307, USA; either version 2 of the License, or
9 ## (at your option) any later version; incorporated herein by reference.
11 ## -----------------------------------------------------------------------
14 # Main Makefile for SYSLINUX
17 # No builtin rules
18 MAKEFLAGS = -r
20 TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
22 gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) dummy.c -o $$tmpf 2>/dev/null; \
23 then echo '$(1)'; else echo '$(2)'; fi; rm -f $$tmpf)
25 comma := ,
26 LDHASH := $(call gcc_ok,-Wl$(comma)--hash-style=both,)
28 OSTYPE = $(shell uname -msr)
29 CC = gcc
30 INCLUDE =
31 CFLAGS = -W -Wall -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
32 PIC = -fPIC
33 LDFLAGS = -O2 -s $(LDHASH)
34 AR = ar
35 RANLIB = ranlib
37 NASM = nasm
38 NASMOPT = -O9999
39 NINCLUDE =
40 BINDIR = /usr/bin
41 SBINDIR = /sbin
42 LIBDIR = /usr/lib
43 AUXDIR = $(LIBDIR)/syslinux
44 MANDIR = /usr/man
45 INCDIR = /usr/include
46 TFTPBOOT = /tftpboot
48 PERL = perl
50 VERSION = $(shell cat version)
52 %.o: %.c
53 $(CC) $(INCLUDE) $(CFLAGS) -c $<
56 # The BTARGET refers to objects that are derived from ldlinux.asm; we
57 # like to keep those uniform for debugging reasons; however, distributors
58 # want to recompile the installers (ITARGET).
60 # BOBJECTS and IOBJECTS are the same thing, except used for
61 # installation, so they include objects that may be in subdirectories
62 # with their own Makefiles. Finally, there is a list of those
63 # directories.
65 CSRC = gethostip.c
66 NASMSRC = $(wildcard *.asm)
67 SOURCES = $(CSRC) *.h $(NASMSRC) *.inc
69 # _bin.c files required by both BTARGET and ITARGET installers
70 BINFILES = bootsect_bin.c ldlinux_bin.c mbr_bin.c \
71 extlinux_bss_bin.c extlinux_sys_bin.c
73 # syslinux.exe is BTARGET so as to not require everyone to have the
74 # mingw suite installed
75 BTARGET = kwdhash.gen version.gen version.h \
76 ldlinux.bss ldlinux.sys ldlinux.bin \
77 pxelinux.0 isolinux.bin isolinux-debug.bin \
78 extlinux.bin extlinux.bss extlinux.sys
79 BOBJECTS = $(BTARGET) mbr/mbr.bin dos/syslinux.com win32/syslinux.exe \
80 memdisk/memdisk memdump/memdump.com
81 # BESUBDIRS and IESUBDIRS are "early", i.e. before the root; BSUBDIRS
82 # and ISUBDIRS are "late", after the root.
83 BESUBDIRS = mbr
84 BSUBDIRS = memdisk memdump dos win32
85 ITARGET = copybs.com gethostip mkdiskimage
86 IOBJECTS = $(ITARGET) mtools/syslinux unix/syslinux extlinux/extlinux
87 IESUBDIRS =
88 ISUBDIRS = mtools unix extlinux sample com32
89 DOCS = COPYING NEWS README TODO BUGS *.doc sample menu com32
90 OTHER = Makefile bin2c.pl now.pl genhash.pl keywords findpatch.pl \
91 keytab-lilo.pl version version.pl sys2ansi.pl \
92 ppmtolss16 lss16toppm memdisk bin2hex.pl mkdiskimage.in \
93 sha1pass md5pass
94 OBSOLETE = pxelinux.bin
96 # Things to install in /usr/bin
97 INSTALL_BIN = mtools/syslinux gethostip ppmtolss16 lss16toppm \
98 sha1pass md5pass
99 # Things to install in /sbin
100 INSTALL_SBIN = extlinux/extlinux
101 # Things to install in /usr/lib/syslinux
102 INSTALL_AUX = pxelinux.0 isolinux.bin isolinux-debug.bin \
103 dos/syslinux.com copybs.com memdisk/memdisk mbr/mbr.bin
104 INSTALL_AUX_OPT = win32/syslinux.exe
106 # The DATE is set on the make command line when building binaries for
107 # official release. Otherwise, substitute a hex string that is pretty much
108 # guaranteed to be unique to be unique from build to build.
109 ifndef HEXDATE
110 HEXDATE := $(shell $(PERL) now.pl ldlinux.asm pxelinux.asm isolinux.asm)
111 endif
112 ifndef DATE
113 DATE := $(HEXDATE)
114 endif
115 MAKE += DATE=$(DATE) HEXDATE=$(HEXDATE)
118 # NOTE: If you don't have the mingw compiler suite installed, you probably
119 # want to remove win32 from this list; otherwise you're going to get an
120 # error every time you try to build.
123 all:
124 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) ; do $(MAKE) -C $$i $@ ; done
125 $(MAKE) all-local
126 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
127 -ls -l $(BOBJECTS) $(IOBJECTS)
129 all-local: $(BTARGET) $(ITARGET) $(BINFILES)
131 installer:
132 set -e ; for i in $(IESUBDIRS); do $(MAKE) -C $$i all ; done
133 $(MAKE) installer-local
134 set -e ; for i in $(ISUBDIRS); do $(MAKE) -C $$i all ; done
135 -ls -l $(BOBJECTS) $(IOBJECTS)
137 installer-local: $(ITARGET) $(BINFILES)
139 version.gen: version version.pl
140 $(PERL) version.pl $< $@ '%define'
142 version.h: version version.pl
143 $(PERL) version.pl $< $@ '#define'
145 kwdhash.gen: keywords genhash.pl
146 $(PERL) genhash.pl < keywords > kwdhash.gen
148 # Standard rule for {isolinux,isolinux-debug}.bin
149 iso%.bin: iso%.asm kwdhash.gen version.gen
150 $(NASM) $(NASMOPT) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
151 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lsr) -o $@ $<
152 $(PERL) lstadjust.pl $(@:.bin=.lsr) $(@:.bin=.map) $(@:.bin=.lst)
153 $(PERL) checksumiso.pl $@
154 $(PERL) checkov.pl $(@:.bin=.map) $@
156 # Standard rule for {ldlinux,pxelinux,extlinux}.bin
157 %.bin: %.asm kwdhash.gen version.gen
158 $(NASM) $(NASMOPT) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
159 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lsr) -o $@ $<
160 $(PERL) lstadjust.pl $(@:.bin=.lsr) $(@:.bin=.map) $(@:.bin=.lst)
161 $(PERL) checkov.pl $(@:.bin=.map) $@
163 pxelinux.0: pxelinux.bin
164 cp pxelinux.bin pxelinux.0
166 ldlinux.bss: ldlinux.bin
167 dd if=$< of=$@ bs=512 count=1
169 ldlinux.sys: ldlinux.bin
170 dd if=$< of=$@ bs=512 skip=1
172 extlinux.bss: extlinux.bin
173 dd if=$< of=$@ bs=512 count=1
175 extlinux.sys: extlinux.bin
176 dd if=$< of=$@ bs=512 skip=1
178 mbr_bin.c: mbr/mbr.bin bin2c.pl
179 $(PERL) bin2c.pl syslinux_mbr < $< > $@
181 copybs.com: copybs.asm
182 $(NASM) $(NASMOPT) -f bin -l copybs.lst -o copybs.com copybs.asm
184 bootsect_bin.c: ldlinux.bss bin2c.pl
185 $(PERL) bin2c.pl syslinux_bootsect < $< > $@
187 ldlinux_bin.c: ldlinux.sys bin2c.pl
188 $(PERL) bin2c.pl syslinux_ldlinux < $< > $@
190 extlinux_bss_bin.c: extlinux.bss bin2c.pl
191 $(PERL) bin2c.pl extlinux_bootsect < $< > $@
193 extlinux_sys_bin.c: extlinux.sys bin2c.pl
194 $(PERL) bin2c.pl extlinux_image 512 < $< > $@
196 gethostip: gethostip.o
197 $(CC) $(LDFLAGS) -o $@ $^
199 mkdiskimage: mkdiskimage.in mbr/mbr.bin bin2hex.pl
200 $(PERL) bin2hex.pl < mbr/mbr.bin | cat mkdiskimage.in - > $@
201 chmod a+x $@
203 install: installer
204 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
205 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
206 mkdir -m 755 -p $(INSTALLROOT)$(SBINDIR)
207 install -m 755 -c $(INSTALL_SBIN) $(INSTALLROOT)$(SBINDIR)
208 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
209 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
210 -install -m 644 -c $(INSTALL_AUX_OPT) $(INSTALLROOT)$(AUXDIR)
211 mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man1
212 install -m 644 -c man/*.1 $(INSTALLROOT)$(MANDIR)/man1
213 : mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man8
214 : install -m 644 -c man/*.8 $(INSTALLROOT)$(MANDIR)/man8
215 $(MAKE) -C com32 install
217 install-lib: installer
219 install-all: install install-lib
221 NETINSTALLABLE = pxelinux.0 memdisk/memdisk memdump/memdump.com \
222 com32/menu/*.c32 com32/modules/*.c32
224 netinstall: installer
225 mkdir -p $(INSTALLROOT)$(TFTPBOOT)
226 install -m 644 $(NETINSTALLABLE) $(INSTALLROOT)$(TFTPBOOT)
228 local-tidy:
229 rm -f *.o *_bin.c stupid.* patch.offset
230 rm -f *.lsr *.lst *.map
231 rm -f $(OBSOLETE)
233 tidy: local-tidy
234 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
236 local-clean:
237 rm -f $(ITARGET)
239 clean: local-tidy local-clean
240 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
242 dist: tidy
243 find . \( -name '*~' -o -name '#*' -o -name core \
244 -o -name '.*.d' -o -name .depend \) -type f -print0 \
245 | xargs -0rt rm -f
247 local-spotless:
248 rm -f $(BTARGET) .depend *.so.*
250 spotless: local-clean dist local-spotless
251 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
253 .depend:
254 rm -f .depend
255 for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done
256 for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
258 local-depend:
259 rm -f .depend
260 $(MAKE) .depend
262 depend: local-depend
263 $(MAKE) -C memdisk depend
265 # Shortcut to build unix/syslinux using klibc
266 klibc:
267 $(MAKE) clean
268 $(MAKE) CC=klcc ITARGET= ISUBDIRS='unix extlinux' BSUBDIRS=
270 # Hook to add private Makefile targets for the maintainer.
271 -include Makefile.private
273 # Include dependencies file
274 include .depend