-
Notifications
You must be signed in to change notification settings - Fork 2
/
510-nss.sh
328 lines (291 loc) · 9.97 KB
/
510-nss.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
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# Build script for nss
do_cross_me_harder_nss_get() {
CT_GetFile "nss-${CT_NSS_VERSION}" .tar.gz \
"https://ftp.mozilla.org/pub/mozilla.org/security/nss/releases/NSS_${CT_NSS_VERSION//\./_}_RTM/src"
}
do_cross_me_harder_nss_extract() {
CT_Extract "nss-${CT_NSS_VERSION}"
CT_Patch "nss" "${CT_NSS_VERSION}"
}
do_cross_me_harder_nss_build() {
local -a host_extra_config
local -a target_extra_config
local ssldir
CT_DoStep EXTRA "Installing host shlibsign"
rm -rf "${CT_BUILD_DIR}/build-nss"
cp -a "${CT_SRC_DIR}/nss-${CT_NSS_VERSION}" "${CT_BUILD_DIR}/build-nss"
CT_Pushd "${CT_BUILD_DIR}/build-nss/mozilla"
case "$CT_BUILD" in
x86_64-* )
host_extra_config+=( "USE_64=1" )
;;
esac
CT_DoLog DEBUG "Extra config passed: '${host_extra_config[*]}'"
CT_Pushd "security/coreconf"
if [ `uname -r | cut -d. -f1` = 3 ]; then
cp Linux2.6.mk Linux`uname -r | cut -d. -f1-2`.mk
fi
CT_DoExecLog ALL \
CPPFLAGS="-I${CT_PREFIX_DIR}/include" \
LDFLAGS="-L${CT_PREFIX_DIR}/lib -Wl,-rpath=${CT_PREFIX_DIR}/lib" \
make \
CC="${CT_HOST}-gcc" \
BUILD_OPT=1 \
"${host_extra_config[@]}"
mkdir -p "${CT_PREFIX_DIR}/bin" "${CT_PREFIX_DIR}/lib"
CT_DoExecLog ALL \
cp -L nsinstall/Linux*/nsinstall "${CT_PREFIX_DIR}/bin"
CT_Popd
CT_Pushd "security/dbm"
CT_DoExecLog ALL \
CPPFLAGS="-I${CT_PREFIX_DIR}/include" \
LDFLAGS="-L${CT_PREFIX_DIR}/lib -Wl,-rpath=${CT_PREFIX_DIR}/lib" \
make \
NSPR_INCLUDE_DIR="${CT_PREFIX_DIR}/include/nspr" \
NSPR_LIB_DIR="${CT_PREFIX_DIR}/lib" \
NSINSTALL="${CT_PREFIX_DIR}/bin/nsinstall" \
CC="${CT_HOST}-gcc" \
BUILD_OPT=1 \
"${host_extra_config[@]}"
CT_Popd
ssldir=$(dirname $(find `pwd`/dist -name libdbm.a))
CT_Pushd "security/nss"
CT_DoExecLog ALL \
CPPFLAGS="-I${CT_PREFIX_DIR}/include" \
LDFLAGS="-L${CT_PREFIX_DIR}/lib -Wl,-rpath=${CT_PREFIX_DIR}/lib" \
LD_LIBRARY_PATH="${ssldir}:${CT_PREFIX_DIR}/lib" \
make \
NSPR_INCLUDE_DIR="${CT_PREFIX_DIR}/include/nspr" \
NSPR_LIB_DIR="${CT_PREFIX_DIR}/lib" \
NSINSTALL="${CT_PREFIX_DIR}/bin/nsinstall" \
CC="${CT_HOST}-gcc" \
BUILD_OPT=1 \
USE_SYSTEM_ZLIB=1 \
"${host_extra_config[@]}"
CT_DoExecLog ALL \
cp -p $(find cmd/shlibsign -name shlibsign -type f) "${CT_PREFIX_DIR}/bin"
CT_Popd
CT_DoExecLog ALL \
cp -L $(find dist -name '*.so' -type l) "${CT_PREFIX_DIR}/lib"
CT_Popd
CT_EndStep
CT_DoStep EXTRA "Installing target nss"
rm -rf "${CT_BUILD_DIR}/build-nss-target"
cp -a "${CT_SRC_DIR}/nss-${CT_NSS_VERSION}" "${CT_BUILD_DIR}/build-nss-target"
CT_Pushd "${CT_BUILD_DIR}/build-nss-target/mozilla"
case "${CT_ARCH}:${CT_ARCH_BITNESS}" in
x86:32) target_extra_config="OS_TEST=i686";;
*) target_extra_config="OS_TEST=${CT_ARCH}";;
esac
CT_DoLog DEBUG "Extra config passed: '${target_extra_config[*]}'"
CT_Pushd "security/dbm"
CT_DoExecLog ALL \
PKG_CONFIG="${CT_TARGET}-pkg-config --define-variable=prefix=${CT_SYSROOT_DIR}/usr" \
make \
NSPR_INCLUDE_DIR="${CT_SYSROOT_DIR}/usr/include/nspr" \
NSPR_LIB_DIR="${CT_SYSROOT_DIR}/usr/lib" \
NSINSTALL="${CT_PREFIX_DIR}/bin/nsinstall" \
HOST_CC="${CT_HOST}-gcc" \
CC="${CT_TARGET}-gcc" \
CCC="${CT_TARGET}-g++" \
RANLIB="${CT_TARGET}-ranlib" \
G++INCLUDES= \
BUILD_OPT=1 \
ALLOW_OPT_CODE_SIZE=1 \
OPT_CODE_SIZE=1 \
MOZ_DEBUG_SYMBOLS=1 \
CROSS_COMPILE=1 \
OS_ARCH=Linux \
OS_RELEASE=2.6 \
OS_TARGET=Linux \
"${target_extra_config[@]}"
CT_Popd
CT_Pushd "security/nss"
CT_DoExecLog ALL \
SHLIBSIGN="${CT_PREFIX_DIR}/bin/shlibsign" \
PKG_CONFIG="${CT_TARGET}-pkg-config --define-variable=prefix=${CT_SYSROOT_DIR}/usr" \
make \
USE_SYSTEM_ZLIB=1 \
NSS_USE_SYSTEM_SQLITE=1 \
NSPR_INCLUDE_DIR="${CT_SYSROOT_DIR}/usr/include/nspr" \
NSPR_LIB_DIR="${CT_SYSROOT_DIR}/usr/lib" \
NSINSTALL="${CT_PREFIX_DIR}/bin/nsinstall" \
HOST_CC="${CT_HOST}-gcc" \
CC="${CT_TARGET}-gcc" \
CCC="${CT_TARGET}-g++" \
RANLIB="${CT_TARGET}-ranlib" \
G++INCLUDES= \
BUILD_OPT=1 \
ALLOW_OPT_CODE_SIZE=1 \
OPT_CODE_SIZE=1 \
MOZ_DEBUG_SYMBOLS=1 \
CROSS_COMPILE=1 \
OS_ARCH=Linux \
OS_RELEASE=2.6 \
OS_TARGET=Linux \
"${target_extra_config[@]}"
CT_Popd
CT_DoExecLog ALL \
rm -rf "${CT_SYSROOT_DIR}/usr/include/dbm" "${CT_SYSROOT_DIR}/usr/include/nss"
CT_DoExecLog ALL \
cp -rL dist/public/dbm dist/public/nss "${CT_SYSROOT_DIR}/usr/include"
CT_DoExecLog ALL \
cp -L $(find dist -name '*.so' -type l) "${CT_SYSROOT_DIR}/usr/lib"
CT_DoExecLog ALL \
cp -L $(find dist -name '*.chk' -type l) "${CT_SYSROOT_DIR}/usr/lib"
CT_DoExecLog ALL \
cp -L $(find dist -name 'libcrmf.a' -type l) "${CT_SYSROOT_DIR}/usr/lib"
CT_Popd
cat > "${CT_SYSROOT_DIR}"/usr/lib/pkgconfig/nss.pc <<EOF
prefix=/usr
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include/nss
Name: NSS
Description: Network Security Services
Version: ${CT_NSS_VERSION}
Requires: nspr >= 4.8
Libs: -L\${libdir} -lssl3 -lsmime3 -lnss3 -lnssutil3
Cflags: -I\${includedir}
EOF
cat > "${CT_SYSROOT_DIR}"/usr/bin/nss-config <<'CT_EOF'
#!/bin/sh
prefix=/usr
major_version=3
minor_version=12
patch_version=10
usage()
{
cat <<EOF
Usage: nss-config [OPTIONS] [LIBRARIES]
Options:
[--prefix[=DIR]]
[--exec-prefix[=DIR]]
[--includedir[=DIR]]
[--libdir[=DIR]]
[--version]
[--libs]
[--cflags]
Libraries:
smime
ssl
nss
nssutil
EOF
exit $1
}
if test $# -eq 0; then
usage 1 1>&2
fi
lib_smime=yes
lib_ssl=yes
lib_nss=yes
lib_nssutil=yes
while test $# -gt 0; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case $1 in
--prefix=*)
prefix=$optarg
;;
--prefix)
echo_prefix=yes
;;
--exec-prefix=*)
exec_prefix=$optarg
;;
--exec-prefix)
echo_exec_prefix=yes
;;
--includedir=*)
includedir=$optarg
;;
--includedir)
echo_includedir=yes
;;
--libdir=*)
libdir=$optarg
;;
--libdir)
echo_libdir=yes
;;
--version)
echo ${major_version}.${minor_version}.${patch_version}
;;
--cflags)
echo_cflags=yes
;;
--libs)
echo_libs=yes
;;
smime)
lib_smime=yes
;;
ssl)
lib_ssl=yes
;;
nss)
lib_nss=yes
;;
nssutil)
lib_nssutil=yes
;;
*)
usage 1 1>&2
;;
esac
shift
done
# Set variables that may be dependent upon other variables
if test -z "$exec_prefix"; then
exec_prefix=${prefix}
fi
if test -z "$includedir"; then
includedir=${prefix}/include/nss
fi
if test -z "$libdir"; then
libdir=${exec_prefix}/lib
fi
if test "$echo_prefix" = "yes"; then
echo $prefix
fi
if test "$echo_exec_prefix" = "yes"; then
echo $exec_prefix
fi
if test "$echo_includedir" = "yes"; then
echo $includedir
fi
if test "$echo_libdir" = "yes"; then
echo $libdir
fi
if test "$echo_cflags" = "yes"; then
echo -I$includedir
fi
if test "$echo_libs" = "yes"; then
libdirs=-L$libdir
if test -n "$lib_smime"; then
libdirs="$libdirs -lsmime${major_version}"
fi
if test -n "$lib_ssl"; then
libdirs="$libdirs -lssl${major_version}"
fi
if test -n "$lib_nss"; then
libdirs="$libdirs -lnss${major_version}"
fi
if test -n "$lib_nssutil"; then
libdirs="$libdirs -lnssutil${major_version}"
fi
os_ldflags=""
for i in $os_ldflags ; do
if echo $i | grep \^-L >/dev/null; then
libdirs="$libdirs $i"
fi
done
echo $libdirs
fi
CT_EOF
chmod 755 "${CT_SYSROOT_DIR}"/usr/bin/nss-config
CT_EndStep
}