-
Notifications
You must be signed in to change notification settings - Fork 16
/
buildnb.sh
executable file
·166 lines (143 loc) · 3.73 KB
/
buildnb.sh
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
#!/bin/sh
appendconfig ()
{
echo $1=\"$(eval echo \${$1})\" >> ./config.sh
echo $1=$(eval echo \${$1}) >> ./config.mk
}
STDJ='-j4'
EXTRAFLAGS="${STDJ}"
TESTS=false
BUILDZFS=false
RUMPSRC=src-netbsd
# figure out where gmake lies
if [ -z "${MAKE}" ]; then
MAKE=make
! type gmake >/dev/null 2>&1 || MAKE=gmake
fi
type ${MAKE} >/dev/null 2>&1 || die '"make" required but not found'
# XXX TODO set FLAGS from -F options here to pass to buildrump.sh
while getopts '?Hqs:' opt; do
case "$opt" in
"H")
EXTRAFLAGS="${EXTRAFLAGS} -H"
;;
"q")
BUILD_QUIET=${BUILD_QUIET:=-}q
;;
"s")
RUMPSRC=${OPTARG}
;;
"?")
exit 1
esac
done
shift $((${OPTIND} - 1))
for arg in "$@"; do
case ${arg} in
"tests")
TESTS=true
;;
"clean")
${MAKE} distcleanrump
exit 0
;;
"zfs")
echo '>> zfs build not supported' 2>&1
exit 1
;;
*)
RUMPLOC=${arg}
;;
esac
done
${MAKE} --version | grep -q 'GNU Make' \
|| die GNU Make required, '$MAKE' "(${MAKE})" is not
set -e
# Check sources
if git submodule status ${RUMPSRC} 2>/dev/null | grep -q '^-' \
|| git submodule status buildrump.sh 2>/dev/null | grep -q '^-'
then
echo '>>'
echo '>> submodules missing. run "git submodule update --init"'
echo '>>'
exit 1
fi
if git submodule status ${RUMPSRC} 2>/dev/null | grep -q '^+' \
|| git submodule status buildrump.sh 2>/dev/null | grep -q '^+'
then
echo '>>'
echo '>> Your git submodules are out-of-date'
echo '>> Forgot to run "git submodule update" after pull?'
echo '>> (sleeping for 5s, press ctrl-C to abort)'
echo '>>'
echo -n '>>'
for x in 1 2 3 4 5; do echo -n ' !' ; sleep 1 ; done
fi
. ./buildrump.sh/subr.sh
rm -f ./config.mk ./config.sh
${BUILDZFS} && \
ZFSLIBS="$(ls -d ${RUMPSRC}/external/cddl/osnet/lib/lib* | grep -v libdtrace)"
OPENSSLLIBS="${RUMPSRC}/crypto/external/bsd/openssl/lib/libcrypto
${RUMPSRC}/crypto/external/bsd/openssl/lib/libdes
${RUMPSRC}/crypto/external/bsd/openssl/lib/libssl"
LIBS="$(stdlibs ${RUMPSRC}) ${ZFSLIBS} ${OPENSSLLIBS}"
appendconfig BUILDZFS
appendconfig RUMPSRC
#
# We build tools twice: once to create a host version of librumpclient
# and another time to build all of the other libs. Technically,
# the difference is just a bit of mk.conf, but it's a lot easier to
# build twice than start poking in the general mk.conf file.
#
# host lib tools (for building librumpclient)
./buildrump.sh/buildrump.sh ${BUILD_QUIET} ${EXTRAFLAGS} ${FLAGS} \
-s ${RUMPSRC} -T hosttools -o hostobj -d hostlib -V MKSTATICLIB=no \
tools
# tools and headers for clientside libs
./buildrump.sh/buildrump.sh ${BUILD_QUIET} ${EXTRAFLAGS} ${FLAGS} -s ${RUMPSRC} \
-T rumptools -o rumpobj -F CFLAGS="-nostdinc -isystem ${PWD}/rump/include" \
-k -V MKPIC=no -V BUILDRUMP_SYSROOT=yes \
tools kernelheaders install
#
# Build host bits. There's no real infra for this, so it's mostly
# a matter of running rumpmake in the right places with the right args.
#
RUMPMAKE=$(pwd)/hosttools/rumpmake
mkdir -p hostlib/include/rump
mkdir -p hostlib/lib
(
# librumpclient dependency
cd ${RUMPSRC}/lib/librumpuser
${RUMPMAKE} includes
)
(
# librumpclient dependency
cd ${RUMPSRC}/sys/rump/include
${RUMPMAKE} includes
)
(
cd ${RUMPSRC}/lib/librumpclient
${RUMPMAKE} includes \
&& ${RUMPMAKE} MKMAN=no dependall \
&& ${RUMPMAKE} MKMAN=no install
)
# set rumpmake
RUMPMAKE=$(pwd)/rumptools/rumpmake
appendconfig RUMPMAKE
usermtree rump
userincludes ${RUMPSRC} ${LIBS}
( cd ${RUMPSRC}/lib/librumpclient && ${RUMPMAKE} includes )
for lib in ${LIBS}; do
[ "${lib%libpthread}" = "${lib}" ] || continue
makeuserlib ${lib}
done
mkdir -p bin
${MAKE}
if ${TESTS}; then
[ -n "${RUMPLOC}" ] || die need rump kernel for tests
export PATH=${RUMPLOC}/bin:${PATH}
tests/test.sh
fi
echo
echo ">> $0 ran successfully"
exit 0