forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.in
2889 lines (2628 loc) · 81.2 KB
/
configure.in
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
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
dnl
dnl This Source Code Form is subject to the terms of the Mozilla Public
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
AC_PREREQ(2.61)
AC_INIT
AC_CONFIG_SRCDIR([pr/include/nspr.h])
AC_CONFIG_AUX_DIR(build/autoconf)
AC_CANONICAL_TARGET
dnl ========================================================
dnl = Defaults
dnl ========================================================
MOD_MAJOR_VERSION=4
MOD_MINOR_VERSION=35
MOD_PATCH_VERSION=0
NSPR_MODNAME=nspr20
_HAVE_PTHREADS=
USE_PTHREADS=
USE_USER_PTHREADS=
USE_NSPR_THREADS=
USE_N32=
USE_X32=
USE_64=
USE_CPLUS=
USE_IPV6=
USE_MDUPDATE=
_MACOSX_DEPLOYMENT_TARGET=
_OPTIMIZE_FLAGS=-O
_DEBUG_FLAGS=-g
MOZ_DEBUG=1
MOZ_OPTIMIZE=
OBJDIR='$(OBJDIR_NAME)'
OBJDIR_NAME=.
OBJDIR_SUFFIX=OBJ
NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall'
NOSUCHFILE=/no-such-file
LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)'
LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)'
CYGWIN_WRAPPER=
MACOS_SDK_DIR=
NEXT_ROOT=
MT=
MOZ_OS2_HIGH_MEMORY=1
PROFILE_GEN_CFLAGS=
PROFILE_GEN_LDFLAGS=
PROFILE_USE_CFLAGS=
PROFILE_USE_LDFLAGS=
dnl Link in libraries necessary to resolve all symbols for shared libs
RESOLVE_LINK_SYMBOLS=
dnl ========================================================
dnl =
dnl = Dont change the following lines. Doing so breaks:
dnl =
dnl = CFLAGS="-foo" ./configure
dnl =
dnl ========================================================
CFLAGS="${CFLAGS=}"
CXXFLAGS="${CXXFLAGS=}"
LDFLAGS="${LDFLAGS=}"
DLLFLAGS="${DLLFLAGS=}"
HOST_CFLAGS="${HOST_CFLAGS=}"
HOST_LDFLAGS="${HOST_LDFLAGS=}"
case "$target" in
*-cygwin*|*-mingw*|*-msys*)
# Check to see if we are really running in a msvc environemnt
_WIN32_MSVC=
AC_CHECK_PROGS(CC, cl)
cat > conftest.c <<EOF
#ifdef _MSC_VER
COMPILER IS MSVC
#endif
EOF
read dummy <<EOF
$($CC -E conftest.c 2>/dev/null | grep COMPILER)
EOF
if test -n "$dummy"; then
_WIN32_MSVC=1
CXX=$CC
fi
rm -f conftest.c
;;
*-mks*)
_WIN32_MSVC=1
;;
esac
if test -n "$_WIN32_MSVC"; then
SKIP_PATH_CHECKS=1
SKIP_COMPILER_CHECKS=1
SKIP_LIBRARY_CHECKS=1
fi
dnl ========================================================
dnl = Android uses a very custom (hacky) toolchain; we need to do this
dnl = here, so that the compiler checks can succeed
dnl ========================================================
AC_ARG_WITH(android-ndk,
[ --with-android-ndk=DIR
location where the Android NDK can be found],
android_ndk=$withval)
AC_ARG_WITH(android-toolchain,
[ --with-android-toolchain=DIR
location of the Android toolchain],
android_toolchain=$withval)
dnl The default android_version is different for each target cpu.
case "$target_cpu" in
arm)
android_version=5
;;
i?86|mipsel)
android_version=9
;;
esac
AC_ARG_WITH(android-version,
[ --with-android-version=VER
Android platform version, default 5 for arm, 9 for x86/mips],
android_version=$withval)
AC_ARG_WITH(android-platform,
[ --with-android-platform=DIR
location of platform dir],
android_platform=$withval)
case "$target" in
x86_64-linux*-android*)
android_tool_prefix="x86_64-linux-android"
;;
aarch64-linux*-android*)
android_tool_prefix="aarch64-linux-android"
;;
arm-linux*-android*|*-linuxandroid*)
android_tool_prefix="arm-linux-androideabi"
;;
i?86-*android*)
android_tool_prefix="i686-linux-android"
;;
mipsel-*android*)
android_tool_prefix="mipsel-linux-android"
;;
*)
android_tool_prefix="$target_os"
;;
esac
case "$target" in
*-android*|*-linuxandroid*)
if test -z "$android_ndk" ; then
AC_MSG_ERROR([You must specify --with-android-ndk=/path/to/ndk when targeting Android.])
fi
if test -z "$android_toolchain" ; then
AC_MSG_CHECKING([for android toolchain directory])
kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
case "$target_cpu" in
arm)
target_name=arm-linux-androideabi-4.4.3
;;
i?86)
target_name=x86-4.4.3
;;
mipsel)
target_name=mipsel-linux-android-4.4.3
;;
esac
android_toolchain="$android_ndk"/toolchains/$target_name/prebuilt/$kernel_name-x86
if test -d "$android_toolchain" ; then
AC_MSG_RESULT([$android_toolchain])
else
AC_MSG_ERROR([not found. You have to specify --with-android-toolchain=/path/to/ndk/toolchain.])
fi
fi
if test -z "$android_platform" ; then
AC_MSG_CHECKING([for android platform directory])
case "$target_cpu" in
arm)
target_name=arm
;;
i?86)
target_name=x86
;;
mipsel)
target_name=mips
;;
esac
android_platform="$android_ndk"/platforms/android-"$android_version"/arch-"$target_name"
if test -d "$android_platform" ; then
AC_MSG_RESULT([$android_platform])
else
AC_MSG_ERROR([not found. You have to specify --with-android-platform=/path/to/ndk/platform.])
fi
fi
dnl Old NDK support. If minimum requirement is changed to NDK r8b,
dnl please remove this.
case "$target_cpu" in
i?86)
if ! test -e "$android_toolchain"/bin/"$android_tool_prefix"-gcc; then
dnl Old NDK toolchain name
android_tool_prefix="i686-android-linux"
fi
;;
esac
dnl set up compilers
AS="$android_toolchain"/bin/"$android_tool_prefix"-as
CC="$android_toolchain"/bin/"$android_tool_prefix"-gcc
CXX="$android_toolchain"/bin/"$android_tool_prefix"-g++
CPP="$android_toolchain"/bin/"$android_tool_prefix"-cpp
LD="$android_toolchain"/bin/"$android_tool_prefix"-ld
AR="$android_toolchain"/bin/"$android_tool_prefix"-ar
RANLIB="$android_toolchain"/bin/"$android_tool_prefix"-ranlib
STRIP="$android_toolchain"/bin/"$android_tool_prefix"-strip
CPPFLAGS="-I$android_platform/usr/include $CPPFLAGS"
CFLAGS="-mandroid -I$android_platform/usr/include -fno-short-enums -fno-exceptions $CFLAGS"
CXXFLAGS="-mandroid -I$android_platform/usr/include -fpic -fno-short-enums -fno-exceptions $CXXFLAGS"
LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform $LDFLAGS"
AC_DEFINE(ANDROID)
;;
esac
dnl ========================================================
dnl =
dnl = Check options that may affect the compiler
dnl =
dnl ========================================================
dist_prefix='${MOD_DEPTH}/dist'
dist_bindir='${dist_prefix}/bin'
dist_includedir='${dist_prefix}/include/nspr'
dist_libdir='${dist_prefix}/lib'
dnl If the --includedir option was not specified, add '/nspr' to autoconf's
dnl default value of includedir.
if test "${includedir}" = '${prefix}/include'; then
includedir='${prefix}/include/nspr'
fi
AC_ARG_WITH(dist-prefix,
[ --with-dist-prefix=DIST_PREFIX
place build files in DIST_PREFIX [dist]],
dist_prefix=$withval)
AC_ARG_WITH(dist-bindir,
[ --with-dist-bindir=DIR build execuatables in DIR [DIST_PREFIX/bin]],
dist_bindir=$withval)
AC_ARG_WITH(dist-includedir,
[ --with-dist-includedir=DIR
build include files in DIR [DIST_PREFIX/include/nspr]],
dist_includedir=$withval)
AC_ARG_WITH(dist-libdir,
[ --with-dist-libdir=DIR build library files in DIR [DIST_PREFIX/lib]],
dist_libdir=$withval)
AC_SUBST(dist_prefix)
AC_SUBST(dist_bindir)
AC_SUBST(dist_includedir)
AC_SUBST(dist_libdir)
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)
MOZILLA_CLIENT=1
else
MOZILLA_CLIENT=
fi],
[ if test -n "$MOZILLA_CLIENT"; then
AC_DEFINE(MOZILLA_CLIENT)
fi])
AC_ARG_ENABLE(optimize,
[ --enable-optimize[=OPT] Enable code optimizations (ie. -O2) ],
[ if test "$enableval" != "no"; then
MOZ_OPTIMIZE=1
if test -n "$enableval" -a "$enableval" != "yes"; then
_OPTIMIZE_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
_SAVE_OPTIMIZE_FLAGS=$_OPTIMIZE_FLAGS
fi
else
MOZ_OPTIMIZE=
fi ])
AC_ARG_ENABLE(debug,
[ --enable-debug[=DBG] Enable debugging (using compiler flags DBG)],
[ if test "$enableval" != "no"; then
MOZ_DEBUG=1
MOZ_DEBUG_SYMBOLS=1
if test -n "$enableval" -a "$enableval" != "yes"; then
_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
_SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS
fi
else
MOZ_DEBUG=
fi ],
MOZ_DEBUG_SYMBOLS=1)
AC_ARG_ENABLE(debug-symbols,
[ --enable-debug-symbols[=DBG] Enable debugging symbols
(using compiler flags DBG)],
[ if test "$enableval" != "no"; then
MOZ_DEBUG_SYMBOLS=1
if test -n "$enableval" -a "$enableval" != "yes"; then
if test -z "$_SAVE_DEBUG_FLAGS"; then
_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
_SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS
else
AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
fi
fi
else
MOZ_DEBUG_SYMBOLS=
fi ])
AC_ARG_ENABLE(win32-target,
[ --enable-win32-target=\$t
Specify win32 flavor. (WIN95 or WINNT)],
OS_TARGET=`echo $enableval | tr a-z A-Z`)
AC_ARG_ENABLE(debug-rtl,
[ --enable-debug-rtl Use the MSVC debug runtime library],
[ if test "$enableval" = "yes"; then
USE_DEBUG_RTL=1
else
USE_DEBUG_RTL=0
fi ])
AC_ARG_ENABLE(static-rtl,
[ --enable-static-rtl Use the MSVC static runtime library],
[ if test "$enableval" = "yes"; then
USE_STATIC_RTL=1
fi ])
AC_ARG_ENABLE(x32,
[ --enable-x32 Enable x32 ABI support (x86_64 only)],
[ if test "$enableval" = "yes"; then
USE_X32=1
else if test "$enableval" = "no"; then
USE_X32=
fi
fi ])
AC_ARG_ENABLE(64bit,
[ --enable-64bit Enable 64-bit support (on certain platforms)],
[ if test "$enableval" = "yes"; then
USE_64=1
fi ])
AC_ARG_ENABLE(mdupdate,
[ --enable-mdupdate Enable use of certain compilers' mdupdate feature],
[ if test "$enableval" = "yes"; then
USE_MDUPDATE=1
fi ])
AC_ARG_ENABLE(cplus,
[ --enable-cplus Enable some c++ api routines],
[ if test "$enableval" = "yes"; then
USE_CPLUS=1
fi])
AC_ARG_WITH(arm-kuser,
[ --with-arm-kuser Use kuser helpers (Linux/ARM only)
(Requires kernel 2.6.13 or later)],
[ if test "$withval" = "yes"; then
AC_DEFINE(_PR_ARM_KUSER)
fi ])
dnl ========================================================
dnl = Mac OS X SDK support
dnl ========================================================
AC_ARG_WITH(macos-sdk,
[ --with-macos-sdk=dir Location of platform SDK to use (Mac OS X only)],
MACOS_SDK_DIR=$withval)
AC_ARG_ENABLE(macos-target,
[ --enable-macos-target=VER
Set the minimum MacOS version needed at runtime
[10.3 for ppc, 10.4 for x86]],
[_MACOSX_DEPLOYMENT_TARGET=$enableval])
dnl ========================================================
dnl =
dnl = Set the threading model
dnl =
dnl ========================================================
case "$target" in
*-aix*)
case "${target_os}" in
aix3.2*)
USE_NSPR_THREADS=1
;;
*)
USE_PTHREADS=1
;;
esac
;;
esac
dnl ========================================================
dnl =
dnl = Set the default C compiler
dnl =
dnl ========================================================
if test -z "$CC"; then
case "$target" in
*-aix*)
if test -z "$USE_NSPR_THREADS"; then
CC=xlc_r
else
CC=xlc
fi
;;
*-hpux*)
CC=cc
;;
*-solaris*)
CC=cc
;;
esac
fi
dnl ========================================================
dnl =
dnl = Set the default C++ compiler
dnl =
dnl ========================================================
if test -z "$CXX"; then
case "$target" in
*-aix*)
if test -z "$USE_NSPR_THREADS"; then
CXX=xlC_r
else
CXX=xlC
fi
;;
*-hpux*)
case "${target_os}" in
hpux10.30)
CXX=aCC
;;
hpux11.*)
CXX=aCC
;;
*)
CXX=CC
;;
esac
;;
*-solaris*)
CXX=CC
;;
esac
fi
if test -z "$SKIP_PATH_CHECKS"; then
AC_PATH_PROG(WHOAMI, $WHOAMI whoami, echo not_whoami)
fi
if test -n "$MOZ_DEBUG"; then
AC_DEFINE(DEBUG)
DEFINES="$DEFINES -UNDEBUG"
case "${target_os}" in
mks*|cygwin*|mingw*|msys*|os2*)
DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`"
;;
*)
DEFINES="$DEFINES -DDEBUG_`$WHOAMI`"
;;
esac
else
AC_DEFINE(NDEBUG)
DEFINES="$DEFINES -UDEBUG"
fi
if test -z "$SKIP_COMPILER_CHECKS"; then
dnl ========================================================
dnl Checks for compilers.
dnl ========================================================
if test "$target" != "$host"; then
echo "cross compiling from $host to $target"
cross_compiling=yes
case "$build:$target" in
powerpc-apple-darwin8*:i?86-apple-darwin*)
dnl The Darwin cross compiler doesn't necessarily point itself at a
dnl root that has libraries for the proper architecture, it defaults
dnl to the system root. The libraries in the system root on current
dnl versions of PPC OS X 10.4 aren't fat, so these target compiler
dnl checks will fail. Fake a working SDK in that case.
_SAVE_CFLAGS=$CFLAGS
_SAVE_CXXFLAGS=$CXXFLAGS
CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CFLAGS"
CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CXXFLAGS"
;;
esac
AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", echo)
unset ac_cv_prog_CC
dnl Now exit the conditional block to invoke AC_PROG_CC.
fi
dnl In the latest versions of autoconf, AC_PROG_CC is a one-shot macro,
dnl declared with AC_DEFUN_ONCE. So it must not be expanded inside a
dnl conditional block. Invoke AC_PROG_CC outside any conditional block
dnl and before invoking AC_TRY_COMPILE (which requires AC_PROG_CC).
AC_PROG_CC
dnl Reenter the conditional blocks after invoking AC_PROG_CC.
if test "$target" != "$host"; then
if test -n "$USE_CPLUS"; then
AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", echo)
unset ac_cv_prog_CXX
AC_PROG_CXX
fi
case "$build:$target" in
powerpc-apple-darwin8*:i?86-apple-darwin*|*:arm*-apple-darwin*)
dnl Revert the changes made above. From this point on, the target
dnl compiler will never be used without applying the SDK to CFLAGS
dnl (see --with-macos-sdk below).
CFLAGS=$_SAVE_CFLAGS
CXXFLAGS=$_SAVE_CXXFLAGS
;;
esac
AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", echo)
AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", echo)
AC_CHECK_PROGS(AS, $AS "${target_alias}-as" "${target}-as", echo)
AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", echo)
AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", echo)
AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", echo)
_SAVE_CC="$CC"
_SAVE_CFLAGS="$CFLAGS"
_SAVE_LDFLAGS="$LDFLAGS"
AC_MSG_CHECKING([for $host compiler])
AC_CHECK_PROGS(HOST_CC, $HOST_CC gcc cc /usr/ucb/cc, "")
if test -z "$HOST_CC"; then
AC_MSG_ERROR([no acceptable cc found in \$PATH])
fi
AC_MSG_RESULT([$HOST_CC])
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_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
else
if test -n "$USE_CPLUS"; then
if test "$CC" = "cl" -a -z "$CXX"; then
CXX=$CC
else
AC_PROG_CXX
fi
fi
AC_PROG_RANLIB
AC_PATH_PROGS(AS, as, $CC)
AC_PATH_PROGS(AR, ar, echo not_ar)
AC_PATH_PROGS(LD, ld link, echo not_ld)
AC_PATH_PROGS(STRIP, strip, echo not_strip)
AC_PATH_PROGS(WINDRES, windres, echo not_windres)
if test -z "$HOST_CC"; then
HOST_CC="$CC"
fi
if test -z "$HOST_CFLAGS"; then
HOST_CFLAGS="$CFLAGS"
fi
fi
AC_PROG_CPP
if test "$GCC" = "yes"; then
GNU_CC=1
fi
if test "$GXX" = "yes"; then
GNU_CXX=1
fi
if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then
GNU_AS=1
fi
rm -f a.out
case "$build:$target" in
i?86-apple-darwin*:powerpc-apple-darwin*)
dnl cross_compiling will have erroneously been set to "no" in this
dnl case, because the x86 build host is able to run ppc code in a
dnl translated environment, making a cross compiler appear native.
cross_compiling=yes
;;
esac
if test "$cross_compiling" = "yes"; then
CROSS_COMPILE=1
else
CROSS_COMPILE=
fi
dnl ========================================================
dnl Check for gcc -pipe support
dnl ========================================================
AC_MSG_CHECKING([for gcc -pipe support])
if test -n "$GNU_CC" && test -n "$GNU_CXX" && test -n "$GNU_AS"; then
echo '#include <stdio.h>' > dummy-hello.c
echo 'int main() { printf("Hello World\n"); return 0; }' >> dummy-hello.c
${CC} -S dummy-hello.c -o dummy-hello.s 2>&5
cat dummy-hello.s | ${AS} -o dummy-hello.S - 2>&5
if test $? = 0; then
_res_as_stdin="yes"
else
_res_as_stdin="no"
fi
if test "$_res_as_stdin" = "yes"; then
_SAVE_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -pipe"
AC_TRY_COMPILE( [ #include <stdio.h> ],
[printf("Hello World\n");],
[_res_gcc_pipe="yes"],
[_res_gcc_pipe="no"] )
CFLAGS=$_SAVE_CFLAGS
fi
if test "$_res_as_stdin" = "yes" && test "$_res_gcc_pipe" = "yes"; then
_res="yes";
CFLAGS="$CFLAGS -pipe"
CXXFLAGS="$CXXFLAGS -pipe"
else
_res="no"
fi
rm -f dummy-hello.c dummy-hello.s dummy-hello.S dummy-hello a.out
AC_MSG_RESULT([$_res])
else
AC_MSG_RESULT([no])
fi
dnl ========================================================
dnl Check for pragma diagnostic
dnl ========================================================
AC_MSG_CHECKING([for pragma diagnostic])
if test "$GNU_CC" = "1"; then
cat >dummy-hello.c <<EOF
#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
int main() {
char *dummy = "";
return 0;
}
EOF
${CC} -Werror=unused-but-set-variable -S dummy-hello.c -o dummy-hello.s 2>&5
if test $? != 0; then
${CC} -Werror=unused-but-set-variable -D_PR_HAS_PRAGMA_DIAGNOSTIC -S dummy-hello.c -o dummy-hello.s 2>&5
if test $? = 0; then
CFLAGS="$CFLAGS -D_PR_HAS_PRAGMA_DIAGNOSTIC=1"
_res=yes
else
_res=no
fi
else
_res=no
fi
rm -f dummy-hello.c dummy-hello.s
AC_MSG_RESULT([$_res])
else
AC_MSG_RESULT([no])
fi
dnl ========================================================
dnl Profile guided optimization
dnl ========================================================
dnl Test for profiling options
dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
_SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
AC_TRY_COMPILE([], [return 0;],
[ PROFILE_GEN_CFLAGS="-fprofile-generate"
result="yes" ], result="no")
AC_MSG_RESULT([$result])
if test $result = "yes"; then
PROFILE_GEN_LDFLAGS="-fprofile-generate"
PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
PROFILE_USE_LDFLAGS="-fprofile-use"
fi
CFLAGS="$_SAVE_CFLAGS"
dnl ===============================================================
dnl Check for .hidden assembler directive and visibility attribute.
dnl Borrowed from glibc configure.in
dnl ===============================================================
if test "$GNU_CC"; then
AC_CACHE_CHECK(for visibility(hidden) attribute,
ac_cv_visibility_hidden,
[cat > conftest.c <<EOF
int foo __attribute__ ((visibility ("hidden"))) = 1;
EOF
ac_cv_visibility_hidden=no
if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
if grep '\.hidden.*foo' conftest.s >/dev/null; then
ac_cv_visibility_hidden=yes
fi
fi
rm -f conftest.[cs]
])
if test "$ac_cv_visibility_hidden" = "yes"; then
AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
AC_CACHE_CHECK(for visibility pragma support,
ac_cv_visibility_pragma,
[cat > conftest.c <<EOF
#pragma GCC visibility push(hidden)
int foo_hidden = 1;
#pragma GCC visibility push(default)
int foo_default = 1;
EOF
ac_cv_visibility_pragma=no
if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
if grep '\.hidden.*foo_hidden' conftest.s >/dev/null; then
if ! grep '\.hidden.*foo_default' conftest.s > /dev/null; then
ac_cv_visibility_pragma=yes
fi
fi
fi
rm -f conftest.[cs]
])
if test "$ac_cv_visibility_pragma" = "yes"; then
AC_DEFINE(HAVE_VISIBILITY_PRAGMA)
# To work around a build problem on Linux x86-64 (Bugzilla bug
# 293438), we use the -fvisibility=hidden flag. This flag is less
# optimal than #pragma GCC visibility push(hidden) because the flag
# assumes that symbols defined outside the current source file have
# the default visibility. This has the advantage that we don't need
# to wrap system header files, but has the disadvantage that calls
# to hidden symbols defined in other source files cannot be
# optimized by the compiler. The -fvisibility=hidden flag does
# hide and export symbols correctly.
#VISIBILITY_FLAGS='-I$(dist_includedir)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
#WRAP_SYSTEM_INCLUDES=1
VISIBILITY_FLAGS="-fvisibility=hidden"
WRAP_SYSTEM_INCLUDES=
fi
fi
fi # GNU_CC
fi # SKIP_COMPILER_CHECKS
dnl ========================================================
dnl Checks for programs.
dnl ========================================================
if test -z "$SKIP_PATH_CHECKS"; then
AC_PATH_PROGS(PERL, perl5 perl, echo not_perl)
elif test -z "$PERL"; then
PERL=perl
fi
dnl ========================================================
dnl Default platform specific options
dnl ========================================================
OBJ_SUFFIX=o
LIB_SUFFIX=a
DLL_SUFFIX=so
ASM_SUFFIX=s
MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
PR_MD_ASFILES=
PR_MD_CSRCS=
PR_MD_ARCH_DIR=unix
AR_FLAGS='cr $@'
AS='$(CC)'
ASFLAGS='$(CFLAGS)'
if test -n "$CROSS_COMPILE"; then
OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
OS_RELEASE=
OS_TEST="${target_cpu}"
case "${target_os}" in
linux*) OS_ARCH=Linux ;;
solaris*) OS_ARCH=SunOS OS_RELEASE=5 ;;
mingw*) OS_ARCH=WINNT CPU_ARCH=x86 ;;
cygwin*) OS_ARCH=WINNT ;;
darwin*) OS_ARCH=Darwin ;;
riscos*) OS_ARCH=RISCOS ;;
esac
else
OS_ARCH=`uname -s | sed -e 's|/|_|g'`
OS_RELEASE=`uname -r`
OS_TEST=`uname -m`
fi
if test "$OS_ARCH" = "AIX"; then
OS_RELEASE=`uname -v`.`uname -r`
fi
if test "$OS_ARCH" = "FreeBSD"; then
OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
fi
if test "$OS_ARCH" = "Linux"; then
OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'`
OS_RELEASE=`echo $OS_RELEASE | awk -F\. '{ print $1 "." $2 }'`
fi
#######################################################################
# Master "Core Components" macros for getting the OS target #
#######################################################################
#
# Note: OS_TARGET should be specified on the command line for gmake.
# When OS_TARGET=WIN95 is specified, then a Windows 95 target is built.
# The difference between the Win95 target and the WinNT target is that
# the WinNT target uses Windows NT specific features not available
# in Windows 95. The Win95 target will run on Windows NT, but (supposedly)
# at lesser performance (the Win95 target uses threads; the WinNT target
# uses fibers).
#
# If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
# cross-compilation.
#
#
# The following hack allows one to build on a WIN95 machine (as if
# s/he were cross-compiling on a WINNT host for a WIN95 target).
# It also accomodates for MKS's uname.exe. If you never intend
# to do development on a WIN95 machine, you don't need this hack.
#
case "$OS_ARCH" in
Windows_95)
OS_ARCH=Windows_NT
OS_TARGET=WIN95
;;
Windows_98)
OS_ARCH=Windows_NT
OS_TARGET=WIN95
;;
CYGWIN_9*|CYGWIN_ME*)
OS_ARCH='CYGWIN_NT-4.0'
OS_TARGET=WIN95
;;
OS_2)
OS_ARCH=OS2
OS_TARGET=OS2
;;
esac
#
# On WIN32, we also define the variable CPU_ARCH.
#
case "$OS_ARCH" in
Windows_NT)
#
# If uname -s returns "Windows_NT", we assume that we are using
# the uname.exe in MKS toolkit.
#
# The -r option of MKS uname only returns the major version number.
# So we need to use its -v option to get the minor version number.
# Moreover, it doesn't have the -p option, so we need to use uname -m.
#
OS_ARCH=WINNT
OS_MINOR_RELEASE=`uname -v`
if test "$OS_MINOR_RELEASE" = "00"; then
OS_MINOR_RELEASE=0
fi
OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
CPU_ARCH=`uname -m`
#
# MKS's uname -m returns "586" on a Pentium machine.
#
if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
CPU_ARCH=x86
fi
;;
CYGWIN_NT*|MINGW*_NT*|MSYS_NT*)
#
# If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
# the uname.exe in the Cygwin tools.
# If uname -s returns "MINGW32_NT-5.1", we assume that we are using
# the uname.exe in the MSYS tools.
# If uname -s returns "MSYS_NT-6.3", we assume that we are using
# the uname.exe in the MSYS2 tools.
#
OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
OS_ARCH=WINNT
CPU_ARCH=`uname -m`
#
# Cygwin's uname -m returns "i686" on a Pentium Pro machine.
#
if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
CPU_ARCH=x86
fi
;;
esac
if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then
OS_TARGET=WIN95
if test -n "$MOZ_DEBUG" -a -z "$USE_DEBUG_RTL"; then
USE_DEBUG_RTL=1
fi
fi
if test -z "$OS_TARGET"; then
OS_TARGET=$OS_ARCH
fi
if test "$OS_TARGET" = "WIN95"; then
OS_RELEASE="4.0"
fi
OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
dnl ========================================================
dnl Enable high-memory support on OS/2 by default.
dnl ========================================================
AC_ARG_ENABLE(os2-high-mem,
[ --disable-os2-high-mem Disable high-memory support on OS/2],
[ if test "$enableval" = "no"; then
MOZ_OS2_HIGH_MEMORY=
else
MOZ_OS2_HIGH_MEMORY=1
fi ])
dnl ========================================================
dnl = ARM toolchain tweaks
dnl ========================================================
dnl Defaults
MOZ_ALIGN=toolchain-default
case "$target" in
arm*-android*|arm*-linuxandroid*)
MOZ_THUMB=yes
MOZ_ARCH=armv7-a
MOZ_FPU=vfp
MOZ_FLOAT_ABI=softfp
MOZ_SOFT_FLOAT=yes
MOZ_ALIGN=no
;;
arm*-*)
if test -n "$MOZ_PLATFORM_MAEMO"; then
MOZ_THUMB=no
MOZ_ARCH=armv7-a
MOZ_FLOAT_ABI=softfp
fi
if test "$MOZ_PLATFORM_MAEMO" = 6; then
MOZ_THUMB=yes
fi
;;
esac
dnl Kept for compatibility with some buildbot mozconfig
AC_ARG_ENABLE(thumb2, [], MOZ_THUMB=$enableval)
AC_ARG_WITH(thumb,
[ --with-thumb[[=yes|no|toolchain-default]]]
[ Use Thumb instruction set (-mthumb)],
if test -z "$GNU_CC"; then
AC_MSG_ERROR([--with-thumb is not supported on non-GNU toolchain-defaults])
fi
MOZ_THUMB=$withval)