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
20 CFLAGS = -Wall -O2 -fomit-frame-pointer
28 LIBDIR = /usr/lib/syslinux
32 VERSION = $(shell cat version)
35 $(CC) $(INCLUDE) $(CFLAGS) -c $<
38 # The BTARGET refers to objects that are derived from ldlinux.asm; we
39 # like to keep those uniform for debugging reasons; however, distributors
40 # want to recompile the installers (ITARGET).
42 CSRC = syslinux.c syslxmod.c gethostip.c
43 NASMSRC = ldlinux.asm syslinux.asm copybs.asm \
44 pxelinux.asm mbr.asm isolinux.asm isolinux-debug.asm
45 SOURCES = $(CSRC) *.h $(NASMSRC) *.inc
46 BTARGET = kwdhash.gen version.gen ldlinux.bss ldlinux.sys ldlinux.bin \
47 pxelinux.0 mbr.bin isolinux.bin isolinux-debug.bin libsyslinux.a
48 ITARGET = syslinux.com syslinux copybs.com gethostip mkdiskimage
49 DOCS = COPYING NEWS README TODO *.doc sample com32/include
50 OTHER = Makefile bin2c.pl now.pl genhash.pl keywords findpatch.pl \
51 keytab-lilo.pl version version.pl sys2ansi.pl \
52 ppmtolss16 lss16toppm memdisk bin2hex.pl mkdiskimage.in
53 OBSOLETE = pxelinux.bin
55 # Things to install in /usr/bin
56 INSTALL_BIN = syslinux gethostip ppmtolss16 lss16toppm
57 # Things to install in /usr/lib/syslinux
58 INSTALL_LIB = pxelinux.0 isolinux.bin isolinux-debug.bin \
59 syslinux.com copybs.com memdisk/memdisk
61 # The DATE is set on the make command line when building binaries for
62 # official release. Otherwise, substitute a hex string that is pretty much
63 # guaranteed to be unique to be unique from build to build.
65 HEXDATE := $(shell $(PERL) now.pl ldlinux.asm pxelinux.asm isolinux.asm)
71 all: $(BTARGET) $(ITARGET) samples memdisk
72 ls -l $(BTARGET) $(ITARGET) memdisk/memdisk
74 installer: $(ITARGET) samples
75 ls -l $(BTARGET) $(ITARGET)
83 $(MAKE) -C memdisk all
85 version.gen: version version.pl
86 $(PERL) version.pl version
88 kwdhash.gen: keywords genhash.pl
89 $(PERL) genhash.pl < keywords > kwdhash.gen
91 ldlinux.bin: ldlinux.asm kwdhash.gen version.gen
92 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
93 -l ldlinux.lst -o ldlinux.bin ldlinux.asm
95 pxelinux.bin: pxelinux.asm kwdhash.gen version.gen
96 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
97 -l pxelinux.lst -o pxelinux.bin pxelinux.asm
99 isolinux.bin: isolinux.asm kwdhash.gen version.gen
100 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
101 -l isolinux.lst -o isolinux.bin isolinux.asm
103 pxelinux.0: pxelinux.bin
104 cp pxelinux.bin pxelinux.0
106 # Special verbose version of isolinux.bin
107 isolinux-debug.bin: isolinux-debug.asm kwdhash.gen
108 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
109 -l isolinux-debug.lst -o isolinux-debug.bin isolinux-debug.asm
111 ldlinux.bss: ldlinux.bin
112 dd if=ldlinux.bin of=ldlinux.bss bs=512 count=1
114 ldlinux.sys: ldlinux.bin
115 dd if=ldlinux.bin of=ldlinux.sys bs=512 skip=1
117 patch.offset: ldlinux.sys findpatch.pl
118 $(PERL) findpatch.pl > patch.offset
121 $(NASM) -f bin -l mbr.lst -o mbr.bin mbr.asm
123 syslinux.com: syslinux.asm ldlinux.bss ldlinux.sys patch.offset
124 $(NASM) -f bin -DPATCH_OFFSET=`cat patch.offset` \
125 -l syslinux.lst -o syslinux.com syslinux.asm
127 copybs.com: copybs.asm
128 $(NASM) -f bin -l copybs.lst -o copybs.com copybs.asm
130 bootsect_bin.c: ldlinux.bss bin2c.pl
131 $(PERL) bin2c.pl syslinux_bootsect < ldlinux.bss > bootsect_bin.c
133 ldlinux_bin.c: ldlinux.sys bin2c.pl
134 $(PERL) bin2c.pl syslinux_ldlinux < ldlinux.sys > ldlinux_bin.c
136 libsyslinux.a: bootsect_bin.o ldlinux_bin.o syslxmod.o
141 syslinux: syslinux.o libsyslinux.a
142 $(CC) $(LDFLAGS) -o $@ $^
144 syslxmod.o: syslxmod.c patch.offset
145 $(CC) $(INCLUDE) $(CFLAGS) -DPATCH_OFFSET=`cat patch.offset` \
148 gethostip.o: gethostip.c
150 gethostip: gethostip.o
152 mkdiskimage: mkdiskimage.in mbr.bin bin2hex.pl
153 $(PERL) bin2hex.pl < mbr.bin | cat mkdiskimage.in - > $@
157 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR) $(INSTALLROOT)$(LIBDIR)
158 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
159 install -m 644 -c $(INSTALL_LIB) $(INSTALLROOT)$(LIBDIR)
162 rm -f *.o *_bin.c stupid.* patch.offset
163 rm -f syslinux.lst copybs.lst pxelinux.lst isolinux*.lst
167 $(MAKE) -C memdisk tidy
172 clean: local-tidy local-clean
173 $(MAKE) -C sample clean
174 $(MAKE) -C memdisk clean
177 for dir in . sample memdisk ; do \
178 ( cd $$dir && rm -f *~ \#* core ) ; \
182 rm -f $(BTARGET) .depend
184 spotless: local-clean dist local-spotless
185 $(MAKE) -C sample spotless
186 $(MAKE) -C memdisk spotless
190 for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done
191 for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
198 $(MAKE) -C memdisk depend
200 # Hook to add private Makefile targets for the maintainer.
201 -include Makefile.private
203 # Include dependencies file