summaryrefslogtreecommitdiff
path: root/configure.in
blob: af9e986a773e5254a22a6248c63a34c348453d87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.12)
AC_INIT(config/libc_r.h)

d=`pwd`
if test "${srcdir}" = "$d" || test "${srcdir}" = "."  ; then
   echo "Do not build in the srcdir as it will override Makefiles used by non-autoconf build."
   exit 1;
fi

AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
AC_CANONICAL_SYSTEM
AC_VALIDATE_CACHED_SYSTEM_TUPLE
AC_PREFIX_DEFAULT(\${MOD_DEPTH}/dist)

dnl Set this define to make fixes w/o breaking anything else.
AC_DEFINE(USE_AUTOCONF)

dnl ========================================================
dnl = Version defaults
dnl ========================================================
NSPR_VERSION=3
NSPR_MODNAME=nspr20
_HAVE_PTHREADS=
USE_PTHREADS=
USE_USER_PTHREADS=
USE_NSPR_THREADS=

dnl ========================================================
dnl =
dnl = Dont change the following lines.  Doing so breaks:
dnl =
dnl = CFLAGS="-foo" ./configure
dnl =
dnl ========================================================
CFLAGS="${CFLAGS=}"
CXXFLAGS="${CXXFLAGS=}"
LDFLAGS="${LDFLAGS=}"
HOST_CFLAGS="${HOST_CFLAGS=}"
HOST_LDFLAGS="${HOST_LDFLAGS=}"

dnl ========================================================
dnl =
dnl = Check options that may affect the compiler
dnl =
dnl ========================================================
MOZ_DEBUG=1
AC_ARG_ENABLE(debug,
    [  --disable-debug         Do not compile in debugging symbols],
    [	if test "$enableval" = "no"; then
    	    MOZ_DEBUG=
	fi])

AC_ARG_ENABLE(target,
    [  --enable-target=\$t      Turn on features for target \$t when build has multiple targets],
    MOZ_TARGET=`echo $enableval | tr a-z A-Z`,
    MOZ_TARGET=)

if test -n "$MOZ_DEBUG"; then
    CFLAGS="$CFLAGS -g"
    CXXFLAGS="$CXXFLAGS -g"
fi

dnl ========================================================
dnl Checks for compilers.
dnl ========================================================
if test "$target" != "$host"; then
    echo "cross compiling from $host to $target"
    cross_compiling=yes

    _SAVE_CC="$CC"
    _SAVE_CFLAGS="$CFLAGS"
    _SAVE_LDFLAGS="$LDFLAGS"

    AC_MSG_CHECKING([for $host compiler])
    if test -z "$HOST_CC"; then
	AC_CHECK_PROGS(HOST_CC, gcc cc /usr/ucb/cc, "")
	if test -z "$HOST_CC"; then
	    AC_MSG_ERROR([no acceptable cc found in \$PATH])
	fi
    fi
    AC_MSG_RESULT([$HOST_CC])
    if test -z "$HOST_CFLAGS"; then
	HOST_CFLAGS="$CFLAGS"
    fi
    if test -z "$HOST_LDFLAGS"; then
	HOST_LDFLAGS="$LDFLAGS"
    fi

    CC="$HOST_CC"
    CFLAGS="$HOST_CFLAGS"
    LDFLAGS="$HOST_LDFLAGS"

    AC_MSG_CHECKING([whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
    AC_TRY_COMPILE([], [return(0);], 
	[ac_cv_prog_host_cc_works=1 AC_MSG_RESULT([yes])],
	AC_MSG_ERROR([installation or configuration problem: $host compiler $HOST_CC cannot create executables.]) )
    
    CC=$_SAVE_CC
    CFLAGS=$_SAVE_CFLAGS
    LDFLAGS=$_SAVE_LDFLAGS

    if test -z "$CC"; then
	AC_CHECK_PROGS(CC, "${target_alias}-gcc" "${target}-gcc", :)
    fi
    unset ac_cv_prog_CC
    AC_PROG_CC
    if test -z "$CXX"; then
	AC_CHECK_PROGS(CXX, "${target_alias}-g++" "${target}-g++", :)
    fi
    unset ac_cv_prog_CXX
    AC_PROG_CXX
    if test -z "$RANLIB"; then
	AC_CHECK_PROGS(RANLIB, "${target_alias}-ranlib" "${target}-ranlib", :)
    fi
    if test -z "$AR"; then
	AC_CHECK_PROGS(AR, "${target_alias}-ar" "${target}-ar", :)
    fi
    if test -z "$AS"; then
	AC_CHECK_PROGS(AS, "${target_alias}-as" "${target}-as", :)
    fi
    if test -z "$DLLTOOL"; then
	AC_CHECK_PROGS(DLLTOOL, "${target_alias}-dlltool" "${target}-dlltool", :)
    fi
    if test -z "$WINDRES"; then
	AC_CHECK_PROGS(WINDRES, "${target_alias}-windres" "${target}-windres", :)
    fi
else
    AC_PROG_CC
    AC_PROG_CXX
    AC_PROG_RANLIB
    AC_PATH_PROGS(AS, as, $CC)
    AC_PATH_PROGS(AR, ar, :)
    AC_PATH_PROGS(DLLTOOL, dlltool, :)
    AC_PATH_PROGS(WINDRES, windres, :)
    if test -z "$HOST_CC"; then
	HOST_CC="$CC"
    fi
    if test -z "$HOST_CFLAGS"; then
	HOST_CFLAGS="$CFLAGS"
    fi
fi

if test "$GCC" = "yes"; then
    GNU_CC=1
fi

dnl ========================================================
dnl Checks for programs.
dnl ========================================================
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PATH_PROGS(PERL, perl5 perl, :)

dnl ========================================================
dnl Default platform specific options
dnl ========================================================
OBJ_SUFFIX=o
LIB_SUFFIX=a
DLL_SUFFIX=so
MKSHLIB='$(CCC) -shared -o $@'
PR_MD_ASFILES=
PR_MD_CSRCS=

dnl ========================================================
dnl Override of system specific host options
dnl ========================================================
case "$host" in
*-mingw*)
    ;;
*)
    HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
    ;;
esac

dnl ========================================================
dnl Override of system specific target options
dnl ========================================================
case "$target" in
*-beos*)
    AC_DEFINE(XP_BEOS)
    AC_DEFINE(BeOS)
    AC_DEFINE(BEOS)
    ;;

*-linux*)
    AC_DEFINE(XP_UNIX)
    MDCPUCFG_H=_linux.cfg
    PR_MD_CSRCS=linux.c
    PR_MD_ARCH_DIR=unix
    case "${target_cpu}" in
    alpha*)
	AC_DEFINE(XP_UNIX)
	AC_DEFINE(_POSIX_SOURCE)
	AC_DEFINE(_BSD_SOURCE)
	;;
    esac
    ;;

*-irix*)
    AC_DEFINE(XP_UNIX)
    MDCPUCFG_H=_irix32.cfg
    PR_MD_CSRCS=irix.c
    AS="as -D_ASM $(INCLUDES) -n32"
    PR_MD_ASFILES=os_Irix.s
    PR_MD_ARCH_DIR=unix
    case "${target_cpu}" in
    alpha*)
	AC_DEFINE(_POSIX_SOURCE)
	AC_DEFINE(_BSD_SOURCE)
	;;
    esac
    ;;

*-mingw*)
    AC_DEFINE(XP_PC)
    PR_MD_ARCH_DIR=windows
    if test -z "$GNU_CC"; then
	OBJ_SUFFIX=obj
	LIB_SUFFIX=lib
	DLL_SUFFIX=dll
    fi
    MKSHLIB='$(DLLTOOL) --as=$(AS) -k --dllname $*.dll --output-lib $@'

    case "$MOZ_TARGET" in
    WINNT)
	DEFINES="$DEFINES -DWIN32 -DWINNT -DWin32_Winsock"
	MDCPUCFG_H=_winnt.cfg
	;;
    WIN95)
	DEFINES="$DEFINES -UWINNT -DWIN32 -DWIN95 -DWin32_Winsock -D_PR_GLOBAL_THREADS_ONLY"
	MDCPUCFG_H=_win95.cfg
	;;
    WIN16)
	DEFINES="$DEFINES -UWINNT"
	MDCPUCFG_H=_win16.cfg
	;;
    *)
	AC_MSG_ERROR([Missing MOZ_TARGET for ${target}.  Use --enable-target to set.])
   	;;
    esac

    case "$target" in
    i?86-*)
	AC_DEFINE(_X86_)
        ;;
    alpha-*)
	AC_DEFINE(_ALPHA_)
   	;;
    mips-*)
	AC_DEFINE(_MIPS_)
	;;
    *)
	AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
	;;
    esac
    ;;
esac

dnl ========================================================
dnl Check for system libraries
dnl ========================================================
dnl AC_CHECK_LIB(C, main)
dnl AC_CHECK_LIB(C_r, main)
dnl AC_CHECK_LIB(c, main)
dnl AC_CHECK_LIB(c_r, main)
dnl AC_CHECK_LIB(dce, main)
dnl AC_CHECK_LIB(dl, main)
dnl AC_CHECK_LIB(dld, main)
dnl AC_CHECK_LIB(gen, main)
dnl AC_CHECK_LIB(ip6, main)
dnl AC_CHECK_LIB(l, main)
dnl AC_CHECK_LIB(m, main)
dnl AC_CHECK_LIB(nsl, main)
dnl AC_CHECK_LIB(posix4, main)
dnl AC_CHECK_LIB(prstrms, main)
dnl AC_CHECK_LIB(prstrms_shr, main)
dnl AC_CHECK_LIB(pthread, main)
dnl AC_CHECK_LIB(pthreads, main)
dnl AC_CHECK_LIB(resolv, main)
dnl AC_CHECK_LIB(rt, main)
dnl AC_CHECK_LIB(socket, main)
dnl AC_CHECK_LIB(svld, main)
dnl AC_CHECK_LIB(thread, main)
dnl AC_CHECK_LIB(vms_jackets, main)

dnl ========================================================
dnl Check for system header files.
dnl ========================================================
dnl AC_HEADER_DIRENT
dnl AC_HEADER_STDC
dnl AC_HEADER_SYS_WAIT
dnl AC_CHECK_HEADERS(fcntl.h limits.h sys/file.h sys/ioctl.h sys/time.h unistd.h)

dnl ========================================================
dnl Check for typedefs and structs
dnl ========================================================
dnl AC_C_CONST
dnl AC_TYPE_UID_T
dnl AC_TYPE_MODE_T
dnl AC_TYPE_OFF_T
dnl AC_TYPE_PID_T
dnl AC_TYPE_SIZE_T
dnl AC_STRUCT_ST_BLKSIZE
dnl AC_STRUCT_ST_BLOCKS
dnl AC_STRUCT_ST_RDEV
dnl AC_HEADER_TIME
dnl AC_STRUCT_TM

dnl ========================================================
dnl Checks for library functions.
dnl ========================================================
AC_PROG_GCC_TRADITIONAL
AC_CHECK_FUNCS(lchown strerror)

dnl AC_FUNC_MEMCMP
dnl AC_FUNC_MMAP
dnl AC_FUNC_SETVBUF_REVERSED
dnl AC_FUNC_STRCOLL
dnl AC_FUNC_STRFTIME
dnl AC_FUNC_UTIME_NULL
dnl AC_FUNC_VPRINTF
dnl AC_CHECK_FUNCS(ftime getcwd gethostname gettimeofday getwd mkdir mktime putenv rmdir select socket strdup strerror strstr strtol strtoul uname)

dnl ========================================================
dnl Check options
dnl ========================================================
dnl
dnl Check if NSPR is being compiled for Mozilla
dnl Let --with-arg override environment setting
dnl
AC_ARG_WITH(mozilla,
    [  --with-mozilla          Compile NSPR with Mozilla support],
    [	if test "$withval" = "yes"; then
	    AC_DEFINE(MOZILLA_CLIENT)
	else
	    MOZILLA_CLIENT=
	fi],
    [	if test -n "$MOZILLA_CLIENT"; then
	    AC_DEFINE(MOZILLA_CLIENT)
	fi])

AC_CHECK_LIB(pthread, pthread_attr_init, 
             _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread")

dnl 
dnl If the above test failed, try lib c_r
dnl 
if test "x$ac_cv_lib_pthread_pthread_attr_init" = "xno" -a \
"x$ac_cv_lib_c_r_gethostbyname_r" = "xno"
then
  AC_CHECK_LIB(c_r, pthread_attr_init,
               _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r")
fi

AC_ARG_WITH(pthreads,
    [  --with-pthreads         Use system pthreads library as thread subsystem],
    [	if test "$withval" = "yes"; then
	    if test -n "$_HAVE_PTHREADS"; then
		USE_PTHREADS=1 
		USE_USER_PTHREADS=
		USE_NSPR_THREADS=
	    else
		AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
	    fi
	else
	    USE_PTHREADS=
	    _PTHREAD_LDFLAGS=
	fi],
	[ if test -n "$_HAVE_PTHREADS"; then
	    USE_PTHREADS=1
	    USE_USER_PTHREADS=
	    USE_NSPR_THREADS=
	  fi])

AC_ARG_ENABLE(user-pthreads,
    [  --enable-user-pthreads  Build using userland pthreads],
    [	if test "$enableval" = "yes"; then
	    if test -n "$_HAVE_PTHREADS"; then
		USE_PTHREADS=
		USE_USER_PTHREADS=1
		USE_NSPR_THREADS=
	    else
		AC_MSG_ERROR([ --enable-user-pthreads specified for a system without pthread support ]);
	    fi
	fi])

AC_ARG_ENABLE(nspr-threads,
    [  --enable-nspr-threads   Build using classic nspr threads],
    [	if test "$enableval" = "yes"; then
	    USE_PTHREADS=
	    USE_USER_PTHREADS=
	    USE_NSPR_THREADS=1
	fi])

case "$target" in
*-beos*)
    AC_ARG_WITH(bthreads,
    [  --with-bthreads         Use system bthreads library as thread subsystem (BeOS only)],
    [	if test "$withval" = "yes"; then
    	    USE_BTHREADS=1
	    USE_USER_PTHREADS=
	    USE_PTHREADS=
	fi])
    ;;

*-solaris*)
    AC_ARG_WITH(native-threads,
    [  --with-native-threads   Use native system threads as thread subsystem (Solaris only)],
    [	if test "$withval" = "yes"; then
	    USE_NATIVE_THREADS=1
	    USE_USER_PTHREADS=
	    USE_PTHREADS=
	fi])
    ;;
esac

USE_CPLUS=
AC_ARG_ENABLE(cplus,
    [  --enable-cplus          Use cplus for whatever reason],
    [ if test "$enableval" = "yes"; then
	USE_CPLUS=1
      fi]) 

USE_IPV6=
AC_ARG_ENABLE(ipv6,
    [  --enable-ipv6           Compile ipv6 support],
    [ if test "$enableval" = "yes"; then
	USE_IPV6=1
      fi])

if test -n "$USE_PTHREADS"; then
   dnl See if -pthread is supported.
   rm -f conftest*
   ac_cv_have_dash_pthread=no
   AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
   echo 'int main() { return 0; }' | cat > conftest.c
   ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
   if test $? -eq 0; then
	if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
	    ac_cv_have_dash_pthread=yes
	    CFLAGS="$CFLAGS -pthread"
	    CXXFLAGS="$CXXFLAGS -pthread"
	fi
    fi
    rm -f conftest*
    AC_MSG_RESULT($ac_cv_have_dash_pthread)

    case "$target" in
    *-mingw*|*-cygwin*|*-uwin*)
	;;
    *-solaris*)
	AC_DEFINE(_REENTRANT)
	if test -n "$GNU_CC"; then
	    CFLAGS="$CFLAGS -mt"
	    CXXFLAGS="$CXXFLAGS -mt"
	fi
	;;
    *-freebsd*)
	AC_DEFINE(_REENTRANT)
	AC_DEFINE(_THREAD_SAFE)
	 dnl -pthread links in -lc_r, so don't specify it explicitly.
	if test "$ac_cv_have_dash_pthread" = "yes"; then
	    PTHREAD_LDFLAGS=
	fi
	;;
    *)
	AC_DEFINE(_REENTRANT)
	;;
    esac

else 
    if test -n "$USE_USER_PTHREADS"; then
	USE_PTHREADS=
	USE_NSPR_THREADS=
    else
	USE_NSPR_THREADS=1
	case "$target" in
    	*-linux*)
	    AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
	    ;;
	esac
    fi
fi
dnl Special thread exceptions

case "$target" in
    *-mingw*|*-cygwin*|*-uwin*)
	# win32 does not use pthreads
	USE_PTHREADS=
	PTHREAD_LDFLAGS=
	USE_USER_PTHREADS=
	;;
    *-solaris*)
	if test -n "$USE_NATIVE_THREADS"; then
	    AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
	else
	    AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
	fi
	;;
esac

dnl ========================================================
dnl Substitution of found variables.
dnl ========================================================
AC_SUBST(MOZILLA_CLIENT)
AC_SUBST(CC)
AC_SUBST(CXX)
AC_SUBST(CFLAGS)
AC_SUBST(CXXFLAGS)
AC_SUBST(HOST_CC)
AC_SUBST(HOST_CFLAGS)
AC_SUBST(GNU_CC)

AC_SUBST(USE_PTHREADS)
AC_SUBST(USE_BTHREADS)
AC_SUBST(USE_CPLUS)
AC_SUBST(USE_IPV6)
AC_SUBST(USE_USER_PTHREADS)
AC_SUBST(USE_NATIVE_THREADS)
AC_SUBST(USE_NSPR_THREADS)

AC_SUBST(NSPR_VERSION)
AC_SUBST(NSPR_MODNAME)
AC_SUBST(MDCPUCFG_H)
AC_SUBST(MOZ_TARGET)
AC_SUBST(PR_MD_CSRCS)
AC_SUBST(PR_MD_ASFILES)
AC_SUBST(PR_MD_ARCH_DIR)

AC_SUBST(OBJ_SUFFIX)
AC_SUBST(LIB_SUFFIX)
AC_SUBST(DLL_SUFFIX)
AC_SUBST(MKSHLIB)

AC_SUBST(DEFINES)
AC_SUBST(DEFS)
AC_SUBST(AR)
AC_SUBST(DLLTOOL)
AC_SUBST(WINDRES)
AC_SUBST(RANLIB)
AC_SUBST(PERL)

dnl ========================================================
dnl Generate output files.
dnl ========================================================
AC_OUTPUT([
Makefile 
config/Makefile
config/autoconf.mk
lib/Makefile 
lib/ds/Makefile 
lib/libc/Makefile 
lib/libc/include/Makefile 
lib/libc/src/Makefile 
lib/msgc/Makefile 
lib/msgc/include/Makefile 
lib/msgc/src/Makefile 
lib/msgc/tests/Makefile
lib/prstreams/Makefile 
lib/tests/Makefile 
pr/Makefile 
pr/include/Makefile 
pr/include/md/Makefile 
pr/include/obsolete/Makefile 
pr/include/private/Makefile 
pr/src/Makefile 
pr/src/bthreads/Makefile 
pr/src/cplus/Makefile 
pr/src/cplus/tests/Makefile 
pr/src/io/Makefile 
pr/src/linking/Makefile 
pr/src/malloc/Makefile 
pr/src/md/Makefile 
pr/src/md/beos/Makefile 
pr/src/md/os2/Makefile 
pr/src/md/unix/Makefile 
pr/src/md/windows/Makefile 
pr/src/memory/Makefile 
pr/src/misc/Makefile 
pr/src/pthreads/Makefile 
pr/src/threads/Makefile 
pr/src/threads/combined/Makefile 
pr/tests/Makefile 
pr/tests/dll/Makefile 
pr/tests/w16gui/Makefile 
tools/Makefile 
])

dnl lib/prstreams/tests/testprstrm/Makefile 
dnl lib/tests/windows/makefile