*** empty log message ***
[profile/ivi/syslinux.git] / Makefile
1 ## -----------------------------------------------------------------------
2 ##  $Id$
3 ##
4 ##   Copyright 1998-2001 H. Peter Anvin - All Rights Reserved
5 ##
6 ##   This program is free software; you can redistribute it and/or modify
7 ##   it under the terms of the GNU General Public License as published by
8 ##   the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
9 ##   USA; either version 2 of the License, or (at your option) any later
10 ##   version; incorporated herein by reference.
11 ##
12 ## -----------------------------------------------------------------------
13
14 #
15 # Main Makefile for SYSLINUX
16 #
17
18 CC       = gcc
19 INCLUDE  =
20 CFLAGS   = -Wall -O2 -fomit-frame-pointer
21 LDFLAGS  = -O2 -s
22
23 NASM     = nasm
24 NINCLUDE = 
25 BINDIR   = /usr/bin
26 LIBDIR   = /usr/lib/syslinux
27
28 PERL     = perl
29
30 VERSION  = $(shell cat version)
31
32 .c.o:
33         $(CC) $(INCLUDE) $(CFLAGS) -c $<
34
35 #
36 # The BTARGET refers to objects that are derived from ldlinux.asm; we
37 # like to keep those uniform for debugging reasons; however, distributors 
38 # want to recompile the installers (ITARGET).
39 #
40 CSRC    = syslinux.c gethostip.c
41 NASMSRC  = ldlinux.asm syslinux.asm copybs.asm \
42           pxelinux.asm mbr.asm isolinux.asm
43 SOURCES = $(CSRC) $(NASMSRC) *.inc
44 BTARGET = ldlinux.bss ldlinux.sys ldlinux.bin ldlinux.lst \
45           pxelinux.0 mbr.bin isolinux.bin isolinux-debug.bin
46 ITARGET = syslinux.com syslinux copybs.com gethostip
47 DOCS    = COPYING NEWS README TODO *.doc sample
48 OTHER   = Makefile bin2c.pl now.pl genhash.pl keywords genstupid.pl \
49           keytab-lilo.pl version sys2ansi.pl ppmtolss16 lss16toppm memdisk
50 OBSOLETE = pxelinux.bin
51
52 # Things to install in /usr/bin
53 INSTALL_BIN   = syslinux gethostip ppmtolss16 lss16toppm
54 # Things to install in /usr/lib/syslinux
55 INSTALL_LIB   = pxelinux.0 isolinux.bin isolinux-debug.bin \
56                 syslinux.com copybs.com memdisk/memdisk
57
58 # The DATE is set on the make command line when building binaries for
59 # official release.  Otherwise, substitute a hex string that is pretty much
60 # guaranteed to be unique to be unique from build to build.
61 ifndef HEXDATE
62 HEXDATE := $(shell $(PERL) now.pl ldlinux.asm pxelinux.asm isolinux.asm)
63 endif
64 ifndef DATE
65 DATE    := $(HEXDATE)
66 endif
67
68 all:    $(BTARGET) $(ITARGET) samples memdisk
69         ls -l $(BTARGET) $(ITARGET) memdisk/memdisk
70
71 installer: $(ITARGET) samples
72         ls -l $(BTARGET) $(ITARGET)
73
74 .PHONY: samples
75 samples:
76         $(MAKE) -C sample all
77
78 .PHONY: memdisk
79 memdisk:
80         $(MAKE) -C memdisk all
81
82 kwdhash.inc: keywords genhash.pl
83         $(PERL) genhash.pl < keywords > kwdhash.inc
84
85 ldlinux.bin: ldlinux.asm kwdhash.inc
86         $(NASM) -f bin -dVERSION="'$(VERSION)'" -dDATE_STR="'$(DATE)'" \
87                 -dHEXDATE="$(HEXDATE)" \
88                 -l ldlinux.lst -o ldlinux.bin ldlinux.asm
89         $(PERL) genstupid.pl < ldlinux.lst
90
91 pxelinux.0: pxelinux.asm kwdhash.inc
92         $(NASM) -f bin -dVERSION="'$(VERSION)'" -dDATE_STR="'$(DATE)'" \
93                 -dHEXDATE="$(HEXDATE)" \
94                 -l pxelinux.lst -o pxelinux.0 pxelinux.asm
95
96 isolinux.bin: isolinux.asm kwdhash.inc
97         $(NASM) -f bin -dVERSION="'$(VERSION)'" -dDATE_STR="'$(DATE)'" \
98                 -dHEXDATE="$(HEXDATE)" \
99                 -l isolinux.lst -o isolinux.bin isolinux.asm
100
101 # Special verbose version of isolinux.bin
102 isolinux-debug.bin: isolinux.asm kwdhash.inc
103         $(NASM) -f bin -dVERSION="'$(VERSION)'" -dDATE_STR="'$(DATE)'" \
104                 -dHEXDATE="$(HEXDATE)" -dDEBUG_MESSAGES \
105                 -l isolinux-debug.lst -o isolinux-debug.bin isolinux.asm
106
107 ldlinux.bss: ldlinux.bin
108         dd if=ldlinux.bin of=ldlinux.bss bs=512 count=1
109
110 ldlinux.sys: ldlinux.bin
111         dd if=ldlinux.bin of=ldlinux.sys  bs=512 skip=1
112
113 mbr.bin: mbr.asm
114         $(NASM) -f bin -l mbr.lst -o mbr.bin mbr.asm
115
116 syslinux.com: syslinux.asm ldlinux.bss ldlinux.sys stupid.inc
117         $(NASM) -f bin -l syslinux.lst -o syslinux.com syslinux.asm
118
119 copybs.com: copybs.asm
120         $(NASM) -f bin -l copybs.lst -o copybs.com copybs.asm
121
122 bootsect_bin.c: ldlinux.bss bin2c.pl
123         $(PERL) bin2c.pl bootsect < ldlinux.bss > bootsect_bin.c
124
125 ldlinux_bin.c: ldlinux.sys bin2c.pl
126         $(PERL) bin2c.pl ldlinux < ldlinux.sys > ldlinux_bin.c
127
128 syslinux: syslinux.o bootsect_bin.o ldlinux_bin.o stupid.o
129         $(CC) $(LDFLAGS) -o syslinux \
130                 syslinux.o bootsect_bin.o ldlinux_bin.o stupid.o
131
132 ldlinux.lst: ldlinux.bin
133         : Generated by side effect
134
135 stupid.c: ldlinux.lst genstupid.pl
136         $(PERL) genstupid.pl < ldlinux.lst
137
138 stupid.inc: stupid.c
139         : Generated by side effect
140
141 stupid.o: stupid.c
142
143 gethostip.o: gethostip.c
144
145 gethostip: gethostip.o
146
147 install: installer
148         mkdir -m 755 -p $(INSTALLROOT)$(BINDIR) $(INSTALLROOT)$(LIBDIR)
149         install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
150         install -m 644 -c $(INSTALL_LIB) $(INSTALLROOT)$(LIBDIR)
151
152 local-tidy:
153         rm -f *.o *_bin.c stupid.*
154         rm -f syslinux.lst copybs.lst pxelinux.lst isolinux*.lst
155         rm -f $(OBSOLETE)
156
157 tidy: local-tidy
158         $(MAKE) -C memdisk tidy
159
160 local-clean:
161         rm -f $(ITARGET)
162
163 clean: local-tidy local-clean
164         $(MAKE) -C sample clean
165         $(MAKE) -C memdisk clean
166
167 dist: tidy
168         for dir in . sample memdisk ; do \
169                 ( cd $$dir && rm -f *~ \#* core ) ; \
170         done
171
172 local-spotless:
173         rm -f $(BTARGET) .depend
174
175 spotless: local-clean dist local-spotless
176         $(MAKE) -C sample spotless
177         $(MAKE) -C memdisk spotless
178
179 .depend:
180         rm -f .depend
181         for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -M $$csrc >> .depend ; done
182         for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
183
184 depend:
185         rm -f .depend
186         $(MAKE) .depend
187
188 # Hook to add private Makefile targets for the maintainer.
189 -include Makefile.private
190
191 # Include dependencies file
192 -include .depend