2 ## -----------------------------------------------------------------------
4 ## Copyright 1998-2004 H. Peter Anvin - All Rights Reserved
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 OSTYPE = $(shell uname -msr)
21 CFLAGS = -W -Wall -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
32 AUXDIR = $(LIBDIR)/syslinux
37 VERSION = $(shell cat version)
40 $(CC) $(INCLUDE) $(CFLAGS) -c $<
43 # The BTARGET refers to objects that are derived from ldlinux.asm; we
44 # like to keep those uniform for debugging reasons; however, distributors
45 # want to recompile the installers (ITARGET).
47 # BOBJECTS and IOBJECTS are the same thing, except used for
48 # installation, so they include objects that may be in subdirectories
49 # with their own Makefiles. Finally, there is a list of those
52 CSRC = syslxmod.c gethostip.c
53 NASMSRC = ldlinux.asm copybs.asm pxelinux.asm mbr.asm isolinux.asm
54 SOURCES = $(CSRC) *.h $(NASMSRC) *.inc
56 # _bin.c files required by both BTARGET and ITARGET installers
57 BINFILES = bootsect_bin.c ldlinux_bin.c mbr_bin.c \
58 extlinux_bss_bin.c extlinux_sys_bin.c
60 # syslinux.exe is BTARGET so as to not require everyone to have the
61 # mingw suite installed
62 BTARGET = kwdhash.gen version.gen ldlinux.bss ldlinux.sys ldlinux.bin \
63 pxelinux.0 mbr.bin isolinux.bin isolinux-debug.bin \
64 extlinux.bin extlinux.bss extlinux.sys
65 BOBJECTS = $(BTARGET) dos/syslinux.com win32/syslinux.exe memdisk/memdisk
66 BSUBDIRS = memdisk dos win32
67 ITARGET = copybs.com gethostip mkdiskimage
68 IOBJECTS = $(ITARGET) mtools/syslinux unix/syslinux extlinux/extlinux
69 ISUBDIRS = mtools unix extlinux sample com32
70 DOCS = COPYING NEWS README TODO BUGS *.doc sample menu com32
71 OTHER = Makefile bin2c.pl now.pl genhash.pl keywords findpatch.pl \
72 keytab-lilo.pl version version.pl sys2ansi.pl \
73 ppmtolss16 lss16toppm memdisk bin2hex.pl mkdiskimage.in
74 OBSOLETE = pxelinux.bin
76 # Things to install in /usr/bin
77 INSTALL_BIN = mtools/syslinux gethostip ppmtolss16 lss16toppm
78 # Things to install in /sbin
79 INSTALL_SBIN = extlinux/extlinux
80 # Things to install in /usr/lib/syslinux
81 INSTALL_AUX = pxelinux.0 isolinux.bin isolinux-debug.bin \
82 dos/syslinux.com copybs.com memdisk/memdisk
83 INSTALL_AUX_OPT = win32/syslinux.exe
85 # The DATE is set on the make command line when building binaries for
86 # official release. Otherwise, substitute a hex string that is pretty much
87 # guaranteed to be unique to be unique from build to build.
89 HEXDATE := $(shell $(PERL) now.pl ldlinux.asm pxelinux.asm isolinux.asm)
94 MAKE += DATE=$(DATE) HEXDATE=$(HEXDATE)
97 # NOTE: If you don't have the mingw compiler suite installed, you probably
98 # want to remove win32 from this list; otherwise you're going to get an
99 # error every time you try to build.
103 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
105 -ls -l $(BOBJECTS) $(IOBJECTS)
107 all-local: $(BTARGET) $(ITARGET) $(BINFILES)
109 installer: installer-local
110 set -e ; for i in $(ISUBDIRS); do $(MAKE) -C $$i all ; done
111 -ls -l $(BOBJECTS) $(IOBJECTS)
113 installer-local: $(ITARGET) $(BINFILES)
115 version.gen: version version.pl
116 $(PERL) version.pl version
118 kwdhash.gen: keywords genhash.pl
119 $(PERL) genhash.pl < keywords > kwdhash.gen
121 ldlinux.bin: ldlinux.asm kwdhash.gen version.gen
122 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
123 -DMAP=ldlinux.map -l ldlinux.lst -o ldlinux.bin ldlinux.asm
125 pxelinux.bin: pxelinux.asm kwdhash.gen version.gen
126 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
127 -DMAP=pxelinux.map -l pxelinux.lst -o pxelinux.bin pxelinux.asm
129 isolinux.bin: isolinux.asm kwdhash.gen version.gen checksumiso.pl
130 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
131 -DMAP=isolinux.map -l isolinux.lst -o isolinux.bin isolinux.asm
132 $(PERL) checksumiso.pl isolinux.bin
134 # Special verbose version of isolinux.bin
135 isolinux-debug.bin: isolinux.asm kwdhash.gen version.gen checksumiso.pl
136 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
138 -DMAP=isolinux-debug.map -l isolinux-debug.lst \
139 -o isolinux-debug.bin isolinux.asm
140 $(PERL) checksumiso.pl $@
142 extlinux.bin: extlinux.asm kwdhash.gen version.gen
143 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
144 -DMAP=extlinux.map -l extlinux.lst -o extlinux.bin extlinux.asm
146 pxelinux.0: pxelinux.bin
147 cp pxelinux.bin pxelinux.0
149 ldlinux.bss: ldlinux.bin
150 dd if=$< of=$@ bs=512 count=1
152 ldlinux.sys: ldlinux.bin
153 dd if=$< of=$@ bs=512 skip=1
155 extlinux.bss: extlinux.bin
156 dd if=$< of=$@ bs=512 count=1
158 extlinux.sys: extlinux.bin
159 dd if=$< of=$@ bs=512 skip=1
162 $(NASM) -f bin -l mbr.lst -o mbr.bin mbr.asm
164 mbr_bin.c: mbr.bin bin2c.pl
165 $(PERL) bin2c.pl syslinux_mbr < $< > $@
167 copybs.com: copybs.asm
168 $(NASM) -f bin -l copybs.lst -o copybs.com copybs.asm
170 bootsect_bin.c: ldlinux.bss bin2c.pl
171 $(PERL) bin2c.pl syslinux_bootsect < $< > $@
173 ldlinux_bin.c: ldlinux.sys bin2c.pl
174 $(PERL) bin2c.pl syslinux_ldlinux < $< > $@
176 extlinux_bss_bin.c: extlinux.bss bin2c.pl
177 $(PERL) bin2c.pl extlinux_bootsect < $< > $@
179 extlinux_sys_bin.c: extlinux.sys bin2c.pl
180 $(PERL) bin2c.pl extlinux_image < $< > $@
182 libsyslinux.a: bootsect_bin.o ldlinux_bin.o mbr_bin.o syslxmod.o
187 $(LIB_SO): bootsect_bin.o ldlinux_bin.o syslxmod.o
188 $(CC) $(LDFLAGS) -shared -Wl,-soname,$(LIB_SONAME) -o $@ $^
190 gethostip.o: gethostip.c
192 gethostip: gethostip.o
194 mkdiskimage: mkdiskimage.in mbr.bin bin2hex.pl
195 $(PERL) bin2hex.pl < mbr.bin | cat mkdiskimage.in - > $@
199 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
200 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
201 mkdir -m 755 -p $(INSTALLROOT)$(SBINDIR)
202 install -m 755 -c $(INSTALL_SBIN) $(INSTALLROOT)$(SBINDIR)
203 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
204 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
205 -install -m 644 -c $(INSTALL_AUX_OPT) $(INSTALLROOT)$(AUXDIR)
206 $(MAKE) -C com32 install
208 install-lib: installer
210 install-all: install install-lib
213 rm -f *.o *_bin.c stupid.* patch.offset
218 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
223 clean: local-tidy local-clean
224 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
227 for dir in . sample memdisk ; do \
228 ( cd $$dir && rm -f *~ \#* core ) ; \
232 rm -f $(BTARGET) .depend *.so.*
234 spotless: local-clean dist local-spotless
235 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
239 for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done
240 for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
247 $(MAKE) -C memdisk depend
249 # Hook to add private Makefile targets for the maintainer.
250 -include Makefile.private
252 # Include dependencies file