1dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; fill-column: 100 -*-
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],[7.2.6.2],[],[],[http://documentfoundation.org/])
13
14dnl libnumbertext needs autoconf 2.68, but that can pick up autoconf268 just fine if it is installed
15dnl whereas aclocal (as run by autogen.sh) insists on using autoconf and fails hard
16dnl so check for the version of autoconf that is actually used to create the configure script
17AC_PREREQ([2.59])
18m4_if(m4_version_compare(m4_defn([AC_AUTOCONF_VERSION]), [2.68]), -1,
19    [AC_MSG_ERROR([at least autoconf version 2.68 is needed (you can use AUTOCONF environment variable to point to a suitable one)])])
20
21if test -n "$BUILD_TYPE"; then
22    AC_MSG_ERROR([You have sourced config_host.mk in this shell.  This may lead to trouble, please run in a fresh (login) shell.])
23fi
24
25save_CC=$CC
26save_CXX=$CXX
27
28first_arg_basename()
29{
30    for i in $1; do
31        basename "$i"
32        break
33    done
34}
35
36CC_BASE=`first_arg_basename "$CC"`
37CXX_BASE=`first_arg_basename "$CXX"`
38
39BUILD_TYPE="LibO"
40SCPDEFS=""
41GIT_NEEDED_SUBMODULES=""
42LO_PATH= # used by path_munge to construct a PATH variable
43
44FilterLibs()
45{
46    # Return value: $filteredlibs
47
48    filteredlibs=
49    for f in $1; do
50        case "$f" in
51            # let's start with Fedora's paths for now
52            -L/lib|-L/lib/|-L/lib64|-L/lib64/|-L/usr/lib|-L/usr/lib/|-L/usr/lib64|-L/usr/lib64/)
53                # ignore it: on UNIXoids it is searched by default anyway
54                # but if it's given explicitly then it may override other paths
55                # (on macOS it would be an error to use it instead of SDK)
56                ;;
57            *)
58                filteredlibs="$filteredlibs $f"
59                ;;
60        esac
61    done
62}
63
64PathFormat()
65{
66    # Args: $1: A pathname. On Cygwin and WSL, in either the Unix or the Windows format. Note that this
67    # function is called also on Unix.
68    #
69    # Return value: $formatted_path and $formatted_path_unix.
70    #
71    # $formatted_path is the argument in Windows format, but using forward slashes instead of
72    # backslashes, using 8.3 pathname components if necessary (if it otherwise would contains spaces
73    # or shell metacharacters).
74    #
75    # $formatted_path_unix is the argument in a form usable in Cygwin or WSL, using 8.3 components if
76    # necessary. On Cygwin, it is the same as $formatted_path, but on WSL it is $formatted_path as a
77    # Unix pathname.
78    #
79    # Errors out if 8.3 names are needed but aren't present for some of the path components.
80
81    # Examples:
82    #
83    # /home/tml/lo/master-optimised => C:/cygwin64/home/tml/lo/master-optimised
84    #
85    # C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe => C:/PROGRA~2/MICROS~3/INSTAL~1/vswhere.exe
86    #
87    # C:\Program Files (x86)\Microsoft Visual Studio\2019\Community => C:/PROGRA~2/MICROS~3/2019/COMMUN~1
88    #
89    # C:/PROGRA~2/WI3CF2~1/10/Include/10.0.18362.0/ucrt => C:/PROGRA~2/WI3CF2~1/10/Include/10.0.18362.0/ucrt
90    #
91    # /cygdrive/c/PROGRA~2/WI3CF2~1/10 => C:/PROGRA~2/WI3CF2~1/10
92    #
93    # C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\ => C:/PROGRA~2/WI3CF2~1/NETFXSDK/4.8/
94    #
95    # /usr/bin/find.exe => C:/cygwin64/bin/find.exe
96
97    if test -n "$UNITTEST_WSL_PATHFORMAT"; then
98        printf "PathFormat $1 ==> "
99    fi
100
101    formatted_path="$1"
102    if test "$build_os" = "cygwin" -o "$build_os" = "wsl"; then
103        if test "$build_os" = "wsl"; then
104            formatted_path=$(echo "$formatted_path" | tr -d '\r')
105        fi
106
107        pf_conv_to_dos=
108        # spaces,parentheses,brackets,braces are problematic in pathname
109        # so are backslashes
110        case "$formatted_path" in
111            *\ * | *\)* | *\(* | *\{* | *\}* | *\[* | *\]* | *\\* )
112                pf_conv_to_dos="yes"
113            ;;
114        esac
115        if test "$pf_conv_to_dos" = "yes"; then
116            if test "$build_os" = "wsl"; then
117                case "$formatted_path" in
118                    /*)
119                        formatted_path=$(wslpath -w "$formatted_path")
120                        ;;
121                esac
122                formatted_path=$($BUILDDIR/solenv/wsl/wsl-lo-helper.exe --8.3 "$formatted_path")
123            elif test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
124                formatted_path=`cygpath -sm "$formatted_path"`
125            else
126                formatted_path=`cygpath -d "$formatted_path"`
127            fi
128            if test $? -ne 0;  then
129                AC_MSG_ERROR([path conversion failed for "$1".])
130            fi
131        fi
132        fp_count_colon=`echo "$formatted_path" | $GREP -c "[:]"`
133        fp_count_slash=`echo "$formatted_path" | $GREP -c "[/]"`
134        if test "$fp_count_slash$fp_count_colon" != "00"; then
135            if test "$fp_count_colon" = "0"; then
136                new_formatted_path=`realpath "$formatted_path"`
137                if test $? -ne 0;  then
138                    AC_MSG_WARN([realpath failed for "$formatted_path", not necessarily a problem.])
139                else
140                    formatted_path="$new_formatted_path"
141                fi
142            fi
143            if test "$build_os" = "wsl"; then
144                if test "$fp_count_colon" != "0"; then
145                    formatted_path=$(wslpath "$formatted_path")
146                    local final_slash=
147                    case "$formatted_path" in
148                        */)
149                            final_slash=/
150                            ;;
151                    esac
152                    formatted_path=$(wslpath -m $formatted_path)
153                    case "$formatted_path" in
154                        */)
155                            ;;
156                        *)
157                            formatted_path="$formatted_path"$final_slash
158                            ;;
159                    esac
160                else
161                    formatted_path=$(wslpath -m "$formatted_path")
162                fi
163            else
164                formatted_path=`cygpath -m "$formatted_path"`
165            fi
166            if test $? -ne 0;  then
167                AC_MSG_ERROR([path conversion failed for "$1".])
168            fi
169        fi
170        fp_count_space=`echo "$formatted_path" | $GREP -c "[ ]"`
171        if test "$fp_count_space" != "0"; then
172            AC_MSG_ERROR([converted path "$formatted_path" still contains spaces. Short filenames (8.3 filenames) support was disabled on this system?])
173        fi
174    fi
175    if test "$build_os" = "wsl"; then
176        # WSL can't run Windows binaries from Windows pathnames so we need a separate return value in Unix format
177        formatted_path_unix=$(wslpath "$formatted_path")
178    else
179        # But Cygwin can
180        formatted_path_unix="$formatted_path"
181    fi
182}
183
184AbsolutePath()
185{
186    # There appears to be no simple and portable method to get an absolute and
187    # canonical path, so we try creating the directory if does not exist and
188    # utilizing the shell and pwd.
189
190    # Args: $1: A possibly relative pathname
191    # Return value: $absolute_path
192
193    local rel="$1"
194    absolute_path=""
195    test ! -e "$rel" && mkdir -p "$rel"
196    if test -d "$rel" ; then
197        cd "$rel" || AC_MSG_ERROR([absolute path resolution failed for "$rel".])
198        absolute_path="$(pwd)"
199        cd - > /dev/null
200    else
201        AC_MSG_ERROR([Failed to resolve absolute path.  "$rel" does not exist or is not a directory.])
202    fi
203}
204
205WARNINGS_FILE=config.warn
206WARNINGS_FILE_FOR_BUILD=config.Build.warn
207rm -f "$WARNINGS_FILE" "$WARNINGS_FILE_FOR_BUILD"
208have_WARNINGS="no"
209add_warning()
210{
211    if test "$have_WARNINGS" = "no"; then
212        echo "*************************************" > "$WARNINGS_FILE"
213        have_WARNINGS="yes"
214        if which tput >/dev/null && test "`tput colors 2>/dev/null || echo 0`" -ge 8; then
215            dnl <esc> as actual byte (U+1b), [ escaped using quadrigraph @<:@
216            COLORWARN='*@<:@1;33;40m WARNING @<:@0m:'
217        else
218            COLORWARN="* WARNING :"
219        fi
220    fi
221    echo "$COLORWARN $@" >> "$WARNINGS_FILE"
222}
223
224dnl Some Mac User have the bad habit of letting a lot of crap
225dnl accumulate in their PATH and even adding stuff in /usr/local/bin
226dnl that confuse the build.
227dnl For the ones that use LODE, let's be nice and protect them
228dnl from themselves
229
230mac_sanitize_path()
231{
232    mac_path="$LODE_HOME/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin"
233dnl a common but nevertheless necessary thing that may be in a fancy
234dnl path location is git, so make sure we have it
235    mac_git_path=`which git 2>/dev/null`
236    if test -n "$mac_git_path" -a -x "$mac_git_path" -a "$mac_git_path" != "/usr/bin/git" ; then
237        mac_path="$mac_path:`dirname $mac_git_path`"
238    fi
239dnl a not so common but nevertheless quite helpful thing that may be in a fancy
240dnl path location is gpg, so make sure we find it
241    mac_gpg_path=`which gpg 2>/dev/null`
242    if test -n "$mac_gpg_path" -a -x "$mac_gpg_path" -a "$mac_gpg_path" != "/usr/bin/gpg" ; then
243        mac_path="$mac_path:`dirname $mac_gpg_path`"
244    fi
245    PATH="$mac_path"
246    unset mac_path
247    unset mac_git_path
248    unset mac_gpg_path
249}
250
251echo "********************************************************************"
252echo "*"
253echo "*   Running ${PACKAGE_NAME} build configuration."
254echo "*"
255echo "********************************************************************"
256echo ""
257
258dnl ===================================================================
259dnl checks build and host OSes
260dnl do this before argument processing to allow for platform dependent defaults
261dnl ===================================================================
262
263# Check for WSL (version 2, at least). But if --host is explicitly specified (to really do build for
264# Linux on WSL) trust that.
265if test -z "$host" -a -z "$build" -a "`wslsys -v 2>/dev/null`" != ""; then
266    ac_cv_host="x86_64-pc-wsl"
267    ac_cv_host_cpu="x86_64"
268    ac_cv_host_os="wsl"
269    ac_cv_build="$ac_cv_host"
270    ac_cv_build_cpu="$ac_cv_host_cpu"
271    ac_cv_build_os="$ac_cv_host_os"
272
273    # Emulation of Cygwin's cygpath command for WSL.
274    cygpath()
275    {
276        if test -n "$UNITTEST_WSL_CYGPATH"; then
277            echo -n cygpath "$@" "==> "
278        fi
279
280        # Cygwin's real cygpath has a plethora of options but we use only a few here.
281        local args="$@"
282        local opt
283        local opt_d opt_m opt_u opt_w opt_l opt_s opt_p
284        OPTIND=1
285
286        while getopts dmuwlsp opt; do
287            case "$opt" in
288                \?)
289                    AC_MSG_ERROR([Unimplemented cygpath emulation option in invocation: cygpath $args])
290                    ;;
291                ?)
292                    eval opt_$opt=yes
293                    ;;
294            esac
295        done
296
297        shift $((OPTIND-1))
298
299        if test $# -ne 1; then
300            AC_MSG_ERROR([Invalid cygpath emulation invocation: Pathname missing]);
301        fi
302
303        local input="$1"
304
305        local result
306
307        if test -n "$opt_d" -o -n "$opt_m" -o -n "$opt_w"; then
308            # Print Windows path, possibly in 8.3 form (-d) or with forward slashes (-m)
309
310            if test -n "$opt_u"; then
311                AC_MSG_ERROR([Invalid cygpath invocation: Both Windows and Unix path output requested])
312            fi
313
314            case "$input" in
315                /mnt/*)
316                    # A Windows file in WSL format
317                    input=$(wslpath -w "$input")
318                    ;;
319                [[a-zA-Z]]:\\* | \\* | [[a-zA-Z]]:/* | /*)
320                    # Already in Windows format
321                    ;;
322                /*)
323                    input=$(wslpath -w "$input")
324                    ;;
325                *)
326                    AC_MSG_ERROR([Invalid cygpath invocation: Path '$input' is not absolute])
327                    ;;
328            esac
329            if test -n "$opt_d" -o -n "$opt_s"; then
330                input=$($BUILDDIR/solenv/wsl/wsl-lo-helper.exe --8.3 "$input")
331            fi
332            if test -n "$opt_m"; then
333                input="${input//\\//}"
334            fi
335            echo "$input"
336        else
337            # Print Unix path
338
339            case "$input" in
340                [[a-zA-Z]]:\\* | \\* | [[a-zA-Z]]:/* | /*)
341                    wslpath -u "$input"
342                    ;;
343                /)
344                    echo "$input"
345                    ;;
346                *)
347                    AC_MSG_ERROR([Invalid cygpath invocation: Path '$input' is not absolute])
348                    ;;
349            esac
350        fi
351    }
352
353    if test -n "$UNITTEST_WSL_CYGPATH"; then
354        BUILDDIR=.
355
356        # Nothing special with these file names, just arbitrary ones picked to test with
357        cygpath -d /usr/lib64/ld-linux-x86-64.so.2
358        cygpath -w /usr/lib64/ld-linux-x86-64.so.2
359        cygpath -m /usr/lib64/ld-linux-x86-64.so.2
360        cygpath -m -s /usr/lib64/ld-linux-x86-64.so.2
361        # At least on my machine for instance this file does have an 8.3 name
362        cygpath -d /mnt/c/windows/WindowsUpdate.log
363        # But for instance this one doesn't
364        cygpath -w /mnt/c/windows/system32/AboutSettingsHandlers.dll
365        cygpath -ws /mnt/c/windows/WindowsUpdate.log
366        cygpath -m /mnt/c/windows/system32/AboutSettingsHandlers.dll
367        cygpath -ms /mnt/c/windows/WindowsUpdate.log
368
369        cygpath -u 'c:\windows\system32\AboutSettingsHandlers.dll'
370        cygpath -u 'c:/windows/system32/AboutSettingsHandlers.dll'
371
372        exit 0
373    fi
374fi
375
376AC_CANONICAL_HOST
377AC_CANONICAL_BUILD
378
379if test -n "$UNITTEST_WSL_PATHFORMAT"; then
380    BUILDDIR=.
381    GREP=grep
382
383    # Use of PathFormat must be after AC_CANONICAL_BUILD above
384    PathFormat /
385    printf "$formatted_path , $formatted_path_unix\n"
386
387    PathFormat $PWD
388    printf "$formatted_path , $formatted_path_unix\n"
389
390    PathFormat "$PROGRAMFILESX86"
391    printf "$formatted_path , $formatted_path_unix\n"
392
393    exit 0
394fi
395
396AC_MSG_CHECKING([for product name])
397PRODUCTNAME="AC_PACKAGE_NAME"
398if test -n "$with_product_name" -a "$with_product_name" != no; then
399    PRODUCTNAME="$with_product_name"
400fi
401if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
402    PRODUCTNAME="${PRODUCTNAME}Dev"
403fi
404AC_MSG_RESULT([$PRODUCTNAME])
405AC_SUBST(PRODUCTNAME)
406PRODUCTNAME_WITHOUT_SPACES=$(printf %s "$PRODUCTNAME" | sed 's/ //g')
407AC_SUBST(PRODUCTNAME_WITHOUT_SPACES)
408
409dnl ===================================================================
410dnl Our version is defined by the AC_INIT() at the top of this script.
411dnl ===================================================================
412
413AC_MSG_CHECKING([for package version])
414if test -n "$with_package_version" -a "$with_package_version" != no; then
415    PACKAGE_VERSION="$with_package_version"
416fi
417AC_MSG_RESULT([$PACKAGE_VERSION])
418
419set `echo "$PACKAGE_VERSION" | sed "s/\./ /g"`
420
421LIBO_VERSION_MAJOR=$1
422LIBO_VERSION_MINOR=$2
423LIBO_VERSION_MICRO=$3
424LIBO_VERSION_PATCH=$4
425
426LIBO_VERSION_SUFFIX=$5
427
428# Split out LIBO_VERSION_SUFFIX_SUFFIX... horrible crack. But apparently wanted separately in
429# openoffice.lst as ABOUTBOXPRODUCTVERSIONSUFFIX. Note that the double brackets are for m4's sake,
430# they get undoubled before actually passed to sed.
431LIBO_VERSION_SUFFIX_SUFFIX=`echo "$LIBO_VERSION_SUFFIX" | sed -e 's/.*[[a-zA-Z0-9]]\([[^a-zA-Z0-9]]*\)$/\1/'`
432test -n "$LIBO_VERSION_SUFFIX_SUFFIX" && LIBO_VERSION_SUFFIX="${LIBO_VERSION_SUFFIX%${LIBO_VERSION_SUFFIX_SUFFIX}}"
433# LIBO_VERSION_SUFFIX, if non-empty, should include the period separator
434test -n "$LIBO_VERSION_SUFFIX" && LIBO_VERSION_SUFFIX=".$LIBO_VERSION_SUFFIX"
435
436# The value for key CFBundleVersion in the Info.plist file must be a period-separated list of at most
437# three non-negative integers. Please find more information about CFBundleVersion at
438# https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion
439
440# The value for key CFBundleShortVersionString in the Info.plist file must be a period-separated list
441# of at most three non-negative integers. Please find more information about
442# CFBundleShortVersionString at
443# https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring
444
445# But that is enforced only in the App Store, and we apparently want to break the rules otherwise.
446
447if test "$enable_macosx_sandbox" = yes; then
448    MACOSX_BUNDLE_SHORTVERSION=$LIBO_VERSION_MAJOR.$LIBO_VERSION_MINOR.`expr $LIBO_VERSION_MICRO '*' 1000 + $LIBO_VERSION_PATCH`
449    MACOSX_BUNDLE_VERSION=$MACOSX_BUNDLE_SHORTVERSION
450else
451    MACOSX_BUNDLE_SHORTVERSION=$LIBO_VERSION_MAJOR.$LIBO_VERSION_MINOR.$LIBO_VERSION_MICRO.$LIBO_VERSION_PATCH
452    MACOSX_BUNDLE_VERSION=$MACOSX_BUNDLE_SHORTVERSION$LIBO_VERSION_SUFFIX
453fi
454
455AC_SUBST(LIBO_VERSION_MAJOR)
456AC_SUBST(LIBO_VERSION_MINOR)
457AC_SUBST(LIBO_VERSION_MICRO)
458AC_SUBST(LIBO_VERSION_PATCH)
459AC_SUBST(LIBO_VERSION_SUFFIX)
460AC_SUBST(LIBO_VERSION_SUFFIX_SUFFIX)
461AC_SUBST(MACOSX_BUNDLE_SHORTVERSION)
462AC_SUBST(MACOSX_BUNDLE_VERSION)
463
464AC_DEFINE_UNQUOTED(LIBO_VERSION_MAJOR,$LIBO_VERSION_MAJOR)
465AC_DEFINE_UNQUOTED(LIBO_VERSION_MINOR,$LIBO_VERSION_MINOR)
466AC_DEFINE_UNQUOTED(LIBO_VERSION_MICRO,$LIBO_VERSION_MICRO)
467AC_DEFINE_UNQUOTED(LIBO_VERSION_PATCH,$LIBO_VERSION_PATCH)
468
469LIBO_THIS_YEAR=`date +%Y`
470AC_DEFINE_UNQUOTED(LIBO_THIS_YEAR,$LIBO_THIS_YEAR)
471
472dnl ===================================================================
473dnl Product version
474dnl ===================================================================
475AC_MSG_CHECKING([for product version])
476PRODUCTVERSION="$LIBO_VERSION_MAJOR.$LIBO_VERSION_MINOR"
477AC_MSG_RESULT([$PRODUCTVERSION])
478AC_SUBST(PRODUCTVERSION)
479
480AC_PROG_EGREP
481# AC_PROG_EGREP doesn't set GREP on all systems as well
482AC_PATH_PROG(GREP, grep)
483
484BUILDDIR=`pwd`
485cd $srcdir
486SRC_ROOT=`pwd`
487cd $BUILDDIR
488x_Cygwin=[\#]
489
490dnl ======================================
491dnl Required GObject introspection version
492dnl ======================================
493INTROSPECTION_REQUIRED_VERSION=1.32.0
494
495dnl ===================================================================
496dnl Search all the common names for GNU Make
497dnl ===================================================================
498AC_MSG_CHECKING([for GNU Make])
499
500# try to use our own make if it is available and GNUMAKE was not already defined
501if test -z "$GNUMAKE"; then
502    if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/make" ; then
503        GNUMAKE="$LODE_HOME/opt/bin/make"
504    elif test -x "/opt/lo/bin/make"; then
505        GNUMAKE="/opt/lo/bin/make"
506    fi
507fi
508
509GNUMAKE_WIN_NATIVE=
510for a in "$MAKE" "$GNUMAKE" make gmake gnumake; do
511    if test -n "$a"; then
512        $a --version 2> /dev/null | grep GNU  2>&1 > /dev/null
513        if test $? -eq 0;  then
514            if test "$build_os" = "cygwin"; then
515                if test -n "$($a -v | grep 'Built for Windows')" ; then
516                    GNUMAKE="$(cygpath -m "$(which "$(cygpath -u $a)")")"
517                    GNUMAKE_WIN_NATIVE="TRUE"
518                else
519                    GNUMAKE=`which $a`
520                fi
521            else
522                GNUMAKE=`which $a`
523            fi
524            break
525        fi
526    fi
527done
528AC_MSG_RESULT($GNUMAKE)
529if test -z "$GNUMAKE"; then
530    AC_MSG_ERROR([not found. install GNU Make.])
531else
532    if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
533        AC_MSG_NOTICE([Using a native Win32 GNU Make version.])
534    fi
535fi
536
537win_short_path_for_make()
538{
539    local short_path="$1"
540    if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
541        cygpath -sm "$short_path"
542    else
543        cygpath -u "$(cygpath -d "$short_path")"
544    fi
545}
546
547
548if test "$build_os" = "cygwin"; then
549    PathFormat "$SRC_ROOT"
550    SRC_ROOT="$formatted_path"
551    PathFormat "$BUILDDIR"
552    BUILDDIR="$formatted_path"
553    x_Cygwin=
554    AC_MSG_CHECKING(for explicit COMSPEC)
555    if test -z "$COMSPEC"; then
556        AC_MSG_ERROR([COMSPEC not set in environment, please set it and rerun])
557    else
558        AC_MSG_RESULT([found: $COMSPEC])
559    fi
560fi
561
562AC_SUBST(SRC_ROOT)
563AC_SUBST(BUILDDIR)
564AC_SUBST(x_Cygwin)
565AC_DEFINE_UNQUOTED(SRCDIR,"$SRC_ROOT")
566AC_DEFINE_UNQUOTED(SRC_ROOT,"$SRC_ROOT")
567AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
568
569if test "z$EUID" = "z0" -a "`uname -o 2>/dev/null`" = "Cygwin"; then
570    AC_MSG_ERROR([You must build LibreOffice as a normal user - not using an administrative account])
571fi
572
573# need sed in os checks...
574AC_PATH_PROGS(SED, sed)
575if test -z "$SED"; then
576    AC_MSG_ERROR([install sed to run this script])
577fi
578
579# Set the ENABLE_LTO variable
580# ===================================================================
581AC_MSG_CHECKING([whether to use link-time optimization])
582if test -n "$enable_lto" -a "$enable_lto" != "no"; then
583    ENABLE_LTO="TRUE"
584    AC_MSG_RESULT([yes])
585else
586    ENABLE_LTO=""
587    AC_MSG_RESULT([no])
588fi
589AC_SUBST(ENABLE_LTO)
590
591AC_ARG_ENABLE(fuzz-options,
592    AS_HELP_STRING([--enable-fuzz-options],
593        [Randomly enable or disable each of those configurable options
594         that are supposed to be freely selectable without interdependencies,
595         or where bad interaction from interdependencies is automatically avoided.])
596)
597
598dnl ===================================================================
599dnl When building for Android, --with-android-ndk,
600dnl --with-android-ndk-toolchain-version and --with-android-sdk are
601dnl mandatory
602dnl ===================================================================
603
604AC_ARG_WITH(android-ndk,
605    AS_HELP_STRING([--with-android-ndk],
606        [Specify location of the Android Native Development Kit. Mandatory when building for Android.]),
607,)
608
609AC_ARG_WITH(android-ndk-toolchain-version,
610    AS_HELP_STRING([--with-android-ndk-toolchain-version],
611        [Specify which toolchain version to use, of those present in the
612        Android NDK you are using. The default (and only supported version currently) is "clang5.0"]),,
613        with_android_ndk_toolchain_version=clang5.0)
614
615AC_ARG_WITH(android-sdk,
616    AS_HELP_STRING([--with-android-sdk],
617        [Specify location of the Android SDK. Mandatory when building for Android.]),
618,)
619
620AC_ARG_WITH(android-api-level,
621    AS_HELP_STRING([--with-android-api-level],
622        [Specify the API level when building for Android. Defaults to 16 for ARM and x86 and to 21 for ARM64 and x86-64]),
623,)
624
625ANDROID_NDK_HOME=
626if test -z "$with_android_ndk" -a -e "$SRC_ROOT/external/android-ndk" -a "$build" != "$host"; then
627    with_android_ndk="$SRC_ROOT/external/android-ndk"
628fi
629if test -n "$with_android_ndk"; then
630    eval ANDROID_NDK_HOME=$with_android_ndk
631
632    # Set up a lot of pre-canned defaults
633
634    if test ! -f $ANDROID_NDK_HOME/RELEASE.TXT; then
635        if test ! -f $ANDROID_NDK_HOME/source.properties; then
636            AC_MSG_ERROR([Unrecognized Android NDK. Missing RELEASE.TXT or source.properties file in $ANDROID_NDK_HOME.])
637        fi
638        ANDROID_NDK_VERSION=`sed -n -e 's/Pkg.Revision = //p' $ANDROID_NDK_HOME/source.properties`
639    else
640        ANDROID_NDK_VERSION=`cut -f1 -d' ' <$ANDROID_NDK_HOME/RELEASE.TXT`
641    fi
642    if test -z "$ANDROID_NDK_VERSION";  then
643        AC_MSG_ERROR([Failed to determine Android NDK version. Please check your installation.])
644    fi
645    case $ANDROID_NDK_VERSION in
646    r9*|r10*)
647        AC_MSG_ERROR([Building for Android is only supported with NDK versions above 16.x*])
648        ;;
649    11.1.*|12.1.*|13.1.*|14.1.*)
650        AC_MSG_ERROR([Building for Android is only supported with NDK versions above 16.x.*])
651        ;;
652    16.*|17.*|18.*|19.*|20.*)
653        ;;
654    *)
655        AC_MSG_WARN([Untested Android NDK version $ANDROID_NDK_VERSION, only versions 16.* til 20.* have been used successfully. Proceed at your own risk.])
656        add_warning "Untested Android NDK version $ANDROID_NDK_VERSION, only versions 16.* til 20.* have been used successfully. Proceed at your own risk."
657        ;;
658    esac
659
660    ANDROID_API_LEVEL=16
661    if test -n "$with_android_api_level" ; then
662        ANDROID_API_LEVEL="$with_android_api_level"
663    fi
664
665    android_cpu=$host_cpu
666    if test $host_cpu = arm; then
667        android_platform_prefix=arm-linux-androideabi
668        android_gnu_prefix=$android_platform_prefix
669        LLVM_TRIPLE=armv7a-linux-androideabi
670        ANDROID_APP_ABI=armeabi-v7a
671        ANDROIDCFLAGS="-mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -Wl,--fix-cortex-a8"
672    elif test $host_cpu = aarch64; then
673        android_platform_prefix=aarch64-linux-android
674        android_gnu_prefix=$android_platform_prefix
675        LLVM_TRIPLE=$android_platform_prefix
676        # minimum android version that supports aarch64
677        if test "$ANDROID_API_LEVEL" -lt "21" ; then
678            ANDROID_API_LEVEL=21
679        fi
680        ANDROID_APP_ABI=arm64-v8a
681    elif test $host_cpu = x86_64; then
682        android_platform_prefix=x86_64-linux-android
683        android_gnu_prefix=$android_platform_prefix
684        LLVM_TRIPLE=$android_platform_prefix
685        # minimum android version that supports x86_64
686        ANDROID_API_LEVEL=21
687        ANDROID_APP_ABI=x86_64
688    else
689        # host_cpu is something like "i386" or "i686" I guess, NDK uses
690        # "x86" in some contexts
691        android_cpu=x86
692        android_platform_prefix=$android_cpu
693        android_gnu_prefix=i686-linux-android
694        LLVM_TRIPLE=$android_gnu_prefix
695        ANDROID_APP_ABI=x86
696    fi
697
698    case "$with_android_ndk_toolchain_version" in
699    clang5.0)
700        ANDROID_GCC_TOOLCHAIN_VERSION=4.9
701        ;;
702    *)
703        AC_MSG_ERROR([Unrecognized value for the --with-android-ndk-toolchain-version option. Building for Android is only supported with Clang 5.*])
704    esac
705
706    AC_MSG_NOTICE([using the Android API level... $ANDROID_API_LEVEL])
707
708    # NDK 15 or later toolchain is 64bit-only, except for Windows that we don't support. Using a 64-bit
709    # linker is required if you compile large parts of the code with -g. A 32-bit linker just won't
710    # manage to link the (app-specific) single huge .so that is built for the app in
711    # android/source/ if there is debug information in a significant part of the object files.
712    # (A 64-bit ld.gold grows too much over 10 gigabytes of virtual space when linking such a .so if
713    # all objects have been built with debug information.)
714    case $build_os in
715    linux-gnu*)
716        android_HOST_TAG=linux-x86_64
717        ;;
718    darwin*)
719        android_HOST_TAG=darwin-x86_64
720        ;;
721    *)
722        AC_MSG_ERROR([We only support building for Android from Linux or macOS])
723        # ndk would also support windows and windows-x86_64
724        ;;
725    esac
726    android_TOOLCHAIN=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/$android_HOST_TAG
727    ANDROID_COMPILER_BIN=$android_TOOLCHAIN/bin
728    dnl TODO: NSS build uses it...
729    ANDROID_BINUTILS_PREBUILT_ROOT=$ANDROID_NDK_HOME/toolchains/$android_platform_prefix-$ANDROID_GCC_TOOLCHAIN_VERSION/prebuilt/$android_HOST_TAG
730    AC_SUBST(ANDROID_BINUTILS_PREBUILT_ROOT)
731
732    test -z "$AR" && AR=$ANDROID_COMPILER_BIN/$android_gnu_prefix-ar
733    test -z "$NM" && NM=$ANDROID_COMPILER_BIN/$android_gnu_prefix-nm
734    test -z "$OBJDUMP" && OBJDUMP=$ANDROID_COMPILER_BIN/$android_gnu_prefix-objdump
735    test -z "$RANLIB" && RANLIB=$ANDROID_COMPILER_BIN/$android_gnu_prefix-ranlib
736    test -z "$STRIP" && STRIP=$ANDROID_COMPILER_BIN/$android_gnu_prefix-strip
737
738    ANDROIDCFLAGS="$ANDROIDCFLAGS -target ${LLVM_TRIPLE}${ANDROID_API_LEVEL}"
739    ANDROIDCFLAGS="$ANDROIDCFLAGS -no-canonical-prefixes -ffunction-sections -fdata-sections -Qunused-arguments"
740    if test "$ENABLE_LTO" = TRUE; then
741        # -flto comes from com_GCC_defs.mk, too, but we need to make sure it gets passed as part of
742        # $CC and $CXX when building external libraries
743        ANDROIDCFLAGS="$ANDROIDCFLAGS -flto -fuse-linker-plugin -O2"
744    fi
745
746    ANDROIDCXXFLAGS="$ANDROIDCFLAGS -stdlib=libc++"
747
748    if test -z "$CC"; then
749        CC="$ANDROID_COMPILER_BIN/clang $ANDROIDCFLAGS"
750        CC_BASE="clang"
751    fi
752    if test -z "$CXX"; then
753        CXX="$ANDROID_COMPILER_BIN/clang++ $ANDROIDCXXFLAGS"
754        CXX_BASE="clang++"
755    fi
756fi
757AC_SUBST(ANDROID_NDK_HOME)
758AC_SUBST(ANDROID_APP_ABI)
759AC_SUBST(ANDROID_GCC_TOOLCHAIN_VERSION)
760
761dnl ===================================================================
762dnl --with-android-sdk
763dnl ===================================================================
764ANDROID_SDK_HOME=
765if test -z "$with_android_sdk" -a -e "$SRC_ROOT/external/android-sdk-linux" -a "$build" != "$host"; then
766    with_android_sdk="$SRC_ROOT/external/android-sdk-linux"
767fi
768if test -n "$with_android_sdk"; then
769    eval ANDROID_SDK_HOME=$with_android_sdk
770    PATH="$ANDROID_SDK_HOME/platform-tools:$ANDROID_SDK_HOME/tools:$PATH"
771fi
772AC_SUBST(ANDROID_SDK_HOME)
773
774AC_ARG_ENABLE([android-lok],
775    AS_HELP_STRING([--enable-android-lok],
776        [The Android app from the android/ subdir needs several tweaks all
777         over the place that break the LOK when used in the Online-based
778         Android app.  This switch indicates that the intent of this build is
779         actually the Online-based, non-modified LOK.])
780)
781ENABLE_ANDROID_LOK=
782if test -n "$ANDROID_NDK_HOME" ; then
783    if test "$enable_android_lok" = yes; then
784        ENABLE_ANDROID_LOK=TRUE
785        AC_DEFINE(HAVE_FEATURE_ANDROID_LOK)
786        AC_MSG_NOTICE([building the Android version... for the Online-based Android app])
787    else
788        AC_MSG_NOTICE([building the Android version... for the app from the android/ subdir])
789    fi
790fi
791AC_SUBST([ENABLE_ANDROID_LOK])
792
793libo_FUZZ_ARG_ENABLE([android-editing],
794    AS_HELP_STRING([--enable-android-editing],
795        [Enable the experimental editing feature on Android.])
796)
797ENABLE_ANDROID_EDITING=
798if test "$enable_android_editing" = yes; then
799    ENABLE_ANDROID_EDITING=TRUE
800fi
801AC_SUBST([ENABLE_ANDROID_EDITING])
802
803disable_database_connectivity_dependencies()
804{
805    enable_evolution2=no
806    enable_firebird_sdbc=no
807    enable_mariadb_sdbc=no
808    enable_postgresql_sdbc=no
809    enable_report_builder=no
810}
811
812# ===================================================================
813#
814# Start initial platform setup
815#
816# The using_* variables reflect platform support and should not be
817# changed after the "End initial platform setup" block.
818# This is also true for most test_* variables.
819# ===================================================================
820build_crypto=yes
821test_cmis=yes
822test_curl=yes
823test_gdb_index=no
824test_openldap=yes
825test_split_debug=no
826test_webdav=yes
827
828# There is currently just iOS not using salplug, so this explicitly enables it.
829# must: using_freetype_fontconfig
830#  may: using_headless_plugin defaults to $using_freetype_fontconfig
831using_vclplug=yes
832# must: using_x11
833
834# Default values, as such probably valid just for Linux, set
835# differently below just for Mac OSX, but at least better than
836# hardcoding these as we used to do. Much of this is duplicated also
837# in solenv for old build system and for gbuild, ideally we should
838# perhaps define stuff like this only here in configure.ac?
839
840LINKFLAGSSHL="-shared"
841PICSWITCH="-fpic"
842DLLPOST=".so"
843
844LINKFLAGSNOUNDEFS="-Wl,-z,defs"
845
846INSTROOTBASESUFFIX=
847INSTROOTCONTENTSUFFIX=
848SDKDIRNAME=sdk
849
850HOST_PLATFORM="$host"
851
852host_cpu_for_clang="$host_cpu"
853
854case "$host_os" in
855
856solaris*)
857    using_freetype_fontconfig=yes
858    using_x11=yes
859    build_skia=yes
860    _os=SunOS
861
862    dnl ===========================================================
863    dnl Check whether we're using Solaris 10 - SPARC or Intel.
864    dnl ===========================================================
865    AC_MSG_CHECKING([the Solaris operating system release])
866    _os_release=`echo $host_os | $SED -e s/solaris2\.//`
867    if test "$_os_release" -lt "10"; then
868        AC_MSG_ERROR([use Solaris >= 10 to build LibreOffice])
869    else
870        AC_MSG_RESULT([ok ($_os_release)])
871    fi
872
873    dnl Check whether we're using a SPARC or i386 processor
874    AC_MSG_CHECKING([the processor type])
875    if test "$host_cpu" = "sparc" -o "$host_cpu" = "i386"; then
876        AC_MSG_RESULT([ok ($host_cpu)])
877    else
878        AC_MSG_ERROR([only SPARC and i386 processors are supported])
879    fi
880    ;;
881
882linux-gnu*|k*bsd*-gnu*)
883    using_freetype_fontconfig=yes
884    using_x11=yes
885    build_skia=yes
886    test_gdb_index=yes
887    test_split_debug=yes
888    if test "$enable_fuzzers" = yes; then
889        test_system_freetype=no
890    fi
891    _os=Linux
892    ;;
893
894gnu)
895    using_freetype_fontconfig=yes
896    using_x11=no
897    _os=GNU
898     ;;
899
900cygwin*|wsl*)
901    # When building on Windows normally with MSVC under Cygwin,
902    # configure thinks that the host platform (the platform the
903    # built code will run on) is Cygwin, even if it obviously is
904    # Windows, which in Autoconf terminology is called
905    # "mingw32". (Which is misleading as MinGW is the name of the
906    # tool-chain, not an operating system.)
907
908    # Somewhat confusing, yes. But this configure script doesn't
909    # look at $host etc that much, it mostly uses its own $_os
910    # variable, set here in this case statement.
911
912    using_freetype_fontconfig=no
913    using_x11=no
914    test_openldap=no
915    build_skia=yes
916    _os=WINNT
917
918    DLLPOST=".dll"
919    LINKFLAGSNOUNDEFS=
920
921    if test "$host_cpu" = "aarch64"; then
922        enable_gpgmepp=no
923        enable_coinmp=no
924        enable_firebird_sdbc=no
925    fi
926    ;;
927
928darwin*|macos*) # macOS
929    using_freetype_fontconfig=no
930    using_x11=no
931    if test -n "$LODE_HOME" ; then
932        mac_sanitize_path
933        AC_MSG_NOTICE([sanitized the PATH to $PATH])
934    fi
935    _os=Darwin
936    INSTROOTBASESUFFIX=/$PRODUCTNAME_WITHOUT_SPACES.app
937    INSTROOTCONTENTSUFFIX=/Contents
938    SDKDIRNAME=${PRODUCTNAME_WITHOUT_SPACES}${PRODUCTVERSION}_SDK
939    # See comment above the case "$host_os"
940    LINKFLAGSSHL="-dynamiclib -single_module"
941
942    # -fPIC is default
943    PICSWITCH=""
944
945    DLLPOST=".dylib"
946
947    # -undefined error is the default
948    LINKFLAGSNOUNDEFS=""
949    case "$host_cpu" in
950    aarch64|arm64)
951        case "$host_os" in
952        macos*)
953            # HOST_PLATFORM is used for external projects and their configury occasionally doesn't like
954            # the "macos" part so be sure to use aarch64-apple-darwin for now.
955            HOST_PLATFORM=aarch64-apple-darwin
956            ;;
957        esac
958
959        # Apple's Clang uses "arm64"
960        host_cpu_for_clang=arm64
961    esac
962;;
963
964ios*) # iOS
965    using_freetype_fontconfig=no
966    using_vclplug=no
967    using_x11=no
968    build_crypto=no
969    test_cmis=no
970    test_openldap=no
971    test_webdav=no
972    if test -n "$LODE_HOME" ; then
973        mac_sanitize_path
974        AC_MSG_NOTICE([sanitized the PATH to $PATH])
975    fi
976    enable_gpgmepp=no
977    _os=iOS
978    enable_mpl_subset=yes
979    enable_lotuswordpro=no
980    disable_database_connectivity_dependencies
981    enable_coinmp=no
982    enable_lpsolve=no
983    enable_extension_integration=no
984    with_ppds=no
985    if test "$enable_ios_simulator" = "yes"; then
986        host=x86_64-apple-darwin
987    fi
988    # See comment above the case "$host_os"
989    LINKFLAGSSHL="-dynamiclib -single_module"
990
991    # -fPIC is default
992    PICSWITCH=""
993
994    DLLPOST=".dylib"
995
996    # -undefined error is the default
997    LINKFLAGSNOUNDEFS=""
998
999    # HOST_PLATFORM is used for external projects and their configury typically doesn't like the "ios"
1000    # part, so use aarch64-apple-darwin for now.
1001    HOST_PLATFORM=aarch64-apple-darwin
1002
1003    # Apple's Clang uses "arm64"
1004    host_cpu_for_clang=arm64
1005;;
1006
1007freebsd*)
1008    using_freetype_fontconfig=yes
1009    using_x11=yes
1010    build_skia=yes
1011    AC_MSG_CHECKING([the FreeBSD operating system release])
1012    if test -n "$with_os_version"; then
1013        OSVERSION="$with_os_version"
1014    else
1015        OSVERSION=`/sbin/sysctl -n kern.osreldate`
1016    fi
1017    AC_MSG_RESULT([found OSVERSION=$OSVERSION])
1018    AC_MSG_CHECKING([which thread library to use])
1019    if test "$OSVERSION" -lt "500016"; then
1020        PTHREAD_CFLAGS="-D_THREAD_SAFE"
1021        PTHREAD_LIBS="-pthread"
1022    elif test "$OSVERSION" -lt "502102"; then
1023        PTHREAD_CFLAGS="-D_THREAD_SAFE"
1024        PTHREAD_LIBS="-lc_r"
1025    else
1026        PTHREAD_CFLAGS=""
1027        PTHREAD_LIBS="-pthread"
1028    fi
1029    AC_MSG_RESULT([$PTHREAD_LIBS])
1030    _os=FreeBSD
1031    ;;
1032
1033*netbsd*)
1034    using_freetype_fontconfig=yes
1035    using_x11=yes
1036    test_gtk3_kde5=no
1037    build_skia=yes
1038    PTHREAD_LIBS="-pthread -lpthread"
1039    _os=NetBSD
1040    ;;
1041
1042aix*)
1043    using_freetype_fontconfig=yes
1044    using_x11=yes
1045    test_randr=no
1046    test_gstreamer_1_0=no
1047    PTHREAD_LIBS=-pthread
1048    _os=AIX
1049    ;;
1050
1051openbsd*)
1052    using_freetype_fontconfig=yes
1053    using_x11=yes
1054    PTHREAD_CFLAGS="-D_THREAD_SAFE"
1055    PTHREAD_LIBS="-pthread"
1056    _os=OpenBSD
1057    ;;
1058
1059dragonfly*)
1060    using_freetype_fontconfig=yes
1061    using_x11=yes
1062    build_skia=yes
1063    PTHREAD_LIBS="-pthread"
1064    _os=DragonFly
1065    ;;
1066
1067linux-android*)
1068    using_freetype_fontconfig=yes
1069    using_headless_plugin=no
1070    using_x11=no
1071    build_crypto=no
1072    test_openldap=no
1073    test_system_freetype=no
1074    test_webdav=no
1075    disable_database_connectivity_dependencies
1076    enable_lotuswordpro=no
1077    enable_mpl_subset=yes
1078    enable_cairo_canvas=no
1079    enable_coinmp=yes
1080    enable_lpsolve=no
1081    enable_odk=no
1082    enable_python=no
1083    _os=Android
1084
1085    AC_DEFINE(HAVE_FT_FACE_GETCHARVARIANTINDEX)
1086    ;;
1087
1088haiku*)
1089    using_freetype_fontconfig=yes
1090    using_x11=no
1091    test_gtk3_kde5=no
1092    test_kf5=yes
1093    enable_odk=no
1094    enable_coinmp=no
1095    enable_pdfium=no
1096    enable_sdremote=no
1097    enable_postgresql_sdbc=no
1098    enable_firebird_sdbc=no
1099    _os=Haiku
1100    ;;
1101
1102emscripten)
1103    using_freetype_fontconfig=yes
1104    using_x11=no
1105    test_openldap=no
1106    enable_compiler_plugins=no
1107    test_cmis=no
1108    test_webdav=no
1109    enable_database_connectivity=no
1110    enable_lpsolve=no
1111    with_system_zlib=no
1112    with_theme="breeze"
1113    _os=Emscripten
1114    ;;
1115
1116*)
1117    AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice for!])
1118    ;;
1119esac
1120
1121AC_SUBST(HOST_PLATFORM)
1122
1123if test -z "$using_x11" -o -z "$using_freetype_fontconfig"; then
1124    AC_MSG_ERROR([You must set \$using_freetype_fontconfig and \$using_x11 for your platform])
1125fi
1126
1127# Set defaults, if not set by platform
1128test "${test_cups+set}" = set || test_cups="$using_x11"
1129test "${test_dbus+set}" = set || test_dbus="$using_x11"
1130test "${test_gstreamer_1_0+set}" = set || test_gstreamer_1_0="$using_x11"
1131test "${test_gtk3+set}" = set || test_gtk3="$using_x11"
1132test "${test_gtk4+set}" = set || test_gtk4="$using_x11"
1133test "${test_kf5+set}" = set || test_kf5="$using_x11"
1134# don't handle test_qt5, so it can disable test_kf5 later
1135test "${test_randr+set}" = set || test_randr="$using_x11"
1136test "${test_xrender+set}" = set || test_xrender="$using_x11"
1137test "${using_headless_plugin+set}" = set || using_headless_plugin="$using_freetype_fontconfig"
1138
1139test "${test_gtk3_kde5+set}" != set -a "$test_kf5" = yes -a "$test_gtk3" = yes && test_gtk3_kde5="yes"
1140test "${test_system_fontconfig+set}" != set -a "${test_system_freetype+set}" = set && test_system_fontconfig="$test_system_freetype"
1141test "${test_system_freetype+set}" != set -a "${test_system_fontconfig+set}" = set && test_system_freetype="$test_system_fontconfig"
1142
1143# convenience / platform overriding "fixes"
1144# Don't sort!
1145test "$test_kf5" = yes -a "$test_qt5" = no && test_kf5=no
1146test "$test_kf5" = yes && test_qt5=yes
1147test "$test_gtk3" != yes -o "$test_kf5" != yes && test_gtk3_kde5=no
1148test "$using_freetype_fontconfig" = no && using_headless_plugin=no
1149test "$using_freetype_fontconfig" = yes && test_cairo=yes
1150
1151# Keep in sync with the above $using_x11 depending test default list
1152disable_x11_tests()
1153{
1154    test_cups=no
1155    test_dbus=no
1156    test_gstreamer_1_0=no
1157    test_gtk3_kde5=no
1158    test_gtk3=no
1159    test_gtk4=no
1160    test_kf5=no
1161    test_qt5=no
1162    test_randr=no
1163    test_xrender=no
1164}
1165
1166test "$using_x11" = yes && USING_X11=TRUE
1167
1168if test "$using_freetype_fontconfig" = yes; then
1169    if test "$using_headless_plugin" = yes; then
1170        AC_DEFINE(ENABLE_HEADLESS)
1171        ENABLE_HEADLESS=TRUE
1172    fi
1173fi
1174
1175AC_SUBST(ENABLE_HEADLESS)
1176
1177AC_MSG_NOTICE([VCL platform uses freetype+fontconfig: $using_freetype_fontconfig])
1178AC_MSG_NOTICE([VCL platform uses headless plugin: $using_headless_plugin])
1179AC_MSG_NOTICE([VCL platform uses vclplug: $using_vclplug])
1180AC_MSG_NOTICE([VCL platform uses X11: $using_x11])
1181
1182# ===================================================================
1183#
1184# End initial platform setup
1185#
1186# ===================================================================
1187
1188if test "$_os" = "Android" ; then
1189    # Verify that the NDK and SDK options are proper
1190    if test -z "$with_android_ndk"; then
1191        AC_MSG_ERROR([the --with-android-ndk option is mandatory, unless it is available at external/android-ndk/.])
1192    elif test ! -f "$ANDROID_NDK_HOME/meta/abis.json"; then
1193        AC_MSG_ERROR([the --with-android-ndk option does not point to an Android NDK])
1194    fi
1195
1196    if test -z "$ANDROID_SDK_HOME"; then
1197        AC_MSG_ERROR([the --with-android-sdk option is mandatory, unless it is available at external/android-sdk-linux/.])
1198    elif test ! -d "$ANDROID_SDK_HOME/platforms"; then
1199        AC_MSG_ERROR([the --with-android-sdk option does not point to an Android SDK])
1200    fi
1201
1202    BUILD_TOOLS_VERSION=`$SED -n -e 's/.*buildToolsVersion "\(.*\)"/\1/p' $SRC_ROOT/android/source/build.gradle`
1203    if test ! -d "$ANDROID_SDK_HOME/build-tools/$BUILD_TOOLS_VERSION"; then
1204        AC_MSG_WARN([android build-tools $BUILD_TOOLS_VERSION not found - install with
1205                         $ANDROID_SDK_HOME/tools/android update sdk -u --all --filter build-tools-$BUILD_TOOLS_VERSION
1206                    or adjust change $SRC_ROOT/android/source/build.gradle accordingly])
1207        add_warning "android build-tools $BUILD_TOOLS_VERSION not found - install with"
1208        add_warning "    $ANDROID_SDK_HOME/tools/android update sdk -u --all --filter build-tools-$BUILD_TOOLS_VERSION"
1209        add_warning "or adjust $SRC_ROOT/android/source/build.gradle accordingly"
1210    fi
1211    if test ! -f "$ANDROID_SDK_HOME/extras/android/m2repository/source.properties"; then
1212        AC_MSG_WARN([android support repository not found - install with
1213                         $ANDROID_SDK_HOME/tools/android update sdk -u --filter extra-android-m2repository
1214                     to allow the build to download the specified version of the android support libraries])
1215        add_warning "android support repository not found - install with"
1216        add_warning "    $ANDROID_SDK_HOME/tools/android update sdk -u --filter extra-android-m2repository"
1217        add_warning "to allow the build to download the specified version of the android support libraries"
1218    fi
1219fi
1220
1221if test "$_os" = "AIX"; then
1222    AC_PATH_PROG(GAWK, gawk)
1223    if test -z "$GAWK"; then
1224        AC_MSG_ERROR([gawk not found in \$PATH])
1225    fi
1226fi
1227
1228AC_SUBST(SDKDIRNAME)
1229
1230AC_SUBST(PTHREAD_CFLAGS)
1231AC_SUBST(PTHREAD_LIBS)
1232
1233# Check for explicit A/C/CXX/OBJC/OBJCXX/LDFLAGS.
1234# By default use the ones specified by our build system,
1235# but explicit override is possible.
1236AC_MSG_CHECKING(for explicit AFLAGS)
1237if test -n "$AFLAGS"; then
1238    AC_MSG_RESULT([$AFLAGS])
1239    x_AFLAGS=
1240else
1241    AC_MSG_RESULT(no)
1242    x_AFLAGS=[\#]
1243fi
1244AC_MSG_CHECKING(for explicit CFLAGS)
1245if test -n "$CFLAGS"; then
1246    AC_MSG_RESULT([$CFLAGS])
1247    x_CFLAGS=
1248else
1249    AC_MSG_RESULT(no)
1250    x_CFLAGS=[\#]
1251fi
1252AC_MSG_CHECKING(for explicit CXXFLAGS)
1253if test -n "$CXXFLAGS"; then
1254    AC_MSG_RESULT([$CXXFLAGS])
1255    x_CXXFLAGS=
1256else
1257    AC_MSG_RESULT(no)
1258    x_CXXFLAGS=[\#]
1259fi
1260AC_MSG_CHECKING(for explicit OBJCFLAGS)
1261if test -n "$OBJCFLAGS"; then
1262    AC_MSG_RESULT([$OBJCFLAGS])
1263    x_OBJCFLAGS=
1264else
1265    AC_MSG_RESULT(no)
1266    x_OBJCFLAGS=[\#]
1267fi
1268AC_MSG_CHECKING(for explicit OBJCXXFLAGS)
1269if test -n "$OBJCXXFLAGS"; then
1270    AC_MSG_RESULT([$OBJCXXFLAGS])
1271    x_OBJCXXFLAGS=
1272else
1273    AC_MSG_RESULT(no)
1274    x_OBJCXXFLAGS=[\#]
1275fi
1276AC_MSG_CHECKING(for explicit LDFLAGS)
1277if test -n "$LDFLAGS"; then
1278    AC_MSG_RESULT([$LDFLAGS])
1279    x_LDFLAGS=
1280else
1281    AC_MSG_RESULT(no)
1282    x_LDFLAGS=[\#]
1283fi
1284AC_SUBST(AFLAGS)
1285AC_SUBST(CFLAGS)
1286AC_SUBST(CXXFLAGS)
1287AC_SUBST(OBJCFLAGS)
1288AC_SUBST(OBJCXXFLAGS)
1289AC_SUBST(LDFLAGS)
1290AC_SUBST(x_AFLAGS)
1291AC_SUBST(x_CFLAGS)
1292AC_SUBST(x_CXXFLAGS)
1293AC_SUBST(x_OBJCFLAGS)
1294AC_SUBST(x_OBJCXXFLAGS)
1295AC_SUBST(x_LDFLAGS)
1296
1297dnl These are potentially set for MSVC, in the code checking for UCRT below:
1298my_original_CFLAGS=$CFLAGS
1299my_original_CXXFLAGS=$CXXFLAGS
1300my_original_CPPFLAGS=$CPPFLAGS
1301
1302dnl The following checks for gcc, cc and then cl (if it weren't guarded for win32)
1303dnl Needs to precede the AC_C_BIGENDIAN and AC_SEARCH_LIBS calls below, which apparently call
1304dnl AC_PROG_CC internally.
1305if test "$_os" != "WINNT"; then
1306    # AC_PROG_CC sets CFLAGS to -g -O2 if not set, avoid that
1307    save_CFLAGS=$CFLAGS
1308    AC_PROG_CC
1309    CFLAGS=$save_CFLAGS
1310    if test -z "$CC_BASE"; then
1311        CC_BASE=`first_arg_basename "$CC"`
1312    fi
1313fi
1314
1315if test "$_os" != "WINNT"; then
1316    AC_C_BIGENDIAN([ENDIANNESS=big], [ENDIANNESS=little])
1317else
1318    ENDIANNESS=little
1319fi
1320AC_SUBST(ENDIANNESS)
1321
1322if test $_os != "WINNT"; then
1323    save_LIBS="$LIBS"
1324    AC_SEARCH_LIBS([dlsym], [dl],
1325        [case "$ac_cv_search_dlsym" in -l*) DLOPEN_LIBS="$ac_cv_search_dlsym";; esac],
1326        [AC_MSG_ERROR([dlsym not found in either libc nor libdl])])
1327    LIBS="$save_LIBS"
1328fi
1329AC_SUBST(DLOPEN_LIBS)
1330
1331dnl ===================================================================
1332dnl Sanity checks for Emscripten SDK setup
1333dnl ===================================================================
1334
1335if test "$_os" = "Emscripten"; then
1336    EMSCRIPTEN_ERROR=0
1337    if ! which emconfigure >/dev/null 2>&1; then
1338        AC_MSG_WARN([emconfigure must be in your \$PATH])
1339        EMSCRIPTEN_ERROR=1
1340    fi
1341    if test -z "$EMMAKEN_JUST_CONFIGURE"; then
1342        AC_MSG_WARN(["\$EMMAKEN_JUST_CONFIGURE wasn't set by emconfigure. Prefix configure or use autogen.sh])
1343        EMSCRIPTEN_ERROR=1
1344    fi
1345    if test $EMSCRIPTEN_ERROR -ne 0; then
1346        AC_MSG_ERROR(["Please fix your EMSDK setup to build with Emscripten!"])
1347    fi
1348fi
1349
1350###############################################################################
1351# Extensions switches --enable/--disable
1352###############################################################################
1353# By default these should be enabled unless having extra dependencies.
1354# If there is extra dependency over configure options then the enable should
1355# be automagic based on whether the requiring feature is enabled or not.
1356# All this options change anything only with --enable-extension-integration.
1357
1358# The name of this option and its help string makes it sound as if
1359# extensions are built anyway, just not integrated in the installer,
1360# if you use --disable-extension-integration. Is that really the
1361# case?
1362
1363AC_ARG_ENABLE(ios-simulator,
1364    AS_HELP_STRING([--enable-ios-simulator],
1365        [build for iOS simulator])
1366)
1367
1368libo_FUZZ_ARG_ENABLE(extension-integration,
1369    AS_HELP_STRING([--disable-extension-integration],
1370        [Disable integration of the built extensions in the installer of the
1371         product. Use this switch to disable the integration.])
1372)
1373
1374AC_ARG_ENABLE(avmedia,
1375    AS_HELP_STRING([--disable-avmedia],
1376        [Disable displaying and inserting AV media in documents. Work in progress, use only if you are hacking on it.])
1377)
1378
1379AC_ARG_ENABLE(database-connectivity,
1380    AS_HELP_STRING([--disable-database-connectivity],
1381        [Disable various database connectivity. Work in progress, use only if you are hacking on it.])
1382)
1383
1384# This doesn't mean not building (or "integrating") extensions
1385# (although it probably should; i.e. it should imply
1386# --disable-extension-integration I guess), it means not supporting
1387# any extension mechanism at all
1388libo_FUZZ_ARG_ENABLE(extensions,
1389    AS_HELP_STRING([--disable-extensions],
1390        [Disable all add-on extension functionality. Work in progress, use only if you are hacking on it.])
1391)
1392
1393AC_ARG_ENABLE(scripting,
1394    AS_HELP_STRING([--disable-scripting],
1395        [Disable BASIC, Java and Python. Work in progress, use only if you are hacking on it.])
1396)
1397
1398# This is mainly for Android and iOS, but could potentially be used in some
1399# special case otherwise, too, so factored out as a separate setting
1400
1401AC_ARG_ENABLE(dynamic-loading,
1402    AS_HELP_STRING([--disable-dynamic-loading],
1403        [Disable any use of dynamic loading of code. Work in progress, use only if you are hacking on it.])
1404)
1405
1406libo_FUZZ_ARG_ENABLE(report-builder,
1407    AS_HELP_STRING([--disable-report-builder],
1408        [Disable the Report Builder.])
1409)
1410
1411libo_FUZZ_ARG_ENABLE(ext-wiki-publisher,
1412    AS_HELP_STRING([--enable-ext-wiki-publisher],
1413        [Enable the Wiki Publisher extension.])
1414)
1415
1416libo_FUZZ_ARG_ENABLE(lpsolve,
1417    AS_HELP_STRING([--disable-lpsolve],
1418        [Disable compilation of the lp solve solver ])
1419)
1420libo_FUZZ_ARG_ENABLE(coinmp,
1421    AS_HELP_STRING([--disable-coinmp],
1422        [Disable compilation of the CoinMP solver ])
1423)
1424
1425libo_FUZZ_ARG_ENABLE(pdfimport,
1426    AS_HELP_STRING([--disable-pdfimport],
1427        [Disable building the PDF import feature.])
1428)
1429
1430libo_FUZZ_ARG_ENABLE(pdfium,
1431    AS_HELP_STRING([--disable-pdfium],
1432        [Disable building PDFium. Results in unsecure PDF signature verification.])
1433)
1434
1435libo_FUZZ_ARG_ENABLE(skia,
1436    AS_HELP_STRING([--disable-skia],
1437        [Disable building Skia. Use --enable-skia=debug to build without optimizations.])
1438)
1439
1440###############################################################################
1441
1442dnl ---------- *** ----------
1443
1444libo_FUZZ_ARG_ENABLE(mergelibs,
1445    AS_HELP_STRING([--enable-mergelibs],
1446        [Merge several of the smaller libraries into one big, "merged", one.])
1447)
1448
1449libo_FUZZ_ARG_ENABLE(breakpad,
1450    AS_HELP_STRING([--enable-breakpad],
1451        [Enables breakpad for crash reporting.])
1452)
1453
1454libo_FUZZ_ARG_ENABLE(crashdump,
1455    AS_HELP_STRING([--disable-crashdump],
1456        [Disable dump.ini and dump-file, when --enable-breakpad])
1457)
1458
1459AC_ARG_ENABLE(fetch-external,
1460    AS_HELP_STRING([--disable-fetch-external],
1461        [Disables fetching external tarballs from web sources.])
1462)
1463
1464AC_ARG_ENABLE(fuzzers,
1465    AS_HELP_STRING([--enable-fuzzers],
1466        [Enables building libfuzzer targets for fuzz testing.])
1467)
1468
1469libo_FUZZ_ARG_ENABLE(pch,
1470    AS_HELP_STRING([--enable-pch=<yes/no/system/base/normal/full>],
1471        [Enables precompiled header support for C++. Forced default on Windows/VC build.
1472         Using 'system' will include only external headers, 'base' will add also headers
1473         from base modules, 'normal' will also add all headers except from the module built,
1474         'full' will use all suitable headers even from a module itself.])
1475)
1476
1477libo_FUZZ_ARG_ENABLE(epm,
1478    AS_HELP_STRING([--enable-epm],
1479        [LibreOffice includes self-packaging code, that requires epm, however epm is
1480         useless for large scale package building.])
1481)
1482
1483libo_FUZZ_ARG_ENABLE(odk,
1484    AS_HELP_STRING([--enable-odk],
1485        [Enable building the Office Development Kit, the part that extensions need to build against])
1486)
1487
1488AC_ARG_ENABLE(mpl-subset,
1489    AS_HELP_STRING([--enable-mpl-subset],
1490        [Don't compile any pieces which are not MPL or more liberally licensed])
1491)
1492
1493libo_FUZZ_ARG_ENABLE(evolution2,
1494    AS_HELP_STRING([--enable-evolution2],
1495        [Allows the built-in evolution 2 addressbook connectivity build to be
1496         enabled.])
1497)
1498
1499AC_ARG_ENABLE(avahi,
1500    AS_HELP_STRING([--enable-avahi],
1501        [Determines whether to use Avahi to advertise Impress to remote controls.])
1502)
1503
1504libo_FUZZ_ARG_ENABLE(werror,
1505    AS_HELP_STRING([--enable-werror],
1506        [Turn warnings to errors. (Has no effect in modules where the treating
1507         of warnings as errors is disabled explicitly.)]),
1508,)
1509
1510libo_FUZZ_ARG_ENABLE(assert-always-abort,
1511    AS_HELP_STRING([--enable-assert-always-abort],
1512        [make assert() failures abort even when building without --enable-debug or --enable-dbgutil.]),
1513,)
1514
1515libo_FUZZ_ARG_ENABLE(dbgutil,
1516    AS_HELP_STRING([--enable-dbgutil],
1517        [Provide debugging support from --enable-debug and include additional debugging
1518         utilities such as object counting or more expensive checks.
1519         This is the recommended option for developers.
1520         Note that this makes the build ABI incompatible, it is not possible to mix object
1521         files or libraries from a --enable-dbgutil and a --disable-dbgutil build.]))
1522
1523libo_FUZZ_ARG_ENABLE(debug,
1524    AS_HELP_STRING([--enable-debug],
1525        [Include debugging information, disable compiler optimization and inlining plus
1526         extra debugging code like assertions. Extra large build! (enables -g compiler flag).]))
1527
1528libo_FUZZ_ARG_ENABLE(split-debug,
1529    AS_HELP_STRING([--disable-split-debug],
1530        [Disable using split debug information (-gsplit-dwarf compile flag). Split debug information
1531         saves disk space and build time, but requires tools that support it (both build tools and debuggers).]))
1532
1533libo_FUZZ_ARG_ENABLE(gdb-index,
1534    AS_HELP_STRING([--disable-gdb-index],
1535        [Disables creating debug information in the gdb index format, which makes gdb start faster.
1536         The feature requires the gold or lld linker.]))
1537
1538libo_FUZZ_ARG_ENABLE(sal-log,
1539    AS_HELP_STRING([--enable-sal-log],
1540        [Make SAL_INFO and SAL_WARN calls do something even in a non-debug build.]))
1541
1542libo_FUZZ_ARG_ENABLE(symbols,
1543    AS_HELP_STRING([--enable-symbols],
1544        [Generate debug information.
1545         By default, enabled for --enable-debug and --enable-dbgutil, disabled
1546         otherwise. It is possible to explicitly specify gbuild build targets
1547         (where 'all' means everything, '-' prepended means to not enable, '/' appended means
1548         everything in the directory; there is no ordering, more specific overrides
1549         more general, and disabling takes precedence).
1550         Example: --enable-symbols="all -sw/ -Library_sc".]))
1551
1552libo_FUZZ_ARG_ENABLE(optimized,
1553    AS_HELP_STRING([--enable-optimized=<yes/no/debug>],
1554        [Whether to compile with optimization flags.
1555         By default, disabled for --enable-debug and --enable-dbgutil, enabled
1556         otherwise. Using 'debug' will try to use only optimizations that should
1557         not interfere with debugging. For Emscripten we default to optimized (-O1)
1558         debug build, as otherwise binaries become too large.]))
1559
1560libo_FUZZ_ARG_ENABLE(runtime-optimizations,
1561    AS_HELP_STRING([--disable-runtime-optimizations],
1562        [Statically disable certain runtime optimizations (like rtl/alloc.h or
1563         JVM JIT) that are known to interact badly with certain dynamic analysis
1564         tools (like -fsanitize=address or Valgrind).  By default, disabled iff
1565         CC contains "-fsanitize=*".  (For Valgrind, those runtime optimizations
1566         are typically disabled dynamically via RUNNING_ON_VALGRIND.)]))
1567
1568AC_ARG_WITH(valgrind,
1569    AS_HELP_STRING([--with-valgrind],
1570        [Make availability of Valgrind headers a hard requirement.]))
1571
1572libo_FUZZ_ARG_ENABLE(compiler-plugins,
1573    AS_HELP_STRING([--enable-compiler-plugins],
1574        [Enable compiler plugins that will perform additional checks during
1575         building. Enabled automatically by --enable-dbgutil.
1576         Use --enable-compiler-plugins=debug to also enable debug code in the plugins.]))
1577COMPILER_PLUGINS_DEBUG=
1578if test "$enable_compiler_plugins" = debug; then
1579    enable_compiler_plugins=yes
1580    COMPILER_PLUGINS_DEBUG=TRUE
1581fi
1582
1583libo_FUZZ_ARG_ENABLE(compiler-plugins-analyzer-pch,
1584    AS_HELP_STRING([--disable-compiler-plugins-analyzer-pch],
1585        [Disable use of precompiled headers when running the Clang compiler plugin analyzer.  Not
1586         relevant in the --disable-compiler-plugins case.]))
1587
1588libo_FUZZ_ARG_ENABLE(ooenv,
1589    AS_HELP_STRING([--enable-ooenv],
1590        [Enable ooenv for the instdir installation.]))
1591
1592AC_ARG_ENABLE(lto,
1593    AS_HELP_STRING([--enable-lto],
1594        [Enable link-time optimization. Suitable for (optimised) product builds. Building might take
1595         longer but libraries and executables are optimized for speed. For GCC, best to use the 'gold'
1596         linker. For MSVC, this option is broken at the moment. This is experimental work
1597         in progress that shouldn't be used unless you are working on it.)]))
1598
1599AC_ARG_ENABLE(python,
1600    AS_HELP_STRING([--enable-python=<no/auto/system/internal/fully-internal>],
1601        [Enables or disables Python support at run-time.
1602         Also specifies what Python to use at build-time.
1603         'fully-internal' even forces the internal version for uses of Python
1604         during the build.
1605         On macOS the only choices are
1606         'internal' (default) or 'fully-internal'. Otherwise the default is 'auto'.
1607         ]))
1608
1609libo_FUZZ_ARG_ENABLE(gtk3,
1610    AS_HELP_STRING([--disable-gtk3],
1611        [Determines whether to use Gtk+ 3.0 vclplug on platforms where Gtk+ 3.0 is available.]),
1612,test "${enable_gtk3+set}" = set || enable_gtk3=yes)
1613
1614AC_ARG_ENABLE(gtk4,
1615    AS_HELP_STRING([--enable-gtk4],
1616        [Determines whether to use Gtk+ 4.0 vclplug on platforms where Gtk+ 4.0 is available.]))
1617
1618AC_ARG_ENABLE(introspection,
1619    AS_HELP_STRING([--enable-introspection],
1620        [Generate files for GObject introspection.  Requires --enable-gtk3.  (Typically used by
1621         Linux distributions.)]))
1622
1623AC_ARG_ENABLE(split-app-modules,
1624    AS_HELP_STRING([--enable-split-app-modules],
1625        [Split file lists for app modules, e.g. base, calc.
1626         Has effect only with make distro-pack-install]),
1627,)
1628
1629AC_ARG_ENABLE(split-opt-features,
1630    AS_HELP_STRING([--enable-split-opt-features],
1631        [Split file lists for some optional features, e.g. pyuno, testtool.
1632         Has effect only with make distro-pack-install]),
1633,)
1634
1635libo_FUZZ_ARG_ENABLE(cairo-canvas,
1636    AS_HELP_STRING([--disable-cairo-canvas],
1637        [Determines whether to build the Cairo canvas on platforms where Cairo is available.]),
1638,)
1639
1640libo_FUZZ_ARG_ENABLE(dbus,
1641    AS_HELP_STRING([--disable-dbus],
1642        [Determines whether to enable features that depend on dbus.
1643         e.g. Presentation mode screensaver control, bluetooth presentation control, automatic font install]),
1644,test "${enable_dbus+set}" = set || enable_dbus=yes)
1645
1646libo_FUZZ_ARG_ENABLE(sdremote,
1647    AS_HELP_STRING([--disable-sdremote],
1648        [Determines whether to enable Impress remote control (i.e. the server component).]),
1649,test "${enable_sdremote+set}" = set || enable_sdremote=yes)
1650
1651libo_FUZZ_ARG_ENABLE(sdremote-bluetooth,
1652    AS_HELP_STRING([--disable-sdremote-bluetooth],
1653        [Determines whether to build sdremote with bluetooth support.
1654         Requires dbus on Linux.]))
1655
1656libo_FUZZ_ARG_ENABLE(gio,
1657    AS_HELP_STRING([--disable-gio],
1658        [Determines whether to use the GIO support.]),
1659,test "${enable_gio+set}" = set || enable_gio=yes)
1660
1661AC_ARG_ENABLE(qt5,
1662    AS_HELP_STRING([--enable-qt5],
1663        [Determines whether to use Qt5 vclplug on platforms where Qt5 is
1664         available.]),
1665,)
1666
1667AC_ARG_ENABLE(kf5,
1668    AS_HELP_STRING([--enable-kf5],
1669        [Determines whether to use Qt5/KF5 vclplug on platforms where Qt5 and
1670         KF5 are available.]),
1671,)
1672
1673AC_ARG_ENABLE(gtk3_kde5,
1674    AS_HELP_STRING([--enable-gtk3-kde5],
1675        [Determines whether to use Gtk3 vclplug with KF5 file dialogs on
1676         platforms where Gtk3, Qt5 and Plasma is available.]),
1677,)
1678
1679AC_ARG_ENABLE(gui,
1680    AS_HELP_STRING([--disable-gui],
1681        [Disable use of X11 or Wayland to reduce dependencies (e.g. for building LibreOfficeKit).]),
1682,enable_gui=yes)
1683
1684libo_FUZZ_ARG_ENABLE(randr,
1685    AS_HELP_STRING([--disable-randr],
1686        [Disable RandR support in the vcl project.]),
1687,test "${enable_randr+set}" = set || enable_randr=yes)
1688
1689libo_FUZZ_ARG_ENABLE(gstreamer-1-0,
1690    AS_HELP_STRING([--disable-gstreamer-1-0],
1691        [Disable building with the gstreamer 1.0 avmedia backend.]),
1692,test "${enable_gstreamer_1_0+set}" = set || enable_gstreamer_1_0=yes)
1693
1694libo_FUZZ_ARG_ENABLE([eot],
1695    [AS_HELP_STRING([--enable-eot],
1696        [Enable support for Embedded OpenType fonts.])],
1697,test "${enable_eot+set}" = set || enable_eot=no)
1698
1699libo_FUZZ_ARG_ENABLE(cve-tests,
1700    AS_HELP_STRING([--disable-cve-tests],
1701        [Prevent CVE tests to be executed]),
1702,)
1703
1704libo_FUZZ_ARG_ENABLE(chart-tests,
1705    AS_HELP_STRING([--enable-chart-tests],
1706        [Executes chart XShape tests. In a perfect world these tests would be
1707         stable and everyone could run them, in reality it is best to run them
1708         only on a few machines that are known to work and maintained by people
1709         who can judge if a test failure is a regression or not.]),
1710,)
1711
1712AC_ARG_ENABLE(build-opensymbol,
1713    AS_HELP_STRING([--enable-build-opensymbol],
1714        [Do not use the prebuilt opens___.ttf. Build it instead. This needs
1715         fontforge installed.]),
1716,)
1717
1718AC_ARG_ENABLE(dependency-tracking,
1719    AS_HELP_STRING([--enable-dependency-tracking],
1720        [Do not reject slow dependency extractors.])[
1721  --disable-dependency-tracking
1722                          Disables generation of dependency information.
1723                          Speed up one-time builds.],
1724,)
1725
1726AC_ARG_ENABLE(icecream,
1727    AS_HELP_STRING([--enable-icecream],
1728        [Use the 'icecream' distributed compiling tool to speedup the compilation.
1729         It defaults to /opt/icecream for the location of the icecream gcc/g++
1730         wrappers, you can override that using --with-gcc-home=/the/path switch.]),
1731,)
1732
1733AC_ARG_ENABLE(ld,
1734    AS_HELP_STRING([--enable-ld=<linker>],
1735        [Use the specified linker. Both 'gold' and 'lld' linkers generally use less memory and link faster.
1736         By default tries to use the best linker possible, use --disable-ld to use the default linker.
1737         If <linker> contains any ':', the part before the first ':' is used as the value of
1738         -fuse-ld, while the part after the first ':' is used as the value of --ld-path (which is
1739         needed for Clang 12).]),
1740,)
1741
1742libo_FUZZ_ARG_ENABLE(cups,
1743    AS_HELP_STRING([--disable-cups],
1744        [Do not build cups support.])
1745)
1746
1747AC_ARG_ENABLE(ccache,
1748    AS_HELP_STRING([--disable-ccache],
1749        [Do not try to use ccache automatically.
1750         By default, unless on Windows, we will try to detect if ccache is available; in that case if
1751         CC/CXX are not yet set, and --enable-icecream is not given, we
1752         attempt to use ccache. --disable-ccache disables ccache completely.
1753         Additionally ccache's depend mode is enabled if possible,
1754         use --enable-ccache=nodepend to enable ccache without depend mode.
1755]),
1756,)
1757
1758libo_FUZZ_ARG_ENABLE(online-update,
1759    AS_HELP_STRING([--enable-online-update],
1760        [Enable the online update service that will check for new versions of
1761         LibreOffice. By default, it is enabled on Windows and Mac, disabled on Linux.
1762         If the value is "mar", the experimental Mozilla-like update will be
1763         enabled instead of the traditional update mechanism.]),
1764,)
1765
1766AC_ARG_WITH(update-config,
1767    AS_HELP_STRING([--with-update-config=/tmp/update.ini],
1768                   [Path to the update config ini file]))
1769
1770libo_FUZZ_ARG_ENABLE(extension-update,
1771    AS_HELP_STRING([--disable-extension-update],
1772        [Disable possibility to update installed extensions.]),
1773,)
1774
1775libo_FUZZ_ARG_ENABLE(release-build,
1776    AS_HELP_STRING([--enable-release-build],
1777        [Enable release build. Note that the "release build" choice is orthogonal to
1778         whether symbols are present, debug info is generated, or optimization
1779         is done.
1780         See http://wiki.documentfoundation.org/Development/DevBuild]),
1781,)
1782
1783AC_ARG_ENABLE(windows-build-signing,
1784    AS_HELP_STRING([--enable-windows-build-signing],
1785        [Enable signing of windows binaries (*.exe, *.dll)]),
1786,)
1787
1788AC_ARG_ENABLE(silent-msi,
1789    AS_HELP_STRING([--enable-silent-msi],
1790        [Enable MSI with LIMITUI=1 (silent install).]),
1791,)
1792
1793AC_ARG_ENABLE(macosx-code-signing,
1794    AS_HELP_STRING([--enable-macosx-code-signing=<identity>],
1795        [Sign executables, dylibs, frameworks and the app bundle. If you
1796         don't provide an identity the first suitable certificate
1797         in your keychain is used.]),
1798,)
1799
1800AC_ARG_ENABLE(macosx-package-signing,
1801    AS_HELP_STRING([--enable-macosx-package-signing=<identity>],
1802        [Create a .pkg suitable for uploading to the Mac App Store and sign
1803         it. If you don't provide an identity the first suitable certificate
1804         in your keychain is used.]),
1805,)
1806
1807AC_ARG_ENABLE(macosx-sandbox,
1808    AS_HELP_STRING([--enable-macosx-sandbox],
1809        [Make the app bundle run in a sandbox. Requires code signing.
1810         Is required by apps distributed in the Mac App Store, and implies
1811         adherence to App Store rules.]),
1812,)
1813
1814AC_ARG_WITH(macosx-bundle-identifier,
1815    AS_HELP_STRING([--with-macosx-bundle-identifier=tld.mumble.orifice.TheOffice],
1816        [Define the macOS bundle identifier. Default is the somewhat weird
1817         org.libreoffice.script ("script", huh?).]),
1818,with_macosx_bundle_identifier=org.libreoffice.script)
1819
1820AC_ARG_WITH(product-name,
1821    AS_HELP_STRING([--with-product-name='My Own Office Suite'],
1822        [Define the product name. Default is AC_PACKAGE_NAME.]),
1823,with_product_name=$PRODUCTNAME)
1824
1825libo_FUZZ_ARG_ENABLE(community-flavor,
1826    AS_HELP_STRING([--disable-community-flavor],
1827        [Disable the Community branding.]),
1828,)
1829
1830AC_ARG_WITH(package-version,
1831    AS_HELP_STRING([--with-package-version='3.1.4.5'],
1832        [Define the package version. Default is AC_PACKAGE_VERSION. Use only if you distribute an own build for macOS.]),
1833,)
1834
1835libo_FUZZ_ARG_ENABLE(readonly-installset,
1836    AS_HELP_STRING([--enable-readonly-installset],
1837        [Prevents any attempts by LibreOffice to write into its installation. That means
1838         at least that no "system-wide" extensions can be added. Partly experimental work in
1839         progress, probably not fully implemented. Always enabled for macOS.]),
1840,)
1841
1842libo_FUZZ_ARG_ENABLE(mariadb-sdbc,
1843    AS_HELP_STRING([--disable-mariadb-sdbc],
1844        [Disable the build of the MariaDB/MySQL-SDBC driver.])
1845)
1846
1847libo_FUZZ_ARG_ENABLE(postgresql-sdbc,
1848    AS_HELP_STRING([--disable-postgresql-sdbc],
1849        [Disable the build of the PostgreSQL-SDBC driver.])
1850)
1851
1852libo_FUZZ_ARG_ENABLE(lotuswordpro,
1853    AS_HELP_STRING([--disable-lotuswordpro],
1854        [Disable the build of the Lotus Word Pro filter.]),
1855,test "${enable_lotuswordpro+set}" = set || enable_lotuswordpro=yes)
1856
1857libo_FUZZ_ARG_ENABLE(firebird-sdbc,
1858    AS_HELP_STRING([--disable-firebird-sdbc],
1859        [Disable the build of the Firebird-SDBC driver if it doesn't compile for you.]),
1860,test "${enable_firebird_sdbc+set}" = set || enable_firebird_sdbc=yes)
1861
1862AC_ARG_ENABLE(bogus-pkg-config,
1863    AS_HELP_STRING([--enable-bogus-pkg-config],
1864        [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.]),
1865)
1866
1867AC_ARG_ENABLE(openssl,
1868    AS_HELP_STRING([--disable-openssl],
1869        [Disable using libssl/libcrypto from OpenSSL. If disabled,
1870         components will either use GNUTLS or NSS. Work in progress,
1871         use only if you are hacking on it.]),
1872,enable_openssl=yes)
1873
1874libo_FUZZ_ARG_ENABLE(cipher-openssl-backend,
1875    AS_HELP_STRING([--enable-cipher-openssl-backend],
1876        [Enable using OpenSSL as the actual implementation of the rtl/cipher.h functionality.
1877         Requires --enable-openssl.]))
1878
1879AC_ARG_ENABLE(nss,
1880    AS_HELP_STRING([--disable-nss],
1881        [Disable using NSS. If disabled,
1882         components will either use GNUTLS or openssl. Work in progress,
1883         use only if you are hacking on it.]),
1884,enable_nss=yes)
1885
1886AC_ARG_ENABLE(library-bin-tar,
1887    AS_HELP_STRING([--enable-library-bin-tar],
1888        [Enable the building and reused of tarball of binary build for some 'external' libraries.
1889        Some libraries can save their build result in a tarball
1890        stored in TARFILE_LOCATION. That binary tarball is
1891        uniquely identified by the source tarball,
1892        the content of the config_host.mk file and the content
1893        of the top-level directory in core for that library
1894        If this option is enabled, then if such a tarfile exist, it will be untarred
1895        instead of the source tarfile, and the build step will be skipped for that
1896        library.
1897        If a proper tarfile does not exist, then the normal source-based
1898        build is done for that library and a proper binary tarfile is created
1899        for the next time.]),
1900)
1901
1902AC_ARG_ENABLE(dconf,
1903    AS_HELP_STRING([--disable-dconf],
1904        [Disable the dconf configuration backend (enabled by default where
1905         available).]))
1906
1907libo_FUZZ_ARG_ENABLE(formula-logger,
1908    AS_HELP_STRING(
1909        [--enable-formula-logger],
1910        [Enable formula logger for logging formula calculation flow in Calc.]
1911    )
1912)
1913
1914AC_ARG_ENABLE(ldap,
1915    AS_HELP_STRING([--disable-ldap],
1916        [Disable LDAP support.]),
1917,enable_ldap=yes)
1918
1919AC_ARG_ENABLE(opencl,
1920    AS_HELP_STRING([--disable-opencl],
1921        [Disable OpenCL support.]),
1922,enable_opencl=yes)
1923
1924libo_FUZZ_ARG_ENABLE(librelogo,
1925    AS_HELP_STRING([--disable-librelogo],
1926        [Do not build LibreLogo.]),
1927,enable_librelogo=yes)
1928
1929AC_ARG_ENABLE(cmis,
1930    AS_HELP_STRING([--disable-cmis],
1931        [Disable CMIS support.]),
1932,enable_cmis=yes)
1933
1934AC_ARG_ENABLE(curl,
1935    AS_HELP_STRING([--disable-curl],
1936        [Disable CURL support.]),
1937,enable_curl=yes)
1938
1939AC_ARG_ENABLE(wasm-strip,
1940    AS_HELP_STRING([--enable-wasm-strip],
1941        [Strip the static build like for WASM/emscripten platform.]),
1942,enable_wasm_strip=yes)
1943
1944
1945dnl ===================================================================
1946dnl Optional Packages (--with/without-)
1947dnl ===================================================================
1948
1949AC_ARG_WITH(gcc-home,
1950    AS_HELP_STRING([--with-gcc-home],
1951        [Specify the location of gcc/g++ manually. This can be used in conjunction
1952         with --enable-icecream when icecream gcc/g++ wrappers are installed in a
1953         non-default path.]),
1954,)
1955
1956AC_ARG_WITH(gnu-patch,
1957    AS_HELP_STRING([--with-gnu-patch],
1958        [Specify location of GNU patch on Solaris or FreeBSD.]),
1959,)
1960
1961AC_ARG_WITH(build-platform-configure-options,
1962    AS_HELP_STRING([--with-build-platform-configure-options],
1963        [Specify options for the configure script run for the *build* platform in a cross-compilation]),
1964,)
1965
1966AC_ARG_WITH(gnu-cp,
1967    AS_HELP_STRING([--with-gnu-cp],
1968        [Specify location of GNU cp on Solaris or FreeBSD.]),
1969,)
1970
1971AC_ARG_WITH(external-tar,
1972    AS_HELP_STRING([--with-external-tar=<TARFILE_PATH>],
1973        [Specify an absolute path of where to find (and store) tarfiles.]),
1974    TARFILE_LOCATION=$withval ,
1975)
1976
1977AC_ARG_WITH(referenced-git,
1978    AS_HELP_STRING([--with-referenced-git=<OTHER_CHECKOUT_DIR>],
1979        [Specify another checkout directory to reference. This makes use of
1980                 git submodule update --reference, and saves a lot of diskspace
1981                 when having multiple trees side-by-side.]),
1982    GIT_REFERENCE_SRC=$withval ,
1983)
1984
1985AC_ARG_WITH(linked-git,
1986    AS_HELP_STRING([--with-linked-git=<submodules repo basedir>],
1987        [Specify a directory where the repositories of submodules are located.
1988         This uses a method similar to git-new-workdir to get submodules.]),
1989    GIT_LINK_SRC=$withval ,
1990)
1991
1992AC_ARG_WITH(galleries,
1993    AS_HELP_STRING([--with-galleries],
1994        [Specify how galleries should be built. It is possible either to
1995         build these internally from source ("build"),
1996         or to disable them ("no")]),
1997)
1998
1999AC_ARG_WITH(theme,
2000    AS_HELP_STRING([--with-theme="theme1 theme2..."],
2001        [Choose which themes to include. By default those themes with an '*' are included.
2002         Possible choices: *breeze, *breeze_dark, *breeze_dark_svg, *breeze_svg, *colibre, *colibre_svg, *elementary,
2003         *elementary_svg, *karasa_jaga, *karasa_jaga_svg, *sifr, *sifr_dark, *sifr_dark_svg, *sifr_svg, *sukapura, *sukapura_svg.]),
2004,)
2005
2006libo_FUZZ_ARG_WITH(helppack-integration,
2007    AS_HELP_STRING([--without-helppack-integration],
2008        [It will not integrate the helppacks to the installer
2009         of the product. Please use this switch to use the online help
2010         or separate help packages.]),
2011,)
2012
2013libo_FUZZ_ARG_WITH(fonts,
2014    AS_HELP_STRING([--without-fonts],
2015        [LibreOffice includes some third-party fonts to provide a reliable basis for
2016         help content, templates, samples, etc. When these fonts are already
2017         known to be available on the system then you should use this option.]),
2018,)
2019
2020AC_ARG_WITH(epm,
2021    AS_HELP_STRING([--with-epm],
2022        [Decides which epm to use. Default is to use the one from the system if
2023         one is built. When either this is not there or you say =internal epm
2024         will be built.]),
2025,)
2026
2027AC_ARG_WITH(package-format,
2028    AS_HELP_STRING([--with-package-format],
2029        [Specify package format(s) for LibreOffice installation sets. The
2030         implicit --without-package-format leads to no installation sets being
2031         generated. Possible values: aix, archive, bsd, deb, dmg,
2032         installed, msi, pkg, and rpm.
2033         Example: --with-package-format='deb rpm']),
2034,)
2035
2036AC_ARG_WITH(tls,
2037    AS_HELP_STRING([--with-tls],
2038        [Decides which TLS/SSL and cryptographic implementations to use for
2039         LibreOffice's code. Notice that this doesn't apply for depending
2040         libraries like "neon", for example. Default is to use NSS
2041         although OpenSSL is also possible. Notice that selecting NSS restricts
2042         the usage of OpenSSL in LO's code but selecting OpenSSL doesn't
2043         restrict by now the usage of NSS in LO's code. Possible values:
2044         openssl, nss. Example: --with-tls="nss"]),
2045,)
2046
2047AC_ARG_WITH(system-libs,
2048    AS_HELP_STRING([--with-system-libs],
2049        [Use libraries already on system -- enables all --with-system-* flags.]),
2050,)
2051
2052AC_ARG_WITH(system-bzip2,
2053    AS_HELP_STRING([--with-system-bzip2],
2054        [Use bzip2 already on system. Used only when --enable-online-update=mar]),,
2055    [with_system_bzip2="$with_system_libs"])
2056
2057AC_ARG_WITH(system-headers,
2058    AS_HELP_STRING([--with-system-headers],
2059        [Use headers already on system -- enables all --with-system-* flags for
2060         external packages whose headers are the only entities used i.e.
2061         boost/odbc/sane-header(s).]),,
2062    [with_system_headers="$with_system_libs"])
2063
2064AC_ARG_WITH(system-jars,
2065    AS_HELP_STRING([--without-system-jars],
2066        [When building with --with-system-libs, also the needed jars are expected
2067         on the system. Use this to disable that]),,
2068    [with_system_jars="$with_system_libs"])
2069
2070AC_ARG_WITH(system-cairo,
2071    AS_HELP_STRING([--with-system-cairo],
2072        [Use cairo libraries already on system.  Happens automatically for
2073         (implicit) --enable-gtk3.]))
2074
2075AC_ARG_WITH(system-epoxy,
2076    AS_HELP_STRING([--with-system-epoxy],
2077        [Use epoxy libraries already on system.  Happens automatically for
2078         (implicit) --enable-gtk3.]),,
2079       [with_system_epoxy="$with_system_libs"])
2080
2081AC_ARG_WITH(myspell-dicts,
2082    AS_HELP_STRING([--with-myspell-dicts],
2083        [Adds myspell dictionaries to the LibreOffice installation set]),
2084,)
2085
2086AC_ARG_WITH(system-dicts,
2087    AS_HELP_STRING([--without-system-dicts],
2088        [Do not use dictionaries from system paths.]),
2089,)
2090
2091AC_ARG_WITH(external-dict-dir,
2092    AS_HELP_STRING([--with-external-dict-dir],
2093        [Specify external dictionary dir.]),
2094,)
2095
2096AC_ARG_WITH(external-hyph-dir,
2097    AS_HELP_STRING([--with-external-hyph-dir],
2098        [Specify external hyphenation pattern dir.]),
2099,)
2100
2101AC_ARG_WITH(external-thes-dir,
2102    AS_HELP_STRING([--with-external-thes-dir],
2103        [Specify external thesaurus dir.]),
2104,)
2105
2106AC_ARG_WITH(system-zlib,
2107    AS_HELP_STRING([--with-system-zlib],
2108        [Use zlib already on system.]),,
2109    [with_system_zlib=auto])
2110
2111AC_ARG_WITH(system-jpeg,
2112    AS_HELP_STRING([--with-system-jpeg],
2113        [Use jpeg already on system.]),,
2114    [with_system_jpeg="$with_system_libs"])
2115
2116AC_ARG_WITH(system-clucene,
2117    AS_HELP_STRING([--with-system-clucene],
2118        [Use clucene already on system.]),,
2119    [with_system_clucene="$with_system_libs"])
2120
2121AC_ARG_WITH(system-expat,
2122    AS_HELP_STRING([--with-system-expat],
2123        [Use expat already on system.]),,
2124    [with_system_expat="$with_system_libs"])
2125
2126AC_ARG_WITH(system-libxml,
2127    AS_HELP_STRING([--with-system-libxml],
2128        [Use libxml/libxslt already on system.]),,
2129    [with_system_libxml=auto])
2130
2131AC_ARG_WITH(system-icu,
2132    AS_HELP_STRING([--with-system-icu],
2133        [Use icu already on system.]),,
2134    [with_system_icu="$with_system_libs"])
2135
2136AC_ARG_WITH(system-ucpp,
2137    AS_HELP_STRING([--with-system-ucpp],
2138        [Use ucpp already on system.]),,
2139    [])
2140
2141AC_ARG_WITH(system-openldap,
2142    AS_HELP_STRING([--with-system-openldap],
2143        [Use the OpenLDAP LDAP SDK already on system.]),,
2144    [with_system_openldap="$with_system_libs"])
2145
2146libo_FUZZ_ARG_ENABLE(poppler,
2147    AS_HELP_STRING([--disable-poppler],
2148        [Disable building Poppler.])
2149)
2150
2151AC_ARG_WITH(system-poppler,
2152    AS_HELP_STRING([--with-system-poppler],
2153        [Use system poppler (only needed for PDF import).]),,
2154    [with_system_poppler="$with_system_libs"])
2155
2156libo_FUZZ_ARG_ENABLE(gpgmepp,
2157    AS_HELP_STRING([--disable-gpgmepp],
2158        [Disable building gpgmepp. Do not use in normal cases unless you want to fix potential problems it causes.])
2159)
2160
2161AC_ARG_WITH(system-gpgmepp,
2162    AS_HELP_STRING([--with-system-gpgmepp],
2163        [Use gpgmepp already on system]),,
2164    [with_system_gpgmepp="$with_system_libs"])
2165
2166AC_ARG_WITH(system-mariadb,
2167    AS_HELP_STRING([--with-system-mariadb],
2168        [Use MariaDB/MySQL libraries already on system.]),,
2169    [with_system_mariadb="$with_system_libs"])
2170
2171AC_ARG_ENABLE(bundle-mariadb,
2172    AS_HELP_STRING([--enable-bundle-mariadb],
2173        [When using MariaDB/MySQL libraries already on system, bundle them with the MariaDB Connector/LibreOffice.])
2174)
2175
2176AC_ARG_WITH(system-postgresql,
2177    AS_HELP_STRING([--with-system-postgresql],
2178        [Use PostgreSQL libraries already on system, for building the PostgreSQL-SDBC
2179         driver. If pg_config is not in PATH, use PGCONFIG to point to it.]),,
2180    [with_system_postgresql="$with_system_libs"])
2181
2182AC_ARG_WITH(libpq-path,
2183    AS_HELP_STRING([--with-libpq-path=<absolute path to your libpq installation>],
2184        [Use this PostgreSQL C interface (libpq) installation for building
2185         the PostgreSQL-SDBC extension.]),
2186,)
2187
2188AC_ARG_WITH(system-firebird,
2189    AS_HELP_STRING([--with-system-firebird],
2190        [Use Firebird libraries already on system, for building the Firebird-SDBC
2191         driver. If fb_config is not in PATH, use FBCONFIG to point to it.]),,
2192    [with_system_firebird="$with_system_libs"])
2193
2194AC_ARG_WITH(system-libtommath,
2195            AS_HELP_STRING([--with-system-libtommath],
2196                           [Use libtommath already on system]),,
2197            [with_system_libtommath="$with_system_libs"])
2198
2199AC_ARG_WITH(system-hsqldb,
2200    AS_HELP_STRING([--with-system-hsqldb],
2201        [Use hsqldb already on system.]))
2202
2203AC_ARG_WITH(hsqldb-jar,
2204    AS_HELP_STRING([--with-hsqldb-jar=JARFILE],
2205        [Specify path to jarfile manually.]),
2206    HSQLDB_JAR=$withval)
2207
2208libo_FUZZ_ARG_ENABLE(scripting-beanshell,
2209    AS_HELP_STRING([--disable-scripting-beanshell],
2210        [Disable support for scripts in BeanShell.]),
2211,
2212)
2213
2214AC_ARG_WITH(system-beanshell,
2215    AS_HELP_STRING([--with-system-beanshell],
2216        [Use beanshell already on system.]),,
2217    [with_system_beanshell="$with_system_jars"])
2218
2219AC_ARG_WITH(beanshell-jar,
2220    AS_HELP_STRING([--with-beanshell-jar=JARFILE],
2221        [Specify path to jarfile manually.]),
2222    BSH_JAR=$withval)
2223
2224libo_FUZZ_ARG_ENABLE(scripting-javascript,
2225    AS_HELP_STRING([--disable-scripting-javascript],
2226        [Disable support for scripts in JavaScript.]),
2227,
2228)
2229
2230AC_ARG_WITH(system-rhino,
2231    AS_HELP_STRING([--with-system-rhino],
2232        [Use rhino already on system.]),,)
2233#    [with_system_rhino="$with_system_jars"])
2234# Above is not used as we have different debug interface
2235# patched into internal rhino. This code needs to be fixed
2236# before we can enable it by default.
2237
2238AC_ARG_WITH(rhino-jar,
2239    AS_HELP_STRING([--with-rhino-jar=JARFILE],
2240        [Specify path to jarfile manually.]),
2241    RHINO_JAR=$withval)
2242
2243AC_ARG_WITH(system-jfreereport,
2244    AS_HELP_STRING([--with-system-jfreereport],
2245        [Use JFreeReport already on system.]),,
2246    [with_system_jfreereport="$with_system_jars"])
2247
2248AC_ARG_WITH(sac-jar,
2249    AS_HELP_STRING([--with-sac-jar=JARFILE],
2250        [Specify path to jarfile manually.]),
2251    SAC_JAR=$withval)
2252
2253AC_ARG_WITH(libxml-jar,
2254    AS_HELP_STRING([--with-libxml-jar=JARFILE],
2255        [Specify path to jarfile manually.]),
2256    LIBXML_JAR=$withval)
2257
2258AC_ARG_WITH(flute-jar,
2259    AS_HELP_STRING([--with-flute-jar=JARFILE],
2260        [Specify path to jarfile manually.]),
2261    FLUTE_JAR=$withval)
2262
2263AC_ARG_WITH(jfreereport-jar,
2264    AS_HELP_STRING([--with-jfreereport-jar=JARFILE],
2265        [Specify path to jarfile manually.]),
2266    JFREEREPORT_JAR=$withval)
2267
2268AC_ARG_WITH(liblayout-jar,
2269    AS_HELP_STRING([--with-liblayout-jar=JARFILE],
2270        [Specify path to jarfile manually.]),
2271    LIBLAYOUT_JAR=$withval)
2272
2273AC_ARG_WITH(libloader-jar,
2274    AS_HELP_STRING([--with-libloader-jar=JARFILE],
2275        [Specify path to jarfile manually.]),
2276    LIBLOADER_JAR=$withval)
2277
2278AC_ARG_WITH(libformula-jar,
2279    AS_HELP_STRING([--with-libformula-jar=JARFILE],
2280        [Specify path to jarfile manually.]),
2281    LIBFORMULA_JAR=$withval)
2282
2283AC_ARG_WITH(librepository-jar,
2284    AS_HELP_STRING([--with-librepository-jar=JARFILE],
2285        [Specify path to jarfile manually.]),
2286    LIBREPOSITORY_JAR=$withval)
2287
2288AC_ARG_WITH(libfonts-jar,
2289    AS_HELP_STRING([--with-libfonts-jar=JARFILE],
2290        [Specify path to jarfile manually.]),
2291    LIBFONTS_JAR=$withval)
2292
2293AC_ARG_WITH(libserializer-jar,
2294    AS_HELP_STRING([--with-libserializer-jar=JARFILE],
2295        [Specify path to jarfile manually.]),
2296    LIBSERIALIZER_JAR=$withval)
2297
2298AC_ARG_WITH(libbase-jar,
2299    AS_HELP_STRING([--with-libbase-jar=JARFILE],
2300        [Specify path to jarfile manually.]),
2301    LIBBASE_JAR=$withval)
2302
2303AC_ARG_WITH(system-odbc,
2304    AS_HELP_STRING([--with-system-odbc],
2305        [Use the odbc headers already on system.]),,
2306    [with_system_odbc="auto"])
2307
2308AC_ARG_WITH(system-sane,
2309    AS_HELP_STRING([--with-system-sane],
2310        [Use sane.h already on system.]),,
2311    [with_system_sane="$with_system_headers"])
2312
2313AC_ARG_WITH(system-bluez,
2314    AS_HELP_STRING([--with-system-bluez],
2315        [Use bluetooth.h already on system.]),,
2316    [with_system_bluez="$with_system_headers"])
2317
2318AC_ARG_WITH(system-curl,
2319    AS_HELP_STRING([--with-system-curl],
2320        [Use curl already on system.]),,
2321    [with_system_curl=auto])
2322
2323AC_ARG_WITH(system-boost,
2324    AS_HELP_STRING([--with-system-boost],
2325        [Use boost already on system.]),,
2326    [with_system_boost="$with_system_headers"])
2327
2328AC_ARG_WITH(system-glm,
2329    AS_HELP_STRING([--with-system-glm],
2330        [Use glm already on system.]),,
2331    [with_system_glm="$with_system_headers"])
2332
2333AC_ARG_WITH(system-hunspell,
2334    AS_HELP_STRING([--with-system-hunspell],
2335        [Use libhunspell already on system.]),,
2336    [with_system_hunspell="$with_system_libs"])
2337
2338libo_FUZZ_ARG_ENABLE(zxing,
2339    AS_HELP_STRING([--disable-zxing],
2340       [Disable use of zxing external library.]))
2341
2342AC_ARG_WITH(system-zxing,
2343    AS_HELP_STRING([--with-system-zxing],
2344        [Use libzxing already on system.]),,
2345    [with_system_zxing="$with_system_libs"])
2346
2347AC_ARG_WITH(system-box2d,
2348    AS_HELP_STRING([--with-system-box2d],
2349        [Use box2d already on system.]),,
2350    [with_system_box2d="$with_system_libs"])
2351
2352AC_ARG_WITH(system-mythes,
2353    AS_HELP_STRING([--with-system-mythes],
2354        [Use mythes already on system.]),,
2355    [with_system_mythes="$with_system_libs"])
2356
2357AC_ARG_WITH(system-altlinuxhyph,
2358    AS_HELP_STRING([--with-system-altlinuxhyph],
2359        [Use ALTLinuxhyph already on system.]),,
2360    [with_system_altlinuxhyph="$with_system_libs"])
2361
2362AC_ARG_WITH(system-lpsolve,
2363    AS_HELP_STRING([--with-system-lpsolve],
2364        [Use lpsolve already on system.]),,
2365    [with_system_lpsolve="$with_system_libs"])
2366
2367AC_ARG_WITH(system-coinmp,
2368    AS_HELP_STRING([--with-system-coinmp],
2369        [Use CoinMP already on system.]),,
2370    [with_system_coinmp="$with_system_libs"])
2371
2372AC_ARG_WITH(system-liblangtag,
2373    AS_HELP_STRING([--with-system-liblangtag],
2374        [Use liblangtag library already on system.]),,
2375    [with_system_liblangtag="$with_system_libs"])
2376
2377AC_ARG_WITH(webdav,
2378    AS_HELP_STRING([--with-webdav],
2379        [Specify which library to use for webdav implementation.
2380         Possible values: "neon", "serf", "no". The default value is "neon".
2381         Example: --with-webdav="serf"]))
2382
2383AC_ARG_WITH(linker-hash-style,
2384    AS_HELP_STRING([--with-linker-hash-style],
2385        [Use linker with --hash-style=<style> when linking shared objects.
2386         Possible values: "sysv", "gnu", "both". The default value is "gnu"
2387         if supported on the build system, and "sysv" otherwise.]))
2388
2389AC_ARG_WITH(jdk-home,
2390    AS_HELP_STRING([--with-jdk-home=<absolute path to JDK home>],
2391        [If you have installed JDK 9 or later on your system please supply the
2392         path here. Note that this is not the location of the java command but the
2393         location of the entire distribution. In case of cross-compiling, this
2394         is the JDK of the host os. Use --with-build-platform-configure-options
2395         to point to a different build platform JDK.]),
2396,)
2397
2398AC_ARG_WITH(help,
2399    AS_HELP_STRING([--with-help],
2400        [Enable the build of help. There is a special parameter "common" that
2401         can be used to bundle only the common part, .e.g help-specific icons.
2402         This is useful when you build the helpcontent separately.])
2403    [
2404                          Usage:     --with-help    build the old local help
2405                                 --without-help     no local help (default)
2406                                 --with-help=html   build the new HTML local help
2407                                 --with-help=online build the new HTML online help
2408    ],
2409,)
2410
2411AC_ARG_WITH(omindex,
2412   AS_HELP_STRING([--with-omindex],
2413        [Enable the support of xapian-omega index for online help.])
2414   [
2415                         Usage: --with-omindex=server prepare the pages for omindex
2416                                but let xapian-omega be built in server.
2417                                --with-omindex=noxap do not prepare online pages
2418                                for xapian-omega
2419  ],
2420,)
2421
2422libo_FUZZ_ARG_WITH(java,
2423    AS_HELP_STRING([--with-java=<java command>],
2424        [Specify the name of the Java interpreter command. Typically "java"
2425         which is the default.
2426
2427         To build without support for Java components, applets, accessibility
2428         or the XML filters written in Java, use --without-java or --with-java=no.]),
2429    [ test -z "$with_java" -o "$with_java" = "yes" && with_java=java ],
2430    [ test -z "$with_java" -o "$with_java" = "yes" && with_java=java ]
2431)
2432
2433AC_ARG_WITH(jvm-path,
2434    AS_HELP_STRING([--with-jvm-path=<absolute path to parent of jvm home>],
2435        [Use a specific JVM search path at runtime.
2436         e.g. use --with-jvm-path=/usr/lib/ to find JRE/JDK in /usr/lib/jvm/]),
2437,)
2438
2439AC_ARG_WITH(ant-home,
2440    AS_HELP_STRING([--with-ant-home=<absolute path to Ant home>],
2441        [If you have installed Apache Ant on your system, please supply the path here.
2442         Note that this is not the location of the Ant binary but the location
2443         of the entire distribution.]),
2444,)
2445
2446AC_ARG_WITH(symbol-config,
2447    AS_HELP_STRING([--with-symbol-config],
2448        [Configuration for the crashreport symbol upload]),
2449        [],
2450        [with_symbol_config=no])
2451
2452AC_ARG_WITH(export-validation,
2453    AS_HELP_STRING([--without-export-validation],
2454        [Disable validating OOXML and ODF files as exported from in-tree tests.]),
2455,with_export_validation=auto)
2456
2457AC_ARG_WITH(bffvalidator,
2458    AS_HELP_STRING([--with-bffvalidator=<absolute path to BFFValidator>],
2459        [Enables export validation for Microsoft Binary formats (doc, xls, ppt).
2460         Requires installed Microsoft Office Binary File Format Validator.
2461         Note: export-validation (--with-export-validation) is required to be turned on.
2462         See https://www.microsoft.com/en-us/download/details.aspx?id=26794]),
2463,with_bffvalidator=no)
2464
2465libo_FUZZ_ARG_WITH(junit,
2466    AS_HELP_STRING([--with-junit=<absolute path to JUnit 4 jar>],
2467        [Specifies the JUnit 4 jar file to use for JUnit-based tests.
2468         --without-junit disables those tests. Not relevant in the --without-java case.]),
2469,with_junit=yes)
2470
2471AC_ARG_WITH(hamcrest,
2472    AS_HELP_STRING([--with-hamcrest=<absolute path to hamcrest jar>],
2473        [Specifies the hamcrest jar file to use for JUnit-based tests.
2474         --without-junit disables those tests. Not relevant in the --without-java case.]),
2475,with_hamcrest=yes)
2476
2477AC_ARG_WITH(perl-home,
2478    AS_HELP_STRING([--with-perl-home=<abs. path to Perl 5 home>],
2479        [If you have installed Perl 5 Distribution, on your system, please
2480         supply the path here. Note that this is not the location of the Perl
2481         binary but the location of the entire distribution.]),
2482,)
2483
2484libo_FUZZ_ARG_WITH(doxygen,
2485    AS_HELP_STRING(
2486        [--with-doxygen=<absolute path to doxygen executable>],
2487        [Specifies the doxygen executable to use when generating ODK C/C++
2488         documentation. --without-doxygen disables generation of ODK C/C++
2489         documentation. Not relevant in the --disable-odk case.]),
2490,with_doxygen=yes)
2491
2492AC_ARG_WITH(visual-studio,
2493    AS_HELP_STRING([--with-visual-studio=<2019>],
2494        [Specify which Visual Studio version to use in case several are
2495         installed. Currently only 2019 (default) is supported.]),
2496,)
2497
2498AC_ARG_WITH(windows-sdk,
2499    AS_HELP_STRING([--with-windows-sdk=<8.0(A)/8.1(A)/10.0>],
2500        [Specify which Windows SDK, or "Windows Kit", version to use
2501         in case the one that came with the selected Visual Studio
2502         is not what you want for some reason. Note that not all compiler/SDK
2503         combinations are supported. The intent is that this option should not
2504         be needed.]),
2505,)
2506
2507AC_ARG_WITH(lang,
2508    AS_HELP_STRING([--with-lang="es sw tu cs sk"],
2509        [Use this option to build LibreOffice with additional UI language support.
2510         English (US) is always included by default.
2511         Separate multiple languages with space.
2512         For all languages, use --with-lang=ALL.]),
2513,)
2514
2515AC_ARG_WITH(locales,
2516    AS_HELP_STRING([--with-locales="en es pt fr zh kr ja"],
2517        [Use this option to limit the locale information built in.
2518         Separate multiple locales with space.
2519         Very experimental and might well break stuff.
2520         Just a desperate measure to shrink code and data size.
2521         By default all the locales available is included.
2522         This option is completely unrelated to --with-lang.])
2523    [
2524                          Affects also our character encoding conversion
2525                          tables for encodings mainly targeted for a
2526                          particular locale, like EUC-CN and EUC-TW for
2527                          zh, ISO-2022-JP for ja.
2528
2529                          Affects also our add-on break iterator data for
2530                          some languages.
2531
2532                          For the default, all locales, don't use this switch at all.
2533                          Specifying just the language part of a locale means all matching
2534                          locales will be included.
2535    ],
2536,)
2537
2538# Kerberos and GSSAPI used only by PostgreSQL as of LibO 3.5
2539libo_FUZZ_ARG_WITH(krb5,
2540    AS_HELP_STRING([--with-krb5],
2541        [Enable MIT Kerberos 5 support in modules that support it.
2542         By default automatically enabled on platforms
2543         where a good system Kerberos 5 is available.]),
2544,)
2545
2546libo_FUZZ_ARG_WITH(gssapi,
2547    AS_HELP_STRING([--with-gssapi],
2548        [Enable GSSAPI support in modules that support it.
2549         By default automatically enabled on platforms
2550         where a good system GSSAPI is available.]),
2551,)
2552
2553AC_ARG_WITH(iwyu,
2554    AS_HELP_STRING([--with-iwyu],
2555        [Use given IWYU binary path to check unneeded includes instead of building.
2556         Use only if you are hacking on it.]),
2557,)
2558
2559libo_FUZZ_ARG_WITH(lxml,
2560    AS_HELP_STRING([--without-lxml],
2561        [gla11y will use python lxml when available, potentially building a local copy if necessary.
2562         --without-lxml tells it to not use python lxml at all, which means that gla11y will only
2563         report widget classes and ids.]),
2564,)
2565
2566libo_FUZZ_ARG_WITH(latest-c++,
2567    AS_HELP_STRING([--with-latest-c++],
2568        [Try to enable the latest features of the C++ compiler, even if they are not yet part of a
2569         published standard.]),,
2570        [with_latest_c__=no])
2571
2572dnl ===================================================================
2573dnl Branding
2574dnl ===================================================================
2575
2576AC_ARG_WITH(branding,
2577    AS_HELP_STRING([--with-branding=/path/to/images],
2578        [Use given path to retrieve branding images set.])
2579    [
2580                          Search for intro.png about.svg and logo.svg.
2581                          If any is missing, default ones will be used instead.
2582
2583                          Search also progress.conf for progress
2584                          settings on intro screen :
2585
2586                          PROGRESSBARCOLOR="255,255,255" Set color of
2587                          progress bar. Comma separated RGB decimal values.
2588                          PROGRESSSIZE="407,6" Set size of progress bar.
2589                          Comma separated decimal values (width, height).
2590                          PROGRESSPOSITION="61,317" Set position of progress
2591                          bar from left,top. Comma separated decimal values.
2592                          PROGRESSFRAMECOLOR="20,136,3" Set color of progress
2593                          bar frame. Comma separated RGB decimal values.
2594                          PROGRESSTEXTCOLOR="0,0,0" Set color of progress
2595                          bar text. Comma separated RGB decimal values.
2596                          PROGRESSTEXTBASELINE="287" Set vertical position of
2597                          progress bar text from top. Decimal value.
2598
2599                          Default values will be used if not found.
2600    ],
2601,)
2602
2603
2604AC_ARG_WITH(extra-buildid,
2605    AS_HELP_STRING([--with-extra-buildid="Tinderbox: Win-x86@6, Branch:master, Date:2012-11-26_00.29.34"],
2606        [Show addition build identification in about dialog.]),
2607,)
2608
2609
2610AC_ARG_WITH(vendor,
2611    AS_HELP_STRING([--with-vendor="John the Builder"],
2612        [Set vendor of the build.]),
2613,)
2614
2615AC_ARG_WITH(privacy-policy-url,
2616    AS_HELP_STRING([--with-privacy-policy-url="https://yourdomain/privacy-policy"],
2617        [The URL to your privacy policy (needed when
2618         enabling online-update or crashreporting via breakpad)]),
2619        [if test "x$with_privacy_policy_url" = "xyes"; then
2620            AC_MSG_FAILURE([you need to specify an argument when using --with-privacy-policy-url])
2621         elif test "x$with_privacy_policy_url" = "xno"; then
2622            with_privacy_policy_url="undefined"
2623         fi]
2624,[with_privacy_policy_url="undefined"])
2625
2626AC_ARG_WITH(android-package-name,
2627    AS_HELP_STRING([--with-android-package-name="org.libreoffice"],
2628        [Set Android package name of the build.]),
2629,)
2630
2631AC_ARG_WITH(compat-oowrappers,
2632    AS_HELP_STRING([--with-compat-oowrappers],
2633        [Install oo* wrappers in parallel with
2634         lo* ones to keep backward compatibility.
2635         Has effect only with make distro-pack-install]),
2636,)
2637
2638AC_ARG_WITH(os-version,
2639    AS_HELP_STRING([--with-os-version=<OSVERSION>],
2640        [For FreeBSD users, use this option to override the detected OSVERSION.]),
2641,)
2642
2643AC_ARG_WITH(idlc-cpp,
2644    AS_HELP_STRING([--with-idlc-cpp=<cpp/ucpp>],
2645        [Specify the C Preprocessor to use for idlc. Default is ucpp.]),
2646,)
2647
2648AC_ARG_WITH(parallelism,
2649    AS_HELP_STRING([--with-parallelism],
2650        [Number of jobs to run simultaneously during build. Parallel builds can
2651        save a lot of time on multi-cpu machines. Defaults to the number of
2652        CPUs on the machine, unless you configure --enable-icecream - then to
2653        40.]),
2654,)
2655
2656AC_ARG_WITH(all-tarballs,
2657    AS_HELP_STRING([--with-all-tarballs],
2658        [Download all external tarballs unconditionally]))
2659
2660AC_ARG_WITH(gdrive-client-id,
2661    AS_HELP_STRING([--with-gdrive-client-id],
2662        [Provides the client id of the application for OAuth2 authentication
2663        on Google Drive. If either this or --with-gdrive-client-secret is
2664        empty, the feature will be disabled]),
2665)
2666
2667AC_ARG_WITH(gdrive-client-secret,
2668    AS_HELP_STRING([--with-gdrive-client-secret],
2669        [Provides the client secret of the application for OAuth2
2670        authentication on Google Drive. If either this or
2671        --with-gdrive-client-id is empty, the feature will be disabled]),
2672)
2673
2674AC_ARG_WITH(alfresco-cloud-client-id,
2675    AS_HELP_STRING([--with-alfresco-cloud-client-id],
2676        [Provides the client id of the application for OAuth2 authentication
2677        on Alfresco Cloud. If either this or --with-alfresco-cloud-client-secret is
2678        empty, the feature will be disabled]),
2679)
2680
2681AC_ARG_WITH(alfresco-cloud-client-secret,
2682    AS_HELP_STRING([--with-alfresco-cloud-client-secret],
2683        [Provides the client secret of the application for OAuth2
2684        authentication on Alfresco Cloud. If either this or
2685        --with-alfresco-cloud-client-id is empty, the feature will be disabled]),
2686)
2687
2688AC_ARG_WITH(onedrive-client-id,
2689    AS_HELP_STRING([--with-onedrive-client-id],
2690        [Provides the client id of the application for OAuth2 authentication
2691        on OneDrive. If either this or --with-onedrive-client-secret is
2692        empty, the feature will be disabled]),
2693)
2694
2695AC_ARG_WITH(onedrive-client-secret,
2696    AS_HELP_STRING([--with-onedrive-client-secret],
2697        [Provides the client secret of the application for OAuth2
2698        authentication on OneDrive. If either this or
2699        --with-onedrive-client-id is empty, the feature will be disabled]),
2700)
2701dnl ===================================================================
2702dnl Do we want to use pre-build binary tarball for recompile
2703dnl ===================================================================
2704
2705if test "$enable_library_bin_tar" = "yes" ; then
2706    USE_LIBRARY_BIN_TAR=TRUE
2707else
2708    USE_LIBRARY_BIN_TAR=
2709fi
2710AC_SUBST(USE_LIBRARY_BIN_TAR)
2711
2712dnl ===================================================================
2713dnl Test whether build target is Release Build
2714dnl ===================================================================
2715AC_MSG_CHECKING([whether build target is Release Build])
2716if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
2717    AC_MSG_RESULT([no])
2718    ENABLE_RELEASE_BUILD=
2719    GET_TASK_ALLOW_ENTITLEMENT='
2720        <!-- We want to be able to debug a hardened process when not building for release -->
2721        <key>com.apple.security.get-task-allow</key>
2722        <true/>'
2723else
2724    AC_MSG_RESULT([yes])
2725    ENABLE_RELEASE_BUILD=TRUE
2726    GET_TASK_ALLOW_ENTITLEMENT=''
2727fi
2728AC_SUBST(ENABLE_RELEASE_BUILD)
2729AC_SUBST(GET_TASK_ALLOW_ENTITLEMENT)
2730
2731AC_MSG_CHECKING([whether to build a Community flavor])
2732if test -z "$enable_community_flavor" -o "$enable_community_flavor" = "yes"; then
2733    AC_DEFINE(HAVE_FEATURE_COMMUNITY_FLAVOR)
2734    AC_MSG_RESULT([yes])
2735else
2736    AC_MSG_RESULT([no])
2737fi
2738
2739dnl ===================================================================
2740dnl Test whether to sign Windows Build
2741dnl ===================================================================
2742AC_MSG_CHECKING([whether to sign windows build])
2743if test "$enable_windows_build_signing" = "yes" -a "$_os" = "WINNT"; then
2744    AC_MSG_RESULT([yes])
2745    WINDOWS_BUILD_SIGNING="TRUE"
2746else
2747    AC_MSG_RESULT([no])
2748    WINDOWS_BUILD_SIGNING="FALSE"
2749fi
2750AC_SUBST(WINDOWS_BUILD_SIGNING)
2751
2752dnl ===================================================================
2753dnl MacOSX build and runtime environment options
2754dnl ===================================================================
2755
2756AC_ARG_WITH(macosx-sdk,
2757    AS_HELP_STRING([--with-macosx-sdk=<version>],
2758        [Prefer a specific SDK for building.])
2759    [
2760                          If the requested SDK is not available, a search for the oldest one will be done.
2761                          With current Xcode versions, only the latest SDK is included, so this option is
2762                          not terribly useful. It works fine to build with a new SDK and run the result
2763                          on an older OS.
2764
2765                          e. g.: --with-macosx-sdk=10.10
2766
2767                          there are 3 options to control the MacOSX build:
2768                          --with-macosx-sdk (referred as 'sdk' below)
2769                          --with-macosx-version-min-required (referred as 'min' below)
2770                          --with-macosx-version-max-allowed (referred as 'max' below)
2771
2772                          the connection between these value and the default they take is as follow:
2773                          ( ? means not specified on the command line, s means the SDK version found,
2774                          constraint: 8 <= x <= y <= z)
2775
2776                          ==========================================
2777                           command line      || config result
2778                          ==========================================
2779                          min  | max  | sdk  || min   | max  | sdk  |
2780                          ?    | ?    | ?    || 10.10 | 10.s | 10.s |
2781                          ?    | ?    | 10.x || 10.10 | 10.x | 10.x |
2782                          ?    | 10.x | ?    || 10.10 | 10.s | 10.s |
2783                          ?    | 10.x | 10.y || 10.10 | 10.x | 10.y |
2784                          10.x | ?    | ?    || 10.x  | 10.s | 10.s |
2785                          10.x | ?    | 10.y || 10.x  | 10.y | 10.y |
2786                          10.x | 10.y | ?    || 10.x  | 10.y | 10.y |
2787                          10.x | 10.y | 10.z || 10.x  | 10.y | 10.z |
2788
2789
2790                          see: http://developer.apple.com/library/mac/#technotes/tn2064/_index.html
2791                          for a detailed technical explanation of these variables
2792
2793                          Note: MACOSX_DEPLOYMENT_TARGET will be set to the value of 'min'.
2794    ],
2795,)
2796
2797AC_ARG_WITH(macosx-version-min-required,
2798    AS_HELP_STRING([--with-macosx-version-min-required=<version>],
2799        [set the minimum OS version needed to run the built LibreOffice])
2800    [
2801                          e. g.: --with-macosx-version-min-required=10.10
2802                          see --with-macosx-sdk for more info
2803    ],
2804,)
2805
2806AC_ARG_WITH(macosx-version-max-allowed,
2807    AS_HELP_STRING([--with-macosx-version-max-allowed=<version>],
2808        [set the maximum allowed OS version the LibreOffice compilation can use APIs from])
2809    [
2810                          e. g.: --with-macosx-version-max-allowed=10.10
2811                          see --with-macosx-sdk for more info
2812    ],
2813,)
2814
2815
2816dnl ===================================================================
2817dnl options for stuff used during cross-compilation build
2818dnl Not quite superseded by --with-build-platform-configure-options.
2819dnl TODO: check, if the "force" option is still needed anywhere.
2820dnl ===================================================================
2821
2822AC_ARG_WITH(system-icu-for-build,
2823    AS_HELP_STRING([--with-system-icu-for-build=yes/no/force],
2824        [Use icu already on system for build tools (cross-compilation only).]))
2825
2826
2827dnl ===================================================================
2828dnl Check for incompatible options set by fuzzing, and reset those
2829dnl automatically to working combinations
2830dnl ===================================================================
2831
2832if test "$libo_fuzzed_enable_dbus" = yes -a "$libo_fuzzed_enable_avahi" -a \
2833        "$enable_dbus" != "$enable_avahi"; then
2834    AC_MSG_NOTICE([Resetting --enable-avahi=$enable_dbus])
2835    enable_avahi=$enable_dbus
2836fi
2837
2838add_lopath_after ()
2839{
2840    if ! echo "$LO_PATH" | $EGREP -q "(^|${P_SEP})$1($|${P_SEP})"; then
2841        LO_PATH="${LO_PATH:+$LO_PATH$P_SEP}$1"
2842    fi
2843}
2844
2845add_lopath_before ()
2846{
2847    local IFS=${P_SEP}
2848    local path_cleanup
2849    local dir
2850    for dir in $LO_PATH ; do
2851        if test "$dir" != "$1" ; then
2852            path_cleanup=${path_cleanup:+$path_cleanup$P_SEP}$dir
2853        fi
2854    done
2855    LO_PATH="$1${path_cleanup:+$P_SEP$path_cleanup}"
2856}
2857
2858dnl ===================================================================
2859dnl check for required programs (grep, awk, sed, bash)
2860dnl ===================================================================
2861
2862pathmunge ()
2863{
2864    local new_path
2865    if test -n "$1"; then
2866        if test "$build_os" = "cygwin"; then
2867            if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
2868                PathFormat "$1"
2869                new_path=`cygpath -sm "$formatted_path"`
2870            else
2871                PathFormat "$1"
2872                new_path=`cygpath -u "$formatted_path"`
2873            fi
2874        else
2875            new_path="$1"
2876        fi
2877        if test "$2" = "after"; then
2878            add_lopath_after "$new_path"
2879        else
2880            add_lopath_before "$new_path"
2881        fi
2882    fi
2883}
2884
2885AC_PROG_AWK
2886AC_PATH_PROG( AWK, $AWK)
2887if test -z "$AWK"; then
2888    AC_MSG_ERROR([install awk to run this script])
2889fi
2890
2891AC_PATH_PROG(BASH, bash)
2892if test -z "$BASH"; then
2893    AC_MSG_ERROR([bash not found in \$PATH])
2894fi
2895AC_SUBST(BASH)
2896
2897AC_MSG_CHECKING([for GNU or BSD tar])
2898for a in $GNUTAR gtar gnutar bsdtar tar /usr/sfw/bin/gtar; do
2899    $a --version 2> /dev/null | egrep "GNU|bsdtar"  2>&1 > /dev/null
2900    if test $? -eq 0;  then
2901        GNUTAR=$a
2902        break
2903    fi
2904done
2905AC_MSG_RESULT($GNUTAR)
2906if test -z "$GNUTAR"; then
2907    AC_MSG_ERROR([not found. install GNU or BSD tar.])
2908fi
2909AC_SUBST(GNUTAR)
2910
2911AC_MSG_CHECKING([for tar's option to strip components])
2912$GNUTAR --help 2> /dev/null | egrep "bsdtar|strip-components" 2>&1 >/dev/null
2913if test $? -eq 0; then
2914    STRIP_COMPONENTS="--strip-components"
2915else
2916    $GNUTAR --help 2> /dev/null | egrep "strip-path" 2>&1 >/dev/null
2917    if test $? -eq 0; then
2918        STRIP_COMPONENTS="--strip-path"
2919    else
2920        STRIP_COMPONENTS="unsupported"
2921    fi
2922fi
2923AC_MSG_RESULT($STRIP_COMPONENTS)
2924if test x$STRIP_COMPONENTS = xunsupported; then
2925    AC_MSG_ERROR([you need a tar that is able to strip components.])
2926fi
2927AC_SUBST(STRIP_COMPONENTS)
2928
2929dnl It is useful to have a BUILD_TYPE keyword to distinguish "normal"
2930dnl desktop OSes from "mobile" ones.
2931
2932dnl We assume that a non-DESKTOP build type is also a non-NATIVE one.
2933dnl In other words, that when building for an OS that is not a
2934dnl "desktop" one but a "mobile" one, we are always cross-compiling.
2935
2936dnl Note the direction of the implication; there is no assumption that
2937dnl cross-compiling would imply a non-desktop OS.
2938
2939if test $_os != iOS -a $_os != Android -a $_os != Emscripten -a "$enable_fuzzers" != "yes"; then
2940    BUILD_TYPE="$BUILD_TYPE DESKTOP"
2941    AC_DEFINE(HAVE_FEATURE_DESKTOP)
2942    AC_DEFINE(HAVE_FEATURE_MULTIUSER_ENVIRONMENT)
2943fi
2944
2945# Whether to build "avmedia" functionality or not.
2946
2947if test -z "$enable_avmedia"; then
2948    enable_avmedia=yes
2949fi
2950
2951BUILD_TYPE="$BUILD_TYPE AVMEDIA"
2952if test "$enable_avmedia" = yes; then
2953    AC_DEFINE(HAVE_FEATURE_AVMEDIA)
2954else
2955    USE_AVMEDIA_DUMMY='TRUE'
2956fi
2957AC_SUBST(USE_AVMEDIA_DUMMY)
2958
2959# Decide whether to build database connectivity stuff (including Base) or not.
2960if test "$enable_database_connectivity" != no; then
2961    BUILD_TYPE="$BUILD_TYPE DBCONNECTIVITY"
2962    AC_DEFINE(HAVE_FEATURE_DBCONNECTIVITY)
2963else
2964    if test "$_os" = iOS; then
2965        AC_MSG_ERROR([Presumly can't disable DB connectivity on iOS.])
2966    fi
2967    disable_database_connectivity_dependencies
2968fi
2969
2970if test -z "$enable_extensions"; then
2971    # For iOS and Android Viewer, disable extensions unless specifically overridden with --enable-extensions.
2972    if test $_os != iOS && test $_os != Android -o "$ENABLE_ANDROID_LOK" = TRUE ; then
2973        enable_extensions=yes
2974    fi
2975fi
2976
2977if test "$enable_extensions" = yes; then
2978    BUILD_TYPE="$BUILD_TYPE EXTENSIONS"
2979    AC_DEFINE(HAVE_FEATURE_EXTENSIONS)
2980fi
2981
2982if test -z "$enable_scripting"; then
2983    # Disable scripting for iOS unless specifically overridden
2984    # with --enable-scripting.
2985    if test $_os != iOS -o $_os = Emscripten; then
2986        enable_scripting=yes
2987    fi
2988fi
2989
2990DISABLE_SCRIPTING=''
2991if test "$enable_scripting" = yes; then
2992    BUILD_TYPE="$BUILD_TYPE SCRIPTING"
2993    AC_DEFINE(HAVE_FEATURE_SCRIPTING)
2994else
2995    DISABLE_SCRIPTING='TRUE'
2996    SCPDEFS="$SCPDEFS -DDISABLE_SCRIPTING"
2997fi
2998
2999if test $_os = iOS -o $_os = Android -o $_os = Emscripten; then
3000    # Disable dynamic_loading always for iOS and Android
3001    enable_dynamic_loading=no
3002elif test -z "$enable_dynamic_loading"; then
3003    # Otherwise enable it unless specifically disabled
3004    enable_dynamic_loading=yes
3005fi
3006
3007DISABLE_DYNLOADING=''
3008if test "$enable_dynamic_loading" = yes; then
3009    BUILD_TYPE="$BUILD_TYPE DYNLOADING"
3010else
3011    DISABLE_DYNLOADING='TRUE'
3012fi
3013AC_SUBST(DISABLE_DYNLOADING)
3014
3015# remember SYSBASE value
3016AC_SUBST(SYSBASE)
3017
3018dnl ===================================================================
3019dnl  Sort out various gallery compilation options
3020dnl ===================================================================
3021WITH_GALLERY_BUILD=TRUE
3022AC_MSG_CHECKING([how to build and package galleries])
3023if test -n "${with_galleries}"; then
3024    if test "$with_galleries" = "build"; then
3025        if test "$enable_database_connectivity" = no; then
3026            AC_MSG_ERROR([DB connectivity is needed for gengal / svx])
3027        fi
3028        AC_MSG_RESULT([build from source images internally])
3029    elif test "$with_galleries" = "no"; then
3030        WITH_GALLERY_BUILD=
3031        AC_MSG_RESULT([disable non-internal gallery build])
3032    else
3033        AC_MSG_ERROR([unknown value --with-galleries=$with_galleries])
3034    fi
3035else
3036    if test $_os != iOS -a $_os != Android; then
3037        AC_MSG_RESULT([internal src images for desktop])
3038    else
3039        WITH_GALLERY_BUILD=
3040        AC_MSG_RESULT([disable src image build])
3041    fi
3042fi
3043AC_SUBST(WITH_GALLERY_BUILD)
3044
3045dnl ===================================================================
3046dnl  Checks if ccache is available
3047dnl ===================================================================
3048CCACHE_DEPEND_MODE=
3049if test "$enable_ccache" = "no"; then
3050    CCACHE=""
3051elif test "$_os" = "WINNT"; then
3052    # on windows/VC build do not use ccache - but perhaps sccache is around?
3053    case "%$CC%$CXX%" in
3054    # If $CC and/or $CXX already contain "sccache" (possibly suffixed with some version number etc),
3055    # assume that's good then
3056    *%sccache[[-_' ']]*|*/sccache[[-_' ']]*)
3057        AC_MSG_NOTICE([sccache seems to be included in a pre-defined CC and/or CXX])
3058        CCACHE_DEPEND_MODE=1
3059        ;;
3060    *)
3061        # for sharing code below, reuse CCACHE env var
3062        AC_PATH_PROG([CCACHE],[sccache],[not found])
3063        if test "$CCACHE" = "not found"; then
3064            CCACHE=""
3065        else
3066            CCACHE=`win_short_path_for_make "$CCACHE"`
3067            CCACHE_DEPEND_MODE=1
3068        fi
3069        ;;
3070    esac
3071elif test -n "$enable_ccache" -o \( "$enable_ccache" = "" -a "$enable_icecream" != "yes" \); then
3072    case "%$CC%$CXX%" in
3073    # If $CC and/or $CXX already contain "ccache" (possibly suffixed with some version number etc),
3074    # assume that's good then
3075    *%ccache[[-_' ']]*|*/ccache[[-_' ']]*)
3076        AC_MSG_NOTICE([ccache seems to be included in a pre-defined CC and/or CXX])
3077        CCACHE_DEPEND_MODE=1
3078        ;;
3079    *)
3080        AC_PATH_PROG([CCACHE],[ccache],[not found])
3081        if test "$CCACHE" = "not found"; then
3082            CCACHE=""
3083        else
3084            CCACHE_DEPEND_MODE=1
3085            # Need to check for ccache version: otherwise prevents
3086            # caching of the results (like "-x objective-c++" for Mac)
3087            if test $_os = Darwin -o $_os = iOS; then
3088                # Check ccache version
3089                AC_MSG_CHECKING([whether version of ccache is suitable])
3090                CCACHE_VERSION=`"$CCACHE" -V | "$AWK" '/^ccache version/{print $3}'`
3091                CCACHE_NUMVER=`echo $CCACHE_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
3092                if test "$CCACHE_VERSION" = "2.4_OOo" -o "$CCACHE_NUMVER" -ge "030100"; then
3093                    AC_MSG_RESULT([yes, $CCACHE_VERSION])
3094                else
3095                    AC_MSG_RESULT([no, $CCACHE_VERSION])
3096                    CCACHE=""
3097                    CCACHE_DEPEND_MODE=
3098                fi
3099            fi
3100        fi
3101        ;;
3102    esac
3103else
3104    CCACHE=""
3105fi
3106if test "$enable_ccache" = "nodepend"; then
3107    CCACHE_DEPEND_MODE=""
3108fi
3109AC_SUBST(CCACHE_DEPEND_MODE)
3110
3111# skip on windows - sccache defaults are good enough
3112if test "$CCACHE" != "" -a "$_os" != "WINNT"; then
3113    ccache_size_msg=$([ccache -s | tail -n 1 | sed 's/^[^0-9]*//' | sed -e 's/\.[0-9]*//'])
3114    ccache_size=$(echo "$ccache_size_msg" | grep "G" | sed -e 's/G.*$//')
3115    if test "$ccache_size" = ""; then
3116        ccache_size=$(echo "$ccache_size_msg" | grep "M" | sed -e 's/\ M.*$//')
3117        if test "$ccache_size" = ""; then
3118            ccache_size=0
3119        fi
3120        # we could not determine the size or it was less than 1GB -> disable auto-ccache
3121        if test $ccache_size -lt 1024; then
3122            CCACHE=""
3123            AC_MSG_WARN([ccache's cache size is less than 1GB using it is counter-productive: Disabling auto-ccache detection])
3124            add_warning "ccache's cache size is less than 1GB using it is counter-productive: auto-ccache detection disabled"
3125        else
3126            # warn that ccache may be too small for debug build
3127            AC_MSG_WARN([ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build])
3128            add_warning "ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build"
3129        fi
3130    else
3131        if test $ccache_size -lt 5; then
3132            #warn that ccache may be too small for debug build
3133            AC_MSG_WARN([ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build])
3134            add_warning "ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build"
3135        fi
3136    fi
3137fi
3138
3139dnl ===================================================================
3140dnl  Checks for C compiler,
3141dnl  The check for the C++ compiler is later on.
3142dnl ===================================================================
3143if test "$_os" != "WINNT"; then
3144    GCC_HOME_SET="true"
3145    AC_MSG_CHECKING([gcc home])
3146    if test -z "$with_gcc_home"; then
3147        if test "$enable_icecream" = "yes"; then
3148            if test -d "/usr/lib/icecc/bin"; then
3149                GCC_HOME="/usr/lib/icecc/"
3150            elif test -d "/usr/libexec/icecc/bin"; then
3151                GCC_HOME="/usr/libexec/icecc/"
3152            elif test -d "/opt/icecream/bin"; then
3153                GCC_HOME="/opt/icecream/"
3154            else
3155                AC_MSG_ERROR([Could not figure out the location of icecream GCC wrappers, manually use --with-gcc-home])
3156
3157            fi
3158        else
3159            GCC_HOME=`which gcc | $SED -e s,/bin/gcc,,`
3160            GCC_HOME_SET="false"
3161        fi
3162    else
3163        GCC_HOME="$with_gcc_home"
3164    fi
3165    AC_MSG_RESULT($GCC_HOME)
3166    AC_SUBST(GCC_HOME)
3167
3168    if test "$GCC_HOME_SET" = "true"; then
3169        if test -z "$CC"; then
3170            CC="$GCC_HOME/bin/gcc"
3171            CC_BASE="gcc"
3172        fi
3173        if test -z "$CXX"; then
3174            CXX="$GCC_HOME/bin/g++"
3175            CXX_BASE="g++"
3176        fi
3177    fi
3178fi
3179
3180COMPATH=`dirname "$CC"`
3181if test "$COMPATH" = "."; then
3182    AC_PATH_PROGS(COMPATH, $CC)
3183    dnl double square bracket to get single because of M4 quote...
3184    COMPATH=`echo $COMPATH | $SED "s@/[[^/:]]*\\\$@@"`
3185fi
3186COMPATH=`echo $COMPATH | $SED "s@/[[Bb]][[Ii]][[Nn]]\\\$@@"`
3187
3188dnl ===================================================================
3189dnl Java support
3190dnl ===================================================================
3191AC_MSG_CHECKING([whether to build with Java support])
3192if test "$with_java" != "no"; then
3193    if test "$DISABLE_SCRIPTING" = TRUE; then
3194        AC_MSG_RESULT([no, overridden by --disable-scripting])
3195        ENABLE_JAVA=""
3196        with_java=no
3197    else
3198        AC_MSG_RESULT([yes])
3199        ENABLE_JAVA="TRUE"
3200        AC_DEFINE(HAVE_FEATURE_JAVA)
3201    fi
3202else
3203    AC_MSG_RESULT([no])
3204    ENABLE_JAVA=""
3205fi
3206
3207AC_SUBST(ENABLE_JAVA)
3208
3209dnl ENABLE_JAVA="TRUE" if we want there to be *run-time* (and build-time) support for Java
3210
3211dnl ENABLE_JAVA="" indicate no Java support at all
3212
3213dnl ===================================================================
3214dnl Check macOS SDK and compiler
3215dnl ===================================================================
3216
3217if test $_os = Darwin; then
3218
3219    # If no --with-macosx-sdk option is given, look for one
3220
3221    # The intent is that for "most" Mac-based developers, a suitable
3222    # SDK will be found automatically without any configure options.
3223
3224    # For developers with a current Xcode, the lowest-numbered SDK
3225    # higher than or equal to the minimum required should be found.
3226
3227    AC_MSG_CHECKING([what macOS SDK to use])
3228    for _macosx_sdk in ${with_macosx_sdk-12.1 12.0 11.3 11.1 11.0 10.15 10.14 10.13}; do
3229        MACOSX_SDK_PATH=`xcrun --sdk macosx${_macosx_sdk} --show-sdk-path 2> /dev/null`
3230        if test -d "$MACOSX_SDK_PATH"; then
3231            with_macosx_sdk="${_macosx_sdk}"
3232            break
3233        else
3234            MACOSX_SDK_PATH="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${_macosx_sdk}.sdk"
3235            if test -d "$MACOSX_SDK_PATH"; then
3236                with_macosx_sdk="${_macosx_sdk}"
3237                break
3238            fi
3239        fi
3240    done
3241    if test ! -d "$MACOSX_SDK_PATH"; then
3242        AC_MSG_ERROR([Could not find an appropriate macOS SDK])
3243    fi
3244
3245    AC_MSG_RESULT([SDK $with_macosx_sdk at $MACOSX_SDK_PATH])
3246
3247    case $with_macosx_sdk in
3248    10.13)
3249        MACOSX_SDK_VERSION=101300
3250        ;;
3251    10.14)
3252        MACOSX_SDK_VERSION=101400
3253        ;;
3254    10.15)
3255        MACOSX_SDK_VERSION=101500
3256        ;;
3257    11.0)
3258        MACOSX_SDK_VERSION=110000
3259        ;;
3260    11.1)
3261        MACOSX_SDK_VERSION=110100
3262        ;;
3263    11.3)
3264        MACOSX_SDK_VERSION=110300
3265        ;;
3266    12.0)
3267        MACOSX_SDK_VERSION=120000
3268        ;;
3269    12.1)
3270        MACOSX_SDK_VERSION=120100
3271        ;;
3272    *)
3273        AC_MSG_ERROR([with-macosx-sdk $with_macosx_sdk is not a supported value, supported values are 10.13--12.1])
3274        ;;
3275    esac
3276
3277    if test "$host_cpu" = arm64 -a $MACOSX_SDK_VERSION -lt 110000; then
3278        AC_MSG_ERROR([with-macosx-sdk $with_macosx_sdk is not a supported value for Apple Silicon])
3279    fi
3280
3281    if test "$with_macosx_version_min_required" = "" ; then
3282        if test "$host_cpu" = x86_64; then
3283            with_macosx_version_min_required="10.10";
3284        else
3285            with_macosx_version_min_required="11.0";
3286        fi
3287    fi
3288
3289    if test "$with_macosx_version_max_allowed" = "" ; then
3290        with_macosx_version_max_allowed="$with_macosx_sdk"
3291    fi
3292
3293    # export this so that "xcrun" invocations later return matching values
3294    DEVELOPER_DIR="${MACOSX_SDK_PATH%/SDKs*}"
3295    DEVELOPER_DIR="${DEVELOPER_DIR%/Platforms*}"
3296    export DEVELOPER_DIR
3297    FRAMEWORKSHOME="$MACOSX_SDK_PATH/System/Library/Frameworks"
3298    MACOSX_DEPLOYMENT_TARGET="$with_macosx_version_min_required"
3299
3300    AC_MSG_CHECKING([whether Xcode is new enough])
3301    my_xcode_ver1=$(xcrun xcodebuild -version | head -n 1)
3302    my_xcode_ver2=${my_xcode_ver1#Xcode }
3303    my_xcode_ver3=$(printf %s "$my_xcode_ver2" | $AWK -F. '{ print $1*100+($2<100?$2:99) }')
3304    if test "$my_xcode_ver3" -ge 1103; then
3305        AC_MSG_RESULT([yes ($my_xcode_ver2)])
3306    else
3307        AC_MSG_ERROR(["$my_xcode_ver1" is too old or unrecognized, must be at least Xcode 11.3])
3308    fi
3309
3310    case "$with_macosx_version_min_required" in
3311    10.10)
3312        MAC_OS_X_VERSION_MIN_REQUIRED="101000"
3313        ;;
3314    10.11)
3315        MAC_OS_X_VERSION_MIN_REQUIRED="101100"
3316        ;;
3317    10.12)
3318        MAC_OS_X_VERSION_MIN_REQUIRED="101200"
3319        ;;
3320    10.13)
3321        MAC_OS_X_VERSION_MIN_REQUIRED="101300"
3322        ;;
3323    10.14)
3324        MAC_OS_X_VERSION_MIN_REQUIRED="101400"
3325        ;;
3326    10.15)
3327        MAC_OS_X_VERSION_MIN_REQUIRED="101500"
3328        ;;
3329    10.16)
3330        MAC_OS_X_VERSION_MIN_REQUIRED="101600"
3331        ;;
3332    11.0)
3333        MAC_OS_X_VERSION_MIN_REQUIRED="110000"
3334        ;;
3335    11.1)
3336        MAC_OS_X_VERSION_MIN_REQUIRED="110100"
3337        ;;
3338    11.3)
3339        MAC_OS_X_VERSION_MIN_REQUIRED="110300"
3340        ;;
3341    12.0)
3342        MAC_OS_X_VERSION_MIN_REQUIRED="120000"
3343        ;;
3344    12.1)
3345        MAC_OS_X_VERSION_MIN_REQUIRED="120100"
3346        ;;
3347    *)
3348        AC_MSG_ERROR([with-macosx-version-min-required $with_macosx_version_min_required is not a supported value, supported values are 10.10--12.1])
3349        ;;
3350    esac
3351
3352    LIBTOOL=/usr/bin/libtool
3353    INSTALL_NAME_TOOL=install_name_tool
3354    if test -z "$save_CC"; then
3355        stdlib=-stdlib=libc++
3356
3357        AC_MSG_CHECKING([what C compiler to use])
3358        CC="`xcrun -find clang`"
3359        CC_BASE=`first_arg_basename "$CC"`
3360        if test "$host_cpu" = x86_64; then
3361            CC+=" -target x86_64-apple-macos"
3362        else
3363            CC+=" -target arm64-apple-macos"
3364        fi
3365        CC+=" -mmacosx-version-min=$with_macosx_version_min_required -isysroot $MACOSX_SDK_PATH"
3366        AC_MSG_RESULT([$CC])
3367
3368        AC_MSG_CHECKING([what C++ compiler to use])
3369        CXX="`xcrun -find clang++`"
3370        CXX_BASE=`first_arg_basename "$CXX"`
3371        if test "$host_cpu" = x86_64; then
3372            CXX+=" -target x86_64-apple-macos"
3373        else
3374            CXX+=" -target arm64-apple-macos"
3375        fi
3376        CXX+=" $stdlib -mmacosx-version-min=$with_macosx_version_min_required -isysroot $MACOSX_SDK_PATH"
3377        AC_MSG_RESULT([$CXX])
3378
3379        INSTALL_NAME_TOOL=`xcrun -find install_name_tool`
3380        AR=`xcrun -find ar`
3381        NM=`xcrun -find nm`
3382        STRIP=`xcrun -find strip`
3383        LIBTOOL=`xcrun -find libtool`
3384        RANLIB=`xcrun -find ranlib`
3385    fi
3386
3387    case "$with_macosx_version_max_allowed" in
3388    10.10)
3389        MAC_OS_X_VERSION_MAX_ALLOWED="101000"
3390        ;;
3391    10.11)
3392        MAC_OS_X_VERSION_MAX_ALLOWED="101100"
3393        ;;
3394    10.12)
3395        MAC_OS_X_VERSION_MAX_ALLOWED="101200"
3396        ;;
3397    10.13)
3398        MAC_OS_X_VERSION_MAX_ALLOWED="101300"
3399        ;;
3400    10.14)
3401        MAC_OS_X_VERSION_MAX_ALLOWED="101400"
3402        ;;
3403    10.15)
3404        MAC_OS_X_VERSION_MAX_ALLOWED="101500"
3405        ;;
3406    11.0)
3407        MAC_OS_X_VERSION_MAX_ALLOWED="110000"
3408        ;;
3409    11.1)
3410        MAC_OS_X_VERSION_MAX_ALLOWED="110100"
3411        ;;
3412    11.3)
3413        MAC_OS_X_VERSION_MAX_ALLOWED="110300"
3414        ;;
3415    12.0)
3416        MAC_OS_X_VERSION_MAX_ALLOWED="120000"
3417        ;;
3418    12.1)
3419        MAC_OS_X_VERSION_MAX_ALLOWED="120100"
3420        ;;
3421    *)
3422        AC_MSG_ERROR([with-macosx-version-max-allowed $with_macosx_version_max_allowed is not a supported value, supported values are 10.10--12.1])
3423        ;;
3424    esac
3425
3426    AC_MSG_CHECKING([that macosx-version-min-required is coherent with macosx-version-max-allowed])
3427    if test $MAC_OS_X_VERSION_MIN_REQUIRED -gt $MAC_OS_X_VERSION_MAX_ALLOWED; then
3428        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])
3429    else
3430        AC_MSG_RESULT([ok])
3431    fi
3432
3433    AC_MSG_CHECKING([that macosx-version-max-allowed is coherent with macos-with-sdk])
3434    if test $MAC_OS_X_VERSION_MAX_ALLOWED -gt $MACOSX_SDK_VERSION; then
3435        AC_MSG_ERROR([the version maximum allowed cannot be greater than the sdk level])
3436    else
3437        AC_MSG_RESULT([ok])
3438    fi
3439    AC_MSG_NOTICE([MAC_OS_X_VERSION_MIN_REQUIRED=$MAC_OS_X_VERSION_MIN_REQUIRED])
3440    AC_MSG_NOTICE([MAC_OS_X_VERSION_MAX_ALLOWED=$MAC_OS_X_VERSION_MAX_ALLOWED])
3441
3442    AC_MSG_CHECKING([whether to do code signing])
3443
3444    if test "$enable_macosx_code_signing" = yes; then
3445        # By default use the first suitable certificate (?).
3446
3447        # http://stackoverflow.com/questions/13196291/difference-between-mac-developer-and-3rd-party-mac-developer-application
3448        # says that the "Mac Developer" certificate is useful just for self-testing. For distribution
3449        # outside the Mac App Store, use the "Developer ID Application" one, and for distribution in
3450        # the App Store, the "3rd Party Mac Developer" one. I think it works best to the
3451        # "Developer ID Application" one.
3452
3453        identity=`security find-identity -p codesigning -v 2>/dev/null | grep 'Developer ID Application:' | $AWK '{print $2}' |head -1`
3454        if test -n "$identity"; then
3455            MACOSX_CODESIGNING_IDENTITY=$identity
3456            pretty_name=`security find-identity -p codesigning -v | grep "$MACOSX_CODESIGNING_IDENTITY" | sed -e 's/^[[^"]]*"//' -e 's/"//'`
3457            AC_MSG_RESULT([yes, using the identity $MACOSX_CODESIGNING_IDENTITY for $pretty_name])
3458        else
3459            AC_MSG_ERROR([cannot determine identity to use])
3460        fi
3461    elif test -n "$enable_macosx_code_signing" -a "$enable_macosx_code_signing" != no ; then
3462        MACOSX_CODESIGNING_IDENTITY=$enable_macosx_code_signing
3463        pretty_name=`security find-identity -p codesigning -v | grep "$MACOSX_CODESIGNING_IDENTITY" | sed -e 's/^[[^"]]*"//' -e 's/"//'`
3464        AC_MSG_RESULT([yes, using the identity $MACOSX_CODESIGNING_IDENTITY for $pretty_name])
3465    else
3466        AC_MSG_RESULT([no])
3467    fi
3468
3469    AC_MSG_CHECKING([whether to create a Mac App Store package])
3470
3471    if test -z "$enable_macosx_package_signing" || test "$enable_macosx_package_signing" == no; then
3472        AC_MSG_RESULT([no])
3473    elif test -z "$MACOSX_CODESIGNING_IDENTITY"; then
3474        AC_MSG_ERROR([You forgot --enable-macosx-code-signing])
3475    elif test "$enable_macosx_package_signing" = yes; then
3476        # By default use the first suitable certificate.
3477        # It should be a "3rd Party Mac Developer Installer" one
3478
3479        identity=`security find-identity -v 2>/dev/null | grep '3rd Party Mac Developer Installer:' | awk '{print $2}' |head -1`
3480        if test -n "$identity"; then
3481            MACOSX_PACKAGE_SIGNING_IDENTITY=$identity
3482            pretty_name=`security find-identity -v | grep "$MACOSX_PACKAGE_SIGNING_IDENTITY" | sed -e 's/^[[^"]]*"//' -e 's/"//'`
3483            AC_MSG_RESULT([yes, using the identity $MACOSX_PACKAGE_SIGNING_IDENTITY for $pretty_name])
3484        else
3485            AC_MSG_ERROR([Could not find any suitable '3rd Party Mac Developer Installer' certificate])
3486        fi
3487    else
3488        MACOSX_PACKAGE_SIGNING_IDENTITY=$enable_macosx_package_signing
3489        pretty_name=`security find-identity -v | grep "$MACOSX_PACKAGE_SIGNING_IDENTITY" | sed -e 's/^[[^"]]*"//' -e 's/"//'`
3490        AC_MSG_RESULT([yes, using the identity $MACOSX_PACKAGE_SIGNING_IDENTITY for $pretty_name])
3491    fi
3492
3493    if test -n "$MACOSX_CODESIGNING_IDENTITY" -a -n "$MACOSX_PACKAGE_SIGNING_IDENTITY" -a "$MACOSX_CODESIGNING_IDENTITY" = "$MACOSX_PACKAGE_SIGNING_IDENTITY"; then
3494        AC_MSG_ERROR([You should not use the same identity for code and package signing])
3495    fi
3496
3497    AC_MSG_CHECKING([whether to sandbox the application])
3498
3499    if test -n "$ENABLE_JAVA" -a "$enable_macosx_sandbox" = yes; then
3500        AC_MSG_ERROR([macOS sandboxing (actually App Store rules) disallows use of Java])
3501    elif test "$enable_macosx_sandbox" = yes; then
3502        ENABLE_MACOSX_SANDBOX=TRUE
3503        AC_DEFINE(HAVE_FEATURE_MACOSX_SANDBOX)
3504        AC_MSG_RESULT([yes])
3505    else
3506        AC_MSG_RESULT([no])
3507    fi
3508
3509    AC_MSG_CHECKING([what macOS app bundle identifier to use])
3510    MACOSX_BUNDLE_IDENTIFIER=$with_macosx_bundle_identifier
3511    AC_MSG_RESULT([$MACOSX_BUNDLE_IDENTIFIER])
3512fi
3513AC_SUBST(MACOSX_SDK_PATH)
3514AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
3515AC_SUBST(MAC_OS_X_VERSION_MIN_REQUIRED)
3516AC_SUBST(MAC_OS_X_VERSION_MAX_ALLOWED)
3517AC_SUBST(INSTALL_NAME_TOOL)
3518AC_SUBST(LIBTOOL) # Note that the macOS libtool command is unrelated to GNU libtool
3519AC_SUBST(MACOSX_CODESIGNING_IDENTITY)
3520AC_SUBST(MACOSX_PACKAGE_SIGNING_IDENTITY)
3521AC_SUBST(ENABLE_MACOSX_SANDBOX)
3522AC_SUBST(MACOSX_BUNDLE_IDENTIFIER)
3523
3524dnl ===================================================================
3525dnl Check iOS SDK and compiler
3526dnl ===================================================================
3527
3528if test $_os = iOS; then
3529    AC_MSG_CHECKING([what iOS SDK to use])
3530    current_sdk_ver=14.5
3531    older_sdk_vers="14.4 14.3 14.2 14.1 14.0 13.7"
3532    if test "$enable_ios_simulator" = "yes"; then
3533        platform=iPhoneSimulator
3534        versionmin=-mios-simulator-version-min=12.2
3535    else
3536        platform=iPhoneOS
3537        versionmin=-miphoneos-version-min=12.2
3538    fi
3539    xcode_developer=`xcode-select -print-path`
3540
3541    for sdkver in $current_sdk_ver $older_sdk_vers; do
3542        t=$xcode_developer/Platforms/$platform.platform/Developer/SDKs/$platform$sdkver.sdk
3543        if test -d $t; then
3544            sysroot=$t
3545            break
3546        fi
3547    done
3548
3549    if test -z "$sysroot"; then
3550        AC_MSG_ERROR([Could not find iOS SDK, expected something like $xcode_developer/Platforms/$platform.platform/Developer/SDKs/${platform}${current_sdk_ver}.sdk])
3551    fi
3552
3553    AC_MSG_RESULT($sysroot)
3554
3555    stdlib="-stdlib=libc++"
3556
3557    AC_MSG_CHECKING([what C compiler to use])
3558    CC="`xcrun -find clang`"
3559    CC_BASE=`first_arg_basename "$CC"`
3560    CC+=" -arch $host_cpu_for_clang -isysroot $sysroot $versionmin"
3561    AC_MSG_RESULT([$CC])
3562
3563    AC_MSG_CHECKING([what C++ compiler to use])
3564    CXX="`xcrun -find clang++`"
3565    CXX_BASE=`first_arg_basename "$CXX"`
3566    CXX+=" -arch $host_cpu_for_clang $stdlib -isysroot $sysroot $versionmin"
3567    AC_MSG_RESULT([$CXX])
3568
3569    INSTALL_NAME_TOOL=`xcrun -find install_name_tool`
3570    AR=`xcrun -find ar`
3571    NM=`xcrun -find nm`
3572    STRIP=`xcrun -find strip`
3573    LIBTOOL=`xcrun -find libtool`
3574    RANLIB=`xcrun -find ranlib`
3575fi
3576
3577AC_MSG_CHECKING([whether to treat the installation as read-only])
3578
3579if test $_os = Darwin; then
3580    enable_readonly_installset=yes
3581elif test "$enable_extensions" != yes; then
3582    enable_readonly_installset=yes
3583fi
3584if test "$enable_readonly_installset" = yes; then
3585    AC_MSG_RESULT([yes])
3586    AC_DEFINE(HAVE_FEATURE_READONLY_INSTALLSET)
3587else
3588    AC_MSG_RESULT([no])
3589fi
3590
3591dnl ===================================================================
3592dnl Structure of install set
3593dnl ===================================================================
3594
3595if test $_os = Darwin; then
3596    LIBO_BIN_FOLDER=MacOS
3597    LIBO_ETC_FOLDER=Resources
3598    LIBO_LIBEXEC_FOLDER=MacOS
3599    LIBO_LIB_FOLDER=Frameworks
3600    LIBO_LIB_PYUNO_FOLDER=Resources
3601    LIBO_SHARE_FOLDER=Resources
3602    LIBO_SHARE_HELP_FOLDER=Resources/help
3603    LIBO_SHARE_JAVA_FOLDER=Resources/java
3604    LIBO_SHARE_PRESETS_FOLDER=Resources/presets
3605    LIBO_SHARE_READMES_FOLDER=Resources/readmes
3606    LIBO_SHARE_RESOURCE_FOLDER=Resources/resource
3607    LIBO_SHARE_SHELL_FOLDER=Resources/shell
3608    LIBO_URE_BIN_FOLDER=MacOS
3609    LIBO_URE_ETC_FOLDER=Resources/ure/etc
3610    LIBO_URE_LIB_FOLDER=Frameworks
3611    LIBO_URE_MISC_FOLDER=Resources/ure/share/misc
3612    LIBO_URE_SHARE_JAVA_FOLDER=Resources/java
3613elif test $_os = WINNT; then
3614    LIBO_BIN_FOLDER=program
3615    LIBO_ETC_FOLDER=program
3616    LIBO_LIBEXEC_FOLDER=program
3617    LIBO_LIB_FOLDER=program
3618    LIBO_LIB_PYUNO_FOLDER=program
3619    LIBO_SHARE_FOLDER=share
3620    LIBO_SHARE_HELP_FOLDER=help
3621    LIBO_SHARE_JAVA_FOLDER=program/classes
3622    LIBO_SHARE_PRESETS_FOLDER=presets
3623    LIBO_SHARE_READMES_FOLDER=readmes
3624    LIBO_SHARE_RESOURCE_FOLDER=program/resource
3625    LIBO_SHARE_SHELL_FOLDER=program/shell
3626    LIBO_URE_BIN_FOLDER=program
3627    LIBO_URE_ETC_FOLDER=program
3628    LIBO_URE_LIB_FOLDER=program
3629    LIBO_URE_MISC_FOLDER=program
3630    LIBO_URE_SHARE_JAVA_FOLDER=program/classes
3631else
3632    LIBO_BIN_FOLDER=program
3633    LIBO_ETC_FOLDER=program
3634    LIBO_LIBEXEC_FOLDER=program
3635    LIBO_LIB_FOLDER=program
3636    LIBO_LIB_PYUNO_FOLDER=program
3637    LIBO_SHARE_FOLDER=share
3638    LIBO_SHARE_HELP_FOLDER=help
3639    LIBO_SHARE_JAVA_FOLDER=program/classes
3640    LIBO_SHARE_PRESETS_FOLDER=presets
3641    LIBO_SHARE_READMES_FOLDER=readmes
3642    if test "$enable_fuzzers" != yes; then
3643        LIBO_SHARE_RESOURCE_FOLDER=program/resource
3644    else
3645        LIBO_SHARE_RESOURCE_FOLDER=resource
3646    fi
3647    LIBO_SHARE_SHELL_FOLDER=program/shell
3648    LIBO_URE_BIN_FOLDER=program
3649    LIBO_URE_ETC_FOLDER=program
3650    LIBO_URE_LIB_FOLDER=program
3651    LIBO_URE_MISC_FOLDER=program
3652    LIBO_URE_SHARE_JAVA_FOLDER=program/classes
3653fi
3654AC_DEFINE_UNQUOTED(LIBO_BIN_FOLDER,"$LIBO_BIN_FOLDER")
3655AC_DEFINE_UNQUOTED(LIBO_ETC_FOLDER,"$LIBO_ETC_FOLDER")
3656AC_DEFINE_UNQUOTED(LIBO_LIBEXEC_FOLDER,"$LIBO_LIBEXEC_FOLDER")
3657AC_DEFINE_UNQUOTED(LIBO_LIB_FOLDER,"$LIBO_LIB_FOLDER")
3658AC_DEFINE_UNQUOTED(LIBO_LIB_PYUNO_FOLDER,"$LIBO_LIB_PYUNO_FOLDER")
3659AC_DEFINE_UNQUOTED(LIBO_SHARE_FOLDER,"$LIBO_SHARE_FOLDER")
3660AC_DEFINE_UNQUOTED(LIBO_SHARE_HELP_FOLDER,"$LIBO_SHARE_HELP_FOLDER")
3661AC_DEFINE_UNQUOTED(LIBO_SHARE_JAVA_FOLDER,"$LIBO_SHARE_JAVA_FOLDER")
3662AC_DEFINE_UNQUOTED(LIBO_SHARE_PRESETS_FOLDER,"$LIBO_SHARE_PRESETS_FOLDER")
3663AC_DEFINE_UNQUOTED(LIBO_SHARE_RESOURCE_FOLDER,"$LIBO_SHARE_RESOURCE_FOLDER")
3664AC_DEFINE_UNQUOTED(LIBO_SHARE_SHELL_FOLDER,"$LIBO_SHARE_SHELL_FOLDER")
3665AC_DEFINE_UNQUOTED(LIBO_URE_BIN_FOLDER,"$LIBO_URE_BIN_FOLDER")
3666AC_DEFINE_UNQUOTED(LIBO_URE_ETC_FOLDER,"$LIBO_URE_ETC_FOLDER")
3667AC_DEFINE_UNQUOTED(LIBO_URE_LIB_FOLDER,"$LIBO_URE_LIB_FOLDER")
3668AC_DEFINE_UNQUOTED(LIBO_URE_MISC_FOLDER,"$LIBO_URE_MISC_FOLDER")
3669AC_DEFINE_UNQUOTED(LIBO_URE_SHARE_JAVA_FOLDER,"$LIBO_URE_SHARE_JAVA_FOLDER")
3670
3671# Not all of them needed in config_host.mk, add more if need arises
3672AC_SUBST(LIBO_BIN_FOLDER)
3673AC_SUBST(LIBO_ETC_FOLDER)
3674AC_SUBST(LIBO_LIB_FOLDER)
3675AC_SUBST(LIBO_LIB_PYUNO_FOLDER)
3676AC_SUBST(LIBO_SHARE_FOLDER)
3677AC_SUBST(LIBO_SHARE_HELP_FOLDER)
3678AC_SUBST(LIBO_SHARE_JAVA_FOLDER)
3679AC_SUBST(LIBO_SHARE_PRESETS_FOLDER)
3680AC_SUBST(LIBO_SHARE_READMES_FOLDER)
3681AC_SUBST(LIBO_SHARE_RESOURCE_FOLDER)
3682AC_SUBST(LIBO_URE_BIN_FOLDER)
3683AC_SUBST(LIBO_URE_ETC_FOLDER)
3684AC_SUBST(LIBO_URE_LIB_FOLDER)
3685AC_SUBST(LIBO_URE_MISC_FOLDER)
3686AC_SUBST(LIBO_URE_SHARE_JAVA_FOLDER)
3687
3688dnl ===================================================================
3689dnl Windows specific tests and stuff
3690dnl ===================================================================
3691
3692reg_get_value()
3693{
3694    # Return value: $regvalue
3695    unset regvalue
3696
3697    if test "$build_os" = "wsl"; then
3698        regvalue=$($BUILDDIR/solenv/wsl/wsl-lo-helper.exe --read-registry $1 "$2" 2>/dev/null)
3699        return
3700    fi
3701
3702    local _regentry="/proc/registry${1}/${2}"
3703    if test -f "$_regentry"; then
3704        # Stop bash complaining about \0 bytes in input, as it can't handle them.
3705        # Registry keys read via /proc/registry* are always \0 terminated!
3706        local _regvalue=$(tr -d '\0' < "$_regentry")
3707        if test $? -eq 0; then
3708            regvalue=$_regvalue
3709        fi
3710    fi
3711}
3712
3713# Get a value from the 32-bit side of the Registry
3714reg_get_value_32()
3715{
3716    reg_get_value "32" "$1"
3717}
3718
3719# Get a value from the 64-bit side of the Registry
3720reg_get_value_64()
3721{
3722    reg_get_value "64" "$1"
3723}
3724
3725case "$host_os" in
3726cygwin*|wsl*)
3727    COM=MSC
3728    OS=WNT
3729    RTL_OS=Windows
3730    if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
3731        P_SEP=";"
3732    else
3733        P_SEP=:
3734    fi
3735    case "$host_cpu" in
3736    x86_64)
3737        CPUNAME=X86_64
3738        RTL_ARCH=X86_64
3739        PLATFORMID=windows_x86_64
3740        WINDOWS_X64=1
3741        SCPDEFS="$SCPDEFS -DWINDOWS_X64"
3742        WIN_HOST_ARCH="x64"
3743        WIN_MULTI_ARCH="x86"
3744        WIN_HOST_BITS=64
3745        ;;
3746    i*86)
3747        CPUNAME=INTEL
3748        RTL_ARCH=x86
3749        PLATFORMID=windows_x86
3750        WIN_HOST_ARCH="x86"
3751        WIN_HOST_BITS=32
3752        WIN_OTHER_ARCH="x64"
3753        ;;
3754    aarch64)
3755        CPUNAME=AARCH64
3756        RTL_ARCH=AARCH64
3757        PLATFORMID=windows_aarch64
3758        WINDOWS_X64=1
3759        SCPDEFS="$SCPDEFS -DWINDOWS_AARCH64"
3760        WIN_HOST_ARCH="arm64"
3761        WIN_HOST_BITS=64
3762        with_ucrt_dir=no
3763        ;;
3764    *)
3765        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
3766        ;;
3767    esac
3768
3769    case "$build_cpu" in
3770    x86_64) WIN_BUILD_ARCH="x64" ;;
3771    i*86) WIN_BUILD_ARCH="x86" ;;
3772    aarch64) WIN_BUILD_ARCH="arm64" ;;
3773    *)
3774        AC_MSG_ERROR([Unsupported build_cpu $build_cpu for host_os $host_os])
3775        ;;
3776    esac
3777
3778    SCPDEFS="$SCPDEFS -D_MSC_VER"
3779    ;;
3780esac
3781
3782# multi-arch is an arch, which can execute on the host (x86 on x64), while
3783# other-arch won't, but wouldn't break the build (x64 on x86).
3784if test -n "$WIN_MULTI_ARCH" -a -n "$WIN_OTHER_ARCH"; then
3785    AC_MSG_ERROR([Broken configure.ac file: can't have set \$WIN_MULTI_ARCH and $WIN_OTHER_ARCH])
3786fi
3787
3788
3789if test "$_os" = "iOS" -o "$build_cpu" != "$host_cpu"; then
3790    # To allow building Windows multi-arch releases without cross-tooling
3791    if test -z "$WIN_MULTI_ARCH" -a -z "$WIN_OTHER_ARCH"; then
3792        cross_compiling="yes"
3793    fi
3794fi
3795
3796ENABLE_WASM_STRIP=''
3797if test "$cross_compiling" = "yes"; then
3798    export CROSS_COMPILING=TRUE
3799    if test "$enable_dynamic_loading" != yes -a "$enable_wasm_strip" = yes; then
3800        ENABLE_WASM_STRIP=TRUE
3801    fi
3802else
3803    CROSS_COMPILING=
3804    BUILD_TYPE="$BUILD_TYPE NATIVE"
3805fi
3806AC_SUBST(CROSS_COMPILING)
3807AC_SUBST(ENABLE_WASM_STRIP)
3808
3809# Use -isystem (gcc) if possible, to avoid warnings in 3rd party headers.
3810# NOTE: must _not_ be used for bundled external libraries!
3811ISYSTEM=
3812if test "$GCC" = "yes"; then
3813    AC_MSG_CHECKING( for -isystem )
3814    save_CFLAGS=$CFLAGS
3815    CFLAGS="$CFLAGS -Werror"
3816    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ ISYSTEM="-isystem " ],[])
3817    CFLAGS=$save_CFLAGS
3818    if test -n "$ISYSTEM"; then
3819        AC_MSG_RESULT(yes)
3820    else
3821        AC_MSG_RESULT(no)
3822    fi
3823fi
3824if test -z "$ISYSTEM"; then
3825    # fall back to using -I
3826    ISYSTEM=-I
3827fi
3828AC_SUBST(ISYSTEM)
3829
3830dnl ===================================================================
3831dnl  Check which Visual Studio compiler is used
3832dnl ===================================================================
3833
3834map_vs_year_to_version()
3835{
3836    # Return value: $vsversion
3837
3838    unset vsversion
3839
3840    case $1 in
3841    2019)
3842        vsversion=16;;
3843    *)
3844        AC_MSG_ERROR([Assertion failure - invalid argument "$1" to map_vs_year_to_version()]);;
3845    esac
3846}
3847
3848vs_versions_to_check()
3849{
3850    # Args: $1 (optional) : versions to check, in the order of preference
3851    # Return value: $vsversions
3852
3853    unset vsversions
3854
3855    if test -n "$1"; then
3856        map_vs_year_to_version "$1"
3857        vsversions=$vsversion
3858    else
3859        # We accept only 2019
3860        vsversions="16"
3861    fi
3862}
3863
3864win_get_env_from_vsvars32bat()
3865{
3866    local WRAPPERBATCHFILEPATH="`mktemp -t wrpXXXXXX.bat`"
3867    # Also seems to be located in another directory under the same name: vsvars32.bat
3868    # https://github.com/bazelbuild/bazel/blob/master/src/main/native/build_windows_jni.sh#L56-L57
3869    printf '@call "%s/../Common7/Tools/VsDevCmd.bat" /no_logo\r\n' "$(cygpath -w $VC_PRODUCT_DIR)" > $WRAPPERBATCHFILEPATH
3870    # use 'echo.%ENV%' syntax (instead of 'echo %ENV%') to avoid outputting "ECHO is off." in case when ENV is empty or a space
3871    printf '@setlocal\r\n@echo.%%%s%%\r\n@endlocal\r\n' "$1" >> $WRAPPERBATCHFILEPATH
3872    local result
3873    if test "$build_os" = "wsl"; then
3874        result=$(cd /mnt/c && cmd.exe /c $(wslpath -w $WRAPPERBATCHFILEPATH) | tr -d '\r')
3875    else
3876        chmod +x $WRAPPERBATCHFILEPATH
3877        result=$("$WRAPPERBATCHFILEPATH" | tr -d '\r')
3878    fi
3879    rm -f $WRAPPERBATCHFILEPATH
3880    printf '%s' "$result"
3881}
3882
3883find_ucrt()
3884{
3885    reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v10.0/InstallationFolder"
3886    if test -n "$regvalue"; then
3887        PathFormat "$regvalue"
3888        UCRTSDKDIR=$formatted_path_unix
3889        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v10.0/ProductVersion"
3890        UCRTVERSION=$regvalue
3891        # Rest if not exist
3892        if ! test -d "${UCRTSDKDIR}Include/$UCRTVERSION/ucrt"; then
3893          UCRTSDKDIR=
3894        fi
3895    fi
3896    if test -z "$UCRTSDKDIR"; then
3897        ide_env_dir="$VC_PRODUCT_DIR/../Common7/Tools/"
3898        ide_env_file="${ide_env_dir}VsDevCmd.bat"
3899        if test -f "$ide_env_file"; then
3900            PathFormat "$(win_get_env_from_vsvars32bat UniversalCRTSdkDir)"
3901            UCRTSDKDIR=$formatted_path
3902            UCRTVERSION=$(win_get_env_from_vsvars32bat UCRTVersion)
3903            dnl Hack needed at least by tml:
3904            if test "$UCRTVERSION" = 10.0.15063.0 \
3905                -a ! -f "${UCRTSDKDIR}Include/10.0.15063.0/um/sqlext.h" \
3906                -a -f "${UCRTSDKDIR}Include/10.0.14393.0/um/sqlext.h"
3907            then
3908                UCRTVERSION=10.0.14393.0
3909            fi
3910        else
3911          AC_MSG_ERROR([No UCRT found])
3912        fi
3913    fi
3914}
3915
3916find_msvc()
3917{
3918    # Find Visual C++ 2019
3919    # Args: $1 (optional) : The VS version year
3920    # Return values: $vctest, $vcyear, $vcnum, $vcnumwithdot, $vcbuildnumber
3921
3922    unset vctest vcnum vcnumwithdot vcbuildnumber
3923
3924    vs_versions_to_check "$1"
3925    if test "$build_os" = wsl; then
3926        vswhere="$PROGRAMFILESX86"
3927    else
3928        vswhere="$(perl -e 'print $ENV{"ProgramFiles(x86)"}')"
3929    fi
3930    vswhere+="\\Microsoft Visual Studio\\Installer\\vswhere.exe"
3931    PathFormat "$vswhere"
3932    vswhere=$formatted_path_unix
3933    for ver in $vsversions; do
3934        vswhereoutput=`$vswhere -version "@<:@ $ver , $(expr $ver + 1) @:}@" -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | head -1`
3935        # Fall back to all MS products (this includes VC++ Build Tools)
3936        if ! test -n "$vswhereoutput"; then
3937            AC_MSG_CHECKING([VC++ Build Tools and similar])
3938            vswhereoutput=`$vswhere -products \* -version "@<:@ $ver , $(expr $ver + 1) @:}@" -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | head -1`
3939        fi
3940        if test -n "$vswhereoutput"; then
3941            PathFormat "$vswhereoutput"
3942            vctest=$formatted_path_unix
3943            break
3944        fi
3945    done
3946
3947    if test -n "$vctest"; then
3948        vcnumwithdot="$ver.0"
3949        case "$vcnumwithdot" in
3950        16.0)
3951            vcyear=2019
3952            vcnum=160
3953            ;;
3954        esac
3955        vcbuildnumber=`ls $vctest/VC/Tools/MSVC -A1r | head -1`
3956
3957    fi
3958}
3959
3960test_cl_exe()
3961{
3962    AC_MSG_CHECKING([$1 compiler])
3963
3964    CL_EXE_PATH="$2/cl.exe"
3965
3966    if test ! -f "$CL_EXE_PATH"; then
3967        if test "$1" = "multi-arch"; then
3968            AC_MSG_WARN([no compiler (cl.exe) in $2])
3969            return 1
3970        else
3971            AC_MSG_ERROR([no compiler (cl.exe) in $2])
3972        fi
3973    fi
3974
3975    dnl ===========================================================
3976    dnl  Check for the corresponding mspdb*.dll
3977    dnl ===========================================================
3978
3979    # MSVC 15.0 has libraries from 14.0?
3980    mspdbnum="140"
3981
3982    if test ! -e "$2/mspdb${mspdbnum}.dll"; then
3983        AC_MSG_ERROR([No mspdb${mspdbnum}.dll in $2, Visual Studio installation broken?])
3984    fi
3985
3986    # The compiles has to find its shared libraries
3987    OLD_PATH="$PATH"
3988    TEMP_PATH=`cygpath -d "$2"`
3989    PATH="`cygpath -u "$TEMP_PATH"`:$PATH"
3990
3991    if ! "$CL_EXE_PATH" -? </dev/null >/dev/null 2>&1; then
3992        AC_MSG_ERROR([no compiler (cl.exe) in $2])
3993    fi
3994
3995    PATH="$OLD_PATH"
3996
3997    AC_MSG_RESULT([$CL_EXE_PATH])
3998}
3999
4000SOLARINC=
4001MSBUILD_PATH=
4002DEVENV=
4003if test "$_os" = "WINNT"; then
4004    AC_MSG_CHECKING([Visual C++])
4005    find_msvc "$with_visual_studio"
4006    if test -z "$vctest"; then
4007        if test -n "$with_visual_studio"; then
4008            AC_MSG_ERROR([no Visual Studio $with_visual_studio installation found])
4009        else
4010            AC_MSG_ERROR([no Visual Studio 2019 installation found])
4011        fi
4012    fi
4013    AC_MSG_RESULT([])
4014
4015    VC_PRODUCT_DIR="$vctest/VC"
4016    COMPATH="$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber"
4017
4018    # $WIN_OTHER_ARCH is a hack to test the x64 compiler on x86, even if it's not multi-arch
4019    if test -n "$WIN_MULTI_ARCH" -o -n "$WIN_OTHER_ARCH"; then
4020        MSVC_MULTI_PATH="$COMPATH/bin/Host$WIN_BUILD_ARCH/${WIN_MULTI_ARCH}${WIN_OTHER_ARCH}"
4021        test_cl_exe "multi-arch" "$MSVC_MULTI_PATH"
4022        if test $? -ne 0; then
4023            WIN_MULTI_ARCH=""
4024            WIN_OTHER_ARCH=""
4025        fi
4026    fi
4027
4028    if test "$WIN_BUILD_ARCH" = "$WIN_HOST_ARCH"; then
4029        MSVC_BUILD_PATH="$COMPATH/bin/Host$WIN_BUILD_ARCH/$WIN_BUILD_ARCH"
4030        test_cl_exe "build" "$MSVC_BUILD_PATH"
4031    fi
4032
4033    if test "$WIN_BUILD_ARCH" != "$WIN_HOST_ARCH"; then
4034        MSVC_HOST_PATH="$COMPATH/bin/Host$WIN_BUILD_ARCH/$WIN_HOST_ARCH"
4035        test_cl_exe "host" "$MSVC_HOST_PATH"
4036    else
4037        MSVC_HOST_PATH="$MSVC_BUILD_PATH"
4038    fi
4039
4040    AC_MSG_CHECKING([for short pathname of VC product directory])
4041    VC_PRODUCT_DIR=`win_short_path_for_make "$VC_PRODUCT_DIR"`
4042    AC_MSG_RESULT([$VC_PRODUCT_DIR])
4043
4044    UCRTSDKDIR=
4045    UCRTVERSION=
4046
4047    AC_MSG_CHECKING([for UCRT location])
4048    find_ucrt
4049    # find_ucrt errors out if it doesn't find it
4050    AC_MSG_RESULT([$UCRTSDKDIR ($UCRTVERSION)])
4051    PathFormat "${UCRTSDKDIR}Include/$UCRTVERSION/ucrt"
4052    ucrtincpath_formatted=$formatted_path
4053    # SOLARINC is used for external modules and must be set too.
4054    # And no, it's not sufficient to set SOLARINC only, as configure
4055    # itself doesn't honour it.
4056    SOLARINC="$SOLARINC -I$ucrtincpath_formatted"
4057    CFLAGS="$CFLAGS -I$ucrtincpath_formatted"
4058    CXXFLAGS="$CXXFLAGS -I$ucrtincpath_formatted"
4059    CPPFLAGS="$CPPFLAGS -I$ucrtincpath_formatted"
4060
4061    AC_SUBST(UCRTSDKDIR)
4062    AC_SUBST(UCRTVERSION)
4063
4064    AC_MSG_CHECKING([for MSBuild.exe location for: $vcnumwithdot])
4065    # Find the proper version of MSBuild.exe to use based on the VS version
4066    reg_get_value_32 HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MSBuild/$vcnumwithdot/MSBuildOverrideTasksPath
4067    if test -n "$regvalue" ; then
4068        AC_MSG_RESULT([found: $regvalue])
4069        MSBUILD_PATH=`win_short_path_for_make "$regvalue"`
4070    else
4071        if test "$vcnumwithdot" = "16.0"; then
4072            if test "$WIN_BUILD_ARCH" != "x64"; then
4073                regvalue="$VC_PRODUCT_DIR/../MSBuild/Current/Bin"
4074            else
4075                regvalue="$VC_PRODUCT_DIR/../MSBuild/Current/Bin/amd64"
4076            fi
4077        else
4078            if test "$WIN_BUILD_ARCH" != "x64"; then
4079                regvalue="$VC_PRODUCT_DIR/../MSBuild/$vcnumwithdot/Bin"
4080            else
4081                regvalue="$VC_PRODUCT_DIR/../MSBuild/$vcnumwithdot/Bin/amd64"
4082            fi
4083        fi
4084        MSBUILD_PATH=`win_short_path_for_make "$regvalue"`
4085        AC_MSG_RESULT([$regvalue])
4086    fi
4087
4088    # Find the version of devenv.exe
4089    # MSVC 2017 devenv does not start properly from a DOS 8.3 path
4090    DEVENV=$(cygpath -lm "$VC_PRODUCT_DIR/../Common7/IDE/devenv.exe")
4091    DEVENV_unix=$(cygpath -u "$DEVENV")
4092    if test ! -e "$DEVENV_unix"; then
4093        AC_MSG_WARN([No devenv.exe found - this is expected for VC++ Build Tools])
4094    fi
4095
4096    dnl Save the true MSVC cl.exe for use when CC/CXX is actually clang-cl,
4097    dnl needed when building CLR code:
4098    if test -z "$MSVC_CXX"; then
4099        # This gives us a posix path with 8.3 filename restrictions
4100        MSVC_CXX=`win_short_path_for_make "$MSVC_HOST_PATH/cl.exe"`
4101    fi
4102
4103    if test -z "$CC"; then
4104        CC=$MSVC_CXX
4105        CC_BASE=`first_arg_basename "$CC"`
4106    fi
4107    if test -z "$CXX"; then
4108        CXX=$MSVC_CXX
4109        CXX_BASE=`first_arg_basename "$CXX"`
4110    fi
4111
4112    if test -n "$CC"; then
4113        # Remove /cl.exe from CC case insensitive
4114        AC_MSG_NOTICE([found Visual C++ $vcyear])
4115
4116        main_include_dir=`cygpath -d -m "$COMPATH/Include"`
4117        CPPFLAGS="$CPPFLAGS -I$main_include_dir"
4118
4119        PathFormat "$COMPATH"
4120        COMPATH=`win_short_path_for_make "$formatted_path"`
4121
4122        VCVER=$vcnum
4123
4124        # The WINDOWS_SDK_ACCEPTABLE_VERSIONS is mostly an educated guess...  Assuming newer ones
4125        # are always "better", we list them in reverse chronological order.
4126
4127        case "$vcnum" in
4128        160)
4129            WINDOWS_SDK_ACCEPTABLE_VERSIONS="10.0 8.1A 8.1 8.0"
4130            ;;
4131        esac
4132
4133        # The expectation is that --with-windows-sdk should not need to be used
4134        if test -n "$with_windows_sdk"; then
4135            case " $WINDOWS_SDK_ACCEPTABLE_VERSIONS " in
4136            *" "$with_windows_sdk" "*)
4137                WINDOWS_SDK_ACCEPTABLE_VERSIONS=$with_windows_sdk
4138                ;;
4139            *)
4140                AC_MSG_ERROR([Windows SDK $with_windows_sdk is not known to work with VS $vcyear])
4141                ;;
4142            esac
4143        fi
4144
4145        # Make AC_COMPILE_IFELSE etc. work (set by AC_PROG_C, which we don't use for MSVC)
4146        ac_objext=obj
4147        ac_exeext=exe
4148
4149    else
4150        AC_MSG_ERROR([Visual C++ not found after all, huh])
4151    fi
4152
4153    AC_MSG_CHECKING([$CC_BASE is at least Visual Studio 2019 version 16.5])
4154    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
4155        // See <https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros> for mapping
4156        // between Visual Studio versions and _MSC_VER:
4157        #if _MSC_VER < 1925
4158        #error
4159        #endif
4160    ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no])])
4161
4162    # Check for 64-bit (cross-)compiler to use to build the 64-bit
4163    # version of the Explorer extension (and maybe other small
4164    # bits, too) needed when installing a 32-bit LibreOffice on a
4165    # 64-bit OS. The 64-bit Explorer extension is a feature that
4166    # has been present since long in OOo. Don't confuse it with
4167    # building LibreOffice itself as 64-bit code.
4168
4169    BUILD_X64=
4170    CXX_X64_BINARY=
4171
4172    if test "$WIN_HOST_ARCH" = "x86" -a -n "$WIN_OTHER_ARCH"; then
4173        AC_MSG_CHECKING([for the libraries to build the 64-bit Explorer extensions])
4174        if test -f "$COMPATH/atlmfc/lib/x64/atls.lib" -o \
4175             -f "$COMPATH/atlmfc/lib/spectre/x64/atls.lib"
4176        then
4177            BUILD_X64=TRUE
4178            CXX_X64_BINARY=`win_short_path_for_make "$MSVC_MULTI_PATH/cl.exe"`
4179            AC_MSG_RESULT([found])
4180        else
4181            AC_MSG_RESULT([not found])
4182            AC_MSG_WARN([Installation set will not contain 64-bit Explorer extensions])
4183        fi
4184    elif test "$WIN_HOST_ARCH" = "x64"; then
4185        CXX_X64_BINARY=$CXX
4186    fi
4187    AC_SUBST(BUILD_X64)
4188
4189    # These are passed to the environment and then used in gbuild/platform/com_MSC_class.mk
4190    AC_SUBST(CXX_X64_BINARY)
4191
4192    # Check for 32-bit compiler to use to build the 32-bit TWAIN shim
4193    # needed to support TWAIN scan on both 32- and 64-bit systems
4194
4195    case "$WIN_HOST_ARCH" in
4196    x64)
4197        AC_MSG_CHECKING([for a x86 compiler and libraries for 32-bit binaries required for TWAIN support])
4198        if test -n "$CXX_X86_BINARY"; then
4199            BUILD_X86=TRUE
4200            AC_MSG_RESULT([preset])
4201        elif test -n "$WIN_MULTI_ARCH"; then
4202            BUILD_X86=TRUE
4203            CXX_X86_BINARY=`win_short_path_for_make "$MSVC_MULTI_PATH/cl.exe"`
4204            CXX_X86_BINARY+=" /arch:SSE"
4205            AC_MSG_RESULT([found])
4206        else
4207            AC_MSG_RESULT([not found])
4208            AC_MSG_WARN([Installation set will not contain 32-bit binaries required for TWAIN support])
4209        fi
4210        ;;
4211    x86)
4212        BUILD_X86=TRUE
4213        CXX_X86_BINARY=$MSVC_CXX
4214        ;;
4215    esac
4216    AC_SUBST(BUILD_X86)
4217    AC_SUBST(CXX_X86_BINARY)
4218fi
4219AC_SUBST(VCVER)
4220AC_SUBST(DEVENV)
4221AC_SUBST(MSVC_CXX)
4222
4223COM_IS_CLANG=
4224AC_MSG_CHECKING([whether the compiler is actually Clang])
4225AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
4226    #ifndef __clang__
4227    you lose
4228    #endif
4229    int foo=42;
4230    ]])],
4231    [AC_MSG_RESULT([yes])
4232     COM_IS_CLANG=TRUE],
4233    [AC_MSG_RESULT([no])])
4234AC_SUBST(COM_IS_CLANG)
4235
4236CC_PLAIN=$CC
4237CLANGVER=
4238if test "$COM_IS_CLANG" = TRUE; then
4239    AC_MSG_CHECKING([whether Clang is new enough])
4240    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
4241        #if !defined __apple_build_version__
4242        #error
4243        #endif
4244        ]])],
4245        [my_apple_clang=yes],[my_apple_clang=])
4246    if test "$my_apple_clang" = yes; then
4247        AC_MSG_RESULT([assumed yes (Apple Clang)])
4248    elif test "$_os" = Emscripten; then
4249        AC_MSG_RESULT([assumed yes (Emscripten Clang)])
4250    else
4251        if test "$_os" = WINNT; then
4252            dnl In which case, assume clang-cl:
4253            my_args="/EP /TC"
4254            dnl Filter out -FIIntrin.h, which needs to be explicitly stated for
4255            dnl clang-cl:
4256            CC_PLAIN=
4257            for i in $CC; do
4258                case $i in
4259                -FIIntrin.h)
4260                    ;;
4261                *)
4262                    CC_PLAIN="$CC_PLAIN $i"
4263                    ;;
4264                esac
4265            done
4266        else
4267            my_args="-E -P"
4268        fi
4269        clang_version=`echo __clang_major__.__clang_minor__.__clang_patchlevel__ | $CC_PLAIN $my_args - | sed 's/ //g'`
4270        CLANG_FULL_VERSION=`echo __clang_version__ | $CC_PLAIN $my_args -`
4271        CLANGVER=`echo $clang_version \
4272            | $AWK -F. '{ print \$1*10000+(\$2<100?\$2:99)*100+(\$3<100?\$3:99) }'`
4273        if test "$CLANGVER" -ge 50002; then
4274            AC_MSG_RESULT([yes ($clang_version)])
4275        else
4276            AC_MSG_ERROR(["$CLANG_FULL_VERSION" is too old or unrecognized, must be at least Clang 5.0.2])
4277        fi
4278        AC_DEFINE_UNQUOTED(CLANG_VERSION,$CLANGVER)
4279        AC_DEFINE_UNQUOTED(CLANG_FULL_VERSION,$CLANG_FULL_VERSION)
4280    fi
4281fi
4282
4283SHOWINCLUDES_PREFIX=
4284if test "$_os" = WINNT; then
4285    dnl We need to guess the prefix of the -showIncludes output, it can be
4286    dnl localized
4287    AC_MSG_CHECKING([the dependency generation prefix (cl.exe -showIncludes)])
4288    echo "#include <stdlib.h>" > conftest.c
4289    SHOWINCLUDES_PREFIX=`$CC_PLAIN $CFLAGS -c -showIncludes conftest.c 2>/dev/null | \
4290        grep 'stdlib\.h' | head -n1 | sed 's/ [[[:alpha:]]]:.*//'`
4291    rm -f conftest.c conftest.obj
4292    if test -z "$SHOWINCLUDES_PREFIX"; then
4293        AC_MSG_ERROR([cannot determine the -showIncludes prefix])
4294    else
4295        AC_MSG_RESULT(["$SHOWINCLUDES_PREFIX"])
4296    fi
4297fi
4298AC_SUBST(SHOWINCLUDES_PREFIX)
4299
4300#
4301# prefix C with ccache if needed
4302#
4303UNCACHED_CC="$CC"
4304if test "$CCACHE" != ""; then
4305    AC_MSG_CHECKING([whether $CC_BASE is already ccached])
4306
4307    AC_LANG_PUSH([C])
4308    save_CFLAGS=$CFLAGS
4309    CFLAGS="$CFLAGS --ccache-skip -O2"
4310    dnl an empty program will do, we're checking the compiler flags
4311    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
4312                      [use_ccache=yes], [use_ccache=no])
4313    CFLAGS=$save_CFLAGS
4314    if test $use_ccache = yes -a "${CCACHE/*sccache*/}" != ""; then
4315        AC_MSG_RESULT([yes])
4316    else
4317        CC="$CCACHE $CC"
4318        CC_BASE="ccache $CC_BASE"
4319        AC_MSG_RESULT([no])
4320    fi
4321    AC_LANG_POP([C])
4322fi
4323
4324# ===================================================================
4325# check various GCC options that Clang does not support now but maybe
4326# will somewhen in the future, check them even for GCC, so that the
4327# flags are set
4328# ===================================================================
4329
4330HAVE_GCC_GGDB2=
4331if test "$GCC" = "yes" -a "$_os" != "Emscripten"; then
4332    AC_MSG_CHECKING([whether $CC_BASE supports -ggdb2])
4333    save_CFLAGS=$CFLAGS
4334    CFLAGS="$CFLAGS -Werror -ggdb2"
4335    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_GGDB2=TRUE ],[])
4336    CFLAGS=$save_CFLAGS
4337    if test "$HAVE_GCC_GGDB2" = "TRUE"; then
4338        AC_MSG_RESULT([yes])
4339    else
4340        AC_MSG_RESULT([no])
4341    fi
4342
4343    if test "$host_cpu" = "m68k"; then
4344        AC_MSG_CHECKING([whether $CC_BASE supports -mlong-jump-table-offsets])
4345        save_CFLAGS=$CFLAGS
4346        CFLAGS="$CFLAGS -Werror -mlong-jump-table-offsets"
4347        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_LONG_JUMP_TABLE_OFFSETS=TRUE ],[])
4348        CFLAGS=$save_CFLAGS
4349        if test "$HAVE_GCC_LONG_JUMP_TABLE_OFFSETS" = "TRUE"; then
4350            AC_MSG_RESULT([yes])
4351        else
4352            AC_MSG_ERROR([no])
4353        fi
4354    fi
4355fi
4356AC_SUBST(HAVE_GCC_GGDB2)
4357
4358dnl ===================================================================
4359dnl  Test the gcc version
4360dnl ===================================================================
4361if test "$GCC" = "yes" -a -z "$COM_IS_CLANG"; then
4362    AC_MSG_CHECKING([the GCC version])
4363    _gcc_version=`$CC -dumpversion`
4364    gcc_full_version=$(printf '%s' "$_gcc_version" | \
4365        $AWK -F. '{ print $1*10000+$2*100+(NF<3?1:$3) }')
4366    GCC_VERSION=`echo $_gcc_version | $AWK -F. '{ print \$1*100+\$2 }'`
4367
4368    AC_MSG_RESULT([gcc $_gcc_version ($gcc_full_version)])
4369
4370    if test "$gcc_full_version" -lt 70000; then
4371        AC_MSG_ERROR([GCC $_gcc_version is too old, must be at least GCC 7.0.0])
4372    fi
4373else
4374    # Explicitly force GCC_VERSION to be empty, even for Clang, to check incorrect uses.
4375    # GCC version should generally be checked only when handling GCC-specific bugs, for testing
4376    # things like features configure checks should be used, otherwise they may e.g. fail with Clang
4377    # (which reports itself as GCC 4.2.1).
4378    GCC_VERSION=
4379fi
4380AC_SUBST(GCC_VERSION)
4381
4382dnl Set the ENABLE_DBGUTIL variable
4383dnl ===================================================================
4384AC_MSG_CHECKING([whether to build with additional debug utilities])
4385if test -n "$enable_dbgutil" -a "$enable_dbgutil" != "no"; then
4386    ENABLE_DBGUTIL="TRUE"
4387    # this is an extra var so it can have different default on different MSVC
4388    # versions (in case there are version specific problems with it)
4389    MSVC_USE_DEBUG_RUNTIME="TRUE"
4390
4391    AC_MSG_RESULT([yes])
4392    # cppunit and graphite expose STL in public headers
4393    if test "$with_system_cppunit" = "yes"; then
4394        AC_MSG_ERROR([--with-system-cppunit conflicts with --enable-dbgutil])
4395    else
4396        with_system_cppunit=no
4397    fi
4398    if test "$with_system_graphite" = "yes"; then
4399        AC_MSG_ERROR([--with-system-graphite conflicts with --enable-dbgutil])
4400    else
4401        with_system_graphite=no
4402    fi
4403    if test "$with_system_orcus" = "yes"; then
4404        AC_MSG_ERROR([--with-system-orcus conflicts with --enable-dbgutil])
4405    else
4406        with_system_orcus=no
4407    fi
4408    if test "$with_system_libcmis" = "yes"; then
4409        AC_MSG_ERROR([--with-system-libcmis conflicts with --enable-dbgutil])
4410    else
4411        with_system_libcmis=no
4412    fi
4413    if test "$with_system_hunspell" = "yes"; then
4414        AC_MSG_ERROR([--with-system-hunspell conflicts with --enable-dbgutil])
4415    else
4416        with_system_hunspell=no
4417    fi
4418    if test "$with_system_gpgmepp" = "yes"; then
4419        AC_MSG_ERROR([--with-system-gpgmepp conflicts with --enable-dbgutil])
4420    else
4421        with_system_gpgmepp=no
4422    fi
4423    # As mixing system libwps and non-system libnumbertext or vice versa likely causes trouble (see
4424    # 603074c5f2b84de8a24593faf807da784b040625 "Pass _GLIBCXX_DEBUG into external/libwps" and the
4425    # mail thread starting at <https://gcc.gnu.org/ml/gcc/2018-05/msg00057.html> "libstdc++: ODR
4426    # violation when using std::regex with and without -D_GLIBCXX_DEBUG"), simply make sure neither
4427    # of those two is using the system variant:
4428    if test "$with_system_libnumbertext" = "yes"; then
4429        AC_MSG_ERROR([--with-system-libnumbertext conflicts with --enable-dbgutil])
4430    else
4431        with_system_libnumbertext=no
4432    fi
4433    if test "$with_system_libwps" = "yes"; then
4434        AC_MSG_ERROR([--with-system-libwps conflicts with --enable-dbgutil])
4435    else
4436        with_system_libwps=no
4437    fi
4438else
4439    ENABLE_DBGUTIL=""
4440    MSVC_USE_DEBUG_RUNTIME=""
4441    AC_MSG_RESULT([no])
4442fi
4443AC_SUBST(ENABLE_DBGUTIL)
4444AC_SUBST(MSVC_USE_DEBUG_RUNTIME)
4445
4446dnl Set the ENABLE_DEBUG variable.
4447dnl ===================================================================
4448if test -n "$enable_debug" && test "$enable_debug" != "yes" && test "$enable_debug" != "no"; then
4449    AC_MSG_ERROR([--enable-debug now accepts only yes or no, use --enable-symbols])
4450fi
4451if test -n "$ENABLE_DBGUTIL" -a "$enable_debug" = "no"; then
4452    if test -z "$libo_fuzzed_enable_debug"; then
4453        AC_MSG_ERROR([--disable-debug cannot be used with --enable-dbgutil])
4454    else
4455        AC_MSG_NOTICE([Resetting --enable-debug=yes])
4456        enable_debug=yes
4457    fi
4458fi
4459
4460AC_MSG_CHECKING([whether to do a debug build])
4461if test -n "$ENABLE_DBGUTIL" -o \( -n "$enable_debug" -a "$enable_debug" != "no" \) ; then
4462    ENABLE_DEBUG="TRUE"
4463    if test -n "$ENABLE_DBGUTIL" ; then
4464        AC_MSG_RESULT([yes (dbgutil)])
4465    else
4466        AC_MSG_RESULT([yes])
4467    fi
4468else
4469    ENABLE_DEBUG=""
4470    AC_MSG_RESULT([no])
4471fi
4472AC_SUBST(ENABLE_DEBUG)
4473
4474dnl ===================================================================
4475dnl Select the linker to use (gold/lld/ld.bfd).
4476dnl This is done only after compiler checks (need to know if Clang is
4477dnl used, for different defaults) and after checking if a debug build
4478dnl is wanted (non-debug builds get the default linker if not explicitly
4479dnl specified otherwise).
4480dnl All checks for linker features/options should come after this.
4481dnl ===================================================================
4482check_use_ld()
4483{
4484    use_ld=-fuse-ld=${1%%:*}
4485    use_ld_path=${1#*:}
4486    if test "$use_ld_path" != "$1"; then
4487        use_ld="$use_ld --ld-path=$use_ld_path"
4488    fi
4489    use_ld_fail_if_error=$2
4490    use_ld_ok=
4491    AC_MSG_CHECKING([for $use_ld linker support])
4492    use_ld_ldflags_save="$LDFLAGS"
4493    LDFLAGS="$LDFLAGS $use_ld"
4494    AC_LINK_IFELSE([AC_LANG_PROGRAM([
4495#include <stdio.h>
4496        ],[
4497printf ("hello world\n");
4498        ])], USE_LD=$use_ld, [])
4499    if test -n "$USE_LD"; then
4500        AC_MSG_RESULT( yes )
4501        use_ld_ok=yes
4502    else
4503        if test -n "$use_ld_fail_if_error"; then
4504            AC_MSG_ERROR( no )
4505        else
4506            AC_MSG_RESULT( no )
4507        fi
4508    fi
4509    if test -n "$use_ld_ok"; then
4510        dnl keep the value of LDFLAGS
4511        return 0
4512    fi
4513    LDFLAGS="$use_ld_ldflags_save"
4514    return 1
4515}
4516USE_LD=
4517if test "$enable_ld" != "no"; then
4518    if test "$GCC" = "yes"; then
4519        if test -n "$enable_ld"; then
4520            check_use_ld "$enable_ld" fail_if_error
4521        elif test -z "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
4522            dnl non-debug builds default to the default linker
4523            true
4524        elif test -n "$COM_IS_CLANG"; then
4525            check_use_ld lld
4526            if test $? -ne 0; then
4527                check_use_ld gold
4528            fi
4529        else
4530            # For gcc first try gold, new versions also support lld.
4531            check_use_ld gold
4532            if test $? -ne 0; then
4533                check_use_ld lld
4534            fi
4535        fi
4536        ld_output=$(echo 'int main() { return 0; }' | $CC -Wl,-v -x c -o conftest.out - $CFLAGS $LDFLAGS 2>/dev/null)
4537        rm conftest.out
4538        ld_used=$(echo "$ld_output" | grep -E '(^GNU gold|^GNU ld|^LLD)')
4539        if test -z "$ld_used"; then
4540            ld_used="unknown"
4541        fi
4542        AC_MSG_CHECKING([for linker that is used])
4543        AC_MSG_RESULT([$ld_used])
4544        if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
4545            if echo "$ld_used" | grep -q "^GNU ld"; then
4546                AC_MSG_WARN([The default GNU linker is slow, consider using the LLD or the GNU gold linker.])
4547                add_warning "The default GNU linker is slow, consider using the LLD or the GNU gold linker."
4548            fi
4549        fi
4550    else
4551        if test "$enable_ld" = "yes"; then
4552            AC_MSG_ERROR([--enable-ld not supported])
4553        fi
4554    fi
4555fi
4556AC_SUBST(USE_LD)
4557
4558HAVE_LD_BSYMBOLIC_FUNCTIONS=
4559if test "$GCC" = "yes" -a "$_os" != Emscripten ; then
4560    AC_MSG_CHECKING([for -Bsymbolic-functions linker support])
4561    bsymbolic_functions_ldflags_save=$LDFLAGS
4562    LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
4563    AC_LINK_IFELSE([AC_LANG_PROGRAM([
4564#include <stdio.h>
4565        ],[
4566printf ("hello world\n");
4567        ])], HAVE_LD_BSYMBOLIC_FUNCTIONS=TRUE, [])
4568    if test "$HAVE_LD_BSYMBOLIC_FUNCTIONS" = "TRUE"; then
4569        AC_MSG_RESULT( found )
4570    else
4571        AC_MSG_RESULT( not found )
4572    fi
4573    LDFLAGS=$bsymbolic_functions_ldflags_save
4574fi
4575AC_SUBST(HAVE_LD_BSYMBOLIC_FUNCTIONS)
4576
4577LD_GC_SECTIONS=
4578if test "$GCC" = "yes"; then
4579    for flag in "--gc-sections" "-dead_strip"; do
4580        AC_MSG_CHECKING([for $flag linker support])
4581        ldflags_save=$LDFLAGS
4582        LDFLAGS="$LDFLAGS -Wl,$flag"
4583        AC_LINK_IFELSE([AC_LANG_PROGRAM([
4584#include <stdio.h>
4585            ],[
4586printf ("hello world\n");
4587            ])],[
4588            LD_GC_SECTIONS="-Wl,$flag"
4589            AC_MSG_RESULT( found )
4590            ], [
4591            AC_MSG_RESULT( not found )
4592            ])
4593        LDFLAGS=$ldflags_save
4594        if test -n "$LD_GC_SECTIONS"; then
4595            break
4596        fi
4597    done
4598fi
4599AC_SUBST(LD_GC_SECTIONS)
4600
4601HAVE_GSPLIT_DWARF=
4602if test "$enable_split_debug" != no; then
4603    dnl Currently by default enabled only on Linux, feel free to set test_split_debug above also for other platforms.
4604    if test "$enable_split_debug" = yes -o \( "$test_split_debug" = "yes" -a -n "$ENABLE_DEBUG$ENABLE_DBGUTIL" \); then
4605        AC_MSG_CHECKING([whether $CC_BASE supports -gsplit-dwarf])
4606        save_CFLAGS=$CFLAGS
4607        CFLAGS="$CFLAGS -Werror -gsplit-dwarf"
4608        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_SPLIT_DWARF=TRUE ],[])
4609        CFLAGS=$save_CFLAGS
4610        if test "$HAVE_GCC_SPLIT_DWARF" = "TRUE"; then
4611            AC_MSG_RESULT([yes])
4612        else
4613            if test "$enable_split_debug" = yes; then
4614                AC_MSG_ERROR([no])
4615            else
4616                AC_MSG_RESULT([no])
4617            fi
4618        fi
4619    fi
4620    if test -z "$HAVE_GCC_SPLIT_DWARF" -a "$test_split_debug" = "yes" -a -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
4621        AC_MSG_WARN([Compiler is not capable of creating split debug info, linking will require more time and disk space.])
4622        add_warning "Compiler is not capable of creating split debug info, linking will require more time and disk space."
4623    fi
4624fi
4625AC_SUBST(HAVE_GCC_SPLIT_DWARF)
4626
4627HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR=
4628AC_MSG_CHECKING([whether $CC_BASE supports -Xclang -debug-info-kind=constructor])
4629save_CFLAGS=$CFLAGS
4630CFLAGS="$CFLAGS -Werror -Xclang -debug-info-kind=constructor"
4631AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR=TRUE ],[])
4632CFLAGS=$save_CFLAGS
4633if test "$HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR" = "TRUE"; then
4634    AC_MSG_RESULT([yes])
4635else
4636    AC_MSG_RESULT([no])
4637fi
4638AC_SUBST(HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR)
4639
4640ENABLE_GDB_INDEX=
4641if test "$enable_gdb_index" != "no"; then
4642    dnl Currently by default enabled only on Linux, feel free to set test_gdb_index above also for other platforms.
4643    if test "$enable_gdb_index" = yes -o \( "$test_gdb_index" = "yes" -o -n "$ENABLE_DEBUG$ENABLE_DBGUTIL" \); then
4644        AC_MSG_CHECKING([whether $CC_BASE supports -ggnu-pubnames])
4645        save_CFLAGS=$CFLAGS
4646        CFLAGS="$CFLAGS -Werror -ggnu-pubnames"
4647        have_ggnu_pubnames=
4648        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[have_ggnu_pubnames=TRUE],[have_ggnu_pubnames=])
4649        if test "$have_ggnu_pubnames" != "TRUE"; then
4650            if test "$enable_gdb_index" = "yes"; then
4651                AC_MSG_ERROR([no, --enable-gdb-index not supported])
4652            else
4653                AC_MSG_RESULT( no )
4654            fi
4655        else
4656            AC_MSG_RESULT( yes )
4657            AC_MSG_CHECKING([whether $CC_BASE supports -Wl,--gdb-index])
4658            ldflags_save=$LDFLAGS
4659            LDFLAGS="$LDFLAGS -Wl,--gdb-index"
4660            AC_LINK_IFELSE([AC_LANG_PROGRAM([
4661#include <stdio.h>
4662                ],[
4663printf ("hello world\n");
4664                ])], ENABLE_GDB_INDEX=TRUE, [])
4665            if test "$ENABLE_GDB_INDEX" = "TRUE"; then
4666                AC_MSG_RESULT( yes )
4667            else
4668                if test "$enable_gdb_index" = "yes"; then
4669                    AC_MSG_ERROR( no )
4670                else
4671                    AC_MSG_RESULT( no )
4672                fi
4673            fi
4674            LDFLAGS=$ldflags_save
4675        fi
4676        CFLAGS=$save_CFLAGS
4677        fi
4678    if test -z "$ENABLE_GDB_INDEX" -a "$test_gdb_index" = "yes" -a -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
4679        AC_MSG_WARN([Linker is not capable of creating gdb index, debugger startup will be slow.])
4680        add_warning "Linker is not capable of creating gdb index, debugger startup will be slow."
4681    fi
4682fi
4683AC_SUBST(ENABLE_GDB_INDEX)
4684
4685if test -z "$enable_sal_log" && test "$ENABLE_DEBUG" = TRUE; then
4686    enable_sal_log=yes
4687fi
4688if test "$enable_sal_log" = yes; then
4689    ENABLE_SAL_LOG=TRUE
4690fi
4691AC_SUBST(ENABLE_SAL_LOG)
4692
4693dnl Check for enable symbols option
4694dnl ===================================================================
4695AC_MSG_CHECKING([whether to generate debug information])
4696if test -z "$enable_symbols"; then
4697    if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
4698        enable_symbols=yes
4699    else
4700        enable_symbols=no
4701    fi
4702fi
4703if test "$enable_symbols" = yes; then
4704    ENABLE_SYMBOLS_FOR=all
4705    AC_MSG_RESULT([yes])
4706elif test "$enable_symbols" = no; then
4707    ENABLE_SYMBOLS_FOR=
4708    AC_MSG_RESULT([no])
4709else
4710    # Selective debuginfo.
4711    ENABLE_SYMBOLS_FOR="$enable_symbols"
4712    AC_MSG_RESULT([for "$enable_symbols"])
4713fi
4714AC_SUBST(ENABLE_SYMBOLS_FOR)
4715
4716if test -n "$with_android_ndk" -a \( -n "$ENABLE_SYMBOLS" -o -n "$ENABLE_DEBUG" -o -n "$ENABLE_DBGUTIL" \) -a "$ENABLE_DEBUGINFO_FOR" = "all"; then
4717    # Building on Android with full symbols: without enough memory the linker never finishes currently.
4718    AC_MSG_CHECKING([whether enough memory is available for linking])
4719    mem_size=$(grep -o 'MemTotal: *.\+ kB' /proc/meminfo | sed 's/MemTotal: *\(.\+\) kB/\1/')
4720    # Check for 15GB, as Linux reports a bit less than the physical memory size.
4721    if test -n "$mem_size" -a $mem_size -lt 15728640; then
4722        AC_MSG_ERROR([building with full symbols and less than 16GB of memory is not supported])
4723    else
4724        AC_MSG_RESULT([yes])
4725    fi
4726fi
4727
4728ENABLE_OPTIMIZED=
4729ENABLE_OPTIMIZED_DEBUG=
4730AC_MSG_CHECKING([whether to compile with optimization flags])
4731if test -z "$enable_optimized"; then
4732    if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
4733        enable_optimized=no
4734    else
4735        enable_optimized=yes
4736    fi
4737fi
4738if test "$enable_optimized" = yes; then
4739    ENABLE_OPTIMIZED=TRUE
4740    AC_MSG_RESULT([yes])
4741elif test "$enable_optimized" = debug; then
4742    ENABLE_OPTIMIZED_DEBUG=TRUE
4743    AC_MSG_RESULT([yes (debug)])
4744    HAVE_GCC_OG=
4745    if test "$GCC" = "yes" -a "$_os" != "Emscripten"; then
4746        AC_MSG_CHECKING([whether $CC_BASE supports -Og])
4747        save_CFLAGS=$CFLAGS
4748        CFLAGS="$CFLAGS -Werror -Og"
4749        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_OG=TRUE ],[])
4750        CFLAGS=$save_CFLAGS
4751        if test "$HAVE_GCC_OG" = "TRUE"; then
4752            AC_MSG_RESULT([yes])
4753        else
4754            AC_MSG_RESULT([no])
4755        fi
4756    fi
4757    if test -z "$HAVE_GCC_OG" -a "$_os" != "Emscripten"; then
4758        AC_MSG_ERROR([The compiler does not support optimizations suitable for debugging.])
4759    fi
4760else
4761    AC_MSG_RESULT([no])
4762fi
4763AC_SUBST(ENABLE_OPTIMIZED)
4764AC_SUBST(ENABLE_OPTIMIZED_DEBUG)
4765
4766#
4767# determine CPUNAME, OS, ...
4768#
4769case "$host_os" in
4770
4771aix*)
4772    COM=GCC
4773    CPUNAME=POWERPC
4774    OS=AIX
4775    RTL_OS=AIX
4776    RTL_ARCH=PowerPC
4777    PLATFORMID=aix_powerpc
4778    P_SEP=:
4779    ;;
4780
4781cygwin*|wsl*)
4782    # Already handled
4783    ;;
4784
4785darwin*|macos*)
4786    COM=GCC
4787    OS=MACOSX
4788    RTL_OS=MacOSX
4789    P_SEP=:
4790
4791    case "$host_cpu" in
4792    aarch64|arm64)
4793        if test "$enable_ios_simulator" = "yes"; then
4794            OS=iOS
4795        else
4796            CPUNAME=AARCH64
4797            RTL_ARCH=AARCH64
4798            PLATFORMID=macosx_aarch64
4799        fi
4800        ;;
4801    x86_64)
4802        if test "$enable_ios_simulator" = "yes"; then
4803            OS=iOS
4804        fi
4805        CPUNAME=X86_64
4806        RTL_ARCH=X86_64
4807        PLATFORMID=macosx_x86_64
4808        ;;
4809    *)
4810        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4811        ;;
4812    esac
4813    ;;
4814
4815ios*)
4816    COM=GCC
4817    OS=iOS
4818    RTL_OS=iOS
4819    P_SEP=:
4820
4821    case "$host_cpu" in
4822    aarch64|arm64)
4823        if test "$enable_ios_simulator" = "yes"; then
4824            AC_MSG_ERROR([iOS simulator is only available in macOS not iOS])
4825        fi
4826        ;;
4827    *)
4828        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4829        ;;
4830    esac
4831    CPUNAME=AARCH64
4832    RTL_ARCH=AARCH64
4833    PLATFORMID=ios_arm64
4834    ;;
4835
4836dragonfly*)
4837    COM=GCC
4838    OS=DRAGONFLY
4839    RTL_OS=DragonFly
4840    P_SEP=:
4841
4842    case "$host_cpu" in
4843    i*86)
4844        CPUNAME=INTEL
4845        RTL_ARCH=x86
4846        PLATFORMID=dragonfly_x86
4847        ;;
4848    x86_64)
4849        CPUNAME=X86_64
4850        RTL_ARCH=X86_64
4851        PLATFORMID=dragonfly_x86_64
4852        ;;
4853    *)
4854        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4855        ;;
4856    esac
4857    ;;
4858
4859freebsd*)
4860    COM=GCC
4861    RTL_OS=FreeBSD
4862    OS=FREEBSD
4863    P_SEP=:
4864
4865    case "$host_cpu" in
4866    aarch64)
4867        CPUNAME=AARCH64
4868        PLATFORMID=freebsd_aarch64
4869        RTL_ARCH=AARCH64
4870        ;;
4871    i*86)
4872        CPUNAME=INTEL
4873        RTL_ARCH=x86
4874        PLATFORMID=freebsd_x86
4875        ;;
4876    x86_64|amd64)
4877        CPUNAME=X86_64
4878        RTL_ARCH=X86_64
4879        PLATFORMID=freebsd_x86_64
4880        ;;
4881    powerpc64)
4882        CPUNAME=POWERPC64
4883        RTL_ARCH=PowerPC_64
4884        PLATFORMID=freebsd_powerpc64
4885        ;;
4886    powerpc|powerpcspe)
4887        CPUNAME=POWERPC
4888        RTL_ARCH=PowerPC
4889        PLATFORMID=freebsd_powerpc
4890        ;;
4891    *)
4892        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4893        ;;
4894    esac
4895    ;;
4896
4897haiku*)
4898    COM=GCC
4899    GUIBASE=haiku
4900    RTL_OS=Haiku
4901    OS=HAIKU
4902    P_SEP=:
4903
4904    case "$host_cpu" in
4905    i*86)
4906        CPUNAME=INTEL
4907        RTL_ARCH=x86
4908        PLATFORMID=haiku_x86
4909        ;;
4910    x86_64|amd64)
4911        CPUNAME=X86_64
4912        RTL_ARCH=X86_64
4913        PLATFORMID=haiku_x86_64
4914        ;;
4915    *)
4916        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4917        ;;
4918    esac
4919    ;;
4920
4921kfreebsd*)
4922    COM=GCC
4923    OS=LINUX
4924    RTL_OS=kFreeBSD
4925    P_SEP=:
4926
4927    case "$host_cpu" in
4928
4929    i*86)
4930        CPUNAME=INTEL
4931        RTL_ARCH=x86
4932        PLATFORMID=kfreebsd_x86
4933        ;;
4934    x86_64)
4935        CPUNAME=X86_64
4936        RTL_ARCH=X86_64
4937        PLATFORMID=kfreebsd_x86_64
4938        ;;
4939    *)
4940        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4941        ;;
4942    esac
4943    ;;
4944
4945linux-gnu*)
4946    COM=GCC
4947    OS=LINUX
4948    RTL_OS=Linux
4949    P_SEP=:
4950
4951    case "$host_cpu" in
4952
4953    aarch64)
4954        CPUNAME=AARCH64
4955        PLATFORMID=linux_aarch64
4956        RTL_ARCH=AARCH64
4957        EPM_FLAGS="-a arm64"
4958        ;;
4959    alpha)
4960        CPUNAME=AXP
4961        RTL_ARCH=ALPHA
4962        PLATFORMID=linux_alpha
4963        ;;
4964    arm*)
4965        CPUNAME=ARM
4966        EPM_FLAGS="-a arm"
4967        RTL_ARCH=ARM_EABI
4968        PLATFORMID=linux_arm_eabi
4969        case "$host_cpu" in
4970        arm*-linux)
4971            RTL_ARCH=ARM_OABI
4972            PLATFORMID=linux_arm_oabi
4973            ;;
4974        esac
4975        ;;
4976    hppa)
4977        CPUNAME=HPPA
4978        RTL_ARCH=HPPA
4979        EPM_FLAGS="-a hppa"
4980        PLATFORMID=linux_hppa
4981        ;;
4982    i*86)
4983        CPUNAME=INTEL
4984        RTL_ARCH=x86
4985        PLATFORMID=linux_x86
4986        ;;
4987    ia64)
4988        CPUNAME=IA64
4989        RTL_ARCH=IA64
4990        PLATFORMID=linux_ia64
4991        ;;
4992    mips)
4993        CPUNAME=GODSON
4994        RTL_ARCH=MIPS_EB
4995        EPM_FLAGS="-a mips"
4996        PLATFORMID=linux_mips_eb
4997        ;;
4998    mips64)
4999        CPUNAME=GODSON64
5000        RTL_ARCH=MIPS64_EB
5001        EPM_FLAGS="-a mips64"
5002        PLATFORMID=linux_mips64_eb
5003        ;;
5004    mips64el)
5005        CPUNAME=GODSON64
5006        RTL_ARCH=MIPS64_EL
5007        EPM_FLAGS="-a mips64el"
5008        PLATFORMID=linux_mips64_el
5009        ;;
5010    mipsel)
5011        CPUNAME=GODSON
5012        RTL_ARCH=MIPS_EL
5013        EPM_FLAGS="-a mipsel"
5014        PLATFORMID=linux_mips_el
5015        ;;
5016    m68k)
5017        CPUNAME=M68K
5018        RTL_ARCH=M68K
5019        PLATFORMID=linux_m68k
5020        ;;
5021    powerpc)
5022        CPUNAME=POWERPC
5023        RTL_ARCH=PowerPC
5024        PLATFORMID=linux_powerpc
5025        ;;
5026    powerpc64)
5027        CPUNAME=POWERPC64
5028        RTL_ARCH=PowerPC_64
5029        PLATFORMID=linux_powerpc64
5030        ;;
5031    powerpc64le)
5032        CPUNAME=POWERPC64
5033        RTL_ARCH=PowerPC_64_LE
5034        PLATFORMID=linux_powerpc64_le
5035        ;;
5036    sparc)
5037        CPUNAME=SPARC
5038        RTL_ARCH=SPARC
5039        PLATFORMID=linux_sparc
5040        ;;
5041    sparc64)
5042        CPUNAME=SPARC64
5043        RTL_ARCH=SPARC64
5044        PLATFORMID=linux_sparc64
5045        ;;
5046    s390)
5047        CPUNAME=S390
5048        RTL_ARCH=S390
5049        PLATFORMID=linux_s390
5050        ;;
5051    s390x)
5052        CPUNAME=S390X
5053        RTL_ARCH=S390x
5054        PLATFORMID=linux_s390x
5055        ;;
5056    x86_64)
5057        CPUNAME=X86_64
5058        RTL_ARCH=X86_64
5059        PLATFORMID=linux_x86_64
5060        ;;
5061    *)
5062        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5063        ;;
5064    esac
5065    ;;
5066
5067linux-android*)
5068    COM=GCC
5069    OS=ANDROID
5070    RTL_OS=Android
5071    P_SEP=:
5072
5073    case "$host_cpu" in
5074
5075    arm|armel)
5076        CPUNAME=ARM
5077        RTL_ARCH=ARM_EABI
5078        PLATFORMID=android_arm_eabi
5079        ;;
5080    aarch64)
5081        CPUNAME=AARCH64
5082        RTL_ARCH=AARCH64
5083        PLATFORMID=android_aarch64
5084        ;;
5085    i*86)
5086        CPUNAME=INTEL
5087        RTL_ARCH=x86
5088        PLATFORMID=android_x86
5089        ;;
5090    x86_64)
5091        CPUNAME=X86_64
5092        RTL_ARCH=X86_64
5093        PLATFORMID=android_x86_64
5094        ;;
5095    *)
5096        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5097        ;;
5098    esac
5099    ;;
5100
5101*netbsd*)
5102    COM=GCC
5103    OS=NETBSD
5104    RTL_OS=NetBSD
5105    P_SEP=:
5106
5107    case "$host_cpu" in
5108    i*86)
5109        CPUNAME=INTEL
5110        RTL_ARCH=x86
5111        PLATFORMID=netbsd_x86
5112        ;;
5113    powerpc)
5114        CPUNAME=POWERPC
5115        RTL_ARCH=PowerPC
5116        PLATFORMID=netbsd_powerpc
5117        ;;
5118    sparc)
5119        CPUNAME=SPARC
5120        RTL_ARCH=SPARC
5121        PLATFORMID=netbsd_sparc
5122        ;;
5123    x86_64)
5124        CPUNAME=X86_64
5125        RTL_ARCH=X86_64
5126        PLATFORMID=netbsd_x86_64
5127        ;;
5128    *)
5129        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5130        ;;
5131    esac
5132    ;;
5133
5134openbsd*)
5135    COM=GCC
5136    OS=OPENBSD
5137    RTL_OS=OpenBSD
5138    P_SEP=:
5139
5140    case "$host_cpu" in
5141    i*86)
5142        CPUNAME=INTEL
5143        RTL_ARCH=x86
5144        PLATFORMID=openbsd_x86
5145        ;;
5146    x86_64)
5147        CPUNAME=X86_64
5148        RTL_ARCH=X86_64
5149        PLATFORMID=openbsd_x86_64
5150        ;;
5151    *)
5152        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5153        ;;
5154    esac
5155    SOLARINC="$SOLARINC -I/usr/local/include"
5156    ;;
5157
5158solaris*)
5159    COM=GCC
5160    OS=SOLARIS
5161    RTL_OS=Solaris
5162    P_SEP=:
5163
5164    case "$host_cpu" in
5165    i*86)
5166        CPUNAME=INTEL
5167        RTL_ARCH=x86
5168        PLATFORMID=solaris_x86
5169        ;;
5170    sparc)
5171        CPUNAME=SPARC
5172        RTL_ARCH=SPARC
5173        PLATFORMID=solaris_sparc
5174        ;;
5175    sparc64)
5176        CPUNAME=SPARC64
5177        RTL_ARCH=SPARC64
5178        PLATFORMID=solaris_sparc64
5179        ;;
5180    *)
5181        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5182        ;;
5183    esac
5184    SOLARINC="$SOLARINC -I/usr/local/include"
5185    ;;
5186
5187emscripten*)
5188    COM=GCC
5189    OS=EMSCRIPTEN
5190    RTL_OS=Emscripten
5191    P_SEP=:
5192
5193    case "$host_cpu" in
5194    wasm32|wasm64)
5195        ;;
5196    *)
5197        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5198        ;;
5199    esac
5200    CPUNAME=INTEL
5201    RTL_ARCH=x86
5202    PLATFORMID=linux_x86
5203    ;;
5204
5205*)
5206    AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice for!])
5207    ;;
5208esac
5209
5210if test "$with_x" = "no"; then
5211    AC_MSG_ERROR([Use --disable-gui instead. How can we get rid of this option? No idea where it comes from.])
5212fi
5213
5214DISABLE_GUI=""
5215if test "$enable_gui" = "no"; then
5216    if test "$using_x11" != yes; then
5217        AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice with --disable-gui.])
5218    fi
5219    USING_X11=
5220    DISABLE_GUI=TRUE
5221else
5222    AC_DEFINE(HAVE_FEATURE_UI)
5223fi
5224AC_SUBST(DISABLE_GUI)
5225
5226if test "$using_x11" = yes; then
5227    if test "$USING_X11" = TRUE; then
5228        AC_DEFINE(USING_X11)
5229    else
5230        disable_x11_tests
5231    fi
5232else
5233    if test "$USING_X11" = TRUE; then
5234        AC_MSG_ERROR([Platform doesn't support X11 (\$using_x11), but \$USING_X11 is set!])
5235    fi
5236fi
5237
5238WORKDIR="${BUILDDIR}/workdir"
5239INSTDIR="${BUILDDIR}/instdir"
5240INSTROOTBASE=${INSTDIR}${INSTROOTBASESUFFIX}
5241INSTROOT=${INSTROOTBASE}${INSTROOTCONTENTSUFFIX}
5242SOLARINC="-I$SRC_ROOT/include $SOLARINC"
5243AC_SUBST(COM)
5244AC_SUBST(CPUNAME)
5245AC_SUBST(RTL_OS)
5246AC_SUBST(RTL_ARCH)
5247AC_SUBST(EPM_FLAGS)
5248AC_SUBST(USING_X11)
5249AC_SUBST([INSTDIR])
5250AC_SUBST([INSTROOT])
5251AC_SUBST([INSTROOTBASE])
5252AC_SUBST(OS)
5253AC_SUBST(P_SEP)
5254AC_SUBST(WORKDIR)
5255AC_SUBST(PLATFORMID)
5256AC_SUBST(WINDOWS_X64)
5257AC_DEFINE_UNQUOTED(WORKDIR,"$WORKDIR")
5258
5259if test "$OS" = WNT -a "$COM" = MSC; then
5260    case "$CPUNAME" in
5261    INTEL) CPPU_ENV=msci ;;
5262    X86_64) CPPU_ENV=mscx ;;
5263    AARCH64) CPPU_ENV=msca ;;
5264    *)
5265        AC_MSG_ERROR([Unknown \$CPUNAME '$CPUNAME' for $OS / $COM"])
5266        ;;
5267    esac
5268else
5269    CPPU_ENV=gcc3
5270fi
5271AC_SUBST(CPPU_ENV)
5272
5273dnl ===================================================================
5274dnl Test which package format to use
5275dnl ===================================================================
5276AC_MSG_CHECKING([which package format to use])
5277if test -n "$with_package_format" -a "$with_package_format" != no; then
5278    for i in $with_package_format; do
5279        case "$i" in
5280        aix | bsd | deb | pkg | rpm | archive | dmg | installed | msi)
5281            ;;
5282        *)
5283            AC_MSG_ERROR([unsupported format $i. Supported by EPM are:
5284aix - AIX software distribution
5285bsd - FreeBSD, NetBSD, or OpenBSD software distribution
5286deb - Debian software distribution
5287pkg - Solaris software distribution
5288rpm - RedHat software distribution
5289
5290LibreOffice additionally supports:
5291archive - .tar.gz or .zip
5292dmg - macOS .dmg
5293installed - installation tree
5294msi - Windows .msi
5295        ])
5296            ;;
5297        esac
5298    done
5299    # fakeroot is needed to ensure correct file ownerships/permissions
5300    # inside deb packages and tar archives created on Linux and Solaris.
5301    if test "$OS" = "LINUX" || test "$OS" = "SOLARIS"; then
5302        AC_PATH_PROG(FAKEROOT, fakeroot, no)
5303        if test "$FAKEROOT" = "no"; then
5304            AC_MSG_ERROR(
5305                [--with-package-format='$with_package_format' requires fakeroot. Install fakeroot.])
5306        fi
5307    fi
5308    PKGFORMAT="$with_package_format"
5309    AC_MSG_RESULT([$PKGFORMAT])
5310else
5311    PKGFORMAT=
5312    AC_MSG_RESULT([none])
5313fi
5314AC_SUBST(PKGFORMAT)
5315
5316dnl ===================================================================
5317dnl Set up a different compiler to produce tools to run on the build
5318dnl machine when doing cross-compilation
5319dnl ===================================================================
5320
5321m4_pattern_allow([PKG_CONFIG_FOR_BUILD])
5322m4_pattern_allow([PKG_CONFIG_LIBDIR])
5323if test "$cross_compiling" = "yes"; then
5324    AC_MSG_CHECKING([for BUILD platform configuration])
5325    echo
5326    rm -rf CONF-FOR-BUILD config_build.mk
5327    mkdir CONF-FOR-BUILD
5328    # Here must be listed all files needed when running the configure script. In particular, also
5329    # those expanded by the AC_CONFIG_FILES() call near the end of this configure.ac. For clarity,
5330    # keep them in the same order as there.
5331    (cd $SRC_ROOT && tar cf - \
5332        config.guess \
5333        bin/get_config_variables \
5334        solenv/bin/getcompver.awk \
5335        solenv/inc/langlist.mk \
5336        download.lst \
5337        config_host.mk.in \
5338        config_host_lang.mk.in \
5339        Makefile.in \
5340        bin/bffvalidator.sh.in \
5341        bin/odfvalidator.sh.in \
5342        bin/officeotron.sh.in \
5343        hardened_runtime.xcent.in \
5344        instsetoo_native/util/openoffice.lst.in \
5345        config_host/*.in \
5346        sysui/desktop/macosx/Info.plist.in \
5347        .vscode/vs-code-template.code-workspace.in \
5348        ) \
5349    | (cd CONF-FOR-BUILD && tar xf -)
5350    cp configure CONF-FOR-BUILD
5351    test -d config_build && cp -p config_build/*.h CONF-FOR-BUILD/config_host 2>/dev/null
5352    (
5353    unset COM USING_X11 OS CPUNAME
5354    unset CC CXX SYSBASE CFLAGS
5355    unset AR LD NM OBJDUMP PKG_CONFIG RANLIB READELF STRIP
5356    unset CPPUNIT_CFLAGS CPPUNIT_LIBS
5357    unset LIBXML_CFLAGS LIBXML_LIBS LIBXSLT_CFLAGS LIBXSLT_LIBS XSLTPROC
5358    unset PKG_CONFIG_LIBDIR PKG_CONFIG_PATH
5359    if test -n "$CC_FOR_BUILD"; then
5360        export CC="$CC_FOR_BUILD"
5361        CC_BASE=`first_arg_basename "$CC"`
5362    fi
5363    if test -n "$CXX_FOR_BUILD"; then
5364        export CXX="$CXX_FOR_BUILD"
5365        CXX_BASE=`first_arg_basename "$CXX"`
5366    fi
5367    test -n "$PKG_CONFIG_FOR_BUILD" && export PKG_CONFIG="$PKG_CONFIG_FOR_BUILD"
5368    cd CONF-FOR-BUILD
5369
5370    # Handle host configuration, which affects the cross-toolset too
5371    sub_conf_opts=""
5372    test -n "$enable_ccache" && sub_conf_opts="$sub_conf_opts --enable-ccache=$enable_ccache"
5373    test -n "$with_ant_home" && sub_conf_opts="$sub_conf_opts --with-ant-home=$with_ant_home"
5374    test "$with_junit" = "no" && sub_conf_opts="$sub_conf_opts --without-junit"
5375    if test -n "$ENABLE_JAVA"; then
5376        case "$_os" in
5377        iOS) sub_conf_opts="$sub_conf_opts --without-java" ;; # force it off, like it used to be
5378        Android)
5379            # Hack for Android - the build doesn't need a host JDK, so just forward to build for convenience
5380            test -n "$with_jdk_home" && sub_conf_opts="$sub_conf_opts --with-jdk-home=$with_jdk_home"
5381            ;;
5382        *)
5383            if test -z "$with_jdk_home"; then
5384                AC_MSG_ERROR([Missing host JDK! This can't be detected for the build OS, so you have to specify it with --with-jdk-home.])
5385            fi
5386            ;;
5387        esac
5388    else
5389        sub_conf_opts="$sub_conf_opts --without-java"
5390    fi
5391    test -n "$TARFILE_LOCATION" && sub_conf_opts="$sub_conf_opts --with-external-tar=$TARFILE_LOCATION"
5392    test "$with_system_icu_for_build" = "yes" -o "$with_system_icu_for_build" = "force" && sub_conf_opts="$sub_conf_opts --with-system-icu"
5393    test "$with_galleries" = "no" -o -z "$WITH_GALLERY_BUILD" && sub_conf_opts="$sub_conf_opts --with-galleries=no --disable-database-connectivity"
5394    test "$enable_wasm_strip" = "yes" && sub_conf_opts="$sub_conf_opts --enable-wasm-strip"
5395    sub_conf_opts="$sub_conf_opts $with_build_platform_configure_options"
5396
5397    # Don't bother having configure look for stuff not needed for the build platform anyway
5398    ./configure \
5399        --build="$build_alias" \
5400        --disable-cairo-canvas \
5401        --disable-cups \
5402        --disable-firebird-sdbc \
5403        --disable-gpgmepp \
5404        --disable-gstreamer-1-0 \
5405        --disable-gtk3 \
5406        --disable-gtk4 \
5407        --disable-mariadb-sdbc \
5408        --disable-nss \
5409        --disable-online-update \
5410        --disable-opencl \
5411        --disable-pdfimport \
5412        --disable-postgresql-sdbc \
5413        --disable-skia \
5414        --enable-icecream="$enable_icecream" \
5415        --without-doxygen \
5416        --without-webdav \
5417        --with-parallelism="$with_parallelism" \
5418        --with-theme="$with_theme" \
5419        --with-tls=openssl \
5420        $sub_conf_opts \
5421        --srcdir=$srcdir \
5422        2>&1 | sed -e 's/^/    /'
5423    if test [${PIPESTATUS[0]}] -ne 0; then
5424        AC_MSG_ERROR([Running the configure script for BUILD side failed, see CONF-FOR-BUILD/config.log])
5425    fi
5426
5427    # filter permitted build targets
5428    PERMITTED_BUILD_TARGETS="
5429        AVMEDIA
5430        BOOST
5431        CAIRO
5432        CLUCENE
5433        CURL
5434        DBCONNECTIVITY
5435        DESKTOP
5436        DYNLOADING
5437        EPOXY
5438        EXPAT
5439        GLM
5440        GRAPHITE
5441        HARFBUZZ
5442        ICU
5443        LCMS2
5444        LIBJPEG_TURBO
5445        LIBLANGTAG
5446        LibO
5447        LIBFFI
5448        LIBPN
5449        LIBXML2
5450        LIBXSLT
5451        MDDS
5452        NATIVE
5453        OPENSSL
5454        ORCUS
5455        PYTHON
5456        SCRIPTING
5457        ZLIB
5458"
5459    # converts BUILD_TYPE and PERMITTED_BUILD_TARGETS into non-whitespace,
5460    # newlined lists, to use grep as a filter
5461    PERMITTED_BUILD_TARGETS=$(echo "$PERMITTED_BUILD_TARGETS" | sed -e '/^ *$/d' -e 's/ *//')
5462    BUILD_TARGETS="$(sed -n -e '/^export BUILD_TYPE=/ s/.*=//p' config_host.mk | tr ' ' '\n')"
5463    BUILD_TARGETS="$(echo "$BUILD_TARGETS" | grep -F "$PERMITTED_BUILD_TARGETS" | tr '\n' ' ')"
5464    sed -i -e "s/ BUILD_TYPE=.*$/ BUILD_TYPE=$BUILD_TARGETS/" config_host.mk
5465
5466    cp config_host.mk ../config_build.mk
5467    cp config_host_lang.mk ../config_build_lang.mk
5468    mv config.log ../config.Build.log
5469    mkdir -p ../config_build
5470    mv config_host/*.h ../config_build
5471    test -f "$WARNINGS_FILE" && mv "$WARNINGS_FILE" "../$WARNINGS_FILE_FOR_BUILD"
5472
5473    # all these will get a _FOR_BUILD postfix
5474    DIRECT_FOR_BUILD_SETTINGS="
5475        CC
5476        CPPU_ENV
5477        CXX
5478        ILIB
5479        JAVA_HOME
5480        JAVAIFLAGS
5481        JDK
5482        LIBO_BIN_FOLDER
5483        LIBO_LIB_FOLDER
5484        LIBO_URE_LIB_FOLDER
5485        LIBO_URE_MISC_FOLDER
5486        OS
5487        SDKDIRNAME
5488        SYSTEM_LIBXML
5489        SYSTEM_LIBXSLT
5490"
5491    # these overwrite host config with build config
5492    OVERWRITING_SETTINGS="
5493        ANT
5494        ANT_HOME
5495        ANT_LIB
5496        HSQLDB_USE_JDBC_4_1
5497        JAVA_CLASSPATH_NOT_SET
5498        JAVA_SOURCE_VER
5499        JAVA_TARGET_VER
5500        JAVACFLAGS
5501        JAVACOMPILER
5502        JAVADOC
5503        JAVADOCISGJDOC
5504"
5505    # these need some special handling
5506    EXTRA_HANDLED_SETTINGS="
5507        INSTDIR
5508        INSTROOT
5509        PATH
5510        WORKDIR
5511"
5512    OLD_PATH=$PATH
5513    . ./bin/get_config_variables $DIRECT_FOR_BUILD_SETTINGS $OVERWRITING_SETTINGS $EXTRA_HANDLED_SETTINGS
5514    BUILD_PATH=$PATH
5515    PATH=$OLD_PATH
5516
5517    line=`echo "LO_PATH_FOR_BUILD='${BUILD_PATH}'" | sed -e 's,/CONF-FOR-BUILD,,g'`
5518    echo "$line" >>build-config
5519
5520    for V in $DIRECT_FOR_BUILD_SETTINGS; do
5521        VV='$'$V
5522        VV=`eval "echo $VV"`
5523        if test -n "$VV"; then
5524            line=${V}_FOR_BUILD='${'${V}_FOR_BUILD:-$VV'}'
5525            echo "$line" >>build-config
5526        fi
5527    done
5528
5529    for V in $OVERWRITING_SETTINGS; do
5530        VV='$'$V
5531        VV=`eval "echo $VV"`
5532        if test -n "$VV"; then
5533            line=${V}='${'${V}:-$VV'}'
5534            echo "$line" >>build-config
5535        fi
5536    done
5537
5538    for V in INSTDIR INSTROOT WORKDIR; do
5539        VV='$'$V
5540        VV=`eval "echo $VV"`
5541        VV=`echo $VV | sed -e "s,/CONF-FOR-BUILD/\([[a-z]]*\),/\1_for_build,g"`
5542        if test -n "$VV"; then
5543            line="${V}_FOR_BUILD='$VV'"
5544            echo "$line" >>build-config
5545        fi
5546    done
5547
5548    )
5549    test -f CONF-FOR-BUILD/build-config || AC_MSG_ERROR([setup/configure for BUILD side failed, see CONF-FOR-BUILD/config.log])
5550    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])
5551    perl -pi -e 's,/(workdir|instdir)(/|$),/\1_for_build\2,g;' \
5552             -e 's,/CONF-FOR-BUILD,,g;' config_build.mk
5553
5554    eval `cat CONF-FOR-BUILD/build-config`
5555
5556    AC_MSG_RESULT([checking for BUILD platform configuration... done])
5557
5558    rm -rf CONF-FOR-BUILD
5559else
5560    OS_FOR_BUILD="$OS"
5561    CC_FOR_BUILD="$CC"
5562    CPPU_ENV_FOR_BUILD="$CPPU_ENV"
5563    CXX_FOR_BUILD="$CXX"
5564    INSTDIR_FOR_BUILD="$INSTDIR"
5565    INSTROOT_FOR_BUILD="$INSTROOT"
5566    LIBO_BIN_FOLDER_FOR_BUILD="$LIBO_BIN_FOLDER"
5567    LIBO_LIB_FOLDER_FOR_BUILD="$LIBO_LIB_FOLDER"
5568    LIBO_URE_LIB_FOLDER_FOR_BUILD="$LIBO_URE_LIB_FOLDER"
5569    LIBO_URE_MISC_FOLDER_FOR_BUILD="$LIBO_URE_MISC_FOLDER"
5570    SDKDIRNAME_FOR_BUILD="$SDKDIRNAME"
5571    WORKDIR_FOR_BUILD="$WORKDIR"
5572fi
5573AC_SUBST(OS_FOR_BUILD)
5574AC_SUBST(INSTDIR_FOR_BUILD)
5575AC_SUBST(INSTROOT_FOR_BUILD)
5576AC_SUBST(LIBO_BIN_FOLDER_FOR_BUILD)
5577AC_SUBST(LIBO_LIB_FOLDER_FOR_BUILD)
5578AC_SUBST(LIBO_URE_LIB_FOLDER_FOR_BUILD)
5579AC_SUBST(LIBO_URE_MISC_FOLDER_FOR_BUILD)
5580AC_SUBST(SDKDIRNAME_FOR_BUILD)
5581AC_SUBST(WORKDIR_FOR_BUILD)
5582AC_SUBST(CC_FOR_BUILD)
5583AC_SUBST(CXX_FOR_BUILD)
5584AC_SUBST(CPPU_ENV_FOR_BUILD)
5585
5586dnl ===================================================================
5587dnl Check for syslog header
5588dnl ===================================================================
5589AC_CHECK_HEADER(syslog.h, AC_DEFINE(HAVE_SYSLOG_H))
5590
5591dnl Set the ENABLE_WERROR variable. (Activate --enable-werror)
5592dnl ===================================================================
5593AC_MSG_CHECKING([whether to turn warnings to errors])
5594if test -n "$enable_werror" -a "$enable_werror" != "no"; then
5595    ENABLE_WERROR="TRUE"
5596    PYTHONWARNINGS="error"
5597    AC_MSG_RESULT([yes])
5598else
5599    if test -n "$LODE_HOME" -a -z "$enable_werror"; then
5600        ENABLE_WERROR="TRUE"
5601        PYTHONWARNINGS="error"
5602        AC_MSG_RESULT([yes])
5603    else
5604        AC_MSG_RESULT([no])
5605    fi
5606fi
5607AC_SUBST(ENABLE_WERROR)
5608AC_SUBST(PYTHONWARNINGS)
5609
5610dnl Check for --enable-assert-always-abort, set ASSERT_ALWAYS_ABORT
5611dnl ===================================================================
5612AC_MSG_CHECKING([whether to have assert() failures abort even without --enable-debug])
5613if test -z "$enable_assert_always_abort"; then
5614   if test "$ENABLE_DEBUG" = TRUE; then
5615       enable_assert_always_abort=yes
5616   else
5617       enable_assert_always_abort=no
5618   fi
5619fi
5620if test "$enable_assert_always_abort" = "yes"; then
5621    ASSERT_ALWAYS_ABORT="TRUE"
5622    AC_MSG_RESULT([yes])
5623else
5624    ASSERT_ALWAYS_ABORT="FALSE"
5625    AC_MSG_RESULT([no])
5626fi
5627AC_SUBST(ASSERT_ALWAYS_ABORT)
5628
5629# Determine whether to use ooenv for the instdir installation
5630# ===================================================================
5631if test $_os != "WINNT" -a $_os != "Darwin"; then
5632    AC_MSG_CHECKING([whether to use ooenv for the instdir installation])
5633    if test -z "$enable_ooenv"; then
5634        if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
5635            enable_ooenv=yes
5636        else
5637            enable_ooenv=no
5638        fi
5639    fi
5640    if test "$enable_ooenv" = "no"; then
5641        AC_MSG_RESULT([no])
5642    else
5643        ENABLE_OOENV="TRUE"
5644        AC_MSG_RESULT([yes])
5645    fi
5646fi
5647AC_SUBST(ENABLE_OOENV)
5648
5649if test "$test_kf5" = "yes" -a "$enable_kf5" = "yes"; then
5650    if test "$enable_qt5" = "no"; then
5651        AC_MSG_ERROR([KF5 support depends on QT5, so it conflicts with --disable-qt5])
5652    else
5653        enable_qt5=yes
5654    fi
5655fi
5656
5657dnl ===================================================================
5658dnl check for cups support
5659dnl ===================================================================
5660
5661AC_MSG_CHECKING([whether to enable CUPS support])
5662if test "$test_cups" = yes -a "$enable_cups" != no; then
5663    ENABLE_CUPS=TRUE
5664    AC_MSG_RESULT([yes])
5665
5666    AC_MSG_CHECKING([whether cups support is present])
5667    AC_CHECK_LIB([cups], [cupsPrintFiles], [:])
5668    AC_CHECK_HEADER(cups/cups.h, AC_DEFINE(HAVE_CUPS_H))
5669    if test "$ac_cv_lib_cups_cupsPrintFiles" != "yes" -o "$ac_cv_header_cups_cups_h" != "yes"; then
5670        AC_MSG_ERROR([Could not find CUPS. Install libcups2-dev or cups-devel.])
5671    fi
5672else
5673    AC_MSG_RESULT([no])
5674fi
5675
5676AC_SUBST(ENABLE_CUPS)
5677
5678# fontconfig checks
5679if test "$using_freetype_fontconfig" = yes; then
5680    AC_MSG_CHECKING([which fontconfig to use])
5681fi
5682if test "$using_freetype_fontconfig" = yes -a "$test_system_fontconfig" != no; then
5683    AC_MSG_RESULT([external])
5684    PKG_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.4.1])
5685    SYSTEM_FONTCONFIG=TRUE
5686    FilterLibs "${FONTCONFIG_LIBS}"
5687    FONTCONFIG_LIBS="${filteredlibs}"
5688elif test "$using_freetype_fontconfig" = yes; then
5689    AC_MSG_RESULT([internal])
5690    BUILD_TYPE="$BUILD_TYPE FONTCONFIG"
5691fi
5692AC_SUBST(FONTCONFIG_CFLAGS)
5693AC_SUBST(FONTCONFIG_LIBS)
5694AC_SUBST([SYSTEM_FONTCONFIG])
5695
5696dnl whether to find & fetch external tarballs?
5697dnl ===================================================================
5698if test -z "$TARFILE_LOCATION" -a -n "$LODE_HOME" ; then
5699   if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
5700       TARFILE_LOCATION="`cygpath -m $LODE_HOME/ext_tar`"
5701   else
5702       TARFILE_LOCATION="$LODE_HOME/ext_tar"
5703   fi
5704fi
5705if test -z "$TARFILE_LOCATION"; then
5706    if test -d "$SRC_ROOT/src" ; then
5707        mv "$SRC_ROOT/src" "$SRC_ROOT/external/tarballs"
5708        ln -s "$SRC_ROOT/external/tarballs" "$SRC_ROOT/src"
5709    fi
5710    TARFILE_LOCATION="$SRC_ROOT/external/tarballs"
5711else
5712    AbsolutePath "$TARFILE_LOCATION"
5713    PathFormat "${absolute_path}"
5714    TARFILE_LOCATION="${formatted_path}"
5715fi
5716AC_SUBST(TARFILE_LOCATION)
5717
5718AC_MSG_CHECKING([whether we want to fetch tarballs])
5719if test "$enable_fetch_external" != "no"; then
5720    if test "$with_all_tarballs" = "yes"; then
5721        AC_MSG_RESULT([yes, all of them])
5722        DO_FETCH_TARBALLS="ALL"
5723    else
5724        AC_MSG_RESULT([yes, if we use them])
5725        DO_FETCH_TARBALLS="TRUE"
5726    fi
5727else
5728    AC_MSG_RESULT([no])
5729    DO_FETCH_TARBALLS=
5730fi
5731AC_SUBST(DO_FETCH_TARBALLS)
5732
5733AC_MSG_CHECKING([whether to build help])
5734if test -n "$with_help" -a "$with_help" != "no" -a $_os != iOS -a $_os != Android; then
5735    BUILD_TYPE="$BUILD_TYPE HELP"
5736    GIT_NEEDED_SUBMODULES="helpcontent2 $GIT_NEEDED_SUBMODULES"
5737    case "$with_help" in
5738    "html")
5739        ENABLE_HTMLHELP=TRUE
5740        SCPDEFS="$SCPDEFS -DWITH_HELP"
5741        AC_MSG_RESULT([HTML])
5742        ;;
5743    "online")
5744        ENABLE_HTMLHELP=TRUE
5745        HELP_ONLINE=TRUE
5746        AC_MSG_RESULT([HTML])
5747        ;;
5748    yes)
5749        SCPDEFS="$SCPDEFS -DWITH_HELP"
5750        AC_MSG_RESULT([yes])
5751        ;;
5752    *)
5753        AC_MSG_ERROR([Unknown --with-help=$with_help])
5754        ;;
5755    esac
5756else
5757    AC_MSG_RESULT([no])
5758fi
5759AC_SUBST([ENABLE_HTMLHELP])
5760AC_SUBST([HELP_ONLINE])
5761
5762AC_MSG_CHECKING([whether to enable xapian-omega support for help])
5763if test -n "$with_omindex" -a "$with_omindex" != "no" -a $_os != iOS -a $_os != Android; then
5764    BUILD_TYPE="$BUILD_TYPE HELP"
5765    GIT_NEEDED_SUBMODULES="helpcontent2 $GIT_NEEDED_SUBMODULES"
5766    case "$with_omindex" in
5767    "server")
5768        ENABLE_HTMLHELP=TRUE
5769        HELP_ONLINE=TRUE
5770        HELP_OMINDEX_PAGE=TRUE
5771        AC_MSG_RESULT([SERVER])
5772        ;;
5773    "noxap")
5774        ENABLE_HTMLHELP=TRUE
5775        HELP_ONLINE=TRUE
5776        HELP_OMINDEX_PAGE=FALSE
5777        AC_MSG_RESULT([NOXAP])
5778        ;;
5779    *)
5780        AC_MSG_ERROR([Unknown --with-omindex=$with_omindex])
5781        ;;
5782    esac
5783else
5784    HELP_OMINDEX_PAGE=FALSE
5785    AC_MSG_RESULT([no])
5786fi
5787AC_SUBST([ENABLE_HTMLHELP])
5788AC_SUBST([HELP_OMINDEX_PAGE])
5789AC_SUBST([HELP_ONLINE])
5790
5791
5792dnl Test whether to include MySpell dictionaries
5793dnl ===================================================================
5794AC_MSG_CHECKING([whether to include MySpell dictionaries])
5795if test "$with_myspell_dicts" = "yes"; then
5796    AC_MSG_RESULT([yes])
5797    WITH_MYSPELL_DICTS=TRUE
5798    BUILD_TYPE="$BUILD_TYPE DICTIONARIES"
5799    GIT_NEEDED_SUBMODULES="dictionaries $GIT_NEEDED_SUBMODULES"
5800else
5801    AC_MSG_RESULT([no])
5802    WITH_MYSPELL_DICTS=
5803fi
5804AC_SUBST(WITH_MYSPELL_DICTS)
5805
5806# There are no "system" myspell, hyphen or mythes dictionaries on macOS, Windows, Android or iOS.
5807if test $_os = Darwin -o $_os = WINNT -o $_os = iOS -o $_os = Android; then
5808    if test "$with_system_dicts" = yes; then
5809        AC_MSG_ERROR([There are no system dicts on this OS in the formats the 3rd-party libs we use expect]);
5810    fi
5811    with_system_dicts=no
5812fi
5813
5814AC_MSG_CHECKING([whether to use dicts from external paths])
5815if test -z "$with_system_dicts" -o "$with_system_dicts" != "no"; then
5816    AC_MSG_RESULT([yes])
5817    SYSTEM_DICTS=TRUE
5818    AC_MSG_CHECKING([for spelling dictionary directory])
5819    if test -n "$with_external_dict_dir"; then
5820        DICT_SYSTEM_DIR=file://$with_external_dict_dir
5821    else
5822        DICT_SYSTEM_DIR=file:///usr/share/hunspell
5823        if test ! -d /usr/share/hunspell -a -d /usr/share/myspell; then
5824            DICT_SYSTEM_DIR=file:///usr/share/myspell
5825        fi
5826    fi
5827    AC_MSG_RESULT([$DICT_SYSTEM_DIR])
5828    AC_MSG_CHECKING([for hyphenation patterns directory])
5829    if test -n "$with_external_hyph_dir"; then
5830        HYPH_SYSTEM_DIR=file://$with_external_hyph_dir
5831    else
5832        HYPH_SYSTEM_DIR=file:///usr/share/hyphen
5833    fi
5834    AC_MSG_RESULT([$HYPH_SYSTEM_DIR])
5835    AC_MSG_CHECKING([for thesaurus directory])
5836    if test -n "$with_external_thes_dir"; then
5837        THES_SYSTEM_DIR=file://$with_external_thes_dir
5838    else
5839        THES_SYSTEM_DIR=file:///usr/share/mythes
5840    fi
5841    AC_MSG_RESULT([$THES_SYSTEM_DIR])
5842else
5843    AC_MSG_RESULT([no])
5844    SYSTEM_DICTS=
5845fi
5846AC_SUBST(SYSTEM_DICTS)
5847AC_SUBST(DICT_SYSTEM_DIR)
5848AC_SUBST(HYPH_SYSTEM_DIR)
5849AC_SUBST(THES_SYSTEM_DIR)
5850
5851dnl ===================================================================
5852dnl Precompiled headers.
5853ENABLE_PCH=""
5854AC_MSG_CHECKING([whether to enable pch feature])
5855if test -z "$enable_pch"; then
5856    if test "$_os" = "WINNT"; then
5857        # Enabled by default on Windows.
5858        enable_pch=yes
5859    else
5860        enable_pch=no
5861    fi
5862fi
5863if test "$enable_pch" != "no" -a "$_os" != "WINNT" -a "$GCC" != "yes" ; then
5864    AC_MSG_ERROR([Precompiled header not yet supported for your platform/compiler])
5865fi
5866if test "$enable_pch" = "system"; then
5867    ENABLE_PCH="1"
5868    AC_MSG_RESULT([yes (system headers)])
5869elif test "$enable_pch" = "base"; then
5870    ENABLE_PCH="2"
5871    AC_MSG_RESULT([yes (system and base headers)])
5872elif test "$enable_pch" = "normal"; then
5873    ENABLE_PCH="3"
5874    AC_MSG_RESULT([yes (normal)])
5875elif test "$enable_pch" = "full"; then
5876    ENABLE_PCH="4"
5877    AC_MSG_RESULT([yes (full)])
5878elif test "$enable_pch" = "yes"; then
5879    # Pick a suitable default.
5880    if test "$GCC" = "yes"; then
5881        # With Clang and GCC higher levels do not seem to make a noticeable improvement,
5882        # while making the PCHs larger and rebuilds more likely.
5883        ENABLE_PCH="2"
5884        AC_MSG_RESULT([yes (system and base headers)])
5885    else
5886        # With MSVC the highest level makes a significant difference,
5887        # and it was the default when there used to be no PCH levels.
5888        ENABLE_PCH="4"
5889        AC_MSG_RESULT([yes (full)])
5890    fi
5891elif test "$enable_pch" = "no"; then
5892    AC_MSG_RESULT([no])
5893else
5894    AC_MSG_ERROR([Unknown value for --enable-pch])
5895fi
5896AC_SUBST(ENABLE_PCH)
5897# ccache 3.7.1 and older do not properly detect/handle -include .gch in CCACHE_DEPEND mode
5898if test -n "$ENABLE_PCH" -a -n "$CCACHE_DEPEND_MODE" -a "$GCC" = "yes" -a "$COM_IS_CLANG" != "TRUE"; then
5899    AC_PATH_PROG([CCACHE_BIN],[ccache],[not found])
5900    if test "$CCACHE_BIN" != "not found"; then
5901        AC_MSG_CHECKING([ccache version])
5902        CCACHE_VERSION=`"$CCACHE_BIN" -V | "$AWK" '/^ccache version/{print $3}'`
5903        CCACHE_NUMVER=`echo $CCACHE_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
5904        AC_MSG_RESULT([$CCACHE_VERSION])
5905        AC_MSG_CHECKING([whether ccache depend mode works properly with GCC PCH])
5906        if test "$CCACHE_NUMVER" -gt "030701"; then
5907            AC_MSG_RESULT([yes])
5908        else
5909            AC_MSG_RESULT([no (not newer than 3.7.1)])
5910            CCACHE_DEPEND_MODE=
5911        fi
5912    fi
5913fi
5914
5915PCH_INSTANTIATE_TEMPLATES=
5916if test -n "$ENABLE_PCH"; then
5917    AC_MSG_CHECKING([whether $CC supports -fpch-instantiate-templates])
5918    save_CFLAGS=$CFLAGS
5919    CFLAGS="$CFLAGS -Werror -fpch-instantiate-templates"
5920    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ PCH_INSTANTIATE_TEMPLATES="-fpch-instantiate-templates" ],[])
5921    CFLAGS=$save_CFLAGS
5922    if test -n "$PCH_INSTANTIATE_TEMPLATES"; then
5923        AC_MSG_RESULT(yes)
5924    else
5925        AC_MSG_RESULT(no)
5926    fi
5927fi
5928AC_SUBST(PCH_INSTANTIATE_TEMPLATES)
5929
5930BUILDING_PCH_WITH_OBJ=
5931if test -n "$ENABLE_PCH"; then
5932    AC_MSG_CHECKING([whether $CC supports -Xclang -building-pch-with-obj])
5933    save_CFLAGS=$CFLAGS
5934    CFLAGS="$CFLAGS -Werror -Xclang -building-pch-with-obj"
5935    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ BUILDING_PCH_WITH_OBJ="-Xclang -building-pch-with-obj" ],[])
5936    CFLAGS=$save_CFLAGS
5937    if test -n "$BUILDING_PCH_WITH_OBJ"; then
5938        AC_MSG_RESULT(yes)
5939    else
5940        AC_MSG_RESULT(no)
5941    fi
5942fi
5943AC_SUBST(BUILDING_PCH_WITH_OBJ)
5944
5945PCH_CODEGEN=
5946PCH_NO_CODEGEN=
5947if test -n "$BUILDING_PCH_WITH_OBJ"; then
5948    AC_MSG_CHECKING([whether $CC supports -fpch-codegen])
5949    save_CFLAGS=$CFLAGS
5950    CFLAGS="$CFLAGS -Werror -fpch-codegen"
5951    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],
5952        [
5953        PCH_CODEGEN="-fpch-codegen"
5954        PCH_NO_CODEGEN="-fno-pch-codegen"
5955        ],[])
5956    CFLAGS=$save_CFLAGS
5957    if test -n "$PCH_CODEGEN"; then
5958        AC_MSG_RESULT(yes)
5959    else
5960        AC_MSG_RESULT(no)
5961    fi
5962fi
5963AC_SUBST(PCH_CODEGEN)
5964AC_SUBST(PCH_NO_CODEGEN)
5965PCH_DEBUGINFO=
5966if test -n "$BUILDING_PCH_WITH_OBJ"; then
5967    AC_MSG_CHECKING([whether $CC supports -fpch-debuginfo])
5968    save_CFLAGS=$CFLAGS
5969    CFLAGS="$CFLAGS -Werror -fpch-debuginfo"
5970    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ PCH_DEBUGINFO="-fpch-debuginfo" ],[])
5971    CFLAGS=$save_CFLAGS
5972    if test -n "$PCH_DEBUGINFO"; then
5973        AC_MSG_RESULT(yes)
5974    else
5975        AC_MSG_RESULT(no)
5976    fi
5977fi
5978AC_SUBST(PCH_DEBUGINFO)
5979
5980TAB=`printf '\t'`
5981
5982AC_MSG_CHECKING([the GNU Make version])
5983_make_version=`$GNUMAKE --version | grep GNU | $GREP -v GPL | $SED -e 's@^[[^0-9]]*@@' -e 's@ .*@@' -e 's@,.*@@'`
5984_make_longver=`echo $_make_version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
5985if test "$_make_longver" -ge "038200"; then
5986    AC_MSG_RESULT([$GNUMAKE $_make_version])
5987
5988elif test "$_make_longver" -ge "038100"; then
5989    if test "$build_os" = "cygwin"; then
5990        AC_MSG_ERROR([failed ($GNUMAKE version >= 3.82 needed])
5991    fi
5992    AC_MSG_RESULT([$GNUMAKE $_make_version])
5993
5994    dnl ===================================================================
5995    dnl Search all the common names for sha1sum
5996    dnl ===================================================================
5997    AC_CHECK_PROGS(SHA1SUM, sha1sum sha1 shasum openssl)
5998    if test -z "$SHA1SUM"; then
5999        AC_MSG_ERROR([install the appropriate SHA-1 checksumming program for this OS])
6000    elif test "$SHA1SUM" = "openssl"; then
6001        SHA1SUM="openssl sha1"
6002    fi
6003    AC_MSG_CHECKING([for GNU Make bug 20033])
6004    TESTGMAKEBUG20033=`mktemp -d tmp.XXXXXX`
6005    $SED -e "s/<TAB>/$TAB/g" > $TESTGMAKEBUG20033/Makefile << EOF
6006A := \$(wildcard *.a)
6007
6008.PHONY: all
6009all: \$(A:.a=.b)
6010<TAB>@echo survived bug20033.
6011
6012.PHONY: setup
6013setup:
6014<TAB>@touch 1.a 2.a 3.a 4.a 5.a 6.a
6015
6016define d1
6017@echo lala \$(1)
6018@sleep 1
6019endef
6020
6021define d2
6022@echo tyty \$(1)
6023@sleep 1
6024endef
6025
6026%.b : %.a
6027<TAB>\$(eval CHECKSUM := \$(word 1,\$(shell cat \$^ | $SHA1SUM))) \$(if \$(wildcard \$(CACHEDIR)/\$(CHECKSUM)),\
6028<TAB>\$(call d1,\$(CHECKSUM)),\
6029<TAB>\$(call d2,\$(CHECKSUM)))
6030EOF
6031    if test -z "`(cd $TESTGMAKEBUG20033 && $GNUMAKE setup && $GNUMAKE -j)|grep survived`"; then
6032        no_parallelism_make="YES"
6033        AC_MSG_RESULT([yes, disable parallelism])
6034    else
6035        AC_MSG_RESULT([no, keep parallelism enabled])
6036    fi
6037    rm -rf $TESTGMAKEBUG20033
6038else
6039    AC_MSG_ERROR([failed ($GNUMAKE version >= 3.81 needed])
6040fi
6041
6042# find if gnumake support file function
6043AC_MSG_CHECKING([whether GNU Make supports the 'file' function])
6044TESTGMAKEFILEFUNC="`mktemp -d -t tst.XXXXXX`"
6045if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
6046    TESTGMAKEFILEFUNC=`cygpath -m $TESTGMAKEFILEFUNC`
6047fi
6048$SED -e "s/<TAB>/$TAB/" > $TESTGMAKEFILEFUNC/Makefile << EOF
6049\$(file >test.txt,Success )
6050
6051.PHONY: all
6052all:
6053<TAB>@cat test.txt
6054
6055EOF
6056$GNUMAKE -C $TESTGMAKEFILEFUNC 2>/dev/null 1>&2
6057if test -f $TESTGMAKEFILEFUNC/test.txt; then
6058    HAVE_GNUMAKE_FILE_FUNC=TRUE
6059    AC_MSG_RESULT([yes])
6060else
6061    AC_MSG_RESULT([no])
6062fi
6063rm -rf $TESTGMAKEFILEFUNC
6064AC_SUBST(HAVE_GNUMAKE_FILE_FUNC)
6065
6066_make_ver_check=`$GNUMAKE --version | grep "Built for Windows"`
6067STALE_MAKE=
6068if test "$_make_ver_check" = ""; then
6069   STALE_MAKE=TRUE
6070fi
6071
6072HAVE_LD_HASH_STYLE=FALSE
6073WITH_LINKER_HASH_STYLE=
6074AC_MSG_CHECKING([for --hash-style gcc linker support])
6075if test "$GCC" = "yes"; then
6076    if test -z "$with_linker_hash_style" -o "$with_linker_hash_style" = "yes"; then
6077        hash_styles="gnu sysv"
6078    elif test "$with_linker_hash_style" = "no"; then
6079        hash_styles=
6080    else
6081        hash_styles="$with_linker_hash_style"
6082    fi
6083
6084    for hash_style in $hash_styles; do
6085        test "$HAVE_LD_HASH_STYLE" = "TRUE" && continue
6086        hash_style_ldflags_save=$LDFLAGS
6087        LDFLAGS="$LDFLAGS -Wl,--hash-style=$hash_style"
6088
6089        AC_RUN_IFELSE([AC_LANG_PROGRAM(
6090            [
6091#include <stdio.h>
6092            ],[
6093printf ("");
6094            ])],
6095            [
6096                  HAVE_LD_HASH_STYLE=TRUE
6097                  WITH_LINKER_HASH_STYLE=$hash_style
6098            ],
6099            [HAVE_LD_HASH_STYLE=FALSE],
6100            [HAVE_LD_HASH_STYLE=FALSE])
6101        LDFLAGS=$hash_style_ldflags_save
6102    done
6103
6104    if test "$HAVE_LD_HASH_STYLE" = "TRUE"; then
6105        AC_MSG_RESULT( $WITH_LINKER_HASH_STYLE )
6106    else
6107        AC_MSG_RESULT( no )
6108    fi
6109    LDFLAGS=$hash_style_ldflags_save
6110else
6111    AC_MSG_RESULT( no )
6112fi
6113AC_SUBST(HAVE_LD_HASH_STYLE)
6114AC_SUBST(WITH_LINKER_HASH_STYLE)
6115
6116dnl ===================================================================
6117dnl Check whether there's a Perl version available.
6118dnl ===================================================================
6119if test -z "$with_perl_home"; then
6120    AC_PATH_PROG(PERL, perl)
6121else
6122    test "$build_os" = "cygwin" && with_perl_home=`cygpath -u "$with_perl_home"`
6123    _perl_path="$with_perl_home/bin/perl"
6124    if test -x "$_perl_path"; then
6125        PERL=$_perl_path
6126    else
6127        AC_MSG_ERROR([$_perl_path not found])
6128    fi
6129fi
6130
6131dnl ===================================================================
6132dnl Testing for Perl version 5 or greater.
6133dnl $] is the Perl version variable, it is returned as an integer
6134dnl ===================================================================
6135if test "$PERL"; then
6136    AC_MSG_CHECKING([the Perl version])
6137    ${PERL} -e "exit($]);"
6138    _perl_version=$?
6139    if test "$_perl_version" -lt 5; then
6140        AC_MSG_ERROR([found Perl $_perl_version, use Perl 5])
6141    fi
6142    AC_MSG_RESULT([Perl $_perl_version])
6143else
6144    AC_MSG_ERROR([Perl not found, install Perl 5])
6145fi
6146
6147dnl ===================================================================
6148dnl Testing for required Perl modules
6149dnl ===================================================================
6150
6151AC_MSG_CHECKING([for required Perl modules])
6152perl_use_string="use Cwd ; use Digest::MD5"
6153if test "$_os" = "WINNT"; then
6154    if test -n "$PKGFORMAT"; then
6155        for i in $PKGFORMAT; do
6156            case "$i" in
6157            msi)
6158                # for getting fonts versions to use in MSI
6159                perl_use_string="$perl_use_string ; use Font::TTF::Font"
6160                ;;
6161            esac
6162        done
6163    fi
6164fi
6165if test "$with_system_hsqldb" = "yes"; then
6166    perl_use_string="$perl_use_string ; use Archive::Zip"
6167fi
6168if test "$enable_openssl" = "yes" -a "$with_system_openssl" != "yes"; then
6169    # OpenSSL needs that to build
6170    perl_use_string="$perl_use_string ; use FindBin"
6171fi
6172if $PERL -e "$perl_use_string">/dev/null 2>&1; then
6173    AC_MSG_RESULT([all modules found])
6174else
6175    AC_MSG_RESULT([failed to find some modules])
6176    # Find out which modules are missing.
6177    for i in $perl_use_string; do
6178        if test "$i" != "use" -a "$i" != ";"; then
6179            if ! $PERL -e "use $i;">/dev/null 2>&1; then
6180                missing_perl_modules="$missing_perl_modules $i"
6181            fi
6182        fi
6183    done
6184    AC_MSG_ERROR([
6185    The missing Perl modules are: $missing_perl_modules
6186    Install them as superuser/administrator with "cpan -i $missing_perl_modules"])
6187fi
6188
6189dnl ===================================================================
6190dnl Check for pkg-config
6191dnl ===================================================================
6192if test "$_os" != "WINNT"; then
6193    PKG_PROG_PKG_CONFIG
6194fi
6195
6196if test "$_os" != "WINNT"; then
6197
6198    # If you use CC=/path/to/compiler/foo-gcc or even CC="ccache
6199    # /path/to/compiler/foo-gcc" you need to set the AR etc env vars
6200    # explicitly. Or put /path/to/compiler in PATH yourself.
6201
6202    # Use wrappers for LTO
6203    if test "$ENABLE_LTO" = "TRUE" -a "$COM_IS_CLANG" != "TRUE"; then
6204        AC_CHECK_TOOL(AR,gcc-ar)
6205        AC_CHECK_TOOL(NM,gcc-nm)
6206        AC_CHECK_TOOL(RANLIB,gcc-ranlib)
6207    else
6208        AC_CHECK_TOOL(AR,ar)
6209        AC_CHECK_TOOL(NM,nm)
6210        AC_CHECK_TOOL(RANLIB,ranlib)
6211    fi
6212    AC_CHECK_TOOL(OBJDUMP,objdump)
6213    AC_CHECK_TOOL(READELF,readelf)
6214    AC_CHECK_TOOL(STRIP,strip)
6215    if test "$_os" = "WINNT"; then
6216        AC_CHECK_TOOL(DLLTOOL,dlltool)
6217        AC_CHECK_TOOL(WINDRES,windres)
6218    fi
6219fi
6220AC_SUBST(AR)
6221AC_SUBST(DLLTOOL)
6222AC_SUBST(LD)
6223AC_SUBST(NM)
6224AC_SUBST(OBJDUMP)
6225AC_SUBST(PKG_CONFIG)
6226AC_SUBST(PKG_CONFIG_PATH)
6227AC_SUBST(PKG_CONFIG_LIBDIR)
6228AC_SUBST(RANLIB)
6229AC_SUBST(READELF)
6230AC_SUBST(STRIP)
6231AC_SUBST(WINDRES)
6232
6233dnl ===================================================================
6234dnl pkg-config checks on macOS
6235dnl ===================================================================
6236
6237if test $_os = Darwin; then
6238    AC_MSG_CHECKING([for bogus pkg-config])
6239    if test -n "$PKG_CONFIG"; then
6240        if test "$PKG_CONFIG" = /usr/bin/pkg-config && ls -l /usr/bin/pkg-config | $GREP -q Mono.framework; then
6241            AC_MSG_ERROR([yes, from Mono. This *will* break the build. Please remove or hide $PKG_CONFIG])
6242        else
6243            if test "$enable_bogus_pkg_config" = "yes"; then
6244                AC_MSG_RESULT([yes, user-approved from unknown origin.])
6245            else
6246                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.])
6247            fi
6248        fi
6249    else
6250        AC_MSG_RESULT([no, good])
6251    fi
6252fi
6253
6254find_csc()
6255{
6256    # Return value: $csctest
6257
6258    unset csctest
6259
6260    reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/NET Framework Setup/NDP/v4/Client/InstallPath"
6261    if test -n "$regvalue"; then
6262        csctest=$regvalue
6263        return
6264    fi
6265}
6266
6267find_al()
6268{
6269    # Return value: $altest
6270
6271    unset altest
6272
6273    # We need this check to detect 4.6.1 or above.
6274    for ver in 4.8 4.7.2 4.7.1 4.7 4.6.2 4.6.1; do
6275        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/NETFXSDK/$ver/WinSDK-NetFx40Tools/InstallationFolder"
6276        if test -n "$regvalue" -a \( -f "$regvalue/al.exe" -o -f "$regvalue/bin/al.exe" \); then
6277            altest=$regvalue
6278            return
6279        fi
6280    done
6281
6282    for x in `ls /proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft\ SDKs/Windows`; do
6283        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/$x/WinSDK-NetFx40Tools/InstallationFolder"
6284        if test -n "$regvalue" -a \( -f "$regvalue/al.exe" -o -f "$regvalue/bin/al.exe" \); then
6285            altest=$regvalue
6286            return
6287        fi
6288    done
6289}
6290
6291find_dotnetsdk46()
6292{
6293    unset frametest
6294
6295    for ver in 4.8 4.7.2 4.7.1 4.7 4.6.2 4.6.1 4.6; do
6296        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/NETFXSDK/$ver/KitsInstallationFolder"
6297        if test -n "$regvalue"; then
6298            frametest=$regvalue
6299            return
6300        fi
6301    done
6302}
6303
6304find_winsdk_version()
6305{
6306    # Args: $1 : SDK version as in "8.0", "8.1A" etc
6307    # Return values: $winsdktest, $winsdkbinsubdir, $winsdklibsubdir
6308
6309    unset winsdktest winsdkbinsubdir winsdklibsubdir
6310
6311    case "$1" in
6312    8.0|8.0A)
6313        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows Kits/Installed Roots/KitsRoot"
6314        if test -n "$regvalue"; then
6315            winsdktest=$regvalue
6316            winsdklibsubdir=win8
6317            return
6318        fi
6319        ;;
6320    8.1|8.1A)
6321        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows Kits/Installed Roots/KitsRoot81"
6322        if test -n "$regvalue"; then
6323            winsdktest=$regvalue
6324            winsdklibsubdir=winv6.3
6325            return
6326        fi
6327        ;;
6328    10.0)
6329        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v${1}/InstallationFolder"
6330        if test -n "$regvalue"; then
6331            winsdktest=$regvalue
6332            reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v${1}/ProductVersion"
6333            if test -n "$regvalue"; then
6334                winsdkbinsubdir="$regvalue".0
6335                winsdklibsubdir=$winsdkbinsubdir
6336                local tmppath="$winsdktest\\Include\\$winsdklibsubdir"
6337                local tmppath_unix=$(cygpath -u "$tmppath")
6338                # test exist the SDK path
6339                if test -d "$tmppath_unix"; then
6340                   # when path is convertible to a short path then path is okay
6341                   cygpath -d "$tmppath" >/dev/null 2>&1
6342                   if test $? -ne 0; then
6343                      AC_MSG_ERROR([Windows SDK doesn't have a 8.3 name, see NtfsDisable8dot3NameCreation])
6344                   fi
6345                else
6346                   AC_MSG_ERROR([The Windows SDK not found, check the installation])
6347                fi
6348            fi
6349            return
6350        fi
6351        ;;
6352    esac
6353}
6354
6355find_winsdk()
6356{
6357    # Return value: From find_winsdk_version
6358
6359    unset winsdktest
6360
6361    for ver in $WINDOWS_SDK_ACCEPTABLE_VERSIONS; do
6362        find_winsdk_version $ver
6363        if test -n "$winsdktest"; then
6364            return
6365        fi
6366    done
6367}
6368
6369find_msms()
6370{
6371    # Return value: $msmdir
6372
6373    AC_MSG_CHECKING([for MSVC merge modules directory])
6374    local my_msm_files=Microsoft_VC${VCVER}_CRT_x86.msm
6375    local my_msm_dir
6376
6377    case "$VCVER" in
6378        160)
6379        my_msm_files="Microsoft_VC141_CRT_x86.msm Microsoft_VC142_CRT_x86.msm ${my_msm_files}"
6380        ;;
6381    esac
6382    for f in $my_msm_files; do
6383        echo "$as_me:$LINENO: searching for $f" >&5
6384    done
6385
6386    msmdir=
6387    for ver in 14.0 15.0; do
6388        reg_get_value_32 HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/VisualStudio/$ver/Setup/VS/MSMDir
6389        if test -n "$regvalue"; then
6390            for f in ${my_msm_files}; do
6391                if test -e "$regvalue/${f}"; then
6392                    msmdir=$regvalue
6393                    break
6394                fi
6395            done
6396        fi
6397    done
6398    dnl Is the following fallback really necessary, or was it added in response
6399    dnl to never having started Visual Studio on a given machine, so the
6400    dnl registry keys checked above had presumably not yet been created?
6401    dnl Anyway, if it really is necessary, it might be worthwhile to extend it
6402    dnl to also check %CommonProgramFiles(X86)% (typically expanding to
6403    dnl "C:\Program Files (X86)\Common Files" compared to %CommonProgramFiles%
6404    dnl expanding to "C:\Program Files\Common Files"), which would need
6405    dnl something like $(perl -e 'print $ENV{"CommonProgramFiles(x86)"}') to
6406    dnl obtain its value from cygwin:
6407    if test -z "$msmdir"; then
6408        my_msm_dir="${COMMONPROGRAMFILES}/Merge Modules/"
6409        for f in ${my_msm_files}; do
6410            if test -e "$my_msm_dir/${f}"; then
6411                msmdir=$my_msm_dir
6412            fi
6413        done
6414    fi
6415
6416    dnl Starting from MSVC 15.0, merge modules are located in different directory
6417    case "$VCVER" in
6418    160)
6419        for l in `ls -1 $VC_PRODUCT_DIR/redist/MSVC/`; do
6420            echo "$as_me:$LINENO: looking in $VC_PRODUCT_DIR/redist/MSVC/$l/MergeModules])" >&5
6421            my_msm_dir="$VC_PRODUCT_DIR/redist/MSVC/$l/MergeModules/"
6422            for f in ${my_msm_files}; do
6423                if test -e "$my_msm_dir/${f}"; then
6424                    msmdir=$my_msm_dir
6425                    break
6426                fi
6427            done
6428        done
6429        ;;
6430    esac
6431
6432    if test -n "$msmdir"; then
6433        msmdir=`cygpath -m "$msmdir"`
6434        AC_MSG_RESULT([$msmdir])
6435    else
6436        if test "$ENABLE_RELEASE_BUILD" = "TRUE" ; then
6437            AC_MSG_FAILURE([not found])
6438        else
6439            AC_MSG_WARN([not found (check config.log)])
6440            add_warning "MSM none of ${my_msm_files} found"
6441        fi
6442    fi
6443}
6444
6445find_msvc_x64_dlls()
6446{
6447    # Return value: $msvcdllpath, $msvcdlls
6448
6449    AC_MSG_CHECKING([for MSVC x64 DLL path])
6450    msvcdllpath="$VC_PRODUCT_DIR/redist/x64/Microsoft.VC${VCVER}.CRT"
6451    case "$VCVER" in
6452    160)
6453        for l in `ls -1 $VC_PRODUCT_DIR/redist/MSVC/`; do
6454            echo "$as_me:$LINENO: testing $VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC141.CRT" >&5
6455            if test -d "$VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC141.CRT"; then
6456                msvcdllpath="$VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC141.CRT"
6457                break
6458            fi
6459            echo "$as_me:$LINENO: testing $VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC142.CRT" >&5
6460            if test -d "$VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC142.CRT"; then
6461                msvcdllpath="$VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC142.CRT"
6462                break
6463            fi
6464        done
6465        ;;
6466    esac
6467    AC_MSG_RESULT([$msvcdllpath])
6468    AC_MSG_CHECKING([for MSVC x64 DLLs])
6469    msvcdlls="msvcp140.dll vcruntime140.dll"
6470    for dll in $msvcdlls; do
6471        if ! test -f "$msvcdllpath/$dll"; then
6472            AC_MSG_FAILURE([missing $dll])
6473        fi
6474    done
6475    AC_MSG_RESULT([found all ($msvcdlls)])
6476}
6477
6478dnl =========================================
6479dnl Check for the Windows  SDK.
6480dnl =========================================
6481if test "$_os" = "WINNT"; then
6482    AC_MSG_CHECKING([for Windows SDK])
6483    if test "$build_os" = "cygwin" -o "$build_os" = "wsl"; then
6484        find_winsdk
6485        WINDOWS_SDK_HOME=$winsdktest
6486
6487        # normalize if found
6488        if test -n "$WINDOWS_SDK_HOME"; then
6489            WINDOWS_SDK_HOME=`cygpath -d "$WINDOWS_SDK_HOME"`
6490            WINDOWS_SDK_HOME=`cygpath -u "$WINDOWS_SDK_HOME"`
6491        fi
6492
6493        WINDOWS_SDK_LIB_SUBDIR=$winsdklibsubdir
6494    fi
6495
6496    if test -n "$WINDOWS_SDK_HOME"; then
6497        # Remove a possible trailing backslash
6498        WINDOWS_SDK_HOME=`echo $WINDOWS_SDK_HOME | $SED 's/\/$//'`
6499
6500        if test -f "$WINDOWS_SDK_HOME/Include/adoint.h" \
6501             -a -f "$WINDOWS_SDK_HOME/Include/SqlUcode.h" \
6502             -a -f "$WINDOWS_SDK_HOME/Include/usp10.h"; then
6503            have_windows_sdk_headers=yes
6504        elif test -f "$WINDOWS_SDK_HOME/Include/um/adoint.h" \
6505             -a -f "$WINDOWS_SDK_HOME/Include/um/SqlUcode.h" \
6506             -a -f "$WINDOWS_SDK_HOME/Include/um/usp10.h"; then
6507            have_windows_sdk_headers=yes
6508        elif test -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/adoint.h" \
6509             -a -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/SqlUcode.h" \
6510             -a -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/usp10.h"; then
6511            have_windows_sdk_headers=yes
6512        else
6513            have_windows_sdk_headers=no
6514        fi
6515
6516        if test -f "$WINDOWS_SDK_HOME/lib/user32.lib"; then
6517            have_windows_sdk_libs=yes
6518        elif test -f "$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/$WIN_BUILD_ARCH/user32.lib"; then
6519            have_windows_sdk_libs=yes
6520        else
6521            have_windows_sdk_libs=no
6522        fi
6523
6524        if test $have_windows_sdk_headers = no -o $have_windows_sdk_libs = no; then
6525            AC_MSG_ERROR([Some (all?) Windows SDK files not found, please check if all needed parts of
6526the  Windows SDK are installed.])
6527        fi
6528    fi
6529
6530    if test -z "$WINDOWS_SDK_HOME"; then
6531        AC_MSG_RESULT([no, hoping the necessary headers and libraries will be found anyway!?])
6532    elif echo $WINDOWS_SDK_HOME | grep "8.0" >/dev/null 2>/dev/null; then
6533        WINDOWS_SDK_VERSION=80
6534        AC_MSG_RESULT([found Windows SDK 8.0 ($WINDOWS_SDK_HOME)])
6535    elif echo $WINDOWS_SDK_HOME | grep "8.1" >/dev/null 2>/dev/null; then
6536        WINDOWS_SDK_VERSION=81
6537        AC_MSG_RESULT([found Windows SDK 8.1 ($WINDOWS_SDK_HOME)])
6538    elif echo $WINDOWS_SDK_HOME | grep "/10" >/dev/null 2>/dev/null; then
6539        WINDOWS_SDK_VERSION=10
6540        AC_MSG_RESULT([found Windows SDK 10.0 ($WINDOWS_SDK_HOME)])
6541    else
6542        AC_MSG_ERROR([Found legacy Windows Platform SDK ($WINDOWS_SDK_HOME)])
6543    fi
6544    PathFormat "$WINDOWS_SDK_HOME"
6545    WINDOWS_SDK_HOME="$formatted_path"
6546    WINDOWS_SDK_HOME_unix="$formatted_path_unix"
6547    if test "$build_os" = "cygwin" -o "$build_os" = "wsl"; then
6548        SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/include -I$COMPATH/Include"
6549        if test -d "$WINDOWS_SDK_HOME/include/um"; then
6550            SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/include/um -I$WINDOWS_SDK_HOME/include/shared"
6551        elif test -d "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um"; then
6552            SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um -I$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/shared"
6553        fi
6554    fi
6555
6556    dnl TODO: solenv/bin/modules/installer/windows/msiglobal.pm wants to use a
6557    dnl WiLangId.vbs that is included only in some SDKs (e.g., included in v7.1
6558    dnl but not in v8.0), so allow this to be overridden with a
6559    dnl WINDOWS_SDK_WILANGID for now; a full-blown --with-windows-sdk-wilangid
6560    dnl and configuration error if no WiLangId.vbs is found would arguably be
6561    dnl better, but I do not know under which conditions exactly it is needed by
6562    dnl msiglobal.pm:
6563    if test -z "$WINDOWS_SDK_WILANGID" -a -n "$WINDOWS_SDK_HOME"; then
6564        WINDOWS_SDK_WILANGID=$WINDOWS_SDK_HOME/Samples/sysmgmt/msi/scripts/WiLangId.vbs
6565        WINDOWS_SDK_WILANGID_unix=$(cygpath -u "$WINDOWS_SDK_WILANGID")
6566        if ! test -e "$WINDOWS_SDK_WILANGID_unix" ; then
6567            WINDOWS_SDK_WILANGID="${WINDOWS_SDK_HOME}/bin/${WINDOWS_SDK_LIB_SUBDIR}/${WIN_BUILD_ARCH}/WiLangId.vbs"
6568            WINDOWS_SDK_WILANGID_unix=$(cygpath -u "$WINDOWS_SDK_WILANGID")
6569        fi
6570        if ! test -e "$WINDOWS_SDK_WILANGID_unix" ; then
6571            WINDOWS_SDK_WILANGID=$WINDOWS_SDK_HOME/bin/$WIN_BUILD_ARCH/WiLangId.vbs
6572            WINDOWS_SDK_WILANGID_unix=$(cygpath -u "$WINDOWS_SDK_WILANGID")
6573        fi
6574        if ! test -e "$WINDOWS_SDK_WILANGID_unix" ; then
6575            WINDOWS_SDK_WILANGID=$(cygpath -sm "C:/Program Files (x86)/Windows Kits/8.1/bin/$WIN_BUILD_ARCH/WiLangId.vbs")
6576            WINDOWS_SDK_WILANGID_unix=$(cygpath -u "$WINDOWS_SDK_WILANGID")
6577        fi
6578    fi
6579    if test -n "$with_lang" -a "$with_lang" != "en-US"; then
6580        if test -n "$with_package_format" -a "$with_package_format" != no; then
6581            for i in "$with_package_format"; do
6582                if test "$i" = "msi"; then
6583                    if ! test -e "$WINDOWS_SDK_WILANGID_unix" ; then
6584                        AC_MSG_ERROR([WiLangId.vbs not found - building translated packages will fail])
6585                    fi
6586                fi
6587            done
6588        fi
6589    fi
6590fi
6591AC_SUBST(WINDOWS_SDK_HOME)
6592AC_SUBST(WINDOWS_SDK_LIB_SUBDIR)
6593AC_SUBST(WINDOWS_SDK_VERSION)
6594AC_SUBST(WINDOWS_SDK_WILANGID)
6595
6596if test "$build_os" = "cygwin"; then
6597    dnl Check midl.exe; this being the first check for a tool in the SDK bin
6598    dnl dir, it also determines that dir's path w/o an arch segment if any,
6599    dnl WINDOWS_SDK_BINDIR_NO_ARCH:
6600    AC_MSG_CHECKING([for midl.exe])
6601
6602    find_winsdk
6603    if test -n "$winsdkbinsubdir" \
6604        -a -f "$winsdktest/Bin/$winsdkbinsubdir/$WIN_BUILD_ARCH/midl.exe"
6605    then
6606        MIDL_PATH=$winsdktest/Bin/$winsdkbinsubdir/$WIN_BUILD_ARCH
6607        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME/Bin/$winsdkbinsubdir
6608    elif test -f "$winsdktest/Bin/$WIN_BUILD_ARCH/midl.exe"; then
6609        MIDL_PATH=$winsdktest/Bin/$WIN_BUILD_ARCH
6610        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME/Bin
6611    elif test -f "$winsdktest/Bin/midl.exe"; then
6612        MIDL_PATH=$winsdktest/Bin
6613        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME/Bin
6614    fi
6615    if test ! -f "$MIDL_PATH/midl.exe"; then
6616        AC_MSG_ERROR([midl.exe not found in $winsdktest/Bin/$WIN_BUILD_ARCH, Windows SDK installation broken?])
6617    else
6618        AC_MSG_RESULT([$MIDL_PATH/midl.exe])
6619    fi
6620
6621    # Convert to posix path with 8.3 filename restrictions ( No spaces )
6622    MIDL_PATH=`win_short_path_for_make "$MIDL_PATH"`
6623
6624    if test -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msiinfo.exe" \
6625         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msidb.exe" \
6626         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/uuidgen.exe" \
6627         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msitran.exe"; then :
6628    elif test -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msiinfo.exe" \
6629         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msidb.exe" \
6630         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/uuidgen.exe" \
6631         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msitran.exe"; then :
6632    elif test -f "$WINDOWS_SDK_HOME/bin/x86/msiinfo.exe" \
6633         -a -f "$WINDOWS_SDK_HOME/bin/x86/msidb.exe" \
6634         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/uuidgen.exe" \
6635         -a -f "$WINDOWS_SDK_HOME/bin/x86/msitran.exe"; then :
6636    else
6637        AC_MSG_ERROR([Some (all?) Windows Installer tools in the Windows SDK are missing, please install.])
6638    fi
6639
6640    dnl Check csc.exe
6641    AC_MSG_CHECKING([for csc.exe])
6642    find_csc
6643    if test -f "$csctest/csc.exe"; then
6644        CSC_PATH="$csctest"
6645    fi
6646    if test ! -f "$CSC_PATH/csc.exe"; then
6647        AC_MSG_ERROR([csc.exe not found as $CSC_PATH/csc.exe])
6648    else
6649        AC_MSG_RESULT([$CSC_PATH/csc.exe])
6650    fi
6651
6652    CSC_PATH=`win_short_path_for_make "$CSC_PATH"`
6653
6654    dnl Check al.exe
6655    AC_MSG_CHECKING([for al.exe])
6656    find_winsdk
6657    if test -n "$winsdkbinsubdir" \
6658        -a -f "$winsdktest/Bin/$winsdkbinsubdir/$WIN_BUILD_ARCH/al.exe"
6659    then
6660        AL_PATH="$winsdktest/Bin/$winsdkbinsubdir/$WIN_BUILD_ARCH"
6661    elif test -f "$winsdktest/Bin/$WIN_BUILD_ARCH/al.exe"; then
6662        AL_PATH="$winsdktest/Bin/$WIN_BUILD_ARCH"
6663    elif test -f "$winsdktest/Bin/al.exe"; then
6664        AL_PATH="$winsdktest/Bin"
6665    fi
6666
6667    if test -z "$AL_PATH"; then
6668        find_al
6669        if test -f "$altest/bin/al.exe"; then
6670            AL_PATH="$altest/bin"
6671        elif test -f "$altest/al.exe"; then
6672            AL_PATH="$altest"
6673        fi
6674    fi
6675    if test ! -f "$AL_PATH/al.exe"; then
6676        AC_MSG_ERROR([al.exe not found as $AL_PATH/al.exe])
6677    else
6678        AC_MSG_RESULT([$AL_PATH/al.exe])
6679    fi
6680
6681    AL_PATH=`win_short_path_for_make "$AL_PATH"`
6682
6683    dnl Check mscoree.lib / .NET Framework dir
6684    AC_MSG_CHECKING(.NET Framework)
6685    find_dotnetsdk46
6686    PathFormat "$frametest"
6687    frametest="$formatted_path"
6688    if test -f "$frametest/Lib/um/$WIN_BUILD_ARCH/mscoree.lib"; then
6689        DOTNET_FRAMEWORK_HOME="$frametest"
6690    else
6691        find_winsdk
6692        if test -f "$winsdktest/lib/mscoree.lib" -o -f "$winsdktest/lib/$winsdklibsubdir/um/$WIN_BUILD_ARCH/mscoree.lib"; then
6693            DOTNET_FRAMEWORK_HOME="$winsdktest"
6694        fi
6695    fi
6696    if test ! -f "$DOTNET_FRAMEWORK_HOME/lib/mscoree.lib" -a ! -f "$DOTNET_FRAMEWORK_HOME/lib/$winsdklibsubdir/um/$WIN_BUILD_ARCH/mscoree.lib" -a ! -f "$DOTNET_FRAMEWORK_HOME/Lib/um/$WIN_BUILD_ARCH/mscoree.lib"; then
6697        AC_MSG_ERROR([mscoree.lib not found])
6698    fi
6699    AC_MSG_RESULT([found: $DOTNET_FRAMEWORK_HOME])
6700
6701    PathFormat "$MIDL_PATH"
6702    MIDL_PATH="$formatted_path"
6703
6704    PathFormat "$AL_PATH"
6705    AL_PATH="$formatted_path"
6706
6707    PathFormat "$DOTNET_FRAMEWORK_HOME"
6708    DOTNET_FRAMEWORK_HOME="$formatted_path"
6709
6710    PathFormat "$CSC_PATH"
6711    CSC_PATH="$formatted_path"
6712fi
6713
6714dnl ===================================================================
6715dnl Testing for C++ compiler and version...
6716dnl ===================================================================
6717
6718if test "$_os" != "WINNT"; then
6719    # AC_PROG_CXX sets CXXFLAGS to -g -O2 if not set, avoid that
6720    save_CXXFLAGS=$CXXFLAGS
6721    AC_PROG_CXX
6722    CXXFLAGS=$save_CXXFLAGS
6723    if test -z "$CXX_BASE"; then
6724        CXX_BASE=`first_arg_basename "$CXX"`
6725    fi
6726fi
6727
6728dnl check for GNU C++ compiler version
6729if test "$GXX" = "yes" -a -z "$COM_IS_CLANG"; then
6730    AC_MSG_CHECKING([the GNU C++ compiler version])
6731
6732    _gpp_version=`$CXX -dumpversion`
6733    _gpp_majmin=`echo $_gpp_version | $AWK -F. '{ print \$1*100+\$2 }'`
6734
6735    if test "$_gpp_majmin" -lt "700"; then
6736        AC_MSG_ERROR([You need to use GNU C++ compiler version >= 7.0 to build LibreOffice, you have $_gpp_version.])
6737    else
6738        AC_MSG_RESULT([ok (g++ $_gpp_version)])
6739    fi
6740
6741    dnl see https://code.google.com/p/android/issues/detail?id=41770
6742        glibcxx_threads=no
6743        AC_LANG_PUSH([C++])
6744        AC_REQUIRE_CPP
6745        AC_MSG_CHECKING([whether $CXX_BASE is broken with boost.thread])
6746        AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
6747            #include <bits/c++config.h>]],[[
6748            #if !defined(_GLIBCXX_HAVE_GTHR_DEFAULT) \
6749            && !defined(_GLIBCXX__PTHREADS) \
6750            && !defined(_GLIBCXX_HAS_GTHREADS)
6751            choke me
6752            #endif
6753        ]])],[AC_MSG_RESULT([yes])
6754        glibcxx_threads=yes],[AC_MSG_RESULT([no])])
6755        AC_LANG_POP([C++])
6756        if test $glibcxx_threads = yes; then
6757            BOOST_CXXFLAGS="-D_GLIBCXX_HAS_GTHREADS"
6758        fi
6759fi
6760AC_SUBST(BOOST_CXXFLAGS)
6761
6762#
6763# prefx CXX with ccache if needed
6764#
6765UNCACHED_CXX="$CXX"
6766if test "$CCACHE" != ""; then
6767    AC_MSG_CHECKING([whether $CXX_BASE is already ccached])
6768    AC_LANG_PUSH([C++])
6769    save_CXXFLAGS=$CXXFLAGS
6770    CXXFLAGS="$CXXFLAGS --ccache-skip -O2"
6771    dnl an empty program will do, we're checking the compiler flags
6772    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
6773                      [use_ccache=yes], [use_ccache=no])
6774    if test $use_ccache = yes -a "${CCACHE/*sccache*/}" != ""; then
6775        AC_MSG_RESULT([yes])
6776    else
6777        CXX="$CCACHE $CXX"
6778        CXX_BASE="ccache $CXX_BASE"
6779        AC_MSG_RESULT([no])
6780    fi
6781    CXXFLAGS=$save_CXXFLAGS
6782    AC_LANG_POP([C++])
6783fi
6784
6785dnl ===================================================================
6786dnl Find pre-processors.(should do that _after_ messing with CC/CXX)
6787dnl ===================================================================
6788
6789if test "$_os" != "WINNT"; then
6790    AC_PROG_CXXCPP
6791
6792    dnl Check whether there's a C pre-processor.
6793    AC_PROG_CPP
6794fi
6795
6796
6797dnl ===================================================================
6798dnl Find integral type sizes and alignments
6799dnl ===================================================================
6800
6801if test "$_os" != "WINNT"; then
6802
6803    AC_CHECK_SIZEOF(long)
6804    AC_CHECK_SIZEOF(short)
6805    AC_CHECK_SIZEOF(int)
6806    AC_CHECK_SIZEOF(long long)
6807    AC_CHECK_SIZEOF(double)
6808    AC_CHECK_SIZEOF(void*)
6809
6810    SAL_TYPES_SIZEOFSHORT=$ac_cv_sizeof_short
6811    SAL_TYPES_SIZEOFINT=$ac_cv_sizeof_int
6812    SAL_TYPES_SIZEOFLONG=$ac_cv_sizeof_long
6813    SAL_TYPES_SIZEOFLONGLONG=$ac_cv_sizeof_long_long
6814    SAL_TYPES_SIZEOFPOINTER=$ac_cv_sizeof_voidp
6815
6816    dnl Allow build without AC_CHECK_ALIGNOF, grrr
6817    m4_pattern_allow([AC_CHECK_ALIGNOF])
6818    m4_ifdef([AC_CHECK_ALIGNOF],
6819        [
6820            AC_CHECK_ALIGNOF(short,[#include <stddef.h>])
6821            AC_CHECK_ALIGNOF(int,[#include <stddef.h>])
6822            AC_CHECK_ALIGNOF(long,[#include <stddef.h>])
6823            AC_CHECK_ALIGNOF(double,[#include <stddef.h>])
6824        ],
6825        [
6826            case "$_os-$host_cpu" in
6827            Linux-i686)
6828                test -z "$ac_cv_alignof_short" && ac_cv_alignof_short=2
6829                test -z "$ac_cv_alignof_int" && ac_cv_alignof_int=4
6830                test -z "$ac_cv_alignof_long" && ac_cv_alignof_long=4
6831                test -z "$ac_cv_alignof_double" && ac_cv_alignof_double=4
6832                ;;
6833            Linux-x86_64)
6834                test -z "$ac_cv_alignof_short" && ac_cv_alignof_short=2
6835                test -z "$ac_cv_alignof_int" && ac_cv_alignof_int=4
6836                test -z "$ac_cv_alignof_long" && ac_cv_alignof_long=8
6837                test -z "$ac_cv_alignof_double" && ac_cv_alignof_double=8
6838                ;;
6839            *)
6840                if test -z "$ac_cv_alignof_short" -o \
6841                        -z "$ac_cv_alignof_int" -o \
6842                        -z "$ac_cv_alignof_long" -o \
6843                        -z "$ac_cv_alignof_double"; then
6844                   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.])
6845                fi
6846                ;;
6847            esac
6848        ])
6849
6850    SAL_TYPES_ALIGNMENT2=$ac_cv_alignof_short
6851    SAL_TYPES_ALIGNMENT4=$ac_cv_alignof_int
6852    if test $ac_cv_sizeof_long -eq 8; then
6853        SAL_TYPES_ALIGNMENT8=$ac_cv_alignof_long
6854    elif test $ac_cv_sizeof_double -eq 8; then
6855        SAL_TYPES_ALIGNMENT8=$ac_cv_alignof_double
6856    else
6857        AC_MSG_ERROR([Cannot find alignment of 8 byte types.])
6858    fi
6859
6860    dnl Check for large file support
6861    AC_SYS_LARGEFILE
6862    if test -n "$ac_cv_sys_file_offset_bits" -a "$ac_cv_sys_file_offset_bits" != "no"; then
6863        LFS_CFLAGS="-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
6864    fi
6865    if test -n "$ac_cv_sys_large_files" -a "$ac_cv_sys_large_files" != "no"; then
6866        LFS_CFLAGS="$LFS_CFLAGS -D_LARGE_FILES"
6867    fi
6868else
6869    # Hardcode for MSVC
6870    SAL_TYPES_SIZEOFSHORT=2
6871    SAL_TYPES_SIZEOFINT=4
6872    SAL_TYPES_SIZEOFLONG=4
6873    SAL_TYPES_SIZEOFLONGLONG=8
6874    if test $WIN_HOST_BITS -eq 32; then
6875        SAL_TYPES_SIZEOFPOINTER=4
6876    else
6877        SAL_TYPES_SIZEOFPOINTER=8
6878    fi
6879    SAL_TYPES_ALIGNMENT2=2
6880    SAL_TYPES_ALIGNMENT4=4
6881    SAL_TYPES_ALIGNMENT8=8
6882    LFS_CFLAGS=''
6883fi
6884AC_SUBST(LFS_CFLAGS)
6885
6886AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFSHORT,$SAL_TYPES_SIZEOFSHORT)
6887AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFINT,$SAL_TYPES_SIZEOFINT)
6888AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFLONG,$SAL_TYPES_SIZEOFLONG)
6889AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFLONGLONG,$SAL_TYPES_SIZEOFLONGLONG)
6890AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFPOINTER,$SAL_TYPES_SIZEOFPOINTER)
6891AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT2,$SAL_TYPES_ALIGNMENT2)
6892AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT4,$SAL_TYPES_ALIGNMENT4)
6893AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT8,$SAL_TYPES_ALIGNMENT8)
6894
6895dnl ===================================================================
6896dnl Check whether to enable runtime optimizations
6897dnl ===================================================================
6898ENABLE_RUNTIME_OPTIMIZATIONS=
6899AC_MSG_CHECKING([whether to enable runtime optimizations])
6900if test -z "$enable_runtime_optimizations"; then
6901    for i in $CC; do
6902        case $i in
6903        -fsanitize=*)
6904            enable_runtime_optimizations=no
6905            break
6906            ;;
6907        esac
6908    done
6909fi
6910if test "$enable_runtime_optimizations" != no; then
6911    ENABLE_RUNTIME_OPTIMIZATIONS=TRUE
6912    AC_DEFINE(ENABLE_RUNTIME_OPTIMIZATIONS)
6913    AC_MSG_RESULT([yes])
6914else
6915    AC_MSG_RESULT([no])
6916fi
6917AC_SUBST([ENABLE_RUNTIME_OPTIMIZATIONS])
6918
6919dnl ===================================================================
6920dnl Check if valgrind headers are available
6921dnl ===================================================================
6922ENABLE_VALGRIND=
6923if test "$cross_compiling" != yes -a "$with_valgrind" != no; then
6924    prev_cppflags=$CPPFLAGS
6925    # Is VALGRIND_CFLAGS something one is supposed to have in the environment,
6926    # or where does it come from?
6927    CPPFLAGS="$CPPFLAGS $VALGRIND_CFLAGS"
6928    AC_CHECK_HEADER([valgrind/valgrind.h],
6929        [ENABLE_VALGRIND=TRUE])
6930    CPPFLAGS=$prev_cppflags
6931fi
6932AC_SUBST([ENABLE_VALGRIND])
6933if test -z "$ENABLE_VALGRIND"; then
6934    if test "$with_valgrind" = yes; then
6935        AC_MSG_ERROR([--with-valgrind specified but no Valgrind headers found])
6936    fi
6937    VALGRIND_CFLAGS=
6938fi
6939AC_SUBST([VALGRIND_CFLAGS])
6940
6941
6942dnl ===================================================================
6943dnl Check if SDT probes (for systemtap, gdb, dtrace) are available
6944dnl ===================================================================
6945
6946# We need at least the sys/sdt.h include header.
6947AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND='TRUE'], [SDT_H_FOUND='FALSE'])
6948if test "$SDT_H_FOUND" = "TRUE"; then
6949    # Found sys/sdt.h header, now make sure the c++ compiler works.
6950    # Old g++ versions had problems with probes in constructors/destructors.
6951    AC_MSG_CHECKING([working sys/sdt.h and c++ support])
6952    AC_LANG_PUSH([C++])
6953    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
6954    #include <sys/sdt.h>
6955    class ProbeClass
6956    {
6957    private:
6958      int& ref;
6959      const char *name;
6960
6961    public:
6962      ProbeClass(int& v, const char *n) : ref(v), name(n)
6963      {
6964        DTRACE_PROBE2(_test_, cons, name, ref);
6965      }
6966
6967      void method(int min)
6968      {
6969        DTRACE_PROBE3(_test_, meth, name, ref, min);
6970        ref -= min;
6971      }
6972
6973      ~ProbeClass()
6974      {
6975        DTRACE_PROBE2(_test_, dest, name, ref);
6976      }
6977    };
6978    ]],[[
6979    int i = 64;
6980    DTRACE_PROBE1(_test_, call, i);
6981    ProbeClass inst = ProbeClass(i, "call");
6982    inst.method(24);
6983    ]])], [AC_MSG_RESULT([yes]); AC_DEFINE([USE_SDT_PROBES])],
6984          [AC_MSG_RESULT([no, sdt.h or c++ compiler too old])])
6985    AC_LANG_POP([C++])
6986fi
6987AC_CONFIG_HEADERS([config_host/config_probes.h])
6988
6989dnl ===================================================================
6990dnl GCC features
6991dnl ===================================================================
6992HAVE_GCC_STACK_CLASH_PROTECTION=
6993if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
6994    AC_MSG_CHECKING([whether $CC_BASE supports -fstack-clash-protection])
6995    save_CFLAGS=$CFLAGS
6996    CFLAGS="$CFLAGS -Werror -fstack-clash-protection"
6997    AC_LINK_IFELSE(
6998        [AC_LANG_PROGRAM(, [[return 0;]])],
6999        [AC_MSG_RESULT([yes]); HAVE_GCC_STACK_CLASH_PROTECTION=TRUE],
7000        [AC_MSG_RESULT([no])])
7001    CFLAGS=$save_CFLAGS
7002
7003    AC_MSG_CHECKING([whether $CC_BASE supports -mno-avx])
7004    save_CFLAGS=$CFLAGS
7005    CFLAGS="$CFLAGS -Werror -mno-avx"
7006    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_AVX=TRUE ],[])
7007    CFLAGS=$save_CFLAGS
7008    if test "$HAVE_GCC_AVX" = "TRUE"; then
7009        AC_MSG_RESULT([yes])
7010    else
7011        AC_MSG_RESULT([no])
7012    fi
7013
7014    AC_MSG_CHECKING([whether $CC_BASE supports atomic functions])
7015    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
7016    int v = 0;
7017    if (__sync_add_and_fetch(&v, 1) != 1 ||
7018        __sync_sub_and_fetch(&v, 1) != 0)
7019        return 1;
7020    __sync_synchronize();
7021    if (__sync_val_compare_and_swap(&v, 0, 1) != 0 ||
7022        v != 1)
7023        return 1;
7024    return 0;
7025]])],[HAVE_GCC_BUILTIN_ATOMIC=TRUE],[])
7026    if test "$HAVE_GCC_BUILTIN_ATOMIC" = "TRUE"; then
7027        AC_MSG_RESULT([yes])
7028        AC_DEFINE(HAVE_GCC_BUILTIN_ATOMIC)
7029    else
7030        AC_MSG_RESULT([no])
7031    fi
7032
7033    AC_MSG_CHECKING([whether $CXX_BASE defines __base_class_type_info in cxxabi.h])
7034    AC_LANG_PUSH([C++])
7035    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7036            #include <cstddef>
7037            #include <cxxabi.h>
7038            std::size_t f() { return sizeof(__cxxabiv1::__base_class_type_info); }
7039        ])], [
7040            AC_DEFINE([HAVE_CXXABI_H_BASE_CLASS_TYPE_INFO],[1])
7041            AC_MSG_RESULT([yes])
7042        ], [AC_MSG_RESULT([no])])
7043    AC_LANG_POP([C++])
7044
7045    AC_MSG_CHECKING([whether $CXX_BASE defines __class_type_info in cxxabi.h])
7046    AC_LANG_PUSH([C++])
7047    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7048            #include <cstddef>
7049            #include <cxxabi.h>
7050            std::size_t f() { return sizeof(__cxxabiv1::__class_type_info); }
7051        ])], [
7052            AC_DEFINE([HAVE_CXXABI_H_CLASS_TYPE_INFO],[1])
7053            AC_MSG_RESULT([yes])
7054        ], [AC_MSG_RESULT([no])])
7055    AC_LANG_POP([C++])
7056
7057    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_allocate_exception in cxxabi.h])
7058    AC_LANG_PUSH([C++])
7059    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7060            #include <cxxabi.h>
7061            void * f() { return __cxxabiv1::__cxa_allocate_exception(0); }
7062        ])], [
7063            AC_DEFINE([HAVE_CXXABI_H_CXA_ALLOCATE_EXCEPTION],[1])
7064            AC_MSG_RESULT([yes])
7065        ], [AC_MSG_RESULT([no])])
7066    AC_LANG_POP([C++])
7067
7068    AC_MSG_CHECKING([whether $CXX_BASE defines __cxa_eh_globals in cxxabi.h])
7069    AC_LANG_PUSH([C++])
7070    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7071            #include <cstddef>
7072            #include <cxxabi.h>
7073            std::size_t f() { return sizeof(__cxxabiv1::__cxa_eh_globals); }
7074        ])], [
7075            AC_DEFINE([HAVE_CXXABI_H_CXA_EH_GLOBALS],[1])
7076            AC_MSG_RESULT([yes])
7077        ], [AC_MSG_RESULT([no])])
7078    AC_LANG_POP([C++])
7079
7080    AC_MSG_CHECKING([whether $CXX_BASE defines __cxa_exception in cxxabi.h])
7081    AC_LANG_PUSH([C++])
7082    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7083            #include <cstddef>
7084            #include <cxxabi.h>
7085            std::size_t f() { return sizeof(__cxxabiv1::__cxa_exception); }
7086        ])], [
7087            AC_DEFINE([HAVE_CXXABI_H_CXA_EXCEPTION],[1])
7088            AC_MSG_RESULT([yes])
7089        ], [AC_MSG_RESULT([no])])
7090    AC_LANG_POP([C++])
7091
7092    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_get_globals in cxxabi.h])
7093    AC_LANG_PUSH([C++])
7094    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7095            #include <cxxabi.h>
7096            void * f() { return __cxxabiv1::__cxa_get_globals(); }
7097        ])], [
7098            AC_DEFINE([HAVE_CXXABI_H_CXA_GET_GLOBALS],[1])
7099            AC_MSG_RESULT([yes])
7100        ], [AC_MSG_RESULT([no])])
7101    AC_LANG_POP([C++])
7102
7103    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_current_exception_type in cxxabi.h])
7104    AC_LANG_PUSH([C++])
7105    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7106            #include <cxxabi.h>
7107            void * f() { return __cxxabiv1::__cxa_current_exception_type(); }
7108        ])], [
7109            AC_DEFINE([HAVE_CXXABI_H_CXA_CURRENT_EXCEPTION_TYPE],[1])
7110            AC_MSG_RESULT([yes])
7111        ], [AC_MSG_RESULT([no])])
7112    AC_LANG_POP([C++])
7113
7114    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_throw in cxxabi.h])
7115    AC_LANG_PUSH([C++])
7116    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7117            #include <cxxabi.h>
7118            void f() { __cxxabiv1::__cxa_throw(0, 0, 0); }
7119        ])], [
7120            AC_DEFINE([HAVE_CXXABI_H_CXA_THROW],[1])
7121            AC_MSG_RESULT([yes])
7122        ], [AC_MSG_RESULT([no])])
7123    AC_LANG_POP([C++])
7124
7125    AC_MSG_CHECKING([whether $CXX_BASE defines __si_class_type_info in cxxabi.h])
7126    AC_LANG_PUSH([C++])
7127    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7128            #include <cstddef>
7129            #include <cxxabi.h>
7130            std::size_t f() { return sizeof(__cxxabiv1::__si_class_type_info); }
7131        ])], [
7132            AC_DEFINE([HAVE_CXXABI_H_SI_CLASS_TYPE_INFO],[1])
7133            AC_MSG_RESULT([yes])
7134        ], [AC_MSG_RESULT([no])])
7135    AC_LANG_POP([C++])
7136
7137    AC_MSG_CHECKING([whether $CXX_BASE defines __vmi_class_type_info in cxxabi.h])
7138    AC_LANG_PUSH([C++])
7139    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7140            #include <cstddef>
7141            #include <cxxabi.h>
7142            std::size_t f() { return sizeof(__cxxabiv1::__vmi_class_type_info); }
7143        ])], [
7144            AC_DEFINE([HAVE_CXXABI_H_VMI_CLASS_TYPE_INFO],[1])
7145            AC_MSG_RESULT([yes])
7146        ], [AC_MSG_RESULT([no])])
7147    AC_LANG_POP([C++])
7148fi
7149
7150AC_SUBST(HAVE_GCC_AVX)
7151AC_SUBST(HAVE_GCC_BUILTIN_ATOMIC)
7152AC_SUBST(HAVE_GCC_STACK_CLASH_PROTECTION)
7153
7154dnl ===================================================================
7155dnl Identify the C++ library
7156dnl ===================================================================
7157
7158AC_MSG_CHECKING([what the C++ library is])
7159AC_LANG_PUSH([C++])
7160AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
7161#include <utility>
7162#ifndef __GLIBCXX__
7163foo bar
7164#endif
7165]])],
7166    [CPP_LIBRARY=GLIBCXX
7167     cpp_library_name="GNU libstdc++"
7168    ],
7169    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
7170#include <utility>
7171#ifndef _LIBCPP_VERSION
7172foo bar
7173#endif
7174]])],
7175    [CPP_LIBRARY=LIBCPP
7176     cpp_library_name="LLVM libc++"
7177     AC_DEFINE([HAVE_LIBCXX])
7178    ],
7179    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
7180#include <utility>
7181#ifndef _MSC_VER
7182foo bar
7183#endif
7184]])],
7185    [CPP_LIBRARY=MSVCRT
7186     cpp_library_name="Microsoft"
7187    ],
7188    AC_MSG_ERROR([Could not figure out what C++ library this is]))))
7189AC_MSG_RESULT([$cpp_library_name])
7190AC_LANG_POP([C++])
7191
7192dnl ===================================================================
7193dnl Check for gperf
7194dnl ===================================================================
7195AC_PATH_PROG(GPERF, gperf)
7196if test -z "$GPERF"; then
7197    AC_MSG_ERROR([gperf not found but needed. Install it.])
7198fi
7199if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
7200    GPERF=`cygpath -m $GPERF`
7201fi
7202AC_MSG_CHECKING([whether gperf is new enough])
7203my_gperf_ver1=$($GPERF --version | head -n 1)
7204my_gperf_ver2=${my_gperf_ver1#GNU gperf }
7205my_gperf_ver3=$(printf %s "$my_gperf_ver2" | $AWK -F. '{ print $1*100+($2<100?$2:99) }')
7206if test "$my_gperf_ver3" -ge 301; then
7207    AC_MSG_RESULT([yes ($my_gperf_ver2)])
7208else
7209    AC_MSG_ERROR(["$my_gperf_ver1" is too old or unrecognized, must be at least gperf 3.1])
7210fi
7211AC_SUBST(GPERF)
7212
7213dnl ===================================================================
7214dnl Check for system libcmis
7215dnl ===================================================================
7216# libcmis requires curl and we can't build curl for iOS
7217if test "$test_cmis" = "yes" -a "$enable_cmis" = "yes"; then
7218    libo_CHECK_SYSTEM_MODULE([libcmis],[LIBCMIS],[libcmis-0.5 >= 0.5.2])
7219    ENABLE_LIBCMIS=TRUE
7220else
7221    ENABLE_LIBCMIS=
7222fi
7223AC_SUBST(ENABLE_LIBCMIS)
7224
7225dnl ===================================================================
7226dnl C++11
7227dnl ===================================================================
7228
7229AC_MSG_CHECKING([whether $CXX_BASE supports C++17])
7230CXXFLAGS_CXX11=
7231if test "$COM" = MSC -a "$COM_IS_CLANG" != TRUE; then
7232    if test "$with_latest_c__" = yes; then
7233        CXXFLAGS_CXX11=-std:c++latest
7234    else
7235        CXXFLAGS_CXX11=-std:c++17
7236    fi
7237    CXXFLAGS_CXX11="$CXXFLAGS_CXX11 -permissive- -Zc:__cplusplus"
7238elif test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
7239    my_flags='-std=c++17 -std=c++1z'
7240    if test "$with_latest_c__" = yes; then
7241        my_flags="-std=c++23 -std=c++2b -std=c++20 -std=c++2a $my_flags"
7242    fi
7243    for flag in $my_flags; do
7244        if test "$COM" = MSC; then
7245            flag="-Xclang $flag"
7246        fi
7247        save_CXXFLAGS=$CXXFLAGS
7248        CXXFLAGS="$CXXFLAGS $flag -Werror"
7249        if test "$SYSTEM_LIBCMIS" = TRUE; then
7250            CXXFLAGS="$CXXFLAGS -DSYSTEM_LIBCMIS $LIBCMIS_CFLAGS"
7251        fi
7252        AC_LANG_PUSH([C++])
7253        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
7254            #include <algorithm>
7255            #include <functional>
7256            #include <vector>
7257
7258            #if defined SYSTEM_LIBCMIS
7259            // See ucb/source/ucp/cmis/auth_provider.hxx:
7260            #if !defined __clang__
7261            #pragma GCC diagnostic push
7262            #pragma GCC diagnostic ignored "-Wdeprecated"
7263            #pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
7264            #endif
7265            #include <libcmis/libcmis.hxx>
7266            #if !defined __clang__
7267            #pragma GCC diagnostic pop
7268            #endif
7269            #endif
7270
7271            void f(std::vector<int> & v, std::function<bool(int, int)> fn) {
7272                std::sort(v.begin(), v.end(), fn);
7273            }
7274            ]])],[CXXFLAGS_CXX11=$flag])
7275        AC_LANG_POP([C++])
7276        CXXFLAGS=$save_CXXFLAGS
7277        if test -n "$CXXFLAGS_CXX11"; then
7278            break
7279        fi
7280    done
7281fi
7282if test -n "$CXXFLAGS_CXX11"; then
7283    AC_MSG_RESULT([yes ($CXXFLAGS_CXX11)])
7284else
7285    AC_MSG_ERROR(no)
7286fi
7287AC_SUBST(CXXFLAGS_CXX11)
7288
7289if test "$GCC" = "yes"; then
7290    save_CXXFLAGS=$CXXFLAGS
7291    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
7292    CHECK_L_ATOMIC
7293    CXXFLAGS=$save_CXXFLAGS
7294    AC_SUBST(ATOMIC_LIB)
7295fi
7296
7297dnl Test for temporarily incompatible libstdc++ 4.7.{0,1}, where
7298dnl <https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=179528> introduced
7299dnl an additional member _M_size into C++11 std::list towards 4.7.0 and
7300dnl <https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=189186> removed it
7301dnl again towards 4.7.2:
7302if test $CPP_LIBRARY = GLIBCXX; then
7303    AC_MSG_CHECKING([whether using C++11 causes libstdc++ 4.7.0/4.7.1 ABI breakage])
7304    AC_LANG_PUSH([C++])
7305    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
7306#include <list>
7307#if !defined __GLIBCXX__ || (__GLIBCXX__ != 20120322 && __GLIBCXX__ != 20120614)
7308    // according to <https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html>:
7309    //   GCC 4.7.0: 20120322
7310    //   GCC 4.7.1: 20120614
7311    // and using a range check is not possible as the mapping between
7312    // __GLIBCXX__ values and GCC versions is not monotonic
7313/* ok */
7314#else
7315abi broken
7316#endif
7317        ]])], [AC_MSG_RESULT(no, ok)],
7318        [AC_MSG_ERROR(yes)])
7319    AC_LANG_POP([C++])
7320fi
7321
7322AC_MSG_CHECKING([whether $CXX_BASE supports C++11 without Language Defect 757])
7323save_CXXFLAGS=$CXXFLAGS
7324CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
7325AC_LANG_PUSH([C++])
7326
7327AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
7328#include <stddef.h>
7329
7330template <typename T, size_t S> char (&sal_n_array_size( T(&)[S] ))[S];
7331
7332namespace
7333{
7334        struct b
7335        {
7336                int i;
7337                int j;
7338        };
7339}
7340]], [[
7341struct a
7342{
7343        int i;
7344        int j;
7345};
7346a thinga[]={{0,0}, {1,1}};
7347b thingb[]={{0,0}, {1,1}};
7348size_t i = sizeof(sal_n_array_size(thinga));
7349size_t j = sizeof(sal_n_array_size(thingb));
7350return !(i != 0 && j != 0);
7351]])
7352    ], [ AC_MSG_RESULT(yes) ],
7353    [ AC_MSG_ERROR(no)])
7354AC_LANG_POP([C++])
7355CXXFLAGS=$save_CXXFLAGS
7356
7357HAVE_GCC_FNO_SIZED_DEALLOCATION=
7358if test "$GCC" = yes; then
7359    AC_MSG_CHECKING([whether $CXX_BASE supports -fno-sized-deallocation])
7360    AC_LANG_PUSH([C++])
7361    save_CXXFLAGS=$CXXFLAGS
7362    CXXFLAGS="$CXXFLAGS -fno-sized-deallocation"
7363    AC_LINK_IFELSE([AC_LANG_PROGRAM()],[HAVE_GCC_FNO_SIZED_DEALLOCATION=TRUE])
7364    CXXFLAGS=$save_CXXFLAGS
7365    AC_LANG_POP([C++])
7366    if test "$HAVE_GCC_FNO_SIZED_DEALLOCATION" = TRUE; then
7367        AC_MSG_RESULT([yes])
7368    else
7369        AC_MSG_RESULT([no])
7370    fi
7371fi
7372AC_SUBST([HAVE_GCC_FNO_SIZED_DEALLOCATION])
7373
7374AC_MSG_CHECKING([whether $CXX_BASE supports a working C++20 consteval])
7375dnl ...that does not suffer from <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96994> "Missing code
7376dnl from consteval constructor initializing const variable",
7377dnl <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98752> "wrong 'error: ‘this’ is not a constant
7378dnl expression' with consteval constructor", or <https://bugs.llvm.org/show_bug.cgi?id=50063> "code
7379dnl using consteval: 'clang/lib/CodeGen/Address.h:38: llvm::Value*
7380dnl clang::CodeGen::Address::getPointer() const: Assertion `isValid()' failed.'":
7381AC_LANG_PUSH([C++])
7382save_CXXFLAGS=$CXXFLAGS
7383CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
7384AC_RUN_IFELSE([AC_LANG_PROGRAM([
7385        struct S {
7386            consteval S() { i = 1; }
7387            int i = 0;
7388        };
7389        S const s;
7390
7391        struct S1 { consteval S1(int) {} };
7392        struct S2 {
7393            S1 x;
7394            S2(): x(0) {}
7395        };
7396
7397        struct S3 {
7398            consteval S3() {}
7399            union {
7400                int a;
7401                unsigned b = 0;
7402            };
7403        };
7404        void f() { S3(); }
7405    ], [
7406        return (s.i == 1) ? 0 : 1;
7407    ])], [
7408        AC_DEFINE([HAVE_CPP_CONSTEVAL],[1])
7409        AC_MSG_RESULT([yes])
7410    ], [AC_MSG_RESULT([no])], [AC_MSG_RESULT([assumed no (cross compiling)])])
7411CXXFLAGS=$save_CXXFLAGS
7412AC_LANG_POP([C++])
7413
7414AC_MSG_CHECKING([whether $CXX_BASE supports C++2a constinit sorted vectors])
7415AC_LANG_PUSH([C++])
7416save_CXXFLAGS=$CXXFLAGS
7417CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
7418AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7419        #include <algorithm>
7420        #include <initializer_list>
7421        #include <vector>
7422        template<typename T> class S {
7423        private:
7424            std::vector<T> v_;
7425        public:
7426            constexpr S(std::initializer_list<T> i): v_(i) { std::sort(v_.begin(), v_.end()); }
7427        };
7428        constinit S<int> s{3, 2, 1};
7429    ])], [
7430        AC_DEFINE([HAVE_CPP_CONSTINIT_SORTED_VECTOR],[1])
7431        AC_MSG_RESULT([yes])
7432    ], [AC_MSG_RESULT([no])])
7433CXXFLAGS=$save_CXXFLAGS
7434AC_LANG_POP([C++])
7435
7436AC_MSG_CHECKING([whether $CXX_BASE supports C++2a <span> with unsigned size_type])
7437AC_LANG_PUSH([C++])
7438save_CXXFLAGS=$CXXFLAGS
7439CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
7440AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7441        #include <span>
7442        #include <type_traits>
7443        // Don't check size_type directly, as it was called index_type before P1872R0:
7444        void f(std::span<int> s) { static_assert(std::is_unsigned_v<decltype(s.size())>); };
7445    ])], [
7446        AC_DEFINE([HAVE_CPP_SPAN],[1])
7447        AC_MSG_RESULT([yes])
7448    ], [AC_MSG_RESULT([no])])
7449CXXFLAGS=$save_CXXFLAGS
7450AC_LANG_POP([C++])
7451
7452AC_MSG_CHECKING([whether $CXX_BASE implements C++ DR P1155R3])
7453AC_LANG_PUSH([C++])
7454save_CXXFLAGS=$CXXFLAGS
7455CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
7456AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7457        struct S1 { S1(S1 &&); };
7458        struct S2: S1 {};
7459        S1 f(S2 s) { return s; }
7460    ])], [
7461        AC_DEFINE([HAVE_P1155R3],[1])
7462        AC_MSG_RESULT([yes])
7463    ], [AC_MSG_RESULT([no])])
7464CXXFLAGS=$save_CXXFLAGS
7465AC_LANG_POP([C++])
7466
7467dnl Supported since GCC 9 and Clang 10 (which each also started to support -Wdeprecated-copy, but
7468dnl which is included in -Wextra anyway):
7469HAVE_WDEPRECATED_COPY_DTOR=
7470if test "$GCC" = yes; then
7471    AC_MSG_CHECKING([whether $CXX_BASE supports -Wdeprecated-copy-dtor])
7472    AC_LANG_PUSH([C++])
7473    save_CXXFLAGS=$CXXFLAGS
7474    CXXFLAGS="$CXXFLAGS -Werror -Wdeprecated-copy-dtor"
7475    AC_COMPILE_IFELSE([AC_LANG_SOURCE()], [
7476            HAVE_WDEPRECATED_COPY_DTOR=TRUE
7477            AC_MSG_RESULT([yes])
7478        ], [AC_MSG_RESULT([no])])
7479    CXXFLAGS=$save_CXXFLAGS
7480    AC_LANG_POP([C++])
7481fi
7482AC_SUBST([HAVE_WDEPRECATED_COPY_DTOR])
7483
7484dnl At least GCC 8.2 with -O2 (i.e., --enable-optimized) causes a false-positive -Wmaybe-
7485dnl uninitialized warning for code like
7486dnl
7487dnl   OString f();
7488dnl   boost::optional<OString> * g(bool b) {
7489dnl       boost::optional<OString> o;
7490dnl       if (b) o = f();
7491dnl       return new boost::optional<OString>(o);
7492dnl   }
7493dnl
7494dnl (as is e.g. present, in a slightly more elaborate form, in
7495dnl librdf_TypeConverter::extractNode_NoLock in unoxml/source/rdf/librdf_repository.cxx); the below
7496dnl code is meant to be a faithfully stripped-down and self-contained version of the above code:
7497HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED=
7498if test "$GCC" = yes && test "$COM_IS_CLANG" != TRUE; then
7499    AC_MSG_CHECKING([whether $CXX_BASE might report false -Werror=maybe-uninitialized])
7500    AC_LANG_PUSH([C++])
7501    save_CXXFLAGS=$CXXFLAGS
7502    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11 -Werror -Wmaybe-uninitialized"
7503    if test "$ENABLE_OPTIMIZED" = TRUE; then
7504        CXXFLAGS="$CXXFLAGS -O2"
7505    else
7506        CXXFLAGS="$CXXFLAGS -O0"
7507    fi
7508    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
7509            #include <new>
7510            void f1(int);
7511            struct S1 {
7512                ~S1() { f1(n); }
7513                int n = 0;
7514            };
7515            struct S2 {
7516                S2() {}
7517                S2(S2 const & s) { if (s.init) set(*reinterpret_cast<S1 const *>(s.stg)); }
7518                ~S2() { if (init) reinterpret_cast<S1 *>(stg)->S1::~S1(); }
7519                void set(S1 s) {
7520                    new (stg) S1(s);
7521                    init = true;
7522                }
7523                bool init = false;
7524                char stg[sizeof (S1)];
7525            } ;
7526            S1 f2();
7527            S2 * f3(bool b) {
7528                S2 o;
7529                if (b) o.set(f2());
7530                return new S2(o);
7531            }
7532        ]])], [AC_MSG_RESULT([no])], [
7533            HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED=TRUE
7534            AC_MSG_RESULT([yes])
7535        ])
7536    CXXFLAGS=$save_CXXFLAGS
7537    AC_LANG_POP([C++])
7538fi
7539AC_SUBST([HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED])
7540
7541dnl Check for <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87296#c5> "[8/9/10/11 Regression]
7542dnl -Wstringop-overflow false positive due to using MEM_REF type of &MEM" (fixed in GCC 11), which
7543dnl hits us e.g. with GCC 10 and --enable-optimized at
7544dnl
7545dnl   In file included from include/rtl/string.hxx:49,
7546dnl                    from include/rtl/ustring.hxx:43,
7547dnl                    from include/osl/file.hxx:35,
7548dnl                    from include/codemaker/global.hxx:28,
7549dnl                    from include/codemaker/options.hxx:23,
7550dnl                    from codemaker/source/commoncpp/commoncpp.cxx:24:
7551dnl   In function ‘char* rtl::addDataHelper(char*, const char*, std::size_t)’,
7552dnl       inlined from ‘static char* rtl::ToStringHelper<const char [N]>::addData(char*, const char*) [with long unsigned int N = 3]’ at include/rtl/stringconcat.hxx:147:85,
7553dnl       inlined from ‘char* rtl::OStringConcat<T1, T2>::addData(char*) const [with T1 = const char [3]; T2 = rtl::OString]’ at include/rtl/stringconcat.hxx:226:103,
7554dnl       inlined from ‘rtl::OStringBuffer& rtl::OStringBuffer::append(rtl::OStringConcat<T1, T2>&&) [with T1 = const char [3]; T2 = rtl::OString]’ at include/rtl/strbuf.hxx:599:30,
7555dnl       inlined from ‘rtl::OString codemaker::cpp::scopedCppName(const rtl::OString&, bool)’ at codemaker/source/commoncpp/commoncpp.cxx:53:55:
7556dnl   include/rtl/stringconcat.hxx:78:15: error: writing 2 bytes into a region of size 1 [-Werror=stringop-overflow=]
7557dnl      78 |         memcpy( buffer, data, length );
7558dnl         |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
7559HAVE_BROKEN_GCC_WSTRINGOP_OVERFLOW=
7560if test "$GCC" = yes && test "$COM_IS_CLANG" != TRUE; then
7561    AC_MSG_CHECKING([whether $CXX_BASE might report false -Werror=stringop-overflow=])
7562    AC_LANG_PUSH([C++])
7563    save_CXXFLAGS=$CXXFLAGS
7564    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11 -Werror -Wstringop-overflow"
7565    if test "$ENABLE_OPTIMIZED" = TRUE; then
7566        CXXFLAGS="$CXXFLAGS -O2"
7567    else
7568        CXXFLAGS="$CXXFLAGS -O0"
7569    fi
7570    dnl Test code taken from <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87296#c0>:
7571    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
7572            void fill(char const * begin, char const * end, char c);
7573            struct q {
7574                char ids[4];
7575                char username[6];
7576            };
7577            void test(q & c) {
7578                fill(c.ids, c.ids + sizeof(c.ids), '\0');
7579                __builtin_strncpy(c.username, "root", sizeof(c.username));
7580            }
7581        ]])], [AC_MSG_RESULT([no])], [
7582            HAVE_BROKEN_GCC_WSTRINGOP_OVERFLOW=TRUE
7583            AC_MSG_RESULT([yes])
7584        ])
7585    CXXFLAGS=$save_CXXFLAGS
7586    AC_LANG_POP([C++])
7587fi
7588AC_SUBST([HAVE_BROKEN_GCC_WSTRINGOP_OVERFLOW])
7589
7590dnl ===================================================================
7591dnl CPU Intrinsics support - SSE, AVX
7592dnl ===================================================================
7593
7594CXXFLAGS_INTRINSICS_SSE2=
7595CXXFLAGS_INTRINSICS_SSSE3=
7596CXXFLAGS_INTRINSICS_SSE41=
7597CXXFLAGS_INTRINSICS_SSE42=
7598CXXFLAGS_INTRINSICS_AVX=
7599CXXFLAGS_INTRINSICS_AVX2=
7600CXXFLAGS_INTRINSICS_AVX512=
7601CXXFLAGS_INTRINSICS_F16C=
7602CXXFLAGS_INTRINSICS_FMA=
7603
7604if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
7605    # GCC, Clang or Clang-cl (clang-cl + MSVC's -arch options don't work well together)
7606    flag_sse2=-msse2
7607    flag_ssse3=-mssse3
7608    flag_sse41=-msse4.1
7609    flag_sse42=-msse4.2
7610    flag_avx=-mavx
7611    flag_avx2=-mavx2
7612    flag_avx512="-mavx512f -mavx512vl -mavx512bw -mavx512dq -mavx512cd"
7613    flag_f16c=-mf16c
7614    flag_fma=-mfma
7615else
7616    # https://docs.microsoft.com/en-us/cpp/build/reference/arch-x86
7617    # MSVC seems to differentiate only between SSE and SSE2, where in fact
7618    # SSE2 seems to be SSE2+.
7619    # Even if -arch:SSE2 is the default, set it explicitly, so that the variable
7620    # is not empty (and can be tested in gbuild).
7621    flag_sse2=-arch:SSE2
7622    flag_ssse3=-arch:SSE2
7623    flag_sse41=-arch:SSE2
7624    flag_sse42=-arch:SSE2
7625    flag_avx=-arch:AVX
7626    flag_avx2=-arch:AVX2
7627    flag_avx512=-arch:AVX512
7628    # These are part of -arch:AVX2
7629    flag_f16c=-arch:AVX2
7630    flag_fma=-arch:AVX2
7631fi
7632
7633AC_MSG_CHECKING([whether $CXX can compile SSE2 intrinsics])
7634AC_LANG_PUSH([C++])
7635save_CXXFLAGS=$CXXFLAGS
7636CXXFLAGS="$CXXFLAGS $flag_sse2"
7637AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7638    #include <emmintrin.h>
7639    int main () {
7640        __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
7641        c = _mm_xor_si128 (a, b);
7642        return 0;
7643    }
7644    ])],
7645    [can_compile_sse2=yes],
7646    [can_compile_sse2=no])
7647AC_LANG_POP([C++])
7648CXXFLAGS=$save_CXXFLAGS
7649AC_MSG_RESULT([${can_compile_sse2}])
7650if test "${can_compile_sse2}" = "yes" ; then
7651    CXXFLAGS_INTRINSICS_SSE2="$flag_sse2"
7652fi
7653
7654AC_MSG_CHECKING([whether $CXX can compile SSSE3 intrinsics])
7655AC_LANG_PUSH([C++])
7656save_CXXFLAGS=$CXXFLAGS
7657CXXFLAGS="$CXXFLAGS $flag_ssse3"
7658AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7659    #include <tmmintrin.h>
7660    int main () {
7661        __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
7662        c = _mm_maddubs_epi16 (a, b);
7663        return 0;
7664    }
7665    ])],
7666    [can_compile_ssse3=yes],
7667    [can_compile_ssse3=no])
7668AC_LANG_POP([C++])
7669CXXFLAGS=$save_CXXFLAGS
7670AC_MSG_RESULT([${can_compile_ssse3}])
7671if test "${can_compile_ssse3}" = "yes" ; then
7672    CXXFLAGS_INTRINSICS_SSSE3="$flag_ssse3"
7673fi
7674
7675AC_MSG_CHECKING([whether $CXX can compile SSE4.1 intrinsics])
7676AC_LANG_PUSH([C++])
7677save_CXXFLAGS=$CXXFLAGS
7678CXXFLAGS="$CXXFLAGS $flag_sse41"
7679AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7680    #include <smmintrin.h>
7681    int main () {
7682        __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
7683        c = _mm_cmpeq_epi64 (a, b);
7684        return 0;
7685    }
7686    ])],
7687    [can_compile_sse41=yes],
7688    [can_compile_sse41=no])
7689AC_LANG_POP([C++])
7690CXXFLAGS=$save_CXXFLAGS
7691AC_MSG_RESULT([${can_compile_sse41}])
7692if test "${can_compile_sse41}" = "yes" ; then
7693    CXXFLAGS_INTRINSICS_SSE41="$flag_sse41"
7694fi
7695
7696AC_MSG_CHECKING([whether $CXX can compile SSE4.2 intrinsics])
7697AC_LANG_PUSH([C++])
7698save_CXXFLAGS=$CXXFLAGS
7699CXXFLAGS="$CXXFLAGS $flag_sse42"
7700AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7701    #include <nmmintrin.h>
7702    int main () {
7703        __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
7704        c = _mm_cmpgt_epi64 (a, b);
7705        return 0;
7706    }
7707    ])],
7708    [can_compile_sse42=yes],
7709    [can_compile_sse42=no])
7710AC_LANG_POP([C++])
7711CXXFLAGS=$save_CXXFLAGS
7712AC_MSG_RESULT([${can_compile_sse42}])
7713if test "${can_compile_sse42}" = "yes" ; then
7714    CXXFLAGS_INTRINSICS_SSE42="$flag_sse42"
7715fi
7716
7717AC_MSG_CHECKING([whether $CXX can compile AVX intrinsics])
7718AC_LANG_PUSH([C++])
7719save_CXXFLAGS=$CXXFLAGS
7720CXXFLAGS="$CXXFLAGS $flag_avx"
7721AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7722    #include <immintrin.h>
7723    int main () {
7724        __m256 a = _mm256_set1_ps (0.0f), b = _mm256_set1_ps (0.0f), c;
7725        c = _mm256_xor_ps(a, b);
7726        return 0;
7727    }
7728    ])],
7729    [can_compile_avx=yes],
7730    [can_compile_avx=no])
7731AC_LANG_POP([C++])
7732CXXFLAGS=$save_CXXFLAGS
7733AC_MSG_RESULT([${can_compile_avx}])
7734if test "${can_compile_avx}" = "yes" ; then
7735    CXXFLAGS_INTRINSICS_AVX="$flag_avx"
7736fi
7737
7738AC_MSG_CHECKING([whether $CXX can compile AVX2 intrinsics])
7739AC_LANG_PUSH([C++])
7740save_CXXFLAGS=$CXXFLAGS
7741CXXFLAGS="$CXXFLAGS $flag_avx2"
7742AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7743    #include <immintrin.h>
7744    int main () {
7745        __m256i a = _mm256_set1_epi32 (0), b = _mm256_set1_epi32 (0), c;
7746        c = _mm256_maddubs_epi16(a, b);
7747        return 0;
7748    }
7749    ])],
7750    [can_compile_avx2=yes],
7751    [can_compile_avx2=no])
7752AC_LANG_POP([C++])
7753CXXFLAGS=$save_CXXFLAGS
7754AC_MSG_RESULT([${can_compile_avx2}])
7755if test "${can_compile_avx2}" = "yes" ; then
7756    CXXFLAGS_INTRINSICS_AVX2="$flag_avx2"
7757fi
7758
7759AC_MSG_CHECKING([whether $CXX can compile AVX512 intrinsics])
7760AC_LANG_PUSH([C++])
7761save_CXXFLAGS=$CXXFLAGS
7762CXXFLAGS="$CXXFLAGS $flag_avx512"
7763AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7764    #include <immintrin.h>
7765    int main () {
7766        __m512i a = _mm512_loadu_si512(0);
7767        return 0;
7768    }
7769    ])],
7770    [can_compile_avx512=yes],
7771    [can_compile_avx512=no])
7772AC_LANG_POP([C++])
7773CXXFLAGS=$save_CXXFLAGS
7774AC_MSG_RESULT([${can_compile_avx512}])
7775if test "${can_compile_avx512}" = "yes" ; then
7776    CXXFLAGS_INTRINSICS_AVX512="$flag_avx512"
7777fi
7778
7779AC_MSG_CHECKING([whether $CXX can compile F16C intrinsics])
7780AC_LANG_PUSH([C++])
7781save_CXXFLAGS=$CXXFLAGS
7782CXXFLAGS="$CXXFLAGS $flag_f16c"
7783AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7784    #include <immintrin.h>
7785    int main () {
7786        __m128i a = _mm_set1_epi32 (0);
7787        __m128 c;
7788        c = _mm_cvtph_ps(a);
7789        return 0;
7790    }
7791    ])],
7792    [can_compile_f16c=yes],
7793    [can_compile_f16c=no])
7794AC_LANG_POP([C++])
7795CXXFLAGS=$save_CXXFLAGS
7796AC_MSG_RESULT([${can_compile_f16c}])
7797if test "${can_compile_f16c}" = "yes" ; then
7798    CXXFLAGS_INTRINSICS_F16C="$flag_f16c"
7799fi
7800
7801AC_MSG_CHECKING([whether $CXX can compile FMA intrinsics])
7802AC_LANG_PUSH([C++])
7803save_CXXFLAGS=$CXXFLAGS
7804CXXFLAGS="$CXXFLAGS $flag_fma"
7805AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7806    #include <immintrin.h>
7807    int main () {
7808        __m256 a = _mm256_set1_ps (0.0f), b = _mm256_set1_ps (0.0f), c = _mm256_set1_ps (0.0f), d;
7809        d = _mm256_fmadd_ps(a, b, c);
7810        return 0;
7811    }
7812    ])],
7813    [can_compile_fma=yes],
7814    [can_compile_fma=no])
7815AC_LANG_POP([C++])
7816CXXFLAGS=$save_CXXFLAGS
7817AC_MSG_RESULT([${can_compile_fma}])
7818if test "${can_compile_fma}" = "yes" ; then
7819    CXXFLAGS_INTRINSICS_FMA="$flag_fma"
7820fi
7821
7822AC_SUBST([CXXFLAGS_INTRINSICS_SSE2])
7823AC_SUBST([CXXFLAGS_INTRINSICS_SSSE3])
7824AC_SUBST([CXXFLAGS_INTRINSICS_SSE41])
7825AC_SUBST([CXXFLAGS_INTRINSICS_SSE42])
7826AC_SUBST([CXXFLAGS_INTRINSICS_AVX])
7827AC_SUBST([CXXFLAGS_INTRINSICS_AVX2])
7828AC_SUBST([CXXFLAGS_INTRINSICS_AVX512])
7829AC_SUBST([CXXFLAGS_INTRINSICS_F16C])
7830AC_SUBST([CXXFLAGS_INTRINSICS_FMA])
7831
7832dnl ===================================================================
7833dnl system stl sanity tests
7834dnl ===================================================================
7835if test "$_os" != "WINNT"; then
7836
7837    AC_LANG_PUSH([C++])
7838
7839    save_CPPFLAGS="$CPPFLAGS"
7840    if test -n "$MACOSX_SDK_PATH"; then
7841        CPPFLAGS="-isysroot $MACOSX_SDK_PATH $CPPFLAGS"
7842    fi
7843
7844    # Assume visibility is not broken with libc++. The below test is very much designed for libstdc++
7845    # only.
7846    if test "$CPP_LIBRARY" = GLIBCXX; then
7847        dnl gcc#19664, gcc#22482, rhbz#162935
7848        AC_MSG_CHECKING([if STL headers are visibility safe (GCC bug 22482)])
7849        AC_EGREP_HEADER(visibility push, string, stlvisok=yes, stlvisok=no)
7850        AC_MSG_RESULT([$stlvisok])
7851        if test "$stlvisok" = "no"; then
7852            AC_MSG_ERROR([Your libstdc++ headers are not visibility safe. This is no longer supported.])
7853        fi
7854    fi
7855
7856    # As the below test checks things when linking self-compiled dynamic libraries, it presumably is irrelevant
7857    # when we don't make any dynamic libraries?
7858    if test "$DISABLE_DYNLOADING" = ""; then
7859        AC_MSG_CHECKING([if $CXX_BASE is -fvisibility-inlines-hidden safe (Clang bug 11250)])
7860        cat > conftestlib1.cc <<_ACEOF
7861template<typename T> struct S1 { virtual ~S1() {} virtual void f() {} };
7862struct S2: S1<int> { virtual ~S2(); };
7863S2::~S2() {}
7864_ACEOF
7865        cat > conftestlib2.cc <<_ACEOF
7866template<typename T> struct S1 { virtual ~S1() {} virtual void f() {} };
7867struct S2: S1<int> { virtual ~S2(); };
7868struct S3: S2 { virtual ~S3(); }; S3::~S3() {}
7869_ACEOF
7870        gccvisinlineshiddenok=yes
7871        if ! $CXX $CXXFLAGS $CPPFLAGS $LINKFLAGSSHL -fPIC -fvisibility-inlines-hidden conftestlib1.cc -o libconftest1$DLLPOST >/dev/null 2>&5; then
7872            gccvisinlineshiddenok=no
7873        else
7874            dnl At least Clang -fsanitize=address and -fsanitize=undefined are
7875            dnl known to not work with -z defs (unsetting which makes the test
7876            dnl moot, though):
7877            my_linkflagsnoundefs=$LINKFLAGSNOUNDEFS
7878            if test "$COM_IS_CLANG" = TRUE; then
7879                for i in $CXX $CXXFLAGS; do
7880                    case $i in
7881                    -fsanitize=*)
7882                        my_linkflagsnoundefs=
7883                        break
7884                        ;;
7885                    esac
7886                done
7887            fi
7888            if ! $CXX $CXXFLAGS $CPPFLAGS $LINKFLAGSSHL -fPIC -fvisibility-inlines-hidden conftestlib2.cc -L. -lconftest1 $my_linkflagsnoundefs -o libconftest2$DLLPOST >/dev/null 2>&5; then
7889                gccvisinlineshiddenok=no
7890            fi
7891        fi
7892
7893        rm -fr libconftest*
7894        AC_MSG_RESULT([$gccvisinlineshiddenok])
7895        if test "$gccvisinlineshiddenok" = "no"; then
7896            AC_MSG_ERROR([Your gcc/clang is not -fvisibility-inlines-hidden safe. This is no longer supported.])
7897        fi
7898    fi
7899
7900   AC_MSG_CHECKING([if $CXX_BASE has a visibility bug with class-level attributes (GCC bug 26905)])
7901    cat >visibility.cxx <<_ACEOF
7902#pragma GCC visibility push(hidden)
7903struct __attribute__ ((visibility ("default"))) TestStruct {
7904  static void Init();
7905};
7906__attribute__ ((visibility ("default"))) void TestFunc() {
7907  TestStruct::Init();
7908}
7909_ACEOF
7910    if ! $CXX $CXXFLAGS $CPPFLAGS -fpic -S visibility.cxx; then
7911        gccvisbroken=yes
7912    else
7913        case "$host_cpu" in
7914        i?86|x86_64)
7915            if test "$_os" = "Darwin" -o "$_os" = "iOS"; then
7916                gccvisbroken=no
7917            else
7918                if $EGREP -q '@PLT|@GOT' visibility.s || test "$ENABLE_LTO" = "TRUE"; then
7919                    gccvisbroken=no
7920                else
7921                    gccvisbroken=yes
7922                fi
7923            fi
7924            ;;
7925        *)
7926            gccvisbroken=no
7927            ;;
7928        esac
7929    fi
7930    rm -f visibility.s visibility.cxx
7931
7932    AC_MSG_RESULT([$gccvisbroken])
7933    if test "$gccvisbroken" = "yes"; then
7934        AC_MSG_ERROR([Your gcc is not -fvisibility=hidden safe. This is no longer supported.])
7935    fi
7936
7937    CPPFLAGS="$save_CPPFLAGS"
7938
7939    AC_LANG_POP([C++])
7940fi
7941
7942dnl ===================================================================
7943dnl  Clang++ tests
7944dnl ===================================================================
7945
7946HAVE_GCC_FNO_ENFORCE_EH_SPECS=
7947if test "$GCC" = "yes"; then
7948    AC_MSG_CHECKING([whether $CXX_BASE supports -fno-enforce-eh-specs])
7949    AC_LANG_PUSH([C++])
7950    save_CXXFLAGS=$CXXFLAGS
7951    CXXFLAGS="$CFLAGS -Werror -fno-enforce-eh-specs"
7952    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_FNO_ENFORCE_EH_SPECS=TRUE ],[])
7953    CXXFLAGS=$save_CXXFLAGS
7954    AC_LANG_POP([C++])
7955    if test "$HAVE_GCC_FNO_ENFORCE_EH_SPECS" = "TRUE"; then
7956        AC_MSG_RESULT([yes])
7957    else
7958        AC_MSG_RESULT([no])
7959    fi
7960fi
7961AC_SUBST(HAVE_GCC_FNO_ENFORCE_EH_SPECS)
7962
7963dnl ===================================================================
7964dnl Compiler plugins
7965dnl ===================================================================
7966
7967COMPILER_PLUGINS=
7968# currently only Clang
7969
7970if test "$COM_IS_CLANG" != "TRUE"; then
7971    if test "$libo_fuzzed_enable_compiler_plugins" = yes -a "$enable_compiler_plugins" = yes; then
7972        AC_MSG_NOTICE([Resetting --enable-compiler-plugins=no])
7973        enable_compiler_plugins=no
7974    fi
7975fi
7976
7977COMPILER_PLUGINS_COM_IS_CLANG=
7978if test "$COM_IS_CLANG" = "TRUE"; then
7979    if test -n "$enable_compiler_plugins"; then
7980        compiler_plugins="$enable_compiler_plugins"
7981    elif test -n "$ENABLE_DBGUTIL"; then
7982        compiler_plugins=test
7983    else
7984        compiler_plugins=no
7985    fi
7986    if test "$compiler_plugins" != no -a "$my_apple_clang" != yes; then
7987        if test "$CLANGVER" -lt 50002; then
7988            if test "$compiler_plugins" = yes; then
7989                AC_MSG_ERROR([Clang $CLANGVER is too old to build compiler plugins; need >= 5.0.2.])
7990            else
7991                compiler_plugins=no
7992            fi
7993        fi
7994    fi
7995    if test "$compiler_plugins" != "no"; then
7996        dnl The prefix where Clang resides, override to where Clang resides if
7997        dnl using a source build:
7998        if test -z "$CLANGDIR"; then
7999            CLANGDIR=$(dirname $(dirname $($CXX -print-prog-name=$(basename $(printf '%s\n' $CXX | grep clang | head -n 1)))))
8000        fi
8001        # Assume Clang is self-built, but allow overriding COMPILER_PLUGINS_CXX to the compiler Clang was built with.
8002        if test -z "$COMPILER_PLUGINS_CXX"; then
8003            COMPILER_PLUGINS_CXX=[$(echo $CXX | sed -e 's/-fsanitize=[^ ]*//g')]
8004        fi
8005        clangbindir=$CLANGDIR/bin
8006        if test "$build_os" = "cygwin"; then
8007            clangbindir=$(cygpath -u "$clangbindir")
8008        fi
8009        AC_PATH_PROG(LLVM_CONFIG, llvm-config,[],"$clangbindir" $PATH)
8010        if test -n "$LLVM_CONFIG"; then
8011            COMPILER_PLUGINS_CXXFLAGS=$($LLVM_CONFIG --cxxflags)
8012            COMPILER_PLUGINS_LINKFLAGS=$($LLVM_CONFIG --ldflags --libs --system-libs | tr '\n' ' ')
8013            if test -z "$CLANGLIBDIR"; then
8014                CLANGLIBDIR=$($LLVM_CONFIG --libdir)
8015            fi
8016            # Try if clang is built from source (in which case its includes are not together with llvm includes).
8017            # src-root is [llvm-toplevel-src-dir]/llvm, clang is [llvm-toplevel-src-dir]/clang
8018            clangsrcdir=$(dirname $($LLVM_CONFIG --src-root))
8019            if test -n "$clangsrcdir" -a -d "$clangsrcdir" -a -d "$clangsrcdir/clang/include"; then
8020                COMPILER_PLUGINS_CXXFLAGS="$COMPILER_PLUGINS_CXXFLAGS -I$clangsrcdir/clang/include"
8021            fi
8022            # obj-root is [llvm-toplevel-obj-dir]/, clang is [llvm-toplevel-obj-dir]/tools/clang
8023            clangobjdir=$($LLVM_CONFIG --obj-root)
8024            if test -n "$clangobjdir" -a -d "$clangobjdir" -a -d "$clangobjdir/tools/clang/include"; then
8025                COMPILER_PLUGINS_CXXFLAGS="$COMPILER_PLUGINS_CXXFLAGS -I$clangobjdir/tools/clang/include"
8026            fi
8027        fi
8028        AC_MSG_NOTICE([compiler plugins compile flags: $COMPILER_PLUGINS_CXXFLAGS])
8029        AC_LANG_PUSH([C++])
8030        save_CXX=$CXX
8031        save_CXXCPP=$CXXCPP
8032        save_CPPFLAGS=$CPPFLAGS
8033        save_CXXFLAGS=$CXXFLAGS
8034        save_LDFLAGS=$LDFLAGS
8035        save_LIBS=$LIBS
8036        CXX=$COMPILER_PLUGINS_CXX
8037        CXXCPP="$COMPILER_PLUGINS_CXX -E"
8038        CPPFLAGS="$COMPILER_PLUGINS_CXXFLAGS"
8039        CXXFLAGS="$COMPILER_PLUGINS_CXXFLAGS"
8040        AC_CHECK_HEADER(clang/Basic/SourceLocation.h,
8041            [COMPILER_PLUGINS=TRUE],
8042            [
8043            if test "$compiler_plugins" = "yes"; then
8044                AC_MSG_ERROR([Cannot find Clang headers to build compiler plugins.])
8045            else
8046                AC_MSG_WARN([Cannot find Clang headers to build compiler plugins, plugins disabled])
8047                add_warning "Cannot find Clang headers to build compiler plugins, plugins disabled."
8048            fi
8049            ])
8050        dnl TODO: Windows doesn't use LO_CLANG_SHARED_PLUGINS for now, see corresponding TODO
8051        dnl comment in compilerplugins/Makefile-clang.mk:
8052        if test -n "$COMPILER_PLUGINS" && test "$_os" != "WINNT"; then
8053            LDFLAGS=""
8054            AC_MSG_CHECKING([for clang libraries to use])
8055            if test -z "$CLANGTOOLLIBS"; then
8056                LIBS="-lclangTooling -lclangFrontend -lclangDriver -lclangParse -lclangSema -lclangEdit \
8057 -lclangAnalysis -lclangAST -lclangLex -lclangSerialization -lclangBasic $COMPILER_PLUGINS_LINKFLAGS"
8058                AC_LINK_IFELSE([
8059                    AC_LANG_PROGRAM([[#include "clang/Basic/SourceLocation.h"]],
8060                        [[ clang::FullSourceLoc().dump(); ]])
8061                ],[CLANGTOOLLIBS="$LIBS"],[])
8062            fi
8063            if test -z "$CLANGTOOLLIBS"; then
8064                LIBS="-lclang-cpp $COMPILER_PLUGINS_LINKFLAGS"
8065                AC_LINK_IFELSE([
8066                    AC_LANG_PROGRAM([[#include "clang/Basic/SourceLocation.h"]],
8067                        [[ clang::FullSourceLoc().dump(); ]])
8068                ],[CLANGTOOLLIBS="$LIBS"],[])
8069            fi
8070            AC_MSG_RESULT([$CLANGTOOLLIBS])
8071            if test -z "$CLANGTOOLLIBS"; then
8072                if test "$compiler_plugins" = "yes"; then
8073                    AC_MSG_ERROR([Cannot find Clang libraries to build compiler plugins.])
8074                else
8075                    AC_MSG_WARN([Cannot find Clang libraries to build compiler plugins, plugins disabled])
8076                    add_warning "Cannot find Clang libraries to build compiler plugins, plugins disabled."
8077                fi
8078                COMPILER_PLUGINS=
8079            fi
8080            if test -n "$COMPILER_PLUGINS"; then
8081                if test -z "$CLANGSYSINCLUDE"; then
8082                    if test -n "$LLVM_CONFIG"; then
8083                        # Path to the clang system headers (no idea if there's a better way to get it).
8084                        CLANGSYSINCLUDE=$($LLVM_CONFIG --libdir)/clang/$($LLVM_CONFIG --version | sed 's/git\|svn//')/include
8085                    fi
8086                fi
8087            fi
8088        fi
8089        CXX=$save_CXX
8090        CXXCPP=$save_CXXCPP
8091        CPPFLAGS=$save_CPPFLAGS
8092        CXXFLAGS=$save_CXXFLAGS
8093        LDFLAGS=$save_LDFLAGS
8094        LIBS="$save_LIBS"
8095        AC_LANG_POP([C++])
8096
8097        AC_MSG_CHECKING([whether the compiler for building compilerplugins is actually Clang])
8098        AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
8099            #ifndef __clang__
8100            you lose
8101            #endif
8102            int foo=42;
8103            ]])],
8104            [AC_MSG_RESULT([yes])
8105             COMPILER_PLUGINS_COM_IS_CLANG=TRUE],
8106            [AC_MSG_RESULT([no])])
8107        AC_SUBST(COMPILER_PLUGINS_COM_IS_CLANG)
8108    fi
8109else
8110    if test "$enable_compiler_plugins" = "yes"; then
8111        AC_MSG_ERROR([Compiler plugins are currently supported only with the Clang compiler.])
8112    fi
8113fi
8114COMPILER_PLUGINS_ANALYZER_PCH=
8115if test "$enable_compiler_plugins_analyzer_pch" != no; then
8116    COMPILER_PLUGINS_ANALYZER_PCH=TRUE
8117fi
8118AC_SUBST(COMPILER_PLUGINS)
8119AC_SUBST(COMPILER_PLUGINS_ANALYZER_PCH)
8120AC_SUBST(COMPILER_PLUGINS_COM_IS_CLANG)
8121AC_SUBST(COMPILER_PLUGINS_CXX)
8122AC_SUBST(COMPILER_PLUGINS_CXXFLAGS)
8123AC_SUBST(COMPILER_PLUGINS_CXX_LINKFLAGS)
8124AC_SUBST(COMPILER_PLUGINS_DEBUG)
8125AC_SUBST(COMPILER_PLUGINS_TOOLING_ARGS)
8126AC_SUBST(CLANGDIR)
8127AC_SUBST(CLANGLIBDIR)
8128AC_SUBST(CLANGTOOLLIBS)
8129AC_SUBST(CLANGSYSINCLUDE)
8130
8131# Plugin to help linker.
8132# Add something like LD_PLUGIN=/usr/lib64/LLVMgold.so to your autogen.input.
8133# This makes --enable-lto build with clang work.
8134AC_SUBST(LD_PLUGIN)
8135
8136AC_CHECK_FUNCS(posix_fallocate, HAVE_POSIX_FALLOCATE=YES, [HAVE_POSIX_FALLOCATE=NO])
8137AC_SUBST(HAVE_POSIX_FALLOCATE)
8138
8139JITC_PROCESSOR_TYPE=""
8140if test "$_os" = "Linux" -a "$host_cpu" = "powerpc"; then
8141    # IBMs JDK needs this...
8142    JITC_PROCESSOR_TYPE=6
8143    export JITC_PROCESSOR_TYPE
8144fi
8145AC_SUBST([JITC_PROCESSOR_TYPE])
8146
8147# Misc Windows Stuff
8148AC_ARG_WITH(ucrt-dir,
8149    AS_HELP_STRING([--with-ucrt-dir],
8150        [path to the directory with the arch-specific MSU packages of the Windows Universal CRT redistributables
8151        (MS KB 2999226) for packaging into the installsets (without those the target system needs to install
8152        the UCRT or Visual C++ Runtimes manually). The directory must contain the following 6 files:
8153            Windows6.1-KB2999226-x64.msu
8154            Windows6.1-KB2999226-x86.msu
8155            Windows8.1-KB2999226-x64.msu
8156            Windows8.1-KB2999226-x86.msu
8157            Windows8-RT-KB2999226-x64.msu
8158            Windows8-RT-KB2999226-x86.msu
8159        A zip archive including those files is available from Microsoft site:
8160        https://www.microsoft.com/en-us/download/details.aspx?id=48234]),
8161,)
8162
8163UCRT_REDISTDIR="$with_ucrt_dir"
8164if test $_os = "WINNT"; then
8165    find_msvc_x64_dlls
8166    for i in $PKGFORMAT; do
8167        if test "$i" = msi; then
8168            find_msms
8169            break
8170        fi
8171    done
8172    MSVC_DLL_PATH=`win_short_path_for_make "$msvcdllpath"`
8173    MSVC_DLLS="$msvcdlls"
8174    test -n "$msmdir" && MSM_PATH=`win_short_path_for_make "$msmdir"`
8175    # MSVC 15.3 changed it to VC141
8176    if echo "$msvcdllpath" | grep -q "VC142.CRT$"; then
8177        SCPDEFS="$SCPDEFS -DWITH_VC142_REDIST"
8178    elif echo "$msvcdllpath" | grep -q "VC141.CRT$"; then
8179        SCPDEFS="$SCPDEFS -DWITH_VC141_REDIST"
8180    else
8181        SCPDEFS="$SCPDEFS -DWITH_VC${VCVER}_REDIST"
8182    fi
8183
8184    if test "$UCRT_REDISTDIR" = "no"; then
8185        dnl explicitly disabled
8186        UCRT_REDISTDIR=""
8187    else
8188        if ! test -f "$UCRT_REDISTDIR/Windows6.1-KB2999226-x64.msu" -a \
8189                  -f "$UCRT_REDISTDIR/Windows6.1-KB2999226-x86.msu" -a \
8190                  -f "$UCRT_REDISTDIR/Windows8.1-KB2999226-x64.msu" -a \
8191                  -f "$UCRT_REDISTDIR/Windows8.1-KB2999226-x86.msu" -a \
8192                  -f "$UCRT_REDISTDIR/Windows8-RT-KB2999226-x64.msu" -a \
8193                  -f "$UCRT_REDISTDIR/Windows8-RT-KB2999226-x86.msu"; then
8194            UCRT_REDISTDIR=""
8195            if test -n "$PKGFORMAT"; then
8196               for i in $PKGFORMAT; do
8197                   case "$i" in
8198                   msi)
8199                       AC_MSG_WARN([--without-ucrt-dir not specified or MSUs not found - installer will have runtime dependency])
8200                       add_warning "--without-ucrt-dir not specified or MSUs not found - installer will have runtime dependency"
8201                       ;;
8202                   esac
8203               done
8204            fi
8205        fi
8206    fi
8207fi
8208
8209AC_SUBST(UCRT_REDISTDIR)
8210AC_SUBST(MSVC_DLL_PATH)
8211AC_SUBST(MSVC_DLLS)
8212AC_SUBST(MSM_PATH)
8213
8214
8215dnl ===================================================================
8216dnl Checks for Java
8217dnl ===================================================================
8218if test "$ENABLE_JAVA" != ""; then
8219
8220    # Windows-specific tests
8221    if test "$build_os" = "cygwin"; then
8222        if test -z "$with_jdk_home"; then
8223            dnl See <https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-EEED398E-AE37-4D12-
8224            dnl AB10-49F82F720027> section "Windows Registry Key Changes":
8225            reg_get_value "$WIN_HOST_BITS" "HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/JDK/CurrentVersion"
8226            if test -n "$regvalue"; then
8227                ver=$regvalue
8228                reg_get_value "$WIN_HOST_BITS" "HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/JDK/$ver/JavaHome"
8229                with_jdk_home=$regvalue
8230            fi
8231            howfound="found automatically"
8232        else
8233            with_jdk_home=`win_short_path_for_make "$with_jdk_home"`
8234            howfound="you passed"
8235        fi
8236
8237        if ! test -f "$with_jdk_home/lib/jvm.lib" -a -f "$with_jdk_home/bin/java.exe"; then
8238            AC_MSG_ERROR([No JDK found, pass the --with-jdk-home option (or fix the path) pointing to a $WIN_HOST_BITS-bit JDK >= 9])
8239        fi
8240    fi
8241
8242    # 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.
8243    # /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java, but /usr does not contain the JDK libraries
8244    if test -z "$with_jdk_home" -a "$_os" = "Darwin" -a -x /usr/libexec/java_home; then
8245        with_jdk_home=`/usr/libexec/java_home`
8246    fi
8247
8248    JAVA_HOME=; export JAVA_HOME
8249    if test -z "$with_jdk_home"; then
8250        AC_PATH_PROG(JAVAINTERPRETER, $with_java)
8251    else
8252        _java_path="$with_jdk_home/bin/$with_java"
8253        dnl Check if there is a Java interpreter at all.
8254        if test -x "$_java_path"; then
8255            JAVAINTERPRETER=$_java_path
8256        else
8257            AC_MSG_ERROR([$_java_path not found, pass --with-jdk-home])
8258        fi
8259    fi
8260
8261    dnl Check that the JDK found is correct architecture (at least 2 reasons to
8262    dnl check: officebean needs to link -ljawt, and libjpipe.so needs to be
8263    dnl loaded by java to run JunitTests:
8264    if test "$build_os" = "cygwin" -a "$cross_compiling" != "yes"; then
8265        shortjdkhome=`cygpath -d "$with_jdk_home"`
8266        if test $WIN_HOST_BITS -eq 64 -a -f "$with_jdk_home/bin/java.exe" -a "`$shortjdkhome/bin/java.exe -version 2>&1 | $GREP -i 64-bit`" = "" >/dev/null; then
8267            AC_MSG_WARN([You are building 64-bit binaries but the JDK $howfound is 32-bit])
8268            AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a 64-bit JDK])
8269        elif test $WIN_HOST_BITS -eq 32 -a -f "$with_jdk_home/bin/java.exe" -a "`$shortjdkhome/bin/java.exe -version 2>&1 | $GREP -i 64-bit`" != ""  >/dev/null; then
8270            AC_MSG_WARN([You are building 32-bit binaries but the JDK $howfound is 64-bit])
8271            AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a (32-bit) JDK])
8272        fi
8273
8274        if test x`echo "$JAVAINTERPRETER" | $GREP -i '\.exe$'` = x; then
8275            JAVAINTERPRETER="${JAVAINTERPRETER}.exe"
8276        fi
8277        JAVAINTERPRETER=`win_short_path_for_make "$JAVAINTERPRETER"`
8278    elif test "$cross_compiling" != "yes"; then
8279        case $CPUNAME in
8280            AARCH64|AXP|X86_64|HPPA|IA64|POWERPC64|S390X|SPARC64|GODSON64)
8281                if test -f "$JAVAINTERPRETER" -a "`$JAVAINTERPRETER -version 2>&1 | $GREP -i 64-bit`" = "" >/dev/null; then
8282                    AC_MSG_WARN([You are building 64-bit binaries but the JDK $JAVAINTERPRETER is 32-bit])
8283                    AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a 64-bit JDK])
8284                fi
8285                ;;
8286            *) # assumption: everything else 32-bit
8287                if test -f "$JAVAINTERPRETER" -a "`$JAVAINTERPRETER -version 2>&1 | $GREP -i 64-bit`" != ""  >/dev/null; then
8288                    AC_MSG_WARN([You are building 32-bit binaries but the JDK $howfound is 64-bit])
8289                    AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a (32-bit) JDK])
8290                fi
8291                ;;
8292        esac
8293    fi
8294fi
8295
8296dnl ===================================================================
8297dnl Checks for JDK.
8298dnl ===================================================================
8299
8300# Whether all the complexity here actually is needed any more or not, no idea.
8301
8302if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then
8303    _gij_longver=0
8304    AC_MSG_CHECKING([the installed JDK])
8305    if test -n "$JAVAINTERPRETER"; then
8306        dnl java -version sends output to stderr!
8307        if test `$JAVAINTERPRETER -version 2>&1 | $GREP -c "Kaffe"` -gt 0; then
8308            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
8309        elif test `$JAVAINTERPRETER --version 2>&1 | $GREP -c "GNU libgcj"` -gt 0; then
8310            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
8311        elif test `$JAVAINTERPRETER -version 2>&1 | $AWK '{ print }' | $GREP -c "BEA"` -gt 0; then
8312            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
8313        elif test `$JAVAINTERPRETER -version 2>&1 | $AWK '{ print }' | $GREP -c "IBM"` -gt 0; then
8314            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
8315        else
8316            JDK=sun
8317
8318            dnl Sun JDK specific tests
8319            _jdk=`$JAVAINTERPRETER -version 2>&1 | $AWK -F'"' '{ print \$2 }' | $SED '/^$/d' | $SED s/[[-A-Za-z]]*//`
8320            _jdk_ver=`echo "$_jdk" | $AWK -F. '{ print (($1 * 100) + $2) * 100 + $3;}'`
8321
8322            if test "$_jdk_ver" -lt 10900; then
8323                AC_MSG_ERROR([JDK is too old, you need at least 9 ($_jdk_ver < 10900)])
8324            fi
8325            if test "$_jdk_ver" -gt 10900; then
8326                JAVA_CLASSPATH_NOT_SET=TRUE
8327            fi
8328
8329            JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*java,,p"`
8330            if test "$_os" = "WINNT"; then
8331                JAVA_HOME=`echo $JAVA_HOME | $SED "s,\.[[eE]][[xX]][[eE]]$,,"`
8332            fi
8333            AC_MSG_RESULT([found $JAVA_HOME (JDK $_jdk)])
8334
8335            # set to limit VM usage for JunitTests
8336            JAVAIFLAGS=-Xmx64M
8337            # set to limit VM usage for javac
8338            JAVACFLAGS=-J-Xmx128M
8339        fi
8340    else
8341        AC_MSG_ERROR([Java not found. You need at least JDK 9])
8342    fi
8343else
8344    if test -z "$ENABLE_JAVA"; then
8345        dnl Java disabled
8346        JAVA_HOME=
8347        export JAVA_HOME
8348    elif test "$cross_compiling" = "yes"; then
8349        # Just assume compatibility of build and host JDK
8350        JDK=$JDK_FOR_BUILD
8351        JAVAIFLAGS=$JAVAIFLAGS_FOR_BUILD
8352    fi
8353fi
8354
8355dnl ===================================================================
8356dnl Checks for javac
8357dnl ===================================================================
8358if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then
8359    javacompiler="javac"
8360    : ${JAVA_SOURCE_VER=8}
8361    : ${JAVA_TARGET_VER=8}
8362    if test -z "$with_jdk_home"; then
8363        AC_PATH_PROG(JAVACOMPILER, $javacompiler)
8364    else
8365        _javac_path="$with_jdk_home/bin/$javacompiler"
8366        dnl Check if there is a Java compiler at all.
8367        if test -x "$_javac_path"; then
8368            JAVACOMPILER=$_javac_path
8369        fi
8370    fi
8371    if test -z "$JAVACOMPILER"; then
8372        AC_MSG_ERROR([$javacompiler not found set with_jdk_home])
8373    fi
8374    if test "$build_os" = "cygwin"; then
8375        if test x`echo "$JAVACOMPILER" | $GREP -i '\.exe$'` = x; then
8376            JAVACOMPILER="${JAVACOMPILER}.exe"
8377        fi
8378        JAVACOMPILER=`win_short_path_for_make "$JAVACOMPILER"`
8379    fi
8380fi
8381
8382dnl ===================================================================
8383dnl Checks for javadoc
8384dnl ===================================================================
8385if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then
8386    if test -z "$with_jdk_home"; then
8387        AC_PATH_PROG(JAVADOC, javadoc)
8388    else
8389        _javadoc_path="$with_jdk_home/bin/javadoc"
8390        dnl Check if there is a javadoc at all.
8391        if test -x "$_javadoc_path"; then
8392            JAVADOC=$_javadoc_path
8393        else
8394            AC_PATH_PROG(JAVADOC, javadoc)
8395        fi
8396    fi
8397    if test -z "$JAVADOC"; then
8398        AC_MSG_ERROR([$_javadoc_path not found set with_jdk_home])
8399    fi
8400    if test "$build_os" = "cygwin"; then
8401        if test x`echo "$JAVADOC" | $GREP -i '\.exe$'` = x; then
8402            JAVADOC="${JAVADOC}.exe"
8403        fi
8404        JAVADOC=`win_short_path_for_make "$JAVADOC"`
8405    fi
8406
8407    if test `$JAVADOC --version 2>&1 | $GREP -c "gjdoc"` -gt 0; then
8408    JAVADOCISGJDOC="yes"
8409    fi
8410fi
8411AC_SUBST(JAVADOC)
8412AC_SUBST(JAVADOCISGJDOC)
8413
8414if test "$ENABLE_JAVA" != "" -a \( "$cross_compiling" != "yes" -o -n "$with_jdk_home" \); then
8415    # check if JAVA_HOME was (maybe incorrectly?) set automatically to /usr
8416    if test "$JAVA_HOME" = "/usr" -a "x$with_jdk_home" = "x"; then
8417        if basename $(readlink $(readlink $JAVACOMPILER)) >/dev/null 2>/dev/null; then
8418           # try to recover first by looking whether we have an alternative
8419           # system as in Debian or newer SuSEs where following /usr/bin/javac
8420           # over /etc/alternatives/javac leads to the right bindir where we
8421           # just need to strip a bit away to get a valid JAVA_HOME
8422           JAVA_HOME=$(readlink $(readlink $JAVACOMPILER))
8423        elif readlink $JAVACOMPILER >/dev/null 2>/dev/null; then
8424            # maybe only one level of symlink (e.g. on Mac)
8425            JAVA_HOME=$(readlink $JAVACOMPILER)
8426            if test "$(dirname $JAVA_HOME)" = "."; then
8427                # we've got no path to trim back
8428                JAVA_HOME=""
8429            fi
8430        else
8431            # else warn
8432            AC_MSG_WARN([JAVA_HOME is set to /usr - this is very likely to be incorrect])
8433            AC_MSG_WARN([if this is the case, please inform the correct JAVA_HOME with --with-jdk-home])
8434            add_warning "JAVA_HOME is set to /usr - this is very likely to be incorrect"
8435            add_warning "if this is the case, please inform the correct JAVA_HOME with --with-jdk-home"
8436        fi
8437        dnl now that we probably have the path to the real javac, make a JAVA_HOME out of it...
8438        if test "$JAVA_HOME" != "/usr"; then
8439            if test "$_os" = "Darwin" -o "$OS_FOR_BUILD" = MACOSX; then
8440                dnl Leopard returns a non-suitable path with readlink - points to "Current" only
8441                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/Current/Commands/javac$,/CurrentJDK/Home,)
8442                dnl Tiger already returns a JDK path...
8443                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/CurrentJDK/Commands/javac$,/CurrentJDK/Home,)
8444            else
8445                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/bin/javac$,,)
8446                dnl check that we have a directory as certain distros eg gentoo substitute javac for a script
8447                dnl that checks which version to run
8448                if test -f "$JAVA_HOME"; then
8449                    JAVA_HOME=""; # set JAVA_HOME to null if it's a file
8450                fi
8451            fi
8452        fi
8453    fi
8454    # as we drop out of this, JAVA_HOME may have been set to the empty string by readlink
8455
8456    dnl now if JAVA_HOME has been set to empty, then call findhome to find it
8457    if test -z "$JAVA_HOME"; then
8458        if test "x$with_jdk_home" = "x"; then
8459            cat > findhome.java <<_ACEOF
8460[import java.io.File;
8461
8462class findhome
8463{
8464    public static void main(String args[])
8465    {
8466        String jrelocation = System.getProperty("java.home");
8467        File jre = new File(jrelocation);
8468        System.out.println(jre.getParent());
8469    }
8470}]
8471_ACEOF
8472            AC_MSG_CHECKING([if javac works])
8473            javac_cmd="$JAVACOMPILER findhome.java 1>&2"
8474            AC_TRY_EVAL(javac_cmd)
8475            if test $? = 0 -a -f ./findhome.class; then
8476                AC_MSG_RESULT([javac works])
8477            else
8478                echo "configure: javac test failed" >&5
8479                cat findhome.java >&5
8480                AC_MSG_ERROR([javac does not work - java projects will not build!])
8481            fi
8482            AC_MSG_CHECKING([if gij knows its java.home])
8483            JAVA_HOME=`$JAVAINTERPRETER findhome`
8484            if test $? = 0 -a "$JAVA_HOME" != ""; then
8485                AC_MSG_RESULT([$JAVA_HOME])
8486            else
8487                echo "configure: java test failed" >&5
8488                cat findhome.java >&5
8489                AC_MSG_ERROR([gij does not know its java.home - use --with-jdk-home])
8490            fi
8491            # clean-up after ourselves
8492            rm -f ./findhome.java ./findhome.class
8493        else
8494            JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*$with_java,,p"`
8495        fi
8496    fi
8497
8498    # now check if $JAVA_HOME is really valid
8499    if test "$_os" = "Darwin" -o "$OS_FOR_BUILD" = MACOSX; then
8500        if test ! -f "$JAVA_HOME/lib/jvm.cfg" -a "x$with_jdk_home" = "x"; then
8501            AC_MSG_WARN([JAVA_HOME was not explicitly informed with --with-jdk-home. the configure script])
8502            AC_MSG_WARN([attempted to find JAVA_HOME automatically, but apparently it failed])
8503            AC_MSG_WARN([in case JAVA_HOME is incorrectly set, some projects will not be built correctly])
8504            add_warning "JAVA_HOME was not explicitly informed with --with-jdk-home. the configure script"
8505            add_warning "attempted to find JAVA_HOME automatically, but apparently it failed"
8506            add_warning "in case JAVA_HOME is incorrectly set, some projects will not be built correctly"
8507        fi
8508    fi
8509    PathFormat "$JAVA_HOME"
8510    JAVA_HOME="$formatted_path"
8511fi
8512
8513if test -z "$JAWTLIB" -a -n "$ENABLE_JAVA" -a "$_os" != Android -a \
8514    "$_os" != Darwin
8515then
8516    AC_MSG_CHECKING([for JAWT lib])
8517    if test "$_os" = WINNT; then
8518        # The path to $JAVA_HOME/lib/$JAWTLIB is part of $ILIB:
8519        JAWTLIB=jawt.lib
8520    else
8521        case "$host_cpu" in
8522        arm*)
8523            AS_IF([test -e "$JAVA_HOME/jre/lib/aarch32/libjawt.so"], [my_java_arch=aarch32], [my_java_arch=arm])
8524            JAVA_ARCH=$my_java_arch
8525            ;;
8526        i*86)
8527            my_java_arch=i386
8528            ;;
8529        m68k)
8530            my_java_arch=m68k
8531            ;;
8532        powerpc)
8533            my_java_arch=ppc
8534            ;;
8535        powerpc64)
8536            my_java_arch=ppc64
8537            ;;
8538        powerpc64le)
8539            AS_IF([test -e "$JAVA_HOME/jre/lib/ppc64le/libjawt.so"], [my_java_arch=ppc64le], [my_java_arch=ppc64])
8540            JAVA_ARCH=$my_java_arch
8541            ;;
8542        sparc64)
8543            my_java_arch=sparcv9
8544            ;;
8545        x86_64)
8546            my_java_arch=amd64
8547            ;;
8548        *)
8549            my_java_arch=$host_cpu
8550            ;;
8551        esac
8552        # This is where JDK9 puts the library
8553        if test -e "$JAVA_HOME/lib/libjawt.so"; then
8554            JAWTLIB="-L$JAVA_HOME/lib/ -ljawt"
8555        else
8556            JAWTLIB="-L$JAVA_HOME/jre/lib/$my_java_arch -ljawt"
8557        fi
8558        AS_IF([test "$JAVA_ARCH" != ""], [AC_DEFINE_UNQUOTED([JAVA_ARCH], ["$JAVA_ARCH"])])
8559    fi
8560    AC_MSG_RESULT([$JAWTLIB])
8561fi
8562AC_SUBST(JAWTLIB)
8563
8564if test -n "$ENABLE_JAVA" -a -z "$JAVAINC"; then
8565    case "$host_os" in
8566
8567    aix*)
8568        JAVAINC="-I$JAVA_HOME/include"
8569        JAVAINC="$JAVAINC -I$JAVA_HOME/include/aix"
8570        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
8571        ;;
8572
8573    cygwin*|wsl*)
8574        JAVAINC="-I$JAVA_HOME/include/win32"
8575        JAVAINC="$JAVAINC -I$JAVA_HOME/include"
8576        ;;
8577
8578    darwin*|macos*)
8579        if test -d "$JAVA_HOME/include/darwin"; then
8580            JAVAINC="-I$JAVA_HOME/include  -I$JAVA_HOME/include/darwin"
8581        else
8582            JAVAINC=${ISYSTEM}$FRAMEWORKSHOME/JavaVM.framework/Versions/Current/Headers
8583        fi
8584        ;;
8585
8586    dragonfly*)
8587        JAVAINC="-I$JAVA_HOME/include"
8588        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
8589        ;;
8590
8591    freebsd*)
8592        JAVAINC="-I$JAVA_HOME/include"
8593        JAVAINC="$JAVAINC -I$JAVA_HOME/include/freebsd"
8594        JAVAINC="$JAVAINC -I$JAVA_HOME/include/bsd"
8595        JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux"
8596        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
8597        ;;
8598
8599    k*bsd*-gnu*)
8600        JAVAINC="-I$JAVA_HOME/include"
8601        JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux"
8602        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
8603        ;;
8604
8605    linux-gnu*)
8606        JAVAINC="-I$JAVA_HOME/include"
8607        JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux"
8608        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
8609        ;;
8610
8611    *netbsd*)
8612        JAVAINC="-I$JAVA_HOME/include"
8613        JAVAINC="$JAVAINC -I$JAVA_HOME/include/netbsd"
8614        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
8615       ;;
8616
8617    openbsd*)
8618        JAVAINC="-I$JAVA_HOME/include"
8619        JAVAINC="$JAVAINC -I$JAVA_HOME/include/openbsd"
8620        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
8621        ;;
8622
8623    solaris*)
8624        JAVAINC="-I$JAVA_HOME/include"
8625        JAVAINC="$JAVAINC -I$JAVA_HOME/include/solaris"
8626        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
8627        ;;
8628    esac
8629fi
8630SOLARINC="$SOLARINC $JAVAINC"
8631
8632if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then
8633    JAVA_HOME_FOR_BUILD=$JAVA_HOME
8634    JAVAIFLAGS_FOR_BUILD=$JAVAIFLAGS
8635    JDK_FOR_BUILD=$JDK
8636fi
8637
8638AC_SUBST(JAVACFLAGS)
8639AC_SUBST(JAVACOMPILER)
8640AC_SUBST(JAVAINTERPRETER)
8641AC_SUBST(JAVAIFLAGS)
8642AC_SUBST(JAVAIFLAGS_FOR_BUILD)
8643AC_SUBST(JAVA_CLASSPATH_NOT_SET)
8644AC_SUBST(JAVA_HOME)
8645AC_SUBST(JAVA_HOME_FOR_BUILD)
8646AC_SUBST(JDK)
8647AC_SUBST(JDK_FOR_BUILD)
8648AC_SUBST(JAVA_SOURCE_VER)
8649AC_SUBST(JAVA_TARGET_VER)
8650
8651
8652dnl ===================================================================
8653dnl Export file validation
8654dnl ===================================================================
8655AC_MSG_CHECKING([whether to enable export file validation])
8656if test "$with_export_validation" != "no"; then
8657    if test -z "$ENABLE_JAVA"; then
8658        if test "$with_export_validation" = "yes"; then
8659            AC_MSG_ERROR([requested, but Java is disabled])
8660        else
8661            AC_MSG_RESULT([no, as Java is disabled])
8662        fi
8663    elif ! test -d "${SRC_ROOT}/schema"; then
8664        if test "$with_export_validation" = "yes"; then
8665            AC_MSG_ERROR([requested, but schema directory is missing (it is excluded from tarballs)])
8666        else
8667            AC_MSG_RESULT([no, schema directory is missing (it is excluded from tarballs)])
8668        fi
8669    else
8670        AC_MSG_RESULT([yes])
8671        AC_DEFINE(HAVE_EXPORT_VALIDATION)
8672
8673        AC_PATH_PROGS(ODFVALIDATOR, odfvalidator)
8674        if test -z "$ODFVALIDATOR"; then
8675            # remember to download the ODF toolkit with validator later
8676            AC_MSG_NOTICE([no odfvalidator found, will download it])
8677            BUILD_TYPE="$BUILD_TYPE ODFVALIDATOR"
8678            ODFVALIDATOR="$BUILDDIR/bin/odfvalidator.sh"
8679
8680            # and fetch name of odfvalidator jar name from download.lst
8681            ODFVALIDATOR_JAR=`$SED -n -e "s/export *ODFVALIDATOR_JAR *:= *\(.*\) */\1/p" $SRC_ROOT/download.lst`
8682            AC_SUBST(ODFVALIDATOR_JAR)
8683
8684            if test -z "$ODFVALIDATOR_JAR"; then
8685                AC_MSG_ERROR([cannot determine odfvalidator jar location (--with-export-validation)])
8686            fi
8687        fi
8688        if test "$build_os" = "cygwin"; then
8689            # In case of Cygwin it will be executed from Windows,
8690            # so we need to run bash and absolute path to validator
8691            # so instead of "odfvalidator" it will be
8692            # something like "bash.exe C:\cygwin\opt\lo\bin\odfvalidator"
8693            ODFVALIDATOR="bash.exe `cygpath -m "$ODFVALIDATOR"`"
8694        else
8695            ODFVALIDATOR="sh $ODFVALIDATOR"
8696        fi
8697        AC_SUBST(ODFVALIDATOR)
8698
8699
8700        AC_PATH_PROGS(OFFICEOTRON, officeotron)
8701        if test -z "$OFFICEOTRON"; then
8702            # remember to download the officeotron with validator later
8703            AC_MSG_NOTICE([no officeotron found, will download it])
8704            BUILD_TYPE="$BUILD_TYPE OFFICEOTRON"
8705            OFFICEOTRON="$BUILDDIR/bin/officeotron.sh"
8706
8707            # and fetch name of officeotron jar name from download.lst
8708            OFFICEOTRON_JAR=`$SED -n -e "s/export *OFFICEOTRON_JAR *:= *\(.*\) */\1/p" $SRC_ROOT/download.lst`
8709            AC_SUBST(OFFICEOTRON_JAR)
8710
8711            if test -z "$OFFICEOTRON_JAR"; then
8712                AC_MSG_ERROR([cannot determine officeotron jar location (--with-export-validation)])
8713            fi
8714        else
8715            # check version of existing officeotron
8716            OFFICEOTRON_VER=`$OFFICEOTRON --version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
8717            if test 0"$OFFICEOTRON_VER" -lt 704; then
8718                AC_MSG_ERROR([officeotron too old])
8719            fi
8720        fi
8721        if test "$build_os" = "cygwin"; then
8722            # In case of Cygwin it will be executed from Windows,
8723            # so we need to run bash and absolute path to validator
8724            # so instead of "odfvalidator" it will be
8725            # something like "bash.exe C:\cygwin\opt\lo\bin\odfvalidator"
8726            OFFICEOTRON="bash.exe `cygpath -m "$OFFICEOTRON"`"
8727        else
8728            OFFICEOTRON="sh $OFFICEOTRON"
8729        fi
8730    fi
8731    AC_SUBST(OFFICEOTRON)
8732else
8733    AC_MSG_RESULT([no])
8734fi
8735
8736AC_MSG_CHECKING([for Microsoft Binary File Format Validator])
8737if test "$with_bffvalidator" != "no"; then
8738    AC_DEFINE(HAVE_BFFVALIDATOR)
8739
8740    if test "$with_export_validation" = "no"; then
8741        AC_MSG_ERROR([Please enable export validation (-with-export-validation)!])
8742    fi
8743
8744    if test "$with_bffvalidator" = "yes"; then
8745        BFFVALIDATOR=`win_short_path_for_make "$PROGRAMFILES/Microsoft Office/BFFValidator/BFFValidator.exe"`
8746    else
8747        BFFVALIDATOR="$with_bffvalidator"
8748    fi
8749
8750    if test "$build_os" = "cygwin"; then
8751        if test -n "$BFFVALIDATOR" -a -e "`cygpath $BFFVALIDATOR`"; then
8752            AC_MSG_RESULT($BFFVALIDATOR)
8753        else
8754            AC_MSG_ERROR([bffvalidator not found, but required by --with-bffvalidator])
8755        fi
8756    elif test -n "$BFFVALIDATOR"; then
8757        # We are not in Cygwin but need to run Windows binary with wine
8758        AC_PATH_PROGS(WINE, wine)
8759
8760        # so swap in a shell wrapper that converts paths transparently
8761        BFFVALIDATOR_EXE="$BFFVALIDATOR"
8762        BFFVALIDATOR="sh $BUILDDIR/bin/bffvalidator.sh"
8763        AC_SUBST(BFFVALIDATOR_EXE)
8764        AC_MSG_RESULT($BFFVALIDATOR)
8765    else
8766        AC_MSG_ERROR([bffvalidator not found, but required by --with-bffvalidator])
8767    fi
8768    AC_SUBST(BFFVALIDATOR)
8769else
8770    AC_MSG_RESULT([no])
8771fi
8772
8773dnl ===================================================================
8774dnl Check for C preprocessor to use
8775dnl ===================================================================
8776AC_MSG_CHECKING([which C preprocessor to use in idlc])
8777if test -n "$with_idlc_cpp"; then
8778    AC_MSG_RESULT([$with_idlc_cpp])
8779    AC_PATH_PROG(SYSTEM_UCPP, $with_idlc_cpp)
8780else
8781    AC_MSG_RESULT([ucpp])
8782    AC_MSG_CHECKING([which ucpp tp use])
8783    if test -n "$with_system_ucpp" -a "$with_system_ucpp" != "no"; then
8784        AC_MSG_RESULT([external])
8785        AC_PATH_PROG(SYSTEM_UCPP, ucpp)
8786    else
8787        AC_MSG_RESULT([internal])
8788        BUILD_TYPE="$BUILD_TYPE UCPP"
8789    fi
8790fi
8791AC_SUBST(SYSTEM_UCPP)
8792
8793dnl ===================================================================
8794dnl Check for epm (not needed for Windows)
8795dnl ===================================================================
8796AC_MSG_CHECKING([whether to enable EPM for packing])
8797if test "$enable_epm" = "yes"; then
8798    AC_MSG_RESULT([yes])
8799    if test "$_os" != "WINNT"; then
8800        if test $_os = Darwin; then
8801            EPM=internal
8802        elif test -n "$with_epm"; then
8803            EPM=$with_epm
8804        else
8805            AC_PATH_PROG(EPM, epm, no)
8806        fi
8807        if test "$EPM" = "no" -o "$EPM" = "internal"; then
8808            AC_MSG_NOTICE([EPM will be built.])
8809            BUILD_TYPE="$BUILD_TYPE EPM"
8810            EPM=${WORKDIR}/UnpackedTarball/epm/epm
8811        else
8812            # Gentoo has some epm which is something different...
8813            AC_MSG_CHECKING([whether the found epm is the right epm])
8814            if $EPM | grep "ESP Package Manager" >/dev/null 2>/dev/null; then
8815                AC_MSG_RESULT([yes])
8816            else
8817                AC_MSG_ERROR([no. Install ESP Package Manager (http://www.msweet.org/projects.php?Z2) and/or specify the path to the right epm])
8818            fi
8819            AC_MSG_CHECKING([epm version])
8820            EPM_VERSION=`$EPM | grep 'ESP Package Manager' | cut -d' ' -f4 | $SED -e s/v//`
8821            if test "`echo $EPM_VERSION | cut -d'.' -f1`" -gt "3" || \
8822               test "`echo $EPM_VERSION | cut -d'.' -f1`" -eq "3" -a "`echo $EPM_VERSION | cut -d'.' -f2`" -ge "7"; then
8823                AC_MSG_RESULT([OK, >= 3.7])
8824            else
8825                AC_MSG_RESULT([too old. epm >= 3.7 is required.])
8826                AC_MSG_ERROR([Install ESP Package Manager (http://www.msweet.org/projects.php?Z2) and/or specify the path to the right epm])
8827            fi
8828        fi
8829    fi
8830
8831    if echo "$PKGFORMAT" | $EGREP rpm 2>&1 >/dev/null; then
8832        AC_MSG_CHECKING([for rpm])
8833        for a in "$RPM" rpmbuild rpm; do
8834            $a --usage >/dev/null 2> /dev/null
8835            if test $? -eq 0; then
8836                RPM=$a
8837                break
8838            else
8839                $a --version >/dev/null 2> /dev/null
8840                if test $? -eq 0; then
8841                    RPM=$a
8842                    break
8843                fi
8844            fi
8845        done
8846        if test -z "$RPM"; then
8847            AC_MSG_ERROR([not found])
8848        elif "$RPM" --help 2>&1 | $EGREP buildroot >/dev/null; then
8849            RPM_PATH=`which $RPM`
8850            AC_MSG_RESULT([$RPM_PATH])
8851            SCPDEFS="$SCPDEFS -DWITH_RPM"
8852        else
8853            AC_MSG_ERROR([cannot build packages. Try installing rpmbuild.])
8854        fi
8855    fi
8856    if echo "$PKGFORMAT" | $EGREP deb 2>&1 >/dev/null; then
8857        AC_PATH_PROG(DPKG, dpkg, no)
8858        if test "$DPKG" = "no"; then
8859            AC_MSG_ERROR([dpkg needed for deb creation. Install dpkg.])
8860        fi
8861    fi
8862    if echo "$PKGFORMAT" | $EGREP rpm 2>&1 >/dev/null || \
8863       echo "$PKGFORMAT" | $EGREP pkg 2>&1 >/dev/null; then
8864        if test "$with_epm" = "no" -a "$_os" != "Darwin"; then
8865            if test "`echo $EPM_VERSION | cut -d'.' -f1`" -lt "4"; then
8866                AC_MSG_CHECKING([whether epm is patched for LibreOffice's needs])
8867                if grep "Patched for .*Office" $EPM >/dev/null 2>/dev/null; then
8868                    AC_MSG_RESULT([yes])
8869                else
8870                    AC_MSG_RESULT([no])
8871                    if echo "$PKGFORMAT" | $GREP -q rpm; then
8872                        _pt="rpm"
8873                        AC_MSG_WARN([the rpms will need to be installed with --nodeps])
8874                        add_warning "the rpms will need to be installed with --nodeps"
8875                    else
8876                        _pt="pkg"
8877                    fi
8878                    AC_MSG_WARN([the ${_pt}s will not be relocatable])
8879                    add_warning "the ${_pt}s will not be relocatable"
8880                    AC_MSG_WARN([if you want to make sure installation without --nodeps and
8881                                 relocation will work, you need to patch your epm with the
8882                                 patch in epm/epm-3.7.patch or build with
8883                                 --with-epm=internal which will build a suitable epm])
8884                fi
8885            fi
8886        fi
8887    fi
8888    if echo "$PKGFORMAT" | $EGREP pkg 2>&1 >/dev/null; then
8889        AC_PATH_PROG(PKGMK, pkgmk, no)
8890        if test "$PKGMK" = "no"; then
8891            AC_MSG_ERROR([pkgmk needed for Solaris pkg creation. Install it.])
8892        fi
8893    fi
8894    AC_SUBST(RPM)
8895    AC_SUBST(DPKG)
8896    AC_SUBST(PKGMK)
8897else
8898    for i in $PKGFORMAT; do
8899        case "$i" in
8900        aix | bsd | deb | pkg | rpm | native | portable)
8901            AC_MSG_ERROR(
8902                [--with-package-format='$PKGFORMAT' requires --enable-epm])
8903            ;;
8904        esac
8905    done
8906    AC_MSG_RESULT([no])
8907    EPM=NO
8908fi
8909AC_SUBST(EPM)
8910
8911ENABLE_LWP=
8912if test "$enable_lotuswordpro" = "yes"; then
8913    ENABLE_LWP="TRUE"
8914fi
8915AC_SUBST(ENABLE_LWP)
8916
8917dnl ===================================================================
8918dnl Check for building ODK
8919dnl ===================================================================
8920if test "$enable_odk" != yes; then
8921    unset DOXYGEN
8922else
8923    if test "$with_doxygen" = no; then
8924        AC_MSG_CHECKING([for doxygen])
8925        unset DOXYGEN
8926        AC_MSG_RESULT([no])
8927    else
8928        if test "$with_doxygen" = yes; then
8929            AC_PATH_PROG([DOXYGEN], [doxygen])
8930            if test -z "$DOXYGEN"; then
8931                AC_MSG_ERROR([doxygen not found in \$PATH; specify its pathname via --with-doxygen=..., or disable its use via --without-doxygen])
8932            fi
8933            if $DOXYGEN -g - | grep -q "HAVE_DOT *= *YES"; then
8934                if ! dot -V 2>/dev/null; then
8935                    AC_MSG_ERROR([dot not found in \$PATH but doxygen defaults to HAVE_DOT=YES; install graphviz or disable its use via --without-doxygen])
8936                fi
8937            fi
8938        else
8939            AC_MSG_CHECKING([for doxygen])
8940            DOXYGEN=$with_doxygen
8941            AC_MSG_RESULT([$DOXYGEN])
8942        fi
8943        if test -n "$DOXYGEN"; then
8944            DOXYGEN_VERSION=`$DOXYGEN --version 2>/dev/null`
8945            DOXYGEN_NUMVERSION=`echo $DOXYGEN_VERSION | $AWK -F. '{ print \$1*10000 + \$2*100 + \$3 }'`
8946            if ! test "$DOXYGEN_NUMVERSION" -ge "10804" ; then
8947                AC_MSG_ERROR([found doxygen is too old; need at least version 1.8.4 or specify --without-doxygen])
8948            fi
8949        fi
8950    fi
8951fi
8952AC_SUBST([DOXYGEN])
8953
8954AC_MSG_CHECKING([whether to build the ODK])
8955if test "$enable_odk" = yes; then
8956    AC_MSG_RESULT([yes])
8957    BUILD_TYPE="$BUILD_TYPE ODK"
8958else
8959    AC_MSG_RESULT([no])
8960fi
8961
8962dnl ===================================================================
8963dnl Check for system zlib
8964dnl ===================================================================
8965if test "$with_system_zlib" = "auto"; then
8966    case "$_os" in
8967    WINNT)
8968        with_system_zlib="$with_system_libs"
8969        ;;
8970    *)
8971        if test "$enable_fuzzers" != "yes"; then
8972            with_system_zlib=yes
8973        else
8974            with_system_zlib=no
8975        fi
8976        ;;
8977    esac
8978fi
8979
8980dnl we want to use libo_CHECK_SYSTEM_MODULE here too, but macOS is too stupid
8981dnl and has no pkg-config for it at least on some tinderboxes,
8982dnl so leaving that out for now
8983dnl libo_CHECK_SYSTEM_MODULE([zlib],[ZLIB],[zlib])
8984AC_MSG_CHECKING([which zlib to use])
8985if test "$with_system_zlib" = "yes"; then
8986    AC_MSG_RESULT([external])
8987    SYSTEM_ZLIB=TRUE
8988    AC_CHECK_HEADER(zlib.h, [],
8989        [AC_MSG_ERROR(zlib.h not found. install zlib)], [])
8990    AC_CHECK_LIB(z, deflate, [ ZLIB_LIBS=-lz ],
8991        [AC_MSG_ERROR(zlib not found or functional)], [])
8992else
8993    AC_MSG_RESULT([internal])
8994    SYSTEM_ZLIB=
8995    BUILD_TYPE="$BUILD_TYPE ZLIB"
8996    ZLIB_CFLAGS="-I${WORKDIR}/UnpackedTarball/zlib"
8997    ZLIB_LIBS="-L${WORKDIR}/LinkTarget/StaticLibrary -lzlib"
8998fi
8999AC_SUBST(ZLIB_CFLAGS)
9000AC_SUBST(ZLIB_LIBS)
9001AC_SUBST(SYSTEM_ZLIB)
9002
9003dnl ===================================================================
9004dnl Check for system jpeg
9005dnl ===================================================================
9006AC_MSG_CHECKING([which libjpeg to use])
9007if test "$with_system_jpeg" = "yes"; then
9008    AC_MSG_RESULT([external])
9009    SYSTEM_LIBJPEG=TRUE
9010    AC_CHECK_HEADER(jpeglib.h, [ LIBJPEG_CFLAGS= ],
9011        [AC_MSG_ERROR(jpeg.h not found. install libjpeg)], [])
9012    AC_CHECK_LIB(jpeg, jpeg_resync_to_restart, [ LIBJPEG_LIBS="-ljpeg" ],
9013        [AC_MSG_ERROR(jpeg library not found or functional)], [])
9014else
9015    SYSTEM_LIBJPEG=
9016    AC_MSG_RESULT([internal, libjpeg-turbo])
9017    BUILD_TYPE="$BUILD_TYPE LIBJPEG_TURBO"
9018    LIBJPEG_CFLAGS="-I${WORKDIR}/UnpackedTarball/libjpeg-turbo"
9019    if test "$COM" = "MSC"; then
9020        LIBJPEG_LIBS="${WORKDIR}/UnpackedTarball/libjpeg-turbo/.libs/libjpeg.lib"
9021    else
9022        LIBJPEG_LIBS="-L${WORKDIR}/UnpackedTarball/libjpeg-turbo/.libs -ljpeg"
9023    fi
9024
9025    case "$host_cpu" in
9026    x86_64 | amd64 | i*86 | x86 | ia32)
9027        AC_CHECK_PROGS(NASM, [nasm nasmw yasm])
9028        if test -z "$NASM" -a "$build_os" = "cygwin"; then
9029            if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/nasm"; then
9030                NASM="$LODE_HOME/opt/bin/nasm"
9031            elif test -x "/opt/lo/bin/nasm"; then
9032                NASM="/opt/lo/bin/nasm"
9033            fi
9034        fi
9035
9036        if test -n "$NASM"; then
9037            AC_MSG_CHECKING([for object file format of host system])
9038            case "$host_os" in
9039              cygwin* | mingw* | pw32* | wsl*)
9040                case "$host_cpu" in
9041                  x86_64)
9042                    objfmt='Win64-COFF'
9043                    ;;
9044                  *)
9045                    objfmt='Win32-COFF'
9046                    ;;
9047                esac
9048              ;;
9049              msdosdjgpp* | go32*)
9050                objfmt='COFF'
9051              ;;
9052              os2-emx*) # not tested
9053                objfmt='MSOMF' # obj
9054              ;;
9055              linux*coff* | linux*oldld*)
9056                objfmt='COFF' # ???
9057              ;;
9058              linux*aout*)
9059                objfmt='a.out'
9060              ;;
9061              linux*)
9062                case "$host_cpu" in
9063                  x86_64)
9064                    objfmt='ELF64'
9065                    ;;
9066                  *)
9067                    objfmt='ELF'
9068                    ;;
9069                esac
9070              ;;
9071              kfreebsd* | freebsd* | netbsd* | openbsd*)
9072                if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
9073                  objfmt='BSD-a.out'
9074                else
9075                  case "$host_cpu" in
9076                    x86_64 | amd64)
9077                      objfmt='ELF64'
9078                      ;;
9079                    *)
9080                      objfmt='ELF'
9081                      ;;
9082                  esac
9083                fi
9084              ;;
9085              solaris* | sunos* | sysv* | sco*)
9086                case "$host_cpu" in
9087                  x86_64)
9088                    objfmt='ELF64'
9089                    ;;
9090                  *)
9091                    objfmt='ELF'
9092                    ;;
9093                esac
9094              ;;
9095              darwin* | rhapsody* | nextstep* | openstep* | macos*)
9096                case "$host_cpu" in
9097                  x86_64)
9098                    objfmt='Mach-O64'
9099                    ;;
9100                  *)
9101                    objfmt='Mach-O'
9102                    ;;
9103                esac
9104              ;;
9105              *)
9106                objfmt='ELF ?'
9107              ;;
9108            esac
9109
9110            AC_MSG_RESULT([$objfmt])
9111            if test "$objfmt" = 'ELF ?'; then
9112              objfmt='ELF'
9113              AC_MSG_WARN([unexpected host system. assumed that the format is $objfmt.])
9114            fi
9115
9116            AC_MSG_CHECKING([for object file format specifier (NAFLAGS) ])
9117            case "$objfmt" in
9118              MSOMF)      NAFLAGS='-fobj -DOBJ32';;
9119              Win32-COFF) NAFLAGS='-fwin32 -DWIN32';;
9120              Win64-COFF) NAFLAGS='-fwin64 -DWIN64 -D__x86_64__';;
9121              COFF)       NAFLAGS='-fcoff -DCOFF';;
9122              a.out)      NAFLAGS='-faout -DAOUT';;
9123              BSD-a.out)  NAFLAGS='-faoutb -DAOUT';;
9124              ELF)        NAFLAGS='-felf -DELF';;
9125              ELF64)      NAFLAGS='-felf64 -DELF -D__x86_64__';;
9126              RDF)        NAFLAGS='-frdf -DRDF';;
9127              Mach-O)     NAFLAGS='-fmacho -DMACHO';;
9128              Mach-O64)   NAFLAGS='-fmacho64 -DMACHO -D__x86_64__';;
9129            esac
9130            AC_MSG_RESULT([$NAFLAGS])
9131
9132            AC_MSG_CHECKING([whether the assembler ($NASM $NAFLAGS) works])
9133            cat > conftest.asm << EOF
9134            [%line __oline__ "configure"
9135                    section .text
9136                    global  _main,main
9137            _main:
9138            main:   xor     eax,eax
9139                    ret
9140            ]
9141EOF
9142            try_nasm='$NASM $NAFLAGS -o conftest.o conftest.asm'
9143            if AC_TRY_EVAL(try_nasm) && test -s conftest.o; then
9144              AC_MSG_RESULT(yes)
9145            else
9146              echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
9147              cat conftest.asm >&AS_MESSAGE_LOG_FD
9148              rm -rf conftest*
9149              AC_MSG_RESULT(no)
9150              AC_MSG_WARN([installation or configuration problem: assembler cannot create object files.])
9151              NASM=""
9152            fi
9153
9154        fi
9155
9156        if test -z "$NASM"; then
9157cat << _EOS
9158****************************************************************************
9159You need yasm or nasm (Netwide Assembler) to build the internal jpeg library optimally.
9160To get one please:
9161
9162_EOS
9163            if test "$build_os" = "cygwin"; then
9164cat << _EOS
9165install a pre-compiled binary for Win32
9166
9167mkdir -p /opt/lo/bin
9168cd /opt/lo/bin
9169wget https://dev-www.libreoffice.org/bin/cygwin/nasm.exe
9170chmod +x nasm
9171
9172or get and install one from http://www.nasm.us/
9173
9174Then re-run autogen.sh
9175
9176Note: autogen.sh will try to use /opt/lo/bin/nasm if the environment variable NASM is not already defined.
9177Alternatively, you can install the 'new' nasm where ever you want and make sure that \`which nasm\` finds it.
9178
9179_EOS
9180            else
9181cat << _EOS
9182consult https://github.com/libjpeg-turbo/libjpeg-turbo/blob/master/BUILDING.md
9183
9184_EOS
9185            fi
9186            AC_MSG_WARN([no suitable nasm (Netwide Assembler) found])
9187            add_warning "no suitable nasm (Netwide Assembler) found for internal libjpeg-turbo"
9188        fi
9189      ;;
9190    esac
9191fi
9192
9193AC_SUBST(NASM)
9194AC_SUBST(LIBJPEG_CFLAGS)
9195AC_SUBST(LIBJPEG_LIBS)
9196AC_SUBST(SYSTEM_LIBJPEG)
9197
9198dnl ===================================================================
9199dnl Check for system clucene
9200dnl ===================================================================
9201dnl we should rather be using
9202dnl libo_CHECK_SYSTEM_MODULE([clucence],[CLUCENE],[liblucence-core]) here
9203dnl but the contribs-lib check seems tricky
9204AC_MSG_CHECKING([which clucene to use])
9205if test "$with_system_clucene" = "yes"; then
9206    AC_MSG_RESULT([external])
9207    SYSTEM_CLUCENE=TRUE
9208    PKG_CHECK_MODULES(CLUCENE, libclucene-core)
9209    CLUCENE_CFLAGS=[$(printf '%s' "$CLUCENE_CFLAGS" | sed -e 's@-I[^ ]*/CLucene/ext@@' -e "s/-I/${ISYSTEM?}/g")]
9210    FilterLibs "${CLUCENE_LIBS}"
9211    CLUCENE_LIBS="${filteredlibs}"
9212    AC_LANG_PUSH([C++])
9213    save_CXXFLAGS=$CXXFLAGS
9214    save_CPPFLAGS=$CPPFLAGS
9215    CXXFLAGS="$CXXFLAGS $CLUCENE_CFLAGS"
9216    CPPFLAGS="$CPPFLAGS $CLUCENE_CFLAGS"
9217    dnl http://sourceforge.net/tracker/index.php?func=detail&aid=3392466&group_id=80013&atid=558446
9218    dnl https://bugzilla.redhat.com/show_bug.cgi?id=794795
9219    AC_CHECK_HEADER([CLucene/analysis/cjk/CJKAnalyzer.h], [],
9220                 [AC_MSG_ERROR([Your version of libclucene has contribs-lib missing.])], [#include <CLucene.h>])
9221    CXXFLAGS=$save_CXXFLAGS
9222    CPPFLAGS=$save_CPPFLAGS
9223    AC_LANG_POP([C++])
9224
9225    CLUCENE_LIBS="$CLUCENE_LIBS -lclucene-contribs-lib"
9226else
9227    AC_MSG_RESULT([internal])
9228    SYSTEM_CLUCENE=
9229    BUILD_TYPE="$BUILD_TYPE CLUCENE"
9230fi
9231AC_SUBST(SYSTEM_CLUCENE)
9232AC_SUBST(CLUCENE_CFLAGS)
9233AC_SUBST(CLUCENE_LIBS)
9234
9235dnl ===================================================================
9236dnl Check for system expat
9237dnl ===================================================================
9238libo_CHECK_SYSTEM_MODULE([expat], [EXPAT], [expat])
9239
9240dnl ===================================================================
9241dnl Check for system xmlsec
9242dnl ===================================================================
9243libo_CHECK_SYSTEM_MODULE([xmlsec], [XMLSEC], [xmlsec1-nss >= 1.2.28])
9244
9245AC_MSG_CHECKING([whether to enable Embedded OpenType support])
9246if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_eot" = "yes"; then
9247    ENABLE_EOT="TRUE"
9248    AC_DEFINE([ENABLE_EOT])
9249    AC_MSG_RESULT([yes])
9250
9251    libo_CHECK_SYSTEM_MODULE([libeot],[LIBEOT],[libeot >= 0.01])
9252else
9253    ENABLE_EOT=
9254    AC_MSG_RESULT([no])
9255fi
9256AC_SUBST([ENABLE_EOT])
9257
9258dnl ===================================================================
9259dnl Check for DLP libs
9260dnl ===================================================================
9261AS_IF([test "$COM" = "MSC"],
9262      [librevenge_libdir="${WORKDIR}/LinkTarget/Library"],
9263      [librevenge_libdir="${WORKDIR}/UnpackedTarball/librevenge/src/lib/.libs"]
9264)
9265libo_CHECK_SYSTEM_MODULE([librevenge],[REVENGE],[librevenge-0.0 >= 0.0.1],["-I${WORKDIR}/UnpackedTarball/librevenge/inc"],["-L${librevenge_libdir} -lrevenge-0.0"])
9266
9267libo_CHECK_SYSTEM_MODULE([libodfgen],[ODFGEN],[libodfgen-0.1])
9268
9269libo_CHECK_SYSTEM_MODULE([libepubgen],[EPUBGEN],[libepubgen-0.1])
9270
9271AS_IF([test "$COM" = "MSC"],
9272      [libwpd_libdir="${WORKDIR}/LinkTarget/Library"],
9273      [libwpd_libdir="${WORKDIR}/UnpackedTarball/libwpd/src/lib/.libs"]
9274)
9275libo_CHECK_SYSTEM_MODULE([libwpd],[WPD],[libwpd-0.10],["-I${WORKDIR}/UnpackedTarball/libwpd/inc"],["-L${libwpd_libdir} -lwpd-0.10"])
9276
9277libo_CHECK_SYSTEM_MODULE([libwpg],[WPG],[libwpg-0.3])
9278
9279libo_CHECK_SYSTEM_MODULE([libwps],[WPS],[libwps-0.4])
9280libo_PKG_VERSION([WPS], [libwps-0.4], [0.4.12])
9281
9282libo_CHECK_SYSTEM_MODULE([libvisio],[VISIO],[libvisio-0.1])
9283
9284libo_CHECK_SYSTEM_MODULE([libcdr],[CDR],[libcdr-0.1])
9285
9286libo_CHECK_SYSTEM_MODULE([libmspub],[MSPUB],[libmspub-0.1])
9287
9288libo_CHECK_SYSTEM_MODULE([libmwaw],[MWAW],[libmwaw-0.3 >= 0.3.1])
9289libo_PKG_VERSION([MWAW], [libmwaw-0.3], [0.3.19])
9290
9291libo_CHECK_SYSTEM_MODULE([libetonyek],[ETONYEK],[libetonyek-0.1])
9292libo_PKG_VERSION([ETONYEK], [libetonyek-0.1], [0.1.10])
9293
9294libo_CHECK_SYSTEM_MODULE([libfreehand],[FREEHAND],[libfreehand-0.1])
9295
9296libo_CHECK_SYSTEM_MODULE([libebook],[EBOOK],[libe-book-0.1])
9297libo_PKG_VERSION([EBOOK], [libe-book-0.1], [0.1.2])
9298
9299libo_CHECK_SYSTEM_MODULE([libabw],[ABW],[libabw-0.1])
9300
9301libo_CHECK_SYSTEM_MODULE([libpagemaker],[PAGEMAKER],[libpagemaker-0.0])
9302
9303libo_CHECK_SYSTEM_MODULE([libqxp],[QXP],[libqxp-0.0])
9304
9305libo_CHECK_SYSTEM_MODULE([libzmf],[ZMF],[libzmf-0.0])
9306
9307libo_CHECK_SYSTEM_MODULE([libstaroffice],[STAROFFICE],[libstaroffice-0.0])
9308libo_PKG_VERSION([STAROFFICE], [libstaroffice-0.0], [0.0.7])
9309
9310dnl ===================================================================
9311dnl Check for system lcms2
9312dnl ===================================================================
9313if test "$with_system_lcms2" != "yes"; then
9314    SYSTEM_LCMS2=
9315fi
9316libo_CHECK_SYSTEM_MODULE([lcms2],[LCMS2],[lcms2],["-I${WORKDIR}/UnpackedTarball/lcms2/include"],["-L${WORKDIR}/UnpackedTarball/lcms2/src/.libs -llcms2"])
9317if test "$GCC" = "yes"; then
9318    LCMS2_CFLAGS="${LCMS2_CFLAGS} -Wno-long-long"
9319fi
9320if test "$COM" = "MSC"; then # override the above
9321    LCMS2_LIBS=${WORKDIR}/UnpackedTarball/lcms2/bin/lcms2.lib
9322fi
9323
9324dnl ===================================================================
9325dnl Check for system cppunit
9326dnl ===================================================================
9327if test "$_os" != "Android" ; then
9328    libo_CHECK_SYSTEM_MODULE([cppunit],[CPPUNIT],[cppunit >= 1.14.0])
9329fi
9330
9331dnl ===================================================================
9332dnl Check whether freetype is available
9333dnl ===================================================================
9334if test "$using_freetype_fontconfig" = yes; then
9335    AC_MSG_CHECKING([which freetype to use])
9336fi
9337if test "$using_freetype_fontconfig" = yes -a "$test_system_freetype" != no; then
9338    AC_MSG_RESULT([external])
9339    # FreeType has 3 different kinds of versions
9340    # * release, like 2.4.10
9341    # * libtool, like 13.0.7 (this what pkg-config returns)
9342    # * soname
9343    # FreeType's docs/VERSION.DLL provides a table mapping between the three
9344    #
9345    # 9.9.3 is 2.2.0
9346    PKG_CHECK_MODULES(FREETYPE, freetype2 >= 9.9.3)
9347    FREETYPE_CFLAGS=$(printf '%s' "$FREETYPE_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
9348    FilterLibs "${FREETYPE_LIBS}"
9349    FREETYPE_LIBS="${filteredlibs}"
9350    SYSTEM_FREETYPE=TRUE
9351elif test "$using_freetype_fontconfig" = yes; then
9352    AC_MSG_RESULT([internal])
9353    FREETYPE_CFLAGS="${ISYSTEM}${WORKDIR}/UnpackedTarball/freetype/include"
9354    if test "x$ac_config_site_64bit_host" = xYES; then
9355        FREETYPE_LIBS="-L${WORKDIR}/UnpackedTarball/freetype/instdir/lib64 -lfreetype"
9356    else
9357        FREETYPE_LIBS="-L${WORKDIR}/UnpackedTarball/freetype/instdir/lib -lfreetype"
9358    fi
9359    BUILD_TYPE="$BUILD_TYPE FREETYPE"
9360fi
9361AC_SUBST(FREETYPE_CFLAGS)
9362AC_SUBST(FREETYPE_LIBS)
9363AC_SUBST([SYSTEM_FREETYPE])
9364
9365# ===================================================================
9366# Check for system libxslt
9367# to prevent incompatibilities between internal libxml2 and external libxslt,
9368# or vice versa, use with_system_libxml here
9369# ===================================================================
9370if test "$with_system_libxml" = "auto"; then
9371    case "$_os" in
9372    WINNT|iOS|Android)
9373        with_system_libxml="$with_system_libs"
9374        ;;
9375    Emscripten)
9376        with_system_libxml=no
9377        ;;
9378    *)
9379        if test "$enable_fuzzers" != "yes"; then
9380            with_system_libxml=yes
9381        else
9382            with_system_libxml=no
9383        fi
9384        ;;
9385    esac
9386fi
9387
9388AC_MSG_CHECKING([which libxslt to use])
9389if test "$with_system_libxml" = "yes"; then
9390    AC_MSG_RESULT([external])
9391    SYSTEM_LIBXSLT=TRUE
9392    if test "$_os" = "Darwin"; then
9393        dnl make sure to use SDK path
9394        LIBXSLT_CFLAGS="-I$MACOSX_SDK_PATH/usr/include/libxml2"
9395        LIBEXSLT_CFLAGS="$LIBXSLT_CFLAGS"
9396        dnl omit -L/usr/lib
9397        LIBXSLT_LIBS="-lxslt -lxml2 -lz -lpthread -liconv -lm"
9398        LIBEXSLT_LIBS="-lexslt $LIBXSLT_LIBS"
9399    else
9400        PKG_CHECK_MODULES(LIBXSLT, libxslt)
9401        LIBXSLT_CFLAGS=$(printf '%s' "$LIBXSLT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
9402        FilterLibs "${LIBXSLT_LIBS}"
9403        LIBXSLT_LIBS="${filteredlibs}"
9404        PKG_CHECK_MODULES(LIBEXSLT, libexslt)
9405        LIBEXSLT_CFLAGS=$(printf '%s' "$LIBEXSLT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
9406        FilterLibs "${LIBEXSLT_LIBS}"
9407        LIBEXSLT_LIBS=$(printf '%s' "${filteredlibs}" | sed -e "s/-lgpg-error//"  -e "s/-lgcrypt//")
9408    fi
9409
9410    dnl Check for xsltproc
9411    AC_PATH_PROG(XSLTPROC, xsltproc, no)
9412    if test "$XSLTPROC" = "no"; then
9413        AC_MSG_ERROR([xsltproc is required])
9414    fi
9415else
9416    AC_MSG_RESULT([internal])
9417    SYSTEM_LIBXSLT=
9418    BUILD_TYPE="$BUILD_TYPE LIBXSLT"
9419fi
9420AC_SUBST(SYSTEM_LIBXSLT)
9421if test -z "$SYSTEM_LIBXSLT_FOR_BUILD"; then
9422    SYSTEM_LIBXSLT_FOR_BUILD="$SYSTEM_LIBXSLT"
9423fi
9424AC_SUBST(SYSTEM_LIBXSLT_FOR_BUILD)
9425
9426AC_SUBST(LIBEXSLT_CFLAGS)
9427AC_SUBST(LIBEXSLT_LIBS)
9428AC_SUBST(LIBXSLT_CFLAGS)
9429AC_SUBST(LIBXSLT_LIBS)
9430AC_SUBST(XSLTPROC)
9431
9432# ===================================================================
9433# Check for system libxml
9434# ===================================================================
9435AC_MSG_CHECKING([which libxml to use])
9436if test "$with_system_libxml" = "yes"; then
9437    AC_MSG_RESULT([external])
9438    SYSTEM_LIBXML=TRUE
9439    if test "$_os" = "Darwin"; then
9440        dnl make sure to use SDK path
9441        LIBXML_CFLAGS="-I$MACOSX_SDK_PATH/usr/include/libxml2"
9442        dnl omit -L/usr/lib
9443        LIBXML_LIBS="-lxml2 -lz -lpthread -liconv -lm"
9444    elif test $_os = iOS; then
9445        dnl make sure to use SDK path
9446        usr=`echo '#include <stdlib.h>' | $CC -E -MD - | grep usr/include/stdlib.h | head -1 | sed -e 's,# 1 ",,' -e 's,/usr/include/.*,/usr,'`
9447        LIBXML_CFLAGS="-I$usr/include/libxml2"
9448        LIBXML_LIBS="-L$usr/lib -lxml2 -liconv"
9449    else
9450        PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= 2.0)
9451        LIBXML_CFLAGS=$(printf '%s' "$LIBXML_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
9452        FilterLibs "${LIBXML_LIBS}"
9453        LIBXML_LIBS="${filteredlibs}"
9454    fi
9455
9456    dnl Check for xmllint
9457    AC_PATH_PROG(XMLLINT, xmllint, no)
9458    if test "$XMLLINT" = "no"; then
9459        AC_MSG_ERROR([xmllint is required])
9460    fi
9461else
9462    AC_MSG_RESULT([internal])
9463    SYSTEM_LIBXML=
9464    LIBXML_CFLAGS="-I${WORKDIR}/UnpackedTarball/libxml2/include"
9465    if test "$COM" = "MSC"; then
9466        LIBXML_CFLAGS="${LIBXML_CFLAGS} -I${WORKDIR}/UnpackedTarball/icu/source/i18n -I${WORKDIR}/UnpackedTarball/icu/source/common"
9467    fi
9468    if test "$COM" = "MSC"; then
9469        LIBXML_LIBS="${WORKDIR}/UnpackedTarball/libxml2/win32/bin.msvc/libxml2.lib"
9470    else
9471        LIBXML_LIBS="-L${WORKDIR}/UnpackedTarball/libxml2/.libs -lxml2"
9472        if test "$_os" = Android; then
9473            LIBXML_LIBS="$LIBXML_LIBS -lm"
9474        fi
9475    fi
9476    BUILD_TYPE="$BUILD_TYPE LIBXML2"
9477fi
9478AC_SUBST(SYSTEM_LIBXML)
9479if test -z "$SYSTEM_LIBXML_FOR_BUILD"; then
9480    SYSTEM_LIBXML_FOR_BUILD="$SYSTEM_LIBXML"
9481fi
9482AC_SUBST(SYSTEM_LIBXML_FOR_BUILD)
9483AC_SUBST(LIBXML_CFLAGS)
9484AC_SUBST(LIBXML_LIBS)
9485AC_SUBST(XMLLINT)
9486
9487# =====================================================================
9488# Checking for a Python interpreter with version >= 3.3.
9489# Optionally user can pass an option to configure, i. e.
9490# ./configure PYTHON=/usr/bin/python
9491# =====================================================================
9492if test $_os = Darwin -a "$enable_python" != no -a "$enable_python" != fully-internal -a "$enable_python" != internal -a "$enable_python" != system; then
9493    # Only allowed choices for macOS are 'no', 'internal' (default), and 'fully-internal'
9494    # unless PYTHON is defined as above which allows 'system'
9495    enable_python=internal
9496fi
9497if test "$build_os" != "cygwin" -a "$enable_python" != fully-internal; then
9498    if test -n "$PYTHON"; then
9499        PYTHON_FOR_BUILD=$PYTHON
9500    else
9501        # This allows a lack of system python with no error, we use internal one in that case.
9502        AM_PATH_PYTHON([3.3],, [:])
9503        # Clean PYTHON_VERSION checked below if cross-compiling
9504        PYTHON_VERSION=""
9505        if test "$PYTHON" != ":"; then
9506            PYTHON_FOR_BUILD=$PYTHON
9507        fi
9508    fi
9509fi
9510AC_SUBST(PYTHON_FOR_BUILD)
9511
9512# Checks for Python to use for Pyuno
9513AC_MSG_CHECKING([which Python to use for Pyuno])
9514case "$enable_python" in
9515no|disable)
9516    if test -z $PYTHON_FOR_BUILD; then
9517        # Python is required to build LibreOffice. In theory we could separate the build-time Python
9518        # requirement from the choice whether to include Python stuff in the installer, but why
9519        # bother?
9520        if test "$cross_compiling" = yes; then
9521            enable_python=system
9522        else
9523            AC_MSG_ERROR([Python is required at build time.])
9524        fi
9525    fi
9526    enable_python=no
9527    AC_MSG_RESULT([none])
9528    ;;
9529""|yes|auto)
9530    if test "$DISABLE_SCRIPTING" = TRUE -a -n "$PYTHON_FOR_BUILD"; then
9531        AC_MSG_RESULT([no, overridden by --disable-scripting])
9532        enable_python=no
9533    elif test $build_os = cygwin; then
9534        dnl When building on Windows we don't attempt to use any installed
9535        dnl "system"  Python.
9536        AC_MSG_RESULT([fully internal])
9537        enable_python=internal
9538    elif test "$cross_compiling" = yes; then
9539        AC_MSG_RESULT([system])
9540        enable_python=system
9541    else
9542        # Unset variables set by the above AM_PATH_PYTHON so that
9543        # we actually do check anew.
9544        AC_MSG_RESULT([])
9545        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
9546        AM_PATH_PYTHON([3.3],, [:])
9547        AC_MSG_CHECKING([which Python to use for Pyuno])
9548        if test "$PYTHON" = ":"; then
9549            if test -z "$PYTHON_FOR_BUILD"; then
9550                AC_MSG_RESULT([fully internal])
9551            else
9552                AC_MSG_RESULT([internal])
9553            fi
9554            enable_python=internal
9555        else
9556            AC_MSG_RESULT([system])
9557            enable_python=system
9558        fi
9559    fi
9560    ;;
9561internal)
9562    AC_MSG_RESULT([internal])
9563    ;;
9564fully-internal)
9565    AC_MSG_RESULT([fully internal])
9566    enable_python=internal
9567    ;;
9568system)
9569    AC_MSG_RESULT([system])
9570    if test "$_os" = Darwin -a -z "$PYTHON"; then
9571        AC_MSG_ERROR([--enable-python=system doesn't work on macOS because the version provided is obsolete])
9572    fi
9573    ;;
9574*)
9575    AC_MSG_ERROR([Incorrect --enable-python option])
9576    ;;
9577esac
9578
9579if test $enable_python != no; then
9580    BUILD_TYPE="$BUILD_TYPE PYUNO"
9581fi
9582
9583if test $enable_python = system; then
9584    if test -n "$PYTHON_CFLAGS" -a -n "$PYTHON_LIBS"; then
9585        # Fallback: Accept these in the environment, or as set above
9586        # for MacOSX.
9587        :
9588    elif test "$cross_compiling" != yes; then
9589        # Unset variables set by the above AM_PATH_PYTHON so that
9590        # we actually do check anew.
9591        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
9592        # This causes an error if no python command is found
9593        AM_PATH_PYTHON([3.3])
9594        python_include=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('INCLUDEPY'));"`
9595        python_version=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('VERSION'));"`
9596        python_libs=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBS'));"`
9597        python_libdir=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBDIR'));"`
9598        if test -z "$PKG_CONFIG"; then
9599            PYTHON_CFLAGS="-I$python_include"
9600            PYTHON_LIBS="-L$python_libdir -lpython$python_version $python_libs"
9601        elif $PKG_CONFIG --exists python-$python_version-embed; then
9602            PYTHON_CFLAGS="`$PKG_CONFIG --cflags python-$python_version-embed`"
9603            PYTHON_LIBS="`$PKG_CONFIG --libs python-$python_version-embed` $python_libs"
9604        elif $PKG_CONFIG --exists python-$python_version; then
9605            PYTHON_CFLAGS="`$PKG_CONFIG --cflags python-$python_version`"
9606            PYTHON_LIBS="`$PKG_CONFIG --libs python-$python_version` $python_libs"
9607        else
9608            PYTHON_CFLAGS="-I$python_include"
9609            PYTHON_LIBS="-L$python_libdir -lpython$python_version $python_libs"
9610        fi
9611        FilterLibs "${PYTHON_LIBS}"
9612        PYTHON_LIBS="${filteredlibs}"
9613    else
9614        dnl How to find out the cross-compilation Python installation path?
9615        AC_MSG_CHECKING([for python version])
9616        AS_IF([test -n "$PYTHON_VERSION"],
9617              [AC_MSG_RESULT([$PYTHON_VERSION])],
9618              [AC_MSG_RESULT([not found])
9619               AC_MSG_ERROR([no usable python found])])
9620        test -n "$PYTHON_CFLAGS" && break
9621    fi
9622
9623    dnl Check if the headers really work
9624    save_CPPFLAGS="$CPPFLAGS"
9625    CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
9626    AC_CHECK_HEADER(Python.h)
9627    CPPFLAGS="$save_CPPFLAGS"
9628
9629    # let the PYTHON_FOR_BUILD match the same python installation that
9630    # provides PYTHON_CFLAGS/PYTHON_LDFLAGS for pyuno, which should be
9631    # better for PythonTests.
9632    PYTHON_FOR_BUILD=$PYTHON
9633fi
9634
9635if test "$with_lxml" != no; then
9636    if test -z "$PYTHON_FOR_BUILD"; then
9637        case $build_os in
9638            cygwin)
9639                AC_MSG_WARN([No system-provided python lxml, gla11y will only report widget classes and ids])
9640                ;;
9641            *)
9642                if test "$cross_compiling" != yes ; then
9643                    BUILD_TYPE="$BUILD_TYPE LXML"
9644                fi
9645                ;;
9646        esac
9647    else
9648        AC_MSG_CHECKING([for python lxml])
9649        if $PYTHON_FOR_BUILD -c "import lxml.etree as ET" 2> /dev/null ; then
9650            AC_MSG_RESULT([yes])
9651        else
9652            case $build_os in
9653                cygwin)
9654                    AC_MSG_RESULT([no, gla11y will only report widget classes and ids])
9655                    ;;
9656                *)
9657                    if test "$cross_compiling" != yes -a "x$ac_cv_header_Python_h" = "xyes"; then
9658                        if test -n ${SYSTEM_LIBXSLT} -o -n ${SYSTEM_LIBXML}; then
9659                            AC_MSG_RESULT([no, and no system libxml/libxslt, gla11y will only report widget classes and ids])
9660                        else
9661                            BUILD_TYPE="$BUILD_TYPE LXML"
9662                            AC_MSG_RESULT([no, using internal lxml])
9663                        fi
9664                    else
9665                        AC_MSG_RESULT([no, and system does not provide python development headers, gla11y will only report widget classes and ids])
9666                    fi
9667                    ;;
9668            esac
9669        fi
9670    fi
9671fi
9672
9673dnl By now enable_python should be "system", "internal" or "no"
9674case $enable_python in
9675system)
9676    SYSTEM_PYTHON=TRUE
9677
9678    if test "x$ac_cv_header_Python_h" != "xyes"; then
9679       AC_MSG_ERROR([Python headers not found. You probably want to set both the PYTHON_CFLAGS and PYTHON_LIBS environment variables.])
9680    fi
9681
9682    AC_LANG_PUSH(C)
9683    CFLAGS="$CFLAGS $PYTHON_CFLAGS"
9684    AC_MSG_CHECKING([for correct python library version])
9685       AC_RUN_IFELSE([AC_LANG_SOURCE([[
9686#include <Python.h>
9687
9688int main(int argc, char **argv) {
9689   if ((PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 3)) return 0;
9690   else return 1;
9691}
9692       ]])],[AC_MSG_RESULT([ok])],[AC_MSG_ERROR([Python >= 3.3 is needed when building with Python 3])],[AC_MSG_RESULT([skipped; cross-compiling])])
9693    AC_LANG_POP(C)
9694
9695    dnl FIXME Check if the Python library can be linked with, too?
9696    ;;
9697
9698internal)
9699    SYSTEM_PYTHON=
9700    PYTHON_VERSION_MAJOR=3
9701    PYTHON_VERSION_MINOR=8
9702    PYTHON_VERSION=${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.10
9703    if ! grep -q -i python.*${PYTHON_VERSION} ${SRC_ROOT}/download.lst; then
9704        AC_MSG_ERROR([PYTHON_VERSION ${PYTHON_VERSION} but no matching file in download.lst])
9705    fi
9706    AC_DEFINE_UNQUOTED([PYTHON_VERSION_STRING], [L"${PYTHON_VERSION}"])
9707    BUILD_TYPE="$BUILD_TYPE PYTHON"
9708    if test "$OS" = LINUX -o "$OS" = WNT ; then
9709        BUILD_TYPE="$BUILD_TYPE LIBFFI"
9710    fi
9711    # Embedded Python dies without Home set
9712    if test "$HOME" = ""; then
9713        export HOME=""
9714    fi
9715    ;;
9716no)
9717    DISABLE_PYTHON=TRUE
9718    SYSTEM_PYTHON=
9719    ;;
9720*)
9721    AC_MSG_ERROR([Internal configure script error, invalid enable_python value "$enable_python"])
9722    ;;
9723esac
9724
9725AC_SUBST(DISABLE_PYTHON)
9726AC_SUBST(SYSTEM_PYTHON)
9727AC_SUBST(PYTHON_CFLAGS)
9728AC_SUBST(PYTHON_LIBS)
9729AC_SUBST(PYTHON_VERSION)
9730AC_SUBST(PYTHON_VERSION_MAJOR)
9731AC_SUBST(PYTHON_VERSION_MINOR)
9732
9733AC_MSG_CHECKING([whether to build LibreLogo])
9734case "$enable_python" in
9735no|disable)
9736    AC_MSG_RESULT([no; Python disabled])
9737    ;;
9738*)
9739    if test "${enable_librelogo}" = "no"; then
9740        AC_MSG_RESULT([no])
9741    else
9742        AC_MSG_RESULT([yes])
9743        BUILD_TYPE="${BUILD_TYPE} LIBRELOGO"
9744        AC_DEFINE([ENABLE_LIBRELOGO],1)
9745    fi
9746    ;;
9747esac
9748AC_SUBST(ENABLE_LIBRELOGO)
9749
9750ENABLE_MARIADBC=
9751MARIADBC_MAJOR=1
9752MARIADBC_MINOR=0
9753MARIADBC_MICRO=2
9754AC_MSG_CHECKING([whether to build the MariaDB/MySQL SDBC driver])
9755if test "x$enable_mariadb_sdbc" != "xno" -a "$enable_mpl_subset" != "yes"; then
9756    ENABLE_MARIADBC=TRUE
9757    AC_MSG_RESULT([yes])
9758    BUILD_TYPE="$BUILD_TYPE MARIADBC"
9759else
9760    AC_MSG_RESULT([no])
9761fi
9762AC_SUBST(ENABLE_MARIADBC)
9763AC_SUBST(MARIADBC_MAJOR)
9764AC_SUBST(MARIADBC_MINOR)
9765AC_SUBST(MARIADBC_MICRO)
9766
9767if test "$ENABLE_MARIADBC" = "TRUE"; then
9768    dnl ===================================================================
9769    dnl Check for system MariaDB
9770    dnl ===================================================================
9771    AC_MSG_CHECKING([which MariaDB to use])
9772    if test "$with_system_mariadb" = "yes"; then
9773        AC_MSG_RESULT([external])
9774        SYSTEM_MARIADB_CONNECTOR_C=TRUE
9775        #AC_PATH_PROG(MARIADBCONFIG, [mariadb_config])
9776        if test -z "$MARIADBCONFIG"; then
9777            AC_PATH_PROG(MARIADBCONFIG, [mysql_config])
9778            if test -z "$MARIADBCONFIG"; then
9779                AC_MSG_ERROR([mysql_config is missing. Install MySQL client library development package.])
9780                #AC_MSG_ERROR([mariadb_config and mysql_config are missing. Install MariaDB or MySQL client library development package.])
9781            fi
9782        fi
9783        AC_MSG_CHECKING([MariaDB version])
9784        MARIADB_VERSION=`$MARIADBCONFIG --version`
9785        MARIADB_MAJOR=`$MARIADBCONFIG --version | cut -d"." -f1`
9786        if test "$MARIADB_MAJOR" -ge "5"; then
9787            AC_MSG_RESULT([OK])
9788        else
9789            AC_MSG_ERROR([too old, use 5.0.x or later])
9790        fi
9791        AC_MSG_CHECKING([for MariaDB Client library])
9792        MARIADB_CFLAGS=`$MARIADBCONFIG --cflags`
9793        if test "$COM_IS_CLANG" = TRUE; then
9794            MARIADB_CFLAGS=$(printf '%s' "$MARIADB_CFLAGS" | sed -e s/-fstack-protector-strong//)
9795        fi
9796        MARIADB_LIBS=`$MARIADBCONFIG --libs_r`
9797        dnl At least mariadb-5.5.34-3.fc20.x86_64 plus
9798        dnl mariadb-5.5.34-3.fc20.i686 reports 64-bit specific output even under
9799        dnl linux32:
9800        if test "$OS" = LINUX -a "$CPUNAME" = INTEL; then
9801            MARIADB_CFLAGS=$(printf '%s' "$MARIADB_CFLAGS" | sed -e s/-m64//)
9802            MARIADB_LIBS=$(printf '%s' "$MARIADB_LIBS" \
9803                | sed -e 's|/lib64/|/lib/|')
9804        fi
9805        FilterLibs "${MARIADB_LIBS}"
9806        MARIADB_LIBS="${filteredlibs}"
9807        AC_MSG_RESULT([includes '$MARIADB_CFLAGS', libraries '$MARIADB_LIBS'])
9808        AC_MSG_CHECKING([whether to bundle the MySQL/MariaDB client library])
9809        if test "$enable_bundle_mariadb" = "yes"; then
9810            AC_MSG_RESULT([yes])
9811            BUNDLE_MARIADB_CONNECTOR_C=TRUE
9812            LIBMARIADB=lib$(echo "${MARIADB_LIBS}" | sed -e 's/[[[:space:]]]\{1,\}-l\([[^[:space:]]]\{1,\}\)/\
9813\1\
9814/g' -e 's/^-l\([[^[:space:]]]\{1,\}\)[[[:space:]]]*/\
9815\1\
9816/g' | grep -E '(mysqlclient|mariadb)')
9817            if test "$_os" = "Darwin"; then
9818                LIBMARIADB=${LIBMARIADB}.dylib
9819            elif test "$_os" = "WINNT"; then
9820                LIBMARIADB=${LIBMARIADB}.dll
9821            else
9822                LIBMARIADB=${LIBMARIADB}.so
9823            fi
9824            LIBMARIADB_PATH=$($MARIADBCONFIG --variable=pkglibdir)
9825            AC_MSG_CHECKING([for $LIBMARIADB in $LIBMARIADB_PATH])
9826            if test -e "$LIBMARIADB_PATH/$LIBMARIADB"; then
9827                AC_MSG_RESULT([found.])
9828                PathFormat "$LIBMARIADB_PATH"
9829                LIBMARIADB_PATH="$formatted_path"
9830            else
9831                AC_MSG_ERROR([not found.])
9832            fi
9833        else
9834            AC_MSG_RESULT([no])
9835            BUNDLE_MARIADB_CONNECTOR_C=
9836        fi
9837    else
9838        AC_MSG_RESULT([internal])
9839        SYSTEM_MARIADB_CONNECTOR_C=
9840        MARIADB_CFLAGS="-I${WORKDIR}/UnpackedTarball/mariadb-connector-c/include"
9841        MARIADB_LIBS="-L${WORKDIR}/LinkTarget/StaticLibrary -lmariadb-connector-c"
9842        BUILD_TYPE="$BUILD_TYPE MARIADB_CONNECTOR_C"
9843    fi
9844
9845    AC_SUBST(SYSTEM_MARIADB_CONNECTOR_C)
9846    AC_SUBST(MARIADB_CFLAGS)
9847    AC_SUBST(MARIADB_LIBS)
9848    AC_SUBST(LIBMARIADB)
9849    AC_SUBST(LIBMARIADB_PATH)
9850    AC_SUBST(BUNDLE_MARIADB_CONNECTOR_C)
9851fi
9852
9853dnl ===================================================================
9854dnl Check for system hsqldb
9855dnl ===================================================================
9856if test "$with_java" != "no" -a "$cross_compiling" != "yes"; then
9857    HSQLDB_USE_JDBC_4_1=
9858    AC_MSG_CHECKING([which hsqldb to use])
9859    if test "$with_system_hsqldb" = "yes"; then
9860        AC_MSG_RESULT([external])
9861        SYSTEM_HSQLDB=TRUE
9862        if test -z $HSQLDB_JAR; then
9863            HSQLDB_JAR=/usr/share/java/hsqldb.jar
9864        fi
9865        if ! test -f $HSQLDB_JAR; then
9866               AC_MSG_ERROR(hsqldb.jar not found.)
9867        fi
9868        AC_MSG_CHECKING([whether hsqldb is 1.8.0.x])
9869        export HSQLDB_JAR
9870        if $PERL -e \
9871           'use Archive::Zip;
9872            my $file = "$ENV{'HSQLDB_JAR'}";
9873            my $zip = Archive::Zip->new( $file );
9874            my $mf = $zip->contents ( "META-INF/MANIFEST.MF" );
9875            if ( $mf =~ m/Specification-Version: 1.8.*/ )
9876            {
9877                push @l, split(/\n/, $mf);
9878                foreach my $line (@l)
9879                {
9880                    if ($line =~ m/Specification-Version:/)
9881                    {
9882                        ($t, $version) = split (/:/,$line);
9883                        $version =~ s/^\s//;
9884                        ($a, $b, $c, $d) = split (/\./,$version);
9885                        if ($c == "0" && $d > "8")
9886                        {
9887                            exit 0;
9888                        }
9889                        else
9890                        {
9891                            exit 1;
9892                        }
9893                    }
9894                }
9895            }
9896            else
9897            {
9898                exit 1;
9899            }'; then
9900            AC_MSG_RESULT([yes])
9901        else
9902            AC_MSG_ERROR([no, you need hsqldb >= 1.8.0.9 but < 1.8.1])
9903        fi
9904    else
9905        AC_MSG_RESULT([internal])
9906        SYSTEM_HSQLDB=
9907        BUILD_TYPE="$BUILD_TYPE HSQLDB"
9908        NEED_ANT=TRUE
9909        AC_MSG_CHECKING([whether hsqldb should be built with JDBC 4.1])
9910        javanumver=`$JAVAINTERPRETER -version 2>&1 | $AWK -v num=true -f $SRC_ROOT/solenv/bin/getcompver.awk`
9911        if expr "$javanumver" '>=' 000100060000 > /dev/null; then
9912            AC_MSG_RESULT([yes])
9913            HSQLDB_USE_JDBC_4_1=TRUE
9914        else
9915            AC_MSG_RESULT([no])
9916        fi
9917    fi
9918else
9919    if test "$with_java" != "no" -a -z "$HSQLDB_JAR"; then
9920        BUILD_TYPE="$BUILD_TYPE HSQLDB"
9921    fi
9922fi
9923AC_SUBST(SYSTEM_HSQLDB)
9924AC_SUBST(HSQLDB_JAR)
9925AC_SUBST([HSQLDB_USE_JDBC_4_1])
9926
9927dnl ===================================================================
9928dnl Check for PostgreSQL stuff
9929dnl ===================================================================
9930AC_MSG_CHECKING([whether to build the PostgreSQL SDBC driver])
9931if test "x$enable_postgresql_sdbc" != "xno"; then
9932    AC_MSG_RESULT([yes])
9933    SCPDEFS="$SCPDEFS -DWITH_POSTGRESQL_SDBC"
9934
9935    if test "$with_krb5" = "yes" -a "$enable_openssl" = "no"; then
9936        AC_MSG_ERROR([krb5 needs OpenSSL, but --disable-openssl was given.])
9937    fi
9938    if test "$with_gssapi" = "yes" -a "$enable_openssl" = "no"; then
9939        AC_MSG_ERROR([GSSAPI needs OpenSSL, but --disable-openssl was given.])
9940    fi
9941
9942    postgres_interface=""
9943    if test "$with_system_postgresql" = "yes"; then
9944        postgres_interface="external PostgreSQL"
9945        SYSTEM_POSTGRESQL=TRUE
9946        if test "$_os" = Darwin; then
9947            supp_path=''
9948            for d in /Library/PostgreSQL/9.*/bin /sw/opt/postgresql/9.*/bin /opt/local/lib/postgresql9*/bin; do
9949                pg_supp_path="$P_SEP$d$pg_supp_path"
9950            done
9951        fi
9952        AC_PATH_PROG(PGCONFIG, pg_config, ,$PATH$pg_supp_path)
9953        if test -n "$PGCONFIG"; then
9954            POSTGRESQL_INC=-I$(${PGCONFIG} --includedir)
9955            POSTGRESQL_LIB="-L$(${PGCONFIG} --libdir)"
9956        else
9957            PKG_CHECK_MODULES(POSTGRESQL, libpq, [
9958              POSTGRESQL_INC=$POSTGRESQL_CFLAGS
9959              POSTGRESQL_LIB=$POSTGRESQL_LIBS
9960            ],[
9961              AC_MSG_ERROR([pg_config or 'pkg-config libpq' needed; set PGCONFIG if not in PATH])
9962            ])
9963        fi
9964        FilterLibs "${POSTGRESQL_LIB}"
9965        POSTGRESQL_LIB="${filteredlibs}"
9966    else
9967        # if/when anything else than PostgreSQL uses Kerberos,
9968        # move this out of `test "x$enable_postgresql_sdbc" != "xno"'
9969        WITH_KRB5=
9970        WITH_GSSAPI=
9971        case "$_os" in
9972        Darwin)
9973            # macOS has system MIT Kerberos 5 since 10.4
9974            if test "$with_krb5" != "no"; then
9975                WITH_KRB5=TRUE
9976                save_LIBS=$LIBS
9977                # Not sure whether it makes any sense here to search multiple potential libraries; it is not likely
9978                # that the libraries where these functions are located on macOS will change, is it?
9979                AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
9980                    [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
9981                KRB5_LIBS=$LIBS
9982                LIBS=$save_LIBS
9983                AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
9984                    [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
9985                KRB5_LIBS="$KRB5_LIBS $LIBS"
9986                LIBS=$save_LIBS
9987            fi
9988            if test "$with_gssapi" != "no"; then
9989                WITH_GSSAPI=TRUE
9990                save_LIBS=$LIBS
9991                AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
9992                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
9993                GSSAPI_LIBS=$LIBS
9994                LIBS=$save_LIBS
9995            fi
9996            ;;
9997        WINNT)
9998            if test "$with_krb5" = "yes" -o "$with_gssapi" = "yes"; then
9999                AC_MSG_ERROR([Refusing to enable MIT Kerberos 5 or GSSAPI on Windows.])
10000            fi
10001            ;;
10002        Linux|GNU|*BSD|DragonFly)
10003            if test "$with_krb5" != "no"; then
10004                WITH_KRB5=TRUE
10005                save_LIBS=$LIBS
10006                AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
10007                    [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
10008                KRB5_LIBS=$LIBS
10009                LIBS=$save_LIBS
10010                AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
10011                    [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
10012                KRB5_LIBS="$KRB5_LIBS $LIBS"
10013                LIBS=$save_LIBS
10014            fi
10015            if test "$with_gssapi" != "no"; then
10016                WITH_GSSAPI=TRUE
10017                save_LIBS=$LIBS
10018                AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
10019                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
10020                GSSAPI_LIBS=$LIBS
10021                LIBS=$save_LIBS
10022            fi
10023            ;;
10024        *)
10025            if test "$with_krb5" = "yes"; then
10026                WITH_KRB5=TRUE
10027                save_LIBS=$LIBS
10028                AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
10029                    [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
10030                KRB5_LIBS=$LIBS
10031                LIBS=$save_LIBS
10032                AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
10033                    [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
10034                KRB5_LIBS="$KRB5_LIBS $LIBS"
10035                LIBS=$save_LIBS
10036            fi
10037            if test "$with_gssapi" = "yes"; then
10038                WITH_GSSAPI=TRUE
10039                save_LIBS=$LIBS
10040                AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
10041                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
10042                LIBS=$save_LIBS
10043                GSSAPI_LIBS=$LIBS
10044            fi
10045        esac
10046
10047        if test -n "$with_libpq_path"; then
10048            SYSTEM_POSTGRESQL=TRUE
10049            postgres_interface="external libpq"
10050            POSTGRESQL_LIB="-L${with_libpq_path}/lib/"
10051            POSTGRESQL_INC=-I"${with_libpq_path}/include/"
10052        else
10053            SYSTEM_POSTGRESQL=
10054            postgres_interface="internal"
10055            POSTGRESQL_LIB=""
10056            POSTGRESQL_INC="%OVERRIDE_ME%"
10057            BUILD_TYPE="$BUILD_TYPE POSTGRESQL"
10058        fi
10059    fi
10060
10061    AC_MSG_CHECKING([PostgreSQL C interface])
10062    AC_MSG_RESULT([$postgres_interface])
10063
10064    if test "${SYSTEM_POSTGRESQL}" = "TRUE"; then
10065        AC_MSG_NOTICE([checking system PostgreSQL prerequisites])
10066        save_CFLAGS=$CFLAGS
10067        save_CPPFLAGS=$CPPFLAGS
10068        save_LIBS=$LIBS
10069        CPPFLAGS="${CPPFLAGS} ${POSTGRESQL_INC}"
10070        LIBS="${LIBS} ${POSTGRESQL_LIB}"
10071        AC_CHECK_HEADER([libpq-fe.h], [], [AC_MSG_ERROR([libpq-fe.h is needed])], [])
10072        AC_CHECK_LIB([pq], [PQconnectdbParams], [:],
10073            [AC_MSG_ERROR(libpq not found or too old. Need >= 9.0)], [])
10074        CFLAGS=$save_CFLAGS
10075        CPPFLAGS=$save_CPPFLAGS
10076        LIBS=$save_LIBS
10077    fi
10078    BUILD_POSTGRESQL_SDBC=TRUE
10079else
10080    AC_MSG_RESULT([no])
10081fi
10082AC_SUBST(WITH_KRB5)
10083AC_SUBST(WITH_GSSAPI)
10084AC_SUBST(GSSAPI_LIBS)
10085AC_SUBST(KRB5_LIBS)
10086AC_SUBST(BUILD_POSTGRESQL_SDBC)
10087AC_SUBST(SYSTEM_POSTGRESQL)
10088AC_SUBST(POSTGRESQL_INC)
10089AC_SUBST(POSTGRESQL_LIB)
10090
10091dnl ===================================================================
10092dnl Check for Firebird stuff
10093dnl ===================================================================
10094ENABLE_FIREBIRD_SDBC=
10095if test "$enable_firebird_sdbc" = "yes" ; then
10096    SCPDEFS="$SCPDEFS -DWITH_FIREBIRD_SDBC"
10097
10098    dnl ===================================================================
10099    dnl Check for system Firebird
10100    dnl ===================================================================
10101    AC_MSG_CHECKING([which Firebird to use])
10102    if test "$with_system_firebird" = "yes"; then
10103        AC_MSG_RESULT([external])
10104        SYSTEM_FIREBIRD=TRUE
10105        AC_PATH_PROG(FIREBIRDCONFIG, [fb_config])
10106        if test -z "$FIREBIRDCONFIG"; then
10107            AC_MSG_NOTICE([No fb_config -- using pkg-config])
10108            PKG_CHECK_MODULES([FIREBIRD], [fbclient >= 3], [FIREBIRD_PKGNAME=fbclient], [
10109                PKG_CHECK_MODULES([FIREBIRD], [fbembed], [FIREBIRD_PKGNAME=fbembed])
10110            ])
10111            FIREBIRD_VERSION=`pkg-config --modversion "$FIREBIRD_PKGNAME"`
10112        else
10113            AC_MSG_NOTICE([fb_config found])
10114            FIREBIRD_VERSION=`$FIREBIRDCONFIG --version`
10115            AC_MSG_CHECKING([for Firebird Client library])
10116            FIREBIRD_CFLAGS=`$FIREBIRDCONFIG --cflags`
10117            FIREBIRD_LIBS=`$FIREBIRDCONFIG --embedlibs`
10118            FilterLibs "${FIREBIRD_LIBS}"
10119            FIREBIRD_LIBS="${filteredlibs}"
10120        fi
10121        AC_MSG_RESULT([includes `$FIREBIRD_CFLAGS', libraries `$FIREBIRD_LIBS'])
10122        AC_MSG_CHECKING([Firebird version])
10123        if test -n "${FIREBIRD_VERSION}"; then
10124            FIREBIRD_MAJOR=`echo $FIREBIRD_VERSION | cut -d"." -f1`
10125            if test "$FIREBIRD_MAJOR" -ge "3"; then
10126                AC_MSG_RESULT([OK])
10127            else
10128                AC_MSG_ERROR([Ensure firebird >= 3 is installed])
10129            fi
10130        else
10131            save_CFLAGS="${CFLAGS}"
10132            CFLAGS="${CFLAGS} ${FIREBIRD_CFLAGS}"
10133            AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <ibase.h>
10134#if defined(FB_API_VER) && FB_API_VER == 30
10135int fb_api_is_30(void) { return 0; }
10136#else
10137#error "Wrong Firebird API version"
10138#endif]])],AC_MSG_RESULT([OK]),AC_MSG_ERROR([Ensure firebird 3.0.x is installed]))
10139            CFLAGS="$save_CFLAGS"
10140        fi
10141        ENABLE_FIREBIRD_SDBC=TRUE
10142        AC_DEFINE([ENABLE_FIREBIRD_SDBC],1)
10143    elif test "$enable_database_connectivity" = no; then
10144        AC_MSG_RESULT([none])
10145    elif test "$cross_compiling" = "yes"; then
10146        AC_MSG_RESULT([none])
10147    else
10148        dnl Embedded Firebird has version 3.0
10149        dnl We need libatomic_ops for any non X86/X64 system
10150        if test "${CPUNAME}" != INTEL -a "${CPUNAME}" != X86_64; then
10151            dnl ===================================================================
10152            dnl Check for system libatomic_ops
10153            dnl ===================================================================
10154            libo_CHECK_SYSTEM_MODULE([libatomic_ops],[LIBATOMIC_OPS],[atomic_ops >= 0.7.2])
10155            if test "$with_system_libatomic_ops" = "yes"; then
10156                SYSTEM_LIBATOMIC_OPS=TRUE
10157                AC_CHECK_HEADERS(atomic_ops.h, [],
10158                [AC_MSG_ERROR(atomic_ops.h not found. install libatomic_ops)], [])
10159            else
10160                SYSTEM_LIBATOMIC_OPS=
10161                LIBATOMIC_OPS_CFLAGS="-I${WORKDIR}/UnpackedTarball/libatomic_ops/include"
10162                LIBATOMIC_OPS_LIBS="-latomic_ops"
10163                BUILD_TYPE="$BUILD_TYPE LIBATOMIC_OPS"
10164            fi
10165        fi
10166
10167        AC_MSG_RESULT([internal])
10168        SYSTEM_FIREBIRD=
10169        FIREBIRD_CFLAGS="-I${WORKDIR}/UnpackedTarball/firebird/gen/Release/firebird/include"
10170        FIREBIRD_LIBS="-lfbclient"
10171
10172        if test "$with_system_libtommath" = "yes"; then
10173            SYSTEM_LIBTOMMATH=TRUE
10174            dnl check for tommath presence
10175            save_LIBS=$LIBS
10176            AC_CHECK_HEADER(tommath.h,,AC_MSG_ERROR(Include file for tommath not found - please install development tommath package))
10177            AC_CHECK_LIB(tommath, mp_init, LIBTOMMATH_LIBS=-ltommath, AC_MSG_ERROR(Library tommath not found - please install development tommath package))
10178            LIBS=$save_LIBS
10179        else
10180            SYSTEM_LIBTOMMATH=
10181            LIBTOMMATH_CFLAGS="-I${WORKDIR}/UnpackedTarball/libtommath"
10182            LIBTOMMATH_LIBS="-ltommath"
10183            BUILD_TYPE="$BUILD_TYPE LIBTOMMATH"
10184        fi
10185
10186        BUILD_TYPE="$BUILD_TYPE FIREBIRD"
10187        ENABLE_FIREBIRD_SDBC=TRUE
10188        AC_DEFINE([ENABLE_FIREBIRD_SDBC],1)
10189    fi
10190fi
10191AC_SUBST(ENABLE_FIREBIRD_SDBC)
10192AC_SUBST(SYSTEM_LIBATOMIC_OPS)
10193AC_SUBST(LIBATOMIC_OPS_CFLAGS)
10194AC_SUBST(LIBATOMIC_OPS_LIBS)
10195AC_SUBST(SYSTEM_FIREBIRD)
10196AC_SUBST(FIREBIRD_CFLAGS)
10197AC_SUBST(FIREBIRD_LIBS)
10198AC_SUBST(SYSTEM_LIBTOMMATH)
10199AC_SUBST(LIBTOMMATH_CFLAGS)
10200AC_SUBST(LIBTOMMATH_LIBS)
10201
10202dnl ===================================================================
10203dnl Check for system curl
10204dnl ===================================================================
10205AC_MSG_CHECKING([which libcurl to use])
10206if test "$with_system_curl" = "auto"; then
10207    with_system_curl="$with_system_libs"
10208fi
10209
10210if test "$test_curl" = "yes" -a "$enable_curl" = "yes" -a "$with_system_curl" = "yes"; then
10211    AC_MSG_RESULT([external])
10212    SYSTEM_CURL=TRUE
10213
10214    # First try PKGCONFIG and then fall back
10215    PKG_CHECK_MODULES(CURL, libcurl >= 7.19.4,, [:])
10216
10217    if test -n "$CURL_PKG_ERRORS"; then
10218        AC_PATH_PROG(CURLCONFIG, curl-config)
10219        if test -z "$CURLCONFIG"; then
10220            AC_MSG_ERROR([curl development files not found])
10221        fi
10222        CURL_LIBS=`$CURLCONFIG --libs`
10223        FilterLibs "${CURL_LIBS}"
10224        CURL_LIBS="${filteredlibs}"
10225        CURL_CFLAGS=$("$CURLCONFIG" --cflags | sed -e "s/-I/${ISYSTEM?}/g")
10226        curl_version=`$CURLCONFIG --version | $SED -e 's/^libcurl //'`
10227
10228        AC_MSG_CHECKING([whether libcurl is >= 7.19.4])
10229        case $curl_version in
10230        dnl brackets doubled below because Autoconf uses them as m4 quote characters,
10231        dnl so they need to be doubled to end up in the configure script
10232        7.19.4|7.19.[[5-9]]|7.[[2-9]]?.*|7.???.*|[[8-9]].*|[[1-9]][[0-9]].*)
10233            AC_MSG_RESULT([yes])
10234            ;;
10235        *)
10236            AC_MSG_ERROR([no, you have $curl_version])
10237            ;;
10238        esac
10239    fi
10240
10241    ENABLE_CURL=TRUE
10242elif test "$test_curl" = "no"; then
10243    AC_MSG_RESULT([none])
10244else
10245    AC_MSG_RESULT([internal])
10246    SYSTEM_CURL=
10247    BUILD_TYPE="$BUILD_TYPE CURL"
10248    ENABLE_CURL=TRUE
10249fi
10250AC_SUBST(SYSTEM_CURL)
10251AC_SUBST(CURL_CFLAGS)
10252AC_SUBST(CURL_LIBS)
10253AC_SUBST(ENABLE_CURL)
10254
10255dnl ===================================================================
10256dnl Check for system boost
10257dnl ===================================================================
10258AC_MSG_CHECKING([which boost to use])
10259if test "$with_system_boost" = "yes"; then
10260    AC_MSG_RESULT([external])
10261    SYSTEM_BOOST=TRUE
10262    AX_BOOST_BASE([1.66],,[AC_MSG_ERROR([no suitable Boost found])])
10263    AX_BOOST_DATE_TIME
10264    AX_BOOST_FILESYSTEM
10265    AX_BOOST_IOSTREAMS
10266    AX_BOOST_LOCALE
10267    AC_LANG_PUSH([C++])
10268    save_CXXFLAGS=$CXXFLAGS
10269    CXXFLAGS="$CXXFLAGS $BOOST_CPPFLAGS $CXXFLAGS_CXX11"
10270    AC_CHECK_HEADER(boost/shared_ptr.hpp, [],
10271       [AC_MSG_ERROR(boost/shared_ptr.hpp not found. install boost)], [])
10272    AC_CHECK_HEADER(boost/spirit/include/classic_core.hpp, [],
10273       [AC_MSG_ERROR(boost/spirit/include/classic_core.hpp not found. install boost >= 1.36)], [])
10274    CXXFLAGS=$save_CXXFLAGS
10275    AC_LANG_POP([C++])
10276    # this is in m4/ax_boost_base.m4
10277    FilterLibs "${BOOST_LDFLAGS}"
10278    BOOST_LDFLAGS="${filteredlibs}"
10279else
10280    AC_MSG_RESULT([internal])
10281    BUILD_TYPE="$BUILD_TYPE BOOST"
10282    SYSTEM_BOOST=
10283    if test "${COM}" = "GCC" -o "${COM_IS_CLANG}" = "TRUE"; then
10284        # use warning-suppressing wrapper headers
10285        BOOST_CPPFLAGS="-I${SRC_ROOT}/external/boost/include -I${WORKDIR}/UnpackedTarball/boost"
10286    else
10287        BOOST_CPPFLAGS="-I${WORKDIR}/UnpackedTarball/boost"
10288    fi
10289fi
10290AC_SUBST(SYSTEM_BOOST)
10291
10292dnl ===================================================================
10293dnl Check for system mdds
10294dnl ===================================================================
10295libo_CHECK_SYSTEM_MODULE([mdds], [MDDS], [mdds-1.5 >= 1.5.0], ["-I${WORKDIR}/UnpackedTarball/mdds/include"])
10296
10297dnl ===================================================================
10298dnl Check for system glm
10299dnl ===================================================================
10300AC_MSG_CHECKING([which glm to use])
10301if test "$with_system_glm" = "yes"; then
10302    AC_MSG_RESULT([external])
10303    SYSTEM_GLM=TRUE
10304    AC_LANG_PUSH([C++])
10305    AC_CHECK_HEADER([glm/glm.hpp], [],
10306       [AC_MSG_ERROR([glm/glm.hpp not found. install glm])], [])
10307    AC_LANG_POP([C++])
10308else
10309    AC_MSG_RESULT([internal])
10310    BUILD_TYPE="$BUILD_TYPE GLM"
10311    SYSTEM_GLM=
10312    GLM_CFLAGS="${ISYSTEM}${WORKDIR}/UnpackedTarball/glm"
10313fi
10314AC_SUBST([GLM_CFLAGS])
10315AC_SUBST([SYSTEM_GLM])
10316
10317dnl ===================================================================
10318dnl Check for system odbc
10319dnl ===================================================================
10320AC_MSG_CHECKING([which odbc headers to use])
10321if test "$with_system_odbc" = "yes" -o '(' "$with_system_headers" = "yes" -a "$with_system_odbc" = "auto" ')' -o '(' "$_os" = "WINNT" -a  "$with_system_odbc" != "no" ')'; then
10322    AC_MSG_RESULT([external])
10323    SYSTEM_ODBC_HEADERS=TRUE
10324
10325    if test "$build_os" = "cygwin" -o "$build_os" = "wsl"; then
10326        save_CPPFLAGS=$CPPFLAGS
10327        find_winsdk
10328        PathFormat "$winsdktest"
10329        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"
10330        AC_CHECK_HEADER(sqlext.h, [],
10331            [AC_MSG_ERROR(odbc not found. install odbc)],
10332            [#include <windows.h>])
10333        CPPFLAGS=$save_CPPFLAGS
10334    else
10335        AC_CHECK_HEADER(sqlext.h, [],
10336            [AC_MSG_ERROR(odbc not found. install odbc)],[])
10337    fi
10338elif test "$enable_database_connectivity" = no; then
10339    AC_MSG_RESULT([none])
10340else
10341    AC_MSG_RESULT([internal])
10342    SYSTEM_ODBC_HEADERS=
10343fi
10344AC_SUBST(SYSTEM_ODBC_HEADERS)
10345
10346dnl ===================================================================
10347dnl Check for system NSS
10348dnl ===================================================================
10349if test "$enable_fuzzers" != "yes" -a "$enable_nss" = "yes"; then
10350    libo_CHECK_SYSTEM_MODULE([nss],[NSS],[nss >= 3.9.3 nspr >= 4.8])
10351    AC_DEFINE(HAVE_FEATURE_NSS)
10352    ENABLE_NSS=TRUE
10353elif test $_os != iOS ; then
10354    with_tls=openssl
10355fi
10356AC_SUBST(ENABLE_NSS)
10357
10358dnl ===================================================================
10359dnl Enable LDAP support
10360dnl ===================================================================
10361
10362if test "$test_openldap" = yes; then
10363    AC_MSG_CHECKING([whether to enable LDAP support])
10364    if test "$enable_ldap" = yes -a \( "$ENABLE_NSS" = TRUE -o "$with_system_openldap" = yes \); then
10365        AC_MSG_RESULT([yes])
10366        ENABLE_LDAP=TRUE
10367    else
10368        if test "$enable_ldap" != "yes"; then
10369            AC_MSG_RESULT([no])
10370        else
10371            AC_MSG_RESULT([no (needs NSS or system openldap)])
10372        fi
10373    fi
10374
10375dnl ===================================================================
10376dnl Check for system openldap
10377dnl ===================================================================
10378
10379    if test "$ENABLE_LDAP" = TRUE; then
10380        AC_MSG_CHECKING([which openldap library to use])
10381        if test "$with_system_openldap" = yes; then
10382            AC_MSG_RESULT([external])
10383            SYSTEM_OPENLDAP=TRUE
10384            AC_CHECK_HEADERS(ldap.h, [], [AC_MSG_ERROR(ldap.h not found. install openldap libs)], [])
10385            AC_CHECK_LIB([ldap], [ldap_simple_bind_s], [:], [AC_MSG_ERROR(openldap lib not found or functional)], [])
10386            AC_CHECK_LIB([ldap], [ldap_set_option], [:], [AC_MSG_ERROR(openldap lib not found or functional)], [])
10387        else
10388            AC_MSG_RESULT([internal])
10389            BUILD_TYPE="$BUILD_TYPE OPENLDAP"
10390        fi
10391    fi
10392fi
10393
10394AC_SUBST(ENABLE_LDAP)
10395AC_SUBST(SYSTEM_OPENLDAP)
10396
10397dnl ===================================================================
10398dnl Check for TLS/SSL and cryptographic implementation to use
10399dnl ===================================================================
10400AC_MSG_CHECKING([which TLS/SSL and cryptographic implementation to use])
10401if test -n "$with_tls"; then
10402    case $with_tls in
10403    openssl)
10404        AC_DEFINE(USE_TLS_OPENSSL)
10405        TLS=OPENSSL
10406        AC_MSG_RESULT([$TLS])
10407
10408        if test "$enable_openssl" != "yes"; then
10409            AC_MSG_ERROR(["Disabling OpenSSL was requested, but the requested TLS to use is actually OpenSSL."])
10410        fi
10411
10412        # warn that OpenSSL has been selected but not all TLS code has this option
10413        AC_MSG_WARN([TLS/SSL implementation to use is OpenSSL but some code may still depend on NSS or GNUTLS])
10414        add_warning "TLS/SSL implementation to use is OpenSSL but some code may still depend on NSS or GNUTLS"
10415        ;;
10416    nss)
10417        AC_DEFINE(USE_TLS_NSS)
10418        TLS=NSS
10419        AC_MSG_RESULT([$TLS])
10420        ;;
10421    no)
10422        AC_MSG_RESULT([none])
10423        AC_MSG_WARN([Skipping TLS/SSL])
10424        ;;
10425    *)
10426        AC_MSG_RESULT([])
10427        AC_MSG_ERROR([unsupported implementation $with_tls. Supported are:
10428openssl - OpenSSL
10429nss - Mozilla's Network Security Services (NSS)
10430    ])
10431        ;;
10432    esac
10433else
10434    # default to using NSS, it results in smaller oox lib
10435    AC_DEFINE(USE_TLS_NSS)
10436    TLS=NSS
10437    AC_MSG_RESULT([$TLS])
10438fi
10439AC_SUBST(TLS)
10440
10441dnl ===================================================================
10442dnl Check for system sane
10443dnl ===================================================================
10444AC_MSG_CHECKING([which sane header to use])
10445if test "$with_system_sane" = "yes"; then
10446    AC_MSG_RESULT([external])
10447    AC_CHECK_HEADER(sane/sane.h, [],
10448      [AC_MSG_ERROR(sane not found. install sane)], [])
10449else
10450    AC_MSG_RESULT([internal])
10451    BUILD_TYPE="$BUILD_TYPE SANE"
10452fi
10453
10454dnl ===================================================================
10455dnl Check for system icu
10456dnl ===================================================================
10457SYSTEM_GENBRK=
10458SYSTEM_GENCCODE=
10459SYSTEM_GENCMN=
10460
10461ICU_MAJOR=69
10462ICU_MINOR=1
10463ICU_RECLASSIFIED_PREPEND_SET_EMPTY="TRUE"
10464ICU_RECLASSIFIED_CONDITIONAL_JAPANESE_STARTER="TRUE"
10465ICU_RECLASSIFIED_HEBREW_LETTER="TRUE"
10466AC_MSG_CHECKING([which icu to use])
10467if test "$with_system_icu" = "yes"; then
10468    AC_MSG_RESULT([external])
10469    SYSTEM_ICU=TRUE
10470    AC_LANG_PUSH([C++])
10471    AC_MSG_CHECKING([for unicode/rbbi.h])
10472    AC_PREPROC_IFELSE([AC_LANG_SOURCE([[unicode/rbbi.h]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([icu headers not found])])
10473    AC_LANG_POP([C++])
10474
10475    if test "$cross_compiling" != "yes"; then
10476        PKG_CHECK_MODULES(ICU, icu-i18n >= 4.6)
10477        ICU_VERSION=`$PKG_CONFIG --modversion icu-i18n 2>/dev/null`
10478        ICU_MAJOR=`echo $ICU_VERSION | cut -d"." -f1`
10479        ICU_MINOR=`echo $ICU_VERSION | cut -d"." -f2`
10480    fi
10481
10482    if test "$cross_compiling" = "yes" -a \( "$with_system_icu_for_build" = "yes" -o "$with_system_icu_for_build" = "force" \); then
10483        ICU_VERSION_FOR_BUILD=`$PKG_CONFIG --modversion icu-i18n 2>/dev/null`
10484        ICU_MAJOR_FOR_BUILD=`echo $ICU_VERSION_FOR_BUILD | cut -d"." -f1`
10485        ICU_MINOR_FOR_BUILD=`echo $ICU_VERSION_FOR_BUILD | cut -d"." -f2`
10486        AC_MSG_CHECKING([if MinGW and system versions of ICU are compatible])
10487        if test "$ICU_MAJOR" -eq "$ICU_MAJOR_FOR_BUILD" -a "$ICU_MINOR" -eq "$ICU_MINOR_FOR_BUILD"; then
10488            AC_MSG_RESULT([yes])
10489        else
10490            AC_MSG_RESULT([no])
10491            if test "$with_system_icu_for_build" != "force"; then
10492                AC_MSG_ERROR([System ICU is not version-compatible with MinGW ICU.
10493You can use --with-system-icu-for-build=force to use it anyway.])
10494            fi
10495        fi
10496    fi
10497
10498    if test "$cross_compiling" != "yes" -o "$with_system_icu_for_build" = "yes" -o "$with_system_icu_for_build" = "force"; then
10499        # using the system icu tools can lead to version confusion, use the
10500        # ones from the build environment when cross-compiling
10501        AC_PATH_PROG(SYSTEM_GENBRK, genbrk, [], [$PATH:/usr/sbin:/sbin])
10502        if test -z "$SYSTEM_GENBRK"; then
10503            AC_MSG_ERROR([\'genbrk\' not found in \$PATH, install the icu development tool \'genbrk\'])
10504        fi
10505        AC_PATH_PROG(SYSTEM_GENCCODE, genccode, [], [$PATH:/usr/sbin:/sbin:/usr/local/sbin])
10506        if test -z "$SYSTEM_GENCCODE"; then
10507            AC_MSG_ERROR([\'genccode\' not found in \$PATH, install the icu development tool \'genccode\'])
10508        fi
10509        AC_PATH_PROG(SYSTEM_GENCMN, gencmn, [], [$PATH:/usr/sbin:/sbin:/usr/local/sbin])
10510        if test -z "$SYSTEM_GENCMN"; then
10511            AC_MSG_ERROR([\'gencmn\' not found in \$PATH, install the icu development tool \'gencmn\'])
10512        fi
10513        if test "$ICU_MAJOR" -ge "49"; then
10514            ICU_RECLASSIFIED_PREPEND_SET_EMPTY="TRUE"
10515            ICU_RECLASSIFIED_CONDITIONAL_JAPANESE_STARTER="TRUE"
10516            ICU_RECLASSIFIED_HEBREW_LETTER="TRUE"
10517        else
10518            ICU_RECLASSIFIED_PREPEND_SET_EMPTY=
10519            ICU_RECLASSIFIED_CONDITIONAL_JAPANESE_STARTER=
10520            ICU_RECLASSIFIED_HEBREW_LETTER=
10521        fi
10522    fi
10523
10524    if test "$cross_compiling" = "yes"; then
10525        if test "$ICU_MAJOR" -ge "50"; then
10526            AC_MSG_RESULT([Ignore ICU_MINOR as obviously the libraries don't include the minor version in their names any more])
10527            ICU_MINOR=""
10528        fi
10529    fi
10530else
10531    AC_MSG_RESULT([internal])
10532    SYSTEM_ICU=
10533    BUILD_TYPE="$BUILD_TYPE ICU"
10534    # surprisingly set these only for "internal" (to be used by various other
10535    # external libs): the system icu-config is quite unhelpful and spits out
10536    # dozens of weird flags and also default path -I/usr/include
10537    ICU_CFLAGS="-I${WORKDIR}/UnpackedTarball/icu/source/i18n -I${WORKDIR}/UnpackedTarball/icu/source/common"
10538    ICU_LIBS="-L${WORKDIR}/UnpackedTarball/icu/source/lib"
10539fi
10540if test "$ICU_MAJOR" -ge "59"; then
10541    # As of ICU 59 it defaults to typedef char16_t UChar; which is available
10542    # with -std=c++11 but not all external libraries can be built with that,
10543    # for those use a bit-compatible typedef uint16_t UChar; see
10544    # icu/source/common/unicode/umachine.h
10545    ICU_UCHAR_TYPE="-DUCHAR_TYPE=uint16_t"
10546else
10547    ICU_UCHAR_TYPE=""
10548fi
10549AC_SUBST(SYSTEM_ICU)
10550AC_SUBST(SYSTEM_GENBRK)
10551AC_SUBST(SYSTEM_GENCCODE)
10552AC_SUBST(SYSTEM_GENCMN)
10553AC_SUBST(ICU_MAJOR)
10554AC_SUBST(ICU_MINOR)
10555AC_SUBST(ICU_RECLASSIFIED_PREPEND_SET_EMPTY)
10556AC_SUBST(ICU_RECLASSIFIED_CONDITIONAL_JAPANESE_STARTER)
10557AC_SUBST(ICU_RECLASSIFIED_HEBREW_LETTER)
10558AC_SUBST(ICU_CFLAGS)
10559AC_SUBST(ICU_LIBS)
10560AC_SUBST(ICU_UCHAR_TYPE)
10561
10562dnl ==================================================================
10563dnl Breakpad
10564dnl ==================================================================
10565DEFAULT_CRASHDUMP_VALUE="true"
10566AC_MSG_CHECKING([whether to enable breakpad])
10567if test "$enable_breakpad" != yes; then
10568    AC_MSG_RESULT([no])
10569else
10570    AC_MSG_RESULT([yes])
10571    ENABLE_BREAKPAD="TRUE"
10572    AC_DEFINE(ENABLE_BREAKPAD)
10573    AC_DEFINE(HAVE_FEATURE_BREAKPAD, 1)
10574    BUILD_TYPE="$BUILD_TYPE BREAKPAD"
10575
10576    AC_MSG_CHECKING([for disable crash dump])
10577    if test "$enable_crashdump" = no; then
10578        DEFAULT_CRASHDUMP_VALUE="false"
10579        AC_MSG_RESULT([yes])
10580    else
10581       AC_MSG_RESULT([no])
10582    fi
10583
10584    AC_MSG_CHECKING([for crashreport config])
10585    if test "$with_symbol_config" = "no"; then
10586        BREAKPAD_SYMBOL_CONFIG="invalid"
10587        AC_MSG_RESULT([no])
10588    else
10589        BREAKPAD_SYMBOL_CONFIG="$with_symbol_config"
10590        AC_DEFINE(BREAKPAD_SYMBOL_CONFIG)
10591        AC_MSG_RESULT([yes])
10592    fi
10593    AC_SUBST(BREAKPAD_SYMBOL_CONFIG)
10594fi
10595AC_SUBST(ENABLE_BREAKPAD)
10596AC_SUBST(DEFAULT_CRASHDUMP_VALUE)
10597
10598dnl ==================================================================
10599dnl libfuzzer
10600dnl ==================================================================
10601AC_MSG_CHECKING([whether to enable fuzzers])
10602if test "$enable_fuzzers" != yes; then
10603    AC_MSG_RESULT([no])
10604else
10605    if test $LIB_FUZZING_ENGINE == ""; then
10606      AC_MSG_ERROR(['LIB_FUZZING_ENGINE' must be set when using --enable-fuzzers. Examples include '-fsanitize=fuzzer'.])
10607    fi
10608    AC_MSG_RESULT([yes])
10609    ENABLE_FUZZERS="TRUE"
10610    AC_DEFINE([ENABLE_FUZZERS],1)
10611    BUILD_TYPE="$BUILD_TYPE FUZZERS"
10612fi
10613AC_SUBST(LIB_FUZZING_ENGINE)
10614AC_SUBST(ENABLE_FUZZERS)
10615
10616dnl ===================================================================
10617dnl Orcus
10618dnl ===================================================================
10619libo_CHECK_SYSTEM_MODULE([orcus],[ORCUS],[liborcus-0.16 >= 0.16.0])
10620if test "$with_system_orcus" != "yes"; then
10621    if test "$SYSTEM_BOOST" = "TRUE"; then
10622        # ===========================================================
10623        # Determine if we are going to need to link with Boost.System
10624        # ===========================================================
10625        dnl This seems to be necessary since boost 1.50 (1.48 does not need it,
10626        dnl 1.49 is untested). The macro BOOST_THREAD_DONT_USE_SYSTEM mentioned
10627        dnl in documentation has no effect.
10628        AC_MSG_CHECKING([if we need to link with Boost.System])
10629        AC_LANG_PUSH([C++])
10630        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
10631                @%:@include <boost/version.hpp>
10632            ]],[[
10633                #if BOOST_VERSION >= 105000
10634                #   error yes, we need to link with Boost.System
10635                #endif
10636            ]])],[
10637                AC_MSG_RESULT([no])
10638            ],[
10639                AC_MSG_RESULT([yes])
10640                AX_BOOST_SYSTEM
10641        ])
10642        AC_LANG_POP([C++])
10643    fi
10644fi
10645dnl FIXME by renaming SYSTEM_LIBORCUS to SYSTEM_ORCUS in the build system world
10646SYSTEM_LIBORCUS=$SYSTEM_ORCUS
10647AC_SUBST([BOOST_SYSTEM_LIB])
10648AC_SUBST(SYSTEM_LIBORCUS)
10649
10650dnl ===================================================================
10651dnl HarfBuzz
10652dnl ===================================================================
10653libo_CHECK_SYSTEM_MODULE([graphite],[GRAPHITE],[graphite2 >= 0.9.3],
10654                         ["-I${WORKDIR}/UnpackedTarball/graphite/include -DGRAPHITE2_STATIC"],
10655                         ["-L${WORKDIR}/LinkTarget/StaticLibrary -lgraphite"])
10656
10657libo_CHECK_SYSTEM_MODULE([harfbuzz],[HARFBUZZ],[harfbuzz-icu >= 0.9.42],
10658                         ["-I${WORKDIR}/UnpackedTarball/harfbuzz/src"],
10659                         ["-L${WORKDIR}/UnpackedTarball/harfbuzz/src/.libs -lharfbuzz"])
10660
10661if test "$COM" = "MSC"; then # override the above
10662    GRAPHITE_LIBS="${WORKDIR}/LinkTarget/StaticLibrary/graphite.lib"
10663    HARFBUZZ_LIBS="${WORKDIR}/UnpackedTarball/harfbuzz/src/.libs/libharfbuzz.lib"
10664fi
10665
10666if test "$with_system_harfbuzz" = "yes"; then
10667    if test "$with_system_graphite" = "no"; then
10668        AC_MSG_ERROR([--with-system-graphite must be used when --with-system-harfbuzz is used])
10669    fi
10670    AC_MSG_CHECKING([whether system Harfbuzz is built with Graphite support])
10671    save_LIBS="$LIBS"
10672    save_CFLAGS="$CFLAGS"
10673    LIBS="$LIBS $HARFBUZZ_LIBS"
10674    CFLAGS="$CFLAGS $HARFBUZZ_CFLAGS"
10675    AC_CHECK_FUNC(hb_graphite2_face_get_gr_face,,[AC_MSG_ERROR([Harfbuzz needs to be built with Graphite support.])])
10676    LIBS="$save_LIBS"
10677    CFLAGS="$save_CFLAGS"
10678else
10679    if test "$with_system_graphite" = "yes"; then
10680        AC_MSG_ERROR([--without-system-graphite must be used when --without-system-harfbuzz is used])
10681    fi
10682fi
10683
10684if test "$USING_X11" = TRUE; then
10685    AC_PATH_X
10686    AC_PATH_XTRA
10687    CPPFLAGS="$CPPFLAGS $X_CFLAGS"
10688
10689    if test -z "$x_includes"; then
10690        x_includes="default_x_includes"
10691    fi
10692    if test -z "$x_libraries"; then
10693        x_libraries="default_x_libraries"
10694    fi
10695    CFLAGS="$CFLAGS $X_CFLAGS"
10696    LDFLAGS="$LDFLAGS $X_LDFLAGS $X_LIBS"
10697    AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS", [AC_MSG_ERROR([X Development libraries not found])])
10698else
10699    x_includes="no_x_includes"
10700    x_libraries="no_x_libraries"
10701fi
10702
10703if test "$USING_X11" = TRUE; then
10704    dnl ===================================================================
10705    dnl Check for extension headers
10706    dnl ===================================================================
10707    AC_CHECK_HEADERS(X11/extensions/shape.h,[],[AC_MSG_ERROR([libXext headers not found])],
10708     [#include <X11/extensions/shape.h>])
10709
10710    # vcl needs ICE and SM
10711    AC_CHECK_HEADERS(X11/ICE/ICElib.h,[],[AC_MSG_ERROR([libICE headers not found])])
10712    AC_CHECK_LIB([ICE], [IceConnectionNumber], [:],
10713        [AC_MSG_ERROR(ICE library not found)])
10714    AC_CHECK_HEADERS(X11/SM/SMlib.h,[],[AC_MSG_ERROR([libSM headers not found])])
10715    AC_CHECK_LIB([SM], [SmcOpenConnection], [:],
10716        [AC_MSG_ERROR(SM library not found)])
10717fi
10718
10719if test "$USING_X11" = TRUE -a "$ENABLE_JAVA" != ""; then
10720    # bean/native/unix/com_sun_star_comp_beans_LocalOfficeWindow.c needs Xt
10721    AC_CHECK_HEADERS(X11/Intrinsic.h,[],[AC_MSG_ERROR([libXt headers not found])])
10722fi
10723
10724dnl ===================================================================
10725dnl Check for system Xrender
10726dnl ===================================================================
10727AC_MSG_CHECKING([whether to use Xrender])
10728if test "$USING_X11" = TRUE -a  "$test_xrender" = "yes"; then
10729    AC_MSG_RESULT([yes])
10730    PKG_CHECK_MODULES(XRENDER, xrender)
10731    XRENDER_CFLAGS=$(printf '%s' "$XRENDER_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10732    FilterLibs "${XRENDER_LIBS}"
10733    XRENDER_LIBS="${filteredlibs}"
10734    AC_CHECK_LIB([Xrender], [XRenderQueryVersion], [:],
10735      [AC_MSG_ERROR(libXrender not found or functional)], [])
10736    AC_CHECK_HEADER(X11/extensions/Xrender.h, [],
10737      [AC_MSG_ERROR(Xrender not found. install X)], [])
10738else
10739    AC_MSG_RESULT([no])
10740fi
10741AC_SUBST(XRENDER_CFLAGS)
10742AC_SUBST(XRENDER_LIBS)
10743
10744dnl ===================================================================
10745dnl Check for XRandr
10746dnl ===================================================================
10747AC_MSG_CHECKING([whether to enable RandR support])
10748if test "$USING_X11" = TRUE -a "$test_randr" = "yes" -a \( "$enable_randr" = "yes" -o "$enable_randr" = "TRUE" \); then
10749    AC_MSG_RESULT([yes])
10750    PKG_CHECK_MODULES(XRANDR, xrandr >= 1.2, ENABLE_RANDR="TRUE", ENABLE_RANDR="")
10751    if test "$ENABLE_RANDR" != "TRUE"; then
10752        AC_CHECK_HEADER(X11/extensions/Xrandr.h, [],
10753                    [AC_MSG_ERROR([X11/extensions/Xrandr.h could not be found. X11 dev missing?])], [])
10754        XRANDR_CFLAGS=" "
10755        AC_CHECK_LIB([Xrandr], [XRRQueryExtension], [:],
10756          [ AC_MSG_ERROR(libXrandr not found or functional) ], [])
10757        XRANDR_LIBS="-lXrandr "
10758        ENABLE_RANDR="TRUE"
10759    fi
10760    XRANDR_CFLAGS=$(printf '%s' "$XRANDR_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10761    FilterLibs "${XRANDR_LIBS}"
10762    XRANDR_LIBS="${filteredlibs}"
10763else
10764    ENABLE_RANDR=""
10765    AC_MSG_RESULT([no])
10766fi
10767AC_SUBST(XRANDR_CFLAGS)
10768AC_SUBST(XRANDR_LIBS)
10769AC_SUBST(ENABLE_RANDR)
10770
10771if test "$test_webdav" = yes; then
10772    if test -z "$with_webdav"; then
10773        WITH_WEBDAV=neon
10774        if test "$enable_mpl_subset" = yes; then
10775            WITH_WEBDAV=serf
10776        fi
10777    else
10778        WITH_WEBDAV="$with_webdav"
10779    fi
10780fi
10781
10782AC_MSG_CHECKING([for webdav library])
10783case "$WITH_WEBDAV" in
10784serf)
10785    AC_MSG_RESULT([serf])
10786    # Check for system apr-util
10787    libo_CHECK_SYSTEM_MODULE([apr],[APR],[apr-util-1],
10788                             ["-I${WORKDIR}/UnpackedTarball/apr/include -I${WORKDIR}/UnpackedTarball/apr_util/include"],
10789                             ["-L${WORKDIR}/UnpackedTarball/apr/.libs -lapr-1 -L${WORKDIR}/UnpackedTarball/apr_util/.libs -laprutil-1"])
10790    if test "$COM" = "MSC"; then
10791        APR_LIB_DIR="LibR"
10792        test -n "${MSVC_USE_DEBUG_RUNTIME}" && APR_LIB_DIR="LibD"
10793        APR_LIBS="${WORKDIR}/UnpackedTarball/apr/${APR_LIB_DIR}/apr-1.lib ${WORKDIR}/UnpackedTarball/apr_util/${APR_LIB_DIR}/aprutil-1.lib"
10794    fi
10795
10796    # Check for system serf
10797    libo_CHECK_SYSTEM_MODULE([serf],[SERF],[serf-1 >= 1.3.9])
10798    ;;
10799neon)
10800    AC_MSG_RESULT([neon])
10801    # Check for system neon
10802    libo_CHECK_SYSTEM_MODULE([neon],[NEON],[neon >= 0.31.2])
10803    if test "$with_system_neon" = "yes"; then
10804        NEON_VERSION="`$PKG_CONFIG --modversion neon | $SED 's/\.//g'`"
10805    else
10806        NEON_VERSION=0312
10807    fi
10808    AC_SUBST(NEON_VERSION)
10809    ;;
10810*)
10811    AC_MSG_RESULT([none, disabled])
10812    WITH_WEBDAV=""
10813    ;;
10814esac
10815AC_SUBST(WITH_WEBDAV)
10816
10817dnl ===================================================================
10818dnl Check for disabling cve_tests
10819dnl ===================================================================
10820AC_MSG_CHECKING([whether to execute CVE tests])
10821# If not explicitly enabled or disabled, default
10822if test -z "$enable_cve_tests"; then
10823    case "$OS" in
10824    WNT)
10825        # Default cves off for Windows with its wild and wonderful
10826        # variety of AV software kicking in and panicking
10827        enable_cve_tests=no
10828        ;;
10829    *)
10830        # otherwise yes
10831        enable_cve_tests=yes
10832        ;;
10833    esac
10834fi
10835if test "$enable_cve_tests" = "no"; then
10836    AC_MSG_RESULT([no])
10837    DISABLE_CVE_TESTS=TRUE
10838    AC_SUBST(DISABLE_CVE_TESTS)
10839else
10840    AC_MSG_RESULT([yes])
10841fi
10842
10843dnl ===================================================================
10844dnl Check for enabling chart XShape tests
10845dnl ===================================================================
10846AC_MSG_CHECKING([whether to execute chart XShape tests])
10847if test "$enable_chart_tests" = "yes" -o '(' "$_os" = "WINNT" -a "$enable_chart_tests" != "no" ')'; then
10848    AC_MSG_RESULT([yes])
10849    ENABLE_CHART_TESTS=TRUE
10850    AC_SUBST(ENABLE_CHART_TESTS)
10851else
10852    AC_MSG_RESULT([no])
10853fi
10854
10855dnl ===================================================================
10856dnl Check for system openssl
10857dnl ===================================================================
10858ENABLE_OPENSSL=
10859AC_MSG_CHECKING([whether to disable OpenSSL usage])
10860if test "$enable_openssl" = "yes"; then
10861    AC_MSG_RESULT([no])
10862    ENABLE_OPENSSL=TRUE
10863    if test "$_os" = Darwin ; then
10864        # OpenSSL is deprecated when building for 10.7 or later.
10865        #
10866        # http://stackoverflow.com/questions/7406946/why-is-apple-deprecating-openssl-in-macos-10-7-lion
10867        # http://stackoverflow.com/questions/7475914/libcrypto-deprecated-on-mac-os-x-10-7-lion
10868
10869        with_system_openssl=no
10870        libo_CHECK_SYSTEM_MODULE([openssl],[OPENSSL],[openssl])
10871    elif test "$_os" = "FreeBSD" -o "$_os" = "NetBSD" -o "$_os" = "OpenBSD" -o "$_os" = "DragonFly" \
10872            && test "$with_system_openssl" != "no"; then
10873        with_system_openssl=yes
10874        SYSTEM_OPENSSL=TRUE
10875        OPENSSL_CFLAGS=
10876        OPENSSL_LIBS="-lssl -lcrypto"
10877    else
10878        libo_CHECK_SYSTEM_MODULE([openssl],[OPENSSL],[openssl])
10879    fi
10880    if test "$with_system_openssl" = "yes"; then
10881        AC_MSG_CHECKING([whether openssl supports SHA512])
10882        AC_LANG_PUSH([C])
10883        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <openssl/sha.h>]],[[
10884            SHA512_CTX context;
10885]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no, openssl too old. Need >= 0.9.8.])])
10886        AC_LANG_POP(C)
10887    fi
10888else
10889    AC_MSG_RESULT([yes])
10890
10891    # warn that although OpenSSL is disabled, system libraries may depend on it
10892    AC_MSG_WARN([OpenSSL has been disabled. No code compiled here will make use of it but system libraries may create indirect dependencies])
10893    add_warning "OpenSSL has been disabled. No code compiled here will make use of it but system libraries may create indirect dependencies"
10894fi
10895
10896AC_SUBST([ENABLE_OPENSSL])
10897
10898if test "$enable_cipher_openssl_backend" = yes && test "$ENABLE_OPENSSL" != TRUE; then
10899    if test "$libo_fuzzed_enable_cipher_openssl_backend" = yes; then
10900        AC_MSG_NOTICE([Resetting --enable-cipher-openssl-backend=no])
10901        enable_cipher_openssl_backend=no
10902    else
10903        AC_MSG_ERROR([--enable-cipher-openssl-backend needs OpenSSL, but --disable-openssl was given.])
10904    fi
10905fi
10906AC_MSG_CHECKING([whether to enable the OpenSSL backend for rtl/cipher.h])
10907ENABLE_CIPHER_OPENSSL_BACKEND=
10908if test "$enable_cipher_openssl_backend" = yes; then
10909    AC_MSG_RESULT([yes])
10910    ENABLE_CIPHER_OPENSSL_BACKEND=TRUE
10911else
10912    AC_MSG_RESULT([no])
10913fi
10914AC_SUBST([ENABLE_CIPHER_OPENSSL_BACKEND])
10915
10916dnl ===================================================================
10917dnl Select the crypto backends used by LO
10918dnl ===================================================================
10919
10920if test "$build_crypto" = yes; then
10921    if test "$OS" = WNT; then
10922        BUILD_TYPE="$BUILD_TYPE CRYPTO_MSCAPI"
10923        AC_DEFINE([USE_CRYPTO_MSCAPI])
10924    elif test "$ENABLE_NSS" = TRUE; then
10925        BUILD_TYPE="$BUILD_TYPE CRYPTO_NSS"
10926        AC_DEFINE([USE_CRYPTO_NSS])
10927    fi
10928fi
10929
10930dnl ===================================================================
10931dnl Check for building gnutls
10932dnl ===================================================================
10933AC_MSG_CHECKING([whether to use gnutls])
10934if test "$WITH_WEBDAV" = "neon" -a "$with_system_neon" = no -a "$enable_openssl" = "no"; then
10935    AC_MSG_RESULT([yes])
10936    AM_PATH_LIBGCRYPT()
10937    PKG_CHECK_MODULES(GNUTLS, [gnutls],,
10938        AC_MSG_ERROR([[Disabling OpenSSL was requested, but GNUTLS is not
10939                      available in the system to use as replacement.]]))
10940    FilterLibs "${LIBGCRYPT_LIBS}"
10941    LIBGCRYPT_LIBS="${filteredlibs}"
10942else
10943    AC_MSG_RESULT([no])
10944fi
10945
10946AC_SUBST([LIBGCRYPT_CFLAGS])
10947AC_SUBST([LIBGCRYPT_LIBS])
10948
10949dnl ===================================================================
10950dnl Check for system redland
10951dnl ===================================================================
10952dnl redland: versions before 1.0.8 write RDF/XML that is useless for ODF (@xml:base)
10953dnl raptor2: need at least 2.0.7 for CVE-2012-0037
10954libo_CHECK_SYSTEM_MODULE([redland],[REDLAND],[redland >= 1.0.8 raptor2 >= 2.0.7])
10955if test "$with_system_redland" = "yes"; then
10956    AC_CHECK_LIB([rdf], [librdf_world_set_raptor_init_handler], [:],
10957            [AC_MSG_ERROR(librdf too old. Need >= 1.0.16)], [])
10958else
10959    RAPTOR_MAJOR="0"
10960    RASQAL_MAJOR="3"
10961    REDLAND_MAJOR="0"
10962fi
10963AC_SUBST(RAPTOR_MAJOR)
10964AC_SUBST(RASQAL_MAJOR)
10965AC_SUBST(REDLAND_MAJOR)
10966
10967dnl ===================================================================
10968dnl Check for system hunspell
10969dnl ===================================================================
10970AC_MSG_CHECKING([which libhunspell to use])
10971if test "$with_system_hunspell" = "yes"; then
10972    AC_MSG_RESULT([external])
10973    SYSTEM_HUNSPELL=TRUE
10974    AC_LANG_PUSH([C++])
10975    PKG_CHECK_MODULES(HUNSPELL, hunspell, HUNSPELL_PC="TRUE", HUNSPELL_PC="" )
10976    if test "$HUNSPELL_PC" != "TRUE"; then
10977        AC_CHECK_HEADER(hunspell.hxx, [],
10978            [
10979            AC_CHECK_HEADER(hunspell/hunspell.hxx, [ HUNSPELL_CFLAGS=-I/usr/include/hunspell ],
10980            [AC_MSG_ERROR(hunspell headers not found.)], [])
10981            ], [])
10982        AC_CHECK_LIB([hunspell], [main], [:],
10983           [ AC_MSG_ERROR(hunspell library not found.) ], [])
10984        HUNSPELL_LIBS=-lhunspell
10985    fi
10986    AC_LANG_POP([C++])
10987    HUNSPELL_CFLAGS=$(printf '%s' "$HUNSPELL_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10988    FilterLibs "${HUNSPELL_LIBS}"
10989    HUNSPELL_LIBS="${filteredlibs}"
10990else
10991    AC_MSG_RESULT([internal])
10992    SYSTEM_HUNSPELL=
10993    HUNSPELL_CFLAGS="-I${WORKDIR}/UnpackedTarball/hunspell/src/hunspell"
10994    if test "$COM" = "MSC"; then
10995        HUNSPELL_LIBS="${WORKDIR}/LinkTarget/StaticLibrary/hunspell.lib"
10996    else
10997        HUNSPELL_LIBS="-L${WORKDIR}/UnpackedTarball/hunspell/src/hunspell/.libs -lhunspell-1.7"
10998    fi
10999    BUILD_TYPE="$BUILD_TYPE HUNSPELL"
11000fi
11001AC_SUBST(SYSTEM_HUNSPELL)
11002AC_SUBST(HUNSPELL_CFLAGS)
11003AC_SUBST(HUNSPELL_LIBS)
11004
11005dnl ===================================================================
11006dnl Check for system zxing
11007dnl ===================================================================
11008AC_MSG_CHECKING([whether to use zxing])
11009if test "$enable_zxing" = "no"; then
11010    AC_MSG_RESULT([no])
11011    ENABLE_ZXING=
11012    SYSTEM_ZXING=
11013else
11014    AC_MSG_RESULT([yes])
11015    ENABLE_ZXING=TRUE
11016    AC_MSG_CHECKING([which libzxing to use])
11017    if test "$with_system_zxing" = "yes"; then
11018        AC_MSG_RESULT([external])
11019        SYSTEM_ZXING=TRUE
11020        AC_LANG_PUSH([C++])
11021        AC_CHECK_HEADER(ZXing/MultiFormatWriter.h, [],
11022            [AC_MSG_ERROR(zxing headers not found.)], [#include <stdexcept>])
11023        ZXING_CFLAGS=-I/usr/include/ZXing
11024        AC_CHECK_LIB([ZXing], [main], [ZXING_LIBS=-lZXing],
11025            [ AC_CHECK_LIB([ZXingCore], [main], [ZXING_LIBS=-lZXingCore],
11026            [ AC_MSG_ERROR(zxing C++ library not found.) ])], [])
11027        AC_LANG_POP([C++])
11028        ZXING_CFLAGS=$(printf '%s' "$ZXING_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11029        FilterLibs "${ZXING_LIBS}"
11030        ZXING_LIBS="${filteredlibs}"
11031    else
11032        AC_MSG_RESULT([internal])
11033        SYSTEM_ZXING=
11034        BUILD_TYPE="$BUILD_TYPE ZXING"
11035    fi
11036    if test "$ENABLE_ZXING" = TRUE; then
11037        AC_DEFINE(ENABLE_ZXING)
11038    fi
11039fi
11040AC_SUBST(SYSTEM_ZXING)
11041AC_SUBST(ENABLE_ZXING)
11042AC_SUBST(ZXING_CFLAGS)
11043AC_SUBST(ZXING_LIBS)
11044
11045dnl ===================================================================
11046dnl Check for system box2d
11047dnl ===================================================================
11048AC_MSG_CHECKING([which box2d to use])
11049if test "$with_system_box2d" = "yes"; then
11050    AC_MSG_RESULT([external])
11051    SYSTEM_BOX2D=TRUE
11052    AC_LANG_PUSH([C++])
11053    AC_CHECK_HEADER(box2d/box2d.h, [BOX2D_H_FOUND='TRUE'],
11054        [BOX2D_H_FOUND='FALSE'])
11055    if test "$BOX2D_H_FOUND" = "TRUE"; then # 2.4.0+
11056        _BOX2D_LIB=box2d
11057        AC_DEFINE(BOX2D_HEADER,<box2d/box2d.h>)
11058    else
11059        # fail this. there's no other alternative to check when we are here.
11060        AC_CHECK_HEADER([Box2D/Box2D.h], [],
11061            [AC_MSG_ERROR(box2d headers not found.)])
11062        _BOX2D_LIB=Box2D
11063        AC_DEFINE(BOX2D_HEADER,<Box2D/Box2D.h>)
11064    fi
11065    AC_CHECK_LIB([$_BOX2D_LIB], [main], [:],
11066        [ AC_MSG_ERROR(box2d library not found.) ], [])
11067    BOX2D_LIBS=-l$_BOX2D_LIB
11068    AC_LANG_POP([C++])
11069    BOX2D_CFLAGS=$(printf '%s' "$BOX2D_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11070    FilterLibs "${BOX2D_LIBS}"
11071    BOX2D_LIBS="${filteredlibs}"
11072else
11073    AC_MSG_RESULT([internal])
11074    SYSTEM_BOX2D=
11075    BUILD_TYPE="$BUILD_TYPE BOX2D"
11076fi
11077AC_SUBST(SYSTEM_BOX2D)
11078AC_SUBST(BOX2D_CFLAGS)
11079AC_SUBST(BOX2D_LIBS)
11080
11081dnl ===================================================================
11082dnl Checking for altlinuxhyph
11083dnl ===================================================================
11084AC_MSG_CHECKING([which altlinuxhyph to use])
11085if test "$with_system_altlinuxhyph" = "yes"; then
11086    AC_MSG_RESULT([external])
11087    SYSTEM_HYPH=TRUE
11088    AC_CHECK_HEADER(hyphen.h, [],
11089       [ AC_MSG_ERROR(altlinuxhyph headers not found.)], [])
11090    AC_CHECK_MEMBER(struct _HyphenDict.cset, [],
11091       [ AC_MSG_ERROR(no. You are sure you have altlinuyhyph headers?)],
11092       [#include <hyphen.h>])
11093    AC_CHECK_LIB(hyphen, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhyphen],
11094        [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
11095    if test -z "$HYPHEN_LIB"; then
11096        AC_CHECK_LIB(hyph, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhyph],
11097           [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
11098    fi
11099    if test -z "$HYPHEN_LIB"; then
11100        AC_CHECK_LIB(hnj, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhnj],
11101           [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
11102    fi
11103else
11104    AC_MSG_RESULT([internal])
11105    SYSTEM_HYPH=
11106    BUILD_TYPE="$BUILD_TYPE HYPHEN"
11107    if test "$COM" = "MSC"; then
11108        HYPHEN_LIB="${WORKDIR}/LinkTarget/StaticLibrary/hyphen.lib"
11109    else
11110        HYPHEN_LIB="-L${WORKDIR}/UnpackedTarball/hyphen/.libs -lhyphen"
11111    fi
11112fi
11113AC_SUBST(SYSTEM_HYPH)
11114AC_SUBST(HYPHEN_LIB)
11115
11116dnl ===================================================================
11117dnl Checking for mythes
11118dnl ===================================================================
11119AC_MSG_CHECKING([which mythes to use])
11120if test "$with_system_mythes" = "yes"; then
11121    AC_MSG_RESULT([external])
11122    SYSTEM_MYTHES=TRUE
11123    AC_LANG_PUSH([C++])
11124    PKG_CHECK_MODULES(MYTHES, mythes, MYTHES_PKGCONFIG=yes, MYTHES_PKGCONFIG=no)
11125    if test "$MYTHES_PKGCONFIG" = "no"; then
11126        AC_CHECK_HEADER(mythes.hxx, [],
11127            [ AC_MSG_ERROR(mythes.hxx headers not found.)], [])
11128        AC_CHECK_LIB([mythes-1.2], [main], [:],
11129            [ MYTHES_FOUND=no], [])
11130    if test "$MYTHES_FOUND" = "no"; then
11131        AC_CHECK_LIB(mythes, main, [MYTHES_FOUND=yes],
11132                [ MYTHES_FOUND=no], [])
11133    fi
11134    if test "$MYTHES_FOUND" = "no"; then
11135        AC_MSG_ERROR([mythes library not found!.])
11136    fi
11137    fi
11138    AC_LANG_POP([C++])
11139    MYTHES_CFLAGS=$(printf '%s' "$MYTHES_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11140    FilterLibs "${MYTHES_LIBS}"
11141    MYTHES_LIBS="${filteredlibs}"
11142else
11143    AC_MSG_RESULT([internal])
11144    SYSTEM_MYTHES=
11145    BUILD_TYPE="$BUILD_TYPE MYTHES"
11146    if test "$COM" = "MSC"; then
11147        MYTHES_LIBS="${WORKDIR}/LinkTarget/StaticLibrary/mythes.lib"
11148    else
11149        MYTHES_LIBS="-L${WORKDIR}/UnpackedTarball/mythes/.libs -lmythes-1.2"
11150    fi
11151fi
11152AC_SUBST(SYSTEM_MYTHES)
11153AC_SUBST(MYTHES_CFLAGS)
11154AC_SUBST(MYTHES_LIBS)
11155
11156dnl ===================================================================
11157dnl How should we build the linear programming solver ?
11158dnl ===================================================================
11159
11160ENABLE_COINMP=
11161AC_MSG_CHECKING([whether to build with CoinMP])
11162if test "$enable_coinmp" != "no"; then
11163    ENABLE_COINMP=TRUE
11164    AC_MSG_RESULT([yes])
11165    if test "$with_system_coinmp" = "yes"; then
11166        SYSTEM_COINMP=TRUE
11167        PKG_CHECK_MODULES(COINMP, coinmp coinutils)
11168        FilterLibs "${COINMP_LIBS}"
11169        COINMP_LIBS="${filteredlibs}"
11170    else
11171        BUILD_TYPE="$BUILD_TYPE COINMP"
11172    fi
11173else
11174    AC_MSG_RESULT([no])
11175fi
11176AC_SUBST(ENABLE_COINMP)
11177AC_SUBST(SYSTEM_COINMP)
11178AC_SUBST(COINMP_CFLAGS)
11179AC_SUBST(COINMP_LIBS)
11180
11181ENABLE_LPSOLVE=
11182AC_MSG_CHECKING([whether to build with lpsolve])
11183if test "$enable_lpsolve" != "no"; then
11184    ENABLE_LPSOLVE=TRUE
11185    AC_MSG_RESULT([yes])
11186else
11187    AC_MSG_RESULT([no])
11188fi
11189AC_SUBST(ENABLE_LPSOLVE)
11190
11191if test "$ENABLE_LPSOLVE" = TRUE; then
11192    AC_MSG_CHECKING([which lpsolve to use])
11193    if test "$with_system_lpsolve" = "yes"; then
11194        AC_MSG_RESULT([external])
11195        SYSTEM_LPSOLVE=TRUE
11196        AC_CHECK_HEADER(lpsolve/lp_lib.h, [],
11197           [ AC_MSG_ERROR(lpsolve headers not found.)], [])
11198        save_LIBS=$LIBS
11199        # some systems need this. Like Ubuntu...
11200        AC_CHECK_LIB(m, floor)
11201        AC_CHECK_LIB(dl, dlopen)
11202        AC_CHECK_LIB([lpsolve55], [make_lp], [:],
11203            [ AC_MSG_ERROR(lpsolve library not found or too old.)], [])
11204        LIBS=$save_LIBS
11205    else
11206        AC_MSG_RESULT([internal])
11207        SYSTEM_LPSOLVE=
11208        BUILD_TYPE="$BUILD_TYPE LPSOLVE"
11209    fi
11210fi
11211AC_SUBST(SYSTEM_LPSOLVE)
11212
11213dnl ===================================================================
11214dnl Checking for libexttextcat
11215dnl ===================================================================
11216libo_CHECK_SYSTEM_MODULE([libexttextcat],[LIBEXTTEXTCAT],[libexttextcat >= 3.4.1])
11217if test "$with_system_libexttextcat" = "yes"; then
11218    SYSTEM_LIBEXTTEXTCAT_DATA=file://`$PKG_CONFIG --variable=pkgdatadir libexttextcat`
11219fi
11220AC_SUBST(SYSTEM_LIBEXTTEXTCAT_DATA)
11221
11222dnl ===================================================================
11223dnl Checking for libnumbertext
11224dnl ===================================================================
11225libo_CHECK_SYSTEM_MODULE([libnumbertext],[LIBNUMBERTEXT],[libnumbertext >= 1.0.6])
11226if test "$with_system_libnumbertext" = "yes"; then
11227    SYSTEM_LIBNUMBERTEXT_DATA=file://`$PKG_CONFIG --variable=pkgdatadir libnumbertext`
11228    SYSTEM_LIBNUMBERTEXT=YES
11229else
11230    SYSTEM_LIBNUMBERTEXT=
11231    AC_LANG_PUSH([C++])
11232    save_CPPFLAGS=$CPPFLAGS
11233    CPPFLAGS="$CPPFLAGS $CXXFLAGS_CXX11"
11234    AC_CHECK_HEADERS([codecvt regex])
11235    AS_IF([test "x$ac_cv_header_codecvt" != xyes -o "x$ac_cv_header_regex" != xyes],
11236            [ LIBNUMBERTEXT_CFLAGS=''
11237              AC_MSG_WARN([No system-provided libnumbertext or codecvt/regex C++11 headers (min. libstdc++ 4.9).
11238                           Enable libnumbertext fallback (missing number to number name conversion).])
11239            ])
11240    CPPFLAGS=$save_CPPFLAGS
11241    AC_LANG_POP([C++])
11242fi
11243AC_SUBST(SYSTEM_LIBNUMBERTEXT)
11244AC_SUBST(SYSTEM_LIBNUMBERTEXT_DATA)
11245AC_SUBST(LIBNUMBERTEXT_CFLAGS)
11246
11247dnl ***************************************
11248dnl testing libc version for Linux...
11249dnl ***************************************
11250if test "$_os" = "Linux"; then
11251    AC_MSG_CHECKING([whether libc is >= 2.1.1])
11252    exec 6>/dev/null # no output
11253    AC_CHECK_LIB(c, gnu_get_libc_version, HAVE_LIBC=yes; export HAVE_LIBC)
11254    exec 6>&1 # output on again
11255    if test "$HAVE_LIBC"; then
11256        AC_MSG_RESULT([yes])
11257    else
11258        AC_MSG_ERROR([no, upgrade libc])
11259    fi
11260fi
11261
11262dnl =========================================
11263dnl Check for uuidgen
11264dnl =========================================
11265if test "$_os" = "WINNT"; then
11266    # we must use the uuidgen from the Windows SDK, which will be in the LO_PATH, but isn't in
11267    # the PATH for AC_PATH_PROG. It is already tested above in the WINDOWS_SDK_HOME check.
11268    UUIDGEN=uuidgen.exe
11269    AC_SUBST(UUIDGEN)
11270else
11271    AC_PATH_PROG([UUIDGEN], [uuidgen])
11272    if test -z "$UUIDGEN"; then
11273        AC_MSG_WARN([uuid is needed for building installation sets])
11274    fi
11275fi
11276
11277dnl ***************************************
11278dnl Checking for bison and flex
11279dnl ***************************************
11280AC_PATH_PROG(BISON, bison)
11281if test -z "$BISON"; then
11282    AC_MSG_ERROR([no bison found in \$PATH, install it])
11283else
11284    AC_MSG_CHECKING([the bison version])
11285    _bison_version=`$BISON --version | grep GNU | $SED -e 's@^[[^0-9]]*@@' -e 's@ .*@@' -e 's@,.*@@'`
11286    _bison_longver=`echo $_bison_version | $AWK -F. '{ print \$1*1000+\$2}'`
11287    dnl Accept newer than 2.0; for --enable-compiler-plugins at least 2.3 is known to be bad and
11288    dnl cause
11289    dnl
11290    dnl   idlc/source/parser.y:222:15: error: externally available entity 'YYSTYPE' is not previously declared in an included file (if it is only used in this translation unit, put it in an unnamed namespace; otherwise, provide a declaration of it in an included file) [loplugin:external]
11291    dnl   typedef union YYSTYPE
11292    dnl           ~~~~~~^~~~~~~
11293    dnl
11294    dnl while at least 3.4.1 is know to be good:
11295    if test "$COMPILER_PLUGINS" = TRUE; then
11296        if test "$_bison_longver" -lt 2004; then
11297            AC_MSG_ERROR([failed ($BISON $_bison_version need 2.4+ for --enable-compiler-plugins)])
11298        fi
11299    else
11300        if test "$_bison_longver" -lt 2000; then
11301            AC_MSG_ERROR([failed ($BISON $_bison_version need 2.0+)])
11302        fi
11303    fi
11304fi
11305AC_SUBST([BISON])
11306
11307AC_PATH_PROG(FLEX, flex)
11308if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
11309    FLEX=`cygpath -m $FLEX`
11310fi
11311if test -z "$FLEX"; then
11312    AC_MSG_ERROR([no flex found in \$PATH, install it])
11313else
11314    AC_MSG_CHECKING([the flex version])
11315    _flex_version=$($FLEX --version | $SED -e 's/^.*\([[[:digit:]]]\{1,\}\.[[[:digit:]]]\{1,\}\.[[[:digit:]]]\{1,\}\).*$/\1/')
11316    if test $(echo $_flex_version | $AWK -F. '{printf("%d%03d%03d", $1, $2, $3)}') -lt 2006000; then
11317        AC_MSG_ERROR([failed ($FLEX $_flex_version found, but need at least 2.6.0)])
11318    fi
11319fi
11320AC_SUBST([FLEX])
11321dnl ***************************************
11322dnl Checking for patch
11323dnl ***************************************
11324AC_PATH_PROG(PATCH, patch)
11325if test -z "$PATCH"; then
11326    AC_MSG_ERROR(["patch" not found in \$PATH, install it])
11327fi
11328
11329dnl On Solaris or macOS, check if --with-gnu-patch was used
11330if test "$_os" = "SunOS" -o "$_os" = "Darwin"; then
11331    if test -z "$with_gnu_patch"; then
11332        GNUPATCH=$PATCH
11333    else
11334        if test -x "$with_gnu_patch"; then
11335            GNUPATCH=$with_gnu_patch
11336        else
11337            AC_MSG_ERROR([--with-gnu-patch did not point to an executable])
11338        fi
11339    fi
11340
11341    AC_MSG_CHECKING([whether $GNUPATCH is GNU patch])
11342    if $GNUPATCH --version | grep "Free Software Foundation" >/dev/null 2>/dev/null; then
11343        AC_MSG_RESULT([yes])
11344    else
11345        AC_MSG_ERROR([no, GNU patch needed. install or specify with --with-gnu-patch=/path/to/it])
11346    fi
11347else
11348    GNUPATCH=$PATCH
11349fi
11350
11351if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
11352    GNUPATCH=`cygpath -m $GNUPATCH`
11353fi
11354
11355dnl We also need to check for --with-gnu-cp
11356
11357if test -z "$with_gnu_cp"; then
11358    # check the place where the good stuff is hidden on Solaris...
11359    if test -x /usr/gnu/bin/cp; then
11360        GNUCP=/usr/gnu/bin/cp
11361    else
11362        AC_PATH_PROGS(GNUCP, gnucp cp)
11363    fi
11364    if test -z $GNUCP; then
11365        AC_MSG_ERROR([Neither gnucp nor cp found. Install GNU cp and/or specify --with-gnu-cp=/path/to/it])
11366    fi
11367else
11368    if test -x "$with_gnu_cp"; then
11369        GNUCP=$with_gnu_cp
11370    else
11371        AC_MSG_ERROR([--with-gnu-cp did not point to an executable])
11372    fi
11373fi
11374
11375if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
11376    GNUCP=`cygpath -m $GNUCP`
11377fi
11378
11379AC_MSG_CHECKING([whether $GNUCP is GNU cp from coreutils with preserve= support])
11380if $GNUCP --version 2>/dev/null | grep "coreutils" >/dev/null 2>/dev/null; then
11381    AC_MSG_RESULT([yes])
11382elif $GNUCP --version 2>/dev/null | grep "GNU fileutils" >/dev/null 2>/dev/null; then
11383    AC_MSG_RESULT([yes])
11384else
11385    case "$build_os" in
11386    darwin*|macos*|netbsd*|openbsd*|freebsd*|dragonfly*|aix*)
11387        x_GNUCP=[\#]
11388        GNUCP=''
11389        AC_MSG_RESULT([no gnucp found - using the system's cp command])
11390        ;;
11391    *)
11392        AC_MSG_ERROR([no, GNU cp needed. install or specify with --with-gnu-cp=/path/to/it])
11393        ;;
11394    esac
11395fi
11396
11397AC_SUBST(GNUPATCH)
11398AC_SUBST(GNUCP)
11399AC_SUBST(x_GNUCP)
11400
11401dnl ***************************************
11402dnl testing assembler path
11403dnl ***************************************
11404ML_EXE=""
11405if test "$_os" = "WINNT"; then
11406    case "$WIN_HOST_ARCH" in
11407    x86) assembler=ml.exe ;;
11408    x64) assembler=ml64.exe ;;
11409    arm64) assembler=armasm64.exe ;;
11410    esac
11411
11412    AC_MSG_CHECKING([for the MSVC assembler ($assembler)])
11413    if test -f "$MSVC_HOST_PATH/$assembler"; then
11414        ML_EXE=`win_short_path_for_make "$MSVC_HOST_PATH/$assembler"`
11415        AC_MSG_RESULT([$ML_EXE])
11416    else
11417        AC_MSG_ERROR([not found in $MSVC_HOST_PATH])
11418    fi
11419fi
11420
11421AC_SUBST(ML_EXE)
11422
11423dnl ===================================================================
11424dnl We need zip and unzip
11425dnl ===================================================================
11426AC_PATH_PROG(ZIP, zip)
11427test -z "$ZIP" && AC_MSG_ERROR([zip is required])
11428if ! "$ZIP" --filesync < /dev/null 2>/dev/null > /dev/null; then
11429    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],,)
11430fi
11431
11432AC_PATH_PROG(UNZIP, unzip)
11433test -z "$UNZIP" && AC_MSG_ERROR([unzip is required])
11434
11435dnl ===================================================================
11436dnl Zip must be a specific type for different build types.
11437dnl ===================================================================
11438if test $build_os = cygwin; then
11439    if test -n "`$ZIP -h | $GREP -i WinNT`"; then
11440        AC_MSG_ERROR([$ZIP is not the required Cygwin version of Info-ZIP's zip.exe.])
11441    fi
11442fi
11443
11444dnl ===================================================================
11445dnl We need touch with -h option support.
11446dnl ===================================================================
11447AC_PATH_PROG(TOUCH, touch)
11448test -z "$TOUCH" && AC_MSG_ERROR([touch is required])
11449touch "$WARNINGS_FILE"
11450if ! "$TOUCH" -h "$WARNINGS_FILE" 2>/dev/null > /dev/null; then
11451    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],,)
11452fi
11453
11454dnl ===================================================================
11455dnl Check for system epoxy
11456dnl ===================================================================
11457libo_CHECK_SYSTEM_MODULE([epoxy], [EPOXY], [epoxy >= 1.2], ["-I${WORKDIR}/UnpackedTarball/epoxy/include"])
11458
11459dnl ===================================================================
11460dnl Set vcl option: coordinate device in double or sal_Int32
11461dnl ===================================================================
11462
11463dnl disabled for now, we don't want subtle differences between OSs
11464dnl AC_MSG_CHECKING([Type to use for Device Pixel coordinates])
11465dnl if test "$_os" = "Darwin" -o  $_os = iOS ; then
11466dnl     AC_DEFINE(VCL_FLOAT_DEVICE_PIXEL)
11467dnl     AC_MSG_RESULT([double])
11468dnl else
11469dnl     AC_MSG_RESULT([sal_Int32])
11470dnl fi
11471
11472dnl ===================================================================
11473dnl Show which vclplugs will be built.
11474dnl ===================================================================
11475R=""
11476if test "$USING_X11" != TRUE; then
11477    enable_gtk3=no
11478fi
11479
11480ENABLE_GTK3=""
11481if test "x$enable_gtk3" = "xyes"; then
11482    ENABLE_GTK3="TRUE"
11483    AC_DEFINE(ENABLE_GTK3)
11484    R="$R gtk3"
11485fi
11486AC_SUBST(ENABLE_GTK3)
11487
11488ENABLE_GTK3_KDE5=""
11489if test "x$enable_gtk3_kde5" = "xyes"; then
11490    ENABLE_GTK3_KDE5="TRUE"
11491    AC_DEFINE(ENABLE_GTK3_KDE5)
11492    R="$R gtk3_kde5"
11493fi
11494AC_SUBST(ENABLE_GTK3_KDE5)
11495
11496ENABLE_GTK4=""
11497if test "x$enable_gtk4" = "xyes"; then
11498    ENABLE_GTK4="TRUE"
11499    AC_DEFINE(ENABLE_GTK4)
11500    R="$R gtk4"
11501fi
11502AC_SUBST(ENABLE_GTK4)
11503
11504ENABLE_QT5=""
11505if test "x$enable_qt5" = "xyes"; then
11506    ENABLE_QT5="TRUE"
11507    AC_DEFINE(ENABLE_QT5)
11508    R="$R qt5"
11509fi
11510AC_SUBST(ENABLE_QT5)
11511
11512ENABLE_KF5=""
11513if test "x$enable_kf5" = "xyes"; then
11514    ENABLE_KF5="TRUE"
11515    AC_DEFINE(ENABLE_KF5)
11516    R="$R kf5"
11517fi
11518AC_SUBST(ENABLE_KF5)
11519
11520if test "x$USING_X11" = "xyes"; then
11521    R="$R gen"
11522fi
11523
11524if test "$_os" = "WINNT"; then
11525    R="$R win"
11526elif test "$_os" = "Darwin"; then
11527    R="$R osx"
11528elif test "$_os" = "iOS"; then
11529    R="ios"
11530elif test "$_os" = Android; then
11531    R="android"
11532fi
11533
11534build_vcl_plugins="$R"
11535if test -z "$build_vcl_plugins"; then
11536    build_vcl_plugins=" none"
11537fi
11538AC_MSG_NOTICE([VCLplugs to be built:${build_vcl_plugins}])
11539VCL_PLUGIN_INFO=$R
11540AC_SUBST([VCL_PLUGIN_INFO])
11541
11542dnl ===================================================================
11543dnl Check for GTK libraries
11544dnl ===================================================================
11545
11546GTK3_CFLAGS=""
11547GTK3_LIBS=""
11548if test "$test_gtk3" = yes -a "x$enable_gtk3" = "xyes" -o "x$enable_gtk3_kde5" = "xyes"; then
11549    if test "$with_system_cairo" = no; then
11550        add_warning 'Non-system cairo combined with gtk3 is assumed to cause trouble; proceed at your own risk.'
11551    fi
11552    : ${with_system_cairo:=yes}
11553    PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.20 gtk+-unix-print-3.0 gmodule-no-export-2.0 glib-2.0 >= 2.38 cairo)
11554    GTK3_CFLAGS=$(printf '%s' "$GTK3_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11555    GTK3_CFLAGS="$GTK3_CFLAGS -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
11556    FilterLibs "${GTK3_LIBS}"
11557    GTK3_LIBS="${filteredlibs}"
11558
11559    dnl We require egl only for the gtk3 plugin. Otherwise we use glx.
11560    if test "$with_system_epoxy" != "yes"; then
11561        AC_CHECK_LIB(EGL, eglMakeCurrent, [:], AC_MSG_ERROR([libEGL required.]))
11562        AC_CHECK_HEADER(EGL/eglplatform.h, [],
11563                        [AC_MSG_ERROR(EGL headers not found. install mesa-libEGL-devel)], [])
11564    fi
11565fi
11566AC_SUBST(GTK3_LIBS)
11567AC_SUBST(GTK3_CFLAGS)
11568
11569GTK4_CFLAGS=""
11570GTK4_LIBS=""
11571if test "$test_gtk4" = yes -a "x$enable_gtk4" = "xyes"; then
11572    if test "$with_system_cairo" = no; then
11573        add_warning 'Non-system cairo combined with gtk4 is assumed to cause trouble; proceed at your own risk.'
11574    fi
11575    : ${with_system_cairo:=yes}
11576    PKG_CHECK_MODULES(GTK4, gtk4 gmodule-no-export-2.0 glib-2.0 >= 2.38 cairo atk)
11577    GTK4_CFLAGS=$(printf '%s' "$GTK4_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11578    GTK4_CFLAGS="$GTK4_CFLAGS -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
11579    FilterLibs "${GTK4_LIBS}"
11580    GTK4_LIBS="${filteredlibs}"
11581
11582    dnl We require egl only for the gtk4 plugin. Otherwise we use glx.
11583    if test "$with_system_epoxy" != "yes"; then
11584        AC_CHECK_LIB(EGL, eglMakeCurrent, [:], AC_MSG_ERROR([libEGL required.]))
11585        AC_CHECK_HEADER(EGL/eglplatform.h, [],
11586                        [AC_MSG_ERROR(EGL headers not found. install mesa-libEGL-devel)], [])
11587    fi
11588fi
11589AC_SUBST(GTK4_LIBS)
11590AC_SUBST(GTK4_CFLAGS)
11591
11592if test "$enable_introspection" = yes; then
11593    if test "$ENABLE_GTK3" = "TRUE" -o "$ENABLE_GTK3_KDE5" = "TRUE"; then
11594        GOBJECT_INTROSPECTION_REQUIRE(INTROSPECTION_REQUIRED_VERSION)
11595    else
11596        AC_MSG_ERROR([--enable-introspection requires --enable-gtk3])
11597    fi
11598fi
11599
11600dnl ===================================================================
11601dnl check for dbus support
11602dnl ===================================================================
11603ENABLE_DBUS=""
11604DBUS_CFLAGS=""
11605DBUS_LIBS=""
11606DBUS_GLIB_CFLAGS=""
11607DBUS_GLIB_LIBS=""
11608DBUS_HAVE_GLIB=""
11609
11610if test "$enable_dbus" = "no"; then
11611    test_dbus=no
11612fi
11613
11614AC_MSG_CHECKING([whether to enable DBUS support])
11615if test "$test_dbus" = "yes"; then
11616    ENABLE_DBUS="TRUE"
11617    AC_MSG_RESULT([yes])
11618    PKG_CHECK_MODULES(DBUS, dbus-1 >= 0.60)
11619    AC_DEFINE(ENABLE_DBUS)
11620    DBUS_CFLAGS=$(printf '%s' "$DBUS_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11621    FilterLibs "${DBUS_LIBS}"
11622    DBUS_LIBS="${filteredlibs}"
11623
11624    # Glib is needed for BluetoothServer
11625    # Sets also DBUS_GLIB_CFLAGS/DBUS_GLIB_LIBS if successful.
11626    PKG_CHECK_MODULES(DBUS_GLIB,[glib-2.0 >= 2.4],
11627        [
11628            DBUS_HAVE_GLIB="TRUE"
11629            AC_DEFINE(DBUS_HAVE_GLIB,1)
11630        ],
11631        AC_MSG_WARN([[No Glib found, Bluetooth support will be disabled]])
11632    )
11633else
11634    AC_MSG_RESULT([no])
11635fi
11636
11637AC_SUBST(ENABLE_DBUS)
11638AC_SUBST(DBUS_CFLAGS)
11639AC_SUBST(DBUS_LIBS)
11640AC_SUBST(DBUS_GLIB_CFLAGS)
11641AC_SUBST(DBUS_GLIB_LIBS)
11642AC_SUBST(DBUS_HAVE_GLIB)
11643
11644AC_MSG_CHECKING([whether to enable Impress remote control])
11645if test -n "$enable_sdremote" -a "$enable_sdremote" != "no"; then
11646    AC_MSG_RESULT([yes])
11647    ENABLE_SDREMOTE=TRUE
11648    AC_MSG_CHECKING([whether to enable Bluetooth support in Impress remote control])
11649
11650    if test $OS = MACOSX && test "$MACOSX_SDK_VERSION" -ge 101500; then
11651        # The Bluetooth code doesn't compile with macOS SDK 10.15
11652        if test "$enable_sdremote_bluetooth" = yes; then
11653            AC_MSG_ERROR([macOS SDK $with_macosx_sdk does not currently support --enable-sdremote-bluetooth])
11654        fi
11655        enable_sdremote_bluetooth=no
11656    fi
11657    # If not explicitly enabled or disabled, default
11658    if test -z "$enable_sdremote_bluetooth"; then
11659        case "$OS" in
11660        LINUX|MACOSX|WNT)
11661            # Default to yes for these
11662            enable_sdremote_bluetooth=yes
11663            ;;
11664        *)
11665            # otherwise no
11666            enable_sdremote_bluetooth=no
11667            ;;
11668        esac
11669    fi
11670    # $enable_sdremote_bluetooth is guaranteed non-empty now
11671
11672    if test "$enable_sdremote_bluetooth" != "no"; then
11673        if test "$OS" = "LINUX"; then
11674            if test "$ENABLE_DBUS" = "TRUE" -a "$DBUS_HAVE_GLIB" = "TRUE"; then
11675                AC_MSG_RESULT([yes])
11676                ENABLE_SDREMOTE_BLUETOOTH=TRUE
11677                dnl ===================================================================
11678                dnl Check for system bluez
11679                dnl ===================================================================
11680                AC_MSG_CHECKING([which Bluetooth header to use])
11681                if test "$with_system_bluez" = "yes"; then
11682                    AC_MSG_RESULT([external])
11683                    AC_CHECK_HEADER(bluetooth/bluetooth.h, [],
11684                        [AC_MSG_ERROR(bluetooth.h not found. install bluez)], [])
11685                    SYSTEM_BLUEZ=TRUE
11686                else
11687                    AC_MSG_RESULT([internal])
11688                    SYSTEM_BLUEZ=
11689                fi
11690            else
11691                AC_MSG_RESULT([no, dbus disabled])
11692                ENABLE_SDREMOTE_BLUETOOTH=
11693                SYSTEM_BLUEZ=
11694            fi
11695        else
11696            AC_MSG_RESULT([yes])
11697            ENABLE_SDREMOTE_BLUETOOTH=TRUE
11698            SYSTEM_BLUEZ=
11699        fi
11700    else
11701        AC_MSG_RESULT([no])
11702        ENABLE_SDREMOTE_BLUETOOTH=
11703        SYSTEM_BLUEZ=
11704    fi
11705else
11706    ENABLE_SDREMOTE=
11707    SYSTEM_BLUEZ=
11708    AC_MSG_RESULT([no])
11709fi
11710AC_SUBST(ENABLE_SDREMOTE)
11711AC_SUBST(ENABLE_SDREMOTE_BLUETOOTH)
11712AC_SUBST(SYSTEM_BLUEZ)
11713
11714dnl ===================================================================
11715dnl Check whether to enable GIO support
11716dnl ===================================================================
11717if test "$ENABLE_GTK4" = "TRUE" -o "$ENABLE_GTK3" = "TRUE" -o "$ENABLE_GTK3_KDE5" = "TRUE"; then
11718    AC_MSG_CHECKING([whether to enable GIO support])
11719    if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_gio" = "yes"; then
11720        dnl Need at least 2.26 for the dbus support.
11721        PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.26],
11722                          [ENABLE_GIO="TRUE"], [ENABLE_GIO=""])
11723        if test "$ENABLE_GIO" = "TRUE"; then
11724            AC_DEFINE(ENABLE_GIO)
11725            GIO_CFLAGS=$(printf '%s' "$GIO_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11726            FilterLibs "${GIO_LIBS}"
11727            GIO_LIBS="${filteredlibs}"
11728        fi
11729    else
11730        AC_MSG_RESULT([no])
11731    fi
11732fi
11733AC_SUBST(ENABLE_GIO)
11734AC_SUBST(GIO_CFLAGS)
11735AC_SUBST(GIO_LIBS)
11736
11737
11738dnl ===================================================================
11739
11740SPLIT_APP_MODULES=""
11741if test "$enable_split_app_modules" = "yes"; then
11742    SPLIT_APP_MODULES="TRUE"
11743fi
11744AC_SUBST(SPLIT_APP_MODULES)
11745
11746SPLIT_OPT_FEATURES=""
11747if test "$enable_split_opt_features" = "yes"; then
11748    SPLIT_OPT_FEATURES="TRUE"
11749fi
11750AC_SUBST(SPLIT_OPT_FEATURES)
11751
11752dnl ===================================================================
11753dnl Check whether the GStreamer libraries are available.
11754dnl ===================================================================
11755
11756ENABLE_GSTREAMER_1_0=""
11757
11758if test "$test_gstreamer_1_0" = yes; then
11759
11760    AC_MSG_CHECKING([whether to enable the GStreamer 1.0 avmedia backend])
11761    if test "$enable_avmedia" = yes -a "$enable_gstreamer_1_0" != no; then
11762        ENABLE_GSTREAMER_1_0="TRUE"
11763        AC_MSG_RESULT([yes])
11764        PKG_CHECK_MODULES( [GSTREAMER_1_0], [gstreamer-1.0 gstreamer-plugins-base-1.0 gstreamer-pbutils-1.0 gstreamer-video-1.0] )
11765        GSTREAMER_1_0_CFLAGS=$(printf '%s' "$GSTREAMER_1_0_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11766        FilterLibs "${GSTREAMER_1_0_LIBS}"
11767        GSTREAMER_1_0_LIBS="${filteredlibs}"
11768        AC_DEFINE(ENABLE_GSTREAMER_1_0)
11769    else
11770        AC_MSG_RESULT([no])
11771    fi
11772fi
11773AC_SUBST(GSTREAMER_1_0_CFLAGS)
11774AC_SUBST(GSTREAMER_1_0_LIBS)
11775AC_SUBST(ENABLE_GSTREAMER_1_0)
11776
11777ENABLE_OPENGL_TRANSITIONS=
11778ENABLE_OPENGL_CANVAS=
11779if test $_os = iOS -o $_os = Android -o "$ENABLE_FUZZERS" = "TRUE"; then
11780   : # disable
11781elif test "$_os" = "Darwin"; then
11782    # We use frameworks on macOS, no need for detail checks
11783    ENABLE_OPENGL_TRANSITIONS=TRUE
11784    AC_DEFINE(HAVE_FEATURE_OPENGL,1)
11785    ENABLE_OPENGL_CANVAS=TRUE
11786elif test $_os = WINNT; then
11787    ENABLE_OPENGL_TRANSITIONS=TRUE
11788    AC_DEFINE(HAVE_FEATURE_OPENGL,1)
11789    ENABLE_OPENGL_CANVAS=TRUE
11790else
11791    if test "$USING_X11" = TRUE; then
11792        AC_CHECK_LIB(GL, glBegin, [:], AC_MSG_ERROR([libGL required.]))
11793        ENABLE_OPENGL_TRANSITIONS=TRUE
11794        AC_DEFINE(HAVE_FEATURE_OPENGL,1)
11795        ENABLE_OPENGL_CANVAS=TRUE
11796    fi
11797fi
11798
11799AC_SUBST(ENABLE_OPENGL_TRANSITIONS)
11800AC_SUBST(ENABLE_OPENGL_CANVAS)
11801
11802dnl =================================================
11803dnl Check whether to build with OpenCL support.
11804dnl =================================================
11805
11806if test $_os != iOS -a $_os != Android -a "$ENABLE_FUZZERS" != "TRUE" -a "$enable_opencl" = "yes"; then
11807    # OPENCL in BUILD_TYPE and HAVE_FEATURE_OPENCL tell that OpenCL is potentially available on the
11808    # platform (optional at run-time, used through clew).
11809    BUILD_TYPE="$BUILD_TYPE OPENCL"
11810    AC_DEFINE(HAVE_FEATURE_OPENCL)
11811fi
11812
11813dnl =================================================
11814dnl Check whether to build with dconf support.
11815dnl =================================================
11816
11817if test $_os != Android -a $_os != iOS -a "$enable_dconf" != no; then
11818    PKG_CHECK_MODULES([DCONF], [dconf >= 0.15.2], [], [
11819        if test "$enable_dconf" = yes; then
11820            AC_MSG_ERROR([dconf not found])
11821        else
11822            enable_dconf=no
11823        fi])
11824fi
11825AC_MSG_CHECKING([whether to enable dconf])
11826if test $_os = Android -o $_os = iOS -o "$enable_dconf" = no; then
11827    DCONF_CFLAGS=
11828    DCONF_LIBS=
11829    ENABLE_DCONF=
11830    AC_MSG_RESULT([no])
11831else
11832    ENABLE_DCONF=TRUE
11833    AC_DEFINE(ENABLE_DCONF)
11834    AC_MSG_RESULT([yes])
11835fi
11836AC_SUBST([DCONF_CFLAGS])
11837AC_SUBST([DCONF_LIBS])
11838AC_SUBST([ENABLE_DCONF])
11839
11840# pdf import?
11841AC_MSG_CHECKING([whether to build the PDF import feature])
11842ENABLE_PDFIMPORT=
11843if test -z "$enable_pdfimport" -o "$enable_pdfimport" = yes; then
11844    AC_MSG_RESULT([yes])
11845    ENABLE_PDFIMPORT=TRUE
11846    AC_DEFINE(HAVE_FEATURE_PDFIMPORT)
11847else
11848    AC_MSG_RESULT([no])
11849fi
11850
11851# Pdfium?
11852AC_MSG_CHECKING([whether to build PDFium])
11853ENABLE_PDFIUM=
11854if test \( -z "$enable_pdfium" -a "$ENABLE_PDFIMPORT" = "TRUE" \) -o "$enable_pdfium" = yes; then
11855    AC_MSG_RESULT([yes])
11856    ENABLE_PDFIUM=TRUE
11857    BUILD_TYPE="$BUILD_TYPE PDFIUM"
11858else
11859    AC_MSG_RESULT([no])
11860fi
11861AC_SUBST(ENABLE_PDFIUM)
11862
11863dnl ===================================================================
11864dnl Check for poppler
11865dnl ===================================================================
11866ENABLE_POPPLER=
11867AC_MSG_CHECKING([whether to build Poppler])
11868if test \( -z "$enable_poppler" -a "$ENABLE_PDFIMPORT" = "TRUE" -a $_os != Android \) -o "$enable_poppler" = yes; then
11869    AC_MSG_RESULT([yes])
11870    ENABLE_POPPLER=TRUE
11871    AC_DEFINE(HAVE_FEATURE_POPPLER)
11872else
11873    AC_MSG_RESULT([no])
11874fi
11875AC_SUBST(ENABLE_POPPLER)
11876
11877if test "$ENABLE_PDFIMPORT" = "TRUE" -a "$ENABLE_POPPLER" != "TRUE" -a "$ENABLE_PDFIUM" != "TRUE"; then
11878    AC_MSG_ERROR([Cannot import PDF without either Pdfium or Poppler; please enable either of them.])
11879fi
11880
11881if test "$ENABLE_PDFIMPORT" != "TRUE" -a \( "$ENABLE_POPPLER" = "TRUE" -o "$ENABLE_PDFIUM" = "TRUE" \); then
11882    AC_MSG_ERROR([Cannot enable Pdfium or Poppler when PDF importing is disabled; please enable PDF import first.])
11883fi
11884
11885if test "$ENABLE_PDFIMPORT" = "TRUE" -a "$ENABLE_POPPLER" = "TRUE"; then
11886    dnl ===================================================================
11887    dnl Check for system poppler
11888    dnl ===================================================================
11889    AC_MSG_CHECKING([which PDF import poppler to use])
11890    if test "$with_system_poppler" = "yes"; then
11891        AC_MSG_RESULT([external])
11892        SYSTEM_POPPLER=TRUE
11893        PKG_CHECK_MODULES( POPPLER, poppler >= 0.12.0 )
11894        AC_LANG_PUSH([C++])
11895        save_CXXFLAGS=$CXXFLAGS
11896        save_CPPFLAGS=$CPPFLAGS
11897        CXXFLAGS="$CXXFLAGS $POPPLER_CFLAGS"
11898        CPPFLAGS="$CPPFLAGS $POPPLER_CFLAGS"
11899        AC_CHECK_HEADER([cpp/poppler-version.h],
11900            [AC_DEFINE([HAVE_POPPLER_VERSION_H], 1)],
11901            [])
11902        CXXFLAGS=$save_CXXFLAGS
11903        CPPFLAGS=$save_CPPFLAGS
11904        AC_LANG_POP([C++])
11905        POPPLER_CFLAGS=$(printf '%s' "$POPPLER_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11906
11907        FilterLibs "${POPPLER_LIBS}"
11908        POPPLER_LIBS="${filteredlibs}"
11909    else
11910        AC_MSG_RESULT([internal])
11911        SYSTEM_POPPLER=
11912        BUILD_TYPE="$BUILD_TYPE POPPLER"
11913        AC_DEFINE([HAVE_POPPLER_VERSION_H], 1)
11914    fi
11915    AC_DEFINE([ENABLE_PDFIMPORT],1)
11916fi
11917AC_SUBST(ENABLE_PDFIMPORT)
11918AC_SUBST(SYSTEM_POPPLER)
11919AC_SUBST(POPPLER_CFLAGS)
11920AC_SUBST(POPPLER_LIBS)
11921
11922# Skia?
11923AC_MSG_CHECKING([whether to build Skia])
11924ENABLE_SKIA=
11925if test "$enable_skia" != "no" -a "$build_skia" = "yes" -a -z "$DISABLE_GUI"; then
11926    if test "$enable_skia" = "debug"; then
11927        AC_MSG_RESULT([yes (debug)])
11928        ENABLE_SKIA_DEBUG=TRUE
11929    else
11930        AC_MSG_RESULT([yes])
11931        ENABLE_SKIA_DEBUG=
11932    fi
11933    ENABLE_SKIA=TRUE
11934    AC_DEFINE(HAVE_FEATURE_SKIA)
11935    BUILD_TYPE="$BUILD_TYPE SKIA"
11936else
11937    AC_MSG_RESULT([no])
11938fi
11939AC_SUBST(ENABLE_SKIA)
11940AC_SUBST(ENABLE_SKIA_DEBUG)
11941
11942LO_CLANG_CXXFLAGS_INTRINSICS_SSE2=
11943LO_CLANG_CXXFLAGS_INTRINSICS_SSSE3=
11944LO_CLANG_CXXFLAGS_INTRINSICS_SSE41=
11945LO_CLANG_CXXFLAGS_INTRINSICS_SSE42=
11946LO_CLANG_CXXFLAGS_INTRINSICS_AVX=
11947LO_CLANG_CXXFLAGS_INTRINSICS_AVX2=
11948LO_CLANG_CXXFLAGS_INTRINSICS_AVX512=
11949LO_CLANG_CXXFLAGS_INTRINSICS_F16C=
11950LO_CLANG_CXXFLAGS_INTRINSICS_FMA=
11951HAVE_LO_CLANG_DLLEXPORTINLINES=
11952
11953if test "$ENABLE_SKIA" = TRUE -a "$COM_IS_CLANG" != TRUE -a ! \( "$_os" = "WINNT" -a "$CPUNAME" = "AARCH64" \); then
11954    if test -n "$LO_CLANG_CC" -a -n "$LO_CLANG_CXX"; then
11955        AC_MSG_CHECKING([for Clang])
11956        AC_MSG_RESULT([$LO_CLANG_CC / $LO_CLANG_CXX])
11957    else
11958        if test "$_os" = "WINNT"; then
11959            AC_MSG_CHECKING([for clang-cl])
11960            if test -x "$VC_PRODUCT_DIR/Tools/Llvm/bin/clang-cl.exe"; then
11961                LO_CLANG_CC=`win_short_path_for_make "$VC_PRODUCT_DIR/Tools/Llvm/bin/clang-cl.exe"`
11962                dnl explicitly set -m32/-m64
11963                LO_CLANG_CC="$LO_CLANG_CC -m$WIN_HOST_BITS"
11964                LO_CLANG_CXX="$LO_CLANG_CC"
11965                AC_MSG_RESULT([$LO_CLANG_CC])
11966            else
11967                AC_MSG_RESULT([no])
11968            fi
11969        else
11970            AC_CHECK_PROG(LO_CLANG_CC,clang,clang,[])
11971            AC_CHECK_PROG(LO_CLANG_CXX,clang++,clang++,[])
11972        fi
11973    fi
11974    if test -n "$LO_CLANG_CC" -a -n "$LO_CLANG_CXX"; then
11975        clang2_version=`echo __clang_major__.__clang_minor__.__clang_patchlevel__ | $LO_CLANG_CC -E - | tail -1 | sed 's/ //g'`
11976        clang2_ver=`echo "$clang2_version" | $AWK -F. '{ print \$1*10000+(\$2<100?\$2:99)*100+(\$3<100?\$3:99) }'`
11977        if test "$clang2_ver" -lt 50002; then
11978            AC_MSG_WARN(["$clang2_version" is too old or unrecognized, must be at least Clang 5.0.2])
11979            LO_CLANG_CC=
11980            LO_CLANG_CXX=
11981        fi
11982    fi
11983    if test -n "$LO_CLANG_CC" -a -n "$LO_CLANG_CXX" -a "$_os" = "WINNT"; then
11984        save_CXX="$CXX"
11985        CXX="$LO_CLANG_CXX"
11986        AC_MSG_CHECKING([whether $CXX supports -Zc:dllexportInlines-])
11987        AC_LANG_PUSH([C++])
11988        save_CXXFLAGS=$CXXFLAGS
11989        CXXFLAGS="$CXXFLAGS -Werror -Zc:dllexportInlines-"
11990        AC_COMPILE_IFELSE([AC_LANG_SOURCE()], [
11991                HAVE_LO_CLANG_DLLEXPORTINLINES=TRUE
11992                AC_MSG_RESULT([yes])
11993            ], [AC_MSG_RESULT([no])])
11994        CXXFLAGS=$save_CXXFLAGS
11995        AC_LANG_POP([C++])
11996        CXX="$save_CXX"
11997        if test -z "$HAVE_LO_CLANG_DLLEXPORTINLINES"; then
11998            AC_MSG_ERROR([Clang compiler does not support -Zc:dllexportInlines-. The Skia library needs to be built using a newer Clang version, or use --disable-skia.])
11999        fi
12000    fi
12001    if test -z "$LO_CLANG_CC" -o -z "$LO_CLANG_CXX"; then
12002        # Skia is the default on Windows, so hard-require Clang.
12003        # Elsewhere it's used just by the 'gen' VCL backend which is rarely used.
12004        if test "$_os" = "WINNT"; then
12005            AC_MSG_ERROR([Clang compiler not found. The Skia library needs to be built using Clang.])
12006        else
12007            AC_MSG_WARN([Clang compiler not found.])
12008        fi
12009    else
12010
12011        save_CXX="$CXX"
12012        CXX="$LO_CLANG_CXX"
12013        # copy&paste (and adjust) of intrinsics checks, since MSVC's -arch doesn't work well for Clang-cl
12014        flag_sse2=-msse2
12015        flag_ssse3=-mssse3
12016        flag_sse41=-msse4.1
12017        flag_sse42=-msse4.2
12018        flag_avx=-mavx
12019        flag_avx2=-mavx2
12020        flag_avx512="-mavx512f -mavx512vl -mavx512bw -mavx512dq -mavx512cd"
12021        flag_f16c=-mf16c
12022        flag_fma=-mfma
12023
12024        AC_MSG_CHECKING([whether $CXX can compile SSE2 intrinsics])
12025        AC_LANG_PUSH([C++])
12026        save_CXXFLAGS=$CXXFLAGS
12027        CXXFLAGS="$CXXFLAGS $flag_sse2"
12028        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12029            #include <emmintrin.h>
12030            int main () {
12031                __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
12032                c = _mm_xor_si128 (a, b);
12033                return 0;
12034            }
12035            ])],
12036            [can_compile_sse2=yes],
12037            [can_compile_sse2=no])
12038        AC_LANG_POP([C++])
12039        CXXFLAGS=$save_CXXFLAGS
12040        AC_MSG_RESULT([${can_compile_sse2}])
12041        if test "${can_compile_sse2}" = "yes" ; then
12042            LO_CLANG_CXXFLAGS_INTRINSICS_SSE2="$flag_sse2"
12043        fi
12044
12045        AC_MSG_CHECKING([whether $CXX can compile SSSE3 intrinsics])
12046        AC_LANG_PUSH([C++])
12047        save_CXXFLAGS=$CXXFLAGS
12048        CXXFLAGS="$CXXFLAGS $flag_ssse3"
12049        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12050            #include <tmmintrin.h>
12051            int main () {
12052                __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
12053                c = _mm_maddubs_epi16 (a, b);
12054                return 0;
12055            }
12056            ])],
12057            [can_compile_ssse3=yes],
12058            [can_compile_ssse3=no])
12059        AC_LANG_POP([C++])
12060        CXXFLAGS=$save_CXXFLAGS
12061        AC_MSG_RESULT([${can_compile_ssse3}])
12062        if test "${can_compile_ssse3}" = "yes" ; then
12063            LO_CLANG_CXXFLAGS_INTRINSICS_SSSE3="$flag_ssse3"
12064        fi
12065
12066        AC_MSG_CHECKING([whether $CXX can compile SSE4.1 intrinsics])
12067        AC_LANG_PUSH([C++])
12068        save_CXXFLAGS=$CXXFLAGS
12069        CXXFLAGS="$CXXFLAGS $flag_sse41"
12070        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12071            #include <smmintrin.h>
12072            int main () {
12073                __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
12074                c = _mm_cmpeq_epi64 (a, b);
12075                return 0;
12076            }
12077            ])],
12078            [can_compile_sse41=yes],
12079            [can_compile_sse41=no])
12080        AC_LANG_POP([C++])
12081        CXXFLAGS=$save_CXXFLAGS
12082        AC_MSG_RESULT([${can_compile_sse41}])
12083        if test "${can_compile_sse41}" = "yes" ; then
12084            LO_CLANG_CXXFLAGS_INTRINSICS_SSE41="$flag_sse41"
12085        fi
12086
12087        AC_MSG_CHECKING([whether $CXX can compile SSE4.2 intrinsics])
12088        AC_LANG_PUSH([C++])
12089        save_CXXFLAGS=$CXXFLAGS
12090        CXXFLAGS="$CXXFLAGS $flag_sse42"
12091        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12092            #include <nmmintrin.h>
12093            int main () {
12094                __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
12095                c = _mm_cmpgt_epi64 (a, b);
12096                return 0;
12097            }
12098            ])],
12099            [can_compile_sse42=yes],
12100            [can_compile_sse42=no])
12101        AC_LANG_POP([C++])
12102        CXXFLAGS=$save_CXXFLAGS
12103        AC_MSG_RESULT([${can_compile_sse42}])
12104        if test "${can_compile_sse42}" = "yes" ; then
12105            LO_CLANG_CXXFLAGS_INTRINSICS_SSE42="$flag_sse42"
12106        fi
12107
12108        AC_MSG_CHECKING([whether $CXX can compile AVX intrinsics])
12109        AC_LANG_PUSH([C++])
12110        save_CXXFLAGS=$CXXFLAGS
12111        CXXFLAGS="$CXXFLAGS $flag_avx"
12112        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12113            #include <immintrin.h>
12114            int main () {
12115                __m256 a = _mm256_set1_ps (0.0f), b = _mm256_set1_ps (0.0f), c;
12116                c = _mm256_xor_ps(a, b);
12117                return 0;
12118            }
12119            ])],
12120            [can_compile_avx=yes],
12121            [can_compile_avx=no])
12122        AC_LANG_POP([C++])
12123        CXXFLAGS=$save_CXXFLAGS
12124        AC_MSG_RESULT([${can_compile_avx}])
12125        if test "${can_compile_avx}" = "yes" ; then
12126            LO_CLANG_CXXFLAGS_INTRINSICS_AVX="$flag_avx"
12127        fi
12128
12129        AC_MSG_CHECKING([whether $CXX can compile AVX2 intrinsics])
12130        AC_LANG_PUSH([C++])
12131        save_CXXFLAGS=$CXXFLAGS
12132        CXXFLAGS="$CXXFLAGS $flag_avx2"
12133        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12134            #include <immintrin.h>
12135            int main () {
12136                __m256i a = _mm256_set1_epi32 (0), b = _mm256_set1_epi32 (0), c;
12137                c = _mm256_maddubs_epi16(a, b);
12138                return 0;
12139            }
12140            ])],
12141            [can_compile_avx2=yes],
12142            [can_compile_avx2=no])
12143        AC_LANG_POP([C++])
12144        CXXFLAGS=$save_CXXFLAGS
12145        AC_MSG_RESULT([${can_compile_avx2}])
12146        if test "${can_compile_avx2}" = "yes" ; then
12147            LO_CLANG_CXXFLAGS_INTRINSICS_AVX2="$flag_avx2"
12148        fi
12149
12150        AC_MSG_CHECKING([whether $CXX can compile AVX512 intrinsics])
12151        AC_LANG_PUSH([C++])
12152        save_CXXFLAGS=$CXXFLAGS
12153        CXXFLAGS="$CXXFLAGS $flag_avx512"
12154        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12155            #include <immintrin.h>
12156            int main () {
12157                __m512i a = _mm512_loadu_si512(0);
12158                return 0;
12159            }
12160            ])],
12161            [can_compile_avx512=yes],
12162            [can_compile_avx512=no])
12163        AC_LANG_POP([C++])
12164        CXXFLAGS=$save_CXXFLAGS
12165        AC_MSG_RESULT([${can_compile_avx512}])
12166        if test "${can_compile_avx512}" = "yes" ; then
12167            LO_CLANG_CXXFLAGS_INTRINSICS_AVX512="$flag_avx512"
12168        fi
12169
12170        AC_MSG_CHECKING([whether $CXX can compile F16C intrinsics])
12171        AC_LANG_PUSH([C++])
12172        save_CXXFLAGS=$CXXFLAGS
12173        CXXFLAGS="$CXXFLAGS $flag_f16c"
12174        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12175            #include <immintrin.h>
12176            int main () {
12177                __m128i a = _mm_set1_epi32 (0);
12178                __m128 c;
12179                c = _mm_cvtph_ps(a);
12180                return 0;
12181            }
12182            ])],
12183            [can_compile_f16c=yes],
12184            [can_compile_f16c=no])
12185        AC_LANG_POP([C++])
12186        CXXFLAGS=$save_CXXFLAGS
12187        AC_MSG_RESULT([${can_compile_f16c}])
12188        if test "${can_compile_f16c}" = "yes" ; then
12189            LO_CLANG_CXXFLAGS_INTRINSICS_F16C="$flag_f16c"
12190        fi
12191
12192        AC_MSG_CHECKING([whether $CXX can compile FMA intrinsics])
12193        AC_LANG_PUSH([C++])
12194        save_CXXFLAGS=$CXXFLAGS
12195        CXXFLAGS="$CXXFLAGS $flag_fma"
12196        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12197            #include <immintrin.h>
12198            int main () {
12199                __m256 a = _mm256_set1_ps (0.0f), b = _mm256_set1_ps (0.0f), c = _mm256_set1_ps (0.0f), d;
12200                d = _mm256_fmadd_ps(a, b, c);
12201                return 0;
12202            }
12203            ])],
12204            [can_compile_fma=yes],
12205            [can_compile_fma=no])
12206        AC_LANG_POP([C++])
12207        CXXFLAGS=$save_CXXFLAGS
12208        AC_MSG_RESULT([${can_compile_fma}])
12209        if test "${can_compile_fma}" = "yes" ; then
12210            LO_CLANG_CXXFLAGS_INTRINSICS_FMA="$flag_fma"
12211        fi
12212
12213        CXX="$save_CXX"
12214    fi
12215fi
12216#
12217# prefix LO_CLANG_CC/LO_CLANG_CXX with ccache if needed
12218#
12219UNCACHED_CLANG_CC="$LO_CLANG_CC"
12220UNCACHED_CLANG_CXX="$LO_CLANG_CXX"
12221if test "$CCACHE" != "" -a -n "$LO_CLANG_CC" -a -n "$LO_CLANG_CXX"; then
12222    AC_MSG_CHECKING([whether $LO_CLANG_CC is already ccached])
12223    AC_LANG_PUSH([C])
12224    save_CC="$CC"
12225    CC="$LO_CLANG_CC"
12226    save_CFLAGS=$CFLAGS
12227    CFLAGS="$CFLAGS --ccache-skip -O2"
12228    dnl an empty program will do, we're checking the compiler flags
12229    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
12230                      [use_ccache=yes], [use_ccache=no])
12231    CFLAGS=$save_CFLAGS
12232    CC=$save_CC
12233    if test $use_ccache = yes -a "${CCACHE/*sccache*/}" != ""; then
12234        AC_MSG_RESULT([yes])
12235    else
12236        LO_CLANG_CC="$CCACHE $LO_CLANG_CC"
12237        AC_MSG_RESULT([no])
12238    fi
12239    AC_LANG_POP([C])
12240
12241    AC_MSG_CHECKING([whether $LO_CLANG_CXX is already ccached])
12242    AC_LANG_PUSH([C++])
12243    save_CXX="$CXX"
12244    CXX="$LO_CLANG_CXX"
12245    save_CXXFLAGS=$CXXFLAGS
12246    CXXFLAGS="$CXXFLAGS --ccache-skip -O2"
12247    dnl an empty program will do, we're checking the compiler flags
12248    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
12249                      [use_ccache=yes], [use_ccache=no])
12250    if test $use_ccache = yes -a "${CCACHE/*sccache*/}" != ""; then
12251        AC_MSG_RESULT([yes])
12252    else
12253        LO_CLANG_CXX="$CCACHE $LO_CLANG_CXX"
12254        AC_MSG_RESULT([no])
12255    fi
12256    CXXFLAGS=$save_CXXFLAGS
12257    CXX=$save_CXX
12258    AC_LANG_POP([C++])
12259fi
12260
12261AC_SUBST(UNCACHED_CC)
12262AC_SUBST(UNCACHED_CXX)
12263AC_SUBST(LO_CLANG_CC)
12264AC_SUBST(LO_CLANG_CXX)
12265AC_SUBST(UNCACHED_CLANG_CC)
12266AC_SUBST(UNCACHED_CLANG_CXX)
12267AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_SSE2)
12268AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_SSSE3)
12269AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_SSE41)
12270AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_SSE42)
12271AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_AVX)
12272AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_AVX2)
12273AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_AVX512)
12274AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_F16C)
12275AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_FMA)
12276AC_SUBST(CLANG_USE_LD)
12277AC_SUBST([HAVE_LO_CLANG_DLLEXPORTINLINES])
12278
12279SYSTEM_GPGMEPP=
12280
12281if test "$enable_gpgmepp" = no; then
12282    AC_MSG_CHECKING([whether to enable gpgmepp])
12283    AC_MSG_RESULT([no])
12284elif test "$enable_mpl_subset" = "yes"; then
12285    AC_MSG_CHECKING([whether gpgmepp should be disabled due to building just MPL])
12286    AC_MSG_RESULT([yes])
12287elif test "$enable_fuzzers" = "yes"; then
12288    AC_MSG_CHECKING([whether gpgmepp should be disabled due to oss-fuzz])
12289    AC_MSG_RESULT([yes])
12290elif test "$_os" = "Linux" -o "$_os" = "Darwin" -o "$_os" = "WINNT" ; then
12291    dnl ===================================================================
12292    dnl Check for system gpgme
12293    dnl ===================================================================
12294    AC_MSG_CHECKING([which gpgmepp to use])
12295    if test "$with_system_gpgmepp" = "yes"; then
12296        AC_MSG_RESULT([external])
12297        SYSTEM_GPGMEPP=TRUE
12298
12299        # C++ library doesn't come with fancy gpgmepp-config, check for headers the old-fashioned way
12300        AC_CHECK_HEADER(gpgme++/gpgmepp_version.h, [ GPGMEPP_CFLAGS=-I/usr/include/gpgme++ ],
12301            [AC_MSG_ERROR([gpgmepp headers not found, install gpgmepp development package])], [])
12302        # progress_callback is the only func with plain C linkage
12303        # checking for it also filters out older, KDE-dependent libgpgmepp versions
12304        AC_CHECK_LIB(gpgmepp, progress_callback, [ GPGMEPP_LIBS=-lgpgmepp ],
12305            [AC_MSG_ERROR(gpgmepp not found or not functional)], [])
12306        AC_CHECK_HEADER(gpgme.h, [],
12307            [AC_MSG_ERROR([gpgme headers not found, install gpgme development package])], [])
12308    else
12309        AC_MSG_RESULT([internal])
12310        BUILD_TYPE="$BUILD_TYPE LIBGPGERROR LIBASSUAN GPGMEPP"
12311        AC_DEFINE([GPGME_CAN_EXPORT_MINIMAL_KEY])
12312
12313        GPG_ERROR_CFLAGS="-I${WORKDIR}/UnpackedTarball/libgpg-error/src"
12314        LIBASSUAN_CFLAGS="-I${WORKDIR}/UnpackedTarball/libassuan/src"
12315        if test "$_os" != "WINNT"; then
12316            GPG_ERROR_LIBS="-L${WORKDIR}/UnpackedTarball/libgpg-error/src/.libs -lgpg-error"
12317            LIBASSUAN_LIBS="-L${WORKDIR}/UnpackedTarball/libassuan/src/.libs -lassuan"
12318        fi
12319    fi
12320    ENABLE_GPGMEPP=TRUE
12321    AC_DEFINE([HAVE_FEATURE_GPGME])
12322    AC_PATH_PROG(GPG, gpg)
12323    # TODO: Windows's cygwin gpg does not seem to work with our gpgme,
12324    # so let's exclude that manually for the moment
12325    if test -n "$GPG" -a "$_os" != "WINNT"; then
12326        # make sure we not only have a working gpgme, but a full working
12327        # gpg installation to run OpenPGP signature verification
12328        AC_DEFINE([HAVE_FEATURE_GPGVERIFY])
12329    fi
12330    if test "$_os" = "Linux"; then
12331      uid=`id -u`
12332      AC_MSG_CHECKING([for /run/user/$uid])
12333      if test -d /run/user/$uid; then
12334        AC_MSG_RESULT([yes])
12335        AC_PATH_PROG(GPGCONF, gpgconf)
12336
12337        # Older versions of gpgconf are not working as expected, since
12338        # `gpgconf --remove-socketdir` fails to exit any gpg-agent daemon operating
12339        # on that socket dir that has (indirectly) been started by the tests in xmlsecurity/qa/unit/signing/signing.cxx
12340        # (see commit message of f0305ec0a7d199e605511844d9d6af98b66d4bfd%5E )
12341        AC_MSG_CHECKING([whether version of gpgconf is suitable ... ])
12342        GPGCONF_VERSION=`"$GPGCONF" --version | "$AWK" '/^gpgconf \(GnuPG\)/{print $3}'`
12343        GPGCONF_NUMVER=`echo $GPGCONF_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
12344        if test "$GPGCONF_VERSION" = "2.2_OOo" -o "$GPGCONF_NUMVER" -ge "020200"; then
12345          AC_MSG_RESULT([yes, $GPGCONF_VERSION])
12346          AC_MSG_CHECKING([for gpgconf --create-socketdir... ])
12347          if $GPGCONF --dump-options > /dev/null ; then
12348            if $GPGCONF --dump-options | grep -q create-socketdir ; then
12349              AC_MSG_RESULT([yes])
12350              AC_DEFINE([HAVE_GPGCONF_SOCKETDIR])
12351              AC_DEFINE_UNQUOTED([GPGME_GPGCONF], ["$GPGCONF"])
12352            else
12353              AC_MSG_RESULT([no])
12354            fi
12355          else
12356            AC_MSG_RESULT([no. missing or broken gpgconf?])
12357          fi
12358        else
12359          AC_MSG_RESULT([no, $GPGCONF_VERSION])
12360        fi
12361      else
12362        AC_MSG_RESULT([no])
12363     fi
12364   fi
12365fi
12366AC_SUBST(ENABLE_GPGMEPP)
12367AC_SUBST(SYSTEM_GPGMEPP)
12368AC_SUBST(GPG_ERROR_CFLAGS)
12369AC_SUBST(GPG_ERROR_LIBS)
12370AC_SUBST(LIBASSUAN_CFLAGS)
12371AC_SUBST(LIBASSUAN_LIBS)
12372AC_SUBST(GPGMEPP_CFLAGS)
12373AC_SUBST(GPGMEPP_LIBS)
12374
12375AC_MSG_CHECKING([whether to build the Wiki Publisher extension])
12376if test "x$enable_ext_wiki_publisher" = "xyes" -a "x$enable_extension_integration" != "xno" -a "$with_java" != "no"; then
12377    AC_MSG_RESULT([yes])
12378    ENABLE_MEDIAWIKI=TRUE
12379    BUILD_TYPE="$BUILD_TYPE XSLTML"
12380    if test  "x$with_java" = "xno"; then
12381        AC_MSG_ERROR([Wiki Publisher requires Java! Enable Java if you want to build it.])
12382    fi
12383else
12384    AC_MSG_RESULT([no])
12385    ENABLE_MEDIAWIKI=
12386    SCPDEFS="$SCPDEFS -DWITHOUT_EXTENSION_MEDIAWIKI"
12387fi
12388AC_SUBST(ENABLE_MEDIAWIKI)
12389
12390AC_MSG_CHECKING([whether to build the Report Builder])
12391if test "$enable_report_builder" != "no" -a "$with_java" != "no"; then
12392    AC_MSG_RESULT([yes])
12393    ENABLE_REPORTBUILDER=TRUE
12394    AC_MSG_CHECKING([which jfreereport libs to use])
12395    if test "$with_system_jfreereport" = "yes"; then
12396        SYSTEM_JFREEREPORT=TRUE
12397        AC_MSG_RESULT([external])
12398        if test -z $SAC_JAR; then
12399            SAC_JAR=/usr/share/java/sac.jar
12400        fi
12401        if ! test -f $SAC_JAR; then
12402             AC_MSG_ERROR(sac.jar not found.)
12403        fi
12404
12405        if test -z $LIBXML_JAR; then
12406            if test -f /usr/share/java/libxml-1.0.0.jar; then
12407                LIBXML_JAR=/usr/share/java/libxml-1.0.0.jar
12408            elif test -f /usr/share/java/libxml.jar; then
12409                LIBXML_JAR=/usr/share/java/libxml.jar
12410            else
12411                AC_MSG_ERROR(libxml.jar replacement not found.)
12412            fi
12413        elif ! test -f $LIBXML_JAR; then
12414            AC_MSG_ERROR(libxml.jar not found.)
12415        fi
12416
12417        if test -z $FLUTE_JAR; then
12418            if test -f /usr/share/java/flute-1.3.0.jar; then
12419                FLUTE_JAR=/usr/share/java/flute-1.3.0.jar
12420            elif test -f /usr/share/java/flute.jar; then
12421                FLUTE_JAR=/usr/share/java/flute.jar
12422            else
12423                AC_MSG_ERROR(flute-1.3.0.jar replacement not found.)
12424            fi
12425        elif ! test -f $FLUTE_JAR; then
12426            AC_MSG_ERROR(flute-1.3.0.jar not found.)
12427        fi
12428
12429        if test -z $JFREEREPORT_JAR; then
12430            if test -f /usr/share/java/flow-engine-0.9.2.jar; then
12431                JFREEREPORT_JAR=/usr/share/java/flow-engine-0.9.2.jar
12432            elif test -f /usr/share/java/flow-engine.jar; then
12433                JFREEREPORT_JAR=/usr/share/java/flow-engine.jar
12434            else
12435                AC_MSG_ERROR(jfreereport.jar replacement not found.)
12436            fi
12437        elif ! test -f  $JFREEREPORT_JAR; then
12438                AC_MSG_ERROR(jfreereport.jar not found.)
12439        fi
12440
12441        if test -z $LIBLAYOUT_JAR; then
12442            if test -f /usr/share/java/liblayout-0.2.9.jar; then
12443                LIBLAYOUT_JAR=/usr/share/java/liblayout-0.2.9.jar
12444            elif test -f /usr/share/java/liblayout.jar; then
12445                LIBLAYOUT_JAR=/usr/share/java/liblayout.jar
12446            else
12447                AC_MSG_ERROR(liblayout.jar replacement not found.)
12448            fi
12449        elif ! test -f $LIBLAYOUT_JAR; then
12450                AC_MSG_ERROR(liblayout.jar not found.)
12451        fi
12452
12453        if test -z $LIBLOADER_JAR; then
12454            if test -f /usr/share/java/libloader-1.0.0.jar; then
12455                LIBLOADER_JAR=/usr/share/java/libloader-1.0.0.jar
12456            elif test -f /usr/share/java/libloader.jar; then
12457                LIBLOADER_JAR=/usr/share/java/libloader.jar
12458            else
12459                AC_MSG_ERROR(libloader.jar replacement not found.)
12460            fi
12461        elif ! test -f  $LIBLOADER_JAR; then
12462            AC_MSG_ERROR(libloader.jar not found.)
12463        fi
12464
12465        if test -z $LIBFORMULA_JAR; then
12466            if test -f /usr/share/java/libformula-0.2.0.jar; then
12467                LIBFORMULA_JAR=/usr/share/java/libformula-0.2.0.jar
12468            elif test -f /usr/share/java/libformula.jar; then
12469                LIBFORMULA_JAR=/usr/share/java/libformula.jar
12470            else
12471                AC_MSG_ERROR(libformula.jar replacement not found.)
12472            fi
12473        elif ! test -f $LIBFORMULA_JAR; then
12474                AC_MSG_ERROR(libformula.jar not found.)
12475        fi
12476
12477        if test -z $LIBREPOSITORY_JAR; then
12478            if test -f /usr/share/java/librepository-1.0.0.jar; then
12479                LIBREPOSITORY_JAR=/usr/share/java/librepository-1.0.0.jar
12480            elif test -f /usr/share/java/librepository.jar; then
12481                LIBREPOSITORY_JAR=/usr/share/java/librepository.jar
12482            else
12483                AC_MSG_ERROR(librepository.jar replacement not found.)
12484            fi
12485        elif ! test -f $LIBREPOSITORY_JAR; then
12486            AC_MSG_ERROR(librepository.jar not found.)
12487        fi
12488
12489        if test -z $LIBFONTS_JAR; then
12490            if test -f /usr/share/java/libfonts-1.0.0.jar; then
12491                LIBFONTS_JAR=/usr/share/java/libfonts-1.0.0.jar
12492            elif test -f /usr/share/java/libfonts.jar; then
12493                LIBFONTS_JAR=/usr/share/java/libfonts.jar
12494            else
12495                AC_MSG_ERROR(libfonts.jar replacement not found.)
12496            fi
12497        elif ! test -f $LIBFONTS_JAR; then
12498                AC_MSG_ERROR(libfonts.jar not found.)
12499        fi
12500
12501        if test -z $LIBSERIALIZER_JAR; then
12502            if test -f /usr/share/java/libserializer-1.0.0.jar; then
12503                LIBSERIALIZER_JAR=/usr/share/java/libserializer-1.0.0.jar
12504            elif test -f /usr/share/java/libserializer.jar; then
12505                LIBSERIALIZER_JAR=/usr/share/java/libserializer.jar
12506            else
12507                AC_MSG_ERROR(libserializer.jar replacement not found.)
12508            fi
12509        elif ! test -f $LIBSERIALIZER_JAR; then
12510                AC_MSG_ERROR(libserializer.jar not found.)
12511        fi
12512
12513        if test -z $LIBBASE_JAR; then
12514            if test -f /usr/share/java/libbase-1.0.0.jar; then
12515                LIBBASE_JAR=/usr/share/java/libbase-1.0.0.jar
12516            elif test -f /usr/share/java/libbase.jar; then
12517                LIBBASE_JAR=/usr/share/java/libbase.jar
12518            else
12519                AC_MSG_ERROR(libbase.jar replacement not found.)
12520            fi
12521        elif ! test -f $LIBBASE_JAR; then
12522            AC_MSG_ERROR(libbase.jar not found.)
12523        fi
12524
12525    else
12526        AC_MSG_RESULT([internal])
12527        SYSTEM_JFREEREPORT=
12528        BUILD_TYPE="$BUILD_TYPE JFREEREPORT"
12529        NEED_ANT=TRUE
12530    fi
12531else
12532    AC_MSG_RESULT([no])
12533    ENABLE_REPORTBUILDER=
12534    SYSTEM_JFREEREPORT=
12535fi
12536AC_SUBST(ENABLE_REPORTBUILDER)
12537AC_SUBST(SYSTEM_JFREEREPORT)
12538AC_SUBST(SAC_JAR)
12539AC_SUBST(LIBXML_JAR)
12540AC_SUBST(FLUTE_JAR)
12541AC_SUBST(JFREEREPORT_JAR)
12542AC_SUBST(LIBBASE_JAR)
12543AC_SUBST(LIBLAYOUT_JAR)
12544AC_SUBST(LIBLOADER_JAR)
12545AC_SUBST(LIBFORMULA_JAR)
12546AC_SUBST(LIBREPOSITORY_JAR)
12547AC_SUBST(LIBFONTS_JAR)
12548AC_SUBST(LIBSERIALIZER_JAR)
12549
12550# scripting provider for BeanShell?
12551AC_MSG_CHECKING([whether to build support for scripts in BeanShell])
12552if test "${enable_scripting_beanshell}" != "no" -a "x$with_java" != "xno"; then
12553    AC_MSG_RESULT([yes])
12554    ENABLE_SCRIPTING_BEANSHELL=TRUE
12555
12556    dnl ===================================================================
12557    dnl Check for system beanshell
12558    dnl ===================================================================
12559    AC_MSG_CHECKING([which beanshell to use])
12560    if test "$with_system_beanshell" = "yes"; then
12561        AC_MSG_RESULT([external])
12562        SYSTEM_BSH=TRUE
12563        if test -z $BSH_JAR; then
12564            BSH_JAR=/usr/share/java/bsh.jar
12565        fi
12566        if ! test -f $BSH_JAR; then
12567            AC_MSG_ERROR(bsh.jar not found.)
12568        fi
12569    else
12570        AC_MSG_RESULT([internal])
12571        SYSTEM_BSH=
12572        BUILD_TYPE="$BUILD_TYPE BSH"
12573    fi
12574else
12575    AC_MSG_RESULT([no])
12576    ENABLE_SCRIPTING_BEANSHELL=
12577    SCPDEFS="$SCPDEFS -DWITHOUT_SCRIPTING_BEANSHELL"
12578fi
12579AC_SUBST(ENABLE_SCRIPTING_BEANSHELL)
12580AC_SUBST(SYSTEM_BSH)
12581AC_SUBST(BSH_JAR)
12582
12583# scripting provider for JavaScript?
12584AC_MSG_CHECKING([whether to build support for scripts in JavaScript])
12585if test "${enable_scripting_javascript}" != "no" -a "x$with_java" != "xno"; then
12586    AC_MSG_RESULT([yes])
12587    ENABLE_SCRIPTING_JAVASCRIPT=TRUE
12588
12589    dnl ===================================================================
12590    dnl Check for system rhino
12591    dnl ===================================================================
12592    AC_MSG_CHECKING([which rhino to use])
12593    if test "$with_system_rhino" = "yes"; then
12594        AC_MSG_RESULT([external])
12595        SYSTEM_RHINO=TRUE
12596        if test -z $RHINO_JAR; then
12597            RHINO_JAR=/usr/share/java/js.jar
12598        fi
12599        if ! test -f $RHINO_JAR; then
12600            AC_MSG_ERROR(js.jar not found.)
12601        fi
12602    else
12603        AC_MSG_RESULT([internal])
12604        SYSTEM_RHINO=
12605        BUILD_TYPE="$BUILD_TYPE RHINO"
12606        NEED_ANT=TRUE
12607    fi
12608else
12609    AC_MSG_RESULT([no])
12610    ENABLE_SCRIPTING_JAVASCRIPT=
12611    SCPDEFS="$SCPDEFS -DWITHOUT_SCRIPTING_JAVASCRIPT"
12612fi
12613AC_SUBST(ENABLE_SCRIPTING_JAVASCRIPT)
12614AC_SUBST(SYSTEM_RHINO)
12615AC_SUBST(RHINO_JAR)
12616
12617# This is only used in Qt5/KF5 checks to determine if /usr/lib64
12618# paths should be added to library search path. So lets put all 64-bit
12619# platforms there.
12620supports_multilib=
12621case "$host_cpu" in
12622x86_64 | powerpc64 | powerpc64le | s390x | aarch64 | mips64 | mips64el)
12623    if test "$SAL_TYPES_SIZEOFLONG" = "8"; then
12624        supports_multilib="yes"
12625    fi
12626    ;;
12627*)
12628    ;;
12629esac
12630
12631dnl ===================================================================
12632dnl QT5 Integration
12633dnl ===================================================================
12634
12635QT5_CFLAGS=""
12636QT5_LIBS=""
12637QMAKE5="qmake"
12638MOC5="moc"
12639QT5_GOBJECT_CFLAGS=""
12640QT5_GOBJECT_LIBS=""
12641QT5_HAVE_GOBJECT=""
12642QT5_PLATFORMS_SRCDIR=""
12643if test \( "$test_kf5" = "yes" -a "$ENABLE_KF5" = "TRUE" \) -o \
12644        \( "$test_qt5" = "yes" -a "$ENABLE_QT5" = "TRUE" \) -o \
12645        \( "$test_gtk3_kde5" = "yes" -a "$ENABLE_GTK3_KDE5" = "TRUE" \)
12646then
12647    qt5_incdirs="$QT5INC /usr/include/qt5 /usr/include $x_includes"
12648    qt5_libdirs="$QT5LIB /usr/lib/qt5 /usr/lib $x_libraries"
12649
12650    if test -n "$supports_multilib"; then
12651        qt5_libdirs="$qt5_libdirs /usr/lib64/qt5 /usr/lib64/qt /usr/lib64"
12652    fi
12653
12654    qt5_test_include="QtWidgets/qapplication.h"
12655    if test "$_os" = "Emscripten"; then
12656        qt5_test_library="libQt5Widgets.a"
12657    else
12658        qt5_test_library="libQt5Widgets.so"
12659    fi
12660
12661    dnl Check for qmake5
12662    if test -n "$QT5DIR"; then
12663        AC_PATH_PROG(QMAKE5, [qmake], no, [$QT5DIR/bin])
12664    else
12665        AC_PATH_PROGS(QMAKE5, [qmake-qt5 qmake], no)
12666    fi
12667    if test "$QMAKE5" = "no"; then
12668        AC_MSG_ERROR([Qmake not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
12669    else
12670        qmake5_test_ver="`$QMAKE5 -v 2>&1 | $SED -n -e 's/^Using Qt version \(5\.[[0-9.]]\+\).*$/\1/p'`"
12671        if test -z "$qmake5_test_ver"; then
12672            AC_MSG_ERROR([Wrong qmake for Qt5 found. Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
12673        fi
12674        qmake5_minor_version="`echo $qmake5_test_ver | cut -d. -f2`"
12675        qt5_minimal_minor="6"
12676        if test "$qmake5_minor_version" -lt "$qt5_minimal_minor"; then
12677            AC_MSG_ERROR([The minimal supported Qt5 version is 5.${qt5_minimal_minor}, but your 'qmake -v' reports Qt5 version $qmake5_test_ver.])
12678        else
12679            AC_MSG_NOTICE([Detected Qt5 version: $qmake5_test_ver])
12680        fi
12681    fi
12682
12683    qt5_incdirs="`$QMAKE5 -query QT_INSTALL_HEADERS` $qt5_incdirs"
12684    qt5_libdirs="`$QMAKE5 -query QT_INSTALL_LIBS` $qt5_libdirs"
12685    qt5_platformsdir="`$QMAKE5 -query QT_INSTALL_PLUGINS`/platforms"
12686    QT5_PLATFORMS_SRCDIR="$qt5_platformsdir"
12687
12688    AC_MSG_CHECKING([for Qt5 headers])
12689    qt5_incdir="no"
12690    for inc_dir in $qt5_incdirs; do
12691        if test -r "$inc_dir/$qt5_test_include"; then
12692            qt5_incdir="$inc_dir"
12693            break
12694        fi
12695    done
12696    AC_MSG_RESULT([$qt5_incdir])
12697    if test "x$qt5_incdir" = "xno"; then
12698        AC_MSG_ERROR([Qt5 headers not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
12699    fi
12700    # check for scenario: qt5-qtbase-devel-*.86_64 installed but host is i686
12701    AC_LANG_PUSH([C++])
12702    save_CPPFLAGS=$CPPFLAGS
12703    CPPFLAGS="${CPPFLAGS} -I${qt5_incdir}"
12704    AC_CHECK_HEADER(QtCore/qconfig.h, [],
12705        [AC_MSG_ERROR(qconfig.h header not found.)], [])
12706    CPPFLAGS=$save_CPPFLAGS
12707    AC_LANG_POP([C++])
12708
12709    AC_MSG_CHECKING([for Qt5 libraries])
12710    qt5_libdir="no"
12711    for lib_dir in $qt5_libdirs; do
12712        if test -r "$lib_dir/$qt5_test_library"; then
12713            qt5_libdir="$lib_dir"
12714            break
12715        fi
12716    done
12717    AC_MSG_RESULT([$qt5_libdir])
12718    if test "x$qt5_libdir" = "xno"; then
12719        AC_MSG_ERROR([Qt5 libraries not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
12720    fi
12721
12722    if test "$_os" = "Emscripten"; then
12723        if test ! -f "$QT5_PLATFORMS_SRCDIR"/wasm_shell.html ; then
12724            QT5_PLATFORMS_SRCDIR="${QT5_PLATFORMS_SRCDIR/plugins/src\/plugins}/wasm"
12725        fi
12726        if test ! -f "${qt5_platformsdir}"/libqwasm.a -o ! -f "$QT5_PLATFORMS_SRCDIR"/wasm_shell.html; then
12727            AC_MSG_ERROR([No Qt5 WASM QPA plugin found in ${qt5_platformsdir} or ${QT5_PLATFORMS_SRCDIR}])
12728        fi
12729    fi
12730
12731    QT5_CFLAGS="-I$qt5_incdir -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT -DQT_NO_VERSION_TAGGING"
12732    QT5_CFLAGS=$(printf '%s' "$QT5_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12733    QT5_LIBS="-L$qt5_libdir -lQt5Core -lQt5Gui -lQt5Widgets -lQt5Network"
12734    if test "$_os" = "Emscripten"; then
12735        QT5_LIBS="$QT5_LIBS -lqtpcre2 -lQt5EventDispatcherSupport -lQt5FontDatabaseSupport -L${qt5_platformsdir} -lqwasm"
12736    fi
12737
12738    if test "$USING_X11" = TRUE; then
12739        PKG_CHECK_MODULES(QT5_XCB,[xcb],,[AC_MSG_ERROR([XCB not found, which is needed for correct app grouping in X11.])])
12740        PKG_CHECK_MODULES(QT5_XCB_ICCCM,[xcb-icccm],[
12741            QT5_HAVE_XCB_ICCCM=1
12742            AC_DEFINE(QT5_HAVE_XCB_ICCCM)
12743        ],[
12744            AC_MSG_WARN([XCB ICCCM not found, which is needed for old Qt versions (< 5.12) on some WMs to correctly group dialogs (like QTBUG-46626)])
12745            add_warning "XCB ICCCM not found, which is needed for Qt versions (< 5.12) on some WMs to correctly group dialogs (like QTBUG-46626)"
12746        ])
12747        QT5_CFLAGS="$QT5_CFLAGS $QT5_XCB_CFLAGS $QT5_XCB_ICCCM_CFLAGS"
12748        QT5_LIBS="$QT5_LIBS $QT5_XCB_LIBS $QT5_XCB_ICCCM_LIBS -lQt5X11Extras"
12749        QT5_USING_X11=1
12750        AC_DEFINE(QT5_USING_X11)
12751    fi
12752
12753    dnl Check for Meta Object Compiler
12754
12755    AC_PATH_PROGS( MOC5, [moc-qt5 moc], no, [`dirname $qt5_libdir`/bin:$QT5DIR/bin:$PATH])
12756    if test "$MOC5" = "no"; then
12757        AC_MSG_ERROR([Qt Meta Object Compiler not found.  Please specify
12758the root of your Qt installation by exporting QT5DIR before running "configure".])
12759    fi
12760
12761    if test "$test_gstreamer_1_0" = yes; then
12762        PKG_CHECK_MODULES(QT5_GOBJECT,[gobject-2.0], [
12763                QT5_HAVE_GOBJECT=1
12764                AC_DEFINE(QT5_HAVE_GOBJECT)
12765            ],
12766            AC_MSG_WARN([[No GObject found, can't use QWidget GStreamer sink on wayland!]])
12767        )
12768    fi
12769fi
12770AC_SUBST(QT5_CFLAGS)
12771AC_SUBST(QT5_LIBS)
12772AC_SUBST(MOC5)
12773AC_SUBST(QT5_GOBJECT_CFLAGS)
12774AC_SUBST(QT5_GOBJECT_LIBS)
12775AC_SUBST(QT5_HAVE_GOBJECT)
12776AC_SUBST(QT5_PLATFORMS_SRCDIR)
12777
12778dnl ===================================================================
12779dnl KF5 Integration
12780dnl ===================================================================
12781
12782KF5_CFLAGS=""
12783KF5_LIBS=""
12784KF5_CONFIG="kf5-config"
12785if test \( "$test_kf5" = "yes" -a "$ENABLE_KF5" = "TRUE" \) -o \
12786        \( "$test_gtk3_kde5" = "yes" -a "$ENABLE_GTK3_KDE5" = "TRUE" \)
12787then
12788    if test "$OS" = "HAIKU"; then
12789        haiku_arch="`echo $RTL_ARCH | tr X x`"
12790        kf5_haiku_incdirs="`findpaths -c ' ' -a $haiku_arch B_FIND_PATH_HEADERS_DIRECTORY`"
12791        kf5_haiku_libdirs="`findpaths -c ' ' -a $haiku_arch B_FIND_PATH_DEVELOP_LIB_DIRECTORY`"
12792    fi
12793
12794    kf5_incdirs="$KF5INC /usr/include $kf5_haiku_incdirs $x_includes"
12795    kf5_libdirs="$KF5LIB /usr/lib /usr/lib/kf5 /usr/lib/kf5/devel $kf5_haiku_libdirs $x_libraries"
12796    if test -n "$supports_multilib"; then
12797        kf5_libdirs="$kf5_libdirs /usr/lib64 /usr/lib64/kf5 /usr/lib64/kf5/devel"
12798    fi
12799
12800    kf5_test_include="KF5/KIOFileWidgets/KFileWidget"
12801    kf5_test_library="libKF5KIOFileWidgets.so"
12802    kf5_libdirs="$qt5_libdir $kf5_libdirs"
12803
12804    dnl kf5 KDE4 support compatibility installed
12805    AC_PATH_PROG( KF5_CONFIG, $KF5_CONFIG, no, )
12806    if test "$KF5_CONFIG" != "no"; then
12807        kf5_incdirs="`$KF5_CONFIG --path include` $kf5_incdirs"
12808        kf5_libdirs="`$KF5_CONFIG --path lib` $kf5_libdirs"
12809    fi
12810
12811    dnl Check for KF5 headers
12812    AC_MSG_CHECKING([for KF5 headers])
12813    kf5_incdir="no"
12814    for kf5_check in $kf5_incdirs; do
12815        if test -r "$kf5_check/$kf5_test_include"; then
12816            kf5_incdir="$kf5_check/KF5"
12817            break
12818        fi
12819    done
12820    AC_MSG_RESULT([$kf5_incdir])
12821    if test "x$kf5_incdir" = "xno"; then
12822        AC_MSG_ERROR([KF5 headers not found.  Please specify the root of your KF5 installation by exporting KF5DIR before running "configure".])
12823    fi
12824
12825    dnl Check for KF5 libraries
12826    AC_MSG_CHECKING([for KF5 libraries])
12827    kf5_libdir="no"
12828    for kf5_check in $kf5_libdirs; do
12829        if test -r "$kf5_check/$kf5_test_library"; then
12830            kf5_libdir="$kf5_check"
12831            break
12832        fi
12833    done
12834
12835    AC_MSG_RESULT([$kf5_libdir])
12836    if test "x$kf5_libdir" = "xno"; then
12837        AC_MSG_ERROR([KF5 libraries not found.  Please specify the root of your KF5 installation by exporting KF5DIR before running "configure".])
12838    fi
12839
12840    KF5_CFLAGS="-I$kf5_incdir -I$kf5_incdir/KCoreAddons -I$kf5_incdir/KI18n -I$kf5_incdir/KConfigCore -I$kf5_incdir/KWindowSystem -I$kf5_incdir/KIOCore -I$kf5_incdir/KIOWidgets -I$kf5_incdir/KIOFileWidgets -I$qt5_incdir -I$qt5_incdir/QtCore -I$qt5_incdir/QtGui -I$qt5_incdir/QtWidgets -I$qt5_incdir/QtNetwork -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT -DQT_NO_VERSION_TAGGING"
12841    KF5_LIBS="-L$kf5_libdir -lKF5CoreAddons -lKF5I18n -lKF5ConfigCore -lKF5WindowSystem -lKF5KIOCore -lKF5KIOWidgets -lKF5KIOFileWidgets -L$qt5_libdir -lQt5Core -lQt5Gui -lQt5Widgets -lQt5Network"
12842    KF5_CFLAGS=$(printf '%s' "$KF5_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12843
12844    if test "$USING_X11" = TRUE; then
12845        KF5_LIBS="$KF5_LIBS -lQt5X11Extras"
12846    fi
12847
12848    AC_LANG_PUSH([C++])
12849    save_CXXFLAGS=$CXXFLAGS
12850    CXXFLAGS="$CXXFLAGS $KF5_CFLAGS"
12851    AC_MSG_CHECKING([whether KDE is >= 5.0])
12852       AC_RUN_IFELSE([AC_LANG_SOURCE([[
12853#include <kcoreaddons_version.h>
12854
12855int main(int argc, char **argv) {
12856       if (KCOREADDONS_VERSION_MAJOR == 5 && KCOREADDONS_VERSION_MINOR >= 0) return 0;
12857       else return 1;
12858}
12859       ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([KDE version too old])],[])
12860    CXXFLAGS=$save_CXXFLAGS
12861    AC_LANG_POP([C++])
12862fi
12863AC_SUBST(KF5_CFLAGS)
12864AC_SUBST(KF5_LIBS)
12865
12866dnl ===================================================================
12867dnl Test whether to include Evolution 2 support
12868dnl ===================================================================
12869AC_MSG_CHECKING([whether to enable evolution 2 support])
12870if test "$enable_evolution2" = yes; then
12871    AC_MSG_RESULT([yes])
12872    PKG_CHECK_MODULES(GOBJECT, gobject-2.0)
12873    GOBJECT_CFLAGS=$(printf '%s' "$GOBJECT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12874    FilterLibs "${GOBJECT_LIBS}"
12875    GOBJECT_LIBS="${filteredlibs}"
12876    ENABLE_EVOAB2="TRUE"
12877else
12878    AC_MSG_RESULT([no])
12879fi
12880AC_SUBST(ENABLE_EVOAB2)
12881AC_SUBST(GOBJECT_CFLAGS)
12882AC_SUBST(GOBJECT_LIBS)
12883
12884dnl ===================================================================
12885dnl Test which themes to include
12886dnl ===================================================================
12887AC_MSG_CHECKING([which themes to include])
12888# if none given use default subset of available themes
12889if test "x$with_theme" = "x" -o "x$with_theme" = "xyes"; then
12890    with_theme="breeze breeze_dark breeze_dark_svg breeze_svg colibre colibre_svg elementary elementary_svg karasa_jaga karasa_jaga_svg sifr sifr_svg sifr_dark sifr_dark_svg sukapura sukapura_svg"
12891fi
12892
12893WITH_THEMES=""
12894if test "x$with_theme" != "xno"; then
12895    for theme in $with_theme; do
12896        case $theme in
12897        breeze|breeze_dark|breeze_dark_svg|breeze_svg|colibre|colibre_svg|elementary|elementary_svg|karasa_jaga|karasa_jaga_svg|sifr|sifr_svg|sifr_dark|sifr_dark_svg|sukapura|sukapura_svg) real_theme="$theme" ;;
12898        default) real_theme=colibre ;;
12899        *) AC_MSG_ERROR([Unknown value for --with-theme: $theme]) ;;
12900        esac
12901        WITH_THEMES=`echo "$WITH_THEMES $real_theme"|tr '\ ' '\n'|sort|uniq|tr '\n' '\ '`
12902    done
12903fi
12904AC_MSG_RESULT([$WITH_THEMES])
12905AC_SUBST([WITH_THEMES])
12906# FIXME: remove this, and the convenience default->colibre remapping after a grace period
12907for theme in $with_theme; do
12908    case $theme in
12909    default) AC_MSG_WARN([--with-theme=default is deprecated and will be removed, use --with-theme=colibre]) ;;
12910    *) ;;
12911    esac
12912done
12913
12914dnl ===================================================================
12915dnl Test whether to integrate helppacks into the product's installer
12916dnl ===================================================================
12917AC_MSG_CHECKING([for helppack integration])
12918if test "$with_helppack_integration" = "no"; then
12919    AC_MSG_RESULT([no integration])
12920else
12921    SCPDEFS="$SCPDEFS -DWITH_HELPPACK_INTEGRATION"
12922    AC_MSG_RESULT([integration])
12923fi
12924
12925###############################################################################
12926# Extensions checking
12927###############################################################################
12928AC_MSG_CHECKING([for extensions integration])
12929if test "x$enable_extension_integration" != "xno"; then
12930    WITH_EXTENSION_INTEGRATION=TRUE
12931    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_INTEGRATION"
12932    AC_MSG_RESULT([yes, use integration])
12933else
12934    WITH_EXTENSION_INTEGRATION=
12935    AC_MSG_RESULT([no, do not integrate])
12936fi
12937AC_SUBST(WITH_EXTENSION_INTEGRATION)
12938
12939dnl Should any extra extensions be included?
12940dnl There are standalone tests for each of these below.
12941WITH_EXTRA_EXTENSIONS=
12942AC_SUBST([WITH_EXTRA_EXTENSIONS])
12943
12944libo_CHECK_EXTENSION([ConvertTextToNumber],[CT2N],[ct2n],[ct2n],[])
12945libo_CHECK_EXTENSION([Numbertext],[NUMBERTEXT],[numbertext],[numbertext],[b7cae45ad2c23551fd6ccb8ae2c1f59e-numbertext_0.9.5.oxt])
12946if test "x$with_java" != "xno"; then
12947    libo_CHECK_EXTENSION([NLPSolver],[NLPSOLVER],[nlpsolver],[nlpsolver],[])
12948    libo_CHECK_EXTENSION([LanguageTool],[LANGUAGETOOL],[languagetool],[languagetool],[])
12949fi
12950
12951AC_MSG_CHECKING([whether to build opens___.ttf])
12952if test "$enable_build_opensymbol" = "yes"; then
12953    AC_MSG_RESULT([yes])
12954    AC_PATH_PROG(FONTFORGE, fontforge)
12955    if test -z "$FONTFORGE"; then
12956        AC_MSG_ERROR([fontforge not installed])
12957    fi
12958else
12959    AC_MSG_RESULT([no])
12960    OPENSYMBOL_TTF=f543e6e2d7275557a839a164941c0a86e5f2c3f2a0042bfc434c88c6dde9e140-opens___.ttf
12961    BUILD_TYPE="$BUILD_TYPE OPENSYMBOL"
12962fi
12963AC_SUBST(OPENSYMBOL_TTF)
12964AC_SUBST(FONTFORGE)
12965
12966dnl ===================================================================
12967dnl Test whether to include fonts
12968dnl ===================================================================
12969AC_MSG_CHECKING([whether to include third-party fonts])
12970if test "$with_fonts" != "no"; then
12971    AC_MSG_RESULT([yes])
12972    WITH_FONTS=TRUE
12973    BUILD_TYPE="$BUILD_TYPE MORE_FONTS"
12974    AC_DEFINE(HAVE_MORE_FONTS)
12975else
12976    AC_MSG_RESULT([no])
12977    WITH_FONTS=
12978    SCPDEFS="$SCPDEFS -DWITHOUT_FONTS"
12979fi
12980AC_SUBST(WITH_FONTS)
12981
12982
12983dnl ===================================================================
12984dnl Test whether to enable online update service
12985dnl ===================================================================
12986AC_MSG_CHECKING([whether to enable online update])
12987ENABLE_ONLINE_UPDATE=
12988ENABLE_ONLINE_UPDATE_MAR=
12989UPDATE_CONFIG=
12990if test "$enable_online_update" = ""; then
12991    if test "$_os" = "WINNT" -o "$_os" = "Darwin"; then
12992        AC_MSG_RESULT([yes])
12993        ENABLE_ONLINE_UPDATE="TRUE"
12994    else
12995        AC_MSG_RESULT([no])
12996    fi
12997else
12998    if test "$enable_online_update" = "mar"; then
12999        AC_MSG_RESULT([yes - MAR-based online update])
13000        ENABLE_ONLINE_UPDATE_MAR="TRUE"
13001        if test "$with_update_config" = ""; then
13002            AC_MSG_ERROR([mar based online updater needs an update config specified with "with-update-config])
13003        fi
13004        UPDATE_CONFIG="$with_update_config"
13005        AC_DEFINE(HAVE_FEATURE_UPDATE_MAR)
13006    elif test "$enable_online_update" = "yes"; then
13007        AC_MSG_RESULT([yes])
13008        ENABLE_ONLINE_UPDATE="TRUE"
13009    else
13010        AC_MSG_RESULT([no])
13011    fi
13012fi
13013AC_SUBST(ENABLE_ONLINE_UPDATE)
13014AC_SUBST(ENABLE_ONLINE_UPDATE_MAR)
13015AC_SUBST(UPDATE_CONFIG)
13016
13017
13018PRIVACY_POLICY_URL="$with_privacy_policy_url"
13019if test "$ENABLE_ONLINE_UPDATE" = TRUE -o "$ENABLE_BREAKPAD" = "TRUE"; then
13020    if test "x$with_privacy_policy_url" = "xundefined"; then
13021        AC_MSG_FAILURE([online update or breakpad/crashreporting are enabled, but no --with-privacy-policy-url=... was provided])
13022    fi
13023fi
13024AC_SUBST(PRIVACY_POLICY_URL)
13025dnl ===================================================================
13026dnl Test whether we need bzip2
13027dnl ===================================================================
13028SYSTEM_BZIP2=
13029if test "$ENABLE_ONLINE_UPDATE_MAR" = "TRUE"; then
13030    AC_MSG_CHECKING([whether to use system bzip2])
13031    if test "$with_system_bzip2" = yes; then
13032        SYSTEM_BZIP2=TRUE
13033        AC_MSG_RESULT([yes])
13034        PKG_CHECK_MODULES(BZIP2, bzip2)
13035        FilterLibs "${BZIP2_LIBS}"
13036        BZIP2_LIBS="${filteredlibs}"
13037    else
13038        AC_MSG_RESULT([no])
13039        BUILD_TYPE="$BUILD_TYPE BZIP2"
13040    fi
13041fi
13042AC_SUBST(SYSTEM_BZIP2)
13043AC_SUBST(BZIP2_CFLAGS)
13044AC_SUBST(BZIP2_LIBS)
13045
13046dnl ===================================================================
13047dnl Test whether to enable extension update
13048dnl ===================================================================
13049AC_MSG_CHECKING([whether to enable extension update])
13050ENABLE_EXTENSION_UPDATE=
13051if test "x$enable_extension_update" = "xno"; then
13052    AC_MSG_RESULT([no])
13053else
13054    AC_MSG_RESULT([yes])
13055    ENABLE_EXTENSION_UPDATE="TRUE"
13056    AC_DEFINE(ENABLE_EXTENSION_UPDATE)
13057    SCPDEFS="$SCPDEFS -DENABLE_EXTENSION_UPDATE"
13058fi
13059AC_SUBST(ENABLE_EXTENSION_UPDATE)
13060
13061
13062dnl ===================================================================
13063dnl Test whether to create MSI with LIMITUI=1 (silent install)
13064dnl ===================================================================
13065AC_MSG_CHECKING([whether to create MSI with LIMITUI=1 (silent install)])
13066if test "$enable_silent_msi" = "" -o "$enable_silent_msi" = "no"; then
13067    AC_MSG_RESULT([no])
13068    ENABLE_SILENT_MSI=
13069else
13070    AC_MSG_RESULT([yes])
13071    ENABLE_SILENT_MSI=TRUE
13072    SCPDEFS="$SCPDEFS -DENABLE_SILENT_MSI"
13073fi
13074AC_SUBST(ENABLE_SILENT_MSI)
13075
13076AC_MSG_CHECKING([whether and how to use Xinerama])
13077if test "$_os" = "Linux" -o "$_os" = "FreeBSD"; then
13078    if test "$x_libraries" = "default_x_libraries"; then
13079        XINERAMALIB=`$PKG_CONFIG --variable=libdir xinerama`
13080        if test "x$XINERAMALIB" = x; then
13081           XINERAMALIB="/usr/lib"
13082        fi
13083    else
13084        XINERAMALIB="$x_libraries"
13085    fi
13086    if test -e "$XINERAMALIB/libXinerama.so" -a -e "$XINERAMALIB/libXinerama.a"; then
13087        # we have both versions, let the user decide but use the dynamic one
13088        # per default
13089        USE_XINERAMA=TRUE
13090        if test -z "$with_static_xinerama" -o -n "$with_system_libs"; then
13091            XINERAMA_LINK=dynamic
13092        else
13093            XINERAMA_LINK=static
13094        fi
13095    elif test -e "$XINERAMALIB/libXinerama.so" -a ! -e "$XINERAMALIB/libXinerama.a"; then
13096        # we have only the dynamic version
13097        USE_XINERAMA=TRUE
13098        XINERAMA_LINK=dynamic
13099    elif test -e "$XINERAMALIB/libXinerama.a"; then
13100        # static version
13101        if echo $host_cpu | $GREP -E 'i[[3456]]86' 2>/dev/null >/dev/null; then
13102            USE_XINERAMA=TRUE
13103            XINERAMA_LINK=static
13104        else
13105            USE_XINERAMA=
13106            XINERAMA_LINK=none
13107        fi
13108    else
13109        # no Xinerama
13110        USE_XINERAMA=
13111        XINERAMA_LINK=none
13112    fi
13113    if test "$USE_XINERAMA" = "TRUE"; then
13114        AC_MSG_RESULT([yes, with $XINERAMA_LINK linking])
13115        AC_CHECK_HEADER(X11/extensions/Xinerama.h, [],
13116            [AC_MSG_ERROR(Xinerama header not found.)], [])
13117        XEXTLIBS=`$PKG_CONFIG --variable=libs xext`
13118        if test "x$XEXTLIB" = x; then
13119           XEXTLIBS="-L$XLIB -L$XINERAMALIB -lXext"
13120        fi
13121        XINERAMA_EXTRA_LIBS="$XEXTLIBS"
13122        if test "$_os" = "FreeBSD"; then
13123            XINERAMA_EXTRA_LIBS="$XINERAMA_EXTRA_LIBS -lXt"
13124        fi
13125        if test "$_os" = "Linux"; then
13126            XINERAMA_EXTRA_LIBS="$XINERAMA_EXTRA_LIBS -ldl"
13127        fi
13128        AC_CHECK_LIB([Xinerama], [XineramaIsActive], [:],
13129            [AC_MSG_ERROR(Xinerama not functional?)], [$XINERAMA_EXTRA_LIBS])
13130    else
13131        AC_MSG_RESULT([no, libXinerama not found or wrong architecture.])
13132    fi
13133else
13134    USE_XINERAMA=
13135    XINERAMA_LINK=none
13136    AC_MSG_RESULT([no])
13137fi
13138AC_SUBST(USE_XINERAMA)
13139AC_SUBST(XINERAMA_LINK)
13140
13141dnl ===================================================================
13142dnl Test whether to build cairo or rely on the system version
13143dnl ===================================================================
13144
13145if test "$test_cairo" = "yes"; then
13146    AC_MSG_CHECKING([whether to use the system cairo])
13147
13148    : ${with_system_cairo:=$with_system_libs}
13149    if test "$with_system_cairo" = "yes"; then
13150        SYSTEM_CAIRO=TRUE
13151        AC_MSG_RESULT([yes])
13152
13153        PKG_CHECK_MODULES( CAIRO, cairo >= 1.8.0 )
13154        CAIRO_CFLAGS=$(printf '%s' "$CAIRO_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
13155        FilterLibs "${CAIRO_LIBS}"
13156        CAIRO_LIBS="${filteredlibs}"
13157
13158        if test "$test_xrender" = "yes"; then
13159            AC_MSG_CHECKING([whether Xrender.h defines PictStandardA8])
13160            AC_LANG_PUSH([C])
13161            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <X11/extensions/Xrender.h>]],[[
13162#ifdef PictStandardA8
13163#else
13164      return fail;
13165#endif
13166]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no, X headers too old.])])
13167
13168            AC_LANG_POP([C])
13169        fi
13170    else
13171        AC_MSG_RESULT([no])
13172        BUILD_TYPE="$BUILD_TYPE CAIRO"
13173    fi
13174
13175    if test "$enable_cairo_canvas" != no; then
13176        AC_DEFINE(ENABLE_CAIRO_CANVAS)
13177        ENABLE_CAIRO_CANVAS=TRUE
13178    fi
13179fi
13180
13181AC_SUBST(CAIRO_CFLAGS)
13182AC_SUBST(CAIRO_LIBS)
13183AC_SUBST(ENABLE_CAIRO_CANVAS)
13184AC_SUBST(SYSTEM_CAIRO)
13185
13186dnl ===================================================================
13187dnl Test whether to use avahi
13188dnl ===================================================================
13189if test "$_os" = "WINNT"; then
13190    # Windows uses bundled mDNSResponder
13191    BUILD_TYPE="$BUILD_TYPE MDNSRESPONDER"
13192elif test "$_os" != "Darwin" -a "$enable_avahi" = "yes"; then
13193    PKG_CHECK_MODULES([AVAHI], [avahi-client >= 0.6.10],
13194                      [ENABLE_AVAHI="TRUE"])
13195    AC_DEFINE(HAVE_FEATURE_AVAHI)
13196    AVAHI_CFLAGS=$(printf '%s' "$AVAHI_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
13197    FilterLibs "${AVAHI_LIBS}"
13198    AVAHI_LIBS="${filteredlibs}"
13199fi
13200
13201AC_SUBST(ENABLE_AVAHI)
13202AC_SUBST(AVAHI_CFLAGS)
13203AC_SUBST(AVAHI_LIBS)
13204
13205dnl ===================================================================
13206dnl Test whether to use liblangtag
13207dnl ===================================================================
13208SYSTEM_LIBLANGTAG=
13209AC_MSG_CHECKING([whether to use system liblangtag])
13210if test "$with_system_liblangtag" = yes; then
13211    SYSTEM_LIBLANGTAG=TRUE
13212    AC_MSG_RESULT([yes])
13213    PKG_CHECK_MODULES( LIBLANGTAG, liblangtag >= 0.4.0)
13214    dnl cf. <https://bitbucket.org/tagoh/liblangtag/commits/9324836a0d1c> "Fix a build issue with inline keyword"
13215    PKG_CHECK_EXISTS([liblangtag >= 0.5.5], [], [AC_DEFINE([LIBLANGTAG_INLINE_FIX])])
13216    LIBLANGTAG_CFLAGS=$(printf '%s' "$LIBLANGTAG_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
13217    FilterLibs "${LIBLANGTAG_LIBS}"
13218    LIBLANGTAG_LIBS="${filteredlibs}"
13219else
13220    SYSTEM_LIBLANGTAG=
13221    AC_MSG_RESULT([no])
13222    BUILD_TYPE="$BUILD_TYPE LIBLANGTAG"
13223    LIBLANGTAG_CFLAGS="-I${WORKDIR}/UnpackedTarball/liblangtag"
13224    if test "$COM" = "MSC"; then
13225        LIBLANGTAG_LIBS="${WORKDIR}/UnpackedTarball/liblangtag/liblangtag/.libs/liblangtag.lib"
13226    else
13227        LIBLANGTAG_LIBS="-L${WORKDIR}/UnpackedTarball/liblangtag/liblangtag/.libs -llangtag"
13228    fi
13229fi
13230AC_SUBST(SYSTEM_LIBLANGTAG)
13231AC_SUBST(LIBLANGTAG_CFLAGS)
13232AC_SUBST(LIBLANGTAG_LIBS)
13233
13234dnl ===================================================================
13235dnl Test whether to build libpng or rely on the system version
13236dnl ===================================================================
13237
13238libo_CHECK_SYSTEM_MODULE([libpng],[LIBPNG],[libpng],["-I${WORKDIR}/UnpackedTarball/libpng"],["-L${WORKDIR}/LinkTarget/StaticLibrary -llibpng"])
13239
13240dnl ===================================================================
13241dnl Check for runtime JVM search path
13242dnl ===================================================================
13243if test "$ENABLE_JAVA" != ""; then
13244    AC_MSG_CHECKING([whether to use specific JVM search path at runtime])
13245    if test -n "$with_jvm_path" -a "$with_jvm_path" != "no"; then
13246        AC_MSG_RESULT([yes])
13247        if ! test -d "$with_jvm_path"; then
13248            AC_MSG_ERROR(["$with_jvm_path" not a directory])
13249        fi
13250        if ! test -d "$with_jvm_path"jvm; then
13251            AC_MSG_ERROR(["$with_jvm_path"jvm not found, point with_jvm_path to \[/path/to/\]jvm])
13252        fi
13253        JVM_ONE_PATH_CHECK="$with_jvm_path"
13254        AC_SUBST(JVM_ONE_PATH_CHECK)
13255    else
13256        AC_MSG_RESULT([no])
13257    fi
13258fi
13259
13260dnl ===================================================================
13261dnl Test for the presence of Ant and that it works
13262dnl ===================================================================
13263
13264if test "$ENABLE_JAVA" != "" -a "$NEED_ANT" = "TRUE" -a "$cross_compiling" != "yes"; then
13265    ANT_HOME=; export ANT_HOME
13266    WITH_ANT_HOME=; export WITH_ANT_HOME
13267    if test -z "$with_ant_home" -a -n "$LODE_HOME" ; then
13268        if test -x "$LODE_HOME/opt/ant/bin/ant" ; then
13269            if test "$_os" = "WINNT"; then
13270                with_ant_home="`cygpath -m $LODE_HOME/opt/ant`"
13271            else
13272                with_ant_home="$LODE_HOME/opt/ant"
13273            fi
13274        elif test -x  "$LODE_HOME/opt/bin/ant" ; then
13275            with_ant_home="$LODE_HOME/opt/ant"
13276        fi
13277    fi
13278    if test -z "$with_ant_home"; then
13279        AC_PATH_PROGS(ANT, [ant ant.sh ant.bat ant.cmd])
13280    else
13281        if test "$_os" = "WINNT"; then
13282            # AC_PATH_PROGS needs unix path
13283            with_ant_home=`cygpath -u "$with_ant_home"`
13284        fi
13285        AbsolutePath "$with_ant_home"
13286        with_ant_home=$absolute_path
13287        AC_PATH_PROGS(ANT, [ant ant.sh ant.bat ant.cmd],,$with_ant_home/bin:$PATH)
13288        WITH_ANT_HOME=$with_ant_home
13289        ANT_HOME=$with_ant_home
13290    fi
13291
13292    if test -z "$ANT"; then
13293        AC_MSG_ERROR([Ant not found - Make sure it's in the path or use --with-ant-home])
13294    else
13295        # resolve relative or absolute symlink
13296        while test -h "$ANT"; do
13297            a_cwd=`pwd`
13298            a_basename=`basename "$ANT"`
13299            a_script=`ls -l "$ANT" | $SED "s/.*${a_basename} -> //g"`
13300            cd "`dirname "$ANT"`"
13301            cd "`dirname "$a_script"`"
13302            ANT="`pwd`"/"`basename "$a_script"`"
13303            cd "$a_cwd"
13304        done
13305
13306        AC_MSG_CHECKING([if $ANT works])
13307        mkdir -p conftest.dir
13308        a_cwd=$(pwd)
13309        cd conftest.dir
13310        cat > conftest.java << EOF
13311        public class conftest {
13312            int testmethod(int a, int b) {
13313                    return a + b;
13314            }
13315        }
13316EOF
13317
13318        cat > conftest.xml << EOF
13319        <project name="conftest" default="conftest">
13320        <target name="conftest">
13321            <javac srcdir="." includes="conftest.java">
13322            </javac>
13323        </target>
13324        </project>
13325EOF
13326
13327        AC_TRY_COMMAND("$ANT" -buildfile conftest.xml 1>&2)
13328        if test $? = 0 -a -f ./conftest.class; then
13329            AC_MSG_RESULT([Ant works])
13330            if test -z "$WITH_ANT_HOME"; then
13331                ANT_HOME=`"$ANT" -diagnostics | $EGREP "ant.home :" | $SED -e "s#ant.home : ##g"`
13332                if test -z "$ANT_HOME"; then
13333                    ANT_HOME=`echo "$ANT" | $SED -n "s/\/bin\/ant.*\$//p"`
13334                fi
13335            else
13336                ANT_HOME="$WITH_ANT_HOME"
13337            fi
13338        else
13339            echo "configure: Ant test failed" >&5
13340            cat conftest.java >&5
13341            cat conftest.xml >&5
13342            AC_MSG_ERROR([Ant does not work - Some Java projects will not build!])
13343        fi
13344        cd "$a_cwd"
13345        rm -fr conftest.dir
13346    fi
13347    if test -z "$ANT_HOME"; then
13348        ANT_HOME="NO_ANT_HOME"
13349    else
13350        PathFormat "$ANT_HOME"
13351        ANT_HOME="$formatted_path"
13352        PathFormat "$ANT"
13353        ANT="$formatted_path"
13354    fi
13355
13356    dnl Checking for ant.jar
13357    if test "$ANT_HOME" != "NO_ANT_HOME"; then
13358        AC_MSG_CHECKING([Ant lib directory])
13359        if test -f $ANT_HOME/lib/ant.jar; then
13360            ANT_LIB="$ANT_HOME/lib"
13361        else
13362            if test -f $ANT_HOME/ant.jar; then
13363                ANT_LIB="$ANT_HOME"
13364            else
13365                if test -f /usr/share/java/ant.jar; then
13366                    ANT_LIB=/usr/share/java
13367                else
13368                    if test -f /usr/share/ant-core/lib/ant.jar; then
13369                        ANT_LIB=/usr/share/ant-core/lib
13370                    else
13371                        if test -f $ANT_HOME/lib/ant/ant.jar; then
13372                            ANT_LIB="$ANT_HOME/lib/ant"
13373                        else
13374                            if test -f /usr/share/lib/ant/ant.jar; then
13375                                ANT_LIB=/usr/share/lib/ant
13376                            else
13377                                AC_MSG_ERROR([Ant libraries not found!])
13378                            fi
13379                        fi
13380                    fi
13381                fi
13382            fi
13383        fi
13384        PathFormat "$ANT_LIB"
13385        ANT_LIB="$formatted_path"
13386        AC_MSG_RESULT([Ant lib directory found.])
13387    fi
13388
13389    ant_minver=1.6.0
13390    ant_minminor1=`echo $ant_minver | cut -d"." -f2`
13391
13392    AC_MSG_CHECKING([whether Ant is >= $ant_minver])
13393    ant_version=`"$ANT" -version | $AWK '$3 == "version" { print $4; }'`
13394    ant_version_major=`echo $ant_version | cut -d. -f1`
13395    ant_version_minor=`echo $ant_version | cut -d. -f2`
13396    echo "configure: ant_version $ant_version " >&5
13397    echo "configure: ant_version_major $ant_version_major " >&5
13398    echo "configure: ant_version_minor $ant_version_minor " >&5
13399    if test "$ant_version_major" -ge "2"; then
13400        AC_MSG_RESULT([yes, $ant_version])
13401    elif test "$ant_version_major" = "1" -a "$ant_version_minor" -ge "$ant_minminor1"; then
13402        AC_MSG_RESULT([yes, $ant_version])
13403    else
13404        AC_MSG_ERROR([no, you need at least Ant >= $ant_minver])
13405    fi
13406
13407    rm -f conftest* core core.* *.core
13408fi
13409AC_SUBST(ANT)
13410AC_SUBST(ANT_HOME)
13411AC_SUBST(ANT_LIB)
13412
13413OOO_JUNIT_JAR=
13414HAMCREST_JAR=
13415if test "$ENABLE_JAVA" != "" -a "$with_junit" != "no" -a "$cross_compiling" != "yes"; then
13416    AC_MSG_CHECKING([for JUnit 4])
13417    if test "$with_junit" = "yes"; then
13418        if test -n "$LODE_HOME" -a -e "$LODE_HOME/opt/share/java/junit.jar" ; then
13419            OOO_JUNIT_JAR="$LODE_HOME/opt/share/java/junit.jar"
13420        elif test -e /usr/share/java/junit4.jar; then
13421            OOO_JUNIT_JAR=/usr/share/java/junit4.jar
13422        else
13423           if test -e /usr/share/lib/java/junit.jar; then
13424              OOO_JUNIT_JAR=/usr/share/lib/java/junit.jar
13425           else
13426              OOO_JUNIT_JAR=/usr/share/java/junit.jar
13427           fi
13428        fi
13429    else
13430        OOO_JUNIT_JAR=$with_junit
13431    fi
13432    if test "$_os" = "WINNT"; then
13433        OOO_JUNIT_JAR=`cygpath -m "$OOO_JUNIT_JAR"`
13434    fi
13435    printf 'import org.junit.Before;' > conftest.java
13436    if "$JAVACOMPILER" -classpath "$OOO_JUNIT_JAR" conftest.java >&5 2>&5; then
13437        AC_MSG_RESULT([$OOO_JUNIT_JAR])
13438    else
13439        AC_MSG_ERROR(
13440[cannot find JUnit 4 jar; please install one in the default location (/usr/share/java),
13441 specify its pathname via --with-junit=..., or disable it via --without-junit])
13442    fi
13443    rm -f conftest.class conftest.java
13444    if test $OOO_JUNIT_JAR != ""; then
13445        BUILD_TYPE="$BUILD_TYPE QADEVOOO"
13446    fi
13447
13448    AC_MSG_CHECKING([for included Hamcrest])
13449    printf 'import org.hamcrest.BaseDescription;' > conftest.java
13450    if "$JAVACOMPILER" -classpath "$OOO_JUNIT_JAR" conftest.java >&5 2>&5; then
13451        AC_MSG_RESULT([Included in $OOO_JUNIT_JAR])
13452    else
13453        AC_MSG_RESULT([Not included])
13454        AC_MSG_CHECKING([for standalone hamcrest jar.])
13455        if test "$with_hamcrest" = "yes"; then
13456            if test -e /usr/share/lib/java/hamcrest.jar; then
13457                HAMCREST_JAR=/usr/share/lib/java/hamcrest.jar
13458            elif test -e /usr/share/java/hamcrest/core.jar; then
13459                HAMCREST_JAR=/usr/share/java/hamcrest/core.jar
13460            elif test -e /usr/share/java/hamcrest/hamcrest.jar; then
13461                HAMCREST_JAR=/usr/share/java/hamcrest/hamcrest.jar
13462            else
13463                HAMCREST_JAR=/usr/share/java/hamcrest.jar
13464            fi
13465        else
13466            HAMCREST_JAR=$with_hamcrest
13467        fi
13468        if test "$_os" = "WINNT"; then
13469            HAMCREST_JAR=`cygpath -m "$HAMCREST_JAR"`
13470        fi
13471        if "$JAVACOMPILER" -classpath "$HAMCREST_JAR" conftest.java >&5 2>&5; then
13472            AC_MSG_RESULT([$HAMCREST_JAR])
13473        else
13474            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),
13475                          specify its path with --with-hamcrest=..., or disable junit with --without-junit])
13476        fi
13477    fi
13478    rm -f conftest.class conftest.java
13479fi
13480AC_SUBST(OOO_JUNIT_JAR)
13481AC_SUBST(HAMCREST_JAR)
13482
13483
13484AC_SUBST(SCPDEFS)
13485
13486#
13487# check for wget and curl
13488#
13489WGET=
13490CURL=
13491
13492if test "$enable_fetch_external" != "no"; then
13493
13494CURL=`which curl 2>/dev/null`
13495
13496for i in wget /usr/bin/wget /usr/local/bin/wget /usr/sfw/bin/wget /opt/sfw/bin/wget /opt/local/bin/wget; do
13497    # wget new enough?
13498    $i --help 2> /dev/null | $GREP no-use-server-timestamps 2>&1 > /dev/null
13499    if test $? -eq 0; then
13500        WGET=$i
13501        break
13502    fi
13503done
13504
13505if test -z "$WGET" -a -z "$CURL"; then
13506    AC_MSG_ERROR([neither wget nor curl found!])
13507fi
13508
13509fi
13510
13511AC_SUBST(WGET)
13512AC_SUBST(CURL)
13513
13514#
13515# check for sha256sum
13516#
13517SHA256SUM=
13518
13519for i in shasum /usr/local/bin/shasum /usr/sfw/bin/shasum /opt/sfw/bin/shasum /opt/local/bin/shasum; do
13520    eval "$i -a 256 --version" > /dev/null 2>&1
13521    ret=$?
13522    if test $ret -eq 0; then
13523        SHA256SUM="$i -a 256"
13524        break
13525    fi
13526done
13527
13528if test -z "$SHA256SUM"; then
13529    for i in sha256sum /usr/local/bin/sha256sum /usr/sfw/bin/sha256sum /opt/sfw/bin/sha256sum /opt/local/bin/sha256sum; do
13530        eval "$i --version" > /dev/null 2>&1
13531        ret=$?
13532        if test $ret -eq 0; then
13533            SHA256SUM=$i
13534            break
13535        fi
13536    done
13537fi
13538
13539if test -z "$SHA256SUM"; then
13540    AC_MSG_ERROR([no sha256sum found!])
13541fi
13542
13543AC_SUBST(SHA256SUM)
13544
13545dnl ===================================================================
13546dnl Dealing with l10n options
13547dnl ===================================================================
13548AC_MSG_CHECKING([which languages to be built])
13549# get list of all languages
13550# generate shell variable from completelangiso= from solenv/inc/langlist.mk
13551# the sed command does the following:
13552#   + if a line ends with a backslash, append the next line to it
13553#   + adds " on the beginning of the value (after =)
13554#   + adds " at the end of the value
13555#   + removes en-US; we want to put it on the beginning
13556#   + prints just the section starting with 'completelangiso=' and ending with the " at the end of line
13557[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)]
13558ALL_LANGS="en-US $completelangiso"
13559# check the configured localizations
13560WITH_LANG="$with_lang"
13561
13562# Check for --without-lang which turns up as $with_lang being "no". Luckily there is no language with code "no".
13563# (Norwegian is "nb" and "nn".)
13564if test "$WITH_LANG" = "no"; then
13565    WITH_LANG=
13566fi
13567
13568if test -z "$WITH_LANG" -o "$WITH_LANG" = "en-US"; then
13569    AC_MSG_RESULT([en-US])
13570else
13571    AC_MSG_RESULT([$WITH_LANG])
13572    GIT_NEEDED_SUBMODULES="translations $GIT_NEEDED_SUBMODULES"
13573    if test -z "$MSGFMT"; then
13574        if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/msgfmt" ; then
13575            MSGFMT="$LODE_HOME/opt/bin/msgfmt"
13576        elif test -x "/opt/lo/bin/msgfmt"; then
13577            MSGFMT="/opt/lo/bin/msgfmt"
13578        else
13579            AC_CHECK_PROGS(MSGFMT, [msgfmt])
13580            if test -z "$MSGFMT"; then
13581                AC_MSG_ERROR([msgfmt not found. Install GNU gettext, or re-run without languages.])
13582            fi
13583        fi
13584    fi
13585    if test -z "$MSGUNIQ"; then
13586        if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/msguniq" ; then
13587            MSGUNIQ="$LODE_HOME/opt/bin/msguniq"
13588        elif test -x "/opt/lo/bin/msguniq"; then
13589            MSGUNIQ="/opt/lo/bin/msguniq"
13590        else
13591            AC_CHECK_PROGS(MSGUNIQ, [msguniq])
13592            if test -z "$MSGUNIQ"; then
13593                AC_MSG_ERROR([msguniq not found. Install GNU gettext, or re-run without languages.])
13594            fi
13595        fi
13596    fi
13597fi
13598AC_SUBST(MSGFMT)
13599AC_SUBST(MSGUNIQ)
13600# check that the list is valid
13601for lang in $WITH_LANG; do
13602    test "$lang" = "ALL" && continue
13603    # need to check for the exact string, so add space before and after the list of all languages
13604    for vl in $ALL_LANGS; do
13605        if test "$vl" = "$lang"; then
13606           break
13607        fi
13608    done
13609    if test "$vl" != "$lang"; then
13610        # if you're reading this - you prolly quoted your languages remove the quotes ...
13611        AC_MSG_ERROR([invalid language: '$lang' (vs '$v1'); supported languages are: $ALL_LANGS])
13612    fi
13613done
13614if test -n "$WITH_LANG" -a "$WITH_LANG" != "ALL"; then
13615    echo $WITH_LANG | grep -q en-US
13616    test $? -ne 1 || WITH_LANG=`echo $WITH_LANG en-US`
13617fi
13618# list with substituted ALL
13619WITH_LANG_LIST=`echo $WITH_LANG | sed "s/ALL/$ALL_LANGS/"`
13620test -z "$WITH_LANG_LIST" && WITH_LANG_LIST="en-US"
13621test "$WITH_LANG" = "en-US" && WITH_LANG=
13622if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
13623    test "$WITH_LANG_LIST" = "en-US" || WITH_LANG_LIST=`echo $WITH_LANG_LIST qtz`
13624    ALL_LANGS=`echo $ALL_LANGS qtz`
13625fi
13626AC_SUBST(ALL_LANGS)
13627AC_DEFINE_UNQUOTED(WITH_LANG,"$WITH_LANG")
13628AC_SUBST(WITH_LANG)
13629AC_SUBST(WITH_LANG_LIST)
13630AC_SUBST(GIT_NEEDED_SUBMODULES)
13631
13632WITH_POOR_HELP_LOCALIZATIONS=
13633if test -d "$SRC_ROOT/translations/source"; then
13634    for l in `ls -1 $SRC_ROOT/translations/source`; do
13635        if test ! -d "$SRC_ROOT/translations/source/$l/helpcontent2"; then
13636            WITH_POOR_HELP_LOCALIZATIONS="$WITH_POOR_HELP_LOCALIZATIONS $l"
13637        fi
13638    done
13639fi
13640AC_SUBST(WITH_POOR_HELP_LOCALIZATIONS)
13641
13642if test -n "$with_locales"; then
13643    WITH_LOCALES="$with_locales"
13644
13645    just_langs="`echo $WITH_LOCALES | sed -e 's/_[A-Z]*//g'`"
13646    # Only languages and scripts for which we actually have ifdefs need to be handled. Also see
13647    # config_host/config_locales.h.in
13648    for locale in $WITH_LOCALES; do
13649        lang=${locale%_*}
13650
13651        AC_DEFINE_UNQUOTED(WITH_LOCALE_$lang, 1)
13652
13653        case $lang in
13654        hi|mr*ne)
13655            AC_DEFINE(WITH_LOCALE_FOR_SCRIPT_Deva)
13656            ;;
13657        bg|ru)
13658            AC_DEFINE(WITH_LOCALE_FOR_SCRIPT_Cyrl)
13659            ;;
13660        esac
13661    done
13662else
13663    AC_DEFINE(WITH_LOCALE_ALL)
13664fi
13665AC_SUBST(WITH_LOCALES)
13666
13667dnl git submodule update --reference
13668dnl ===================================================================
13669if test -n "${GIT_REFERENCE_SRC}"; then
13670    for repo in ${GIT_NEEDED_SUBMODULES}; do
13671        if ! test -d "${GIT_REFERENCE_SRC}"/${repo}; then
13672            AC_MSG_ERROR([referenced git: required repository does not exist: ${GIT_REFERENCE_SRC}/${repo}])
13673        fi
13674    done
13675fi
13676AC_SUBST(GIT_REFERENCE_SRC)
13677
13678dnl git submodules linked dirs
13679dnl ===================================================================
13680if test -n "${GIT_LINK_SRC}"; then
13681    for repo in ${GIT_NEEDED_SUBMODULES}; do
13682        if ! test -d "${GIT_LINK_SRC}"/${repo}; then
13683            AC_MSG_ERROR([linked git: required repository does not exist: ${GIT_LINK_SRC}/${repo}])
13684        fi
13685    done
13686fi
13687AC_SUBST(GIT_LINK_SRC)
13688
13689dnl branding
13690dnl ===================================================================
13691AC_MSG_CHECKING([for alternative branding images directory])
13692# initialize mapped arrays
13693BRAND_INTRO_IMAGES="intro.png intro-highres.png"
13694brand_files="$BRAND_INTRO_IMAGES logo.svg logo_inverted.svg logo-sc.svg logo-sc_inverted.svg about.svg"
13695
13696if test -z "$with_branding" -o "$with_branding" = "no"; then
13697    AC_MSG_RESULT([none])
13698    DEFAULT_BRAND_IMAGES="$brand_files"
13699else
13700    if ! test -d $with_branding ; then
13701        AC_MSG_ERROR([No directory $with_branding, falling back to default branding])
13702    else
13703        AC_MSG_RESULT([$with_branding])
13704        CUSTOM_BRAND_DIR="$with_branding"
13705        for lfile in $brand_files
13706        do
13707            if ! test -f $with_branding/$lfile ; then
13708                AC_MSG_WARN([Branded file $lfile does not exist, using the default one])
13709                DEFAULT_BRAND_IMAGES="$DEFAULT_BRAND_IMAGES $lfile"
13710            else
13711                CUSTOM_BRAND_IMAGES="$CUSTOM_BRAND_IMAGES $lfile"
13712            fi
13713        done
13714        check_for_progress="yes"
13715    fi
13716fi
13717AC_SUBST([BRAND_INTRO_IMAGES])
13718AC_SUBST([CUSTOM_BRAND_DIR])
13719AC_SUBST([CUSTOM_BRAND_IMAGES])
13720AC_SUBST([DEFAULT_BRAND_IMAGES])
13721
13722
13723AC_MSG_CHECKING([for 'intro' progress settings])
13724PROGRESSBARCOLOR=
13725PROGRESSSIZE=
13726PROGRESSPOSITION=
13727PROGRESSFRAMECOLOR=
13728PROGRESSTEXTCOLOR=
13729PROGRESSTEXTBASELINE=
13730
13731if test "$check_for_progress" = "yes" -a -f "$with_branding/progress.conf" ; then
13732    source "$with_branding/progress.conf"
13733    AC_MSG_RESULT([settings found in $with_branding/progress.conf])
13734else
13735    AC_MSG_RESULT([none])
13736fi
13737
13738AC_SUBST(PROGRESSBARCOLOR)
13739AC_SUBST(PROGRESSSIZE)
13740AC_SUBST(PROGRESSPOSITION)
13741AC_SUBST(PROGRESSFRAMECOLOR)
13742AC_SUBST(PROGRESSTEXTCOLOR)
13743AC_SUBST(PROGRESSTEXTBASELINE)
13744
13745
13746dnl ===================================================================
13747dnl Custom build version
13748dnl ===================================================================
13749AC_MSG_CHECKING([for extra build ID])
13750if test -n "$with_extra_buildid" -a "$with_extra_buildid" != "yes" ; then
13751    EXTRA_BUILDID="$with_extra_buildid"
13752fi
13753# in tinderboxes, it is easier to set EXTRA_BUILDID via the environment variable instead of configure switch
13754if test -n "$EXTRA_BUILDID" ; then
13755    AC_MSG_RESULT([$EXTRA_BUILDID])
13756else
13757    AC_MSG_RESULT([not set])
13758fi
13759AC_DEFINE_UNQUOTED([EXTRA_BUILDID], ["$EXTRA_BUILDID"])
13760
13761OOO_VENDOR=
13762AC_MSG_CHECKING([for vendor])
13763if test -z "$with_vendor" -o "$with_vendor" = "no"; then
13764    OOO_VENDOR="$USERNAME"
13765
13766    if test -z "$OOO_VENDOR"; then
13767        OOO_VENDOR="$USER"
13768    fi
13769
13770    if test -z "$OOO_VENDOR"; then
13771        OOO_VENDOR="`id -u -n`"
13772    fi
13773
13774    AC_MSG_RESULT([not set, using $OOO_VENDOR])
13775else
13776    OOO_VENDOR="$with_vendor"
13777    AC_MSG_RESULT([$OOO_VENDOR])
13778fi
13779AC_DEFINE_UNQUOTED(OOO_VENDOR,"$OOO_VENDOR")
13780AC_SUBST(OOO_VENDOR)
13781
13782if test "$_os" = "Android" ; then
13783    ANDROID_PACKAGE_NAME=
13784    AC_MSG_CHECKING([for Android package name])
13785    if test -z "$with_android_package_name" -o "$with_android_package_name" = "no"; then
13786        if test -n "$ENABLE_DEBUG"; then
13787            # Default to the package name that makes ndk-gdb happy.
13788            ANDROID_PACKAGE_NAME="org.libreoffice"
13789        else
13790            ANDROID_PACKAGE_NAME="org.example.libreoffice"
13791        fi
13792
13793        AC_MSG_RESULT([not set, using $ANDROID_PACKAGE_NAME])
13794    else
13795        ANDROID_PACKAGE_NAME="$with_android_package_name"
13796        AC_MSG_RESULT([$ANDROID_PACKAGE_NAME])
13797    fi
13798    AC_SUBST(ANDROID_PACKAGE_NAME)
13799fi
13800
13801AC_MSG_CHECKING([whether to install the compat oo* wrappers])
13802if test "$with_compat_oowrappers" = "yes"; then
13803    WITH_COMPAT_OOWRAPPERS=TRUE
13804    AC_MSG_RESULT(yes)
13805else
13806    WITH_COMPAT_OOWRAPPERS=
13807    AC_MSG_RESULT(no)
13808fi
13809AC_SUBST(WITH_COMPAT_OOWRAPPERS)
13810
13811INSTALLDIRNAME=`echo AC_PACKAGE_NAME | $AWK '{print tolower($0)}'`
13812AC_MSG_CHECKING([for install dirname])
13813if test -n "$with_install_dirname" -a "$with_install_dirname" != "no" -a "$with_install_dirname" != "yes"; then
13814    INSTALLDIRNAME="$with_install_dirname"
13815fi
13816AC_MSG_RESULT([$INSTALLDIRNAME])
13817AC_SUBST(INSTALLDIRNAME)
13818
13819AC_MSG_CHECKING([for prefix])
13820test "x$prefix" = xNONE && prefix=$ac_default_prefix
13821test "x$exec_prefix" = xNONE && exec_prefix=$prefix
13822PREFIXDIR="$prefix"
13823AC_MSG_RESULT([$PREFIXDIR])
13824AC_SUBST(PREFIXDIR)
13825
13826LIBDIR=[$(eval echo $(eval echo $libdir))]
13827AC_SUBST(LIBDIR)
13828
13829DATADIR=[$(eval echo $(eval echo $datadir))]
13830AC_SUBST(DATADIR)
13831
13832MANDIR=[$(eval echo $(eval echo $mandir))]
13833AC_SUBST(MANDIR)
13834
13835DOCDIR=[$(eval echo $(eval echo $docdir))]
13836AC_SUBST(DOCDIR)
13837
13838BINDIR=[$(eval echo $(eval echo $bindir))]
13839AC_SUBST(BINDIR)
13840
13841INSTALLDIR="$LIBDIR/$INSTALLDIRNAME"
13842AC_SUBST(INSTALLDIR)
13843
13844TESTINSTALLDIR="${BUILDDIR}/test-install"
13845AC_SUBST(TESTINSTALLDIR)
13846
13847
13848# ===================================================================
13849# OAuth2 id and secrets
13850# ===================================================================
13851
13852AC_MSG_CHECKING([for Google Drive client id and secret])
13853if test "$with_gdrive_client_id" = "no" -o -z "$with_gdrive_client_id"; then
13854    AC_MSG_RESULT([not set])
13855    GDRIVE_CLIENT_ID="\"\""
13856    GDRIVE_CLIENT_SECRET="\"\""
13857else
13858    AC_MSG_RESULT([set])
13859    GDRIVE_CLIENT_ID="\"$with_gdrive_client_id\""
13860    GDRIVE_CLIENT_SECRET="\"$with_gdrive_client_secret\""
13861fi
13862AC_DEFINE_UNQUOTED(GDRIVE_CLIENT_ID, $GDRIVE_CLIENT_ID)
13863AC_DEFINE_UNQUOTED(GDRIVE_CLIENT_SECRET, $GDRIVE_CLIENT_SECRET)
13864
13865AC_MSG_CHECKING([for Alfresco Cloud client id and secret])
13866if test "$with_alfresco_cloud_client_id" = "no" -o -z "$with_alfresco_cloud_client_id"; then
13867    AC_MSG_RESULT([not set])
13868    ALFRESCO_CLOUD_CLIENT_ID="\"\""
13869    ALFRESCO_CLOUD_CLIENT_SECRET="\"\""
13870else
13871    AC_MSG_RESULT([set])
13872    ALFRESCO_CLOUD_CLIENT_ID="\"$with_alfresco_cloud_client_id\""
13873    ALFRESCO_CLOUD_CLIENT_SECRET="\"$with_alfresco_cloud_client_secret\""
13874fi
13875AC_DEFINE_UNQUOTED(ALFRESCO_CLOUD_CLIENT_ID, $ALFRESCO_CLOUD_CLIENT_ID)
13876AC_DEFINE_UNQUOTED(ALFRESCO_CLOUD_CLIENT_SECRET, $ALFRESCO_CLOUD_CLIENT_SECRET)
13877
13878AC_MSG_CHECKING([for OneDrive client id and secret])
13879if test "$with_onedrive_client_id" = "no" -o -z "$with_onedrive_client_id"; then
13880    AC_MSG_RESULT([not set])
13881    ONEDRIVE_CLIENT_ID="\"\""
13882    ONEDRIVE_CLIENT_SECRET="\"\""
13883else
13884    AC_MSG_RESULT([set])
13885    ONEDRIVE_CLIENT_ID="\"$with_onedrive_client_id\""
13886    ONEDRIVE_CLIENT_SECRET="\"$with_onedrive_client_secret\""
13887fi
13888AC_DEFINE_UNQUOTED(ONEDRIVE_CLIENT_ID, $ONEDRIVE_CLIENT_ID)
13889AC_DEFINE_UNQUOTED(ONEDRIVE_CLIENT_SECRET, $ONEDRIVE_CLIENT_SECRET)
13890
13891
13892dnl ===================================================================
13893dnl Hook up LibreOffice's nodep environmental variable to automake's equivalent
13894dnl --enable-dependency-tracking configure option
13895dnl ===================================================================
13896AC_MSG_CHECKING([whether to enable dependency tracking])
13897if test "$enable_dependency_tracking" = "no"; then
13898    nodep=TRUE
13899    AC_MSG_RESULT([no])
13900else
13901    AC_MSG_RESULT([yes])
13902fi
13903AC_SUBST(nodep)
13904
13905dnl ===================================================================
13906dnl Number of CPUs to use during the build
13907dnl ===================================================================
13908AC_MSG_CHECKING([for number of processors to use])
13909# plain --with-parallelism is just the default
13910if test -n "$with_parallelism" -a "$with_parallelism" != "yes"; then
13911    if test "$with_parallelism" = "no"; then
13912        PARALLELISM=0
13913    else
13914        PARALLELISM=$with_parallelism
13915    fi
13916else
13917    if test "$enable_icecream" = "yes"; then
13918        PARALLELISM="40"
13919    else
13920        case `uname -s` in
13921
13922        Darwin|FreeBSD|NetBSD|OpenBSD)
13923            PARALLELISM=`sysctl -n hw.ncpu`
13924            ;;
13925
13926        Linux)
13927            PARALLELISM=`getconf _NPROCESSORS_ONLN`
13928        ;;
13929        # what else than above does profit here *and* has /proc?
13930        *)
13931            PARALLELISM=`grep $'^processor\t*:' /proc/cpuinfo | wc -l`
13932            ;;
13933        esac
13934
13935        # If we hit the catch-all case, but /proc/cpuinfo doesn't exist or has an
13936        # unexpected format, 'wc -l' will have returned 0 (and we won't use -j at all).
13937    fi
13938fi
13939
13940if test "$no_parallelism_make" = "YES" && test $PARALLELISM -gt 1; then
13941    if test -z "$with_parallelism"; then
13942            AC_MSG_WARN([gmake 3.81 crashes with parallelism > 1, reducing it to 1. upgrade to 3.82 to avoid this.])
13943            add_warning "gmake 3.81 crashes with parallelism > 1, reducing it to 1. upgrade to 3.82 to avoid this."
13944            PARALLELISM="1"
13945    else
13946        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."
13947    fi
13948fi
13949
13950if test $PARALLELISM -eq 0; then
13951    AC_MSG_RESULT([explicit make -j option needed])
13952else
13953    AC_MSG_RESULT([$PARALLELISM])
13954fi
13955AC_SUBST(PARALLELISM)
13956
13957IWYU_PATH="$with_iwyu"
13958AC_SUBST(IWYU_PATH)
13959if test ! -z "$IWYU_PATH"; then
13960    if test ! -f "$IWYU_PATH"; then
13961        AC_MSG_ERROR([cannot find include-what-you-use binary specified by --with-iwyu])
13962    fi
13963fi
13964
13965#
13966# Set up ILIB for MSVC build
13967#
13968ILIB1=
13969if test "$build_os" = "cygwin"; then
13970    ILIB="."
13971    if test -n "$JAVA_HOME"; then
13972        ILIB="$ILIB;$JAVA_HOME/lib"
13973    fi
13974    ILIB1=-link
13975    ILIB="$ILIB;$COMPATH/lib/$WIN_HOST_ARCH"
13976    ILIB1="$ILIB1 -LIBPATH:$COMPATH/lib/$WIN_HOST_ARCH"
13977    ILIB="$ILIB;$WINDOWS_SDK_HOME/lib/$WIN_HOST_ARCH"
13978    ILIB1="$ILIB1 -LIBPATH:$WINDOWS_SDK_HOME/lib/$WIN_HOST_ARCH"
13979    if test $WINDOWS_SDK_VERSION = 80 -o $WINDOWS_SDK_VERSION = 81 -o $WINDOWS_SDK_VERSION = 10; then
13980        ILIB="$ILIB;$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/$WIN_HOST_ARCH"
13981        ILIB1="$ILIB1 -LIBPATH:$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/$WIN_HOST_ARCH"
13982    fi
13983    PathFormat "${UCRTSDKDIR}lib/$UCRTVERSION/ucrt/$WIN_HOST_ARCH"
13984    ucrtlibpath_formatted=$formatted_path
13985    ILIB="$ILIB;$ucrtlibpath_formatted"
13986    ILIB1="$ILIB1 -LIBPATH:$ucrtlibpath_formatted"
13987    if test -f "$DOTNET_FRAMEWORK_HOME/lib/mscoree.lib"; then
13988        ILIB="$ILIB;$DOTNET_FRAMEWORK_HOME/lib"
13989    else
13990        ILIB="$ILIB;$DOTNET_FRAMEWORK_HOME/Lib/um/$WIN_HOST_ARCH"
13991    fi
13992
13993    if test "$cross_compiling" != "yes"; then
13994        ILIB_FOR_BUILD="$ILIB"
13995    fi
13996fi
13997AC_SUBST(ILIB)
13998AC_SUBST(ILIB_FOR_BUILD)
13999
14000# ===================================================================
14001# Creating bigger shared library to link against
14002# ===================================================================
14003AC_MSG_CHECKING([whether to create huge library])
14004MERGELIBS=
14005
14006if test $_os = iOS -o $_os = Android; then
14007    # Never any point in mergelibs for these as we build just static
14008    # libraries anyway...
14009    enable_mergelibs=no
14010fi
14011
14012if test -n "$enable_mergelibs" -a "$enable_mergelibs" != "no"; then
14013    if test $_os != Linux -a $_os != WINNT; then
14014        add_warning "--enable-mergelibs is not tested for this platform"
14015    fi
14016    MERGELIBS="TRUE"
14017    AC_MSG_RESULT([yes])
14018    AC_DEFINE(ENABLE_MERGELIBS)
14019else
14020    AC_MSG_RESULT([no])
14021fi
14022AC_SUBST([MERGELIBS])
14023
14024dnl ===================================================================
14025dnl icerun is a wrapper that stops us spawning tens of processes
14026dnl locally - for tools that can't be executed on the compile cluster
14027dnl this avoids a dozen javac's ganging up on your laptop to kill it.
14028dnl ===================================================================
14029AC_MSG_CHECKING([whether to use icerun wrapper])
14030ICECREAM_RUN=
14031if test "$enable_icecream" = "yes" && which icerun >/dev/null 2>&1 ; then
14032    ICECREAM_RUN=icerun
14033    AC_MSG_RESULT([yes])
14034else
14035    AC_MSG_RESULT([no])
14036fi
14037AC_SUBST(ICECREAM_RUN)
14038
14039dnl ===================================================================
14040dnl Setup the ICECC_VERSION for the build the same way it was set for
14041dnl configure, so that CC/CXX and ICECC_VERSION are in sync
14042dnl ===================================================================
14043x_ICECC_VERSION=[\#]
14044if test -n "$ICECC_VERSION" ; then
14045    x_ICECC_VERSION=
14046fi
14047AC_SUBST(x_ICECC_VERSION)
14048AC_SUBST(ICECC_VERSION)
14049
14050dnl ===================================================================
14051
14052AC_MSG_CHECKING([MPL subset])
14053MPL_SUBSET=
14054
14055if test "$enable_mpl_subset" = "yes"; then
14056    warn_report=false
14057    if test "$enable_report_builder" != "no" -a "$with_java" != "no"; then
14058        warn_report=true
14059    elif test "$ENABLE_REPORTBUILDER" = "TRUE"; then
14060        warn_report=true
14061    fi
14062    if test "$warn_report" = "true"; then
14063        AC_MSG_ERROR([need to --disable-report-builder - extended database report builder.])
14064    fi
14065    if test "x$enable_postgresql_sdbc" != "xno"; then
14066        AC_MSG_ERROR([need to --disable-postgresql-sdbc - the PostgreSQL database backend.])
14067    fi
14068    if test "$enable_lotuswordpro" = "yes"; then
14069        AC_MSG_ERROR([need to --disable-lotuswordpro - a Lotus Word Pro file format import filter.])
14070    fi
14071    if test "$WITH_WEBDAV" = "neon"; then
14072        AC_MSG_ERROR([need --with-webdav=serf or --without-webdav - webdav support.])
14073    fi
14074    if test -n "$ENABLE_POPPLER"; then
14075        if test "x$SYSTEM_POPPLER" = "x"; then
14076            AC_MSG_ERROR([need to disable PDF import via poppler or use system library])
14077        fi
14078    fi
14079    # cf. m4/libo_check_extension.m4
14080    if test "x$WITH_EXTRA_EXTENSIONS" != "x"; then
14081        AC_MSG_ERROR([need to disable extra extensions '$WITH_EXTRA_EXTENSIONS'])
14082    fi
14083    for theme in $WITH_THEMES; do
14084        case $theme in
14085        breeze|breeze_dark|breeze_dark_svg|breeze_svg|elementary|elementary_svg|karasa_jaga|karasa_jaga_svg) #denylist of icon themes under GPL or LGPL
14086            AC_MSG_ERROR([need to disable icon themes from '$WITH_THEMES': $theme present, use --with-theme=colibre]) ;;
14087        *) : ;;
14088        esac
14089    done
14090
14091    ENABLE_OPENGL_TRANSITIONS=
14092
14093    if test "$enable_lpsolve" != "no" -o "x$ENABLE_LPSOLVE" = "xTRUE"; then
14094        AC_MSG_ERROR([need to --disable-lpsolve - calc linear programming solver.])
14095    fi
14096
14097    MPL_SUBSET="TRUE"
14098    AC_DEFINE(MPL_HAVE_SUBSET)
14099    AC_MSG_RESULT([only])
14100else
14101    AC_MSG_RESULT([no restrictions])
14102fi
14103AC_SUBST(MPL_SUBSET)
14104
14105dnl ===================================================================
14106
14107AC_MSG_CHECKING([formula logger])
14108ENABLE_FORMULA_LOGGER=
14109
14110if test "x$enable_formula_logger" = "xyes"; then
14111    AC_MSG_RESULT([yes])
14112    AC_DEFINE(ENABLE_FORMULA_LOGGER)
14113    ENABLE_FORMULA_LOGGER=TRUE
14114elif test -n "$ENABLE_DBGUTIL" ; then
14115    AC_MSG_RESULT([yes])
14116    AC_DEFINE(ENABLE_FORMULA_LOGGER)
14117    ENABLE_FORMULA_LOGGER=TRUE
14118else
14119    AC_MSG_RESULT([no])
14120fi
14121
14122AC_SUBST(ENABLE_FORMULA_LOGGER)
14123
14124dnl ===================================================================
14125dnl Checking for active Antivirus software.
14126dnl ===================================================================
14127
14128if test $_os = WINNT -a -f "$SRC_ROOT/antivirusDetection.vbs" ; then
14129    AC_MSG_CHECKING([for active Antivirus software])
14130    ANTIVIRUS_LIST=`cscript.exe //Nologo $SRC_ROOT/antivirusDetection.vbs`
14131    if [ [ "$ANTIVIRUS_LIST" != "NULL" ] ]; then
14132        if [ [ "$ANTIVIRUS_LIST" != "NOT_FOUND" ] ]; then
14133            AC_MSG_RESULT([found])
14134            EICAR_STRING='X5O!P%@AP@<:@4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*'
14135            echo $EICAR_STRING > $SRC_ROOT/eicar
14136            EICAR_TEMP_FILE_CONTENTS=`cat $SRC_ROOT/eicar`
14137            rm $SRC_ROOT/eicar
14138            if [ [ "$EICAR_STRING" != "$EICAR_TEMP_FILE_CONTENTS" ] ]; then
14139                AC_MSG_ERROR([Exclude the build and source directories associated with LibreOffice in the following Antivirus software: $ANTIVIRUS_LIST])
14140            fi
14141            echo $EICAR_STRING > $BUILDDIR/eicar
14142            EICAR_TEMP_FILE_CONTENTS=`cat $BUILDDIR/eicar`
14143            rm $BUILDDIR/eicar
14144            if [ [ "$EICAR_STRING" != "$EICAR_TEMP_FILE_CONTENTS" ] ]; then
14145                AC_MSG_ERROR([Exclude the build and source directories associated with LibreOffice in the following Antivirus software: $ANTIVIRUS_LIST])
14146            fi
14147            add_warning "To speed up builds and avoid failures in unit tests, it is highly recommended that you exclude the build and source directories associated with LibreOffice in the following Antivirus software: $ANTIVIRUS_LIST"
14148        else
14149            AC_MSG_RESULT([not found])
14150        fi
14151    else
14152        AC_MSG_RESULT([n/a])
14153    fi
14154fi
14155
14156dnl ===================================================================
14157dnl Setting up the environment.
14158dnl ===================================================================
14159AC_MSG_NOTICE([setting up the build environment variables...])
14160
14161AC_SUBST(COMPATH)
14162
14163if test "$build_os" = "cygwin"; then
14164    if test -d "$COMPATH/atlmfc/lib/spectre"; then
14165        ATL_LIB="$COMPATH/atlmfc/lib/spectre"
14166        ATL_INCLUDE="$COMPATH/atlmfc/include"
14167    elif test -d "$COMPATH/atlmfc/lib"; then
14168        ATL_LIB="$COMPATH/atlmfc/lib"
14169        ATL_INCLUDE="$COMPATH/atlmfc/include"
14170    else
14171        ATL_LIB="$WINDOWS_SDK_HOME/lib" # Doesn't exist for VSE
14172        ATL_INCLUDE="$WINDOWS_SDK_HOME/include/atl"
14173    fi
14174    ATL_LIB="$ATL_LIB/$WIN_HOST_ARCH"
14175    ATL_LIB=`win_short_path_for_make "$ATL_LIB"`
14176    ATL_INCLUDE=`win_short_path_for_make "$ATL_INCLUDE"`
14177
14178    # sort.exe and find.exe also exist in C:/Windows/system32 so need /usr/bin/
14179    PathFormat "/usr/bin/find.exe"
14180    FIND="$formatted_path"
14181    PathFormat "/usr/bin/sort.exe"
14182    SORT="$formatted_path"
14183    PathFormat "/usr/bin/grep.exe"
14184    WIN_GREP="$formatted_path"
14185    PathFormat "/usr/bin/ls.exe"
14186    WIN_LS="$formatted_path"
14187    PathFormat "/usr/bin/touch.exe"
14188    WIN_TOUCH="$formatted_path"
14189else
14190    FIND=find
14191    SORT=sort
14192fi
14193
14194AC_SUBST(ATL_INCLUDE)
14195AC_SUBST(ATL_LIB)
14196AC_SUBST(FIND)
14197AC_SUBST(SORT)
14198AC_SUBST(WIN_GREP)
14199AC_SUBST(WIN_LS)
14200AC_SUBST(WIN_TOUCH)
14201
14202AC_SUBST(BUILD_TYPE)
14203
14204AC_SUBST(SOLARINC)
14205
14206PathFormat "$PERL"
14207PERL="$formatted_path"
14208AC_SUBST(PERL)
14209
14210if test -n "$TMPDIR"; then
14211    TEMP_DIRECTORY="$TMPDIR"
14212else
14213    TEMP_DIRECTORY="/tmp"
14214fi
14215if test "$build_os" = "cygwin"; then
14216    TEMP_DIRECTORY=`cygpath -m "$TEMP_DIRECTORY"`
14217fi
14218AC_SUBST(TEMP_DIRECTORY)
14219
14220# setup the PATH for the environment
14221if test -n "$LO_PATH_FOR_BUILD"; then
14222    LO_PATH="$LO_PATH_FOR_BUILD"
14223    case "$host_os" in
14224    cygwin*|wsl*)
14225        pathmunge "$MSVC_HOST_PATH" "before"
14226        ;;
14227    esac
14228else
14229    LO_PATH="$PATH"
14230
14231    case "$host_os" in
14232
14233    aix*|dragonfly*|freebsd*|linux-gnu*|*netbsd*|openbsd*)
14234        if test "$ENABLE_JAVA" != ""; then
14235            pathmunge "$JAVA_HOME/bin" "after"
14236        fi
14237        ;;
14238
14239    cygwin*|wsl*)
14240        # Win32 make needs native paths
14241        if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
14242            LO_PATH=`cygpath -p -m "$PATH"`
14243        fi
14244        if test "$WIN_BUILD_ARCH" = "x64"; then
14245            # needed for msi packaging
14246            pathmunge "$WINDOWS_SDK_BINDIR_NO_ARCH/x86" "before"
14247        fi
14248        # .NET 4.6 and higher don't have bin directory
14249        if test -f "$DOTNET_FRAMEWORK_HOME/bin"; then
14250            pathmunge "$DOTNET_FRAMEWORK_HOME/bin" "before"
14251        fi
14252        pathmunge "$WINDOWS_SDK_HOME/bin" "before"
14253        pathmunge "$CSC_PATH" "before"
14254        pathmunge "$MIDL_PATH" "before"
14255        pathmunge "$AL_PATH" "before"
14256        pathmunge "$MSVC_MULTI_PATH" "before"
14257        pathmunge "$MSVC_BUILD_PATH" "before"
14258        if test -n "$MSBUILD_PATH" ; then
14259            pathmunge "$MSBUILD_PATH" "before"
14260        fi
14261        pathmunge "$WINDOWS_SDK_BINDIR_NO_ARCH/$WIN_BUILD_ARCH" "before"
14262        if test "$ENABLE_JAVA" != ""; then
14263            if test -d "$JAVA_HOME/jre/bin/client"; then
14264                pathmunge "$JAVA_HOME/jre/bin/client" "before"
14265            fi
14266            if test -d "$JAVA_HOME/jre/bin/hotspot"; then
14267                pathmunge "$JAVA_HOME/jre/bin/hotspot" "before"
14268            fi
14269            pathmunge "$JAVA_HOME/bin" "before"
14270        fi
14271        pathmunge "$MSVC_HOST_PATH" "before"
14272        ;;
14273
14274    solaris*)
14275        pathmunge "/usr/css/bin" "before"
14276        if test "$ENABLE_JAVA" != ""; then
14277            pathmunge "$JAVA_HOME/bin" "after"
14278        fi
14279        ;;
14280    esac
14281fi
14282
14283AC_SUBST(LO_PATH)
14284
14285# Allow to pass LO_ELFCHECK_ALLOWLIST from autogen.input to bin/check-elf-dynamic-objects:
14286if test "$LO_ELFCHECK_ALLOWLIST" = x || test "${LO_ELFCHECK_ALLOWLIST-x}" != x; then
14287    x_LO_ELFCHECK_ALLOWLIST=
14288else
14289    x_LO_ELFCHECK_ALLOWLIST=[\#]
14290fi
14291AC_SUBST(x_LO_ELFCHECK_ALLOWLIST)
14292AC_SUBST(LO_ELFCHECK_ALLOWLIST)
14293
14294libo_FUZZ_SUMMARY
14295
14296# Generate a configuration sha256 we can use for deps
14297if test -f config_host.mk; then
14298    config_sha256=`$SHA256SUM config_host.mk | sed "s/ .*//"`
14299fi
14300if test -f config_host_lang.mk; then
14301    config_lang_sha256=`$SHA256SUM config_host_lang.mk | sed "s/ .*//"`
14302fi
14303
14304CFLAGS=$my_original_CFLAGS
14305CXXFLAGS=$my_original_CXXFLAGS
14306CPPFLAGS=$my_original_CPPFLAGS
14307
14308AC_CONFIG_LINKS([include:include])
14309
14310# Keep in sync with list of files far up, at AC_MSG_CHECKING([for
14311# BUILD platform configuration] - otherwise breaks cross building
14312AC_CONFIG_FILES([config_host.mk
14313                 config_host_lang.mk
14314                 Makefile
14315                 bin/bffvalidator.sh
14316                 bin/odfvalidator.sh
14317                 bin/officeotron.sh
14318                 hardened_runtime.xcent
14319                 instsetoo_native/util/openoffice.lst
14320                 sysui/desktop/macosx/Info.plist
14321                 vs-code-template.code-workspace:.vscode/vs-code-template.code-workspace.in])
14322AC_CONFIG_HEADERS([config_host/config_buildid.h])
14323AC_CONFIG_HEADERS([config_host/config_box2d.h])
14324AC_CONFIG_HEADERS([config_host/config_clang.h])
14325AC_CONFIG_HEADERS([config_host/config_crypto.h])
14326AC_CONFIG_HEADERS([config_host/config_dconf.h])
14327AC_CONFIG_HEADERS([config_host/config_eot.h])
14328AC_CONFIG_HEADERS([config_host/config_extensions.h])
14329AC_CONFIG_HEADERS([config_host/config_cairo_canvas.h])
14330AC_CONFIG_HEADERS([config_host/config_cxxabi.h])
14331AC_CONFIG_HEADERS([config_host/config_dbus.h])
14332AC_CONFIG_HEADERS([config_host/config_features.h])
14333AC_CONFIG_HEADERS([config_host/config_feature_desktop.h])
14334AC_CONFIG_HEADERS([config_host/config_feature_opencl.h])
14335AC_CONFIG_HEADERS([config_host/config_firebird.h])
14336AC_CONFIG_HEADERS([config_host/config_folders.h])
14337AC_CONFIG_HEADERS([config_host/config_fuzzers.h])
14338AC_CONFIG_HEADERS([config_host/config_gio.h])
14339AC_CONFIG_HEADERS([config_host/config_global.h])
14340AC_CONFIG_HEADERS([config_host/config_gpgme.h])
14341AC_CONFIG_HEADERS([config_host/config_java.h])
14342AC_CONFIG_HEADERS([config_host/config_langs.h])
14343AC_CONFIG_HEADERS([config_host/config_lgpl.h])
14344AC_CONFIG_HEADERS([config_host/config_libcxx.h])
14345AC_CONFIG_HEADERS([config_host/config_liblangtag.h])
14346AC_CONFIG_HEADERS([config_host/config_locales.h])
14347AC_CONFIG_HEADERS([config_host/config_mpl.h])
14348AC_CONFIG_HEADERS([config_host/config_oox.h])
14349AC_CONFIG_HEADERS([config_host/config_options.h])
14350AC_CONFIG_HEADERS([config_host/config_options_calc.h])
14351AC_CONFIG_HEADERS([config_host/config_zxing.h])
14352AC_CONFIG_HEADERS([config_host/config_skia.h])
14353AC_CONFIG_HEADERS([config_host/config_typesizes.h])
14354AC_CONFIG_HEADERS([config_host/config_vendor.h])
14355AC_CONFIG_HEADERS([config_host/config_vcl.h])
14356AC_CONFIG_HEADERS([config_host/config_vclplug.h])
14357AC_CONFIG_HEADERS([config_host/config_version.h])
14358AC_CONFIG_HEADERS([config_host/config_oauth2.h])
14359AC_CONFIG_HEADERS([config_host/config_poppler.h])
14360AC_CONFIG_HEADERS([config_host/config_python.h])
14361AC_CONFIG_HEADERS([config_host/config_writerperfect.h])
14362AC_OUTPUT
14363
14364if test "$CROSS_COMPILING" = TRUE; then
14365    (echo; echo export BUILD_TYPE_FOR_HOST=$BUILD_TYPE) >>config_build.mk
14366fi
14367
14368# touch the config timestamp file
14369if test ! -f config_host.mk.stamp; then
14370    echo > config_host.mk.stamp
14371elif test "$config_sha256" = `$SHA256SUM config_host.mk | sed "s/ .*//"`; then
14372    echo "Host Configuration unchanged - avoiding scp2 stamp update"
14373else
14374    echo > config_host.mk.stamp
14375fi
14376
14377# touch the config lang timestamp file
14378if test ! -f config_host_lang.mk.stamp; then
14379    echo > config_host_lang.mk.stamp
14380elif test "$config_lang_sha256" = `$SHA256SUM config_host_lang.mk | sed "s/ .*//"`; then
14381    echo "Language Configuration unchanged - avoiding scp2 stamp update"
14382else
14383    echo > config_host_lang.mk.stamp
14384fi
14385
14386
14387if test \( "$STALE_MAKE" = "TRUE" -o "$HAVE_GNUMAKE_FILE_FUNC" != "TRUE" \) \
14388        -a "$build_os" = "cygwin"; then
14389
14390cat << _EOS
14391****************************************************************************
14392WARNING:
14393Your make version is known to be horribly slow, and hard to debug
14394problems with. To get a reasonably functional make please do:
14395
14396to install a pre-compiled binary make for Win32
14397
14398 mkdir -p /opt/lo/bin
14399 cd /opt/lo/bin
14400 wget https://dev-www.libreoffice.org/bin/cygwin/make-4.2.1-msvc.exe
14401 cp make-4.2.1-msvc.exe make
14402 chmod +x make
14403
14404to install from source:
14405place yourself in a working directory of you choice.
14406
14407 git clone git://git.savannah.gnu.org/make.git
14408
14409 [go to Start menu, open "Visual Studio 2019", click "x86 Native Tools Command Prompt" or "x64 Native Tools Command Prompt"]
14410 set PATH=%PATH%;C:\Cygwin\bin
14411 [or Cygwin64, if that is what you have]
14412 cd path-to-make-repo-you-cloned-above
14413 build_w32.bat --without-guile
14414
14415should result in a WinRel/gnumake.exe.
14416Copy it to the Cygwin /opt/lo/bin directory as make.exe
14417
14418Then re-run autogen.sh
14419
14420Note: autogen.sh will try to use /opt/lo/bin/make if the environment variable GNUMAKE is not already defined.
14421Alternatively, you can install the 'new' make where ever you want and make sure that `which make` finds it.
14422
14423_EOS
14424if test "$HAVE_GNUMAKE_FILE_FUNC" != "TRUE"; then
14425    AC_MSG_ERROR([no file function found; the build will fail without it; use GNU make 4.0 or later])
14426fi
14427fi
14428
14429
14430cat << _EOF
14431****************************************************************************
14432
14433To build, run:
14434$GNUMAKE
14435
14436To view some help, run:
14437$GNUMAKE help
14438
14439_EOF
14440
14441if test $_os != WINNT -a "$CROSS_COMPILING" != TRUE; then
14442    cat << _EOF
14443After the build has finished successfully, you can immediately run what you built using the command:
14444_EOF
14445
14446    if test $_os = Darwin; then
14447        echo open instdir/$PRODUCTNAME_WITHOUT_SPACES.app
14448    else
14449        echo instdir/program/soffice
14450    fi
14451    cat << _EOF
14452
14453If you want to run the smoketest, run:
14454$GNUMAKE check
14455
14456_EOF
14457fi
14458
14459if test -f "$WARNINGS_FILE_FOR_BUILD"; then
14460    echo "BUILD / cross-toolset config, repeated ($WARNINGS_FILE_FOR_BUILD)"
14461    cat "$WARNINGS_FILE_FOR_BUILD"
14462    echo
14463fi
14464
14465if test -f "$WARNINGS_FILE"; then
14466    echo "HOST config ($WARNINGS_FILE)"
14467    cat "$WARNINGS_FILE"
14468fi
14469
14470dnl vim:set shiftwidth=4 softtabstop=4 expandtab:
14471