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 CSRC = syslxmod.c gethostip.c
51 NASMSRC = ldlinux.asm syslinux.asm copybs.asm \
52 pxelinux.asm mbr.asm isolinux.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)
86 MAKE += DATE=$(DATE) HEXDATE=$(HEXDATE)
89 # NOTE: If you don't have the mingw compiler suite installed, you probably
90 # want to remove win32 from this list; otherwise you're going to get an
91 # error every time you try to build.
94 ISUBDIRS = mtools unix win32 sample com32
96 all: $(BTARGET) $(ITARGET)
97 for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
98 -ls -l $(BTARGET) $(ITARGET) memdisk/memdisk
100 installer: $(ITARGET)
101 for i in $(ISUBDIRS); do $(MAKE) -C $$i all ; done
102 -ls -l $(BTARGET) $(ITARGET)
104 version.gen: version version.pl
105 $(PERL) version.pl version
107 kwdhash.gen: keywords genhash.pl
108 $(PERL) genhash.pl < keywords > kwdhash.gen
110 ldlinux.bin: ldlinux.asm kwdhash.gen version.gen
111 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
112 -l ldlinux.lst -o ldlinux.bin ldlinux.asm
114 pxelinux.bin: pxelinux.asm kwdhash.gen version.gen
115 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
116 -l pxelinux.lst -o pxelinux.bin pxelinux.asm
118 isolinux.bin: isolinux.asm kwdhash.gen version.gen checksumiso.pl
119 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
120 -l isolinux.lst -o isolinux.bin isolinux.asm
121 $(PERL) checksumiso.pl isolinux.bin
123 pxelinux.0: pxelinux.bin
124 cp pxelinux.bin pxelinux.0
126 # Special verbose version of isolinux.bin
127 isolinux-debug.bin: isolinux.asm kwdhash.gen version.gen checksumiso.pl
128 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
130 -l isolinux-debug.lst -o isolinux-debug.bin isolinux.asm
131 $(PERL) checksumiso.pl $@
133 ldlinux.bss: ldlinux.bin
134 dd if=ldlinux.bin of=ldlinux.bss bs=512 count=1
136 ldlinux.sys: ldlinux.bin
137 dd if=ldlinux.bin of=ldlinux.sys bs=512 skip=1
140 $(NASM) -f bin -l mbr.lst -o mbr.bin mbr.asm
142 syslinux.com: syslinux.asm ldlinux.bss ldlinux.sys
143 $(NASM) -f bin -l syslinux.lst -o syslinux.com syslinux.asm
145 copybs.com: copybs.asm
146 $(NASM) -f bin -l copybs.lst -o copybs.com copybs.asm
148 bootsect_bin.c: ldlinux.bss bin2c.pl
149 $(PERL) bin2c.pl syslinux_bootsect < ldlinux.bss > bootsect_bin.c
151 ldlinux_bin.c: ldlinux.sys bin2c.pl
152 $(PERL) bin2c.pl syslinux_ldlinux < ldlinux.sys > ldlinux_bin.c
154 libsyslinux.a: bootsect_bin.o ldlinux_bin.o syslxmod.o
159 $(LIB_SO): bootsect_bin.o ldlinux_bin.o syslxmod.o
160 $(CC) $(LDFLAGS) -shared -Wl,-soname,$(LIB_SONAME) -o $@ $^
162 syslinux: syslinux.o libsyslinux.a
163 $(CC) $(LDFLAGS) -o $@ $^
165 syslinux-nomtools: syslinux-nomtools.o libsyslinux.a
166 $(CC) $(LDFLAGS) -o $@ $^
168 syslxmod.o: syslxmod.c patch.offset
169 $(CC) $(INCLUDE) $(CFLAGS) $(PIC) -DPATCH_OFFSET=`cat patch.offset` \
172 syslinux.exe: win32/syslinux-mingw.c libsyslinux.a
175 gethostip.o: gethostip.c
177 gethostip: gethostip.o
179 mkdiskimage: mkdiskimage.in mbr.bin bin2hex.pl
180 $(PERL) bin2hex.pl < mbr.bin | cat mkdiskimage.in - > $@
184 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR) $(INSTALLROOT)$(AUXDIR)
185 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
186 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
187 $(MAKE) -C com32 install
189 install-lib: installer
190 mkdir -m 755 -p $(INSTALLROOT)$(LIBDIR) $(INSTALLDIR)$(INCDIR)
191 install -m 644 -c $(INSTALL_LIB) $(INSTALLROOT)$(LIBDIR)
192 install -m 644 -c $(INSTALL_INC) $(INSTALLROOT)$(INCDIR)
193 cd $(INSTALLROOT)$(LIBDIR) && ln -sf $(LIB_SO) libsyslinux.so
194 if [ -z '$(INSTALLROOT)' ]; then ldconfig; fi
196 install-all: install install-lib
199 rm -f *.o *_bin.c stupid.* patch.offset
204 for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
209 clean: local-tidy local-clean
210 for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
213 for dir in . sample memdisk ; do \
214 ( cd $$dir && rm -f *~ \#* core ) ; \
218 rm -f $(BTARGET) .depend *.so.*
220 spotless: local-clean dist local-spotless
221 for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
225 for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done
226 for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
233 $(MAKE) -C memdisk depend
235 # Hook to add private Makefile targets for the maintainer.
236 -include Makefile.private
238 # Include dependencies file