blob: fce5a856ee98218ca694648e6cd62ee08562772d [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
Andrew Geisslerf103a7f2021-05-07 16:09:40 -050014LICENSE = "(MPL-2.0 & MIT) | (MPL-2.0 & GPL-2.0+ & MIT) | (MPL-2.0 & LGPL-2.1+ & MIT)"
Andrew Geissler82c905d2020-04-13 13:39:40 -050015
16LIC_FILES_CHKSUM = "file://nss/COPYING;md5=3b1e88e1b9c0b5a4b2881d46cce06a18 \
17 file://nss/lib/freebl/mpi/doc/LICENSE;md5=491f158d09d948466afce85d6f1fe18f \
Andrew Geisslerf103a7f2021-05-07 16:09:40 -050018 file://nss/lib/freebl/mpi/doc/LICENSE-MPL;md5=5d425c8f3157dbf212db2ec53d9e5132 \
19 file://nss/lib/freebl/verified/Hacl_Poly1305_256.c;beginline=1;endline=22;md5=d4096c1e4421ee56e9e0f441a8161f78"
Andrew Geissler82c905d2020-04-13 13:39:40 -050020
21VERSION_DIR = "${@d.getVar('BP').upper().replace('-', '_').replace('.', '_') + '_RTM'}"
22
23SRC_URI = "http://ftp.mozilla.org/pub/mozilla.org/security/nss/releases/${VERSION_DIR}/src/${BP}.tar.gz \
24 file://nss.pc.in \
Andrew Geissler82c905d2020-04-13 13:39:40 -050025 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 \
Andrew Geissler82c905d2020-04-13 13:39:40 -050035 "
Andrew Geisslerf103a7f2021-05-07 16:09:40 -050036SRC_URI[sha256sum] = "d3175427172e9c3a6f1ebc74452cb791590f28191c6a1a443dbc0d87c9df1126"
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 Geissler82c905d2020-04-13 13:39:40 -050046TARGET_CC_ARCH += "${LDFLAGS}"
47
48do_configure_prepend_libc-musl () {
49 sed -i -e '/-DHAVE_SYS_CDEFS_H/d' ${S}/nss/lib/dbm/config/config.mk
50}
51
Andrew Geissler97771a32021-03-05 15:23:11 -060052do_configure_prepend_powerpc64le_toolchain-clang () {
53 sed -i -e 's/\-std=c99/\-std=gnu99/g' ${S}/nss/coreconf/command.mk
54}
55
56do_configure_prepend_powerpc64_toolchain-clang () {
57 sed -i -e 's/\-std=c99/\-std=gnu99/g' ${S}/nss/coreconf/command.mk
58}
59
Andrew Geissler82c905d2020-04-13 13:39:40 -050060do_compile_prepend_class-native() {
61 export NSPR_INCLUDE_DIR=${STAGING_INCDIR_NATIVE}/nspr
62 export NSPR_LIB_DIR=${STAGING_LIBDIR_NATIVE}
Andrew Geissler82c905d2020-04-13 13:39:40 -050063}
64
65do_compile_prepend_class-nativesdk() {
66 export LDFLAGS=""
67}
68
69do_compile_prepend_class-native() {
70 # Need to set RPATH so that chrpath will do its job correctly
71 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}"
72}
73
74do_compile() {
75 export NSPR_INCLUDE_DIR=${STAGING_INCDIR}/nspr
76
77 export CROSS_COMPILE=1
78 export NATIVE_CC="${BUILD_CC}"
79 # Additional defines needed on Centos 7
80 export NATIVE_FLAGS="${BUILD_CFLAGS} -DLINUX -Dlinux"
81 export BUILD_OPT=1
82
Andrew Geissler97771a32021-03-05 15:23:11 -060083 # POSIX.1-2001 states that the behaviour of getcwd() when passing a null
84 # pointer as the buf argument, is unspecified.
85 export NATIVE_FLAGS="${NATIVE_FLAGS} -DGETCWD_CANT_MALLOC"
86
Andrew Geissler82c905d2020-04-13 13:39:40 -050087 export FREEBL_NO_DEPEND=1
88 export FREEBL_LOWHASH=1
89
90 export LIBDIR=${libdir}
91 export MOZILLA_CLIENT=1
92 export NS_USE_GCC=1
93 export NSS_USE_SYSTEM_SQLITE=1
94 export NSS_ENABLE_ECC=1
William A. Kennington IIIb95905d2021-06-02 12:40:56 -070095 export NSS_ENABLE_WERROR=0
Andrew Geissler82c905d2020-04-13 13:39:40 -050096
97 ${@bb.utils.contains("TUNE_FEATURES", "crypto", "export NSS_USE_ARM_HW_CRYPTO=1", "", d)}
98
99 export OS_RELEASE=3.4
100 export OS_TARGET=Linux
101 export OS_ARCH=Linux
102
103 if [ "${TARGET_ARCH}" = "powerpc" ]; then
104 OS_TEST=ppc
Andrew Geissler97771a32021-03-05 15:23:11 -0600105 elif [ "${TARGET_ARCH}" = "powerpc64" -o "${TARGET_ARCH}" = "powerpc64le" ]; then
Andrew Geissler82c905d2020-04-13 13:39:40 -0500106 OS_TEST=ppc64
107 elif [ "${TARGET_ARCH}" = "mips" -o "${TARGET_ARCH}" = "mipsel" -o "${TARGET_ARCH}" = "mips64" -o "${TARGET_ARCH}" = "mips64el" ]; then
108 OS_TEST=mips
109 elif [ "${TARGET_ARCH}" = "aarch64_be" ]; then
110 OS_TEST="aarch64"
111 else
112 OS_TEST="${TARGET_ARCH}"
113 fi
114
115 if [ "${SITEINFO_BITS}" = "64" ]; then
116 export USE_64=1
117 elif [ "${TARGET_ARCH}" = "x86_64" -a "${SITEINFO_BITS}" = "32" ]; then
118 export USE_X32=1
119 fi
120
121 export NSS_DISABLE_GTESTS=1
Andrew Geissler82c905d2020-04-13 13:39:40 -0500122 # We can modify CC in the environment, but if we set it via an
123 # argument to make, nsinstall, a host program, will also build with it!
124 #
125 # nss pretty much does its own thing with CFLAGS, so we put them into CC.
126 # Optimization will get clobbered, but most of the stuff will survive.
127 # The motivation for this is to point to the correct place for debug
128 # source files and CFLAGS does that. Nothing uses CCC.
129 #
130 export CC="${CC} ${CFLAGS}"
131 make -C ./nss CCC="${CXX} -g" \
132 OS_TEST=${OS_TEST} \
Andrew Geissler748a4832020-07-24 16:24:21 -0500133 RPATH="${RPATH}" \
134 autobuild
Andrew Geissler82c905d2020-04-13 13:39:40 -0500135}
136
137do_compile[vardepsexclude] += "SITEINFO_BITS"
138
139do_install_prepend_class-nativesdk() {
140 export LDFLAGS=""
141}
142
143do_install() {
144 export CROSS_COMPILE=1
145 export NATIVE_CC="${BUILD_CC}"
146 export BUILD_OPT=1
147
148 export FREEBL_NO_DEPEND=1
149
150 export LIBDIR=${libdir}
151 export MOZILLA_CLIENT=1
152 export NS_USE_GCC=1
153 export NSS_USE_SYSTEM_SQLITE=1
154 export NSS_ENABLE_ECC=1
155
156 export OS_RELEASE=3.4
157 export OS_TARGET=Linux
158 export OS_ARCH=Linux
159
160 if [ "${TARGET_ARCH}" = "powerpc" ]; then
161 OS_TEST=ppc
Andrew Geissler97771a32021-03-05 15:23:11 -0600162 elif [ "${TARGET_ARCH}" = "powerpc64" -o "${TARGET_ARCH}" = "powerpc64le" ]; then
Andrew Geissler82c905d2020-04-13 13:39:40 -0500163 OS_TEST=ppc64
164 elif [ "${TARGET_ARCH}" = "mips" -o "${TARGET_ARCH}" = "mipsel" -o "${TARGET_ARCH}" = "mips64" -o "${TARGET_ARCH}" = "mips64el" ]; then
165 OS_TEST=mips
166 elif [ "${TARGET_ARCH}" = "aarch64_be" ]; then
167 CPU_ARCH=aarch64
168 OS_TEST="aarch64"
169 else
170 OS_TEST="${TARGET_ARCH}"
171 fi
172 if [ "${SITEINFO_BITS}" = "64" ]; then
173 export USE_64=1
174 elif [ "${TARGET_ARCH}" = "x86_64" -a "${SITEINFO_BITS}" = "32" ]; then
175 export USE_X32=1
176 fi
177
178 export NSS_DISABLE_GTESTS=1
179
180 make -C ./nss \
181 CCC="${CXX}" \
182 OS_TEST=${OS_TEST} \
183 SOURCE_LIB_DIR="${TD}/${libdir}" \
184 SOURCE_BIN_DIR="${TD}/${bindir}" \
185 install
186
187 install -d ${D}/${libdir}/
188 for file in ${S}/dist/*.OBJ/lib/*.so; do
189 echo "Installing `basename $file`..."
190 cp $file ${D}/${libdir}/
191 done
192
193 for shared_lib in ${TD}/${libdir}/*.so.*; do
194 if [ -f $shared_lib ]; then
195 cp $shared_lib ${D}/${libdir}
196 ln -sf $(basename $shared_lib) ${D}/${libdir}/$(basename $shared_lib .1oe)
197 fi
198 done
199 for shared_lib in ${TD}/${libdir}/*.so; do
200 if [ -f $shared_lib -a ! -e ${D}/${libdir}/$shared_lib ]; then
201 cp $shared_lib ${D}/${libdir}
202 fi
203 done
204
205 install -d ${D}/${includedir}/nss3
206 install -m 644 -t ${D}/${includedir}/nss3 dist/public/nss/*
207
208 install -d ${D}/${bindir}
209 for binary in ${TD}/${bindir}/*; do
210 install -m 755 -t ${D}/${bindir} $binary
211 done
212}
213
214do_install[vardepsexclude] += "SITEINFO_BITS"
215
216do_install_append() {
217 # Create empty .chk files for the NSS libraries at build time. They could
218 # be regenerated at target's boot time.
219 for file in libsoftokn3.chk libfreebl3.chk libnssdbm3.chk; do
220 touch ${D}/${libdir}/$file
221 chmod 755 ${D}/${libdir}/$file
222 done
Andrew Geissler82c905d2020-04-13 13:39:40 -0500223
224 install -d ${D}${libdir}/pkgconfig/
225 sed 's/%NSS_VERSION%/${PV}/' ${WORKDIR}/nss.pc.in | sed 's/%NSPR_VERSION%/4.9.2/' > ${D}${libdir}/pkgconfig/nss.pc
226 sed -i s:OEPREFIX:${prefix}:g ${D}${libdir}/pkgconfig/nss.pc
227 sed -i s:OEEXECPREFIX:${exec_prefix}:g ${D}${libdir}/pkgconfig/nss.pc
228 sed -i s:OELIBDIR:${libdir}:g ${D}${libdir}/pkgconfig/nss.pc
229 sed -i s:OEINCDIR:${includedir}/nss3:g ${D}${libdir}/pkgconfig/nss.pc
230}
231
232do_install_append_class-target() {
233 # It used to call certutil to create a blank certificate with empty password at
234 # build time, but the checksum of key4.db changes every time when certutil is called.
235 # It causes non-determinism issue, so provide databases with a blank certificate
236 # which are originally from output of nss in qemux86-64 build. You can get these
237 # databases by:
238 # certutil -N -d sql:/database/path/ --empty-password
239 install -d ${D}${sysconfdir}/pki/nssdb/
240 install -m 0644 ${WORKDIR}/blank-cert9.db ${D}${sysconfdir}/pki/nssdb/cert9.db
241 install -m 0644 ${WORKDIR}/blank-key4.db ${D}${sysconfdir}/pki/nssdb/key4.db
242 install -m 0644 ${WORKDIR}/system-pkcs11.txt ${D}${sysconfdir}/pki/nssdb/pkcs11.txt
243}
244
245PACKAGE_WRITE_DEPS += "nss-native"
Andrew Geisslerd688a012020-09-18 13:36:00 -0500246
Andrew Geissler82c905d2020-04-13 13:39:40 -0500247pkg_postinst_${PN} () {
Andrew Geisslerd688a012020-09-18 13:36:00 -0500248 for I in $D${libdir}/lib*.chk; do
249 DN=`dirname $I`
250 BN=`basename $I .chk`
251 FN=$DN/$BN.so
252 shlibsign -i $FN
253 if [ $? -ne 0 ]; then
254 echo "shlibsign -i $FN failed"
255 fi
256 done
Andrew Geissler82c905d2020-04-13 13:39:40 -0500257}
258
259PACKAGES =+ "${PN}-smime"
260FILES_${PN}-smime = "\
261 ${bindir}/smime \
262"
263
264FILES_${PN} = "\
265 ${sysconfdir} \
266 ${bindir} \
267 ${libdir}/lib*.chk \
268 ${libdir}/lib*.so \
269 "
270
271FILES_${PN}-dev = "\
272 ${libdir}/nss \
273 ${libdir}/pkgconfig/* \
274 ${includedir}/* \
275 "
276
277RDEPENDS_${PN}-smime = "perl"
278
279BBCLASSEXTEND = "native nativesdk"