1 ## -----------------------------------------------------------------------
3 ## Copyright 1998-2006 H. Peter Anvin - All Rights Reserved
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 ## Boston MA 02111-1307, USA; either version 2 of the License, or
9 ## (at your option) any later version; incorporated herein by reference.
11 ## -----------------------------------------------------------------------
14 # Main Makefile for SYSLINUX
20 OSTYPE = $(shell uname -msr)
23 CFLAGS = -W -Wall -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
34 AUXDIR = $(LIBDIR)/syslinux
39 VERSION = $(shell cat version)
42 $(CC) $(INCLUDE) $(CFLAGS) -c $<
45 # The BTARGET refers to objects that are derived from ldlinux.asm; we
46 # like to keep those uniform for debugging reasons; however, distributors
47 # want to recompile the installers (ITARGET).
49 # BOBJECTS and IOBJECTS are the same thing, except used for
50 # installation, so they include objects that may be in subdirectories
51 # with their own Makefiles. Finally, there is a list of those
54 CSRC = syslxmod.c gethostip.c
55 NASMSRC = $(wildcard *.asm)
56 SOURCES = $(CSRC) *.h $(NASMSRC) *.inc
58 # _bin.c files required by both BTARGET and ITARGET installers
59 BINFILES = bootsect_bin.c ldlinux_bin.c mbr_bin.c \
60 extlinux_bss_bin.c extlinux_sys_bin.c
62 # syslinux.exe is BTARGET so as to not require everyone to have the
63 # mingw suite installed
64 BTARGET = kwdhash.gen version.gen version.h \
65 ldlinux.bss ldlinux.sys ldlinux.bin \
66 pxelinux.0 mbr.bin isolinux.bin isolinux-debug.bin \
67 extlinux.bin extlinux.bss extlinux.sys
68 BOBJECTS = $(BTARGET) dos/syslinux.com win32/syslinux.exe memdisk/memdisk
69 BSUBDIRS = memdisk dos win32
70 ITARGET = copybs.com gethostip mkdiskimage
71 IOBJECTS = $(ITARGET) mtools/syslinux unix/syslinux extlinux/extlinux
72 ISUBDIRS = mtools unix extlinux sample com32
73 DOCS = COPYING NEWS README TODO BUGS *.doc sample menu com32
74 OTHER = Makefile bin2c.pl now.pl genhash.pl keywords findpatch.pl \
75 keytab-lilo.pl version version.pl sys2ansi.pl \
76 ppmtolss16 lss16toppm memdisk bin2hex.pl mkdiskimage.in
77 OBSOLETE = pxelinux.bin
79 # Things to install in /usr/bin
80 INSTALL_BIN = mtools/syslinux gethostip ppmtolss16 lss16toppm
81 # Things to install in /sbin
82 INSTALL_SBIN = extlinux/extlinux
83 # Things to install in /usr/lib/syslinux
84 INSTALL_AUX = pxelinux.0 isolinux.bin isolinux-debug.bin \
85 dos/syslinux.com copybs.com memdisk/memdisk mbr.bin
86 INSTALL_AUX_OPT = win32/syslinux.exe
88 # The DATE is set on the make command line when building binaries for
89 # official release. Otherwise, substitute a hex string that is pretty much
90 # guaranteed to be unique to be unique from build to build.
92 HEXDATE := $(shell $(PERL) now.pl ldlinux.asm pxelinux.asm isolinux.asm)
97 MAKE += DATE=$(DATE) HEXDATE=$(HEXDATE)
100 # NOTE: If you don't have the mingw compiler suite installed, you probably
101 # want to remove win32 from this list; otherwise you're going to get an
102 # error every time you try to build.
106 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
108 -ls -l $(BOBJECTS) $(IOBJECTS)
110 all-local: $(BTARGET) $(ITARGET) $(BINFILES)
112 installer: installer-local
113 set -e ; for i in $(ISUBDIRS); do $(MAKE) -C $$i all ; done
114 -ls -l $(BOBJECTS) $(IOBJECTS)
116 installer-local: $(ITARGET) $(BINFILES)
118 version.gen: version version.pl
119 $(PERL) version.pl $< $@ '%define'
121 version.h: version version.pl
122 $(PERL) version.pl $< $@ '#define'
124 kwdhash.gen: keywords genhash.pl
125 $(PERL) genhash.pl < keywords > kwdhash.gen
127 ldlinux.bin: ldlinux.asm kwdhash.gen version.gen
128 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
129 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
130 $(PERL) checkov.pl ldlinux.map $@
132 pxelinux.bin: pxelinux.asm kwdhash.gen version.gen
133 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
134 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
135 $(PERL) checkov.pl $(@:.bin=.map) $@
137 isolinux.bin: isolinux.asm kwdhash.gen version.gen checksumiso.pl
138 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
139 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
140 $(PERL) checkov.pl $(@:.bin=.map) $@
141 $(PERL) checksumiso.pl $@
143 # Special verbose version of isolinux.bin
144 isolinux-debug.bin: isolinux-debug.asm kwdhash.gen version.gen checksumiso.pl
145 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
146 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
147 $(PERL) checkov.pl $(@:.bin=.map) $@
148 $(PERL) checksumiso.pl $@
150 extlinux.bin: extlinux.asm kwdhash.gen version.gen
151 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
152 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
153 $(PERL) checkov.pl $(@:.bin=.map) $@
155 pxelinux.0: pxelinux.bin
156 cp pxelinux.bin pxelinux.0
158 ldlinux.bss: ldlinux.bin
159 dd if=$< of=$@ bs=512 count=1
161 ldlinux.sys: ldlinux.bin
162 dd if=$< of=$@ bs=512 skip=1
164 extlinux.bss: extlinux.bin
165 dd if=$< of=$@ bs=512 count=1
167 extlinux.sys: extlinux.bin
168 dd if=$< of=$@ bs=512 skip=1
171 $(NASM) -f bin -l mbr.lst -o mbr.bin mbr.asm
173 mbr_bin.c: mbr.bin bin2c.pl
174 $(PERL) bin2c.pl syslinux_mbr < $< > $@
176 copybs.com: copybs.asm
177 $(NASM) -f bin -l copybs.lst -o copybs.com copybs.asm
179 bootsect_bin.c: ldlinux.bss bin2c.pl
180 $(PERL) bin2c.pl syslinux_bootsect < $< > $@
182 ldlinux_bin.c: ldlinux.sys bin2c.pl
183 $(PERL) bin2c.pl syslinux_ldlinux < $< > $@
185 extlinux_bss_bin.c: extlinux.bss bin2c.pl
186 $(PERL) bin2c.pl extlinux_bootsect < $< > $@
188 extlinux_sys_bin.c: extlinux.sys bin2c.pl
189 $(PERL) bin2c.pl extlinux_image < $< > $@
191 libsyslinux.a: bootsect_bin.o ldlinux_bin.o mbr_bin.o syslxmod.o
196 $(LIB_SO): bootsect_bin.o ldlinux_bin.o syslxmod.o
197 $(CC) $(LDFLAGS) -shared -Wl,-soname,$(LIB_SONAME) -o $@ $^
199 gethostip: gethostip.o
200 $(CC) $(LDFLAGS) -o $@ $^
202 mkdiskimage: mkdiskimage.in mbr.bin bin2hex.pl
203 $(PERL) bin2hex.pl < mbr.bin | cat mkdiskimage.in - > $@
207 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
208 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
209 mkdir -m 755 -p $(INSTALLROOT)$(SBINDIR)
210 install -m 755 -c $(INSTALL_SBIN) $(INSTALLROOT)$(SBINDIR)
211 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
212 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
213 -install -m 644 -c $(INSTALL_AUX_OPT) $(INSTALLROOT)$(AUXDIR)
214 $(MAKE) -C com32 install
216 install-lib: installer
218 install-all: install install-lib
221 rm -f *.o *_bin.c stupid.* patch.offset
226 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
231 clean: local-tidy local-clean
232 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
235 for dir in . sample memdisk ; do \
236 ( cd $$dir && rm -f *~ \#* core ) ; \
240 rm -f $(BTARGET) .depend *.so.*
242 spotless: local-clean dist local-spotless
243 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
247 for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done
248 for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
255 $(MAKE) -C memdisk depend
257 # Shortcut to build unix/syslinux using klibc
260 $(MAKE) CC=klcc ITARGET= ISUBDIRS='unix extlinux' BSUBDIRS=
262 # Hook to add private Makefile targets for the maintainer.
263 -include Makefile.private
265 # Include dependencies file