1dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; fill-column: 102 -*-
2dnl configure.ac serves as input for the GNU autoconf package
3dnl in order to create a configure script.
4
5# The version number in the second argument to AC_INIT should be four numbers separated by
6# periods. Some parts of the code requires the first one to be less than 128 and the others to be less
7# than 256. The four numbers can optionally be followed by a period and a free-form string containing
8# no spaces or periods, like "frobozz-mumble-42" or "alpha0". If the free-form string ends with one or
9# several non-alphanumeric characters, those are split off and used only for the
10# ABOUTBOXPRODUCTVERSIONSUFFIX in openoffice.lst. Why that is necessary, no idea.
11
12AC_INIT([LibreOffice],[6.4.7.2],[],[],[http://documentfoundation.org/])
13
14dnl libnumbertext needs autoconf 2.68, but that can pick up autoconf268 just fine if it is installed
15dnl whereas aclocal (as run by autogen.sh) insists on using autoconf and fails hard
16dnl so check for the version of autoconf that is actually used to create the configure script
17AC_PREREQ([2.59])
18m4_if(m4_version_compare(m4_defn([AC_AUTOCONF_VERSION]), [2.68]), -1,
19    [AC_MSG_ERROR([at least autoconf version 2.68 is needed (you can use AUTOCONF environment variable to point to a suitable one)])])
20
21if test -n "$BUILD_TYPE"; then
22    AC_MSG_ERROR([You have sourced config_host.mk in this shell.  This may lead to trouble, please run in a fresh (login) shell.])
23fi
24
25save_CC=$CC
26save_CXX=$CXX
27
28first_arg_basename()
29{
30    for i in $1; do
31        basename "$i"
32        break
33    done
34}
35
36CC_BASE=`first_arg_basename "$CC"`
37CXX_BASE=`first_arg_basename "$CXX"`
38
39BUILD_TYPE="LibO"
40SCPDEFS=""
41GIT_NEEDED_SUBMODULES=""
42LO_PATH= # used by path_munge to construct a PATH variable
43
44FilterLibs()
45{
46    filteredlibs=
47    for f in $1; do
48        case "$f" in
49            # let's start with Fedora's paths for now
50            -L/lib|-L/lib/|-L/lib64|-L/lib64/|-L/usr/lib|-L/usr/lib/|-L/usr/lib64|-L/usr/lib64/)
51                # ignore it: on UNIXoids it is searched by default anyway
52                # but if it's given explicitly then it may override other paths
53                # (on macOS it would be an error to use it instead of SDK)
54                ;;
55            *)
56                filteredlibs="$filteredlibs $f"
57                ;;
58        esac
59    done
60}
61
62PathFormat()
63{
64    formatted_path="$1"
65    if test "$build_os" = "cygwin"; then
66        pf_conv_to_dos=
67        # spaces,parentheses,brackets,braces are problematic in pathname
68        # so are backslashes
69        case "$formatted_path" in
70            *\ * | *\)* | *\(* | *\{* | *\}* | *\[* | *\]* | *\\* )
71                pf_conv_to_dos="yes"
72            ;;
73        esac
74        if test "$pf_conv_to_dos" = "yes"; then
75            if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
76                formatted_path=`cygpath -sm "$formatted_path"`
77            else
78                formatted_path=`cygpath -d "$formatted_path"`
79            fi
80            if test $? -ne 0;  then
81                AC_MSG_ERROR([path conversion failed for "$1".])
82            fi
83        fi
84        fp_count_colon=`echo "$formatted_path" | $GREP -c "[:]"`
85        fp_count_slash=`echo "$formatted_path" | $GREP -c "[/]"`
86        if test "$fp_count_slash$fp_count_colon" != "00"; then
87            if test "$fp_count_colon" = "0"; then
88                new_formatted_path=`realpath "$formatted_path"`
89                if test $? -ne 0;  then
90                    AC_MSG_WARN([realpath failed for "$1", not necessarily a problem.])
91                else
92                    formatted_path="$new_formatted_path"
93                fi
94            fi
95            formatted_path=`cygpath -m "$formatted_path"`
96            if test $? -ne 0;  then
97                AC_MSG_ERROR([path conversion failed for "$1".])
98            fi
99        fi
100        fp_count_space=`echo "$formatted_path" | $GREP -c "[ ]"`
101        if test "$fp_count_space" != "0"; then
102            AC_MSG_ERROR([converted path "$formatted_path" still contains spaces. Short filenames (8.3 filenames) support was disabled on this system?])
103        fi
104    fi
105}
106
107AbsolutePath()
108{
109    # There appears to be no simple and portable method to get an absolute and
110    # canonical path, so we try creating the directory if does not exist and
111    # utilizing the shell and pwd.
112    rel="$1"
113    absolute_path=""
114    test ! -e "$rel" && mkdir -p "$rel"
115    if test -d "$rel" ; then
116        cd "$rel" || AC_MSG_ERROR([absolute path resolution failed for "$rel".])
117        absolute_path="$(pwd)"
118        cd - > /dev/null
119    else
120        AC_MSG_ERROR([Failed to resolve absolute path.  "$rel" does not exist or is not a directory.])
121    fi
122}
123
124rm -f warn
125have_WARNINGS="no"
126add_warning()
127{
128    if test "$have_WARNINGS" = "no"; then
129        echo "*************************************" > warn
130        have_WARNINGS="yes"
131        if which tput >/dev/null && test "`tput colors 2>/dev/null || echo 0`" -ge 8; then
132            dnl <esc> as actual byte (U+1b), [ escaped using quadrigraph @<:@
133            COLORWARN='*@<:@1;33;40m WARNING @<:@0m:'
134        else
135            COLORWARN="* WARNING :"
136        fi
137    fi
138    echo "$COLORWARN $@" >> warn
139}
140
141dnl Some Mac User have the bad habit of letting a lot of crap
142dnl accumulate in their PATH and even adding stuff in /usr/local/bin
143dnl that confuse the build.
144dnl For the ones that use LODE, let's be nice and protect them
145dnl from themselves
146
147mac_sanitize_path()
148{
149    mac_path="$LODE_HOME/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin"
150dnl a common but nevertheless necessary thing that may be in a fancy
151dnl path location is git, so make sure we have it
152    mac_git_path=`which git 2>/dev/null`
153    if test -n "$mac_git_path" -a -x "$mac_git_path" -a "$mac_git_path" != "/usr/bin/git" ; then
154        mac_path="$mac_path:`dirname $mac_git_path`"
155    fi
156dnl a not so common but nevertheless quite helpful thing that may be in a fancy
157dnl path location is gpg, so make sure we find it
158    mac_gpg_path=`which gpg 2>/dev/null`
159    if test -n "$mac_gpg_path" -a -x "$mac_gpg_path" -a "$mac_gpg_path" != "/usr/bin/gpg" ; then
160        mac_path="$mac_path:`dirname $mac_gpg_path`"
161    fi
162    PATH="$mac_path"
163    unset mac_path
164    unset mac_git_path
165    unset mac_gpg_path
166}
167
168echo "********************************************************************"
169echo "*"
170echo "*   Running ${PACKAGE_NAME} build configuration."
171echo "*"
172echo "********************************************************************"
173echo ""
174
175dnl ===================================================================
176dnl checks build and host OSes
177dnl do this before argument processing to allow for platform dependent defaults
178dnl ===================================================================
179AC_CANONICAL_HOST
180
181AC_MSG_CHECKING([for product name])
182PRODUCTNAME="AC_PACKAGE_NAME"
183if test -n "$with_product_name" -a "$with_product_name" != no; then
184    PRODUCTNAME="$with_product_name"
185fi
186if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
187    PRODUCTNAME="${PRODUCTNAME}Dev"
188fi
189AC_MSG_RESULT([$PRODUCTNAME])
190AC_SUBST(PRODUCTNAME)
191PRODUCTNAME_WITHOUT_SPACES=$(printf %s "$PRODUCTNAME" | sed 's/ //g')
192AC_SUBST(PRODUCTNAME_WITHOUT_SPACES)
193
194dnl ===================================================================
195dnl Our version is defined by the AC_INIT() at the top of this script.
196dnl ===================================================================
197
198AC_MSG_CHECKING([for package version])
199if test -n "$with_package_version" -a "$with_package_version" != no; then
200    PACKAGE_VERSION="$with_package_version"
201fi
202AC_MSG_RESULT([$PACKAGE_VERSION])
203
204set `echo "$PACKAGE_VERSION" | sed "s/\./ /g"`
205
206LIBO_VERSION_MAJOR=$1
207LIBO_VERSION_MINOR=$2
208LIBO_VERSION_MICRO=$3
209LIBO_VERSION_PATCH=$4
210
211# The CFBundleShortVersionString in Info.plist consists of three integers, so encode the third
212# as the micro version times 1000 plus the patch number. Unfortunately the LIBO_VERSION_SUFFIX can be anything so
213# no way to encode that into an integer in general.
214MACOSX_BUNDLE_SHORTVERSION=$LIBO_VERSION_MAJOR.$LIBO_VERSION_MINOR.`expr $LIBO_VERSION_MICRO '*' 1000 + $LIBO_VERSION_PATCH`
215
216LIBO_VERSION_SUFFIX=$5
217# Split out LIBO_VERSION_SUFFIX_SUFFIX... horrible crack. But apparently wanted separately in
218# openoffice.lst as ABOUTBOXPRODUCTVERSIONSUFFIX. Note that the double brackets are for m4's sake,
219# they get undoubled before actually passed to sed.
220LIBO_VERSION_SUFFIX_SUFFIX=`echo "$LIBO_VERSION_SUFFIX" | sed -e 's/.*[[a-zA-Z0-9]]\([[^a-zA-Z0-9]]*\)$/\1/'`
221test -n "$LIBO_VERSION_SUFFIX_SUFFIX" && LIBO_VERSION_SUFFIX="${LIBO_VERSION_SUFFIX%${LIBO_VERSION_SUFFIX_SUFFIX}}"
222# LIBO_VERSION_SUFFIX, if non-empty, should include the period separator
223test -n "$LIBO_VERSION_SUFFIX" && LIBO_VERSION_SUFFIX=".$LIBO_VERSION_SUFFIX"
224
225AC_SUBST(LIBO_VERSION_MAJOR)
226AC_SUBST(LIBO_VERSION_MINOR)
227AC_SUBST(LIBO_VERSION_MICRO)
228AC_SUBST(LIBO_VERSION_PATCH)
229AC_SUBST(MACOSX_BUNDLE_SHORTVERSION)
230AC_SUBST(LIBO_VERSION_SUFFIX)
231AC_SUBST(LIBO_VERSION_SUFFIX_SUFFIX)
232
233AC_DEFINE_UNQUOTED(LIBO_VERSION_MAJOR,$LIBO_VERSION_MAJOR)
234AC_DEFINE_UNQUOTED(LIBO_VERSION_MINOR,$LIBO_VERSION_MINOR)
235AC_DEFINE_UNQUOTED(LIBO_VERSION_MICRO,$LIBO_VERSION_MICRO)
236AC_DEFINE_UNQUOTED(LIBO_VERSION_PATCH,$LIBO_VERSION_PATCH)
237
238LIBO_THIS_YEAR=`date +%Y`
239AC_DEFINE_UNQUOTED(LIBO_THIS_YEAR,$LIBO_THIS_YEAR)
240
241dnl ===================================================================
242dnl Product version
243dnl ===================================================================
244AC_MSG_CHECKING([for product version])
245PRODUCTVERSION="$LIBO_VERSION_MAJOR.$LIBO_VERSION_MINOR"
246AC_MSG_RESULT([$PRODUCTVERSION])
247AC_SUBST(PRODUCTVERSION)
248
249AC_PROG_EGREP
250# AC_PROG_EGREP doesn't set GREP on all systems as well
251AC_PATH_PROG(GREP, grep)
252
253BUILDDIR=`pwd`
254cd $srcdir
255SRC_ROOT=`pwd`
256cd $BUILDDIR
257x_Cygwin=[\#]
258
259dnl ======================================
260dnl Required GObject introspection version
261dnl ======================================
262INTROSPECTION_REQUIRED_VERSION=1.32.0
263
264dnl ===================================================================
265dnl Search all the common names for GNU Make
266dnl ===================================================================
267AC_MSG_CHECKING([for GNU Make])
268
269# try to use our own make if it is available and GNUMAKE was not already defined
270if test -z "$GNUMAKE"; then
271    if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/make" ; then
272        GNUMAKE="$LODE_HOME/opt/bin/make"
273    elif test -x "/opt/lo/bin/make"; then
274        GNUMAKE="/opt/lo/bin/make"
275    fi
276fi
277
278GNUMAKE_WIN_NATIVE=
279for a in "$MAKE" "$GNUMAKE" make gmake gnumake; do
280    if test -n "$a"; then
281        $a --version 2> /dev/null | grep GNU  2>&1 > /dev/null
282        if test $? -eq 0;  then
283            if test "$build_os" = "cygwin"; then
284                if test -n "$($a -v | grep 'Built for Windows')" ; then
285                    GNUMAKE="$(cygpath -m "$(which "$(cygpath -u $a)")")"
286                    GNUMAKE_WIN_NATIVE="TRUE"
287                else
288                    GNUMAKE=`which $a`
289                fi
290            else
291                GNUMAKE=`which $a`
292            fi
293            break
294        fi
295    fi
296done
297AC_MSG_RESULT($GNUMAKE)
298if test -z "$GNUMAKE"; then
299    AC_MSG_ERROR([not found. install GNU Make.])
300else
301    if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
302        AC_MSG_NOTICE([Using a native Win32 GNU Make version.])
303    fi
304fi
305
306win_short_path_for_make()
307{
308    local_short_path="$1"
309    if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
310        cygpath -sm "$local_short_path"
311    else
312        cygpath -u "$(cygpath -d "$local_short_path")"
313    fi
314}
315
316
317if test "$build_os" = "cygwin"; then
318    PathFormat "$SRC_ROOT"
319    SRC_ROOT="$formatted_path"
320    PathFormat "$BUILDDIR"
321    BUILDDIR="$formatted_path"
322    x_Cygwin=
323    AC_MSG_CHECKING(for explicit COMSPEC)
324    if test -z "$COMSPEC"; then
325        AC_MSG_ERROR([COMSPEC not set in environment, please set it and rerun])
326    else
327        AC_MSG_RESULT([found: $COMSPEC])
328    fi
329fi
330
331AC_SUBST(SRC_ROOT)
332AC_SUBST(BUILDDIR)
333AC_SUBST(x_Cygwin)
334AC_DEFINE_UNQUOTED(SRCDIR,"$SRC_ROOT")
335AC_DEFINE_UNQUOTED(SRC_ROOT,"$SRC_ROOT")
336AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
337
338if test "z$EUID" = "z0" -a "`uname -o 2>/dev/null`" = "Cygwin"; then
339    AC_MSG_ERROR([You must build LibreOffice as a normal user - not using an administrative account])
340fi
341
342# need sed in os checks...
343AC_PATH_PROGS(SED, sed)
344if test -z "$SED"; then
345    AC_MSG_ERROR([install sed to run this script])
346fi
347
348# Set the ENABLE_LTO variable
349# ===================================================================
350AC_MSG_CHECKING([whether to use link-time optimization])
351if test -n "$enable_lto" -a "$enable_lto" != "no"; then
352    ENABLE_LTO="TRUE"
353    AC_MSG_RESULT([yes])
354    AC_DEFINE(STATIC_LINKING)
355else
356    ENABLE_LTO=""
357    AC_MSG_RESULT([no])
358fi
359AC_SUBST(ENABLE_LTO)
360
361AC_ARG_ENABLE(fuzz-options,
362    AS_HELP_STRING([--enable-fuzz-options],
363        [Randomly enable or disable each of those configurable options
364         that are supposed to be freely selectable without interdependencies,
365         or where bad interaction from interdependencies is automatically avoided.])
366)
367
368dnl ===================================================================
369dnl When building for Android, --with-android-ndk,
370dnl --with-android-ndk-toolchain-version and --with-android-sdk are
371dnl mandatory
372dnl ===================================================================
373
374AC_ARG_WITH(android-ndk,
375    AS_HELP_STRING([--with-android-ndk],
376        [Specify location of the Android Native Development Kit. Mandatory when building for Android.]),
377,)
378
379AC_ARG_WITH(android-ndk-toolchain-version,
380    AS_HELP_STRING([--with-android-ndk-toolchain-version],
381        [Specify which toolchain version to use, of those present in the
382        Android NDK you are using. The default (and only supported version currently) is "clang5.0"]),,
383        with_android_ndk_toolchain_version=clang5.0)
384
385AC_ARG_WITH(android-sdk,
386    AS_HELP_STRING([--with-android-sdk],
387        [Specify location of the Android SDK. Mandatory when building for Android.]),
388,)
389
390AC_ARG_WITH(android-api-level,
391    AS_HELP_STRING([--with-android-api-level],
392        [Specify the API level when building for Android. Defaults to 16 for ARM and x86 and to 21 for ARM64 and x86-64]),
393,)
394
395ANDROID_NDK_HOME=
396if test -z "$with_android_ndk" -a -e "$SRC_ROOT/external/android-ndk" -a "$build" != "$host"; then
397    with_android_ndk="$SRC_ROOT/external/android-ndk"
398fi
399if test -n "$with_android_ndk"; then
400    eval ANDROID_NDK_HOME=$with_android_ndk
401
402    # Set up a lot of pre-canned defaults
403
404    if test ! -f $ANDROID_NDK_HOME/RELEASE.TXT; then
405        if test ! -f $ANDROID_NDK_HOME/source.properties; then
406            AC_MSG_ERROR([Unrecognized Android NDK. Missing RELEASE.TXT or source.properties file in $ANDROID_NDK_HOME.])
407        fi
408        ANDROID_NDK_VERSION=`sed -n -e 's/Pkg.Revision = //p' $ANDROID_NDK_HOME/source.properties`
409    else
410        ANDROID_NDK_VERSION=`cut -f1 -d' ' <$ANDROID_NDK_HOME/RELEASE.TXT`
411    fi
412    if test -z "$ANDROID_NDK_VERSION";  then
413        AC_MSG_ERROR([Failed to determine Android NDK version. Please check your installation.])
414    fi
415    case $ANDROID_NDK_VERSION in
416    r9*|r10*)
417        AC_MSG_ERROR([Building for Android is only supported with NDK versions above 16.x*])
418        ;;
419    11.1.*|12.1.*|13.1.*|14.1.*)
420        AC_MSG_ERROR([Building for Android is only supported with NDK versions above 16.x.*])
421        ;;
422    16.*|17.*|18.*|19.*|20.*)
423        ;;
424    *)
425        AC_MSG_WARN([Untested Android NDK version $ANDROID_NDK_VERSION, only versions 16.* til 20.* have been used successfully. Proceed at your own risk.])
426        add_warning "Untested Android NDK version $ANDROID_NDK_VERSION, only versions 16.* til 20.* have been used successfully. Proceed at your own risk."
427        ;;
428    esac
429
430    ANDROID_API_LEVEL=16
431    if test -n "$with_android_api_level" ; then
432        ANDROID_API_LEVEL="$with_android_api_level"
433    fi
434
435    android_cpu=$host_cpu
436    if test $host_cpu = arm; then
437        android_platform_prefix=arm-linux-androideabi
438        android_gnu_prefix=$android_platform_prefix
439        LLVM_TRIPLE=armv7a-linux-androideabi
440        ANDROID_APP_ABI=armeabi-v7a
441        ANDROIDCFLAGS="-mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -Wl,--fix-cortex-a8"
442    elif test $host_cpu = aarch64; then
443        android_platform_prefix=aarch64-linux-android
444        android_gnu_prefix=$android_platform_prefix
445        LLVM_TRIPLE=$android_platform_prefix
446        # minimum android version that supports aarch64
447        if test "$ANDROID_API_LEVEL" -lt "21" ; then
448            ANDROID_API_LEVEL=21
449        fi
450        ANDROID_APP_ABI=arm64-v8a
451    elif test $host_cpu = x86_64; then
452        android_platform_prefix=x86_64-linux-android
453        android_gnu_prefix=$android_platform_prefix
454        LLVM_TRIPLE=$android_platform_prefix
455        # minimum android version that supports x86_64
456        ANDROID_API_LEVEL=21
457        ANDROID_APP_ABI=x86_64
458    else
459        # host_cpu is something like "i386" or "i686" I guess, NDK uses
460        # "x86" in some contexts
461        android_cpu=x86
462        android_platform_prefix=$android_cpu
463        android_gnu_prefix=i686-linux-android
464        LLVM_TRIPLE=$android_gnu_prefix
465        ANDROID_APP_ABI=x86
466    fi
467
468    case "$with_android_ndk_toolchain_version" in
469    clang5.0)
470        ANDROID_GCC_TOOLCHAIN_VERSION=4.9
471        ;;
472    *)
473        AC_MSG_ERROR([Unrecognized value for the --with-android-ndk-toolchain-version option. Building for Android is only supported with Clang 5.*])
474    esac
475
476    AC_MSG_NOTICE([using the Android API level... $ANDROID_API_LEVEL])
477
478    # NDK 15 or later toolchain is 64bit-only, except for Windows that we don't support. Using a 64-bit
479    # linker is required if you compile large parts of the code with -g. A 32-bit linker just won't
480    # manage to link the (app-specific) single huge .so that is built for the app in
481    # android/source/ if there is debug information in a significant part of the object files.
482    # (A 64-bit ld.gold grows too much over 10 gigabytes of virtual space when linking such a .so if
483    # all objects have been built with debug information.)
484    case $build_os in
485    linux-gnu*)
486        android_HOST_TAG=linux-x86_64
487        ;;
488    darwin*)
489        android_HOST_TAG=darwin-x86_64
490        ;;
491    *)
492        AC_MSG_ERROR([We only support building for Android from Linux or macOS])
493        # ndk would also support windows and windows-x86_64
494        ;;
495    esac
496    android_TOOLCHAIN=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/$android_HOST_TAG
497    ANDROID_COMPILER_BIN=$android_TOOLCHAIN/bin
498    dnl TODO: NSS build uses it...
499    ANDROID_BINUTILS_PREBUILT_ROOT=$ANDROID_NDK_HOME/toolchains/$android_platform_prefix-$ANDROID_GCC_TOOLCHAIN_VERSION/prebuilt/$android_HOST_TAG
500    AC_SUBST(ANDROID_BINUTILS_PREBUILT_ROOT)
501
502    test -z "$AR" && AR=$ANDROID_COMPILER_BIN/$android_gnu_prefix-ar
503    test -z "$NM" && NM=$ANDROID_COMPILER_BIN/$android_gnu_prefix-nm
504    test -z "$OBJDUMP" && OBJDUMP=$ANDROID_COMPILER_BIN/$android_gnu_prefix-objdump
505    test -z "$RANLIB" && RANLIB=$ANDROID_COMPILER_BIN/$android_gnu_prefix-ranlib
506    test -z "$STRIP" && STRIP=$ANDROID_COMPILER_BIN/$android_gnu_prefix-strip
507
508    ANDROIDCFLAGS="$ANDROIDCFLAGS -target ${LLVM_TRIPLE}${ANDROID_API_LEVEL}"
509    ANDROIDCFLAGS="$ANDROIDCFLAGS -no-canonical-prefixes -ffunction-sections -fdata-sections -Qunused-arguments"
510    if test "$ENABLE_LTO" = TRUE; then
511        # -flto comes from com_GCC_defs.mk, too, but we need to make sure it gets passed as part of
512        # $CC and $CXX when building external libraries
513        ANDROIDCFLAGS="$ANDROIDCFLAGS -flto -fuse-linker-plugin -O2"
514    fi
515
516    ANDROIDCXXFLAGS="$ANDROIDCFLAGS -stdlib=libc++"
517
518    if test -z "$CC"; then
519        CC="$ANDROID_COMPILER_BIN/clang $ANDROIDCFLAGS"
520        CC_BASE="clang"
521    fi
522    if test -z "$CXX"; then
523        CXX="$ANDROID_COMPILER_BIN/clang++ $ANDROIDCXXFLAGS"
524        CXX_BASE="clang++"
525    fi
526
527    # remember to download the ownCloud Android library later
528    BUILD_TYPE="$BUILD_TYPE OWNCLOUD_ANDROID_LIB"
529fi
530AC_SUBST(ANDROID_NDK_HOME)
531AC_SUBST(ANDROID_APP_ABI)
532AC_SUBST(ANDROID_GCC_TOOLCHAIN_VERSION)
533
534dnl ===================================================================
535dnl --with-android-sdk
536dnl ===================================================================
537ANDROID_SDK_HOME=
538if test -z "$with_android_sdk" -a -e "$SRC_ROOT/external/android-sdk-linux" -a "$build" != "$host"; then
539    with_android_sdk="$SRC_ROOT/external/android-sdk-linux"
540fi
541if test -n "$with_android_sdk"; then
542    eval ANDROID_SDK_HOME=$with_android_sdk
543    PATH="$ANDROID_SDK_HOME/platform-tools:$ANDROID_SDK_HOME/tools:$PATH"
544fi
545AC_SUBST(ANDROID_SDK_HOME)
546
547libo_FUZZ_ARG_ENABLE([android-editing],
548    AS_HELP_STRING([--enable-android-editing],
549        [Enable the experimental editing feature on Android.])
550)
551ENABLE_ANDROID_EDITING=
552if test "$enable_android_editing" = yes; then
553    ENABLE_ANDROID_EDITING=TRUE
554fi
555AC_SUBST([ENABLE_ANDROID_EDITING])
556
557dnl ===================================================================
558dnl The following is a list of supported systems.
559dnl Sequential to keep the logic very simple
560dnl These values may be checked and reset later.
561dnl ===================================================================
562#defaults unless the os test overrides this:
563test_randr=yes
564test_xrender=yes
565test_cups=yes
566test_dbus=yes
567test_fontconfig=yes
568test_cairo=no
569test_gdb_index=no
570test_split_debug=no
571
572# Default values, as such probably valid just for Linux, set
573# differently below just for Mac OSX, but at least better than
574# hardcoding these as we used to do. Much of this is duplicated also
575# in solenv for old build system and for gbuild, ideally we should
576# perhaps define stuff like this only here in configure.ac?
577
578LINKFLAGSSHL="-shared"
579PICSWITCH="-fpic"
580DLLPOST=".so"
581
582LINKFLAGSNOUNDEFS="-Wl,-z,defs"
583
584INSTROOTBASESUFFIX=
585INSTROOTCONTENTSUFFIX=
586SDKDIRNAME=sdk
587
588case "$host_os" in
589
590solaris*)
591    build_gstreamer_1_0=yes
592    test_freetype=yes
593    _os=SunOS
594
595    dnl ===========================================================
596    dnl Check whether we're using Solaris 10 - SPARC or Intel.
597    dnl ===========================================================
598    AC_MSG_CHECKING([the Solaris operating system release])
599    _os_release=`echo $host_os | $SED -e s/solaris2\.//`
600    if test "$_os_release" -lt "10"; then
601        AC_MSG_ERROR([use Solaris >= 10 to build LibreOffice])
602    else
603        AC_MSG_RESULT([ok ($_os_release)])
604    fi
605
606    dnl Check whether we're using a SPARC or i386 processor
607    AC_MSG_CHECKING([the processor type])
608    if test "$host_cpu" = "sparc" -o "$host_cpu" = "i386"; then
609        AC_MSG_RESULT([ok ($host_cpu)])
610    else
611        AC_MSG_ERROR([only SPARC and i386 processors are supported])
612    fi
613    ;;
614
615linux-gnu*|k*bsd*-gnu*)
616    build_gstreamer_1_0=yes
617    test_kf5=yes
618    test_gtk3_kde5=yes
619    test_gdb_index=yes
620    test_split_debug=yes
621    if test "$enable_fuzzers" != yes; then
622        test_freetype=yes
623        test_fontconfig=yes
624    else
625        test_freetype=no
626        test_fontconfig=no
627        BUILD_TYPE="$BUILD_TYPE FONTCONFIG FREETYPE"
628    fi
629    _os=Linux
630    ;;
631
632gnu)
633    test_randr=no
634    test_xrender=no
635    _os=GNU
636     ;;
637
638cygwin*|interix*)
639
640    # When building on Windows normally with MSVC under Cygwin,
641    # configure thinks that the host platform (the platform the
642    # built code will run on) is Cygwin, even if it obviously is
643    # Windows, which in Autoconf terminology is called
644    # "mingw32". (Which is misleading as MinGW is the name of the
645    # tool-chain, not an operating system.)
646
647    # Somewhat confusing, yes. But this configure script doesn't
648    # look at $host etc that much, it mostly uses its own $_os
649    # variable, set here in this case statement.
650
651    test_cups=no
652    test_dbus=no
653    test_randr=no
654    test_xrender=no
655    test_freetype=no
656    test_fontconfig=no
657    _os=WINNT
658
659    DLLPOST=".dll"
660    LINKFLAGSNOUNDEFS=
661    ;;
662
663darwin*) # macOS or iOS
664    test_randr=no
665    test_xrender=no
666    test_freetype=no
667    test_fontconfig=no
668    test_dbus=no
669    if test -n "$LODE_HOME" ; then
670        mac_sanitize_path
671        AC_MSG_NOTICE([sanitized the PATH to $PATH])
672    fi
673    if test "$host_cpu" = "arm64" -o "$enable_ios_simulator" = "yes"; then
674        build_for_ios=YES
675        _os=iOS
676        test_cups=no
677        enable_mpl_subset=yes
678        enable_lotuswordpro=no
679        enable_coinmp=no
680        enable_lpsolve=no
681        enable_postgresql_sdbc=no
682        enable_extension_integration=no
683        enable_report_builder=no
684        with_ppds=no
685        if test "$enable_ios_simulator" = "yes"; then
686            host=x86_64-apple-darwin
687        fi
688    else
689        _os=Darwin
690        INSTROOTBASESUFFIX=/$PRODUCTNAME_WITHOUT_SPACES.app
691        INSTROOTCONTENTSUFFIX=/Contents
692        SDKDIRNAME=AC_PACKAGE_NAME${PRODUCTVERSION}_SDK
693    fi
694    # See comment above the case "$host_os"
695    LINKFLAGSSHL="-dynamiclib -single_module"
696
697    # -fPIC is default
698    PICSWITCH=""
699
700    DLLPOST=".dylib"
701
702    # -undefined error is the default
703    LINKFLAGSNOUNDEFS=""
704;;
705
706freebsd*)
707    build_gstreamer_1_0=yes
708    test_kf5=yes
709    test_gtk3_kde5=yes
710    test_freetype=yes
711    AC_MSG_CHECKING([the FreeBSD operating system release])
712    if test -n "$with_os_version"; then
713        OSVERSION="$with_os_version"
714    else
715        OSVERSION=`/sbin/sysctl -n kern.osreldate`
716    fi
717    AC_MSG_RESULT([found OSVERSION=$OSVERSION])
718    AC_MSG_CHECKING([which thread library to use])
719    if test "$OSVERSION" -lt "500016"; then
720        PTHREAD_CFLAGS="-D_THREAD_SAFE"
721        PTHREAD_LIBS="-pthread"
722    elif test "$OSVERSION" -lt "502102"; then
723        PTHREAD_CFLAGS="-D_THREAD_SAFE"
724        PTHREAD_LIBS="-lc_r"
725    else
726        PTHREAD_CFLAGS=""
727        PTHREAD_LIBS="-pthread"
728    fi
729    AC_MSG_RESULT([$PTHREAD_LIBS])
730    _os=FreeBSD
731    ;;
732
733*netbsd*)
734    build_gstreamer_1_0=yes
735    test_kf5=yes
736    test_gtk3_kde5=yes
737    test_freetype=yes
738    PTHREAD_LIBS="-pthread -lpthread"
739    _os=NetBSD
740    ;;
741
742aix*)
743    test_randr=no
744    test_freetype=yes
745    PTHREAD_LIBS=-pthread
746    _os=AIX
747    ;;
748
749openbsd*)
750    test_freetype=yes
751    PTHREAD_CFLAGS="-D_THREAD_SAFE"
752    PTHREAD_LIBS="-pthread"
753    _os=OpenBSD
754    ;;
755
756dragonfly*)
757    build_gstreamer_1_0=yes
758    test_kf5=yes
759    test_gtk3_kde5=yes
760    test_freetype=yes
761    PTHREAD_LIBS="-pthread"
762    _os=DragonFly
763    ;;
764
765linux-android*)
766    build_gstreamer_1_0=no
767    enable_lotuswordpro=no
768    enable_mpl_subset=yes
769    enable_coinmp=yes
770    enable_lpsolve=no
771    enable_report_builder=no
772    enable_odk=no
773    enable_postgresql_sdbc=no
774    enable_python=no
775    test_cups=no
776    test_dbus=no
777    test_fontconfig=no
778    test_freetype=no
779    test_kf5=no
780    test_qt5=no
781    test_gtk3_kde5=no
782    test_randr=no
783    test_xrender=no
784    _os=Android
785
786    AC_DEFINE(HAVE_FT_FACE_GETCHARVARIANTINDEX)
787    BUILD_TYPE="$BUILD_TYPE CAIRO FONTCONFIG FREETYPE"
788    ;;
789
790haiku*)
791    test_cups=no
792    test_dbus=no
793    test_randr=no
794    test_xrender=no
795    test_freetype=yes
796    enable_odk=no
797    enable_gstreamer_1_0=no
798    enable_vlc=no
799    enable_coinmp=no
800    enable_pdfium=no
801    enable_sdremote=no
802    enable_postgresql_sdbc=no
803    enable_firebird_sdbc=no
804    _os=Haiku
805    ;;
806
807*)
808    AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice for!])
809    ;;
810esac
811
812if test "$_os" = "Android" ; then
813    # Verify that the NDK and SDK options are proper
814    if test -z "$with_android_ndk"; then
815        AC_MSG_ERROR([the --with-android-ndk option is mandatory, unless it is available at external/android-ndk/.])
816    elif test ! -f "$ANDROID_NDK_HOME/meta/abis.json"; then
817        AC_MSG_ERROR([the --with-android-ndk option does not point to an Android NDK])
818    fi
819
820    if test -z "$ANDROID_SDK_HOME"; then
821        AC_MSG_ERROR([the --with-android-sdk option is mandatory, unless it is available at external/android-sdk-linux/.])
822    elif test ! -d "$ANDROID_SDK_HOME/platforms"; then
823        AC_MSG_ERROR([the --with-android-sdk option does not point to an Android SDK])
824    fi
825
826    BUILD_TOOLS_VERSION=`$SED -n -e 's/.*buildToolsVersion "\(.*\)"/\1/p' $SRC_ROOT/android/source/build.gradle`
827    if test ! -d "$ANDROID_SDK_HOME/build-tools/$BUILD_TOOLS_VERSION"; then
828        AC_MSG_WARN([android build-tools $BUILD_TOOLS_VERSION not found - install with
829                         $ANDROID_SDK_HOME/tools/android update sdk -u --all --filter build-tools-$BUILD_TOOLS_VERSION
830                    or adjust change $SRC_ROOT/android/source/build.gradle accordingly])
831        add_warning "android build-tools $BUILD_TOOLS_VERSION not found - install with"
832        add_warning "    $ANDROID_SDK_HOME/tools/android update sdk -u --all --filter build-tools-$BUILD_TOOLS_VERSION"
833        add_warning "or adjust $SRC_ROOT/android/source/build.gradle accordingly"
834    fi
835    if test ! -f "$ANDROID_SDK_HOME/extras/android/m2repository/source.properties"; then
836        AC_MSG_WARN([android support repository not found - install with
837                         $ANDROID_SDK_HOME/tools/android update sdk -u --filter extra-android-m2repository
838                     to allow the build to download the specified version of the android support libraries])
839        add_warning "android support repository not found - install with"
840        add_warning "    $ANDROID_SDK_HOME/tools/android update sdk -u --filter extra-android-m2repository"
841        add_warning "to allow the build to download the specified version of the android support libraries"
842    fi
843fi
844
845if test "$_os" = "AIX"; then
846    AC_PATH_PROG(GAWK, gawk)
847    if test -z "$GAWK"; then
848        AC_MSG_ERROR([gawk not found in \$PATH])
849    fi
850fi
851
852AC_SUBST(SDKDIRNAME)
853
854AC_SUBST(PTHREAD_CFLAGS)
855AC_SUBST(PTHREAD_LIBS)
856
857# Check for explicit A/C/CXX/OBJC/OBJCXX/LDFLAGS.
858# By default use the ones specified by our build system,
859# but explicit override is possible.
860AC_MSG_CHECKING(for explicit AFLAGS)
861if test -n "$AFLAGS"; then
862    AC_MSG_RESULT([$AFLAGS])
863    x_AFLAGS=
864else
865    AC_MSG_RESULT(no)
866    x_AFLAGS=[\#]
867fi
868AC_MSG_CHECKING(for explicit CFLAGS)
869if test -n "$CFLAGS"; then
870    AC_MSG_RESULT([$CFLAGS])
871    x_CFLAGS=
872else
873    AC_MSG_RESULT(no)
874    x_CFLAGS=[\#]
875fi
876AC_MSG_CHECKING(for explicit CXXFLAGS)
877if test -n "$CXXFLAGS"; then
878    AC_MSG_RESULT([$CXXFLAGS])
879    x_CXXFLAGS=
880else
881    AC_MSG_RESULT(no)
882    x_CXXFLAGS=[\#]
883fi
884AC_MSG_CHECKING(for explicit OBJCFLAGS)
885if test -n "$OBJCFLAGS"; then
886    AC_MSG_RESULT([$OBJCFLAGS])
887    x_OBJCFLAGS=
888else
889    AC_MSG_RESULT(no)
890    x_OBJCFLAGS=[\#]
891fi
892AC_MSG_CHECKING(for explicit OBJCXXFLAGS)
893if test -n "$OBJCXXFLAGS"; then
894    AC_MSG_RESULT([$OBJCXXFLAGS])
895    x_OBJCXXFLAGS=
896else
897    AC_MSG_RESULT(no)
898    x_OBJCXXFLAGS=[\#]
899fi
900AC_MSG_CHECKING(for explicit LDFLAGS)
901if test -n "$LDFLAGS"; then
902    AC_MSG_RESULT([$LDFLAGS])
903    x_LDFLAGS=
904else
905    AC_MSG_RESULT(no)
906    x_LDFLAGS=[\#]
907fi
908AC_SUBST(AFLAGS)
909AC_SUBST(CFLAGS)
910AC_SUBST(CXXFLAGS)
911AC_SUBST(OBJCFLAGS)
912AC_SUBST(OBJCXXFLAGS)
913AC_SUBST(LDFLAGS)
914AC_SUBST(x_AFLAGS)
915AC_SUBST(x_CFLAGS)
916AC_SUBST(x_CXXFLAGS)
917AC_SUBST(x_OBJCFLAGS)
918AC_SUBST(x_OBJCXXFLAGS)
919AC_SUBST(x_LDFLAGS)
920
921dnl These are potentially set for MSVC, in the code checking for UCRT below:
922my_original_CFLAGS=$CFLAGS
923my_original_CXXFLAGS=$CXXFLAGS
924my_original_CPPFLAGS=$CPPFLAGS
925
926dnl The following checks for gcc, cc and then cl (if it weren't guarded for win32)
927dnl Needs to precede the AC_C_BIGENDIAN and AC_SEARCH_LIBS calls below, which apparently call
928dnl AC_PROG_CC internally.
929if test "$_os" != "WINNT"; then
930    # AC_PROG_CC sets CFLAGS to -g -O2 if not set, avoid that
931    save_CFLAGS=$CFLAGS
932    AC_PROG_CC
933    CFLAGS=$save_CFLAGS
934    if test -z "$CC_BASE"; then
935        CC_BASE=`first_arg_basename "$CC"`
936    fi
937fi
938
939if test "$_os" != "WINNT"; then
940    AC_C_BIGENDIAN([ENDIANNESS=big], [ENDIANNESS=little])
941else
942    ENDIANNESS=little
943fi
944AC_SUBST(ENDIANNESS)
945
946if test $_os != "WINNT"; then
947    save_LIBS="$LIBS"
948    AC_SEARCH_LIBS([dlsym], [dl],
949        [case "$ac_cv_search_dlsym" in -l*) DLOPEN_LIBS="$ac_cv_search_dlsym";; esac],
950        [AC_MSG_ERROR([dlsym not found in either libc nor libdl])])
951    LIBS="$save_LIBS"
952fi
953AC_SUBST(DLOPEN_LIBS)
954
955AC_ARG_ENABLE(ios-simulator,
956    AS_HELP_STRING([--enable-ios-simulator],
957        [build i386 or x86_64 for ios simulator])
958)
959
960AC_ARG_ENABLE(ios-libreofficelight-app,
961    AS_HELP_STRING([--enable-ios-libreofficelight-app],
962        [When building for iOS, build stuff relevant only for the 'LibreOfficeLight' app
963         (in ios/LibreOfficeLight). Note that this app is not known to work in any useful manner,
964         and also that its actual build (in Xcode) requires some obvious modifications to the project.])
965)
966
967ENABLE_IOS_LIBREOFFICELIGHT_APP=
968if test "$enable_ios_libreofficelight_app" = yes; then
969    ENABLE_IOS_LIBREOFFICELIGHT_APP=TRUE
970fi
971AC_SUBST(ENABLE_IOS_LIBREOFFICELIGHT_APP)
972
973###############################################################################
974# Extensions switches --enable/--disable
975###############################################################################
976# By default these should be enabled unless having extra dependencies.
977# If there is extra dependency over configure options then the enable should
978# be automagic based on whether the requiring feature is enabled or not.
979# All this options change anything only with --enable-extension-integration.
980
981# The name of this option and its help string makes it sound as if
982# extensions are built anyway, just not integrated in the installer,
983# if you use --disable-extension-integration. Is that really the
984# case?
985
986libo_FUZZ_ARG_ENABLE(extension-integration,
987    AS_HELP_STRING([--disable-extension-integration],
988        [Disable integration of the built extensions in the installer of the
989         product. Use this switch to disable the integration.])
990)
991
992AC_ARG_ENABLE(avmedia,
993    AS_HELP_STRING([--disable-avmedia],
994        [Disable displaying and inserting AV media in documents. Work in progress, use only if you are hacking on it.])
995)
996
997AC_ARG_ENABLE(database-connectivity,
998    AS_HELP_STRING([--disable-database-connectivity],
999        [Disable various database connectivity. Work in progress, use only if you are hacking on it.])
1000)
1001
1002# This doesn't mean not building (or "integrating") extensions
1003# (although it probably should; i.e. it should imply
1004# --disable-extension-integration I guess), it means not supporting
1005# any extension mechanism at all
1006libo_FUZZ_ARG_ENABLE(extensions,
1007    AS_HELP_STRING([--disable-extensions],
1008        [Disable all add-on extension functionality. Work in progress, use only if you are hacking on it.])
1009)
1010
1011AC_ARG_ENABLE(scripting,
1012    AS_HELP_STRING([--disable-scripting],
1013        [Disable BASIC, Java and Python. Work in progress, use only if you are hacking on it.])
1014)
1015
1016# This is mainly for Android and iOS, but could potentially be used in some
1017# special case otherwise, too, so factored out as a separate setting
1018
1019AC_ARG_ENABLE(dynamic-loading,
1020    AS_HELP_STRING([--disable-dynamic-loading],
1021        [Disable any use of dynamic loading of code. Work in progress, use only if you are hacking on it.])
1022)
1023
1024libo_FUZZ_ARG_ENABLE(report-builder,
1025    AS_HELP_STRING([--disable-report-builder],
1026        [Disable the Report Builder.])
1027)
1028
1029libo_FUZZ_ARG_ENABLE(ext-wiki-publisher,
1030    AS_HELP_STRING([--enable-ext-wiki-publisher],
1031        [Enable the Wiki Publisher extension.])
1032)
1033
1034libo_FUZZ_ARG_ENABLE(lpsolve,
1035    AS_HELP_STRING([--disable-lpsolve],
1036        [Disable compilation of the lp solve solver ])
1037)
1038libo_FUZZ_ARG_ENABLE(coinmp,
1039    AS_HELP_STRING([--disable-coinmp],
1040        [Disable compilation of the CoinMP solver ])
1041)
1042
1043libo_FUZZ_ARG_ENABLE(pdfimport,
1044    AS_HELP_STRING([--disable-pdfimport],
1045        [Disable building the PDF import feature.])
1046)
1047
1048libo_FUZZ_ARG_ENABLE(pdfium,
1049    AS_HELP_STRING([--disable-pdfium],
1050        [Disable building PDFium.])
1051)
1052
1053###############################################################################
1054
1055dnl ---------- *** ----------
1056
1057libo_FUZZ_ARG_ENABLE(mergelibs,
1058    AS_HELP_STRING([--enable-mergelibs],
1059        [Merge several of the smaller libraries into one big, "merged", one.])
1060)
1061
1062libo_FUZZ_ARG_ENABLE(breakpad,
1063    AS_HELP_STRING([--enable-breakpad],
1064        [Enables breakpad for crash reporting.])
1065)
1066
1067libo_FUZZ_ARG_ENABLE(crashdump,
1068    AS_HELP_STRING([--disable-crashdump],
1069        [Disable dump.ini and dump-file, when --enable-breakpad])
1070)
1071
1072AC_ARG_ENABLE(fetch-external,
1073    AS_HELP_STRING([--disable-fetch-external],
1074        [Disables fetching external tarballs from web sources.])
1075)
1076
1077AC_ARG_ENABLE(fuzzers,
1078    AS_HELP_STRING([--enable-fuzzers],
1079        [Enables building libfuzzer targets for fuzz testing.])
1080)
1081
1082libo_FUZZ_ARG_ENABLE(pch,
1083    AS_HELP_STRING([--enable-pch=<yes/no/system/base/normal/full>],
1084        [Enables precompiled header support for C++. Forced default on Windows/VC build.
1085         Using 'system' will include only external headers, 'base' will add also headers
1086         from base modules, 'normal' will also add all headers except from the module built,
1087         'full' will use all suitable headers even from a module itself.])
1088)
1089
1090libo_FUZZ_ARG_ENABLE(epm,
1091    AS_HELP_STRING([--enable-epm],
1092        [LibreOffice includes self-packaging code, that requires epm, however epm is
1093         useless for large scale package building.])
1094)
1095
1096libo_FUZZ_ARG_ENABLE(odk,
1097    AS_HELP_STRING([--disable-odk],
1098        [LibreOffice includes an ODK, office development kit which some packagers may
1099         wish to build without.])
1100)
1101
1102AC_ARG_ENABLE(mpl-subset,
1103    AS_HELP_STRING([--enable-mpl-subset],
1104        [Don't compile any pieces which are not MPL or more liberally licensed])
1105)
1106
1107libo_FUZZ_ARG_ENABLE(evolution2,
1108    AS_HELP_STRING([--enable-evolution2],
1109        [Allows the built-in evolution 2 addressbook connectivity build to be
1110         enabled.])
1111)
1112
1113AC_ARG_ENABLE(avahi,
1114    AS_HELP_STRING([--enable-avahi],
1115        [Determines whether to use Avahi to advertise Impress to remote controls.])
1116)
1117
1118libo_FUZZ_ARG_ENABLE(werror,
1119    AS_HELP_STRING([--enable-werror],
1120        [Turn warnings to errors. (Has no effect in modules where the treating
1121         of warnings as errors is disabled explicitly.)]),
1122,)
1123
1124libo_FUZZ_ARG_ENABLE(assert-always-abort,
1125    AS_HELP_STRING([--enable-assert-always-abort],
1126        [make assert() failures abort even when building without --enable-debug or --enable-dbgutil.]),
1127,)
1128
1129libo_FUZZ_ARG_ENABLE(dbgutil,
1130    AS_HELP_STRING([--enable-dbgutil],
1131        [Provide debugging support from --enable-debug and include additional debugging
1132         utilities such as object counting or more expensive checks.
1133         This is the recommended option for developers.
1134         Note that this makes the build ABI incompatible, it is not possible to mix object
1135         files or libraries from a --enable-dbgutil and a --disable-dbgutil build.]))
1136
1137libo_FUZZ_ARG_ENABLE(debug,
1138    AS_HELP_STRING([--enable-debug],
1139        [Include debugging information, disable compiler optimization and inlining plus
1140         extra debugging code like assertions. Extra large build! (enables -g compiler flag).]))
1141
1142libo_FUZZ_ARG_ENABLE(split-debug,
1143    AS_HELP_STRING([--disable-split-debug],
1144        [Disable using split debug information (-gsplit-dwarf compile flag). Split debug information
1145         saves disk space and build time, but requires tools that support it (both build tools and debuggers).]))
1146
1147libo_FUZZ_ARG_ENABLE(gdb-index,
1148    AS_HELP_STRING([--disable-gdb-index],
1149        [Disables creating debug information in the gdb index format, which makes gdb start faster.
1150         The feature requires the gold or lld linker.]))
1151
1152libo_FUZZ_ARG_ENABLE(sal-log,
1153    AS_HELP_STRING([--enable-sal-log],
1154        [Make SAL_INFO and SAL_WARN calls do something even in a non-debug build.]))
1155
1156libo_FUZZ_ARG_ENABLE(symbols,
1157    AS_HELP_STRING([--enable-symbols],
1158        [Generate debug information.
1159         By default, enabled for --enable-debug and --enable-dbgutil, disabled
1160         otherwise. It is possible to explicitly specify gbuild build targets
1161         (where 'all' means everything, '-' prepended means to not enable, '/' appended means
1162         everything in the directory; there is no ordering, more specific overrides
1163         more general, and disabling takes precedence).
1164         Example: --enable-symbols="all -sw/ -Library_sc".]))
1165
1166libo_FUZZ_ARG_ENABLE(optimized,
1167    AS_HELP_STRING([--disable-optimized],
1168        [Whether to compile with optimization flags.
1169         By default, disabled for --enable-debug and --enable-dbgutil, enabled
1170         otherwise.]))
1171
1172libo_FUZZ_ARG_ENABLE(runtime-optimizations,
1173    AS_HELP_STRING([--disable-runtime-optimizations],
1174        [Statically disable certain runtime optimizations (like rtl/alloc.h or
1175         JVM JIT) that are known to interact badly with certain dynamic analysis
1176         tools (like -fsanitize=address or Valgrind).  By default, disabled iff
1177         CC contains "-fsanitize=*".  (For Valgrind, those runtime optimizations
1178         are typically disabled dynamically via RUNNING_ON_VALGRIND.)]))
1179
1180AC_ARG_WITH(valgrind,
1181    AS_HELP_STRING([--with-valgrind],
1182        [Make availability of Valgrind headers a hard requirement.]))
1183
1184libo_FUZZ_ARG_ENABLE(compiler-plugins,
1185    AS_HELP_STRING([--enable-compiler-plugins],
1186        [Enable compiler plugins that will perform additional checks during
1187         building. Enabled automatically by --enable-dbgutil.
1188         Use --enable-compiler-plugins=debug to also enable debug code in the plugins.]))
1189COMPILER_PLUGINS_DEBUG=
1190if test "$enable_compiler_plugins" = debug; then
1191    enable_compiler_plugins=yes
1192    COMPILER_PLUGINS_DEBUG=TRUE
1193fi
1194
1195libo_FUZZ_ARG_ENABLE(ooenv,
1196    AS_HELP_STRING([--disable-ooenv],
1197        [Disable ooenv for the instdir installation.]))
1198
1199libo_FUZZ_ARG_ENABLE(libnumbertext,
1200    AS_HELP_STRING([--disable-libnumbertext],
1201        [Disable use of numbertext external library.]))
1202
1203AC_ARG_ENABLE(lto,
1204    AS_HELP_STRING([--enable-lto],
1205        [Enable link-time optimization. Suitable for (optimised) product builds. Building might take
1206         longer but libraries and executables are optimized for speed. For GCC, best to use the 'gold'
1207         linker. For MSVC, this option is broken at the moment. This is experimental work
1208         in progress that shouldn't be used unless you are working on it.)]))
1209
1210AC_ARG_ENABLE(python,
1211    AS_HELP_STRING([--enable-python=<no/auto/system/internal/fully-internal>],
1212        [Enables or disables Python support at run-time.
1213         Also specifies what Python to use. 'auto' is the default.
1214         'fully-internal' even forces the internal version for uses of Python
1215         during the build.]))
1216
1217libo_FUZZ_ARG_ENABLE(gtk3,
1218    AS_HELP_STRING([--disable-gtk3],
1219        [Determines whether to use Gtk+ 3.0 vclplug on platforms where Gtk+ 3.0 is available.]),
1220,test "${enable_gtk3+set}" = set || enable_gtk3=yes)
1221
1222AC_ARG_ENABLE(introspection,
1223    AS_HELP_STRING([--enable-introspection],
1224        [Generate files for GObject introspection.  Requires --enable-gtk3.  (Typically used by
1225         Linux distributions.)]))
1226
1227AC_ARG_ENABLE(split-app-modules,
1228    AS_HELP_STRING([--enable-split-app-modules],
1229        [Split file lists for app modules, e.g. base, calc.
1230         Has effect only with make distro-pack-install]),
1231,)
1232
1233AC_ARG_ENABLE(split-opt-features,
1234    AS_HELP_STRING([--enable-split-opt-features],
1235        [Split file lists for some optional features, e.g. pyuno, testtool.
1236         Has effect only with make distro-pack-install]),
1237,)
1238
1239libo_FUZZ_ARG_ENABLE(cairo-canvas,
1240    AS_HELP_STRING([--disable-cairo-canvas],
1241        [Determines whether to build the Cairo canvas on platforms where Cairo is available.]),
1242,)
1243
1244libo_FUZZ_ARG_ENABLE(dbus,
1245    AS_HELP_STRING([--disable-dbus],
1246        [Determines whether to enable features that depend on dbus.
1247         e.g. Presentation mode screensaver control, bluetooth presentation control, automatic font install]),
1248,test "${enable_dbus+set}" = set || enable_dbus=yes)
1249
1250libo_FUZZ_ARG_ENABLE(sdremote,
1251    AS_HELP_STRING([--disable-sdremote],
1252        [Determines whether to enable Impress remote control (i.e. the server component).]),
1253,test "${enable_sdremote+set}" = set || enable_sdremote=yes)
1254
1255libo_FUZZ_ARG_ENABLE(sdremote-bluetooth,
1256    AS_HELP_STRING([--disable-sdremote-bluetooth],
1257        [Determines whether to build sdremote with bluetooth support.
1258         Requires dbus on Linux.]))
1259
1260libo_FUZZ_ARG_ENABLE(gio,
1261    AS_HELP_STRING([--disable-gio],
1262        [Determines whether to use the GIO support.]),
1263,test "${enable_gio+set}" = set || enable_gio=yes)
1264
1265AC_ARG_ENABLE(qt5,
1266    AS_HELP_STRING([--enable-qt5],
1267        [Determines whether to use Qt5 vclplug on platforms where Qt5 is
1268         available.]),
1269,)
1270
1271AC_ARG_ENABLE(kf5,
1272    AS_HELP_STRING([--enable-kf5],
1273        [Determines whether to use Qt5/KF5 vclplug on platforms where Qt5 and
1274         KF5 are available.]),
1275,)
1276
1277AC_ARG_ENABLE(kde5,
1278    AS_HELP_STRING([--enable-kde5],
1279        [Compatibility switch for the kde5 => kf5 rename. Use --enable-kf5!])
1280,)
1281
1282AC_ARG_ENABLE(gtk3_kde5,
1283    AS_HELP_STRING([--enable-gtk3-kde5],
1284        [Determines whether to use Gtk3 vclplug with KF5 file dialogs on
1285         platforms where Gtk3, Qt5 and Plasma is available.]),
1286,)
1287
1288AC_ARG_ENABLE(gui,
1289    AS_HELP_STRING([--disable-gui],
1290        [Disable use of X11 or Wayland to reduce dependencies (e.g. for building LibreOfficeKit).]),
1291,enable_gui=yes)
1292
1293libo_FUZZ_ARG_ENABLE(randr,
1294    AS_HELP_STRING([--disable-randr],
1295        [Disable RandR support in the vcl project.]),
1296,test "${enable_randr+set}" = set || enable_randr=yes)
1297
1298libo_FUZZ_ARG_ENABLE(gstreamer-1-0,
1299    AS_HELP_STRING([--disable-gstreamer-1-0],
1300        [Disable building with the gstreamer 1.0 avmedia backend.]),
1301,test "${enable_gstreamer_1_0+set}" = set || enable_gstreamer_1_0=yes)
1302
1303libo_FUZZ_ARG_ENABLE(vlc,
1304    AS_HELP_STRING([--enable-vlc],
1305        [Enable building with the (experimental) VLC avmedia backend.]),
1306,test "${enable_vlc+set}" = set || enable_vlc=no)
1307
1308libo_FUZZ_ARG_ENABLE(neon,
1309    AS_HELP_STRING([--disable-neon],
1310        [Disable neon and the compilation of webdav binding.]),
1311,)
1312
1313libo_FUZZ_ARG_ENABLE([eot],
1314    [AS_HELP_STRING([--enable-eot],
1315        [Enable support for Embedded OpenType fonts.])],
1316,test "${enable_eot+set}" = set || enable_eot=no)
1317
1318libo_FUZZ_ARG_ENABLE(cve-tests,
1319    AS_HELP_STRING([--disable-cve-tests],
1320        [Prevent CVE tests to be executed]),
1321,)
1322
1323libo_FUZZ_ARG_ENABLE(chart-tests,
1324    AS_HELP_STRING([--enable-chart-tests],
1325        [Executes chart XShape tests. In a perfect world these tests would be
1326         stable and everyone could run them, in reality it is best to run them
1327         only on a few machines that are known to work and maintained by people
1328         who can judge if a test failure is a regression or not.]),
1329,)
1330
1331AC_ARG_ENABLE(build-unowinreg,
1332    AS_HELP_STRING([--enable-build-unowinreg],
1333        [Do not use the prebuilt unowinreg.dll. Build it instead. The MinGW C++
1334         compiler is needed on Linux.]),
1335,)
1336
1337AC_ARG_ENABLE(build-opensymbol,
1338    AS_HELP_STRING([--enable-build-opensymbol],
1339        [Do not use the prebuilt opens___.ttf. Build it instead. This needs
1340         fontforge installed.]),
1341,)
1342
1343AC_ARG_ENABLE(dependency-tracking,
1344    AS_HELP_STRING([--enable-dependency-tracking],
1345        [Do not reject slow dependency extractors.])[
1346  --disable-dependency-tracking
1347                          Disables generation of dependency information.
1348                          Speed up one-time builds.],
1349,)
1350
1351AC_ARG_ENABLE(icecream,
1352    AS_HELP_STRING([--enable-icecream],
1353        [Use the 'icecream' distributed compiling tool to speedup the compilation.
1354         It defaults to /opt/icecream for the location of the icecream gcc/g++
1355         wrappers, you can override that using --with-gcc-home=/the/path switch.]),
1356,)
1357
1358AC_ARG_ENABLE(ld,
1359    AS_HELP_STRING([--enable-ld=<linker>],
1360        [Use the specified linker. Both 'gold' and 'lld' linkers generally use less memory and link faster.
1361         By default tries to use the best linker possible, use --disable-ld to use the default linker.]),
1362,)
1363
1364libo_FUZZ_ARG_ENABLE(cups,
1365    AS_HELP_STRING([--disable-cups],
1366        [Do not build cups support.])
1367)
1368
1369AC_ARG_ENABLE(ccache,
1370    AS_HELP_STRING([--disable-ccache],
1371        [Do not try to use ccache automatically.
1372         By default, unless on Windows, we will try to detect if ccache is available; in that case if
1373         CC/CXX are not yet set, and --enable-icecream is not given, we
1374         attempt to use ccache. --disable-ccache disables ccache completely.
1375         Additionally ccache's depend mode is enabled if possible,
1376         use --enable-ccache=nodepend to enable ccache without depend mode.
1377]),
1378,)
1379
1380AC_ARG_ENABLE(64-bit,
1381    AS_HELP_STRING([--enable-64-bit],
1382        [Build a 64-bit LibreOffice on platforms where the normal build is 32-bit.
1383         At the moment meaningful only for Windows.]), ,)
1384
1385libo_FUZZ_ARG_ENABLE(online-update,
1386    AS_HELP_STRING([--enable-online-update],
1387        [Enable the online update service that will check for new versions of
1388         LibreOffice. By default, it is enabled on Windows and Mac, disabled on Linux.
1389         If the value is "mar", the experimental Mozilla-like update will be
1390         enabled instead of the traditional update mechanism.]),
1391,)
1392
1393AC_ARG_WITH(update-config,
1394    AS_HELP_STRING([--with-update-config=/tmp/update.ini],
1395                   [Path to the update config ini file]))
1396
1397libo_FUZZ_ARG_ENABLE(extension-update,
1398    AS_HELP_STRING([--disable-extension-update],
1399        [Disable possibility to update installed extensions.]),
1400,)
1401
1402libo_FUZZ_ARG_ENABLE(release-build,
1403    AS_HELP_STRING([--enable-release-build],
1404        [Enable release build. Note that the "release build" choice is orthogonal to
1405         whether symbols are present, debug info is generated, or optimization
1406         is done.
1407         See http://wiki.documentfoundation.org/Development/DevBuild]),
1408,)
1409
1410AC_ARG_ENABLE(windows-build-signing,
1411    AS_HELP_STRING([--enable-windows-build-signing],
1412        [Enable signing of windows binaries (*.exe, *.dll)]),
1413,)
1414
1415AC_ARG_ENABLE(silent-msi,
1416    AS_HELP_STRING([--enable-silent-msi],
1417        [Enable MSI with LIMITUI=1 (silent install).]),
1418,)
1419
1420AC_ARG_ENABLE(macosx-code-signing,
1421    AS_HELP_STRING([--enable-macosx-code-signing=<identity>],
1422        [Sign executables, dylibs, frameworks and the app bundle. If you
1423         don't provide an identity the first suitable certificate
1424         in your keychain is used.]),
1425,)
1426
1427AC_ARG_ENABLE(macosx-package-signing,
1428    AS_HELP_STRING([--enable-macosx-package-signing=<identity>],
1429        [Create a .pkg suitable for uploading to the Mac App Store and sign
1430         it. If you don't provide an identity the first suitable certificate
1431         in your keychain is used.]),
1432,)
1433
1434AC_ARG_ENABLE(macosx-sandbox,
1435    AS_HELP_STRING([--enable-macosx-sandbox],
1436        [Make the app bundle run in a sandbox. Requires code signing.
1437         Is required by apps distributed in the Mac App Store, and implies
1438         adherence to App Store rules.]),
1439,)
1440
1441AC_ARG_WITH(macosx-bundle-identifier,
1442    AS_HELP_STRING([--with-macosx-bundle-identifier=tld.mumble.orifice.TheOffice],
1443        [Define the macOS bundle identifier. Default is the somewhat weird
1444         org.libreoffice.script ("script", huh?).]),
1445,with_macosx_bundle_identifier=org.libreoffice.script)
1446
1447AC_ARG_WITH(product-name,
1448    AS_HELP_STRING([--with-product-name='My Own Office Suite'],
1449        [Define the product name. Default is AC_PACKAGE_NAME.]),
1450,with_product_name=$PRODUCTNAME)
1451
1452AC_ARG_WITH(package-version,
1453    AS_HELP_STRING([--with-package-version='3.1.4.5'],
1454        [Define the package version. Default is AC_PACKAGE_VERSION. Use only if you distribute an own build for macOS.]),
1455,)
1456
1457libo_FUZZ_ARG_ENABLE(readonly-installset,
1458    AS_HELP_STRING([--enable-readonly-installset],
1459        [Prevents any attempts by LibreOffice to write into its installation. That means
1460         at least that no "system-wide" extensions can be added. Partly experimental work in
1461         progress, probably not fully implemented (but is useful for sandboxed macOS builds).]),
1462,)
1463
1464libo_FUZZ_ARG_ENABLE(postgresql-sdbc,
1465    AS_HELP_STRING([--disable-postgresql-sdbc],
1466        [Disable the build of the PostgreSQL-SDBC driver.])
1467)
1468
1469libo_FUZZ_ARG_ENABLE(lotuswordpro,
1470    AS_HELP_STRING([--disable-lotuswordpro],
1471        [Disable the build of the Lotus Word Pro filter.]),
1472,test "${enable_lotuswordpro+set}" = set || enable_lotuswordpro=yes)
1473
1474libo_FUZZ_ARG_ENABLE(firebird-sdbc,
1475    AS_HELP_STRING([--disable-firebird-sdbc],
1476        [Disable the build of the Firebird-SDBC driver if it doesn't compile for you.]),
1477,test "${enable_firebird_sdbc+set}" = set || enable_firebird_sdbc=yes)
1478
1479AC_ARG_ENABLE(bogus-pkg-config,
1480    AS_HELP_STRING([--enable-bogus-pkg-config],
1481        [MACOSX only: on MacOSX pkg-config can cause trouble. by default if one is found in the PATH, an error is issued. This flag turn that error into a warning.]),
1482)
1483
1484AC_ARG_ENABLE(openssl,
1485    AS_HELP_STRING([--disable-openssl],
1486        [Disable using libssl/libcrypto from OpenSSL. If disabled,
1487         components will either use GNUTLS or NSS. Work in progress,
1488         use only if you are hacking on it.]),
1489,enable_openssl=yes)
1490
1491libo_FUZZ_ARG_ENABLE(cipher-openssl-backend,
1492    AS_HELP_STRING([--enable-cipher-openssl-backend],
1493        [Enable using OpenSSL as the actual implementation of the rtl/cipher.h functionality.
1494         Requires --enable-openssl.]))
1495
1496AC_ARG_ENABLE(library-bin-tar,
1497    AS_HELP_STRING([--enable-library-bin-tar],
1498        [Enable the building and reused of tarball of binary build for some 'external' libraries.
1499        Some libraries can save their build result in a tarball
1500        stored in TARFILE_LOCATION. That binary tarball is
1501        uniquely identified by the source tarball,
1502        the content of the config_host.mk file and the content
1503        of the top-level directory in core for that library
1504        If this option is enabled, then if such a tarfile exist, it will be untarred
1505        instead of the source tarfile, and the build step will be skipped for that
1506        library.
1507        If a proper tarfile does not exist, then the normal source-based
1508        build is done for that library and a proper binary tarfile is created
1509        for the next time.]),
1510)
1511
1512AC_ARG_ENABLE(dconf,
1513    AS_HELP_STRING([--disable-dconf],
1514        [Disable the dconf configuration backend (enabled by default where
1515         available).]))
1516
1517libo_FUZZ_ARG_ENABLE(formula-logger,
1518    AS_HELP_STRING(
1519        [--enable-formula-logger],
1520        [Enable formula logger for logging formula calculation flow in Calc.]
1521    )
1522)
1523
1524AC_ARG_ENABLE(ldap,
1525    AS_HELP_STRING([--disable-ldap],
1526        [Disable LDAP support.]),
1527,enable_ldap=yes)
1528
1529dnl ===================================================================
1530dnl Optional Packages (--with/without-)
1531dnl ===================================================================
1532
1533AC_ARG_WITH(gcc-home,
1534    AS_HELP_STRING([--with-gcc-home],
1535        [Specify the location of gcc/g++ manually. This can be used in conjunction
1536         with --enable-icecream when icecream gcc/g++ wrappers are installed in a
1537         non-default path.]),
1538,)
1539
1540AC_ARG_WITH(gnu-patch,
1541    AS_HELP_STRING([--with-gnu-patch],
1542        [Specify location of GNU patch on Solaris or FreeBSD.]),
1543,)
1544
1545AC_ARG_WITH(build-platform-configure-options,
1546    AS_HELP_STRING([--with-build-platform-configure-options],
1547        [Specify options for the configure script run for the *build* platform in a cross-compilation]),
1548,)
1549
1550AC_ARG_WITH(gnu-cp,
1551    AS_HELP_STRING([--with-gnu-cp],
1552        [Specify location of GNU cp on Solaris or FreeBSD.]),
1553,)
1554
1555AC_ARG_WITH(external-tar,
1556    AS_HELP_STRING([--with-external-tar=<TARFILE_PATH>],
1557        [Specify an absolute path of where to find (and store) tarfiles.]),
1558    TARFILE_LOCATION=$withval ,
1559)
1560
1561AC_ARG_WITH(referenced-git,
1562    AS_HELP_STRING([--with-referenced-git=<OTHER_CHECKOUT_DIR>],
1563        [Specify another checkout directory to reference. This makes use of
1564                 git submodule update --reference, and saves a lot of diskspace
1565                 when having multiple trees side-by-side.]),
1566    GIT_REFERENCE_SRC=$withval ,
1567)
1568
1569AC_ARG_WITH(linked-git,
1570    AS_HELP_STRING([--with-linked-git=<submodules repo basedir>],
1571        [Specify a directory where the repositories of submodules are located.
1572         This uses a method similar to git-new-workdir to get submodules.]),
1573    GIT_LINK_SRC=$withval ,
1574)
1575
1576AC_ARG_WITH(galleries,
1577    AS_HELP_STRING([--with-galleries],
1578        [Specify how galleries should be built. It is possible either to
1579         build these internally from source ("build"),
1580         or to disable them ("no")]),
1581)
1582
1583AC_ARG_WITH(theme,
1584    AS_HELP_STRING([--with-theme="theme1 theme2..."],
1585        [Choose which themes to include. By default those themes with an '*' are included.
1586         Possible choices: *breeze, *breeze_dark, *breeze_dark_svg, *breeze_svg, *colibre, *colibre_svg, *elementary,
1587         *elementary_svg, *karasa_jaga, *karasa_jaga_svg, *sifr, *sifr_dark, *sifr_dark_svg, *sifr_svg, *tango.]),
1588,)
1589
1590libo_FUZZ_ARG_WITH(helppack-integration,
1591    AS_HELP_STRING([--without-helppack-integration],
1592        [It will not integrate the helppacks to the installer
1593         of the product. Please use this switch to use the online help
1594         or separate help packages.]),
1595,)
1596
1597libo_FUZZ_ARG_WITH(fonts,
1598    AS_HELP_STRING([--without-fonts],
1599        [LibreOffice includes some third-party fonts to provide a reliable basis for
1600         help content, templates, samples, etc. When these fonts are already
1601         known to be available on the system then you should use this option.]),
1602,)
1603
1604AC_ARG_WITH(epm,
1605    AS_HELP_STRING([--with-epm],
1606        [Decides which epm to use. Default is to use the one from the system if
1607         one is built. When either this is not there or you say =internal epm
1608         will be built.]),
1609,)
1610
1611AC_ARG_WITH(package-format,
1612    AS_HELP_STRING([--with-package-format],
1613        [Specify package format(s) for LibreOffice installation sets. The
1614         implicit --without-package-format leads to no installation sets being
1615         generated. Possible values: aix, archive, bsd, deb, dmg,
1616         installed, msi, pkg, and rpm.
1617         Example: --with-package-format='deb rpm']),
1618,)
1619
1620AC_ARG_WITH(tls,
1621    AS_HELP_STRING([--with-tls],
1622        [Decides which TLS/SSL and cryptographic implementations to use for
1623         LibreOffice's code. Notice that this doesn't apply for depending
1624         libraries like "neon", for example. Default is to use OpenSSL
1625         although NSS is also possible. Notice that selecting NSS restricts
1626         the usage of OpenSSL in LO's code but selecting OpenSSL doesn't
1627         restrict by now the usage of NSS in LO's code. Possible values:
1628         openssl, nss. Example: --with-tls="nss"]),
1629,)
1630
1631AC_ARG_WITH(system-libs,
1632    AS_HELP_STRING([--with-system-libs],
1633        [Use libraries already on system -- enables all --with-system-* flags.]),
1634,)
1635
1636AC_ARG_WITH(system-bzip2,
1637    AS_HELP_STRING([--with-system-bzip2],
1638        [Use bzip2 already on system. Used only when --enable-online-update=mar]),,
1639    [with_system_bzip2="$with_system_libs"])
1640
1641AC_ARG_WITH(system-headers,
1642    AS_HELP_STRING([--with-system-headers],
1643        [Use headers already on system -- enables all --with-system-* flags for
1644         external packages whose headers are the only entities used i.e.
1645         boost/odbc/sane-header(s).]),,
1646    [with_system_headers="$with_system_libs"])
1647
1648AC_ARG_WITH(system-jars,
1649    AS_HELP_STRING([--without-system-jars],
1650        [When building with --with-system-libs, also the needed jars are expected
1651         on the system. Use this to disable that]),,
1652    [with_system_jars="$with_system_libs"])
1653
1654AC_ARG_WITH(system-cairo,
1655    AS_HELP_STRING([--with-system-cairo],
1656        [Use cairo libraries already on system.  Happens automatically for
1657         (implicit) --enable-gtk3.]))
1658
1659AC_ARG_WITH(system-epoxy,
1660    AS_HELP_STRING([--with-system-epoxy],
1661        [Use epoxy libraries already on system.  Happens automatically for
1662         (implicit) --enable-gtk3.]),,
1663       [with_system_epoxy="$with_system_libs"])
1664
1665AC_ARG_WITH(myspell-dicts,
1666    AS_HELP_STRING([--with-myspell-dicts],
1667        [Adds myspell dictionaries to the LibreOffice installation set]),
1668,)
1669
1670AC_ARG_WITH(system-dicts,
1671    AS_HELP_STRING([--without-system-dicts],
1672        [Do not use dictionaries from system paths.]),
1673,)
1674
1675AC_ARG_WITH(external-dict-dir,
1676    AS_HELP_STRING([--with-external-dict-dir],
1677        [Specify external dictionary dir.]),
1678,)
1679
1680AC_ARG_WITH(external-hyph-dir,
1681    AS_HELP_STRING([--with-external-hyph-dir],
1682        [Specify external hyphenation pattern dir.]),
1683,)
1684
1685AC_ARG_WITH(external-thes-dir,
1686    AS_HELP_STRING([--with-external-thes-dir],
1687        [Specify external thesaurus dir.]),
1688,)
1689
1690AC_ARG_WITH(system-zlib,
1691    AS_HELP_STRING([--with-system-zlib],
1692        [Use zlib already on system.]),,
1693    [with_system_zlib=auto])
1694
1695AC_ARG_WITH(system-jpeg,
1696    AS_HELP_STRING([--with-system-jpeg],
1697        [Use jpeg already on system.]),,
1698    [with_system_jpeg="$with_system_libs"])
1699
1700AC_ARG_WITH(system-clucene,
1701    AS_HELP_STRING([--with-system-clucene],
1702        [Use clucene already on system.]),,
1703    [with_system_clucene="$with_system_libs"])
1704
1705AC_ARG_WITH(system-expat,
1706    AS_HELP_STRING([--with-system-expat],
1707        [Use expat already on system.]),,
1708    [with_system_expat="$with_system_libs"])
1709
1710AC_ARG_WITH(system-libxml,
1711    AS_HELP_STRING([--with-system-libxml],
1712        [Use libxml/libxslt already on system.]),,
1713    [with_system_libxml=auto])
1714
1715AC_ARG_WITH(system-icu,
1716    AS_HELP_STRING([--with-system-icu],
1717        [Use icu already on system.]),,
1718    [with_system_icu="$with_system_libs"])
1719
1720AC_ARG_WITH(system-ucpp,
1721    AS_HELP_STRING([--with-system-ucpp],
1722        [Use ucpp already on system.]),,
1723    [])
1724
1725AC_ARG_WITH(system-openldap,
1726    AS_HELP_STRING([--with-system-openldap],
1727        [Use the OpenLDAP LDAP SDK already on system.]),,
1728    [with_system_openldap="$with_system_libs"])
1729
1730libo_FUZZ_ARG_ENABLE(poppler,
1731    AS_HELP_STRING([--disable-poppler],
1732        [Disable building Poppler.])
1733)
1734
1735AC_ARG_WITH(system-poppler,
1736    AS_HELP_STRING([--with-system-poppler],
1737        [Use system poppler (only needed for PDF import).]),,
1738    [with_system_poppler="$with_system_libs"])
1739
1740AC_ARG_WITH(system-gpgmepp,
1741    AS_HELP_STRING([--with-system-gpgmepp],
1742        [Use gpgmepp already on system]),,
1743    [with_system_gpgmepp="$with_system_libs"])
1744
1745AC_ARG_WITH(system-apache-commons,
1746    AS_HELP_STRING([--with-system-apache-commons],
1747        [Use Apache commons libraries already on system.]),,
1748    [with_system_apache_commons="$with_system_jars"])
1749
1750AC_ARG_WITH(system-mariadb,
1751    AS_HELP_STRING([--with-system-mariadb],
1752        [Use MariaDB/MySQL libraries already on system.]),,
1753    [with_system_mariadb="$with_system_libs"])
1754
1755AC_ARG_ENABLE(bundle-mariadb,
1756    AS_HELP_STRING([--enable-bundle-mariadb],
1757        [When using MariaDB/MySQL libraries already on system, bundle them with the MariaDB Connector/LibreOffice.])
1758)
1759
1760AC_ARG_WITH(system-postgresql,
1761    AS_HELP_STRING([--with-system-postgresql],
1762        [Use PostgreSQL libraries already on system, for building the PostgreSQL-SDBC
1763         driver. If pg_config is not in PATH, use PGCONFIG to point to it.]),,
1764    [with_system_postgresql="$with_system_libs"])
1765
1766AC_ARG_WITH(libpq-path,
1767    AS_HELP_STRING([--with-libpq-path=<absolute path to your libpq installation>],
1768        [Use this PostgreSQL C interface (libpq) installation for building
1769         the PostgreSQL-SDBC extension.]),
1770,)
1771
1772AC_ARG_WITH(system-firebird,
1773    AS_HELP_STRING([--with-system-firebird],
1774        [Use Firebird libraries already on system, for building the Firebird-SDBC
1775         driver. If fb_config is not in PATH, use FBCONFIG to point to it.]),,
1776    [with_system_firebird="$with_system_libs"])
1777
1778AC_ARG_WITH(system-libtommath,
1779            AS_HELP_STRING([--with-system-libtommath],
1780                           [Use libtommath already on system]),,
1781            [with_system_libtommath="$with_system_libs"])
1782
1783AC_ARG_WITH(system-hsqldb,
1784    AS_HELP_STRING([--with-system-hsqldb],
1785        [Use hsqldb already on system.]))
1786
1787AC_ARG_WITH(hsqldb-jar,
1788    AS_HELP_STRING([--with-hsqldb-jar=JARFILE],
1789        [Specify path to jarfile manually.]),
1790    HSQLDB_JAR=$withval)
1791
1792libo_FUZZ_ARG_ENABLE(scripting-beanshell,
1793    AS_HELP_STRING([--disable-scripting-beanshell],
1794        [Disable support for scripts in BeanShell.]),
1795,
1796)
1797
1798AC_ARG_WITH(system-beanshell,
1799    AS_HELP_STRING([--with-system-beanshell],
1800        [Use beanshell already on system.]),,
1801    [with_system_beanshell="$with_system_jars"])
1802
1803AC_ARG_WITH(beanshell-jar,
1804    AS_HELP_STRING([--with-beanshell-jar=JARFILE],
1805        [Specify path to jarfile manually.]),
1806    BSH_JAR=$withval)
1807
1808libo_FUZZ_ARG_ENABLE(scripting-javascript,
1809    AS_HELP_STRING([--disable-scripting-javascript],
1810        [Disable support for scripts in JavaScript.]),
1811,
1812)
1813
1814AC_ARG_WITH(system-rhino,
1815    AS_HELP_STRING([--with-system-rhino],
1816        [Use rhino already on system.]),,)
1817#    [with_system_rhino="$with_system_jars"])
1818# Above is not used as we have different debug interface
1819# patched into internal rhino. This code needs to be fixed
1820# before we can enable it by default.
1821
1822AC_ARG_WITH(rhino-jar,
1823    AS_HELP_STRING([--with-rhino-jar=JARFILE],
1824        [Specify path to jarfile manually.]),
1825    RHINO_JAR=$withval)
1826
1827AC_ARG_WITH(commons-logging-jar,
1828    AS_HELP_STRING([--with-commons-logging-jar=JARFILE],
1829        [Specify path to jarfile manually.]),
1830    COMMONS_LOGGING_JAR=$withval)
1831
1832AC_ARG_WITH(system-jfreereport,
1833    AS_HELP_STRING([--with-system-jfreereport],
1834        [Use JFreeReport already on system.]),,
1835    [with_system_jfreereport="$with_system_jars"])
1836
1837AC_ARG_WITH(sac-jar,
1838    AS_HELP_STRING([--with-sac-jar=JARFILE],
1839        [Specify path to jarfile manually.]),
1840    SAC_JAR=$withval)
1841
1842AC_ARG_WITH(libxml-jar,
1843    AS_HELP_STRING([--with-libxml-jar=JARFILE],
1844        [Specify path to jarfile manually.]),
1845    LIBXML_JAR=$withval)
1846
1847AC_ARG_WITH(flute-jar,
1848    AS_HELP_STRING([--with-flute-jar=JARFILE],
1849        [Specify path to jarfile manually.]),
1850    FLUTE_JAR=$withval)
1851
1852AC_ARG_WITH(jfreereport-jar,
1853    AS_HELP_STRING([--with-jfreereport-jar=JARFILE],
1854        [Specify path to jarfile manually.]),
1855    JFREEREPORT_JAR=$withval)
1856
1857AC_ARG_WITH(liblayout-jar,
1858    AS_HELP_STRING([--with-liblayout-jar=JARFILE],
1859        [Specify path to jarfile manually.]),
1860    LIBLAYOUT_JAR=$withval)
1861
1862AC_ARG_WITH(libloader-jar,
1863    AS_HELP_STRING([--with-libloader-jar=JARFILE],
1864        [Specify path to jarfile manually.]),
1865    LIBLOADER_JAR=$withval)
1866
1867AC_ARG_WITH(libformula-jar,
1868    AS_HELP_STRING([--with-libformula-jar=JARFILE],
1869        [Specify path to jarfile manually.]),
1870    LIBFORMULA_JAR=$withval)
1871
1872AC_ARG_WITH(librepository-jar,
1873    AS_HELP_STRING([--with-librepository-jar=JARFILE],
1874        [Specify path to jarfile manually.]),
1875    LIBREPOSITORY_JAR=$withval)
1876
1877AC_ARG_WITH(libfonts-jar,
1878    AS_HELP_STRING([--with-libfonts-jar=JARFILE],
1879        [Specify path to jarfile manually.]),
1880    LIBFONTS_JAR=$withval)
1881
1882AC_ARG_WITH(libserializer-jar,
1883    AS_HELP_STRING([--with-libserializer-jar=JARFILE],
1884        [Specify path to jarfile manually.]),
1885    LIBSERIALIZER_JAR=$withval)
1886
1887AC_ARG_WITH(libbase-jar,
1888    AS_HELP_STRING([--with-libbase-jar=JARFILE],
1889        [Specify path to jarfile manually.]),
1890    LIBBASE_JAR=$withval)
1891
1892AC_ARG_WITH(system-odbc,
1893    AS_HELP_STRING([--with-system-odbc],
1894        [Use the odbc headers already on system.]),,
1895    [with_system_odbc="auto"])
1896
1897AC_ARG_WITH(system-sane,
1898    AS_HELP_STRING([--with-system-sane],
1899        [Use sane.h already on system.]),,
1900    [with_system_sane="$with_system_headers"])
1901
1902AC_ARG_WITH(system-bluez,
1903    AS_HELP_STRING([--with-system-bluez],
1904        [Use bluetooth.h already on system.]),,
1905    [with_system_bluez="$with_system_headers"])
1906
1907AC_ARG_WITH(system-curl,
1908    AS_HELP_STRING([--with-system-curl],
1909        [Use curl already on system.]),,
1910    [with_system_curl=auto])
1911
1912AC_ARG_WITH(system-boost,
1913    AS_HELP_STRING([--with-system-boost],
1914        [Use boost already on system.]),,
1915    [with_system_boost="$with_system_headers"])
1916
1917AC_ARG_WITH(system-glm,
1918    AS_HELP_STRING([--with-system-glm],
1919        [Use glm already on system.]),,
1920    [with_system_glm="$with_system_headers"])
1921
1922AC_ARG_WITH(system-hunspell,
1923    AS_HELP_STRING([--with-system-hunspell],
1924        [Use libhunspell already on system.]),,
1925    [with_system_hunspell="$with_system_libs"])
1926
1927libo_FUZZ_ARG_ENABLE(qrcodegen,
1928    AS_HELP_STRING([--disable-qrcodegen],
1929        [Disable use of qrcodegen external library.]))
1930
1931AC_ARG_WITH(system-qrcodegen,
1932    AS_HELP_STRING([--with-system-qrcodegen],
1933        [Use libqrcodegen already on system.]),,
1934    [with_system_qrcodegen="$with_system_libs"])
1935
1936AC_ARG_WITH(system-mythes,
1937    AS_HELP_STRING([--with-system-mythes],
1938        [Use mythes already on system.]),,
1939    [with_system_mythes="$with_system_libs"])
1940
1941AC_ARG_WITH(system-altlinuxhyph,
1942    AS_HELP_STRING([--with-system-altlinuxhyph],
1943        [Use ALTLinuxhyph already on system.]),,
1944    [with_system_altlinuxhyph="$with_system_libs"])
1945
1946AC_ARG_WITH(system-lpsolve,
1947    AS_HELP_STRING([--with-system-lpsolve],
1948        [Use lpsolve already on system.]),,
1949    [with_system_lpsolve="$with_system_libs"])
1950
1951AC_ARG_WITH(system-coinmp,
1952    AS_HELP_STRING([--with-system-coinmp],
1953        [Use CoinMP already on system.]),,
1954    [with_system_coinmp="$with_system_libs"])
1955
1956AC_ARG_WITH(system-liblangtag,
1957    AS_HELP_STRING([--with-system-liblangtag],
1958        [Use liblangtag library already on system.]),,
1959    [with_system_liblangtag="$with_system_libs"])
1960
1961AC_ARG_WITH(webdav,
1962    AS_HELP_STRING([--with-webdav],
1963        [Specify which library to use for webdav implementation.
1964         Possible values: "neon", "serf", "no". The default value is "neon".
1965         Example: --with-webdav="serf"]),
1966    WITH_WEBDAV=$withval,
1967    WITH_WEBDAV="neon")
1968
1969AC_ARG_WITH(linker-hash-style,
1970    AS_HELP_STRING([--with-linker-hash-style],
1971        [Use linker with --hash-style=<style> when linking shared objects.
1972         Possible values: "sysv", "gnu", "both". The default value is "gnu"
1973         if supported on the build system, and "sysv" otherwise.]))
1974
1975AC_ARG_WITH(jdk-home,
1976    AS_HELP_STRING([--with-jdk-home=<absolute path to JDK home>],
1977        [If you have installed JDK 8 or later on your system please supply the
1978         path here. Note that this is not the location of the java command but the
1979         location of the entire distribution.]),
1980,)
1981
1982AC_ARG_WITH(help,
1983    AS_HELP_STRING([--with-help],
1984        [Enable the build of help. There is a special parameter "common" that
1985         can be used to bundle only the common part, .e.g help-specific icons.
1986         This is useful when you build the helpcontent separately.])
1987    [
1988                          Usage:     --with-help    build the old local help
1989                                 --without-help     no local help (default)
1990                                 --with-help=html   build the new HTML local help
1991                                 --with-help=online build the new HTML online help
1992    ],
1993,)
1994
1995AC_ARG_WITH(omindex,
1996   AS_HELP_STRING([--with-omindex],
1997	[Enable the support of xapian-omega index for online help.])
1998   [
1999                         Usage: --with-omindex=server prepare the pages for omindex
2000				but let xapian-omega be built in server.
2001				--with-omindex=noxap do not prepare online pages
2002                                for xapian-omega
2003  ],
2004,)
2005
2006libo_FUZZ_ARG_WITH(java,
2007    AS_HELP_STRING([--with-java=<java command>],
2008        [Specify the name of the Java interpreter command. Typically "java"
2009         which is the default.
2010
2011         To build without support for Java components, applets, accessibility
2012         or the XML filters written in Java, use --without-java or --with-java=no.]),
2013    [ test -z "$with_java" -o "$with_java" = "yes" && with_java=java ],
2014    [ test -z "$with_java" -o "$with_java" = "yes" && with_java=java ]
2015)
2016
2017AC_ARG_WITH(jvm-path,
2018    AS_HELP_STRING([--with-jvm-path=<absolute path to parent of jvm home>],
2019        [Use a specific JVM search path at runtime.
2020         e.g. use --with-jvm-path=/usr/lib/ to find JRE/JDK in /usr/lib/jvm/]),
2021,)
2022
2023AC_ARG_WITH(ant-home,
2024    AS_HELP_STRING([--with-ant-home=<absolute path to Ant home>],
2025        [If you have installed Apache Ant on your system, please supply the path here.
2026         Note that this is not the location of the Ant binary but the location
2027         of the entire distribution.]),
2028,)
2029
2030AC_ARG_WITH(symbol-config,
2031    AS_HELP_STRING([--with-symbol-config],
2032        [Configuration for the crashreport symbol upload]),
2033        [],
2034        [with_symbol_config=no])
2035
2036AC_ARG_WITH(export-validation,
2037    AS_HELP_STRING([--without-export-validation],
2038        [Disable validating OOXML and ODF files as exported from in-tree tests.]),
2039,with_export_validation=auto)
2040
2041AC_ARG_WITH(bffvalidator,
2042    AS_HELP_STRING([--with-bffvalidator=<absolute path to BFFValidator>],
2043        [Enables export validation for Microsoft Binary formats (doc, xls, ppt).
2044         Requires installed Microsoft Office Binary File Format Validator.
2045         Note: export-validation (--with-export-validation) is required to be turned on.
2046         See https://www.microsoft.com/en-us/download/details.aspx?id=26794]),
2047,with_bffvalidator=no)
2048
2049libo_FUZZ_ARG_WITH(junit,
2050    AS_HELP_STRING([--with-junit=<absolute path to JUnit 4 jar>],
2051        [Specifies the JUnit 4 jar file to use for JUnit-based tests.
2052         --without-junit disables those tests. Not relevant in the --without-java case.]),
2053,with_junit=yes)
2054
2055AC_ARG_WITH(hamcrest,
2056    AS_HELP_STRING([--with-hamcrest=<absolute path to hamcrest jar>],
2057        [Specifies the hamcrest jar file to use for JUnit-based tests.
2058         --without-junit disables those tests. Not relevant in the --without-java case.]),
2059,with_hamcrest=yes)
2060
2061AC_ARG_WITH(perl-home,
2062    AS_HELP_STRING([--with-perl-home=<abs. path to Perl 5 home>],
2063        [If you have installed Perl 5 Distribution, on your system, please
2064         supply the path here. Note that this is not the location of the Perl
2065         binary but the location of the entire distribution.]),
2066,)
2067
2068libo_FUZZ_ARG_WITH(doxygen,
2069    AS_HELP_STRING(
2070        [--with-doxygen=<absolute path to doxygen executable>],
2071        [Specifies the doxygen executable to use when generating ODK C/C++
2072         documentation. --without-doxygen disables generation of ODK C/C++
2073         documentation. Not relevant in the --disable-odk case.]),
2074,with_doxygen=yes)
2075
2076AC_ARG_WITH(visual-studio,
2077    AS_HELP_STRING([--with-visual-studio=<2017>],
2078        [Specify which Visual Studio version to use in case several are
2079         installed. Currently only 2017 is supported.]),
2080,)
2081
2082AC_ARG_WITH(windows-sdk,
2083    AS_HELP_STRING([--with-windows-sdk=<8.0(A)/8.1(A)/10>],
2084        [Specify which Windows SDK, or "Windows Kit", version to use
2085         in case the one that came with the selected Visual Studio
2086         is not what you want for some reason. Note that not all compiler/SDK
2087         combinations are supported. The intent is that this option should not
2088         be needed.]),
2089,)
2090
2091AC_ARG_WITH(lang,
2092    AS_HELP_STRING([--with-lang="es sw tu cs sk"],
2093        [Use this option to build LibreOffice with additional UI language support.
2094         English (US) is always included by default.
2095         Separate multiple languages with space.
2096         For all languages, use --with-lang=ALL.]),
2097,)
2098
2099AC_ARG_WITH(locales,
2100    AS_HELP_STRING([--with-locales="en es pt fr zh kr ja"],
2101        [Use this option to limit the locale information built in.
2102         Separate multiple locales with space.
2103         Very experimental and might well break stuff.
2104         Just a desperate measure to shrink code and data size.
2105         By default all the locales available is included.
2106         This option is completely unrelated to --with-lang.])
2107    [
2108                          Affects also our character encoding conversion
2109                          tables for encodings mainly targeted for a
2110                          particular locale, like EUC-CN and EUC-TW for
2111                          zh, ISO-2022-JP for ja.
2112
2113                          Affects also our add-on break iterator data for
2114                          some languages.
2115
2116                          For the default, all locales, don't use this switch at all.
2117                          Specifying just the language part of a locale means all matching
2118                          locales will be included.
2119    ],
2120,)
2121
2122# Kerberos and GSSAPI used only by PostgreSQL as of LibO 3.5
2123libo_FUZZ_ARG_WITH(krb5,
2124    AS_HELP_STRING([--with-krb5],
2125        [Enable MIT Kerberos 5 support in modules that support it.
2126         By default automatically enabled on platforms
2127         where a good system Kerberos 5 is available.]),
2128,)
2129
2130libo_FUZZ_ARG_WITH(gssapi,
2131    AS_HELP_STRING([--with-gssapi],
2132        [Enable GSSAPI support in modules that support it.
2133         By default automatically enabled on platforms
2134         where a good system GSSAPI is available.]),
2135,)
2136
2137AC_ARG_WITH(iwyu,
2138    AS_HELP_STRING([--with-iwyu],
2139        [Use given IWYU binary path to check unneeded includes instead of building.
2140         Use only if you are hacking on it.]),
2141,)
2142
2143libo_FUZZ_ARG_WITH(lxml,
2144    AS_HELP_STRING([--without-lxml],
2145        [gla11y will use python lxml when available, potentially building a local copy if necessary.
2146         --without-lxml tells it to not use python lxml at all, which means that gla11y will only
2147         report widget classes and ids.]),
2148,)
2149
2150libo_FUZZ_ARG_WITH(latest-c++,
2151    AS_HELP_STRING([--with-latest-c++],
2152        [Try to enable the latest features of the C++ compiler, even if they are not yet part of a
2153         published standard.]),,
2154        [with_latest_c__=no])
2155
2156dnl ===================================================================
2157dnl Branding
2158dnl ===================================================================
2159
2160AC_ARG_WITH(branding,
2161    AS_HELP_STRING([--with-branding=/path/to/images],
2162        [Use given path to retrieve branding images set.])
2163    [
2164                          Search for intro.png about.svg and flat_logo.svg.
2165                          If any is missing, default ones will be used instead.
2166
2167                          Search also progress.conf for progress
2168                          settings on intro screen :
2169
2170                          PROGRESSBARCOLOR="255,255,255" Set color of
2171                          progress bar. Comma separated RGB decimal values.
2172                          PROGRESSSIZE="407,6" Set size of progress bar.
2173                          Comma separated decimal values (width, height).
2174                          PROGRESSPOSITION="61,317" Set position of progress
2175                          bar from left,top. Comma separated decimal values.
2176                          PROGRESSFRAMECOLOR="20,136,3" Set color of progress
2177                          bar frame. Comma separated RGB decimal values.
2178                          PROGRESSTEXTCOLOR="0,0,0" Set color of progress
2179                          bar text. Comma separated RGB decimal values.
2180                          PROGRESSTEXTBASELINE="287" Set vertical position of
2181                          progress bar text from top. Decimal value.
2182
2183                          Default values will be used if not found.
2184    ],
2185,)
2186
2187
2188AC_ARG_WITH(extra-buildid,
2189    AS_HELP_STRING([--with-extra-buildid="Tinderbox: Win-x86@6, Branch:master, Date:2012-11-26_00.29.34"],
2190        [Show addition build identification in about dialog.]),
2191,)
2192
2193
2194AC_ARG_WITH(vendor,
2195    AS_HELP_STRING([--with-vendor="John the Builder"],
2196        [Set vendor of the build.]),
2197,)
2198
2199AC_ARG_WITH(android-package-name,
2200    AS_HELP_STRING([--with-android-package-name="org.libreoffice"],
2201        [Set Android package name of the build.]),
2202,)
2203
2204AC_ARG_WITH(compat-oowrappers,
2205    AS_HELP_STRING([--with-compat-oowrappers],
2206        [Install oo* wrappers in parallel with
2207         lo* ones to keep backward compatibility.
2208         Has effect only with make distro-pack-install]),
2209,)
2210
2211AC_ARG_WITH(os-version,
2212    AS_HELP_STRING([--with-os-version=<OSVERSION>],
2213        [For FreeBSD users, use this option to override the detected OSVERSION.]),
2214,)
2215
2216AC_ARG_WITH(mingw-cross-compiler,
2217    AS_HELP_STRING([--with-mingw-cross-compiler=<mingw32-g++ command>],
2218        [Specify the MinGW cross-compiler to use.
2219         When building on the ODK on Unix and building unowinreg.dll,
2220         specify the MinGW C++ cross-compiler.]),
2221,)
2222
2223AC_ARG_WITH(idlc-cpp,
2224    AS_HELP_STRING([--with-idlc-cpp=<cpp/ucpp>],
2225        [Specify the C Preprocessor to use for idlc. Default is ucpp.]),
2226,)
2227
2228AC_ARG_WITH(build-version,
2229    AS_HELP_STRING([--with-build-version="Built by Jim"],
2230        [Allows the builder to add a custom version tag that will appear in the
2231         Help/About box for QA purposes.]),
2232with_build_version=$withval,
2233)
2234
2235AC_ARG_WITH(parallelism,
2236    AS_HELP_STRING([--with-parallelism],
2237        [Number of jobs to run simultaneously during build. Parallel builds can
2238        save a lot of time on multi-cpu machines. Defaults to the number of
2239        CPUs on the machine, unless you configure --enable-icecream - then to
2240        40.]),
2241,)
2242
2243AC_ARG_WITH(all-tarballs,
2244    AS_HELP_STRING([--with-all-tarballs],
2245        [Download all external tarballs unconditionally]))
2246
2247AC_ARG_WITH(gdrive-client-id,
2248    AS_HELP_STRING([--with-gdrive-client-id],
2249        [Provides the client id of the application for OAuth2 authentication
2250        on Google Drive. If either this or --with-gdrive-client-secret is
2251        empty, the feature will be disabled]),
2252)
2253
2254AC_ARG_WITH(gdrive-client-secret,
2255    AS_HELP_STRING([--with-gdrive-client-secret],
2256        [Provides the client secret of the application for OAuth2
2257        authentication on Google Drive. If either this or
2258        --with-gdrive-client-id is empty, the feature will be disabled]),
2259)
2260
2261AC_ARG_WITH(alfresco-cloud-client-id,
2262    AS_HELP_STRING([--with-alfresco-cloud-client-id],
2263        [Provides the client id of the application for OAuth2 authentication
2264        on Alfresco Cloud. If either this or --with-alfresco-cloud-client-secret is
2265        empty, the feature will be disabled]),
2266)
2267
2268AC_ARG_WITH(alfresco-cloud-client-secret,
2269    AS_HELP_STRING([--with-alfresco-cloud-client-secret],
2270        [Provides the client secret of the application for OAuth2
2271        authentication on Alfresco Cloud. If either this or
2272        --with-alfresco-cloud-client-id is empty, the feature will be disabled]),
2273)
2274
2275AC_ARG_WITH(onedrive-client-id,
2276    AS_HELP_STRING([--with-onedrive-client-id],
2277        [Provides the client id of the application for OAuth2 authentication
2278        on OneDrive. If either this or --with-onedrive-client-secret is
2279        empty, the feature will be disabled]),
2280)
2281
2282AC_ARG_WITH(onedrive-client-secret,
2283    AS_HELP_STRING([--with-onedrive-client-secret],
2284        [Provides the client secret of the application for OAuth2
2285        authentication on OneDrive. If either this or
2286        --with-onedrive-client-id is empty, the feature will be disabled]),
2287)
2288dnl ===================================================================
2289dnl Do we want to use pre-build binary tarball for recompile
2290dnl ===================================================================
2291
2292if test "$enable_library_bin_tar" = "yes" ; then
2293    USE_LIBRARY_BIN_TAR=TRUE
2294else
2295    USE_LIBRARY_BIN_TAR=
2296fi
2297AC_SUBST(USE_LIBRARY_BIN_TAR)
2298
2299dnl ===================================================================
2300dnl Test whether build target is Release Build
2301dnl ===================================================================
2302AC_MSG_CHECKING([whether build target is Release Build])
2303if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
2304    AC_MSG_RESULT([no])
2305    ENABLE_RELEASE_BUILD=
2306else
2307    AC_MSG_RESULT([yes])
2308    ENABLE_RELEASE_BUILD=TRUE
2309fi
2310AC_SUBST(ENABLE_RELEASE_BUILD)
2311
2312dnl ===================================================================
2313dnl Test whether to sign Windows Build
2314dnl ===================================================================
2315AC_MSG_CHECKING([whether to sign windows build])
2316if test "$enable_windows_build_signing" = "yes" -a "$_os" = "WINNT"; then
2317    AC_MSG_RESULT([yes])
2318    WINDOWS_BUILD_SIGNING="TRUE"
2319else
2320    AC_MSG_RESULT([no])
2321    WINDOWS_BUILD_SIGNING="FALSE"
2322fi
2323AC_SUBST(WINDOWS_BUILD_SIGNING)
2324
2325dnl ===================================================================
2326dnl MacOSX build and runtime environment options
2327dnl ===================================================================
2328
2329AC_ARG_WITH(macosx-sdk,
2330    AS_HELP_STRING([--with-macosx-sdk=<version>],
2331        [Prefer a specific SDK for building.])
2332    [
2333                          If the requested SDK is not available, a search for the oldest one will be done.
2334                          With current Xcode versions, only the latest SDK is included, so this option is
2335                          not terribly useful. It works fine to build with a new SDK and run the result
2336                          on an older OS.
2337
2338                          e. g.: --with-macosx-sdk=10.10
2339
2340                          there are 3 options to control the MacOSX build:
2341                          --with-macosx-sdk (referred as 'sdk' below)
2342                          --with-macosx-version-min-required (referred as 'min' below)
2343                          --with-macosx-version-max-allowed (referred as 'max' below)
2344
2345                          the connection between these value and the default they take is as follow:
2346                          ( ? means not specified on the command line, s means the SDK version found,
2347                          constraint: 8 <= x <= y <= z)
2348
2349                          ==========================================
2350                           command line      || config result
2351                          ==========================================
2352                          min  | max  | sdk  || min   | max  | sdk  |
2353                          ?    | ?    | ?    || 10.10 | 10.s | 10.s |
2354                          ?    | ?    | 10.x || 10.10 | 10.x | 10.x |
2355                          ?    | 10.x | ?    || 10.10 | 10.s | 10.s |
2356                          ?    | 10.x | 10.y || 10.10 | 10.x | 10.y |
2357                          10.x | ?    | ?    || 10.x  | 10.s | 10.s |
2358                          10.x | ?    | 10.y || 10.x  | 10.y | 10.y |
2359                          10.x | 10.y | ?    || 10.x  | 10.y | 10.y |
2360                          10.x | 10.y | 10.z || 10.x  | 10.y | 10.z |
2361
2362
2363                          see: http://developer.apple.com/library/mac/#technotes/tn2064/_index.html
2364                          for a detailed technical explanation of these variables
2365
2366                          Note: MACOSX_DEPLOYMENT_TARGET will be set to the value of 'min'.
2367    ],
2368,)
2369
2370AC_ARG_WITH(macosx-version-min-required,
2371    AS_HELP_STRING([--with-macosx-version-min-required=<version>],
2372        [set the minimum OS version needed to run the built LibreOffice])
2373    [
2374                          e. g.: --with-macos-version-min-required=10.10
2375                          see --with-macosx-sdk for more info
2376    ],
2377,)
2378
2379AC_ARG_WITH(macosx-version-max-allowed,
2380    AS_HELP_STRING([--with-macosx-version-max-allowed=<version>],
2381        [set the maximum allowed OS version the LibreOffice compilation can use APIs from])
2382    [
2383                          e. g.: --with-macos-version-max-allowed=10.10
2384                          see --with-macosx-sdk for more info
2385    ],
2386,)
2387
2388
2389dnl ===================================================================
2390dnl options for stuff used during cross-compilation build
2391dnl Not quite superseded by --with-build-platform-configure-options.
2392dnl TODO: check, if the "force" option is still needed anywhere.
2393dnl ===================================================================
2394
2395AC_ARG_WITH(system-icu-for-build,
2396    AS_HELP_STRING([--with-system-icu-for-build=yes/no/force],
2397        [Use icu already on system for build tools (cross-compilation only).]))
2398
2399
2400dnl ===================================================================
2401dnl Check for incompatible options set by fuzzing, and reset those
2402dnl automatically to working combinations
2403dnl ===================================================================
2404
2405if test "$libo_fuzzed_enable_dbus" = yes -a "$libo_fuzzed_enable_avahi" -a \
2406        "$enable_dbus" != "$enable_avahi"; then
2407    AC_MSG_NOTICE([Resetting --enable-avahi=$enable_dbus])
2408    enable_avahi=$enable_dbus
2409fi
2410
2411add_lopath_after ()
2412{
2413    if ! echo "$LO_PATH" | $EGREP -q "(^|${P_SEP})$1($|${P_SEP})"; then
2414        LO_PATH="${LO_PATH:+$LO_PATH$P_SEP}$1"
2415    fi
2416}
2417
2418add_lopath_before ()
2419{
2420    local IFS=${P_SEP}
2421    local path_cleanup
2422    local dir
2423    for dir in $LO_PATH ; do
2424        if test "$dir" != "$1" ; then
2425            path_cleanup=${path_cleanup:+$path_cleanup$P_SEP}$dir
2426        fi
2427    done
2428    LO_PATH="$1${path_cleanup:+$P_SEP$path_cleanup}"
2429}
2430
2431dnl ===================================================================
2432dnl check for required programs (grep, awk, sed, bash)
2433dnl ===================================================================
2434
2435pathmunge ()
2436{
2437    if test -n "$1"; then
2438        if test "$build_os" = "cygwin"; then
2439            if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
2440                PathFormat "$1"
2441                new_path=`cygpath -sm "$formatted_path"`
2442            else
2443                PathFormat "$1"
2444                new_path=`cygpath -u "$formatted_path"`
2445            fi
2446        else
2447            new_path="$1"
2448        fi
2449        if test "$2" = "after"; then
2450            add_lopath_after "$new_path"
2451        else
2452            add_lopath_before "$new_path"
2453        fi
2454        unset new_path
2455    fi
2456}
2457
2458AC_PROG_AWK
2459AC_PATH_PROG( AWK, $AWK)
2460if test -z "$AWK"; then
2461    AC_MSG_ERROR([install awk to run this script])
2462fi
2463
2464AC_PATH_PROG(BASH, bash)
2465if test -z "$BASH"; then
2466    AC_MSG_ERROR([bash not found in \$PATH])
2467fi
2468AC_SUBST(BASH)
2469
2470AC_MSG_CHECKING([for GNU or BSD tar])
2471for a in $GNUTAR gtar gnutar bsdtar tar /usr/sfw/bin/gtar; do
2472    $a --version 2> /dev/null | egrep "GNU|bsdtar"  2>&1 > /dev/null
2473    if test $? -eq 0;  then
2474        GNUTAR=$a
2475        break
2476    fi
2477done
2478AC_MSG_RESULT($GNUTAR)
2479if test -z "$GNUTAR"; then
2480    AC_MSG_ERROR([not found. install GNU or BSD tar.])
2481fi
2482AC_SUBST(GNUTAR)
2483
2484AC_MSG_CHECKING([for tar's option to strip components])
2485$GNUTAR --help 2> /dev/null | egrep "bsdtar|strip-components" 2>&1 >/dev/null
2486if test $? -eq 0; then
2487    STRIP_COMPONENTS="--strip-components"
2488else
2489    $GNUTAR --help 2> /dev/null | egrep "strip-path" 2>&1 >/dev/null
2490    if test $? -eq 0; then
2491        STRIP_COMPONENTS="--strip-path"
2492    else
2493        STRIP_COMPONENTS="unsupported"
2494    fi
2495fi
2496AC_MSG_RESULT($STRIP_COMPONENTS)
2497if test x$STRIP_COMPONENTS = xunsupported; then
2498    AC_MSG_ERROR([you need a tar that is able to strip components.])
2499fi
2500AC_SUBST(STRIP_COMPONENTS)
2501
2502dnl It is useful to have a BUILD_TYPE keyword to distinguish "normal"
2503dnl desktop OSes from "mobile" ones.
2504
2505dnl We assume that a non-DESKTOP build type is also a non-NATIVE one.
2506dnl In other words, that when building for an OS that is not a
2507dnl "desktop" one but a "mobile" one, we are always cross-compiling.
2508
2509dnl Note the direction of the implication; there is no assumption that
2510dnl cross-compiling would imply a non-desktop OS.
2511
2512if test $_os != iOS -a $_os != Android -a "$enable_fuzzers" != "yes"; then
2513    BUILD_TYPE="$BUILD_TYPE DESKTOP"
2514    AC_DEFINE(HAVE_FEATURE_DESKTOP)
2515    AC_DEFINE(HAVE_FEATURE_MULTIUSER_ENVIRONMENT)
2516fi
2517
2518# Whether to build "avmedia" functionality or not.
2519
2520if test -z "$enable_avmedia"; then
2521    enable_avmedia=yes
2522fi
2523
2524BUILD_TYPE="$BUILD_TYPE AVMEDIA"
2525if test "$enable_avmedia" = yes; then
2526    AC_DEFINE(HAVE_FEATURE_AVMEDIA)
2527else
2528    USE_AVMEDIA_DUMMY='TRUE'
2529fi
2530AC_SUBST(USE_AVMEDIA_DUMMY)
2531
2532# Decide whether to build database connectivity stuff (including
2533# Base) or not. We probably don't want to on non-desktop OSes.
2534if test -z "$enable_database_connectivity"; then
2535    # --disable-database-connectivity is unfinished work in progress
2536    # and the iOS test app doesn't link if we actually try to use it.
2537    # if test $_os != iOS -a $_os != Android; then
2538    if test $_os != iOS; then
2539        enable_database_connectivity=yes
2540    fi
2541fi
2542
2543if test "$enable_database_connectivity" = yes; then
2544    BUILD_TYPE="$BUILD_TYPE DBCONNECTIVITY"
2545    AC_DEFINE(HAVE_FEATURE_DBCONNECTIVITY)
2546fi
2547
2548if test -z "$enable_extensions"; then
2549    # For iOS and Android disable extensions unless specifically overridden with --enable-extensions.
2550    if test $_os != iOS -a $_os != Android; then
2551        enable_extensions=yes
2552    fi
2553fi
2554
2555if test "$enable_extensions" = yes; then
2556    BUILD_TYPE="$BUILD_TYPE EXTENSIONS"
2557    AC_DEFINE(HAVE_FEATURE_EXTENSIONS)
2558fi
2559
2560if test -z "$enable_scripting"; then
2561    # Disable scripting for iOS unless specifically overridden
2562    # with --enable-scripting.
2563    if test $_os != iOS; then
2564        enable_scripting=yes
2565    fi
2566fi
2567
2568DISABLE_SCRIPTING=''
2569if test "$enable_scripting" = yes; then
2570    BUILD_TYPE="$BUILD_TYPE SCRIPTING"
2571    AC_DEFINE(HAVE_FEATURE_SCRIPTING)
2572else
2573    DISABLE_SCRIPTING='TRUE'
2574    SCPDEFS="$SCPDEFS -DDISABLE_SCRIPTING"
2575fi
2576
2577if test $_os = iOS -o $_os = Android; then
2578    # Disable dynamic_loading always for iOS and Android
2579    enable_dynamic_loading=no
2580elif test -z "$enable_dynamic_loading"; then
2581    # Otherwise enable it unless specifically disabled
2582    enable_dynamic_loading=yes
2583fi
2584
2585DISABLE_DYNLOADING=''
2586if test "$enable_dynamic_loading" = yes; then
2587    BUILD_TYPE="$BUILD_TYPE DYNLOADING"
2588else
2589    DISABLE_DYNLOADING='TRUE'
2590fi
2591AC_SUBST(DISABLE_DYNLOADING)
2592
2593# remember SYSBASE value
2594AC_SUBST(SYSBASE)
2595
2596dnl ===================================================================
2597dnl  Sort out various gallery compilation options
2598dnl ===================================================================
2599AC_MSG_CHECKING([how to build and package galleries])
2600if test -n "${with_galleries}"; then
2601    if test "$with_galleries" = "build"; then
2602        WITH_GALLERY_BUILD=TRUE
2603        AC_MSG_RESULT([build from source images internally])
2604    elif test "$with_galleries" = "no"; then
2605        WITH_GALLERY_BUILD=
2606        AC_MSG_RESULT([disable non-internal gallery build])
2607    else
2608        AC_MSG_ERROR([unknown value --with-galleries=$with_galleries])
2609    fi
2610else
2611    if test $_os != iOS -a $_os != Android; then
2612        WITH_GALLERY_BUILD=TRUE
2613        AC_MSG_RESULT([internal src images for desktop])
2614    else
2615        WITH_GALLERY_BUILD=
2616        AC_MSG_RESULT([disable src image build])
2617    fi
2618fi
2619AC_SUBST(WITH_GALLERY_BUILD)
2620
2621dnl ===================================================================
2622dnl  Checks if ccache is available
2623dnl ===================================================================
2624CCACHE_DEPEND_MODE=
2625if test "$_os" = "WINNT"; then
2626    # on windows/VC build do not use ccache
2627    CCACHE=""
2628elif test "$enable_ccache" = "no"; then
2629    CCACHE=""
2630elif test -n "$enable_ccache" -o \( "$enable_ccache" = "" -a "$enable_icecream" != "yes" \); then
2631    case "%$CC%$CXX%" in
2632    # If $CC and/or $CXX already contain "ccache" (possibly suffixed with some version number etc),
2633    # assume that's good then
2634    *%ccache[[-_' ']]*|*/ccache[[-_' ']]*)
2635        AC_MSG_NOTICE([ccache seems to be included in a pre-defined CC and/or CXX])
2636        CCACHE_DEPEND_MODE=1
2637        ;;
2638    *)
2639        AC_PATH_PROG([CCACHE],[ccache],[not found])
2640        if test "$CCACHE" = "not found"; then
2641            CCACHE=""
2642        else
2643            CCACHE_DEPEND_MODE=1
2644            # Need to check for ccache version: otherwise prevents
2645            # caching of the results (like "-x objective-c++" for Mac)
2646            if test $_os = Darwin -o $_os = iOS; then
2647                # Check ccache version
2648                AC_MSG_CHECKING([whether version of ccache is suitable])
2649                CCACHE_VERSION=`"$CCACHE" -V | "$AWK" '/^ccache version/{print $3}'`
2650                CCACHE_NUMVER=`echo $CCACHE_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
2651                if test "$CCACHE_VERSION" = "2.4_OOo" -o "$CCACHE_NUMVER" -ge "030100"; then
2652                    AC_MSG_RESULT([yes, $CCACHE_VERSION])
2653                else
2654                    AC_MSG_RESULT([no, $CCACHE_VERSION])
2655                    CCACHE=""
2656                    CCACHE_DEPEND_MODE=
2657                fi
2658            fi
2659        fi
2660        ;;
2661    esac
2662else
2663    CCACHE=""
2664fi
2665if test "$enable_ccache" = "nodepend"; then
2666    CCACHE_DEPEND_MODE=""
2667fi
2668AC_SUBST(CCACHE_DEPEND_MODE)
2669
2670if test "$CCACHE" != ""; then
2671    ccache_size_msg=$([ccache -s | tail -n 1 | sed 's/^[^0-9]*//' | sed -e 's/\.[0-9]*//'])
2672    ccache_size=$(echo "$ccache_size_msg" | grep "G" | sed -e 's/G.*$//')
2673    if test "$ccache_size" = ""; then
2674        ccache_size=$(echo "$ccache_size_msg" | grep "M" | sed -e 's/\ M.*$//')
2675        if test "$ccache_size" = ""; then
2676            ccache_size=0
2677        fi
2678        # we could not determine the size or it was less than 1GB -> disable auto-ccache
2679        if test $ccache_size -lt 1024; then
2680            CCACHE=""
2681            AC_MSG_WARN([ccache's cache size is less than 1GB using it is counter-productive: Disabling auto-ccache detection])
2682            add_warning "ccache's cache size is less than 1GB using it is counter-productive: auto-ccache detection disabled"
2683        else
2684            # warn that ccache may be too small for debug build
2685            AC_MSG_WARN([ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build])
2686            add_warning "ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build"
2687        fi
2688    else
2689        if test $ccache_size -lt 5; then
2690            #warn that ccache may be too small for debug build
2691            AC_MSG_WARN([ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build])
2692            add_warning "ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build"
2693        fi
2694    fi
2695fi
2696
2697dnl ===================================================================
2698dnl  Checks for C compiler,
2699dnl  The check for the C++ compiler is later on.
2700dnl ===================================================================
2701if test "$_os" != "WINNT"; then
2702    GCC_HOME_SET="true"
2703    AC_MSG_CHECKING([gcc home])
2704    if test -z "$with_gcc_home"; then
2705        if test "$enable_icecream" = "yes"; then
2706            if test -d "/usr/lib/icecc/bin"; then
2707                GCC_HOME="/usr/lib/icecc/"
2708            elif test -d "/usr/libexec/icecc/bin"; then
2709                GCC_HOME="/usr/libexec/icecc/"
2710            elif test -d "/opt/icecream/bin"; then
2711                GCC_HOME="/opt/icecream/"
2712            else
2713                AC_MSG_ERROR([Could not figure out the location of icecream GCC wrappers, manually use --with-gcc-home])
2714
2715            fi
2716        else
2717            GCC_HOME=`which gcc | $SED -e s,/bin/gcc,,`
2718            GCC_HOME_SET="false"
2719        fi
2720    else
2721        GCC_HOME="$with_gcc_home"
2722    fi
2723    AC_MSG_RESULT($GCC_HOME)
2724    AC_SUBST(GCC_HOME)
2725
2726    if test "$GCC_HOME_SET" = "true"; then
2727        if test -z "$CC"; then
2728            CC="$GCC_HOME/bin/gcc"
2729            CC_BASE="gcc"
2730        fi
2731        if test -z "$CXX"; then
2732            CXX="$GCC_HOME/bin/g++"
2733            CXX_BASE="g++"
2734        fi
2735    fi
2736fi
2737
2738COMPATH=`dirname "$CC"`
2739if test "$COMPATH" = "."; then
2740    AC_PATH_PROGS(COMPATH, $CC)
2741    dnl double square bracket to get single because of M4 quote...
2742    COMPATH=`echo $COMPATH | $SED "s@/[[^/:]]*\\\$@@"`
2743fi
2744COMPATH=`echo $COMPATH | $SED "s@/[[Bb]][[Ii]][[Nn]]\\\$@@"`
2745
2746dnl ===================================================================
2747dnl Java support
2748dnl ===================================================================
2749AC_MSG_CHECKING([whether to build with Java support])
2750if test "$with_java" != "no"; then
2751    if test "$DISABLE_SCRIPTING" = TRUE; then
2752        AC_MSG_RESULT([no, overridden by --disable-scripting])
2753        ENABLE_JAVA=""
2754        with_java=no
2755    else
2756        AC_MSG_RESULT([yes])
2757        ENABLE_JAVA="TRUE"
2758        AC_DEFINE(HAVE_FEATURE_JAVA)
2759    fi
2760else
2761    AC_MSG_RESULT([no])
2762    ENABLE_JAVA=""
2763fi
2764
2765AC_SUBST(ENABLE_JAVA)
2766
2767dnl ENABLE_JAVA="TRUE" if we want there to be *run-time* (and build-time) support for Java
2768
2769dnl ENABLE_JAVA="" indicate no Java support at all
2770
2771dnl ===================================================================
2772dnl Check macOS SDK and compiler
2773dnl ===================================================================
2774
2775HAVE_MACOS_LD_PLATFORMVERSION=
2776if test $_os = Darwin; then
2777
2778    # If no --with-macosx-sdk option is given, look for one
2779
2780    # The intent is that for "most" Mac-based developers, a suitable
2781    # SDK will be found automatically without any configure options.
2782
2783    # For developers with a current Xcode, the lowest-numbered SDK
2784    # higher than or equal to the minimum required should be found.
2785
2786    AC_MSG_CHECKING([what macOS SDK to use])
2787    for _macosx_sdk in ${with_macosx_sdk-10.15 10.14 10.13 10.12}; do
2788        MACOSX_SDK_PATH=`xcrun --sdk macosx${_macosx_sdk} --show-sdk-path 2> /dev/null`
2789        if test -d "$MACOSX_SDK_PATH"; then
2790            with_macosx_sdk="${_macosx_sdk}"
2791            break
2792        else
2793            MACOSX_SDK_PATH="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${_macosx_sdk}.sdk"
2794            if test -d "$MACOSX_SDK_PATH"; then
2795                with_macosx_sdk="${_macosx_sdk}"
2796                break
2797            fi
2798        fi
2799    done
2800    if test ! -d "$MACOSX_SDK_PATH"; then
2801        AC_MSG_ERROR([Could not find an appropriate macOS SDK])
2802    fi
2803
2804    AC_MSG_RESULT([SDK $with_macosx_sdk at $MACOSX_SDK_PATH])
2805
2806    case $with_macosx_sdk in
2807    10.12)
2808        MACOSX_SDK_VERSION=101200
2809        ;;
2810    10.13)
2811        MACOSX_SDK_VERSION=101300
2812        ;;
2813    10.14)
2814        MACOSX_SDK_VERSION=101400
2815        ;;
2816    10.15)
2817        MACOSX_SDK_VERSION=101500
2818        ;;
2819    *)
2820        AC_MSG_ERROR([with-macosx-sdk $with_macosx_sdk is not a supported value, supported values are 10.12--15])
2821        ;;
2822    esac
2823
2824    if test "$with_macosx_version_min_required" = "" ; then
2825        with_macosx_version_min_required="10.10";
2826    fi
2827
2828    if test "$with_macosx_version_max_allowed" = "" ; then
2829        with_macosx_version_max_allowed="$with_macosx_sdk"
2830    fi
2831
2832    # export this so that "xcrun" invocations later return matching values
2833    DEVELOPER_DIR="${MACOSX_SDK_PATH%/SDKs*}"
2834    DEVELOPER_DIR="${DEVELOPER_DIR%/Platforms*}"
2835    export DEVELOPER_DIR
2836    FRAMEWORKSHOME="$MACOSX_SDK_PATH/System/Library/Frameworks"
2837    MACOSX_DEPLOYMENT_TARGET="$with_macosx_version_min_required"
2838
2839    AC_MSG_CHECKING([whether Xcode is new enough])
2840    my_xcode_ver1=$(xcrun xcodebuild -version | head -n 1)
2841    my_xcode_ver2=${my_xcode_ver1#Xcode }
2842    my_xcode_ver3=$(printf %s "$my_xcode_ver2" | $AWK -F. '{ print $1*100+($2<100?$2:99) }')
2843    if test "$my_xcode_ver3" -ge 903; then
2844        AC_MSG_RESULT([yes ($my_xcode_ver2)])
2845    else
2846        AC_MSG_ERROR(["$my_xcode_ver1" is too old or unrecognized, must be at least Xcode 9.3])
2847    fi
2848
2849    case "$with_macosx_version_min_required" in
2850    10.10)
2851        MAC_OS_X_VERSION_MIN_REQUIRED="101000"
2852        ;;
2853    10.11)
2854        MAC_OS_X_VERSION_MIN_REQUIRED="101100"
2855        ;;
2856    10.12)
2857        MAC_OS_X_VERSION_MIN_REQUIRED="101200"
2858        ;;
2859    10.13)
2860        MAC_OS_X_VERSION_MIN_REQUIRED="101300"
2861        ;;
2862    10.14)
2863        MAC_OS_X_VERSION_MIN_REQUIRED="101400"
2864        ;;
2865    10.15)
2866        MAC_OS_X_VERSION_MIN_REQUIRED="101500"
2867        ;;
2868    *)
2869        AC_MSG_ERROR([with-macosx-version-min-required $with_macosx_version_min_required is not a supported value, supported values are 10.10--15])
2870        ;;
2871    esac
2872    MAC_OS_X_VERSION_MIN_REQUIRED_DOTS=$with_macosx_version_min_required
2873
2874    LIBTOOL=/usr/bin/libtool
2875    INSTALL_NAME_TOOL=install_name_tool
2876    if test -z "$save_CC"; then
2877        stdlib=-stdlib=libc++
2878        if test "$ENABLE_LTO" = TRUE; then
2879            lto=-flto
2880        fi
2881
2882        AC_MSG_CHECKING([what C compiler to use])
2883        CC="`xcrun -find clang`"
2884        CC_BASE=`first_arg_basename "$CC"`
2885        CC+=" -m64 $lto -mmacosx-version-min=$with_macosx_version_min_required -isysroot $MACOSX_SDK_PATH"
2886        AC_MSG_RESULT([$CC])
2887
2888        AC_MSG_CHECKING([what C++ compiler to use])
2889        CXX="`xcrun -find clang++`"
2890        CXX_BASE=`first_arg_basename "$CXX"`
2891        CXX+=" -m64 $lto $stdlib -mmacosx-version-min=$with_macosx_version_min_required -isysroot $MACOSX_SDK_PATH"
2892        AC_MSG_RESULT([$CXX])
2893
2894        INSTALL_NAME_TOOL=`xcrun -find install_name_tool`
2895        AR=`xcrun -find ar`
2896        NM=`xcrun -find nm`
2897        STRIP=`xcrun -find strip`
2898        LIBTOOL=`xcrun -find libtool`
2899        RANLIB=`xcrun -find ranlib`
2900    fi
2901
2902    case "$with_macosx_version_max_allowed" in
2903    10.10)
2904        MAC_OS_X_VERSION_MAX_ALLOWED="101000"
2905        ;;
2906    10.11)
2907        MAC_OS_X_VERSION_MAX_ALLOWED="101100"
2908        ;;
2909    10.12)
2910        MAC_OS_X_VERSION_MAX_ALLOWED="101200"
2911        ;;
2912    10.13)
2913        MAC_OS_X_VERSION_MAX_ALLOWED="101300"
2914        ;;
2915    10.14)
2916        MAC_OS_X_VERSION_MAX_ALLOWED="101400"
2917        ;;
2918    10.15)
2919        MAC_OS_X_VERSION_MAX_ALLOWED="101500"
2920        ;;
2921    *)
2922        AC_MSG_ERROR([with-macosx-version-max-allowed $with_macosx_version_max_allowed is not a supported value, supported values are 10.10--15])
2923        ;;
2924    esac
2925
2926    AC_MSG_CHECKING([that macosx-version-min-required is coherent with macosx-version-max-allowed])
2927    if test $MAC_OS_X_VERSION_MIN_REQUIRED -gt $MAC_OS_X_VERSION_MAX_ALLOWED; then
2928        AC_MSG_ERROR([the version minimum required, $MAC_OS_X_VERSION_MIN_REQUIRED, must be <= the version maximum allowed, $MAC_OS_X_VERSION_MAX_ALLOWED])
2929    else
2930        AC_MSG_RESULT([ok])
2931    fi
2932
2933    AC_MSG_CHECKING([that macosx-version-max-allowed is coherent with macos-with-sdk])
2934    if test $MAC_OS_X_VERSION_MAX_ALLOWED -gt $MACOSX_SDK_VERSION; then
2935        AC_MSG_ERROR([the version maximum allowed cannot be greater than the sdk level])
2936    else
2937        AC_MSG_RESULT([ok])
2938    fi
2939    AC_MSG_NOTICE([MAC_OS_X_VERSION_MIN_REQUIRED=$MAC_OS_X_VERSION_MIN_REQUIRED])
2940    AC_MSG_NOTICE([MAC_OS_X_VERSION_MAX_ALLOWED=$MAC_OS_X_VERSION_MAX_ALLOWED])
2941
2942    AC_MSG_CHECKING([whether to do code signing])
2943
2944    if test "$enable_macosx_code_signing" = yes; then
2945        # By default use the first suitable certificate (?).
2946
2947        # http://stackoverflow.com/questions/13196291/difference-between-mac-developer-and-3rd-party-mac-developer-application
2948        # says that the "Mac Developer" certificate is useful just for self-testing. For distribution
2949        # outside the Mac App Store, use the "Developer ID Application" one, and for distribution in
2950        # the App Store, the "3rd Party Mac Developer" one. I think it works best to the
2951        # "Developer ID Application" one.
2952
2953        identity=`security find-identity -p codesigning -v 2>/dev/null | grep 'Developer ID Application:' | $AWK '{print $2}' |head -1`
2954        if test -n "$identity"; then
2955            MACOSX_CODESIGNING_IDENTITY=$identity
2956            pretty_name=`security find-identity -p codesigning -v | grep "$MACOSX_CODESIGNING_IDENTITY" | sed -e 's/^[[^"]]*"//' -e 's/"//'`
2957            AC_MSG_RESULT([yes, using the identity $MACOSX_CODESIGNING_IDENTITY for $pretty_name])
2958        else
2959            AC_MSG_ERROR([cannot determine identity to use])
2960        fi
2961    elif test -n "$enable_macosx_code_signing" -a "$enable_macosx_code_signing" != no ; then
2962        MACOSX_CODESIGNING_IDENTITY=$enable_macosx_code_signing
2963        pretty_name=`security find-identity -p codesigning -v | grep "$MACOSX_CODESIGNING_IDENTITY" | sed -e 's/^[[^"]]*"//' -e 's/"//'`
2964        AC_MSG_RESULT([yes, using the identity $MACOSX_CODESIGNING_IDENTITY for $pretty_name])
2965    else
2966        AC_MSG_RESULT([no])
2967    fi
2968
2969    AC_MSG_CHECKING([whether to create a Mac App Store package])
2970
2971    if test -n "$enable_macosx_package_signing" -a -z "$MACOSX_CODESIGNING_IDENTITY"; then
2972        AC_MSG_ERROR([You forgot --enable-macosx-code-signing])
2973    elif test "$enable_macosx_package_signing" = yes; then
2974        # By default use the first suitable certificate.
2975        # It should be a "3rd Party Mac Developer Installer" one
2976
2977        identity=`security find-identity -v 2>/dev/null | grep '3rd Party Mac Developer Installer:' | awk '{print $2}' |head -1`
2978        if test -n "$identity"; then
2979            MACOSX_PACKAGE_SIGNING_IDENTITY=$identity
2980            pretty_name=`security find-identity -v | grep "$MACOSX_PACKAGE_SIGNING_IDENTITY" | sed -e 's/^[[^"]]*"//' -e 's/"//'`
2981            AC_MSG_RESULT([yes, using the identity $MACOSX_PACKAGE_SIGNING_IDENTITY for $pretty_name])
2982        else
2983            AC_MSG_ERROR([Could not find any suitable '3rd Party Mac Developer Installer' certificate])
2984        fi
2985    elif test -n "$enable_macosx_package_signing"; then
2986        MACOSX_PACKAGE_SIGNING_IDENTITY=$enable_macosx_package_signing
2987        pretty_name=`security find-identity -v | grep "$MACOSX_PACKAGE_SIGNING_IDENTITY" | sed -e 's/^[[^"]]*"//' -e 's/"//'`
2988        AC_MSG_RESULT([yes, using the identity $MACOSX_PACKAGE_SIGNING_IDENTITY for $pretty_name])
2989    else
2990        AC_MSG_RESULT([no])
2991    fi
2992
2993    if test -n "$MACOSX_CODESIGNING_IDENTITY" -a -n "$MACOSX_PACKAGE_SIGNING_IDENTITY" -a "$MACOSX_CODESIGNING_IDENTITY" = "$MACOSX_PACKAGE_SIGNING_IDENTITY"; then
2994        AC_MSG_ERROR([You should not use the same identity for code and package signing])
2995    fi
2996
2997    AC_MSG_CHECKING([whether to sandbox the application])
2998
2999    if test -z "$MACOSX_CODESIGNING_IDENTITY" -a "$enable_macosx_sandbox" = yes; then
3000        AC_MSG_ERROR([macOS sandboxing requires code signing])
3001    elif test -n "$ENABLE_JAVA" -a "$enable_macosx_sandbox" = yes; then
3002        AC_MSG_ERROR([macOS sandboxing (actually App Store rules) disallows use of Java])
3003    elif test -n "$MACOSX_CODESIGNING_IDENTITY" -a "$enable_macosx_sandbox" = yes; then
3004        ENABLE_MACOSX_SANDBOX=TRUE
3005        AC_DEFINE(HAVE_FEATURE_MACOSX_SANDBOX)
3006        AC_MSG_RESULT([yes])
3007    else
3008        AC_MSG_RESULT([no])
3009    fi
3010
3011    AC_MSG_CHECKING([what macOS app bundle identifier to use])
3012    MACOSX_BUNDLE_IDENTIFIER=$with_macosx_bundle_identifier
3013    AC_MSG_RESULT([$MACOSX_BUNDLE_IDENTIFIER])
3014
3015    AC_MSG_CHECKING([whether the linker supports -platform_version])
3016    save_LDFLAGS=$LDFLAGS
3017    LDFLAGS="$LDFLAGS -Xlinker -platform_version -Xlinker macos \
3018        -Xlinker $MAC_OS_X_VERSION_MIN_REQUIRED_DOTS -Xlinker 0.0.0"
3019    AC_LINK_IFELSE([AC_LANG_PROGRAM()],
3020        [AC_MSG_RESULT([yes])
3021         HAVE_MACOS_LD_PLATFORMVERSION=TRUE],
3022        [AC_MSG_RESULT([no])])
3023    LDFLAGS=$save_LDFLAGS
3024fi
3025AC_SUBST(MACOSX_SDK_PATH)
3026AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
3027AC_SUBST(MAC_OS_X_VERSION_MIN_REQUIRED)
3028AC_SUBST(MAC_OS_X_VERSION_MIN_REQUIRED_DOTS)
3029AC_SUBST(MAC_OS_X_VERSION_MAX_ALLOWED)
3030AC_SUBST(INSTALL_NAME_TOOL)
3031AC_SUBST(LIBTOOL) # Note that the macOS libtool command is unrelated to GNU libtool
3032AC_SUBST(MACOSX_CODESIGNING_IDENTITY)
3033AC_SUBST(MACOSX_PACKAGE_SIGNING_IDENTITY)
3034AC_SUBST(ENABLE_MACOSX_SANDBOX)
3035AC_SUBST(MACOSX_BUNDLE_IDENTIFIER)
3036AC_SUBST(HAVE_MACOS_LD_PLATFORMVERSION)
3037
3038dnl ===================================================================
3039dnl Check iOS SDK and compiler
3040dnl ===================================================================
3041
3042if test $_os = iOS; then
3043    AC_MSG_CHECKING([what iOS SDK to use])
3044    current_sdk_ver=13.2
3045    older_sdk_vers="13.1 13.0 12.4 12.2"
3046    if test "$enable_ios_simulator" = "yes"; then
3047        platform=iPhoneSimulator
3048        versionmin=-mios-simulator-version-min=12.2
3049    else
3050        platform=iPhoneOS
3051        versionmin=-miphoneos-version-min=12.2
3052    fi
3053    xcode_developer=`xcode-select -print-path`
3054
3055    for sdkver in $current_sdk_ver $older_sdk_vers; do
3056        t=$xcode_developer/Platforms/$platform.platform/Developer/SDKs/$platform$sdkver.sdk
3057        if test -d $t; then
3058            sysroot=$t
3059            break
3060        fi
3061    done
3062
3063    if test -z "$sysroot"; then
3064        AC_MSG_ERROR([Could not find iOS SDK, expected something like $xcode_developer/Platforms/$platform.platform/Developer/SDKs/${platform}${current_sdk_ver}.sdk])
3065    fi
3066
3067    AC_MSG_RESULT($sysroot)
3068
3069    # LTO is not really recommended for iOS builds,
3070    # the link time will be astronomical
3071    if test "$ENABLE_LTO" = TRUE; then
3072        lto=-flto
3073    fi
3074
3075    stdlib="-stdlib=libc++"
3076
3077    AC_MSG_CHECKING([what C compiler to use])
3078    CC="`xcrun -find clang`"
3079    CC_BASE=`first_arg_basename "$CC"`
3080    CC+=" -arch $host_cpu -isysroot $sysroot $lto $versionmin"
3081    AC_MSG_RESULT([$CC])
3082
3083    AC_MSG_CHECKING([what C++ compiler to use])
3084    CXX="`xcrun -find clang++`"
3085    CXX_BASE=`first_arg_basename "$CXX"`
3086    CXX+=" -arch $host_cpu $stdlib -isysroot $sysroot $lto $versionmin"
3087    AC_MSG_RESULT([$CXX])
3088
3089    INSTALL_NAME_TOOL=`xcrun -find install_name_tool`
3090    AR=`xcrun -find ar`
3091    NM=`xcrun -find nm`
3092    STRIP=`xcrun -find strip`
3093    LIBTOOL=`xcrun -find libtool`
3094    RANLIB=`xcrun -find ranlib`
3095fi
3096
3097AC_MSG_CHECKING([whether to treat the installation as read-only])
3098
3099if test \( -z "$enable_readonly_installset" -a "$ENABLE_MACOSX_SANDBOX" = TRUE \) -o \
3100        "$enable_extensions" != yes; then
3101    enable_readonly_installset=yes
3102fi
3103if test "$enable_readonly_installset" = yes; then
3104    AC_MSG_RESULT([yes])
3105    AC_DEFINE(HAVE_FEATURE_READONLY_INSTALLSET)
3106else
3107    AC_MSG_RESULT([no])
3108fi
3109
3110dnl ===================================================================
3111dnl Structure of install set
3112dnl ===================================================================
3113
3114if test $_os = Darwin; then
3115    LIBO_BIN_FOLDER=MacOS
3116    LIBO_ETC_FOLDER=Resources
3117    LIBO_LIBEXEC_FOLDER=MacOS
3118    LIBO_LIB_FOLDER=Frameworks
3119    LIBO_LIB_PYUNO_FOLDER=Resources
3120    LIBO_SHARE_FOLDER=Resources
3121    LIBO_SHARE_HELP_FOLDER=Resources/help
3122    LIBO_SHARE_JAVA_FOLDER=Resources/java
3123    LIBO_SHARE_PRESETS_FOLDER=Resources/presets
3124    LIBO_SHARE_READMES_FOLDER=Resources/readmes
3125    LIBO_SHARE_RESOURCE_FOLDER=Resources/resource
3126    LIBO_SHARE_SHELL_FOLDER=Resources/shell
3127    LIBO_URE_BIN_FOLDER=MacOS
3128    LIBO_URE_ETC_FOLDER=Resources/ure/etc
3129    LIBO_URE_LIB_FOLDER=Frameworks
3130    LIBO_URE_MISC_FOLDER=Resources/ure/share/misc
3131    LIBO_URE_SHARE_JAVA_FOLDER=Resources/java
3132elif test $_os = WINNT; then
3133    LIBO_BIN_FOLDER=program
3134    LIBO_ETC_FOLDER=program
3135    LIBO_LIBEXEC_FOLDER=program
3136    LIBO_LIB_FOLDER=program
3137    LIBO_LIB_PYUNO_FOLDER=program
3138    LIBO_SHARE_FOLDER=share
3139    LIBO_SHARE_HELP_FOLDER=help
3140    LIBO_SHARE_JAVA_FOLDER=program/classes
3141    LIBO_SHARE_PRESETS_FOLDER=presets
3142    LIBO_SHARE_READMES_FOLDER=readmes
3143    LIBO_SHARE_RESOURCE_FOLDER=program/resource
3144    LIBO_SHARE_SHELL_FOLDER=program/shell
3145    LIBO_URE_BIN_FOLDER=program
3146    LIBO_URE_ETC_FOLDER=program
3147    LIBO_URE_LIB_FOLDER=program
3148    LIBO_URE_MISC_FOLDER=program
3149    LIBO_URE_SHARE_JAVA_FOLDER=program/classes
3150else
3151    LIBO_BIN_FOLDER=program
3152    LIBO_ETC_FOLDER=program
3153    LIBO_LIBEXEC_FOLDER=program
3154    LIBO_LIB_FOLDER=program
3155    LIBO_LIB_PYUNO_FOLDER=program
3156    LIBO_SHARE_FOLDER=share
3157    LIBO_SHARE_HELP_FOLDER=help
3158    LIBO_SHARE_JAVA_FOLDER=program/classes
3159    LIBO_SHARE_PRESETS_FOLDER=presets
3160    LIBO_SHARE_READMES_FOLDER=readmes
3161    if test "$enable_fuzzers" != yes; then
3162        LIBO_SHARE_RESOURCE_FOLDER=program/resource
3163    else
3164        LIBO_SHARE_RESOURCE_FOLDER=resource
3165    fi
3166    LIBO_SHARE_SHELL_FOLDER=program/shell
3167    LIBO_URE_BIN_FOLDER=program
3168    LIBO_URE_ETC_FOLDER=program
3169    LIBO_URE_LIB_FOLDER=program
3170    LIBO_URE_MISC_FOLDER=program
3171    LIBO_URE_SHARE_JAVA_FOLDER=program/classes
3172fi
3173AC_DEFINE_UNQUOTED(LIBO_BIN_FOLDER,"$LIBO_BIN_FOLDER")
3174AC_DEFINE_UNQUOTED(LIBO_ETC_FOLDER,"$LIBO_ETC_FOLDER")
3175AC_DEFINE_UNQUOTED(LIBO_LIBEXEC_FOLDER,"$LIBO_LIBEXEC_FOLDER")
3176AC_DEFINE_UNQUOTED(LIBO_LIB_FOLDER,"$LIBO_LIB_FOLDER")
3177AC_DEFINE_UNQUOTED(LIBO_LIB_PYUNO_FOLDER,"$LIBO_LIB_PYUNO_FOLDER")
3178AC_DEFINE_UNQUOTED(LIBO_SHARE_FOLDER,"$LIBO_SHARE_FOLDER")
3179AC_DEFINE_UNQUOTED(LIBO_SHARE_HELP_FOLDER,"$LIBO_SHARE_HELP_FOLDER")
3180AC_DEFINE_UNQUOTED(LIBO_SHARE_JAVA_FOLDER,"$LIBO_SHARE_JAVA_FOLDER")
3181AC_DEFINE_UNQUOTED(LIBO_SHARE_PRESETS_FOLDER,"$LIBO_SHARE_PRESETS_FOLDER")
3182AC_DEFINE_UNQUOTED(LIBO_SHARE_RESOURCE_FOLDER,"$LIBO_SHARE_RESOURCE_FOLDER")
3183AC_DEFINE_UNQUOTED(LIBO_SHARE_SHELL_FOLDER,"$LIBO_SHARE_SHELL_FOLDER")
3184AC_DEFINE_UNQUOTED(LIBO_URE_BIN_FOLDER,"$LIBO_URE_BIN_FOLDER")
3185AC_DEFINE_UNQUOTED(LIBO_URE_ETC_FOLDER,"$LIBO_URE_ETC_FOLDER")
3186AC_DEFINE_UNQUOTED(LIBO_URE_LIB_FOLDER,"$LIBO_URE_LIB_FOLDER")
3187AC_DEFINE_UNQUOTED(LIBO_URE_MISC_FOLDER,"$LIBO_URE_MISC_FOLDER")
3188AC_DEFINE_UNQUOTED(LIBO_URE_SHARE_JAVA_FOLDER,"$LIBO_URE_SHARE_JAVA_FOLDER")
3189
3190# Not all of them needed in config_host.mk, add more if need arises
3191AC_SUBST(LIBO_BIN_FOLDER)
3192AC_SUBST(LIBO_ETC_FOLDER)
3193AC_SUBST(LIBO_LIB_FOLDER)
3194AC_SUBST(LIBO_LIB_PYUNO_FOLDER)
3195AC_SUBST(LIBO_SHARE_FOLDER)
3196AC_SUBST(LIBO_SHARE_HELP_FOLDER)
3197AC_SUBST(LIBO_SHARE_JAVA_FOLDER)
3198AC_SUBST(LIBO_SHARE_PRESETS_FOLDER)
3199AC_SUBST(LIBO_SHARE_READMES_FOLDER)
3200AC_SUBST(LIBO_SHARE_RESOURCE_FOLDER)
3201AC_SUBST(LIBO_URE_BIN_FOLDER)
3202AC_SUBST(LIBO_URE_ETC_FOLDER)
3203AC_SUBST(LIBO_URE_LIB_FOLDER)
3204AC_SUBST(LIBO_URE_MISC_FOLDER)
3205AC_SUBST(LIBO_URE_SHARE_JAVA_FOLDER)
3206
3207dnl ===================================================================
3208dnl Windows specific tests and stuff
3209dnl ===================================================================
3210
3211reg_get_value()
3212{
3213    # Return value: $regvalue
3214    unset regvalue
3215
3216    local _regentry="/proc/registry${1}/${2}"
3217    if test -f "$_regentry"; then
3218        # Stop bash complaining about \0 bytes in input, as it can't handle them.
3219        # Registry keys read via /proc/registry* are always \0 terminated!
3220        local _regvalue=$(tr -d '\0' < "$_regentry")
3221        if test $? -eq 0; then
3222            regvalue=$_regvalue
3223        fi
3224    fi
3225}
3226
3227# Get a value from the 32-bit side of the Registry
3228reg_get_value_32()
3229{
3230    reg_get_value "32" "$1"
3231}
3232
3233# Get a value from the 64-bit side of the Registry
3234reg_get_value_64()
3235{
3236    reg_get_value "64" "$1"
3237}
3238
3239if test "$_os" = "WINNT"; then
3240    AC_MSG_CHECKING([whether to build a 64-bit LibreOffice])
3241    if test "$enable_64_bit" = "" -o "$enable_64_bit" = "no"; then
3242        AC_MSG_RESULT([no])
3243        WINDOWS_SDK_ARCH="x86"
3244    else
3245        AC_MSG_RESULT([yes])
3246        WINDOWS_SDK_ARCH="x64"
3247        BITNESS_OVERRIDE=64
3248    fi
3249fi
3250if test "$_os" = "iOS"; then
3251    cross_compiling="yes"
3252fi
3253
3254if test "$cross_compiling" = "yes"; then
3255    export CROSS_COMPILING=TRUE
3256else
3257    CROSS_COMPILING=
3258    BUILD_TYPE="$BUILD_TYPE NATIVE"
3259fi
3260AC_SUBST(CROSS_COMPILING)
3261
3262# Use -isystem (gcc) if possible, to avoid warnings in 3rd party headers.
3263# NOTE: must _not_ be used for bundled external libraries!
3264ISYSTEM=
3265if test "$GCC" = "yes"; then
3266    AC_MSG_CHECKING( for -isystem )
3267    save_CFLAGS=$CFLAGS
3268    CFLAGS="$CFLAGS -Werror"
3269    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ ISYSTEM="-isystem " ],[])
3270    CFLAGS=$save_CFLAGS
3271    if test -n "$ISYSTEM"; then
3272        AC_MSG_RESULT(yes)
3273    else
3274        AC_MSG_RESULT(no)
3275    fi
3276fi
3277if test -z "$ISYSTEM"; then
3278    # fall back to using -I
3279    ISYSTEM=-I
3280fi
3281AC_SUBST(ISYSTEM)
3282
3283dnl ===================================================================
3284dnl  Check which Visual Studio compiler is used
3285dnl ===================================================================
3286
3287map_vs_year_to_version()
3288{
3289    # Return value: $vsversion
3290
3291    unset vsversion
3292
3293    case $1 in
3294    2017)
3295        vsversion=15;;
3296    2019)
3297        vsversion=16;;
3298    *)
3299        AC_MSG_ERROR([Assertion failure - invalid argument "$1" to map_vs_year_to_version()]);;
3300    esac
3301}
3302
3303vs_versions_to_check()
3304{
3305    # Args: $1 (optional) : versions to check, in the order of preference
3306    # Return value: $vsversions
3307
3308    unset vsversions
3309
3310    if test -n "$1"; then
3311        map_vs_year_to_version "$1"
3312        vsversions=$vsversion
3313    else
3314        # We accept only 2017
3315        vsversions="15"
3316    fi
3317}
3318
3319win_get_env_from_vsvars32bat()
3320{
3321    WRAPPERBATCHFILEPATH="`mktemp -t wrpXXXXXX.bat`"
3322    # Also seems to be located in another directory under the same name: vsvars32.bat
3323    # https://github.com/bazelbuild/bazel/blob/master/src/main/native/build_windows_jni.sh#L56-L57
3324    printf '@call "%s/../Common7/Tools/VsDevCmd.bat" /no_logo\r\n' "$(cygpath -w $VC_PRODUCT_DIR)" > $WRAPPERBATCHFILEPATH
3325    printf '@setlocal\r\n@echo %%%s%%\r\n@endlocal\r\n' "$1" >> $WRAPPERBATCHFILEPATH
3326    chmod +x $WRAPPERBATCHFILEPATH
3327    _win_get_env_from_vsvars32bat=$("$WRAPPERBATCHFILEPATH" | tr -d '\r')
3328    rm -f $WRAPPERBATCHFILEPATH
3329    printf '%s' "$_win_get_env_from_vsvars32bat"
3330}
3331
3332find_ucrt()
3333{
3334    reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v10.0/InstallationFolder"
3335    if test -n "$regvalue"; then
3336        PathFormat "$regvalue"
3337        UCRTSDKDIR=$formatted_path
3338        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v10.0/ProductVersion"
3339        UCRTVERSION=$regvalue
3340        # Rest if not exist
3341        if ! test -d "${UCRTSDKDIR}Include/$UCRTVERSION/ucrt"; then
3342          UCRTSDKDIR=
3343        fi
3344    fi
3345    if test -z "$UCRTSDKDIR"; then
3346        ide_env_dir="$VC_PRODUCT_DIR/../Common7/Tools/"
3347        ide_env_file="${ide_env_dir}VsDevCmd.bat"
3348        if test -f "$ide_env_file"; then
3349            PathFormat "$(win_get_env_from_vsvars32bat UniversalCRTSdkDir)"
3350            UCRTSDKDIR=$formatted_path
3351            UCRTVERSION=$(win_get_env_from_vsvars32bat UCRTVersion)
3352            dnl Hack needed at least by tml:
3353            if test "$UCRTVERSION" = 10.0.15063.0 \
3354                -a ! -f "${UCRTSDKDIR}Include/10.0.15063.0/um/sqlext.h" \
3355                -a -f "${UCRTSDKDIR}Include/10.0.14393.0/um/sqlext.h"
3356            then
3357                UCRTVERSION=10.0.14393.0
3358            fi
3359        else
3360          AC_MSG_ERROR([No UCRT found])
3361        fi
3362    fi
3363}
3364
3365find_msvc()
3366{
3367    # Find Visual C++ 2017/2019
3368    # Args: $1 (optional) : The VS version year
3369    # Return values: $vctest, $vcyear, $vcnum, $vcnumwithdot, $vcbuildnumber
3370
3371    unset vctest vcnum vcnumwithdot vcbuildnumber
3372
3373    vs_versions_to_check "$1"
3374    vswhere="$(perl -e 'print $ENV{"ProgramFiles(x86)"}')"
3375    vswhere+="\\Microsoft Visual Studio\\Installer\\vswhere.exe"
3376    PathFormat "$vswhere"
3377    vswhere=$formatted_path
3378    for ver in $vsversions; do
3379        vswhereoutput=`$vswhere -version "@<:@ $ver , $(expr $ver + 1) @:}@" -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | head -1`
3380        if test -n "$vswhereoutput"; then
3381            PathFormat "$vswhereoutput"
3382            vctest=$formatted_path
3383            break
3384        fi
3385    done
3386
3387    # This fallback is needed on *some* (but not all) VS 2017 installations, where vswhere turns up
3388    # with the empty list for unclear reason. The below hack does not work for VS 2019 anyway, so
3389    # should be removed when upgrading baseline.
3390    if ! test -n "$vctest"; then
3391        for ver in $vsversions; do
3392            reg_get_value_32 HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/VisualStudio/$ver.0/Setup/VC/ProductDir
3393            if test -n "$regvalue"; then
3394                vctest=$regvalue
3395                break
3396            fi
3397            reg_get_value_32 HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/VisualStudio/SxS/VS7/$ver.0
3398            if test -n "$regvalue"; then
3399                AC_MSG_RESULT([found: $regvalue])
3400                PathFormat "$regvalue"
3401                vctest=$formatted_path
3402                break
3403            fi
3404        done
3405    fi
3406
3407    if test -n "$vctest"; then
3408        vcnumwithdot="$ver.0"
3409        case "$vcnumwithdot" in
3410        15.0)
3411            vcyear=2017
3412            vcnum=150
3413            ;;
3414        16.0)
3415            vcyear=2019
3416            vcnum=160
3417            ;;
3418        esac
3419        vcbuildnumber=`ls $vctest/VC/Tools/MSVC -A1r | head -1`
3420
3421    fi
3422}
3423
3424SOLARINC=
3425MSBUILD_PATH=
3426DEVENV=
3427if test "$_os" = "WINNT"; then
3428    AC_MSG_CHECKING([Visual C++])
3429    find_msvc "$with_visual_studio"
3430    if test -z "$vctest"; then
3431        if test -n "$with_visual_studio"; then
3432            AC_MSG_ERROR([no Visual Studio $with_visual_studio installation found])
3433        else
3434            AC_MSG_ERROR([no Visual Studio 2017 installation found])
3435        fi
3436    fi
3437
3438    if test "$BITNESS_OVERRIDE" = ""; then
3439        if test -f "$vctest/VC/Tools/MSVC/$vcbuildnumber/bin/HostX86/x86/cl.exe"; then
3440            VC_PRODUCT_DIR=$vctest/VC
3441        else
3442            AC_MSG_ERROR([no compiler (cl.exe) in $vctest/VC/Tools/MSVC/$vcbuildnumber/bin/HostX86/x86])
3443        fi
3444    else
3445        if test -f "$vctest/VC/Tools/MSVC/$vcbuildnumber/bin/HostX64/x64/cl.exe"; then
3446            VC_PRODUCT_DIR=$vctest/VC
3447        else
3448            AC_MSG_ERROR([no compiler (cl.exe) in $vctest/VC/Tools/MSVC/$vcbuildnumber/bin/HostX64/x64])
3449        fi
3450    fi
3451    AC_MSG_RESULT([$VC_PRODUCT_DIR])
3452
3453    AC_MSG_CHECKING([for short pathname of VC product directory])
3454    VC_PRODUCT_DIR=`win_short_path_for_make "$VC_PRODUCT_DIR"`
3455    AC_MSG_RESULT([$VC_PRODUCT_DIR])
3456
3457    UCRTSDKDIR=
3458    UCRTVERSION=
3459
3460    AC_MSG_CHECKING([for UCRT location])
3461    find_ucrt
3462    # find_ucrt errors out if it doesn't find it
3463    AC_MSG_RESULT([found])
3464    PathFormat "${UCRTSDKDIR}Include/$UCRTVERSION/ucrt"
3465    ucrtincpath_formatted=$formatted_path
3466    # SOLARINC is used for external modules and must be set too.
3467    # And no, it's not sufficient to set SOLARINC only, as configure
3468    # itself doesn't honour it.
3469    SOLARINC="$SOLARINC -I$ucrtincpath_formatted"
3470    CFLAGS="$CFLAGS -I$ucrtincpath_formatted"
3471    CXXFLAGS="$CXXFLAGS -I$ucrtincpath_formatted"
3472    CPPFLAGS="$CPPFLAGS -I$ucrtincpath_formatted"
3473
3474    AC_SUBST(UCRTSDKDIR)
3475    AC_SUBST(UCRTVERSION)
3476
3477    AC_MSG_CHECKING([for MSBuild.exe location for: $vcnumwithdot])
3478    # Find the proper version of MSBuild.exe to use based on the VS version
3479    reg_get_value_32 HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MSBuild/$vcnumwithdot/MSBuildOverrideTasksPath
3480    if test -n "$regvalue" ; then
3481        AC_MSG_RESULT([found: $regvalue])
3482        MSBUILD_PATH=`win_short_path_for_make "$regvalue"`
3483    else
3484        if test "$vcnumwithdot" = "16.0"; then
3485            if test "$BITNESS_OVERRIDE" = ""; then
3486                regvalue="$VC_PRODUCT_DIR/../MSBuild/Current/Bin"
3487            else
3488                regvalue="$VC_PRODUCT_DIR/../MSBuild/Current/Bin/amd64"
3489            fi
3490        else
3491            if test "$BITNESS_OVERRIDE" = ""; then
3492                regvalue="$VC_PRODUCT_DIR/../MSBuild/$vcnumwithdot/Bin"
3493            else
3494                regvalue="$VC_PRODUCT_DIR/../MSBuild/$vcnumwithdot/Bin/amd64"
3495            fi
3496        fi
3497        MSBUILD_PATH=`win_short_path_for_make "$regvalue"`
3498        AC_MSG_RESULT([$regvalue])
3499    fi
3500
3501    # Find the version of devenv.exe
3502    # MSVC 2017 devenv does not start properly from a DOS 8.3 path
3503    DEVENV=$(cygpath -lm "$VC_PRODUCT_DIR/../Common7/IDE/devenv.exe")
3504    if test ! -e "$DEVENV"; then
3505        AC_MSG_ERROR([No devenv.exe found, Visual Studio installation broken?])
3506    fi
3507
3508    dnl ===========================================================
3509    dnl  Check for the corresponding mspdb*.dll
3510    dnl ===========================================================
3511
3512    VC_HOST_DIR=
3513    MSPDB_PATH=
3514    CL_PATH=
3515
3516    if "$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/HostX64/x64/cl.exe" -? </dev/null >/dev/null 2>&1; then
3517        VC_HOST_DIR="HostX64"
3518        MSPDB_PATH="$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/$VC_HOST_DIR/x64"
3519    else
3520        VC_HOST_DIR="HostX86"
3521        MSPDB_PATH="$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/$VC_HOST_DIR/x86"
3522    fi
3523
3524    if test "$BITNESS_OVERRIDE" = ""; then
3525        CL_PATH="$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/$VC_HOST_DIR/x86"
3526    else
3527        CL_PATH="$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/$VC_HOST_DIR/x64"
3528    fi
3529
3530    # MSVC 15.0 has libraries from 14.0?
3531    mspdbnum="140"
3532
3533    if test ! -e "$MSPDB_PATH/mspdb${mspdbnum}.dll"; then
3534        AC_MSG_ERROR([No mspdb${mspdbnum}.dll in $MSPDB_PATH, Visual Studio installation broken?])
3535    fi
3536
3537    dnl The path needs to be added before cl is called
3538    TEMP_PATH=`cygpath -d "$MSPDB_PATH"`
3539    PATH="`cygpath -u "$TEMP_PATH"`:$PATH"
3540
3541    AC_MSG_CHECKING([cl.exe])
3542
3543    # Is there really ever a need to pass CC explicitly? Surely we can hope to get all the
3544    # automagical niceness to work OK? If somebody has some unsupported compiler in some weird
3545    # location, isn't it likely that lots of other things needs changes, too, and just setting CC
3546    # is not enough?
3547
3548    dnl Save the true MSVC cl.exe for use when CC/CXX is actually clang-cl,
3549    dnl needed when building CLR code:
3550    if test -z "$MSVC_CXX"; then
3551        if test -f "$CL_PATH/cl.exe"; then
3552            MSVC_CXX="$CL_PATH/cl.exe"
3553        fi
3554
3555        # This gives us a posix path with 8.3 filename restrictions
3556        MSVC_CXX=`win_short_path_for_make "$MSVC_CXX"`
3557    fi
3558
3559    if test -z "$CC"; then
3560        CC=$MSVC_CXX
3561        CC_BASE=`first_arg_basename "$CC"`
3562    fi
3563    if test "$BITNESS_OVERRIDE" = ""; then
3564        dnl since MSVC 2012, default for x86 is -arch:SSE2:
3565        MSVC_CXX="$MSVC_CXX -arch:SSE"
3566    fi
3567    if test -z "$CXX"; then
3568        CXX=$MSVC_CXX
3569        CXX_BASE=`first_arg_basename "$CXX"`
3570    fi
3571
3572    if test -n "$CC"; then
3573        # Remove /cl.exe from CC case insensitive
3574        AC_MSG_RESULT([found Visual C++ $vcyear ($CC)])
3575        if test "$BITNESS_OVERRIDE" = ""; then
3576           COMPATH="$VC_PRODUCT_DIR"
3577        else
3578            if test -n "$VC_PRODUCT_DIR"; then
3579                COMPATH=$VC_PRODUCT_DIR
3580            fi
3581        fi
3582        if test "$BITNESS_OVERRIDE" = ""; then
3583            dnl since MSVC 2012, default for x86 is -arch:SSE2:
3584            CC="$CC -arch:SSE"
3585        fi
3586
3587        COMPATH="$COMPATH/Tools/MSVC/$vcbuildnumber"
3588
3589        export INCLUDE=`cygpath -d "$COMPATH\Include"`
3590
3591        PathFormat "$COMPATH"
3592        COMPATH=`win_short_path_for_make "$formatted_path"`
3593
3594        VCVER=$vcnum
3595        MSVSVER=$vcyear
3596
3597        # The WINDOWS_SDK_ACCEPTABLE_VERSIONS is mostly an educated guess...  Assuming newer ones
3598        # are always "better", we list them in reverse chronological order.
3599
3600        case "$vcnum" in
3601        150|160)
3602            WINDOWS_SDK_ACCEPTABLE_VERSIONS="10.0 8.1A 8.1 8.0"
3603            ;;
3604        esac
3605
3606        # The expectation is that --with-windows-sdk should not need to be used
3607        if test -n "$with_windows_sdk"; then
3608            case " $WINDOWS_SDK_ACCEPTABLE_VERSIONS " in
3609            *" "$with_windows_sdk" "*)
3610                WINDOWS_SDK_ACCEPTABLE_VERSIONS=$with_windows_sdk
3611                ;;
3612            *)
3613                AC_MSG_ERROR([Windows SDK $with_windows_sdk is not known to work with VS $MSVSVER])
3614                ;;
3615            esac
3616        fi
3617
3618        # Make AC_COMPILE_IFELSE etc. work (set by AC_PROG_C, which we don't use for MSVC)
3619        ac_objext=obj
3620        ac_exeext=exe
3621
3622    else
3623        AC_MSG_ERROR([Visual C++ not found after all, huh])
3624    fi
3625
3626    AC_MSG_CHECKING([$CC_BASE is at least Visual Studio 2017 version 15.7])
3627    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3628        // See <https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros> for mapping
3629        // between Visual Studio versions and _MSC_VER:
3630        #if _MSC_VER < 1914
3631        #error
3632        #endif
3633    ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no])])
3634
3635    # Check for 64-bit (cross-)compiler to use to build the 64-bit
3636    # version of the Explorer extension (and maybe other small
3637    # bits, too) needed when installing a 32-bit LibreOffice on a
3638    # 64-bit OS. The 64-bit Explorer extension is a feature that
3639    # has been present since long in OOo. Don't confuse it with
3640    # building LibreOffice itself as 64-bit code.
3641
3642    BUILD_X64=
3643    CXX_X64_BINARY=
3644
3645    if test "$BITNESS_OVERRIDE" = ""; then
3646        AC_MSG_CHECKING([for a x64 compiler and libraries for 64-bit Explorer extensions])
3647        if test -f "$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/atlmfc/lib/x64/atls.lib" || \
3648             test -f "$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/atlmfc/lib/spectre/x64/atls.lib"; then
3649            if "$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/$VC_HOST_DIR/x64/cl.exe" -? </dev/null >/dev/null 2>&1; then
3650                BUILD_X64=TRUE
3651                CXX_X64_BINARY=`win_short_path_for_make "$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/$VC_HOST_DIR/x64/cl.exe"`
3652            fi
3653        fi
3654        if test "$BUILD_X64" = TRUE; then
3655            AC_MSG_RESULT([found])
3656        else
3657            AC_MSG_RESULT([not found])
3658            AC_MSG_WARN([Installation set will not contain 64-bit Explorer extensions])
3659        fi
3660    else
3661        CXX_X64_BINARY=$CXX
3662    fi
3663    AC_SUBST(BUILD_X64)
3664
3665    # These are passed to the environment and then used in gbuild/platform/com_MSC_class.mk
3666    AC_SUBST(CXX_X64_BINARY)
3667
3668    # Check for 32-bit compiler to use to build the 32-bit TWAIN shim
3669    # needed to support TWAIN scan on both 32- and 64-bit systems
3670
3671    BUILD_X86=
3672
3673    if test "$BITNESS_OVERRIDE" = "64"; then
3674        AC_MSG_CHECKING([for a x86 compiler and libraries for 32-bit binaries required for TWAIN support])
3675        if test -n "$CXX_X86_BINARY"; then
3676            BUILD_X86=TRUE
3677            AC_MSG_RESULT([preset])
3678        elif "$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/$VC_HOST_DIR/x86/cl.exe" -? </dev/null >/dev/null 2>&1; then
3679            BUILD_X86=TRUE
3680            CXX_X86_BINARY=`win_short_path_for_make "$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/$VC_HOST_DIR/x86/cl.exe"`
3681            CXX_X86_BINARY+=" /arch:SSE"
3682            AC_MSG_RESULT([found])
3683        else
3684            CXX_X86_BINARY=
3685            AC_MSG_RESULT([not found])
3686            AC_MSG_WARN([Installation set will not contain 32-bit binaries required for TWAIN support])
3687        fi
3688    else
3689        BUILD_X86=TRUE
3690        CXX_X86_BINARY=$MSVC_CXX
3691    fi
3692    AC_SUBST(BUILD_X86)
3693    AC_SUBST(CXX_X86_BINARY)
3694fi
3695AC_SUBST(VCVER)
3696AC_SUBST(DEVENV)
3697AC_SUBST(MSVC_CXX)
3698
3699#
3700# unowinreg.dll
3701#
3702UNOWINREG_DLL="185d60944ea767075d27247c3162b3bc-unowinreg.dll"
3703AC_SUBST(UNOWINREG_DLL)
3704
3705COM_IS_CLANG=
3706AC_MSG_CHECKING([whether the compiler is actually Clang])
3707AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3708    #ifndef __clang__
3709    you lose
3710    #endif
3711    int foo=42;
3712    ]])],
3713    [AC_MSG_RESULT([yes])
3714     COM_IS_CLANG=TRUE],
3715    [AC_MSG_RESULT([no])])
3716AC_SUBST(COM_IS_CLANG)
3717
3718CC_PLAIN=$CC
3719CLANGVER=
3720if test "$COM_IS_CLANG" = TRUE; then
3721    AC_MSG_CHECKING([whether Clang is new enough])
3722    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3723        #if !defined __apple_build_version__
3724        #error
3725        #endif
3726        ]])],
3727        [my_apple_clang=yes],[my_apple_clang=])
3728    if test "$my_apple_clang" = yes; then
3729        AC_MSG_RESULT([assumed yes (Apple Clang)])
3730    else
3731        if test "$_os" = WINNT; then
3732            dnl In which case, assume clang-cl:
3733            my_args="/EP /TC"
3734            dnl Filter out -FIIntrin.h, which needs to be explicitly stated for
3735            dnl clang-cl:
3736            CC_PLAIN=
3737            for i in $CC; do
3738                case $i in
3739                -FIIntrin.h)
3740                    ;;
3741                *)
3742                    CC_PLAIN="$CC_PLAIN $i"
3743                    ;;
3744                esac
3745            done
3746        else
3747            my_args="-E -P"
3748        fi
3749        clang_version=`echo __clang_major__.__clang_minor__.__clang_patchlevel__ | $CC_PLAIN $my_args - | sed 's/ //g'`
3750        CLANG_FULL_VERSION=`echo __clang_version__ | $CC_PLAIN $my_args -`
3751        CLANGVER=`echo $clang_version \
3752            | $AWK -F. '{ print \$1*10000+(\$2<100?\$2:99)*100+(\$3<100?\$3:99) }'`
3753        if test "$CLANGVER" -ge 50002; then
3754            AC_MSG_RESULT([yes ($clang_version)])
3755        else
3756            AC_MSG_ERROR(["$CLANG_FULL_VERSION" is too old or unrecognized, must be at least Clang 5.0.2])
3757        fi
3758        AC_DEFINE_UNQUOTED(CLANG_VERSION,$CLANGVER)
3759        AC_DEFINE_UNQUOTED(CLANG_FULL_VERSION,$CLANG_FULL_VERSION)
3760    fi
3761fi
3762
3763SHOWINCLUDES_PREFIX=
3764if test "$_os" = WINNT; then
3765    dnl We need to guess the prefix of the -showIncludes output, it can be
3766    dnl localized
3767    AC_MSG_CHECKING([the dependency generation prefix (cl.exe -showIncludes)])
3768    echo "#include <stdlib.h>" > conftest.c
3769    SHOWINCLUDES_PREFIX=`$CC_PLAIN $CFLAGS -c -showIncludes conftest.c 2>/dev/null | \
3770        grep 'stdlib\.h' | head -n1 | sed 's/ [[[:alpha:]]]:.*//'`
3771    rm -f conftest.c conftest.obj
3772    if test -z "$SHOWINCLUDES_PREFIX"; then
3773        AC_MSG_ERROR([cannot determine the -showIncludes prefix])
3774    else
3775        AC_MSG_RESULT(["$SHOWINCLUDES_PREFIX"])
3776    fi
3777fi
3778AC_SUBST(SHOWINCLUDES_PREFIX)
3779
3780#
3781# prefix C with ccache if needed
3782#
3783if test "$CCACHE" != ""; then
3784    AC_MSG_CHECKING([whether $CC_BASE is already ccached])
3785
3786    AC_LANG_PUSH([C])
3787    save_CFLAGS=$CFLAGS
3788    CFLAGS="$CFLAGS --ccache-skip -O2"
3789    dnl an empty program will do, we're checking the compiler flags
3790    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
3791                      [use_ccache=yes], [use_ccache=no])
3792    if test $use_ccache = yes; then
3793        AC_MSG_RESULT([yes])
3794    else
3795        CC="$CCACHE $CC"
3796        CC_BASE="ccache $CC_BASE"
3797        AC_MSG_RESULT([no])
3798    fi
3799    CFLAGS=$save_CFLAGS
3800    AC_LANG_POP([C])
3801fi
3802
3803# ===================================================================
3804# check various GCC options that Clang does not support now but maybe
3805# will somewhen in the future, check them even for GCC, so that the
3806# flags are set
3807# ===================================================================
3808
3809HAVE_GCC_GGDB2=
3810if test "$GCC" = "yes"; then
3811    AC_MSG_CHECKING([whether $CC_BASE supports -ggdb2])
3812    save_CFLAGS=$CFLAGS
3813    CFLAGS="$CFLAGS -Werror -ggdb2"
3814    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_GGDB2=TRUE ],[])
3815    CFLAGS=$save_CFLAGS
3816    if test "$HAVE_GCC_GGDB2" = "TRUE"; then
3817        AC_MSG_RESULT([yes])
3818    else
3819        AC_MSG_RESULT([no])
3820    fi
3821
3822    if test "$host_cpu" = "m68k"; then
3823        AC_MSG_CHECKING([whether $CC_BASE supports -mlong-jump-table-offsets])
3824        save_CFLAGS=$CFLAGS
3825        CFLAGS="$CFLAGS -Werror -mlong-jump-table-offsets"
3826        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_LONG_JUMP_TABLE_OFFSETS=TRUE ],[])
3827        CFLAGS=$save_CFLAGS
3828        if test "$HAVE_GCC_LONG_JUMP_TABLE_OFFSETS" = "TRUE"; then
3829            AC_MSG_RESULT([yes])
3830        else
3831            AC_MSG_ERROR([no])
3832        fi
3833    fi
3834fi
3835AC_SUBST(HAVE_GCC_GGDB2)
3836
3837dnl ===================================================================
3838dnl  Test the gcc version
3839dnl ===================================================================
3840if test "$GCC" = "yes" -a -z "$COM_IS_CLANG"; then
3841    AC_MSG_CHECKING([the GCC version])
3842    _gcc_version=`$CC -dumpversion`
3843    gcc_full_version=$(printf '%s' "$_gcc_version" | \
3844        $AWK -F. '{ print $1*10000+$2*100+(NF<3?1:$3) }')
3845    GCC_VERSION=`echo $_gcc_version | $AWK -F. '{ print \$1*100+\$2 }'`
3846
3847    AC_MSG_RESULT([gcc $_gcc_version ($gcc_full_version)])
3848
3849    if test "$gcc_full_version" -lt 70000; then
3850        AC_MSG_ERROR([GCC $_gcc_version is too old, must be at least GCC 7.0.0])
3851    fi
3852else
3853    # Explicitly force GCC_VERSION to be empty, even for Clang, to check incorrect uses.
3854    # GCC version should generally be checked only when handling GCC-specific bugs, for testing
3855    # things like features configure checks should be used, otherwise they may e.g. fail with Clang
3856    # (which reports itself as GCC 4.2.1).
3857    GCC_VERSION=
3858fi
3859AC_SUBST(GCC_VERSION)
3860
3861dnl Set the ENABLE_DBGUTIL variable
3862dnl ===================================================================
3863AC_MSG_CHECKING([whether to build with additional debug utilities])
3864if test -n "$enable_dbgutil" -a "$enable_dbgutil" != "no"; then
3865    ENABLE_DBGUTIL="TRUE"
3866    # this is an extra var so it can have different default on different MSVC
3867    # versions (in case there are version specific problems with it)
3868    MSVC_USE_DEBUG_RUNTIME="TRUE"
3869
3870    AC_MSG_RESULT([yes])
3871    # cppunit and graphite expose STL in public headers
3872    if test "$with_system_cppunit" = "yes"; then
3873        AC_MSG_ERROR([--with-system-cppunit conflicts with --enable-dbgutil])
3874    else
3875        with_system_cppunit=no
3876    fi
3877    if test "$with_system_graphite" = "yes"; then
3878        AC_MSG_ERROR([--with-system-graphite conflicts with --enable-dbgutil])
3879    else
3880        with_system_graphite=no
3881    fi
3882    if test "$with_system_orcus" = "yes"; then
3883        AC_MSG_ERROR([--with-system-orcus conflicts with --enable-dbgutil])
3884    else
3885        with_system_orcus=no
3886    fi
3887    if test "$with_system_libcmis" = "yes"; then
3888        AC_MSG_ERROR([--with-system-libcmis conflicts with --enable-dbgutil])
3889    else
3890        with_system_libcmis=no
3891    fi
3892    if test "$with_system_hunspell" = "yes"; then
3893        AC_MSG_ERROR([--with-system-hunspell conflicts with --enable-dbgutil])
3894    else
3895        with_system_hunspell=no
3896    fi
3897    if test "$with_system_gpgmepp" = "yes"; then
3898        AC_MSG_ERROR([--with-system-gpgmepp conflicts with --enable-dbgutil])
3899    else
3900        with_system_gpgmepp=no
3901    fi
3902    # As mixing system libwps and non-system libnumbertext or vice versa likely causes trouble (see
3903    # 603074c5f2b84de8a24593faf807da784b040625 "Pass _GLIBCXX_DEBUG into external/libwps" and the
3904    # mail thread starting at <https://gcc.gnu.org/ml/gcc/2018-05/msg00057.html> "libstdc++: ODR
3905    # violation when using std::regex with and without -D_GLIBCXX_DEBUG"), simply make sure neither
3906    # of those two is using the system variant:
3907    if test "$with_system_libnumbertext" = "yes"; then
3908        AC_MSG_ERROR([--with-system-libnumbertext conflicts with --enable-dbgutil])
3909    else
3910        with_system_libnumbertext=no
3911    fi
3912    if test "$with_system_libwps" = "yes"; then
3913        AC_MSG_ERROR([--with-system-libwps conflicts with --enable-dbgutil])
3914    else
3915        with_system_libwps=no
3916    fi
3917else
3918    ENABLE_DBGUTIL=""
3919    MSVC_USE_DEBUG_RUNTIME=""
3920    AC_MSG_RESULT([no])
3921fi
3922AC_SUBST(ENABLE_DBGUTIL)
3923AC_SUBST(MSVC_USE_DEBUG_RUNTIME)
3924
3925dnl Set the ENABLE_DEBUG variable.
3926dnl ===================================================================
3927if test -n "$enable_debug" && test "$enable_debug" != "yes" && test "$enable_debug" != "no"; then
3928    AC_MSG_ERROR([--enable-debug now accepts only yes or no, use --enable-symbols])
3929fi
3930if test -n "$ENABLE_DBGUTIL" -a "$enable_debug" = "no"; then
3931    if test -z "$libo_fuzzed_enable_debug"; then
3932        AC_MSG_ERROR([--disable-debug cannot be used with --enable-dbgutil])
3933    else
3934        AC_MSG_NOTICE([Resetting --enable-debug=yes])
3935        enable_debug=yes
3936    fi
3937fi
3938
3939AC_MSG_CHECKING([whether to do a debug build])
3940if test -n "$ENABLE_DBGUTIL" -o \( -n "$enable_debug" -a "$enable_debug" != "no" \) ; then
3941    ENABLE_DEBUG="TRUE"
3942    if test -n "$ENABLE_DBGUTIL" ; then
3943        AC_MSG_RESULT([yes (dbgutil)])
3944    else
3945        AC_MSG_RESULT([yes])
3946    fi
3947else
3948    ENABLE_DEBUG=""
3949    AC_MSG_RESULT([no])
3950fi
3951AC_SUBST(ENABLE_DEBUG)
3952
3953dnl ===================================================================
3954dnl Select the linker to use (gold/lld/ld.bfd).
3955dnl This is done only after compiler checks (need to know if Clang is
3956dnl used, for different defaults) and after checking if a debug build
3957dnl is wanted (non-debug builds get the default linker if not explicitly
3958dnl specified otherwise).
3959dnl All checks for linker features/options should come after this.
3960dnl ===================================================================
3961check_use_ld()
3962{
3963    use_ld=$1
3964    use_ld_fail_if_error=$2
3965    use_ld_ok=
3966    AC_MSG_CHECKING([for -fuse-ld=$use_ld linker support])
3967    use_ld_ldflags_save="$LDFLAGS"
3968    LDFLAGS="$LDFLAGS -fuse-ld=$use_ld"
3969    AC_LINK_IFELSE([AC_LANG_PROGRAM([
3970#include <stdio.h>
3971        ],[
3972printf ("hello world\n");
3973        ])], USE_LD=$use_ld, [])
3974    if test -n "$USE_LD"; then
3975        AC_MSG_RESULT( yes )
3976        use_ld_ok=yes
3977    else
3978        if test -n "$use_ld_fail_if_error"; then
3979            AC_MSG_ERROR( no )
3980        else
3981            AC_MSG_RESULT( no )
3982        fi
3983    fi
3984    if test -n "$use_ld_ok"; then
3985        dnl keep the value of LDFLAGS
3986        return 0
3987    fi
3988    LDFLAGS="$use_ld_ldflags_save"
3989    return 1
3990}
3991USE_LD=
3992if test "$enable_ld" != "no"; then
3993    if test "$GCC" = "yes"; then
3994        if test -n "$enable_ld"; then
3995            check_use_ld "$enable_ld" fail_if_error
3996        elif test -z "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
3997            dnl non-debug builds default to the default linker
3998            true
3999        elif test -n "$COM_IS_CLANG"; then
4000            check_use_ld lld
4001            if test $? -ne 0; then
4002                check_use_ld gold
4003            fi
4004        else
4005            # For gcc first try gold, new versions also support lld.
4006            check_use_ld gold
4007            if test $? -ne 0; then
4008                check_use_ld lld
4009            fi
4010        fi
4011        ld_output=$(echo 'int main() { return 0; }' | $CC -Wl,-v -x c -o conftest.out - $CFLAGS $LDFLAGS 2>/dev/null)
4012        rm conftest.out
4013        ld_used=$(echo "$ld_output" | grep -E '(^GNU gold|^GNU ld|^LLD)')
4014        if test -z "$ld_used"; then
4015            ld_used="unknown"
4016        fi
4017        AC_MSG_CHECKING([for linker that is used])
4018        AC_MSG_RESULT([$ld_used])
4019        if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
4020            if echo "$ld_used" | grep -q "^GNU ld"; then
4021                AC_MSG_WARN([The default GNU linker is slow, consider using the LLD or the GNU gold linker.])
4022                add_warning "The default GNU linker is slow, consider using the LLD or the GNU gold linker."
4023            fi
4024        fi
4025    else
4026        if test "$enable_ld" = "yes"; then
4027            AC_MSG_ERROR([--enable-ld not supported])
4028        fi
4029    fi
4030fi
4031AC_SUBST(USE_LD)
4032
4033HAVE_LD_BSYMBOLIC_FUNCTIONS=
4034if test "$GCC" = "yes"; then
4035    AC_MSG_CHECKING([for -Bsymbolic-functions linker support])
4036    bsymbolic_functions_ldflags_save=$LDFLAGS
4037    LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
4038    AC_LINK_IFELSE([AC_LANG_PROGRAM([
4039#include <stdio.h>
4040        ],[
4041printf ("hello world\n");
4042        ])], HAVE_LD_BSYMBOLIC_FUNCTIONS=TRUE, [])
4043    if test "$HAVE_LD_BSYMBOLIC_FUNCTIONS" = "TRUE"; then
4044        AC_MSG_RESULT( found )
4045    else
4046        AC_MSG_RESULT( not found )
4047    fi
4048    LDFLAGS=$bsymbolic_functions_ldflags_save
4049fi
4050AC_SUBST(HAVE_LD_BSYMBOLIC_FUNCTIONS)
4051
4052
4053HAVE_GSPLIT_DWARF=
4054if test "$enable_split_debug" != no; then
4055    dnl Currently by default enabled only on Linux, feel free to set test_split_debug above also for other platforms.
4056    if test "$enable_split_debug" = yes -o \( "$test_split_debug" = "yes" -a -n "$ENABLE_DEBUG$ENABLE_DBGUTIL" \); then
4057        AC_MSG_CHECKING([whether $CC_BASE supports -gsplit-dwarf])
4058        save_CFLAGS=$CFLAGS
4059        CFLAGS="$CFLAGS -Werror -gsplit-dwarf"
4060        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_SPLIT_DWARF=TRUE ],[])
4061        CFLAGS=$save_CFLAGS
4062        if test "$HAVE_GCC_SPLIT_DWARF" = "TRUE"; then
4063            AC_MSG_RESULT([yes])
4064        else
4065            if test "$enable_split_debug" = yes; then
4066                AC_MSG_ERROR([no])
4067            else
4068                AC_MSG_RESULT([no])
4069            fi
4070        fi
4071    fi
4072    if test -z "$HAVE_GCC_SPLIT_DWARF" -a "$test_split_debug" = "yes" -a -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
4073        AC_MSG_WARN([Compiler is not capable of creating split debug info, linking will require more time and disk space.])
4074        add_warning "Compiler is not capable of creating split debug info, linking will require more time and disk space."
4075    fi
4076fi
4077AC_SUBST(HAVE_GCC_SPLIT_DWARF)
4078
4079ENABLE_GDB_INDEX=
4080if test "$enable_gdb_index" != "no"; then
4081    dnl Currently by default enabled only on Linux, feel free to set test_gdb_index above also for other platforms.
4082    if test "$enable_gdb_index" = yes -o \( "$test_gdb_index" = "yes" -o -n "$ENABLE_DEBUG$ENABLE_DBGUTIL" \); then
4083        AC_MSG_CHECKING([whether $CC_BASE supports -ggnu-pubnames])
4084        save_CFLAGS=$CFLAGS
4085        CFLAGS="$CFLAGS -Werror -ggnu-pubnames"
4086        have_ggnu_pubnames=
4087        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[have_ggnu_pubnames=TRUE],[have_ggnu_pubnames=])
4088        if test "$have_ggnu_pubnames" != "TRUE"; then
4089            if test "$enable_gdb_index" = "yes"; then
4090                AC_MSG_ERROR( no, --enable-gdb-index not supported )
4091            else
4092                AC_MSG_RESULT( no )
4093            fi
4094        else
4095            AC_MSG_RESULT( yes )
4096            AC_MSG_CHECKING([whether $CC_BASE supports -Wl,--gdb-index])
4097            ldflags_save=$LDFLAGS
4098            LDFLAGS="$LDFLAGS -Wl,--gdb-index"
4099            AC_LINK_IFELSE([AC_LANG_PROGRAM([
4100#include <stdio.h>
4101                ],[
4102printf ("hello world\n");
4103                ])], ENABLE_GDB_INDEX=TRUE, [])
4104            if test "$ENABLE_GDB_INDEX" = "TRUE"; then
4105                AC_MSG_RESULT( yes )
4106            else
4107                if test "$enable_gdb_index" = "yes"; then
4108                    AC_MSG_ERROR( no )
4109                else
4110                    AC_MSG_RESULT( no )
4111                fi
4112            fi
4113            LDFLAGS=$ldflags_save
4114        fi
4115        CFLAGS=$save_CFLAGS
4116        fi
4117    if test -z "$ENABLE_GDB_INDEX" -a "$test_gdb_index" = "yes" -a -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
4118        AC_MSG_WARN([Linker is not capable of creating gdb index, debugger startup will be slow.])
4119        add_warning "Linker is not capable of creating gdb index, debugger startup will be slow."
4120    fi
4121fi
4122AC_SUBST(ENABLE_GDB_INDEX)
4123
4124if test "$enable_sal_log" = yes; then
4125    ENABLE_SAL_LOG=TRUE
4126fi
4127AC_SUBST(ENABLE_SAL_LOG)
4128
4129dnl Check for enable symbols option
4130dnl ===================================================================
4131AC_MSG_CHECKING([whether to generate debug information])
4132if test -z "$enable_symbols"; then
4133    if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
4134        enable_symbols=yes
4135    else
4136        enable_symbols=no
4137    fi
4138fi
4139if test "$enable_symbols" = yes; then
4140    ENABLE_SYMBOLS_FOR=all
4141    AC_MSG_RESULT([yes])
4142elif test "$enable_symbols" = no; then
4143    ENABLE_SYMBOLS_FOR=
4144    AC_MSG_RESULT([no])
4145else
4146    # Selective debuginfo.
4147    ENABLE_SYMBOLS_FOR="$enable_symbols"
4148    AC_MSG_RESULT([for "$enable_symbols"])
4149fi
4150AC_SUBST(ENABLE_SYMBOLS_FOR)
4151
4152if test -n "$with_android_ndk" -a \( -n "$ENABLE_SYMBOLS" -o -n "$ENABLE_DEBUG" -o -n "$ENABLE_DBGUTIL" \) -a "$ENABLE_DEBUGINFO_FOR" = "all"; then
4153    # Building on Android with full symbols: without enough memory the linker never finishes currently.
4154    AC_MSG_CHECKING([whether enough memory is available for linking])
4155    mem_size=$(grep -o 'MemTotal: *.\+ kB' /proc/meminfo | sed 's/MemTotal: *\(.\+\) kB/\1/')
4156    # Check for 15GB, as Linux reports a bit less than the physical memory size.
4157    if test -n "$mem_size" -a $mem_size -lt 15728640; then
4158        AC_MSG_ERROR([building with full symbols and less than 16GB of memory is not supported])
4159    else
4160        AC_MSG_RESULT([yes])
4161    fi
4162fi
4163
4164AC_MSG_CHECKING([whether to compile with optimization flags])
4165if test -z "$enable_optimized"; then
4166    if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
4167        enable_optimized=no
4168    else
4169        enable_optimized=yes
4170    fi
4171fi
4172if test "$enable_optimized" != no; then
4173    ENABLE_OPTIMIZED=TRUE
4174    AC_MSG_RESULT([yes])
4175else
4176    ENABLE_OPTIMIZED=
4177    AC_MSG_RESULT([no])
4178fi
4179AC_SUBST(ENABLE_OPTIMIZED)
4180
4181#
4182# determine CPUNAME, OS, ...
4183# The USING_X11 flag tells whether the host os uses X by default. Can be overridden with the --without-x option.
4184#
4185case "$host_os" in
4186
4187aix*)
4188    COM=GCC
4189    CPUNAME=POWERPC
4190    USING_X11=TRUE
4191    OS=AIX
4192    RTL_OS=AIX
4193    RTL_ARCH=PowerPC
4194    PLATFORMID=aix_powerpc
4195    P_SEP=:
4196    ;;
4197
4198cygwin*)
4199    COM=MSC
4200    USING_X11=
4201    OS=WNT
4202    RTL_OS=Windows
4203    if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
4204        P_SEP=";"
4205    else
4206        P_SEP=:
4207    fi
4208    case "$host_cpu" in
4209    i*86|x86_64)
4210        if test "$BITNESS_OVERRIDE" = 64; then
4211            CPUNAME=X86_64
4212            RTL_ARCH=X86_64
4213            PLATFORMID=windows_x86_64
4214            WINDOWS_X64=1
4215            SCPDEFS="$SCPDEFS -DWINDOWS_X64"
4216        else
4217            CPUNAME=INTEL
4218            RTL_ARCH=x86
4219            PLATFORMID=windows_x86
4220        fi
4221        ;;
4222    *)
4223        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4224        ;;
4225    esac
4226    SCPDEFS="$SCPDEFS -D_MSC_VER"
4227    ;;
4228
4229darwin*)
4230    COM=GCC
4231    USING_X11=
4232    OS=MACOSX
4233    RTL_OS=MacOSX
4234    P_SEP=:
4235
4236    case "$host_cpu" in
4237    arm)
4238        AC_MSG_ERROR([Can't build 32-bit code for iOS])
4239        ;;
4240    arm64)
4241        OS=iOS
4242        RTL_OS=iOS
4243        if test "$enable_ios_simulator" = "yes"; then
4244            AC_MSG_ERROR([iOS simulator is only available in OSX not iOS])
4245        else
4246            CPUNAME=ARM64
4247            RTL_ARCH=ARM_EABI
4248            PLATFORMID=ios_arm64
4249        fi
4250        ;;
4251    i*86)
4252        AC_MSG_ERROR([Can't build 64-bit code in 32-bit OS])
4253        ;;
4254    x86_64)
4255        if test "$enable_ios_simulator" = "yes"; then
4256            OS=iOS
4257        fi
4258        CPUNAME=X86_64
4259        RTL_ARCH=X86_64
4260        PLATFORMID=macosx_x86_64
4261        ;;
4262    *)
4263        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4264        ;;
4265    esac
4266    ;;
4267
4268dragonfly*)
4269    COM=GCC
4270    USING_X11=TRUE
4271    OS=DRAGONFLY
4272    RTL_OS=DragonFly
4273    P_SEP=:
4274
4275    case "$host_cpu" in
4276    i*86)
4277        CPUNAME=INTEL
4278        RTL_ARCH=x86
4279        PLATFORMID=dragonfly_x86
4280        ;;
4281    x86_64)
4282        CPUNAME=X86_64
4283        RTL_ARCH=X86_64
4284        PLATFORMID=dragonfly_x86_64
4285        ;;
4286    *)
4287        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4288        ;;
4289    esac
4290    ;;
4291
4292freebsd*)
4293    COM=GCC
4294    USING_X11=TRUE
4295    RTL_OS=FreeBSD
4296    OS=FREEBSD
4297    P_SEP=:
4298
4299    case "$host_cpu" in
4300    i*86)
4301        CPUNAME=INTEL
4302        RTL_ARCH=x86
4303        PLATFORMID=freebsd_x86
4304        ;;
4305    x86_64|amd64)
4306        CPUNAME=X86_64
4307        RTL_ARCH=X86_64
4308        PLATFORMID=freebsd_x86_64
4309        ;;
4310    powerpc64)
4311        CPUNAME=POWERPC64
4312        RTL_ARCH=PowerPC_64
4313        PLATFORMID=freebsd_powerpc64
4314        ;;
4315    powerpc64le)
4316        CPUNAME=POWERPC64
4317        RTL_ARCH=PowerPC_64
4318        PLATFORMID=freebsd_powerpc64_le
4319        ;;
4320    powerpc|powerpcspe)
4321        CPUNAME=POWERPC
4322        RTL_ARCH=PowerPC
4323        PLATFORMID=freebsd_powerpc
4324        ;;
4325    *)
4326        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4327        ;;
4328    esac
4329    ;;
4330
4331haiku*)
4332    COM=GCC
4333    USING_X11=
4334    GUIBASE=haiku
4335    RTL_OS=Haiku
4336    OS=HAIKU
4337    P_SEP=:
4338
4339    case "$host_cpu" in
4340    i*86)
4341        CPUNAME=INTEL
4342        RTL_ARCH=x86
4343        PLATFORMID=haiku_x86
4344        ;;
4345    x86_64|amd64)
4346        CPUNAME=X86_64
4347        RTL_ARCH=X86_64
4348        PLATFORMID=haiku_x86_64
4349        ;;
4350    *)
4351        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4352        ;;
4353    esac
4354    ;;
4355
4356kfreebsd*)
4357    COM=GCC
4358    USING_X11=TRUE
4359    OS=LINUX
4360    RTL_OS=kFreeBSD
4361    P_SEP=:
4362
4363    case "$host_cpu" in
4364
4365    i*86)
4366        CPUNAME=INTEL
4367        RTL_ARCH=x86
4368        PLATFORMID=kfreebsd_x86
4369        ;;
4370    x86_64)
4371        CPUNAME=X86_64
4372        RTL_ARCH=X86_64
4373        PLATFORMID=kfreebsd_x86_64
4374        ;;
4375    *)
4376        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4377        ;;
4378    esac
4379    ;;
4380
4381linux-gnu*)
4382    COM=GCC
4383    USING_X11=TRUE
4384    OS=LINUX
4385    RTL_OS=Linux
4386    P_SEP=:
4387
4388    case "$host_cpu" in
4389
4390    aarch64)
4391        CPUNAME=AARCH64
4392        PLATFORMID=linux_aarch64
4393        RTL_ARCH=AARCH64
4394        ;;
4395    alpha)
4396        CPUNAME=AXP
4397        RTL_ARCH=ALPHA
4398        PLATFORMID=linux_alpha
4399        ;;
4400    arm*)
4401        CPUNAME=ARM
4402        EPM_FLAGS="-a arm"
4403        RTL_ARCH=ARM_EABI
4404        PLATFORMID=linux_arm_eabi
4405        case "$host_cpu" in
4406        arm*-linux)
4407            RTL_ARCH=ARM_OABI
4408            PLATFORMID=linux_arm_oabi
4409            ;;
4410        esac
4411        ;;
4412    hppa)
4413        CPUNAME=HPPA
4414        RTL_ARCH=HPPA
4415        EPM_FLAGS="-a hppa"
4416        PLATFORMID=linux_hppa
4417        ;;
4418    i*86)
4419        CPUNAME=INTEL
4420        RTL_ARCH=x86
4421        PLATFORMID=linux_x86
4422        ;;
4423    ia64)
4424        CPUNAME=IA64
4425        RTL_ARCH=IA64
4426        PLATFORMID=linux_ia64
4427        ;;
4428    mips)
4429        CPUNAME=GODSON
4430        RTL_ARCH=MIPS_EB
4431        EPM_FLAGS="-a mips"
4432        PLATFORMID=linux_mips_eb
4433        ;;
4434    mips64)
4435        CPUNAME=GODSON64
4436        RTL_ARCH=MIPS64_EB
4437        EPM_FLAGS="-a mips64"
4438        PLATFORMID=linux_mips64_eb
4439        ;;
4440    mips64el)
4441        CPUNAME=GODSON64
4442        RTL_ARCH=MIPS64_EL
4443        EPM_FLAGS="-a mips64el"
4444        PLATFORMID=linux_mips64_el
4445        ;;
4446    mipsel)
4447        CPUNAME=GODSON
4448        RTL_ARCH=MIPS_EL
4449        EPM_FLAGS="-a mipsel"
4450        PLATFORMID=linux_mips_el
4451        ;;
4452    m68k)
4453        CPUNAME=M68K
4454        RTL_ARCH=M68K
4455        PLATFORMID=linux_m68k
4456        ;;
4457    powerpc)
4458        CPUNAME=POWERPC
4459        RTL_ARCH=PowerPC
4460        PLATFORMID=linux_powerpc
4461        ;;
4462    powerpc64)
4463        CPUNAME=POWERPC64
4464        RTL_ARCH=PowerPC_64
4465        PLATFORMID=linux_powerpc64
4466        ;;
4467    powerpc64le)
4468        CPUNAME=POWERPC64
4469        RTL_ARCH=PowerPC_64_LE
4470        PLATFORMID=linux_powerpc64_le
4471        ;;
4472    sparc)
4473        CPUNAME=SPARC
4474        RTL_ARCH=SPARC
4475        PLATFORMID=linux_sparc
4476        ;;
4477    sparc64)
4478        CPUNAME=SPARC64
4479        RTL_ARCH=SPARC64
4480        PLATFORMID=linux_sparc64
4481        ;;
4482    s390)
4483        CPUNAME=S390
4484        RTL_ARCH=S390
4485        PLATFORMID=linux_s390
4486        ;;
4487    s390x)
4488        CPUNAME=S390X
4489        RTL_ARCH=S390x
4490        PLATFORMID=linux_s390x
4491        ;;
4492    x86_64)
4493        CPUNAME=X86_64
4494        RTL_ARCH=X86_64
4495        PLATFORMID=linux_x86_64
4496        ;;
4497    *)
4498        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4499        ;;
4500    esac
4501    ;;
4502
4503linux-android*)
4504    COM=GCC
4505    USING_X11=
4506    OS=ANDROID
4507    RTL_OS=Android
4508    P_SEP=:
4509
4510    case "$host_cpu" in
4511
4512    arm|armel)
4513        CPUNAME=ARM
4514        RTL_ARCH=ARM_EABI
4515        PLATFORMID=android_arm_eabi
4516        ;;
4517    aarch64)
4518        CPUNAME=AARCH64
4519        RTL_ARCH=AARCH64
4520        PLATFORMID=android_aarch64
4521        ;;
4522    i*86)
4523        CPUNAME=INTEL
4524        RTL_ARCH=x86
4525        PLATFORMID=android_x86
4526        ;;
4527    x86_64)
4528        CPUNAME=X86_64
4529        RTL_ARCH=X86_64
4530        PLATFORMID=android_x86_64
4531        ;;
4532    *)
4533        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4534        ;;
4535    esac
4536    ;;
4537
4538*netbsd*)
4539    COM=GCC
4540    USING_X11=TRUE
4541    OS=NETBSD
4542    RTL_OS=NetBSD
4543    P_SEP=:
4544
4545    case "$host_cpu" in
4546    i*86)
4547        CPUNAME=INTEL
4548        RTL_ARCH=x86
4549        PLATFORMID=netbsd_x86
4550        ;;
4551    powerpc)
4552        CPUNAME=POWERPC
4553        RTL_ARCH=PowerPC
4554        PLATFORMID=netbsd_powerpc
4555        ;;
4556    sparc)
4557        CPUNAME=SPARC
4558        RTL_ARCH=SPARC
4559        PLATFORMID=netbsd_sparc
4560        ;;
4561    x86_64)
4562        CPUNAME=X86_64
4563        RTL_ARCH=X86_64
4564        PLATFORMID=netbsd_x86_64
4565        ;;
4566    *)
4567        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4568        ;;
4569    esac
4570    ;;
4571
4572openbsd*)
4573    COM=GCC
4574    USING_X11=TRUE
4575    OS=OPENBSD
4576    RTL_OS=OpenBSD
4577    P_SEP=:
4578
4579    case "$host_cpu" in
4580    i*86)
4581        CPUNAME=INTEL
4582        RTL_ARCH=x86
4583        PLATFORMID=openbsd_x86
4584        ;;
4585    x86_64)
4586        CPUNAME=X86_64
4587        RTL_ARCH=X86_64
4588        PLATFORMID=openbsd_x86_64
4589        ;;
4590    *)
4591        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4592        ;;
4593    esac
4594    SOLARINC="$SOLARINC -I/usr/local/include"
4595    ;;
4596
4597solaris*)
4598    COM=GCC
4599    USING_X11=TRUE
4600    OS=SOLARIS
4601    RTL_OS=Solaris
4602    P_SEP=:
4603
4604    case "$host_cpu" in
4605    i*86)
4606        CPUNAME=INTEL
4607        RTL_ARCH=x86
4608        PLATFORMID=solaris_x86
4609        ;;
4610    sparc)
4611        CPUNAME=SPARC
4612        RTL_ARCH=SPARC
4613        PLATFORMID=solaris_sparc
4614        ;;
4615    sparc64)
4616        CPUNAME=SPARC64
4617        RTL_ARCH=SPARC64
4618        PLATFORMID=solaris_sparc64
4619        ;;
4620    *)
4621        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4622        ;;
4623    esac
4624    SOLARINC="$SOLARINC -I/usr/local/include"
4625    ;;
4626
4627*)
4628    AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice for!])
4629    ;;
4630esac
4631
4632if test "$with_x" = "no"; then
4633    AC_MSG_ERROR([Use --disable-gui instead. How can we get rid of this option? No idea where it comes from.])
4634fi
4635
4636DISABLE_GUI=""
4637if test "$enable_gui" = "no"; then
4638    if test "$USING_X11" != TRUE; then
4639        AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice with --disable-gui.])
4640    fi
4641    USING_X11=
4642    DISABLE_GUI=TRUE
4643    AC_DEFINE(HAVE_FEATURE_UI,0)
4644    test_cairo=yes
4645fi
4646AC_SUBST(DISABLE_GUI)
4647
4648WORKDIR="${BUILDDIR}/workdir"
4649INSTDIR="${BUILDDIR}/instdir"
4650INSTROOTBASE=${INSTDIR}${INSTROOTBASESUFFIX}
4651INSTROOT=${INSTROOTBASE}${INSTROOTCONTENTSUFFIX}
4652SOLARINC="-I$SRC_ROOT/include $SOLARINC"
4653AC_SUBST(COM)
4654AC_SUBST(CPUNAME)
4655AC_SUBST(RTL_OS)
4656AC_SUBST(RTL_ARCH)
4657AC_SUBST(EPM_FLAGS)
4658AC_SUBST(USING_X11)
4659AC_SUBST([INSTDIR])
4660AC_SUBST([INSTROOT])
4661AC_SUBST([INSTROOTBASE])
4662AC_SUBST(OS)
4663AC_SUBST(P_SEP)
4664AC_SUBST(WORKDIR)
4665AC_SUBST(PLATFORMID)
4666AC_SUBST(WINDOWS_X64)
4667AC_DEFINE_UNQUOTED(WORKDIR,"$WORKDIR")
4668
4669dnl ===================================================================
4670dnl Test which package format to use
4671dnl ===================================================================
4672AC_MSG_CHECKING([which package format to use])
4673if test -n "$with_package_format" -a "$with_package_format" != no; then
4674    for i in $with_package_format; do
4675        case "$i" in
4676        aix | bsd | deb | pkg | rpm | archive | dmg | installed | msi)
4677            ;;
4678        *)
4679            AC_MSG_ERROR([unsupported format $i. Supported by EPM are:
4680aix - AIX software distribution
4681bsd - FreeBSD, NetBSD, or OpenBSD software distribution
4682deb - Debian software distribution
4683pkg - Solaris software distribution
4684rpm - RedHat software distribution
4685
4686LibreOffice additionally supports:
4687archive - .tar.gz or .zip
4688dmg - macOS .dmg
4689installed - installation tree
4690msi - Windows .msi
4691        ])
4692            ;;
4693        esac
4694    done
4695    # fakeroot is needed to ensure correct file ownerships/permissions
4696    # inside deb packages and tar archives created on Linux and Solaris.
4697    if test "$OS" = "LINUX" || test "$OS" = "SOLARIS"; then
4698        AC_PATH_PROG(FAKEROOT, fakeroot, no)
4699        if test "$FAKEROOT" = "no"; then
4700            AC_MSG_ERROR(
4701                [--with-package-format='$with_package_format' requires fakeroot. Install fakeroot.])
4702        fi
4703    fi
4704    PKGFORMAT="$with_package_format"
4705    AC_MSG_RESULT([$PKGFORMAT])
4706else
4707    PKGFORMAT=
4708    AC_MSG_RESULT([none])
4709fi
4710AC_SUBST(PKGFORMAT)
4711
4712dnl ===================================================================
4713dnl Set up a different compiler to produce tools to run on the build
4714dnl machine when doing cross-compilation
4715dnl ===================================================================
4716
4717m4_pattern_allow([PKG_CONFIG_FOR_BUILD])
4718m4_pattern_allow([PKG_CONFIG_LIBDIR])
4719if test "$cross_compiling" = "yes"; then
4720    AC_MSG_CHECKING([for BUILD platform configuration])
4721    echo
4722    rm -rf CONF-FOR-BUILD config_build.mk
4723    mkdir CONF-FOR-BUILD
4724    # Here must be listed all files needed when running the configure script. In particular, also
4725    # those expanded by the AC_CONFIG_FILES() call near the end of this configure.ac. For clarity,
4726    # keep them in the same order as there.
4727    (cd $SRC_ROOT && tar cf - \
4728        config.guess \
4729        bin/get_config_variables \
4730        solenv/bin/getcompver.awk \
4731        solenv/inc/langlist.mk \
4732        download.lst \
4733        config_host.mk.in \
4734        config_host_lang.mk.in \
4735        Makefile.in \
4736        bin/bffvalidator.sh.in \
4737        bin/odfvalidator.sh.in \
4738        bin/officeotron.sh.in \
4739        instsetoo_native/util/openoffice.lst.in \
4740        config_host/*.in \
4741        sysui/desktop/macosx/Info.plist.in) \
4742    | (cd CONF-FOR-BUILD && tar xf -)
4743    cp configure CONF-FOR-BUILD
4744    test -d config_build && cp -p config_build/*.h CONF-FOR-BUILD/config_host 2>/dev/null
4745    (
4746    unset COM USING_X11 OS CPUNAME
4747    unset CC CXX SYSBASE CFLAGS
4748    unset AR NM OBJDUMP PKG_CONFIG RANLIB READELF STRIP
4749    unset CPPUNIT_CFLAGS CPPUNIT_LIBS
4750    unset LIBXML_CFLAGS LIBXML_LIBS LIBXSLT_CFLAGS LIBXSLT_LIBS XSLTPROC PKG_CONFIG_LIBDIR
4751    if test -n "$CC_FOR_BUILD"; then
4752        export CC="$CC_FOR_BUILD"
4753        CC_BASE=`first_arg_basename "$CC"`
4754    fi
4755    if test -n "$CXX_FOR_BUILD"; then
4756        export CXX="$CXX_FOR_BUILD"
4757        CXX_BASE=`first_arg_basename "$CXX"`
4758    fi
4759    test -n "$PKG_CONFIG_FOR_BUILD" && export PKG_CONFIG="$PKG_CONFIG_FOR_BUILD"
4760    cd CONF-FOR-BUILD
4761    sub_conf_opts=""
4762    test -n "$enable_ccache" && sub_conf_opts="$sub_conf_opts --enable-ccache=$enable_ccache"
4763    test -n "$with_ant_home" && sub_conf_opts="$sub_conf_opts --with-ant-home=$with_ant_home"
4764    test $with_junit = no && sub_conf_opts="$sub_conf_opts --without-junit"
4765    test -n "$TARFILE_LOCATION" && sub_conf_opts="$sub_conf_opts --with-external-tar=$TARFILE_LOCATION"
4766    test "$with_system_icu_for_build" = "yes" -o "$with_system_icu_for_build" = "force" && sub_conf_opts="$sub_conf_opts --with-system-icu"
4767    test "$build_for_ios" = "YES" && sub_conf_opts="$sub_conf_opts build_for_ios=YES"
4768    sub_conf_opts="$sub_conf_opts $with_build_platform_configure_options"
4769    # Don't bother having configure look for stuff not needed for the build platform anyway
4770    ./configure \
4771        --disable-cups \
4772        --disable-gstreamer-1-0 \
4773        --disable-gtk3 \
4774        --disable-pdfimport \
4775        --disable-postgresql-sdbc \
4776        --with-parallelism="$with_parallelism" \
4777        --without-doxygen \
4778        --without-java \
4779        $sub_conf_opts \
4780        --srcdir=$srcdir \
4781        2>&1 | sed -e 's/^/    /'
4782    test -f ./config_host.mk 2>/dev/null || exit
4783    cp config_host.mk ../config_build.mk
4784    cp config_host_lang.mk ../config_build_lang.mk
4785    mv config.log ../config.Build.log
4786    mkdir -p ../config_build
4787    mv config_host/*.h ../config_build
4788    . ./bin/get_config_variables CC CXX INSTDIR INSTROOT LIBO_BIN_FOLDER LIBO_LIB_FOLDER LIBO_URE_LIB_FOLDER LIBO_URE_MISC_FOLDER OS PATH SDKDIRNAME SYSTEM_LIBXML SYSTEM_LIBXSLT WORKDIR
4789
4790    for V in CC CXX LIBO_BIN_FOLDER LIBO_LIB_FOLDER LIBO_URE_LIB_FOLDER LIBO_URE_MISC_FOLDER OS SDKDIRNAME SYSTEM_LIBXML SYSTEM_LIBXSLT; do
4791        VV='$'$V
4792        VV=`eval "echo $VV"`
4793        if test -n "$VV"; then
4794            line=${V}_FOR_BUILD='${'${V}_FOR_BUILD:-$VV'}'
4795            echo "$line" >>build-config
4796        fi
4797    done
4798
4799    for V in INSTDIR INSTROOT WORKDIR; do
4800        VV='$'$V
4801        VV=`eval "echo $VV"`
4802        VV=`echo $VV | sed -e "s,/CONF-FOR-BUILD/\([[a-z]]*\),/\1_for_build,g"`
4803        if test -n "$VV"; then
4804            line="${V}_FOR_BUILD='$VV'"
4805            echo "$line" >>build-config
4806        fi
4807    done
4808
4809    line=`echo "LO_PATH_FOR_BUILD=$PATH" | sed -e 's,/CONF-FOR-BUILD,,g'`
4810    echo "$line" >>build-config
4811
4812    )
4813    test -f CONF-FOR-BUILD/build-config || AC_MSG_ERROR([Running configure script for BUILD system failed, see CONF-FOR-BUILD/config.log])
4814    test -f config_build.mk || AC_MSG_ERROR([A file called config_build.mk was supposed to have been copied here, but it isn't found])
4815    perl -pi -e 's,/(workdir|instdir)(/|$),/\1_for_build\2,g;' \
4816             -e 's,/CONF-FOR-BUILD,,g;' config_build.mk
4817
4818    eval `cat CONF-FOR-BUILD/build-config`
4819
4820    AC_MSG_RESULT([checking for BUILD platform configuration... done])
4821
4822    rm -rf CONF-FOR-BUILD
4823else
4824    OS_FOR_BUILD="$OS"
4825    CC_FOR_BUILD="$CC"
4826    CXX_FOR_BUILD="$CXX"
4827    INSTDIR_FOR_BUILD="$INSTDIR"
4828    INSTROOT_FOR_BUILD="$INSTROOT"
4829    LIBO_BIN_FOLDER_FOR_BUILD="$LIBO_BIN_FOLDER"
4830    LIBO_LIB_FOLDER_FOR_BUILD="$LIBO_LIB_FOLDER"
4831    LIBO_URE_LIB_FOLDER_FOR_BUILD="$LIBO_URE_LIB_FOLDER"
4832    LIBO_URE_MISC_FOLDER_FOR_BUILD="$LIBO_URE_MISC_FOLDER"
4833    SDKDIRNAME_FOR_BUILD="$SDKDIRNAME"
4834    WORKDIR_FOR_BUILD="$WORKDIR"
4835fi
4836AC_SUBST(OS_FOR_BUILD)
4837AC_SUBST(INSTDIR_FOR_BUILD)
4838AC_SUBST(INSTROOT_FOR_BUILD)
4839AC_SUBST(LIBO_BIN_FOLDER_FOR_BUILD)
4840AC_SUBST(LIBO_LIB_FOLDER_FOR_BUILD)
4841AC_SUBST(LIBO_URE_LIB_FOLDER_FOR_BUILD)
4842AC_SUBST(LIBO_URE_MISC_FOLDER_FOR_BUILD)
4843AC_SUBST(SDKDIRNAME_FOR_BUILD)
4844AC_SUBST(WORKDIR_FOR_BUILD)
4845
4846dnl ===================================================================
4847dnl Check for syslog header
4848dnl ===================================================================
4849AC_CHECK_HEADER(syslog.h, AC_DEFINE(HAVE_SYSLOG_H))
4850
4851dnl Set the ENABLE_WERROR variable. (Activate --enable-werror)
4852dnl ===================================================================
4853AC_MSG_CHECKING([whether to turn warnings to errors])
4854if test -n "$enable_werror" -a "$enable_werror" != "no"; then
4855    ENABLE_WERROR="TRUE"
4856    AC_MSG_RESULT([yes])
4857else
4858    if test -n "$LODE_HOME" -a -z "$enable_werror"; then
4859        ENABLE_WERROR="TRUE"
4860        AC_MSG_RESULT([yes])
4861    else
4862        AC_MSG_RESULT([no])
4863    fi
4864fi
4865AC_SUBST(ENABLE_WERROR)
4866
4867dnl Check for --enable-assert-always-abort, set ASSERT_ALWAYS_ABORT
4868dnl ===================================================================
4869AC_MSG_CHECKING([whether to have assert() failures abort even without --enable-debug])
4870if test -z "$enable_assert_always_abort"; then
4871   if test "$ENABLE_DEBUG" = TRUE; then
4872       enable_assert_always_abort=yes
4873   else
4874       enable_assert_always_abort=no
4875   fi
4876fi
4877if test "$enable_assert_always_abort" = "yes"; then
4878    ASSERT_ALWAYS_ABORT="TRUE"
4879    AC_MSG_RESULT([yes])
4880else
4881    ASSERT_ALWAYS_ABORT="FALSE"
4882    AC_MSG_RESULT([no])
4883fi
4884AC_SUBST(ASSERT_ALWAYS_ABORT)
4885
4886# Determine whether to use ooenv for the instdir installation
4887# ===================================================================
4888if test $_os != "WINNT" -a $_os != "Darwin"; then
4889    AC_MSG_CHECKING([whether to use ooenv for the instdir installation])
4890    if test "$enable_ooenv" = "no"; then
4891        AC_MSG_RESULT([no])
4892    else
4893        ENABLE_OOENV="TRUE"
4894        AC_MSG_RESULT([yes])
4895    fi
4896fi
4897AC_SUBST(ENABLE_OOENV)
4898
4899if test "$USING_X11" != TRUE; then
4900    # be sure to do not mess with unneeded stuff
4901    test_randr=no
4902    test_xrender=no
4903    test_cups=no
4904    test_dbus=no
4905    build_gstreamer_1_0=no
4906    test_kf5=no
4907    test_qt5=no
4908    test_gtk3_kde5=no
4909    enable_cairo_canvas=no
4910fi
4911
4912if test "$OS" = "HAIKU"; then
4913    enable_cairo_canvas=yes
4914    test_kf5=yes
4915fi
4916
4917if test "$test_kf5" = "yes" -a "$enable_kde5" = "yes"; then
4918    AC_MSG_WARN([The kde5 VCL plugin was renamed to kf5. Please update your configuration to use --enable-kf5, as --enable-kde5 will be removed after the next major release!])
4919    add_warning "The kde5 VCL plugin was renamed to kf5. Please update your configuration to use --enable-kf5, as --enable-kde5 will be removed after the next major release!"
4920    enable_kf5=yes
4921fi
4922
4923if test "$test_kf5" = "yes"; then
4924    test_qt5=yes
4925fi
4926
4927if test "$test_kf5" = "yes" -a "$enable_kf5" = "yes"; then
4928    if test "$enable_qt5" = "no"; then
4929        AC_MSG_ERROR([KF5 support depends on QT5, so it conflicts with --disable-qt5])
4930    else
4931        enable_qt5=yes
4932    fi
4933fi
4934
4935dnl ===================================================================
4936dnl check for cups support
4937dnl ===================================================================
4938ENABLE_CUPS=""
4939
4940if test "$enable_cups" = "no"; then
4941    test_cups=no
4942fi
4943
4944AC_MSG_CHECKING([whether to enable CUPS support])
4945if test "$test_cups" = "yes"; then
4946    ENABLE_CUPS="TRUE"
4947    AC_MSG_RESULT([yes])
4948
4949    AC_MSG_CHECKING([whether cups support is present])
4950    AC_CHECK_LIB([cups], [cupsPrintFiles], [:])
4951    AC_CHECK_HEADER(cups/cups.h, AC_DEFINE(HAVE_CUPS_H))
4952    if test "$ac_cv_lib_cups_cupsPrintFiles" != "yes" -o "$ac_cv_header_cups_cups_h" != "yes"; then
4953        AC_MSG_ERROR([Could not find CUPS. Install libcups2-dev or cups-devel.])
4954    fi
4955
4956else
4957    AC_MSG_RESULT([no])
4958fi
4959
4960AC_SUBST(ENABLE_CUPS)
4961
4962# fontconfig checks
4963if test "$test_fontconfig" = "yes"; then
4964    PKG_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.4.1])
4965    SYSTEM_FONTCONFIG=TRUE
4966    FilterLibs "${FONTCONFIG_LIBS}"
4967    FONTCONFIG_LIBS="${filteredlibs}"
4968fi
4969AC_SUBST(FONTCONFIG_CFLAGS)
4970AC_SUBST(FONTCONFIG_LIBS)
4971AC_SUBST([SYSTEM_FONTCONFIG])
4972
4973dnl whether to find & fetch external tarballs?
4974dnl ===================================================================
4975if test -z "$TARFILE_LOCATION" -a -n "$LODE_HOME" ; then
4976   if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
4977       TARFILE_LOCATION="`cygpath -m $LODE_HOME/ext_tar`"
4978   else
4979       TARFILE_LOCATION="$LODE_HOME/ext_tar"
4980   fi
4981fi
4982if test -z "$TARFILE_LOCATION"; then
4983    if test -d "$SRC_ROOT/src" ; then
4984        mv "$SRC_ROOT/src" "$SRC_ROOT/external/tarballs"
4985        ln -s "$SRC_ROOT/external/tarballs" "$SRC_ROOT/src"
4986    fi
4987    TARFILE_LOCATION="$SRC_ROOT/external/tarballs"
4988else
4989    AbsolutePath "$TARFILE_LOCATION"
4990    PathFormat "${absolute_path}"
4991    TARFILE_LOCATION="${formatted_path}"
4992fi
4993AC_SUBST(TARFILE_LOCATION)
4994
4995AC_MSG_CHECKING([whether we want to fetch tarballs])
4996if test "$enable_fetch_external" != "no"; then
4997    if test "$with_all_tarballs" = "yes"; then
4998        AC_MSG_RESULT([yes, all of them])
4999        DO_FETCH_TARBALLS="ALL"
5000    else
5001        AC_MSG_RESULT([yes, if we use them])
5002        DO_FETCH_TARBALLS="TRUE"
5003    fi
5004else
5005    AC_MSG_RESULT([no])
5006    DO_FETCH_TARBALLS=
5007fi
5008AC_SUBST(DO_FETCH_TARBALLS)
5009
5010AC_MSG_CHECKING([whether to build help])
5011if test -n "$with_help" -a "$with_help" != "no" -a $_os != iOS -a $_os != Android; then
5012    BUILD_TYPE="$BUILD_TYPE HELP"
5013    GIT_NEEDED_SUBMODULES="helpcontent2 $GIT_NEEDED_SUBMODULES"
5014    case "$with_help" in
5015    "html")
5016        ENABLE_HTMLHELP=TRUE
5017        SCPDEFS="$SCPDEFS -DWITH_HELP"
5018        AC_MSG_RESULT([HTML])
5019        ;;
5020    "online")
5021        ENABLE_HTMLHELP=TRUE
5022        HELP_ONLINE=TRUE
5023        AC_MSG_RESULT([HTML])
5024        ;;
5025    yes)
5026        SCPDEFS="$SCPDEFS -DWITH_HELP"
5027        AC_MSG_RESULT([yes])
5028        ;;
5029    *)
5030        AC_MSG_ERROR([Unknown --with-help=$with_help])
5031        ;;
5032    esac
5033else
5034    AC_MSG_RESULT([no])
5035fi
5036AC_SUBST([ENABLE_HTMLHELP])
5037AC_SUBST([HELP_ONLINE])
5038
5039AC_MSG_CHECKING([whether to enable xapian-omega support for help])
5040if test -n "$with_omindex" -a "$with_omindex" != "no" -a $_os != iOS -a $_os != Android; then
5041    BUILD_TYPE="$BUILD_TYPE HELP"
5042    GIT_NEEDED_SUBMODULES="helpcontent2 $GIT_NEEDED_SUBMODULES"
5043    case "$with_omindex" in
5044    "server")
5045        ENABLE_HTMLHELP=TRUE
5046        HELP_ONLINE=TRUE
5047        HELP_OMINDEX_PAGE=TRUE
5048        AC_MSG_RESULT([SERVER])
5049        ;;
5050    "noxap")
5051        ENABLE_HTMLHELP=TRUE
5052        HELP_ONLINE=TRUE
5053        HELP_OMINDEX_PAGE=FALSE
5054        AC_MSG_RESULT([NOXAP])
5055        ;;
5056    *)
5057        AC_MSG_ERROR([Unknown --with-omindex=$with_omindex])
5058        ;;
5059    esac
5060else
5061    HELP_OMINDEX_PAGE=FALSE
5062    AC_MSG_RESULT([no])
5063fi
5064AC_SUBST([ENABLE_HTMLHELP])
5065AC_SUBST([HELP_OMINDEX_PAGE])
5066AC_SUBST([HELP_ONLINE])
5067
5068
5069dnl Test whether to include MySpell dictionaries
5070dnl ===================================================================
5071AC_MSG_CHECKING([whether to include MySpell dictionaries])
5072if test "$with_myspell_dicts" = "yes"; then
5073    AC_MSG_RESULT([yes])
5074    WITH_MYSPELL_DICTS=TRUE
5075    BUILD_TYPE="$BUILD_TYPE DICTIONARIES"
5076    GIT_NEEDED_SUBMODULES="dictionaries $GIT_NEEDED_SUBMODULES"
5077else
5078    AC_MSG_RESULT([no])
5079    WITH_MYSPELL_DICTS=
5080fi
5081AC_SUBST(WITH_MYSPELL_DICTS)
5082
5083# There are no "system" myspell, hyphen or mythes dictionaries on macOS, Windows, Android or iOS.
5084if test $_os = Darwin -o $_os = WINNT -o $_os = iOS -o $_os = Android; then
5085    if test "$with_system_dicts" = yes; then
5086        AC_MSG_ERROR([There are no system dicts on this OS in the formats the 3rd-party libs we use expect]);
5087    fi
5088    with_system_dicts=no
5089fi
5090
5091AC_MSG_CHECKING([whether to use dicts from external paths])
5092if test -z "$with_system_dicts" -o "$with_system_dicts" != "no"; then
5093    AC_MSG_RESULT([yes])
5094    SYSTEM_DICTS=TRUE
5095    AC_MSG_CHECKING([for spelling dictionary directory])
5096    if test -n "$with_external_dict_dir"; then
5097        DICT_SYSTEM_DIR=file://$with_external_dict_dir
5098    else
5099        DICT_SYSTEM_DIR=file:///usr/share/hunspell
5100        if test ! -d /usr/share/hunspell -a -d /usr/share/myspell; then
5101            DICT_SYSTEM_DIR=file:///usr/share/myspell
5102        fi
5103    fi
5104    AC_MSG_RESULT([$DICT_SYSTEM_DIR])
5105    AC_MSG_CHECKING([for hyphenation patterns directory])
5106    if test -n "$with_external_hyph_dir"; then
5107        HYPH_SYSTEM_DIR=file://$with_external_hyph_dir
5108    else
5109        HYPH_SYSTEM_DIR=file:///usr/share/hyphen
5110    fi
5111    AC_MSG_RESULT([$HYPH_SYSTEM_DIR])
5112    AC_MSG_CHECKING([for thesaurus directory])
5113    if test -n "$with_external_thes_dir"; then
5114        THES_SYSTEM_DIR=file://$with_external_thes_dir
5115    else
5116        THES_SYSTEM_DIR=file:///usr/share/mythes
5117    fi
5118    AC_MSG_RESULT([$THES_SYSTEM_DIR])
5119else
5120    AC_MSG_RESULT([no])
5121    SYSTEM_DICTS=
5122fi
5123AC_SUBST(SYSTEM_DICTS)
5124AC_SUBST(DICT_SYSTEM_DIR)
5125AC_SUBST(HYPH_SYSTEM_DIR)
5126AC_SUBST(THES_SYSTEM_DIR)
5127
5128dnl ===================================================================
5129dnl Precompiled headers.
5130ENABLE_PCH=""
5131AC_MSG_CHECKING([whether to enable pch feature])
5132if test -z "$enable_pch"; then
5133    if test "$_os" = "WINNT"; then
5134        # Enabled by default on Windows.
5135        enable_pch=yes
5136    else
5137        enable_pch=no
5138    fi
5139fi
5140if test "$enable_pch" != "no" -a "$_os" != "WINNT" -a "$GCC" != "yes" ; then
5141    AC_MSG_ERROR([Precompiled header not yet supported for your platform/compiler])
5142fi
5143if test "$enable_pch" = "system"; then
5144    ENABLE_PCH="1"
5145    AC_MSG_RESULT([yes (system headers)])
5146elif test "$enable_pch" = "base"; then
5147    ENABLE_PCH="2"
5148    AC_MSG_RESULT([yes (system and base headers)])
5149elif test "$enable_pch" = "normal"; then
5150    ENABLE_PCH="3"
5151    AC_MSG_RESULT([yes (normal)])
5152elif test "$enable_pch" = "full"; then
5153    ENABLE_PCH="4"
5154    AC_MSG_RESULT([yes (full)])
5155elif test "$enable_pch" = "yes"; then
5156    # Pick a suitable default.
5157    if test "$GCC" = "yes"; then
5158        # With Clang and GCC higher levels do not seem to make a noticeable improvement,
5159        # while making the PCHs larger and rebuilds more likely.
5160        ENABLE_PCH="2"
5161        AC_MSG_RESULT([yes (system and base headers)])
5162    else
5163        # With MSVC the highest level makes a significant difference,
5164        # and it was the default when there used to be no PCH levels.
5165        ENABLE_PCH="4"
5166        AC_MSG_RESULT([yes (full)])
5167    fi
5168elif test "$enable_pch" = "no"; then
5169    AC_MSG_RESULT([no])
5170else
5171    AC_MSG_ERROR([Unknown value for --enable-pch])
5172fi
5173AC_SUBST(ENABLE_PCH)
5174# ccache 3.7.1 and older do not properly detect/handle -include .gch in CCACHE_DEPEND mode
5175if test -n "$ENABLE_PCH" -a -n "$CCACHE_DEPEND_MODE" -a "$GCC" = "yes" -a "$COM_IS_CLANG" != "TRUE"; then
5176    AC_PATH_PROG([CCACHE_BIN],[ccache],[not found])
5177    if test "$CCACHE_BIN" != "not found"; then
5178        AC_MSG_CHECKING([ccache version])
5179        CCACHE_VERSION=`"$CCACHE_BIN" -V | "$AWK" '/^ccache version/{print $3}'`
5180        CCACHE_NUMVER=`echo $CCACHE_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
5181        AC_MSG_RESULT([$CCACHE_VERSION])
5182        AC_MSG_CHECKING([whether ccache depend mode works properly with GCC PCH])
5183        if test "$CCACHE_NUMVER" -gt "030701"; then
5184            AC_MSG_RESULT([yes])
5185        else
5186            AC_MSG_RESULT([no (not newer than 3.7.1)])
5187            CCACHE_DEPEND_MODE=
5188        fi
5189    fi
5190fi
5191
5192TAB=`printf '\t'`
5193
5194AC_MSG_CHECKING([the GNU Make version])
5195_make_version=`$GNUMAKE --version | grep GNU | $GREP -v GPL | $SED -e 's@^[[^0-9]]*@@' -e 's@ .*@@' -e 's@,.*@@'`
5196_make_longver=`echo $_make_version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
5197if test "$_make_longver" -ge "038200"; then
5198    AC_MSG_RESULT([$GNUMAKE $_make_version])
5199
5200elif test "$_make_longver" -ge "038100"; then
5201    if test "$build_os" = "cygwin"; then
5202        AC_MSG_ERROR([failed ($GNUMAKE version >= 3.82 needed])
5203    fi
5204    AC_MSG_RESULT([$GNUMAKE $_make_version])
5205
5206    dnl ===================================================================
5207    dnl Search all the common names for sha1sum
5208    dnl ===================================================================
5209    AC_CHECK_PROGS(SHA1SUM, sha1sum sha1 shasum openssl)
5210    if test -z "$SHA1SUM"; then
5211        AC_MSG_ERROR([install the appropriate SHA-1 checksumming program for this OS])
5212    elif test "$SHA1SUM" = "openssl"; then
5213        SHA1SUM="openssl sha1"
5214    fi
5215    AC_MSG_CHECKING([for GNU Make bug 20033])
5216    TESTGMAKEBUG20033=`mktemp -d tmp.XXXXXX`
5217    $SED -e "s/<TAB>/$TAB/g" > $TESTGMAKEBUG20033/Makefile << EOF
5218A := \$(wildcard *.a)
5219
5220.PHONY: all
5221all: \$(A:.a=.b)
5222<TAB>@echo survived bug20033.
5223
5224.PHONY: setup
5225setup:
5226<TAB>@touch 1.a 2.a 3.a 4.a 5.a 6.a
5227
5228define d1
5229@echo lala \$(1)
5230@sleep 1
5231endef
5232
5233define d2
5234@echo tyty \$(1)
5235@sleep 1
5236endef
5237
5238%.b : %.a
5239<TAB>\$(eval CHECKSUM := \$(word 1,\$(shell cat \$^ | $SHA1SUM))) \$(if \$(wildcard \$(CACHEDIR)/\$(CHECKSUM)),\
5240<TAB>\$(call d1,\$(CHECKSUM)),\
5241<TAB>\$(call d2,\$(CHECKSUM)))
5242EOF
5243    if test -z "`(cd $TESTGMAKEBUG20033 && $GNUMAKE setup && $GNUMAKE -j)|grep survived`"; then
5244        no_parallelism_make="YES"
5245        AC_MSG_RESULT([yes, disable parallelism])
5246    else
5247        AC_MSG_RESULT([no, keep parallelism enabled])
5248    fi
5249    rm -rf $TESTGMAKEBUG20033
5250else
5251    AC_MSG_ERROR([failed ($GNUMAKE version >= 3.81 needed])
5252fi
5253
5254# find if gnumake support file function
5255AC_MSG_CHECKING([whether GNU Make supports the 'file' function])
5256TESTGMAKEFILEFUNC="`mktemp -d -t tst.XXXXXX`"
5257if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
5258    TESTGMAKEFILEFUNC=`cygpath -m $TESTGMAKEFILEFUNC`
5259fi
5260$SED -e "s/<TAB>/$TAB/" > $TESTGMAKEFILEFUNC/Makefile << EOF
5261\$(file >test.txt,Success )
5262
5263.PHONY: all
5264all:
5265<TAB>@cat test.txt
5266
5267EOF
5268$GNUMAKE -C $TESTGMAKEFILEFUNC 2>/dev/null 1>&2
5269if test -f $TESTGMAKEFILEFUNC/test.txt; then
5270    HAVE_GNUMAKE_FILE_FUNC=TRUE
5271    AC_MSG_RESULT([yes])
5272else
5273    AC_MSG_RESULT([no])
5274fi
5275rm -rf $TESTGMAKEFILEFUNC
5276AC_SUBST(HAVE_GNUMAKE_FILE_FUNC)
5277AC_SUBST(GNUMAKE_WIN_NATIVE)
5278
5279_make_ver_check=`$GNUMAKE --version | grep "Built for Windows"`
5280STALE_MAKE=
5281if test "$_make_ver_check" = ""; then
5282   STALE_MAKE=TRUE
5283fi
5284
5285HAVE_LD_HASH_STYLE=FALSE
5286WITH_LINKER_HASH_STYLE=
5287AC_MSG_CHECKING([for --hash-style gcc linker support])
5288if test "$GCC" = "yes"; then
5289    if test -z "$with_linker_hash_style" -o "$with_linker_hash_style" = "yes"; then
5290        hash_styles="gnu sysv"
5291    elif test "$with_linker_hash_style" = "no"; then
5292        hash_styles=
5293    else
5294        hash_styles="$with_linker_hash_style"
5295    fi
5296
5297    for hash_style in $hash_styles; do
5298        test "$HAVE_LD_HASH_STYLE" = "TRUE" && continue
5299        hash_style_ldflags_save=$LDFLAGS
5300        LDFLAGS="$LDFLAGS -Wl,--hash-style=$hash_style"
5301
5302        AC_RUN_IFELSE([AC_LANG_PROGRAM(
5303            [
5304#include <stdio.h>
5305            ],[
5306printf ("");
5307            ])],
5308            [
5309                  HAVE_LD_HASH_STYLE=TRUE
5310                  WITH_LINKER_HASH_STYLE=$hash_style
5311            ],
5312            [HAVE_LD_HASH_STYLE=FALSE],
5313            [HAVE_LD_HASH_STYLE=FALSE])
5314        LDFLAGS=$hash_style_ldflags_save
5315    done
5316
5317    if test "$HAVE_LD_HASH_STYLE" = "TRUE"; then
5318        AC_MSG_RESULT( $WITH_LINKER_HASH_STYLE )
5319    else
5320        AC_MSG_RESULT( no )
5321    fi
5322    LDFLAGS=$hash_style_ldflags_save
5323else
5324    AC_MSG_RESULT( no )
5325fi
5326AC_SUBST(HAVE_LD_HASH_STYLE)
5327AC_SUBST(WITH_LINKER_HASH_STYLE)
5328
5329dnl ===================================================================
5330dnl Check whether there's a Perl version available.
5331dnl ===================================================================
5332if test -z "$with_perl_home"; then
5333    AC_PATH_PROG(PERL, perl)
5334else
5335    test "$build_os" = "cygwin" && with_perl_home=`cygpath -u "$with_perl_home"`
5336    _perl_path="$with_perl_home/bin/perl"
5337    if test -x "$_perl_path"; then
5338        PERL=$_perl_path
5339    else
5340        AC_MSG_ERROR([$_perl_path not found])
5341    fi
5342fi
5343
5344dnl ===================================================================
5345dnl Testing for Perl version 5 or greater.
5346dnl $] is the Perl version variable, it is returned as an integer
5347dnl ===================================================================
5348if test "$PERL"; then
5349    AC_MSG_CHECKING([the Perl version])
5350    ${PERL} -e "exit($]);"
5351    _perl_version=$?
5352    if test "$_perl_version" -lt 5; then
5353        AC_MSG_ERROR([found Perl $_perl_version, use Perl 5])
5354    fi
5355    AC_MSG_RESULT([Perl $_perl_version])
5356else
5357    AC_MSG_ERROR([Perl not found, install Perl 5])
5358fi
5359
5360dnl ===================================================================
5361dnl Testing for required Perl modules
5362dnl ===================================================================
5363
5364AC_MSG_CHECKING([for required Perl modules])
5365perl_use_string="use Cwd ; use Digest::MD5"
5366if test "$_os" = "WINNT"; then
5367    if test -n "$PKGFORMAT"; then
5368        for i in $PKGFORMAT; do
5369            case "$i" in
5370            msi)
5371                # for getting fonts versions to use in MSI
5372                perl_use_string="$perl_use_string ; use Font::TTF::Font"
5373                ;;
5374            esac
5375        done
5376    fi
5377fi
5378if test "$with_system_hsqldb" = "yes"; then
5379    perl_use_string="$perl_use_string ; use Archive::Zip"
5380fi
5381if $PERL -e "$perl_use_string">/dev/null 2>&1; then
5382    AC_MSG_RESULT([all modules found])
5383else
5384    AC_MSG_RESULT([failed to find some modules])
5385    # Find out which modules are missing.
5386    for i in $perl_use_string; do
5387        if test "$i" != "use" -a "$i" != ";"; then
5388            if ! $PERL -e "use $i;">/dev/null 2>&1; then
5389                missing_perl_modules="$missing_perl_modules $i"
5390            fi
5391        fi
5392    done
5393    AC_MSG_ERROR([
5394    The missing Perl modules are: $missing_perl_modules
5395    Install them as superuser/administrator with "cpan -i $missing_perl_modules"])
5396fi
5397
5398dnl ===================================================================
5399dnl Check for pkg-config
5400dnl ===================================================================
5401if test "$_os" != "WINNT"; then
5402    PKG_PROG_PKG_CONFIG
5403fi
5404
5405if test "$_os" != "WINNT"; then
5406
5407    # If you use CC=/path/to/compiler/foo-gcc or even CC="ccache
5408    # /path/to/compiler/foo-gcc" you need to set the AR etc env vars
5409    # explicitly. Or put /path/to/compiler in PATH yourself.
5410
5411    # Use wrappers for LTO
5412    if test "$ENABLE_LTO" = "TRUE" -a "$COM_IS_CLANG" != "TRUE"; then
5413        AC_CHECK_TOOL(AR,gcc-ar)
5414        AC_CHECK_TOOL(NM,gcc-nm)
5415        AC_CHECK_TOOL(RANLIB,gcc-ranlib)
5416    else
5417        AC_CHECK_TOOL(AR,ar)
5418        AC_CHECK_TOOL(NM,nm)
5419        AC_CHECK_TOOL(RANLIB,ranlib)
5420    fi
5421    AC_CHECK_TOOL(OBJDUMP,objdump)
5422    AC_CHECK_TOOL(READELF,readelf)
5423    AC_CHECK_TOOL(STRIP,strip)
5424    if test "$_os" = "WINNT"; then
5425        AC_CHECK_TOOL(DLLTOOL,dlltool)
5426        AC_CHECK_TOOL(WINDRES,windres)
5427    fi
5428fi
5429AC_SUBST(AR)
5430AC_SUBST(DLLTOOL)
5431AC_SUBST(NM)
5432AC_SUBST(OBJDUMP)
5433AC_SUBST(PKG_CONFIG)
5434AC_SUBST(RANLIB)
5435AC_SUBST(READELF)
5436AC_SUBST(STRIP)
5437AC_SUBST(WINDRES)
5438
5439dnl ===================================================================
5440dnl pkg-config checks on macOS
5441dnl ===================================================================
5442
5443if test $_os = Darwin; then
5444    AC_MSG_CHECKING([for bogus pkg-config])
5445    if test -n "$PKG_CONFIG"; then
5446        if test "$PKG_CONFIG" = /usr/bin/pkg-config && ls -l /usr/bin/pkg-config | $GREP -q Mono.framework; then
5447            AC_MSG_ERROR([yes, from Mono. This *will* break the build. Please remove or hide $PKG_CONFIG])
5448        else
5449            if test "$enable_bogus_pkg_config" = "yes"; then
5450                AC_MSG_RESULT([yes, user-approved from unknown origin.])
5451            else
5452                AC_MSG_ERROR([yes, from unknown origin. This *will* break the build. Please modify your PATH variable so that $PKG_CONFIG is no longer found by configure scripts.])
5453            fi
5454        fi
5455    else
5456        AC_MSG_RESULT([no, good])
5457    fi
5458fi
5459
5460find_csc()
5461{
5462    # Return value: $csctest
5463
5464    unset csctest
5465
5466    reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/NET Framework Setup/NDP/v4/Client/InstallPath"
5467    if test -n "$regvalue"; then
5468        csctest=$regvalue
5469        return
5470    fi
5471}
5472
5473find_al()
5474{
5475    # Return value: $altest
5476
5477    unset altest
5478
5479    # We need this check to detect 4.6.1 or above.
5480    for ver in 4.8 4.7.2 4.7.1 4.7 4.6.2 4.6.1; do
5481        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/NETFXSDK/$ver/WinSDK-NetFx40Tools/InstallationFolder"
5482        if test -n "$regvalue" -a \( -f "$regvalue/al.exe" -o -f "$regvalue/bin/al.exe" \); then
5483            altest=$regvalue
5484            return
5485        fi
5486    done
5487
5488    for x in `ls /proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft\ SDKs/Windows`; do
5489        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/$x/WinSDK-NetFx40Tools/InstallationFolder"
5490        if test -n "$regvalue" -a \( -f "$regvalue/al.exe" -o -f "$regvalue/bin/al.exe" \); then
5491            altest=$regvalue
5492            return
5493        fi
5494    done
5495
5496
5497}
5498
5499find_dotnetsdk46()
5500{
5501    unset frametest
5502
5503    for ver in 4.8 4.7.2 4.7.1 4.7 4.6.2 4.6.1 4.6; do
5504        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/NETFXSDK/$ver/KitsInstallationFolder"
5505        if test -n "$regvalue"; then
5506            frametest=$regvalue
5507            return
5508        fi
5509    done
5510}
5511
5512find_winsdk_version()
5513{
5514    # Args: $1 : SDK version as in "8.0", "8.1A" etc
5515    # Return values: $winsdktest, $winsdkbinsubdir, $winsdklibsubdir
5516
5517    unset winsdktest winsdkbinsubdir winsdklibsubdir
5518
5519    case "$1" in
5520    8.0|8.0A)
5521        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows Kits/Installed Roots/KitsRoot"
5522        if test -n "$regvalue"; then
5523            winsdktest=$regvalue
5524            winsdklibsubdir=win8
5525            return
5526        fi
5527        ;;
5528    8.1|8.1A)
5529        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows Kits/Installed Roots/KitsRoot81"
5530        if test -n "$regvalue"; then
5531            winsdktest=$regvalue
5532            winsdklibsubdir=winv6.3
5533            return
5534        fi
5535        ;;
5536    10.0)
5537        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v${1}/InstallationFolder"
5538        if test -n "$regvalue"; then
5539            winsdktest=$regvalue
5540            reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v${1}/ProductVersion"
5541            if test -n "$regvalue"; then
5542                winsdkbinsubdir="$regvalue".0
5543                winsdklibsubdir=$winsdkbinsubdir
5544                tmppath="$winsdktest\\Include\\$winsdklibsubdir"
5545                # test exist the SDK path
5546                if test -d "$tmppath"; then
5547                   # when path is convertible to a short path then path is okay
5548                   cygpath -d "$tmppath" >/dev/null 2>&1
5549                   if test $? -ne 0; then
5550                      AC_MSG_ERROR([Windows SDK doesn't have a 8.3 name, see NtfsDisable8dot3NameCreation])
5551                   fi
5552                else
5553                   AC_MSG_ERROR([The Windows SDK not found, check the installation])
5554                fi
5555            fi
5556            return
5557        fi
5558        ;;
5559    esac
5560}
5561
5562find_winsdk()
5563{
5564    # Return value: From find_winsdk_version
5565
5566    unset winsdktest
5567
5568    for ver in $WINDOWS_SDK_ACCEPTABLE_VERSIONS; do
5569        find_winsdk_version $ver
5570        if test -n "$winsdktest"; then
5571            return
5572        fi
5573    done
5574}
5575
5576find_msms()
5577{
5578    AC_MSG_CHECKING([for MSVC merge modules directory])
5579    my_msm_files=Microsoft_VC${VCVER}_CRT_x86.msm
5580    case "$VCVER" in
5581        150|160)
5582        my_msm_files="Microsoft_VC141_CRT_x86.msm Microsoft_VC142_CRT_x86.msm ${my_msm_files}"
5583        ;;
5584    esac
5585    for f in $my_msm_files; do
5586        echo "$as_me:$LINENO: searching for $f" >&5
5587    done
5588
5589    msmdir=
5590    for ver in 14.0 15.0; do
5591        reg_get_value_32 HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/VisualStudio/$ver/Setup/VS/MSMDir
5592        if test -n "$regvalue"; then
5593            for f in ${my_msm_files}; do
5594                if test -e "$regvalue/${f}"; then
5595                    msmdir=$regvalue
5596                    break
5597                fi
5598            done
5599        fi
5600    done
5601    dnl Is the following fallback really necessary, or was it added in response
5602    dnl to never having started Visual Studio on a given machine, so the
5603    dnl registry keys checked above had presumably not yet been created?
5604    dnl Anyway, if it really is necessary, it might be worthwhile to extend it
5605    dnl to also check %CommonProgramFiles(X86)% (typically expanding to
5606    dnl "C:\Program Files (X86)\Common Files" compared to %CommonProgramFiles%
5607    dnl expanding to "C:\Program Files\Common Files"), which would need
5608    dnl something like $(perl -e 'print $ENV{"CommonProgramFiles(x86)"}') to
5609    dnl obtain its value from cygwin:
5610    if test -z "$msmdir"; then
5611        my_msm_dir="${COMMONPROGRAMFILES}/Merge Modules/"
5612        for f in ${my_msm_files}; do
5613            if test -e "$my_msm_dir/${f}"; then
5614                msmdir=$my_msm_dir
5615            fi
5616        done
5617    fi
5618
5619    dnl Starting from MSVC 15.0, merge modules are located in different directory
5620    case "$VCVER" in
5621    150|160)
5622        for l in `ls -1 $VC_PRODUCT_DIR/redist/MSVC/`; do
5623            echo "$as_me:$LINENO: looking in $VC_PRODUCT_DIR/redist/MSVC/$l/MergeModules])" >&5
5624            my_msm_dir="$VC_PRODUCT_DIR/redist/MSVC/$l/MergeModules/"
5625            for f in ${my_msm_files}; do
5626                if test -e "$my_msm_dir/${f}"; then
5627                    msmdir=$my_msm_dir
5628                    break
5629                fi
5630            done
5631        done
5632        ;;
5633    esac
5634
5635    if test -n "$msmdir"; then
5636        msmdir=`cygpath -m "$msmdir"`
5637        AC_MSG_RESULT([$msmdir])
5638    else
5639        if test "$ENABLE_RELEASE_BUILD" = "TRUE" ; then
5640            AC_MSG_FAILURE([not found])
5641        else
5642            AC_MSG_WARN([not found (check config.log)])
5643            add_warning "MSM none of ${my_msm_files} found"
5644        fi
5645    fi
5646}
5647
5648find_msvc_x64_dlls()
5649{
5650    AC_MSG_CHECKING([for MSVC x64 DLL path])
5651    msvcdllpath="$VC_PRODUCT_DIR/redist/x64/Microsoft.VC${VCVER}.CRT"
5652    case "$VCVER" in
5653    150|160)
5654        for l in `ls -1 $VC_PRODUCT_DIR/redist/MSVC/`; do
5655            echo "$as_me:$LINENO: testing $VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC141.CRT" >&5
5656            if test -d "$VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC141.CRT"; then
5657                msvcdllpath="$VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC141.CRT"
5658                break
5659            fi
5660            echo "$as_me:$LINENO: testing $VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC142.CRT" >&5
5661            if test -d "$VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC142.CRT"; then
5662                msvcdllpath="$VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC142.CRT"
5663                break
5664            fi
5665            echo "$as_me:$LINENO: testing $VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC150.CRT" >&5
5666            if test -d "$VC_PRODUCT_DIR/redist/MSVC/$l/onecore/x64/Microsoft.VC150.CRT"; then
5667                msvcdllpath="$VC_PRODUCT_DIR/redist/MSVC/$l/onecore/x64/Microsoft.VC150.CRT"
5668                break
5669            fi
5670        done
5671        ;;
5672    esac
5673    AC_MSG_RESULT([$msvcdllpath])
5674    AC_MSG_CHECKING([for MSVC x64 DLLs])
5675    msvcdlls="msvcp140.dll vcruntime140.dll"
5676    for dll in $msvcdlls; do
5677        if ! test -f "$msvcdllpath/$dll"; then
5678            AC_MSG_FAILURE([missing $dll])
5679        fi
5680    done
5681    AC_MSG_RESULT([found all ($msvcdlls)])
5682}
5683
5684dnl =========================================
5685dnl Check for the Windows  SDK.
5686dnl =========================================
5687if test "$_os" = "WINNT"; then
5688    AC_MSG_CHECKING([for Windows SDK])
5689    if test "$build_os" = "cygwin"; then
5690        find_winsdk
5691        WINDOWS_SDK_HOME=$winsdktest
5692
5693        # normalize if found
5694        if test -n "$WINDOWS_SDK_HOME"; then
5695            WINDOWS_SDK_HOME=`cygpath -d "$WINDOWS_SDK_HOME"`
5696            WINDOWS_SDK_HOME=`cygpath -u "$WINDOWS_SDK_HOME"`
5697        fi
5698
5699        WINDOWS_SDK_LIB_SUBDIR=$winsdklibsubdir
5700    fi
5701
5702    if test -n "$WINDOWS_SDK_HOME"; then
5703        # Remove a possible trailing backslash
5704        WINDOWS_SDK_HOME=`echo $WINDOWS_SDK_HOME | $SED 's/\/$//'`
5705
5706        if test -f "$WINDOWS_SDK_HOME/Include/adoint.h" \
5707             -a -f "$WINDOWS_SDK_HOME/Include/SqlUcode.h" \
5708             -a -f "$WINDOWS_SDK_HOME/Include/usp10.h"; then
5709            have_windows_sdk_headers=yes
5710        elif test -f "$WINDOWS_SDK_HOME/Include/um/adoint.h" \
5711             -a -f "$WINDOWS_SDK_HOME/Include/um/SqlUcode.h" \
5712             -a -f "$WINDOWS_SDK_HOME/Include/um/usp10.h"; then
5713            have_windows_sdk_headers=yes
5714        elif test -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/adoint.h" \
5715             -a -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/SqlUcode.h" \
5716             -a -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/usp10.h"; then
5717            have_windows_sdk_headers=yes
5718        else
5719            have_windows_sdk_headers=no
5720        fi
5721
5722        if test -f "$WINDOWS_SDK_HOME/lib/user32.lib"; then
5723            have_windows_sdk_libs=yes
5724        elif test -f "$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/$WINDOWS_SDK_ARCH/user32.lib"; then
5725            have_windows_sdk_libs=yes
5726        else
5727            have_windows_sdk_libs=no
5728        fi
5729
5730        if test $have_windows_sdk_headers = no -o $have_windows_sdk_libs = no; then
5731            AC_MSG_ERROR([Some (all?) Windows SDK files not found, please check if all needed parts of
5732the  Windows SDK are installed.])
5733        fi
5734    fi
5735
5736    if test -z "$WINDOWS_SDK_HOME"; then
5737        AC_MSG_RESULT([no, hoping the necessary headers and libraries will be found anyway!?])
5738    elif echo $WINDOWS_SDK_HOME | grep "8.0" >/dev/null 2>/dev/null; then
5739        WINDOWS_SDK_VERSION=80
5740        AC_MSG_RESULT([found Windows SDK 8.0 ($WINDOWS_SDK_HOME)])
5741    elif echo $WINDOWS_SDK_HOME | grep "8.1" >/dev/null 2>/dev/null; then
5742        WINDOWS_SDK_VERSION=81
5743        AC_MSG_RESULT([found Windows SDK 8.1 ($WINDOWS_SDK_HOME)])
5744    elif echo $WINDOWS_SDK_HOME | grep "/10" >/dev/null 2>/dev/null; then
5745        WINDOWS_SDK_VERSION=10
5746        AC_MSG_RESULT([found Windows SDK 10.0 ($WINDOWS_SDK_HOME)])
5747    else
5748        AC_MSG_ERROR([Found legacy Windows Platform SDK ($WINDOWS_SDK_HOME)])
5749    fi
5750    PathFormat "$WINDOWS_SDK_HOME"
5751    WINDOWS_SDK_HOME="$formatted_path"
5752    if test "$build_os" = "cygwin"; then
5753        SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/include -I$COMPATH/Include"
5754        if test -d "$WINDOWS_SDK_HOME/include/um"; then
5755            SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/include/um -I$WINDOWS_SDK_HOME/include/shared"
5756        elif test -d "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um"; then
5757            SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um -I$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/shared"
5758        fi
5759    fi
5760
5761    dnl TODO: solenv/bin/modules/installer/windows/msiglobal.pm wants to use a
5762    dnl WiLangId.vbs that is included only in some SDKs (e.g., included in v7.1
5763    dnl but not in v8.0), so allow this to be overridden with a
5764    dnl WINDOWS_SDK_WILANGID for now; a full-blown --with-windows-sdk-wilangid
5765    dnl and configuration error if no WiLangId.vbs is found would arguably be
5766    dnl better, but I do not know under which conditions exactly it is needed by
5767    dnl msiglobal.pm:
5768    if test -z "$WINDOWS_SDK_WILANGID" -a -n "$WINDOWS_SDK_HOME"; then
5769        WINDOWS_SDK_WILANGID=$WINDOWS_SDK_HOME/Samples/sysmgmt/msi/scripts/WiLangId.vbs
5770        if ! test -e "$WINDOWS_SDK_WILANGID" ; then
5771            WINDOWS_SDK_WILANGID="${WINDOWS_SDK_HOME}/bin/${WINDOWS_SDK_LIB_SUBDIR}/${WINDOWS_SDK_ARCH}/WiLangId.vbs"
5772        fi
5773        if ! test -e "$WINDOWS_SDK_WILANGID" ; then
5774            WINDOWS_SDK_WILANGID=$WINDOWS_SDK_HOME/bin/$WINDOWS_SDK_ARCH/WiLangId.vbs
5775        fi
5776        if ! test -e "$WINDOWS_SDK_WILANGID" ; then
5777            WINDOWS_SDK_WILANGID=$(cygpath -sm "C:/Program Files (x86)/Windows Kits/8.1/bin/$WINDOWS_SDK_ARCH/WiLangId.vbs")
5778        fi
5779    fi
5780    if test -n "$with_lang" -a "$with_lang" != "en-US"; then
5781        if test -n "$with_package_format" -a "$with_package_format" != no; then
5782            for i in "$with_package_format"; do
5783                if test "$i" = "msi"; then
5784                    if ! test -e "$WINDOWS_SDK_WILANGID" ; then
5785                        AC_MSG_ERROR([WiLangId.vbs not found - building translated packages will fail])
5786                    fi
5787                fi
5788            done
5789        fi
5790    fi
5791fi
5792AC_SUBST(WINDOWS_SDK_HOME)
5793AC_SUBST(WINDOWS_SDK_LIB_SUBDIR)
5794AC_SUBST(WINDOWS_SDK_VERSION)
5795AC_SUBST(WINDOWS_SDK_WILANGID)
5796
5797if test "$build_os" = "cygwin"; then
5798    dnl Check midl.exe; this being the first check for a tool in the SDK bin
5799    dnl dir, it also determines that dir's path w/o an arch segment if any,
5800    dnl WINDOWS_SDK_BINDIR_NO_ARCH:
5801    AC_MSG_CHECKING([for midl.exe])
5802
5803    find_winsdk
5804    if test -n "$winsdkbinsubdir" \
5805        -a -f "$winsdktest/Bin/$winsdkbinsubdir/$WINDOWS_SDK_ARCH/midl.exe"
5806    then
5807        MIDL_PATH=$winsdktest/Bin/$winsdkbinsubdir/$WINDOWS_SDK_ARCH
5808        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME/Bin/$winsdkbinsubdir
5809    elif test -f "$winsdktest/Bin/$WINDOWS_SDK_ARCH/midl.exe"; then
5810        MIDL_PATH=$winsdktest/Bin/$WINDOWS_SDK_ARCH
5811        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME/Bin
5812    elif test -f "$winsdktest/Bin/midl.exe"; then
5813        MIDL_PATH=$winsdktest/Bin
5814        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME/Bin
5815    fi
5816    if test ! -f "$MIDL_PATH/midl.exe"; then
5817        AC_MSG_ERROR([midl.exe not found in $winsdktest/Bin/$WINDOWS_SDK_ARCH, Windows SDK installation broken?])
5818    else
5819        AC_MSG_RESULT([$MIDL_PATH/midl.exe])
5820    fi
5821
5822    # Convert to posix path with 8.3 filename restrictions ( No spaces )
5823    MIDL_PATH=`win_short_path_for_make "$MIDL_PATH"`
5824
5825    if test -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msiinfo.exe" \
5826         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msidb.exe" \
5827         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/uuidgen.exe" \
5828         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msitran.exe"; then :
5829    elif test -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msiinfo.exe" \
5830         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msidb.exe" \
5831         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/uuidgen.exe" \
5832         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msitran.exe"; then :
5833    elif test -f "$WINDOWS_SDK_HOME/bin/x86/msiinfo.exe" \
5834         -a -f "$WINDOWS_SDK_HOME/bin/x86/msidb.exe" \
5835         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/uuidgen.exe" \
5836         -a -f "$WINDOWS_SDK_HOME/bin/x86/msitran.exe"; then :
5837    else
5838        AC_MSG_ERROR([Some (all?) Windows Installer tools in the Windows SDK are missing, please install.])
5839    fi
5840
5841    dnl Check csc.exe
5842    AC_MSG_CHECKING([for csc.exe])
5843    find_csc
5844    if test -f "$csctest/csc.exe"; then
5845        CSC_PATH="$csctest"
5846    fi
5847    if test ! -f "$CSC_PATH/csc.exe"; then
5848        AC_MSG_ERROR([csc.exe not found as $CSC_PATH/csc.exe])
5849    else
5850        AC_MSG_RESULT([$CSC_PATH/csc.exe])
5851    fi
5852
5853    CSC_PATH=`win_short_path_for_make "$CSC_PATH"`
5854
5855    dnl Check al.exe
5856    AC_MSG_CHECKING([for al.exe])
5857    find_winsdk
5858    if test -n "$winsdkbinsubdir" \
5859        -a -f "$winsdktest/Bin/$winsdkbinsubdir/$WINDOWS_SDK_ARCH/al.exe"
5860    then
5861        AL_PATH="$winsdktest/Bin/$winsdkbinsubdir/$WINDOWS_SDK_ARCH"
5862    elif test -f "$winsdktest/Bin/$WINDOWS_SDK_ARCH/al.exe"; then
5863        AL_PATH="$winsdktest/Bin/$WINDOWS_SDK_ARCH"
5864    elif test -f "$winsdktest/Bin/al.exe"; then
5865        AL_PATH="$winsdktest/Bin"
5866    fi
5867
5868    if test -z "$AL_PATH"; then
5869        find_al
5870        if test -f "$altest/bin/al.exe"; then
5871            AL_PATH="$altest/bin"
5872        elif test -f "$altest/al.exe"; then
5873            AL_PATH="$altest"
5874        fi
5875    fi
5876    if test ! -f "$AL_PATH/al.exe"; then
5877        AC_MSG_ERROR([al.exe not found as $AL_PATH/al.exe])
5878    else
5879        AC_MSG_RESULT([$AL_PATH/al.exe])
5880    fi
5881
5882    AL_PATH=`win_short_path_for_make "$AL_PATH"`
5883
5884    dnl Check mscoree.lib / .NET Framework dir
5885    AC_MSG_CHECKING(.NET Framework)
5886    find_dotnetsdk46
5887    PathFormat "$frametest"
5888    frametest="$formatted_path"
5889    if test -f "$frametest/Lib/um/$WINDOWS_SDK_ARCH/mscoree.lib"; then
5890        DOTNET_FRAMEWORK_HOME="$frametest"
5891    else
5892        find_winsdk
5893        if test -f "$winsdktest/lib/mscoree.lib" -o -f "$winsdktest/lib/$winsdklibsubdir/um/$WINDOWS_SDK_ARCH/mscoree.lib"; then
5894            DOTNET_FRAMEWORK_HOME="$winsdktest"
5895        fi
5896    fi
5897    if test ! -f "$DOTNET_FRAMEWORK_HOME/lib/mscoree.lib" -a ! -f "$DOTNET_FRAMEWORK_HOME/lib/$winsdklibsubdir/um/$WINDOWS_SDK_ARCH/mscoree.lib" -a ! -f "$DOTNET_FRAMEWORK_HOME/Lib/um/$WINDOWS_SDK_ARCH/mscoree.lib"; then
5898        AC_MSG_ERROR([mscoree.lib not found])
5899    fi
5900    AC_MSG_RESULT([found: $DOTNET_FRAMEWORK_HOME])
5901
5902    PathFormat "$MIDL_PATH"
5903    MIDL_PATH="$formatted_path"
5904
5905    PathFormat "$AL_PATH"
5906    AL_PATH="$formatted_path"
5907
5908    PathFormat "$DOTNET_FRAMEWORK_HOME"
5909    DOTNET_FRAMEWORK_HOME="$formatted_path"
5910
5911    PathFormat "$CSC_PATH"
5912    CSC_PATH="$formatted_path"
5913fi
5914
5915dnl ===================================================================
5916dnl Check if stdc headers are available excluding MSVC.
5917dnl ===================================================================
5918if test "$_os" != "WINNT"; then
5919    AC_HEADER_STDC
5920fi
5921
5922dnl ===================================================================
5923dnl Testing for C++ compiler and version...
5924dnl ===================================================================
5925
5926if test "$_os" != "WINNT"; then
5927    # AC_PROG_CXX sets CXXFLAGS to -g -O2 if not set, avoid that
5928    save_CXXFLAGS=$CXXFLAGS
5929    AC_PROG_CXX
5930    CXXFLAGS=$save_CXXFLAGS
5931    if test -z "$CXX_BASE"; then
5932        CXX_BASE=`first_arg_basename "$CXX"`
5933    fi
5934fi
5935
5936dnl check for GNU C++ compiler version
5937if test "$GXX" = "yes" -a -z "$COM_IS_CLANG"; then
5938    AC_MSG_CHECKING([the GNU C++ compiler version])
5939
5940    _gpp_version=`$CXX -dumpversion`
5941    _gpp_majmin=`echo $_gpp_version | $AWK -F. '{ print \$1*100+\$2 }'`
5942
5943    if test "$_gpp_majmin" -lt "700"; then
5944        AC_MSG_ERROR([You need to use GNU C++ compiler version >= 7.0 to build LibreOffice, you have $_gpp_version.])
5945    else
5946        AC_MSG_RESULT([ok (g++ $_gpp_version)])
5947    fi
5948
5949    dnl see https://code.google.com/p/android/issues/detail?id=41770
5950        glibcxx_threads=no
5951        AC_LANG_PUSH([C++])
5952        AC_REQUIRE_CPP
5953        AC_MSG_CHECKING([whether $CXX_BASE is broken with boost.thread])
5954        AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
5955            #include <bits/c++config.h>]],[[
5956            #if !defined(_GLIBCXX_HAVE_GTHR_DEFAULT) \
5957            && !defined(_GLIBCXX__PTHREADS) \
5958            && !defined(_GLIBCXX_HAS_GTHREADS)
5959            choke me
5960            #endif
5961        ]])],[AC_MSG_RESULT([yes])
5962        glibcxx_threads=yes],[AC_MSG_RESULT([no])])
5963        AC_LANG_POP([C++])
5964        if test $glibcxx_threads = yes; then
5965            BOOST_CXXFLAGS="-D_GLIBCXX_HAS_GTHREADS"
5966        fi
5967fi
5968AC_SUBST(BOOST_CXXFLAGS)
5969
5970#
5971# prefx CXX with ccache if needed
5972#
5973if test "$CCACHE" != ""; then
5974    AC_MSG_CHECKING([whether $CXX_BASE is already ccached])
5975    AC_LANG_PUSH([C++])
5976    save_CXXFLAGS=$CXXFLAGS
5977    CXXFLAGS="$CXXFLAGS --ccache-skip -O2"
5978    dnl an empty program will do, we're checking the compiler flags
5979    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
5980                      [use_ccache=yes], [use_ccache=no])
5981    if test $use_ccache = yes; then
5982        AC_MSG_RESULT([yes])
5983    else
5984        CXX="$CCACHE $CXX"
5985        CXX_BASE="ccache $CXX_BASE"
5986        AC_MSG_RESULT([no])
5987    fi
5988    CXXFLAGS=$save_CXXFLAGS
5989    AC_LANG_POP([C++])
5990fi
5991
5992dnl ===================================================================
5993dnl Find pre-processors.(should do that _after_ messing with CC/CXX)
5994dnl ===================================================================
5995
5996if test "$_os" != "WINNT"; then
5997    AC_PROG_CXXCPP
5998
5999    dnl Check whether there's a C pre-processor.
6000    AC_PROG_CPP
6001fi
6002
6003
6004dnl ===================================================================
6005dnl Find integral type sizes and alignments
6006dnl ===================================================================
6007
6008if test "$_os" != "WINNT"; then
6009
6010if test "$_os" = "iOS"; then
6011    AC_MSG_CHECKING([iOS setting sizes long, short, int, long long, double, voidp])
6012    ac_cv_sizeof_long=8
6013    ac_cv_sizeof_short=2
6014    ac_cv_sizeof_int=4
6015    ac_cv_sizeof_long_long=8
6016    ac_cv_sizeof_double=8
6017    ac_cv_sizeof_voidp=8
6018else
6019    AC_CHECK_SIZEOF(long)
6020    AC_CHECK_SIZEOF(short)
6021    AC_CHECK_SIZEOF(int)
6022    AC_CHECK_SIZEOF(long long)
6023    AC_CHECK_SIZEOF(double)
6024    AC_CHECK_SIZEOF(void*)
6025fi
6026
6027    SAL_TYPES_SIZEOFSHORT=$ac_cv_sizeof_short
6028    SAL_TYPES_SIZEOFINT=$ac_cv_sizeof_int
6029    SAL_TYPES_SIZEOFLONG=$ac_cv_sizeof_long
6030    SAL_TYPES_SIZEOFLONGLONG=$ac_cv_sizeof_long_long
6031    SAL_TYPES_SIZEOFPOINTER=$ac_cv_sizeof_voidp
6032
6033    dnl Allow build without AC_CHECK_ALIGNOF, grrr
6034    m4_pattern_allow([AC_CHECK_ALIGNOF])
6035    m4_ifdef([AC_CHECK_ALIGNOF],
6036        [
6037            AC_CHECK_ALIGNOF(short,[#include <stddef.h>])
6038            AC_CHECK_ALIGNOF(int,[#include <stddef.h>])
6039            AC_CHECK_ALIGNOF(long,[#include <stddef.h>])
6040            AC_CHECK_ALIGNOF(double,[#include <stddef.h>])
6041        ],
6042        [
6043            case "$_os-$host_cpu" in
6044            Linux-i686)
6045                test -z "$ac_cv_alignof_short" && ac_cv_alignof_short=2
6046                test -z "$ac_cv_alignof_int" && ac_cv_alignof_int=4
6047                test -z "$ac_cv_alignof_long" && ac_cv_alignof_long=4
6048                test -z "$ac_cv_alignof_double" && ac_cv_alignof_double=4
6049                ;;
6050            Linux-x86_64)
6051                test -z "$ac_cv_alignof_short" && ac_cv_alignof_short=2
6052                test -z "$ac_cv_alignof_int" && ac_cv_alignof_int=4
6053                test -z "$ac_cv_alignof_long" && ac_cv_alignof_long=8
6054                test -z "$ac_cv_alignof_double" && ac_cv_alignof_double=8
6055                ;;
6056            *)
6057                if test -z "$ac_cv_alignof_short" -o \
6058                        -z "$ac_cv_alignof_int" -o \
6059                        -z "$ac_cv_alignof_long" -o \
6060                        -z "$ac_cv_alignof_double"; then
6061                   AC_MSG_ERROR([Your Autoconf doesn't have [AC_][CHECK_ALIGNOF]. You need to set the environment variables ac_cv_alignof_short, ac_cv_alignof_int, ac_cv_alignof_long and ac_cv_alignof_double.])
6062                fi
6063                ;;
6064            esac
6065        ])
6066
6067    SAL_TYPES_ALIGNMENT2=$ac_cv_alignof_short
6068    SAL_TYPES_ALIGNMENT4=$ac_cv_alignof_int
6069    if test $ac_cv_sizeof_long -eq 8; then
6070        SAL_TYPES_ALIGNMENT8=$ac_cv_alignof_long
6071    elif test $ac_cv_sizeof_double -eq 8; then
6072        SAL_TYPES_ALIGNMENT8=$ac_cv_alignof_double
6073    else
6074        AC_MSG_ERROR([Cannot find alignment of 8 byte types.])
6075    fi
6076
6077    dnl Check for large file support
6078    AC_SYS_LARGEFILE
6079    if test -n "$ac_cv_sys_file_offset_bits" -a "$ac_cv_sys_file_offset_bits" != "no"; then
6080        LFS_CFLAGS="-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
6081    fi
6082    if test -n "$ac_cv_sys_large_files" -a "$ac_cv_sys_large_files" != "no"; then
6083        LFS_CFLAGS="$LFS_CFLAGS -D_LARGE_FILES"
6084    fi
6085else
6086    # Hardcode for MSVC
6087    SAL_TYPES_SIZEOFSHORT=2
6088    SAL_TYPES_SIZEOFINT=4
6089    SAL_TYPES_SIZEOFLONG=4
6090    SAL_TYPES_SIZEOFLONGLONG=8
6091    if test "$BITNESS_OVERRIDE" = ""; then
6092        SAL_TYPES_SIZEOFPOINTER=4
6093    else
6094        SAL_TYPES_SIZEOFPOINTER=8
6095    fi
6096    SAL_TYPES_ALIGNMENT2=2
6097    SAL_TYPES_ALIGNMENT4=4
6098    SAL_TYPES_ALIGNMENT8=8
6099    LFS_CFLAGS=''
6100fi
6101AC_SUBST(LFS_CFLAGS)
6102
6103AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFSHORT,$SAL_TYPES_SIZEOFSHORT)
6104AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFINT,$SAL_TYPES_SIZEOFINT)
6105AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFLONG,$SAL_TYPES_SIZEOFLONG)
6106AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFLONGLONG,$SAL_TYPES_SIZEOFLONGLONG)
6107AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFPOINTER,$SAL_TYPES_SIZEOFPOINTER)
6108AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT2,$SAL_TYPES_ALIGNMENT2)
6109AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT4,$SAL_TYPES_ALIGNMENT4)
6110AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT8,$SAL_TYPES_ALIGNMENT8)
6111
6112dnl ===================================================================
6113dnl Check whether to enable runtime optimizations
6114dnl ===================================================================
6115ENABLE_RUNTIME_OPTIMIZATIONS=
6116AC_MSG_CHECKING([whether to enable runtime optimizations])
6117if test -z "$enable_runtime_optimizations"; then
6118    for i in $CC; do
6119        case $i in
6120        -fsanitize=*)
6121            enable_runtime_optimizations=no
6122            break
6123            ;;
6124        esac
6125    done
6126fi
6127if test "$enable_runtime_optimizations" != no; then
6128    ENABLE_RUNTIME_OPTIMIZATIONS=TRUE
6129    AC_DEFINE(ENABLE_RUNTIME_OPTIMIZATIONS)
6130    AC_MSG_RESULT([yes])
6131else
6132    AC_MSG_RESULT([no])
6133fi
6134AC_SUBST([ENABLE_RUNTIME_OPTIMIZATIONS])
6135
6136dnl ===================================================================
6137dnl Check if valgrind headers are available
6138dnl ===================================================================
6139ENABLE_VALGRIND=
6140if test "$cross_compiling" != yes -a "$with_valgrind" != no; then
6141    prev_cppflags=$CPPFLAGS
6142    # Is VALGRIND_CFLAGS something one is supposed to have in the environment,
6143    # or where does it come from?
6144    CPPFLAGS="$CPPFLAGS $VALGRIND_CFLAGS"
6145    AC_CHECK_HEADER([valgrind/valgrind.h],
6146        [ENABLE_VALGRIND=TRUE])
6147    CPPFLAGS=$prev_cppflags
6148fi
6149AC_SUBST([ENABLE_VALGRIND])
6150if test -z "$ENABLE_VALGRIND"; then
6151    if test "$with_valgrind" = yes; then
6152        AC_MSG_ERROR([--with-valgrind specified but no Valgrind headers found])
6153    fi
6154    VALGRIND_CFLAGS=
6155fi
6156AC_SUBST([VALGRIND_CFLAGS])
6157
6158
6159dnl ===================================================================
6160dnl Check if SDT probes (for systemtap, gdb, dtrace) are available
6161dnl ===================================================================
6162
6163# We need at least the sys/sdt.h include header.
6164AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND='TRUE'], [SDT_H_FOUND='FALSE'])
6165if test "$SDT_H_FOUND" = "TRUE"; then
6166    # Found sys/sdt.h header, now make sure the c++ compiler works.
6167    # Old g++ versions had problems with probes in constructors/destructors.
6168    AC_MSG_CHECKING([working sys/sdt.h and c++ support])
6169    AC_LANG_PUSH([C++])
6170    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
6171    #include <sys/sdt.h>
6172    class ProbeClass
6173    {
6174    private:
6175      int& ref;
6176      const char *name;
6177
6178    public:
6179      ProbeClass(int& v, const char *n) : ref(v), name(n)
6180      {
6181        DTRACE_PROBE2(_test_, cons, name, ref);
6182      }
6183
6184      void method(int min)
6185      {
6186        DTRACE_PROBE3(_test_, meth, name, ref, min);
6187        ref -= min;
6188      }
6189
6190      ~ProbeClass()
6191      {
6192        DTRACE_PROBE2(_test_, dest, name, ref);
6193      }
6194    };
6195    ]],[[
6196    int i = 64;
6197    DTRACE_PROBE1(_test_, call, i);
6198    ProbeClass inst = ProbeClass(i, "call");
6199    inst.method(24);
6200    ]])], [AC_MSG_RESULT([yes]); AC_DEFINE([USE_SDT_PROBES])],
6201          [AC_MSG_RESULT([no, sdt.h or c++ compiler too old])])
6202    AC_LANG_POP([C++])
6203fi
6204AC_CONFIG_HEADERS([config_host/config_probes.h])
6205
6206dnl ===================================================================
6207dnl GCC features
6208dnl ===================================================================
6209HAVE_GCC_STACK_CLASH_PROTECTION=
6210if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
6211    AC_MSG_CHECKING([whether $CC_BASE supports -fstack-clash-protection])
6212    save_CFLAGS=$CFLAGS
6213    CFLAGS="$CFLAGS -fstack-clash-protection"
6214    AC_LINK_IFELSE(
6215        [AC_LANG_PROGRAM(, [[return 0;]])],
6216        [AC_MSG_RESULT([yes]); HAVE_GCC_STACK_CLASH_PROTECTION=TRUE],
6217        [AC_MSG_RESULT([no])])
6218    CFLAGS=$save_CFLAGS
6219
6220    AC_MSG_CHECKING([whether $CC_BASE supports -mno-avx])
6221    save_CFLAGS=$CFLAGS
6222    CFLAGS="$CFLAGS -Werror -mno-avx"
6223    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_AVX=TRUE ],[])
6224    CFLAGS=$save_CFLAGS
6225    if test "$HAVE_GCC_AVX" = "TRUE"; then
6226        AC_MSG_RESULT([yes])
6227    else
6228        AC_MSG_RESULT([no])
6229    fi
6230
6231    AC_MSG_CHECKING([whether $CC_BASE supports atomic functions])
6232    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
6233    int v = 0;
6234    if (__sync_add_and_fetch(&v, 1) != 1 ||
6235        __sync_sub_and_fetch(&v, 1) != 0)
6236        return 1;
6237    __sync_synchronize();
6238    if (__sync_val_compare_and_swap(&v, 0, 1) != 0 ||
6239        v != 1)
6240        return 1;
6241    return 0;
6242]])],[HAVE_GCC_BUILTIN_ATOMIC=TRUE],[])
6243    if test "$HAVE_GCC_BUILTIN_ATOMIC" = "TRUE"; then
6244        AC_MSG_RESULT([yes])
6245        AC_DEFINE(HAVE_GCC_BUILTIN_ATOMIC)
6246    else
6247        AC_MSG_RESULT([no])
6248    fi
6249
6250    AC_MSG_CHECKING([whether $CC_BASE supports __builtin_ffs])
6251    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return __builtin_ffs(1); ]])],[HAVE_GCC_BUILTIN_FFS=TRUE],[])
6252    if test "$HAVE_GCC_BUILTIN_FFS" = "TRUE"; then
6253        AC_MSG_RESULT([yes])
6254        AC_DEFINE(HAVE_GCC_BUILTIN_FFS)
6255    else
6256        AC_MSG_RESULT([no])
6257    fi
6258
6259    AC_MSG_CHECKING([whether $CC_BASE supports __attribute__((deprecated(message)))])
6260    save_CFLAGS=$CFLAGS
6261    CFLAGS="$CFLAGS -Werror"
6262    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6263            __attribute__((deprecated("test"))) void f();
6264        ])], [
6265            AC_DEFINE([HAVE_GCC_DEPRECATED_MESSAGE],[1])
6266            AC_MSG_RESULT([yes])
6267        ], [AC_MSG_RESULT([no])])
6268    CFLAGS=$save_CFLAGS
6269
6270    AC_MSG_CHECKING([whether $CXX_BASE defines __base_class_type_info in cxxabi.h])
6271    AC_LANG_PUSH([C++])
6272    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6273            #include <cstddef>
6274            #include <cxxabi.h>
6275            std::size_t f() { return sizeof(__cxxabiv1::__base_class_type_info); }
6276        ])], [
6277            AC_DEFINE([HAVE_CXXABI_H_BASE_CLASS_TYPE_INFO],[1])
6278            AC_MSG_RESULT([yes])
6279        ], [AC_MSG_RESULT([no])])
6280    AC_LANG_POP([C++])
6281
6282    AC_MSG_CHECKING([whether $CXX_BASE defines __class_type_info in cxxabi.h])
6283    AC_LANG_PUSH([C++])
6284    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6285            #include <cstddef>
6286            #include <cxxabi.h>
6287            std::size_t f() { return sizeof(__cxxabiv1::__class_type_info); }
6288        ])], [
6289            AC_DEFINE([HAVE_CXXABI_H_CLASS_TYPE_INFO],[1])
6290            AC_MSG_RESULT([yes])
6291        ], [AC_MSG_RESULT([no])])
6292    AC_LANG_POP([C++])
6293
6294    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_allocate_exception in cxxabi.h])
6295    AC_LANG_PUSH([C++])
6296    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6297            #include <cxxabi.h>
6298            void * f() { return __cxxabiv1::__cxa_allocate_exception(0); }
6299        ])], [
6300            AC_DEFINE([HAVE_CXXABI_H_CXA_ALLOCATE_EXCEPTION],[1])
6301            AC_MSG_RESULT([yes])
6302        ], [AC_MSG_RESULT([no])])
6303    AC_LANG_POP([C++])
6304
6305    AC_MSG_CHECKING([whether $CXX_BASE defines __cxa_eh_globals in cxxabi.h])
6306    AC_LANG_PUSH([C++])
6307    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6308            #include <cstddef>
6309            #include <cxxabi.h>
6310            std::size_t f() { return sizeof(__cxxabiv1::__cxa_eh_globals); }
6311        ])], [
6312            AC_DEFINE([HAVE_CXXABI_H_CXA_EH_GLOBALS],[1])
6313            AC_MSG_RESULT([yes])
6314        ], [AC_MSG_RESULT([no])])
6315    AC_LANG_POP([C++])
6316
6317    AC_MSG_CHECKING([whether $CXX_BASE defines __cxa_exception in cxxabi.h])
6318    AC_LANG_PUSH([C++])
6319    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6320            #include <cstddef>
6321            #include <cxxabi.h>
6322            std::size_t f() { return sizeof(__cxxabiv1::__cxa_exception); }
6323        ])], [
6324            AC_DEFINE([HAVE_CXXABI_H_CXA_EXCEPTION],[1])
6325            AC_MSG_RESULT([yes])
6326        ], [AC_MSG_RESULT([no])])
6327    AC_LANG_POP([C++])
6328
6329    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_get_globals in cxxabi.h])
6330    AC_LANG_PUSH([C++])
6331    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6332            #include <cxxabi.h>
6333            void * f() { return __cxxabiv1::__cxa_get_globals(); }
6334        ])], [
6335            AC_DEFINE([HAVE_CXXABI_H_CXA_GET_GLOBALS],[1])
6336            AC_MSG_RESULT([yes])
6337        ], [AC_MSG_RESULT([no])])
6338    AC_LANG_POP([C++])
6339
6340    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_current_exception_type in cxxabi.h])
6341    AC_LANG_PUSH([C++])
6342    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6343            #include <cxxabi.h>
6344            void * f() { return __cxxabiv1::__cxa_current_exception_type(); }
6345        ])], [
6346            AC_DEFINE([HAVE_CXXABI_H_CXA_CURRENT_EXCEPTION_TYPE],[1])
6347            AC_MSG_RESULT([yes])
6348        ], [AC_MSG_RESULT([no])])
6349    AC_LANG_POP([C++])
6350
6351    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_throw in cxxabi.h])
6352    AC_LANG_PUSH([C++])
6353    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6354            #include <cxxabi.h>
6355            void f() { __cxxabiv1::__cxa_throw(0, 0, 0); }
6356        ])], [
6357            AC_DEFINE([HAVE_CXXABI_H_CXA_THROW],[1])
6358            AC_MSG_RESULT([yes])
6359        ], [AC_MSG_RESULT([no])])
6360    AC_LANG_POP([C++])
6361
6362    AC_MSG_CHECKING([whether $CXX_BASE defines __si_class_type_info in cxxabi.h])
6363    AC_LANG_PUSH([C++])
6364    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6365            #include <cstddef>
6366            #include <cxxabi.h>
6367            std::size_t f() { return sizeof(__cxxabiv1::__si_class_type_info); }
6368        ])], [
6369            AC_DEFINE([HAVE_CXXABI_H_SI_CLASS_TYPE_INFO],[1])
6370            AC_MSG_RESULT([yes])
6371        ], [AC_MSG_RESULT([no])])
6372    AC_LANG_POP([C++])
6373
6374    AC_MSG_CHECKING([whether $CXX_BASE defines __vmi_class_type_info in cxxabi.h])
6375    AC_LANG_PUSH([C++])
6376    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6377            #include <cstddef>
6378            #include <cxxabi.h>
6379            std::size_t f() { return sizeof(__cxxabiv1::__vmi_class_type_info); }
6380        ])], [
6381            AC_DEFINE([HAVE_CXXABI_H_VMI_CLASS_TYPE_INFO],[1])
6382            AC_MSG_RESULT([yes])
6383        ], [AC_MSG_RESULT([no])])
6384    AC_LANG_POP([C++])
6385
6386    dnl Available in GCC 4.9 and at least since Clang 3.4:
6387    AC_MSG_CHECKING([whether $CXX_BASE supports __attribute__((warn_unused))])
6388    AC_LANG_PUSH([C++])
6389    save_CXXFLAGS=$CXXFLAGS
6390    CXXFLAGS="$CXXFLAGS -Werror"
6391    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6392            struct __attribute__((warn_unused)) dummy {};
6393        ])], [
6394            AC_DEFINE([HAVE_GCC_ATTRIBUTE_WARN_UNUSED],[1])
6395            AC_MSG_RESULT([yes])
6396        ], [AC_MSG_RESULT([no])])
6397    CXXFLAGS=$save_CXXFLAGS
6398AC_LANG_POP([C++])
6399fi
6400
6401AC_SUBST(HAVE_GCC_AVX)
6402AC_SUBST(HAVE_GCC_BUILTIN_ATOMIC)
6403AC_SUBST(HAVE_GCC_BUILTIN_FFS)
6404AC_SUBST(HAVE_GCC_STACK_CLASH_PROTECTION)
6405
6406dnl ===================================================================
6407dnl Identify the C++ library
6408dnl ===================================================================
6409
6410AC_MSG_CHECKING([what the C++ library is])
6411AC_LANG_PUSH([C++])
6412AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6413#include <utility>
6414#ifndef __GLIBCXX__
6415foo bar
6416#endif
6417]])],
6418    [CPP_LIBRARY=GLIBCXX
6419     cpp_library_name="GNU libstdc++"
6420    ],
6421    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6422#include <utility>
6423#ifndef _LIBCPP_VERSION
6424foo bar
6425#endif
6426]])],
6427    [CPP_LIBRARY=LIBCPP
6428     cpp_library_name="LLVM libc++"
6429     AC_DEFINE([HAVE_LIBCXX])
6430    ],
6431    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6432#include <utility>
6433#ifndef _MSC_VER
6434foo bar
6435#endif
6436]])],
6437    [CPP_LIBRARY=MSVCRT
6438     cpp_library_name="Microsoft"
6439    ],
6440    AC_MSG_ERROR([Could not figure out what C++ library this is]))))
6441AC_MSG_RESULT([$cpp_library_name])
6442AC_LANG_POP([C++])
6443
6444dnl ===================================================================
6445dnl Check for gperf
6446dnl ===================================================================
6447AC_PATH_PROG(GPERF, gperf)
6448if test -z "$GPERF"; then
6449    AC_MSG_ERROR([gperf not found but needed. Install it.])
6450fi
6451if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
6452    GPERF=`cygpath -m $GPERF`
6453fi
6454AC_MSG_CHECKING([whether gperf is new enough])
6455my_gperf_ver1=$($GPERF --version | head -n 1)
6456my_gperf_ver2=${my_gperf_ver1#GNU gperf }
6457my_gperf_ver3=$(printf %s "$my_gperf_ver2" | $AWK -F. '{ print $1*100+($2<100?$2:99) }')
6458if test "$my_gperf_ver3" -ge 301; then
6459    AC_MSG_RESULT([yes ($my_gperf_ver2)])
6460else
6461    AC_MSG_ERROR(["$my_gperf_ver1" is too old or unrecognized, must be at least gperf 3.1])
6462fi
6463AC_SUBST(GPERF)
6464
6465dnl ===================================================================
6466dnl Check for system libcmis
6467dnl ===================================================================
6468# libcmis requires curl and we can't build curl for iOS
6469if test $_os != iOS; then
6470    libo_CHECK_SYSTEM_MODULE([libcmis],[LIBCMIS],[libcmis-0.5 >= 0.5.2])
6471    ENABLE_LIBCMIS=TRUE
6472else
6473    ENABLE_LIBCMIS=
6474fi
6475AC_SUBST(ENABLE_LIBCMIS)
6476
6477dnl ===================================================================
6478dnl C++11
6479dnl ===================================================================
6480
6481AC_MSG_CHECKING([whether $CXX_BASE supports C++17])
6482CXXFLAGS_CXX11=
6483if test "$COM" = MSC -a "$COM_IS_CLANG" != TRUE; then
6484    if test "$with_latest_c__" = yes; then
6485        CXXFLAGS_CXX11=-std:c++latest
6486    else
6487        CXXFLAGS_CXX11=-std:c++17
6488    fi
6489    CXXFLAGS_CXX11="$CXXFLAGS_CXX11 -Zc:__cplusplus"
6490elif test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
6491    my_flags='-std=c++17 -std=c++1z'
6492    if test "$with_latest_c__" = yes; then
6493        my_flags="-std=gnu++2a -std=c++2a $my_flags"
6494    fi
6495    for flag in $my_flags; do
6496        if test "$COM" = MSC; then
6497            flag="-Xclang $flag"
6498        fi
6499        save_CXXFLAGS=$CXXFLAGS
6500        CXXFLAGS="$CXXFLAGS $flag -Werror"
6501        if test "$SYSTEM_LIBCMIS" = TRUE; then
6502            CXXFLAGS="$CXXFLAGS -DSYSTEM_LIBCMIS $LIBCMIS_CFLAGS"
6503        fi
6504        AC_LANG_PUSH([C++])
6505        dnl Clang 3.9 supports __float128 since
6506        dnl <http://llvm.org/viewvc/llvm-project?view=revision&revision=268898> "Enable support for
6507        dnl __float128 in Clang and enable it on pertinent platforms", but Clang 3.8 may need a
6508        dnl hacky workaround to be able to include <vector> (as is done in the main check whether
6509        dnl $flag is supported below, so check this first):
6510        my_float128hack=
6511        my_float128hack_impl=-D__float128=void
6512        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6513            #include <vector>
6514            // some Clang fail when compiling against libstdc++ headers with -std=gnu++0x
6515            // (__float128)
6516            ]])
6517        ],,[
6518            dnl The only reason why libstdc++ headers fail with Clang in C++11 mode is because they
6519            dnl use the __float128 type that Clang doesn't know (libstdc++ checks whether __float128
6520            dnl is available during its build, but it's usually built using GCC, and so c++config.h
6521            dnl hardcodes __float128 being supported). At least for some older libstdc++, the only
6522            dnl place where __float128 is used is in a template specialization, -D__float128=void
6523            dnl will avoid the problem there while still causing a problem if somebody actually uses
6524            dnl the type. (But some later libstdc++ are known to use __float128 also in algorithm ->
6525            dnl bits/stl_alog.h -> cstdlib -> bits/std_abs.h, in a way that unfortunately cannot be
6526            dnl "fixed" with this hack):
6527            CXXFLAGS="$CXXFLAGS $my_float128hack_impl"
6528            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6529                #include <vector>
6530                // some Clang fail when compiling against libstdc++ headers with -std=gnu++0x
6531                // (__float128)
6532                ]])
6533            ],[my_float128hack=$my_float128hack_impl])
6534        ])
6535        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6536            #include <algorithm>
6537            #include <functional>
6538            #include <vector>
6539
6540            #if defined SYSTEM_LIBCMIS
6541            // See ucb/source/ucp/cmis/auth_provider.hxx:
6542            #if !defined __clang__
6543            #pragma GCC diagnostic push
6544            #pragma GCC diagnostic ignored "-Wdeprecated"
6545            #pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
6546            #endif
6547            #include <libcmis/libcmis.hxx>
6548            #if !defined __clang__
6549            #pragma GCC diagnostic pop
6550            #endif
6551            #endif
6552
6553            void f(std::vector<int> & v, std::function<bool(int, int)> fn) {
6554                std::sort(v.begin(), v.end(), fn);
6555            }
6556            ]])],[CXXFLAGS_CXX11=$flag $my_float128hack])
6557        AC_LANG_POP([C++])
6558        CXXFLAGS=$save_CXXFLAGS
6559        if test -n "$CXXFLAGS_CXX11"; then
6560            break
6561        fi
6562    done
6563fi
6564if test -n "$CXXFLAGS_CXX11"; then
6565    AC_MSG_RESULT([yes ($CXXFLAGS_CXX11)])
6566else
6567    AC_MSG_ERROR(no)
6568fi
6569AC_SUBST(CXXFLAGS_CXX11)
6570
6571if test "$GCC" = "yes"; then
6572    save_CXXFLAGS=$CXXFLAGS
6573    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
6574    CHECK_L_ATOMIC
6575    CXXFLAGS=$save_CXXFLAGS
6576    AC_SUBST(ATOMIC_LIB)
6577fi
6578
6579dnl Test for temporarily incompatible libstdc++ 4.7.{0,1}, where
6580dnl <https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=179528> introduced
6581dnl an additional member _M_size into C++11 std::list towards 4.7.0 and
6582dnl <https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=189186> removed it
6583dnl again towards 4.7.2:
6584if test $CPP_LIBRARY = GLIBCXX; then
6585    AC_MSG_CHECKING([whether using C++11 causes libstdc++ 4.7.0/4.7.1 ABI breakage])
6586    AC_LANG_PUSH([C++])
6587    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6588#include <list>
6589#if !defined __GLIBCXX__ || (__GLIBCXX__ != 20120322 && __GLIBCXX__ != 20120614)
6590    // according to <https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html>:
6591    //   GCC 4.7.0: 20120322
6592    //   GCC 4.7.1: 20120614
6593    // and using a range check is not possible as the mapping between
6594    // __GLIBCXX__ values and GCC versions is not monotonic
6595/* ok */
6596#else
6597abi broken
6598#endif
6599        ]])], [AC_MSG_RESULT(no, ok)],
6600        [AC_MSG_ERROR(yes)])
6601    AC_LANG_POP([C++])
6602fi
6603
6604AC_MSG_CHECKING([whether $CXX_BASE supports C++11 without Language Defect 757])
6605save_CXXFLAGS=$CXXFLAGS
6606CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
6607AC_LANG_PUSH([C++])
6608
6609AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6610#include <stddef.h>
6611
6612template <typename T, size_t S> char (&sal_n_array_size( T(&)[S] ))[S];
6613
6614namespace
6615{
6616        struct b
6617        {
6618                int i;
6619                int j;
6620        };
6621}
6622]], [[
6623struct a
6624{
6625        int i;
6626        int j;
6627};
6628a thinga[]={{0,0}, {1,1}};
6629b thingb[]={{0,0}, {1,1}};
6630size_t i = sizeof(sal_n_array_size(thinga));
6631size_t j = sizeof(sal_n_array_size(thingb));
6632return !(i != 0 && j != 0);
6633]])
6634    ], [ AC_MSG_RESULT(yes) ],
6635    [ AC_MSG_ERROR(no)])
6636AC_LANG_POP([C++])
6637CXXFLAGS=$save_CXXFLAGS
6638
6639dnl _Pragma support (may require C++11)
6640if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
6641    AC_MSG_CHECKING([whether $CXX_BASE supports _Pragma operator])
6642    AC_LANG_PUSH([C++])
6643    save_CXXFLAGS=$CXXFLAGS
6644    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11 -Werror"
6645    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6646            _Pragma("GCC diagnostic ignored \"-Wformat\"")
6647        ])], [
6648            AC_DEFINE([HAVE_GCC_PRAGMA_OPERATOR],[1])
6649            AC_MSG_RESULT([yes])
6650        ], [AC_MSG_RESULT([no])])
6651    AC_LANG_POP([C++])
6652    CXXFLAGS=$save_CXXFLAGS
6653fi
6654
6655HAVE_GCC_FNO_SIZED_DEALLOCATION=
6656if test "$GCC" = yes; then
6657    AC_MSG_CHECKING([whether $CXX_BASE supports -fno-sized-deallocation])
6658    AC_LANG_PUSH([C++])
6659    save_CXXFLAGS=$CXXFLAGS
6660    CXXFLAGS="$CXXFLAGS -fno-sized-deallocation"
6661    AC_LINK_IFELSE([AC_LANG_PROGRAM()],[HAVE_GCC_FNO_SIZED_DEALLOCATION=TRUE])
6662    CXXFLAGS=$save_CXXFLAGS
6663    AC_LANG_POP([C++])
6664    if test "$HAVE_GCC_FNO_SIZED_DEALLOCATION" = TRUE; then
6665        AC_MSG_RESULT([yes])
6666    else
6667        AC_MSG_RESULT([no])
6668    fi
6669fi
6670AC_SUBST([HAVE_GCC_FNO_SIZED_DEALLOCATION])
6671
6672AC_MSG_CHECKING([whether $CXX_BASE supports guaranteed copy elision])
6673AC_LANG_PUSH([C++])
6674save_CXXFLAGS=$CXXFLAGS
6675CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
6676AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6677        // At least VS 2017 15.8.1 defines __cpp_guaranteed_copy_elision as 201606L without actually
6678        // supporting it:
6679        #if !defined __cpp_guaranteed_copy_elision || (defined _MSC_VER && !defined __clang__)
6680        struct S {
6681        private:
6682            S(S const &);
6683        public:
6684            S();
6685            ~S();
6686        };
6687        S copy();
6688        void f() { S c(copy()); }
6689        #endif
6690    ])], [
6691        AC_DEFINE([HAVE_CPP_GUARANTEED_COPY_ELISION],[1])
6692        AC_MSG_RESULT([yes])
6693    ], [AC_MSG_RESULT([no])])
6694CXXFLAGS=$save_CXXFLAGS
6695AC_LANG_POP([C++])
6696
6697AC_MSG_CHECKING([whether $CXX_BASE supports C++2a constinit sorted vectors])
6698AC_LANG_PUSH([C++])
6699save_CXXFLAGS=$CXXFLAGS
6700CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
6701AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6702        #include <algorithm>
6703        #include <initializer_list>
6704        #include <vector>
6705        template<typename T> class S {
6706        private:
6707            std::vector<T> v_;
6708        public:
6709            constexpr S(std::initializer_list<T> i): v_(i) { std::sort(v_.begin(), v_.end()); }
6710        };
6711        constinit S<int> s{3, 2, 1};
6712    ])], [
6713        AC_DEFINE([HAVE_CPP_CONSTINIT_SORTED_VECTOR],[1])
6714        AC_MSG_RESULT([yes])
6715    ], [AC_MSG_RESULT([no])])
6716CXXFLAGS=$save_CXXFLAGS
6717AC_LANG_POP([C++])
6718
6719AC_MSG_CHECKING([whether $CXX_BASE supports C++2a <span> with unsigned size_type])
6720AC_LANG_PUSH([C++])
6721save_CXXFLAGS=$CXXFLAGS
6722CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
6723AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6724        #include <span>
6725        #include <type_traits>
6726        // Don't check size_type directly, as it was called index_type before P1872R0:
6727        void f(std::span<int> s) { static_assert(std::is_unsigned_v<decltype(s.size())>); };
6728    ])], [
6729        AC_DEFINE([HAVE_CPP_SPAN],[1])
6730        AC_MSG_RESULT([yes])
6731    ], [AC_MSG_RESULT([no])])
6732CXXFLAGS=$save_CXXFLAGS
6733AC_LANG_POP([C++])
6734
6735AC_MSG_CHECKING([whether $CXX_BASE has GCC bug 87150])
6736AC_LANG_PUSH([C++])
6737save_CXXFLAGS=$CXXFLAGS
6738CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
6739AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6740        struct S1 { S1(S1 &&); };
6741        struct S2: S1 {};
6742        S1 f(S2 s) { return s; }
6743    ])], [
6744        AC_DEFINE([HAVE_GCC_BUG_87150],[1])
6745        AC_MSG_RESULT([yes])
6746    ], [AC_MSG_RESULT([no])])
6747CXXFLAGS=$save_CXXFLAGS
6748AC_LANG_POP([C++])
6749
6750dnl At least GCC 8.2 with -O2 (i.e., --enable-optimized) causes a false-positive -Wmaybe-
6751dnl uninitialized warning for code like
6752dnl
6753dnl   OString f();
6754dnl   boost::optional<OString> * g(bool b) {
6755dnl       boost::optional<OString> o;
6756dnl       if (b) o = f();
6757dnl       return new boost::optional<OString>(o);
6758dnl   }
6759dnl
6760dnl (as is e.g. present, in a slightly more elaborate form, in
6761dnl librdf_TypeConverter::extractNode_NoLock in unoxml/source/rdf/librdf_repository.cxx); the below
6762dnl code is meant to be a faithfully stripped-down and self-contained version of the above code:
6763HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED=
6764if test "$GCC" = yes && test "$COM_IS_CLANG" != TRUE; then
6765    AC_MSG_CHECKING([whether $CXX_BASE might report false -Werror=maybe-uninitialized])
6766    AC_LANG_PUSH([C++])
6767    save_CXXFLAGS=$CXXFLAGS
6768    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11 -Werror -Wmaybe-uninitialized"
6769    if test "$ENABLE_OPTIMIZED" = TRUE; then
6770        CXXFLAGS="$CXXFLAGS -O2"
6771    else
6772        CXXFLAGS="$CXXFLAGS -O0"
6773    fi
6774    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
6775            #include <new>
6776            void f1(int);
6777            struct S1 {
6778                ~S1() { f1(n); }
6779                int n = 0;
6780            };
6781            struct S2 {
6782                S2() {}
6783                S2(S2 const & s) { if (s.init) set(*reinterpret_cast<S1 const *>(s.stg)); }
6784                ~S2() { if (init) reinterpret_cast<S1 *>(stg)->S1::~S1(); }
6785                void set(S1 s) {
6786                    new (stg) S1(s);
6787                    init = true;
6788                }
6789                bool init = false;
6790                char stg[sizeof (S1)];
6791            } ;
6792            S1 f2();
6793            S2 * f3(bool b) {
6794                S2 o;
6795                if (b) o.set(f2());
6796                return new S2(o);
6797            }
6798        ]])], [AC_MSG_RESULT([no])], [
6799            HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED=TRUE
6800            AC_MSG_RESULT([yes])
6801        ])
6802    CXXFLAGS=$save_CXXFLAGS
6803    AC_LANG_POP([C++])
6804fi
6805AC_SUBST([HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED])
6806
6807dnl ===================================================================
6808dnl CPU Intrinsics support - SSE, AVX
6809dnl ===================================================================
6810
6811INTRINSICS_CXXFLAGS=""
6812
6813if test "$GCC" = "yes"; then
6814    AC_MSG_CHECKING([whether $CXX can compile SSE2 intrinsics])
6815    AC_LANG_PUSH([C++])
6816    save_CXXFLAGS=$CXXFLAGS
6817    CXXFLAGS="$CXXFLAGS -msse2"
6818    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6819        #include <emmintrin.h>
6820        int main () {
6821            volatile __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
6822            c = _mm_xor_si128 (a, b);
6823            return 0;
6824        }
6825        ])],
6826        [can_compile_sse2=yes],
6827        [can_compile_sse2=no])
6828    AC_LANG_POP([C++])
6829    CXXFLAGS=$save_CXXFLAGS
6830    AC_MSG_RESULT([${can_compile_sse2}])
6831    if test "${can_compile_sse2}" = "yes" ; then
6832        INTRINSICS_CXXFLAGS="-msse2"
6833    else
6834        AC_MSG_WARN([cannot compile SSE2 intrinsics])
6835    fi
6836
6837    AC_MSG_CHECKING([whether $CXX can compile SSSE3 intrinsics])
6838    AC_LANG_PUSH([C++])
6839    save_CXXFLAGS=$CXXFLAGS
6840    CXXFLAGS="$CXXFLAGS -mssse3"
6841    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6842        #include <tmmintrin.h>
6843        int main () {
6844            volatile __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
6845            c = _mm_maddubs_epi16 (a, b);
6846            return 0;
6847        }
6848        ])],
6849        [can_compile_ssse3=yes],
6850        [can_compile_ssse3=no])
6851    AC_LANG_POP([C++])
6852    CXXFLAGS=$save_CXXFLAGS
6853    AC_MSG_RESULT([${can_compile_ssse3}])
6854    if test "${can_compile_ssse3}" = "yes" ; then
6855        INTRINSICS_CXXFLAGS="-mssse3"
6856    else
6857        AC_MSG_WARN([cannot compile SSSE3 intrinsics])
6858    fi
6859
6860    AC_MSG_CHECKING([whether $CXX can compile AVX intrinsics])
6861    AC_LANG_PUSH([C++])
6862    save_CXXFLAGS=$CXXFLAGS
6863    CXXFLAGS="$CXXFLAGS -mavx"
6864    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6865        #include <immintrin.h>
6866        int main () {
6867            volatile __m256 a = _mm256_set1_ps (0.0f), b = _mm256_set1_ps (0.0f), c;
6868            c = _mm256_xor_ps(a, b);
6869            return 0;
6870        }
6871        ])],
6872        [can_compile_avx=yes],
6873        [can_compile_avx=no])
6874    AC_LANG_POP([C++])
6875    CXXFLAGS=$save_CXXFLAGS
6876    AC_MSG_RESULT([${can_compile_avx}])
6877    if test "${can_compile_avx}" = "yes" ; then
6878        INTRINSICS_CXXFLAGS="-mavx"
6879    else
6880        AC_MSG_WARN([cannot compile AVX intrinsics])
6881    fi
6882
6883    AC_MSG_CHECKING([whether $CXX can compile AVX2 intrinsics])
6884    AC_LANG_PUSH([C++])
6885    save_CXXFLAGS=$CXXFLAGS
6886    CXXFLAGS="$CXXFLAGS -mavx2"
6887    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6888        #include <immintrin.h>
6889        int main () {
6890            volatile __m256i a = _mm256_set1_epi32 (0), b = _mm256_set1_epi32 (0), c;
6891            c = _mm256_maddubs_epi16(a, b);
6892            return 0;
6893        }
6894        ])],
6895        [can_compile_avx2=yes],
6896        [can_compile_avx2=no])
6897    AC_LANG_POP([C++])
6898    CXXFLAGS=$save_CXXFLAGS
6899    AC_MSG_RESULT([${can_compile_avx2}])
6900    if test "${can_compile_avx2}" = "yes" ; then
6901        INTRINSICS_CXXFLAGS="-mavx2"
6902    else
6903        AC_MSG_WARN([cannot compile AVX2 intrinsics])
6904    fi
6905fi
6906
6907AC_SUBST([INTRINSICS_CXXFLAGS])
6908
6909dnl ===================================================================
6910dnl system stl sanity tests
6911dnl ===================================================================
6912if test "$_os" != "WINNT"; then
6913
6914    AC_LANG_PUSH([C++])
6915
6916    save_CPPFLAGS="$CPPFLAGS"
6917    if test -n "$MACOSX_SDK_PATH"; then
6918        CPPFLAGS="-isysroot $MACOSX_SDK_PATH $CPPFLAGS"
6919    fi
6920
6921    # Assume visibility is not broken with libc++. The below test is very much designed for libstdc++
6922    # only.
6923    if test "$CPP_LIBRARY" = GLIBCXX; then
6924        dnl gcc#19664, gcc#22482, rhbz#162935
6925        AC_MSG_CHECKING([if STL headers are visibility safe (GCC bug 22482)])
6926        AC_EGREP_HEADER(visibility push, string, stlvisok=yes, stlvisok=no)
6927        AC_MSG_RESULT([$stlvisok])
6928        if test "$stlvisok" = "no"; then
6929            AC_MSG_ERROR([Your libstdc++ headers are not visibility safe. This is no longer supported.])
6930        fi
6931    fi
6932
6933    # As the below test checks things when linking self-compiled dynamic libraries, it presumably is irrelevant
6934    # when we don't make any dynamic libraries?
6935    if test "$DISABLE_DYNLOADING" = ""; then
6936        AC_MSG_CHECKING([if $CXX_BASE is -fvisibility-inlines-hidden safe (Clang bug 11250)])
6937        cat > conftestlib1.cc <<_ACEOF
6938template<typename T> struct S1 { virtual ~S1() {} virtual void f() {} };
6939struct S2: S1<int> { virtual ~S2(); };
6940S2::~S2() {}
6941_ACEOF
6942        cat > conftestlib2.cc <<_ACEOF
6943template<typename T> struct S1 { virtual ~S1() {} virtual void f() {} };
6944struct S2: S1<int> { virtual ~S2(); };
6945struct S3: S2 { virtual ~S3(); }; S3::~S3() {}
6946_ACEOF
6947        gccvisinlineshiddenok=yes
6948        if ! $CXX $CXXFLAGS $CPPFLAGS $LINKFLAGSSHL -fPIC -fvisibility-inlines-hidden conftestlib1.cc -o libconftest1$DLLPOST >/dev/null 2>&5; then
6949            gccvisinlineshiddenok=no
6950        else
6951            dnl At least Clang -fsanitize=address and -fsanitize=undefined are
6952            dnl known to not work with -z defs (unsetting which makes the test
6953            dnl moot, though):
6954            my_linkflagsnoundefs=$LINKFLAGSNOUNDEFS
6955            if test "$COM_IS_CLANG" = TRUE; then
6956                for i in $CXX $CXXFLAGS; do
6957                    case $i in
6958                    -fsanitize=*)
6959                        my_linkflagsnoundefs=
6960                        break
6961                        ;;
6962                    esac
6963                done
6964            fi
6965            if ! $CXX $CXXFLAGS $CPPFLAGS $LINKFLAGSSHL -fPIC -fvisibility-inlines-hidden conftestlib2.cc -L. -lconftest1 $my_linkflagsnoundefs -o libconftest2$DLLPOST >/dev/null 2>&5; then
6966                gccvisinlineshiddenok=no
6967            fi
6968        fi
6969
6970        rm -fr libconftest*
6971        AC_MSG_RESULT([$gccvisinlineshiddenok])
6972        if test "$gccvisinlineshiddenok" = "no"; then
6973            AC_MSG_ERROR([Your gcc/clang is not -fvisibility-inlines-hidden safe. This is no longer supported.])
6974        fi
6975    fi
6976
6977   AC_MSG_CHECKING([if $CXX_BASE has a visibility bug with class-level attributes (GCC bug 26905)])
6978    cat >visibility.cxx <<_ACEOF
6979#pragma GCC visibility push(hidden)
6980struct __attribute__ ((visibility ("default"))) TestStruct {
6981  static void Init();
6982};
6983__attribute__ ((visibility ("default"))) void TestFunc() {
6984  TestStruct::Init();
6985}
6986_ACEOF
6987    if ! $CXX $CXXFLAGS $CPPFLAGS -fpic -S visibility.cxx; then
6988        gccvisbroken=yes
6989    else
6990        case "$host_cpu" in
6991        i?86|x86_64)
6992            if test "$_os" = "Darwin" -o "$_os" = "iOS"; then
6993                gccvisbroken=no
6994            else
6995                if $EGREP -q '@PLT|@GOT' visibility.s || test "$ENABLE_LTO" = "TRUE"; then
6996                    gccvisbroken=no
6997                else
6998                    gccvisbroken=yes
6999                fi
7000            fi
7001            ;;
7002        *)
7003            gccvisbroken=no
7004            ;;
7005        esac
7006    fi
7007    rm -f visibility.s visibility.cxx
7008
7009    AC_MSG_RESULT([$gccvisbroken])
7010    if test "$gccvisbroken" = "yes"; then
7011        AC_MSG_ERROR([Your gcc is not -fvisibility=hidden safe. This is no longer supported.])
7012    fi
7013
7014    CPPFLAGS="$save_CPPFLAGS"
7015
7016    AC_LANG_POP([C++])
7017fi
7018
7019dnl ===================================================================
7020dnl  Clang++ tests
7021dnl ===================================================================
7022
7023HAVE_GCC_FNO_ENFORCE_EH_SPECS=
7024if test "$GCC" = "yes"; then
7025    AC_MSG_CHECKING([whether $CXX_BASE supports -fno-enforce-eh-specs])
7026    AC_LANG_PUSH([C++])
7027    save_CXXFLAGS=$CXXFLAGS
7028    CXXFLAGS="$CFLAGS -Werror -fno-enforce-eh-specs"
7029    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_FNO_ENFORCE_EH_SPECS=TRUE ],[])
7030    CXXFLAGS=$save_CXXFLAGS
7031    AC_LANG_POP([C++])
7032    if test "$HAVE_GCC_FNO_ENFORCE_EH_SPECS" = "TRUE"; then
7033        AC_MSG_RESULT([yes])
7034    else
7035        AC_MSG_RESULT([no])
7036    fi
7037fi
7038AC_SUBST(HAVE_GCC_FNO_ENFORCE_EH_SPECS)
7039
7040dnl ===================================================================
7041dnl Compiler plugins
7042dnl ===================================================================
7043
7044COMPILER_PLUGINS=
7045# currently only Clang
7046
7047if test "$COM_IS_CLANG" != "TRUE"; then
7048    if test "$libo_fuzzed_enable_compiler_plugins" = yes -a "$enable_compiler_plugins" = yes; then
7049        AC_MSG_NOTICE([Resetting --enable-compiler-plugins=no])
7050        enable_compiler_plugins=no
7051    fi
7052fi
7053
7054if test "$COM_IS_CLANG" = "TRUE"; then
7055    if test -n "$enable_compiler_plugins"; then
7056        compiler_plugins="$enable_compiler_plugins"
7057    elif test -n "$ENABLE_DBGUTIL"; then
7058        compiler_plugins=test
7059    else
7060        compiler_plugins=no
7061    fi
7062    if test "$compiler_plugins" != no -a "$my_apple_clang" != yes; then
7063        if test "$CLANGVER" -lt 50002; then
7064            if test "$compiler_plugins" = yes; then
7065                AC_MSG_ERROR([Clang $CLANGVER is too old to build compiler plugins; need >= 5.0.2.])
7066            else
7067                compiler_plugins=no
7068            fi
7069        fi
7070    fi
7071    if test "$compiler_plugins" != "no"; then
7072        dnl The prefix where Clang resides, override to where Clang resides if
7073        dnl using a source build:
7074        if test -z "$CLANGDIR"; then
7075            CLANGDIR=$(dirname $(dirname $($CXX -print-prog-name=$(basename $CXX))))
7076        fi
7077        # Assume Clang is self-built, but allow overriding COMPILER_PLUGINS_CXX to the compiler Clang was built with.
7078        if test -z "$COMPILER_PLUGINS_CXX"; then
7079            COMPILER_PLUGINS_CXX=[$(echo $CXX | sed -e 's/-fsanitize=[^ ]*//g')]
7080        fi
7081        clangbindir=$CLANGDIR/bin
7082        if test "$build_os" = "cygwin"; then
7083            clangbindir=$(cygpath -u "$clangbindir")
7084        fi
7085        AC_PATH_PROG(LLVM_CONFIG, llvm-config,[],"$clangbindir" $PATH)
7086        if test -n "$LLVM_CONFIG"; then
7087            COMPILER_PLUGINS_CXXFLAGS=$($LLVM_CONFIG --cxxflags)
7088            COMPILER_PLUGINS_LINKFLAGS=$($LLVM_CONFIG --ldflags --libs --system-libs | tr '\n' ' ')
7089            if test -z "$CLANGLIBDIR"; then
7090                CLANGLIBDIR=$($LLVM_CONFIG --libdir)
7091            fi
7092            # Try if clang is built from source (in which case its includes are not together with llvm includes).
7093            # src-root is [llvm-toplevel-src-dir]/llvm, clang is [llvm-toplevel-src-dir]/clang
7094            clangsrcdir=$(dirname $($LLVM_CONFIG --src-root))
7095            if test -n "$clangsrcdir" -a -d "$clangsrcdir" -a -d "$clangsrcdir/clang/include"; then
7096                COMPILER_PLUGINS_CXXFLAGS="$COMPILER_PLUGINS_CXXFLAGS -I$clangsrcdir/clang/include"
7097            fi
7098            # obj-root is [llvm-toplevel-obj-dir]/, clang is [llvm-toplevel-obj-dir]/tools/clang
7099            clangobjdir=$($LLVM_CONFIG --obj-root)
7100            if test -n "$clangobjdir" -a -d "$clangobjdir" -a -d "$clangobjdir/tools/clang/include"; then
7101                COMPILER_PLUGINS_CXXFLAGS="$COMPILER_PLUGINS_CXXFLAGS -I$clangobjdir/tools/clang/include"
7102            fi
7103        fi
7104        AC_MSG_NOTICE([compiler plugins compile flags: $COMPILER_PLUGINS_CXXFLAGS])
7105        AC_LANG_PUSH([C++])
7106        save_CXX=$CXX
7107        save_CXXCPP=$CXXCPP
7108        save_CPPFLAGS=$CPPFLAGS
7109        save_CXXFLAGS=$CXXFLAGS
7110        save_LDFLAGS=$LDFLAGS
7111        save_LIBS=$LIBS
7112        CXX=$COMPILER_PLUGINS_CXX
7113        CXXCPP="$COMPILER_PLUGINS_CXX -E"
7114        CPPFLAGS="$COMPILER_PLUGINS_CXXFLAGS"
7115        CXXFLAGS="$COMPILER_PLUGINS_CXXFLAGS"
7116        AC_CHECK_HEADER(clang/Basic/SourceLocation.h,
7117            [COMPILER_PLUGINS=TRUE],
7118            [
7119            if test "$compiler_plugins" = "yes"; then
7120                AC_MSG_ERROR([Cannot find Clang headers to build compiler plugins.])
7121            else
7122                AC_MSG_WARN([Cannot find Clang headers to build compiler plugins, plugins disabled])
7123                add_warning "Cannot find Clang headers to build compiler plugins, plugins disabled."
7124            fi
7125            ])
7126        dnl TODO: Windows doesn't use LO_CLANG_SHARED_PLUGINS for now, see corresponding TODO
7127        dnl comment in compilerplugins/Makefile-clang.mk:
7128        if test -n "$COMPILER_PLUGINS" && test "$_os" != "WINNT"; then
7129            LDFLAGS=""
7130            AC_MSG_CHECKING([for clang libraries to use])
7131            if test -z "$CLANGTOOLLIBS"; then
7132                LIBS="-lclangTooling -lclangDriver -lclangFrontend -lclangParse -lclangSema -lclangEdit \
7133 -lclangAnalysis -lclangAST -lclangLex -lclangSerialization -lclangBasic $COMPILER_PLUGINS_LINKFLAGS"
7134                AC_LINK_IFELSE([
7135                    AC_LANG_PROGRAM([[#include "clang/Basic/SourceLocation.h"]],
7136                        [[ clang::FullSourceLoc().dump(); ]])
7137                ],[CLANGTOOLLIBS="$LIBS"],[])
7138            fi
7139            if test -z "$CLANGTOOLLIBS"; then
7140                LIBS="-lclang-cpp $COMPILER_PLUGINS_LINKFLAGS"
7141                AC_LINK_IFELSE([
7142                    AC_LANG_PROGRAM([[#include "clang/Basic/SourceLocation.h"]],
7143                        [[ clang::FullSourceLoc().dump(); ]])
7144                ],[CLANGTOOLLIBS="$LIBS"],[])
7145            fi
7146            AC_MSG_RESULT([$CLANGTOOLLIBS])
7147            if test -z "$CLANGTOOLLIBS"; then
7148                if test "$compiler_plugins" = "yes"; then
7149                    AC_MSG_ERROR([Cannot find Clang libraries to build compiler plugins.])
7150                else
7151                    AC_MSG_WARN([Cannot find Clang libraries to build compiler plugins, plugins disabled])
7152                    add_warning "Cannot find Clang libraries to build compiler plugins, plugins disabled."
7153                fi
7154                COMPILER_PLUGINS=
7155            fi
7156            if test -n "$COMPILER_PLUGINS"; then
7157                if test -z "$CLANGSYSINCLUDE"; then
7158                    if test -n "$LLVM_CONFIG"; then
7159                        # Path to the clang system headers (no idea if there's a better way to get it).
7160                        CLANGSYSINCLUDE=$($LLVM_CONFIG --libdir)/clang/$($LLVM_CONFIG --version | sed 's/svn//')/include
7161                    fi
7162                fi
7163            fi
7164        fi
7165        CXX=$save_CXX
7166        CXXCPP=$save_CXXCPP
7167        CPPFLAGS=$save_CPPFLAGS
7168        CXXFLAGS=$save_CXXFLAGS
7169        LDFLAGS=$save_LDFLAGS
7170        LIBS="$save_LIBS"
7171        AC_LANG_POP([C++])
7172    fi
7173else
7174    if test "$enable_compiler_plugins" = "yes"; then
7175        AC_MSG_ERROR([Compiler plugins are currently supported only with the Clang compiler.])
7176    fi
7177fi
7178AC_SUBST(COMPILER_PLUGINS)
7179AC_SUBST(COMPILER_PLUGINS_CXX)
7180AC_SUBST(COMPILER_PLUGINS_CXXFLAGS)
7181AC_SUBST(COMPILER_PLUGINS_CXX_LINKFLAGS)
7182AC_SUBST(COMPILER_PLUGINS_DEBUG)
7183AC_SUBST(COMPILER_PLUGINS_TOOLING_ARGS)
7184AC_SUBST(CLANGDIR)
7185AC_SUBST(CLANGLIBDIR)
7186AC_SUBST(CLANGTOOLLIBS)
7187AC_SUBST(CLANGSYSINCLUDE)
7188
7189# Plugin to help linker.
7190# Add something like LD_PLUGIN=/usr/lib64/LLVMgold.so to your autogen.input.
7191# This makes --enable-lto build with clang work.
7192AC_SUBST(LD_PLUGIN)
7193
7194AC_CHECK_FUNCS(posix_fallocate, HAVE_POSIX_FALLOCATE=YES, [HAVE_POSIX_FALLOCATE=NO])
7195AC_SUBST(HAVE_POSIX_FALLOCATE)
7196
7197dnl ===================================================================
7198dnl Custom build version
7199dnl ===================================================================
7200
7201AC_MSG_CHECKING([whether to add custom build version])
7202if test "$with_build_version" != ""; then
7203    BUILD_VER_STRING=$with_build_version
7204    AC_MSG_RESULT([yes, $BUILD_VER_STRING])
7205else
7206    BUILD_VER_STRING=
7207    AC_MSG_RESULT([no])
7208fi
7209AC_SUBST(BUILD_VER_STRING)
7210
7211JITC_PROCESSOR_TYPE=""
7212if test "$_os" = "Linux" -a "$host_cpu" = "powerpc"; then
7213    # IBMs JDK needs this...
7214    JITC_PROCESSOR_TYPE=6
7215    export JITC_PROCESSOR_TYPE
7216fi
7217AC_SUBST([JITC_PROCESSOR_TYPE])
7218
7219# Misc Windows Stuff
7220AC_ARG_WITH(ucrt-dir,
7221    AS_HELP_STRING([--with-ucrt-dir],
7222        [path to the directory with the arch-specific MSU packages of the Windows Universal CRT redistributables
7223        (MS KB 2999226) for packaging into the installsets (without those the target system needs to install
7224        the UCRT or Visual C++ Runtimes manually). The directory must contain the following 6 files:
7225            Windows6.1-KB2999226-x64.msu
7226            Windows6.1-KB2999226-x86.msu
7227            Windows8.1-KB2999226-x64.msu
7228            Windows8.1-KB2999226-x86.msu
7229            Windows8-RT-KB2999226-x64.msu
7230            Windows8-RT-KB2999226-x86.msu
7231        A zip archive including those files is available from Microsoft site:
7232        https://www.microsoft.com/en-us/download/details.aspx?id=48234]),
7233,)
7234UCRT_REDISTDIR="$with_ucrt_dir"
7235if test $_os = "WINNT"; then
7236    find_msvc_x64_dlls
7237    find_msms
7238    MSVC_DLL_PATH=`win_short_path_for_make "$msvcdllpath"`
7239    MSVC_DLLS="$msvcdlls"
7240    MSM_PATH=`win_short_path_for_make "$msmdir"`
7241    # MSVC 15.3 changed it to VC141
7242    if echo "$msvcdllpath" | grep -q "VC141.CRT$"; then
7243        SCPDEFS="$SCPDEFS -DWITH_VC141_REDIST"
7244    else
7245        SCPDEFS="$SCPDEFS -DWITH_VC${VCVER}_REDIST"
7246    fi
7247
7248    if test "$UCRT_REDISTDIR" = "no"; then
7249        dnl explicitly disabled
7250        UCRT_REDISTDIR=""
7251    else
7252        if ! test -f "$UCRT_REDISTDIR/Windows6.1-KB2999226-x64.msu" -a \
7253                  -f "$UCRT_REDISTDIR/Windows6.1-KB2999226-x86.msu" -a \
7254                  -f "$UCRT_REDISTDIR/Windows8.1-KB2999226-x64.msu" -a \
7255                  -f "$UCRT_REDISTDIR/Windows8.1-KB2999226-x86.msu" -a \
7256                  -f "$UCRT_REDISTDIR/Windows8-RT-KB2999226-x64.msu" -a \
7257                  -f "$UCRT_REDISTDIR/Windows8-RT-KB2999226-x86.msu"; then
7258            UCRT_REDISTDIR=""
7259            if test -n "$PKGFORMAT"; then
7260               for i in $PKGFORMAT; do
7261                   case "$i" in
7262                   msi)
7263                       AC_MSG_WARN([--without-ucrt-dir not specified or MSUs not found - installer will have runtime dependency])
7264                       add_warning "--without-ucrt-dir not specified or MSUs not found - installer will have runtime dependency"
7265                       ;;
7266                   esac
7267               done
7268            fi
7269        fi
7270    fi
7271fi
7272
7273AC_SUBST(UCRT_REDISTDIR)
7274AC_SUBST(MSVC_DLL_PATH)
7275AC_SUBST(MSVC_DLLS)
7276AC_SUBST(MSM_PATH)
7277
7278dnl ===================================================================
7279dnl Checks for Java
7280dnl ===================================================================
7281if test "$ENABLE_JAVA" != ""; then
7282
7283    # Windows-specific tests
7284    if test "$build_os" = "cygwin"; then
7285        if test "$BITNESS_OVERRIDE" = 64; then
7286            bitness=64
7287        else
7288            bitness=32
7289        fi
7290
7291        if test -z "$with_jdk_home"; then
7292            dnl See <https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-EEED398E-AE37-4D12-
7293            dnl AB10-49F82F720027> section "Windows Registry Key Changes":
7294            reg_get_value "$bitness" "HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/JDK/CurrentVersion"
7295            if test -n "$regvalue"; then
7296                ver=$regvalue
7297                reg_get_value "$bitness" "HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/JDK/$ver/JavaHome"
7298                _jdk_home=$regvalue
7299            fi
7300            if test -z "$with_jdk_home"; then
7301                for ver in 1.8; do
7302                    reg_get_value "$bitness" "HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java Development Kit/$ver/JavaHome"
7303                    if test -n "$regvalue"; then
7304                        _jdk_home=$regvalue
7305                        break
7306                    fi
7307                done
7308            fi
7309            if test -f "$_jdk_home/lib/jvm.lib" -a -f "$_jdk_home/bin/java.exe"; then
7310                with_jdk_home="$_jdk_home"
7311                howfound="found automatically"
7312            else
7313                AC_MSG_ERROR([No JDK found, pass the --with-jdk-home option pointing to a $bitness-bit JDK])
7314            fi
7315        else
7316            test "$build_os" = "cygwin" && with_jdk_home=`win_short_path_for_make "$with_jdk_home"`
7317            howfound="you passed"
7318        fi
7319    fi
7320
7321    # macOS: /usr/libexec/java_home helps to set the current JDK_HOME. Actually JDK_HOME should NOT be set where java (/usr/bin/java) is located.
7322    # /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java, but /usr does not contain the JDK libraries
7323    if test -z "$with_jdk_home" -a "$_os" = "Darwin" -a -x /usr/libexec/java_home; then
7324        with_jdk_home=`/usr/libexec/java_home`
7325    fi
7326
7327    JAVA_HOME=; export JAVA_HOME
7328    if test -z "$with_jdk_home"; then
7329        AC_PATH_PROG(JAVAINTERPRETER, $with_java)
7330    else
7331        _java_path="$with_jdk_home/bin/$with_java"
7332        dnl Check if there is a Java interpreter at all.
7333        if test -x "$_java_path"; then
7334            JAVAINTERPRETER=$_java_path
7335        else
7336            AC_MSG_ERROR([$_java_path not found, pass --with-jdk-home])
7337        fi
7338    fi
7339
7340    dnl Check that the JDK found is correct architecture (at least 2 reasons to
7341    dnl check: officebean needs to link -ljawt, and libjpipe.so needs to be
7342    dnl loaded by java to run JunitTests:
7343    if test "$build_os" = "cygwin"; then
7344        shortjdkhome=`cygpath -d "$with_jdk_home"`
7345        if test "$BITNESS_OVERRIDE" = 64 -a -f "$with_jdk_home/bin/java.exe" -a "`$shortjdkhome/bin/java.exe -version 2>&1 | $GREP -i 64-bit`" = "" >/dev/null; then
7346            AC_MSG_WARN([You are building 64-bit binaries but the JDK $howfound is 32-bit])
7347            AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a 64-bit JDK])
7348        elif test "$BITNESS_OVERRIDE" = "" -a -f "$_jdk_home/bin/java.exe" -a "`$shortjdkhome/bin/java.exe -version 2>&1 | $GREP -i 64-bit`" != ""  >/dev/null; then
7349            AC_MSG_WARN([You are building 32-bit binaries but the JDK $howfound is 64-bit])
7350            AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a (32-bit) JDK])
7351        fi
7352
7353        if test x`echo "$JAVAINTERPRETER" | $GREP -i '\.exe$'` = x; then
7354            JAVAINTERPRETER="${JAVAINTERPRETER}.exe"
7355        fi
7356        JAVAINTERPRETER=`win_short_path_for_make "$JAVAINTERPRETER"`
7357    elif test "$cross_compiling" != "yes"; then
7358        case $CPUNAME in
7359            AARCH64|AXP|X86_64|HPPA|IA64|POWERPC64|S390X|SPARC64|GODSON64)
7360                if test -f "$JAVAINTERPRETER" -a "`$JAVAINTERPRETER -version 2>&1 | $GREP -i 64-bit`" = "" >/dev/null; then
7361                    AC_MSG_WARN([You are building 64-bit binaries but the JDK $JAVAINTERPRETER is 32-bit])
7362                    AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a 64-bit JDK])
7363                fi
7364                ;;
7365            *) # assumption: everything else 32-bit
7366                if test -f "$JAVAINTERPRETER" -a "`$JAVAINTERPRETER -version 2>&1 | $GREP -i 64-bit`" != ""  >/dev/null; then
7367                    AC_MSG_WARN([You are building 32-bit binaries but the JDK $howfound is 64-bit])
7368                    AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a (32-bit) JDK])
7369                fi
7370                ;;
7371        esac
7372    fi
7373fi
7374
7375dnl ===================================================================
7376dnl Checks for JDK.
7377dnl ===================================================================
7378
7379# Note that JAVA_HOME as for now always means the *build* platform's
7380# JAVA_HOME. Whether all the complexity here actually is needed any
7381# more or not, no idea.
7382
7383if test "$ENABLE_JAVA" != ""; then
7384    _gij_longver=0
7385    AC_MSG_CHECKING([the installed JDK])
7386    if test -n "$JAVAINTERPRETER"; then
7387        dnl java -version sends output to stderr!
7388        if test `$JAVAINTERPRETER -version 2>&1 | $GREP -c "Kaffe"` -gt 0; then
7389            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
7390        elif test `$JAVAINTERPRETER --version 2>&1 | $GREP -c "GNU libgcj"` -gt 0; then
7391            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
7392        elif test `$JAVAINTERPRETER -version 2>&1 | $AWK '{ print }' | $GREP -c "BEA"` -gt 0; then
7393            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
7394        elif test `$JAVAINTERPRETER -version 2>&1 | $AWK '{ print }' | $GREP -c "IBM"` -gt 0; then
7395            JDK=ibm
7396
7397            dnl IBM JDK specific tests
7398            _jdk=`$JAVAINTERPRETER -version 2>&1 | $AWK -F'"' '{ print \$2 }' | $SED s/[[-A-Za-z]]*//`
7399            _jdk_ver=`echo "$_jdk" | $AWK -F. '{ print (($1 * 100) + $2) * 100 + $3;}'`
7400
7401            if test "$_jdk_ver" -lt 10800; then
7402                AC_MSG_ERROR([IBM JDK is too old, you need at least 8])
7403            fi
7404
7405            AC_MSG_RESULT([found (IBM JDK $_jdk)])
7406
7407            if test "$with_jdk_home" = ""; then
7408                AC_MSG_ERROR([In order to successfully build LibreOffice using the IBM JDK,
7409you must use the "--with-jdk-home" configure option explicitly])
7410            fi
7411
7412            JAVA_HOME=$with_jdk_home
7413        else
7414            JDK=sun
7415
7416            dnl Sun JDK specific tests
7417            _jdk=`$JAVAINTERPRETER -version 2>&1 | $AWK -F'"' '{ print \$2 }' | $SED '/^$/d' | $SED s/[[-A-Za-z]]*//`
7418            _jdk_ver=`echo "$_jdk" | $AWK -F. '{ print (($1 * 100) + $2) * 100 + $3;}'`
7419
7420            if test "$_jdk_ver" -lt 10800; then
7421                AC_MSG_ERROR([JDK is too old, you need at least 8])
7422            fi
7423            if test "$_jdk_ver" -gt 10800; then
7424                JAVA_CLASSPATH_NOT_SET=TRUE
7425            fi
7426
7427            AC_MSG_RESULT([found (JDK $_jdk)])
7428            JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*java,,p"`
7429            if test "$_os" = "WINNT"; then
7430                JAVA_HOME=`echo $JAVA_HOME | $SED "s,\.[[eE]][[xX]][[eE]]$,,"`
7431            fi
7432
7433            # set to limit VM usage for JunitTests
7434            JAVAIFLAGS=-Xmx64M
7435            # set to limit VM usage for javac
7436            JAVAFLAGS=-J-Xmx128M
7437        fi
7438    else
7439        AC_MSG_ERROR([Java not found. You need at least JDK 8])
7440    fi
7441else
7442    dnl Java disabled
7443    JAVA_HOME=
7444    export JAVA_HOME
7445fi
7446
7447dnl ===================================================================
7448dnl Checks for javac
7449dnl ===================================================================
7450if test "$ENABLE_JAVA" != ""; then
7451    javacompiler="javac"
7452    : ${JAVA_SOURCE_VER=8}
7453    : ${JAVA_TARGET_VER=8}
7454    if test -z "$with_jdk_home"; then
7455        AC_PATH_PROG(JAVACOMPILER, $javacompiler)
7456    else
7457        _javac_path="$with_jdk_home/bin/$javacompiler"
7458        dnl Check if there is a Java compiler at all.
7459        if test -x "$_javac_path"; then
7460            JAVACOMPILER=$_javac_path
7461        fi
7462    fi
7463    if test -z "$JAVACOMPILER"; then
7464        AC_MSG_ERROR([$javacompiler not found set with_jdk_home])
7465    fi
7466    if test "$build_os" = "cygwin"; then
7467        if test x`echo "$JAVACOMPILER" | $GREP -i '\.exe$'` = x; then
7468            JAVACOMPILER="${JAVACOMPILER}.exe"
7469        fi
7470        JAVACOMPILER=`win_short_path_for_make "$JAVACOMPILER"`
7471    fi
7472fi
7473
7474dnl ===================================================================
7475dnl Checks for javadoc
7476dnl ===================================================================
7477if test "$ENABLE_JAVA" != ""; then
7478    if test -z "$with_jdk_home"; then
7479        AC_PATH_PROG(JAVADOC, javadoc)
7480    else
7481        _javadoc_path="$with_jdk_home/bin/javadoc"
7482        dnl Check if there is a javadoc at all.
7483        if test -x "$_javadoc_path"; then
7484            JAVADOC=$_javadoc_path
7485        else
7486            AC_PATH_PROG(JAVADOC, javadoc)
7487        fi
7488    fi
7489    if test -z "$JAVADOC"; then
7490        AC_MSG_ERROR([$_javadoc_path not found set with_jdk_home])
7491    fi
7492    if test "$build_os" = "cygwin"; then
7493        if test x`echo "$JAVADOC" | $GREP -i '\.exe$'` = x; then
7494            JAVADOC="${JAVADOC}.exe"
7495        fi
7496        JAVADOC=`win_short_path_for_make "$JAVADOC"`
7497    fi
7498
7499    if test `$JAVADOC --version 2>&1 | $GREP -c "gjdoc"` -gt 0; then
7500    JAVADOCISGJDOC="yes"
7501    fi
7502fi
7503AC_SUBST(JAVADOCISGJDOC)
7504
7505if test "$ENABLE_JAVA" != ""; then
7506    # check if JAVA_HOME was (maybe incorrectly?) set automatically to /usr
7507    if test "$JAVA_HOME" = "/usr" -a "x$with_jdk_home" = "x"; then
7508        if basename $(readlink $(readlink $JAVACOMPILER)) >/dev/null 2>/dev/null; then
7509           # try to recover first by looking whether we have an alternative
7510           # system as in Debian or newer SuSEs where following /usr/bin/javac
7511           # over /etc/alternatives/javac leads to the right bindir where we
7512           # just need to strip a bit away to get a valid JAVA_HOME
7513           JAVA_HOME=$(readlink $(readlink $JAVACOMPILER))
7514        elif readlink $JAVACOMPILER >/dev/null 2>/dev/null; then
7515            # maybe only one level of symlink (e.g. on Mac)
7516            JAVA_HOME=$(readlink $JAVACOMPILER)
7517            if test "$(dirname $JAVA_HOME)" = "."; then
7518                # we've got no path to trim back
7519                JAVA_HOME=""
7520            fi
7521        else
7522            # else warn
7523            AC_MSG_WARN([JAVA_HOME is set to /usr - this is very likely to be incorrect])
7524            AC_MSG_WARN([if this is the case, please inform the correct JAVA_HOME with --with-jdk-home])
7525            add_warning "JAVA_HOME is set to /usr - this is very likely to be incorrect"
7526            add_warning "if this is the case, please inform the correct JAVA_HOME with --with-jdk-home"
7527        fi
7528        dnl now that we probably have the path to the real javac, make a JAVA_HOME out of it...
7529        if test "$JAVA_HOME" != "/usr"; then
7530            if test "$_os" = "Darwin" -o "$OS_FOR_BUILD" = MACOSX; then
7531                dnl Leopard returns a non-suitable path with readlink - points to "Current" only
7532                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/Current/Commands/javac$,/CurrentJDK/Home,)
7533                dnl Tiger already returns a JDK path...
7534                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/CurrentJDK/Commands/javac$,/CurrentJDK/Home,)
7535            else
7536                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/bin/javac$,,)
7537                dnl check that we have a directory as certain distros eg gentoo substitute javac for a script
7538                dnl that checks which version to run
7539                if test -f "$JAVA_HOME"; then
7540                    JAVA_HOME=""; # set JAVA_HOME to null if it's a file
7541                fi
7542            fi
7543        fi
7544    fi
7545    # as we drop out of this, JAVA_HOME may have been set to the empty string by readlink
7546
7547    dnl now if JAVA_HOME has been set to empty, then call findhome to find it
7548    if test -z "$JAVA_HOME"; then
7549        if test "x$with_jdk_home" = "x"; then
7550            cat > findhome.java <<_ACEOF
7551[import java.io.File;
7552
7553class findhome
7554{
7555    public static void main(String args[])
7556    {
7557        String jrelocation = System.getProperty("java.home");
7558        File jre = new File(jrelocation);
7559        System.out.println(jre.getParent());
7560    }
7561}]
7562_ACEOF
7563            AC_MSG_CHECKING([if javac works])
7564            javac_cmd="$JAVACOMPILER findhome.java 1>&2"
7565            AC_TRY_EVAL(javac_cmd)
7566            if test $? = 0 -a -f ./findhome.class; then
7567                AC_MSG_RESULT([javac works])
7568            else
7569                echo "configure: javac test failed" >&5
7570                cat findhome.java >&5
7571                AC_MSG_ERROR([javac does not work - java projects will not build!])
7572            fi
7573            AC_MSG_CHECKING([if gij knows its java.home])
7574            JAVA_HOME=`$JAVAINTERPRETER findhome`
7575            if test $? = 0 -a "$JAVA_HOME" != ""; then
7576                AC_MSG_RESULT([$JAVA_HOME])
7577            else
7578                echo "configure: java test failed" >&5
7579                cat findhome.java >&5
7580                AC_MSG_ERROR([gij does not know its java.home - use --with-jdk-home])
7581            fi
7582            # clean-up after ourselves
7583            rm -f ./findhome.java ./findhome.class
7584        else
7585            JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*$with_java,,p"`
7586        fi
7587    fi
7588
7589    # now check if $JAVA_HOME is really valid
7590    if test "$_os" = "Darwin" -o "$OS_FOR_BUILD" = MACOSX; then
7591        case "${JAVA_HOME}" in
7592            /Library/Java/JavaVirtualMachines/*)
7593                ;;
7594            *)
7595                AC_MSG_ERROR([JDK in $JAVA_HOME cannot be used in CppUnit tests - install Oracle JDK])
7596                ;;
7597        esac
7598        if test ! -f "$JAVA_HOME/lib/jvm.cfg" -a "x$with_jdk_home" = "x"; then
7599            JAVA_HOME_OK="NO"
7600        fi
7601    elif test ! -d "$JAVA_HOME/jre" -a "x$with_jdk_home" = "x"; then
7602        JAVA_HOME_OK="NO"
7603    fi
7604    if test "$JAVA_HOME_OK" = "NO"; then
7605        AC_MSG_WARN([JAVA_HOME was not explicitly informed with --with-jdk-home. the configure script])
7606        AC_MSG_WARN([attempted to find JAVA_HOME automatically, but apparently it failed])
7607        AC_MSG_WARN([in case JAVA_HOME is incorrectly set, some projects will not be built correctly])
7608        add_warning "JAVA_HOME was not explicitly informed with --with-jdk-home. the configure script"
7609        add_warning "attempted to find JAVA_HOME automatically, but apparently it failed"
7610        add_warning "in case JAVA_HOME is incorrectly set, some projects will not be built correctly"
7611    fi
7612    PathFormat "$JAVA_HOME"
7613    JAVA_HOME="$formatted_path"
7614fi
7615
7616if test -z "$JAWTLIB" -a -n "$ENABLE_JAVA" -a "$_os" != Android -a \
7617    "$_os" != Darwin
7618then
7619    AC_MSG_CHECKING([for JAWT lib])
7620    if test "$_os" = WINNT; then
7621        # The path to $JAVA_HOME/lib/$JAWTLIB is part of $ILIB:
7622        JAWTLIB=jawt.lib
7623    else
7624        case "$host_cpu" in
7625        arm*)
7626            AS_IF([test -e "$JAVA_HOME/jre/lib/aarch32/libjawt.so"], [my_java_arch=aarch32], [my_java_arch=arm])
7627            JAVA_ARCH=$my_java_arch
7628            ;;
7629        i*86)
7630            my_java_arch=i386
7631            ;;
7632        m68k)
7633            my_java_arch=m68k
7634            ;;
7635        powerpc)
7636            my_java_arch=ppc
7637            ;;
7638        powerpc64)
7639            my_java_arch=ppc64
7640            ;;
7641        powerpc64le)
7642            AS_IF([test -e "$JAVA_HOME/jre/lib/ppc64le/libjawt.so"], [my_java_arch=ppc64le], [my_java_arch=ppc64])
7643            JAVA_ARCH=$my_java_arch
7644            ;;
7645        sparc64)
7646            my_java_arch=sparcv9
7647            ;;
7648        x86_64)
7649            my_java_arch=amd64
7650            ;;
7651        *)
7652            my_java_arch=$host_cpu
7653            ;;
7654        esac
7655        # This is where JDK9 puts the library
7656        if test -e "$JAVA_HOME/lib/libjawt.so"; then
7657            JAWTLIB="-L$JAVA_HOME/lib/ -ljawt"
7658        else
7659            JAWTLIB="-L$JAVA_HOME/jre/lib/$my_java_arch -ljawt"
7660        fi
7661        AS_IF([test "$JAVA_ARCH" != ""], [AC_DEFINE_UNQUOTED([JAVA_ARCH], ["$JAVA_ARCH"])])
7662    fi
7663    AC_MSG_RESULT([$JAWTLIB])
7664fi
7665AC_SUBST(JAWTLIB)
7666
7667if test -n "$ENABLE_JAVA" -a -z "$JAVAINC"; then
7668    case "$host_os" in
7669
7670    aix*)
7671        JAVAINC="-I$JAVA_HOME/include"
7672        JAVAINC="$JAVAINC -I$JAVA_HOME/include/aix"
7673        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
7674        ;;
7675
7676    cygwin*)
7677        JAVAINC="-I$JAVA_HOME/include/win32"
7678        JAVAINC="$JAVAINC -I$JAVA_HOME/include"
7679        ;;
7680
7681    darwin*)
7682        if test -d "$JAVA_HOME/include/darwin"; then
7683            JAVAINC="-I$JAVA_HOME/include  -I$JAVA_HOME/include/darwin"
7684        else
7685            JAVAINC=${ISYSTEM}$FRAMEWORKSHOME/JavaVM.framework/Versions/Current/Headers
7686        fi
7687        ;;
7688
7689    dragonfly*)
7690        JAVAINC="-I$JAVA_HOME/include"
7691        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
7692        ;;
7693
7694    freebsd*)
7695        JAVAINC="-I$JAVA_HOME/include"
7696        JAVAINC="$JAVAINC -I$JAVA_HOME/include/freebsd"
7697        JAVAINC="$JAVAINC -I$JAVA_HOME/include/bsd"
7698        JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux"
7699        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
7700        ;;
7701
7702    k*bsd*-gnu*)
7703        JAVAINC="-I$JAVA_HOME/include"
7704        JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux"
7705        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
7706        ;;
7707
7708    linux-gnu*)
7709        JAVAINC="-I$JAVA_HOME/include"
7710        JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux"
7711        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
7712        ;;
7713
7714    *netbsd*)
7715        JAVAINC="-I$JAVA_HOME/include"
7716        JAVAINC="$JAVAINC -I$JAVA_HOME/include/netbsd"
7717        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
7718       ;;
7719
7720    openbsd*)
7721        JAVAINC="-I$JAVA_HOME/include"
7722        JAVAINC="$JAVAINC -I$JAVA_HOME/include/openbsd"
7723        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
7724        ;;
7725
7726    solaris*)
7727        JAVAINC="-I$JAVA_HOME/include"
7728        JAVAINC="$JAVAINC -I$JAVA_HOME/include/solaris"
7729        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
7730        ;;
7731    esac
7732fi
7733SOLARINC="$SOLARINC $JAVAINC"
7734
7735AC_SUBST(JAVACOMPILER)
7736AC_SUBST(JAVADOC)
7737AC_SUBST(JAVAINTERPRETER)
7738AC_SUBST(JAVAIFLAGS)
7739AC_SUBST(JAVAFLAGS)
7740AC_SUBST(JAVA_CLASSPATH_NOT_SET)
7741AC_SUBST(JAVA_HOME)
7742AC_SUBST(JAVA_SOURCE_VER)
7743AC_SUBST(JAVA_TARGET_VER)
7744AC_SUBST(JDK)
7745
7746
7747dnl ===================================================================
7748dnl Export file validation
7749dnl ===================================================================
7750AC_MSG_CHECKING([whether to enable export file validation])
7751if test "$with_export_validation" != "no"; then
7752    if test -z "$ENABLE_JAVA"; then
7753        if test "$with_export_validation" = "yes"; then
7754            AC_MSG_ERROR([requested, but Java is disabled])
7755        else
7756            AC_MSG_RESULT([no, as Java is disabled])
7757        fi
7758    elif ! test -d "${SRC_ROOT}/schema"; then
7759        if test "$with_export_validation" = "yes"; then
7760            AC_MSG_ERROR([requested, but schema directory is missing (it is excluded from tarballs)])
7761        else
7762            AC_MSG_RESULT([no, schema directory is missing (it is excluded from tarballs)])
7763        fi
7764    else
7765        AC_MSG_RESULT([yes])
7766        AC_DEFINE(HAVE_EXPORT_VALIDATION)
7767
7768        AC_PATH_PROGS(ODFVALIDATOR, odfvalidator)
7769        if test -z "$ODFVALIDATOR"; then
7770            # remember to download the ODF toolkit with validator later
7771            AC_MSG_NOTICE([no odfvalidator found, will download it])
7772            BUILD_TYPE="$BUILD_TYPE ODFVALIDATOR"
7773            ODFVALIDATOR="$BUILDDIR/bin/odfvalidator.sh"
7774
7775            # and fetch name of odfvalidator jar name from download.lst
7776            ODFVALIDATOR_JAR=`$SED -n -e "s/export *ODFVALIDATOR_JAR *:= *\(.*\) */\1/p" $SRC_ROOT/download.lst`
7777            AC_SUBST(ODFVALIDATOR_JAR)
7778
7779            if test -z "$ODFVALIDATOR_JAR"; then
7780                AC_MSG_ERROR([cannot determine odfvalidator jar location (--with-export-validation)])
7781            fi
7782        fi
7783        if test "$build_os" = "cygwin"; then
7784            # In case of Cygwin it will be executed from Windows,
7785            # so we need to run bash and absolute path to validator
7786            # so instead of "odfvalidator" it will be
7787            # something like "bash.exe C:\cygwin\opt\lo\bin\odfvalidator"
7788            ODFVALIDATOR="bash.exe `cygpath -m "$ODFVALIDATOR"`"
7789        else
7790            ODFVALIDATOR="sh $ODFVALIDATOR"
7791        fi
7792        AC_SUBST(ODFVALIDATOR)
7793
7794
7795        AC_PATH_PROGS(OFFICEOTRON, officeotron)
7796        if test -z "$OFFICEOTRON"; then
7797            # remember to download the officeotron with validator later
7798            AC_MSG_NOTICE([no officeotron found, will download it])
7799            BUILD_TYPE="$BUILD_TYPE OFFICEOTRON"
7800            OFFICEOTRON="$BUILDDIR/bin/officeotron.sh"
7801
7802            # and fetch name of officeotron jar name from download.lst
7803            OFFICEOTRON_JAR=`$SED -n -e "s/export *OFFICEOTRON_JAR *:= *\(.*\) */\1/p" $SRC_ROOT/download.lst`
7804            AC_SUBST(OFFICEOTRON_JAR)
7805
7806            if test -z "$OFFICEOTRON_JAR"; then
7807                AC_MSG_ERROR([cannot determine officeotron jar location (--with-export-validation)])
7808            fi
7809        else
7810            # check version of existing officeotron
7811            OFFICEOTRON_VER=`$OFFICEOTRON --version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
7812            if test 0"$OFFICEOTRON_VER" -lt 704; then
7813                AC_MSG_ERROR([officeotron too old])
7814            fi
7815        fi
7816        if test "$build_os" = "cygwin"; then
7817            # In case of Cygwin it will be executed from Windows,
7818            # so we need to run bash and absolute path to validator
7819            # so instead of "odfvalidator" it will be
7820            # something like "bash.exe C:\cygwin\opt\lo\bin\odfvalidator"
7821            OFFICEOTRON="bash.exe `cygpath -m "$OFFICEOTRON"`"
7822        else
7823            OFFICEOTRON="sh $OFFICEOTRON"
7824        fi
7825    fi
7826    AC_SUBST(OFFICEOTRON)
7827else
7828    AC_MSG_RESULT([no])
7829fi
7830
7831AC_MSG_CHECKING([for Microsoft Binary File Format Validator])
7832if test "$with_bffvalidator" != "no"; then
7833    AC_DEFINE(HAVE_BFFVALIDATOR)
7834
7835    if test "$with_export_validation" = "no"; then
7836        AC_MSG_ERROR([Please enable export validation (-with-export-validation)!])
7837    fi
7838
7839    if test "$with_bffvalidator" = "yes"; then
7840        BFFVALIDATOR=`win_short_path_for_make "$PROGRAMFILES/Microsoft Office/BFFValidator/BFFValidator.exe"`
7841    else
7842        BFFVALIDATOR="$with_bffvalidator"
7843    fi
7844
7845    if test "$build_os" = "cygwin"; then
7846        if test -n "$BFFVALIDATOR" -a -e "`cygpath $BFFVALIDATOR`"; then
7847            AC_MSG_RESULT($BFFVALIDATOR)
7848        else
7849            AC_MSG_ERROR([bffvalidator not found, but required by --with-bffvalidator])
7850        fi
7851    elif test -n "$BFFVALIDATOR"; then
7852        # We are not in Cygwin but need to run Windows binary with wine
7853        AC_PATH_PROGS(WINE, wine)
7854
7855        # so swap in a shell wrapper that converts paths transparently
7856        BFFVALIDATOR_EXE="$BFFVALIDATOR"
7857        BFFVALIDATOR="sh $BUILDDIR/bin/bffvalidator.sh"
7858        AC_SUBST(BFFVALIDATOR_EXE)
7859        AC_MSG_RESULT($BFFVALIDATOR)
7860    else
7861        AC_MSG_ERROR([bffvalidator not found, but required by --with-bffvalidator])
7862    fi
7863    AC_SUBST(BFFVALIDATOR)
7864else
7865    AC_MSG_RESULT([no])
7866fi
7867
7868dnl ===================================================================
7869dnl Check for C preprocessor to use
7870dnl ===================================================================
7871AC_MSG_CHECKING([which C preprocessor to use in idlc])
7872if test -n "$with_idlc_cpp"; then
7873    AC_MSG_RESULT([$with_idlc_cpp])
7874    AC_PATH_PROG(SYSTEM_UCPP, $with_idlc_cpp)
7875else
7876    AC_MSG_RESULT([ucpp])
7877    AC_MSG_CHECKING([which ucpp tp use])
7878    if test -n "$with_system_ucpp" -a "$with_system_ucpp" != "no"; then
7879        AC_MSG_RESULT([external])
7880        AC_PATH_PROG(SYSTEM_UCPP, ucpp)
7881    else
7882        AC_MSG_RESULT([internal])
7883        BUILD_TYPE="$BUILD_TYPE UCPP"
7884    fi
7885fi
7886AC_SUBST(SYSTEM_UCPP)
7887
7888dnl ===================================================================
7889dnl Check for epm (not needed for Windows)
7890dnl ===================================================================
7891AC_MSG_CHECKING([whether to enable EPM for packing])
7892if test "$enable_epm" = "yes"; then
7893    AC_MSG_RESULT([yes])
7894    if test "$_os" != "WINNT"; then
7895        if test $_os = Darwin; then
7896            EPM=internal
7897        elif test -n "$with_epm"; then
7898            EPM=$with_epm
7899        else
7900            AC_PATH_PROG(EPM, epm, no)
7901        fi
7902        if test "$EPM" = "no" -o "$EPM" = "internal"; then
7903            AC_MSG_NOTICE([EPM will be built.])
7904            BUILD_TYPE="$BUILD_TYPE EPM"
7905            EPM=${WORKDIR}/UnpackedTarball/epm/epm
7906        else
7907            # Gentoo has some epm which is something different...
7908            AC_MSG_CHECKING([whether the found epm is the right epm])
7909            if $EPM | grep "ESP Package Manager" >/dev/null 2>/dev/null; then
7910                AC_MSG_RESULT([yes])
7911            else
7912                AC_MSG_ERROR([no. Install ESP Package Manager (http://www.msweet.org/projects.php?Z2) and/or specify the path to the right epm])
7913            fi
7914            AC_MSG_CHECKING([epm version])
7915            EPM_VERSION=`$EPM | grep 'ESP Package Manager' | cut -d' ' -f4 | $SED -e s/v//`
7916            if test "`echo $EPM_VERSION | cut -d'.' -f1`" -gt "3" || \
7917               test "`echo $EPM_VERSION | cut -d'.' -f1`" -eq "3" -a "`echo $EPM_VERSION | cut -d'.' -f2`" -ge "7"; then
7918                AC_MSG_RESULT([OK, >= 3.7])
7919            else
7920                AC_MSG_RESULT([too old. epm >= 3.7 is required.])
7921                AC_MSG_ERROR([Install ESP Package Manager (http://www.msweet.org/projects.php?Z2) and/or specify the path to the right epm])
7922            fi
7923        fi
7924    fi
7925
7926    if echo "$PKGFORMAT" | $EGREP rpm 2>&1 >/dev/null; then
7927        AC_MSG_CHECKING([for rpm])
7928        for a in "$RPM" rpmbuild rpm; do
7929            $a --usage >/dev/null 2> /dev/null
7930            if test $? -eq 0; then
7931                RPM=$a
7932                break
7933            else
7934                $a --version >/dev/null 2> /dev/null
7935                if test $? -eq 0; then
7936                    RPM=$a
7937                    break
7938                fi
7939            fi
7940        done
7941        if test -z "$RPM"; then
7942            AC_MSG_ERROR([not found])
7943        elif "$RPM" --help 2>&1 | $EGREP buildroot >/dev/null; then
7944            RPM_PATH=`which $RPM`
7945            AC_MSG_RESULT([$RPM_PATH])
7946            SCPDEFS="$SCPDEFS -DWITH_RPM"
7947        else
7948            AC_MSG_ERROR([cannot build packages. Try installing rpmbuild.])
7949        fi
7950    fi
7951    if echo "$PKGFORMAT" | $EGREP deb 2>&1 >/dev/null; then
7952        AC_PATH_PROG(DPKG, dpkg, no)
7953        if test "$DPKG" = "no"; then
7954            AC_MSG_ERROR([dpkg needed for deb creation. Install dpkg.])
7955        fi
7956    fi
7957    if echo "$PKGFORMAT" | $EGREP rpm 2>&1 >/dev/null || \
7958       echo "$PKGFORMAT" | $EGREP pkg 2>&1 >/dev/null; then
7959        if test "$with_epm" = "no" -a "$_os" != "Darwin"; then
7960            if test "`echo $EPM_VERSION | cut -d'.' -f1`" -lt "4"; then
7961                AC_MSG_CHECKING([whether epm is patched for LibreOffice's needs])
7962                if grep "Patched for .*Office" $EPM >/dev/null 2>/dev/null; then
7963                    AC_MSG_RESULT([yes])
7964                else
7965                    AC_MSG_RESULT([no])
7966                    if echo "$PKGFORMAT" | $GREP -q rpm; then
7967                        _pt="rpm"
7968                        AC_MSG_WARN([the rpms will need to be installed with --nodeps])
7969                        add_warning "the rpms will need to be installed with --nodeps"
7970                    else
7971                        _pt="pkg"
7972                    fi
7973                    AC_MSG_WARN([the ${_pt}s will not be relocatable])
7974                    add_warning "the ${_pt}s will not be relocatable"
7975                    AC_MSG_WARN([if you want to make sure installation without --nodeps and
7976                                 relocation will work, you need to patch your epm with the
7977                                 patch in epm/epm-3.7.patch or build with
7978                                 --with-epm=internal which will build a suitable epm])
7979                fi
7980            fi
7981        fi
7982    fi
7983    if echo "$PKGFORMAT" | $EGREP pkg 2>&1 >/dev/null; then
7984        AC_PATH_PROG(PKGMK, pkgmk, no)
7985        if test "$PKGMK" = "no"; then
7986            AC_MSG_ERROR([pkgmk needed for Solaris pkg creation. Install it.])
7987        fi
7988    fi
7989    AC_SUBST(RPM)
7990    AC_SUBST(DPKG)
7991    AC_SUBST(PKGMK)
7992else
7993    for i in $PKGFORMAT; do
7994        case "$i" in
7995        aix | bsd | deb | pkg | rpm | native | portable)
7996            AC_MSG_ERROR(
7997                [--with-package-format='$PKGFORMAT' requires --enable-epm])
7998            ;;
7999        esac
8000    done
8001    AC_MSG_RESULT([no])
8002    EPM=NO
8003fi
8004AC_SUBST(EPM)
8005
8006ENABLE_LWP=
8007if test "$enable_lotuswordpro" = "yes"; then
8008    ENABLE_LWP="TRUE"
8009fi
8010AC_SUBST(ENABLE_LWP)
8011
8012dnl ===================================================================
8013dnl Check for building ODK
8014dnl ===================================================================
8015if test "$enable_odk" = no; then
8016    unset DOXYGEN
8017else
8018    if test "$with_doxygen" = no; then
8019        AC_MSG_CHECKING([for doxygen])
8020        unset DOXYGEN
8021        AC_MSG_RESULT([no])
8022    else
8023        if test "$with_doxygen" = yes; then
8024            AC_PATH_PROG([DOXYGEN], [doxygen])
8025            if test -z "$DOXYGEN"; then
8026                AC_MSG_ERROR([doxygen not found in \$PATH; specify its pathname via --with-doxygen=..., or disable its use via --without-doxygen])
8027            fi
8028            if $DOXYGEN -g - | grep -q "HAVE_DOT *= *YES"; then
8029                if ! dot -V 2>/dev/null; then
8030                    AC_MSG_ERROR([dot not found in \$PATH but doxygen defaults to HAVE_DOT=YES; install graphviz or disable its use via --without-doxygen])
8031                fi
8032            fi
8033        else
8034            AC_MSG_CHECKING([for doxygen])
8035            DOXYGEN=$with_doxygen
8036            AC_MSG_RESULT([$DOXYGEN])
8037        fi
8038        if test -n "$DOXYGEN"; then
8039            DOXYGEN_VERSION=`$DOXYGEN --version 2>/dev/null`
8040            DOXYGEN_NUMVERSION=`echo $DOXYGEN_VERSION | $AWK -F. '{ print \$1*10000 + \$2*100 + \$3 }'`
8041            if ! test "$DOXYGEN_NUMVERSION" -ge "10804" ; then
8042                AC_MSG_ERROR([found doxygen is too old; need at least version 1.8.4 or specify --without-doxygen])
8043            fi
8044        fi
8045    fi
8046fi
8047AC_SUBST([DOXYGEN])
8048
8049AC_MSG_CHECKING([whether to build the ODK])
8050if test "$enable_odk" = "" -o "$enable_odk" != "no"; then
8051    AC_MSG_RESULT([yes])
8052
8053    if test "$with_java" != "no"; then
8054        AC_MSG_CHECKING([whether to build unowinreg.dll])
8055        if test "$_os" = "WINNT" -a "$enable_build_unowinreg" = ""; then
8056            # build on Win by default
8057            enable_build_unowinreg=yes
8058        fi
8059        if test "$enable_build_unowinreg" = "" -o "$enable_build_unowinreg" = "no"; then
8060            AC_MSG_RESULT([no])
8061            BUILD_UNOWINREG=
8062        else
8063            AC_MSG_RESULT([yes])
8064            BUILD_UNOWINREG=TRUE
8065        fi
8066        if test "$_os" != "WINNT" -a "$BUILD_UNOWINREG" = "TRUE"; then
8067            if test -z "$with_mingw_cross_compiler"; then
8068                dnl Guess...
8069                AC_CHECK_PROGS(MINGWCXX,i386-mingw32msvc-g++ i586-pc-mingw32-g++ i686-pc-mingw32-g++ i686-w64-mingw32-g++,false)
8070            elif test -x "$with_mingw_cross_compiler"; then
8071                 MINGWCXX="$with_mingw_cross_compiler"
8072            else
8073                AC_CHECK_TOOL(MINGWCXX, "$with_mingw_cross_compiler", false)
8074            fi
8075
8076            if test "$MINGWCXX" = "false"; then
8077                AC_MSG_ERROR([MinGW32 C++ cross-compiler not found.])
8078            fi
8079
8080            mingwstrip_test="`echo $MINGWCXX | $SED -e s/g++/strip/`"
8081            if test -x "$mingwstrip_test"; then
8082                MINGWSTRIP="$mingwstrip_test"
8083            else
8084                AC_CHECK_TOOL(MINGWSTRIP, "$mingwstrip_test", false)
8085            fi
8086
8087            if test "$MINGWSTRIP" = "false"; then
8088                AC_MSG_ERROR(MinGW32 binutils not found.)
8089            fi
8090        fi
8091    fi
8092    BUILD_TYPE="$BUILD_TYPE ODK"
8093else
8094    AC_MSG_RESULT([no])
8095    BUILD_UNOWINREG=
8096fi
8097AC_SUBST(BUILD_UNOWINREG)
8098AC_SUBST(MINGWCXX)
8099AC_SUBST(MINGWSTRIP)
8100
8101dnl ===================================================================
8102dnl Check for system zlib
8103dnl ===================================================================
8104if test "$with_system_zlib" = "auto"; then
8105    case "$_os" in
8106    WINNT)
8107        with_system_zlib="$with_system_libs"
8108        ;;
8109    *)
8110        if test "$enable_fuzzers" != "yes"; then
8111            with_system_zlib=yes
8112        else
8113            with_system_zlib=no
8114        fi
8115        ;;
8116    esac
8117fi
8118
8119dnl we want to use libo_CHECK_SYSTEM_MODULE here too, but macOS is too stupid
8120dnl and has no pkg-config for it at least on some tinderboxes,
8121dnl so leaving that out for now
8122dnl libo_CHECK_SYSTEM_MODULE([zlib],[ZLIB],[zlib])
8123AC_MSG_CHECKING([which zlib to use])
8124if test "$with_system_zlib" = "yes"; then
8125    AC_MSG_RESULT([external])
8126    SYSTEM_ZLIB=TRUE
8127    AC_CHECK_HEADER(zlib.h, [],
8128        [AC_MSG_ERROR(zlib.h not found. install zlib)], [])
8129    AC_CHECK_LIB(z, deflate, [ ZLIB_LIBS=-lz ],
8130        [AC_MSG_ERROR(zlib not found or functional)], [])
8131else
8132    AC_MSG_RESULT([internal])
8133    SYSTEM_ZLIB=
8134    BUILD_TYPE="$BUILD_TYPE ZLIB"
8135    ZLIB_CFLAGS="-I${WORKDIR}/UnpackedTarball/zlib"
8136    ZLIB_LIBS="-L${WORKDIR}/LinkTarget/StaticLibrary -lzlib"
8137fi
8138AC_SUBST(ZLIB_CFLAGS)
8139AC_SUBST(ZLIB_LIBS)
8140AC_SUBST(SYSTEM_ZLIB)
8141
8142dnl ===================================================================
8143dnl Check for system jpeg
8144dnl ===================================================================
8145AC_MSG_CHECKING([which libjpeg to use])
8146if test "$with_system_jpeg" = "yes"; then
8147    AC_MSG_RESULT([external])
8148    SYSTEM_LIBJPEG=TRUE
8149    AC_CHECK_HEADER(jpeglib.h, [ LIBJPEG_CFLAGS= ],
8150        [AC_MSG_ERROR(jpeg.h not found. install libjpeg)], [])
8151    AC_CHECK_LIB(jpeg, jpeg_resync_to_restart, [ LIBJPEG_LIBS="-ljpeg" ],
8152        [AC_MSG_ERROR(jpeg library not found or functional)], [])
8153else
8154    SYSTEM_LIBJPEG=
8155    AC_MSG_RESULT([internal, libjpeg-turbo])
8156    BUILD_TYPE="$BUILD_TYPE LIBJPEG_TURBO"
8157    LIBJPEG_CFLAGS="-I${WORKDIR}/UnpackedTarball/libjpeg-turbo"
8158    if test "$COM" = "MSC"; then
8159        LIBJPEG_LIBS="${WORKDIR}/UnpackedTarball/libjpeg-turbo/.libs/libjpeg.lib"
8160    else
8161        LIBJPEG_LIBS="-L${WORKDIR}/UnpackedTarball/libjpeg-turbo/.libs -ljpeg"
8162    fi
8163
8164    case "$host_cpu" in
8165    x86_64 | amd64 | i*86 | x86 | ia32)
8166        AC_CHECK_PROGS(NASM, [nasm nasmw yasm])
8167        if test -z "$NASM" -a "$build_os" = "cygwin"; then
8168            if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/nasm"; then
8169                NASM="$LODE_HOME/opt/bin/nasm"
8170            elif test -x "/opt/lo/bin/nasm"; then
8171                NASM="/opt/lo/bin/nasm"
8172            fi
8173        fi
8174
8175        if test -n "$NASM"; then
8176            AC_MSG_CHECKING([for object file format of host system])
8177            case "$host_os" in
8178              cygwin* | mingw* | pw32* | interix*)
8179                case "$host_cpu" in
8180                  x86_64)
8181                    objfmt='Win64-COFF'
8182                    ;;
8183                  *)
8184                    objfmt='Win32-COFF'
8185                    ;;
8186                esac
8187              ;;
8188              msdosdjgpp* | go32*)
8189                objfmt='COFF'
8190              ;;
8191              os2-emx*) # not tested
8192                objfmt='MSOMF' # obj
8193              ;;
8194              linux*coff* | linux*oldld*)
8195                objfmt='COFF' # ???
8196              ;;
8197              linux*aout*)
8198                objfmt='a.out'
8199              ;;
8200              linux*)
8201                case "$host_cpu" in
8202                  x86_64)
8203                    objfmt='ELF64'
8204                    ;;
8205                  *)
8206                    objfmt='ELF'
8207                    ;;
8208                esac
8209              ;;
8210              kfreebsd* | freebsd* | netbsd* | openbsd*)
8211                if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
8212                  objfmt='BSD-a.out'
8213                else
8214                  case "$host_cpu" in
8215                    x86_64 | amd64)
8216                      objfmt='ELF64'
8217                      ;;
8218                    *)
8219                      objfmt='ELF'
8220                      ;;
8221                  esac
8222                fi
8223              ;;
8224              solaris* | sunos* | sysv* | sco*)
8225                case "$host_cpu" in
8226                  x86_64)
8227                    objfmt='ELF64'
8228                    ;;
8229                  *)
8230                    objfmt='ELF'
8231                    ;;
8232                esac
8233              ;;
8234              darwin* | rhapsody* | nextstep* | openstep* | macos*)
8235                case "$host_cpu" in
8236                  x86_64)
8237                    objfmt='Mach-O64'
8238                    ;;
8239                  *)
8240                    objfmt='Mach-O'
8241                    ;;
8242                esac
8243              ;;
8244              *)
8245                objfmt='ELF ?'
8246              ;;
8247            esac
8248
8249            AC_MSG_RESULT([$objfmt])
8250            if test "$objfmt" = 'ELF ?'; then
8251              objfmt='ELF'
8252              AC_MSG_WARN([unexpected host system. assumed that the format is $objfmt.])
8253            fi
8254
8255            AC_MSG_CHECKING([for object file format specifier (NAFLAGS) ])
8256            case "$objfmt" in
8257              MSOMF)      NAFLAGS='-fobj -DOBJ32';;
8258              Win32-COFF) NAFLAGS='-fwin32 -DWIN32';;
8259              Win64-COFF) NAFLAGS='-fwin64 -DWIN64 -D__x86_64__';;
8260              COFF)       NAFLAGS='-fcoff -DCOFF';;
8261              a.out)      NAFLAGS='-faout -DAOUT';;
8262              BSD-a.out)  NAFLAGS='-faoutb -DAOUT';;
8263              ELF)        NAFLAGS='-felf -DELF';;
8264              ELF64)      NAFLAGS='-felf64 -DELF -D__x86_64__';;
8265              RDF)        NAFLAGS='-frdf -DRDF';;
8266              Mach-O)     NAFLAGS='-fmacho -DMACHO';;
8267              Mach-O64)   NAFLAGS='-fmacho64 -DMACHO -D__x86_64__';;
8268            esac
8269            AC_MSG_RESULT([$NAFLAGS])
8270
8271            AC_MSG_CHECKING([whether the assembler ($NASM $NAFLAGS) works])
8272            cat > conftest.asm << EOF
8273            [%line __oline__ "configure"
8274                    section .text
8275                    global  _main,main
8276            _main:
8277            main:   xor     eax,eax
8278                    ret
8279            ]
8280EOF
8281            try_nasm='$NASM $NAFLAGS -o conftest.o conftest.asm'
8282            if AC_TRY_EVAL(try_nasm) && test -s conftest.o; then
8283              AC_MSG_RESULT(yes)
8284            else
8285              echo "configure: failed program was:" >&AC_FD_CC
8286              cat conftest.asm >&AC_FD_CC
8287              rm -rf conftest*
8288              AC_MSG_RESULT(no)
8289              AC_MSG_WARN([installation or configuration problem: assembler cannot create object files.])
8290              NASM=""
8291            fi
8292
8293        fi
8294
8295        if test -z "$NASM"; then
8296cat << _EOS
8297****************************************************************************
8298You need yasm or nasm (Netwide Assembler) to build the internal jpeg library optimally.
8299To get one please:
8300
8301_EOS
8302            if test "$build_os" = "cygwin"; then
8303cat << _EOS
8304install a pre-compiled binary for Win32
8305
8306mkdir -p /opt/lo/bin
8307cd /opt/lo/bin
8308wget https://dev-www.libreoffice.org/bin/cygwin/nasm.exe
8309chmod +x nasm
8310
8311or get and install one from http://www.nasm.us/
8312
8313Then re-run autogen.sh
8314
8315Note: autogen.sh will try to use /opt/lo/bin/nasm if the environment variable NASM is not already defined.
8316Alternatively, you can install the 'new' nasm where ever you want and make sure that \`which nasm\` finds it.
8317
8318_EOS
8319            else
8320cat << _EOS
8321consult https://github.com/libjpeg-turbo/libjpeg-turbo/blob/master/BUILDING.md
8322
8323_EOS
8324            fi
8325            AC_MSG_WARN([no suitable nasm (Netwide Assembler) found])
8326            add_warning "no suitable nasm (Netwide Assembler) found for internal libjpeg-turbo"
8327        fi
8328      ;;
8329    esac
8330fi
8331
8332AC_SUBST(NASM)
8333AC_SUBST(LIBJPEG_CFLAGS)
8334AC_SUBST(LIBJPEG_LIBS)
8335AC_SUBST(SYSTEM_LIBJPEG)
8336
8337dnl ===================================================================
8338dnl Check for system clucene
8339dnl ===================================================================
8340dnl we should rather be using
8341dnl libo_CHECK_SYSTEM_MODULE([clucence],[CLUCENE],[liblucence-core]) here
8342dnl but the contribs-lib check seems tricky
8343AC_MSG_CHECKING([which clucene to use])
8344if test "$with_system_clucene" = "yes"; then
8345    AC_MSG_RESULT([external])
8346    SYSTEM_CLUCENE=TRUE
8347    PKG_CHECK_MODULES(CLUCENE, libclucene-core)
8348    CLUCENE_CFLAGS=[$(printf '%s' "$CLUCENE_CFLAGS" | sed -e 's@-I[^ ]*/CLucene/ext@@' -e "s/-I/${ISYSTEM?}/g")]
8349    FilterLibs "${CLUCENE_LIBS}"
8350    CLUCENE_LIBS="${filteredlibs}"
8351    AC_LANG_PUSH([C++])
8352    save_CXXFLAGS=$CXXFLAGS
8353    save_CPPFLAGS=$CPPFLAGS
8354    CXXFLAGS="$CXXFLAGS $CLUCENE_CFLAGS"
8355    CPPFLAGS="$CPPFLAGS $CLUCENE_CFLAGS"
8356    dnl http://sourceforge.net/tracker/index.php?func=detail&aid=3392466&group_id=80013&atid=558446
8357    dnl https://bugzilla.redhat.com/show_bug.cgi?id=794795
8358    AC_CHECK_HEADER([CLucene/analysis/cjk/CJKAnalyzer.h], [],
8359                 [AC_MSG_ERROR([Your version of libclucene has contribs-lib missing.])], [#include <CLucene.h>])
8360    CXXFLAGS=$save_CXXFLAGS
8361    CPPFLAGS=$save_CPPFLAGS
8362    AC_LANG_POP([C++])
8363
8364    CLUCENE_LIBS="$CLUCENE_LIBS -lclucene-contribs-lib"
8365else
8366    AC_MSG_RESULT([internal])
8367    SYSTEM_CLUCENE=
8368    BUILD_TYPE="$BUILD_TYPE CLUCENE"
8369fi
8370AC_SUBST(SYSTEM_CLUCENE)
8371AC_SUBST(CLUCENE_CFLAGS)
8372AC_SUBST(CLUCENE_LIBS)
8373
8374dnl ===================================================================
8375dnl Check for system expat
8376dnl ===================================================================
8377libo_CHECK_SYSTEM_MODULE([expat], [EXPAT], [expat])
8378
8379dnl ===================================================================
8380dnl Check for system xmlsec
8381dnl ===================================================================
8382libo_CHECK_SYSTEM_MODULE([xmlsec], [XMLSEC], [xmlsec1-nss >= 1.2.28])
8383
8384AC_MSG_CHECKING([whether to enable Embedded OpenType support])
8385if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_eot" = "yes"; then
8386    ENABLE_EOT="TRUE"
8387    AC_DEFINE([ENABLE_EOT])
8388    AC_MSG_RESULT([yes])
8389
8390    libo_CHECK_SYSTEM_MODULE([libeot],[LIBEOT],[libeot >= 0.01])
8391else
8392    ENABLE_EOT=
8393    AC_MSG_RESULT([no])
8394fi
8395AC_SUBST([ENABLE_EOT])
8396
8397dnl ===================================================================
8398dnl Check for DLP libs
8399dnl ===================================================================
8400AS_IF([test "$COM" = "MSC"],
8401      [librevenge_libdir="${WORKDIR}/LinkTarget/Library"],
8402      [librevenge_libdir="${WORKDIR}/UnpackedTarball/librevenge/src/lib/.libs"]
8403)
8404libo_CHECK_SYSTEM_MODULE([librevenge],[REVENGE],[librevenge-0.0 >= 0.0.1],["-I${WORKDIR}/UnpackedTarball/librevenge/inc"],["-L${librevenge_libdir} -lrevenge-0.0"])
8405
8406libo_CHECK_SYSTEM_MODULE([libodfgen],[ODFGEN],[libodfgen-0.1])
8407
8408libo_CHECK_SYSTEM_MODULE([libepubgen],[EPUBGEN],[libepubgen-0.1])
8409
8410AS_IF([test "$COM" = "MSC"],
8411      [libwpd_libdir="${WORKDIR}/LinkTarget/Library"],
8412      [libwpd_libdir="${WORKDIR}/UnpackedTarball/libwpd/src/lib/.libs"]
8413)
8414libo_CHECK_SYSTEM_MODULE([libwpd],[WPD],[libwpd-0.10],["-I${WORKDIR}/UnpackedTarball/libwpd/inc"],["-L${libwpd_libdir} -lwpd-0.10"])
8415
8416libo_CHECK_SYSTEM_MODULE([libwpg],[WPG],[libwpg-0.3])
8417
8418libo_CHECK_SYSTEM_MODULE([libwps],[WPS],[libwps-0.4])
8419libo_PKG_VERSION([WPS], [libwps-0.4], [0.4.10])
8420
8421libo_CHECK_SYSTEM_MODULE([libvisio],[VISIO],[libvisio-0.1])
8422
8423libo_CHECK_SYSTEM_MODULE([libcdr],[CDR],[libcdr-0.1])
8424
8425libo_CHECK_SYSTEM_MODULE([libmspub],[MSPUB],[libmspub-0.1])
8426
8427libo_CHECK_SYSTEM_MODULE([libmwaw],[MWAW],[libmwaw-0.3 >= 0.3.1])
8428libo_PKG_VERSION([MWAW], [libmwaw-0.3], [0.3.15])
8429
8430libo_CHECK_SYSTEM_MODULE([libetonyek],[ETONYEK],[libetonyek-0.1])
8431libo_PKG_VERSION([ETONYEK], [libetonyek-0.1], [0.1.8])
8432
8433libo_CHECK_SYSTEM_MODULE([libfreehand],[FREEHAND],[libfreehand-0.1])
8434
8435libo_CHECK_SYSTEM_MODULE([libebook],[EBOOK],[libe-book-0.1])
8436libo_PKG_VERSION([EBOOK], [libe-book-0.1], [0.1.2])
8437
8438libo_CHECK_SYSTEM_MODULE([libabw],[ABW],[libabw-0.1])
8439
8440libo_CHECK_SYSTEM_MODULE([libpagemaker],[PAGEMAKER],[libpagemaker-0.0])
8441
8442libo_CHECK_SYSTEM_MODULE([libqxp],[QXP],[libqxp-0.0])
8443
8444libo_CHECK_SYSTEM_MODULE([libzmf],[ZMF],[libzmf-0.0])
8445
8446libo_CHECK_SYSTEM_MODULE([libstaroffice],[STAROFFICE],[libstaroffice-0.0])
8447libo_PKG_VERSION([STAROFFICE], [libstaroffice-0.0], [0.0.6])
8448
8449dnl ===================================================================
8450dnl Check for system lcms2
8451dnl ===================================================================
8452if test "$with_system_lcms2" != "yes"; then
8453    SYSTEM_LCMS2=
8454fi
8455libo_CHECK_SYSTEM_MODULE([lcms2],[LCMS2],[lcms2],["-I${WORKDIR}/UnpackedTarball/lcms2/include"],["-L${WORKDIR}/UnpackedTarball/lcms2/src/.libs -llcms2"])
8456if test "$GCC" = "yes"; then
8457    LCMS2_CFLAGS="${LCMS2_CFLAGS} -Wno-long-long"
8458fi
8459if test "$COM" = "MSC"; then # override the above
8460    LCMS2_LIBS=${WORKDIR}/UnpackedTarball/lcms2/bin/lcms2.lib
8461fi
8462
8463dnl ===================================================================
8464dnl Check for system cppunit
8465dnl ===================================================================
8466if test "$_os" != "Android" ; then
8467    libo_CHECK_SYSTEM_MODULE([cppunit],[CPPUNIT],[cppunit >= 1.14.0])
8468fi
8469
8470dnl ===================================================================
8471dnl Check whether freetype is available
8472dnl ===================================================================
8473if test  "$test_freetype" = "yes"; then
8474    AC_MSG_CHECKING([whether freetype is available])
8475    # FreeType has 3 different kinds of versions
8476    # * release, like 2.4.10
8477    # * libtool, like 13.0.7 (this what pkg-config returns)
8478    # * soname
8479    # FreeType's docs/VERSION.DLL provides a table mapping between the three
8480    #
8481    # 9.9.3 is 2.2.0
8482    PKG_CHECK_MODULES(FREETYPE, freetype2 >= 9.9.3)
8483    FREETYPE_CFLAGS=$(printf '%s' "$FREETYPE_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
8484    FilterLibs "${FREETYPE_LIBS}"
8485    FREETYPE_LIBS="${filteredlibs}"
8486    SYSTEM_FREETYPE=TRUE
8487else
8488    FREETYPE_CFLAGS="${ISYSTEM}${WORKDIR}/UnpackedTarball/freetype/include"
8489    FREETYPE_LIBS="-L${WORKDIR}/UnpackedTarball/freetype/instdir/lib -lfreetype"
8490fi
8491AC_SUBST(FREETYPE_CFLAGS)
8492AC_SUBST(FREETYPE_LIBS)
8493AC_SUBST([SYSTEM_FREETYPE])
8494
8495# ===================================================================
8496# Check for system libxslt
8497# to prevent incompatibilities between internal libxml2 and external libxslt,
8498# or vice versa, use with_system_libxml here
8499# ===================================================================
8500if test "$with_system_libxml" = "auto"; then
8501    case "$_os" in
8502    WINNT|iOS|Android)
8503        with_system_libxml="$with_system_libs"
8504        ;;
8505    *)
8506        if test "$enable_fuzzers" != "yes"; then
8507            with_system_libxml=yes
8508        else
8509            with_system_libxml=no
8510        fi
8511        ;;
8512    esac
8513fi
8514
8515AC_MSG_CHECKING([which libxslt to use])
8516if test "$with_system_libxml" = "yes"; then
8517    AC_MSG_RESULT([external])
8518    SYSTEM_LIBXSLT=TRUE
8519    if test "$_os" = "Darwin"; then
8520        dnl make sure to use SDK path
8521        LIBXSLT_CFLAGS="-I$MACOSX_SDK_PATH/usr/include/libxml2"
8522        LIBEXSLT_CFLAGS="$LIBXSLT_CFLAGS"
8523        dnl omit -L/usr/lib
8524        LIBXSLT_LIBS="-lxslt -lxml2 -lz -lpthread -liconv -lm"
8525        LIBEXSLT_LIBS="-lexslt $LIBXSLT_LIBS"
8526    else
8527        PKG_CHECK_MODULES(LIBXSLT, libxslt)
8528        LIBXSLT_CFLAGS=$(printf '%s' "$LIBXSLT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
8529        FilterLibs "${LIBXSLT_LIBS}"
8530        LIBXSLT_LIBS="${filteredlibs}"
8531        PKG_CHECK_MODULES(LIBEXSLT, libexslt)
8532        LIBEXSLT_CFLAGS=$(printf '%s' "$LIBEXSLT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
8533        FilterLibs "${LIBEXSLT_LIBS}"
8534        LIBEXSLT_LIBS=$(printf '%s' "${filteredlibs}" | sed -e "s/-lgpg-error//"  -e "s/-lgcrypt//")
8535    fi
8536
8537    dnl Check for xsltproc
8538    AC_PATH_PROG(XSLTPROC, xsltproc, no)
8539    if test "$XSLTPROC" = "no"; then
8540        AC_MSG_ERROR([xsltproc is required])
8541    fi
8542else
8543    AC_MSG_RESULT([internal])
8544    SYSTEM_LIBXSLT=
8545    BUILD_TYPE="$BUILD_TYPE LIBXSLT"
8546
8547    if test "$cross_compiling" = "yes"; then
8548        AC_PATH_PROG(XSLTPROC, xsltproc, no)
8549        if test "$XSLTPROC" = "no"; then
8550            AC_MSG_ERROR([xsltproc is required])
8551        fi
8552    fi
8553fi
8554AC_SUBST(SYSTEM_LIBXSLT)
8555if test -z "$SYSTEM_LIBXSLT_FOR_BUILD"; then
8556    SYSTEM_LIBXSLT_FOR_BUILD="$SYSTEM_LIBXSLT"
8557fi
8558AC_SUBST(SYSTEM_LIBXSLT_FOR_BUILD)
8559
8560AC_SUBST(LIBEXSLT_CFLAGS)
8561AC_SUBST(LIBEXSLT_LIBS)
8562AC_SUBST(LIBXSLT_CFLAGS)
8563AC_SUBST(LIBXSLT_LIBS)
8564AC_SUBST(XSLTPROC)
8565
8566# ===================================================================
8567# Check for system libxml
8568# ===================================================================
8569AC_MSG_CHECKING([which libxml to use])
8570if test "$with_system_libxml" = "yes"; then
8571    AC_MSG_RESULT([external])
8572    SYSTEM_LIBXML=TRUE
8573    if test "$_os" = "Darwin"; then
8574        dnl make sure to use SDK path
8575        LIBXML_CFLAGS="-I$MACOSX_SDK_PATH/usr/include/libxml2"
8576        dnl omit -L/usr/lib
8577        LIBXML_LIBS="-lxml2 -lz -lpthread -liconv -lm"
8578    elif test $_os = iOS; then
8579        dnl make sure to use SDK path
8580        usr=`echo '#include <stdlib.h>' | $CC -E -MD - | grep usr/include/stdlib.h | head -1 | sed -e 's,# 1 ",,' -e 's,/usr/include/.*,/usr,'`
8581        LIBXML_CFLAGS="-I$usr/include/libxml2"
8582        LIBXML_LIBS="-L$usr/lib -lxml2 -liconv"
8583    else
8584        PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= 2.0)
8585        LIBXML_CFLAGS=$(printf '%s' "$LIBXML_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
8586        FilterLibs "${LIBXML_LIBS}"
8587        LIBXML_LIBS="${filteredlibs}"
8588    fi
8589
8590    dnl Check for xmllint
8591    AC_PATH_PROG(XMLLINT, xmllint, no)
8592    if test "$XMLLINT" = "no"; then
8593        AC_MSG_ERROR([xmllint is required])
8594    fi
8595else
8596    AC_MSG_RESULT([internal])
8597    SYSTEM_LIBXML=
8598    LIBXML_CFLAGS="-I${WORKDIR}/UnpackedTarball/libxml2/include"
8599    if test "$COM" = "MSC"; then
8600        LIBXML_CFLAGS="${LIBXML_CFLAGS} -I${WORKDIR}/UnpackedTarball/icu/source/i18n -I${WORKDIR}/UnpackedTarball/icu/source/common"
8601    fi
8602    if test "$COM" = "MSC"; then
8603        LIBXML_LIBS="${WORKDIR}/UnpackedTarball/libxml2/win32/bin.msvc/libxml2.lib"
8604    else
8605        LIBXML_LIBS="-L${WORKDIR}/UnpackedTarball/libxml2/.libs -lxml2"
8606    fi
8607    BUILD_TYPE="$BUILD_TYPE LIBXML2"
8608fi
8609AC_SUBST(SYSTEM_LIBXML)
8610if test -z "$SYSTEM_LIBXML_FOR_BUILD"; then
8611    SYSTEM_LIBXML_FOR_BUILD="$SYSTEM_LIBXML"
8612fi
8613AC_SUBST(SYSTEM_LIBXML_FOR_BUILD)
8614AC_SUBST(LIBXML_CFLAGS)
8615AC_SUBST(LIBXML_LIBS)
8616AC_SUBST(XMLLINT)
8617
8618# =====================================================================
8619# Checking for a Python interpreter with version >= 2.7.
8620# Build and runtime requires Python 3 compatible version (>= 2.7).
8621# Optionally user can pass an option to configure, i. e.
8622# ./configure PYTHON=/usr/bin/python
8623# =====================================================================
8624if test "$build_os" != "cygwin" -a "$enable_python" != fully-internal; then
8625    if test -n "$PYTHON"; then
8626        PYTHON_FOR_BUILD=$PYTHON
8627    else
8628        # This allows a lack of system python with no error, we use internal one in that case.
8629        AM_PATH_PYTHON([2.7],, [:])
8630        # Clean PYTHON_VERSION checked below if cross-compiling
8631        PYTHON_VERSION=""
8632        if test "$PYTHON" != ":"; then
8633            PYTHON_FOR_BUILD=$PYTHON
8634        fi
8635    fi
8636fi
8637AC_SUBST(PYTHON_FOR_BUILD)
8638
8639# Checks for Python to use for Pyuno
8640AC_MSG_CHECKING([which Python to use for Pyuno])
8641case "$enable_python" in
8642no|disable)
8643    if test -z $PYTHON_FOR_BUILD; then
8644        # Python is required to build LibreOffice. In theory we could separate the build-time Python
8645        # requirement from the choice whether to include Python stuff in the installer, but why
8646        # bother?
8647        AC_MSG_ERROR([Python is required at build time.])
8648    fi
8649    enable_python=no
8650    AC_MSG_RESULT([none])
8651    ;;
8652""|yes|auto)
8653    if test "$DISABLE_SCRIPTING" = TRUE -a -n "$PYTHON_FOR_BUILD"; then
8654        AC_MSG_RESULT([no, overridden by --disable-scripting])
8655        enable_python=no
8656    elif test $build_os = cygwin; then
8657        dnl When building on Windows we don't attempt to use any installed
8658        dnl "system"  Python.
8659        AC_MSG_RESULT([fully internal])
8660        enable_python=internal
8661    elif test "$cross_compiling" = yes; then
8662        AC_MSG_RESULT([system])
8663        enable_python=system
8664    else
8665        # Unset variables set by the above AM_PATH_PYTHON so that
8666        # we actually do check anew.
8667        AC_MSG_RESULT([])
8668        unset PYTHON am_cv_pathless_PYTHON ac_cv_path_PYTHON am_cv_python_version am_cv_python_platform am_cv_python_pythondir am_cv_python_pyexecdir
8669        AM_PATH_PYTHON([3.3],, [:])
8670        AC_MSG_CHECKING([which Python to use for Pyuno])
8671        if test "$PYTHON" = ":"; then
8672            if test -z "$PYTHON_FOR_BUILD"; then
8673                AC_MSG_RESULT([fully internal])
8674            else
8675                AC_MSG_RESULT([internal])
8676            fi
8677            enable_python=internal
8678        else
8679            AC_MSG_RESULT([system])
8680            enable_python=system
8681        fi
8682    fi
8683    ;;
8684internal)
8685    AC_MSG_RESULT([internal])
8686    ;;
8687fully-internal)
8688    AC_MSG_RESULT([fully internal])
8689    enable_python=internal
8690    ;;
8691system)
8692    AC_MSG_RESULT([system])
8693    if test "$_os" = Darwin; then
8694        AC_MSG_ERROR([--enable-python=system doesn't work on macOS: /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/unicodeobject.h is known to contain uses of "register", which is removed from C++17])
8695    fi
8696    ;;
8697*)
8698    AC_MSG_ERROR([Incorrect --enable-python option])
8699    ;;
8700esac
8701
8702if test $enable_python != no; then
8703    BUILD_TYPE="$BUILD_TYPE PYUNO"
8704fi
8705
8706if test $enable_python = system; then
8707    if test -n "$PYTHON_CFLAGS" -a -n "$PYTHON_LIBS"; then
8708        # Fallback: Accept these in the environment, or as set above
8709        # for MacOSX.
8710        :
8711    elif test "$cross_compiling" != yes; then
8712        # Unset variables set by the above AM_PATH_PYTHON so that
8713        # we actually do check anew.
8714        unset PYTHON am_cv_pathless_PYTHON ac_cv_path_PYTHON am_cv_python_version am_cv_python_platform am_cv_python_pythondir am_cv_python_pyexecdir
8715        # This causes an error if no python command is found
8716        AM_PATH_PYTHON([3.3])
8717        python_include=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('INCLUDEPY'));"`
8718        python_version=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('VERSION'));"`
8719        python_libs=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBS'));"`
8720        python_libdir=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBDIR'));"`
8721        if test -z "$PKG_CONFIG"; then
8722            PYTHON_CFLAGS="-I$python_include"
8723            PYTHON_LIBS="-L$python_libdir -lpython$python_version $python_libs"
8724        elif $PKG_CONFIG --exists python-$python_version-embed; then
8725            PYTHON_CFLAGS="`$PKG_CONFIG --cflags python-$python_version-embed`"
8726            PYTHON_LIBS="`$PKG_CONFIG --libs python-$python_version-embed` $python_libs"
8727        elif $PKG_CONFIG --exists python-$python_version; then
8728            PYTHON_CFLAGS="`$PKG_CONFIG --cflags python-$python_version`"
8729            PYTHON_LIBS="`$PKG_CONFIG --libs python-$python_version` $python_libs"
8730        else
8731            PYTHON_CFLAGS="-I$python_include"
8732            PYTHON_LIBS="-L$python_libdir -lpython$python_version $python_libs"
8733        fi
8734        FilterLibs "${PYTHON_LIBS}"
8735        PYTHON_LIBS="${filteredlibs}"
8736    else
8737        dnl How to find out the cross-compilation Python installation path?
8738        AC_MSG_CHECKING([for python version])
8739        AS_IF([test -n "$PYTHON_VERSION"],
8740              [AC_MSG_RESULT([$PYTHON_VERSION])],
8741              [AC_MSG_RESULT([not found])
8742               AC_MSG_ERROR([no usable python found])])
8743        test -n "$PYTHON_CFLAGS" && break
8744    fi
8745
8746    dnl Check if the headers really work
8747    save_CPPFLAGS="$CPPFLAGS"
8748    CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
8749    AC_CHECK_HEADER(Python.h)
8750    CPPFLAGS="$save_CPPFLAGS"
8751
8752    # let the PYTHON_FOR_BUILD match the same python installation that
8753    # provides PYTHON_CFLAGS/PYTHON_LDFLAGS for pyuno, which should be
8754    # better for PythonTests.
8755    PYTHON_FOR_BUILD=$PYTHON
8756fi
8757
8758if test "$with_lxml" != no; then
8759    if test -z "$PYTHON_FOR_BUILD"; then
8760        case $build_os in
8761            cygwin)
8762                AC_MSG_WARN([No system-provided python lxml, gla11y will only report widget classes and ids])
8763                ;;
8764            *)
8765                if test "$cross_compiling" != yes ; then
8766                    BUILD_TYPE="$BUILD_TYPE LXML"
8767                fi
8768                ;;
8769        esac
8770    else
8771        AC_MSG_CHECKING([for python lxml])
8772        if $PYTHON_FOR_BUILD -c "import lxml.etree as ET" 2> /dev/null ; then
8773            AC_MSG_RESULT([yes])
8774        else
8775            case $build_os in
8776                cygwin)
8777                    AC_MSG_RESULT([no, gla11y will only report widget classes and ids])
8778                    ;;
8779                *)
8780                    if test "$cross_compiling" != yes -a "x$ac_cv_header_Python_h" = "xyes"; then
8781                        if test -n ${SYSTEM_LIBXSLT} -o -n ${SYSTEM_LIBXML}; then
8782                            AC_MSG_RESULT([no, and no system libxml/libxslt, gla11y will only report widget classes and ids])
8783                        else
8784                            BUILD_TYPE="$BUILD_TYPE LXML"
8785                            AC_MSG_RESULT([no, using internal lxml])
8786                        fi
8787                    else
8788                        AC_MSG_RESULT([no, and system does not provide python development headers, gla11y will only report widget classes and ids])
8789                    fi
8790                    ;;
8791            esac
8792        fi
8793    fi
8794fi
8795
8796dnl By now enable_python should be "system", "internal" or "no"
8797case $enable_python in
8798system)
8799    SYSTEM_PYTHON=TRUE
8800
8801    if test "x$ac_cv_header_Python_h" != "xyes"; then
8802       AC_MSG_ERROR([Python headers not found. You probably want to set both the PYTHON_CFLAGS and PYTHON_LIBS environment variables.])
8803    fi
8804
8805    AC_LANG_PUSH(C)
8806    CFLAGS="$CFLAGS $PYTHON_CFLAGS"
8807    AC_MSG_CHECKING([for correct python library version])
8808       AC_RUN_IFELSE([AC_LANG_SOURCE([[
8809#include <Python.h>
8810
8811int main(int argc, char **argv) {
8812   if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 7) ||
8813       (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 3)) return 0;
8814   else return 1;
8815}
8816       ]])],[AC_MSG_RESULT([ok])],[AC_MSG_ERROR([Python >= 3.3 is needed when building with Python 3, or Python >= 2.7 when building with Python 2])],[AC_MSG_RESULT([skipped; cross-compiling])])
8817    CFLAGS=$save_CFLAGS
8818    AC_LANG_POP(C)
8819
8820    dnl FIXME Check if the Python library can be linked with, too?
8821    ;;
8822
8823internal)
8824    SYSTEM_PYTHON=
8825    PYTHON_VERSION_MAJOR=3
8826    PYTHON_VERSION_MINOR=7
8827    PYTHON_VERSION=${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.7
8828    if ! grep -q -i python.*${PYTHON_VERSION} ${SRC_ROOT}/download.lst; then
8829        AC_MSG_ERROR([PYTHON_VERSION ${PYTHON_VERSION} but no matching file in download.lst])
8830    fi
8831    AC_DEFINE_UNQUOTED([PYTHON_VERSION_STRING], [L"${PYTHON_VERSION}"])
8832    BUILD_TYPE="$BUILD_TYPE PYTHON"
8833    if test "$OS" = LINUX; then
8834        BUILD_TYPE="$BUILD_TYPE LIBFFI"
8835    fi
8836    # Embedded Python dies without Home set
8837    if test "$HOME" = ""; then
8838        export HOME=""
8839    fi
8840    ;;
8841no)
8842    DISABLE_PYTHON=TRUE
8843    SYSTEM_PYTHON=
8844    ;;
8845*)
8846    AC_MSG_ERROR([Internal configure script error, invalid enable_python value "$enable_python"])
8847    ;;
8848esac
8849
8850AC_SUBST(DISABLE_PYTHON)
8851AC_SUBST(SYSTEM_PYTHON)
8852AC_SUBST(PYTHON_CFLAGS)
8853AC_SUBST(PYTHON_LIBS)
8854AC_SUBST(PYTHON_VERSION)
8855AC_SUBST(PYTHON_VERSION_MAJOR)
8856AC_SUBST(PYTHON_VERSION_MINOR)
8857
8858ENABLE_MARIADBC=TRUE
8859if test "$_os" = "Android" -o "$_os" = "iOS" -o "$enable_mpl_subset" = "yes"; then
8860    ENABLE_MARIADBC=
8861fi
8862MARIADBC_MAJOR=1
8863MARIADBC_MINOR=0
8864MARIADBC_MICRO=2
8865if test "$ENABLE_MARIADBC" = "TRUE"; then
8866    BUILD_TYPE="$BUILD_TYPE MARIADBC"
8867fi
8868
8869AC_SUBST(ENABLE_MARIADBC)
8870AC_SUBST(MARIADBC_MAJOR)
8871AC_SUBST(MARIADBC_MINOR)
8872AC_SUBST(MARIADBC_MICRO)
8873
8874if test "$ENABLE_MARIADBC" = "TRUE"; then
8875    dnl ===================================================================
8876    dnl Check for system MariaDB
8877    dnl ===================================================================
8878    AC_MSG_CHECKING([which MariaDB to use])
8879    if test "$with_system_mariadb" = "yes"; then
8880        AC_MSG_RESULT([external])
8881        SYSTEM_MARIADB_CONNECTOR_C=TRUE
8882        #AC_PATH_PROG(MARIADBCONFIG, [mariadb_config])
8883        if test -z "$MARIADBCONFIG"; then
8884            AC_PATH_PROG(MARIADBCONFIG, [mysql_config])
8885            if test -z "$MARIADBCONFIG"; then
8886                AC_MSG_ERROR([mysql_config is missing. Install MySQL client library development package.])
8887                #AC_MSG_ERROR([mariadb_config and mysql_config are missing. Install MariaDB or MySQL client library development package.])
8888            fi
8889        fi
8890        AC_MSG_CHECKING([MariaDB version])
8891        MARIADB_VERSION=`$MARIADBCONFIG --version`
8892        MARIADB_MAJOR=`$MARIADBCONFIG --version | cut -d"." -f1`
8893        if test "$MARIADB_MAJOR" -ge "5"; then
8894            AC_MSG_RESULT([OK])
8895        else
8896            AC_MSG_ERROR([too old, use 5.0.x or later])
8897        fi
8898        AC_MSG_CHECKING([for MariaDB Client library])
8899        MARIADB_CFLAGS=`$MARIADBCONFIG --cflags`
8900        if test "$COM_IS_CLANG" = TRUE; then
8901            MARIADB_CFLAGS=$(printf '%s' "$MARIADB_CFLAGS" | sed -e s/-fstack-protector-strong//)
8902        fi
8903        MARIADB_LIBS=`$MARIADBCONFIG --libs_r`
8904        dnl At least mariadb-5.5.34-3.fc20.x86_64 plus
8905        dnl mariadb-5.5.34-3.fc20.i686 reports 64-bit specific output even under
8906        dnl linux32:
8907        if test "$OS" = LINUX -a "$CPUNAME" = INTEL; then
8908            MARIADB_CFLAGS=$(printf '%s' "$MARIADB_CFLAGS" | sed -e s/-m64//)
8909            MARIADB_LIBS=$(printf '%s' "$MARIADB_LIBS" \
8910                | sed -e 's|/lib64/|/lib/|')
8911        fi
8912        FilterLibs "${MARIADB_LIBS}"
8913        MARIADB_LIBS="${filteredlibs}"
8914        AC_MSG_RESULT([includes '$MARIADB_CFLAGS', libraries '$MARIADB_LIBS'])
8915        AC_MSG_CHECKING([whether to bundle the MySQL/MariaDB client library])
8916        if test "$enable_bundle_mariadb" = "yes"; then
8917            AC_MSG_RESULT([yes])
8918            BUNDLE_MARIADB_CONNECTOR_C=TRUE
8919            LIBMARIADB=lib$(echo "${MARIADB_LIBS}" | sed -e 's/[[[:space:]]]\{1,\}-l\([[^[:space:]]]\{1,\}\)/\
8920\1\
8921/g' -e 's/^-l\([[^[:space:]]]\{1,\}\)[[[:space:]]]*/\
8922\1\
8923/g' | grep -E '(mysqlclient|mariadb)')
8924            if test "$_os" = "Darwin"; then
8925                LIBMARIADB=${LIBMARIADB}.dylib
8926            elif test "$_os" = "WINNT"; then
8927                LIBMARIADB=${LIBMARIADB}.dll
8928            else
8929                LIBMARIADB=${LIBMARIADB}.so
8930            fi
8931            LIBMARIADB_PATH=$($MARIADBCONFIG --variable=pkglibdir)
8932            AC_MSG_CHECKING([for $LIBMARIADB in $LIBMARIADB_PATH])
8933            if test -e "$LIBMARIADB_PATH/$LIBMARIADB"; then
8934                AC_MSG_RESULT([found.])
8935                PathFormat "$LIBMARIADB_PATH"
8936                LIBMARIADB_PATH="$formatted_path"
8937            else
8938                AC_MSG_ERROR([not found.])
8939            fi
8940        else
8941            AC_MSG_RESULT([no])
8942            BUNDLE_MARIADB_CONNECTOR_C=
8943        fi
8944    else
8945        AC_MSG_RESULT([internal])
8946        SYSTEM_MARIADB_CONNECTOR_C=
8947        MARIADB_CFLAGS="-I${WORKDIR}/UnpackedTarball/mariadb-connector-c/include"
8948        MARIADB_LIBS="-L${WORKDIR}/LinkTarget/StaticLibrary -lmariadb-connector-c"
8949        BUILD_TYPE="$BUILD_TYPE MARIADB_CONNECTOR_C"
8950    fi
8951
8952    AC_SUBST(SYSTEM_MARIADB_CONNECTOR_C)
8953    AC_SUBST(MARIADB_CFLAGS)
8954    AC_SUBST(MARIADB_LIBS)
8955    AC_SUBST(LIBMARIADB)
8956    AC_SUBST(LIBMARIADB_PATH)
8957    AC_SUBST(BUNDLE_MARIADB_CONNECTOR_C)
8958fi
8959
8960dnl ===================================================================
8961dnl Check for system hsqldb
8962dnl ===================================================================
8963if test "$with_java" != "no"; then
8964    HSQLDB_USE_JDBC_4_1=
8965    AC_MSG_CHECKING([which hsqldb to use])
8966    if test "$with_system_hsqldb" = "yes"; then
8967        AC_MSG_RESULT([external])
8968        SYSTEM_HSQLDB=TRUE
8969        if test -z $HSQLDB_JAR; then
8970            HSQLDB_JAR=/usr/share/java/hsqldb.jar
8971        fi
8972        if ! test -f $HSQLDB_JAR; then
8973               AC_MSG_ERROR(hsqldb.jar not found.)
8974        fi
8975        AC_MSG_CHECKING([whether hsqldb is 1.8.0.x])
8976        export HSQLDB_JAR
8977        if $PERL -e \
8978           'use Archive::Zip;
8979            my $file = "$ENV{'HSQLDB_JAR'}";
8980            my $zip = Archive::Zip->new( $file );
8981            my $mf = $zip->contents ( "META-INF/MANIFEST.MF" );
8982            if ( $mf =~ m/Specification-Version: 1.8.*/ )
8983            {
8984                push @l, split(/\n/, $mf);
8985                foreach my $line (@l)
8986                {
8987                    if ($line =~ m/Specification-Version:/)
8988                    {
8989                        ($t, $version) = split (/:/,$line);
8990                        $version =~ s/^\s//;
8991                        ($a, $b, $c, $d) = split (/\./,$version);
8992                        if ($c == "0" && $d > "8")
8993                        {
8994                            exit 0;
8995                        }
8996                        else
8997                        {
8998                            exit 1;
8999                        }
9000                    }
9001                }
9002            }
9003            else
9004            {
9005                exit 1;
9006            }'; then
9007            AC_MSG_RESULT([yes])
9008        else
9009            AC_MSG_ERROR([no, you need hsqldb >= 1.8.0.9 but < 1.8.1])
9010        fi
9011    else
9012        AC_MSG_RESULT([internal])
9013        SYSTEM_HSQLDB=
9014        BUILD_TYPE="$BUILD_TYPE HSQLDB"
9015        NEED_ANT=TRUE
9016        AC_MSG_CHECKING([whether hsqldb should be built with JDBC 4.1])
9017        javanumver=`$JAVAINTERPRETER -version 2>&1 | $AWK -v num=true -f $SRC_ROOT/solenv/bin/getcompver.awk`
9018        if expr "$javanumver" '>=' 000100060000 > /dev/null; then
9019            AC_MSG_RESULT([yes])
9020            HSQLDB_USE_JDBC_4_1=TRUE
9021        else
9022            AC_MSG_RESULT([no])
9023        fi
9024    fi
9025    AC_SUBST(SYSTEM_HSQLDB)
9026    AC_SUBST(HSQLDB_JAR)
9027    AC_SUBST([HSQLDB_USE_JDBC_4_1])
9028fi
9029
9030dnl ===================================================================
9031dnl Check for PostgreSQL stuff
9032dnl ===================================================================
9033AC_MSG_CHECKING([whether to build the PostgreSQL SDBC driver])
9034if test "x$enable_postgresql_sdbc" != "xno"; then
9035    AC_MSG_RESULT([yes])
9036    SCPDEFS="$SCPDEFS -DWITH_POSTGRESQL_SDBC"
9037
9038    if test "$with_krb5" = "yes" -a "$enable_openssl" = "no"; then
9039        AC_MSG_ERROR([krb5 needs OpenSSL, but --disable-openssl was given.])
9040    fi
9041    if test "$with_gssapi" = "yes" -a "$enable_openssl" = "no"; then
9042        AC_MSG_ERROR([GSSAPI needs OpenSSL, but --disable-openssl was given.])
9043    fi
9044
9045    postgres_interface=""
9046    if test "$with_system_postgresql" = "yes"; then
9047        postgres_interface="external PostgreSQL"
9048        SYSTEM_POSTGRESQL=TRUE
9049        if test "$_os" = Darwin; then
9050            supp_path=''
9051            for d in /Library/PostgreSQL/9.*/bin /sw/opt/postgresql/9.*/bin /opt/local/lib/postgresql9*/bin; do
9052                pg_supp_path="$P_SEP$d$pg_supp_path"
9053            done
9054        fi
9055        AC_PATH_PROG(PGCONFIG, pg_config, ,$PATH$pg_supp_path)
9056        if test -n "$PGCONFIG"; then
9057            POSTGRESQL_INC=-I$(${PGCONFIG} --includedir)
9058            POSTGRESQL_LIB="-L$(${PGCONFIG} --libdir)"
9059        else
9060            PKG_CHECK_MODULES(POSTGRESQL, libpq, [
9061              POSTGRESQL_INC=$POSTGRESQL_CFLAGS
9062              POSTGRESQL_LIB=$POSTGRESQL_LIBS
9063            ],[
9064              AC_MSG_ERROR([pg_config or 'pkg-config libpq' needed; set PGCONFIG if not in PATH])
9065            ])
9066        fi
9067        FilterLibs "${POSTGRESQL_LIB}"
9068        POSTGRESQL_LIB="${filteredlibs}"
9069    else
9070        # if/when anything else than PostgreSQL uses Kerberos,
9071        # move this out of `test "x$enable_postgresql_sdbc" != "xno"'
9072        WITH_KRB5=
9073        WITH_GSSAPI=
9074        case "$_os" in
9075        Darwin)
9076            # macOS has system MIT Kerberos 5 since 10.4
9077            if test "$with_krb5" != "no"; then
9078                WITH_KRB5=TRUE
9079                save_LIBS=$LIBS
9080                # Not sure whether it makes any sense here to search multiple potential libraries; it is not likely
9081                # that the libraries where these functions are located on macOS will change, is it?
9082                AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
9083                    [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
9084                KRB5_LIBS=$LIBS
9085                LIBS=$save_LIBS
9086                AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
9087                    [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
9088                KRB5_LIBS="$KRB5_LIBS $LIBS"
9089                LIBS=$save_LIBS
9090            fi
9091            if test "$with_gssapi" != "no"; then
9092                WITH_GSSAPI=TRUE
9093                save_LIBS=$LIBS
9094                AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
9095                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
9096                GSSAPI_LIBS=$LIBS
9097                LIBS=$save_LIBS
9098            fi
9099            ;;
9100        WINNT)
9101            if test "$with_krb5" = "yes" -o "$with_gssapi" = "yes"; then
9102                AC_MSG_ERROR([Refusing to enable MIT Kerberos 5 or GSSAPI on Windows.])
9103            fi
9104            ;;
9105        Linux|GNU|*BSD|DragonFly)
9106            if test "$with_krb5" != "no"; then
9107                WITH_KRB5=TRUE
9108                save_LIBS=$LIBS
9109                AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
9110                    [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
9111                KRB5_LIBS=$LIBS
9112                LIBS=$save_LIBS
9113                AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
9114                    [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
9115                KRB5_LIBS="$KRB5_LIBS $LIBS"
9116                LIBS=$save_LIBS
9117            fi
9118            if test "$with_gssapi" != "no"; then
9119                WITH_GSSAPI=TRUE
9120                save_LIBS=$LIBS
9121                AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
9122                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
9123                GSSAPI_LIBS=$LIBS
9124                LIBS=$save_LIBS
9125            fi
9126            ;;
9127        *)
9128            if test "$with_krb5" = "yes"; then
9129                WITH_KRB5=TRUE
9130                save_LIBS=$LIBS
9131                AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
9132                    [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
9133                KRB5_LIBS=$LIBS
9134                LIBS=$save_LIBS
9135                AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
9136                    [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
9137                KRB5_LIBS="$KRB5_LIBS $LIBS"
9138                LIBS=$save_LIBS
9139            fi
9140            if test "$with_gssapi" = "yes"; then
9141                WITH_GSSAPI=TRUE
9142                save_LIBS=$LIBS
9143                AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
9144                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
9145                LIBS=$save_LIBS
9146                GSSAPI_LIBS=$LIBS
9147            fi
9148        esac
9149
9150        if test -n "$with_libpq_path"; then
9151            SYSTEM_POSTGRESQL=TRUE
9152            postgres_interface="external libpq"
9153            POSTGRESQL_LIB="-L${with_libpq_path}/lib/"
9154            POSTGRESQL_INC=-I"${with_libpq_path}/include/"
9155        else
9156            SYSTEM_POSTGRESQL=
9157            postgres_interface="internal"
9158            POSTGRESQL_LIB=""
9159            POSTGRESQL_INC="%OVERRIDE_ME%"
9160            BUILD_TYPE="$BUILD_TYPE POSTGRESQL"
9161        fi
9162    fi
9163
9164    AC_MSG_CHECKING([PostgreSQL C interface])
9165    AC_MSG_RESULT([$postgres_interface])
9166
9167    if test "${SYSTEM_POSTGRESQL}" = "TRUE"; then
9168        AC_MSG_NOTICE([checking system PostgreSQL prerequisites])
9169        save_CFLAGS=$CFLAGS
9170        save_CPPFLAGS=$CPPFLAGS
9171        save_LIBS=$LIBS
9172        CPPFLAGS="${CPPFLAGS} ${POSTGRESQL_INC}"
9173        LIBS="${LIBS} ${POSTGRESQL_LIB}"
9174        AC_CHECK_HEADER([libpq-fe.h], [], [AC_MSG_ERROR([libpq-fe.h is needed])], [])
9175        AC_CHECK_LIB([pq], [PQconnectdbParams], [:],
9176            [AC_MSG_ERROR(libpq not found or too old. Need >= 9.0)], [])
9177        CFLAGS=$save_CFLAGS
9178        CPPFLAGS=$save_CPPFLAGS
9179        LIBS=$save_LIBS
9180    fi
9181    BUILD_POSTGRESQL_SDBC=TRUE
9182else
9183    AC_MSG_RESULT([no])
9184fi
9185AC_SUBST(WITH_KRB5)
9186AC_SUBST(WITH_GSSAPI)
9187AC_SUBST(GSSAPI_LIBS)
9188AC_SUBST(KRB5_LIBS)
9189AC_SUBST(BUILD_POSTGRESQL_SDBC)
9190AC_SUBST(SYSTEM_POSTGRESQL)
9191AC_SUBST(POSTGRESQL_INC)
9192AC_SUBST(POSTGRESQL_LIB)
9193
9194dnl ===================================================================
9195dnl Check for Firebird stuff
9196dnl ===================================================================
9197ENABLE_FIREBIRD_SDBC=
9198if test "$enable_firebird_sdbc" = "yes" ; then
9199    SCPDEFS="$SCPDEFS -DWITH_FIREBIRD_SDBC"
9200
9201    dnl ===================================================================
9202    dnl Check for system Firebird
9203    dnl ===================================================================
9204    AC_MSG_CHECKING([which Firebird to use])
9205    if test "$with_system_firebird" = "yes"; then
9206        AC_MSG_RESULT([external])
9207        SYSTEM_FIREBIRD=TRUE
9208        AC_PATH_PROG(FIREBIRDCONFIG, [fb_config])
9209        if test -z "$FIREBIRDCONFIG"; then
9210            AC_MSG_NOTICE([No fb_config -- using pkg-config])
9211            PKG_CHECK_MODULES([FIREBIRD], [fbclient >= 3], [FIREBIRD_PKGNAME=fbclient], [
9212                PKG_CHECK_MODULES([FIREBIRD], [fbembed], [FIREBIRD_PKGNAME=fbembed])
9213            ])
9214            FIREBIRD_VERSION=`pkg-config --modversion "$FIREBIRD_PKGNAME"`
9215        else
9216            AC_MSG_NOTICE([fb_config found])
9217            FIREBIRD_VERSION=`$FIREBIRDCONFIG --version`
9218            AC_MSG_CHECKING([for Firebird Client library])
9219            FIREBIRD_CFLAGS=`$FIREBIRDCONFIG --cflags`
9220            FIREBIRD_LIBS=`$FIREBIRDCONFIG --embedlibs`
9221            FilterLibs "${FIREBIRD_LIBS}"
9222            FIREBIRD_LIBS="${filteredlibs}"
9223        fi
9224        AC_MSG_RESULT([includes `$FIREBIRD_CFLAGS', libraries `$FIREBIRD_LIBS'])
9225        AC_MSG_CHECKING([Firebird version])
9226        if test -n "${FIREBIRD_VERSION}"; then
9227            FIREBIRD_MAJOR=`echo $FIREBIRD_VERSION | cut -d"." -f1`
9228            FIREBIRD_MINOR=`echo $FIREBIRD_VERSION | cut -d"." -f2`
9229            if test "$FIREBIRD_MAJOR" -eq "3" -a "$FIREBIRD_MINOR" -eq "0"; then
9230                AC_MSG_RESULT([OK])
9231            else
9232                AC_MSG_ERROR([Ensure firebird 3.0.x is installed])
9233            fi
9234        else
9235            __save_CFLAGS="${CFLAGS}"
9236            CFLAGS="${CFLAGS} ${FIREBIRD_CFLAGS}"
9237            AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <ibase.h>
9238#if defined(FB_API_VER) && FB_API_VER == 30
9239int fb_api_is_30(void) { return 0; }
9240#else
9241#error "Wrong Firebird API version"
9242#endif]])],AC_MSG_RESULT([OK]),AC_MSG_ERROR([Ensure firebird 3.0.x is installed]))
9243            CFLAGS="${__save_CFLAGS}"
9244        fi
9245        ENABLE_FIREBIRD_SDBC=TRUE
9246        AC_DEFINE([ENABLE_FIREBIRD_SDBC],1)
9247    elif test "$enable_database_connectivity" != yes; then
9248        AC_MSG_RESULT([none])
9249    elif test "$cross_compiling" = "yes"; then
9250        AC_MSG_RESULT([none])
9251    else
9252        dnl Embedded Firebird has version 3.0
9253        AC_DEFINE(HAVE_FIREBIRD_30, 1)
9254        dnl We need libatomic_ops for any non X86/X64 system
9255        if test "${CPUNAME}" != INTEL -a "${CPUNAME}" != X86_64; then
9256            dnl ===================================================================
9257            dnl Check for system libatomic_ops
9258            dnl ===================================================================
9259            libo_CHECK_SYSTEM_MODULE([libatomic_ops],[ATOMIC_OPS],[atomic_ops >= 0.7.2])
9260            if test "$with_system_libatomic_ops" = "yes"; then
9261                SYSTEM_LIBATOMIC_OPS=TRUE
9262                AC_CHECK_HEADERS(atomic_ops.h, [],
9263                [AC_MSG_ERROR(atomic_ops.h not found. install libatomic_ops)], [])
9264            else
9265                SYSTEM_LIBATOMIC_OPS=
9266                LIBATOMIC_OPS_CFLAGS="-I${WORKDIR}/UnpackedTarball/libatomic_ops/include"
9267                LIBATOMIC_OPS_LIBS="-latomic_ops"
9268                BUILD_TYPE="$BUILD_TYPE LIBATOMIC_OPS"
9269            fi
9270        fi
9271
9272        AC_MSG_RESULT([internal])
9273        SYSTEM_FIREBIRD=
9274        FIREBIRD_CFLAGS="-I${WORKDIR}/UnpackedTarball/firebird/gen/Release/firebird/include"
9275        FIREBIRD_LIBS="-lfbclient"
9276
9277        if test "$with_system_libtommath" = "yes"; then
9278            SYSTEM_LIBTOMMATH=TRUE
9279            dnl check for tommath presence
9280            save_LIBS=$LIBS
9281            AC_CHECK_HEADER(tommath.h,,AC_MSG_ERROR(Include file for tommath not found - please install development tommath package))
9282            AC_CHECK_LIB(tommath, mp_init, TOMMATH_LIBS=-ltommath, AC_MSG_ERROR(Library tommath not found - please install development tommath package))
9283            LIBS=$save_LIBS
9284        else
9285            SYSTEM_LIBTOMMATH=
9286            LIBTOMMATH_CFLAGS="-I${WORKDIR}/UnpackedTarball/libtommath"
9287            LIBTOMMATH_LIBS="-ltommath"
9288            BUILD_TYPE="$BUILD_TYPE LIBTOMMATH"
9289        fi
9290
9291        BUILD_TYPE="$BUILD_TYPE FIREBIRD"
9292        ENABLE_FIREBIRD_SDBC=TRUE
9293        AC_DEFINE([ENABLE_FIREBIRD_SDBC],1)
9294    fi
9295fi
9296AC_SUBST(ENABLE_FIREBIRD_SDBC)
9297AC_SUBST(SYSTEM_LIBATOMIC_OPS)
9298AC_SUBST(LIBATOMIC_OPS_CFLAGS)
9299AC_SUBST(LIBATOMIC_OPS_LIBS)
9300AC_SUBST(SYSTEM_FIREBIRD)
9301AC_SUBST(FIREBIRD_CFLAGS)
9302AC_SUBST(FIREBIRD_LIBS)
9303AC_SUBST([TOMMATH_CFLAGS])
9304AC_SUBST([TOMMATH_LIBS])
9305
9306dnl ===================================================================
9307dnl Check for system curl
9308dnl ===================================================================
9309AC_MSG_CHECKING([which libcurl to use])
9310if test "$with_system_curl" = "auto"; then
9311    with_system_curl="$with_system_libs"
9312fi
9313
9314if test "$with_system_curl" = "yes"; then
9315    AC_MSG_RESULT([external])
9316    SYSTEM_CURL=TRUE
9317
9318    # First try PKGCONFIG and then fall back
9319    PKG_CHECK_MODULES(CURL, libcurl >= 7.19.4,, [:])
9320
9321    if test -n "$CURL_PKG_ERRORS"; then
9322        AC_PATH_PROG(CURLCONFIG, curl-config)
9323        if test -z "$CURLCONFIG"; then
9324            AC_MSG_ERROR([curl development files not found])
9325        fi
9326        CURL_LIBS=`$CURLCONFIG --libs`
9327        FilterLibs "${CURL_LIBS}"
9328        CURL_LIBS="${filteredlibs}"
9329        CURL_CFLAGS=$("$CURLCONFIG" --cflags | sed -e "s/-I/${ISYSTEM?}/g")
9330        curl_version=`$CURLCONFIG --version | $SED -e 's/^libcurl //'`
9331
9332        AC_MSG_CHECKING([whether libcurl is >= 7.19.4])
9333        case $curl_version in
9334        dnl brackets doubled below because Autoconf uses them as m4 quote characters,
9335        dnl so they need to be doubled to end up in the configure script
9336        7.19.4|7.19.[[5-9]]|7.[[2-9]]?.*|7.???.*|[[8-9]].*|[[1-9]][[0-9]].*)
9337            AC_MSG_RESULT([yes])
9338            ;;
9339        *)
9340            AC_MSG_ERROR([no, you have $curl_version])
9341            ;;
9342        esac
9343    fi
9344
9345    ENABLE_CURL=TRUE
9346elif test $_os = iOS; then
9347    # Let's see if we need curl, I think not?
9348    AC_MSG_RESULT([none])
9349    ENABLE_CURL=
9350else
9351    AC_MSG_RESULT([internal])
9352    SYSTEM_CURL=
9353    BUILD_TYPE="$BUILD_TYPE CURL"
9354    ENABLE_CURL=TRUE
9355fi
9356AC_SUBST(SYSTEM_CURL)
9357AC_SUBST(CURL_CFLAGS)
9358AC_SUBST(CURL_LIBS)
9359AC_SUBST(ENABLE_CURL)
9360
9361dnl ===================================================================
9362dnl Check for system boost
9363dnl ===================================================================
9364AC_MSG_CHECKING([which boost to use])
9365if test "$with_system_boost" = "yes"; then
9366    AC_MSG_RESULT([external])
9367    SYSTEM_BOOST=TRUE
9368    AX_BOOST_BASE(1.47)
9369    AX_BOOST_DATE_TIME
9370    AX_BOOST_FILESYSTEM
9371    AX_BOOST_IOSTREAMS
9372    AX_BOOST_LOCALE
9373    AC_LANG_PUSH([C++])
9374    save_CXXFLAGS=$CXXFLAGS
9375    CXXFLAGS="$CXXFLAGS $BOOST_CPPFLAGS $CXXFLAGS_CXX11"
9376    AC_CHECK_HEADER(boost/shared_ptr.hpp, [],
9377       [AC_MSG_ERROR(boost/shared_ptr.hpp not found. install boost)], [])
9378    AC_CHECK_HEADER(boost/spirit/include/classic_core.hpp, [],
9379       [AC_MSG_ERROR(boost/spirit/include/classic_core.hpp not found. install boost >= 1.36)], [])
9380    CXXFLAGS=$save_CXXFLAGS
9381    AC_LANG_POP([C++])
9382    # this is in m4/ax_boost_base.m4
9383    FilterLibs "${BOOST_LDFLAGS}"
9384    BOOST_LDFLAGS="${filteredlibs}"
9385else
9386    AC_MSG_RESULT([internal])
9387    BUILD_TYPE="$BUILD_TYPE BOOST"
9388    SYSTEM_BOOST=
9389    if test "${COM}" = "GCC" -o "${COM_IS_CLANG}" = "TRUE"; then
9390        # use warning-suppressing wrapper headers
9391        BOOST_CPPFLAGS="-I${SRC_ROOT}/external/boost/include -I${WORKDIR}/UnpackedTarball/boost"
9392    else
9393        BOOST_CPPFLAGS="-I${WORKDIR}/UnpackedTarball/boost"
9394    fi
9395fi
9396AC_SUBST(SYSTEM_BOOST)
9397
9398dnl ===================================================================
9399dnl Check for system mdds
9400dnl ===================================================================
9401libo_CHECK_SYSTEM_MODULE([mdds], [MDDS], [mdds-1.5 >= 1.5.0], ["-I${WORKDIR}/UnpackedTarball/mdds/include"])
9402
9403dnl ===================================================================
9404dnl Check for system glm
9405dnl ===================================================================
9406AC_MSG_CHECKING([which glm to use])
9407if test "$with_system_glm" = "yes"; then
9408    AC_MSG_RESULT([external])
9409    SYSTEM_GLM=TRUE
9410    AC_LANG_PUSH([C++])
9411    AC_CHECK_HEADER([glm/glm.hpp], [],
9412       [AC_MSG_ERROR([glm/glm.hpp not found. install glm])], [])
9413    AC_LANG_POP([C++])
9414else
9415    AC_MSG_RESULT([internal])
9416    BUILD_TYPE="$BUILD_TYPE GLM"
9417    SYSTEM_GLM=
9418    GLM_CFLAGS="${ISYSTEM}${WORKDIR}/UnpackedTarball/glm"
9419fi
9420AC_SUBST([GLM_CFLAGS])
9421AC_SUBST([SYSTEM_GLM])
9422
9423dnl ===================================================================
9424dnl Check for system odbc
9425dnl ===================================================================
9426AC_MSG_CHECKING([which odbc headers to use])
9427if test "$with_system_odbc" = "yes" -o '(' "$with_system_headers" = "yes" -a "$with_system_odbc" = "auto" ')' -o '(' "$_os" = "WINNT" -a  "$with_system_odbc" != "no" ')'; then
9428    AC_MSG_RESULT([external])
9429    SYSTEM_ODBC_HEADERS=TRUE
9430
9431    if test "$build_os" = "cygwin"; then
9432        save_CPPFLAGS=$CPPFLAGS
9433        find_winsdk
9434        PathFormat "$winsdktest"
9435        CPPFLAGS="$CPPFLAGS -I$formatted_path/include/um -I$formatted_path/Include/$winsdklibsubdir/um -I$formatted_path/include -I$formatted_path/include/shared -I$formatted_path/include/$winsdklibsubdir/shared"
9436        AC_CHECK_HEADER(sqlext.h, [],
9437            [AC_MSG_ERROR(odbc not found. install odbc)],
9438            [#include <windows.h>])
9439        CPPFLAGS=$save_CPPFLAGS
9440    else
9441        AC_CHECK_HEADER(sqlext.h, [],
9442            [AC_MSG_ERROR(odbc not found. install odbc)],[])
9443    fi
9444elif test "$enable_database_connectivity" != yes; then
9445    AC_MSG_RESULT([none])
9446else
9447    AC_MSG_RESULT([internal])
9448    SYSTEM_ODBC_HEADERS=
9449fi
9450AC_SUBST(SYSTEM_ODBC_HEADERS)
9451
9452dnl ===================================================================
9453dnl Enable LDAP support
9454dnl ===================================================================
9455
9456if test "$_os" != "WINNT" -a "$_os" != "iOS" -a "$_os" != "Android"; then
9457AC_MSG_CHECKING([whether to enable LDAP support])
9458    if test "$enable_ldap" != "yes"; then
9459        AC_MSG_RESULT([no])
9460        ENABLE_LDAP=""
9461        enable_ldap=no
9462    else
9463        AC_MSG_RESULT([yes])
9464        ENABLE_LDAP="TRUE"
9465        AC_DEFINE(HAVE_FEATURE_LDAP)
9466    fi
9467fi
9468AC_SUBST(ENABLE_LDAP)
9469
9470dnl ===================================================================
9471dnl Check for system openldap
9472dnl ===================================================================
9473
9474if test "$_os" != "WINNT" -a "$_os" != "iOS" -a "$_os" != "Android" -a "$ENABLE_LDAP" != ""; then
9475AC_MSG_CHECKING([which openldap library to use])
9476if test "$with_system_openldap" = "yes"; then
9477    AC_MSG_RESULT([external])
9478    SYSTEM_OPENLDAP=TRUE
9479    AC_CHECK_HEADERS(ldap.h, [], [AC_MSG_ERROR(ldap.h not found. install openldap libs)], [])
9480    AC_CHECK_LIB([ldap], [ldap_simple_bind_s], [:], [AC_MSG_ERROR(openldap lib not found or functional)], [])
9481    AC_CHECK_LIB([ldap], [ldap_set_option], [:], [AC_MSG_ERROR(openldap lib not found or functional)], [])
9482else
9483    AC_MSG_RESULT([internal])
9484    SYSTEM_OPENLDAP=
9485    BUILD_TYPE="$BUILD_TYPE OPENLDAP"
9486fi
9487fi
9488AC_SUBST(SYSTEM_OPENLDAP)
9489
9490dnl ===================================================================
9491dnl Check for system NSS
9492dnl ===================================================================
9493if test $_os != iOS -a "$enable_fuzzers" != "yes"; then
9494    libo_CHECK_SYSTEM_MODULE([nss],[NSS],[nss >= 3.9.3 nspr >= 4.8])
9495    AC_DEFINE(HAVE_FEATURE_NSS)
9496    ENABLE_NSS="TRUE"
9497    AC_DEFINE(ENABLE_NSS)
9498elif test $_os != iOS ; then
9499    with_tls=openssl
9500fi
9501AC_SUBST(ENABLE_NSS)
9502
9503dnl ===================================================================
9504dnl Check for TLS/SSL and cryptographic implementation to use
9505dnl ===================================================================
9506AC_MSG_CHECKING([which TLS/SSL and cryptographic implementation to use])
9507if test -n "$with_tls"; then
9508    case $with_tls in
9509    openssl)
9510        AC_DEFINE(USE_TLS_OPENSSL)
9511        TLS=OPENSSL
9512
9513        if test "$enable_openssl" != "yes"; then
9514            AC_MSG_ERROR(["Disabling OpenSSL was requested, but the requested TLS to use is actually OpenSSL."])
9515        fi
9516
9517        # warn that OpenSSL has been selected but not all TLS code has this option
9518        AC_MSG_WARN([TLS/SSL implementation to use is OpenSSL but some code may still depend on NSS or GNUTLS])
9519        add_warning "TLS/SSL implementation to use is OpenSSL but some code may still depend on NSS or GNUTLS"
9520        ;;
9521    nss)
9522        AC_DEFINE(USE_TLS_NSS)
9523        TLS=NSS
9524        ;;
9525    no)
9526        AC_MSG_WARN([Skipping TLS/SSL])
9527        ;;
9528    *)
9529        AC_MSG_ERROR([unsupported implementation $with_tls. Supported are:
9530openssl - OpenSSL
9531nss - Mozilla's Network Security Services (NSS)
9532    ])
9533        ;;
9534    esac
9535else
9536    # default to using NSS, it results in smaller oox lib
9537    AC_DEFINE(USE_TLS_NSS)
9538    TLS=NSS
9539fi
9540AC_MSG_RESULT([$TLS])
9541AC_SUBST(TLS)
9542
9543dnl ===================================================================
9544dnl Check for system sane
9545dnl ===================================================================
9546AC_MSG_CHECKING([which sane header to use])
9547if test "$with_system_sane" = "yes"; then
9548    AC_MSG_RESULT([external])
9549    AC_CHECK_HEADER(sane/sane.h, [],
9550      [AC_MSG_ERROR(sane not found. install sane)], [])
9551else
9552    AC_MSG_RESULT([internal])
9553    BUILD_TYPE="$BUILD_TYPE SANE"
9554fi
9555
9556dnl ===================================================================
9557dnl Check for system icu
9558dnl ===================================================================
9559SYSTEM_GENBRK=
9560SYSTEM_GENCCODE=
9561SYSTEM_GENCMN=
9562
9563ICU_MAJOR=65
9564ICU_MINOR=1
9565ICU_RECLASSIFIED_PREPEND_SET_EMPTY="TRUE"
9566ICU_RECLASSIFIED_CONDITIONAL_JAPANESE_STARTER="TRUE"
9567ICU_RECLASSIFIED_HEBREW_LETTER="TRUE"
9568AC_MSG_CHECKING([which icu to use])
9569if test "$with_system_icu" = "yes"; then
9570    AC_MSG_RESULT([external])
9571    SYSTEM_ICU=TRUE
9572    AC_LANG_PUSH([C++])
9573    AC_MSG_CHECKING([for unicode/rbbi.h])
9574    AC_PREPROC_IFELSE([AC_LANG_SOURCE([[unicode/rbbi.h]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([icu headers not found])])
9575    AC_LANG_POP([C++])
9576
9577    if test "$cross_compiling" != "yes"; then
9578        PKG_CHECK_MODULES(ICU, icu-i18n >= 4.6)
9579        ICU_VERSION=`$PKG_CONFIG --modversion icu-i18n 2>/dev/null`
9580        ICU_MAJOR=`echo $ICU_VERSION | cut -d"." -f1`
9581        ICU_MINOR=`echo $ICU_VERSION | cut -d"." -f2`
9582    fi
9583
9584    if test "$cross_compiling" = "yes" -a \( "$with_system_icu_for_build" = "yes" -o "$with_system_icu_for_build" = "force" \); then
9585        ICU_VERSION_FOR_BUILD=`$PKG_CONFIG --modversion icu-i18n 2>/dev/null`
9586        ICU_MAJOR_FOR_BUILD=`echo $ICU_VERSION_FOR_BUILD | cut -d"." -f1`
9587        ICU_MINOR_FOR_BUILD=`echo $ICU_VERSION_FOR_BUILD | cut -d"." -f2`
9588        AC_MSG_CHECKING([if MinGW and system versions of ICU are compatible])
9589        if test "$ICU_MAJOR" -eq "$ICU_MAJOR_FOR_BUILD" -a "$ICU_MINOR" -eq "$ICU_MINOR_FOR_BUILD"; then
9590            AC_MSG_RESULT([yes])
9591        else
9592            AC_MSG_RESULT([no])
9593            if test "$with_system_icu_for_build" != "force"; then
9594                AC_MSG_ERROR([System ICU is not version-compatible with MinGW ICU.
9595You can use --with-system-icu-for-build=force to use it anyway.])
9596            fi
9597        fi
9598    fi
9599
9600    if test "$cross_compiling" != "yes" -o "$with_system_icu_for_build" = "yes" -o "$with_system_icu_for_build" = "force"; then
9601        # using the system icu tools can lead to version confusion, use the
9602        # ones from the build environment when cross-compiling
9603        AC_PATH_PROG(SYSTEM_GENBRK, genbrk, [], [$PATH:/usr/sbin:/sbin])
9604        if test -z "$SYSTEM_GENBRK"; then
9605            AC_MSG_ERROR([\'genbrk\' not found in \$PATH, install the icu development tool \'genbrk\'])
9606        fi
9607        AC_PATH_PROG(SYSTEM_GENCCODE, genccode, [], [$PATH:/usr/sbin:/sbin:/usr/local/sbin])
9608        if test -z "$SYSTEM_GENCCODE"; then
9609            AC_MSG_ERROR([\'genccode\' not found in \$PATH, install the icu development tool \'genccode\'])
9610        fi
9611        AC_PATH_PROG(SYSTEM_GENCMN, gencmn, [], [$PATH:/usr/sbin:/sbin:/usr/local/sbin])
9612        if test -z "$SYSTEM_GENCMN"; then
9613            AC_MSG_ERROR([\'gencmn\' not found in \$PATH, install the icu development tool \'gencmn\'])
9614        fi
9615        if test "$ICU_MAJOR" -ge "49"; then
9616            ICU_RECLASSIFIED_PREPEND_SET_EMPTY="TRUE"
9617            ICU_RECLASSIFIED_CONDITIONAL_JAPANESE_STARTER="TRUE"
9618            ICU_RECLASSIFIED_HEBREW_LETTER="TRUE"
9619        else
9620            ICU_RECLASSIFIED_PREPEND_SET_EMPTY=
9621            ICU_RECLASSIFIED_CONDITIONAL_JAPANESE_STARTER=
9622            ICU_RECLASSIFIED_HEBREW_LETTER=
9623        fi
9624    fi
9625
9626    if test "$cross_compiling" = "yes"; then
9627        if test "$ICU_MAJOR" -ge "50"; then
9628            AC_MSG_RESULT([Ignore ICU_MINOR as obviously the libraries don't include the minor version in their names any more])
9629            ICU_MINOR=""
9630        fi
9631    fi
9632else
9633    AC_MSG_RESULT([internal])
9634    SYSTEM_ICU=
9635    BUILD_TYPE="$BUILD_TYPE ICU"
9636    # surprisingly set these only for "internal" (to be used by various other
9637    # external libs): the system icu-config is quite unhelpful and spits out
9638    # dozens of weird flags and also default path -I/usr/include
9639    ICU_CFLAGS="-I${WORKDIR}/UnpackedTarball/icu/source/i18n -I${WORKDIR}/UnpackedTarball/icu/source/common"
9640    ICU_LIBS="-L${WORKDIR}/UnpackedTarball/icu/source/lib"
9641fi
9642if test "$ICU_MAJOR" -ge "59"; then
9643    # As of ICU 59 it defaults to typedef char16_t UChar; which is available
9644    # with -std=c++11 but not all external libraries can be built with that,
9645    # for those use a bit-compatible typedef uint16_t UChar; see
9646    # icu/source/common/unicode/umachine.h
9647    ICU_UCHAR_TYPE="-DUCHAR_TYPE=uint16_t"
9648else
9649    ICU_UCHAR_TYPE=""
9650fi
9651AC_SUBST(SYSTEM_ICU)
9652AC_SUBST(SYSTEM_GENBRK)
9653AC_SUBST(SYSTEM_GENCCODE)
9654AC_SUBST(SYSTEM_GENCMN)
9655AC_SUBST(ICU_MAJOR)
9656AC_SUBST(ICU_MINOR)
9657AC_SUBST(ICU_RECLASSIFIED_PREPEND_SET_EMPTY)
9658AC_SUBST(ICU_RECLASSIFIED_CONDITIONAL_JAPANESE_STARTER)
9659AC_SUBST(ICU_RECLASSIFIED_HEBREW_LETTER)
9660AC_SUBST(ICU_CFLAGS)
9661AC_SUBST(ICU_LIBS)
9662AC_SUBST(ICU_UCHAR_TYPE)
9663
9664dnl ==================================================================
9665dnl Breakpad
9666dnl ==================================================================
9667DEFAULT_CRASHDUMP_VALUE="true"
9668AC_MSG_CHECKING([whether to enable breakpad])
9669if test "$enable_breakpad" != yes; then
9670    AC_MSG_RESULT([no])
9671else
9672    AC_MSG_RESULT([yes])
9673    ENABLE_BREAKPAD="TRUE"
9674    AC_DEFINE(ENABLE_BREAKPAD)
9675    AC_DEFINE(HAVE_FEATURE_BREAKPAD, 1)
9676    BUILD_TYPE="$BUILD_TYPE BREAKPAD"
9677
9678    AC_MSG_CHECKING([for disable crash dump])
9679    if test "$enable_crashdump" = no; then
9680        DEFAULT_CRASHDUMP_VALUE="false"
9681        AC_MSG_RESULT([yes])
9682    else
9683       AC_MSG_RESULT([no])
9684    fi
9685
9686    AC_MSG_CHECKING([for crashreport config])
9687    if test "$with_symbol_config" = "no"; then
9688        BREAKPAD_SYMBOL_CONFIG="invalid"
9689        AC_MSG_RESULT([no])
9690    else
9691        BREAKPAD_SYMBOL_CONFIG="$with_symbol_config"
9692        AC_DEFINE(BREAKPAD_SYMBOL_CONFIG)
9693        AC_MSG_RESULT([yes])
9694    fi
9695    AC_SUBST(BREAKPAD_SYMBOL_CONFIG)
9696fi
9697AC_SUBST(ENABLE_BREAKPAD)
9698AC_SUBST(DEFAULT_CRASHDUMP_VALUE)
9699
9700dnl ==================================================================
9701dnl libfuzzer
9702dnl ==================================================================
9703AC_MSG_CHECKING([whether to enable fuzzers])
9704if test "$enable_fuzzers" != yes; then
9705    AC_MSG_RESULT([no])
9706else
9707    AC_MSG_RESULT([yes])
9708    ENABLE_FUZZERS="TRUE"
9709    AC_DEFINE([ENABLE_FUZZERS],1)
9710    BUILD_TYPE="$BUILD_TYPE FUZZERS"
9711fi
9712AC_SUBST(ENABLE_FUZZERS)
9713
9714dnl ===================================================================
9715dnl Orcus
9716dnl ===================================================================
9717libo_CHECK_SYSTEM_MODULE([orcus],[ORCUS],[liborcus-0.15 >= 0.15.0])
9718if test "$with_system_orcus" != "yes"; then
9719    if test "$SYSTEM_BOOST" = "TRUE"; then
9720        # ===========================================================
9721        # Determine if we are going to need to link with Boost.System
9722        # ===========================================================
9723        dnl This seems to be necessary since boost 1.50 (1.48 does not need it,
9724        dnl 1.49 is untested). The macro BOOST_THREAD_DONT_USE_SYSTEM mentioned
9725        dnl in documentation has no effect.
9726        AC_MSG_CHECKING([if we need to link with Boost.System])
9727        AC_LANG_PUSH([C++])
9728        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
9729                @%:@include <boost/version.hpp>
9730            ]],[[
9731                #if BOOST_VERSION >= 105000
9732                #   error yes, we need to link with Boost.System
9733                #endif
9734            ]])],[
9735                AC_MSG_RESULT([no])
9736            ],[
9737                AC_MSG_RESULT([yes])
9738                AX_BOOST_SYSTEM
9739        ])
9740        AC_LANG_POP([C++])
9741    fi
9742fi
9743dnl FIXME by renaming SYSTEM_LIBORCUS to SYSTEM_ORCUS in the build system world
9744SYSTEM_LIBORCUS=$SYSTEM_ORCUS
9745AC_SUBST([BOOST_SYSTEM_LIB])
9746AC_SUBST(SYSTEM_LIBORCUS)
9747
9748dnl ===================================================================
9749dnl HarfBuzz
9750dnl ===================================================================
9751libo_CHECK_SYSTEM_MODULE([graphite],[GRAPHITE],[graphite2 >= 0.9.3],
9752                         ["-I${WORKDIR}/UnpackedTarball/graphite/include -DGRAPHITE2_STATIC"],
9753                         ["-L${WORKDIR}/LinkTarget/StaticLibrary -lgraphite"])
9754
9755libo_CHECK_SYSTEM_MODULE([harfbuzz],[HARFBUZZ],[harfbuzz-icu >= 0.9.42],
9756                         ["-I${WORKDIR}/UnpackedTarball/harfbuzz/src"],
9757                         ["-L${WORKDIR}/UnpackedTarball/harfbuzz/src/.libs -lharfbuzz"])
9758
9759if test "$COM" = "MSC"; then # override the above
9760    GRAPHITE_LIBS="${WORKDIR}/LinkTarget/StaticLibrary/graphite.lib"
9761    HARFBUZZ_LIBS="${WORKDIR}/UnpackedTarball/harfbuzz/src/.libs/libharfbuzz.lib"
9762fi
9763
9764if test "$with_system_harfbuzz" = "yes"; then
9765    if test "$with_system_graphite" = "no"; then
9766        AC_MSG_ERROR([--with-system-graphite must be used when --with-system-harfbuzz is used])
9767    fi
9768    AC_MSG_CHECKING([whether system Harfbuzz is built with Graphite support])
9769    _save_libs="$LIBS"
9770    _save_cflags="$CFLAGS"
9771    LIBS="$LIBS $HARFBUZZ_LIBS"
9772    CFLAGS="$CFLAGS $HARFBUZZ_CFLAGS"
9773    AC_CHECK_FUNC(hb_graphite2_face_get_gr_face,,[AC_MSG_ERROR([Harfbuzz needs to be built with Graphite support.])])
9774    LIBS="$_save_libs"
9775    CFLAGS="$_save_cflags"
9776else
9777    if test "$with_system_graphite" = "yes"; then
9778        AC_MSG_ERROR([--without-system-graphite must be used when --without-system-harfbuzz is used])
9779    fi
9780fi
9781
9782AC_MSG_CHECKING([whether to use X11])
9783dnl ***************************************
9784dnl testing for X libraries and includes...
9785dnl ***************************************
9786if test "$USING_X11" = TRUE; then
9787    AC_DEFINE(HAVE_FEATURE_X11)
9788fi
9789AC_MSG_RESULT([$USING_X11])
9790
9791if test "$USING_X11" = TRUE; then
9792    AC_PATH_X
9793    AC_PATH_XTRA
9794    CPPFLAGS="$CPPFLAGS $X_CFLAGS"
9795
9796    if test -z "$x_includes"; then
9797        x_includes="default_x_includes"
9798    fi
9799    if test -z "$x_libraries"; then
9800        x_libraries="default_x_libraries"
9801    fi
9802    CFLAGS="$CFLAGS $X_CFLAGS"
9803    LDFLAGS="$LDFLAGS $X_LDFLAGS $X_LIBS"
9804    AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS", [AC_MSG_ERROR([X Development libraries not found])])
9805else
9806    x_includes="no_x_includes"
9807    x_libraries="no_x_libraries"
9808fi
9809
9810if test "$USING_X11" = TRUE; then
9811    dnl ===================================================================
9812    dnl Check for extension headers
9813    dnl ===================================================================
9814    AC_CHECK_HEADERS(X11/extensions/shape.h,[],[AC_MSG_ERROR([libXext headers not found])],
9815     [#include <X11/extensions/shape.h>])
9816
9817    # vcl needs ICE and SM
9818    AC_CHECK_HEADERS(X11/ICE/ICElib.h,[],[AC_MSG_ERROR([libICE headers not found])])
9819    AC_CHECK_LIB([ICE], [IceConnectionNumber], [:],
9820        [AC_MSG_ERROR(ICE library not found)])
9821    AC_CHECK_HEADERS(X11/SM/SMlib.h,[],[AC_MSG_ERROR([libSM headers not found])])
9822    AC_CHECK_LIB([SM], [SmcOpenConnection], [:],
9823        [AC_MSG_ERROR(SM library not found)])
9824fi
9825
9826dnl ===================================================================
9827dnl Check for system Xrender
9828dnl ===================================================================
9829AC_MSG_CHECKING([whether to use Xrender])
9830if test "$USING_X11" = TRUE -a  "$test_xrender" = "yes"; then
9831    AC_MSG_RESULT([yes])
9832    PKG_CHECK_MODULES(XRENDER, xrender)
9833    XRENDER_CFLAGS=$(printf '%s' "$XRENDER_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
9834    FilterLibs "${XRENDER_LIBS}"
9835    XRENDER_LIBS="${filteredlibs}"
9836    AC_CHECK_LIB([Xrender], [XRenderQueryVersion], [:],
9837      [AC_MSG_ERROR(libXrender not found or functional)], [])
9838    AC_CHECK_HEADER(X11/extensions/Xrender.h, [],
9839      [AC_MSG_ERROR(Xrender not found. install X)], [])
9840else
9841    AC_MSG_RESULT([no])
9842fi
9843AC_SUBST(XRENDER_CFLAGS)
9844AC_SUBST(XRENDER_LIBS)
9845
9846dnl ===================================================================
9847dnl Check for XRandr
9848dnl ===================================================================
9849AC_MSG_CHECKING([whether to enable RandR support])
9850if test "$USING_X11" = TRUE -a "$test_randr" = "yes" -a \( "$enable_randr" = "yes" -o "$enable_randr" = "TRUE" \); then
9851    AC_MSG_RESULT([yes])
9852    PKG_CHECK_MODULES(XRANDR, xrandr >= 1.2, ENABLE_RANDR="TRUE", ENABLE_RANDR="")
9853    if test "$ENABLE_RANDR" != "TRUE"; then
9854        AC_CHECK_HEADER(X11/extensions/Xrandr.h, [],
9855                    [AC_MSG_ERROR([X11/extensions/Xrandr.h could not be found. X11 dev missing?])], [])
9856        XRANDR_CFLAGS=" "
9857        AC_CHECK_LIB([Xrandr], [XRRQueryExtension], [:],
9858          [ AC_MSG_ERROR(libXrandr not found or functional) ], [])
9859        XRANDR_LIBS="-lXrandr "
9860        ENABLE_RANDR="TRUE"
9861    fi
9862    XRANDR_CFLAGS=$(printf '%s' "$XRANDR_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
9863    FilterLibs "${XRANDR_LIBS}"
9864    XRANDR_LIBS="${filteredlibs}"
9865else
9866    ENABLE_RANDR=""
9867    AC_MSG_RESULT([no])
9868fi
9869AC_SUBST(XRANDR_CFLAGS)
9870AC_SUBST(XRANDR_LIBS)
9871AC_SUBST(ENABLE_RANDR)
9872
9873if test "$enable_neon" = "no" -o "$enable_mpl_subset" = "yes"; then
9874    WITH_WEBDAV="serf"
9875fi
9876if test $_os = iOS -o $_os = Android; then
9877    WITH_WEBDAV="no"
9878fi
9879AC_MSG_CHECKING([for webdav library])
9880case "$WITH_WEBDAV" in
9881serf)
9882    AC_MSG_RESULT([serf])
9883    # Check for system apr-util
9884    libo_CHECK_SYSTEM_MODULE([apr],[APR],[apr-util-1],
9885                             ["-I${WORKDIR}/UnpackedTarball/apr/include -I${WORKDIR}/UnpackedTarball/apr_util/include"],
9886                             ["-L${WORKDIR}/UnpackedTarball/apr/.libs -lapr-1 -L${WORKDIR}/UnpackedTarball/apr_util/.libs -laprutil-1"])
9887    if test "$COM" = "MSC"; then
9888        APR_LIB_DIR="LibR"
9889        test -n "${MSVC_USE_DEBUG_RUNTIME}" && APR_LIB_DIR="LibD"
9890        APR_LIBS="${WORKDIR}/UnpackedTarball/apr/${APR_LIB_DIR}/apr-1.lib ${WORKDIR}/UnpackedTarball/apr_util/${APR_LIB_DIR}/aprutil-1.lib"
9891    fi
9892
9893    # Check for system serf
9894    libo_CHECK_SYSTEM_MODULE([serf],[SERF],[serf-1 >= 1.1.0],["-I${WORKDIR}/UnpackedTarball/serf"],
9895                             ["-L${WORKDIR}/UnpackedTarball/serf/.libs -lserf-1"])
9896    if test "$COM" = "MSC"; then
9897        SERF_LIB_DIR="Release"
9898        test -n "${MSVC_USE_DEBUG_RUNTIME}" && SERF_LIB_DIR="Debug"
9899        SERF_LIBS="${WORKDIR}/UnpackedTarball/serf/${SERF_LIB_DIR}/serf-1.lib"
9900    fi
9901    ;;
9902neon)
9903    AC_MSG_RESULT([neon])
9904    # Check for system neon
9905    libo_CHECK_SYSTEM_MODULE([neon],[NEON],[neon >= 0.26.0])
9906    if test "$with_system_neon" = "yes"; then
9907        NEON_VERSION="`$PKG_CONFIG --modversion neon | $SED 's/\.//g'`"
9908    else
9909        NEON_VERSION=0295
9910    fi
9911    AC_SUBST(NEON_VERSION)
9912    ;;
9913*)
9914    AC_MSG_RESULT([none, disabled])
9915    WITH_WEBDAV=""
9916    ;;
9917esac
9918AC_SUBST(WITH_WEBDAV)
9919
9920dnl ===================================================================
9921dnl Check for disabling cve_tests
9922dnl ===================================================================
9923AC_MSG_CHECKING([whether to execute CVE tests])
9924# If not explicitly enabled or disabled, default
9925if test -z "$enable_cve_tests"; then
9926    case "$OS" in
9927    WNT)
9928        # Default cves off for Windows with its wild and wonderful
9929        # variety of AV software kicking in and panicking
9930        enable_cve_tests=no
9931        ;;
9932    *)
9933        # otherwise yes
9934        enable_cve_tests=yes
9935        ;;
9936    esac
9937fi
9938if test "$enable_cve_tests" = "no"; then
9939    AC_MSG_RESULT([no])
9940    DISABLE_CVE_TESTS=TRUE
9941    AC_SUBST(DISABLE_CVE_TESTS)
9942else
9943    AC_MSG_RESULT([yes])
9944fi
9945
9946dnl ===================================================================
9947dnl Check for enabling chart XShape tests
9948dnl ===================================================================
9949AC_MSG_CHECKING([whether to execute chart XShape tests])
9950if test "$enable_chart_tests" = "yes" -o '(' "$_os" = "WINNT" -a "$enable_chart_tests" != "no" ')'; then
9951    AC_MSG_RESULT([yes])
9952    ENABLE_CHART_TESTS=TRUE
9953    AC_SUBST(ENABLE_CHART_TESTS)
9954else
9955    AC_MSG_RESULT([no])
9956fi
9957
9958dnl ===================================================================
9959dnl Check for system openssl
9960dnl ===================================================================
9961DISABLE_OPENSSL=
9962AC_MSG_CHECKING([whether to disable OpenSSL usage])
9963if test "$enable_openssl" = "yes"; then
9964    AC_MSG_RESULT([no])
9965    if test "$_os" = Darwin ; then
9966        # OpenSSL is deprecated when building for 10.7 or later.
9967        #
9968        # http://stackoverflow.com/questions/7406946/why-is-apple-deprecating-openssl-in-macos-10-7-lion
9969        # http://stackoverflow.com/questions/7475914/libcrypto-deprecated-on-mac-os-x-10-7-lion
9970
9971        with_system_openssl=no
9972        libo_CHECK_SYSTEM_MODULE([openssl],[OPENSSL],[openssl])
9973    elif test "$_os" = "NetBSD" -o "$_os" = "OpenBSD" -o "$_os" = "DragonFly" \
9974            && test "$with_system_openssl" != "no"; then
9975        with_system_openssl=yes
9976        SYSTEM_OPENSSL=TRUE
9977        OPENSSL_CFLAGS=
9978        OPENSSL_LIBS="-lssl -lcrypto"
9979    else
9980        libo_CHECK_SYSTEM_MODULE([openssl],[OPENSSL],[openssl])
9981    fi
9982    if test "$with_system_openssl" = "yes"; then
9983        AC_MSG_CHECKING([whether openssl supports SHA512])
9984        AC_LANG_PUSH([C])
9985        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <openssl/sha.h>]],[[
9986            SHA512_CTX context;
9987]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no, openssl too old. Need >= 0.9.8.])])
9988        AC_LANG_POP(C)
9989    fi
9990else
9991    AC_MSG_RESULT([yes])
9992    DISABLE_OPENSSL=TRUE
9993
9994    # warn that although OpenSSL is disabled, system libraries may depend on it
9995    AC_MSG_WARN([OpenSSL has been disabled. No code compiled here will make use of it but system libraries may create indirect dependencies])
9996    add_warning "OpenSSL has been disabled. No code compiled here will make use of it but system libraries may create indirect dependencies"
9997fi
9998
9999AC_SUBST([DISABLE_OPENSSL])
10000
10001if test "$enable_cipher_openssl_backend" = yes && test "$DISABLE_OPENSSL" = TRUE; then
10002    if test "$libo_fuzzed_enable_cipher_openssl_backend" = yes; then
10003        AC_MSG_NOTICE([Resetting --enable-cipher-openssl-backend=no])
10004        enable_cipher_openssl_backend=no
10005    else
10006        AC_MSG_ERROR([--enable-cipher-openssl-backend needs OpenSSL, but --disable-openssl was given.])
10007    fi
10008fi
10009AC_MSG_CHECKING([whether to enable the OpenSSL backend for rtl/cipher.h])
10010ENABLE_CIPHER_OPENSSL_BACKEND=
10011if test "$enable_cipher_openssl_backend" = yes; then
10012    AC_MSG_RESULT([yes])
10013    ENABLE_CIPHER_OPENSSL_BACKEND=TRUE
10014else
10015    AC_MSG_RESULT([no])
10016fi
10017AC_SUBST([ENABLE_CIPHER_OPENSSL_BACKEND])
10018
10019dnl ===================================================================
10020dnl Check for building gnutls
10021dnl ===================================================================
10022AC_MSG_CHECKING([whether to use gnutls])
10023if test "$WITH_WEBDAV" = "neon" -a "$with_system_neon" = no -a "$enable_openssl" = "no"; then
10024    AC_MSG_RESULT([yes])
10025    AM_PATH_LIBGCRYPT()
10026    PKG_CHECK_MODULES(GNUTLS, [gnutls],,
10027        AC_MSG_ERROR([[Disabling OpenSSL was requested, but GNUTLS is not
10028                      available in the system to use as replacement.]]))
10029    FilterLibs "${LIBGCRYPT_LIBS}"
10030    LIBGCRYPT_LIBS="${filteredlibs}"
10031else
10032    AC_MSG_RESULT([no])
10033fi
10034
10035AC_SUBST([LIBGCRYPT_CFLAGS])
10036AC_SUBST([LIBGCRYPT_LIBS])
10037
10038dnl ===================================================================
10039dnl Check for system redland
10040dnl ===================================================================
10041dnl redland: versions before 1.0.8 write RDF/XML that is useless for ODF (@xml:base)
10042dnl raptor2: need at least 2.0.7 for CVE-2012-0037
10043libo_CHECK_SYSTEM_MODULE([redland],[REDLAND],[redland >= 1.0.8 raptor2 >= 2.0.7])
10044if test "$with_system_redland" = "yes"; then
10045    AC_CHECK_LIB([rdf], [librdf_world_set_raptor_init_handler], [:],
10046            [AC_MSG_ERROR(librdf too old. Need >= 1.0.16)], [])
10047else
10048    RAPTOR_MAJOR="0"
10049    RASQAL_MAJOR="3"
10050    REDLAND_MAJOR="0"
10051fi
10052AC_SUBST(RAPTOR_MAJOR)
10053AC_SUBST(RASQAL_MAJOR)
10054AC_SUBST(REDLAND_MAJOR)
10055
10056dnl ===================================================================
10057dnl Check for system hunspell
10058dnl ===================================================================
10059AC_MSG_CHECKING([which libhunspell to use])
10060if test "$with_system_hunspell" = "yes"; then
10061    AC_MSG_RESULT([external])
10062    SYSTEM_HUNSPELL=TRUE
10063    AC_LANG_PUSH([C++])
10064    PKG_CHECK_MODULES(HUNSPELL, hunspell, HUNSPELL_PC="TRUE", HUNSPELL_PC="" )
10065    if test "$HUNSPELL_PC" != "TRUE"; then
10066        AC_CHECK_HEADER(hunspell.hxx, [],
10067            [
10068            AC_CHECK_HEADER(hunspell/hunspell.hxx, [ HUNSPELL_CFLAGS=-I/usr/include/hunspell ],
10069            [AC_MSG_ERROR(hunspell headers not found.)], [])
10070            ], [])
10071        AC_CHECK_LIB([hunspell], [main], [:],
10072           [ AC_MSG_ERROR(hunspell library not found.) ], [])
10073        HUNSPELL_LIBS=-lhunspell
10074    fi
10075    AC_LANG_POP([C++])
10076    HUNSPELL_CFLAGS=$(printf '%s' "$HUNSPELL_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10077    FilterLibs "${HUNSPELL_LIBS}"
10078    HUNSPELL_LIBS="${filteredlibs}"
10079else
10080    AC_MSG_RESULT([internal])
10081    SYSTEM_HUNSPELL=
10082    HUNSPELL_CFLAGS="-I${WORKDIR}/UnpackedTarball/hunspell/src/hunspell"
10083    if test "$COM" = "MSC"; then
10084        HUNSPELL_LIBS="${WORKDIR}/LinkTarget/StaticLibrary/hunspell.lib"
10085    else
10086        HUNSPELL_LIBS="-L${WORKDIR}/UnpackedTarball/hunspell/src/hunspell/.libs -lhunspell-1.7"
10087    fi
10088    BUILD_TYPE="$BUILD_TYPE HUNSPELL"
10089fi
10090AC_SUBST(SYSTEM_HUNSPELL)
10091AC_SUBST(HUNSPELL_CFLAGS)
10092AC_SUBST(HUNSPELL_LIBS)
10093
10094dnl ===================================================================
10095dnl Check for system qrcodegen
10096dnl ===================================================================
10097AC_MSG_CHECKING([whether to use libqrcodegen])
10098if test "$enable_qrcodegen" = "no"; then
10099    AC_MSG_RESULT([no])
10100    ENABLE_QRCODEGEN=
10101    SYSTEM_QRCODEGEN=
10102else
10103    AC_MSG_RESULT([yes])
10104    ENABLE_QRCODEGEN=TRUE
10105    AC_MSG_CHECKING([which libqrcodegen to use])
10106    if test "$with_system_qrcodegen" = "yes"; then
10107        AC_MSG_RESULT([external])
10108        SYSTEM_QRCODEGEN=TRUE
10109        AC_LANG_PUSH([C++])
10110        AC_CHECK_HEADER(qrcodegen/QrCode.hpp, [],
10111            [AC_MSG_ERROR(qrcodegen headers not found.)], [#include <stdexcept>])
10112        AC_CHECK_LIB([qrcodegencpp], [main], [:],
10113            [ AC_MSG_ERROR(qrcodegen C++ library not found.) ], [])
10114        QRCODEGEN_LIBS=-lqrcodegencpp
10115        AC_LANG_POP([C++])
10116        QRCODEGEN_CFLAGS=$(printf '%s' "$QRCODEGEN_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10117        FilterLibs "${QRCODEGEN_LIBS}"
10118        QRCODEGEN_LIBS="${filteredlibs}"
10119    else
10120        AC_MSG_RESULT([internal])
10121        SYSTEM_QRCODEGEN=
10122        BUILD_TYPE="$BUILD_TYPE QRCODEGEN"
10123    fi
10124    if test "$ENABLE_QRCODEGEN" = TRUE; then
10125        AC_DEFINE(ENABLE_QRCODEGEN)
10126    fi
10127fi
10128AC_SUBST(SYSTEM_QRCODEGEN)
10129AC_SUBST(ENABLE_QRCODEGEN)
10130AC_SUBST(QRCODEGEN_CFLAGS)
10131AC_SUBST(QRCODEGEN_LIBS)
10132
10133dnl ===================================================================
10134dnl Checking for altlinuxhyph
10135dnl ===================================================================
10136AC_MSG_CHECKING([which altlinuxhyph to use])
10137if test "$with_system_altlinuxhyph" = "yes"; then
10138    AC_MSG_RESULT([external])
10139    SYSTEM_HYPH=TRUE
10140    AC_CHECK_HEADER(hyphen.h, [],
10141       [ AC_MSG_ERROR(altlinuxhyph headers not found.)], [])
10142    AC_CHECK_MEMBER(struct _HyphenDict.cset, [],
10143       [ AC_MSG_ERROR(no. You are sure you have altlinuyhyph headers?)],
10144       [#include <hyphen.h>])
10145    AC_CHECK_LIB(hyphen, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhyphen],
10146        [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
10147    if test -z "$HYPHEN_LIB"; then
10148        AC_CHECK_LIB(hyph, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhyph],
10149           [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
10150    fi
10151    if test -z "$HYPHEN_LIB"; then
10152        AC_CHECK_LIB(hnj, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhnj],
10153           [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
10154    fi
10155else
10156    AC_MSG_RESULT([internal])
10157    SYSTEM_HYPH=
10158    BUILD_TYPE="$BUILD_TYPE HYPHEN"
10159    if test "$COM" = "MSC"; then
10160        HYPHEN_LIB="${WORKDIR}/LinkTarget/StaticLibrary/hyphen.lib"
10161    else
10162        HYPHEN_LIB="-L${WORKDIR}/UnpackedTarball/hyphen/.libs -lhyphen"
10163    fi
10164fi
10165AC_SUBST(SYSTEM_HYPH)
10166AC_SUBST(HYPHEN_LIB)
10167
10168dnl ===================================================================
10169dnl Checking for mythes
10170dnl ===================================================================
10171AC_MSG_CHECKING([which mythes to use])
10172if test "$with_system_mythes" = "yes"; then
10173    AC_MSG_RESULT([external])
10174    SYSTEM_MYTHES=TRUE
10175    AC_LANG_PUSH([C++])
10176    PKG_CHECK_MODULES(MYTHES, mythes, MYTHES_PKGCONFIG=yes, MYTHES_PKGCONFIG=no)
10177    if test "$MYTHES_PKGCONFIG" = "no"; then
10178        AC_CHECK_HEADER(mythes.hxx, [],
10179            [ AC_MSG_ERROR(mythes.hxx headers not found.)], [])
10180        AC_CHECK_LIB([mythes-1.2], [main], [:],
10181            [ MYTHES_FOUND=no], [])
10182    if test "$MYTHES_FOUND" = "no"; then
10183        AC_CHECK_LIB(mythes, main, [MYTHES_FOUND=yes],
10184                [ MYTHES_FOUND=no], [])
10185    fi
10186    if test "$MYTHES_FOUND" = "no"; then
10187        AC_MSG_ERROR([mythes library not found!.])
10188    fi
10189    fi
10190    AC_LANG_POP([C++])
10191    MYTHES_CFLAGS=$(printf '%s' "$MYTHES_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10192    FilterLibs "${MYTHES_LIBS}"
10193    MYTHES_LIBS="${filteredlibs}"
10194else
10195    AC_MSG_RESULT([internal])
10196    SYSTEM_MYTHES=
10197    BUILD_TYPE="$BUILD_TYPE MYTHES"
10198    if test "$COM" = "MSC"; then
10199        MYTHES_LIBS="${WORKDIR}/LinkTarget/StaticLibrary/mythes.lib"
10200    else
10201        MYTHES_LIBS="-L${WORKDIR}/UnpackedTarball/mythes/.libs -lmythes-1.2"
10202    fi
10203fi
10204AC_SUBST(SYSTEM_MYTHES)
10205AC_SUBST(MYTHES_CFLAGS)
10206AC_SUBST(MYTHES_LIBS)
10207
10208dnl ===================================================================
10209dnl How should we build the linear programming solver ?
10210dnl ===================================================================
10211
10212ENABLE_COINMP=
10213AC_MSG_CHECKING([whether to build with CoinMP])
10214if test "$enable_coinmp" != "no"; then
10215    ENABLE_COINMP=TRUE
10216    AC_MSG_RESULT([yes])
10217    if test "$with_system_coinmp" = "yes"; then
10218        SYSTEM_COINMP=TRUE
10219        PKG_CHECK_MODULES(COINMP, coinmp coinutils)
10220        FilterLibs "${COINMP_LIBS}"
10221        COINMP_LIBS="${filteredlibs}"
10222    else
10223        BUILD_TYPE="$BUILD_TYPE COINMP"
10224    fi
10225else
10226    AC_MSG_RESULT([no])
10227fi
10228AC_SUBST(ENABLE_COINMP)
10229AC_SUBST(SYSTEM_COINMP)
10230AC_SUBST(COINMP_CFLAGS)
10231AC_SUBST(COINMP_LIBS)
10232
10233ENABLE_LPSOLVE=
10234AC_MSG_CHECKING([whether to build with lpsolve])
10235if test "$enable_lpsolve" != "no"; then
10236    ENABLE_LPSOLVE=TRUE
10237    AC_MSG_RESULT([yes])
10238else
10239    AC_MSG_RESULT([no])
10240fi
10241AC_SUBST(ENABLE_LPSOLVE)
10242
10243if test "$ENABLE_LPSOLVE" = TRUE; then
10244    AC_MSG_CHECKING([which lpsolve to use])
10245    if test "$with_system_lpsolve" = "yes"; then
10246        AC_MSG_RESULT([external])
10247        SYSTEM_LPSOLVE=TRUE
10248        AC_CHECK_HEADER(lpsolve/lp_lib.h, [],
10249           [ AC_MSG_ERROR(lpsolve headers not found.)], [])
10250        save_LIBS=$LIBS
10251        # some systems need this. Like Ubuntu...
10252        AC_CHECK_LIB(m, floor)
10253        AC_CHECK_LIB(dl, dlopen)
10254        AC_CHECK_LIB([lpsolve55], [make_lp], [:],
10255            [ AC_MSG_ERROR(lpsolve library not found or too old.)], [])
10256        LIBS=$save_LIBS
10257    else
10258        AC_MSG_RESULT([internal])
10259        SYSTEM_LPSOLVE=
10260        BUILD_TYPE="$BUILD_TYPE LPSOLVE"
10261    fi
10262fi
10263AC_SUBST(SYSTEM_LPSOLVE)
10264
10265dnl ===================================================================
10266dnl Checking for libexttextcat
10267dnl ===================================================================
10268libo_CHECK_SYSTEM_MODULE([libexttextcat],[LIBEXTTEXTCAT],[libexttextcat >= 3.4.1])
10269if test "$with_system_libexttextcat" = "yes"; then
10270    SYSTEM_LIBEXTTEXTCAT_DATA=file://`$PKG_CONFIG --variable=pkgdatadir libexttextcat`
10271fi
10272AC_SUBST(SYSTEM_LIBEXTTEXTCAT_DATA)
10273
10274dnl ===================================================================
10275dnl Checking for libnumbertext
10276dnl ===================================================================
10277AC_MSG_CHECKING([whether to use libnumbertext])
10278if test "$enable_libnumbertext" = "no"; then
10279    AC_MSG_RESULT([no])
10280    ENABLE_LIBNUMBERTEXT=
10281    SYSTEM_LIBNUMBERTEXT=
10282else
10283    AC_MSG_RESULT([yes])
10284    ENABLE_LIBNUMBERTEXT=TRUE
10285    libo_CHECK_SYSTEM_MODULE([libnumbertext],[LIBNUMBERTEXT],[libnumbertext >= 1.0.0])
10286    if test "$with_system_libnumbertext" = "yes"; then
10287        SYSTEM_LIBNUMBERTEXT_DATA=file://`$PKG_CONFIG --variable=pkgdatadir libnumbertext`
10288        SYSTEM_LIBNUMBERTEXT=YES
10289    else
10290        SYSTEM_LIBNUMBERTEXT=
10291        AC_LANG_PUSH([C++])
10292        save_CPPFLAGS=$CPPFLAGS
10293        CPPFLAGS="$CPPFLAGS $CXXFLAGS_CXX11"
10294        AC_CHECK_HEADERS([codecvt regex])
10295        AS_IF([test "x$ac_cv_header_codecvt" != xyes -o "x$ac_cv_header_regex" != xyes],
10296                [ ENABLE_LIBNUMBERTEXT=''
10297                  LIBNUMBERTEXT_CFLAGS=''
10298                  AC_MSG_WARN([No system-provided libnumbertext or codecvt/regex C++11 headers (min. libstdc++ 4.9).
10299                               Enable libnumbertext fallback (missing number to number name conversion).])
10300                ])
10301        CPPFLAGS=$save_CPPFLAGS
10302        AC_LANG_POP([C++])
10303    fi
10304    if test "$ENABLE_LIBNUMBERTEXT" = TRUE; then
10305        AC_DEFINE(ENABLE_LIBNUMBERTEXT)
10306    fi
10307fi
10308AC_SUBST(SYSTEM_LIBNUMBERTEXT)
10309AC_SUBST(SYSTEM_LIBNUMBERTEXT_DATA)
10310AC_SUBST(ENABLE_LIBNUMBERTEXT)
10311AC_SUBST(LIBNUMBERTEXT_CFLAGS)
10312
10313dnl ***************************************
10314dnl testing libc version for Linux...
10315dnl ***************************************
10316if test "$_os" = "Linux"; then
10317    AC_MSG_CHECKING([whether libc is >= 2.1.1])
10318    exec 6>/dev/null # no output
10319    AC_CHECK_LIB(c, gnu_get_libc_version, HAVE_LIBC=yes; export HAVE_LIBC)
10320    exec 6>&1 # output on again
10321    if test "$HAVE_LIBC"; then
10322        AC_MSG_RESULT([yes])
10323    else
10324        AC_MSG_ERROR([no, upgrade libc])
10325    fi
10326fi
10327
10328dnl =========================================
10329dnl Check for uuidgen
10330dnl =========================================
10331if test "$_os" = "WINNT" -a "$cross_compiling" != "yes"; then
10332    # presence is already tested above in the WINDOWS_SDK_HOME check
10333    UUIDGEN=uuidgen.exe
10334    AC_SUBST(UUIDGEN)
10335else
10336    AC_PATH_PROG([UUIDGEN], [uuidgen])
10337    if test -z "$UUIDGEN"; then
10338        AC_MSG_WARN([uuid is needed for building installation sets])
10339    fi
10340fi
10341
10342dnl ***************************************
10343dnl Checking for bison and flex
10344dnl ***************************************
10345AC_PATH_PROG(BISON, bison)
10346if test -z "$BISON"; then
10347    AC_MSG_ERROR([no bison found in \$PATH, install it])
10348else
10349    AC_MSG_CHECKING([the bison version])
10350    _bison_version=`$BISON --version | grep GNU | $SED -e 's@^[[^0-9]]*@@' -e 's@ .*@@' -e 's@,.*@@'`
10351    _bison_longver=`echo $_bison_version | $AWK -F. '{ print \$1*1000+\$2}'`
10352    # Accept newer than 2.0
10353    if test "$_bison_longver" -lt 2000; then
10354        AC_MSG_ERROR([failed ($BISON $_bison_version need 2.0+)])
10355    fi
10356fi
10357
10358AC_PATH_PROG(FLEX, flex)
10359if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
10360    FLEX=`cygpath -m $FLEX`
10361fi
10362if test -z "$FLEX"; then
10363    AC_MSG_ERROR([no flex found in \$PATH, install it])
10364else
10365    AC_MSG_CHECKING([the flex version])
10366    _flex_version=$($FLEX --version | $SED -e 's/^.*\([[[:digit:]]]\{1,\}\.[[[:digit:]]]\{1,\}\.[[[:digit:]]]\{1,\}\).*$/\1/')
10367    if test $(echo $_flex_version | $AWK -F. '{printf("%d%03d%03d", $1, $2, $3)}') -lt 2006000; then
10368        AC_MSG_ERROR([failed ($FLEX $_flex_version found, but need at least 2.6.0)])
10369    fi
10370fi
10371AC_SUBST([FLEX])
10372dnl ***************************************
10373dnl Checking for patch
10374dnl ***************************************
10375AC_PATH_PROG(PATCH, patch)
10376if test -z "$PATCH"; then
10377    AC_MSG_ERROR(["patch" not found in \$PATH, install it])
10378fi
10379
10380dnl On Solaris, FreeBSD or macOS, check if --with-gnu-patch was used
10381if test "$_os" = "SunOS" -o "$_os" = "FreeBSD" -o "$_os" = "Darwin"; then
10382    if test -z "$with_gnu_patch"; then
10383        GNUPATCH=$PATCH
10384    else
10385        if test -x "$with_gnu_patch"; then
10386            GNUPATCH=$with_gnu_patch
10387        else
10388            AC_MSG_ERROR([--with-gnu-patch did not point to an executable])
10389        fi
10390    fi
10391
10392    AC_MSG_CHECKING([whether $GNUPATCH is GNU patch])
10393    if $GNUPATCH --version | grep "Free Software Foundation" >/dev/null 2>/dev/null; then
10394        AC_MSG_RESULT([yes])
10395    else
10396        AC_MSG_ERROR([no, GNU patch needed. install or specify with --with-gnu-patch=/path/to/it])
10397    fi
10398else
10399    GNUPATCH=$PATCH
10400fi
10401
10402if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
10403    GNUPATCH=`cygpath -m $GNUPATCH`
10404fi
10405
10406dnl We also need to check for --with-gnu-cp
10407
10408if test -z "$with_gnu_cp"; then
10409    # check the place where the good stuff is hidden on Solaris...
10410    if test -x /usr/gnu/bin/cp; then
10411        GNUCP=/usr/gnu/bin/cp
10412    else
10413        AC_PATH_PROGS(GNUCP, gnucp cp)
10414    fi
10415    if test -z $GNUCP; then
10416        AC_MSG_ERROR([Neither gnucp nor cp found. Install GNU cp and/or specify --with-gnu-cp=/path/to/it])
10417    fi
10418else
10419    if test -x "$with_gnu_cp"; then
10420        GNUCP=$with_gnu_cp
10421    else
10422        AC_MSG_ERROR([--with-gnu-cp did not point to an executable])
10423    fi
10424fi
10425
10426if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
10427    GNUCP=`cygpath -m $GNUCP`
10428fi
10429
10430AC_MSG_CHECKING([whether $GNUCP is GNU cp from coreutils with preserve= support])
10431if $GNUCP --version 2>/dev/null | grep "coreutils" >/dev/null 2>/dev/null; then
10432    AC_MSG_RESULT([yes])
10433elif $GNUCP --version 2>/dev/null | grep "GNU fileutils" >/dev/null 2>/dev/null; then
10434    AC_MSG_RESULT([yes])
10435else
10436    case "$build_os" in
10437    darwin*|netbsd*|openbsd*|freebsd*|dragonfly*|aix*)
10438        x_GNUCP=[\#]
10439        GNUCP=''
10440        AC_MSG_RESULT([no gnucp found - using the system's cp command])
10441        ;;
10442    *)
10443        AC_MSG_ERROR([no, GNU cp needed. install or specify with --with-gnu-cp=/path/to/it])
10444        ;;
10445    esac
10446fi
10447
10448AC_SUBST(GNUPATCH)
10449AC_SUBST(GNUCP)
10450AC_SUBST(x_GNUCP)
10451
10452dnl ***************************************
10453dnl testing assembler path
10454dnl ***************************************
10455ML_EXE=""
10456if test "$_os" = "WINNT"; then
10457    if test "$BITNESS_OVERRIDE" = ""; then
10458        assembler=ml.exe
10459    else
10460        assembler=ml64.exe
10461    fi
10462
10463    AC_MSG_CHECKING([for the MSVC assembler ($assembler)])
10464    if test -f "$CL_PATH/$assembler"; then
10465        ML_EXE=`win_short_path_for_make "$CL_PATH/$assembler"`
10466        AC_MSG_RESULT([$ML_EXE])
10467    else
10468        AC_MSG_ERROR([not found])
10469    fi
10470fi
10471
10472AC_SUBST(ML_EXE)
10473
10474dnl ===================================================================
10475dnl We need zip and unzip
10476dnl ===================================================================
10477AC_PATH_PROG(ZIP, zip)
10478test -z "$ZIP" && AC_MSG_ERROR([zip is required])
10479if ! "$ZIP" --filesync < /dev/null 2>/dev/null > /dev/null; then
10480    AC_MSG_ERROR([Zip version 3.0 or newer is required to build, please install it and make sure it is the one found first in PATH],,)
10481fi
10482
10483AC_PATH_PROG(UNZIP, unzip)
10484test -z "$UNZIP" && AC_MSG_ERROR([unzip is required])
10485
10486dnl ===================================================================
10487dnl Zip must be a specific type for different build types.
10488dnl ===================================================================
10489if test $build_os = cygwin; then
10490    if test -n "`$ZIP -h | $GREP -i WinNT`"; then
10491        AC_MSG_ERROR([$ZIP is not the required Cygwin version of Info-ZIP's zip.exe.])
10492    fi
10493fi
10494
10495dnl ===================================================================
10496dnl We need touch with -h option support.
10497dnl ===================================================================
10498AC_PATH_PROG(TOUCH, touch)
10499test -z "$TOUCH" && AC_MSG_ERROR([touch is required])
10500touch warn
10501if ! "$TOUCH" -h warn 2>/dev/null > /dev/null; then
10502    AC_MSG_ERROR([touch version with -h option support is required to build, please install it and make sure it is the one found first in PATH],,)
10503fi
10504
10505dnl ===================================================================
10506dnl Check for system epoxy
10507dnl ===================================================================
10508libo_CHECK_SYSTEM_MODULE([epoxy], [EPOXY], [epoxy >= 1.2], ["-I${WORKDIR}/UnpackedTarball/epoxy/include"])
10509
10510dnl ===================================================================
10511dnl Set vcl option: coordinate device in double or sal_Int32
10512dnl ===================================================================
10513
10514dnl disabled for now, we don't want subtle differences between OSs
10515dnl AC_MSG_CHECKING([Type to use for Device Pixel coordinates])
10516dnl if test "$_os" = "Darwin" -o  $_os = iOS ; then
10517dnl     AC_DEFINE(VCL_FLOAT_DEVICE_PIXEL)
10518dnl     AC_MSG_RESULT([double])
10519dnl else
10520dnl     AC_MSG_RESULT([sal_Int32])
10521dnl fi
10522
10523dnl ===================================================================
10524dnl Test which vclplugs have to be built.
10525dnl ===================================================================
10526R=""
10527if test "$USING_X11" != TRUE; then
10528    enable_gtk3=no
10529fi
10530GTK3_CFLAGS=""
10531GTK3_LIBS=""
10532ENABLE_GTK3=""
10533if test "x$enable_gtk3" = "xyes"; then
10534    if test "$with_system_cairo" = no; then
10535        AC_MSG_ERROR([System cairo required for gtk3 support, do not combine --enable-gtk3 with --without-system-cairo])
10536    fi
10537    : ${with_system_cairo:=yes}
10538    PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.18 gtk+-unix-print-3.0 gmodule-no-export-2.0 glib-2.0 >= 2.38 cairo, ENABLE_GTK3="TRUE", ENABLE_GTK3="")
10539    if test "x$ENABLE_GTK3" = "xTRUE"; then
10540        AC_DEFINE(ENABLE_GTK3)
10541        R="gtk3"
10542    else
10543        AC_MSG_ERROR([gtk3 or dependent libraries of the correct versions, not found])
10544    fi
10545    GTK3_CFLAGS=$(printf '%s' "$GTK3_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10546    FilterLibs "${GTK3_LIBS}"
10547    GTK3_LIBS="${filteredlibs}"
10548
10549    dnl We require egl only for the gtk3 plugin. Otherwise we use glx.
10550    if test "$with_system_epoxy" != "yes"; then
10551        AC_CHECK_LIB(EGL, eglMakeCurrent, [:], AC_MSG_ERROR([libEGL required.]))
10552        AC_CHECK_HEADER(EGL/eglplatform.h, [],
10553                        [AC_MSG_ERROR(EGL headers not found. install mesa-libEGL-devel)], [])
10554    fi
10555fi
10556AC_SUBST(GTK3_LIBS)
10557AC_SUBST(GTK3_CFLAGS)
10558AC_SUBST(ENABLE_GTK3)
10559
10560if test "$enable_introspection" = yes; then
10561    if test "$ENABLE_GTK3" = TRUE; then
10562        GOBJECT_INTROSPECTION_REQUIRE(INTROSPECTION_REQUIRED_VERSION)
10563    else
10564        AC_MSG_ERROR([--enable-introspection requires --enable-gtk3])
10565    fi
10566fi
10567
10568ENABLE_QT5=""
10569if test "x$enable_qt5" = "xyes"; then
10570    ENABLE_QT5="TRUE"
10571    AC_DEFINE(ENABLE_QT5)
10572    R="$R qt5"
10573fi
10574AC_SUBST(ENABLE_QT5)
10575
10576ENABLE_KF5=""
10577if test "x$enable_kf5" = "xyes"; then
10578    ENABLE_KF5="TRUE"
10579    AC_DEFINE(ENABLE_KF5)
10580    R="$R kf5"
10581fi
10582AC_SUBST(ENABLE_KF5)
10583
10584ENABLE_GTK3_KDE5=""
10585if test "x$enable_gtk3_kde5" = "xyes"; then
10586    ENABLE_GTK3_KDE5="TRUE"
10587    AC_DEFINE(ENABLE_GTK3_KDE5)
10588    R="$R gtk3_kde5"
10589fi
10590AC_SUBST(ENABLE_GTK3_KDE5)
10591
10592if test "$_os" = "WINNT"; then
10593    R="$R win"
10594elif test "$_os" = "Darwin"; then
10595    R="$R osx"
10596elif test "$_os" = "iOS"; then
10597    R="ios (builtin)"
10598fi
10599
10600build_vcl_plugins="$R"
10601if test -z "$build_vcl_plugins"; then
10602    build_vcl_plugins="none"
10603fi
10604AC_MSG_NOTICE([VCLplugs to be built: $build_vcl_plugins])
10605
10606dnl ===================================================================
10607dnl check for dbus support
10608dnl ===================================================================
10609ENABLE_DBUS=""
10610DBUS_CFLAGS=""
10611DBUS_LIBS=""
10612DBUS_GLIB_CFLAGS=""
10613DBUS_GLIB_LIBS=""
10614DBUS_HAVE_GLIB=""
10615
10616if test "$enable_dbus" = "no"; then
10617    test_dbus=no
10618fi
10619
10620AC_MSG_CHECKING([whether to enable DBUS support])
10621if test "$test_dbus" = "yes"; then
10622    ENABLE_DBUS="TRUE"
10623    AC_MSG_RESULT([yes])
10624    PKG_CHECK_MODULES(DBUS, dbus-1 >= 0.60)
10625    AC_DEFINE(ENABLE_DBUS)
10626    DBUS_CFLAGS=$(printf '%s' "$DBUS_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10627    FilterLibs "${DBUS_LIBS}"
10628    DBUS_LIBS="${filteredlibs}"
10629
10630    # Glib is needed for BluetoothServer
10631    # Sets also DBUS_GLIB_CFLAGS/DBUS_GLIB_LIBS if successful.
10632    PKG_CHECK_MODULES(DBUS_GLIB,[glib-2.0 >= 2.4],
10633        [
10634            DBUS_HAVE_GLIB="TRUE"
10635            AC_DEFINE(DBUS_HAVE_GLIB,1)
10636        ],
10637        AC_MSG_WARN([[No Glib found, Bluetooth support will be disabled]])
10638    )
10639else
10640    AC_MSG_RESULT([no])
10641fi
10642
10643AC_SUBST(ENABLE_DBUS)
10644AC_SUBST(DBUS_CFLAGS)
10645AC_SUBST(DBUS_LIBS)
10646AC_SUBST(DBUS_GLIB_CFLAGS)
10647AC_SUBST(DBUS_GLIB_LIBS)
10648AC_SUBST(DBUS_HAVE_GLIB)
10649
10650AC_MSG_CHECKING([whether to enable Impress remote control])
10651if test -n "$enable_sdremote" -a "$enable_sdremote" != "no"; then
10652    AC_MSG_RESULT([yes])
10653    ENABLE_SDREMOTE=TRUE
10654    AC_MSG_CHECKING([whether to enable Bluetooth support in Impress remote control])
10655
10656    if test $OS = MACOSX && test "$MAC_OS_X_VERSION_MAX_ALLOWED" -ge 101500; then
10657        # The Bluetooth code doesn't compile with macOS SDK 10.15
10658        enable_sdremote_bluetooth=no
10659    fi
10660    # If not explicitly enabled or disabled, default
10661    if test -z "$enable_sdremote_bluetooth"; then
10662        case "$OS" in
10663        LINUX|MACOSX|WNT)
10664            # Default to yes for these
10665            enable_sdremote_bluetooth=yes
10666            ;;
10667        *)
10668            # otherwise no
10669            enable_sdremote_bluetooth=no
10670            ;;
10671        esac
10672    fi
10673    # $enable_sdremote_bluetooth is guaranteed non-empty now
10674
10675    if test "$enable_sdremote_bluetooth" != "no"; then
10676        if test "$OS" = "LINUX"; then
10677            if test "$ENABLE_DBUS" = "TRUE" -a "$DBUS_HAVE_GLIB" = "TRUE"; then
10678                AC_MSG_RESULT([yes])
10679                ENABLE_SDREMOTE_BLUETOOTH=TRUE
10680                dnl ===================================================================
10681                dnl Check for system bluez
10682                dnl ===================================================================
10683                AC_MSG_CHECKING([which Bluetooth header to use])
10684                if test "$with_system_bluez" = "yes"; then
10685                    AC_MSG_RESULT([external])
10686                    AC_CHECK_HEADER(bluetooth/bluetooth.h, [],
10687                        [AC_MSG_ERROR(bluetooth.h not found. install bluez)], [])
10688                    SYSTEM_BLUEZ=TRUE
10689                else
10690                    AC_MSG_RESULT([internal])
10691                    SYSTEM_BLUEZ=
10692                fi
10693            else
10694                AC_MSG_RESULT([no, dbus disabled])
10695                ENABLE_SDREMOTE_BLUETOOTH=
10696                SYSTEM_BLUEZ=
10697            fi
10698        else
10699            AC_MSG_RESULT([yes])
10700            ENABLE_SDREMOTE_BLUETOOTH=TRUE
10701            SYSTEM_BLUEZ=
10702        fi
10703    else
10704        AC_MSG_RESULT([no])
10705        ENABLE_SDREMOTE_BLUETOOTH=
10706        SYSTEM_BLUEZ=
10707    fi
10708else
10709    ENABLE_SDREMOTE=
10710    SYSTEM_BLUEZ=
10711    AC_MSG_RESULT([no])
10712fi
10713AC_SUBST(ENABLE_SDREMOTE)
10714AC_SUBST(ENABLE_SDREMOTE_BLUETOOTH)
10715AC_SUBST(SYSTEM_BLUEZ)
10716
10717dnl ===================================================================
10718dnl Check whether to enable GIO support
10719dnl ===================================================================
10720if test "$ENABLE_GTK3" = "TRUE"; then
10721    AC_MSG_CHECKING([whether to enable GIO support])
10722    if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_gio" = "yes"; then
10723        dnl Need at least 2.26 for the dbus support.
10724        PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.26],
10725                          [ENABLE_GIO="TRUE"], [ENABLE_GIO=""])
10726        if test "$ENABLE_GIO" = "TRUE"; then
10727            AC_DEFINE(ENABLE_GIO)
10728            GIO_CFLAGS=$(printf '%s' "$GIO_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10729            FilterLibs "${GIO_LIBS}"
10730            GIO_LIBS="${filteredlibs}"
10731        fi
10732    else
10733        AC_MSG_RESULT([no])
10734    fi
10735fi
10736AC_SUBST(ENABLE_GIO)
10737AC_SUBST(GIO_CFLAGS)
10738AC_SUBST(GIO_LIBS)
10739
10740
10741dnl ===================================================================
10742
10743SPLIT_APP_MODULES=""
10744if test "$enable_split_app_modules" = "yes"; then
10745    SPLIT_APP_MODULES="TRUE"
10746fi
10747AC_SUBST(SPLIT_APP_MODULES)
10748
10749SPLIT_OPT_FEATURES=""
10750if test "$enable_split_opt_features" = "yes"; then
10751    SPLIT_OPT_FEATURES="TRUE"
10752fi
10753AC_SUBST(SPLIT_OPT_FEATURES)
10754
10755if test $_os = Darwin -o $_os = WINNT -o $_os = iOS; then
10756    if test "$enable_cairo_canvas" = yes; then
10757        AC_MSG_ERROR([The cairo canvas should not be used for this platform])
10758    fi
10759    enable_cairo_canvas=no
10760elif test -z "$enable_cairo_canvas"; then
10761    enable_cairo_canvas=yes
10762fi
10763
10764ENABLE_CAIRO_CANVAS=""
10765if test "$enable_cairo_canvas" = "yes"; then
10766    test_cairo=yes
10767    ENABLE_CAIRO_CANVAS="TRUE"
10768    AC_DEFINE(ENABLE_CAIRO_CANVAS)
10769fi
10770AC_SUBST(ENABLE_CAIRO_CANVAS)
10771
10772dnl ===================================================================
10773dnl Check whether the GStreamer libraries are available.
10774dnl ===================================================================
10775
10776ENABLE_GSTREAMER_1_0=""
10777
10778if test "$build_gstreamer_1_0" = "yes"; then
10779
10780    AC_MSG_CHECKING([whether to enable the GStreamer 1.0 avmedia backend])
10781    if test "$enable_avmedia" = yes -a "$enable_gstreamer_1_0" != no; then
10782        ENABLE_GSTREAMER_1_0="TRUE"
10783        AC_MSG_RESULT([yes])
10784        PKG_CHECK_MODULES( [GSTREAMER_1_0], [gstreamer-1.0 gstreamer-plugins-base-1.0 gstreamer-pbutils-1.0 gstreamer-video-1.0] )
10785        GSTREAMER_1_0_CFLAGS=$(printf '%s' "$GSTREAMER_1_0_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10786        FilterLibs "${GSTREAMER_1_0_LIBS}"
10787        GSTREAMER_1_0_LIBS="${filteredlibs}"
10788        AC_DEFINE(ENABLE_GSTREAMER_1_0)
10789    else
10790        AC_MSG_RESULT([no])
10791    fi
10792fi
10793AC_SUBST(GSTREAMER_1_0_CFLAGS)
10794AC_SUBST(GSTREAMER_1_0_LIBS)
10795AC_SUBST(ENABLE_GSTREAMER_1_0)
10796
10797dnl ===================================================================
10798dnl Check whether to build the VLC avmedia backend
10799dnl ===================================================================
10800
10801ENABLE_VLC=""
10802
10803AC_MSG_CHECKING([whether to enable the VLC avmedia backend])
10804if test "$enable_avmedia" = yes -a $_os != iOS -a $_os != Android -a "$enable_vlc" = yes; then
10805    ENABLE_VLC="TRUE"
10806    AC_MSG_RESULT([yes])
10807else
10808    AC_MSG_RESULT([no])
10809fi
10810AC_SUBST(ENABLE_VLC)
10811
10812ENABLE_OPENGL_TRANSITIONS=
10813ENABLE_OPENGL_CANVAS=
10814if test $_os = iOS -o $_os = Android -o "$ENABLE_FUZZERS" = "TRUE"; then
10815   : # disable
10816elif test "$_os" = "Darwin"; then
10817    # We use frameworks on macOS, no need for detail checks
10818    ENABLE_OPENGL_TRANSITIONS=TRUE
10819    AC_DEFINE(HAVE_FEATURE_OPENGL,1)
10820    ENABLE_OPENGL_CANVAS=TRUE
10821elif test $_os = WINNT; then
10822    ENABLE_OPENGL_TRANSITIONS=TRUE
10823    AC_DEFINE(HAVE_FEATURE_OPENGL,1)
10824    ENABLE_OPENGL_CANVAS=TRUE
10825else
10826    if test "$USING_X11" = TRUE; then
10827        AC_CHECK_LIB(GL, glBegin, [:], AC_MSG_ERROR([libGL required.]))
10828        ENABLE_OPENGL_TRANSITIONS=TRUE
10829        AC_DEFINE(HAVE_FEATURE_OPENGL,1)
10830        ENABLE_OPENGL_CANVAS=TRUE
10831    fi
10832fi
10833
10834AC_SUBST(ENABLE_OPENGL_TRANSITIONS)
10835AC_SUBST(ENABLE_OPENGL_CANVAS)
10836
10837dnl =================================================
10838dnl Check whether to build with OpenCL support.
10839dnl =================================================
10840
10841if test $_os != iOS -a $_os != Android -a "$ENABLE_FUZZERS" != "TRUE"; then
10842    # OPENCL in BUILD_TYPE and HAVE_FEATURE_OPENCL tell that OpenCL is potentially available on the
10843    # platform (optional at run-time, used through clew).
10844    BUILD_TYPE="$BUILD_TYPE OPENCL"
10845    AC_DEFINE(HAVE_FEATURE_OPENCL)
10846fi
10847
10848dnl =================================================
10849dnl Check whether to build with dconf support.
10850dnl =================================================
10851
10852if test $_os != Android -a $_os != iOS -a "$enable_dconf" != no; then
10853    PKG_CHECK_MODULES([DCONF], [dconf >= 0.15.2], [], [
10854        if test "$enable_dconf" = yes; then
10855            AC_MSG_ERROR([dconf not found])
10856        else
10857            enable_dconf=no
10858        fi])
10859fi
10860AC_MSG_CHECKING([whether to enable dconf])
10861if test $_os = Android -o $_os = iOS -o "$enable_dconf" = no; then
10862    DCONF_CFLAGS=
10863    DCONF_LIBS=
10864    ENABLE_DCONF=
10865    AC_MSG_RESULT([no])
10866else
10867    ENABLE_DCONF=TRUE
10868    AC_DEFINE(ENABLE_DCONF)
10869    AC_MSG_RESULT([yes])
10870fi
10871AC_SUBST([DCONF_CFLAGS])
10872AC_SUBST([DCONF_LIBS])
10873AC_SUBST([ENABLE_DCONF])
10874
10875# pdf import?
10876AC_MSG_CHECKING([whether to build the PDF import feature])
10877ENABLE_PDFIMPORT=
10878if test $_os != Android -a $_os != iOS -a \( -z "$enable_pdfimport" -o "$enable_pdfimport" = yes \); then
10879    AC_MSG_RESULT([yes])
10880    ENABLE_PDFIMPORT=TRUE
10881    AC_DEFINE(HAVE_FEATURE_PDFIMPORT)
10882else
10883    AC_MSG_RESULT([no])
10884fi
10885
10886# Pdfium?
10887AC_MSG_CHECKING([whether to build PDFium])
10888ENABLE_PDFIUM=
10889if test \( -z "$enable_pdfium" -a "$ENABLE_PDFIMPORT" = "TRUE" \) -o "$enable_pdfium" = yes; then
10890    AC_MSG_RESULT([yes])
10891    ENABLE_PDFIUM=TRUE
10892    AC_DEFINE(HAVE_FEATURE_PDFIUM)
10893    BUILD_TYPE="$BUILD_TYPE PDFIUM"
10894else
10895    AC_MSG_RESULT([no])
10896fi
10897AC_SUBST(ENABLE_PDFIUM)
10898
10899dnl ===================================================================
10900dnl Check for poppler
10901dnl ===================================================================
10902ENABLE_POPPLER=
10903AC_MSG_CHECKING([whether to build Poppler])
10904if test \( -z "$enable_poppler" -a "$ENABLE_PDFIMPORT" = "TRUE" \) -o "$enable_poppler" = yes; then
10905    AC_MSG_RESULT([yes])
10906    ENABLE_POPPLER=TRUE
10907    AC_DEFINE(HAVE_FEATURE_POPPLER)
10908else
10909    AC_MSG_RESULT([no])
10910fi
10911AC_SUBST(ENABLE_POPPLER)
10912
10913if test "$ENABLE_PDFIMPORT" = "TRUE" -a "$ENABLE_POPPLER" != "TRUE" -a "$ENABLE_PDFIUM" != "TRUE"; then
10914    AC_MSG_ERROR([Cannot import PDF without either Pdfium or Poppler; please enable either of them.])
10915fi
10916
10917if test "$ENABLE_PDFIMPORT" != "TRUE" -a \( "$ENABLE_POPPLER" = "TRUE" -o "$ENABLE_PDFIUM" = "TRUE" \); then
10918    AC_MSG_ERROR([Cannot enable Pdfium or Poppler when PDF importing is disabled; please enable PDF import first.])
10919fi
10920
10921if test "$ENABLE_PDFIMPORT" = "TRUE" -a "$ENABLE_POPPLER" = "TRUE"; then
10922    dnl ===================================================================
10923    dnl Check for system poppler
10924    dnl ===================================================================
10925    AC_MSG_CHECKING([which PDF import poppler to use])
10926    if test "$with_system_poppler" = "yes"; then
10927        AC_MSG_RESULT([external])
10928        SYSTEM_POPPLER=TRUE
10929        PKG_CHECK_MODULES( POPPLER, poppler >= 0.12.0 )
10930        AC_LANG_PUSH([C++])
10931        save_CXXFLAGS=$CXXFLAGS
10932        save_CPPFLAGS=$CPPFLAGS
10933        CXXFLAGS="$CXXFLAGS $POPPLER_CFLAGS"
10934        CPPFLAGS="$CPPFLAGS $POPPLER_CFLAGS"
10935        AC_CHECK_HEADER([cpp/poppler-version.h],
10936            [AC_DEFINE([HAVE_POPPLER_VERSION_H], 1)],
10937            [])
10938        CXXFLAGS=$save_CXXFLAGS
10939        CPPFLAGS=$save_CPPFLAGS
10940        AC_LANG_POP([C++])
10941        POPPLER_CFLAGS=$(printf '%s' "$POPPLER_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10942
10943        FilterLibs "${POPPLER_LIBS}"
10944        POPPLER_LIBS="${filteredlibs}"
10945    else
10946        AC_MSG_RESULT([internal])
10947        SYSTEM_POPPLER=
10948        BUILD_TYPE="$BUILD_TYPE POPPLER"
10949        AC_DEFINE([HAVE_POPPLER_VERSION_H], 1)
10950    fi
10951    AC_DEFINE([ENABLE_PDFIMPORT],1)
10952fi
10953AC_SUBST(ENABLE_PDFIMPORT)
10954AC_SUBST(SYSTEM_POPPLER)
10955AC_SUBST(POPPLER_CFLAGS)
10956AC_SUBST(POPPLER_LIBS)
10957
10958SYSTEM_GPGMEPP=
10959
10960if test "$build_for_ios" = "YES"; then
10961    AC_MSG_CHECKING([whether gpgmepp should be disabled due to iOS])
10962    AC_MSG_RESULT([yes])
10963elif test "$enable_mpl_subset" = "yes"; then
10964    AC_MSG_CHECKING([whether gpgmepp should be disabled due to building just MPL])
10965    AC_MSG_RESULT([yes])
10966elif test "$enable_fuzzers" = "yes"; then
10967    AC_MSG_CHECKING([whether gpgmepp should be disabled due to oss-fuzz])
10968    AC_MSG_RESULT([yes])
10969elif test "$_os" = "Linux" -o "$_os" = "Darwin" -o "$_os" = "WINNT" ; then
10970    dnl ===================================================================
10971    dnl Check for system gpgme
10972    dnl ===================================================================
10973    AC_MSG_CHECKING([which gpgmepp to use])
10974    if test "$with_system_gpgmepp" = "yes"; then
10975        AC_MSG_RESULT([external])
10976        SYSTEM_GPGMEPP=TRUE
10977
10978        # C++ library doesn't come with fancy gpgmepp-config, check for headers the old-fashioned way
10979        AC_CHECK_HEADER(gpgme++/gpgmepp_version.h, [ GPGMEPP_CFLAGS=-I/usr/include/gpgme++ ],
10980            [AC_MSG_ERROR([gpgmepp headers not found, install gpgmepp development package])], [])
10981        # progress_callback is the only func with plain C linkage
10982        # checking for it also filters out older, KDE-dependent libgpgmepp versions
10983        AC_CHECK_LIB(gpgmepp, progress_callback, [ GPGMEPP_LIBS=-lgpgmepp ],
10984            [AC_MSG_ERROR(gpgmepp not found or not functional)], [])
10985        AC_CHECK_HEADER(gpgme.h, [],
10986            [AC_MSG_ERROR([gpgme headers not found, install gpgme development package])], [])
10987    else
10988        AC_MSG_RESULT([internal])
10989        BUILD_TYPE="$BUILD_TYPE LIBGPGERROR LIBASSUAN GPGMEPP"
10990        AC_DEFINE([GPGME_CAN_EXPORT_MINIMAL_KEY])
10991
10992        GPG_ERROR_CFLAGS="-I${WORKDIR}/UnpackedTarball/libgpg-error/src"
10993        LIBASSUAN_CFLAGS="-I${WORKDIR}/UnpackedTarball/libassuan/src"
10994        if test "$_os" != "WINNT"; then
10995            GPG_ERROR_LIBS="-L${WORKDIR}/UnpackedTarball/libgpg-error/src/.libs -lgpg-error"
10996            LIBASSUAN_LIBS="-L${WORKDIR}/UnpackedTarball/libassuan/src/.libs -lassuan"
10997        elif test "$host_cpu" = "i686" -a "$WINDOWS_SDK_ARCH" = "x64"; then
10998            AC_MSG_ERROR(gpgme cannot be built on cygwin32 for Win64.)
10999        fi
11000    fi
11001    ENABLE_GPGMEPP=TRUE
11002    AC_DEFINE([HAVE_FEATURE_GPGME])
11003    AC_PATH_PROG(GPG, gpg)
11004    # TODO: Windows's cygwin gpg does not seem to work with our gpgme,
11005    # so let's exclude that manually for the moment
11006    if test -n "$GPG" -a "$_os" != "WINNT"; then
11007        # make sure we not only have a working gpgme, but a full working
11008        # gpg installation to run OpenPGP signature verification
11009        AC_DEFINE([HAVE_FEATURE_GPGVERIFY])
11010    fi
11011    if test "$_os" = "Linux"; then
11012      uid=`id -u`
11013      AC_MSG_CHECKING([for /run/user/$uid])
11014      if test -d /run/user/$uid; then
11015        AC_MSG_RESULT([yes])
11016        AC_PATH_PROG(GPGCONF, gpgconf)
11017
11018        # Older versions of gpgconf are not working as expected, since
11019        # `gpgconf --remove-socketdir` fails to exit any gpg-agent daemon operating
11020        # on that socket dir that has (indirectly) been started by the tests in xmlsecurity/qa/unit/signing/signing.cxx
11021        # (see commit message of f0305ec0a7d199e605511844d9d6af98b66d4bfd%5E )
11022        AC_MSG_CHECKING([whether version of gpgconf is suitable ... ])
11023        GPGCONF_VERSION=`"$GPGCONF" --version | "$AWK" '/^gpgconf \(GnuPG\)/{print $3}'`
11024        GPGCONF_NUMVER=`echo $GPGCONF_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
11025        if test "$GPGCONF_VERSION" = "2.2_OOo" -o "$GPGCONF_NUMVER" -ge "020200"; then
11026          AC_MSG_RESULT([yes, $GPGCONF_VERSION])
11027          AC_MSG_CHECKING([for gpgconf --create-socketdir... ])
11028          if $GPGCONF --dump-options > /dev/null ; then
11029            if $GPGCONF --dump-options | grep -q create-socketdir ; then
11030              AC_MSG_RESULT([yes])
11031              AC_DEFINE([HAVE_GPGCONF_SOCKETDIR])
11032              AC_DEFINE_UNQUOTED([GPGME_GPGCONF], ["$GPGCONF"])
11033            else
11034              AC_MSG_RESULT([no])
11035            fi
11036          else
11037            AC_MSG_RESULT([no. missing or broken gpgconf?])
11038          fi
11039        else
11040          AC_MSG_RESULT([no, $GPGCONF_VERSION])
11041        fi
11042      else
11043        AC_MSG_RESULT([no])
11044     fi
11045   fi
11046fi
11047AC_SUBST(ENABLE_GPGMEPP)
11048AC_SUBST(SYSTEM_GPGMEPP)
11049AC_SUBST(GPG_ERROR_CFLAGS)
11050AC_SUBST(GPG_ERROR_LIBS)
11051AC_SUBST(LIBASSUAN_CFLAGS)
11052AC_SUBST(LIBASSUAN_LIBS)
11053AC_SUBST(GPGMEPP_CFLAGS)
11054AC_SUBST(GPGMEPP_LIBS)
11055
11056AC_MSG_CHECKING([whether to build the Wiki Publisher extension])
11057if test "x$enable_ext_wiki_publisher" = "xyes" -a "x$enable_extension_integration" != "xno" -a "$with_java" != "no"; then
11058    AC_MSG_RESULT([yes])
11059    ENABLE_MEDIAWIKI=TRUE
11060    BUILD_TYPE="$BUILD_TYPE XSLTML"
11061    if test  "x$with_java" = "xno"; then
11062        AC_MSG_ERROR([Wiki Publisher requires Java! Enable Java if you want to build it.])
11063    fi
11064else
11065    AC_MSG_RESULT([no])
11066    ENABLE_MEDIAWIKI=
11067    SCPDEFS="$SCPDEFS -DWITHOUT_EXTENSION_MEDIAWIKI"
11068fi
11069AC_SUBST(ENABLE_MEDIAWIKI)
11070
11071AC_MSG_CHECKING([whether to build the Report Builder])
11072if test "$enable_report_builder" != "no" -a "$with_java" != "no"; then
11073    AC_MSG_RESULT([yes])
11074    ENABLE_REPORTBUILDER=TRUE
11075    AC_MSG_CHECKING([which jfreereport libs to use])
11076    if test "$with_system_jfreereport" = "yes"; then
11077        SYSTEM_JFREEREPORT=TRUE
11078        AC_MSG_RESULT([external])
11079        if test -z $SAC_JAR; then
11080            SAC_JAR=/usr/share/java/sac.jar
11081        fi
11082        if ! test -f $SAC_JAR; then
11083             AC_MSG_ERROR(sac.jar not found.)
11084        fi
11085
11086        if test -z $LIBXML_JAR; then
11087            if test -f /usr/share/java/libxml-1.0.0.jar; then
11088                LIBXML_JAR=/usr/share/java/libxml-1.0.0.jar
11089            elif test -f /usr/share/java/libxml.jar; then
11090                LIBXML_JAR=/usr/share/java/libxml.jar
11091            else
11092                AC_MSG_ERROR(libxml.jar replacement not found.)
11093            fi
11094        elif ! test -f $LIBXML_JAR; then
11095            AC_MSG_ERROR(libxml.jar not found.)
11096        fi
11097
11098        if test -z $FLUTE_JAR; then
11099            if test -f/usr/share/java/flute-1.3.0.jar; then
11100                FLUTE_JAR=/usr/share/java/flute-1.3.0.jar
11101            elif test -f /usr/share/java/flute.jar; then
11102                FLUTE_JAR=/usr/share/java/flute.jar
11103            else
11104                AC_MSG_ERROR(flute-1.3.0.jar replacement not found.)
11105            fi
11106        elif ! test -f $FLUTE_JAR; then
11107            AC_MSG_ERROR(flute-1.3.0.jar not found.)
11108        fi
11109
11110        if test -z $JFREEREPORT_JAR; then
11111            if test -f /usr/share/java/flow-engine-0.9.2.jar; then
11112                JFREEREPORT_JAR=/usr/share/java/flow-engine-0.9.2.jar
11113            elif test -f /usr/share/java/flow-engine.jar; then
11114                JFREEREPORT_JAR=/usr/share/java/flow-engine.jar
11115            else
11116                AC_MSG_ERROR(jfreereport.jar replacement not found.)
11117            fi
11118        elif ! test -f  $JFREEREPORT_JAR; then
11119                AC_MSG_ERROR(jfreereport.jar not found.)
11120        fi
11121
11122        if test -z $LIBLAYOUT_JAR; then
11123            if test -f /usr/share/java/liblayout-0.2.9.jar; then
11124                LIBLAYOUT_JAR=/usr/share/java/liblayout-0.2.9.jar
11125            elif test -f /usr/share/java/liblayout.jar; then
11126                LIBLAYOUT_JAR=/usr/share/java/liblayout.jar
11127            else
11128                AC_MSG_ERROR(liblayout.jar replacement not found.)
11129            fi
11130        elif ! test -f $LIBLAYOUT_JAR; then
11131                AC_MSG_ERROR(liblayout.jar not found.)
11132        fi
11133
11134        if test -z $LIBLOADER_JAR; then
11135            if test -f /usr/share/java/libloader-1.0.0.jar; then
11136                LIBLOADER_JAR=/usr/share/java/libloader-1.0.0.jar
11137            elif test -f /usr/share/java/libloader.jar; then
11138                LIBLOADER_JAR=/usr/share/java/libloader.jar
11139            else
11140                AC_MSG_ERROR(libloader.jar replacement not found.)
11141            fi
11142        elif ! test -f  $LIBLOADER_JAR; then
11143            AC_MSG_ERROR(libloader.jar not found.)
11144        fi
11145
11146        if test -z $LIBFORMULA_JAR; then
11147            if test -f /usr/share/java/libformula-0.2.0.jar; then
11148                LIBFORMULA_JAR=/usr/share/java/libformula-0.2.0.jar
11149            elif test -f /usr/share/java/libformula.jar; then
11150                LIBFORMULA_JAR=/usr/share/java/libformula.jar
11151            else
11152                AC_MSG_ERROR(libformula.jar replacement not found.)
11153            fi
11154        elif ! test -f $LIBFORMULA_JAR; then
11155                AC_MSG_ERROR(libformula.jar not found.)
11156        fi
11157
11158        if test -z $LIBREPOSITORY_JAR; then
11159            if test -f /usr/share/java/librepository-1.0.0.jar; then
11160                LIBREPOSITORY_JAR=/usr/share/java/librepository-1.0.0.jar
11161            elif test -f /usr/share/java/librepository.jar; then
11162                LIBREPOSITORY_JAR=/usr/share/java/librepository.jar
11163            else
11164                AC_MSG_ERROR(librepository.jar replacement not found.)
11165            fi
11166        elif ! test -f $LIBREPOSITORY_JAR; then
11167            AC_MSG_ERROR(librepository.jar not found.)
11168        fi
11169
11170        if test -z $LIBFONTS_JAR; then
11171            if test -f /usr/share/java/libfonts-1.0.0.jar; then
11172                LIBFONTS_JAR=/usr/share/java/libfonts-1.0.0.jar
11173            elif test -f /usr/share/java/libfonts.jar; then
11174                LIBFONTS_JAR=/usr/share/java/libfonts.jar
11175            else
11176                AC_MSG_ERROR(libfonts.jar replacement not found.)
11177            fi
11178        elif ! test -f $LIBFONTS_JAR; then
11179                AC_MSG_ERROR(libfonts.jar not found.)
11180        fi
11181
11182        if test -z $LIBSERIALIZER_JAR; then
11183            if test -f /usr/share/java/libserializer-1.0.0.jar; then
11184                LIBSERIALIZER_JAR=/usr/share/java/libserializer-1.0.0.jar
11185            elif test -f /usr/share/java/libserializer.jar; then
11186                LIBSERIALIZER_JAR=/usr/share/java/libserializer.jar
11187            else
11188                AC_MSG_ERROR(libserializer.jar replacement not found.)
11189            fi
11190        elif ! test -f $LIBSERIALIZER_JAR; then
11191                AC_MSG_ERROR(libserializer.jar not found.)
11192        fi
11193
11194        if test -z $LIBBASE_JAR; then
11195            if test -f /usr/share/java/libbase-1.0.0.jar; then
11196                LIBBASE_JAR=/usr/share/java/libbase-1.0.0.jar
11197            elif test -f /usr/share/java/libbase.jar; then
11198                LIBBASE_JAR=/usr/share/java/libbase.jar
11199            else
11200                AC_MSG_ERROR(libbase.jar replacement not found.)
11201            fi
11202        elif ! test -f $LIBBASE_JAR; then
11203            AC_MSG_ERROR(libbase.jar not found.)
11204        fi
11205
11206    else
11207        AC_MSG_RESULT([internal])
11208        SYSTEM_JFREEREPORT=
11209        BUILD_TYPE="$BUILD_TYPE JFREEREPORT"
11210        NEED_ANT=TRUE
11211    fi
11212else
11213    AC_MSG_RESULT([no])
11214    ENABLE_REPORTBUILDER=
11215    SYSTEM_JFREEREPORT=
11216fi
11217AC_SUBST(ENABLE_REPORTBUILDER)
11218AC_SUBST(SYSTEM_JFREEREPORT)
11219AC_SUBST(SAC_JAR)
11220AC_SUBST(LIBXML_JAR)
11221AC_SUBST(FLUTE_JAR)
11222AC_SUBST(JFREEREPORT_JAR)
11223AC_SUBST(LIBBASE_JAR)
11224AC_SUBST(LIBLAYOUT_JAR)
11225AC_SUBST(LIBLOADER_JAR)
11226AC_SUBST(LIBFORMULA_JAR)
11227AC_SUBST(LIBREPOSITORY_JAR)
11228AC_SUBST(LIBFONTS_JAR)
11229AC_SUBST(LIBSERIALIZER_JAR)
11230
11231# this has to be here because both the Wiki Publisher and the SRB use
11232# commons-logging
11233COMMONS_LOGGING_VERSION=1.2
11234if test "$ENABLE_REPORTBUILDER" = "TRUE"; then
11235    AC_MSG_CHECKING([which Apache commons-* libs to use])
11236    if test "$with_system_apache_commons" = "yes"; then
11237        SYSTEM_APACHE_COMMONS=TRUE
11238        AC_MSG_RESULT([external])
11239        if test -z $COMMONS_LOGGING_JAR; then
11240            if test -f /usr/share/java/commons-logging-${COMMONS_LOGGING_VERSION}.jar; then
11241               COMMONS_LOGGING_JAR=/usr/share/java/commons-logging-${COMMONS_LOGGING_VERSION}.jar
11242           elif test -f /usr/share/java/commons-logging.jar; then
11243                COMMONS_LOGGING_JAR=/usr/share/java/commons-logging.jar
11244            else
11245                AC_MSG_ERROR(commons-logging.jar replacement not found.)
11246            fi
11247        elif ! test -f $COMMONS_LOGGING_JAR; then
11248            AC_MSG_ERROR(commons-logging.jar not found.)
11249        fi
11250    else
11251        AC_MSG_RESULT([internal])
11252        SYSTEM_APACHE_COMMONS=
11253        BUILD_TYPE="$BUILD_TYPE APACHE_COMMONS"
11254        NEED_ANT=TRUE
11255    fi
11256fi
11257AC_SUBST(SYSTEM_APACHE_COMMONS)
11258AC_SUBST(COMMONS_LOGGING_JAR)
11259AC_SUBST(COMMONS_LOGGING_VERSION)
11260
11261# scripting provider for BeanShell?
11262AC_MSG_CHECKING([whether to build support for scripts in BeanShell])
11263if test "${enable_scripting_beanshell}" != "no" -a "x$with_java" != "xno"; then
11264    AC_MSG_RESULT([yes])
11265    ENABLE_SCRIPTING_BEANSHELL=TRUE
11266
11267    dnl ===================================================================
11268    dnl Check for system beanshell
11269    dnl ===================================================================
11270    AC_MSG_CHECKING([which beanshell to use])
11271    if test "$with_system_beanshell" = "yes"; then
11272        AC_MSG_RESULT([external])
11273        SYSTEM_BSH=TRUE
11274        if test -z $BSH_JAR; then
11275            BSH_JAR=/usr/share/java/bsh.jar
11276        fi
11277        if ! test -f $BSH_JAR; then
11278            AC_MSG_ERROR(bsh.jar not found.)
11279        fi
11280    else
11281        AC_MSG_RESULT([internal])
11282        SYSTEM_BSH=
11283        BUILD_TYPE="$BUILD_TYPE BSH"
11284    fi
11285else
11286    AC_MSG_RESULT([no])
11287    ENABLE_SCRIPTING_BEANSHELL=
11288    SCPDEFS="$SCPDEFS -DWITHOUT_SCRIPTING_BEANSHELL"
11289fi
11290AC_SUBST(ENABLE_SCRIPTING_BEANSHELL)
11291AC_SUBST(SYSTEM_BSH)
11292AC_SUBST(BSH_JAR)
11293
11294# scripting provider for JavaScript?
11295AC_MSG_CHECKING([whether to build support for scripts in JavaScript])
11296if test "${enable_scripting_javascript}" != "no" -a "x$with_java" != "xno"; then
11297    AC_MSG_RESULT([yes])
11298    ENABLE_SCRIPTING_JAVASCRIPT=TRUE
11299
11300    dnl ===================================================================
11301    dnl Check for system rhino
11302    dnl ===================================================================
11303    AC_MSG_CHECKING([which rhino to use])
11304    if test "$with_system_rhino" = "yes"; then
11305        AC_MSG_RESULT([external])
11306        SYSTEM_RHINO=TRUE
11307        if test -z $RHINO_JAR; then
11308            RHINO_JAR=/usr/share/java/js.jar
11309        fi
11310        if ! test -f $RHINO_JAR; then
11311            AC_MSG_ERROR(js.jar not found.)
11312        fi
11313    else
11314        AC_MSG_RESULT([internal])
11315        SYSTEM_RHINO=
11316        BUILD_TYPE="$BUILD_TYPE RHINO"
11317        NEED_ANT=TRUE
11318    fi
11319else
11320    AC_MSG_RESULT([no])
11321    ENABLE_SCRIPTING_JAVASCRIPT=
11322    SCPDEFS="$SCPDEFS -DWITHOUT_SCRIPTING_JAVASCRIPT"
11323fi
11324AC_SUBST(ENABLE_SCRIPTING_JAVASCRIPT)
11325AC_SUBST(SYSTEM_RHINO)
11326AC_SUBST(RHINO_JAR)
11327
11328# This is only used in Qt5/KF5 checks to determine if /usr/lib64
11329# paths should be added to library search path. So lets put all 64-bit
11330# platforms there.
11331supports_multilib=
11332case "$host_cpu" in
11333x86_64 | powerpc64 | powerpc64le | s390x | aarch64 | mips64 | mips64el)
11334    if test "$SAL_TYPES_SIZEOFLONG" = "8"; then
11335        supports_multilib="yes"
11336    fi
11337    ;;
11338*)
11339    ;;
11340esac
11341
11342dnl ===================================================================
11343dnl QT5 Integration
11344dnl ===================================================================
11345
11346QT5_CFLAGS=""
11347QT5_LIBS=""
11348QMAKE5="qmake"
11349MOC5="moc"
11350QT5_GOBJECT_CFLAGS=""
11351QT5_GOBJECT_LIBS=""
11352QT5_HAVE_GOBJECT=""
11353if test \( "$test_kf5" = "yes" -a "$ENABLE_KF5" = "TRUE" \) -o \
11354        \( "$test_qt5" = "yes" -a "$ENABLE_QT5" = "TRUE" \) -o \
11355        \( "$test_gtk3_kde5" = "yes" -a "$ENABLE_GTK3_KDE5" = "TRUE" \)
11356then
11357    qt5_incdirs="$QT5INC /usr/include/qt5 /usr/include $x_includes"
11358    qt5_libdirs="$QT5LIB /usr/lib/qt5 /usr/lib $x_libraries"
11359
11360    if test -n "$supports_multilib"; then
11361        qt5_libdirs="$qt5_libdirs /usr/lib64/qt5 /usr/lib64/qt /usr/lib64"
11362    fi
11363
11364    qt5_test_include="QtWidgets/qapplication.h"
11365    qt5_test_library="libQt5Widgets.so"
11366
11367    dnl Check for qmake5
11368    AC_PATH_PROGS( QMAKE5, [qmake-qt5 qmake], no, [$QT5DIR/bin:$PATH])
11369    if test "$QMAKE5" = "no"; then
11370        AC_MSG_ERROR([Qmake not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
11371    else
11372        qmake5_test_ver="`$QMAKE5 -v 2>&1 | $SED -n -e 's/^Using Qt version \(5\.[[0-9.]]\+\).*$/\1/p'`"
11373        if test -z "$qmake5_test_ver"; then
11374            AC_MSG_ERROR([Wrong qmake for Qt5 found. Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
11375        fi
11376        qmake5_minor_version="`echo $qmake5_test_ver | cut -d. -f2`"
11377        qt5_minimal_minor="6"
11378        if test "$qmake5_minor_version" -lt "$qt5_minimal_minor"; then
11379            AC_MSG_ERROR([The minimal supported Qt5 version is 5.${qt5_minimal_minor}, but your 'qmake -v' reports Qt5 version $qmake5_test_ver.])
11380        else
11381            AC_MSG_NOTICE([Detected Qt5 version: $qmake5_test_ver])
11382        fi
11383    fi
11384
11385    qt5_incdirs="`$QMAKE5 -query QT_INSTALL_HEADERS` $qt5_incdirs"
11386    qt5_libdirs="`$QMAKE5 -query QT_INSTALL_LIBS` $qt5_libdirs"
11387
11388    AC_MSG_CHECKING([for Qt5 headers])
11389    qt5_incdir="no"
11390    for inc_dir in $qt5_incdirs; do
11391        if test -r "$inc_dir/$qt5_test_include"; then
11392            qt5_incdir="$inc_dir"
11393            break
11394        fi
11395    done
11396    AC_MSG_RESULT([$qt5_incdir])
11397    if test "x$qt5_incdir" = "xno"; then
11398        AC_MSG_ERROR([Qt5 headers not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
11399    fi
11400
11401    AC_MSG_CHECKING([for Qt5 libraries])
11402    qt5_libdir="no"
11403    for lib_dir in $qt5_libdirs; do
11404        if test -r "$lib_dir/$qt5_test_library"; then
11405            qt5_libdir="$lib_dir"
11406            break
11407        fi
11408    done
11409    AC_MSG_RESULT([$qt5_libdir])
11410    if test "x$qt5_libdir" = "xno"; then
11411        AC_MSG_ERROR([Qt5 libraries not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
11412    fi
11413
11414    QT5_CFLAGS="-I$qt5_incdir -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT -DQT_NO_VERSION_TAGGING"
11415    QT5_CFLAGS=$(printf '%s' "$QT5_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11416    QT5_LIBS="-L$qt5_libdir -lQt5Core -lQt5Gui -lQt5Widgets -lQt5Network"
11417
11418    if test "$USING_X11" = TRUE; then
11419        PKG_CHECK_MODULES(QT5_XCB,[xcb],,[AC_MSG_ERROR([XCB not found, which is needed for correct app grouping in X11.])])
11420        PKG_CHECK_MODULES(QT5_XCB_ICCCM,[xcb-icccm],[
11421            QT5_HAVE_XCB_ICCCM=1
11422            AC_DEFINE(QT5_HAVE_XCB_ICCCM)
11423        ],[
11424            AC_MSG_WARN([XCB ICCCM not found, which is needed for old Qt versions (< 5.12) on some WMs to correctly group dialogs (like QTBUG-46626)])
11425            add_warning "XCB ICCCM not found, which is needed for Qt versions (< 5.12) on some WMs to correctly group dialogs (like QTBUG-46626)"
11426        ])
11427        QT5_CFLAGS="$QT5_CFLAGS $QT5_XCB_CFLAGS $QT5_XCB_ICCCM_CFLAGS"
11428        QT5_LIBS="$QT5_LIBS $QT5_XCB_LIBS $QT5_XCB_ICCCM_LIBS -lQt5X11Extras"
11429        QT5_USING_X11=1
11430        AC_DEFINE(QT5_USING_X11)
11431    fi
11432
11433    dnl Check for Meta Object Compiler
11434
11435    AC_PATH_PROGS( MOC5, [moc-qt5 moc], no, [`dirname $qt5_libdir`/bin:$QT5DIR/bin:$PATH])
11436    if test "$MOC5" = "no"; then
11437        AC_MSG_ERROR([Qt Meta Object Compiler not found.  Please specify
11438the root of your Qt installation by exporting QT5DIR before running "configure".])
11439    fi
11440
11441    if test "$build_gstreamer_1_0" = "yes"; then
11442        PKG_CHECK_MODULES(QT5_GOBJECT,[gobject-2.0], [
11443                QT5_HAVE_GOBJECT=1
11444                AC_DEFINE(QT5_HAVE_GOBJECT)
11445            ],
11446            AC_MSG_WARN([[No GObject found, can't use QWidget GStreamer sink on wayland!]])
11447        )
11448    fi
11449fi
11450AC_SUBST(QT5_CFLAGS)
11451AC_SUBST(QT5_LIBS)
11452AC_SUBST(MOC5)
11453AC_SUBST(QT5_GOBJECT_CFLAGS)
11454AC_SUBST(QT5_GOBJECT_LIBS)
11455AC_SUBST(QT5_HAVE_GOBJECT)
11456
11457dnl ===================================================================
11458dnl KF5 Integration
11459dnl ===================================================================
11460
11461KF5_CFLAGS=""
11462KF5_LIBS=""
11463KF5_CONFIG="kf5-config"
11464if test \( "$test_kf5" = "yes" -a "$ENABLE_KF5" = "TRUE" \) -o \
11465        \( "$test_gtk3_kde5" = "yes" -a "$ENABLE_GTK3_KDE5" = "TRUE" \)
11466then
11467    if test "$OS" = "HAIKU"; then
11468        haiku_arch="`echo $RTL_ARCH | tr X x`"
11469        kf5_haiku_incdirs="`findpaths -c ' ' -a $haiku_arch B_FIND_PATH_HEADERS_DIRECTORY`"
11470        kf5_haiku_libdirs="`findpaths -c ' ' -a $haiku_arch B_FIND_PATH_DEVELOP_LIB_DIRECTORY`"
11471    fi
11472
11473    kf5_incdirs="$KF5INC /usr/include $kf5_haiku_incdirs $x_includes"
11474    kf5_libdirs="$KF5LIB /usr/lib /usr/lib/kf5 /usr/lib/kf5/devel $kf5_haiku_libdirs $x_libraries"
11475    if test -n "$supports_multilib"; then
11476        kf5_libdirs="$kf5_libdirs /usr/lib64 /usr/lib64/kf5 /usr/lib64/kf5/devel"
11477    fi
11478
11479    kf5_test_include="KF5/kcoreaddons_version.h"
11480    kf5_test_library="libKF5CoreAddons.so"
11481    kf5_libdirs="$qt5_libdir $kf5_libdirs"
11482
11483    dnl kf5 KDE4 support compatibility installed
11484    AC_PATH_PROG( KF5_CONFIG, $KF5_CONFIG, no, )
11485    if test "$KF5_CONFIG" != "no"; then
11486        kf5_incdirs="`$KF5_CONFIG --path include` $kf5_incdirs"
11487        kf5_libdirs="`$KF5_CONFIG --path lib` $kf5_libdirs"
11488    fi
11489
11490    dnl Check for KF5 headers
11491    AC_MSG_CHECKING([for KF5 headers])
11492    kf5_incdir="no"
11493    for kf5_check in $kf5_incdirs; do
11494        if test -r "$kf5_check/$kf5_test_include"; then
11495            kf5_incdir="$kf5_check/KF5"
11496            break
11497        fi
11498    done
11499    AC_MSG_RESULT([$kf5_incdir])
11500    if test "x$kf5_incdir" = "xno"; then
11501        AC_MSG_ERROR([KF5 headers not found.  Please specify the root of your KF5 installation by exporting KF5DIR before running "configure".])
11502    fi
11503
11504    dnl Check for KF5 libraries
11505    AC_MSG_CHECKING([for KF5 libraries])
11506    kf5_libdir="no"
11507    for kf5_check in $kf5_libdirs; do
11508        if test -r "$kf5_check/$kf5_test_library"; then
11509            kf5_libdir="$kf5_check"
11510            break
11511        fi
11512    done
11513
11514    AC_MSG_RESULT([$kf5_libdir])
11515    if test "x$kf5_libdir" = "xno"; then
11516        AC_MSG_ERROR([KF5 libraries not found.  Please specify the root of your KF5 installation by exporting KF5DIR before running "configure".])
11517    fi
11518
11519    KF5_CFLAGS="-I$kf5_incdir -I$kf5_incdir/KCoreAddons -I$kf5_incdir/KI18n -I$kf5_incdir/KConfigCore -I$kf5_incdir/KWindowSystem -I$kf5_incdir/KIOCore -I$kf5_incdir/KIOWidgets -I$kf5_incdir/KIOFileWidgets -I$qt5_incdir -I$qt5_incdir/QtCore -I$qt5_incdir/QtGui -I$qt5_incdir/QtWidgets -I$qt5_incdir/QtNetwork -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT -DQT_NO_VERSION_TAGGING"
11520    KF5_LIBS="-L$kf5_libdir -lKF5CoreAddons -lKF5I18n -lKF5ConfigCore -lKF5WindowSystem -lKF5KIOCore -lKF5KIOWidgets -lKF5KIOFileWidgets -L$qt5_libdir -lQt5Core -lQt5Gui -lQt5Widgets -lQt5Network"
11521    KF5_CFLAGS=$(printf '%s' "$KF5_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11522
11523    if test "$USING_X11" = TRUE; then
11524        KF5_LIBS="$KF5_LIBS -lQt5X11Extras"
11525    fi
11526
11527    AC_LANG_PUSH([C++])
11528    save_CXXFLAGS=$CXXFLAGS
11529    CXXFLAGS="$CXXFLAGS $KF5_CFLAGS"
11530    AC_MSG_CHECKING([whether KDE is >= 5.0])
11531       AC_RUN_IFELSE([AC_LANG_SOURCE([[
11532#include <kcoreaddons_version.h>
11533
11534int main(int argc, char **argv) {
11535       if (KCOREADDONS_VERSION_MAJOR == 5 && KCOREADDONS_VERSION_MINOR >= 0) return 0;
11536       else return 1;
11537}
11538       ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([KDE version too old])],[])
11539    CXXFLAGS=$save_CXXFLAGS
11540    AC_LANG_POP([C++])
11541fi
11542AC_SUBST(KF5_CFLAGS)
11543AC_SUBST(KF5_LIBS)
11544
11545dnl ===================================================================
11546dnl Test whether to include Evolution 2 support
11547dnl ===================================================================
11548AC_MSG_CHECKING([whether to enable evolution 2 support])
11549if test "$enable_evolution2" = "yes" -o "$enable_evolution2" = "TRUE"; then
11550    AC_MSG_RESULT([yes])
11551    PKG_CHECK_MODULES(GOBJECT, gobject-2.0)
11552    GOBJECT_CFLAGS=$(printf '%s' "$GOBJECT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11553    FilterLibs "${GOBJECT_LIBS}"
11554    GOBJECT_LIBS="${filteredlibs}"
11555    ENABLE_EVOAB2="TRUE"
11556else
11557    ENABLE_EVOAB2=""
11558    AC_MSG_RESULT([no])
11559fi
11560AC_SUBST(ENABLE_EVOAB2)
11561AC_SUBST(GOBJECT_CFLAGS)
11562AC_SUBST(GOBJECT_LIBS)
11563
11564dnl ===================================================================
11565dnl Test which themes to include
11566dnl ===================================================================
11567AC_MSG_CHECKING([which themes to include])
11568# if none given use default subset of available themes
11569if test "x$with_theme" = "x" -o "x$with_theme" = "xyes"; then
11570    with_theme="breeze breeze_dark breeze_dark_svg breeze_svg colibre colibre_svg elementary elementary_svg karasa_jaga karasa_jaga_svg sifr sifr_svg sifr_dark sifr_dark_svg tango"
11571fi
11572
11573WITH_THEMES=""
11574if test "x$with_theme" != "xno"; then
11575    for theme in $with_theme; do
11576        case $theme in
11577        breeze|breeze_dark|breeze_dark_svg|breeze_svg|colibre|colibre_svg|elementary|elementary_svg|karasa_jaga|karasa_jaga_svg|sifr|sifr_svg|sifr_dark|sifr_dark_svg|tango) real_theme="$theme" ;;
11578        default) real_theme=colibre ;;
11579        *) AC_MSG_ERROR([Unknown value for --with-theme: $theme]) ;;
11580        esac
11581        WITH_THEMES=`echo "$WITH_THEMES $real_theme"|tr '\ ' '\n'|sort|uniq|tr '\n' '\ '`
11582    done
11583fi
11584AC_MSG_RESULT([$WITH_THEMES])
11585AC_SUBST([WITH_THEMES])
11586# FIXME: remove this, and the convenience default->colibre remapping after a grace period
11587for theme in $with_theme; do
11588    case $theme in
11589    default) AC_MSG_WARN([--with-theme=default is deprecated and will be removed, use --with-theme=colibre]) ;;
11590    *) ;;
11591    esac
11592done
11593
11594dnl ===================================================================
11595dnl Test whether to integrate helppacks into the product's installer
11596dnl ===================================================================
11597AC_MSG_CHECKING([for helppack integration])
11598if test "$with_helppack_integration" = "no"; then
11599    AC_MSG_RESULT([no integration])
11600else
11601    SCPDEFS="$SCPDEFS -DWITH_HELPPACK_INTEGRATION"
11602    AC_MSG_RESULT([integration])
11603fi
11604
11605###############################################################################
11606# Extensions checking
11607###############################################################################
11608AC_MSG_CHECKING([for extensions integration])
11609if test "x$enable_extension_integration" != "xno"; then
11610    WITH_EXTENSION_INTEGRATION=TRUE
11611    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_INTEGRATION"
11612    AC_MSG_RESULT([yes, use integration])
11613else
11614    WITH_EXTENSION_INTEGRATION=
11615    AC_MSG_RESULT([no, do not integrate])
11616fi
11617AC_SUBST(WITH_EXTENSION_INTEGRATION)
11618
11619dnl Should any extra extensions be included?
11620dnl There are standalone tests for each of these below.
11621WITH_EXTRA_EXTENSIONS=
11622AC_SUBST([WITH_EXTRA_EXTENSIONS])
11623
11624libo_CHECK_EXTENSION([ConvertTextToNumber],[CT2N],[ct2n],[ct2n],[])
11625libo_CHECK_EXTENSION([Numbertext],[NUMBERTEXT],[numbertext],[numbertext],[b7cae45ad2c23551fd6ccb8ae2c1f59e-numbertext_0.9.5.oxt])
11626if test "x$with_java" != "xno"; then
11627    libo_CHECK_EXTENSION([NLPSolver],[NLPSOLVER],[nlpsolver],[nlpsolver],[])
11628    libo_CHECK_EXTENSION([LanguageTool],[LANGUAGETOOL],[languagetool],[languagetool],[])
11629fi
11630
11631AC_MSG_CHECKING([whether to build opens___.ttf])
11632if test "$enable_build_opensymbol" = "yes"; then
11633    AC_MSG_RESULT([yes])
11634    AC_PATH_PROG(FONTFORGE, fontforge)
11635    if test -z "$FONTFORGE"; then
11636        AC_MSG_ERROR([fontforge not installed])
11637    fi
11638else
11639    AC_MSG_RESULT([no])
11640    OPENSYMBOL_TTF=884ed41809687c3e168fc7c19b16585149ff058eca79acbf3ee784f6630704cc-opens___.ttf
11641    BUILD_TYPE="$BUILD_TYPE OPENSYMBOL"
11642fi
11643AC_SUBST(OPENSYMBOL_TTF)
11644AC_SUBST(FONTFORGE)
11645
11646dnl ===================================================================
11647dnl Test whether to include fonts
11648dnl ===================================================================
11649AC_MSG_CHECKING([whether to include third-party fonts])
11650if test "$with_fonts" != "no"; then
11651    AC_MSG_RESULT([yes])
11652    WITH_FONTS=TRUE
11653    BUILD_TYPE="$BUILD_TYPE MORE_FONTS"
11654    AC_DEFINE(HAVE_MORE_FONTS)
11655else
11656    AC_MSG_RESULT([no])
11657    WITH_FONTS=
11658    SCPDEFS="$SCPDEFS -DWITHOUT_FONTS"
11659fi
11660AC_SUBST(WITH_FONTS)
11661
11662
11663dnl ===================================================================
11664dnl Test whether to enable online update service
11665dnl ===================================================================
11666AC_MSG_CHECKING([whether to enable online update])
11667ENABLE_ONLINE_UPDATE=
11668ENABLE_ONLINE_UPDATE_MAR=
11669UPDATE_CONFIG=
11670if test "$enable_online_update" = ""; then
11671    if test "$_os" = "WINNT" -o "$_os" = "Darwin"; then
11672        AC_MSG_RESULT([yes])
11673        ENABLE_ONLINE_UPDATE="TRUE"
11674    else
11675        AC_MSG_RESULT([no])
11676    fi
11677else
11678    if test "$enable_online_update" = "mar"; then
11679        AC_MSG_RESULT([yes - MAR-based online update])
11680        ENABLE_ONLINE_UPDATE_MAR="TRUE"
11681        if test "$with_update_config" = ""; then
11682            AC_MSG_ERROR([mar based online updater needs an update config specified with "with-update-config])
11683        fi
11684        UPDATE_CONFIG="$with_update_config"
11685        AC_DEFINE(HAVE_FEATURE_UPDATE_MAR)
11686    elif test "$enable_online_update" = "yes"; then
11687        AC_MSG_RESULT([yes])
11688        ENABLE_ONLINE_UPDATE="TRUE"
11689    else
11690        AC_MSG_RESULT([no])
11691    fi
11692fi
11693AC_SUBST(ENABLE_ONLINE_UPDATE)
11694AC_SUBST(ENABLE_ONLINE_UPDATE_MAR)
11695AC_SUBST(UPDATE_CONFIG)
11696
11697dnl ===================================================================
11698dnl Test whether we need bzip2
11699dnl ===================================================================
11700SYSTEM_BZIP2=
11701if test "$ENABLE_ONLINE_UPDATE_MAR" = "TRUE"; then
11702    AC_MSG_CHECKING([whether to use system bzip2])
11703    if test "$with_system_bzip2" = yes; then
11704        SYSTEM_BZIP2=TRUE
11705        AC_MSG_RESULT([yes])
11706        PKG_CHECK_MODULES(BZIP2, bzip2)
11707        FilterLibs "${BZIP2_LIBS}"
11708        BZIP2_LIBS="${filteredlibs}"
11709    else
11710        AC_MSG_RESULT([no])
11711        BUILD_TYPE="$BUILD_TYPE BZIP2"
11712    fi
11713fi
11714AC_SUBST(SYSTEM_BZIP2)
11715AC_SUBST(BZIP2_CFLAGS)
11716AC_SUBST(BZIP2_LIBS)
11717
11718dnl ===================================================================
11719dnl Test whether to enable extension update
11720dnl ===================================================================
11721AC_MSG_CHECKING([whether to enable extension update])
11722ENABLE_EXTENSION_UPDATE=
11723if test "x$enable_extension_update" = "xno"; then
11724    AC_MSG_RESULT([no])
11725else
11726    AC_MSG_RESULT([yes])
11727    ENABLE_EXTENSION_UPDATE="TRUE"
11728    AC_DEFINE(ENABLE_EXTENSION_UPDATE)
11729    SCPDEFS="$SCPDEFS -DENABLE_EXTENSION_UPDATE"
11730fi
11731AC_SUBST(ENABLE_EXTENSION_UPDATE)
11732
11733
11734dnl ===================================================================
11735dnl Test whether to create MSI with LIMITUI=1 (silent install)
11736dnl ===================================================================
11737AC_MSG_CHECKING([whether to create MSI with LIMITUI=1 (silent install)])
11738if test "$enable_silent_msi" = "" -o "$enable_silent_msi" = "no"; then
11739    AC_MSG_RESULT([no])
11740    ENABLE_SILENT_MSI=
11741else
11742    AC_MSG_RESULT([yes])
11743    ENABLE_SILENT_MSI=TRUE
11744    SCPDEFS="$SCPDEFS -DENABLE_SILENT_MSI"
11745fi
11746AC_SUBST(ENABLE_SILENT_MSI)
11747
11748AC_MSG_CHECKING([whether and how to use Xinerama])
11749if test "$_os" = "Linux" -o "$_os" = "FreeBSD"; then
11750    if test "$x_libraries" = "default_x_libraries"; then
11751        XINERAMALIB=`$PKG_CONFIG --variable=libdir xinerama`
11752        if test "x$XINERAMALIB" = x; then
11753           XINERAMALIB="/usr/lib"
11754        fi
11755    else
11756        XINERAMALIB="$x_libraries"
11757    fi
11758    if test -e "$XINERAMALIB/libXinerama.so" -a -e "$XINERAMALIB/libXinerama.a"; then
11759        # we have both versions, let the user decide but use the dynamic one
11760        # per default
11761        USE_XINERAMA=TRUE
11762        if test -z "$with_static_xinerama" -o -n "$with_system_libs"; then
11763            XINERAMA_LINK=dynamic
11764        else
11765            XINERAMA_LINK=static
11766        fi
11767    elif test -e "$XINERAMALIB/libXinerama.so" -a ! -e "$XINERAMALIB/libXinerama.a"; then
11768        # we have only the dynamic version
11769        USE_XINERAMA=TRUE
11770        XINERAMA_LINK=dynamic
11771    elif test -e "$XINERAMALIB/libXinerama.a"; then
11772        # static version
11773        if echo $host_cpu | $GREP -E 'i[[3456]]86' 2>/dev/null >/dev/null; then
11774            USE_XINERAMA=TRUE
11775            XINERAMA_LINK=static
11776        else
11777            USE_XINERAMA=
11778            XINERAMA_LINK=none
11779        fi
11780    else
11781        # no Xinerama
11782        USE_XINERAMA=
11783        XINERAMA_LINK=none
11784    fi
11785    if test "$USE_XINERAMA" = "TRUE"; then
11786        AC_MSG_RESULT([yes, with $XINERAMA_LINK linking])
11787        AC_CHECK_HEADER(X11/extensions/Xinerama.h, [],
11788            [AC_MSG_ERROR(Xinerama header not found.)], [])
11789        XEXTLIBS=`$PKG_CONFIG --variable=libs xext`
11790        if test "x$XEXTLIB" = x; then
11791           XEXTLIBS="-L$XLIB -L$XINERAMALIB -lXext"
11792        fi
11793        XINERAMA_EXTRA_LIBS="$XEXTLIBS"
11794        if test "$_os" = "FreeBSD"; then
11795            XINERAMA_EXTRA_LIBS="$XINERAMA_EXTRA_LIBS -lXt"
11796        fi
11797        if test "$_os" = "Linux"; then
11798            XINERAMA_EXTRA_LIBS="$XINERAMA_EXTRA_LIBS -ldl"
11799        fi
11800        AC_CHECK_LIB([Xinerama], [XineramaIsActive], [:],
11801            [AC_MSG_ERROR(Xinerama not functional?)], [$XINERAMA_EXTRA_LIBS])
11802    else
11803        AC_MSG_RESULT([no, libXinerama not found or wrong architecture.])
11804    fi
11805else
11806    USE_XINERAMA=
11807    XINERAMA_LINK=none
11808    AC_MSG_RESULT([no])
11809fi
11810AC_SUBST(USE_XINERAMA)
11811AC_SUBST(XINERAMA_LINK)
11812
11813dnl ===================================================================
11814dnl Test whether to build cairo or rely on the system version
11815dnl ===================================================================
11816
11817if test "$USING_X11" = TRUE; then
11818    # Used in vcl/Library_vclplug_gen.mk
11819    test_cairo=yes
11820fi
11821
11822if test "$test_cairo" = "yes"; then
11823    AC_MSG_CHECKING([whether to use the system cairo])
11824
11825    : ${with_system_cairo:=$with_system_libs}
11826    if test "$with_system_cairo" = "yes"; then
11827        SYSTEM_CAIRO=TRUE
11828        AC_MSG_RESULT([yes])
11829
11830        PKG_CHECK_MODULES( CAIRO, cairo >= 1.8.0 )
11831        CAIRO_CFLAGS=$(printf '%s' "$CAIRO_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11832        FilterLibs "${CAIRO_LIBS}"
11833        CAIRO_LIBS="${filteredlibs}"
11834
11835        if test "$test_xrender" = "yes"; then
11836            AC_MSG_CHECKING([whether Xrender.h defines PictStandardA8])
11837            AC_LANG_PUSH([C])
11838            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <X11/extensions/Xrender.h>]],[[
11839#ifdef PictStandardA8
11840#else
11841      return fail;
11842#endif
11843]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no, X headers too old.])])
11844
11845            AC_LANG_POP([C])
11846        fi
11847    else
11848        SYSTEM_CAIRO=
11849        AC_MSG_RESULT([no])
11850
11851        BUILD_TYPE="$BUILD_TYPE CAIRO"
11852    fi
11853fi
11854
11855AC_SUBST(SYSTEM_CAIRO)
11856AC_SUBST(CAIRO_CFLAGS)
11857AC_SUBST(CAIRO_LIBS)
11858
11859dnl ===================================================================
11860dnl Test whether to use avahi
11861dnl ===================================================================
11862if test "$_os" = "WINNT"; then
11863    # Windows uses bundled mDNSResponder
11864    BUILD_TYPE="$BUILD_TYPE MDNSRESPONDER"
11865elif test "$_os" != "Darwin" -a "$enable_avahi" = "yes"; then
11866    PKG_CHECK_MODULES([AVAHI], [avahi-client >= 0.6.10],
11867                      [ENABLE_AVAHI="TRUE"])
11868    AC_DEFINE(HAVE_FEATURE_AVAHI)
11869    AVAHI_CFLAGS=$(printf '%s' "$AVAHI_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11870    FilterLibs "${AVAHI_LIBS}"
11871    AVAHI_LIBS="${filteredlibs}"
11872fi
11873
11874AC_SUBST(ENABLE_AVAHI)
11875AC_SUBST(AVAHI_CFLAGS)
11876AC_SUBST(AVAHI_LIBS)
11877
11878dnl ===================================================================
11879dnl Test whether to use liblangtag
11880dnl ===================================================================
11881SYSTEM_LIBLANGTAG=
11882AC_MSG_CHECKING([whether to use system liblangtag])
11883if test "$with_system_liblangtag" = yes; then
11884    SYSTEM_LIBLANGTAG=TRUE
11885    AC_MSG_RESULT([yes])
11886    PKG_CHECK_MODULES( LIBLANGTAG, liblangtag >= 0.4.0)
11887    dnl cf. <https://bitbucket.org/tagoh/liblangtag/commits/9324836a0d1c> "Fix a build issue with inline keyword"
11888    PKG_CHECK_EXISTS([liblangtag >= 0.5.5], [], [AC_DEFINE([LIBLANGTAG_INLINE_FIX])])
11889    LIBLANGTAG_CFLAGS=$(printf '%s' "$LIBLANGTAG_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11890    FilterLibs "${LIBLANGTAG_LIBS}"
11891    LIBLANGTAG_LIBS="${filteredlibs}"
11892else
11893    SYSTEM_LIBLANGTAG=
11894    AC_MSG_RESULT([no])
11895    BUILD_TYPE="$BUILD_TYPE LIBLANGTAG"
11896    LIBLANGTAG_CFLAGS="-I${WORKDIR}/UnpackedTarball/liblangtag"
11897    if test "$COM" = "MSC"; then
11898        LIBLANGTAG_LIBS="${WORKDIR}/UnpackedTarball/liblangtag/liblangtag/.libs/liblangtag.lib"
11899    else
11900        LIBLANGTAG_LIBS="-L${WORKDIR}/UnpackedTarball/liblangtag/liblangtag/.libs -llangtag"
11901    fi
11902fi
11903AC_SUBST(SYSTEM_LIBLANGTAG)
11904AC_SUBST(LIBLANGTAG_CFLAGS)
11905AC_SUBST(LIBLANGTAG_LIBS)
11906
11907dnl ===================================================================
11908dnl Test whether to build libpng or rely on the system version
11909dnl ===================================================================
11910
11911libo_CHECK_SYSTEM_MODULE([libpng],[LIBPNG],[libpng],["-I${WORKDIR}/UnpackedTarball/libpng"],["-L${WORKDIR}/LinkTarget/StaticLibrary -llibpng"])
11912
11913dnl ===================================================================
11914dnl Check for runtime JVM search path
11915dnl ===================================================================
11916if test "$ENABLE_JAVA" != ""; then
11917    AC_MSG_CHECKING([whether to use specific JVM search path at runtime])
11918    if test -n "$with_jvm_path" -a "$with_jvm_path" != "no"; then
11919        AC_MSG_RESULT([yes])
11920        if ! test -d "$with_jvm_path"; then
11921            AC_MSG_ERROR(["$with_jvm_path" not a directory])
11922        fi
11923        if ! test -d "$with_jvm_path"jvm; then
11924            AC_MSG_ERROR(["$with_jvm_path"jvm not found, point with_jvm_path to \[/path/to/\]jvm])
11925        fi
11926        JVM_ONE_PATH_CHECK="$with_jvm_path"
11927        AC_SUBST(JVM_ONE_PATH_CHECK)
11928    else
11929        AC_MSG_RESULT([no])
11930    fi
11931fi
11932
11933dnl ===================================================================
11934dnl Test for the presence of Ant and that it works
11935dnl ===================================================================
11936
11937if test "$ENABLE_JAVA" != "" -a "$NEED_ANT" = "TRUE"; then
11938    ANT_HOME=; export ANT_HOME
11939    WITH_ANT_HOME=; export WITH_ANT_HOME
11940    if test -z "$with_ant_home" -a -n "$LODE_HOME" ; then
11941        if test -x "$LODE_HOME/opt/ant/bin/ant" ; then
11942            if test "$_os" = "WINNT"; then
11943                with_ant_home="`cygpath -m $LODE_HOME/opt/ant`"
11944            else
11945                with_ant_home="$LODE_HOME/opt/ant"
11946            fi
11947        elif test -x  "$LODE_HOME/opt/bin/ant" ; then
11948            with_ant_home="$LODE_HOME/opt/ant"
11949        fi
11950    fi
11951    if test -z "$with_ant_home"; then
11952        AC_PATH_PROGS(ANT, [ant ant.sh ant.bat ant.cmd])
11953    else
11954        if test "$_os" = "WINNT"; then
11955            # AC_PATH_PROGS needs unix path
11956            with_ant_home=`cygpath -u "$with_ant_home"`
11957        fi
11958        AbsolutePath "$with_ant_home"
11959        with_ant_home=$absolute_path
11960        AC_PATH_PROGS(ANT, [ant ant.sh ant.bat ant.cmd],,$with_ant_home/bin:$PATH)
11961        WITH_ANT_HOME=$with_ant_home
11962        ANT_HOME=$with_ant_home
11963    fi
11964
11965    if test -z "$ANT"; then
11966        AC_MSG_ERROR([Ant not found - Make sure it's in the path or use --with-ant-home])
11967    else
11968        # resolve relative or absolute symlink
11969        while test -h "$ANT"; do
11970            a_cwd=`pwd`
11971            a_basename=`basename "$ANT"`
11972            a_script=`ls -l "$ANT" | $SED "s/.*${a_basename} -> //g"`
11973            cd "`dirname "$ANT"`"
11974            cd "`dirname "$a_script"`"
11975            ANT="`pwd`"/"`basename "$a_script"`"
11976            cd "$a_cwd"
11977        done
11978
11979        AC_MSG_CHECKING([if $ANT works])
11980        mkdir -p conftest.dir
11981        a_cwd=$(pwd)
11982        cd conftest.dir
11983        cat > conftest.java << EOF
11984        public class conftest {
11985            int testmethod(int a, int b) {
11986                    return a + b;
11987            }
11988        }
11989EOF
11990
11991        cat > conftest.xml << EOF
11992        <project name="conftest" default="conftest">
11993        <target name="conftest">
11994            <javac srcdir="." includes="conftest.java">
11995            </javac>
11996        </target>
11997        </project>
11998EOF
11999
12000        AC_TRY_COMMAND("$ANT" -buildfile conftest.xml 1>&2)
12001        if test $? = 0 -a -f ./conftest.class; then
12002            AC_MSG_RESULT([Ant works])
12003            if test -z "$WITH_ANT_HOME"; then
12004                ANT_HOME=`"$ANT" -diagnostics | $EGREP "ant.home :" | $SED -e "s#ant.home : ##g"`
12005                if test -z "$ANT_HOME"; then
12006                    ANT_HOME=`echo "$ANT" | $SED -n "s/\/bin\/ant.*\$//p"`
12007                fi
12008            else
12009                ANT_HOME="$WITH_ANT_HOME"
12010            fi
12011        else
12012            echo "configure: Ant test failed" >&5
12013            cat conftest.java >&5
12014            cat conftest.xml >&5
12015            AC_MSG_ERROR([Ant does not work - Some Java projects will not build!])
12016        fi
12017        cd "$a_cwd"
12018        rm -fr conftest.dir
12019    fi
12020    if test -z "$ANT_HOME"; then
12021        ANT_HOME="NO_ANT_HOME"
12022    else
12023        PathFormat "$ANT_HOME"
12024        ANT_HOME="$formatted_path"
12025        PathFormat "$ANT"
12026        ANT="$formatted_path"
12027    fi
12028    AC_SUBST(ANT_HOME)
12029    AC_SUBST(ANT)
12030
12031    dnl Checking for ant.jar
12032    if test "$ANT_HOME" != "NO_ANT_HOME"; then
12033        AC_MSG_CHECKING([Ant lib directory])
12034        if test -f $ANT_HOME/lib/ant.jar; then
12035            ANT_LIB="$ANT_HOME/lib"
12036        else
12037            if test -f $ANT_HOME/ant.jar; then
12038                ANT_LIB="$ANT_HOME"
12039            else
12040                if test -f /usr/share/java/ant.jar; then
12041                    ANT_LIB=/usr/share/java
12042                else
12043                    if test -f /usr/share/ant-core/lib/ant.jar; then
12044                        ANT_LIB=/usr/share/ant-core/lib
12045                    else
12046                        if test -f $ANT_HOME/lib/ant/ant.jar; then
12047                            ANT_LIB="$ANT_HOME/lib/ant"
12048                        else
12049                            if test -f /usr/share/lib/ant/ant.jar; then
12050                                ANT_LIB=/usr/share/lib/ant
12051                            else
12052                                AC_MSG_ERROR([Ant libraries not found!])
12053                            fi
12054                        fi
12055                    fi
12056                fi
12057            fi
12058        fi
12059        PathFormat "$ANT_LIB"
12060        ANT_LIB="$formatted_path"
12061        AC_MSG_RESULT([Ant lib directory found.])
12062    fi
12063    AC_SUBST(ANT_LIB)
12064
12065    ant_minver=1.6.0
12066    ant_minminor1=`echo $ant_minver | cut -d"." -f2`
12067
12068    AC_MSG_CHECKING([whether Ant is >= $ant_minver])
12069    ant_version=`"$ANT" -version | $AWK '$3 == "version" { print $4; }'`
12070    ant_version_major=`echo $ant_version | cut -d. -f1`
12071    ant_version_minor=`echo $ant_version | cut -d. -f2`
12072    echo "configure: ant_version $ant_version " >&5
12073    echo "configure: ant_version_major $ant_version_major " >&5
12074    echo "configure: ant_version_minor $ant_version_minor " >&5
12075    if test "$ant_version_major" -ge "2"; then
12076        AC_MSG_RESULT([yes, $ant_version])
12077    elif test "$ant_version_major" = "1" -a "$ant_version_minor" -ge "$ant_minminor1"; then
12078        AC_MSG_RESULT([yes, $ant_version])
12079    else
12080        AC_MSG_ERROR([no, you need at least Ant >= $ant_minver])
12081    fi
12082
12083    rm -f conftest* core core.* *.core
12084fi
12085
12086OOO_JUNIT_JAR=
12087if test "$ENABLE_JAVA" != "" -a "$with_junit" != "no"; then
12088    AC_MSG_CHECKING([for JUnit 4])
12089    if test "$with_junit" = "yes"; then
12090        if test -n "$LODE_HOME" -a -e "$LODE_HOME/opt/share/java/junit.jar" ; then
12091            OOO_JUNIT_JAR="$LODE_HOME/opt/share/java/junit.jar"
12092        elif test -e /usr/share/java/junit4.jar; then
12093            OOO_JUNIT_JAR=/usr/share/java/junit4.jar
12094        else
12095           if test -e /usr/share/lib/java/junit.jar; then
12096              OOO_JUNIT_JAR=/usr/share/lib/java/junit.jar
12097           else
12098              OOO_JUNIT_JAR=/usr/share/java/junit.jar
12099           fi
12100        fi
12101    else
12102        OOO_JUNIT_JAR=$with_junit
12103    fi
12104    if test "$_os" = "WINNT"; then
12105        OOO_JUNIT_JAR=`cygpath -m "$OOO_JUNIT_JAR"`
12106    fi
12107    printf 'import org.junit.Before;' > conftest.java
12108    if "$JAVACOMPILER" -classpath "$OOO_JUNIT_JAR" conftest.java >&5 2>&5; then
12109        AC_MSG_RESULT([$OOO_JUNIT_JAR])
12110    else
12111        AC_MSG_ERROR(
12112[cannot find JUnit 4 jar; please install one in the default location (/usr/share/java),
12113 specify its pathname via --with-junit=..., or disable it via --without-junit])
12114    fi
12115    rm -f conftest.class conftest.java
12116    if test $OOO_JUNIT_JAR != ""; then
12117    BUILD_TYPE="$BUILD_TYPE QADEVOOO"
12118    fi
12119fi
12120AC_SUBST(OOO_JUNIT_JAR)
12121
12122HAMCREST_JAR=
12123if test "$ENABLE_JAVA" != "" -a "$with_junit" != "no"; then
12124    AC_MSG_CHECKING([for included Hamcrest])
12125    printf 'import org.hamcrest.BaseDescription;' > conftest.java
12126    if "$JAVACOMPILER" -classpath "$OOO_JUNIT_JAR" conftest.java >&5 2>&5; then
12127        AC_MSG_RESULT([Included in $OOO_JUNIT_JAR])
12128    else
12129        AC_MSG_RESULT([Not included])
12130        AC_MSG_CHECKING([for standalone hamcrest jar.])
12131        if test "$with_hamcrest" = "yes"; then
12132            if test -e /usr/share/lib/java/hamcrest.jar; then
12133                HAMCREST_JAR=/usr/share/lib/java/hamcrest.jar
12134            elif test -e /usr/share/java/hamcrest/core.jar; then
12135                HAMCREST_JAR=/usr/share/java/hamcrest/core.jar
12136            else
12137                HAMCREST_JAR=/usr/share/java/hamcrest.jar
12138            fi
12139        else
12140            HAMCREST_JAR=$with_hamcrest
12141        fi
12142        if test "$_os" = "WINNT"; then
12143            HAMCREST_JAR=`cygpath -m "$HAMCREST_JAR"`
12144        fi
12145        if "$JAVACOMPILER" -classpath "$HAMCREST_JAR" conftest.java >&5 2>&5; then
12146            AC_MSG_RESULT([$HAMCREST_JAR])
12147        else
12148            AC_MSG_ERROR([junit does not contain hamcrest; please use a junit jar that includes hamcrest, install a hamcrest jar in the default location (/usr/share/java),
12149                          specify its path with --with-hamcrest=..., or disable junit with --without-junit])
12150        fi
12151    fi
12152    rm -f conftest.class conftest.java
12153fi
12154AC_SUBST(HAMCREST_JAR)
12155
12156
12157AC_SUBST(SCPDEFS)
12158
12159#
12160# check for wget and curl
12161#
12162WGET=
12163CURL=
12164
12165if test "$enable_fetch_external" != "no"; then
12166
12167CURL=`which curl 2>/dev/null`
12168
12169for i in wget /usr/bin/wget /usr/local/bin/wget /usr/sfw/bin/wget /opt/sfw/bin/wget /opt/local/bin/wget; do
12170    # wget new enough?
12171    $i --help 2> /dev/null | $GREP no-use-server-timestamps 2>&1 > /dev/null
12172    if test $? -eq 0; then
12173        WGET=$i
12174        break
12175    fi
12176done
12177
12178if test -z "$WGET" -a -z "$CURL"; then
12179    AC_MSG_ERROR([neither wget nor curl found!])
12180fi
12181
12182fi
12183
12184AC_SUBST(WGET)
12185AC_SUBST(CURL)
12186
12187#
12188# check for sha256sum
12189#
12190SHA256SUM=
12191
12192for i in shasum /usr/local/bin/shasum /usr/sfw/bin/shasum /opt/sfw/bin/shasum /opt/local/bin/shasum; do
12193    eval "$i -a 256 --version" > /dev/null 2>&1
12194    ret=$?
12195    if test $ret -eq 0; then
12196        SHA256SUM="$i -a 256"
12197        break
12198    fi
12199done
12200
12201if test -z "$SHA256SUM"; then
12202    for i in sha256sum /usr/local/bin/sha256sum /usr/sfw/bin/sha256sum /opt/sfw/bin/sha256sum /opt/local/bin/sha256sum; do
12203        eval "$i --version" > /dev/null 2>&1
12204        ret=$?
12205        if test $ret -eq 0; then
12206            SHA256SUM=$i
12207            break
12208        fi
12209    done
12210fi
12211
12212if test -z "$SHA256SUM"; then
12213    AC_MSG_ERROR([no sha256sum found!])
12214fi
12215
12216AC_SUBST(SHA256SUM)
12217
12218dnl ===================================================================
12219dnl Dealing with l10n options
12220dnl ===================================================================
12221AC_MSG_CHECKING([which languages to be built])
12222# get list of all languages
12223# generate shell variable from completelangiso= from solenv/inc/langlist.mk
12224# the sed command does the following:
12225#   + if a line ends with a backslash, append the next line to it
12226#   + adds " on the beginning of the value (after =)
12227#   + adds " at the end of the value
12228#   + removes en-US; we want to put it on the beginning
12229#   + prints just the section starting with 'completelangiso=' and ending with the " at the end of line
12230[eval $(sed -e :a -e '/\\$/N; s/\\\n//; ta' -n -e 's/=/="/;s/\([^\\]\)$/\1"/;s/en-US//;/^completelangiso/p' $SRC_ROOT/solenv/inc/langlist.mk)]
12231ALL_LANGS="en-US $completelangiso"
12232# check the configured localizations
12233WITH_LANG="$with_lang"
12234
12235# Check for --without-lang which turns up as $with_lang being "no". Luckily there is no language with code "no".
12236# (Norwegian is "nb" and "nn".)
12237if test "$WITH_LANG" = "no"; then
12238    WITH_LANG=
12239fi
12240
12241if test -z "$WITH_LANG" -o "$WITH_LANG" = "en-US"; then
12242    AC_MSG_RESULT([en-US])
12243else
12244    AC_MSG_RESULT([$WITH_LANG])
12245    GIT_NEEDED_SUBMODULES="translations $GIT_NEEDED_SUBMODULES"
12246    if test -z "$MSGFMT"; then
12247        if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/msgfmt" ; then
12248            MSGFMT="$LODE_HOME/opt/bin/msgfmt"
12249        elif test -x "/opt/lo/bin/msgfmt"; then
12250            MSGFMT="/opt/lo/bin/msgfmt"
12251        else
12252            AC_CHECK_PROGS(MSGFMT, [msgfmt])
12253            if test -z "$MSGFMT"; then
12254                AC_MSG_ERROR([msgfmt not found. Install GNU gettext, or re-run without languages.])
12255            fi
12256        fi
12257    fi
12258    if test -z "$MSGUNIQ"; then
12259        if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/msguniq" ; then
12260            MSGUNIQ="$LODE_HOME/opt/bin/msguniq"
12261        elif test -x "/opt/lo/bin/msguniq"; then
12262            MSGUNIQ="/opt/lo/bin/msguniq"
12263        else
12264            AC_CHECK_PROGS(MSGUNIQ, [msguniq])
12265            if test -z "$MSGUNIQ"; then
12266                AC_MSG_ERROR([msguniq not found. Install GNU gettext, or re-run without languages.])
12267            fi
12268        fi
12269    fi
12270fi
12271AC_SUBST(MSGFMT)
12272AC_SUBST(MSGUNIQ)
12273# check that the list is valid
12274for lang in $WITH_LANG; do
12275    test "$lang" = "ALL" && continue
12276    # need to check for the exact string, so add space before and after the list of all languages
12277    for vl in $ALL_LANGS; do
12278        if test "$vl" = "$lang"; then
12279           break
12280        fi
12281    done
12282    if test "$vl" != "$lang"; then
12283        # if you're reading this - you prolly quoted your languages remove the quotes ...
12284        AC_MSG_ERROR([invalid language: '$lang' (vs '$v1'); supported languages are: $ALL_LANGS])
12285    fi
12286done
12287if test -n "$WITH_LANG" -a "$WITH_LANG" != "ALL"; then
12288    echo $WITH_LANG | grep -q en-US
12289    test $? -ne 1 || WITH_LANG=`echo $WITH_LANG en-US`
12290fi
12291# list with substituted ALL
12292WITH_LANG_LIST=`echo $WITH_LANG | sed "s/ALL/$ALL_LANGS/"`
12293test -z "$WITH_LANG_LIST" && WITH_LANG_LIST="en-US"
12294test "$WITH_LANG" = "en-US" && WITH_LANG=
12295if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
12296    test "$WITH_LANG_LIST" = "en-US" || WITH_LANG_LIST=`echo $WITH_LANG_LIST qtz`
12297    ALL_LANGS=`echo $ALL_LANGS qtz`
12298fi
12299AC_SUBST(ALL_LANGS)
12300AC_DEFINE_UNQUOTED(WITH_LANG,"$WITH_LANG")
12301AC_SUBST(WITH_LANG)
12302AC_SUBST(WITH_LANG_LIST)
12303AC_SUBST(GIT_NEEDED_SUBMODULES)
12304
12305WITH_POOR_HELP_LOCALIZATIONS=
12306if test -d "$SRC_ROOT/translations/source"; then
12307    for l in `ls -1 $SRC_ROOT/translations/source`; do
12308        if test ! -d "$SRC_ROOT/translations/source/$l/helpcontent2"; then
12309            WITH_POOR_HELP_LOCALIZATIONS="$WITH_POOR_HELP_LOCALIZATIONS $l"
12310        fi
12311    done
12312fi
12313AC_SUBST(WITH_POOR_HELP_LOCALIZATIONS)
12314
12315if test -n "$with_locales"; then
12316    WITH_LOCALES="$with_locales"
12317
12318    just_langs="`echo $WITH_LOCALES | sed -e 's/_[A-Z]*//g'`"
12319    # Only languages and scripts for which we actually have ifdefs need to be handled. Also see
12320    # config_host/config_locales.h.in
12321    for locale in $WITH_LOCALES; do
12322        lang=${locale%_*}
12323
12324        AC_DEFINE_UNQUOTED(WITH_LOCALE_$lang, 1)
12325
12326        case $lang in
12327        hi|mr*ne)
12328            AC_DEFINE(WITH_LOCALE_FOR_SCRIPT_Deva)
12329            ;;
12330        bg|ru)
12331            AC_DEFINE(WITH_LOCALE_FOR_SCRIPT_Cyrl)
12332            ;;
12333        esac
12334    done
12335else
12336    AC_DEFINE(WITH_LOCALE_ALL)
12337fi
12338AC_SUBST(WITH_LOCALES)
12339
12340dnl git submodule update --reference
12341dnl ===================================================================
12342if test -n "${GIT_REFERENCE_SRC}"; then
12343    for repo in ${GIT_NEEDED_SUBMODULES}; do
12344        if ! test -d "${GIT_REFERENCE_SRC}"/${repo}; then
12345            AC_MSG_ERROR([referenced git: required repository does not exist: ${GIT_REFERENCE_SRC}/${repo}])
12346        fi
12347    done
12348fi
12349AC_SUBST(GIT_REFERENCE_SRC)
12350
12351dnl git submodules linked dirs
12352dnl ===================================================================
12353if test -n "${GIT_LINK_SRC}"; then
12354    for repo in ${GIT_NEEDED_SUBMODULES}; do
12355        if ! test -d "${GIT_LINK_SRC}"/${repo}; then
12356            AC_MSG_ERROR([linked git: required repository does not exist: ${GIT_LINK_SRC}/${repo}])
12357        fi
12358    done
12359fi
12360AC_SUBST(GIT_LINK_SRC)
12361
12362dnl branding
12363dnl ===================================================================
12364AC_MSG_CHECKING([for alternative branding images directory])
12365# initialize mapped arrays
12366BRAND_INTRO_IMAGES="flat_logo.svg intro.png intro-highres.png"
12367brand_files="$BRAND_INTRO_IMAGES about.svg"
12368
12369if test -z "$with_branding" -o "$with_branding" = "no"; then
12370    AC_MSG_RESULT([none])
12371    DEFAULT_BRAND_IMAGES="$brand_files"
12372else
12373    if ! test -d $with_branding ; then
12374        AC_MSG_ERROR([No directory $with_branding, falling back to default branding])
12375    else
12376        AC_MSG_RESULT([$with_branding])
12377        CUSTOM_BRAND_DIR="$with_branding"
12378        for lfile in $brand_files
12379        do
12380            if ! test -f $with_branding/$lfile ; then
12381                AC_MSG_WARN([Branded file $lfile does not exist, using the default one])
12382                DEFAULT_BRAND_IMAGES="$DEFAULT_BRAND_IMAGES $lfile"
12383            else
12384                CUSTOM_BRAND_IMAGES="$CUSTOM_BRAND_IMAGES $lfile"
12385            fi
12386        done
12387        check_for_progress="yes"
12388    fi
12389fi
12390AC_SUBST([BRAND_INTRO_IMAGES])
12391AC_SUBST([CUSTOM_BRAND_DIR])
12392AC_SUBST([CUSTOM_BRAND_IMAGES])
12393AC_SUBST([DEFAULT_BRAND_IMAGES])
12394
12395
12396AC_MSG_CHECKING([for 'intro' progress settings])
12397PROGRESSBARCOLOR=
12398PROGRESSSIZE=
12399PROGRESSPOSITION=
12400PROGRESSFRAMECOLOR=
12401PROGRESSTEXTCOLOR=
12402PROGRESSTEXTBASELINE=
12403
12404if test "$check_for_progress" = "yes" -a -f "$with_branding/progress.conf" ; then
12405    source "$with_branding/progress.conf"
12406    AC_MSG_RESULT([settings found in $with_branding/progress.conf])
12407else
12408    AC_MSG_RESULT([none])
12409fi
12410
12411AC_SUBST(PROGRESSBARCOLOR)
12412AC_SUBST(PROGRESSSIZE)
12413AC_SUBST(PROGRESSPOSITION)
12414AC_SUBST(PROGRESSFRAMECOLOR)
12415AC_SUBST(PROGRESSTEXTCOLOR)
12416AC_SUBST(PROGRESSTEXTBASELINE)
12417
12418
12419AC_MSG_CHECKING([for extra build ID])
12420if test -n "$with_extra_buildid" -a "$with_extra_buildid" != "yes" ; then
12421    EXTRA_BUILDID="$with_extra_buildid"
12422fi
12423# in tinderboxes, it is easier to set EXTRA_BUILDID via the environment variable instead of configure switch
12424if test -n "$EXTRA_BUILDID" ; then
12425    AC_MSG_RESULT([$EXTRA_BUILDID])
12426else
12427    AC_MSG_RESULT([not set])
12428fi
12429AC_DEFINE_UNQUOTED([EXTRA_BUILDID], ["$EXTRA_BUILDID"])
12430
12431OOO_VENDOR=
12432AC_MSG_CHECKING([for vendor])
12433if test -z "$with_vendor" -o "$with_vendor" = "no"; then
12434    OOO_VENDOR="$USERNAME"
12435
12436    if test -z "$OOO_VENDOR"; then
12437        OOO_VENDOR="$USER"
12438    fi
12439
12440    if test -z "$OOO_VENDOR"; then
12441        OOO_VENDOR="`id -u -n`"
12442    fi
12443
12444    AC_MSG_RESULT([not set, using $OOO_VENDOR])
12445else
12446    OOO_VENDOR="$with_vendor"
12447    AC_MSG_RESULT([$OOO_VENDOR])
12448fi
12449AC_DEFINE_UNQUOTED(OOO_VENDOR,"$OOO_VENDOR")
12450AC_SUBST(OOO_VENDOR)
12451
12452if test "$_os" = "Android" ; then
12453    ANDROID_PACKAGE_NAME=
12454    AC_MSG_CHECKING([for Android package name])
12455    if test -z "$with_android_package_name" -o "$with_android_package_name" = "no"; then
12456        if test -n "$ENABLE_DEBUG"; then
12457            # Default to the package name that makes ndk-gdb happy.
12458            ANDROID_PACKAGE_NAME="org.libreoffice"
12459        else
12460            ANDROID_PACKAGE_NAME="org.example.libreoffice"
12461        fi
12462
12463        AC_MSG_RESULT([not set, using $ANDROID_PACKAGE_NAME])
12464    else
12465        ANDROID_PACKAGE_NAME="$with_android_package_name"
12466        AC_MSG_RESULT([$ANDROID_PACKAGE_NAME])
12467    fi
12468    AC_SUBST(ANDROID_PACKAGE_NAME)
12469fi
12470
12471AC_MSG_CHECKING([whether to install the compat oo* wrappers])
12472if test "$with_compat_oowrappers" = "yes"; then
12473    WITH_COMPAT_OOWRAPPERS=TRUE
12474    AC_MSG_RESULT(yes)
12475else
12476    WITH_COMPAT_OOWRAPPERS=
12477    AC_MSG_RESULT(no)
12478fi
12479AC_SUBST(WITH_COMPAT_OOWRAPPERS)
12480
12481INSTALLDIRNAME=`echo AC_PACKAGE_NAME | $AWK '{print tolower($0)}'`
12482AC_MSG_CHECKING([for install dirname])
12483if test -n "$with_install_dirname" -a "$with_install_dirname" != "no" -a "$with_install_dirname" != "yes"; then
12484    INSTALLDIRNAME="$with_install_dirname"
12485fi
12486AC_MSG_RESULT([$INSTALLDIRNAME])
12487AC_SUBST(INSTALLDIRNAME)
12488
12489AC_MSG_CHECKING([for prefix])
12490test "x$prefix" = xNONE && prefix=$ac_default_prefix
12491test "x$exec_prefix" = xNONE && exec_prefix=$prefix
12492PREFIXDIR="$prefix"
12493AC_MSG_RESULT([$PREFIXDIR])
12494AC_SUBST(PREFIXDIR)
12495
12496LIBDIR=[$(eval echo $(eval echo $libdir))]
12497AC_SUBST(LIBDIR)
12498
12499DATADIR=[$(eval echo $(eval echo $datadir))]
12500AC_SUBST(DATADIR)
12501
12502MANDIR=[$(eval echo $(eval echo $mandir))]
12503AC_SUBST(MANDIR)
12504
12505DOCDIR=[$(eval echo $(eval echo $docdir))]
12506AC_SUBST(DOCDIR)
12507
12508BINDIR=[$(eval echo $(eval echo $bindir))]
12509AC_SUBST(BINDIR)
12510
12511INSTALLDIR="$LIBDIR/$INSTALLDIRNAME"
12512AC_SUBST(INSTALLDIR)
12513
12514TESTINSTALLDIR="${BUILDDIR}/test-install"
12515AC_SUBST(TESTINSTALLDIR)
12516
12517
12518# ===================================================================
12519# OAuth2 id and secrets
12520# ===================================================================
12521
12522AC_MSG_CHECKING([for Google Drive client id and secret])
12523if test "$with_gdrive_client_id" = "no" -o -z "$with_gdrive_client_id"; then
12524    AC_MSG_RESULT([not set])
12525    GDRIVE_CLIENT_ID="\"\""
12526    GDRIVE_CLIENT_SECRET="\"\""
12527else
12528    AC_MSG_RESULT([set])
12529    GDRIVE_CLIENT_ID="\"$with_gdrive_client_id\""
12530    GDRIVE_CLIENT_SECRET="\"$with_gdrive_client_secret\""
12531fi
12532AC_DEFINE_UNQUOTED(GDRIVE_CLIENT_ID, $GDRIVE_CLIENT_ID)
12533AC_DEFINE_UNQUOTED(GDRIVE_CLIENT_SECRET, $GDRIVE_CLIENT_SECRET)
12534
12535AC_MSG_CHECKING([for Alfresco Cloud client id and secret])
12536if test "$with_alfresco_cloud_client_id" = "no" -o -z "$with_alfresco_cloud_client_id"; then
12537    AC_MSG_RESULT([not set])
12538    ALFRESCO_CLOUD_CLIENT_ID="\"\""
12539    ALFRESCO_CLOUD_CLIENT_SECRET="\"\""
12540else
12541    AC_MSG_RESULT([set])
12542    ALFRESCO_CLOUD_CLIENT_ID="\"$with_alfresco_cloud_client_id\""
12543    ALFRESCO_CLOUD_CLIENT_SECRET="\"$with_alfresco_cloud_client_secret\""
12544fi
12545AC_DEFINE_UNQUOTED(ALFRESCO_CLOUD_CLIENT_ID, $ALFRESCO_CLOUD_CLIENT_ID)
12546AC_DEFINE_UNQUOTED(ALFRESCO_CLOUD_CLIENT_SECRET, $ALFRESCO_CLOUD_CLIENT_SECRET)
12547
12548AC_MSG_CHECKING([for OneDrive client id and secret])
12549if test "$with_onedrive_client_id" = "no" -o -z "$with_onedrive_client_id"; then
12550    AC_MSG_RESULT([not set])
12551    ONEDRIVE_CLIENT_ID="\"\""
12552    ONEDRIVE_CLIENT_SECRET="\"\""
12553else
12554    AC_MSG_RESULT([set])
12555    ONEDRIVE_CLIENT_ID="\"$with_onedrive_client_id\""
12556    ONEDRIVE_CLIENT_SECRET="\"$with_onedrive_client_secret\""
12557fi
12558AC_DEFINE_UNQUOTED(ONEDRIVE_CLIENT_ID, $ONEDRIVE_CLIENT_ID)
12559AC_DEFINE_UNQUOTED(ONEDRIVE_CLIENT_SECRET, $ONEDRIVE_CLIENT_SECRET)
12560
12561
12562dnl ===================================================================
12563dnl Hook up LibreOffice's nodep environmental variable to automake's equivalent
12564dnl --enable-dependency-tracking configure option
12565dnl ===================================================================
12566AC_MSG_CHECKING([whether to enable dependency tracking])
12567if test "$enable_dependency_tracking" = "no"; then
12568    nodep=TRUE
12569    AC_MSG_RESULT([no])
12570else
12571    AC_MSG_RESULT([yes])
12572fi
12573AC_SUBST(nodep)
12574
12575dnl ===================================================================
12576dnl Number of CPUs to use during the build
12577dnl ===================================================================
12578AC_MSG_CHECKING([for number of processors to use])
12579# plain --with-parallelism is just the default
12580if test -n "$with_parallelism" -a "$with_parallelism" != "yes"; then
12581    if test "$with_parallelism" = "no"; then
12582        PARALLELISM=0
12583    else
12584        PARALLELISM=$with_parallelism
12585    fi
12586else
12587    if test "$enable_icecream" = "yes"; then
12588        PARALLELISM="40"
12589    else
12590        case `uname -s` in
12591
12592        Darwin|FreeBSD|NetBSD|OpenBSD)
12593            PARALLELISM=`sysctl -n hw.ncpu`
12594            ;;
12595
12596        Linux)
12597            PARALLELISM=`getconf _NPROCESSORS_ONLN`
12598        ;;
12599        # what else than above does profit here *and* has /proc?
12600        *)
12601            PARALLELISM=`grep $'^processor\t*:' /proc/cpuinfo | wc -l`
12602            ;;
12603        esac
12604
12605        # If we hit the catch-all case, but /proc/cpuinfo doesn't exist or has an
12606        # unexpected format, 'wc -l' will have returned 0 (and we won't use -j at all).
12607    fi
12608fi
12609
12610if test "$no_parallelism_make" = "YES" && test $PARALLELISM -gt 1; then
12611    if test -z "$with_parallelism"; then
12612            AC_MSG_WARN([gmake 3.81 crashes with parallelism > 1, reducing it to 1. upgrade to 3.82 to avoid this.])
12613            add_warning "gmake 3.81 crashes with parallelism > 1, reducing it to 1. upgrade to 3.82 to avoid this."
12614            PARALLELISM="1"
12615    else
12616        add_warning "make 3.81 is prone to crashes with parallelism > 1. Since --with-parallelism was explicitly given, it is honored, but do not complain when make segfaults on you."
12617    fi
12618fi
12619
12620if test $PARALLELISM -eq 0; then
12621    AC_MSG_RESULT([explicit make -j option needed])
12622else
12623    AC_MSG_RESULT([$PARALLELISM])
12624fi
12625AC_SUBST(PARALLELISM)
12626
12627IWYU_PATH="$with_iwyu"
12628AC_SUBST(IWYU_PATH)
12629if test ! -z "$IWYU_PATH"; then
12630    if test ! -f "$IWYU_PATH"; then
12631        AC_MSG_ERROR([cannot find include-what-you-use binary specified by --with-iwyu])
12632    fi
12633fi
12634
12635#
12636# Set up ILIB for MSVC build
12637#
12638ILIB1=
12639if test "$build_os" = "cygwin"; then
12640    ILIB="."
12641    if test -n "$JAVA_HOME"; then
12642        ILIB="$ILIB;$JAVA_HOME/lib"
12643    fi
12644    ILIB1=-link
12645    if test "$BITNESS_OVERRIDE" = 64; then
12646        ILIB="$ILIB;$COMPATH/lib/x64"
12647        ILIB1="$ILIB1 -LIBPATH:$COMPATH/lib/x64"
12648        ILIB="$ILIB;$WINDOWS_SDK_HOME/lib/x64"
12649        ILIB1="$ILIB1 -LIBPATH:$WINDOWS_SDK_HOME/lib/x64"
12650        if test $WINDOWS_SDK_VERSION = 80 -o $WINDOWS_SDK_VERSION = 81 -o $WINDOWS_SDK_VERSION = 10; then
12651            ILIB="$ILIB;$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/x64"
12652            ILIB1="$ILIB1 -LIBPATH:$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/x64"
12653        fi
12654        PathFormat "${UCRTSDKDIR}lib/$UCRTVERSION/ucrt/x64"
12655        ucrtlibpath_formatted=$formatted_path
12656        ILIB="$ILIB;$ucrtlibpath_formatted"
12657        ILIB1="$ILIB1 -LIBPATH:$ucrtlibpath_formatted"
12658    else
12659        ILIB="$ILIB;$COMPATH/lib/x86"
12660        ILIB1="$ILIB1 -LIBPATH:$COMPATH/lib/x86"
12661        ILIB="$ILIB;$WINDOWS_SDK_HOME/lib"
12662        ILIB1="$ILIB1 -LIBPATH:$WINDOWS_SDK_HOME/lib"
12663        if test $WINDOWS_SDK_VERSION = 80 -o $WINDOWS_SDK_VERSION = 81 -o $WINDOWS_SDK_VERSION = 10; then
12664            ILIB="$ILIB;$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/x86"
12665            ILIB1="$ILIB1 -LIBPATH:$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/x86"
12666        fi
12667        PathFormat "${UCRTSDKDIR}lib/$UCRTVERSION/ucrt/x86"
12668        ucrtlibpath_formatted=$formatted_path
12669        ILIB="$ILIB;$ucrtlibpath_formatted"
12670        ILIB1="$ILIB1 -LIBPATH:$ucrtlibpath_formatted"
12671    fi
12672    if test -f "$DOTNET_FRAMEWORK_HOME/lib/mscoree.lib"; then
12673        ILIB="$ILIB;$DOTNET_FRAMEWORK_HOME/lib"
12674    else
12675        ILIB="$ILIB;$DOTNET_FRAMEWORK_HOME/Lib/um/$WINDOWS_SDK_ARCH"
12676    fi
12677
12678    AC_SUBST(ILIB)
12679fi
12680
12681# ===================================================================
12682# Creating bigger shared library to link against
12683# ===================================================================
12684AC_MSG_CHECKING([whether to create huge library])
12685MERGELIBS=
12686
12687if test $_os = iOS -o $_os = Android; then
12688    # Never any point in mergelibs for these as we build just static
12689    # libraries anyway...
12690    enable_mergelibs=no
12691fi
12692
12693if test -n "$enable_mergelibs" -a "$enable_mergelibs" != "no"; then
12694    if test $_os != Linux -a $_os != WINNT; then
12695        add_warning "--enable-mergelibs is not tested for this platform"
12696    fi
12697    MERGELIBS="TRUE"
12698    AC_MSG_RESULT([yes])
12699else
12700    AC_MSG_RESULT([no])
12701fi
12702AC_SUBST([MERGELIBS])
12703
12704dnl ===================================================================
12705dnl icerun is a wrapper that stops us spawning tens of processes
12706dnl locally - for tools that can't be executed on the compile cluster
12707dnl this avoids a dozen javac's ganging up on your laptop to kill it.
12708dnl ===================================================================
12709AC_MSG_CHECKING([whether to use icerun wrapper])
12710ICECREAM_RUN=
12711if test "$enable_icecream" = "yes" && which icerun >/dev/null 2>&1 ; then
12712    ICECREAM_RUN=icerun
12713    AC_MSG_RESULT([yes])
12714else
12715    AC_MSG_RESULT([no])
12716fi
12717AC_SUBST(ICECREAM_RUN)
12718
12719dnl ===================================================================
12720dnl Setup the ICECC_VERSION for the build the same way it was set for
12721dnl configure, so that CC/CXX and ICECC_VERSION are in sync
12722dnl ===================================================================
12723x_ICECC_VERSION=[\#]
12724if test -n "$ICECC_VERSION" ; then
12725    x_ICECC_VERSION=
12726fi
12727AC_SUBST(x_ICECC_VERSION)
12728AC_SUBST(ICECC_VERSION)
12729
12730dnl ===================================================================
12731
12732AC_MSG_CHECKING([MPL subset])
12733MPL_SUBSET=
12734
12735if test "$enable_mpl_subset" = "yes"; then
12736    warn_report=false
12737    if test "$enable_report_builder" != "no" -a "$with_java" != "no"; then
12738        warn_report=true
12739    elif test "$ENABLE_REPORTBUILDER" = "TRUE"; then
12740        warn_report=true
12741    fi
12742    if test "$warn_report" = "true"; then
12743        AC_MSG_ERROR([need to --disable-report-builder - extended database report builder.])
12744    fi
12745    if test "x$enable_postgresql_sdbc" != "xno"; then
12746        AC_MSG_ERROR([need to --disable-postgresql-sdbc - the PostgreSQL database backend.])
12747    fi
12748    if test "$enable_lotuswordpro" = "yes"; then
12749        AC_MSG_ERROR([need to --disable-lotuswordpro - a Lotus Word Pro file format import filter.])
12750    fi
12751    if test "$WITH_WEBDAV" = "neon"; then
12752        AC_MSG_ERROR([need --with-webdav=serf or --without-webdav - webdav support.])
12753    fi
12754    if test -n "$ENABLE_POPPLER"; then
12755        if test "x$SYSTEM_POPPLER" = "x"; then
12756            AC_MSG_ERROR([need to disable PDF import via poppler or use system library])
12757        fi
12758    fi
12759    # cf. m4/libo_check_extension.m4
12760    if test "x$WITH_EXTRA_EXTENSIONS" != "x"; then
12761        AC_MSG_ERROR([need to disable extra extensions '$WITH_EXTRA_EXTENSIONS'])
12762    fi
12763    for theme in $WITH_THEMES; do
12764        case $theme in
12765        breeze|breeze_dark|breeze_svg|elementary|elementary_svg|karasa_jaga|karasa_jaga_svg) #blacklist of icon themes under GPL or LGPL
12766            AC_MSG_ERROR([need to disable icon themes from '$WITH_THEMES': $theme present, use --with-theme=tango]) ;;
12767        *) : ;;
12768        esac
12769    done
12770
12771    ENABLE_OPENGL_TRANSITIONS=
12772
12773    if test "$enable_lpsolve" != "no" -o "x$ENABLE_LPSOLVE" = "xTRUE"; then
12774        AC_MSG_ERROR([need to --disable-lpsolve - calc linear programming solver.])
12775    fi
12776
12777    MPL_SUBSET="TRUE"
12778    AC_DEFINE(MPL_HAVE_SUBSET)
12779    AC_MSG_RESULT([only])
12780else
12781    AC_MSG_RESULT([no restrictions])
12782fi
12783AC_SUBST(MPL_SUBSET)
12784
12785dnl ===================================================================
12786
12787AC_MSG_CHECKING([formula logger])
12788ENABLE_FORMULA_LOGGER=
12789
12790if test "x$enable_formula_logger" = "xyes"; then
12791    AC_MSG_RESULT([yes])
12792    AC_DEFINE(ENABLE_FORMULA_LOGGER)
12793    ENABLE_FORMULA_LOGGER=TRUE
12794elif test -n "$ENABLE_DBGUTIL" ; then
12795    AC_MSG_RESULT([yes])
12796    AC_DEFINE(ENABLE_FORMULA_LOGGER)
12797    ENABLE_FORMULA_LOGGER=TRUE
12798else
12799    AC_MSG_RESULT([no])
12800fi
12801
12802AC_SUBST(ENABLE_FORMULA_LOGGER)
12803
12804dnl ===================================================================
12805dnl Setting up the environment.
12806dnl ===================================================================
12807AC_MSG_NOTICE([setting up the build environment variables...])
12808
12809AC_SUBST(COMPATH)
12810
12811if test "$build_os" = "cygwin"; then
12812    if test -d "$COMPATH/atlmfc/lib/spectre"; then
12813        ATL_LIB="$COMPATH/atlmfc/lib/spectre"
12814        ATL_INCLUDE="$COMPATH/atlmfc/include"
12815    elif test -d "$COMPATH/atlmfc/lib"; then
12816        ATL_LIB="$COMPATH/atlmfc/lib"
12817        ATL_INCLUDE="$COMPATH/atlmfc/include"
12818    else
12819        ATL_LIB="$WINDOWS_SDK_HOME/lib" # Doesn't exist for VSE
12820        ATL_INCLUDE="$WINDOWS_SDK_HOME/include/atl"
12821    fi
12822    if test "$BITNESS_OVERRIDE" = 64; then
12823        ATL_LIB="$ATL_LIB/x64"
12824    else
12825        ATL_LIB="$ATL_LIB/x86"
12826    fi
12827    ATL_LIB=`win_short_path_for_make "$ATL_LIB"`
12828    ATL_INCLUDE=`win_short_path_for_make "$ATL_INCLUDE"`
12829
12830    # sort.exe and find.exe also exist in C:/Windows/system32 so need /usr/bin/
12831    PathFormat "/usr/bin/find.exe"
12832    FIND="$formatted_path"
12833    PathFormat "/usr/bin/sort.exe"
12834    SORT="$formatted_path"
12835    PathFormat "/usr/bin/grep.exe"
12836    WIN_GREP="$formatted_path"
12837    PathFormat "/usr/bin/ls.exe"
12838    WIN_LS="$formatted_path"
12839    PathFormat "/usr/bin/touch.exe"
12840    WIN_TOUCH="$formatted_path"
12841else
12842    FIND=find
12843    SORT=sort
12844fi
12845
12846AC_SUBST(ATL_INCLUDE)
12847AC_SUBST(ATL_LIB)
12848AC_SUBST(FIND)
12849AC_SUBST(SORT)
12850AC_SUBST(WIN_GREP)
12851AC_SUBST(WIN_LS)
12852AC_SUBST(WIN_TOUCH)
12853
12854AC_SUBST(BUILD_TYPE)
12855
12856AC_SUBST(SOLARINC)
12857
12858PathFormat "$PERL"
12859PERL="$formatted_path"
12860AC_SUBST(PERL)
12861
12862if test -n "$TMPDIR"; then
12863    TEMP_DIRECTORY="$TMPDIR"
12864else
12865    TEMP_DIRECTORY="/tmp"
12866fi
12867if test "$build_os" = "cygwin"; then
12868    TEMP_DIRECTORY=`cygpath -m "$TEMP_DIRECTORY"`
12869fi
12870AC_SUBST(TEMP_DIRECTORY)
12871
12872# setup the PATH for the environment
12873if test -n "$LO_PATH_FOR_BUILD"; then
12874    LO_PATH="$LO_PATH_FOR_BUILD"
12875else
12876    LO_PATH="$PATH"
12877
12878    case "$host_os" in
12879
12880    aix*|dragonfly*|freebsd*|linux-gnu*|*netbsd*|openbsd*)
12881        if test "$ENABLE_JAVA" != ""; then
12882            pathmunge "$JAVA_HOME/bin" "after"
12883        fi
12884        ;;
12885
12886    cygwin*)
12887        # Win32 make needs native paths
12888        if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
12889            LO_PATH=`cygpath -p -m "$PATH"`
12890        fi
12891        if test "$BITNESS_OVERRIDE" = 64; then
12892            # needed for msi packaging
12893            pathmunge "$WINDOWS_SDK_BINDIR_NO_ARCH/x86" "before"
12894        fi
12895        # .NET 4.6 and higher don't have bin directory
12896        if test -f "$DOTNET_FRAMEWORK_HOME/bin"; then
12897            pathmunge "$DOTNET_FRAMEWORK_HOME/bin" "before"
12898        fi
12899        pathmunge "$WINDOWS_SDK_HOME/bin" "before"
12900        pathmunge "$CSC_PATH" "before"
12901        pathmunge "$MIDL_PATH" "before"
12902        pathmunge "$AL_PATH" "before"
12903        pathmunge "$MSPDB_PATH" "before"
12904        if test "$MSPDB_PATH" != "$CL_PATH" ; then
12905            pathmunge "$CL_PATH" "before"
12906        fi
12907        if test -n "$MSBUILD_PATH" ; then
12908            pathmunge "$MSBUILD_PATH" "before"
12909        fi
12910        if test "$BITNESS_OVERRIDE" = 64; then
12911            pathmunge "$COMPATH/bin/amd64" "before"
12912            pathmunge "$WINDOWS_SDK_BINDIR_NO_ARCH/x64" "before"
12913        else
12914            pathmunge "$COMPATH/bin" "before"
12915            pathmunge "$WINDOWS_SDK_BINDIR_NO_ARCH/x86" "before"
12916        fi
12917        if test "$ENABLE_JAVA" != ""; then
12918            if test -d "$JAVA_HOME/jre/bin/client"; then
12919                pathmunge "$JAVA_HOME/jre/bin/client" "before"
12920            fi
12921            if test -d "$JAVA_HOME/jre/bin/hotspot"; then
12922                pathmunge "$JAVA_HOME/jre/bin/hotspot" "before"
12923            fi
12924            pathmunge "$JAVA_HOME/bin" "before"
12925        fi
12926        ;;
12927
12928    solaris*)
12929        pathmunge "/usr/css/bin" "before"
12930        if test "$ENABLE_JAVA" != ""; then
12931            pathmunge "$JAVA_HOME/bin" "after"
12932        fi
12933        ;;
12934    esac
12935fi
12936
12937AC_SUBST(LO_PATH)
12938
12939libo_FUZZ_SUMMARY
12940
12941# Generate a configuration sha256 we can use for deps
12942if test -f config_host.mk; then
12943    config_sha256=`$SHA256SUM config_host.mk | sed "s/ .*//"`
12944fi
12945if test -f config_host_lang.mk; then
12946    config_lang_sha256=`$SHA256SUM config_host_lang.mk | sed "s/ .*//"`
12947fi
12948
12949CFLAGS=$my_original_CFLAGS
12950CXXFLAGS=$my_original_CXXFLAGS
12951CPPFLAGS=$my_original_CPPFLAGS
12952
12953AC_CONFIG_FILES([config_host.mk
12954                 config_host_lang.mk
12955                 Makefile
12956                 bin/bffvalidator.sh
12957                 bin/odfvalidator.sh
12958                 bin/officeotron.sh
12959                 instsetoo_native/util/openoffice.lst
12960                 sysui/desktop/macosx/Info.plist])
12961AC_CONFIG_HEADERS([config_host/config_buildid.h])
12962AC_CONFIG_HEADERS([config_host/config_clang.h])
12963AC_CONFIG_HEADERS([config_host/config_dconf.h])
12964AC_CONFIG_HEADERS([config_host/config_eot.h])
12965AC_CONFIG_HEADERS([config_host/config_extensions.h])
12966AC_CONFIG_HEADERS([config_host/config_cairo_canvas.h])
12967AC_CONFIG_HEADERS([config_host/config_cxxabi.h])
12968AC_CONFIG_HEADERS([config_host/config_dbus.h])
12969AC_CONFIG_HEADERS([config_host/config_features.h])
12970AC_CONFIG_HEADERS([config_host/config_feature_desktop.h])
12971AC_CONFIG_HEADERS([config_host/config_feature_opencl.h])
12972AC_CONFIG_HEADERS([config_host/config_firebird.h])
12973AC_CONFIG_HEADERS([config_host/config_folders.h])
12974AC_CONFIG_HEADERS([config_host/config_fuzzers.h])
12975AC_CONFIG_HEADERS([config_host/config_gio.h])
12976AC_CONFIG_HEADERS([config_host/config_global.h])
12977AC_CONFIG_HEADERS([config_host/config_gpgme.h])
12978AC_CONFIG_HEADERS([config_host/config_java.h])
12979AC_CONFIG_HEADERS([config_host/config_langs.h])
12980AC_CONFIG_HEADERS([config_host/config_lgpl.h])
12981AC_CONFIG_HEADERS([config_host/config_libcxx.h])
12982AC_CONFIG_HEADERS([config_host/config_liblangtag.h])
12983AC_CONFIG_HEADERS([config_host/config_libnumbertext.h])
12984AC_CONFIG_HEADERS([config_host/config_locales.h])
12985AC_CONFIG_HEADERS([config_host/config_mpl.h])
12986AC_CONFIG_HEADERS([config_host/config_oox.h])
12987AC_CONFIG_HEADERS([config_host/config_options.h])
12988AC_CONFIG_HEADERS([config_host/config_options_calc.h])
12989AC_CONFIG_HEADERS([config_host/config_qrcodegen.h])
12990AC_CONFIG_HEADERS([config_host/config_typesizes.h])
12991AC_CONFIG_HEADERS([config_host/config_vendor.h])
12992AC_CONFIG_HEADERS([config_host/config_vcl.h])
12993AC_CONFIG_HEADERS([config_host/config_vclplug.h])
12994AC_CONFIG_HEADERS([config_host/config_version.h])
12995AC_CONFIG_HEADERS([config_host/config_oauth2.h])
12996AC_CONFIG_HEADERS([config_host/config_poppler.h])
12997AC_CONFIG_HEADERS([config_host/config_python.h])
12998AC_CONFIG_HEADERS([config_host/config_writerperfect.h])
12999AC_OUTPUT
13000
13001if test "$CROSS_COMPILING" = TRUE; then
13002    (echo; echo export BUILD_TYPE_FOR_HOST=$BUILD_TYPE) >>config_build.mk
13003fi
13004
13005# touch the config timestamp file
13006if test ! -f config_host.mk.stamp; then
13007    echo > config_host.mk.stamp
13008elif test "$config_sha256" = `$SHA256SUM config_host.mk | sed "s/ .*//"`; then
13009    echo "Host Configuration unchanged - avoiding scp2 stamp update"
13010else
13011    echo > config_host.mk.stamp
13012fi
13013
13014# touch the config lang timestamp file
13015if test ! -f config_host_lang.mk.stamp; then
13016    echo > config_host_lang.mk.stamp
13017elif test "$config_lang_sha256" = `$SHA256SUM config_host_lang.mk | sed "s/ .*//"`; then
13018    echo "Language Configuration unchanged - avoiding scp2 stamp update"
13019else
13020    echo > config_host_lang.mk.stamp
13021fi
13022
13023
13024if test \( "$STALE_MAKE" = "TRUE" -o "$HAVE_GNUMAKE_FILE_FUNC" != "TRUE" \) \
13025        -a "$build_os" = "cygwin"; then
13026
13027cat << _EOS
13028****************************************************************************
13029WARNING:
13030Your make version is known to be horribly slow, and hard to debug
13031problems with. To get a reasonably functional make please do:
13032
13033to install a pre-compiled binary make for Win32
13034
13035 mkdir -p /opt/lo/bin
13036 cd /opt/lo/bin
13037 wget https://dev-www.libreoffice.org/bin/cygwin/make-4.2.1-msvc.exe
13038 cp make-4.2.1-msvc.exe make
13039 chmod +x make
13040
13041to install from source:
13042place yourself in a working directory of you choice.
13043
13044 git clone git://git.savannah.gnu.org/make.git
13045
13046 [go to Start menu, open "Visual Studio 2017", click "VS2017 x86 Native Tools Command Prompt" or "VS2017 x64 Native Tools Command Prompt"]
13047 set PATH=%PATH%;C:\Cygwin\bin
13048 [or Cygwin64, if that is what you have]
13049 cd path-to-make-repo-you-cloned-above
13050 build_w32.bat --without-guile
13051
13052should result in a WinRel/gnumake.exe.
13053Copy it to the Cygwin /opt/lo/bin directory as make.exe
13054
13055Then re-run autogen.sh
13056
13057Note: autogen.sh will try to use /opt/lo/bin/make if the environment variable GNUMAKE is not already defined.
13058Alternatively, you can install the 'new' make where ever you want and make sure that `which make` finds it.
13059
13060_EOS
13061if test "$HAVE_GNUMAKE_FILE_FUNC" != "TRUE"; then
13062    AC_MSG_ERROR([no file function found; the build will fail without it; use GNU make 4.0 or later])
13063fi
13064fi
13065
13066
13067cat << _EOF
13068****************************************************************************
13069
13070To build, run:
13071$GNUMAKE
13072
13073To view some help, run:
13074$GNUMAKE help
13075
13076_EOF
13077
13078if test $_os != WINNT -a "$CROSS_COMPILING" != TRUE; then
13079    cat << _EOF
13080After the build of LibreOffice has finished successfully, you can immediately run LibreOffice using the command:
13081_EOF
13082
13083    if test $_os = Darwin; then
13084        echo open instdir/$PRODUCTNAME.app
13085    else
13086        echo instdir/program/soffice
13087    fi
13088    cat << _EOF
13089
13090If you want to run the smoketest, run:
13091$GNUMAKE check
13092
13093_EOF
13094fi
13095
13096if test -f warn; then
13097    cat warn
13098    rm warn
13099fi
13100
13101dnl vim:set shiftwidth=4 softtabstop=4 expandtab:
13102