Patch from Mike Kaplinskiy <mike.kaplinskiy@gmail.com> implementing trim, trimLeft...
[mozilla-central.git] / nsprpub / configure.in
blobaf52259e6b95805828d836a4e8e3d623583332ca
1 dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
2 dnl 
3 dnl ***** BEGIN LICENSE BLOCK *****
4 dnl Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 dnl
6 dnl The contents of this file are subject to the Mozilla Public License Version
7 dnl 1.1 (the "License"); you may not use this file except in compliance with
8 dnl the License. You may obtain a copy of the License at
9 dnl http://www.mozilla.org/MPL/
10 dnl
11 dnl Software distributed under the License is distributed on an "AS IS" basis,
12 dnl WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 dnl for the specific language governing rights and limitations under the
14 dnl License.
15 dnl
16 dnl The Original Code is the Netscape Portable Runtime (NSPR).
17 dnl
18 dnl The Initial Developer of the Original Code is
19 dnl Netscape Communications Corporation.
20 dnl Portions created by the Initial Developer are Copyright (C) 1998
21 dnl the Initial Developer. All Rights Reserved.
22 dnl
23 dnl Contributor(s):
24 dnl   Christopher Seawood <cls@seawood.org>
25 dnl   Howard Chu <hyc@symas.com>
26 dnl   Mark Mentovai <mark@moxienet.com>
27 dnl
28 dnl Alternatively, the contents of this file may be used under the terms of
29 dnl either the GNU General Public License Version 2 or later (the "GPL"), or
30 dnl the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31 dnl in which case the provisions of the GPL or the LGPL are applicable instead
32 dnl of those above. If you wish to allow use of your version of this file only
33 dnl under the terms of either the GPL or the LGPL, and not to allow others to
34 dnl use your version of this file under the terms of the MPL, indicate your
35 dnl decision by deleting the provisions above and replace them with the notice
36 dnl and other provisions required by the GPL or the LGPL. If you do not delete
37 dnl the provisions above, a recipient may use your version of this file under
38 dnl the terms of any one of the MPL, the GPL or the LGPL.
39 dnl
40 dnl ***** END LICENSE BLOCK *****
42 AC_PREREQ(2.12)
43 AC_INIT(config/libc_r.h)
45 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
46 AC_CANONICAL_SYSTEM
48 dnl ========================================================
49 dnl = Defaults
50 dnl ========================================================
51 MOD_MAJOR_VERSION=4
52 MOD_MINOR_VERSION=7
53 MOD_PATCH_VERSION=2
54 NSPR_MODNAME=nspr20
55 _HAVE_PTHREADS=
56 USE_PTHREADS=
57 USE_USER_PTHREADS=
58 USE_NSPR_THREADS=
59 USE_N32=
60 USE_64=
61 USE_CPLUS=
62 USE_IPV6=
63 USE_MDUPDATE=
64 _MACOSX_DEPLOYMENT_TARGET=
65 _OPTIMIZE_FLAGS=-O
66 _DEBUG_FLAGS=-g
67 MOZ_DEBUG=1
68 MOZ_OPTIMIZE=
69 OBJDIR='$(OBJDIR_NAME)'
70 OBJDIR_NAME=.
71 OBJDIR_SUFFIX=OBJ
72 NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall'
73 NOSUCHFILE=/no-such-file
74 LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)'
75 LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)'
76 CYGWIN_WRAPPER=
77 MACOS_SDK_DIR=
78 NEXT_ROOT=
79 MT=
80 MOZ_OS2_HIGH_MEMORY=1
82 dnl Link in libraries necessary to resolve all symbols for shared libs
83 RESOLVE_LINK_SYMBOLS=
85 dnl ========================================================
86 dnl =
87 dnl = Dont change the following lines.  Doing so breaks:
88 dnl =
89 dnl = CFLAGS="-foo" ./configure
90 dnl =
91 dnl ========================================================
92 CFLAGS="${CFLAGS=}"
93 CXXFLAGS="${CXXFLAGS=}"
94 LDFLAGS="${LDFLAGS=}"
95 DLLFLAGS="${DLLFLAGS=}"
96 HOST_CFLAGS="${HOST_CFLAGS=}"
97 HOST_LDFLAGS="${HOST_LDFLAGS=}"
99 case "$target" in
100 *-cygwin*|*-mingw*)
101     # Check to see if we are really running in a msvc environemnt
102     _WIN32_MSVC=
103     AC_CHECK_PROGS(CC, cl)
104     if test "$CC" = "cl"; then
105         echo 'main() { return 0; }' > dummy.c
106         ${CC} -o dummy dummy.c >/dev/null 2>&1
107         if test $? = 0; then
108             _WIN32_MSVC=1
109             CXX=$CC
110         else
111             AC_MSG_WARN([$(CC) test failed.  Using normal feature tests])
112         fi
113         rm -f dummy dummy.o dummy.obj dummy.exe dummy.c
114     fi
115     ;;
116 *-msvc*)
117     _WIN32_MSVC=1
118     ;;
119 *-mks*)
120     _WIN32_MSVC=1
121     ;;
122 esac
124 if test -n "$_WIN32_MSVC"; then
125     SKIP_PATH_CHECKS=1
126     SKIP_COMPILER_CHECKS=1
127     SKIP_LIBRARY_CHECKS=1
130 dnl ========================================================
131 dnl =
132 dnl = Check options that may affect the compiler
133 dnl =
134 dnl ========================================================
135 dist_prefix='${MOD_DEPTH}/dist'
136 dist_bindir='${dist_prefix}/bin'
137 dist_includedir='${dist_prefix}/include/nspr'
138 dist_libdir='${dist_prefix}/lib'
139 dnl If the --includedir option was not specified, add '/nspr' to autoconf's
140 dnl default value of includedir.
141 if test "${includedir}" = '${prefix}/include'; then
142     includedir='${prefix}/include/nspr'
145 AC_ARG_WITH(dist-prefix,
146     [  --with-dist-prefix=DIST_PREFIX
147                           place build files in DIST_PREFIX [dist]],
148     dist_prefix=$withval)
150 AC_ARG_WITH(dist-bindir,
151     [  --with-dist-bindir=DIR  build execuatables in DIR [DIST_PREFIX/bin]],
152     dist_bindir=$withval)
154 AC_ARG_WITH(dist-includedir,
155     [  --with-dist-includedir=DIR
156                           build include files in DIR [DIST_PREFIX/include/nspr]],
157     dist_includedir=$withval)
159 AC_ARG_WITH(dist-libdir,
160     [  --with-dist-libdir=DIR  build library files in DIR [DIST_PREFIX/lib]],
161     dist_libdir=$withval)
163 AC_SUBST(dist_prefix)
164 AC_SUBST(dist_bindir)
165 AC_SUBST(dist_includedir)
166 AC_SUBST(dist_libdir)
168 dnl Check if NSPR is being compiled for Mozilla
169 dnl Let --with-arg override environment setting
171 AC_ARG_WITH(mozilla,
172     [  --with-mozilla          Compile NSPR with Mozilla support],
173     [   if test "$withval" = "yes"; then
174             AC_DEFINE(MOZILLA_CLIENT)
175             MOZILLA_CLIENT=1
176             else
177                 MOZILLA_CLIENT=
178             fi],
179     [   if test -n "$MOZILLA_CLIENT"; then
180                 AC_DEFINE(MOZILLA_CLIENT)
181             fi])
183 AC_ARG_ENABLE(optimize,
184     [  --enable-optimize(=val) Enable code optimizations (val, ie. -O2) ],
185     [ if test "$enableval" != "no"; then
186         MOZ_OPTIMIZE=1
187         if test -n "$enableval" && test "$enableval" != "yes"; then
188             _OPTIMIZE_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
189             _SAVE_OPTIMIZE_FLAGS=$_OPTIMIZE_FLAGS
190         fi
191       else
192         MOZ_OPTIMIZE=
193     fi ])
195 AC_ARG_ENABLE(debug,
196     [  --disable-debug         Do not compile in debugging symbols
197   --enable-debug(=val)    Enable debugging (debug flags val)],
198     [   if test "$enableval" = "no"; then
199             MOZ_DEBUG=
200         else
201             MOZ_DEBUG=1
202             if test -n "$enableval" && test "$enableval" != "yes"; then
203                 _DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
204                 _SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS
205             fi
206         fi])
208 AC_ARG_ENABLE(win32-target,
209     [  --enable-win32-target=\$t
210                           Specify win32 flavor. (WIN95 or WINNT)],
211     OS_TARGET=`echo $enableval | tr a-z A-Z`,
212     OS_TARGET=)
214 AC_ARG_ENABLE(debug-rtl,
215     [  --enable-debug-rtl      Use the MSVC debug runtime library],
216     [ if test "$enableval" = "yes"; then
217             USE_DEBUG_RTL=1
218       fi ])
220 AC_ARG_ENABLE(n32,
221     [  --enable-n32            Enable n32 ABI support (IRIX only)],
222     [ if test "$enableval" = "yes"; then
223         USE_N32=1
224       else if test "$enableval" = "no"; then
225         USE_N32=
226       fi
227     fi ])
229 AC_ARG_ENABLE(64bit,
230     [  --enable-64bit          Enable 64-bit support (on certain platforms)],
231     [ if test "$enableval" = "yes"; then
232             USE_64=1
233       fi ])
235 AC_ARG_ENABLE(mdupdate,
236     [  --enable-mdupdate       Enable use of certain compilers' mdupdate feature],
237     [ if test "$enableval" = "yes"; then
238             USE_MDUPDATE=1
239       fi ])
241 AC_ARG_ENABLE(cplus,
242     [  --enable-cplus          Enable some c++ api routines],
243     [ if test "$enableval" = "yes"; then
244             USE_CPLUS=1
245       fi]) 
247 AC_ARG_WITH(arm-kuser,
248     [  --with-arm-kuser        Use kuser helpers (Linux/ARM only)
249                           (Requires kernel 2.6.13 or later)],
250     [ if test "$withval" = "yes"; then
251             AC_DEFINE(_PR_ARM_KUSER)
252       fi ])
254 dnl ========================================================
255 dnl = Mac OS X SDK support
256 dnl ========================================================
257 AC_ARG_WITH(macos-sdk,
258     [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
259     MACOS_SDK_DIR=$withval)
261 AC_ARG_ENABLE(macos-target,
262              [  --enable-macos-target=VER
263                           Set the minimum MacOS version needed at runtime
264                           [10.2 for ppc, 10.4 for x86]],
265              [_MACOSX_DEPLOYMENT_TARGET=$enableval])
267 dnl ========================================================
268 dnl =
269 dnl = Set the threading model
270 dnl =
271 dnl ========================================================
272 case "$target" in
274 *-aix*)
275     case "${target_os}" in
276     aix3.2*)
277         USE_NSPR_THREADS=1
278         ;;
279     *)
280         USE_PTHREADS=1
281         ;;
282     esac
283     ;;
285 esac
287 dnl ========================================================
288 dnl =
289 dnl = Set the default C compiler
290 dnl =
291 dnl ========================================================
292 if test -z "$CC"; then
293     case "$target" in
295     *-aix*)
296         if test -z "$USE_NSPR_THREADS"; then
297             CC=xlc_r
298         else
299             CC=xlc
300         fi
301     ;;
303     *-hpux*)
304         CC=cc
305     ;;
307     *-irix*)
308         CC=cc
309     ;;
311     *-openvms*)
312         CC=cc
313     ;;
315     *-osf*)
316         CC=cc
317     ;;
319     *-solaris*)
320         CC=cc
321     ;;
323     esac
326 dnl ========================================================
327 dnl =
328 dnl = Set the default C++ compiler
329 dnl =
330 dnl ========================================================
331 if test -z "$CXX"; then
332     case "$target" in
334     *-aix*)
335         if test -z "$USE_NSPR_THREADS"; then
336             CXX=xlC_r
337         else
338             CXX=xlC
339         fi
340     ;;
342     *-hpux*)
343         case "${target_os}" in
344         hpux10.30)
345             CXX=aCC
346             ;;
347         hpux11.*)
348             CXX=aCC
349             ;;
350         *)
351             CXX=CC
352             ;;
353         esac
354     ;;
356     *-irix*)
357         CXX=CC
358     ;;
360     *-openvms*)
361         CXX=cxx
362     ;;
364     *-osf*)
365         CXX=cxx
366     ;;
368     *-solaris*)
369         CXX=CC
370     ;;
372     esac
375 if test -z "$SKIP_PATH_CHECKS"; then
376     AC_PATH_PROG(WHOAMI, $WHOAMI whoami, echo not_whoami)
379 if test -n "$MOZ_DEBUG"; then
380     AC_DEFINE(DEBUG)
381     DEFINES="$DEFINES -UNDEBUG"
383     case "${target_os}" in
384     beos*)
385         DEFINES="$DEFINES -DDEBUG_${USER}"
386         ;;
387     msvc*|mks*|cygwin*|mingw*|os2*)
388         DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`"
389         ;;
390     *) 
391         DEFINES="$DEFINES -DDEBUG_`$WHOAMI`"
392         ;;
393     esac
394 else
395     AC_DEFINE(NDEBUG)
396     DEFINES="$DEFINES -UDEBUG"
399 if test -z "$SKIP_COMPILER_CHECKS"; then
400 dnl ========================================================
401 dnl Checks for compilers.
402 dnl ========================================================
403 if test "$target" != "$host"; then
404     echo "cross compiling from $host to $target"
405     cross_compiling=yes
407     _SAVE_CC="$CC"
408     _SAVE_CFLAGS="$CFLAGS"
409     _SAVE_LDFLAGS="$LDFLAGS"
411     AC_MSG_CHECKING([for $host compiler])
412     AC_CHECK_PROGS(HOST_CC, $HOST_CC gcc cc /usr/ucb/cc, "")
413     if test -z "$HOST_CC"; then
414         AC_MSG_ERROR([no acceptable cc found in \$PATH])
415     fi
416     AC_MSG_RESULT([$HOST_CC])
417     if test -z "$HOST_CFLAGS"; then
418         HOST_CFLAGS="$CFLAGS"
419     fi
420     if test -z "$HOST_LDFLAGS"; then
421         HOST_LDFLAGS="$LDFLAGS"
422     fi
424     CC="$HOST_CC"
425     CFLAGS="$HOST_CFLAGS"
426     LDFLAGS="$HOST_LDFLAGS"
428     AC_MSG_CHECKING([whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
429     AC_TRY_COMPILE([], [return(0);], 
430         [ac_cv_prog_host_cc_works=1 AC_MSG_RESULT([yes])],
431         AC_MSG_ERROR([installation or configuration problem: $host compiler $HOST_CC cannot create executables.]) )
433     CC=$_SAVE_CC
434     CFLAGS=$_SAVE_CFLAGS
435     LDFLAGS=$_SAVE_LDFLAGS
437     case "$build:$target" in 
438       powerpc-apple-darwin8*:i?86-apple-darwin*)
439         dnl The Darwin cross compiler doesn't necessarily point itself at a
440         dnl root that has libraries for the proper architecture, it defaults
441         dnl to the system root.  The libraries in the system root on current
442         dnl versions of PPC OS X 10.4 aren't fat, so these target compiler
443         dnl checks will fail.  Fake a working SDK in that case.
444         _SAVE_CFLAGS=$CFLAGS 
445         _SAVE_CXXFLAGS=$CXXLAGS
446         CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CFLAGS"
447         CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CXXFLAGS"
448         ;;        
449     esac            
451     AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", echo)
452     unset ac_cv_prog_CC
453     AC_PROG_CC
454     if test -n "$USE_CPLUS"; then
455         AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", echo)
456         unset ac_cv_prog_CXX
457         AC_PROG_CXX
458     fi
460     case "$build:$target" in
461       powerpc-apple-darwin8*:i?86-apple-darwin*)
462         dnl Revert the changes made above.  From this point on, the target
463         dnl compiler will never be used without applying the SDK to CFLAGS
464         dnl (see --with-macos-sdk below).
465         CFLAGS=$_SAVE_CFLAGS
466         CXXFLAGS=$_SAVE_CXXFLAGS
467         ;;
468     esac
470     AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", echo)
471     AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", echo)
472     AC_CHECK_PROGS(AS, $AS "${target_alias}-as" "${target}-as", echo)
473     AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", echo)
474     AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", echo)
475     AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", echo)
477 else
478     AC_PROG_CC
479     if test -n "$USE_CPLUS"; then
480         if test "$CC" = "cl" -a -z "$CXX"; then
481             CXX=$CC
482         else        
483             AC_PROG_CXX
484         fi
485     fi
486     AC_PROG_CPP
487     AC_PROG_RANLIB
488     AC_PATH_PROGS(AS, as, $CC)
489     AC_PATH_PROGS(AR, ar, echo not_ar)
490     AC_PATH_PROGS(LD, ld link, echo not_ld)
491     AC_PATH_PROGS(STRIP, strip, echo not_strip)
492     AC_PATH_PROGS(WINDRES, windres, echo not_windres)
493     if test -z "$HOST_CC"; then
494         HOST_CC="$CC"
495     fi
496     if test -z "$HOST_CFLAGS"; then
497         HOST_CFLAGS="$CFLAGS"
498     fi
501 if test "$GCC" = "yes"; then
502     GNU_CC=1
504 if test "$GXX" = "yes"; then
505     GNU_CXX=1
507 if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then
508     GNU_AS=1
510 rm -f a.out
512 case "$build:$target" in
513     i?86-apple-darwin*:powerpc-apple-darwin*)
514         dnl cross_compiling will have erroneously been set to "no" in this
515         dnl case, because the x86 build host is able to run ppc code in a
516         dnl translated environment, making a cross compiler appear native.
517         cross_compiling=yes
518         ;;
519 esac
521 if test "$cross_compiling"  = "yes"; then
522     CROSS_COMPILE=1
523 else
524     CROSS_COMPILE=
527 dnl ========================================================
528 dnl Check for gcc -pipe support
529 dnl ========================================================
530 AC_MSG_CHECKING([for gcc -pipe support])
531 if test -n "$GNU_CC" && test -n "$GNU_CXX" && test -n "$GNU_AS"; then
532     echo '#include <stdio.h>' > dummy-hello.c
533     echo 'int main() { printf("Hello World\n"); return 0; }' >> dummy-hello.c
534     ${CC} -S dummy-hello.c -o dummy-hello.s 2>&5
535     cat dummy-hello.s | ${AS} -o dummy-hello.S - 2>&5
536     if test $? = 0; then
537         _res_as_stdin="yes"
538     else
539         _res_as_stdin="no"
540     fi
541     if test "$_res_as_stdin" = "yes"; then
542         _SAVE_CFLAGS=$CFLAGS
543         CFLAGS="$CFLAGS -pipe"
544         AC_TRY_COMPILE( [ #include <stdio.h> ],
545             [printf("Hello World\n");],
546             [_res_gcc_pipe="yes"],
547             [_res_gcc_pipe="no"] )
548         CFLAGS=$_SAVE_CFLAGS
549     fi
550     if test "$_res_as_stdin" = "yes" && test "$_res_gcc_pipe" = "yes"; then
551         _res="yes";
552         CFLAGS="$CFLAGS -pipe"
553         CXXFLAGS="$CXXFLAGS -pipe"
554     else
555         _res="no"
556     fi
557     rm -f dummy-hello.c dummy-hello.s dummy-hello.S dummy-hello a.out
558     AC_MSG_RESULT([$_res])
559 else
560     AC_MSG_RESULT([no])
563 dnl ===============================================================
564 dnl Check for .hidden assembler directive and visibility attribute.
565 dnl Borrowed from glibc configure.in
566 dnl ===============================================================
567 if test "$GNU_CC"; then
568     AC_CACHE_CHECK(for visibility(hidden) attribute,
569         ac_cv_visibility_hidden,
570         [cat > conftest.c <<EOF
571         int foo __attribute__ ((visibility ("hidden"))) = 1;
573         ac_cv_visibility_hidden=no
574         if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
575             if grep '\.hidden.*foo' conftest.s >/dev/null; then
576                 ac_cv_visibility_hidden=yes
577             fi
578         fi
579         rm -f conftest.[cs]
580         ])
581     if test "$ac_cv_visibility_hidden" = "yes"; then
582         AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
583         AC_CACHE_CHECK(for visibility pragma support,
584             ac_cv_visibility_pragma,
585             [cat > conftest.c <<EOF
586 #pragma GCC visibility push(hidden)
587             int foo_hidden = 1;
588 #pragma GCC visibility push(default)
589             int foo_default = 1;
591             ac_cv_visibility_pragma=no
592             if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
593                 if grep '\.hidden.*foo_hidden' conftest.s >/dev/null; then
594                     if ! grep '\.hidden.*foo_default' conftest.s > /dev/null; then
595                         ac_cv_visibility_pragma=yes
596                     fi
597                 fi
598             fi
599             rm -f conftest.[cs]
600             ])
601         if test "$ac_cv_visibility_pragma" = "yes"; then
602             AC_DEFINE(HAVE_VISIBILITY_PRAGMA)
603             # To work around a build problem on Linux x86-64 (Bugzilla bug
604             # 293438), we use the -fvisibility=hidden flag.  This flag is less
605             # optimal than #pragma GCC visibility push(hidden) because the flag
606             # assumes that symbols defined outside the current source file have
607             # the default visibility.  This has the advantage that we don't need
608             # to wrap system header files, but has the disadvantage that calls
609             # to hidden symbols defined in other source files cannot be
610             # optimized by the compiler.  The -fvisibility=hidden flag does
611             # hide and export symbols correctly.
612             #VISIBILITY_FLAGS='-I$(dist_includedir)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
613             #WRAP_SYSTEM_INCLUDES=1
614             VISIBILITY_FLAGS="-fvisibility=hidden"
615             WRAP_SYSTEM_INCLUDES=
616         fi
617     fi
618 fi # GNU_CC
620 fi # SKIP_COMPILER_CHECKS
622 dnl ========================================================
623 dnl Checks for programs.
624 dnl ========================================================
625 if test -z "$SKIP_PATH_CHECKS"; then
626     AC_PATH_PROGS(PERL, perl5 perl, echo not_perl)
627 elif test -z "$PERL"; then
628     PERL=perl
631 dnl ========================================================
632 dnl Default platform specific options
633 dnl ========================================================
634 OBJ_SUFFIX=o
635 LIB_SUFFIX=a
636 DLL_SUFFIX=so
637 ASM_SUFFIX=s
638 MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
639 PR_MD_ASFILES=
640 PR_MD_CSRCS=
641 PR_MD_ARCH_DIR=unix
642 AR_FLAGS='cr $@'
643 AS='$(CC)'
644 ASFLAGS='$(CFLAGS)'
646 if test -n "$CROSS_COMPILE"; then
647     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
648     OS_RELEASE=
649     OS_TEST="${target_cpu}"
650     case "${target_os}" in
651         linux*)       OS_ARCH=Linux ;;
652         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
653         mingw*)       OS_ARCH=WINNT ;;
654         darwin*)      OS_ARCH=Darwin ;;
655     esac
656 else
657     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
658     OS_RELEASE=`uname -r`
659     OS_TEST=`uname -m`
662 if test "$OS_ARCH" = "IRIX64"; then
663     OS_ARCH=IRIX
666 if test "$OS_ARCH" = "AIX"; then
667     OS_RELEASE=`uname -v`.`uname -r`
670 if test "$OS_ARCH" = "FreeBSD"; then
671     OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
674 if test "$OS_ARCH" = "Linux"; then
675     OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
676     OS_RELEASE=`echo $OS_RELEASE | awk -F\. '{ print $1 "." $2 }'`
679 if test "$OS_ARCH" = "OpenVMS"; then
680     OS_RELEASE=`uname -v`
683 #######################################################################
684 # Master "Core Components" macros for getting the OS target           #
685 #######################################################################
688 # Note: OS_TARGET should be specified on the command line for gmake.
689 # When OS_TARGET=WIN95 is specified, then a Windows 95 target is built.
690 # The difference between the Win95 target and the WinNT target is that
691 # the WinNT target uses Windows NT specific features not available
692 # in Windows 95. The Win95 target will run on Windows NT, but (supposedly)
693 # at lesser performance (the Win95 target uses threads; the WinNT target
694 # uses fibers).
696 # When OS_TARGET=WIN16 is specified, then a Windows 3.11 (16bit) target
697 # is built. See: win16_3.11.mk for lots more about the Win16 target.
699 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
700 # cross-compilation.
704 # The following hack allows one to build on a WIN95 machine (as if
705 # s/he were cross-compiling on a WINNT host for a WIN95 target).
706 # It also accomodates for MKS's uname.exe.  If you never intend
707 # to do development on a WIN95 machine, you don't need this hack.
709 case "$OS_ARCH" in
710 WIN95)
711     OS_ARCH=WINNT
712     OS_TARGET=WIN95
713     ;;
714 Windows_95)
715     OS_ARCH=Windows_NT
716     OS_TARGET=WIN95
717     ;;
718 Windows_98)
719     OS_ARCH=Windows_NT
720     OS_TARGET=WIN95
721     ;;
722 CYGWIN_9*|CYGWIN_ME*)
723     OS_ARCH='CYGWIN_NT-4.0'
724     OS_TARGET=WIN95
725     ;;
726 OS_2)
727     OS_ARCH=OS2
728     OS_TARGET=OS2
729     ;;
730 esac
733 # On WIN32, we also define the variable CPU_ARCH.
736 case "$OS_ARCH" in
737 WINNT)
738     CPU_ARCH=`uname -p`
739     if test "$CPU_ARCH" = "I386"; then
740         CPU_ARCH=x86
741     fi
742     ;;
743 Windows_NT)
745 # If uname -s returns "Windows_NT", we assume that we are using
746 # the uname.exe in MKS toolkit.
748 # The -r option of MKS uname only returns the major version number.
749 # So we need to use its -v option to get the minor version number.
750 # Moreover, it doesn't have the -p option, so we need to use uname -m.
752     OS_ARCH=WINNT
753     OS_MINOR_RELEASE=`uname -v`
754     if test "$OS_MINOR_RELEASE" = "00"; then
755         OS_MINOR_RELEASE=0
756     fi
757     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
758     CPU_ARCH=`uname -m`
759     #
760     # MKS's uname -m returns "586" on a Pentium machine.
761     #
762     if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
763         CPU_ARCH=x86
764     fi
765     ;;
766 CYGWIN_NT*|MINGW*_NT*)
768 # If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
769 # the uname.exe in the Cygwin tools.
770 # If uname -s returns MINGW32_NT-5.1, we assume that we are using
771 # the uname.exe in the MSYS tools.
773     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
774     OS_ARCH=WINNT
775     CPU_ARCH=`uname -m`
776     #
777     # Cygwin's uname -m returns "i686" on a Pentium Pro machine.
778     #
779     if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
780         CPU_ARCH=x86
781     fi
782     ;;
783 esac
785 if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then
786     OS_TARGET=WIN95
787     if test -n "$MOZ_DEBUG"; then
788         USE_DEBUG_RTL=1
789     fi
791 if test -z "$OS_TARGET"; then
792     OS_TARGET=$OS_ARCH
794 if test "$OS_TARGET" = "WIN95"; then
795     OS_RELEASE="4.0"
797 if test "$OS_TARGET" = "WIN16"; then
798     OS_RELEASE=
800 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
802 dnl ========================================================
803 dnl Enable high-memory support on OS/2 by default.
804 dnl ========================================================
805 AC_ARG_ENABLE(os2-high-mem,
806     [  --disable-os2-high-mem  Disable high-memory support on OS/2],
807     [ if test "$enableval" = "no"; then
808         MOZ_OS2_HIGH_MEMORY=
809       else
810         MOZ_OS2_HIGH_MEMORY=1
811       fi ])
813 dnl ========================================================
814 dnl Override of system specific host options
815 dnl ========================================================
816 case "$host" in
817 *-mingw*)
818     NSINSTALL=nsinstall
819     ;;
820 *-cygwin*|*-msvc*|*-mks*)
821     NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
822     if test `echo "${PATH}" | grep -c \;` = 0; then
823         CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
824     fi
825     ;;
826 *-beos*)
827     HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
828     ;;
829 *os2*)
830     ;;
832     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
833     ;;
834 esac
836 dnl ========================================================
837 dnl Override of system specific target options
838 dnl ========================================================
839 case "$target" in
841 *-aix*)
842     AC_DEFINE(XP_UNIX)
843     AC_DEFINE(AIX)
844     AC_DEFINE(SYSV)
845     DSO_LDOPTS='-brtl -bnortllib -bM:SRE -bnoentry -bexpall -blibpath:/usr/lib:/lib'
846     AC_CHECK_HEADER(sys/atomic_op.h, AC_DEFINE(AIX_HAVE_ATOMIC_OP_H))
847     case "${target_os}" in
848     aix3.2*)
849         AC_DEFINE(AIX_RENAME_SELECT)
850         AC_DEFINE(_PR_NO_LARGE_FILES)
851         AIX_LINK_OPTS='-bnso -berok'
852         PR_MD_ASFILES=os_AIX.s
853         ;;
854     aix4.1*)
855         AC_DEFINE(AIX_TIMERS)
856         AC_DEFINE(_PR_NO_LARGE_FILES)
857         AC_DEFINE(AIX4_1)
858         MKSHLIB=
859         DSO_LDOPTS=
860         AIX_LINK_OPTS='-bnso -berok'
861         LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)_shr'
862         LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)_shr'
863         ;;
864     aix4.2*)
865         AC_DEFINE(AIX_TIMERS)
866         AC_DEFINE(_PR_HAVE_OFF64_T)
867         AIX_LINK_OPTS='-brtl -bnso -berok'
868         ;;
869     aix4.3*)
870         AC_DEFINE(AIX_TIMERS)
871         AC_DEFINE(_PR_HAVE_OFF64_T)
872         AC_DEFINE(AIX4_3_PLUS)
873         AC_DEFINE(HAVE_SOCKLEN_T)
874         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
875         USE_IPV6=1
876         AIX_LINK_OPTS='-brtl -bnso -berok'
877         ;;
878     *)
879         AC_DEFINE(AIX_TIMERS)
880         AC_DEFINE(_PR_HAVE_OFF64_T)
881         AC_DEFINE(AIX4_3_PLUS)
882         AC_DEFINE(HAVE_SOCKLEN_T)
883         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
884         USE_IPV6=1
885         AIX_LINK_OPTS='-brtl -bnso -berok'
886         ;;
887     esac
888     CFLAGS="$CFLAGS -qro -qroconst"
889     AIX_WRAP='$(DIST)/lib/aixwrap.o'
890     AIX_TMP='./_aix_tmp.o'
891     if test -n "$USE_64"; then
892         MDCPUCFG_H=_aix64.cfg
893         OBJECT_MODE=64
894     else
895         MDCPUCFG_H=_aix32.cfg
896     fi
897     PR_MD_CSRCS=aix.c
898     RESOLVE_LINK_SYMBOLS=1
899     ;;
900         
901 *-beos*)
902     AC_DEFINE(XP_BEOS)
903     AC_DEFINE(BeOS)
904     AC_DEFINE(BEOS)
905     AC_DEFINE(_POSIX_SOURCE)
906     DSO_LDOPTS=-nostart
907     MDCPUCFG_H=_beos.cfg
908     USE_BTHREADS=1
909     PR_MD_ARCH_DIR=beos
910     RESOLVE_LINK_SYMBOLS=1
911     case "${target_cpu}" in
912     i*86)
913         _OPTIMIZE_FLAGS=-O2
914         _DEBUG_FLAGS='-gdwarf-2 -O0'
915         MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@'
916         AC_CHECK_LIB(bind, gethostbyaddr, [OS_LIBS="$OS_LIBS -lbind -lsocket"])
917         ;;
918     powerpc)
919         CC=mwcc
920         CCC=mwcc
921         LD=mwld
922         DSO_LDOPTS='-xms -export pragma -init _init_routine_ -term _term_routine_ -lroot -lnet /boot/develop/lib/ppc/glue-noinit.a /boot/develop/lib/ppc/init_term_dyn.o /boot/develop/lib/ppc/start_dyn.o'
923         _OPTIMIZE_FLAGS=-O2    
924         _DEBUG_FLAGS='-g -O0'
925         ;;
926     esac
927     ;;
929 *-bsdi*)
930     AC_DEFINE(XP_UNIX)
931     AC_DEFINE(BSDI)
932     AC_DEFINE(NEED_BSDREGEX)
934     CFLAGS="$CFLAGS -Wall -Wno-format"
935     CXXFLAGS="$CXXFLAGS -Wall -Wno-format"
937     if echo "$OS_TEST" | grep -c 86 >/dev/null; then
938         CPU_ARCH=x86
939     elif echo "$OS_TEST" | grep -c sparc >/dev/null; then 
940         CPU_ARCH=sparc
941     fi
943     MDCPUCFG_H=_bsdi.cfg
944     PR_MD_CSRCS=bsdi.c
946     DSO_LDOPTS=-r
948     case "$target_os" in
949     bsdi1.1*)
950         AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
951         AC_DEFINE(_PR_STAT_HAS_ONLY_ST_ATIME)
952         AC_DEFINE(_PR_NEED_H_ERRNO)
953         MKSHLIB=
954         DSO_CFLAGS=
955         DSO_LDOPTS=
956         ;;
958     bsdi2.1*)
959         AC_DEFINE(_PR_TIMESPEC_HAS_TS_SEC)
960         AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
961         AC_DEFINE(HAVE_DLL)
962         AC_DEFINE(USE_DLFCN)
963         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
964         PR_MD_ASFILES=os_BSD_OS_386_2.s
965         ;;
967     bsdi4.* | bsdi5.*)
968         AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
969         AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
970         AC_DEFINE(HAVE_DLL)
971         AC_DEFINE(USE_DLFCN)
972         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
973         MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
974         DSO_CFLAGS=-fPIC
975         DSO_LDOPTS='-shared -Wl,-soname,$(@:$(OBJDIR)/%.so=%.so)'
976         STRIP="$STRIP -d"
977         case "$target_os" in
978         bsdi4.2* | bsdi4.3* | bsdi5.*)
979             AC_DEFINE(_PR_HAVE_GETPROTO_R)
980             AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER)
981             ;;
982         esac
983         ;;
984     *)
985         AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
986         AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
987         AC_DEFINE(HAVE_DLL)
988         AC_DEFINE(USE_DLFCN)
989         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
990         ;;
991     esac
993     ;;
995 *-darwin*)
996     AC_DEFINE(XP_UNIX)
997     AC_DEFINE(DARWIN)
998     AC_DEFINE(HAVE_BSD_FLOCK)
999     AC_DEFINE(HAVE_SOCKLEN_T)
1000     CFLAGS="$CFLAGS -Wmost -fno-common"
1001     case "${target_cpu}" in
1002         i*86*)
1003             if test -n "$USE_64"; then
1004                 CPU_ARCH=x86_64
1005                 CC="$CC -arch x86_64"
1006             else        
1007                 CPU_ARCH=i386
1008             fi
1009             ;;
1010         *)
1011             CPU_ARCH=ppc
1012             ;;
1013     esac
1014     DSO_CFLAGS=-fPIC
1015     DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@ -headerpad_max_install_names'
1016     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1017     STRIP="$STRIP -x -S"
1018     DLL_SUFFIX=dylib
1019     USE_PTHREADS=1
1020     MDCPUCFG_H=_darwin.cfg
1021     PR_MD_CSRCS=darwin.c
1022     PR_MD_ASFILES=os_Darwin.s
1024     # Add Mac OS X support for loading CFM & CFBundle plugins
1025     if test -f /System/Library/Frameworks/Carbon.framework/Carbon; then
1026         AC_DEFINE(XP_MACOSX)
1027         OS_TARGET=MacOSX
1029         if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
1030             dnl Use the specified value
1031             export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
1032         elif test -z "$MACOSX_DEPLOYMENT_TARGET" ; then
1033             dnl No value specified on the command line or in the environment,
1034             dnl use the lesser of the library's minimum or the architecture's
1035             dnl minimum.
1036             case "${target_cpu}" in
1037                 powerpc*)
1038                     dnl Architecture minimum 10.2
1039                     export MACOSX_DEPLOYMENT_TARGET=10.2
1040                     ;;
1041                 i*86*)
1042                     dnl Architecture minimum 10.4
1043                     export MACOSX_DEPLOYMENT_TARGET=10.4
1044                     ;;
1045             esac
1046         fi
1048         dnl MACOS_SDK_DIR will be set to the SDK location whenever one is
1049         dnl in use.  NEXT_ROOT will be set and exported if it's needed for
1050         dnl ld.
1052         if test "$MACOS_SDK_DIR"; then
1053             dnl Sync this section with the one in Mozilla's top level.
1055             if test ! -d "$MACOS_SDK_DIR"; then
1056                 AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
1057 specify a valid SDK.  SDKs are installed when the optional cross-development
1058 tools are selected during the Xcode/Developer Tools installation.])
1059             fi
1061             changequote(,)
1062             CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
1063             GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
1064             GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
1065             changequote([,])
1066             GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
1067             if test "$GCC_VERSION_MAJOR" -lt "4" ; then
1068                 SDK_C_FRAMEWORK="-F${MACOS_SDK_DIR}/System/Library/Frameworks"
1069                 if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then
1070                     SDK_C_FRAMEWORK="$SDK_C_FRAMEWORK -F${MACOS_SDK_DIR}/Library/Frameworks"
1071                 fi
1073                 SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include ${SDK_C_FRAMEWORK}"
1075                 CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}"
1077                 dnl CPP needs to be set for AC_CHECK_HEADER.
1078                 CPP="$CPP -nostdinc ${SDK_C_INCLUDE}"
1080                 changequote(,)
1081                 HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
1082                 changequote([,])
1083                 if test "$HOST_DARWIN_MAJOR" -lt 9 ; then
1084                     dnl The build host is running Tiger (10.4) or earlier.
1085                     dnl ld support for -syslibroot is compiler-agnostic, but
1086                     dnl only available on Tiger and later.  On Tiger and
1087                     dnl earlier build hosts, just rely on NEXT_ROOT, because
1088                     dnl it's not been shown to cause any problems.
1089                     MACOS_SDK_LIBS="-L${MACOS_SDK_DIR}/usr/lib/gcc/darwin -L${MACOS_SDK_DIR}/usr/lib/gcc/darwin/${GCC_VERSION_FULL} -L${MACOS_SDK_DIR}/usr/lib ${SDK_C_FRAMEWORK}"
1090                 else
1091                     dnl The build host is running Leopard (10.5) or later.
1092                     dnl With NEXT_ROOT set, the linker will still not apply
1093                     dnl it when resolving dependencies.  This causes problems
1094                     dnl on Leopard, where an SDK depends on frameworks which
1095                     dnl were present in earlier OS releases (and the associated
1096                     dnl SDK) but not in Leopard.  -syslibroot does not have
1097                     dnl this problem, but it results in harmless warnings when
1098                     dnl NEXT_ROOT is set.  NEXT_ROOT needs to remain set even
1099                     dnl on Leopard because the compiler uses it too.
1100                     MACOS_SDK_LIBS="-Wl,-syslibroot,${MACOS_SDK_DIR}"
1101                 fi
1103                 dnl LDFLAGS is for the utilities built in config (now and
1104                 dnl nsinstall).  DSO_LDOPTS is used when linking shared
1105                 dnl libraries.
1106                 LDFLAGS="${MACOS_SDK_LIBS} $LDFLAGS"
1107                 DSO_LDOPTS="${MACOS_SDK_LIBS} $DSO_LDOPTS"
1108                 export NEXT_ROOT=$MACOS_SDK_DIR
1110                 if test -n "$CROSS_COMPILE" ; then
1111                     dnl NEXT_ROOT will be in the environment, but it
1112                     dnl shouldn't be set for the build host.  HOST_CXX is
1113                     dnl presently unused.
1114                     HOST_CC="NEXT_ROOT= $HOST_CC"
1115                     HOST_CXX="NEXT_ROOT= $HOST_CXX"
1116                 fi
1117             else
1118                 dnl gcc >= 4.0 uses different paths than above, but knows
1119                 dnl how to find them itself.
1120                 CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
1122                 dnl CPP needs to be set for AC_CHECK_HEADER.
1123                 CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
1125                 dnl If gcc >= 4.0.0, we're guaranteed to be on Tiger, which
1126                 dnl has an ld that supports -syslibroot.  Don't set
1127                 dnl NEXT_ROOT because it will be ignored and cause
1128                 dnl warnings when -syslibroot is specified.
1129                 dnl
1130                 dnl Both LDFLAGS and DSO_LDOPTS are set here, see the
1131                 dnl gcc < 4.0 case for the explanation.
1132                 if test "$GCC_VERSION_FULL" != "4.0.0" ; then
1133                     dnl gcc > 4.0.0 will pass -syslibroot to ld automatically
1134                     dnl based on the -isysroot it receives.
1135                     LDFLAGS="$LDFLAGS -isysroot ${MACOS_SDK_DIR}"
1136                     DSO_LDOPTS="$DSO_LDOPTS -isysroot ${MACOS_SDK_DIR}"
1137                 else
1138                     dnl gcc 4.0.0 doesn't pass -syslibroot to ld, it needs
1139                     dnl to be explicit.
1140                     LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
1141                     DSO_LDOPTS="$DSO_LDOPTS -Wl,-syslibroot,${MACOS_SDK_DIR}"
1142                 fi
1143             fi
1144         fi
1145     fi
1146     ;;
1148 *-dgux*)
1149     AC_DEFINE(XP_UNIX)
1150     AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
1151     AC_DEFINE(SVR4)
1152     AC_DEFINE(SYSV)
1153     AC_DEFINE(DGUX)
1154     AC_DEFINE(_DGUX_SOURCE)
1155     AC_DEFINE(_POSIX4A_DRAFT6_SOURCE)
1156     DSO_LDOPTS=-G
1157     _OPTIMIZE_FLAGS=-O2
1158     _DEBUG_FLAGS=
1159     MDCPUCFG_H=_dgux.cfg
1160     PR_MD_CSRCS=dgux.c
1161     ;;
1163 *-freebsd*)
1164     if test -z "$USE_NSPR_THREADS"; then
1165         USE_PTHREADS=1
1166     fi
1167     AC_DEFINE(XP_UNIX)
1168     AC_DEFINE(FREEBSD)
1169     AC_DEFINE(HAVE_BSD_FLOCK)
1170     AC_DEFINE(HAVE_SOCKLEN_T)
1171     CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall"
1172     MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
1173     if test "$MOZ_OBJFORMAT" = "elf"; then
1174         DLL_SUFFIX=so
1175     else
1176         DLL_SUFFIX=so.1.0
1177     fi
1178     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1179     DSO_CFLAGS=-fPIC
1180     DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
1181     MDCPUCFG_H=_freebsd.cfg
1182     PR_MD_CSRCS=freebsd.c
1183     ;;
1185 *-hpux*)
1186     AC_DEFINE(XP_UNIX)
1187     AC_DEFINE(HPUX)
1188     AC_DEFINE(_HPUX_SOURCE)
1189     # OSF1 and HPUX report the POLLHUP event for a socket when the
1190     # shutdown(SHUT_WR) operation is called for the remote end, even though
1191     # the socket is still writeable. Use select(), instead of poll(), to
1192     # workaround this problem.
1193     AC_DEFINE(_PR_POLL_WITH_SELECT)
1194     AC_DEFINE(_USE_BIG_FDS)
1195     DSO_LDOPTS='-b +h $(notdir $@)'
1196     PR_MD_CSRCS=hpux.c
1197     if test "$OS_TEST" = "ia64"; then
1198         DLL_SUFFIX=so
1199         DSO_LDOPTS="$DSO_LDOPTS +b '\$\$ORIGIN'"
1200         CPU_ARCH_TAG=_$OS_TEST 
1201         if test -z "$USE_64"; then
1202             COMPILER_TAG=_32
1203         fi
1204         PR_MD_ASFILES=os_HPUX_ia64.s
1205     else
1206         AC_DEFINE(hppa)
1207         DLL_SUFFIX=sl
1208         PR_MD_ASFILES=os_HPUX.s
1209     fi
1210     if test -n "$USE_64"; then
1211         MDCPUCFG_H=_hpux64.cfg
1212     else
1213         MDCPUCFG_H=_hpux32.cfg
1214     fi
1215     if test -z "$GNU_CC"; then
1216         CC="$CC -Ae"
1217         CXX="$CXX -ext"
1218         DSO_CFLAGS=+Z
1219     else
1220         DSO_CFLAGS=-fPIC
1221     fi
1223     if test -n "$MOZILLA_CLIENT"; then
1224         DEFAULT_IMPL_STRATEGY=_EMU
1225     fi
1227     if echo "$OS_RELEASE" | grep ^A.09 >/dev/null; then
1228         AC_DEFINE(_PR_NEED_H_ERRNO)
1229         AC_DEFINE(HPUX9)
1230         DEFAULT_IMPL_STRATEGY=_EMU
1231         USE_NSPR_THREADS=1
1232     fi
1234     if echo "$OS_RELEASE" | egrep '^(A.09|B.10)' >/dev/null; then
1235         AC_DEFINE(_PR_NO_LARGE_FILES)
1236     fi
1238     if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
1239         AC_DEFINE(_PR_NEED_H_ERRNO)
1240     fi
1242     if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
1243         AC_DEFINE(HAVE_INT_LOCALTIME_R)
1244     fi
1246     if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11)' >/dev/null; then
1247         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1248     fi
1250     # HP-UX 11i v2 (B.11.23) or higher
1251     changequote(<<,>>)
1252     case "$OS_RELEASE" in
1253     [C-Z]*|B.[2-9]*|B.1[2-9]*|B.11.[3-9]*|B.11.2[3-9]*)
1254         USE_IPV6=1
1255         ;;
1256     esac
1257     changequote([,])
1259     if test "$OS_RELEASE" = "B.10.01"; then
1260         AC_DEFINE(HPUX10)
1261         DEFAULT_IMPL_STRATEGY=_EMU
1262     fi
1264     if test "$OS_RELEASE" = "B.10.10"; then
1265         AC_DEFINE(HPUX10)
1266         AC_DEFINE(HPUX10_10)
1267         DEFAULT_IMPL_STRATEGY=_PTH
1268     fi
1270     if test "$OS_RELEASE" = "B.10.20"; then
1271         AC_DEFINE(HPUX10)
1272         AC_DEFINE(HPUX10_20)
1273         if test -z "$GNU_CC"; then
1274             CFLAGS="$CFLAGS +DAportable +DS1.1"
1275             CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
1276         fi
1277         DEFAULT_IMPL_STRATEGY=_PTH
1278     fi
1280     if test "$OS_RELEASE" = "B.10.30"; then
1281         AC_DEFINE(HPUX10)
1282         AC_DEFINE(HPUX10_30)
1283         if test -z "$GNU_CC"; then
1284             CFLAGS="$CFLAGS +DAportable +DS1.1"
1285             CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
1286         fi
1287         DEFAULT_IMPL_STRATEGY=_PTH
1288     fi
1290     if echo "$OS_RELEASE" | grep ^B.11 >/dev/null; then
1291         AC_DEFINE(HPUX10)
1292         AC_DEFINE(HPUX11)
1293         AC_DEFINE(_LARGEFILE64_SOURCE)
1294         AC_DEFINE(_PR_HAVE_OFF64_T)
1295         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1296         if test -z "$GNU_CC"; then
1297             if test -z "$USE_64"; then
1298                 if test "$OS_TEST" = "ia64"; then
1299                     CFLAGS="$CFLAGS +DD32"
1300                     CXXFLAGS="$CXXFLAGS +DD32"
1301                 else
1302                     CFLAGS="$CFLAGS +DAportable +DS2.0"
1303                     CXXFLAGS="$CXXFLAGS +DAportable +DS2.0"
1304                 fi
1305             else
1306                 if test "$OS_TEST" = "ia64"; then
1307                     CFLAGS="$CFLAGS +DD64"
1308                     CXXFLAGS="$CXXFLAGS +DD64"
1309                 else
1310                     CFLAGS="$CFLAGS +DA2.0W +DS2.0"
1311                     CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0"
1312                 fi
1313             fi
1314         fi
1315         DEFAULT_IMPL_STRATEGY=_PTH
1316     fi
1318     if test "$DEFAULT_IMPL_STRATEGY" = "_EMU"; then
1319         USE_NSPR_THREADS=1
1320         USE_PTHREADS=
1321         USE_USER_PTHREADS=
1322     elif test "$DEFAULT_IMPL_STRATEGY" = "_PTH"; then
1323         USE_PTHREADS=1
1324         if test "$USE_NSPR_THREADS"; then
1325             USE_PTHREADS=
1326         fi
1327         if test "$USE_USER_PTHREADS"; then
1328             USE_PTHREADS=
1329         fi
1330     fi
1331     ;;
1333 *-irix*)
1334     AC_DEFINE(XP_UNIX)
1335     AC_DEFINE(IRIX)
1336     AC_DEFINE(SVR4)
1337     AC_DEFINE(_SGI_MP_SOURCE)
1338     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1339     PR_MD_CSRCS=irix.c
1340     PR_MD_ASFILES=os_Irix.s
1341     MKSHLIB='$(LD) $(DSO_LDOPTS) -rdata_shared -shared -soname $(notdir $@) -o $@'
1342     STRIP="$STRIP -f"
1343     RESOLVE_LINK_SYMBOLS=1
1344     if test -n "$USE_64"; then
1345         MDCPUCFG_H=_irix64.cfg
1346     else
1347         MDCPUCFG_H=_irix32.cfg
1348     fi
1349     case "${target_os}" in
1350     irix6*)
1351         AC_DEFINE(IRIX6)
1352         USE_PTHREADS=1
1353         USE_N32=1
1354         COMPILER_TAG=_n32
1355         IMPL_STRATEGY=_PTH
1356         ;;
1357     irix5*)
1358         AC_DEFINE(IRIX5)
1359         USE_NSPR_THREADS=1
1360         ;;
1361     *)
1362         USE_PTHREADS=1
1363         USE_N32=1
1364         ;;
1365     esac
1366     if test "$GNU_CC"; then
1367         dnl
1368         dnl If we are using gcc with native binutils, we need to
1369         dnl suppress the
1370         dnl #lineno "filename" num num
1371         dnl lines, which confuse IRIX native as.  Add -Wp,-P to the
1372         dnl gcc command line, which passes -P to the preprocessor.
1373         dnl
1374             AS='$(CC) -Wp,-P -x assembler-with-cpp -D_ASM -mips2 $(INCLUDES)'
1375             CFLAGS="$CFLAGS -Wall -Wno-format"
1376             _OPTIMIZE_FLAGS="-O6"
1377     else
1378             if test -n "$USE_N32"; then
1379                 AS='as -D_ASM $(INCLUDES) -n32'
1380             else
1381                 AS='as -D_ASM $(INCLUDES)'
1382             fi
1383             CFLAGS="$CFLAGS -fullwarn -xansi"
1384             if test "$USE_N32"; then
1385                 _OPTIMIZE_FLAGS="-O -OPT:Olimit=4000"
1386             else
1387                 _OPTIMIZE_FLAGS="-O -Olimit 4000"
1388             fi
1389             if test "$USE_MDUPDATE"; then
1390                 CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
1391             fi
1392             case "${target}" in
1393             *-irix6.*)
1394                 CFLAGS="$CFLAGS -multigot"
1395                 DSO_LDOPTS="-no_unresolved"
1396                 if test "$USE_N32"; then
1397                         CFLAGS="$CFLAGS -n32 -woff 1209"
1398                         DSO_LDOPTS="$DSO_LDOPTS -n32"
1399                 else
1400                         if test "$USE_64"; then
1401                             CFLAGS="$CFLAGS -64"
1402                         else
1403                             CFLAGS="$CFLAGS -32"
1404                         fi
1405                 fi
1406                 ;;
1407             *)
1408                 CFLAGS="$CFLAGS -xgot"
1409                 ;;
1410             esac
1411     fi
1412     if test "${target_os}" = "irix5.3"; then
1413             AC_DEFINE(IRIX5_3)
1414     fi
1415     case "${target_os}" in
1416         irix6.5)
1417             if test -z "$GNU_CC"; then
1418                     CFLAGS="$CFLAGS -mips3"
1419             fi
1420             AC_DEFINE(_PR_HAVE_GETPROTO_R)
1421             AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER)
1422             AC_DEFINE(_PR_HAVE_SGI_PRDA_PROCMASK)
1423             ;;
1424         irix5*)
1425             ;;
1426         *)
1427             AC_DEFINE(_PR_HAVE_SGI_PRDA_PROCMASK)
1428             ;;
1429         esac
1430     ;;
1432 *-linux*|*-gnu*|*-k*bsd*-gnu)
1433     if test -z "$USE_NSPR_THREADS"; then
1434         USE_PTHREADS=1
1435         IMPL_STRATEGY=_PTH
1436     fi
1437     AC_DEFINE(XP_UNIX)
1438     AC_DEFINE(_GNU_SOURCE)
1439     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1440     case "${target_os}" in
1441     linux*)
1442         AC_DEFINE(LINUX)
1443         ;;
1444     esac
1445     CFLAGS="$CFLAGS -Wall"
1446     CXXFLAGS="$CXXFLAGS -Wall"
1447     MDCPUCFG_H=_linux.cfg
1448     PR_MD_CSRCS=linux.c
1449     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1450     DSO_CFLAGS=-fPIC
1451     DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
1452     _OPTIMIZE_FLAGS=-O2
1453     _DEBUG_FLAGS="-g -fno-inline"  # most people on linux use gcc/gdb, and that
1454                                    # combo is not yet good at debugging inlined
1455                                    # functions (even when using DWARF2 as the
1456                                    # debugging format)
1457     COMPILER_TAG=_glibc
1458     if echo "$OS_TEST" | grep -c 86 >/dev/null; then
1459         CPU_ARCH=x86
1460     else
1461         CPU_ARCH=$OS_TEST
1462     fi
1463     CPU_ARCH_TAG=_${CPU_ARCH}
1464     case "${target_cpu}" in
1465     alpha)
1466         AC_DEFINE(_ALPHA_)
1467         AC_DEFINE(__alpha)
1468         CFLAGS="$CFLAGS -mieee"
1469         CXXFLAGS="$CXXFLAGS -mieee"
1470         ;;
1471     i*86)
1472         AC_DEFINE(i386)
1473         PR_MD_ASFILES=os_Linux_x86.s
1474         ;;
1475     ia64)
1476         PR_MD_ASFILES=os_Linux_ia64.s
1477         ;;
1478     x86_64)
1479         if test -n "$USE_64"; then
1480             PR_MD_ASFILES=os_Linux_x86_64.s
1481         else
1482             AC_DEFINE(i386)
1483             PR_MD_ASFILES=os_Linux_x86.s
1484             CC="$CC -m32"
1485             CXX="$CXX -m32"
1486         fi
1487         ;;
1488     ppc|powerpc)
1489         PR_MD_ASFILES=os_Linux_ppc.s
1490         ;;
1491     powerpc64)
1492         if test -n "$USE_64"; then
1493             CC="$CC -m64"
1494             CXX="$CXX -m64"
1495         else
1496             PR_MD_ASFILES=os_Linux_ppc.s
1497         fi
1498         ;;
1499     m68k)
1500         CFLAGS="$CFLAGS -m68020-60"
1501         CXXFLAGS="$CXXFLAGS -m68020-60"
1502         ;;
1503     esac    
1504     ;;
1506 *-mingw*|*-cygwin*|*-msvc*|*-mks*)
1507     AC_DEFINE(XP_PC)
1508     AC_DEFINE(WIN32)
1509     PR_MD_ARCH_DIR=windows
1510     RESOLVE_LINK_SYMBOLS=1
1512     if test -n "$GNU_CC"; then
1513         CC="$CC -mno-cygwin"
1514         CXX="$CXX -mno-cygwin"
1515         DLL_SUFFIX=dll
1516         MKSHLIB='$(CC) -shared -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) $(DLLBASE) -o $(subst $(OBJDIR)/,,$(SHARED_LIBRARY))'
1517         RC=$WINDRES
1518         # Use temp file for windres (bug 213281)
1519         RCFLAGS='-O coff --use-temp-file'
1520     else
1521         CC=cl
1522         CXX=cl
1523         LD=link
1524         AR='lib -NOLOGO -OUT:"$@"'
1525         AR_FLAGS=
1526         RANLIB='echo not_ranlib'
1527         STRIP='echo not_strip'
1528         RC=rc.exe
1529         GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
1530         OBJ_SUFFIX=obj
1531         LIB_SUFFIX=lib
1532         DLL_SUFFIX=dll
1534         # Determine compiler version
1535         CC_VERSION=`"${CC}" -v 2>&1 | grep Version | sed -e 's|.* Version ||' -e 's| .*||'`
1536         _CC_MAJOR_VERSION=`echo $CC_VERSION | awk -F\. '{ print $1 }'`
1537         _CC_MINOR_VERSION=`echo $CC_VERSION | awk -F\. '{ print $2 }'`
1538         MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
1540         # Ensure that mt is Microsoft (R) Manifest Tool and not magnetic
1541         # tape manipulation utility (or something else)
1542         if test "$MSC_VER" -ge "1400"; then
1543             changequote(,)
1544             _MSMT_VER_FILTER='s|.* \([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
1545             changequote([,])
1547             MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
1548             if test -n "$MSMT_TOOL"; then
1549                 MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
1550                 if test -z "$MSMANIFEST_TOOL_VERSION"; then
1551                     AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
1552                 fi
1553                 MT=mt
1554                 unset MSMT_TOOL
1555             else
1556                 AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
1557             fi
1558         fi
1559         
1560         CFLAGS="$CFLAGS -W3 -nologo -GF -Gy"
1561         DLLFLAGS="$DLLFLAGS -OUT:\"\$@\""
1562         _DEBUG_FLAGS=-Z7
1563         _OPTIMIZE_FLAGS=-O2
1564         if test -z "$MOZ_OPTIMIZE"; then
1565             CFLAGS="$CFLAGS -Od"
1566         fi
1568         if test -n "$USE_DEBUG_RTL"; then
1569             CFLAGS="$CFLAGS -MDd"
1570         else
1571             CFLAGS="$CFLAGS -MD"
1572         fi
1574         if test -n "$MOZ_DEBUG"; then
1575             AC_DEFINE(_DEBUG)
1576         else
1577             DEFINES="$DEFINES -U_DEBUG"
1578         fi
1580         if test -n "$MOZ_OPTIMIZE"; then
1581             if test -n "$MOZ_PROFILE"; then
1582                 _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Z7"
1583             fi
1584             if test -n "$MOZ_DEBUG_SYMBOLS"; then
1585                 _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Zi"
1586             fi
1587             if test -n "$MOZ_PROFILE" -o -n "$MOZ_DEBUG_SYMBOLS"; then
1588                 DLLFLAGS="$DLLFLAGS -DEBUG -OPT:REF"
1589                 LDFLAGS="$LDFLAGS -DEBUG -OPT:REF"
1590             fi
1591         fi
1593         if test -n "$MOZ_DEBUG"; then
1594             DLLFLAGS="$DLLFLAGS -DEBUG"
1595             LDFLAGS="$LDFLAGS -DEBUG"
1596         fi
1598         OS_DLLFLAGS="-nologo -DLL -SUBSYSTEM:WINDOWS"
1599         if test "$MSC_VER" -le "1200" -a -z "$MOZ_DEBUG_SYMBOLS"; then
1600             OS_DLLFLAGS="$OS_DLLFLAGS -PDB:NONE"
1601         fi
1602         
1603         if test "$OS_TARGET" = "WINNT"; then
1604             CFLAGS="$CFLAGS -GT"
1605             LIBNSPR='$(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1606             LIBPLC='$(dist_libdir)/libplc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1607         else
1608             LIBNSPR='$(dist_libdir)/nspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1609             LIBPLC='$(dist_libdir)/plc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
1610         fi
1611     fi # GNU_CC
1613     if test -n "$USE_STATIC_TLS"; then
1614         AC_DEFINE(_PR_USE_STATIC_TLS)
1615     fi
1617     if test "$OS_TARGET" = "WINNT"; then
1618         AC_DEFINE(WINNT)
1619     else
1620         AC_DEFINE(WIN95)
1621         # undefine WINNT as some versions of mingw gcc define it by default
1622         DEFINES="$DEFINES -UWINNT"
1623         AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
1624     fi
1626     if test "$CPU_ARCH" = "x86"; then
1627         CPU_ARCH_TAG=
1628     else
1629         CPU_ARCH_TAG=$CPU_ARCH
1630     fi
1632     if test -n "$USE_DEBUG_RTL"; then
1633         OBJDIR_SUFFIX=OBJD
1634     fi
1636     case "$OS_TARGET" in
1637     WINNT)
1638             MDCPUCFG_H=_winnt.cfg
1639             ;;
1640     WIN95)
1641             MDCPUCFG_H=_win95.cfg
1642             ;;
1643     WIN16)
1644             MDCPUCFG_H=_win16.cfg
1645             ;;
1646     *)
1647             AC_MSG_ERROR([Missing OS_TARGET for ${target}.  Use --enable-win32-target to set.])
1648         ;;
1649     esac
1651     case "$target_cpu" in
1652     i*86)
1653         if test -n "$USE_64"; then
1654             AC_DEFINE(_AMD64_)
1655             AC_DEFINE(_M_AMD64)    
1656         else            
1657             AC_DEFINE(_X86_)
1658         fi
1659         ;;
1660     alpha)
1661             AC_DEFINE(_ALPHA_)
1662             ;;
1663     mips)
1664             AC_DEFINE(_MIPS_)
1665             ;;
1666     x86_64)
1667             AC_DEFINE(_AMD64_)
1668             AC_DEFINE(_M_AMD64)
1669             USE_64=1
1670             ;;
1671     ia64)
1672             AC_DEFINE(_IA64_)
1673             AC_DEFINE(_M_IA64)
1674             USE_64=1
1675             ;;
1676     *)
1677             AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
1678             ;;
1679     esac
1681     if test "$USE_64"; then
1682         AC_DEFINE(_WIN64)
1683     fi
1685     ;;
1687 *-ncr-sysv*)
1688     AC_DEFINE(XP_UNIX)
1689     AC_DEFINE(SVR4)
1690     AC_DEFINE(SYSV)
1691     AC_DEFINE(NCR)
1692     USE_NSPR_THREADS=1
1693     if test "$OS_RELEASE" = "2.03"; then
1694         AC_DEFINE(_PR_STAT_HAS_ST_ATIM)
1695     else
1696         AC_DEFINE(_PR_STAT_HAS_ST_ATIM_UNION)
1697     fi
1699     if test -z "$GNU_CC"; then
1700         CFLAGS="$CFLAGS -Hnocopyr"
1701         CXXFLAGS="$CXXFLAGS -Hnocopyr"
1702     else
1703         CFLAGS="$CFLAGS -fPIC -Wall"
1704         CXXFLAGS="$CXXFLAGS -fPIC -Wall"
1705         DSO_LDOPTS=-G
1706     fi
1707     MDCPUCFG_H=_ncr.cfg
1708     PR_MD_CSRCS=ncr.c
1709     ;;
1711 mips-nec-sysv*)
1712     AC_DEFINE(XP_UNIX)
1713     AC_DEFINE(SVR4)
1714     AC_DEFINE(__SVR4)
1715     AC_DEFINE(NEC)
1716     AC_DEFINE(nec_ews)
1717     USE_NSPR_THREADS=1
1718     if test -z "$GNU_CC"; then
1719         CC='$(NSDEPTH)/build/hcc cc -Xa -KGnum=0 -KOlimit=4000'
1720         CXX=g++
1721     fi
1722     OS_LIBS="$OS_LIBS -lsocket -lnsl -ldl"
1723     DSO_LDOPTS=-G
1724     MDCPUCFG_H=_nec.cfg
1725     PR_MD_CSRCS=nec.c
1726     ;;
1728 *-netbsd*)
1729     AC_DEFINE(XP_UNIX)
1730     AC_DEFINE(NETBSD)
1731     AC_DEFINE(HAVE_BSD_FLOCK)
1732     USE_NSPR_THREADS=1
1733     MDCPUCFG_H=_netbsd.cfg
1734     PR_MD_CSRCS=netbsd.c
1736     DSO_CFLAGS='-fPIC -DPIC'
1737     CFLAGS="$CFLAGS -ansi -Wall"
1738     CXXFLAGS="$CXXFLAGS -ansi -Wall"
1739     MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
1741     if test -z "$OBJECT_FMT"; then
1742         if echo __ELF__ | ${CC-cc} -E - | grep -q __ELF__ 2>/dev/null; then
1743             OBJECT_FMT=a.out
1744             DLL_SUFFIX=so.1.0
1745             DSO_LDOPTS='-shared'
1746         else
1747             OBJECT_FMT=ELF
1748             DLL_SUFFIX=so
1749             DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)'
1750         fi
1751     fi
1753     if test "$LIBRUNPATH"; then
1754         DSO_LDOPTS="$DSO_LDOPTS -Wl,-R$LIBRUNPATH"
1755     fi
1756     ;;
1758 mips-sony-newsos*)
1759     AC_DEFINE(XP_UNIX)
1760     AC_DEFINE(SONY)
1761     AC_DEFINE(SYSV)
1762     AC_DEFINE(SVR4)
1763     AC_DEFINE(__svr4)
1764     AC_DEFINE(__svr4__)
1765     AC_DEFINE(HAVE_SVID_GETTOD)
1766     USE_NSPR_THREADS=1
1767     CFLAGS="$CFLAGS -Xa -fullwarn"
1768     CXXFLAGS="$CXXFLAGS -Xa -fullwarn"
1769     DSO_LDOPTS=-G
1770     MDCPUCFG_H=_sony.cfg
1771     PR_MD_CSRCS=sony.c
1772     ;;
1774 *-nextstep*|*-openstep*)
1775     AC_DEFINE(XP_UNIX)
1776     AC_DEFINE(NEXTSTEP)
1777     AC_DEFINE(HAVE_BSD_FLOCK)
1778     AC_DEFINE(_POSIX_SOURCE)
1779     CFLAGS="$CFLAGS -Wall -fno-common -traditional-cpp -posix"
1780     CXXFLAGS="$CXXFLAGS -Wall -fno-common -traditional-cpp -posix"
1781     USE_NSPR_THREADS=1
1782     DLL_SUFFIX=dylib
1783     MDCPUCFG_H=_nextstep.cfg
1784     PR_MD_CSRCS=nextstep.c
1785     ;;
1788 *-nto*)
1789     AC_DEFINE(XP_UNIX)
1790     AC_DEFINE(NTO)
1791     AC_DEFINE(_QNX_SOURCE)
1792     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1793     MDCPUCFG_H=_nto.cfg
1794     PR_MD_CSRCS=nto.c
1795     MKSHLIB='$(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(notdir $@) -o $@'
1796     DSO_CFLAGS=-fPIC
1797     DSO_LDOPTS=-shared
1798     OS_LIBS="$OS_LIBS -lsocket"
1799     _OPTIMIZE_FLAGS="-O1"
1800     _DEBUG_FLAGS="-gstabs"
1801         ;;
1803 *-openbsd*)
1804     AC_DEFINE(XP_UNIX)
1805     AC_DEFINE(OPENBSD)
1806     AC_DEFINE(HAVE_BSD_FLOCK)
1807     AC_DEFINE(HAVE_SOCKLEN_T)
1808     CFLAGS="$CFLAGS -ansi -Wall"
1809     CXXFLAGS="$CXXFLAGS -ansi -Wall"
1810     DLL_SUFFIX=so.1.0
1811     DSO_CFLAGS=-fPIC
1812     MDCPUCFG_H=_openbsd.cfg
1813     PR_MD_CSRCS=openbsd.c
1814     OS_LIBS="-lc"
1815     if test -z "$USE_NSPR_THREADS"; then
1816         USE_PTHREADS=1
1817     fi
1818     DSO_LDOPTS='-shared -fPIC'
1819     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1820     ;;
1822 *-openvms*)
1823     AC_DEFINE(XP_UNIX)
1824     AC_DEFINE(VMS)
1825     AC_DEFINE(PR_GETIPNODE_NOT_THREADSAFE)
1826     RESOLVE_LINK_SYMBOLS=1
1827     AR_FLAGS='c $@'
1828     MDCPUCFG_H=_openvms.cfg
1829     PR_MD_CSRCS=openvms.c
1830     DSO_LDOPTS='-shared -auto_symvec $(LDFLAGS)'
1831     if test -n "$MOZ_DEBUG"; then
1832       DSO_LDOPTS="$DSO_LDOPTS $_DEBUG_FLAGS"
1833     else
1834       DSO_LDOPTS="$DSO_LDOPTS $_OPTIMIZE_FLAGS"
1835     fi
1836     ;;
1838 *-osf*)
1839     SHELL_OVERRIDE="SHELL               = /usr/bin/ksh"
1840     AC_DEFINE(XP_UNIX)
1841     AC_DEFINE(OSF1)
1842     AC_DEFINE(_REENTRANT)
1843     # OSF1 and HPUX report the POLLHUP event for a socket when the
1844     # shutdown(SHUT_WR) operation is called for the remote end, even though
1845     # the socket is still writeable. Use select(), instead of poll(), to
1846     # workaround this problem.
1847     AC_DEFINE(_PR_POLL_WITH_SELECT)
1849     if echo "$OS_RELEASE" | egrep -c '(V2.0|V3.2)' 2>/dev/null ; then
1850         USE_NSPR_THREADS=1
1851     fi
1853     if test -z "$GNU_CC"; then
1854         CC="$CC -std1 -ieee_with_inexact"
1855         if test "$OS_RELEASE" != "V2.0"; then
1856             CC="$CC -readonly_strings"
1857         fi
1858         _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000"
1859         AC_CHECK_HEADER(machine/builtins.h, AC_DEFINE(OSF1_HAVE_MACHINE_BUILTINS_H))
1860     else
1861         CFLAGS="$CFLAGS -mieee"
1862         CXXFLAGS="$CXXFLAGS -mieee"
1863     fi
1865     if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then
1866         AC_DEFINE(HAVE_INT_LOCALTIME_R)
1867     else
1868         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1869         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
1870     fi
1871     if echo $OS_RELEASE | grep -c V4.0 >/dev/null; then
1872         AC_DEFINE(OSF1V4_MAP_PRIVATE_BUG)
1873     fi
1874     DSO_LDOPTS='-shared -all -expect_unresolved "*" -soname $(notdir $@)'
1875     MDCPUCFG_H=_osf1.cfg
1876     PR_MD_CSRCS=osf1.c
1877     ;;
1879 *-qnx*)
1880     AC_DEFINE(XP_UNIX)
1881     AC_DEFINE(QNX)
1882     AC_DEFINE(_PR_NEED_H_ERRNO)
1883     USE_NSPR_THREADS=1
1884     MDCPUCFG_H=_qnx.cfg
1885     PR_MD_CSRCS=qnx.c
1886     ;;
1888 *-riscos*)
1889     AC_DEFINE(XP_UNIX)
1890     AC_DEFINE(RISCOS)
1891     AC_DEFINE(_PR_NEED_H_ERRNO)
1892     USE_PTHREADS=1
1893     MDCPUCFG_H=_riscos.cfg
1894     PR_MD_CSRCS=riscos.c
1895     DLL_SUFFIX=a
1896     LD="/home/riscos/env/ro-ar cr"
1897     ;;
1899 *-*-sco*)
1900     AC_DEFINE(XP_UNIX)
1901     AC_DEFINE(SCO)
1902     AC_DEFINE(sco)
1903     AC_DEFINE(SYSV)
1904     AC_DEFINE(_SVID3)
1905     AC_DEFINE(_PR_NEED_H_ERRNO)
1906     CC='cc -b elf -KPIC'
1907     CXX='$(NSDEPTH)/build/hcpp CC +.cpp +w'
1908     USE_NSPR_THREADS=1
1909     CPU_ARCH=x86
1910     DSO_LDOPTS='-b elf -G'
1911     MDCPUCFG_H=_scoos.cfg
1912     PR_MD_SRCS=scoos.c
1913     ;;
1915 *-sinix*)
1916     AC_DEFINE(XP_UNIX)
1917     AC_DEFINE(SVR4)
1918     AC_DEFINE(SNI)
1919     AC_DEFINE(RELIANTUNIX)
1920     AC_DEFINE(sinix)
1921     AC_DEFINE(HAVE_SVID_GETTOD)
1922     if echo "$OS_TEST" | grep -c 86 2>/dev/null; then
1923         AC_DEFINE(i386)
1924         CPU_ARCH=x86
1925     else
1926         CPU_ARCH=mips
1927     fi
1929     if test "$GNU_CC"; then
1930         AS='$(CC) -x assembler-with-cpp'
1931         if test "$CPU_ARCH" = "mips"; then
1932             LD=gld
1933         fi
1934         CFLAGS="$CFLAGS -Wall -Wno-format"
1935     else
1936         AS='/usr/bin/cc'
1937         _OPTIMIZE_FLAGS='-O -F Olimit,4000'
1938     fi
1940     DSO_LDOPTS='-G -z defs -h $(@:$(OBJDIR)/%.so=%.so)'
1942     if test "$OS_RELEASE" = "5.43"; then
1943         AC_DEFINE(IP_MULTICAST)
1944     fi
1946     OS_LIBS="$OS_LIBS -lsocket -lnsl -lresolv -ldl -lc"
1947     USE_NSPR_THREADS=1
1948     MDCPUCFG_H=_reliantunix.cfg
1949     PR_MD_CSRCS=reliantunix.c
1950     if test "${OS_ARCH}" = "mips"; then
1951         PR_MD_ASFILES=os_ReliantUNIX.s
1952     fi
1953     ;;
1955 *-sunos*)
1956     AC_DEFINE(XP_UNIX)
1957     AC_DEFINE(SUNOS4)
1958     CFLAGS="$CFLAGS -Wall -Wno-format"
1959     if test "$USE_MDUPDATE"; then
1960         CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
1961     fi
1962     CPU_ARCH=sparc
1963     DLL_SUFFIX=so.1.0
1964     DSO_LDOPTS=
1965     DSO_CFLAGS=-fPIC
1966     USE_NSPR_THREADS=1
1967     if test "$OS_RELEASE" = "4.1.3_U1"; then
1968         _OPTIMIZE_FLAGS=
1969         OS_LIBS="$OS_LIBS -lm"
1970     fi
1971     MDCPUCFG_H=_sunos4.cfg
1972     PR_MD_CSRCS=sunos4.c
1973     ;;
1975 *-solaris*)
1976     if test -z "$USE_NSPR_THREADS"; then
1977         USE_PTHREADS=1
1978     fi
1979     AC_DEFINE(XP_UNIX)
1980     AC_DEFINE(SVR4)
1981     AC_DEFINE(SYSV)
1982     AC_DEFINE(__svr4)
1983     AC_DEFINE(__svr4__)
1984     AC_DEFINE(SOLARIS)
1985     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
1986     CPU_ARCH=`uname -p`
1987     MDCPUCFG_H=_solaris.cfg
1988     PR_MD_CSRCS=solaris.c
1989     LD=/usr/ccs/bin/ld
1990     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1991     RESOLVE_LINK_SYMBOLS=1
1992     if test -n "$GNU_CC"; then
1993         DSO_CFLAGS=-fPIC
1994         if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
1995             GCC_USE_GNU_LD=1
1996         fi
1997         DSO_LDOPTS='-shared -Wl,-h,$(notdir $@),-z,combreloc,-z,defs,-z,ignore,-Bdirect' 
1998     else
1999         DSO_CFLAGS=-KPIC
2000         DSO_LDOPTS='-G -h $(notdir $@) -z combreloc -z defs -z ignore -Bdirect'
2001     fi
2002     if test -n "$GNU_CC"; then
2003         CFLAGS="$CFLAGS -Wall"
2004         CXXFLAGS="$CXXFLAGS -Wall"
2005         if test -n "$USE_MDUPDATE"; then
2006             CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
2007             CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)"
2008         fi
2009         GCC_AS=`$CC -print-prog-name=as`
2010         if test "`echo | $GCC_AS -v 2>&1 | grep -c GNU`" != "0"; then
2011             GNU_AS=1
2012         fi
2013     else
2014         CFLAGS="$CFLAGS -xstrconst"
2015         CXXFLAGS="$CXXFLAGS -Qoption cg -xstrconst -features=tmplife"
2016         if test -z "$MOZ_OPTIMIZE"; then
2017             CFLAGS="$CFLAGS -xs"
2018             CXXFLAGS="$CXXFLAGS -xs"
2019         fi
2020         _OPTIMIZE_FLAGS=-xO4
2021     fi
2022     if test -z "$GNU_AS"; then
2023         ASFLAGS="$ASFLAGS -Wa,-P"
2024     fi
2025     if test -n "$USE_64"; then
2026         if test -n "$GNU_CC"; then
2027             CC="$CC -m64"
2028             CXX="$CXX -m64"
2029         else
2030             if test "$OS_TEST" = "i86pc"; then
2031                 CC="$CC -xarch=amd64"
2032                 CXX="$CXX -xarch=amd64"
2033             else
2034                 CC="$CC -xarch=v9"
2035                 CXX="$CXX -xarch=v9"
2036             fi
2037         fi
2038     fi
2039     if test "$OS_TEST" = "i86pc"; then
2040         if test -z "$USE_64"; then
2041             AC_DEFINE(i386)
2042         fi
2043         CPU_ARCH_TAG=_$OS_TEST
2044         # The default debug format, DWARF (-g), is not supported by gcc
2045         # on i386-ANY-sysv4/solaris, but the stabs format is.  It is
2046         # assumed that the Solaris assembler /usr/ccs/bin/as is used.
2047         # If your gcc uses GNU as, you do not need the -Wa,-s option.
2048         if test -n "$MOZ_DEBUG" && test -n "$GNU_CC"; then
2049             _DEBUG_FLAGS=-gstabs
2050             if test -z "$GNU_AS"; then
2051                 _DEBUG_FLAGS="$_DEBUG_FLAGS -Wa,-s"
2052             fi
2053         fi
2054     fi
2055     case "${target_os}" in
2056     solaris2.3*)
2057         AC_DEFINE(_PR_NO_LARGE_FILES)
2058         ;;
2059     solaris2.4*)
2060         AC_DEFINE(_PR_NO_LARGE_FILES)
2061         ;;
2062     solaris2.5*)
2063         AC_DEFINE(SOLARIS2_5)    
2064         ;;
2065     *)
2066         AC_DEFINE(_PR_HAVE_OFF64_T)
2067         # The lfcompile64(5) man page on Solaris 2.6 says:
2068         #     For applications that do not wish to conform to the POSIX or
2069         #     X/Open  specifications,  the  64-bit transitional interfaces
2070         #     are available by default.  No compile-time flags need to  be
2071         #     set.
2072         # But gcc 2.7.2.x fails to define _LARGEFILE64_SOURCE by default.
2073         # The native compiler, gcc 2.8.x, and egcs don't have this problem.
2074         if test -n "$GNU_CC"; then
2075             AC_DEFINE(_LARGEFILE64_SOURCE)
2076         fi
2077         ;;
2078     esac
2079     case "${target_os}" in
2080     solaris2.3*)
2081         ;;
2082     solaris2.4*)
2083         ;;
2084     solaris2.5*)
2085         ;;
2086     solaris2.6*)
2087         ;;
2088     solaris2.7*)
2089         ;;
2090     *)
2091         # Solaris 8 or higher has IPv6.
2092         AC_DEFINE(_PR_INET6)
2093         ;;
2094     esac
2095     if test "$CPU_ARCH" = "sparc"; then
2096         # 64-bit Solaris SPARC requires V9 architecture, so the following
2097         # is not needed.
2098         if test -z "$USE_64"; then
2099             ULTRASPARC_LIBRARY=nspr_flt
2100         fi
2101     fi
2102     # Purify requires that binaries linked against nspr also
2103     # be linked against -lrt (or -lposix4) so add it to OS_LIBS
2104     _rev=`uname -r`
2105     _librt=`echo $_rev 5.6 | awk '{ if ($1 > $2) print "-lrt"; else print "-lposix4" }'`
2106     OS_LIBS="$OS_LIBS $_librt"
2107     ;;
2109 *-sco-sysv5*)
2110     AC_DEFINE(XP_UNIX)
2111     AC_DEFINE(UNIXWARE)
2112     AC_DEFINE(SVR4)
2113     AC_DEFINE(SYSV)
2114     USE_NSPR_THREADS=1
2115     if echo $OS_RELEASE | grep -c 2.1 2>/dev/null; then
2116         AC_DEFINE(_PR_NO_LARGE_FILES)
2117         CC='$(NSDEPTH)/build/hcc cc'
2118         CXX='$(NSDEPTH)/build/hcpp CC'
2119         MDCPUCFG_H=_unixware.cfg
2120     else
2121         AC_DEFINE(_LARGEFILE64_SOURCE)
2122         AC_DEFINE(_PR_HAVE_OFF64_T)
2123         AC_DEFINE(_PR_HAVE_SOCKADDR_LEN)
2124         MDCPUCFG_H=_unixware7.cfg
2125     fi
2126     PR_MD_CSRCS=unixware.c
2127     DSO_LDOPTS=-G
2128     CPU_ARCH=x86
2129     ;;
2131 *-os2*)
2132     AC_DEFINE(XP_OS2)
2133     AC_DEFINE(XP_PC)
2134     AC_DEFINE(BSD_SELECT)
2135     AC_DEFINE(TCPV40HDRS)
2136     LIB_SUFFIX=lib
2137     DLL_SUFFIX=dll
2138     RC=rc.exe
2139     PR_MD_ARCH_DIR=os2
2140     PROG_SUFFIX=.exe
2141     NSINSTALL=nsinstall
2142     MDCPUCFG_H=_os2.cfg
2143     RESOLVE_LINK_SYMBOLS=1
2145     AC_DEFINE(OS2)
2146     AR=emxomfar
2147     AR_FLAGS='r $@'
2148     CFLAGS="$CFLAGS -Wall -Zomf"
2149     CXXFLAGS="$CFLAGS -Wall -Zomf"
2150     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2151     DSO_CFLAGS=
2152     DSO_LDOPTS='-Zomf -Zdll -Zmap'
2153     LDFLAGS='-Zmap'
2154     _OPTIMIZE_FLAGS="-O2 -s"
2155     _DEBUG_FLAGS="-g -fno-inline"
2156     if test -n "$MOZ_OPTIMIZE"; then
2157       DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
2158     fi
2159     OS_LIBS="-lsocket"
2160     IMPLIB='emximp -o'
2161     FILTER='emxexp -o'
2162     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
2163       DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem"
2164       LDFLAGS="$LDFLAGS -Zhigh-mem"
2165       AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
2166     fi
2168     # GCC for OS/2 currently predefines these, but we don't want them
2169     DEFINES="$DEFINES -Uunix -U__unix -U__unix__"
2170     ;;
2173     AC_DEFINE(XP_UNIX)
2174     ;;
2175    
2176 esac
2178 if test -z "$SKIP_LIBRARY_CHECKS"; then
2179 dnl ========================================================
2180 dnl Check for system libraries
2181 dnl ========================================================
2182 dnl AC_CHECK_LIB(C, main)
2183 dnl AC_CHECK_LIB(C_r, main)
2184 dnl AC_CHECK_LIB(c, main)
2185 dnl AC_CHECK_LIB(c_r, main)
2186 dnl AC_CHECK_LIB(dce, main)
2187 dnl AC_CHECK_LIB(dl, main)
2188 dnl AC_CHECK_LIB(dld, main)
2189 dnl AC_CHECK_LIB(gen, main)
2190 dnl AC_CHECK_LIB(ip6, main)
2191 dnl AC_CHECK_LIB(l, main)
2192 dnl AC_CHECK_LIB(m, main)
2193 dnl AC_CHECK_LIB(nsl, main)
2194 dnl AC_CHECK_LIB(posix4, main)
2195 dnl AC_CHECK_LIB(prstrms, main)
2196 dnl AC_CHECK_LIB(prstrms_shr, main)
2197 dnl AC_CHECK_LIB(pthread, main)
2198 dnl AC_CHECK_LIB(pthreads, main)
2199 dnl AC_CHECK_LIB(resolv, main)
2200 dnl AC_CHECK_LIB(rt, main)
2201 dnl AC_CHECK_LIB(socket, main)
2202 dnl AC_CHECK_LIB(svld, main)
2203 dnl AC_CHECK_LIB(thread, main)
2204 dnl AC_CHECK_LIB(vms_jackets, main)
2207 dnl We don't want anything to link with libdl even if it's present on OS X, 
2208 dnl since it's not used and not part of the default installation.
2209 dnl The same goes for BeOS.
2211 case $target in
2212 *-darwin*|*-beos*)
2213     ;;
2215     AC_CHECK_LIB(dl, dlopen,
2216         AC_CHECK_HEADER(dlfcn.h,
2217             OS_LIBS="-ldl $OS_LIBS"))
2218     ;;
2219 esac
2222 dnl ========================================================
2223 dnl Check for system header files.
2224 dnl ========================================================
2225 dnl AC_HEADER_DIRENT
2226 dnl AC_HEADER_STDC
2227 dnl AC_HEADER_SYS_WAIT
2228 dnl AC_CHECK_HEADERS(fcntl.h limits.h sys/file.h sys/ioctl.h sys/time.h unistd.h)
2230 dnl ========================================================
2231 dnl Check for typedefs and structs
2232 dnl ========================================================
2233 dnl AC_C_CONST
2234 dnl AC_TYPE_UID_T
2235 dnl AC_TYPE_MODE_T
2236 dnl AC_TYPE_OFF_T
2237 dnl AC_TYPE_PID_T
2238 dnl AC_TYPE_SIZE_T
2239 dnl AC_STRUCT_ST_BLKSIZE
2240 dnl AC_STRUCT_ST_BLOCKS
2241 dnl AC_STRUCT_ST_RDEV
2242 dnl AC_HEADER_TIME
2243 dnl AC_STRUCT_TM
2245 dnl ========================================================
2246 dnl Checks for library functions.
2247 dnl ========================================================
2248 AC_PROG_GCC_TRADITIONAL
2249 AC_CHECK_FUNCS(lchown strerror)
2251 dnl AC_FUNC_MEMCMP
2252 dnl AC_FUNC_MMAP
2253 dnl AC_FUNC_SETVBUF_REVERSED
2254 dnl AC_FUNC_STRCOLL
2255 dnl AC_FUNC_STRFTIME
2256 dnl AC_FUNC_UTIME_NULL
2257 dnl AC_FUNC_VPRINTF
2258 dnl AC_CHECK_FUNCS(ftime getcwd gethostname gettimeofday getwd mkdir mktime putenv rmdir select socket strdup strerror strstr strtol strtoul uname)
2260 dnl ========================================================
2261 dnl Check options
2262 dnl ========================================================
2264 dnl ========================================================
2265 dnl =
2266 dnl = --enable-strip
2267 dnl = 
2268 dnl = Enable stripping of libs and executables
2269 dnl = 
2270 dnl ========================================================
2271 AC_ARG_ENABLE(strip,
2272     [  --enable-strip          Enable stripping of shared libs and programs],
2273     [ if test "$enableval" = "yes"; then
2274             ENABLE_STRIP=1
2275       fi ])
2277 dnl Check for hpux options
2278 case "${target_os}" in
2279 hpux*)
2280 if test -z "$GNU_CC"; then
2282     AC_CACHE_CHECK(for +Olit support,
2283         ac_cv_hpux_usable_olit_option,
2284         dnl since aCC doesn't throw an error on invalid options,
2285         dnl we have to test this the hard way
2286         [ac_cv_hpux_usable_olit_option=no
2287         rm -f conftest*
2288         echo 'int main() { return 0; }' | cat > conftest.c
2289         ${CC-cc} ${CFLAGS} +Olit=all -o conftest conftest.c > conftest.out 2>&1
2290         if test $? -eq 0; then
2291             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out`"; then
2292                 ac_cv_hpux_usable_olit_option=yes
2293             fi
2294         fi
2295         rm -f conftest*
2296         ])
2298     if test "$ac_cv_hpux_usable_olit_option" = "yes"; then
2299         CFLAGS="$CFLAGS +Olit=all"
2300         CXXFLAGS="$CXXFLAGS +Olit=all"
2301     else
2302         CFLAGS="$CFLAGS +ESlit"
2303         CXXFLAGS="$CXXFLAGS +ESlit"
2304     fi
2307 esac
2310 dnl Apparently, some systems cannot properly check for the pthread
2311 dnl library unless <pthread.h> is included so we need to test
2312 dnl using it
2314 dnl MOZ_CHECK_PTHREADS(lib, success, failure)
2315 AC_DEFUN(MOZ_CHECK_PTHREADS,
2317 AC_MSG_CHECKING([for pthread_create in -l$1])
2318 echo "
2319     #include <pthread.h> 
2320     void *foo(void *v) { return v; } 
2321     int main() { 
2322         pthread_t t;
2323         if (!pthread_create(&t, 0, &foo, 0)) {
2324             pthread_join(t, 0);
2325         }
2326         return 0;
2327     }" > dummy.c ;
2328     echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS" 1>&5;
2329     ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS 2>&5;
2330     _res=$? ;
2331     rm -f dummy.c dummy${ac_exeext} ;
2332     if test "$_res" = "0"; then
2333         AC_MSG_RESULT([yes])
2334         [$2]
2335     else
2336         AC_MSG_RESULT([no])
2337         [$3]
2338     fi
2341 case "$target_os" in
2342 darwin*)
2343     _HAVE_PTHREADS=1
2344     ;;
2346     MOZ_CHECK_PTHREADS(pthreads,
2347         _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
2348         MOZ_CHECK_PTHREADS(pthread,
2349             _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
2350             MOZ_CHECK_PTHREADS(c_r,
2351                 _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
2352                 MOZ_CHECK_PTHREADS(c,
2353                     _HAVE_PTHREADS=1
2354                 )
2355             )
2356         )
2357     )
2358     ;;
2359 esac
2361 AC_ARG_WITH(pthreads,
2362     [  --with-pthreads         Use system pthreads library as thread subsystem],
2363     [ if test "$withval" = "yes"; then
2364             if test -n "$_HAVE_PTHREADS"; then
2365                     USE_PTHREADS=1 
2366                     USE_USER_PTHREADS=
2367                     USE_NSPR_THREADS=
2368             else
2369                     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
2370             fi
2371           else
2372             USE_PTHREADS=
2373             _PTHREAD_LDFLAGS=
2374           fi],
2375         [ if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USE_NSPR_THREADS"; then
2376             USE_PTHREADS=1
2377             USE_USER_PTHREADS=
2378             USE_NSPR_THREADS=
2379           fi])
2381 AC_ARG_ENABLE(user-pthreads,
2382     [  --enable-user-pthreads  Build using userland pthreads],
2383     [ if test "$enableval" = "yes"; then
2384         if test -n "$_HAVE_PTHREADS"; then
2385                     USE_PTHREADS=
2386                     USE_USER_PTHREADS=1
2387                     USE_NSPR_THREADS=
2388             else
2389                     AC_MSG_ERROR([ --enable-user-pthreads specified for a system without pthread support ]);
2390             fi
2391           fi])
2393 AC_ARG_ENABLE(nspr-threads,
2394     [  --enable-nspr-threads   Build using classic nspr threads],
2395     [ if test "$enableval" = "yes"; then
2396             USE_PTHREADS=
2397             USE_USER_PTHREADS=
2398             USE_NSPR_THREADS=1
2399           fi])
2401 case "$target" in
2402 *-beos*)
2403     AC_ARG_WITH(bthreads,
2404     [  --with-bthreads         Use system bthreads library as thread subsystem
2405                           (BeOS only)],
2406     [   if test "$withval" = "yes"; then
2407             USE_BTHREADS=1
2408                 USE_USER_PTHREADS=
2409                 USE_PTHREADS=
2410             fi])
2411     ;;
2412 esac
2414 fi # SKIP_LIBRARY_CHECKS
2416 AC_ARG_ENABLE(ipv6,
2417     [  --enable-ipv6           Compile ipv6 support],
2418     [ if test "$enableval" = "yes"; then
2419             USE_IPV6=1
2420       else
2421             USE_IPV6=
2422       fi])
2425 AC_ARG_ENABLE(boehm,
2426     [  --enable-boehm          Enable the Boehm Garbage Collector],
2427     [ if test "$enableval" = "yes"; then
2428         AC_DEFINE(GC_LEAK_DETECTOR)
2429         GC_LEAK_DETECTOR=1
2430     fi])
2432 if test -n "$USE_PTHREADS"; then
2433    dnl See if -pthread is supported.
2434    rm -f conftest*
2435    ac_cv_have_dash_pthread=no
2436    AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
2437    echo 'int main() { return 0; }' | cat > conftest.c
2438    ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
2439    if test $? -eq 0; then
2440         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2441             ac_cv_have_dash_pthread=yes
2442                 case "$target_os" in
2443             freebsd*)
2444 # Freebsd doesn't use -pthread for compiles, it uses them for linking
2445             ;;
2446             *)
2447             CFLAGS="$CFLAGS -pthread"
2448             CXXFLAGS="$CXXFLAGS -pthread"
2449             ;;
2450         esac
2451         fi
2452     fi
2453     rm -f conftest*
2454     AC_MSG_RESULT($ac_cv_have_dash_pthread)
2456         dnl
2457         dnl See if -pthreads is supported.
2458         dnl
2459     ac_cv_have_dash_pthreads=no
2460     if test "$ac_cv_have_dash_pthread" = "no"; then
2461             AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
2462         echo 'int main() { return 0; }' | cat > conftest.c
2463             ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
2464         if test $? -eq 0; then
2465                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2466                             ac_cv_have_dash_pthreads=yes
2467                             CFLAGS="$CFLAGS -pthreads"
2468                             CXXFLAGS="$CXXFLAGS -pthreads"
2469                     fi
2470             fi
2471             rm -f conftest*
2472         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
2473     fi
2475     case "$target" in
2476     *-solaris*)
2477         if test "$ac_cv_have_dash_pthreads" = "yes"; then
2478             _PTHREAD_LDFLAGS=
2479         fi
2480             ;;
2481     *-freebsd*)
2482             AC_DEFINE(_REENTRANT)
2483             AC_DEFINE(_THREAD_SAFE)
2484             dnl -pthread links in -lc_r, so don't specify it explicitly.
2485             if test "$ac_cv_have_dash_pthread" = "yes"; then
2486                 _PTHREAD_LDFLAGS="-pthread"
2487             else
2488                 _PTHREAD_LDFLAGS="-lc_r"
2489             fi
2490             ;;
2491     *-netbsd*)
2492             if test "$ac_cv_have_dash_pthread" = "yes"; then
2493                 _PTHREAD_LDFLAGS="-pthread"
2494             fi
2495             ;;
2496     *-bsdi*)
2497             AC_DEFINE(_THREAD_SAFE)
2498             dnl -pthread links in -lc_r, so don't specify it explicitly.
2499             if test "$ac_cv_have_dash_pthread" = "yes"; then
2500                 _PTHREAD_LDFLAGS=
2501             fi
2502             ;;
2503     *-openbsd*)
2504         if test "$ac_cv_have_dash_pthread" = "yes"; then
2505             _PTHREAD_LDFLAGS=-pthread
2506         fi
2507         ;;
2508     *-linux*|*-gnu*|*-k*bsd*-gnu)
2509         AC_DEFINE(_REENTRANT)
2510         ;;
2511     esac
2513 else 
2514     if test -n "$USE_USER_PTHREADS"; then
2515             USE_PTHREADS=
2516             USE_NSPR_THREADS=
2517     else
2518         _PTHREAD_LDFLAGS=
2519     fi
2521 dnl Special thread exceptions
2523 case "$target" in
2524 *-aix*)
2525     if test -n "$USE_NSPR_THREADS"; then
2526         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2527     fi
2528     case "$target_os" in
2529     aix4.1*)
2530         if test -z "$USE_PTHREADS"; then
2531             AC_DEFINE(AIX_RENAME_SELECT)
2532         fi
2533         ;;
2534     aix4.2*)
2535         if test -z "$USE_NSPR_THREADS"; then
2536             AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2537         fi
2538         ;;
2539     aix4.3*)
2540         if test -z "$USE_NSPR_THREADS"; then
2541             AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2542         fi
2543         if test -n "$USE_PTHREADS"; then
2544             AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2545         fi
2546         ;;
2547     *)
2548         if test -z "$USE_NSPR_THREADS"; then
2549             AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2550         fi
2551         if test -n "$USE_PTHREADS"; then
2552             AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2553         fi
2554         ;;
2555     esac
2556     ;;
2557 *-bsdi*)
2558     if test -n "$USE_PTHREADS"; then
2559         AC_DEFINE(_PR_NEED_PTHREAD_INIT)
2560     fi
2561     ;;
2562 *-freebsd*)
2563     if test -n "$USE_NSPR_THREADS"; then
2564         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2565     fi
2566     ;;
2567 *-hpux*)
2568     if test -n "$USE_NSPR_THREADS"; then
2569         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2570     fi 
2571     if test "$USE_PTHREADS"; then
2572         if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
2573             AC_DEFINE(_REENTRANT)
2574             AC_DEFINE(_PR_DCETHREADS)
2575         else
2576             AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
2577             AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2578         fi
2579     fi
2580     if test "$USE_USER_PTHREADS"; then
2581         AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
2582     fi
2583     ;;
2584 *-irix*)
2585     if test "${target_os}" = "irix6.5"; then
2586         if test -n "$USE_PTHREADS"; then
2587             AC_DEFINE(_PR_HAVE_GETHOST_R)
2588             AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER)
2589         fi
2590     fi
2591     ;;
2592 *-linux*|*-gnu*|*-k*bsd*-gnu)
2593     if test -n "$USE_NSPR_THREADS"; then
2594         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2595     fi
2596     ;;
2597 *-mingw*|*-cygwin*|*-msvc*|*-mks*|*-os2*|*-beos*)
2598     dnl win32, os2 & beos cannot use pthreads
2599     USE_PTHREADS=
2600     _PTHREAD_LDFLAGS=
2601     USE_USER_PTHREADS=
2602     ;;
2603 *-netbsd*|*-openbsd*)
2604     if test -n "$USE_NSPR_THREADS"; then
2605         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2606     fi
2607     ;;
2608 *-osf*)
2609     if test -n "$USE_NSPR_THREADS"; then
2610         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2611     fi
2612     if test -n "$USE_PTHREADS"; then
2613         if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then
2614             :
2615         else
2616             AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
2617         fi
2618     fi
2619     ;;
2620 *-solaris*)
2621     if test -n "$USE_NSPR_THREADS"; then
2622         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
2623     fi
2624     if test -n "$USE_PTHREADS"; then
2625         AC_DEFINE(_REENTRANT)
2626         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
2627         if test "$OS_TEST" = "i86pc"; then
2628             if test -n "$USE_64"; then
2629                PR_MD_ASFILES=os_SunOS_x86_64.s
2630             else
2631                PR_MD_ASFILES=os_SunOS_x86.s
2632             fi
2633         else
2634             if test -n "$USE_64"; then
2635                 PR_MD_ASFILES=os_SunOS_sparcv9.s
2636             fi
2637         fi
2638     fi
2639     ;;
2640 *-nto*)
2641     if test -n "$USE_PTHREADS"; then
2642         AC_DEFINE(_PR_HAVE_GETHOST_R)
2643         AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER)
2644     fi
2645     ;;
2646 esac
2648 OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS"
2650 dnl If the user passed in arg to --enable-optimize or --enable-debug,
2651 dnl make sure that we use it.
2652 if test -n "$_SAVE_OPTIMIZE_FLAGS"; then
2653     _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS"
2656 if test -n "$_SAVE_DEBUG_FLAGS"; then
2657     _DEBUG_FLAGS="$_SAVE_DEBUG_FLAGS"
2660 if test -n "$MOZ_OPTIMIZE"; then
2661     CFLAGS="$CFLAGS $_OPTIMIZE_FLAGS"
2662     CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS"
2665 if test -n "$MOZ_DEBUG"; then
2666     CFLAGS="$CFLAGS $_DEBUG_FLAGS"
2667     CXXFLAGS="$CXXFLAGS $_DEBUG_FLAGS"
2670 if test -n "$MOZ_OPTIMIZE"; then
2671     OBJDIR_TAG=_OPT
2672 else
2673     OBJDIR_TAG=_DBG
2676 if test -n "$USE_64"; then
2677     COMPILER_TAG=_64
2680 RELEASE_OBJDIR_NAME="${OS_CONFIG}${CPU_ARCH_TAG}${COMPILER_TAG}${IMPL_STRATEGY}${OBJDIR_TAG}.${OBJDIR_SUFFIX}"
2682 dnl ========================================================
2683 dnl Use cygwin wrapper for win32 builds, except MSYS/MinGW
2684 dnl ========================================================
2685 case "$target_os" in
2686 cygwin*|msvc*|mks*)
2687     CC="\$(CYGWIN_WRAPPER) $CC"
2688     CXX="\$(CYGWIN_WRAPPER) $CXX"
2689     RC="\$(CYGWIN_WRAPPER) $RC"
2690     ;;
2691 esac
2693 dnl ========================================================
2694 dnl Substitution of found variables.
2695 dnl ========================================================
2696 AC_SUBST(SHELL_OVERRIDE)
2698 AC_SUBST(MOZILLA_CLIENT)
2699 AC_SUBST(CC)
2700 AC_SUBST(CXX)
2701 AC_SUBST(CFLAGS)
2702 AC_SUBST(CXXFLAGS)
2703 AC_SUBST(CPPFLAGS)
2704 AC_SUBST(HOST_CC)
2705 AC_SUBST(HOST_CFLAGS)
2706 AC_SUBST(LDFLAGS)
2707 AC_SUBST(HOST_LDFLAGS)
2708 AC_SUBST(GNU_CC)
2709 AC_SUBST(GCC_USE_GNU_LD)
2710 AC_SUBST(MSC_VER)
2711 AC_SUBST(CROSS_COMPILE)
2713 AC_SUBST(MOZ_OPTIMIZE)
2715 AC_SUBST(USE_CPLUS)
2716 AC_SUBST(USE_IPV6)
2717 AC_SUBST(USE_N32)
2718 AC_SUBST(USE_64)
2719 AC_SUBST(OBJECT_MODE)
2720 AC_SUBST(GC_LEAK_DETECTOR)
2721 AC_SUBST(ENABLE_STRIP)
2723 AC_SUBST(USE_PTHREADS)
2724 AC_SUBST(USE_BTHREADS)
2725 AC_SUBST(USE_USER_PTHREADS)
2726 AC_SUBST(USE_NSPR_THREADS)
2728 AC_SUBST(LIBNSPR)
2729 AC_SUBST(LIBPLC)
2731 AC_SUBST(MOD_MAJOR_VERSION)
2732 AC_SUBST(MOD_MINOR_VERSION)
2733 AC_SUBST(MOD_PATCH_VERSION)
2734 AC_SUBST(NSPR_MODNAME)
2735 AC_SUBST(MDCPUCFG_H)
2736 AC_SUBST(PR_MD_CSRCS)
2737 AC_SUBST(PR_MD_ASFILES)
2738 AC_SUBST(PR_MD_ARCH_DIR)
2739 AC_SUBST(CPU_ARCH)
2741 AC_SUBST(OBJ_SUFFIX)
2742 AC_SUBST(LIB_SUFFIX)
2743 AC_SUBST(DLL_SUFFIX)
2744 AC_SUBST(ASM_SUFFIX)
2745 AC_SUBST(MKSHLIB)
2746 AC_SUBST(DSO_CFLAGS)
2747 AC_SUBST(DSO_LDOPTS)
2749 AC_SUBST(OS_TARGET)
2750 AC_SUBST(OS_ARCH)
2751 AC_SUBST(OS_RELEASE)
2752 AC_SUBST(OS_TEST)
2753 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
2755 AC_SUBST(DEFINES)
2756 AC_SUBST(DEFS)
2757 AC_SUBST(AR)
2758 AC_SUBST(AR_FLAGS)
2759 AC_SUBST(AS)
2760 AC_SUBST(ASFLAGS)
2761 AC_SUBST(LD)
2762 AC_SUBST(RANLIB)
2763 AC_SUBST(PERL)
2764 AC_SUBST(STRIP)
2765 AC_SUBST(FILTER)
2766 AC_SUBST(IMPLIB)
2768 AC_SUBST(OS_LIBS)
2769 AC_SUBST(RESOLVE_LINK_SYMBOLS)
2770 AC_SUBST(AIX_LINK_OPTS)
2771 AC_SUBST(NOSUCHFILE)
2772 AC_SUBST(MOZ_OBJFORMAT)
2773 AC_SUBST(ULTRASPARC_LIBRARY)
2775 AC_SUBST(OBJDIR)
2776 AC_SUBST(OBJDIR_NAME)
2777 AC_SUBST(RELEASE_OBJDIR_NAME)
2778 AC_SUBST(NSINSTALL)
2779 AC_SUBST(OPTIMIZER)
2780 AC_SUBST(RC)
2781 AC_SUBST(RCFLAGS)
2782 AC_SUBST(DLLFLAGS)
2783 AC_SUBST(EXEFLAGS)
2784 AC_SUBST(OS_DLLFLAGS)
2785 AC_SUBST(CYGWIN_WRAPPER)
2786 AC_SUBST(VISIBILITY_FLAGS)
2787 AC_SUBST(WRAP_SYSTEM_INCLUDES)
2788 AC_SUBST(MACOS_SDK_DIR)
2789 AC_SUBST(NEXT_ROOT)
2790 AC_SUBST(MT)
2792 dnl ========================================================
2793 dnl Generate output files.
2794 dnl ========================================================
2795 MAKEFILES="
2796 Makefile 
2797 config/Makefile
2798 config/autoconf.mk
2799 config/nsprincl.mk
2800 config/nsprincl.sh
2801 config/nspr-config
2802 lib/Makefile 
2803 lib/ds/Makefile 
2804 lib/libc/Makefile 
2805 lib/libc/include/Makefile 
2806 lib/libc/src/Makefile 
2807 lib/tests/Makefile
2808 pkg/Makefile
2809 pkg/linux/Makefile
2810 pkg/solaris/Makefile
2811 pkg/solaris/SUNWpr/Makefile
2812 pkg/solaris/SUNWprd/Makefile
2813 pr/Makefile 
2814 pr/include/Makefile 
2815 pr/include/md/Makefile 
2816 pr/include/obsolete/Makefile 
2817 pr/include/private/Makefile 
2818 pr/src/Makefile 
2819 pr/src/io/Makefile 
2820 pr/src/linking/Makefile 
2821 pr/src/malloc/Makefile 
2822 pr/src/md/Makefile 
2823 pr/src/md/${PR_MD_ARCH_DIR}/Makefile 
2824 pr/src/memory/Makefile 
2825 pr/src/misc/Makefile 
2826 pr/src/threads/Makefile 
2827 pr/tests/Makefile 
2828 pr/tests/dll/Makefile 
2831 dnl lib/tests/Makefile
2832 dnl pr/tests/w16gui/Makefile
2833 dnl tools/Makefile
2835 if test -z "$USE_PTHREADS" && test -z "$USE_BTHREADS"; then
2836     MAKEFILES="$MAKEFILES pr/src/threads/combined/Makefile"
2837 elif test -n "$USE_PTHREADS"; then
2838     MAKEFILES="$MAKEFILES pr/src/pthreads/Makefile"
2839 elif test -n "$USE_BTHREADS"; then
2840     MAKEFILES="$MAKEFILES pr/src/bthreads/Makefile"
2843 if test -n "$USE_CPLUS"; then
2844     MAKEFILES="$MAKEFILES pr/src/cplus/Makefile pr/src/cplus/tests/Makefile"
2847 echo $MAKEFILES > unallmakefiles
2849 AC_OUTPUT([$MAKEFILES], [chmod +x config/nspr-config])