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