1 ## -----------------------------------------------------------------------
3 ## Copyright 1998-2007 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 TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
22 gcc_ok = $(shell tmpf=$(TMPFILE); if gcc $(1) dummy.c -o $$tmpf 2>/dev/null; \
23 then echo '$(1)'; else echo '$(2)'; fi; rm -f $$tmpf)
26 LDHASH := $(call gcc_ok,-Wl$(comma)--hash-style=both,)
28 OSTYPE = $(shell uname -msr)
31 CFLAGS = -W -Wall -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
33 LDFLAGS = -O2 -s $(LDHASH)
42 AUXDIR = $(LIBDIR)/syslinux
47 VERSION = $(shell cat version)
50 $(CC) $(INCLUDE) $(CFLAGS) -c $<
53 # The BTARGET refers to objects that are derived from ldlinux.asm; we
54 # like to keep those uniform for debugging reasons; however, distributors
55 # want to recompile the installers (ITARGET).
57 # BOBJECTS and IOBJECTS are the same thing, except used for
58 # installation, so they include objects that may be in subdirectories
59 # with their own Makefiles. Finally, there is a list of those
62 CSRC = syslxmod.c gethostip.c
63 NASMSRC = $(wildcard *.asm)
64 SOURCES = $(CSRC) *.h $(NASMSRC) *.inc
66 # _bin.c files required by both BTARGET and ITARGET installers
67 BINFILES = bootsect_bin.c ldlinux_bin.c mbr_bin.c \
68 extlinux_bss_bin.c extlinux_sys_bin.c
70 # syslinux.exe is BTARGET so as to not require everyone to have the
71 # mingw suite installed
72 BTARGET = kwdhash.gen version.gen version.h \
73 ldlinux.bss ldlinux.sys ldlinux.bin \
74 pxelinux.0 isolinux.bin isolinux-debug.bin \
75 extlinux.bin extlinux.bss extlinux.sys
76 BOBJECTS = $(BTARGET) mbr/mbr.bin dos/syslinux.com win32/syslinux.exe \
77 memdisk/memdisk memdump/memdump.com
78 # BESUBDIRS and IESUBDIRS are "early", i.e. before the root; BSUBDIRS
79 # and ISUBDIRS are "late", after the root.
81 BSUBDIRS = memdisk memdump dos win32
82 ITARGET = copybs.com gethostip mkdiskimage
83 IOBJECTS = $(ITARGET) mtools/syslinux unix/syslinux extlinux/extlinux
85 ISUBDIRS = mtools unix extlinux sample com32
86 DOCS = COPYING NEWS README TODO BUGS *.doc sample menu com32
87 OTHER = Makefile bin2c.pl now.pl genhash.pl keywords findpatch.pl \
88 keytab-lilo.pl version version.pl sys2ansi.pl \
89 ppmtolss16 lss16toppm memdisk bin2hex.pl mkdiskimage.in \
91 OBSOLETE = pxelinux.bin
93 # Things to install in /usr/bin
94 INSTALL_BIN = mtools/syslinux gethostip ppmtolss16 lss16toppm \
96 # Things to install in /sbin
97 INSTALL_SBIN = extlinux/extlinux
98 # Things to install in /usr/lib/syslinux
99 INSTALL_AUX = pxelinux.0 isolinux.bin isolinux-debug.bin \
100 dos/syslinux.com copybs.com memdisk/memdisk mbr/mbr.bin
101 INSTALL_AUX_OPT = win32/syslinux.exe
103 # The DATE is set on the make command line when building binaries for
104 # official release. Otherwise, substitute a hex string that is pretty much
105 # guaranteed to be unique to be unique from build to build.
107 HEXDATE := $(shell $(PERL) now.pl ldlinux.asm pxelinux.asm isolinux.asm)
112 MAKE += DATE=$(DATE) HEXDATE=$(HEXDATE)
115 # NOTE: If you don't have the mingw compiler suite installed, you probably
116 # want to remove win32 from this list; otherwise you're going to get an
117 # error every time you try to build.
121 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) ; do $(MAKE) -C $$i $@ ; done
123 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
124 -ls -l $(BOBJECTS) $(IOBJECTS)
126 all-local: $(BTARGET) $(ITARGET) $(BINFILES)
128 installer: installer-local
129 set -e ; for i in $(ISUBDIRS); do $(MAKE) -C $$i all ; done
130 -ls -l $(BOBJECTS) $(IOBJECTS)
132 installer-local: $(ITARGET) $(BINFILES)
134 version.gen: version version.pl
135 $(PERL) version.pl $< $@ '%define'
137 version.h: version version.pl
138 $(PERL) version.pl $< $@ '#define'
140 kwdhash.gen: keywords genhash.pl
141 $(PERL) genhash.pl < keywords > kwdhash.gen
143 # Standard rule for {ldlinux,pxelinux,isolinux,isolinux-debug,extlinux}.bin
144 %.bin: %.asm kwdhash.gen version.gen
145 $(NASM) -O99 -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
146 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lsr) -o $@ $<
147 $(PERL) lstadjust.pl $(@:.bin=.lsr) $(@:.bin=.map) $(@:.bin=.lst)
148 $(PERL) checkov.pl $(@:.bin=.map) $@
150 pxelinux.0: pxelinux.bin
151 cp pxelinux.bin pxelinux.0
153 ldlinux.bss: ldlinux.bin
154 dd if=$< of=$@ bs=512 count=1
156 ldlinux.sys: ldlinux.bin
157 dd if=$< of=$@ bs=512 skip=1
159 extlinux.bss: extlinux.bin
160 dd if=$< of=$@ bs=512 count=1
162 extlinux.sys: extlinux.bin
163 dd if=$< of=$@ bs=512 skip=1
165 mbr_bin.c: mbr/mbr.bin bin2c.pl
166 $(PERL) bin2c.pl syslinux_mbr < $< > $@
168 copybs.com: copybs.asm
169 $(NASM) -O99 -f bin -l copybs.lst -o copybs.com copybs.asm
171 bootsect_bin.c: ldlinux.bss bin2c.pl
172 $(PERL) bin2c.pl syslinux_bootsect < $< > $@
174 ldlinux_bin.c: ldlinux.sys bin2c.pl
175 $(PERL) bin2c.pl syslinux_ldlinux < $< > $@
177 extlinux_bss_bin.c: extlinux.bss bin2c.pl
178 $(PERL) bin2c.pl extlinux_bootsect < $< > $@
180 extlinux_sys_bin.c: extlinux.sys bin2c.pl
181 $(PERL) bin2c.pl extlinux_image < $< > $@
183 libsyslinux.a: bootsect_bin.o ldlinux_bin.o mbr_bin.o syslxmod.o
188 $(LIB_SO): bootsect_bin.o ldlinux_bin.o syslxmod.o
189 $(CC) $(LDFLAGS) -shared -Wl,-soname,$(LIB_SONAME) -o $@ $^
191 gethostip: gethostip.o
192 $(CC) $(LDFLAGS) -o $@ $^
194 mkdiskimage: mkdiskimage.in mbr/mbr.bin bin2hex.pl
195 $(PERL) bin2hex.pl < mbr/mbr.bin | cat mkdiskimage.in - > $@
199 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
200 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
201 mkdir -m 755 -p $(INSTALLROOT)$(SBINDIR)
202 install -m 755 -c $(INSTALL_SBIN) $(INSTALLROOT)$(SBINDIR)
203 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
204 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
205 -install -m 644 -c $(INSTALL_AUX_OPT) $(INSTALLROOT)$(AUXDIR)
206 $(MAKE) -C com32 install
208 install-lib: installer
210 install-all: install install-lib
213 rm -f *.o *_bin.c stupid.* patch.offset
214 rm -f *.lsr *.lst *.map
218 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
223 clean: local-tidy local-clean
224 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
227 for dir in . sample memdisk ; do \
228 ( cd $$dir && rm -f *~ \#* core ) ; \
232 rm -f $(BTARGET) .depend *.so.*
234 spotless: local-clean dist local-spotless
235 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
239 for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done
240 for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
247 $(MAKE) -C memdisk depend
249 # Shortcut to build unix/syslinux using klibc
252 $(MAKE) CC=klcc ITARGET= ISUBDIRS='unix extlinux' BSUBDIRS=
254 # Hook to add private Makefile targets for the maintainer.
255 -include Makefile.private
257 # Include dependencies file