-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkfile
61 lines (41 loc) · 1.15 KB
/
mkfile
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
</$objtype/mkfile
HFILES=`{test -d src && walk -f src | grep '\.h$'}
CFILES=`{test -d src && walk -f src | grep '\.c$'}
CMAIN=`{grep -l '^(thread)?main\(' $CFILES /dev/null}
CCOM=`{grep -L '^(thread)?main\(' $CFILES /dev/null | sed '/^\/dev\/null/d'}
OCOM=${CCOM:src/%.c=obj/$objtype/%.o}
BINTARG=${CMAIN:src/%.c=bin/$objtype/%}
RCFILES=`{test -d rc && walk -f rc}
MANFILES=`{test -d man && walk -n 2,2 -f man}
BIN=/$objtype/bin
RC=/rc/bin
MAN=/sys/man
DIRS=bin obj bin/$objtype obj/$objtype
BININST=${BINTARG:bin/$objtype/%=$BIN/%}
RCINST=${RCFILES:rc/%=$RC/%}
MANINST=${MANFILES:man/%=$MAN/%}
INST=$BININST $RCINST $MANINST
none:V: all
$DIRS:
mkdir -p $target
obj/$objtype/%.o: obj/$objtype $HFILES
obj/$objtype/%.o: src/%.c
$CC $CFLAGS -o $target src/$stem.c
bin/$objtype/%: bin/$objtype obj/$objtype/%.o $OCOM
$LD $LDFLAGS -o $target obj/$objtype/$stem.o $OCOM
$BIN/%: bin/$objtype/%
cp $prereq $target
$RC/%: rc/%
cp -x $prereq $target
/sys/man/%: man/%
cp $prereq $target
man:V: $MANINST
%.cpus:V:
for(objtype in $CPUS) mk $MKFLAGS $stem
all:V: $BINTARG
install:V: $INST
installall:V: install.cpus
uninstall:V:
rm -f $INST
clean:V:
rm -rf bin obj