Source code

Revision control

Other Tools

1
dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
2
dnl vi: set tabstop=4 shiftwidth=4 expandtab syntax=m4:
3
dnl This Source Code Form is subject to the terms of the Mozilla Public
4
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
5
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7
dnl Process this file with autoconf to produce a configure script.
8
dnl ========================================================
9
AC_PREREQ(2.13)
10
AC_INIT(js/src/jsapi.h)
11
AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
12
AC_CANONICAL_SYSTEM
13
14
dnl ========================================================
15
dnl =
16
dnl = Don't change the following lines. Doing so breaks:
17
dnl =
18
dnl = CFLAGS="-foo" ./configure
19
dnl =
20
dnl ========================================================
21
CFLAGS="${CFLAGS=}"
22
CPPFLAGS="${CPPFLAGS=}"
23
CXXFLAGS="${CXXFLAGS=}"
24
LDFLAGS="${LDFLAGS=}"
25
HOST_CFLAGS="${HOST_CFLAGS=}"
26
HOST_CXXFLAGS="${HOST_CXXFLAGS=}"
27
HOST_LDFLAGS="${HOST_LDFLAGS=}"
28
29
dnl ========================================================
30
dnl = Preserve certain environment flags passed to configure
31
dnl = We want sub projects to receive the same flags
32
dnl = untainted by this configure script
33
dnl ========================================================
34
_SUBDIR_CC="$CC"
35
_SUBDIR_CXX="$CXX"
36
_SUBDIR_CFLAGS="$CFLAGS"
37
_SUBDIR_CPPFLAGS="$CPPFLAGS"
38
_SUBDIR_CXXFLAGS="$CXXFLAGS"
39
_SUBDIR_LDFLAGS="$LDFLAGS"
40
_SUBDIR_HOST_CC="$HOST_CC"
41
_SUBDIR_HOST_CFLAGS="$HOST_CFLAGS"
42
_SUBDIR_HOST_CXXFLAGS="$HOST_CXXFLAGS"
43
_SUBDIR_HOST_LDFLAGS="$HOST_LDFLAGS"
44
_SUBDIR_CONFIG_ARGS="$ac_configure_args"
45
46
dnl Set the version number of the libs included with mozilla
47
dnl ========================================================
48
NSPR_VERSION=4
49
NSPR_MINVER=4.9.2
50
51
dnl Set the minimum version of toolkit libs used by mozilla
52
dnl ========================================================
53
W32API_VERSION=3.14
54
55
dnl Set various checks
56
dnl ========================================================
57
MISSING_X=
58
59
dnl Initialize the Pthread test variables early so they can be
60
dnl overridden by each platform.
61
dnl ========================================================
62
USE_PTHREADS=
63
_PTHREAD_LDFLAGS=""
64
65
LDFLAGS="$LDFLAGS $LINKER_LDFLAGS"
66
67
if test -z "$JS_STANDALONE"; then
68
autoconfmk=autoconf-js.mk
69
fi
70
AC_SUBST(autoconfmk)
71
72
if test -n "$JS_STANDALONE"; then
73
jsconfdefs=$_objdir/js/src/js-confdefs.h
74
else
75
jsconfdefs=$_objdir/js-confdefs.h
76
fi
77
78
MOZ_ANDROID_NDK
79
80
case "$target" in
81
*-apple-darwin*)
82
MOZ_IOS_SDK
83
;;
84
esac
85
86
dnl ========================================================
87
dnl Checks for compilers.
88
dnl ========================================================
89
90
if test "$COMPILE_ENVIRONMENT"; then
91
92
# Note:
93
# In Mozilla, we use the names $target, $host and $build incorrectly, but are
94
# too far gone to back out now. See Bug 475488:
95
# - When we say $target, we mean $host, that is, the system on which
96
# Mozilla will be run.
97
# - When we say $host, we mean $build, that is, the system on which Mozilla
98
# is built.
99
# - $target (in its correct usage) is for compilers who generate code for a
100
# different platform than $host, so it would not be used by Mozilla.
101
if test "$target" != "$host"; then
102
MOZ_CROSS_COMPILER
103
else
104
AC_PROG_CC
105
AC_PROG_CXX
106
AC_PROG_RANLIB
107
MOZ_PATH_PROGS(AS, $AS as, $CC)
108
AC_CHECK_PROGS(STRIP, strip, :)
109
fi
110
111
MOZ_TOOL_VARIABLES
112
113
dnl Special win32 checks
114
dnl ========================================================
115
116
# Target the Windows 8.1 SDK by default
117
WINVER=601
118
119
case "$target" in
120
*-mingw*)
121
if test "$GCC" != "yes"; then
122
# Check to see if we are really running in a msvc environemnt
123
_WIN32_MSVC=1
124
125
# Make sure compilers are valid
126
CFLAGS="$CFLAGS -nologo"
127
CXXFLAGS="$CXXFLAGS -TP -nologo"
128
if test -z "$CLANG_CL"; then
129
CPPFLAGS="$CPPFLAGS -utf-8"
130
fi
131
# _CRT_SECURE_NO_WARNINGS disables warnings about using MSVC-specific
132
# secure CRT functions.
133
CXXFLAGS="$CXXFLAGS -D_CRT_SECURE_NO_WARNINGS"
134
AC_LANG_SAVE
135
AC_LANG_C
136
AC_TRY_COMPILE([#include <stdio.h>],
137
[ printf("Hello World\n"); ],,
138
AC_MSG_ERROR([\$(CC) test failed. You must have MS VC++ in your path to build.]) )
139
140
AC_LANG_CPLUSPLUS
141
AC_TRY_COMPILE([#include <new.h>],
142
[ unsigned *test = new unsigned(42); ],,
143
AC_MSG_ERROR([\$(CXX) test failed. You must have MS VC++ in your path to build.]) )
144
AC_LANG_RESTORE
145
146
changequote(,)
147
_MSVC_VER_FILTER='s|.*[^!-~]([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
148
changequote([,])
149
150
AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
151
AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
152
AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI.
153
154
_CC_SUITE=14
155
MSVC_C_RUNTIME_DLL=vcruntime140.dll
156
MSVC_CXX_RUNTIME_DLL=msvcp140.dll
157
158
# -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
159
CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
160
161
AC_SUBST(MSVC_C_RUNTIME_DLL)
162
AC_SUBST(MSVC_CXX_RUNTIME_DLL)
163
164
# Check linker version, except in lld builds
165
case "$LINKER" in
166
*lld*)
167
;;
168
*)
169
_LD_FULL_VERSION=`"${LINKER}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
170
_LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
171
if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
172
AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION, does not match the compiler suite version, $_CC_SUITE.])
173
fi
174
;;
175
esac
176
177
INCREMENTAL_LINKER=1
178
179
unset _MSVC_VER_FILTER
180
181
CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
182
CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
183
else
184
# Check w32api version
185
_W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
186
_W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
187
AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
188
AC_TRY_COMPILE([#include <w32api.h>],
189
#if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
190
(__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
191
__W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
192
#error "test failed."
193
#endif
194
, [ res=yes ], [ res=no ])
195
AC_MSG_RESULT([$res])
196
if test "$res" != "yes"; then
197
AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
198
fi
199
fi # !GNU_CC
200
201
AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
202
AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
203
# Require OS features provided by IE 8.0 (Win7)
204
AC_DEFINE_UNQUOTED(_WIN32_IE,0x0800)
205
206
;;
207
esac
208
209
if test -n "$_WIN32_MSVC"; then
210
SKIP_PATH_CHECKS=1
211
SKIP_COMPILER_CHECKS=1
212
SKIP_LIBRARY_CHECKS=1
213
214
# Since we're skipping compiler and library checks, hard-code
215
# some facts here.
216
217
# Common to all MSVC environments:
218
219
AC_DEFINE(HAVE_LOCALECONV)
220
AC_CHECK_FUNCS([_getc_nolock])
221
fi
222
223
fi # COMPILE_ENVIRONMENT
224
225
# Check to see if we are running in a broken QEMU scratchbox.
226
# We know that anything below 1.0.16 is broken.
227
AC_CHECK_PROGS(SBCONF, sb-conf ve, "")
228
if test -n "$SBCONF"; then
229
_sb_version=`$SBCONF ve`
230
_sb_version_major=`echo $_sb_version | cut -f1 -d.`
231
_sb_version_minor=`echo $_sb_version | cut -f2 -d.`
232
_sb_version_point=`echo $_sb_version | cut -f3 -d.`
233
if test $_sb_version_major -eq 1 -a $_sb_version_minor -eq 0 -a $_sb_version_point -le 16; then
234
QEMU_CANT_RUN_JS_SHELL=1
235
fi
236
fi
237
AC_SUBST(QEMU_CANT_RUN_JS_SHELL)
238
239
AC_SUBST(GNU_CC)
240
AC_SUBST(GNU_CXX)
241
242
dnl ========================================================
243
dnl Checks for programs.
244
dnl ========================================================
245
if test "$COMPILE_ENVIRONMENT"; then
246
247
AC_PATH_XTRA
248
249
XCFLAGS="$X_CFLAGS"
250
251
fi # COMPILE_ENVIRONMENT
252
253
# Separate version into components for use in shared object naming etc
254
changequote(,)
255
MOZJS_MAJOR_VERSION=`echo $MOZILLA_VERSION | sed "s|\(^[0-9]*\)\.[0-9]*.*|\1|"`
256
MOZJS_MINOR_VERSION=`echo $MOZILLA_VERSION | sed "s|^[0-9]*\.\([0-9]*\).*|\1|"`
257
MOZJS_PATCH_VERSION=`echo $MOZILLA_VERSION | sed "s|^[0-9]*\.[0-9]*[^0-9]*||"`
258
IS_ALPHA=`echo $MOZILLA_VERSION | grep '[ab]'`
259
260
dnl XXX in a temporary bid to avoid developer anger at renaming files
261
dnl XXX before "js" symlinks exist, don't change names.
262
dnl
263
dnl if test -n "$JS_STANDALONE"; then
264
dnl JS_SHELL_NAME=js$MOZJS_MAJOR_VERSION
265
dnl JS_CONFIG_NAME=js$MOZJS_MAJOR_VERSION-config
266
dnl else
267
JS_SHELL_NAME=js
268
JS_CONFIG_NAME=js-config
269
dnl fi
270
271
changequote([,])
272
if test -n "$IS_ALPHA"; then
273
changequote(,)
274
MOZJS_ALPHA=`echo $MOZILLA_VERSION | sed "s|^[0-9]*\.[0-9\.]*\([^0-9]\).*|\1|"`
275
changequote([,])
276
fi
277
AC_DEFINE_UNQUOTED(MOZJS_MAJOR_VERSION,$MOZJS_MAJOR_VERSION)
278
AC_DEFINE_UNQUOTED(MOZJS_MINOR_VERSION,$MOZJS_MINOR_VERSION)
279
AC_SUBST(JS_SHELL_NAME)
280
AC_SUBST(JS_CONFIG_NAME)
281
AC_SUBST(MOZJS_MAJOR_VERSION)
282
AC_SUBST(MOZJS_MINOR_VERSION)
283
AC_SUBST(MOZJS_PATCH_VERSION)
284
AC_SUBST(MOZJS_ALPHA)
285
286
287
dnl ========================================================
288
dnl set the defaults first
289
dnl ========================================================
290
MOZ_USER_DIR=".mozilla"
291
292
MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
293
294
dnl Configure platform-specific CPU architecture compiler options.
295
dnl ==============================================================
296
MOZ_ARCH_OPTS
297
298
dnl ========================================================
299
dnl Android libstdc++
300
dnl ========================================================
301
302
MOZ_ANDROID_CPU_ARCH
303
MOZ_ANDROID_STLPORT
304
305
dnl ========================================================
306
dnl Suppress Clang Argument Warnings
307
dnl ========================================================
308
WARNINGS_CFLAGS="$_WARNINGS_CFLAGS"
309
if test -n "${CLANG_CC}${CLANG_CL}"; then
310
WARNINGS_CFLAGS="-Qunused-arguments $WARNINGS_CFLAGS"
311
CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
312
fi
313
if test -n "${CLANG_CXX}${CLANG_CL}"; then
314
_WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
315
fi
316
317
MOZ_CONFIG_SANITIZE
318
319
dnl ========================================================
320
dnl GNU specific defaults
321
dnl ========================================================
322
if test "$GNU_CC"; then
323
DSO_LDOPTS='-shared'
324
if test "$GCC_USE_GNU_LD"; then
325
# Some tools like ASan use a runtime library that is only
326
# linked against executables, so we must allow undefined
327
# symbols for shared objects in some cases.
328
if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
329
# Don't allow undefined symbols in libraries
330
DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
331
fi
332
fi
333
WARNINGS_AS_ERRORS='-Werror'
334
DSO_CFLAGS=''
335
336
if test "$OS_ARCH" != "WINNT"; then
337
DSO_PIC_CFLAGS='-fPIC'
338
ASFLAGS="$ASFLAGS -fPIC"
339
fi
340
341
AC_MSG_CHECKING([for --noexecstack option to as])
342
_SAVE_CFLAGS=$CFLAGS
343
CFLAGS="$CFLAGS -Wa,--noexecstack"
344
AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
345
[ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
346
AC_MSG_RESULT([no]))
347
CFLAGS=$_SAVE_CFLAGS
348
AC_MSG_CHECKING([for -z noexecstack option to ld])
349
_SAVE_LDFLAGS=$LDFLAGS
350
LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
351
AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
352
AC_MSG_RESULT([no])
353
LDFLAGS=$_SAVE_LDFLAGS)
354
355
AC_MSG_CHECKING([for -z text option to ld])
356
_SAVE_LDFLAGS=$LDFLAGS
357
LDFLAGS="$LDFLAGS -Wl,-z,text"
358
AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
359
AC_MSG_RESULT([no])
360
LDFLAGS=$_SAVE_LDFLAGS)
361
362
AC_MSG_CHECKING([for -z relro option to ld])
363
_SAVE_LDFLAGS=$LDFLAGS
364
LDFLAGS="$LDFLAGS -Wl,-z,relro"
365
AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
366
AC_MSG_RESULT([no])
367
LDFLAGS=$_SAVE_LDFLAGS)
368
369
AC_MSG_CHECKING([for -z nocopyreloc option to ld])
370
_SAVE_LDFLAGS=$LDFLAGS
371
LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc"
372
AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
373
AC_MSG_RESULT([no])
374
LDFLAGS=$_SAVE_LDFLAGS)
375
376
AC_MSG_CHECKING([for -Bsymbolic-functions option to ld])
377
_SAVE_LDFLAGS=$LDFLAGS
378
LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
379
AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
380
AC_MSG_RESULT([no])
381
LDFLAGS=$_SAVE_LDFLAGS)
382
383
AC_MSG_CHECKING([for --build-id=sha1 option to ld])
384
_SAVE_LDFLAGS=$LDFLAGS
385
LDFLAGS="$LDFLAGS -Wl,--build-id=sha1"
386
AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
387
AC_MSG_RESULT([no])
388
LDFLAGS=$_SAVE_LDFLAGS)
389
390
_DEFINES_CFLAGS="-include $jsconfdefs -DMOZILLA_CLIENT"
391
_USE_CPP_INCLUDE_FLAG=1
392
fi
393
394
if test "$GNU_CXX"; then
395
_DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $jsconfdefs"
396
_USE_CPP_INCLUDE_FLAG=1
397
fi
398
399
dnl ========================================================
400
dnl System overrides of the defaults for host
401
dnl ========================================================
402
case "$host" in
403
*mingw*)
404
if test -n "$_WIN32_MSVC"; then
405
HOST_CFLAGS="$HOST_CFLAGS -nologo"
406
else
407
HOST_CFLAGS="$HOST_CFLAGS -mwindows"
408
fi
409
HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
410
HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
411
HOST_BIN_SUFFIX=.exe
412
413
case "${host_cpu}" in
414
i*86)
415
if test -n "$_WIN32_MSVC"; then
416
HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
417
fi
418
;;
419
x86_64)
420
if test -n "$_WIN32_MSVC"; then
421
HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
422
fi
423
HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
424
;;
425
esac
426
;;
427
428
*-darwin*)
429
HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
430
HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
431
;;
432
433
*-linux*|*-kfreebsd*-gnu|*-gnu*)
434
HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
435
HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
436
;;
437
438
*)
439
HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
440
HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
441
;;
442
esac
443
444
dnl ========================================================
445
dnl Add optional and non-optional hardening flags from toolchain.configure
446
dnl ========================================================
447
448
CFLAGS="$CFLAGS $MOZ_HARDENING_CFLAGS_JS"
449
CPPFLAGS="$CPPFLAGS $MOZ_HARDENING_CFLAGS_JS"
450
CXXFLAGS="$CXXFLAGS $MOZ_HARDENING_CFLAGS_JS"
451
LDFLAGS="$LDFLAGS $MOZ_HARDENING_LDFLAGS_JS"
452
453
dnl ========================================================
454
dnl System overrides of the defaults for target
455
dnl ========================================================
456
457
case "$target" in
458
*-darwin*)
459
MOZ_OPTIMIZE_FLAGS="-O3"
460
CFLAGS="$CFLAGS -fno-common"
461
CXXFLAGS="$CXXFLAGS -fno-common -stdlib=libc++"
462
DSO_LDOPTS=''
463
STRIP="$STRIP -x -S"
464
LDFLAGS="$LDFLAGS -lobjc"
465
# The ExceptionHandling framework is needed for Objective-C exception
466
# logging code in nsObjCExceptions.h. Currently we only use that in debug
467
# builds.
468
_SAVE_LDFLAGS=$LDFLAGS
469
AC_MSG_CHECKING([for -framework ExceptionHandling])
470
LDFLAGS="$LDFLAGS -framework ExceptionHandling"
471
AC_TRY_LINK(,[return 0;],
472
ac_cv_have_framework_exceptionhandling="yes",
473
ac_cv_have_framework_exceptionhandling="no")
474
AC_MSG_RESULT([$ac_cv_have_framework_exceptionhandling])
475
if test "$ac_cv_have_framework_exceptionhandling" = "yes"; then
476
MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
477
fi
478
LDFLAGS=$_SAVE_LDFLAGS
479
480
dnl DTrace and -dead_strip don't interact well. See bug 403132.
481
dnl ===================================================================
482
if test "x$enable_dtrace" = "xyes"; then
483
echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
484
else
485
dnl check for the presence of the -dead_strip linker flag
486
AC_MSG_CHECKING([for -dead_strip option to ld])
487
_SAVE_LDFLAGS=$LDFLAGS
488
LDFLAGS="$LDFLAGS -Wl,-dead_strip"
489
AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
490
if test -n "$_HAVE_DEAD_STRIP" ; then
491
AC_MSG_RESULT([yes])
492
MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
493
else
494
AC_MSG_RESULT([no])
495
fi
496
497
LDFLAGS=$_SAVE_LDFLAGS
498
fi
499
MOZ_FIX_LINK_PATHS="-Wl,-executable_path,${DIST}/bin"
500
;;
501
502
*-android*|*-linuxandroid*)
503
AC_DEFINE(NO_PW_GECOS)
504
MOZ_GFX_OPTIMIZE_MOBILE=1
505
MOZ_OPTIMIZE_FLAGS="-O3"
506
if test -z "$CLANG_CC"; then
507
MOZ_OPTIMIZE_FLAGS="-freorder-blocks -fno-reorder-functions $MOZ_OPTIMIZE_FLAGS"
508
fi
509
;;
510
511
*-*linux*)
512
if test "$GNU_CC" -o "$GNU_CXX"; then
513
MOZ_PGO_OPTIMIZE_FLAGS="-O3"
514
MOZ_OPTIMIZE_FLAGS="-O3"
515
if test -z "$CLANG_CC"; then
516
MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
517
fi
518
fi
519
520
case "${target_cpu}" in
521
alpha*)
522
CFLAGS="$CFLAGS -mieee"
523
CXXFLAGS="$CXXFLAGS -mieee"
524
;;
525
esac
526
;;
527
528
*-mingw*)
529
DSO_CFLAGS=
530
DSO_PIC_CFLAGS=
531
if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
532
CC="$CC -mwindows"
533
CXX="$CXX -mwindows"
534
CPP="$CPP -mwindows"
535
CFLAGS="$CFLAGS -mms-bitfields"
536
CXXFLAGS="$CXXFLAGS -mms-bitfields"
537
DSO_LDOPTS='-shared'
538
# Use temp file for windres (bug 213281)
539
RCFLAGS='-O coff --use-temp-file'
540
# mingw doesn't require kernel32, user32, and advapi32 explicitly
541
LIBS="$LIBS -lusp10 -lgdi32 -lwinmm -lwsock32"
542
MOZ_FIX_LINK_PATHS=
543
544
if test -z "$CLANG_CC"; then
545
# Use static libgcc and libstdc++
546
LDFLAGS="$LDFLAGS -static"
547
else
548
# Silence problematic clang warnings
549
CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
550
fi
551
552
MOZ_OPTIMIZE_FLAGS="-O2"
553
554
WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
555
WIN32_GUI_EXE_LDFLAGS=-mwindows
556
else
557
TARGET_COMPILER_ABI=msvc
558
RANLIB='echo not_ranlib'
559
STRIP='echo not_strip'
560
PKG_SKIP_STRIP=1
561
# aarch64 doesn't support subsystems below 6.02
562
if test "$CPU_ARCH" = "aarch64"; then
563
WIN32_SUBSYSTEM_VERSION=6.02
564
else
565
WIN32_SUBSYSTEM_VERSION=6.01
566
fi
567
WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
568
WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
569
DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
570
_USE_CPP_INCLUDE_FLAG=1
571
_DEFINES_CFLAGS="-FI $jsconfdefs -DMOZILLA_CLIENT"
572
_DEFINES_CXXFLAGS="-FI $jsconfdefs -DMOZILLA_CLIENT"
573
CFLAGS="$CFLAGS -W3 -Gy -Zc:inline"
574
CXXFLAGS="$CXXFLAGS -W3 -Gy -Zc:inline"
575
if test "$CPU_ARCH" = "x86";then
576
dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
577
dnl more recent, so set that explicitly here unless another
578
dnl target arch has already been set.
579
changequote(,)
580
if test -z `echo $CFLAGS | grep -i [-/]arch:` ; then
581
CFLAGS="$CFLAGS -arch:SSE2"
582
fi
583
if test -z `echo $CXXFLAGS | grep -i [-/]arch:` ; then
584
CXXFLAGS="$CXXFLAGS -arch:SSE2"
585
fi
586
changequote([,])
587
fi
588
dnl VS2013+ supports -Gw for better linker optimizations.
590
dnl Disabled on ASan because it causes false-positive ODR violations.
591
if test -z "$MOZ_ASAN"; then
592
CFLAGS="$CFLAGS -Gw"
593
CXXFLAGS="$CXXFLAGS -Gw"
594
else
595
# String tail merging doesn't play nice with ASan's ODR checker.
596
LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
597
fi
598
if test -n "$CLANG_CL"; then
599
# XXX We should combine some of these with our generic GCC-style
600
# warning checks.
601
#
602
# Suppress the clang-cl warning for the inline 'new' and 'delete' in mozalloc
603
CXXFLAGS="$CXXFLAGS -Wno-inline-new-delete"
604
# We use offsetof on non-POD objects all the time.
605
# We also suppress this warning on other platforms.
606
CXXFLAGS="$CXXFLAGS -Wno-invalid-offsetof"
607
# This warns for reasonable things like:
608
# enum { X = 0xffffffffU };
609
# which is annoying for IDL headers.
610
CXXFLAGS="$CXXFLAGS -Wno-microsoft-enum-value"
611
# This warns for cases that would be reached by the Microsoft
612
# #include rules, but also currently warns on cases that would
613
# *also* be reached by standard C++ include rules. That
614
# behavior doesn't seem useful, so we turn it off.
615
CXXFLAGS="$CXXFLAGS -Wno-microsoft-include"
616
# We normally error out on unknown pragmas, but since clang-cl
617
# claims to be MSVC, it would be difficult to add
618
# #if defined(_MSC_VER) && !defined(__clang__) everywhere we
619
# use such pragmas, so just ignore them.
620
CFLAGS="$CFLAGS -Wno-unknown-pragmas"
621
CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas"
622
# We get errors about various #pragma intrinsic directives from
623
# clang-cl, and we don't need to hear about those.
624
CFLAGS="$CFLAGS -Wno-ignored-pragmas"
625
CXXFLAGS="$CXXFLAGS -Wno-ignored-pragmas"
626
# clang-cl's Intrin.h marks things like _ReadWriteBarrier
627
# as __attribute((__deprecated__)). This is nice to know,
628
# but since we don't get the equivalent warning from MSVC,
629
# let's just ignore it.
630
CFLAGS="$CFLAGS -Wno-deprecated-declarations"
631
CXXFLAGS="$CXXFLAGS -Wno-deprecated-declarations"
632
# We use a function like:
633
# __declspec(noreturn) __inline void f() {}
634
# which -Winvalid-noreturn complains about. Again, MSVC seems
635
# OK with it, so let's silence the warning.
636
CFLAGS="$CFLAGS -Wno-invalid-noreturn"
637
CXXFLAGS="$CXXFLAGS -Wno-invalid-noreturn"
638
# Missing |override| on virtual function declarations isn't
639
# something that MSVC currently warns about.
640
CXXFLAGS="$CXXFLAGS -Wno-inconsistent-missing-override"
641
# We use -DHAS_EXCEPTIONS=0, which removes the |throw()|
642
# declaration on |operator delete(void*)|. However, clang-cl
643
# must internally declare |operator delete(void*)| differently,
644
# which causes this warning for virtually every file in the
645
# tree. clang-cl doesn't support -fno-exceptions or equivalent,
646
# so there doesn't seem to be any way to convince clang-cl to
647
# declare |delete| differently. Therefore, suppress this
648
# warning.
649
CXXFLAGS="$CXXFLAGS -Wno-implicit-exception-spec-mismatch"
650
# At least one MSVC header and several headers in-tree have
651
# unused typedefs, so turn this on.
652
CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"
653
# jemalloc uses __declspec(allocator) as a profiler hint,
654
# which clang-cl doesn't understand.
655
CXXFLAGS="$CXXFLAGS -Wno-ignored-attributes"
656
# __attribute__((unused)) really means "might be unused" and
657
# we use it to avoid warnings about things that are unused
658
# in some compilation units, but used in many others. This
659
# warning insists on complaining about the latter case, which
660
# is annoying, and rather noisy.
661
CXXFLAGS="$CXXFLAGS -Wno-used-but-marked-unused"
662
fi
663
LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib"
664
MOZ_DEBUG_LDFLAGS='-DEBUG'
665
WARNINGS_AS_ERRORS='-WX'
666
MOZ_OPTIMIZE_FLAGS="-O2"
667
MOZ_FIX_LINK_PATHS=
668
LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
669
if test -z "$DEVELOPER_OPTIONS"; then
670
LDFLAGS="$LDFLAGS -RELEASE"
671
fi
672
RCFLAGS="-nologo"
673
fi
674
AC_DEFINE(HAVE__MSIZE)
675
AC_DEFINE(WIN32_LEAN_AND_MEAN)
677
AC_DEFINE(NOMINMAX)
678
BIN_SUFFIX='.exe'
679
MOZ_USER_DIR="Mozilla"
680
681
case "$host_os" in
682
cygwin*|msvc*|mks*)
683
AC_MSG_ERROR([Using a Cygwin build environment is unsupported. Configure cannot check for presence of necessary headers. Please upgrade to MozillaBuild; see https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
684
;;
685
esac
686
687
if test -n "$GNU_CC" -a -z "$CLANG_CC"; then
688
CFLAGS="$CFLAGS -fno-keep-inline-dllexport"
689
CXXFLAGS="$CXXFLAGS -fno-keep-inline-dllexport"
690
fi
691
692
case "$target" in
693
i*86-*)
694
if test -n "$GNU_CC"; then
695
CFLAGS="$CFLAGS -mstackrealign"
696
CXXFLAGS="$CXXFLAGS -mstackrealign"
697
LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
698
else
699
DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
700
LDFLAGS="$LDFLAGS -SAFESEH"
701
fi
702
703
AC_DEFINE(_X86_)
704
;;
705
x86_64-*)
706
if test -n "$_WIN32_MSVC"; then
707
DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
708
fi
709
AC_DEFINE(_AMD64_)
710
;;
711
aarch64-*)
712
if test -n "$_WIN32_MSVC"; then
713
DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
714
fi
715
AC_DEFINE(_ARM64_)
716
;;
717
*)
718
AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
719
;;
720
esac
721
;;
722
723
*-netbsd*)
724
DSO_CFLAGS=''
725
CFLAGS="$CFLAGS -Dunix"
726
CXXFLAGS="$CXXFLAGS -Dunix"
727
if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
728
DSO_PIC_CFLAGS='-fPIC -DPIC'
729
DSO_LDOPTS='-shared'
730
MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
731
else
732
DSO_PIC_CFLAGS='-fPIC -DPIC'
733
DSO_LDOPTS='-shared'
734
fi
735
# This will fail on a.out systems prior to 1.5.1_ALPHA.
736
if test "$LIBRUNPATH"; then
737
DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
738
fi
739
;;
740
741
*-openbsd*)
742
DSO_CFLAGS=''
743
DSO_PIC_CFLAGS='-fPIC'
744
DSO_LDOPTS='-shared -fPIC'
745
if test "$LIBRUNPATH"; then
746
DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
747
fi
748
;;
749
750
*-solaris*)
751
MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
752
;;
753
754
esac
755
756
if test -z "$MOZ_OPTIMIZE_FLAGS"; then
757
MOZ_OPTIMIZE_FLAGS="-O"
758
fi
759
760
if test -z "$COMPILE_ENVIRONMENT"; then
761
SKIP_COMPILER_CHECKS=1
762
SKIP_LIBRARY_CHECKS=1
763
fi
764
765
if test -n "$COMPILE_ENVIRONMENT"; then
766
MOZ_COMPILER_OPTS
767
fi
768
769
if test -z "$SKIP_COMPILER_CHECKS"; then
770
dnl Checks for typedefs, structures, and compiler characteristics.
771
dnl ========================================================
772
AC_C_CONST
773
AC_TYPE_MODE_T
774
AC_TYPE_OFF_T
775
AC_TYPE_PID_T
776
AC_TYPE_SIZE_T
777
AC_LANG_CPLUSPLUS
778
AC_LANG_C
779
AC_MSG_CHECKING(for ssize_t)
780
AC_CACHE_VAL(ac_cv_type_ssize_t,
781
[AC_TRY_COMPILE([#include <stdio.h>
782
#include <sys/types.h>],
783
[ssize_t foo = 0;],
784
[ac_cv_type_ssize_t=true],
785
[ac_cv_type_ssize_t=false])])
786
if test "$ac_cv_type_ssize_t" = true ; then
787
AC_DEFINE(HAVE_SSIZE_T)
788
AC_MSG_RESULT(yes)
789
else
790
AC_MSG_RESULT(no)
791
fi
792
793
AC_LANG_CPLUSPLUS
794
795
MOZ_CXX11
796
797
case "${OS_TARGET}" in
798
WINNT|Darwin|Android)
799
;;
800
*)
801
STL_FLAGS="-I${DIST}/stl_wrappers"
802
WRAP_STL_INCLUDES=1
803
;;
804
esac
805
806
dnl Checks for header files.
807
dnl ========================================================
808
AC_HEADER_DIRENT
809
case "$target_os" in
810
freebsd*)
811
# for stuff like -lXshm
812
CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
813
;;
814
esac
815
816
MOZ_ARG_ENABLE_BOOL(dtrace,
817
[ --enable-dtrace build with dtrace support if available (default=no)],
818
[enable_dtrace="yes"],)
819
if test "x$enable_dtrace" = "xyes"; then
820
MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
821
if test -n "$HAVE_DTRACE"; then
822
AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
823
else
824
AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
825
fi
826
fi
827
AC_SUBST(HAVE_DTRACE)
828
829
dnl Checks for libraries.
830
dnl ========================================================
831
AC_CHECK_LIB(c_r, gethostbyname_r)
832
833
dnl We don't want to link with libdl even if it's present on OS X, since
834
dnl it's not used and not part of the default installation. OS/2 has dlfcn
835
dnl in libc.
836
dnl We don't want to link against libm or libpthread on Darwin since
837
dnl they both are just symlinks to libSystem and explicitly linking
838
dnl against libSystem causes issues when debugging (see bug 299601).
839
case $target in
840
*-darwin*)
841
;;
842
*)
843
AC_SEARCH_LIBS(dlopen, dl,
844
MOZ_CHECK_HEADER(dlfcn.h,
845
AC_DEFINE(HAVE_DLOPEN)))
846
;;
847
esac
848
849
if test ! "$GNU_CXX"; then
850
AC_CHECK_LIB(C, demangle)
851
fi
852
853
AC_CHECK_LIB(socket, socket)
854
855
dnl ========================================================
856
dnl = pthread support
857
dnl = Start by checking whether the system support pthreads
858
dnl ========================================================
859
case "$target_os" in
860
darwin*)
861
USE_PTHREADS=1
862
;;
863
*)
864
AC_CHECK_LIB(pthreads, pthread_create,
865
USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
866
AC_CHECK_LIB(pthread, pthread_create,
867
USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
868
AC_CHECK_LIB(c_r, pthread_create,
869
USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
870
AC_CHECK_LIB(c, pthread_create,
871
USE_PTHREADS=1
872
)
873
)
874
)
875
)
876
;;
877
esac
878
879
dnl ========================================================
880
dnl Do the platform specific pthread hackery
881
dnl ========================================================
882
if test "$USE_PTHREADS"x != x
883
then
884
dnl
885
dnl See if -pthread is supported.
886
dnl
887
rm -f conftest*
888
ac_cv_have_dash_pthread=no
889
AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
890
echo 'int main() { return 0; }' | cat > conftest.c
891
${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
892
if test $? -eq 0; then
893
if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
894
ac_cv_have_dash_pthread=yes
895
case "$target_os" in
896
freebsd*)
897
# Freebsd doesn't use -pthread for compiles, it uses them for linking
898
;;
899
*)
900
CFLAGS="$CFLAGS -pthread"
901
CXXFLAGS="$CXXFLAGS -pthread"
902
;;
903
esac
904
fi
905
fi
906
rm -f conftest*
907
AC_MSG_RESULT($ac_cv_have_dash_pthread)
908
909
dnl
910
dnl See if -pthreads is supported.
911
dnl
912
ac_cv_have_dash_pthreads=no
913
if test "$ac_cv_have_dash_pthread" = "no"; then
914
AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
915
echo 'int main() { return 0; }' | cat > conftest.c
916
${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
917
if test $? -eq 0; then
918
if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
919
ac_cv_have_dash_pthreads=yes
920
CFLAGS="$CFLAGS -pthreads"
921
CXXFLAGS="$CXXFLAGS -pthreads"
922
fi
923
fi
924
rm -f conftest*
925
AC_MSG_RESULT($ac_cv_have_dash_pthreads)
926
fi
927
928
case "$target" in
929
*-*-freebsd*)
930
AC_DEFINE(_REENTRANT)
931
AC_DEFINE(_THREAD_SAFE)
932
dnl -pthread links in -lpthread, so don't specify it explicitly.
933
if test "$ac_cv_have_dash_pthread" = "yes"; then
934
_PTHREAD_LDFLAGS="-pthread"
935
fi
936
;;
937
938
*-*-openbsd*|*-*-bsdi*)
939
AC_DEFINE(_REENTRANT)
940
AC_DEFINE(_THREAD_SAFE)
941
dnl -pthread links in -lc_r, so don't specify it explicitly.
942
if test "$ac_cv_have_dash_pthread" = "yes"; then
943
_PTHREAD_LDFLAGS="-pthread"
944
fi
945
;;
946
947
*-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
948
AC_DEFINE(_REENTRANT)
949
;;
950
951
esac
952
LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
953
fi
954
955
956
dnl Checks for library functions.
957
dnl ========================================================
958
AC_CHECK_FUNCS([getc_unlocked _getc_nolock gmtime_r localtime_r pthread_getname_np pthread_get_name_np])
959
960
dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
961
AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
962
ac_cv_clock_monotonic,
963
[for libs in "" -lrt; do
964
_SAVE_LIBS="$LIBS"
965
_SAVE_CFLAGS="$CFLAGS"
966
LIBS="$LIBS $libs"
967
CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
968
dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
969
dnl we should or not be able to use it. To detect if we can, we need to make the
970
dnl availability attribute strict, so that compilation fails when the target is < 10.12.
971
AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
972
#include <time.h>],
973
[ struct timespec ts;
974
clock_gettime(CLOCK_MONOTONIC, &ts); ],
975
ac_cv_clock_monotonic=$libs
976
LIBS="$_SAVE_LIBS"
977
break,
978
ac_cv_clock_monotonic=no)
979
LIBS="$_SAVE_LIBS"
980
CFLAGS="$_SAVE_CFLAGS"
981
done])
982
if test "$ac_cv_clock_monotonic" != "no"; then
983
HAVE_CLOCK_MONOTONIC=1
984
REALTIME_LIBS=$ac_cv_clock_monotonic
985
AC_DEFINE(HAVE_CLOCK_MONOTONIC)
986
AC_SUBST(HAVE_CLOCK_MONOTONIC)
987
AC_SUBST_LIST(REALTIME_LIBS)
988
fi
989
990
dnl Checks for math functions.
991
dnl ========================================================
992
AC_CHECK_LIB(m, sin)
993
994
AC_CACHE_CHECK(
995
[for res_ninit()],
996
ac_cv_func_res_ninit,
997
[if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
998
dnl no need for res_ninit() on NetBSD and OpenBSD
999
ac_cv_func_res_ninit=no
1000
else
1001
AC_TRY_LINK([
1002
#ifdef linux
1003
#define _BSD_SOURCE 1
1004
#endif
1005
#include <sys/types.h>
1006
#include <netinet/in.h>
1007
#include <arpa/nameser.h>
1008
#include <resolv.h>
1009
],
1010
[int foo = res_ninit(&_res);],
1011
[ac_cv_func_res_ninit=yes],
1012
[ac_cv_func_res_ninit=no])
1013
fi
1014
])
1015
1016
if test "$ac_cv_func_res_ninit" = "yes"; then
1017
AC_DEFINE(HAVE_RES_NINIT)
1018
dnl must add the link line we do something as foolish as this... dougt
1019
dnl else
1020
dnl AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
1021
dnl AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
1022
fi
1023
1024
AM_LANGINFO_CODESET
1025
1026
AC_LANG_C
1027
1028
dnl **********************
1029
dnl *** va_copy checks ***
1030
dnl **********************
1031
AC_CACHE_CHECK([for an implementation of va_copy()],
1032
ac_cv_va_copy,
1033
[AC_TRY_COMPILE([#include <stdarg.h>
1034
#include <stdlib.h>
1035
void f (int i, ...) {
1036
va_list args1, args2;
1037
va_start (args1, i);
1038
va_copy (args2, args1);
1039
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1040
exit (1);
1041
va_end (args1); va_end (args2);
1042
}],
1043
[f(0, 42); return 0],
1044
[ac_cv_va_copy=yes],
1045
[ac_cv_va_copy=no]
1046
)]
1047
)
1048
AC_CACHE_CHECK([whether va_list can be copied by value],
1049
ac_cv_va_val_copy,
1050
[AC_TRY_COMPILE([#include <stdarg.h>
1051
#include <stdlib.h>
1052
void f (int i, ...) {
1053
va_list args1, args2;
1054
va_start (args1, i);
1055
args2 = args1;
1056
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1057
exit (1);
1058
va_end (args1); va_end (args2);
1059
}],
1060
[f(0, 42); return 0],
1061
[ac_cv_va_val_copy=yes],
1062
[ac_cv_va_val_copy=no],
1063
)]
1064
)
1065
if test "x$ac_cv_va_copy" = "xyes"; then
1066
AC_DEFINE(VA_COPY, va_copy)
1067
AC_DEFINE(HAVE_VA_COPY)
1068
fi
1069
1070
if test "x$ac_cv_va_val_copy" = "xno"; then
1071
AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
1072
fi
1073
1074
dnl ===================================================================
1075
dnl ========================================================
1076
dnl Put your C++ language/feature checks below
1077
dnl ========================================================
1078
AC_LANG_CPLUSPLUS
1079
1080
ARM_ABI_PREFIX=
1081
if test "$GNU_CC"; then
1082
if test "$CPU_ARCH" = "arm" ; then
1083
AC_CACHE_CHECK(for ARM EABI,
1084
ac_cv_gcc_arm_eabi,
1085
[AC_TRY_COMPILE([],
1086
[
1087
#if defined(__ARM_EABI__)
1088
return 0;
1089
#else
1090
#error Not ARM EABI.
1091
#endif
1092
],
1093
ac_cv_gcc_arm_eabi="yes",
1094
ac_cv_gcc_arm_eabi="no")])
1095
if test "$ac_cv_gcc_arm_eabi" = "yes"; then
1096
HAVE_ARM_EABI=1
1097
ARM_ABI_PREFIX=eabi-
1098
else
1099
ARM_ABI_PREFIX=oabi-
1100
fi
1101
fi
1102
1103
TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
1104
fi
1105
1106
# try harder, when checking for __thread support, see bug 521750 comment #33 and below
1107
# We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
1108
# enabled, the linker in xcode 4.1 will crash. Without this it would crash when
1109
# linking XUL.
1110
_SAVE_LDFLAGS=$LDFLAGS
1111
LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
1112
AC_CACHE_CHECK(for __thread keyword for TLS variables,
1113
ac_cv_thread_keyword,
1114
[AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
1115
[return tlsIsMainThread;],
1116
ac_cv_thread_keyword=yes,
1117
ac_cv_thread_keyword=no)])
1118
LDFLAGS=$_SAVE_LDFLAGS
1119
if test "$ac_cv_thread_keyword" = yes; then
1120
# mips builds fail with TLS variables because of a binutils bug.
1121
# See bug 528687
1122
case "${target}" in
1123
mips*-*)
1124
:
1125
;;
1126
*-android*|*-linuxandroid*)
1127
:
1128
;;
1129
*)
1130
AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
1131
;;
1132
esac
1133
fi
1134
1135
dnl End of C++ language/feature checks
1136
AC_LANG_C
1137
1138
dnl ========================================================
1139
dnl = Internationalization checks
1140
dnl ========================================================
1141
dnl
1142
dnl Internationalization and Locale support is different
1143
dnl on various UNIX platforms. Checks for specific i18n
1144
dnl features go here.
1145
1146
AC_HAVE_FUNCS(localeconv)
1147
fi # ! SKIP_COMPILER_CHECKS
1148
1149
TARGET_XPCOM_ABI=
1150
if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
1151
TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
1152
fi
1153
1154
dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
1155
dnl features that Windows actually does support.
1156
1157
if test -n "$SKIP_COMPILER_CHECKS"; then
1158
dnl Windows has malloc.h
1159
AC_DEFINE(MALLOC_H, [<malloc.h>])
1160
AC_DEFINE(HAVE_FORCEINLINE)
1161
AC_DEFINE(HAVE_LOCALECONV)
1162
fi # SKIP_COMPILER_CHECKS
1163
1164
dnl Mozilla specific options
1165
dnl ========================================================
1166
dnl The macros used for command line options
1167
dnl are defined in build/autoconf/altoptions.m4.
1168
1169
dnl ========================================================
1170
dnl =
1171
dnl = Check for external package dependencies
1172
dnl =
1173
dnl ========================================================
1174
MOZ_ARG_HEADER(External Packages)
1175
1176
MOZ_CONFIG_NSPR(js)
1177
1178
dnl ========================================================
1179
dnl system zlib Support
1180
dnl ========================================================
1181
dnl Standalone js defaults to system zlib
1182
if test -n "$JS_STANDALONE"; then
1183
ZLIB_DIR=yes
1184
fi
1185
1186
MOZ_ZLIB_CHECK([1.2.3])
1187
1188
if test -n "$ZLIB_IN_MOZGLUE"; then
1189
AC_DEFINE(ZLIB_IN_MOZGLUE)
1190
fi
1191
AC_SUBST(ZLIB_IN_MOZGLUE)
1192
1193
dnl ========================================================
1194
dnl =
1195
dnl = Application
1196
dnl =
1197
dnl ========================================================
1198
1199
MOZ_ARG_HEADER(Application)
1200
1201
dnl ========================================================
1202
dnl =
1203
dnl = Components & Features
1204
dnl =
1205
dnl ========================================================
1206
MOZ_ARG_HEADER(Components and Features)
1207
1208
dnl ========================================================
1209
dnl =
1210
dnl = Module specific options
1211
dnl =
1212
dnl ========================================================
1213
MOZ_ARG_HEADER(Individual module options)
1214
1215
dnl ========================================================
1216
dnl =
1217
dnl = Debugging Options
1218
dnl =
1219
dnl ========================================================
1220
MOZ_ARG_HEADER(Debugging and Optimizations)
1221
1222
dnl ========================================================
1223
dnl = Enable code optimization. ON by default.
1224
dnl ========================================================
1225
1226
# Use value from moz.configure if one is defined. Else use our computed
1227
# value.
1228
if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
1229
MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
1230
fi
1231
1232
if test "$COMPILE_ENVIRONMENT"; then
1233
if test -n "$MOZ_OPTIMIZE"; then
1234
AC_MSG_CHECKING([for valid optimization flags])
1235
_SAVE_CFLAGS=$CFLAGS
1236
CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
1237
AC_TRY_COMPILE([#include <stdio.h>],
1238
[printf("Hello World\n");],
1239
_results=yes,
1240
_results=no)
1241
AC_MSG_RESULT([$_results])
1242
if test "$_results" = "no"; then
1243
AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
1244
fi
1245
CFLAGS=$_SAVE_CFLAGS
1246
if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
1247
# When using llvm-based LTO, non numeric optimization levels are
1248
# not supported by the linker, so force the linker to use -O2 (
1249
# which doesn't influence the level compilation units are actually
1250
# compiled at).
1251
case " $MOZ_OPTIMIZE_FLAGS " in
1252
*\ -Os\ *|*\ -Oz\ *)
1253
MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
1254
;;
1255
esac
1256
fi
1257
fi
1258
fi # COMPILE_ENVIRONMENT
1259
1260
AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
1261
AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
1262
AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
1263
1264
dnl ========================================================
1265
dnl = Disable treating compiler warnings as errors
1266
dnl ========================================================
1267
if test -z "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
1268
WARNINGS_AS_ERRORS=''
1269
fi
1270
1271
dnl ========================================================
1272
dnl = Enable jemalloc
1273
dnl ========================================================
1274
1275
if test "$JS_STANDALONE" -a -z "$MOZ_MEMORY"; then
1276
MOZ_GLUE_IN_PROGRAM=
1277
else
1278
case "${OS_TARGET}" in
1279
Android|WINNT|Darwin)
1280
MOZ_GLUE_IN_PROGRAM=
1281
;;
1282
*)
1283
dnl On !Android !Windows !OSX, we only want to link executables against mozglue
1284
MOZ_GLUE_IN_PROGRAM=1
1285
AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
1286
;;
1287
esac
1288
fi
1289
1290
if test "$MOZ_MEMORY"; then
1291
dnl The generic feature tests that determine how to compute ncpus are long and
1292
dnl complicated. Therefore, simply define special cpp variables for the
1293
dnl platforms we have special knowledge of.
1294
case "${target}" in
1295
*-mingw*)
1296
export MOZ_NO_DEBUG_RTL=1
1297
;;
1298
esac
1299
fi
1300
AC_SUBST(MOZ_GLUE_IN_PROGRAM)
1301
1302
dnl ========================================================
1303
dnl instruments
1304
dnl ========================================================
1305
if test -n "$MOZ_INSTRUMENTS"; then
1306
LIBS="$LIBS -framework CoreFoundation"
1307
fi
1308
1309
dnl ========================================================
1310
dnl Debug (see Bug 939505)
1311
dnl ========================================================
1312
if test -n "$MOZ_DEBUG"; then
1313
AC_DEFINE(JS_DEBUG)
1314
fi
1315
1316
dnl ========================================================
1317
dnl = Enable using the clang plugin to build
1318
dnl ========================================================
1319
1320
if test -n "$COMPILE_ENVIRONMENT"; then
1321
MOZ_CONFIG_CLANG_PLUGIN
1322
fi # COMPILE_ENVIRONMENT
1323
1324
dnl ========================================================
1325
dnl = Enable static checking using sixgill
1326
dnl ========================================================
1327
1328
MOZ_ARG_WITH_STRING(sixgill,
1329
[ --with-sixgill=path/to/sixgill
1330
Enable static checking of code using sixgill],
1331
SIXGILL_PATH=$withval,
1332
SIXGILL_PATH= )
1333
1334
if test -n "$SIXGILL_PATH"; then
1335
if test ! -x "$SIXGILL_PATH/bin/xdbfind" || test ! -f "$SIXGILL_PATH/gcc/xgill.so" || test ! -x "$SIXGILL_PATH/scripts/wrap_gcc/g++"; then
1336
AC_MSG_ERROR([The sixgill plugin and binaries are not at the specified path.])
1337
fi
1338
fi
1339
AC_SUBST(SIXGILL_PATH)
1340
1341
dnl ========================================================
1342
dnl = Enable stripping of libs & executables
1343
dnl ========================================================
1344
MOZ_ARG_ENABLE_BOOL(strip,
1345
[ --enable-strip Enable stripping of libs & executables ],
1346
ENABLE_STRIP=1,
1347
ENABLE_STRIP= )
1348
1349
dnl ========================================================
1350
dnl = Enable stripping of libs & executables when packaging
1351
dnl ========================================================
1352
MOZ_ARG_ENABLE_BOOL(install-strip,
1353
[ --enable-install-strip Enable stripping of libs & executables when packaging ],
1354
PKG_SKIP_STRIP= ,
1355
PKG_SKIP_STRIP=1)
1356
1357
dnl ========================================================
1358
dnl =
1359
dnl = Profiling and Instrumenting
1360
dnl =
1361
dnl ========================================================
1362
MOZ_ARG_HEADER(Profiling and Instrumenting)
1363
1364
dnl ========================================================
1365
dnl = Support for demangling undefined symbols
1366
dnl ========================================================
1367
if test -z "$SKIP_LIBRARY_CHECKS"; then
1368
AC_LANG_SAVE
1369
AC_LANG_CPLUSPLUS
1370
AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
1371
AC_LANG_RESTORE
1372
fi
1373
1374
dnl ========================================================
1375
dnl JIT observers
1376
dnl ========================================================
1377
1378
MOZ_ARG_WITH_STRING(jitreport-granularity,
1379
[ --jitreport-granularity=N
1380
Default granularity at which to report JIT code
1381
to external tools
1382
0 - no info
1383
1 - code ranges for whole functions only
1384
2 - per-line information
1385
3 - per-op information],
1386
JITREPORT_GRANULARITY=$withval,
1387
JITREPORT_GRANULARITY=3)
1388
1389
AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
1390
1391
dnl ========================================================
1392
dnl =
1393
dnl = Misc. Options
1394
dnl =
1395
dnl ========================================================
1396
MOZ_ARG_HEADER(Misc. Options)
1397
1398
if test -z "$SKIP_COMPILER_CHECKS"; then
1399
1400
dnl ========================================================
1401
dnl =
1402
dnl = Compiler Options
1403
dnl =
1404
dnl ========================================================
1405
MOZ_ARG_HEADER(Compiler Options)
1406
1407
dnl ========================================================
1408
dnl Check for gcc -pipe support
1409
dnl ========================================================
1410
AC_MSG_CHECKING([for -pipe support])
1411
if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
1412
dnl Any gcc that supports firefox supports -pipe.
1413
CFLAGS="$CFLAGS -pipe"
1414
CXXFLAGS="$CXXFLAGS -pipe"
1415
AC_MSG_RESULT([yes])
1416
else
1417
AC_MSG_RESULT([no])
1418
fi
1419
1420
AC_LANG_CPLUSPLUS
1421
1422
dnl ========================================================
1423
dnl Check for tm_zone, tm_gmtoff in struct tm
1424
dnl ========================================================
1425
AC_CACHE_CHECK(for tm_zone tm_gmtoff in struct tm,
1426
ac_cv_struct_tm_zone_tm_gmtoff,
1427
[AC_TRY_COMPILE([#include <time.h>],
1428
[struct tm tm; tm.tm_zone = 0; tm.tm_gmtoff = 1;],
1429
[ac_cv_struct_tm_zone_tm_gmtoff="yes"],
1430
[ac_cv_struct_tm_zone_tm_gmtoff="no"])])
1431
if test "$ac_cv_struct_tm_zone_tm_gmtoff" = "yes" ; then
1432
AC_DEFINE(HAVE_TM_ZONE_TM_GMTOFF)
1433
fi
1434
fi # ! SKIP_COMPILER_CHECKS
1435
1436
AC_DEFINE(CPP_THROW_NEW, [throw()])
1437
AC_LANG_C
1438
1439
MOZ_EXPAND_LIBS
1440
1441
dnl ========================================================
1442
dnl = Link js shell to system readline
1443
dnl ========================================================
1444
MOZ_ARG_ENABLE_BOOL(readline,
1445
[ --enable-readline Link js shell to system readline library],
1446
JS_WANT_READLINE=1,
1447
JS_WANT_READLINE= )
1448
1449
JS_BUNDLED_EDITLINE=
1450
EDITLINE_LIBS=
1451
1452
case "$target" in
1453
*-mingw*)
1454
NO_EDITLINE=1
1455
;;
1456
*)
1457
;;
1458
esac
1459
1460
if test -z "$SKIP_LIBRARY_CHECKS" -a -z "$NO_EDITLINE"; then
1461
if test -n "$JS_WANT_READLINE"; then
1462
AC_CHECK_LIB(readline, readline,
1463
EDITLINE_LIBS="-lreadline",
1464
AC_MSG_ERROR([No system readline library found.]))
1465
else
1466
dnl By default, we use editline
1467
JS_BUNDLED_EDITLINE=1
1468
fi
1469
1470
dnl Either way, we want to build with line editing support.
1471
AC_DEFINE(EDITLINE)
1472
fi
1473
AC_SUBST(JS_BUNDLED_EDITLINE)
1474
AC_SUBST_LIST(EDITLINE_LIBS)
1475
1476
dnl ========================================================
1477
dnl =
1478
dnl = Standalone module options
1479
dnl =
1480
dnl ========================================================
1481
MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
1482
1483
dnl ========================================================
1484
dnl =
1485
dnl = Options for generating the shell as a script
1486
dnl =
1487
dnl ========================================================
1488
1489
MOZ_ARG_WITH_STRING(qemu-exe,
1490
[ --with-qemu-exe=path Use path as an arm emulator on host platforms],
1491
QEMU_EXE=$withval)
1492
AC_SUBST(QEMU_EXE)
1493
MOZ_ARG_WITH_STRING(cross-lib,
1494
[ --with-cross-lib=dir Use dir as the location for arm libraries],
1495
CROSS_LIB=$withval,
1496
CROSS_LIB=/usr/$target)
1497
AC_SUBST(CROSS_LIB)
1498
dnl ========================================================
1499
dnl =
1500
dnl = Maintainer debug option (no --enable equivalent)
1501
dnl =
1502
dnl ========================================================
1503
1504
AC_SUBST(NM)
1505
AC_SUBST_LIST(ASFLAGS)
1506
AC_SUBST(RCFLAGS)
1507
AC_SUBST(WINDRES)
1508
AC_SUBST(IMPLIB)
1509
AC_SUBST(FILTER)
1510
AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
1511
AC_SUBST(WARNINGS_AS_ERRORS)
1512
AC_SUBST_LIST(WARNINGS_CFLAGS)
1513
AC_SUBST(LIBICONV)
1514
1515
AC_SUBST(ENABLE_STRIP)
1516
AC_SUBST(PKG_SKIP_STRIP)
1517
AC_SUBST(INCREMENTAL_LINKER)
1518
1519
AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
1520
1521
AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
1522
1523
AC_SUBST(MOZ_APP_NAME)
1524
AC_SUBST(MOZ_APP_DISPLAYNAME)
1525
1526
AC_SUBST(MOZ_PKG_SPECIAL)
1527
1528
dnl ========================================================
1529
dnl ECMAScript Internationalization API Support (uses ICU)
1530
dnl ========================================================
1531
1532
dnl top-level configure may override this with --without-intl-api
1533
_INTL_API=yes
1534
1535
MOZ_CONFIG_ICU()
1536
1537
dnl Echo the CFLAGS to remove extra whitespace.
1538
CFLAGS=`echo \
1539
$_COMPILATION_CFLAGS \
1540
$CFLAGS`
1541
1542
CXXFLAGS=`echo \
1543
$_WARNINGS_CXXFLAGS \
1544
$_COMPILATION_CXXFLAGS \
1545
$CXXFLAGS`
1546
1547
COMPILE_CFLAGS=`echo \
1548
$_DEFINES_CFLAGS \
1549
$COMPILE_CFLAGS`
1550
1551
COMPILE_CXXFLAGS=`echo \
1552
$_DEFINES_CXXFLAGS \
1553
$COMPILE_CXXFLAGS`
1554
1555
HOST_CFLAGS=`echo \
1556
$_WARNINGS_HOST_CFLAGS \
1557
$_COMPILATION_HOST_CFLAGS \
1558
$HOST_CFLAGS`
1559
1560
HOST_CXXFLAGS=`echo \
1561
$_WARNINGS_HOST_CXXFLAGS \
1562
$_COMPILATION_HOST_CXXFLAGS \
1563
$HOST_CXXFLAGS`
1564
1565
AC_SUBST(MOZ_SYSTEM_NSPR)
1566
1567
OS_CFLAGS="$CFLAGS"
1568
OS_CXXFLAGS="$CXXFLAGS"
1569
OS_CPPFLAGS="$CPPFLAGS"
1570
OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
1571
OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
1572
OS_LDFLAGS="$LDFLAGS"
1573
OS_LIBS="$LIBS"
1574
AC_SUBST_LIST(OS_CFLAGS)
1575
AC_SUBST_LIST(OS_CXXFLAGS)
1576
AC_SUBST_LIST(OS_CPPFLAGS)
1577
AC_SUBST_LIST(OS_COMPILE_CFLAGS)
1578
AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
1579
AC_SUBST_LIST(OS_LDFLAGS)
1580
AC_SUBST(OS_LIBS)
1581
1582
AC_SUBST(HOST_CC)
1583
AC_SUBST(HOST_CXX)
1584
AC_SUBST_LIST(HOST_CFLAGS)
1585
AC_SUBST_LIST(HOST_CPPFLAGS)
1586
AC_SUBST_LIST(HOST_CXXFLAGS)
1587
AC_SUBST(HOST_LDFLAGS)
1588
AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
1589
AC_SUBST(HOST_BIN_SUFFIX)
1590
1591
AC_SUBST(TARGET_XPCOM_ABI)
1592
1593
AC_SUBST_LIST(DSO_CFLAGS)
1594
AC_SUBST_LIST(DSO_PIC_CFLAGS)
1595
AC_SUBST(DSO_LDOPTS)
1596
AC_SUBST(BIN_SUFFIX)
1597
AC_SUBST(USE_N32)
1598
AC_SUBST(MOZ_LINKER)
1599
AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
1600
AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
1601
1602
AC_CHECK_FUNCS(posix_fadvise posix_fallocate)
1603
1604
dnl Set various defines and substitutions
1605
dnl ========================================================
1606
1607
AC_SUBST(MOZ_DEV_EDITION)
1608
if test -n "$MOZ_DEV_EDITION"; then
1609
AC_DEFINE(MOZ_DEV_EDITION)
1610
fi
1611
1612
# Allow influencing configure with a defines.sh script.
1613
. "${srcdir}/build/defines.sh"
1614
1615
# If we're not building a release build, define EARLY_BETA_OR_EARLIER if it is
1616
# set in defines.sh
1617
if test "$BUILDING_RELEASE"; then
1618
# Override value in defines.sh, if any
1619
EARLY_BETA_OR_EARLIER=
1620
elif test "$EARLY_BETA_OR_EARLIER"; then
1621
AC_DEFINE(EARLY_BETA_OR_EARLIER)
1622
fi
1623
AC_SUBST(EARLY_BETA_OR_EARLIER)
1624
1625
BINDGEN_SYSTEM_FLAGS="$_BINDGEN_CFLAGS $NSPR_CFLAGS"
1626
AC_SUBST(BINDGEN_SYSTEM_FLAGS)
1627
1628
dnl ========================================================
1629
dnl JavaScript shell
1630
dnl ========================================================
1631
1632
MOZ_CHECK_ALLOCATOR
1633
1634
AC_SUBST(ac_configure_args)
1635
1636
if test -n "$JS_STANDALONE"; then
1637
MOZ_APP_NAME="mozjs"
1638
JS_LIBRARY_NAME="mozjs-$MOZILLA_SYMBOLVERSION"
1639
else
1640
JS_LIBRARY_NAME="mozjs"
1641
fi
1642
JS_CONFIG_LIBS="$NSPR_LIBS $LIBS"
1643
if test -n "$GNU_CC"; then
1644
JS_CONFIG_MOZ_JS_LIBS='-L${libdir} -l${JS_LIBRARY_NAME}'
1645
else
1646
JS_CONFIG_MOZ_JS_LIBS='${libdir}/${JS_LIBRARY_NAME}.lib'
1647
fi
1648
AC_SUBST(JS_LIBRARY_NAME)
1649
AC_SUBST(JS_CONFIG_MOZ_JS_LIBS)
1650
AC_SUBST(JS_CONFIG_LIBS)
1651
1652
# Avoid using obsolete NSPR features
1653
AC_DEFINE(NO_NSPR_10_SUPPORT)
1654
1655
dnl Spit out some output
1656
dnl ========================================================
1657
MOZ_CREATE_CONFIG_STATUS()
1658
1659
rm -fr confdefs* $ac_clean_files