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