xref: /plan9/sys/src/9/pcboot/mkfile (revision 0792d947be768a877eb2f61da0eec05e1238d60b)
1# build pxe loaders (from pxe + pbs) and disk loaders (disk + usb)
2objtype=386
3</$objtype/mkfile
4
5TARG=\
6	9boot\
7	9bootpbs\
8	9load\
9	9loadusb\
10
11BIN=/386
12
13PXEBASE=0x80007c00
14PBSBASE=0x80010000
15# assume we've been decompressed into place by our header.
16# BOOTBASE must match expand.c's Kerneladdr|KZERO; +0x20 allows for a.out header
17BOOTBASE=0x80900020
18EXTRACOPIES=
19
20SFX=''				# defaults
21BASE=boot
22
23ONPROC=$NPROC
24NPROC=1				# don't build all boot flavours at once
25
26%.$O:	%.s
27	$AS $AFLAGS $stem.s
28
29%.$O:	%.c
30	$CC $CFLAGS $stem.c
31
32all:V: $TARG
33
34install:V: 9boot.install 9bootpbs.install 9load.install 9loadusb.install
35
36pcclean pclean:V:
37	@ { cd ../pc && mk clean }
38clean:V:
39	rm -f 8.* bootmain bootmain.c
40	@ {
41		rfork ne; bind bootmkfile mkfile
42		CONF=bootpbs SFX=pbs mk clean
43		BASE=load CONF=loadusb mk clean
44		BASE=load CONF=loadusb SFX=pxe mk clean
45		for (BASE in boot load)
46			CONF=$BASE mk clean
47	}
48
49%.calls:
50	@ { rfork ne; bind bootmkfile mkfile
51	KTZERO=$PXEBASE CONF=boot mk $target }
52
53#
54# pxe-loaded pxe loader
55#
569bootmain 9bootmaindebug:V:
57	cp boot bootmain
58	@ { rfork ne; bind bootmkfile mkfile
59	KTZERO=$BOOTBASE CONF=bootmain NPROC=$ONPROC
60	mk all }
61
62# creating $O.expand also creates $O.expanddebug, out of mk's sight
639boot:D: $O.expand 9bootmaindebug
64	cp 9bootmaindebug 9bootdebug		# for 9boot.install
65	{ cat $O.expand; strip -o /fd/1 9bootmaindebug | gzip -9 } >$target
66
67# creating 9boot also creates 9bootdebug, out of mk's sight
689boot.install:V: 9boot
69	cp 9boot 9bootdebug /$objtype/ &
70	for(i in $EXTRACOPIES)
71		{ 9fs $i && cp $prereq /n/$i/$objtype && echo -n $i... & }
72	wait
73	echo
74
75#
76# disk-resident pxe loader, loaded by pbs
77#
789bootpbs:V:
79	@ { rfork ne; bind bootmkfile mkfile
80	KTZERO=$PBSBASE CONF=bootpbs SFX=pbs
81	NPROC=$ONPROC START=l16r.$O; mk all }
82
839bootpbs.install:V: 9bootpbs
84	@ { rfork ne; bind bootmkfile mkfile
85	KTZERO=$PBSBASE CONF=bootpbs SFX=pbs
86	NPROC=$ONPROC START=l16r.$O; mk install }
87
88#
89# disk-resident disk loaders, loaded by pbs
90#
919load:V:
92	@ { rfork ne; bind bootmkfile mkfile
93	KTZERO=$PBSBASE BASE=load CONF=load
94	NPROC=$ONPROC START=l16r.$O; mk all }
95
969load.install:V: 9load
97	@ { rfork ne; bind bootmkfile mkfile
98	KTZERO=$PBSBASE BASE=load CONF=load
99	NPROC=$ONPROC START=l16r.$O; mk install }
100
1019loadusb:V:
102	@ { rfork ne; bind bootmkfile mkfile
103	KTZERO=$PBSBASE BASE=load CONF=loadusb
104	NPROC=$ONPROC START=l16r.$O; mk all }
105
1069loadusb.install:V: 9loadusb
107	@ { rfork ne; bind bootmkfile mkfile
108	KTZERO=$PBSBASE BASE=load CONF=loadusb
109	NPROC=$ONPROC START=l16r.$O; mk install }
110
111#
112# pxe-loaded disk loaders for convenient debugging only
113#
1149loadpxe:V:
115	@ { rfork ne; bind bootmkfile mkfile
116	KTZERO=$PXEBASE BASE=load CONF=loadpxe SFX=pxe
117	NPROC=$ONPROC START=l16r.$O; mk all }
118
1199loadpxe.install:V: 9loadpxe
120	@ { rfork ne; bind bootmkfile mkfile
121	KTZERO=$PXEBASE BASE=load CONF=loadpxe SFX=pxe
122	NPROC=$ONPROC START=l16r.$O; mk install }
123
1249loadusbpxe:V:
125	@ { rfork ne; bind bootmkfile mkfile
126	KTZERO=$PXEBASE BASE=load CONF=loadusbpxe SFX=pxe
127	NPROC=$ONPROC START=l16r.$O; mk all }
128
1299loadusbpxe.install:V: 9loadusbpxe
130	@ { rfork ne; bind bootmkfile mkfile
131	KTZERO=$PXEBASE BASE=load CONF=loadusbpxe SFX=pxe
132	NPROC=$ONPROC START=l16r.$O; mk install }
133
134#
135# 8.expand: the decompressing header for 9boot
136#
137# for pbs, 0x10000 (64K), for pxe, 0x7c00 (31K)
138LOADADDR=0x7c00
139
140cga.tiny.$O expand.$O: expand.h inflate.guts.c
141
142$O.expand: ldecomp.$O cga.tiny.$O expand.$O
143	$LD -o $target^debug -R1 -T$LOADADDR $prereq
144	$LD -o $target   -H3 -R1 -T$LOADADDR $prereq
145