blob: 5d9318a9223d1aea03ca3d6fb31f8b9e6252a341 [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 Geissler82c905d2020-04-13 13:39:40 -050034 "
Andrew Geisslerbbbd5f42020-10-30 15:42:48 -050035SRC_URI[sha256sum] = "55a86c01be860381d64bb4e5b94eb198df9b0f098a8af0e58c014df398bdc382"
Andrew Geissler82c905d2020-04-13 13:39:40 -050036
37UPSTREAM_CHECK_URI = "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/NSS_Releases"
38UPSTREAM_CHECK_REGEX = "NSS_(?P<pver>.+)_release_notes"
39
40inherit siteinfo
41
42TD = "${S}/tentative-dist"
43TDS = "${S}/tentative-dist-staging"
44
Andrew Geissler7f40b712020-05-15 14:09:53 -050045# cortex-a55 is ARMv8.2-a based but libatomic explicitly asks for -march=armv8.1-a
46# which caused -march conflicts in gcc
47TUNE_CCARGS_remove = "-mcpu=cortex-a55+crc -mcpu=cortex-a55 -mcpu=cortex-a55+crc+crypto"
48
Andrew Geissler82c905d2020-04-13 13:39:40 -050049TARGET_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}
Andrew Geissler82c905d2020-04-13 13:39:40 -050058}
59
60do_compile_prepend_class-nativesdk() {
61 export LDFLAGS=""
62}
63
64do_compile_prepend_class-native() {
65 # Need to set RPATH so that chrpath will do its job correctly
66 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}"
67}
68
69do_compile() {
70 export NSPR_INCLUDE_DIR=${STAGING_INCDIR}/nspr
Andrew Geisslerd688a012020-09-18 13:36:00 -050071 export NSS_ENABLE_WERROR=0
Andrew Geissler82c905d2020-04-13 13:39:40 -050072
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} \
Andrew Geissler748a4832020-07-24 16:24:21 -0500125 RPATH="${RPATH}" \
126 autobuild
Andrew Geissler82c905d2020-04-13 13:39:40 -0500127}
128
129do_compile[vardepsexclude] += "SITEINFO_BITS"
130
131do_install_prepend_class-nativesdk() {
132 export LDFLAGS=""
133}
134
135do_install() {
136 export CROSS_COMPILE=1
137 export NATIVE_CC="${BUILD_CC}"
138 export BUILD_OPT=1
139
140 export FREEBL_NO_DEPEND=1
141
142 export LIBDIR=${libdir}
143 export MOZILLA_CLIENT=1
144 export NS_USE_GCC=1
145 export NSS_USE_SYSTEM_SQLITE=1
146 export NSS_ENABLE_ECC=1
147
148 export OS_RELEASE=3.4
149 export OS_TARGET=Linux
150 export OS_ARCH=Linux
151
152 if [ "${TARGET_ARCH}" = "powerpc" ]; then
153 OS_TEST=ppc
154 elif [ "${TARGET_ARCH}" = "powerpc64" ]; then
155 OS_TEST=ppc64
156 elif [ "${TARGET_ARCH}" = "mips" -o "${TARGET_ARCH}" = "mipsel" -o "${TARGET_ARCH}" = "mips64" -o "${TARGET_ARCH}" = "mips64el" ]; then
157 OS_TEST=mips
158 elif [ "${TARGET_ARCH}" = "aarch64_be" ]; then
159 CPU_ARCH=aarch64
160 OS_TEST="aarch64"
161 else
162 OS_TEST="${TARGET_ARCH}"
163 fi
164 if [ "${SITEINFO_BITS}" = "64" ]; then
165 export USE_64=1
166 elif [ "${TARGET_ARCH}" = "x86_64" -a "${SITEINFO_BITS}" = "32" ]; then
167 export USE_X32=1
168 fi
169
170 export NSS_DISABLE_GTESTS=1
171
172 make -C ./nss \
173 CCC="${CXX}" \
174 OS_TEST=${OS_TEST} \
175 SOURCE_LIB_DIR="${TD}/${libdir}" \
176 SOURCE_BIN_DIR="${TD}/${bindir}" \
177 install
178
179 install -d ${D}/${libdir}/
180 for file in ${S}/dist/*.OBJ/lib/*.so; do
181 echo "Installing `basename $file`..."
182 cp $file ${D}/${libdir}/
183 done
184
185 for shared_lib in ${TD}/${libdir}/*.so.*; do
186 if [ -f $shared_lib ]; then
187 cp $shared_lib ${D}/${libdir}
188 ln -sf $(basename $shared_lib) ${D}/${libdir}/$(basename $shared_lib .1oe)
189 fi
190 done
191 for shared_lib in ${TD}/${libdir}/*.so; do
192 if [ -f $shared_lib -a ! -e ${D}/${libdir}/$shared_lib ]; then
193 cp $shared_lib ${D}/${libdir}
194 fi
195 done
196
197 install -d ${D}/${includedir}/nss3
198 install -m 644 -t ${D}/${includedir}/nss3 dist/public/nss/*
199
200 install -d ${D}/${bindir}
201 for binary in ${TD}/${bindir}/*; do
202 install -m 755 -t ${D}/${bindir} $binary
203 done
204}
205
206do_install[vardepsexclude] += "SITEINFO_BITS"
207
208do_install_append() {
209 # Create empty .chk files for the NSS libraries at build time. They could
210 # be regenerated at target's boot time.
211 for file in libsoftokn3.chk libfreebl3.chk libnssdbm3.chk; do
212 touch ${D}/${libdir}/$file
213 chmod 755 ${D}/${libdir}/$file
214 done
Andrew Geissler82c905d2020-04-13 13:39:40 -0500215
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"
Andrew Geisslerd688a012020-09-18 13:36:00 -0500238
Andrew Geissler82c905d2020-04-13 13:39:40 -0500239pkg_postinst_${PN} () {
Andrew Geisslerd688a012020-09-18 13:36:00 -0500240 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 echo "shlibsign -i $FN failed"
247 fi
248 done
Andrew Geissler82c905d2020-04-13 13:39:40 -0500249}
250
251PACKAGES =+ "${PN}-smime"
252FILES_${PN}-smime = "\
253 ${bindir}/smime \
254"
255
256FILES_${PN} = "\
257 ${sysconfdir} \
258 ${bindir} \
259 ${libdir}/lib*.chk \
260 ${libdir}/lib*.so \
261 "
262
263FILES_${PN}-dev = "\
264 ${libdir}/nss \
265 ${libdir}/pkgconfig/* \
266 ${includedir}/* \
267 "
268
269RDEPENDS_${PN}-smime = "perl"
270
271BBCLASSEXTEND = "native nativesdk"