-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkfile.todo
313 lines (238 loc) · 6.43 KB
/
mkfile.todo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
release:V:
mk nuke
rm -f /$objtype/lib/ape/*.a
rm -f /$objtype/lib/*.a
mk install
mk clean
--------------------------------------------
# safer to clean all the libs and binaries, you never know, you could
# get some no-up-to-date libs or binaries there
clean:V:
rm -f 386/bin/*
rm -f 386/lib/*
#once mk all and mk install works in ape/
# rm -f 386/lib/ape/*
----------------------------------------------
</$objtype/mkfile
TARG=`{ls *.[cy] | sed '/\.tab\.c$/d;s/..$//'}
HFILES=/$objtype/include/u.h /sys/include/libc.h /sys/include/bio.h
BIN=/$objtype/bin
PROGS=${TARG:%=$O.%}
YFLAGS=-d
cpuobjtype=`{sed -n 's/^O=//p' /$cputype/mkfile}
#NOMK=awk|faces
#DIRS=`{ls -l | sed '/^d/!d; s/.* //; /^('$NOMK')$/d'}
TOP=../../..
none:VQ:
echo usage: mk cmds, dirs, all, install, installall, '$O'.cmd, cmd.install, or cmd.installall
cmds:V: $PROGS
dirs:V:
for(i in $DIRS) @{
cd $i
echo DIR: cmd/$i
mk $MKFLAGS all
}
all:V: $PROGS dirs
#PAD: put $LDFLAGS and have weird behavior => I've removed it
^([$OS])\.(.*):R: \2.\1
$stem1^l -o $target $stem2.$stem1
.*\.[$OS]:R: $HFILES
(.*)\.([$OS])'$':R: \1.c
$stem2^c $CFLAGS $stem1.c
&:n: $O.&
mv $O.$stem $stem
%.tab.h %.tab.c: %.y
$YACC $YFLAGS -s $stem $prereq
%.install:V: $BIN/%
$cpuobjtype._cp: /bin/cp
cp $prereq $target
%.safeinstall: $O.% $cpuobjtype._cp
test -e $BIN/$stem && mv $BIN/$stem $BIN/_$stem
$cpuobjtype._cp $O.$stem $BIN/$stem
%.safeinstallall:
for(objtype in $CPUS)
mk $stem.safeinstall
mk $stem.clean
$BIN/%: $O.% $cpuobjtype._cp
$cpuobjtype._cp $O.$stem $BIN/$stem
%.directories:V:
for(i in $DIRS) @{
cd $i
echo mk $i
mk $MKFLAGS $stem
}
clean:V: cleanfiles clean.directories
nuke:V: cleanfiles nuke.directories
directories:V: install.directories
cleanfiles:V:
rm -f [$OS].out *.[$OS] y.tab.? y.debug y.output [$OS].$TARG [$OS].units.tab $TARG bc.c bc.tab.h units.tab.h units.c [$OS]._cp
%.clean:V:
rm -f [$OS].$stem $stem.[$OS]
install:V:
test -e $cpuobjtype._cp || cp /bin/cp $cpuobjtype._cp
mk $MKFLAGS $TARG.install
mk $MKFLAGS directories
installall:V:
for(objtype in $CPUS)
mk $MKFLAGS install
%.installall: %.c
test -e $cpuobjtype._cp || cp /bin/cp $cpuobjtype._cp
for (objtype in $CPUS) {
rfork e
mk $stem.install &
}
wait
rm -f $stem.[$OS] y.tab.? $stem.tab.? y.debug y.output [$OS].$stem bc.c bc.tab.h units.c
%.acid: %.$O $HFILES
$CC $CFLAGS -a $stem.c >$target
$BIN/init: $O.init
cp $prereq /$objtype/init
%.update:V:
update $stem.c /386/bin/$stem
compilers:V:
for(i in ?c)
if(! ~ $i cc rc) @{
cd $i
mk clean
objtype=$cputype mk install
mk clean
}
for(i in ?c)
if(! ~ $i cc rc) @{
cd $i
mk clean
mk installall
mk clean
}
----------------------------------------------------------------
</$objtype/mkfile
#TODO: consolefs? depend? mouse? reboot? searchfs? statusbar
#LESS: mklatinkbd
TARG=\
data2s\
mouse\
# reboot\
BIN=/$objtype/bin/aux
UPDATE=\
mkfile\
$HFILES\
${OFILES:%.$O=%.c}\
${TARG:%=%.c}\
</sys/src/cmd/mkmany
DIRS=vga\
all:V: $DIRS
$DIRS:V:
for (i in $DIRS) @{
echo DIR: cmd/aux/$i
cd $i
mk all
}
install:V: installdirs
nuke:V: nukedirs
installdirs:V:
for (i in $DIRS) @{
echo mk $i
cd $i
mk install
}
clean:V:
for (i in $DIRS) @{
echo clean $i
cd $i
mk clean
}
rm -f [$OS].* *.[$OS]
nukedirs:V:
for (i in $DIRS) @{
echo nuke $i
cd $i
mk nuke
}
update:V:
update $UPDATEFLAGS $UPDATE
for (i in $DIRS) @{
echo update $i
cd $i
mk 'UPDATEFLAGS='$"UPDATEFLAGS update
}
------------------------------------------------------------------------
trace:
mk clean
mk libs > make_trace.txt
mk kernels >> make_trace.txt
mk cmds >> make_trace.txt
# when files are moved by xmv, need to rerun that
# need to have run 'mk' in 9/pc before cos need autogenerated files
compile_commands:
~/pfff/pfff_test -analyze_make_trace make_trace.txt > compile_commands.json
clangfiles:
# ~/pfff/pfff -gen_clang compile_commands.json
# ~/pfff/pfff_test.opt -uninclude_clang
-----------------------------------------------------------------------
all:
make compile && make disk && make run
compile:
mkdir -p ROOT/386/bin/ape/
cp ROOT/386/bin/rc ROOT/386/bin/ape/sh
disk:
run:
qemu-system-i386 -smp 4 -m 512 \
-kernel sys/src/9/pc/9$(CONFIG) \
-hda dosdisk.img \
# -net nic,model=ne2k_pci -net user
#-fda ~/floppy.img
#-hda ~/plan9.raw.img
#-cdrom plan9.iso? does not work?
#-vga cirrus
clean:
cd sys/src; mk clean
cd sys/src/9/pc; mk clean
cd ROOT; mk clean
clean_pfff:
mv PFFF_* *.marshall *.opti layer* pfff.log .pfff/
##############################################################################
# Developer rules
##############################################################################
# codemap.opt has some issue with light db and graph db loading :(
#-symlinks
visual:
~/pfff/codemap.opt -screen_size 2 -no_legend -filter xix .
graph:
~/pfff/codegraph -derived_data -lang c -build .
tags:
~/pfff/codegraph -derived_data -lang c -build .
check:
~/pfff/scheck -filter 3 -lang c .
loc:
~/pfff/codemap.opt -screen_size 2 -no_legend -filter xix -test_loc .
#todo? add libc, lib_networking, lib_memlayer/lib_memdraw/lib_draw, libmp?
KERNELSRC=include/ kernel/ lib_core/libc/9syscall lib_graphics/
# just kernel, but with new graph_code_c!
graph_kernel:
~/pfff/codegraph -derived_data -lang c -build $(KERNELSRC)
graph_kernel2:
~/pfff/codegraph -derived_data -lang c -build include/ kernel/ lib_core/libc/9syscall
prolog_kernel:
~/pfff/codequery -lang c -build $(KERNELSRC)
datalog_kernel:
~/pfff/codequery -datalog -lang c -build $(KERNELSRC)
loc_kernel:
~/pfff/codemap -filter cpp -test_loc kernel
WINDOWSRC=include/ lib_graphics/ windows/ kernel/devices/screen/
graph_windows:
~/pfff/codegraph -derived_data -lang c -build $(WINDOWSRC)
graph_windows2:
~/pfff/codegraph -derived_data -lang c -build include/ lib_graphics/ windows/
# you need also to adjust skip list sometimes!
ASSEMBLERSRC=include assemblers/aa/ assemblers/5a
##############################################################################
# Literate Programming rules
##############################################################################
visual2:
~/pfff/codemap.opt -no_legend -symlinks -filter nw -ft 1.0 .
# cp sys/src/9/pc/apbootstrap.h kernel/init/386/
# cp sys/src/9/pc/init.h kernel/init/user/preboot
# cp sys/src/9/pc/reboot.h kernel/init/386
# cp sys/src/9/pc/$(CONFIG).c kernel/conf
# cp sys/src/9/pc/$(CONFIG).rootc.c kernel/conf
# mv sys/src/9/pc/*.clang2 kernel/conf