Merge commit 'origin/gpxe-support' into gpxe-added
[syslinux.git] / Makefile
blob7e6088a9300334cb6a6de013aa246d9863067929
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 gpxelinux.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 gpxelinux.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 -f $< $@
166 gpxelinux.0: pxelinux.0
167 $(MAKE) -C gpxe/src bin/undionly.kpxe
168 cp -f gpxe/src/bin/undionly.kpxe $@
170 ldlinux.bss: ldlinux.bin
171 dd if=$< of=$@ bs=512 count=1
173 ldlinux.sys: ldlinux.bin
174 dd if=$< of=$@ bs=512 skip=1
176 extlinux.bss: extlinux.bin
177 dd if=$< of=$@ bs=512 count=1
179 extlinux.sys: extlinux.bin
180 dd if=$< of=$@ bs=512 skip=1
182 mbr_bin.c: mbr/mbr.bin bin2c.pl
183 $(PERL) bin2c.pl syslinux_mbr < $< > $@
185 copybs.com: copybs.asm
186 $(NASM) $(NASMOPT) -f bin -l copybs.lst -o copybs.com copybs.asm
188 bootsect_bin.c: ldlinux.bss bin2c.pl
189 $(PERL) bin2c.pl syslinux_bootsect < $< > $@
191 ldlinux_bin.c: ldlinux.sys bin2c.pl
192 $(PERL) bin2c.pl syslinux_ldlinux < $< > $@
194 extlinux_bss_bin.c: extlinux.bss bin2c.pl
195 $(PERL) bin2c.pl extlinux_bootsect < $< > $@
197 extlinux_sys_bin.c: extlinux.sys bin2c.pl
198 $(PERL) bin2c.pl extlinux_image 512 < $< > $@
200 gethostip: gethostip.o
201 $(CC) $(LDFLAGS) -o $@ $^
203 mkdiskimage: mkdiskimage.in mbr/mbr.bin bin2hex.pl
204 $(PERL) bin2hex.pl < mbr/mbr.bin | cat mkdiskimage.in - > $@
205 chmod a+x $@
207 install: installer
208 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
209 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
210 mkdir -m 755 -p $(INSTALLROOT)$(SBINDIR)
211 install -m 755 -c $(INSTALL_SBIN) $(INSTALLROOT)$(SBINDIR)
212 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
213 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
214 -install -m 644 -c $(INSTALL_AUX_OPT) $(INSTALLROOT)$(AUXDIR)
215 mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man1
216 install -m 644 -c man/*.1 $(INSTALLROOT)$(MANDIR)/man1
217 : mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man8
218 : install -m 644 -c man/*.8 $(INSTALLROOT)$(MANDIR)/man8
219 $(MAKE) -C com32 install
221 install-lib: installer
223 install-all: install install-lib
225 NETINSTALLABLE = pxelinux.0 memdisk/memdisk memdump/memdump.com \
226 com32/menu/*.c32 com32/modules/*.c32
228 netinstall: installer
229 mkdir -p $(INSTALLROOT)$(TFTPBOOT)
230 install -m 644 $(NETINSTALLABLE) $(INSTALLROOT)$(TFTPBOOT)
232 local-tidy:
233 rm -f *.o *_bin.c stupid.* patch.offset
234 rm -f *.lsr *.lst *.map
235 rm -f $(OBSOLETE)
236 $(MAKE) -C gpxe/src veryclean
238 tidy: local-tidy
239 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
241 local-clean:
242 rm -f $(ITARGET)
244 clean: local-tidy local-clean
245 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
247 dist: tidy
248 find . \( -name '*~' -o -name '#*' -o -name core \
249 -o -name '.*.d' -o -name .depend \) -type f -print0 \
250 | xargs -0rt rm -f
252 local-spotless:
253 rm -f $(BTARGET) .depend *.so.*
255 spotless: local-clean dist local-spotless
256 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
258 .depend:
259 rm -f .depend
260 for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done
261 for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
263 local-depend:
264 rm -f .depend
265 $(MAKE) .depend
267 depend: local-depend
268 $(MAKE) -C memdisk depend
270 # Shortcut to build unix/syslinux using klibc
271 klibc:
272 $(MAKE) clean
273 $(MAKE) CC=klcc ITARGET= ISUBDIRS='unix extlinux' BSUBDIRS=
275 # Hook to add private Makefile targets for the maintainer.
276 -include Makefile.private
278 # Include dependencies file
279 include .depend