forked from cbsd/cbsd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuniverse.subr
181 lines (154 loc) · 3.61 KB
/
universe.subr
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
init_distcc()
{
if [ "${distcc}" = "1" ]; then
readconf distcc.conf
if ! distcc_check; then
distcc=0
fi
else
distcc=0
fi
}
init_notify()
{
if [ "${notify}" = "1" ]; then
notify=1
else
notify=0
fi
}
# init SRC_DIR, origmakeconf, MAKEOBJDIRPREFIX, SRCCONF. After init_target_arch only
# require: $ver, $arch, $target_arch.
# optional: $basename
init_srcdir()
{
local _confname
SRC_DIR="${srcdir}/src_${ver}/src"
if [ -z "${basename}" ]; then
[ -f "${etcdir}/make.conf" ] && origmakeconf="${etcdir}/make.conf"
else
[ -f "${etcdir}/make-$basename.conf" ] && origmakeconf="${etcdir}/make-$basename.conf"
fi
if [ -z "${basename}" ]; then
export MAKEOBJDIRPREFIX=${srcdir}/obj_${arch}_${target_arch}_${ver}
else
export MAKEOBJDIRPREFIX=${srcdir}/obj_${basename}_${arch}_${target_arch}_${ver}
fi
if [ -z "${basename}" ]; then
_confname="src.conf"
else
_confname="src-${basename}.conf"
fi
if [ -f "${etcdir}/${_confname}" ]; then
SRCCONF="${etcdir}/${_confname}"
else
SRCCONF="${etcdir}/defaults/${_confname}"
fi
}
# init BASE_DIR. After init_target_arch only
# require: $arch, $target_arch, $ver
# optional: $basename, $destdir
# SKIP_CHECK_DIR=1 - do not exit if dir not exist, just init path variable
init_basedir()
{
if [ -n "${destdir}" ]; then
BASE_DIR="${destdir}"
return 0
fi
if [ -z "${basename}" ]; then
BASE_DIR="${basejaildir}/${basejailpref}_${arch}_${target_arch}_${ver}"
else
BASE_DIR="${basejaildir}/${basejailpref}_${basename}_${arch}_${target_arch}_${ver}"
fi
}
# init KERNEL_DIR
# require: $arch, $ver
# optional: $destdir, $name
init_kerneldir()
{
if [ -n "${destdir}" ]; then
KERNEL_DIR="${destdir}"
return 0
fi
[ -z "${name}" ] && name="GENERIC"
if [ -z "${basename}" ]; then
KERNEL_DIR="${basejaildir}/kernel_${name}_${arch}_${ver}"
else
KERNEL_DIR="${basejaildir}/kernel_${basename}_${name}_${arch}_${ver}"
fi
}
init_supported_arch()
{
support_arch=0
for i in $SUPPORTED_ARCH; do
[ "${arch}" = "${i}" ] && support_arch=1 && return 0
done
[ ${support_arch} -eq 0 ] && err 1 "${MAGENTA}Supported architecture only: ${GREEN}${SUPPORTED_ARCH}${NORMAL}"
}
# init EMULATOR, TARGET and TARGET_ARCH variable
# require: $arch, $target_arch
init_target_arch()
{
local _my_arch=`uname -m`
local _my_target_arch=`uname -p`
if [ "${_my_arch}" != "${arch}" ]; then
case "${arch}" in
"i386")
TARGET="i386"
TARGET_ARCH="i386"
;;
"amd64")
TARGET="amd64"
TARGET_ARCH="amd64"
;;
"arm")
TARGET="arm"
TARGET_ARCH="armv6"
BUILDPATH="arm-bsd-user"
EMULATOR="qemu-arm"
;;
"mips")
TARGET="mips"
TARGET_ARCH="mips64"
BUILDPATH="mips64-bsd-user"
EMULATOR="qemu-mips64"
;;
esac
fi
#overwrite target_arch if specify
if [ -n "${target_arch}" ]; then
TARGET_ARCH="${target_arch}"
else
if [ -n "${TARGET_ARCH}" ]; then
target_arch="${TARGET_ARCH}"
else
target_arch="${arch}" # default
fi
fi
}
# init SVN_REV
# require: $SRC_DIR
init_svn_and_version()
{
SVN_TOOLS=""
if [ -f "/usr/bin/svnlite" ]; then
SVN_TOOLS="/usr/bin/svnlite"
elif [ -f "/usr/local/bin/svn" ]; then
SVN_TOOLS="/usr/local/bin/svn"
fi
if [ -n "${SVN_TOOLS}" ]; then
SVN_REV=`cd ${SRC_DIR} && ${SVN_TOOLS} info |awk '/^Revision: /{printf $2}'`
else
SVN_REV=`date`
fi
}
# init NUMJOBS, NOCLEANUP
# require: $maxjobs, $clean
init_make_flags()
{
NUMJOBS=""
[ $maxjobs -ne 0 ] && NUMJOBS="-j${maxjobs}"
NOCLEANUP=""
[ ${clean} -ne 1 ] && NOCLEANUP="-DNO_CLEAN"
return 0
}