af916c484a3bf875d45d9c53f7c082ccecd428dd
[rrq/maintain_lilo.git] / src / Makefile
1 # -*- makefile -*-
2 #
3 # Copyright 2009-2011 Joachim Wiedorn
4 # All rights reserved.
5
6 # Licensed under the terms contained in the file 'COPYING'
7 # in the source directory.
8 #
9
10 # adding variables
11 include ../make.vars
12
13 #
14 #  Do not modify anything below this point
15 #
16
17 SHELL=/bin/sh
18 CC=gcc
19 CPP=$(CC) -E
20 AS86=as86 -0 -a
21 LD86=ld86 -0
22 NASM=nasm
23 G=`cat foo1 foo2 | grep version | cut -d " " -f 3`
24
25 CFLAGS=$(OPT) -Wall $(PCONFIG)
26 LDFLAGS=#-Xlinker -qmagic
27 LIBS=$(DEVMAPPER)
28
29 OBJS=lilo.o raid.o map.o geometry.o boot.o device.o common.o bsect.o cfg.o \
30   partition.o identify.o probe.o shs2.o edit.o temp.o
31
32 EDIT=edit.c common.o
33
34 LIS=chain.lis disk.lis dparam.lis first.lis second.lis \
35   bootsect.lis third.lis mbr.lis bitmap.lis pseudo.lis mbr2.lis \
36   pseudo1.lis loader.lis pseudo3.lis
37 BFILES=first.b second.b third.b bitmap.b chain.b mbr.b mbr2.b \
38   bootsect.b pseudo1.b pseudo2.b pseudo3.b
39 CFILES=boot.c bsect.c cfg.c common.c device.c edit.c geometry.c \
40   identify.c lilo.c map.c partition.c probe.c raid.c shs2.c temp.c
41 HFILES=bdata.h bitmap.h boot.h bsect.h cfg.h common.h config.h device.h \
42   edit.h geometry.h identify.h lilo.h loader.h map.h md-int.h partition.h \
43   probe.h raid.h shs2.h temp.h version.h vesainfo.h
44
45 .SUFFIXES:      .img .b .com .S .s
46
47
48 #
49 # everything needed to run, just short of installation
50 #
51 all:    lilo bootsect.b
52
53 #
54 # everything above plus the statically linked version
55 #
56 alles: all diag1.img lilo.static
57
58 #
59 # make the bootable diagnostic floppies
60 #
61 floppy1: disk.com bootsect.b
62         @echo
63         @echo Creating Diagnostic Floppy 1.6
64         @echo
65         @echo Insert a blank, formatted, floppy into drive 0
66         @echo "Press <Enter> to continue, <^C> to abort ..."
67         @read
68         cat bootsect.b disk.com | dd of=/dev/fd0 bs=512
69
70 floppy2: disk.b
71         @echo
72         @echo Creating Diagnostic Floppy 2.4
73         @$(MAKE) -C ../diagnose check
74         @$(MAKE) -C ../diagnose floppy
75
76 diagnostic: ../test.img diag1.img diag2.img diag3.img
77
78 manpath:
79         echo $(MAN_DIR)
80
81 .c.o:
82                 $(CC) -c $(CFLAGS) $*.c
83
84 .s.o:
85                 $(AS86) -w -l $*.lis -o $*.o $*.s
86
87 .o.img:
88                 $(LD86) -s -o $*.img $*.o
89
90 .img.b:
91                 dd if=$*.img of=$*.b bs=32 skip=1
92
93 edit:           $(EDIT)
94                 $(CC) $(CFLAGS) -DSTANDALONE -o edit $(EDIT) $(LDFLAGS)
95
96 loader.i:       mkloader first.b second.b third.b bitmap.b mbr.b chain.b mbr2.b
97                 ./mkloader >loader.i
98
99 disk.com:       disk.b
100                 cp disk.b disk.com
101
102 disk.s:         disk.S read.S bdata.h biosdata.S lilo.h Makefile
103                 $(CPP) -traditional $(PCONFIG) -o disk.s  disk.S
104
105 mbr.s:          mbr.S lilo.h Makefile
106                 $(CPP) -traditional $(PCONFIG) -DMBR=0xafbbe760 \
107                         -o mbr.s  mbr.S
108
109 mbr.b:          mbr.img
110                 dd if=$*.img of=$*.b bs=32 skip=49
111
112 mbr2.s:         mbr.S lilo.h Makefile
113                 $(CPP) -traditional $(PCONFIG) -DMBX=0x93c00848 \
114                         -o mbr2.s  mbr.S
115
116 mbr2.b: mbr2.img
117         dd if=$*.img of=$*.b bs=32 skip=49
118
119 bootsect.s: bootsect.S disk.b
120         $(CPP) -traditional $(PCONFIG) \
121                 -DSIZEDISKB=`wc -c <disk.b | sed "s/ //g"` \
122                 -o bootsect.s  bootsect.S
123
124 pseudo1.s: bootsect.S pseudo.S disk.com
125         cat bootsect.S pseudo.S >$(TMP).S
126         $(CPP) -traditional $(PCONFIG) \
127                 -DSIZEKRNL=`wc -c <disk.com | sed "s/ //g"` \
128                 -DSIZEDISKB=512 -o pseudo1.s $(TMP).S
129         rm -f $(TMP).S
130
131 pseudo2.s: bootsect.S pseudo.S
132         $(MAKE) -C ../diagnose all
133         cat bootsect.S pseudo.S >$(TMP).S
134         $(CPP) -traditional $(PCONFIG) \
135                 -DSIZEKRNL=`wc -c <../diagnose/test4.com | sed "s/ //g"` \
136                 -DSIZEDISKB=512 -o pseudo2.s $(TMP).S
137         rm -f $(TMP).S
138
139 pseudo3.s: bootsect.S pseudo.S
140         $(MAKE) -C ../diagnose all
141         cat bootsect.S pseudo.S >$(TMP).S
142         $(CPP) -traditional $(PCONFIG) \
143                 -DSIZEKRNL=`wc -c <../diagnose/test5.com | sed "s/ //g"` \
144                 -DSIZEDISKB=512 -o pseudo3.s $(TMP).S
145         rm -f $(TMP).S
146
147 pseudo1.b:      pseudo1.s
148 pseudo2.b:      pseudo2.s
149 pseudo3.b:      pseudo3.s
150
151
152 diag1.img:      disk.com pseudo1.b
153         cat pseudo1.b disk.com >diag1.img
154
155 diag2.img: pseudo2.b
156         $(MAKE) -C ../diagnose all
157         cat pseudo2.b ../diagnose/test4.com >diag2.img
158
159 diag3.img: pseudo3.b
160         $(MAKE) -C ../diagnose all
161         cat pseudo3.b ../diagnose/test5.com >diag3.img
162
163 flags.i:        ../test.img Makefile version $(CFILES) $(HFILES)
164         echo "#define CFLAGS \"" $(CFLAGS) "\"" >flags.i
165         tail -$$((`wc -l <Makefile`-`sed /\#\#\#/q <Makefile | wc -l`)) \
166           <Makefile | grep -v "0x" >$(TMP)
167         for i in $(CFILES) $(HFILES) ; do cat $$i >>$(TMP) ; done
168         echo "#define CSOURCE " `./version $(TMP)` >>flags.i
169         rm -f $(TMP)
170
171
172 dparam.com:     dparam.img
173                 dd if=dparam.img of=dparam.com bs=288 skip=1
174
175 dparam.s:       dparam.S
176                 cp -p dparam.S dparam.s
177
178 lilo:           $(OBJS)
179                 $(CC) -o lilo $(LDFLAGS) $(OBJS) $(LIBS)
180
181 lilo.static:    $(OBJS)
182                 $(CC) -o lilo.static -static $(LDFLAGS) $(OBJS) $(LIBS)
183
184 common.s:       common.h
185                 $(CPP) -C -traditional -DLILO_ASM -o common.s common.h
186
187 bitmap.o: bitmap.s common.s
188 third.o: third.s common.s
189 second.o: second.s common.s
190 first.o: first.s common.s
191 chain.o: chain.s common.s
192
193 first.s:        first.S lilo.h version.h Makefile
194                 $(CPP) $(PCONFIG) -DFIRST=0x62177489 -o first.s first.S
195
196 second.s:       second.S read.S volume.S mapper.S biosdata.S shs3.S bdata.h lilo.h version.h \
197                         graph.S menu.S strlen.S bitmap.S crt.S display4.S Makefile
198                 $(CPP) $(PCONFIG) -DTEXT=0x9dd476ec second.S -o second.s
199
200 third.s:        second.S read.S volume.S mapper.S biosdata.S shs3.S bdata.h lilo.h version.h \
201                         graph.S menu.S strlen.S bitmap.S crt.S display4.S Makefile
202                 $(CPP) $(PCONFIG) -DMENU=0x2012a4a7 second.S -o third.s
203
204 bitmap.s:       second.S read.S volume.S mapper.S biosdata.S shs3.S bdata.h lilo.h version.h \
205                         graph.S menu.S strlen.S bitmap.S crt.S display4.S Makefile
206                 $(CPP) $(PCONFIG) -DBITMAP=0x2ece2fbe second.S -o bitmap.s
207
208 chain.s:        chain.S lilo.h version.h first.b Makefile
209                 $(CPP) $(PCONFIG) -DCHAIN=0x536a7646 chain.S -o chain.s
210
211 xxx.s:          chain.S lilo.h Makefile
212                 $(CPP) chain.S -DXXX -o xxx.s
213
214 $(OBJS):        Makefile
215
216 #
217 # shorthand install, if one knows that one has the 'bcc' compiler
218 #
219 ins:    diag install
220
221 #
222 #  normal install, but doesn't make the diagnostic binaries
223 #
224 install:
225         mkdir -p $$DESTDIR$(SBIN_DIR) $$DESTDIR$(CFG_DIR) 
226         mkdir -p $$DESTDIR$(BOOT_DIR) $$DESTDIR$(USRSBIN_DIR)
227
228         @if [ -e $$DESTDIR$(BOOT_DIR)/boot.b -o -e $$DESTDIR$(BOOT_DIR)/boot.old ]; then \
229           rm -f $$DESTDIR$(BOOT_DIR)/boot.b; rm -f $$DESTDIR$(BOOT_DIR)/boot.old; fi
230         @if [ -f $$DESTDIR$(BOOT_DIR)/boot-bmp.b -o -f $$DESTDIR$(BOOT_DIR)/boot-bmp.old ]; then \
231           rm -f $$DESTDIR$(BOOT_DIR)/boot-bmp.b; rm -f $$DESTDIR$(BOOT_DIR)/boot-bmp.old; fi
232         @if [ -f $$DESTDIR$(BOOT_DIR)/boot-menu.b -o -f $$DESTDIR$(BOOT_DIR)/boot-menu.old ]; then \
233           rm -f $$DESTDIR$(BOOT_DIR)/boot-menu.b; rm -f $$DESTDIR$(BOOT_DIR)/boot-menu.old; fi
234         @if [ -f $$DESTDIR$(BOOT_DIR)/boot-text.b -o -f $$DESTDIR$(BOOT_DIR)/boot-text.old ]; then \
235           rm -f $$DESTDIR$(BOOT_DIR)/boot-text.b; rm -f $$DESTDIR$(BOOT_DIR)/boot-text.old; fi
236         @if [ -f $$DESTDIR$(BOOT_DIR)/chain.b ]; then \
237           mv $$DESTDIR$(BOOT_DIR)/chain.b $$DESTDIR$(BOOT_DIR)/chain.old; fi
238         @if [ -f $$DESTDIR$(BOOT_DIR)/mbr.b ]; then \
239           mv $$DESTDIR$(BOOT_DIR)/mbr.b $$DESTDIR$(BOOT_DIR)/mbr.old; fi
240
241         if [ -f chain.b -a  $(BUILTIN) -eq 0 ]; then cp chain.b $$DESTDIR$(BOOT_DIR); fi
242         if [ -f mbr.b   -a  $(BUILTIN) -eq 0 ]; then cp mbr.b   $$DESTDIR$(BOOT_DIR); fi
243         if [ -f diag1.img ]; then cp -f diag1.img $$DESTDIR$(BOOT_DIR); fi
244         if [ -f diag2.img ]; then cp -f diag2.img $$DESTDIR$(BOOT_DIR); fi
245
246         cp lilo $$DESTDIR$(SBIN_DIR)/lilo
247         strip $$DESTDIR$(SBIN_DIR)/lilo
248         cp ../mkrescue $$DESTDIR$(USRSBIN_DIR)/mkrescue
249         cp ../keytab-lilo.pl $$DESTDIR$(USRSBIN_DIR)/keytab-lilo
250
251 dep:
252         sed '/\#\#\# Dependencies/q' <Makefile >tmp_make
253         $(CPP) $(CFLAGS) -MM *.c >>tmp_make
254         mv tmp_make Makefile
255
256 version:        common.c lilo.h common.h
257         $(CC) $(CFLAGS) -DSHS_MAIN -o version common.c
258
259 mkloader:       temp.c
260         $(CC) $(CFLAGS) -DLILO_BINARY -o mkloader temp.c
261
262
263 tidy:
264         rm -f core $(LIS) *.shs *.crc $(TMP)*
265         rm -rf sbin boot usr
266         if [ -x lilo ]; then strip lilo; fi
267         if [ -x lilo.static ]; then strip lilo.static; fi
268
269 clean:
270         rm -f *.o *.s *.i *.img *.b tmp_make version
271         rm -f lilo lilo.static edit mkloader
272
273 distclean:
274         rm -f *~ */*~ *.b *.com lilo*tar.gz
275
276 uninstall:
277         rm -f $$DESTDIR$(SBIN_DIR)/lilo
278         rm -f $$DESTDIR$(USRSBIN_DIR)/mkrescue
279         rm -f $$DESTDIR$(USRSBIN_DIR)/keytab-lilo
280         rm -f $$DESTDIR$(BOOT_DIR)/diag1.img
281         rm -f $$DESTDIR$(BOOT_DIR)/diag2.img
282
283         if [ -f $$DESTDIR$(BOOT_DIR)/chain.b ]; then \
284           rm -f $$DESTDIR$(BOOT_DIR)/chain.b; fi
285         if [ -f $$DESTDIR$(BOOT_DIR)/mbr.b ]; then \
286           rm -f $$DESTDIR$(BOOT_DIR)/mbr.b; fi
287
288
289 ### Dependencies
290 boot.o: boot.c config.h lilo.h version.h common.h geometry.h device.h \
291   cfg.h map.h partition.h boot.h loader.h
292 bsect.o: bsect.c config.h lilo.h version.h common.h raid.h cfg.h device.h \
293   geometry.h map.h temp.h partition.h boot.h bsect.h bitmap.h probe.h \
294   loader.h edit.h shs2.h
295 cfg.o: cfg.c lilo.h version.h common.h temp.h cfg.h
296 common.o: common.c lilo.h version.h common.h
297 device.o: device.c config.h lilo.h version.h common.h temp.h device.h \
298   geometry.h partition.h cfg.h probe.h md-int.h
299 edit.o: edit.c config.h lilo.h version.h common.h cfg.h temp.h bsect.h \
300   bitmap.h edit.h
301 geometry.o: geometry.c config.h lilo.h version.h common.h device.h raid.h \
302   geometry.h cfg.h md-int.h probe.h
303 identify.o: identify.c lilo.h version.h common.h cfg.h
304 lilo.o: lilo.c config.h lilo.h version.h common.h cfg.h raid.h boot.h \
305   device.h flags.i geometry.h map.h bsect.h identify.h partition.h \
306   probe.h temp.h loader.h md-int.h edit.h bitmap.h
307 map.o: map.c lilo.h version.h common.h geometry.h map.h
308 partition.o: partition.c config.h lilo.h version.h common.h cfg.h \
309   device.h geometry.h partition.h boot.h loader.h
310 probe.o: probe.c lilo.h version.h common.h device.h geometry.h \
311   partition.h bsect.h bdata.h probe.h
312 raid.o: raid.c config.h lilo.h version.h common.h raid.h boot.h device.h \
313   geometry.h bsect.h cfg.h partition.h md-int.h
314 shs2.o: shs2.c lilo.h version.h shs2.h
315 temp.o: temp.c lilo.h version.h common.h temp.h loader.i