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
DSO_CFLAGS=''
334
335
if test "$OS_ARCH" != "WINNT"; then
336
DSO_PIC_CFLAGS='-fPIC'
337
ASFLAGS="$ASFLAGS -fPIC"
338
fi
339
340
AC_MSG_CHECKING([for --noexecstack option to as])
341
_SAVE_CFLAGS=$CFLAGS
342
CFLAGS="$CFLAGS -Wa,--noexecstack"
343
AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
344
[ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
345
AC_MSG_RESULT([no]))
346
CFLAGS=$_SAVE_CFLAGS
347
AC_MSG_CHECKING([for -z noexecstack option to ld])
348
_SAVE_LDFLAGS=$LDFLAGS
349
LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
350
AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
351
AC_MSG_RESULT([no])
352
LDFLAGS=$_SAVE_LDFLAGS)
353
354
AC_MSG_CHECKING([for -z text option to ld])
355
_SAVE_LDFLAGS=$LDFLAGS
356
LDFLAGS="$LDFLAGS -Wl,-z,text"
357
AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
358
AC_MSG_RESULT([no])
359
LDFLAGS=$_SAVE_LDFLAGS)
360
361
AC_MSG_CHECKING([for -z relro option to ld])
362
_SAVE_LDFLAGS=$LDFLAGS
363
LDFLAGS="$LDFLAGS -Wl,-z,relro"
364
AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
365
AC_MSG_RESULT([no])
366
LDFLAGS=$_SAVE_LDFLAGS)
367
368
AC_MSG_CHECKING([for -z nocopyreloc option to ld])
369
_SAVE_LDFLAGS=$LDFLAGS
370
LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc"
371
AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
372
AC_MSG_RESULT([no])
373
LDFLAGS=$_SAVE_LDFLAGS)
374
375
AC_MSG_CHECKING([for -Bsymbolic-functions option to ld])
376
_SAVE_LDFLAGS=$LDFLAGS
377
LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
378
AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
379
AC_MSG_RESULT([no])
380
LDFLAGS=$_SAVE_LDFLAGS)
381
382
AC_MSG_CHECKING([for --build-id=sha1 option to ld])
383
_SAVE_LDFLAGS=$LDFLAGS
384
LDFLAGS="$LDFLAGS -Wl,--build-id=sha1"
385
AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
386
AC_MSG_RESULT([no])
387
LDFLAGS=$_SAVE_LDFLAGS)
388
389
_DEFINES_CFLAGS="-include $jsconfdefs -DMOZILLA_CLIENT"
390
_USE_CPP_INCLUDE_FLAG=1
391
fi
392
393
if test "$GNU_CXX"; then
394
_DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $jsconfdefs"
395
_USE_CPP_INCLUDE_FLAG=1
396
fi
397
398
dnl ========================================================
399
dnl System overrides of the defaults for host
400
dnl ========================================================
401
case "$host" in
402
*mingw*)
403
if test -n "$_WIN32_MSVC"; then
404
HOST_CFLAGS="$HOST_CFLAGS -nologo"
405
else
406
HOST_CFLAGS="$HOST_CFLAGS -mwindows"
407
fi
408
HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
409
HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
410
HOST_BIN_SUFFIX=.exe
411
412
case "${host_cpu}" in
413
i*86)
414
if test -n "$_WIN32_MSVC"; then
415
HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
416
fi
417
;;
418
x86_64)
419
if test -n "$_WIN32_MSVC"; then
420
HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
421
fi
422
HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
423
;;
424
esac
425
;;
426
427
*-darwin*)
428
HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
429
HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
430
;;
431
432
*-linux*|*-kfreebsd*-gnu|*-gnu*)
433
HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
434
HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
435
;;
436
437
*)
438
HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
439
HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
440
;;
441
esac
442
443
dnl ========================================================
444
dnl System overrides of the defaults for target
445
dnl ========================================================
446
447
case "$target" in
448
*-darwin*)
449
MOZ_OPTIMIZE_FLAGS="-O3"
450
CFLAGS="$CFLAGS -fno-common"
451
CXXFLAGS="$CXXFLAGS -fno-common -stdlib=libc++"
452
DSO_LDOPTS=''
453
STRIP="$STRIP -x -S"
454
LDFLAGS="$LDFLAGS -lobjc"
455
# The ExceptionHandling framework is needed for Objective-C exception
456
# logging code in nsObjCExceptions.h. Currently we only use that in debug
457
# builds.
458
_SAVE_LDFLAGS=$LDFLAGS
459
AC_MSG_CHECKING([for -framework ExceptionHandling])
460
LDFLAGS="$LDFLAGS -framework ExceptionHandling"
461
AC_TRY_LINK(,[return 0;],
462
ac_cv_have_framework_exceptionhandling="yes",
463
ac_cv_have_framework_exceptionhandling="no")
464
AC_MSG_RESULT([$ac_cv_have_framework_exceptionhandling])
465
if test "$ac_cv_have_framework_exceptionhandling" = "yes"; then
466
MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
467
fi
468
LDFLAGS=$_SAVE_LDFLAGS
469
470
dnl DTrace and -dead_strip don't interact well. See bug 403132.
471
dnl ===================================================================
472
if test "x$enable_dtrace" = "xyes"; then
473
echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
474
else
475
dnl check for the presence of the -dead_strip linker flag
476
AC_MSG_CHECKING([for -dead_strip option to ld])
477
_SAVE_LDFLAGS=$LDFLAGS
478
LDFLAGS="$LDFLAGS -Wl,-dead_strip"
479
AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
480
if test -n "$_HAVE_DEAD_STRIP" ; then
481
AC_MSG_RESULT([yes])
482
MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
483
else
484
AC_MSG_RESULT([no])
485
fi
486
487
LDFLAGS=$_SAVE_LDFLAGS
488
fi
489
MOZ_FIX_LINK_PATHS="-Wl,-executable_path,${DIST}/bin"
490
;;
491
492
*-android*|*-linuxandroid*)
493
MOZ_GFX_OPTIMIZE_MOBILE=1
494
MOZ_OPTIMIZE_FLAGS="-O3"
495
if test -z "$CLANG_CC"; then
496
MOZ_OPTIMIZE_FLAGS="-freorder-blocks -fno-reorder-functions $MOZ_OPTIMIZE_FLAGS"
497
fi
498
;;
499
500
*-*linux*)
501
if test "$GNU_CC" -o "$GNU_CXX"; then
502
MOZ_PGO_OPTIMIZE_FLAGS="-O3"
503
MOZ_OPTIMIZE_FLAGS="-O3"
504
if test -z "$CLANG_CC"; then
505
MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
506
fi
507
fi
508
509
case "${target_cpu}" in
510
alpha*)
511
CFLAGS="$CFLAGS -mieee"
512
CXXFLAGS="$CXXFLAGS -mieee"
513
;;
514
esac
515
;;
516
517
*-mingw*)
518
DSO_CFLAGS=
519
DSO_PIC_CFLAGS=
520
if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
521
# $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
522
if test -z "$CLANG_CC"; then
523
AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
524
fi
525
526
DSO_LDOPTS='-shared'
527
# Use temp file for windres (bug 213281)
528
RCFLAGS='-O coff --use-temp-file'
529
# mingw doesn't require kernel32, user32, and advapi32 explicitly
530
LIBS="$LIBS -lusp10 -lgdi32 -lwinmm -lwsock32"
531
MOZ_FIX_LINK_PATHS=
532
533
# Silence problematic clang warnings
534
CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
535
536
MOZ_OPTIMIZE_FLAGS="-O2"
537
538
WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
539
WIN32_GUI_EXE_LDFLAGS=-mwindows
540
else
541
TARGET_COMPILER_ABI=msvc
542
RANLIB='echo not_ranlib'
543
STRIP='echo not_strip'
544
PKG_SKIP_STRIP=1
545
# aarch64 doesn't support subsystems below 6.02
546
if test "$CPU_ARCH" = "aarch64"; then
547
WIN32_SUBSYSTEM_VERSION=6.02
548
else
549
WIN32_SUBSYSTEM_VERSION=6.01
550
fi
551
WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
552
WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
553
DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
554
_USE_CPP_INCLUDE_FLAG=1
555
_DEFINES_CFLAGS="-FI $jsconfdefs -DMOZILLA_CLIENT"
556
_DEFINES_CXXFLAGS="-FI $jsconfdefs -DMOZILLA_CLIENT"
557
CFLAGS="$CFLAGS -W3 -Gy -Zc:inline"
558
CXXFLAGS="$CXXFLAGS -W3 -Gy -Zc:inline"
559
if test "$CPU_ARCH" = "x86";then
560
dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
561
dnl more recent, so set that explicitly here unless another
562
dnl target arch has already been set.
563
changequote(,)
564
if test -z `echo $CFLAGS | grep -i [-/]arch:` ; then
565
CFLAGS="$CFLAGS -arch:SSE2"
566
fi
567
if test -z `echo $CXXFLAGS | grep -i [-/]arch:` ; then
568
CXXFLAGS="$CXXFLAGS -arch:SSE2"
569
fi
570
changequote([,])
571
fi
572
dnl VS2013+ supports -Gw for better linker optimizations.
574
dnl Disabled on ASan because it causes false-positive ODR violations.
575
if test -z "$MOZ_ASAN"; then
576
CFLAGS="$CFLAGS -Gw"
577
CXXFLAGS="$CXXFLAGS -Gw"
578
else
579
# String tail merging doesn't play nice with ASan's ODR checker.
580
LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
581
fi
582
if test -n "$CLANG_CL"; then
583
# XXX We should combine some of these with our generic GCC-style
584
# warning checks.
585
#
586
# Suppress the clang-cl warning for the inline 'new' and 'delete' in mozalloc
587
CXXFLAGS="$CXXFLAGS -Wno-inline-new-delete"
588
# We use offsetof on non-POD objects all the time.
589
# We also suppress this warning on other platforms.
590
CXXFLAGS="$CXXFLAGS -Wno-invalid-offsetof"
591
# This warns for reasonable things like:
592
# enum { X = 0xffffffffU };
593
# which is annoying for IDL headers.
594
CXXFLAGS="$CXXFLAGS -Wno-microsoft-enum-value"
595
# This warns for cases that would be reached by the Microsoft
596
# #include rules, but also currently warns on cases that would
597
# *also* be reached by standard C++ include rules. That
598
# behavior doesn't seem useful, so we turn it off.
599
CXXFLAGS="$CXXFLAGS -Wno-microsoft-include"
600
# We normally error out on unknown pragmas, but since clang-cl
601
# claims to be MSVC, it would be difficult to add
602
# #if defined(_MSC_VER) && !defined(__clang__) everywhere we
603
# use such pragmas, so just ignore them.
604
CFLAGS="$CFLAGS -Wno-unknown-pragmas"
605
CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas"
606
# We get errors about various #pragma intrinsic directives from
607
# clang-cl, and we don't need to hear about those.
608
CFLAGS="$CFLAGS -Wno-ignored-pragmas"
609
CXXFLAGS="$CXXFLAGS -Wno-ignored-pragmas"
610
# clang-cl's Intrin.h marks things like _ReadWriteBarrier
611
# as __attribute((__deprecated__)). This is nice to know,
612
# but since we don't get the equivalent warning from MSVC,
613
# let's just ignore it.
614
CFLAGS="$CFLAGS -Wno-deprecated-declarations"
615
CXXFLAGS="$CXXFLAGS -Wno-deprecated-declarations"
616
# We use a function like:
617
# __declspec(noreturn) __inline void f() {}
618
# which -Winvalid-noreturn complains about. Again, MSVC seems
619
# OK with it, so let's silence the warning.
620
CFLAGS="$CFLAGS -Wno-invalid-noreturn"
621
CXXFLAGS="$CXXFLAGS -Wno-invalid-noreturn"
622
# Missing |override| on virtual function declarations isn't
623
# something that MSVC currently warns about.
624
CXXFLAGS="$CXXFLAGS -Wno-inconsistent-missing-override"
625
# We use -DHAS_EXCEPTIONS=0, which removes the |throw()|
626
# declaration on |operator delete(void*)|. However, clang-cl
627
# must internally declare |operator delete(void*)| differently,
628
# which causes this warning for virtually every file in the
629
# tree. clang-cl doesn't support -fno-exceptions or equivalent,
630
# so there doesn't seem to be any way to convince clang-cl to
631
# declare |delete| differently. Therefore, suppress this
632
# warning.
633
CXXFLAGS="$CXXFLAGS -Wno-implicit-exception-spec-mismatch"
634
# At least one MSVC header and several headers in-tree have
635
# unused typedefs, so turn this on.
636
CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"
637
# jemalloc uses __declspec(allocator) as a profiler hint,
638
# which clang-cl doesn't understand.
639
CXXFLAGS="$CXXFLAGS -Wno-ignored-attributes"
640
# __attribute__((unused)) really means "might be unused" and
641
# we use it to avoid warnings about things that are unused
642
# in some compilation units, but used in many others. This
643
# warning insists on complaining about the latter case, which
644
# is annoying, and rather noisy.
645
CXXFLAGS="$CXXFLAGS -Wno-used-but-marked-unused"
646
fi
647
LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib"
648
MOZ_DEBUG_LDFLAGS='-DEBUG'
649
MOZ_OPTIMIZE_FLAGS="-O2"
650
MOZ_FIX_LINK_PATHS=
651
LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
652
if test -z "$DEVELOPER_OPTIONS"; then
653
LDFLAGS="$LDFLAGS -RELEASE"
654
fi
655
RCFLAGS="-nologo"
656
fi
657
AC_DEFINE(HAVE__MSIZE)
658
AC_DEFINE(WIN32_LEAN_AND_MEAN)
660
AC_DEFINE(NOMINMAX)
661
BIN_SUFFIX='.exe'
662
MOZ_USER_DIR="Mozilla"
663
664
case "$host_os" in
665
cygwin*|msvc*|mks*)
666
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.])
667
;;
668
esac
669
670
case "$target" in
671
i*86-*)
672
if test -n "$GNU_CC"; then
673
CFLAGS="$CFLAGS -mstackrealign"
674
CXXFLAGS="$CXXFLAGS -mstackrealign"
675
LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
676
else
677
DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
678
LDFLAGS="$LDFLAGS -SAFESEH"
679
fi
680
681
AC_DEFINE(_X86_)
682
;;
683
x86_64-*)
684
if test -n "$_WIN32_MSVC"; then
685
DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
686
fi
687
AC_DEFINE(_AMD64_)
688
;;
689
aarch64-*)
690
if test -n "$_WIN32_MSVC"; then
691
DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
692
fi
693
AC_DEFINE(_ARM64_)
694
;;
695
*)
696
AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
697
;;
698
esac
699
;;
700
701
*-netbsd*)
702
DSO_CFLAGS=''
703
CFLAGS="$CFLAGS -Dunix"
704
CXXFLAGS="$CXXFLAGS -Dunix"
705
if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
706
DSO_PIC_CFLAGS='-fPIC -DPIC'
707
DSO_LDOPTS='-shared'
708
MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
709
else
710
DSO_PIC_CFLAGS='-fPIC -DPIC'
711
DSO_LDOPTS='-shared'
712
fi
713
# This will fail on a.out systems prior to 1.5.1_ALPHA.
714
if test "$LIBRUNPATH"; then
715
DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
716
fi
717
;;
718
719
*-openbsd*)
720
DSO_CFLAGS=''
721
DSO_PIC_CFLAGS='-fPIC'
722
DSO_LDOPTS='-shared -fPIC'
723
if test "$LIBRUNPATH"; then
724
DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
725
fi
726
;;
727
728
*-solaris*)
729
MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
730
;;
731
732
esac
733
734
if test -z "$MOZ_OPTIMIZE_FLAGS"; then
735
MOZ_OPTIMIZE_FLAGS="-O"
736
fi
737
738
if test -z "$COMPILE_ENVIRONMENT"; then
739
SKIP_COMPILER_CHECKS=1
740
SKIP_LIBRARY_CHECKS=1
741
fi
742
743
if test -n "$COMPILE_ENVIRONMENT"; then
744
MOZ_COMPILER_OPTS
745
fi
746
747
if test -z "$SKIP_COMPILER_CHECKS"; then
748
dnl Checks for typedefs, structures, and compiler characteristics.
749
dnl ========================================================
750
AC_C_CONST
751
AC_TYPE_MODE_T
752
AC_TYPE_OFF_T
753
AC_TYPE_PID_T
754
AC_TYPE_SIZE_T
755
AC_LANG_CPLUSPLUS
756
AC_LANG_C
757
AC_MSG_CHECKING(for ssize_t)
758
AC_CACHE_VAL(ac_cv_type_ssize_t,
759
[AC_TRY_COMPILE([#include <stdio.h>
760
#include <sys/types.h>],
761
[ssize_t foo = 0;],
762
[ac_cv_type_ssize_t=true],
763
[ac_cv_type_ssize_t=false])])
764
if test "$ac_cv_type_ssize_t" = true ; then
765
AC_DEFINE(HAVE_SSIZE_T)
766
AC_MSG_RESULT(yes)
767
else
768
AC_MSG_RESULT(no)
769
fi
770
771
AC_LANG_CPLUSPLUS
772
773
MOZ_CXX11
774
775
case "${OS_TARGET}" in
776
WINNT|Darwin|Android)
777
;;
778
*)
779
STL_FLAGS="-I${DIST}/stl_wrappers"
780
WRAP_STL_INCLUDES=1
781
;;
782
esac
783
784
dnl Checks for header files.
785
dnl ========================================================
786
AC_HEADER_DIRENT
787
case "$target_os" in
788
freebsd*)
789
# for stuff like -lXshm
790
CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
791
;;
792
esac
793
794
MOZ_ARG_ENABLE_BOOL(dtrace,
795
[ --enable-dtrace build with dtrace support if available (default=no)],
796
[enable_dtrace="yes"],)
797
if test "x$enable_dtrace" = "xyes"; then
798
MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
799
if test -n "$HAVE_DTRACE"; then
800
AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
801
else
802
AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
803
fi
804
fi
805
AC_SUBST(HAVE_DTRACE)
806
807
dnl Checks for libraries.
808
dnl ========================================================
809
AC_CHECK_LIB(c_r, gethostbyname_r)
810
811
dnl We don't want to link with libdl even if it's present on OS X, since
812
dnl it's not used and not part of the default installation. OS/2 has dlfcn
813
dnl in libc.
814
dnl We don't want to link against libm or libpthread on Darwin since
815
dnl they both are just symlinks to libSystem and explicitly linking
816
dnl against libSystem causes issues when debugging (see bug 299601).
817
case $target in
818
*-darwin*)
819
;;
820
*)
821
AC_SEARCH_LIBS(dlopen, dl,
822
MOZ_CHECK_HEADER(dlfcn.h,
823
AC_DEFINE(HAVE_DLOPEN)))
824
;;
825
esac
826
827
if test ! "$GNU_CXX"; then
828
AC_CHECK_LIB(C, demangle)
829
fi
830
831
AC_CHECK_LIB(socket, socket)
832
833
dnl ========================================================
834
dnl = pthread support
835
dnl = Start by checking whether the system support pthreads
836
dnl ========================================================
837
case "$target_os" in
838
darwin*)
839
USE_PTHREADS=1
840
;;
841
*)
842
AC_CHECK_LIB(pthreads, pthread_create,
843
USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
844
AC_CHECK_LIB(pthread, pthread_create,
845
USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
846
AC_CHECK_LIB(c_r, pthread_create,
847
USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
848
AC_CHECK_LIB(c, pthread_create,
849
USE_PTHREADS=1
850
)
851
)
852
)
853
)
854
;;
855
esac
856
857
dnl ========================================================
858
dnl Do the platform specific pthread hackery
859
dnl ========================================================
860
if test "$USE_PTHREADS"x != x
861
then
862
dnl
863
dnl See if -pthread is supported.
864
dnl
865
rm -f conftest*
866
ac_cv_have_dash_pthread=no
867
AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
868
echo 'int main() { return 0; }' | cat > conftest.c
869
${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
870
if test $? -eq 0; then
871
if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
872
ac_cv_have_dash_pthread=yes
873
case "$target_os" in
874
freebsd*)
875
# Freebsd doesn't use -pthread for compiles, it uses them for linking
876
;;
877
*)
878
CFLAGS="$CFLAGS -pthread"
879
CXXFLAGS="$CXXFLAGS -pthread"
880
;;
881
esac
882
fi
883
fi
884
rm -f conftest*
885
AC_MSG_RESULT($ac_cv_have_dash_pthread)
886
887
dnl
888
dnl See if -pthreads is supported.
889
dnl
890
ac_cv_have_dash_pthreads=no
891
if test "$ac_cv_have_dash_pthread" = "no"; then
892
AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
893
echo 'int main() { return 0; }' | cat > conftest.c
894
${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
895
if test $? -eq 0; then
896
if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
897
ac_cv_have_dash_pthreads=yes
898
CFLAGS="$CFLAGS -pthreads"
899
CXXFLAGS="$CXXFLAGS -pthreads"
900
fi
901
fi
902
rm -f conftest*
903
AC_MSG_RESULT($ac_cv_have_dash_pthreads)
904
fi
905
906
case "$target" in
907
*-*-freebsd*)
908
AC_DEFINE(_REENTRANT)
909
AC_DEFINE(_THREAD_SAFE)
910
dnl -pthread links in -lpthread, so don't specify it explicitly.
911
if test "$ac_cv_have_dash_pthread" = "yes"; then
912
_PTHREAD_LDFLAGS="-pthread"
913
fi
914
;;
915
916
*-*-openbsd*|*-*-bsdi*)
917
AC_DEFINE(_REENTRANT)
918
AC_DEFINE(_THREAD_SAFE)
919
dnl -pthread links in -lc_r, so don't specify it explicitly.
920
if test "$ac_cv_have_dash_pthread" = "yes"; then
921
_PTHREAD_LDFLAGS="-pthread"
922
fi
923
;;
924
925
*-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
926
AC_DEFINE(_REENTRANT)
927
;;
928
929
esac
930
LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
931
fi
932
933
934
dnl Checks for library functions.
935
dnl ========================================================
936
AC_CHECK_FUNCS([getc_unlocked _getc_nolock gmtime_r localtime_r pthread_getname_np pthread_get_name_np])
937
938
dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
939
AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
940
ac_cv_clock_monotonic,
941
[for libs in "" -lrt; do
942
_SAVE_LIBS="$LIBS"
943
_SAVE_CFLAGS="$CFLAGS"
944
LIBS="$LIBS $libs"
945
CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
946
dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
947
dnl we should or not be able to use it. To detect if we can, we need to make the
948
dnl availability attribute strict, so that compilation fails when the target is < 10.12.
949
AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
950
#include <time.h>],
951
[ struct timespec ts;
952
clock_gettime(CLOCK_MONOTONIC, &ts); ],
953
ac_cv_clock_monotonic=$libs
954
LIBS="$_SAVE_LIBS"
955
break,
956
ac_cv_clock_monotonic=no)
957
LIBS="$_SAVE_LIBS"
958
CFLAGS="$_SAVE_CFLAGS"
959
done])
960
if test "$ac_cv_clock_monotonic" != "no"; then
961
HAVE_CLOCK_MONOTONIC=1
962
REALTIME_LIBS=$ac_cv_clock_monotonic
963
AC_DEFINE(HAVE_CLOCK_MONOTONIC)
964
AC_SUBST(HAVE_CLOCK_MONOTONIC)
965
AC_SUBST_LIST(REALTIME_LIBS)
966
fi
967
968
dnl Checks for math functions.
969
dnl ========================================================
970
AC_CHECK_LIB(m, sin)
971
972
AC_CACHE_CHECK(
973
[for res_ninit()],
974
ac_cv_func_res_ninit,
975
[if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
976
dnl no need for res_ninit() on NetBSD and OpenBSD
977
ac_cv_func_res_ninit=no
978
else
979
AC_TRY_LINK([
980
#ifdef linux
981
#define _BSD_SOURCE 1
982
#endif
983
#include <sys/types.h>
984
#include <netinet/in.h>
985
#include <arpa/nameser.h>
986
#include <resolv.h>
987
],
988
[int foo = res_ninit(&_res);],
989
[ac_cv_func_res_ninit=yes],
990
[ac_cv_func_res_ninit=no])
991
fi
992
])
993
994
if test "$ac_cv_func_res_ninit" = "yes"; then
995
AC_DEFINE(HAVE_RES_NINIT)
996
dnl must add the link line we do something as foolish as this... dougt
997
dnl else
998
dnl AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
999
dnl AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
1000
fi
1001
1002
AM_LANGINFO_CODESET
1003
1004
AC_LANG_C
1005
1006
dnl **********************
1007
dnl *** va_copy checks ***
1008
dnl **********************
1009
AC_CACHE_CHECK([for an implementation of va_copy()],
1010
ac_cv_va_copy,
1011
[AC_TRY_COMPILE([#include <stdarg.h>
1012
#include <stdlib.h>
1013
void f (int i, ...) {
1014
va_list args1, args2;
1015
va_start (args1, i);
1016
va_copy (args2, args1);
1017
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1018
exit (1);
1019
va_end (args1); va_end (args2);
1020
}],
1021
[f(0, 42); return 0],
1022
[ac_cv_va_copy=yes],
1023
[ac_cv_va_copy=no]
1024
)]
1025
)
1026
AC_CACHE_CHECK([whether va_list can be copied by value],
1027
ac_cv_va_val_copy,
1028
[AC_TRY_COMPILE([#include <stdarg.h>
1029
#include <stdlib.h>
1030
void f (int i, ...) {
1031
va_list args1, args2;
1032
va_start (args1, i);
1033
args2 = args1;
1034
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1035
exit (1);
1036
va_end (args1); va_end (args2);
1037
}],
1038
[f(0, 42); return 0],
1039
[ac_cv_va_val_copy=yes],
1040
[ac_cv_va_val_copy=no],
1041
)]
1042
)
1043
if test "x$ac_cv_va_copy" = "xyes"; then
1044
AC_DEFINE(VA_COPY, va_copy)
1045
AC_DEFINE(HAVE_VA_COPY)
1046
fi
1047
1048
if test "x$ac_cv_va_val_copy" = "xno"; then
1049
AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
1050
fi
1051
1052
dnl ===================================================================
1053
dnl ========================================================
1054
dnl Put your C++ language/feature checks below
1055
dnl ========================================================
1056
AC_LANG_CPLUSPLUS
1057
1058
ARM_ABI_PREFIX=
1059
if test "$GNU_CC"; then
1060
if test "$CPU_ARCH" = "arm" ; then
1061
AC_CACHE_CHECK(for ARM EABI,
1062
ac_cv_gcc_arm_eabi,
1063
[AC_TRY_COMPILE([],
1064
[
1065
#if defined(__ARM_EABI__)
1066
return 0;
1067
#else
1068
#error Not ARM EABI.
1069
#endif
1070
],
1071
ac_cv_gcc_arm_eabi="yes",
1072
ac_cv_gcc_arm_eabi="no")])
1073
if test "$ac_cv_gcc_arm_eabi" = "yes"; then
1074
HAVE_ARM_EABI=1
1075
ARM_ABI_PREFIX=eabi-
1076
else
1077
ARM_ABI_PREFIX=oabi-
1078
fi
1079
fi
1080
1081
TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
1082
fi
1083
1084
# try harder, when checking for __thread support, see bug 521750 comment #33 and below
1085
# We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
1086
# enabled, the linker in xcode 4.1 will crash. Without this it would crash when
1087
# linking XUL.
1088
_SAVE_LDFLAGS=$LDFLAGS
1089
LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
1090
AC_CACHE_CHECK(for __thread keyword for TLS variables,
1091
ac_cv_thread_keyword,
1092
[AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
1093
[return tlsIsMainThread;],
1094
ac_cv_thread_keyword=yes,
1095
ac_cv_thread_keyword=no)])
1096
LDFLAGS=$_SAVE_LDFLAGS
1097
if test "$ac_cv_thread_keyword" = yes; then
1098
# mips builds fail with TLS variables because of a binutils bug.
1099
# See bug 528687
1100
case "${target}" in
1101
mips*-*)
1102
:
1103
;;
1104
*-android*|*-linuxandroid*)
1105
:
1106
;;
1107
*)
1108
AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
1109
;;
1110
esac
1111
fi
1112
1113
dnl End of C++ language/feature checks
1114
AC_LANG_C
1115
1116
dnl ========================================================
1117
dnl = Internationalization checks
1118
dnl ========================================================
1119
dnl
1120
dnl Internationalization and Locale support is different
1121
dnl on various UNIX platforms. Checks for specific i18n
1122
dnl features go here.
1123
1124
AC_HAVE_FUNCS(localeconv)
1125
fi # ! SKIP_COMPILER_CHECKS
1126
1127
TARGET_XPCOM_ABI=
1128
if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
1129
TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
1130
fi
1131
1132
dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
1133
dnl features that Windows actually does support.
1134
1135
if test -n "$SKIP_COMPILER_CHECKS"; then
1136
dnl Windows has malloc.h
1137
AC_DEFINE(MALLOC_H, [<malloc.h>])
1138
AC_DEFINE(HAVE_FORCEINLINE)
1139
AC_DEFINE(HAVE_LOCALECONV)
1140
fi # SKIP_COMPILER_CHECKS
1141
1142
dnl Mozilla specific options
1143
dnl ========================================================
1144
dnl The macros used for command line options
1145
dnl are defined in build/autoconf/altoptions.m4.
1146
1147
dnl ========================================================
1148
dnl =
1149
dnl = Check for external package dependencies
1150
dnl =
1151
dnl ========================================================
1152
MOZ_ARG_HEADER(External Packages)
1153
1154
MOZ_CONFIG_NSPR(js)
1155
1156
dnl ========================================================
1157
dnl system zlib Support
1158
dnl ========================================================
1159
dnl Standalone js defaults to system zlib
1160
if test -n "$JS_STANDALONE"; then
1161
ZLIB_DIR=yes
1162
fi
1163
1164
MOZ_ZLIB_CHECK([1.2.3])
1165
1166
if test -n "$ZLIB_IN_MOZGLUE"; then
1167
AC_DEFINE(ZLIB_IN_MOZGLUE)
1168
fi
1169
AC_SUBST(ZLIB_IN_MOZGLUE)
1170
1171
dnl ========================================================
1172
dnl =
1173
dnl = Application
1174
dnl =
1175
dnl ========================================================
1176
1177
MOZ_ARG_HEADER(Application)
1178
1179
dnl ========================================================
1180
dnl =
1181
dnl = Components & Features
1182
dnl =
1183
dnl ========================================================
1184
MOZ_ARG_HEADER(Components and Features)
1185
1186
dnl ========================================================
1187
dnl =
1188
dnl = Module specific options
1189
dnl =
1190
dnl ========================================================
1191
MOZ_ARG_HEADER(Individual module options)
1192
1193
dnl ========================================================
1194
dnl =
1195
dnl = Debugging Options
1196
dnl =
1197
dnl ========================================================
1198
MOZ_ARG_HEADER(Debugging and Optimizations)
1199
1200
dnl ========================================================
1201
dnl = Enable code optimization. ON by default.
1202
dnl ========================================================
1203
1204
# Use value from moz.configure if one is defined. Else use our computed
1205
# value.
1206
if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
1207
MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
1208
fi
1209
1210
if test "$COMPILE_ENVIRONMENT"; then
1211
if test -n "$MOZ_OPTIMIZE"; then
1212
AC_MSG_CHECKING([for valid optimization flags])
1213
_SAVE_CFLAGS=$CFLAGS
1214
CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
1215
AC_TRY_COMPILE([#include <stdio.h>],
1216
[printf("Hello World\n");],
1217
_results=yes,
1218
_results=no)
1219
AC_MSG_RESULT([$_results])
1220
if test "$_results" = "no"; then
1221
AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
1222
fi
1223
CFLAGS=$_SAVE_CFLAGS
1224
if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
1225
# When using llvm-based LTO, non numeric optimization levels are
1226
# not supported by the linker, so force the linker to use -O2 (
1227
# which doesn't influence the level compilation units are actually
1228
# compiled at).
1229
case " $MOZ_OPTIMIZE_FLAGS " in
1230
*\ -Os\ *|*\ -Oz\ *)
1231
MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
1232
;;
1233
esac
1234
fi
1235
fi
1236
fi # COMPILE_ENVIRONMENT
1237
1238
AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
1239
AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
1240
AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
1241
1242
dnl ========================================================
1243
dnl = Enable jemalloc
1244
dnl ========================================================
1245
1246
if test "$JS_STANDALONE" -a -z "$MOZ_MEMORY"; then
1247
MOZ_GLUE_IN_PROGRAM=
1248
else
1249
case "${OS_TARGET}" in
1250
Android|WINNT|Darwin)
1251
MOZ_GLUE_IN_PROGRAM=
1252
;;
1253
*)
1254
dnl On !Android !Windows !OSX, we only want to link executables against mozglue
1255
MOZ_GLUE_IN_PROGRAM=1
1256
AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
1257
;;
1258
esac
1259
fi
1260
1261
if test "$MOZ_MEMORY"; then
1262
dnl The generic feature tests that determine how to compute ncpus are long and
1263
dnl complicated. Therefore, simply define special cpp variables for the
1264
dnl platforms we have special knowledge of.
1265
case "${target}" in
1266
*-mingw*)
1267
export MOZ_NO_DEBUG_RTL=1
1268
;;
1269
esac
1270
fi
1271
AC_SUBST(MOZ_GLUE_IN_PROGRAM)
1272
1273
dnl ========================================================
1274
dnl instruments
1275
dnl ========================================================
1276
if test -n "$MOZ_INSTRUMENTS"; then
1277
LIBS="$LIBS -framework CoreFoundation"
1278
fi
1279
1280
dnl ========================================================
1281
dnl Debug (see Bug 939505)
1282
dnl ========================================================
1283
if test -n "$MOZ_DEBUG"; then
1284
AC_DEFINE(JS_DEBUG)
1285
fi
1286
1287
dnl ========================================================
1288
dnl = Enable using the clang plugin to build
1289
dnl ========================================================
1290
1291
if test -n "$COMPILE_ENVIRONMENT"; then
1292
MOZ_CONFIG_CLANG_PLUGIN
1293
fi # COMPILE_ENVIRONMENT
1294
1295
dnl ========================================================
1296
dnl = Enable static checking using sixgill
1297
dnl ========================================================
1298
1299
MOZ_ARG_WITH_STRING(sixgill,
1300
[ --with-sixgill=path/to/sixgill
1301
Enable static checking of code using sixgill],
1302
SIXGILL_PATH=$withval,
1303
SIXGILL_PATH= )
1304
1305
if test -n "$SIXGILL_PATH"; then
1306
if test ! -x "$SIXGILL_PATH/bin/xdbfind" || test ! -f "$SIXGILL_PATH/gcc/xgill.so" || test ! -x "$SIXGILL_PATH/scripts/wrap_gcc/g++"; then
1307
AC_MSG_ERROR([The sixgill plugin and binaries are not at the specified path.])
1308
fi
1309
fi
1310
AC_SUBST(SIXGILL_PATH)
1311
1312
dnl ========================================================
1313
dnl = Enable stripping of libs & executables
1314
dnl ========================================================
1315
MOZ_ARG_ENABLE_BOOL(strip,
1316
[ --enable-strip Enable stripping of libs & executables ],
1317
ENABLE_STRIP=1,
1318
ENABLE_STRIP= )
1319
1320
dnl ========================================================
1321
dnl = Enable stripping of libs & executables when packaging
1322
dnl ========================================================
1323
MOZ_ARG_ENABLE_BOOL(install-strip,
1324
[ --enable-install-strip Enable stripping of libs & executables when packaging ],
1325
PKG_SKIP_STRIP= ,
1326
PKG_SKIP_STRIP=1)
1327
1328
dnl ========================================================
1329
dnl =
1330
dnl = Profiling and Instrumenting
1331
dnl =
1332
dnl ========================================================
1333
MOZ_ARG_HEADER(Profiling and Instrumenting)
1334
1335
dnl ========================================================
1336
dnl = Support for demangling undefined symbols
1337
dnl ========================================================
1338
if test -z "$SKIP_LIBRARY_CHECKS"; then
1339
AC_LANG_SAVE
1340
AC_LANG_CPLUSPLUS
1341
AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
1342
AC_LANG_RESTORE
1343
fi
1344
1345
dnl ========================================================
1346
dnl JIT observers
1347
dnl ========================================================
1348
1349
MOZ_ARG_WITH_STRING(jitreport-granularity,
1350
[ --jitreport-granularity=N
1351
Default granularity at which to report JIT code
1352
to external tools
1353
0 - no info
1354
1 - code ranges for whole functions only
1355
2 - per-line information
1356
3 - per-op information],
1357
JITREPORT_GRANULARITY=$withval,
1358
JITREPORT_GRANULARITY=3)
1359
1360
AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
1361
1362
dnl ========================================================
1363
dnl =
1364
dnl = Misc. Options
1365
dnl =
1366
dnl ========================================================
1367
MOZ_ARG_HEADER(Misc. Options)
1368
1369
if test -z "$SKIP_COMPILER_CHECKS"; then
1370
1371
dnl ========================================================
1372
dnl =
1373
dnl = Compiler Options
1374
dnl =
1375
dnl ========================================================
1376
MOZ_ARG_HEADER(Compiler Options)
1377
1378
dnl ========================================================
1379
dnl Check for gcc -pipe support
1380
dnl ========================================================
1381
AC_MSG_CHECKING([for -pipe support])
1382
if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
1383
dnl Any gcc that supports firefox supports -pipe.
1384
CFLAGS="$CFLAGS -pipe"
1385
CXXFLAGS="$CXXFLAGS -pipe"
1386
AC_MSG_RESULT([yes])
1387
else
1388
AC_MSG_RESULT([no])
1389
fi
1390
1391
AC_LANG_CPLUSPLUS
1392
1393
dnl ========================================================
1394
dnl Check for tm_zone, tm_gmtoff in struct tm
1395
dnl ========================================================
1396
AC_CACHE_CHECK(for tm_zone tm_gmtoff in struct tm,
1397
ac_cv_struct_tm_zone_tm_gmtoff,
1398
[AC_TRY_COMPILE([#include <time.h>],
1399
[struct tm tm; tm.tm_zone = 0; tm.tm_gmtoff = 1;],
1400
[ac_cv_struct_tm_zone_tm_gmtoff="yes"],
1401
[ac_cv_struct_tm_zone_tm_gmtoff="no"])])
1402
if test "$ac_cv_struct_tm_zone_tm_gmtoff" = "yes" ; then
1403
AC_DEFINE(HAVE_TM_ZONE_TM_GMTOFF)
1404
fi
1405
fi # ! SKIP_COMPILER_CHECKS
1406
1407
AC_LANG_C
1408
1409
MOZ_EXPAND_LIBS
1410
1411
dnl ========================================================
1412
dnl = Link js shell to system readline
1413
dnl ========================================================
1414
MOZ_ARG_ENABLE_BOOL(readline,
1415
[ --enable-readline Link js shell to system readline library],
1416
JS_WANT_READLINE=1,
1417
JS_WANT_READLINE= )
1418
1419
JS_BUNDLED_EDITLINE=
1420
EDITLINE_LIBS=
1421
1422
case "$target" in
1423
*-mingw*)
1424
NO_EDITLINE=1
1425
;;
1426
*)
1427
;;
1428
esac
1429
1430
if test -z "$SKIP_LIBRARY_CHECKS" -a -z "$NO_EDITLINE"; then
1431
if test -n "$JS_WANT_READLINE"; then
1432
AC_CHECK_LIB(readline, readline,
1433
EDITLINE_LIBS="-lreadline",
1434
AC_MSG_ERROR([No system readline library found.]))
1435
else
1436
dnl By default, we use editline
1437
JS_BUNDLED_EDITLINE=1
1438
fi
1439
1440
dnl Either way, we want to build with line editing support.
1441
AC_DEFINE(EDITLINE)
1442
fi
1443
AC_SUBST(JS_BUNDLED_EDITLINE)
1444
AC_SUBST_LIST(EDITLINE_LIBS)
1445
1446
dnl ========================================================
1447
dnl =
1448
dnl = Standalone module options
1449
dnl =
1450
dnl ========================================================
1451
MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
1452
1453
dnl ========================================================
1454
dnl =
1455
dnl = Options for generating the shell as a script
1456
dnl =
1457
dnl ========================================================
1458
1459
MOZ_ARG_WITH_STRING(qemu-exe,
1460
[ --with-qemu-exe=path Use path as an arm emulator on host platforms],
1461
QEMU_EXE=$withval)
1462
AC_SUBST(QEMU_EXE)
1463
MOZ_ARG_WITH_STRING(cross-lib,
1464
[ --with-cross-lib=dir Use dir as the location for arm libraries],
1465
CROSS_LIB=$withval,
1466
CROSS_LIB=/usr/$target)
1467
AC_SUBST(CROSS_LIB)
1468
dnl ========================================================
1469
dnl =
1470
dnl = Maintainer debug option (no --enable equivalent)
1471
dnl =
1472
dnl ========================================================
1473
1474
AC_SUBST(NM)
1475
AC_SUBST_LIST(ASFLAGS)
1476
AC_SUBST(RCFLAGS)
1477
AC_SUBST(WINDRES)
1478
AC_SUBST(IMPLIB)
1479
AC_SUBST(FILTER)
1480
AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
1481
AC_SUBST_LIST(WARNINGS_CFLAGS)
1482
AC_SUBST(LIBICONV)
1483
1484
AC_SUBST(ENABLE_STRIP)
1485
AC_SUBST(PKG_SKIP_STRIP)
1486
AC_SUBST(INCREMENTAL_LINKER)
1487
1488
AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
1489
1490
AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
1491
1492
AC_SUBST(MOZ_APP_NAME)
1493
AC_SUBST(MOZ_APP_DISPLAYNAME)
1494
1495
AC_SUBST(MOZ_PKG_SPECIAL)
1496
1497
dnl ========================================================
1498
dnl ECMAScript Internationalization API Support (uses ICU)
1499
dnl ========================================================
1500
1501
dnl top-level configure may override this with --without-intl-api
1502
_INTL_API=yes
1503
1504
MOZ_CONFIG_ICU()
1505
1506
dnl Echo the CFLAGS to remove extra whitespace.
1507
CFLAGS=`echo \
1508
$_COMPILATION_CFLAGS \
1509
$CFLAGS`
1510
1511
CXXFLAGS=`echo \
1512
$_WARNINGS_CXXFLAGS \
1513
$_COMPILATION_CXXFLAGS \
1514
$CXXFLAGS`
1515
1516
COMPILE_CFLAGS=`echo \
1517
$_DEFINES_CFLAGS \
1518
$COMPILE_CFLAGS`
1519
1520
COMPILE_CXXFLAGS=`echo \
1521
$_DEFINES_CXXFLAGS \
1522
$COMPILE_CXXFLAGS`
1523
1524
HOST_CFLAGS=`echo \
1525
$_WARNINGS_HOST_CFLAGS \
1526
$_COMPILATION_HOST_CFLAGS \
1527
$HOST_CFLAGS`
1528
1529
HOST_CXXFLAGS=`echo \
1530
$_WARNINGS_HOST_CXXFLAGS \
1531
$_COMPILATION_HOST_CXXFLAGS \
1532
$HOST_CXXFLAGS`
1533
1534
AC_SUBST(MOZ_SYSTEM_NSPR)
1535
1536
OS_CFLAGS="$CFLAGS"
1537
OS_CXXFLAGS="$CXXFLAGS"
1538
OS_CPPFLAGS="$CPPFLAGS"
1539
OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
1540
OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
1541
OS_LDFLAGS="$LDFLAGS"
1542
OS_LIBS="$LIBS"
1543
AC_SUBST_LIST(OS_CFLAGS)
1544
AC_SUBST_LIST(OS_CXXFLAGS)
1545
AC_SUBST_LIST(OS_CPPFLAGS)
1546
AC_SUBST_LIST(OS_COMPILE_CFLAGS)
1547
AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
1548
AC_SUBST_LIST(OS_LDFLAGS)
1549
AC_SUBST(OS_LIBS)
1550
1551
AC_SUBST(HOST_CC)
1552
AC_SUBST(HOST_CXX)
1553
AC_SUBST_LIST(HOST_CFLAGS)
1554
AC_SUBST_LIST(HOST_CPPFLAGS)
1555
AC_SUBST_LIST(HOST_CXXFLAGS)
1556
AC_SUBST(HOST_LDFLAGS)
1557
AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
1558
AC_SUBST(HOST_BIN_SUFFIX)
1559
1560
AC_SUBST(TARGET_XPCOM_ABI)
1561
1562
AC_SUBST_LIST(DSO_CFLAGS)
1563
AC_SUBST_LIST(DSO_PIC_CFLAGS)
1564
AC_SUBST(DSO_LDOPTS)
1565
AC_SUBST(BIN_SUFFIX)
1566
AC_SUBST(USE_N32)
1567
AC_SUBST(MOZ_LINKER)
1568
AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
1569
AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
1570
1571
AC_CHECK_FUNCS(posix_fadvise posix_fallocate)
1572
1573
dnl Set various defines and substitutions
1574
dnl ========================================================
1575
1576
AC_SUBST(MOZ_DEV_EDITION)
1577
if test -n "$MOZ_DEV_EDITION"; then
1578
AC_DEFINE(MOZ_DEV_EDITION)
1579
fi
1580
1581
# Allow influencing configure with a defines.sh script.
1582
. "${srcdir}/build/defines.sh"
1583
1584
# If we're not building a release build, define EARLY_BETA_OR_EARLIER if it is
1585
# set in defines.sh
1586
if test "$BUILDING_RELEASE"; then
1587
# Override value in defines.sh, if any
1588
EARLY_BETA_OR_EARLIER=
1589
elif test "$EARLY_BETA_OR_EARLIER"; then
1590
AC_DEFINE(EARLY_BETA_OR_EARLIER)
1591
fi
1592
AC_SUBST(EARLY_BETA_OR_EARLIER)
1593
1594
BINDGEN_SYSTEM_FLAGS="$_BINDGEN_CFLAGS $NSPR_CFLAGS"
1595
AC_SUBST(BINDGEN_SYSTEM_FLAGS)
1596
1597
dnl ========================================================
1598
dnl JavaScript shell
1599
dnl ========================================================
1600
1601
MOZ_CHECK_ALLOCATOR
1602
1603
AC_SUBST(ac_configure_args)
1604
1605
if test -n "$JS_STANDALONE"; then
1606
MOZ_APP_NAME="mozjs"
1607
JS_LIBRARY_NAME="mozjs-$MOZILLA_SYMBOLVERSION"
1608
else
1609
JS_LIBRARY_NAME="mozjs"
1610
fi
1611
JS_CONFIG_LIBS="$NSPR_LIBS $LIBS"
1612
if test -n "$GNU_CC"; then
1613
JS_CONFIG_MOZ_JS_LIBS='-L${libdir} -l${JS_LIBRARY_NAME}'
1614
else
1615
JS_CONFIG_MOZ_JS_LIBS='${libdir}/${JS_LIBRARY_NAME}.lib'
1616
fi
1617
AC_SUBST(JS_LIBRARY_NAME)
1618
AC_SUBST(JS_CONFIG_MOZ_JS_LIBS)
1619
AC_SUBST(JS_CONFIG_LIBS)
1620
1621
# Avoid using obsolete NSPR features
1622
AC_DEFINE(NO_NSPR_10_SUPPORT)
1623
1624
dnl Spit out some output
1625
dnl ========================================================
1626
MOZ_CREATE_CONFIG_STATUS()
1627
1628
rm -fr confdefs* $ac_clean_files