1dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
2dnl vi: set tabstop=4 shiftwidth=4 expandtab syntax=m4:
3dnl This Source Code Form is subject to the terms of the Mozilla Public
4dnl License, v. 2.0. If a copy of the MPL was not distributed with this
5dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7dnl Process this file with autoconf to produce a configure script.
8dnl ========================================================
9AC_PREREQ(2.13)
10AC_INIT(config/config.mk)
11AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
12AC_CANONICAL_SYSTEM
13
14dnl ========================================================
15dnl =
16dnl = Don't change the following lines. Doing so breaks:
17dnl =
18dnl = CFLAGS="-foo" ./configure
19dnl =
20dnl ========================================================
21CFLAGS="${CFLAGS=}"
22CPPFLAGS="${CPPFLAGS=}"
23CXXFLAGS="${CXXFLAGS=}"
24LDFLAGS="${LDFLAGS=}"
25HOST_CFLAGS="${HOST_CFLAGS=}"
26HOST_CXXFLAGS="${HOST_CXXFLAGS=}"
27HOST_LDFLAGS="${HOST_LDFLAGS=}"
28
29dnl ========================================================
30dnl = Preserve certain environment flags passed to configure
31dnl = We want sub projects to receive the same flags
32dnl = untainted by this configure script
33dnl ========================================================
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
46dnl Set the version number of the libs included with mozilla
47dnl ========================================================
48MOZPNG=10635
49
50dnl Set the minimum version of toolkit libs used by mozilla
51dnl ========================================================
52GLIB_VERSION=2.42
53GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_42
54GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_42
55CAIRO_VERSION=1.10
56GTK3_VERSION=3.14.0
57GDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_14
58W32API_VERSION=3.14
59DBUS_VERSION=0.60
60
61dnl Set various checks
62dnl ========================================================
63MISSING_X=
64
65dnl Initialize the Pthread test variables early so they can be
66dnl  overridden by each platform.
67dnl ========================================================
68MOZ_USE_PTHREADS=
69_PTHREAD_LDFLAGS=""
70
71LDFLAGS="$LDFLAGS $LINKER_LDFLAGS"
72
73if test "$COMPILE_ENVIRONMENT"; then
74    MOZ_ANDROID_NDK
75fi # COMPILE_ENVIRONMENT
76
77case "$target" in
78*-android*|*-linuxandroid*)
79    ;;
80*-linux*)
81    AC_PATH_PROG(OBJCOPY,objcopy)
82    ;;
83esac
84
85AC_SUBST(OBJCOPY)
86
87dnl ========================================================
88dnl Checks for compilers.
89dnl ========================================================
90
91if test "$COMPILE_ENVIRONMENT"; then
92
93# Run some logic to figure out exe extensions (mostly for mingw's sake)
94AC_EXEEXT
95
96if test "$target" != "$host"; then
97    MOZ_CROSS_COMPILER
98else
99    AC_PROG_CC
100    case "$target" in
101    *-mingw*)
102      # Work around the conftest.exe access problem on Windows
103      sleep 2
104    esac
105    AC_PROG_CXX
106    MOZ_PATH_PROGS(AS, $AS as, $CC)
107    AC_CHECK_PROGS(STRIP, strip, :)
108    AC_CHECK_PROGS(OTOOL, otool, :)
109fi
110
111MOZ_TOOL_VARIABLES
112
113dnl ========================================================
114dnl Special win32 checks
115dnl ========================================================
116
117WINVER=601
118
119case "$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        CXXFLAGS="$CXXFLAGS -TP"
127        AC_LANG_SAVE
128        AC_LANG_C
129        AC_TRY_COMPILE([#include <stdio.h>],
130            [ printf("Hello World\n"); ],,
131            AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
132
133        AC_LANG_CPLUSPLUS
134        AC_TRY_COMPILE([#include <new.h>],
135            [ unsigned *test = new unsigned(42); ],,
136            AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
137        AC_LANG_RESTORE
138
139        changequote(,)
140        _MSVC_VER_FILTER='s|.*[^!-~]([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
141        changequote([,])
142
143        AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
144        AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
145        AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI.
146
147        _CC_SUITE=14
148        MSVC_C_RUNTIME_DLL=vcruntime140.dll
149        MSVC_CXX_RUNTIME_DLL=msvcp140.dll
150
151        # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
152        CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
153
154        if test -n "$WIN_UCRT_REDIST_DIR"; then
155          if test ! -d "$WIN_UCRT_REDIST_DIR"; then
156            AC_MSG_ERROR([Invalid Windows UCRT Redist directory: ${WIN_UCRT_REDIST_DIR}])
157          fi
158          WIN_UCRT_REDIST_DIR=`cd "$WIN_UCRT_REDIST_DIR" && (pwd -W 2>/dev/null || pwd)`
159        fi
160
161        AC_SUBST(MSVC_C_RUNTIME_DLL)
162        AC_SUBST(MSVC_CXX_RUNTIME_DLL)
163
164        AC_DEFINE(HAVE_SEH_EXCEPTIONS)
165
166        if test -n "$WIN32_REDIST_DIR"; then
167          if test ! -d "$WIN32_REDIST_DIR"; then
168            AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
169          fi
170          WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && (pwd -W 2>/dev/null || pwd)`
171        fi
172
173        # Check linker version, except in lld builds
174        case "$LINKER" in
175        *lld*)
176            ;;
177        *)
178            _LD_FULL_VERSION=`"${LINKER}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
179            _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
180            if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
181                AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
182            fi
183            ;;
184        esac
185
186        INCREMENTAL_LINKER=1
187
188        unset _MSVC_VER_FILTER
189
190        WRAP_STL_INCLUDES=1
191        STL_FLAGS="-I${DIST}/stl_wrappers"
192    else
193        # Check w32api version
194        _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
195        _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
196        AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
197        AC_TRY_COMPILE([#include <w32api.h>],
198            #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
199                (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
200                 __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
201                #error "test failed."
202            #endif
203            , [ res=yes ], [ res=no ])
204        AC_MSG_RESULT([$res])
205        if test "$res" != "yes"; then
206            AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
207        fi
208        # strsafe.h on mingw uses macros for function deprecation that pollutes namespace
209        # causing problems with local implementations with the same name.
210        AC_DEFINE(STRSAFE_NO_DEPRECATE)
211    fi # !GNU_CC
212
213    CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
214    CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
215
216    AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
217    AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
218    # Require OS features provided by IE 8.0 (Win7)
219    AC_DEFINE_UNQUOTED(_WIN32_IE,0x0800)
220
221    ;;
222esac
223
224if test -n "$_WIN32_MSVC"; then
225    SKIP_PATH_CHECKS=1
226    SKIP_COMPILER_CHECKS=1
227    SKIP_LIBRARY_CHECKS=1
228
229    # Since we're skipping compiler and library checks, hard-code
230    # some facts here.
231    AC_DEFINE(HAVE_IO_H)
232    AC_DEFINE(HAVE_ISATTY)
233fi
234
235fi # COMPILE_ENVIRONMENT
236
237AC_SUBST(GNU_CC)
238AC_SUBST(GNU_CXX)
239
240AC_SUBST_LIST(STL_FLAGS)
241AC_SUBST(WRAP_STL_INCLUDES)
242
243dnl ========================================================
244dnl Checks for programs.
245dnl ========================================================
246if test "$COMPILE_ENVIRONMENT"; then
247
248AC_PATH_XTRA
249
250XCFLAGS="$X_CFLAGS"
251
252fi # COMPILE_ENVIRONMENT
253
254dnl ========================================================
255dnl set the defaults first
256dnl ========================================================
257MOZ_USER_DIR=".mozilla"
258
259MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
260
261MOZ_FS_LAYOUT=unix
262
263dnl Configure platform-specific CPU architecture compiler options.
264dnl ==============================================================
265if test "$COMPILE_ENVIRONMENT"; then
266    MOZ_ARCH_OPTS
267fi # COMPILE_ENVIRONMENT
268
269dnl ========================================================
270dnl Android libstdc++
271dnl ========================================================
272
273MOZ_ANDROID_CPU_ARCH
274if test "$COMPILE_ENVIRONMENT"; then
275    MOZ_ANDROID_STLPORT
276fi # COMPILE_ENVIRONMENT
277
278dnl ========================================================
279dnl Suppress Clang Argument Warnings
280dnl ========================================================
281WARNINGS_CFLAGS="$_WARNINGS_CFLAGS"
282if test -n "${CLANG_CC}${CLANG_CL}"; then
283    WARNINGS_CFLAGS="-Qunused-arguments $WARNINGS_CFLAGS"
284    CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
285fi
286if test -n "${CLANG_CXX}${CLANG_CL}"; then
287    _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
288fi
289
290if test -n "$COMPILE_ENVIRONMENT"; then
291   MOZ_CONFIG_SANITIZE
292fi
293
294dnl ========================================================
295dnl GNU specific defaults
296dnl ========================================================
297if test "$GNU_CC"; then
298    MMX_FLAGS="-mmmx"
299    SSE_FLAGS="-msse"
300    SSE2_FLAGS="-msse2"
301    SSSE3_FLAGS="-mssse3"
302    CFLAGS="$CFLAGS -fno-strict-aliasing"
303
304    if test "$OS_ARCH" != "WINNT" -o -z "$CLANG_CC"; then
305        DSO_PIC_CFLAGS='-fPIC'
306        ASFLAGS="$ASFLAGS -fPIC"
307    fi
308
309    AC_MSG_CHECKING([for --noexecstack option to as])
310    _SAVE_CFLAGS=$CFLAGS
311    CFLAGS="$CFLAGS -Wa,--noexecstack"
312    AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
313                     [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
314                     AC_MSG_RESULT([no]))
315    CFLAGS=$_SAVE_CFLAGS
316    AC_MSG_CHECKING([for -z noexecstack option to ld])
317    _SAVE_LDFLAGS=$LDFLAGS
318    LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
319    AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
320                  AC_MSG_RESULT([no])
321                  LDFLAGS=$_SAVE_LDFLAGS)
322
323    AC_MSG_CHECKING([for -z text option to ld])
324    _SAVE_LDFLAGS=$LDFLAGS
325    LDFLAGS="$LDFLAGS -Wl,-z,text"
326    AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
327                  AC_MSG_RESULT([no])
328                  LDFLAGS=$_SAVE_LDFLAGS)
329
330    AC_MSG_CHECKING([for -z relro option to ld])
331    _SAVE_LDFLAGS=$LDFLAGS
332    LDFLAGS="$LDFLAGS -Wl,-z,relro"
333    AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
334                  AC_MSG_RESULT([no])
335                  LDFLAGS=$_SAVE_LDFLAGS)
336
337    AC_MSG_CHECKING([for -z nocopyreloc option to ld])
338    _SAVE_LDFLAGS=$LDFLAGS
339    LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc"
340    AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
341                  AC_MSG_RESULT([no])
342                  LDFLAGS=$_SAVE_LDFLAGS)
343
344    AC_MSG_CHECKING([for -Bsymbolic-functions option to ld])
345    _SAVE_LDFLAGS=$LDFLAGS
346    LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
347    AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
348                  AC_MSG_RESULT([no])
349                  LDFLAGS=$_SAVE_LDFLAGS)
350
351    AC_MSG_CHECKING([for --build-id=sha1 option to ld])
352    _SAVE_LDFLAGS=$LDFLAGS
353    LDFLAGS="$LDFLAGS -Wl,--build-id=sha1"
354    AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
355                  AC_MSG_RESULT([no])
356                  LDFLAGS=$_SAVE_LDFLAGS)
357
358    AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])
359    HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=
360    _SAVE_LDFLAGS=$LDFLAGS
361    LDFLAGS="$LDFLAGS -Wl,--ignore-unresolved-symbol,environ"
362    AC_TRY_LINK(,,AC_MSG_RESULT([yes])
363                  [HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=1],
364                  AC_MSG_RESULT([no]))
365    LDFLAGS=$_SAVE_LDFLAGS
366
367    # Check for -mssse3 on $CC
368    AC_MSG_CHECKING([if toolchain supports -mssse3 option])
369    HAVE_TOOLCHAIN_SUPPORT_MSSSE3=
370    _SAVE_CFLAGS=$CFLAGS
371    CFLAGS="$CFLAGS -mssse3"
372    AC_TRY_COMPILE([asm ("pmaddubsw %xmm2,%xmm3");],,AC_MSG_RESULT([yes])
373                     [HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1],
374                     AC_MSG_RESULT([no]))
375    CFLAGS=$_SAVE_CFLAGS
376
377    # Check for -msse4.1 on $CC
378    AC_MSG_CHECKING([if toolchain supports -msse4.1 option])
379    HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=
380    _SAVE_CFLAGS=$CFLAGS
381    CFLAGS="$CFLAGS -msse4.1"
382    AC_TRY_COMPILE([asm ("pmulld %xmm6,%xmm0");],,AC_MSG_RESULT([yes])
383                     [HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1],
384                     AC_MSG_RESULT([no]))
385    CFLAGS=$_SAVE_CFLAGS
386
387    case "${CPU_ARCH}" in
388    x86 | x86_64)
389      AC_MSG_CHECKING(for x86 AVX2 asm support in compiler)
390      AC_TRY_COMPILE([],
391                     [asm volatile ("vpermq      \$0xd8,%ymm0,%ymm0 \n");],
392                     result="yes", result="no")
393      AC_MSG_RESULT("$result")
394      if test "$result" = "yes"; then
395          HAVE_X86_AVX2=1
396      fi
397      ;;
398
399    ppc*)
400      AC_MSG_CHECKING([whether we can enable AltiVec support])
401      HAVE_ALTIVEC=
402      _SAVE_CFLAGS=$CFLAGS
403      CFLAGS="$CFLAGS -maltivec"
404      AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
405                       [HAVE_ALTIVEC=1],
406                       AC_MSG_RESULT([no]))
407      CFLAGS=$_SAVE_CFLAGS
408      ;;
409    esac
410
411    DSO_LDOPTS='-shared'
412    if test "$GCC_USE_GNU_LD"; then
413        # Some tools like ASan use a runtime library that is only
414        # linked against executables, so we must allow undefined
415        # symbols for shared objects in some cases.
416        if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
417            # Don't allow undefined symbols in libraries
418            DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
419
420            # BSDs need `environ' exposed for posix_spawn (bug 753046)
421            case "$OS_TARGET" in
422            DragonFly|FreeBSD|NetBSD|OpenBSD)
423                if test -n "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED"; then
424                    DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
425                else
426                    DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
427                fi
428                ;;
429            esac
430        fi
431    fi
432
433    _DEFINES_CFLAGS="-include $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
434
435    ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
436fi
437
438if test "$GNU_CXX"; then
439    CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
440
441    _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $_objdir/mozilla-config.h"
442fi
443
444dnl ========================================================
445dnl = Enable DMD
446dnl ========================================================
447
448if test "$MOZ_DMD"; then
449    if test "${CPU_ARCH}" = "arm"; then
450        CFLAGS="$CFLAGS -funwind-tables"
451        CXXFLAGS="$CXXFLAGS -funwind-tables"
452    fi
453fi
454
455dnl ========================================================
456dnl System overrides of the defaults for host
457dnl ========================================================
458case "$host" in
459*mingw*)
460    if test -n "$_WIN32_MSVC"; then
461        HOST_CFLAGS="$HOST_CFLAGS"
462    else
463        HOST_CFLAGS="$HOST_CFLAGS -mwindows"
464    fi
465    HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
466    HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
467    HOST_BIN_SUFFIX=.exe
468
469    case "${host_cpu}" in
470    i*86)
471        if test -n "$_WIN32_MSVC"; then
472            HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
473        fi
474        ;;
475    x86_64)
476        if test -n "$_WIN32_MSVC"; then
477            HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
478        fi
479        HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
480        ;;
481    esac
482    ;;
483
484*-darwin*)
485    HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
486    HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
487    ;;
488
489*-linux*|*-kfreebsd*-gnu|*-gnu*)
490    HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
491    HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
492    ;;
493
494*)
495    HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
496    HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
497    ;;
498esac
499
500dnl ========================================================
501dnl System overrides of the defaults for target
502dnl ========================================================
503
504case "$target" in
505*-darwin*)
506    MOZ_OPTIMIZE_FLAGS="-O3"
507    CXXFLAGS="$CXXFLAGS -stdlib=libc++"
508    DSO_LDOPTS=''
509    # The ExceptionHandling framework is needed for Objective-C exception
510    # logging code in nsObjCExceptions.h. Currently we only use that in debug
511    # builds.
512    MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
513
514    dnl DTrace and -dead_strip don't interact well. See bug 403132.
515    dnl ===================================================================
516    if test "x$enable_dtrace" = "xyes"; then
517        echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
518    else
519        dnl check for the presence of the -dead_strip linker flag
520        AC_MSG_CHECKING([for -dead_strip option to ld])
521        _SAVE_LDFLAGS=$LDFLAGS
522        LDFLAGS="$LDFLAGS -Wl,-dead_strip"
523        AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
524        if test -n "$_HAVE_DEAD_STRIP" ; then
525            AC_MSG_RESULT([yes])
526            MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
527        else
528            AC_MSG_RESULT([no])
529        fi
530
531        LDFLAGS=$_SAVE_LDFLAGS
532    fi
533
534    MOZ_FIX_LINK_PATHS="-Wl,-executable_path,${DIST}/bin"
535    ;;
536
537*-android*|*-linuxandroid*)
538    if test "$COMPILE_ENVIRONMENT" -a -n "$MOZ_MEMORY"; then
539        MOZ_LINKER=1
540    fi
541
542    if test -z "$CLANG_CC"; then
543        MOZ_OPTIMIZE_FLAGS="-freorder-blocks -fno-reorder-functions -Os"
544    else
545        # From https://github.com/android-ndk/ndk/issues/133#issuecomment-308549264
546        # -Oz is smaller than -Os on clang.
547        MOZ_OPTIMIZE_FLAGS="-Oz"
548        # Disable the outliner, which causes performance regressions, and is
549        # enabled on some platforms at -Oz.
550        if test -z "$MOZ_LTO"; then
551            DISABLE_OUTLINER="-mno-outline"
552            _SAVE_CFLAGS=$CFLAGS
553            CFLAGS="$CFLAGS $DISABLE_OUTLINER"
554            AC_TRY_COMPILE(,,[MOZ_OPTIMIZE_FLAGS="$MOZ_OPTIMIZE_FLAGS $DISABLE_OUTLINER"])
555            CFLAGS="$_SAVE_CFLAGS"
556        else
557            DISABLE_OUTLINER="-Wl,-plugin-opt=-enable-machine-outliner=never"
558            _SAVE_LDFLAGS=$LDFLAGS
559            LDFLAGS="$LDFLAGS $MOZ_LTO_LDFLAGS $DISABLE_OUTLINER"
560            AC_TRY_LINK(,,[MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS $DISABLE_OUTLINER"])
561            LDFLAGS="$_SAVE_LDFLAGS"
562        fi
563    fi
564    ;;
565
566*-*linux*)
567    if test "$GNU_CC" -o "$GNU_CXX"; then
568        MOZ_PGO_OPTIMIZE_FLAGS="-O3"
569        if test -n "$MOZ_DEBUG"; then
570            MOZ_OPTIMIZE_FLAGS="-Os"
571        else
572            MOZ_OPTIMIZE_FLAGS="-O2"
573        fi
574        if test -z "$CLANG_CC"; then
575           MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
576        fi
577    fi
578
579    case "${target_cpu}" in
580    alpha*)
581        CFLAGS="$CFLAGS -mieee"
582        CXXFLAGS="$CXXFLAGS -mieee"
583    ;;
584    esac
585    ;;
586*-mingw*)
587    DSO_PIC_CFLAGS=
588    # certain versions of cygwin's makedepend barf on the
589    # #include <string> vs -I./dist/include/string issue so don't use it
590    if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
591        # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
592        if test -z "$CLANG_CC"; then
593            AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
594        fi
595
596        DSO_LDOPTS='-shared'
597        # mingw doesn't require kernel32, user32, and advapi32 explicitly
598        LIBS="$LIBS -luuid -lusp10 -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32"
599        MOZ_FIX_LINK_PATHS=
600
601        MOZ_OPTIMIZE_FLAGS="-O2"
602
603        WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
604        WIN32_GUI_EXE_LDFLAGS=-mwindows
605
606        # Silence problematic clang warnings
607        CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
608        LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
609    else
610        TARGET_COMPILER_ABI=msvc
611        STRIP='echo not_strip'
612        # aarch64 doesn't support subsystems below 6.02
613        if test "$CPU_ARCH" = "aarch64"; then
614            WIN32_SUBSYSTEM_VERSION=6.02
615        else
616            WIN32_SUBSYSTEM_VERSION=6.01
617        fi
618        WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
619        WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
620        DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
621        _DEFINES_CFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
622        _DEFINES_CXXFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
623        CFLAGS="$CFLAGS -W3 -Gy -Zc:inline"
624        CXXFLAGS="$CXXFLAGS -W3 -Gy -Zc:inline"
625        if test -z "$CLANG_CL"; then
626            CPPFLAGS="$CPPFLAGS -utf-8"
627        fi
628        if test "$CPU_ARCH" = "x86"; then
629            dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
630            dnl more recent, so set that explicitly here unless another
631            dnl target arch has already been set.
632            changequote(,)
633            if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
634              CFLAGS="$CFLAGS -arch:SSE2"
635            fi
636            if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
637              CXXFLAGS="$CXXFLAGS -arch:SSE2"
638            fi
639            changequote([,])
640            SSE_FLAGS="-arch:SSE"
641            SSE2_FLAGS="-arch:SSE2"
642            dnl MSVC allows the use of intrinsics without any flags
643            dnl and doesn't have a separate arch for SSSE3
644            SSSE3_FLAGS="-arch:SSE2"
645        fi
646        dnl clang-cl requires appropriate flags to enable SSSE3 support
647        dnl on all architectures.
648        if test -n "$CLANG_CL"; then
649            SSSE3_FLAGS="-mssse3"
650        fi
651        dnl VS2013+ supports -Gw for better linker optimizations.
652        dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
653        dnl Disabled on ASan because it causes false-positive ODR violations.
654        if test -z "$MOZ_ASAN"; then
655            CFLAGS="$CFLAGS -Gw"
656            CXXFLAGS="$CXXFLAGS -Gw"
657        else
658            # String tail merging doesn't play nice with ASan's ODR checker.
659            LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
660        fi
661        if test -n "$CLANG_CL"; then
662            # XXX We should combine some of these with our generic GCC-style
663            # warning checks.
664            #
665            # Suppress the clang-cl warning for the inline 'new' and 'delete' in mozalloc
666            CXXFLAGS="$CXXFLAGS -Wno-inline-new-delete"
667            # We use offsetof on non-POD objects all the time.
668            # We also suppress this warning on other platforms.
669            CXXFLAGS="$CXXFLAGS -Wno-invalid-offsetof"
670            # This warns for reasonable things like:
671            #   enum { X = 0xffffffffU };
672            # which is annoying for IDL headers.
673            CXXFLAGS="$CXXFLAGS -Wno-microsoft-enum-value"
674            # This warns for cases that would be reached by the Microsoft
675            # #include rules, but also currently warns on cases that would
676            # *also* be reached by standard C++ include rules.  That
677            # behavior doesn't seem useful, so we turn it off.
678            CXXFLAGS="$CXXFLAGS -Wno-microsoft-include"
679            # We normally error out on unknown pragmas, but since clang-cl
680            # claims to be MSVC, it would be difficult to add
681            # #if defined(_MSC_VER) && !defined(__clang__) everywhere we
682            # use such pragmas, so just ignore them.
683            CFLAGS="$CFLAGS -Wno-unknown-pragmas"
684            CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas"
685            # We get errors about various #pragma intrinsic directives from
686            # clang-cl, and we don't need to hear about those.
687            CFLAGS="$CFLAGS -Wno-ignored-pragmas"
688            CXXFLAGS="$CXXFLAGS -Wno-ignored-pragmas"
689            # clang-cl's Intrin.h marks things like _ReadWriteBarrier
690            # as __attribute((__deprecated__)).  This is nice to know,
691            # but since we don't get the equivalent warning from MSVC,
692            # let's just ignore it.
693            CFLAGS="$CFLAGS -Wno-deprecated-declarations"
694            CXXFLAGS="$CXXFLAGS -Wno-deprecated-declarations"
695            # We use a function like:
696            #   __declspec(noreturn) __inline void f() {}
697            # which -Winvalid-noreturn complains about.  Again, MSVC seems
698            # OK with it, so let's silence the warning.
699            CFLAGS="$CFLAGS -Wno-invalid-noreturn"
700            CXXFLAGS="$CXXFLAGS -Wno-invalid-noreturn"
701            # Missing |override| on virtual function declarations isn't
702            # something that MSVC currently warns about.
703            CXXFLAGS="$CXXFLAGS -Wno-inconsistent-missing-override"
704            # We use -DHAS_EXCEPTIONS=0, which removes the |throw()|
705            # declaration on |operator delete(void*)|.  However, clang-cl
706            # must internally declare |operator delete(void*)| differently,
707            # which causes this warning for virtually every file in the
708            # tree.  clang-cl doesn't support -fno-exceptions or equivalent,
709            # so there doesn't seem to be any way to convince clang-cl to
710            # declare |delete| differently.  Therefore, suppress this
711            # warning.
712            CXXFLAGS="$CXXFLAGS -Wno-implicit-exception-spec-mismatch"
713            # Macros like STDMETHOD() and IFACEMETHOD() can declare
714            # __attribute__((nothrow)) on their respective method declarations,
715            # while the definitions are left without the matching attribute.
716            CXXFLAGS="$CXXFLAGS -Wno-microsoft-exception-spec"
717            # At least one MSVC header and several headers in-tree have
718            # unused typedefs, so turn this on.
719            CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"
720            # jemalloc uses __declspec(allocator) as a profiler hint,
721            # which clang-cl doesn't understand.
722            CXXFLAGS="$CXXFLAGS -Wno-ignored-attributes"
723            # __attribute__((unused)) really means "might be unused" and
724            # we use it to avoid warnings about things that are unused
725            # in some compilation units, but used in many others.  This
726            # warning insists on complaining about the latter case, which
727            # is annoying, and rather noisy.
728            CXXFLAGS="$CXXFLAGS -Wno-used-but-marked-unused"
729        fi
730        # Silence VS2017 15.5+ TR1 deprecation warnings hit by older gtest versions
731        CXXFLAGS="$CXXFLAGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
732        LIBS="$LIBS user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib"
733        MOZ_DEBUG_LDFLAGS='-DEBUG'
734        if test "$HOST_OS_ARCH" != "WINNT"; then
735          # %_PDB% is a special signal to emit only the PDB basename. This
736          # avoids problems in Windows tools that don't like forward-slashes.
737          MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -PDBALTPATH:%_PDB%"
738        fi
739        # Use a higher optimization level for clang-cl, so we can come closer
740        # to MSVC's performance numbers (see bug 1443590).
741        if test -n "$CLANG_CL"; then
742            MOZ_OPTIMIZE_FLAGS='-O2'
743        else
744            MOZ_OPTIMIZE_FLAGS='-O1 -Oi'
745        fi
746        MOZ_FIX_LINK_PATHS=
747        LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
748        dnl Minimum reqiurement of Gecko is VS2015 or later which supports
749        dnl both SSSE3 and SSE4.1.
750        HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1
751        HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1
752        dnl allow AVX2 code from VS2015
753        HAVE_X86_AVX2=1
754    fi
755    AC_DEFINE(WIN32_LEAN_AND_MEAN)
756    dnl See http://support.microsoft.com/kb/143208 to use STL
757    AC_DEFINE(NOMINMAX)
758    BIN_SUFFIX='.exe'
759    MOZ_USER_DIR="Mozilla"
760
761    case "$host_os" in
762    cygwin*|msvc*|mks*)
763        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.])
764        ;;
765    esac
766
767    case "$target" in
768    i*86-*)
769        if test -n "$GNU_CC"; then
770            CFLAGS="$CFLAGS -mstackrealign"
771            CXXFLAGS="$CXXFLAGS -mstackrealign"
772            LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
773        else
774            DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
775            LDFLAGS="$LDFLAGS -SAFESEH"
776        fi
777
778        AC_DEFINE(_X86_)
779        ;;
780    x86_64-*)
781        if test -n "$_WIN32_MSVC"; then
782            DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
783        fi
784        AC_DEFINE(_AMD64_)
785        ;;
786    aarch64-*)
787        if test -n "$_WIN32_MSVC"; then
788            DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
789        fi
790        AC_DEFINE(_ARM64_)
791        ;;
792    *)
793        AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
794        ;;
795    esac
796    ;;
797
798*-netbsd*)
799    CFLAGS="$CFLAGS -Dunix"
800    CXXFLAGS="$CXXFLAGS -Dunix"
801    if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
802        DSO_PIC_CFLAGS='-fPIC -DPIC'
803        DSO_LDOPTS='-shared'
804        MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
805    else
806        DSO_PIC_CFLAGS='-fPIC -DPIC'
807        DSO_LDOPTS='-shared'
808    fi
809    # This will fail on a.out systems prior to 1.5.1_ALPHA.
810    if test "$LIBRUNPATH"; then
811        DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
812    fi
813    ;;
814
815*-openbsd*)
816    if test -z "$X11BASE"; then
817        X11BASE=/usr/X11R6
818    fi
819    MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
820    DSO_PIC_CFLAGS='-fPIC'
821    DSO_LDOPTS='-shared -fPIC'
822    if test "$LIBRUNPATH"; then
823        DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
824    fi
825    ;;
826
827*-solaris*)
828    MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
829    ;;
830
831esac
832
833CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
834CXXFLAGS="$CXXFLAGS $DSO_PIC_CFLAGS"
835
836if test -z "$MOZ_OPTIMIZE_FLAGS"; then
837    MOZ_OPTIMIZE_FLAGS="-O"
838fi
839
840AC_SUBST_LIST(MMX_FLAGS)
841AC_SUBST_LIST(SSE_FLAGS)
842AC_SUBST_LIST(SSE2_FLAGS)
843AC_SUBST_LIST(SSSE3_FLAGS)
844
845AC_SUBST(MOZ_LINKER)
846if test -n "$MOZ_LINKER"; then
847  AC_DEFINE(MOZ_LINKER)
848  MOZ_LINKER_EXTRACT=1
849  AC_CHECK_PROGS(XZ, xz)
850fi
851
852if test -z "$COMPILE_ENVIRONMENT"; then
853    SKIP_COMPILER_CHECKS=1
854    SKIP_LIBRARY_CHECKS=1
855    MOZ_DEBUGGING_OPTS
856else
857    MOZ_COMPILER_OPTS
858fi # COMPILE_ENVIRONMENT
859
860if test -z "$SKIP_COMPILER_CHECKS"; then
861dnl Checks for typedefs, structures, and compiler characteristics.
862dnl ========================================================
863AC_C_CONST
864AC_TYPE_MODE_T
865AC_TYPE_OFF_T
866AC_TYPE_PID_T
867AC_TYPE_SIZE_T
868AC_LANG_CPLUSPLUS
869AC_LANG_C
870
871AC_LANG_CPLUSPLUS
872
873MOZ_CXX11
874
875AC_LANG_C
876
877case "${OS_TARGET}" in
878Darwin)
879  ;;
880*)
881  STL_FLAGS="-I${DIST}/stl_wrappers"
882  WRAP_STL_INCLUDES=1
883  ;;
884esac
885
886if test "$MOZ_BUILD_APP" = "tools/crashreporter"; then
887    WRAP_STL_INCLUDES=
888fi
889if test "$MOZ_BUILD_APP" = "tools/crashreporter/injector"; then
890    WRAP_STL_INCLUDES=
891fi
892
893dnl Checks for header files.
894dnl ========================================================
895AC_HEADER_DIRENT
896case "$target_os" in
897bitrig*|dragonfly*|freebsd*|openbsd*)
898# for stuff like -lXshm
899    CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
900    ;;
901esac
902
903dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
904AC_CACHE_CHECK(for sockaddr_in.sin_len,
905                   ac_cv_sockaddr_in_sin_len,
906                   [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
907                                    #include <sys/types.h>
908                                    #endif
909                                    #include <netinet/in.h>
910                                    struct sockaddr_in x;
911                                    void *foo = (void*) &x.sin_len;],
912                                   [],
913                                   [ac_cv_sockaddr_in_sin_len=true],
914                                   [ac_cv_sockaddr_in_sin_len=false])])
915if test "$ac_cv_sockaddr_in_sin_len" = true ; then
916  AC_DEFINE(HAVE_SIN_LEN)
917dnl HAVE_CONN_LEN must be the same as HAVE_SIN_LEN (and HAVE_SIN6_LEN too)
918  AC_DEFINE(HAVE_SCONN_LEN)
919fi
920
921AC_CACHE_CHECK(for sockaddr_in6.sin6_len,
922               ac_cv_sockaddr_in6_sin6_len,
923               [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
924                                #include <sys/types.h>
925                                #endif
926                                #include <netinet/in.h>
927                                struct sockaddr_in6 x;
928                                void *foo = (void*) &x.sin6_len;],
929                               [],
930                               [ac_cv_sockaddr_in6_sin6_len=true],
931                               [ac_cv_sockaddr_in6_sin6_len=false])])
932if test "$ac_cv_sockaddr_in6_sin6_len" = true ; then
933  AC_DEFINE(HAVE_SIN6_LEN)
934fi
935
936AC_CACHE_CHECK(for sockaddr.sa_len,
937               ac_cv_sockaddr_sa_len,
938               [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
939                                #include <sys/types.h>
940                                #endif
941                                #include <sys/socket.h>
942                                struct sockaddr x;
943                                void *foo = (void*) &x.sa_len;],
944                               [],
945                               [ac_cv_sockaddr_sa_len=true],
946                               [ac_cv_sockaddr_sa_len=false])])
947if test "$ac_cv_sockaddr_sa_len" = true ; then
948  AC_DEFINE(HAVE_SA_LEN)
949fi
950
951dnl Checks for libraries.
952dnl ========================================================
953AC_CHECK_LIB(c_r, gethostbyname_r)
954
955dnl We don't want to link with libdl even if it's present on OS X, since
956dnl it's not used and not part of the default installation. OS/2 has dlfcn
957dnl in libc.
958dnl We don't want to link against libm or libpthread on Darwin since
959dnl they both are just symlinks to libSystem and explicitly linking
960dnl against libSystem causes issues when debugging (see bug 299601).
961case $target in
962*-darwin*)
963    ;;
964*)
965    AC_SEARCH_LIBS(dlopen, dl,
966        MOZ_CHECK_HEADER(dlfcn.h,
967        AC_DEFINE(HAVE_DLOPEN)))
968    ;;
969esac
970
971_SAVE_CFLAGS="$CFLAGS"
972CFLAGS="$CFLAGS -D_GNU_SOURCE"
973AC_CHECK_FUNCS(dladdr memmem)
974CFLAGS="$_SAVE_CFLAGS"
975
976if test ! "$GNU_CXX"; then
977    AC_CHECK_LIB(C, demangle)
978fi
979
980AC_CHECK_LIB(socket, socket)
981
982XLDFLAGS="$X_LIBS"
983XLIBS="$X_EXTRA_LIBS"
984
985dnl ========================================================
986dnl Checks for X libraries.
987dnl Ordering is important.
988dnl Xt is dependent upon SM as of X11R6
989dnl ========================================================
990if test -n "$MOZ_X11"; then
991    AC_DEFINE_UNQUOTED(FUNCPROTO,15)
992    _SAVE_LDFLAGS="$LDFLAGS"
993    _SAVE_LIBS="$LIBS"
994    LDFLAGS="$XLDFLAGS $LDFLAGS"
995    AC_CHECK_LIB(X11, XDrawLines, [XLIBS="-lX11 $XLIBS"],
996        [MISSING_X="$MISSING_X -lX11"], $XLIBS)
997    AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
998        [MISSING_X="$MISSING_X -lXext"], $XLIBS)
999
1000    AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
1001        unset ac_cv_lib_Xt_XtFree
1002        AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
1003        AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
1004        AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
1005            [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
1006        ])
1007
1008    dnl ========================================================
1009    dnl = Check for xcb
1010    dnl ========================================================
1011    AC_CHECK_LIB(xcb, xcb_connect, [XLIBS="-lxcb $XLIBS"],
1012        [MISSING_X="$MISSING_X -lxcb"], $XLIBS)
1013    AC_CHECK_LIB(xcb-shm, xcb_shm_query_version, [XLIBS="-lxcb-shm $XLIBS"],
1014        [MISSING_X="$MISSING_X -lxcb-shm"], $XLIBS)
1015    AC_CHECK_LIB(X11-xcb, XGetXCBConnection, [XLIBS="-lX11-xcb $XLIBS"],
1016        [MISSING_X="$MISSING_X -lX11-xcb"], $XLIBS)
1017
1018    LDFLAGS="$_SAVE_LDFLAGS"
1019    LIBS="$_SAVE_LIBS"
1020fi # $MOZ_X11
1021
1022AC_SUBST_LIST(XCFLAGS)
1023AC_SUBST_LIST(XLDFLAGS)
1024AC_SUBST_LIST(XLIBS)
1025AC_SUBST_LIST(XEXT_LIBS)
1026AC_SUBST_LIST(XT_LIBS)
1027
1028dnl ========================================================
1029dnl = pthread support
1030dnl = Start by checking whether the system support pthreads
1031dnl ========================================================
1032case "$target_os" in
1033darwin*)
1034    MOZ_USE_PTHREADS=1
1035    ;;
1036*)
1037    AC_CHECK_LIB(pthreads, pthread_create,
1038        MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
1039        AC_CHECK_LIB(pthread, pthread_create,
1040            MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
1041            AC_CHECK_LIB(c_r, pthread_create,
1042                MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
1043                AC_CHECK_LIB(c, pthread_create,
1044                    MOZ_USE_PTHREADS=1
1045                )
1046            )
1047        )
1048    )
1049    ;;
1050esac
1051
1052dnl ========================================================
1053dnl Do the platform specific pthread hackery
1054dnl ========================================================
1055if test "$MOZ_USE_PTHREADS"x != x
1056then
1057    dnl
1058    dnl See if -pthread is supported.
1059    dnl
1060    rm -f conftest*
1061    ac_cv_have_dash_pthread=no
1062    AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
1063    echo 'int main() { return 0; }' | cat > conftest.c
1064    ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
1065    if test $? -eq 0; then
1066        if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
1067            ac_cv_have_dash_pthread=yes
1068            case "$target_os" in
1069            freebsd*)
1070# Freebsd doesn't use -pthread for compiles, it uses them for linking
1071                ;;
1072            *)
1073                CFLAGS="$CFLAGS -pthread"
1074                CXXFLAGS="$CXXFLAGS -pthread"
1075                ;;
1076            esac
1077        fi
1078    fi
1079    rm -f conftest*
1080    AC_MSG_RESULT($ac_cv_have_dash_pthread)
1081
1082    dnl
1083    dnl See if -pthreads is supported.
1084    dnl
1085    ac_cv_have_dash_pthreads=no
1086    if test "$ac_cv_have_dash_pthread" = "no"; then
1087        AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
1088        echo 'int main() { return 0; }' | cat > conftest.c
1089        ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
1090        if test $? -eq 0; then
1091            if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
1092                ac_cv_have_dash_pthreads=yes
1093                CFLAGS="$CFLAGS -pthreads"
1094                CXXFLAGS="$CXXFLAGS -pthreads"
1095            fi
1096        fi
1097        rm -f conftest*
1098        AC_MSG_RESULT($ac_cv_have_dash_pthreads)
1099    fi
1100
1101    case "$target" in
1102        *-*-freebsd*)
1103            AC_DEFINE(_REENTRANT)
1104            AC_DEFINE(_THREAD_SAFE)
1105            dnl -pthread links in -lpthread, so don't specify it explicitly.
1106            if test "$ac_cv_have_dash_pthread" = "yes"; then
1107                _PTHREAD_LDFLAGS="-pthread"
1108            fi
1109            ;;
1110
1111        *-*-openbsd*|*-*-bsdi*)
1112            AC_DEFINE(_REENTRANT)
1113            AC_DEFINE(_THREAD_SAFE)
1114            dnl -pthread links in -lc_r, so don't specify it explicitly.
1115            if test "$ac_cv_have_dash_pthread" = "yes"; then
1116                _PTHREAD_LDFLAGS="-pthread"
1117            fi
1118            ;;
1119
1120        *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
1121            AC_DEFINE(_REENTRANT)
1122            ;;
1123
1124    esac
1125    LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
1126    AC_SUBST(MOZ_USE_PTHREADS)
1127    MOZ_CHECK_HEADERS(pthread.h)
1128fi
1129
1130
1131dnl Checks for library functions.
1132dnl ========================================================
1133AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize gmtime_r localtime_r arc4random arc4random_buf mallinfo gettid lchown setpriority strerror syscall lutimes)
1134
1135dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
1136AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
1137               ac_cv_clock_monotonic,
1138               [for libs in "" -lrt; do
1139                    _SAVE_LIBS="$LIBS"
1140                    LIBS="$LIBS $libs"
1141dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
1142dnl we should or not be able to use it. To detect if we can, we need to make the
1143dnl availability attribute strict, so that compilation fails when the target is < 10.12.
1144                    AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
1145                                 #include <time.h>],
1146                                 [ struct timespec ts;
1147                                   clock_gettime(CLOCK_MONOTONIC, &ts); ],
1148                                 ac_cv_clock_monotonic=$libs
1149                                 LIBS="$_SAVE_LIBS"
1150                                 break,
1151                                 ac_cv_clock_monotonic=no)
1152                    LIBS="$_SAVE_LIBS"
1153                done])
1154if test "$ac_cv_clock_monotonic" != "no"; then
1155    HAVE_CLOCK_MONOTONIC=1
1156    REALTIME_LIBS=$ac_cv_clock_monotonic
1157    AC_DEFINE(HAVE_CLOCK_MONOTONIC)
1158    AC_SUBST(HAVE_CLOCK_MONOTONIC)
1159    AC_SUBST_LIST(REALTIME_LIBS)
1160fi
1161
1162dnl Turn on warnings-as-errors to prevent implicit declaration of
1163dnl pthread_cond_timedwait_monotonic_np, which can cause this test to
1164dnl inadvertently pass even if the function does not really exist.
1165_SAVE_CFLAGS="$CFLAGS"
1166CFLAGS="$CFLAGS $WARNINGS_AS_ERRORS"
1167AC_CACHE_CHECK(for pthread_cond_timedwait_monotonic_np,
1168               ac_cv_pthread_cond_timedwait_monotonic_np,
1169               AC_TRY_LINK([#include <pthread.h>],
1170                           [pthread_cond_timedwait_monotonic_np(0, 0, 0);],
1171                           ac_cv_pthread_cond_timewait_monotonic_np=yes,
1172                           ac_cv_pthread_cond_timewait_monotonic_np=no))
1173if test "$ac_cv_pthread_cond_timewait_monotonic_np" != "no"; then
1174    AC_DEFINE(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)
1175fi
1176CFLAGS=$_SAVE_CFLAGS
1177
1178AC_CACHE_CHECK(
1179    [for res_ninit()],
1180    ac_cv_func_res_ninit,
1181    [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
1182        dnl no need for res_ninit() on NetBSD and OpenBSD
1183        ac_cv_func_res_ninit=no
1184     else
1185        AC_TRY_LINK([
1186            #ifdef linux
1187            #define _BSD_SOURCE 1
1188            #endif
1189            #include <sys/types.h>
1190            #include <netinet/in.h>
1191            #include <arpa/nameser.h>
1192            #include <resolv.h>
1193            ],
1194            [int foo = res_ninit(&_res);],
1195            [ac_cv_func_res_ninit=yes],
1196            [ac_cv_func_res_ninit=no])
1197     fi
1198    ])
1199
1200if test "$ac_cv_func_res_ninit" = "yes"; then
1201    AC_DEFINE(HAVE_RES_NINIT)
1202dnl must add the link line we do something as foolish as this... dougt
1203dnl else
1204dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
1205dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
1206fi
1207
1208AC_LANG_C
1209
1210dnl **********************
1211dnl *** va_copy checks ***
1212AC_CACHE_CHECK([for an implementation of va_copy()],
1213               ac_cv_va_copy,
1214    [AC_TRY_COMPILE([#include <stdarg.h>
1215                     #include <stdlib.h>
1216        void f (int i, ...) {
1217            va_list args1, args2;
1218            va_start (args1, i);
1219            va_copy (args2, args1);
1220            if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1221                exit (1);
1222            va_end (args1); va_end (args2);
1223        }],
1224        [f(0, 42); return 0],
1225        [ac_cv_va_copy=yes],
1226        [ac_cv_va_copy=no]
1227    )]
1228)
1229AC_CACHE_CHECK([whether va_list can be copied by value],
1230               ac_cv_va_val_copy,
1231    [AC_TRY_COMPILE([#include <stdarg.h>
1232                     #include <stdlib.h>
1233        void f (int i, ...) {
1234            va_list args1, args2;
1235            va_start (args1, i);
1236            args2 = args1;
1237            if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1238                exit (1);
1239            va_end (args1); va_end (args2);
1240        }],
1241        [f(0, 42); return 0],
1242        [ac_cv_va_val_copy=yes],
1243        [ac_cv_va_val_copy=no],
1244    )]
1245)
1246if test "x$ac_cv_va_copy" = "xyes"; then
1247    AC_DEFINE(VA_COPY, va_copy)
1248    AC_DEFINE(HAVE_VA_COPY)
1249fi
1250
1251if test "x$ac_cv_va_val_copy" = "xno"; then
1252   AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
1253fi
1254
1255dnl ===================================================================
1256dnl ========================================================
1257dnl Put your C++ language/feature checks below
1258dnl ========================================================
1259AC_LANG_CPLUSPLUS
1260
1261ARM_ABI_PREFIX=
1262if test "$GNU_CC"; then
1263  if test "$CPU_ARCH" = "arm" ; then
1264    AC_CACHE_CHECK(for ARM EABI,
1265        ac_cv_gcc_arm_eabi,
1266        [AC_TRY_COMPILE([],
1267                        [
1268#if defined(__ARM_EABI__)
1269  return 0;
1270#else
1271#error Not ARM EABI.
1272#endif
1273                        ],
1274                        ac_cv_gcc_arm_eabi="yes",
1275                        ac_cv_gcc_arm_eabi="no")])
1276    if test "$ac_cv_gcc_arm_eabi" = "yes"; then
1277        HAVE_ARM_EABI=1
1278        ARM_ABI_PREFIX=eabi-
1279    else
1280        ARM_ABI_PREFIX=oabi-
1281    fi
1282  fi
1283
1284  TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
1285fi
1286
1287# try harder, when checking for __thread support, see bug 521750 comment #33 and below
1288# We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
1289# enabled, the linker in xcode 4.1 will crash. Without this it would crash when
1290# linking XUL.
1291_SAVE_LDFLAGS=$LDFLAGS
1292LDFLAGS="$LDFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
1293AC_CACHE_CHECK(for __thread keyword for TLS variables,
1294               ac_cv_thread_keyword,
1295               [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
1296                            [return tlsIsMainThread;],
1297                            ac_cv_thread_keyword=yes,
1298                            ac_cv_thread_keyword=no)])
1299LDFLAGS=$_SAVE_LDFLAGS
1300# The custom dynamic linker doesn't support TLS variables
1301MOZ_TLS=
1302if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
1303  # mips builds fail with TLS variables because of a binutils bug.
1304  # See bug 528687
1305  # OpenBSD doesn't have TLS support, and the test succeeds with clang++
1306  case "${target}" in
1307    mips*-*)
1308      :
1309      ;;
1310    *-android*|*-linuxandroid*)
1311      :
1312      ;;
1313    *-openbsd*)
1314      :
1315      ;;
1316    *)
1317      AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
1318      MOZ_TLS=1
1319      ;;
1320  esac
1321fi
1322
1323dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
1324if test -n "$MOZ_LINKER"; then
1325  if test "$CPU_ARCH" = arm; then
1326    dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
1327    if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
1328      LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
1329      _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
1330    fi
1331  fi
1332
1333dnl gold emits wrong sysv-style elf hash tables when building both sysv and
1334dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
1335dnl Since the linker only understands the sysv ones, no need to build the
1336dnl gnu style tables anyways.
1337  LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
1338fi
1339
1340dnl End of C++ language/feature checks
1341AC_LANG_C
1342
1343dnl ========================================================
1344dnl =  Internationalization checks
1345dnl ========================================================
1346dnl
1347dnl Internationalization and Locale support is different
1348dnl on various UNIX platforms.  Checks for specific i18n
1349dnl features go here.
1350
1351AC_HAVE_FUNCS(localeconv)
1352
1353fi # ! SKIP_COMPILER_CHECKS
1354
1355if test -n "${COMPILE_ENVIRONMENT}"; then
1356  MOZ_CHECK_ALLOCATOR
1357fi
1358
1359TARGET_XPCOM_ABI=
1360if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
1361    TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
1362    AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
1363fi
1364
1365dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
1366dnl features that Windows actually does support.
1367
1368if test -n "$SKIP_COMPILER_CHECKS"; then
1369   dnl Windows has malloc.h
1370   AC_DEFINE(MALLOC_H, [<malloc.h>])
1371   AC_DEFINE(HAVE_FORCEINLINE)
1372   AC_DEFINE(HAVE_LOCALECONV)
1373fi # SKIP_COMPILER_CHECKS
1374
1375dnl Mozilla specific options
1376dnl ========================================================
1377dnl The macros used for command line options
1378dnl are defined in build/autoconf/altoptions.m4.
1379
1380dnl ========================================================
1381dnl =
1382dnl = Check for external package dependencies
1383dnl =
1384dnl ========================================================
1385MOZ_ARG_HEADER(External Packages)
1386
1387dnl ========================================================
1388dnl system libevent Support
1389dnl ========================================================
1390MOZ_ARG_WITH_STRING(system-libevent,
1391[  --with-system-libevent[=PFX]
1392                          Use system libevent [installed at prefix PFX]],
1393    LIBEVENT_DIR=$withval)
1394
1395_SAVE_CFLAGS=$CFLAGS
1396_SAVE_LDFLAGS=$LDFLAGS
1397_SAVE_LIBS=$LIBS
1398if test "$LIBEVENT_DIR" = yes; then
1399    PKG_CHECK_MODULES(MOZ_LIBEVENT, libevent,
1400        MOZ_SYSTEM_LIBEVENT=1,
1401        LIBEVENT_DIR=/usr)
1402fi
1403if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
1404    MOZ_SYSTEM_LIBEVENT=
1405elif test -z "$MOZ_SYSTEM_LIBEVENT"; then
1406    CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
1407    LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
1408    MOZ_CHECK_HEADER(event.h,
1409        [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
1410             AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
1411         fi],
1412        AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
1413    AC_CHECK_LIB(event, event_init,
1414                 [MOZ_SYSTEM_LIBEVENT=1
1415                  MOZ_LIBEVENT_CFLAGS="-I${LIBEVENT_DIR}/include"
1416                  MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
1417                 [MOZ_SYSTEM_LIBEVENT= MOZ_LIBEVENT_CFLAGS= MOZ_LIBEVENT_LIBS=])
1418fi
1419CFLAGS=$_SAVE_CFLAGS
1420LDFLAGS=$_SAVE_LDFLAGS
1421LIBS=$_SAVE_LIBS
1422
1423AC_SUBST(MOZ_SYSTEM_LIBEVENT)
1424
1425if test -z "$SKIP_LIBRARY_CHECKS"; then
1426
1427dnl ========================================================
1428dnl system PNG Support
1429dnl ========================================================
1430MOZ_ARG_WITH_STRING(system-png,
1431[  --with-system-png[=PFX]
1432                          Use system libpng [installed at prefix PFX]],
1433    PNG_DIR=$withval)
1434
1435_SAVE_CFLAGS=$CFLAGS
1436_SAVE_LDFLAGS=$LDFLAGS
1437_SAVE_LIBS=$LIBS
1438if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
1439    CFLAGS="-I${PNG_DIR}/include $CFLAGS"
1440    LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
1441fi
1442if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
1443    MOZ_SYSTEM_PNG=
1444else
1445    AC_CHECK_LIB(png, png_get_valid, [MOZ_SYSTEM_PNG=1 MOZ_PNG_LIBS="-lpng"],
1446                 AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
1447    AC_CHECK_LIB(png, png_get_acTL, ,
1448                 AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
1449fi
1450if test "$MOZ_SYSTEM_PNG" = 1; then
1451    AC_TRY_COMPILE([ #include <stdio.h>
1452                     #include <sys/types.h>
1453                     #include <png.h> ],
1454                   [ #if PNG_LIBPNG_VER < $MOZPNG
1455                     #error "Insufficient libpng version ($MOZPNG required)."
1456                     #endif
1457                     #ifndef PNG_UINT_31_MAX
1458                     #error "Insufficient libpng version."
1459                     #endif ],
1460                   MOZ_SYSTEM_PNG=1,
1461                   AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
1462fi
1463CFLAGS=$_SAVE_CFLAGS
1464LDFLAGS=$_SAVE_LDFLAGS
1465LIBS=$_SAVE_LIBS
1466
1467if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_SYSTEM_PNG" = 1; then
1468    MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
1469    MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_PNG_LIBS}"
1470fi
1471
1472fi # SKIP_LIBRARY_CHECKS
1473
1474dnl ========================================================
1475dnl =
1476dnl = Application
1477dnl =
1478dnl ========================================================
1479
1480MOZ_ARG_HEADER(Application)
1481
1482ENABLE_SYSTEM_EXTENSION_DIRS=1
1483MOZ_BRANDING_DIRECTORY=
1484MOZ_OFFICIAL_BRANDING=
1485MOZ_AUTH_EXTENSION=1
1486MOZ_SPELLCHECK=1
1487MOZ_UNIVERSALCHARDET=1
1488MOZ_XUL=1
1489MOZ_ZIPWRITER=1
1490MOZ_NO_SMART_CARDS=
1491MOZ_SANDBOX=1
1492MOZ_BINARY_EXTENSIONS=
1493MOZ_DEVTOOLS=server
1494
1495dnl ========================================================
1496dnl = Trademarked Branding
1497dnl ========================================================
1498MOZ_ARG_ENABLE_BOOL(official-branding,
1499[  --enable-official-branding
1500                          Enable Official mozilla.org Branding
1501                          Do not distribute builds with
1502                          --enable-official-branding unless you have
1503                          permission to use trademarks per
1504                          http://www.mozilla.org/foundation/trademarks/ .],
1505    MOZ_OFFICIAL_BRANDING=1,
1506    MOZ_OFFICIAL_BRANDING=)
1507
1508# Allow the application to influence configure with a confvars.sh script.
1509AC_MSG_CHECKING([if app-specific confvars.sh exists])
1510if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
1511  AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
1512  . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
1513else
1514  AC_MSG_RESULT([no])
1515fi
1516
1517dnl ========================================================
1518dnl Ensure Android SDK and build-tools versions depending on
1519dnl mobile target.
1520dnl ========================================================
1521
1522case "$MOZ_BUILD_APP" in
1523mobile/android)
1524    MOZ_ANDROID_SDK
1525    ;;
1526esac
1527
1528dnl ========================================================
1529dnl =
1530dnl = Toolkit Options
1531dnl =
1532dnl ========================================================
1533MOZ_ARG_HEADER(Toolkit Options)
1534
1535dnl ========================================================
1536dnl = Enable the toolkit as needed                         =
1537dnl ========================================================
1538
1539case "$MOZ_WIDGET_TOOLKIT" in
1540
1541cocoa)
1542    LDFLAGS="$LDFLAGS -framework Cocoa"
1543    # Use -Wl as a trick to avoid -framework and framework names from
1544    # being separated by AC_SUBST_LIST.
1545    TK_LIBS='-Wl,-framework,Foundation -Wl,-framework,CoreFoundation -Wl,-framework,CoreLocation -Wl,-framework,QuartzCore -Wl,-framework,Carbon -Wl,-framework,CoreAudio -Wl,-framework,CoreVideo -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,AddressBook -Wl,-framework,OpenGL -Wl,-framework,Security -Wl,-framework,ServiceManagement -Wl,-framework,CoreServices -Wl,-framework,ApplicationServices -Wl,-framework,AppKit'
1546    TK_CFLAGS=""
1547    CFLAGS="$CFLAGS $TK_CFLAGS"
1548    CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
1549    MOZ_USER_DIR="Mozilla"
1550    MOZ_FS_LAYOUT=bundle
1551    ;;
1552
1553uikit)
1554    LDFLAGS="$LDFLAGS -framework UIKit"
1555    TK_CFLAGS=""
1556    TK_LIBS='-Wl,-framework,Foundation -Wl,-framework,CoreFoundation -Wl,-framework,CoreGraphics -Wl,-framework,CoreText -Wl,-framework,AVFoundation -Wl,-framework,AudioToolbox -Wl,-framework,CoreMedia -Wl,-framework,CoreVideo -Wl,-framework,OpenGLES -Wl,-framework,QuartzCore'
1557    CFLAGS="$CFLAGS $TK_CFLAGS"
1558    CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
1559    MOZ_USER_DIR="Mozilla"
1560    MOZ_FS_LAYOUT=bundle
1561    ;;
1562
1563esac
1564
1565if test "$OS_TARGET" = Darwin; then
1566    LDFLAGS="$LDFLAGS -lobjc"
1567fi
1568
1569dnl there are a lot of tests on MOZ_ENABLE_GTK below, that are more convenient
1570dnl to keep that way than testing against MOZ_WIDGET_TOOLKIT
1571case "$MOZ_WIDGET_TOOLKIT" in
1572gtk*)
1573    MOZ_ENABLE_GTK=1
1574    ;;
1575esac
1576
1577if test "$COMPILE_ENVIRONMENT"; then
1578  if test "$MOZ_WIDGET_TOOLKIT" = gtk; then
1579    PKG_CHECK_MODULES(MOZ_GTK3, gtk+-3.0 >= $GTK3_VERSION gtk+-unix-print-3.0 glib-2.0 gobject-2.0 gio-unix-2.0 $GDK_PACKAGES)
1580    MOZ_GTK3_CFLAGS="-I${_topsrcdir}/widget/gtk/compat-gtk3 $MOZ_GTK3_CFLAGS"
1581    TK_CFLAGS=$MOZ_GTK3_CFLAGS
1582    TK_LIBS=$MOZ_GTK3_LIBS
1583    dnl GDK_VERSION_MIN_REQUIRED is not set here as GDK3 deprecated warnings
1584    dnl are suppressed by widget/gtk/compat-gtk3/gdk/gdkversionmacros.h.
1585    AC_DEFINE_UNQUOTED(GDK_VERSION_MAX_ALLOWED,$GDK_VERSION_MAX_ALLOWED)
1586  fi
1587  if test "$MOZ_ENABLE_GTK"; then
1588    AC_DEFINE_UNQUOTED(GLIB_VERSION_MIN_REQUIRED,$GLIB_VERSION_MIN_REQUIRED)
1589    AC_DEFINE_UNQUOTED(GLIB_VERSION_MAX_ALLOWED,$GLIB_VERSION_MAX_ALLOWED)
1590  fi
1591fi # COMPILE_ENVIRONMENT
1592
1593AC_SUBST(MOZ_FS_LAYOUT)
1594
1595AC_SUBST_LIST(TK_CFLAGS)
1596AC_SUBST_LIST(TK_LIBS)
1597
1598dnl ========================================================
1599dnl =
1600dnl = Components & Features
1601dnl =
1602dnl ========================================================
1603MOZ_ARG_HEADER(Components and Features)
1604
1605AC_SUBST(MOZ_OFFICIAL_BRANDING)
1606if test -n "$MOZ_OFFICIAL_BRANDING"; then
1607  if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
1608    AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
1609  else
1610    MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
1611    AC_DEFINE(MOZ_OFFICIAL_BRANDING)
1612  fi
1613fi
1614
1615MOZ_ARG_WITH_STRING(branding,
1616[  --with-branding=dir     Use branding from the specified directory.],
1617    MOZ_BRANDING_DIRECTORY=$withval)
1618
1619REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
1620if test -z "$REAL_BRANDING_DIRECTORY"; then
1621  REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
1622fi
1623
1624if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
1625  . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
1626fi
1627
1628AC_SUBST(MOZ_BRANDING_DIRECTORY)
1629
1630dnl ========================================================
1631dnl = Distribution ID
1632dnl ========================================================
1633MOZ_ARG_WITH_STRING(distribution-id,
1634[  --with-distribution-id=ID
1635                          Set distribution-specific id (default=org.mozilla)],
1636[ val=`echo $withval`
1637    MOZ_DISTRIBUTION_ID="$val"])
1638
1639if test -z "$MOZ_DISTRIBUTION_ID"; then
1640   MOZ_DISTRIBUTION_ID="org.mozilla"
1641fi
1642
1643AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
1644AC_SUBST(MOZ_DISTRIBUTION_ID)
1645
1646dnl ========================================================
1647dnl = libproxy support
1648dnl ========================================================
1649
1650if test "$MOZ_ENABLE_GTK"
1651then
1652    MOZ_ENABLE_LIBPROXY=
1653
1654    MOZ_ARG_ENABLE_BOOL(libproxy,
1655    [  --enable-libproxy         Enable libproxy support ],
1656    MOZ_ENABLE_LIBPROXY=1,
1657    MOZ_ENABLE_LIBPROXY=)
1658
1659    if test "$MOZ_ENABLE_LIBPROXY"
1660    then
1661        PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
1662        AC_DEFINE(MOZ_ENABLE_LIBPROXY)
1663    fi
1664fi
1665AC_SUBST(MOZ_ENABLE_LIBPROXY)
1666
1667dnl ========================================================
1668dnl = dbus support
1669dnl ========================================================
1670
1671if test "$MOZ_ENABLE_GTK"
1672then
1673    MOZ_ENABLE_DBUS=1
1674
1675    MOZ_ARG_DISABLE_BOOL(dbus,
1676    [  --disable-dbus          Disable dbus support ],
1677        MOZ_ENABLE_DBUS=,
1678        MOZ_ENABLE_DBUS=1)
1679
1680    if test "$MOZ_ENABLE_DBUS"
1681    then
1682        PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
1683        PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
1684        AC_DEFINE(MOZ_ENABLE_DBUS)
1685    fi
1686fi
1687AC_SUBST(MOZ_ENABLE_DBUS)
1688
1689AC_TRY_COMPILE([#include <linux/ethtool.h>],
1690               [ struct ethtool_cmd cmd; cmd.speed_hi = 0; ],
1691               MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI=1)
1692
1693AC_SUBST(MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI)
1694
1695if test -n "$MOZ_WEBRTC"; then
1696    if test -n "$MOZ_X11"; then
1697      MOZ_WEBRTC_X11_LIBS="-lXext -lXdamage -lXfixes -lXcomposite"
1698    fi
1699fi
1700
1701AC_SUBST_LIST(MOZ_WEBRTC_X11_LIBS)
1702
1703dnl ========================================================
1704dnl = Apple platform decoder support
1705dnl ========================================================
1706if test "$COMPILE_ENVIRONMENT"; then
1707if test -n "$MOZ_APPLEMEDIA"; then
1708  # hack in frameworks for fmp4 - see bug 1029974
1709  # We load VideoToolbox and CoreMedia dynamically, so they don't appear here.
1710  LDFLAGS="$LDFLAGS -framework AudioToolbox"
1711  dnl Verify CoreMedia is available.
1712  AC_CHECK_HEADERS([CoreMedia/CoreMedia.h VideoToolbox/VideoToolbox.h], [],
1713    [AC_MSG_ERROR([MacOS X 10.9 SDK or later is required])])
1714fi
1715fi # COMPILE_ENVIRONMENT
1716
1717dnl ========================================================
1718dnl = Handle dependent MEDIA defines
1719dnl ========================================================
1720
1721MOZ_WEBM_ENCODER=1
1722AC_DEFINE(MOZ_WEBM_ENCODER)
1723AC_SUBST(MOZ_WEBM_ENCODER)
1724
1725dnl ========================================================
1726dnl NegotiateAuth
1727dnl ========================================================
1728
1729MOZ_ARG_DISABLE_BOOL(negotiateauth,
1730[  --disable-negotiateauth Disable GSS-API negotiation ],
1731    MOZ_AUTH_EXTENSION=,
1732    MOZ_AUTH_EXTENSION=1 )
1733
1734dnl ========================================================
1735dnl Searching of system directories for extensions.
1736dnl Note: this switch is meant to be used for test builds
1737dnl whose behavior should not depend on what happens to be
1738dnl installed on the local machine.
1739dnl ========================================================
1740MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
1741[  --disable-system-extension-dirs
1742                          Disable searching system- and account-global
1743                          directories for extensions of any kind; use
1744                          only profile-specific extension directories],
1745  ENABLE_SYSTEM_EXTENSION_DIRS=,
1746  ENABLE_SYSTEM_EXTENSION_DIRS=1 )
1747if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
1748  AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
1749fi
1750
1751dnl ========================================================
1752dnl = Universalchardet
1753dnl ========================================================
1754MOZ_ARG_DISABLE_BOOL(universalchardet,
1755[  --disable-universalchardet
1756                          Disable universal encoding detection],
1757  MOZ_UNIVERSALCHARDET=,
1758  MOZ_UNIVERSALCHARDET=1 )
1759
1760dnl ========================================================
1761dnl Gamepad support
1762dnl ========================================================
1763
1764if test "$COMPILE_ENVIRONMENT" ; then
1765
1766dnl Moved gamepad platform check to moz.build, linux header check still needed here.
1767if test "$OS_TARGET" = "Linux"; then
1768    MOZ_CHECK_HEADER([linux/joystick.h])
1769    if test "$ac_cv_header_linux_joystick_h" != "yes"; then
1770      AC_MSG_ERROR([Can't find header linux/joystick.h, needed for gamepad support. Please install Linux kernel headers.])
1771    fi
1772fi
1773
1774fi # COMPILE_ENVIRONMENT
1775
1776
1777dnl ========================================================
1778dnl = Breakpad crash reporting (on by default on supported platforms)
1779dnl ========================================================
1780
1781case $target in
1782i?86-*-mingw*|x86_64-*-mingw*|aarch64-*-mingw*)
1783  MOZ_CRASHREPORTER=1
1784  ;;
1785i?86-apple-darwin*|x86_64-apple-darwin*|aarch64-apple-darwin*)
1786  MOZ_CRASHREPORTER=1
1787  ;;
1788*-android*|*-linuxandroid*)
1789  dnl Android/arm is arm-unknown-linux-androideabi, so android condition should
1790  dnl be before Linux condition
1791  dnl The crash reporter prevents crash stacktraces to be logged in the
1792  dnl logs so we leave it out by default in developer builds.
1793  if test -z "$DEVELOPER_OPTIONS"; then
1794    MOZ_CRASHREPORTER=1
1795  fi
1796  ;;
1797i?86-*-linux*|x86_64-*-linux*|arm-*-linux*)
1798  if test "$MOZ_ENABLE_GTK"; then
1799    MOZ_CRASHREPORTER=1
1800  fi
1801  ;;
1802esac
1803
1804MOZ_ARG_DISABLE_BOOL(crashreporter,
1805[  --disable-crashreporter Disable breakpad crash reporting],
1806    [MOZ_CRASHREPORTER=],
1807    [MOZ_CRASHREPORTER=F # Force enable breakpad])
1808
1809if test "$OS_ARCH" != "$HOST_OS_ARCH" -a "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "Darwin" -a "$MOZ_WIDGET_TOOLKIT" != "android"; then
1810  if test "$MOZ_CRASHREPORTER" = F; then
1811    AC_MSG_ERROR([Cannot --enable-crashreporter, as breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.])
1812  fi
1813  MOZ_CRASHREPORTER=
1814fi
1815
1816if test -n "$MOZ_CRASHREPORTER"; then
1817   AC_DEFINE(MOZ_CRASHREPORTER)
1818
1819  if test "$OS_TARGET" = "Linux" && \
1820    test -z "$SKIP_LIBRARY_CHECKS"; then
1821    PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
1822  fi
1823
1824  if test "$OS_ARCH" = "WINNT"; then
1825    if test -z "$HAVE_64BIT_BUILD" -a -n "$COMPILE_ENVIRONMENT"; then
1826      MOZ_CRASHREPORTER_INJECTOR=1
1827      AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
1828    fi
1829  fi
1830fi
1831
1832dnl ========================================================
1833dnl = Enable compilation of specific extension modules
1834dnl ========================================================
1835
1836MOZ_ARG_ENABLE_STRING(extensions,
1837[  --enable-extensions     Enable extensions],
1838[ for option in `echo $enableval | sed 's/,/ /g'`; do
1839    if test "$option" = "yes" -o "$option" = "all"; then
1840        AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
1841    elif test "$option" = "no" -o "$option" = "none"; then
1842        MOZ_EXTENSIONS=""
1843    elif test "$option" = "default"; then
1844        MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
1845    elif test `echo "$option" | grep -c \^-` != 0; then
1846        option=`echo $option | sed 's/^-//'`
1847        MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
1848    else
1849        MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
1850    fi
1851done],
1852    MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
1853
1854dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
1855dnl when trying to build a nonexistent extension.
1856for extension in $MOZ_EXTENSIONS; do
1857    if test ! -d "${srcdir}/extensions/${extension}"; then
1858        AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
1859    fi
1860done
1861
1862# Avoid defining MOZ_ENABLE_CAIRO_FT on Windows platforms because
1863# "cairo-ft-font.c" includes <dlfcn.h>, which only exists on posix platforms
1864if test -n "$MOZ_TREE_FREETYPE" -a "$OS_TARGET" != WINNT; then
1865   MOZ_ENABLE_CAIRO_FT=1
1866   FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
1867   CAIRO_FT_CFLAGS="-I$_topsrcdir/modules/freetype2/include"
1868   AC_SUBST_LIST(CAIRO_FT_CFLAGS)
1869fi
1870
1871dnl ========================================================
1872dnl Updater
1873dnl ========================================================
1874
1875MOZ_ARG_DISABLE_BOOL(updater,
1876[  --disable-updater       Disable building of updater],
1877    MOZ_UPDATER=,
1878    MOZ_UPDATER=1 )
1879
1880if test -n "$MOZ_UPDATER"; then
1881    AC_DEFINE(MOZ_UPDATER)
1882fi
1883
1884dnl ========================================================
1885dnl parental controls (for Windows Vista)
1886dnl ========================================================
1887MOZ_ARG_DISABLE_BOOL(parental-controls,
1888[  --disable-parental-controls
1889                          Do not build parental controls],
1890   MOZ_DISABLE_PARENTAL_CONTROLS=1,
1891   MOZ_DISABLE_PARENTAL_CONTROLS=)
1892if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
1893    AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
1894fi
1895
1896AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
1897
1898dnl ========================================================
1899dnl = Disable smartcard support
1900dnl ========================================================
1901if test -n "$MOZ_NO_SMART_CARDS"; then
1902    AC_DEFINE(MOZ_NO_SMART_CARDS)
1903fi
1904AC_SUBST(MOZ_NO_SMART_CARDS)
1905
1906dnl ========================================================
1907dnl = Sandboxing support
1908dnl ========================================================
1909if test -n "$MOZ_TSAN" -o -n "$MOZ_ASAN"; then
1910    # Bug 1182565: TSan conflicts with sandboxing on Linux.
1911    # Bug 1287971: LSan also conflicts with sandboxing on Linux.
1912    case $OS_TARGET in
1913    Linux|Android)
1914        MOZ_SANDBOX=
1915        ;;
1916    esac
1917fi
1918
1919MOZ_ARG_DISABLE_BOOL(sandbox,
1920[  --disable-sandbox        Disable sandboxing support],
1921    MOZ_SANDBOX=,
1922    MOZ_SANDBOX=1)
1923
1924case "$OS_TARGET" in
1925WINNT|Darwin|OpenBSD)
1926;;
1927Linux)
1928    case $CPU_ARCH in
1929        x86_64|x86|arm|aarch64)
1930        ;;
1931        # Linux sandbox is only available on x86{,_64} and arm{,64}.
1932        *)
1933            MOZ_SANDBOX=
1934        ;;
1935    esac
1936    ;;
1937*)
1938    # Only enable the sandbox by default on Linux, OpenBSD, macOS, and Windows
1939    MOZ_SANDBOX=
1940;;
1941esac
1942
1943if test -n "$MOZ_SANDBOX"; then
1944    AC_DEFINE(MOZ_SANDBOX)
1945fi
1946
1947AC_SUBST(MOZ_SANDBOX)
1948
1949
1950dnl ========================================================
1951dnl =
1952dnl = Module specific options
1953dnl =
1954dnl ========================================================
1955MOZ_ARG_HEADER(Individual module options)
1956
1957dnl ==============================
1958dnl === SQLite fdatasync check ===
1959dnl ==============================
1960dnl Check to see if fdatasync is available and make use of it
1961AC_CHECK_FUNC(fdatasync)
1962
1963dnl ========================================================
1964dnl = Disable zipwriter
1965dnl ========================================================
1966MOZ_ARG_DISABLE_BOOL(zipwriter,
1967[  --disable-zipwriter     Disable zipwriter component],
1968    MOZ_ZIPWRITER=,
1969    MOZ_ZIPWRITER=1 )
1970AC_SUBST(MOZ_ZIPWRITER)
1971
1972dnl ========================================================
1973dnl =
1974dnl = Feature options that require extra sources to be pulled
1975dnl =
1976dnl ========================================================
1977dnl MOZ_ARG_HEADER(Features that require extra sources)
1978
1979dnl ========================================================
1980dnl =
1981dnl = Runtime debugging and Optimization Options
1982dnl =
1983dnl ========================================================
1984MOZ_ARG_HEADER(Runtime debugging and Optimizations)
1985
1986dnl ========================================================
1987dnl = Enable code optimization. ON by default.
1988dnl ========================================================
1989
1990# Use value from moz.configure if one is defined. Else use our computed
1991# value.
1992if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
1993    MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
1994fi
1995
1996if test "$COMPILE_ENVIRONMENT"; then
1997if test -n "$MOZ_OPTIMIZE"; then
1998    AC_MSG_CHECKING([for valid C compiler optimization flags])
1999    _SAVE_CFLAGS=$CFLAGS
2000    CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
2001    AC_TRY_COMPILE([#include <stdio.h>],
2002        [printf("Hello World\n");],
2003        _results=yes,
2004        _results=no)
2005    AC_MSG_RESULT([$_results])
2006    if test "$_results" = "no"; then
2007        AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
2008    fi
2009    CFLAGS=$_SAVE_CFLAGS
2010    if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
2011        # When using llvm-based LTO, non numeric optimization levels are
2012        # not supported by the linker, so force the linker to use -O2 (
2013        # which doesn't influence the level compilation units are actually
2014        # compiled at).
2015        case " $MOZ_OPTIMIZE_FLAGS " in
2016        *\ -Os\ *|*\ -Oz\ *)
2017            MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
2018            ;;
2019        esac
2020    fi
2021fi
2022fi # COMPILE_ENVIRONMENT
2023
2024AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
2025AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
2026AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
2027
2028dnl ========================================================
2029dnl = Enable runtime logging
2030dnl ========================================================
2031AC_DEFINE(MOZ_LOGGING)
2032AC_DEFINE(FORCE_PR_LOG)
2033
2034dnl ========================================================
2035dnl = This will enable logging of addref, release, ctor, dtor.
2036dnl ========================================================
2037_ENABLE_LOGREFCNT=42
2038MOZ_ARG_ENABLE_BOOL(logrefcnt,
2039[  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
2040    _ENABLE_LOGREFCNT=1,
2041    _ENABLE_LOGREFCNT= )
2042if test "$_ENABLE_LOGREFCNT" = "1"; then
2043    AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
2044elif test -z "$_ENABLE_LOGREFCNT"; then
2045    AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
2046fi
2047
2048dnl ========================================================
2049dnl moz_dump_painting
2050dnl ========================================================
2051MOZ_ARG_ENABLE_BOOL(dump-painting,
2052[  --enable-dump-painting          Enable paint debugging.],
2053    MOZ_DUMP_PAINTING=1,
2054    MOZ_DUMP_PAINTING= )
2055if test -n "$MOZ_DUMP_PAINTING"; then
2056    AC_DEFINE(MOZ_DUMP_PAINTING)
2057    AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
2058fi
2059if test -n "$MOZ_DEBUG"; then
2060    AC_DEFINE(MOZ_DUMP_PAINTING)
2061fi
2062
2063case "${OS_TARGET}" in
2064Android|WINNT|Darwin)
2065  MOZ_GLUE_IN_PROGRAM=
2066  ;;
2067*)
2068  dnl On !Android !Windows !OSX, we only want to link executables against mozglue
2069  MOZ_GLUE_IN_PROGRAM=1
2070  AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
2071  ;;
2072esac
2073
2074dnl ========================================================
2075dnl = Jemalloc build setup
2076dnl ========================================================
2077if test -z "$MOZ_MEMORY"; then
2078  case "${target}" in
2079    *-mingw*)
2080      if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
2081        AC_MSG_WARN([When not building jemalloc, you need to set WIN32_REDIST_DIR to the path to the Visual C++ Redist (usually VCINSTALLDIR/redist/x86/Microsoft.VC80.CRT, for VC++ v8) if you intend to distribute your build.])
2082      fi
2083      ;;
2084  esac
2085else
2086  dnl The generic feature tests that determine how to compute ncpus are long and
2087  dnl complicated.  Therefore, simply define special cpp variables for the
2088  dnl platforms we have special knowledge of.
2089  case "${target}" in
2090  *-mingw*)
2091    export MOZ_NO_DEBUG_RTL=1
2092    ;;
2093  esac
2094fi # MOZ_MEMORY
2095AC_SUBST(MOZ_GLUE_IN_PROGRAM)
2096
2097dnl ========================================================
2098dnl = Enable using the clang plugin to build
2099dnl ========================================================
2100
2101if test -n "$COMPILE_ENVIRONMENT"; then
2102MOZ_CONFIG_CLANG_PLUGIN
2103fi # COMPILE_ENVIRONMENT
2104
2105dnl ========================================================
2106dnl = frontend JS debug mode
2107dnl ========================================================
2108
2109MOZ_ARG_ENABLE_BOOL(debug-js-modules,
2110[  --enable-debug-js-modules  Enable debug mode for frontend JS libraries],
2111   DEBUG_JS_MODULES=1,
2112   DEBUG_JS_MODULES=)
2113
2114AC_SUBST(DEBUG_JS_MODULES)
2115
2116dnl ========================================================
2117dnl =
2118dnl = Profiling and Instrumenting
2119dnl =
2120dnl ========================================================
2121MOZ_ARG_HEADER(Profiling and Instrumenting)
2122
2123dnl ========================================================
2124dnl = Support for demangling undefined symbols
2125dnl ========================================================
2126if test -z "$SKIP_LIBRARY_CHECKS"; then
2127    AC_LANG_SAVE
2128    AC_LANG_CPLUSPLUS
2129    AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
2130    AC_LANG_RESTORE
2131fi
2132
2133# Demangle only for debug or DMD builds
2134MOZ_DEMANGLE_SYMBOLS=
2135if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$MOZ_DMD"; then
2136    MOZ_DEMANGLE_SYMBOLS=1
2137    AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
2138fi
2139AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
2140
2141dnl ========================================================
2142dnl = Support for gcc stack unwinding (from gcc 3.3)
2143dnl ========================================================
2144if test -z "$SKIP_LIBRARY_CHECKS"; then
2145    AC_LANG_SAVE
2146    AC_LANG_CPLUSPLUS
2147    MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
2148    AC_LANG_RESTORE
2149fi
2150
2151dnl ========================================================
2152dnl =
2153dnl = Misc. Options
2154dnl =
2155dnl ========================================================
2156MOZ_ARG_HEADER(Misc. Options)
2157
2158dnl ========================================================
2159dnl = Location of the mozilla user directory (default is ~/.mozilla).],
2160dnl ========================================================
2161MOZ_ARG_WITH_STRING(user-appdir,
2162[  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
2163[ val=`echo $withval`
2164if echo "$val" | grep "\/" >/dev/null; then
2165    AC_MSG_ERROR("Homedir must be single relative path.")
2166else
2167    MOZ_USER_DIR="$val"
2168fi])
2169
2170AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
2171
2172if test -z "$SKIP_COMPILER_CHECKS"; then
2173dnl ========================================================
2174dnl =
2175dnl = Compiler Options
2176dnl =
2177dnl ========================================================
2178MOZ_ARG_HEADER(Compiler Options)
2179
2180dnl ========================================================
2181dnl Check for gcc -pipe support
2182dnl ========================================================
2183AC_MSG_CHECKING([for -pipe support])
2184if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
2185    dnl Any gcc that supports firefox supports -pipe.
2186    CFLAGS="$CFLAGS -pipe"
2187    CXXFLAGS="$CXXFLAGS -pipe"
2188    AC_MSG_RESULT([yes])
2189else
2190    AC_MSG_RESULT([no])
2191fi
2192
2193fi # ! SKIP_COMPILER_CHECKS
2194
2195AC_LANG_C
2196
2197if test "$COMPILE_ENVIRONMENT"; then
2198MOZ_EXPAND_LIBS
2199fi # COMPILE_ENVIRONMENT
2200
2201dnl ========================================================
2202dnl =
2203dnl = Static Build Options
2204dnl =
2205dnl ========================================================
2206MOZ_ARG_HEADER(Static build options)
2207
2208if test -z "$MOZ_SYSTEM_ZLIB"; then
2209if test -n "$JS_SHARED_LIBRARY" -o -n "$MOZ_LINKER" -o "$MOZ_WIDGET_TOOLKIT" = android; then
2210  ZLIB_IN_MOZGLUE=1
2211  AC_DEFINE(ZLIB_IN_MOZGLUE)
2212fi
2213fi
2214
2215AC_SUBST(ZLIB_IN_MOZGLUE)
2216
2217dnl ========================================================
2218dnl =
2219dnl = Standalone module options
2220dnl =
2221dnl ========================================================
2222MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
2223
2224dnl Check for GLib.
2225dnl ========================================================
2226
2227if test -z "$SKIP_PATH_CHECKS"; then
2228if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
2229    if test "$MOZ_ENABLE_GTK" ; then
2230        PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
2231    fi
2232fi
2233fi
2234
2235if test -z "${GLIB_GMODULE_LIBS}" \
2236   -a -n "${GLIB_CONFIG}"\
2237    -a "${GLIB_CONFIG}" != no\
2238; then
2239    GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
2240fi
2241
2242AC_SUBST_LIST(GLIB_GMODULE_LIBS)
2243
2244if test "$USE_FC_FREETYPE"; then
2245    if test "$COMPILE_ENVIRONMENT"; then
2246        dnl ========================================================
2247        dnl = Check for freetype2 functionality
2248        dnl ========================================================
2249        if test "$_HAVE_FREETYPE2" -a -z "$MOZ_TREE_FREETYPE"; then
2250            _SAVE_LIBS="$LIBS"
2251            _SAVE_CFLAGS="$CFLAGS"
2252            LIBS="$LIBS $FT2_LIBS"
2253            CFLAGS="$CFLAGS $FT2_CFLAGS"
2254
2255            AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
2256                ac_cv_member_FT_Bitmap_Size_y_ppem,
2257                [AC_TRY_COMPILE([#include <ft2build.h>
2258                                 #include FT_FREETYPE_H],
2259                                [FT_Bitmap_Size s;
2260                                 if (sizeof s.y_ppem) return 0;
2261                                 return 1],
2262                                ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
2263                                ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
2264            if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
2265                HAVE_FT_BITMAP_SIZE_Y_PPEM=1
2266            else
2267                HAVE_FT_BITMAP_SIZE_Y_PPEM=0
2268            fi
2269            AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
2270                               $HAVE_FT_BITMAP_SIZE_Y_PPEM,
2271                               [FT_Bitmap_Size structure includes y_ppem field])
2272
2273            AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table)
2274
2275            LIBS="$_SAVE_LIBS"
2276            CFLAGS="$_SAVE_CFLAGS"
2277        fi
2278
2279        _SAVE_CPPFLAGS="$CPPFLAGS"
2280        CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
2281        MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
2282            [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
2283        CPPFLAGS="$_SAVE_CPPFLAGS"
2284    fi
2285fi
2286
2287dnl ========================================================
2288dnl Check if we need the 32-bit Linux SSE2 error dialog
2289dnl ========================================================
2290
2291AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
2292
2293dnl ========================================================
2294dnl Check for graphite2
2295dnl ========================================================
2296if test -n "$MOZ_SYSTEM_GRAPHITE2"; then
2297    dnl graphite2.pc has bogus version, check manually
2298    _SAVE_CFLAGS=$CFLAGS
2299    CFLAGS="$CFLAGS $MOZ_GRAPHITE2_CFLAGS"
2300    AC_TRY_COMPILE([ #include <graphite2/Font.h>
2301                     #define GR2_VERSION_REQUIRE(major,minor,bugfix)  \
2302                             ( GR2_VERSION_MAJOR * 10000 + GR2_VERSION_MINOR \
2303                               * 100 + GR2_VERSION_BUGFIX >= \
2304                               (major) * 10000 + (minor) * 100 + (bugfix) )
2305                   ], [
2306                     #if !GR2_VERSION_REQUIRE(1,3,14)
2307                     #error "Insufficient graphite2 version."
2308                     #endif
2309                   ], [],
2310                   [AC_MSG_ERROR([--with-system-graphite2 requested but no working libgraphite2 found])])
2311    CFLAGS=$_SAVE_CFLAGS
2312fi
2313
2314dnl ========================================================
2315dnl Check for pixman and cairo
2316dnl ========================================================
2317
2318MOZ_TREE_CAIRO=1
2319MOZ_ARG_ENABLE_BOOL(system-cairo,
2320[ --enable-system-cairo  Obsolete: do not use this option],
2321AC_MSG_ERROR(--enable-system-cairo is not supported),
2322MOZ_TREE_CAIRO=1 )
2323
2324MOZ_TREE_PIXMAN=1
2325MOZ_ARG_ENABLE_BOOL(system-pixman,
2326[ --enable-system-pixman Use system pixman (located with pkgconfig)],
2327MOZ_TREE_PIXMAN=,
2328MOZ_TREE_PIXMAN=force,
2329MOZ_TREE_PIXMAN=1 )
2330
2331if test "$MOZ_TREE_PIXMAN"; then
2332    AC_DEFINE(MOZ_TREE_PIXMAN)
2333else
2334    PKG_CHECK_MODULES(MOZ_PIXMAN, pixman-1 >= 0.19.2)
2335fi
2336
2337MOZ_CAIRO_CFLAGS="-I${DIST}/include/cairo"
2338AC_DEFINE(MOZ_TREE_CAIRO)
2339
2340if test "$OS_ARCH" = "WINNT"; then
2341    # For now we assume that we will have a uint64_t available through
2342    # one of the above headers or mozstdint.h.
2343    AC_DEFINE(HAVE_UINT64_T)
2344fi
2345
2346# Define macros for cairo-features.h
2347TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
2348if test "$MOZ_X11"; then
2349    XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
2350    XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
2351    PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
2352fi
2353if test "$_HAVE_FREETYPE2"; then
2354    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
2355    MOZ_ENABLE_CAIRO_FT=1
2356    CAIRO_FT_CFLAGS="$FT2_CFLAGS"
2357fi
2358
2359case "$MOZ_WIDGET_TOOLKIT" in
2360  cocoa | uikit)
2361    QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
2362    QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
2363    QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
2364    ;;
2365  windows)
2366    WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
2367    WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
2368    WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
2369
2370    if test "$COMPILE_ENVIRONMENT"; then
2371      MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
2372    fi
2373    ;;
2374esac
2375if test "$USE_FC_FREETYPE"; then
2376    FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
2377fi
2378AC_SUBST(MOZ_ENABLE_CAIRO_FT)
2379AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
2380
2381AC_SUBST(PS_SURFACE_FEATURE)
2382AC_SUBST(SVG_SURFACE_FEATURE)
2383AC_SUBST(XLIB_SURFACE_FEATURE)
2384AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
2385AC_SUBST(QUARTZ_SURFACE_FEATURE)
2386AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
2387AC_SUBST(WIN32_SURFACE_FEATURE)
2388AC_SUBST(OS2_SURFACE_FEATURE)
2389AC_SUBST(DIRECTFB_SURFACE_FEATURE)
2390AC_SUBST(FT_FONT_FEATURE)
2391AC_SUBST(FC_FONT_FEATURE)
2392AC_SUBST(WIN32_FONT_FEATURE)
2393AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
2394AC_SUBST(QUARTZ_FONT_FEATURE)
2395AC_SUBST(PNG_FUNCTIONS_FEATURE)
2396AC_SUBST(QT_SURFACE_FEATURE)
2397AC_SUBST(TEE_SURFACE_FEATURE)
2398
2399if test "$MOZ_X11"; then
2400    MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender"
2401fi
2402
2403CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
2404
2405case "$MOZ_WIDGET_TOOLKIT" in
2406android)
2407    TK_CFLAGS="$MOZ_CAIRO_CFLAGS $MOZ_PIXMAN_CFLAGS"
2408    TK_LIBS="$MOZ_CAIRO_LIBS $MOZ_PIXMAN_LIBS"
2409    ;;
2410esac
2411
2412AC_SUBST(MOZ_TREE_CAIRO)
2413AC_SUBST_LIST(MOZ_CAIRO_CFLAGS)
2414AC_SUBST_LIST(MOZ_CAIRO_LIBS)
2415AC_SUBST_LIST(MOZ_CAIRO_OSLIBS)
2416AC_SUBST(MOZ_TREE_PIXMAN)
2417
2418BINDGEN_SYSTEM_FLAGS="$_BINDGEN_CFLAGS $NSPR_CFLAGS $NSS_CFLAGS $MOZ_PIXMAN_CFLAGS $MOZ_CAIRO_CFLAGS"
2419AC_SUBST(BINDGEN_SYSTEM_FLAGS)
2420BINDGEN_SYSTEM_TOML_FLAGS="$BINDGEN_SYSTEM_FLAGS"
2421AC_SUBST_TOML_LIST(BINDGEN_SYSTEM_TOML_FLAGS)
2422
2423dnl ========================================================
2424dnl disable xul
2425dnl ========================================================
2426MOZ_ARG_DISABLE_BOOL(xul,
2427[  --disable-xul           Disable XUL],
2428    MOZ_XUL= )
2429if test "$MOZ_XUL"; then
2430  AC_DEFINE(MOZ_XUL)
2431else
2432  dnl remove extensions that require XUL
2433  MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/irc//' -e 's/tasks//'`
2434fi
2435
2436AC_SUBST(MOZ_XUL)
2437
2438dnl ========================================================
2439dnl necko configuration options
2440dnl ========================================================
2441
2442dnl
2443dnl option to disable necko's wifi scanner
2444dnl
2445
2446if test "$MOZ_WIDGET_TOOLKIT"; then
2447
2448  case "$OS_TARGET" in
2449    Darwin)
2450      NECKO_WIFI=1
2451      ;;
2452    DragonFly|FreeBSD|WINNT)
2453      NECKO_WIFI=1
2454      ;;
2455    Linux)
2456      NECKO_WIFI=1
2457      NECKO_WIFI_DBUS=1
2458      ;;
2459  esac
2460
2461fi
2462
2463MOZ_ARG_DISABLE_BOOL(necko-wifi,
2464[  --disable-necko-wifi    Disable necko wifi scanner],
2465    NECKO_WIFI=,
2466    NECKO_WIFI=1)
2467
2468if test "$NECKO_WIFI"; then
2469  if test -z "$MOZ_ENABLE_DBUS" -a -n "$NECKO_WIFI_DBUS"; then
2470    AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove --disable-dbus or use --disable-necko-wifi])
2471  fi
2472  AC_DEFINE(NECKO_WIFI)
2473fi
2474AC_SUBST(NECKO_WIFI)
2475AC_SUBST(NECKO_WIFI_DBUS)
2476
2477dnl ========================================================
2478dnl =
2479dnl = Maintainer debug option (no --enable equivalent)
2480dnl =
2481dnl ========================================================
2482
2483AC_SUBST_LIST(ASFLAGS)
2484AC_SUBST(IMPLIB)
2485AC_SUBST(FILTER)
2486AC_SUBST(MOZ_AUTH_EXTENSION)
2487AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
2488AC_SUBST_LIST(WARNINGS_CFLAGS)
2489AC_SUBST_SET(MOZ_EXTENSIONS)
2490
2491AC_SUBST(MOZ_UNIVERSALCHARDET)
2492AC_SUBST(MOZ_SPELLCHECK)
2493AC_SUBST(MOZ_ANDROID_ANR_REPORTER)
2494AC_SUBST(MOZ_CRASHREPORTER)
2495AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
2496AC_SUBST(MOZ_STUB_INSTALLER)
2497AC_SUBST(MOZ_UPDATER)
2498
2499AC_SUBST(MOZ_ANDROID_APPLICATION_CLASS)
2500AC_SUBST(MOZ_ANDROID_BROWSER_INTENT_CLASS)
2501AC_SUBST(INCREMENTAL_LINKER)
2502
2503AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
2504
2505AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
2506AC_SUBST(MOZ_LINKER_EXTRACT)
2507
2508if test -n "$MOZ_BINARY_EXTENSIONS"; then
2509  AC_DEFINE(MOZ_BINARY_EXTENSIONS)
2510fi
2511
2512dnl ========================================================
2513dnl = Mac bundle name prefix
2514dnl ========================================================
2515MOZ_ARG_WITH_STRING(macbundlename-prefix,
2516[  --with-macbundlename-prefix=prefix
2517                          Prefix for MOZ_MACBUNDLE_NAME],
2518[ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
2519
2520MOZ_MACBUNDLE_NAME=$MOZ_APP_DISPLAYNAME
2521if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
2522  MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
2523fi
2524
2525if test "$MOZ_DEBUG"; then
2526  MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME}Debug.app"
2527else
2528  MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
2529fi
2530AC_SUBST(MOZ_MACBUNDLE_NAME)
2531
2532dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
2533# If the MOZ_MACBUNDLE_ID is defined in the configure.sh, use it
2534# Otherwise, use MOZ_APP_DISPLAYNAME
2535if test -z "$MOZ_MACBUNDLE_ID"; then
2536   MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr 'A-Z' 'a-z' | tr -dc 'a-z-'`
2537fi
2538MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
2539if test "$MOZ_DEBUG"; then
2540  MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
2541fi
2542
2543AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
2544AC_SUBST(MOZ_MACBUNDLE_ID)
2545
2546dnl ========================================================
2547dnl = Child Process Name for IPC
2548dnl ========================================================
2549if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
2550  MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
2551else
2552  # We want to let Android unpack the file at install time, but it only does
2553  # so if the file is named libsomething.so. The lib/ path is also required
2554  # because the unpacked file will be under the lib/ subdirectory and will
2555  # need to be executed from that path.
2556  MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
2557fi
2558MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
2559MOZ_CHILD_PROCESS_BUNDLENAME="${MOZ_APP_DISPLAYNAME}CP"
2560
2561AC_SUBST(MOZ_CHILD_PROCESS_NAME)
2562AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
2563AC_SUBST(MOZ_CHILD_PROCESS_BUNDLENAME)
2564
2565# The following variables are available to branding and application
2566# configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
2567# - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
2568# impacts profile location and user-visible fields.
2569# - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
2570# Mac Bundle name, Updater, Installer), it is typically used for nightly
2571# builds (e.g. Aurora for Firefox).
2572# - MOZ_APP_PROFILE: When set, used for application.ini's
2573# "Profile" field, which controls profile location.
2574# - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
2575# crash reporter server url.
2576# - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
2577
2578# The following environment variables used to have an effect, but don't anymore:
2579# - MOZ_APP_VERSION: Defines the application version number. This was replaced with
2580# the contents from the version.txt file in the application directory, or
2581# browser/config/version.txt if there isn't one.
2582# - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
2583# in the "About" window. This was replaced with the contents from the
2584# version_display.txt or version.txt in the application directory, or
2585# browser/config/version_display.txt.
2586
2587# For extensions and langpacks, we require a max version that is compatible
2588# across security releases. MOZ_APP_MAXVERSION is our method for doing that.
2589# 24.0a1 and 24.0a2 aren't affected
2590# 24.0 becomes 24.*
2591# 24.1.1 becomes 24.*
2592IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
2593if test -z "$IS_ALPHA"; then
2594  changequote(,)
2595  if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
2596    MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
2597  else
2598    MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
2599  fi
2600  changequote([,])
2601else
2602  MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
2603fi
2604
2605AC_SUBST(MOZ_APP_DISPLAYNAME)
2606AC_SUBST(MOZ_APP_VENDOR)
2607AC_SUBST(MOZ_APP_PROFILE)
2608AC_SUBST(MOZ_APP_ID)
2609AC_SUBST(MAR_CHANNEL_ID)
2610AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
2611AC_SUBST(MOZ_PROFILE_MIGRATOR)
2612AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
2613AC_SUBST(MOZ_APP_UA_NAME)
2614AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
2615AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL, $BROWSER_CHROME_URL)
2616AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL_QUOTED, "$BROWSER_CHROME_URL")
2617
2618AC_SUBST(MOZ_APP_MAXVERSION)
2619AC_SUBST(MOZ_PKG_SPECIAL)
2620AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
2621
2622if test "$MOZILLA_OFFICIAL"; then
2623    # Build revisions should always be present in official builds
2624    MOZ_INCLUDE_SOURCE_INFO=1
2625fi
2626
2627# External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
2628# explicitly set the repository and changeset information in.
2629AC_SUBST(MOZ_SOURCE_REPO)
2630AC_SUBST(MOZ_SOURCE_CHANGESET)
2631AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
2632
2633dnl If we have any service that uploads data (and requires data submission
2634dnl policy alert), set MOZ_DATA_REPORTING.
2635dnl We need SUBST for build system and DEFINE for xul preprocessor.
2636if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "$MOZ_CRASHREPORTER"  || test -n "$MOZ_NORMANDY"; then
2637  MOZ_DATA_REPORTING=1
2638  AC_DEFINE(MOZ_DATA_REPORTING)
2639  AC_SUBST(MOZ_DATA_REPORTING)
2640fi
2641
2642dnl win32 options
2643AC_SUBST(WIN32_REDIST_DIR)
2644AC_SUBST(WIN_UCRT_REDIST_DIR)
2645
2646dnl Echo the CFLAGS to remove extra whitespace.
2647CFLAGS=`echo \
2648    $_COMPILATION_CFLAGS \
2649    $CFLAGS`
2650
2651CXXFLAGS=`echo \
2652    $_WARNINGS_CXXFLAGS \
2653    $_COMPILATION_CXXFLAGS \
2654    $CXXFLAGS`
2655
2656COMPILE_CFLAGS=`echo \
2657    $_DEFINES_CFLAGS \
2658    $COMPILE_CFLAGS`
2659
2660COMPILE_CXXFLAGS=`echo \
2661    $_DEFINES_CXXFLAGS \
2662    $COMPILE_CXXFLAGS`
2663
2664HOST_CFLAGS=`echo \
2665    $_WARNINGS_HOST_CFLAGS \
2666    $_COMPILATION_HOST_CFLAGS \
2667    $HOST_CFLAGS`
2668
2669HOST_CXXFLAGS=`echo \
2670    $_WARNINGS_HOST_CXXFLAGS \
2671    $_COMPILATION_HOST_CXXFLAGS \
2672    $HOST_CXXFLAGS`
2673
2674AC_SUBST(MOZ_SYSTEM_PNG)
2675
2676AC_SUBST_LIST(MOZ_PNG_CFLAGS)
2677AC_SUBST_LIST(MOZ_PNG_LIBS)
2678
2679HOST_CMFLAGS="-x objective-c -fobjc-exceptions"
2680HOST_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
2681OS_COMPILE_CMFLAGS="-x objective-c -fobjc-exceptions"
2682OS_COMPILE_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
2683if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
2684  OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
2685  OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
2686fi
2687AC_SUBST(HOST_CMFLAGS)
2688AC_SUBST(HOST_CMMFLAGS)
2689AC_SUBST(OS_COMPILE_CMFLAGS)
2690AC_SUBST(OS_COMPILE_CMMFLAGS)
2691
2692OS_CFLAGS="$CFLAGS"
2693OS_CXXFLAGS="$CXXFLAGS"
2694OS_CPPFLAGS="$CPPFLAGS"
2695OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
2696OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
2697OS_LDFLAGS="$LDFLAGS"
2698OS_LIBS="$LIBS"
2699AC_SUBST_LIST(OS_CFLAGS)
2700AC_SUBST_LIST(OS_CXXFLAGS)
2701AC_SUBST_LIST(OS_CPPFLAGS)
2702AC_SUBST_LIST(OS_COMPILE_CFLAGS)
2703AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
2704AC_SUBST_LIST(OS_LDFLAGS)
2705AC_SUBST(OS_LIBS)
2706
2707AC_SUBST(HOST_CC)
2708AC_SUBST(HOST_CXX)
2709AC_SUBST_LIST(HOST_CFLAGS)
2710AC_SUBST_LIST(HOST_CPPFLAGS)
2711AC_SUBST_LIST(HOST_CXXFLAGS)
2712AC_SUBST(HOST_LDFLAGS)
2713AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
2714AC_SUBST(HOST_BIN_SUFFIX)
2715
2716AC_SUBST(TARGET_XPCOM_ABI)
2717AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
2718AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSE4_1)
2719AC_SUBST(HAVE_X86_AVX2)
2720AC_SUBST(HAVE_ALTIVEC)
2721
2722AC_SUBST(DSO_LDOPTS)
2723AC_SUBST(BIN_SUFFIX)
2724AC_SUBST(USE_N32)
2725AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
2726AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
2727
2728AC_SUBST(MOZ_DEVTOOLS)
2729
2730AC_SUBST(MOZ_PACKAGE_JSSHELL)
2731
2732AC_SUBST(DMG_TOOL)
2733
2734dnl Host JavaScript runtime, if any, to use during cross compiles.
2735AC_SUBST(JS_BINARY)
2736
2737AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
2738
2739if test -n "$COMPILE_ENVIRONMENT"; then
2740AC_CHECK_FUNCS(posix_fadvise posix_fallocate)
2741
2742dnl Check for missing components
2743if test "$MOZ_X11"; then
2744    dnl ====================================================
2745    dnl = Check if X headers exist
2746    dnl ====================================================
2747    _SAVE_CFLAGS=$CFLAGS
2748    CFLAGS="$CFLAGS $XCFLAGS"
2749    AC_TRY_COMPILE([
2750        #include <stdio.h>
2751        #include <stdlib.h>
2752        #include <X11/Xlib.h>
2753        #include <X11/Intrinsic.h>
2754        #include <X11/extensions/XShm.h>
2755    ],
2756    [
2757        Display *dpy = 0;
2758        if ((dpy = XOpenDisplay(NULL)) == NULL) {
2759            fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
2760            exit(1);
2761        }
2762    ], [],
2763    [ AC_MSG_ERROR([Can't find X headers (install libxt-dev (Debian/Ubuntu), libXt-devel (Fedora), or xorg-x11-libXt-devel (SuSE)).]) ])
2764    CFLAGS="$_SAVE_CFLAGS"
2765
2766    if test -n "$MISSING_X"; then
2767        AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
2768    fi
2769
2770fi # MOZ_X11
2771
2772fi # COMPILE_ENVIRONMENT
2773
2774dnl Set various defines and substitutions
2775dnl ========================================================
2776
2777if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK" ; then
2778    AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
2779    ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
2780    ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
2781    ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
2782    ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
2783    AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
2784    AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
2785    AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
2786fi
2787
2788AC_SUBST(MOZ_DEV_EDITION)
2789if test -n "$MOZ_DEV_EDITION"; then
2790    AC_DEFINE(MOZ_DEV_EDITION)
2791fi
2792
2793if test "$MOZ_DEBUG" -o "$DEVELOPER_OPTIONS"; then
2794    A11Y_LOG=1
2795fi
2796AC_SUBST(A11Y_LOG)
2797if test -n "$A11Y_LOG"; then
2798    AC_DEFINE(A11Y_LOG)
2799fi
2800
2801dnl Windows AccessibilityHandler
2802dnl ========================================================
2803
2804if test -z "$MOZ_HANDLER_CLSID"; then
2805    MOZ_HANDLER_CLSID="4a195748-dca2-45fb-9295-0a139e76a9e7"
2806    MOZ_IHANDLERCONTROL_IID="3316ce35-f892-4832-97c5-06c52c03cdba"
2807    MOZ_ASYNCIHANDLERCONTROL_IID="15b48b76-ad38-4ad3-bd1a-d3c48a5a9947"
2808    MOZ_IGECKOBACKCHANNEL_IID="dd2e4a89-999e-4d65-8b65-440c923ddb61"
2809fi
2810
2811AC_SUBST(MOZ_HANDLER_CLSID)
2812AC_SUBST(MOZ_IHANDLERCONTROL_IID)
2813AC_SUBST(MOZ_ASYNCIHANDLERCONTROL_IID)
2814AC_SUBST(MOZ_IGECKOBACKCHANNEL_IID)
2815
2816dnl Spit out some output
2817dnl ========================================================
2818
2819# Avoid using obsolete NSPR features
2820AC_DEFINE(NO_NSPR_10_SUPPORT)
2821
2822MOZ_CREATE_CONFIG_STATUS()
2823
2824rm -fr confdefs* $ac_clean_files
2825