1 dnl This Source Code Form is subject to the terms of the Mozilla Public
2 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
3 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 AC_DEFUN([MOZ_CONFIG_NSPR], [
7 ifelse([$1],,define(CONFIGURING_JS,yes))
9 dnl Possible ways this can be called:
10 dnl from toplevel configure:
11 dnl JS_STANDALONE= MOZ_BUILD_APP!=js
12 dnl from js/src/configure invoked by toplevel configure:
13 dnl JS_STANDALONE= MOZ_BUILD_APP=js
14 dnl from standalone js/src/configure:
15 dnl JS_STANDALONE=1 MOZ_BUILD_APP=js
17 dnl ========================================================
18 dnl = Find the right NSPR to use.
19 dnl ========================================================
20 MOZ_ARG_WITH_STRING(nspr-cflags,
21 [ --with-nspr-cflags=FLAGS
22 Pass FLAGS to CC when building code that uses NSPR.
23 Use this when there's no accurate nspr-config
24 script available. This is the case when building
25 SpiderMonkey as part of the Mozilla tree: the
26 top-level configure script computes NSPR flags
27 that accomodate the quirks of that environment.],
29 MOZ_ARG_WITH_STRING(nspr-libs,
30 [ --with-nspr-libs=LIBS Pass LIBS to LD when linking code that uses NSPR.
31 See --with-nspr-cflags for more details.],
34 ifdef([CONFIGURING_JS],[
35 MOZ_ARG_ENABLE_BOOL(nspr-build,
36 [ --enable-nspr-build Build NSPR from source tree],
41 if test "$MOZ_BUILD_APP" != js || test -n "$JS_STANDALONE"; then
45 MOZ_ARG_WITH_BOOL(system-nspr,
46 [ --with-system-nspr Use an NSPR that is already built and installed.
47 Use the 'nspr-config' script in the current path,
48 or look for the script in the directories given with
49 --with-nspr-exec-prefix or --with-nspr-prefix.
50 (Those flags are only checked if you specify
51 --with-system-nspr.)],
55 ifdef([CONFIGURING_JS],[
56 if test -n "$JS_STANDALONE"; then
58 *linux*|*darwin*|*dragonfly*|*freebsd*|*netbsd*|*openbsd*)
59 if test -z "$_HAS_NSPR"; then
60 JS_POSIX_NSPR_DEFAULT=1
66 MOZ_ARG_ENABLE_BOOL(posix-nspr-emulation,
67 [ --enable-posix-nspr-emulation
68 Enable emulation of NSPR for POSIX systems],
73 dnl Pass at most one of
74 dnl --with-system-nspr
75 dnl --with-nspr-cflags/libs
76 dnl --enable-nspr-build
77 dnl --enable-posix-nspr-emulation
79 AC_MSG_CHECKING([NSPR selection])
82 if test -n "$_USE_SYSTEM_NSPR"; then
83 nspr_opts="x$nspr_opts"
86 if test -n "$NSPR_CFLAGS" -o -n "$NSPR_LIBS"; then
87 nspr_opts="x$nspr_opts"
88 which_nspr="command-line"
90 if test -n "$MOZ_BUILD_NSPR"; then
91 nspr_opts="x$nspr_opts"
92 which_nspr="source-tree"
94 if test "$JS_POSIX_NSPR" = unset; then
97 nspr_opts="x$nspr_opts"
98 which_nspr="posix-wrapper"
101 if test -z "$nspr_opts"; then
102 if test "$MOZ_BUILD_APP" != js; then
103 dnl Toplevel configure defaults to using nsprpub from the source tree
105 which_nspr="source-tree"
107 dnl JS configure defaults to emulated NSPR if available, falling back
109 JS_POSIX_NSPR="$JS_POSIX_NSPR_DEFAULT"
110 if test -z "$JS_POSIX_NSPR"; then
112 which_nspr="source-tree"
114 which_nspr="posix-wrapper"
119 if test -z "$nspr_opts" || test "$nspr_opts" = x; then
120 AC_MSG_RESULT($which_nspr)
122 AC_MSG_ERROR([only one way of using NSPR may be selected. See 'configure --help'.])
125 AC_SUBST(MOZ_BUILD_NSPR)
127 if test "$MOZ_BUILD_APP" = js; then
128 if test "$JS_POSIX_NSPR" = 1; then
129 AC_DEFINE(JS_POSIX_NSPR)
131 AC_SUBST(JS_POSIX_NSPR)
134 # A (sub)configure invoked by the toplevel configure will always receive
135 # --with-nspr-libs on the command line. It will never need to figure out
137 if test -n "$_IS_OUTER_CONFIGURE"; then
139 if test -n "$_USE_SYSTEM_NSPR"; then
140 AM_PATH_NSPR($NSPR_MINVER, [MOZ_SYSTEM_NSPR=1], [AC_MSG_ERROR([you do not have NSPR installed or your version is older than $NSPR_MINVER.])])
143 if test -n "$MOZ_SYSTEM_NSPR" -o -n "$NSPR_CFLAGS" -o -n "$NSPR_LIBS"; then
145 CFLAGS="$CFLAGS $NSPR_CFLAGS"
146 AC_TRY_COMPILE([#include "prtypes.h"],
147 [#ifndef PR_STATIC_ASSERT
148 #error PR_STATIC_ASSERT not defined or requires including prtypes.h
151 AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT or including prtypes.h does not provide it]))
152 AC_TRY_COMPILE([#include "prtypes.h"],
154 #error PR_UINT64 not defined or requires including prtypes.h
157 AC_MSG_ERROR([system NSPR does not support PR_UINT64 or including prtypes.h does not provide it]))
159 NSPR_INCLUDE_DIR=`echo ${NSPR_CFLAGS} | sed -e 's/.*-I\([^ ]*\).*/\1/'`
160 NSPR_LIB_DIR=`echo ${NSPR_LIBS} | sed -e 's/.*-L\([^ ]*\).*/\1/'`
161 elif test -z "$JS_POSIX_NSPR"; then
162 NSPR_INCLUDE_DIR="${DIST}/include/nspr"
163 NSPR_CFLAGS="-I${NSPR_INCLUDE_DIR}"
164 if test -n "$GNU_CC"; then
165 if test -n "$MOZ_FOLD_LIBS"; then
166 NSPR_LIB_DIR=${DIST}/lib
168 NSPR_LIB_DIR=${DIST}/bin
170 NSPR_LIBS="-L${NSPR_LIB_DIR} -lnspr${NSPR_VERSION} -lplc${NSPR_VERSION} -lplds${NSPR_VERSION}"
172 # NSS needs actual static libs to link to, and this is where they are.
173 NSPR_LIBS="${DIST}/lib/nspr${NSPR_VERSION}.lib ${DIST}/lib/plc${NSPR_VERSION}.lib ${DIST}/lib/plds${NSPR_VERSION}.lib "
174 NSPR_LIB_DIR="${DIST}/lib"
178 AC_SUBST_LIST(NSPR_CFLAGS)
179 AC_SUBST(NSPR_INCLUDE_DIR)
180 AC_SUBST(NSPR_LIB_DIR)
182 NSPR_PKGCONF_CHECK="nspr"
183 if test -n "$MOZ_SYSTEM_NSPR"; then
184 # piggy back on $MOZ_SYSTEM_NSPR to set a variable for the nspr check for js.pc
185 NSPR_PKGCONF_CHECK="nspr >= $NSPR_MINVER"
188 CFLAGS="$CFLAGS $NSPR_CFLAGS"
189 AC_TRY_COMPILE([#include "prlog.h"],
190 [#ifndef PR_STATIC_ASSERT
191 #error PR_STATIC_ASSERT not defined
194 AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT]))
197 AC_SUBST(NSPR_PKGCONF_CHECK)
199 fi # _IS_OUTER_CONFIGURE