1 ## -----------------------------------------------------------------------
4 ## Copyright 1998-2003 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., 675 Mass Ave, Cambridge MA 02139,
9 ## USA; either version 2 of the License, or (at your option) any later
10 ## 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
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 CSRC = syslinux.c syslinux-nomtools.c syslxmod.c gethostip.c
51 NASMSRC = ldlinux.asm syslinux.asm copybs.asm \
52 pxelinux.asm mbr.asm isolinux.asm isolinux-debug.asm
53 SOURCES = $(CSRC) *.h $(NASMSRC) *.inc
54 # syslinux.exe is BTARGET so as to not require everyone to have the
55 # mingw suite installed
56 BTARGET = kwdhash.gen version.gen ldlinux.bss ldlinux.sys ldlinux.bin \
57 pxelinux.0 mbr.bin isolinux.bin isolinux-debug.bin \
58 libsyslinux.a syslinux.exe $(LIB_SO)
59 ITARGET = syslinux.com syslinux syslinux-nomtools copybs.com gethostip \
61 DOCS = COPYING NEWS README TODO BUGS *.doc sample menu com32
62 OTHER = Makefile bin2c.pl now.pl genhash.pl keywords findpatch.pl \
63 keytab-lilo.pl version version.pl sys2ansi.pl \
64 ppmtolss16 lss16toppm memdisk bin2hex.pl mkdiskimage.in
65 OBSOLETE = pxelinux.bin
67 # Things to install in /usr/bin
68 INSTALL_BIN = syslinux gethostip ppmtolss16 lss16toppm
69 # Things to install in /usr/lib/syslinux
70 INSTALL_AUX = pxelinux.0 isolinux.bin isolinux-debug.bin \
71 syslinux.com syslinux.exe copybs.com memdisk/memdisk
72 # Things to install in /usr/lib
73 INSTALL_LIB = $(LIB_SO) libsyslinux.a
74 # Things to install in /usr/include
75 INSTALL_INC = syslinux.h
77 # The DATE is set on the make command line when building binaries for
78 # official release. Otherwise, substitute a hex string that is pretty much
79 # guaranteed to be unique to be unique from build to build.
81 HEXDATE := $(shell $(PERL) now.pl ldlinux.asm pxelinux.asm isolinux.asm)
87 all: $(BTARGET) $(ITARGET) samples memdisk
88 ls -l $(BTARGET) $(ITARGET) memdisk/memdisk
90 installer: $(ITARGET) samples
91 ls -l $(BTARGET) $(ITARGET)
99 $(MAKE) -C memdisk all
101 version.gen: version version.pl
102 $(PERL) version.pl version
104 kwdhash.gen: keywords genhash.pl
105 $(PERL) genhash.pl < keywords > kwdhash.gen
107 ldlinux.bin: ldlinux.asm kwdhash.gen version.gen
108 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
109 -l ldlinux.lst -o ldlinux.bin ldlinux.asm
111 pxelinux.bin: pxelinux.asm kwdhash.gen version.gen
112 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
113 -l pxelinux.lst -o pxelinux.bin pxelinux.asm
115 isolinux.bin: isolinux.asm kwdhash.gen version.gen
116 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
117 -l isolinux.lst -o isolinux.bin isolinux.asm
119 pxelinux.0: pxelinux.bin
120 cp pxelinux.bin pxelinux.0
122 # Special verbose version of isolinux.bin
123 isolinux-debug.bin: isolinux-debug.asm kwdhash.gen
124 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
125 -l isolinux-debug.lst -o isolinux-debug.bin isolinux-debug.asm
127 ldlinux.bss: ldlinux.bin
128 dd if=ldlinux.bin of=ldlinux.bss bs=512 count=1
130 ldlinux.sys: ldlinux.bin
131 dd if=ldlinux.bin of=ldlinux.sys bs=512 skip=1
133 patch.offset: ldlinux.sys findpatch.pl
134 $(PERL) findpatch.pl > patch.offset
137 $(NASM) -f bin -l mbr.lst -o mbr.bin mbr.asm
139 syslinux.com: syslinux.asm ldlinux.bss ldlinux.sys patch.offset
140 $(NASM) -f bin -DPATCH_OFFSET=`cat patch.offset` \
141 -l syslinux.lst -o syslinux.com syslinux.asm
143 copybs.com: copybs.asm
144 $(NASM) -f bin -l copybs.lst -o copybs.com copybs.asm
146 bootsect_bin.c: ldlinux.bss bin2c.pl
147 $(PERL) bin2c.pl syslinux_bootsect < ldlinux.bss > bootsect_bin.c
149 ldlinux_bin.c: ldlinux.sys bin2c.pl
150 $(PERL) bin2c.pl syslinux_ldlinux < ldlinux.sys > ldlinux_bin.c
152 libsyslinux.a: bootsect_bin.o ldlinux_bin.o syslxmod.o
157 $(LIB_SO): bootsect_bin.o ldlinux_bin.o syslxmod.o
158 $(CC) $(LDFLAGS) -shared -Wl,-soname,$(LIB_SONAME) -o $@ $^
160 syslinux: syslinux.o libsyslinux.a
161 $(CC) $(LDFLAGS) -o $@ $^
163 syslinux-nomtools: syslinux-nomtools.o libsyslinux.a
164 $(CC) $(LDFLAGS) -o $@ $^
166 syslxmod.o: syslxmod.c patch.offset
167 $(CC) $(INCLUDE) $(CFLAGS) $(PIC) -DPATCH_OFFSET=`cat patch.offset` \
170 syslinux.exe: win32/syslinux-mingw.c libsyslinux.a
173 gethostip.o: gethostip.c
175 gethostip: gethostip.o
177 mkdiskimage: mkdiskimage.in mbr.bin bin2hex.pl
178 $(PERL) bin2hex.pl < mbr.bin | cat mkdiskimage.in - > $@
182 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR) $(INSTALLROOT)$(AUXDIR)
183 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
184 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
186 install-lib: installer
187 mkdir -m 755 -p $(INSTALLROOT)$(LIBDIR) $(INSTALLDIR)$(INCDIR)
188 install -m 644 -c $(INSTALL_LIB) $(INSTALLROOT)$(LIBDIR)
189 install -m 644 -c $(INSTALL_INC) $(INSTALLROOT)$(INCDIR)
190 cd $(INSTALLROOT)$(LIBDIR) && ln -sf $(LIB_SO) libsyslinux.so
191 if [ -z '$(INSTALLROOT)' ]; then ldconfig; fi
193 install-all: install install-all
196 rm -f *.o *_bin.c stupid.* patch.offset
197 rm -f syslinux.lst copybs.lst pxelinux.lst isolinux*.lst
201 $(MAKE) -C memdisk tidy
202 $(MAKE) -C win32 tidy
203 $(MAKE) -C sample tidy
208 clean: local-tidy local-clean
209 $(MAKE) -C sample clean
210 $(MAKE) -C memdisk clean
211 $(MAKE) -C win32 clean
214 for dir in . sample memdisk ; do \
215 ( cd $$dir && rm -f *~ \#* core ) ; \
219 rm -f $(BTARGET) .depend *.so.*
221 spotless: local-clean dist local-spotless
222 $(MAKE) -C sample spotless
223 $(MAKE) -C memdisk spotless
224 $(MAKE) -C win32 spotless
228 for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done
229 for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
236 $(MAKE) -C memdisk depend
238 # Hook to add private Makefile targets for the maintainer.
239 -include Makefile.private
241 # Include dependencies file