Adding upstream version 3.30~pre4.
[syslinux-debian/hramrach.git] / Makefile
blobdffe44c18f9cf4eb68118ae450eff73e144aa638
1 ## -----------------------------------------------------------------------
2 ##
3 ## Copyright 1998-2005 H. Peter Anvin - All Rights Reserved
4 ##
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
17 OSTYPE = $(shell uname -msr)
18 CC = gcc
19 INCLUDE =
20 CFLAGS = -W -Wall -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
21 PIC = -fPIC
22 LDFLAGS = -O2 -s
23 AR = ar
24 RANLIB = ranlib
26 NASM = nasm -O99
27 NINCLUDE =
28 BINDIR = /usr/bin
29 SBINDIR = /sbin
30 LIBDIR = /usr/lib
31 AUXDIR = $(LIBDIR)/syslinux
32 INCDIR = /usr/include
34 PERL = perl
36 VERSION = $(shell cat version)
38 .c.o:
39 $(CC) $(INCLUDE) $(CFLAGS) -c $<
42 # The BTARGET refers to objects that are derived from ldlinux.asm; we
43 # like to keep those uniform for debugging reasons; however, distributors
44 # want to recompile the installers (ITARGET).
46 # BOBJECTS and IOBJECTS are the same thing, except used for
47 # installation, so they include objects that may be in subdirectories
48 # with their own Makefiles. Finally, there is a list of those
49 # directories.
51 CSRC = syslxmod.c gethostip.c
52 NASMSRC = $(wildcard *.asm)
53 SOURCES = $(CSRC) *.h $(NASMSRC) *.inc
55 # _bin.c files required by both BTARGET and ITARGET installers
56 BINFILES = bootsect_bin.c ldlinux_bin.c mbr_bin.c \
57 extlinux_bss_bin.c extlinux_sys_bin.c
59 # syslinux.exe is BTARGET so as to not require everyone to have the
60 # mingw suite installed
61 BTARGET = kwdhash.gen version.gen version.h \
62 ldlinux.bss ldlinux.sys ldlinux.bin \
63 pxelinux.0 mbr.bin isolinux.bin isolinux-debug.bin \
64 extlinux.bin extlinux.bss extlinux.sys
65 BOBJECTS = $(BTARGET) dos/syslinux.com win32/syslinux.exe memdisk/memdisk
66 BSUBDIRS = memdisk dos win32
67 ITARGET = copybs.com gethostip mkdiskimage
68 IOBJECTS = $(ITARGET) mtools/syslinux unix/syslinux extlinux/extlinux
69 ISUBDIRS = mtools unix extlinux sample com32
70 DOCS = COPYING NEWS README TODO BUGS *.doc sample menu com32
71 OTHER = Makefile bin2c.pl now.pl genhash.pl keywords findpatch.pl \
72 keytab-lilo.pl version version.pl sys2ansi.pl \
73 ppmtolss16 lss16toppm memdisk bin2hex.pl mkdiskimage.in
74 OBSOLETE = pxelinux.bin
76 # Things to install in /usr/bin
77 INSTALL_BIN = mtools/syslinux gethostip ppmtolss16 lss16toppm
78 # Things to install in /sbin
79 INSTALL_SBIN = extlinux/extlinux
80 # Things to install in /usr/lib/syslinux
81 INSTALL_AUX = pxelinux.0 isolinux.bin isolinux-debug.bin \
82 dos/syslinux.com copybs.com memdisk/memdisk mbr.bin
83 INSTALL_AUX_OPT = win32/syslinux.exe
85 # The DATE is set on the make command line when building binaries for
86 # official release. Otherwise, substitute a hex string that is pretty much
87 # guaranteed to be unique to be unique from build to build.
88 ifndef HEXDATE
89 HEXDATE := $(shell $(PERL) now.pl ldlinux.asm pxelinux.asm isolinux.asm)
90 endif
91 ifndef DATE
92 DATE := $(HEXDATE)
93 endif
94 MAKE += DATE=$(DATE) HEXDATE=$(HEXDATE)
97 # NOTE: If you don't have the mingw compiler suite installed, you probably
98 # want to remove win32 from this list; otherwise you're going to get an
99 # error every time you try to build.
102 all: all-local
103 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
104 $(MAKE) all-local
105 -ls -l $(BOBJECTS) $(IOBJECTS)
107 all-local: $(BTARGET) $(ITARGET) $(BINFILES)
109 installer: installer-local
110 set -e ; for i in $(ISUBDIRS); do $(MAKE) -C $$i all ; done
111 -ls -l $(BOBJECTS) $(IOBJECTS)
113 installer-local: $(ITARGET) $(BINFILES)
115 version.gen: version version.pl
116 $(PERL) version.pl $< $@ '%define'
118 version.h: version version.pl
119 $(PERL) version.pl $< $@ '#define'
121 kwdhash.gen: keywords genhash.pl
122 $(PERL) genhash.pl < keywords > kwdhash.gen
124 ldlinux.bin: ldlinux.asm kwdhash.gen version.gen
125 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
126 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
127 $(PERL) checkov.pl ldlinux.map $@
129 pxelinux.bin: pxelinux.asm kwdhash.gen version.gen
130 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
131 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
132 $(PERL) checkov.pl $(@:.bin=.map) $@
134 isolinux.bin: isolinux.asm kwdhash.gen version.gen checksumiso.pl
135 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
136 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
137 $(PERL) checkov.pl $(@:.bin=.map) $@
138 $(PERL) checksumiso.pl $@
140 # Special verbose version of isolinux.bin
141 isolinux-debug.bin: isolinux-debug.asm kwdhash.gen version.gen checksumiso.pl
142 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
143 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
144 $(PERL) checkov.pl $(@:.bin=.map) $@
145 $(PERL) checksumiso.pl $@
147 extlinux.bin: extlinux.asm kwdhash.gen version.gen
148 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
149 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
150 $(PERL) checkov.pl $(@:.bin=.map) $@
152 pxelinux.0: pxelinux.bin
153 cp pxelinux.bin pxelinux.0
155 ldlinux.bss: ldlinux.bin
156 dd if=$< of=$@ bs=512 count=1
158 ldlinux.sys: ldlinux.bin
159 dd if=$< of=$@ bs=512 skip=1
161 extlinux.bss: extlinux.bin
162 dd if=$< of=$@ bs=512 count=1
164 extlinux.sys: extlinux.bin
165 dd if=$< of=$@ bs=512 skip=1
167 mbr.bin: mbr.asm
168 $(NASM) -f bin -l mbr.lst -o mbr.bin mbr.asm
170 mbr_bin.c: mbr.bin bin2c.pl
171 $(PERL) bin2c.pl syslinux_mbr < $< > $@
173 copybs.com: copybs.asm
174 $(NASM) -f bin -l copybs.lst -o copybs.com copybs.asm
176 bootsect_bin.c: ldlinux.bss bin2c.pl
177 $(PERL) bin2c.pl syslinux_bootsect < $< > $@
179 ldlinux_bin.c: ldlinux.sys bin2c.pl
180 $(PERL) bin2c.pl syslinux_ldlinux < $< > $@
182 extlinux_bss_bin.c: extlinux.bss bin2c.pl
183 $(PERL) bin2c.pl extlinux_bootsect < $< > $@
185 extlinux_sys_bin.c: extlinux.sys bin2c.pl
186 $(PERL) bin2c.pl extlinux_image < $< > $@
188 libsyslinux.a: bootsect_bin.o ldlinux_bin.o mbr_bin.o syslxmod.o
189 rm -f $@
190 $(AR) cq $@ $^
191 $(RANLIB) $@
193 $(LIB_SO): bootsect_bin.o ldlinux_bin.o syslxmod.o
194 $(CC) $(LDFLAGS) -shared -Wl,-soname,$(LIB_SONAME) -o $@ $^
196 gethostip.o: gethostip.c
198 gethostip: gethostip.o
200 mkdiskimage: mkdiskimage.in mbr.bin bin2hex.pl
201 $(PERL) bin2hex.pl < mbr.bin | cat mkdiskimage.in - > $@
202 chmod a+x $@
204 install: installer
205 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
206 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
207 mkdir -m 755 -p $(INSTALLROOT)$(SBINDIR)
208 install -m 755 -c $(INSTALL_SBIN) $(INSTALLROOT)$(SBINDIR)
209 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
210 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
211 -install -m 644 -c $(INSTALL_AUX_OPT) $(INSTALLROOT)$(AUXDIR)
212 $(MAKE) -C com32 install
214 install-lib: installer
216 install-all: install install-lib
218 local-tidy:
219 rm -f *.o *_bin.c stupid.* patch.offset
220 rm -f *.lst *.map
221 rm -f $(OBSOLETE)
223 tidy: local-tidy
224 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
226 local-clean:
227 rm -f $(ITARGET)
229 clean: local-tidy local-clean
230 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
232 dist: tidy
233 for dir in . sample memdisk ; do \
234 ( cd $$dir && rm -f *~ \#* core ) ; \
235 done
237 local-spotless:
238 rm -f $(BTARGET) .depend *.so.*
240 spotless: local-clean dist local-spotless
241 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
243 .depend:
244 rm -f .depend
245 for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done
246 for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
248 local-depend:
249 rm -f .depend
250 $(MAKE) .depend
252 depend: local-depend
253 $(MAKE) -C memdisk depend
255 # Shortcut to build unix/syslinux using klibc
256 klibc:
257 $(MAKE) clean
258 $(MAKE) CC=klcc ITARGET= ISUBDIRS='unix extlinux' BSUBDIRS=
260 # Hook to add private Makefile targets for the maintainer.
261 -include Makefile.private
263 # Include dependencies file
264 -include .depend