1 ## -----------------------------------------------------------------------
3 ## Copyright 1998-2008 H. Peter Anvin - All Rights Reserved
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
20 TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
22 gcc_ok = $(shell tmpf=$(TMPFILE); if gcc $(1) dummy.c -o $$tmpf 2>/dev/null; \
23 then echo '$(1)'; else echo '$(2)'; fi; rm -f $$tmpf)
26 LDHASH := $(call gcc_ok,-Wl$(comma)--hash-style=both,)
28 OSTYPE = $(shell uname -msr)
31 CFLAGS = -W -Wall -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
33 LDFLAGS = -O2 -s $(LDHASH)
43 AUXDIR = $(LIBDIR)/syslinux
49 VERSION = $(shell cat version)
52 $(CC) $(INCLUDE) $(CFLAGS) -c $<
55 # The BTARGET refers to objects that are derived from ldlinux.asm; we
56 # like to keep those uniform for debugging reasons; however, distributors
57 # want to recompile the installers (ITARGET).
59 # BOBJECTS and IOBJECTS are the same thing, except used for
60 # installation, so they include objects that may be in subdirectories
61 # with their own Makefiles. Finally, there is a list of those
64 CSRC = syslxmod.c gethostip.c
65 NASMSRC = $(wildcard *.asm)
66 SOURCES = $(CSRC) *.h $(NASMSRC) *.inc
68 # _bin.c files required by both BTARGET and ITARGET installers
69 BINFILES = bootsect_bin.c ldlinux_bin.c mbr_bin.c \
70 extlinux_bss_bin.c extlinux_sys_bin.c
72 # syslinux.exe is BTARGET so as to not require everyone to have the
73 # mingw suite installed
74 BTARGET = kwdhash.gen version.gen version.h \
75 ldlinux.bss ldlinux.sys ldlinux.bin \
76 pxelinux.0 isolinux.bin isolinux-debug.bin \
77 extlinux.bin extlinux.bss extlinux.sys
78 BOBJECTS = $(BTARGET) mbr/mbr.bin dos/syslinux.com win32/syslinux.exe \
79 memdisk/memdisk memdump/memdump.com
80 # BESUBDIRS and IESUBDIRS are "early", i.e. before the root; BSUBDIRS
81 # and ISUBDIRS are "late", after the root.
83 BSUBDIRS = memdisk memdump dos win32
84 ITARGET = copybs.com gethostip mkdiskimage
85 IOBJECTS = $(ITARGET) mtools/syslinux unix/syslinux extlinux/extlinux
87 ISUBDIRS = mtools unix extlinux sample com32
88 DOCS = COPYING NEWS README TODO BUGS *.doc sample menu com32
89 OTHER = Makefile bin2c.pl now.pl genhash.pl keywords findpatch.pl \
90 keytab-lilo.pl version version.pl sys2ansi.pl \
91 ppmtolss16 lss16toppm memdisk bin2hex.pl mkdiskimage.in \
93 OBSOLETE = pxelinux.bin
95 # Things to install in /usr/bin
96 INSTALL_BIN = mtools/syslinux gethostip ppmtolss16 lss16toppm \
98 # Things to install in /sbin
99 INSTALL_SBIN = extlinux/extlinux
100 # Things to install in /usr/lib/syslinux
101 INSTALL_AUX = pxelinux.0 isolinux.bin isolinux-debug.bin \
102 dos/syslinux.com copybs.com memdisk/memdisk mbr/mbr.bin
103 INSTALL_AUX_OPT = win32/syslinux.exe
105 # The DATE is set on the make command line when building binaries for
106 # official release. Otherwise, substitute a hex string that is pretty much
107 # guaranteed to be unique to be unique from build to build.
109 HEXDATE := $(shell $(PERL) now.pl ldlinux.asm pxelinux.asm isolinux.asm)
114 MAKE += DATE=$(DATE) HEXDATE=$(HEXDATE)
117 # NOTE: If you don't have the mingw compiler suite installed, you probably
118 # want to remove win32 from this list; otherwise you're going to get an
119 # error every time you try to build.
123 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) ; do $(MAKE) -C $$i $@ ; done
125 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
126 -ls -l $(BOBJECTS) $(IOBJECTS)
128 all-local: $(BTARGET) $(ITARGET) $(BINFILES)
131 set -e ; for i in $(IESUBDIRS); do $(MAKE) -C $$i all ; done
132 $(MAKE) installer-local
133 set -e ; for i in $(ISUBDIRS); do $(MAKE) -C $$i all ; done
134 -ls -l $(BOBJECTS) $(IOBJECTS)
136 installer-local: $(ITARGET) $(BINFILES)
138 version.gen: version version.pl
139 $(PERL) version.pl $< $@ '%define'
141 version.h: version version.pl
142 $(PERL) version.pl $< $@ '#define'
144 kwdhash.gen: keywords genhash.pl
145 $(PERL) genhash.pl < keywords > kwdhash.gen
147 # Standard rule for {ldlinux,pxelinux,isolinux,isolinux-debug,extlinux}.bin
148 %.bin: %.asm kwdhash.gen version.gen
149 $(NASM) $(NASMOPT) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
150 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lsr) -o $@ $<
151 $(PERL) lstadjust.pl $(@:.bin=.lsr) $(@:.bin=.map) $(@:.bin=.lst)
152 $(PERL) checkov.pl $(@:.bin=.map) $@
154 pxelinux.0: pxelinux.bin
155 cp pxelinux.bin pxelinux.0
157 ldlinux.bss: ldlinux.bin
158 dd if=$< of=$@ bs=512 count=1
160 ldlinux.sys: ldlinux.bin
161 dd if=$< of=$@ bs=512 skip=1
163 extlinux.bss: extlinux.bin
164 dd if=$< of=$@ bs=512 count=1
166 extlinux.sys: extlinux.bin
167 dd if=$< of=$@ bs=512 skip=1
169 mbr_bin.c: mbr/mbr.bin bin2c.pl
170 $(PERL) bin2c.pl syslinux_mbr < $< > $@
172 copybs.com: copybs.asm
173 $(NASM) $(NASMOPT) -f bin -l copybs.lst -o copybs.com copybs.asm
175 bootsect_bin.c: ldlinux.bss bin2c.pl
176 $(PERL) bin2c.pl syslinux_bootsect < $< > $@
178 ldlinux_bin.c: ldlinux.sys bin2c.pl
179 $(PERL) bin2c.pl syslinux_ldlinux < $< > $@
181 extlinux_bss_bin.c: extlinux.bss bin2c.pl
182 $(PERL) bin2c.pl extlinux_bootsect < $< > $@
184 extlinux_sys_bin.c: extlinux.sys bin2c.pl
185 $(PERL) bin2c.pl extlinux_image < $< > $@
187 libsyslinux.a: bootsect_bin.o ldlinux_bin.o mbr_bin.o syslxmod.o
192 $(LIB_SO): bootsect_bin.o ldlinux_bin.o syslxmod.o
193 $(CC) $(LDFLAGS) -shared -Wl,-soname,$(LIB_SONAME) -o $@ $^
195 gethostip: gethostip.o
196 $(CC) $(LDFLAGS) -o $@ $^
198 mkdiskimage: mkdiskimage.in mbr/mbr.bin bin2hex.pl
199 $(PERL) bin2hex.pl < mbr/mbr.bin | cat mkdiskimage.in - > $@
203 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
204 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
205 mkdir -m 755 -p $(INSTALLROOT)$(SBINDIR)
206 install -m 755 -c $(INSTALL_SBIN) $(INSTALLROOT)$(SBINDIR)
207 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
208 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
209 -install -m 644 -c $(INSTALL_AUX_OPT) $(INSTALLROOT)$(AUXDIR)
210 mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man1
211 install -m 644 -c man/*.1 $(INSTALLROOT)$(MANDIR)/man1
212 : mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man8
213 : install -m 644 -c man/*.8 $(INSTALLROOT)$(MANDIR)/man8
214 $(MAKE) -C com32 install
216 install-lib: installer
218 install-all: install install-lib
221 rm -f *.o *_bin.c stupid.* patch.offset
222 rm -f *.lsr *.lst *.map
226 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
231 clean: local-tidy local-clean
232 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
235 for dir in . sample memdisk ; do \
236 ( cd $$dir && rm -f *~ \#* core ) ; \
240 rm -f $(BTARGET) .depend *.so.*
242 spotless: local-clean dist local-spotless
243 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
247 for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done
248 for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
255 $(MAKE) -C memdisk depend
257 # Shortcut to build unix/syslinux using klibc
260 $(MAKE) CC=klcc ITARGET= ISUBDIRS='unix extlinux' BSUBDIRS=
262 # Hook to add private Makefile targets for the maintainer.
263 -include Makefile.private
265 # Include dependencies file