blob: 001124011ec2c73ff3b9b9647e36439e0425016f [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001SUMMARY = "Mozilla's SSL and TLS implementation"
2DESCRIPTION = "Network Security Services (NSS) is a set of libraries \
3designed to support cross-platform development of \
4security-enabled client and server applications. \
5Applications built with NSS can support SSL v2 and v3, \
6TLS, PKCS 5, PKCS 7, PKCS 11, PKCS 12, S/MIME, X.509 \
7v3 certificates, and other security standards."
8HOMEPAGE = "http://www.mozilla.org/projects/security/pki/nss/"
9SECTION = "libs"
10
11DEPENDS = "sqlite3 nspr zlib nss-native"
12DEPENDS_class-native = "sqlite3-native nspr-native zlib-native"
13
14LICENSE = "MPL-2.0 | (MPL-2.0 & GPL-2.0+) | (MPL-2.0 & LGPL-2.1+)"
15
16LIC_FILES_CHKSUM = "file://nss/COPYING;md5=3b1e88e1b9c0b5a4b2881d46cce06a18 \
17 file://nss/lib/freebl/mpi/doc/LICENSE;md5=491f158d09d948466afce85d6f1fe18f \
18 file://nss/lib/freebl/mpi/doc/LICENSE-MPL;md5=5d425c8f3157dbf212db2ec53d9e5132"
19
20VERSION_DIR = "${@d.getVar('BP').upper().replace('-', '_').replace('.', '_') + '_RTM'}"
21
22SRC_URI = "http://ftp.mozilla.org/pub/mozilla.org/security/nss/releases/${VERSION_DIR}/src/${BP}.tar.gz \
23 file://nss.pc.in \
24 file://signlibs.sh \
25 file://0001-nss-fix-support-cross-compiling.patch \
26 file://nss-no-rpath-for-cross-compiling.patch \
27 file://nss-fix-incorrect-shebang-of-perl.patch \
28 file://disable-Wvarargs-with-clang.patch \
29 file://pqg.c-ULL_addend.patch \
30 file://blank-cert9.db \
31 file://blank-key4.db \
32 file://system-pkcs11.txt \
33 file://nss-fix-nsinstall-build.patch \
34 file://0001-freebl-add-a-configure-option-to-disable-ARM-HW-cryp.patch \
35 file://riscv.patch \
36 "
37
38SRC_URI[md5sum] = "6acaf1ddff69306ae30a908881c6f233"
39SRC_URI[sha256sum] = "085c5eaceef040eddea639e2e068e70f0e368f840327a678ef74ae3d6c15ca78"
40
41UPSTREAM_CHECK_URI = "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/NSS_Releases"
42UPSTREAM_CHECK_REGEX = "NSS_(?P<pver>.+)_release_notes"
43
44inherit siteinfo
45
46TD = "${S}/tentative-dist"
47TDS = "${S}/tentative-dist-staging"
48
49TARGET_CC_ARCH += "${LDFLAGS}"
50
51do_configure_prepend_libc-musl () {
52 sed -i -e '/-DHAVE_SYS_CDEFS_H/d' ${S}/nss/lib/dbm/config/config.mk
53}
54
55do_compile_prepend_class-native() {
56 export NSPR_INCLUDE_DIR=${STAGING_INCDIR_NATIVE}/nspr
57 export NSPR_LIB_DIR=${STAGING_LIBDIR_NATIVE}
58 export NSS_ENABLE_WERROR=0
59}
60
61do_compile_prepend_class-nativesdk() {
62 export LDFLAGS=""
63}
64
65do_compile_prepend_class-native() {
66 # Need to set RPATH so that chrpath will do its job correctly
67 RPATH="-Wl,-rpath-link,${STAGING_LIBDIR_NATIVE} -Wl,-rpath-link,${STAGING_BASE_LIBDIR_NATIVE} -Wl,-rpath,${STAGING_LIBDIR_NATIVE} -Wl,-rpath,${STAGING_BASE_LIBDIR_NATIVE}"
68}
69
70do_compile() {
71 export NSPR_INCLUDE_DIR=${STAGING_INCDIR}/nspr
72
73 export CROSS_COMPILE=1
74 export NATIVE_CC="${BUILD_CC}"
75 # Additional defines needed on Centos 7
76 export NATIVE_FLAGS="${BUILD_CFLAGS} -DLINUX -Dlinux"
77 export BUILD_OPT=1
78
79 export FREEBL_NO_DEPEND=1
80 export FREEBL_LOWHASH=1
81
82 export LIBDIR=${libdir}
83 export MOZILLA_CLIENT=1
84 export NS_USE_GCC=1
85 export NSS_USE_SYSTEM_SQLITE=1
86 export NSS_ENABLE_ECC=1
87
88 ${@bb.utils.contains("TUNE_FEATURES", "crypto", "export NSS_USE_ARM_HW_CRYPTO=1", "", d)}
89
90 export OS_RELEASE=3.4
91 export OS_TARGET=Linux
92 export OS_ARCH=Linux
93
94 if [ "${TARGET_ARCH}" = "powerpc" ]; then
95 OS_TEST=ppc
96 elif [ "${TARGET_ARCH}" = "powerpc64" ]; then
97 OS_TEST=ppc64
98 elif [ "${TARGET_ARCH}" = "mips" -o "${TARGET_ARCH}" = "mipsel" -o "${TARGET_ARCH}" = "mips64" -o "${TARGET_ARCH}" = "mips64el" ]; then
99 OS_TEST=mips
100 elif [ "${TARGET_ARCH}" = "aarch64_be" ]; then
101 OS_TEST="aarch64"
102 else
103 OS_TEST="${TARGET_ARCH}"
104 fi
105
106 if [ "${SITEINFO_BITS}" = "64" ]; then
107 export USE_64=1
108 elif [ "${TARGET_ARCH}" = "x86_64" -a "${SITEINFO_BITS}" = "32" ]; then
109 export USE_X32=1
110 fi
111
112 export NSS_DISABLE_GTESTS=1
113
114 # We can modify CC in the environment, but if we set it via an
115 # argument to make, nsinstall, a host program, will also build with it!
116 #
117 # nss pretty much does its own thing with CFLAGS, so we put them into CC.
118 # Optimization will get clobbered, but most of the stuff will survive.
119 # The motivation for this is to point to the correct place for debug
120 # source files and CFLAGS does that. Nothing uses CCC.
121 #
122 export CC="${CC} ${CFLAGS}"
123 make -C ./nss CCC="${CXX} -g" \
124 OS_TEST=${OS_TEST} \
125 RPATH="${RPATH}"
126}
127
128do_compile[vardepsexclude] += "SITEINFO_BITS"
129
130do_install_prepend_class-nativesdk() {
131 export LDFLAGS=""
132}
133
134do_install() {
135 export CROSS_COMPILE=1
136 export NATIVE_CC="${BUILD_CC}"
137 export BUILD_OPT=1
138
139 export FREEBL_NO_DEPEND=1
140
141 export LIBDIR=${libdir}
142 export MOZILLA_CLIENT=1
143 export NS_USE_GCC=1
144 export NSS_USE_SYSTEM_SQLITE=1
145 export NSS_ENABLE_ECC=1
146
147 export OS_RELEASE=3.4
148 export OS_TARGET=Linux
149 export OS_ARCH=Linux
150
151 if [ "${TARGET_ARCH}" = "powerpc" ]; then
152 OS_TEST=ppc
153 elif [ "${TARGET_ARCH}" = "powerpc64" ]; then
154 OS_TEST=ppc64
155 elif [ "${TARGET_ARCH}" = "mips" -o "${TARGET_ARCH}" = "mipsel" -o "${TARGET_ARCH}" = "mips64" -o "${TARGET_ARCH}" = "mips64el" ]; then
156 OS_TEST=mips
157 elif [ "${TARGET_ARCH}" = "aarch64_be" ]; then
158 CPU_ARCH=aarch64
159 OS_TEST="aarch64"
160 else
161 OS_TEST="${TARGET_ARCH}"
162 fi
163 if [ "${SITEINFO_BITS}" = "64" ]; then
164 export USE_64=1
165 elif [ "${TARGET_ARCH}" = "x86_64" -a "${SITEINFO_BITS}" = "32" ]; then
166 export USE_X32=1
167 fi
168
169 export NSS_DISABLE_GTESTS=1
170
171 make -C ./nss \
172 CCC="${CXX}" \
173 OS_TEST=${OS_TEST} \
174 SOURCE_LIB_DIR="${TD}/${libdir}" \
175 SOURCE_BIN_DIR="${TD}/${bindir}" \
176 install
177
178 install -d ${D}/${libdir}/
179 for file in ${S}/dist/*.OBJ/lib/*.so; do
180 echo "Installing `basename $file`..."
181 cp $file ${D}/${libdir}/
182 done
183
184 for shared_lib in ${TD}/${libdir}/*.so.*; do
185 if [ -f $shared_lib ]; then
186 cp $shared_lib ${D}/${libdir}
187 ln -sf $(basename $shared_lib) ${D}/${libdir}/$(basename $shared_lib .1oe)
188 fi
189 done
190 for shared_lib in ${TD}/${libdir}/*.so; do
191 if [ -f $shared_lib -a ! -e ${D}/${libdir}/$shared_lib ]; then
192 cp $shared_lib ${D}/${libdir}
193 fi
194 done
195
196 install -d ${D}/${includedir}/nss3
197 install -m 644 -t ${D}/${includedir}/nss3 dist/public/nss/*
198
199 install -d ${D}/${bindir}
200 for binary in ${TD}/${bindir}/*; do
201 install -m 755 -t ${D}/${bindir} $binary
202 done
203}
204
205do_install[vardepsexclude] += "SITEINFO_BITS"
206
207do_install_append() {
208 # Create empty .chk files for the NSS libraries at build time. They could
209 # be regenerated at target's boot time.
210 for file in libsoftokn3.chk libfreebl3.chk libnssdbm3.chk; do
211 touch ${D}/${libdir}/$file
212 chmod 755 ${D}/${libdir}/$file
213 done
214 install -D -m 755 ${WORKDIR}/signlibs.sh ${D}/${bindir}/signlibs.sh
215
216 install -d ${D}${libdir}/pkgconfig/
217 sed 's/%NSS_VERSION%/${PV}/' ${WORKDIR}/nss.pc.in | sed 's/%NSPR_VERSION%/4.9.2/' > ${D}${libdir}/pkgconfig/nss.pc
218 sed -i s:OEPREFIX:${prefix}:g ${D}${libdir}/pkgconfig/nss.pc
219 sed -i s:OEEXECPREFIX:${exec_prefix}:g ${D}${libdir}/pkgconfig/nss.pc
220 sed -i s:OELIBDIR:${libdir}:g ${D}${libdir}/pkgconfig/nss.pc
221 sed -i s:OEINCDIR:${includedir}/nss3:g ${D}${libdir}/pkgconfig/nss.pc
222}
223
224do_install_append_class-target() {
225 # It used to call certutil to create a blank certificate with empty password at
226 # build time, but the checksum of key4.db changes every time when certutil is called.
227 # It causes non-determinism issue, so provide databases with a blank certificate
228 # which are originally from output of nss in qemux86-64 build. You can get these
229 # databases by:
230 # certutil -N -d sql:/database/path/ --empty-password
231 install -d ${D}${sysconfdir}/pki/nssdb/
232 install -m 0644 ${WORKDIR}/blank-cert9.db ${D}${sysconfdir}/pki/nssdb/cert9.db
233 install -m 0644 ${WORKDIR}/blank-key4.db ${D}${sysconfdir}/pki/nssdb/key4.db
234 install -m 0644 ${WORKDIR}/system-pkcs11.txt ${D}${sysconfdir}/pki/nssdb/pkcs11.txt
235}
236
237PACKAGE_WRITE_DEPS += "nss-native"
238pkg_postinst_${PN} () {
239 if [ -n "$D" ]; then
240 for I in $D${libdir}/lib*.chk; do
241 DN=`dirname $I`
242 BN=`basename $I .chk`
243 FN=$DN/$BN.so
244 shlibsign -i $FN
245 if [ $? -ne 0 ]; then
246 exit 1
247 fi
248 done
249 else
250 signlibs.sh
251 fi
252}
253
254PACKAGES =+ "${PN}-smime"
255FILES_${PN}-smime = "\
256 ${bindir}/smime \
257"
258
259FILES_${PN} = "\
260 ${sysconfdir} \
261 ${bindir} \
262 ${libdir}/lib*.chk \
263 ${libdir}/lib*.so \
264 "
265
266FILES_${PN}-dev = "\
267 ${libdir}/nss \
268 ${libdir}/pkgconfig/* \
269 ${includedir}/* \
270 "
271
272RDEPENDS_${PN}-smime = "perl"
273
274BBCLASSEXTEND = "native nativesdk"