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 BSUBDIRS = memdisk win32
88 ISUBDIRS = sample com32
90 all: $(BTARGET) $(ITARGET)
91 for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
92 ls -l $(BTARGET) $(ITARGET) memdisk/memdisk
95 for i in $(ISUBDIRS); do $(MAKE) -C $$i all ; done
96 ls -l $(BTARGET) $(ITARGET)
98 version.gen: version version.pl
99 $(PERL) version.pl version
101 kwdhash.gen: keywords genhash.pl
102 $(PERL) genhash.pl < keywords > kwdhash.gen
104 ldlinux.bin: ldlinux.asm kwdhash.gen version.gen
105 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
106 -l ldlinux.lst -o ldlinux.bin ldlinux.asm
108 pxelinux.bin: pxelinux.asm kwdhash.gen version.gen
109 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
110 -l pxelinux.lst -o pxelinux.bin pxelinux.asm
112 isolinux.bin: isolinux.asm kwdhash.gen version.gen
113 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
114 -l isolinux.lst -o isolinux.bin isolinux.asm
116 pxelinux.0: pxelinux.bin
117 cp pxelinux.bin pxelinux.0
119 # Special verbose version of isolinux.bin
120 isolinux-debug.bin: isolinux-debug.asm kwdhash.gen
121 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
122 -l isolinux-debug.lst -o isolinux-debug.bin isolinux-debug.asm
124 ldlinux.bss: ldlinux.bin
125 dd if=ldlinux.bin of=ldlinux.bss bs=512 count=1
127 ldlinux.sys: ldlinux.bin
128 dd if=ldlinux.bin of=ldlinux.sys bs=512 skip=1
130 patch.offset: ldlinux.sys findpatch.pl
131 $(PERL) findpatch.pl > patch.offset
134 $(NASM) -f bin -l mbr.lst -o mbr.bin mbr.asm
136 syslinux.com: syslinux.asm ldlinux.bss ldlinux.sys patch.offset
137 $(NASM) -f bin -DPATCH_OFFSET=`cat patch.offset` \
138 -l syslinux.lst -o syslinux.com syslinux.asm
140 copybs.com: copybs.asm
141 $(NASM) -f bin -l copybs.lst -o copybs.com copybs.asm
143 bootsect_bin.c: ldlinux.bss bin2c.pl
144 $(PERL) bin2c.pl syslinux_bootsect < ldlinux.bss > bootsect_bin.c
146 ldlinux_bin.c: ldlinux.sys bin2c.pl
147 $(PERL) bin2c.pl syslinux_ldlinux < ldlinux.sys > ldlinux_bin.c
149 libsyslinux.a: bootsect_bin.o ldlinux_bin.o syslxmod.o
154 $(LIB_SO): bootsect_bin.o ldlinux_bin.o syslxmod.o
155 $(CC) $(LDFLAGS) -shared -Wl,-soname,$(LIB_SONAME) -o $@ $^
157 syslinux: syslinux.o libsyslinux.a
158 $(CC) $(LDFLAGS) -o $@ $^
160 syslinux-nomtools: syslinux-nomtools.o libsyslinux.a
161 $(CC) $(LDFLAGS) -o $@ $^
163 syslxmod.o: syslxmod.c patch.offset
164 $(CC) $(INCLUDE) $(CFLAGS) $(PIC) -DPATCH_OFFSET=`cat patch.offset` \
167 syslinux.exe: win32/syslinux-mingw.c libsyslinux.a
170 gethostip.o: gethostip.c
172 gethostip: gethostip.o
174 mkdiskimage: mkdiskimage.in mbr.bin bin2hex.pl
175 $(PERL) bin2hex.pl < mbr.bin | cat mkdiskimage.in - > $@
179 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR) $(INSTALLROOT)$(AUXDIR)
180 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
181 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
183 install-lib: installer
184 mkdir -m 755 -p $(INSTALLROOT)$(LIBDIR) $(INSTALLDIR)$(INCDIR)
185 install -m 644 -c $(INSTALL_LIB) $(INSTALLROOT)$(LIBDIR)
186 install -m 644 -c $(INSTALL_INC) $(INSTALLROOT)$(INCDIR)
187 cd $(INSTALLROOT)$(LIBDIR) && ln -sf $(LIB_SO) libsyslinux.so
188 if [ -z '$(INSTALLROOT)' ]; then ldconfig; fi
190 install-all: install install-all
193 rm -f *.o *_bin.c stupid.* patch.offset
194 rm -f syslinux.lst copybs.lst pxelinux.lst isolinux*.lst
198 for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
203 clean: local-tidy local-clean
204 for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
207 for dir in . sample memdisk ; do \
208 ( cd $$dir && rm -f *~ \#* core ) ; \
212 rm -f $(BTARGET) .depend *.so.*
214 spotless: local-clean dist local-spotless
215 for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
219 for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done
220 for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
227 $(MAKE) -C memdisk depend
229 # Hook to add private Makefile targets for the maintainer.
230 -include Makefile.private
232 # Include dependencies file