Add support for Unix-standard MD5 password
[profile/ivi/syslinux.git] / Makefile
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.
10 ##
11 ## -----------------------------------------------------------------------
12
13 #
14 # Main Makefile for SYSLINUX
15 #
16
17 # No builtin rules
18 MAKEFLAGS = -r
19
20 TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
21
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)
24
25 comma   := ,
26 LDHASH  := $(call gcc_ok,-Wl$(comma)--hash-style=both,)
27
28 OSTYPE   = $(shell uname -msr)
29 CC       = gcc
30 INCLUDE  =
31 CFLAGS   = -W -Wall -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
32 PIC      = -fPIC
33 LDFLAGS  = -O2 -s $(LDHASH)
34 AR       = ar
35 RANLIB   = ranlib
36
37 NASM     = nasm
38 NINCLUDE =
39 BINDIR   = /usr/bin
40 SBINDIR  = /sbin
41 LIBDIR   = /usr/lib
42 AUXDIR   = $(LIBDIR)/syslinux
43 INCDIR   = /usr/include
44
45 PERL     = perl
46
47 VERSION  = $(shell cat version)
48
49 %.o: %.c
50         $(CC) $(INCLUDE) $(CFLAGS) -c $<
51
52 #
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).
56 #
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
60 # directories.
61 #
62 CSRC     = syslxmod.c gethostip.c
63 NASMSRC  = $(wildcard *.asm)
64 SOURCES = $(CSRC) *.h $(NASMSRC) *.inc
65
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
69
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 memdisk/memdisk
77 # BESUBDIRS and IESUBDIRS are "early", i.e. before the root; BSUBDIRS
78 # and ISUBDIRS are "late", after the root.
79 BESUBDIRS = mbr
80 BSUBDIRS = memdisk dos win32
81 ITARGET  = copybs.com gethostip mkdiskimage
82 IOBJECTS = $(ITARGET) mtools/syslinux unix/syslinux extlinux/extlinux
83 IESUBDIRS =
84 ISUBDIRS = mtools unix extlinux sample com32
85 DOCS     = COPYING NEWS README TODO BUGS *.doc sample menu com32
86 OTHER    = Makefile bin2c.pl now.pl genhash.pl keywords findpatch.pl \
87            keytab-lilo.pl version version.pl sys2ansi.pl \
88            ppmtolss16 lss16toppm memdisk bin2hex.pl mkdiskimage.in \
89            sha1pass md5pass
90 OBSOLETE = pxelinux.bin
91
92 # Things to install in /usr/bin
93 INSTALL_BIN   = mtools/syslinux gethostip ppmtolss16 lss16toppm
94 # Things to install in /sbin
95 INSTALL_SBIN  = extlinux/extlinux
96 # Things to install in /usr/lib/syslinux
97 INSTALL_AUX   = pxelinux.0 isolinux.bin isolinux-debug.bin \
98                 dos/syslinux.com copybs.com memdisk/memdisk mbr/mbr.bin
99 INSTALL_AUX_OPT = win32/syslinux.exe
100
101 # The DATE is set on the make command line when building binaries for
102 # official release.  Otherwise, substitute a hex string that is pretty much
103 # guaranteed to be unique to be unique from build to build.
104 ifndef HEXDATE
105 HEXDATE := $(shell $(PERL) now.pl ldlinux.asm pxelinux.asm isolinux.asm)
106 endif
107 ifndef DATE
108 DATE    := $(HEXDATE)
109 endif
110 MAKE    += DATE=$(DATE) HEXDATE=$(HEXDATE)
111
112 #
113 # NOTE: If you don't have the mingw compiler suite installed, you probably
114 # want to remove win32 from this list; otherwise you're going to get an
115 # error every time you try to build.
116 #
117
118 all:
119         set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) ; do $(MAKE) -C $$i $@ ; done
120         $(MAKE) all-local
121         set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
122         -ls -l $(BOBJECTS) $(IOBJECTS)
123
124 all-local: $(BTARGET) $(ITARGET) $(BINFILES)
125
126 installer: installer-local
127         set -e ; for i in $(ISUBDIRS); do $(MAKE) -C $$i all ; done
128         -ls -l $(BOBJECTS) $(IOBJECTS)
129
130 installer-local: $(ITARGET) $(BINFILES)
131
132 version.gen: version version.pl
133         $(PERL) version.pl $< $@ '%define'
134
135 version.h: version version.pl
136         $(PERL) version.pl $< $@ '#define'
137
138 kwdhash.gen: keywords genhash.pl
139         $(PERL) genhash.pl < keywords > kwdhash.gen
140
141 # Standard rule for {ldlinux,pxelinux,isolinux,isolinux-debug,extlinux}.bin
142 %.bin: %.asm kwdhash.gen version.gen
143         $(NASM) -O99 -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
144                 -DMAP=$(@:.bin=.map) -l $(@:.bin=.lsr) -o $@ $<
145         $(PERL) lstadjust.pl $(@:.bin=.lsr) $(@:.bin=.map) $(@:.bin=.lst)
146         $(PERL) checkov.pl $(@:.bin=.map) $@
147
148 pxelinux.0: pxelinux.bin
149         cp pxelinux.bin pxelinux.0
150
151 ldlinux.bss: ldlinux.bin
152         dd if=$< of=$@ bs=512 count=1
153
154 ldlinux.sys: ldlinux.bin
155         dd if=$< of=$@ bs=512 skip=1
156
157 extlinux.bss: extlinux.bin
158         dd if=$< of=$@ bs=512 count=1
159
160 extlinux.sys: extlinux.bin
161         dd if=$< of=$@ bs=512 skip=1
162
163 mbr_bin.c: mbr/mbr.bin bin2c.pl
164         $(PERL) bin2c.pl syslinux_mbr < $< > $@
165
166 copybs.com: copybs.asm
167         $(NASM) -O99 -f bin -l copybs.lst -o copybs.com copybs.asm
168
169 bootsect_bin.c: ldlinux.bss bin2c.pl
170         $(PERL) bin2c.pl syslinux_bootsect < $< > $@
171
172 ldlinux_bin.c: ldlinux.sys bin2c.pl
173         $(PERL) bin2c.pl syslinux_ldlinux < $< > $@
174
175 extlinux_bss_bin.c: extlinux.bss bin2c.pl
176         $(PERL) bin2c.pl extlinux_bootsect < $< > $@
177
178 extlinux_sys_bin.c: extlinux.sys bin2c.pl
179         $(PERL) bin2c.pl extlinux_image < $< > $@
180
181 libsyslinux.a: bootsect_bin.o ldlinux_bin.o mbr_bin.o syslxmod.o
182         rm -f $@
183         $(AR) cq $@ $^
184         $(RANLIB) $@
185
186 $(LIB_SO): bootsect_bin.o ldlinux_bin.o syslxmod.o
187         $(CC) $(LDFLAGS) -shared -Wl,-soname,$(LIB_SONAME) -o $@ $^
188
189 gethostip: gethostip.o
190         $(CC) $(LDFLAGS) -o $@ $^
191
192 mkdiskimage: mkdiskimage.in mbr/mbr.bin bin2hex.pl
193         $(PERL) bin2hex.pl < mbr/mbr.bin | cat mkdiskimage.in - > $@
194         chmod a+x $@
195
196 install: installer
197         mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
198         install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
199         mkdir -m 755 -p $(INSTALLROOT)$(SBINDIR)
200         install -m 755 -c $(INSTALL_SBIN) $(INSTALLROOT)$(SBINDIR)
201         mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
202         install -m 644 -c $(INSTALL_AUX) $(INSTALLROOT)$(AUXDIR)
203         -install -m 644 -c $(INSTALL_AUX_OPT) $(INSTALLROOT)$(AUXDIR)
204         $(MAKE) -C com32 install
205
206 install-lib: installer
207
208 install-all: install install-lib
209
210 local-tidy:
211         rm -f *.o *_bin.c stupid.* patch.offset
212         rm -f *.lsr *.lst *.map
213         rm -f $(OBSOLETE)
214
215 tidy: local-tidy
216         set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
217
218 local-clean:
219         rm -f $(ITARGET)
220
221 clean: local-tidy local-clean
222         set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
223
224 dist: tidy
225         for dir in . sample memdisk ; do \
226                 ( cd $$dir && rm -f *~ \#* core ) ; \
227         done
228
229 local-spotless:
230         rm -f $(BTARGET) .depend *.so.*
231
232 spotless: local-clean dist local-spotless
233         set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
234
235 .depend:
236         rm -f .depend
237         for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done
238         for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
239
240 local-depend:
241         rm -f .depend
242         $(MAKE) .depend
243
244 depend: local-depend
245         $(MAKE) -C memdisk depend
246
247 # Shortcut to build unix/syslinux using klibc
248 klibc:
249         $(MAKE) clean
250         $(MAKE) CC=klcc ITARGET= ISUBDIRS='unix extlinux' BSUBDIRS=
251
252 # Hook to add private Makefile targets for the maintainer.
253 -include Makefile.private
254
255 # Include dependencies file
256 include .depend