Bug 1295072 - Focus urlbar after opening an empty new tab r=kmag
[gecko.git] / build / autoconf / nspr-build.m4
blobbb4e630d262bdb869948f8faf842a7e2bdf06c5f
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.],
28     NSPR_CFLAGS=$withval)
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.],
32     NSPR_LIBS=$withval)
34 ifdef([CONFIGURING_JS],[
35     MOZ_ARG_ENABLE_BOOL(nspr-build,
36 [  --enable-nspr-build     Build NSPR from source tree],
37         MOZ_BUILD_NSPR=1,
38         MOZ_BUILD_NSPR=)
41 if test "$MOZ_BUILD_APP" != js || test -n "$JS_STANDALONE"; then
42   _IS_OUTER_CONFIGURE=1
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.)],
52     _USE_SYSTEM_NSPR=1 )
54 JS_POSIX_NSPR=unset
55 ifdef([CONFIGURING_JS],[
56     if test -n "$JS_STANDALONE"; then
57       case "$target" in
58         *linux*|*darwin*|*dragonfly*|*freebsd*|*netbsd*|*openbsd*)
59           if test -z "$_HAS_NSPR"; then
60             JS_POSIX_NSPR_DEFAULT=1
61           fi
62           ;;
63       esac
64     fi
66     MOZ_ARG_ENABLE_BOOL(posix-nspr-emulation,
67 [  --enable-posix-nspr-emulation
68                           Enable emulation of NSPR for POSIX systems],
69     JS_POSIX_NSPR=1,
70     JS_POSIX_NSPR=)
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])
80 nspr_opts=
81 which_nspr=default
82 if test -n "$_USE_SYSTEM_NSPR"; then
83     nspr_opts="x$nspr_opts"
84     which_nspr="system"
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
95     JS_POSIX_NSPR=
96 else
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
104       MOZ_BUILD_NSPR=1
105       which_nspr="source-tree"
106     else
107       dnl JS configure defaults to emulated NSPR if available, falling back
108       dnl to nsprpub.
109       JS_POSIX_NSPR="$JS_POSIX_NSPR_DEFAULT"
110       if test -z "$JS_POSIX_NSPR"; then
111         MOZ_BUILD_NSPR=1
112         which_nspr="source-tree"
113       else
114         which_nspr="posix-wrapper"
115       fi
116    fi
119 if test -z "$nspr_opts" || test "$nspr_opts" = x; then
120     AC_MSG_RESULT($which_nspr)
121 else
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)
130   fi
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
136 # anything itself.
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
144     _SAVE_CFLAGS=$CFLAGS
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
149                  #endif],
150                 ,
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"],
153                 [#ifndef PR_UINT64
154                  #error PR_UINT64 not defined or requires including prtypes.h
155                  #endif],
156                 ,
157                 AC_MSG_ERROR([system NSPR does not support PR_UINT64 or including prtypes.h does not provide it]))
158     CFLAGS=$_SAVE_CFLAGS
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
167         else
168            NSPR_LIB_DIR=${DIST}/bin
169         fi
170         NSPR_LIBS="-L${NSPR_LIB_DIR} -lnspr${NSPR_VERSION} -lplc${NSPR_VERSION} -lplds${NSPR_VERSION}"
171     else
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"
175     fi
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"
187     _SAVE_CFLAGS=$CFLAGS
188     CFLAGS="$CFLAGS $NSPR_CFLAGS"
189     AC_TRY_COMPILE([#include "prlog.h"],
190                 [#ifndef PR_STATIC_ASSERT
191                  #error PR_STATIC_ASSERT not defined
192                  #endif],
193                 ,
194                 AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT]))
195     CFLAGS=$_SAVE_CFLAGS
197 AC_SUBST(NSPR_PKGCONF_CHECK)
199 fi # _IS_OUTER_CONFIGURE