blob: 997f8950fd945f47f71bdcd808281b62e7e0cfd5 [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 \
Andrew Geissler82c905d2020-04-13 13:39:40 -050024 file://0001-nss-fix-support-cross-compiling.patch \
25 file://nss-no-rpath-for-cross-compiling.patch \
26 file://nss-fix-incorrect-shebang-of-perl.patch \
27 file://disable-Wvarargs-with-clang.patch \
28 file://pqg.c-ULL_addend.patch \
29 file://blank-cert9.db \
30 file://blank-key4.db \
31 file://system-pkcs11.txt \
32 file://nss-fix-nsinstall-build.patch \
33 file://0001-freebl-add-a-configure-option-to-disable-ARM-HW-cryp.patch \
Andrew Geisslerd688a012020-09-18 13:36:00 -050034 file://0001-pkix-Do-not-use-NULL-where-0-is-needed.patch \
Andrew Geissler82c905d2020-04-13 13:39:40 -050035 "
Andrew Geisslerd688a012020-09-18 13:36:00 -050036SRC_URI[sha256sum] = "f875e0e8ed3b5ce92d675be4a55aa25a8c1199789a4a01f69b5f2327e2048e9c"
Andrew Geissler82c905d2020-04-13 13:39:40 -050037
38UPSTREAM_CHECK_URI = "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/NSS_Releases"
39UPSTREAM_CHECK_REGEX = "NSS_(?P<pver>.+)_release_notes"
40
41inherit siteinfo
42
43TD = "${S}/tentative-dist"
44TDS = "${S}/tentative-dist-staging"
45
Andrew Geissler7f40b712020-05-15 14:09:53 -050046# cortex-a55 is ARMv8.2-a based but libatomic explicitly asks for -march=armv8.1-a
47# which caused -march conflicts in gcc
48TUNE_CCARGS_remove = "-mcpu=cortex-a55+crc -mcpu=cortex-a55 -mcpu=cortex-a55+crc+crypto"
49
Andrew Geissler82c905d2020-04-13 13:39:40 -050050TARGET_CC_ARCH += "${LDFLAGS}"
51
52do_configure_prepend_libc-musl () {
53 sed -i -e '/-DHAVE_SYS_CDEFS_H/d' ${S}/nss/lib/dbm/config/config.mk
54}
55
56do_compile_prepend_class-native() {
57 export NSPR_INCLUDE_DIR=${STAGING_INCDIR_NATIVE}/nspr
58 export NSPR_LIB_DIR=${STAGING_LIBDIR_NATIVE}
Andrew Geissler82c905d2020-04-13 13:39:40 -050059}
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
Andrew Geisslerd688a012020-09-18 13:36:00 -050072 export NSS_ENABLE_WERROR=0
Andrew Geissler82c905d2020-04-13 13:39:40 -050073
74 export CROSS_COMPILE=1
75 export NATIVE_CC="${BUILD_CC}"
76 # Additional defines needed on Centos 7
77 export NATIVE_FLAGS="${BUILD_CFLAGS} -DLINUX -Dlinux"
78 export BUILD_OPT=1
79
80 export FREEBL_NO_DEPEND=1
81 export FREEBL_LOWHASH=1
82
83 export LIBDIR=${libdir}
84 export MOZILLA_CLIENT=1
85 export NS_USE_GCC=1
86 export NSS_USE_SYSTEM_SQLITE=1
87 export NSS_ENABLE_ECC=1
88
89 ${@bb.utils.contains("TUNE_FEATURES", "crypto", "export NSS_USE_ARM_HW_CRYPTO=1", "", d)}
90
91 export OS_RELEASE=3.4
92 export OS_TARGET=Linux
93 export OS_ARCH=Linux
94
95 if [ "${TARGET_ARCH}" = "powerpc" ]; then
96 OS_TEST=ppc
97 elif [ "${TARGET_ARCH}" = "powerpc64" ]; then
98 OS_TEST=ppc64
99 elif [ "${TARGET_ARCH}" = "mips" -o "${TARGET_ARCH}" = "mipsel" -o "${TARGET_ARCH}" = "mips64" -o "${TARGET_ARCH}" = "mips64el" ]; then
100 OS_TEST=mips
101 elif [ "${TARGET_ARCH}" = "aarch64_be" ]; then
102 OS_TEST="aarch64"
103 else
104 OS_TEST="${TARGET_ARCH}"
105 fi
106
107 if [ "${SITEINFO_BITS}" = "64" ]; then
108 export USE_64=1
109 elif [ "${TARGET_ARCH}" = "x86_64" -a "${SITEINFO_BITS}" = "32" ]; then
110 export USE_X32=1
111 fi
112
113 export NSS_DISABLE_GTESTS=1
114
115 # We can modify CC in the environment, but if we set it via an
116 # argument to make, nsinstall, a host program, will also build with it!
117 #
118 # nss pretty much does its own thing with CFLAGS, so we put them into CC.
119 # Optimization will get clobbered, but most of the stuff will survive.
120 # The motivation for this is to point to the correct place for debug
121 # source files and CFLAGS does that. Nothing uses CCC.
122 #
123 export CC="${CC} ${CFLAGS}"
124 make -C ./nss CCC="${CXX} -g" \
125 OS_TEST=${OS_TEST} \
Andrew Geissler748a4832020-07-24 16:24:21 -0500126 RPATH="${RPATH}" \
127 autobuild
Andrew Geissler82c905d2020-04-13 13:39:40 -0500128}
129
130do_compile[vardepsexclude] += "SITEINFO_BITS"
131
132do_install_prepend_class-nativesdk() {
133 export LDFLAGS=""
134}
135
136do_install() {
137 export CROSS_COMPILE=1
138 export NATIVE_CC="${BUILD_CC}"
139 export BUILD_OPT=1
140
141 export FREEBL_NO_DEPEND=1
142
143 export LIBDIR=${libdir}
144 export MOZILLA_CLIENT=1
145 export NS_USE_GCC=1
146 export NSS_USE_SYSTEM_SQLITE=1
147 export NSS_ENABLE_ECC=1
148
149 export OS_RELEASE=3.4
150 export OS_TARGET=Linux
151 export OS_ARCH=Linux
152
153 if [ "${TARGET_ARCH}" = "powerpc" ]; then
154 OS_TEST=ppc
155 elif [ "${TARGET_ARCH}" = "powerpc64" ]; then
156 OS_TEST=ppc64
157 elif [ "${TARGET_ARCH}" = "mips" -o "${TARGET_ARCH}" = "mipsel" -o "${TARGET_ARCH}" = "mips64" -o "${TARGET_ARCH}" = "mips64el" ]; then
158 OS_TEST=mips
159 elif [ "${TARGET_ARCH}" = "aarch64_be" ]; then
160 CPU_ARCH=aarch64
161 OS_TEST="aarch64"
162 else
163 OS_TEST="${TARGET_ARCH}"
164 fi
165 if [ "${SITEINFO_BITS}" = "64" ]; then
166 export USE_64=1
167 elif [ "${TARGET_ARCH}" = "x86_64" -a "${SITEINFO_BITS}" = "32" ]; then
168 export USE_X32=1
169 fi
170
171 export NSS_DISABLE_GTESTS=1
172
173 make -C ./nss \
174 CCC="${CXX}" \
175 OS_TEST=${OS_TEST} \
176 SOURCE_LIB_DIR="${TD}/${libdir}" \
177 SOURCE_BIN_DIR="${TD}/${bindir}" \
178 install
179
180 install -d ${D}/${libdir}/
181 for file in ${S}/dist/*.OBJ/lib/*.so; do
182 echo "Installing `basename $file`..."
183 cp $file ${D}/${libdir}/
184 done
185
186 for shared_lib in ${TD}/${libdir}/*.so.*; do
187 if [ -f $shared_lib ]; then
188 cp $shared_lib ${D}/${libdir}
189 ln -sf $(basename $shared_lib) ${D}/${libdir}/$(basename $shared_lib .1oe)
190 fi
191 done
192 for shared_lib in ${TD}/${libdir}/*.so; do
193 if [ -f $shared_lib -a ! -e ${D}/${libdir}/$shared_lib ]; then
194 cp $shared_lib ${D}/${libdir}
195 fi
196 done
197
198 install -d ${D}/${includedir}/nss3
199 install -m 644 -t ${D}/${includedir}/nss3 dist/public/nss/*
200
201 install -d ${D}/${bindir}
202 for binary in ${TD}/${bindir}/*; do
203 install -m 755 -t ${D}/${bindir} $binary
204 done
205}
206
207do_install[vardepsexclude] += "SITEINFO_BITS"
208
209do_install_append() {
210 # Create empty .chk files for the NSS libraries at build time. They could
211 # be regenerated at target's boot time.
212 for file in libsoftokn3.chk libfreebl3.chk libnssdbm3.chk; do
213 touch ${D}/${libdir}/$file
214 chmod 755 ${D}/${libdir}/$file
215 done
Andrew Geissler82c905d2020-04-13 13:39:40 -0500216
217 install -d ${D}${libdir}/pkgconfig/
218 sed 's/%NSS_VERSION%/${PV}/' ${WORKDIR}/nss.pc.in | sed 's/%NSPR_VERSION%/4.9.2/' > ${D}${libdir}/pkgconfig/nss.pc
219 sed -i s:OEPREFIX:${prefix}:g ${D}${libdir}/pkgconfig/nss.pc
220 sed -i s:OEEXECPREFIX:${exec_prefix}:g ${D}${libdir}/pkgconfig/nss.pc
221 sed -i s:OELIBDIR:${libdir}:g ${D}${libdir}/pkgconfig/nss.pc
222 sed -i s:OEINCDIR:${includedir}/nss3:g ${D}${libdir}/pkgconfig/nss.pc
223}
224
225do_install_append_class-target() {
226 # It used to call certutil to create a blank certificate with empty password at
227 # build time, but the checksum of key4.db changes every time when certutil is called.
228 # It causes non-determinism issue, so provide databases with a blank certificate
229 # which are originally from output of nss in qemux86-64 build. You can get these
230 # databases by:
231 # certutil -N -d sql:/database/path/ --empty-password
232 install -d ${D}${sysconfdir}/pki/nssdb/
233 install -m 0644 ${WORKDIR}/blank-cert9.db ${D}${sysconfdir}/pki/nssdb/cert9.db
234 install -m 0644 ${WORKDIR}/blank-key4.db ${D}${sysconfdir}/pki/nssdb/key4.db
235 install -m 0644 ${WORKDIR}/system-pkcs11.txt ${D}${sysconfdir}/pki/nssdb/pkcs11.txt
236}
237
238PACKAGE_WRITE_DEPS += "nss-native"
Andrew Geisslerd688a012020-09-18 13:36:00 -0500239
Andrew Geissler82c905d2020-04-13 13:39:40 -0500240pkg_postinst_${PN} () {
Andrew Geisslerd688a012020-09-18 13:36:00 -0500241 for I in $D${libdir}/lib*.chk; do
242 DN=`dirname $I`
243 BN=`basename $I .chk`
244 FN=$DN/$BN.so
245 shlibsign -i $FN
246 if [ $? -ne 0 ]; then
247 echo "shlibsign -i $FN failed"
248 fi
249 done
Andrew Geissler82c905d2020-04-13 13:39:40 -0500250}
251
252PACKAGES =+ "${PN}-smime"
253FILES_${PN}-smime = "\
254 ${bindir}/smime \
255"
256
257FILES_${PN} = "\
258 ${sysconfdir} \
259 ${bindir} \
260 ${libdir}/lib*.chk \
261 ${libdir}/lib*.so \
262 "
263
264FILES_${PN}-dev = "\
265 ${libdir}/nss \
266 ${libdir}/pkgconfig/* \
267 ${includedir}/* \
268 "
269
270RDEPENDS_${PN}-smime = "perl"
271
272BBCLASSEXTEND = "native nativesdk"