Make the MEMDISK directory use the same clean conventions as the
[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 NASM    = nasm
19 CC      = gcc
20 CFLAGS  = -Wall -O2 -fomit-frame-pointer
21 LDFLAGS = -O2 -s
22
23 BINDIR  = /usr/bin
24 LIBDIR  = /usr/lib/syslinux
25
26 VERSION = $(shell cat version)
27
28 .c.o:
29         $(CC) $(CFLAGS) -c $<
30
31 #
32 # The BTARGET refers to objects that are derived from ldlinux.asm; we
33 # like to keep those uniform for debugging reasons; however, distributors 
34 # want to recompile the installers (ITARGET).
35 #
36 SOURCES = ldlinux.asm syslinux.asm syslinux.c copybs.asm \
37           pxelinux.asm pxe.inc mbr.asm gethostip.c \
38           isolinux.asm
39 BTARGET = bootsect.bin ldlinux.sys ldlinux.bin ldlinux.lst \
40           pxelinux.0 mbr.bin isolinux.bin isolinux-debug.bin
41 ITARGET = syslinux.com syslinux copybs.com gethostip
42 DOCS    = COPYING NEWS README TODO *.doc sample
43 OTHER   = Makefile bin2c.pl now.pl genstupid.pl keytab-lilo.pl version \
44           sys2ansi.pl ppmtolss16 lss16toppm memdisk
45 OBSOLETE = pxelinux.bin
46
47 # Things to install in /usr/bin
48 INSTALL_BIN   = syslinux gethostip ppmtolss16 lss16toppm
49 # Things to install in /usr/lib/syslinux
50 INSTALL_LIB   = pxelinux.0 isolinux.bin isolinux-debug.bin \
51                 syslinux.com copybs.com memdisk/memdisk
52
53 # The DATE is set on the make command line when building binaries for
54 # official release.  Otherwise, substitute a hex string that is pretty much
55 # guaranteed to be unique to be unique from build to build.
56 ifndef HEXDATE
57 HEXDATE := $(shell perl now.pl ldlinux.asm pxelinux.asm isolinux.asm)
58 endif
59 ifndef DATE
60 DATE    := $(HEXDATE)
61 endif
62
63 all:    $(BTARGET) $(ITARGET) samples memdisk
64         ls -l $(BTARGET) $(ITARGET) memdisk/memdisk
65
66 installer: $(ITARGET) samples
67         ls -l $(BTARGET) $(ITARGET)
68
69 .PHONY: samples
70 samples:
71         $(MAKE) -C sample all
72
73 .PHONY: memdisk
74 memdisk:
75         $(MAKE) -C memdisk all
76
77 ldlinux.bin: ldlinux.asm
78         $(NASM) -f bin -dVERSION="'$(VERSION)'" -dDATE_STR="'$(DATE)'" \
79                 -dHEXDATE="$(HEXDATE)" \
80                 -l ldlinux.lst -o ldlinux.bin ldlinux.asm
81         perl genstupid.pl < ldlinux.lst
82
83 pxelinux.0: pxelinux.asm pxe.inc
84         $(NASM) -f bin -dVERSION="'$(VERSION)'" -dDATE_STR="'$(DATE)'" \
85                 -dHEXDATE="$(HEXDATE)" \
86                 -l pxelinux.lst -o pxelinux.0 pxelinux.asm
87
88 isolinux.bin: isolinux.asm
89         $(NASM) -f bin -dVERSION="'$(VERSION)'" -dDATE_STR="'$(DATE)'" \
90                 -dHEXDATE="$(HEXDATE)" \
91                 -l isolinux.lst -o isolinux.bin isolinux.asm
92
93 # Special verbose version of isolinux.bin
94 isolinux-debug.bin: isolinux.asm
95         $(NASM) -f bin -dVERSION="'$(VERSION)'" -dDATE_STR="'$(DATE)'" \
96                 -dHEXDATE="$(HEXDATE)" -dDEBUG_MESSAGES \
97                 -l isolinux-debug.lst -o isolinux-debug.bin isolinux.asm
98
99 bootsect.bin: ldlinux.bin
100         dd if=ldlinux.bin of=bootsect.bin bs=512 count=1
101
102 ldlinux.sys: ldlinux.bin
103         dd if=ldlinux.bin of=ldlinux.sys  bs=512 skip=1
104
105 mbr.bin: mbr.asm
106         $(NASM) -f bin -l mbr.lst -o mbr.bin mbr.asm
107
108 syslinux.com: syslinux.asm bootsect.bin ldlinux.sys stupid.inc
109         $(NASM) -f bin -l syslinux.lst -o syslinux.com syslinux.asm
110
111 copybs.com: copybs.asm
112         $(NASM) -f bin -l copybs.lst -o copybs.com copybs.asm
113
114 bootsect_bin.c: bootsect.bin bin2c.pl
115         perl bin2c.pl bootsect < bootsect.bin > bootsect_bin.c
116
117 ldlinux_bin.c: ldlinux.sys bin2c.pl
118         perl bin2c.pl ldlinux < ldlinux.sys > ldlinux_bin.c
119
120 syslinux: syslinux.o bootsect_bin.o ldlinux_bin.o stupid.o
121         $(CC) $(LDFLAGS) -o syslinux \
122                 syslinux.o bootsect_bin.o ldlinux_bin.o stupid.o
123
124 ldlinux.lst: ldlinux.bin
125         : Generated by side effect
126
127 stupid.c: ldlinux.lst genstupid.pl
128         perl genstupid.pl < ldlinux.lst
129
130 stupid.inc: stupid.c
131         : Generated by side effect
132
133 stupid.o: stupid.c
134
135 gethostip.o: gethostip.c
136
137 gethostip: gethostip.o
138
139 install: installer
140         mkdir -m 755 -p $(INSTALLROOT)$(BINDIR) $(INSTALLROOT)$(LIBDIR)
141         install -m 755 -c $(INSTALL_BIN) $(INSTALLROOT)$(BINDIR)
142         install -m 644 -c $(INSTALL_LIB) $(INSTALLROOT)$(LIBDIR)
143
144 local-tidy:
145         rm -f *.o *_bin.c stupid.*
146         rm -f syslinux.lst copybs.lst pxelinux.lst isolinux*.lst
147         rm -f $(OBSOLETE)
148
149 tidy: local-tidy
150         $(MAKE) -C memdisk tidy
151
152 clean: local-tidy
153         rm -f $(ITARGET)
154         $(MAKE) -C sample clean
155         $(MAKE) -C memdisk clean
156
157 dist: tidy
158         for dir in . sample memdisk ; do \
159                 ( cd $$dir && rm -f *~ \#* core ) ; \
160         done
161
162 spotless: clean dist
163         rm -f $(BTARGET)
164         $(MAKE) -C sample spotless
165         $(MAKE) -C memdisk spotless
166
167 #
168 # Hook to add private Makefile targets for the maintainer.
169 #
170 -include Makefile.private