Adding debian version 3.40~pre9-1.
[syslinux-debian/hramrach.git] / Makefile
blob5a27526c158693f0130162838748eabbf09e9f1d
1 ## -----------------------------------------------------------------------
2 ##
3 ## Copyright 1998-2007 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 # No builtin rules
18 MAKEFLAGS = -r
20 gcc_ok = $(shell if gcc $(1) dummy.c -o /dev/null 2>/dev/null; \
21 then echo '$(1)'; else echo '$(2)'; fi)
23 comma := ,
24 LDHASH := $(call gcc_ok,-Wl$(comma)--hash-style=both,)
26 OSTYPE = $(shell uname -msr)
27 CC = gcc
28 INCLUDE =
29 CFLAGS = -W -Wall -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
30 PIC = -fPIC
31 LDFLAGS = -O2 -s $(LDHASH)
32 AR = ar
33 RANLIB = ranlib
35 NASM = nasm -O99
36 NINCLUDE =
37 BINDIR = /usr/bin
38 SBINDIR = /sbin
39 LIBDIR = /usr/lib
40 AUXDIR = $(LIBDIR)/syslinux
41 INCDIR = /usr/include
43 PERL = perl
45 VERSION = $(shell cat version)
47 %.o: %.c
48 $(CC) $(INCLUDE) $(CFLAGS) -c $<
51 # The BTARGET refers to objects that are derived from ldlinux.asm; we
52 # like to keep those uniform for debugging reasons; however, distributors
53 # want to recompile the installers (ITARGET).
55 # BOBJECTS and IOBJECTS are the same thing, except used for
56 # installation, so they include objects that may be in subdirectories
57 # with their own Makefiles. Finally, there is a list of those
58 # directories.
60 CSRC = syslxmod.c gethostip.c
61 NASMSRC = $(wildcard *.asm)
62 SOURCES = $(CSRC) *.h $(NASMSRC) *.inc
64 # _bin.c files required by both BTARGET and ITARGET installers
65 BINFILES = bootsect_bin.c ldlinux_bin.c mbr_bin.c \
66 extlinux_bss_bin.c extlinux_sys_bin.c
68 # syslinux.exe is BTARGET so as to not require everyone to have the
69 # mingw suite installed
70 BTARGET = kwdhash.gen version.gen version.h \
71 ldlinux.bss ldlinux.sys ldlinux.bin \
72 pxelinux.0 isolinux.bin isolinux-debug.bin \
73 extlinux.bin extlinux.bss extlinux.sys
74 BOBJECTS = $(BTARGET) mbr/mbr.bin dos/syslinux.com win32/syslinux.exe memdisk/memdisk
75 # BESUBDIRS and IESUBDIRS are "early", i.e. before the root; BSUBDIRS
76 # and ISUBDIRS are "late", after the root.
77 BESUBDIRS = mbr
78 BSUBDIRS = memdisk dos win32
79 ITARGET = copybs.com gethostip mkdiskimage
80 IOBJECTS = $(ITARGET) mtools/syslinux unix/syslinux extlinux/extlinux
81 IESUBDIRS =
82 ISUBDIRS = mtools unix extlinux sample com32
83 DOCS = COPYING NEWS README TODO BUGS *.doc sample menu com32
84 OTHER = Makefile bin2c.pl now.pl genhash.pl keywords findpatch.pl \
85 keytab-lilo.pl version version.pl sys2ansi.pl \
86 ppmtolss16 lss16toppm memdisk bin2hex.pl mkdiskimage.in
87 OBSOLETE = pxelinux.bin
89 # Things to install in /usr/bin
90 INSTALL_BIN = mtools/syslinux gethostip ppmtolss16 lss16toppm
91 # Things to install in /sbin
92 INSTALL_SBIN = extlinux/extlinux
93 # Things to install in /usr/lib/syslinux
94 INSTALL_AUX = pxelinux.0 isolinux.bin isolinux-debug.bin \
95 dos/syslinux.com copybs.com memdisk/memdisk mbr/mbr.bin
96 INSTALL_AUX_OPT = win32/syslinux.exe
98 # The DATE is set on the make command line when building binaries for
99 # official release. Otherwise, substitute a hex string that is pretty much
100 # guaranteed to be unique to be unique from build to build.
101 ifndef HEXDATE
102 HEXDATE := $(shell $(PERL) now.pl ldlinux.asm pxelinux.asm isolinux.asm)
103 endif
104 ifndef DATE
105 DATE := $(HEXDATE)
106 endif
107 MAKE += DATE=$(DATE) HEXDATE=$(HEXDATE)
110 # NOTE: If you don't have the mingw compiler suite installed, you probably
111 # want to remove win32 from this list; otherwise you're going to get an
112 # error every time you try to build.
115 all:
116 set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) ; do $(MAKE) -C $$i $@ ; done
117 $(MAKE) all-local
118 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
119 -ls -l $(BOBJECTS) $(IOBJECTS)
121 all-local: $(BTARGET) $(ITARGET) $(BINFILES)
123 installer: installer-local
124 set -e ; for i in $(ISUBDIRS); do $(MAKE) -C $$i all ; done
125 -ls -l $(BOBJECTS) $(IOBJECTS)
127 installer-local: $(ITARGET) $(BINFILES)
129 version.gen: version version.pl
130 $(PERL) version.pl $< $@ '%define'
132 version.h: version version.pl
133 $(PERL) version.pl $< $@ '#define'
135 kwdhash.gen: keywords genhash.pl
136 $(PERL) genhash.pl < keywords > kwdhash.gen
138 ldlinux.bin: ldlinux.asm kwdhash.gen version.gen
139 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
140 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
141 $(PERL) checkov.pl ldlinux.map $@
143 pxelinux.bin: pxelinux.asm kwdhash.gen version.gen
144 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
145 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
146 $(PERL) checkov.pl $(@:.bin=.map) $@
148 isolinux.bin: isolinux.asm kwdhash.gen version.gen checksumiso.pl
149 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
150 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
151 $(PERL) checkov.pl $(@:.bin=.map) $@
152 $(PERL) checksumiso.pl $@
154 # Special verbose version of isolinux.bin
155 isolinux-debug.bin: isolinux-debug.asm kwdhash.gen version.gen checksumiso.pl
156 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
157 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
158 $(PERL) checkov.pl $(@:.bin=.map) $@
159 $(PERL) checksumiso.pl $@
161 extlinux.bin: extlinux.asm kwdhash.gen version.gen
162 $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
163 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lst) -o $@ $<
164 $(PERL) checkov.pl $(@:.bin=.map) $@
166 pxelinux.0: pxelinux.bin
167 cp pxelinux.bin pxelinux.0
169 ldlinux.bss: ldlinux.bin
170 dd if=$< of=$@ bs=512 count=1
172 ldlinux.sys: ldlinux.bin
173 dd if=$< of=$@ bs=512 skip=1
175 extlinux.bss: extlinux.bin
176 dd if=$< of=$@ bs=512 count=1
178 extlinux.sys: extlinux.bin
179 dd if=$< of=$@ bs=512 skip=1
181 mbr_bin.c: mbr/mbr.bin bin2c.pl
182 $(PERL) bin2c.pl syslinux_mbr < $< > $@
184 copybs.com: copybs.asm
185 $(NASM) -f bin -l copybs.lst -o copybs.com copybs.asm
187 bootsect_bin.c: ldlinux.bss bin2c.pl
188 $(PERL) bin2c.pl syslinux_bootsect < $< > $@
190 ldlinux_bin.c: ldlinux.sys bin2c.pl
191 $(PERL) bin2c.pl syslinux_ldlinux < $< > $@
193 extlinux_bss_bin.c: extlinux.bss bin2c.pl
194 $(PERL) bin2c.pl extlinux_bootsect < $< > $@
196 extlinux_sys_bin.c: extlinux.sys bin2c.pl
197 $(PERL) bin2c.pl extlinux_image < $< > $@
199 libsyslinux.a: bootsect_bin.o ldlinux_bin.o mbr_bin.o syslxmod.o
200 rm -f $@
201 $(AR) cq $@ $^
202 $(RANLIB) $@
204 $(LIB_SO): bootsect_bin.o ldlinux_bin.o syslxmod.o
205 $(CC) $(LDFLAGS) -shared -Wl,-soname,$(LIB_SONAME) -o $@ $^
207 gethostip: gethostip.o
208 $(CC) $(LDFLAGS) -o $@ $^
210 mkdiskimage: mkdiskimage.in mbr/mbr.bin bin2hex.pl
211 $(PERL) bin2hex.pl < mbr/mbr.bin | cat mkdiskimage.in - > $@
212 chmod a+x $@
214 install: installer
215 mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
216 install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
217 mkdir -m 755 -p $(INSTALLROOT)$(SBINDIR)
218 install -m 755 -c $(INSTALL_SBIN) $(INSTALLROOT)$(SBINDIR)
219 mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
220 install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
221 -install -m 644 -c $(INSTALL_AUX_OPT) $(INSTALLROOT)$(AUXDIR)
222 $(MAKE) -C com32 install
224 install-lib: installer
226 install-all: install install-lib
228 local-tidy:
229 rm -f *.o *_bin.c stupid.* patch.offset
230 rm -f *.lst *.map
231 rm -f $(OBSOLETE)
233 tidy: local-tidy
234 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
236 local-clean:
237 rm -f $(ITARGET)
239 clean: local-tidy local-clean
240 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
242 dist: tidy
243 for dir in . sample memdisk ; do \
244 ( cd $$dir && rm -f *~ \#* core ) ; \
245 done
247 local-spotless:
248 rm -f $(BTARGET) .depend *.so.*
250 spotless: local-clean dist local-spotless
251 set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
253 .depend:
254 rm -f .depend
255 for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done
256 for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
258 local-depend:
259 rm -f .depend
260 $(MAKE) .depend
262 depend: local-depend
263 $(MAKE) -C memdisk depend
265 # Shortcut to build unix/syslinux using klibc
266 klibc:
267 $(MAKE) clean
268 $(MAKE) CC=klcc ITARGET= ISUBDIRS='unix extlinux' BSUBDIRS=
270 # Hook to add private Makefile targets for the maintainer.
271 -include Makefile.private
273 # Include dependencies file
274 include .depend