1SUMMARY = "Netscape Portable Runtime Library"
2HOMEPAGE =  "http://www.mozilla.org/projects/nspr/"
3LICENSE = "GPL-2.0-only | MPL-2.0 | LGPL-2.1-only"
4LIC_FILES_CHKSUM = "file://configure.in;beginline=3;endline=6;md5=90c2fdee38e45d6302abcfe475c8b5c5 \
5                    file://Makefile.in;beginline=4;endline=38;md5=beda1dbb98a515f557d3e58ef06bca99"
6SECTION = "libs/network"
7
8SRC_URI = "http://ftp.mozilla.org/pub/nspr/releases/v${PV}/src/nspr-${PV}.tar.gz \
9           file://remove-rpath-from-tests.patch \
10           file://fix-build-on-x86_64.patch \
11           file://0002-Add-nios2-support.patch \
12           file://0001-md-Fix-build-with-musl.patch \
13           file://Makefile.in-remove-_BUILD_STRING-and-_BUILD_TIME.patch \
14           file://0001-config-nspr-config.in-don-t-pass-LDFLAGS.patch \
15           file://0001-Fix-Wincompatible-function-pointer-types.patch \
16           file://nspr.pc.in \
17           "
18
19CACHED_CONFIGUREVARS:append:libc-musl = " CFLAGS='${CFLAGS} -D_PR_POLL_AVAILABLE \
20                                          -D_PR_HAVE_LARGE_OFF_T -D_PR_INET6 -D_PR_HAVE_INET_NTOP \
21                                          -D_PR_HAVE_GETHOSTBYNAME2 -D_PR_HAVE_GETADDRINFO \
22                                          -D_PR_INET6_PROBE -DNO_DLOPEN_NULL'"
23
24UPSTREAM_CHECK_URI = "http://ftp.mozilla.org/pub/nspr/releases/"
25UPSTREAM_CHECK_REGEX = "v(?P<pver>\d+(\.\d+)+)/"
26
27SRC_URI[sha256sum] = "7ea3297ea5969b5d25a5dd8d47f2443cda88e9ee746301f6e1e1426f8a6abc8f"
28
29CVE_PRODUCT = "netscape_portable_runtime"
30
31S = "${WORKDIR}/nspr-${PV}/nspr"
32
33RDEPENDS:${PN}-dev += "perl"
34TARGET_CC_ARCH += "${LDFLAGS}"
35
36TESTS = " \
37    accept \
38    acceptread \
39    acceptreademu \
40    affinity \
41    alarm \
42    anonfm \
43    atomic \
44    attach \
45    bigfile \
46    cleanup \
47    cltsrv  \
48    concur \
49    cvar \
50    cvar2 \
51    dlltest \
52    dtoa \
53    errcodes \
54    exit \
55    fdcach \
56    fileio \
57    foreign \
58    formattm \
59    fsync \
60    gethost \
61    getproto \
62    i2l \
63    initclk \
64    inrval \
65    instrumt \
66    intrio \
67    intrupt \
68    io_timeout \
69    ioconthr \
70    join \
71    joinkk \
72    joinku \
73    joinuk \
74    joinuu \
75    layer \
76    lazyinit \
77    libfilename \
78    lltest \
79    lock \
80    lockfile \
81    logfile \
82    logger \
83    many_cv \
84    multiwait \
85    nameshm1 \
86    nblayer \
87    nonblock \
88    ntioto \
89    ntoh \
90    op_2long \
91    op_excl \
92    op_filnf \
93    op_filok \
94    op_nofil \
95    parent \
96    parsetm \
97    peek \
98    perf \
99    pipeping \
100    pipeping2 \
101    pipeself \
102    poll_nm \
103    poll_to \
104    pollable \
105    prftest \
106    primblok \
107    provider \
108    prpollml \
109    ranfile \
110    randseed \
111    reinit \
112    rwlocktest \
113    sel_spd \
114    selct_er \
115    selct_nm \
116    selct_to \
117    selintr \
118    sema \
119    semaerr \
120    semaping \
121    sendzlf \
122    server_test \
123    servr_kk \
124    servr_uk \
125    servr_ku \
126    servr_uu \
127    short_thread \
128    sigpipe \
129    socket \
130    sockopt \
131    sockping \
132    sprintf \
133    stack \
134    stdio \
135    str2addr \
136    strod \
137    switch \
138    system \
139    testbit \
140    testfile \
141    threads \
142    timemac \
143    timetest \
144    tpd \
145    udpsrv \
146    vercheck \
147    version \
148    writev \
149    xnotify \
150    zerolen"
151
152inherit autotools multilib_script
153
154MULTILIB_SCRIPTS = "${PN}-dev:${bindir}/nspr-config"
155
156PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)}"
157PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6,"
158
159# Do not install nspr in usr/include, but in usr/include/nspr, the
160# preferred path upstream.
161EXTRA_OECONF += "--includedir=${includedir}/nspr"
162
163EXTRA_OEMAKE:append:class-native = " EXTRA_LIBS='-lpthread -lrt -ldl'"
164
165do_compile:prepend() {
166	oe_runmake CROSS_COMPILE=1 CFLAGS="-DXP_UNIX ${BUILD_CFLAGS}" LDFLAGS="" CC="${BUILD_CC}" -C config export
167}
168
169do_compile:append() {
170	oe_runmake -C pr/tests
171}
172
173do_install:append() {
174    install -D ${WORKDIR}/nspr.pc.in ${D}${libdir}/pkgconfig/nspr.pc
175    sed -i  \
176    -e 's:NSPRVERSION:${PV}:g' \
177    -e 's:OEPREFIX:${prefix}:g' \
178    -e 's:OELIBDIR:${libdir}:g' \
179    -e 's:OEINCDIR:${includedir}:g' \
180    -e 's:OEEXECPREFIX:${exec_prefix}:g' \
181    ${D}${libdir}/pkgconfig/nspr.pc
182
183    mkdir -p ${D}${libdir}/nspr/tests
184    install -m 0755 ${S}/pr/tests/runtests.pl ${D}${libdir}/nspr/tests
185    install -m 0755 ${S}/pr/tests/runtests.sh ${D}${libdir}/nspr/tests
186    cd ${B}/pr/tests
187    install -m 0755 ${TESTS} ${D}${libdir}/nspr/tests
188
189    # delete compile-et.pl and perr.properties from ${bindir} because these are
190    # only used to generate prerr.c and prerr.h files from prerr.et at compile
191    # time
192    rm ${D}${bindir}/compile-et.pl ${D}${bindir}/prerr.properties
193}
194
195FILES:${PN} = "${libdir}/lib*.so"
196FILES:${PN}-dev = "${bindir}/* ${libdir}/nspr/tests/* ${libdir}/pkgconfig \
197                ${includedir}/* ${datadir}/aclocal/* "
198
199BBCLASSEXTEND = "native nativesdk"
200