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
31 AUXDIR = $(LIBDIR)/syslinux
36 VERSION = $(shell cat version)
39 $(CC) $(INCLUDE) $(CFLAGS) -c $<
42 LIB_SONAME = libsyslinux.so.2.2
43 LIB_SO = libsyslinux.so.$(VERSION)
46 # The BTARGET refers to objects that are derived from ldlinux.asm; we
47 # like to keep those uniform for debugging reasons; however, distributors
48 # want to recompile the installers (ITARGET).
50 # BOBJECTS and IOBJECTS are the same thing, except used for
51 # installation, so they include objects that may be in subdirectories
52 # with their own Makefiles. Finally, there is a list of those
55 CSRC = syslxmod.c gethostip.c
56 NASMSRC = ldlinux.asm copybs.asm pxelinux.asm mbr.asm isolinux.asm
57 SOURCES = $(CSRC) *.h $(NASMSRC) *.inc
58 # syslinux.exe is BTARGET so as to not require everyone to have the
59 # mingw suite installed
60 BTARGET = kwdhash.gen version.gen ldlinux.bss ldlinux.sys ldlinux.bin \
61 pxelinux.0 mbr.bin isolinux.bin isolinux-debug.bin \
62 extlinux.bin extlinux.bss extlinux.sys \
63 bootsect_bin.c ldlinux_bin.c extlinux_bss_bin.c extlinux_sys_bin.c
64 # libsyslinux.a $(LIB_SO)
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
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 /usr/lib/syslinux
79 INSTALL_AUX = pxelinux.0 isolinux.bin isolinux-debug.bin \
80 dos/syslinux.com win32/syslinux.exe \
81 copybs.com memdisk/memdisk
82 # Things to install in /usr/lib
83 INSTALL_LIB = $(LIB_SO) libsyslinux.a
84 # Things to install in /usr/include
85 INSTALL_INC = syslinux.h
87 # The DATE is set on the make command line when building binaries for
88 # official release. Otherwise, substitute a hex string that is pretty much
89 # guaranteed to be unique to be unique from build to build.
91 HEXDATE := $(shell $(PERL) now.pl ldlinux.asm pxelinux.asm isolinux.asm)
96 MAKE += DATE=$(DATE) HEXDATE=$(HEXDATE)
99 # NOTE: If you don't have the mingw compiler suite installed, you probably
100 # want to remove win32 from this list; otherwise you're going to get an
101 # error every time you try to build.
104 all: $(BTARGET) $(ITARGET)
105 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
107 -ls -l $(BOBJECTS) $(IOBJECTS)
109 all-local: $(BTARGET) $(ITARGET)
111 installer: installer-local
113 installer: $(ITARGET)
114 set -e ; for i in $(ISUBDIRS); do $(MAKE) -C $$i all ; done
115 -ls -l $(BOBJECTS) $(IOBJECTS)
117 version.gen: version version.pl
118 $(PERL) version.pl version
120 kwdhash.gen: keywords genhash.pl
121 $(PERL) genhash.pl < keywords > kwdhash.gen
123 ldlinux.bin: ldlinux.asm kwdhash.gen version.gen
124 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
125 -l ldlinux.lst -o ldlinux.bin ldlinux.asm
127 pxelinux.bin: pxelinux.asm kwdhash.gen version.gen
128 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
129 -l pxelinux.lst -o pxelinux.bin pxelinux.asm
131 isolinux.bin: isolinux.asm kwdhash.gen version.gen checksumiso.pl
132 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
133 -l isolinux.lst -o isolinux.bin isolinux.asm
134 $(PERL) checksumiso.pl isolinux.bin
136 extlinux.bin: extlinux.asm kwdhash.gen version.gen
137 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
138 -l extlinux.lst -o extlinux.bin extlinux.asm
140 pxelinux.0: pxelinux.bin
141 cp pxelinux.bin pxelinux.0
143 # Special verbose version of isolinux.bin
144 isolinux-debug.bin: isolinux.asm kwdhash.gen version.gen checksumiso.pl
145 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
147 -l isolinux-debug.lst -o isolinux-debug.bin isolinux.asm
148 $(PERL) checksumiso.pl $@
150 ldlinux.bss: ldlinux.bin
151 dd if=$< of=$@ bs=512 count=1
153 ldlinux.sys: ldlinux.bin
154 dd if=$< of=$@ bs=512 skip=1
156 extlinux.bss: extlinux.bin
157 dd if=$< of=$@ bs=512 count=1
159 extlinux.sys: extlinux.bin
160 dd if=$< of=$@ bs=512 skip=1
163 $(NASM) -f bin -l mbr.lst -o mbr.bin mbr.asm
165 copybs.com: copybs.asm
166 $(NASM) -f bin -l copybs.lst -o copybs.com copybs.asm
168 bootsect_bin.c: ldlinux.bss bin2c.pl
169 $(PERL) bin2c.pl syslinux_bootsect < $< > $@
171 ldlinux_bin.c: ldlinux.sys bin2c.pl
172 $(PERL) bin2c.pl syslinux_ldlinux < $< > $@
174 extlinux_bss_bin.c: extlinux.bss bin2c.pl
175 $(PERL) bin2c.pl extlinux_bootsect < $< > $@
177 extlinux_sys_bin.c: extlinux.sys bin2c.pl
178 $(PERL) bin2c.pl extlinux_image < $< > $@
180 libsyslinux.a: bootsect_bin.o ldlinux_bin.o syslxmod.o
185 $(LIB_SO): bootsect_bin.o ldlinux_bin.o syslxmod.o
186 $(CC) $(LDFLAGS) -shared -Wl,-soname,$(LIB_SONAME) -o $@ $^
188 gethostip.o: gethostip.c
190 gethostip: gethostip.o
192 mkdiskimage: mkdiskimage.in mbr.bin bin2hex.pl
193 $(PERL) bin2hex.pl < mbr.bin | cat mkdiskimage.in - > $@
197 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR) $(INSTALLROOT)$(AUXDIR)
198 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
199 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
200 $(MAKE) -C com32 install
202 install-lib: installer
203 mkdir -m 755 -p $(INSTALLROOT)$(LIBDIR) $(INSTALLDIR)$(INCDIR)
204 install -m 644 -c $(INSTALL_LIB) $(INSTALLROOT)$(LIBDIR)
205 install -m 644 -c $(INSTALL_INC) $(INSTALLROOT)$(INCDIR)
206 cd $(INSTALLROOT)$(LIBDIR) && ln -sf $(LIB_SO) libsyslinux.so
207 if [ -z '$(INSTALLROOT)' ]; then ldconfig; fi
209 install-all: install install-lib
212 rm -f *.o *_bin.c stupid.* patch.offset
217 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
222 clean: local-tidy local-clean
223 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
226 for dir in . sample memdisk ; do \
227 ( cd $$dir && rm -f *~ \#* core ) ; \
231 rm -f $(BTARGET) .depend *.so.*
233 spotless: local-clean dist local-spotless
234 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
238 for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done
239 for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
246 $(MAKE) -C memdisk depend
248 # Hook to add private Makefile targets for the maintainer.
249 -include Makefile.private
251 # Include dependencies file