1 ## -----------------------------------------------------------------------
3 ## Copyright 1998-2006 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 OSTYPE = $(shell uname -msr)
23 CFLAGS = -W -Wall -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
34 AUXDIR = $(LIBDIR)/syslinux
39 VERSION = $(shell cat version)
42 $(CC) $(INCLUDE) $(CFLAGS) -c $<
45 # The BTARGET refers to objects that are derived from ldlinux.asm; we
46 # like to keep those uniform for debugging reasons; however, distributors
47 # want to recompile the installers (ITARGET).
49 # BOBJECTS and IOBJECTS are the same thing, except used for
50 # installation, so they include objects that may be in subdirectories
51 # with their own Makefiles. Finally, there is a list of those
54 CSRC = syslxmod.c gethostip.c
55 NASMSRC = $(wildcard *.asm)
56 SOURCES = $(CSRC) *.h $(NASMSRC) *.inc
58 # _bin.c files required by both BTARGET and ITARGET installers
59 BINFILES = bootsect_bin.c ldlinux_bin.c mbr_bin.c \
60 extlinux_bss_bin.c extlinux_sys_bin.c
62 # syslinux.exe is BTARGET so as to not require everyone to have the
63 # mingw suite installed
64 BTARGET = kwdhash.gen version.gen version.h \
65 ldlinux.bss ldlinux.sys ldlinux.bin \
66 pxelinux.0 isolinux.bin isolinux-debug.bin \
67 extlinux.bin extlinux.bss extlinux.sys
68 BOBJECTS = $(BTARGET) mbr/mbr.bin dos/syslinux.com win32/syslinux.exe memdisk/memdisk
69 # BESUBDIRS and IESUBDIRS are "early", i.e. before the root; BSUBDIRS
70 # and ISUBDIRS are "late", after the root.
72 BSUBDIRS = memdisk dos win32
73 ITARGET = copybs.com gethostip mkdiskimage
74 IOBJECTS = $(ITARGET) mtools/syslinux unix/syslinux extlinux/extlinux
76 ISUBDIRS = mtools unix extlinux sample com32
77 DOCS = COPYING NEWS README TODO BUGS *.doc sample menu com32
78 OTHER = Makefile bin2c.pl now.pl genhash.pl keywords findpatch.pl \
79 keytab-lilo.pl version version.pl sys2ansi.pl \
80 ppmtolss16 lss16toppm memdisk bin2hex.pl mkdiskimage.in
81 OBSOLETE = pxelinux.bin
83 # Things to install in /usr/bin
84 INSTALL_BIN = mtools/syslinux gethostip ppmtolss16 lss16toppm
85 # Things to install in /sbin
86 INSTALL_SBIN = extlinux/extlinux
87 # Things to install in /usr/lib/syslinux
88 INSTALL_AUX = pxelinux.0 isolinux.bin isolinux-debug.bin \
89 dos/syslinux.com copybs.com memdisk/memdisk mbr/mbr.bin
90 INSTALL_AUX_OPT = win32/syslinux.exe
92 # The DATE is set on the make command line when building binaries for
93 # official release. Otherwise, substitute a hex string that is pretty much
94 # guaranteed to be unique to be unique from build to build.
96 HEXDATE := $(shell $(PERL) now.pl ldlinux.asm pxelinux.asm isolinux.asm)
101 MAKE += DATE=$(DATE) HEXDATE=$(HEXDATE)
104 # NOTE: If you don't have the mingw compiler suite installed, you probably
105 # want to remove win32 from this list; otherwise you're going to get an
106 # error every time you try to build.
110 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) ; do $(MAKE) -C $$i $@ ; done
112 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
113 -ls -l $(BOBJECTS) $(IOBJECTS)
115 all-local: $(BTARGET) $(ITARGET) $(BINFILES)
117 installer: installer-local
118 set -e ; for i in $(ISUBDIRS); do $(MAKE) -C $$i all ; done
119 -ls -l $(BOBJECTS) $(IOBJECTS)
121 installer-local: $(ITARGET) $(BINFILES)
123 version.gen: version version.pl
124 $(PERL) version.pl $< $@ '%define'
126 version.h: version version.pl
127 $(PERL) version.pl $< $@ '#define'
129 kwdhash.gen: keywords genhash.pl
130 $(PERL) genhash.pl < keywords > kwdhash.gen
132 ldlinux.bin: ldlinux.asm kwdhash.gen version.gen
133 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
134 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
135 $(PERL) checkov.pl ldlinux.map $@
137 pxelinux.bin: pxelinux.asm kwdhash.gen version.gen
138 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
139 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
140 $(PERL) checkov.pl $(@:.bin=.map) $@
142 isolinux.bin: isolinux.asm kwdhash.gen version.gen checksumiso.pl
143 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
144 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
145 $(PERL) checkov.pl $(@:.bin=.map) $@
146 $(PERL) checksumiso.pl $@
148 # Special verbose version of isolinux.bin
149 isolinux-debug.bin: isolinux-debug.asm kwdhash.gen version.gen checksumiso.pl
150 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
151 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
152 $(PERL) checkov.pl $(@:.bin=.map) $@
153 $(PERL) checksumiso.pl $@
155 extlinux.bin: extlinux.asm kwdhash.gen version.gen
156 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
157 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
158 $(PERL) checkov.pl $(@:.bin=.map) $@
160 pxelinux.0: pxelinux.bin
161 cp pxelinux.bin pxelinux.0
163 ldlinux.bss: ldlinux.bin
164 dd if=$< of=$@ bs=512 count=1
166 ldlinux.sys: ldlinux.bin
167 dd if=$< of=$@ bs=512 skip=1
169 extlinux.bss: extlinux.bin
170 dd if=$< of=$@ bs=512 count=1
172 extlinux.sys: extlinux.bin
173 dd if=$< of=$@ bs=512 skip=1
175 mbr_bin.c: mbr/mbr.bin bin2c.pl
176 $(PERL) bin2c.pl syslinux_mbr < $< > $@
178 copybs.com: copybs.asm
179 $(NASM) -f bin -l copybs.lst -o copybs.com copybs.asm
181 bootsect_bin.c: ldlinux.bss bin2c.pl
182 $(PERL) bin2c.pl syslinux_bootsect < $< > $@
184 ldlinux_bin.c: ldlinux.sys bin2c.pl
185 $(PERL) bin2c.pl syslinux_ldlinux < $< > $@
187 extlinux_bss_bin.c: extlinux.bss bin2c.pl
188 $(PERL) bin2c.pl extlinux_bootsect < $< > $@
190 extlinux_sys_bin.c: extlinux.sys bin2c.pl
191 $(PERL) bin2c.pl extlinux_image < $< > $@
193 libsyslinux.a: bootsect_bin.o ldlinux_bin.o mbr_bin.o syslxmod.o
198 $(LIB_SO): bootsect_bin.o ldlinux_bin.o syslxmod.o
199 $(CC) $(LDFLAGS) -shared -Wl,-soname,$(LIB_SONAME) -o $@ $^
201 gethostip: gethostip.o
202 $(CC) $(LDFLAGS) -o $@ $^
204 mkdiskimage: mkdiskimage.in mbr.bin bin2hex.pl
205 $(PERL) bin2hex.pl < mbr.bin | cat mkdiskimage.in - > $@
209 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
210 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
211 mkdir -m 755 -p $(INSTALLROOT)$(SBINDIR)
212 install -m 755 -c $(INSTALL_SBIN) $(INSTALLROOT)$(SBINDIR)
213 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
214 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
215 -install -m 644 -c $(INSTALL_AUX_OPT) $(INSTALLROOT)$(AUXDIR)
216 $(MAKE) -C com32 install
218 install-lib: installer
220 install-all: install install-lib
223 rm -f *.o *_bin.c stupid.* patch.offset
228 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
233 clean: local-tidy local-clean
234 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
237 for dir in . sample memdisk ; do \
238 ( cd $$dir && rm -f *~ \#* core ) ; \
242 rm -f $(BTARGET) .depend *.so.*
244 spotless: local-clean dist local-spotless
245 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
249 for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done
250 for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
257 $(MAKE) -C memdisk depend
259 # Shortcut to build unix/syslinux using klibc
262 $(MAKE) CC=klcc ITARGET= ISUBDIRS='unix extlinux' BSUBDIRS=
264 # Hook to add private Makefile targets for the maintainer.
265 -include Makefile.private
267 # Include dependencies file