xref: /core/configure.ac (revision b4141cad)
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.0.0.alpha0+],[],[],[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
28BUILD_TYPE="LibO"
29SCPDEFS=""
30GIT_NEEDED_SUBMODULES=""
31LO_PATH= # used by path_munge to construct a PATH variable
32
33FilterLibs()
34{
35    filteredlibs=
36    for f in $1; do
37        case "$f" in
38            # let's start with Fedora's paths for now
39            -L/lib|-L/lib/|-L/lib64|-L/lib64/|-L/usr/lib|-L/usr/lib/|-L/usr/lib64|-L/usr/lib64/)
40                # ignore it: on UNIXoids it is searched by default anyway
41                # but if it's given explicitly then it may override other paths
42                # (on macOS it would be an error to use it instead of SDK)
43                ;;
44            *)
45                filteredlibs="$filteredlibs $f"
46                ;;
47        esac
48    done
49}
50
51PathFormat()
52{
53    formatted_path="$1"
54    if test "$build_os" = "cygwin"; then
55        pf_conv_to_dos=
56        # spaces,parentheses,brackets,braces are problematic in pathname
57        # so are backslashes
58        case "$formatted_path" in
59            *\ * | *\)* | *\(* | *\{* | *\}* | *\[* | *\]* | *\\* )
60                pf_conv_to_dos="yes"
61            ;;
62        esac
63        if test "$pf_conv_to_dos" = "yes"; then
64            if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
65                formatted_path=`cygpath -sm "$formatted_path"`
66            else
67                formatted_path=`cygpath -d "$formatted_path"`
68            fi
69            if test $? -ne 0;  then
70                AC_MSG_ERROR([path conversion failed for "$1".])
71            fi
72        fi
73        fp_count_colon=`echo "$formatted_path" | $GREP -c "[:]"`
74        fp_count_slash=`echo "$formatted_path" | $GREP -c "[/]"`
75        if test "$fp_count_slash$fp_count_colon" != "00"; then
76            if test "$fp_count_colon" = "0"; then
77                new_formatted_path=`realpath "$formatted_path"`
78                if test $? -ne 0;  then
79                    AC_MSG_WARN([realpath failed for "$1", not necessarily a problem.])
80                else
81                    formatted_path="$new_formatted_path"
82                fi
83            fi
84            formatted_path=`cygpath -m "$formatted_path"`
85            if test $? -ne 0;  then
86                AC_MSG_ERROR([path conversion failed for "$1".])
87            fi
88        fi
89        fp_count_space=`echo "$formatted_path" | $GREP -c "[ ]"`
90        if test "$fp_count_space" != "0"; then
91            AC_MSG_ERROR([converted path "$formatted_path" still contains spaces. Short filenames (8.3 filenames) support was disabled on this system?])
92        fi
93    fi
94}
95
96AbsolutePath()
97{
98    # There appears to be no simple and portable method to get an absolute and
99    # canonical path, so we try creating the directory if does not exist and
100    # utilizing the shell and pwd.
101    rel="$1"
102    absolute_path=""
103    test ! -e "$rel" && mkdir -p "$rel"
104    if test -d "$rel" ; then
105        cd "$rel" || AC_MSG_ERROR([absolute path resolution failed for "$rel".])
106        absolute_path="$(pwd)"
107        cd - > /dev/null
108    else
109        AC_MSG_ERROR([Failed to resolve absolute path.  "$rel" does not exist or is not a directory.])
110    fi
111}
112
113rm -f warn
114have_WARNINGS="no"
115add_warning()
116{
117    if test "$have_WARNINGS" = "no"; then
118        echo "*************************************" > warn
119        have_WARNINGS="yes"
120        if which tput >/dev/null && test "`tput colors 2>/dev/null || echo 0`" -ge 8; then
121            dnl <esc> as actual byte (U+1b), [ escaped using quadrigraph @<:@
122            COLORWARN='*@<:@1;33;40m WARNING @<:@0m:'
123        else
124            COLORWARN="* WARNING :"
125        fi
126    fi
127    echo "$COLORWARN $@" >> warn
128}
129
130dnl Some Mac User have the bad habit of letting a lot of crap
131dnl accumulate in their PATH and even adding stuff in /usr/local/bin
132dnl that confuse the build.
133dnl For the ones that use LODE, let's be nice and protect them
134dnl from themselves
135
136mac_sanitize_path()
137{
138    mac_path="$LODE_HOME/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin"
139dnl a common but nevertheless necessary thing that may be in a fancy
140dnl path location is git, so make sure we have it
141    mac_git_path=`which git 2>/dev/null`
142    if test -n "$mac_git_path" -a -x "$mac_git_path" -a "$mac_git_path" != "/usr/bin/git" ; then
143        mac_path="$mac_path:`dirname $mac_git_path`"
144    fi
145dnl a not so common but nevertheless quite helpful thing that may be in a fancy
146dnl path location is gpg, so make sure we find it
147    mac_gpg_path=`which gpg 2>/dev/null`
148    if test -n "$mac_gpg_path" -a -x "$mac_gpg_path" -a "$mac_gpg_path" != "/usr/bin/gpg" ; then
149        mac_path="$mac_path:`dirname $mac_gpg_path`"
150    fi
151    PATH="$mac_path"
152    unset mac_path
153    unset mac_git_path
154    unset mac_gpg_path
155}
156
157echo "********************************************************************"
158echo "*"
159echo "*   Running ${PACKAGE_NAME} build configuration."
160echo "*"
161echo "********************************************************************"
162echo ""
163
164dnl ===================================================================
165dnl checks build and host OSes
166dnl do this before argument processing to allow for platform dependent defaults
167dnl ===================================================================
168AC_CANONICAL_HOST
169
170AC_MSG_CHECKING([for product name])
171PRODUCTNAME="AC_PACKAGE_NAME"
172if test -n "$with_product_name" -a "$with_product_name" != no; then
173    PRODUCTNAME="$with_product_name"
174fi
175if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
176    PRODUCTNAME="${PRODUCTNAME}Dev"
177fi
178AC_MSG_RESULT([$PRODUCTNAME])
179AC_SUBST(PRODUCTNAME)
180PRODUCTNAME_WITHOUT_SPACES=$(printf %s "$PRODUCTNAME" | sed 's/ //g')
181AC_SUBST(PRODUCTNAME_WITHOUT_SPACES)
182
183dnl ===================================================================
184dnl Our version is defined by the AC_INIT() at the top of this script.
185dnl ===================================================================
186
187AC_MSG_CHECKING([for package version])
188if test -n "$with_package_version" -a "$with_package_version" != no; then
189    PACKAGE_VERSION="$with_package_version"
190fi
191AC_MSG_RESULT([$PACKAGE_VERSION])
192
193set `echo "$PACKAGE_VERSION" | sed "s/\./ /g"`
194
195LIBO_VERSION_MAJOR=$1
196LIBO_VERSION_MINOR=$2
197LIBO_VERSION_MICRO=$3
198LIBO_VERSION_PATCH=$4
199
200# The CFBundleShortVersionString in Info.plist consists of three integers, so encode the third
201# as the micro version times 1000 plus the patch number. Unfortunately the LIBO_VERSION_SUFFIX can be anything so
202# no way to encode that into an integer in general.
203MACOSX_BUNDLE_SHORTVERSION=$LIBO_VERSION_MAJOR.$LIBO_VERSION_MINOR.`expr $LIBO_VERSION_MICRO '*' 1000 + $LIBO_VERSION_PATCH`
204
205LIBO_VERSION_SUFFIX=$5
206# Split out LIBO_VERSION_SUFFIX_SUFFIX... horrible crack. But apparently wanted separately in
207# openoffice.lst as ABOUTBOXPRODUCTVERSIONSUFFIX. Note that the double brackets are for m4's sake,
208# they get undoubled before actually passed to sed.
209LIBO_VERSION_SUFFIX_SUFFIX=`echo "$LIBO_VERSION_SUFFIX" | sed -e 's/.*[[a-zA-Z0-9]]\([[^a-zA-Z0-9]]*\)$/\1/'`
210test -n "$LIBO_VERSION_SUFFIX_SUFFIX" && LIBO_VERSION_SUFFIX="${LIBO_VERSION_SUFFIX%${LIBO_VERSION_SUFFIX_SUFFIX}}"
211# LIBO_VERSION_SUFFIX, if non-empty, should include the period separator
212test -n "$LIBO_VERSION_SUFFIX" && LIBO_VERSION_SUFFIX=".$LIBO_VERSION_SUFFIX"
213
214AC_SUBST(LIBO_VERSION_MAJOR)
215AC_SUBST(LIBO_VERSION_MINOR)
216AC_SUBST(LIBO_VERSION_MICRO)
217AC_SUBST(LIBO_VERSION_PATCH)
218AC_SUBST(MACOSX_BUNDLE_SHORTVERSION)
219AC_SUBST(LIBO_VERSION_SUFFIX)
220AC_SUBST(LIBO_VERSION_SUFFIX_SUFFIX)
221
222AC_DEFINE_UNQUOTED(LIBO_VERSION_MAJOR,$LIBO_VERSION_MAJOR)
223AC_DEFINE_UNQUOTED(LIBO_VERSION_MINOR,$LIBO_VERSION_MINOR)
224AC_DEFINE_UNQUOTED(LIBO_VERSION_MICRO,$LIBO_VERSION_MICRO)
225AC_DEFINE_UNQUOTED(LIBO_VERSION_PATCH,$LIBO_VERSION_PATCH)
226
227LIBO_THIS_YEAR=`date +%Y`
228AC_DEFINE_UNQUOTED(LIBO_THIS_YEAR,$LIBO_THIS_YEAR)
229
230dnl ===================================================================
231dnl Product version
232dnl ===================================================================
233AC_MSG_CHECKING([for product version])
234PRODUCTVERSION="$LIBO_VERSION_MAJOR.$LIBO_VERSION_MINOR"
235AC_MSG_RESULT([$PRODUCTVERSION])
236AC_SUBST(PRODUCTVERSION)
237
238AC_PROG_EGREP
239# AC_PROG_EGREP doesn't set GREP on all systems as well
240AC_PATH_PROG(GREP, grep)
241
242BUILDDIR=`pwd`
243cd $srcdir
244SRC_ROOT=`pwd`
245cd $BUILDDIR
246x_Cygwin=[\#]
247
248dnl ======================================
249dnl Required GObject introspection version
250dnl ======================================
251INTROSPECTION_REQUIRED_VERSION=1.32.0
252
253dnl ===================================================================
254dnl Search all the common names for GNU Make
255dnl ===================================================================
256AC_MSG_CHECKING([for GNU Make])
257
258# try to use our own make if it is available and GNUMAKE was not already defined
259if test -z "$GNUMAKE"; then
260    if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/make" ; then
261        GNUMAKE="$LODE_HOME/opt/bin/make"
262    elif test -x "/opt/lo/bin/make"; then
263        GNUMAKE="/opt/lo/bin/make"
264    fi
265fi
266
267GNUMAKE_WIN_NATIVE=
268for a in "$MAKE" "$GNUMAKE" make gmake gnumake; do
269    if test -n "$a"; then
270        $a --version 2> /dev/null | grep GNU  2>&1 > /dev/null
271        if test $? -eq 0;  then
272            if test "$build_os" = "cygwin"; then
273                if test -n "$($a -v | grep 'Built for Windows')" ; then
274                    GNUMAKE="$(cygpath -m "$(which "$(cygpath -u $a)")")"
275                    GNUMAKE_WIN_NATIVE="TRUE"
276                else
277                    GNUMAKE=`which $a`
278                fi
279            else
280                GNUMAKE=`which $a`
281            fi
282            break
283        fi
284    fi
285done
286AC_MSG_RESULT($GNUMAKE)
287if test -z "$GNUMAKE"; then
288    AC_MSG_ERROR([not found. install GNU Make.])
289else
290    if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
291        AC_MSG_NOTICE([Using a native Win32 GNU Make version.])
292    fi
293fi
294
295win_short_path_for_make()
296{
297    local_short_path="$1"
298    if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
299        cygpath -sm "$local_short_path"
300    else
301        cygpath -u "$(cygpath -d "$local_short_path")"
302    fi
303}
304
305
306if test "$build_os" = "cygwin"; then
307    PathFormat "$SRC_ROOT"
308    SRC_ROOT="$formatted_path"
309    PathFormat "$BUILDDIR"
310    BUILDDIR="$formatted_path"
311    x_Cygwin=
312    AC_MSG_CHECKING(for explicit COMSPEC)
313    if test -z "$COMSPEC"; then
314        AC_MSG_ERROR([COMSPEC not set in environment, please set it and rerun])
315    else
316        AC_MSG_RESULT([found: $COMSPEC])
317    fi
318fi
319
320AC_SUBST(SRC_ROOT)
321AC_SUBST(BUILDDIR)
322AC_SUBST(x_Cygwin)
323AC_DEFINE_UNQUOTED(SRCDIR,"$SRC_ROOT")
324AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
325
326if test "z$EUID" = "z0" -a "`uname -o 2>/dev/null`" = "Cygwin"; then
327    AC_MSG_ERROR([You must build LibreOffice as a normal user - not using an administrative account])
328fi
329
330# need sed in os checks...
331AC_PATH_PROGS(SED, sed)
332if test -z "$SED"; then
333    AC_MSG_ERROR([install sed to run this script])
334fi
335
336# Set the ENABLE_LTO variable
337# ===================================================================
338AC_MSG_CHECKING([whether to use link-time optimization])
339if test -n "$enable_lto" -a "$enable_lto" != "no"; then
340    ENABLE_LTO="TRUE"
341    AC_MSG_RESULT([yes])
342    AC_DEFINE(STATIC_LINKING)
343else
344    ENABLE_LTO=""
345    AC_MSG_RESULT([no])
346fi
347AC_SUBST(ENABLE_LTO)
348
349AC_ARG_ENABLE(fuzz-options,
350    AS_HELP_STRING([--enable-fuzz-options],
351        [Randomly enable or disable each of those configurable options
352         that are supposed to be freely selectable without interdependencies,
353         or where bad interaction from interdependencies is automatically avoided.])
354)
355
356dnl ===================================================================
357dnl When building for Android, --with-android-ndk,
358dnl --with-android-ndk-toolchain-version and --with-android-sdk are
359dnl mandatory
360dnl ===================================================================
361
362AC_ARG_WITH(android-ndk,
363    AS_HELP_STRING([--with-android-ndk],
364        [Specify location of the Android Native Development Kit. Mandatory when building for Android.]),
365,)
366
367AC_ARG_WITH(android-ndk-toolchain-version,
368    AS_HELP_STRING([--with-android-ndk-toolchain-version],
369        [Specify which toolchain version to use, of those present in the
370        Android NDK you are using. The default (and only supported version currently) is "clang5.0"]),,
371        with_android_ndk_toolchain_version=clang5.0)
372
373AC_ARG_WITH(android-sdk,
374    AS_HELP_STRING([--with-android-sdk],
375        [Specify location of the Android SDK. Mandatory when building for Android.]),
376,)
377
378ANDROID_NDK_HOME=
379if test -z "$with_android_ndk" -a -e "$SRC_ROOT/external/android-ndk" -a "$build" != "$host"; then
380    with_android_ndk="$SRC_ROOT/external/android-ndk"
381fi
382if test -n "$with_android_ndk"; then
383    ANDROID_NDK_HOME=$with_android_ndk
384
385    # Set up a lot of pre-canned defaults
386
387    if test ! -f $ANDROID_NDK_HOME/RELEASE.TXT; then
388        if test ! -f $ANDROID_NDK_HOME/source.properties; then
389            AC_MSG_ERROR([Unrecognized Android NDK. Missing RELEASE.TXT or source.properties file in $ANDROID_NDK_HOME.])
390        fi
391        ANDROID_NDK_VERSION=`sed -n -e 's/Pkg.Revision = //p' $ANDROID_NDK_HOME/source.properties`
392    else
393        ANDROID_NDK_VERSION=`cut -f1 -d' ' <$ANDROID_NDK_HOME/RELEASE.TXT`
394    fi
395    if test -z "$ANDROID_NDK_VERSION";  then
396        AC_MSG_ERROR([Failed to determine Android NDK version. Please check your installation.])
397    fi
398    case $ANDROID_NDK_VERSION in
399    r9*|r10*)
400        AC_MSG_ERROR([Building for Android is only supported with NDK versions above 16.x*])
401        ;;
402    11.1.*|12.1.*|13.1.*|14.1.*)
403        AC_MSG_ERROR([Building for Android is only supported with NDK versions above 16.x.*])
404        ;;
405    16.*)
406        ;;
407    *)
408        AC_MSG_WARN([Untested Android NDK version $ANDROID_NDK_VERSION, only version 16.* have been used successfully. Proceed at your own risk.])
409        add_warning "Untested Android NDK version $ANDROID_NDK_VERSION, only version 16.* have been used successfully. Proceed at your own risk."
410        ;;
411    esac
412
413    ANDROID_API_LEVEL=14
414    android_cpu=$host_cpu
415    ANDROID_ARCH=$android_cpu
416    if test $host_cpu = arm; then
417        android_platform_prefix=$android_cpu-linux-androideabi
418        android_gnu_prefix=$android_platform_prefix
419        LLVM_TRIPLE=armv7-none-linux-androideabi
420        ANDROID_APP_ABI=armeabi-v7a
421        ANDROIDCFLAGS="-mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -Wl,--fix-cortex-a8"
422    elif test $host_cpu = aarch64; then
423        android_platform_prefix=$android_cpu-linux-android
424        android_gnu_prefix=$android_platform_prefix
425        LLVM_TRIPLE=aarch64-none-linux-android
426        # minimum android version that supports aarch64
427        ANDROID_API_LEVEL=21
428        ANDROID_APP_ABI=arm64-v8a
429        ANDROID_ARCH=arm64
430    elif test $host_cpu = mips; then
431        android_platform_prefix=mipsel-linux-android
432        android_gnu_prefix=$android_platform_prefix
433        LLVM_TRIPLE=mipsel-none-linux-android
434        ANDROID_APP_ABI=mips
435    else
436        # host_cpu is something like "i386" or "i686" I guess, NDK uses
437        # "x86" in some contexts
438        android_cpu=x86
439        android_platform_prefix=$android_cpu
440        android_gnu_prefix=i686-linux-android
441        LLVM_TRIPLE=i686-none-linux-android
442        ANDROID_APP_ABI=x86
443        ANDROID_ARCH=$android_cpu
444        ANDROIDCFLAGS="-march=atom"
445    fi
446
447    case "$with_android_ndk_toolchain_version" in
448    clang5.0)
449        ANDROID_GCC_TOOLCHAIN_VERSION=4.9
450        ANDROID_BINUTILS_DIR=$ANDROID_NDK_HOME/toolchains/$android_platform_prefix-$ANDROID_GCC_TOOLCHAIN_VERSION
451        ANDROID_COMPILER_DIR=$ANDROID_NDK_HOME/toolchains/llvm
452        ;;
453    *)
454        AC_MSG_ERROR([Unrecognized value for the --with-android-ndk-toolchain-version option. Building for Android is only supported with Clang 5.*])
455    esac
456
457    if test ! -d $ANDROID_BINUTILS_DIR; then
458        AC_MSG_ERROR([No directory $ANDROID_BINUTILS_DIR])
459    elif test ! -d $ANDROID_COMPILER_DIR; then
460        AC_MSG_ERROR([No directory $ANDROID_COMPILER_DIR])
461    fi
462
463    # NDK 15 or later toolchain is 64bit-only, except for Windows that we don't support. Using a 64-bit
464    # linker is required if you compile large parts of the code with -g. A 32-bit linker just won't
465    # manage to link the (app-specific) single huge .so that is built for the app in
466    # android/source/ if there is debug information in a significant part of the object files.
467    # (A 64-bit ld.gold grows too much over 10 gigabytes of virtual space when linking such a .so if
468    # all objects have been built with debug information.)
469    case $build_os in
470    linux-gnu*)
471        ndk_build_os=linux
472        ;;
473    darwin*)
474        ndk_build_os=darwin
475        ;;
476    *)
477        AC_MSG_ERROR([We only support building for Android from Linux or macOS])
478        ;;
479    esac
480    ANDROID_COMPILER_BIN=$ANDROID_COMPILER_DIR/prebuilt/$ndk_build_os-x86_64/bin
481    ANDROID_BINUTILS_PREBUILT_ROOT=$ANDROID_BINUTILS_DIR/prebuilt/$ndk_build_os-x86_64
482    AC_SUBST(ANDROID_BINUTILS_PREBUILT_ROOT)
483
484    test -z "$SYSBASE" && SYSBASE=$ANDROID_NDK_HOME/platforms/android-${ANDROID_API_LEVEL}/arch-${ANDROID_ARCH}
485    test -z "$AR" && AR=$ANDROID_BINUTILS_PREBUILT_ROOT/bin/$android_gnu_prefix-ar
486    test -z "$NM" && NM=$ANDROID_BINUTILS_PREBUILT_ROOT/bin/$android_gnu_prefix-nm
487    test -z "$OBJDUMP" && OBJDUMP=$ANDROID_BINUTILS_PREBUILT_ROOT/bin/$android_gnu_prefix-objdump
488    test -z "$RANLIB" && RANLIB=$ANDROID_BINUTILS_PREBUILT_ROOT/bin/$android_gnu_prefix-ranlib
489    test -z "$STRIP" && STRIP=$ANDROID_BINUTILS_PREBUILT_ROOT/bin/$android_gnu_prefix-strip
490
491    ANDROIDCFLAGS="$ANDROIDCFLAGS -gcc-toolchain $ANDROID_BINUTILS_PREBUILT_ROOT -target $LLVM_TRIPLE$ANDROID_API_LEVEL -no-canonical-prefixes"
492    # android is using different sysroots for compilation and linking, but as
493    # there is no full separation in configure and elsewhere, use isystem for
494    # compilation stuff and sysroot for linking
495    ANDROIDCFLAGS="$ANDROIDCFLAGS -D__ANDROID_API__=$ANDROID_API_LEVEL -isystem $ANDROID_NDK_HOME/sysroot/usr/include"
496    ANDROIDCFLAGS="$ANDROIDCFLAGS -isystem $ANDROID_NDK_HOME/sysroot/usr/include/$android_gnu_prefix"
497    ANDROIDCFLAGS="$ANDROIDCFLAGS --sysroot=$SYSBASE -ffunction-sections -fdata-sections -Qunused-arguments"
498    ANDROIDCFLAGS="$ANDROIDCFLAGS -L$ANDROID_NDK_HOME/sources/cxx-stl/llvm-libc++/libs/$ANDROID_APP_ABI"
499    if test "$ENABLE_LTO" = TRUE; then
500        # -flto comes from com_GCC_defs.mk, too, but we need to make sure it gets passed as part of
501        # $CC and $CXX when building external libraries
502        ANDROIDCFLAGS="$ANDROIDCFLAGS -flto -fuse-linker-plugin -O2"
503    fi
504
505    ANDROIDCXXFLAGS="$ANDROIDCFLAGS -I$ANDROID_NDK_HOME/sources/cxx-stl/llvm-libc++/include -I$ANDROID_NDK_HOME/sources/cxx-stl/llvm-libc++abi/include -I$ANDROID_NDK_HOME/sources/android/support/include -std=c++11"
506
507    if test -z "$CC"; then
508        CC="$ANDROID_COMPILER_BIN/clang $ANDROIDCFLAGS"
509    fi
510    if test -z "$CXX"; then
511        CXX="$ANDROID_COMPILER_BIN/clang++ $ANDROIDCXXFLAGS"
512    fi
513
514    # remember to download the ownCloud Android library later
515    BUILD_TYPE="$BUILD_TYPE OWNCLOUD_ANDROID_LIB"
516fi
517AC_SUBST(ANDROID_NDK_HOME)
518AC_SUBST(ANDROID_APP_ABI)
519AC_SUBST(ANDROID_GCC_TOOLCHAIN_VERSION)
520
521dnl ===================================================================
522dnl --with-android-sdk
523dnl ===================================================================
524ANDROID_SDK_HOME=
525if test -z "$with_android_sdk" -a -e "$SRC_ROOT/external/android-sdk-linux" -a "$build" != "$host"; then
526    with_android_sdk="$SRC_ROOT/external/android-sdk-linux"
527fi
528if test -n "$with_android_sdk"; then
529    ANDROID_SDK_HOME=$with_android_sdk
530    PATH="$ANDROID_SDK_HOME/platform-tools:$ANDROID_SDK_HOME/tools:$PATH"
531fi
532AC_SUBST(ANDROID_SDK_HOME)
533
534libo_FUZZ_ARG_ENABLE([android-editing],
535    AS_HELP_STRING([--enable-android-editing],
536        [Enable the experimental editing feature on Android.])
537)
538ENABLE_ANDROID_EDITING=
539if test "$enable_android_editing" = yes; then
540    ENABLE_ANDROID_EDITING=TRUE
541fi
542AC_SUBST([ENABLE_ANDROID_EDITING])
543
544dnl ===================================================================
545dnl The following is a list of supported systems.
546dnl Sequential to keep the logic very simple
547dnl These values may be checked and reset later.
548dnl ===================================================================
549#defaults unless the os test overrides this:
550test_randr=yes
551test_xrender=yes
552test_cups=yes
553test_dbus=yes
554test_fontconfig=yes
555test_cairo=no
556test_gdb_index=no
557test_split_debug=no
558
559# Default values, as such probably valid just for Linux, set
560# differently below just for Mac OSX, but at least better than
561# hardcoding these as we used to do. Much of this is duplicated also
562# in solenv for old build system and for gbuild, ideally we should
563# perhaps define stuff like this only here in configure.ac?
564
565LINKFLAGSSHL="-shared"
566PICSWITCH="-fpic"
567DLLPOST=".so"
568
569LINKFLAGSNOUNDEFS="-Wl,-z,defs"
570
571INSTROOTBASESUFFIX=
572INSTROOTCONTENTSUFFIX=
573SDKDIRNAME=sdk
574
575case "$host_os" in
576
577solaris*)
578    test_gtk=yes
579    build_gstreamer_1_0=yes
580    test_freetype=yes
581    _os=SunOS
582
583    dnl ===========================================================
584    dnl Check whether we're using Solaris 10 - SPARC or Intel.
585    dnl ===========================================================
586    AC_MSG_CHECKING([the Solaris operating system release])
587    _os_release=`echo $host_os | $SED -e s/solaris2\.//`
588    if test "$_os_release" -lt "10"; then
589        AC_MSG_ERROR([use Solaris >= 10 to build LibreOffice])
590    else
591        AC_MSG_RESULT([ok ($_os_release)])
592    fi
593
594    dnl Check whether we're using a SPARC or i386 processor
595    AC_MSG_CHECKING([the processor type])
596    if test "$host_cpu" = "sparc" -o "$host_cpu" = "i386"; then
597        AC_MSG_RESULT([ok ($host_cpu)])
598    else
599        AC_MSG_ERROR([only SPARC and i386 processors are supported])
600    fi
601    ;;
602
603linux-gnu*|k*bsd*-gnu*)
604    test_gtk=yes
605    build_gstreamer_1_0=yes
606    test_kde5=yes
607    test_gtk3_kde5=yes
608    test_gdb_index=yes
609    test_split_debug=yes
610    if test "$enable_fuzzers" != yes; then
611        test_freetype=yes
612        test_fontconfig=yes
613    else
614        test_freetype=no
615        test_fontconfig=no
616        BUILD_TYPE="$BUILD_TYPE FONTCONFIG FREETYPE"
617    fi
618    _os=Linux
619    ;;
620
621gnu)
622    test_randr=no
623    test_xrender=no
624    _os=GNU
625     ;;
626
627cygwin*|interix*)
628
629    # When building on Windows normally with MSVC under Cygwin,
630    # configure thinks that the host platform (the platform the
631    # built code will run on) is Cygwin, even if it obviously is
632    # Windows, which in Autoconf terminology is called
633    # "mingw32". (Which is misleading as MinGW is the name of the
634    # tool-chain, not an operating system.)
635
636    # Somewhat confusing, yes. But this configure script doesn't
637    # look at $host etc that much, it mostly uses its own $_os
638    # variable, set here in this case statement.
639
640    test_cups=no
641    test_dbus=no
642    test_randr=no
643    test_xrender=no
644    test_freetype=no
645    test_fontconfig=no
646    _os=WINNT
647
648    DLLPOST=".dll"
649    LINKFLAGSNOUNDEFS=
650    ;;
651
652darwin*) # macOS or iOS
653    test_gtk=yes
654    test_randr=no
655    test_xrender=no
656    test_freetype=no
657    test_fontconfig=no
658    test_dbus=no
659    if test -n "$LODE_HOME" ; then
660        mac_sanitize_path
661        AC_MSG_NOTICE([sanitized the PATH to $PATH])
662    fi
663    if test "$host_cpu" = "arm64" -o "$enable_ios_simulator" = "yes"; then
664        build_for_ios=YES
665        _os=iOS
666        test_gtk=no
667        test_cups=no
668        enable_mpl_subset=yes
669        enable_lotuswordpro=no
670        enable_coinmp=no
671        enable_lpsolve=no
672        enable_postgresql_sdbc=no
673        enable_extension_integration=no
674        enable_report_builder=no
675        with_ppds=no
676        if test "$enable_ios_simulator" = "yes"; then
677            host=x86_64-apple-darwin
678        fi
679    else
680        _os=Darwin
681        INSTROOTBASESUFFIX=/$PRODUCTNAME_WITHOUT_SPACES.app
682        INSTROOTCONTENTSUFFIX=/Contents
683        SDKDIRNAME=AC_PACKAGE_NAME${PRODUCTVERSION}_SDK
684    fi
685    # See comment above the case "$host_os"
686    LINKFLAGSSHL="-dynamiclib -single_module"
687
688    # -fPIC is default
689    PICSWITCH=""
690
691    DLLPOST=".dylib"
692
693    # -undefined error is the default
694    LINKFLAGSNOUNDEFS=""
695;;
696
697freebsd*)
698    test_gtk=yes
699    build_gstreamer_1_0=yes
700    test_kde5=yes
701    test_gtk3_kde5=yes
702    test_freetype=yes
703    AC_MSG_CHECKING([the FreeBSD operating system release])
704    if test -n "$with_os_version"; then
705        OSVERSION="$with_os_version"
706    else
707        OSVERSION=`/sbin/sysctl -n kern.osreldate`
708    fi
709    AC_MSG_RESULT([found OSVERSION=$OSVERSION])
710    AC_MSG_CHECKING([which thread library to use])
711    if test "$OSVERSION" -lt "500016"; then
712        PTHREAD_CFLAGS="-D_THREAD_SAFE"
713        PTHREAD_LIBS="-pthread"
714    elif test "$OSVERSION" -lt "502102"; then
715        PTHREAD_CFLAGS="-D_THREAD_SAFE"
716        PTHREAD_LIBS="-lc_r"
717    else
718        PTHREAD_CFLAGS=""
719        PTHREAD_LIBS="-pthread"
720    fi
721    AC_MSG_RESULT([$PTHREAD_LIBS])
722    _os=FreeBSD
723    ;;
724
725*netbsd*)
726    test_gtk=yes
727    build_gstreamer_1_0=yes
728    test_kde5=yes
729    test_gtk3_kde5=yes
730    test_freetype=yes
731    PTHREAD_LIBS="-pthread -lpthread"
732    _os=NetBSD
733    ;;
734
735aix*)
736    test_randr=no
737    test_freetype=yes
738    PTHREAD_LIBS=-pthread
739    _os=AIX
740    ;;
741
742openbsd*)
743    test_gtk=yes
744    test_freetype=yes
745    PTHREAD_CFLAGS="-D_THREAD_SAFE"
746    PTHREAD_LIBS="-pthread"
747    _os=OpenBSD
748    ;;
749
750dragonfly*)
751    test_gtk=yes
752    build_gstreamer_1_0=yes
753    test_kde5=yes
754    test_gtk3_kde5=yes
755    test_freetype=yes
756    PTHREAD_LIBS="-pthread"
757    _os=DragonFly
758    ;;
759
760linux-android*)
761    build_gstreamer_1_0=no
762    enable_lotuswordpro=no
763    enable_mpl_subset=yes
764    enable_coinmp=yes
765    enable_lpsolve=no
766    enable_report_builder=no
767    enable_odk=no
768    enable_postgresql_sdbc=no
769    enable_python=no
770    test_cups=no
771    test_dbus=no
772    test_fontconfig=no
773    test_freetype=no
774    test_gtk=no
775    test_kde5=no
776    test_gtk3_kde5=no
777    test_randr=no
778    test_xrender=no
779    _os=Android
780
781    AC_DEFINE(HAVE_FT_FACE_GETCHARVARIANTINDEX)
782    BUILD_TYPE="$BUILD_TYPE CAIRO FONTCONFIG FREETYPE"
783    ;;
784
785haiku*)
786    test_cups=no
787    test_dbus=no
788    test_randr=no
789    test_xrender=no
790    test_freetype=yes
791    enable_odk=no
792    enable_gstreamer_1_0=no
793    enable_vlc=no
794    enable_coinmp=no
795    enable_pdfium=no
796    enable_sdremote=no
797    enable_postgresql_sdbc=no
798    enable_firebird_sdbc=no
799    _os=Haiku
800    ;;
801
802*)
803    AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice for!])
804    ;;
805esac
806
807if test "$_os" = "Android" ; then
808    # Verify that the NDK and SDK options are proper
809    if test -z "$with_android_ndk"; then
810        AC_MSG_ERROR([the --with-android-ndk option is mandatory, unless it is available at external/android-ndk/.])
811    elif test ! -f "$ANDROID_NDK_HOME/platforms/android-${ANDROID_API_LEVEL}/arch-${ANDROID_ARCH}/usr/lib/libc.a"; then
812        AC_MSG_ERROR([the --with-android-ndk option does not point to an Android NDK])
813    fi
814
815    if test -z "$ANDROID_SDK_HOME"; then
816        AC_MSG_ERROR([the --with-android-sdk option is mandatory, unless it is available at external/android-sdk-linux/.])
817    elif test ! -d "$ANDROID_SDK_HOME/platforms"; then
818        AC_MSG_ERROR([the --with-android-sdk option does not point to an Android SDK])
819    fi
820
821    BUILD_TOOLS_VERSION=`$SED -n -e 's/.*buildToolsVersion "\(.*\)"/\1/p' $SRC_ROOT/android/source/build.gradle`
822    if test ! -d "$ANDROID_SDK_HOME/build-tools/$BUILD_TOOLS_VERSION"; then
823        AC_MSG_WARN([android build-tools $BUILD_TOOLS_VERSION not found - install with
824                         $ANDROID_SDK_HOME/tools/android update sdk -u --all --filter build-tools-$BUILD_TOOLS_VERSION
825                    or adjust change $SRC_ROOT/android/source/build.gradle accordingly])
826        add_warning "android build-tools $BUILD_TOOLS_VERSION not found - install with"
827        add_warning "    $ANDROID_SDK_HOME/tools/android update sdk -u --all --filter build-tools-$BUILD_TOOLS_VERSION"
828        add_warning "or adjust $SRC_ROOT/android/source/build.gradle accordingly"
829    fi
830    if test ! -f "$ANDROID_SDK_HOME/extras/android/m2repository/source.properties"; then
831        AC_MSG_WARN([android support repository not found - install with
832                         $ANDROID_SDK_HOME/tools/android update sdk -u --filter extra-android-m2repository
833                     to allow the build to download the specified version of the android support libraries])
834        add_warning "android support repository not found - install with"
835        add_warning "    $ANDROID_SDK_HOME/tools/android update sdk -u --filter extra-android-m2repository"
836        add_warning "to allow the build to download the specified version of the android support libraries"
837    fi
838fi
839
840if test "$_os" = "AIX"; then
841    AC_PATH_PROG(GAWK, gawk)
842    if test -z "$GAWK"; then
843        AC_MSG_ERROR([gawk not found in \$PATH])
844    fi
845fi
846
847AC_SUBST(SDKDIRNAME)
848
849AC_SUBST(PTHREAD_CFLAGS)
850AC_SUBST(PTHREAD_LIBS)
851
852# Check for explicit A/C/CXX/OBJC/OBJCXX/LDFLAGS.
853# By default use the ones specified by our build system,
854# but explicit override is possible.
855AC_MSG_CHECKING(for explicit AFLAGS)
856if test -n "$AFLAGS"; then
857    AC_MSG_RESULT([$AFLAGS])
858    x_AFLAGS=
859else
860    AC_MSG_RESULT(no)
861    x_AFLAGS=[\#]
862fi
863AC_MSG_CHECKING(for explicit CFLAGS)
864if test -n "$CFLAGS"; then
865    AC_MSG_RESULT([$CFLAGS])
866    x_CFLAGS=
867else
868    AC_MSG_RESULT(no)
869    x_CFLAGS=[\#]
870fi
871AC_MSG_CHECKING(for explicit CXXFLAGS)
872if test -n "$CXXFLAGS"; then
873    AC_MSG_RESULT([$CXXFLAGS])
874    x_CXXFLAGS=
875else
876    AC_MSG_RESULT(no)
877    x_CXXFLAGS=[\#]
878fi
879AC_MSG_CHECKING(for explicit OBJCFLAGS)
880if test -n "$OBJCFLAGS"; then
881    AC_MSG_RESULT([$OBJCFLAGS])
882    x_OBJCFLAGS=
883else
884    AC_MSG_RESULT(no)
885    x_OBJCFLAGS=[\#]
886fi
887AC_MSG_CHECKING(for explicit OBJCXXFLAGS)
888if test -n "$OBJCXXFLAGS"; then
889    AC_MSG_RESULT([$OBJCXXFLAGS])
890    x_OBJCXXFLAGS=
891else
892    AC_MSG_RESULT(no)
893    x_OBJCXXFLAGS=[\#]
894fi
895AC_MSG_CHECKING(for explicit LDFLAGS)
896if test -n "$LDFLAGS"; then
897    AC_MSG_RESULT([$LDFLAGS])
898    x_LDFLAGS=
899else
900    AC_MSG_RESULT(no)
901    x_LDFLAGS=[\#]
902fi
903AC_SUBST(AFLAGS)
904AC_SUBST(CFLAGS)
905AC_SUBST(CXXFLAGS)
906AC_SUBST(OBJCFLAGS)
907AC_SUBST(OBJCXXFLAGS)
908AC_SUBST(LDFLAGS)
909AC_SUBST(x_AFLAGS)
910AC_SUBST(x_CFLAGS)
911AC_SUBST(x_CXXFLAGS)
912AC_SUBST(x_OBJCFLAGS)
913AC_SUBST(x_OBJCXXFLAGS)
914AC_SUBST(x_LDFLAGS)
915
916dnl These are potentially set for MSVC, in the code checking for UCRT below:
917my_original_CFLAGS=$CFLAGS
918my_original_CXXFLAGS=$CXXFLAGS
919my_original_CPPFLAGS=$CPPFLAGS
920
921dnl The following checks for gcc, cc and then cl (if it weren't guarded for win32)
922dnl Needs to precede the AC_C_BIGENDIAN and AC_SEARCH_LIBS calls below, which apparently call
923dnl AC_PROG_CC internally.
924if test "$_os" != "WINNT"; then
925    # AC_PROG_CC sets CFLAGS to -g -O2 if not set, avoid that
926    save_CFLAGS=$CFLAGS
927    AC_PROG_CC
928    CFLAGS=$save_CFLAGS
929fi
930
931if test "$_os" != "WINNT"; then
932AC_C_BIGENDIAN([ENDIANNESS=big], [ENDIANNESS=little])
933else
934ENDIANNESS=little
935fi
936AC_SUBST(ENDIANNESS)
937
938if test $_os != "WINNT"; then
939    save_LIBS="$LIBS"
940    AC_SEARCH_LIBS([dlsym], [dl],
941        [case "$ac_cv_search_dlsym" in -l*) DLOPEN_LIBS="$ac_cv_search_dlsym";; esac],
942        [AC_MSG_ERROR([dlsym not found in either libc nor libdl])])
943    LIBS="$save_LIBS"
944fi
945AC_SUBST(DLOPEN_LIBS)
946
947AC_ARG_ENABLE(ios-simulator,
948    AS_HELP_STRING([--enable-ios-simulator],
949        [build i386 or x86_64 for ios simulator])
950)
951
952AC_ARG_ENABLE(ios-libreofficelight-app,
953    AS_HELP_STRING([--enable-ios-libreofficelight-app],
954        [When building for iOS, build stuff relevant only for the 'LibreOfficeLight' app
955         (in ios/LibreOfficeLight). Note that this app is not known to work in any useful manner,
956         and also that its actual build (in Xcode) requires some obvious modifications to the project.])
957)
958
959ENABLE_IOS_LIBREOFFICELIGHT_APP=
960if test "$enable_ios_libreofficelight_app" = yes; then
961    ENABLE_IOS_LIBREOFFICELIGHT_APP=TRUE
962fi
963AC_SUBST(ENABLE_IOS_LIBREOFFICELIGHT_APP)
964
965###############################################################################
966# Extensions switches --enable/--disable
967###############################################################################
968# By default these should be enabled unless having extra dependencies.
969# If there is extra dependency over configure options then the enable should
970# be automagic based on whether the requiring feature is enabled or not.
971# All this options change anything only with --enable-extension-integration.
972
973# The name of this option and its help string makes it sound as if
974# extensions are built anyway, just not integrated in the installer,
975# if you use --disable-extension-integration. Is that really the
976# case?
977
978libo_FUZZ_ARG_ENABLE(extension-integration,
979    AS_HELP_STRING([--disable-extension-integration],
980        [Disable integration of the built extensions in the installer of the
981         product. Use this switch to disable the integration.])
982)
983
984AC_ARG_ENABLE(avmedia,
985    AS_HELP_STRING([--disable-avmedia],
986        [Disable displaying and inserting AV media in documents. Work in progress, use only if you are hacking on it.])
987)
988
989AC_ARG_ENABLE(database-connectivity,
990    AS_HELP_STRING([--disable-database-connectivity],
991        [Disable various database connectivity. Work in progress, use only if you are hacking on it.])
992)
993
994# This doesn't mean not building (or "integrating") extensions
995# (although it probably should; i.e. it should imply
996# --disable-extension-integration I guess), it means not supporting
997# any extension mechanism at all
998libo_FUZZ_ARG_ENABLE(extensions,
999    AS_HELP_STRING([--disable-extensions],
1000        [Disable all add-on extension functionality. Work in progress, use only if you are hacking on it.])
1001)
1002
1003AC_ARG_ENABLE(scripting,
1004    AS_HELP_STRING([--disable-scripting],
1005        [Disable BASIC, Java and Python. Work in progress, use only if you are hacking on it.])
1006)
1007
1008# This is mainly for Android and iOS, but could potentially be used in some
1009# special case otherwise, too, so factored out as a separate setting
1010
1011AC_ARG_ENABLE(dynamic-loading,
1012    AS_HELP_STRING([--disable-dynamic-loading],
1013        [Disable any use of dynamic loading of code. Work in progress, use only if you are hacking on it.])
1014)
1015
1016libo_FUZZ_ARG_ENABLE(report-builder,
1017    AS_HELP_STRING([--disable-report-builder],
1018        [Disable the Report Builder.])
1019)
1020
1021libo_FUZZ_ARG_ENABLE(ext-wiki-publisher,
1022    AS_HELP_STRING([--enable-ext-wiki-publisher],
1023        [Enable the Wiki Publisher extension.])
1024)
1025
1026libo_FUZZ_ARG_ENABLE(lpsolve,
1027    AS_HELP_STRING([--disable-lpsolve],
1028        [Disable compilation of the lp solve solver ])
1029)
1030libo_FUZZ_ARG_ENABLE(coinmp,
1031    AS_HELP_STRING([--disable-coinmp],
1032        [Disable compilation of the CoinMP solver ])
1033)
1034
1035libo_FUZZ_ARG_ENABLE(pdfimport,
1036    AS_HELP_STRING([--disable-pdfimport],
1037        [Disable building the PDF import feature.])
1038)
1039
1040libo_FUZZ_ARG_ENABLE(pdfium,
1041    AS_HELP_STRING([--disable-pdfium],
1042        [Disable building PDFium.])
1043)
1044
1045###############################################################################
1046
1047dnl ---------- *** ----------
1048
1049libo_FUZZ_ARG_ENABLE(mergelibs,
1050    AS_HELP_STRING([--enable-mergelibs],
1051        [Merge several of the smaller libraries into one big, "merged", one.])
1052)
1053
1054libo_FUZZ_ARG_ENABLE(breakpad,
1055    AS_HELP_STRING([--enable-breakpad],
1056        [Enables breakpad for crash reporting.])
1057)
1058
1059AC_ARG_ENABLE(fetch-external,
1060    AS_HELP_STRING([--disable-fetch-external],
1061        [Disables fetching external tarballs from web sources.])
1062)
1063
1064AC_ARG_ENABLE(fuzzers,
1065    AS_HELP_STRING([--enable-fuzzers],
1066        [Enables building libfuzzer targets for fuzz testing.])
1067)
1068
1069libo_FUZZ_ARG_ENABLE(pch,
1070    AS_HELP_STRING([--enable-pch=<yes/no/system/base/normal/full>],
1071        [Enables precompiled header support for C++. Forced default on Windows/VC build.
1072         Using 'system' will include only external headers, 'base' will add also headers
1073         from base modules, 'normal' will also add all headers except from the module built,
1074         'full' will use all suitable headers even from a module itself.])
1075)
1076
1077libo_FUZZ_ARG_ENABLE(epm,
1078    AS_HELP_STRING([--enable-epm],
1079        [LibreOffice includes self-packaging code, that requires epm, however epm is
1080         useless for large scale package building.])
1081)
1082
1083libo_FUZZ_ARG_ENABLE(odk,
1084    AS_HELP_STRING([--disable-odk],
1085        [LibreOffice includes an ODK, office development kit which some packagers may
1086         wish to build without.])
1087)
1088
1089AC_ARG_ENABLE(mpl-subset,
1090    AS_HELP_STRING([--enable-mpl-subset],
1091        [Don't compile any pieces which are not MPL or more liberally licensed])
1092)
1093
1094libo_FUZZ_ARG_ENABLE(evolution2,
1095    AS_HELP_STRING([--enable-evolution2],
1096        [Allows the built-in evolution 2 addressbook connectivity build to be
1097         enabled.])
1098)
1099
1100AC_ARG_ENABLE(avahi,
1101    AS_HELP_STRING([--enable-avahi],
1102        [Determines whether to use Avahi to advertise Impress to remote controls.])
1103)
1104
1105libo_FUZZ_ARG_ENABLE(werror,
1106    AS_HELP_STRING([--enable-werror],
1107        [Turn warnings to errors. (Has no effect in modules where the treating
1108         of warnings as errors is disabled explicitly.)]),
1109,)
1110
1111libo_FUZZ_ARG_ENABLE(assert-always-abort,
1112    AS_HELP_STRING([--enable-assert-always-abort],
1113        [make assert() failures abort even when building without --enable-debug or --enable-dbgutil.]),
1114,)
1115
1116libo_FUZZ_ARG_ENABLE(dbgutil,
1117    AS_HELP_STRING([--enable-dbgutil],
1118        [Provide debugging support from --enable-debug and include additional debugging
1119         utilities such as object counting or more expensive checks.
1120         This is the recommended option for developers.
1121         Note that this makes the build ABI incompatible, it is not possible to mix object
1122         files or libraries from a --enable-dbgutil and a --disable-dbgutil build.]))
1123
1124libo_FUZZ_ARG_ENABLE(debug,
1125    AS_HELP_STRING([--enable-debug],
1126        [Include debugging information, disable compiler optimization and inlining plus
1127         extra debugging code like assertions. Extra large build! (enables -g compiler flag).]))
1128
1129libo_FUZZ_ARG_ENABLE(split-debug,
1130    AS_HELP_STRING([--disable-split-debug],
1131        [Disable using split debug information (-gsplit-dwarf compile flag). Split debug information
1132         saves disk space and build time, but requires tools that support it (both build tools and debuggers).]))
1133
1134libo_FUZZ_ARG_ENABLE(gdb-index,
1135    AS_HELP_STRING([--disable-gdb-index],
1136        [Disables creating debug information in the gdb index format, which makes gdb start faster.
1137         The feature requires the gold or lld linker.]))
1138
1139libo_FUZZ_ARG_ENABLE(sal-log,
1140    AS_HELP_STRING([--enable-sal-log],
1141        [Make SAL_INFO and SAL_WARN calls do something even in a non-debug build.]))
1142
1143libo_FUZZ_ARG_ENABLE(symbols,
1144    AS_HELP_STRING([--enable-symbols],
1145        [Generate debug information.
1146         By default, enabled for --enable-debug and --enable-dbgutil, disabled
1147         otherwise. It is possible to explicitly specify gbuild build targets
1148         (where 'all' means everything, '-' prepended means to not enable, '/' appended means
1149         everything in the directory; there is no ordering, more specific overrides
1150         more general, and disabling takes precedence).
1151         Example: --enable-symbols="all -sw/ -Library_sc".]))
1152
1153libo_FUZZ_ARG_ENABLE(optimized,
1154    AS_HELP_STRING([--disable-optimized],
1155        [Whether to compile with optimization flags.
1156         By default, disabled for --enable-debug and --enable-dbgutil, enabled
1157         otherwise.]))
1158
1159libo_FUZZ_ARG_ENABLE(runtime-optimizations,
1160    AS_HELP_STRING([--disable-runtime-optimizations],
1161        [Statically disable certain runtime optimizations (like rtl/alloc.h or
1162         JVM JIT) that are known to interact badly with certain dynamic analysis
1163         tools (like -fsanitize=address or Valgrind).  By default, disabled iff
1164         CC contains "-fsanitize=*".  (For Valgrind, those runtime optimizations
1165         are typically disabled dynamically via RUNNING_ON_VALGRIND.)]))
1166
1167AC_ARG_WITH(valgrind,
1168    AS_HELP_STRING([--with-valgrind],
1169        [Make availability of Valgrind headers a hard requirement.]))
1170
1171libo_FUZZ_ARG_ENABLE(compiler-plugins,
1172    AS_HELP_STRING([--enable-compiler-plugins],
1173        [Enable compiler plugins that will perform additional checks during
1174         building. Enabled automatically by --enable-dbgutil.
1175         Use --enable-compiler-plugins=debug to also enable debug code in the plugins.]))
1176COMPILER_PLUGINS_DEBUG=
1177if test "$enable_compiler_plugins" = debug; then
1178    enable_compiler_plugins=yes
1179    COMPILER_PLUGINS_DEBUG=TRUE
1180fi
1181
1182libo_FUZZ_ARG_ENABLE(ooenv,
1183    AS_HELP_STRING([--disable-ooenv],
1184        [Disable ooenv for the instdir installation.]))
1185
1186libo_FUZZ_ARG_ENABLE(libnumbertext,
1187    AS_HELP_STRING([--disable-libnumbertext],
1188        [Disable use of numbertext external library.]))
1189
1190AC_ARG_ENABLE(lto,
1191    AS_HELP_STRING([--enable-lto],
1192        [Enable link-time optimization. Suitable for (optimised) product builds. Building might take
1193         longer but libraries and executables are optimized for speed. For GCC, best to use the 'gold'
1194         linker. For MSVC, this option is broken at the moment. This is experimental work
1195         in progress that shouldn't be used unless you are working on it.)]))
1196
1197AC_ARG_ENABLE(python,
1198    AS_HELP_STRING([--enable-python=<no/auto/system/internal/fully-internal>],
1199        [Enables or disables Python support at run-time.
1200         Also specifies what Python to use. 'auto' is the default.
1201         'fully-internal' even forces the internal version for uses of Python
1202         during the build.]))
1203
1204libo_FUZZ_ARG_ENABLE(gtk,
1205    AS_HELP_STRING([--disable-gtk],
1206        [Determines whether to use Gtk+ vclplug on platforms where Gtk+ is available.]),
1207,test "${enable_gtk+set}" = set || enable_gtk=yes)
1208
1209libo_FUZZ_ARG_ENABLE(gtk3,
1210    AS_HELP_STRING([--disable-gtk3],
1211        [Determines whether to use Gtk+ 3.0 vclplug on platforms where Gtk+ 3.0 is available.]),
1212,test "${enable_gtk3+set}" = set || enable_gtk3=yes)
1213
1214AC_ARG_ENABLE(split-app-modules,
1215    AS_HELP_STRING([--enable-split-app-modules],
1216        [Split file lists for app modules, e.g. base, calc.
1217         Has effect only with make distro-pack-install]),
1218,)
1219
1220AC_ARG_ENABLE(split-opt-features,
1221    AS_HELP_STRING([--enable-split-opt-features],
1222        [Split file lists for some optional features, e.g. pyuno, testtool.
1223         Has effect only with make distro-pack-install]),
1224,)
1225
1226libo_FUZZ_ARG_ENABLE(cairo-canvas,
1227    AS_HELP_STRING([--disable-cairo-canvas],
1228        [Determines whether to build the Cairo canvas on platforms where Cairo is available.]),
1229,)
1230
1231libo_FUZZ_ARG_ENABLE(dbus,
1232    AS_HELP_STRING([--disable-dbus],
1233        [Determines whether to enable features that depend on dbus.
1234         e.g. Presentation mode screensaver control, bluetooth presentation control, automatic font install]),
1235,test "${enable_dbus+set}" = set || enable_dbus=yes)
1236
1237libo_FUZZ_ARG_ENABLE(sdremote,
1238    AS_HELP_STRING([--disable-sdremote],
1239        [Determines whether to enable Impress remote control (i.e. the server component).]),
1240,test "${enable_sdremote+set}" = set || enable_sdremote=yes)
1241
1242libo_FUZZ_ARG_ENABLE(sdremote-bluetooth,
1243    AS_HELP_STRING([--disable-sdremote-bluetooth],
1244        [Determines whether to build sdremote with bluetooth support.
1245         Requires dbus on Linux.]))
1246
1247libo_FUZZ_ARG_ENABLE(gio,
1248    AS_HELP_STRING([--disable-gio],
1249        [Determines whether to use the GIO support.]),
1250,test "${enable_gio+set}" = set || enable_gio=yes)
1251
1252AC_ARG_ENABLE(qt5,
1253    AS_HELP_STRING([--enable-qt5],
1254        [Determines whether to use Qt5 vclplug on platforms where Qt5 is
1255         available.]),
1256,)
1257
1258AC_ARG_ENABLE(kde5,
1259    AS_HELP_STRING([--enable-kde5],
1260        [Determines whether to use Qt5/KF5 vclplug on platforms where Qt5 and
1261         KF5 are available.]),
1262,)
1263
1264AC_ARG_ENABLE(gtk3_kde5,
1265    AS_HELP_STRING([--enable-gtk3-kde5],
1266        [Determines whether to use Gtk3 vclplug with KDE file dialogs on
1267         platforms where Gtk3, Qt5 and Plasma is available.]),
1268,)
1269
1270AC_ARG_ENABLE(gui,
1271    AS_HELP_STRING([--disable-gui],
1272        [Disable use of X11 or Wayland to reduce dependencies. Not related to the --headless
1273         command-line option. Not related to LibreOffice Online functionality. Don't use
1274         unless you are certain you need to. Nobody will help you if you insist on trying
1275         this and run into problems.]),
1276,enable_gui=yes)
1277
1278libo_FUZZ_ARG_ENABLE(randr,
1279    AS_HELP_STRING([--disable-randr],
1280        [Disable RandR support in the vcl project.]),
1281,test "${enable_randr+set}" = set || enable_randr=yes)
1282
1283libo_FUZZ_ARG_ENABLE(gstreamer-1-0,
1284    AS_HELP_STRING([--disable-gstreamer-1-0],
1285        [Disable building with the gstreamer 1.0 avmedia backend.]),
1286,test "${enable_gstreamer_1_0+set}" = set || enable_gstreamer_1_0=yes)
1287
1288libo_FUZZ_ARG_ENABLE(vlc,
1289    AS_HELP_STRING([--enable-vlc],
1290        [Enable building with the (experimental) VLC avmedia backend.]),
1291,test "${enable_vlc+set}" = set || enable_vlc=no)
1292
1293libo_FUZZ_ARG_ENABLE(neon,
1294    AS_HELP_STRING([--disable-neon],
1295        [Disable neon and the compilation of webdav binding.]),
1296,)
1297
1298libo_FUZZ_ARG_ENABLE([eot],
1299    [AS_HELP_STRING([--enable-eot],
1300        [Enable support for Embedded OpenType fonts.])],
1301,test "${enable_eot+set}" = set || enable_eot=no)
1302
1303libo_FUZZ_ARG_ENABLE(cve-tests,
1304    AS_HELP_STRING([--disable-cve-tests],
1305        [Prevent CVE tests to be executed]),
1306,)
1307
1308libo_FUZZ_ARG_ENABLE(chart-tests,
1309    AS_HELP_STRING([--enable-chart-tests],
1310        [Executes chart XShape tests. In a perfect world these tests would be
1311         stable and everyone could run them, in reality it is best to run them
1312         only on a few machines that are known to work and maintained by people
1313         who can judge if a test failure is a regression or not.]),
1314,)
1315
1316AC_ARG_ENABLE(build-unowinreg,
1317    AS_HELP_STRING([--enable-build-unowinreg],
1318        [Do not use the prebuilt unowinreg.dll. Build it instead. The MinGW C++
1319         compiler is needed on Linux.]),
1320,)
1321
1322AC_ARG_ENABLE(build-opensymbol,
1323    AS_HELP_STRING([--enable-build-opensymbol],
1324        [Do not use the prebuilt opens___.ttf. Build it instead. This needs
1325         fontforge installed.]),
1326,)
1327
1328AC_ARG_ENABLE(dependency-tracking,
1329    AS_HELP_STRING([--enable-dependency-tracking],
1330        [Do not reject slow dependency extractors.])[
1331  --disable-dependency-tracking
1332                          Disables generation of dependency information.
1333                          Speed up one-time builds.],
1334,)
1335
1336AC_ARG_ENABLE(icecream,
1337    AS_HELP_STRING([--enable-icecream],
1338        [Use the 'icecream' distributed compiling tool to speedup the compilation.
1339         It defaults to /opt/icecream for the location of the icecream gcc/g++
1340         wrappers, you can override that using --with-gcc-home=/the/path switch.]),
1341,)
1342
1343AC_ARG_ENABLE(ld,
1344    AS_HELP_STRING([--enable-ld=<linker>],
1345        [Use the specified linker. Both 'gold' and 'lld' linkers generally use less memory and link faster.
1346         By default tries to use the best linker possible, use --disable-ld to use the default linker.]),
1347,)
1348
1349libo_FUZZ_ARG_ENABLE(cups,
1350    AS_HELP_STRING([--disable-cups],
1351        [Do not build cups support.])
1352)
1353
1354AC_ARG_ENABLE(ccache,
1355    AS_HELP_STRING([--disable-ccache],
1356        [Do not try to use ccache automatically.
1357         By default, unless on Windows, we will try to detect if ccache is available; in that case if
1358         CC/CXX are not yet set, and --enable-icecream is not given, we
1359         attempt to use ccache. --disable-ccache disables ccache completely.
1360         Additionally ccache's depend mode is enabled if possible,
1361         use --enable-ccache=nodepend to enable ccache without depend mode.
1362]),
1363,)
1364
1365AC_ARG_ENABLE(64-bit,
1366    AS_HELP_STRING([--enable-64-bit],
1367        [Build a 64-bit LibreOffice on platforms where the normal build is 32-bit.
1368         At the moment meaningful only for Windows.]), ,)
1369
1370libo_FUZZ_ARG_ENABLE(online-update,
1371    AS_HELP_STRING([--enable-online-update],
1372        [Enable the online update service that will check for new versions of
1373         LibreOffice. By default, it is enabled on Windows and Mac, disabled on Linux.
1374         If the value is "mar", the experimental Mozilla-like update will be
1375         enabled instead of the traditional update mechanism.]),
1376,)
1377
1378AC_ARG_WITH(update-config,
1379    AS_HELP_STRING([--with-update-config=/tmp/update.ini],
1380                   [Path to the update config ini file]))
1381
1382libo_FUZZ_ARG_ENABLE(extension-update,
1383    AS_HELP_STRING([--disable-extension-update],
1384        [Disable possibility to update installed extensions.]),
1385,)
1386
1387libo_FUZZ_ARG_ENABLE(release-build,
1388    AS_HELP_STRING([--enable-release-build],
1389        [Enable release build. Note that the "release build" choice is orthogonal to
1390         whether symbols are present, debug info is generated, or optimization
1391         is done.
1392         See http://wiki.documentfoundation.org/Development/DevBuild]),
1393,)
1394
1395AC_ARG_ENABLE(windows-build-signing,
1396    AS_HELP_STRING([--enable-windows-build-signing],
1397        [Enable signing of windows binaries (*.exe, *.dll)]),
1398,)
1399
1400AC_ARG_ENABLE(silent-msi,
1401    AS_HELP_STRING([--enable-silent-msi],
1402        [Enable MSI with LIMITUI=1 (silent install).]),
1403,)
1404
1405AC_ARG_ENABLE(macosx-code-signing,
1406    AS_HELP_STRING([--enable-macosx-code-signing=<identity>],
1407        [Sign executables, dylibs, frameworks and the app bundle. If you
1408         don't provide an identity the first suitable certificate
1409         in your keychain is used.]),
1410,)
1411
1412AC_ARG_ENABLE(macosx-package-signing,
1413    AS_HELP_STRING([--enable-macosx-package-signing=<identity>],
1414        [Create a .pkg suitable for uploading to the Mac App Store and sign
1415         it. If you don't provide an identity the first suitable certificate
1416         in your keychain is used.]),
1417,)
1418
1419AC_ARG_ENABLE(macosx-sandbox,
1420    AS_HELP_STRING([--enable-macosx-sandbox],
1421        [Make the app bundle run in a sandbox. Requires code signing.
1422         Is required by apps distributed in the Mac App Store, and implies
1423         adherence to App Store rules.]),
1424,)
1425
1426AC_ARG_WITH(macosx-bundle-identifier,
1427    AS_HELP_STRING([--with-macosx-bundle-identifier=tld.mumble.orifice.TheOffice],
1428        [Define the macOS bundle identifier. Default is the somewhat weird
1429         org.libreoffice.script ("script", huh?).]),
1430,with_macosx_bundle_identifier=org.libreoffice.script)
1431
1432AC_ARG_WITH(product-name,
1433    AS_HELP_STRING([--with-product-name='My Own Office Suite'],
1434        [Define the product name. Default is AC_PACKAGE_NAME.]),
1435,with_product_name=$PRODUCTNAME)
1436
1437AC_ARG_WITH(package-version,
1438    AS_HELP_STRING([--with-package-version='3.1.4.5'],
1439        [Define the package version. Default is AC_PACKAGE_VERSION. Use only if you distribute an own build for macOS.]),
1440,)
1441
1442libo_FUZZ_ARG_ENABLE(readonly-installset,
1443    AS_HELP_STRING([--enable-readonly-installset],
1444        [Prevents any attempts by LibreOffice to write into its installation. That means
1445         at least that no "system-wide" extensions can be added. Partly experimental work in
1446         progress, probably not fully implemented (but is useful for sandboxed macOS builds).]),
1447,)
1448
1449libo_FUZZ_ARG_ENABLE(postgresql-sdbc,
1450    AS_HELP_STRING([--disable-postgresql-sdbc],
1451        [Disable the build of the PostgreSQL-SDBC driver.])
1452)
1453
1454libo_FUZZ_ARG_ENABLE(lotuswordpro,
1455    AS_HELP_STRING([--disable-lotuswordpro],
1456        [Disable the build of the Lotus Word Pro filter.]),
1457,test "${enable_lotuswordpro+set}" = set || enable_lotuswordpro=yes)
1458
1459libo_FUZZ_ARG_ENABLE(firebird-sdbc,
1460    AS_HELP_STRING([--disable-firebird-sdbc],
1461        [Disable the build of the Firebird-SDBC driver if it doesn't compile for you.]),
1462,test "${enable_firebird_sdbc+set}" = set || enable_firebird_sdbc=yes)
1463
1464AC_ARG_ENABLE(bogus-pkg-config,
1465    AS_HELP_STRING([--enable-bogus-pkg-config],
1466        [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.]),
1467)
1468
1469AC_ARG_ENABLE(openssl,
1470    AS_HELP_STRING([--disable-openssl],
1471        [Disable using libssl/libcrypto from OpenSSL. If disabled,
1472         components will either use GNUTLS or NSS. Work in progress,
1473         use only if you are hacking on it.]),
1474,enable_openssl=yes)
1475
1476libo_FUZZ_ARG_ENABLE(cipher-openssl-backend,
1477    AS_HELP_STRING([--enable-cipher-openssl-backend],
1478        [Enable using OpenSSL as the actual implementation of the rtl/cipher.h functionality.
1479         Requires --enable-openssl.]))
1480
1481AC_ARG_ENABLE(library-bin-tar,
1482    AS_HELP_STRING([--enable-library-bin-tar],
1483        [Enable the building and reused of tarball of binary build for some 'external' libraries.
1484        Some libraries can save their build result in a tarball
1485        stored in TARFILE_LOCATION. That binary tarball is
1486        uniquely identified by the source tarball,
1487        the content of the config_host.mk file and the content
1488        of the top-level directory in core for that library
1489        If this option is enabled, then if such a tarfile exist, it will be untarred
1490        instead of the source tarfile, and the build step will be skipped for that
1491        library.
1492        If a proper tarfile does not exist, then the normal source-based
1493        build is done for that library and a proper binary tarfile is created
1494        for the next time.]),
1495)
1496
1497AC_ARG_ENABLE(dconf,
1498    AS_HELP_STRING([--disable-dconf],
1499        [Disable the dconf configuration backend (enabled by default where
1500         available).]))
1501
1502libo_FUZZ_ARG_ENABLE(formula-logger,
1503    AS_HELP_STRING(
1504        [--enable-formula-logger],
1505        [Enable formula logger for logging formula calculation flow in Calc.]
1506    )
1507)
1508
1509AC_ARG_ENABLE(ldap,
1510    AS_HELP_STRING([--disable-ldap],
1511        [Disable LDAP support.]),
1512,enable_ldap=yes)
1513
1514dnl ===================================================================
1515dnl Optional Packages (--with/without-)
1516dnl ===================================================================
1517
1518AC_ARG_WITH(gcc-home,
1519    AS_HELP_STRING([--with-gcc-home],
1520        [Specify the location of gcc/g++ manually. This can be used in conjunction
1521         with --enable-icecream when icecream gcc/g++ wrappers are installed in a
1522         non-default path.]),
1523,)
1524
1525AC_ARG_WITH(gnu-patch,
1526    AS_HELP_STRING([--with-gnu-patch],
1527        [Specify location of GNU patch on Solaris or FreeBSD.]),
1528,)
1529
1530AC_ARG_WITH(build-platform-configure-options,
1531    AS_HELP_STRING([--with-build-platform-configure-options],
1532        [Specify options for the configure script run for the *build* platform in a cross-compilation]),
1533,)
1534
1535AC_ARG_WITH(gnu-cp,
1536    AS_HELP_STRING([--with-gnu-cp],
1537        [Specify location of GNU cp on Solaris or FreeBSD.]),
1538,)
1539
1540AC_ARG_WITH(external-tar,
1541    AS_HELP_STRING([--with-external-tar=<TARFILE_PATH>],
1542        [Specify an absolute path of where to find (and store) tarfiles.]),
1543    TARFILE_LOCATION=$withval ,
1544)
1545
1546AC_ARG_WITH(referenced-git,
1547    AS_HELP_STRING([--with-referenced-git=<OTHER_CHECKOUT_DIR>],
1548        [Specify another checkout directory to reference. This makes use of
1549                 git submodule update --reference, and saves a lot of diskspace
1550                 when having multiple trees side-by-side.]),
1551    GIT_REFERENCE_SRC=$withval ,
1552)
1553
1554AC_ARG_WITH(linked-git,
1555    AS_HELP_STRING([--with-linked-git=<submodules repo basedir>],
1556        [Specify a directory where the repositories of submodules are located.
1557         This uses a method similar to git-new-workdir to get submodules.]),
1558    GIT_LINK_SRC=$withval ,
1559)
1560
1561AC_ARG_WITH(galleries,
1562    AS_HELP_STRING([--with-galleries],
1563        [Specify how galleries should be built. It is possible either to
1564         build these internally from source ("build"),
1565         or to disable them ("no")]),
1566)
1567
1568AC_ARG_WITH(theme,
1569    AS_HELP_STRING([--with-theme="theme1 theme2..."],
1570        [Choose which themes to include. By default those themes with an '*' are included.
1571         Possible choices: *breeze, *breeze_dark, *breeze_svg, *colibre, *colibre_svg, *elementary,
1572         *elementary_svg, *karasa_jaga, *sifr, *sif_svg, *sifr_dark, *tango.]),
1573,)
1574
1575libo_FUZZ_ARG_WITH(helppack-integration,
1576    AS_HELP_STRING([--without-helppack-integration],
1577        [It will not integrate the helppacks to the installer
1578         of the product. Please use this switch to use the online help
1579         or separate help packages.]),
1580,)
1581
1582libo_FUZZ_ARG_WITH(fonts,
1583    AS_HELP_STRING([--without-fonts],
1584        [LibreOffice includes some third-party fonts to provide a reliable basis for
1585         help content, templates, samples, etc. When these fonts are already
1586         known to be available on the system then you should use this option.]),
1587,)
1588
1589AC_ARG_WITH(epm,
1590    AS_HELP_STRING([--with-epm],
1591        [Decides which epm to use. Default is to use the one from the system if
1592         one is built. When either this is not there or you say =internal epm
1593         will be built.]),
1594,)
1595
1596AC_ARG_WITH(package-format,
1597    AS_HELP_STRING([--with-package-format],
1598        [Specify package format(s) for LibreOffice installation sets. The
1599         implicit --without-package-format leads to no installation sets being
1600         generated. Possible values: aix, archive, bsd, deb, dmg,
1601         installed, msi, pkg, and rpm.
1602         Example: --with-package-format='deb rpm']),
1603,)
1604
1605AC_ARG_WITH(tls,
1606    AS_HELP_STRING([--with-tls],
1607        [Decides which TLS/SSL and cryptographic implementations to use for
1608         LibreOffice's code. Notice that this doesn't apply for depending
1609         libraries like "neon", for example. Default is to use OpenSSL
1610         although NSS is also possible. Notice that selecting NSS restricts
1611         the usage of OpenSSL in LO's code but selecting OpenSSL doesn't
1612         restrict by now the usage of NSS in LO's code. Possible values:
1613         openssl, nss. Example: --with-tls="nss"]),
1614,)
1615
1616AC_ARG_WITH(system-libs,
1617    AS_HELP_STRING([--with-system-libs],
1618        [Use libraries already on system -- enables all --with-system-* flags.]),
1619,)
1620
1621AC_ARG_WITH(system-bzip2,
1622    AS_HELP_STRING([--with-system-bzip2],
1623        [Use bzip2 already on system. Used only when --enable-online-update=mar]),,
1624    [with_system_bzip2="$with_system_libs"])
1625
1626AC_ARG_WITH(system-headers,
1627    AS_HELP_STRING([--with-system-headers],
1628        [Use headers already on system -- enables all --with-system-* flags for
1629         external packages whose headers are the only entities used i.e.
1630         boost/odbc/sane-header(s).]),,
1631    [with_system_headers="$with_system_libs"])
1632
1633AC_ARG_WITH(system-jars,
1634    AS_HELP_STRING([--without-system-jars],
1635        [When building with --with-system-libs, also the needed jars are expected
1636         on the system. Use this to disable that]),,
1637    [with_system_jars="$with_system_libs"])
1638
1639AC_ARG_WITH(system-cairo,
1640    AS_HELP_STRING([--with-system-cairo],
1641        [Use cairo libraries already on system.  Happens automatically for
1642         (implicit) --enable-gtk and for --enable-gtk3.]))
1643
1644AC_ARG_WITH(system-epoxy,
1645    AS_HELP_STRING([--with-system-epoxy],
1646        [Use epoxy libraries already on system.  Happens automatically for
1647         --enable-gtk3.]),,
1648       [with_system_epoxy="$with_system_libs"])
1649
1650AC_ARG_WITH(myspell-dicts,
1651    AS_HELP_STRING([--with-myspell-dicts],
1652        [Adds myspell dictionaries to the LibreOffice installation set]),
1653,)
1654
1655AC_ARG_WITH(system-dicts,
1656    AS_HELP_STRING([--without-system-dicts],
1657        [Do not use dictionaries from system paths.]),
1658,)
1659
1660AC_ARG_WITH(external-dict-dir,
1661    AS_HELP_STRING([--with-external-dict-dir],
1662        [Specify external dictionary dir.]),
1663,)
1664
1665AC_ARG_WITH(external-hyph-dir,
1666    AS_HELP_STRING([--with-external-hyph-dir],
1667        [Specify external hyphenation pattern dir.]),
1668,)
1669
1670AC_ARG_WITH(external-thes-dir,
1671    AS_HELP_STRING([--with-external-thes-dir],
1672        [Specify external thesaurus dir.]),
1673,)
1674
1675AC_ARG_WITH(system-zlib,
1676    AS_HELP_STRING([--with-system-zlib],
1677        [Use zlib already on system.]),,
1678    [with_system_zlib=auto])
1679
1680AC_ARG_WITH(system-jpeg,
1681    AS_HELP_STRING([--with-system-jpeg],
1682        [Use jpeg already on system.]),,
1683    [with_system_jpeg="$with_system_libs"])
1684
1685AC_ARG_WITH(system-clucene,
1686    AS_HELP_STRING([--with-system-clucene],
1687        [Use clucene already on system.]),,
1688    [with_system_clucene="$with_system_libs"])
1689
1690AC_ARG_WITH(system-expat,
1691    AS_HELP_STRING([--with-system-expat],
1692        [Use expat already on system.]),,
1693    [with_system_expat="$with_system_libs"])
1694
1695AC_ARG_WITH(system-libxml,
1696    AS_HELP_STRING([--with-system-libxml],
1697        [Use libxml/libxslt already on system.]),,
1698    [with_system_libxml=auto])
1699
1700AC_ARG_WITH(system-icu,
1701    AS_HELP_STRING([--with-system-icu],
1702        [Use icu already on system.]),,
1703    [with_system_icu="$with_system_libs"])
1704
1705AC_ARG_WITH(system-ucpp,
1706    AS_HELP_STRING([--with-system-ucpp],
1707        [Use ucpp already on system.]),,
1708    [])
1709
1710AC_ARG_WITH(system-openldap,
1711    AS_HELP_STRING([--with-system-openldap],
1712        [Use the OpenLDAP LDAP SDK already on system.]),,
1713    [with_system_openldap="$with_system_libs"])
1714
1715libo_FUZZ_ARG_ENABLE(poppler,
1716    AS_HELP_STRING([--disable-poppler],
1717        [Disable building Poppler.])
1718)
1719
1720AC_ARG_WITH(system-poppler,
1721    AS_HELP_STRING([--with-system-poppler],
1722        [Use system poppler (only needed for PDF import).]),,
1723    [with_system_poppler="$with_system_libs"])
1724
1725AC_ARG_WITH(system-gpgmepp,
1726    AS_HELP_STRING([--with-system-gpgmepp],
1727        [Use gpgmepp already on system]),,
1728    [with_system_gpgmepp="$with_system_libs"])
1729
1730AC_ARG_WITH(system-apache-commons,
1731    AS_HELP_STRING([--with-system-apache-commons],
1732        [Use Apache commons libraries already on system.]),,
1733    [with_system_apache_commons="$with_system_jars"])
1734
1735AC_ARG_WITH(system-mariadb,
1736    AS_HELP_STRING([--with-system-mariadb],
1737        [Use MariaDB/MySQL libraries already on system.]),,
1738    [with_system_mariadb="$with_system_libs"])
1739
1740AC_ARG_ENABLE(bundle-mariadb,
1741    AS_HELP_STRING([--enable-bundle-mariadb],
1742        [When using MariaDB/MySQL libraries already on system, bundle them with the MariaDB Connector/LibreOffice.])
1743)
1744
1745AC_ARG_WITH(system-postgresql,
1746    AS_HELP_STRING([--with-system-postgresql],
1747        [Use PostgreSQL libraries already on system, for building the PostgreSQL-SDBC
1748         driver. If pg_config is not in PATH, use PGCONFIG to point to it.]),,
1749    [with_system_postgresql="$with_system_libs"])
1750
1751AC_ARG_WITH(libpq-path,
1752    AS_HELP_STRING([--with-libpq-path=<absolute path to your libpq installation>],
1753        [Use this PostgreSQL C interface (libpq) installation for building
1754         the PostgreSQL-SDBC extension.]),
1755,)
1756
1757AC_ARG_WITH(system-firebird,
1758    AS_HELP_STRING([--with-system-firebird],
1759        [Use Firebird libraries already on system, for building the Firebird-SDBC
1760         driver. If fb_config is not in PATH, use FBCONFIG to point to it.]),,
1761    [with_system_firebird="$with_system_libs"])
1762
1763AC_ARG_WITH(system-libtommath,
1764            AS_HELP_STRING([--with-system-libtommath],
1765                           [Use libtommath already on system]),,
1766            [with_system_libtommath="$with_system_libs"])
1767
1768AC_ARG_WITH(system-hsqldb,
1769    AS_HELP_STRING([--with-system-hsqldb],
1770        [Use hsqldb already on system.]))
1771
1772AC_ARG_WITH(hsqldb-jar,
1773    AS_HELP_STRING([--with-hsqldb-jar=JARFILE],
1774        [Specify path to jarfile manually.]),
1775    HSQLDB_JAR=$withval)
1776
1777libo_FUZZ_ARG_ENABLE(scripting-beanshell,
1778    AS_HELP_STRING([--disable-scripting-beanshell],
1779        [Disable support for scripts in BeanShell.]),
1780,
1781)
1782
1783AC_ARG_WITH(system-beanshell,
1784    AS_HELP_STRING([--with-system-beanshell],
1785        [Use beanshell already on system.]),,
1786    [with_system_beanshell="$with_system_jars"])
1787
1788AC_ARG_WITH(beanshell-jar,
1789    AS_HELP_STRING([--with-beanshell-jar=JARFILE],
1790        [Specify path to jarfile manually.]),
1791    BSH_JAR=$withval)
1792
1793libo_FUZZ_ARG_ENABLE(scripting-javascript,
1794    AS_HELP_STRING([--disable-scripting-javascript],
1795        [Disable support for scripts in JavaScript.]),
1796,
1797)
1798
1799AC_ARG_WITH(system-rhino,
1800    AS_HELP_STRING([--with-system-rhino],
1801        [Use rhino already on system.]),,)
1802#    [with_system_rhino="$with_system_jars"])
1803# Above is not used as we have different debug interface
1804# patched into internal rhino. This code needs to be fixed
1805# before we can enable it by default.
1806
1807AC_ARG_WITH(rhino-jar,
1808    AS_HELP_STRING([--with-rhino-jar=JARFILE],
1809        [Specify path to jarfile manually.]),
1810    RHINO_JAR=$withval)
1811
1812AC_ARG_WITH(commons-logging-jar,
1813    AS_HELP_STRING([--with-commons-logging-jar=JARFILE],
1814        [Specify path to jarfile manually.]),
1815    COMMONS_LOGGING_JAR=$withval)
1816
1817AC_ARG_WITH(system-jfreereport,
1818    AS_HELP_STRING([--with-system-jfreereport],
1819        [Use JFreeReport already on system.]),,
1820    [with_system_jfreereport="$with_system_jars"])
1821
1822AC_ARG_WITH(sac-jar,
1823    AS_HELP_STRING([--with-sac-jar=JARFILE],
1824        [Specify path to jarfile manually.]),
1825    SAC_JAR=$withval)
1826
1827AC_ARG_WITH(libxml-jar,
1828    AS_HELP_STRING([--with-libxml-jar=JARFILE],
1829        [Specify path to jarfile manually.]),
1830    LIBXML_JAR=$withval)
1831
1832AC_ARG_WITH(flute-jar,
1833    AS_HELP_STRING([--with-flute-jar=JARFILE],
1834        [Specify path to jarfile manually.]),
1835    FLUTE_JAR=$withval)
1836
1837AC_ARG_WITH(jfreereport-jar,
1838    AS_HELP_STRING([--with-jfreereport-jar=JARFILE],
1839        [Specify path to jarfile manually.]),
1840    JFREEREPORT_JAR=$withval)
1841
1842AC_ARG_WITH(liblayout-jar,
1843    AS_HELP_STRING([--with-liblayout-jar=JARFILE],
1844        [Specify path to jarfile manually.]),
1845    LIBLAYOUT_JAR=$withval)
1846
1847AC_ARG_WITH(libloader-jar,
1848    AS_HELP_STRING([--with-libloader-jar=JARFILE],
1849        [Specify path to jarfile manually.]),
1850    LIBLOADER_JAR=$withval)
1851
1852AC_ARG_WITH(libformula-jar,
1853    AS_HELP_STRING([--with-libformula-jar=JARFILE],
1854        [Specify path to jarfile manually.]),
1855    LIBFORMULA_JAR=$withval)
1856
1857AC_ARG_WITH(librepository-jar,
1858    AS_HELP_STRING([--with-librepository-jar=JARFILE],
1859        [Specify path to jarfile manually.]),
1860    LIBREPOSITORY_JAR=$withval)
1861
1862AC_ARG_WITH(libfonts-jar,
1863    AS_HELP_STRING([--with-libfonts-jar=JARFILE],
1864        [Specify path to jarfile manually.]),
1865    LIBFONTS_JAR=$withval)
1866
1867AC_ARG_WITH(libserializer-jar,
1868    AS_HELP_STRING([--with-libserializer-jar=JARFILE],
1869        [Specify path to jarfile manually.]),
1870    LIBSERIALIZER_JAR=$withval)
1871
1872AC_ARG_WITH(libbase-jar,
1873    AS_HELP_STRING([--with-libbase-jar=JARFILE],
1874        [Specify path to jarfile manually.]),
1875    LIBBASE_JAR=$withval)
1876
1877AC_ARG_WITH(system-odbc,
1878    AS_HELP_STRING([--with-system-odbc],
1879        [Use the odbc headers already on system.]),,
1880    [with_system_odbc="auto"])
1881
1882AC_ARG_WITH(system-sane,
1883    AS_HELP_STRING([--with-system-sane],
1884        [Use sane.h already on system.]),,
1885    [with_system_sane="$with_system_headers"])
1886
1887AC_ARG_WITH(system-bluez,
1888    AS_HELP_STRING([--with-system-bluez],
1889        [Use bluetooth.h already on system.]),,
1890    [with_system_bluez="$with_system_headers"])
1891
1892AC_ARG_WITH(system-curl,
1893    AS_HELP_STRING([--with-system-curl],
1894        [Use curl already on system.]),,
1895    [with_system_curl=auto])
1896
1897AC_ARG_WITH(system-boost,
1898    AS_HELP_STRING([--with-system-boost],
1899        [Use boost already on system.]),,
1900    [with_system_boost="$with_system_headers"])
1901
1902AC_ARG_WITH(system-glm,
1903    AS_HELP_STRING([--with-system-glm],
1904        [Use glm already on system.]),,
1905    [with_system_glm="$with_system_headers"])
1906
1907AC_ARG_WITH(system-hunspell,
1908    AS_HELP_STRING([--with-system-hunspell],
1909        [Use libhunspell already on system.]),,
1910    [with_system_hunspell="$with_system_libs"])
1911
1912AC_ARG_WITH(system-qrcodegen,
1913    AS_HELP_STRING([--with-system-qrcodegen],
1914        [Use libqrcodegen already on system.]),,
1915    [with_system_qrcodegen="$with_system_libs"])
1916
1917AC_ARG_WITH(system-mythes,
1918    AS_HELP_STRING([--with-system-mythes],
1919        [Use mythes already on system.]),,
1920    [with_system_mythes="$with_system_libs"])
1921
1922AC_ARG_WITH(system-altlinuxhyph,
1923    AS_HELP_STRING([--with-system-altlinuxhyph],
1924        [Use ALTLinuxhyph already on system.]),,
1925    [with_system_altlinuxhyph="$with_system_libs"])
1926
1927AC_ARG_WITH(system-lpsolve,
1928    AS_HELP_STRING([--with-system-lpsolve],
1929        [Use lpsolve already on system.]),,
1930    [with_system_lpsolve="$with_system_libs"])
1931
1932AC_ARG_WITH(system-coinmp,
1933    AS_HELP_STRING([--with-system-coinmp],
1934        [Use CoinMP already on system.]),,
1935    [with_system_coinmp="$with_system_libs"])
1936
1937AC_ARG_WITH(system-liblangtag,
1938    AS_HELP_STRING([--with-system-liblangtag],
1939        [Use liblangtag library already on system.]),,
1940    [with_system_liblangtag="$with_system_libs"])
1941
1942AC_ARG_WITH(webdav,
1943    AS_HELP_STRING([--with-webdav],
1944        [Specify which library to use for webdav implementation.
1945         Possible values: "neon", "serf", "no". The default value is "neon".
1946         Example: --with-webdav="serf"]),
1947    WITH_WEBDAV=$withval,
1948    WITH_WEBDAV="neon")
1949
1950AC_ARG_WITH(linker-hash-style,
1951    AS_HELP_STRING([--with-linker-hash-style],
1952        [Use linker with --hash-style=<style> when linking shared objects.
1953         Possible values: "sysv", "gnu", "both". The default value is "gnu"
1954         if supported on the build system, and "sysv" otherwise.]))
1955
1956AC_ARG_WITH(jdk-home,
1957    AS_HELP_STRING([--with-jdk-home=<absolute path to JDK home>],
1958        [If you have installed JDK 1.6 or later on your system please supply the
1959         path here. Note that this is not the location of the java command but the
1960         location of the entire distribution.]),
1961,)
1962
1963AC_ARG_WITH(help,
1964    AS_HELP_STRING([--with-help],
1965        [Enable the build of help. There is a special parameter "common" that
1966         can be used to bundle only the common part, .e.g help-specific icons.
1967         This is useful when you build the helpcontent separately.])
1968    [
1969                          Usage:     --with-help    build the old local help
1970                                 --without-help     no local help (default)
1971                                 --with-help=html   build the new HTML local help
1972                                 --with-help=online build the new HTML online help
1973    ],
1974,)
1975
1976libo_FUZZ_ARG_WITH(java,
1977    AS_HELP_STRING([--with-java=<java command>],
1978        [Specify the name of the Java interpreter command. Typically "java"
1979         which is the default.
1980
1981         To build without support for Java components, applets, accessibility
1982         or the XML filters written in Java, use --without-java or --with-java=no.]),
1983    [ test -z "$with_java" -o "$with_java" = "yes" && with_java=java ],
1984    [ test -z "$with_java" -o "$with_java" = "yes" && with_java=java ]
1985)
1986
1987AC_ARG_WITH(jvm-path,
1988    AS_HELP_STRING([--with-jvm-path=<absolute path to parent of jvm home>],
1989        [Use a specific JVM search path at runtime.
1990         e.g. use --with-jvm-path=/usr/lib/ to find JRE/JDK in /usr/lib/jvm/]),
1991,)
1992
1993AC_ARG_WITH(ant-home,
1994    AS_HELP_STRING([--with-ant-home=<absolute path to Ant home>],
1995        [If you have installed Apache Ant on your system, please supply the path here.
1996         Note that this is not the location of the Ant binary but the location
1997         of the entire distribution.]),
1998,)
1999
2000AC_ARG_WITH(symbol-config,
2001    AS_HELP_STRING([--with-symbol-config],
2002        [Configuration for the crashreport symbol upload]),
2003        [],
2004        [with_symbol_config=no])
2005
2006AC_ARG_WITH(export-validation,
2007    AS_HELP_STRING([--without-export-validation],
2008        [Disable validating OOXML and ODF files as exported from in-tree tests.]),
2009,with_export_validation=auto)
2010
2011AC_ARG_WITH(bffvalidator,
2012    AS_HELP_STRING([--with-bffvalidator=<absolute path to BFFValidator>],
2013        [Enables export validation for Microsoft Binary formats (doc, xls, ppt).
2014         Requires installed Microsoft Office Binary File Format Validator.
2015         Note: export-validation (--with-export-validation) is required to be turned on.
2016         See https://www.microsoft.com/en-us/download/details.aspx?id=26794]),
2017,with_bffvalidator=no)
2018
2019libo_FUZZ_ARG_WITH(junit,
2020    AS_HELP_STRING([--with-junit=<absolute path to JUnit 4 jar>],
2021        [Specifies the JUnit 4 jar file to use for JUnit-based tests.
2022         --without-junit disables those tests. Not relevant in the --without-java case.]),
2023,with_junit=yes)
2024
2025AC_ARG_WITH(hamcrest,
2026    AS_HELP_STRING([--with-hamcrest=<absolute path to hamcrest jar>],
2027        [Specifies the hamcrest jar file to use for JUnit-based tests.
2028         --without-junit disables those tests. Not relevant in the --without-java case.]),
2029,with_hamcrest=yes)
2030
2031AC_ARG_WITH(perl-home,
2032    AS_HELP_STRING([--with-perl-home=<abs. path to Perl 5 home>],
2033        [If you have installed Perl 5 Distribution, on your system, please
2034         supply the path here. Note that this is not the location of the Perl
2035         binary but the location of the entire distribution.]),
2036,)
2037
2038libo_FUZZ_ARG_WITH(doxygen,
2039    AS_HELP_STRING(
2040        [--with-doxygen=<absolute path to doxygen executable>],
2041        [Specifies the doxygen executable to use when generating ODK C/C++
2042         documentation. --without-doxygen disables generation of ODK C/C++
2043         documentation. Not relevant in the --disable-odk case.]),
2044,with_doxygen=yes)
2045
2046AC_ARG_WITH(visual-studio,
2047    AS_HELP_STRING([--with-visual-studio=<2017>],
2048        [Specify which Visual Studio version to use in case several are
2049         installed. Currently only 2017 is supported.]),
2050,)
2051
2052AC_ARG_WITH(windows-sdk,
2053    AS_HELP_STRING([--with-windows-sdk=<7.1(A)/8.0(A)/8.1(A)/10>],
2054        [Specify which Windows SDK, or "Windows Kit", version to use
2055         in case the one that came with the selected Visual Studio
2056         is not what you want for some reason. Note that not all compiler/SDK
2057         combinations are supported. The intent is that this option should not
2058         be needed.]),
2059,)
2060
2061AC_ARG_WITH(lang,
2062    AS_HELP_STRING([--with-lang="es sw tu cs sk"],
2063        [Use this option to build LibreOffice with additional UI language support.
2064         English (US) is always included by default.
2065         Separate multiple languages with space.
2066         For all languages, use --with-lang=ALL.]),
2067,)
2068
2069AC_ARG_WITH(locales,
2070    AS_HELP_STRING([--with-locales="en es pt fr zh kr ja"],
2071        [Use this option to limit the locale information built in.
2072         Separate multiple locales with space.
2073         Very experimental and might well break stuff.
2074         Just a desperate measure to shrink code and data size.
2075         By default all the locales available is included.
2076         This option is completely unrelated to --with-lang.])
2077    [
2078                          Affects also our character encoding conversion
2079                          tables for encodings mainly targeted for a
2080                          particular locale, like EUC-CN and EUC-TW for
2081                          zh, ISO-2022-JP for ja.
2082
2083                          Affects also our add-on break iterator data for
2084                          some languages.
2085
2086                          For the default, all locales, don't use this switch at all.
2087                          Specifying just the language part of a locale means all matching
2088                          locales will be included.
2089    ],
2090,)
2091
2092# Kerberos and GSSAPI used only by PostgreSQL as of LibO 3.5
2093libo_FUZZ_ARG_WITH(krb5,
2094    AS_HELP_STRING([--with-krb5],
2095        [Enable MIT Kerberos 5 support in modules that support it.
2096         By default automatically enabled on platforms
2097         where a good system Kerberos 5 is available.]),
2098,)
2099
2100libo_FUZZ_ARG_WITH(gssapi,
2101    AS_HELP_STRING([--with-gssapi],
2102        [Enable GSSAPI support in modules that support it.
2103         By default automatically enabled on platforms
2104         where a good system GSSAPI is available.]),
2105,)
2106
2107AC_ARG_WITH(iwyu,
2108    AS_HELP_STRING([--with-iwyu],
2109        [Use given IWYU binary path to check unneeded includes instead of building.
2110         Use only if you are hacking on it.]),
2111,)
2112
2113libo_FUZZ_ARG_WITH(lxml,
2114    AS_HELP_STRING([--without-lxml],
2115        [gla11y will use python lxml when available, potentially building a local copy if necessary.
2116         --without-lxml tells it to not use python lxml at all, which means that gla11y will only
2117         report widget classes and ids.]),
2118,)
2119
2120dnl ===================================================================
2121dnl Branding
2122dnl ===================================================================
2123
2124AC_ARG_WITH(branding,
2125    AS_HELP_STRING([--with-branding=/path/to/images],
2126        [Use given path to retrieve branding images set.])
2127    [
2128                          Search for intro.png about.svg and flat_logo.svg.
2129                          If any is missing, default ones will be used instead.
2130
2131                          Search also progress.conf for progress
2132                          settings on intro screen :
2133
2134                          PROGRESSBARCOLOR="255,255,255" Set color of
2135                          progress bar. Comma separated RGB decimal values.
2136                          PROGRESSSIZE="407,6" Set size of progress bar.
2137                          Comma separated decimal values (width, height).
2138                          PROGRESSPOSITION="61,317" Set position of progress
2139                          bar from left,top. Comma separated decimal values.
2140                          PROGRESSFRAMECOLOR="20,136,3" Set color of progress
2141                          bar frame. Comma separated RGB decimal values.
2142                          PROGRESSTEXTCOLOR="0,0,0" Set color of progress
2143                          bar text. Comma separated RGB decimal values.
2144                          PROGRESSTEXTBASELINE="287" Set vertical position of
2145                          progress bar text from top. Decimal value.
2146
2147                          Default values will be used if not found.
2148    ],
2149,)
2150
2151
2152AC_ARG_WITH(extra-buildid,
2153    AS_HELP_STRING([--with-extra-buildid="Tinderbox: Win-x86@6, Branch:master, Date:2012-11-26_00.29.34"],
2154        [Show addition build identification in about dialog.]),
2155,)
2156
2157
2158AC_ARG_WITH(vendor,
2159    AS_HELP_STRING([--with-vendor="John the Builder"],
2160        [Set vendor of the build.]),
2161,)
2162
2163AC_ARG_WITH(android-package-name,
2164    AS_HELP_STRING([--with-android-package-name="org.libreoffice"],
2165        [Set Android package name of the build.]),
2166,)
2167
2168AC_ARG_WITH(compat-oowrappers,
2169    AS_HELP_STRING([--with-compat-oowrappers],
2170        [Install oo* wrappers in parallel with
2171         lo* ones to keep backward compatibility.
2172         Has effect only with make distro-pack-install]),
2173,)
2174
2175AC_ARG_WITH(os-version,
2176    AS_HELP_STRING([--with-os-version=<OSVERSION>],
2177        [For FreeBSD users, use this option to override the detected OSVERSION.]),
2178,)
2179
2180AC_ARG_WITH(mingw-cross-compiler,
2181    AS_HELP_STRING([--with-mingw-cross-compiler=<mingw32-g++ command>],
2182        [Specify the MinGW cross-compiler to use.
2183         When building on the ODK on Unix and building unowinreg.dll,
2184         specify the MinGW C++ cross-compiler.]),
2185,)
2186
2187AC_ARG_WITH(idlc-cpp,
2188    AS_HELP_STRING([--with-idlc-cpp=<cpp/ucpp>],
2189        [Specify the C Preprocessor to use for idlc. Default is ucpp.]),
2190,)
2191
2192AC_ARG_WITH(build-version,
2193    AS_HELP_STRING([--with-build-version="Built by Jim"],
2194        [Allows the builder to add a custom version tag that will appear in the
2195         Help/About box for QA purposes.]),
2196with_build_version=$withval,
2197)
2198
2199AC_ARG_WITH(parallelism,
2200    AS_HELP_STRING([--with-parallelism],
2201        [Number of jobs to run simultaneously during build. Parallel builds can
2202        save a lot of time on multi-cpu machines. Defaults to the number of
2203        CPUs on the machine, unless you configure --enable-icecream - then to
2204        10.]),
2205,)
2206
2207AC_ARG_WITH(all-tarballs,
2208    AS_HELP_STRING([--with-all-tarballs],
2209        [Download all external tarballs unconditionally]))
2210
2211AC_ARG_WITH(gdrive-client-id,
2212    AS_HELP_STRING([--with-gdrive-client-id],
2213        [Provides the client id of the application for OAuth2 authentication
2214        on Google Drive. If either this or --with-gdrive-client-secret is
2215        empty, the feature will be disabled]),
2216)
2217
2218AC_ARG_WITH(gdrive-client-secret,
2219    AS_HELP_STRING([--with-gdrive-client-secret],
2220        [Provides the client secret of the application for OAuth2
2221        authentication on Google Drive. If either this or
2222        --with-gdrive-client-id is empty, the feature will be disabled]),
2223)
2224
2225AC_ARG_WITH(alfresco-cloud-client-id,
2226    AS_HELP_STRING([--with-alfresco-cloud-client-id],
2227        [Provides the client id of the application for OAuth2 authentication
2228        on Alfresco Cloud. If either this or --with-alfresco-cloud-client-secret is
2229        empty, the feature will be disabled]),
2230)
2231
2232AC_ARG_WITH(alfresco-cloud-client-secret,
2233    AS_HELP_STRING([--with-alfresco-cloud-client-secret],
2234        [Provides the client secret of the application for OAuth2
2235        authentication on Alfresco Cloud. If either this or
2236        --with-alfresco-cloud-client-id is empty, the feature will be disabled]),
2237)
2238
2239AC_ARG_WITH(onedrive-client-id,
2240    AS_HELP_STRING([--with-onedrive-client-id],
2241        [Provides the client id of the application for OAuth2 authentication
2242        on OneDrive. If either this or --with-onedrive-client-secret is
2243        empty, the feature will be disabled]),
2244)
2245
2246AC_ARG_WITH(onedrive-client-secret,
2247    AS_HELP_STRING([--with-onedrive-client-secret],
2248        [Provides the client secret of the application for OAuth2
2249        authentication on OneDrive. If either this or
2250        --with-onedrive-client-id is empty, the feature will be disabled]),
2251)
2252dnl ===================================================================
2253dnl Do we want to use pre-build binary tarball for recompile
2254dnl ===================================================================
2255
2256if test "$enable_library_bin_tar" = "yes" ; then
2257    USE_LIBRARY_BIN_TAR=TRUE
2258else
2259    USE_LIBRARY_BIN_TAR=
2260fi
2261AC_SUBST(USE_LIBRARY_BIN_TAR)
2262
2263dnl ===================================================================
2264dnl Test whether build target is Release Build
2265dnl ===================================================================
2266AC_MSG_CHECKING([whether build target is Release Build])
2267if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
2268    AC_MSG_RESULT([no])
2269    ENABLE_RELEASE_BUILD=
2270else
2271    AC_MSG_RESULT([yes])
2272    ENABLE_RELEASE_BUILD=TRUE
2273fi
2274AC_SUBST(ENABLE_RELEASE_BUILD)
2275
2276dnl ===================================================================
2277dnl Test whether to sign Windows Build
2278dnl ===================================================================
2279AC_MSG_CHECKING([whether to sign windows build])
2280if test "$enable_windows_build_signing" = "yes" -a "$_os" = "WINNT"; then
2281    AC_MSG_RESULT([yes])
2282    WINDOWS_BUILD_SIGNING="TRUE"
2283else
2284    AC_MSG_RESULT([no])
2285    WINDOWS_BUILD_SIGNING="FALSE"
2286fi
2287AC_SUBST(WINDOWS_BUILD_SIGNING)
2288
2289dnl ===================================================================
2290dnl MacOSX build and runtime environment options
2291dnl ===================================================================
2292
2293AC_ARG_WITH(macosx-sdk,
2294    AS_HELP_STRING([--with-macosx-sdk=<version>],
2295        [Prefer a specific SDK for building.])
2296    [
2297                          If the requested SDK is not available, a search for the oldest one will be done.
2298                          With current Xcode versions, only the latest SDK is included, so this option is
2299                          not terribly useful. It works fine to build with a new SDK and run the result
2300                          on an older OS.
2301
2302                          e. g.: --with-macosx-sdk=10.10
2303
2304                          there are 3 options to control the MacOSX build:
2305                          --with-macosx-sdk (referred as 'sdk' below)
2306                          --with-macosx-version-min-required (referred as 'min' below)
2307                          --with-macosx-version-max-allowed (referred as 'max' below)
2308
2309                          the connection between these value and the default they take is as follow:
2310                          ( ? means not specified on the command line, s means the SDK version found,
2311                          constraint: 8 <= x <= y <= z)
2312
2313                          ==========================================
2314                           command line      || config result
2315                          ==========================================
2316                          min  | max  | sdk  || min   | max  | sdk  |
2317                          ?    | ?    | ?    || 10.10 | 10.s | 10.s |
2318                          ?    | ?    | 10.x || 10.10 | 10.x | 10.x |
2319                          ?    | 10.x | ?    || 10.10 | 10.s | 10.s |
2320                          ?    | 10.x | 10.y || 10.10 | 10.x | 10.y |
2321                          10.x | ?    | ?    || 10.x  | 10.s | 10.s |
2322                          10.x | ?    | 10.y || 10.x  | 10.y | 10.y |
2323                          10.x | 10.y | ?    || 10.x  | 10.y | 10.y |
2324                          10.x | 10.y | 10.z || 10.x  | 10.y | 10.z |
2325
2326
2327                          see: http://developer.apple.com/library/mac/#technotes/tn2064/_index.html
2328                          for a detailed technical explanation of these variables
2329
2330                          Note: MACOSX_DEPLOYMENT_TARGET will be set to the value of 'min'.
2331    ],
2332,)
2333
2334AC_ARG_WITH(macosx-version-min-required,
2335    AS_HELP_STRING([--with-macosx-version-min-required=<version>],
2336        [set the minimum OS version needed to run the built LibreOffice])
2337    [
2338                          e. g.: --with-macos-version-min-required=10.10
2339                          see --with-macosx-sdk for more info
2340    ],
2341,)
2342
2343AC_ARG_WITH(macosx-version-max-allowed,
2344    AS_HELP_STRING([--with-macosx-version-max-allowed=<version>],
2345        [set the maximum allowed OS version the LibreOffice compilation can use APIs from])
2346    [
2347                          e. g.: --with-macos-version-max-allowed=10.10
2348                          see --with-macosx-sdk for more info
2349    ],
2350,)
2351
2352
2353dnl ===================================================================
2354dnl options for stuff used during cross-compilation build
2355dnl Not quite superseded by --with-build-platform-configure-options.
2356dnl TODO: check, if the "force" option is still needed anywhere.
2357dnl ===================================================================
2358
2359AC_ARG_WITH(system-icu-for-build,
2360    AS_HELP_STRING([--with-system-icu-for-build=yes/no/force],
2361        [Use icu already on system for build tools (cross-compilation only).]))
2362
2363
2364dnl ===================================================================
2365dnl Check for incompatible options set by fuzzing, and reset those
2366dnl automatically to working combinations
2367dnl ===================================================================
2368
2369if test "$libo_fuzzed_enable_dbus" = yes -a "$libo_fuzzed_enable_avahi" -a \
2370        "$enable_dbus" != "$enable_avahi"; then
2371    AC_MSG_NOTICE([Resetting --enable-avahi=$enable_dbus])
2372    enable_avahi=$enable_dbus
2373fi
2374
2375add_lopath_after ()
2376{
2377    if ! echo "$LO_PATH" | $EGREP -q "(^|${P_SEP})$1($|${P_SEP})"; then
2378        LO_PATH="${LO_PATH:+$LO_PATH$P_SEP}$1"
2379    fi
2380}
2381
2382add_lopath_before ()
2383{
2384    local IFS=${P_SEP}
2385    local path_cleanup
2386    local dir
2387    for dir in $LO_PATH ; do
2388        if test "$dir" != "$1" ; then
2389            path_cleanup=${path_cleanup:+$path_cleanup$P_SEP}$dir
2390        fi
2391    done
2392    LO_PATH="$1${path_cleanup:+$P_SEP$path_cleanup}"
2393}
2394
2395dnl ===================================================================
2396dnl check for required programs (grep, awk, sed, bash)
2397dnl ===================================================================
2398
2399pathmunge ()
2400{
2401    if test -n "$1"; then
2402        if test "$build_os" = "cygwin"; then
2403            if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
2404                PathFormat "$1"
2405                new_path=`cygpath -sm "$formatted_path"`
2406            else
2407                PathFormat "$1"
2408                new_path=`cygpath -u "$formatted_path"`
2409            fi
2410        else
2411            new_path="$1"
2412        fi
2413        if test "$2" = "after"; then
2414            add_lopath_after "$new_path"
2415        else
2416            add_lopath_before "$new_path"
2417        fi
2418        unset new_path
2419    fi
2420}
2421
2422AC_PROG_AWK
2423AC_PATH_PROG( AWK, $AWK)
2424if test -z "$AWK"; then
2425    AC_MSG_ERROR([install awk to run this script])
2426fi
2427
2428AC_PATH_PROG(BASH, bash)
2429if test -z "$BASH"; then
2430    AC_MSG_ERROR([bash not found in \$PATH])
2431fi
2432AC_SUBST(BASH)
2433
2434AC_MSG_CHECKING([for GNU or BSD tar])
2435for a in $GNUTAR gtar gnutar bsdtar tar /usr/sfw/bin/gtar; do
2436    $a --version 2> /dev/null | egrep "GNU|bsdtar"  2>&1 > /dev/null
2437    if test $? -eq 0;  then
2438        GNUTAR=$a
2439        break
2440    fi
2441done
2442AC_MSG_RESULT($GNUTAR)
2443if test -z "$GNUTAR"; then
2444    AC_MSG_ERROR([not found. install GNU or BSD tar.])
2445fi
2446AC_SUBST(GNUTAR)
2447
2448AC_MSG_CHECKING([for tar's option to strip components])
2449$GNUTAR --help 2> /dev/null | egrep "bsdtar|strip-components" 2>&1 >/dev/null
2450if test $? -eq 0; then
2451    STRIP_COMPONENTS="--strip-components"
2452else
2453    $GNUTAR --help 2> /dev/null | egrep "strip-path" 2>&1 >/dev/null
2454    if test $? -eq 0; then
2455        STRIP_COMPONENTS="--strip-path"
2456    else
2457        STRIP_COMPONENTS="unsupported"
2458    fi
2459fi
2460AC_MSG_RESULT($STRIP_COMPONENTS)
2461if test x$STRIP_COMPONENTS = xunsupported; then
2462    AC_MSG_ERROR([you need a tar that is able to strip components.])
2463fi
2464AC_SUBST(STRIP_COMPONENTS)
2465
2466dnl It is useful to have a BUILD_TYPE keyword to distinguish "normal"
2467dnl desktop OSes from "mobile" ones.
2468
2469dnl We assume that a non-DESKTOP build type is also a non-NATIVE one.
2470dnl In other words, that when building for an OS that is not a
2471dnl "desktop" one but a "mobile" one, we are always cross-compiling.
2472
2473dnl Note the direction of the implication; there is no assumption that
2474dnl cross-compiling would imply a non-desktop OS.
2475
2476if test $_os != iOS -a $_os != Android -a "$enable_fuzzers" != "yes"; then
2477    BUILD_TYPE="$BUILD_TYPE DESKTOP"
2478    AC_DEFINE(HAVE_FEATURE_DESKTOP)
2479    AC_DEFINE(HAVE_FEATURE_MULTIUSER_ENVIRONMENT)
2480fi
2481
2482# Whether to build "avmedia" functionality or not.
2483
2484if test -z "$enable_avmedia"; then
2485    enable_avmedia=yes
2486fi
2487
2488BUILD_TYPE="$BUILD_TYPE AVMEDIA"
2489if test "$enable_avmedia" = yes; then
2490    AC_DEFINE(HAVE_FEATURE_AVMEDIA)
2491else
2492    USE_AVMEDIA_DUMMY='TRUE'
2493fi
2494AC_SUBST(USE_AVMEDIA_DUMMY)
2495
2496# Decide whether to build database connectivity stuff (including
2497# Base) or not. We probably don't want to on non-desktop OSes.
2498if test -z "$enable_database_connectivity"; then
2499    # --disable-database-connectivity is unfinished work in progress
2500    # and the iOS test app doesn't link if we actually try to use it.
2501    # if test $_os != iOS -a $_os != Android; then
2502    if test $_os != iOS; then
2503        enable_database_connectivity=yes
2504    fi
2505fi
2506
2507if test "$enable_database_connectivity" = yes; then
2508    BUILD_TYPE="$BUILD_TYPE DBCONNECTIVITY"
2509    AC_DEFINE(HAVE_FEATURE_DBCONNECTIVITY)
2510fi
2511
2512if test -z "$enable_extensions"; then
2513    # For iOS and Android disable extensions unless specifically overridden with --enable-extensions.
2514    if test $_os != iOS -a $_os != Android; then
2515        enable_extensions=yes
2516    fi
2517fi
2518
2519if test "$enable_extensions" = yes; then
2520    BUILD_TYPE="$BUILD_TYPE EXTENSIONS"
2521    AC_DEFINE(HAVE_FEATURE_EXTENSIONS)
2522fi
2523
2524if test -z "$enable_scripting"; then
2525    # Disable scripting for iOS unless specifically overridden
2526    # with --enable-scripting.
2527    if test $_os != iOS; then
2528        enable_scripting=yes
2529    fi
2530fi
2531
2532DISABLE_SCRIPTING=''
2533if test "$enable_scripting" = yes; then
2534    BUILD_TYPE="$BUILD_TYPE SCRIPTING"
2535    AC_DEFINE(HAVE_FEATURE_SCRIPTING)
2536else
2537    DISABLE_SCRIPTING='TRUE'
2538    SCPDEFS="$SCPDEFS -DDISABLE_SCRIPTING"
2539fi
2540
2541if test $_os = iOS -o $_os = Android; then
2542    # Disable dynamic_loading always for iOS and Android
2543    enable_dynamic_loading=no
2544elif test -z "$enable_dynamic_loading"; then
2545    # Otherwise enable it unless specifically disabled
2546    enable_dynamic_loading=yes
2547fi
2548
2549DISABLE_DYNLOADING=''
2550if test "$enable_dynamic_loading" = yes; then
2551    BUILD_TYPE="$BUILD_TYPE DYNLOADING"
2552else
2553    DISABLE_DYNLOADING='TRUE'
2554fi
2555AC_SUBST(DISABLE_DYNLOADING)
2556
2557# remember SYSBASE value
2558AC_SUBST(SYSBASE)
2559
2560dnl ===================================================================
2561dnl  Sort out various gallery compilation options
2562dnl ===================================================================
2563AC_MSG_CHECKING([how to build and package galleries])
2564if test -n "${with_galleries}"; then
2565    if test "$with_galleries" = "build"; then
2566        WITH_GALLERY_BUILD=TRUE
2567        AC_MSG_RESULT([build from source images internally])
2568    elif test "$with_galleries" = "no"; then
2569        WITH_GALLERY_BUILD=
2570        AC_MSG_RESULT([disable non-internal gallery build])
2571    else
2572        AC_MSG_ERROR([unknown value --with-galleries=$with_galleries])
2573    fi
2574else
2575    if test $_os != iOS -a $_os != Android; then
2576        WITH_GALLERY_BUILD=TRUE
2577        AC_MSG_RESULT([internal src images for desktop])
2578    else
2579        WITH_GALLERY_BUILD=
2580        AC_MSG_RESULT([disable src image build])
2581    fi
2582fi
2583AC_SUBST(WITH_GALLERY_BUILD)
2584
2585dnl ===================================================================
2586dnl  Checks if ccache is available
2587dnl ===================================================================
2588CCACHE_DEPEND_MODE=
2589if test "$_os" = "WINNT"; then
2590    # on windows/VC build do not use ccache
2591    CCACHE=""
2592elif test "$enable_ccache" = "no"; then
2593    CCACHE=""
2594elif test -n "$enable_ccache" -o \( "$enable_ccache" = "" -a "$enable_icecream" != "yes" \); then
2595    case "%$CC%$CXX%" in
2596    # If $CC and/or $CXX already contain "ccache" (possibly suffixed with some version number etc),
2597    # assume that's good then
2598    *%ccache[[-_' ']]*|*/ccache[[-_' ']]*)
2599        AC_MSG_NOTICE([ccache seems to be included in a pre-defined CC and/or CXX])
2600        CCACHE_DEPEND_MODE=1
2601        ;;
2602    *)
2603        AC_PATH_PROG([CCACHE],[ccache],[not found])
2604        if test "$CCACHE" = "not found"; then
2605            CCACHE=""
2606        else
2607            CCACHE_DEPEND_MODE=1
2608            # Need to check for ccache version: otherwise prevents
2609            # caching of the results (like "-x objective-c++" for Mac)
2610            if test $_os = Darwin -o $_os = iOS; then
2611                # Check ccache version
2612                AC_MSG_CHECKING([whether version of ccache is suitable])
2613                CCACHE_VERSION=`"$CCACHE" -V | "$AWK" '/^ccache version/{print $3}'`
2614                CCACHE_NUMVER=`echo $CCACHE_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
2615                if test "$CCACHE_VERSION" = "2.4_OOo" -o "$CCACHE_NUMVER" -ge "030100"; then
2616                    AC_MSG_RESULT([yes, $CCACHE_VERSION])
2617                else
2618                    AC_MSG_RESULT([no, $CCACHE_VERSION])
2619                    CCACHE=""
2620                    CCACHE_DEPEND_MODE=
2621                fi
2622            fi
2623        fi
2624        ;;
2625    esac
2626else
2627    CCACHE=""
2628fi
2629if test "$enable_ccache" = "nodepend"; then
2630    CCACHE_DEPEND_MODE=""
2631fi
2632AC_SUBST(CCACHE_DEPEND_MODE)
2633
2634if test "$CCACHE" != ""; then
2635    ccache_size_msg=$([ccache -s | tail -n 1 | sed 's/^[^0-9]*//' | sed -e 's/\.[0-9]*//'])
2636    ccache_size=$(echo "$ccache_size_msg" | grep "G" | sed -e 's/G.*$//')
2637    if test "$ccache_size" = ""; then
2638        ccache_size=$(echo "$ccache_size_msg" | grep "M" | sed -e 's/\ M.*$//')
2639        if test "$ccache_size" = ""; then
2640            ccache_size=0
2641        fi
2642        # we could not determine the size or it was less than 1GB -> disable auto-ccache
2643        if test $ccache_size -lt 1024; then
2644            CCACHE=""
2645            AC_MSG_WARN([ccache's cache size is less than 1GB using it is counter-productive: Disabling auto-ccache detection])
2646            add_warning "ccache's cache size is less than 1GB using it is counter-productive: auto-ccache detection disabled"
2647        else
2648            # warn that ccache may be too small for debug build
2649            AC_MSG_WARN([ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build])
2650            add_warning "ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build"
2651        fi
2652    else
2653        if test $ccache_size -lt 5; then
2654            #warn that ccache may be too small for debug build
2655            AC_MSG_WARN([ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build])
2656            add_warning "ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build"
2657        fi
2658    fi
2659fi
2660
2661dnl ===================================================================
2662dnl  Checks for C compiler,
2663dnl  The check for the C++ compiler is later on.
2664dnl ===================================================================
2665if test "$_os" != "WINNT"; then
2666    GCC_HOME_SET="true"
2667    AC_MSG_CHECKING([gcc home])
2668    if test -z "$with_gcc_home"; then
2669        if test "$enable_icecream" = "yes"; then
2670            if test -d "/usr/lib/icecc/bin"; then
2671                GCC_HOME="/usr/lib/icecc/"
2672            elif test -d "/usr/libexec/icecc/bin"; then
2673                GCC_HOME="/usr/libexec/icecc/"
2674            elif test -d "/opt/icecream/bin"; then
2675                GCC_HOME="/opt/icecream/"
2676            else
2677                AC_MSG_ERROR([Could not figure out the location of icecream GCC wrappers, manually use --with-gcc-home])
2678
2679            fi
2680        else
2681            GCC_HOME=`which gcc | $SED -e s,/bin/gcc,,`
2682            GCC_HOME_SET="false"
2683        fi
2684    else
2685        GCC_HOME="$with_gcc_home"
2686    fi
2687    AC_MSG_RESULT($GCC_HOME)
2688    AC_SUBST(GCC_HOME)
2689
2690    if test "$GCC_HOME_SET" = "true"; then
2691        if test -z "$CC"; then
2692            CC="$GCC_HOME/bin/gcc"
2693        fi
2694        if test -z "$CXX"; then
2695            CXX="$GCC_HOME/bin/g++"
2696        fi
2697    fi
2698fi
2699
2700COMPATH=`dirname "$CC"`
2701if test "$COMPATH" = "."; then
2702    AC_PATH_PROGS(COMPATH, $CC)
2703    dnl double square bracket to get single because of M4 quote...
2704    COMPATH=`echo $COMPATH | $SED "s@/[[^/:]]*\\\$@@"`
2705fi
2706COMPATH=`echo $COMPATH | $SED "s@/[[Bb]][[Ii]][[Nn]]\\\$@@"`
2707
2708dnl ===================================================================
2709dnl Java support
2710dnl ===================================================================
2711AC_MSG_CHECKING([whether to build with Java support])
2712if test "$with_java" != "no"; then
2713    if test "$DISABLE_SCRIPTING" = TRUE; then
2714        AC_MSG_RESULT([no, overridden by --disable-scripting])
2715        ENABLE_JAVA=""
2716        with_java=no
2717    else
2718        AC_MSG_RESULT([yes])
2719        ENABLE_JAVA="TRUE"
2720        AC_DEFINE(HAVE_FEATURE_JAVA)
2721    fi
2722else
2723    AC_MSG_RESULT([no])
2724    ENABLE_JAVA=""
2725fi
2726
2727AC_SUBST(ENABLE_JAVA)
2728
2729dnl ENABLE_JAVA="TRUE" if we want there to be *run-time* (and build-time) support for Java
2730
2731dnl ENABLE_JAVA="" indicate no Java support at all
2732
2733dnl ===================================================================
2734dnl Check macOS SDK and compiler
2735dnl ===================================================================
2736
2737if test $_os = Darwin -o $_os = iOS; then
2738
2739    # If no --with-macosx-sdk option is given, look for one
2740
2741    # The intent is that for "most" Mac-based developers, a suitable
2742    # SDK will be found automatically without any configure options.
2743
2744    # For developers with a current Xcode, the lowest-numbered SDK
2745    # higher than or equal to the minimum required should be found.
2746
2747    AC_MSG_CHECKING([what macOS SDK to use])
2748    for _macosx_sdk in ${with_macosx_sdk-10.15 10.14 10.13 10.12}; do
2749        MACOSX_SDK_PATH=`xcrun --sdk macosx${_macosx_sdk} --show-sdk-path 2> /dev/null`
2750        if test -d "$MACOSX_SDK_PATH"; then
2751            with_macosx_sdk="${_macosx_sdk}"
2752            break
2753        else
2754            MACOSX_SDK_PATH="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${_macosx_sdk}.sdk"
2755            if test -d "$MACOSX_SDK_PATH"; then
2756                with_macosx_sdk="${_macosx_sdk}"
2757                break
2758            fi
2759        fi
2760    done
2761    if test ! -d "$MACOSX_SDK_PATH"; then
2762        AC_MSG_ERROR([Could not find an appropriate macOS SDK])
2763    fi
2764
2765    if test $_os = iOS; then
2766        if test "$enable_ios_simulator" = "yes"; then
2767            useos=iphonesimulator
2768        else
2769            useos=iphoneos
2770        fi
2771        MACOSX_SDK_PATH=`xcrun --sdk ${useos} --show-sdk-path 2> /dev/null`
2772    fi
2773    AC_MSG_RESULT([SDK $with_macosx_sdk at $MACOSX_SDK_PATH])
2774
2775
2776    case $with_macosx_sdk in
2777    10.12)
2778        MACOSX_SDK_VERSION=101200
2779        ;;
2780    10.13)
2781        MACOSX_SDK_VERSION=101300
2782        ;;
2783    10.14)
2784        MACOSX_SDK_VERSION=101400
2785        ;;
2786    10.15)
2787        MACOSX_SDK_VERSION=101500
2788        ;;
2789    *)
2790        AC_MSG_ERROR([with-macosx-sdk $with_macosx_sdk is not a supported value, supported values are 10.12--15])
2791        ;;
2792    esac
2793
2794    if test "$with_macosx_version_min_required" = "" ; then
2795        with_macosx_version_min_required="10.10";
2796    fi
2797
2798    if test "$with_macosx_version_max_allowed" = "" ; then
2799        with_macosx_version_max_allowed="$with_macosx_sdk"
2800    fi
2801
2802    # export this so that "xcrun" invocations later return matching values
2803    DEVELOPER_DIR="${MACOSX_SDK_PATH%/SDKs*}"
2804    DEVELOPER_DIR="${DEVELOPER_DIR%/Platforms*}"
2805    export DEVELOPER_DIR
2806    FRAMEWORKSHOME="$MACOSX_SDK_PATH/System/Library/Frameworks"
2807    MACOSX_DEPLOYMENT_TARGET="$with_macosx_version_min_required"
2808
2809    AC_MSG_CHECKING([whether Xcode is new enough])
2810    my_xcode_ver1=$(xcrun xcodebuild -version | head -n 1)
2811    my_xcode_ver2=${my_xcode_ver1#Xcode }
2812    my_xcode_ver3=$(printf %s "$my_xcode_ver2" | $AWK -F. '{ print $1*100+($2<100?$2:99) }')
2813    if test "$my_xcode_ver3" -ge 903; then
2814        AC_MSG_RESULT([yes ($my_xcode_ver2)])
2815    else
2816        AC_MSG_ERROR(["$my_xcode_ver1" is too old or unrecognized, must be at least Xcode 9.3])
2817    fi
2818
2819    case "$with_macosx_version_min_required" in
2820    10.10)
2821        MAC_OS_X_VERSION_MIN_REQUIRED="101000"
2822        ;;
2823    10.11)
2824        MAC_OS_X_VERSION_MIN_REQUIRED="101100"
2825        ;;
2826    10.12)
2827        MAC_OS_X_VERSION_MIN_REQUIRED="101200"
2828        ;;
2829    10.13)
2830        MAC_OS_X_VERSION_MIN_REQUIRED="101300"
2831        ;;
2832    10.14)
2833        MAC_OS_X_VERSION_MIN_REQUIRED="101400"
2834        ;;
2835    10.15)
2836        MAC_OS_X_VERSION_MIN_REQUIRED="101500"
2837        ;;
2838    *)
2839        AC_MSG_ERROR([with-macosx-version-min-required $with_macosx_version_min_required is not a supported value, supported values are 10.10--15])
2840        ;;
2841    esac
2842    MAC_OS_X_VERSION_MIN_REQUIRED_DOTS=$with_macosx_version_min_required
2843
2844    LIBTOOL=/usr/bin/libtool
2845    INSTALL_NAME_TOOL=install_name_tool
2846    if test -z "$save_CC"; then
2847        AC_MSG_CHECKING([what compiler to use])
2848        stdlib=-stdlib=libc++
2849        if test "$ENABLE_LTO" = TRUE; then
2850            lto=-flto
2851        fi
2852        CC="`xcrun -find clang` -m64 $lto -mmacosx-version-min=$with_macosx_version_min_required -isysroot $MACOSX_SDK_PATH"
2853        CXX="`xcrun -find clang++` -m64 $lto $stdlib -mmacosx-version-min=$with_macosx_version_min_required -isysroot $MACOSX_SDK_PATH"
2854        INSTALL_NAME_TOOL=`xcrun -find install_name_tool`
2855        AR=`xcrun -find ar`
2856        NM=`xcrun -find nm`
2857        STRIP=`xcrun -find strip`
2858        LIBTOOL=`xcrun -find libtool`
2859        RANLIB=`xcrun -find ranlib`
2860        AC_MSG_RESULT([$CC and $CXX])
2861    fi
2862
2863    case "$with_macosx_version_max_allowed" in
2864    10.10)
2865        MAC_OS_X_VERSION_MAX_ALLOWED="101000"
2866        ;;
2867    10.11)
2868        MAC_OS_X_VERSION_MAX_ALLOWED="101100"
2869        ;;
2870    10.12)
2871        MAC_OS_X_VERSION_MAX_ALLOWED="101200"
2872        ;;
2873    10.13)
2874        MAC_OS_X_VERSION_MAX_ALLOWED="101300"
2875        ;;
2876    10.14)
2877        MAC_OS_X_VERSION_MAX_ALLOWED="101400"
2878        ;;
2879    10.15)
2880        MAC_OS_X_VERSION_MAX_ALLOWED="101500"
2881        ;;
2882    *)
2883        AC_MSG_ERROR([with-macosx-version-max-allowed $with_macosx_version_max_allowed is not a supported value, supported values are 10.10--15])
2884        ;;
2885    esac
2886
2887    AC_MSG_CHECKING([that macosx-version-min-required is coherent with macosx-version-max-allowed])
2888    if test $MAC_OS_X_VERSION_MIN_REQUIRED -gt $MAC_OS_X_VERSION_MAX_ALLOWED; then
2889        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])
2890    else
2891        AC_MSG_RESULT([ok])
2892    fi
2893
2894    AC_MSG_CHECKING([that macosx-version-max-allowed is coherent with macos-with-sdk])
2895    if test $MAC_OS_X_VERSION_MAX_ALLOWED -gt $MACOSX_SDK_VERSION; then
2896        AC_MSG_ERROR([the version maximum allowed cannot be greater than the sdk level])
2897    else
2898        AC_MSG_RESULT([ok])
2899    fi
2900    AC_MSG_NOTICE([MAC_OS_X_VERSION_MIN_REQUIRED=$MAC_OS_X_VERSION_MIN_REQUIRED])
2901    AC_MSG_NOTICE([MAC_OS_X_VERSION_MAX_ALLOWED=$MAC_OS_X_VERSION_MAX_ALLOWED])
2902
2903    AC_MSG_CHECKING([whether to do code signing])
2904
2905    if test "$enable_macosx_code_signing" = yes; then
2906        # By default use the first suitable certificate (?).
2907
2908        # http://stackoverflow.com/questions/13196291/difference-between-mac-developer-and-3rd-party-mac-developer-application
2909        # says that the "Mac Developer" certificate is useful just for self-testing. For distribution
2910        # outside the Mac App Store, use the "Developer ID Application" one, and for distribution in
2911        # the App Store, the "3rd Party Mac Developer" one. I think it works best to the
2912        # "Developer ID Application" one.
2913
2914        identity=`security find-identity -p codesigning -v 2>/dev/null | grep 'Developer ID Application:' | $AWK '{print $2}' |head -1`
2915        if test -n "$identity"; then
2916            MACOSX_CODESIGNING_IDENTITY=$identity
2917            pretty_name=`security find-identity -p codesigning -v | grep "$MACOSX_CODESIGNING_IDENTITY" | sed -e 's/^[[^"]]*"//' -e 's/"//'`
2918            AC_MSG_RESULT([yes, using the identity $MACOSX_CODESIGNING_IDENTITY for $pretty_name])
2919        else
2920            AC_MSG_ERROR([cannot determine identity to use])
2921        fi
2922    elif test -n "$enable_macosx_code_signing" -a "$enable_macosx_code_signing" != no ; then
2923        MACOSX_CODESIGNING_IDENTITY=$enable_macosx_code_signing
2924        pretty_name=`security find-identity -p codesigning -v | grep "$MACOSX_CODESIGNING_IDENTITY" | sed -e 's/^[[^"]]*"//' -e 's/"//'`
2925        AC_MSG_RESULT([yes, using the identity $MACOSX_CODESIGNING_IDENTITY for $pretty_name])
2926    else
2927        AC_MSG_RESULT([no])
2928    fi
2929
2930    AC_MSG_CHECKING([whether to create a Mac App Store package])
2931
2932    if test -n "$enable_macosx_package_signing" -a -z "$MACOSX_CODESIGNING_IDENTITY"; then
2933        AC_MSG_ERROR([You forgot --enable-macosx-code-signing])
2934    elif test "$enable_macosx_package_signing" = yes; then
2935        # By default use the first suitable certificate.
2936        # It should be a "3rd Party Mac Developer Installer" one
2937
2938        identity=`security find-identity -v 2>/dev/null | grep '3rd Party Mac Developer Installer:' | awk '{print $2}' |head -1`
2939        if test -n "$identity"; then
2940            MACOSX_PACKAGE_SIGNING_IDENTITY=$identity
2941            pretty_name=`security find-identity -v | grep "$MACOSX_PACKAGE_SIGNING_IDENTITY" | sed -e 's/^[[^"]]*"//' -e 's/"//'`
2942            AC_MSG_RESULT([yes, using the identity $MACOSX_PACKAGE_SIGNING_IDENTITY for $pretty_name])
2943        else
2944            AC_MSG_ERROR([Could not find any suitable '3rd Party Mac Developer Installer' certificate])
2945        fi
2946    elif test -n "$enable_macosx_package_signing"; then
2947        MACOSX_PACKAGE_SIGNING_IDENTITY=$enable_macosx_package_signing
2948        pretty_name=`security find-identity -v | grep "$MACOSX_PACKAGE_SIGNING_IDENTITY" | sed -e 's/^[[^"]]*"//' -e 's/"//'`
2949        AC_MSG_RESULT([yes, using the identity $MACOSX_PACKAGE_SIGNING_IDENTITY for $pretty_name])
2950    else
2951        AC_MSG_RESULT([no])
2952    fi
2953
2954    if test -n "$MACOSX_CODESIGNING_IDENTITY" -a -n "$MACOSX_PACKAGE_SIGNING_IDENTITY" -a "$MACOSX_CODESIGNING_IDENTITY" = "$MACOSX_PACKAGE_SIGNING_IDENTITY"; then
2955        AC_MSG_ERROR([You should not use the same identity for code and package signing])
2956    fi
2957
2958    AC_MSG_CHECKING([whether to sandbox the application])
2959
2960    if test -z "$MACOSX_CODESIGNING_IDENTITY" -a "$enable_macosx_sandbox" = yes; then
2961        AC_MSG_ERROR([macOS sandboxing requires code signing])
2962    elif test -n "$ENABLE_JAVA" -a "$enable_macosx_sandbox" = yes; then
2963        AC_MSG_ERROR([macOS sandboxing (actually App Store rules) disallows use of Java])
2964    elif test -n "$MACOSX_CODESIGNING_IDENTITY" -a "$enable_macosx_sandbox" = yes; then
2965        ENABLE_MACOSX_SANDBOX=TRUE
2966        AC_DEFINE(HAVE_FEATURE_MACOSX_SANDBOX)
2967        AC_MSG_RESULT([yes])
2968    else
2969        AC_MSG_RESULT([no])
2970    fi
2971
2972    AC_MSG_CHECKING([what macOS app bundle identifier to use])
2973    MACOSX_BUNDLE_IDENTIFIER=$with_macosx_bundle_identifier
2974    AC_MSG_RESULT([$MACOSX_BUNDLE_IDENTIFIER])
2975fi
2976AC_SUBST(MACOSX_SDK_PATH)
2977AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
2978AC_SUBST(MAC_OS_X_VERSION_MIN_REQUIRED)
2979AC_SUBST(MAC_OS_X_VERSION_MIN_REQUIRED_DOTS)
2980AC_SUBST(MAC_OS_X_VERSION_MAX_ALLOWED)
2981AC_SUBST(INSTALL_NAME_TOOL)
2982AC_SUBST(LIBTOOL) # Note that the macOS libtool command is unrelated to GNU libtool
2983AC_SUBST(MACOSX_CODESIGNING_IDENTITY)
2984AC_SUBST(MACOSX_PACKAGE_SIGNING_IDENTITY)
2985AC_SUBST(ENABLE_MACOSX_SANDBOX)
2986AC_SUBST(MACOSX_BUNDLE_IDENTIFIER)
2987
2988dnl ===================================================================
2989dnl Check iOS SDK and compiler
2990dnl ===================================================================
2991
2992if test $_os = iOS; then
2993    AC_MSG_CHECKING([what iOS SDK to use])
2994    current_sdk_ver=12.2
2995    older_sdk_vers="13.0 12.1 12.0 11.4"
2996    if test "$enable_ios_simulator" = "yes"; then
2997        platform=iPhoneSimulator
2998        versionmin=-mios-simulator-version-min=11.0
2999    else
3000        platform=iPhoneOS
3001        versionmin=-miphoneos-version-min=11.0
3002    fi
3003    xcode_developer=`xcode-select -print-path`
3004
3005    for sdkver in $current_sdk_ver $older_sdk_vers; do
3006        t=$xcode_developer/Platforms/$platform.platform/Developer/SDKs/$platform$sdkver.sdk
3007        if test -d $t; then
3008            sysroot=$t
3009            break
3010        fi
3011    done
3012
3013    if test -z "$sysroot"; then
3014        AC_MSG_ERROR([Could not find iOS SDK, expected something like $xcode_developer/Platforms/$platform.platform/Developer/SDKs/${platform}${current_sdk_ver}.sdk])
3015    fi
3016
3017    AC_MSG_RESULT($sysroot)
3018
3019    # LTO is not really recommended for iOS builds,
3020    # the link time will be astronomical
3021    if test "$ENABLE_LTO" = TRUE; then
3022        lto=-flto
3023    fi
3024
3025    stdlib="-stdlib=libc++"
3026
3027    CC="`xcrun -find clang` -arch $host_cpu -isysroot $sysroot $lto $versionmin"
3028    CXX="`xcrun -find clang++` -arch $host_cpu $stdlib -isysroot $sysroot $lto $versionmin"
3029
3030    INSTALL_NAME_TOOL=`xcrun -find install_name_tool`
3031    AR=`xcrun -find ar`
3032    NM=`xcrun -find nm`
3033    STRIP=`xcrun -find strip`
3034    LIBTOOL=`xcrun -find libtool`
3035    RANLIB=`xcrun -find ranlib`
3036fi
3037
3038AC_MSG_CHECKING([whether to treat the installation as read-only])
3039
3040if test \( -z "$enable_readonly_installset" -a "$ENABLE_MACOSX_SANDBOX" = TRUE \) -o \
3041        "$enable_extensions" != yes; then
3042    enable_readonly_installset=yes
3043fi
3044if test "$enable_readonly_installset" = yes; then
3045    AC_MSG_RESULT([yes])
3046    AC_DEFINE(HAVE_FEATURE_READONLY_INSTALLSET)
3047else
3048    AC_MSG_RESULT([no])
3049fi
3050
3051dnl ===================================================================
3052dnl Structure of install set
3053dnl ===================================================================
3054
3055if test $_os = Darwin; then
3056    LIBO_BIN_FOLDER=MacOS
3057    LIBO_ETC_FOLDER=Resources
3058    LIBO_LIBEXEC_FOLDER=MacOS
3059    LIBO_LIB_FOLDER=Frameworks
3060    LIBO_LIB_PYUNO_FOLDER=Resources
3061    LIBO_SHARE_FOLDER=Resources
3062    LIBO_SHARE_HELP_FOLDER=Resources/help
3063    LIBO_SHARE_JAVA_FOLDER=Resources/java
3064    LIBO_SHARE_PRESETS_FOLDER=Resources/presets
3065    LIBO_SHARE_READMES_FOLDER=Resources/readmes
3066    LIBO_SHARE_RESOURCE_FOLDER=Resources/resource
3067    LIBO_SHARE_SHELL_FOLDER=Resources/shell
3068    LIBO_URE_BIN_FOLDER=MacOS
3069    LIBO_URE_ETC_FOLDER=Resources/ure/etc
3070    LIBO_URE_LIB_FOLDER=Frameworks
3071    LIBO_URE_MISC_FOLDER=Resources/ure/share/misc
3072    LIBO_URE_SHARE_JAVA_FOLDER=Resources/java
3073elif test $_os = WINNT; then
3074    LIBO_BIN_FOLDER=program
3075    LIBO_ETC_FOLDER=program
3076    LIBO_LIBEXEC_FOLDER=program
3077    LIBO_LIB_FOLDER=program
3078    LIBO_LIB_PYUNO_FOLDER=program
3079    LIBO_SHARE_FOLDER=share
3080    LIBO_SHARE_HELP_FOLDER=help
3081    LIBO_SHARE_JAVA_FOLDER=program/classes
3082    LIBO_SHARE_PRESETS_FOLDER=presets
3083    LIBO_SHARE_READMES_FOLDER=readmes
3084    LIBO_SHARE_RESOURCE_FOLDER=program/resource
3085    LIBO_SHARE_SHELL_FOLDER=program/shell
3086    LIBO_URE_BIN_FOLDER=program
3087    LIBO_URE_ETC_FOLDER=program
3088    LIBO_URE_LIB_FOLDER=program
3089    LIBO_URE_MISC_FOLDER=program
3090    LIBO_URE_SHARE_JAVA_FOLDER=program/classes
3091else
3092    LIBO_BIN_FOLDER=program
3093    LIBO_ETC_FOLDER=program
3094    LIBO_LIBEXEC_FOLDER=program
3095    LIBO_LIB_FOLDER=program
3096    LIBO_LIB_PYUNO_FOLDER=program
3097    LIBO_SHARE_FOLDER=share
3098    LIBO_SHARE_HELP_FOLDER=help
3099    LIBO_SHARE_JAVA_FOLDER=program/classes
3100    LIBO_SHARE_PRESETS_FOLDER=presets
3101    LIBO_SHARE_READMES_FOLDER=readmes
3102    if test "$enable_fuzzers" != yes; then
3103        LIBO_SHARE_RESOURCE_FOLDER=program/resource
3104    else
3105        LIBO_SHARE_RESOURCE_FOLDER=resource
3106    fi
3107    LIBO_SHARE_SHELL_FOLDER=program/shell
3108    LIBO_URE_BIN_FOLDER=program
3109    LIBO_URE_ETC_FOLDER=program
3110    LIBO_URE_LIB_FOLDER=program
3111    LIBO_URE_MISC_FOLDER=program
3112    LIBO_URE_SHARE_JAVA_FOLDER=program/classes
3113fi
3114AC_DEFINE_UNQUOTED(LIBO_BIN_FOLDER,"$LIBO_BIN_FOLDER")
3115AC_DEFINE_UNQUOTED(LIBO_ETC_FOLDER,"$LIBO_ETC_FOLDER")
3116AC_DEFINE_UNQUOTED(LIBO_LIBEXEC_FOLDER,"$LIBO_LIBEXEC_FOLDER")
3117AC_DEFINE_UNQUOTED(LIBO_LIB_FOLDER,"$LIBO_LIB_FOLDER")
3118AC_DEFINE_UNQUOTED(LIBO_LIB_PYUNO_FOLDER,"$LIBO_LIB_PYUNO_FOLDER")
3119AC_DEFINE_UNQUOTED(LIBO_SHARE_FOLDER,"$LIBO_SHARE_FOLDER")
3120AC_DEFINE_UNQUOTED(LIBO_SHARE_HELP_FOLDER,"$LIBO_SHARE_HELP_FOLDER")
3121AC_DEFINE_UNQUOTED(LIBO_SHARE_JAVA_FOLDER,"$LIBO_SHARE_JAVA_FOLDER")
3122AC_DEFINE_UNQUOTED(LIBO_SHARE_PRESETS_FOLDER,"$LIBO_SHARE_PRESETS_FOLDER")
3123AC_DEFINE_UNQUOTED(LIBO_SHARE_RESOURCE_FOLDER,"$LIBO_SHARE_RESOURCE_FOLDER")
3124AC_DEFINE_UNQUOTED(LIBO_SHARE_SHELL_FOLDER,"$LIBO_SHARE_SHELL_FOLDER")
3125AC_DEFINE_UNQUOTED(LIBO_URE_BIN_FOLDER,"$LIBO_URE_BIN_FOLDER")
3126AC_DEFINE_UNQUOTED(LIBO_URE_ETC_FOLDER,"$LIBO_URE_ETC_FOLDER")
3127AC_DEFINE_UNQUOTED(LIBO_URE_LIB_FOLDER,"$LIBO_URE_LIB_FOLDER")
3128AC_DEFINE_UNQUOTED(LIBO_URE_MISC_FOLDER,"$LIBO_URE_MISC_FOLDER")
3129AC_DEFINE_UNQUOTED(LIBO_URE_SHARE_JAVA_FOLDER,"$LIBO_URE_SHARE_JAVA_FOLDER")
3130
3131# Not all of them needed in config_host.mk, add more if need arises
3132AC_SUBST(LIBO_BIN_FOLDER)
3133AC_SUBST(LIBO_ETC_FOLDER)
3134AC_SUBST(LIBO_LIB_FOLDER)
3135AC_SUBST(LIBO_LIB_PYUNO_FOLDER)
3136AC_SUBST(LIBO_SHARE_FOLDER)
3137AC_SUBST(LIBO_SHARE_HELP_FOLDER)
3138AC_SUBST(LIBO_SHARE_JAVA_FOLDER)
3139AC_SUBST(LIBO_SHARE_PRESETS_FOLDER)
3140AC_SUBST(LIBO_SHARE_READMES_FOLDER)
3141AC_SUBST(LIBO_SHARE_RESOURCE_FOLDER)
3142AC_SUBST(LIBO_URE_BIN_FOLDER)
3143AC_SUBST(LIBO_URE_ETC_FOLDER)
3144AC_SUBST(LIBO_URE_LIB_FOLDER)
3145AC_SUBST(LIBO_URE_MISC_FOLDER)
3146AC_SUBST(LIBO_URE_SHARE_JAVA_FOLDER)
3147
3148dnl ===================================================================
3149dnl Windows specific tests and stuff
3150dnl ===================================================================
3151
3152reg_get_value()
3153{
3154    # Return value: $regvalue
3155    unset regvalue
3156
3157    local _regentry="/proc/registry${1}/${2}"
3158    if test -f "$_regentry"; then
3159        # Stop bash complaining about \0 bytes in input, as it can't handle them.
3160        # Registry keys read via /proc/registry* are always \0 terminated!
3161        local _regvalue=$(tr -d '\0' < "$_regentry")
3162        if test $? -eq 0; then
3163            regvalue=$_regvalue
3164        fi
3165    fi
3166}
3167
3168# Get a value from the 32-bit side of the Registry
3169reg_get_value_32()
3170{
3171    reg_get_value "32" "$1"
3172}
3173
3174# Get a value from the 64-bit side of the Registry
3175reg_get_value_64()
3176{
3177    reg_get_value "64" "$1"
3178}
3179
3180if test "$_os" = "WINNT"; then
3181    AC_MSG_CHECKING([whether to build a 64-bit LibreOffice])
3182    if test "$enable_64_bit" = "" -o "$enable_64_bit" = "no"; then
3183        AC_MSG_RESULT([no])
3184        WINDOWS_SDK_ARCH="x86"
3185    else
3186        AC_MSG_RESULT([yes])
3187        WINDOWS_SDK_ARCH="x64"
3188        BITNESS_OVERRIDE=64
3189    fi
3190fi
3191if test "$_os" = "iOS"; then
3192    cross_compiling="yes"
3193fi
3194
3195if test "$cross_compiling" = "yes"; then
3196    export CROSS_COMPILING=TRUE
3197else
3198    CROSS_COMPILING=
3199    BUILD_TYPE="$BUILD_TYPE NATIVE"
3200fi
3201AC_SUBST(CROSS_COMPILING)
3202
3203# Use -isystem (gcc) if possible, to avoid warnings in 3rd party headers.
3204# NOTE: must _not_ be used for bundled external libraries!
3205ISYSTEM=
3206if test "$GCC" = "yes"; then
3207    AC_MSG_CHECKING( for -isystem )
3208    save_CFLAGS=$CFLAGS
3209    CFLAGS="$CFLAGS -Werror"
3210    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ ISYSTEM="-isystem " ],[])
3211    CFLAGS=$save_CFLAGS
3212    if test -n "$ISYSTEM"; then
3213        AC_MSG_RESULT(yes)
3214    else
3215        AC_MSG_RESULT(no)
3216    fi
3217fi
3218if test -z "$ISYSTEM"; then
3219    # fall back to using -I
3220    ISYSTEM=-I
3221fi
3222AC_SUBST(ISYSTEM)
3223
3224dnl ===================================================================
3225dnl  Check which Visual Studio compiler is used
3226dnl ===================================================================
3227
3228map_vs_year_to_version()
3229{
3230    # Return value: $vsversion
3231
3232    unset vsversion
3233
3234    case $1 in
3235    2017)
3236        vsversion=15;;
3237    2019)
3238        vsversion=16;;
3239    *)
3240        AC_MSG_ERROR([Assertion failure - invalid argument "$1" to map_vs_year_to_version()]);;
3241    esac
3242}
3243
3244vs_versions_to_check()
3245{
3246    # Args: $1 (optional) : versions to check, in the order of preference
3247    # Return value: $vsversions
3248
3249    unset vsversions
3250
3251    if test -n "$1"; then
3252        map_vs_year_to_version "$1"
3253        vsversions=$vsversion
3254    else
3255        # We accept only 2017
3256        vsversions="15"
3257    fi
3258}
3259
3260win_get_env_from_vsvars32bat()
3261{
3262    WRAPPERBATCHFILEPATH="`mktemp -t wrpXXXXXX.bat`"
3263    # Also seems to be located in another directory under the same name: vsvars32.bat
3264    # https://github.com/bazelbuild/bazel/blob/master/src/main/native/build_windows_jni.sh#L56-L57
3265    printf '@call "%s/../Common7/Tools/VsDevCmd.bat" /no_logo\r\n' "$(cygpath -w $VC_PRODUCT_DIR)" > $WRAPPERBATCHFILEPATH
3266    printf '@setlocal\r\n@echo %%%s%%\r\n@endlocal\r\n' "$1" >> $WRAPPERBATCHFILEPATH
3267    chmod +x $WRAPPERBATCHFILEPATH
3268    _win_get_env_from_vsvars32bat=$("$WRAPPERBATCHFILEPATH" | tr -d '\r')
3269    rm -f $WRAPPERBATCHFILEPATH
3270    printf '%s' "$_win_get_env_from_vsvars32bat"
3271}
3272
3273find_ucrt()
3274{
3275    reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v10.0/InstallationFolder"
3276    if test -n "$regvalue"; then
3277        PathFormat "$regvalue"
3278        UCRTSDKDIR=$formatted_path
3279        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v10.0/ProductVersion"
3280        UCRTVERSION=$regvalue
3281        # Rest if not exist
3282        if ! test -d "${UCRTSDKDIR}Include/$UCRTVERSION/ucrt"; then
3283          UCRTSDKDIR=
3284        fi
3285    fi
3286    if test -z "$UCRTSDKDIR"; then
3287        ide_env_dir="$VC_PRODUCT_DIR/../Common7/Tools/"
3288        ide_env_file="${ide_env_dir}VsDevCmd.bat"
3289        if test -f "$ide_env_file"; then
3290            PathFormat "$(win_get_env_from_vsvars32bat UniversalCRTSdkDir)"
3291            UCRTSDKDIR=$formatted_path
3292            UCRTVERSION=$(win_get_env_from_vsvars32bat UCRTVersion)
3293            dnl Hack needed at least by tml:
3294            if test "$UCRTVERSION" = 10.0.15063.0 \
3295                -a ! -f "${UCRTSDKDIR}Include/10.0.15063.0/um/sqlext.h" \
3296                -a -f "${UCRTSDKDIR}Include/10.0.14393.0/um/sqlext.h"
3297            then
3298                UCRTVERSION=10.0.14393.0
3299            fi
3300        else
3301          AC_MSG_ERROR([No UCRT found])
3302        fi
3303    fi
3304}
3305
3306find_msvc()
3307{
3308    # Find Visual C++ 2017/2019
3309    # Args: $1 (optional) : The VS version year
3310    # Return values: $vctest, $vcyear, $vcnum, $vcnumwithdot, $vcbuildnumber
3311
3312    unset vctest vcnum vcnumwithdot vcbuildnumber
3313
3314    vs_versions_to_check "$1"
3315    vswhere="$(perl -e 'print $ENV{"ProgramFiles(x86)"}')"
3316    vswhere+="\\Microsoft Visual Studio\\Installer\\vswhere.exe"
3317    PathFormat "$vswhere"
3318    vswhere=$formatted_path
3319    for ver in $vsversions; do
3320        vswhereoutput=`$vswhere -version "@<:@ $ver , $(expr $ver + 1) @:}@" -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | head -1`
3321        if test -n "$vswhereoutput"; then
3322            PathFormat "$vswhereoutput"
3323            vctest=$formatted_path
3324            break
3325        fi
3326    done
3327
3328    # This fallback is needed on *some* (but not all) VS 2017 installations, where vswhere turns up
3329    # with the empty list for unclear reason. The below hack does not work for VS 2019 anyway, so
3330    # should be removed when upgrading baseline.
3331    if ! test -n "$vctest"; then
3332        for ver in $vsversions; do
3333            reg_get_value_32 HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/VisualStudio/$ver.0/Setup/VC/ProductDir
3334            if test -n "$regvalue"; then
3335                vctest=$regvalue
3336                break
3337            fi
3338            reg_get_value_32 HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/VisualStudio/SxS/VS7/$ver.0
3339            if test -n "$regvalue"; then
3340                AC_MSG_RESULT([found: $regvalue])
3341                PathFormat "$regvalue"
3342                vctest=$formatted_path
3343                break
3344            fi
3345        done
3346    fi
3347
3348    if test -n "$vctest"; then
3349        vcnumwithdot="$ver.0"
3350        case "$vcnumwithdot" in
3351        15.0)
3352            vcyear=2017
3353            vcnum=150
3354            ;;
3355        16.0)
3356            vcyear=2019
3357            vcnum=160
3358            ;;
3359        esac
3360        vcbuildnumber=`ls $vctest/VC/Tools/MSVC -A1r | head -1`
3361
3362    fi
3363}
3364
3365SOLARINC=
3366MSBUILD_PATH=
3367DEVENV=
3368if test "$_os" = "WINNT"; then
3369    AC_MSG_CHECKING([Visual C++])
3370    find_msvc "$with_visual_studio"
3371    if test -z "$vctest"; then
3372        if test -n "$with_visual_studio"; then
3373            AC_MSG_ERROR([No Visual Studio $with_visual_studio installation found])
3374        else
3375            AC_MSG_ERROR([No Visual Studio 2017 installation found])
3376        fi
3377    fi
3378
3379    if test "$BITNESS_OVERRIDE" = ""; then
3380        if test -f "$vctest/VC/Tools/MSVC/$vcbuildnumber/bin/HostX86/x86/cl.exe"; then
3381            VC_PRODUCT_DIR=$vctest/VC
3382        else
3383            AC_MSG_ERROR([No compiler (cl.exe) in $vctest/VC/Tools/MSVC/$vcbuildnumber/bin/HostX86/x86])
3384        fi
3385    else
3386        if test -f "$vctest/VC/Tools/MSVC/$vcbuildnumber/bin/HostX64/x64/cl.exe"; then
3387            VC_PRODUCT_DIR=$vctest/VC
3388        else
3389            AC_MSG_ERROR([No compiler (cl.exe) in $vctest/VC/Tools/MSVC/$vcbuildnumber/bin/HostX64/x64])
3390        fi
3391    fi
3392
3393    AC_MSG_CHECKING([for short pathname of VC product directory])
3394    VC_PRODUCT_DIR=`win_short_path_for_make "$VC_PRODUCT_DIR"`
3395    AC_MSG_RESULT([$VC_PRODUCT_DIR])
3396
3397    UCRTSDKDIR=
3398    UCRTVERSION=
3399
3400    AC_MSG_CHECKING([for UCRT location])
3401    find_ucrt
3402    # find_ucrt errors out if it doesn't find it
3403    AC_MSG_RESULT([found])
3404    PathFormat "${UCRTSDKDIR}Include/$UCRTVERSION/ucrt"
3405    ucrtincpath_formatted=$formatted_path
3406    # SOLARINC is used for external modules and must be set too.
3407    # And no, it's not sufficient to set SOLARINC only, as configure
3408    # itself doesn't honour it.
3409    SOLARINC="$SOLARINC -I$ucrtincpath_formatted"
3410    CFLAGS="$CFLAGS -I$ucrtincpath_formatted"
3411    CXXFLAGS="$CXXFLAGS -I$ucrtincpath_formatted"
3412    CPPFLAGS="$CPPFLAGS -I$ucrtincpath_formatted"
3413
3414    AC_SUBST(UCRTSDKDIR)
3415    AC_SUBST(UCRTVERSION)
3416
3417    AC_MSG_CHECKING([for MSBuild.exe location for: $vcnumwithdot])
3418    # Find the proper version of MSBuild.exe to use based on the VS version
3419    reg_get_value_32 HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MSBuild/$vcnumwithdot/MSBuildOverrideTasksPath
3420    if test -n "$regvalue" ; then
3421        AC_MSG_RESULT([found: $regvalue])
3422        MSBUILD_PATH=`win_short_path_for_make "$regvalue"`
3423    else
3424        if test "$vcnumwithdot" = "16.0"; then
3425            if test "$BITNESS_OVERRIDE" = ""; then
3426                regvalue="$VC_PRODUCT_DIR/../MSBuild/Current/Bin"
3427            else
3428                regvalue="$VC_PRODUCT_DIR/../MSBuild/Current/Bin/amd64"
3429            fi
3430        else
3431            if test "$BITNESS_OVERRIDE" = ""; then
3432                regvalue="$VC_PRODUCT_DIR/../MSBuild/$vcnumwithdot/Bin"
3433            else
3434                regvalue="$VC_PRODUCT_DIR/../MSBuild/$vcnumwithdot/Bin/amd64"
3435            fi
3436        fi
3437        MSBUILD_PATH=`win_short_path_for_make "$regvalue"`
3438        AC_MSG_RESULT([$regvalue])
3439    fi
3440
3441    # Find the version of devenv.exe
3442    # MSVC 2017 devenv does not start properly from a DOS 8.3 path
3443    DEVENV=$(cygpath -lm "$VC_PRODUCT_DIR/../Common7/IDE/devenv.exe")
3444    if test ! -e "$DEVENV"; then
3445        AC_MSG_ERROR([No devenv.exe found, Visual Studio installation broken?])
3446    fi
3447
3448    dnl ===========================================================
3449    dnl  Check for the corresponding mspdb*.dll
3450    dnl ===========================================================
3451
3452    VC_HOST_DIR=
3453    MSPDB_PATH=
3454    CL_PATH=
3455
3456    if "$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/HostX64/x64/cl.exe" -? </dev/null >/dev/null 2>&1; then
3457        VC_HOST_DIR="HostX64"
3458        MSPDB_PATH="$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/$VC_HOST_DIR/x64"
3459    else
3460        VC_HOST_DIR="HostX86"
3461        MSPDB_PATH="$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/$VC_HOST_DIR/x86"
3462    fi
3463
3464    if test "$BITNESS_OVERRIDE" = ""; then
3465        CL_PATH="$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/$VC_HOST_DIR/x86"
3466    else
3467        CL_PATH="$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/$VC_HOST_DIR/x64"
3468    fi
3469
3470    # MSVC 15.0 has libraries from 14.0?
3471    mspdbnum="140"
3472
3473    if test ! -e "$MSPDB_PATH/mspdb${mspdbnum}.dll"; then
3474        AC_MSG_ERROR([No mspdb${mspdbnum}.dll in $MSPDB_PATH, Visual Studio installation broken?])
3475    fi
3476
3477    dnl The path needs to be added before cl is called
3478    TEMP_PATH=`cygpath -d "$MSPDB_PATH"`
3479    PATH="`cygpath -u "$TEMP_PATH"`:$PATH"
3480
3481    AC_MSG_CHECKING([cl.exe])
3482
3483    # Is there really ever a need to pass CC explicitly? Surely we can hope to get all the
3484    # automagical niceness to work OK? If somebody has some unsupported compiler in some weird
3485    # location, isn't it likely that lots of other things needs changes, too, and just setting CC
3486    # is not enough?
3487
3488    dnl Save the true MSVC cl.exe for use when CC/CXX is actually clang-cl,
3489    dnl needed when building CLR code:
3490    if test -z "$MSVC_CXX"; then
3491        if test -f "$CL_PATH/cl.exe"; then
3492            MSVC_CXX="$CL_PATH/cl.exe"
3493        fi
3494
3495        # This gives us a posix path with 8.3 filename restrictions
3496        MSVC_CXX=`win_short_path_for_make "$MSVC_CXX"`
3497    fi
3498
3499    if test -z "$CC"; then
3500        CC=$MSVC_CXX
3501    fi
3502    if test "$BITNESS_OVERRIDE" = ""; then
3503        dnl since MSVC 2012, default for x86 is -arch:SSE2:
3504        MSVC_CXX="$MSVC_CXX -arch:SSE"
3505    fi
3506
3507    if test -n "$CC"; then
3508        # Remove /cl.exe from CC case insensitive
3509        AC_MSG_RESULT([found Visual C++ $vcyear ($CC)])
3510        if test "$BITNESS_OVERRIDE" = ""; then
3511           COMPATH="$VC_PRODUCT_DIR"
3512        else
3513            if test -n "$VC_PRODUCT_DIR"; then
3514                COMPATH=$VC_PRODUCT_DIR
3515            fi
3516        fi
3517        if test "$BITNESS_OVERRIDE" = ""; then
3518            dnl since MSVC 2012, default for x86 is -arch:SSE2:
3519            CC="$CC -arch:SSE"
3520        fi
3521
3522        COMPATH="$COMPATH/Tools/MSVC/$vcbuildnumber"
3523
3524        export INCLUDE=`cygpath -d "$COMPATH\Include"`
3525
3526        PathFormat "$COMPATH"
3527        COMPATH="$formatted_path"
3528
3529        VCVER=$vcnum
3530        MSVSVER=$vcyear
3531
3532        # The WINDOWS_SDK_ACCEPTABLE_VERSIONS is mostly an educated guess...  Assuming newer ones
3533        # are always "better", we list them in reverse chronological order.
3534
3535        case "$vcnum" in
3536        150|160)
3537            WINDOWS_SDK_ACCEPTABLE_VERSIONS="10.0 8.1A 8.1 8.0 7.1A"
3538            ;;
3539        esac
3540
3541        # The expectation is that --with-windows-sdk should not need to be used
3542        if test -n "$with_windows_sdk"; then
3543            case " $WINDOWS_SDK_ACCEPTABLE_VERSIONS " in
3544            *" "$with_windows_sdk" "*)
3545                WINDOWS_SDK_ACCEPTABLE_VERSIONS=$with_windows_sdk
3546                ;;
3547            *)
3548                AC_MSG_ERROR([Windows SDK $with_windows_sdk is not known to work with VS $MSVSVER])
3549                ;;
3550            esac
3551        fi
3552
3553        # Make AC_COMPILE_IFELSE etc. work (set by AC_PROG_C, which we don't use for MSVC)
3554        ac_objext=obj
3555        ac_exeext=exe
3556
3557    else
3558        AC_MSG_ERROR([Visual C++ not found after all, huh])
3559    fi
3560
3561    AC_MSG_CHECKING([$CC is at least Visual Studio 2017 version 15.7])
3562    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3563        // See <https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros> for mapping
3564        // between Visual Studio versions and _MSC_VER:
3565        #if _MSC_VER < 1914
3566        #error
3567        #endif
3568    ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no])])
3569
3570    # Check for 64-bit (cross-)compiler to use to build the 64-bit
3571    # version of the Explorer extension (and maybe other small
3572    # bits, too) needed when installing a 32-bit LibreOffice on a
3573    # 64-bit OS. The 64-bit Explorer extension is a feature that
3574    # has been present since long in OOo. Don't confuse it with
3575    # building LibreOffice itself as 64-bit code.
3576
3577    BUILD_X64=
3578    CXX_X64_BINARY=
3579
3580    if test "$BITNESS_OVERRIDE" = ""; then
3581        AC_MSG_CHECKING([for a x64 compiler and libraries for 64-bit Explorer extensions])
3582        if test -f "$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/atlmfc/lib/x64/atls.lib" || \
3583             test -f "$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/atlmfc/lib/spectre/x64/atls.lib"; then
3584            if "$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/$VC_HOST_DIR/x64/cl.exe" -? </dev/null >/dev/null 2>&1; then
3585                BUILD_X64=TRUE
3586                CXX_X64_BINARY=`win_short_path_for_make "$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/$VC_HOST_DIR/x64/cl.exe"`
3587            fi
3588        fi
3589        if test "$BUILD_X64" = TRUE; then
3590            AC_MSG_RESULT([found])
3591        else
3592            AC_MSG_RESULT([not found])
3593            AC_MSG_WARN([Installation set will not contain 64-bit Explorer extensions])
3594        fi
3595    else
3596        CXX_X64_BINARY=$MSVC_CXX
3597    fi
3598    AC_SUBST(BUILD_X64)
3599
3600    # These are passed to the environment and then used in gbuild/platform/com_MSC_class.mk
3601    AC_SUBST(CXX_X64_BINARY)
3602
3603    # Check for 32-bit compiler to use to build the 32-bit TWAIN shim
3604    # needed to support TWAIN scan on both 32- and 64-bit systems
3605
3606    BUILD_X86=
3607
3608    if test "$BITNESS_OVERRIDE" = "64"; then
3609        AC_MSG_CHECKING([for a x86 compiler and libraries for 32-bit binaries required for TWAIN support])
3610        if test -n "$CXX_X86_BINARY"; then
3611            BUILD_X86=TRUE
3612            AC_MSG_RESULT([preset])
3613        elif "$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/$VC_HOST_DIR/x86/cl.exe" -? </dev/null >/dev/null 2>&1; then
3614            BUILD_X86=TRUE
3615            CXX_X86_BINARY=`win_short_path_for_make "$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/$VC_HOST_DIR/x86/cl.exe"`
3616            CXX_X86_BINARY+=" /arch:SSE"
3617            AC_MSG_RESULT([found])
3618        else
3619            CXX_X86_BINARY=
3620            AC_MSG_RESULT([not found])
3621            AC_MSG_WARN([Installation set will not contain 32-bit binaries required for TWAIN support])
3622        fi
3623    else
3624        BUILD_X86=TRUE
3625        CXX_X86_BINARY=$MSVC_CXX
3626    fi
3627    AC_SUBST(BUILD_X86)
3628    AC_SUBST(CXX_X86_BINARY)
3629fi
3630AC_SUBST(VCVER)
3631AC_SUBST(DEVENV)
3632AC_SUBST(MSVC_CXX)
3633
3634#
3635# unowinreg.dll
3636#
3637UNOWINREG_DLL="185d60944ea767075d27247c3162b3bc-unowinreg.dll"
3638AC_SUBST(UNOWINREG_DLL)
3639
3640COM_IS_CLANG=
3641AC_MSG_CHECKING([whether the compiler is actually Clang])
3642AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3643    #ifndef __clang__
3644    you lose
3645    #endif
3646    int foo=42;
3647    ]])],
3648    [AC_MSG_RESULT([yes])
3649     COM_IS_CLANG=TRUE],
3650    [AC_MSG_RESULT([no])])
3651AC_SUBST(COM_IS_CLANG)
3652
3653CC_PLAIN=$CC
3654CLANGVER=
3655if test "$COM_IS_CLANG" = TRUE; then
3656    AC_MSG_CHECKING([whether Clang is new enough])
3657    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3658        #if !defined __apple_build_version__
3659        #error
3660        #endif
3661        ]])],
3662        [my_apple_clang=yes],[my_apple_clang=])
3663    if test "$my_apple_clang" = yes; then
3664        AC_MSG_RESULT([assumed yes (Apple Clang)])
3665    else
3666        if test "$_os" = WINNT; then
3667            dnl In which case, assume clang-cl:
3668            my_args="/EP /TC"
3669            dnl Filter out -FIIntrin.h, which needs to be explicitly stated for
3670            dnl clang-cl:
3671            CC_PLAIN=
3672            for i in $CC; do
3673                case $i in
3674                -FIIntrin.h)
3675                    ;;
3676                *)
3677                    CC_PLAIN="$CC_PLAIN $i"
3678                    ;;
3679                esac
3680            done
3681        else
3682            my_args="-E -P"
3683        fi
3684        clang_version=`echo __clang_major__.__clang_minor__.__clang_patchlevel__ | $CC_PLAIN $my_args - | sed 's/ //g'`
3685        CLANG_FULL_VERSION=`echo __clang_version__ | $CC_PLAIN $my_args -`
3686        CLANGVER=`echo $clang_version \
3687            | $AWK -F. '{ print \$1*10000+(\$2<100?\$2:99)*100+(\$3<100?\$3:99) }'`
3688        if test "$CLANGVER" -ge 50002; then
3689            AC_MSG_RESULT([yes ($clang_version)])
3690        else
3691            AC_MSG_ERROR(["$CLANG_FULL_VERSION" is too old or unrecognized, must be at least Clang 5.0.2])
3692        fi
3693        AC_DEFINE_UNQUOTED(CLANG_VERSION,$CLANGVER)
3694        AC_DEFINE_UNQUOTED(CLANG_FULL_VERSION,$CLANG_FULL_VERSION)
3695    fi
3696fi
3697
3698SHOWINCLUDES_PREFIX=
3699if test "$_os" = WINNT; then
3700    dnl We need to guess the prefix of the -showIncludes output, it can be
3701    dnl localized
3702    AC_MSG_CHECKING([the dependency generation prefix (cl.exe -showIncludes)])
3703    echo "#include <stdlib.h>" > conftest.c
3704    SHOWINCLUDES_PREFIX=`$CC_PLAIN $CFLAGS -c -showIncludes conftest.c 2>/dev/null | \
3705        grep 'stdlib\.h' | head -n1 | sed 's/ [[[:alpha:]]]:.*//'`
3706    rm -f conftest.c conftest.obj
3707    if test -z "$SHOWINCLUDES_PREFIX"; then
3708        AC_MSG_ERROR([cannot determine the -showIncludes prefix])
3709    else
3710        AC_MSG_RESULT(["$SHOWINCLUDES_PREFIX"])
3711    fi
3712fi
3713AC_SUBST(SHOWINCLUDES_PREFIX)
3714
3715#
3716# prefix C with ccache if needed
3717#
3718if test "$CCACHE" != ""; then
3719    AC_MSG_CHECKING([whether $CC is already ccached])
3720
3721    AC_LANG_PUSH([C])
3722    save_CFLAGS=$CFLAGS
3723    CFLAGS="$CFLAGS --ccache-skip -O2"
3724    dnl an empty program will do, we're checking the compiler flags
3725    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
3726                      [use_ccache=yes], [use_ccache=no])
3727    if test $use_ccache = yes; then
3728        AC_MSG_RESULT([yes])
3729    else
3730        CC="$CCACHE $CC"
3731        AC_MSG_RESULT([no])
3732    fi
3733    CFLAGS=$save_CFLAGS
3734    AC_LANG_POP([C])
3735fi
3736
3737# ===================================================================
3738# check various GCC options that Clang does not support now but maybe
3739# will somewhen in the future, check them even for GCC, so that the
3740# flags are set
3741# ===================================================================
3742
3743HAVE_GCC_GGDB2=
3744if test "$GCC" = "yes"; then
3745    AC_MSG_CHECKING([whether $CC supports -ggdb2])
3746    save_CFLAGS=$CFLAGS
3747    CFLAGS="$CFLAGS -Werror -ggdb2"
3748    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_GGDB2=TRUE ],[])
3749    CFLAGS=$save_CFLAGS
3750    if test "$HAVE_GCC_GGDB2" = "TRUE"; then
3751        AC_MSG_RESULT([yes])
3752    else
3753        AC_MSG_RESULT([no])
3754    fi
3755
3756    if test "$host_cpu" = "m68k"; then
3757        AC_MSG_CHECKING([whether $CC supports -mlong-jump-table-offsets])
3758        save_CFLAGS=$CFLAGS
3759        CFLAGS="$CFLAGS -Werror -mlong-jump-table-offsets"
3760        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_LONG_JUMP_TABLE_OFFSETS=TRUE ],[])
3761        CFLAGS=$save_CFLAGS
3762        if test "$HAVE_GCC_LONG_JUMP_TABLE_OFFSETS" = "TRUE"; then
3763            AC_MSG_RESULT([yes])
3764        else
3765            AC_MSG_ERROR([no])
3766        fi
3767    fi
3768fi
3769AC_SUBST(HAVE_GCC_GGDB2)
3770
3771dnl ===================================================================
3772dnl  Test the gcc version
3773dnl ===================================================================
3774if test "$GCC" = "yes" -a -z "$COM_IS_CLANG"; then
3775    AC_MSG_CHECKING([the GCC version])
3776    _gcc_version=`$CC -dumpversion`
3777    gcc_full_version=$(printf '%s' "$_gcc_version" | \
3778        $AWK -F. '{ print $1*10000+$2*100+(NF<3?1:$3) }')
3779    GCC_VERSION=`echo $_gcc_version | $AWK -F. '{ print \$1*100+\$2 }'`
3780
3781    AC_MSG_RESULT([gcc $_gcc_version ($gcc_full_version)])
3782
3783    if test "$gcc_full_version" -lt 70000; then
3784        AC_MSG_ERROR([GCC $_gcc_version is too old, must be at least GCC 7.0.0])
3785    fi
3786else
3787    # Explicitly force GCC_VERSION to be empty, even for Clang, to check incorrect uses.
3788    # GCC version should generally be checked only when handling GCC-specific bugs, for testing
3789    # things like features configure checks should be used, otherwise they may e.g. fail with Clang
3790    # (which reports itself as GCC 4.2.1).
3791    GCC_VERSION=
3792fi
3793AC_SUBST(GCC_VERSION)
3794
3795dnl Set the ENABLE_DBGUTIL variable
3796dnl ===================================================================
3797AC_MSG_CHECKING([whether to build with additional debug utilities])
3798if test -n "$enable_dbgutil" -a "$enable_dbgutil" != "no"; then
3799    ENABLE_DBGUTIL="TRUE"
3800    # this is an extra var so it can have different default on different MSVC
3801    # versions (in case there are version specific problems with it)
3802    MSVC_USE_DEBUG_RUNTIME="TRUE"
3803
3804    AC_MSG_RESULT([yes])
3805    # cppunit and graphite expose STL in public headers
3806    if test "$with_system_cppunit" = "yes"; then
3807        AC_MSG_ERROR([--with-system-cppunit conflicts with --enable-dbgutil])
3808    else
3809        with_system_cppunit=no
3810    fi
3811    if test "$with_system_graphite" = "yes"; then
3812        AC_MSG_ERROR([--with-system-graphite conflicts with --enable-dbgutil])
3813    else
3814        with_system_graphite=no
3815    fi
3816    if test "$with_system_orcus" = "yes"; then
3817        AC_MSG_ERROR([--with-system-orcus conflicts with --enable-dbgutil])
3818    else
3819        with_system_orcus=no
3820    fi
3821    if test "$with_system_libcmis" = "yes"; then
3822        AC_MSG_ERROR([--with-system-libcmis conflicts with --enable-dbgutil])
3823    else
3824        with_system_libcmis=no
3825    fi
3826    if test "$with_system_hunspell" = "yes"; then
3827        AC_MSG_ERROR([--with-system-hunspell conflicts with --enable-dbgutil])
3828    else
3829        with_system_hunspell=no
3830    fi
3831    if test "$with_system_gpgmepp" = "yes"; then
3832        AC_MSG_ERROR([--with-system-gpgmepp conflicts with --enable-dbgutil])
3833    else
3834        with_system_gpgmepp=no
3835    fi
3836    # As mixing system libwps and non-system libnumbertext or vice versa likely causes trouble (see
3837    # 603074c5f2b84de8a24593faf807da784b040625 "Pass _GLIBCXX_DEBUG into external/libwps" and the
3838    # mail thread starting at <https://gcc.gnu.org/ml/gcc/2018-05/msg00057.html> "libstdc++: ODR
3839    # violation when using std::regex with and without -D_GLIBCXX_DEBUG"), simply make sure neither
3840    # of those two is using the system variant:
3841    if test "$with_system_libnumbertext" = "yes"; then
3842        AC_MSG_ERROR([--with-system-libnumbertext conflicts with --enable-dbgutil])
3843    else
3844        with_system_libnumbertext=no
3845    fi
3846    if test "$with_system_libwps" = "yes"; then
3847        AC_MSG_ERROR([--with-system-libwps conflicts with --enable-dbgutil])
3848    else
3849        with_system_libwps=no
3850    fi
3851else
3852    ENABLE_DBGUTIL=""
3853    MSVC_USE_DEBUG_RUNTIME=""
3854    AC_MSG_RESULT([no])
3855fi
3856AC_SUBST(ENABLE_DBGUTIL)
3857AC_SUBST(MSVC_USE_DEBUG_RUNTIME)
3858
3859dnl Set the ENABLE_DEBUG variable.
3860dnl ===================================================================
3861if test -n "$enable_debug" && test "$enable_debug" != "yes" && test "$enable_debug" != "no"; then
3862    AC_MSG_ERROR([--enable-debug now accepts only yes or no, use --enable-symbols])
3863fi
3864if test -n "$ENABLE_DBGUTIL" -a "$enable_debug" = "no"; then
3865    if test -z "$libo_fuzzed_enable_debug"; then
3866        AC_MSG_ERROR([--disable-debug cannot be used with --enable-dbgutil])
3867    else
3868        AC_MSG_NOTICE([Resetting --enable-debug=yes])
3869        enable_debug=yes
3870    fi
3871fi
3872
3873AC_MSG_CHECKING([whether to do a debug build])
3874if test -n "$ENABLE_DBGUTIL" -o \( -n "$enable_debug" -a "$enable_debug" != "no" \) ; then
3875    ENABLE_DEBUG="TRUE"
3876    if test -n "$ENABLE_DBGUTIL" ; then
3877        AC_MSG_RESULT([yes (dbgutil)])
3878    else
3879        AC_MSG_RESULT([yes])
3880    fi
3881else
3882    ENABLE_DEBUG=""
3883    AC_MSG_RESULT([no])
3884fi
3885AC_SUBST(ENABLE_DEBUG)
3886
3887AC_MSG_CHECKING([whether special RTTI visibility flags are needed for Clang Linux UBSan])
3888NEED_CLANG_LINUX_UBSAN_RTTI_VISIBILITY=
3889dnl Clang 9 is known fixed since
3890dnl <https://github.com/llvm/llvm-project/commit/5745eccef54ddd3caca278d1d292a88b2281528b> "Adapt
3891dnl -fsanitize=function to SANITIZER_NON_UNIQUE_TYPEINFO":
3892if test "$COM_IS_CLANG" = TRUE && test "$CLANGVER" -lt 90000 && test "$_os" = Linux; then
3893    for i in $CC; do
3894        case $i in
3895        -fsanitize=*)
3896            NEED_CLANG_LINUX_UBSAN_RTTI_VISIBILITY=TRUE
3897            break
3898            ;;
3899        esac
3900    done
3901fi
3902if test "$NEED_CLANG_LINUX_UBSAN_RTTI_VISIBILITY" = TRUE; then
3903    AC_MSG_RESULT([yes])
3904else
3905    AC_MSG_RESULT([no])
3906fi
3907AC_SUBST([NEED_CLANG_LINUX_UBSAN_RTTI_VISIBILITY])
3908
3909dnl ===================================================================
3910dnl Select the linker to use (gold/lld/ld.bfd).
3911dnl This is done only after compiler checks (need to know if Clang is
3912dnl used, for different defaults) and after checking if a debug build
3913dnl is wanted (non-debug builds get the default linker if not explicitly
3914dnl specified otherwise).
3915dnl All checks for linker features/options should come after this.
3916dnl ===================================================================
3917check_use_ld()
3918{
3919    use_ld=$1
3920    use_ld_fail_if_error=$2
3921    use_ld_ok=
3922    AC_MSG_CHECKING([for -fuse-ld=$use_ld linker support])
3923    use_ld_ldflags_save="$LDFLAGS"
3924    LDFLAGS="$LDFLAGS -fuse-ld=$use_ld"
3925    AC_LINK_IFELSE([AC_LANG_PROGRAM([
3926#include <stdio.h>
3927        ],[
3928printf ("hello world\n");
3929        ])], USE_LD=$use_ld, [])
3930    if test -n "$USE_LD"; then
3931        AC_MSG_RESULT( yes )
3932        use_ld_ok=yes
3933        dnl For obscure reasons, unxgcc.mk uses the --dynamic-list-cpp-typeinfo linker option
3934        dnl if NEED_CLANG_LINUX_UBSAN_RTTI_VISIBILITY, and lld doesn't support this option.
3935        if test -n "$NEED_CLANG_LINUX_UBSAN_RTTI_VISIBILITY"; then
3936            AC_MSG_CHECKING([for --dynamic-list-cpp-typeinfo linker support (-fuse-ld=$use_ld)])
3937            use_ld_ldflags_save_2="$LDFLAGS"
3938            LDFLAGS="$LDFLAGS -Wl,--dynamic-list-cpp-typeinfo"
3939            use_ld_has_cpp_typeinfo=
3940            AC_LINK_IFELSE([AC_LANG_PROGRAM([
3941#include <stdio.h>
3942                ],[
3943printf ("hello world\n");
3944                ])], use_ld_has_cpp_typeinfo=yes, [])
3945            LDFLAGS="$use_ld_ldflags_save_2"
3946            if test -n "$use_ld_has_cpp_typeinfo"; then
3947                AC_MSG_RESULT( yes )
3948            else
3949                if test -n "$use_ld_fail_if_error"; then
3950                    AC_MSG_ERROR( no )
3951                else
3952                    AC_MSG_RESULT( no )
3953                fi
3954                use_ld_ok=
3955            fi
3956        fi
3957    else
3958        if test -n "$use_ld_fail_if_error"; then
3959            AC_MSG_ERROR( no )
3960        else
3961            AC_MSG_RESULT( no )
3962        fi
3963    fi
3964    if test -n "$use_ld_ok"; then
3965        dnl keep the value of LDFLAGS
3966        return 0
3967    fi
3968    LDFLAGS="$use_ld_ldflags_save"
3969    return 1
3970}
3971USE_LD=
3972if test "$enable_ld" != "no"; then
3973    if test "$GCC" = "yes"; then
3974        if test -n "$enable_ld"; then
3975            check_use_ld "$enable_ld" fail_if_error
3976        elif test -z "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
3977            dnl non-debug builds default to the default linker
3978            true
3979        elif test -n "$COM_IS_CLANG"; then
3980            check_use_ld lld
3981            if test $? -ne 0; then
3982                check_use_ld gold
3983            fi
3984        else
3985            # For gcc first try gold, new versions also support lld.
3986            check_use_ld gold
3987            if test $? -ne 0; then
3988                check_use_ld lld
3989            fi
3990        fi
3991        ld_output=$(echo 'int main() { return 0; }' | $CC -Wl,-v -x c -o conftest.out - $CFLAGS $LDFLAGS 2>/dev/null)
3992        rm conftest.out
3993        ld_used=$(echo "$ld_output" | grep -E '(^GNU gold|^GNU ld|^LLD)')
3994        if test -z "$ld_used"; then
3995            ld_used="unknown"
3996        fi
3997        AC_MSG_CHECKING([for linker that is used])
3998        AC_MSG_RESULT([$ld_used])
3999        if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
4000            if echo "$ld_used" | grep -q "^GNU ld"; then
4001                AC_MSG_WARN([The default GNU linker is slow, consider using the LLD or the GNU gold linker.])
4002                add_warning "The default GNU linker is slow, consider using the LLD or the GNU gold linker."
4003            fi
4004        fi
4005    else
4006        if test "$enable_ld" = "yes"; then
4007            AC_MSG_ERROR([--enable-ld not supported])
4008        fi
4009    fi
4010fi
4011AC_SUBST(USE_LD)
4012
4013HAVE_LD_BSYMBOLIC_FUNCTIONS=
4014if test "$GCC" = "yes"; then
4015    AC_MSG_CHECKING([for -Bsymbolic-functions linker support])
4016    bsymbolic_functions_ldflags_save=$LDFLAGS
4017    LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
4018    AC_LINK_IFELSE([AC_LANG_PROGRAM([
4019#include <stdio.h>
4020        ],[
4021printf ("hello world\n");
4022        ])], HAVE_LD_BSYMBOLIC_FUNCTIONS=TRUE, [])
4023    if test "$HAVE_LD_BSYMBOLIC_FUNCTIONS" = "TRUE"; then
4024        AC_MSG_RESULT( found )
4025    else
4026        AC_MSG_RESULT( not found )
4027    fi
4028    LDFLAGS=$bsymbolic_functions_ldflags_save
4029fi
4030AC_SUBST(HAVE_LD_BSYMBOLIC_FUNCTIONS)
4031
4032
4033HAVE_GSPLIT_DWARF=
4034if test "$enable_split_debug" != no; then
4035    dnl Currently by default enabled only on Linux, feel free to set test_split_debug above also for other platforms.
4036    if test "$enable_split_debug" = yes -o \( "$test_split_debug" = "yes" -a -n "$ENABLE_DEBUG$ENABLE_DBGUTIL" \); then
4037        AC_MSG_CHECKING([whether $CC supports -gsplit-dwarf])
4038        save_CFLAGS=$CFLAGS
4039        CFLAGS="$CFLAGS -Werror -gsplit-dwarf"
4040        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_SPLIT_DWARF=TRUE ],[])
4041        CFLAGS=$save_CFLAGS
4042        if test "$HAVE_GCC_SPLIT_DWARF" = "TRUE"; then
4043            AC_MSG_RESULT([yes])
4044        else
4045            if test "$enable_split_debug" = yes; then
4046                AC_MSG_ERROR([no])
4047            else
4048                AC_MSG_RESULT([no])
4049            fi
4050        fi
4051    fi
4052    if test -z "$HAVE_GCC_SPLIT_DWARF" -a "$test_split_debug" = "yes" -a -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
4053        AC_MSG_WARN([Compiler is not capable of creating split debug info, linking will require more time and disk space.])
4054        add_warning "Compiler is not capable of creating split debug info, linking will require more time and disk space."
4055    fi
4056fi
4057AC_SUBST(HAVE_GCC_SPLIT_DWARF)
4058
4059ENABLE_GDB_INDEX=
4060if test "$enable_gdb_index" != "no"; then
4061    dnl Currently by default enabled only on Linux, feel free to set test_gdb_index above also for other platforms.
4062    if test "$enable_gdb_index" = yes -o \( "$test_gdb_index" = "yes" -o -n "$ENABLE_DEBUG$ENABLE_DBGUTIL" \); then
4063        AC_MSG_CHECKING([whether $CC supports -ggnu-pubnames])
4064        save_CFLAGS=$CFLAGS
4065        CFLAGS="$CFLAGS -Werror -ggnu-pubnames"
4066        have_ggnu_pubnames=
4067        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[have_ggnu_pubnames=TRUE],[have_ggnu_pubnames=])
4068        if test "$have_ggnu_pubnames" != "TRUE"; then
4069            if test "$enable_gdb_index" = "yes"; then
4070                AC_MSG_ERROR( no, --enable-gdb-index not supported )
4071            else
4072                AC_MSG_RESULT( no )
4073            fi
4074        else
4075            AC_MSG_RESULT( yes )
4076            AC_MSG_CHECKING([whether $CC supports -Wl,--gdb-index])
4077            ldflags_save=$LDFLAGS
4078            LDFLAGS="$LDFLAGS -Wl,--gdb-index"
4079            AC_LINK_IFELSE([AC_LANG_PROGRAM([
4080#include <stdio.h>
4081                ],[
4082printf ("hello world\n");
4083                ])], ENABLE_GDB_INDEX=TRUE, [])
4084            if test "$ENABLE_GDB_INDEX" = "TRUE"; then
4085                AC_MSG_RESULT( yes )
4086            else
4087                if test "$enable_gdb_index" = "yes"; then
4088                    AC_MSG_ERROR( no )
4089                else
4090                    AC_MSG_RESULT( no )
4091                fi
4092            fi
4093            LDFLAGS=$ldflags_save
4094        fi
4095        CFLAGS=$save_CFLAGS
4096        fi
4097    if test -z "$ENABLE_GDB_INDEX" -a "$test_gdb_index" = "yes" -a -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
4098        AC_MSG_WARN([Linker is not capable of creating gdb index, debugger startup will be slow.])
4099        add_warning "Linker is not capable of creating gdb index, debugger startup will be slow."
4100    fi
4101fi
4102AC_SUBST(ENABLE_GDB_INDEX)
4103
4104if test "$enable_sal_log" = yes; then
4105    ENABLE_SAL_LOG=TRUE
4106fi
4107AC_SUBST(ENABLE_SAL_LOG)
4108
4109dnl Check for enable symbols option
4110dnl ===================================================================
4111AC_MSG_CHECKING([whether to generate debug information])
4112if test -z "$enable_symbols"; then
4113    if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
4114        enable_symbols=yes
4115    else
4116        enable_symbols=no
4117    fi
4118fi
4119if test "$enable_symbols" = yes; then
4120    ENABLE_SYMBOLS_FOR=all
4121    AC_MSG_RESULT([yes])
4122elif test "$enable_symbols" = no; then
4123    ENABLE_SYMBOLS_FOR=
4124    AC_MSG_RESULT([no])
4125else
4126    # Selective debuginfo.
4127    ENABLE_SYMBOLS_FOR="$enable_symbols"
4128    AC_MSG_RESULT([for "$enable_symbols"])
4129fi
4130AC_SUBST(ENABLE_SYMBOLS_FOR)
4131
4132if test -n "$with_android_ndk" -a \( -n "$ENABLE_SYMBOLS" -o -n "$ENABLE_DEBUG" -o -n "$ENABLE_DBGUTIL" \) -a "$ENABLE_DEBUGINFO_FOR" = "all"; then
4133    # Building on Android with full symbols: without enough memory the linker never finishes currently.
4134    AC_MSG_CHECKING([whether enough memory is available for linking])
4135    mem_size=$(grep -o 'MemTotal: *.\+ kB' /proc/meminfo | sed 's/MemTotal: *\(.\+\) kB/\1/')
4136    # Check for 15GB, as Linux reports a bit less than the physical memory size.
4137    if test -n "$mem_size" -a $mem_size -lt 15728640; then
4138        AC_MSG_ERROR([building with full symbols and less than 16GB of memory is not supported])
4139    else
4140        AC_MSG_RESULT([yes])
4141    fi
4142fi
4143
4144AC_MSG_CHECKING([whether to compile with optimization flags])
4145if test -z "$enable_optimized"; then
4146    if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
4147        enable_optimized=no
4148    else
4149        enable_optimized=yes
4150    fi
4151fi
4152if test "$enable_optimized" != no; then
4153    ENABLE_OPTIMIZED=TRUE
4154    AC_MSG_RESULT([yes])
4155else
4156    ENABLE_OPTIMIZED=
4157    AC_MSG_RESULT([no])
4158fi
4159AC_SUBST(ENABLE_OPTIMIZED)
4160
4161#
4162# determine CPUNAME, OS, ...
4163# The USING_X11 flag tells whether the host os uses X by default. Can be overridden with the --without-x option.
4164#
4165case "$host_os" in
4166
4167aix*)
4168    COM=GCC
4169    CPUNAME=POWERPC
4170    USING_X11=TRUE
4171    OS=AIX
4172    RTL_OS=AIX
4173    RTL_ARCH=PowerPC
4174    PLATFORMID=aix_powerpc
4175    P_SEP=:
4176    ;;
4177
4178cygwin*)
4179    COM=MSC
4180    USING_X11=
4181    OS=WNT
4182    RTL_OS=Windows
4183    if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
4184        P_SEP=";"
4185    else
4186        P_SEP=:
4187    fi
4188    case "$host_cpu" in
4189    i*86|x86_64)
4190        if test "$BITNESS_OVERRIDE" = 64; then
4191            CPUNAME=X86_64
4192            RTL_ARCH=X86_64
4193            PLATFORMID=windows_x86_64
4194            WINDOWS_X64=1
4195            SCPDEFS="$SCPDEFS -DWINDOWS_X64"
4196        else
4197            CPUNAME=INTEL
4198            RTL_ARCH=x86
4199            PLATFORMID=windows_x86
4200        fi
4201        ;;
4202    *)
4203        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4204        ;;
4205    esac
4206    SCPDEFS="$SCPDEFS -D_MSC_VER"
4207    ;;
4208
4209darwin*)
4210    COM=GCC
4211    USING_X11=
4212    OS=MACOSX
4213    RTL_OS=MacOSX
4214    P_SEP=:
4215
4216    case "$host_cpu" in
4217    arm)
4218        AC_MSG_ERROR([Can't build 32-bit code for iOS])
4219        ;;
4220    arm64)
4221        OS=iOS
4222        if test "$enable_ios_simulator" = "yes"; then
4223            AC_MSG_ERROR([iOS simulator is only available in OSX not iOS])
4224        else
4225            CPUNAME=ARM64
4226            RTL_ARCH=ARM_EABI
4227            PLATFORMID=ios_arm64
4228        fi
4229        ;;
4230    i*86)
4231        AC_MSG_ERROR([Can't build 64-bit code in 32-bit OS])
4232        ;;
4233    x86_64)
4234        if test "$enable_ios_simulator" = "yes"; then
4235            OS=iOS
4236        fi
4237        CPUNAME=X86_64
4238        RTL_ARCH=X86_64
4239        PLATFORMID=macosx_x86_64
4240        ;;
4241    *)
4242        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4243        ;;
4244    esac
4245    ;;
4246
4247dragonfly*)
4248    COM=GCC
4249    USING_X11=TRUE
4250    OS=DRAGONFLY
4251    RTL_OS=DragonFly
4252    P_SEP=:
4253
4254    case "$host_cpu" in
4255    i*86)
4256        CPUNAME=INTEL
4257        RTL_ARCH=x86
4258        PLATFORMID=dragonfly_x86
4259        ;;
4260    x86_64)
4261        CPUNAME=X86_64
4262        RTL_ARCH=X86_64
4263        PLATFORMID=dragonfly_x86_64
4264        ;;
4265    *)
4266        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4267        ;;
4268    esac
4269    ;;
4270
4271freebsd*)
4272    COM=GCC
4273    USING_X11=TRUE
4274    RTL_OS=FreeBSD
4275    OS=FREEBSD
4276    P_SEP=:
4277
4278    case "$host_cpu" in
4279    i*86)
4280        CPUNAME=INTEL
4281        RTL_ARCH=x86
4282        PLATFORMID=freebsd_x86
4283        ;;
4284    x86_64|amd64)
4285        CPUNAME=X86_64
4286        RTL_ARCH=X86_64
4287        PLATFORMID=freebsd_x86_64
4288        ;;
4289    *)
4290        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4291        ;;
4292    esac
4293    ;;
4294
4295haiku*)
4296    COM=GCC
4297    USING_X11=
4298    GUIBASE=haiku
4299    RTL_OS=Haiku
4300    OS=HAIKU
4301    P_SEP=:
4302
4303    case "$host_cpu" in
4304    i*86)
4305        CPUNAME=INTEL
4306        RTL_ARCH=x86
4307        PLATFORMID=haiku_x86
4308        ;;
4309    x86_64|amd64)
4310        CPUNAME=X86_64
4311        RTL_ARCH=X86_64
4312        PLATFORMID=haiku_x86_64
4313        ;;
4314    *)
4315        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4316        ;;
4317    esac
4318    ;;
4319
4320kfreebsd*)
4321    COM=GCC
4322    USING_X11=TRUE
4323    OS=LINUX
4324    RTL_OS=kFreeBSD
4325    P_SEP=:
4326
4327    case "$host_cpu" in
4328
4329    i*86)
4330        CPUNAME=INTEL
4331        RTL_ARCH=x86
4332        PLATFORMID=kfreebsd_x86
4333        ;;
4334    x86_64)
4335        CPUNAME=X86_64
4336        RTL_ARCH=X86_64
4337        PLATFORMID=kfreebsd_x86_64
4338        ;;
4339    *)
4340        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4341        ;;
4342    esac
4343    ;;
4344
4345linux-gnu*)
4346    COM=GCC
4347    USING_X11=TRUE
4348    OS=LINUX
4349    RTL_OS=Linux
4350    P_SEP=:
4351
4352    case "$host_cpu" in
4353
4354    aarch64)
4355        CPUNAME=AARCH64
4356        PLATFORMID=linux_aarch64
4357        RTL_ARCH=AARCH64
4358        ;;
4359    alpha)
4360        CPUNAME=AXP
4361        RTL_ARCH=ALPHA
4362        PLATFORMID=linux_alpha
4363        ;;
4364    arm*)
4365        CPUNAME=ARM
4366        EPM_FLAGS="-a arm"
4367        RTL_ARCH=ARM_EABI
4368        PLATFORMID=linux_arm_eabi
4369        case "$host_cpu" in
4370        arm*-linux)
4371            RTL_ARCH=ARM_OABI
4372            PLATFORMID=linux_arm_oabi
4373            ;;
4374        esac
4375        ;;
4376    hppa)
4377        CPUNAME=HPPA
4378        RTL_ARCH=HPPA
4379        EPM_FLAGS="-a hppa"
4380        PLATFORMID=linux_hppa
4381        ;;
4382    i*86)
4383        CPUNAME=INTEL
4384        RTL_ARCH=x86
4385        PLATFORMID=linux_x86
4386        ;;
4387    ia64)
4388        CPUNAME=IA64
4389        RTL_ARCH=IA64
4390        PLATFORMID=linux_ia64
4391        ;;
4392    mips)
4393        CPUNAME=GODSON
4394        RTL_ARCH=MIPS_EB
4395        EPM_FLAGS="-a mips"
4396        PLATFORMID=linux_mips_eb
4397        ;;
4398    mips64)
4399        CPUNAME=GODSON64
4400        RTL_ARCH=MIPS64_EB
4401        EPM_FLAGS="-a mips64"
4402        PLATFORMID=linux_mips64_eb
4403        ;;
4404    mips64el)
4405        CPUNAME=GODSON64
4406        RTL_ARCH=MIPS64_EL
4407        EPM_FLAGS="-a mips64el"
4408        PLATFORMID=linux_mips64_el
4409        ;;
4410    mipsel)
4411        CPUNAME=GODSON
4412        RTL_ARCH=MIPS_EL
4413        EPM_FLAGS="-a mipsel"
4414        PLATFORMID=linux_mips_el
4415        ;;
4416    m68k)
4417        CPUNAME=M68K
4418        RTL_ARCH=M68K
4419        PLATFORMID=linux_m68k
4420        ;;
4421    powerpc)
4422        CPUNAME=POWERPC
4423        RTL_ARCH=PowerPC
4424        PLATFORMID=linux_powerpc
4425        ;;
4426    powerpc64)
4427        CPUNAME=POWERPC64
4428        RTL_ARCH=PowerPC_64
4429        PLATFORMID=linux_powerpc64
4430        ;;
4431    powerpc64le)
4432        CPUNAME=POWERPC64
4433        RTL_ARCH=PowerPC_64_LE
4434        PLATFORMID=linux_powerpc64_le
4435        ;;
4436    sparc)
4437        CPUNAME=SPARC
4438        RTL_ARCH=SPARC
4439        PLATFORMID=linux_sparc
4440        ;;
4441    sparc64)
4442        CPUNAME=SPARC64
4443        RTL_ARCH=SPARC64
4444        PLATFORMID=linux_sparc64
4445        ;;
4446    s390)
4447        CPUNAME=S390
4448        RTL_ARCH=S390
4449        PLATFORMID=linux_s390
4450        ;;
4451    s390x)
4452        CPUNAME=S390X
4453        RTL_ARCH=S390x
4454        PLATFORMID=linux_s390x
4455        ;;
4456    x86_64)
4457        CPUNAME=X86_64
4458        RTL_ARCH=X86_64
4459        PLATFORMID=linux_x86_64
4460        ;;
4461    *)
4462        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4463        ;;
4464    esac
4465    ;;
4466
4467linux-android*)
4468    COM=GCC
4469    USING_X11=
4470    OS=ANDROID
4471    RTL_OS=Android
4472    P_SEP=:
4473
4474    case "$host_cpu" in
4475
4476    arm|armel)
4477        CPUNAME=ARM
4478        RTL_ARCH=ARM_EABI
4479        PLATFORMID=android_arm_eabi
4480        ;;
4481    aarch64)
4482        CPUNAME=AARCH64
4483        RTL_ARCH=AARCH64
4484        PLATFORMID=android_aarch64
4485        ;;
4486    mips|mipsel)
4487        CPUNAME=GODSON # Weird, but maybe that's the LO convention?
4488        RTL_ARCH=MIPS_EL
4489        PLATFORMID=android_mips_el
4490        ;;
4491    i*86)
4492        CPUNAME=INTEL
4493        RTL_ARCH=x86
4494        PLATFORMID=android_x86
4495        ;;
4496    *)
4497        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4498        ;;
4499    esac
4500    ;;
4501
4502*netbsd*)
4503    COM=GCC
4504    USING_X11=TRUE
4505    OS=NETBSD
4506    RTL_OS=NetBSD
4507    P_SEP=:
4508
4509    case "$host_cpu" in
4510    i*86)
4511        CPUNAME=INTEL
4512        RTL_ARCH=x86
4513        PLATFORMID=netbsd_x86
4514        ;;
4515    powerpc)
4516        CPUNAME=POWERPC
4517        RTL_ARCH=PowerPC
4518        PLATFORMID=netbsd_powerpc
4519        ;;
4520    sparc)
4521        CPUNAME=SPARC
4522        RTL_ARCH=SPARC
4523        PLATFORMID=netbsd_sparc
4524        ;;
4525    x86_64)
4526        CPUNAME=X86_64
4527        RTL_ARCH=X86_64
4528        PLATFORMID=netbsd_x86_64
4529        ;;
4530    *)
4531        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4532        ;;
4533    esac
4534    ;;
4535
4536openbsd*)
4537    COM=GCC
4538    USING_X11=TRUE
4539    OS=OPENBSD
4540    RTL_OS=OpenBSD
4541    P_SEP=:
4542
4543    case "$host_cpu" in
4544    i*86)
4545        CPUNAME=INTEL
4546        RTL_ARCH=x86
4547        PLATFORMID=openbsd_x86
4548        ;;
4549    x86_64)
4550        CPUNAME=X86_64
4551        RTL_ARCH=X86_64
4552        PLATFORMID=openbsd_x86_64
4553        ;;
4554    *)
4555        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4556        ;;
4557    esac
4558    SOLARINC="$SOLARINC -I/usr/local/include"
4559    ;;
4560
4561solaris*)
4562    COM=GCC
4563    USING_X11=TRUE
4564    OS=SOLARIS
4565    RTL_OS=Solaris
4566    P_SEP=:
4567
4568    case "$host_cpu" in
4569    i*86)
4570        CPUNAME=INTEL
4571        RTL_ARCH=x86
4572        PLATFORMID=solaris_x86
4573        ;;
4574    sparc)
4575        CPUNAME=SPARC
4576        RTL_ARCH=SPARC
4577        PLATFORMID=solaris_sparc
4578        ;;
4579    sparc64)
4580        CPUNAME=SPARC64
4581        RTL_ARCH=SPARC64
4582        PLATFORMID=solaris_sparc64
4583        ;;
4584    *)
4585        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4586        ;;
4587    esac
4588    SOLARINC="$SOLARINC -I/usr/local/include"
4589    ;;
4590
4591*)
4592    AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice for!])
4593    ;;
4594esac
4595
4596if test "$with_x" = "no"; then
4597    AC_MSG_ERROR([Use --disable-gui instead. How can we get rid of this option? No idea where it comes from.])
4598fi
4599
4600DISABLE_GUI=""
4601if test "$enable_gui" = "no"; then
4602    if test "$USING_X11" != TRUE; then
4603        AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice with --disable-gui.])
4604    fi
4605    USING_X11=
4606    DISABLE_GUI=TRUE
4607    AC_DEFINE(HAVE_FEATURE_UI,0)
4608    test_cairo=yes
4609fi
4610AC_SUBST(DISABLE_GUI)
4611
4612WORKDIR="${BUILDDIR}/workdir"
4613INSTDIR="${BUILDDIR}/instdir"
4614INSTROOTBASE=${INSTDIR}${INSTROOTBASESUFFIX}
4615INSTROOT=${INSTROOTBASE}${INSTROOTCONTENTSUFFIX}
4616SOLARINC="-I$SRC_ROOT/include $SOLARINC"
4617AC_SUBST(COM)
4618AC_SUBST(CPUNAME)
4619AC_SUBST(RTL_OS)
4620AC_SUBST(RTL_ARCH)
4621AC_SUBST(EPM_FLAGS)
4622AC_SUBST(USING_X11)
4623AC_SUBST([INSTDIR])
4624AC_SUBST([INSTROOT])
4625AC_SUBST([INSTROOTBASE])
4626AC_SUBST(OS)
4627AC_SUBST(P_SEP)
4628AC_SUBST(WORKDIR)
4629AC_SUBST(PLATFORMID)
4630AC_SUBST(WINDOWS_X64)
4631AC_DEFINE_UNQUOTED(WORKDIR,"$WORKDIR")
4632
4633dnl ===================================================================
4634dnl Test which package format to use
4635dnl ===================================================================
4636AC_MSG_CHECKING([which package format to use])
4637if test -n "$with_package_format" -a "$with_package_format" != no; then
4638    for i in $with_package_format; do
4639        case "$i" in
4640        aix | bsd | deb | pkg | rpm | archive | dmg | installed | msi)
4641            ;;
4642        *)
4643            AC_MSG_ERROR([unsupported format $i. Supported by EPM are:
4644aix - AIX software distribution
4645bsd - FreeBSD, NetBSD, or OpenBSD software distribution
4646deb - Debian software distribution
4647pkg - Solaris software distribution
4648rpm - RedHat software distribution
4649
4650LibreOffice additionally supports:
4651archive - .tar.gz or .zip
4652dmg - macOS .dmg
4653installed - installation tree
4654msi - Windows .msi
4655        ])
4656            ;;
4657        esac
4658    done
4659    # fakeroot is needed to ensure correct file ownerships/permissions
4660    # inside deb packages and tar archives created on Linux and Solaris.
4661    if test "$OS" = "LINUX" || test "$OS" = "SOLARIS"; then
4662        AC_PATH_PROG(FAKEROOT, fakeroot, no)
4663        if test "$FAKEROOT" = "no"; then
4664            AC_MSG_ERROR(
4665                [--with-package-format='$with_package_format' requires fakeroot. Install fakeroot.])
4666        fi
4667    fi
4668    PKGFORMAT="$with_package_format"
4669    AC_MSG_RESULT([$PKGFORMAT])
4670else
4671    PKGFORMAT=
4672    AC_MSG_RESULT([none])
4673fi
4674AC_SUBST(PKGFORMAT)
4675
4676dnl ===================================================================
4677dnl Set up a different compiler to produce tools to run on the build
4678dnl machine when doing cross-compilation
4679dnl ===================================================================
4680
4681m4_pattern_allow([PKG_CONFIG_FOR_BUILD])
4682m4_pattern_allow([PKG_CONFIG_LIBDIR])
4683if test "$cross_compiling" = "yes"; then
4684    AC_MSG_CHECKING([for BUILD platform configuration])
4685    echo
4686    rm -rf CONF-FOR-BUILD config_build.mk
4687    mkdir CONF-FOR-BUILD
4688    # Here must be listed all files needed when running the configure script. In particular, also
4689    # those expanded by the AC_CONFIG_FILES() call near the end of this configure.ac. For clarity,
4690    # keep them in the same order as there.
4691    (cd $SRC_ROOT && tar cf - \
4692        config.guess \
4693        bin/get_config_variables \
4694        solenv/bin/getcompver.awk \
4695        solenv/inc/langlist.mk \
4696        download.lst \
4697        config_host.mk.in \
4698        config_host_lang.mk.in \
4699        Makefile.in \
4700        bin/bffvalidator.sh.in \
4701        bin/odfvalidator.sh.in \
4702        bin/officeotron.sh.in \
4703        instsetoo_native/util/openoffice.lst.in \
4704        config_host/*.in \
4705        sysui/desktop/macosx/Info.plist.in) \
4706    | (cd CONF-FOR-BUILD && tar xf -)
4707    cp configure CONF-FOR-BUILD
4708    test -d config_build && cp -p config_build/*.h CONF-FOR-BUILD/config_host 2>/dev/null
4709    (
4710    unset COM USING_X11 OS CPUNAME
4711    unset CC CXX SYSBASE CFLAGS
4712    unset AR NM OBJDUMP PKG_CONFIG RANLIB READELF STRIP
4713    unset CPPUNIT_CFLAGS CPPUNIT_LIBS
4714    unset LIBXML_CFLAGS LIBXML_LIBS LIBXSLT_CFLAGS LIBXSLT_LIBS XSLTPROC PKG_CONFIG_LIBDIR
4715    test -n "$CC_FOR_BUILD" && export CC="$CC_FOR_BUILD"
4716    test -n "$CXX_FOR_BUILD" && export CXX="$CXX_FOR_BUILD"
4717    test -n "$PKG_CONFIG_FOR_BUILD" && export PKG_CONFIG="$PKG_CONFIG_FOR_BUILD"
4718    cd CONF-FOR-BUILD
4719    sub_conf_opts=""
4720    test -n "$enable_ccache" && sub_conf_opts="$sub_conf_opts --enable-ccache=$enable_ccache"
4721    test -n "$with_ant_home" && sub_conf_opts="$sub_conf_opts --with-ant-home=$with_ant_home"
4722    test $with_junit = no && sub_conf_opts="$sub_conf_opts --without-junit"
4723    test -n "$TARFILE_LOCATION" && sub_conf_opts="$sub_conf_opts --with-external-tar=$TARFILE_LOCATION"
4724    test "$with_system_icu_for_build" = "yes" -o "$with_system_icu_for_build" = "force" && sub_conf_opts="$sub_conf_opts --with-system-icu"
4725    test "$build_for_ios" = "YES" && sub_conf_opts="$sub_conf_opts build_for_ios=YES"
4726    sub_conf_opts="$sub_conf_opts $with_build_platform_configure_options"
4727    # Don't bother having configure look for stuff not needed for the build platform anyway
4728    ./configure \
4729        --disable-cups \
4730        --disable-gstreamer-1-0 \
4731        --disable-gtk \
4732        --disable-gtk3 \
4733        --disable-pdfimport \
4734        --disable-postgresql-sdbc \
4735        --with-parallelism="$with_parallelism" \
4736        --without-doxygen \
4737        --without-java \
4738        $sub_conf_opts \
4739        --srcdir=$srcdir \
4740        2>&1 | sed -e 's/^/    /'
4741    test -f ./config_host.mk 2>/dev/null || exit
4742    cp config_host.mk ../config_build.mk
4743    cp config_host_lang.mk ../config_build_lang.mk
4744    mv config.log ../config.Build.log
4745    mkdir -p ../config_build
4746    mv config_host/*.h ../config_build
4747    . ./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
4748
4749    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
4750        VV='$'$V
4751        VV=`eval "echo $VV"`
4752        if test -n "$VV"; then
4753            line=${V}_FOR_BUILD='${'${V}_FOR_BUILD:-$VV'}'
4754            echo "$line" >>build-config
4755        fi
4756    done
4757
4758    for V in INSTDIR INSTROOT WORKDIR; do
4759        VV='$'$V
4760        VV=`eval "echo $VV"`
4761        VV=`echo $VV | sed -e "s,/CONF-FOR-BUILD/\([[a-z]]*\),/\1_for_build,g"`
4762        if test -n "$VV"; then
4763            line="${V}_FOR_BUILD='$VV'"
4764            echo "$line" >>build-config
4765        fi
4766    done
4767
4768    line=`echo "LO_PATH_FOR_BUILD=$PATH" | sed -e 's,/CONF-FOR-BUILD,,g'`
4769    echo "$line" >>build-config
4770
4771    )
4772    test -f CONF-FOR-BUILD/build-config || AC_MSG_ERROR([Running configure script for BUILD system failed, see CONF-FOR-BUILD/config.log])
4773    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])
4774    perl -pi -e 's,/(workdir|instdir)(/|$),/\1_for_build\2,g;' \
4775             -e 's,/CONF-FOR-BUILD,,g;' config_build.mk
4776
4777    eval `cat CONF-FOR-BUILD/build-config`
4778
4779    AC_MSG_RESULT([checking for BUILD platform configuration... done])
4780
4781    rm -rf CONF-FOR-BUILD
4782else
4783    OS_FOR_BUILD="$OS"
4784    CC_FOR_BUILD="$CC"
4785    CXX_FOR_BUILD="$CXX"
4786    INSTDIR_FOR_BUILD="$INSTDIR"
4787    INSTROOT_FOR_BUILD="$INSTROOT"
4788    LIBO_BIN_FOLDER_FOR_BUILD="$LIBO_BIN_FOLDER"
4789    LIBO_LIB_FOLDER_FOR_BUILD="$LIBO_LIB_FOLDER"
4790    LIBO_URE_LIB_FOLDER_FOR_BUILD="$LIBO_URE_LIB_FOLDER"
4791    LIBO_URE_MISC_FOLDER_FOR_BUILD="$LIBO_URE_MISC_FOLDER"
4792    SDKDIRNAME_FOR_BUILD="$SDKDIRNAME"
4793    WORKDIR_FOR_BUILD="$WORKDIR"
4794fi
4795AC_SUBST(OS_FOR_BUILD)
4796AC_SUBST(INSTDIR_FOR_BUILD)
4797AC_SUBST(INSTROOT_FOR_BUILD)
4798AC_SUBST(LIBO_BIN_FOLDER_FOR_BUILD)
4799AC_SUBST(LIBO_LIB_FOLDER_FOR_BUILD)
4800AC_SUBST(LIBO_URE_LIB_FOLDER_FOR_BUILD)
4801AC_SUBST(LIBO_URE_MISC_FOLDER_FOR_BUILD)
4802AC_SUBST(SDKDIRNAME_FOR_BUILD)
4803AC_SUBST(WORKDIR_FOR_BUILD)
4804
4805dnl ===================================================================
4806dnl Check for syslog header
4807dnl ===================================================================
4808AC_CHECK_HEADER(syslog.h, AC_DEFINE(HAVE_SYSLOG_H))
4809
4810dnl Set the ENABLE_WERROR variable. (Activate --enable-werror)
4811dnl ===================================================================
4812AC_MSG_CHECKING([whether to turn warnings to errors])
4813if test -n "$enable_werror" -a "$enable_werror" != "no"; then
4814    ENABLE_WERROR="TRUE"
4815    AC_MSG_RESULT([yes])
4816else
4817    if test -n "$LODE_HOME" -a -z "$enable_werror"; then
4818        ENABLE_WERROR="TRUE"
4819        AC_MSG_RESULT([yes])
4820    else
4821        AC_MSG_RESULT([no])
4822    fi
4823fi
4824AC_SUBST(ENABLE_WERROR)
4825
4826dnl Check for --enable-assert-always-abort, set ASSERT_ALWAYS_ABORT
4827dnl ===================================================================
4828AC_MSG_CHECKING([whether to have assert() failures abort even without --enable-debug])
4829if test -z "$enable_assert_always_abort"; then
4830   if test "$ENABLE_DEBUG" = TRUE; then
4831       enable_assert_always_abort=yes
4832   else
4833       enable_assert_always_abort=no
4834   fi
4835fi
4836if test "$enable_assert_always_abort" = "yes"; then
4837    ASSERT_ALWAYS_ABORT="TRUE"
4838    AC_MSG_RESULT([yes])
4839else
4840    ASSERT_ALWAYS_ABORT="FALSE"
4841    AC_MSG_RESULT([no])
4842fi
4843AC_SUBST(ASSERT_ALWAYS_ABORT)
4844
4845# Determine whether to use ooenv for the instdir installation
4846# ===================================================================
4847if test $_os != "WINNT" -a $_os != "Darwin"; then
4848    AC_MSG_CHECKING([whether to use ooenv for the instdir installation])
4849    if test "$enable_ooenv" = "no"; then
4850        AC_MSG_RESULT([no])
4851    else
4852        ENABLE_OOENV="TRUE"
4853        AC_MSG_RESULT([yes])
4854    fi
4855fi
4856AC_SUBST(ENABLE_OOENV)
4857
4858if test "$USING_X11" != TRUE; then
4859    # be sure to do not mess with unneeded stuff
4860    test_randr=no
4861    test_xrender=no
4862    test_cups=no
4863    test_dbus=no
4864    test_gtk=no
4865    build_gstreamer_1_0=no
4866    test_kde5=no
4867    test_qt5=no
4868    test_gtk3_kde5=no
4869    enable_cairo_canvas=no
4870fi
4871
4872if test "$OS" = "HAIKU"; then
4873    enable_cairo_canvas=yes
4874    test_kde5=yes
4875fi
4876
4877if test "$test_kde5" = "yes"; then
4878    test_qt5=yes
4879fi
4880
4881if test "$test_kde5" = "yes" -a  "$enable_kde5" = "yes"; then
4882    if test "$enable_qt5" = "no"; then
4883        AC_MSG_ERROR([KDE5 support depends on QT5, so it conflicts with --disable-qt5])
4884    else
4885        enable_qt5=yes
4886    fi
4887fi
4888
4889dnl ===================================================================
4890dnl check for cups support
4891dnl ===================================================================
4892ENABLE_CUPS=""
4893
4894if test "$enable_cups" = "no"; then
4895    test_cups=no
4896fi
4897
4898AC_MSG_CHECKING([whether to enable CUPS support])
4899if test "$test_cups" = "yes"; then
4900    ENABLE_CUPS="TRUE"
4901    AC_MSG_RESULT([yes])
4902
4903    AC_MSG_CHECKING([whether cups support is present])
4904    AC_CHECK_LIB([cups], [cupsPrintFiles], [:])
4905    AC_CHECK_HEADER(cups/cups.h, AC_DEFINE(HAVE_CUPS_H))
4906    if test "$ac_cv_lib_cups_cupsPrintFiles" != "yes" -o "$ac_cv_header_cups_cups_h" != "yes"; then
4907        AC_MSG_ERROR([Could not find CUPS. Install libcups2-dev or cups-devel.])
4908    fi
4909
4910else
4911    AC_MSG_RESULT([no])
4912fi
4913
4914AC_SUBST(ENABLE_CUPS)
4915
4916# fontconfig checks
4917if test "$test_fontconfig" = "yes"; then
4918    PKG_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.4.1])
4919    SYSTEM_FONTCONFIG=TRUE
4920    FilterLibs "${FONTCONFIG_LIBS}"
4921    FONTCONFIG_LIBS="${filteredlibs}"
4922fi
4923AC_SUBST(FONTCONFIG_CFLAGS)
4924AC_SUBST(FONTCONFIG_LIBS)
4925AC_SUBST([SYSTEM_FONTCONFIG])
4926
4927dnl whether to find & fetch external tarballs?
4928dnl ===================================================================
4929if test -z "$TARFILE_LOCATION" -a -n "$LODE_HOME" ; then
4930   if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
4931       TARFILE_LOCATION="`cygpath -m $LODE_HOME/ext_tar`"
4932   else
4933       TARFILE_LOCATION="$LODE_HOME/ext_tar"
4934   fi
4935fi
4936if test -z "$TARFILE_LOCATION"; then
4937    if test -d "$SRC_ROOT/src" ; then
4938        mv "$SRC_ROOT/src" "$SRC_ROOT/external/tarballs"
4939        ln -s "$SRC_ROOT/external/tarballs" "$SRC_ROOT/src"
4940    fi
4941    TARFILE_LOCATION="$SRC_ROOT/external/tarballs"
4942else
4943    AbsolutePath "$TARFILE_LOCATION"
4944    PathFormat "${absolute_path}"
4945    TARFILE_LOCATION="${formatted_path}"
4946fi
4947AC_SUBST(TARFILE_LOCATION)
4948
4949AC_MSG_CHECKING([whether we want to fetch tarballs])
4950if test "$enable_fetch_external" != "no"; then
4951    if test "$with_all_tarballs" = "yes"; then
4952        AC_MSG_RESULT([yes, all of them])
4953        DO_FETCH_TARBALLS="ALL"
4954    else
4955        AC_MSG_RESULT([yes, if we use them])
4956        DO_FETCH_TARBALLS="TRUE"
4957    fi
4958else
4959    AC_MSG_RESULT([no])
4960    DO_FETCH_TARBALLS=
4961fi
4962AC_SUBST(DO_FETCH_TARBALLS)
4963
4964AC_MSG_CHECKING([whether to build help])
4965if test -n "$with_help" -a "$with_help" != "no" -a $_os != iOS -a $_os != Android; then
4966    BUILD_TYPE="$BUILD_TYPE HELP"
4967    GIT_NEEDED_SUBMODULES="helpcontent2 $GIT_NEEDED_SUBMODULES"
4968    case "$with_help" in
4969    "html")
4970        ENABLE_HTMLHELP=TRUE
4971        SCPDEFS="$SCPDEFS -DWITH_HELP"
4972        AC_MSG_RESULT([HTML])
4973        ;;
4974    "online")
4975        ENABLE_HTMLHELP=TRUE
4976        HELP_ONLINE=TRUE
4977        AC_MSG_RESULT([HTML])
4978        ;;
4979    yes)
4980        SCPDEFS="$SCPDEFS -DWITH_HELP"
4981        AC_MSG_RESULT([yes])
4982        ;;
4983    *)
4984        AC_MSG_ERROR([Unknown --with-help=$with_help])
4985        ;;
4986    esac
4987else
4988    AC_MSG_RESULT([no])
4989fi
4990AC_SUBST([ENABLE_HTMLHELP])
4991AC_SUBST([HELP_ONLINE])
4992
4993dnl Test whether to include MySpell dictionaries
4994dnl ===================================================================
4995AC_MSG_CHECKING([whether to include MySpell dictionaries])
4996if test "$with_myspell_dicts" = "yes"; then
4997    AC_MSG_RESULT([yes])
4998    WITH_MYSPELL_DICTS=TRUE
4999    BUILD_TYPE="$BUILD_TYPE DICTIONARIES"
5000    GIT_NEEDED_SUBMODULES="dictionaries $GIT_NEEDED_SUBMODULES"
5001else
5002    AC_MSG_RESULT([no])
5003    WITH_MYSPELL_DICTS=
5004fi
5005AC_SUBST(WITH_MYSPELL_DICTS)
5006
5007# There are no "system" myspell, hyphen or mythes dictionaries on macOS, Windows, Android or iOS.
5008if test $_os = Darwin -o $_os = WINNT -o $_os = iOS -o $_os = Android; then
5009    if test "$with_system_dicts" = yes; then
5010        AC_MSG_ERROR([There are no system dicts on this OS in the formats the 3rd-party libs we use expect]);
5011    fi
5012    with_system_dicts=no
5013fi
5014
5015AC_MSG_CHECKING([whether to use dicts from external paths])
5016if test -z "$with_system_dicts" -o "$with_system_dicts" != "no"; then
5017    AC_MSG_RESULT([yes])
5018    SYSTEM_DICTS=TRUE
5019    AC_MSG_CHECKING([for spelling dictionary directory])
5020    if test -n "$with_external_dict_dir"; then
5021        DICT_SYSTEM_DIR=file://$with_external_dict_dir
5022    else
5023        DICT_SYSTEM_DIR=file:///usr/share/hunspell
5024        if test ! -d /usr/share/hunspell -a -d /usr/share/myspell; then
5025            DICT_SYSTEM_DIR=file:///usr/share/myspell
5026        fi
5027    fi
5028    AC_MSG_RESULT([$DICT_SYSTEM_DIR])
5029    AC_MSG_CHECKING([for hyphenation patterns directory])
5030    if test -n "$with_external_hyph_dir"; then
5031        HYPH_SYSTEM_DIR=file://$with_external_hyph_dir
5032    else
5033        HYPH_SYSTEM_DIR=file:///usr/share/hyphen
5034    fi
5035    AC_MSG_RESULT([$HYPH_SYSTEM_DIR])
5036    AC_MSG_CHECKING([for thesaurus directory])
5037    if test -n "$with_external_thes_dir"; then
5038        THES_SYSTEM_DIR=file://$with_external_thes_dir
5039    else
5040        THES_SYSTEM_DIR=file:///usr/share/mythes
5041    fi
5042    AC_MSG_RESULT([$THES_SYSTEM_DIR])
5043else
5044    AC_MSG_RESULT([no])
5045    SYSTEM_DICTS=
5046fi
5047AC_SUBST(SYSTEM_DICTS)
5048AC_SUBST(DICT_SYSTEM_DIR)
5049AC_SUBST(HYPH_SYSTEM_DIR)
5050AC_SUBST(THES_SYSTEM_DIR)
5051
5052dnl ===================================================================
5053dnl Precompiled headers.
5054ENABLE_PCH=""
5055AC_MSG_CHECKING([whether to enable pch feature])
5056if test -z "$enable_pch"; then
5057    if test "$_os" = "WINNT"; then
5058        # Enabled by default on Windows.
5059        enable_pch=yes
5060    else
5061        enable_pch=no
5062    fi
5063fi
5064if test "$enable_pch" != "no" -a "$_os" != "WINNT" -a "$GCC" != "yes" ; then
5065    AC_MSG_ERROR([Precompiled header not yet supported for your platform/compiler])
5066fi
5067if test "$enable_pch" = "system"; then
5068    ENABLE_PCH="1"
5069    AC_MSG_RESULT([yes (system headers)])
5070elif test "$enable_pch" = "base"; then
5071    ENABLE_PCH="2"
5072    AC_MSG_RESULT([yes (system and base headers)])
5073elif test "$enable_pch" = "normal"; then
5074    ENABLE_PCH="3"
5075    AC_MSG_RESULT([yes (normal)])
5076elif test "$enable_pch" = "full"; then
5077    ENABLE_PCH="4"
5078    AC_MSG_RESULT([yes (full)])
5079elif test "$enable_pch" = "yes"; then
5080    # Pick a suitable default.
5081    if test "$GCC" = "yes"; then
5082        # With Clang and GCC higher levels do not seem to make a noticeable improvement,
5083        # while making the PCHs larger and rebuilds more likely.
5084        ENABLE_PCH="2"
5085        AC_MSG_RESULT([yes (system and base headers)])
5086    else
5087        # With MSVC the highest level makes a significant difference,
5088        # and it was the default when there used to be no PCH levels.
5089        ENABLE_PCH="4"
5090        AC_MSG_RESULT([yes (full)])
5091    fi
5092elif test "$enable_pch" = "no"; then
5093    AC_MSG_RESULT([no])
5094else
5095    AC_MSG_ERROR([Unknown value for --enable-pch])
5096fi
5097AC_SUBST(ENABLE_PCH)
5098# ccache 3.7.1 and older do not properly detect/handle -include .gch in CCACHE_DEPEND mode
5099if test -n "$ENABLE_PCH" -a -n "$CCACHE_DEPEND_MODE" -a "$GCC" = "yes" -a "$COM_IS_CLANG" != "TRUE"; then
5100    AC_PATH_PROG([CCACHE_BIN],[ccache],[not found])
5101    if test "$CCACHE_BIN" != "not found"; then
5102        AC_MSG_CHECKING([ccache version])
5103        CCACHE_VERSION=`"$CCACHE_BIN" -V | "$AWK" '/^ccache version/{print $3}'`
5104        CCACHE_NUMVER=`echo $CCACHE_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
5105        AC_MSG_RESULT([$CCACHE_VERSION])
5106        AC_MSG_CHECKING([whether ccache depend mode works properly with GCC PCH])
5107        if test "$CCACHE_NUMVER" -gt "030701"; then
5108            AC_MSG_RESULT([yes])
5109        else
5110            AC_MSG_RESULT([no (not newer than 3.7.1)])
5111            CCACHE_DEPEND_MODE=
5112        fi
5113    fi
5114fi
5115
5116TAB=`printf '\t'`
5117
5118AC_MSG_CHECKING([the GNU Make version])
5119_make_version=`$GNUMAKE --version | grep GNU | $GREP -v GPL | $SED -e 's@^[[^0-9]]*@@' -e 's@ .*@@' -e 's@,.*@@'`
5120_make_longver=`echo $_make_version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
5121if test "$_make_longver" -ge "038200"; then
5122    AC_MSG_RESULT([$GNUMAKE $_make_version])
5123
5124elif test "$_make_longver" -ge "038100"; then
5125    if test "$build_os" = "cygwin"; then
5126        AC_MSG_ERROR([failed ($GNUMAKE version >= 3.82 needed])
5127    fi
5128    AC_MSG_RESULT([$GNUMAKE $_make_version])
5129
5130    dnl ===================================================================
5131    dnl Search all the common names for sha1sum
5132    dnl ===================================================================
5133    AC_CHECK_PROGS(SHA1SUM, sha1sum sha1 shasum openssl)
5134    if test -z "$SHA1SUM"; then
5135        AC_MSG_ERROR([install the appropriate SHA-1 checksumming program for this OS])
5136    elif test "$SHA1SUM" = "openssl"; then
5137        SHA1SUM="openssl sha1"
5138    fi
5139    AC_MSG_CHECKING([for GNU Make bug 20033])
5140    TESTGMAKEBUG20033=`mktemp -d tmp.XXXXXX`
5141    $SED -e "s/<TAB>/$TAB/g" > $TESTGMAKEBUG20033/Makefile << EOF
5142A := \$(wildcard *.a)
5143
5144.PHONY: all
5145all: \$(A:.a=.b)
5146<TAB>@echo survived bug20033.
5147
5148.PHONY: setup
5149setup:
5150<TAB>@touch 1.a 2.a 3.a 4.a 5.a 6.a
5151
5152define d1
5153@echo lala \$(1)
5154@sleep 1
5155endef
5156
5157define d2
5158@echo tyty \$(1)
5159@sleep 1
5160endef
5161
5162%.b : %.a
5163<TAB>\$(eval CHECKSUM := \$(word 1,\$(shell cat \$^ | $SHA1SUM))) \$(if \$(wildcard \$(CACHEDIR)/\$(CHECKSUM)),\
5164<TAB>\$(call d1,\$(CHECKSUM)),\
5165<TAB>\$(call d2,\$(CHECKSUM)))
5166EOF
5167    if test -z "`(cd $TESTGMAKEBUG20033 && $GNUMAKE setup && $GNUMAKE -j)|grep survived`"; then
5168        no_parallelism_make="YES"
5169        AC_MSG_RESULT([yes, disable parallelism])
5170    else
5171        AC_MSG_RESULT([no, keep parallelism enabled])
5172    fi
5173    rm -rf $TESTGMAKEBUG20033
5174else
5175    AC_MSG_ERROR([failed ($GNUMAKE version >= 3.81 needed])
5176fi
5177
5178# find if gnumake support file function
5179AC_MSG_CHECKING([whether GNU Make supports the 'file' function])
5180TESTGMAKEFILEFUNC="`mktemp -d -t tst.XXXXXX`"
5181if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
5182    TESTGMAKEFILEFUNC=`cygpath -m $TESTGMAKEFILEFUNC`
5183fi
5184$SED -e "s/<TAB>/$TAB/" > $TESTGMAKEFILEFUNC/Makefile << EOF
5185\$(file >test.txt,Success )
5186
5187.PHONY: all
5188all:
5189<TAB>@cat test.txt
5190
5191EOF
5192$GNUMAKE -C $TESTGMAKEFILEFUNC 2>/dev/null 1>&2
5193if test -f $TESTGMAKEFILEFUNC/test.txt; then
5194    HAVE_GNUMAKE_FILE_FUNC=TRUE
5195    AC_MSG_RESULT([yes])
5196else
5197    AC_MSG_RESULT([no])
5198fi
5199rm -rf $TESTGMAKEFILEFUNC
5200AC_SUBST(HAVE_GNUMAKE_FILE_FUNC)
5201AC_SUBST(GNUMAKE_WIN_NATIVE)
5202
5203_make_ver_check=`$GNUMAKE --version | grep "Built for Windows"`
5204STALE_MAKE=
5205if test "$_make_ver_check" = ""; then
5206   STALE_MAKE=TRUE
5207fi
5208
5209HAVE_LD_HASH_STYLE=FALSE
5210WITH_LINKER_HASH_STYLE=
5211AC_MSG_CHECKING([for --hash-style gcc linker support])
5212if test "$GCC" = "yes"; then
5213    if test -z "$with_linker_hash_style" -o "$with_linker_hash_style" = "yes"; then
5214        hash_styles="gnu sysv"
5215    elif test "$with_linker_hash_style" = "no"; then
5216        hash_styles=
5217    else
5218        hash_styles="$with_linker_hash_style"
5219    fi
5220
5221    for hash_style in $hash_styles; do
5222        test "$HAVE_LD_HASH_STYLE" = "TRUE" && continue
5223        hash_style_ldflags_save=$LDFLAGS
5224        LDFLAGS="$LDFLAGS -Wl,--hash-style=$hash_style"
5225
5226        AC_RUN_IFELSE([AC_LANG_PROGRAM(
5227            [
5228#include <stdio.h>
5229            ],[
5230printf ("");
5231            ])],
5232            [
5233                  HAVE_LD_HASH_STYLE=TRUE
5234                  WITH_LINKER_HASH_STYLE=$hash_style
5235            ],
5236            [HAVE_LD_HASH_STYLE=FALSE],
5237            [HAVE_LD_HASH_STYLE=FALSE])
5238        LDFLAGS=$hash_style_ldflags_save
5239    done
5240
5241    if test "$HAVE_LD_HASH_STYLE" = "TRUE"; then
5242        AC_MSG_RESULT( $WITH_LINKER_HASH_STYLE )
5243    else
5244        AC_MSG_RESULT( no )
5245    fi
5246    LDFLAGS=$hash_style_ldflags_save
5247else
5248    AC_MSG_RESULT( no )
5249fi
5250AC_SUBST(HAVE_LD_HASH_STYLE)
5251AC_SUBST(WITH_LINKER_HASH_STYLE)
5252
5253dnl ===================================================================
5254dnl Check whether there's a Perl version available.
5255dnl ===================================================================
5256if test -z "$with_perl_home"; then
5257    AC_PATH_PROG(PERL, perl)
5258else
5259    test "$build_os" = "cygwin" && with_perl_home=`cygpath -u "$with_perl_home"`
5260    _perl_path="$with_perl_home/bin/perl"
5261    if test -x "$_perl_path"; then
5262        PERL=$_perl_path
5263    else
5264        AC_MSG_ERROR([$_perl_path not found])
5265    fi
5266fi
5267
5268dnl ===================================================================
5269dnl Testing for Perl version 5 or greater.
5270dnl $] is the Perl version variable, it is returned as an integer
5271dnl ===================================================================
5272if test "$PERL"; then
5273    AC_MSG_CHECKING([the Perl version])
5274    ${PERL} -e "exit($]);"
5275    _perl_version=$?
5276    if test "$_perl_version" -lt 5; then
5277        AC_MSG_ERROR([found Perl $_perl_version, use Perl 5])
5278    fi
5279    AC_MSG_RESULT([Perl $_perl_version])
5280else
5281    AC_MSG_ERROR([Perl not found, install Perl 5])
5282fi
5283
5284dnl ===================================================================
5285dnl Testing for required Perl modules
5286dnl ===================================================================
5287
5288AC_MSG_CHECKING([for required Perl modules])
5289perl_use_string="use Cwd ; use Digest::MD5"
5290if test "$_os" = "WINNT"; then
5291    if test -n "$PKGFORMAT"; then
5292        for i in $PKGFORMAT; do
5293            case "$i" in
5294            msi)
5295                # for getting fonts versions to use in MSI
5296                perl_use_string="$perl_use_string ; use Font::TTF::Font"
5297                ;;
5298            esac
5299        done
5300    fi
5301fi
5302if test "$with_system_hsqldb" = "yes"; then
5303	perl_use_string="$perl_use_string ; use Archive::Zip"
5304fi
5305if $PERL -e "$perl_use_string">/dev/null 2>&1; then
5306    AC_MSG_RESULT([all modules found])
5307else
5308    AC_MSG_RESULT([failed to find some modules])
5309    # Find out which modules are missing.
5310    for i in $perl_use_string; do
5311        if test "$i" != "use" -a "$i" != ";"; then
5312            if ! $PERL -e "use $i;">/dev/null 2>&1; then
5313                missing_perl_modules="$missing_perl_modules $i"
5314            fi
5315        fi
5316    done
5317    AC_MSG_ERROR([
5318    The missing Perl modules are: $missing_perl_modules
5319    Install them as superuser/administrator with "cpan -i $missing_perl_modules"])
5320fi
5321
5322dnl ===================================================================
5323dnl Check for pkg-config
5324dnl ===================================================================
5325if test "$_os" != "WINNT"; then
5326    PKG_PROG_PKG_CONFIG
5327fi
5328
5329if test "$_os" != "WINNT"; then
5330
5331    # If you use CC=/path/to/compiler/foo-gcc or even CC="ccache
5332    # /path/to/compiler/foo-gcc" you need to set the AR etc env vars
5333    # explicitly. Or put /path/to/compiler in PATH yourself.
5334
5335    # Use wrappers for LTO
5336    if test "$ENABLE_LTO" = "TRUE" -a "$COM_IS_CLANG" != "TRUE"; then
5337        AC_CHECK_TOOL(AR,gcc-ar)
5338        AC_CHECK_TOOL(NM,gcc-nm)
5339        AC_CHECK_TOOL(RANLIB,gcc-ranlib)
5340    else
5341        AC_CHECK_TOOL(AR,ar)
5342        AC_CHECK_TOOL(NM,nm)
5343        AC_CHECK_TOOL(RANLIB,ranlib)
5344    fi
5345    AC_CHECK_TOOL(OBJDUMP,objdump)
5346    AC_CHECK_TOOL(READELF,readelf)
5347    AC_CHECK_TOOL(STRIP,strip)
5348    if test "$_os" = "WINNT"; then
5349        AC_CHECK_TOOL(DLLTOOL,dlltool)
5350        AC_CHECK_TOOL(WINDRES,windres)
5351    fi
5352fi
5353AC_SUBST(AR)
5354AC_SUBST(DLLTOOL)
5355AC_SUBST(NM)
5356AC_SUBST(OBJDUMP)
5357AC_SUBST(PKG_CONFIG)
5358AC_SUBST(RANLIB)
5359AC_SUBST(READELF)
5360AC_SUBST(STRIP)
5361AC_SUBST(WINDRES)
5362
5363dnl ===================================================================
5364dnl pkg-config checks on macOS
5365dnl ===================================================================
5366
5367if test $_os = Darwin; then
5368    AC_MSG_CHECKING([for bogus pkg-config])
5369    if test -n "$PKG_CONFIG"; then
5370        if test "$PKG_CONFIG" = /usr/bin/pkg-config && ls -l /usr/bin/pkg-config | $GREP -q Mono.framework; then
5371            AC_MSG_ERROR([yes, from Mono. This *will* break the build. Please remove or hide $PKG_CONFIG])
5372        else
5373            if test "$enable_bogus_pkg_config" = "yes"; then
5374                AC_MSG_RESULT([yes, user-approved from unknown origin.])
5375            else
5376                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.])
5377            fi
5378        fi
5379    else
5380        AC_MSG_RESULT([no, good])
5381    fi
5382fi
5383
5384find_csc()
5385{
5386    # Return value: $csctest
5387
5388    unset csctest
5389
5390    reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/NET Framework Setup/NDP/v4/Client/InstallPath"
5391    if test -n "$regvalue"; then
5392        csctest=$regvalue
5393        return
5394    fi
5395}
5396
5397find_al()
5398{
5399    # Return value: $altest
5400
5401    unset altest
5402
5403    # We need this check to detect 4.6.1 or above.
5404    for ver in 4.8 4.7.2 4.7.1 4.7 4.6.2 4.6.1; do
5405        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/NETFXSDK/$ver/WinSDK-NetFx40Tools/InstallationFolder"
5406        if test -n "$regvalue" -a \( -f "$regvalue/al.exe" -o -f "$regvalue/bin/al.exe" \); then
5407            altest=$regvalue
5408            return
5409        fi
5410    done
5411
5412    for x in `ls /proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft\ SDKs/Windows`; do
5413        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/$x/WinSDK-NetFx40Tools/InstallationFolder"
5414        if test -n "$regvalue" -a \( -f "$regvalue/al.exe" -o -f "$regvalue/bin/al.exe" \); then
5415            altest=$regvalue
5416            return
5417        fi
5418    done
5419
5420
5421}
5422
5423find_dotnetsdk46()
5424{
5425    unset frametest
5426
5427    for ver in 4.8 4.7.2 4.7.1 4.7 4.6.2 4.6.1 4.6; do
5428        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/NETFXSDK/$ver/KitsInstallationFolder"
5429        if test -n "$regvalue"; then
5430            frametest=$regvalue
5431            return
5432        fi
5433    done
5434}
5435
5436find_winsdk_version()
5437{
5438    # Args: $1 : SDK version as in "6.0A", "7.0" etc
5439    # Return values: $winsdktest, $winsdkbinsubdir, $winsdklibsubdir
5440
5441    unset winsdktest winsdkbinsubdir winsdklibsubdir
5442
5443    case "$1" in
5444    7.*)
5445        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v${1}/InstallationFolder"
5446        if test -n "$regvalue"; then
5447            winsdktest=$regvalue
5448            winsdklibsubdir=.
5449            return
5450        fi
5451        ;;
5452    8.0|8.0A)
5453        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows Kits/Installed Roots/KitsRoot"
5454        if test -n "$regvalue"; then
5455            winsdktest=$regvalue
5456            winsdklibsubdir=win8
5457            return
5458        fi
5459        ;;
5460    8.1|8.1A)
5461        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows Kits/Installed Roots/KitsRoot81"
5462        if test -n "$regvalue"; then
5463            winsdktest=$regvalue
5464            winsdklibsubdir=winv6.3
5465            return
5466        fi
5467        ;;
5468    10.0)
5469        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v${1}/InstallationFolder"
5470        if test -n "$regvalue"; then
5471            winsdktest=$regvalue
5472            reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v${1}/ProductVersion"
5473            if test -n "$regvalue"; then
5474                winsdkbinsubdir="$regvalue".0
5475                winsdklibsubdir=$winsdkbinsubdir
5476                tmppath="$winsdktest\\Include\\$winsdklibsubdir"
5477                # test exist the SDK path
5478                if test -d "$tmppath"; then
5479                   # when path is convertible to a short path then path is okay
5480                   if ! cygpath -d "$tmppath"; then
5481                      AC_MSG_ERROR([Windows SDK doesn't have a 8.3 name, see NtfsDisable8dot3NameCreation])
5482                   fi
5483                else
5484                   AC_MSG_ERROR([The Windows SDK not found, check the installation])
5485                fi
5486            fi
5487            return
5488        fi
5489        ;;
5490    esac
5491}
5492
5493find_winsdk()
5494{
5495    # Return value: From find_winsdk_version
5496
5497    unset winsdktest
5498
5499    for ver in $WINDOWS_SDK_ACCEPTABLE_VERSIONS; do
5500        find_winsdk_version $ver
5501        if test -n "$winsdktest"; then
5502            return
5503        fi
5504    done
5505}
5506
5507find_msms()
5508{
5509    my_msm_files=Microsoft_VC${VCVER}_CRT_x86.msm
5510    case "$VCVER" in
5511        150|160)
5512        my_msm_files="Microsoft_VC141_CRT_x86.msm Microsoft_VC142_CRT_x86.msm ${my_msm_files}"
5513        ;;
5514    esac
5515    AC_MSG_CHECKING([for ${my_msm_files}])
5516    msmdir=
5517    for ver in 14.0 15.0; do
5518        reg_get_value_32 HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/VisualStudio/$ver/Setup/VS/MSMDir
5519        if test -n "$regvalue"; then
5520            for f in ${my_msm_files}; do
5521                if test -e "$regvalue/${f}"; then
5522                    msmdir=$regvalue
5523                    break
5524                fi
5525            done
5526        fi
5527    done
5528    dnl Is the following fallback really necessary, or was it added in response
5529    dnl to never having started Visual Studio on a given machine, so the
5530    dnl registry keys checked above had presumably not yet been created?
5531    dnl Anyway, if it really is necessary, it might be worthwhile to extend it
5532    dnl to also check %CommonProgramFiles(X86)% (typically expanding to
5533    dnl "C:\Program Files (X86)\Common Files" compared to %CommonProgramFiles%
5534    dnl expanding to "C:\Program Files\Common Files"), which would need
5535    dnl something like $(perl -e 'print $ENV{"CommonProgramFiles(x86)"}') to
5536    dnl obtain its value from cygwin:
5537    if test -z "$msmdir"; then
5538        my_msm_dir="${COMMONPROGRAMFILES}/Merge Modules/"
5539        for f in ${my_msm_files}; do
5540            if test -e "$my_msm_dir/${f}"; then
5541                msmdir=$my_msm_dir
5542            fi
5543        done
5544    fi
5545
5546    dnl Starting from MSVC 15.0, merge modules are located in different directory
5547    case "$VCVER" in
5548    150|160)
5549        for l in `ls -1 $VC_PRODUCT_DIR/redist/MSVC/`; do
5550            AC_MSG_CHECKING([for $VC_PRODUCT_DIR/redist/MSVC/$l/MergeModules])
5551            my_msm_dir="$VC_PRODUCT_DIR/redist/MSVC/$l/MergeModules/"
5552            for f in ${my_msm_files}; do
5553                if test -e "$my_msm_dir/${f}"; then
5554                    msmdir=$my_msm_dir
5555                    break
5556                fi
5557            done
5558        done
5559        ;;
5560    esac
5561
5562    if test -n "$msmdir"; then
5563        msmdir=`cygpath -m "$msmdir"`
5564        AC_MSG_RESULT([$msmdir])
5565    else
5566        if test "$ENABLE_RELEASE_BUILD" = "TRUE" ; then
5567            AC_MSG_ERROR([not found])
5568        else
5569            AC_MSG_WARN([not found])
5570            add_warning "MSM none of ${my_msm_files} found"
5571        fi
5572    fi
5573}
5574
5575find_msvc_x64_dlls()
5576{
5577    msvcdllpath="$VC_PRODUCT_DIR/redist/x64/Microsoft.VC${VCVER}.CRT"
5578    case "$VCVER" in
5579    150|160)
5580        for l in `ls -1 $VC_PRODUCT_DIR/redist/MSVC/`; do
5581            AC_MSG_CHECKING([for $VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC141.CRT])
5582            if test -d "$VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC141.CRT"; then
5583                msvcdllpath="$VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC141.CRT"
5584                break
5585            fi
5586            AC_MSG_CHECKING([for $VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC142.CRT])
5587            if test -d "$VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC142.CRT"; then
5588                msvcdllpath="$VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC142.CRT"
5589                break
5590            fi
5591            if test -d "$VC_PRODUCT_DIR/redist/MSVC/$l/onecore/x64/Microsoft.VC150.CRT"; then
5592                msvcdllpath="$VC_PRODUCT_DIR/redist/MSVC/$l/onecore/x64/Microsoft.VC150.CRT"
5593                break
5594            fi
5595        done
5596        ;;
5597    esac
5598    msvcdlls="msvcp140.dll vcruntime140.dll"
5599    for dll in $msvcdlls; do
5600        if ! test -f "$msvcdllpath/$dll"; then
5601            AC_MSG_ERROR([can not find $dll in $msvcdllpath])
5602        fi
5603    done
5604}
5605
5606dnl =========================================
5607dnl Check for the Windows  SDK.
5608dnl =========================================
5609if test "$_os" = "WINNT"; then
5610    AC_MSG_CHECKING([for Windows SDK])
5611    if test "$build_os" = "cygwin"; then
5612        find_winsdk
5613        WINDOWS_SDK_HOME=$winsdktest
5614
5615        # normalize if found
5616        if test -n "$WINDOWS_SDK_HOME"; then
5617            WINDOWS_SDK_HOME=`cygpath -d "$WINDOWS_SDK_HOME"`
5618            WINDOWS_SDK_HOME=`cygpath -u "$WINDOWS_SDK_HOME"`
5619        fi
5620
5621        WINDOWS_SDK_LIB_SUBDIR=$winsdklibsubdir
5622    fi
5623
5624    if test -n "$WINDOWS_SDK_HOME"; then
5625        # Remove a possible trailing backslash
5626        WINDOWS_SDK_HOME=`echo $WINDOWS_SDK_HOME | $SED 's/\/$//'`
5627
5628        if test -f "$WINDOWS_SDK_HOME/Include/adoint.h" \
5629             -a -f "$WINDOWS_SDK_HOME/Include/SqlUcode.h" \
5630             -a -f "$WINDOWS_SDK_HOME/Include/usp10.h"; then
5631            have_windows_sdk_headers=yes
5632        elif test -f "$WINDOWS_SDK_HOME/Include/um/adoint.h" \
5633             -a -f "$WINDOWS_SDK_HOME/Include/um/SqlUcode.h" \
5634             -a -f "$WINDOWS_SDK_HOME/Include/um/usp10.h"; then
5635            have_windows_sdk_headers=yes
5636        elif test -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/adoint.h" \
5637             -a -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/SqlUcode.h" \
5638             -a -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/usp10.h"; then
5639            have_windows_sdk_headers=yes
5640        else
5641            have_windows_sdk_headers=no
5642        fi
5643
5644        if test -f "$WINDOWS_SDK_HOME/lib/user32.lib"; then
5645            have_windows_sdk_libs=yes
5646        elif test -f "$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/$WINDOWS_SDK_ARCH/user32.lib"; then
5647            have_windows_sdk_libs=yes
5648        else
5649            have_windows_sdk_libs=no
5650        fi
5651
5652        if test $have_windows_sdk_headers = no -o $have_windows_sdk_libs = no; then
5653            AC_MSG_ERROR([Some (all?) Windows SDK files not found, please check if all needed parts of
5654the  Windows SDK are installed.])
5655        fi
5656    fi
5657
5658    if test -z "$WINDOWS_SDK_HOME"; then
5659        AC_MSG_RESULT([no, hoping the necessary headers and libraries will be found anyway!?])
5660    elif echo $WINDOWS_SDK_HOME | grep "v7.1" >/dev/null 2>/dev/null; then
5661        WINDOWS_SDK_VERSION=70
5662        AC_MSG_RESULT([found Windows SDK 7 ($WINDOWS_SDK_HOME)])
5663    elif echo $WINDOWS_SDK_HOME | grep "8.0" >/dev/null 2>/dev/null; then
5664        WINDOWS_SDK_VERSION=80
5665        AC_MSG_RESULT([found Windows SDK 8.0 ($WINDOWS_SDK_HOME)])
5666    elif echo $WINDOWS_SDK_HOME | grep "8.1" >/dev/null 2>/dev/null; then
5667        WINDOWS_SDK_VERSION=81
5668        AC_MSG_RESULT([found Windows SDK 8.1 ($WINDOWS_SDK_HOME)])
5669    elif echo $WINDOWS_SDK_HOME | grep "/10" >/dev/null 2>/dev/null; then
5670        WINDOWS_SDK_VERSION=10
5671        AC_MSG_RESULT([found Windows SDK 10.0 ($WINDOWS_SDK_HOME)])
5672    else
5673        AC_MSG_ERROR([Found legacy Windows Platform SDK ($WINDOWS_SDK_HOME)])
5674    fi
5675    PathFormat "$WINDOWS_SDK_HOME"
5676    WINDOWS_SDK_HOME="$formatted_path"
5677    if test "$build_os" = "cygwin"; then
5678        SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/include -I$COMPATH/Include"
5679        if test -d "$WINDOWS_SDK_HOME/include/um"; then
5680            SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/include/um -I$WINDOWS_SDK_HOME/include/shared"
5681        elif test -d "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um"; then
5682            SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um -I$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/shared"
5683        fi
5684    fi
5685
5686    dnl TODO: solenv/bin/modules/installer/windows/msiglobal.pm wants to use a
5687    dnl WiLangId.vbs that is included only in some SDKs (e.g., included in v7.1
5688    dnl but not in v8.0), so allow this to be overridden with a
5689    dnl WINDOWS_SDK_WILANGID for now; a full-blown --with-windows-sdk-wilangid
5690    dnl and configuration error if no WiLangId.vbs is found would arguably be
5691    dnl better, but I do not know under which conditions exactly it is needed by
5692    dnl msiglobal.pm:
5693    if test -z "$WINDOWS_SDK_WILANGID" -a -n "$WINDOWS_SDK_HOME"; then
5694        WINDOWS_SDK_WILANGID=$WINDOWS_SDK_HOME/Samples/sysmgmt/msi/scripts/WiLangId.vbs
5695        if ! test -e "$WINDOWS_SDK_WILANGID" ; then
5696            WINDOWS_SDK_WILANGID="${WINDOWS_SDK_HOME}/bin/${WINDOWS_SDK_LIB_SUBDIR}/${WINDOWS_SDK_ARCH}/WiLangId.vbs"
5697        fi
5698        if ! test -e "$WINDOWS_SDK_WILANGID" ; then
5699            WINDOWS_SDK_WILANGID=$WINDOWS_SDK_HOME/bin/$WINDOWS_SDK_ARCH/WiLangId.vbs
5700        fi
5701        if ! test -e "$WINDOWS_SDK_WILANGID" ; then
5702            WINDOWS_SDK_WILANGID=$(cygpath -sm "C:/Program Files (x86)/Windows Kits/8.1/bin/$WINDOWS_SDK_ARCH/WiLangId.vbs")
5703        fi
5704    fi
5705    if test -n "$with_lang" -a "$with_lang" != "en-US"; then
5706        if test -n "$with_package_format" -a "$with_package_format" != no; then
5707            for i in "$with_package_format"; do
5708                if test "$i" = "msi"; then
5709                    if ! test -e "$WINDOWS_SDK_WILANGID" ; then
5710                        AC_MSG_ERROR([WiLangId.vbs not found - building translated packages will fail])
5711                    fi
5712                fi
5713            done
5714        fi
5715    fi
5716fi
5717AC_SUBST(WINDOWS_SDK_HOME)
5718AC_SUBST(WINDOWS_SDK_LIB_SUBDIR)
5719AC_SUBST(WINDOWS_SDK_VERSION)
5720AC_SUBST(WINDOWS_SDK_WILANGID)
5721
5722if test "$build_os" = "cygwin"; then
5723    dnl Check midl.exe; this being the first check for a tool in the SDK bin
5724    dnl dir, it also determines that dir's path w/o an arch segment if any,
5725    dnl WINDOWS_SDK_BINDIR_NO_ARCH:
5726    AC_MSG_CHECKING([for midl.exe])
5727
5728    find_winsdk
5729    if test -n "$winsdkbinsubdir" \
5730        -a -f "$winsdktest/Bin/$winsdkbinsubdir/$WINDOWS_SDK_ARCH/midl.exe"
5731    then
5732        MIDL_PATH=$winsdktest/Bin/$winsdkbinsubdir/$WINDOWS_SDK_ARCH
5733        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME/Bin/$winsdkbinsubdir
5734    elif test -f "$winsdktest/Bin/$WINDOWS_SDK_ARCH/midl.exe"; then
5735        MIDL_PATH=$winsdktest/Bin/$WINDOWS_SDK_ARCH
5736        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME/Bin
5737    elif test -f "$winsdktest/Bin/midl.exe"; then
5738        MIDL_PATH=$winsdktest/Bin
5739        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME/Bin
5740    fi
5741    if test ! -f "$MIDL_PATH/midl.exe"; then
5742        AC_MSG_ERROR([midl.exe not found in $winsdktest/Bin/$WINDOWS_SDK_ARCH, Windows SDK installation broken?])
5743    else
5744        AC_MSG_RESULT([$MIDL_PATH/midl.exe])
5745    fi
5746
5747    # Convert to posix path with 8.3 filename restrictions ( No spaces )
5748    MIDL_PATH=`win_short_path_for_make "$MIDL_PATH"`
5749
5750    if test -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msiinfo.exe" \
5751         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msidb.exe" \
5752         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/uuidgen.exe" \
5753         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msitran.exe"; then :
5754    elif test -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msiinfo.exe" \
5755         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msidb.exe" \
5756         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/uuidgen.exe" \
5757         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msitran.exe"; then :
5758    elif test -f "$WINDOWS_SDK_HOME/bin/x86/msiinfo.exe" \
5759         -a -f "$WINDOWS_SDK_HOME/bin/x86/msidb.exe" \
5760         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/uuidgen.exe" \
5761         -a -f "$WINDOWS_SDK_HOME/bin/x86/msitran.exe"; then :
5762    else
5763        AC_MSG_ERROR([Some (all?) Windows Installer tools in the Windows SDK are missing, please install.])
5764    fi
5765
5766    dnl Check csc.exe
5767    AC_MSG_CHECKING([for csc.exe])
5768    find_csc
5769    if test -f "$csctest/csc.exe"; then
5770        CSC_PATH="$csctest"
5771    fi
5772    if test ! -f "$CSC_PATH/csc.exe"; then
5773        AC_MSG_ERROR([csc.exe not found as $CSC_PATH/csc.exe])
5774    else
5775        AC_MSG_RESULT([$CSC_PATH/csc.exe])
5776    fi
5777
5778    CSC_PATH=`win_short_path_for_make "$CSC_PATH"`
5779
5780    dnl Check al.exe
5781    AC_MSG_CHECKING([for al.exe])
5782    find_winsdk
5783    if test -n "$winsdkbinsubdir" \
5784        -a -f "$winsdktest/Bin/$winsdkbinsubdir/$WINDOWS_SDK_ARCH/al.exe"
5785    then
5786        AL_PATH="$winsdktest/Bin/$winsdkbinsubdir/$WINDOWS_SDK_ARCH"
5787    elif test -f "$winsdktest/Bin/$WINDOWS_SDK_ARCH/al.exe"; then
5788        AL_PATH="$winsdktest/Bin/$WINDOWS_SDK_ARCH"
5789    elif test -f "$winsdktest/Bin/al.exe"; then
5790        AL_PATH="$winsdktest/Bin"
5791    fi
5792
5793    if test -z "$AL_PATH"; then
5794        find_al
5795        if test -f "$altest/bin/al.exe"; then
5796            AL_PATH="$altest/bin"
5797        elif test -f "$altest/al.exe"; then
5798            AL_PATH="$altest"
5799        fi
5800    fi
5801    if test ! -f "$AL_PATH/al.exe"; then
5802        AC_MSG_ERROR([al.exe not found as $AL_PATH/al.exe])
5803    else
5804        AC_MSG_RESULT([$AL_PATH/al.exe])
5805    fi
5806
5807    AL_PATH=`win_short_path_for_make "$AL_PATH"`
5808
5809    dnl Check mscoree.lib / .NET Framework dir
5810    AC_MSG_CHECKING(.NET Framework)
5811    find_dotnetsdk46
5812    PathFormat "$frametest"
5813    frametest="$formatted_path"
5814    if test -f "$frametest/Lib/um/$WINDOWS_SDK_ARCH/mscoree.lib"; then
5815        DOTNET_FRAMEWORK_HOME="$frametest"
5816    else
5817        find_winsdk
5818        if test -f "$winsdktest/lib/mscoree.lib" -o -f "$winsdktest/lib/$winsdklibsubdir/um/$WINDOWS_SDK_ARCH/mscoree.lib"; then
5819            DOTNET_FRAMEWORK_HOME="$winsdktest"
5820        fi
5821    fi
5822    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
5823        AC_MSG_ERROR([mscoree.lib not found])
5824    fi
5825    AC_MSG_RESULT([found: $DOTNET_FRAMEWORK_HOME])
5826
5827    PathFormat "$MIDL_PATH"
5828    MIDL_PATH="$formatted_path"
5829
5830    PathFormat "$AL_PATH"
5831    AL_PATH="$formatted_path"
5832
5833    PathFormat "$DOTNET_FRAMEWORK_HOME"
5834    DOTNET_FRAMEWORK_HOME="$formatted_path"
5835
5836    PathFormat "$CSC_PATH"
5837    CSC_PATH="$formatted_path"
5838fi
5839
5840dnl ===================================================================
5841dnl Check if stdc headers are available excluding MSVC.
5842dnl ===================================================================
5843if test "$_os" != "WINNT"; then
5844    AC_HEADER_STDC
5845fi
5846
5847dnl ===================================================================
5848dnl Testing for C++ compiler and version...
5849dnl ===================================================================
5850
5851if test "$_os" != "WINNT"; then
5852    # AC_PROG_CXX sets CXXFLAGS to -g -O2 if not set, avoid that
5853    save_CXXFLAGS=$CXXFLAGS
5854    AC_PROG_CXX
5855    CXXFLAGS=$save_CXXFLAGS
5856else
5857    if test -n "$CC" -a -z "$CXX"; then
5858        CXX="$CC"
5859    fi
5860fi
5861
5862dnl check for GNU C++ compiler version
5863if test "$GXX" = "yes"; then
5864    AC_MSG_CHECKING([the GNU C++ compiler version])
5865
5866    _gpp_version=`$CXX -dumpversion`
5867    _gpp_majmin=`echo $_gpp_version | $AWK -F. '{ print \$1*100+\$2 }'`
5868
5869    if test "$_gpp_majmin" -lt "401"; then
5870        AC_MSG_ERROR([You need to use GNU C++ compiler version >= 4.1 to build LibreOffice, you have $_gpp_version.])
5871    else
5872        AC_MSG_RESULT([checked (g++ $_gpp_version)])
5873    fi
5874
5875    dnl see https://code.google.com/p/android/issues/detail?id=41770
5876    if test "$_gpp_majmin" -ge "401"; then
5877        glibcxx_threads=no
5878        AC_LANG_PUSH([C++])
5879        AC_REQUIRE_CPP
5880        AC_MSG_CHECKING([whether $CXX is broken with boost.thread])
5881        AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
5882            #include <bits/c++config.h>]],[[
5883            #if !defined(_GLIBCXX_HAVE_GTHR_DEFAULT) \
5884            && !defined(_GLIBCXX__PTHREADS) \
5885            && !defined(_GLIBCXX_HAS_GTHREADS)
5886            choke me
5887            #endif
5888        ]])],[AC_MSG_RESULT([yes])
5889        glibcxx_threads=yes],[AC_MSG_RESULT([no])])
5890        AC_LANG_POP([C++])
5891        if test $glibcxx_threads = yes; then
5892            BOOST_CXXFLAGS="-D_GLIBCXX_HAS_GTHREADS"
5893        fi
5894     fi
5895fi
5896AC_SUBST(BOOST_CXXFLAGS)
5897
5898#
5899# prefx CXX with ccache if needed
5900#
5901if test "$CCACHE" != ""; then
5902    AC_MSG_CHECKING([whether $CXX is already ccached])
5903    AC_LANG_PUSH([C++])
5904    save_CXXFLAGS=$CXXFLAGS
5905    CXXFLAGS="$CXXFLAGS --ccache-skip -O2"
5906    dnl an empty program will do, we're checking the compiler flags
5907    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
5908                      [use_ccache=yes], [use_ccache=no])
5909    if test $use_ccache = yes; then
5910        AC_MSG_RESULT([yes])
5911    else
5912        CXX="$CCACHE $CXX"
5913        AC_MSG_RESULT([no])
5914    fi
5915    CXXFLAGS=$save_CXXFLAGS
5916    AC_LANG_POP([C++])
5917fi
5918
5919dnl ===================================================================
5920dnl Find pre-processors.(should do that _after_ messing with CC/CXX)
5921dnl ===================================================================
5922
5923if test "$_os" != "WINNT"; then
5924    AC_PROG_CXXCPP
5925
5926    dnl Check whether there's a C pre-processor.
5927    AC_PROG_CPP
5928fi
5929
5930
5931dnl ===================================================================
5932dnl Find integral type sizes and alignments
5933dnl ===================================================================
5934
5935if test "$_os" != "WINNT"; then
5936
5937if test "$_os" == "iOS"; then
5938    AC_MSG_CHECKING([iOS setting sizes long, short, int, long long, double, voidp])
5939    ac_cv_sizeof_long=8
5940    ac_cv_sizeof_short=2
5941    ac_cv_sizeof_int=4
5942    ac_cv_sizeof_long_long=8
5943    ac_cv_sizeof_double=8
5944    ac_cv_sizeof_voidp=8
5945else
5946    AC_CHECK_SIZEOF(long)
5947    AC_CHECK_SIZEOF(short)
5948    AC_CHECK_SIZEOF(int)
5949    AC_CHECK_SIZEOF(long long)
5950    AC_CHECK_SIZEOF(double)
5951    AC_CHECK_SIZEOF(void*)
5952fi
5953
5954    SAL_TYPES_SIZEOFSHORT=$ac_cv_sizeof_short
5955    SAL_TYPES_SIZEOFINT=$ac_cv_sizeof_int
5956    SAL_TYPES_SIZEOFLONG=$ac_cv_sizeof_long
5957    SAL_TYPES_SIZEOFLONGLONG=$ac_cv_sizeof_long_long
5958    SAL_TYPES_SIZEOFPOINTER=$ac_cv_sizeof_voidp
5959
5960    dnl Allow build without AC_CHECK_ALIGNOF, grrr
5961    m4_pattern_allow([AC_CHECK_ALIGNOF])
5962    m4_ifdef([AC_CHECK_ALIGNOF],
5963        [
5964            AC_CHECK_ALIGNOF(short,[#include <stddef.h>])
5965            AC_CHECK_ALIGNOF(int,[#include <stddef.h>])
5966            AC_CHECK_ALIGNOF(long,[#include <stddef.h>])
5967            AC_CHECK_ALIGNOF(double,[#include <stddef.h>])
5968        ],
5969        [
5970            case "$_os-$host_cpu" in
5971            Linux-i686)
5972                test -z "$ac_cv_alignof_short" && ac_cv_alignof_short=2
5973                test -z "$ac_cv_alignof_int" && ac_cv_alignof_int=4
5974                test -z "$ac_cv_alignof_long" && ac_cv_alignof_long=4
5975                test -z "$ac_cv_alignof_double" && ac_cv_alignof_double=4
5976                ;;
5977            Linux-x86_64)
5978                test -z "$ac_cv_alignof_short" && ac_cv_alignof_short=2
5979                test -z "$ac_cv_alignof_int" && ac_cv_alignof_int=4
5980                test -z "$ac_cv_alignof_long" && ac_cv_alignof_long=8
5981                test -z "$ac_cv_alignof_double" && ac_cv_alignof_double=8
5982                ;;
5983            *)
5984                if test -z "$ac_cv_alignof_short" -o \
5985                        -z "$ac_cv_alignof_int" -o \
5986                        -z "$ac_cv_alignof_long" -o \
5987                        -z "$ac_cv_alignof_double"; then
5988                   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.])
5989                fi
5990                ;;
5991            esac
5992        ])
5993
5994    SAL_TYPES_ALIGNMENT2=$ac_cv_alignof_short
5995    SAL_TYPES_ALIGNMENT4=$ac_cv_alignof_int
5996    if test $ac_cv_sizeof_long -eq 8; then
5997        SAL_TYPES_ALIGNMENT8=$ac_cv_alignof_long
5998    elif test $ac_cv_sizeof_double -eq 8; then
5999        SAL_TYPES_ALIGNMENT8=$ac_cv_alignof_double
6000    else
6001        AC_MSG_ERROR([Cannot find alignment of 8 byte types.])
6002    fi
6003
6004    dnl Check for large file support
6005    AC_SYS_LARGEFILE
6006    if test -n "$ac_cv_sys_file_offset_bits" -a "$ac_cv_sys_file_offset_bits" != "no"; then
6007        LFS_CFLAGS="-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
6008    fi
6009    if test -n "$ac_cv_sys_large_files" -a "$ac_cv_sys_large_files" != "no"; then
6010        LFS_CFLAGS="$LFS_CFLAGS -D_LARGE_FILES"
6011    fi
6012else
6013    # Hardcode for MSVC
6014    SAL_TYPES_SIZEOFSHORT=2
6015    SAL_TYPES_SIZEOFINT=4
6016    SAL_TYPES_SIZEOFLONG=4
6017    SAL_TYPES_SIZEOFLONGLONG=8
6018    if test "$BITNESS_OVERRIDE" = ""; then
6019        SAL_TYPES_SIZEOFPOINTER=4
6020    else
6021        SAL_TYPES_SIZEOFPOINTER=8
6022    fi
6023    SAL_TYPES_ALIGNMENT2=2
6024    SAL_TYPES_ALIGNMENT4=4
6025    SAL_TYPES_ALIGNMENT8=8
6026    LFS_CFLAGS=''
6027fi
6028AC_SUBST(LFS_CFLAGS)
6029
6030AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFSHORT,$SAL_TYPES_SIZEOFSHORT)
6031AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFINT,$SAL_TYPES_SIZEOFINT)
6032AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFLONG,$SAL_TYPES_SIZEOFLONG)
6033AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFLONGLONG,$SAL_TYPES_SIZEOFLONGLONG)
6034AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFPOINTER,$SAL_TYPES_SIZEOFPOINTER)
6035AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT2,$SAL_TYPES_ALIGNMENT2)
6036AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT4,$SAL_TYPES_ALIGNMENT4)
6037AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT8,$SAL_TYPES_ALIGNMENT8)
6038
6039dnl ===================================================================
6040dnl Check whether to enable runtime optimizations
6041dnl ===================================================================
6042ENABLE_RUNTIME_OPTIMIZATIONS=
6043AC_MSG_CHECKING([whether to enable runtime optimizations])
6044if test -z "$enable_runtime_optimizations"; then
6045    for i in $CC; do
6046        case $i in
6047        -fsanitize=*)
6048            enable_runtime_optimizations=no
6049            break
6050            ;;
6051        esac
6052    done
6053fi
6054if test "$enable_runtime_optimizations" != no; then
6055    ENABLE_RUNTIME_OPTIMIZATIONS=TRUE
6056    AC_DEFINE(ENABLE_RUNTIME_OPTIMIZATIONS)
6057    AC_MSG_RESULT([yes])
6058else
6059    AC_MSG_RESULT([no])
6060fi
6061AC_SUBST([ENABLE_RUNTIME_OPTIMIZATIONS])
6062
6063dnl ===================================================================
6064dnl Check if valgrind headers are available
6065dnl ===================================================================
6066ENABLE_VALGRIND=
6067if test "$cross_compiling" != yes -a "$with_valgrind" != no; then
6068    prev_cppflags=$CPPFLAGS
6069    # Is VALGRIND_CFLAGS something one is supposed to have in the environment,
6070    # or where does it come from?
6071    CPPFLAGS="$CPPFLAGS $VALGRIND_CFLAGS"
6072    AC_CHECK_HEADER([valgrind/valgrind.h],
6073        [ENABLE_VALGRIND=TRUE])
6074    CPPFLAGS=$prev_cppflags
6075fi
6076AC_SUBST([ENABLE_VALGRIND])
6077if test -z "$ENABLE_VALGRIND"; then
6078    if test "$with_valgrind" = yes; then
6079        AC_MSG_ERROR([--with-valgrind specified but no Valgrind headers found])
6080    fi
6081    VALGRIND_CFLAGS=
6082fi
6083AC_SUBST([VALGRIND_CFLAGS])
6084
6085
6086dnl ===================================================================
6087dnl Check if SDT probes (for systemtap, gdb, dtrace) are available
6088dnl ===================================================================
6089
6090# We need at least the sys/sdt.h include header.
6091AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND='TRUE'], [SDT_H_FOUND='FALSE'])
6092if test "$SDT_H_FOUND" = "TRUE"; then
6093    # Found sys/sdt.h header, now make sure the c++ compiler works.
6094    # Old g++ versions had problems with probes in constructors/destructors.
6095    AC_MSG_CHECKING([working sys/sdt.h and c++ support])
6096    AC_LANG_PUSH([C++])
6097    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
6098    #include <sys/sdt.h>
6099    class ProbeClass
6100    {
6101    private:
6102      int& ref;
6103      const char *name;
6104
6105    public:
6106      ProbeClass(int& v, const char *n) : ref(v), name(n)
6107      {
6108        DTRACE_PROBE2(_test_, cons, name, ref);
6109      }
6110
6111      void method(int min)
6112      {
6113        DTRACE_PROBE3(_test_, meth, name, ref, min);
6114        ref -= min;
6115      }
6116
6117      ~ProbeClass()
6118      {
6119        DTRACE_PROBE2(_test_, dest, name, ref);
6120      }
6121    };
6122    ]],[[
6123    int i = 64;
6124    DTRACE_PROBE1(_test_, call, i);
6125    ProbeClass inst = ProbeClass(i, "call");
6126    inst.method(24);
6127    ]])], [AC_MSG_RESULT([yes]); AC_DEFINE([USE_SDT_PROBES])],
6128          [AC_MSG_RESULT([no, sdt.h or c++ compiler too old])])
6129    AC_LANG_POP([C++])
6130fi
6131AC_CONFIG_HEADERS([config_host/config_probes.h])
6132
6133dnl ===================================================================
6134dnl GCC features
6135dnl ===================================================================
6136if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
6137    AC_MSG_CHECKING([whether $CC supports -mno-avx])
6138    save_CFLAGS=$CFLAGS
6139    CFLAGS="$CFLAGS -Werror -mno-avx"
6140    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_AVX=TRUE ],[])
6141    CFLAGS=$save_CFLAGS
6142    if test "$HAVE_GCC_AVX" = "TRUE"; then
6143        AC_MSG_RESULT([yes])
6144    else
6145        AC_MSG_RESULT([no])
6146    fi
6147
6148    AC_MSG_CHECKING([whether $CC supports -fstack-protector-strong])
6149    save_CFLAGS=$CFLAGS
6150    CFLAGS="$CFLAGS -O0 -Werror -fstack-protector-strong"
6151    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ char a[8]; a[7] = 0; ]])],[ HAVE_GCC_STACK_PROTECTOR_STRONG=TRUE ],[])
6152    CFLAGS=$save_CFLAGS
6153    if test "$HAVE_GCC_STACK_PROTECTOR_STRONG" = "TRUE"; then
6154        AC_MSG_RESULT([yes])
6155    else
6156        AC_MSG_RESULT([no])
6157    fi
6158
6159    AC_MSG_CHECKING([whether $CC supports atomic functions])
6160    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
6161    int v = 0;
6162    if (__sync_add_and_fetch(&v, 1) != 1 ||
6163        __sync_sub_and_fetch(&v, 1) != 0)
6164        return 1;
6165    __sync_synchronize();
6166    if (__sync_val_compare_and_swap(&v, 0, 1) != 0 ||
6167        v != 1)
6168        return 1;
6169    return 0;
6170]])],[HAVE_GCC_BUILTIN_ATOMIC=TRUE],[])
6171    if test "$HAVE_GCC_BUILTIN_ATOMIC" = "TRUE"; then
6172        AC_MSG_RESULT([yes])
6173        AC_DEFINE(HAVE_GCC_BUILTIN_ATOMIC)
6174    else
6175        AC_MSG_RESULT([no])
6176    fi
6177
6178    AC_MSG_CHECKING([whether $CC supports __builtin_ffs])
6179    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return __builtin_ffs(1); ]])],[HAVE_GCC_BUILTIN_FFS=TRUE],[])
6180    if test "$HAVE_GCC_BUILTIN_FFS" = "TRUE"; then
6181        AC_MSG_RESULT([yes])
6182        AC_DEFINE(HAVE_GCC_BUILTIN_FFS)
6183    else
6184        AC_MSG_RESULT([no])
6185    fi
6186
6187    AC_MSG_CHECKING([whether $CC supports __attribute__((deprecated(message)))])
6188    save_CFLAGS=$CFLAGS
6189    CFLAGS="$CFLAGS -Werror"
6190    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6191            __attribute__((deprecated("test"))) void f();
6192        ])], [
6193            AC_DEFINE([HAVE_GCC_DEPRECATED_MESSAGE],[1])
6194            AC_MSG_RESULT([yes])
6195        ], [AC_MSG_RESULT([no])])
6196    CFLAGS=$save_CFLAGS
6197
6198    AC_MSG_CHECKING([whether $CXX defines __base_class_type_info in cxxabi.h])
6199    AC_LANG_PUSH([C++])
6200    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6201            #include <cstddef>
6202            #include <cxxabi.h>
6203            std::size_t f() { return sizeof(__cxxabiv1::__base_class_type_info); }
6204        ])], [
6205            AC_DEFINE([HAVE_CXXABI_H_BASE_CLASS_TYPE_INFO],[1])
6206            AC_MSG_RESULT([yes])
6207        ], [AC_MSG_RESULT([no])])
6208    AC_LANG_POP([C++])
6209
6210    AC_MSG_CHECKING([whether $CXX defines __class_type_info in cxxabi.h])
6211    AC_LANG_PUSH([C++])
6212    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6213            #include <cstddef>
6214            #include <cxxabi.h>
6215            std::size_t f() { return sizeof(__cxxabiv1::__class_type_info); }
6216        ])], [
6217            AC_DEFINE([HAVE_CXXABI_H_CLASS_TYPE_INFO],[1])
6218            AC_MSG_RESULT([yes])
6219        ], [AC_MSG_RESULT([no])])
6220    AC_LANG_POP([C++])
6221
6222    AC_MSG_CHECKING([whether $CXX declares __cxa_allocate_exception in cxxabi.h])
6223    AC_LANG_PUSH([C++])
6224    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6225            #include <cxxabi.h>
6226            void * f() { return __cxxabiv1::__cxa_allocate_exception(0); }
6227        ])], [
6228            AC_DEFINE([HAVE_CXXABI_H_CXA_ALLOCATE_EXCEPTION],[1])
6229            AC_MSG_RESULT([yes])
6230        ], [AC_MSG_RESULT([no])])
6231    AC_LANG_POP([C++])
6232
6233    AC_MSG_CHECKING([whether $CXX defines __cxa_eh_globals in cxxabi.h])
6234    AC_LANG_PUSH([C++])
6235    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6236            #include <cstddef>
6237            #include <cxxabi.h>
6238            std::size_t f() { return sizeof(__cxxabiv1::__cxa_eh_globals); }
6239        ])], [
6240            AC_DEFINE([HAVE_CXXABI_H_CXA_EH_GLOBALS],[1])
6241            AC_MSG_RESULT([yes])
6242        ], [AC_MSG_RESULT([no])])
6243    AC_LANG_POP([C++])
6244
6245    AC_MSG_CHECKING([whether $CXX defines __cxa_exceptions in cxxabi.h])
6246    AC_LANG_PUSH([C++])
6247    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6248            #include <cstddef>
6249            #include <cxxabi.h>
6250            std::size_t f() { return sizeof(__cxxabiv1::__cxa_exceptions); }
6251        ])], [
6252            AC_DEFINE([HAVE_CXXABI_H_CXA_EXCEPTIONS],[1])
6253            AC_MSG_RESULT([yes])
6254        ], [AC_MSG_RESULT([no])])
6255    AC_LANG_POP([C++])
6256
6257    AC_MSG_CHECKING([whether $CXX declares __cxa_get_globals in cxxabi.h])
6258    AC_LANG_PUSH([C++])
6259    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6260            #include <cxxabi.h>
6261            void * f() { return __cxxabiv1::__cxa_get_globals(); }
6262        ])], [
6263            AC_DEFINE([HAVE_CXXABI_H_CXA_GET_GLOBALS],[1])
6264            AC_MSG_RESULT([yes])
6265        ], [AC_MSG_RESULT([no])])
6266    AC_LANG_POP([C++])
6267
6268    AC_MSG_CHECKING([whether $CXX declares __cxa_current_exception_type in cxxabi.h])
6269    AC_LANG_PUSH([C++])
6270    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6271            #include <cxxabi.h>
6272            void * f() { return __cxxabiv1::__cxa_current_exception_type(); }
6273        ])], [
6274            AC_DEFINE([HAVE_CXXABI_H_CXA_CURRENT_EXCEPTION_TYPE],[1])
6275            AC_MSG_RESULT([yes])
6276        ], [AC_MSG_RESULT([no])])
6277    AC_LANG_POP([C++])
6278
6279    AC_MSG_CHECKING([whether $CXX declares __cxa_throw in cxxabi.h])
6280    AC_LANG_PUSH([C++])
6281    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6282            #include <cxxabi.h>
6283            void f() { __cxxabiv1::__cxa_throw(0, 0, 0); }
6284        ])], [
6285            AC_DEFINE([HAVE_CXXABI_H_CXA_THROW],[1])
6286            AC_MSG_RESULT([yes])
6287        ], [AC_MSG_RESULT([no])])
6288    AC_LANG_POP([C++])
6289
6290    AC_MSG_CHECKING([whether $CXX defines __si_class_type_info in cxxabi.h])
6291    AC_LANG_PUSH([C++])
6292    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6293            #include <cstddef>
6294            #include <cxxabi.h>
6295            std::size_t f() { return sizeof(__cxxabiv1::__si_class_type_info); }
6296        ])], [
6297            AC_DEFINE([HAVE_CXXABI_H_SI_CLASS_TYPE_INFO],[1])
6298            AC_MSG_RESULT([yes])
6299        ], [AC_MSG_RESULT([no])])
6300    AC_LANG_POP([C++])
6301
6302    AC_MSG_CHECKING([whether $CXX defines __vmi_class_type_info in cxxabi.h])
6303    AC_LANG_PUSH([C++])
6304    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6305            #include <cstddef>
6306            #include <cxxabi.h>
6307            std::size_t f() { return sizeof(__cxxabiv1::__vmi_class_type_info); }
6308        ])], [
6309            AC_DEFINE([HAVE_CXXABI_H_VMI_CLASS_TYPE_INFO],[1])
6310            AC_MSG_RESULT([yes])
6311        ], [AC_MSG_RESULT([no])])
6312    AC_LANG_POP([C++])
6313
6314    dnl Available in GCC 4.9 and at least since Clang 3.4:
6315    AC_MSG_CHECKING([whether $CXX supports __attribute__((warn_unused))])
6316    AC_LANG_PUSH([C++])
6317    save_CXXFLAGS=$CXXFLAGS
6318    CXXFLAGS="$CXXFLAGS -Werror"
6319    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6320            struct __attribute__((warn_unused)) dummy {};
6321        ])], [
6322            AC_DEFINE([HAVE_GCC_ATTRIBUTE_WARN_UNUSED],[1])
6323            AC_MSG_RESULT([yes])
6324        ], [AC_MSG_RESULT([no])])
6325    CXXFLAGS=$save_CXXFLAGS
6326AC_LANG_POP([C++])
6327fi
6328
6329AC_SUBST(HAVE_GCC_AVX)
6330AC_SUBST(HAVE_GCC_STACK_PROTECTOR_STRONG)
6331AC_SUBST(HAVE_GCC_BUILTIN_ATOMIC)
6332AC_SUBST(HAVE_GCC_BUILTIN_FFS)
6333
6334dnl ===================================================================
6335dnl Identify the C++ library
6336dnl ===================================================================
6337
6338AC_MSG_CHECKING([what the C++ library is])
6339AC_LANG_PUSH([C++])
6340AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6341#include <utility>
6342#ifndef __GLIBCXX__
6343foo bar
6344#endif
6345]])],
6346    [CPP_LIBRARY=GLIBCXX
6347     cpp_library_name="GNU libstdc++"
6348    ],
6349    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6350#include <utility>
6351#ifndef _LIBCPP_VERSION
6352foo bar
6353#endif
6354]])],
6355    [CPP_LIBRARY=LIBCPP
6356     cpp_library_name="LLVM libc++"
6357     AC_DEFINE([HAVE_LIBCXX])
6358    ],
6359    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6360#include <utility>
6361#ifndef _MSC_VER
6362foo bar
6363#endif
6364]])],
6365    [CPP_LIBRARY=MSVCRT
6366     cpp_library_name="Microsoft"
6367    ],
6368    AC_MSG_ERROR([Could not figure out what C++ library this is]))))
6369AC_MSG_RESULT([$cpp_library_name])
6370AC_LANG_POP([C++])
6371
6372dnl ===================================================================
6373dnl Check for gperf
6374dnl ===================================================================
6375AC_PATH_PROG(GPERF, gperf)
6376if test -z "$GPERF"; then
6377    AC_MSG_ERROR([gperf not found but needed. Install it.])
6378fi
6379if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
6380    GPERF=`cygpath -m $GPERF`
6381fi
6382AC_MSG_CHECKING([whether gperf is new enough])
6383my_gperf_ver1=$($GPERF --version | head -n 1)
6384my_gperf_ver2=${my_gperf_ver1#GNU gperf }
6385my_gperf_ver3=$(printf %s "$my_gperf_ver2" | $AWK -F. '{ print $1*100+($2<100?$2:99) }')
6386if test "$my_gperf_ver3" -ge 301; then
6387    AC_MSG_RESULT([yes ($my_gperf_ver2)])
6388else
6389    AC_MSG_ERROR(["$my_gperf_ver1" is too old or unrecognized, must be at least gperf 3.1])
6390fi
6391AC_SUBST(GPERF)
6392
6393dnl ===================================================================
6394dnl Check for system libcmis
6395dnl ===================================================================
6396# libcmis requires curl and we can't build curl for iOS
6397if test $_os != iOS; then
6398    libo_CHECK_SYSTEM_MODULE([libcmis],[LIBCMIS],[libcmis-0.5 >= 0.5.0])
6399    ENABLE_LIBCMIS=TRUE
6400else
6401    ENABLE_LIBCMIS=
6402fi
6403AC_SUBST(ENABLE_LIBCMIS)
6404
6405dnl ===================================================================
6406dnl C++11
6407dnl ===================================================================
6408
6409AC_MSG_CHECKING([whether $CXX supports C++17])
6410CXXFLAGS_CXX11=
6411if test "$COM" = MSC -a "$COM_IS_CLANG" != TRUE; then
6412    CXXFLAGS_CXX11='-std:c++17 -Zc:__cplusplus'
6413elif test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
6414    my_flags='-std=gnu++2a -std=c++2a -std=gnu++17 -std=gnu++1z -std=c++17 -std=c++1z'
6415    for flag in $my_flags; do
6416        if test "$COM" = MSC; then
6417            flag="-Xclang $flag"
6418        fi
6419        save_CXXFLAGS=$CXXFLAGS
6420        CXXFLAGS="$CXXFLAGS $flag -Werror"
6421        if test "$SYSTEM_LIBCMIS" = TRUE; then
6422            CXXFLAGS="$CXXFLAGS -DSYSTEM_LIBCMIS $LIBCMIS_CFLAGS"
6423        fi
6424        AC_LANG_PUSH([C++])
6425        dnl Clang 3.9 supports __float128 since
6426        dnl <http://llvm.org/viewvc/llvm-project?view=revision&revision=268898> "Enable support for
6427        dnl __float128 in Clang and enable it on pertinent platforms", but Clang 3.8 may need a
6428        dnl hacky workaround to be able to include <vector> (as is done in the main check whether
6429        dnl $flag is supported below, so check this first):
6430        my_float128hack=
6431        my_float128hack_impl=-D__float128=void
6432        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6433            #include <vector>
6434            // some Clang fail when compiling against libstdc++ headers with -std=gnu++0x
6435            // (__float128)
6436            ]])
6437        ],,[
6438            dnl The only reason why libstdc++ headers fail with Clang in C++11 mode is because they
6439            dnl use the __float128 type that Clang doesn't know (libstdc++ checks whether __float128
6440            dnl is available during its build, but it's usually built using GCC, and so c++config.h
6441            dnl hardcodes __float128 being supported). At least for some older libstdc++, the only
6442            dnl place where __float128 is used is in a template specialization, -D__float128=void
6443            dnl will avoid the problem there while still causing a problem if somebody actually uses
6444            dnl the type. (But some later libstdc++ are known to use __float128 also in algorithm ->
6445            dnl bits/stl_alog.h -> cstdlib -> bits/std_abs.h, in a way that unfortunately cannot be
6446            dnl "fixed" with this hack):
6447            CXXFLAGS="$CXXFLAGS $my_float128hack_impl"
6448            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6449                #include <vector>
6450                // some Clang fail when compiling against libstdc++ headers with -std=gnu++0x
6451                // (__float128)
6452                ]])
6453            ],[my_float128hack=$my_float128hack_impl])
6454        ])
6455        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6456            #include <algorithm>
6457            #include <cmath>
6458            #include <functional>
6459            #include <vector>
6460
6461            #if defined SYSTEM_LIBCMIS
6462            // See ucb/source/ucp/cmis/auth_provider.hxx:
6463            #if !defined __clang__
6464            #pragma GCC diagnostic push
6465            #pragma GCC diagnostic ignored "-Wdeprecated"
6466            #pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
6467            #endif
6468            #include <libcmis/libcmis.hxx>
6469            #if !defined __clang__
6470            #pragma GCC diagnostic pop
6471            #endif
6472            #endif
6473
6474            void f(std::vector<int> & v, std::function<bool(int, int)> fn) {
6475                std::sort(v.begin(), v.end(), fn);
6476            }
6477
6478            // At least with glibc-headers-2.28-26.fc29.x86_64, when building for Linux x86 32-bit
6479            // (via -m32) and passed-in CXXFLAGS setting -O1 (or higher; overriding -Os as set in
6480            // solenv/gbuild/platform/LINUX_INTEL_GCC.mk), std=gnu* would cause math_errhandling to
6481            // get undef'ed in /usr/include/bits/mathinline.h, while std=c* keeps it defined (as
6482            // needed by sc/source/core/tool/math.cxx):
6483            int g() { return math_errhandling; }
6484            ]])],[CXXFLAGS_CXX11=$flag $my_float128hack])
6485        AC_LANG_POP([C++])
6486        CXXFLAGS=$save_CXXFLAGS
6487        if test -n "$CXXFLAGS_CXX11"; then
6488            break
6489        fi
6490    done
6491fi
6492if test -n "$CXXFLAGS_CXX11"; then
6493    AC_MSG_RESULT([yes ($CXXFLAGS_CXX11)])
6494else
6495    AC_MSG_ERROR(no)
6496fi
6497AC_SUBST(CXXFLAGS_CXX11)
6498
6499dnl Test for temporarily incompatible libstdc++ 4.7.{0,1}, where
6500dnl <https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=179528> introduced
6501dnl an additional member _M_size into C++11 std::list towards 4.7.0 and
6502dnl <https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=189186> removed it
6503dnl again towards 4.7.2:
6504if test $CPP_LIBRARY = GLIBCXX; then
6505    AC_MSG_CHECKING([whether using C++11 causes libstdc++ 4.7.0/4.7.1 ABI breakage])
6506    AC_LANG_PUSH([C++])
6507    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6508#include <list>
6509#if !defined __GLIBCXX__ || (__GLIBCXX__ != 20120322 && __GLIBCXX__ != 20120614)
6510    // according to <https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html>:
6511    //   GCC 4.7.0: 20120322
6512    //   GCC 4.7.1: 20120614
6513    // and using a range check is not possible as the mapping between
6514    // __GLIBCXX__ values and GCC versions is not monotonic
6515/* ok */
6516#else
6517abi broken
6518#endif
6519        ]])], [AC_MSG_RESULT(no, ok)],
6520        [AC_MSG_ERROR(yes)])
6521    AC_LANG_POP([C++])
6522fi
6523
6524AC_MSG_CHECKING([whether $CXX supports C++11 without Language Defect 757])
6525save_CXXFLAGS=$CXXFLAGS
6526CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
6527AC_LANG_PUSH([C++])
6528
6529AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6530#include <stddef.h>
6531
6532template <typename T, size_t S> char (&sal_n_array_size( T(&)[S] ))[S];
6533
6534namespace
6535{
6536        struct b
6537        {
6538                int i;
6539                int j;
6540        };
6541}
6542]], [[
6543struct a
6544{
6545        int i;
6546        int j;
6547};
6548a thinga[]={{0,0}, {1,1}};
6549b thingb[]={{0,0}, {1,1}};
6550size_t i = sizeof(sal_n_array_size(thinga));
6551size_t j = sizeof(sal_n_array_size(thingb));
6552return !(i != 0 && j != 0);
6553]])
6554    ], [ AC_MSG_RESULT(yes) ],
6555    [ AC_MSG_ERROR(no)])
6556AC_LANG_POP([C++])
6557CXXFLAGS=$save_CXXFLAGS
6558
6559dnl _Pragma support (may require C++11)
6560if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
6561    AC_MSG_CHECKING([whether $CXX supports _Pragma operator])
6562    AC_LANG_PUSH([C++])
6563    save_CXXFLAGS=$CXXFLAGS
6564    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11 -Werror"
6565    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6566            _Pragma("GCC diagnostic ignored \"-Wformat\"")
6567        ])], [
6568            AC_DEFINE([HAVE_GCC_PRAGMA_OPERATOR],[1])
6569            AC_MSG_RESULT([yes])
6570        ], [AC_MSG_RESULT([no])])
6571    AC_LANG_POP([C++])
6572    CXXFLAGS=$save_CXXFLAGS
6573fi
6574
6575HAVE_GCC_FNO_SIZED_DEALLOCATION=
6576if test "$GCC" = yes; then
6577    AC_MSG_CHECKING([whether $CXX supports -fno-sized-deallocation])
6578    AC_LANG_PUSH([C++])
6579    save_CXXFLAGS=$CXXFLAGS
6580    CXXFLAGS="$CXXFLAGS -fno-sized-deallocation"
6581    AC_LINK_IFELSE([AC_LANG_PROGRAM()],[HAVE_GCC_FNO_SIZED_DEALLOCATION=TRUE])
6582    CXXFLAGS=$save_CXXFLAGS
6583    AC_LANG_POP([C++])
6584    if test "$HAVE_GCC_FNO_SIZED_DEALLOCATION" = TRUE; then
6585        AC_MSG_RESULT([yes])
6586    else
6587        AC_MSG_RESULT([no])
6588    fi
6589fi
6590AC_SUBST([HAVE_GCC_FNO_SIZED_DEALLOCATION])
6591
6592AC_MSG_CHECKING([whether $CXX supports guaranteed copy elision])
6593AC_LANG_PUSH([C++])
6594save_CXXFLAGS=$CXXFLAGS
6595CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
6596AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6597        // At least VS 2017 15.8.1 defines __cpp_guaranteed_copy_elision as 201606L without actually
6598        // supporting it:
6599        #if !defined __cpp_guaranteed_copy_elision || (defined _MSC_VER && !defined __clang__)
6600        struct S {
6601        private:
6602            S(S const &);
6603        public:
6604            S();
6605            ~S();
6606        };
6607        S copy();
6608        void f() { S c(copy()); }
6609        #endif
6610    ])], [
6611        AC_DEFINE([HAVE_CPP_GUARANTEED_COPY_ELISION],[1])
6612        AC_MSG_RESULT([yes])
6613    ], [AC_MSG_RESULT([no])])
6614CXXFLAGS=$save_CXXFLAGS
6615AC_LANG_POP([C++])
6616
6617AC_MSG_CHECKING([whether $CXX has GCC bug 87150])
6618AC_LANG_PUSH([C++])
6619save_CXXFLAGS=$CXXFLAGS
6620CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
6621AC_COMPILE_IFELSE([AC_LANG_SOURCE([
6622        struct S1 { S1(S1 &&); };
6623        struct S2: S1 {};
6624        S1 f(S2 s) { return s; }
6625    ])], [
6626        AC_DEFINE([HAVE_GCC_BUG_87150],[1])
6627        AC_MSG_RESULT([yes])
6628    ], [AC_MSG_RESULT([no])])
6629CXXFLAGS=$save_CXXFLAGS
6630AC_LANG_POP([C++])
6631
6632dnl At least GCC 8.2 with -O2 (i.e., --enable-optimized) causes a false-positive -Wmaybe-
6633dnl uninitialized warning for code like
6634dnl
6635dnl   OString f();
6636dnl   boost::optional<OString> * g(bool b) {
6637dnl       boost::optional<OString> o;
6638dnl       if (b) o = f();
6639dnl       return new boost::optional<OString>(o);
6640dnl   }
6641dnl
6642dnl (as is e.g. present, in a slightly more elaborate form, in
6643dnl librdf_TypeConverter::extractNode_NoLock in unoxml/source/rdf/librdf_repository.cxx); the below
6644dnl code is meant to be a faithfully stripped-down and self-contained version of the above code:
6645HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED=
6646if test "$GCC" = yes && test "$COM_IS_CLANG" != TRUE; then
6647    AC_MSG_CHECKING([whether $CXX might report false -Werror=maybe-uninitialized])
6648    AC_LANG_PUSH([C++])
6649    save_CXXFLAGS=$CXXFLAGS
6650    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11 -Werror -Wmaybe-uninitialized"
6651    if test "$ENABLE_OPTIMIZED" = TRUE; then
6652        CXXFLAGS="$CXXFLAGS -O2"
6653    else
6654        CXXFLAGS="$CXXFLAGS -O0"
6655    fi
6656    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
6657            #include <new>
6658            void f1(int);
6659            struct S1 {
6660                ~S1() { f1(n); }
6661                int n = 0;
6662            };
6663            struct S2 {
6664                S2() {}
6665                S2(S2 const & s) { if (s.init) set(*reinterpret_cast<S1 const *>(s.stg)); }
6666                ~S2() { if (init) reinterpret_cast<S1 *>(stg)->S1::~S1(); }
6667                void set(S1 s) {
6668                    new (stg) S1(s);
6669                    init = true;
6670                }
6671                bool init = false;
6672                char stg[sizeof (S1)];
6673            } ;
6674            S1 f2();
6675            S2 * f3(bool b) {
6676                S2 o;
6677                if (b) o.set(f2());
6678                return new S2(o);
6679            }
6680        ]])], [AC_MSG_RESULT([no])], [
6681            HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED=TRUE
6682            AC_MSG_RESULT([yes])
6683        ])
6684    CXXFLAGS=$save_CXXFLAGS
6685    AC_LANG_POP([C++])
6686fi
6687AC_SUBST([HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED])
6688
6689dnl ===================================================================
6690dnl system stl sanity tests
6691dnl ===================================================================
6692if test "$_os" != "WINNT"; then
6693
6694    AC_LANG_PUSH([C++])
6695
6696    save_CPPFLAGS="$CPPFLAGS"
6697    if test -n "$MACOSX_SDK_PATH"; then
6698        CPPFLAGS="-isysroot $MACOSX_SDK_PATH $CPPFLAGS"
6699    fi
6700
6701    # Assume visibility is not broken with libc++. The below test is very much designed for libstdc++
6702    # only.
6703    if test "$CPP_LIBRARY" = GLIBCXX; then
6704        dnl gcc#19664, gcc#22482, rhbz#162935
6705        AC_MSG_CHECKING([if STL headers are visibility safe (GCC bug 22482)])
6706        AC_EGREP_HEADER(visibility push, string, stlvisok=yes, stlvisok=no)
6707        AC_MSG_RESULT([$stlvisok])
6708        if test "$stlvisok" = "no"; then
6709            AC_MSG_ERROR([Your libstdc++ headers are not visibility safe. This is no longer supported.])
6710        fi
6711    fi
6712
6713    # As the below test checks things when linking self-compiled dynamic libraries, it presumably is irrelevant
6714    # when we don't make any dynamic libraries?
6715    if test "$DISABLE_DYNLOADING" = ""; then
6716        AC_MSG_CHECKING([if $CXX is -fvisibility-inlines-hidden safe (Clang bug 11250)])
6717        cat > conftestlib1.cc <<_ACEOF
6718template<typename T> struct S1 { virtual ~S1() {} virtual void f() {} };
6719struct S2: S1<int> { virtual ~S2(); };
6720S2::~S2() {}
6721_ACEOF
6722        cat > conftestlib2.cc <<_ACEOF
6723template<typename T> struct S1 { virtual ~S1() {} virtual void f() {} };
6724struct S2: S1<int> { virtual ~S2(); };
6725struct S3: S2 { virtual ~S3(); }; S3::~S3() {}
6726_ACEOF
6727        gccvisinlineshiddenok=yes
6728        if ! $CXX $CXXFLAGS $CPPFLAGS $LINKFLAGSSHL -fPIC -fvisibility-inlines-hidden conftestlib1.cc -o libconftest1$DLLPOST >/dev/null 2>&5; then
6729            gccvisinlineshiddenok=no
6730        else
6731            dnl At least Clang -fsanitize=address and -fsanitize=undefined are
6732            dnl known to not work with -z defs (unsetting which makes the test
6733            dnl moot, though):
6734            my_linkflagsnoundefs=$LINKFLAGSNOUNDEFS
6735            if test "$COM_IS_CLANG" = TRUE; then
6736                for i in $CXX $CXXFLAGS; do
6737                    case $i in
6738                    -fsanitize=*)
6739                        my_linkflagsnoundefs=
6740                        break
6741                        ;;
6742                    esac
6743                done
6744            fi
6745            if ! $CXX $CXXFLAGS $CPPFLAGS $LINKFLAGSSHL -fPIC -fvisibility-inlines-hidden conftestlib2.cc -L. -lconftest1 $my_linkflagsnoundefs -o libconftest2$DLLPOST >/dev/null 2>&5; then
6746                gccvisinlineshiddenok=no
6747            fi
6748        fi
6749
6750        rm -fr libconftest*
6751        AC_MSG_RESULT([$gccvisinlineshiddenok])
6752        if test "$gccvisinlineshiddenok" = "no"; then
6753            AC_MSG_ERROR([Your gcc/clang is not -fvisibility-inlines-hidden safe. This is no longer supported.])
6754        fi
6755    fi
6756
6757   AC_MSG_CHECKING([if $CXX has a visibility bug with class-level attributes (GCC bug 26905)])
6758    cat >visibility.cxx <<_ACEOF
6759#pragma GCC visibility push(hidden)
6760struct __attribute__ ((visibility ("default"))) TestStruct {
6761  static void Init();
6762};
6763__attribute__ ((visibility ("default"))) void TestFunc() {
6764  TestStruct::Init();
6765}
6766_ACEOF
6767    if ! $CXX $CXXFLAGS $CPPFLAGS -fpic -S visibility.cxx; then
6768        gccvisbroken=yes
6769    else
6770        case "$host_cpu" in
6771        i?86|x86_64)
6772            if test "$_os" = "Darwin" -o "$_os" = "iOS"; then
6773                gccvisbroken=no
6774            else
6775                if $EGREP -q '@PLT|@GOT' visibility.s || test "$ENABLE_LTO" = "TRUE"; then
6776                    gccvisbroken=no
6777                else
6778                    gccvisbroken=yes
6779                fi
6780            fi
6781            ;;
6782        *)
6783            gccvisbroken=no
6784            ;;
6785        esac
6786    fi
6787    rm -f visibility.s visibility.cxx
6788
6789    AC_MSG_RESULT([$gccvisbroken])
6790    if test "$gccvisbroken" = "yes"; then
6791        AC_MSG_ERROR([Your gcc is not -fvisibility=hidden safe. This is no longer supported.])
6792    fi
6793
6794    CPPFLAGS="$save_CPPFLAGS"
6795
6796    AC_LANG_POP([C++])
6797fi
6798
6799dnl ===================================================================
6800dnl  Clang++ tests
6801dnl ===================================================================
6802
6803HAVE_GCC_FNO_ENFORCE_EH_SPECS=
6804if test "$GCC" = "yes"; then
6805    AC_MSG_CHECKING([whether $CXX supports -fno-enforce-eh-specs])
6806    AC_LANG_PUSH([C++])
6807    save_CXXFLAGS=$CXXFLAGS
6808    CXXFLAGS="$CFLAGS -Werror -fno-enforce-eh-specs"
6809    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_FNO_ENFORCE_EH_SPECS=TRUE ],[])
6810    CXXFLAGS=$save_CXXFLAGS
6811    AC_LANG_POP([C++])
6812    if test "$HAVE_GCC_FNO_ENFORCE_EH_SPECS" = "TRUE"; then
6813        AC_MSG_RESULT([yes])
6814    else
6815        AC_MSG_RESULT([no])
6816    fi
6817fi
6818AC_SUBST(HAVE_GCC_FNO_ENFORCE_EH_SPECS)
6819
6820dnl ===================================================================
6821dnl Compiler plugins
6822dnl ===================================================================
6823
6824COMPILER_PLUGINS=
6825# currently only Clang
6826
6827if test "$COM_IS_CLANG" != "TRUE"; then
6828    if test "$libo_fuzzed_enable_compiler_plugins" = yes -a "$enable_compiler_plugins" = yes; then
6829        AC_MSG_NOTICE([Resetting --enable-compiler-plugins=no])
6830        enable_compiler_plugins=no
6831    fi
6832fi
6833
6834if test "$COM_IS_CLANG" = "TRUE"; then
6835    if test -n "$enable_compiler_plugins"; then
6836        compiler_plugins="$enable_compiler_plugins"
6837    elif test -n "$ENABLE_DBGUTIL"; then
6838        compiler_plugins=test
6839    else
6840        compiler_plugins=no
6841    fi
6842    if test "$compiler_plugins" != no -a "$CLANGVER" -lt 50002; then
6843        if test "$compiler_plugins" = yes; then
6844            AC_MSG_ERROR([Clang $CLANGVER is too old to build compiler plugins; need >= 5.0.2.])
6845        else
6846            compiler_plugins=no
6847        fi
6848    fi
6849    if test "$compiler_plugins" != "no"; then
6850        dnl The prefix where Clang resides, override to where Clang resides if
6851        dnl using a source build:
6852        if test -z "$CLANGDIR"; then
6853            CLANGDIR=$(dirname $(dirname $($CXX -print-prog-name=$(basename $CXX))))
6854        fi
6855        AC_LANG_PUSH([C++])
6856        save_CPPFLAGS=$CPPFLAGS
6857        save_CXX=$CXX
6858        save_CXXCPP=$CXXCPP
6859        # compiler plugins must be built with "native" compiler that was used to build Clang itself:
6860        : "${COMPILER_PLUGINS_CXX=g++ -std=c++11}"
6861        CXX=$COMPILER_PLUGINS_CXX
6862        CXXCPP="$COMPILER_PLUGINS_CXX -E"
6863        CPPFLAGS="$CPPFLAGS -I$CLANGDIR/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
6864        AC_CHECK_HEADER(clang/AST/RecursiveASTVisitor.h,
6865            [COMPILER_PLUGINS=TRUE],
6866            [
6867            if test "$compiler_plugins" = "yes"; then
6868                AC_MSG_ERROR([Cannot find Clang headers to build compiler plugins.])
6869            else
6870                AC_MSG_WARN([Cannot find Clang headers to build compiler plugins, plugins disabled])
6871                add_warning "Cannot find Clang headers to build compiler plugins, plugins disabled."
6872            fi
6873            ])
6874        CXX=$save_CXX
6875        CXXCPP=$save_CXXCPP
6876        CPPFLAGS=$save_CPPFLAGS
6877        AC_LANG_POP([C++])
6878    fi
6879else
6880    if test "$enable_compiler_plugins" = "yes"; then
6881        AC_MSG_ERROR([Compiler plugins are currently supported only with the Clang compiler.])
6882    fi
6883fi
6884AC_SUBST(COMPILER_PLUGINS)
6885AC_SUBST(COMPILER_PLUGINS_CXX)
6886AC_SUBST(COMPILER_PLUGINS_CXX_LINKFLAGS)
6887AC_SUBST(COMPILER_PLUGINS_DEBUG)
6888AC_SUBST(COMPILER_PLUGINS_TOOLING_ARGS)
6889AC_SUBST(CLANGDIR)
6890AC_SUBST(CLANGLIBDIR)
6891
6892# Plugin to help linker.
6893# Add something like LD_PLUGIN=/usr/lib64/LLVMgold.so to your autogen.input.
6894# This makes --enable-lto build with clang work.
6895AC_SUBST(LD_PLUGIN)
6896
6897AC_CHECK_FUNCS(posix_fallocate, HAVE_POSIX_FALLOCATE=YES, [HAVE_POSIX_FALLOCATE=NO])
6898AC_SUBST(HAVE_POSIX_FALLOCATE)
6899
6900dnl ===================================================================
6901dnl Custom build version
6902dnl ===================================================================
6903
6904AC_MSG_CHECKING([whether to add custom build version])
6905if test "$with_build_version" != ""; then
6906    BUILD_VER_STRING=$with_build_version
6907    AC_MSG_RESULT([yes, $BUILD_VER_STRING])
6908else
6909    BUILD_VER_STRING=
6910    AC_MSG_RESULT([no])
6911fi
6912AC_SUBST(BUILD_VER_STRING)
6913
6914JITC_PROCESSOR_TYPE=""
6915if test "$_os" = "Linux" -a "$host_cpu" = "powerpc"; then
6916    # IBMs JDK needs this...
6917    JITC_PROCESSOR_TYPE=6
6918    export JITC_PROCESSOR_TYPE
6919fi
6920AC_SUBST([JITC_PROCESSOR_TYPE])
6921
6922# Misc Windows Stuff
6923AC_ARG_WITH(ucrt-dir,
6924    AS_HELP_STRING([--with-ucrt-dir],
6925        [path to the directory with the arch-specific MSU packages of the Windows Universal CRT redistributables
6926        (MS KB 2999226) for packaging into the installsets (without those the target system needs to install
6927        the UCRT or Visual C++ Runtimes manually). The directory must contain the following 6 files:
6928            Windows6.1-KB2999226-x64.msu
6929            Windows6.1-KB2999226-x86.msu
6930            Windows8.1-KB2999226-x64.msu
6931            Windows8.1-KB2999226-x86.msu
6932            Windows8-RT-KB2999226-x64.msu
6933            Windows8-RT-KB2999226-x86.msu
6934        A zip archive including those files is available from Microsoft site:
6935        https://www.microsoft.com/en-us/download/details.aspx?id=48234]),
6936,)
6937UCRT_REDISTDIR="$with_ucrt_dir"
6938if test $_os = "WINNT"; then
6939    find_msvc_x64_dlls
6940    find_msms
6941    MSVC_DLL_PATH="$msvcdllpath"
6942    MSVC_DLLS="$msvcdlls"
6943    MSM_PATH="$msmdir"
6944    # MSVC 15.3 changed it to VC141
6945    if echo "$MSVC_DLL_PATH" | grep -q "VC141.CRT$"; then
6946        SCPDEFS="$SCPDEFS -DWITH_VC141_REDIST"
6947    else
6948        SCPDEFS="$SCPDEFS -DWITH_VC${VCVER}_REDIST"
6949    fi
6950    if test "$UCRT_REDISTDIR" = "no"; then
6951        dnl explicitly disabled
6952        UCRT_REDISTDIR=""
6953    else
6954        if ! test -f "$UCRT_REDISTDIR/Windows6.1-KB2999226-x64.msu" -a \
6955                  -f "$UCRT_REDISTDIR/Windows6.1-KB2999226-x86.msu" -a \
6956                  -f "$UCRT_REDISTDIR/Windows8.1-KB2999226-x64.msu" -a \
6957                  -f "$UCRT_REDISTDIR/Windows8.1-KB2999226-x86.msu" -a \
6958                  -f "$UCRT_REDISTDIR/Windows8-RT-KB2999226-x64.msu" -a \
6959                  -f "$UCRT_REDISTDIR/Windows8-RT-KB2999226-x86.msu"; then
6960            UCRT_REDISTDIR=""
6961            if test -n "$PKGFORMAT"; then
6962               for i in $PKGFORMAT; do
6963                   case "$i" in
6964                   msi)
6965                       AC_MSG_WARN([--without-ucrt-dir not specified or MSUs not found - installer will have runtime dependency])
6966                       add_warning "--without-ucrt-dir not specified or MSUs not found - installer will have runtime dependency"
6967                       ;;
6968                   esac
6969               done
6970            fi
6971        fi
6972    fi
6973fi
6974
6975AC_SUBST(UCRT_REDISTDIR)
6976AC_SUBST(MSVC_DLL_PATH)
6977AC_SUBST(MSVC_DLLS)
6978AC_SUBST(MSM_PATH)
6979
6980dnl ===================================================================
6981dnl Checks for Java
6982dnl ===================================================================
6983if test "$ENABLE_JAVA" != ""; then
6984
6985    # Windows-specific tests
6986    if test "$build_os" = "cygwin"; then
6987        if test "$BITNESS_OVERRIDE" = 64; then
6988            bitness=64
6989        else
6990            bitness=32
6991        fi
6992
6993        if test -z "$with_jdk_home"; then
6994            dnl See <https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-EEED398E-AE37-4D12-
6995            dnl AB10-49F82F720027> section "Windows Registry Key Changes":
6996            reg_get_value "$bitness" "HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/JDK/CurrentVersion"
6997            if test -n "$regvalue"; then
6998                ver=$regvalue
6999                reg_get_value "$bitness" "HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/JDK/$ver/JavaHome"
7000                _jdk_home=$regvalue
7001            fi
7002            if test -z "$with_jdk_home"; then
7003                for ver in 1.8 1.7 1.6; do
7004                    reg_get_value "$bitness" "HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java Development Kit/$ver/JavaHome"
7005                    if test -n "$regvalue"; then
7006                        _jdk_home=$regvalue
7007                        break
7008                    fi
7009                done
7010            fi
7011            if test -f "$_jdk_home/lib/jvm.lib" -a -f "$_jdk_home/bin/java.exe"; then
7012                with_jdk_home="$_jdk_home"
7013                howfound="found automatically"
7014            else
7015                AC_MSG_ERROR([No JDK found, pass the --with-jdk-home option pointing to a $bitness-bit JDK])
7016            fi
7017        else
7018            test "$build_os" = "cygwin" && with_jdk_home=`win_short_path_for_make "$with_jdk_home"`
7019            howfound="you passed"
7020        fi
7021    fi
7022
7023    # 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.
7024    # /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java, but /usr does not contain the JDK libraries
7025    if test -z "$with_jdk_home" -a "$_os" = "Darwin" -a -x /usr/libexec/java_home; then
7026        with_jdk_home=`/usr/libexec/java_home`
7027    fi
7028
7029    JAVA_HOME=; export JAVA_HOME
7030    if test -z "$with_jdk_home"; then
7031        AC_PATH_PROG(JAVAINTERPRETER, $with_java)
7032    else
7033        _java_path="$with_jdk_home/bin/$with_java"
7034        dnl Check if there is a Java interpreter at all.
7035        if test -x "$_java_path"; then
7036            JAVAINTERPRETER=$_java_path
7037        else
7038            AC_MSG_ERROR([$_java_path not found, pass --with-jdk-home])
7039        fi
7040    fi
7041
7042    dnl Check that the JDK found is correct architecture (at least 2 reasons to
7043    dnl check: officebean needs to link -ljawt, and libjpipe.so needs to be
7044    dnl loaded by java to run JunitTests:
7045    if test "$build_os" = "cygwin"; then
7046        shortjdkhome=`cygpath -d "$with_jdk_home"`
7047        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
7048            AC_MSG_WARN([You are building 64-bit binaries but the JDK $howfound is 32-bit])
7049            AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a 64-bit JDK])
7050        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
7051            AC_MSG_WARN([You are building 32-bit binaries but the JDK $howfound is 64-bit])
7052            AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a (32-bit) JDK])
7053        fi
7054
7055        if test x`echo "$JAVAINTERPRETER" | $GREP -i '\.exe$'` = x; then
7056            JAVAINTERPRETER="${JAVAINTERPRETER}.exe"
7057        fi
7058        JAVAINTERPRETER=`win_short_path_for_make "$JAVAINTERPRETER"`
7059    elif test "$cross_compiling" != "yes"; then
7060        case $CPUNAME in
7061            AARCH64|AXP|X86_64|HPPA|IA64|POWERPC64|S390X|SPARC64|GODSON64)
7062                if test -f "$JAVAINTERPRETER" -a "`$JAVAINTERPRETER -version 2>&1 | $GREP -i 64-bit`" = "" >/dev/null; then
7063                    AC_MSG_WARN([You are building 64-bit binaries but the JDK $JAVAINTERPRETER is 32-bit])
7064                    AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a 64-bit JDK])
7065                fi
7066                ;;
7067            *) # assumption: everything else 32-bit
7068                if test -f "$JAVAINTERPRETER" -a "`$JAVAINTERPRETER -version 2>&1 | $GREP -i 64-bit`" != ""  >/dev/null; then
7069                    AC_MSG_WARN([You are building 32-bit binaries but the JDK $howfound is 64-bit])
7070                    AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a (32-bit) JDK])
7071                fi
7072                ;;
7073        esac
7074    fi
7075fi
7076
7077dnl ===================================================================
7078dnl Checks for JDK.
7079dnl ===================================================================
7080
7081# Note that JAVA_HOME as for now always means the *build* platform's
7082# JAVA_HOME. Whether all the complexity here actually is needed any
7083# more or not, no idea.
7084
7085if test "$ENABLE_JAVA" != ""; then
7086    _gij_longver=0
7087    AC_MSG_CHECKING([the installed JDK])
7088    if test -n "$JAVAINTERPRETER"; then
7089        dnl java -version sends output to stderr!
7090        if test `$JAVAINTERPRETER -version 2>&1 | $GREP -c "Kaffe"` -gt 0; then
7091            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
7092        elif test `$JAVAINTERPRETER --version 2>&1 | $GREP -c "GNU libgcj"` -gt 0; then
7093            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
7094        elif test `$JAVAINTERPRETER -version 2>&1 | $AWK '{ print }' | $GREP -c "BEA"` -gt 0; then
7095            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
7096        elif test `$JAVAINTERPRETER -version 2>&1 | $AWK '{ print }' | $GREP -c "IBM"` -gt 0; then
7097            JDK=ibm
7098
7099            dnl IBM JDK specific tests
7100            _jdk=`$JAVAINTERPRETER -version 2>&1 | $AWK -F'"' '{ print \$2 }' | $SED s/[[-A-Za-z]]*//`
7101            _jdk_ver=`echo "$_jdk" | $AWK -F. '{ print (($1 * 100) + $2) * 100 + $3;}'`
7102
7103            if test "$_jdk_ver" -lt 10600; then
7104                AC_MSG_ERROR([IBM JDK is too old, you need at least 1.6])
7105            fi
7106
7107            AC_MSG_RESULT([checked (IBM JDK $_jdk)])
7108
7109            if test "$with_jdk_home" = ""; then
7110                AC_MSG_ERROR([In order to successfully build LibreOffice using the IBM JDK,
7111you must use the "--with-jdk-home" configure option explicitly])
7112            fi
7113
7114            JAVA_HOME=$with_jdk_home
7115        else
7116            JDK=sun
7117
7118            dnl Sun JDK specific tests
7119            _jdk=`$JAVAINTERPRETER -version 2>&1 | $AWK -F'"' '{ print \$2 }' | $SED '/^$/d' | $SED s/[[-A-Za-z]]*//`
7120            _jdk_ver=`echo "$_jdk" | $AWK -F. '{ print (($1 * 100) + $2) * 100 + $3;}'`
7121
7122            if test "$_jdk_ver" -lt 10600; then
7123                AC_MSG_ERROR([JDK is too old, you need at least 1.6])
7124            fi
7125            if test "$_jdk_ver" -gt 10600; then
7126                JAVA_CLASSPATH_NOT_SET=TRUE
7127            fi
7128
7129            AC_MSG_RESULT([checked (JDK $_jdk)])
7130            JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*java,,p"`
7131            if test "$_os" = "WINNT"; then
7132                JAVA_HOME=`echo $JAVA_HOME | $SED "s,\.[[eE]][[xX]][[eE]]$,,"`
7133            fi
7134
7135            # set to limit VM usage for JunitTests
7136            JAVAIFLAGS=-Xmx64M
7137            # set to limit VM usage for javac
7138            JAVAFLAGS=-J-Xmx128M
7139        fi
7140    else
7141        AC_MSG_ERROR([Java not found. You need at least jdk-1.6])
7142    fi
7143else
7144    dnl Java disabled
7145    JAVA_HOME=
7146    export JAVA_HOME
7147fi
7148
7149dnl ===================================================================
7150dnl Checks for javac
7151dnl ===================================================================
7152if test "$ENABLE_JAVA" != ""; then
7153    javacompiler="javac"
7154    : ${JAVA_SOURCE_VER=1.6}
7155    : ${JAVA_TARGET_VER=1.6}
7156    if test -z "$with_jdk_home"; then
7157        AC_PATH_PROG(JAVACOMPILER, $javacompiler)
7158    else
7159        _javac_path="$with_jdk_home/bin/$javacompiler"
7160        dnl Check if there is a Java compiler at all.
7161        if test -x "$_javac_path"; then
7162            JAVACOMPILER=$_javac_path
7163        fi
7164    fi
7165    if test -z "$JAVACOMPILER"; then
7166        AC_MSG_ERROR([$javacompiler not found set with_jdk_home])
7167    fi
7168    if test "$build_os" = "cygwin"; then
7169        if test x`echo "$JAVACOMPILER" | $GREP -i '\.exe$'` = x; then
7170            JAVACOMPILER="${JAVACOMPILER}.exe"
7171        fi
7172        JAVACOMPILER=`win_short_path_for_make "$JAVACOMPILER"`
7173    fi
7174fi
7175
7176dnl ===================================================================
7177dnl Checks for javadoc
7178dnl ===================================================================
7179if test "$ENABLE_JAVA" != ""; then
7180    if test -z "$with_jdk_home"; then
7181        AC_PATH_PROG(JAVADOC, javadoc)
7182    else
7183        _javadoc_path="$with_jdk_home/bin/javadoc"
7184        dnl Check if there is a javadoc at all.
7185        if test -x "$_javadoc_path"; then
7186            JAVADOC=$_javadoc_path
7187        else
7188            AC_PATH_PROG(JAVADOC, javadoc)
7189        fi
7190    fi
7191    if test -z "$JAVADOC"; then
7192        AC_MSG_ERROR([$_javadoc_path not found set with_jdk_home])
7193    fi
7194    if test "$build_os" = "cygwin"; then
7195        if test x`echo "$JAVADOC" | $GREP -i '\.exe$'` = x; then
7196            JAVADOC="${JAVADOC}.exe"
7197        fi
7198        JAVADOC=`win_short_path_for_make "$JAVADOC"`
7199    fi
7200
7201    if test `$JAVADOC --version 2>&1 | $GREP -c "gjdoc"` -gt 0; then
7202    JAVADOCISGJDOC="yes"
7203    fi
7204fi
7205AC_SUBST(JAVADOCISGJDOC)
7206
7207if test "$ENABLE_JAVA" != ""; then
7208    # check if JAVA_HOME was (maybe incorrectly?) set automatically to /usr
7209    if test "$JAVA_HOME" = "/usr" -a "x$with_jdk_home" = "x"; then
7210        if basename $(readlink $(readlink $JAVACOMPILER)) >/dev/null 2>/dev/null; then
7211           # try to recover first by looking whether we have an alternative
7212           # system as in Debian or newer SuSEs where following /usr/bin/javac
7213           # over /etc/alternatives/javac leads to the right bindir where we
7214           # just need to strip a bit away to get a valid JAVA_HOME
7215           JAVA_HOME=$(readlink $(readlink $JAVACOMPILER))
7216        elif readlink $JAVACOMPILER >/dev/null 2>/dev/null; then
7217            # maybe only one level of symlink (e.g. on Mac)
7218            JAVA_HOME=$(readlink $JAVACOMPILER)
7219            if test "$(dirname $JAVA_HOME)" = "."; then
7220                # we've got no path to trim back
7221                JAVA_HOME=""
7222            fi
7223        else
7224            # else warn
7225            AC_MSG_WARN([JAVA_HOME is set to /usr - this is very likely to be incorrect])
7226            AC_MSG_WARN([if this is the case, please inform the correct JAVA_HOME with --with-jdk-home])
7227            add_warning "JAVA_HOME is set to /usr - this is very likely to be incorrect"
7228            add_warning "if this is the case, please inform the correct JAVA_HOME with --with-jdk-home"
7229        fi
7230        dnl now that we probably have the path to the real javac, make a JAVA_HOME out of it..
7231        if test "$JAVA_HOME" != "/usr"; then
7232            if test "$_os" = "Darwin" -o "$OS_FOR_BUILD" = MACOSX; then
7233                dnl Leopard returns a non-suitable path with readlink - points to "Current" only
7234                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/Current/Commands/javac$,/CurrentJDK/Home,)
7235                dnl Tiger already returns a JDK path..
7236                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/CurrentJDK/Commands/javac$,/CurrentJDK/Home,)
7237            else
7238                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/bin/javac$,,)
7239                dnl check that we have a directory as certain distros eg gentoo substitute javac for a script
7240                dnl that checks which version to run
7241                if test -f "$JAVA_HOME"; then
7242                    JAVA_HOME=""; # set JAVA_HOME to null if it's a file
7243                fi
7244            fi
7245        fi
7246    fi
7247    # as we drop out of this, JAVA_HOME may have been set to the empty string by readlink
7248
7249    dnl now if JAVA_HOME has been set to empty, then call findhome to find it
7250    if test -z "$JAVA_HOME"; then
7251        if test "x$with_jdk_home" = "x"; then
7252            cat > findhome.java <<_ACEOF
7253[import java.io.File;
7254
7255class findhome
7256{
7257    public static void main(String args[])
7258    {
7259        String jrelocation = System.getProperty("java.home");
7260        File jre = new File(jrelocation);
7261        System.out.println(jre.getParent());
7262    }
7263}]
7264_ACEOF
7265            AC_MSG_CHECKING([if javac works])
7266            javac_cmd="$JAVACOMPILER findhome.java 1>&2"
7267            AC_TRY_EVAL(javac_cmd)
7268            if test $? = 0 -a -f ./findhome.class; then
7269                AC_MSG_RESULT([javac works])
7270            else
7271                echo "configure: javac test failed" >&5
7272                cat findhome.java >&5
7273                AC_MSG_ERROR([javac does not work - java projects will not build!])
7274            fi
7275            AC_MSG_CHECKING([if gij knows its java.home])
7276            JAVA_HOME=`$JAVAINTERPRETER findhome`
7277            if test $? = 0 -a "$JAVA_HOME" != ""; then
7278                AC_MSG_RESULT([$JAVA_HOME])
7279            else
7280                echo "configure: java test failed" >&5
7281                cat findhome.java >&5
7282                AC_MSG_ERROR([gij does not know its java.home - use --with-jdk-home])
7283            fi
7284            # clean-up after ourselves
7285            rm -f ./findhome.java ./findhome.class
7286        else
7287            JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*$with_java,,p"`
7288        fi
7289    fi
7290
7291    # now check if $JAVA_HOME is really valid
7292    if test "$_os" = "Darwin" -o "$OS_FOR_BUILD" = MACOSX; then
7293        case "${JAVA_HOME}" in
7294            /Library/Java/JavaVirtualMachines/*)
7295                ;;
7296            *)
7297                AC_MSG_ERROR([JDK in $JAVA_HOME cannot be used in CppUnit tests - install Oracle JDK])
7298                ;;
7299        esac
7300        if test ! -f "$JAVA_HOME/lib/jvm.cfg" -a "x$with_jdk_home" = "x"; then
7301            JAVA_HOME_OK="NO"
7302        fi
7303    elif test ! -d "$JAVA_HOME/jre" -a "x$with_jdk_home" = "x"; then
7304        JAVA_HOME_OK="NO"
7305    fi
7306    if test "$JAVA_HOME_OK" = "NO"; then
7307        AC_MSG_WARN([JAVA_HOME was not explicitly informed with --with-jdk-home. the configure script])
7308        AC_MSG_WARN([attempted to find JAVA_HOME automatically, but apparently it failed])
7309        AC_MSG_WARN([in case JAVA_HOME is incorrectly set, some projects will not be built correctly])
7310        add_warning "JAVA_HOME was not explicitly informed with --with-jdk-home. the configure script"
7311        add_warning "attempted to find JAVA_HOME automatically, but apparently it failed"
7312        add_warning "in case JAVA_HOME is incorrectly set, some projects will not be built correctly"
7313    fi
7314    PathFormat "$JAVA_HOME"
7315    JAVA_HOME="$formatted_path"
7316fi
7317
7318if test -z "$JAWTLIB" -a -n "$ENABLE_JAVA" -a "$_os" != Android -a \
7319    "$_os" != Darwin
7320then
7321    AC_MSG_CHECKING([for JAWT lib])
7322    if test "$_os" = WINNT; then
7323        # The path to $JAVA_HOME/lib/$JAWTLIB is part of $ILIB:
7324        JAWTLIB=jawt.lib
7325    else
7326        case "$host_cpu" in
7327        arm*)
7328            AS_IF([test -e "$JAVA_HOME/jre/lib/aarch32/libjawt.so"], [my_java_arch=aarch32], [my_java_arch=arm])
7329            JAVA_ARCH=$my_java_arch
7330            ;;
7331        i*86)
7332            my_java_arch=i386
7333            ;;
7334        m68k)
7335            my_java_arch=m68k
7336            ;;
7337        powerpc)
7338            my_java_arch=ppc
7339            ;;
7340        powerpc64)
7341            my_java_arch=ppc64
7342            ;;
7343        powerpc64le)
7344            AS_IF([test -e "$JAVA_HOME/jre/lib/ppc64le/libjawt.so"], [my_java_arch=ppc64le], [my_java_arch=ppc64])
7345            JAVA_ARCH=$my_java_arch
7346            ;;
7347        sparc64)
7348            my_java_arch=sparcv9
7349            ;;
7350        x86_64)
7351            my_java_arch=amd64
7352            ;;
7353        *)
7354            my_java_arch=$host_cpu
7355            ;;
7356        esac
7357        # This is where JDK9 puts the library
7358        if test -e "$JAVA_HOME/lib/libjawt.so"; then
7359            JAWTLIB="-L$JAVA_HOME/lib/ -ljawt"
7360        else
7361            JAWTLIB="-L$JAVA_HOME/jre/lib/$my_java_arch -ljawt"
7362        fi
7363        AS_IF([test "$JAVA_ARCH" != ""], [AC_DEFINE_UNQUOTED([JAVA_ARCH], ["$JAVA_ARCH"])])
7364    fi
7365    AC_MSG_RESULT([$JAWTLIB])
7366fi
7367AC_SUBST(JAWTLIB)
7368
7369if test -n "$ENABLE_JAVA" -a -z "$JAVAINC"; then
7370    case "$host_os" in
7371
7372    aix*)
7373        JAVAINC="-I$JAVA_HOME/include"
7374        JAVAINC="$JAVAINC -I$JAVA_HOME/include/aix"
7375        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
7376        ;;
7377
7378    cygwin*)
7379        JAVAINC="-I$JAVA_HOME/include/win32"
7380        JAVAINC="$JAVAINC -I$JAVA_HOME/include"
7381        ;;
7382
7383    darwin*)
7384        if test -d "$JAVA_HOME/include/darwin"; then
7385            JAVAINC="-I$JAVA_HOME/include  -I$JAVA_HOME/include/darwin"
7386        else
7387            JAVAINC=${ISYSTEM}$FRAMEWORKSHOME/JavaVM.framework/Versions/Current/Headers
7388        fi
7389        ;;
7390
7391    dragonfly*)
7392        JAVAINC="-I$JAVA_HOME/include"
7393        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
7394        ;;
7395
7396    freebsd*)
7397        JAVAINC="-I$JAVA_HOME/include"
7398        JAVAINC="$JAVAINC -I$JAVA_HOME/include/freebsd"
7399        JAVAINC="$JAVAINC -I$JAVA_HOME/include/bsd"
7400        JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux"
7401        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
7402        ;;
7403
7404    k*bsd*-gnu*)
7405        JAVAINC="-I$JAVA_HOME/include"
7406        JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux"
7407        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
7408        ;;
7409
7410    linux-gnu*)
7411        JAVAINC="-I$JAVA_HOME/include"
7412        JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux"
7413        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
7414        ;;
7415
7416    *netbsd*)
7417        JAVAINC="-I$JAVA_HOME/include"
7418        JAVAINC="$JAVAINC -I$JAVA_HOME/include/netbsd"
7419        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
7420       ;;
7421
7422    openbsd*)
7423        JAVAINC="-I$JAVA_HOME/include"
7424        JAVAINC="$JAVAINC -I$JAVA_HOME/include/openbsd"
7425        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
7426        ;;
7427
7428    solaris*)
7429        JAVAINC="-I$JAVA_HOME/include"
7430        JAVAINC="$JAVAINC -I$JAVA_HOME/include/solaris"
7431        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
7432        ;;
7433    esac
7434fi
7435SOLARINC="$SOLARINC $JAVAINC"
7436
7437if test "$ENABLE_JAVA" != "" -a "x" != "x$JAVACOMPILER" && test "$_jdk_ver" -ge 10900; then
7438    url_check_unknown=0
7439    java_base="testurlcheck"
7440    java_src="${java_base}.java"
7441    java_cls="${java_base}.class"
7442    cat > "${java_src}" <<_ACEOF
7443[import jdk.internal.loader.URLClassPath;
7444import java.lang.reflect.Field;
7445import java.net.URL;
7446
7447class ${java_base}
7448{
7449    public static void main(String args[])
7450    {
7451        try {
7452            URLClassPath cp = new URLClassPath(new URL[0], null);
7453            Field field = cp.getClass().getDeclaredField("DISABLE_CP_URL_CHECK");
7454            field.setAccessible(true);
7455            System.out.println(field.get(cp).toString());
7456        } catch(Exception e) {
7457            System.out.println("unknown");
7458        }
7459    }
7460}]
7461_ACEOF
7462    AC_MSG_CHECKING([if jdk.net.URLClassPath.ClassPathURLCheck is disabled])
7463    java_cmd="$JAVACOMPILER --add-exports java.base/jdk.internal.loader=ALL-UNNAMED ${java_src} 1>&2"
7464    AC_TRY_EVAL(java_cmd)
7465    if test $? = 0 -a -f "./${java_cls}"; then
7466        java_res=`$JAVAINTERPRETER --add-opens java.base/jdk.internal.loader=ALL-UNNAMED ${java_base} 2>/dev/null`
7467        if test $? = 0; then
7468            case "${java_res}" in
7469            true) AC_MSG_RESULT([yes]) ;;
7470            false)
7471                rm -f "./${java_src}" "./${java_cls}"
7472                AC_MSG_ERROR([no - Java unit tests will break!])
7473                ;;
7474            *) url_check_unknown=1 ;;
7475            esac
7476        else
7477            url_check_unknown=1
7478        fi
7479    else
7480        url_check_unknown=1
7481    fi
7482    if test $url_check_unknown -eq 1; then
7483        AC_MSG_RESULT([unknown - assuming yes])
7484        add_warning "Unable to find the default value for jdk.net.URLClassPath.ClassPathURLCheck - java tests might fail!"
7485    fi
7486    rm -f "./${java_src}" "./${java_cls}"
7487fi
7488
7489AC_SUBST(JAVACOMPILER)
7490AC_SUBST(JAVADOC)
7491AC_SUBST(JAVAINTERPRETER)
7492AC_SUBST(JAVAIFLAGS)
7493AC_SUBST(JAVAFLAGS)
7494AC_SUBST(JAVA_CLASSPATH_NOT_SET)
7495AC_SUBST(JAVA_HOME)
7496AC_SUBST(JAVA_SOURCE_VER)
7497AC_SUBST(JAVA_TARGET_VER)
7498AC_SUBST(JDK)
7499
7500
7501dnl ===================================================================
7502dnl Export file validation
7503dnl ===================================================================
7504AC_MSG_CHECKING([whether to enable export file validation])
7505if test "$with_export_validation" != "no"; then
7506    if test -z "$ENABLE_JAVA"; then
7507        if test "$with_export_validation" = "yes"; then
7508            AC_MSG_ERROR([requested, but Java is disabled])
7509        else
7510            AC_MSG_RESULT([no, as Java is disabled])
7511        fi
7512    elif test "$_jdk_ver" -lt 10800; then
7513        if test "$with_export_validation" = "yes"; then
7514            AC_MSG_ERROR([requested, but Java is too old, need Java 8])
7515        else
7516            AC_MSG_RESULT([no, as Java is too old, need Java 8])
7517        fi
7518    else
7519        AC_MSG_RESULT([yes])
7520        AC_DEFINE(HAVE_EXPORT_VALIDATION)
7521
7522        AC_PATH_PROGS(ODFVALIDATOR, odfvalidator)
7523        if test -z "$ODFVALIDATOR"; then
7524            # remember to download the ODF toolkit with validator later
7525            AC_MSG_NOTICE([no odfvalidator found, will download it])
7526            BUILD_TYPE="$BUILD_TYPE ODFVALIDATOR"
7527            ODFVALIDATOR="$BUILDDIR/bin/odfvalidator.sh"
7528
7529            # and fetch name of odfvalidator jar name from download.lst
7530            ODFVALIDATOR_JAR=`$SED -n -e "s/export *ODFVALIDATOR_JAR *:= *\(.*\) */\1/p" $SRC_ROOT/download.lst`
7531            AC_SUBST(ODFVALIDATOR_JAR)
7532
7533            if test -z "$ODFVALIDATOR_JAR"; then
7534                AC_MSG_ERROR([cannot determine odfvalidator jar location (--with-export-validation)])
7535            fi
7536        fi
7537        if test "$build_os" = "cygwin"; then
7538            # In case of Cygwin it will be executed from Windows,
7539            # so we need to run bash and absolute path to validator
7540            # so instead of "odfvalidator" it will be
7541            # something like "bash.exe C:\cygwin\opt\lo\bin\odfvalidator"
7542            ODFVALIDATOR="bash.exe `cygpath -m "$ODFVALIDATOR"`"
7543        else
7544            ODFVALIDATOR="sh $ODFVALIDATOR"
7545        fi
7546        AC_SUBST(ODFVALIDATOR)
7547
7548
7549        AC_PATH_PROGS(OFFICEOTRON, officeotron)
7550        if test -z "$OFFICEOTRON"; then
7551            # remember to download the officeotron with validator later
7552            AC_MSG_NOTICE([no officeotron found, will download it])
7553            BUILD_TYPE="$BUILD_TYPE OFFICEOTRON"
7554            OFFICEOTRON="$BUILDDIR/bin/officeotron.sh"
7555
7556            # and fetch name of officeotron jar name from download.lst
7557            OFFICEOTRON_JAR=`$SED -n -e "s/export *OFFICEOTRON_JAR *:= *\(.*\) */\1/p" $SRC_ROOT/download.lst`
7558            AC_SUBST(OFFICEOTRON_JAR)
7559
7560            if test -z "$OFFICEOTRON_JAR"; then
7561                AC_MSG_ERROR([cannot determine officeotron jar location (--with-export-validation)])
7562            fi
7563        else
7564            # check version of existing officeotron
7565            OFFICEOTRON_VER=`$OFFICEOTRON --version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
7566            if test 0"$OFFICEOTRON_VER" -lt 704; then
7567                AC_MSG_ERROR([officeotron too old])
7568            fi
7569        fi
7570        if test "$build_os" = "cygwin"; then
7571            # In case of Cygwin it will be executed from Windows,
7572            # so we need to run bash and absolute path to validator
7573            # so instead of "odfvalidator" it will be
7574            # something like "bash.exe C:\cygwin\opt\lo\bin\odfvalidator"
7575            OFFICEOTRON="bash.exe `cygpath -m "$OFFICEOTRON"`"
7576        else
7577            OFFICEOTRON="sh $OFFICEOTRON"
7578        fi
7579    fi
7580    AC_SUBST(OFFICEOTRON)
7581else
7582    AC_MSG_RESULT([no])
7583fi
7584
7585AC_MSG_CHECKING([for Microsoft Binary File Format Validator])
7586if test "$with_bffvalidator" != "no"; then
7587    AC_DEFINE(HAVE_BFFVALIDATOR)
7588
7589    if test "$with_export_validation" = "no"; then
7590        AC_MSG_ERROR([Please enable export validation (-with-export-validation)!])
7591    fi
7592
7593    if test "$with_bffvalidator" = "yes"; then
7594        BFFVALIDATOR=`win_short_path_for_make "$PROGRAMFILES/Microsoft Office/BFFValidator/BFFValidator.exe"`
7595    else
7596        BFFVALIDATOR="$with_bffvalidator"
7597    fi
7598
7599    if test "$build_os" = "cygwin"; then
7600        if test -n "$BFFVALIDATOR" -a -e "`cygpath $BFFVALIDATOR`"; then
7601            AC_MSG_RESULT($BFFVALIDATOR)
7602        else
7603            AC_MSG_ERROR([bffvalidator not found, but required by --with-bffvalidator])
7604        fi
7605    elif test -n "$BFFVALIDATOR"; then
7606        # We are not in Cygwin but need to run Windows binary with wine
7607        AC_PATH_PROGS(WINE, wine)
7608
7609        # so swap in a shell wrapper that converts paths transparently
7610        BFFVALIDATOR_EXE="$BFFVALIDATOR"
7611        BFFVALIDATOR="sh $BUILDDIR/bin/bffvalidator.sh"
7612        AC_SUBST(BFFVALIDATOR_EXE)
7613        AC_MSG_RESULT($BFFVALIDATOR)
7614    else
7615        AC_MSG_ERROR([bffvalidator not found, but required by --with-bffvalidator])
7616    fi
7617    AC_SUBST(BFFVALIDATOR)
7618else
7619    AC_MSG_RESULT([no])
7620fi
7621
7622dnl ===================================================================
7623dnl Check for C preprocessor to use
7624dnl ===================================================================
7625AC_MSG_CHECKING([which C preprocessor to use in idlc])
7626if test -n "$with_idlc_cpp"; then
7627    AC_MSG_RESULT([$with_idlc_cpp])
7628    AC_PATH_PROG(SYSTEM_UCPP, $with_idlc_cpp)
7629else
7630    AC_MSG_RESULT([ucpp])
7631    AC_MSG_CHECKING([which ucpp tp use])
7632    if test -n "$with_system_ucpp" -a "$with_system_ucpp" != "no"; then
7633        AC_MSG_RESULT([external])
7634        AC_PATH_PROG(SYSTEM_UCPP, ucpp)
7635    else
7636        AC_MSG_RESULT([internal])
7637        BUILD_TYPE="$BUILD_TYPE UCPP"
7638    fi
7639fi
7640AC_SUBST(SYSTEM_UCPP)
7641
7642dnl ===================================================================
7643dnl Check for epm (not needed for Windows)
7644dnl ===================================================================
7645AC_MSG_CHECKING([whether to enable EPM for packing])
7646if test "$enable_epm" = "yes"; then
7647    AC_MSG_RESULT([yes])
7648    if test "$_os" != "WINNT"; then
7649        if test $_os = Darwin; then
7650            EPM=internal
7651        elif test -n "$with_epm"; then
7652            EPM=$with_epm
7653        else
7654            AC_PATH_PROG(EPM, epm, no)
7655        fi
7656        if test "$EPM" = "no" -o "$EPM" = "internal"; then
7657            AC_MSG_NOTICE([EPM will be built.])
7658            BUILD_TYPE="$BUILD_TYPE EPM"
7659            EPM=${WORKDIR}/UnpackedTarball/epm/epm
7660        else
7661            # Gentoo has some epm which is something different...
7662            AC_MSG_CHECKING([whether the found epm is the right epm])
7663            if $EPM | grep "ESP Package Manager" >/dev/null 2>/dev/null; then
7664                AC_MSG_RESULT([yes])
7665            else
7666                AC_MSG_ERROR([no. Install ESP Package Manager (http://www.msweet.org/projects.php?Z2) and/or specify the path to the right epm])
7667            fi
7668            AC_MSG_CHECKING([epm version])
7669            EPM_VERSION=`$EPM | grep 'ESP Package Manager' | cut -d' ' -f4 | $SED -e s/v//`
7670            if test "`echo $EPM_VERSION | cut -d'.' -f1`" -gt "3" || \
7671               test "`echo $EPM_VERSION | cut -d'.' -f1`" -eq "3" -a "`echo $EPM_VERSION | cut -d'.' -f2`" -ge "7"; then
7672                AC_MSG_RESULT([OK, >= 3.7])
7673            else
7674                AC_MSG_RESULT([too old. epm >= 3.7 is required.])
7675                AC_MSG_ERROR([Install ESP Package Manager (http://www.msweet.org/projects.php?Z2) and/or specify the path to the right epm])
7676            fi
7677        fi
7678    fi
7679
7680    if echo "$PKGFORMAT" | $EGREP rpm 2>&1 >/dev/null; then
7681        AC_MSG_CHECKING([for rpm])
7682        for a in "$RPM" rpmbuild rpm; do
7683            $a --usage >/dev/null 2> /dev/null
7684            if test $? -eq 0; then
7685                RPM=$a
7686                break
7687            else
7688                $a --version >/dev/null 2> /dev/null
7689                if test $? -eq 0; then
7690                    RPM=$a
7691                    break
7692                fi
7693            fi
7694        done
7695        if test -z "$RPM"; then
7696            AC_MSG_ERROR([not found])
7697        elif "$RPM" --help 2>&1 | $EGREP buildroot >/dev/null; then
7698            RPM_PATH=`which $RPM`
7699            AC_MSG_RESULT([$RPM_PATH])
7700            SCPDEFS="$SCPDEFS -DWITH_RPM"
7701        else
7702            AC_MSG_ERROR([cannot build packages. Try installing rpmbuild.])
7703        fi
7704    fi
7705    if echo "$PKGFORMAT" | $EGREP deb 2>&1 >/dev/null; then
7706        AC_PATH_PROG(DPKG, dpkg, no)
7707        if test "$DPKG" = "no"; then
7708            AC_MSG_ERROR([dpkg needed for deb creation. Install dpkg.])
7709        fi
7710    fi
7711    if echo "$PKGFORMAT" | $EGREP rpm 2>&1 >/dev/null || \
7712       echo "$PKGFORMAT" | $EGREP pkg 2>&1 >/dev/null; then
7713        if test "$with_epm" = "no" -a "$_os" != "Darwin"; then
7714            if test "`echo $EPM_VERSION | cut -d'.' -f1`" -lt "4"; then
7715                AC_MSG_CHECKING([whether epm is patched for LibreOffice's needs])
7716                if grep "Patched for .*Office" $EPM >/dev/null 2>/dev/null; then
7717                    AC_MSG_RESULT([yes])
7718                else
7719                    AC_MSG_RESULT([no])
7720                    if echo "$PKGFORMAT" | $GREP -q rpm; then
7721                        _pt="rpm"
7722                        AC_MSG_WARN([the rpms will need to be installed with --nodeps])
7723                        add_warning "the rpms will need to be installed with --nodeps"
7724                    else
7725                        _pt="pkg"
7726                    fi
7727                    AC_MSG_WARN([the ${_pt}s will not be relocatable])
7728                    add_warning "the ${_pt}s will not be relocatable"
7729                    AC_MSG_WARN([if you want to make sure installation without --nodeps and
7730                                 relocation will work, you need to patch your epm with the
7731                                 patch in epm/epm-3.7.patch or build with
7732                                 --with-epm=internal which will build a suitable epm])
7733                fi
7734            fi
7735        fi
7736    fi
7737    if echo "$PKGFORMAT" | $EGREP pkg 2>&1 >/dev/null; then
7738        AC_PATH_PROG(PKGMK, pkgmk, no)
7739        if test "$PKGMK" = "no"; then
7740            AC_MSG_ERROR([pkgmk needed for Solaris pkg creation. Install it.])
7741        fi
7742    fi
7743    AC_SUBST(RPM)
7744    AC_SUBST(DPKG)
7745    AC_SUBST(PKGMK)
7746else
7747    for i in $PKGFORMAT; do
7748        case "$i" in
7749        aix | bsd | deb | pkg | rpm | native | portable)
7750            AC_MSG_ERROR(
7751                [--with-package-format='$PKGFORMAT' requires --enable-epm])
7752            ;;
7753        esac
7754    done
7755    AC_MSG_RESULT([no])
7756    EPM=NO
7757fi
7758AC_SUBST(EPM)
7759
7760ENABLE_LWP=
7761if test "$enable_lotuswordpro" = "yes"; then
7762    ENABLE_LWP="TRUE"
7763fi
7764AC_SUBST(ENABLE_LWP)
7765
7766dnl ===================================================================
7767dnl Check for building ODK
7768dnl ===================================================================
7769if test "$enable_odk" = no; then
7770    unset DOXYGEN
7771else
7772    if test "$with_doxygen" = no; then
7773        AC_MSG_CHECKING([for doxygen])
7774        unset DOXYGEN
7775        AC_MSG_RESULT([no])
7776    else
7777        if test "$with_doxygen" = yes; then
7778            AC_PATH_PROG([DOXYGEN], [doxygen])
7779            if test -z "$DOXYGEN"; then
7780                AC_MSG_ERROR([doxygen not found in \$PATH; specify its pathname via --with-doxygen=..., or disable its use via --without-doxygen])
7781            fi
7782            if $DOXYGEN -g - | grep -q "HAVE_DOT *= *YES"; then
7783                if ! dot -V 2>/dev/null; then
7784                    AC_MSG_ERROR([dot not found in \$PATH but doxygen defaults to HAVE_DOT=YES; install graphviz or disable its use via --without-doxygen])
7785                fi
7786            fi
7787        else
7788            AC_MSG_CHECKING([for doxygen])
7789            DOXYGEN=$with_doxygen
7790            AC_MSG_RESULT([$DOXYGEN])
7791        fi
7792        if test -n "$DOXYGEN"; then
7793            DOXYGEN_VERSION=`$DOXYGEN --version 2>/dev/null`
7794            DOXYGEN_NUMVERSION=`echo $DOXYGEN_VERSION | $AWK -F. '{ print \$1*10000 + \$2*100 + \$3 }'`
7795            if ! test "$DOXYGEN_NUMVERSION" -ge "10804" ; then
7796                AC_MSG_ERROR([found doxygen is too old; need at least version 1.8.4 or specify --without-doxygen])
7797            fi
7798        fi
7799    fi
7800fi
7801AC_SUBST([DOXYGEN])
7802
7803AC_MSG_CHECKING([whether to build the ODK])
7804if test "$enable_odk" = "" -o "$enable_odk" != "no"; then
7805    AC_MSG_RESULT([yes])
7806
7807    if test "$with_java" != "no"; then
7808        AC_MSG_CHECKING([whether to build unowinreg.dll])
7809        if test "$_os" = "WINNT" -a "$enable_build_unowinreg" = ""; then
7810            # build on Win by default
7811            enable_build_unowinreg=yes
7812        fi
7813        if test "$enable_build_unowinreg" = "" -o "$enable_build_unowinreg" = "no"; then
7814            AC_MSG_RESULT([no])
7815            BUILD_UNOWINREG=
7816        else
7817            AC_MSG_RESULT([yes])
7818            BUILD_UNOWINREG=TRUE
7819        fi
7820        if test "$_os" != "WINNT" -a "$BUILD_UNOWINREG" = "TRUE"; then
7821            if test -z "$with_mingw_cross_compiler"; then
7822                dnl Guess...
7823                AC_CHECK_PROGS(MINGWCXX,i386-mingw32msvc-g++ i586-pc-mingw32-g++ i686-pc-mingw32-g++ i686-w64-mingw32-g++,false)
7824            elif test -x "$with_mingw_cross_compiler"; then
7825                 MINGWCXX="$with_mingw_cross_compiler"
7826            else
7827                AC_CHECK_TOOL(MINGWCXX, "$with_mingw_cross_compiler", false)
7828            fi
7829
7830            if test "$MINGWCXX" = "false"; then
7831                AC_MSG_ERROR([MinGW32 C++ cross-compiler not found.])
7832            fi
7833
7834            mingwstrip_test="`echo $MINGWCXX | $SED -e s/g++/strip/`"
7835            if test -x "$mingwstrip_test"; then
7836                MINGWSTRIP="$mingwstrip_test"
7837            else
7838                AC_CHECK_TOOL(MINGWSTRIP, "$mingwstrip_test", false)
7839            fi
7840
7841            if test "$MINGWSTRIP" = "false"; then
7842                AC_MSG_ERROR(MinGW32 binutils not found.)
7843            fi
7844        fi
7845    fi
7846    BUILD_TYPE="$BUILD_TYPE ODK"
7847else
7848    AC_MSG_RESULT([no])
7849    BUILD_UNOWINREG=
7850fi
7851AC_SUBST(BUILD_UNOWINREG)
7852AC_SUBST(MINGWCXX)
7853AC_SUBST(MINGWSTRIP)
7854
7855dnl ===================================================================
7856dnl Check for system zlib
7857dnl ===================================================================
7858if test "$with_system_zlib" = "auto"; then
7859    case "$_os" in
7860    WINNT)
7861        with_system_zlib="$with_system_libs"
7862        ;;
7863    *)
7864        if test "$enable_fuzzers" != "yes"; then
7865            with_system_zlib=yes
7866        else
7867            with_system_zlib=no
7868        fi
7869        ;;
7870    esac
7871fi
7872
7873dnl we want to use libo_CHECK_SYSTEM_MODULE here too, but macOS is too stupid
7874dnl and has no pkg-config for it at least on some tinderboxes,
7875dnl so leaving that out for now
7876dnl libo_CHECK_SYSTEM_MODULE([zlib],[ZLIB],[zlib])
7877AC_MSG_CHECKING([which zlib to use])
7878if test "$with_system_zlib" = "yes"; then
7879    AC_MSG_RESULT([external])
7880    SYSTEM_ZLIB=TRUE
7881    AC_CHECK_HEADER(zlib.h, [],
7882        [AC_MSG_ERROR(zlib.h not found. install zlib)], [])
7883    AC_CHECK_LIB(z, deflate, [ ZLIB_LIBS=-lz ],
7884        [AC_MSG_ERROR(zlib not found or functional)], [])
7885else
7886    AC_MSG_RESULT([internal])
7887    SYSTEM_ZLIB=
7888    BUILD_TYPE="$BUILD_TYPE ZLIB"
7889    ZLIB_CFLAGS="-I${WORKDIR}/UnpackedTarball/zlib"
7890    ZLIB_LIBS="-L${WORKDIR}/LinkTarget/StaticLibrary -lzlib"
7891fi
7892AC_SUBST(ZLIB_CFLAGS)
7893AC_SUBST(ZLIB_LIBS)
7894AC_SUBST(SYSTEM_ZLIB)
7895
7896dnl ===================================================================
7897dnl Check for system jpeg
7898dnl ===================================================================
7899AC_MSG_CHECKING([which libjpeg to use])
7900if test "$with_system_jpeg" = "yes"; then
7901    AC_MSG_RESULT([external])
7902    SYSTEM_LIBJPEG=TRUE
7903    AC_CHECK_HEADER(jpeglib.h, [ LIBJPEG_CFLAGS= ],
7904        [AC_MSG_ERROR(jpeg.h not found. install libjpeg)], [])
7905    AC_CHECK_LIB(jpeg, jpeg_resync_to_restart, [ LIBJPEG_LIBS="-ljpeg" ],
7906        [AC_MSG_ERROR(jpeg library not found or functional)], [])
7907else
7908    SYSTEM_LIBJPEG=
7909    AC_MSG_RESULT([internal, libjpeg-turbo])
7910    BUILD_TYPE="$BUILD_TYPE LIBJPEG_TURBO"
7911    LIBJPEG_CFLAGS="-I${WORKDIR}/UnpackedTarball/libjpeg-turbo"
7912    if test "$COM" = "MSC"; then
7913        LIBJPEG_LIBS="${WORKDIR}/UnpackedTarball/libjpeg-turbo/.libs/libjpeg.lib"
7914    else
7915        LIBJPEG_LIBS="-L${WORKDIR}/UnpackedTarball/libjpeg-turbo/.libs -ljpeg"
7916    fi
7917
7918    case "$host_cpu" in
7919    x86_64 | amd64 | i*86 | x86 | ia32)
7920        AC_CHECK_PROGS(NASM, [nasm nasmw yasm])
7921        if test -z "$NASM" -a "$build_os" = "cygwin"; then
7922            if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/nasm"; then
7923                NASM="$LODE_HOME/opt/bin/nasm"
7924            elif test -x "/opt/lo/bin/nasm"; then
7925                NASM="/opt/lo/bin/nasm"
7926            fi
7927        fi
7928
7929        if test -n "$NASM"; then
7930            AC_MSG_CHECKING([for object file format of host system])
7931            case "$host_os" in
7932              cygwin* | mingw* | pw32* | interix*)
7933                case "$host_cpu" in
7934                  x86_64)
7935                    objfmt='Win64-COFF'
7936                    ;;
7937                  *)
7938                    objfmt='Win32-COFF'
7939                    ;;
7940                esac
7941              ;;
7942              msdosdjgpp* | go32*)
7943                objfmt='COFF'
7944              ;;
7945              os2-emx*)			# not tested
7946                objfmt='MSOMF'		# obj
7947              ;;
7948              linux*coff* | linux*oldld*)
7949                objfmt='COFF'		# ???
7950              ;;
7951              linux*aout*)
7952                objfmt='a.out'
7953              ;;
7954              linux*)
7955                case "$host_cpu" in
7956                  x86_64)
7957                    objfmt='ELF64'
7958                    ;;
7959                  *)
7960                    objfmt='ELF'
7961                    ;;
7962                esac
7963              ;;
7964              kfreebsd* | freebsd* | netbsd* | openbsd*)
7965                if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
7966                  objfmt='BSD-a.out'
7967                else
7968                  case "$host_cpu" in
7969                    x86_64 | amd64)
7970                      objfmt='ELF64'
7971                      ;;
7972                    *)
7973                      objfmt='ELF'
7974                      ;;
7975                  esac
7976                fi
7977              ;;
7978              solaris* | sunos* | sysv* | sco*)
7979                case "$host_cpu" in
7980                  x86_64)
7981                    objfmt='ELF64'
7982                    ;;
7983                  *)
7984                    objfmt='ELF'
7985                    ;;
7986                esac
7987              ;;
7988              darwin* | rhapsody* | nextstep* | openstep* | macos*)
7989                case "$host_cpu" in
7990                  x86_64)
7991                    objfmt='Mach-O64'
7992                    ;;
7993                  *)
7994                    objfmt='Mach-O'
7995                    ;;
7996                esac
7997              ;;
7998              *)
7999                objfmt='ELF ?'
8000              ;;
8001            esac
8002
8003            AC_MSG_RESULT([$objfmt])
8004            if test "$objfmt" = 'ELF ?'; then
8005              objfmt='ELF'
8006              AC_MSG_WARN([unexpected host system. assumed that the format is $objfmt.])
8007            fi
8008
8009            AC_MSG_CHECKING([for object file format specifier (NAFLAGS) ])
8010            case "$objfmt" in
8011              MSOMF)      NAFLAGS='-fobj -DOBJ32';;
8012              Win32-COFF) NAFLAGS='-fwin32 -DWIN32';;
8013              Win64-COFF) NAFLAGS='-fwin64 -DWIN64 -D__x86_64__';;
8014              COFF)       NAFLAGS='-fcoff -DCOFF';;
8015              a.out)      NAFLAGS='-faout -DAOUT';;
8016              BSD-a.out)  NAFLAGS='-faoutb -DAOUT';;
8017              ELF)        NAFLAGS='-felf -DELF';;
8018              ELF64)      NAFLAGS='-felf64 -DELF -D__x86_64__';;
8019              RDF)        NAFLAGS='-frdf -DRDF';;
8020              Mach-O)     NAFLAGS='-fmacho -DMACHO';;
8021              Mach-O64)   NAFLAGS='-fmacho64 -DMACHO -D__x86_64__';;
8022            esac
8023            AC_MSG_RESULT([$NAFLAGS])
8024
8025            AC_MSG_CHECKING([whether the assembler ($NASM $NAFLAGS) works])
8026            cat > conftest.asm << EOF
8027            [%line __oline__ "configure"
8028                    section .text
8029                    global  _main,main
8030            _main:
8031            main:   xor     eax,eax
8032                    ret
8033            ]
8034EOF
8035            try_nasm='$NASM $NAFLAGS -o conftest.o conftest.asm'
8036            if AC_TRY_EVAL(try_nasm) && test -s conftest.o; then
8037              AC_MSG_RESULT(yes)
8038            else
8039              echo "configure: failed program was:" >&AC_FD_CC
8040              cat conftest.asm >&AC_FD_CC
8041              rm -rf conftest*
8042              AC_MSG_RESULT(no)
8043              AC_MSG_WARN([installation or configuration problem: assembler cannot create object files.])
8044              NASM=""
8045            fi
8046
8047        fi
8048
8049        if test -z "$NASM"; then
8050cat << _EOS
8051****************************************************************************
8052You need yasm or nasm (Netwide Assembler) to build the internal jpeg library optimally.
8053To get one please:
8054
8055_EOS
8056            if test "$build_os" = "cygwin"; then
8057cat << _EOS
8058install a pre-compiled binary for Win32
8059
8060mkdir -p /opt/lo/bin
8061cd /opt/lo/bin
8062wget https://dev-www.libreoffice.org/bin/cygwin/nasm.exe
8063chmod +x nasm
8064
8065or get and install one from http://www.nasm.us/
8066
8067Then re-run autogen.sh
8068
8069Note: autogen.sh will try to use /opt/lo/bin/nasm if the environment variable NASM is not already defined.
8070Alternatively, you can install the 'new' nasm where ever you want and make sure that \`which nasm\` finds it.
8071
8072_EOS
8073            else
8074cat << _EOS
8075consult https://github.com/libjpeg-turbo/libjpeg-turbo/blob/master/BUILDING.md
8076
8077_EOS
8078            fi
8079            AC_MSG_WARN([no suitable nasm (Netwide Assembler) found])
8080            add_warning "no suitable nasm (Netwide Assembler) found for internal libjpeg-turbo"
8081        fi
8082      ;;
8083    esac
8084fi
8085
8086AC_SUBST(NASM)
8087AC_SUBST(LIBJPEG_CFLAGS)
8088AC_SUBST(LIBJPEG_LIBS)
8089AC_SUBST(SYSTEM_LIBJPEG)
8090
8091dnl ===================================================================
8092dnl Check for system clucene
8093dnl ===================================================================
8094dnl we should rather be using
8095dnl libo_CHECK_SYSTEM_MODULE([clucence],[CLUCENE],[liblucence-core]) here
8096dnl but the contribs-lib check seems tricky
8097AC_MSG_CHECKING([which clucene to use])
8098if test "$with_system_clucene" = "yes"; then
8099    AC_MSG_RESULT([external])
8100    SYSTEM_CLUCENE=TRUE
8101    PKG_CHECK_MODULES(CLUCENE, libclucene-core)
8102    CLUCENE_CFLAGS=[$(printf '%s' "$CLUCENE_CFLAGS" | sed -e 's@-I[^ ]*/CLucene/ext@@' -e "s/-I/${ISYSTEM?}/g")]
8103    FilterLibs "${CLUCENE_LIBS}"
8104    CLUCENE_LIBS="${filteredlibs}"
8105    AC_LANG_PUSH([C++])
8106    save_CXXFLAGS=$CXXFLAGS
8107    save_CPPFLAGS=$CPPFLAGS
8108    CXXFLAGS="$CXXFLAGS $CLUCENE_CFLAGS"
8109    CPPFLAGS="$CPPFLAGS $CLUCENE_CFLAGS"
8110    dnl http://sourceforge.net/tracker/index.php?func=detail&aid=3392466&group_id=80013&atid=558446
8111    dnl https://bugzilla.redhat.com/show_bug.cgi?id=794795
8112    AC_CHECK_HEADER([CLucene/analysis/cjk/CJKAnalyzer.h], [],
8113                 [AC_MSG_ERROR([Your version of libclucene has contribs-lib missing.])], [#include <CLucene.h>])
8114    CXXFLAGS=$save_CXXFLAGS
8115    CPPFLAGS=$save_CPPFLAGS
8116    AC_LANG_POP([C++])
8117
8118    CLUCENE_LIBS="$CLUCENE_LIBS -lclucene-contribs-lib"
8119else
8120    AC_MSG_RESULT([internal])
8121    SYSTEM_CLUCENE=
8122    BUILD_TYPE="$BUILD_TYPE CLUCENE"
8123fi
8124AC_SUBST(SYSTEM_CLUCENE)
8125AC_SUBST(CLUCENE_CFLAGS)
8126AC_SUBST(CLUCENE_LIBS)
8127
8128dnl ===================================================================
8129dnl Check for system expat
8130dnl ===================================================================
8131libo_CHECK_SYSTEM_MODULE([expat], [EXPAT], [expat])
8132
8133dnl ===================================================================
8134dnl Check for system xmlsec
8135dnl ===================================================================
8136libo_CHECK_SYSTEM_MODULE([xmlsec], [XMLSEC], [xmlsec1-nss >= 1.2.24])
8137
8138AC_MSG_CHECKING([whether to enable Embedded OpenType support])
8139if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_eot" = "yes"; then
8140    ENABLE_EOT="TRUE"
8141    AC_DEFINE([ENABLE_EOT])
8142    AC_MSG_RESULT([yes])
8143
8144    libo_CHECK_SYSTEM_MODULE([libeot],[LIBEOT],[libeot >= 0.01])
8145else
8146    ENABLE_EOT=
8147    AC_MSG_RESULT([no])
8148fi
8149AC_SUBST([ENABLE_EOT])
8150
8151dnl ===================================================================
8152dnl Check for DLP libs
8153dnl ===================================================================
8154AS_IF([test "$COM" = "MSC"],
8155      [librevenge_libdir="${WORKDIR}/LinkTarget/Library"],
8156      [librevenge_libdir="${WORKDIR}/UnpackedTarball/librevenge/src/lib/.libs"]
8157)
8158libo_CHECK_SYSTEM_MODULE([librevenge],[REVENGE],[librevenge-0.0 >= 0.0.1],["-I${WORKDIR}/UnpackedTarball/librevenge/inc"],["-L${librevenge_libdir} -lrevenge-0.0"])
8159
8160libo_CHECK_SYSTEM_MODULE([libodfgen],[ODFGEN],[libodfgen-0.1])
8161
8162libo_CHECK_SYSTEM_MODULE([libepubgen],[EPUBGEN],[libepubgen-0.1])
8163
8164AS_IF([test "$COM" = "MSC"],
8165      [libwpd_libdir="${WORKDIR}/LinkTarget/Library"],
8166      [libwpd_libdir="${WORKDIR}/UnpackedTarball/libwpd/src/lib/.libs"]
8167)
8168libo_CHECK_SYSTEM_MODULE([libwpd],[WPD],[libwpd-0.10],["-I${WORKDIR}/UnpackedTarball/libwpd/inc"],["-L${libwpd_libdir} -lwpd-0.10"])
8169
8170libo_CHECK_SYSTEM_MODULE([libwpg],[WPG],[libwpg-0.3])
8171
8172libo_CHECK_SYSTEM_MODULE([libwps],[WPS],[libwps-0.4])
8173libo_PKG_VERSION([WPS], [libwps-0.4], [0.4.10])
8174
8175libo_CHECK_SYSTEM_MODULE([libvisio],[VISIO],[libvisio-0.1])
8176
8177libo_CHECK_SYSTEM_MODULE([libcdr],[CDR],[libcdr-0.1])
8178
8179libo_CHECK_SYSTEM_MODULE([libmspub],[MSPUB],[libmspub-0.1])
8180
8181libo_CHECK_SYSTEM_MODULE([libmwaw],[MWAW],[libmwaw-0.3 >= 0.3.1])
8182libo_PKG_VERSION([MWAW], [libmwaw-0.3], [0.3.15])
8183
8184libo_CHECK_SYSTEM_MODULE([libetonyek],[ETONYEK],[libetonyek-0.1])
8185libo_PKG_VERSION([ETONYEK], [libetonyek-0.1], [0.1.8])
8186
8187libo_CHECK_SYSTEM_MODULE([libfreehand],[FREEHAND],[libfreehand-0.1])
8188
8189libo_CHECK_SYSTEM_MODULE([libebook],[EBOOK],[libe-book-0.1])
8190libo_PKG_VERSION([EBOOK], [libe-book-0.1], [0.1.2])
8191
8192libo_CHECK_SYSTEM_MODULE([libabw],[ABW],[libabw-0.1])
8193
8194libo_CHECK_SYSTEM_MODULE([libpagemaker],[PAGEMAKER],[libpagemaker-0.0])
8195
8196libo_CHECK_SYSTEM_MODULE([libqxp],[QXP],[libqxp-0.0])
8197
8198libo_CHECK_SYSTEM_MODULE([libzmf],[ZMF],[libzmf-0.0])
8199
8200libo_CHECK_SYSTEM_MODULE([libstaroffice],[STAROFFICE],[libstaroffice-0.0])
8201libo_PKG_VERSION([STAROFFICE], [libstaroffice-0.0], [0.0.6])
8202
8203dnl ===================================================================
8204dnl Check for system lcms2
8205dnl ===================================================================
8206if test "$with_system_lcms2" != "yes"; then
8207    SYSTEM_LCMS2=
8208fi
8209libo_CHECK_SYSTEM_MODULE([lcms2],[LCMS2],[lcms2],["-I${WORKDIR}/UnpackedTarball/lcms2/include"],["-L${WORKDIR}/UnpackedTarball/lcms2/src/.libs -llcms2"])
8210if test "$GCC" = "yes"; then
8211    LCMS2_CFLAGS="${LCMS2_CFLAGS} -Wno-long-long"
8212fi
8213if test "$COM" = "MSC"; then # override the above
8214    LCMS2_LIBS=${WORKDIR}/UnpackedTarball/lcms2/bin/lcms2.lib
8215fi
8216
8217dnl ===================================================================
8218dnl Check for system cppunit
8219dnl ===================================================================
8220if test "$_os" != "Android" ; then
8221    libo_CHECK_SYSTEM_MODULE([cppunit],[CPPUNIT],[cppunit >= 1.14.0])
8222fi
8223
8224dnl ===================================================================
8225dnl Check whether freetype is available
8226dnl ===================================================================
8227if test  "$test_freetype" = "yes"; then
8228    AC_MSG_CHECKING([whether freetype is available])
8229    # FreeType has 3 different kinds of versions
8230    # * release, like 2.4.10
8231    # * libtool, like 13.0.7 (this what pkg-config returns)
8232    # * soname
8233    # FreeType's docs/VERSION.DLL provides a table mapping between the three
8234    #
8235    # 9.9.3 is 2.2.0
8236    PKG_CHECK_MODULES(FREETYPE, freetype2 >= 9.9.3)
8237    FREETYPE_CFLAGS=$(printf '%s' "$FREETYPE_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
8238    FilterLibs "${FREETYPE_LIBS}"
8239    FREETYPE_LIBS="${filteredlibs}"
8240    SYSTEM_FREETYPE=TRUE
8241else
8242    FREETYPE_CFLAGS="${ISYSTEM}${WORKDIR}/UnpackedTarball/freetype/include"
8243    FREETYPE_LIBS="-L${WORKDIR}/UnpackedTarball/freetype/instdir/lib -lfreetype"
8244fi
8245AC_SUBST(FREETYPE_CFLAGS)
8246AC_SUBST(FREETYPE_LIBS)
8247AC_SUBST([SYSTEM_FREETYPE])
8248
8249# ===================================================================
8250# Check for system libxslt
8251# to prevent incompatibilities between internal libxml2 and external libxslt,
8252# or vice versa, use with_system_libxml here
8253# ===================================================================
8254if test "$with_system_libxml" = "auto"; then
8255    case "$_os" in
8256    WINNT|iOS|Android)
8257        with_system_libxml="$with_system_libs"
8258        ;;
8259    *)
8260        if test "$enable_fuzzers" != "yes"; then
8261            with_system_libxml=yes
8262        else
8263            with_system_libxml=no
8264        fi
8265        ;;
8266    esac
8267fi
8268
8269AC_MSG_CHECKING([which libxslt to use])
8270if test "$with_system_libxml" = "yes"; then
8271    AC_MSG_RESULT([external])
8272    SYSTEM_LIBXSLT=TRUE
8273    if test "$_os" = "Darwin"; then
8274        dnl make sure to use SDK path
8275        LIBXSLT_CFLAGS="-I$MACOSX_SDK_PATH/usr/include/libxml2"
8276        LIBEXSLT_CFLAGS="$LIBXSLT_CFLAGS"
8277        dnl omit -L/usr/lib
8278        LIBXSLT_LIBS="-lxslt -lxml2 -lz -lpthread -liconv -lm"
8279        LIBEXSLT_LIBS="-lexslt $LIBXSLT_LIBS"
8280    else
8281        PKG_CHECK_MODULES(LIBXSLT, libxslt)
8282        LIBXSLT_CFLAGS=$(printf '%s' "$LIBXSLT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
8283        FilterLibs "${LIBXSLT_LIBS}"
8284        LIBXSLT_LIBS="${filteredlibs}"
8285        PKG_CHECK_MODULES(LIBEXSLT, libexslt)
8286        LIBEXSLT_CFLAGS=$(printf '%s' "$LIBEXSLT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
8287        FilterLibs "${LIBEXSLT_LIBS}"
8288        LIBEXSLT_LIBS=$(printf '%s' "${filteredlibs}" | sed -e "s/-lgpg-error//"  -e "s/-lgcrypt//")
8289    fi
8290
8291    dnl Check for xsltproc
8292    AC_PATH_PROG(XSLTPROC, xsltproc, no)
8293    if test "$XSLTPROC" = "no"; then
8294        AC_MSG_ERROR([xsltproc is required])
8295    fi
8296else
8297    AC_MSG_RESULT([internal])
8298    SYSTEM_LIBXSLT=
8299    BUILD_TYPE="$BUILD_TYPE LIBXSLT"
8300
8301    if test "$cross_compiling" = "yes"; then
8302        AC_PATH_PROG(XSLTPROC, xsltproc, no)
8303        if test "$XSLTPROC" = "no"; then
8304            AC_MSG_ERROR([xsltproc is required])
8305        fi
8306    fi
8307fi
8308AC_SUBST(SYSTEM_LIBXSLT)
8309if test -z "$SYSTEM_LIBXSLT_FOR_BUILD"; then
8310    SYSTEM_LIBXSLT_FOR_BUILD="$SYSTEM_LIBXSLT"
8311fi
8312AC_SUBST(SYSTEM_LIBXSLT_FOR_BUILD)
8313
8314AC_SUBST(LIBEXSLT_CFLAGS)
8315AC_SUBST(LIBEXSLT_LIBS)
8316AC_SUBST(LIBXSLT_CFLAGS)
8317AC_SUBST(LIBXSLT_LIBS)
8318AC_SUBST(XSLTPROC)
8319
8320# ===================================================================
8321# Check for system libxml
8322# ===================================================================
8323AC_MSG_CHECKING([which libxml to use])
8324if test "$with_system_libxml" = "yes"; then
8325    AC_MSG_RESULT([external])
8326    SYSTEM_LIBXML=TRUE
8327    if test "$_os" = "Darwin"; then
8328        dnl make sure to use SDK path
8329        LIBXML_CFLAGS="-I$MACOSX_SDK_PATH/usr/include/libxml2"
8330        dnl omit -L/usr/lib
8331        LIBXML_LIBS="-lxml2 -lz -lpthread -liconv -lm"
8332    elif test $_os = iOS; then
8333        dnl make sure to use SDK path
8334        usr=`echo '#include <stdlib.h>' | $CC -E -MD - | grep usr/include/stdlib.h | head -1 | sed -e 's,# 1 ",,' -e 's,/usr/include/.*,/usr,'`
8335        LIBXML_CFLAGS="-I$usr/include/libxml2"
8336        LIBXML_LIBS="-L$usr/lib -lxml2 -liconv"
8337    else
8338        PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= 2.0)
8339        LIBXML_CFLAGS=$(printf '%s' "$LIBXML_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
8340        FilterLibs "${LIBXML_LIBS}"
8341        LIBXML_LIBS="${filteredlibs}"
8342    fi
8343
8344    dnl Check for xmllint
8345    AC_PATH_PROG(XMLLINT, xmllint, no)
8346    if test "$XMLLINT" = "no"; then
8347        AC_MSG_ERROR([xmllint is required])
8348    fi
8349else
8350    AC_MSG_RESULT([internal])
8351    SYSTEM_LIBXML=
8352    LIBXML_CFLAGS="-I${WORKDIR}/UnpackedTarball/libxml2/include"
8353    if test "$COM" = "MSC"; then
8354        LIBXML_CFLAGS="${LIBXML_CFLAGS} -I${WORKDIR}/UnpackedTarball/icu/source/i18n -I${WORKDIR}/UnpackedTarball/icu/source/common"
8355    fi
8356    if test "$COM" = "MSC"; then
8357        LIBXML_LIBS="${WORKDIR}/UnpackedTarball/libxml2/win32/bin.msvc/libxml2.lib"
8358    else
8359        LIBXML_LIBS="-L${WORKDIR}/UnpackedTarball/libxml2/.libs -lxml2"
8360    fi
8361    BUILD_TYPE="$BUILD_TYPE LIBXML2"
8362fi
8363AC_SUBST(SYSTEM_LIBXML)
8364if test -z "$SYSTEM_LIBXML_FOR_BUILD"; then
8365    SYSTEM_LIBXML_FOR_BUILD="$SYSTEM_LIBXML"
8366fi
8367AC_SUBST(SYSTEM_LIBXML_FOR_BUILD)
8368AC_SUBST(LIBXML_CFLAGS)
8369AC_SUBST(LIBXML_LIBS)
8370AC_SUBST(XMLLINT)
8371
8372# =====================================================================
8373# Checking for a Python interpreter with version >= 2.7.
8374# Build and runtime requires Python 3 compatible version (>= 2.7).
8375# Optionally user can pass an option to configure, i. e.
8376# ./configure PYTHON=/usr/bin/python
8377# =====================================================================
8378if test "$build_os" != "cygwin" -a "$enable_python" != fully-internal; then
8379    if test -n "$PYTHON"; then
8380        PYTHON_FOR_BUILD=$PYTHON
8381    else
8382        # This allows a lack of system python with no error, we use internal one in that case.
8383        AM_PATH_PYTHON([2.7],, [:])
8384        # Clean PYTHON_VERSION checked below if cross-compiling
8385        PYTHON_VERSION=""
8386        if test "$PYTHON" != ":"; then
8387            PYTHON_FOR_BUILD=$PYTHON
8388        fi
8389    fi
8390fi
8391AC_SUBST(PYTHON_FOR_BUILD)
8392
8393# Checks for Python to use for Pyuno
8394AC_MSG_CHECKING([which Python to use for Pyuno])
8395case "$enable_python" in
8396no|disable)
8397    if test -z $PYTHON_FOR_BUILD; then
8398        # Python is required to build LibreOffice. In theory we could separate the build-time Python
8399        # requirement from the choice whether to include Python stuff in the installer, but why
8400        # bother?
8401        AC_MSG_ERROR([Python is required at build time.])
8402    fi
8403    enable_python=no
8404    AC_MSG_RESULT([none])
8405    ;;
8406""|yes|auto)
8407    if test "$DISABLE_SCRIPTING" = TRUE -a -n "$PYTHON_FOR_BUILD"; then
8408        AC_MSG_RESULT([no, overridden by --disable-scripting])
8409        enable_python=no
8410    elif test $build_os = cygwin; then
8411        dnl When building on Windows we don't attempt to use any installed
8412        dnl "system"  Python.
8413        AC_MSG_RESULT([fully internal])
8414        enable_python=internal
8415    elif test "$cross_compiling" = yes; then
8416        AC_MSG_RESULT([system])
8417        enable_python=system
8418    else
8419        # Unset variables set by the above AM_PATH_PYTHON so that
8420        # we actually do check anew.
8421        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
8422        AM_PATH_PYTHON([3.3],, [:])
8423        if test "$PYTHON" = ":"; then
8424            if test -z "$PYTHON_FOR_BUILD"; then
8425                AC_MSG_RESULT([fully internal])
8426            else
8427                AC_MSG_RESULT([internal])
8428            fi
8429            enable_python=internal
8430        else
8431            AC_MSG_RESULT([system])
8432            enable_python=system
8433        fi
8434    fi
8435    ;;
8436internal)
8437    AC_MSG_RESULT([internal])
8438    ;;
8439fully-internal)
8440    AC_MSG_RESULT([fully internal])
8441    enable_python=internal
8442    ;;
8443system)
8444    AC_MSG_RESULT([system])
8445    if test "$_os" = Darwin; then
8446        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])
8447    fi
8448    ;;
8449*)
8450    AC_MSG_ERROR([Incorrect --enable-python option])
8451    ;;
8452esac
8453
8454if test $enable_python != no; then
8455    BUILD_TYPE="$BUILD_TYPE PYUNO"
8456fi
8457
8458if test $enable_python = system; then
8459    if test -n "$PYTHON_CFLAGS" -a -n "$PYTHON_LIBS"; then
8460        # Fallback: Accept these in the environment, or as set above
8461        # for MacOSX.
8462        :
8463    elif test "$cross_compiling" != yes; then
8464        # Unset variables set by the above AM_PATH_PYTHON so that
8465        # we actually do check anew.
8466        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
8467        # This causes an error if no python command is found
8468        AM_PATH_PYTHON([3.3])
8469        python_include=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('INCLUDEPY'));"`
8470        python_version=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('VERSION'));"`
8471        python_libs=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBS'));"`
8472        python_libdir=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBDIR'));"`
8473        if test -z "$PKG_CONFIG"; then
8474            PYTHON_CFLAGS="-I$python_include"
8475            PYTHON_LIBS="-L$python_libdir -lpython$python_version $python_libs"
8476        elif $PKG_CONFIG --exists python-$python_version-embed; then
8477            PYTHON_CFLAGS="`$PKG_CONFIG --cflags python-$python_version-embed`"
8478            PYTHON_LIBS="`$PKG_CONFIG --libs python-$python_version-embed` $python_libs"
8479        elif $PKG_CONFIG --exists python-$python_version; then
8480            PYTHON_CFLAGS="`$PKG_CONFIG --cflags python-$python_version`"
8481            PYTHON_LIBS="`$PKG_CONFIG --libs python-$python_version` $python_libs"
8482        else
8483            PYTHON_CFLAGS="-I$python_include"
8484            PYTHON_LIBS="-L$python_libdir -lpython$python_version $python_libs"
8485        fi
8486        FilterLibs "${PYTHON_LIBS}"
8487        PYTHON_LIBS="${filteredlibs}"
8488    else
8489        dnl How to find out the cross-compilation Python installation path?
8490        AC_MSG_CHECKING([for python version])
8491        AS_IF([test -n "$PYTHON_VERSION"],
8492              [AC_MSG_RESULT([$PYTHON_VERSION])],
8493              [AC_MSG_RESULT([not found])
8494               AC_MSG_ERROR([no usable python found])])
8495        test -n "$PYTHON_CFLAGS" && break
8496    fi
8497
8498    dnl Check if the headers really work
8499    save_CPPFLAGS="$CPPFLAGS"
8500    CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
8501    AC_CHECK_HEADER(Python.h)
8502    CPPFLAGS="$save_CPPFLAGS"
8503
8504    # let the PYTHON_FOR_BUILD match the same python installation that
8505    # provides PYTHON_CFLAGS/PYTHON_LDFLAGS for pyuno, which should be
8506    # better for PythonTests.
8507    PYTHON_FOR_BUILD=$PYTHON
8508fi
8509
8510if test "$with_lxml" != no; then
8511    if test -z "$PYTHON_FOR_BUILD"; then
8512        case $build_os in
8513            cygwin)
8514                AC_MSG_WARN([No system-provided python lxml, gla11y will only report widget classes and ids])
8515                ;;
8516            *)
8517                if test "$cross_compiling" != yes ; then
8518                    BUILD_TYPE="$BUILD_TYPE LXML"
8519                fi
8520                ;;
8521        esac
8522    else
8523        AC_MSG_CHECKING([for python lxml])
8524        if $PYTHON_FOR_BUILD -c "import lxml.etree as ET" 2> /dev/null ; then
8525            AC_MSG_RESULT([yes])
8526        else
8527            case $build_os in
8528                cygwin)
8529                    AC_MSG_RESULT([no, gla11y will only report widget classes and ids])
8530                    ;;
8531                *)
8532                    if test "$cross_compiling" != yes -a "x$ac_cv_header_Python_h" = "xyes"; then
8533                        BUILD_TYPE="$BUILD_TYPE LXML"
8534                        AC_MSG_RESULT([no, using internal lxml])
8535                    else
8536                        AC_MSG_RESULT([no, and system does not provide python development headers, gla11y will only report widget classes and ids])
8537                    fi
8538                    ;;
8539            esac
8540        fi
8541    fi
8542fi
8543
8544dnl By now enable_python should be "system", "internal" or "no"
8545case $enable_python in
8546system)
8547    SYSTEM_PYTHON=TRUE
8548
8549    if test "x$ac_cv_header_Python_h" != "xyes"; then
8550       AC_MSG_ERROR([Python headers not found. You probably want to set both the PYTHON_CFLAGS and PYTHON_LIBS environment variables.])
8551    fi
8552
8553    AC_LANG_PUSH(C)
8554    CFLAGS="$CFLAGS $PYTHON_CFLAGS"
8555    AC_MSG_CHECKING([for correct python library version])
8556       AC_RUN_IFELSE([AC_LANG_SOURCE([[
8557#include <Python.h>
8558
8559int main(int argc, char **argv) {
8560   if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 7) ||
8561       (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 3)) return 0;
8562   else return 1;
8563}
8564       ]])],[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])])
8565    CFLAGS=$save_CFLAGS
8566    AC_LANG_POP(C)
8567
8568    dnl FIXME Check if the Python library can be linked with, too?
8569    ;;
8570
8571internal)
8572    SYSTEM_PYTHON=
8573    PYTHON_VERSION_MAJOR=3
8574    PYTHON_VERSION_MINOR=5
8575    PYTHON_VERSION=${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.7
8576    if ! grep -q -i python.*${PYTHON_VERSION} ${SRC_ROOT}/download.lst; then
8577        AC_MSG_ERROR([PYTHON_VERSION ${PYTHON_VERSION} but no matching file in download.lst])
8578    fi
8579    AC_DEFINE_UNQUOTED([PYTHON_VERSION_STRING], [L"${PYTHON_VERSION}"])
8580    BUILD_TYPE="$BUILD_TYPE PYTHON"
8581    # Embedded Python dies without Home set
8582    if test "$HOME" = ""; then
8583        export HOME=""
8584    fi
8585    ;;
8586no)
8587    DISABLE_PYTHON=TRUE
8588    SYSTEM_PYTHON=
8589    ;;
8590*)
8591    AC_MSG_ERROR([Internal configure script error, invalid enable_python value "$enable_python"])
8592    ;;
8593esac
8594
8595AC_SUBST(DISABLE_PYTHON)
8596AC_SUBST(SYSTEM_PYTHON)
8597AC_SUBST(PYTHON_CFLAGS)
8598AC_SUBST(PYTHON_LIBS)
8599AC_SUBST(PYTHON_VERSION)
8600AC_SUBST(PYTHON_VERSION_MAJOR)
8601AC_SUBST(PYTHON_VERSION_MINOR)
8602
8603ENABLE_MARIADBC=TRUE
8604if test "$_os" = "Android" -o "$_os" = "iOS" -o "$enable_mpl_subset" = "yes"; then
8605    ENABLE_MARIADBC=
8606fi
8607MARIADBC_MAJOR=1
8608MARIADBC_MINOR=0
8609MARIADBC_MICRO=2
8610if test "$ENABLE_MARIADBC" = "TRUE"; then
8611    BUILD_TYPE="$BUILD_TYPE MARIADBC"
8612fi
8613
8614AC_SUBST(ENABLE_MARIADBC)
8615AC_SUBST(MARIADBC_MAJOR)
8616AC_SUBST(MARIADBC_MINOR)
8617AC_SUBST(MARIADBC_MICRO)
8618
8619if test "$ENABLE_MARIADBC" = "TRUE"; then
8620    dnl ===================================================================
8621    dnl Check for system MariaDB
8622    dnl ===================================================================
8623    AC_MSG_CHECKING([which MariaDB to use])
8624    if test "$with_system_mariadb" = "yes"; then
8625        AC_MSG_RESULT([external])
8626        SYSTEM_MARIADB_CONNECTOR_C=TRUE
8627        #AC_PATH_PROG(MARIADBCONFIG, [mariadb_config])
8628        if test -z "$MARIADBCONFIG"; then
8629            AC_PATH_PROG(MARIADBCONFIG, [mysql_config])
8630            if test -z "$MARIADBCONFIG"; then
8631                AC_MSG_ERROR([mysql_config is missing. Install MySQL client library development package.])
8632                #AC_MSG_ERROR([mariadb_config and mysql_config are missing. Install MariaDB or MySQL client library development package.])
8633            fi
8634        fi
8635        AC_MSG_CHECKING([MariaDB version])
8636        MARIADB_VERSION=`$MARIADBCONFIG --version`
8637        MARIADB_MAJOR=`$MARIADBCONFIG --version | cut -d"." -f1`
8638        if test "$MARIADB_MAJOR" -ge "5"; then
8639            AC_MSG_RESULT([OK])
8640        else
8641            AC_MSG_ERROR([too old, use 5.0.x or later])
8642        fi
8643        AC_MSG_CHECKING([for MariaDB Client library])
8644        MARIADB_CFLAGS=`$MARIADBCONFIG --cflags`
8645        if test "$COM_IS_CLANG" = TRUE; then
8646            MARIADB_CFLAGS=$(printf '%s' "$MARIADB_CFLAGS" | sed -e s/-fstack-protector-strong//)
8647        fi
8648        MARIADB_LIBS=`$MARIADBCONFIG --libs_r`
8649        dnl At least mariadb-5.5.34-3.fc20.x86_64 plus
8650        dnl mariadb-5.5.34-3.fc20.i686 reports 64-bit specific output even under
8651        dnl linux32:
8652        if test "$OS" = LINUX -a "$CPUNAME" = INTEL; then
8653            MARIADB_CFLAGS=$(printf '%s' "$MARIADB_CFLAGS" | sed -e s/-m64//)
8654            MARIADB_LIBS=$(printf '%s' "$MARIADB_LIBS" \
8655                | sed -e 's|/lib64/|/lib/|')
8656        fi
8657        FilterLibs "${MARIADB_LIBS}"
8658        MARIADB_LIBS="${filteredlibs}"
8659        AC_MSG_RESULT([includes '$MARIADB_CFLAGS', libraries '$MARIADB_LIBS'])
8660        AC_MSG_CHECKING([whether to bundle the MySQL/MariaDB client library])
8661        if test "$enable_bundle_mariadb" = "yes"; then
8662            AC_MSG_RESULT([yes])
8663            BUNDLE_MARIADB_CONNECTOR_C=TRUE
8664            LIBMARIADB=lib$(echo "${MARIADB_LIBS}" | sed -e 's/[[[:space:]]]\{1,\}-l\([[^[:space:]]]\{1,\}\)/\
8665\1\
8666/g' -e 's/^-l\([[^[:space:]]]\{1,\}\)[[[:space:]]]*/\
8667\1\
8668/g' | grep -E '(mysqlclient|mariadb)')
8669            if test "$_os" = "Darwin"; then
8670                LIBMARIADB=${LIBMARIADB}.dylib
8671            elif test "$_os" = "WINNT"; then
8672                LIBMARIADB=${LIBMARIADB}.dll
8673            else
8674                LIBMARIADB=${LIBMARIADB}.so
8675            fi
8676            LIBMARIADB_PATH=$($MARIADBCONFIG --variable=pkglibdir)
8677            AC_MSG_CHECKING([for $LIBMARIADB in $LIBMARIADB_PATH])
8678            if test -e "$LIBMARIADB_PATH/$LIBMARIADB"; then
8679                AC_MSG_RESULT([found.])
8680                PathFormat "$LIBMARIADB_PATH"
8681                LIBMARIADB_PATH="$formatted_path"
8682            else
8683                AC_MSG_ERROR([not found.])
8684            fi
8685        else
8686            AC_MSG_RESULT([no])
8687            BUNDLE_MARIADB_CONNECTOR_C=
8688        fi
8689    else
8690        AC_MSG_RESULT([internal])
8691        SYSTEM_MARIADB_CONNECTOR_C=
8692        MARIADB_CFLAGS="-I${WORKDIR}/UnpackedTarball/mariadb-connector-c/include"
8693        MARIADB_LIBS="-L${WORKDIR}/LinkTarget/StaticLibrary -lmariadb-connector-c"
8694        BUILD_TYPE="$BUILD_TYPE MARIADB_CONNECTOR_C"
8695    fi
8696
8697    AC_SUBST(SYSTEM_MARIADB_CONNECTOR_C)
8698    AC_SUBST(MARIADB_CFLAGS)
8699    AC_SUBST(MARIADB_LIBS)
8700    AC_SUBST(LIBMARIADB)
8701    AC_SUBST(LIBMARIADB_PATH)
8702    AC_SUBST(BUNDLE_MARIADB_CONNECTOR_C)
8703fi
8704
8705dnl ===================================================================
8706dnl Check for system hsqldb
8707dnl ===================================================================
8708if test "$with_java" != "no"; then
8709    HSQLDB_USE_JDBC_4_1=
8710    AC_MSG_CHECKING([which hsqldb to use])
8711    if test "$with_system_hsqldb" = "yes"; then
8712        AC_MSG_RESULT([external])
8713        SYSTEM_HSQLDB=TRUE
8714        if test -z $HSQLDB_JAR; then
8715            HSQLDB_JAR=/usr/share/java/hsqldb.jar
8716        fi
8717        if ! test -f $HSQLDB_JAR; then
8718               AC_MSG_ERROR(hsqldb.jar not found.)
8719        fi
8720        AC_MSG_CHECKING([whether hsqldb is 1.8.0.x])
8721        export HSQLDB_JAR
8722        if $PERL -e \
8723           'use Archive::Zip;
8724            my $file = "$ENV{'HSQLDB_JAR'}";
8725            my $zip = Archive::Zip->new( $file );
8726            my $mf = $zip->contents ( "META-INF/MANIFEST.MF" );
8727            if ( $mf =~ m/Specification-Version: 1.8.*/ )
8728            {
8729                push @l, split(/\n/, $mf);
8730                foreach my $line (@l)
8731                {
8732                    if ($line =~ m/Specification-Version:/)
8733                    {
8734                        ($t, $version) = split (/:/,$line);
8735                        $version =~ s/^\s//;
8736                        ($a, $b, $c, $d) = split (/\./,$version);
8737                        if ($c == "0" && $d > "8")
8738                        {
8739                            exit 0;
8740                        }
8741                        else
8742                        {
8743                            exit 1;
8744                        }
8745                    }
8746                }
8747            }
8748            else
8749            {
8750                exit 1;
8751            }'; then
8752            AC_MSG_RESULT([yes])
8753        else
8754            AC_MSG_ERROR([no, you need hsqldb >= 1.8.0.9 but < 1.8.1])
8755        fi
8756    else
8757        AC_MSG_RESULT([internal])
8758        SYSTEM_HSQLDB=
8759        BUILD_TYPE="$BUILD_TYPE HSQLDB"
8760        NEED_ANT=TRUE
8761        AC_MSG_CHECKING([whether hsqldb should be built with JDBC 4.1])
8762        javanumver=`$JAVAINTERPRETER -version 2>&1 | $AWK -v num=true -f $SRC_ROOT/solenv/bin/getcompver.awk`
8763        if expr "$javanumver" '>=' 000100060000 > /dev/null; then
8764            AC_MSG_RESULT([yes])
8765            HSQLDB_USE_JDBC_4_1=TRUE
8766        else
8767            AC_MSG_RESULT([no])
8768        fi
8769    fi
8770    AC_SUBST(SYSTEM_HSQLDB)
8771    AC_SUBST(HSQLDB_JAR)
8772    AC_SUBST([HSQLDB_USE_JDBC_4_1])
8773fi
8774
8775dnl ===================================================================
8776dnl Check for PostgreSQL stuff
8777dnl ===================================================================
8778AC_MSG_CHECKING([whether to build the PostgreSQL SDBC driver])
8779if test "x$enable_postgresql_sdbc" != "xno"; then
8780    AC_MSG_RESULT([yes])
8781    SCPDEFS="$SCPDEFS -DWITH_POSTGRESQL_SDBC"
8782
8783    if test "$with_krb5" = "yes" -a "$enable_openssl" = "no"; then
8784        AC_MSG_ERROR([krb5 needs OpenSSL, but --disable-openssl was given.])
8785    fi
8786    if test "$with_gssapi" = "yes" -a "$enable_openssl" = "no"; then
8787        AC_MSG_ERROR([GSSAPI needs OpenSSL, but --disable-openssl was given.])
8788    fi
8789
8790    postgres_interface=""
8791    if test "$with_system_postgresql" = "yes"; then
8792        postgres_interface="external PostgreSQL"
8793        SYSTEM_POSTGRESQL=TRUE
8794        if test "$_os" = Darwin; then
8795            supp_path=''
8796            for d in /Library/PostgreSQL/9.*/bin /sw/opt/postgresql/9.*/bin /opt/local/lib/postgresql9*/bin; do
8797                pg_supp_path="$P_SEP$d$pg_supp_path"
8798            done
8799        fi
8800        AC_PATH_PROG(PGCONFIG, pg_config, ,$PATH$pg_supp_path)
8801        if test -n "$PGCONFIG"; then
8802            POSTGRESQL_INC=-I$(${PGCONFIG} --includedir)
8803            POSTGRESQL_LIB="-L$(${PGCONFIG} --libdir)"
8804        else
8805            PKG_CHECK_MODULES(POSTGRESQL, libpq, [
8806              POSTGRESQL_INC=$POSTGRESQL_CFLAGS
8807              POSTGRESQL_LIB=$POSTGRESQL_LIBS
8808            ],[
8809              AC_MSG_ERROR([pg_config or 'pkg-config libpq' needed; set PGCONFIG if not in PATH])
8810            ])
8811        fi
8812        FilterLibs "${POSTGRESQL_LIB}"
8813        POSTGRESQL_LIB="${filteredlibs}"
8814    else
8815        # if/when anything else than PostgreSQL uses Kerberos,
8816        # move this out of `test "x$enable_postgresql_sdbc" != "xno"'
8817        WITH_KRB5=
8818        WITH_GSSAPI=
8819        case "$_os" in
8820        Darwin)
8821            # macOS has system MIT Kerberos 5 since 10.4
8822            if test "$with_krb5" != "no"; then
8823                WITH_KRB5=TRUE
8824                save_LIBS=$LIBS
8825                # Not sure whether it makes any sense here to search multiple potential libraries; it is not likely
8826                # that the libraries where these functions are located on macOS will change, is it?
8827                AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
8828                    [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
8829                KRB5_LIBS=$LIBS
8830                LIBS=$save_LIBS
8831                AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
8832                    [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
8833                KRB5_LIBS="$KRB5_LIBS $LIBS"
8834                LIBS=$save_LIBS
8835            fi
8836            if test "$with_gssapi" != "no"; then
8837                WITH_GSSAPI=TRUE
8838                save_LIBS=$LIBS
8839                AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
8840                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
8841                GSSAPI_LIBS=$LIBS
8842                LIBS=$save_LIBS
8843            fi
8844            ;;
8845        WINNT)
8846            if test "$with_krb5" = "yes" -o "$with_gssapi" = "yes"; then
8847                AC_MSG_ERROR([Refusing to enable MIT Kerberos 5 or GSSAPI on Windows.])
8848            fi
8849            ;;
8850        Linux|GNU|*BSD|DragonFly)
8851            if test "$with_krb5" != "no"; then
8852                WITH_KRB5=TRUE
8853                save_LIBS=$LIBS
8854                AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
8855                    [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
8856                KRB5_LIBS=$LIBS
8857                LIBS=$save_LIBS
8858                AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
8859                    [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
8860                KRB5_LIBS="$KRB5_LIBS $LIBS"
8861                LIBS=$save_LIBS
8862            fi
8863            if test "$with_gssapi" != "no"; then
8864                WITH_GSSAPI=TRUE
8865                save_LIBS=$LIBS
8866                AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
8867                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
8868                GSSAPI_LIBS=$LIBS
8869                LIBS=$save_LIBS
8870            fi
8871            ;;
8872        *)
8873            if test "$with_krb5" = "yes"; then
8874                WITH_KRB5=TRUE
8875                save_LIBS=$LIBS
8876                AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
8877                    [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
8878                KRB5_LIBS=$LIBS
8879                LIBS=$save_LIBS
8880                AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
8881                    [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
8882                KRB5_LIBS="$KRB5_LIBS $LIBS"
8883                LIBS=$save_LIBS
8884            fi
8885            if test "$with_gssapi" = "yes"; then
8886                WITH_GSSAPI=TRUE
8887                save_LIBS=$LIBS
8888                AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
8889                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
8890                LIBS=$save_LIBS
8891                GSSAPI_LIBS=$LIBS
8892            fi
8893        esac
8894
8895        if test -n "$with_libpq_path"; then
8896            SYSTEM_POSTGRESQL=TRUE
8897            postgres_interface="external libpq"
8898            POSTGRESQL_LIB="-L${with_libpq_path}/lib/"
8899            POSTGRESQL_INC=-I"${with_libpq_path}/include/"
8900        else
8901            SYSTEM_POSTGRESQL=
8902            postgres_interface="internal"
8903            POSTGRESQL_LIB=""
8904            POSTGRESQL_INC="%OVERRIDE_ME%"
8905            BUILD_TYPE="$BUILD_TYPE POSTGRESQL"
8906        fi
8907    fi
8908
8909    AC_MSG_CHECKING([PostgreSQL C interface])
8910    AC_MSG_RESULT([$postgres_interface])
8911
8912    if test "${SYSTEM_POSTGRESQL}" = "TRUE"; then
8913        AC_MSG_NOTICE([checking system PostgreSQL prerequisites])
8914        save_CFLAGS=$CFLAGS
8915        save_CPPFLAGS=$CPPFLAGS
8916        save_LIBS=$LIBS
8917        CPPFLAGS="${CPPFLAGS} ${POSTGRESQL_INC}"
8918        LIBS="${LIBS} ${POSTGRESQL_LIB}"
8919        AC_CHECK_HEADER([libpq-fe.h], [], [AC_MSG_ERROR([libpq-fe.h is needed])], [])
8920        AC_CHECK_LIB([pq], [PQconnectdbParams], [:],
8921            [AC_MSG_ERROR(libpq not found or too old. Need >= 9.0)], [])
8922        CFLAGS=$save_CFLAGS
8923        CPPFLAGS=$save_CPPFLAGS
8924        LIBS=$save_LIBS
8925    fi
8926    BUILD_POSTGRESQL_SDBC=TRUE
8927else
8928    AC_MSG_RESULT([no])
8929fi
8930AC_SUBST(WITH_KRB5)
8931AC_SUBST(WITH_GSSAPI)
8932AC_SUBST(GSSAPI_LIBS)
8933AC_SUBST(KRB5_LIBS)
8934AC_SUBST(BUILD_POSTGRESQL_SDBC)
8935AC_SUBST(SYSTEM_POSTGRESQL)
8936AC_SUBST(POSTGRESQL_INC)
8937AC_SUBST(POSTGRESQL_LIB)
8938
8939dnl ===================================================================
8940dnl Check for Firebird stuff
8941dnl ===================================================================
8942ENABLE_FIREBIRD_SDBC=
8943if test "$enable_firebird_sdbc" = "yes" ; then
8944    SCPDEFS="$SCPDEFS -DWITH_FIREBIRD_SDBC"
8945
8946    dnl ===================================================================
8947    dnl Check for system Firebird
8948    dnl ===================================================================
8949    AC_MSG_CHECKING([which Firebird to use])
8950    if test "$with_system_firebird" = "yes"; then
8951        AC_MSG_RESULT([external])
8952        SYSTEM_FIREBIRD=TRUE
8953        AC_PATH_PROG(FIREBIRDCONFIG, [fb_config])
8954        if test -z "$FIREBIRDCONFIG"; then
8955            AC_MSG_NOTICE([No fb_config -- using pkg-config])
8956            PKG_CHECK_MODULES([FIREBIRD], [fbclient >= 3], [FIREBIRD_PKGNAME=fbclient], [
8957                PKG_CHECK_MODULES([FIREBIRD], [fbembed], [FIREBIRD_PKGNAME=fbembed])
8958            ])
8959            FIREBIRD_VERSION=`pkg-config --modversion "$FIREBIRD_PKGNAME"`
8960        else
8961            AC_MSG_NOTICE([fb_config found])
8962            FIREBIRD_VERSION=`$FIREBIRDCONFIG --version`
8963            AC_MSG_CHECKING([for Firebird Client library])
8964            FIREBIRD_CFLAGS=`$FIREBIRDCONFIG --cflags`
8965            FIREBIRD_LIBS=`$FIREBIRDCONFIG --embedlibs`
8966            FilterLibs "${FIREBIRD_LIBS}"
8967            FIREBIRD_LIBS="${filteredlibs}"
8968        fi
8969        AC_MSG_RESULT([includes `$FIREBIRD_CFLAGS', libraries `$FIREBIRD_LIBS'])
8970        AC_MSG_CHECKING([Firebird version])
8971        if test -n "${FIREBIRD_VERSION}"; then
8972            FIREBIRD_MAJOR=`echo $FIREBIRD_VERSION | cut -d"." -f1`
8973            FIREBIRD_MINOR=`echo $FIREBIRD_VERSION | cut -d"." -f2`
8974            if test "$FIREBIRD_MAJOR" -eq "3" -a "$FIREBIRD_MINOR" -eq "0"; then
8975                AC_MSG_RESULT([OK])
8976            else
8977                AC_MSG_ERROR([Ensure firebird 3.0.x is installed])
8978            fi
8979        else
8980            __save_CFLAGS="${CFLAGS}"
8981            CFLAGS="${CFLAGS} ${FIREBIRD_CFLAGS}"
8982            AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <ibase.h>
8983#if defined(FB_API_VER) && FB_API_VER == 30
8984int fb_api_is_30(void) { return 0; }
8985#else
8986#error "Wrong Firebird API version"
8987#endif]])],AC_MSG_RESULT([OK]),AC_MSG_ERROR([Ensure firebird 3.0.x is installed]))
8988            CFLAGS="${__save_CFLAGS}"
8989        fi
8990        ENABLE_FIREBIRD_SDBC=TRUE
8991        AC_DEFINE([ENABLE_FIREBIRD_SDBC],1)
8992    elif test "$enable_database_connectivity" != yes; then
8993        AC_MSG_RESULT([none])
8994    elif test "$cross_compiling" = "yes"; then
8995        AC_MSG_RESULT([none])
8996    else
8997        dnl Embedded Firebird has version 3.0
8998        AC_DEFINE(HAVE_FIREBIRD_30, 1)
8999        dnl We need libatomic_ops for any non X86/X64 system
9000        if test "${CPUNAME}" != INTEL -a "${CPUNAME}" != X86_64; then
9001            dnl ===================================================================
9002            dnl Check for system libatomic_ops
9003            dnl ===================================================================
9004            libo_CHECK_SYSTEM_MODULE([libatomic_ops],[ATOMIC_OPS],[atomic_ops >= 0.7.2])
9005            if test "$with_system_libatomic_ops" = "yes"; then
9006                SYSTEM_LIBATOMIC_OPS=TRUE
9007                AC_CHECK_HEADERS(atomic_ops.h, [],
9008                [AC_MSG_ERROR(atomic_ops.h not found. install libatomic_ops)], [])
9009            else
9010                SYSTEM_LIBATOMIC_OPS=
9011                LIBATOMIC_OPS_CFLAGS="-I${WORKDIR}/UnpackedTarball/libatomic_ops/include"
9012                LIBATOMIC_OPS_LIBS="-latomic_ops"
9013                BUILD_TYPE="$BUILD_TYPE LIBATOMIC_OPS"
9014            fi
9015        fi
9016
9017        AC_MSG_RESULT([internal])
9018        SYSTEM_FIREBIRD=
9019        FIREBIRD_CFLAGS="-I${WORKDIR}/UnpackedTarball/firebird/gen/Release/firebird/include"
9020        FIREBIRD_LIBS="-lfbclient"
9021
9022        if test "$with_system_libtommath" = "yes"; then
9023            SYSTEM_LIBTOMMATH=TRUE
9024            dnl check for tommath presence
9025            save_LIBS=$LIBS
9026            AC_CHECK_HEADER(tommath.h,,AC_MSG_ERROR(Include file for tommath not found - please install development tommath package))
9027            AC_CHECK_LIB(tommath, mp_init, TOMMATH_LIBS=-ltommath, AC_MSG_ERROR(Library tommath not found - please install development tommath package))
9028            LIBS=$save_LIBS
9029        else
9030            SYSTEM_LIBTOMMATH=
9031            LIBTOMMATH_CFLAGS="-I${WORKDIR}/UnpackedTarball/libtommath"
9032            LIBTOMMATH_LIBS="-ltommath"
9033            BUILD_TYPE="$BUILD_TYPE LIBTOMMATH"
9034        fi
9035
9036        BUILD_TYPE="$BUILD_TYPE FIREBIRD"
9037        ENABLE_FIREBIRD_SDBC=TRUE
9038        AC_DEFINE([ENABLE_FIREBIRD_SDBC],1)
9039    fi
9040fi
9041AC_SUBST(ENABLE_FIREBIRD_SDBC)
9042AC_SUBST(SYSTEM_LIBATOMIC_OPS)
9043AC_SUBST(LIBATOMIC_OPS_CFLAGS)
9044AC_SUBST(LIBATOMIC_OPS_LIBS)
9045AC_SUBST(SYSTEM_FIREBIRD)
9046AC_SUBST(FIREBIRD_CFLAGS)
9047AC_SUBST(FIREBIRD_LIBS)
9048AC_SUBST([TOMMATH_CFLAGS])
9049AC_SUBST([TOMMATH_LIBS])
9050
9051dnl ===================================================================
9052dnl Check for system curl
9053dnl ===================================================================
9054AC_MSG_CHECKING([which libcurl to use])
9055if test "$with_system_curl" = "auto"; then
9056    with_system_curl="$with_system_libs"
9057fi
9058
9059if test "$with_system_curl" = "yes"; then
9060    AC_MSG_RESULT([external])
9061    SYSTEM_CURL=TRUE
9062
9063    # First try PKGCONFIG and then fall back
9064    PKG_CHECK_MODULES(CURL, libcurl >= 7.19.4,, [:])
9065
9066    if test -n "$CURL_PKG_ERRORS"; then
9067        AC_PATH_PROG(CURLCONFIG, curl-config)
9068        if test -z "$CURLCONFIG"; then
9069            AC_MSG_ERROR([curl development files not found])
9070        fi
9071        CURL_LIBS=`$CURLCONFIG --libs`
9072        FilterLibs "${CURL_LIBS}"
9073        CURL_LIBS="${filteredlibs}"
9074        CURL_CFLAGS=$("$CURLCONFIG" --cflags | sed -e "s/-I/${ISYSTEM?}/g")
9075        curl_version=`$CURLCONFIG --version | $SED -e 's/^libcurl //'`
9076
9077        AC_MSG_CHECKING([whether libcurl is >= 7.19.4])
9078        case $curl_version in
9079        dnl brackets doubled below because Autoconf uses them as m4 quote characters,
9080        dnl so they need to be doubled to end up in the configure script
9081        7.19.4|7.19.[[5-9]]|7.[[2-9]]?.*|7.???.*|[[8-9]].*|[[1-9]][[0-9]].*)
9082            AC_MSG_RESULT([yes])
9083            ;;
9084        *)
9085            AC_MSG_ERROR([no, you have $curl_version])
9086            ;;
9087        esac
9088    fi
9089
9090    ENABLE_CURL=TRUE
9091elif test $_os = iOS; then
9092    # Let's see if we need curl, I think not?
9093    AC_MSG_RESULT([none])
9094    ENABLE_CURL=
9095else
9096    AC_MSG_RESULT([internal])
9097    SYSTEM_CURL=
9098    BUILD_TYPE="$BUILD_TYPE CURL"
9099    ENABLE_CURL=TRUE
9100fi
9101AC_SUBST(SYSTEM_CURL)
9102AC_SUBST(CURL_CFLAGS)
9103AC_SUBST(CURL_LIBS)
9104AC_SUBST(ENABLE_CURL)
9105
9106dnl ===================================================================
9107dnl Check for system boost
9108dnl ===================================================================
9109AC_MSG_CHECKING([which boost to use])
9110if test "$with_system_boost" = "yes"; then
9111    AC_MSG_RESULT([external])
9112    SYSTEM_BOOST=TRUE
9113    AX_BOOST_BASE(1.47)
9114    AX_BOOST_DATE_TIME
9115    AX_BOOST_FILESYSTEM
9116    AX_BOOST_IOSTREAMS
9117    AX_BOOST_LOCALE
9118    AC_LANG_PUSH([C++])
9119    save_CXXFLAGS=$CXXFLAGS
9120    CXXFLAGS="$CXXFLAGS $BOOST_CPPFLAGS $CXXFLAGS_CXX11"
9121    AC_CHECK_HEADER(boost/shared_ptr.hpp, [],
9122       [AC_MSG_ERROR(boost/shared_ptr.hpp not found. install boost)], [])
9123    AC_CHECK_HEADER(boost/spirit/include/classic_core.hpp, [],
9124       [AC_MSG_ERROR(boost/spirit/include/classic_core.hpp not found. install boost >= 1.36)], [])
9125    CXXFLAGS=$save_CXXFLAGS
9126    AC_LANG_POP([C++])
9127    # this is in m4/ax_boost_base.m4
9128    FilterLibs "${BOOST_LDFLAGS}"
9129    BOOST_LDFLAGS="${filteredlibs}"
9130else
9131    AC_MSG_RESULT([internal])
9132    BUILD_TYPE="$BUILD_TYPE BOOST"
9133    SYSTEM_BOOST=
9134    if test "${COM}" = "GCC" -o "${COM_IS_CLANG}" = "TRUE"; then
9135        # use warning-suppressing wrapper headers
9136        BOOST_CPPFLAGS="-I${SRC_ROOT}/external/boost/include -I${WORKDIR}/UnpackedTarball/boost"
9137    else
9138        BOOST_CPPFLAGS="-I${WORKDIR}/UnpackedTarball/boost"
9139    fi
9140fi
9141AC_SUBST(SYSTEM_BOOST)
9142
9143dnl ===================================================================
9144dnl Check for system mdds
9145dnl ===================================================================
9146libo_CHECK_SYSTEM_MODULE([mdds], [MDDS], [mdds-1.4 >= 1.4.1], ["-I${WORKDIR}/UnpackedTarball/mdds/include"])
9147
9148dnl ===================================================================
9149dnl Check for system glm
9150dnl ===================================================================
9151AC_MSG_CHECKING([which glm to use])
9152if test "$with_system_glm" = "yes"; then
9153    AC_MSG_RESULT([external])
9154    SYSTEM_GLM=TRUE
9155    AC_LANG_PUSH([C++])
9156    AC_CHECK_HEADER([glm/glm.hpp], [],
9157       [AC_MSG_ERROR([glm/glm.hpp not found. install glm])], [])
9158    AC_LANG_POP([C++])
9159else
9160    AC_MSG_RESULT([internal])
9161    BUILD_TYPE="$BUILD_TYPE GLM"
9162    SYSTEM_GLM=
9163    GLM_CFLAGS="${ISYSTEM}${WORKDIR}/UnpackedTarball/glm"
9164fi
9165AC_SUBST([GLM_CFLAGS])
9166AC_SUBST([SYSTEM_GLM])
9167
9168dnl ===================================================================
9169dnl Check for system odbc
9170dnl ===================================================================
9171AC_MSG_CHECKING([which odbc headers to use])
9172if test "$with_system_odbc" = "yes" -o '(' "$with_system_headers" = "yes" -a "$with_system_odbc" = "auto" ')' -o '(' "$_os" = "WINNT" -a  "$with_system_odbc" != "no" ')'; then
9173    AC_MSG_RESULT([external])
9174    SYSTEM_ODBC_HEADERS=TRUE
9175
9176    if test "$build_os" = "cygwin"; then
9177        save_CPPFLAGS=$CPPFLAGS
9178        find_winsdk
9179        PathFormat "$winsdktest"
9180        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"
9181        AC_CHECK_HEADER(sqlext.h, [],
9182            [AC_MSG_ERROR(odbc not found. install odbc)],
9183            [#include <windows.h>])
9184        CPPFLAGS=$save_CPPFLAGS
9185    else
9186        AC_CHECK_HEADER(sqlext.h, [],
9187            [AC_MSG_ERROR(odbc not found. install odbc)],[])
9188    fi
9189elif test "$enable_database_connectivity" != yes; then
9190    AC_MSG_RESULT([none])
9191else
9192    AC_MSG_RESULT([internal])
9193    SYSTEM_ODBC_HEADERS=
9194fi
9195AC_SUBST(SYSTEM_ODBC_HEADERS)
9196
9197dnl ===================================================================
9198dnl Enable LDAP support
9199dnl ===================================================================
9200
9201if test "$_os" != "WINNT" -a "$_os" != "iOS" -a "$_os" != "Android"; then
9202AC_MSG_CHECKING([whether to enable LDAP support])
9203    if test "$enable_ldap" != "yes"; then
9204        AC_MSG_RESULT([no])
9205        ENABLE_LDAP=""
9206        enable_ldap=no
9207    else
9208        AC_MSG_RESULT([yes])
9209        ENABLE_LDAP="TRUE"
9210        AC_DEFINE(HAVE_FEATURE_LDAP)
9211    fi
9212fi
9213AC_SUBST(ENABLE_LDAP)
9214
9215dnl ===================================================================
9216dnl Check for system openldap
9217dnl ===================================================================
9218
9219if test "$_os" != "WINNT" -a "$_os" != "iOS" -a "$_os" != "Android" -a "$ENABLE_LDAP" != ""; then
9220AC_MSG_CHECKING([which openldap library to use])
9221if test "$with_system_openldap" = "yes"; then
9222    AC_MSG_RESULT([external])
9223    SYSTEM_OPENLDAP=TRUE
9224    AC_CHECK_HEADERS(ldap.h, [], [AC_MSG_ERROR(ldap.h not found. install openldap libs)], [])
9225    AC_CHECK_LIB([ldap], [ldap_simple_bind_s], [:], [AC_MSG_ERROR(openldap lib not found or functional)], [])
9226    AC_CHECK_LIB([ldap], [ldap_set_option], [:], [AC_MSG_ERROR(openldap lib not found or functional)], [])
9227else
9228    AC_MSG_RESULT([internal])
9229    SYSTEM_OPENLDAP=
9230    BUILD_TYPE="$BUILD_TYPE OPENLDAP"
9231fi
9232fi
9233AC_SUBST(SYSTEM_OPENLDAP)
9234
9235dnl ===================================================================
9236dnl Check for system NSS
9237dnl ===================================================================
9238if test $_os != iOS -a "$enable_fuzzers" != "yes"; then
9239    libo_CHECK_SYSTEM_MODULE([nss],[NSS],[nss >= 3.9.3 nspr >= 4.8])
9240    AC_DEFINE(HAVE_FEATURE_NSS)
9241    ENABLE_NSS="TRUE"
9242    AC_DEFINE(ENABLE_NSS)
9243elif test $_os != iOS ; then
9244    with_tls=openssl
9245fi
9246AC_SUBST(ENABLE_NSS)
9247
9248dnl ===================================================================
9249dnl Check for TLS/SSL and cryptographic implementation to use
9250dnl ===================================================================
9251AC_MSG_CHECKING([which TLS/SSL and cryptographic implementation to use])
9252if test -n "$with_tls"; then
9253    case $with_tls in
9254    openssl)
9255        AC_DEFINE(USE_TLS_OPENSSL)
9256        TLS=OPENSSL
9257
9258        if test "$enable_openssl" != "yes"; then
9259            AC_MSG_ERROR(["Disabling OpenSSL was requested, but the requested TLS to use is actually OpenSSL."])
9260        fi
9261
9262        # warn that OpenSSL has been selected but not all TLS code has this option
9263        AC_MSG_WARN([TLS/SSL implementation to use is OpenSSL but some code may still depend on NSS or GNUTLS])
9264        add_warning "TLS/SSL implementation to use is OpenSSL but some code may still depend on NSS or GNUTLS"
9265        ;;
9266    nss)
9267        AC_DEFINE(USE_TLS_NSS)
9268        TLS=NSS
9269        ;;
9270    no)
9271        AC_MSG_WARN([Skipping TLS/SSL])
9272        ;;
9273    *)
9274        AC_MSG_ERROR([unsupported implementation $with_tls. Supported are:
9275openssl - OpenSSL
9276nss - Mozilla's Network Security Services (NSS)
9277    ])
9278        ;;
9279    esac
9280else
9281    # default to using NSS, it results in smaller oox lib
9282    AC_DEFINE(USE_TLS_NSS)
9283    TLS=NSS
9284fi
9285AC_MSG_RESULT([$TLS])
9286AC_SUBST(TLS)
9287
9288dnl ===================================================================
9289dnl Check for system sane
9290dnl ===================================================================
9291AC_MSG_CHECKING([which sane header to use])
9292if test "$with_system_sane" = "yes"; then
9293    AC_MSG_RESULT([external])
9294    AC_CHECK_HEADER(sane/sane.h, [],
9295      [AC_MSG_ERROR(sane not found. install sane)], [])
9296else
9297    AC_MSG_RESULT([internal])
9298    BUILD_TYPE="$BUILD_TYPE SANE"
9299fi
9300
9301dnl ===================================================================
9302dnl Check for system icu
9303dnl ===================================================================
9304SYSTEM_GENBRK=
9305SYSTEM_GENCCODE=
9306SYSTEM_GENCMN=
9307
9308ICU_MAJOR=63
9309ICU_MINOR=1
9310ICU_RECLASSIFIED_PREPEND_SET_EMPTY="TRUE"
9311ICU_RECLASSIFIED_CONDITIONAL_JAPANESE_STARTER="TRUE"
9312ICU_RECLASSIFIED_HEBREW_LETTER="TRUE"
9313AC_MSG_CHECKING([which icu to use])
9314if test "$with_system_icu" = "yes"; then
9315    AC_MSG_RESULT([external])
9316    SYSTEM_ICU=TRUE
9317    AC_LANG_PUSH([C++])
9318    AC_MSG_CHECKING([for unicode/rbbi.h])
9319    AC_PREPROC_IFELSE([AC_LANG_SOURCE([[unicode/rbbi.h]])],[AC_MSG_RESULT(checked.)],[AC_MSG_ERROR(icu headers not found.)])
9320    AC_LANG_POP([C++])
9321
9322    if test "$cross_compiling" != "yes"; then
9323        PKG_CHECK_MODULES(ICU, icu-i18n >= 4.6)
9324        ICU_VERSION=`$PKG_CONFIG --modversion icu-i18n 2>/dev/null`
9325        ICU_MAJOR=`echo $ICU_VERSION | cut -d"." -f1`
9326        ICU_MINOR=`echo $ICU_VERSION | cut -d"." -f2`
9327    fi
9328
9329    if test "$cross_compiling" = "yes" -a \( "$with_system_icu_for_build" = "yes" -o "$with_system_icu_for_build" = "force" \); then
9330        ICU_VERSION_FOR_BUILD=`$PKG_CONFIG --modversion icu-i18n 2>/dev/null`
9331        ICU_MAJOR_FOR_BUILD=`echo $ICU_VERSION_FOR_BUILD | cut -d"." -f1`
9332        ICU_MINOR_FOR_BUILD=`echo $ICU_VERSION_FOR_BUILD | cut -d"." -f2`
9333        AC_MSG_CHECKING([if MinGW and system versions of ICU are compatible])
9334        if test "$ICU_MAJOR" -eq "$ICU_MAJOR_FOR_BUILD" -a "$ICU_MINOR" -eq "$ICU_MINOR_FOR_BUILD"; then
9335            AC_MSG_RESULT([yes])
9336        else
9337            AC_MSG_RESULT([no])
9338            if test "$with_system_icu_for_build" != "force"; then
9339                AC_MSG_ERROR([System ICU is not version-compatible with MinGW ICU.
9340You can use --with-system-icu-for-build=force to use it anyway.])
9341            fi
9342        fi
9343    fi
9344
9345    if test "$cross_compiling" != "yes" -o "$with_system_icu_for_build" = "yes" -o "$with_system_icu_for_build" = "force"; then
9346        # using the system icu tools can lead to version confusion, use the
9347        # ones from the build environment when cross-compiling
9348        AC_PATH_PROG(SYSTEM_GENBRK, genbrk, [], [$PATH:/usr/sbin:/sbin])
9349        if test -z "$SYSTEM_GENBRK"; then
9350            AC_MSG_ERROR([\'genbrk\' not found in \$PATH, install the icu development tool \'genbrk\'])
9351        fi
9352        AC_PATH_PROG(SYSTEM_GENCCODE, genccode, [], [$PATH:/usr/sbin:/sbin:/usr/local/sbin])
9353        if test -z "$SYSTEM_GENCCODE"; then
9354            AC_MSG_ERROR([\'genccode\' not found in \$PATH, install the icu development tool \'genccode\'])
9355        fi
9356        AC_PATH_PROG(SYSTEM_GENCMN, gencmn, [], [$PATH:/usr/sbin:/sbin:/usr/local/sbin])
9357        if test -z "$SYSTEM_GENCMN"; then
9358            AC_MSG_ERROR([\'gencmn\' not found in \$PATH, install the icu development tool \'gencmn\'])
9359        fi
9360        if test "$ICU_MAJOR" -ge "49"; then
9361            ICU_RECLASSIFIED_PREPEND_SET_EMPTY="TRUE"
9362            ICU_RECLASSIFIED_CONDITIONAL_JAPANESE_STARTER="TRUE"
9363            ICU_RECLASSIFIED_HEBREW_LETTER="TRUE"
9364        else
9365            ICU_RECLASSIFIED_PREPEND_SET_EMPTY=
9366            ICU_RECLASSIFIED_CONDITIONAL_JAPANESE_STARTER=
9367            ICU_RECLASSIFIED_HEBREW_LETTER=
9368        fi
9369    fi
9370
9371    if test "$cross_compiling" = "yes"; then
9372        if test "$ICU_MAJOR" -ge "50"; then
9373            AC_MSG_RESULT([Ignore ICU_MINOR as obviously the libraries don't include the minor version in their names any more])
9374            ICU_MINOR=""
9375        fi
9376    fi
9377else
9378    AC_MSG_RESULT([internal])
9379    SYSTEM_ICU=
9380    BUILD_TYPE="$BUILD_TYPE ICU"
9381    # surprisingly set these only for "internal" (to be used by various other
9382    # external libs): the system icu-config is quite unhelpful and spits out
9383    # dozens of weird flags and also default path -I/usr/include
9384    ICU_CFLAGS="-I${WORKDIR}/UnpackedTarball/icu/source/i18n -I${WORKDIR}/UnpackedTarball/icu/source/common"
9385    ICU_LIBS="-L${WORKDIR}/UnpackedTarball/icu/source/lib"
9386fi
9387if test "$ICU_MAJOR" -ge "59"; then
9388    # As of ICU 59 it defaults to typedef char16_t UChar; which is available
9389    # with -std=c++11 but not all external libraries can be built with that,
9390    # for those use a bit-compatible typedef uint16_t UChar; see
9391    # icu/source/common/unicode/umachine.h
9392    ICU_UCHAR_TYPE="-DUCHAR_TYPE=uint16_t"
9393else
9394    ICU_UCHAR_TYPE=""
9395fi
9396AC_SUBST(SYSTEM_ICU)
9397AC_SUBST(SYSTEM_GENBRK)
9398AC_SUBST(SYSTEM_GENCCODE)
9399AC_SUBST(SYSTEM_GENCMN)
9400AC_SUBST(ICU_MAJOR)
9401AC_SUBST(ICU_MINOR)
9402AC_SUBST(ICU_RECLASSIFIED_PREPEND_SET_EMPTY)
9403AC_SUBST(ICU_RECLASSIFIED_CONDITIONAL_JAPANESE_STARTER)
9404AC_SUBST(ICU_RECLASSIFIED_HEBREW_LETTER)
9405AC_SUBST(ICU_CFLAGS)
9406AC_SUBST(ICU_LIBS)
9407AC_SUBST(ICU_UCHAR_TYPE)
9408
9409dnl ==================================================================
9410dnl Breakpad
9411dnl ==================================================================
9412AC_MSG_CHECKING([whether to enable breakpad])
9413if test "$enable_breakpad" != yes; then
9414    AC_MSG_RESULT([no])
9415else
9416    AC_MSG_RESULT([yes])
9417    ENABLE_BREAKPAD="TRUE"
9418    AC_DEFINE(ENABLE_BREAKPAD)
9419    AC_DEFINE(HAVE_FEATURE_BREAKPAD, 1)
9420    BUILD_TYPE="$BUILD_TYPE BREAKPAD"
9421
9422    AC_MSG_CHECKING([for crashreport config])
9423    if test "$with_symbol_config" = "no"; then
9424        BREAKPAD_SYMBOL_CONFIG="invalid"
9425        AC_MSG_RESULT([no])
9426    else
9427        BREAKPAD_SYMBOL_CONFIG="$with_symbol_config"
9428        AC_DEFINE(BREAKPAD_SYMBOL_CONFIG)
9429        AC_MSG_RESULT([yes])
9430    fi
9431    AC_SUBST(BREAKPAD_SYMBOL_CONFIG)
9432fi
9433AC_SUBST(ENABLE_BREAKPAD)
9434
9435dnl ==================================================================
9436dnl libfuzzer
9437dnl ==================================================================
9438AC_MSG_CHECKING([whether to enable fuzzers])
9439if test "$enable_fuzzers" != yes; then
9440    AC_MSG_RESULT([no])
9441else
9442    AC_MSG_RESULT([yes])
9443    ENABLE_FUZZERS="TRUE"
9444    AC_DEFINE([ENABLE_FUZZERS],1)
9445    BUILD_TYPE="$BUILD_TYPE FUZZERS"
9446fi
9447AC_SUBST(ENABLE_FUZZERS)
9448
9449dnl ===================================================================
9450dnl Orcus
9451dnl ===================================================================
9452libo_CHECK_SYSTEM_MODULE([orcus],[ORCUS],[liborcus-0.14 >= 0.14.0])
9453if test "$with_system_orcus" != "yes"; then
9454    if test "$SYSTEM_BOOST" = "TRUE"; then
9455        # ===========================================================
9456        # Determine if we are going to need to link with Boost.System
9457        # ===========================================================
9458        dnl This seems to be necessary since boost 1.50 (1.48 does not need it,
9459        dnl 1.49 is untested). The macro BOOST_THREAD_DONT_USE_SYSTEM mentioned
9460        dnl in documentation has no effect.
9461        AC_MSG_CHECKING([if we need to link with Boost.System])
9462        AC_LANG_PUSH([C++])
9463        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
9464                @%:@include <boost/version.hpp>
9465            ]],[[
9466                #if BOOST_VERSION >= 105000
9467                #   error yes, we need to link with Boost.System
9468                #endif
9469            ]])],[
9470                AC_MSG_RESULT([no])
9471            ],[
9472                AC_MSG_RESULT([yes])
9473                AX_BOOST_SYSTEM
9474        ])
9475        AC_LANG_POP([C++])
9476    fi
9477fi
9478dnl FIXME by renaming SYSTEM_LIBORCUS to SYSTEM_ORCUS in the build system world
9479SYSTEM_LIBORCUS=$SYSTEM_ORCUS
9480AC_SUBST([BOOST_SYSTEM_LIB])
9481AC_SUBST(SYSTEM_LIBORCUS)
9482
9483dnl ===================================================================
9484dnl HarfBuzz
9485dnl ===================================================================
9486libo_CHECK_SYSTEM_MODULE([graphite],[GRAPHITE],[graphite2 >= 0.9.3],
9487                         ["-I${WORKDIR}/UnpackedTarball/graphite/include -DGRAPHITE2_STATIC"],
9488                         ["-L${WORKDIR}/LinkTarget/StaticLibrary -lgraphite"])
9489
9490libo_CHECK_SYSTEM_MODULE([harfbuzz],[HARFBUZZ],[harfbuzz-icu >= 0.9.42],
9491                         ["-I${WORKDIR}/UnpackedTarball/harfbuzz/src"],
9492                         ["-L${WORKDIR}/UnpackedTarball/harfbuzz/src/.libs -lharfbuzz"])
9493
9494if test "$COM" = "MSC"; then # override the above
9495    GRAPHITE_LIBS="${WORKDIR}/LinkTarget/StaticLibrary/graphite.lib"
9496    HARFBUZZ_LIBS="${WORKDIR}/UnpackedTarball/harfbuzz/src/.libs/libharfbuzz.lib"
9497fi
9498
9499if test "$with_system_harfbuzz" = "yes"; then
9500    if test "$with_system_graphite" = "no"; then
9501        AC_MSG_ERROR([--with-system-graphite must be used when --with-system-harfbuzz is used])
9502    fi
9503    AC_MSG_CHECKING([whether system Harfbuzz is built with Graphite support])
9504    _save_libs="$LIBS"
9505    _save_cflags="$CFLAGS"
9506    LIBS="$LIBS $HARFBUZZ_LIBS"
9507    CFLAGS="$CFLAGS $HARFBUZZ_CFLAGS"
9508    AC_CHECK_FUNC(hb_graphite2_face_get_gr_face,,[AC_MSG_ERROR([Harfbuzz needs to be built with Graphite support.])])
9509    LIBS="$_save_libs"
9510    CFLAGS="$_save_cflags"
9511else
9512    if test "$with_system_graphite" = "yes"; then
9513        AC_MSG_ERROR([--without-system-graphite must be used when --without-system-harfbuzz is used])
9514    fi
9515fi
9516
9517AC_MSG_CHECKING([whether to use X11])
9518dnl ***************************************
9519dnl testing for X libraries and includes...
9520dnl ***************************************
9521if test "$USING_X11" = TRUE; then
9522    AC_DEFINE(HAVE_FEATURE_X11)
9523fi
9524AC_MSG_RESULT([$USING_X11])
9525
9526if test "$USING_X11" = TRUE; then
9527    AC_PATH_X
9528    AC_PATH_XTRA
9529    CPPFLAGS="$CPPFLAGS $X_CFLAGS"
9530
9531    if test -z "$x_includes"; then
9532        x_includes="default_x_includes"
9533    fi
9534    if test -z "$x_libraries"; then
9535        x_libraries="default_x_libraries"
9536    fi
9537    CFLAGS="$CFLAGS $X_CFLAGS"
9538    LDFLAGS="$LDFLAGS $X_LDFLAGS $X_LIBS"
9539    AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS", [AC_MSG_ERROR([X Development libraries not found])])
9540else
9541    x_includes="no_x_includes"
9542    x_libraries="no_x_libraries"
9543fi
9544
9545if test "$USING_X11" = TRUE; then
9546    dnl ===================================================================
9547    dnl Check for extension headers
9548    dnl ===================================================================
9549    AC_CHECK_HEADERS(X11/extensions/shape.h,[],[AC_MSG_ERROR([libXext headers not found])],
9550     [#include <X11/extensions/shape.h>])
9551
9552    # vcl needs ICE and SM
9553    AC_CHECK_HEADERS(X11/ICE/ICElib.h,[],[AC_MSG_ERROR([libICE headers not found])])
9554    AC_CHECK_LIB([ICE], [IceConnectionNumber], [:],
9555        [AC_MSG_ERROR(ICE library not found)])
9556    AC_CHECK_HEADERS(X11/SM/SMlib.h,[],[AC_MSG_ERROR([libSM headers not found])])
9557    AC_CHECK_LIB([SM], [SmcOpenConnection], [:],
9558        [AC_MSG_ERROR(SM library not found)])
9559fi
9560
9561dnl ===================================================================
9562dnl Check for system Xrender
9563dnl ===================================================================
9564AC_MSG_CHECKING([whether to use Xrender])
9565if test "$USING_X11" = TRUE -a  "$test_xrender" = "yes"; then
9566    AC_MSG_RESULT([yes])
9567    PKG_CHECK_MODULES(XRENDER, xrender)
9568    XRENDER_CFLAGS=$(printf '%s' "$XRENDER_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
9569    FilterLibs "${XRENDER_LIBS}"
9570    XRENDER_LIBS="${filteredlibs}"
9571    AC_CHECK_LIB([Xrender], [XRenderQueryVersion], [:],
9572      [AC_MSG_ERROR(libXrender not found or functional)], [])
9573    AC_CHECK_HEADER(X11/extensions/Xrender.h, [],
9574      [AC_MSG_ERROR(Xrender not found. install X)], [])
9575else
9576    AC_MSG_RESULT([no])
9577fi
9578AC_SUBST(XRENDER_CFLAGS)
9579AC_SUBST(XRENDER_LIBS)
9580
9581dnl ===================================================================
9582dnl Check for XRandr
9583dnl ===================================================================
9584AC_MSG_CHECKING([whether to enable RandR support])
9585if test "$USING_X11" = TRUE -a "$test_randr" = "yes" -a \( "$enable_randr" = "yes" -o "$enable_randr" = "TRUE" \); then
9586    AC_MSG_RESULT([yes])
9587    PKG_CHECK_MODULES(XRANDR, xrandr >= 1.2, ENABLE_RANDR="TRUE", ENABLE_RANDR="")
9588    if test "$ENABLE_RANDR" != "TRUE"; then
9589        AC_CHECK_HEADER(X11/extensions/Xrandr.h, [],
9590                    [AC_MSG_ERROR([X11/extensions/Xrandr.h could not be found. X11 dev missing?])], [])
9591        XRANDR_CFLAGS=" "
9592        AC_CHECK_LIB([Xrandr], [XRRQueryExtension], [:],
9593          [ AC_MSG_ERROR(libXrandr not found or functional) ], [])
9594        XRANDR_LIBS="-lXrandr "
9595        ENABLE_RANDR="TRUE"
9596    fi
9597    XRANDR_CFLAGS=$(printf '%s' "$XRANDR_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
9598    FilterLibs "${XRANDR_LIBS}"
9599    XRANDR_LIBS="${filteredlibs}"
9600else
9601    ENABLE_RANDR=""
9602    AC_MSG_RESULT([no])
9603fi
9604AC_SUBST(XRANDR_CFLAGS)
9605AC_SUBST(XRANDR_LIBS)
9606AC_SUBST(ENABLE_RANDR)
9607
9608if test "$enable_neon" = "no" -o "$enable_mpl_subset" = "yes"; then
9609    WITH_WEBDAV="serf"
9610fi
9611if test $_os = iOS -o $_os = Android; then
9612    WITH_WEBDAV="no"
9613fi
9614AC_MSG_CHECKING([for webdav library])
9615case "$WITH_WEBDAV" in
9616serf)
9617    AC_MSG_RESULT([serf])
9618    # Check for system apr-util
9619    libo_CHECK_SYSTEM_MODULE([apr],[APR],[apr-util-1],
9620                             ["-I${WORKDIR}/UnpackedTarball/apr/include -I${WORKDIR}/UnpackedTarball/apr_util/include"],
9621                             ["-L${WORKDIR}/UnpackedTarball/apr/.libs -lapr-1 -L${WORKDIR}/UnpackedTarball/apr_util/.libs -laprutil-1"])
9622    if test "$COM" = "MSC"; then
9623        APR_LIB_DIR="LibR"
9624        test -n "${MSVC_USE_DEBUG_RUNTIME}" && APR_LIB_DIR="LibD"
9625        APR_LIBS="${WORKDIR}/UnpackedTarball/apr/${APR_LIB_DIR}/apr-1.lib ${WORKDIR}/UnpackedTarball/apr_util/${APR_LIB_DIR}/aprutil-1.lib"
9626    fi
9627
9628    # Check for system serf
9629    libo_CHECK_SYSTEM_MODULE([serf],[SERF],[serf-1 >= 1.1.0],["-I${WORKDIR}/UnpackedTarball/serf"],
9630                             ["-L${WORKDIR}/UnpackedTarball/serf/.libs -lserf-1"])
9631    if test "$COM" = "MSC"; then
9632        SERF_LIB_DIR="Release"
9633        test -n "${MSVC_USE_DEBUG_RUNTIME}" && SERF_LIB_DIR="Debug"
9634        SERF_LIBS="${WORKDIR}/UnpackedTarball/serf/${SERF_LIB_DIR}/serf-1.lib"
9635    fi
9636    ;;
9637neon)
9638    AC_MSG_RESULT([neon])
9639    # Check for system neon
9640    libo_CHECK_SYSTEM_MODULE([neon],[NEON],[neon >= 0.26.0])
9641    if test "$with_system_neon" = "yes"; then
9642        NEON_VERSION="`$PKG_CONFIG --modversion neon | $SED 's/\.//g'`"
9643    else
9644        NEON_VERSION=0295
9645    fi
9646    AC_SUBST(NEON_VERSION)
9647    ;;
9648*)
9649    AC_MSG_RESULT([none, disabled])
9650    WITH_WEBDAV=""
9651    ;;
9652esac
9653AC_SUBST(WITH_WEBDAV)
9654
9655dnl ===================================================================
9656dnl Check for disabling cve_tests
9657dnl ===================================================================
9658AC_MSG_CHECKING([whether to execute CVE tests])
9659# If not explicitly enabled or disabled, default
9660if test -z "$enable_cve_tests"; then
9661    case "$OS" in
9662    WNT)
9663        # Default cves off for Windows with its wild and wonderful
9664        # variety of AV software kicking in and panicking
9665        enable_cve_tests=no
9666        ;;
9667    *)
9668        # otherwise yes
9669        enable_cve_tests=yes
9670        ;;
9671    esac
9672fi
9673if test "$enable_cve_tests" = "no"; then
9674    AC_MSG_RESULT([no])
9675    DISABLE_CVE_TESTS=TRUE
9676    AC_SUBST(DISABLE_CVE_TESTS)
9677else
9678    AC_MSG_RESULT([yes])
9679fi
9680
9681dnl ===================================================================
9682dnl Check for enabling chart XShape tests
9683dnl ===================================================================
9684AC_MSG_CHECKING([whether to execute chart XShape tests])
9685if test "$enable_chart_tests" = "yes" -o '(' "$_os" = "WINNT" -a "$enable_chart_tests" != "no" ')'; then
9686    AC_MSG_RESULT([yes])
9687    ENABLE_CHART_TESTS=TRUE
9688    AC_SUBST(ENABLE_CHART_TESTS)
9689else
9690    AC_MSG_RESULT([no])
9691fi
9692
9693dnl ===================================================================
9694dnl Check for system openssl
9695dnl ===================================================================
9696DISABLE_OPENSSL=
9697AC_MSG_CHECKING([whether to disable OpenSSL usage])
9698if test "$enable_openssl" = "yes"; then
9699    AC_MSG_RESULT([no])
9700    if test "$_os" = Darwin ; then
9701        # OpenSSL is deprecated when building for 10.7 or later.
9702        #
9703        # http://stackoverflow.com/questions/7406946/why-is-apple-deprecating-openssl-in-macos-10-7-lion
9704        # http://stackoverflow.com/questions/7475914/libcrypto-deprecated-on-mac-os-x-10-7-lion
9705
9706        with_system_openssl=no
9707        libo_CHECK_SYSTEM_MODULE([openssl],[OPENSSL],[openssl])
9708    elif test "$_os" = "NetBSD" -o "$_os" = "OpenBSD" -o "$_os" = "DragonFly" \
9709            && test "$with_system_openssl" != "no"; then
9710        with_system_openssl=yes
9711        SYSTEM_OPENSSL=TRUE
9712        OPENSSL_CFLAGS=
9713        OPENSSL_LIBS="-lssl -lcrypto"
9714    else
9715        libo_CHECK_SYSTEM_MODULE([openssl],[OPENSSL],[openssl])
9716    fi
9717    if test "$with_system_openssl" = "yes"; then
9718        AC_MSG_CHECKING([whether openssl supports SHA512])
9719        AC_LANG_PUSH([C])
9720        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <openssl/sha.h>]],[[
9721            SHA512_CTX context;
9722]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no, openssl too old. Need >= 0.9.8.])])
9723        AC_LANG_POP(C)
9724    fi
9725else
9726    AC_MSG_RESULT([yes])
9727    DISABLE_OPENSSL=TRUE
9728
9729    # warn that although OpenSSL is disabled, system libraries may depend on it
9730    AC_MSG_WARN([OpenSSL has been disabled. No code compiled by LibO will make use of it but system libraries may create indirect dependencies])
9731    add_warning "OpenSSL has been disabled. No code compiled by LibO will make use of it but system libraries may create indirect dependencies"
9732fi
9733
9734AC_SUBST([DISABLE_OPENSSL])
9735
9736if test "$enable_cipher_openssl_backend" = yes && test "$DISABLE_OPENSSL" = TRUE; then
9737    if test "$libo_fuzzed_enable_cipher_openssl_backend" = yes; then
9738        AC_MSG_NOTICE([Resetting --enable-cipher-openssl-backend=no])
9739        enable_cipher_openssl_backend=no
9740    else
9741        AC_MSG_ERROR([--enable-cipher-openssl-backend needs OpenSSL, but --disable-openssl was given.])
9742    fi
9743fi
9744AC_MSG_CHECKING([whether to enable the OpenSSL backend for rtl/cipher.h])
9745ENABLE_CIPHER_OPENSSL_BACKEND=
9746if test "$enable_cipher_openssl_backend" = yes; then
9747    AC_MSG_RESULT([yes])
9748    ENABLE_CIPHER_OPENSSL_BACKEND=TRUE
9749else
9750    AC_MSG_RESULT([no])
9751fi
9752AC_SUBST([ENABLE_CIPHER_OPENSSL_BACKEND])
9753
9754dnl ===================================================================
9755dnl Check for building gnutls
9756dnl ===================================================================
9757AC_MSG_CHECKING([whether to use gnutls])
9758if test "$WITH_WEBDAV" = "neon" -a "$with_system_neon" = no -a "$enable_openssl" = "no"; then
9759    AC_MSG_RESULT([yes])
9760    AM_PATH_LIBGCRYPT()
9761    PKG_CHECK_MODULES(GNUTLS, [gnutls],,
9762        AC_MSG_ERROR([[Disabling OpenSSL was requested, but GNUTLS is not
9763                      available in the system to use as replacement.]]))
9764    FilterLibs "${LIBGCRYPT_LIBS}"
9765    LIBGCRYPT_LIBS="${filteredlibs}"
9766else
9767    AC_MSG_RESULT([no])
9768fi
9769
9770AC_SUBST([LIBGCRYPT_CFLAGS])
9771AC_SUBST([LIBGCRYPT_LIBS])
9772
9773dnl ===================================================================
9774dnl Check for system redland
9775dnl ===================================================================
9776dnl redland: versions before 1.0.8 write RDF/XML that is useless for ODF (@xml:base)
9777dnl raptor2: need at least 2.0.7 for CVE-2012-0037
9778libo_CHECK_SYSTEM_MODULE([redland],[REDLAND],[redland >= 1.0.8 raptor2 >= 2.0.7])
9779if test "$with_system_redland" = "yes"; then
9780    AC_CHECK_LIB([rdf], [librdf_world_set_raptor_init_handler], [:],
9781            [AC_MSG_ERROR(librdf too old. Need >= 1.0.16)], [])
9782else
9783    RAPTOR_MAJOR="0"
9784    RASQAL_MAJOR="3"
9785    REDLAND_MAJOR="0"
9786fi
9787AC_SUBST(RAPTOR_MAJOR)
9788AC_SUBST(RASQAL_MAJOR)
9789AC_SUBST(REDLAND_MAJOR)
9790
9791dnl ===================================================================
9792dnl Check for system hunspell
9793dnl ===================================================================
9794AC_MSG_CHECKING([which libhunspell to use])
9795if test "$with_system_hunspell" = "yes"; then
9796    AC_MSG_RESULT([external])
9797    SYSTEM_HUNSPELL=TRUE
9798    AC_LANG_PUSH([C++])
9799    PKG_CHECK_MODULES(HUNSPELL, hunspell, HUNSPELL_PC="TRUE", HUNSPELL_PC="" )
9800    if test "$HUNSPELL_PC" != "TRUE"; then
9801        AC_CHECK_HEADER(hunspell.hxx, [],
9802            [
9803            AC_CHECK_HEADER(hunspell/hunspell.hxx, [ HUNSPELL_CFLAGS=-I/usr/include/hunspell ],
9804            [AC_MSG_ERROR(hunspell headers not found.)], [])
9805            ], [])
9806        AC_CHECK_LIB([hunspell], [main], [:],
9807           [ AC_MSG_ERROR(hunspell library not found.) ], [])
9808        HUNSPELL_LIBS=-lhunspell
9809    fi
9810    AC_LANG_POP([C++])
9811    HUNSPELL_CFLAGS=$(printf '%s' "$HUNSPELL_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
9812    FilterLibs "${HUNSPELL_LIBS}"
9813    HUNSPELL_LIBS="${filteredlibs}"
9814else
9815    AC_MSG_RESULT([internal])
9816    SYSTEM_HUNSPELL=
9817    HUNSPELL_CFLAGS="-I${WORKDIR}/UnpackedTarball/hunspell/src/hunspell"
9818    if test "$COM" = "MSC"; then
9819        HUNSPELL_LIBS="${WORKDIR}/LinkTarget/StaticLibrary/hunspell.lib"
9820    else
9821        HUNSPELL_LIBS="-L${WORKDIR}/UnpackedTarball/hunspell/src/hunspell/.libs -lhunspell-1.7"
9822    fi
9823    BUILD_TYPE="$BUILD_TYPE HUNSPELL"
9824fi
9825AC_SUBST(SYSTEM_HUNSPELL)
9826AC_SUBST(HUNSPELL_CFLAGS)
9827AC_SUBST(HUNSPELL_LIBS)
9828
9829dnl ===================================================================
9830dnl Check for system qrcodegen
9831dnl ===================================================================
9832AC_MSG_CHECKING([which libqrcodegen to use])
9833if test "$with_system_qrcodegen" = "yes"; then
9834    AC_MSG_RESULT([external])
9835    SYSTEM_QRCODEGEN=TRUE
9836    AC_LANG_PUSH([C++])
9837    AC_CHECK_HEADER(qrcodegen/QrCode.hpp, [],
9838        [AC_MSG_ERROR(qrcodegen headers not found.)], [#include <stdexcept>])
9839    AC_CHECK_LIB([qrcodegencpp], [main], [:],
9840        [ AC_MSG_ERROR(qrcodegen C++ library not found.) ], [])
9841    QRCODEGEN_LIBS=-lqrcodegencpp
9842    AC_LANG_POP([C++])
9843    QRCODEGEN_CFLAGS=$(printf '%s' "$QRCODEGEN_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
9844    FilterLibs "${QRCODEGEN_LIBS}"
9845    QRCODEGEN_LIBS="${filteredlibs}"
9846else
9847    AC_MSG_RESULT([internal])
9848    SYSTEM_QRCODEGEN=
9849    BUILD_TYPE="$BUILD_TYPE QRCODEGEN"
9850fi
9851AC_SUBST(SYSTEM_QRCODEGEN)
9852AC_SUBST(QRCODEGEN_CFLAGS)
9853AC_SUBST(QRCODEGEN_LIBS)
9854
9855dnl ===================================================================
9856dnl Checking for altlinuxhyph
9857dnl ===================================================================
9858AC_MSG_CHECKING([which altlinuxhyph to use])
9859if test "$with_system_altlinuxhyph" = "yes"; then
9860    AC_MSG_RESULT([external])
9861    SYSTEM_HYPH=TRUE
9862    AC_CHECK_HEADER(hyphen.h, [],
9863       [ AC_MSG_ERROR(altlinuxhyph headers not found.)], [])
9864    AC_CHECK_MEMBER(struct _HyphenDict.cset, [],
9865       [ AC_MSG_ERROR(no. You are sure you have altlinuyhyph headers?)],
9866       [#include <hyphen.h>])
9867    AC_CHECK_LIB(hyphen, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhyphen],
9868        [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
9869    if test -z "$HYPHEN_LIB"; then
9870        AC_CHECK_LIB(hyph, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhyph],
9871           [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
9872    fi
9873    if test -z "$HYPHEN_LIB"; then
9874        AC_CHECK_LIB(hnj, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhnj],
9875           [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
9876    fi
9877else
9878    AC_MSG_RESULT([internal])
9879    SYSTEM_HYPH=
9880    BUILD_TYPE="$BUILD_TYPE HYPHEN"
9881    if test "$COM" = "MSC"; then
9882        HYPHEN_LIB="${WORKDIR}/LinkTarget/StaticLibrary/hyphen.lib"
9883    else
9884        HYPHEN_LIB="-L${WORKDIR}/UnpackedTarball/hyphen/.libs -lhyphen"
9885    fi
9886fi
9887AC_SUBST(SYSTEM_HYPH)
9888AC_SUBST(HYPHEN_LIB)
9889
9890dnl ===================================================================
9891dnl Checking for mythes
9892dnl ===================================================================
9893AC_MSG_CHECKING([which mythes to use])
9894if test "$with_system_mythes" = "yes"; then
9895    AC_MSG_RESULT([external])
9896    SYSTEM_MYTHES=TRUE
9897    AC_LANG_PUSH([C++])
9898    PKG_CHECK_MODULES(MYTHES, mythes, MYTHES_PKGCONFIG=yes, MYTHES_PKGCONFIG=no)
9899    if test "$MYTHES_PKGCONFIG" = "no"; then
9900        AC_CHECK_HEADER(mythes.hxx, [],
9901            [ AC_MSG_ERROR(mythes.hxx headers not found.)], [])
9902        AC_CHECK_LIB([mythes-1.2], [main], [:],
9903            [ MYTHES_FOUND=no], [])
9904    if test "$MYTHES_FOUND" = "no"; then
9905        AC_CHECK_LIB(mythes, main, [MYTHES_FOUND=yes],
9906                [ MYTHES_FOUND=no], [])
9907    fi
9908    if test "$MYTHES_FOUND" = "no"; then
9909        AC_MSG_ERROR([mythes library not found!.])
9910    fi
9911    fi
9912    AC_LANG_POP([C++])
9913    MYTHES_CFLAGS=$(printf '%s' "$MYTHES_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
9914    FilterLibs "${MYTHES_LIBS}"
9915    MYTHES_LIBS="${filteredlibs}"
9916else
9917    AC_MSG_RESULT([internal])
9918    SYSTEM_MYTHES=
9919    BUILD_TYPE="$BUILD_TYPE MYTHES"
9920    if test "$COM" = "MSC"; then
9921        MYTHES_LIBS="${WORKDIR}/LinkTarget/StaticLibrary/mythes.lib"
9922    else
9923        MYTHES_LIBS="-L${WORKDIR}/UnpackedTarball/mythes/.libs -lmythes-1.2"
9924    fi
9925fi
9926AC_SUBST(SYSTEM_MYTHES)
9927AC_SUBST(MYTHES_CFLAGS)
9928AC_SUBST(MYTHES_LIBS)
9929
9930dnl ===================================================================
9931dnl How should we build the linear programming solver ?
9932dnl ===================================================================
9933
9934ENABLE_COINMP=
9935AC_MSG_CHECKING([whether to build with CoinMP])
9936if test "$enable_coinmp" != "no"; then
9937    ENABLE_COINMP=TRUE
9938    AC_MSG_RESULT([yes])
9939    if test "$with_system_coinmp" = "yes"; then
9940        SYSTEM_COINMP=TRUE
9941        PKG_CHECK_MODULES(COINMP, coinmp coinutils)
9942        FilterLibs "${COINMP_LIBS}"
9943        COINMP_LIBS="${filteredlibs}"
9944    else
9945        BUILD_TYPE="$BUILD_TYPE COINMP"
9946    fi
9947else
9948    AC_MSG_RESULT([no])
9949fi
9950AC_SUBST(ENABLE_COINMP)
9951AC_SUBST(SYSTEM_COINMP)
9952AC_SUBST(COINMP_CFLAGS)
9953AC_SUBST(COINMP_LIBS)
9954
9955ENABLE_LPSOLVE=
9956AC_MSG_CHECKING([whether to build with lpsolve])
9957if test "$enable_lpsolve" != "no"; then
9958    ENABLE_LPSOLVE=TRUE
9959    AC_MSG_RESULT([yes])
9960else
9961    AC_MSG_RESULT([no])
9962fi
9963AC_SUBST(ENABLE_LPSOLVE)
9964
9965if test "$ENABLE_LPSOLVE" = TRUE; then
9966    AC_MSG_CHECKING([which lpsolve to use])
9967    if test "$with_system_lpsolve" = "yes"; then
9968        AC_MSG_RESULT([external])
9969        SYSTEM_LPSOLVE=TRUE
9970        AC_CHECK_HEADER(lpsolve/lp_lib.h, [],
9971           [ AC_MSG_ERROR(lpsolve headers not found.)], [])
9972        save_LIBS=$LIBS
9973        # some systems need this. Like Ubuntu....
9974        AC_CHECK_LIB(m, floor)
9975        AC_CHECK_LIB(dl, dlopen)
9976        AC_CHECK_LIB([lpsolve55], [make_lp], [:],
9977            [ AC_MSG_ERROR(lpsolve library not found or too old.)], [])
9978        LIBS=$save_LIBS
9979    else
9980        AC_MSG_RESULT([internal])
9981        SYSTEM_LPSOLVE=
9982        BUILD_TYPE="$BUILD_TYPE LPSOLVE"
9983    fi
9984fi
9985AC_SUBST(SYSTEM_LPSOLVE)
9986
9987dnl ===================================================================
9988dnl Checking for libexttextcat
9989dnl ===================================================================
9990libo_CHECK_SYSTEM_MODULE([libexttextcat],[LIBEXTTEXTCAT],[libexttextcat >= 3.4.1])
9991if test "$with_system_libexttextcat" = "yes"; then
9992    SYSTEM_LIBEXTTEXTCAT_DATA=file://`$PKG_CONFIG --variable=pkgdatadir libexttextcat`
9993fi
9994AC_SUBST(SYSTEM_LIBEXTTEXTCAT_DATA)
9995
9996dnl ===================================================================
9997dnl Checking for libnumbertext
9998dnl ===================================================================
9999AC_MSG_CHECKING([whether to use libnumbertext])
10000if test "$enable_libnumbertext" = "no"; then
10001    AC_MSG_RESULT([no])
10002    ENABLE_LIBNUMBERTEXT=
10003    SYSTEM_LIBNUMBERTEXT=
10004else
10005    AC_MSG_RESULT([yes])
10006    ENABLE_LIBNUMBERTEXT=TRUE
10007    libo_CHECK_SYSTEM_MODULE([libnumbertext],[LIBNUMBERTEXT],[libnumbertext >= 1.0.0])
10008    if test "$with_system_libnumbertext" = "yes"; then
10009        SYSTEM_LIBNUMBERTEXT_DATA=file://`$PKG_CONFIG --variable=pkgdatadir libnumbertext`
10010        SYSTEM_LIBNUMBERTEXT=YES
10011    else
10012        SYSTEM_LIBNUMBERTEXT=
10013        AC_LANG_PUSH([C++])
10014        save_CPPFLAGS=$CPPFLAGS
10015        CPPFLAGS="$CPPFLAGS $CXXFLAGS_CXX11"
10016        AC_CHECK_HEADERS([codecvt regex])
10017        AS_IF([test "x$ac_cv_header_codecvt" != xyes -o "x$ac_cv_header_regex" != xyes],
10018                [ ENABLE_LIBNUMBERTEXT=''
10019                  LIBNUMBERTEXT_CFLAGS=''
10020                  AC_MSG_WARN([No system-provided libnumbertext or codecvt/regex C++11 headers (min. libstdc++ 4.9).
10021                               Enable libnumbertext fallback (missing number to number name conversion).])
10022                ])
10023        CPPFLAGS=$save_CPPFLAGS
10024        AC_LANG_POP([C++])
10025    fi
10026    if test "$ENABLE_LIBNUMBERTEXT" = TRUE; then
10027        AC_DEFINE(ENABLE_LIBNUMBERTEXT)
10028    fi
10029fi
10030AC_SUBST(SYSTEM_LIBNUMBERTEXT)
10031AC_SUBST(SYSTEM_LIBNUMBERTEXT_DATA)
10032AC_SUBST(ENABLE_LIBNUMBERTEXT)
10033AC_SUBST(LIBNUMBERTEXT_CFLAGS)
10034
10035dnl ***************************************
10036dnl testing libc version for Linux...
10037dnl ***************************************
10038if test "$_os" = "Linux"; then
10039    AC_MSG_CHECKING([whether libc is >= 2.1.1])
10040    exec 6>/dev/null # no output
10041    AC_CHECK_LIB(c, gnu_get_libc_version, HAVE_LIBC=yes; export HAVE_LIBC)
10042    exec 6>&1 # output on again
10043    if test "$HAVE_LIBC"; then
10044        AC_MSG_RESULT([yes])
10045    else
10046        AC_MSG_ERROR([no, upgrade libc])
10047    fi
10048fi
10049
10050dnl =========================================
10051dnl Check for uuidgen
10052dnl =========================================
10053if test "$_os" = "WINNT" -a "$cross_compiling" != "yes"; then
10054    # presence is already tested above in the WINDOWS_SDK_HOME check
10055    UUIDGEN=uuidgen.exe
10056    AC_SUBST(UUIDGEN)
10057else
10058    AC_PATH_PROG([UUIDGEN], [uuidgen])
10059    if test -z "$UUIDGEN"; then
10060        AC_MSG_WARN([uuid is needed for building installation sets])
10061    fi
10062fi
10063
10064dnl ***************************************
10065dnl Checking for bison and flex
10066dnl ***************************************
10067AC_PATH_PROG(BISON, bison)
10068if test -z "$BISON"; then
10069    AC_MSG_ERROR([no bison found in \$PATH, install it])
10070else
10071    AC_MSG_CHECKING([the bison version])
10072    _bison_version=`$BISON --version | grep GNU | $SED -e 's@^[[^0-9]]*@@' -e 's@ .*@@' -e 's@,.*@@'`
10073    _bison_longver=`echo $_bison_version | $AWK -F. '{ print \$1*1000+\$2}'`
10074    # Accept newer than 2.0
10075    if test "$_bison_longver" -lt 2000; then
10076        AC_MSG_ERROR([failed ($BISON $_bison_version need 2.0+)])
10077    fi
10078fi
10079
10080AC_PATH_PROG(FLEX, flex)
10081if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
10082    FLEX=`cygpath -m $FLEX`
10083fi
10084if test -z "$FLEX"; then
10085    AC_MSG_ERROR([no flex found in \$PATH, install it])
10086else
10087    AC_MSG_CHECKING([the flex version])
10088    _flex_version=$($FLEX --version | $SED -e 's/^.*\([[[:digit:]]]\{1,\}\.[[[:digit:]]]\{1,\}\.[[[:digit:]]]\{1,\}\).*$/\1/')
10089    if test $(echo $_flex_version | $AWK -F. '{printf("%d%03d%03d", $1, $2, $3)}') -lt 2006000; then
10090        AC_MSG_ERROR([failed ($FLEX $_flex_version found, but need at least 2.6.0)])
10091    fi
10092fi
10093AC_SUBST([FLEX])
10094dnl ***************************************
10095dnl Checking for patch
10096dnl ***************************************
10097AC_PATH_PROG(PATCH, patch)
10098if test -z "$PATCH"; then
10099    AC_MSG_ERROR(["patch" not found in \$PATH, install it])
10100fi
10101
10102dnl On Solaris, FreeBSD or macOS, check if --with-gnu-patch was used
10103if test "$_os" = "SunOS" -o "$_os" = "FreeBSD" -o "$_os" = "Darwin"; then
10104    if test -z "$with_gnu_patch"; then
10105        GNUPATCH=$PATCH
10106    else
10107        if test -x "$with_gnu_patch"; then
10108            GNUPATCH=$with_gnu_patch
10109        else
10110            AC_MSG_ERROR([--with-gnu-patch did not point to an executable])
10111        fi
10112    fi
10113
10114    AC_MSG_CHECKING([whether $GNUPATCH is GNU patch])
10115    if $GNUPATCH --version | grep "Free Software Foundation" >/dev/null 2>/dev/null; then
10116        AC_MSG_RESULT([yes])
10117    else
10118        AC_MSG_ERROR([no, GNU patch needed. install or specify with --with-gnu-patch=/path/to/it])
10119    fi
10120else
10121    GNUPATCH=$PATCH
10122fi
10123
10124if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
10125    GNUPATCH=`cygpath -m $GNUPATCH`
10126fi
10127
10128dnl We also need to check for --with-gnu-cp
10129
10130if test -z "$with_gnu_cp"; then
10131    # check the place where the good stuff is hidden on Solaris...
10132    if test -x /usr/gnu/bin/cp; then
10133        GNUCP=/usr/gnu/bin/cp
10134    else
10135        AC_PATH_PROGS(GNUCP, gnucp cp)
10136    fi
10137    if test -z $GNUCP; then
10138        AC_MSG_ERROR([Neither gnucp nor cp found. Install GNU cp and/or specify --with-gnu-cp=/path/to/it])
10139    fi
10140else
10141    if test -x "$with_gnu_cp"; then
10142        GNUCP=$with_gnu_cp
10143    else
10144        AC_MSG_ERROR([--with-gnu-cp did not point to an executable])
10145    fi
10146fi
10147
10148if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
10149    GNUCP=`cygpath -m $GNUCP`
10150fi
10151
10152AC_MSG_CHECKING([whether $GNUCP is GNU cp from coreutils with preserve= support])
10153if $GNUCP --version 2>/dev/null | grep "coreutils" >/dev/null 2>/dev/null; then
10154    AC_MSG_RESULT([yes])
10155elif $GNUCP --version 2>/dev/null | grep "GNU fileutils" >/dev/null 2>/dev/null; then
10156    AC_MSG_RESULT([yes])
10157else
10158    case "$build_os" in
10159    darwin*|netbsd*|openbsd*|freebsd*|dragonfly*|aix*)
10160        x_GNUCP=[\#]
10161        GNUCP=''
10162        AC_MSG_RESULT([no gnucp found - using the system's cp command])
10163        ;;
10164    *)
10165        AC_MSG_ERROR([no, GNU cp needed. install or specify with --with-gnu-cp=/path/to/it])
10166        ;;
10167    esac
10168fi
10169
10170AC_SUBST(GNUPATCH)
10171AC_SUBST(GNUCP)
10172AC_SUBST(x_GNUCP)
10173
10174dnl ***************************************
10175dnl testing assembler path
10176dnl ***************************************
10177ML_EXE=""
10178if test "$_os" = "WINNT"; then
10179    if test "$BITNESS_OVERRIDE" = ""; then
10180        assembler=ml.exe
10181    else
10182        assembler=ml64.exe
10183    fi
10184
10185    AC_MSG_CHECKING([$CL_PATH/$assembler])
10186    if test -f "$CL_PATH/$assembler"; then
10187        AC_MSG_RESULT([found])
10188        ML_EXE="$CL_PATH/$assembler"
10189    else
10190        AC_MSG_ERROR([Configure did not find $assembler assembler.])
10191    fi
10192fi
10193
10194AC_SUBST(ML_EXE)
10195
10196dnl ===================================================================
10197dnl We need zip and unzip
10198dnl ===================================================================
10199AC_PATH_PROG(ZIP, zip)
10200test -z "$ZIP" && AC_MSG_ERROR([zip is required])
10201if ! "$ZIP" --filesync < /dev/null 2>/dev/null > /dev/null; then
10202    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],,)
10203fi
10204
10205AC_PATH_PROG(UNZIP, unzip)
10206test -z "$UNZIP" && AC_MSG_ERROR([unzip is required])
10207
10208dnl ===================================================================
10209dnl Zip must be a specific type for different build types.
10210dnl ===================================================================
10211if test $build_os = cygwin; then
10212    if test -n "`$ZIP -h | $GREP -i WinNT`"; then
10213        AC_MSG_ERROR([$ZIP is not the required Cygwin version of Info-ZIP's zip.exe.])
10214    fi
10215fi
10216
10217dnl ===================================================================
10218dnl We need touch with -h option support.
10219dnl ===================================================================
10220AC_PATH_PROG(TOUCH, touch)
10221test -z "$TOUCH" && AC_MSG_ERROR([touch is required])
10222touch warn
10223if ! "$TOUCH" -h warn 2>/dev/null > /dev/null; then
10224    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],,)
10225fi
10226
10227dnl ===================================================================
10228dnl Check for system epoxy
10229dnl ===================================================================
10230libo_CHECK_SYSTEM_MODULE([epoxy], [EPOXY], [epoxy >= 1.2], ["-I${WORKDIR}/UnpackedTarball/epoxy/include"])
10231
10232dnl ===================================================================
10233dnl Set vcl option: coordinate device in double or sal_Int32
10234dnl ===================================================================
10235
10236dnl disabled for now, we don't want subtle differences between OSs
10237dnl AC_MSG_CHECKING([Type to use for Device Pixel coordinates])
10238dnl if test "$_os" = "Darwin" -o  $_os = iOS ; then
10239dnl     AC_DEFINE(VCL_FLOAT_DEVICE_PIXEL)
10240dnl     AC_MSG_RESULT([double])
10241dnl else
10242dnl     AC_MSG_RESULT([sal_Int32])
10243dnl fi
10244
10245dnl ===================================================================
10246dnl Test which vclplugs have to be built.
10247dnl ===================================================================
10248R=""
10249if test "$USING_X11" != TRUE; then
10250    enable_gtk=no
10251    enable_gtk3=no
10252fi
10253GTK3_CFLAGS=""
10254GTK3_LIBS=""
10255ENABLE_GTK3=""
10256if test "x$enable_gtk3" = "xyes"; then
10257    if test "$with_system_cairo" = no; then
10258        AC_MSG_ERROR([System cairo required for gtk3 support, do not combine --enable-gtk3 with --without-system-cairo])
10259    fi
10260    : ${with_system_cairo:=yes}
10261    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="")
10262    if test "x$ENABLE_GTK3" = "xTRUE"; then
10263        AC_DEFINE(ENABLE_GTK3)
10264        R="gtk3"
10265        dnl Avoid installed by unpackaged files for now.
10266        if test -z "$PKGFORMAT"; then
10267            GOBJECT_INTROSPECTION_CHECK(INTROSPECTION_REQUIRED_VERSION)
10268        fi
10269    else
10270        AC_MSG_ERROR([gtk3 or dependent libraries of the correct versions, not found])
10271    fi
10272    GTK3_CFLAGS=$(printf '%s' "$GTK3_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10273    FilterLibs "${GTK3_LIBS}"
10274    GTK3_LIBS="${filteredlibs}"
10275
10276    dnl We require egl only for the gtk3 plugin. Otherwise we use glx.
10277    if test "$with_system_epoxy" != "yes"; then
10278        AC_CHECK_LIB(EGL, eglMakeCurrent, [:], AC_MSG_ERROR([libEGL required.]))
10279        AC_CHECK_HEADER(EGL/eglplatform.h, [],
10280                        [AC_MSG_ERROR(EGL headers not found. install mesa-libEGL-devel)], [])
10281    fi
10282fi
10283AC_SUBST(GTK3_LIBS)
10284AC_SUBST(GTK3_CFLAGS)
10285AC_SUBST(ENABLE_GTK3)
10286
10287ENABLE_GTK=""
10288if test "x$enable_gtk" = "xyes"; then
10289    if test "$with_system_cairo" = no; then
10290        AC_MSG_ERROR([System cairo required for gtk support, do not use --without-system-cairo or use --disable-gtk])
10291    fi
10292    : ${with_system_cairo:=yes}
10293    ENABLE_GTK="TRUE"
10294    AC_DEFINE(ENABLE_GTK)
10295    R="gtk $R"
10296fi
10297AC_SUBST(ENABLE_GTK)
10298
10299ENABLE_QT5=""
10300if test "x$enable_qt5" = "xyes"; then
10301    ENABLE_QT5="TRUE"
10302    AC_DEFINE(ENABLE_QT5)
10303    R="$R qt5"
10304fi
10305AC_SUBST(ENABLE_QT5)
10306
10307ENABLE_KDE5=""
10308if test "x$enable_kde5" = "xyes"; then
10309    ENABLE_KDE5="TRUE"
10310    AC_DEFINE(ENABLE_KDE5)
10311    R="$R kde5"
10312fi
10313AC_SUBST(ENABLE_KDE5)
10314
10315ENABLE_GTK3_KDE5=""
10316if test "x$enable_gtk3_kde5" = "xyes"; then
10317    ENABLE_GTK3_KDE5="TRUE"
10318    AC_DEFINE(ENABLE_GTK3_KDE5)
10319    R="$R gtk3_kde5"
10320fi
10321AC_SUBST(ENABLE_GTK3_KDE5)
10322
10323build_vcl_plugins="$R"
10324if test -z "$build_vcl_plugins"; then
10325    build_vcl_plugins="none"
10326fi
10327AC_MSG_NOTICE([VCLplugs to be built: $build_vcl_plugins])
10328
10329dnl ===================================================================
10330dnl check for dbus support
10331dnl ===================================================================
10332ENABLE_DBUS=""
10333DBUS_CFLAGS=""
10334DBUS_LIBS=""
10335DBUS_GLIB_CFLAGS=""
10336DBUS_GLIB_LIBS=""
10337DBUS_HAVE_GLIB=""
10338
10339if test "$enable_dbus" = "no"; then
10340    test_dbus=no
10341fi
10342
10343AC_MSG_CHECKING([whether to enable DBUS support])
10344if test "$test_dbus" = "yes"; then
10345    ENABLE_DBUS="TRUE"
10346    AC_MSG_RESULT([yes])
10347    PKG_CHECK_MODULES(DBUS, dbus-1 >= 0.60)
10348    AC_DEFINE(ENABLE_DBUS)
10349    DBUS_CFLAGS=$(printf '%s' "$DBUS_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10350    FilterLibs "${DBUS_LIBS}"
10351    DBUS_LIBS="${filteredlibs}"
10352
10353    # Glib is needed for BluetoothServer
10354    # Sets also DBUS_GLIB_CFLAGS/DBUS_GLIB_LIBS if successful.
10355    PKG_CHECK_MODULES(DBUS_GLIB,[glib-2.0 >= 2.4],
10356        [
10357            DBUS_HAVE_GLIB="TRUE"
10358            AC_DEFINE(DBUS_HAVE_GLIB,1)
10359        ],
10360        AC_MSG_WARN([[No Glib found, Bluetooth support will be disabled]])
10361    )
10362else
10363    AC_MSG_RESULT([no])
10364fi
10365
10366AC_SUBST(ENABLE_DBUS)
10367AC_SUBST(DBUS_CFLAGS)
10368AC_SUBST(DBUS_LIBS)
10369AC_SUBST(DBUS_GLIB_CFLAGS)
10370AC_SUBST(DBUS_GLIB_LIBS)
10371AC_SUBST(DBUS_HAVE_GLIB)
10372
10373AC_MSG_CHECKING([whether to enable Impress remote control])
10374if test -n "$enable_sdremote" -a "$enable_sdremote" != "no"; then
10375    AC_MSG_RESULT([yes])
10376    ENABLE_SDREMOTE=TRUE
10377    AC_MSG_CHECKING([whether to enable Bluetooth support in Impress remote control])
10378
10379    if test $OS = MACOSX && test "$MAC_OS_X_VERSION_MAX_ALLOWED" -ge 101500; then
10380        # The Bluetooth code doesn't compile with macOS SDK 10.15
10381        enable_sdremote_bluetooth=no
10382    fi
10383    # If not explicitly enabled or disabled, default
10384    if test -z "$enable_sdremote_bluetooth"; then
10385        case "$OS" in
10386        LINUX|MACOSX|WNT)
10387            # Default to yes for these
10388            enable_sdremote_bluetooth=yes
10389            ;;
10390        *)
10391            # otherwise no
10392            enable_sdremote_bluetooth=no
10393            ;;
10394        esac
10395    fi
10396    # $enable_sdremote_bluetooth is guaranteed non-empty now
10397
10398    if test "$enable_sdremote_bluetooth" != "no"; then
10399        if test "$OS" = "LINUX"; then
10400            if test "$ENABLE_DBUS" = "TRUE" -a "$DBUS_HAVE_GLIB" = "TRUE"; then
10401                AC_MSG_RESULT([yes])
10402                ENABLE_SDREMOTE_BLUETOOTH=TRUE
10403                dnl ===================================================================
10404                dnl Check for system bluez
10405                dnl ===================================================================
10406                AC_MSG_CHECKING([which Bluetooth header to use])
10407                if test "$with_system_bluez" = "yes"; then
10408                    AC_MSG_RESULT([external])
10409                    AC_CHECK_HEADER(bluetooth/bluetooth.h, [],
10410                        [AC_MSG_ERROR(bluetooth.h not found. install bluez)], [])
10411                    SYSTEM_BLUEZ=TRUE
10412                else
10413                    AC_MSG_RESULT([internal])
10414                    SYSTEM_BLUEZ=
10415                fi
10416            else
10417                AC_MSG_RESULT([no, dbus disabled])
10418                ENABLE_SDREMOTE_BLUETOOTH=
10419                SYSTEM_BLUEZ=
10420            fi
10421        else
10422            AC_MSG_RESULT([yes])
10423            ENABLE_SDREMOTE_BLUETOOTH=TRUE
10424            SYSTEM_BLUEZ=
10425        fi
10426    else
10427        AC_MSG_RESULT([no])
10428        ENABLE_SDREMOTE_BLUETOOTH=
10429        SYSTEM_BLUEZ=
10430    fi
10431else
10432    ENABLE_SDREMOTE=
10433    SYSTEM_BLUEZ=
10434    AC_MSG_RESULT([no])
10435fi
10436AC_SUBST(ENABLE_SDREMOTE)
10437AC_SUBST(ENABLE_SDREMOTE_BLUETOOTH)
10438AC_SUBST(SYSTEM_BLUEZ)
10439
10440dnl ===================================================================
10441dnl Check whether the gtk 2.0 libraries are available.
10442dnl ===================================================================
10443
10444GTK_CFLAGS=""
10445GTK_LIBS=""
10446if test  "$test_gtk" = "yes"; then
10447
10448    if test "$ENABLE_GTK" = "TRUE"; then
10449        PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.18.0 gdk-pixbuf-2.0 >= 2.2 ,,AC_MSG_ERROR([requirements to build the gtk-plugin not met. Use --disable-gtk or install the missing packages]))
10450        GTK_CFLAGS=$(printf '%s' "$GTK_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10451        FilterLibs "${GTK_LIBS}"
10452        GTK_LIBS="${filteredlibs}"
10453        PKG_CHECK_MODULES(GTHREAD, gthread-2.0,,AC_MSG_ERROR([requirements to build the gtk-plugin not met. Use --disable-gtk or install the missing packages]))
10454        BUILD_TYPE="$BUILD_TYPE GTK"
10455        GTHREAD_CFLAGS=$(printf '%s' "$GTK_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10456        FilterLibs "${GTHREAD_LIBS}"
10457        GTHREAD_LIBS="${filteredlibs}"
10458
10459        AC_MSG_CHECKING([whether to enable Gtk print dialog support])
10460        PKG_CHECK_MODULES([GTK_PRINT], [gtk+-unix-print-2.0 >= 2.10.0],
10461                          [ENABLE_GTK_PRINT="TRUE"],
10462                          [ENABLE_GTK_PRINT=""])
10463        GTK_PRINT_CFLAGS=$(printf '%s' "$GTK_PRINT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10464        FilterLibs "${GTK_PRINT_LIBS}"
10465        GTK_PRINT_LIBS="${filteredlibs}"
10466    fi
10467
10468    if test "$ENABLE_GTK" = "TRUE" || test "$ENABLE_GTK3" = "TRUE"; then
10469        AC_MSG_CHECKING([whether to enable GIO support])
10470        if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_gio" = "yes"; then
10471            dnl Need at least 2.26 for the dbus support.
10472            PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.26],
10473                              [ENABLE_GIO="TRUE"], [ENABLE_GIO=""])
10474            if test "$ENABLE_GIO" = "TRUE"; then
10475                AC_DEFINE(ENABLE_GIO)
10476                GIO_CFLAGS=$(printf '%s' "$GIO_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10477                FilterLibs "${GIO_LIBS}"
10478                GIO_LIBS="${filteredlibs}"
10479            fi
10480        else
10481            AC_MSG_RESULT([no])
10482        fi
10483    fi
10484fi
10485AC_SUBST(ENABLE_GIO)
10486AC_SUBST(GIO_CFLAGS)
10487AC_SUBST(GIO_LIBS)
10488AC_SUBST(GTK_CFLAGS)
10489AC_SUBST(GTK_LIBS)
10490AC_SUBST(GTHREAD_CFLAGS)
10491AC_SUBST(GTHREAD_LIBS)
10492AC_SUBST([ENABLE_GTK_PRINT])
10493AC_SUBST([GTK_PRINT_CFLAGS])
10494AC_SUBST([GTK_PRINT_LIBS])
10495
10496
10497dnl ===================================================================
10498
10499SPLIT_APP_MODULES=""
10500if test "$enable_split_app_modules" = "yes"; then
10501    SPLIT_APP_MODULES="TRUE"
10502fi
10503AC_SUBST(SPLIT_APP_MODULES)
10504
10505SPLIT_OPT_FEATURES=""
10506if test "$enable_split_opt_features" = "yes"; then
10507    SPLIT_OPT_FEATURES="TRUE"
10508fi
10509AC_SUBST(SPLIT_OPT_FEATURES)
10510
10511if test $_os = Darwin -o $_os = WINNT -o $_os = iOS; then
10512    if test "$enable_cairo_canvas" = yes; then
10513        AC_MSG_ERROR([The cairo canvas should not be used for this platform])
10514    fi
10515    enable_cairo_canvas=no
10516elif test -z "$enable_cairo_canvas"; then
10517    enable_cairo_canvas=yes
10518fi
10519
10520ENABLE_CAIRO_CANVAS=""
10521if test "$enable_cairo_canvas" = "yes"; then
10522    test_cairo=yes
10523    ENABLE_CAIRO_CANVAS="TRUE"
10524    AC_DEFINE(ENABLE_CAIRO_CANVAS)
10525fi
10526AC_SUBST(ENABLE_CAIRO_CANVAS)
10527
10528dnl ===================================================================
10529dnl Check whether the GStreamer libraries are available.
10530dnl ===================================================================
10531
10532ENABLE_GSTREAMER_1_0=""
10533
10534if test "$build_gstreamer_1_0" = "yes"; then
10535
10536    AC_MSG_CHECKING([whether to enable the GStreamer 1.0 avmedia backend])
10537    if test "$enable_avmedia" = yes -a "$enable_gstreamer_1_0" != no; then
10538        ENABLE_GSTREAMER_1_0="TRUE"
10539        AC_MSG_RESULT([yes])
10540        PKG_CHECK_MODULES( [GSTREAMER_1_0], [gstreamer-1.0 gstreamer-plugins-base-1.0 gstreamer-pbutils-1.0 gstreamer-video-1.0] )
10541        GSTREAMER_1_0_CFLAGS=$(printf '%s' "$GSTREAMER_1_0_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10542        FilterLibs "${GSTREAMER_1_0_LIBS}"
10543        GSTREAMER_1_0_LIBS="${filteredlibs}"
10544        AC_DEFINE(ENABLE_GSTREAMER_1_0)
10545    else
10546        AC_MSG_RESULT([no])
10547    fi
10548fi
10549AC_SUBST(GSTREAMER_1_0_CFLAGS)
10550AC_SUBST(GSTREAMER_1_0_LIBS)
10551AC_SUBST(ENABLE_GSTREAMER_1_0)
10552
10553dnl ===================================================================
10554dnl Check whether to build the VLC avmedia backend
10555dnl ===================================================================
10556
10557ENABLE_VLC=""
10558
10559AC_MSG_CHECKING([whether to enable the VLC avmedia backend])
10560if test "$enable_avmedia" = yes -a $_os != iOS -a $_os != Android -a "$enable_vlc" = yes; then
10561    ENABLE_VLC="TRUE"
10562    AC_MSG_RESULT([yes])
10563else
10564    AC_MSG_RESULT([no])
10565fi
10566AC_SUBST(ENABLE_VLC)
10567
10568ENABLE_OPENGL_TRANSITIONS=
10569ENABLE_OPENGL_CANVAS=
10570if test $_os = iOS -o $_os = Android -o "$ENABLE_FUZZERS" = "TRUE"; then
10571   : # disable
10572elif test "$_os" = "Darwin"; then
10573    # We use frameworks on macOS, no need for detail checks
10574    ENABLE_OPENGL_TRANSITIONS=TRUE
10575    AC_DEFINE(HAVE_FEATURE_OPENGL,1)
10576    ENABLE_OPENGL_CANVAS=TRUE
10577elif test $_os = WINNT; then
10578    ENABLE_OPENGL_TRANSITIONS=TRUE
10579    AC_DEFINE(HAVE_FEATURE_OPENGL,1)
10580    ENABLE_OPENGL_CANVAS=TRUE
10581else
10582    if test "$USING_X11" = TRUE; then
10583        AC_CHECK_LIB(GL, glBegin, [:], AC_MSG_ERROR([libGL required.]))
10584        ENABLE_OPENGL_TRANSITIONS=TRUE
10585        AC_DEFINE(HAVE_FEATURE_OPENGL,1)
10586        ENABLE_OPENGL_CANVAS=TRUE
10587    fi
10588fi
10589
10590AC_SUBST(ENABLE_OPENGL_TRANSITIONS)
10591AC_SUBST(ENABLE_OPENGL_CANVAS)
10592
10593dnl =================================================
10594dnl Check whether to build with OpenCL support.
10595dnl =================================================
10596
10597if test $_os != iOS -a $_os != Android -a "$ENABLE_FUZZERS" != "TRUE"; then
10598    # OPENCL in BUILD_TYPE and HAVE_FEATURE_OPENCL tell that OpenCL is potentially available on the
10599    # platform (optional at run-time, used through clew).
10600    BUILD_TYPE="$BUILD_TYPE OPENCL"
10601    AC_DEFINE(HAVE_FEATURE_OPENCL)
10602fi
10603
10604dnl =================================================
10605dnl Check whether to build with dconf support.
10606dnl =================================================
10607
10608if test $_os != Android -a $_os != iOS -a "$enable_dconf" != no; then
10609    PKG_CHECK_MODULES([DCONF], [dconf >= 0.15.2], [], [
10610        if test "$enable_dconf" = yes; then
10611            AC_MSG_ERROR([dconf not found])
10612        else
10613            enable_dconf=no
10614        fi])
10615fi
10616AC_MSG_CHECKING([whether to enable dconf])
10617if test $_os = Android -o $_os = iOS -o "$enable_dconf" = no; then
10618    DCONF_CFLAGS=
10619    DCONF_LIBS=
10620    ENABLE_DCONF=
10621    AC_MSG_RESULT([no])
10622else
10623    ENABLE_DCONF=TRUE
10624    AC_DEFINE(ENABLE_DCONF)
10625    AC_MSG_RESULT([yes])
10626fi
10627AC_SUBST([DCONF_CFLAGS])
10628AC_SUBST([DCONF_LIBS])
10629AC_SUBST([ENABLE_DCONF])
10630
10631# pdf import?
10632AC_MSG_CHECKING([whether to build the PDF import feature])
10633ENABLE_PDFIMPORT=
10634if test $_os != Android -a $_os != iOS -a \( -z "$enable_pdfimport" -o "$enable_pdfimport" = yes \); then
10635    AC_MSG_RESULT([yes])
10636    ENABLE_PDFIMPORT=TRUE
10637    AC_DEFINE(HAVE_FEATURE_PDFIMPORT)
10638else
10639    AC_MSG_RESULT([no])
10640fi
10641
10642# Pdfium?
10643AC_MSG_CHECKING([whether to build PDFium])
10644ENABLE_PDFIUM=
10645if test \( -z "$enable_pdfium" -a "$ENABLE_PDFIMPORT" == "TRUE" \) -o "$enable_pdfium" = yes; then
10646    AC_MSG_RESULT([yes])
10647    ENABLE_PDFIUM=TRUE
10648    AC_DEFINE(HAVE_FEATURE_PDFIUM)
10649    BUILD_TYPE="$BUILD_TYPE PDFIUM"
10650else
10651    AC_MSG_RESULT([no])
10652fi
10653AC_SUBST(ENABLE_PDFIUM)
10654
10655dnl ===================================================================
10656dnl Check for poppler
10657dnl ===================================================================
10658ENABLE_POPPLER=
10659AC_MSG_CHECKING([whether to build Poppler])
10660if test \( -z "$enable_poppler" -a "$ENABLE_PDFIMPORT" == "TRUE" \) -o "$enable_poppler" = yes; then
10661    AC_MSG_RESULT([yes])
10662    ENABLE_POPPLER=TRUE
10663    AC_DEFINE(HAVE_FEATURE_POPPLER)
10664else
10665    AC_MSG_RESULT([no])
10666fi
10667AC_SUBST(ENABLE_POPPLER)
10668
10669if test "$ENABLE_PDFIMPORT" == "TRUE" -a "$ENABLE_POPPLER" != "TRUE" -a "$ENABLE_PDFIUM" != "TRUE"; then
10670    AC_MSG_ERROR([Cannot import PDF without either Pdfium or Poppler; please enable either of them.])
10671fi
10672
10673if test "$ENABLE_PDFIMPORT" != "TRUE" -a \( "$ENABLE_POPPLER" == "TRUE" -o "$ENABLE_PDFIUM" == "TRUE" \); then
10674    AC_MSG_ERROR([Cannot enable Pdfium or Poppler when PDF importing is disabled; please enable PDF import first.])
10675fi
10676
10677if test "$ENABLE_PDFIMPORT" == "TRUE" -a "$ENABLE_POPPLER" == "TRUE"; then
10678    dnl ===================================================================
10679    dnl Check for system poppler
10680    dnl ===================================================================
10681    AC_MSG_CHECKING([which PDF import poppler to use])
10682    if test "$with_system_poppler" = "yes"; then
10683        AC_MSG_RESULT([external])
10684        SYSTEM_POPPLER=TRUE
10685        PKG_CHECK_MODULES( POPPLER, poppler >= 0.12.0 )
10686        AC_LANG_PUSH([C++])
10687        save_CXXFLAGS=$CXXFLAGS
10688        save_CPPFLAGS=$CPPFLAGS
10689        CXXFLAGS="$CXXFLAGS $POPPLER_CFLAGS"
10690        CPPFLAGS="$CPPFLAGS $POPPLER_CFLAGS"
10691        AC_CHECK_HEADER([cpp/poppler-version.h],
10692            [AC_DEFINE([HAVE_POPPLER_VERSION_H], 1)],
10693            [])
10694        CXXFLAGS=$save_CXXFLAGS
10695        CPPFLAGS=$save_CPPFLAGS
10696        AC_LANG_POP([C++])
10697        POPPLER_CFLAGS=$(printf '%s' "$POPPLER_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10698
10699        FilterLibs "${POPPLER_LIBS}"
10700        POPPLER_LIBS="${filteredlibs}"
10701    else
10702        AC_MSG_RESULT([internal])
10703        SYSTEM_POPPLER=
10704        BUILD_TYPE="$BUILD_TYPE POPPLER"
10705        AC_DEFINE([HAVE_POPPLER_VERSION_H], 1)
10706    fi
10707    AC_DEFINE([ENABLE_PDFIMPORT],1)
10708fi
10709AC_SUBST(ENABLE_PDFIMPORT)
10710AC_SUBST(SYSTEM_POPPLER)
10711AC_SUBST(POPPLER_CFLAGS)
10712AC_SUBST(POPPLER_LIBS)
10713
10714SYSTEM_GPGMEPP=
10715
10716if test "$build_for_ios" = "YES"; then
10717    AC_MSG_CHECKING([whether gpgmepp should be disabled due to iOS])
10718    AC_MSG_RESULT([yes])
10719elif test "$enable_mpl_subset" = "yes"; then
10720    AC_MSG_CHECKING([whether gpgmepp should be disabled due to building just MPL])
10721    AC_MSG_RESULT([yes])
10722elif test "$enable_fuzzers" = "yes"; then
10723    AC_MSG_CHECKING([whether gpgmepp should be disabled due to oss-fuzz])
10724    AC_MSG_RESULT([yes])
10725elif test "$_os" = "Linux" -o "$_os" = "Darwin" -o "$_os" = "WINNT" ; then
10726    dnl ===================================================================
10727    dnl Check for system gpgme
10728    dnl ===================================================================
10729    AC_MSG_CHECKING([which gpgmepp to use])
10730    if test "$with_system_gpgmepp" = "yes"; then
10731        AC_MSG_RESULT([external])
10732        SYSTEM_GPGMEPP=TRUE
10733
10734        # C++ library doesn't come with fancy gpgmepp-config, check for headers the old-fashioned way
10735        AC_CHECK_HEADER(gpgme++/gpgmepp_version.h, [ GPGMEPP_CFLAGS=-I/usr/include/gpgme++ ],
10736            [AC_MSG_ERROR([gpgmepp headers not found, install gpgmepp development package])], [])
10737        # progress_callback is the only func with plain C linkage
10738        # checking for it also filters out older, KDE-dependent libgpgmepp versions
10739        AC_CHECK_LIB(gpgmepp, progress_callback, [ GPGMEPP_LIBS=-lgpgmepp ],
10740            [AC_MSG_ERROR(gpgmepp not found or not functional)], [])
10741        AC_CHECK_HEADER(gpgme.h, [],
10742            [AC_MSG_ERROR([gpgme headers not found, install gpgme development package])], [])
10743    else
10744        AC_MSG_RESULT([internal])
10745        BUILD_TYPE="$BUILD_TYPE LIBGPGERROR LIBASSUAN GPGMEPP"
10746        AC_DEFINE([GPGME_CAN_EXPORT_MINIMAL_KEY])
10747
10748        GPG_ERROR_CFLAGS="-I${WORKDIR}/UnpackedTarball/libgpg-error/src"
10749        LIBASSUAN_CFLAGS="-I${WORKDIR}/UnpackedTarball/libassuan/src"
10750        if test "$_os" != "WINNT"; then
10751            GPG_ERROR_LIBS="-L${WORKDIR}/UnpackedTarball/libgpg-error/src/.libs -lgpg-error"
10752            LIBASSUAN_LIBS="-L${WORKDIR}/UnpackedTarball/libassuan/src/.libs -lassuan"
10753        elif test "$host_cpu" = "i686" -a "$WINDOWS_SDK_ARCH" = "x64"; then
10754            AC_MSG_ERROR(gpgme cannot be built on cygwin32 for Win64.)
10755        fi
10756    fi
10757    ENABLE_GPGMEPP=TRUE
10758    AC_DEFINE([HAVE_FEATURE_GPGME])
10759    AC_PATH_PROG(GPG, gpg)
10760    # TODO: Windows's cygwin gpg does not seem to work with our gpgme,
10761    # so let's exclude that manually for the moment
10762    if test -n "$GPG" -a "$_os" != "WINNT"; then
10763        # make sure we not only have a working gpgme, but a full working
10764        # gpg installation to run OpenPGP signature verification
10765        AC_DEFINE([HAVE_FEATURE_GPGVERIFY])
10766    fi
10767    if test "$_os" = "Linux"; then
10768      uid=`id -u`
10769      AC_MSG_CHECKING([for /run/user/$uid])
10770      if test -d /run/user/$uid; then
10771        AC_MSG_RESULT([yes])
10772        AC_PATH_PROG(GPGCONF, gpgconf)
10773
10774        # Older versions of gpgconf are not working as expected, since
10775        # `gpgconf --remove-socketdir` fails to exit any gpg-agent daemon operating
10776        # on that socket dir that has (indirectly) been started by the tests in xmlsecurity/qa/unit/signing/signing.cxx
10777        # (see commit message of f0305ec0a7d199e605511844d9d6af98b66d4bfd%5E )
10778        AC_MSG_CHECKING([whether version of gpgconf is suitable ... ])
10779        GPGCONF_VERSION=`"$GPGCONF" --version | "$AWK" '/^gpgconf \(GnuPG\)/{print $3}'`
10780        GPGCONF_NUMVER=`echo $GPGCONF_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
10781        if test "$GPGCONF_VERSION" = "2.2_OOo" -o "$GPGCONF_NUMVER" -ge "020200"; then
10782          AC_MSG_RESULT([yes, $GPGCONF_VERSION])
10783          AC_MSG_CHECKING([for gpgconf --create-socketdir... ])
10784          if $GPGCONF --dump-options > /dev/null ; then
10785            if $GPGCONF --dump-options | grep -q create-socketdir ; then
10786              AC_MSG_RESULT([yes])
10787              AC_DEFINE([HAVE_GPGCONF_SOCKETDIR])
10788              AC_DEFINE_UNQUOTED([GPGME_GPGCONF], ["$GPGCONF"])
10789            else
10790              AC_MSG_RESULT([no])
10791            fi
10792          else
10793            AC_MSG_RESULT([no. missing or broken gpgconf?])
10794          fi
10795        else
10796          AC_MSG_RESULT([no, $GPGCONF_VERSION])
10797        fi
10798      else
10799        AC_MSG_RESULT([no])
10800     fi
10801   fi
10802fi
10803AC_SUBST(ENABLE_GPGMEPP)
10804AC_SUBST(SYSTEM_GPGMEPP)
10805AC_SUBST(GPG_ERROR_CFLAGS)
10806AC_SUBST(GPG_ERROR_LIBS)
10807AC_SUBST(LIBASSUAN_CFLAGS)
10808AC_SUBST(LIBASSUAN_LIBS)
10809AC_SUBST(GPGMEPP_CFLAGS)
10810AC_SUBST(GPGMEPP_LIBS)
10811
10812AC_MSG_CHECKING([whether to build the Wiki Publisher extension])
10813if test "x$enable_ext_wiki_publisher" = "xyes" -a "x$enable_extension_integration" != "xno" -a "$with_java" != "no"; then
10814    AC_MSG_RESULT([yes])
10815    ENABLE_MEDIAWIKI=TRUE
10816    BUILD_TYPE="$BUILD_TYPE XSLTML"
10817    if test  "x$with_java" = "xno"; then
10818        AC_MSG_ERROR([Wiki Publisher requires Java! Enable Java if you want to build it.])
10819    fi
10820else
10821    AC_MSG_RESULT([no])
10822    ENABLE_MEDIAWIKI=
10823    SCPDEFS="$SCPDEFS -DWITHOUT_EXTENSION_MEDIAWIKI"
10824fi
10825AC_SUBST(ENABLE_MEDIAWIKI)
10826
10827AC_MSG_CHECKING([whether to build the Report Builder])
10828if test "$enable_report_builder" != "no" -a "$with_java" != "no"; then
10829    AC_MSG_RESULT([yes])
10830    ENABLE_REPORTBUILDER=TRUE
10831    AC_MSG_CHECKING([which jfreereport libs to use])
10832    if test "$with_system_jfreereport" = "yes"; then
10833        SYSTEM_JFREEREPORT=TRUE
10834        AC_MSG_RESULT([external])
10835        if test -z $SAC_JAR; then
10836            SAC_JAR=/usr/share/java/sac.jar
10837        fi
10838        if ! test -f $SAC_JAR; then
10839             AC_MSG_ERROR(sac.jar not found.)
10840        fi
10841
10842        if test -z $LIBXML_JAR; then
10843            if test -f /usr/share/java/libxml-1.0.0.jar; then
10844                LIBXML_JAR=/usr/share/java/libxml-1.0.0.jar
10845            elif test -f /usr/share/java/libxml.jar; then
10846                LIBXML_JAR=/usr/share/java/libxml.jar
10847            else
10848                AC_MSG_ERROR(libxml.jar replacement not found.)
10849            fi
10850        elif ! test -f $LIBXML_JAR; then
10851            AC_MSG_ERROR(libxml.jar not found.)
10852        fi
10853
10854        if test -z $FLUTE_JAR; then
10855            if test -f/usr/share/java/flute-1.3.0.jar; then
10856                FLUTE_JAR=/usr/share/java/flute-1.3.0.jar
10857            elif test -f /usr/share/java/flute.jar; then
10858                FLUTE_JAR=/usr/share/java/flute.jar
10859            else
10860                AC_MSG_ERROR(flute-1.3.0.jar replacement not found.)
10861            fi
10862        elif ! test -f $FLUTE_JAR; then
10863            AC_MSG_ERROR(flute-1.3.0.jar not found.)
10864        fi
10865
10866        if test -z $JFREEREPORT_JAR; then
10867            if test -f /usr/share/java/flow-engine-0.9.2.jar; then
10868                JFREEREPORT_JAR=/usr/share/java/flow-engine-0.9.2.jar
10869            elif test -f /usr/share/java/flow-engine.jar; then
10870                JFREEREPORT_JAR=/usr/share/java/flow-engine.jar
10871            else
10872                AC_MSG_ERROR(jfreereport.jar replacement not found.)
10873            fi
10874        elif ! test -f  $JFREEREPORT_JAR; then
10875                AC_MSG_ERROR(jfreereport.jar not found.)
10876        fi
10877
10878        if test -z $LIBLAYOUT_JAR; then
10879            if test -f /usr/share/java/liblayout-0.2.9.jar; then
10880                LIBLAYOUT_JAR=/usr/share/java/liblayout-0.2.9.jar
10881            elif test -f /usr/share/java/liblayout.jar; then
10882                LIBLAYOUT_JAR=/usr/share/java/liblayout.jar
10883            else
10884                AC_MSG_ERROR(liblayout.jar replacement not found.)
10885            fi
10886        elif ! test -f $LIBLAYOUT_JAR; then
10887                AC_MSG_ERROR(liblayout.jar not found.)
10888        fi
10889
10890        if test -z $LIBLOADER_JAR; then
10891            if test -f /usr/share/java/libloader-1.0.0.jar; then
10892                LIBLOADER_JAR=/usr/share/java/libloader-1.0.0.jar
10893            elif test -f /usr/share/java/libloader.jar; then
10894                LIBLOADER_JAR=/usr/share/java/libloader.jar
10895            else
10896                AC_MSG_ERROR(libloader.jar replacement not found.)
10897            fi
10898        elif ! test -f  $LIBLOADER_JAR; then
10899            AC_MSG_ERROR(libloader.jar not found.)
10900        fi
10901
10902        if test -z $LIBFORMULA_JAR; then
10903            if test -f /usr/share/java/libformula-0.2.0.jar; then
10904                LIBFORMULA_JAR=/usr/share/java/libformula-0.2.0.jar
10905            elif test -f /usr/share/java/libformula.jar; then
10906                LIBFORMULA_JAR=/usr/share/java/libformula.jar
10907            else
10908                AC_MSG_ERROR(libformula.jar replacement not found.)
10909            fi
10910        elif ! test -f $LIBFORMULA_JAR; then
10911                AC_MSG_ERROR(libformula.jar not found.)
10912        fi
10913
10914        if test -z $LIBREPOSITORY_JAR; then
10915            if test -f /usr/share/java/librepository-1.0.0.jar; then
10916                LIBREPOSITORY_JAR=/usr/share/java/librepository-1.0.0.jar
10917            elif test -f /usr/share/java/librepository.jar; then
10918                LIBREPOSITORY_JAR=/usr/share/java/librepository.jar
10919            else
10920                AC_MSG_ERROR(librepository.jar replacement not found.)
10921            fi
10922        elif ! test -f $LIBREPOSITORY_JAR; then
10923            AC_MSG_ERROR(librepository.jar not found.)
10924        fi
10925
10926        if test -z $LIBFONTS_JAR; then
10927            if test -f /usr/share/java/libfonts-1.0.0.jar; then
10928                LIBFONTS_JAR=/usr/share/java/libfonts-1.0.0.jar
10929            elif test -f /usr/share/java/libfonts.jar; then
10930                LIBFONTS_JAR=/usr/share/java/libfonts.jar
10931            else
10932                AC_MSG_ERROR(libfonts.jar replacement not found.)
10933            fi
10934        elif ! test -f $LIBFONTS_JAR; then
10935                AC_MSG_ERROR(libfonts.jar not found.)
10936        fi
10937
10938        if test -z $LIBSERIALIZER_JAR; then
10939            if test -f /usr/share/java/libserializer-1.0.0.jar; then
10940                LIBSERIALIZER_JAR=/usr/share/java/libserializer-1.0.0.jar
10941            elif test -f /usr/share/java/libserializer.jar; then
10942                LIBSERIALIZER_JAR=/usr/share/java/libserializer.jar
10943            else
10944                AC_MSG_ERROR(libserializer.jar replacement not found.)
10945            fi
10946        elif ! test -f $LIBSERIALIZER_JAR; then
10947                AC_MSG_ERROR(libserializer.jar not found.)
10948        fi
10949
10950        if test -z $LIBBASE_JAR; then
10951            if test -f /usr/share/java/libbase-1.0.0.jar; then
10952                LIBBASE_JAR=/usr/share/java/libbase-1.0.0.jar
10953            elif test -f /usr/share/java/libbase.jar; then
10954                LIBBASE_JAR=/usr/share/java/libbase.jar
10955            else
10956                AC_MSG_ERROR(libbase.jar replacement not found.)
10957            fi
10958        elif ! test -f $LIBBASE_JAR; then
10959            AC_MSG_ERROR(libbase.jar not found.)
10960        fi
10961
10962    else
10963        AC_MSG_RESULT([internal])
10964        SYSTEM_JFREEREPORT=
10965        BUILD_TYPE="$BUILD_TYPE JFREEREPORT"
10966        NEED_ANT=TRUE
10967    fi
10968else
10969    AC_MSG_RESULT([no])
10970    ENABLE_REPORTBUILDER=
10971    SYSTEM_JFREEREPORT=
10972fi
10973AC_SUBST(ENABLE_REPORTBUILDER)
10974AC_SUBST(SYSTEM_JFREEREPORT)
10975AC_SUBST(SAC_JAR)
10976AC_SUBST(LIBXML_JAR)
10977AC_SUBST(FLUTE_JAR)
10978AC_SUBST(JFREEREPORT_JAR)
10979AC_SUBST(LIBBASE_JAR)
10980AC_SUBST(LIBLAYOUT_JAR)
10981AC_SUBST(LIBLOADER_JAR)
10982AC_SUBST(LIBFORMULA_JAR)
10983AC_SUBST(LIBREPOSITORY_JAR)
10984AC_SUBST(LIBFONTS_JAR)
10985AC_SUBST(LIBSERIALIZER_JAR)
10986
10987# this has to be here because both the Wiki Publisher and the SRB use
10988# commons-logging
10989COMMONS_LOGGING_VERSION=1.2
10990if test "$ENABLE_REPORTBUILDER" = "TRUE"; then
10991    AC_MSG_CHECKING([which Apache commons-* libs to use])
10992    if test "$with_system_apache_commons" = "yes"; then
10993        SYSTEM_APACHE_COMMONS=TRUE
10994        AC_MSG_RESULT([external])
10995        if test -z $COMMONS_LOGGING_JAR; then
10996            if test -f /usr/share/java/commons-logging-${COMMONS_LOGGING_VERSION}.jar; then
10997               COMMONS_LOGGING_JAR=/usr/share/java/commons-logging-${COMMONS_LOGGING_VERSION}.jar
10998           elif test -f /usr/share/java/commons-logging.jar; then
10999                COMMONS_LOGGING_JAR=/usr/share/java/commons-logging.jar
11000            else
11001                AC_MSG_ERROR(commons-logging.jar replacement not found.)
11002            fi
11003        elif ! test -f $COMMONS_LOGGING_JAR; then
11004            AC_MSG_ERROR(commons-logging.jar not found.)
11005        fi
11006    else
11007        AC_MSG_RESULT([internal])
11008        SYSTEM_APACHE_COMMONS=
11009        BUILD_TYPE="$BUILD_TYPE APACHE_COMMONS"
11010        NEED_ANT=TRUE
11011    fi
11012fi
11013AC_SUBST(SYSTEM_APACHE_COMMONS)
11014AC_SUBST(COMMONS_LOGGING_JAR)
11015AC_SUBST(COMMONS_LOGGING_VERSION)
11016
11017# scripting provider for BeanShell?
11018AC_MSG_CHECKING([whether to build support for scripts in BeanShell])
11019if test "${enable_scripting_beanshell}" != "no" -a "x$with_java" != "xno"; then
11020    AC_MSG_RESULT([yes])
11021    ENABLE_SCRIPTING_BEANSHELL=TRUE
11022
11023    dnl ===================================================================
11024    dnl Check for system beanshell
11025    dnl ===================================================================
11026    AC_MSG_CHECKING([which beanshell to use])
11027    if test "$with_system_beanshell" = "yes"; then
11028        AC_MSG_RESULT([external])
11029        SYSTEM_BSH=TRUE
11030        if test -z $BSH_JAR; then
11031            BSH_JAR=/usr/share/java/bsh.jar
11032        fi
11033        if ! test -f $BSH_JAR; then
11034            AC_MSG_ERROR(bsh.jar not found.)
11035        fi
11036    else
11037        AC_MSG_RESULT([internal])
11038        SYSTEM_BSH=
11039        BUILD_TYPE="$BUILD_TYPE BSH"
11040    fi
11041else
11042    AC_MSG_RESULT([no])
11043    ENABLE_SCRIPTING_BEANSHELL=
11044    SCPDEFS="$SCPDEFS -DWITHOUT_SCRIPTING_BEANSHELL"
11045fi
11046AC_SUBST(ENABLE_SCRIPTING_BEANSHELL)
11047AC_SUBST(SYSTEM_BSH)
11048AC_SUBST(BSH_JAR)
11049
11050# scripting provider for JavaScript?
11051AC_MSG_CHECKING([whether to build support for scripts in JavaScript])
11052if test "${enable_scripting_javascript}" != "no" -a "x$with_java" != "xno"; then
11053    AC_MSG_RESULT([yes])
11054    ENABLE_SCRIPTING_JAVASCRIPT=TRUE
11055
11056    dnl ===================================================================
11057    dnl Check for system rhino
11058    dnl ===================================================================
11059    AC_MSG_CHECKING([which rhino to use])
11060    if test "$with_system_rhino" = "yes"; then
11061        AC_MSG_RESULT([external])
11062        SYSTEM_RHINO=TRUE
11063        if test -z $RHINO_JAR; then
11064            RHINO_JAR=/usr/share/java/js.jar
11065        fi
11066        if ! test -f $RHINO_JAR; then
11067            AC_MSG_ERROR(js.jar not found.)
11068        fi
11069    else
11070        AC_MSG_RESULT([internal])
11071        SYSTEM_RHINO=
11072        BUILD_TYPE="$BUILD_TYPE RHINO"
11073        NEED_ANT=TRUE
11074    fi
11075else
11076    AC_MSG_RESULT([no])
11077    ENABLE_SCRIPTING_JAVASCRIPT=
11078    SCPDEFS="$SCPDEFS -DWITHOUT_SCRIPTING_JAVASCRIPT"
11079fi
11080AC_SUBST(ENABLE_SCRIPTING_JAVASCRIPT)
11081AC_SUBST(SYSTEM_RHINO)
11082AC_SUBST(RHINO_JAR)
11083
11084# This is only used in Qt5/KDE5 checks to determine if /usr/lib64
11085# paths should be added to library search path. So lets put all 64-bit
11086# platforms there.
11087supports_multilib=
11088case "$host_cpu" in
11089x86_64 | powerpc64 | powerpc64le | s390x | aarch64 | mips64 | mips64el)
11090    if test "$SAL_TYPES_SIZEOFLONG" = "8"; then
11091        supports_multilib="yes"
11092    fi
11093    ;;
11094*)
11095    ;;
11096esac
11097
11098dnl ===================================================================
11099dnl QT5 Integration
11100dnl ===================================================================
11101
11102QT5_CFLAGS=""
11103QT5_LIBS=""
11104QMAKE5="qmake"
11105MOC5="moc"
11106QT5_GOBJECT_CFLAGS=""
11107QT5_GOBJECT_LIBS=""
11108QT5_HAVE_GOBJECT=""
11109if test \( "$test_kde5" = "yes" -a "$ENABLE_KDE5" = "TRUE" \) -o \
11110        \( "$test_qt5" = "yes" -a "$ENABLE_QT5" = "TRUE" \) -o \
11111        \( "$test_gtk3_kde5" = "yes" -a "$ENABLE_GTK3_KDE5" = "TRUE" \)
11112then
11113    qt5_incdirs="$QT5INC /usr/include/qt5 /usr/include $x_includes"
11114    qt5_libdirs="$QT5LIB /usr/lib/qt5 /usr/lib $x_libraries"
11115
11116    if test -n "$supports_multilib"; then
11117        qt5_libdirs="$qt5_libdirs /usr/lib64/qt5 /usr/lib64/qt /usr/lib64"
11118    fi
11119
11120    qt5_test_include="QtWidgets/qapplication.h"
11121    qt5_test_library="libQt5Widgets.so"
11122
11123    dnl Check for qmake5
11124    AC_PATH_PROGS( QMAKE5, [qmake-qt5 qmake], no, [$QT5DIR/bin:$PATH] )
11125    if test "$QMAKE5" = "no"; then
11126        AC_MSG_ERROR([Qmake not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
11127    else
11128        qmake5_test_ver="`$QMAKE5 -v 2>&1 | $SED -n -e 's/^Using Qt version \(5\.[[0-9.]]\+\).*$/\1/p'`"
11129        if test -z "$qmake5_test_ver"; then
11130            AC_MSG_ERROR([Wrong qmake for Qt5 found. Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
11131        fi
11132        qmake5_minor_version="`echo $qmake5_test_ver | cut -d. -f2`"
11133        qt5_minimal_minor="6"
11134        if test "$qmake5_minor_version" -lt "$qt5_minimal_minor"; then
11135            AC_MSG_ERROR([The minimal supported Qt5 version is 5.${qt5_minimal_minor}, but your 'qmake -v' reports Qt5 version $qmake5_test_ver.])
11136        else
11137            AC_MSG_NOTICE([Detected Qt5 version: $qmake5_test_ver])
11138        fi
11139    fi
11140
11141    qt5_incdirs="`$QMAKE5 -query QT_INSTALL_HEADERS` $qt5_incdirs"
11142    qt5_libdirs="`$QMAKE5 -query QT_INSTALL_LIBS` $qt5_libdirs"
11143
11144    AC_MSG_CHECKING([for Qt5 headers])
11145    qt5_incdir="no"
11146    for inc_dir in $qt5_incdirs; do
11147        if test -r "$inc_dir/$qt5_test_include"; then
11148            qt5_incdir="$inc_dir"
11149            break
11150        fi
11151    done
11152    AC_MSG_RESULT([$qt5_incdir])
11153    if test "x$qt5_incdir" = "xno"; then
11154        AC_MSG_ERROR([Qt5 headers not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
11155    fi
11156
11157    AC_MSG_CHECKING([for Qt5 libraries])
11158    qt5_libdir="no"
11159    for lib_dir in $qt5_libdirs; do
11160        if test -r "$lib_dir/$qt5_test_library"; then
11161            qt5_libdir="$lib_dir"
11162            break
11163        fi
11164    done
11165    AC_MSG_RESULT([$qt5_libdir])
11166    if test "x$qt5_libdir" = "xno"; then
11167        AC_MSG_ERROR([Qt5 libraries not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
11168    fi
11169
11170    QT5_CFLAGS="-I$qt5_incdir -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT"
11171    QT5_CFLAGS=$(printf '%s' "$QT5_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11172    QT5_LIBS="-L$qt5_libdir -lQt5Core -lQt5Gui -lQt5Widgets -lQt5Network"
11173
11174    if test "$USING_X11" = TRUE; then
11175        PKG_CHECK_MODULES(QT5_XCB,[xcb],,[AC_MSG_ERROR([XCB not found, which is needed for correct app grouping in X11.])])
11176        QT5_CFLAGS="$QT5_CFLAGS $QT5_XCB_CFLAGS"
11177        QT5_LIBS="$QT5_LIBS $QT5_XCB_LIBS -lQt5X11Extras"
11178        QT5_USING_X11=1
11179        AC_DEFINE(QT5_USING_X11)
11180    fi
11181
11182    dnl Check for Meta Object Compiler
11183
11184    AC_PATH_PROGS( MOC5, [moc-qt5 moc], no, [`dirname $qt5_libdir`/bin:$QT5DIR/bin:$PATH] )
11185    if test "$MOC5" = "no"; then
11186        AC_MSG_ERROR([Qt Meta Object Compiler not found.  Please specify
11187the root of your Qt installation by exporting QT5DIR before running "configure".])
11188    fi
11189
11190    if test "$build_gstreamer_1_0" = "yes"; then
11191        PKG_CHECK_MODULES(QT5_GOBJECT,[gobject-2.0], [
11192                QT5_HAVE_GOBJECT=1
11193                AC_DEFINE(QT5_HAVE_GOBJECT)
11194            ],
11195            AC_MSG_WARN([[No GObject found, can't use QWidget GStreamer sink on wayland!]])
11196        )
11197    fi
11198fi
11199AC_SUBST(QT5_CFLAGS)
11200AC_SUBST(QT5_LIBS)
11201AC_SUBST(MOC5)
11202AC_SUBST(QT5_GOBJECT_CFLAGS)
11203AC_SUBST(QT5_GOBJECT_LIBS)
11204AC_SUBST(QT5_HAVE_GOBJECT)
11205
11206dnl ===================================================================
11207dnl KDE5 Integration
11208dnl ===================================================================
11209
11210KF5_CFLAGS=""
11211KF5_LIBS=""
11212KF5_CONFIG="kf5-config"
11213if test \( "$test_kde5" = "yes" -a "$ENABLE_KDE5" = "TRUE" \) -o \
11214        \( "$test_kf5" = "yes" -a "$ENABLE_KF5" = "TRUE" \) -o \
11215        \( "$test_gtk3_kde5" = "yes" -a "$ENABLE_GTK3_KDE5" = "TRUE" \)
11216then
11217    if test "$OS" = "HAIKU"; then
11218        haiku_arch="`echo $RTL_ARCH | tr X x`"
11219        kf5_haiku_incdirs="`findpaths -c ' ' -a $haiku_arch B_FIND_PATH_HEADERS_DIRECTORY`"
11220        kf5_haiku_libdirs="`findpaths -c ' ' -a $haiku_arch B_FIND_PATH_DEVELOP_LIB_DIRECTORY`"
11221    fi
11222
11223    kf5_incdirs="$KF5INC /usr/include $kf5_haiku_incdirs $x_includes"
11224    kf5_libdirs="$KF5LIB /usr/lib /usr/lib/kf5 /usr/lib/kf5/devel $kf5_haiku_libdirs $x_libraries"
11225    if test -n "$supports_multilib"; then
11226        kf5_libdirs="$kf5_libdirs /usr/lib64 /usr/lib64/kf5 /usr/lib64/kf5/devel"
11227    fi
11228
11229    kf5_test_include="KF5/kcoreaddons_version.h"
11230    kf5_test_library="libKF5CoreAddons.so"
11231    kf5_libdirs="$qt5_libdir $kf5_libdirs"
11232
11233    dnl kf5 KDE4 support compatibility installed
11234    AC_PATH_PROG( KF5_CONFIG, $KF5_CONFIG, no, )
11235    if test "$KF5_CONFIG" != "no"; then
11236        kf5_incdirs="`$KF5_CONFIG --path include` $kf5_incdirs"
11237        kf5_libdirs="`$KF5_CONFIG --path lib` $kf5_libdirs"
11238    fi
11239
11240    dnl Check for KF5 headers
11241    AC_MSG_CHECKING([for KF5 headers])
11242    kf5_incdir="no"
11243    for kf5_check in $kf5_incdirs; do
11244        if test -r "$kf5_check/$kf5_test_include"; then
11245            kf5_incdir="$kf5_check/KF5"
11246            break
11247        fi
11248    done
11249    AC_MSG_RESULT([$kf5_incdir])
11250    if test "x$kf5_incdir" = "xno"; then
11251        AC_MSG_ERROR([KF5 headers not found.  Please specify the root of your KF5 installation by exporting KF5DIR before running "configure".])
11252    fi
11253
11254    dnl Check for KF5 libraries
11255    AC_MSG_CHECKING([for KF5 libraries])
11256    kf5_libdir="no"
11257    for kf5_check in $kf5_libdirs; do
11258        if test -r "$kf5_check/$kf5_test_library"; then
11259            kf5_libdir="$kf5_check"
11260            break
11261        fi
11262    done
11263
11264    AC_MSG_RESULT([$kf5_libdir])
11265    if test "x$kf5_libdir" = "xno"; then
11266        AC_MSG_ERROR([KF5 libraries not found.  Please specify the root of your KF5 installation by exporting KF5DIR before running "configure".])
11267    fi
11268
11269    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"
11270    KF5_LIBS="-L$kf5_libdir -lKF5CoreAddons -lKF5I18n -lKF5ConfigCore -lKF5WindowSystem -lKF5KIOCore -lKF5KIOWidgets -lKF5KIOFileWidgets -L$qt5_libdir -lQt5Core -lQt5Gui -lQt5Widgets -lQt5Network"
11271    KF5_CFLAGS=$(printf '%s' "$KF5_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11272
11273    if test "$USING_X11" = TRUE; then
11274        KF5_LIBS="$KF5_LIBS -lQt5X11Extras"
11275    fi
11276
11277    AC_LANG_PUSH([C++])
11278    save_CXXFLAGS=$CXXFLAGS
11279    CXXFLAGS="$CXXFLAGS $KF5_CFLAGS"
11280    AC_MSG_CHECKING([whether KDE is >= 5.0])
11281       AC_RUN_IFELSE([AC_LANG_SOURCE([[
11282#include <kcoreaddons_version.h>
11283
11284int main(int argc, char **argv) {
11285       if (KCOREADDONS_VERSION_MAJOR == 5 && KCOREADDONS_VERSION_MINOR >= 0) return 0;
11286       else return 1;
11287}
11288       ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([KDE version too old])],[])
11289    CXXFLAGS=$save_CXXFLAGS
11290    AC_LANG_POP([C++])
11291fi
11292AC_SUBST(KF5_CFLAGS)
11293AC_SUBST(KF5_LIBS)
11294
11295dnl ===================================================================
11296dnl Test whether to include Evolution 2 support
11297dnl ===================================================================
11298AC_MSG_CHECKING([whether to enable evolution 2 support])
11299if test "$enable_evolution2" = "yes" -o "$enable_evolution2" = "TRUE"; then
11300    AC_MSG_RESULT([yes])
11301    PKG_CHECK_MODULES(GOBJECT, gobject-2.0)
11302    GOBJECT_CFLAGS=$(printf '%s' "$GOBJECT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11303    FilterLibs "${GOBJECT_LIBS}"
11304    GOBJECT_LIBS="${filteredlibs}"
11305    ENABLE_EVOAB2="TRUE"
11306else
11307    ENABLE_EVOAB2=""
11308    AC_MSG_RESULT([no])
11309fi
11310AC_SUBST(ENABLE_EVOAB2)
11311AC_SUBST(GOBJECT_CFLAGS)
11312AC_SUBST(GOBJECT_LIBS)
11313
11314dnl ===================================================================
11315dnl Test which themes to include
11316dnl ===================================================================
11317AC_MSG_CHECKING([which themes to include])
11318# if none given use default subset of available themes
11319if test "x$with_theme" = "x" -o "x$with_theme" = "xyes"; then
11320    with_theme="breeze breeze_dark breeze_svg colibre colibre_svg elementary elementary_svg karasa_jaga sifr sifr_svg sifr_dark tango"
11321fi
11322
11323WITH_THEMES=""
11324if test "x$with_theme" != "xno"; then
11325    for theme in $with_theme; do
11326        case $theme in
11327        breeze|breeze_dark|breeze_svg|colibre|colibre_svg|elementary|elementary_svg|karasa_jaga|sifr|sifr_svg|sifr_dark|tango) real_theme="$theme" ;;
11328        default) real_theme=colibre ;;
11329        *) AC_MSG_ERROR([Unknown value for --with-theme: $theme]) ;;
11330        esac
11331        WITH_THEMES=`echo "$WITH_THEMES $real_theme"|tr '\ ' '\n'|sort|uniq|tr '\n' '\ '`
11332    done
11333fi
11334AC_MSG_RESULT([$WITH_THEMES])
11335AC_SUBST([WITH_THEMES])
11336# FIXME: remove this, and the convenience default->colibre remapping after a grace period
11337for theme in $with_theme; do
11338    case $theme in
11339    default) AC_MSG_WARN([--with-theme=default is deprecated and will be removed, use --with-theme=colibre]) ;;
11340    *) ;;
11341    esac
11342done
11343
11344dnl ===================================================================
11345dnl Test whether to integrate helppacks into the product's installer
11346dnl ===================================================================
11347AC_MSG_CHECKING([for helppack integration])
11348if test "$with_helppack_integration" = "no"; then
11349    AC_MSG_RESULT([no integration])
11350else
11351    SCPDEFS="$SCPDEFS -DWITH_HELPPACK_INTEGRATION"
11352    AC_MSG_RESULT([integration])
11353fi
11354
11355###############################################################################
11356# Extensions checking
11357###############################################################################
11358AC_MSG_CHECKING([for extensions integration])
11359if test "x$enable_extension_integration" != "xno"; then
11360    WITH_EXTENSION_INTEGRATION=TRUE
11361    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_INTEGRATION"
11362    AC_MSG_RESULT([yes, use integration])
11363else
11364    WITH_EXTENSION_INTEGRATION=
11365    AC_MSG_RESULT([no, do not integrate])
11366fi
11367AC_SUBST(WITH_EXTENSION_INTEGRATION)
11368
11369dnl Should any extra extensions be included?
11370dnl There are standalone tests for each of these below.
11371WITH_EXTRA_EXTENSIONS=
11372AC_SUBST([WITH_EXTRA_EXTENSIONS])
11373
11374libo_CHECK_EXTENSION([ConvertTextToNumber],[CT2N],[ct2n],[ct2n],[])
11375libo_CHECK_EXTENSION([Numbertext],[NUMBERTEXT],[numbertext],[numbertext],[b7cae45ad2c23551fd6ccb8ae2c1f59e-numbertext_0.9.5.oxt])
11376if test "x$with_java" != "xno"; then
11377    libo_CHECK_EXTENSION([NLPSolver],[NLPSOLVER],[nlpsolver],[nlpsolver],[])
11378    libo_CHECK_EXTENSION([LanguageTool],[LANGUAGETOOL],[languagetool],[languagetool],[])
11379fi
11380
11381AC_MSG_CHECKING([whether to build opens___.ttf])
11382if test "$enable_build_opensymbol" = "yes"; then
11383    AC_MSG_RESULT([yes])
11384    AC_PATH_PROG(FONTFORGE, fontforge)
11385    if test -z "$FONTFORGE"; then
11386	AC_MSG_ERROR([fontforge not installed])
11387    fi
11388else
11389    AC_MSG_RESULT([no])
11390    OPENSYMBOL_TTF=49a64f3bcf20a7909ba2751349231d6652ded9cd2840e961b5164d09de3ffa63-opens___.ttf
11391    BUILD_TYPE="$BUILD_TYPE OPENSYMBOL"
11392fi
11393AC_SUBST(OPENSYMBOL_TTF)
11394AC_SUBST(FONTFORGE)
11395
11396dnl ===================================================================
11397dnl Test whether to include fonts
11398dnl ===================================================================
11399AC_MSG_CHECKING([whether to include third-party fonts])
11400if test "$with_fonts" != "no"; then
11401    AC_MSG_RESULT([yes])
11402    WITH_FONTS=TRUE
11403    BUILD_TYPE="$BUILD_TYPE MORE_FONTS"
11404    AC_DEFINE(HAVE_MORE_FONTS)
11405else
11406    AC_MSG_RESULT([no])
11407    WITH_FONTS=
11408    SCPDEFS="$SCPDEFS -DWITHOUT_FONTS"
11409fi
11410AC_SUBST(WITH_FONTS)
11411
11412
11413dnl ===================================================================
11414dnl Test whether to enable online update service
11415dnl ===================================================================
11416AC_MSG_CHECKING([whether to enable online update])
11417ENABLE_ONLINE_UPDATE=
11418ENABLE_ONLINE_UPDATE_MAR=
11419UPDATE_CONFIG=
11420if test "$enable_online_update" = ""; then
11421    if test "$_os" = "WINNT" -o "$_os" = "Darwin"; then
11422        AC_MSG_RESULT([yes])
11423        ENABLE_ONLINE_UPDATE="TRUE"
11424    else
11425        AC_MSG_RESULT([no])
11426    fi
11427else
11428    if test "$enable_online_update" = "mar"; then
11429        AC_MSG_RESULT([yes - MAR-based online update])
11430        ENABLE_ONLINE_UPDATE_MAR="TRUE"
11431        if test "$with_update_config" = ""; then
11432            AC_MSG_ERROR([mar based online updater needs an update config specified with "with-update-config])
11433        fi
11434        UPDATE_CONFIG="$with_update_config"
11435        AC_DEFINE(HAVE_FEATURE_UPDATE_MAR)
11436    elif test "$enable_online_update" = "yes"; then
11437        AC_MSG_RESULT([yes])
11438        ENABLE_ONLINE_UPDATE="TRUE"
11439    else
11440        AC_MSG_RESULT([no])
11441    fi
11442fi
11443AC_SUBST(ENABLE_ONLINE_UPDATE)
11444AC_SUBST(ENABLE_ONLINE_UPDATE_MAR)
11445AC_SUBST(UPDATE_CONFIG)
11446
11447dnl ===================================================================
11448dnl Test whether we need bzip2
11449dnl ===================================================================
11450SYSTEM_BZIP2=
11451if test "$ENABLE_ONLINE_UPDATE_MAR" = "TRUE"; then
11452    AC_MSG_CHECKING([whether to use system bzip2])
11453    if test "$with_system_bzip2" = yes; then
11454        SYSTEM_BZIP2=TRUE
11455        AC_MSG_RESULT([yes])
11456        PKG_CHECK_MODULES(BZIP2, bzip2)
11457        FilterLibs "${BZIP2_LIBS}"
11458        BZIP2_LIBS="${filteredlibs}"
11459    else
11460        AC_MSG_RESULT([no])
11461        BUILD_TYPE="$BUILD_TYPE BZIP2"
11462    fi
11463fi
11464AC_SUBST(SYSTEM_BZIP2)
11465AC_SUBST(BZIP2_CFLAGS)
11466AC_SUBST(BZIP2_LIBS)
11467
11468dnl ===================================================================
11469dnl Test whether to enable extension update
11470dnl ===================================================================
11471AC_MSG_CHECKING([whether to enable extension update])
11472ENABLE_EXTENSION_UPDATE=
11473if test "x$enable_extension_update" = "xno"; then
11474    AC_MSG_RESULT([no])
11475else
11476    AC_MSG_RESULT([yes])
11477    ENABLE_EXTENSION_UPDATE="TRUE"
11478    AC_DEFINE(ENABLE_EXTENSION_UPDATE)
11479    SCPDEFS="$SCPDEFS -DENABLE_EXTENSION_UPDATE"
11480fi
11481AC_SUBST(ENABLE_EXTENSION_UPDATE)
11482
11483
11484dnl ===================================================================
11485dnl Test whether to create MSI with LIMITUI=1 (silent install)
11486dnl ===================================================================
11487AC_MSG_CHECKING([whether to create MSI with LIMITUI=1 (silent install)])
11488if test "$enable_silent_msi" = "" -o "$enable_silent_msi" = "no"; then
11489    AC_MSG_RESULT([no])
11490    ENABLE_SILENT_MSI=
11491else
11492    AC_MSG_RESULT([yes])
11493    ENABLE_SILENT_MSI=TRUE
11494    SCPDEFS="$SCPDEFS -DENABLE_SILENT_MSI"
11495fi
11496AC_SUBST(ENABLE_SILENT_MSI)
11497
11498AC_MSG_CHECKING([whether and how to use Xinerama])
11499if test "$_os" = "Linux" -o "$_os" = "FreeBSD"; then
11500    if test "$x_libraries" = "default_x_libraries"; then
11501        XINERAMALIB=`$PKG_CONFIG --variable=libdir xinerama`
11502        if test "x$XINERAMALIB" = x; then
11503           XINERAMALIB="/usr/lib"
11504        fi
11505    else
11506        XINERAMALIB="$x_libraries"
11507    fi
11508    if test -e "$XINERAMALIB/libXinerama.so" -a -e "$XINERAMALIB/libXinerama.a"; then
11509        # we have both versions, let the user decide but use the dynamic one
11510        # per default
11511        USE_XINERAMA=TRUE
11512        if test -z "$with_static_xinerama" -o -n "$with_system_libs"; then
11513            XINERAMA_LINK=dynamic
11514        else
11515            XINERAMA_LINK=static
11516        fi
11517    elif test -e "$XINERAMALIB/libXinerama.so" -a ! -e "$XINERAMALIB/libXinerama.a"; then
11518        # we have only the dynamic version
11519        USE_XINERAMA=TRUE
11520        XINERAMA_LINK=dynamic
11521    elif test -e "$XINERAMALIB/libXinerama.a"; then
11522        # static version
11523        if echo $host_cpu | $GREP -E 'i[[3456]]86' 2>/dev/null >/dev/null; then
11524            USE_XINERAMA=TRUE
11525            XINERAMA_LINK=static
11526        else
11527            USE_XINERAMA=
11528            XINERAMA_LINK=none
11529        fi
11530    else
11531        # no Xinerama
11532        USE_XINERAMA=
11533        XINERAMA_LINK=none
11534    fi
11535    if test "$USE_XINERAMA" = "TRUE"; then
11536        AC_MSG_RESULT([yes, with $XINERAMA_LINK linking])
11537        AC_CHECK_HEADER(X11/extensions/Xinerama.h, [],
11538            [AC_MSG_ERROR(Xinerama header not found.)], [])
11539        XEXTLIBS=`$PKG_CONFIG --variable=libs xext`
11540        if test "x$XEXTLIB" = x; then
11541           XEXTLIBS="-L$XLIB -L$XINERAMALIB -lXext"
11542        fi
11543        XINERAMA_EXTRA_LIBS="$XEXTLIBS"
11544        if test "$_os" = "FreeBSD"; then
11545            XINERAMA_EXTRA_LIBS="$XINERAMA_EXTRA_LIBS -lXt"
11546        fi
11547        if test "$_os" = "Linux"; then
11548            XINERAMA_EXTRA_LIBS="$XINERAMA_EXTRA_LIBS -ldl"
11549        fi
11550        AC_CHECK_LIB([Xinerama], [XineramaIsActive], [:],
11551            [AC_MSG_ERROR(Xinerama not functional?)], [$XINERAMA_EXTRA_LIBS])
11552    else
11553        AC_MSG_RESULT([no, libXinerama not found or wrong architecture.])
11554    fi
11555else
11556    USE_XINERAMA=
11557    XINERAMA_LINK=none
11558    AC_MSG_RESULT([no])
11559fi
11560AC_SUBST(USE_XINERAMA)
11561AC_SUBST(XINERAMA_LINK)
11562
11563dnl ===================================================================
11564dnl Test whether to build cairo or rely on the system version
11565dnl ===================================================================
11566
11567if test "$USING_X11" = TRUE; then
11568    # Used in vcl/Library_vclplug_gen.mk
11569    test_cairo=yes
11570fi
11571
11572if test "$test_cairo" = "yes"; then
11573    AC_MSG_CHECKING([whether to use the system cairo])
11574
11575    : ${with_system_cairo:=$with_system_libs}
11576    if test "$with_system_cairo" = "yes"; then
11577        SYSTEM_CAIRO=TRUE
11578        AC_MSG_RESULT([yes])
11579
11580        PKG_CHECK_MODULES( CAIRO, cairo >= 1.8.0 )
11581        CAIRO_CFLAGS=$(printf '%s' "$CAIRO_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11582        FilterLibs "${CAIRO_LIBS}"
11583        CAIRO_LIBS="${filteredlibs}"
11584
11585        if test "$test_xrender" = "yes"; then
11586            AC_MSG_CHECKING([whether Xrender.h defines PictStandardA8])
11587            AC_LANG_PUSH([C])
11588            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <X11/extensions/Xrender.h>]],[[
11589#ifdef PictStandardA8
11590#else
11591      return fail;
11592#endif
11593]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no, X headers too old.])])
11594
11595            AC_LANG_POP([C])
11596        fi
11597    else
11598        SYSTEM_CAIRO=
11599        AC_MSG_RESULT([no])
11600
11601        BUILD_TYPE="$BUILD_TYPE CAIRO"
11602    fi
11603fi
11604
11605AC_SUBST(SYSTEM_CAIRO)
11606AC_SUBST(CAIRO_CFLAGS)
11607AC_SUBST(CAIRO_LIBS)
11608
11609dnl ===================================================================
11610dnl Test whether to use avahi
11611dnl ===================================================================
11612if test "$_os" = "WINNT"; then
11613    # Windows uses bundled mDNSResponder
11614    BUILD_TYPE="$BUILD_TYPE MDNSRESPONDER"
11615elif test "$_os" != "Darwin" -a "$enable_avahi" = "yes"; then
11616    PKG_CHECK_MODULES([AVAHI], [avahi-client >= 0.6.10],
11617                      [ENABLE_AVAHI="TRUE"])
11618    AC_DEFINE(HAVE_FEATURE_AVAHI)
11619    AVAHI_CFLAGS=$(printf '%s' "$AVAHI_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11620    FilterLibs "${AVAHI_LIBS}"
11621    AVAHI_LIBS="${filteredlibs}"
11622fi
11623
11624AC_SUBST(ENABLE_AVAHI)
11625AC_SUBST(AVAHI_CFLAGS)
11626AC_SUBST(AVAHI_LIBS)
11627
11628dnl ===================================================================
11629dnl Test whether to use liblangtag
11630dnl ===================================================================
11631SYSTEM_LIBLANGTAG=
11632AC_MSG_CHECKING([whether to use system liblangtag])
11633if test "$with_system_liblangtag" = yes; then
11634    SYSTEM_LIBLANGTAG=TRUE
11635    AC_MSG_RESULT([yes])
11636    PKG_CHECK_MODULES( LIBLANGTAG, liblangtag >= 0.4.0)
11637    dnl cf. <https://bitbucket.org/tagoh/liblangtag/commits/9324836a0d1c> "Fix a build issue with inline keyword"
11638    PKG_CHECK_EXISTS([liblangtag >= 0.5.5], [], [AC_DEFINE([LIBLANGTAG_INLINE_FIX])])
11639    LIBLANGTAG_CFLAGS=$(printf '%s' "$LIBLANGTAG_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11640    FilterLibs "${LIBLANGTAG_LIBS}"
11641    LIBLANGTAG_LIBS="${filteredlibs}"
11642else
11643    SYSTEM_LIBLANGTAG=
11644    AC_MSG_RESULT([no])
11645    BUILD_TYPE="$BUILD_TYPE LIBLANGTAG"
11646    LIBLANGTAG_CFLAGS="-I${WORKDIR}/UnpackedTarball/liblangtag"
11647    if test "$COM" = "MSC"; then
11648        LIBLANGTAG_LIBS="${WORKDIR}/UnpackedTarball/liblangtag/liblangtag/.libs/liblangtag.lib"
11649    else
11650        LIBLANGTAG_LIBS="-L${WORKDIR}/UnpackedTarball/liblangtag/liblangtag/.libs -llangtag"
11651    fi
11652fi
11653AC_SUBST(SYSTEM_LIBLANGTAG)
11654AC_SUBST(LIBLANGTAG_CFLAGS)
11655AC_SUBST(LIBLANGTAG_LIBS)
11656
11657dnl ===================================================================
11658dnl Test whether to build libpng or rely on the system version
11659dnl ===================================================================
11660
11661libo_CHECK_SYSTEM_MODULE([libpng],[LIBPNG],[libpng],["-I${WORKDIR}/UnpackedTarball/libpng"],["-L${WORKDIR}/LinkTarget/StaticLibrary -llibpng"])
11662
11663dnl ===================================================================
11664dnl Check for runtime JVM search path
11665dnl ===================================================================
11666if test "$ENABLE_JAVA" != ""; then
11667    AC_MSG_CHECKING([whether to use specific JVM search path at runtime])
11668    if test -n "$with_jvm_path" -a "$with_jvm_path" != "no"; then
11669        AC_MSG_RESULT([yes])
11670        if ! test -d "$with_jvm_path"; then
11671            AC_MSG_ERROR(["$with_jvm_path" not a directory])
11672        fi
11673        if ! test -d "$with_jvm_path"jvm; then
11674            AC_MSG_ERROR(["$with_jvm_path"jvm not found, point with_jvm_path to \[/path/to/\]jvm])
11675        fi
11676        JVM_ONE_PATH_CHECK="$with_jvm_path"
11677        AC_SUBST(JVM_ONE_PATH_CHECK)
11678    else
11679        AC_MSG_RESULT([no])
11680    fi
11681fi
11682
11683dnl ===================================================================
11684dnl Test for the presence of Ant and that it works
11685dnl ===================================================================
11686
11687if test "$ENABLE_JAVA" != "" -a "$NEED_ANT" = "TRUE"; then
11688    ANT_HOME=; export ANT_HOME
11689    WITH_ANT_HOME=; export WITH_ANT_HOME
11690    if test -z "$with_ant_home" -a -n "$LODE_HOME" ; then
11691        if test -x "$LODE_HOME/opt/ant/bin/ant" ; then
11692            if test "$_os" = "WINNT"; then
11693                with_ant_home="`cygpath -m $LODE_HOME/opt/ant`"
11694            else
11695                with_ant_home="$LODE_HOME/opt/ant"
11696            fi
11697        elif test -x  "$LODE_HOME/opt/bin/ant" ; then
11698            with_ant_home="$LODE_HOME/opt/ant"
11699        fi
11700    fi
11701    if test -z "$with_ant_home"; then
11702        AC_PATH_PROGS(ANT, [ant ant.sh ant.bat ant.cmd])
11703    else
11704        if test "$_os" = "WINNT"; then
11705            # AC_PATH_PROGS needs unix path
11706            with_ant_home=`cygpath -u "$with_ant_home"`
11707        fi
11708        AbsolutePath "$with_ant_home"
11709        with_ant_home=$absolute_path
11710        AC_PATH_PROGS(ANT, [ant ant.sh ant.bat ant.cmd],,$with_ant_home/bin:$PATH)
11711        WITH_ANT_HOME=$with_ant_home
11712        ANT_HOME=$with_ant_home
11713    fi
11714
11715    if test -z "$ANT"; then
11716        AC_MSG_ERROR([Ant not found - Make sure it's in the path or use --with-ant-home])
11717    else
11718        # resolve relative or absolute symlink
11719        while test -h "$ANT"; do
11720            a_cwd=`pwd`
11721            a_basename=`basename "$ANT"`
11722            a_script=`ls -l "$ANT" | $SED "s/.*${a_basename} -> //g"`
11723            cd "`dirname "$ANT"`"
11724            cd "`dirname "$a_script"`"
11725            ANT="`pwd`"/"`basename "$a_script"`"
11726            cd "$a_cwd"
11727        done
11728
11729        AC_MSG_CHECKING([if $ANT works])
11730        mkdir -p conftest.dir
11731        a_cwd=$(pwd)
11732        cd conftest.dir
11733        cat > conftest.java << EOF
11734        public class conftest {
11735            int testmethod(int a, int b) {
11736                    return a + b;
11737            }
11738        }
11739EOF
11740
11741        cat > conftest.xml << EOF
11742        <project name="conftest" default="conftest">
11743        <target name="conftest">
11744            <javac srcdir="." includes="conftest.java">
11745            </javac>
11746        </target>
11747        </project>
11748EOF
11749
11750        AC_TRY_COMMAND("$ANT" -buildfile conftest.xml 1>&2)
11751        if test $? = 0 -a -f ./conftest.class; then
11752            AC_MSG_RESULT([Ant works])
11753            if test -z "$WITH_ANT_HOME"; then
11754                ANT_HOME=`"$ANT" -diagnostics | $EGREP "ant.home :" | $SED -e "s#ant.home : ##g"`
11755                if test -z "$ANT_HOME"; then
11756                    ANT_HOME=`echo "$ANT" | $SED -n "s/\/bin\/ant.*\$//p"`
11757                fi
11758            else
11759                ANT_HOME="$WITH_ANT_HOME"
11760            fi
11761        else
11762            echo "configure: Ant test failed" >&5
11763            cat conftest.java >&5
11764            cat conftest.xml >&5
11765            AC_MSG_ERROR([Ant does not work - Some Java projects will not build!])
11766        fi
11767        cd "$a_cwd"
11768        rm -fr conftest.dir
11769    fi
11770    if test -z "$ANT_HOME"; then
11771        ANT_HOME="NO_ANT_HOME"
11772    else
11773        PathFormat "$ANT_HOME"
11774        ANT_HOME="$formatted_path"
11775        PathFormat "$ANT"
11776        ANT="$formatted_path"
11777    fi
11778    AC_SUBST(ANT_HOME)
11779    AC_SUBST(ANT)
11780
11781    dnl Checking for ant.jar
11782    if test "$ANT_HOME" != "NO_ANT_HOME"; then
11783        AC_MSG_CHECKING([Ant lib directory])
11784        if test -f $ANT_HOME/lib/ant.jar; then
11785            ANT_LIB="$ANT_HOME/lib"
11786        else
11787            if test -f $ANT_HOME/ant.jar; then
11788                ANT_LIB="$ANT_HOME"
11789            else
11790                if test -f /usr/share/java/ant.jar; then
11791                    ANT_LIB=/usr/share/java
11792                else
11793                    if test -f /usr/share/ant-core/lib/ant.jar; then
11794                        ANT_LIB=/usr/share/ant-core/lib
11795                    else
11796                        if test -f $ANT_HOME/lib/ant/ant.jar; then
11797                            ANT_LIB="$ANT_HOME/lib/ant"
11798                        else
11799                            if test -f /usr/share/lib/ant/ant.jar; then
11800                                ANT_LIB=/usr/share/lib/ant
11801                            else
11802                                AC_MSG_ERROR([Ant libraries not found!])
11803                            fi
11804                        fi
11805                    fi
11806                fi
11807            fi
11808        fi
11809        PathFormat "$ANT_LIB"
11810        ANT_LIB="$formatted_path"
11811        AC_MSG_RESULT([Ant lib directory found.])
11812    fi
11813    AC_SUBST(ANT_LIB)
11814
11815    ant_minver=1.6.0
11816    ant_minminor1=`echo $ant_minver | cut -d"." -f2`
11817
11818    AC_MSG_CHECKING([whether Ant is >= $ant_minver])
11819    ant_version=`"$ANT" -version | $AWK '{ print $4; }'`
11820    ant_version_major=`echo $ant_version | cut -d. -f1`
11821    ant_version_minor=`echo $ant_version | cut -d. -f2`
11822    echo "configure: ant_version $ant_version " >&5
11823    echo "configure: ant_version_major $ant_version_major " >&5
11824    echo "configure: ant_version_minor $ant_version_minor " >&5
11825    if test "$ant_version_major" -ge "2"; then
11826        AC_MSG_RESULT([yes, $ant_version])
11827    elif test "$ant_version_major" = "1" -a "$ant_version_minor" -ge "$ant_minminor1"; then
11828        AC_MSG_RESULT([yes, $ant_version])
11829    else
11830        AC_MSG_ERROR([no, you need at least Ant >= $ant_minver])
11831    fi
11832
11833    rm -f conftest* core core.* *.core
11834fi
11835
11836OOO_JUNIT_JAR=
11837if test "$ENABLE_JAVA" != "" -a "$with_junit" != "no"; then
11838    AC_MSG_CHECKING([for JUnit 4])
11839    if test "$with_junit" = "yes"; then
11840        if test -n "$LODE_HOME" -a -e "$LODE_HOME/opt/share/java/junit.jar" ; then
11841            OOO_JUNIT_JAR="$LODE_HOME/opt/share/java/junit.jar"
11842        elif test -e /usr/share/java/junit4.jar; then
11843            OOO_JUNIT_JAR=/usr/share/java/junit4.jar
11844        else
11845           if test -e /usr/share/lib/java/junit.jar; then
11846              OOO_JUNIT_JAR=/usr/share/lib/java/junit.jar
11847           else
11848              OOO_JUNIT_JAR=/usr/share/java/junit.jar
11849           fi
11850        fi
11851    else
11852        OOO_JUNIT_JAR=$with_junit
11853    fi
11854    if test "$_os" = "WINNT"; then
11855        OOO_JUNIT_JAR=`cygpath -m "$OOO_JUNIT_JAR"`
11856    fi
11857    printf 'import org.junit.Before;' > conftest.java
11858    if "$JAVACOMPILER" -classpath "$OOO_JUNIT_JAR" conftest.java >&5 2>&5; then
11859        AC_MSG_RESULT([$OOO_JUNIT_JAR])
11860    else
11861        AC_MSG_ERROR(
11862[cannot find JUnit 4 jar; please install one in the default location (/usr/share/java),
11863 specify its pathname via --with-junit=..., or disable it via --without-junit])
11864    fi
11865    rm -f conftest.class conftest.java
11866    if test $OOO_JUNIT_JAR != ""; then
11867    BUILD_TYPE="$BUILD_TYPE QADEVOOO"
11868    fi
11869fi
11870AC_SUBST(OOO_JUNIT_JAR)
11871
11872HAMCREST_JAR=
11873if test "$ENABLE_JAVA" != "" -a "$with_junit" != "no"; then
11874    AC_MSG_CHECKING([for included Hamcrest])
11875    printf 'import org.hamcrest.BaseDescription;' > conftest.java
11876    if "$JAVACOMPILER" -classpath "$OOO_JUNIT_JAR" conftest.java >&5 2>&5; then
11877        AC_MSG_RESULT([Included in $OOO_JUNIT_JAR])
11878    else
11879        AC_MSG_RESULT([Not included])
11880        AC_MSG_CHECKING([for standalone hamcrest jar.])
11881        if test "$with_hamcrest" = "yes"; then
11882            if test -e /usr/share/lib/java/hamcrest.jar; then
11883                HAMCREST_JAR=/usr/share/lib/java/hamcrest.jar
11884            elif test -e /usr/share/java/hamcrest/core.jar; then
11885                HAMCREST_JAR=/usr/share/java/hamcrest/core.jar
11886            else
11887                HAMCREST_JAR=/usr/share/java/hamcrest.jar
11888            fi
11889        else
11890            HAMCREST_JAR=$with_hamcrest
11891        fi
11892        if test "$_os" = "WINNT"; then
11893            HAMCREST_JAR=`cygpath -m "$HAMCREST_JAR"`
11894        fi
11895        if "$JAVACOMPILER" -classpath "$HAMCREST_JAR" conftest.java >&5 2>&5; then
11896            AC_MSG_RESULT([$HAMCREST_JAR])
11897        else
11898            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),
11899                          specify its path with --with-hamcrest=..., or disable junit with --without-junit])
11900        fi
11901    fi
11902    rm -f conftest.class conftest.java
11903fi
11904AC_SUBST(HAMCREST_JAR)
11905
11906
11907AC_SUBST(SCPDEFS)
11908
11909#
11910# check for wget and curl
11911#
11912WGET=
11913CURL=
11914
11915if test "$enable_fetch_external" != "no"; then
11916
11917CURL=`which curl 2>/dev/null`
11918
11919for i in wget /usr/bin/wget /usr/local/bin/wget /usr/sfw/bin/wget /opt/sfw/bin/wget /opt/local/bin/wget; do
11920    # wget new enough?
11921    $i --help 2> /dev/null | $GREP no-use-server-timestamps 2>&1 > /dev/null
11922    if test $? -eq 0; then
11923        WGET=$i
11924        break
11925    fi
11926done
11927
11928if test -z "$WGET" -a -z "$CURL"; then
11929    AC_MSG_ERROR([neither wget nor curl found!])
11930fi
11931
11932fi
11933
11934AC_SUBST(WGET)
11935AC_SUBST(CURL)
11936
11937#
11938# check for sha256sum
11939#
11940SHA256SUM=
11941
11942for i in shasum /usr/local/bin/shasum /usr/sfw/bin/shasum /opt/sfw/bin/shasum /opt/local/bin/shasum; do
11943    eval "$i -a 256 --version" > /dev/null 2>&1
11944    ret=$?
11945    if test $ret -eq 0; then
11946        SHA256SUM="$i -a 256"
11947        break
11948    fi
11949done
11950
11951if test -z "$SHA256SUM"; then
11952    for i in sha256sum /usr/local/bin/sha256sum /usr/sfw/bin/sha256sum /opt/sfw/bin/sha256sum /opt/local/bin/sha256sum; do
11953        eval "$i --version" > /dev/null 2>&1
11954        ret=$?
11955        if test $ret -eq 0; then
11956            SHA256SUM=$i
11957            break
11958        fi
11959    done
11960fi
11961
11962if test -z "$SHA256SUM"; then
11963    AC_MSG_ERROR([no sha256sum found!])
11964fi
11965
11966AC_SUBST(SHA256SUM)
11967
11968dnl ===================================================================
11969dnl Dealing with l10n options
11970dnl ===================================================================
11971AC_MSG_CHECKING([which languages to be built])
11972# get list of all languages
11973# generate shell variable from completelangiso= from solenv/inc/langlist.mk
11974# the sed command does the following:
11975#   + if a line ends with a backslash, append the next line to it
11976#   + adds " on the beginning of the value (after =)
11977#   + adds " at the end of the value
11978#   + removes en-US; we want to put it on the beginning
11979#   + prints just the section starting with 'completelangiso=' and ending with the " at the end of line
11980[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)]
11981ALL_LANGS="en-US $completelangiso"
11982# check the configured localizations
11983WITH_LANG="$with_lang"
11984
11985# Check for --without-lang which turns up as $with_lang being "no". Luckily there is no language with code "no".
11986# (Norwegian is "nb" and "nn".)
11987if test "$WITH_LANG" = "no"; then
11988    WITH_LANG=
11989fi
11990
11991if test -z "$WITH_LANG" -o "$WITH_LANG" = "en-US"; then
11992    AC_MSG_RESULT([en-US])
11993else
11994    AC_MSG_RESULT([$WITH_LANG])
11995    GIT_NEEDED_SUBMODULES="translations $GIT_NEEDED_SUBMODULES"
11996    if test -z "$MSGFMT"; then
11997        if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/msgfmt" ; then
11998            MSGFMT="$LODE_HOME/opt/bin/msgfmt"
11999        elif test -x "/opt/lo/bin/msgfmt"; then
12000            MSGFMT="/opt/lo/bin/msgfmt"
12001        else
12002            AC_CHECK_PROGS(MSGFMT, [msgfmt])
12003            if test -z "$MSGFMT"; then
12004                AC_MSG_ERROR([msgfmt not found. Install GNU gettext, or re-run without languages.])
12005            fi
12006        fi
12007    fi
12008    if test -z "$MSGUNIQ"; then
12009        if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/msguniq" ; then
12010            MSGUNIQ="$LODE_HOME/opt/bin/msguniq"
12011        elif test -x "/opt/lo/bin/msguniq"; then
12012            MSGUNIQ="/opt/lo/bin/msguniq"
12013        else
12014            AC_CHECK_PROGS(MSGUNIQ, [msguniq])
12015            if test -z "$MSGUNIQ"; then
12016                AC_MSG_ERROR([msguniq not found. Install GNU gettext, or re-run without languages.])
12017            fi
12018        fi
12019    fi
12020fi
12021AC_SUBST(MSGFMT)
12022AC_SUBST(MSGUNIQ)
12023# check that the list is valid
12024for lang in $WITH_LANG; do
12025    test "$lang" = "ALL" && continue
12026    # need to check for the exact string, so add space before and after the list of all languages
12027    for vl in $ALL_LANGS; do
12028        if test "$vl" = "$lang"; then
12029           break
12030        fi
12031    done
12032    if test "$vl" != "$lang"; then
12033        # if you're reading this - you prolly quoted your languages remove the quotes ...
12034        AC_MSG_ERROR([invalid language: '$lang' (vs '$v1'); supported languages are: $ALL_LANGS])
12035    fi
12036done
12037if test -n "$WITH_LANG" -a "$WITH_LANG" != "ALL"; then
12038    echo $WITH_LANG | grep -q en-US
12039    test $? -ne 1 || WITH_LANG=`echo $WITH_LANG en-US`
12040fi
12041# list with substituted ALL
12042WITH_LANG_LIST=`echo $WITH_LANG | sed "s/ALL/$ALL_LANGS/"`
12043test -z "$WITH_LANG_LIST" && WITH_LANG_LIST="en-US"
12044test "$WITH_LANG" = "en-US" && WITH_LANG=
12045if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
12046    test "$WITH_LANG_LIST" = "en-US" || WITH_LANG_LIST=`echo $WITH_LANG_LIST qtz`
12047    ALL_LANGS=`echo $ALL_LANGS qtz`
12048fi
12049AC_SUBST(ALL_LANGS)
12050AC_DEFINE_UNQUOTED(WITH_LANG,"$WITH_LANG")
12051AC_SUBST(WITH_LANG)
12052AC_SUBST(WITH_LANG_LIST)
12053AC_SUBST(GIT_NEEDED_SUBMODULES)
12054
12055WITH_POOR_HELP_LOCALIZATIONS=
12056if test -d "$SRC_ROOT/translations/source"; then
12057    for l in `ls -1 $SRC_ROOT/translations/source`; do
12058        if test ! -d "$SRC_ROOT/translations/source/$l/helpcontent2"; then
12059            WITH_POOR_HELP_LOCALIZATIONS="$WITH_POOR_HELP_LOCALIZATIONS $l"
12060        fi
12061    done
12062fi
12063AC_SUBST(WITH_POOR_HELP_LOCALIZATIONS)
12064
12065if test -n "$with_locales"; then
12066    WITH_LOCALES="$with_locales"
12067
12068    just_langs="`echo $WITH_LOCALES | sed -e 's/_[A-Z]*//g'`"
12069    # Only languages and scripts for which we actually have ifdefs need to be handled. Also see
12070    # config_host/config_locales.h.in
12071    for locale in $WITH_LOCALES; do
12072        lang=${locale%_*}
12073
12074        AC_DEFINE_UNQUOTED(WITH_LOCALE_$lang, 1)
12075
12076        case $lang in
12077        hi|mr*ne)
12078            AC_DEFINE(WITH_LOCALE_FOR_SCRIPT_Deva)
12079            ;;
12080        bg|ru)
12081            AC_DEFINE(WITH_LOCALE_FOR_SCRIPT_Cyrl)
12082            ;;
12083        esac
12084    done
12085else
12086    AC_DEFINE(WITH_LOCALE_ALL)
12087fi
12088AC_SUBST(WITH_LOCALES)
12089
12090dnl git submodule update --reference
12091dnl ===================================================================
12092if test -n "${GIT_REFERENCE_SRC}"; then
12093    for repo in ${GIT_NEEDED_SUBMODULES}; do
12094        if ! test -d "${GIT_REFERENCE_SRC}"/${repo}; then
12095            AC_MSG_ERROR([referenced git: required repository does not exist: ${GIT_REFERENCE_SRC}/${repo}])
12096        fi
12097    done
12098fi
12099AC_SUBST(GIT_REFERENCE_SRC)
12100
12101dnl git submodules linked dirs
12102dnl ===================================================================
12103if test -n "${GIT_LINK_SRC}"; then
12104    for repo in ${GIT_NEEDED_SUBMODULES}; do
12105        if ! test -d "${GIT_LINK_SRC}"/${repo}; then
12106            AC_MSG_ERROR([linked git: required repository does not exist: ${GIT_LINK_SRC}/${repo}])
12107        fi
12108    done
12109fi
12110AC_SUBST(GIT_LINK_SRC)
12111
12112dnl branding
12113dnl ===================================================================
12114AC_MSG_CHECKING([for alternative branding images directory])
12115# initialize mapped arrays
12116BRAND_INTRO_IMAGES="flat_logo.svg intro.png intro-highres.png"
12117brand_files="$BRAND_INTRO_IMAGES about.svg"
12118
12119if test -z "$with_branding" -o "$with_branding" = "no"; then
12120    AC_MSG_RESULT([none])
12121    DEFAULT_BRAND_IMAGES="$brand_files"
12122else
12123    if ! test -d $with_branding ; then
12124        AC_MSG_ERROR([No directory $with_branding, falling back to default branding])
12125    else
12126        AC_MSG_RESULT([$with_branding])
12127        CUSTOM_BRAND_DIR="$with_branding"
12128        for lfile in $brand_files
12129        do
12130            if ! test -f $with_branding/$lfile ; then
12131                AC_MSG_WARN([Branded file $lfile does not exist, using the default one])
12132                DEFAULT_BRAND_IMAGES="$DEFAULT_BRAND_IMAGES $lfile"
12133            else
12134                CUSTOM_BRAND_IMAGES="$CUSTOM_BRAND_IMAGES $lfile"
12135            fi
12136        done
12137        check_for_progress="yes"
12138    fi
12139fi
12140AC_SUBST([BRAND_INTRO_IMAGES])
12141AC_SUBST([CUSTOM_BRAND_DIR])
12142AC_SUBST([CUSTOM_BRAND_IMAGES])
12143AC_SUBST([DEFAULT_BRAND_IMAGES])
12144
12145
12146AC_MSG_CHECKING([for 'intro' progress settings])
12147PROGRESSBARCOLOR=
12148PROGRESSSIZE=
12149PROGRESSPOSITION=
12150PROGRESSFRAMECOLOR=
12151PROGRESSTEXTCOLOR=
12152PROGRESSTEXTBASELINE=
12153
12154if test "$check_for_progress" = "yes" -a -f "$with_branding/progress.conf" ; then
12155    source "$with_branding/progress.conf"
12156    AC_MSG_RESULT([settings found in $with_branding/progress.conf])
12157else
12158    AC_MSG_RESULT([none])
12159fi
12160
12161AC_SUBST(PROGRESSBARCOLOR)
12162AC_SUBST(PROGRESSSIZE)
12163AC_SUBST(PROGRESSPOSITION)
12164AC_SUBST(PROGRESSFRAMECOLOR)
12165AC_SUBST(PROGRESSTEXTCOLOR)
12166AC_SUBST(PROGRESSTEXTBASELINE)
12167
12168
12169AC_MSG_CHECKING([for extra build ID])
12170if test -n "$with_extra_buildid" -a "$with_extra_buildid" != "yes" ; then
12171    EXTRA_BUILDID="$with_extra_buildid"
12172fi
12173# in tinderboxes, it is easier to set EXTRA_BUILDID via the environment variable instead of configure switch
12174if test -n "$EXTRA_BUILDID" ; then
12175    AC_MSG_RESULT([$EXTRA_BUILDID])
12176else
12177    AC_MSG_RESULT([not set])
12178fi
12179AC_DEFINE_UNQUOTED([EXTRA_BUILDID], ["$EXTRA_BUILDID"])
12180
12181OOO_VENDOR=
12182AC_MSG_CHECKING([for vendor])
12183if test -z "$with_vendor" -o "$with_vendor" = "no"; then
12184    OOO_VENDOR="$USERNAME"
12185
12186    if test -z "$OOO_VENDOR"; then
12187        OOO_VENDOR="$USER"
12188    fi
12189
12190    if test -z "$OOO_VENDOR"; then
12191        OOO_VENDOR="`id -u -n`"
12192    fi
12193
12194    AC_MSG_RESULT([not set, using $OOO_VENDOR])
12195else
12196    OOO_VENDOR="$with_vendor"
12197    AC_MSG_RESULT([$OOO_VENDOR])
12198fi
12199AC_DEFINE_UNQUOTED(OOO_VENDOR,"$OOO_VENDOR")
12200AC_SUBST(OOO_VENDOR)
12201
12202if test "$_os" = "Android" ; then
12203    ANDROID_PACKAGE_NAME=
12204    AC_MSG_CHECKING([for Android package name])
12205    if test -z "$with_android_package_name" -o "$with_android_package_name" = "no"; then
12206        if test -n "$ENABLE_DEBUG"; then
12207            # Default to the package name that makes ndk-gdb happy.
12208            ANDROID_PACKAGE_NAME="org.libreoffice"
12209        else
12210            ANDROID_PACKAGE_NAME="org.example.libreoffice"
12211        fi
12212
12213        AC_MSG_RESULT([not set, using $ANDROID_PACKAGE_NAME])
12214    else
12215        ANDROID_PACKAGE_NAME="$with_android_package_name"
12216        AC_MSG_RESULT([$ANDROID_PACKAGE_NAME])
12217    fi
12218    AC_SUBST(ANDROID_PACKAGE_NAME)
12219fi
12220
12221AC_MSG_CHECKING([whether to install the compat oo* wrappers])
12222if test "$with_compat_oowrappers" = "yes"; then
12223    WITH_COMPAT_OOWRAPPERS=TRUE
12224    AC_MSG_RESULT(yes)
12225else
12226    WITH_COMPAT_OOWRAPPERS=
12227    AC_MSG_RESULT(no)
12228fi
12229AC_SUBST(WITH_COMPAT_OOWRAPPERS)
12230
12231INSTALLDIRNAME=`echo AC_PACKAGE_NAME | $AWK '{print tolower($0)}'`
12232AC_MSG_CHECKING([for install dirname])
12233if test -n "$with_install_dirname" -a "$with_install_dirname" != "no" -a "$with_install_dirname" != "yes"; then
12234    INSTALLDIRNAME="$with_install_dirname"
12235fi
12236AC_MSG_RESULT([$INSTALLDIRNAME])
12237AC_SUBST(INSTALLDIRNAME)
12238
12239AC_MSG_CHECKING([for prefix])
12240test "x$prefix" = xNONE && prefix=$ac_default_prefix
12241test "x$exec_prefix" = xNONE && exec_prefix=$prefix
12242PREFIXDIR="$prefix"
12243AC_MSG_RESULT([$PREFIXDIR])
12244AC_SUBST(PREFIXDIR)
12245
12246LIBDIR=[$(eval echo $(eval echo $libdir))]
12247AC_SUBST(LIBDIR)
12248
12249DATADIR=[$(eval echo $(eval echo $datadir))]
12250AC_SUBST(DATADIR)
12251
12252MANDIR=[$(eval echo $(eval echo $mandir))]
12253AC_SUBST(MANDIR)
12254
12255DOCDIR=[$(eval echo $(eval echo $docdir))]
12256AC_SUBST(DOCDIR)
12257
12258BINDIR=[$(eval echo $(eval echo $bindir))]
12259AC_SUBST(BINDIR)
12260
12261INSTALLDIR="$LIBDIR/$INSTALLDIRNAME"
12262AC_SUBST(INSTALLDIR)
12263
12264TESTINSTALLDIR="${BUILDDIR}/test-install"
12265AC_SUBST(TESTINSTALLDIR)
12266
12267
12268# ===================================================================
12269# OAuth2 id and secrets
12270# ===================================================================
12271
12272AC_MSG_CHECKING([for Google Drive client id and secret])
12273if test "$with_gdrive_client_id" = "no" -o -z "$with_gdrive_client_id"; then
12274    AC_MSG_RESULT([not set])
12275    GDRIVE_CLIENT_ID="\"\""
12276    GDRIVE_CLIENT_SECRET="\"\""
12277else
12278    AC_MSG_RESULT([set])
12279    GDRIVE_CLIENT_ID="\"$with_gdrive_client_id\""
12280    GDRIVE_CLIENT_SECRET="\"$with_gdrive_client_secret\""
12281fi
12282AC_DEFINE_UNQUOTED(GDRIVE_CLIENT_ID, $GDRIVE_CLIENT_ID)
12283AC_DEFINE_UNQUOTED(GDRIVE_CLIENT_SECRET, $GDRIVE_CLIENT_SECRET)
12284
12285AC_MSG_CHECKING([for Alfresco Cloud client id and secret])
12286if test "$with_alfresco_cloud_client_id" = "no" -o -z "$with_alfresco_cloud_client_id"; then
12287    AC_MSG_RESULT([not set])
12288    ALFRESCO_CLOUD_CLIENT_ID="\"\""
12289    ALFRESCO_CLOUD_CLIENT_SECRET="\"\""
12290else
12291    AC_MSG_RESULT([set])
12292    ALFRESCO_CLOUD_CLIENT_ID="\"$with_alfresco_cloud_client_id\""
12293    ALFRESCO_CLOUD_CLIENT_SECRET="\"$with_alfresco_cloud_client_secret\""
12294fi
12295AC_DEFINE_UNQUOTED(ALFRESCO_CLOUD_CLIENT_ID, $ALFRESCO_CLOUD_CLIENT_ID)
12296AC_DEFINE_UNQUOTED(ALFRESCO_CLOUD_CLIENT_SECRET, $ALFRESCO_CLOUD_CLIENT_SECRET)
12297
12298AC_MSG_CHECKING([for OneDrive client id and secret])
12299if test "$with_onedrive_client_id" = "no" -o -z "$with_onedrive_client_id"; then
12300    AC_MSG_RESULT([not set])
12301    ONEDRIVE_CLIENT_ID="\"\""
12302    ONEDRIVE_CLIENT_SECRET="\"\""
12303else
12304    AC_MSG_RESULT([set])
12305    ONEDRIVE_CLIENT_ID="\"$with_onedrive_client_id\""
12306    ONEDRIVE_CLIENT_SECRET="\"$with_onedrive_client_secret\""
12307fi
12308AC_DEFINE_UNQUOTED(ONEDRIVE_CLIENT_ID, $ONEDRIVE_CLIENT_ID)
12309AC_DEFINE_UNQUOTED(ONEDRIVE_CLIENT_SECRET, $ONEDRIVE_CLIENT_SECRET)
12310
12311
12312dnl ===================================================================
12313dnl Hook up LibreOffice's nodep environmental variable to automake's equivalent
12314dnl --enable-dependency-tracking configure option
12315dnl ===================================================================
12316AC_MSG_CHECKING([whether to enable dependency tracking])
12317if test "$enable_dependency_tracking" = "no"; then
12318    nodep=TRUE
12319    AC_MSG_RESULT([no])
12320else
12321    AC_MSG_RESULT([yes])
12322fi
12323AC_SUBST(nodep)
12324
12325dnl ===================================================================
12326dnl Number of CPUs to use during the build
12327dnl ===================================================================
12328AC_MSG_CHECKING([for number of processors to use])
12329# plain --with-parallelism is just the default
12330if test -n "$with_parallelism" -a "$with_parallelism" != "yes"; then
12331    if test "$with_parallelism" = "no"; then
12332        PARALLELISM=0
12333    else
12334        PARALLELISM=$with_parallelism
12335    fi
12336else
12337    if test "$enable_icecream" = "yes"; then
12338        PARALLELISM="10"
12339    else
12340        case `uname -s` in
12341
12342        Darwin|FreeBSD|NetBSD|OpenBSD)
12343            PARALLELISM=`sysctl -n hw.ncpu`
12344            ;;
12345
12346        Linux)
12347            PARALLELISM=`getconf _NPROCESSORS_ONLN`
12348        ;;
12349        # what else than above does profit here *and* has /proc?
12350        *)
12351            PARALLELISM=`grep $'^processor\t*:' /proc/cpuinfo | wc -l`
12352            ;;
12353        esac
12354
12355        # If we hit the catch-all case, but /proc/cpuinfo doesn't exist or has an
12356        # unexpected format, 'wc -l' will have returned 0 (and we won't use -j at all).
12357    fi
12358fi
12359
12360if test "$no_parallelism_make" = "YES" && test $PARALLELISM -gt 1; then
12361    if test -z "$with_parallelism"; then
12362            AC_MSG_WARN([gmake 3.81 crashes with parallelism > 1, reducing it to 1. upgrade to 3.82 to avoid this.])
12363            add_warning "gmake 3.81 crashes with parallelism > 1, reducing it to 1. upgrade to 3.82 to avoid this."
12364            PARALLELISM="1"
12365    else
12366        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."
12367    fi
12368fi
12369
12370if test $PARALLELISM -eq 0; then
12371    AC_MSG_RESULT([explicit make -j option needed])
12372else
12373    AC_MSG_RESULT([$PARALLELISM])
12374fi
12375AC_SUBST(PARALLELISM)
12376
12377IWYU_PATH="$with_iwyu"
12378AC_SUBST(IWYU_PATH)
12379if test ! -z "$IWYU_PATH"; then
12380    if test ! -f "$IWYU_PATH"; then
12381        AC_MSG_ERROR([cannot find include-what-you-use binary specified by --with-iwyu])
12382    fi
12383fi
12384
12385#
12386# Set up ILIB for MSVC build
12387#
12388ILIB1=
12389if test "$build_os" = "cygwin"; then
12390    ILIB="."
12391    if test -n "$JAVA_HOME"; then
12392        ILIB="$ILIB;$JAVA_HOME/lib"
12393    fi
12394    ILIB1=-link
12395    if test "$BITNESS_OVERRIDE" = 64; then
12396        ILIB="$ILIB;$COMPATH/lib/x64"
12397        ILIB1="$ILIB1 -LIBPATH:$COMPATH/lib/x64"
12398        ILIB="$ILIB;$WINDOWS_SDK_HOME/lib/x64"
12399        ILIB1="$ILIB1 -LIBPATH:$WINDOWS_SDK_HOME/lib/x64"
12400        if test $WINDOWS_SDK_VERSION = 80 -o $WINDOWS_SDK_VERSION = 81 -o $WINDOWS_SDK_VERSION = 10; then
12401            ILIB="$ILIB;$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/x64"
12402            ILIB1="$ILIB1 -LIBPATH:$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/x64"
12403        fi
12404        PathFormat "${UCRTSDKDIR}lib/$UCRTVERSION/ucrt/x64"
12405        ucrtlibpath_formatted=$formatted_path
12406        ILIB="$ILIB;$ucrtlibpath_formatted"
12407        ILIB1="$ILIB1 -LIBPATH:$ucrtlibpath_formatted"
12408    else
12409        ILIB="$ILIB;$COMPATH/lib/x86"
12410        ILIB1="$ILIB1 -LIBPATH:$COMPATH/lib/x86"
12411        ILIB="$ILIB;$WINDOWS_SDK_HOME/lib"
12412        ILIB1="$ILIB1 -LIBPATH:$WINDOWS_SDK_HOME/lib"
12413        if test $WINDOWS_SDK_VERSION = 80 -o $WINDOWS_SDK_VERSION = 81 -o $WINDOWS_SDK_VERSION = 10; then
12414            ILIB="$ILIB;$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/x86"
12415            ILIB1="$ILIB1 -LIBPATH:$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/x86"
12416        fi
12417        PathFormat "${UCRTSDKDIR}lib/$UCRTVERSION/ucrt/x86"
12418        ucrtlibpath_formatted=$formatted_path
12419        ILIB="$ILIB;$ucrtlibpath_formatted"
12420        ILIB1="$ILIB1 -LIBPATH:$ucrtlibpath_formatted"
12421    fi
12422    if test -f "$DOTNET_FRAMEWORK_HOME/lib/mscoree.lib"; then
12423        ILIB="$ILIB;$DOTNET_FRAMEWORK_HOME/lib"
12424    else
12425        ILIB="$ILIB;$DOTNET_FRAMEWORK_HOME/Lib/um/$WINDOWS_SDK_ARCH"
12426    fi
12427
12428    AC_SUBST(ILIB)
12429fi
12430
12431# ===================================================================
12432# Creating bigger shared library to link against
12433# ===================================================================
12434AC_MSG_CHECKING([whether to create huge library])
12435MERGELIBS=
12436
12437if test $_os = iOS -o $_os = Android; then
12438    # Never any point in mergelibs for these as we build just static
12439    # libraries anyway...
12440    enable_mergelibs=no
12441fi
12442
12443if test -n "$enable_mergelibs" -a "$enable_mergelibs" != "no"; then
12444    if test $_os != Linux -a $_os != WINNT; then
12445        add_warning "--enable-mergelibs is not tested for this platform"
12446    fi
12447    MERGELIBS="TRUE"
12448    AC_MSG_RESULT([yes])
12449else
12450    AC_MSG_RESULT([no])
12451fi
12452AC_SUBST([MERGELIBS])
12453
12454dnl ===================================================================
12455dnl icerun is a wrapper that stops us spawning tens of processes
12456dnl locally - for tools that can't be executed on the compile cluster
12457dnl this avoids a dozen javac's ganging up on your laptop to kill it.
12458dnl ===================================================================
12459AC_MSG_CHECKING([whether to use icerun wrapper])
12460ICECREAM_RUN=
12461if test "$enable_icecream" = "yes" && which icerun >/dev/null 2>&1 ; then
12462    ICECREAM_RUN=icerun
12463    AC_MSG_RESULT([yes])
12464else
12465    AC_MSG_RESULT([no])
12466fi
12467AC_SUBST(ICECREAM_RUN)
12468
12469dnl ===================================================================
12470dnl Setup the ICECC_VERSION for the build the same way it was set for
12471dnl configure, so that CC/CXX and ICECC_VERSION are in sync
12472dnl ===================================================================
12473x_ICECC_VERSION=[\#]
12474if test -n "$ICECC_VERSION" ; then
12475    x_ICECC_VERSION=
12476fi
12477AC_SUBST(x_ICECC_VERSION)
12478AC_SUBST(ICECC_VERSION)
12479
12480dnl ===================================================================
12481
12482AC_MSG_CHECKING([MPL subset])
12483MPL_SUBSET=
12484
12485if test "$enable_mpl_subset" = "yes"; then
12486    warn_report=false
12487    if test "$enable_report_builder" != "no" -a "$with_java" != "no"; then
12488        warn_report=true
12489    elif test "$ENABLE_REPORTBUILDER" = "TRUE"; then
12490        warn_report=true
12491    fi
12492    if test "$warn_report" = "true"; then
12493        AC_MSG_ERROR([need to --disable-report-builder - extended database report builder.])
12494    fi
12495    if test "x$enable_postgresql_sdbc" != "xno"; then
12496        AC_MSG_ERROR([need to --disable-postgresql-sdbc - the PostgreSQL database backend.])
12497    fi
12498    if test "$enable_lotuswordpro" = "yes"; then
12499        AC_MSG_ERROR([need to --disable-lotuswordpro - a Lotus Word Pro file format import filter.])
12500    fi
12501    if test "$WITH_WEBDAV" = "neon"; then
12502        AC_MSG_ERROR([need --with-webdav=serf or --without-webdav - webdav support.])
12503    fi
12504    if test -n "$ENABLE_POPPLER"; then
12505        if test "x$SYSTEM_POPPLER" = "x"; then
12506            AC_MSG_ERROR([need to disable PDF import via poppler or use system library])
12507        fi
12508    fi
12509    # cf. m4/libo_check_extension.m4
12510    if test "x$WITH_EXTRA_EXTENSIONS" != "x"; then
12511        AC_MSG_ERROR([need to disable extra extensions '$WITH_EXTRA_EXTENSIONS'])
12512    fi
12513    for theme in $WITH_THEMES; do
12514        case $theme in
12515        breeze|breeze_dark|breeze_svg|elementary|elementary_svg|karasa_jaga|karasa_jaga_svg) #blacklist of icon themes under GPL or LGPL
12516            AC_MSG_ERROR([need to disable icon themes from '$WITH_THEMES': $theme present, use --with-theme=tango]) ;;
12517        *) : ;;
12518        esac
12519    done
12520
12521    ENABLE_OPENGL_TRANSITIONS=
12522
12523    if test "$enable_lpsolve" != "no" -o "x$ENABLE_LPSOLVE" = "xTRUE"; then
12524        AC_MSG_ERROR([need to --disable-lpsolve - calc linear programming solver.])
12525    fi
12526
12527    MPL_SUBSET="TRUE"
12528    AC_DEFINE(MPL_HAVE_SUBSET)
12529    AC_MSG_RESULT([only])
12530else
12531    AC_MSG_RESULT([no restrictions])
12532fi
12533AC_SUBST(MPL_SUBSET)
12534
12535dnl ===================================================================
12536
12537AC_MSG_CHECKING([formula logger])
12538ENABLE_FORMULA_LOGGER=
12539
12540if test "x$enable_formula_logger" = "xyes"; then
12541    AC_MSG_RESULT([yes])
12542    AC_DEFINE(ENABLE_FORMULA_LOGGER)
12543    ENABLE_FORMULA_LOGGER=TRUE
12544elif test -n "$ENABLE_DBGUTIL" ; then
12545    AC_MSG_RESULT([yes])
12546    AC_DEFINE(ENABLE_FORMULA_LOGGER)
12547    ENABLE_FORMULA_LOGGER=TRUE
12548else
12549    AC_MSG_RESULT([no])
12550fi
12551
12552AC_SUBST(ENABLE_FORMULA_LOGGER)
12553
12554dnl ===================================================================
12555dnl Setting up the environment.
12556dnl ===================================================================
12557AC_MSG_NOTICE([setting up the build environment variables...])
12558
12559AC_SUBST(COMPATH)
12560
12561if test "$build_os" = "cygwin"; then
12562    if test -d "$COMPATH/atlmfc/lib/spectre"; then
12563        ATL_LIB="$COMPATH/atlmfc/lib/spectre"
12564        ATL_INCLUDE="$COMPATH/atlmfc/include"
12565    elif test -d "$COMPATH/atlmfc/lib"; then
12566        ATL_LIB="$COMPATH/atlmfc/lib"
12567        ATL_INCLUDE="$COMPATH/atlmfc/include"
12568    else
12569        ATL_LIB="$WINDOWS_SDK_HOME/lib" # Doesn't exist for VSE
12570        ATL_INCLUDE="$WINDOWS_SDK_HOME/include/atl"
12571    fi
12572    if test "$BITNESS_OVERRIDE" = 64; then
12573        ATL_LIB="$ATL_LIB/x64"
12574    else
12575        ATL_LIB="$ATL_LIB/x86"
12576    fi
12577    # sort.exe and find.exe also exist in C:/Windows/system32 so need /usr/bin/
12578    PathFormat "/usr/bin/find.exe"
12579    FIND="$formatted_path"
12580    PathFormat "/usr/bin/sort.exe"
12581    SORT="$formatted_path"
12582    PathFormat "/usr/bin/grep.exe"
12583    WIN_GREP="$formatted_path"
12584    PathFormat "/usr/bin/ls.exe"
12585    WIN_LS="$formatted_path"
12586    PathFormat "/usr/bin/touch.exe"
12587    WIN_TOUCH="$formatted_path"
12588else
12589    FIND=find
12590    SORT=sort
12591fi
12592
12593AC_SUBST(ATL_INCLUDE)
12594AC_SUBST(ATL_LIB)
12595AC_SUBST(FIND)
12596AC_SUBST(SORT)
12597AC_SUBST(WIN_GREP)
12598AC_SUBST(WIN_LS)
12599AC_SUBST(WIN_TOUCH)
12600
12601AC_SUBST(BUILD_TYPE)
12602
12603AC_SUBST(SOLARINC)
12604
12605PathFormat "$PERL"
12606PERL="$formatted_path"
12607AC_SUBST(PERL)
12608
12609if test -n "$TMPDIR"; then
12610    TEMP_DIRECTORY="$TMPDIR"
12611else
12612    TEMP_DIRECTORY="/tmp"
12613fi
12614if test "$build_os" = "cygwin"; then
12615    TEMP_DIRECTORY=`cygpath -m "$TEMP_DIRECTORY"`
12616fi
12617AC_SUBST(TEMP_DIRECTORY)
12618
12619# setup the PATH for the environment
12620if test -n "$LO_PATH_FOR_BUILD"; then
12621    LO_PATH="$LO_PATH_FOR_BUILD"
12622else
12623    LO_PATH="$PATH"
12624
12625    case "$host_os" in
12626
12627    aix*|dragonfly*|freebsd*|linux-gnu*|*netbsd*|openbsd*)
12628        if test "$ENABLE_JAVA" != ""; then
12629            pathmunge "$JAVA_HOME/bin" "after"
12630        fi
12631        ;;
12632
12633    cygwin*)
12634        # Win32 make needs native paths
12635        if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
12636            LO_PATH=`cygpath -p -m "$PATH"`
12637        fi
12638        if test "$BITNESS_OVERRIDE" = 64; then
12639            # needed for msi packaging
12640            pathmunge "$WINDOWS_SDK_BINDIR_NO_ARCH/x86" "before"
12641        fi
12642        # .NET 4.6 and higher don't have bin directory
12643        if test -f "$DOTNET_FRAMEWORK_HOME/bin"; then
12644            pathmunge "$DOTNET_FRAMEWORK_HOME/bin" "before"
12645        fi
12646        pathmunge "$WINDOWS_SDK_HOME/bin" "before"
12647        pathmunge "$CSC_PATH" "before"
12648        pathmunge "$MIDL_PATH" "before"
12649        pathmunge "$AL_PATH" "before"
12650        pathmunge "$MSPDB_PATH" "before"
12651        if test "$MSPDB_PATH" != "$CL_PATH" ; then
12652            pathmunge "$CL_PATH" "before"
12653        fi
12654        if test -n "$MSBUILD_PATH" ; then
12655            pathmunge "$MSBUILD_PATH" "before"
12656        fi
12657        if test "$BITNESS_OVERRIDE" = 64; then
12658            pathmunge "$COMPATH/bin/amd64" "before"
12659            pathmunge "$WINDOWS_SDK_BINDIR_NO_ARCH/x64" "before"
12660        else
12661            pathmunge "$COMPATH/bin" "before"
12662            pathmunge "$WINDOWS_SDK_BINDIR_NO_ARCH/x86" "before"
12663        fi
12664        if test "$ENABLE_JAVA" != ""; then
12665            if test -d "$JAVA_HOME/jre/bin/client"; then
12666                pathmunge "$JAVA_HOME/jre/bin/client" "before"
12667            fi
12668            if test -d "$JAVA_HOME/jre/bin/hotspot"; then
12669                pathmunge "$JAVA_HOME/jre/bin/hotspot" "before"
12670            fi
12671            pathmunge "$JAVA_HOME/bin" "before"
12672        fi
12673        ;;
12674
12675    solaris*)
12676        pathmunge "/usr/css/bin" "before"
12677        if test "$ENABLE_JAVA" != ""; then
12678            pathmunge "$JAVA_HOME/bin" "after"
12679        fi
12680        ;;
12681    esac
12682fi
12683
12684AC_SUBST(LO_PATH)
12685
12686libo_FUZZ_SUMMARY
12687
12688# Generate a configuration sha256 we can use for deps
12689if test -f config_host.mk; then
12690    config_sha256=`$SHA256SUM config_host.mk | sed "s/ .*//"`
12691fi
12692if test -f config_host_lang.mk; then
12693    config_lang_sha256=`$SHA256SUM config_host_lang.mk | sed "s/ .*//"`
12694fi
12695
12696CFLAGS=$my_original_CFLAGS
12697CXXFLAGS=$my_original_CXXFLAGS
12698CPPFLAGS=$my_original_CPPFLAGS
12699
12700AC_CONFIG_FILES([config_host.mk
12701                 config_host_lang.mk
12702                 Makefile
12703                 bin/bffvalidator.sh
12704                 bin/odfvalidator.sh
12705                 bin/officeotron.sh
12706                 instsetoo_native/util/openoffice.lst
12707                 sysui/desktop/macosx/Info.plist])
12708AC_CONFIG_HEADERS([config_host/config_buildid.h])
12709AC_CONFIG_HEADERS([config_host/config_clang.h])
12710AC_CONFIG_HEADERS([config_host/config_dconf.h])
12711AC_CONFIG_HEADERS([config_host/config_eot.h])
12712AC_CONFIG_HEADERS([config_host/config_extensions.h])
12713AC_CONFIG_HEADERS([config_host/config_cairo_canvas.h])
12714AC_CONFIG_HEADERS([config_host/config_cxxabi.h])
12715AC_CONFIG_HEADERS([config_host/config_dbus.h])
12716AC_CONFIG_HEADERS([config_host/config_features.h])
12717AC_CONFIG_HEADERS([config_host/config_firebird.h])
12718AC_CONFIG_HEADERS([config_host/config_folders.h])
12719AC_CONFIG_HEADERS([config_host/config_fuzzers.h])
12720AC_CONFIG_HEADERS([config_host/config_gio.h])
12721AC_CONFIG_HEADERS([config_host/config_global.h])
12722AC_CONFIG_HEADERS([config_host/config_gpgme.h])
12723AC_CONFIG_HEADERS([config_host/config_java.h])
12724AC_CONFIG_HEADERS([config_host/config_langs.h])
12725AC_CONFIG_HEADERS([config_host/config_lgpl.h])
12726AC_CONFIG_HEADERS([config_host/config_libcxx.h])
12727AC_CONFIG_HEADERS([config_host/config_liblangtag.h])
12728AC_CONFIG_HEADERS([config_host/config_libnumbertext.h])
12729AC_CONFIG_HEADERS([config_host/config_locales.h])
12730AC_CONFIG_HEADERS([config_host/config_mpl.h])
12731AC_CONFIG_HEADERS([config_host/config_oox.h])
12732AC_CONFIG_HEADERS([config_host/config_options.h])
12733AC_CONFIG_HEADERS([config_host/config_options_calc.h])
12734AC_CONFIG_HEADERS([config_host/config_typesizes.h])
12735AC_CONFIG_HEADERS([config_host/config_vendor.h])
12736AC_CONFIG_HEADERS([config_host/config_vcl.h])
12737AC_CONFIG_HEADERS([config_host/config_vclplug.h])
12738AC_CONFIG_HEADERS([config_host/config_version.h])
12739AC_CONFIG_HEADERS([config_host/config_oauth2.h])
12740AC_CONFIG_HEADERS([config_host/config_poppler.h])
12741AC_CONFIG_HEADERS([config_host/config_python.h])
12742AC_CONFIG_HEADERS([config_host/config_writerperfect.h])
12743AC_OUTPUT
12744
12745if test "$CROSS_COMPILING" = TRUE; then
12746    (echo; echo export BUILD_TYPE_FOR_HOST=$BUILD_TYPE) >>config_build.mk
12747fi
12748
12749# touch the config timestamp file
12750if test ! -f config_host.mk.stamp; then
12751    echo > config_host.mk.stamp
12752elif test "$config_sha256" = `$SHA256SUM config_host.mk | sed "s/ .*//"`; then
12753    echo "Host Configuration unchanged - avoiding scp2 stamp update"
12754else
12755    echo > config_host.mk.stamp
12756fi
12757
12758# touch the config lang timestamp file
12759if test ! -f config_host_lang.mk.stamp; then
12760    echo > config_host_lang.mk.stamp
12761elif test "$config_lang_sha256" = `$SHA256SUM config_host_lang.mk | sed "s/ .*//"`; then
12762    echo "Language Configuration unchanged - avoiding scp2 stamp update"
12763else
12764    echo > config_host_lang.mk.stamp
12765fi
12766
12767
12768if test \( "$STALE_MAKE" = "TRUE" -o "$HAVE_GNUMAKE_FILE_FUNC" != "TRUE" \) \
12769        -a "$build_os" = "cygwin"; then
12770
12771cat << _EOS
12772****************************************************************************
12773WARNING:
12774Your make version is known to be horribly slow, and hard to debug
12775problems with. To get a reasonably functional make please do:
12776
12777to install a pre-compiled binary make for Win32
12778
12779 mkdir -p /opt/lo/bin
12780 cd /opt/lo/bin
12781 wget https://dev-www.libreoffice.org/bin/cygwin/make-4.2.1-msvc.exe
12782 cp make-4.2.1-msvc.exe make
12783 chmod +x make
12784
12785to install from source:
12786place yourself in a working directory of you choice.
12787
12788 git clone git://git.savannah.gnu.org/make.git
12789
12790 [go to Start menu, open "Visual Studio 2017", click "VS2017 x86 Native Tools Command Prompt" or "VS2017 x64 Native Tools Command Prompt"]
12791 set PATH=%PATH%;C:\Cygwin\bin
12792 [or Cygwin64, if that is what you have]
12793 cd path-to-make-repo-you-cloned-above
12794 build_w32.bat --without-guile
12795
12796should result in a WinRel/gnumake.exe.
12797Copy it to the Cygwin /opt/lo/bin directory as make.exe
12798
12799Then re-run autogen.sh
12800
12801Note: autogen.sh will try to use /opt/lo/bin/make if the environment variable GNUMAKE is not already defined.
12802Alternatively, you can install the 'new' make where ever you want and make sure that `which make` finds it.
12803
12804_EOS
12805if test "$HAVE_GNUMAKE_FILE_FUNC" != "TRUE"; then
12806    AC_MSG_ERROR([no file function found; the build will fail without it; use GNU make 4.0 or later])
12807fi
12808fi
12809
12810
12811cat << _EOF
12812****************************************************************************
12813
12814To build, run:
12815$GNUMAKE
12816
12817To view some help, run:
12818$GNUMAKE help
12819
12820_EOF
12821
12822if test $_os != WINNT -a "$CROSS_COMPILING" != TRUE; then
12823    cat << _EOF
12824After the build of LibreOffice has finished successfully, you can immediately run LibreOffice using the command:
12825_EOF
12826
12827    if test $_os = Darwin; then
12828        echo open instdir/$PRODUCTNAME.app
12829    else
12830        echo instdir/program/soffice
12831    fi
12832    cat << _EOF
12833
12834If you want to run the smoketest, run:
12835$GNUMAKE check
12836
12837_EOF
12838fi
12839
12840if test -f warn; then
12841    cat warn
12842    rm warn
12843fi
12844
12845dnl vim:set shiftwidth=4 softtabstop=4 expandtab:
12846