-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathMakefile
161 lines (126 loc) · 4.59 KB
/
Makefile
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
include config.mk
include rumptools/toolchain-conf.mk
BINDIR=bin
NBCFLAGS=${CFLAGS} -O2 -g -Wall
HOSTCFLAGS=${CFLAGS} -O2 -g -Wall -Ihostlib/include
NBUTILS+= bin/cat
NBUTILS+= bin/chmod
NBUTILS+= bin/cp
NBUTILS+= bin/dd
NBUTILS+= bin/df
NBUTILS+= bin/ed
NBUTILS+= bin/ln
NBUTILS+= bin/ls
NBUTILS+= bin/mkdir
NBUTILS+= bin/mv
NBUTILS+= bin/pax
NBUTILS+= bin/rm
NBUTILS+= bin/rmdir
NBUTILS+= sbin/cgdconfig
NBUTILS+= sbin/chown
NBUTILS+= sbin/disklabel
NBUTILS+= sbin/dump
NBUTILS+= sbin/fsck
NBUTILS+= sbin/fsck_ext2fs
NBUTILS+= sbin/fsck_ffs
NBUTILS+= sbin/fsck_msdos
NBUTILS+= sbin/ifconfig
NBUTILS+= sbin/mknod
NBUTILS+= sbin/modstat
NBUTILS+= sbin/mount
NBUTILS+= sbin/mount_ext2fs
NBUTILS+= sbin/mount_ffs
NBUTILS+= sbin/mount_msdos
NBUTILS+= sbin/mount_tmpfs
NBUTILS+= sbin/newfs
NBUTILS+= sbin/newfs_ext2fs
NBUTILS+= sbin/newfs_msdos
NBUTILS+= sbin/ping
NBUTILS+= sbin/ping6
NBUTILS+= sbin/raidctl
NBUTILS+= sbin/reboot
NBUTILS+= sbin/rndctl
NBUTILS+= sbin/route
NBUTILS+= sbin/sysctl
NBUTILS+= sbin/umount
NBUTILS+= usr.sbin/arp
NBUTILS+= usr.sbin/dumpfs
NBUTILS+= usr.sbin/ndp
NBUTILS+= usr.sbin/npf/npfctl
NBUTILS+= usr.sbin/pcictl
NBUTILS+= usr.sbin/rtadvd
NBUTILS+= usr.sbin/vnconfig
NBUTILS+= usr.sbin/wlanctl
#NBUTILS+= usr.bin/kdump
NBUTILS+= usr.bin/ktrace
NBUTILS+= usr.bin/mixerctl
NBUTILS+= external/bsd/wpa/bin/wpa_passphrase
NBUTILS+= external/bsd/wpa/bin/wpa_supplicant
ifeq (${BUILDZFS},true)
NBUTILS+= external/cddl/osnet/sbin/zfs
NBUTILS+= external/cddl/osnet/sbin/zpool
NBUTILS+= external/cddl/osnet/usr.bin/ztest
endif
CPPFLAGS.umount= -DSMALL
NBUTILS_BASE= $(notdir ${NBUTILS})
NBCC=./rump/bin/rump-cc
all: ${NBUTILS_BASE} bin/halt rumpctrl.sh
rumpctrl.sh: rumpctrl.sh.in
sed 's,XXXPATHXXX,$(PWD),' $< > $@
emul.o: emul.c
${CC} ${HOSTCFLAGS} -c $< -o $@
rumpclient.o: rumpclient.c
${CC} ${HOSTCFLAGS} -c $< -o $@
readwrite.o: readwrite.c
${CC} ${HOSTCFLAGS} -c $< -o $@
remoteinit.o: remoteinit.c
${CC} ${HOSTCFLAGS} -c $< -o $@
netbsd_init.o: netbsd_init.c ${NBCC}
${NBCC} ${NBCFLAGS} -c $< -o $@
halt.o: halt.c ${NBCC}
${NBCC} ${NBCFLAGS} -c $< -o $@
MAPS=rump.map namespace.map host.map netbsd.map readwrite.map emul.map weakasm.map
${BINDIR}/halt: halt.o emul.o rumpclient.o readwrite.o remoteinit.o ${MAPS}
${NBCC} ${NBCFLAGS} -o ${BINDIR}/halt halt.o
rump.map: ${RUMPSRC}/sys/rump/rump.sysmap
awk '{printf("%s\t%s\n",$$3,$$4)}' $< > $@
namespace.map: ${RUMPSRC}/lib/libc/include/namespace.h rump.map emul.map
grep '#define' $< | grep -v NAMESPACE_H | awk '{printf("%s\t%s\n",$$2,$$3)}' > fns.map
cat rump.map emul.map > all.map
awk 'NR==FNR{a[$$1]=$$1;next}a[$$1]' all.map fns.map | awk '{printf("%s\t%s\n",$$2,$$1)}' > $@
weakasm.map: ${RUMPSRC}/lib/libc/sys/Makefile.inc ${RUMPMAKE}
${RUMPMAKE} -f $< RUMPRUN=no -V '$${WEAKASM}' | xargs -n 1 echo | awk '{sub("\\..*", ""); printf("_sys_%s _%s\n", $$1, $$1);}' > $@
define NBUTIL_templ
rumpobj/${1}/${2}.ro:
( cd ${RUMPSRC}/${1} && ${RUMPMAKE} obj && \
${RUMPMAKE} LDFLAGS=-Wl,-r LIBCRT0= BUILDRUMP_CFLAGS="-fPIC -std=gnu99 -D__NetBSD__ ${CPPFLAGS.${2}}" ${2}.ro )
NBLIBS.${2}:= $(shell cd ${RUMPSRC}/${1} && ${RUMPMAKE} -V '$${LDADD}' | sed 's/-L\S*//g')
LIBS.${2}=$${NBLIBS.${2}:-l%=rump/lib/lib%.a}
${BINDIR}/${2}: rumpobj/${1}/${2}.ro emul.o rumpclient.o readwrite.o remoteinit.o netbsd_init.o ${MAPS} $${LIBS.${2}}
${NBCC} ${NBCFLAGS} -o ${BINDIR}/${2} rumpobj/${1}/${2}.ro $${LIBS.${2}}
${2}: ${BINDIR}/${2}
clean_${2}:
( [ ! -d ${RUMPSRC}/${1} ] || ( cd ${RUMPSRC}/${1} && ${RUMPMAKE} cleandir && rm -f ${2}.ro ) )
endef
$(foreach util,${NBUTILS},$(eval $(call NBUTIL_templ,${util},$(notdir ${util}))))
INSTALL_PATH=${PWD}
${NBCC}: cc.in rump/lib/rump-cc.specs rump/lib/ld.rump
sed -e "s|@PATH@|${INSTALL_PATH}|g" \
-e "s|@BUILDRUMP_TOOL_CPPFLAGS@|${BUILDRUMP_TOOL_CPPFLAGS}|g" \
-e "s|@BUILDRUMP_TOOL_CFLAGS@|${BUILDRUMP_TOOL_CFLAGS}|g" $< > $@
chmod +x $@
rump/lib/ld.rump: ld.in
sed "s|@PATH@|${INSTALL_PATH}|g" $< > $@
chmod +x $@
rump/lib/rump-cc.specs: specs.in
sed -e "s|@BUILDRUMP_TOOL_CPPFLAGS@|${BUILDRUMP_TOOL_CPPFLAGS}|g" \
-e "s|@BUILDRUMP_TOOL_CFLAGS@|${BUILDRUMP_TOOL_CFLAGS}|g" \
-e "s|@PATH@|${INSTALL_PATH}|g" $< > $@
clean: $(foreach util,${NBUTILS_BASE},clean_${util})
rm -f *.o *~ rump.map namespace.map fns.map all.map weakasm.map ${PROGS} ${BINDIR}/* rumpctrl.sh
rm -f test_disk-* test_busmem* disk1-* disk2-* csock-* csock1-* csock2-* raid.conf-*
rm -f ${NBCC} rump/lib/rump-cc.specs
cleanrump: clean
rm -rf rump rumpobj rumptools hostlib hosttools hostobj
rm -f config.mk config.sh
distcleanrump: clean cleanrump