xref: /core/configure.ac (revision 2e5e6c6ef3a31834a729aca8c93f086a3693bdc1)
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
5dnl cspell:enableCompoundWords
6dnl cspell:includeRegExp ^\s*#.*$
7dnl cspell:includeRegExp ^\s*dnl.*$
8dnl cspell:includeRegExp /AC_MSG_[A-Z]*\([^)]*\)/
9dnl cspell:ignoreRegExp /[A-Z]{4,}/
10dnl cspell:ignoreRegExp /\${?[A-za-z]*/
11dnl cspell:ignoreRegExp /[ ']-[fglmBWXZ][a-z][^ ]*/
12dnl cspell:ignoreRegExp / -isystem /
13
14# The version number in the second argument to AC_INIT should be four numbers separated by
15# periods. Some parts of the code requires the first one to be less than 128 and the others to be less
16# than 256. The four numbers can optionally be followed by a period and a free-form string containing
17# no spaces or periods, like "frobozz-mumble-42" or "alpha0". If the free-form string ends with one or
18# several non-alphanumeric characters, those are split off and used only for the
19# ABOUTBOXPRODUCTVERSIONSUFFIX in openoffice.lst. Why that is necessary, no idea.
20
21AC_INIT([LibreOffice],[26.2.0.0.alpha0+],[],[],[http://documentfoundation.org/])
22
23dnl libnumbertext needs autoconf 2.68, but that can pick up autoconf268 just fine if it is installed
24dnl whereas aclocal (as run by autogen.sh) insists on using autoconf and fails hard
25dnl so check for the version of autoconf that is actually used to create the configure script
26AC_PREREQ([2.59])
27m4_if(m4_version_compare(m4_defn([AC_AUTOCONF_VERSION]), [2.68]), -1,
28    [AC_MSG_ERROR([at least autoconf version 2.68 is needed (you can use AUTOCONF environment variable to point to a suitable one)])])
29
30if test -n "$BUILD_TYPE"; then
31    AC_MSG_ERROR([You have sourced config_host.mk in this shell.  This may lead to trouble, please run in a fresh (login) shell.])
32fi
33
34save_CC=$CC
35save_CXX=$CXX
36
37first_arg_basename()
38{
39    for i in $1; do
40        basename "$i"
41        break
42    done
43}
44
45CC_BASE=`first_arg_basename "$CC"`
46CXX_BASE=`first_arg_basename "$CXX"`
47
48BUILD_TYPE="LibO"
49SCPDEFS=""
50GIT_NEEDED_SUBMODULES=""
51LO_PATH= # used by path_munge to construct a PATH variable
52
53
54FilterLibs()
55{
56    # Return value: $filteredlibs
57
58    filteredlibs=
59    if test "$COM" = "MSC"; then
60        for f in $1; do
61            if test "x$f" != "x${f#-L}"; then
62                filteredlibs="$filteredlibs -LIBPATH:${f:2}"
63            elif test "x$f" != "x${f#-l}"; then
64                filteredlibs="$filteredlibs ${f:2}.lib"
65            else
66                filteredlibs="$filteredlibs $f"
67            fi
68        done
69    else
70        for f in $1; do
71            case "$f" in
72                -L*)
73                    case `realpath "${f#-L}"` in
74                        # let's start with Fedora's paths for now
75                        /lib|/lib/|/lib64|/lib64/|/usr/lib|/usr/lib/|/usr/lib64|/usr/lib64/)
76                        # ignore it: on UNIXoids it is searched by default anyway
77                        # but if it's given explicitly then it may override other paths
78                        # (on macOS it would be an error to use it instead of SDK)
79                            ;;
80                        *)
81                            filteredlibs="$filteredlibs $f"
82                            ;;
83                    esac
84                    ;;
85                *)
86                    filteredlibs="$filteredlibs $f"
87                    ;;
88            esac
89        done
90    fi
91}
92
93PathFormat()
94{
95    # Args: $1: A pathname. On Cygwin and WSL, in either the Unix or the Windows format. Note that this
96    # function is called also on Unix.
97    #
98    # Return value: $formatted_path and $formatted_path_unix.
99    #
100    # $formatted_path is the argument in Windows format, but using forward slashes instead of
101    # backslashes, using 8.3 pathname components if necessary (if it otherwise would contains spaces
102    # or shell metacharacters).
103    #
104    # $formatted_path_unix is the argument in a form usable in Cygwin or WSL, using 8.3 components if
105    # necessary. On Cygwin, it is the same as $formatted_path, but on WSL it is $formatted_path as a
106    # Unix pathname.
107    #
108    # Errors out if 8.3 names are needed but aren't present for some of the path components.
109
110    # Examples:
111    #
112    # /home/tml/lo/master-optimised => C:/cygwin64/home/tml/lo/master-optimised
113    #
114    # C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe => C:/PROGRA~2/MICROS~3/INSTAL~1/vswhere.exe
115    #
116    # C:\Program Files (x86)\Microsoft Visual Studio\2019\Community => C:/PROGRA~2/MICROS~3/2019/COMMUN~1
117    #
118    # C:/PROGRA~2/WI3CF2~1/10/Include/10.0.18362.0/ucrt => C:/PROGRA~2/WI3CF2~1/10/Include/10.0.18362.0/ucrt
119    #
120    # /cygdrive/c/PROGRA~2/WI3CF2~1/10 => C:/PROGRA~2/WI3CF2~1/10
121    #
122    # C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\ => C:/PROGRA~2/WI3CF2~1/NETFXSDK/4.8/
123    #
124    # /usr/bin/find.exe => C:/cygwin64/bin/find.exe
125
126    if test -z "$1"; then
127        formatted_path=""
128        formatted_path_unix=""
129        return
130    fi
131
132    if test -n "$UNITTEST_WSL_PATHFORMAT"; then
133        printf "PathFormat $1 ==> "
134    fi
135
136    formatted_path="$1"
137    if test "$build_os" = "cygwin" -o "$build_os" = "wsl"; then
138        if test "$build_os" = "wsl"; then
139            formatted_path=$(echo "$formatted_path" | tr -d '\r')
140        fi
141
142        pf_conv_to_dos=
143        # spaces,parentheses,brackets,braces are problematic in pathname
144        # so are backslashes
145        case "$formatted_path" in
146            *\ * | *\)* | *\(* | *\{* | *\}* | *\[* | *\]* | *\\* )
147                pf_conv_to_dos="yes"
148            ;;
149        esac
150        if test "$pf_conv_to_dos" = "yes"; then
151            if test "$build_os" = "wsl"; then
152                case "$formatted_path" in
153                    /*)
154                        formatted_path=$(wslpath -w "$formatted_path")
155                        ;;
156                esac
157                formatted_path=$($WSL_LO_HELPER --8.3 "$formatted_path")
158            elif test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
159                formatted_path=`cygpath -sm "$formatted_path"`
160            else
161                formatted_path=`cygpath -d "$formatted_path"`
162            fi
163            if test $? -ne 0;  then
164                AC_MSG_ERROR([path conversion failed for "$1".])
165            fi
166        fi
167        fp_count_colon=`echo "$formatted_path" | $GREP -c "[:]"`
168        fp_count_slash=`echo "$formatted_path" | $GREP -c "[/]"`
169        if test "$fp_count_slash$fp_count_colon" != "00"; then
170            if test "$fp_count_colon" = "0"; then
171                new_formatted_path=`realpath "$formatted_path"`
172                if test $? -ne 0;  then
173                    AC_MSG_WARN([realpath failed for "$formatted_path", not necessarily a problem.])
174                else
175                    formatted_path="$new_formatted_path"
176                fi
177            fi
178            if test "$build_os" = "wsl"; then
179                if test "$fp_count_colon" != "0"; then
180                    formatted_path=$(wslpath "$formatted_path")
181                    local final_slash=
182                    case "$formatted_path" in
183                        */)
184                            final_slash=/
185                            ;;
186                    esac
187                    formatted_path=$(wslpath -m $formatted_path)
188                    case "$formatted_path" in
189                        */)
190                            ;;
191                        *)
192                            formatted_path="$formatted_path"$final_slash
193                            ;;
194                    esac
195                else
196                    formatted_path=$(wslpath -m "$formatted_path")
197                fi
198            else
199                formatted_path=`cygpath -m "$formatted_path"`
200            fi
201            if test $? -ne 0;  then
202                AC_MSG_ERROR([path conversion failed for "$1".])
203            fi
204        fi
205        fp_count_space=`echo "$formatted_path" | $GREP -c "[ ]"`
206        if test "$fp_count_space" != "0"; then
207            AC_MSG_ERROR([converted path "$formatted_path" still contains spaces. Short filenames (8.3 filenames) support was disabled on this system?])
208        fi
209    fi
210    if test "$build_os" = "wsl"; then
211        # WSL can't run Windows binaries from Windows pathnames so we need a separate return value in Unix format
212        formatted_path_unix=$(wslpath "$formatted_path")
213    else
214        # But Cygwin can
215        formatted_path_unix="$formatted_path"
216    fi
217    if test -n "$WSL_ONLY_AS_HELPER"; then
218        # if already in unix format, switch to windows format to create shortened path
219        case "$formatted_path" in
220            /*)
221                formatted_path=$(wslpath -m "$formatted_path")
222                ;;
223        esac
224
225        # cd to /mnt/c to avoid wsl/cmd complaining about not supporting UNC paths/the current working directory
226        formatted_path_unix=$(wslpath -u "$(cd /mnt/c; cmd.exe /c $shortpath_cmd "$formatted_path" | tr -d '\r')")
227        # WSL can't run Windows binaries from Windows pathnames so we need a separate return value in Unix format
228        formatted_path=$(wslpath -m "$formatted_path_unix")
229    fi
230}
231
232AbsolutePath()
233{
234    # There appears to be no simple and portable method to get an absolute and
235    # canonical path, so we try creating the directory if does not exist and
236    # utilizing the shell and pwd.
237
238    # Args: $1: A possibly relative pathname
239    # Return value: $absolute_path
240
241    # Convert to unix path, mkdir would treat c:/path as a relative path.
242    PathFormat "$1"
243    local rel="$formatted_path_unix"
244    absolute_path=""
245    test ! -e "$rel" && mkdir -p "$rel"
246    if test -d "$rel" ; then
247        cd "$rel" || AC_MSG_ERROR([absolute path resolution failed for "$rel".])
248        absolute_path="$(pwd)"
249        cd - > /dev/null
250    else
251        AC_MSG_ERROR([Failed to resolve absolute path.  "$rel" does not exist or is not a directory.])
252    fi
253}
254
255WARNINGS_FILE=config.warn
256WARNINGS_FILE_FOR_BUILD=config.Build.warn
257rm -f "$WARNINGS_FILE" "$WARNINGS_FILE_FOR_BUILD"
258have_WARNINGS="no"
259add_warning()
260{
261    if test "$have_WARNINGS" = "no"; then
262        echo "*************************************" > "$WARNINGS_FILE"
263        have_WARNINGS="yes"
264        if command -v tput >/dev/null && test "`tput colors 2>/dev/null || echo 0`" -ge 8; then
265            dnl <esc> as actual byte (U+1b), [ escaped using quadrigraph @<:@
266            COLORWARN='*@<:@1;33;40m WARNING @<:@0m:'
267        else
268            COLORWARN="* WARNING :"
269        fi
270    fi
271    echo "$COLORWARN $@" >> "$WARNINGS_FILE"
272}
273
274dnl Some Mac User have the bad habit of letting a lot of crap
275dnl accumulate in their PATH and even adding stuff in /usr/local/bin
276dnl that confuse the build.
277dnl For the ones that use LODE, let's be nice and protect them
278dnl from themselves
279
280mac_sanitize_path()
281{
282    mac_path="$LODE_HOME/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin"
283dnl a common but nevertheless necessary thing that may be in a fancy
284dnl path location is git, so make sure we have it
285    mac_git_path=`command -v git`
286    if test -n "$mac_git_path" -a -x "$mac_git_path" -a "$mac_git_path" != "/usr/bin/git" ; then
287        mac_path="$mac_path:`dirname $mac_git_path`"
288    fi
289dnl a not so common but nevertheless quite helpful thing that may be in a fancy
290dnl path location is gpg, so make sure we find it
291    mac_gpg_path=`command -v gpg`
292    if test -n "$mac_gpg_path" -a -x "$mac_gpg_path" -a "$mac_gpg_path" != "/usr/bin/gpg" ; then
293        mac_path="$mac_path:`dirname $mac_gpg_path`"
294    fi
295    PATH="$mac_path"
296    unset mac_path
297    unset mac_git_path
298    unset mac_gpg_path
299}
300
301dnl semantically test a three digits version
302dnl $1 - $3 = minimal version
303dnl $4 - $6 = current version
304
305check_semantic_version_three()
306{
307    test "$4" -gt "$1" \
308        -o \( "$4" -eq "$1" -a "$5" -gt "$2" \) \
309        -o \( "$4" -eq "$1" -a "$5" -eq "$2" -a "$6" -ge "$3" \)
310    return $?
311}
312
313dnl calls check_semantic_version_three with digits in named variables $1_MAJOR, $1_MINOR, $1_TINY
314dnl $1 = current version prefix, e.g. EMSCRIPTEN => EMSCRIPTEN_
315dnl $2 = postfix to $1, e.g. MIN => EMSCRIPTEN_MIN_
316
317check_semantic_version_three_prefixed()
318{
319    eval local MIN_MAJOR="\$${1}_${2}_MAJOR"
320    eval local MIN_MINOR="\$${1}_${2}_MINOR"
321    eval local MIN_TINY="\$${1}_${2}_TINY"
322    eval local CUR_MAJOR="\$${1}_MAJOR"
323    eval local CUR_MINOR="\$${1}_MINOR"
324    eval local CUR_TINY="\$${1}_TINY"
325    check_semantic_version_three $MIN_MAJOR $MIN_MINOR $MIN_TINY $CUR_MAJOR $CUR_MINOR $CUR_TINY
326    return $?
327}
328
329echo "********************************************************************"
330echo "*"
331echo "*   Running ${PACKAGE_NAME} build configuration."
332echo "*"
333echo "********************************************************************"
334echo ""
335
336dnl ===================================================================
337dnl checks build and host OSes
338dnl do this before argument processing to allow for platform dependent defaults
339dnl ===================================================================
340
341# are we running in wsl but are called from git-bash/env with mingw64 or clangarm64 in path?
342# if so, we aim to run nearly everything in the Windows realm, and only run autogen/configure
343# in wsl and run a few tools via wsl
344WSL_ONLY_AS_HELPER=
345if test -n "$WSL_DISTRO_NAME" && $(echo $PATH |grep -q -e mingw64 -e clangarm64); then
346    WSL_ONLY_AS_HELPER=TRUE
347    shortpath_cmd=$(wslpath -m $srcdir/solenv/bin/shortpath.cmd)
348    if test -n "$PKG_CONFIG"; then
349        # make sure it is specified in a unix form/a path that wsl can access
350        PathFormat "$PKG_CONFIG"
351        PKG_CONFIG="$formatted_path_unix"
352    fi
353    AC_ARG_WITH([strawberry-perl-portable],
354        [AS_HELP_STRING([--with-strawberry-perl-portable],
355            [Specify the base path to strawberry perl portable])],
356        [],
357        [AC_MSG_ERROR(
358            [for the moment strawberry-perl-portable is a requirement, feel free to replace it])])
359    PathFormat "$with_strawberry_perl_portable"
360    if test ! -f "$formatted_path_unix/perl/bin/perl.exe" -o ! -d "$formatted_path_unix/c/bin"; then
361        AC_MSG_ERROR([$formatted_path doesn't contain perl or the utilities - sure you provided the base path?])
362    fi
363    STRAWBERRY_TOOLS="$formatted_path/c/bin"
364    STRAWBERRY_PERL="$formatted_path/perl/bin/perl.exe"
365    STRAWBERRY_PERL_UNIX="$formatted_path_unix/perl/bin/perl.exe"
366    AC_ARG_WITH([wsl-command],
367        [AS_HELP_STRING([--with-wsl-command],
368            [Specify your wsl distro command if it isn't the default/the one used with just wsl.exe369             for example: wsl.exe -d MyDistro -u NonDefaultUser])],
370        [],
371        [with_wsl_command="wsl.exe"])
372    WSL="$with_wsl_command"
373fi
374AC_SUBST([STRAWBERRY_PERL])
375AC_SUBST([WSL])
376
377# Check for WSL (version 2, at least). But if --host is explicitly specified (to really do build for
378# Linux on WSL) trust that.
379if test -z "$host" -a -z "$build" -a "`wslsys -v 2>/dev/null`" != ""; then
380    ac_cv_host="x86_64-pc-wsl"
381    ac_cv_host_cpu="x86_64"
382    ac_cv_host_os="wsl"
383    ac_cv_build="$ac_cv_host"
384    ac_cv_build_cpu="$ac_cv_host_cpu"
385    ac_cv_build_os="$ac_cv_host_os"
386
387    # Emulation of Cygwin's cygpath command for WSL.
388    cygpath()
389    {
390        if test -n "$UNITTEST_WSL_CYGPATH"; then
391            echo -n cygpath "$@" "==> "
392        fi
393
394        # Cygwin's real cygpath has a plethora of options but we use only a few here.
395        local args="$@"
396        local opt
397        local opt_d opt_m opt_u opt_w opt_l opt_s opt_p
398        OPTIND=1
399
400        while getopts dmuwlsp opt; do
401            case "$opt" in
402                \?)
403                    AC_MSG_ERROR([Unimplemented cygpath emulation option in invocation: cygpath $args])
404                    ;;
405                ?)
406                    eval opt_$opt=yes
407                    ;;
408            esac
409        done
410
411        shift $((OPTIND-1))
412
413        if test $# -ne 1; then
414            AC_MSG_ERROR([Invalid cygpath emulation invocation: Pathname missing]);
415        fi
416
417        local input="$1"
418
419        local result
420
421        if test -n "$opt_d" -o -n "$opt_m" -o -n "$opt_w"; then
422            # Print Windows path, possibly in 8.3 form (-d) or with forward slashes (-m)
423
424            if test -n "$opt_u"; then
425                AC_MSG_ERROR([Invalid cygpath invocation: Both Windows and Unix path output requested])
426            fi
427
428            case "$input" in
429                /mnt/*)
430                    # A Windows file in WSL format
431                    input=$(wslpath -w "$input")
432                    ;;
433                [[a-zA-Z]]:\\* | \\* | [[a-zA-Z]]:/* | /*)
434                    # Already in Windows format
435                    ;;
436                /*)
437                    input=$(wslpath -w "$input")
438                    ;;
439                *)
440                    AC_MSG_ERROR([Invalid cygpath invocation: Path '$input' is not absolute])
441                    ;;
442            esac
443            if test -n "$opt_d" -o -n "$opt_s"; then
444                input=$($WSL_LO_HELPER --8.3 "$input")
445            fi
446            if test -n "$opt_m"; then
447                input="${input//\\//}"
448            fi
449            echo "$input"
450        else
451            # Print Unix path
452
453            case "$input" in
454                [[a-zA-Z]]:\\* | \\* | [[a-zA-Z]]:/* | /*)
455                    wslpath -u "$input"
456                    ;;
457                /)
458                    echo "$input"
459                    ;;
460                *)
461                    AC_MSG_ERROR([Invalid cygpath invocation: Path '$input' is not absolute])
462                    ;;
463            esac
464        fi
465    }
466
467    if test -n "$UNITTEST_WSL_CYGPATH"; then
468        BUILDDIR=.
469
470        # Nothing special with these file names, just arbitrary ones picked to test with
471        cygpath -d /usr/lib64/ld-linux-x86-64.so.2
472        cygpath -w /usr/lib64/ld-linux-x86-64.so.2
473        cygpath -m /usr/lib64/ld-linux-x86-64.so.2
474        cygpath -m -s /usr/lib64/ld-linux-x86-64.so.2
475        # At least on my machine for instance this file does have an 8.3 name
476        cygpath -d /mnt/c/windows/WindowsUpdate.log
477        # But for instance this one doesn't
478        cygpath -w /mnt/c/windows/system32/AboutSettingsHandlers.dll
479        cygpath -ws /mnt/c/windows/WindowsUpdate.log
480        cygpath -m /mnt/c/windows/system32/AboutSettingsHandlers.dll
481        cygpath -ms /mnt/c/windows/WindowsUpdate.log
482
483        cygpath -u 'c:\windows\system32\AboutSettingsHandlers.dll'
484        cygpath -u 'c:/windows/system32/AboutSettingsHandlers.dll'
485
486        exit 0
487    fi
488
489    if test -z "$WSL_LO_HELPER"; then
490        if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/wsl-lo-helper" ; then
491            WSL_LO_HELPER="$LODE_HOME/opt/bin/wsl-lo-helper"
492        elif test -x "/opt/lo/bin/wsl-lo-helper"; then
493            WSL_LO_HELPER="/opt/lo/bin/wsl-lo-helper"
494        fi
495    fi
496    if test -z "$WSL_LO_HELPER"; then
497        AC_MSG_ERROR([wsl-lo-helper not found. See solenv/wsl/README.])
498    fi
499fi
500
501AC_CANONICAL_HOST
502AC_CANONICAL_BUILD
503
504if test -n "$UNITTEST_WSL_PATHFORMAT"; then
505    BUILDDIR=.
506    GREP=grep
507
508    # Use of PathFormat must be after AC_CANONICAL_BUILD above
509    PathFormat /
510    printf "$formatted_path , $formatted_path_unix\n"
511
512    PathFormat $PWD
513    printf "$formatted_path , $formatted_path_unix\n"
514
515    PathFormat "$PROGRAMFILESX86"
516    printf "$formatted_path , $formatted_path_unix\n"
517
518    exit 0
519fi
520
521AC_MSG_CHECKING([for product name])
522PRODUCTNAME="AC_PACKAGE_NAME"
523if test -n "$with_product_name" -a "$with_product_name" != no; then
524    PRODUCTNAME="$with_product_name"
525fi
526if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
527    PRODUCTNAME="${PRODUCTNAME}Dev"
528fi
529AC_MSG_RESULT([$PRODUCTNAME])
530AC_SUBST(PRODUCTNAME)
531PRODUCTNAME_WITHOUT_SPACES=$(printf %s "$PRODUCTNAME" | sed 's/ //g')
532AC_SUBST(PRODUCTNAME_WITHOUT_SPACES)
533
534dnl ===================================================================
535dnl Our version is defined by the AC_INIT() at the top of this script.
536dnl ===================================================================
537
538AC_MSG_CHECKING([for package version])
539if test -n "$with_package_version" -a "$with_package_version" != no; then
540    PACKAGE_VERSION="$with_package_version"
541fi
542AC_MSG_RESULT([$PACKAGE_VERSION])
543
544set `echo "$PACKAGE_VERSION" | sed "s/\./ /g"`
545
546LIBO_VERSION_MAJOR=$1
547LIBO_VERSION_MINOR=$2
548LIBO_VERSION_MICRO=$3
549LIBO_VERSION_PATCH=$4
550
551LIBO_VERSION_SUFFIX=$5
552
553# Split out LIBO_VERSION_SUFFIX_SUFFIX... horrible crack. But apparently wanted separately in
554# openoffice.lst as ABOUTBOXPRODUCTVERSIONSUFFIX. Note that the double brackets are for m4's sake,
555# they get undoubled before actually passed to sed.
556LIBO_VERSION_SUFFIX_SUFFIX=`echo "$LIBO_VERSION_SUFFIX" | sed -e 's/.*[[a-zA-Z0-9]]\([[^a-zA-Z0-9]]*\)$/\1/'`
557test -n "$LIBO_VERSION_SUFFIX_SUFFIX" && LIBO_VERSION_SUFFIX="${LIBO_VERSION_SUFFIX%${LIBO_VERSION_SUFFIX_SUFFIX}}"
558# LIBO_VERSION_SUFFIX, if non-empty, should include the period separator
559test -n "$LIBO_VERSION_SUFFIX" && LIBO_VERSION_SUFFIX=".$LIBO_VERSION_SUFFIX"
560
561# The value for key CFBundleVersion in the Info.plist file must be a period-separated list of at most
562# three non-negative integers. Please find more information about CFBundleVersion at
563# https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion
564
565# The value for key CFBundleShortVersionString in the Info.plist file must be a period-separated list
566# of at most three non-negative integers. Please find more information about
567# CFBundleShortVersionString at
568# https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring
569
570# But that is enforced only in the App Store, and we apparently want to break the rules otherwise.
571
572if test "$enable_macosx_sandbox" = yes; then
573    MACOSX_BUNDLE_SHORTVERSION=$LIBO_VERSION_MAJOR.$LIBO_VERSION_MINOR.`expr $LIBO_VERSION_MICRO '*' 1000 + $LIBO_VERSION_PATCH`
574    MACOSX_BUNDLE_VERSION=$MACOSX_BUNDLE_SHORTVERSION
575else
576    MACOSX_BUNDLE_SHORTVERSION=$LIBO_VERSION_MAJOR.$LIBO_VERSION_MINOR.$LIBO_VERSION_MICRO.$LIBO_VERSION_PATCH
577    MACOSX_BUNDLE_VERSION=$MACOSX_BUNDLE_SHORTVERSION$LIBO_VERSION_SUFFIX
578fi
579
580AC_SUBST(LIBO_VERSION_MAJOR)
581AC_SUBST(LIBO_VERSION_MINOR)
582AC_SUBST(LIBO_VERSION_MICRO)
583AC_SUBST(LIBO_VERSION_PATCH)
584AC_SUBST(LIBO_VERSION_SUFFIX)
585AC_SUBST(LIBO_VERSION_SUFFIX_SUFFIX)
586AC_SUBST(MACOSX_BUNDLE_SHORTVERSION)
587AC_SUBST(MACOSX_BUNDLE_VERSION)
588
589AC_DEFINE_UNQUOTED(LIBO_VERSION_MAJOR,$LIBO_VERSION_MAJOR)
590AC_DEFINE_UNQUOTED(LIBO_VERSION_MINOR,$LIBO_VERSION_MINOR)
591AC_DEFINE_UNQUOTED(LIBO_VERSION_MICRO,$LIBO_VERSION_MICRO)
592AC_DEFINE_UNQUOTED(LIBO_VERSION_PATCH,$LIBO_VERSION_PATCH)
593
594git_date=`git log -1 --pretty=format:"%cd" --date=format:'%Y' 2>/dev/null`
595LIBO_THIS_YEAR=${git_date:-2025}
596AC_DEFINE_UNQUOTED(LIBO_THIS_YEAR,$LIBO_THIS_YEAR)
597
598dnl ===================================================================
599dnl Product version
600dnl ===================================================================
601AC_MSG_CHECKING([for product version])
602PRODUCTVERSION="$LIBO_VERSION_MAJOR.$LIBO_VERSION_MINOR"
603AC_MSG_RESULT([$PRODUCTVERSION])
604AC_SUBST(PRODUCTVERSION)
605
606AC_PROG_EGREP
607# AC_PROG_EGREP doesn't set GREP on all systems as well
608AC_PATH_PROG(GREP, grep)
609
610BUILDDIR=`pwd`
611cd $srcdir
612SRC_ROOT=`pwd`
613cd $BUILDDIR
614x_Cygwin=[\#]
615
616dnl ======================================
617dnl Required GObject introspection version
618dnl ======================================
619INTROSPECTION_REQUIRED_VERSION=1.32.0
620
621dnl ===================================================================
622dnl Search all the common names for GNU Make
623dnl ===================================================================
624AC_MSG_CHECKING([for GNU Make])
625
626# try to use our own make if it is available and GNUMAKE was not already defined
627if test -z "$GNUMAKE"; then
628    if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/make" ; then
629        GNUMAKE="$LODE_HOME/opt/bin/make"
630    elif test -x "/opt/lo/bin/make"; then
631        GNUMAKE="/opt/lo/bin/make"
632    fi
633fi
634
635GNUMAKE_WIN_NATIVE=
636for a in "$MAKE" "$GNUMAKE" make gmake gnumake; do
637    if test -n "$a"; then
638        $a --version 2> /dev/null | grep GNU  2>&1 > /dev/null
639        if test $? -eq 0;  then
640            if test "$build_os" = "cygwin"; then
641                if test -n "$($a -v | grep 'Built for Windows')" ; then
642                    GNUMAKE="$(cygpath -m "$(command -v "$(cygpath -u $a)")")"
643                    GNUMAKE_WIN_NATIVE="TRUE"
644                else
645                    GNUMAKE=`command -v $a`
646                fi
647            else
648                GNUMAKE=`command -v $a`
649            fi
650            break
651        fi
652    fi
653done
654AC_MSG_RESULT($GNUMAKE)
655if test -z "$GNUMAKE"; then
656    AC_MSG_ERROR([not found. install GNU Make.])
657else
658    if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
659        AC_MSG_NOTICE([Using a native Win32 GNU Make version.])
660    fi
661fi
662
663win_short_path_for_make()
664{
665    local short_path="$1"
666    if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
667        cygpath -sm "$short_path"
668    elif test -n "$WSL_ONLY_AS_HELPER"; then
669        # when already unix-style path, wslpath doesn't return anything
670        case "$short_path" in
671        /*)
672            echo $short_path
673            exit
674            ;;
675        esac
676        wslpath -m "$(wslpath -u "$short_path")"
677    else
678        cygpath -u "$(cygpath -d "$short_path")"
679    fi
680}
681
682
683if test "$build_os" = "cygwin"; then
684    PathFormat "$SRC_ROOT"
685    SRC_ROOT="$formatted_path"
686    PathFormat "$BUILDDIR"
687    BUILDDIR="$formatted_path"
688    x_Cygwin=
689    AC_MSG_CHECKING(for explicit COMSPEC)
690    if test -z "$COMSPEC"; then
691        AC_MSG_ERROR([COMSPEC not set in environment, please set it and rerun])
692    else
693        AC_MSG_RESULT([found: $COMSPEC])
694    fi
695fi
696
697AC_SUBST(SRC_ROOT)
698AC_SUBST(BUILDDIR)
699AC_SUBST(x_Cygwin)
700AC_DEFINE_UNQUOTED(SRCDIR,"$SRC_ROOT")
701AC_DEFINE_UNQUOTED(SRC_ROOT,"$SRC_ROOT")
702AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
703
704if test "z$EUID" = "z0" -a "`uname -o 2>/dev/null`" = "Cygwin"; then
705    AC_MSG_ERROR([You must build LibreOffice as a normal user - not using an administrative account])
706fi
707
708# need sed in os checks...
709AC_PATH_PROGS(SED, sed)
710if test -z "$SED"; then
711    AC_MSG_ERROR([install sed to run this script])
712fi
713
714if test "$build_os" = "cygwin" -o -n "$WSL_ONLY_AS_HELPER"; then
715    # convenience check for a custom pkgconf used by meson - needs to be a version that uses windows
716    # style paths. Needs to be checked before the configure-switches that use PKG_CHECK_MODULES as
717    # that would already set the PKG_CONFIG var and then bypass/skip this autoselection
718    AC_PATH_PROG(PKG_CONFIG,pkgconf-2.4.3.exe,,[$PATH:$LODE_HOME/opt/bin])
719    if test -z "$PKG_CONFIG"; then
720        AC_MSG_ERROR([
721            A windows version of pkgconf is required to build harfbuzz.
722            Add PKG_CONFIG=/path/to/pkgconf-2.4.3.exe to autogen.input or put it in PATH])
723    fi
724else
725    case "$build_os" in
726        darwin*)
727            # convenience check for LODE's custom pkgconf used by meson
728            # Needs to be checked before the configure-switches that use PKG_CHECK_MODULES as
729            # that would already set the PKG_CONFIG var and then bypass/skip this autoselection
730            AC_PATH_PROG(PKG_CONFIG,pkgconf,,[$PATH:$LODE_HOME/opt/bin])
731            if test -z "$PKG_CONFIG"; then
732                AC_MSG_WARN([pkgconf not found - pkgconf is required to build harfbuzz])
733                add_warning "please add PKG_CONFIG=/path/to/pkgconf to autogen.input or put it in PATH, pkgconf is required to build harfbuzz"
734            fi
735            ;;
736    esac
737fi
738
739# Set the ENABLE_LTO variable
740# ===================================================================
741AC_MSG_CHECKING([whether to use link-time optimization])
742if test -n "$enable_lto" -a "$enable_lto" != "no"; then
743    ENABLE_LTO="TRUE"
744    AC_MSG_RESULT([yes])
745else
746    ENABLE_LTO=""
747    AC_MSG_RESULT([no])
748fi
749AC_SUBST(ENABLE_LTO)
750
751AC_MSG_CHECKING([whether to enable gcov])
752if test -n "$enable_gcov" -a "$enable_gcov" != "no"; then
753    ENABLE_GCOV="TRUE"
754    AC_MSG_RESULT([yes])
755    if test -n "$ENABLE_LTO"; then
756        AC_MSG_WARN([using --enable-gcov together with --enable-lto will likely fail to link])
757        add_warning "using --enable-gcov together with --enable-lto will likely fail to link"
758    fi
759else
760    ENABLE_GCOV=""
761    AC_MSG_RESULT([no])
762fi
763AC_SUBST(ENABLE_GCOV)
764
765AC_ARG_ENABLE(fuzz-options,
766    AS_HELP_STRING([--enable-fuzz-options],
767        [Randomly enable or disable each of those configurable options
768         that are supposed to be freely selectable without interdependencies,
769         or where bad interaction from interdependencies is automatically avoided.])
770)
771
772dnl ===================================================================
773dnl When building for Android, --with-android-ndk and
774dnl --with-android-sdk are mandatory
775dnl ===================================================================
776
777AC_ARG_WITH(android-ndk,
778    AS_HELP_STRING([--with-android-ndk],
779        [Specify location of the Android Native Development Kit. Mandatory when building for Android.]),
780,)
781
782AC_ARG_WITH(android-sdk,
783    AS_HELP_STRING([--with-android-sdk],
784        [Specify location of the Android SDK. Mandatory when building for Android.]),
785,)
786
787AC_ARG_WITH(android-api-level,
788    AS_HELP_STRING([--with-android-api-level],
789        [Specify the API level when building for Android. Defaults to 16 for ARM and x86 and to 21 for ARM64 and x86-64]),
790,)
791
792ANDROID_NDK_DIR=
793if test -z "$with_android_ndk" -a -e "$SRC_ROOT/external/android-ndk" -a "$build" != "$host"; then
794    with_android_ndk="$SRC_ROOT/external/android-ndk"
795fi
796if test -n "$with_android_ndk"; then
797    eval ANDROID_NDK_DIR=$with_android_ndk
798
799    ANDROID_API_LEVEL=21
800    if test -n "$with_android_api_level" ; then
801        ANDROID_API_LEVEL="$with_android_api_level"
802    fi
803
804    if test $host_cpu = arm; then
805        LLVM_TRIPLE=armv7a-linux-androideabi
806        ANDROID_SYSROOT_PLATFORM=arm-linux-androideabi
807        ANDROID_APP_ABI=armeabi-v7a
808        ANDROIDCFLAGS="-mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -Wl,--fix-cortex-a8"
809    elif test $host_cpu = aarch64; then
810        LLVM_TRIPLE=aarch64-linux-android
811        ANDROID_SYSROOT_PLATFORM=$LLVM_TRIPLE
812        ANDROID_APP_ABI=arm64-v8a
813    elif test $host_cpu = x86_64; then
814        LLVM_TRIPLE=x86_64-linux-android
815        ANDROID_SYSROOT_PLATFORM=$LLVM_TRIPLE
816        ANDROID_APP_ABI=x86_64
817    else
818        # host_cpu is something like "i386" or "i686" I guess, NDK uses
819        # "x86" in some contexts
820        LLVM_TRIPLE=i686-linux-android
821        ANDROID_SYSROOT_PLATFORM=$LLVM_TRIPLE
822        ANDROID_APP_ABI=x86
823    fi
824
825    # Set up a lot of pre-canned defaults
826
827    if test ! -f $ANDROID_NDK_DIR/RELEASE.TXT; then
828        if test ! -f $ANDROID_NDK_DIR/source.properties; then
829            AC_MSG_ERROR([Unrecognized Android NDK. Missing RELEASE.TXT or source.properties file in $ANDROID_NDK_DIR.])
830        fi
831        ANDROID_NDK_VERSION=`sed -n -e 's/Pkg.Revision = //p' $ANDROID_NDK_DIR/source.properties`
832    else
833        ANDROID_NDK_VERSION=`cut -f1 -d' ' <$ANDROID_NDK_DIR/RELEASE.TXT`
834    fi
835    if test -z "$ANDROID_NDK_VERSION";  then
836        AC_MSG_ERROR([Failed to determine Android NDK version. Please check your installation.])
837    fi
838    case $ANDROID_NDK_VERSION in
839    r9*|r10*)
840        AC_MSG_ERROR([Building for Android requires NDK version >= 27.*])
841        ;;
842    11.1.*|12.1.*|13.1.*|14.1.*|16.*|17.*|18.*|19.*|20.*|21.*|22.*|23.*|24.*|25.*|26.*)
843        AC_MSG_ERROR([Building for Android requires NDK version >= 27.*])
844        ;;
845    27.*|28.*|29.*)
846        ;;
847    *)
848        AC_MSG_WARN([Untested Android NDK version $ANDROID_NDK_VERSION, only versions 27.* to 29.* have been used successfully. Proceed at your own risk.])
849        add_warning "Untested Android NDK version $ANDROID_NDK_VERSION, only versions 27.* to 29.* have been used successfully. Proceed at your own risk."
850        ;;
851    esac
852
853    AC_MSG_NOTICE([using the Android API level... $ANDROID_API_LEVEL])
854
855    # NDK 15 or later toolchain is 64bit-only, except for Windows that we don't support. Using a 64-bit
856    # linker is required if you compile large parts of the code with -g. A 32-bit linker just won't
857    # manage to link the (app-specific) single huge .so that is built for the app in
858    # android/source/ if there is debug information in a significant part of the object files.
859    # (A 64-bit ld.gold grows too much over 10 gigabytes of virtual space when linking such a .so if
860    # all objects have been built with debug information.)
861    case $build_os in
862    linux-gnu*)
863        android_HOST_TAG=linux-x86_64
864        ;;
865    darwin*)
866        android_HOST_TAG=darwin-x86_64
867        ;;
868    *)
869        AC_MSG_ERROR([We only support building for Android from Linux or macOS])
870        # ndk would also support windows and windows-x86_64
871        ;;
872    esac
873    ANDROID_TOOLCHAIN=$ANDROID_NDK_DIR/toolchains/llvm/prebuilt/$android_HOST_TAG
874    ANDROID_COMPILER_BIN=$ANDROID_TOOLCHAIN/bin
875
876    test -z "$AR" && AR=$ANDROID_COMPILER_BIN/llvm-ar
877    test -z "$NM" && NM=$ANDROID_COMPILER_BIN/llvm-nm
878    test -z "$OBJDUMP" && OBJDUMP=$ANDROID_COMPILER_BIN/llvm-objdump
879    test -z "$RANLIB" && RANLIB=$ANDROID_COMPILER_BIN/llvm-ranlib
880    test -z "$STRIP" && STRIP=$ANDROID_COMPILER_BIN/llvm-strip
881
882    ANDROIDCFLAGS="$ANDROIDCFLAGS -target ${LLVM_TRIPLE}${ANDROID_API_LEVEL}"
883    ANDROIDCFLAGS="$ANDROIDCFLAGS -no-canonical-prefixes -ffunction-sections -fdata-sections -Qunused-arguments"
884    if test "$ENABLE_LTO" = TRUE; then
885        # -flto comes from com_GCC_defs.mk, too, but we need to make sure it gets passed as part of
886        # $CC and $CXX when building external libraries
887        ANDROIDCFLAGS="$ANDROIDCFLAGS -flto -fuse-linker-plugin -O2"
888    fi
889
890    ANDROIDCXXFLAGS="$ANDROIDCFLAGS -stdlib=libc++"
891
892    if test -z "$CC"; then
893        CC="$ANDROID_COMPILER_BIN/clang $ANDROIDCFLAGS"
894        CC_BASE="clang"
895    fi
896    if test -z "$CXX"; then
897        CXX="$ANDROID_COMPILER_BIN/clang++ $ANDROIDCXXFLAGS"
898        CXX_BASE="clang++"
899    fi
900fi
901AC_SUBST(ANDROID_NDK_DIR)
902AC_SUBST(ANDROID_NDK_VERSION)
903AC_SUBST(ANDROID_API_LEVEL)
904AC_SUBST(ANDROID_APP_ABI)
905AC_SUBST(ANDROID_SYSROOT_PLATFORM)
906AC_SUBST(ANDROID_TOOLCHAIN)
907
908dnl ===================================================================
909dnl --with-android-sdk
910dnl ===================================================================
911ANDROID_SDK_DIR=
912if test -z "$with_android_sdk" -a -e "$SRC_ROOT/external/android-sdk-linux" -a "$build" != "$host"; then
913    with_android_sdk="$SRC_ROOT/external/android-sdk-linux"
914fi
915if test -n "$with_android_sdk"; then
916    eval ANDROID_SDK_DIR=$with_android_sdk
917    PATH="$ANDROID_SDK_DIR/platform-tools:$ANDROID_SDK_DIR/tools:$PATH"
918fi
919AC_SUBST(ANDROID_SDK_DIR)
920
921AC_ARG_ENABLE([android-lok],
922    AS_HELP_STRING([--enable-android-lok],
923        [The Android app from the android/ subdir needs several tweaks all
924         over the place that break the LOK when used in the Online-based
925         Android app.  This switch indicates that the intent of this build is
926         actually the Online-based, non-modified LOK.])
927)
928ENABLE_ANDROID_LOK=
929if test -n "$ANDROID_NDK_DIR" ; then
930    if test "$enable_android_lok" = yes; then
931        ENABLE_ANDROID_LOK=TRUE
932        AC_DEFINE(HAVE_FEATURE_ANDROID_LOK)
933        AC_MSG_NOTICE([building the Android version... for the Online-based Android app])
934    else
935        AC_MSG_NOTICE([building the Android version... for the app from the android/ subdir])
936    fi
937fi
938AC_SUBST([ENABLE_ANDROID_LOK])
939
940libo_FUZZ_ARG_ENABLE([android-editing],
941    AS_HELP_STRING([--enable-android-editing],
942        [Enable the experimental editing feature on Android.])
943)
944ENABLE_ANDROID_EDITING=
945if test "$enable_android_editing" = yes; then
946    ENABLE_ANDROID_EDITING=TRUE
947fi
948AC_SUBST([ENABLE_ANDROID_EDITING])
949
950disable_database_connectivity_dependencies()
951{
952    enable_evolution2=no
953    enable_firebird_sdbc=no
954    enable_mariadb_sdbc=no
955    enable_postgresql_sdbc=no
956    enable_report_builder=no
957}
958
959# ===================================================================
960#
961# Start initial platform setup
962#
963# The using_* variables reflect platform support and should not be
964# changed after the "End initial platform setup" block.
965# This is also true for most test_* variables.
966# ===================================================================
967build_crypto=yes
968test_clucene=no
969test_gdb_index=no
970test_openldap=yes
971test_split_debug=no
972test_webdav=yes
973usable_dlapi=yes
974
975# There is currently just iOS not using salplug, so this explicitly enables it.
976# must: using_freetype_fontconfig
977#  may: using_headless_plugin defaults to $using_freetype_fontconfig
978# must: using_x11
979
980# Default values, as such probably valid just for Linux, set
981# differently below just for Mac OSX, but at least better than
982# hardcoding these as we used to do. Much of this is duplicated also
983# in solenv for old build system and for gbuild, ideally we should
984# perhaps define stuff like this only here in configure.ac?
985
986LINKFLAGSSHL="-shared"
987PICSWITCH="-fpic"
988DLLPOST=".so"
989
990LINKFLAGSNOUNDEFS="-Wl,-z,defs"
991
992INSTROOTBASESUFFIX=
993INSTROOTCONTENTSUFFIX=
994SDKDIRNAME=sdk
995
996HOST_PLATFORM="$host"
997
998host_cpu_for_clang="$host_cpu"
999
1000case "$host_os" in
1001
1002solaris*)
1003    using_freetype_fontconfig=yes
1004    using_x11=yes
1005    build_skia=yes
1006    _os=SunOS
1007
1008    dnl ===========================================================
1009    dnl Check whether we're using Solaris 10 - SPARC or Intel.
1010    dnl ===========================================================
1011    AC_MSG_CHECKING([the Solaris operating system release])
1012    _os_release=`echo $host_os | $SED -e s/solaris2\.//`
1013    if test "$_os_release" -lt "10"; then
1014        AC_MSG_ERROR([use Solaris >= 10 to build LibreOffice])
1015    else
1016        AC_MSG_RESULT([ok ($_os_release)])
1017    fi
1018
1019    dnl Check whether we're using a SPARC or i386 processor
1020    AC_MSG_CHECKING([the processor type])
1021    if test "$host_cpu" = "sparc" -o "$host_cpu" = "i386"; then
1022        AC_MSG_RESULT([ok ($host_cpu)])
1023    else
1024        AC_MSG_ERROR([only SPARC and i386 processors are supported])
1025    fi
1026    ;;
1027
1028linux-gnu*|k*bsd*-gnu*|linux-musl*)
1029    using_freetype_fontconfig=yes
1030    using_x11=yes
1031    build_skia=yes
1032    test_gdb_index=yes
1033    test_split_debug=yes
1034    if test "$enable_fuzzers" = yes; then
1035        test_system_freetype=no
1036    fi
1037    _os=Linux
1038    ;;
1039
1040gnu)
1041    using_freetype_fontconfig=yes
1042    using_x11=no
1043    _os=GNU
1044     ;;
1045
1046cygwin*|wsl*)
1047    # When building on Windows normally with MSVC under Cygwin,
1048    # configure thinks that the host platform (the platform the
1049    # built code will run on) is Cygwin, even if it obviously is
1050    # Windows, which in Autoconf terminology is called
1051    # "mingw32". (Which is misleading as MinGW is the name of the
1052    # tool-chain, not an operating system.)
1053
1054    # Somewhat confusing, yes. But this configure script doesn't
1055    # look at $host etc that much, it mostly uses its own $_os
1056    # variable, set here in this case statement.
1057
1058    using_freetype_fontconfig=no
1059    using_x11=no
1060    test_unix_dlapi=no
1061    test_openldap=no
1062    enable_pagein=no
1063    build_skia=yes
1064    _os=WINNT
1065
1066    DLLPOST=".dll"
1067    LINKFLAGSNOUNDEFS=
1068    # bypass check for ninja, it is not in default path, but it can be used nevertheless by default
1069    NINJA="assumed to be available from Visual Studio"
1070
1071    if test "$host_cpu" = "aarch64"; then
1072        build_skia=yes
1073        enable_gpgmepp=no
1074        enable_coinmp=no
1075        enable_firebird_sdbc=no
1076    fi
1077    ;;
1078
1079darwin*) # macOS
1080    using_freetype_fontconfig=no
1081    using_x11=no
1082    build_skia=yes
1083    enable_pagein=no
1084    if test -n "$LODE_HOME" ; then
1085        mac_sanitize_path
1086        AC_MSG_NOTICE([sanitized the PATH to $PATH])
1087    fi
1088    _os=Darwin
1089    INSTROOTBASESUFFIX=/$PRODUCTNAME_WITHOUT_SPACES.app
1090    INSTROOTCONTENTSUFFIX=/Contents
1091    SDKDIRNAME=${PRODUCTNAME_WITHOUT_SPACES}${PRODUCTVERSION}_SDK
1092    # See "Default values, as such probably valid just for Linux" comment above the case "$host_os"
1093    LINKFLAGSSHL="-dynamiclib"
1094
1095    # -fPIC is default
1096    PICSWITCH=""
1097
1098    DLLPOST=".dylib"
1099
1100    # -undefined error is the default
1101    LINKFLAGSNOUNDEFS=""
1102    case "$host_cpu" in
1103    aarch64|arm64)
1104        # Apple's Clang uses "arm64"
1105        host_cpu_for_clang=arm64
1106    esac
1107;;
1108
1109ios*) # iOS
1110    using_freetype_fontconfig=no
1111    using_x11=no
1112    build_crypto=no
1113    test_libcmis=no
1114    test_openldap=no
1115    test_webdav=no
1116    with_gssapi=no
1117    if test -n "$LODE_HOME" ; then
1118        mac_sanitize_path
1119        AC_MSG_NOTICE([sanitized the PATH to $PATH])
1120    fi
1121    enable_gpgmepp=no
1122    _os=iOS
1123    enable_mpl_subset=yes
1124    enable_lotuswordpro=no
1125    disable_database_connectivity_dependencies
1126    enable_coinmp=no
1127    enable_lpsolve=no
1128    enable_extension_integration=no
1129    enable_xmlhelp=no
1130    with_ppds=no
1131    if test "$enable_ios_simulator" = "yes"; then
1132        host=x86_64-apple-darwin
1133    fi
1134    # See "Default values, as such probably valid just for Linux" comment above the case "$host_os"
1135    LINKFLAGSSHL="-dynamiclib"
1136
1137    # -fPIC is default
1138    PICSWITCH=""
1139
1140    DLLPOST=".dylib"
1141
1142    # -undefined error is the default
1143    LINKFLAGSNOUNDEFS=""
1144
1145    # HOST_PLATFORM is used for external projects and their configury typically doesn't like the "ios"
1146    # part, so use aarch64-apple-darwin for now.
1147    HOST_PLATFORM=aarch64-apple-darwin
1148
1149    # Apple's Clang uses "arm64"
1150    host_cpu_for_clang=arm64
1151;;
1152
1153freebsd*)
1154    using_freetype_fontconfig=yes
1155    using_x11=yes
1156    build_skia=yes
1157    AC_MSG_CHECKING([the FreeBSD operating system release])
1158    if test -n "$with_os_version"; then
1159        OSVERSION="$with_os_version"
1160    else
1161        OSVERSION=`/sbin/sysctl -n kern.osreldate`
1162    fi
1163    AC_MSG_RESULT([found OSVERSION=$OSVERSION])
1164    AC_MSG_CHECKING([which thread library to use])
1165    if test "$OSVERSION" -lt "500016"; then
1166        PTHREAD_CFLAGS="-D_THREAD_SAFE"
1167        PTHREAD_LIBS="-pthread"
1168    elif test "$OSVERSION" -lt "502102"; then
1169        PTHREAD_CFLAGS="-D_THREAD_SAFE"
1170        PTHREAD_LIBS="-lc_r"
1171    else
1172        PTHREAD_CFLAGS=""
1173        PTHREAD_LIBS="-pthread"
1174    fi
1175    AC_MSG_RESULT([$PTHREAD_LIBS])
1176    _os=FreeBSD
1177    ;;
1178
1179*netbsd*)
1180    using_freetype_fontconfig=yes
1181    using_x11=yes
1182    test_gtk3_kde5=no
1183    build_skia=yes
1184    PTHREAD_LIBS="-pthread -lpthread"
1185    _os=NetBSD
1186    ;;
1187
1188openbsd*)
1189    using_freetype_fontconfig=yes
1190    using_x11=yes
1191    PTHREAD_CFLAGS="-D_THREAD_SAFE"
1192    PTHREAD_LIBS="-pthread"
1193    _os=OpenBSD
1194    ;;
1195
1196dragonfly*)
1197    using_freetype_fontconfig=yes
1198    using_x11=yes
1199    build_skia=yes
1200    PTHREAD_LIBS="-pthread"
1201    _os=DragonFly
1202    ;;
1203
1204linux-android*)
1205    # API exists, but seems not really usable since Android 7 AFAIK
1206    usable_dlapi=no
1207    using_freetype_fontconfig=yes
1208    using_headless_plugin=no
1209    using_x11=no
1210    build_crypto=no
1211    test_openldap=no
1212    test_system_freetype=no
1213    test_webdav=no
1214    with_gssapi=no
1215    disable_database_connectivity_dependencies
1216    enable_lotuswordpro=no
1217    enable_mpl_subset=yes
1218    enable_cairo_canvas=no
1219    enable_coinmp=yes
1220    enable_lpsolve=no
1221    enable_odk=no
1222    enable_python=no
1223    enable_xmlhelp=no
1224    _os=Android
1225    ;;
1226
1227haiku*)
1228    using_freetype_fontconfig=yes
1229    using_x11=no
1230    test_gtk3=no
1231    test_gtk3_kde5=no
1232    test_kf5=yes
1233    test_kf6=yes
1234    enable_odk=no
1235    enable_coinmp=no
1236    enable_pdfium=no
1237    enable_sdremote=no
1238    enable_postgresql_sdbc=no
1239    enable_firebird_sdbc=no
1240    _os=Haiku
1241    ;;
1242
1243emscripten)
1244    # API currently just exists in headers, not code
1245    usable_dlapi=no
1246    using_freetype_fontconfig=yes
1247    using_x11=yes
1248    test_openldap=no
1249    test_qt5=yes
1250    test_split_debug=yes
1251    test_system_freetype=no
1252    enable_compiler_plugins=no
1253    enable_customtarget_components=yes
1254    enable_split_debug=yes
1255    enable_wasm_strip=yes
1256    with_system_zlib=no
1257    with_theme="colibre"
1258    _os=Emscripten
1259    ;;
1260
1261*)
1262    AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice for!])
1263    ;;
1264esac
1265
1266AC_SUBST(HOST_PLATFORM)
1267
1268if test -z "$using_x11" -o -z "$using_freetype_fontconfig"; then
1269    AC_MSG_ERROR([You must set \$using_freetype_fontconfig and \$using_x11 for your platform])
1270fi
1271
1272# Set defaults, if not set by platform
1273test "${test_cpdb+set}" = set || test_cpdb="$using_x11"
1274test "${test_cups+set}" = set || test_cups="$using_x11"
1275test "${test_dbus+set}" = set || test_dbus="$using_x11"
1276test "${test_gen+set}" = set || test_gen="$using_x11"
1277test "${test_gstreamer_1_0+set}" = set || test_gstreamer_1_0="$using_x11"
1278test "${test_gtk3+set}" = set || test_gtk3="$using_x11"
1279test "${test_gtk4+set}" = set || test_gtk4="$using_x11"
1280test "${test_kf5+set}" = set || test_kf5="$using_x11"
1281test "${test_kf6+set}" = set || test_kf6="$using_x11"
1282# don't handle test_qt5, so it can disable test_kf5 later
1283test "${test_qt6+set}" = set || test_qt6="$using_x11"
1284test "${test_randr+set}" = set || test_randr="$using_x11"
1285test "${test_xrender+set}" = set || test_xrender="$using_x11"
1286test "${using_headless_plugin+set}" = set || using_headless_plugin="$using_freetype_fontconfig"
1287
1288test "${test_gtk3_kde5+set}" != set -a "$test_kf5" = yes -a "$test_gtk3" = yes && test_gtk3_kde5="yes"
1289# Make sure fontconfig and freetype test both either system or not
1290test "${test_system_fontconfig+set}" != set -a "${test_system_freetype+set}" = set && test_system_fontconfig="$test_system_freetype"
1291test "${test_system_freetype+set}" != set -a "${test_system_fontconfig+set}" = set && test_system_freetype="$test_system_fontconfig"
1292
1293# convenience / platform overriding "fixes"
1294# Don't sort!
1295test "$test_kf5" = yes -a "$test_qt5" = no && test_kf5=no
1296test "$test_kf5" = yes && test_qt5=yes
1297test "$test_gtk3" != yes && enable_gtk3=no
1298test "$test_gtk3" != yes -o "$test_kf5" != yes && test_gtk3_kde5=no
1299test "$using_freetype_fontconfig" = no && using_headless_plugin=no
1300test "$using_freetype_fontconfig" = yes && test_cairo=yes
1301
1302# Keep in sync with the above $using_x11 depending test default list
1303disable_x11_tests()
1304{
1305    test_cpdb=no
1306    test_cups=no
1307    test_dbus=no
1308    test_gen=no
1309    test_gstreamer_1_0=no
1310    test_gtk3_kde5=no
1311    test_gtk3=no
1312    test_gtk4=no
1313    test_kf5=no
1314    test_kf6=no
1315    test_qt5=no
1316    test_qt6=no
1317    test_randr=no
1318    test_xrender=no
1319}
1320
1321test "$using_x11" = yes && USING_X11=TRUE
1322
1323if test "$using_freetype_fontconfig" = yes; then
1324    AC_DEFINE(USE_HEADLESS_CODE)
1325    USE_HEADLESS_CODE=TRUE
1326    if test "$using_headless_plugin" = yes; then
1327        AC_DEFINE(ENABLE_HEADLESS)
1328        ENABLE_HEADLESS=TRUE
1329    fi
1330else
1331    test_fontconfig=no
1332    test_freetype=no
1333fi
1334
1335AC_SUBST(ENABLE_HEADLESS)
1336AC_SUBST(USE_HEADLESS_CODE)
1337
1338AC_MSG_NOTICE([VCL platform has a usable dynamic loading API: $usable_dlapi])
1339AC_MSG_NOTICE([VCL platform uses freetype+fontconfig: $using_freetype_fontconfig])
1340AC_MSG_NOTICE([VCL platform uses headless plugin: $using_headless_plugin])
1341AC_MSG_NOTICE([VCL platform uses X11: $using_x11])
1342
1343# ===================================================================
1344#
1345# End initial platform setup
1346#
1347# ===================================================================
1348
1349if test "$_os" = "Android" ; then
1350    # Verify that the NDK and SDK options are proper
1351    if test -z "$with_android_ndk"; then
1352        AC_MSG_ERROR([the --with-android-ndk option is mandatory, unless it is available at external/android-ndk/.])
1353    elif test ! -f "$ANDROID_NDK_DIR/meta/abis.json"; then
1354        AC_MSG_ERROR([the --with-android-ndk option does not point to an Android NDK])
1355    fi
1356
1357    if test -z "$ANDROID_SDK_DIR"; then
1358        AC_MSG_ERROR([the --with-android-sdk option is mandatory, unless it is available at external/android-sdk-linux/.])
1359    elif test ! -d "$ANDROID_SDK_DIR/platforms"; then
1360        AC_MSG_ERROR([the --with-android-sdk option does not point to an Android SDK])
1361    fi
1362fi
1363
1364AC_SUBST(SDKDIRNAME)
1365
1366AC_SUBST(PTHREAD_CFLAGS)
1367AC_SUBST(PTHREAD_LIBS)
1368
1369# Check for explicit A/C/CXX/OBJC/OBJCXX/LDFLAGS.
1370# By default use the ones specified by our build system,
1371# but explicit override is possible.
1372AC_MSG_CHECKING(for explicit AFLAGS)
1373if test -n "$AFLAGS"; then
1374    AC_MSG_RESULT([$AFLAGS])
1375    x_AFLAGS=
1376else
1377    AC_MSG_RESULT(no)
1378    x_AFLAGS=[\#]
1379fi
1380AC_MSG_CHECKING(for explicit CFLAGS)
1381if test -n "$CFLAGS"; then
1382    AC_MSG_RESULT([$CFLAGS])
1383    x_CFLAGS=
1384else
1385    AC_MSG_RESULT(no)
1386    x_CFLAGS=[\#]
1387fi
1388AC_MSG_CHECKING(for explicit CXXFLAGS)
1389if test -n "$CXXFLAGS"; then
1390    AC_MSG_RESULT([$CXXFLAGS])
1391    x_CXXFLAGS=
1392else
1393    AC_MSG_RESULT(no)
1394    x_CXXFLAGS=[\#]
1395fi
1396AC_MSG_CHECKING(for explicit OBJCFLAGS)
1397if test -n "$OBJCFLAGS"; then
1398    AC_MSG_RESULT([$OBJCFLAGS])
1399    x_OBJCFLAGS=
1400else
1401    AC_MSG_RESULT(no)
1402    x_OBJCFLAGS=[\#]
1403fi
1404AC_MSG_CHECKING(for explicit OBJCXXFLAGS)
1405if test -n "$OBJCXXFLAGS"; then
1406    AC_MSG_RESULT([$OBJCXXFLAGS])
1407    x_OBJCXXFLAGS=
1408else
1409    AC_MSG_RESULT(no)
1410    x_OBJCXXFLAGS=[\#]
1411fi
1412AC_MSG_CHECKING(for explicit LDFLAGS)
1413if test -n "$LDFLAGS"; then
1414    AC_MSG_RESULT([$LDFLAGS])
1415    x_LDFLAGS=
1416else
1417    AC_MSG_RESULT(no)
1418    x_LDFLAGS=[\#]
1419fi
1420AC_SUBST(AFLAGS)
1421AC_SUBST(CFLAGS)
1422AC_SUBST(CXXFLAGS)
1423AC_SUBST(OBJCFLAGS)
1424AC_SUBST(OBJCXXFLAGS)
1425AC_SUBST(LDFLAGS)
1426AC_SUBST(x_AFLAGS)
1427AC_SUBST(x_CFLAGS)
1428AC_SUBST(x_CXXFLAGS)
1429AC_SUBST(x_OBJCFLAGS)
1430AC_SUBST(x_OBJCXXFLAGS)
1431AC_SUBST(x_LDFLAGS)
1432
1433dnl These are potentially set for MSVC, in the code checking for UCRT below:
1434my_original_CFLAGS=$CFLAGS
1435my_original_CXXFLAGS=$CXXFLAGS
1436my_original_CPPFLAGS=$CPPFLAGS
1437
1438dnl The following checks for gcc, cc and then cl (if it weren't guarded for win32)
1439dnl Needs to precede the AC_C_BIGENDIAN and AC_SEARCH_LIBS calls below, which apparently call
1440dnl AC_PROG_CC internally.
1441if test "$_os" != "WINNT"; then
1442    # AC_PROG_CC sets CFLAGS to -g -O2 if not set, avoid that (and avoid -O2 during AC_PROG_CC,
1443    # Clang 12.0.1 occasionally SEGVs on some of the test invocations during AC_PROG_CC with -O2):
1444    save_CFLAGS=$CFLAGS
1445    CFLAGS=-g
1446    AC_PROG_CC
1447    CFLAGS=$save_CFLAGS
1448    if test -z "$CC_BASE"; then
1449        CC_BASE=`first_arg_basename "$CC"`
1450    fi
1451fi
1452
1453if test "$_os" != "WINNT"; then
1454    AC_C_BIGENDIAN([ENDIANNESS=big], [ENDIANNESS=little])
1455else
1456    ENDIANNESS=little
1457fi
1458AC_SUBST(ENDIANNESS)
1459
1460if test "$usable_dlapi" != no; then
1461    AC_DEFINE([HAVE_DLAPI])
1462    if test "$test_unix_dlapi" != no; then
1463        save_LIBS="$LIBS"
1464        AC_SEARCH_LIBS([dlsym], [dl],
1465            [case "$ac_cv_search_dlsym" in -l*) UNIX_DLAPI_LIBS="$ac_cv_search_dlsym";; esac],
1466            [AC_MSG_ERROR([dlsym not found in either libc nor libdl])])
1467        LIBS="$save_LIBS"
1468        AC_DEFINE([HAVE_UNIX_DLAPI])
1469    fi
1470fi
1471AC_SUBST(UNIX_DLAPI_LIBS)
1472
1473# Check for a (GNU) backtrace implementation
1474AC_ARG_VAR([BACKTRACE_CFLAGS], [Compiler flags needed to use backtrace(3)])
1475AC_ARG_VAR([BACKTRACE_LIBS], [Linker flags needed to use backtrace(3)])
1476AS_IF([test "x$BACKTRACE_LIBS$BACKTRACE_CFLAGS" = x], [
1477    save_LIBS="$LIBS"
1478    AC_SEARCH_LIBS([backtrace], [libexecinfo],
1479        [case "$ac_cv_search_backtrace" in -l*) BACKTRACE_LIBS="$ac_cv_search_backtrace";; esac],
1480        [PKG_CHECK_MODULES([BACKTRACE], [libexecinfo], [ac_cv_search_backtrace=], [:])])
1481    LIBS="$save_LIBS"
1482])
1483AS_IF([test "x$ac_cv_search_backtrace" != xno ], [
1484    AC_DEFINE([HAVE_FEATURE_BACKTRACE])
1485])
1486
1487dnl ===================================================================
1488dnl Sanity checks for Emscripten SDK setup
1489dnl ===================================================================
1490
1491EMSCRIPTEN_MIN_MAJOR=3
1492EMSCRIPTEN_MIN_MINOR=1
1493EMSCRIPTEN_MIN_TINY=46
1494EMSCRIPTEN_MIN_VERSION="${EMSCRIPTEN_MIN_MAJOR}.${EMSCRIPTEN_MIN_MINOR}.${EMSCRIPTEN_MIN_TINY}"
1495
1496EMSCRIPTEN_WORKERJS=
1497if test "$_os" = "Emscripten"; then
1498    AC_MSG_CHECKING([if Emscripten is at least $EMSCRIPTEN_MIN_VERSION])
1499    if test -z "$EMSCRIPTEN_VERSION_H"; then
1500        AS_IF([test -z "$EMSDK"],
1501              [AC_MSG_ERROR([No \$EMSDK environment variable.])])
1502        EMSCRIPTEN_VERSION_H=$EMSDK/upstream/emscripten/cache/sysroot/include/emscripten/version.h
1503        if test ! -f "$EMSCRIPTEN_VERSION_H"; then
1504            EMSCRIPTEN_VERSION_H=$EMSDK/emscripten/main/cache/sysroot/include/emscripten/version.h
1505        fi
1506    fi
1507    if test -f "$EMSCRIPTEN_VERSION_H"; then
1508        EMSCRIPTEN_MAJOR=$($GREP __EMSCRIPTEN_major__ "$EMSCRIPTEN_VERSION_H" | $SED -ne 's/.*__EMSCRIPTEN_major__ //p')
1509        EMSCRIPTEN_MINOR=$($GREP __EMSCRIPTEN_minor__ "$EMSCRIPTEN_VERSION_H" | $SED -ne 's/.*__EMSCRIPTEN_minor__ //p')
1510        EMSCRIPTEN_TINY=$($GREP __EMSCRIPTEN_tiny__ "$EMSCRIPTEN_VERSION_H" | $SED -ne 's/.*__EMSCRIPTEN_tiny__ //p')
1511    else
1512        EMSCRIPTEN_DEFINES=$(echo | emcc -dM -E - | $GREP __EMSCRIPTEN_)
1513        EMSCRIPTEN_MAJOR=$(echo "$EMSCRIPTEN_DEFINES" | $SED -ne 's/.*__EMSCRIPTEN_major__ //p')
1514        EMSCRIPTEN_MINOR=$(echo "$EMSCRIPTEN_DEFINES" | $SED -ne 's/.*__EMSCRIPTEN_minor__ //p')
1515        EMSCRIPTEN_TINY=$(echo "$EMSCRIPTEN_DEFINES" | $SED -ne 's/.*__EMSCRIPTEN_tiny__ //p')
1516    fi
1517
1518    EMSCRIPTEN_VERSION="${EMSCRIPTEN_MAJOR}.${EMSCRIPTEN_MINOR}.${EMSCRIPTEN_TINY}"
1519
1520    check_semantic_version_three_prefixed EMSCRIPTEN MIN
1521    if test $? -eq 0; then
1522        AC_MSG_RESULT([yes ($EMSCRIPTEN_VERSION)])
1523    else
1524        AC_MSG_ERROR([no, found $EMSCRIPTEN_VERSION])
1525    fi
1526
1527    EMSCRIPTEN_ERROR=0
1528    if ! command -v emconfigure >/dev/null 2>&1; then
1529        AC_MSG_WARN([emconfigure must be in your \$PATH])
1530        EMSCRIPTEN_ERROR=1
1531    fi
1532    if test -z "$EMMAKEN_JUST_CONFIGURE"; then
1533        AC_MSG_WARN(["\$EMMAKEN_JUST_CONFIGURE wasn't set by emconfigure. Prefix configure or use autogen.sh])
1534        EMSCRIPTEN_ERROR=1
1535    fi
1536    EMSDK_FILE_PACKAGER="$(em-config EMSCRIPTEN_ROOT)"/tools/file_packager
1537    if ! test -x "$EMSDK_FILE_PACKAGER"; then
1538        AC_MSG_WARN([No file_packager found in $(em-config EMSCRIPTEN_ROOT)/tools/file_packager.])
1539        EMSCRIPTEN_ERROR=1
1540    fi
1541    if test $EMSCRIPTEN_ERROR -ne 0; then
1542        AC_MSG_ERROR(["Please fix your EMSDK setup to build with Emscripten!"])
1543    fi
1544
1545    dnl Some build-side things are conditional on "EMSCRIPTEN in BUILD_TYPE_FOR_HOST":
1546    BUILD_TYPE="$BUILD_TYPE EMSCRIPTEN"
1547
1548    dnl Generation of .worker.js files has been dropped completely from Emscripten 3.1.68, and the
1549    dnl generated files were just unused dummies since Emscripten 3.1.58:
1550    AC_MSG_CHECKING([if Emscripten still depends on a separate .worker.js file])
1551    check_semantic_version_three 3 1 58 "$EMSCRIPTEN_MAJOR" "$EMSCRIPTEN_MINOR" "$EMSCRIPTEN_TINY"
1552    if test $? -ne 0; then
1553        AC_MSG_RESULT([yes])
1554        EMSCRIPTEN_WORKERJS=TRUE
1555    else
1556        AC_MSG_RESULT([no])
1557    fi
1558fi
1559AC_SUBST(EMSDK_FILE_PACKAGER)
1560AC_SUBST(EMSCRIPTEN_EXTRA_QTLOADER_CONFIG)
1561AC_SUBST(EMSCRIPTEN_EXTRA_SOFFICE_PRE_JS)
1562AC_SUBST(EMSCRIPTEN_WORKERJS)
1563
1564###############################################################################
1565# Extensions switches --enable/--disable
1566###############################################################################
1567# By default these should be enabled unless having extra dependencies.
1568# If there is extra dependency over configure options then the enable should
1569# be automagic based on whether the requiring feature is enabled or not.
1570# All this options change anything only with --enable-extension-integration.
1571
1572# The name of this option and its help string makes it sound as if
1573# extensions are built anyway, just not integrated in the installer,
1574# if you use --disable-extension-integration. Is that really the
1575# case?
1576
1577AC_ARG_ENABLE(ios-simulator,
1578    AS_HELP_STRING([--enable-ios-simulator],
1579        [build for iOS simulator])
1580)
1581
1582libo_FUZZ_ARG_ENABLE(extension-integration,
1583    AS_HELP_STRING([--disable-extension-integration],
1584        [Disable integration of the built extensions in the installer of the
1585         product. Use this switch to disable the integration.])
1586)
1587
1588AC_ARG_ENABLE(avmedia,
1589    AS_HELP_STRING([--disable-avmedia],
1590        [Disable displaying and inserting AV media in documents. Work in progress, use only if you are hacking on it.]),
1591,test "${enable_avmedia+set}" = set || enable_avmedia=yes)
1592
1593AC_ARG_ENABLE(database-connectivity,
1594    AS_HELP_STRING([--disable-database-connectivity],
1595        [Disable various database connectivity. Work in progress, use only if you are hacking on it.])
1596)
1597
1598# This doesn't mean not building (or "integrating") extensions
1599# (although it probably should; i.e. it should imply
1600# --disable-extension-integration I guess), it means not supporting
1601# any extension mechanism at all
1602libo_FUZZ_ARG_ENABLE(extensions,
1603    AS_HELP_STRING([--disable-extensions],
1604        [Disable all add-on extension functionality. Work in progress, use only if you are hacking on it.])
1605)
1606
1607AC_ARG_ENABLE(scripting,
1608    AS_HELP_STRING([--disable-scripting],
1609        [Disable BASIC, Java, Python and .NET. Work in progress, use only if you are hacking on it.]),
1610,test "${enable_scripting+set}" = set || enable_scripting=yes)
1611
1612# This is mainly for Android and iOS, but could potentially be used in some
1613# special case otherwise, too, so factored out as a separate setting
1614
1615AC_ARG_ENABLE(dynamic-loading,
1616    AS_HELP_STRING([--disable-dynamic-loading],
1617        [Disable any use of dynamic loading of code. Work in progress, use only if you are hacking on it.])
1618)
1619
1620libo_FUZZ_ARG_ENABLE(report-builder,
1621    AS_HELP_STRING([--disable-report-builder],
1622        [Disable the Report Builder.])
1623)
1624
1625libo_FUZZ_ARG_ENABLE(ext-wiki-publisher,
1626    AS_HELP_STRING([--enable-ext-wiki-publisher],
1627        [Enable the Wiki Publisher extension.])
1628)
1629
1630libo_FUZZ_ARG_ENABLE(lpsolve,
1631    AS_HELP_STRING([--disable-lpsolve],
1632        [Disable compilation of the lp solve solver ])
1633)
1634libo_FUZZ_ARG_ENABLE(coinmp,
1635    AS_HELP_STRING([--disable-coinmp],
1636        [Disable compilation of the CoinMP solver ])
1637)
1638
1639libo_FUZZ_ARG_ENABLE(pdfimport,
1640    AS_HELP_STRING([--disable-pdfimport],
1641        [Disable building the PDF import feature.])
1642)
1643
1644libo_FUZZ_ARG_ENABLE(pdfium,
1645    AS_HELP_STRING([--disable-pdfium],
1646        [Disable building PDFium. Results in insecure PDF signature verification.])
1647)
1648
1649libo_FUZZ_ARG_ENABLE(skia,
1650    AS_HELP_STRING([--disable-skia],
1651        [Disable building Skia. Use --enable-skia=debug to build without optimizations.])
1652)
1653
1654libo_FUZZ_ARG_ENABLE(skia-vulkan-validation,
1655    AS_HELP_STRING([--enable-skia-vulkan-validation],
1656        [Enable Vulkan validation layers under Skia. The Vulkan SDK must be installed externally.])
1657)
1658
1659###############################################################################
1660
1661dnl ---------- *** ----------
1662
1663libo_FUZZ_ARG_ENABLE(mergelibs,
1664    AS_HELP_STRING([--enable-mergelibs=yes/no/more],
1665        [Merge several of the smaller libraries into one big "merged" library.
1666         The "more" option will link even more of the smaller libraries.
1667         "more" not appropriate for distros which split up LibreOffice into multiple packages.
1668         It is only appropriate for situations where all of LO is delivered in a single install/package. ])
1669)
1670
1671libo_FUZZ_ARG_ENABLE(breakpad,
1672    AS_HELP_STRING([--enable-breakpad],
1673        [Enables breakpad for crash reporting.])
1674)
1675
1676libo_FUZZ_ARG_ENABLE(crashdump,
1677    AS_HELP_STRING([--disable-crashdump],
1678        [Disable dump.ini and dump-file, when --enable-breakpad])
1679)
1680
1681AC_ARG_ENABLE(fetch-external,
1682    AS_HELP_STRING([--disable-fetch-external],
1683        [Disables fetching external tarballs from web sources.])
1684)
1685
1686AC_ARG_ENABLE(fuzzers,
1687    AS_HELP_STRING([--enable-fuzzers],
1688        [Enables building libfuzzer targets for fuzz testing.])
1689)
1690
1691libo_FUZZ_ARG_ENABLE(pch,
1692    AS_HELP_STRING([--enable-pch=<yes/no/system/base/normal/full>],
1693        [Enables precompiled header support for C++. Forced default on Windows/VC build.
1694         Using 'system' will include only external headers, 'base' will add also headers
1695         from base modules, 'normal' will also add all headers except from the module built,
1696         'full' will use all suitable headers even from a module itself.])
1697)
1698
1699libo_FUZZ_ARG_ENABLE(epm,
1700    AS_HELP_STRING([--enable-epm],
1701        [LibreOffice includes self-packaging code, that requires epm, however epm is
1702         useless for large scale package building.])
1703)
1704
1705libo_FUZZ_ARG_ENABLE(odk,
1706    AS_HELP_STRING([--enable-odk],
1707        [Enable building the Office Development Kit, the part that extensions need to build against])
1708)
1709
1710AC_ARG_ENABLE(mpl-subset,
1711    AS_HELP_STRING([--enable-mpl-subset],
1712        [Don't compile any pieces which are not MPL or more liberally licensed])
1713)
1714
1715libo_FUZZ_ARG_ENABLE(evolution2,
1716    AS_HELP_STRING([--enable-evolution2],
1717        [Allows the built-in evolution 2 addressbook connectivity build to be
1718         enabled.])
1719)
1720
1721AC_ARG_ENABLE(avahi,
1722    AS_HELP_STRING([--enable-avahi],
1723        [Determines whether to use Avahi to advertise Impress to remote controls.])
1724)
1725
1726AC_ARG_ENABLE(msvc-analyze,
1727    AS_HELP_STRING([--enable-msvc-analyze],
1728        [Determines whether to enable the Microsoft Visual Studio /analyze flag to provide additional warnings.])
1729)
1730
1731libo_FUZZ_ARG_ENABLE(werror,
1732    AS_HELP_STRING([--enable-werror],
1733        [Turn warnings to errors. (Has no effect in modules where the treating
1734         of warnings as errors is disabled explicitly.)]),
1735,)
1736
1737libo_FUZZ_ARG_ENABLE(assert-always-abort,
1738    AS_HELP_STRING([--enable-assert-always-abort],
1739        [make assert() failures abort even when building without --enable-debug or --enable-dbgutil.]),
1740,)
1741
1742libo_FUZZ_ARG_ENABLE(dbgutil,
1743    AS_HELP_STRING([--enable-dbgutil],
1744        [Provide debugging support from --enable-debug and include additional debugging
1745         utilities such as object counting or more expensive checks.
1746         This is the recommended option for developers.
1747         Note that this makes the build ABI incompatible, it is not possible to mix object
1748         files or libraries from a --enable-dbgutil and a --disable-dbgutil build.]))
1749
1750libo_FUZZ_ARG_ENABLE(debug,
1751    AS_HELP_STRING([--enable-debug],
1752        [Include debugging information, disable compiler optimization and inlining plus
1753         extra debugging code like assertions. Extra large build! (enables -g compiler flag).]))
1754
1755libo_FUZZ_ARG_ENABLE(split-debug,
1756    AS_HELP_STRING([--disable-split-debug],
1757        [Disable using split debug information (-gsplit-dwarf compile flag). Split debug information
1758         saves disk space and build time, but requires tools that support it (both build tools and debuggers).]))
1759
1760libo_FUZZ_ARG_ENABLE(gdb-index,
1761    AS_HELP_STRING([--disable-gdb-index],
1762        [Disables creating debug information in the gdb index format, which makes gdb start faster.
1763         The feature requires a linker that supports the --gdb-index option.]))
1764
1765libo_FUZZ_ARG_ENABLE(sal-log,
1766    AS_HELP_STRING([--enable-sal-log],
1767        [Make SAL_INFO and SAL_WARN calls do something even in a non-debug build.]))
1768
1769libo_FUZZ_ARG_ENABLE(symbols,
1770    AS_HELP_STRING([--enable-symbols],
1771        [Generate debug information.
1772         By default, enabled for --enable-debug and --enable-dbgutil, disabled
1773         otherwise. It is possible to explicitly specify gbuild build targets
1774         (where 'all' means everything, '-' prepended means to not enable, '/' appended means
1775         everything in the directory; there is no ordering, more specific overrides
1776         more general, and disabling takes precedence).
1777         Example: --enable-symbols="all -sw/ -Library_sc".]))
1778
1779libo_FUZZ_ARG_ENABLE(optimized,
1780    AS_HELP_STRING([--enable-optimized=<yes/no/debug>],
1781        [Whether to compile with optimization flags.
1782         By default, disabled for --enable-debug and --enable-dbgutil, enabled
1783         otherwise. Using 'debug' will try to use only optimizations that should
1784         not interfere with debugging. For Emscripten we default to optimized (-O1)
1785         debug build, as otherwise binaries become too large.]))
1786
1787libo_FUZZ_ARG_ENABLE(runtime-optimizations,
1788    AS_HELP_STRING([--disable-runtime-optimizations],
1789        [Statically disable certain runtime optimizations (like rtl/alloc.h or
1790         JVM JIT) that are known to interact badly with certain dynamic analysis
1791         tools (like -fsanitize=address or Valgrind).  By default, disabled iff
1792         CC contains "-fsanitize=*".  (For Valgrind, those runtime optimizations
1793         are typically disabled dynamically via RUNNING_ON_VALGRIND.)]))
1794
1795AC_ARG_WITH(valgrind,
1796    AS_HELP_STRING([--with-valgrind],
1797        [Make availability of Valgrind headers a hard requirement.]))
1798
1799libo_FUZZ_ARG_ENABLE(compiler-plugins,
1800    AS_HELP_STRING([--enable-compiler-plugins],
1801        [Enable compiler plugins that will perform additional checks during
1802         building. Enabled automatically by --enable-dbgutil.
1803         Use --enable-compiler-plugins=debug to also enable debug code in the plugins.]))
1804COMPILER_PLUGINS_DEBUG=
1805if test "$enable_compiler_plugins" = debug; then
1806    enable_compiler_plugins=yes
1807    COMPILER_PLUGINS_DEBUG=TRUE
1808fi
1809
1810libo_FUZZ_ARG_ENABLE(compiler-plugins-analyzer-pch,
1811    AS_HELP_STRING([--disable-compiler-plugins-analyzer-pch],
1812        [Disable use of precompiled headers when running the Clang compiler plugin analyzer.  Not
1813         relevant in the --disable-compiler-plugins case.]))
1814
1815libo_FUZZ_ARG_ENABLE(ooenv,
1816    AS_HELP_STRING([--enable-ooenv],
1817        [Enable ooenv for the instdir installation.]))
1818
1819AC_ARG_ENABLE(lto,
1820    AS_HELP_STRING([--enable-lto],
1821        [Enable link-time optimization. Suitable for (optimised) product builds. Building might take
1822         longer but libraries and executables are optimized for speed. For GCC, best to use the 'gold'
1823         linker.)]))
1824
1825AC_ARG_ENABLE(gcov,
1826    AS_HELP_STRING([--enable-gcov],
1827        [Enable compiler/linker flags to enable code coverage analysis via GCC's gcov.
1828         Avoid also using --enable-lto, that'll likely fail to link]))
1829
1830AC_ARG_ENABLE(python,
1831    AS_HELP_STRING([--enable-python=<no/auto/system/internal/fully-internal>],
1832        [Enables or disables Python support at run-time.
1833         Also specifies what Python to use at build-time.
1834         'fully-internal' even forces the internal version for uses of Python
1835         during the build.
1836         On macOS the only choices are
1837         'internal' (default) or 'fully-internal'. Otherwise the default is 'auto'.
1838         ]))
1839
1840libo_FUZZ_ARG_ENABLE(gtk3,
1841    AS_HELP_STRING([--disable-gtk3],
1842        [Determines whether to use Gtk+ 3.0 vclplug on platforms where Gtk+ 3.0 is available.]),
1843,test "${test_gtk3}" = no -o "${enable_gtk3+set}" = set || enable_gtk3=yes)
1844
1845AC_ARG_ENABLE(gtk4,
1846    AS_HELP_STRING([--enable-gtk4],
1847        [Determines whether to use Gtk+ 4.0 vclplug on platforms where Gtk+ 4.0 is available.]))
1848
1849AC_ARG_ENABLE(atspi-tests,
1850    AS_HELP_STRING([--disable-atspi-tests],
1851        [Determines whether to enable AT-SPI2 tests for the GTK3 vclplug.]))
1852
1853AC_ARG_ENABLE(introspection,
1854    AS_HELP_STRING([--enable-introspection],
1855        [Generate files for GObject introspection.  Requires --enable-gtk3.  (Typically used by
1856         Linux distributions.)]))
1857
1858AC_ARG_ENABLE(split-app-modules,
1859    AS_HELP_STRING([--enable-split-app-modules],
1860        [Split file lists for app modules, e.g. base, calc.
1861         Has effect only with make distro-pack-install]),
1862,)
1863
1864AC_ARG_ENABLE(split-opt-features,
1865    AS_HELP_STRING([--enable-split-opt-features],
1866        [Split file lists for some optional features, e.g. pyuno, testtool.
1867         Has effect only with make distro-pack-install]),
1868,)
1869
1870libo_FUZZ_ARG_ENABLE(cairo-canvas,
1871    AS_HELP_STRING([--disable-cairo-canvas],
1872        [Determines whether to build the Cairo canvas on platforms where Cairo is available.]),
1873,)
1874
1875libo_FUZZ_ARG_ENABLE(dbus,
1876    AS_HELP_STRING([--disable-dbus],
1877        [Determines whether to enable features that depend on dbus.
1878         e.g. Presentation mode screensaver control, bluetooth presentation control, automatic font install]),
1879,test "${enable_dbus+set}" = set || enable_dbus=yes)
1880
1881libo_FUZZ_ARG_ENABLE(sdremote,
1882    AS_HELP_STRING([--disable-sdremote],
1883        [Determines whether to enable Impress remote control (i.e. the server component).]),
1884,test "${enable_sdremote+set}" = set || enable_sdremote=yes)
1885
1886libo_FUZZ_ARG_ENABLE(sdremote-bluetooth,
1887    AS_HELP_STRING([--disable-sdremote-bluetooth],
1888        [Determines whether to build sdremote with bluetooth support.
1889         Requires dbus on Linux.]))
1890
1891libo_FUZZ_ARG_ENABLE(gio,
1892    AS_HELP_STRING([--disable-gio],
1893        [Determines whether to use the GIO support.]),
1894,test "${enable_gio+set}" = set || enable_gio=yes)
1895
1896AC_ARG_ENABLE(qt5,
1897    AS_HELP_STRING([--enable-qt5],
1898        [Determines whether to use Qt5 vclplug on platforms where Qt5 is
1899         available.]),
1900,)
1901
1902AC_ARG_ENABLE(qt6,
1903    AS_HELP_STRING([--enable-qt6],
1904        [Determines whether to use Qt6 vclplug on platforms where Qt6 is
1905         available.]),
1906,)
1907
1908AC_ARG_ENABLE(qt6-multimedia,
1909    AS_HELP_STRING([--disable-qt6-multimedia],
1910        [Determines whether to enable media playback using QtMultimedia when using the qt6/kf6 VCL plugins.]))
1911
1912AC_ARG_ENABLE(kf5,
1913    AS_HELP_STRING([--enable-kf5],
1914        [Determines whether to use Qt5/KF5 vclplug on platforms where Qt5 and
1915         KF5 are available.]),
1916,)
1917
1918AC_ARG_ENABLE(kf6,
1919    AS_HELP_STRING([--enable-kf6],
1920        [Determines whether to use KF6 vclplug on platforms where Qt6 and
1921         KF6 are available.]),
1922,)
1923
1924
1925AC_ARG_ENABLE(gtk3_kde5,
1926    AS_HELP_STRING([--enable-gtk3-kde5],
1927        [Determines whether to use Gtk3 vclplug with KF5 file dialogs on
1928         platforms where Gtk3, Qt5 and Plasma is available.]),
1929,)
1930
1931AC_ARG_ENABLE(gen,
1932    AS_HELP_STRING([--enable-gen],
1933        [To select the gen backend in case of --disable-dynamic-loading.
1934         Per default auto-enabled when X11 is used.]),
1935,test "${test_gen}" = no -o "${enable_gen+set}" = set || enable_gen=yes)
1936
1937AC_ARG_ENABLE(gui,
1938    AS_HELP_STRING([--disable-gui],
1939        [Disable use of X11 or Wayland to reduce dependencies (e.g. for building LibreOfficeKit).]),
1940,enable_gui=yes)
1941
1942libo_FUZZ_ARG_ENABLE(randr,
1943    AS_HELP_STRING([--disable-randr],
1944        [Disable RandR support in the vcl project.]),
1945,test "${enable_randr+set}" = set || enable_randr=yes)
1946
1947libo_FUZZ_ARG_ENABLE(gstreamer-1-0,
1948    AS_HELP_STRING([--disable-gstreamer-1-0],
1949        [Disable building with the gstreamer 1.0 avmedia backend.]),
1950,test "${enable_gstreamer_1_0+set}" = set || enable_gstreamer_1_0=yes)
1951
1952# Enable by default on Linux and macOS only
1953if test $_os = Darwin -o $_os = Linux -o $_os = WINNT; then
1954    libo_FUZZ_ARG_ENABLE([eot],
1955        [AS_HELP_STRING([--disable-eot],
1956            [Disable support for Embedded OpenType fonts.])],
1957    ,test "${enable_eot+set}" = set || enable_eot=yes)
1958else
1959    libo_FUZZ_ARG_ENABLE([eot],
1960        [AS_HELP_STRING([--enable-eot],
1961            [Enable support for Embedded OpenType fonts.])],
1962    ,test "${enable_eot+set}" = set || enable_eot=no)
1963fi
1964
1965
1966
1967libo_FUZZ_ARG_ENABLE(cve-tests,
1968    AS_HELP_STRING([--disable-cve-tests],
1969        [Prevent CVE tests to be executed]),
1970,)
1971
1972libo_FUZZ_ARG_ENABLE(nan-tests,
1973    AS_HELP_STRING([--disable-nan-tests],
1974        [Prevent NaN payload tests to be executed]),
1975,)
1976
1977AC_ARG_ENABLE(build-opensymbol,
1978    AS_HELP_STRING([--enable-build-opensymbol],
1979        [Do not use the prebuilt opens___.ttf. Build it instead. This needs
1980         fontforge installed.]),
1981,)
1982
1983AC_ARG_ENABLE(dependency-tracking,
1984    AS_HELP_STRING([--enable-dependency-tracking],
1985        [Do not reject slow dependency extractors.  --enable-dependency-tracking=sysincludes enables
1986         dependency tracking also of system include files; currently only implemented for GCC-like
1987         compilers.])[
1988  --disable-dependency-tracking
1989                          Disables generation of dependency information.
1990                          Speed up one-time builds.],
1991,)
1992
1993AC_ARG_ENABLE(icecream,
1994    AS_HELP_STRING([--enable-icecream],
1995        [Use the 'icecream' distributed compiling tool to speedup the compilation.
1996         It defaults to /opt/icecream for the location of the icecream gcc/g++
1997         wrappers, you can override that using --with-gcc-home=/the/path switch.]),
1998,)
1999
2000AC_ARG_ENABLE(ld,
2001    AS_HELP_STRING([--enable-ld=<linker>],
2002        [Use the specified linker. Both 'gold' and 'lld' linkers generally use less memory and link faster.
2003         By default tries to use the best linker possible, use --disable-ld to use the default linker.
2004         If <linker> contains any ':', the part before the first ':' is used as the value of
2005         -fuse-ld, while the part after the first ':' is used as the value of --ld-path (which is
2006         needed for Clang 12).]),
2007,)
2008
2009AC_ARG_ENABLE(cpdb,
2010    AS_HELP_STRING([--enable-cpdb],
2011        [Build CPDB (Common Print Dialog Backends) support.]),
2012,)
2013
2014libo_FUZZ_ARG_ENABLE(cups,
2015    AS_HELP_STRING([--disable-cups],
2016        [Do not build cups support.])
2017)
2018
2019AC_ARG_ENABLE(ccache,
2020    AS_HELP_STRING([--disable-ccache],
2021        [Do not try to use ccache automatically.
2022         By default we will try to detect if ccache is available; in that case if
2023         CC/CXX are not yet set, and --enable-icecream is not given, we
2024         attempt to use ccache. --disable-ccache disables ccache completely.
2025         Additionally ccache's depend mode is enabled if possible,
2026         use --enable-ccache=nodepend to enable ccache without depend mode.
2027]),
2028,)
2029
2030AC_ARG_ENABLE(z7-debug,
2031    AS_HELP_STRING([--enable-z7-debug],
2032        [Makes the MSVC compiler use -Z7 for debugging instead of the default -Zi. Using this option takes
2033         more disk spaces but allows to use ccache. Final PDB files are created even with this option enabled.
2034         Enabled by default if ccache is detected.]))
2035
2036libo_FUZZ_ARG_ENABLE(online-update,
2037    AS_HELP_STRING([--enable-online-update],
2038        [Enable the online update service that will check for new versions of
2039         LibreOffice. Disabled by default. Requires --with-privacy-policy-url to be set.]),
2040,)
2041
2042libo_FUZZ_ARG_ENABLE(online-update-mar,
2043    AS_HELP_STRING([--enable-online-update-mar],
2044        [Enable the Mozilla-like online update service that will
2045         check for new versions of LibreOffice. Currently only works for
2046         Windows and Linux. Disabled by default.]),
2047,)
2048
2049libo_FUZZ_ARG_WITH(online-update-mar-baseurl,
2050    AS_HELP_STRING([--with-online-update-mar-baseurl=...],
2051        [Set the base URL value for --enable-online-update-mar.
2052         (Can be left off for debug purposes, even if that may render the feature
2053         non-functional.)]),
2054,)
2055
2056libo_FUZZ_ARG_WITH(online-update-mar-certificateder,
2057    AS_HELP_STRING([--with-online-update-mar-certificateder=...],
2058        [Set the certificate DER value for --enable-online-update-mar.
2059         (Can be left off for debug purposes, even if that may render the feature
2060         non-functional.)]),
2061,)
2062
2063libo_FUZZ_ARG_WITH(online-update-mar-certificatename,
2064    AS_HELP_STRING([--with-online-update-mar-certificatename=...],
2065        [Set the certificate name value for --enable-online-update-mar.
2066         (Can be left off for debug purposes, even if that may render the feature
2067         non-functional.)]),
2068,)
2069
2070libo_FUZZ_ARG_WITH(online-update-mar-certificatepath,
2071    AS_HELP_STRING([--with-online-update-mar-certificatepath=...],
2072        [Set the certificate path value for --enable-online-update-mar.
2073         (Can be left off for debug purposes, even if that may render the feature
2074         non-functional.)]),
2075,)
2076
2077libo_FUZZ_ARG_ENABLE(extension-update,
2078    AS_HELP_STRING([--disable-extension-update],
2079        [Disable possibility to update installed extensions.]),
2080,)
2081
2082libo_FUZZ_ARG_ENABLE(release-build,
2083    AS_HELP_STRING([--enable-release-build],
2084        [Enable release build. Note that the "release build" choice is orthogonal to
2085         whether symbols are present, debug info is generated, or optimization
2086         is done.
2087         See https://wiki.documentfoundation.org/Development/DevBuild]),
2088,)
2089
2090libo_FUZZ_ARG_ENABLE(hardening-flags,
2091    AS_HELP_STRING([--enable-hardening-flags],
2092        [Enable automatically using hardening compiler flags. Distros typically
2093         instead use their default configuration via CXXFLAGS, etc. But this provides a
2094         convenient set of default hardening flags for non-distros]),
2095,)
2096
2097AC_ARG_ENABLE(windows-build-signing,
2098    AS_HELP_STRING([--enable-windows-build-signing],
2099        [Enable signing of windows binaries (*.exe, *.dll)]),
2100,)
2101
2102AC_ARG_ENABLE(silent-msi,
2103    AS_HELP_STRING([--enable-silent-msi],
2104        [Enable MSI with LIMITUI=1 (silent install).]),
2105,)
2106
2107AC_ARG_ENABLE(wix,
2108    AS_HELP_STRING([--enable-wix],
2109        [Build Windows installer using WiX.]),
2110,)
2111
2112AC_ARG_ENABLE(macosx-code-signing,
2113    AS_HELP_STRING([--enable-macosx-code-signing=<identity>],
2114        [Sign executables, dylibs, frameworks and the app bundle. If you
2115         don't provide an identity the first suitable certificate
2116         in your keychain is used.]),
2117,)
2118
2119AC_ARG_ENABLE(macosx-package-signing,
2120    AS_HELP_STRING([--enable-macosx-package-signing=<identity>],
2121        [Create a .pkg suitable for uploading to the Mac App Store and sign
2122         it. If you don't provide an identity the first suitable certificate
2123         in your keychain is used.]),
2124,)
2125
2126AC_ARG_ENABLE(macosx-sandbox,
2127    AS_HELP_STRING([--enable-macosx-sandbox],
2128        [Make the app bundle run in a sandbox. Requires code signing.
2129         Is required by apps distributed in the Mac App Store, and implies
2130         adherence to App Store rules.]),
2131,)
2132
2133AC_ARG_WITH(macosx-bundle-identifier,
2134    AS_HELP_STRING([--with-macosx-bundle-identifier=tld.mumble.orifice.TheOffice],
2135        [Define the macOS bundle identifier. Default is the somewhat weird
2136         org.libreoffice.script ("script", huh?).]),
2137,with_macosx_bundle_identifier=org.libreoffice.script)
2138
2139AC_ARG_WITH(macosx-provisioning-profile,
2140    AS_HELP_STRING([--with-macosx-provisioning-profile=/path/to/mac.provisionprofile],
2141        [Specify the path to a provisioning profile to use]),
2142,)
2143
2144AC_ARG_WITH(product-name,
2145    AS_HELP_STRING([--with-product-name='My Own Office Suite'],
2146        [Define the product name. Default is AC_PACKAGE_NAME.]),
2147,with_product_name=$PRODUCTNAME)
2148
2149libo_FUZZ_ARG_ENABLE(community-flavor,
2150    AS_HELP_STRING([--disable-community-flavor],
2151        [Disable the Community branding.]),
2152,)
2153
2154AC_ARG_WITH(package-version,
2155    AS_HELP_STRING([--with-package-version='3.1.4.5'],
2156        [Define the package version. Default is AC_PACKAGE_VERSION. Use only if you distribute an own build for macOS.]),
2157,)
2158
2159libo_FUZZ_ARG_ENABLE(readonly-installset,
2160    AS_HELP_STRING([--enable-readonly-installset],
2161        [Prevents any attempts by LibreOffice to write into its installation. That means
2162         at least that no "system-wide" extensions can be added. Partly experimental work in
2163         progress, probably not fully implemented. Always enabled for macOS.]),
2164,)
2165
2166libo_FUZZ_ARG_ENABLE(mariadb-sdbc,
2167    AS_HELP_STRING([--disable-mariadb-sdbc],
2168        [Disable the build of the MariaDB/MySQL-SDBC driver.])
2169)
2170
2171libo_FUZZ_ARG_ENABLE(postgresql-sdbc,
2172    AS_HELP_STRING([--disable-postgresql-sdbc],
2173        [Disable the build of the PostgreSQL-SDBC driver.])
2174)
2175
2176libo_FUZZ_ARG_ENABLE(lotuswordpro,
2177    AS_HELP_STRING([--disable-lotuswordpro],
2178        [Disable the build of the Lotus Word Pro filter.]),
2179,test "${enable_lotuswordpro+set}" = set || enable_lotuswordpro=yes)
2180
2181libo_FUZZ_ARG_ENABLE(firebird-sdbc,
2182    AS_HELP_STRING([--disable-firebird-sdbc],
2183        [Disable the build of the Firebird-SDBC driver if it doesn't compile for you.]),
2184,test "${enable_firebird_sdbc+set}" = set || enable_firebird_sdbc=yes)
2185
2186AC_ARG_ENABLE(bogus-pkg-config,
2187    AS_HELP_STRING([--enable-bogus-pkg-config],
2188        [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.]),
2189)
2190
2191AC_ARG_ENABLE(openssl,
2192    AS_HELP_STRING([--disable-openssl],
2193        [Disable using libssl/libcrypto from OpenSSL. If disabled,
2194         components will use NSS. Work in progress,
2195         use only if you are hacking on it.]),
2196,enable_openssl=yes)
2197
2198libo_FUZZ_ARG_ENABLE(cipher-openssl-backend,
2199    AS_HELP_STRING([--enable-cipher-openssl-backend],
2200        [Enable using OpenSSL as the actual implementation of the rtl/cipher.h functionality.
2201         Requires --enable-openssl.]))
2202
2203AC_ARG_ENABLE(nss,
2204    AS_HELP_STRING([--disable-nss],
2205        [Disable using NSS. If disabled,
2206         components will use openssl. Work in progress,
2207         use only if you are hacking on it.]),
2208,enable_nss=yes)
2209
2210AC_ARG_ENABLE(library-bin-tar,
2211    AS_HELP_STRING([--enable-library-bin-tar],
2212        [Enable the building and reused of tarball of binary build for some 'external' libraries.
2213        Some libraries can save their build result in a tarball
2214        stored in TARFILE_LOCATION. That binary tarball is
2215        uniquely identified by the source tarball,
2216        the content of the config_host.mk file and the content
2217        of the top-level directory in core for that library
2218        If this option is enabled, then if such a tarfile exist, it will be untarred
2219        instead of the source tarfile, and the build step will be skipped for that
2220        library.
2221        If a proper tarfile does not exist, then the normal source-based
2222        build is done for that library and a proper binary tarfile is created
2223        for the next time.]),
2224)
2225
2226AC_ARG_ENABLE(dconf,
2227    AS_HELP_STRING([--disable-dconf],
2228        [Disable the dconf configuration backend (enabled by default where
2229         available).]))
2230
2231libo_FUZZ_ARG_ENABLE(formula-logger,
2232    AS_HELP_STRING(
2233        [--enable-formula-logger],
2234        [Enable formula logger for logging formula calculation flow in Calc.]
2235    )
2236)
2237
2238AC_ARG_ENABLE(ldap,
2239    AS_HELP_STRING([--disable-ldap],
2240        [Disable LDAP support.]),
2241,enable_ldap=yes)
2242
2243AC_ARG_ENABLE(opencl,
2244    AS_HELP_STRING([--disable-opencl],
2245        [Disable OpenCL support.]),
2246,enable_opencl=yes)
2247
2248libo_FUZZ_ARG_ENABLE(librelogo,
2249    AS_HELP_STRING([--disable-librelogo],
2250        [Do not build LibreLogo.]),
2251,enable_librelogo=yes)
2252
2253AC_ARG_ENABLE(wasm-strip,
2254    AS_HELP_STRING([--enable-wasm-strip],
2255        [Strip the static build like for WASM/emscripten platform.]),
2256,)
2257
2258AC_ARG_WITH(wasm-module,
2259    AS_HELP_STRING([--with-wasm-module=<writer/calc/impress>],
2260        [Specify which main module to build for wasm.
2261        Default value is 'calc writer'.]),
2262, [with_wasm_module='calc writer'])
2263# Don't include impress by default. Debug builds become too large for Chromium
2264# with 'calc impress writer' enabled. (buffer source exceeds maximum size)
2265
2266if test "$_os" = Emscripten; then
2267    AC_ARG_ENABLE(emscripten-jspi,
2268        AS_HELP_STRING([--enable-emscripten-jspi],
2269            [Experimentally enable use of the Emscripten -sJSPI feature.]))
2270else
2271    enable_emscripten_jspi=
2272fi
2273
2274if test "$_os" = Emscripten; then
2275    AC_ARG_ENABLE(emscripten-proxy-to-pthread,
2276        AS_HELP_STRING([--disable-emscripten-proxy-to-pthread],
2277            [Experimentally disable use of the Emscripten -sPROXY_TO_PTHREAD feature.]),,
2278        enable_emscripten_proxy_to_pthread=yes)
2279else
2280    enable_emscripten_proxy_to_pthread=
2281fi
2282
2283if test "$_os" = Emscripten; then
2284    AC_ARG_ENABLE(emscripten-proxy-posix-sockets,
2285        AS_HELP_STRING([--enable-emscripten-proxy-posix-sockets],
2286            [Enable experimental Emscripten support for full POSIX sockets over WebSocket proxy
2287             server (-sPROXY_POSIX_SOCKETS).]))
2288else
2289    enable_emscripten_proxy_posix_sockets=
2290fi
2291
2292AC_ARG_ENABLE(embindtest-uno,
2293    AS_HELP_STRING([--enable-embindtest-uno],
2294        [Enable the UNO parts (types and service implementation) of the embindtest framework (which
2295         can also be used independently of the Emscripten build).  On by default for
2296         --enable-dbgutil Emscripten builds (where the Emscripten-specific embindtest.js counterpart
2297         will also be enabled).]))
2298
2299AC_ARG_ENABLE(xmlhelp,
2300    AS_HELP_STRING([--disable-xmlhelp],
2301        [Disable XML help support]),
2302,enable_xmlhelp=yes)
2303
2304AC_ARG_ENABLE(customtarget-components,
2305    AS_HELP_STRING([--enable-customtarget-components],
2306        [Generates the static UNO object constructor mapping from the build.]))
2307
2308AC_ARG_ENABLE(cli,
2309    AS_HELP_STRING([--disable-cli],
2310        [Disable the generation of old CLI bindings.]),
2311,enable_cli=yes)
2312
2313AC_ARG_WITH(extra-cc-flags,
2314    AS_HELP_STRING([--with-extra-cc-flags=...],
2315        [Specify extra flags (like GCC's -fdiagnostics-color=always, which is useful in combination
2316         with the GNU Make --output-sync option) to add to the end of the CC variable.]))
2317
2318AC_ARG_WITH(extra-cxx-flags,
2319    AS_HELP_STRING([--with-extra-cxx-flags=...],
2320        [Specify extra flags (like GCC's -fdiagnostics-color=always, which is useful in combination
2321         with the GNU Make --output-sync option) to add to the end of the CXX variable.]))
2322
2323dnl ===================================================================
2324dnl Optional Packages (--with/without-)
2325dnl ===================================================================
2326
2327AC_ARG_WITH(gcc-home,
2328    AS_HELP_STRING([--with-gcc-home],
2329        [Specify the location of gcc/g++ manually. This can be used in conjunction
2330         with --enable-icecream when icecream gcc/g++ wrappers are installed in a
2331         non-default path.]),
2332,)
2333
2334AC_ARG_WITH(gnu-patch,
2335    AS_HELP_STRING([--with-gnu-patch],
2336        [Specify location of GNU patch on Solaris or FreeBSD.]),
2337,)
2338
2339AC_ARG_WITH(build-platform-configure-options,
2340    AS_HELP_STRING([--with-build-platform-configure-options],
2341        [Specify options for the configure script run for the *build* platform in a cross-compilation]),
2342,)
2343
2344AC_ARG_WITH(gnu-cp,
2345    AS_HELP_STRING([--with-gnu-cp],
2346        [Specify location of GNU cp on Solaris or FreeBSD.]),
2347,)
2348
2349AC_ARG_WITH(external-tar,
2350    AS_HELP_STRING([--with-external-tar=<TARFILE_PATH>],
2351        [Specify an absolute path of where to find (and store) tarfiles.]),
2352    TARFILE_LOCATION=$withval ,
2353)
2354
2355AC_ARG_WITH(referenced-git,
2356    AS_HELP_STRING([--with-referenced-git=<OTHER_CHECKOUT_DIR>],
2357        [Specify another checkout directory to reference. This makes use of
2358                 git submodule update --reference, and saves a lot of diskspace
2359                 when having multiple trees side-by-side.]),
2360    GIT_REFERENCE_SRC=$withval ,
2361)
2362
2363AC_ARG_WITH(linked-git,
2364    AS_HELP_STRING([--with-linked-git=<submodules repo basedir>],
2365        [Specify a directory where the repositories of submodules are located.
2366         This uses a method similar to git-new-workdir to get submodules.]),
2367    GIT_LINK_SRC=$withval ,
2368)
2369
2370AC_ARG_WITH(galleries,
2371    AS_HELP_STRING([--with-galleries],
2372        [Specify how galleries should be built. It is possible either to
2373         build these internally from source ("build"),
2374         or to disable them ("no")]),
2375)
2376
2377AC_ARG_WITH(templates,
2378    AS_HELP_STRING([--with-templates],
2379        [Specify we build with or without template files. It is possible either to
2380         build with templates ("yes"),
2381         or to disable them ("no")]),
2382)
2383
2384AC_ARG_WITH(theme,
2385    AS_HELP_STRING([--with-theme="theme1 theme2..."],
2386        [Choose which themes to include. By default those themes with an '*' are included.
2387         Possible choices: *breeze, *breeze_dark, *breeze_dark_svg, *breeze_svg,
2388         *colibre, *colibre_svg, *colibre_dark, *colibre_dark_svg,
2389         *elementary, *elementary_svg,
2390         *karasa_jaga, *karasa_jaga_svg,
2391         *sifr, *sifr_dark, *sifr_dark_svg, *sifr_svg,
2392         *sukapura, *sukapura_dark, *sukapura_dark_svg, *sukapura_svg.]),
2393,)
2394
2395libo_FUZZ_ARG_WITH(helppack-integration,
2396    AS_HELP_STRING([--without-helppack-integration],
2397        [It will not integrate the helppacks to the installer
2398         of the product. Please use this switch to use the online help
2399         or separate help packages.]),
2400,)
2401
2402libo_FUZZ_ARG_WITH(fonts,
2403    AS_HELP_STRING([--without-fonts],
2404        [LibreOffice includes some third-party fonts to provide a reliable basis for
2405         help content, templates, samples, etc. When these fonts are already
2406         known to be available on the system then you should use this option.]),
2407,)
2408
2409libo_FUZZ_ARG_WITH(docrepair-fonts,
2410    AS_HELP_STRING([--with-docrepair-fonts],
2411        [LibreOffice optionally includes fonts from 'The DocRepair Project' that
2412         provide metrically equivalent fallback fonts for a variety of common fonts
2413         seen in Office Open XML documents. See https://github.com/docrepair-fonts
2414         for more details. This option has no effect when --without-fonts is used.]),
2415,)
2416
2417AC_ARG_WITH(epm,
2418    AS_HELP_STRING([--with-epm],
2419        [Decides which epm to use. Default is to use the one from the system if
2420         one is built. When either this is not there or you say =internal epm
2421         will be built.]),
2422,)
2423
2424AC_ARG_WITH(package-format,
2425    AS_HELP_STRING([--with-package-format],
2426        [Specify package format(s) for LibreOffice installation sets. The
2427         implicit --without-package-format leads to no installation sets being
2428         generated. Possible values: archive, bsd, deb, dmg, emscripten,
2429         installed, msi, pkg, and rpm.
2430         Example: --with-package-format='deb rpm']),
2431,)
2432
2433AC_ARG_WITH(tls,
2434    AS_HELP_STRING([--with-tls],
2435        [Decides which TLS/SSL and cryptographic implementations to use for
2436         LibreOffice's code. Default is to use NSS although OpenSSL is also
2437         possible. Notice that selecting NSS restricts the usage of OpenSSL
2438         in LO's code but selecting OpenSSL doesn't restrict by now the
2439         usage of NSS in LO's code. Possible values: openssl, nss.
2440         Example: --with-tls="nss"]),
2441,)
2442
2443AC_ARG_WITH(system-libs,
2444    AS_HELP_STRING([--with-system-libs],
2445        [Use libraries already on system -- enables all --with-system-* flags.]),
2446,)
2447
2448AC_ARG_WITH(system-bzip2,
2449    AS_HELP_STRING([--with-system-bzip2],
2450        [Use bzip2 already on system. Used when --enable-online-update-mar
2451        or --enable-python=internal]),,
2452    [with_system_bzip2="$with_system_libs"])
2453
2454AC_ARG_WITH(system-headers,
2455    AS_HELP_STRING([--with-system-headers],
2456        [Use headers already on system -- enables all --with-system-* flags for
2457         external packages whose headers are the only entities used i.e.
2458         boost/odbc/sane-header(s).]),,
2459    [with_system_headers="$with_system_libs"])
2460
2461AC_ARG_WITH(system-jars,
2462    AS_HELP_STRING([--without-system-jars],
2463        [When building with --with-system-libs, also the needed jars are expected
2464         on the system. Use this to disable that]),,
2465    [with_system_jars="$with_system_libs"])
2466
2467AC_ARG_WITH(system-cairo,
2468    AS_HELP_STRING([--with-system-cairo],
2469        [Use cairo libraries already on system.  Happens automatically for
2470         (implicit) --enable-gtk3.]))
2471
2472AC_ARG_WITH(system-epoxy,
2473    AS_HELP_STRING([--with-system-epoxy],
2474        [Use epoxy libraries already on system.  Happens automatically for
2475         (implicit) --enable-gtk3.]),,
2476       [with_system_epoxy="$with_system_libs"])
2477
2478AC_ARG_WITH(myspell-dicts,
2479    AS_HELP_STRING([--with-myspell-dicts],
2480        [Adds myspell dictionaries to the LibreOffice installation set]),
2481,)
2482
2483AC_ARG_WITH(system-dicts,
2484    AS_HELP_STRING([--without-system-dicts],
2485        [Do not use dictionaries from system paths.]),
2486,)
2487
2488AC_ARG_WITH(external-dict-dir,
2489    AS_HELP_STRING([--with-external-dict-dir],
2490        [Specify external dictionary dir.]),
2491,)
2492
2493AC_ARG_WITH(external-hyph-dir,
2494    AS_HELP_STRING([--with-external-hyph-dir],
2495        [Specify external hyphenation pattern dir.]),
2496,)
2497
2498AC_ARG_WITH(external-thes-dir,
2499    AS_HELP_STRING([--with-external-thes-dir],
2500        [Specify external thesaurus dir.]),
2501,)
2502
2503AC_ARG_WITH(system-zlib,
2504    AS_HELP_STRING([--with-system-zlib],
2505        [Use zlib already on system.]),,
2506    [with_system_zlib=auto])
2507
2508AC_ARG_WITH(system-zstd,
2509    AS_HELP_STRING([--with-system-zstd=@<:@yes|no|auto@:>@],
2510        [Use zstd already on system [default=auto].]),,
2511    [with_system_zstd=auto])
2512
2513AC_ARG_WITH(system-md4c,
2514    AS_HELP_STRING([--with-system-md4c=@<:@yes|no|auto@:>@],
2515        [Use md4c already on system [default=auto].]),,
2516    [with_system_md4c=auto])
2517
2518AC_ARG_WITH(system-jpeg,
2519    AS_HELP_STRING([--with-system-jpeg],
2520        [Use jpeg already on system.]),,
2521    [with_system_jpeg="$with_system_libs"])
2522
2523AC_ARG_WITH(system-expat,
2524    AS_HELP_STRING([--with-system-expat],
2525        [Use expat already on system.]),,
2526    [with_system_expat="$with_system_libs"])
2527
2528AC_ARG_WITH(system-libxml,
2529    AS_HELP_STRING([--with-system-libxml],
2530        [Use libxml/libxslt already on system.]),,
2531    [with_system_libxml=auto])
2532
2533AC_ARG_WITH(system-openldap,
2534    AS_HELP_STRING([--with-system-openldap],
2535        [Use the OpenLDAP LDAP SDK already on system.]),,
2536    [with_system_openldap="$with_system_libs"])
2537
2538libo_FUZZ_ARG_ENABLE(poppler,
2539    AS_HELP_STRING([--disable-poppler],
2540        [Disable building Poppler.])
2541)
2542
2543AC_ARG_WITH(system-poppler,
2544    AS_HELP_STRING([--with-system-poppler],
2545        [Use system poppler (only needed for PDF import).]),,
2546    [with_system_poppler="$with_system_libs"])
2547
2548AC_ARG_WITH(system-abseil,
2549    AS_HELP_STRING([--with-system-abseil],
2550        [Use the abseil libraries already on system.]),,
2551    [with_system_abseil="$with_system_libs"])
2552
2553AC_ARG_WITH(system-openjpeg,
2554    AS_HELP_STRING([--with-system-openjpeg],
2555        [Use the OpenJPEG library already on system.]),,
2556    [with_system_openjpeg="$with_system_libs"])
2557
2558libo_FUZZ_ARG_ENABLE(gpgmepp,
2559    AS_HELP_STRING([--disable-gpgmepp],
2560        [Disable building gpgmepp. Do not use in normal cases unless you want to fix potential problems it causes.])
2561)
2562
2563AC_ARG_WITH(system-gpgmepp,
2564    AS_HELP_STRING([--with-system-gpgmepp],
2565        [Use gpgmepp already on system]),,
2566    [with_system_gpgmepp="$with_system_libs"])
2567
2568AC_ARG_WITH(system-mariadb,
2569    AS_HELP_STRING([--with-system-mariadb],
2570        [Use MariaDB/MySQL libraries already on system.]),,
2571    [with_system_mariadb="$with_system_libs"])
2572
2573AC_ARG_ENABLE(bundle-mariadb,
2574    AS_HELP_STRING([--enable-bundle-mariadb],
2575        [When using MariaDB/MySQL libraries already on system, bundle them with the MariaDB Connector/LibreOffice.])
2576)
2577
2578AC_ARG_WITH(system-postgresql,
2579    AS_HELP_STRING([--with-system-postgresql],
2580        [Use PostgreSQL libraries already on system, for building the PostgreSQL-SDBC
2581         driver. If pg_config is not in PATH, use PGCONFIG to point to it.]),,
2582    [with_system_postgresql="$with_system_libs"])
2583
2584AC_ARG_WITH(libpq-path,
2585    AS_HELP_STRING([--with-libpq-path=<absolute path to your libpq installation>],
2586        [Use this PostgreSQL C interface (libpq) installation for building
2587         the PostgreSQL-SDBC extension.]),
2588,)
2589
2590AC_ARG_WITH(system-firebird,
2591    AS_HELP_STRING([--with-system-firebird],
2592        [Use Firebird libraries already on system, for building the Firebird-SDBC
2593         driver. If fb_config is not in PATH, use FBCONFIG to point to it.]),,
2594    [with_system_firebird="$with_system_libs"])
2595
2596AC_ARG_WITH(system-libtommath,
2597            AS_HELP_STRING([--with-system-libtommath],
2598                           [Use libtommath already on system]),,
2599            [with_system_libtommath="$with_system_libs"])
2600
2601AC_ARG_WITH(system-hsqldb,
2602    AS_HELP_STRING([--with-system-hsqldb],
2603        [Use hsqldb already on system.]))
2604
2605AC_ARG_WITH(hsqldb-jar,
2606    AS_HELP_STRING([--with-hsqldb-jar=JARFILE],
2607        [Specify path to jarfile manually.]),
2608    HSQLDB_JAR=$withval)
2609
2610libo_FUZZ_ARG_ENABLE(scripting-beanshell,
2611    AS_HELP_STRING([--disable-scripting-beanshell],
2612        [Disable support for scripts in BeanShell.]),
2613,
2614)
2615
2616AC_ARG_WITH(system-beanshell,
2617    AS_HELP_STRING([--with-system-beanshell],
2618        [Use beanshell already on system.]),,
2619    [with_system_beanshell="$with_system_jars"])
2620
2621AC_ARG_WITH(beanshell-jar,
2622    AS_HELP_STRING([--with-beanshell-jar=JARFILE],
2623        [Specify path to jarfile manually.]),
2624    BSH_JAR=$withval)
2625
2626libo_FUZZ_ARG_ENABLE(scripting-javascript,
2627    AS_HELP_STRING([--disable-scripting-javascript],
2628        [Disable support for scripts in JavaScript.]),
2629,
2630)
2631
2632AC_ARG_WITH(system-rhino,
2633    AS_HELP_STRING([--with-system-rhino],
2634        [Use rhino already on system.]),,
2635    [with_system_rhino="$with_system_jars"])
2636
2637AC_ARG_WITH(rhino-jar,
2638    AS_HELP_STRING([--with-rhino-jar=JARFILE],
2639        [Specify path to jarfile manually.]),
2640    RHINO_JAR=$withval)
2641
2642AC_ARG_WITH(system-jfreereport,
2643    AS_HELP_STRING([--with-system-jfreereport],
2644        [Use JFreeReport already on system.]),,
2645    [with_system_jfreereport="$with_system_jars"])
2646
2647AC_ARG_WITH(sac-jar,
2648    AS_HELP_STRING([--with-sac-jar=JARFILE],
2649        [Specify path to jarfile manually.]),
2650    SAC_JAR=$withval)
2651
2652AC_ARG_WITH(libxml-jar,
2653    AS_HELP_STRING([--with-libxml-jar=JARFILE],
2654        [Specify path to jarfile manually.]),
2655    LIBXML_JAR=$withval)
2656
2657AC_ARG_WITH(flute-jar,
2658    AS_HELP_STRING([--with-flute-jar=JARFILE],
2659        [Specify path to jarfile manually.]),
2660    FLUTE_JAR=$withval)
2661
2662AC_ARG_WITH(jfreereport-jar,
2663    AS_HELP_STRING([--with-jfreereport-jar=JARFILE],
2664        [Specify path to jarfile manually.]),
2665    JFREEREPORT_JAR=$withval)
2666
2667AC_ARG_WITH(liblayout-jar,
2668    AS_HELP_STRING([--with-liblayout-jar=JARFILE],
2669        [Specify path to jarfile manually.]),
2670    LIBLAYOUT_JAR=$withval)
2671
2672AC_ARG_WITH(libloader-jar,
2673    AS_HELP_STRING([--with-libloader-jar=JARFILE],
2674        [Specify path to jarfile manually.]),
2675    LIBLOADER_JAR=$withval)
2676
2677AC_ARG_WITH(libformula-jar,
2678    AS_HELP_STRING([--with-libformula-jar=JARFILE],
2679        [Specify path to jarfile manually.]),
2680    LIBFORMULA_JAR=$withval)
2681
2682AC_ARG_WITH(librepository-jar,
2683    AS_HELP_STRING([--with-librepository-jar=JARFILE],
2684        [Specify path to jarfile manually.]),
2685    LIBREPOSITORY_JAR=$withval)
2686
2687AC_ARG_WITH(libfonts-jar,
2688    AS_HELP_STRING([--with-libfonts-jar=JARFILE],
2689        [Specify path to jarfile manually.]),
2690    LIBFONTS_JAR=$withval)
2691
2692AC_ARG_WITH(libserializer-jar,
2693    AS_HELP_STRING([--with-libserializer-jar=JARFILE],
2694        [Specify path to jarfile manually.]),
2695    LIBSERIALIZER_JAR=$withval)
2696
2697AC_ARG_WITH(libbase-jar,
2698    AS_HELP_STRING([--with-libbase-jar=JARFILE],
2699        [Specify path to jarfile manually.]),
2700    LIBBASE_JAR=$withval)
2701
2702AC_ARG_WITH(system-odbc,
2703    AS_HELP_STRING([--with-system-odbc],
2704        [Use the odbc headers already on system.]),,
2705    [with_system_odbc="auto"])
2706
2707AC_ARG_WITH(system-sane,
2708    AS_HELP_STRING([--with-system-sane],
2709        [Use sane.h already on system.]),,
2710    [with_system_sane="$with_system_headers"])
2711
2712AC_ARG_WITH(system-bluez,
2713    AS_HELP_STRING([--with-system-bluez],
2714        [Use bluetooth.h already on system.]),,
2715    [with_system_bluez="$with_system_headers"])
2716
2717AC_ARG_WITH(system-boost,
2718    AS_HELP_STRING([--with-system-boost],
2719        [Use boost already on system.]),,
2720    [with_system_boost="$with_system_headers"])
2721
2722AC_ARG_WITH(system-dragonbox,
2723    AS_HELP_STRING([--with-system-dragonbox],
2724        [Use dragonbox already on system.]),,
2725    [with_system_dragonbox="$with_system_headers"])
2726
2727AC_ARG_WITH(system-frozen,
2728    AS_HELP_STRING([--with-system-frozen],
2729        [Use frozen already on system.]),,
2730    [with_system_frozen="$with_system_headers"])
2731
2732AC_ARG_WITH(system-libfixmath,
2733    AS_HELP_STRING([--with-system-libfixmath],
2734        [Use libfixmath already on system.]),,
2735    [with_system_libfixmath="$with_system_libs"])
2736
2737AC_ARG_WITH(system-glm,
2738    AS_HELP_STRING([--with-system-glm],
2739        [Use glm already on system.]),,
2740    [with_system_glm="$with_system_headers"])
2741
2742AC_ARG_WITH(system-hunspell,
2743    AS_HELP_STRING([--with-system-hunspell],
2744        [Use libhunspell already on system.]),,
2745    [with_system_hunspell="$with_system_libs"])
2746
2747libo_FUZZ_ARG_ENABLE(cairo-rgba,
2748    AS_HELP_STRING([--enable-cairo-rgba],
2749        [Use RGBA order, instead of default BRGA. Not possible with --with-system-cairo]))
2750
2751libo_FUZZ_ARG_ENABLE(zxing,
2752    AS_HELP_STRING([--disable-zxing],
2753       [Disable use of zxing external library.]))
2754
2755AC_ARG_WITH(system-zxing,
2756    AS_HELP_STRING([--with-system-zxing],
2757        [Use libzxing already on system.]),,
2758    [with_system_zxing="$with_system_libs"])
2759
2760AC_ARG_WITH(system-zxcvbn,
2761    AS_HELP_STRING([--with-system-zxcvbn],
2762        [Use libzxcvbn already on system.]),,
2763    [with_system_zxcvbn="$with_system_libs"])
2764
2765AC_ARG_WITH(system-box2d,
2766    AS_HELP_STRING([--with-system-box2d],
2767        [Use box2d already on system.]),,
2768    [with_system_box2d="$with_system_libs"])
2769
2770AC_ARG_WITH(system-mythes,
2771    AS_HELP_STRING([--with-system-mythes],
2772        [Use mythes already on system.]),,
2773    [with_system_mythes="$with_system_libs"])
2774
2775AC_ARG_WITH(system-altlinuxhyph,
2776    AS_HELP_STRING([--with-system-altlinuxhyph],
2777        [Use ALTLinuxhyph already on system.]),,
2778    [with_system_altlinuxhyph="$with_system_libs"])
2779
2780AC_ARG_WITH(system-lpsolve,
2781    AS_HELP_STRING([--with-system-lpsolve],
2782        [Use lpsolve already on system.]),,
2783    [with_system_lpsolve="$with_system_libs"])
2784
2785AC_ARG_WITH(system-colamd,
2786    AS_HELP_STRING([--with-system-colamd],
2787        [Use COLAMD already on system.]),,
2788    [with_system_colamd="$with_system_libs"])
2789
2790AC_ARG_WITH(system-coinmp,
2791    AS_HELP_STRING([--with-system-coinmp],
2792        [Use CoinMP already on system.]),,
2793    [with_system_coinmp="$with_system_libs"])
2794
2795AC_ARG_WITH(system-liblangtag,
2796    AS_HELP_STRING([--with-system-liblangtag],
2797        [Use liblangtag library already on system.]),,
2798    [with_system_liblangtag="$with_system_libs"])
2799
2800AC_ARG_WITH(system-lockfile,
2801    AS_HELP_STRING([--with-system-lockfile[=file]],
2802        [Detect a system lockfile program or use the \$file argument.]))
2803
2804AC_ARG_WITH(webdav,
2805    AS_HELP_STRING([--without-webdav],
2806        [Disable WebDAV support in the UCB.]))
2807
2808AC_ARG_WITH(linker-hash-style,
2809    AS_HELP_STRING([--with-linker-hash-style],
2810        [Use linker with --hash-style=<style> when linking shared objects.
2811         Possible values: "sysv", "gnu", "both". The default value is "gnu"
2812         if supported on the build system, and "sysv" otherwise.]))
2813
2814AC_ARG_WITH(jdk-home,
2815    AS_HELP_STRING([--with-jdk-home=<absolute path to JDK home>],
2816        [If you have installed JDK 8 or later on your system please supply the
2817         path here. Note that this is not the location of the java command but the
2818         location of the entire distribution. In case of cross-compiling, this
2819         is the JDK of the host os. Use --with-build-platform-configure-options
2820         to point to a different build platform JDK.]),
2821,)
2822
2823AC_ARG_WITH(help,
2824    AS_HELP_STRING([--with-help],
2825        [Enable the build of help. There is a special parameter "common" that
2826         can be used to bundle only the common part, .e.g help-specific icons.
2827         This is useful when you build the helpcontent separately.])
2828    [
2829                          Usage:     --with-help    build the old local help
2830                                 --without-help     no local help (default)
2831                                 --with-help=html   build the new HTML local help
2832                                 --with-help=online build the new HTML online help
2833    ],
2834,)
2835
2836AC_ARG_WITH(omindex,
2837   AS_HELP_STRING([--with-omindex],
2838        [Enable the support of xapian-omega index for online help.])
2839   [
2840                         Usage: --with-omindex=server prepare the pages for omindex
2841                                but let xapian-omega be built in server.
2842                                --with-omindex=noxap do not prepare online pages
2843                                for xapian-omega
2844  ],
2845,)
2846
2847libo_FUZZ_ARG_WITH(java,
2848    AS_HELP_STRING([--with-java=<java command>],
2849        [Specify the name of the Java interpreter command. Typically "java"
2850         which is the default.
2851
2852         To build without support for Java components, applets, accessibility
2853         or the XML filters written in Java, use --without-java or --with-java=no.]),
2854    [ test -z "$with_java" -o "$with_java" = "yes" && with_java=java ],
2855    [ test -z "$with_java" -o "$with_java" = "yes" && with_java=java ]
2856)
2857
2858AC_ARG_WITH(jvm-path,
2859    AS_HELP_STRING([--with-jvm-path=<absolute path to parent of jvm home>],
2860        [Use a specific JVM search path at runtime.
2861         e.g. use --with-jvm-path=/usr/lib/ to find JRE/JDK in /usr/lib/jvm/]),
2862,)
2863
2864AC_ARG_WITH(ant-home,
2865    AS_HELP_STRING([--with-ant-home=<absolute path to Ant home>],
2866        [If you have installed Apache Ant on your system, please supply the path here.
2867         Note that this is not the location of the Ant binary but the location
2868         of the entire distribution.]),
2869,)
2870
2871AC_ARG_WITH(symbol-config,
2872    AS_HELP_STRING([--with-symbol-config],
2873        [Configuration for the crashreport symbol upload]),
2874        [],
2875        [with_symbol_config=no])
2876
2877AC_ARG_WITH(export-validation,
2878    AS_HELP_STRING([--without-export-validation],
2879        [Disable validating OOXML and ODF files as exported from in-tree tests.]),
2880,with_export_validation=auto)
2881
2882AC_ARG_WITH(bffvalidator,
2883    AS_HELP_STRING([--with-bffvalidator=<absolute path to BFFValidator>],
2884        [Enables export validation for Microsoft Binary formats (doc, xls, ppt).
2885         Requires installed Microsoft Office Binary File Format Validator.
2886         Note: export-validation (--with-export-validation) is required to be turned on.
2887         See https://web.archive.org/web/20200804155745/https://www.microsoft.com/en-us/download/details.aspx?id=26794]),
2888,with_bffvalidator=no)
2889
2890libo_FUZZ_ARG_WITH(junit,
2891    AS_HELP_STRING([--with-junit=<absolute path to JUnit 4 jar>],
2892        [Specifies the JUnit 4 jar file to use for JUnit-based tests.
2893         --without-junit disables those tests. Not relevant in the --without-java case.]),
2894,with_junit=yes)
2895
2896AC_ARG_WITH(hamcrest,
2897    AS_HELP_STRING([--with-hamcrest=<absolute path to hamcrest jar>],
2898        [Specifies the hamcrest jar file to use for JUnit-based tests.
2899         --without-junit disables those tests. Not relevant in the --without-java case.]),
2900,with_hamcrest=yes)
2901
2902AC_ARG_WITH(yrs,
2903    AS_HELP_STRING([--with-yrs],
2904        [Enables very experimental experiments.]),[
2905    WITH_YRS=$withval
2906    if test "x$withval" != "xno"; then
2907        AC_PATH_PROG([CARGO], [cargo])
2908        if test -z "${CARGO}"; then
2909            AC_MSG_ERROR([install cargo to build yrs])
2910        fi
2911        BUILD_TYPE="${BUILD_TYPE} YRS"
2912        AC_DEFINE(ENABLE_YRS)
2913    fi])
2914AC_SUBST(WITH_YRS)
2915
2916AC_ARG_WITH(perl-home,
2917    AS_HELP_STRING([--with-perl-home=<abs. path to Perl 5 home>],
2918        [If you have installed Perl 5 Distribution, on your system, please
2919         supply the path here. Note that this is not the location of the Perl
2920         binary but the location of the entire distribution.]),
2921,)
2922
2923libo_FUZZ_ARG_WITH(doxygen,
2924    AS_HELP_STRING(
2925        [--with-doxygen=<absolute path to doxygen executable>],
2926        [Only relevant when --enable-odk is set. Specifies the doxygen
2927         executable to use when generating ODK C/C++ documentation.
2928         --without-doxygen disables generation of ODK C/C++ documentation.]),
2929,with_doxygen=yes)
2930
2931AC_ARG_WITH(visual-studio,
2932    AS_HELP_STRING([--with-visual-studio=<2019/2022/2022preview>],
2933        [Specify which Visual Studio version to use in case several are
2934         installed. Currently 2019 (default) and 2022 are supported.]),
2935,)
2936
2937AC_ARG_WITH(windows-sdk,
2938    AS_HELP_STRING([--with-windows-sdk=<8.0(A)/8.1(A)/10.0>],
2939        [Specify which Windows SDK, or "Windows Kit", version to use
2940         in case the one that came with the selected Visual Studio
2941         is not what you want for some reason. Note that not all compiler/SDK
2942         combinations are supported. The intent is that this option should not
2943         be needed.]),
2944,)
2945
2946AC_ARG_WITH(lang,
2947    AS_HELP_STRING([--with-lang="es sw tu cs sk"],
2948        [Use this option to build LibreOffice with additional UI language support.
2949         English (US) is always included by default.
2950         Separate multiple languages with space.
2951         For all languages, use --with-lang=ALL.]),
2952,)
2953
2954AC_ARG_WITH(locales,
2955    AS_HELP_STRING([--with-locales="en es pt fr zh kr ja"],
2956        [Use this option to limit the locale information built in.
2957         Separate multiple locales with space.
2958         Very experimental and might well break stuff.
2959         Just a desperate measure to shrink code and data size.
2960         By default all the locales available is included.
2961         Just works with --disable-dynloading. Defaults to "ALL".
2962         This option is completely unrelated to --with-lang.])
2963    [
2964                          Affects also our character encoding conversion
2965                          tables for encodings mainly targeted for a
2966                          particular locale, like EUC-CN and EUC-TW for
2967                          zh, ISO-2022-JP for ja.
2968
2969                          Affects also our add-on break iterator data for
2970                          some languages.
2971
2972                          For the default, all locales, don't use this switch at all.
2973                          Specifying just the language part of a locale means all matching
2974                          locales will be included.
2975    ],
2976,)
2977
2978# Kerberos and GSSAPI used only by PostgreSQL as of LibO 3.5
2979# and also by Mariadb/Mysql and libcurl since LibO 24.8
2980libo_FUZZ_ARG_WITH(krb5,
2981    AS_HELP_STRING([--with-krb5],
2982        [Enable MIT Kerberos 5 support in modules that support it.
2983         By default automatically enabled on platforms
2984         where a good system Kerberos 5 is available.]),
2985,)
2986
2987libo_FUZZ_ARG_WITH(gssapi,
2988    AS_HELP_STRING([--with-gssapi],
2989        [Enable GSSAPI support in modules that support it.
2990         By default automatically enabled on platforms
2991         where a good system GSSAPI is available.]),
2992,)
2993
2994libo_FUZZ_ARG_WITH(lxml,
2995    AS_HELP_STRING([--without-lxml],
2996        [gla11y will use python lxml when available, potentially building a local copy if necessary.
2997         --without-lxml tells it to not use python lxml at all, which means that gla11y will only
2998         report widget classes and ids.]),
2999,)
3000
3001libo_FUZZ_ARG_WITH(latest-c++,
3002    AS_HELP_STRING([--with-latest-c++],
3003        [Try to enable the latest features of the C++ compiler, even if they are not yet part of a
3004         published standard.  This option is ignored when CXXFLAGS_CXX11 is set explicitly.]),,
3005        [with_latest_c__=no])
3006
3007AC_ARG_WITH(gtk3-build,
3008    AS_HELP_STRING([--with-gtk3-build=<absolute path to GTK3 build>],
3009        [(Windows-only) In order to build GtkTiledViewer on Windows, pass the path
3010         to a GTK3 build, like '--with-gtk3-build=C:/gtk-build/gtk/x64/release'.]))
3011
3012AC_ARG_WITH(keep-awake,
3013    AS_HELP_STRING([--with-keep-awake],
3014        [command to prefix make with in order to prevent the system from going to sleep/suspend
3015         while building.
3016         If no command is specified, defaults to using Awake (from Microsoft PowerToys) on Windows
3017         and caffeinate on macOS]))
3018
3019AC_ARG_WITH(dotnet,
3020    AS_HELP_STRING([--with-dotnet=<absolute path to dotnet executable>],
3021        [Specify the dotnet executable used to build .NET bindings and components.
3022         Requires .NET SDK 8 or higher. To disable building .NET components, use
3023         --without-dotnet or --with-dotnet=no.]))
3024
3025dnl ===================================================================
3026dnl Branding
3027dnl ===================================================================
3028
3029AC_ARG_WITH(branding,
3030    AS_HELP_STRING([--with-branding=/path/to/images],
3031        [Use given path to retrieve branding images set.])
3032    [
3033                          Search for intro.png about.svg and logo.svg.
3034                          If any is missing, default ones will be used instead.
3035
3036                          Search also progress.conf for progress
3037                          settings on intro screen :
3038
3039                          PROGRESSBARCOLOR="255,255,255" Set color of
3040                          progress bar. Comma separated RGB decimal values.
3041                          PROGRESSSIZE="407,6" Set size of progress bar.
3042                          Comma separated decimal values (width, height).
3043                          PROGRESSPOSITION="61,317" Set position of progress
3044                          bar from left,top. Comma separated decimal values.
3045                          PROGRESSFRAMECOLOR="20,136,3" Set color of progress
3046                          bar frame. Comma separated RGB decimal values.
3047                          PROGRESSTEXTCOLOR="0,0,0" Set color of progress
3048                          bar text. Comma separated RGB decimal values.
3049                          PROGRESSTEXTBASELINE="287" Set vertical position of
3050                          progress bar text from top. Decimal value.
3051
3052                          Default values will be used if not found.
3053    ],
3054,)
3055
3056
3057AC_ARG_WITH(extra-buildid,
3058    AS_HELP_STRING([--with-extra-buildid="Tinderbox: Win-x86@6, Branch:master, Date:2012-11-26_00.29.34"],
3059        [Show addition build identification in about dialog.]),
3060,)
3061
3062
3063AC_ARG_WITH(vendor,
3064    AS_HELP_STRING([--with-vendor="John the Builder"],
3065        [Set vendor of the build.]),
3066,)
3067
3068AC_ARG_WITH(privacy-policy-url,
3069    AS_HELP_STRING([--with-privacy-policy-url="https://yourdomain/privacy-policy"],
3070        [The URL to your privacy policy (needed when
3071         enabling online-update or crashreporting via breakpad)]),
3072        [if test "x$with_privacy_policy_url" = "xyes"; then
3073            AC_MSG_FAILURE([you need to specify an argument when using --with-privacy-policy-url])
3074         elif test "x$with_privacy_policy_url" = "xno"; then
3075            with_privacy_policy_url="undefined"
3076         fi]
3077,[with_privacy_policy_url="undefined"])
3078
3079AC_ARG_WITH(android-package-name,
3080    AS_HELP_STRING([--with-android-package-name="org.libreoffice"],
3081        [Set Android package name of the build.]),
3082,)
3083
3084AC_ARG_WITH(compat-oowrappers,
3085    AS_HELP_STRING([--with-compat-oowrappers],
3086        [Install oo* wrappers in parallel with
3087         lo* ones to keep backward compatibility.
3088         Has effect only with make distro-pack-install]),
3089,)
3090
3091AC_ARG_WITH(os-version,
3092    AS_HELP_STRING([--with-os-version=<OSVERSION>],
3093        [For FreeBSD users, use this option to override the detected OSVERSION.]),
3094,)
3095
3096AC_ARG_WITH(parallelism,
3097    AS_HELP_STRING([--with-parallelism],
3098        [Number of jobs to run simultaneously during build. Parallel builds can
3099        save a lot of time on multi-cpu machines. Defaults to the number of
3100        CPUs on the machine, unless you configure --enable-icecream - then to
3101        40.]),
3102,)
3103
3104AC_ARG_WITH(all-tarballs,
3105    AS_HELP_STRING([--with-all-tarballs],
3106        [Download all external tarballs unconditionally]))
3107
3108AC_ARG_WITH(gdrive-client-id,
3109    AS_HELP_STRING([--with-gdrive-client-id],
3110        [Provides the client id of the application for OAuth2 authentication
3111        on Google Drive. If either this or --with-gdrive-client-secret is
3112        empty, the feature will be disabled]),
3113)
3114
3115AC_ARG_WITH(gdrive-client-secret,
3116    AS_HELP_STRING([--with-gdrive-client-secret],
3117        [Provides the client secret of the application for OAuth2
3118        authentication on Google Drive. If either this or
3119        --with-gdrive-client-id is empty, the feature will be disabled]),
3120)
3121
3122AC_ARG_WITH(alfresco-cloud-client-id,
3123    AS_HELP_STRING([--with-alfresco-cloud-client-id],
3124        [Provides the client id of the application for OAuth2 authentication
3125        on Alfresco Cloud. If either this or --with-alfresco-cloud-client-secret is
3126        empty, the feature will be disabled]),
3127)
3128
3129AC_ARG_WITH(alfresco-cloud-client-secret,
3130    AS_HELP_STRING([--with-alfresco-cloud-client-secret],
3131        [Provides the client secret of the application for OAuth2
3132        authentication on Alfresco Cloud. If either this or
3133        --with-alfresco-cloud-client-id is empty, the feature will be disabled]),
3134)
3135
3136AC_ARG_WITH(onedrive-client-id,
3137    AS_HELP_STRING([--with-onedrive-client-id],
3138        [Provides the client id of the application for OAuth2 authentication
3139        on OneDrive. If either this or --with-onedrive-client-secret is
3140        empty, the feature will be disabled]),
3141)
3142
3143AC_ARG_WITH(onedrive-client-secret,
3144    AS_HELP_STRING([--with-onedrive-client-secret],
3145        [Provides the client secret of the application for OAuth2
3146        authentication on OneDrive. If either this or
3147        --with-onedrive-client-id is empty, the feature will be disabled]),
3148)
3149
3150dnl Check for coredumpctl support to present information about crashing test processes:
3151AC_ARG_WITH(coredumpctl,
3152    AS_HELP_STRING([--with-coredumpctl],
3153        [Use coredumpctl (together with systemd-run) to retrieve core dumps of crashing test
3154        processes.]))
3155
3156AC_ARG_WITH(buildconfig-recorded,
3157    AS_HELP_STRING([--with-buildconfig-recorded],
3158        [Put build config into version info reported by LOK. Incompatible with reproducible builds.]),
3159)
3160
3161AC_MSG_CHECKING([whether to record build config])
3162if test -z "$with_buildconfig_recorded"; then
3163    with_buildconfig_recorded=no
3164fi
3165if test "$with_buildconfig_recorded" = no; then
3166    AC_MSG_RESULT([no])
3167else
3168    AC_MSG_RESULT([yes])
3169    # replace backslashes, to get a valid c++ string
3170    config_args=$(echo $ac_configure_args | tr '\\' '/')
3171    AC_DEFINE_UNQUOTED([BUILDCONFIG],[["$config_args"]],[Options passed to configure script])
3172    AC_DEFINE([BUILDCONFIG_RECORDED],[1],[Options passed to configure script])
3173fi
3174
3175dnl ===================================================================
3176dnl Do we want to use pre-build binary tarball for recompile
3177dnl ===================================================================
3178
3179if test "$enable_library_bin_tar" = "yes" ; then
3180    USE_LIBRARY_BIN_TAR=TRUE
3181else
3182    USE_LIBRARY_BIN_TAR=
3183fi
3184AC_SUBST(USE_LIBRARY_BIN_TAR)
3185
3186dnl ===================================================================
3187dnl Test whether build target is Release Build
3188dnl ===================================================================
3189AC_MSG_CHECKING([whether build target is Release Build])
3190if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
3191    AC_MSG_RESULT([no])
3192    ENABLE_RELEASE_BUILD=
3193    dnl Pu the value on one line as make (at least on macOS) seems to ignore
3194    dnl the newlines and then complains about spaces.
3195    GET_TASK_ALLOW_ENTITLEMENT='<!-- We want to be able to debug a hardened process when not building for release --><key>com.apple.security.get-task-allow</key><true/>'
3196else
3197    AC_MSG_RESULT([yes])
3198    ENABLE_RELEASE_BUILD=TRUE
3199    GET_TASK_ALLOW_ENTITLEMENT=
3200fi
3201AC_SUBST(ENABLE_RELEASE_BUILD)
3202AC_SUBST(GET_TASK_ALLOW_ENTITLEMENT)
3203
3204dnl ===================================================================
3205dnl Test whether build should auto use hardening compiler flags
3206dnl ===================================================================
3207AC_MSG_CHECKING([whether build should auto use hardening compiler flags])
3208if test "$enable_hardening_flags" = "" -o "$enable_hardening_flags" = "no"; then
3209    AC_MSG_RESULT([no])
3210    ENABLE_HARDENING_FLAGS=
3211else
3212    AC_MSG_RESULT([yes])
3213    ENABLE_HARDENING_FLAGS=TRUE
3214fi
3215AC_SUBST(ENABLE_HARDENING_FLAGS)
3216
3217AC_MSG_CHECKING([whether to build a Community flavor])
3218if test -z "$enable_community_flavor" -o "$enable_community_flavor" = "yes"; then
3219    AC_DEFINE(HAVE_FEATURE_COMMUNITY_FLAVOR)
3220    AC_MSG_RESULT([yes])
3221else
3222    AC_MSG_RESULT([no])
3223fi
3224
3225dnl ===================================================================
3226dnl Test whether to sign Windows Build
3227dnl ===================================================================
3228AC_MSG_CHECKING([whether to sign windows build])
3229if test "$enable_windows_build_signing" = "yes" -a "$_os" = "WINNT"; then
3230    AC_MSG_RESULT([yes])
3231    WINDOWS_BUILD_SIGNING="TRUE"
3232else
3233    AC_MSG_RESULT([no])
3234    WINDOWS_BUILD_SIGNING="FALSE"
3235fi
3236AC_SUBST(WINDOWS_BUILD_SIGNING)
3237
3238dnl ===================================================================
3239dnl MacOSX build and runtime environment options
3240dnl ===================================================================
3241
3242AC_ARG_WITH(macosx-version-min-required,
3243    AS_HELP_STRING([--with-macosx-version-min-required=<version>],
3244        [set the minimum OS version needed to run the built LibreOffice])
3245    [
3246                          e. g.: --with-macosx-version-min-required=11.0
3247    ],
3248,)
3249
3250dnl ===================================================================
3251dnl Check for incompatible options set by fuzzing, and reset those
3252dnl automatically to working combinations
3253dnl ===================================================================
3254
3255if test "$libo_fuzzed_enable_dbus" = yes -a "$libo_fuzzed_enable_avahi" -a \
3256        "$enable_dbus" != "$enable_avahi"; then
3257    AC_MSG_NOTICE([Resetting --enable-avahi=$enable_dbus])
3258    enable_avahi=$enable_dbus
3259fi
3260
3261add_lopath_after ()
3262{
3263    if ! echo "$LO_PATH" | $EGREP -q "(^|${P_SEP})$1($|${P_SEP})"; then
3264        LO_PATH="${LO_PATH:+$LO_PATH$P_SEP}$1"
3265    fi
3266}
3267
3268add_lopath_before ()
3269{
3270    local IFS=${P_SEP}
3271    local path_cleanup
3272    local dir
3273    for dir in $LO_PATH ; do
3274        if test "$dir" != "$1" ; then
3275            path_cleanup=${path_cleanup:+$path_cleanup$P_SEP}$dir
3276        fi
3277    done
3278    LO_PATH="$1${path_cleanup:+$P_SEP$path_cleanup}"
3279}
3280
3281dnl ===================================================================
3282dnl check for required programs (grep, awk, sed, bash)
3283dnl ===================================================================
3284
3285pathmunge ()
3286{
3287    local new_path
3288    if test -n "$1"; then
3289        if test "$build_os" = "cygwin"; then
3290            if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
3291                PathFormat "$1"
3292                new_path=`cygpath -sm "$formatted_path"`
3293            else
3294                PathFormat "$1"
3295                new_path=`cygpath -u "$formatted_path"`
3296            fi
3297        else
3298            new_path="$1"
3299        fi
3300        if test "$2" = "after"; then
3301            add_lopath_after "$new_path"
3302        else
3303            add_lopath_before "$new_path"
3304        fi
3305    fi
3306}
3307
3308AC_PROG_AWK
3309AC_PATH_PROG( AWK, $AWK)
3310if test -z "$AWK"; then
3311    AC_MSG_ERROR([install awk to run this script])
3312fi
3313
3314AC_PATH_PROG(BASH, bash)
3315if test -z "$BASH"; then
3316    AC_MSG_ERROR([bash not found in \$PATH])
3317fi
3318AC_SUBST(BASH)
3319
3320# prefer parallel compression tools, if available
3321AC_PATH_PROG(COMPRESSIONTOOL, pigz)
3322if test -z "$COMPRESSIONTOOL"; then
3323    AC_PATH_PROG(COMPRESSIONTOOL, gzip)
3324    if test -z "$COMPRESSIONTOOL"; then
3325        AC_MSG_ERROR([gzip not found in \$PATH])
3326    fi
3327fi
3328AC_SUBST(COMPRESSIONTOOL)
3329
3330AC_MSG_CHECKING([for GNU or BSD tar])
3331for a in $GNUTAR gtar gnutar tar bsdtar /usr/sfw/bin/gtar; do
3332    $a --version 2> /dev/null | grep -E "GNU|bsdtar"  2>&1 > /dev/null
3333    if test $? -eq 0;  then
3334        GNUTAR=$a
3335        break
3336    fi
3337done
3338AC_MSG_RESULT($GNUTAR)
3339if test -z "$GNUTAR"; then
3340    AC_MSG_ERROR([not found. install GNU or BSD tar.])
3341fi
3342AC_SUBST(GNUTAR)
3343
3344AC_MSG_CHECKING([for tar's option to strip components])
3345$GNUTAR --help 2> /dev/null | grep -E "bsdtar|strip-components" 2>&1 >/dev/null
3346if test $? -eq 0; then
3347    STRIP_COMPONENTS="--strip-components"
3348else
3349    $GNUTAR --help 2> /dev/null | grep -E "strip-path" 2>&1 >/dev/null
3350    if test $? -eq 0; then
3351        STRIP_COMPONENTS="--strip-path"
3352    else
3353        STRIP_COMPONENTS="unsupported"
3354    fi
3355fi
3356AC_MSG_RESULT($STRIP_COMPONENTS)
3357if test x$STRIP_COMPONENTS = xunsupported; then
3358    AC_MSG_ERROR([you need a tar that is able to strip components.])
3359fi
3360AC_SUBST(STRIP_COMPONENTS)
3361
3362dnl It is useful to have a BUILD_TYPE keyword to distinguish "normal"
3363dnl desktop OSes from "mobile" ones.
3364
3365dnl We assume that a non-DESKTOP build type is also a non-NATIVE one.
3366dnl In other words, that when building for an OS that is not a
3367dnl "desktop" one but a "mobile" one, we are always cross-compiling.
3368
3369dnl Note the direction of the implication; there is no assumption that
3370dnl cross-compiling would imply a non-desktop OS.
3371
3372if test $_os != iOS -a $_os != Android -a "$enable_fuzzers" != "yes"; then
3373    BUILD_TYPE="$BUILD_TYPE DESKTOP"
3374    AC_DEFINE(HAVE_FEATURE_DESKTOP)
3375    if test "$_os" != Emscripten; then
3376        AC_DEFINE(HAVE_FEATURE_MULTIUSER_ENVIRONMENT)
3377    fi
3378fi
3379
3380# explicitly doesn't include enable_gtk3=no and enable_qt5=yes, so it should
3381# also work with the default gtk3 plugin.
3382if test "$enable_wasm_strip" = "yes"; then
3383    enable_avmedia=no
3384    enable_libcmis=no
3385    enable_coinmp=no
3386    enable_cups=no
3387    enable_database_connectivity=no
3388    enable_dbus=no
3389    enable_dconf=no
3390    test "${enable_dynamic_loading+set}" = set -o "$_os" != Emscripten || enable_dynamic_loading=no
3391    enable_extension_integration=no
3392    enable_extensions=no
3393    enable_extension_update=no
3394    enable_gio=no
3395    enable_gpgmepp=no
3396    enable_ldap=no
3397    enable_lotuswordpro=no
3398    enable_lpsolve=no
3399    enable_nss=no
3400    enable_odk=no
3401    enable_online_update=no
3402    enable_opencl=no
3403    enable_pdfimport=no
3404    enable_randr=no
3405    enable_report_builder=no
3406    enable_scripting=no
3407    enable_sdremote=no
3408    enable_sdremote_bluetooth=no
3409    enable_skia=no
3410    enable_xmlhelp=no
3411    enable_zxing=no
3412    test_libepubgen=no
3413    test_libcmis=no
3414    with_galleries=no
3415    with_gssapi=no
3416    with_templates=no
3417    with_x=no
3418
3419    test "${with_fonts+set}" = set || with_fonts=yes
3420
3421    dnl AC_DEFINE sets the value to 1 (TRUE) in the C++ header.
3422    AC_DEFINE(ENABLE_WASM_STRIP_ACCESSIBILITY)
3423#    AC_DEFINE(ENABLE_WASM_STRIP_CHART)
3424    AC_DEFINE(ENABLE_WASM_STRIP_EXTRA)
3425#    AC_DEFINE(ENABLE_WASM_STRIP_HUNSPELL)
3426    AC_DEFINE(ENABLE_WASM_STRIP_PINGUSER)
3427    AC_DEFINE(ENABLE_WASM_STRIP_PREMULTIPLY)
3428    AC_DEFINE(ENABLE_WASM_STRIP_RECENT)
3429    AC_DEFINE(ENABLE_WASM_STRIP_RECOVERYUI)
3430    AC_DEFINE(ENABLE_WASM_STRIP_SPLASH)
3431fi
3432
3433# Whether to build "avmedia" functionality or not.
3434
3435if test "$enable_avmedia" = yes; then
3436    BUILD_TYPE="$BUILD_TYPE AVMEDIA"
3437    AC_DEFINE(HAVE_FEATURE_AVMEDIA)
3438else
3439    test_gstreamer_1_0=no
3440fi
3441
3442# Decide whether to build database connectivity stuff (including Base) or not.
3443if test "$enable_database_connectivity" != no; then
3444    BUILD_TYPE="$BUILD_TYPE DBCONNECTIVITY"
3445    AC_DEFINE(HAVE_FEATURE_DBCONNECTIVITY)
3446else
3447    if test "$_os" = iOS; then
3448        AC_MSG_ERROR([Presumably can't disable DB connectivity on iOS.])
3449    fi
3450    disable_database_connectivity_dependencies
3451fi
3452
3453if test -z "$enable_extensions"; then
3454    # For iOS and Android Viewer, disable extensions unless specifically overridden with --enable-extensions.
3455    if test $_os != iOS && test $_os != Android -o "$ENABLE_ANDROID_LOK" = TRUE ; then
3456        enable_extensions=yes
3457    fi
3458fi
3459
3460DISABLE_SCRIPTING=''
3461if test "$enable_scripting" = yes; then
3462    BUILD_TYPE="$BUILD_TYPE SCRIPTING"
3463    AC_DEFINE(HAVE_FEATURE_SCRIPTING)
3464else
3465    DISABLE_SCRIPTING='TRUE'
3466    SCPDEFS="$SCPDEFS -DDISABLE_SCRIPTING"
3467fi
3468
3469if test $_os = iOS -o $_os = Android -o $_os = Emscripten; then
3470    # Disable dynamic_loading always for iOS and Android
3471    enable_dynamic_loading=no
3472elif test -z "$enable_dynamic_loading"; then
3473    # Otherwise enable it unless specifically disabled
3474    enable_dynamic_loading=yes
3475fi
3476
3477DISABLE_DYNLOADING=''
3478if test "$enable_dynamic_loading" = yes; then
3479    BUILD_TYPE="$BUILD_TYPE DYNLOADING"
3480else
3481    DISABLE_DYNLOADING='TRUE'
3482    if test $_os != iOS -a $_os != Darwin -a $_os != Android -a $_os != WINNT; then
3483        enable_database_connectivity=no
3484        enable_nss=no
3485        enable_odk=no
3486        enable_python=no
3487        enable_skia=no
3488        with_java=no
3489    fi
3490fi
3491AC_SUBST(DISABLE_DYNLOADING)
3492
3493ENABLE_CUSTOMTARGET_COMPONENTS=
3494if test "$enable_customtarget_components" = yes -a "$DISABLE_DYNLOADING" = TRUE; then
3495    ENABLE_CUSTOMTARGET_COMPONENTS=TRUE
3496    if test -n "$with_locales" -a "$with_locales" != en -a "$with_locales" != ALL; then
3497        AC_MSG_ERROR([Currently just --with-locales=all or en is supported with --enable-customtarget-components])
3498    fi
3499fi
3500AC_SUBST(ENABLE_CUSTOMTARGET_COMPONENTS)
3501
3502if test "$enable_extensions" = yes; then
3503    BUILD_TYPE="$BUILD_TYPE EXTENSIONS"
3504    AC_DEFINE(HAVE_FEATURE_EXTENSIONS)
3505else
3506    enable_extension_integration=no
3507    enable_extension_update=no
3508fi
3509
3510# remember SYSBASE value
3511AC_SUBST(SYSBASE)
3512
3513dnl ===================================================================
3514dnl  Sort out various gallery compilation options
3515dnl ===================================================================
3516WITH_GALLERY_BUILD=TRUE
3517AC_MSG_CHECKING([how to build and package galleries])
3518if test -n "${with_galleries}"; then
3519    if test "$with_galleries" = "build"; then
3520        if test "$enable_database_connectivity" = no; then
3521            AC_MSG_ERROR([DB connectivity is needed for gengal / svx])
3522        fi
3523        AC_MSG_RESULT([build from source images internally])
3524    elif test "$with_galleries" = "no"; then
3525        WITH_GALLERY_BUILD=
3526        AC_MSG_RESULT([disable non-internal gallery build])
3527    else
3528        AC_MSG_ERROR([unknown value --with-galleries=$with_galleries])
3529    fi
3530else
3531    if test $_os != iOS -a $_os != Android; then
3532        AC_MSG_RESULT([internal src images for desktop])
3533    else
3534        WITH_GALLERY_BUILD=
3535        AC_MSG_RESULT([disable src image build])
3536    fi
3537fi
3538AC_SUBST(WITH_GALLERY_BUILD)
3539
3540dnl ===================================================================
3541dnl  Sort out various templates compilation options
3542dnl ===================================================================
3543WITH_TEMPLATES=TRUE
3544AC_MSG_CHECKING([build with or without template files])
3545if test -n "${with_templates}"; then
3546    if test "$with_templates" = "yes"; then
3547        AC_MSG_RESULT([enable all templates])
3548    elif test "$with_templates" = "no"; then
3549        WITH_TEMPLATES=
3550        AC_MSG_RESULT([disable non-internal templates])
3551    else
3552        AC_MSG_ERROR([unknown value --with-templates=$with_templates])
3553    fi
3554else
3555    if test $_os != iOS -a $_os != Android -a $_os != Emscripten; then
3556        AC_MSG_RESULT([enable all templates])
3557    else
3558        WITH_TEMPLATES=
3559        AC_MSG_RESULT([disable non-internal templates])
3560    fi
3561fi
3562AC_SUBST(WITH_TEMPLATES)
3563
3564dnl ===================================================================
3565dnl  Checks if ccache is available
3566dnl ===================================================================
3567CCACHE_DEPEND_MODE=
3568if test "$enable_ccache" = "no"; then
3569    CCACHE=""
3570elif test -n "$enable_ccache" -o \( "$enable_ccache" = "" -a "$enable_icecream" != "yes" \); then
3571    case "%$CC%$CXX%" in
3572    # If $CC and/or $CXX already contain "ccache" (possibly suffixed with some version number etc),
3573    # assume that's good then
3574    *%ccache[[-_' ']]*|*/ccache[[-_' ']]*)
3575        AC_MSG_NOTICE([ccache seems to be included in a pre-defined CC and/or CXX])
3576        CCACHE_DEPEND_MODE=1
3577        ;;
3578    *)
3579        # try to use our own ccache if it is available and CCACHE was not already defined
3580        if test -z "$CCACHE"; then
3581            if test "$_os" = "WINNT"; then
3582                ccache_ext=.exe # e.g. openssl build needs ccache.exe, not just ccache
3583            fi
3584            if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/ccache$ccache_ext" ; then
3585                CCACHE="$LODE_HOME/opt/bin/ccache$ccache_ext"
3586            elif test -x "/opt/lo/bin/ccache$ccache_ext"; then
3587                CCACHE="/opt/lo/bin/ccache$ccache_ext"
3588            fi
3589        fi
3590        AC_PATH_PROG([CCACHE],[ccache],[not found])
3591        if test "$CCACHE" != "not found" -a "$_os" = "WINNT"; then
3592            CCACHE=`win_short_path_for_make "$CCACHE"`
3593            # check that it has MSVC support (it should recognize it in CCACHE_COMPILERTYPE)
3594            rm -f conftest.txt
3595            AC_MSG_CHECKING([whether $CCACHE has MSVC support])
3596            CCACHE_COMPILERTYPE=cl CCACHE_LOGFILE=conftest.txt $CCACHE echo >/dev/null 2>/dev/null
3597            if grep -q 'Config: (environment) compiler_type = cl' conftest.txt; then
3598                AC_MSG_RESULT(yes)
3599            else
3600                AC_MSG_RESULT(no)
3601                CCACHE="not found"
3602            fi
3603            rm -f conftest.txt
3604        fi
3605        if test "$CCACHE" = "not found" -a "$_os" = "WINNT"; then
3606            # on windows/VC perhaps sccache is around?
3607            case "%$CC%$CXX%" in
3608            # If $CC and/or $CXX already contain "sccache" (possibly suffixed with some version number etc),
3609            # assume that's good then
3610            *%sccache[[-_' ']]*|*/sccache[[-_' ']]*)
3611                AC_MSG_NOTICE([sccache seems to be included in a pre-defined CC and/or CXX])
3612                CCACHE_DEPEND_MODE=1
3613                SCCACHE=1
3614                ;;
3615            *)
3616                # for sharing code below, reuse CCACHE env var
3617                AC_PATH_PROG([CCACHE],[sccache],[not found])
3618                if test "$CCACHE" != "not found"; then
3619                    CCACHE=`win_short_path_for_make "$CCACHE"`
3620                    SCCACHE=1
3621                    CCACHE_DEPEND_MODE=1
3622                fi
3623                ;;
3624            esac
3625        fi
3626        if test "$CCACHE" = "not found"; then
3627            CCACHE=""
3628        fi
3629        if test -n "$CCACHE" -a -z "$SCCACHE"; then
3630            CCACHE_DEPEND_MODE=1
3631            # Need to check for ccache version: otherwise prevents
3632            # caching of the results (like "-x objective-c++" for Mac)
3633            if test $_os = Darwin -o $_os = iOS; then
3634                # Check ccache version
3635                AC_MSG_CHECKING([whether version of ccache is suitable])
3636                CCACHE_VERSION=`"$CCACHE" -V | "$AWK" '/^ccache version/{print $3}'`
3637                CCACHE_NUMVER=`echo $CCACHE_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
3638                if test "$CCACHE_VERSION" = "2.4_OOo" -o "$CCACHE_NUMVER" -ge "030100"; then
3639                    AC_MSG_RESULT([yes, $CCACHE_VERSION])
3640                else
3641                    AC_MSG_RESULT([no, $CCACHE_VERSION])
3642                    CCACHE=""
3643                    CCACHE_DEPEND_MODE=
3644                fi
3645            fi
3646        fi
3647        if test "$enable_ccache" = yes && test -z "$CCACHE"; then
3648            AC_MSG_ERROR([No suitable ccache found])
3649        fi
3650        ;;
3651    esac
3652else
3653    CCACHE=""
3654fi
3655if test "$enable_ccache" = "nodepend"; then
3656    CCACHE_DEPEND_MODE=""
3657fi
3658AC_SUBST(CCACHE_DEPEND_MODE)
3659
3660# sccache defaults are good enough
3661if test "$CCACHE" != "" -a -z "$SCCACHE"; then
3662    # e.g. (/home/rene/.config/ccache/ccache.conf) max_size = 20.0G
3663    # or (...) max_size = 20.0 G
3664    # -p works with both 4.2 and 4.4
3665    ccache_size_msg=$([$CCACHE -p | $AWK /max_size/'{ print $4 $5 }' | sed -e 's/\.[0-9]*//'])
3666    ccache_size=$(echo "$ccache_size_msg" | grep "G" | sed -e 's/G.*$//')
3667    if test "$ccache_size" = ""; then
3668        ccache_size=$(echo "$ccache_size_msg" | grep "M" | sed -e 's/\ M.*$//')
3669        if test "$ccache_size" = ""; then
3670            ccache_size=0
3671        fi
3672        # we could not determine the size or it was less than 1GB -> disable auto-ccache
3673        if test $ccache_size -lt 1024; then
3674            CCACHE=""
3675            AC_MSG_WARN([ccache's cache size is less than 1GB using it is counter-productive: Disabling auto-ccache detection])
3676            add_warning "ccache's cache size is less than 1GB using it is counter-productive: auto-ccache detection disabled"
3677        else
3678            # warn that ccache may be too small for debug build
3679            AC_MSG_WARN([ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build])
3680            add_warning "ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build"
3681        fi
3682    else
3683        if test $ccache_size -lt 5; then
3684            #warn that ccache may be too small for debug build
3685            AC_MSG_WARN([ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build])
3686            add_warning "ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build"
3687        fi
3688    fi
3689fi
3690
3691ENABLE_Z7_DEBUG=
3692if test "$enable_z7_debug" != no; then
3693    if test "$enable_z7_debug" = yes -o -n "$CCACHE"; then
3694        ENABLE_Z7_DEBUG=TRUE
3695    fi
3696else
3697    AC_MSG_WARN([ccache will not work with --disable-z7-debug])
3698    add_warning "ccache will not work with --disable-z7-debug"
3699fi
3700AC_SUBST(ENABLE_Z7_DEBUG)
3701
3702dnl ===================================================================
3703dnl  Checks for C compiler,
3704dnl  The check for the C++ compiler is later on.
3705dnl ===================================================================
3706if test "$_os" != "WINNT"; then
3707    GCC_HOME_SET="true"
3708    AC_MSG_CHECKING([gcc home])
3709    if test -z "$with_gcc_home"; then
3710        if test "$enable_icecream" = "yes"; then
3711            if test -d "/usr/lib/icecc/bin"; then
3712                GCC_HOME="/usr/lib/icecc/"
3713            elif test -d "/usr/libexec/icecc/bin"; then
3714                GCC_HOME="/usr/libexec/icecc/"
3715            elif test -d "/opt/icecream/bin"; then
3716                GCC_HOME="/opt/icecream/"
3717            else
3718                AC_MSG_ERROR([Could not figure out the location of icecream GCC wrappers, manually use --with-gcc-home])
3719
3720            fi
3721        else
3722            GCC_HOME=`command -v gcc | $SED -e s,/bin/gcc,,`
3723            GCC_HOME_SET="false"
3724        fi
3725    else
3726        GCC_HOME="$with_gcc_home"
3727    fi
3728    AC_MSG_RESULT($GCC_HOME)
3729
3730    if test "$GCC_HOME_SET" = "true"; then
3731        if test -z "$CC"; then
3732            CC="$GCC_HOME/bin/gcc"
3733            CC_BASE="gcc"
3734        fi
3735        if test -z "$CXX"; then
3736            CXX="$GCC_HOME/bin/g++"
3737            CXX_BASE="g++"
3738        fi
3739    fi
3740fi
3741
3742COMPATH=`dirname "$CC"`
3743if test "$COMPATH" = "."; then
3744    AC_PATH_PROGS(COMPATH, $CC)
3745    dnl double square bracket to get single because of M4 quote...
3746    COMPATH=`echo $COMPATH | $SED "s@/[[^/:]]*\\\$@@"`
3747fi
3748COMPATH=`echo $COMPATH | $SED "s@/[[Bb]][[Ii]][[Nn]]\\\$@@"`
3749
3750dnl ===================================================================
3751dnl Java support
3752dnl ===================================================================
3753AC_MSG_CHECKING([whether to build with Java support])
3754javacompiler="javac"
3755javadoc="javadoc"
3756if test "$with_java" != "no"; then
3757    if test "$DISABLE_SCRIPTING" = TRUE; then
3758        AC_MSG_RESULT([no, overridden by --disable-scripting])
3759        ENABLE_JAVA=""
3760        with_java=no
3761    else
3762        AC_MSG_RESULT([yes])
3763        ENABLE_JAVA="TRUE"
3764        AC_DEFINE(HAVE_FEATURE_JAVA)
3765    fi
3766else
3767    AC_MSG_RESULT([no])
3768    ENABLE_JAVA=""
3769fi
3770
3771AC_SUBST(ENABLE_JAVA)
3772
3773dnl ENABLE_JAVA="TRUE" if we want there to be *run-time* (and build-time) support for Java
3774
3775dnl ENABLE_JAVA="" indicate no Java support at all
3776
3777dnl ===================================================================
3778dnl Check macOS SDK and compiler
3779dnl ===================================================================
3780
3781if test $_os = Darwin; then
3782
3783    # The SDK in the currently selected Xcode should be found.
3784
3785    AC_MSG_CHECKING([what macOS SDK to use])
3786    # XCode only ships with a single SDK for a while now, and using older SDKs alongside is not
3787    # really supported anymore, instead you'd use different copies of Xcode, each with their own
3788    # SDK, and thus xcrun will pick the SDK that matches the currently selected Xcode version
3789    # also restricting the SDK version to "known good" versions doesn't seem necessary anymore, the
3790    # problems that existed in the PPC days with target versions not being respected or random
3791    # failures seems to be a thing of the past or rather: limiting either the Xcode version or the
3792    # SDK version is enough, no need to do both...
3793    MACOSX_SDK_PATH=`xcrun --sdk macosx --show-sdk-path 2> /dev/null`
3794    if test ! -d "$MACOSX_SDK_PATH"; then
3795        AC_MSG_ERROR([Could not find an appropriate macOS SDK])
3796    fi
3797    macosx_sdk=`xcodebuild -version -sdk "$MACOSX_SDK_PATH" SDKVersion`
3798    MACOSX_SDK_BUILD_VERSION=$(xcodebuild -version -sdk "$MACOSX_SDK_PATH" ProductBuildVersion)
3799    # format changed between 10.9 and 10.10 - up to 10.9 it was just four digits (1090), starting
3800    # with macOS 10.10 it was switched to account for x.y.z with six digits, 10.10 is 101000,
3801    # 10.10.2 is 101002
3802    # we don't target the lower versions anymore, so it doesn't matter that we don't generate the
3803    # correct version in case such an old SDK is specified, it will be rejected later anyway
3804    MACOSX_SDK_VERSION=$(echo $macosx_sdk | $AWK -F. '{ print $1*10000+$2*100+$3 }')
3805    # we require Xcode 14.2 or later, and thus macOS SDK 13.1 or later/older versions might work
3806    # but are untested
3807    if test $MACOSX_SDK_VERSION -lt 130300; then
3808        AC_MSG_ERROR([macOS SDK $macosx_sdk is not supported, lowest supported version is 13.3])
3809    fi
3810    AC_MSG_RESULT([macOS SDK $macosx_sdk at $MACOSX_SDK_PATH])
3811
3812    AC_MSG_CHECKING([what minimum version of macOS to require])
3813    if test "$with_macosx_version_min_required" = "" ; then
3814        with_macosx_version_min_required="11.0";
3815    fi
3816    # see same notes about MACOSX_SDK_VERSION above
3817    MAC_OS_X_VERSION_MIN_REQUIRED=$(echo $with_macosx_version_min_required | $AWK -F. '{ print $1*10000+$2*100+$3 }')
3818    if test $MAC_OS_X_VERSION_MIN_REQUIRED -lt 110000; then
3819        AC_MSG_ERROR([with-macosx-version-min-required $with_macosx_version_min_required is not a supported value, minimum supported version is 11])
3820    fi
3821    AC_MSG_RESULT([$with_macosx_version_min_required])
3822
3823    AC_MSG_CHECKING([that macosx-version-min-required is coherent with macos-with-sdk])
3824    if test $MAC_OS_X_VERSION_MIN_REQUIRED -gt $MACOSX_SDK_VERSION; then
3825        AC_MSG_ERROR([the version minimum required ($with_macosx_version_min_required) cannot be greater than the sdk level ($macosx_sdk)])
3826    else
3827        AC_MSG_RESULT([yes])
3828    fi
3829
3830    # export this so that "xcrun" invocations later return matching values
3831    DEVELOPER_DIR="${MACOSX_SDK_PATH%/SDKs*}"
3832    DEVELOPER_DIR="${DEVELOPER_DIR%/Platforms*}"
3833    export DEVELOPER_DIR
3834    FRAMEWORKSHOME="$MACOSX_SDK_PATH/System/Library/Frameworks"
3835    MACOSX_DEPLOYMENT_TARGET="$with_macosx_version_min_required"
3836
3837    AC_MSG_CHECKING([whether Xcode is new enough])
3838    my_xcode_ver1=$(xcrun xcodebuild -version | head -n 1)
3839    my_xcode_ver2=${my_xcode_ver1#Xcode }
3840    my_xcode_ver3=$(printf %s "$my_xcode_ver2" | $AWK -F. '{ print $1*100+($2<100?$2:99) }')
3841    if test "$my_xcode_ver3" -ge 1403; then
3842        AC_MSG_RESULT([yes ($my_xcode_ver2)])
3843        if test $MAC_OS_X_VERSION_MIN_REQUIRED -lt 120000; then
3844            if test "$my_xcode_ver3" -eq 1500; then
3845                dnl the bug was already fixed on 15.1 and 15.2 still has the same OS requirements as 15.0
3846                dnl in other words all affected users could update to a working Xcode version
3847                AC_MSG_WARN([Use a current version of XCode or bump the minimum deployment target])
3848                AC_MSG_WARN([[see https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking]])
3849                AC_MSG_ERROR([Xcode 15.0 has a bug in the new linker that causes runtime crashes on macOS 11 - aborting])
3850            fi
3851        fi
3852    else
3853        AC_MSG_ERROR(["$my_xcode_ver1" is too old or unrecognized, must be at least Xcode 14.3])
3854    fi
3855
3856    my_xcode_ver1=$(xcrun xcodebuild -version | tail -n 1)
3857    MACOSX_XCODE_BUILD_VERSION=${my_xcode_ver1#Build version }
3858
3859    LIBTOOL=/usr/bin/libtool
3860    INSTALL_NAME_TOOL=install_name_tool
3861    if test -z "$save_CC"; then
3862        stdlib=-stdlib=libc++
3863
3864        AC_MSG_CHECKING([what C compiler to use])
3865        CC="`xcrun -find clang`"
3866        CC_BASE=`first_arg_basename "$CC"`
3867        if test "$host_cpu" = x86_64; then
3868            CC+=" -target x86_64-apple-macos"
3869        else
3870            CC+=" -target arm64-apple-macos"
3871        fi
3872        CC+=" -mmacosx-version-min=$with_macosx_version_min_required -isysroot $MACOSX_SDK_PATH"
3873        AC_MSG_RESULT([$CC])
3874
3875        AC_MSG_CHECKING([what C++ compiler to use])
3876        CXX="`xcrun -find clang++`"
3877        CXX_BASE=`first_arg_basename "$CXX"`
3878        if test "$host_cpu" = x86_64; then
3879            CXX+=" -target x86_64-apple-macos"
3880        else
3881            CXX+=" -target arm64-apple-macos"
3882        fi
3883        CXX+=" $stdlib -mmacosx-version-min=$with_macosx_version_min_required -isysroot $MACOSX_SDK_PATH"
3884        AC_MSG_RESULT([$CXX])
3885
3886        INSTALL_NAME_TOOL=`xcrun -find install_name_tool`
3887        AR=`xcrun -find ar`
3888        NM=`xcrun -find nm`
3889        STRIP=`xcrun -find strip`
3890        LIBTOOL=`xcrun -find libtool`
3891        RANLIB=`xcrun -find ranlib`
3892    fi
3893
3894    AC_MSG_CHECKING([whether to do code signing])
3895
3896    if test -z "$enable_macosx_code_signing" -o "$enable_macosx_code_signing" == "no" ; then
3897        AC_MSG_RESULT([no])
3898    else
3899        if test "$enable_macosx_code_signing" = yes; then
3900            # By default use the first suitable certificate (?).
3901
3902            # https://stackoverflow.com/questions/13196291/difference-between-mac-developer-and-3rd-party-mac-developer-application
3903            # says that the "Mac Developer" certificate is useful just for self-testing. For distribution
3904            # outside the Mac App Store, use the "Developer ID Application" one, and for distribution in
3905            # the App Store, the "3rd Party Mac Developer" one. I think it works best to the
3906            # "Developer ID Application" one.
3907            identity="Developer ID Application:"
3908        else
3909            identity=$enable_macosx_code_signing
3910        fi
3911        identity=`security find-identity -p codesigning -v 2>/dev/null | $AWK "/$identity/{print \\$2; exit}"`
3912        if test -n "$identity"; then
3913            MACOSX_CODESIGNING_IDENTITY=$identity
3914            pretty_name=`security find-identity -p codesigning -v | grep "$MACOSX_CODESIGNING_IDENTITY" | sed -e 's/^[[^"]]*"//' -e 's/"//'`
3915            MACOSX_CODESIGNING_TEAM_IDENTIFIER=`echo $pretty_name | sed -e 's#.*(\([[:alnum:]]*\))#\1#'`
3916            AC_MSG_RESULT([yes, using the identity $MACOSX_CODESIGNING_IDENTITY for $pretty_name])
3917        else
3918            AC_MSG_ERROR([cannot determine identity to use])
3919        fi
3920    fi
3921
3922    AC_MSG_CHECKING([whether to create a Mac App Store package])
3923
3924    if test -z "$enable_macosx_package_signing" || test "$enable_macosx_package_signing" == no; then
3925        AC_MSG_RESULT([no])
3926    elif test -z "$MACOSX_CODESIGNING_IDENTITY"; then
3927        AC_MSG_ERROR([You forgot --enable-macosx-code-signing])
3928    else
3929        if test "$enable_macosx_package_signing" = yes; then
3930            # By default use the first suitable certificate.
3931            # It should be a "3rd Party Mac Developer Installer" one
3932            identity="3rd Party Mac Developer Installer:"
3933        else
3934            identity=$enable_macosx_package_signing
3935        fi
3936        identity=`security find-identity -v 2>/dev/null | $AWK "/$identity/ {print \\$2; exit}"`
3937        if test -n "$identity"; then
3938            MACOSX_PACKAGE_SIGNING_IDENTITY=$identity
3939            pretty_name=`security find-identity -v | grep "$MACOSX_PACKAGE_SIGNING_IDENTITY" | sed -e 's/^[[^"]]*"//' -e 's/"//'`
3940            AC_MSG_RESULT([yes, using the identity $MACOSX_PACKAGE_SIGNING_IDENTITY for $pretty_name])
3941        else
3942            AC_MSG_ERROR([Could not find any suitable '3rd Party Mac Developer Installer' certificate])
3943        fi
3944    fi
3945
3946    if test -n "$MACOSX_CODESIGNING_IDENTITY" -a -n "$MACOSX_PACKAGE_SIGNING_IDENTITY" -a "$MACOSX_CODESIGNING_IDENTITY" = "$MACOSX_PACKAGE_SIGNING_IDENTITY"; then
3947        AC_MSG_ERROR([You should not use the same identity for code and package signing])
3948    fi
3949
3950    AC_MSG_CHECKING([whether to sandbox the application])
3951
3952    if test -n "$ENABLE_JAVA" -a "$enable_macosx_sandbox" = yes; then
3953        AC_MSG_ERROR([macOS sandboxing (actually App Store rules) disallows use of Java])
3954    elif test "$enable_macosx_sandbox" = yes; then
3955        ENABLE_MACOSX_SANDBOX=TRUE
3956        AC_DEFINE(HAVE_FEATURE_MACOSX_SANDBOX)
3957        AC_MSG_RESULT([yes])
3958    else
3959        AC_MSG_RESULT([no])
3960    fi
3961
3962    AC_MSG_CHECKING([what macOS app bundle identifier to use])
3963    MACOSX_BUNDLE_IDENTIFIER=$with_macosx_bundle_identifier
3964    AC_MSG_RESULT([$MACOSX_BUNDLE_IDENTIFIER])
3965
3966    if test -n "$with_macosx_provisioning_profile" ; then
3967        if test ! -f "$with_macosx_provisioning_profile"; then
3968            AC_MSG_ERROR([provisioning profile not found at $with_macosx_provisioning_profile])
3969        else
3970            MACOSX_PROVISIONING_PROFILE=$with_macosx_provisioning_profile
3971            MACOSX_PROVISIONING_INFO=$([security cms -D -i "$MACOSX_PROVISIONING_PROFILE" | \
3972                xmllint --xpath "//key[.='com.apple.application-identifier' or .='com.apple.developer.team-identifier'] \
3973                    | //key[.='com.apple.application-identifier' or .='com.apple.developer.team-identifier']/following-sibling::string[1]" - | \
3974                sed -e 's#><#>\n\t<#g' -e 's#^#\t#'])
3975        fi
3976    fi
3977fi
3978AC_SUBST(MACOSX_SDK_PATH)
3979AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
3980AC_SUBST(MAC_OS_X_VERSION_MIN_REQUIRED)
3981AC_SUBST(INSTALL_NAME_TOOL)
3982AC_SUBST(LIBTOOL) # Note that the macOS libtool command is unrelated to GNU libtool
3983AC_SUBST(MACOSX_CODESIGNING_IDENTITY)
3984AC_SUBST(MACOSX_CODESIGNING_TEAM_IDENTIFIER)
3985AC_SUBST(MACOSX_PACKAGE_SIGNING_IDENTITY)
3986AC_SUBST(ENABLE_MACOSX_SANDBOX)
3987AC_SUBST(MACOSX_BUNDLE_IDENTIFIER)
3988AC_SUBST(MACOSX_PROVISIONING_INFO)
3989AC_SUBST(MACOSX_PROVISIONING_PROFILE)
3990AC_SUBST(MACOSX_SDK_BUILD_VERSION)
3991AC_SUBST(MACOSX_XCODE_BUILD_VERSION)
3992
3993dnl ===================================================================
3994dnl Check iOS SDK and compiler
3995dnl ===================================================================
3996
3997if test $_os = iOS; then
3998    AC_MSG_CHECKING([what iOS SDK to use])
3999
4000    if test "$enable_ios_simulator" = "yes"; then
4001        platformlc=iphonesimulator
4002        versionmin=-mios-simulator-version-min=14.5
4003    else
4004        platformlc=iphoneos
4005        versionmin=-miphoneos-version-min=14.5
4006    fi
4007
4008    sysroot=`xcrun --sdk $platformlc --show-sdk-path`
4009
4010    if ! test -d "$sysroot"; then
4011        AC_MSG_ERROR([Could not find iOS SDK $sysroot])
4012    fi
4013
4014    AC_MSG_RESULT($sysroot)
4015
4016    stdlib="-stdlib=libc++"
4017
4018    AC_MSG_CHECKING([what C compiler to use])
4019    CC="`xcrun -find clang`"
4020    CC_BASE=`first_arg_basename "$CC"`
4021    CC+=" -arch $host_cpu_for_clang -isysroot $sysroot $versionmin"
4022    AC_MSG_RESULT([$CC])
4023
4024    AC_MSG_CHECKING([what C++ compiler to use])
4025    CXX="`xcrun -find clang++`"
4026    CXX_BASE=`first_arg_basename "$CXX"`
4027    CXX+=" -arch $host_cpu_for_clang $stdlib -isysroot $sysroot $versionmin"
4028    AC_MSG_RESULT([$CXX])
4029
4030    INSTALL_NAME_TOOL=`xcrun -find install_name_tool`
4031    AR=`xcrun -find ar`
4032    NM=`xcrun -find nm`
4033    STRIP=`xcrun -find strip`
4034    LIBTOOL=`xcrun -find libtool`
4035    RANLIB=`xcrun -find ranlib`
4036fi
4037
4038AC_MSG_CHECKING([whether to treat the installation as read-only])
4039
4040if test $_os = Darwin; then
4041    enable_readonly_installset=yes
4042elif test "$enable_extensions" != yes; then
4043    enable_readonly_installset=yes
4044fi
4045if test "$enable_readonly_installset" = yes; then
4046    AC_MSG_RESULT([yes])
4047    AC_DEFINE(HAVE_FEATURE_READONLY_INSTALLSET)
4048else
4049    AC_MSG_RESULT([no])
4050fi
4051
4052dnl ===================================================================
4053dnl Structure of install set
4054dnl ===================================================================
4055
4056if test $_os = Darwin; then
4057    LIBO_BIN_FOLDER=MacOS
4058    LIBO_ETC_FOLDER=Resources
4059    LIBO_LIBEXEC_FOLDER=MacOS
4060    LIBO_LIB_FOLDER=Frameworks
4061    LIBO_LIB_PYUNO_FOLDER=Resources
4062    LIBO_SHARE_FOLDER=Resources
4063    LIBO_SHARE_HELP_FOLDER=Resources/help
4064    LIBO_SHARE_DOTNET_FOLDER=Resources/dotnet
4065    LIBO_SHARE_JAVA_FOLDER=Resources/java
4066    LIBO_SHARE_PRESETS_FOLDER=Resources/presets
4067    LIBO_SHARE_READMES_FOLDER=Resources/readmes
4068    LIBO_SHARE_RESOURCE_FOLDER=Resources/resource
4069    LIBO_SHARE_SHELL_FOLDER=Resources/shell
4070    LIBO_URE_BIN_FOLDER=MacOS
4071    LIBO_URE_ETC_FOLDER=Resources/ure/etc
4072    LIBO_URE_LIB_FOLDER=Frameworks
4073    LIBO_URE_MISC_FOLDER=Resources/ure/share/misc
4074    LIBO_URE_SHARE_JAVA_FOLDER=Resources/java
4075elif test $_os = WINNT; then
4076    LIBO_BIN_FOLDER=program
4077    LIBO_ETC_FOLDER=program
4078    LIBO_LIBEXEC_FOLDER=program
4079    LIBO_LIB_FOLDER=program
4080    LIBO_LIB_PYUNO_FOLDER=program
4081    LIBO_SHARE_FOLDER=share
4082    LIBO_SHARE_HELP_FOLDER=help
4083    LIBO_SHARE_DOTNET_FOLDER=program/dotnet
4084    LIBO_SHARE_JAVA_FOLDER=program/classes
4085    LIBO_SHARE_PRESETS_FOLDER=presets
4086    LIBO_SHARE_READMES_FOLDER=readmes
4087    LIBO_SHARE_RESOURCE_FOLDER=program/resource
4088    LIBO_SHARE_SHELL_FOLDER=program/shell
4089    LIBO_URE_BIN_FOLDER=program
4090    LIBO_URE_ETC_FOLDER=program
4091    LIBO_URE_LIB_FOLDER=program
4092    LIBO_URE_MISC_FOLDER=program
4093    LIBO_URE_SHARE_JAVA_FOLDER=program/classes
4094else
4095    LIBO_BIN_FOLDER=program
4096    LIBO_ETC_FOLDER=program
4097    LIBO_LIBEXEC_FOLDER=program
4098    LIBO_LIB_FOLDER=program
4099    LIBO_LIB_PYUNO_FOLDER=program
4100    LIBO_SHARE_FOLDER=share
4101    LIBO_SHARE_HELP_FOLDER=help
4102    LIBO_SHARE_DOTNET_FOLDER=program/dotnet
4103    LIBO_SHARE_JAVA_FOLDER=program/classes
4104    LIBO_SHARE_PRESETS_FOLDER=presets
4105    LIBO_SHARE_READMES_FOLDER=readmes
4106    if test "$enable_fuzzers" != yes; then
4107        LIBO_SHARE_RESOURCE_FOLDER=program/resource
4108    else
4109        LIBO_SHARE_RESOURCE_FOLDER=resource
4110    fi
4111    LIBO_SHARE_SHELL_FOLDER=program/shell
4112    LIBO_URE_BIN_FOLDER=program
4113    LIBO_URE_ETC_FOLDER=program
4114    LIBO_URE_LIB_FOLDER=program
4115    LIBO_URE_MISC_FOLDER=program
4116    LIBO_URE_SHARE_JAVA_FOLDER=program/classes
4117fi
4118AC_DEFINE_UNQUOTED(LIBO_BIN_FOLDER,"$LIBO_BIN_FOLDER")
4119AC_DEFINE_UNQUOTED(LIBO_ETC_FOLDER,"$LIBO_ETC_FOLDER")
4120AC_DEFINE_UNQUOTED(LIBO_LIBEXEC_FOLDER,"$LIBO_LIBEXEC_FOLDER")
4121AC_DEFINE_UNQUOTED(LIBO_LIB_FOLDER,"$LIBO_LIB_FOLDER")
4122AC_DEFINE_UNQUOTED(LIBO_LIB_PYUNO_FOLDER,"$LIBO_LIB_PYUNO_FOLDER")
4123AC_DEFINE_UNQUOTED(LIBO_SHARE_FOLDER,"$LIBO_SHARE_FOLDER")
4124AC_DEFINE_UNQUOTED(LIBO_SHARE_HELP_FOLDER,"$LIBO_SHARE_HELP_FOLDER")
4125AC_DEFINE_UNQUOTED(LIBO_SHARE_DOTNET_FOLDER,"$LIBO_SHARE_DOTNET_FOLDER")
4126AC_DEFINE_UNQUOTED(LIBO_SHARE_JAVA_FOLDER,"$LIBO_SHARE_JAVA_FOLDER")
4127AC_DEFINE_UNQUOTED(LIBO_SHARE_PRESETS_FOLDER,"$LIBO_SHARE_PRESETS_FOLDER")
4128AC_DEFINE_UNQUOTED(LIBO_SHARE_RESOURCE_FOLDER,"$LIBO_SHARE_RESOURCE_FOLDER")
4129AC_DEFINE_UNQUOTED(LIBO_SHARE_SHELL_FOLDER,"$LIBO_SHARE_SHELL_FOLDER")
4130AC_DEFINE_UNQUOTED(LIBO_URE_BIN_FOLDER,"$LIBO_URE_BIN_FOLDER")
4131AC_DEFINE_UNQUOTED(LIBO_URE_ETC_FOLDER,"$LIBO_URE_ETC_FOLDER")
4132AC_DEFINE_UNQUOTED(LIBO_URE_LIB_FOLDER,"$LIBO_URE_LIB_FOLDER")
4133AC_DEFINE_UNQUOTED(LIBO_URE_MISC_FOLDER,"$LIBO_URE_MISC_FOLDER")
4134AC_DEFINE_UNQUOTED(LIBO_URE_SHARE_JAVA_FOLDER,"$LIBO_URE_SHARE_JAVA_FOLDER")
4135
4136# Not all of them needed in config_host.mk, add more if need arises
4137AC_SUBST(LIBO_BIN_FOLDER)
4138AC_SUBST(LIBO_ETC_FOLDER)
4139AC_SUBST(LIBO_LIB_FOLDER)
4140AC_SUBST(LIBO_LIB_PYUNO_FOLDER)
4141AC_SUBST(LIBO_SHARE_FOLDER)
4142AC_SUBST(LIBO_SHARE_HELP_FOLDER)
4143AC_SUBST(LIBO_SHARE_DOTNET_FOLDER)
4144AC_SUBST(LIBO_SHARE_JAVA_FOLDER)
4145AC_SUBST(LIBO_SHARE_PRESETS_FOLDER)
4146AC_SUBST(LIBO_SHARE_READMES_FOLDER)
4147AC_SUBST(LIBO_SHARE_RESOURCE_FOLDER)
4148AC_SUBST(LIBO_URE_BIN_FOLDER)
4149AC_SUBST(LIBO_URE_ETC_FOLDER)
4150AC_SUBST(LIBO_URE_LIB_FOLDER)
4151AC_SUBST(LIBO_URE_MISC_FOLDER)
4152AC_SUBST(LIBO_URE_SHARE_JAVA_FOLDER)
4153
4154dnl ===================================================================
4155dnl Windows specific tests and stuff
4156dnl ===================================================================
4157
4158reg_get_value()
4159{
4160    # Return value: $regvalue
4161    unset regvalue
4162
4163    if test "$build_os" = "wsl"; then
4164        regvalue=$($WSL_LO_HELPER --read-registry $1 "$2/$3" 2>/dev/null)
4165        return
4166    elif test -n "$WSL_ONLY_AS_HELPER"; then
4167        regvalue=$(reg.exe query "$(echo $2 | tr '/' '\\')" /v "$3" /reg:$1 |sed -ne "s|\s*$3.*REG_SZ\s*\(.*\)[\s\r]*$|\1|p")
4168        return
4169    fi
4170
4171    local _regentry="/proc/registry${1}/${2}/${3}"
4172    if test -f "$_regentry"; then
4173        # Stop bash complaining about \0 bytes in input, as it can't handle them.
4174        # Registry keys read via /proc/registry* are always \0 terminated!
4175        local _regvalue=$(tr -d '\0' < "$_regentry")
4176        if test $? -eq 0; then
4177            regvalue=$_regvalue
4178        fi
4179    fi
4180}
4181
4182# Get a value from the 32-bit side of the Registry
4183reg_get_value_32()
4184{
4185    reg_get_value "32" "$1" "$2"
4186}
4187
4188# Get a value from the 64-bit side of the Registry
4189reg_get_value_64()
4190{
4191    reg_get_value "64" "$1" "$2"
4192}
4193
4194reg_list_values()
4195{
4196    # Return value: $reglist
4197    unset reglist
4198
4199    if test "$build_os" = "wsl"; then
4200        reglist=$($WSL_LO_HELPER --list-registry $1 "$2" 2>/dev/null | tr -d '\r')
4201        return
4202    fi
4203
4204    reglist=$(ls "/proc/registry${1}/${2}")
4205}
4206
4207# List values from the 32-bit side of the Registry
4208reg_list_values_32()
4209{
4210    reg_list_values "32" "$1"
4211}
4212
4213# List values from the 64-bit side of the Registry
4214reg_list_values_64()
4215{
4216    reg_list_values "64" "$1"
4217}
4218
4219case "$host_os" in
4220cygwin*|wsl*)
4221    COM=MSC
4222    OS=WNT
4223    RTL_OS=Windows
4224    if test "$GNUMAKE_WIN_NATIVE" = "TRUE" -o -n "$WSL_ONLY_AS_HELPER" ; then
4225        P_SEP=";"
4226    else
4227        P_SEP=:
4228    fi
4229    case "$host_cpu" in
4230    x86_64)
4231        CPUNAME=X86_64
4232        RTL_ARCH=X86_64
4233        PLATFORMID=windows_x86_64
4234        WINDOWS_X64=1
4235        SCPDEFS="$SCPDEFS -DWINDOWS_X64"
4236        WIN_HOST_ARCH="x64"
4237        WIN_MULTI_ARCH="x86"
4238        WIN_HOST_BITS=64
4239        WIN_CLANG_TARGET="x86_64-pc-windows-msvc"
4240        ;;
4241    i*86)
4242        CPUNAME=INTEL
4243        RTL_ARCH=x86
4244        PLATFORMID=windows_x86
4245        WIN_HOST_ARCH="x86"
4246        WIN_HOST_BITS=32
4247        WIN_OTHER_ARCH="x64"
4248        WIN_CLANG_TARGET="i686-pc-windows-msvc"
4249        ;;
4250    aarch64)
4251        CPUNAME=AARCH64
4252        RTL_ARCH=AARCH64
4253        PLATFORMID=windows_aarch64
4254        WINDOWS_X64=1
4255        SCPDEFS="$SCPDEFS -DWINDOWS_AARCH64"
4256        WIN_HOST_ARCH="arm64"
4257        WIN_HOST_BITS=64
4258        WIN_CLANG_TARGET="arm64-pc-windows-msvc"
4259        ;;
4260    *)
4261        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4262        ;;
4263    esac
4264
4265    case "$build_cpu" in
4266    x86_64) WIN_BUILD_ARCH="x64" ;;
4267    i*86) WIN_BUILD_ARCH="x86" ;;
4268    aarch64) WIN_BUILD_ARCH="arm64" ;;
4269    *)
4270        AC_MSG_ERROR([Unsupported build_cpu $build_cpu for host_os $host_os])
4271        ;;
4272    esac
4273
4274    SCPDEFS="$SCPDEFS -D_MSC_VER"
4275    ;;
4276esac
4277
4278# multi-arch is an arch, which can execute on the host (x86 on x64), while
4279# other-arch won't, but wouldn't break the build (x64 on x86).
4280if test -n "$WIN_MULTI_ARCH" -a -n "$WIN_OTHER_ARCH"; then
4281    AC_MSG_ERROR([Broken configure.ac file: can't have set \$WIN_MULTI_ARCH and $WIN_OTHER_ARCH])
4282fi
4283
4284
4285if test "$build_cpu" != "$host_cpu" -o "$DISABLE_DYNLOADING" = TRUE; then
4286    # To allow building Windows multi-arch releases without cross-tooling
4287    if test "$DISABLE_DYNLOADING" = TRUE -o \( -z "$WIN_MULTI_ARCH" -a -z "$WIN_OTHER_ARCH" \); then
4288        cross_compiling="yes"
4289    fi
4290fi
4291
4292if test "$cross_compiling" = "yes"; then
4293    export CROSS_COMPILING=TRUE
4294    if test "$enable_dynamic_loading" != yes -a "$enable_wasm_strip" = yes; then
4295        ENABLE_WASM_STRIP=TRUE
4296    fi
4297    if test "$_os" = "Emscripten"; then
4298        ENABLE_WASM_STRIP_ACCESSIBILITY=TRUE
4299        ENABLE_WASM_STRIP_BASIC_DRAW_MATH_IMPRESS=TRUE
4300        ENABLE_WASM_STRIP_CALC=TRUE
4301        ENABLE_WASM_STRIP_WRITER=TRUE
4302        for i in $with_wasm_module; do
4303            case "$i" in
4304            calc)
4305                ENABLE_WASM_STRIP_ACCESSIBILITY=
4306                ENABLE_WASM_STRIP_CALC=
4307                ;;
4308            writer)
4309                ENABLE_WASM_STRIP_WRITER=
4310                ;;
4311            impress)
4312                ENABLE_WASM_STRIP_ACCESSIBILITY=
4313                ENABLE_WASM_STRIP_BASIC_DRAW_MATH_IMPRESS=
4314                ;;
4315            *)
4316                AC_MSG_ERROR([Unknown --with-wasm-module "$i"])
4317            esac
4318        done
4319        if test "$ENABLE_WASM_STRIP_BASIC_DRAW_MATH_IMPRESS" = TRUE; then
4320            test_libcdr=no
4321            test_libetonyek=no
4322            test_libfreehand=no
4323            test_libmspub=no
4324            test_libpagemaker=no
4325            test_libqxp=no
4326            test_libvisio=no
4327            test_libzmf=no
4328        fi
4329    fi
4330else
4331    CROSS_COMPILING=
4332    BUILD_TYPE="$BUILD_TYPE NATIVE"
4333fi
4334AC_SUBST(CROSS_COMPILING)
4335AC_SUBST(ENABLE_WASM_STRIP)
4336AC_SUBST(ENABLE_WASM_STRIP_WRITER)
4337AC_SUBST(ENABLE_WASM_STRIP_BASIC_DRAW_MATH_IMPRESS)
4338AC_SUBST(ENABLE_WASM_STRIP_CALC)
4339AC_SUBST(ENABLE_WASM_STRIP_ACCESSIBILITY)
4340
4341if test "$enable_emscripten_jspi" = yes; then
4342    ENABLE_EMSCRIPTEN_JSPI=TRUE
4343    AC_DEFINE(HAVE_EMSCRIPTEN_JSPI)
4344else
4345    ENABLE_EMSCRIPTEN_JSPI=
4346fi
4347AC_SUBST(ENABLE_EMSCRIPTEN_JSPI)
4348
4349if test "$enable_emscripten_proxy_to_pthread" = yes; then
4350    ENABLE_EMSCRIPTEN_PROXY_TO_PTHREAD=TRUE
4351    AC_DEFINE(HAVE_EMSCRIPTEN_PROXY_TO_PTHREAD)
4352else
4353    ENABLE_EMSCRIPTEN_PROXY_TO_PTHREAD=
4354fi
4355AC_SUBST(ENABLE_EMSCRIPTEN_PROXY_TO_PTHREAD)
4356
4357if test "$enable_emscripten_proxy_posix_sockets" = yes; then
4358    ENABLE_EMSCRIPTEN_PROXY_POSIX_SOCKETS=TRUE
4359    AC_DEFINE(HAVE_EMSCRIPTEN_PROXY_POSIX_SOCKETS)
4360else
4361    ENABLE_EMSCRIPTEN_PROXY_POSIX_SOCKETS=
4362fi
4363AC_SUBST(ENABLE_EMSCRIPTEN_PROXY_POSIX_SOCKETS)
4364
4365# Use -isystem (gcc) if possible, to avoid warnings in 3rd party headers.
4366# NOTE: must _not_ be used for bundled external libraries!
4367ISYSTEM=
4368if test "$GCC" = "yes"; then
4369    AC_MSG_CHECKING( for -isystem )
4370    save_CFLAGS=$CFLAGS
4371    CFLAGS="$CFLAGS -isystem /usr/include -Werror"
4372    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ ISYSTEM="-isystem " ],[])
4373    CFLAGS=$save_CFLAGS
4374    if test -n "$ISYSTEM"; then
4375        AC_MSG_RESULT(yes)
4376    else
4377        AC_MSG_RESULT(no)
4378    fi
4379fi
4380if test -z "$ISYSTEM"; then
4381    # fall back to using -I
4382    ISYSTEM=-I
4383fi
4384AC_SUBST(ISYSTEM)
4385
4386dnl ===================================================================
4387dnl  Check which Visual Studio compiler is used
4388dnl ===================================================================
4389
4390map_vs_year_to_version()
4391{
4392    # Return value: $vsversion
4393
4394    unset vsversion
4395
4396    case $1 in
4397    2019)
4398        vsversion=16;;
4399    2022)
4400        vsversion=17;;
4401    2022preview)
4402        vsversion=17.14;;
4403    *)
4404        AC_MSG_ERROR([Assertion failure - invalid argument "$1" to map_vs_year_to_version()]);;
4405    esac
4406}
4407
4408vs_versions_to_check()
4409{
4410    # Args: $1 (optional) : versions to check, in the order of preference
4411    # Return value: $vsversions
4412
4413    unset vsversions
4414
4415    if test -n "$1"; then
4416        map_vs_year_to_version "$1"
4417        vsversions=$vsversion
4418    else
4419        # Default version is 2019
4420        vsversions="16"
4421    fi
4422}
4423
4424win_get_env_from_vsdevcmdbat()
4425{
4426    local WRAPPERBATCHFILEPATH="`mktemp -t wrpXXXXXX.bat`"
4427    printf '@set VSCMD_SKIP_SENDTELEMETRY=1\r\n' > $WRAPPERBATCHFILEPATH
4428    PathFormat "$VC_PRODUCT_DIR"
4429    printf '@call "%s/../Common7/Tools/VsDevCmd.bat" /no_logo\r\n' "$formatted_path" >> $WRAPPERBATCHFILEPATH
4430    # use 'echo.%ENV%' syntax (instead of 'echo %ENV%') to avoid outputting "ECHO is off." in case when ENV is empty or a space
4431    printf '@setlocal\r\n@echo.%%%s%%\r\n@endlocal\r\n' "$1" >> $WRAPPERBATCHFILEPATH
4432    local result
4433    if test "$build_os" = "wsl" -o -n "$WSL_ONLY_AS_HELPER"; then
4434        result=$(cd /mnt/c && cmd.exe /c $(wslpath -w $WRAPPERBATCHFILEPATH) | tr -d '\r')
4435    else
4436        chmod +x $WRAPPERBATCHFILEPATH
4437        result=$("$WRAPPERBATCHFILEPATH" | tr -d '\r')
4438    fi
4439    rm -f $WRAPPERBATCHFILEPATH
4440    printf '%s' "$result"
4441}
4442
4443find_ucrt()
4444{
4445    reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v10.0" "InstallationFolder"
4446    if test -n "$regvalue"; then
4447        PathFormat "$regvalue"
4448        UCRTSDKDIR=$formatted_path_unix
4449        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v10.0" "ProductVersion"
4450        if test -n "$regvalue"; then
4451            UCRTVERSION="$regvalue".0
4452        fi
4453
4454        # Rest if not exist
4455        if ! test -d "${UCRTSDKDIR}Include/$UCRTVERSION/ucrt"; then
4456          UCRTSDKDIR=
4457        fi
4458    fi
4459    if test -z "$UCRTSDKDIR"; then
4460        ide_env_dir="$VC_PRODUCT_DIR/../Common7/Tools/"
4461        ide_env_file="${ide_env_dir}VsDevCmd.bat"
4462        if test -f "$ide_env_file"; then
4463            PathFormat "$(win_get_env_from_vsdevcmdbat UniversalCRTSdkDir)"
4464            UCRTSDKDIR=$formatted_path_unix
4465            UCRTVERSION=$(win_get_env_from_vsdevcmdbat UCRTVersion)
4466            dnl Hack needed at least by tml:
4467            if test "$UCRTVERSION" = 10.0.15063.0 \
4468                -a ! -f "${UCRTSDKDIR}Include/10.0.15063.0/um/sqlext.h" \
4469                -a -f "${UCRTSDKDIR}Include/10.0.14393.0/um/sqlext.h"
4470            then
4471                UCRTVERSION=10.0.14393.0
4472            fi
4473        else
4474          AC_MSG_ERROR([No UCRT found])
4475        fi
4476    fi
4477}
4478
4479find_msvc()
4480{
4481    # Find Visual C++
4482    # Args: $1 (optional) : The VS version year
4483    # Return values: $vctest, $vcyear, $vctoolset, $vcnumwithdot, $vcbuildnumber
4484
4485    unset vctest vctoolset vcnumwithdot vcbuildnumber
4486
4487    vs_versions_to_check "$1"
4488    if test "$build_os" = wsl; then
4489        vswhere="$PROGRAMFILESX86"
4490        if test -z "$vswhere"; then
4491            vswhere="c:\\Program Files (x86)"
4492        fi
4493    elif test -n "$WSL_ONLY_AS_HELPER"; then
4494        vswhere="$(perl.exe -e 'print $ENV{"ProgramFiles(x86)"}')"
4495    else
4496        vswhere="$(perl -e 'print $ENV{"ProgramFiles(x86)"}')"
4497    fi
4498    vswhere+="\\Microsoft Visual Studio\\Installer\\vswhere.exe"
4499    PathFormat "$vswhere"
4500    vswhere=$formatted_path_unix
4501    for ver in $vsversions; do
4502        vswhereoutput=`$vswhere -version "@<:@ $ver , $(expr ${ver%%.*} + 1) @:}@" -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | head -1`
4503        if test -z "$vswhereoutput"; then
4504            vswhereoutput=`$vswhere -prerelease -version "@<:@ $ver , $(expr ${ver%%.*} + 1) @:}@" -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | head -1`
4505        fi
4506        # Fall back to all MS products (this includes VC++ Build Tools)
4507        if ! test -n "$vswhereoutput"; then
4508            AC_MSG_CHECKING([VC++ Build Tools and similar])
4509            vswhereoutput=`$vswhere -products \* -version "@<:@ $ver , $(expr ${ver%%.*} + 1) @:}@" -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | head -1`
4510        fi
4511        if test -n "$vswhereoutput"; then
4512            PathFormat "$vswhereoutput"
4513            vctest=$formatted_path_unix
4514            break
4515        fi
4516    done
4517
4518    if test -n "$vctest"; then
4519        vcnumwithdot="$ver"
4520        if test "${vcnumwithdot%%.*}" = "$vcnumwithdot"; then
4521            vcnumwithdot=$vcnumwithdot.0
4522        fi
4523        case "$vcnumwithdot" in
4524        16.0)
4525            vcyear=2019
4526            vctoolset=v142
4527            ;;
4528        17.0 | 17.14)
4529            vcyear=2022
4530            vctoolset=v143
4531            ;;
4532        esac
4533        vcbuildnumber=`ls $vctest/VC/Tools/MSVC -A1r | head -1`
4534
4535    fi
4536}
4537
4538test_cl_exe()
4539{
4540    AC_MSG_CHECKING([$1 compiler])
4541
4542    CL_EXE_PATH="$2/cl.exe"
4543
4544    if test ! -f "$CL_EXE_PATH"; then
4545        if test "$1" = "multi-arch"; then
4546            AC_MSG_WARN([no compiler (cl.exe) in $2])
4547            return 1
4548        else
4549            AC_MSG_ERROR([no compiler (cl.exe) in $2])
4550        fi
4551    fi
4552
4553    dnl ===========================================================
4554    dnl  Check for the corresponding mspdb*.dll
4555    dnl ===========================================================
4556
4557    # MSVC 15.0 has libraries from 14.0?
4558    mspdbnum="140"
4559
4560    if test ! -e "$2/mspdb${mspdbnum}.dll"; then
4561        AC_MSG_ERROR([No mspdb${mspdbnum}.dll in $2, Visual Studio installation broken?])
4562    fi
4563
4564    # The compiler has to find its shared libraries
4565    OLD_PATH="$PATH"
4566    PathFormat "$2"
4567    PATH="$formatted_path_unix:$PATH"
4568
4569    if ! "$CL_EXE_PATH" -? </dev/null >/dev/null 2>&1; then
4570        AC_MSG_ERROR([no compiler (cl.exe) in $2])
4571    fi
4572
4573    PATH="$OLD_PATH"
4574
4575    AC_MSG_RESULT([$CL_EXE_PATH])
4576}
4577
4578SOLARINC=
4579MSBUILD_PATH=
4580DEVENV=
4581if test "$_os" = "WINNT"; then
4582    AC_MSG_CHECKING([Visual C++])
4583    find_msvc "$with_visual_studio"
4584    if test -z "$vctest"; then
4585        if test -n "$with_visual_studio"; then
4586            AC_MSG_ERROR([no Visual Studio $with_visual_studio installation found])
4587        else
4588            AC_MSG_ERROR([no Visual Studio installation found])
4589        fi
4590    fi
4591    AC_MSG_RESULT([])
4592
4593    VC_PRODUCT_DIR="$vctest/VC"
4594    COMPATH="$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber"
4595
4596    # $WIN_OTHER_ARCH is a hack to test the x64 compiler on x86, even if it's not multi-arch
4597    if test -n "$WIN_MULTI_ARCH" -o -n "$WIN_OTHER_ARCH"; then
4598        MSVC_MULTI_PATH="$COMPATH/bin/Host$WIN_BUILD_ARCH/${WIN_MULTI_ARCH}${WIN_OTHER_ARCH}"
4599        test_cl_exe "multi-arch" "$MSVC_MULTI_PATH"
4600        if test $? -ne 0; then
4601            WIN_MULTI_ARCH=""
4602            WIN_OTHER_ARCH=""
4603        fi
4604    fi
4605
4606    if test "$WIN_BUILD_ARCH" = "$WIN_HOST_ARCH"; then
4607        MSVC_BUILD_PATH="$COMPATH/bin/Host$WIN_BUILD_ARCH/$WIN_BUILD_ARCH"
4608        test_cl_exe "build" "$MSVC_BUILD_PATH"
4609    fi
4610
4611    if test "$WIN_BUILD_ARCH" != "$WIN_HOST_ARCH"; then
4612        MSVC_HOST_PATH="$COMPATH/bin/Host$WIN_BUILD_ARCH/$WIN_HOST_ARCH"
4613        test_cl_exe "host" "$MSVC_HOST_PATH"
4614    else
4615        MSVC_HOST_PATH="$MSVC_BUILD_PATH"
4616    fi
4617
4618    AC_MSG_CHECKING([for short pathname of VC product directory])
4619    VC_PRODUCT_DIR=`win_short_path_for_make "$VC_PRODUCT_DIR"`
4620    AC_MSG_RESULT([$VC_PRODUCT_DIR])
4621
4622    UCRTSDKDIR=
4623    UCRTVERSION=
4624
4625    AC_MSG_CHECKING([for UCRT location])
4626    find_ucrt
4627    # find_ucrt errors out if it doesn't find it
4628    AC_MSG_RESULT([$UCRTSDKDIR ($UCRTVERSION)])
4629    PathFormat "${UCRTSDKDIR}Include/$UCRTVERSION/ucrt"
4630    ucrtincpath_formatted=$formatted_path
4631    # SOLARINC is used for external modules and must be set too.
4632    # And no, it's not sufficient to set SOLARINC only, as configure
4633    # itself doesn't honour it.
4634    SOLARINC="$SOLARINC -I$ucrtincpath_formatted"
4635    CFLAGS="$CFLAGS -I$ucrtincpath_formatted"
4636    CXXFLAGS="$CXXFLAGS -I$ucrtincpath_formatted"
4637    CPPFLAGS="$CPPFLAGS -I$ucrtincpath_formatted"
4638
4639    AC_SUBST(UCRTSDKDIR)
4640    AC_SUBST(UCRTVERSION)
4641
4642    AC_MSG_CHECKING([for MSBuild.exe location for: $vcnumwithdot])
4643    # Find the proper version of MSBuild.exe to use based on the VS version
4644    reg_get_value_32 HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MSBuild/$vcnumwithdot MSBuildOverrideTasksPath
4645    if test -z "$regvalue" ; then
4646        if test "$WIN_BUILD_ARCH" != "x64"; then
4647            regvalue="$VC_PRODUCT_DIR/../MSBuild/Current/Bin"
4648        else
4649            regvalue="$VC_PRODUCT_DIR/../MSBuild/Current/Bin/amd64"
4650        fi
4651    fi
4652    if test -d "$regvalue" ; then
4653        MSBUILD_PATH=`win_short_path_for_make "$regvalue"`
4654        AC_MSG_RESULT([$regvalue])
4655    else
4656        AC_MSG_ERROR([MSBuild.exe location not found])
4657    fi
4658
4659    # Find the version of devenv.exe
4660    PathFormat "$VC_PRODUCT_DIR/../Common7/IDE/devenv.exe"
4661    DEVENV="$formatted_path"
4662    DEVENV_unix="$formatted_path_unix"
4663    if test ! -e "$DEVENV_unix"; then
4664        AC_MSG_WARN([No devenv.exe found - this is expected for VC++ Build Tools])
4665    fi
4666
4667    dnl Save the true MSVC cl.exe for use when CC/CXX is actually clang-cl,
4668    dnl needed when building CLR code:
4669    if test -z "$MSVC_CXX"; then
4670        # This gives us a posix path with 8.3 filename restrictions
4671        MSVC_CXX=`win_short_path_for_make "$MSVC_HOST_PATH/cl.exe"`
4672    fi
4673
4674    if test -z "$CC"; then
4675        CC=$MSVC_CXX
4676        CC_BASE=`first_arg_basename "$CC"`
4677    fi
4678    if test -z "$CXX"; then
4679        CXX=$MSVC_CXX
4680        CXX_BASE=`first_arg_basename "$CXX"`
4681    fi
4682
4683    if test -n "$CC"; then
4684        # Remove /cl.exe from CC case insensitive
4685        AC_MSG_NOTICE([found Visual C++ $vcyear])
4686
4687        PathFormat "$COMPATH"
4688        COMPATH="$formatted_path"
4689        COMPATH_unix="$formatted_path_unix"
4690        CPPFLAGS="$CPPFLAGS -I$COMPATH/Include"
4691
4692        VCVER=$vcnumwithdot
4693        VCTOOLSET=$vctoolset
4694
4695        # The WINDOWS_SDK_ACCEPTABLE_VERSIONS is mostly an educated guess...  Assuming newer ones
4696        # are always "better", we list them in reverse chronological order.
4697
4698        case "$vcnumwithdot" in
4699        16.0 | 17.0 | 17.14)
4700            WINDOWS_SDK_ACCEPTABLE_VERSIONS="10.0 8.1A 8.1 8.0"
4701            ;;
4702        esac
4703
4704        # The expectation is that --with-windows-sdk should not need to be used
4705        if test -n "$with_windows_sdk"; then
4706            case " $WINDOWS_SDK_ACCEPTABLE_VERSIONS " in
4707            *" "$with_windows_sdk" "*)
4708                WINDOWS_SDK_ACCEPTABLE_VERSIONS=$with_windows_sdk
4709                ;;
4710            *)
4711                AC_MSG_ERROR([Windows SDK $with_windows_sdk is not known to work with VS $vcyear])
4712                ;;
4713            esac
4714        fi
4715
4716        # Make AC_COMPILE_IFELSE etc. work (set by AC_PROG_C, which we don't use for MSVC)
4717        ac_objext=obj
4718        ac_exeext=exe
4719
4720    else
4721        AC_MSG_ERROR([Visual C++ not found after all, huh])
4722    fi
4723
4724    # ERROR if VS version < 16.5
4725    AC_MSG_CHECKING([$CC_BASE is at least Visual Studio 2019 version 16.5])
4726    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
4727        // See <https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros> for mapping
4728        // between Visual Studio versions and _MSC_VER:
4729        #if _MSC_VER < 1925
4730        #error
4731        #endif
4732    ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no])])
4733
4734    # WARN if VS version < 16.10
4735    AC_MSG_CHECKING([$CC_BASE is at least Visual Studio 2019 version 16.10])
4736    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
4737        #if _MSC_VER < 1929
4738        #error
4739        #endif
4740    ]])],[vs2019_recommended_version=yes],[vs2019_recommended_version=no])
4741
4742    if test $vs2019_recommended_version = yes; then
4743        AC_MSG_RESULT([yes])
4744    else
4745        AC_MSG_WARN([no])
4746        add_warning "You should have at least Visual Studio 2019 version 16.10 to avoid build problems. Otherwise, you may face problems with the build of some modules including dragonbox."
4747    fi
4748
4749    # we used to build 64bit bits for 32bit windows (explorer shell extension, activex, similar)
4750    # dating back when there was no 64bit version of LibreOffice yet (pre 5.0)
4751    # now (since 25.8) we only care about the inverse, building the 32bit twain and activex spsupp
4752    # lib when targeting/building the 64bit version for Windows
4753
4754    # Check for 32-bit compiler to use to build the 32-bit TWAIN shim
4755    # needed to support TWAIN scan on both 32- and 64-bit systems
4756
4757    case "$WIN_HOST_ARCH" in
4758    x64)
4759        CXX_X64_BINARY=$CXX
4760        AC_MSG_CHECKING([for a x86 compiler and libraries for 32-bit binaries required for TWAIN support])
4761        if test -n "$CXX_X86_BINARY"; then
4762            AC_MSG_RESULT([provided via environment variable])
4763        elif test -n "$WIN_MULTI_ARCH"; then
4764            CXX_X86_BINARY=`win_short_path_for_make "$MSVC_MULTI_PATH/cl.exe"`
4765            AC_MSG_RESULT([found])
4766        else
4767            AC_MSG_RESULT([not found])
4768            AC_MSG_WARN([Installation set will not contain 32-bit binaries required for TWAIN support])
4769        fi
4770        ;;
4771    x86)
4772        CXX_X86_BINARY=$MSVC_CXX
4773        ;;
4774    esac
4775    # These are passed to the environment and then used in gbuild/platform/com_MSC_class.mk
4776    AC_SUBST(CXX_X64_BINARY)
4777    AC_SUBST(CXX_X86_BINARY)
4778fi
4779AC_SUBST(VCVER)
4780AC_SUBST(VCTOOLSET)
4781AC_SUBST(DEVENV)
4782AC_SUBST(MSVC_CXX)
4783
4784COM_IS_CLANG=
4785AC_MSG_CHECKING([whether the compiler is actually Clang])
4786AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
4787    #ifndef __clang__
4788    you lose
4789    #endif
4790    int foo=42;
4791    ]])],
4792    [AC_MSG_RESULT([yes])
4793     COM_IS_CLANG=TRUE],
4794    [AC_MSG_RESULT([no])])
4795AC_SUBST(COM_IS_CLANG)
4796
4797CLANGVER=
4798CLANG_16=
4799if test "$COM_IS_CLANG" = TRUE; then
4800    AC_MSG_CHECKING([whether Clang is new enough])
4801    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
4802        #if !defined __apple_build_version__
4803        #error
4804        #endif
4805        ]])],
4806        [my_apple_clang=yes],[my_apple_clang=])
4807    if test "$my_apple_clang" = yes; then
4808        AC_MSG_RESULT([assumed yes (Apple Clang)])
4809    elif test "$_os" = Emscripten; then
4810        AC_MSG_RESULT([assumed yes (Emscripten Clang)])
4811    else
4812        if test "$_os" = WINNT; then
4813            dnl In which case, assume clang-cl:
4814            my_args="/EP /TC"
4815        else
4816            my_args="-E -P"
4817        fi
4818        clang_version=`echo __clang_major__.__clang_minor__.__clang_patchlevel__ | $CC $my_args - | sed 's/ //g'`
4819        CLANG_FULL_VERSION=`echo __clang_version__ | $CC $my_args -`
4820        CLANGVER=`echo $clang_version \
4821            | $AWK -F. '{ print \$1*10000+(\$2<100?\$2:99)*100+(\$3<100?\$3:99) }'`
4822        if test "$CLANGVER" -ge 120000; then
4823            AC_MSG_RESULT([yes ($clang_version)])
4824        else
4825            AC_MSG_ERROR(["$CLANG_FULL_VERSION" is too old or unrecognized, must be at least Clang 12])
4826        fi
4827        if test "$CLANGVER" -ge 160000; then
4828            CLANG_16=TRUE
4829        fi
4830        AC_DEFINE_UNQUOTED(CLANG_VERSION,$CLANGVER)
4831        AC_DEFINE_UNQUOTED(CLANG_FULL_VERSION,$CLANG_FULL_VERSION)
4832    fi
4833fi
4834AC_SUBST(CLANG_16)
4835
4836SHOWINCLUDES_PREFIX=
4837if test "$_os" = WINNT; then
4838    dnl We need to guess the prefix of the -showIncludes output, it can be
4839    dnl localized
4840    AC_MSG_CHECKING([the dependency generation prefix (cl.exe -showIncludes)])
4841    echo "#include <stdlib.h>" > conftest.c
4842    SHOWINCLUDES_PREFIX=`VSLANG=1033 $CC $CFLAGS -c -showIncludes conftest.c 2>/dev/null | \
4843        grep 'stdlib\.h' | head -n1 | sed 's/ [[[:alpha:]]]:.*//'`
4844    rm -f conftest.c conftest.obj
4845    if test -z "$SHOWINCLUDES_PREFIX"; then
4846        AC_MSG_ERROR([cannot determine the -showIncludes prefix])
4847    else
4848        AC_MSG_RESULT(["$SHOWINCLUDES_PREFIX"])
4849    fi
4850fi
4851AC_SUBST(SHOWINCLUDES_PREFIX)
4852
4853#
4854# prefix C with ccache if needed
4855#
4856if test "$CCACHE" != ""; then
4857    AC_MSG_CHECKING([whether $CC_BASE is already ccached])
4858
4859    AC_LANG_PUSH([C])
4860    save_CFLAGS=$CFLAGS
4861    CFLAGS="$CFLAGS --ccache-skip -O2"
4862    # msvc does not fail on unknown options, check stdout
4863    if test "$COM" = MSC; then
4864        CFLAGS="$CFLAGS -nologo"
4865    fi
4866    save_ac_c_werror_flag=$ac_c_werror_flag
4867    ac_c_werror_flag=yes
4868    dnl an empty program will do, we're checking the compiler flags
4869    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
4870                      [use_ccache=yes], [use_ccache=no])
4871    CFLAGS=$save_CFLAGS
4872    ac_c_werror_flag=$save_ac_c_werror_flag
4873    if test $use_ccache = yes -a "${CCACHE##*sccache*}" != ""; then
4874        AC_MSG_RESULT([yes])
4875    else
4876        CC="$CCACHE $CC"
4877        CC_BASE="ccache $CC_BASE"
4878        AC_MSG_RESULT([no])
4879    fi
4880    AC_LANG_POP([C])
4881fi
4882
4883# ===================================================================
4884# check various GCC options that Clang does not support now but maybe
4885# will somewhen in the future, check them even for GCC, so that the
4886# flags are set
4887# ===================================================================
4888
4889HAVE_GCC_GGDB2=
4890if test "$GCC" = "yes" -a "$_os" != "Emscripten"; then
4891    AC_MSG_CHECKING([whether $CC_BASE supports -ggdb2])
4892    save_CFLAGS=$CFLAGS
4893    CFLAGS="$CFLAGS -Werror -ggdb2"
4894    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_GGDB2=TRUE ],[])
4895    CFLAGS=$save_CFLAGS
4896    if test "$HAVE_GCC_GGDB2" = "TRUE"; then
4897        AC_MSG_RESULT([yes])
4898    else
4899        AC_MSG_RESULT([no])
4900    fi
4901
4902    if test "$host_cpu" = "m68k"; then
4903        AC_MSG_CHECKING([whether $CC_BASE supports -mlong-jump-table-offsets])
4904        save_CFLAGS=$CFLAGS
4905        CFLAGS="$CFLAGS -Werror -mlong-jump-table-offsets"
4906        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_LONG_JUMP_TABLE_OFFSETS=TRUE ],[])
4907        CFLAGS=$save_CFLAGS
4908        if test "$HAVE_GCC_LONG_JUMP_TABLE_OFFSETS" = "TRUE"; then
4909            AC_MSG_RESULT([yes])
4910        else
4911            AC_MSG_ERROR([no])
4912        fi
4913    fi
4914fi
4915AC_SUBST(HAVE_GCC_GGDB2)
4916
4917dnl ===================================================================
4918dnl  Test the gcc version
4919dnl ===================================================================
4920if test "$GCC" = "yes" -a -z "$COM_IS_CLANG"; then
4921    AC_MSG_CHECKING([the GCC version])
4922    _gcc_version=`$CC -dumpfullversion`
4923    gcc_full_version=$(printf '%s' "$_gcc_version" | \
4924        $AWK -F. '{ print $1*10000+$2*100+(NF<3?1:$3) }')
4925    GCC_VERSION=`echo $_gcc_version | $AWK -F. '{ print \$1*100+\$2 }'`
4926
4927    AC_MSG_RESULT([gcc $_gcc_version ($gcc_full_version)])
4928
4929    if test "$gcc_full_version" -lt 120000; then
4930        AC_MSG_ERROR([GCC $_gcc_version is too old, must be at least GCC 12])
4931    fi
4932else
4933    # Explicitly force GCC_VERSION to be empty, even for Clang, to check incorrect uses.
4934    # GCC version should generally be checked only when handling GCC-specific bugs, for testing
4935    # things like features configure checks should be used, otherwise they may e.g. fail with Clang
4936    # (which reports itself as GCC 4.2.1).
4937    GCC_VERSION=
4938fi
4939AC_SUBST(GCC_VERSION)
4940
4941dnl Set the ENABLE_DBGUTIL variable
4942dnl ===================================================================
4943AC_MSG_CHECKING([whether to build with additional debug utilities])
4944if test -n "$enable_dbgutil" -a "$enable_dbgutil" != "no"; then
4945    ENABLE_DBGUTIL="TRUE"
4946    # this is an extra var so it can have different default on different MSVC
4947    # versions (in case there are version specific problems with it)
4948    MSVC_USE_DEBUG_RUNTIME="TRUE"
4949
4950    AC_MSG_RESULT([yes])
4951    # cppunit and graphite expose STL in public headers
4952    if test "$with_system_cppunit" = "yes"; then
4953        AC_MSG_ERROR([--with-system-cppunit conflicts with --enable-dbgutil])
4954    else
4955        with_system_cppunit=no
4956    fi
4957    if test "$with_system_graphite" = "yes"; then
4958        AC_MSG_ERROR([--with-system-graphite conflicts with --enable-dbgutil])
4959    else
4960        with_system_graphite=no
4961    fi
4962    if test "$with_system_orcus" = "yes"; then
4963        AC_MSG_ERROR([--with-system-orcus conflicts with --enable-dbgutil])
4964    else
4965        with_system_orcus=no
4966    fi
4967    if test "$with_system_libcmis" = "yes"; then
4968        AC_MSG_ERROR([--with-system-libcmis conflicts with --enable-dbgutil])
4969    else
4970        with_system_libcmis=no
4971    fi
4972    if test "$with_system_hunspell" = "yes"; then
4973        AC_MSG_ERROR([--with-system-hunspell conflicts with --enable-dbgutil])
4974    else
4975        with_system_hunspell=no
4976    fi
4977    if test "$with_system_gpgmepp" = "yes"; then
4978        AC_MSG_ERROR([--with-system-gpgmepp conflicts with --enable-dbgutil])
4979    else
4980        with_system_gpgmepp=no
4981    fi
4982    if test "$with_system_zxing" = "yes"; then
4983        AC_MSG_ERROR([--with-system-zxing conflicts with --enable-dbgutil])
4984    else
4985        with_system_zxing=no
4986    fi
4987    if test "$with_system_poppler" = "yes"; then
4988        AC_MSG_ERROR([--with-system-poppler conflicts with --enable-dbgutil])
4989    else
4990        with_system_poppler=no
4991    fi
4992    # As mixing system libwps and non-system libnumbertext or vice versa likely causes trouble (see
4993    # 603074c5f2b84de8a24593faf807da784b040625 "Pass _GLIBCXX_DEBUG into external/libwps" and the
4994    # mail thread starting at <https://gcc.gnu.org/ml/gcc/2018-05/msg00057.html> "libstdc++: ODR
4995    # violation when using std::regex with and without -D_GLIBCXX_DEBUG"), simply make sure neither
4996    # of those two is using the system variant:
4997    if test "$with_system_libnumbertext" = "yes"; then
4998        AC_MSG_ERROR([--with-system-libnumbertext conflicts with --enable-dbgutil])
4999    else
5000        with_system_libnumbertext=no
5001    fi
5002    if test "$with_system_libwps" = "yes"; then
5003        AC_MSG_ERROR([--with-system-libwps conflicts with --enable-dbgutil])
5004    else
5005        with_system_libwps=no
5006    fi
5007else
5008    ENABLE_DBGUTIL=""
5009    MSVC_USE_DEBUG_RUNTIME=""
5010    AC_MSG_RESULT([no])
5011fi
5012AC_SUBST(ENABLE_DBGUTIL)
5013AC_SUBST(MSVC_USE_DEBUG_RUNTIME)
5014
5015dnl Set the ENABLE_DEBUG variable.
5016dnl ===================================================================
5017if test -n "$enable_debug" && test "$enable_debug" != "yes" && test "$enable_debug" != "no"; then
5018    AC_MSG_ERROR([--enable-debug now accepts only yes or no, use --enable-symbols])
5019fi
5020if test -n "$ENABLE_DBGUTIL" -a "$enable_debug" = "no"; then
5021    if test -z "$libo_fuzzed_enable_debug"; then
5022        AC_MSG_ERROR([--disable-debug cannot be used with --enable-dbgutil])
5023    else
5024        AC_MSG_NOTICE([Resetting --enable-debug=yes])
5025        enable_debug=yes
5026    fi
5027fi
5028
5029AC_MSG_CHECKING([whether to do a debug build])
5030if test -n "$ENABLE_DBGUTIL" -o \( -n "$enable_debug" -a "$enable_debug" != "no" \) ; then
5031    ENABLE_DEBUG="TRUE"
5032    if test -n "$ENABLE_DBGUTIL" ; then
5033        AC_MSG_RESULT([yes (dbgutil)])
5034    else
5035        AC_MSG_RESULT([yes])
5036    fi
5037else
5038    ENABLE_DEBUG=""
5039    AC_MSG_RESULT([no])
5040fi
5041AC_SUBST(ENABLE_DEBUG)
5042
5043AC_MSG_CHECKING([whether to enable (the UNO parts of) embindtest])
5044if test -z "$enable_embindtest_uno" && test "$_os" = Emscripten && test "$ENABLE_DBGUTIL" = TRUE
5045then
5046    enable_embindtest_uno=yes
5047fi
5048if test "$enable_embindtest_uno" = yes; then
5049    AC_MSG_RESULT([yes])
5050    ENABLE_EMBINDTEST_UNO=TRUE
5051else
5052    AC_MSG_RESULT([no])
5053    ENABLE_EMBINDTEST_UNO=
5054fi
5055AC_SUBST(ENABLE_EMBINDTEST_UNO)
5056
5057dnl ===================================================================
5058dnl Select the linker to use (gold/lld/ld.bfd/mold).
5059dnl This is done only after compiler checks (need to know if Clang is
5060dnl used, for different defaults) and after checking if a debug build
5061dnl is wanted (non-debug builds get the default linker if not explicitly
5062dnl specified otherwise).
5063dnl All checks for linker features/options should come after this.
5064dnl ===================================================================
5065check_use_ld()
5066{
5067    use_ld=-fuse-ld=${1%%:*}
5068    use_ld_path=${1#*:}
5069    if test "$use_ld_path" != "$1"; then
5070        if test "$COM_IS_CLANG" = TRUE; then
5071            if test "$CLANGVER" -ge 120000; then
5072                use_ld="${use_ld} --ld-path=${use_ld_path}"
5073            else
5074                use_ld="-fuse-ld=${use_ld_path}"
5075            fi
5076        else
5077            # I tried to use gcc's '-B<path>' and a directory + symlink setup in
5078            # $BUILDDIR, but libtool always filtered-out that option, so gcc wouldn't
5079            # pickup the alternative linker, when called by libtool for linking.
5080            # For mold, one can use LD_PRELOAD=/usr/lib/mold/mold-wrapper.so instead.
5081            AC_MSG_ERROR([A linker path is just supported with clang, because of libtool's -B filtering!])
5082        fi
5083    fi
5084    use_ld_fail_if_error=$2
5085    use_ld_ok=
5086    AC_MSG_CHECKING([for $use_ld linker support])
5087    use_ld_ldflags_save="$LDFLAGS"
5088    LDFLAGS="$LDFLAGS $use_ld"
5089    AC_LINK_IFELSE([AC_LANG_PROGRAM([
5090#include <stdio.h>
5091        ],[
5092printf ("hello world\n");
5093        ])], USE_LD=$use_ld, [])
5094    if test -n "$USE_LD"; then
5095        AC_MSG_RESULT( yes )
5096        use_ld_ok=yes
5097    else
5098        if test -n "$use_ld_fail_if_error"; then
5099            AC_MSG_ERROR( no )
5100        else
5101            AC_MSG_RESULT( no )
5102        fi
5103    fi
5104    if test -n "$use_ld_ok"; then
5105        dnl keep the value of LDFLAGS
5106        return 0
5107    fi
5108    LDFLAGS="$use_ld_ldflags_save"
5109    return 1
5110}
5111USE_LD=
5112if test "$enable_ld" != "no"; then
5113    if test "$GCC" = "yes" -a "$_os" != "Emscripten"; then
5114        if test -n "$enable_ld"; then
5115            check_use_ld "$enable_ld" fail_if_error
5116        elif test -z "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
5117            dnl non-debug builds default to the default linker
5118            true
5119        elif test -n "$COM_IS_CLANG"; then
5120            check_use_ld lld
5121            if test $? -ne 0; then
5122                check_use_ld gold
5123                if test $? -ne 0; then
5124                    check_use_ld mold
5125                fi
5126            fi
5127        else
5128            # For gcc first try gold, new versions also support lld/mold.
5129            check_use_ld gold
5130            if test $? -ne 0; then
5131                check_use_ld lld
5132                if test $? -ne 0; then
5133                    check_use_ld mold
5134                fi
5135            fi
5136        fi
5137        ld_output=$(echo 'int main() { return 0; }' | $CC -Wl,-v -x c -o conftest.out - $CFLAGS $LDFLAGS 2>/dev/null)
5138        rm conftest.out
5139        ld_used=$(echo "$ld_output" | grep -E '(^GNU gold|^GNU ld|^LLD|^mold)')
5140        if test -z "$ld_used"; then
5141            ld_used="unknown"
5142        fi
5143        AC_MSG_CHECKING([for linker that is used])
5144        AC_MSG_RESULT([$ld_used])
5145        if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
5146            if echo "$ld_used" | grep -q "^GNU ld"; then
5147                AC_MSG_WARN([The default GNU linker is slow, consider using LLD, mold or the GNU gold linker.])
5148                add_warning "The default GNU linker is slow, consider using LLD, mold or the GNU gold linker."
5149            fi
5150        fi
5151    else
5152        if test "$enable_ld" = "yes"; then
5153            AC_MSG_ERROR([--enable-ld not supported])
5154        fi
5155    fi
5156fi
5157AC_SUBST(USE_LD)
5158AC_SUBST(LD)
5159
5160HAVE_LD_BSYMBOLIC_FUNCTIONS=
5161if test "$GCC" = "yes" -a "$_os" != Emscripten ; then
5162    AC_MSG_CHECKING([for -Bsymbolic-functions linker support])
5163    bsymbolic_functions_ldflags_save=$LDFLAGS
5164    LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
5165    AC_LINK_IFELSE([AC_LANG_PROGRAM([
5166#include <stdio.h>
5167        ],[
5168printf ("hello world\n");
5169        ])], HAVE_LD_BSYMBOLIC_FUNCTIONS=TRUE, [])
5170    if test "$HAVE_LD_BSYMBOLIC_FUNCTIONS" = "TRUE"; then
5171        AC_MSG_RESULT( found )
5172    else
5173        AC_MSG_RESULT( not found )
5174    fi
5175    LDFLAGS=$bsymbolic_functions_ldflags_save
5176fi
5177AC_SUBST(HAVE_LD_BSYMBOLIC_FUNCTIONS)
5178
5179LD_GC_SECTIONS=
5180if test "$GCC" = "yes"; then
5181    for flag in "--gc-sections" "-dead_strip"; do
5182        AC_MSG_CHECKING([for $flag linker support])
5183        ldflags_save=$LDFLAGS
5184        LDFLAGS="$LDFLAGS -Wl,$flag"
5185        AC_LINK_IFELSE([AC_LANG_PROGRAM([
5186#include <stdio.h>
5187            ],[
5188printf ("hello world\n");
5189            ])],[
5190            LD_GC_SECTIONS="-Wl,$flag"
5191            AC_MSG_RESULT( found )
5192            ], [
5193            AC_MSG_RESULT( not found )
5194            ])
5195        LDFLAGS=$ldflags_save
5196        if test -n "$LD_GC_SECTIONS"; then
5197            break
5198        fi
5199    done
5200fi
5201AC_SUBST(LD_GC_SECTIONS)
5202
5203HAVE_EXTERNAL_DWARF=
5204if test "$enable_split_debug" != no; then
5205    use_split_debug=
5206    if test -n "$ENABLE_LTO"; then
5207        : # Inherently incompatible, since no debug info is created while compiling, GCC complains.
5208    elif test "$enable_split_debug" = yes; then
5209        use_split_debug=1
5210    dnl Currently by default enabled only on Linux, feel free to set test_split_debug above also for other platforms.
5211    elif test "$test_split_debug" = "yes" -a -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
5212        use_split_debug=1
5213    fi
5214    if test -n "$use_split_debug"; then
5215        if test "$_os" = "Emscripten"; then
5216            TEST_CC_FLAG='-gseparate-dwarf -gsplit-dwarf -gpubnames'
5217        else
5218            TEST_CC_FLAG=-gsplit-dwarf
5219        fi
5220        AC_MSG_CHECKING([whether $CC_BASE supports $TEST_CC_FLAG])
5221        save_CFLAGS=$CFLAGS
5222        CFLAGS="$CFLAGS -Werror $TEST_CC_FLAG"
5223        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_EXTERNAL_DWARF=TRUE ],[])
5224        CFLAGS=$save_CFLAGS
5225        if test "$HAVE_EXTERNAL_DWARF" = "TRUE"; then
5226            AC_MSG_RESULT([yes])
5227        else
5228            if test "$enable_split_debug" = yes; then
5229                AC_MSG_ERROR([no])
5230            else
5231                AC_MSG_RESULT([no])
5232            fi
5233        fi
5234    fi
5235    if test -z "$HAVE_EXTERNAL_DWARF" -a "$test_split_debug" = "yes" -a -n "$use_split_debug"; then
5236        AC_MSG_WARN([Compiler is not capable of creating split debug info, linking will require more time and disk space.])
5237        add_warning "Compiler is not capable of creating split debug info, linking will require more time and disk space."
5238    fi
5239fi
5240AC_SUBST(HAVE_EXTERNAL_DWARF)
5241
5242HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR=
5243AC_MSG_CHECKING([whether $CC_BASE supports -Xclang -debug-info-kind=constructor])
5244save_CFLAGS=$CFLAGS
5245CFLAGS="$CFLAGS -Werror -Xclang -debug-info-kind=constructor"
5246AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR=TRUE ],[])
5247CFLAGS=$save_CFLAGS
5248if test "$HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR" = "TRUE"; then
5249    AC_MSG_RESULT([yes])
5250else
5251    AC_MSG_RESULT([no])
5252fi
5253AC_SUBST(HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR)
5254
5255ENABLE_GDB_INDEX=
5256if test "$enable_gdb_index" != "no"; then
5257    dnl Currently by default enabled only on Linux, feel free to set test_gdb_index above also for other platforms.
5258    if test "$enable_gdb_index" = yes -o \( "$test_gdb_index" = "yes" -a -n "$ENABLE_DEBUG$ENABLE_DBGUTIL" \); then
5259        AC_MSG_CHECKING([whether $CC_BASE supports -ggnu-pubnames])
5260        save_CFLAGS=$CFLAGS
5261        CFLAGS="$CFLAGS -Werror -g -ggnu-pubnames"
5262        have_ggnu_pubnames=
5263        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[have_ggnu_pubnames=TRUE],[have_ggnu_pubnames=])
5264        if test "$have_ggnu_pubnames" != "TRUE"; then
5265            if test "$enable_gdb_index" = "yes"; then
5266                AC_MSG_ERROR([no, --enable-gdb-index not supported])
5267            else
5268                AC_MSG_RESULT( no )
5269            fi
5270        else
5271            AC_MSG_RESULT( yes )
5272            AC_MSG_CHECKING([whether $CC_BASE supports -Wl,--gdb-index])
5273            ldflags_save=$LDFLAGS
5274            LDFLAGS="$LDFLAGS -Wl,--gdb-index"
5275            AC_LINK_IFELSE([AC_LANG_PROGRAM([
5276#include <stdio.h>
5277                ],[
5278printf ("hello world\n");
5279                ])], ENABLE_GDB_INDEX=TRUE, [])
5280            if test "$ENABLE_GDB_INDEX" = "TRUE"; then
5281                AC_MSG_RESULT( yes )
5282            else
5283                if test "$enable_gdb_index" = "yes"; then
5284                    AC_MSG_ERROR( no )
5285                else
5286                    AC_MSG_RESULT( no )
5287                fi
5288            fi
5289            LDFLAGS=$ldflags_save
5290        fi
5291        CFLAGS=$save_CFLAGS
5292        fi
5293    if test -z "$ENABLE_GDB_INDEX" -a "$test_gdb_index" = "yes" -a -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
5294        AC_MSG_WARN([Linker is not capable of creating gdb index, debugger startup will be slow.])
5295        add_warning "Linker is not capable of creating gdb index, debugger startup will be slow."
5296    fi
5297fi
5298AC_SUBST(ENABLE_GDB_INDEX)
5299
5300if test -z "$enable_sal_log" && test "$ENABLE_DEBUG" = TRUE; then
5301    enable_sal_log=yes
5302fi
5303if test "$enable_sal_log" = yes; then
5304    ENABLE_SAL_LOG=TRUE
5305fi
5306AC_SUBST(ENABLE_SAL_LOG)
5307
5308dnl Check for enable symbols option
5309dnl ===================================================================
5310AC_MSG_CHECKING([whether to generate debug information])
5311if test -z "$enable_symbols"; then
5312    if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
5313        enable_symbols=yes
5314    else
5315        enable_symbols=no
5316    fi
5317fi
5318if test "$enable_symbols" = yes; then
5319    ENABLE_SYMBOLS_FOR=all
5320    AC_MSG_RESULT([yes])
5321elif test "$enable_symbols" = no; then
5322    ENABLE_SYMBOLS_FOR=
5323    AC_MSG_RESULT([no])
5324else
5325    # Selective debuginfo.
5326    ENABLE_SYMBOLS_FOR="$enable_symbols"
5327    AC_MSG_RESULT([for "$enable_symbols"])
5328fi
5329AC_SUBST(ENABLE_SYMBOLS_FOR)
5330
5331if test -n "$with_android_ndk" -a \( -n "$ENABLE_DEBUG" -o -n "$ENABLE_DBGUTIL" \) -a "$ENABLE_SYMBOLS_FOR" = "all"; then
5332    # Building on Android with full symbols: without enough memory the linker never finishes currently.
5333    AC_MSG_CHECKING([whether enough memory is available for linking])
5334    mem_size=$(grep -o 'MemTotal: *.\+ kB' /proc/meminfo | sed 's/MemTotal: *\(.\+\) kB/\1/')
5335    # Check for 15GB, as Linux reports a bit less than the physical memory size.
5336    if test -n "$mem_size" -a $mem_size -lt 15728640; then
5337        AC_MSG_ERROR([building with full symbols and less than 16GB of memory is not supported])
5338    else
5339        AC_MSG_RESULT([yes])
5340    fi
5341fi
5342
5343ENABLE_OPTIMIZED=
5344ENABLE_OPTIMIZED_DEBUG=
5345AC_MSG_CHECKING([whether to compile with optimization flags])
5346if test -z "$enable_optimized"; then
5347    if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL$ENABLE_GCOV"; then
5348        enable_optimized=no
5349    else
5350        enable_optimized=yes
5351    fi
5352fi
5353if test "$enable_optimized" = yes; then
5354    ENABLE_OPTIMIZED=TRUE
5355    AC_MSG_RESULT([yes])
5356elif test "$enable_optimized" = debug; then
5357    ENABLE_OPTIMIZED_DEBUG=TRUE
5358    AC_MSG_RESULT([yes (debug)])
5359    HAVE_GCC_OG=
5360    if test "$GCC" = "yes" -a "$_os" != "Emscripten"; then
5361        AC_MSG_CHECKING([whether $CC_BASE supports -Og])
5362        save_CFLAGS=$CFLAGS
5363        CFLAGS="$CFLAGS -Werror -Og"
5364        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_OG=TRUE ],[])
5365        CFLAGS=$save_CFLAGS
5366        if test "$HAVE_GCC_OG" = "TRUE"; then
5367            AC_MSG_RESULT([yes])
5368        else
5369            AC_MSG_RESULT([no])
5370        fi
5371    fi
5372    if test -z "$HAVE_GCC_OG" -a "$_os" != "Emscripten"; then
5373        AC_MSG_ERROR([The compiler does not support optimizations suitable for debugging.])
5374    fi
5375else
5376    AC_MSG_RESULT([no])
5377fi
5378AC_SUBST(ENABLE_OPTIMIZED)
5379AC_SUBST(ENABLE_OPTIMIZED_DEBUG)
5380
5381#
5382# determine CPUNAME, OS, ...
5383#
5384case "$host_os" in
5385
5386cygwin*|wsl*)
5387    # Already handled
5388    ;;
5389
5390darwin*)
5391    COM=GCC
5392    OS=MACOSX
5393    RTL_OS=MacOSX
5394    P_SEP=:
5395
5396    case "$host_cpu" in
5397    aarch64|arm64)
5398        if test "$enable_ios_simulator" = "yes"; then
5399            OS=iOS
5400        else
5401            CPUNAME=AARCH64
5402            RTL_ARCH=AARCH64
5403            PLATFORMID=macosx_aarch64
5404        fi
5405        ;;
5406    x86_64)
5407        if test "$enable_ios_simulator" = "yes"; then
5408            OS=iOS
5409        fi
5410        CPUNAME=X86_64
5411        RTL_ARCH=X86_64
5412        PLATFORMID=macosx_x86_64
5413        ;;
5414    *)
5415        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5416        ;;
5417    esac
5418    ;;
5419
5420ios*)
5421    COM=GCC
5422    OS=iOS
5423    RTL_OS=iOS
5424    P_SEP=:
5425
5426    case "$host_cpu" in
5427    aarch64|arm64)
5428        if test "$enable_ios_simulator" = "yes"; then
5429            AC_MSG_ERROR([iOS simulator is only available in macOS not iOS])
5430        fi
5431        ;;
5432    *)
5433        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5434        ;;
5435    esac
5436    CPUNAME=AARCH64
5437    RTL_ARCH=AARCH64
5438    PLATFORMID=ios_arm64
5439    ;;
5440
5441dragonfly*)
5442    COM=GCC
5443    OS=DRAGONFLY
5444    RTL_OS=DragonFly
5445    P_SEP=:
5446
5447    case "$host_cpu" in
5448    i*86)
5449        CPUNAME=INTEL
5450        RTL_ARCH=x86
5451        PLATFORMID=dragonfly_x86
5452        ;;
5453    x86_64)
5454        CPUNAME=X86_64
5455        RTL_ARCH=X86_64
5456        PLATFORMID=dragonfly_x86_64
5457        ;;
5458    *)
5459        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5460        ;;
5461    esac
5462    ;;
5463
5464freebsd*)
5465    COM=GCC
5466    RTL_OS=FreeBSD
5467    OS=FREEBSD
5468    P_SEP=:
5469
5470    case "$host_cpu" in
5471    aarch64)
5472        CPUNAME=AARCH64
5473        PLATFORMID=freebsd_aarch64
5474        RTL_ARCH=AARCH64
5475        ;;
5476    i*86)
5477        CPUNAME=INTEL
5478        RTL_ARCH=x86
5479        PLATFORMID=freebsd_x86
5480        ;;
5481    x86_64|amd64)
5482        CPUNAME=X86_64
5483        RTL_ARCH=X86_64
5484        PLATFORMID=freebsd_x86_64
5485        ;;
5486    powerpc64)
5487        CPUNAME=POWERPC64
5488        RTL_ARCH=PowerPC_64
5489        PLATFORMID=freebsd_powerpc64
5490        ;;
5491    powerpc|powerpcspe)
5492        CPUNAME=POWERPC
5493        RTL_ARCH=PowerPC
5494        PLATFORMID=freebsd_powerpc
5495        ;;
5496    *)
5497        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5498        ;;
5499    esac
5500    ;;
5501
5502haiku*)
5503    COM=GCC
5504    GUIBASE=haiku
5505    RTL_OS=Haiku
5506    OS=HAIKU
5507    P_SEP=:
5508
5509    case "$host_cpu" in
5510    i*86)
5511        CPUNAME=INTEL
5512        RTL_ARCH=x86
5513        PLATFORMID=haiku_x86
5514        ;;
5515    x86_64|amd64)
5516        CPUNAME=X86_64
5517        RTL_ARCH=X86_64
5518        PLATFORMID=haiku_x86_64
5519        ;;
5520    *)
5521        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5522        ;;
5523    esac
5524    ;;
5525
5526kfreebsd*)
5527    COM=GCC
5528    OS=LINUX
5529    RTL_OS=kFreeBSD
5530    P_SEP=:
5531
5532    case "$host_cpu" in
5533
5534    i*86)
5535        CPUNAME=INTEL
5536        RTL_ARCH=x86
5537        PLATFORMID=kfreebsd_x86
5538        ;;
5539    x86_64)
5540        CPUNAME=X86_64
5541        RTL_ARCH=X86_64
5542        PLATFORMID=kfreebsd_x86_64
5543        ;;
5544    *)
5545        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5546        ;;
5547    esac
5548    ;;
5549
5550linux-gnu*|linux-musl*)
5551    COM=GCC
5552    OS=LINUX
5553    RTL_OS=Linux
5554    P_SEP=:
5555
5556    case "$host_cpu" in
5557
5558    aarch64)
5559        CPUNAME=AARCH64
5560        PLATFORMID=linux_aarch64
5561        RTL_ARCH=AARCH64
5562        EPM_FLAGS="-a arm64"
5563        ;;
5564    alpha)
5565        CPUNAME=AXP
5566        RTL_ARCH=ALPHA
5567        PLATFORMID=linux_alpha
5568        ;;
5569    arm*)
5570        CPUNAME=ARM
5571        EPM_FLAGS="-a arm"
5572        RTL_ARCH=ARM_EABI
5573        PLATFORMID=linux_arm_eabi
5574        case "$host_cpu" in
5575        arm*-linux)
5576            RTL_ARCH=ARM_OABI
5577            PLATFORMID=linux_arm_oabi
5578            ;;
5579        esac
5580        ;;
5581    hppa)
5582        CPUNAME=HPPA
5583        RTL_ARCH=HPPA
5584        EPM_FLAGS="-a hppa"
5585        PLATFORMID=linux_hppa
5586        ;;
5587    i*86)
5588        CPUNAME=INTEL
5589        RTL_ARCH=x86
5590        PLATFORMID=linux_x86
5591        ;;
5592    ia64)
5593        CPUNAME=IA64
5594        RTL_ARCH=IA64
5595        PLATFORMID=linux_ia64
5596        ;;
5597    mips)
5598        CPUNAME=MIPS
5599        RTL_ARCH=MIPS_EB
5600        EPM_FLAGS="-a mips"
5601        PLATFORMID=linux_mips_eb
5602        ;;
5603    mips64)
5604        CPUNAME=MIPS64
5605        RTL_ARCH=MIPS64_EB
5606        EPM_FLAGS="-a mips64"
5607        PLATFORMID=linux_mips64_eb
5608        ;;
5609    mips64el)
5610        CPUNAME=MIPS64
5611        RTL_ARCH=MIPS64_EL
5612        EPM_FLAGS="-a mips64el"
5613        PLATFORMID=linux_mips64_el
5614        ;;
5615    mipsel)
5616        CPUNAME=MIPS
5617        RTL_ARCH=MIPS_EL
5618        EPM_FLAGS="-a mipsel"
5619        PLATFORMID=linux_mips_el
5620        ;;
5621    riscv64)
5622        CPUNAME=RISCV64
5623        RTL_ARCH=RISCV64
5624        EPM_FLAGS="-a riscv64"
5625        PLATFORMID=linux_riscv64
5626        ;;
5627    m68k)
5628        CPUNAME=M68K
5629        RTL_ARCH=M68K
5630        PLATFORMID=linux_m68k
5631        ;;
5632    powerpc)
5633        CPUNAME=POWERPC
5634        RTL_ARCH=PowerPC
5635        PLATFORMID=linux_powerpc
5636        ;;
5637    powerpc64)
5638        CPUNAME=POWERPC64
5639        RTL_ARCH=PowerPC_64
5640        PLATFORMID=linux_powerpc64
5641        ;;
5642    powerpc64le)
5643        CPUNAME=POWERPC64
5644        RTL_ARCH=PowerPC_64_LE
5645        PLATFORMID=linux_powerpc64_le
5646        ;;
5647    sparc)
5648        CPUNAME=SPARC
5649        RTL_ARCH=SPARC
5650        PLATFORMID=linux_sparc
5651        ;;
5652    sparc64)
5653        CPUNAME=SPARC64
5654        RTL_ARCH=SPARC64
5655        PLATFORMID=linux_sparc64
5656        ;;
5657    s390x)
5658        CPUNAME=S390X
5659        RTL_ARCH=S390x
5660        PLATFORMID=linux_s390x
5661        ;;
5662    x86_64)
5663        CPUNAME=X86_64
5664        RTL_ARCH=X86_64
5665        PLATFORMID=linux_x86_64
5666        ;;
5667    loongarch64)
5668        CPUNAME=LOONGARCH64
5669        RTL_ARCH=LOONGARCH64
5670        PLATFORMID=linux_loongarch64
5671        ;;
5672    *)
5673        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5674        ;;
5675    esac
5676    ;;
5677
5678linux-android*)
5679    COM=GCC
5680    OS=ANDROID
5681    RTL_OS=Android
5682    P_SEP=:
5683
5684    case "$host_cpu" in
5685
5686    arm|armel)
5687        CPUNAME=ARM
5688        RTL_ARCH=ARM_EABI
5689        PLATFORMID=android_arm_eabi
5690        ;;
5691    aarch64)
5692        CPUNAME=AARCH64
5693        RTL_ARCH=AARCH64
5694        PLATFORMID=android_aarch64
5695        ;;
5696    i*86)
5697        CPUNAME=INTEL
5698        RTL_ARCH=x86
5699        PLATFORMID=android_x86
5700        ;;
5701    x86_64)
5702        CPUNAME=X86_64
5703        RTL_ARCH=X86_64
5704        PLATFORMID=android_x86_64
5705        ;;
5706    *)
5707        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5708        ;;
5709    esac
5710    ;;
5711
5712*netbsd*)
5713    COM=GCC
5714    OS=NETBSD
5715    RTL_OS=NetBSD
5716    P_SEP=:
5717
5718    case "$host_cpu" in
5719    i*86)
5720        CPUNAME=INTEL
5721        RTL_ARCH=x86
5722        PLATFORMID=netbsd_x86
5723        ;;
5724    powerpc)
5725        CPUNAME=POWERPC
5726        RTL_ARCH=PowerPC
5727        PLATFORMID=netbsd_powerpc
5728        ;;
5729    sparc)
5730        CPUNAME=SPARC
5731        RTL_ARCH=SPARC
5732        PLATFORMID=netbsd_sparc
5733        ;;
5734    x86_64)
5735        CPUNAME=X86_64
5736        RTL_ARCH=X86_64
5737        PLATFORMID=netbsd_x86_64
5738        ;;
5739    *)
5740        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5741        ;;
5742    esac
5743    ;;
5744
5745openbsd*)
5746    COM=GCC
5747    OS=OPENBSD
5748    RTL_OS=OpenBSD
5749    P_SEP=:
5750
5751    case "$host_cpu" in
5752    i*86)
5753        CPUNAME=INTEL
5754        RTL_ARCH=x86
5755        PLATFORMID=openbsd_x86
5756        ;;
5757    x86_64)
5758        CPUNAME=X86_64
5759        RTL_ARCH=X86_64
5760        PLATFORMID=openbsd_x86_64
5761        ;;
5762    *)
5763        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5764        ;;
5765    esac
5766    SOLARINC="$SOLARINC -I/usr/local/include"
5767    ;;
5768
5769solaris*)
5770    COM=GCC
5771    OS=SOLARIS
5772    RTL_OS=Solaris
5773    P_SEP=:
5774
5775    case "$host_cpu" in
5776    i*86)
5777        CPUNAME=INTEL
5778        RTL_ARCH=x86
5779        PLATFORMID=solaris_x86
5780        ;;
5781    sparc)
5782        CPUNAME=SPARC
5783        RTL_ARCH=SPARC
5784        PLATFORMID=solaris_sparc
5785        ;;
5786    sparc64)
5787        CPUNAME=SPARC64
5788        RTL_ARCH=SPARC64
5789        PLATFORMID=solaris_sparc64
5790        ;;
5791    *)
5792        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5793        ;;
5794    esac
5795    SOLARINC="$SOLARINC -I/usr/local/include"
5796    ;;
5797
5798emscripten*)
5799    COM=GCC
5800    OS=EMSCRIPTEN
5801    RTL_OS=Emscripten
5802    P_SEP=:
5803
5804    case "$host_cpu" in
5805    wasm32|wasm64)
5806        ;;
5807    *)
5808        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5809        ;;
5810    esac
5811    CPUNAME=INTEL
5812    RTL_ARCH=x86
5813    PLATFORMID=linux_x86
5814    ;;
5815
5816*)
5817    AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice for!])
5818    ;;
5819esac
5820
5821dnl ===================================================================
5822dnl Target-specific options
5823dnl ===================================================================
5824
5825ENABLE_LASX="TRUE"
5826if test "$CPUNAME" == LOONGARCH64; then
5827    AC_ARG_ENABLE(lasx,
5828        AS_HELP_STRING([--enable-lasx],
5829            [build with LASX vectorization])
5830    )
5831    if test "$enable_lasx" != yes; then
5832        ENABLE_LASX=""
5833    fi
5834fi
5835AC_SUBST(ENABLE_LASX)
5836
5837dnl ===================================================================
5838dnl .NET support
5839dnl ===================================================================
5840
5841AC_MSG_CHECKING([whether to build with .NET support])
5842if test "$with_dotnet" != no; then
5843    if test "$DISABLE_SCRIPTING" = TRUE; then
5844        AC_MSG_RESULT([no, overridden by --disable-scripting])
5845        with_dotnet=no
5846        ENABLE_DOTNET=""
5847    else
5848        AC_MSG_RESULT([yes])
5849        ENABLE_DOTNET=TRUE
5850    fi
5851else
5852    AC_MSG_RESULT([no])
5853    ENABLE_DOTNET=""
5854fi
5855
5856if test "$ENABLE_DOTNET" = TRUE; then
5857    if test -n "$with_dotnet" && test "$with_dotnet" != yes; then
5858        dnl the user explicitly asks for a particular dotnet executable here
5859
5860        AC_MSG_CHECKING([for dotnet])
5861        PathFormat "$with_dotnet"
5862        DOTNET="$formatted_path_unix"
5863
5864        if test -f "$DOTNET"; then
5865            dnl the user provided dotnet is valid
5866            AC_MSG_RESULT([$formatted_path])
5867        else
5868            dnl since the user wants to use a particular dotnet executable,
5869            dnl error out and let them correct the path instead of silently disabling.
5870
5871            AC_MSG_ERROR([$DOTNET is not a valid dotnet executable])
5872            ENABLE_DOTNET=""
5873        fi
5874    else
5875        dnl no specific path to dotnet provided, try looking in $PATH
5876
5877        if test "$OS" = WNT
5878        then
5879                AC_PATH_PROGS(DOTNET, [dotnet.exe])
5880        else
5881                AC_PATH_PROGS(DOTNET, [dotnet])
5882        fi
5883        PathFormat "$DOTNET"
5884        DOTNET="$formatted_path_unix"
5885
5886        if test -z "$DOTNET"; then
5887            dnl since the user does not specify any particular dotnet
5888            dnl silently disable here instead of erroring out, to prevent
5889            dnl breaking their build, as --with-dotnet is enabled by default.
5890
5891            AC_MSG_WARN([dotnet not found, disabling .NET support])
5892            ENABLE_DOTNET=""
5893        fi
5894    fi
5895
5896    if test -n "$DOTNET"; then
5897        dnl the dotnet executable was found, but no guarantees on whether
5898        dnl it contains SDK version 8 or higher unless we check.
5899
5900        AC_MSG_CHECKING([for .NET SDK 8 or higher])
5901        dotnet_sdk_ver_major=`"$DOTNET" --version | "$AWK" -F. '{ print $1 }'`
5902        if test "$dotnet_sdk_ver_major" -ge 8; then
5903            dnl the SDK seems valid, get the root directory
5904
5905            dotnet_sdk_ver=`"$DOTNET" --version | "$SED" 's/\r//g'`
5906            dotnet_sdk_dir=`"$DOTNET" --list-sdks | "$AWK" -F [[]][[]] "/^$dotnet_sdk_ver/"'{ print $2 }' | "$SED" 's/\r//g'`
5907            PathFormat "$dotnet_sdk_dir"
5908            DOTNET_ROOT=`dirname "$formatted_path_unix"`
5909
5910            AC_MSG_RESULT([yes])
5911        else
5912            dnl silently disable for same reason as before
5913
5914            AC_MSG_RESULT([no, disabling .NET support])
5915            ENABLE_DOTNET=""
5916        fi
5917    fi
5918fi
5919
5920if test "$ENABLE_DOTNET" != TRUE; then
5921    DOTNET=""
5922    DOTNET_ROOT=""
5923fi
5924
5925AC_SUBST(ENABLE_DOTNET)
5926AC_SUBST(DOTNET)
5927AC_SUBST(DOTNET_ROOT)
5928
5929DISABLE_GUI=""
5930if test "$enable_gui" = "no"; then
5931    if test "$using_x11" != yes; then
5932        AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice with --disable-gui.])
5933    fi
5934    USING_X11=
5935    DISABLE_GUI=TRUE
5936    test_epoxy=no
5937else
5938    AC_DEFINE(HAVE_FEATURE_UI)
5939fi
5940AC_SUBST(DISABLE_GUI)
5941
5942if test "$with_x" = "no"; then
5943    USING_X11=
5944fi
5945
5946if test -z "$USING_X11" -a "$enable_qt5" = "yes" -a "$enable_gen" = "yes"; then
5947    AC_MSG_ERROR([Can't select gen VCL plugin, if --without-x is used!])
5948fi
5949
5950if test "$using_x11" = yes; then
5951    if test "$USING_X11" = TRUE; then
5952        AC_DEFINE(USING_X11)
5953    else
5954        disable_x11_tests
5955        if test "$DISABLE_DYNLOADING" = TRUE; then
5956            test_qt5=yes
5957            test_qt6=yes
5958        fi
5959    fi
5960else
5961    if test "$USING_X11" = TRUE; then
5962        AC_MSG_ERROR([Platform doesn't support X11 (\$using_x11), but \$USING_X11 is set!])
5963    fi
5964fi
5965
5966WORKDIR="${BUILDDIR}/workdir"
5967INSTDIR="${BUILDDIR}/instdir"
5968INSTROOTBASE=${INSTDIR}${INSTROOTBASESUFFIX}
5969INSTROOT=${INSTROOTBASE}${INSTROOTCONTENTSUFFIX}
5970AC_SUBST(COM)
5971AC_SUBST(CPUNAME)
5972AC_SUBST(RTL_OS)
5973AC_SUBST(RTL_ARCH)
5974AC_SUBST(EPM_FLAGS)
5975AC_SUBST(USING_X11)
5976AC_SUBST([INSTDIR])
5977AC_SUBST([INSTROOT])
5978AC_SUBST([INSTROOTBASE])
5979AC_SUBST(OS)
5980AC_SUBST(P_SEP)
5981AC_SUBST(WORKDIR)
5982AC_SUBST(PLATFORMID)
5983AC_SUBST(WINDOWS_X64)
5984AC_DEFINE_UNQUOTED(SDKDIR, "$INSTDIR/$SDKDIRNAME")
5985AC_DEFINE_UNQUOTED(WORKDIR,"$WORKDIR")
5986
5987if test "$OS" = WNT -a "$COM" = MSC; then
5988    case "$CPUNAME" in
5989    INTEL) CPPU_ENV=msci ;;
5990    X86_64) CPPU_ENV=mscx ;;
5991    AARCH64) CPPU_ENV=msca ;;
5992    *)
5993        AC_MSG_ERROR([Unknown \$CPUNAME '$CPUNAME' for $OS / $COM"])
5994        ;;
5995    esac
5996else
5997    CPPU_ENV=gcc3
5998fi
5999AC_SUBST(CPPU_ENV)
6000
6001dnl ===================================================================
6002dnl Test which package format to use
6003dnl ===================================================================
6004AC_MSG_CHECKING([which package format to use])
6005if test -n "$with_package_format" -a "$with_package_format" != no; then
6006    for i in $with_package_format; do
6007        case "$i" in
6008        bsd | deb | pkg | rpm | archive | dmg | installed | msi | emscripten)
6009            ;;
6010        *)
6011            AC_MSG_ERROR([unsupported format $i. Supported by EPM are:
6012bsd - FreeBSD, NetBSD, or OpenBSD software distribution
6013deb - Debian software distribution
6014pkg - Solaris software distribution
6015rpm - RedHat software distribution
6016
6017LibreOffice additionally supports:
6018archive - .tar.gz or .zip
6019dmg - macOS .dmg
6020emscripten - directory with qt_soffice.html etc.
6021installed - installation tree
6022msi - Windows .msi
6023        ])
6024            ;;
6025        esac
6026    done
6027    # fakeroot is needed to ensure correct file ownerships/permissions
6028    # inside deb packages and tar archives created on Linux and Solaris.
6029    if test "$OS" = "LINUX" || test "$OS" = "SOLARIS"; then
6030        AC_PATH_PROG(FAKEROOT, fakeroot, no)
6031        if test "$FAKEROOT" = "no"; then
6032            AC_MSG_ERROR(
6033                [--with-package-format='$with_package_format' requires fakeroot. Install fakeroot.])
6034        fi
6035    fi
6036    PKGFORMAT="$with_package_format"
6037    AC_MSG_RESULT([$PKGFORMAT])
6038else
6039    PKGFORMAT=
6040    AC_MSG_RESULT([none])
6041fi
6042AC_SUBST(PKGFORMAT)
6043
6044dnl ===================================================================
6045dnl handle help related options
6046dnl
6047dnl If you change help related options, please update README.help
6048dnl ===================================================================
6049
6050ENABLE_HTMLHELP=
6051HELP_OMINDEX_PAGE=
6052HELP_ONLINE=
6053WITH_HELPPACKS=
6054
6055AC_MSG_CHECKING([which help to build])
6056if test -n "$with_help" -a "$with_help" != "no"; then
6057    GIT_NEEDED_SUBMODULES="helpcontent2 $GIT_NEEDED_SUBMODULES"
6058    BUILD_TYPE="$BUILD_TYPE HELP"
6059    case "$with_help" in
6060    "html")
6061        ENABLE_HTMLHELP=TRUE
6062        WITH_HELPPACKS=TRUE
6063        SCPDEFS="$SCPDEFS -DWITH_HELPPACKS"
6064        AC_MSG_RESULT([HTML (local)])
6065        ;;
6066    "online")
6067        ENABLE_HTMLHELP=TRUE
6068        HELP_ONLINE=TRUE
6069        AC_MSG_RESULT([HTML (online)])
6070        ;;
6071    yes)
6072        WITH_HELPPACKS=TRUE
6073        SCPDEFS="$SCPDEFS -DWITH_HELPPACKS"
6074        AC_MSG_RESULT([XML (local)])
6075        ;;
6076    *)
6077        AC_MSG_ERROR([Unknown --with-help=$with_help])
6078        ;;
6079    esac
6080else
6081    AC_MSG_RESULT([no])
6082fi
6083
6084AC_MSG_CHECKING([if we need to build the help index tooling])
6085if test \( "$with_help" = yes -o "$enable_extension_integration" != no \) -a -z "$DISABLE_DYNLOADING"; then
6086    BUILD_TYPE="$BUILD_TYPE HELPTOOLS"
6087    test_clucene=yes
6088    AC_MSG_RESULT([yes])
6089else
6090    AC_MSG_RESULT([no])
6091fi
6092
6093AC_MSG_CHECKING([whether to enable xapian-omega support for online help])
6094if test -n "$with_omindex" -a "$with_omindex" != "no"; then
6095    if test "$HELP_ONLINE" != TRUE; then
6096        AC_MSG_ERROR([Can't build xapian-omega index without --help=online])
6097    fi
6098    case "$with_omindex" in
6099    "server")
6100        HELP_OMINDEX_PAGE=TRUE
6101        AC_MSG_RESULT([SERVER])
6102        ;;
6103    "noxap")
6104        AC_MSG_RESULT([NOXAP])
6105        ;;
6106    *)
6107        AC_MSG_ERROR([Unknown --with-omindex=$with_omindex])
6108        ;;
6109    esac
6110else
6111    AC_MSG_RESULT([no])
6112fi
6113
6114AC_MSG_CHECKING([whether to include the XML-help support])
6115if test "$enable_xmlhelp" = yes; then
6116    BUILD_TYPE="$BUILD_TYPE XMLHELP"
6117    test_clucene=yes
6118    AC_DEFINE(HAVE_FEATURE_XMLHELP)
6119    AC_MSG_RESULT([yes])
6120else
6121    if test "$with_help" = yes; then
6122        add_warning "Building the XML help, but LO with disabled xmlhelp support. Generated help can't be accessed from this LO build!"
6123    fi
6124    AC_MSG_RESULT([no])
6125fi
6126
6127dnl Test whether to integrate helppacks into the product's installer
6128AC_MSG_CHECKING([for helppack integration])
6129if test -z "$WITH_HELPPACKS" -o "$with_helppack_integration" = no; then
6130    AC_MSG_RESULT([no integration])
6131else
6132    SCPDEFS="$SCPDEFS -DWITH_HELPPACK_INTEGRATION"
6133    AC_MSG_RESULT([integration])
6134fi
6135
6136AC_SUBST([ENABLE_HTMLHELP])
6137AC_SUBST([HELP_OMINDEX_PAGE])
6138AC_SUBST([HELP_ONLINE])
6139# WITH_HELPPACKS is used only in configure
6140
6141dnl ===================================================================
6142dnl Set up a different compiler to produce tools to run on the build
6143dnl machine when doing cross-compilation
6144dnl ===================================================================
6145
6146m4_pattern_allow([PKG_CONFIG_FOR_BUILD])
6147m4_pattern_allow([PKG_CONFIG_LIBDIR])
6148if test "$cross_compiling" = "yes"; then
6149    AC_MSG_CHECKING([for BUILD platform configuration])
6150    echo
6151    rm -rf CONF-FOR-BUILD config_build.mk
6152    mkdir CONF-FOR-BUILD
6153    # Here must be listed all files needed when running the configure script. In particular, also
6154    # those expanded by the AC_CONFIG_FILES() call near the end of this configure.ac. For clarity,
6155    # keep them in the same order as there.
6156    (cd $SRC_ROOT && tar cf - \
6157        config.guess \
6158        bin/get_config_variables \
6159        solenv/bin/getcompver.awk \
6160        solenv/inc/langlist.mk \
6161        download.lst \
6162        config_host.mk.in \
6163        config_host_lang.mk.in \
6164        Makefile.in \
6165        bin/bffvalidator.sh.in \
6166        bin/odfvalidator.sh.in \
6167        bin/officeotron.sh.in \
6168        instsetoo_native/util/openoffice.lst.in \
6169        config_host/*.in \
6170        sysui/desktop/macosx/Info.plist.in \
6171        sysui/desktop/macosx/LaunchConstraint.plist.in \
6172        sysui/desktop/macosx/hardened_runtime.xcent.in \
6173        sysui/desktop/macosx/lo.xcent.in \
6174        .vscode/vs-code-template.code-workspace.in \
6175        solenv/lockfile/autoconf.h.in \
6176        extensions/source/macosx/quicklookpreview/appex/Info.plist.in \
6177        extensions/source/macosx/quicklookthumbnail/appex/Info.plist.in \
6178        ) \
6179    | (cd CONF-FOR-BUILD && tar xf -)
6180    cp configure CONF-FOR-BUILD
6181    test -d config_build && cp -p config_build/*.h CONF-FOR-BUILD/config_host 2>/dev/null
6182    (
6183    unset COM USING_X11 OS CPUNAME
6184    unset CC CXX SYSBASE CFLAGS
6185    unset AR LD NM OBJDUMP PKG_CONFIG RANLIB READELF STRIP
6186    unset CPPUNIT_CFLAGS CPPUNIT_LIBS
6187    unset LIBXML_CFLAGS LIBXML_LIBS LIBXSLT_CFLAGS LIBXSLT_LIBS XSLTPROC
6188    unset PKG_CONFIG_LIBDIR PKG_CONFIG_PATH
6189    if test -n "$CC_FOR_BUILD"; then
6190        export CC="$CC_FOR_BUILD"
6191        CC_BASE=`first_arg_basename "$CC"`
6192    fi
6193    if test -n "$CXX_FOR_BUILD"; then
6194        export CXX="$CXX_FOR_BUILD"
6195        CXX_BASE=`first_arg_basename "$CXX"`
6196    fi
6197    test -n "$PKG_CONFIG_FOR_BUILD" && export PKG_CONFIG="$PKG_CONFIG_FOR_BUILD"
6198    cd CONF-FOR-BUILD
6199
6200    # Handle host configuration, which affects the cross-toolset too
6201    sub_conf_opts=""
6202    test -n "$enable_ccache" && sub_conf_opts="$sub_conf_opts --enable-ccache=$enable_ccache"
6203    test -n "$with_ant_home" && sub_conf_opts="$sub_conf_opts --with-ant-home=$with_ant_home"
6204    test "$with_junit" = "no" && sub_conf_opts="$sub_conf_opts --without-junit"
6205    # While we don't need scripting support, we don't have a PYTHON_FOR_BUILD Java equivalent, so must enable scripting for Java
6206    if test -n "$ENABLE_JAVA"; then
6207        case "$_os" in
6208        Android)
6209            # Hack for Android - the build doesn't need a host JDK, so just forward to build for convenience
6210            test -n "$with_jdk_home" && sub_conf_opts="$sub_conf_opts --with-jdk-home=$with_jdk_home"
6211            ;;
6212        *)
6213            if test -z "$with_jdk_home"; then
6214                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.])
6215            fi
6216            ;;
6217        esac
6218    else
6219        sub_conf_opts="$sub_conf_opts --without-java"
6220    fi
6221    test -n "$TARFILE_LOCATION" && sub_conf_opts="$sub_conf_opts --with-external-tar=$TARFILE_LOCATION"
6222    test "$with_galleries" = "no" -o -z "$WITH_GALLERY_BUILD" && sub_conf_opts="$sub_conf_opts --with-galleries=no --disable-database-connectivity"
6223    test "$with_templates" = "no" -o -z "$WITH_TEMPLATES" && sub_conf_opts="$sub_conf_opts --with-templates=no"
6224    test -n "$with_help" -a "$with_help" != "no" && sub_conf_opts="$sub_conf_opts --with-help=$with_help"
6225    test "$enable_extensions" = yes || sub_conf_opts="$sub_conf_opts --disable-extensions"
6226    test "${enable_ld+set}" = set -a "$build_cpu" = "$host_cpu" && sub_conf_opts="$sub_conf_opts --enable-ld=${enable_ld}"
6227    test "${enable_pch+set}" = set && sub_conf_opts="$sub_conf_opts --enable-pch=${enable_pch}"
6228    test "$enable_wasm_strip" = "yes" && sub_conf_opts="$sub_conf_opts --enable-wasm-strip"
6229    test "${with_system_lockfile+set}" = set && sub_conf_opts="$sub_conf_opts --with-system-lockfile=${with_system_lockfile}"
6230    test "${enable_fuzzers}" = yes && sub_conf_opts="$sub_conf_opts --without-system-libxml"
6231    if test "$_os" = "Emscripten"; then
6232        sub_conf_opts="$sub_conf_opts --without-system-libxml --without-system-fontconfig --without-system-freetype --without-system-zlib"
6233    fi
6234    # windows uses full-internal python and that in turn relies on openssl, so also enable openssl
6235    # when cross-compiling for aarch64, overriding the defaults below
6236    # similarly: at least skia headers need to be available in the cross-toolset
6237    test "${PLATFORMID}" = "windows_aarch64" && sub_conf_opts="$sub_conf_opts --enable-openssl --with-tls=openssl --enable-skia"
6238    # cross-compilations don't necessarily enable python support in the product/the sub-configure needs to know
6239    # that the minimum supported python version is 3.7 or later...
6240    test "$with_system_harfbuzz" != "yes" && sub_conf_opts="$sub_conf_opts NEED_MESON=TRUE"
6241
6242    # Don't bother having configure look for stuff not needed for the build platform anyway
6243    # WARNING: any option with an argument containing spaces must be handled separately (see --with-theme)
6244    sub_conf_defaults=" \
6245        --build="$build_alias" \
6246        --disable-cairo-canvas \
6247        --disable-cups \
6248        --disable-customtarget-components \
6249        --disable-firebird-sdbc \
6250        --disable-gpgmepp \
6251        --disable-gstreamer-1-0 \
6252        --disable-gtk3 \
6253        --disable-gtk4 \
6254        --disable-libcmis \
6255        --disable-mariadb-sdbc \
6256        --disable-nss \
6257        --disable-online-update \
6258        --disable-opencl \
6259        --disable-openssl \
6260        --disable-pdfimport \
6261        --disable-postgresql-sdbc \
6262        --disable-skia \
6263        --disable-xmlhelp \
6264        --enable-dynamic-loading \
6265        --enable-icecream="$enable_icecream" \
6266        --without-gssapi \
6267        --without-doxygen \
6268        --without-tls \
6269        --without-webdav \
6270        --without-x \
6271"
6272    # single quotes added for better readability in case of spaces
6273    echo "    Running CONF-FOR-BUILD/configure" \
6274        $sub_conf_defaults \
6275        --with-parallelism="'$with_parallelism'" \
6276        --with-theme="'$with_theme'" \
6277        --with-vendor="'$with_vendor'" \
6278        $sub_conf_opts \
6279        $with_build_platform_configure_options \
6280        --srcdir=$srcdir
6281
6282    ./configure \
6283        $sub_conf_defaults \
6284        --with-parallelism="$with_parallelism" \
6285        --with-theme="$with_theme" \
6286        "--with-vendor=$with_vendor" \
6287        $sub_conf_opts \
6288        $with_build_platform_configure_options \
6289        --srcdir=$srcdir \
6290        2>&1 | sed -e 's/^/    /'
6291    if test [${PIPESTATUS[0]}] -ne 0; then
6292        AC_MSG_ERROR([Running the configure script for BUILD side failed, see CONF-FOR-BUILD/config.log])
6293    fi
6294
6295    # filter permitted build targets
6296    PERMITTED_BUILD_TARGETS="
6297        ARGON2
6298        AVMEDIA
6299        BOOST
6300        BZIP2
6301        CAIRO
6302        CLUCENE
6303        CURL
6304        DBCONNECTIVITY
6305        DESKTOP
6306        DRAGONBOX
6307        DYNLOADING
6308        EPOXY
6309        EXPAT
6310        FROZEN
6311        GLM
6312        GRAPHITE
6313        HARFBUZZ
6314        HELPTOOLS
6315        ICU
6316        LCMS2
6317        LIBJPEG_TURBO
6318        LIBLANGTAG
6319        LibO
6320        LIBFFI
6321        LIBEOT
6322        LIBPN
6323        LIBTIFF
6324        LIBWEBP
6325        LIBXML2
6326        LIBXSLT
6327        MDDS
6328        MESON
6329        NATIVE
6330        OPENSSL
6331        ORCUS
6332        PYTHON
6333        REPORTBUILDER
6334        SCRIPTING
6335        SKIA
6336        ZLIB
6337        ZSTD
6338        ZXCVBN
6339"
6340    # converts BUILD_TYPE and PERMITTED_BUILD_TARGETS into non-whitespace,
6341    # newlined lists, to use grep as a filter
6342    PERMITTED_BUILD_TARGETS=$(echo "$PERMITTED_BUILD_TARGETS" | sed -e '/^ *$/d' -e 's/ *//')
6343    BUILD_TARGETS="$(sed -n -e '/^export BUILD_TYPE=/ s/.*=//p' config_host.mk | tr ' ' '\n')"
6344    BUILD_TARGETS="$(echo "$BUILD_TARGETS" | grep -F "$PERMITTED_BUILD_TARGETS" | tr '\n' ' ')"
6345    sed -i -e "s/ BUILD_TYPE=.*$/ BUILD_TYPE=$BUILD_TARGETS/" config_host.mk
6346
6347    cp config_host.mk ../config_build.mk
6348    cp config_host_lang.mk ../config_build_lang.mk
6349    mv config.log ../config.Build.log
6350    mkdir -p ../config_build
6351    mv config_host/*.h ../config_build
6352    test -f "$WARNINGS_FILE" && mv "$WARNINGS_FILE" "../$WARNINGS_FILE_FOR_BUILD"
6353
6354    # all these will get a _FOR_BUILD postfix
6355    DIRECT_FOR_BUILD_SETTINGS="
6356        CC
6357        CPPU_ENV
6358        CXX
6359        ILIB
6360        JAVA_HOME
6361        JAVAIFLAGS
6362        JDK
6363        JDK_SECURITYMANAGER_DISALLOWED
6364        LIBO_BIN_FOLDER
6365        LIBO_LIB_FOLDER
6366        LIBO_URE_LIB_FOLDER
6367        LIBO_URE_MISC_FOLDER
6368        OS
6369        SDKDIRNAME
6370        SYSTEM_LIBXML
6371        SYSTEM_LIBXSLT
6372"
6373    # these overwrite host config with build config
6374    OVERWRITING_SETTINGS="
6375        ANT
6376        ANT_HOME
6377        ANT_LIB
6378        JAVA_SOURCE_VER
6379        JAVA_TARGET_VER
6380        JAVACFLAGS
6381        JAVACOMPILER
6382        JAVADOC
6383        JAVADOCISGJDOC
6384        LOCKFILE
6385        SYSTEM_GENBRK
6386        SYSTEM_GENCCODE
6387        SYSTEM_GENCMN
6388"
6389    # these need some special handling
6390    EXTRA_HANDLED_SETTINGS="
6391        INSTDIR
6392        INSTROOT
6393        PATH
6394        WORKDIR
6395"
6396    OLD_PATH=$PATH
6397    . ./bin/get_config_variables $DIRECT_FOR_BUILD_SETTINGS $OVERWRITING_SETTINGS $EXTRA_HANDLED_SETTINGS
6398    BUILD_PATH=$PATH
6399    PATH=$OLD_PATH
6400
6401    line=`echo "LO_PATH_FOR_BUILD='${BUILD_PATH}'" | sed -e 's,/CONF-FOR-BUILD,,g'`
6402    echo "$line" >>build-config
6403
6404    for V in $DIRECT_FOR_BUILD_SETTINGS; do
6405        VV='$'$V
6406        VV=`eval "echo $VV"`
6407        if test -n "$VV"; then
6408            line=${V}_FOR_BUILD='${'${V}_FOR_BUILD:-$VV'}'
6409            echo "$line" >>build-config
6410        fi
6411    done
6412
6413    for V in $OVERWRITING_SETTINGS; do
6414        VV='$'$V
6415        VV=`eval "echo $VV"`
6416        if test -n "$VV"; then
6417            line=${V}='${'${V}:-$VV'}'
6418            echo "$line" >>build-config
6419        fi
6420    done
6421
6422    for V in INSTDIR INSTROOT WORKDIR; do
6423        VV='$'$V
6424        VV=`eval "echo $VV"`
6425        VV=`echo $VV | sed -e "s,/CONF-FOR-BUILD/\([[a-z]]*\),/\1_for_build,g"`
6426        if test -n "$VV"; then
6427            line="${V}_FOR_BUILD='$VV'"
6428            echo "$line" >>build-config
6429        fi
6430    done
6431
6432    )
6433    test -f CONF-FOR-BUILD/build-config || AC_MSG_ERROR([setup/configure for BUILD side failed, see CONF-FOR-BUILD/config.log])
6434    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])
6435    perl -pi -e 's,/(workdir|instdir)(/|$),/\1_for_build\2,g;' \
6436             -e 's,/CONF-FOR-BUILD,,g;' config_build.mk
6437
6438    eval `cat CONF-FOR-BUILD/build-config`
6439
6440    AC_MSG_RESULT([checking for BUILD platform configuration... done])
6441
6442    rm -rf CONF-FOR-BUILD
6443else
6444    OS_FOR_BUILD="$OS"
6445    CC_FOR_BUILD="$CC"
6446    CPPU_ENV_FOR_BUILD="$CPPU_ENV"
6447    CXX_FOR_BUILD="$CXX"
6448    INSTDIR_FOR_BUILD="$INSTDIR"
6449    INSTROOT_FOR_BUILD="$INSTROOT"
6450    LIBO_BIN_FOLDER_FOR_BUILD="$LIBO_BIN_FOLDER"
6451    LIBO_LIB_FOLDER_FOR_BUILD="$LIBO_LIB_FOLDER"
6452    LIBO_URE_LIB_FOLDER_FOR_BUILD="$LIBO_URE_LIB_FOLDER"
6453    LIBO_URE_MISC_FOLDER_FOR_BUILD="$LIBO_URE_MISC_FOLDER"
6454    SDKDIRNAME_FOR_BUILD="$SDKDIRNAME"
6455    WORKDIR_FOR_BUILD="$WORKDIR"
6456fi
6457AC_SUBST(OS_FOR_BUILD)
6458AC_SUBST(INSTDIR_FOR_BUILD)
6459AC_SUBST(INSTROOT_FOR_BUILD)
6460AC_SUBST(LIBO_BIN_FOLDER_FOR_BUILD)
6461AC_SUBST(LIBO_LIB_FOLDER_FOR_BUILD)
6462AC_SUBST(LIBO_URE_LIB_FOLDER_FOR_BUILD)
6463AC_SUBST(LIBO_URE_MISC_FOLDER_FOR_BUILD)
6464AC_SUBST(SDKDIRNAME_FOR_BUILD)
6465AC_SUBST(WORKDIR_FOR_BUILD)
6466AC_SUBST(CC_FOR_BUILD)
6467AC_SUBST(CXX_FOR_BUILD)
6468AC_SUBST(CPPU_ENV_FOR_BUILD)
6469
6470dnl ===================================================================
6471dnl Check for lockfile deps
6472dnl ===================================================================
6473if test -z "$CROSS_COMPILING"; then
6474    test -n "$LOCKFILE" -a "${with_system_lockfile+set}" != set && with_system_lockfile="$LOCKFILE"
6475    test "${with_system_lockfile+set}" = set || with_system_lockfile=no
6476    AC_MSG_CHECKING([which lockfile binary to use])
6477    case "$with_system_lockfile" in
6478    yes)
6479        AC_MSG_RESULT([external])
6480        AC_PATH_PROGS([LOCKFILE],[dotlockfile lockfile])
6481        ;;
6482    no)
6483        AC_MSG_RESULT([internal])
6484        ;;
6485    *)
6486        if test -x "$with_system_lockfile"; then
6487            LOCKFILE="$with_system_lockfile"
6488        else
6489            AC_MSG_ERROR(['$with_system_lockfile' is not executable.])
6490        fi
6491        AC_MSG_RESULT([$with_system_lockfile])
6492        ;;
6493    esac
6494fi
6495
6496if test -n "$LOCKFILE" -a "$DISABLE_DYNLOADING" = TRUE; then
6497    add_warning "The default system lockfile has increasing poll intervals up to 60s, so linking executables may be delayed."
6498fi
6499
6500AC_CHECK_HEADERS([getopt.h paths.h sys/param.h])
6501AC_CHECK_FUNCS([utime utimes])
6502AC_SUBST(LOCKFILE)
6503
6504dnl ===================================================================
6505dnl Check for syslog header
6506dnl ===================================================================
6507AC_CHECK_HEADER(syslog.h, AC_DEFINE(HAVE_SYSLOG_H))
6508
6509dnl Set the ENABLE_WERROR variable. (Activate --enable-werror)
6510dnl ===================================================================
6511AC_MSG_CHECKING([whether to turn warnings to errors])
6512if test -n "$enable_werror" -a "$enable_werror" != "no"; then
6513    ENABLE_WERROR="TRUE"
6514    PYTHONWARNINGS="error"
6515    AC_MSG_RESULT([yes])
6516else
6517    if test -n "$LODE_HOME" -a -z "$enable_werror"; then
6518        ENABLE_WERROR="TRUE"
6519        PYTHONWARNINGS="error"
6520        AC_MSG_RESULT([yes])
6521    else
6522        AC_MSG_RESULT([no])
6523    fi
6524fi
6525AC_SUBST(ENABLE_WERROR)
6526AC_SUBST(PYTHONWARNINGS)
6527
6528dnl Check for --enable-assert-always-abort, set ASSERT_ALWAYS_ABORT
6529dnl ===================================================================
6530AC_MSG_CHECKING([whether to have assert() failures abort even without --enable-debug])
6531if test -z "$enable_assert_always_abort"; then
6532   if test "$ENABLE_DEBUG" = TRUE; then
6533       enable_assert_always_abort=yes
6534   else
6535       enable_assert_always_abort=no
6536   fi
6537fi
6538if test "$enable_assert_always_abort" = "yes"; then
6539    ASSERT_ALWAYS_ABORT="TRUE"
6540    AC_MSG_RESULT([yes])
6541else
6542    ASSERT_ALWAYS_ABORT="FALSE"
6543    AC_MSG_RESULT([no])
6544fi
6545AC_SUBST(ASSERT_ALWAYS_ABORT)
6546
6547# Determine whether to use ooenv for the instdir installation
6548# ===================================================================
6549if test $_os != "WINNT" -a $_os != "Darwin"; then
6550    AC_MSG_CHECKING([whether to use ooenv for the instdir installation])
6551    if test -z "$enable_ooenv"; then
6552        if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
6553            enable_ooenv=yes
6554        else
6555            enable_ooenv=no
6556        fi
6557    fi
6558    if test "$enable_ooenv" = "no"; then
6559        AC_MSG_RESULT([no])
6560    else
6561        ENABLE_OOENV="TRUE"
6562        AC_MSG_RESULT([yes])
6563    fi
6564fi
6565AC_SUBST(ENABLE_OOENV)
6566
6567if test "$test_kf5" = "yes" -a "$enable_kf5" = "yes"; then
6568    if test "$enable_qt5" = "no"; then
6569        AC_MSG_ERROR([KF5 support depends on QT5, so it conflicts with --disable-qt5])
6570    else
6571        enable_qt5=yes
6572    fi
6573fi
6574
6575if test "$test_kf6" = "yes" -a "$enable_kf6" = "yes"; then
6576    if test "$enable_qt6" = "no"; then
6577        AC_MSG_ERROR([KF6 support depends on QT6, so it conflicts with --disable-qt6])
6578    else
6579        enable_qt6=yes
6580    fi
6581fi
6582
6583
6584AC_MSG_CHECKING([whether to build the pagein binaries for oosplash])
6585if test "${enable_pagein}" != no -a -z "$DISABLE_DYNLOADING"; then
6586    AC_MSG_RESULT([yes])
6587    ENABLE_PAGEIN=TRUE
6588    AC_DEFINE(HAVE_FEATURE_PAGEIN)
6589else
6590    AC_MSG_RESULT([no])
6591fi
6592AC_SUBST(ENABLE_PAGEIN)
6593
6594
6595AC_MSG_CHECKING([whether to enable CPDB support])
6596ENABLE_CPDB=""
6597CPDB_CFLAGS=""
6598CPDB_LIBS=""
6599if test "$test_cpdb" = yes -a "x$enable_cpdb" = "xyes"; then
6600    ENABLE_CPDB="TRUE"
6601    AC_MSG_RESULT([yes])
6602    PKG_CHECK_MODULES(CPDB, cpdb-frontend)
6603    CPDB_CFLAGS=$(printf '%s' "$CPDB_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
6604    FilterLibs "${CPDB_LIBS}"
6605    CPDB_LIBS="${filteredlibs}"
6606    AC_DEFINE([ENABLE_CPDB],[1])
6607else
6608    AC_MSG_RESULT([no])
6609fi
6610AC_SUBST(ENABLE_CPDB)
6611AC_SUBST(CPDB_LIBS)
6612AC_SUBST(CPDB_CFLAGS)
6613
6614dnl ===================================================================
6615dnl check for cups support
6616dnl ===================================================================
6617
6618AC_MSG_CHECKING([whether to enable CUPS support])
6619if test "$test_cups" = yes -a "$enable_cups" != no; then
6620    ENABLE_CUPS=TRUE
6621    AC_MSG_RESULT([yes])
6622
6623    AC_MSG_CHECKING([whether cups support is present])
6624    AC_CHECK_LIB([cups], [cupsPrintFiles], [:])
6625    AC_CHECK_HEADER(cups/cups.h, AC_DEFINE(HAVE_CUPS_H))
6626    if test "$ac_cv_lib_cups_cupsPrintFiles" != "yes" -o "$ac_cv_header_cups_cups_h" != "yes"; then
6627        AC_MSG_ERROR([Could not find CUPS. Install libcups2-dev or cups-devel.])
6628    fi
6629    AC_DEFINE([ENABLE_CUPS],[1])
6630else
6631    AC_MSG_RESULT([no])
6632fi
6633
6634AC_SUBST(ENABLE_CUPS)
6635
6636libo_CHECK_SYSTEM_MODULE([fontconfig],[FONTCONFIG],[fontconfig >= 2.12.0],,system,TRUE)
6637
6638dnl whether to find & fetch external tarballs?
6639dnl ===================================================================
6640if test -z "$TARFILE_LOCATION" -a -n "$LODE_HOME" ; then
6641   if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
6642       TARFILE_LOCATION="`cygpath -m $LODE_HOME/ext_tar`"
6643   else
6644       TARFILE_LOCATION="$LODE_HOME/ext_tar"
6645   fi
6646fi
6647if test -z "$TARFILE_LOCATION"; then
6648    if test -d "$SRC_ROOT/src" ; then
6649        mv "$SRC_ROOT/src" "$SRC_ROOT/external/tarballs"
6650        ln -s "$SRC_ROOT/external/tarballs" "$SRC_ROOT/src"
6651    fi
6652    TARFILE_LOCATION="$SRC_ROOT/external/tarballs"
6653else
6654    AbsolutePath "$TARFILE_LOCATION"
6655    PathFormat "${absolute_path}"
6656    TARFILE_LOCATION="${formatted_path_unix}"
6657fi
6658PathFormat "$TARFILE_LOCATION"
6659TARFILE_LOCATION_NATIVE="$formatted_path"
6660AC_SUBST(TARFILE_LOCATION)
6661AC_SUBST(TARFILE_LOCATION_NATIVE)
6662
6663AC_MSG_CHECKING([whether we want to fetch tarballs])
6664if test "$enable_fetch_external" != "no"; then
6665    if test "$with_all_tarballs" = "yes"; then
6666        AC_MSG_RESULT([yes, all of them])
6667        DO_FETCH_TARBALLS="ALL"
6668    else
6669        AC_MSG_RESULT([yes, if we use them])
6670        DO_FETCH_TARBALLS="TRUE"
6671    fi
6672else
6673    AC_MSG_RESULT([no])
6674    DO_FETCH_TARBALLS=
6675fi
6676AC_SUBST(DO_FETCH_TARBALLS)
6677
6678dnl Test whether to include MySpell dictionaries
6679dnl ===================================================================
6680AC_MSG_CHECKING([whether to include MySpell dictionaries])
6681if test "$with_myspell_dicts" = "yes"; then
6682    AC_MSG_RESULT([yes])
6683    WITH_MYSPELL_DICTS=TRUE
6684    BUILD_TYPE="$BUILD_TYPE DICTIONARIES"
6685    GIT_NEEDED_SUBMODULES="dictionaries $GIT_NEEDED_SUBMODULES"
6686else
6687    AC_MSG_RESULT([no])
6688    WITH_MYSPELL_DICTS=
6689fi
6690AC_SUBST(WITH_MYSPELL_DICTS)
6691
6692# There are no "system" myspell, hyphen or mythes dictionaries on macOS, Windows, Android or iOS.
6693if test $_os = Darwin -o $_os = WINNT -o $_os = iOS -o $_os = Android; then
6694    if test "$with_system_dicts" = yes; then
6695        AC_MSG_ERROR([There are no system dicts on this OS in the formats the 3rd-party libs we use expect]);
6696    fi
6697    with_system_dicts=no
6698fi
6699
6700AC_MSG_CHECKING([whether to use dicts from external paths])
6701if test -z "$with_system_dicts" -o "$with_system_dicts" != "no"; then
6702    AC_MSG_RESULT([yes])
6703    SYSTEM_DICTS=TRUE
6704    AC_MSG_CHECKING([for spelling dictionary directory])
6705    if test -n "$with_external_dict_dir"; then
6706        DICT_SYSTEM_DIR=file://$with_external_dict_dir
6707    else
6708        DICT_SYSTEM_DIR=file:///usr/share/hunspell
6709        if test ! -d /usr/share/hunspell -a -d /usr/share/myspell; then
6710            DICT_SYSTEM_DIR=file:///usr/share/myspell
6711        fi
6712    fi
6713    AC_MSG_RESULT([$DICT_SYSTEM_DIR])
6714    AC_MSG_CHECKING([for hyphenation patterns directory])
6715    if test -n "$with_external_hyph_dir"; then
6716        HYPH_SYSTEM_DIR=file://$with_external_hyph_dir
6717    else
6718        HYPH_SYSTEM_DIR=file:///usr/share/hyphen
6719    fi
6720    AC_MSG_RESULT([$HYPH_SYSTEM_DIR])
6721    AC_MSG_CHECKING([for thesaurus directory])
6722    if test -n "$with_external_thes_dir"; then
6723        THES_SYSTEM_DIR=file://$with_external_thes_dir
6724    else
6725        THES_SYSTEM_DIR=file:///usr/share/mythes
6726    fi
6727    AC_MSG_RESULT([$THES_SYSTEM_DIR])
6728else
6729    AC_MSG_RESULT([no])
6730    SYSTEM_DICTS=
6731fi
6732AC_SUBST(SYSTEM_DICTS)
6733AC_SUBST(DICT_SYSTEM_DIR)
6734AC_SUBST(HYPH_SYSTEM_DIR)
6735AC_SUBST(THES_SYSTEM_DIR)
6736
6737dnl ===================================================================
6738dnl Precompiled headers.
6739ENABLE_PCH=""
6740AC_MSG_CHECKING([whether to enable pch feature])
6741if test -z "$enable_pch"; then
6742    if test "$_os" = "WINNT"; then
6743        # Enabled by default on Windows.
6744        enable_pch=yes
6745        # never use sccache on auto-enabled PCH builds, except if requested explicitly
6746        if test -z "$enable_ccache" -a "$SCCACHE"; then
6747            CCACHE=""
6748        fi
6749    else
6750        enable_pch=no
6751    fi
6752fi
6753if test "$enable_pch" != no -a "$_os" = Emscripten; then
6754    AC_MSG_ERROR([PCH currently isn't supported for Emscripten with native EH (nEH) because of missing Sj/Lj support with nEH in clang.])
6755fi
6756if test "$enable_pch" != "no" -a "$_os" != "WINNT" -a "$GCC" != "yes" ; then
6757    AC_MSG_ERROR([Precompiled header not yet supported for your platform/compiler])
6758fi
6759if test "$enable_pch" = "system"; then
6760    ENABLE_PCH="1"
6761    AC_MSG_RESULT([yes (system headers)])
6762elif test "$enable_pch" = "base"; then
6763    ENABLE_PCH="2"
6764    AC_MSG_RESULT([yes (system and base headers)])
6765elif test "$enable_pch" = "normal"; then
6766    ENABLE_PCH="3"
6767    AC_MSG_RESULT([yes (normal)])
6768elif test "$enable_pch" = "full"; then
6769    ENABLE_PCH="4"
6770    AC_MSG_RESULT([yes (full)])
6771elif test "$enable_pch" = "yes"; then
6772    # Pick a suitable default.
6773    if test "$GCC" = "yes"; then
6774        # With Clang and GCC higher levels do not seem to make a noticeable improvement,
6775        # while making the PCHs larger and rebuilds more likely.
6776        ENABLE_PCH="2"
6777        AC_MSG_RESULT([yes (system and base headers)])
6778    else
6779        # With MSVC the highest level makes a significant difference,
6780        # and it was the default when there used to be no PCH levels.
6781        ENABLE_PCH="4"
6782        AC_MSG_RESULT([yes (full)])
6783    fi
6784elif test "$enable_pch" = "no"; then
6785    AC_MSG_RESULT([no])
6786else
6787    AC_MSG_ERROR([Unknown value for --enable-pch])
6788fi
6789AC_SUBST(ENABLE_PCH)
6790if test -n "$ENABLE_PCH"; then
6791    AC_DEFINE(ENABLE_PCH)
6792fi
6793# ccache 3.7.1 and older do not properly detect/handle -include .gch in CCACHE_DEPEND mode
6794if test -n "$ENABLE_PCH" -a -n "$CCACHE_DEPEND_MODE" -a "$GCC" = "yes" -a "$COM_IS_CLANG" != "TRUE"; then
6795    AC_PATH_PROG([CCACHE_BIN],[ccache],[not found])
6796    if test "$CCACHE_BIN" != "not found"; then
6797        AC_MSG_CHECKING([ccache version])
6798        CCACHE_VERSION=`"$CCACHE_BIN" -V | "$AWK" '/^ccache version/{print $3}'`
6799        CCACHE_NUMVER=`echo $CCACHE_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
6800        AC_MSG_RESULT([$CCACHE_VERSION])
6801        AC_MSG_CHECKING([whether ccache depend mode works properly with GCC PCH])
6802        if test "$CCACHE_NUMVER" -gt "030701"; then
6803            AC_MSG_RESULT([yes])
6804        else
6805            AC_MSG_RESULT([no (not newer than 3.7.1)])
6806            CCACHE_DEPEND_MODE=
6807        fi
6808    fi
6809fi
6810
6811PCH_INSTANTIATE_TEMPLATES=
6812if test -n "$ENABLE_PCH"; then
6813    AC_MSG_CHECKING([whether $CC supports -fpch-instantiate-templates])
6814    save_CFLAGS=$CFLAGS
6815    CFLAGS="$CFLAGS -Werror -fpch-instantiate-templates"
6816    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ PCH_INSTANTIATE_TEMPLATES="-fpch-instantiate-templates" ],[])
6817    CFLAGS=$save_CFLAGS
6818    if test -n "$PCH_INSTANTIATE_TEMPLATES"; then
6819        AC_MSG_RESULT(yes)
6820    else
6821        AC_MSG_RESULT(no)
6822    fi
6823fi
6824AC_SUBST(PCH_INSTANTIATE_TEMPLATES)
6825
6826BUILDING_PCH_WITH_OBJ=
6827if test -n "$ENABLE_PCH"; then
6828    AC_MSG_CHECKING([whether $CC supports -Xclang -building-pch-with-obj])
6829    save_CFLAGS=$CFLAGS
6830    CFLAGS="$CFLAGS -Werror -Xclang -building-pch-with-obj"
6831    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ BUILDING_PCH_WITH_OBJ="-Xclang -building-pch-with-obj" ],[])
6832    CFLAGS=$save_CFLAGS
6833    if test -n "$BUILDING_PCH_WITH_OBJ"; then
6834        AC_MSG_RESULT(yes)
6835    else
6836        AC_MSG_RESULT(no)
6837    fi
6838fi
6839AC_SUBST(BUILDING_PCH_WITH_OBJ)
6840
6841PCH_CODEGEN=
6842PCH_NO_CODEGEN=
6843fpch_prefix=
6844if test "$COM" = MSC; then
6845    fpch_prefix="-Xclang "
6846fi
6847if test -n "$BUILDING_PCH_WITH_OBJ"; then
6848    AC_MSG_CHECKING([whether $CC supports ${fpch_prefix}-fpch-codegen])
6849    save_CFLAGS=$CFLAGS
6850    CFLAGS="$CFLAGS -Werror ${fpch_prefix}-fpch-codegen"
6851    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],
6852        [ PCH_CODEGEN="${fpch_prefix}-fpch-codegen" ],[])
6853    CFLAGS=$save_CFLAGS
6854    CFLAGS="$CFLAGS -Werror ${fpch_prefix}-fno-pch-codegen"
6855    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],
6856        [ PCH_NO_CODEGEN="${fpch_prefix}-fno-pch-codegen" ],[])
6857    CFLAGS=$save_CFLAGS
6858    if test -n "$PCH_CODEGEN"; then
6859        AC_MSG_RESULT(yes)
6860    else
6861        AC_MSG_RESULT(no)
6862    fi
6863fi
6864AC_SUBST(PCH_CODEGEN)
6865AC_SUBST(PCH_NO_CODEGEN)
6866PCH_DEBUGINFO=
6867if test -n "$BUILDING_PCH_WITH_OBJ"; then
6868    AC_MSG_CHECKING([whether $CC supports ${fpch_prefix}-fpch-debuginfo])
6869    save_CFLAGS=$CFLAGS
6870    CFLAGS="$CFLAGS -Werror ${fpch_prefix}-fpch-debuginfo"
6871    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ PCH_DEBUGINFO="${fpch_prefix}-fpch-debuginfo" ],[])
6872    CFLAGS=$save_CFLAGS
6873    if test -n "$PCH_DEBUGINFO"; then
6874        AC_MSG_RESULT(yes)
6875    else
6876        AC_MSG_RESULT(no)
6877    fi
6878fi
6879AC_SUBST(PCH_DEBUGINFO)
6880
6881TAB=`printf '\t'`
6882
6883AC_MSG_CHECKING([the GNU Make version])
6884_make_version=`$GNUMAKE --version | grep GNU | $GREP -v GPL | $SED -e 's@^[[^0-9]]*@@' -e 's@ .*@@' -e 's@,.*@@'`
6885_make_longver=`echo $_make_version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
6886if test "$_make_longver" -ge "040000"; then
6887    AC_MSG_RESULT([$GNUMAKE $_make_version])
6888else
6889    AC_MSG_ERROR([failed ($GNUMAKE version >= 4.0 needed)])
6890fi
6891
6892_make_ver_check=`$GNUMAKE --version | grep "Built for Windows"`
6893STALE_MAKE=
6894if test "$_make_ver_check" = ""; then
6895   STALE_MAKE=TRUE
6896fi
6897
6898HAVE_LD_HASH_STYLE=FALSE
6899WITH_LINKER_HASH_STYLE=
6900AC_MSG_CHECKING([for --hash-style gcc linker support])
6901if test "$GCC" = "yes"; then
6902    if test -z "$with_linker_hash_style" -o "$with_linker_hash_style" = "yes"; then
6903        hash_styles="gnu sysv"
6904    elif test "$with_linker_hash_style" = "no"; then
6905        hash_styles=
6906    else
6907        hash_styles="$with_linker_hash_style"
6908    fi
6909
6910    for hash_style in $hash_styles; do
6911        test "$HAVE_LD_HASH_STYLE" = "TRUE" && continue
6912        hash_style_ldflags_save=$LDFLAGS
6913        LDFLAGS="$LDFLAGS -Wl,--hash-style=$hash_style"
6914
6915        AC_RUN_IFELSE([AC_LANG_PROGRAM(
6916            [
6917#include <stdio.h>
6918            ],[
6919printf ("");
6920            ])],
6921            [
6922                  HAVE_LD_HASH_STYLE=TRUE
6923                  WITH_LINKER_HASH_STYLE=$hash_style
6924            ],
6925            [HAVE_LD_HASH_STYLE=FALSE],
6926            [HAVE_LD_HASH_STYLE=FALSE])
6927        LDFLAGS=$hash_style_ldflags_save
6928    done
6929
6930    if test "$HAVE_LD_HASH_STYLE" = "TRUE"; then
6931        AC_MSG_RESULT( $WITH_LINKER_HASH_STYLE )
6932    else
6933        AC_MSG_RESULT( no )
6934    fi
6935    LDFLAGS=$hash_style_ldflags_save
6936else
6937    AC_MSG_RESULT( no )
6938fi
6939AC_SUBST(HAVE_LD_HASH_STYLE)
6940AC_SUBST(WITH_LINKER_HASH_STYLE)
6941
6942dnl ===================================================================
6943dnl Check whether there's a Perl version available.
6944dnl ===================================================================
6945if test -z "$with_perl_home"; then
6946    AC_PATH_PROG(PERL, perl)
6947else
6948    test "$build_os" = "cygwin" && with_perl_home=`cygpath -u "$with_perl_home"`
6949    _perl_path="$with_perl_home/bin/perl"
6950    if test -x "$_perl_path"; then
6951        PERL=$_perl_path
6952    else
6953        AC_MSG_ERROR([$_perl_path not found])
6954    fi
6955fi
6956
6957dnl ===================================================================
6958dnl Testing for Perl version 5 or greater.
6959dnl $] is the Perl version variable, it is returned as an integer
6960dnl ===================================================================
6961if test "$PERL"; then
6962    AC_MSG_CHECKING([the Perl version])
6963    ${PERL} -e "exit($]);"
6964    _perl_version=$?
6965    if test "$_perl_version" -lt 5; then
6966        AC_MSG_ERROR([found Perl $_perl_version, use Perl 5])
6967    fi
6968    AC_MSG_RESULT([Perl $_perl_version])
6969else
6970    AC_MSG_ERROR([Perl not found, install Perl 5])
6971fi
6972
6973dnl ===================================================================
6974dnl Testing for required Perl modules
6975dnl ===================================================================
6976
6977AC_MSG_CHECKING([for required Perl modules])
6978dnl Digest::MD5 seems only be used for packaging, but is basically a given
6979perl_use_string="use Cwd ; use Digest::MD5"
6980perl_use_string_spp="use Cwd ; use Digest::MD5"
6981if test "$_os" = "WINNT"; then
6982    if test -n "$PKGFORMAT"; then
6983        for i in $PKGFORMAT; do
6984            case "$i" in
6985            msi)
6986                # for getting fonts versions to use in MSI
6987                if test -n "$WSL_ONLY_AS_HELPER"; then
6988                    # in case of a wsl-as-helper build, the packaging is done using strawberry-perl
6989                    # and not the perl provided by git-bash
6990                    perl_use_string_spp="$perl_use_string_spp ; use Font::TTF::Font"
6991                else
6992                    perl_use_string="$perl_use_string ; use Font::TTF::Font"
6993                fi
6994                ;;
6995            esac
6996        done
6997    fi
6998fi
6999if test "$with_system_hsqldb" = "yes"; then
7000    perl_use_string="$perl_use_string ; use Archive::Zip"
7001fi
7002if test "$enable_openssl" = "yes" -a "$with_system_openssl" != "yes"; then
7003    # OpenSSL needs that to build
7004    if test -n "$WSL_ONLY_AS_HELPER"; then
7005        # OpenSSL is built via spp, FindBin is provided by default, but deps might change in future
7006        perl_use_string_spp="$perl_use_string_spp ; use FindBin"
7007    else
7008        perl_use_string="$perl_use_string ; use FindBin"
7009    fi
7010fi
7011dnl in WSL_ONLY_AS_HELPER case the test should be done with git-bash-provided-perl and not perl from
7012dnl the wsl container, but that can wait until we require a module that's not provided by default
7013if $PERL -e "$perl_use_string">/dev/null 2>&1; then
7014    AC_MSG_RESULT([all modules found])
7015    if test -n "$WSL_ONLY_AS_HELPER"; then
7016        AC_MSG_CHECKING([for required Perl modules in Strawberry Perl])
7017        if $STRAWBERRY_PERL_UNIX -e "$perl_use_string_spp">/dev/null 2>&1; then
7018            AC_MSG_RESULT([all modules found])
7019        else
7020            AC_MSG_RESULT([failed to find some modules])
7021            # Find out which modules are missing.
7022            for i in $perl_use_string_spp; do
7023                if test "$i" != "use" -a "$i" != ";"; then
7024                    if ! $STRAWBERRY_PERL_UNIX -e "use $i;">/dev/null 2>&1; then
7025                        missing_perl_modules="$missing_perl_modules $i"
7026                    fi
7027                fi
7028            done
7029            PathFormat "$(dirname $STRAWBERRY_PERL_UNIX)"
7030            spp_cpan_command='PATH="$(cygpath.exe -up "'$STRAWBERRY_TOOLS';'$formatted_path'"):$PATH" cpanm'
7031            AC_MSG_ERROR([
7032            The missing Perl modules are: $missing_perl_modules
7033            Install them with »$spp_cpan_command $missing_perl_modules«])
7034        fi
7035    fi
7036else
7037    AC_MSG_RESULT([failed to find some modules])
7038    # Find out which modules are missing.
7039    for i in $perl_use_string; do
7040        if test "$i" != "use" -a "$i" != ";"; then
7041            if ! $PERL -e "use $i;">/dev/null 2>&1; then
7042                missing_perl_modules="$missing_perl_modules $i"
7043            fi
7044        fi
7045    done
7046    AC_MSG_ERROR([
7047    The missing Perl modules are: $missing_perl_modules
7048    Install them as superuser/administrator with "cpan -i $missing_perl_modules"])
7049fi
7050
7051dnl ===================================================================
7052dnl Check for pkg-config
7053dnl ===================================================================
7054# pkgconf/pkg-config detection is already triggered by the configure switches way above
7055# (more specifically PKG_CHECK_MODULES), so only do some cleanup of the vars here
7056PathFormat "$(command -v $PKG_CONFIG)"
7057PKG_CONFIG="$formatted_path"
7058AC_SUBST(PKG_CONFIG)
7059AC_SUBST(PKG_CONFIG_PATH)
7060AC_SUBST(PKG_CONFIG_LIBDIR)
7061
7062if test "$_os" != "WINNT"; then
7063
7064    # If you use CC=/path/to/compiler/foo-gcc or even CC="ccache
7065    # /path/to/compiler/foo-gcc" you need to set the AR etc env vars
7066    # explicitly. Or put /path/to/compiler in PATH yourself.
7067
7068    toolprefix=gcc
7069    if test "$COM_IS_CLANG" = "TRUE"; then
7070        toolprefix=llvm
7071    fi
7072    AC_CHECK_TOOLS(AR,$toolprefix-ar ar)
7073    AC_CHECK_TOOLS(NM,$toolprefix-nm nm)
7074    AC_CHECK_TOOLS(RANLIB,$toolprefix-ranlib ranlib)
7075    AC_CHECK_TOOLS(OBJDUMP,$toolprefix-objdump objdump)
7076    AC_CHECK_TOOLS(READELF,$toolprefix-readelf readelf)
7077    AC_CHECK_TOOLS(STRIP,$toolprefix-strip strip)
7078fi
7079AC_SUBST(AR)
7080AC_SUBST(NM)
7081AC_SUBST(OBJDUMP)
7082AC_SUBST(RANLIB)
7083AC_SUBST(READELF)
7084AC_SUBST(STRIP)
7085
7086dnl ===================================================================
7087dnl pkg-config checks on macOS
7088dnl ===================================================================
7089
7090if test $_os = Darwin; then
7091    AC_MSG_CHECKING([for bogus pkg-config])
7092    if test -n "$PKG_CONFIG"; then
7093        if test "$PKG_CONFIG" = /usr/bin/pkg-config && ls -l /usr/bin/pkg-config | $GREP -q Mono.framework; then
7094            AC_MSG_ERROR([yes, from Mono. This *will* break the build. Please remove or hide $PKG_CONFIG])
7095        else
7096            if test "$enable_bogus_pkg_config" = "yes"; then
7097                AC_MSG_RESULT([yes, user-approved from unknown origin.])
7098            else
7099                if test -z "$($PKG_CONFIG --list-all |grep -v '^libpkgconf')" ; then
7100                    AC_MSG_RESULT([yes, accepted since no packages available in default searchpath])
7101                else
7102                    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.])
7103                fi
7104            fi
7105        fi
7106    else
7107        AC_MSG_RESULT([no, good])
7108    fi
7109fi
7110
7111find_csc()
7112{
7113    # Return value: $csctest
7114
7115    unset csctest
7116
7117    reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/NET Framework Setup/NDP/v4/Client" "InstallPath"
7118    if test -n "$regvalue"; then
7119        csctest=$regvalue
7120        return
7121    fi
7122}
7123
7124find_al()
7125{
7126    # Return value: $altest
7127
7128    unset altest
7129
7130    # We need this check to detect 4.6.1 or above.
7131    for ver in 4.8.1 4.8 4.7.2 4.7.1 4.7 4.6.2 4.6.1; do
7132        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/NETFXSDK/$ver/WinSDK-NetFx40Tools" "InstallationFolder"
7133        PathFormat "$regvalue"
7134        if test -n "$regvalue" -a \( -f "$formatted_path_unix/al.exe" -o -f "$formatted_path_unix/bin/al.exe" \); then
7135            altest=$regvalue
7136            return
7137        fi
7138    done
7139
7140    reg_list_values_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows"
7141    for x in $reglist; do
7142        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/$x/WinSDK-NetFx40Tools" "InstallationFolder"
7143        PathFormat "$regvalue"
7144        if test -n "$regvalue" -a \( -f "$formatted_path_unix/al.exe" -o -f "$formatted_path_unix/bin/al.exe" \); then
7145            altest=$regvalue
7146            return
7147        fi
7148    done
7149}
7150
7151find_dotnetsdk()
7152{
7153    unset frametest
7154
7155    for ver in 4.8.1 4.8 4.7.2 4.7.1 4.7 4.6.2 4.6.1 4.6; do
7156        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/NETFXSDK/$ver" "KitsInstallationFolder"
7157        if test -n "$regvalue"; then
7158            frametest=$regvalue
7159            return
7160        fi
7161    done
7162    AC_MSG_ERROR([The Windows NET SDK (minimum 4.6) not found, check the installation])
7163}
7164
7165find_winsdk_version()
7166{
7167    # Args: $1 : SDK version as in "8.0", "8.1A" etc
7168    # Return values: $winsdktest, $winsdkbinsubdir, $winsdklibsubdir
7169
7170    unset winsdktest winsdkbinsubdir winsdklibsubdir
7171
7172    case "$1" in
7173    8.0|8.0A)
7174        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows Kits/Installed Roots" "KitsRoot"
7175        if test -n "$regvalue"; then
7176            winsdktest=$regvalue
7177            winsdklibsubdir=win8
7178            return
7179        fi
7180        ;;
7181    8.1|8.1A)
7182        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows Kits/Installed Roots" "KitsRoot81"
7183        if test -n "$regvalue"; then
7184            winsdktest=$regvalue
7185            winsdklibsubdir=winv6.3
7186            return
7187        fi
7188        ;;
7189    10.0)
7190        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v${1}" "InstallationFolder"
7191        if test -n "$regvalue"; then
7192            winsdktest=$regvalue
7193            reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v${1}" "ProductVersion"
7194            if test -n "$regvalue"; then
7195                winsdkbinsubdir="$regvalue".0
7196                winsdklibsubdir=$winsdkbinsubdir
7197                local tmppath="$winsdktest\\Include\\$winsdklibsubdir"
7198                PathFormat "$tmppath"
7199                local tmppath_unix=$formatted_path_unix
7200                # test exist the SDK path
7201                if test ! -d "$tmppath_unix"; then
7202                   AC_MSG_ERROR([The Windows SDK not found, check the installation])
7203                fi
7204            fi
7205            return
7206        fi
7207        ;;
7208    esac
7209}
7210
7211find_winsdk()
7212{
7213    # Return value: From find_winsdk_version
7214
7215    unset winsdktest
7216
7217    for ver in $WINDOWS_SDK_ACCEPTABLE_VERSIONS; do
7218        find_winsdk_version $ver
7219        if test -n "$winsdktest"; then
7220            return
7221        fi
7222    done
7223}
7224
7225find_msms()
7226{
7227    # Return value: $msmdir
7228    local version="$1"
7229
7230    AC_MSG_CHECKING([for MSVC $version merge modules directory])
7231    local my_msm_dir="$VC_PRODUCT_DIR/redist/MSVC/v${version}/MergeModules"
7232    local my_msm_file="$my_msm_dir/Microsoft_VC${version}_CRT_x86.msm"
7233    echo "$as_me:$LINENO: looking for ${my_msm_file}" >&5
7234    if test -e "${my_msm_file}"; then
7235        PathFormat "$my_msm_dir/"
7236        msmdir="$formatted_path"
7237        AC_MSG_RESULT([$msmdir])
7238    else
7239        if test "$ENABLE_RELEASE_BUILD" = "TRUE" ; then
7240            AC_MSG_FAILURE([not found])
7241        else
7242            AC_MSG_WARN([not found (check config.log)])
7243            add_warning "MSM ${my_msm_file} not found"
7244        fi
7245    fi
7246}
7247
7248dnl =========================================
7249dnl Check for the Windows  SDK.
7250dnl =========================================
7251if test "$_os" = "WINNT"; then
7252    AC_MSG_CHECKING([for Windows SDK])
7253    if test "$build_os" = "cygwin" -o "$build_os" = "wsl" -o -n "$WSL_ONLY_AS_HELPER"; then
7254        find_winsdk
7255        WINDOWS_SDK_HOME=$winsdktest
7256
7257        # normalize if found
7258        if test -n "$WINDOWS_SDK_HOME"; then
7259            PathFormat "$WINDOWS_SDK_HOME"
7260            WINDOWS_SDK_HOME=$formatted_path_unix
7261        fi
7262
7263        WINDOWS_SDK_LIB_SUBDIR=$winsdklibsubdir
7264        # The variable also contains the Windows SDK version
7265        echo $WINDOWS_SDK_LIB_SUBDIR
7266        # Assuming maximum of 5 digits for each part and ignoring last part
7267        SDK_NORMALIZED_VER=$(echo $WINDOWS_SDK_LIB_SUBDIR | awk -F. '{printf("%d%05d%05d\n", $1, $2, $3)}')
7268        if test "$SDK_NORMALIZED_VER" -lt 100000022000; then
7269            if test "$WIN_HOST_ARCH" = "arm64" -a \( "$enable_skia" != "no" -o "$enable_pdfium" != "no" \) ; then
7270                AC_MSG_ERROR([You need Windows SDK 10.0.22000 or later to build for Windows arm64 with skia or pdfium. Install a newer version of the SDK or disable skia and pdfium])
7271            fi
7272            # 10.0.20348.0 is the minimum required version,
7273            # but it makes sense to align with arm64 baseline.
7274            # Give people a heads-up to update their systems before enforcing it
7275            if test "$SDK_NORMALIZED_VER" -lt 100000020348; then
7276                AC_MSG_ERROR([You need Windows SDK greater than or equal 10.0.20348.0])
7277            else
7278                add_warning "build requirements might be bumped to Windows SDK >= 10.0.22000 soon"
7279            fi
7280        fi
7281    fi
7282
7283    if test -n "$WINDOWS_SDK_HOME"; then
7284        # Remove a possible trailing backslash
7285        WINDOWS_SDK_HOME=`echo $WINDOWS_SDK_HOME | $SED 's/\/$//'`
7286
7287        if test -f "$WINDOWS_SDK_HOME/Include/adoint.h" \
7288             -a -f "$WINDOWS_SDK_HOME/Include/SqlUcode.h" \
7289             -a -f "$WINDOWS_SDK_HOME/Include/usp10.h"; then
7290            have_windows_sdk_headers=yes
7291        elif test -f "$WINDOWS_SDK_HOME/Include/um/adoint.h" \
7292             -a -f "$WINDOWS_SDK_HOME/Include/um/SqlUcode.h" \
7293             -a -f "$WINDOWS_SDK_HOME/Include/um/usp10.h"; then
7294            have_windows_sdk_headers=yes
7295        elif test -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/adoint.h" \
7296             -a -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/SqlUcode.h" \
7297             -a -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/usp10.h"; then
7298            have_windows_sdk_headers=yes
7299        else
7300            have_windows_sdk_headers=no
7301        fi
7302
7303        if test -f "$WINDOWS_SDK_HOME/lib/user32.lib"; then
7304            have_windows_sdk_libs=yes
7305        elif test -f "$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/$WIN_BUILD_ARCH/user32.lib"; then
7306            have_windows_sdk_libs=yes
7307        else
7308            have_windows_sdk_libs=no
7309        fi
7310
7311        if test $have_windows_sdk_headers = no -o $have_windows_sdk_libs = no; then
7312            AC_MSG_ERROR([Some (all?) Windows SDK files not found, please check if all needed parts of
7313the  Windows SDK are installed.])
7314        fi
7315    fi
7316
7317    if test -z "$WINDOWS_SDK_HOME"; then
7318        AC_MSG_RESULT([no, hoping the necessary headers and libraries will be found anyway!?])
7319    elif echo $WINDOWS_SDK_HOME | grep "8.0" >/dev/null 2>/dev/null; then
7320        WINDOWS_SDK_VERSION=80
7321        AC_MSG_RESULT([found Windows SDK 8.0 ($WINDOWS_SDK_HOME)])
7322    elif echo $WINDOWS_SDK_HOME | grep "8.1" >/dev/null 2>/dev/null; then
7323        WINDOWS_SDK_VERSION=81
7324        AC_MSG_RESULT([found Windows SDK 8.1 ($WINDOWS_SDK_HOME)])
7325    elif echo $WINDOWS_SDK_HOME | grep "/10" >/dev/null 2>/dev/null; then
7326        WINDOWS_SDK_VERSION=10
7327        AC_MSG_RESULT([found Windows SDK 10.0 ($WINDOWS_SDK_HOME)])
7328    else
7329        AC_MSG_ERROR([Found legacy Windows Platform SDK ($WINDOWS_SDK_HOME)])
7330    fi
7331    PathFormat "$WINDOWS_SDK_HOME"
7332    WINDOWS_SDK_HOME="$formatted_path"
7333    WINDOWS_SDK_HOME_unix="$formatted_path_unix"
7334    if test "$build_os" = "cygwin" -o "$build_os" = "wsl" -o -n "$WSL_ONLY_AS_HELPER"; then
7335        SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/include -I$COMPATH/Include"
7336        if test -d "$WINDOWS_SDK_HOME_unix/include/um"; then
7337            SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/include/um -I$WINDOWS_SDK_HOME/include/shared"
7338        elif test -d "$WINDOWS_SDK_HOME_unix/Include/$winsdklibsubdir/um"; then
7339            SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um -I$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/shared"
7340        fi
7341    fi
7342
7343    dnl TODO: solenv/bin/modules/installer/windows/msiglobal.pm wants to use a
7344    dnl WiLangId.vbs that is included only in some SDKs (e.g., included in v7.1
7345    dnl but not in v8.0), so allow this to be overridden with a
7346    dnl WINDOWS_SDK_WILANGID for now; a full-blown --with-windows-sdk-wilangid
7347    dnl and configuration error if no WiLangId.vbs is found would arguably be
7348    dnl better, but I do not know under which conditions exactly it is needed by
7349    dnl msiglobal.pm:
7350    if test -z "$WINDOWS_SDK_WILANGID" -a -n "$WINDOWS_SDK_HOME"; then
7351        WINDOWS_SDK_WILANGID_unix=$WINDOWS_SDK_HOME_unix/Samples/sysmgmt/msi/scripts/WiLangId.vbs
7352        if ! test -e "$WINDOWS_SDK_WILANGID_unix" ; then
7353            WINDOWS_SDK_WILANGID_unix="${WINDOWS_SDK_HOME_unix}/bin/${WINDOWS_SDK_LIB_SUBDIR}/${WIN_BUILD_ARCH}/WiLangId.vbs"
7354        fi
7355        if ! test -e "$WINDOWS_SDK_WILANGID_unix" ; then
7356            WINDOWS_SDK_WILANGID_unix=$WINDOWS_SDK_HOME_unix/bin/$WIN_BUILD_ARCH/WiLangId.vbs
7357        fi
7358        if ! test -e "$WINDOWS_SDK_WILANGID_unix" ; then
7359            WINDOWS_SDK_WILANGID_unix="C:/Program Files (x86)/Windows Kits/8.1/bin/$WIN_BUILD_ARCH/WiLangId.vbs"
7360        fi
7361        PathFormat "$WINDOWS_SDK_WILANGID_unix"
7362        WINDOWS_SDK_WILANGID="$formatted_path"
7363    fi
7364    if test -n "$with_lang" -a "$with_lang" != "en-US"; then
7365        if test -n "$with_package_format" -a "$with_package_format" != no; then
7366            for i in "$with_package_format"; do
7367                if test "$i" = "msi"; then
7368                    if ! test -e "$WINDOWS_SDK_WILANGID_unix" ; then
7369                        AC_MSG_ERROR([WiLangId.vbs not found - building translated packages will fail])
7370                    fi
7371                fi
7372            done
7373        fi
7374    fi
7375fi
7376AC_SUBST(WINDOWS_SDK_HOME)
7377AC_SUBST(WINDOWS_SDK_LIB_SUBDIR)
7378AC_SUBST(WINDOWS_SDK_VERSION)
7379AC_SUBST(WINDOWS_SDK_WILANGID)
7380
7381if test "$build_os" = "cygwin" -o "$build_os" = "wsl" -o -n "$WSL_ONLY_AS_HELPER"; then
7382    dnl Check midl.exe; this being the first check for a tool in the SDK bin
7383    dnl dir, it also determines that dir's path w/o an arch segment if any,
7384    dnl WINDOWS_SDK_BINDIR_NO_ARCH:
7385    AC_MSG_CHECKING([for midl.exe])
7386
7387    find_winsdk
7388    PathFormat "$winsdktest"
7389    winsdktest_unix="$formatted_path_unix"
7390
7391    if test -n "$winsdkbinsubdir" \
7392        -a -f "$winsdktest_unix/Bin/$winsdkbinsubdir/$WIN_BUILD_ARCH/midl.exe"
7393    then
7394        MIDL_PATH=$winsdktest_unix/Bin/$winsdkbinsubdir/$WIN_BUILD_ARCH
7395        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME_unix/Bin/$winsdkbinsubdir
7396    elif test -f "$winsdktest_unix/Bin/$WIN_BUILD_ARCH/midl.exe"; then
7397        MIDL_PATH=$winsdktest_unix/Bin/$WIN_BUILD_ARCH
7398        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME_unix/Bin
7399    elif test -f "$winsdktest_unix/Bin/midl.exe"; then
7400        MIDL_PATH=$winsdktest_unix/Bin
7401        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME_unix/Bin
7402    fi
7403    PathFormat "$MIDL_PATH"
7404    if test ! -f "$formatted_path_unix/midl.exe"; then
7405        AC_MSG_ERROR([midl.exe not found in $winsdktest/Bin/$WIN_BUILD_ARCH, Windows SDK installation broken?])
7406    else
7407        AC_MSG_RESULT([$MIDL_PATH/midl.exe])
7408    fi
7409
7410    # Convert to posix path with 8.3 filename restrictions ( No spaces )
7411    MIDL_PATH=`win_short_path_for_make "$MIDL_PATH"`
7412
7413    if test -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msiinfo.exe" \
7414         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msidb.exe" \
7415         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/uuidgen.exe" \
7416         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msitran.exe"; then :
7417    elif test -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msiinfo.exe" \
7418         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msidb.exe" \
7419         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/uuidgen.exe" \
7420         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msitran.exe"; then :
7421    elif test -f "$WINDOWS_SDK_HOME/bin/x86/msiinfo.exe" \
7422         -a -f "$WINDOWS_SDK_HOME/bin/x86/msidb.exe" \
7423         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/uuidgen.exe" \
7424         -a -f "$WINDOWS_SDK_HOME/bin/x86/msitran.exe"; then :
7425    else
7426        AC_MSG_ERROR([Some (all?) Windows Installer tools in the Windows SDK are missing, please install.])
7427    fi
7428
7429    PathFormat "$MIDL_PATH"
7430    MIDL_PATH="$formatted_path"
7431
7432    if test "$enable_cli" = yes; then
7433        dnl Check csc.exe
7434        AC_MSG_CHECKING([for csc.exe])
7435        find_csc
7436        PathFormat "$csctest"
7437        csctest_unix="$formatted_path_unix"
7438        if test -f "$csctest_unix/csc.exe"; then
7439            CSC_PATH="$csctest"
7440        fi
7441        if test ! -f "$csctest_unix/csc.exe"; then
7442            AC_MSG_ERROR([csc.exe not found as $CSC_PATH/csc.exe])
7443        else
7444            AC_MSG_RESULT([$CSC_PATH/csc.exe])
7445        fi
7446
7447        CSC_PATH=`win_short_path_for_make "$CSC_PATH"`
7448
7449        dnl Check al.exe
7450        AC_MSG_CHECKING([for al.exe])
7451        if test -n "$winsdkbinsubdir" \
7452            -a -f "$winsdktest_unix/Bin/$winsdkbinsubdir/$WIN_BUILD_ARCH/al.exe"
7453        then
7454            AL_PATH="$winsdktest/Bin/$winsdkbinsubdir/$WIN_BUILD_ARCH"
7455        elif test -f "$winsdktest_unix/Bin/$WIN_BUILD_ARCH/al.exe"; then
7456            AL_PATH="$winsdktest/Bin/$WIN_BUILD_ARCH"
7457        elif test -f "$winsdktest_unix/Bin/al.exe"; then
7458            AL_PATH="$winsdktest/Bin"
7459        fi
7460
7461        if test -z "$AL_PATH"; then
7462            find_al
7463            PathFormat "$altest"
7464            altest_unix="$formatted_path_unix"
7465            if test -f "$altest_unix/bin/al.exe"; then
7466                AL_PATH="$altest/bin"
7467            elif test -f "$altest_unix/al.exe"; then
7468                AL_PATH="$altest"
7469            fi
7470        fi
7471        PathFormat "$AL_PATH"
7472        if test ! -f "$formatted_path_unix/al.exe"; then
7473            AC_MSG_ERROR([al.exe not found as $AL_PATH/al.exe])
7474        else
7475            AC_MSG_RESULT([$AL_PATH/al.exe])
7476        fi
7477
7478        AL_PATH=`win_short_path_for_make "$AL_PATH"`
7479
7480        dnl Check mscoree.lib / .NET Framework dir
7481        AC_MSG_CHECKING(.NET Framework)
7482        find_dotnetsdk
7483        PathFormat "$frametest"
7484        frametest="$formatted_path_unix"
7485        if test -f "$frametest/Lib/um/$WIN_BUILD_ARCH/mscoree.lib"; then
7486            DOTNET_FRAMEWORK_HOME="$frametest"
7487        else
7488            if test -f "$winsdktest_unix/lib/mscoree.lib" -o -f "$winsdktest_unix/lib/$winsdklibsubdir/um/$WIN_BUILD_ARCH/mscoree.lib"; then
7489                DOTNET_FRAMEWORK_HOME="$winsdktest"
7490            fi
7491        fi
7492        PathFormat "$DOTNET_FRAMEWORK_HOME"
7493        if test ! -f "$formatted_path_unix/lib/mscoree.lib" -a ! -f "$formatted_path_unix/lib/$winsdklibsubdir/um/$WIN_BUILD_ARCH/mscoree.lib" -a ! -f "$formatted_path_unix/Lib/um/$WIN_BUILD_ARCH/mscoree.lib"; then
7494            AC_MSG_ERROR([mscoree.lib not found])
7495        fi
7496        AC_MSG_RESULT([found: $DOTNET_FRAMEWORK_HOME])
7497
7498        PathFormat "$AL_PATH"
7499        AL_PATH="$formatted_path"
7500
7501        PathFormat "$DOTNET_FRAMEWORK_HOME"
7502        DOTNET_FRAMEWORK_HOME="$formatted_path"
7503
7504        PathFormat "$CSC_PATH"
7505        CSC_PATH="$formatted_path"
7506
7507        ENABLE_CLI="TRUE"
7508    else
7509        ENABLE_CLI=""
7510    fi
7511else
7512    ENABLE_CLI=""
7513fi
7514AC_SUBST(ENABLE_CLI)
7515
7516dnl ===================================================================
7517dnl Testing for C++ compiler and version...
7518dnl ===================================================================
7519
7520if test "$_os" != "WINNT"; then
7521    # AC_PROG_CXX sets CXXFLAGS to -g -O2 if not set, avoid that (and avoid -O2 during AC_PROG_CXX,
7522    # see AC_PROG_CC above):
7523    save_CXXFLAGS=$CXXFLAGS
7524    CXXFLAGS=-g
7525    AC_PROG_CXX
7526    CXXFLAGS=$save_CXXFLAGS
7527    if test -z "$CXX_BASE"; then
7528        CXX_BASE=`first_arg_basename "$CXX"`
7529    fi
7530fi
7531
7532CC="$CC $with_extra_cc_flags"
7533CXX="$CXX $with_extra_cxx_flags"
7534
7535dnl check for GNU C++ compiler version
7536if test "$GXX" = "yes" -a -z "$COM_IS_CLANG"; then
7537    AC_MSG_CHECKING([the GNU C++ compiler version])
7538
7539    _gpp_version=`$CXX -dumpversion`
7540    _gpp_majmin=`echo $_gpp_version | $AWK -F. '{ print \$1*100+\$2 }'`
7541
7542    if test "$_gpp_majmin" -lt "1200"; then
7543        AC_MSG_ERROR([You need to use GNU C++ compiler version >= 12.0 to build LibreOffice, you have $_gpp_version.])
7544    else
7545        AC_MSG_RESULT([ok (g++ $_gpp_version)])
7546    fi
7547
7548    dnl see https://issuetracker.google.com/issues/36962819
7549        glibcxx_threads=no
7550        AC_LANG_PUSH([C++])
7551        AC_REQUIRE_CPP
7552        AC_MSG_CHECKING([whether $CXX_BASE is broken with boost.thread])
7553        AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
7554            #include <bits/c++config.h>]],[[
7555            #if !defined(_GLIBCXX_HAVE_GTHR_DEFAULT) \
7556            && !defined(_GLIBCXX__PTHREADS) \
7557            && !defined(_GLIBCXX_HAS_GTHREADS)
7558            choke me
7559            #endif
7560        ]])],[AC_MSG_RESULT([yes])
7561        glibcxx_threads=yes],[AC_MSG_RESULT([no])])
7562        AC_LANG_POP([C++])
7563        if test $glibcxx_threads = yes; then
7564            BOOST_CXXFLAGS="-D_GLIBCXX_HAS_GTHREADS"
7565        fi
7566fi
7567AC_SUBST(BOOST_CXXFLAGS)
7568
7569#
7570# prefix CXX with ccache if needed
7571#
7572if test "$CCACHE" != ""; then
7573    AC_MSG_CHECKING([whether $CXX_BASE is already ccached])
7574    AC_LANG_PUSH([C++])
7575    save_CXXFLAGS=$CXXFLAGS
7576    CXXFLAGS="$CXXFLAGS --ccache-skip -O2"
7577    # msvc does not fail on unknown options, check stdout
7578    if test "$COM" = MSC; then
7579        CXXFLAGS="$CXXFLAGS -nologo"
7580    fi
7581    save_ac_cxx_werror_flag=$ac_cxx_werror_flag
7582    ac_cxx_werror_flag=yes
7583    dnl an empty program will do, we're checking the compiler flags
7584    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
7585                      [use_ccache=yes], [use_ccache=no])
7586    if test $use_ccache = yes -a "${CCACHE##*sccache*}" != ""; then
7587        AC_MSG_RESULT([yes])
7588    else
7589        CXX="$CCACHE $CXX"
7590        CXX_BASE="ccache $CXX_BASE"
7591        AC_MSG_RESULT([no])
7592    fi
7593    CXXFLAGS=$save_CXXFLAGS
7594    ac_cxx_werror_flag=$save_ac_cxx_werror_flag
7595    AC_LANG_POP([C++])
7596fi
7597
7598dnl ===================================================================
7599dnl Find pre-processors.(should do that _after_ messing with CC/CXX)
7600dnl ===================================================================
7601
7602if test "$_os" != "WINNT"; then
7603    AC_PROG_CXXCPP
7604
7605    dnl Check whether there's a C pre-processor.
7606    AC_PROG_CPP
7607fi
7608
7609
7610dnl ===================================================================
7611dnl Find integral type sizes and alignments
7612dnl ===================================================================
7613
7614if test "$_os" != "WINNT"; then
7615
7616    AC_CHECK_SIZEOF(long)
7617    AC_CHECK_SIZEOF(short)
7618    AC_CHECK_SIZEOF(int)
7619    AC_CHECK_SIZEOF(long long)
7620    AC_CHECK_SIZEOF(double)
7621    AC_CHECK_SIZEOF(void*)
7622    AC_CHECK_SIZEOF(size_t)
7623
7624    SAL_TYPES_SIZEOFSHORT=$ac_cv_sizeof_short
7625    SAL_TYPES_SIZEOFINT=$ac_cv_sizeof_int
7626    SAL_TYPES_SIZEOFLONG=$ac_cv_sizeof_long
7627    SAL_TYPES_SIZEOFLONGLONG=$ac_cv_sizeof_long_long
7628    SAL_TYPES_SIZEOFPOINTER=$ac_cv_sizeof_voidp
7629    SIZEOF_SIZE_T=$ac_cv_sizeof_size_t
7630
7631    dnl Allow build without AC_CHECK_ALIGNOF, grrr
7632    m4_pattern_allow([AC_CHECK_ALIGNOF])
7633    m4_ifdef([AC_CHECK_ALIGNOF],
7634        [
7635            AC_CHECK_ALIGNOF(short,[#include <stddef.h>])
7636            AC_CHECK_ALIGNOF(int,[#include <stddef.h>])
7637            AC_CHECK_ALIGNOF(long,[#include <stddef.h>])
7638            AC_CHECK_ALIGNOF(double,[#include <stddef.h>])
7639        ],
7640        [
7641            case "$_os-$host_cpu" in
7642            Linux-i686)
7643                test -z "$ac_cv_alignof_short" && ac_cv_alignof_short=2
7644                test -z "$ac_cv_alignof_int" && ac_cv_alignof_int=4
7645                test -z "$ac_cv_alignof_long" && ac_cv_alignof_long=4
7646                test -z "$ac_cv_alignof_double" && ac_cv_alignof_double=4
7647                ;;
7648            Linux-x86_64)
7649                test -z "$ac_cv_alignof_short" && ac_cv_alignof_short=2
7650                test -z "$ac_cv_alignof_int" && ac_cv_alignof_int=4
7651                test -z "$ac_cv_alignof_long" && ac_cv_alignof_long=8
7652                test -z "$ac_cv_alignof_double" && ac_cv_alignof_double=8
7653                ;;
7654            *)
7655                if test -z "$ac_cv_alignof_short" -o \
7656                        -z "$ac_cv_alignof_int" -o \
7657                        -z "$ac_cv_alignof_long" -o \
7658                        -z "$ac_cv_alignof_double"; then
7659                   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.])
7660                fi
7661                ;;
7662            esac
7663        ])
7664
7665    SAL_TYPES_ALIGNMENT2=$ac_cv_alignof_short
7666    SAL_TYPES_ALIGNMENT4=$ac_cv_alignof_int
7667    if test $ac_cv_sizeof_long -eq 8; then
7668        SAL_TYPES_ALIGNMENT8=$ac_cv_alignof_long
7669    elif test $ac_cv_sizeof_double -eq 8; then
7670        SAL_TYPES_ALIGNMENT8=$ac_cv_alignof_double
7671    else
7672        AC_MSG_ERROR([Cannot find alignment of 8 byte types.])
7673    fi
7674
7675    dnl Check for large file support
7676    AC_SYS_LARGEFILE
7677    if test -n "$ac_cv_sys_largefile_opts"  -a "$ac_cv_sys_largefile_opts" != "none needed" -a "$ac_cv_sys_largefile_opts" != "support not detected"; then
7678        LFS_CFLAGS="$ac_cv_sys_largefile_opts"
7679    elif test -n "$ac_cv_sys_file_offset_bits" -a "$ac_cv_sys_file_offset_bits" != "no"; then
7680        LFS_CFLAGS="-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
7681    fi
7682    if test -n "$ac_cv_sys_large_files" -a "$ac_cv_sys_large_files" != "no"; then
7683        LFS_CFLAGS="$LFS_CFLAGS -D_LARGE_FILES"
7684    fi
7685else
7686    # Hardcode for MSVC
7687    SAL_TYPES_SIZEOFSHORT=2
7688    SAL_TYPES_SIZEOFINT=4
7689    SAL_TYPES_SIZEOFLONG=4
7690    SAL_TYPES_SIZEOFLONGLONG=8
7691    if test $WIN_HOST_BITS -eq 32; then
7692        SAL_TYPES_SIZEOFPOINTER=4
7693        SIZEOF_SIZE_T=4
7694    else
7695        SAL_TYPES_SIZEOFPOINTER=8
7696        SIZEOF_SIZE_T=8
7697    fi
7698    SAL_TYPES_ALIGNMENT2=2
7699    SAL_TYPES_ALIGNMENT4=4
7700    SAL_TYPES_ALIGNMENT8=8
7701    LFS_CFLAGS=''
7702fi
7703AC_SUBST(LFS_CFLAGS)
7704AC_SUBST(SIZEOF_SIZE_T)
7705
7706AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFSHORT,$SAL_TYPES_SIZEOFSHORT)
7707AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFINT,$SAL_TYPES_SIZEOFINT)
7708AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFLONG,$SAL_TYPES_SIZEOFLONG)
7709AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFLONGLONG,$SAL_TYPES_SIZEOFLONGLONG)
7710AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFPOINTER,$SAL_TYPES_SIZEOFPOINTER)
7711AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT2,$SAL_TYPES_ALIGNMENT2)
7712AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT4,$SAL_TYPES_ALIGNMENT4)
7713AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT8,$SAL_TYPES_ALIGNMENT8)
7714
7715dnl Calc jumbo sheets (1m+ rows) depend on 64 bit tools::Long .
7716AC_MSG_CHECKING([whether jumbo sheets are supported])
7717if test "$_os" != "WINNT"; then
7718    if test $SAL_TYPES_SIZEOFLONG -gt 4; then
7719        AC_MSG_RESULT([yes])
7720        ENABLE_JUMBO_SHEETS=TRUE
7721        AC_DEFINE(HAVE_FEATURE_JUMBO_SHEETS)
7722    else
7723        AC_MSG_RESULT([no])
7724    fi
7725else
7726    if test $WIN_HOST_BITS -gt 32; then
7727        # 64bit windows is special-cased for tools::Long because long is 32bit
7728        AC_MSG_RESULT([yes])
7729        ENABLE_JUMBO_SHEETS=TRUE
7730        AC_DEFINE(HAVE_FEATURE_JUMBO_SHEETS)
7731    else
7732        AC_MSG_RESULT([no])
7733    fi
7734fi
7735AC_SUBST(ENABLE_JUMBO_SHEETS)
7736
7737dnl ===================================================================
7738dnl Check whether to enable runtime optimizations
7739dnl ===================================================================
7740ENABLE_RUNTIME_OPTIMIZATIONS=
7741AC_MSG_CHECKING([whether to enable runtime optimizations])
7742if test -z "$enable_runtime_optimizations"; then
7743    for i in $CC; do
7744        case $i in
7745        -fsanitize=*)
7746            enable_runtime_optimizations=no
7747            break
7748            ;;
7749        esac
7750    done
7751fi
7752if test "$enable_runtime_optimizations" != no; then
7753    ENABLE_RUNTIME_OPTIMIZATIONS=TRUE
7754    AC_DEFINE(ENABLE_RUNTIME_OPTIMIZATIONS)
7755    AC_MSG_RESULT([yes])
7756else
7757    AC_MSG_RESULT([no])
7758fi
7759AC_SUBST([ENABLE_RUNTIME_OPTIMIZATIONS])
7760
7761dnl ===================================================================
7762dnl Check if valgrind headers are available
7763dnl ===================================================================
7764ENABLE_VALGRIND=
7765if test "$cross_compiling" != yes -a "$with_valgrind" != no; then
7766    prev_cppflags=$CPPFLAGS
7767    # Is VALGRIND_CFLAGS something one is supposed to have in the environment,
7768    # or where does it come from?
7769    CPPFLAGS="$CPPFLAGS $VALGRIND_CFLAGS"
7770    AC_CHECK_HEADER([valgrind/valgrind.h],
7771        [ENABLE_VALGRIND=TRUE])
7772    CPPFLAGS=$prev_cppflags
7773fi
7774AC_SUBST([ENABLE_VALGRIND])
7775if test -z "$ENABLE_VALGRIND"; then
7776    if test "$with_valgrind" = yes; then
7777        AC_MSG_ERROR([--with-valgrind specified but no Valgrind headers found])
7778    fi
7779    VALGRIND_CFLAGS=
7780fi
7781AC_SUBST([VALGRIND_CFLAGS])
7782
7783
7784dnl ===================================================================
7785dnl Check if SDT probes (for systemtap, gdb, dtrace) are available
7786dnl ===================================================================
7787
7788# We need at least the sys/sdt.h include header.
7789AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND='TRUE'], [SDT_H_FOUND='FALSE'])
7790if test "$SDT_H_FOUND" = "TRUE"; then
7791    # Found sys/sdt.h header, now make sure the c++ compiler works.
7792    # Old g++ versions had problems with probes in constructors/destructors.
7793    AC_MSG_CHECKING([working sys/sdt.h and c++ support])
7794    AC_LANG_PUSH([C++])
7795    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
7796    #include <sys/sdt.h>
7797    class ProbeClass
7798    {
7799    private:
7800      int& ref;
7801      const char *name;
7802
7803    public:
7804      ProbeClass(int& v, const char *n) : ref(v), name(n)
7805      {
7806        DTRACE_PROBE2(_test_, cons, name, ref);
7807      }
7808
7809      void method(int min)
7810      {
7811        DTRACE_PROBE3(_test_, meth, name, ref, min);
7812        ref -= min;
7813      }
7814
7815      ~ProbeClass()
7816      {
7817        DTRACE_PROBE2(_test_, dest, name, ref);
7818      }
7819    };
7820    ]],[[
7821    int i = 64;
7822    DTRACE_PROBE1(_test_, call, i);
7823    ProbeClass inst = ProbeClass(i, "call");
7824    inst.method(24);
7825    ]])], [AC_MSG_RESULT([yes]); AC_DEFINE([USE_SDT_PROBES])],
7826          [AC_MSG_RESULT([no, sdt.h or c++ compiler too old])])
7827    AC_LANG_POP([C++])
7828fi
7829AC_CONFIG_HEADERS([config_host/config_probes.h])
7830
7831dnl ===================================================================
7832dnl GCC features
7833dnl ===================================================================
7834HAVE_GCC_STACK_CLASH_PROTECTION=
7835HARDENING_LDFLAGS=
7836HARDENING_CFLAGS=
7837HARDENING_OPT_CFLAGS=
7838if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
7839
7840    AC_MSG_CHECKING([for full RELRO linker support])
7841    save_LDFLAGS=$LDFLAGS
7842    LDFLAGS="$LDFLAGS -Wl,-z,relro,-z,now"
7843    AC_LINK_IFELSE(
7844        [AC_LANG_PROGRAM(, [[return 0;]])],
7845        [AC_MSG_RESULT([yes]); HARDENING_LDFLAGS="$HARDENING_LDFLAGS -Wl,-z,relro,-z,now"],
7846        [AC_MSG_RESULT([no])])
7847    LDFLAGS=$save_LDFLAGS
7848
7849    AC_MSG_CHECKING([whether $CC_BASE supports -grecord-gcc-switches])
7850    save_CFLAGS=$CFLAGS
7851    CFLAGS="$CFLAGS -Werror -grecord-gcc-switches"
7852    AC_LINK_IFELSE(
7853        [AC_LANG_PROGRAM(, [[return 0;]])],
7854        [AC_MSG_RESULT([yes]); HARDENING_CFLAGS="$HARDENING_CFLAGS -grecord-gcc-switches"],
7855        [AC_MSG_RESULT([no])])
7856    CFLAGS=$save_CFLAGS
7857
7858    AC_MSG_CHECKING([whether $CC_BASE supports -D_FORTIFY_SOURCE=2])
7859    save_CFLAGS=$CFLAGS
7860    CFLAGS="$CFLAGS -Werror -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=2"
7861    if test "$ENABLE_OPTIMIZED" = TRUE; then
7862        CFLAGS="$CFLAGS -O2"
7863    fi
7864    AC_LINK_IFELSE(
7865        [AC_LANG_PROGRAM([[#include <string.h>]], [[return 0;]])],
7866        [AC_MSG_RESULT([yes]); HARDENING_OPT_CFLAGS="$HARDENING_OPT_CFLAGS -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=2"],
7867        [AC_MSG_RESULT([no])])
7868    CFLAGS=$save_CFLAGS
7869
7870    AC_MSG_CHECKING([whether $CC_BASE supports -D_GLIBCXX_ASSERTIONS])
7871    save_CFLAGS=$CFLAGS
7872    CFLAGS="$CFLAGS -Werror -Wp,-D_GLIBCXX_ASSERTIONS"
7873    AC_LINK_IFELSE(
7874        [AC_LANG_PROGRAM(, [[return 0;]])],
7875        [AC_MSG_RESULT([yes]); HARDENING_CFLAGS="$HARDENING_CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"],
7876        [AC_MSG_RESULT([no])])
7877    CFLAGS=$save_CFLAGS
7878
7879    AC_MSG_CHECKING([whether $CC_BASE supports -fstack-clash-protection])
7880    save_CFLAGS=$CFLAGS
7881    CFLAGS="$CFLAGS -Werror -fstack-clash-protection"
7882    AC_LINK_IFELSE(
7883        [AC_LANG_PROGRAM(, [[return 0;]])],
7884        [AC_MSG_RESULT([yes]); HAVE_GCC_STACK_CLASH_PROTECTION=TRUE; HARDENING_CFLAGS="$HARDENING_CFLAGS -fstack-clash-protection"],
7885        [AC_MSG_RESULT([no])])
7886    CFLAGS=$save_CFLAGS
7887
7888    AC_MSG_CHECKING([whether $CC_BASE supports -fcf-protection])
7889    save_CFLAGS=$CFLAGS
7890    CFLAGS="$CFLAGS -Werror -fcf-protection"
7891    AC_LINK_IFELSE(
7892        [AC_LANG_PROGRAM(, [[return 0;]])],
7893        [AC_MSG_RESULT([yes]); HARDENING_CFLAGS="$HARDENING_CFLAGS -fcf-protection"],
7894        [AC_MSG_RESULT([no])])
7895    CFLAGS=$save_CFLAGS
7896
7897    AC_MSG_CHECKING([whether $CC_BASE supports -mno-avx])
7898    save_CFLAGS=$CFLAGS
7899    CFLAGS="$CFLAGS -Werror -mno-avx"
7900    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_AVX=TRUE ],[])
7901    CFLAGS=$save_CFLAGS
7902    if test "$HAVE_GCC_AVX" = "TRUE"; then
7903        AC_MSG_RESULT([yes])
7904    else
7905        AC_MSG_RESULT([no])
7906    fi
7907
7908    AC_MSG_CHECKING([whether $CC_BASE supports atomic functions])
7909    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
7910    int v = 0;
7911    if (__sync_add_and_fetch(&v, 1) != 1 ||
7912        __sync_sub_and_fetch(&v, 1) != 0)
7913        return 1;
7914    __sync_synchronize();
7915    if (__sync_val_compare_and_swap(&v, 0, 1) != 0 ||
7916        v != 1)
7917        return 1;
7918    return 0;
7919]])],[HAVE_GCC_BUILTIN_ATOMIC=TRUE],[])
7920    if test "$HAVE_GCC_BUILTIN_ATOMIC" = "TRUE"; then
7921        AC_MSG_RESULT([yes])
7922        AC_DEFINE(HAVE_GCC_BUILTIN_ATOMIC)
7923    else
7924        AC_MSG_RESULT([no])
7925    fi
7926
7927    AC_MSG_CHECKING([whether $CXX_BASE defines __base_class_type_info in cxxabi.h])
7928    AC_LANG_PUSH([C++])
7929    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7930            #include <cstddef>
7931            #include <cxxabi.h>
7932            std::size_t f() { return sizeof(__cxxabiv1::__base_class_type_info); }
7933        ])], [
7934            AC_DEFINE([HAVE_CXXABI_H_BASE_CLASS_TYPE_INFO],[1])
7935            AC_MSG_RESULT([yes])
7936        ], [AC_MSG_RESULT([no])])
7937    AC_LANG_POP([C++])
7938
7939    AC_MSG_CHECKING([whether $CXX_BASE defines __class_type_info in cxxabi.h])
7940    AC_LANG_PUSH([C++])
7941    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7942            #include <cstddef>
7943            #include <cxxabi.h>
7944            std::size_t f() { return sizeof(__cxxabiv1::__class_type_info); }
7945        ])], [
7946            AC_DEFINE([HAVE_CXXABI_H_CLASS_TYPE_INFO],[1])
7947            AC_MSG_RESULT([yes])
7948        ], [AC_MSG_RESULT([no])])
7949    AC_LANG_POP([C++])
7950
7951    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_allocate_exception in cxxabi.h])
7952    AC_LANG_PUSH([C++])
7953    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7954            #include <cxxabi.h>
7955            void * f() { return __cxxabiv1::__cxa_allocate_exception(0); }
7956        ])], [
7957            AC_DEFINE([HAVE_CXXABI_H_CXA_ALLOCATE_EXCEPTION],[1])
7958            AC_MSG_RESULT([yes])
7959        ], [AC_MSG_RESULT([no])])
7960    AC_LANG_POP([C++])
7961
7962    AC_MSG_CHECKING([whether $CXX_BASE defines __cxa_eh_globals in cxxabi.h])
7963    AC_LANG_PUSH([C++])
7964    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7965            #include <cstddef>
7966            #include <cxxabi.h>
7967            std::size_t f() { return sizeof(__cxxabiv1::__cxa_eh_globals); }
7968        ])], [
7969            AC_DEFINE([HAVE_CXXABI_H_CXA_EH_GLOBALS],[1])
7970            AC_MSG_RESULT([yes])
7971        ], [AC_MSG_RESULT([no])])
7972    AC_LANG_POP([C++])
7973
7974    AC_MSG_CHECKING([whether $CXX_BASE defines __cxa_exception in cxxabi.h])
7975    AC_LANG_PUSH([C++])
7976    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7977            #include <cstddef>
7978            #include <cxxabi.h>
7979            std::size_t f() { return sizeof(__cxxabiv1::__cxa_exception); }
7980        ])], [
7981            AC_DEFINE([HAVE_CXXABI_H_CXA_EXCEPTION],[1])
7982            AC_MSG_RESULT([yes])
7983        ], [AC_MSG_RESULT([no])])
7984    AC_LANG_POP([C++])
7985
7986    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_get_globals in cxxabi.h])
7987    AC_LANG_PUSH([C++])
7988    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7989            #include <cxxabi.h>
7990            void * f() { return __cxxabiv1::__cxa_get_globals(); }
7991        ])], [
7992            AC_DEFINE([HAVE_CXXABI_H_CXA_GET_GLOBALS],[1])
7993            AC_MSG_RESULT([yes])
7994        ], [AC_MSG_RESULT([no])])
7995    AC_LANG_POP([C++])
7996
7997    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_current_exception_type in cxxabi.h])
7998    AC_LANG_PUSH([C++])
7999    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8000            #include <cxxabi.h>
8001            void * f() { return __cxxabiv1::__cxa_current_exception_type(); }
8002        ])], [
8003            AC_DEFINE([HAVE_CXXABI_H_CXA_CURRENT_EXCEPTION_TYPE],[1])
8004            AC_MSG_RESULT([yes])
8005        ], [AC_MSG_RESULT([no])])
8006    AC_LANG_POP([C++])
8007
8008    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_throw in cxxabi.h])
8009    AC_LANG_PUSH([C++])
8010    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8011            #include <cxxabi.h>
8012            void f() { __cxxabiv1::__cxa_throw(0, 0, 0); }
8013        ])], [
8014            AC_DEFINE([HAVE_CXXABI_H_CXA_THROW],[1])
8015            AC_MSG_RESULT([yes])
8016        ], [AC_MSG_RESULT([no])])
8017    AC_LANG_POP([C++])
8018
8019    AC_MSG_CHECKING([whether $CXX_BASE defines __si_class_type_info in cxxabi.h])
8020    AC_LANG_PUSH([C++])
8021    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8022            #include <cstddef>
8023            #include <cxxabi.h>
8024            std::size_t f() { return sizeof(__cxxabiv1::__si_class_type_info); }
8025        ])], [
8026            AC_DEFINE([HAVE_CXXABI_H_SI_CLASS_TYPE_INFO],[1])
8027            AC_MSG_RESULT([yes])
8028        ], [AC_MSG_RESULT([no])])
8029    AC_LANG_POP([C++])
8030
8031    AC_MSG_CHECKING([whether $CXX_BASE defines __vmi_class_type_info in cxxabi.h])
8032    AC_LANG_PUSH([C++])
8033    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8034            #include <cstddef>
8035            #include <cxxabi.h>
8036            std::size_t f() { return sizeof(__cxxabiv1::__vmi_class_type_info); }
8037        ])], [
8038            AC_DEFINE([HAVE_CXXABI_H_VMI_CLASS_TYPE_INFO],[1])
8039            AC_MSG_RESULT([yes])
8040        ], [AC_MSG_RESULT([no])])
8041    AC_LANG_POP([C++])
8042fi
8043
8044AC_SUBST(HAVE_GCC_AVX)
8045AC_SUBST(HAVE_GCC_BUILTIN_ATOMIC)
8046AC_SUBST(HAVE_GCC_STACK_CLASH_PROTECTION)
8047AC_SUBST(HARDENING_LDFLAGS)
8048AC_SUBST(HARDENING_CFLAGS)
8049AC_SUBST(HARDENING_OPT_CFLAGS)
8050
8051if test "$GCC" = yes && test "$COM_IS_CLANG" != TRUE; then
8052    AC_MSG_CHECKING([whether $CXX_BASE supports -Wsfinae-incomplete])
8053    AC_LANG_PUSH([C++])
8054    save_CXXFLAGS=$CFLAGS
8055    CXXFLAGS="$CXXFLAGS -Werror"
8056    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8057            #pragma GCC diagnostic warning "-Wsfinae-incomplete"
8058        ])], [
8059            AC_DEFINE([HAVE_GCC_WSFINAE_INCOMPLETE])
8060            AC_MSG_RESULT([yes])
8061        ], [AC_MSG_RESULT([no])])
8062    CXXFLAGS=$save_CXXFLAGS
8063    AC_LANG_POP([C++])
8064fi
8065
8066dnl ===================================================================
8067dnl Identify the C++ library
8068dnl ===================================================================
8069
8070AC_MSG_CHECKING([what the C++ library is])
8071HAVE_LIBSTDCPP=
8072HAVE_LIBCPP=
8073AC_LANG_PUSH([C++])
8074AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
8075#include <utility>
8076#ifndef __GLIBCXX__
8077foo bar
8078#endif
8079]])],
8080    [CPP_LIBRARY=GLIBCXX
8081     cpp_library_name="GNU libstdc++"
8082     HAVE_LIBSTDCPP=TRUE
8083    ],
8084    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
8085#include <utility>
8086#ifndef _LIBCPP_VERSION
8087foo bar
8088#endif
8089]])],
8090    [CPP_LIBRARY=LIBCPP
8091     cpp_library_name="LLVM libc++"
8092     AC_DEFINE([HAVE_LIBCPP])
8093     HAVE_LIBCPP=TRUE
8094    ],
8095    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
8096#include <utility>
8097#ifndef _MSC_VER
8098foo bar
8099#endif
8100]])],
8101    [CPP_LIBRARY=MSVCRT
8102     cpp_library_name="Microsoft"
8103    ],
8104    AC_MSG_ERROR([Could not figure out what C++ library this is]))))
8105AC_MSG_RESULT([$cpp_library_name])
8106AC_LANG_POP([C++])
8107AC_SUBST([HAVE_LIBSTDCPP])
8108AC_SUBST([HAVE_LIBCPP])
8109
8110if test -z "${LIBCPP_DEBUG+x}" -a -z "$CROSS_COMPILING" -a -n "$HAVE_LIBCPP" -a -n "$ENABLE_DBGUTIL"
8111then
8112    # Libc++ has two levels of debug mode, assertions mode enabled with -D_LIBCPP_DEBUG=0,
8113    # and actual debug mode enabled with -D_LIBCPP_DEBUG=1 (and starting with LLVM15
8114    # assertions mode will be separate and controlled by -D_LIBCPP_ENABLE_ASSERTIONS=1,
8115    # although there will be backwards compatibility).
8116    # Debug mode is supported by libc++ only if built for it, e.g. Mac libc++ isn't,
8117    # and there would be undefined references to debug functions.
8118    # Moreover std::to_string() has a bug (https://reviews.llvm.org/D125184).
8119    # So check if debug mode can be used and disable or downgrade it to assertions
8120    # if needed.
8121    AC_MSG_CHECKING([if libc++ has a usable debug mode])
8122    AC_LANG_PUSH([C++])
8123    libcpp_debug_links=
8124    AC_LINK_IFELSE([AC_LANG_SOURCE([[
8125#define _LIBCPP_DEBUG 0 // only assertions
8126#include <vector>
8127int main()
8128{
8129    std::vector<int> v;
8130    v.push_back( 1 );
8131    return v[ 3 ];
8132}
8133]])], [libcpp_debug_links=1])
8134    if test -n "$libcpp_debug_links"; then
8135        # we can use at least assertions, check if debug mode works
8136        AC_RUN_IFELSE([AC_LANG_SOURCE([[
8137#define _LIBCPP_DEBUG 1 // debug mode
8138#include <string>
8139#include <vector>
8140int foo(const std::vector<int>& v) { return *v.begin(); }
8141int main()
8142{
8143    std::vector<int> v;
8144    v.push_back( 1 );
8145    std::string s = "xxxxxxxxxxxxxxxxxxxxxxxxx" + std::to_string(10);
8146    return (foo(v) + s.size()) != 0 ? 0 : 1;
8147}
8148]])],
8149        [AC_MSG_RESULT(yes)
8150         LIBCPP_DEBUG=-D_LIBCPP_DEBUG=1
8151        ],
8152        [AC_MSG_RESULT(no, using only assertions)
8153         LIBCPP_DEBUG=-D_LIBCPP_DEBUG=0
8154        ]
8155        )
8156    else
8157        AC_MSG_RESULT(no)
8158    fi
8159    AC_LANG_POP([C++])
8160fi
8161AC_SUBST([LIBCPP_DEBUG])
8162
8163dnl ===================================================================
8164dnl Check for gperf
8165dnl ===================================================================
8166AC_PATH_PROG(GPERF, gperf)
8167if test -z "$GPERF"; then
8168    AC_MSG_ERROR([gperf not found but needed. Install it.])
8169fi
8170if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
8171    GPERF=`cygpath -m $GPERF`
8172fi
8173AC_MSG_CHECKING([whether gperf is new enough])
8174my_gperf_ver1=$($GPERF --version | head -n 1)
8175my_gperf_ver2=${my_gperf_ver1#GNU gperf }
8176my_gperf_ver3=$(printf %s "$my_gperf_ver2" | $AWK -F. '{ print $1*100+($2<100?$2:99) }')
8177if test "$my_gperf_ver3" -ge 301; then
8178    AC_MSG_RESULT([yes ($my_gperf_ver2)])
8179else
8180    AC_MSG_ERROR(["$my_gperf_ver1" is too old or unrecognized, must be at least gperf 3.1])
8181fi
8182AC_SUBST(GPERF)
8183
8184dnl ===================================================================
8185dnl Check for system libcmis
8186dnl ===================================================================
8187libo_CHECK_SYSTEM_MODULE([libcmis],[LIBCMIS],[libcmis-0.6 >= 0.6.1],enabled)
8188
8189dnl ===================================================================
8190dnl C++11
8191dnl ===================================================================
8192
8193if test -z "${CXXFLAGS_CXX11+x}"; then
8194    AC_MSG_CHECKING([whether $CXX_BASE supports C++20])
8195    if test "$COM" = MSC -a "$COM_IS_CLANG" != TRUE; then
8196        if test "$with_latest_c__" = yes; then
8197            CXXFLAGS_CXX11=-std:c++latest
8198        else
8199            CXXFLAGS_CXX11=-std:c++20
8200        fi
8201        CXXFLAGS_CXX11="$CXXFLAGS_CXX11 -permissive- -Zc:__cplusplus,preprocessor"
8202    elif test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
8203        my_flags='-std=c++20 -std=c++2a'
8204        if test "$with_latest_c__" = yes; then
8205            my_flags="-std=c++26 -std=c++2c -std=c++23 -std=c++2b $my_flags"
8206        fi
8207        for flag in $my_flags; do
8208            if test "$COM" = MSC; then
8209                flag="-Xclang $flag"
8210            fi
8211            save_CXXFLAGS=$CXXFLAGS
8212            CXXFLAGS="$CXXFLAGS $flag -Werror"
8213            AC_LANG_PUSH([C++])
8214            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
8215                #include <algorithm>
8216                #include <functional>
8217                #include <vector>
8218
8219                void f(std::vector<int> & v, std::function<bool(int, int)> fn) {
8220                    std::sort(v.begin(), v.end(), fn);
8221                }
8222                ]])],[CXXFLAGS_CXX11=$flag])
8223            AC_LANG_POP([C++])
8224            CXXFLAGS=$save_CXXFLAGS
8225            if test -n "$CXXFLAGS_CXX11"; then
8226                break
8227            fi
8228        done
8229    fi
8230    if test -n "$CXXFLAGS_CXX11"; then
8231        AC_MSG_RESULT([yes ($CXXFLAGS_CXX11)])
8232    else
8233        AC_MSG_ERROR(no)
8234    fi
8235fi
8236AC_SUBST(CXXFLAGS_CXX11)
8237
8238if test "$GCC" = "yes"; then
8239    save_CXXFLAGS=$CXXFLAGS
8240    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
8241    CHECK_L_ATOMIC
8242    CXXFLAGS=$save_CXXFLAGS
8243    AC_SUBST(ATOMIC_LIB)
8244fi
8245
8246AC_MSG_CHECKING([whether $CXX_BASE supports C++11 without Language Defect 757])
8247save_CXXFLAGS=$CXXFLAGS
8248CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
8249AC_LANG_PUSH([C++])
8250
8251AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
8252#include <stddef.h>
8253
8254template <typename T, size_t S> char (&sal_n_array_size( T(&)[S] ))[S];
8255
8256namespace
8257{
8258        struct b
8259        {
8260                int i;
8261                int j;
8262        };
8263}
8264]], [[
8265struct a
8266{
8267        int i;
8268        int j;
8269};
8270a thinga[]={{0,0}, {1,1}};
8271b thingb[]={{0,0}, {1,1}};
8272size_t i = sizeof(sal_n_array_size(thinga));
8273size_t j = sizeof(sal_n_array_size(thingb));
8274return !(i != 0 && j != 0);
8275]])
8276    ], [ AC_MSG_RESULT(yes) ],
8277    [ AC_MSG_ERROR(no)])
8278AC_LANG_POP([C++])
8279CXXFLAGS=$save_CXXFLAGS
8280
8281HAVE_GCC_FNO_SIZED_DEALLOCATION=
8282if test "$GCC" = yes; then
8283    AC_MSG_CHECKING([whether $CXX_BASE supports -fno-sized-deallocation])
8284    AC_LANG_PUSH([C++])
8285    save_CXXFLAGS=$CXXFLAGS
8286    CXXFLAGS="$CXXFLAGS -fno-sized-deallocation"
8287    AC_LINK_IFELSE([AC_LANG_PROGRAM()],[HAVE_GCC_FNO_SIZED_DEALLOCATION=TRUE])
8288    CXXFLAGS=$save_CXXFLAGS
8289    AC_LANG_POP([C++])
8290    if test "$HAVE_GCC_FNO_SIZED_DEALLOCATION" = TRUE; then
8291        AC_MSG_RESULT([yes])
8292    else
8293        AC_MSG_RESULT([no])
8294    fi
8295fi
8296AC_SUBST([HAVE_GCC_FNO_SIZED_DEALLOCATION])
8297
8298AC_MSG_CHECKING([whether $CXX_BASE supports C++2a constinit sorted vectors])
8299AC_LANG_PUSH([C++])
8300save_CXXFLAGS=$CXXFLAGS
8301CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
8302AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8303        #include <algorithm>
8304        #include <initializer_list>
8305        #include <vector>
8306        template<typename T> class S {
8307        private:
8308            std::vector<T> v_;
8309        public:
8310            constexpr S(std::initializer_list<T> i): v_(i) { std::sort(v_.begin(), v_.end()); }
8311        };
8312        constinit S<int> s{3, 2, 1};
8313    ])], [
8314        AC_DEFINE([HAVE_CPP_CONSTINIT_SORTED_VECTOR],[1])
8315        AC_MSG_RESULT([yes])
8316    ], [AC_MSG_RESULT([no])])
8317CXXFLAGS=$save_CXXFLAGS
8318AC_LANG_POP([C++])
8319
8320AC_MSG_CHECKING([whether $CXX_BASE implements C++ DR P1155R3])
8321AC_LANG_PUSH([C++])
8322save_CXXFLAGS=$CXXFLAGS
8323CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
8324AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8325        struct S1 { S1(S1 &&); };
8326        struct S2: S1 {};
8327        S1 f(S2 s) { return s; }
8328    ])], [
8329        AC_DEFINE([HAVE_P1155R3],[1])
8330        AC_MSG_RESULT([yes])
8331    ], [AC_MSG_RESULT([no])])
8332CXXFLAGS=$save_CXXFLAGS
8333AC_LANG_POP([C++])
8334
8335AC_MSG_CHECKING([whether $CXX_BASE supports C++20 std::atomic_ref])
8336HAVE_CXX20_ATOMIC_REF=
8337AC_LANG_PUSH([C++])
8338save_CXXFLAGS=$CXXFLAGS
8339CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
8340AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8341        #include <atomic>
8342        int x;
8343        std::atomic_ref<int> y(x);
8344    ])], [
8345        HAVE_CXX20_ATOMIC_REF=TRUE
8346        AC_MSG_RESULT([yes])
8347    ], [AC_MSG_RESULT([no])])
8348CXXFLAGS=$save_CXXFLAGS
8349AC_LANG_POP([C++])
8350AC_SUBST([HAVE_CXX20_ATOMIC_REF])
8351
8352dnl Supported since GCC 9 and Clang 10 (which each also started to support -Wdeprecated-copy, but
8353dnl which is included in -Wextra anyway):
8354HAVE_WDEPRECATED_COPY_DTOR=
8355if test "$GCC" = yes; then
8356    AC_MSG_CHECKING([whether $CXX_BASE supports -Wdeprecated-copy-dtor])
8357    AC_LANG_PUSH([C++])
8358    save_CXXFLAGS=$CXXFLAGS
8359    CXXFLAGS="$CXXFLAGS -Werror -Wdeprecated-copy-dtor"
8360    AC_COMPILE_IFELSE([AC_LANG_SOURCE()], [
8361            HAVE_WDEPRECATED_COPY_DTOR=TRUE
8362            AC_MSG_RESULT([yes])
8363        ], [AC_MSG_RESULT([no])])
8364    CXXFLAGS=$save_CXXFLAGS
8365    AC_LANG_POP([C++])
8366fi
8367AC_SUBST([HAVE_WDEPRECATED_COPY_DTOR])
8368
8369dnl At least GCC 8.2 with -O2 (i.e., --enable-optimized) causes a false-positive -Wmaybe-
8370dnl uninitialized warning for code like
8371dnl
8372dnl   OString f();
8373dnl   boost::optional<OString> * g(bool b) {
8374dnl       boost::optional<OString> o;
8375dnl       if (b) o = f();
8376dnl       return new boost::optional<OString>(o);
8377dnl   }
8378dnl
8379dnl (as is e.g. present, in a slightly more elaborate form, in
8380dnl librdf_TypeConverter::extractNode_NoLock in unoxml/source/rdf/librdf_repository.cxx); the below
8381dnl code is meant to be a faithfully stripped-down and self-contained version of the above code:
8382HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED=
8383if test "$GCC" = yes && test "$COM_IS_CLANG" != TRUE; then
8384    AC_MSG_CHECKING([whether $CXX_BASE might report false -Werror=maybe-uninitialized])
8385    AC_LANG_PUSH([C++])
8386    save_CXXFLAGS=$CXXFLAGS
8387    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11 -Werror -Wmaybe-uninitialized"
8388    if test "$ENABLE_OPTIMIZED" = TRUE; then
8389        CXXFLAGS="$CXXFLAGS -O2"
8390    else
8391        CXXFLAGS="$CXXFLAGS -O0"
8392    fi
8393    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
8394            #include <new>
8395            void f1(int);
8396            struct S1 {
8397                ~S1() { f1(n); }
8398                int n = 0;
8399            };
8400            struct S2 {
8401                S2() {}
8402                S2(S2 const & s) { if (s.init) set(*reinterpret_cast<S1 const *>(s.stg)); }
8403                ~S2() { if (init) reinterpret_cast<S1 *>(stg)->S1::~S1(); }
8404                void set(S1 s) {
8405                    new (stg) S1(s);
8406                    init = true;
8407                }
8408                bool init = false;
8409                char stg[sizeof (S1)];
8410            } ;
8411            S1 f2();
8412            S2 * f3(bool b) {
8413                S2 o;
8414                if (b) o.set(f2());
8415                return new S2(o);
8416            }
8417        ]])], [AC_MSG_RESULT([no])], [
8418            HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED=TRUE
8419            AC_MSG_RESULT([yes])
8420        ])
8421    CXXFLAGS=$save_CXXFLAGS
8422    AC_LANG_POP([C++])
8423fi
8424AC_SUBST([HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED])
8425
8426dnl Check for <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87296#c5> "[8/9/10/11 Regression]
8427dnl -Wstringop-overflow false positive due to using MEM_REF type of &MEM" (fixed in GCC 11), which
8428dnl hits us e.g. with GCC 10 and --enable-optimized at
8429dnl
8430dnl   In file included from include/rtl/string.hxx:49,
8431dnl                    from include/rtl/ustring.hxx:43,
8432dnl                    from include/osl/file.hxx:35,
8433dnl                    from include/codemaker/global.hxx:28,
8434dnl                    from include/codemaker/options.hxx:23,
8435dnl                    from codemaker/source/commoncpp/commoncpp.cxx:24:
8436dnl   In function ‘char* rtl::addDataHelper(char*, const char*, std::size_t)’,
8437dnl       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,
8438dnl       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,
8439dnl       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,
8440dnl       inlined from ‘rtl::OString codemaker::cpp::scopedCppName(const rtl::OString&, bool)’ at codemaker/source/commoncpp/commoncpp.cxx:53:55:
8441dnl   include/rtl/stringconcat.hxx:78:15: error: writing 2 bytes into a region of size 1 [-Werror=stringop-overflow=]
8442dnl      78 |         memcpy( buffer, data, length );
8443dnl         |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
8444HAVE_BROKEN_GCC_WSTRINGOP_OVERFLOW=
8445if test "$GCC" = yes && test "$COM_IS_CLANG" != TRUE; then
8446    AC_MSG_CHECKING([whether $CXX_BASE might report false -Werror=stringop-overflow=])
8447    AC_LANG_PUSH([C++])
8448    save_CXXFLAGS=$CXXFLAGS
8449    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11 -Werror -Wstringop-overflow"
8450    if test "$ENABLE_OPTIMIZED" = TRUE; then
8451        CXXFLAGS="$CXXFLAGS -O2"
8452    else
8453        CXXFLAGS="$CXXFLAGS -O0"
8454    fi
8455    dnl Test code taken from <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87296#c0>:
8456    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
8457            void fill(char const * begin, char const * end, char c);
8458            struct q {
8459                char ids[4];
8460                char username[6];
8461            };
8462            void test(q & c) {
8463                fill(c.ids, c.ids + sizeof(c.ids), '\0');
8464                __builtin_strncpy(c.username, "root", sizeof(c.username));
8465            }
8466        ]])], [AC_MSG_RESULT([no])], [
8467            HAVE_BROKEN_GCC_WSTRINGOP_OVERFLOW=TRUE
8468            AC_MSG_RESULT([yes])
8469        ])
8470    CXXFLAGS=$save_CXXFLAGS
8471    AC_LANG_POP([C++])
8472fi
8473AC_SUBST([HAVE_BROKEN_GCC_WSTRINGOP_OVERFLOW])
8474
8475HAVE_DLLEXPORTINLINES=
8476if test "$_os" = "WINNT"; then
8477    AC_MSG_CHECKING([whether $CXX_BASE supports -Zc:dllexportInlines-])
8478    AC_LANG_PUSH([C++])
8479    save_CXXFLAGS=$CXXFLAGS
8480    CXXFLAGS="$CXXFLAGS -Werror -Zc:dllexportInlines-"
8481    AC_COMPILE_IFELSE([AC_LANG_SOURCE()], [
8482            HAVE_DLLEXPORTINLINES=TRUE
8483            AC_MSG_RESULT([yes])
8484        ], [AC_MSG_RESULT([no])])
8485    CXXFLAGS=$save_CXXFLAGS
8486    AC_LANG_POP([C++])
8487fi
8488AC_SUBST([HAVE_DLLEXPORTINLINES])
8489
8490dnl ===================================================================
8491dnl CPU Intrinsics support - SSE, AVX
8492dnl ===================================================================
8493
8494CXXFLAGS_INTRINSICS_SSE2=
8495CXXFLAGS_INTRINSICS_SSSE3=
8496CXXFLAGS_INTRINSICS_SSE41=
8497CXXFLAGS_INTRINSICS_SSE42=
8498CXXFLAGS_INTRINSICS_AVX=
8499CXXFLAGS_INTRINSICS_AVX2=
8500CXXFLAGS_INTRINSICS_AVX512=
8501CXXFLAGS_INTRINSICS_AVX512F=
8502CXXFLAGS_INTRINSICS_F16C=
8503CXXFLAGS_INTRINSICS_FMA=
8504
8505if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
8506    # GCC, Clang or Clang-cl (clang-cl + MSVC's -arch options don't work well together)
8507    flag_sse2=-msse2
8508    flag_ssse3=-mssse3
8509    flag_sse41=-msse4.1
8510    flag_sse42=-msse4.2
8511    flag_avx=-mavx
8512    flag_avx2=-mavx2
8513    flag_avx512="-mavx512f -mavx512vl -mavx512bw -mavx512dq -mavx512cd"
8514    flag_avx512f=-mavx512f
8515    flag_f16c=-mf16c
8516    flag_fma=-mfma
8517else
8518    # With MSVC using -arch is in fact not necessary for being able
8519    # to use CPU intrinsics, code using AVX512F intrinsics will compile
8520    # even if compiled with -arch:AVX, the -arch option really only affects
8521    # instructions generated for C/C++ code.
8522    # So use the matching same (or lower) -arch options, but only in order
8523    # to generate the best matching instructions for the C++ code surrounding
8524    # the intrinsics.
8525    # SSE2 is the default for x86/x64, so no need to specify the option.
8526    flag_sse2=
8527    # No specific options for these, use the next lower.
8528    flag_ssse3="$flag_sse2"
8529    flag_sse41="$flag_sse2"
8530    flag_sse42="$flag_sse2"
8531    flag_avx=-arch:AVX
8532    flag_avx2=-arch:AVX2
8533    flag_avx512=-arch:AVX512
8534    # Using -arch:AVX512 would enable more than just AVX512F, so use only AVX2.
8535    flag_avx512f=-arch:AVX2
8536    # No MSVC options for these.
8537    flag_f16c="$flag_sse2"
8538    flag_fma="$flag_sse2"
8539fi
8540
8541AC_MSG_CHECKING([whether $CXX can compile SSE2 intrinsics])
8542AC_LANG_PUSH([C++])
8543save_CXXFLAGS=$CXXFLAGS
8544CXXFLAGS="$CXXFLAGS $flag_sse2"
8545AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8546    #include <emmintrin.h>
8547    int main () {
8548        __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
8549        c = _mm_xor_si128 (a, b);
8550        return 0;
8551    }
8552    ])],
8553    [can_compile_sse2=yes],
8554    [can_compile_sse2=no])
8555AC_LANG_POP([C++])
8556CXXFLAGS=$save_CXXFLAGS
8557AC_MSG_RESULT([${can_compile_sse2}])
8558if test "${can_compile_sse2}" = "yes" ; then
8559    CXXFLAGS_INTRINSICS_SSE2="$flag_sse2"
8560fi
8561
8562AC_MSG_CHECKING([whether $CXX can compile SSSE3 intrinsics])
8563AC_LANG_PUSH([C++])
8564save_CXXFLAGS=$CXXFLAGS
8565CXXFLAGS="$CXXFLAGS $flag_ssse3"
8566AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8567    #include <tmmintrin.h>
8568    int main () {
8569        __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
8570        c = _mm_maddubs_epi16 (a, b);
8571        return 0;
8572    }
8573    ])],
8574    [can_compile_ssse3=yes],
8575    [can_compile_ssse3=no])
8576AC_LANG_POP([C++])
8577CXXFLAGS=$save_CXXFLAGS
8578AC_MSG_RESULT([${can_compile_ssse3}])
8579if test "${can_compile_ssse3}" = "yes" ; then
8580    CXXFLAGS_INTRINSICS_SSSE3="$flag_ssse3"
8581fi
8582
8583AC_MSG_CHECKING([whether $CXX can compile SSE4.1 intrinsics])
8584AC_LANG_PUSH([C++])
8585save_CXXFLAGS=$CXXFLAGS
8586CXXFLAGS="$CXXFLAGS $flag_sse41"
8587AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8588    #include <smmintrin.h>
8589    int main () {
8590        __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
8591        c = _mm_cmpeq_epi64 (a, b);
8592        return 0;
8593    }
8594    ])],
8595    [can_compile_sse41=yes],
8596    [can_compile_sse41=no])
8597AC_LANG_POP([C++])
8598CXXFLAGS=$save_CXXFLAGS
8599AC_MSG_RESULT([${can_compile_sse41}])
8600if test "${can_compile_sse41}" = "yes" ; then
8601    CXXFLAGS_INTRINSICS_SSE41="$flag_sse41"
8602fi
8603
8604AC_MSG_CHECKING([whether $CXX can compile SSE4.2 intrinsics])
8605AC_LANG_PUSH([C++])
8606save_CXXFLAGS=$CXXFLAGS
8607CXXFLAGS="$CXXFLAGS $flag_sse42"
8608AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8609    #include <nmmintrin.h>
8610    int main () {
8611        __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
8612        c = _mm_cmpgt_epi64 (a, b);
8613        return 0;
8614    }
8615    ])],
8616    [can_compile_sse42=yes],
8617    [can_compile_sse42=no])
8618AC_LANG_POP([C++])
8619CXXFLAGS=$save_CXXFLAGS
8620AC_MSG_RESULT([${can_compile_sse42}])
8621if test "${can_compile_sse42}" = "yes" ; then
8622    CXXFLAGS_INTRINSICS_SSE42="$flag_sse42"
8623fi
8624
8625AC_MSG_CHECKING([whether $CXX can compile AVX intrinsics])
8626AC_LANG_PUSH([C++])
8627save_CXXFLAGS=$CXXFLAGS
8628CXXFLAGS="$CXXFLAGS $flag_avx"
8629AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8630    #include <immintrin.h>
8631    int main () {
8632        __m256 a = _mm256_set1_ps (0.0f), b = _mm256_set1_ps (0.0f), c;
8633        c = _mm256_xor_ps(a, b);
8634        return 0;
8635    }
8636    ])],
8637    [can_compile_avx=yes],
8638    [can_compile_avx=no])
8639AC_LANG_POP([C++])
8640CXXFLAGS=$save_CXXFLAGS
8641AC_MSG_RESULT([${can_compile_avx}])
8642if test "${can_compile_avx}" = "yes" ; then
8643    CXXFLAGS_INTRINSICS_AVX="$flag_avx"
8644fi
8645
8646AC_MSG_CHECKING([whether $CXX can compile AVX2 intrinsics])
8647AC_LANG_PUSH([C++])
8648save_CXXFLAGS=$CXXFLAGS
8649CXXFLAGS="$CXXFLAGS $flag_avx2"
8650AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8651    #include <immintrin.h>
8652    int main () {
8653        __m256i a = _mm256_set1_epi32 (0), b = _mm256_set1_epi32 (0), c;
8654        c = _mm256_maddubs_epi16(a, b);
8655        return 0;
8656    }
8657    ])],
8658    [can_compile_avx2=yes],
8659    [can_compile_avx2=no])
8660AC_LANG_POP([C++])
8661CXXFLAGS=$save_CXXFLAGS
8662AC_MSG_RESULT([${can_compile_avx2}])
8663if test "${can_compile_avx2}" = "yes" ; then
8664    CXXFLAGS_INTRINSICS_AVX2="$flag_avx2"
8665fi
8666
8667AC_MSG_CHECKING([whether $CXX can compile AVX512 intrinsics])
8668AC_LANG_PUSH([C++])
8669save_CXXFLAGS=$CXXFLAGS
8670CXXFLAGS="$CXXFLAGS $flag_avx512"
8671AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8672    #include <immintrin.h>
8673    int main () {
8674        __m512i a = _mm512_loadu_si512(0);
8675        __m512d v1 = _mm512_load_pd(0);
8676        // https://gcc.gnu.org/git/?p=gcc.git;a=commit;f=gcc/config/i386/avx512fintrin.h;h=23bce99cbe7016a04e14c2163ed3fe6a5a64f4e2
8677        __m512d v2 = _mm512_abs_pd(v1);
8678        return 0;
8679    }
8680    ])],
8681    [can_compile_avx512=yes],
8682    [can_compile_avx512=no])
8683AC_LANG_POP([C++])
8684CXXFLAGS=$save_CXXFLAGS
8685AC_MSG_RESULT([${can_compile_avx512}])
8686if test "${can_compile_avx512}" = "yes" ; then
8687    CXXFLAGS_INTRINSICS_AVX512="$flag_avx512"
8688    CXXFLAGS_INTRINSICS_AVX512F="$flag_avx512f"
8689fi
8690
8691AC_MSG_CHECKING([whether $CXX can compile F16C intrinsics])
8692AC_LANG_PUSH([C++])
8693save_CXXFLAGS=$CXXFLAGS
8694CXXFLAGS="$CXXFLAGS $flag_f16c"
8695AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8696    #include <immintrin.h>
8697    int main () {
8698        __m128i a = _mm_set1_epi32 (0);
8699        __m128 c;
8700        c = _mm_cvtph_ps(a);
8701        return 0;
8702    }
8703    ])],
8704    [can_compile_f16c=yes],
8705    [can_compile_f16c=no])
8706AC_LANG_POP([C++])
8707CXXFLAGS=$save_CXXFLAGS
8708AC_MSG_RESULT([${can_compile_f16c}])
8709if test "${can_compile_f16c}" = "yes" ; then
8710    CXXFLAGS_INTRINSICS_F16C="$flag_f16c"
8711fi
8712
8713AC_MSG_CHECKING([whether $CXX can compile FMA intrinsics])
8714AC_LANG_PUSH([C++])
8715save_CXXFLAGS=$CXXFLAGS
8716CXXFLAGS="$CXXFLAGS $flag_fma"
8717AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8718    #include <immintrin.h>
8719    int main () {
8720        __m256 a = _mm256_set1_ps (0.0f), b = _mm256_set1_ps (0.0f), c = _mm256_set1_ps (0.0f), d;
8721        d = _mm256_fmadd_ps(a, b, c);
8722        return 0;
8723    }
8724    ])],
8725    [can_compile_fma=yes],
8726    [can_compile_fma=no])
8727AC_LANG_POP([C++])
8728CXXFLAGS=$save_CXXFLAGS
8729AC_MSG_RESULT([${can_compile_fma}])
8730if test "${can_compile_fma}" = "yes" ; then
8731    CXXFLAGS_INTRINSICS_FMA="$flag_fma"
8732fi
8733
8734AC_SUBST([CXXFLAGS_INTRINSICS_SSE2])
8735AC_SUBST([CXXFLAGS_INTRINSICS_SSSE3])
8736AC_SUBST([CXXFLAGS_INTRINSICS_SSE41])
8737AC_SUBST([CXXFLAGS_INTRINSICS_SSE42])
8738AC_SUBST([CXXFLAGS_INTRINSICS_AVX])
8739AC_SUBST([CXXFLAGS_INTRINSICS_AVX2])
8740AC_SUBST([CXXFLAGS_INTRINSICS_AVX512])
8741AC_SUBST([CXXFLAGS_INTRINSICS_AVX512F])
8742AC_SUBST([CXXFLAGS_INTRINSICS_F16C])
8743AC_SUBST([CXXFLAGS_INTRINSICS_FMA])
8744
8745dnl ===================================================================
8746dnl system stl sanity tests
8747dnl ===================================================================
8748if test "$_os" != "WINNT"; then
8749
8750    AC_LANG_PUSH([C++])
8751
8752    save_CPPFLAGS="$CPPFLAGS"
8753    if test -n "$MACOSX_SDK_PATH"; then
8754        CPPFLAGS="-isysroot $MACOSX_SDK_PATH $CPPFLAGS"
8755    fi
8756
8757    # Assume visibility is not broken with libc++. The below test is very much designed for libstdc++
8758    # only.
8759    if test "$CPP_LIBRARY" = GLIBCXX; then
8760        dnl gcc#19664, gcc#22482, rhbz#162935
8761        AC_MSG_CHECKING([if STL headers are visibility safe (GCC bug 22482)])
8762        AC_EGREP_HEADER(visibility push, string, stlvisok=yes, stlvisok=no)
8763        AC_MSG_RESULT([$stlvisok])
8764        if test "$stlvisok" = "no"; then
8765            AC_MSG_ERROR([Your libstdc++ headers are not visibility safe. This is no longer supported.])
8766        fi
8767    fi
8768
8769    # As the below test checks things when linking self-compiled dynamic libraries, it presumably is irrelevant
8770    # when we don't make any dynamic libraries?
8771    if test "$DISABLE_DYNLOADING" = ""; then
8772        AC_MSG_CHECKING([if $CXX_BASE is -fvisibility-inlines-hidden safe (Clang bug 11250)])
8773        cat > conftestlib1.cc <<_ACEOF
8774template<typename T> struct S1 { virtual ~S1() {} virtual void f() {} };
8775struct S2: S1<int> { virtual ~S2(); };
8776S2::~S2() {}
8777_ACEOF
8778        cat > conftestlib2.cc <<_ACEOF
8779template<typename T> struct S1 { virtual ~S1() {} virtual void f() {} };
8780struct S2: S1<int> { virtual ~S2(); };
8781struct S3: S2 { virtual ~S3(); }; S3::~S3() {}
8782_ACEOF
8783        gccvisinlineshiddenok=yes
8784        if ! $CXX $CXXFLAGS $CPPFLAGS $LINKFLAGSSHL -fPIC -fvisibility-inlines-hidden conftestlib1.cc -o libconftest1$DLLPOST >/dev/null 2>&5; then
8785            gccvisinlineshiddenok=no
8786        else
8787            dnl At least Clang -fsanitize=address and -fsanitize=undefined are
8788            dnl known to not work with -z defs (unsetting which makes the test
8789            dnl moot, though):
8790            my_linkflagsnoundefs=$LINKFLAGSNOUNDEFS
8791            if test "$COM_IS_CLANG" = TRUE; then
8792                for i in $CXX $CXXFLAGS; do
8793                    case $i in
8794                    -fsanitize=*)
8795                        my_linkflagsnoundefs=
8796                        break
8797                        ;;
8798                    esac
8799                done
8800            fi
8801            if ! $CXX $CXXFLAGS $CPPFLAGS $LINKFLAGSSHL -fPIC -fvisibility-inlines-hidden conftestlib2.cc -L. -lconftest1 $my_linkflagsnoundefs -o libconftest2$DLLPOST >/dev/null 2>&5; then
8802                gccvisinlineshiddenok=no
8803            fi
8804        fi
8805
8806        rm -fr libconftest*
8807        AC_MSG_RESULT([$gccvisinlineshiddenok])
8808        if test "$gccvisinlineshiddenok" = "no"; then
8809            AC_MSG_ERROR([Your gcc/clang is not -fvisibility-inlines-hidden safe. This is no longer supported.])
8810        fi
8811    fi
8812
8813   AC_MSG_CHECKING([if $CXX_BASE has a visibility bug with class-level attributes (GCC bug 26905)])
8814    cat >visibility.cxx <<_ACEOF
8815#pragma GCC visibility push(hidden)
8816struct __attribute__ ((visibility ("default"))) TestStruct {
8817  static void Init();
8818};
8819__attribute__ ((visibility ("default"))) void TestFunc() {
8820  TestStruct::Init();
8821}
8822_ACEOF
8823    if ! $CXX $CXXFLAGS $CPPFLAGS -fpic -S visibility.cxx; then
8824        gccvisbroken=yes
8825    else
8826        case "$host_cpu" in
8827        i?86|x86_64)
8828            if test "$_os" = "Darwin" -o "$_os" = "iOS"; then
8829                gccvisbroken=no
8830            else
8831                if $EGREP -q '@PLT|@GOT' visibility.s || test "$ENABLE_LTO" = "TRUE"; then
8832                    gccvisbroken=no
8833                else
8834                    gccvisbroken=yes
8835                fi
8836            fi
8837            ;;
8838        *)
8839            gccvisbroken=no
8840            ;;
8841        esac
8842    fi
8843    rm -f visibility.s visibility.cxx
8844
8845    AC_MSG_RESULT([$gccvisbroken])
8846    if test "$gccvisbroken" = "yes"; then
8847        AC_MSG_ERROR([Your gcc is not -fvisibility=hidden safe. This is no longer supported.])
8848    fi
8849
8850    CPPFLAGS="$save_CPPFLAGS"
8851
8852    AC_MSG_CHECKING([if CET endbranch is recognized])
8853cat > endbr.s <<_ACEOF
8854endbr32
8855_ACEOF
8856    HAVE_ASM_END_BRANCH_INS_SUPPORT=
8857    if $CXX -c endbr.s -o endbr.o >/dev/null 2>&5; then
8858        AC_MSG_RESULT([yes])
8859        HAVE_ASM_END_BRANCH_INS_SUPPORT=TRUE
8860    else
8861        AC_MSG_RESULT([no])
8862    fi
8863    rm -f endbr.s endbr.o
8864    AC_SUBST(HAVE_ASM_END_BRANCH_INS_SUPPORT)
8865
8866    AC_LANG_POP([C++])
8867fi
8868
8869dnl ===================================================================
8870dnl  Clang++ tests
8871dnl ===================================================================
8872
8873HAVE_GCC_FNO_ENFORCE_EH_SPECS=
8874if test "$GCC" = "yes"; then
8875    AC_MSG_CHECKING([whether $CXX_BASE supports -fno-enforce-eh-specs])
8876    AC_LANG_PUSH([C++])
8877    save_CXXFLAGS=$CXXFLAGS
8878    CXXFLAGS="$CFLAGS -Werror -fno-enforce-eh-specs"
8879    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_FNO_ENFORCE_EH_SPECS=TRUE ],[])
8880    CXXFLAGS=$save_CXXFLAGS
8881    AC_LANG_POP([C++])
8882    if test "$HAVE_GCC_FNO_ENFORCE_EH_SPECS" = "TRUE"; then
8883        AC_MSG_RESULT([yes])
8884    else
8885        AC_MSG_RESULT([no])
8886    fi
8887fi
8888AC_SUBST(HAVE_GCC_FNO_ENFORCE_EH_SPECS)
8889
8890dnl ===================================================================
8891dnl Compiler plugins
8892dnl ===================================================================
8893
8894COMPILER_PLUGINS=
8895# currently only Clang
8896
8897if test "$COM_IS_CLANG" != "TRUE"; then
8898    if test "$libo_fuzzed_enable_compiler_plugins" = yes -a "$enable_compiler_plugins" = yes; then
8899        AC_MSG_NOTICE([Resetting --enable-compiler-plugins=no])
8900        enable_compiler_plugins=no
8901    fi
8902fi
8903
8904COMPILER_PLUGINS_COM_IS_CLANG=
8905if test "$COM_IS_CLANG" = "TRUE"; then
8906    if test -n "$enable_compiler_plugins"; then
8907        compiler_plugins="$enable_compiler_plugins"
8908    elif test -n "$ENABLE_DBGUTIL"; then
8909        compiler_plugins=test
8910    else
8911        compiler_plugins=no
8912    fi
8913    if test "$compiler_plugins" != no -a "$my_apple_clang" != yes; then
8914        if test "$CLANGVER" -lt 120001; then
8915            if test "$compiler_plugins" = yes; then
8916                AC_MSG_ERROR(
8917                    [Clang $CLANGVER is too old to build compiler plugins; need >= 12.0.1.])
8918            else
8919                compiler_plugins=no
8920            fi
8921        fi
8922    fi
8923    if test "$compiler_plugins" != "no"; then
8924        dnl The prefix where Clang resides, override to where Clang resides if
8925        dnl using a source build:
8926        if test -z "$CLANGDIR"; then
8927            CLANGDIR=$(dirname $(dirname $($CXX -print-prog-name=$(basename $(printf '%s\n' $CXX | grep clang | head -n 1)))))
8928        fi
8929        # Assume Clang is self-built, but allow overriding COMPILER_PLUGINS_CXX to the compiler Clang was built with.
8930        if test -z "$COMPILER_PLUGINS_CXX"; then
8931            COMPILER_PLUGINS_CXX=[$(echo $CXX | sed -e 's/-fsanitize=[^ ]*//g')]
8932        fi
8933        clangbindir=$CLANGDIR/bin
8934        if test "$build_os" = "cygwin"; then
8935            clangbindir=$(cygpath -u "$clangbindir")
8936        fi
8937        AC_PATH_PROG(LLVM_CONFIG, llvm-config,[],"$clangbindir" $PATH)
8938        if test -n "$LLVM_CONFIG"; then
8939            COMPILER_PLUGINS_CXXFLAGS=$($LLVM_CONFIG --cxxflags)
8940            COMPILER_PLUGINS_LINKFLAGS=$($LLVM_CONFIG --ldflags --libs --system-libs | tr '\n' ' ')
8941            if test -z "$CLANGLIBDIR"; then
8942                CLANGLIBDIR=$($LLVM_CONFIG --libdir)
8943            fi
8944            # Try if clang is built from source (in which case its includes are not together with llvm includes).
8945            # src-root is [llvm-toplevel-src-dir]/llvm, clang is [llvm-toplevel-src-dir]/clang
8946            if $LLVM_CONFIG --src-root >/dev/null 2>&1; then
8947                clangsrcdir=$(dirname $($LLVM_CONFIG --src-root))
8948                if test -n "$clangsrcdir" -a -d "$clangsrcdir" -a -d "$clangsrcdir/clang/include"; then
8949                    COMPILER_PLUGINS_CXXFLAGS="$COMPILER_PLUGINS_CXXFLAGS -I$clangsrcdir/clang/include"
8950                fi
8951            fi
8952            # obj-root is [llvm-toplevel-obj-dir]/, clang is [llvm-toplevel-obj-dir]/tools/clang
8953            clangobjdir=$($LLVM_CONFIG --obj-root)
8954            if test -n "$clangobjdir" -a -d "$clangobjdir" -a -d "$clangobjdir/tools/clang/include"; then
8955                COMPILER_PLUGINS_CXXFLAGS="$COMPILER_PLUGINS_CXXFLAGS -I$clangobjdir/tools/clang/include"
8956            fi
8957        fi
8958        AC_MSG_NOTICE([compiler plugins compile flags: $COMPILER_PLUGINS_CXXFLAGS])
8959        AC_LANG_PUSH([C++])
8960        save_CXX=$CXX
8961        save_CXXCPP=$CXXCPP
8962        save_CPPFLAGS=$CPPFLAGS
8963        save_CXXFLAGS=$CXXFLAGS
8964        save_LDFLAGS=$LDFLAGS
8965        save_LIBS=$LIBS
8966        CXX=$COMPILER_PLUGINS_CXX
8967        CXXCPP="$COMPILER_PLUGINS_CXX -E"
8968        CPPFLAGS="$COMPILER_PLUGINS_CXXFLAGS"
8969        CXXFLAGS="$COMPILER_PLUGINS_CXXFLAGS"
8970        AC_CHECK_HEADER(clang/Basic/SourceLocation.h,
8971            [COMPILER_PLUGINS=TRUE],
8972            [
8973            if test "$compiler_plugins" = "yes"; then
8974                AC_MSG_ERROR([Cannot find Clang headers to build compiler plugins.])
8975            else
8976                AC_MSG_WARN([Cannot find Clang headers to build compiler plugins, plugins disabled])
8977                add_warning "Cannot find Clang headers to build compiler plugins, plugins disabled."
8978            fi
8979            ])
8980        dnl TODO: Windows doesn't use LO_CLANG_SHARED_PLUGINS for now, see corresponding TODO
8981        dnl comment in compilerplugins/Makefile-clang.mk:
8982        if test -n "$COMPILER_PLUGINS" && test "$_os" != "WINNT"; then
8983            LDFLAGS=""
8984            AC_MSG_CHECKING([for clang libraries to use])
8985            if test -z "$CLANGTOOLLIBS"; then
8986                LIBS="-lclang-cpp $COMPILER_PLUGINS_LINKFLAGS"
8987                AC_LINK_IFELSE([
8988                    AC_LANG_PROGRAM([[#include "clang/Basic/SourceLocation.h"]],
8989                        [[ clang::FullSourceLoc().dump(); ]])
8990                ],[CLANGTOOLLIBS="$LIBS"],[])
8991            fi
8992            dnl If the above check for the combined -lclang-cpp failed, fall back to a hand-curated
8993            dnl list of individual -lclang* (but note that that list can become outdated over time,
8994            dnl see e.g. the since-reverted 5078591de9a0e65ca560a4f1913e90dfe95f66bf "CLANGTOOLLIBS
8995            dnl needs to include -lclangSupport now"):
8996            if test -z "$CLANGTOOLLIBS"; then
8997                LIBS="-lclangTooling -lclangFrontend -lclangDriver -lclangParse -lclangSema -lclangEdit \
8998 -lclangAnalysis -lclangAST -lclangLex -lclangSerialization -lclangBasic $COMPILER_PLUGINS_LINKFLAGS"
8999                AC_LINK_IFELSE([
9000                    AC_LANG_PROGRAM([[#include "clang/Basic/SourceLocation.h"]],
9001                        [[ clang::FullSourceLoc().dump(); ]])
9002                ],[CLANGTOOLLIBS="$LIBS"],[])
9003            fi
9004            AC_MSG_RESULT([$CLANGTOOLLIBS])
9005            if test -z "$CLANGTOOLLIBS"; then
9006                if test "$compiler_plugins" = "yes"; then
9007                    AC_MSG_ERROR([Cannot find Clang libraries to build compiler plugins.])
9008                else
9009                    AC_MSG_WARN([Cannot find Clang libraries to build compiler plugins, plugins disabled])
9010                    add_warning "Cannot find Clang libraries to build compiler plugins, plugins disabled."
9011                fi
9012                COMPILER_PLUGINS=
9013            fi
9014            if test -n "$COMPILER_PLUGINS"; then
9015                if test -z "$CLANGSYSINCLUDE"; then
9016                    if test -n "$LLVM_CONFIG"; then
9017                        # Path to the clang system headers (no idea if there's a better way to get it).
9018                        CLANGSYSINCLUDE=$($LLVM_CONFIG --libdir)/clang/$($LLVM_CONFIG --version | sed 's/git\|svn//')/include
9019                    fi
9020                fi
9021            fi
9022        fi
9023        CXX=$save_CXX
9024        CXXCPP=$save_CXXCPP
9025        CPPFLAGS=$save_CPPFLAGS
9026        CXXFLAGS=$save_CXXFLAGS
9027        LDFLAGS=$save_LDFLAGS
9028        LIBS="$save_LIBS"
9029        AC_LANG_POP([C++])
9030
9031        AC_MSG_CHECKING([whether the compiler for building compilerplugins is actually Clang])
9032        AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
9033            #ifndef __clang__
9034            you lose
9035            #endif
9036            int foo=42;
9037            ]])],
9038            [AC_MSG_RESULT([yes])
9039             COMPILER_PLUGINS_COM_IS_CLANG=TRUE],
9040            [AC_MSG_RESULT([no])])
9041        AC_SUBST(COMPILER_PLUGINS_COM_IS_CLANG)
9042    fi
9043else
9044    if test "$enable_compiler_plugins" = "yes"; then
9045        AC_MSG_ERROR([Compiler plugins are currently supported only with the Clang compiler.])
9046    fi
9047fi
9048COMPILER_PLUGINS_ANALYZER_PCH=
9049if test "$enable_compiler_plugins_analyzer_pch" != no; then
9050    COMPILER_PLUGINS_ANALYZER_PCH=TRUE
9051fi
9052AC_SUBST(COMPILER_PLUGINS)
9053AC_SUBST(COMPILER_PLUGINS_ANALYZER_PCH)
9054AC_SUBST(COMPILER_PLUGINS_COM_IS_CLANG)
9055AC_SUBST(COMPILER_PLUGINS_CXX)
9056AC_SUBST(COMPILER_PLUGINS_CXXFLAGS)
9057AC_SUBST(COMPILER_PLUGINS_CXX_LINKFLAGS)
9058AC_SUBST(COMPILER_PLUGINS_DEBUG)
9059AC_SUBST(COMPILER_PLUGINS_TOOLING_ARGS)
9060AC_SUBST(CLANGDIR)
9061AC_SUBST(CLANGLIBDIR)
9062AC_SUBST(CLANGTOOLLIBS)
9063AC_SUBST(CLANGSYSINCLUDE)
9064
9065# Plugin to help linker.
9066# Add something like LD_PLUGIN=/usr/lib64/LLVMgold.so to your autogen.input.
9067# This makes --enable-lto build with clang work.
9068AC_SUBST(LD_PLUGIN)
9069
9070AC_CHECK_FUNCS(posix_fallocate, HAVE_POSIX_FALLOCATE=YES, [HAVE_POSIX_FALLOCATE=NO])
9071AC_SUBST(HAVE_POSIX_FALLOCATE)
9072
9073JITC_PROCESSOR_TYPE=""
9074if test "$_os" = "Linux" -a "$host_cpu" = "powerpc"; then
9075    # IBMs JDK needs this...
9076    JITC_PROCESSOR_TYPE=6
9077    export JITC_PROCESSOR_TYPE
9078fi
9079AC_SUBST([JITC_PROCESSOR_TYPE])
9080
9081if test $_os = "WINNT"; then
9082    for i in $PKGFORMAT; do
9083        if test "$i" = msi; then
9084            dnl strip initial v from the version label found by find_msvc
9085            with_redist=${VCTOOLSET:1}
9086            find_msms "$with_redist"
9087            if test -n "$msmdir"; then
9088                MSM_PATH=`win_short_path_for_make "${msmdir%/}/"`
9089                SCPDEFS="$SCPDEFS -DWITH_VC_REDIST=$with_redist"
9090            fi
9091            break
9092        fi
9093    done
9094fi
9095
9096AC_SUBST(MSM_PATH)
9097
9098
9099dnl ===================================================================
9100dnl Checks for Java
9101dnl ===================================================================
9102if test "$ENABLE_JAVA" != ""; then
9103
9104    # Windows-specific tests
9105    if test "$build_os" = "cygwin" -o -n "$WSL_ONLY_AS_HELPER"; then
9106        if test -z "$with_jdk_home"; then
9107            dnl See <https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-EEED398E-AE37-4D12-
9108            dnl AB10-49F82F720027> section "Windows Registry Key Changes":
9109            reg_get_value "$WIN_HOST_BITS" "HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/JDK" "CurrentVersion"
9110            if test -n "$regvalue"; then
9111                ver=$regvalue
9112                reg_get_value "$WIN_HOST_BITS" "HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/JDK/$ver" "JavaHome"
9113                with_jdk_home=$regvalue
9114            fi
9115            howfound="found automatically"
9116        else
9117            howfound="you passed"
9118        fi
9119        PathFormat "$with_jdk_home"
9120        with_jdk_home="$formatted_path_unix"
9121
9122        if ! test -f "$with_jdk_home/lib/jvm.lib" -a -f "$with_jdk_home/bin/java.exe"; then
9123            AC_MSG_ERROR([No JDK found, pass the --with-jdk-home option (or fix the path) pointing to a $WIN_HOST_BITS-bit JDK >= 8])
9124        fi
9125        with_java="java.exe"
9126        javacompiler="javac.exe"
9127        javadoc="javadoc.exe"
9128    fi
9129
9130    # 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.
9131    # /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java, but /usr does not contain the JDK libraries
9132    if test -z "$with_jdk_home" -a "$_os" = "Darwin" -a -x /usr/libexec/java_home; then
9133        with_jdk_home=`/usr/libexec/java_home`
9134    fi
9135
9136    JAVA_HOME=; export JAVA_HOME
9137    if test -z "$with_jdk_home"; then
9138        AC_PATH_PROG(JAVAINTERPRETER, $with_java)
9139    else
9140        _java_path="$with_jdk_home/bin/$with_java"
9141        dnl Check if there is a Java interpreter at all.
9142        if test -x "$_java_path"; then
9143            JAVAINTERPRETER=$_java_path
9144        else
9145            AC_MSG_ERROR([$_java_path not found, pass --with-jdk-home])
9146        fi
9147    fi
9148
9149    dnl Check that the JDK found is correct architecture (at least 2 reasons to
9150    dnl check: officebean needs to link -ljawt, and libjpipe.so needs to be
9151    dnl loaded by java to run JunitTests:
9152    if test "$build_os" = "cygwin" -a "$cross_compiling" != "yes"; then
9153        shortjdkhome=`cygpath -d "$with_jdk_home"`
9154        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
9155            AC_MSG_WARN([You are building 64-bit binaries but the JDK $howfound is 32-bit])
9156            AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a 64-bit JDK])
9157        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
9158            AC_MSG_WARN([You are building 32-bit binaries but the JDK $howfound is 64-bit])
9159            AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a (32-bit) JDK])
9160        fi
9161
9162        if test x`echo "$JAVAINTERPRETER" | $GREP -i '\.exe$'` = x; then
9163            JAVAINTERPRETER="${JAVAINTERPRETER}.exe"
9164        fi
9165        JAVAINTERPRETER=`win_short_path_for_make "$JAVAINTERPRETER"`
9166    elif test "$cross_compiling" != "yes"; then
9167        case $CPUNAME in
9168            AARCH64|AXP|X86_64|IA64|POWERPC64|S390X|SPARC64|MIPS64|RISCV64|LOONGARCH64)
9169                if test -f "$JAVAINTERPRETER" -a "`$JAVAINTERPRETER -version 2>&1 | $GREP -i 64-bit`" = "" >/dev/null; then
9170                    AC_MSG_WARN([You are building 64-bit binaries but the JDK $JAVAINTERPRETER is 32-bit])
9171                    AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a 64-bit JDK])
9172                fi
9173                ;;
9174            *) # assumption: everything else 32-bit
9175                if test -f "$JAVAINTERPRETER" -a "`$JAVAINTERPRETER -version 2>&1 | $GREP -i 64-bit`" != ""  >/dev/null; then
9176                    AC_MSG_WARN([You are building 32-bit binaries but the JDK $howfound is 64-bit])
9177                    AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a (32-bit) JDK])
9178                fi
9179                ;;
9180        esac
9181    fi
9182fi
9183
9184dnl ===================================================================
9185dnl Checks for JDK.
9186dnl ===================================================================
9187
9188# Whether all the complexity here actually is needed any more or not, no idea.
9189
9190JDK_SECURITYMANAGER_DISALLOWED=
9191MODULAR_JAVA=
9192if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then
9193    _gij_longver=0
9194    AC_MSG_CHECKING([the installed JDK])
9195    if test -n "$JAVAINTERPRETER"; then
9196        dnl java -version sends output to stderr!
9197        if test `$JAVAINTERPRETER -version 2>&1 | $GREP -c "Kaffe"` -gt 0; then
9198            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
9199        elif test `$JAVAINTERPRETER --version 2>&1 | $GREP -c "GNU libgcj"` -gt 0; then
9200            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
9201        elif test `$JAVAINTERPRETER -version 2>&1 | $AWK '{ print }' | $GREP -c "BEA"` -gt 0; then
9202            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
9203        elif test `$JAVAINTERPRETER -version 2>&1 | $AWK '{ print }' | $GREP -c "IBM"` -gt 0; then
9204            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
9205        else
9206            JDK=sun
9207
9208            dnl Sun JDK specific tests
9209            _jdk=`$JAVAINTERPRETER -version 2>&1 | $AWK -F'"' '{ print \$2 }' | $SED '/^$/d' | $SED s/[[-A-Za-z]]*//`
9210            _jdk_ver=`echo "$_jdk" | $AWK -F. '{ print (($1 * 100) + $2) * 100 + $3;}'`
9211
9212            if test "$_jdk_ver" -lt 10800; then
9213                AC_MSG_ERROR([JDK is too old, you need at least 8 ($_jdk_ver < 10800)])
9214            fi
9215            dnl The Security Manager is disallowed since Java 18 (see
9216            dnl <https://openjdk.java.net/jeps/411> "Deprecate the Security Manager for Removal")
9217            dnl and completely removed since Java 24 (see
9218            dnl <https://openjdk.org/jeps/486> "JEP 486: Permanently Disable the Security Manager"):
9219            if test "$_jdk_ver" -ge 180000 && test "$_jdk_ver" -lt 240000; then
9220                JDK_SECURITYMANAGER_DISALLOWED=TRUE
9221            fi
9222
9223            JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*java,,p"`
9224            if test "$_os" = "WINNT"; then
9225                JAVA_HOME=`echo $JAVA_HOME | $SED "s,\.[[eE]][[xX]][[eE]]$,,"`
9226            fi
9227            AC_MSG_RESULT([found $JAVA_HOME (JDK $_jdk)])
9228
9229            dnl Check whether the build Java supports modules
9230            if test "$_jdk_ver" -ge 90000; then
9231                MODULAR_JAVA=TRUE
9232            else
9233                AC_MSG_WARN([Modular jars will not be built. They need at least Java 9 ($_jdk_ver < 90000)])
9234                add_warning "Modular jars will not be built. They need at least Java 9 ($_jdk_ver < 90000)"
9235            fi
9236
9237            # set to limit VM usage for JunitTests
9238            JAVAIFLAGS=-Xmx64M
9239            # set to limit VM usage for javac
9240            JAVACFLAGS=-J-Xmx128M
9241        fi
9242    else
9243        AC_MSG_ERROR([Java not found. You need at least JDK 8])
9244    fi
9245else
9246    if test -z "$ENABLE_JAVA"; then
9247        dnl Java disabled
9248        JAVA_HOME=
9249        export JAVA_HOME
9250    elif test "$cross_compiling" = "yes"; then
9251        # Just assume compatibility of build and host JDK
9252        JDK=$JDK_FOR_BUILD
9253        JAVAIFLAGS=$JAVAIFLAGS_FOR_BUILD
9254    fi
9255fi
9256
9257dnl ===================================================================
9258dnl Checks for javac
9259dnl ===================================================================
9260if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then
9261    : ${JAVA_SOURCE_VER=8}
9262    : ${JAVA_TARGET_VER=8}
9263    if test -z "$with_jdk_home"; then
9264        AC_PATH_PROG(JAVACOMPILER, $javacompiler)
9265    else
9266        _javac_path="$with_jdk_home/bin/$javacompiler"
9267        dnl Check if there is a Java compiler at all.
9268        if test -x "$_javac_path"; then
9269            JAVACOMPILER=$_javac_path
9270        fi
9271    fi
9272    if test -z "$JAVACOMPILER"; then
9273        AC_MSG_ERROR([$javacompiler not found set with_jdk_home])
9274    fi
9275    if test "$build_os" = "cygwin"; then
9276        if test x`echo "$JAVACOMPILER" | $GREP -i '\.exe$'` = x; then
9277            JAVACOMPILER="${JAVACOMPILER}.exe"
9278        fi
9279        JAVACOMPILER=`win_short_path_for_make "$JAVACOMPILER"`
9280    fi
9281fi
9282
9283dnl ===================================================================
9284dnl Checks for javadoc
9285dnl ===================================================================
9286if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then
9287    if test -z "$with_jdk_home"; then
9288        AC_PATH_PROG(JAVADOC, $javadoc)
9289    else
9290        _javadoc_path="$with_jdk_home/bin/$javadoc"
9291        dnl Check if there is a javadoc at all.
9292        if test -x "$_javadoc_path"; then
9293            JAVADOC=$_javadoc_path
9294        else
9295            AC_PATH_PROG(JAVADOC, $javadoc)
9296        fi
9297    fi
9298    if test -z "$JAVADOC"; then
9299        AC_MSG_ERROR([$_javadoc_path not found set with_jdk_home])
9300    fi
9301    if test "$build_os" = "cygwin"; then
9302        if test x`echo "$JAVADOC" | $GREP -i '\.exe$'` = x; then
9303            JAVADOC="${JAVADOC}.exe"
9304        fi
9305        JAVADOC=`win_short_path_for_make "$JAVADOC"`
9306    fi
9307
9308    if test `$JAVADOC --version 2>&1 | $GREP -c "gjdoc"` -gt 0; then
9309    JAVADOCISGJDOC="yes"
9310    fi
9311fi
9312AC_SUBST(JAVADOC)
9313AC_SUBST(JAVADOCISGJDOC)
9314
9315if test "$ENABLE_JAVA" != "" -a \( "$cross_compiling" != "yes" -o -n "$with_jdk_home" \); then
9316    # check if JAVA_HOME was (maybe incorrectly?) set automatically to /usr
9317    if test "$JAVA_HOME" = "/usr" -a "x$with_jdk_home" = "x"; then
9318        if basename $(readlink $(readlink $JAVACOMPILER)) >/dev/null 2>/dev/null; then
9319           # try to recover first by looking whether we have an alternative
9320           # system as in Debian or newer SuSEs where following /usr/bin/javac
9321           # over /etc/alternatives/javac leads to the right bindir where we
9322           # just need to strip a bit away to get a valid JAVA_HOME
9323           JAVA_HOME=$(readlink $(readlink $JAVACOMPILER))
9324        elif readlink $JAVACOMPILER >/dev/null 2>/dev/null; then
9325            # maybe only one level of symlink (e.g. on Mac)
9326            JAVA_HOME=$(readlink $JAVACOMPILER)
9327            if test "$(dirname $JAVA_HOME)" = "."; then
9328                # we've got no path to trim back
9329                JAVA_HOME=""
9330            fi
9331        else
9332            # else warn
9333            AC_MSG_WARN([JAVA_HOME is set to /usr - this is very likely to be incorrect])
9334            AC_MSG_WARN([if this is the case, please inform the correct JAVA_HOME with --with-jdk-home])
9335            add_warning "JAVA_HOME is set to /usr - this is very likely to be incorrect"
9336            add_warning "if this is the case, please inform the correct JAVA_HOME with --with-jdk-home"
9337        fi
9338        dnl now that we probably have the path to the real javac, make a JAVA_HOME out of it...
9339        if test "$JAVA_HOME" != "/usr"; then
9340            if test "$_os" = "Darwin" -o "$OS_FOR_BUILD" = MACOSX; then
9341                dnl Leopard returns a non-suitable path with readlink - points to "Current" only
9342                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/Current/Commands/javac$,/CurrentJDK/Home,)
9343                dnl Tiger already returns a JDK path...
9344                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/CurrentJDK/Commands/javac$,/CurrentJDK/Home,)
9345            else
9346                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/bin/javac$,,)
9347                dnl check that we have a directory as certain distros eg gentoo substitute javac for a script
9348                dnl that checks which version to run
9349                if test -f "$JAVA_HOME"; then
9350                    JAVA_HOME=""; # set JAVA_HOME to null if it's a file
9351                fi
9352            fi
9353        fi
9354    fi
9355    # as we drop out of this, JAVA_HOME may have been set to the empty string by readlink
9356
9357    dnl now if JAVA_HOME has been set to empty, then call findhome to find it
9358    if test -z "$JAVA_HOME"; then
9359        if test "x$with_jdk_home" = "x"; then
9360            cat > findhome.java <<_ACEOF
9361[import java.io.File;
9362
9363class findhome
9364{
9365    public static void main(String args[])
9366    {
9367        String jrelocation = System.getProperty("java.home");
9368        File jre = new File(jrelocation);
9369        System.out.println(jre.getParent());
9370    }
9371}]
9372_ACEOF
9373            AC_MSG_CHECKING([if javac works])
9374            javac_cmd="$JAVACOMPILER findhome.java 1>&2"
9375            AC_TRY_EVAL(javac_cmd)
9376            if test $? = 0 -a -f ./findhome.class; then
9377                AC_MSG_RESULT([javac works])
9378            else
9379                echo "configure: javac test failed" >&5
9380                cat findhome.java >&5
9381                AC_MSG_ERROR([javac does not work - java projects will not build!])
9382            fi
9383            AC_MSG_CHECKING([if gij knows its java.home])
9384            JAVA_HOME=`$JAVAINTERPRETER findhome`
9385            if test $? = 0 -a "$JAVA_HOME" != ""; then
9386                AC_MSG_RESULT([$JAVA_HOME])
9387            else
9388                echo "configure: java test failed" >&5
9389                cat findhome.java >&5
9390                AC_MSG_ERROR([gij does not know its java.home - use --with-jdk-home])
9391            fi
9392            # clean-up after ourselves
9393            rm -f ./findhome.java ./findhome.class
9394        else
9395            JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*$with_java,,p"`
9396        fi
9397    fi
9398
9399    # now check if $JAVA_HOME is really valid
9400    if test "$_os" = "Darwin" -o "$OS_FOR_BUILD" = MACOSX; then
9401        if test ! -f "$JAVA_HOME/lib/jvm.cfg" -a "x$with_jdk_home" = "x"; then
9402            AC_MSG_WARN([JAVA_HOME was not explicitly informed with --with-jdk-home. the configure script])
9403            AC_MSG_WARN([attempted to find JAVA_HOME automatically, but apparently it failed])
9404            AC_MSG_WARN([in case JAVA_HOME is incorrectly set, some projects will not be built correctly])
9405            add_warning "JAVA_HOME was not explicitly informed with --with-jdk-home. the configure script"
9406            add_warning "attempted to find JAVA_HOME automatically, but apparently it failed"
9407            add_warning "in case JAVA_HOME is incorrectly set, some projects will not be built correctly"
9408        fi
9409    fi
9410    PathFormat "$JAVA_HOME"
9411    JAVA_HOME="$formatted_path_unix"
9412fi
9413
9414if test -z "$JAWTLIB" -a -n "$ENABLE_JAVA" -a "$_os" != Android -a \
9415    "$_os" != Darwin
9416then
9417    AC_MSG_CHECKING([for JAWT lib])
9418    if test "$_os" = WINNT; then
9419        # The path to $JAVA_HOME/lib/$JAWTLIB is part of $ILIB:
9420        JAWTLIB=jawt.lib
9421    else
9422        case "$host_cpu" in
9423        arm*)
9424            AS_IF([test -e "$JAVA_HOME/jre/lib/aarch32/libjawt.so"], [my_java_arch=aarch32], [my_java_arch=arm])
9425            JAVA_ARCH=$my_java_arch
9426            ;;
9427        i*86)
9428            my_java_arch=i386
9429            ;;
9430        m68k)
9431            my_java_arch=m68k
9432            ;;
9433        powerpc)
9434            my_java_arch=ppc
9435            ;;
9436        powerpc64)
9437            my_java_arch=ppc64
9438            ;;
9439        powerpc64le)
9440            AS_IF([test -e "$JAVA_HOME/jre/lib/ppc64le/libjawt.so"], [my_java_arch=ppc64le], [my_java_arch=ppc64])
9441            JAVA_ARCH=$my_java_arch
9442            ;;
9443        sparc64)
9444            my_java_arch=sparcv9
9445            ;;
9446        x86_64)
9447            my_java_arch=amd64
9448            ;;
9449        *)
9450            my_java_arch=$host_cpu
9451            ;;
9452        esac
9453        # This is where JDK9 puts the library
9454        if test -e "$JAVA_HOME/lib/libjawt.so"; then
9455            JAWTLIB="-L$JAVA_HOME/lib/ -ljawt"
9456        else
9457            JAWTLIB="-L$JAVA_HOME/jre/lib/$my_java_arch -ljawt"
9458        fi
9459        AS_IF([test "$JAVA_ARCH" != ""], [AC_DEFINE_UNQUOTED([JAVA_ARCH], ["$JAVA_ARCH"])])
9460    fi
9461    AC_MSG_RESULT([$JAWTLIB])
9462fi
9463AC_SUBST(JAWTLIB)
9464
9465if test -n "$ENABLE_JAVA" -a -z "$JAVAINC"; then
9466    case "$host_os" in
9467
9468    cygwin*|wsl*)
9469        JAVAINC="-I$JAVA_HOME/include/win32"
9470        JAVAINC="$JAVAINC -I$JAVA_HOME/include"
9471        ;;
9472
9473    darwin*)
9474        if test -d "$JAVA_HOME/include/darwin"; then
9475            JAVAINC="-I$JAVA_HOME/include  -I$JAVA_HOME/include/darwin"
9476        else
9477            JAVAINC=${ISYSTEM}$FRAMEWORKSHOME/JavaVM.framework/Versions/Current/Headers
9478        fi
9479        ;;
9480
9481    dragonfly*)
9482        JAVAINC="-I$JAVA_HOME/include"
9483        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
9484        ;;
9485
9486    freebsd*)
9487        JAVAINC="-I$JAVA_HOME/include"
9488        JAVAINC="$JAVAINC -I$JAVA_HOME/include/freebsd"
9489        JAVAINC="$JAVAINC -I$JAVA_HOME/include/bsd"
9490        JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux"
9491        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
9492        ;;
9493
9494    k*bsd*-gnu*)
9495        JAVAINC="-I$JAVA_HOME/include"
9496        JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux"
9497        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
9498        ;;
9499
9500    linux-gnu*)
9501        JAVAINC="-I$JAVA_HOME/include"
9502        JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux"
9503        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
9504        ;;
9505
9506    *netbsd*)
9507        JAVAINC="-I$JAVA_HOME/include"
9508        JAVAINC="$JAVAINC -I$JAVA_HOME/include/netbsd"
9509        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
9510       ;;
9511
9512    openbsd*)
9513        JAVAINC="-I$JAVA_HOME/include"
9514        JAVAINC="$JAVAINC -I$JAVA_HOME/include/openbsd"
9515        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
9516        ;;
9517
9518    solaris*)
9519        JAVAINC="-I$JAVA_HOME/include"
9520        JAVAINC="$JAVAINC -I$JAVA_HOME/include/solaris"
9521        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
9522        ;;
9523    esac
9524fi
9525SOLARINC="$SOLARINC $JAVAINC"
9526
9527if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then
9528    JAVA_HOME_FOR_BUILD=$JAVA_HOME
9529    JAVAIFLAGS_FOR_BUILD=$JAVAIFLAGS
9530    JDK_FOR_BUILD=$JDK
9531    JDK_SECURITYMANAGER_DISALLOWED_FOR_BUILD=$JDK_SECURITYMANAGER_DISALLOWED
9532fi
9533
9534AC_SUBST(JAVACFLAGS)
9535AC_SUBST(JAVACOMPILER)
9536AC_SUBST(JAVAINTERPRETER)
9537AC_SUBST(JAVAIFLAGS)
9538AC_SUBST(JAVAIFLAGS_FOR_BUILD)
9539AC_SUBST(JAVA_HOME)
9540AC_SUBST(JAVA_HOME_FOR_BUILD)
9541AC_SUBST(JDK)
9542AC_SUBST(JDK_FOR_BUILD)
9543AC_SUBST(JDK_SECURITYMANAGER_DISALLOWED_FOR_BUILD)
9544AC_SUBST(JAVA_SOURCE_VER)
9545AC_SUBST(JAVA_TARGET_VER)
9546AC_SUBST(MODULAR_JAVA)
9547
9548
9549dnl ===================================================================
9550dnl Export file validation
9551dnl ===================================================================
9552AC_MSG_CHECKING([whether to enable export file validation])
9553if test "$with_export_validation" != "no"; then
9554    if test -z "$ENABLE_JAVA"; then
9555        if test "$with_export_validation" = "yes"; then
9556            AC_MSG_ERROR([requested, but Java is disabled])
9557        else
9558            AC_MSG_RESULT([no, as Java is disabled])
9559        fi
9560    elif ! test -d "${SRC_ROOT}/schema"; then
9561        if test "$with_export_validation" = "yes"; then
9562            AC_MSG_ERROR([requested, but schema directory is missing (it is excluded from tarballs)])
9563        else
9564            AC_MSG_RESULT([no, schema directory is missing (it is excluded from tarballs)])
9565        fi
9566    else
9567        AC_MSG_RESULT([yes])
9568        AC_DEFINE(HAVE_EXPORT_VALIDATION)
9569
9570        AC_PATH_PROGS(ODFVALIDATOR, odfvalidator)
9571        if test -z "$ODFVALIDATOR"; then
9572            # remember to download the ODF toolkit with validator later
9573            AC_MSG_NOTICE([no odfvalidator found, will download it])
9574            BUILD_TYPE="$BUILD_TYPE ODFVALIDATOR"
9575            ODFVALIDATOR="$BUILDDIR/bin/odfvalidator.sh"
9576
9577            # and fetch name of odfvalidator jar name from download.lst
9578            ODFVALIDATOR_JAR=`$SED -n -e "s/^ODFVALIDATOR_JAR *:= *\(.*\) */\1/p" $SRC_ROOT/download.lst`
9579            AC_SUBST(ODFVALIDATOR_JAR)
9580
9581            if test -z "$ODFVALIDATOR_JAR"; then
9582                AC_MSG_ERROR([cannot determine odfvalidator jar location (--with-export-validation)])
9583            fi
9584        fi
9585        if test "$build_os" = "cygwin"; then
9586            # In case of Cygwin it will be executed from Windows,
9587            # so we need to run bash and absolute path to validator
9588            # so instead of "odfvalidator" it will be
9589            # something like "bash.exe C:\cygwin\opt\lo\bin\odfvalidator"
9590            ODFVALIDATOR="bash.exe `cygpath -m "$ODFVALIDATOR"`"
9591        else
9592            ODFVALIDATOR="sh $ODFVALIDATOR"
9593        fi
9594        AC_SUBST(ODFVALIDATOR)
9595
9596
9597        AC_PATH_PROGS(OFFICEOTRON, officeotron)
9598        if test -z "$OFFICEOTRON"; then
9599            # remember to download the officeotron with validator later
9600            AC_MSG_NOTICE([no officeotron found, will download it])
9601            BUILD_TYPE="$BUILD_TYPE OFFICEOTRON"
9602            OFFICEOTRON="$BUILDDIR/bin/officeotron.sh"
9603
9604            # and fetch name of officeotron jar name from download.lst
9605            OFFICEOTRON_JAR=`$SED -n -e "s/^OFFICEOTRON_JAR *:= *\(.*\) */\1/p" $SRC_ROOT/download.lst`
9606            AC_SUBST(OFFICEOTRON_JAR)
9607
9608            if test -z "$OFFICEOTRON_JAR"; then
9609                AC_MSG_ERROR([cannot determine officeotron jar location (--with-export-validation)])
9610            fi
9611        else
9612            # check version of existing officeotron
9613            OFFICEOTRON_VER=`$OFFICEOTRON --version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
9614            if test 0"$OFFICEOTRON_VER" -lt 704; then
9615                AC_MSG_ERROR([officeotron too old])
9616            fi
9617        fi
9618        if test "$build_os" = "cygwin"; then
9619            # In case of Cygwin it will be executed from Windows,
9620            # so we need to run bash and absolute path to validator
9621            # so instead of "odfvalidator" it will be
9622            # something like "bash.exe C:\cygwin\opt\lo\bin\odfvalidator"
9623            OFFICEOTRON="bash.exe `cygpath -m "$OFFICEOTRON"`"
9624        else
9625            OFFICEOTRON="sh $OFFICEOTRON"
9626        fi
9627    fi
9628    AC_SUBST(OFFICEOTRON)
9629else
9630    AC_MSG_RESULT([no])
9631fi
9632
9633AC_MSG_CHECKING([for Microsoft Binary File Format Validator])
9634if test "$with_bffvalidator" != "no"; then
9635    AC_DEFINE(HAVE_BFFVALIDATOR)
9636
9637    if test "$with_export_validation" = "no"; then
9638        AC_MSG_ERROR([Please enable export validation (-with-export-validation)!])
9639    fi
9640
9641    if test "$with_bffvalidator" = "yes"; then
9642        BFFVALIDATOR=`win_short_path_for_make "$PROGRAMFILES/Microsoft Office/BFFValidator/BFFValidator.exe"`
9643    else
9644        BFFVALIDATOR="$with_bffvalidator"
9645    fi
9646
9647    if test "$build_os" = "cygwin"; then
9648        if test -n "$BFFVALIDATOR" -a -e "`cygpath $BFFVALIDATOR`"; then
9649            AC_MSG_RESULT($BFFVALIDATOR)
9650        else
9651            AC_MSG_ERROR([bffvalidator not found, but required by --with-bffvalidator])
9652        fi
9653    elif test -n "$BFFVALIDATOR"; then
9654        # We are not in Cygwin but need to run Windows binary with wine
9655        AC_PATH_PROGS(WINE, wine)
9656
9657        # so swap in a shell wrapper that converts paths transparently
9658        BFFVALIDATOR_EXE="$BFFVALIDATOR"
9659        BFFVALIDATOR="sh $BUILDDIR/bin/bffvalidator.sh"
9660        AC_SUBST(BFFVALIDATOR_EXE)
9661        AC_MSG_RESULT($BFFVALIDATOR)
9662    else
9663        AC_MSG_ERROR([bffvalidator not found, but required by --with-bffvalidator])
9664    fi
9665    AC_SUBST(BFFVALIDATOR)
9666else
9667    AC_MSG_RESULT([no])
9668fi
9669
9670dnl ===================================================================
9671dnl Check for epm (not needed for Windows)
9672dnl ===================================================================
9673AC_MSG_CHECKING([whether to enable EPM for packing])
9674if test "$enable_epm" = "yes"; then
9675    AC_MSG_RESULT([yes])
9676    if test "$_os" != "WINNT"; then
9677        if test $_os = Darwin; then
9678            EPM=internal
9679        elif test -n "$with_epm"; then
9680            EPM=$with_epm
9681        else
9682            AC_PATH_PROG(EPM, epm, no)
9683        fi
9684        if test "$EPM" = "no" -o "$EPM" = "internal"; then
9685            AC_MSG_NOTICE([EPM will be built.])
9686            BUILD_TYPE="$BUILD_TYPE EPM"
9687            EPM=${WORKDIR}/UnpackedTarball/epm/epm
9688        else
9689            # Gentoo has some epm which is something different...
9690            AC_MSG_CHECKING([whether the found epm is the right epm])
9691            if $EPM | grep "ESP Package Manager" >/dev/null 2>/dev/null; then
9692                AC_MSG_RESULT([yes])
9693            else
9694                AC_MSG_ERROR([no. Install ESP Package Manager (https://jimjag.github.io/epm/) and/or specify the path to the right epm])
9695            fi
9696            AC_MSG_CHECKING([epm version])
9697            EPM_VERSION=`$EPM | grep 'ESP Package Manager' | cut -d' ' -f4 | $SED -e s/v//`
9698            if test "`echo $EPM_VERSION | cut -d'.' -f1`" -gt "3" || \
9699               test "`echo $EPM_VERSION | cut -d'.' -f1`" -eq "3" -a "`echo $EPM_VERSION | cut -d'.' -f2`" -ge "7"; then
9700                AC_MSG_RESULT([OK, >= 3.7])
9701            else
9702                AC_MSG_RESULT([too old. epm >= 3.7 is required.])
9703                AC_MSG_ERROR([Install ESP Package Manager (https://jimjag.github.io/epm/) and/or specify the path to the right epm])
9704            fi
9705        fi
9706    fi
9707
9708    if echo "$PKGFORMAT" | $EGREP rpm 2>&1 >/dev/null; then
9709        AC_MSG_CHECKING([for rpm])
9710        for a in "$RPM" rpmbuild rpm; do
9711            $a --usage >/dev/null 2> /dev/null
9712            if test $? -eq 0; then
9713                RPM=$a
9714                break
9715            else
9716                $a --version >/dev/null 2> /dev/null
9717                if test $? -eq 0; then
9718                    RPM=$a
9719                    break
9720                fi
9721            fi
9722        done
9723        if test -z "$RPM"; then
9724            AC_MSG_ERROR([not found])
9725        elif "$RPM" --help 2>&1 | $EGREP buildroot >/dev/null; then
9726            RPM_PATH=`command -v $RPM`
9727            AC_MSG_RESULT([$RPM_PATH])
9728            SCPDEFS="$SCPDEFS -DWITH_RPM"
9729        else
9730            AC_MSG_ERROR([cannot build packages. Try installing rpmbuild.])
9731        fi
9732    fi
9733    if echo "$PKGFORMAT" | $EGREP deb 2>&1 >/dev/null; then
9734        AC_PATH_PROG(DPKG, dpkg, no)
9735        if test "$DPKG" = "no"; then
9736            AC_MSG_ERROR([dpkg needed for deb creation. Install dpkg.])
9737        fi
9738    fi
9739    if echo "$PKGFORMAT" | $EGREP rpm 2>&1 >/dev/null || \
9740       echo "$PKGFORMAT" | $EGREP pkg 2>&1 >/dev/null; then
9741        if test "$with_epm" = "no" -a "$_os" != "Darwin"; then
9742            if test "`echo $EPM_VERSION | cut -d'.' -f1`" -lt "4"; then
9743                AC_MSG_CHECKING([whether epm is patched for LibreOffice's needs])
9744                if grep "Patched for .*Office" $EPM >/dev/null 2>/dev/null; then
9745                    AC_MSG_RESULT([yes])
9746                else
9747                    AC_MSG_RESULT([no])
9748                    if echo "$PKGFORMAT" | $GREP -q rpm; then
9749                        _pt="rpm"
9750                        AC_MSG_WARN([the rpms will need to be installed with --nodeps])
9751                        add_warning "the rpms will need to be installed with --nodeps"
9752                    else
9753                        _pt="pkg"
9754                    fi
9755                    AC_MSG_WARN([the ${_pt}s will not be relocatable])
9756                    add_warning "the ${_pt}s will not be relocatable"
9757                    AC_MSG_WARN([if you want to make sure installation without --nodeps and
9758                                 relocation will work, you need to patch your epm with the
9759                                 patch in epm/epm-3.7.patch or build with
9760                                 --with-epm=internal which will build a suitable epm])
9761                fi
9762            fi
9763        fi
9764    fi
9765    if echo "$PKGFORMAT" | $EGREP pkg 2>&1 >/dev/null; then
9766        AC_PATH_PROG(PKGMK, pkgmk, no)
9767        if test "$PKGMK" = "no"; then
9768            AC_MSG_ERROR([pkgmk needed for Solaris pkg creation. Install it.])
9769        fi
9770    fi
9771    AC_SUBST(RPM)
9772    AC_SUBST(DPKG)
9773    AC_SUBST(PKGMK)
9774else
9775    for i in $PKGFORMAT; do
9776        case "$i" in
9777        bsd | deb | pkg | rpm | native | portable)
9778            AC_MSG_ERROR(
9779                [--with-package-format='$PKGFORMAT' requires --enable-epm])
9780            ;;
9781        esac
9782    done
9783    AC_MSG_RESULT([no])
9784    EPM=NO
9785fi
9786AC_SUBST(EPM)
9787
9788ENABLE_LWP=
9789if test "$enable_lotuswordpro" = "yes"; then
9790    ENABLE_LWP="TRUE"
9791fi
9792AC_SUBST(ENABLE_LWP)
9793
9794dnl ===================================================================
9795dnl Check for building ODK
9796dnl ===================================================================
9797AC_MSG_CHECKING([whether to build the ODK])
9798if test "$enable_odk" = yes; then
9799    if test "$DISABLE_DYNLOADING" = TRUE; then
9800        AC_MSG_ERROR([can't build ODK for --disable-dynamic-loading builds])
9801    fi
9802    AC_MSG_RESULT([yes])
9803    BUILD_TYPE="$BUILD_TYPE ODK"
9804else
9805    AC_MSG_RESULT([no])
9806fi
9807
9808if test "$enable_odk" != yes; then
9809    unset DOXYGEN
9810else
9811    if test "$with_doxygen" = no; then
9812        AC_MSG_CHECKING([for doxygen])
9813        unset DOXYGEN
9814        AC_MSG_RESULT([no])
9815    else
9816        if test "$with_doxygen" = yes; then
9817            AC_PATH_PROG([DOXYGEN], [doxygen])
9818            if test -z "$DOXYGEN"; then
9819                AC_MSG_ERROR([doxygen not found in \$PATH; specify its pathname via --with-doxygen=..., or disable its use via --without-doxygen])
9820            fi
9821            if $DOXYGEN -g - | grep -q "HAVE_DOT *= *YES"; then
9822                if ! dot -V 2>/dev/null; then
9823                    AC_MSG_ERROR([dot not found in \$PATH but doxygen defaults to HAVE_DOT=YES; install graphviz or disable its use via --without-doxygen])
9824                fi
9825            fi
9826        else
9827            AC_MSG_CHECKING([for doxygen])
9828            PathFormat "$with_doxygen"
9829            DOXYGEN="$formatted_path_unix"
9830            AC_MSG_RESULT([$formatted_path])
9831        fi
9832        if test -n "$DOXYGEN"; then
9833            DOXYGEN_VERSION=`$DOXYGEN --version 2>/dev/null`
9834            DOXYGEN_NUMVERSION=`echo $DOXYGEN_VERSION | $AWK -F. '{ print \$1*10000 + \$2*100 + \$3 }'`
9835            if ! test "$DOXYGEN_NUMVERSION" -ge "10804" ; then
9836                AC_MSG_ERROR([found doxygen is too old; need at least version 1.8.4 or specify --without-doxygen])
9837            fi
9838        fi
9839        if test -n "$WSL_ONLY_AS_HELPER"; then
9840            dnl what really should be tested is whether it is doxygen from windows-realm
9841            dnl i.e. one that runs on the windows-side and deals with windows-pathnames
9842            dnl using doxygen from wsl container would be possible, but there's a performance
9843            dnl penalty when accessing the files outside the container
9844            AC_MSG_CHECKING([whether doxygen is a windows executable])
9845            if $(file "$DOXYGEN" | grep -q "PE32"); then
9846                AC_MSG_RESULT([yes])
9847            else
9848                AC_MSG_RESULT([no])
9849                AC_MSG_ERROR([please provide a path to a windows version of doxygen or use --without-doxygen])
9850            fi
9851        fi
9852    fi
9853fi
9854AC_SUBST([DOXYGEN])
9855
9856dnl ==================================================================
9857dnl libfuzzer
9858dnl ==================================================================
9859AC_MSG_CHECKING([whether to enable fuzzers])
9860if test "$enable_fuzzers" != yes; then
9861    AC_MSG_RESULT([no])
9862else
9863    if test -z $LIB_FUZZING_ENGINE; then
9864      AC_MSG_ERROR(['LIB_FUZZING_ENGINE' must be set when using --enable-fuzzers. Examples include '-fsanitize=fuzzer'.])
9865    fi
9866    AC_MSG_RESULT([yes])
9867    ENABLE_FUZZERS="TRUE"
9868    AC_DEFINE([ENABLE_FUZZERS],1)
9869    BUILD_TYPE="$BUILD_TYPE FUZZERS"
9870fi
9871AC_SUBST(LIB_FUZZING_ENGINE)
9872
9873dnl ===================================================================
9874dnl Check for system zlib
9875dnl ===================================================================
9876if test "$with_system_zlib" = "auto"; then
9877    case "$_os" in
9878    WINNT)
9879        with_system_zlib="$with_system_libs"
9880        ;;
9881    *)
9882        if test "$enable_fuzzers" != "yes"; then
9883            with_system_zlib=yes
9884        else
9885            with_system_zlib=no
9886        fi
9887        ;;
9888    esac
9889fi
9890
9891dnl we want to use libo_CHECK_SYSTEM_MODULE here too, but macOS is too stupid
9892dnl and has no pkg-config for it at least on some tinderboxes,
9893dnl so leaving that out for now
9894dnl libo_CHECK_SYSTEM_MODULE([zlib],[ZLIB],[zlib])
9895AC_MSG_CHECKING([which zlib to use])
9896if test "$with_system_zlib" = "yes"; then
9897    AC_MSG_RESULT([external])
9898    SYSTEM_ZLIB=TRUE
9899    AC_CHECK_HEADER(zlib.h, [],
9900        [AC_MSG_ERROR(zlib.h not found. install zlib)], [])
9901    AC_CHECK_LIB(z, deflate, [ ZLIB_LIBS=-lz ],
9902        [AC_MSG_ERROR(zlib not found or functional)], [])
9903else
9904    AC_MSG_RESULT([internal])
9905    SYSTEM_ZLIB=
9906    BUILD_TYPE="$BUILD_TYPE ZLIB"
9907    ZLIB_CFLAGS="-I${WORKDIR}/UnpackedTarball/zlib"
9908    if test "$COM" = "MSC"; then
9909        ZLIB_LIBS='$(gb_StaticLibrary_WORKDIR)/zlib.lib'
9910    else
9911        ZLIB_LIBS='-L$(gb_StaticLibrary_WORKDIR) -lzlib'
9912    fi
9913fi
9914AC_SUBST(ZLIB_CFLAGS)
9915AC_SUBST(ZLIB_LIBS)
9916AC_SUBST(SYSTEM_ZLIB)
9917
9918dnl ===================================================================
9919dnl Check for system zstd
9920dnl ===================================================================
9921
9922if test "x$with_system_zstd" = "xauto"; then
9923  case "$_os" in
9924    WINNT) with_system_zstd="$with_system_libs" ;;  # follow system-libs on Windows
9925    *)     with_system_zstd="$with_system_libs" ;;  # follow system-libs on Unix
9926  esac
9927fi
9928
9929AC_MSG_CHECKING([which zstd to use])
9930case "$with_system_zstd" in
9931  yes)
9932    AC_MSG_RESULT([system])
9933    SYSTEM_ZSTD=TRUE
9934
9935    AC_CHECK_HEADER([zstd.h], [],
9936      [AC_MSG_ERROR([zstd.h not found. Install system zstd.])])
9937
9938    AC_CHECK_LIB([zstd], [ZSTD_createDStream],
9939      [ ZSTD_LIBS="-lzstd"
9940        ZSTD_CFLAGS="" ],
9941      [ AC_MSG_ERROR([system zstd library not found or broken.]) ])
9942    ;;
9943
9944  ""|no)
9945    AC_MSG_RESULT([bundled])
9946    SYSTEM_ZSTD=
9947    ZSTD_LIBS=""
9948    ZSTD_CFLAGS="-I\${WORKDIR}/UnpackedTarball/zstd/lib \
9949                 -I\${WORKDIR}/UnpackedTarball/zstd/lib/common \
9950                 -I\${WORKDIR}/UnpackedTarball/zstd/lib/decompress"
9951    BUILD_TYPE="$BUILD_TYPE ZSTD"
9952    ;;
9953
9954  *)
9955    AC_MSG_ERROR([Invalid value for --with-system-zstd: $with_system_zstd])
9956    ;;
9957esac
9958
9959AC_SUBST(SYSTEM_ZSTD)
9960AC_SUBST(ZSTD_LIBS)
9961AC_SUBST(ZSTD_CFLAGS)
9962AC_SUBST(BUILD_TYPE)
9963
9964dnl ===================================================================
9965dnl Check for system md4c
9966dnl ===================================================================
9967
9968if test "x$with_system_md4c" = "xauto"; then
9969  case "$_os" in
9970    WINNT) with_system_md4c="$with_system_libs" ;;  # follow system-libs on Windows
9971    *)     with_system_md4c="$with_system_libs" ;;  # follow system-libs on Unix
9972  esac
9973fi
9974
9975AC_MSG_CHECKING([which md4c to use])
9976case "$with_system_md4c" in
9977  yes)
9978    AC_MSG_RESULT([system])
9979    SYSTEM_MD4C=TRUE
9980
9981    AC_CHECK_HEADER([md4c.h], [],
9982      [AC_MSG_ERROR([md4c.h not found. Install system md4c.])])
9983
9984    AC_CHECK_LIB([md4c], [md_parse],
9985      [ MD4C_LIBS="-lmd4c"
9986        MD4C_CFLAGS="" ],
9987      [ AC_MSG_ERROR([system md4c library not found or broken.]) ])
9988    ;;
9989
9990  ""|no)
9991    AC_MSG_RESULT([bundled])
9992    SYSTEM_MD4C=
9993    MD4C_LIBS=""
9994    MD4C_CFLAGS="-I\${WORKDIR}/UnpackedTarball/md4c/src"
9995    BUILD_TYPE="$BUILD_TYPE MD4C"
9996    ;;
9997
9998  *)
9999    AC_MSG_ERROR([Invalid value for --with-system-md4c: $with_system_md4c])
10000    ;;
10001esac
10002
10003AC_SUBST(SYSTEM_MD4C)
10004AC_SUBST(MD4C_LIBS)
10005AC_SUBST(MD4C_CFLAGS)
10006AC_SUBST(BUILD_TYPE)
10007
10008dnl ===================================================================
10009dnl Check for system jpeg
10010dnl ===================================================================
10011AC_MSG_CHECKING([which libjpeg to use])
10012if test "$with_system_jpeg" = "yes"; then
10013    AC_MSG_RESULT([external])
10014    SYSTEM_LIBJPEG=TRUE
10015    AC_CHECK_HEADER(jpeglib.h, [ LIBJPEG_CFLAGS= ],
10016        [AC_MSG_ERROR(jpeg.h not found. install libjpeg)], [])
10017    AC_CHECK_LIB(jpeg, jpeg_resync_to_restart, [ LIBJPEG_LIBS="-ljpeg" ],
10018        [AC_MSG_ERROR(jpeg library not found or functional)], [])
10019else
10020    SYSTEM_LIBJPEG=
10021    AC_MSG_RESULT([internal, libjpeg-turbo])
10022    BUILD_TYPE="$BUILD_TYPE LIBJPEG_TURBO"
10023
10024    case "$host_cpu" in
10025    x86_64 | amd64 | i*86 | x86 | ia32)
10026        AC_CHECK_PROGS(NASM, [nasm nasmw yasm])
10027        if test -z "$NASM" -a "$build_os" = "cygwin"; then
10028            if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/nasm"; then
10029                NASM="$LODE_HOME/opt/bin/nasm"
10030            elif test -x "/opt/lo/bin/nasm"; then
10031                NASM="/opt/lo/bin/nasm"
10032            fi
10033        fi
10034
10035        if test -n "$NASM"; then
10036            AC_MSG_CHECKING([for object file format of host system])
10037            case "$host_os" in
10038              cygwin* | mingw* | pw32* | wsl*)
10039                case "$host_cpu" in
10040                  x86_64)
10041                    objfmt='Win64-COFF'
10042                    ;;
10043                  *)
10044                    objfmt='Win32-COFF'
10045                    ;;
10046                esac
10047              ;;
10048              msdosdjgpp* | go32*)
10049                objfmt='COFF'
10050              ;;
10051              os2-emx*) # not tested
10052                objfmt='MSOMF' # obj
10053              ;;
10054              linux*coff* | linux*oldld*)
10055                objfmt='COFF' # ???
10056              ;;
10057              linux*aout*)
10058                objfmt='a.out'
10059              ;;
10060              linux*)
10061                case "$host_cpu" in
10062                  x86_64)
10063                    objfmt='ELF64'
10064                    ;;
10065                  *)
10066                    objfmt='ELF'
10067                    ;;
10068                esac
10069              ;;
10070              kfreebsd* | freebsd* | netbsd* | openbsd*)
10071                if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
10072                  objfmt='BSD-a.out'
10073                else
10074                  case "$host_cpu" in
10075                    x86_64 | amd64)
10076                      objfmt='ELF64'
10077                      ;;
10078                    *)
10079                      objfmt='ELF'
10080                      ;;
10081                  esac
10082                fi
10083              ;;
10084              solaris* | sunos* | sysv* | sco*)
10085                case "$host_cpu" in
10086                  x86_64)
10087                    objfmt='ELF64'
10088                    ;;
10089                  *)
10090                    objfmt='ELF'
10091                    ;;
10092                esac
10093              ;;
10094              darwin* | rhapsody* | nextstep* | openstep* | macos*)
10095                case "$host_cpu" in
10096                  x86_64)
10097                    objfmt='Mach-O64'
10098                    ;;
10099                  *)
10100                    objfmt='Mach-O'
10101                    ;;
10102                esac
10103              ;;
10104              *)
10105                objfmt='ELF ?'
10106              ;;
10107            esac
10108
10109            AC_MSG_RESULT([$objfmt])
10110            if test "$objfmt" = 'ELF ?'; then
10111              objfmt='ELF'
10112              AC_MSG_WARN([unexpected host system. assumed that the format is $objfmt.])
10113            fi
10114
10115            AC_MSG_CHECKING([for object file format specifier (NAFLAGS) ])
10116            case "$objfmt" in
10117              MSOMF)      NAFLAGS='-fobj -DOBJ32 -DPIC';;
10118              Win32-COFF) NAFLAGS='-fwin32 -DWIN32 -DPIC';;
10119              Win64-COFF) NAFLAGS='-fwin64 -DWIN64 -D__x86_64__ -DPIC';;
10120              COFF)       NAFLAGS='-fcoff -DCOFF -DPIC';;
10121              a.out)      NAFLAGS='-faout -DAOUT -DPIC';;
10122              BSD-a.out)  NAFLAGS='-faoutb -DAOUT -DPIC';;
10123              ELF)        NAFLAGS='-felf -DELF -DPIC';;
10124              ELF64)      NAFLAGS='-felf64 -DELF -D__x86_64__ -DPIC';;
10125              RDF)        NAFLAGS='-frdf -DRDF -DPIC';;
10126              Mach-O)     NAFLAGS='-fmacho -DMACHO -DPIC';;
10127              Mach-O64)   NAFLAGS='-fmacho64 -DMACHO -D__x86_64__ -DPIC';;
10128            esac
10129            AC_MSG_RESULT([$NAFLAGS])
10130
10131            AC_MSG_CHECKING([whether the assembler ($NASM $NAFLAGS) works])
10132            cat > conftest.asm << EOF
10133            [%line __oline__ "configure"
10134                    section .text
10135                    global  _main,main
10136            _main:
10137            main:   xor     eax,eax
10138                    ret
10139            ]
10140EOF
10141            try_nasm='$NASM $NAFLAGS -o conftest.o conftest.asm'
10142            if AC_TRY_EVAL(try_nasm) && test -s conftest.o; then
10143              AC_MSG_RESULT(yes)
10144            else
10145              echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
10146              cat conftest.asm >&AS_MESSAGE_LOG_FD
10147              rm -rf conftest*
10148              AC_MSG_RESULT(no)
10149              AC_MSG_WARN([installation or configuration problem: assembler cannot create object files.])
10150              NASM=""
10151            fi
10152
10153        fi
10154
10155        if test -z "$NASM"; then
10156cat << _EOS
10157****************************************************************************
10158You need yasm or nasm (Netwide Assembler) to build the internal jpeg library optimally.
10159To get one please:
10160
10161_EOS
10162            if test "$build_os" = "cygwin"; then
10163cat << _EOS
10164install a pre-compiled binary for Win32
10165
10166mkdir -p /opt/lo/bin
10167cd /opt/lo/bin
10168wget https://dev-www.libreoffice.org/bin/cygwin/nasm.exe
10169chmod +x nasm
10170
10171or get and install one from https://www.nasm.us/
10172
10173Then re-run autogen.sh
10174
10175Note: autogen.sh will try to use /opt/lo/bin/nasm if the environment variable NASM is not already defined.
10176Alternatively, you can install the 'new' nasm where ever you want and make sure that \`command -v nasm\` finds it.
10177
10178_EOS
10179            else
10180cat << _EOS
10181consult https://github.com/libjpeg-turbo/libjpeg-turbo/blob/main/BUILDING.md
10182
10183_EOS
10184            fi
10185            AC_MSG_WARN([no suitable nasm (Netwide Assembler) found])
10186            add_warning "no suitable nasm (Netwide Assembler) found for internal libjpeg-turbo"
10187        fi
10188      ;;
10189    esac
10190fi
10191
10192AC_SUBST(NASM)
10193AC_SUBST(NAFLAGS)
10194AC_SUBST(LIBJPEG_CFLAGS)
10195AC_SUBST(LIBJPEG_LIBS)
10196AC_SUBST(SYSTEM_LIBJPEG)
10197
10198dnl ===================================================================
10199dnl Check for system clucene
10200dnl ===================================================================
10201libo_CHECK_SYSTEM_MODULE([clucene],[CLUCENE],[libclucene-core])
10202if test "$SYSTEM_CLUCENE" = TRUE; then
10203    AC_LANG_PUSH([C++])
10204    save_CXXFLAGS=$CXXFLAGS
10205    save_CPPFLAGS=$CPPFLAGS
10206    CXXFLAGS="$CXXFLAGS $CLUCENE_CFLAGS"
10207    CPPFLAGS="$CPPFLAGS $CLUCENE_CFLAGS"
10208    dnl https://sourceforge.net/p/clucene/bugs/200/
10209    dnl https://bugzilla.redhat.com/show_bug.cgi?id=794795
10210    AC_CHECK_HEADER([CLucene/analysis/cjk/CJKAnalyzer.h], [],
10211                 [AC_MSG_ERROR([Your version of libclucene has contribs-lib missing.])], [#include <CLucene.h>])
10212    CXXFLAGS=$save_CXXFLAGS
10213    CPPFLAGS=$save_CPPFLAGS
10214    AC_LANG_POP([C++])
10215    CLUCENE_LIBS="$CLUCENE_LIBS -lclucene-contribs-lib"
10216fi
10217
10218dnl ===================================================================
10219dnl Check for system expat
10220dnl ===================================================================
10221libo_CHECK_SYSTEM_MODULE([expat], [EXPAT], [expat])
10222
10223dnl ===================================================================
10224dnl Check for system xmlsec
10225dnl ===================================================================
10226libo_CHECK_SYSTEM_MODULE([xmlsec], [XMLSEC], [xmlsec1-nss >= 1.2.35])
10227
10228AC_MSG_CHECKING([whether to enable Embedded OpenType support])
10229if test "$enable_eot" = "yes"; then
10230    ENABLE_EOT="TRUE"
10231    AC_DEFINE([ENABLE_EOT])
10232    AC_MSG_RESULT([yes])
10233
10234    libo_CHECK_SYSTEM_MODULE([libeot],[LIBEOT],[libeot >= 0.01])
10235else
10236    ENABLE_EOT=
10237    AC_MSG_RESULT([no])
10238fi
10239AC_SUBST([ENABLE_EOT])
10240
10241dnl ===================================================================
10242dnl Check for DLP libs
10243dnl ===================================================================
10244REVENGE_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/librevenge/inc"
10245AS_IF([test "$COM" = "MSC"],
10246      [librevenge_libdir='$(gb_Library_DLLDIR)'],
10247      [librevenge_libdir="${WORKDIR}/UnpackedTarball/librevenge/src/lib/.libs"]
10248)
10249REVENGE_LIBS_internal="-L${librevenge_libdir} -lrevenge-0.0"
10250libo_CHECK_SYSTEM_MODULE([librevenge],[REVENGE],[librevenge-0.0 >= 0.0.1])
10251
10252libo_CHECK_SYSTEM_MODULE([libodfgen],[ODFGEN],[libodfgen-0.1])
10253
10254libo_CHECK_SYSTEM_MODULE([libepubgen],[EPUBGEN],[libepubgen-0.1])
10255
10256WPD_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/libwpd/inc"
10257AS_IF([test "$COM" = "MSC"],
10258      [libwpd_libdir='$(gb_Library_DLLDIR)'],
10259      [libwpd_libdir="${WORKDIR}/UnpackedTarball/libwpd/src/lib/.libs"]
10260)
10261WPD_LIBS_internal="-L${libwpd_libdir} -lwpd-0.10"
10262libo_CHECK_SYSTEM_MODULE([libwpd],[WPD],[libwpd-0.10])
10263
10264libo_CHECK_SYSTEM_MODULE([libwpg],[WPG],[libwpg-0.3])
10265
10266libo_CHECK_SYSTEM_MODULE([libwps],[WPS],[libwps-0.4])
10267libo_PKG_VERSION([WPS], [libwps-0.4], [0.4.14])
10268
10269libo_CHECK_SYSTEM_MODULE([libvisio],[VISIO],[libvisio-0.1])
10270
10271libo_CHECK_SYSTEM_MODULE([libcdr],[CDR],[libcdr-0.1])
10272
10273libo_CHECK_SYSTEM_MODULE([libmspub],[MSPUB],[libmspub-0.1])
10274
10275libo_CHECK_SYSTEM_MODULE([libmwaw],[MWAW],[libmwaw-0.3 >= 0.3.21])
10276libo_PKG_VERSION([MWAW], [libmwaw-0.3], [0.3.21])
10277
10278libo_CHECK_SYSTEM_MODULE([libetonyek],[ETONYEK],[libetonyek-0.1])
10279libo_PKG_VERSION([ETONYEK], [libetonyek-0.1], [0.1.10])
10280
10281libo_CHECK_SYSTEM_MODULE([libfreehand],[FREEHAND],[libfreehand-0.1])
10282
10283libo_CHECK_SYSTEM_MODULE([libebook],[EBOOK],[libe-book-0.1])
10284libo_PKG_VERSION([EBOOK], [libe-book-0.1], [0.1.2])
10285
10286libo_CHECK_SYSTEM_MODULE([libabw],[ABW],[libabw-0.1])
10287
10288libo_CHECK_SYSTEM_MODULE([libpagemaker],[PAGEMAKER],[libpagemaker-0.0])
10289
10290libo_CHECK_SYSTEM_MODULE([libqxp],[QXP],[libqxp-0.0])
10291
10292libo_CHECK_SYSTEM_MODULE([libzmf],[ZMF],[libzmf-0.0])
10293
10294libo_CHECK_SYSTEM_MODULE([libstaroffice],[STAROFFICE],[libstaroffice-0.0])
10295libo_PKG_VERSION([STAROFFICE], [libstaroffice-0.0], [0.0.7])
10296
10297dnl ===================================================================
10298dnl Check for system lcms2
10299dnl ===================================================================
10300if test "$with_system_lcms2" != "yes"; then
10301    SYSTEM_LCMS2=
10302fi
10303LCMS2_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/lcms2/include"
10304LCMS2_LIBS_internal="-L${WORKDIR}/UnpackedTarball/lcms2/src/.libs -llcms2"
10305libo_CHECK_SYSTEM_MODULE([lcms2],[LCMS2],[lcms2])
10306if test "$GCC" = "yes"; then
10307    LCMS2_CFLAGS="${LCMS2_CFLAGS} -Wno-long-long"
10308fi
10309if test "$COM" = "MSC"; then # override the above
10310    LCMS2_LIBS=${WORKDIR}/UnpackedTarball/lcms2/bin/lcms2.lib
10311fi
10312
10313dnl ===================================================================
10314dnl Check for system cppunit
10315dnl ===================================================================
10316if test "$_os" != "Android" ; then
10317    libo_CHECK_SYSTEM_MODULE([cppunit],[CPPUNIT],[cppunit >= 1.14.0])
10318fi
10319
10320dnl ===================================================================
10321dnl Check whether freetype is available
10322dnl
10323dnl FreeType has 3 different kinds of versions
10324dnl * release, like 2.4.10
10325dnl * libtool, like 13.0.7 (this what pkg-config returns)
10326dnl * soname
10327dnl FreeType's docs/VERSION.DLL provides a table mapping between the three
10328dnl
10329dnl 9.9.3 is 2.2.0
10330dnl When the minimal version is at least 2.8.1, remove Skia's check down below.
10331dnl ===================================================================
10332FREETYPE_CFLAGS_internal="${ISYSTEM}${WORKDIR}/UnpackedTarball/freetype/include"
10333if test "x$ac_config_site_64bit_host" = xYES; then
10334    FREETYPE_LIBS_internal="-L${WORKDIR}/UnpackedTarball/freetype/instdir/lib64 -lfreetype"
10335else
10336    FREETYPE_LIBS_internal="-L${WORKDIR}/UnpackedTarball/freetype/instdir/lib -lfreetype"
10337fi
10338libo_CHECK_SYSTEM_MODULE([freetype],[FREETYPE],[freetype2 >= 9.9.3],,system,TRUE)
10339
10340# ===================================================================
10341# Check for system libxslt
10342# to prevent incompatibilities between internal libxml2 and external libxslt,
10343# or vice versa, use with_system_libxml here
10344# ===================================================================
10345if test "$with_system_libxml" = "auto"; then
10346    case "$_os" in
10347    WINNT|iOS|Android)
10348        with_system_libxml="$with_system_libs"
10349        ;;
10350    Emscripten)
10351        with_system_libxml=no
10352        ;;
10353    *)
10354        if test "$enable_fuzzers" != "yes"; then
10355            with_system_libxml=yes
10356        else
10357            with_system_libxml=no
10358        fi
10359        ;;
10360    esac
10361fi
10362
10363AC_MSG_CHECKING([which libxslt to use])
10364if test "$with_system_libxml" = "yes"; then
10365    AC_MSG_RESULT([external])
10366    SYSTEM_LIBXSLT=TRUE
10367    if test "$_os" = "Darwin"; then
10368        dnl make sure to use SDK path
10369        LIBXSLT_CFLAGS="-I$MACOSX_SDK_PATH/usr/include/libxml2"
10370        LIBEXSLT_CFLAGS="$LIBXSLT_CFLAGS"
10371        dnl omit -L/usr/lib
10372        LIBXSLT_LIBS="-lxslt -lxml2 -lz -lpthread -liconv -lm"
10373        LIBEXSLT_LIBS="-lexslt $LIBXSLT_LIBS"
10374    else
10375        PKG_CHECK_MODULES(LIBXSLT, libxslt)
10376        LIBXSLT_CFLAGS=$(printf '%s' "$LIBXSLT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10377        FilterLibs "${LIBXSLT_LIBS}"
10378        LIBXSLT_LIBS="${filteredlibs}"
10379        PKG_CHECK_MODULES(LIBEXSLT, libexslt)
10380        LIBEXSLT_CFLAGS=$(printf '%s' "$LIBEXSLT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10381        FilterLibs "${LIBEXSLT_LIBS}"
10382        LIBEXSLT_LIBS=$(printf '%s' "${filteredlibs}" | sed -e "s/-lgpg-error//"  -e "s/-lgcrypt//")
10383    fi
10384
10385    dnl Check for xsltproc
10386    AC_PATH_PROG(XSLTPROC, xsltproc, no)
10387    if test "$XSLTPROC" = "no"; then
10388        AC_MSG_ERROR([xsltproc is required])
10389    fi
10390else
10391    AC_MSG_RESULT([internal])
10392    SYSTEM_LIBXSLT=
10393    BUILD_TYPE="$BUILD_TYPE LIBXSLT"
10394fi
10395AC_SUBST(SYSTEM_LIBXSLT)
10396if test -z "$SYSTEM_LIBXSLT_FOR_BUILD"; then
10397    SYSTEM_LIBXSLT_FOR_BUILD="$SYSTEM_LIBXSLT"
10398fi
10399AC_SUBST(SYSTEM_LIBXSLT_FOR_BUILD)
10400
10401AC_SUBST(LIBEXSLT_CFLAGS)
10402AC_SUBST(LIBEXSLT_LIBS)
10403AC_SUBST(LIBXSLT_CFLAGS)
10404AC_SUBST(LIBXSLT_LIBS)
10405AC_SUBST(XSLTPROC)
10406
10407# ===================================================================
10408# Check for system libxml
10409# ===================================================================
10410AC_MSG_CHECKING([which libxml to use])
10411if test "$with_system_libxml" = "yes"; then
10412    AC_MSG_RESULT([external])
10413    SYSTEM_LIBXML=TRUE
10414    if test "$_os" = "Darwin"; then
10415        dnl make sure to use SDK path
10416        LIBXML_CFLAGS="-I$MACOSX_SDK_PATH/usr/include/libxml2"
10417        dnl omit -L/usr/lib
10418        LIBXML_LIBS="-lxml2 -lz -lpthread -liconv -lm"
10419    elif test $_os = iOS; then
10420        dnl make sure to use SDK path
10421        usr=`echo '#include <stdlib.h>' | $CC -E -MD - | grep usr/include/stdlib.h | head -1 | sed -e 's,# 1 ",,' -e 's,/usr/include/.*,/usr,'`
10422        LIBXML_CFLAGS="-I$usr/include/libxml2"
10423        LIBXML_LIBS="-L$usr/lib -lxml2 -liconv"
10424    else
10425        PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= 2.0)
10426        LIBXML_CFLAGS=$(printf '%s' "$LIBXML_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10427        FilterLibs "${LIBXML_LIBS}"
10428        LIBXML_LIBS="${filteredlibs}"
10429    fi
10430
10431    dnl Check for xmllint
10432    AC_PATH_PROG(XMLLINT, xmllint, no)
10433    if test "$XMLLINT" = "no"; then
10434        AC_MSG_ERROR([xmllint is required])
10435    fi
10436else
10437    AC_MSG_RESULT([internal])
10438    SYSTEM_LIBXML=
10439    LIBXML_CFLAGS="-I${WORKDIR}/UnpackedTarball/libxml2/include"
10440    if test "$COM" = "MSC"; then
10441        LIBXML_CFLAGS="${LIBXML_CFLAGS} -I${WORKDIR}/UnpackedTarball/icu/source/i18n -I${WORKDIR}/UnpackedTarball/icu/source/common"
10442    fi
10443    if test "$COM" = "MSC"; then
10444        LIBXML_LIBS="${WORKDIR}/UnpackedTarball/libxml2/win32/bin.msvc/libxml2.lib"
10445    else
10446        LIBXML_LIBS="-L${WORKDIR}/UnpackedTarball/libxml2/.libs -lxml2"
10447        if test "$DISABLE_DYNLOADING" = TRUE; then
10448            LIBXML_LIBS="$LIBXML_LIBS -lm"
10449        fi
10450    fi
10451    BUILD_TYPE="$BUILD_TYPE LIBXML2"
10452fi
10453AC_SUBST(SYSTEM_LIBXML)
10454if test -z "$SYSTEM_LIBXML_FOR_BUILD"; then
10455    SYSTEM_LIBXML_FOR_BUILD="$SYSTEM_LIBXML"
10456fi
10457AC_SUBST(SYSTEM_LIBXML_FOR_BUILD)
10458AC_SUBST(LIBXML_CFLAGS)
10459AC_SUBST(LIBXML_LIBS)
10460AC_SUBST(XMLLINT)
10461
10462# =====================================================================
10463# Checking for a Python interpreter with version >= 3.3 (or 3.7 if the build needs meson)
10464# Optionally user can pass an option to configure, i. e.
10465# ./configure PYTHON=/usr/bin/python
10466# =====================================================================
10467if test $_os = Darwin -a "$enable_python" != no -a "$enable_python" != fully-internal -a "$enable_python" != internal -a "$enable_python" != system; then
10468    # Only allowed choices for macOS are 'no', 'internal' (default), and 'fully-internal'
10469    # unless PYTHON is defined as above which allows 'system'
10470    enable_python=internal
10471fi
10472if test "$build_os" != "cygwin" -a "$enable_python" != fully-internal; then
10473    if test -n "$PYTHON"; then
10474        PYTHON_FOR_BUILD=$PYTHON
10475    else
10476        # This allows a lack of system python with no error, we use internal one in that case.
10477        if test "$with_system_harfbuzz" = "yes"; then
10478            AM_PATH_PYTHON([3.3],, [:])
10479        else
10480            # harfbuzz is built using meson, and current meson requires at least python 3.7
10481            AM_PATH_PYTHON([3.7],, [:])
10482        fi
10483        # Clean PYTHON_VERSION checked below if cross-compiling
10484        PYTHON_VERSION=""
10485        if test "$PYTHON" != ":"; then
10486            PYTHON_FOR_BUILD=$PYTHON
10487        fi
10488    fi
10489fi
10490
10491# Checks for Python to use for Pyuno
10492AC_MSG_CHECKING([which Python to use for Pyuno])
10493case "$enable_python" in
10494no|disable)
10495    if test -z "$PYTHON_FOR_BUILD" -a "$cross_compiling" != yes; then
10496        # Python is required to build LibreOffice. In theory we could separate the build-time Python
10497        # requirement from the choice whether to include Python stuff in the installer, but why
10498        # bother?
10499        AC_MSG_ERROR([Python is required at build time.])
10500    fi
10501    enable_python=no
10502    AC_MSG_RESULT([none])
10503    ;;
10504""|yes|auto)
10505    if test "$DISABLE_SCRIPTING" = TRUE; then
10506        if test -z "$PYTHON_FOR_BUILD" -a "$cross_compiling" != yes; then
10507            AC_MSG_ERROR([Python support can't be disabled without cross-compiling or a system python.])
10508        fi
10509        AC_MSG_RESULT([none, overridden by --disable-scripting])
10510        enable_python=no
10511    elif test $build_os = cygwin -o $build_os = wsl; then
10512        dnl When building on Windows we don't attempt to use any installed
10513        dnl "system"  Python.
10514        AC_MSG_RESULT([fully internal])
10515        enable_python=internal
10516    elif test "$cross_compiling" = yes; then
10517        AC_MSG_RESULT([system])
10518        enable_python=system
10519    else
10520        # Unset variables set by the above AM_PATH_PYTHON so that
10521        # we actually do check anew.
10522        AC_MSG_RESULT([])
10523        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
10524        if test -z "$NEED_MESON"; then
10525            AM_PATH_PYTHON([3.3],, [:])
10526        else
10527            AM_PATH_PYTHON([3.7],, [:])
10528        fi
10529        AC_MSG_CHECKING([which Python to use for Pyuno])
10530        if test "$PYTHON" = ":"; then
10531            if test -z "$PYTHON_FOR_BUILD"; then
10532                AC_MSG_RESULT([fully internal])
10533            else
10534                AC_MSG_RESULT([internal])
10535            fi
10536            enable_python=internal
10537        else
10538            AC_MSG_RESULT([system])
10539            enable_python=system
10540        fi
10541    fi
10542    ;;
10543internal)
10544    AC_MSG_RESULT([internal])
10545    ;;
10546fully-internal)
10547    AC_MSG_RESULT([fully internal])
10548    enable_python=internal
10549    ;;
10550system)
10551    AC_MSG_RESULT([system])
10552    if test "$_os" = Darwin -a -z "$PYTHON"; then
10553        AC_MSG_ERROR([--enable-python=system doesn't work on macOS because the version provided is obsolete])
10554    fi
10555    ;;
10556*)
10557    AC_MSG_ERROR([Incorrect --enable-python option])
10558    ;;
10559esac
10560
10561if test $enable_python != no; then
10562    BUILD_TYPE="$BUILD_TYPE PYUNO"
10563fi
10564
10565if test $enable_python = system; then
10566    if test -n "$PYTHON_CFLAGS" -a -n "$PYTHON_LIBS"; then
10567        # Fallback: Accept these in the environment, or as set above
10568        # for MacOSX.
10569        :
10570    elif test "$cross_compiling" != yes; then
10571        # Unset variables set by the above AM_PATH_PYTHON so that
10572        # we actually do check anew.
10573        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
10574        # This causes an error if no python command is found
10575        # the version found here also sets PYTHON_FOR_BUILD below, so the python picked here
10576        # needs to be suitable for meson/the harfbuzz build
10577        if test "$with_system_harfbuzz" = "yes" -o -n "$NEED_MESON" ; then
10578            AM_PATH_PYTHON([3.7])
10579        else
10580            AM_PATH_PYTHON([3.3])
10581        fi
10582        python_include=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('INCLUDEPY'));"`
10583        python_version=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('VERSION'));"`
10584        python_libs=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBS'));"`
10585        python_libdir=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBDIR'));"`
10586        if test -z "$PKG_CONFIG"; then
10587            PYTHON_CFLAGS="-I$python_include"
10588            PYTHON_LIBS="-L$python_libdir -lpython$python_version $python_libs"
10589        elif $PKG_CONFIG --exists python-$python_version-embed; then
10590            PYTHON_CFLAGS="`$PKG_CONFIG --cflags python-$python_version-embed`"
10591            PYTHON_LIBS="`$PKG_CONFIG --libs python-$python_version-embed` $python_libs"
10592        elif $PKG_CONFIG --exists python-$python_version; then
10593            PYTHON_CFLAGS="`$PKG_CONFIG --cflags python-$python_version`"
10594            PYTHON_LIBS="`$PKG_CONFIG --libs python-$python_version` $python_libs"
10595        else
10596            PYTHON_CFLAGS="-I$python_include"
10597            PYTHON_LIBS="-L$python_libdir -lpython$python_version $python_libs"
10598        fi
10599        FilterLibs "${PYTHON_LIBS}"
10600        PYTHON_LIBS="${filteredlibs}"
10601    else
10602        dnl How to find out the cross-compilation Python installation path?
10603        AC_MSG_CHECKING([for python version])
10604        AS_IF([test -n "$PYTHON_VERSION"],
10605              [AC_MSG_RESULT([$PYTHON_VERSION])],
10606              [AC_MSG_RESULT([not found])
10607               AC_MSG_ERROR([no usable python found])])
10608        test -n "$PYTHON_CFLAGS" && break
10609    fi
10610
10611    dnl Check if the headers really work
10612    save_CPPFLAGS="$CPPFLAGS"
10613    CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
10614    AC_CHECK_HEADER(Python.h)
10615    CPPFLAGS="$save_CPPFLAGS"
10616
10617    # let the PYTHON_FOR_BUILD match the same python installation that
10618    # provides PYTHON_CFLAGS/PYTHON_LDFLAGS for pyuno, which should be
10619    # better for PythonTests.
10620    PYTHON_FOR_BUILD=$PYTHON
10621fi
10622
10623if test "$with_lxml" != no; then
10624    if test -z "$PYTHON_FOR_BUILD"; then
10625        case $build_os in
10626            cygwin)
10627                AC_MSG_WARN([No system-provided python lxml, gla11y will only report widget classes and ids])
10628                ;;
10629            *)
10630                if test "$cross_compiling" != yes ; then
10631                    BUILD_TYPE="$BUILD_TYPE LXML"
10632                fi
10633                ;;
10634        esac
10635    else
10636        AC_MSG_CHECKING([for python lxml])
10637        if $PYTHON_FOR_BUILD -c "import lxml.etree as ET" 2> /dev/null ; then
10638            AC_MSG_RESULT([yes])
10639        else
10640            case $build_os in
10641                cygwin)
10642                    AC_MSG_RESULT([no, gla11y will only report widget classes and ids])
10643                    ;;
10644                *)
10645                    if test "$cross_compiling" != yes -a "x$ac_cv_header_Python_h" = "xyes"; then
10646                        if test -n ${SYSTEM_LIBXSLT} -o -n ${SYSTEM_LIBXML}; then
10647                            AC_MSG_RESULT([no, and no system libxml/libxslt, gla11y will only report widget classes and ids])
10648                        else
10649                            BUILD_TYPE="$BUILD_TYPE LXML"
10650                            AC_MSG_RESULT([no, using internal lxml])
10651                        fi
10652                    else
10653                        AC_MSG_RESULT([no, and system does not provide python development headers, gla11y will only report widget classes and ids])
10654                    fi
10655                    ;;
10656            esac
10657        fi
10658    fi
10659fi
10660
10661if test \( "$cross_compiling" = yes -a -z "$PYTHON_FOR_BUILD" \) -o "$enable_python" = internal; then
10662    SYSTEM_PYTHON=
10663    PYTHON_VERSION_MAJOR=3
10664    PYTHON_VERSION_MINOR=12
10665    PYTHON_VERSION=${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.11
10666    if ! grep -q -i python.*${PYTHON_VERSION} ${SRC_ROOT}/download.lst; then
10667        AC_MSG_ERROR([PYTHON_VERSION ${PYTHON_VERSION} but no matching file in download.lst])
10668    fi
10669    AC_DEFINE_UNQUOTED([PYTHON_VERSION_STRING], [L"${PYTHON_VERSION}"])
10670
10671    # Embedded Python dies without Home set
10672    if test "$HOME" = ""; then
10673        export HOME=""
10674    fi
10675fi
10676
10677dnl By now enable_python should be "system", "internal" or "no"
10678case $enable_python in
10679system)
10680    SYSTEM_PYTHON=TRUE
10681
10682    if test "x$ac_cv_header_Python_h" != "xyes"; then
10683       AC_MSG_ERROR([Python headers not found. You probably want to set both the PYTHON_CFLAGS and PYTHON_LIBS environment variables.])
10684    fi
10685
10686    AC_LANG_PUSH(C)
10687    CFLAGS="$CFLAGS $PYTHON_CFLAGS"
10688    AC_MSG_CHECKING([for correct python library version])
10689       AC_RUN_IFELSE([AC_LANG_SOURCE([[
10690#include <Python.h>
10691
10692int main(int argc, char **argv) {
10693   if ((PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 3)) return 0;
10694   else return 1;
10695}
10696       ]])],[AC_MSG_RESULT([ok])],[AC_MSG_ERROR([Python >= 3.3 is needed when building with Python 3])],[AC_MSG_RESULT([skipped; cross-compiling])])
10697    AC_LANG_POP(C)
10698
10699    dnl FIXME Check if the Python library can be linked with, too?
10700    ;;
10701
10702internal)
10703    BUILD_TYPE="$BUILD_TYPE PYTHON"
10704    if test "$OS" = LINUX -o "$OS" = WNT ; then
10705        BUILD_TYPE="$BUILD_TYPE LIBFFI"
10706    fi
10707    ;;
10708no)
10709    DISABLE_PYTHON=TRUE
10710    SYSTEM_PYTHON=
10711    ;;
10712*)
10713    AC_MSG_ERROR([Internal configure script error, invalid enable_python value "$enable_python"])
10714    ;;
10715esac
10716
10717AC_SUBST(DISABLE_PYTHON)
10718AC_SUBST(SYSTEM_PYTHON)
10719AC_SUBST(PYTHON_CFLAGS)
10720AC_SUBST(PYTHON_FOR_BUILD)
10721AC_SUBST(PYTHON_LIBS)
10722AC_SUBST(PYTHON_VERSION)
10723AC_SUBST(PYTHON_VERSION_MAJOR)
10724AC_SUBST(PYTHON_VERSION_MINOR)
10725
10726AC_MSG_CHECKING([whether to build LibreLogo])
10727case "$enable_python" in
10728no|disable)
10729    AC_MSG_RESULT([no; Python disabled])
10730    ;;
10731*)
10732    if test "${enable_librelogo}" = "no"; then
10733        AC_MSG_RESULT([no])
10734    else
10735        AC_MSG_RESULT([yes])
10736        BUILD_TYPE="${BUILD_TYPE} LIBRELOGO"
10737        AC_DEFINE([ENABLE_LIBRELOGO],1)
10738    fi
10739    ;;
10740esac
10741AC_SUBST(ENABLE_LIBRELOGO)
10742
10743ENABLE_MARIADBC=
10744MARIADBC_MAJOR=1
10745MARIADBC_MINOR=0
10746MARIADBC_MICRO=2
10747AC_MSG_CHECKING([whether to build the MariaDB/MySQL SDBC driver])
10748if test "x$enable_mariadb_sdbc" != "xno" -a "$enable_mpl_subset" != "yes"; then
10749    ENABLE_MARIADBC=TRUE
10750    AC_MSG_RESULT([yes])
10751    BUILD_TYPE="$BUILD_TYPE MARIADBC"
10752else
10753    AC_MSG_RESULT([no])
10754fi
10755AC_SUBST(ENABLE_MARIADBC)
10756AC_SUBST(MARIADBC_MAJOR)
10757AC_SUBST(MARIADBC_MINOR)
10758AC_SUBST(MARIADBC_MICRO)
10759
10760if test "$ENABLE_MARIADBC" = "TRUE"; then
10761    dnl ===================================================================
10762    dnl Check for system MariaDB
10763    dnl ===================================================================
10764
10765    if test "$with_gssapi" = "yes" -a "$enable_openssl" = "no"; then
10766        AC_MSG_ERROR([GSSAPI needs OpenSSL, but --disable-openssl was given.])
10767    fi
10768
10769    AC_MSG_CHECKING([which MariaDB to use])
10770    if test "$with_system_mariadb" = "yes"; then
10771        AC_MSG_RESULT([external])
10772        SYSTEM_MARIADB_CONNECTOR_C=TRUE
10773        #AC_PATH_PROG(MARIADBCONFIG, [mariadb_config])
10774        if test -z "$MARIADBCONFIG"; then
10775            AC_PATH_PROG(MARIADBCONFIG, [mysql_config])
10776            if test -z "$MARIADBCONFIG"; then
10777                AC_MSG_ERROR([mysql_config is missing. Install MySQL client library development package.])
10778                #AC_MSG_ERROR([mariadb_config and mysql_config are missing. Install MariaDB or MySQL client library development package.])
10779            fi
10780        fi
10781        AC_MSG_CHECKING([MariaDB version])
10782        MARIADB_VERSION=`$MARIADBCONFIG --version`
10783        MARIADB_MAJOR=`$MARIADBCONFIG --version | cut -d"." -f1`
10784        if test "$MARIADB_MAJOR" -ge "5"; then
10785            AC_MSG_RESULT([OK])
10786        else
10787            AC_MSG_ERROR([too old, use 5.0.x or later])
10788        fi
10789        AC_MSG_CHECKING([for MariaDB Client library])
10790        MARIADB_CFLAGS=`$MARIADBCONFIG --cflags`
10791        if test "$COM_IS_CLANG" = TRUE; then
10792            MARIADB_CFLAGS=$(printf '%s' "$MARIADB_CFLAGS" | sed -e s/-fstack-protector-strong//)
10793        fi
10794        MARIADB_LIBS=`$MARIADBCONFIG --libs_r`
10795        dnl At least mariadb-5.5.34-3.fc20.x86_64 plus
10796        dnl mariadb-5.5.34-3.fc20.i686 reports 64-bit specific output even under
10797        dnl linux32:
10798        if test "$OS" = LINUX -a "$CPUNAME" = INTEL; then
10799            MARIADB_CFLAGS=$(printf '%s' "$MARIADB_CFLAGS" | sed -e s/-m64//)
10800            MARIADB_LIBS=$(printf '%s' "$MARIADB_LIBS" \
10801                | sed -e 's|/lib64/|/lib/|')
10802        fi
10803        FilterLibs "${MARIADB_LIBS}"
10804        MARIADB_LIBS="${filteredlibs}"
10805        AC_MSG_RESULT([includes '$MARIADB_CFLAGS', libraries '$MARIADB_LIBS'])
10806        AC_MSG_CHECKING([whether to bundle the MySQL/MariaDB client library])
10807        if test "$enable_bundle_mariadb" = "yes"; then
10808            AC_MSG_RESULT([yes])
10809            BUNDLE_MARIADB_CONNECTOR_C=TRUE
10810            LIBMARIADB=lib$(echo "${MARIADB_LIBS}" | sed -e 's/[[[:space:]]]\{1,\}-l\([[^[:space:]]]\{1,\}\)/\
10811\1\
10812/g' -e 's/^-l\([[^[:space:]]]\{1,\}\)[[[:space:]]]*/\
10813\1\
10814/g' | grep -E '(mysqlclient|mariadb)')
10815            if test "$_os" = "Darwin"; then
10816                LIBMARIADB=${LIBMARIADB}.dylib
10817                if test "$with_gssapi" != "no"; then
10818                    WITH_GSSAPI=TRUE
10819                    save_LIBS=$LIBS
10820                    AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
10821                        [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
10822                    GSSAPI_LIBS=$LIBS
10823                    LIBS=$save_LIBS
10824                fi
10825            elif test "$_os" = "WINNT"; then
10826                LIBMARIADB=${LIBMARIADB}.dll
10827            else
10828                LIBMARIADB=${LIBMARIADB}.so
10829                if test "$with_gssapi" != "no"; then
10830                    WITH_GSSAPI=TRUE
10831                    save_LIBS=$LIBS
10832                    AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
10833                        [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
10834                    GSSAPI_LIBS=$LIBS
10835                    LIBS=$save_LIBS
10836                fi
10837            fi
10838            LIBMARIADB_PATH=$($MARIADBCONFIG --variable=pkglibdir)
10839            AC_MSG_CHECKING([for $LIBMARIADB in $LIBMARIADB_PATH])
10840            if test -e "$LIBMARIADB_PATH/$LIBMARIADB"; then
10841                AC_MSG_RESULT([found.])
10842                PathFormat "$LIBMARIADB_PATH"
10843                LIBMARIADB_PATH="$formatted_path"
10844            else
10845                AC_MSG_ERROR([not found.])
10846            fi
10847        else
10848            AC_MSG_RESULT([no])
10849            BUNDLE_MARIADB_CONNECTOR_C=
10850        fi
10851    else
10852        AC_MSG_RESULT([internal])
10853        SYSTEM_MARIADB_CONNECTOR_C=
10854        MARIADB_CFLAGS="-I${WORKDIR}/UnpackedTarball/mariadb-connector-c/include"
10855        MARIADB_LIBS='-L$(gb_StaticLibrary_WORKDIR) -lmariadb-connector-c'
10856        BUILD_TYPE="$BUILD_TYPE MARIADB_CONNECTOR_C"
10857    fi
10858
10859    AC_SUBST(SYSTEM_MARIADB_CONNECTOR_C)
10860    AC_SUBST(MARIADB_CFLAGS)
10861    AC_SUBST(MARIADB_LIBS)
10862    AC_SUBST(LIBMARIADB)
10863    AC_SUBST(LIBMARIADB_PATH)
10864    AC_SUBST(BUNDLE_MARIADB_CONNECTOR_C)
10865fi
10866
10867dnl ===================================================================
10868dnl Check for system hsqldb
10869dnl ===================================================================
10870if test "$with_java" != "no" -a "$cross_compiling" != "yes"; then
10871    AC_MSG_CHECKING([which hsqldb to use])
10872    if test "$with_system_hsqldb" = "yes"; then
10873        AC_MSG_RESULT([external])
10874        SYSTEM_HSQLDB=TRUE
10875        if test -z $HSQLDB_JAR; then
10876            HSQLDB_JAR=/usr/share/java/hsqldb.jar
10877        fi
10878        if ! test -f $HSQLDB_JAR; then
10879               AC_MSG_ERROR(hsqldb.jar not found.)
10880        fi
10881        AC_MSG_CHECKING([whether hsqldb is 1.8.0.x])
10882        export HSQLDB_JAR
10883        if $PERL -e \
10884           'use Archive::Zip;
10885            my $file = "$ENV{'HSQLDB_JAR'}";
10886            my $zip = Archive::Zip->new( $file );
10887            my $mf = $zip->contents ( "META-INF/MANIFEST.MF" );
10888            if ( $mf =~ m/Specification-Version: 1.8.*/ )
10889            {
10890                push @l, split(/\n/, $mf);
10891                foreach my $line (@l)
10892                {
10893                    if ($line =~ m/Specification-Version:/)
10894                    {
10895                        ($t, $version) = split (/:/,$line);
10896                        $version =~ s/^\s//;
10897                        ($a, $b, $c, $d) = split (/\./,$version);
10898                        if ($c == "0" && $d > "8")
10899                        {
10900                            exit 0;
10901                        }
10902                        else
10903                        {
10904                            exit 1;
10905                        }
10906                    }
10907                }
10908            }
10909            else
10910            {
10911                exit 1;
10912            }'; then
10913            AC_MSG_RESULT([yes])
10914        else
10915            AC_MSG_ERROR([no, you need hsqldb >= 1.8.0.9 but < 1.8.1])
10916        fi
10917    else
10918        AC_MSG_RESULT([internal])
10919        SYSTEM_HSQLDB=
10920        BUILD_TYPE="$BUILD_TYPE HSQLDB"
10921        NEED_ANT=TRUE
10922    fi
10923else
10924    if test "$with_java" != "no" -a -z "$HSQLDB_JAR"; then
10925        BUILD_TYPE="$BUILD_TYPE HSQLDB"
10926    fi
10927fi
10928AC_SUBST(SYSTEM_HSQLDB)
10929AC_SUBST(HSQLDB_JAR)
10930
10931dnl ===================================================================
10932dnl Check for PostgreSQL stuff
10933dnl ===================================================================
10934AC_MSG_CHECKING([whether to build the PostgreSQL SDBC driver])
10935if test "x$enable_postgresql_sdbc" != "xno"; then
10936    AC_MSG_RESULT([yes])
10937    SCPDEFS="$SCPDEFS -DWITH_POSTGRESQL_SDBC"
10938
10939    if test "$with_krb5" = "yes" -a "$enable_openssl" = "no"; then
10940        AC_MSG_ERROR([krb5 needs OpenSSL, but --disable-openssl was given.])
10941    fi
10942    if test "$with_gssapi" = "yes" -a "$enable_openssl" = "no"; then
10943        AC_MSG_ERROR([GSSAPI needs OpenSSL, but --disable-openssl was given.])
10944    fi
10945
10946    postgres_interface=""
10947    if test "$with_system_postgresql" = "yes"; then
10948        postgres_interface="external PostgreSQL"
10949        SYSTEM_POSTGRESQL=TRUE
10950        if test "$_os" = Darwin; then
10951            supp_path=''
10952            for d in /Library/PostgreSQL/9.*/bin /sw/opt/postgresql/9.*/bin /opt/local/lib/postgresql9*/bin; do
10953                pg_supp_path="$P_SEP$d$pg_supp_path"
10954            done
10955        fi
10956        AC_PATH_PROG(PGCONFIG, pg_config, ,$PATH$pg_supp_path)
10957        if test -n "$PGCONFIG"; then
10958            POSTGRESQL_INC=-I$(${PGCONFIG} --includedir)
10959            POSTGRESQL_LIB="-L$(${PGCONFIG} --libdir)"
10960        else
10961            PKG_CHECK_MODULES(POSTGRESQL, libpq, [
10962              POSTGRESQL_INC=$POSTGRESQL_CFLAGS
10963              POSTGRESQL_LIB=$POSTGRESQL_LIBS
10964            ],[
10965              AC_MSG_ERROR([pg_config or 'pkg-config libpq' needed; set PGCONFIG if not in PATH])
10966            ])
10967        fi
10968        FilterLibs "${POSTGRESQL_LIB}"
10969        POSTGRESQL_LIB="${filteredlibs}"
10970    else
10971        # if/when anything else than PostgreSQL uses Kerberos,
10972        # move this out of `test "x$enable_postgresql_sdbc" != "xno"'
10973        WITH_KRB5=
10974        WITH_GSSAPI=
10975        case "$_os" in
10976        Darwin)
10977            # macOS has system MIT Kerberos 5 since 10.4
10978            if test "$with_krb5" != "no"; then
10979                WITH_KRB5=TRUE
10980                save_LIBS=$LIBS
10981                # Not sure whether it makes any sense here to search multiple potential libraries; it is not likely
10982                # that the libraries where these functions are located on macOS will change, is it?
10983                AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
10984                    [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
10985                KRB5_LIBS=$LIBS
10986                LIBS=$save_LIBS
10987                AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
10988                    [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
10989                KRB5_LIBS="$KRB5_LIBS $LIBS"
10990                LIBS=$save_LIBS
10991            fi
10992            if test "$with_gssapi" != "no"; then
10993                WITH_GSSAPI=TRUE
10994                save_LIBS=$LIBS
10995                AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
10996                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
10997                GSSAPI_LIBS=$LIBS
10998                LIBS=$save_LIBS
10999            fi
11000            ;;
11001        WINNT)
11002            if test "$with_krb5" = "yes" -o "$with_gssapi" = "yes"; then
11003                AC_MSG_ERROR([Refusing to enable MIT Kerberos 5 or GSSAPI on Windows.])
11004            fi
11005            ;;
11006        Linux|GNU|*BSD|DragonFly)
11007            if test "$with_krb5" != "no"; then
11008                WITH_KRB5=TRUE
11009                save_LIBS=$LIBS
11010                AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
11011                    [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
11012                KRB5_LIBS=$LIBS
11013                LIBS=$save_LIBS
11014                AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
11015                    [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
11016                KRB5_LIBS="$KRB5_LIBS $LIBS"
11017                LIBS=$save_LIBS
11018            fi
11019            if test "$with_gssapi" != "no"; then
11020                WITH_GSSAPI=TRUE
11021                save_LIBS=$LIBS
11022                AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
11023                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
11024                GSSAPI_LIBS=$LIBS
11025                LIBS=$save_LIBS
11026            fi
11027            ;;
11028        *)
11029            if test "$with_krb5" = "yes"; then
11030                WITH_KRB5=TRUE
11031                save_LIBS=$LIBS
11032                AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
11033                    [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
11034                KRB5_LIBS=$LIBS
11035                LIBS=$save_LIBS
11036                AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
11037                    [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
11038                KRB5_LIBS="$KRB5_LIBS $LIBS"
11039                LIBS=$save_LIBS
11040            fi
11041            if test "$with_gssapi" = "yes"; then
11042                WITH_GSSAPI=TRUE
11043                save_LIBS=$LIBS
11044                AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
11045                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
11046                LIBS=$save_LIBS
11047                GSSAPI_LIBS=$LIBS
11048            fi
11049        esac
11050
11051        if test -n "$with_libpq_path"; then
11052            SYSTEM_POSTGRESQL=TRUE
11053            postgres_interface="external libpq"
11054            POSTGRESQL_LIB="-L${with_libpq_path}/lib/"
11055            POSTGRESQL_INC=-I"${with_libpq_path}/include/"
11056        else
11057            SYSTEM_POSTGRESQL=
11058            postgres_interface="internal"
11059            POSTGRESQL_LIB=""
11060            POSTGRESQL_INC="%OVERRIDE_ME%"
11061            BUILD_TYPE="$BUILD_TYPE POSTGRESQL"
11062        fi
11063    fi
11064
11065    AC_MSG_CHECKING([PostgreSQL C interface])
11066    AC_MSG_RESULT([$postgres_interface])
11067
11068    if test "${SYSTEM_POSTGRESQL}" = "TRUE"; then
11069        AC_MSG_NOTICE([checking system PostgreSQL prerequisites])
11070        save_CFLAGS=$CFLAGS
11071        save_CPPFLAGS=$CPPFLAGS
11072        save_LIBS=$LIBS
11073        CPPFLAGS="${CPPFLAGS} ${POSTGRESQL_INC}"
11074        LIBS="${LIBS} ${POSTGRESQL_LIB}"
11075        AC_CHECK_HEADER([libpq-fe.h], [], [AC_MSG_ERROR([libpq-fe.h is needed])], [])
11076        AC_CHECK_LIB([pq], [PQconnectdbParams], [:],
11077            [AC_MSG_ERROR(libpq not found or too old. Need >= 9.0)], [])
11078        CFLAGS=$save_CFLAGS
11079        CPPFLAGS=$save_CPPFLAGS
11080        LIBS=$save_LIBS
11081    fi
11082    BUILD_POSTGRESQL_SDBC=TRUE
11083else
11084    AC_MSG_RESULT([no])
11085fi
11086AC_SUBST(WITH_KRB5)
11087AC_SUBST(WITH_GSSAPI)
11088AC_SUBST(GSSAPI_LIBS)
11089AC_SUBST(KRB5_LIBS)
11090AC_SUBST(BUILD_POSTGRESQL_SDBC)
11091AC_SUBST(SYSTEM_POSTGRESQL)
11092AC_SUBST(POSTGRESQL_INC)
11093AC_SUBST(POSTGRESQL_LIB)
11094
11095dnl ===================================================================
11096dnl Check for Firebird stuff
11097dnl ===================================================================
11098ENABLE_FIREBIRD_SDBC=
11099if test "$enable_firebird_sdbc" = "yes" ; then
11100    SCPDEFS="$SCPDEFS -DWITH_FIREBIRD_SDBC"
11101
11102    dnl ===================================================================
11103    dnl Check for system Firebird
11104    dnl ===================================================================
11105    AC_MSG_CHECKING([which Firebird to use])
11106    if test "$with_system_firebird" = "yes"; then
11107        AC_MSG_RESULT([external])
11108        SYSTEM_FIREBIRD=TRUE
11109        AC_PATH_PROG(FIREBIRDCONFIG, [fb_config])
11110        if test -z "$FIREBIRDCONFIG"; then
11111            AC_MSG_NOTICE([No fb_config -- using pkg-config])
11112            PKG_CHECK_MODULES([FIREBIRD], [fbclient >= 3], [FIREBIRD_PKGNAME=fbclient], [
11113                PKG_CHECK_MODULES([FIREBIRD], [fbembed], [FIREBIRD_PKGNAME=fbembed])
11114            ])
11115            FIREBIRD_VERSION=`pkg-config --modversion "$FIREBIRD_PKGNAME"`
11116        else
11117            AC_MSG_NOTICE([fb_config found])
11118            FIREBIRD_VERSION=`$FIREBIRDCONFIG --version`
11119            AC_MSG_CHECKING([for Firebird Client library])
11120            FIREBIRD_CFLAGS=`$FIREBIRDCONFIG --cflags`
11121            FIREBIRD_LIBS=`$FIREBIRDCONFIG --embedlibs`
11122            FilterLibs "${FIREBIRD_LIBS}"
11123            FIREBIRD_LIBS="${filteredlibs}"
11124        fi
11125        AC_MSG_RESULT([includes `$FIREBIRD_CFLAGS', libraries `$FIREBIRD_LIBS'])
11126        AC_MSG_CHECKING([Firebird version])
11127        if test -n "${FIREBIRD_VERSION}"; then
11128            FIREBIRD_MAJOR=`echo $FIREBIRD_VERSION | cut -d"." -f1`
11129            if test "$FIREBIRD_MAJOR" -ge "3"; then
11130                AC_MSG_RESULT([OK])
11131            else
11132                AC_MSG_ERROR([Ensure firebird >= 3 is installed])
11133            fi
11134        else
11135            save_CFLAGS="${CFLAGS}"
11136            CFLAGS="${CFLAGS} ${FIREBIRD_CFLAGS}"
11137            AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <ibase.h>
11138#if defined(FB_API_VER) && FB_API_VER == 30
11139int fb_api_is_30(void) { return 0; }
11140#else
11141#error "Wrong Firebird API version"
11142#endif]])],AC_MSG_RESULT([OK]),AC_MSG_ERROR([Ensure firebird 3.0.x is installed]))
11143            CFLAGS="$save_CFLAGS"
11144        fi
11145        ENABLE_FIREBIRD_SDBC=TRUE
11146        AC_DEFINE([ENABLE_FIREBIRD_SDBC],1)
11147    elif test "$enable_database_connectivity" = no; then
11148        AC_MSG_RESULT([none])
11149    elif test "$cross_compiling" = "yes"; then
11150        AC_MSG_RESULT([none])
11151    else
11152        dnl Embedded Firebird has version 3.0
11153        dnl We need libatomic_ops for any non X86/X64 system
11154        if test "${CPUNAME}" != INTEL -a "${CPUNAME}" != X86_64; then
11155            dnl ===================================================================
11156            dnl Check for system libatomic_ops
11157            dnl ===================================================================
11158            libo_CHECK_SYSTEM_MODULE([libatomic_ops],[LIBATOMIC_OPS],[atomic_ops >= 0.7.2])
11159            if test "$with_system_libatomic_ops" = "yes"; then
11160                SYSTEM_LIBATOMIC_OPS=TRUE
11161                AC_CHECK_HEADERS(atomic_ops.h, [],
11162                [AC_MSG_ERROR(atomic_ops.h not found. install libatomic_ops)], [])
11163            else
11164                SYSTEM_LIBATOMIC_OPS=
11165                LIBATOMIC_OPS_CFLAGS="-I${WORKDIR}/UnpackedTarball/libatomic_ops/include"
11166                LIBATOMIC_OPS_LIBS="-latomic_ops"
11167                BUILD_TYPE="$BUILD_TYPE LIBATOMIC_OPS"
11168            fi
11169        fi
11170
11171        AC_MSG_RESULT([internal])
11172        SYSTEM_FIREBIRD=
11173        FIREBIRD_CFLAGS="-I${WORKDIR}/UnpackedTarball/firebird/gen/Release/firebird/include"
11174        FIREBIRD_LIBS="-lfbclient"
11175
11176        if test "$with_system_libtommath" = "yes"; then
11177            SYSTEM_LIBTOMMATH=TRUE
11178            dnl check for tommath presence
11179            save_LIBS=$LIBS
11180            AC_CHECK_HEADER(tommath.h,,AC_MSG_ERROR(Include file for tommath not found - please install development tommath package))
11181            AC_CHECK_LIB(tommath, mp_init, LIBTOMMATH_LIBS=-ltommath, AC_MSG_ERROR(Library tommath not found - please install development tommath package))
11182            LIBS=$save_LIBS
11183        else
11184            SYSTEM_LIBTOMMATH=
11185            LIBTOMMATH_CFLAGS="-I${WORKDIR}/UnpackedTarball/libtommath"
11186            LIBTOMMATH_LIBS="-ltommath"
11187            BUILD_TYPE="$BUILD_TYPE LIBTOMMATH"
11188        fi
11189
11190        BUILD_TYPE="$BUILD_TYPE FIREBIRD"
11191        ENABLE_FIREBIRD_SDBC=TRUE
11192        AC_DEFINE([ENABLE_FIREBIRD_SDBC],1)
11193    fi
11194fi
11195AC_SUBST(ENABLE_FIREBIRD_SDBC)
11196AC_SUBST(SYSTEM_LIBATOMIC_OPS)
11197AC_SUBST(LIBATOMIC_OPS_CFLAGS)
11198AC_SUBST(LIBATOMIC_OPS_LIBS)
11199AC_SUBST(SYSTEM_FIREBIRD)
11200AC_SUBST(FIREBIRD_CFLAGS)
11201AC_SUBST(FIREBIRD_LIBS)
11202AC_SUBST(SYSTEM_LIBTOMMATH)
11203AC_SUBST(LIBTOMMATH_CFLAGS)
11204AC_SUBST(LIBTOMMATH_LIBS)
11205
11206dnl ===================================================================
11207dnl Check for system curl
11208dnl ===================================================================
11209libo_CHECK_SYSTEM_MODULE([curl],[CURL],[libcurl >= 7.68.0],enabled)
11210
11211if test "$enable_curl" = "yes" -a "$with_system_curl" != "yes" -a "$with_gssapi" != "no"; then
11212    if test "$_os" != "WINNT"; then
11213        WITH_GSSAPI=TRUE
11214        save_LIBS=$LIBS
11215        AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
11216            [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
11217        GSSAPI_LIBS=$LIBS
11218        LIBS=$save_LIBS
11219    fi
11220fi
11221
11222dnl ===================================================================
11223dnl Check for system boost
11224dnl ===================================================================
11225AC_MSG_CHECKING([which boost to use])
11226if test "$with_system_boost" = "yes"; then
11227    AC_MSG_RESULT([external])
11228    SYSTEM_BOOST=TRUE
11229    AX_BOOST_BASE([1.69],,[AC_MSG_ERROR([no suitable Boost found])])
11230    AX_BOOST_DATE_TIME
11231    AX_BOOST_FILESYSTEM
11232    AX_BOOST_IOSTREAMS
11233    AX_BOOST_LOCALE
11234    AC_LANG_PUSH([C++])
11235    save_CXXFLAGS=$CXXFLAGS
11236    CXXFLAGS="$CXXFLAGS $BOOST_CPPFLAGS $CXXFLAGS_CXX11"
11237    AC_CHECK_HEADER(boost/shared_ptr.hpp, [],
11238       [AC_MSG_ERROR(boost/shared_ptr.hpp not found. install boost)], [])
11239    AC_CHECK_HEADER(boost/spirit/include/classic_core.hpp, [],
11240       [AC_MSG_ERROR(boost/spirit/include/classic_core.hpp not found. install boost >= 1.36)], [])
11241    CXXFLAGS=$save_CXXFLAGS
11242    AC_LANG_POP([C++])
11243    # this is in m4/ax_boost_base.m4
11244    FilterLibs "${BOOST_LDFLAGS}"
11245    BOOST_LDFLAGS="${filteredlibs}"
11246else
11247    AC_MSG_RESULT([internal])
11248    BUILD_TYPE="$BUILD_TYPE BOOST"
11249    SYSTEM_BOOST=
11250    if test "${COM}" = "GCC" -o "${COM_IS_CLANG}" = "TRUE"; then
11251        # use warning-suppressing wrapper headers
11252        BOOST_CPPFLAGS="-I${SRC_ROOT}/external/boost/include -I${WORKDIR}/UnpackedTarball/boost"
11253    else
11254        BOOST_CPPFLAGS="-I${WORKDIR}/UnpackedTarball/boost"
11255    fi
11256fi
11257AC_SUBST(SYSTEM_BOOST)
11258
11259dnl ===================================================================
11260dnl Check for system mdds
11261dnl ===================================================================
11262MDDS_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/mdds/include"
11263libo_CHECK_SYSTEM_MODULE([mdds],[MDDS],[mdds-3.0 >= 3.0.0])
11264
11265dnl ===================================================================
11266dnl Check for system dragonbox
11267dnl ===================================================================
11268AC_MSG_CHECKING([which dragonbox to use])
11269if test "$with_system_dragonbox" = "yes"; then
11270    AC_MSG_RESULT([external])
11271    SYSTEM_DRAGONBOX=TRUE
11272    AC_LANG_PUSH([C++])
11273    save_CPPFLAGS=$CPPFLAGS
11274    # This is where upstream installs to, unfortunately no .pc or so...
11275    DRAGONBOX_CFLAGS=-I/usr/include/dragonbox-1.1.3
11276    CPPFLAGS="$CPPFLAGS $DRAGONBOX_CFLAGS"
11277    AC_CHECK_HEADER([dragonbox/dragonbox.h], [],
11278       [AC_MSG_ERROR([dragonbox/dragonbox.h not found. install dragonbox])], [])
11279    AC_LANG_POP([C++])
11280    CPPFLAGS=$save_CPPFLAGS
11281else
11282    AC_MSG_RESULT([internal])
11283    BUILD_TYPE="$BUILD_TYPE DRAGONBOX"
11284    SYSTEM_DRAGONBOX=
11285fi
11286AC_SUBST([SYSTEM_DRAGONBOX])
11287AC_SUBST([DRAGONBOX_CFLAGS])
11288
11289dnl ===================================================================
11290dnl Check for system frozen
11291dnl ===================================================================
11292AC_MSG_CHECKING([which frozen to use])
11293if test "$with_system_frozen" = "yes"; then
11294    AC_MSG_RESULT([external])
11295    SYSTEM_FROZEN=TRUE
11296    AC_LANG_PUSH([C++])
11297    save_CPPFLAGS=$CPPFLAGS
11298    AC_CHECK_HEADER([frozen/unordered_map.h], [],
11299       [AC_MSG_ERROR([frozen/unordered_map.h not found. install frozen headers])], [])
11300    AC_LANG_POP([C++])
11301    CPPFLAGS=$save_CPPFLAGS
11302else
11303    AC_MSG_RESULT([internal])
11304    BUILD_TYPE="$BUILD_TYPE FROZEN"
11305    SYSTEM_FROZEN=
11306fi
11307AC_SUBST([SYSTEM_FROZEN])
11308AC_SUBST([FROZEN_CFLAGS])
11309
11310dnl ===================================================================
11311dnl Check for system libfixmath
11312dnl ===================================================================
11313AC_MSG_CHECKING([which libfixmath to use])
11314if test "$with_system_libfixmath" = "yes"; then
11315    AC_MSG_RESULT([external])
11316    SYSTEM_LIBFIXMATH=TRUE
11317    AC_LANG_PUSH([C++])
11318    AC_CHECK_HEADER([libfixmath/fix16.hpp], [],
11319       [AC_MSG_ERROR([libfixmath/fix16.hpp not found. install libfixmath])], [])
11320    AC_CHECK_LIB([libfixmath], [fix16_mul], [LIBFIXMATH_LIBS=-llibfixmath],
11321                 [AC_CHECK_LIB([fixmath], [fix16_mul], [LIBFIXMATH_LIBS=-lfixmath],
11322                               [AC_MSG_ERROR(libfixmath lib not found or functional)])])
11323    AC_LANG_POP([C++])
11324else
11325    AC_MSG_RESULT([internal])
11326    SYSTEM_LIBFIXMATH=
11327    LIBFIXMATH_LIBS=
11328fi
11329AC_SUBST([SYSTEM_LIBFIXMATH])
11330AC_SUBST([LIBFIXMATH_LIBS])
11331
11332dnl ===================================================================
11333dnl Check for system glm
11334dnl ===================================================================
11335AC_MSG_CHECKING([which glm to use])
11336if test "$with_system_glm" = "yes"; then
11337    AC_MSG_RESULT([external])
11338    SYSTEM_GLM=TRUE
11339    AC_LANG_PUSH([C++])
11340    AC_CHECK_HEADER([glm/glm.hpp], [],
11341       [AC_MSG_ERROR([glm/glm.hpp not found. install glm])], [])
11342    AC_LANG_POP([C++])
11343else
11344    AC_MSG_RESULT([internal])
11345    BUILD_TYPE="$BUILD_TYPE GLM"
11346    SYSTEM_GLM=
11347    GLM_CFLAGS="${ISYSTEM}${WORKDIR}/UnpackedTarball/glm"
11348fi
11349AC_SUBST([GLM_CFLAGS])
11350AC_SUBST([SYSTEM_GLM])
11351
11352dnl ===================================================================
11353dnl Check for system odbc
11354dnl ===================================================================
11355AC_MSG_CHECKING([which odbc headers to use])
11356if test "$with_system_odbc" = "yes" -o '(' "$with_system_headers" = "yes" -a "$with_system_odbc" = "auto" ')' -o '(' "$_os" = "WINNT" -a  "$with_system_odbc" != "no" ')'; then
11357    AC_MSG_RESULT([external])
11358    SYSTEM_ODBC_HEADERS=TRUE
11359
11360    if test "$build_os" = "cygwin" -o "$build_os" = "wsl" -o -n "$WSL_ONLY_AS_HELPER"; then
11361        save_CPPFLAGS=$CPPFLAGS
11362        find_winsdk
11363        PathFormat "$winsdktest"
11364        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"
11365        AC_CHECK_HEADER(sqlext.h, [],
11366            [AC_MSG_ERROR(odbc not found. install odbc)],
11367            [#include <windows.h>])
11368        CPPFLAGS=$save_CPPFLAGS
11369    else
11370        AC_CHECK_HEADER(sqlext.h, [],
11371            [AC_MSG_ERROR(odbc not found. install odbc)],[])
11372    fi
11373elif test "$enable_database_connectivity" = no; then
11374    AC_MSG_RESULT([none])
11375else
11376    AC_MSG_RESULT([internal])
11377    SYSTEM_ODBC_HEADERS=
11378fi
11379AC_SUBST(SYSTEM_ODBC_HEADERS)
11380
11381dnl ===================================================================
11382dnl Check for system NSS
11383dnl ===================================================================
11384if test "$enable_fuzzers" != "yes" -a "$enable_nss" = "yes"; then
11385    libo_CHECK_SYSTEM_MODULE([nss],[NSS],[nss >= 3.9.3 nspr >= 4.8],,system-if-linux)
11386    AC_DEFINE(HAVE_FEATURE_NSS)
11387    ENABLE_NSS=TRUE
11388elif test $_os != iOS -a "$enable_openssl" != "no"; then
11389    with_tls=openssl
11390fi
11391AC_SUBST(ENABLE_NSS)
11392
11393dnl ===================================================================
11394dnl Enable LDAP support
11395dnl ===================================================================
11396
11397if test "$test_openldap" = yes; then
11398    AC_MSG_CHECKING([whether to enable LDAP support])
11399    if test "$enable_ldap" = yes -a \( "$enable_openssl" = yes -o "$with_system_openldap" = yes \); then
11400        AC_MSG_RESULT([yes])
11401        ENABLE_LDAP=TRUE
11402    else
11403        if test "$enable_ldap" != "yes"; then
11404            AC_MSG_RESULT([no])
11405        else
11406            AC_MSG_RESULT([no (needs OPENSSL or system openldap)])
11407        fi
11408    fi
11409
11410dnl ===================================================================
11411dnl Check for system openldap
11412dnl ===================================================================
11413
11414    if test "$ENABLE_LDAP" = TRUE; then
11415        AC_MSG_CHECKING([which openldap library to use])
11416        if test "$with_system_openldap" = yes; then
11417            AC_MSG_RESULT([external])
11418            SYSTEM_OPENLDAP=TRUE
11419            AC_CHECK_HEADERS(ldap.h, [], [AC_MSG_ERROR(ldap.h not found. install openldap libs)], [])
11420            AC_CHECK_LIB([ldap], [ldap_simple_bind_s], [:], [AC_MSG_ERROR(openldap lib not found or functional)], [])
11421            AC_CHECK_LIB([ldap], [ldap_set_option], [:], [AC_MSG_ERROR(openldap lib not found or functional)], [])
11422        else
11423            AC_MSG_RESULT([internal])
11424            BUILD_TYPE="$BUILD_TYPE OPENLDAP"
11425        fi
11426    fi
11427fi
11428
11429AC_SUBST(ENABLE_LDAP)
11430AC_SUBST(SYSTEM_OPENLDAP)
11431
11432dnl ===================================================================
11433dnl Check for TLS/SSL and cryptographic implementation to use
11434dnl ===================================================================
11435AC_MSG_CHECKING([which TLS/SSL and cryptographic implementation to use])
11436if test -n "$with_tls"; then
11437    case $with_tls in
11438    openssl)
11439        AC_DEFINE(USE_TLS_OPENSSL)
11440        TLS=OPENSSL
11441        AC_MSG_RESULT([$TLS])
11442
11443        if test "$enable_openssl" != "yes"; then
11444            AC_MSG_ERROR(["Disabling OpenSSL was requested, but the requested TLS to use is actually OpenSSL."])
11445        fi
11446
11447        # warn that OpenSSL has been selected but not all TLS code has this option
11448        AC_MSG_WARN([TLS/SSL implementation to use is OpenSSL but some code may still depend on NSS])
11449        add_warning "TLS/SSL implementation to use is OpenSSL but some code may still depend on NSS"
11450        ;;
11451    nss)
11452        AC_DEFINE(USE_TLS_NSS)
11453        TLS=NSS
11454        AC_MSG_RESULT([$TLS])
11455        ;;
11456    no)
11457        AC_MSG_RESULT([none])
11458        AC_MSG_WARN([Skipping TLS/SSL])
11459        ;;
11460    *)
11461        AC_MSG_RESULT([])
11462        AC_MSG_ERROR([unsupported implementation $with_tls. Supported are:
11463openssl - OpenSSL
11464nss - Mozilla's Network Security Services (NSS)
11465    ])
11466        ;;
11467    esac
11468else
11469    # default to using NSS, it results in smaller oox lib
11470    AC_DEFINE(USE_TLS_NSS)
11471    TLS=NSS
11472    AC_MSG_RESULT([$TLS])
11473fi
11474AC_SUBST(TLS)
11475
11476dnl ===================================================================
11477dnl Check for system sane
11478dnl ===================================================================
11479AC_MSG_CHECKING([which sane header to use])
11480if test "$with_system_sane" = "yes"; then
11481    AC_MSG_RESULT([external])
11482    AC_CHECK_HEADER(sane/sane.h, [],
11483      [AC_MSG_ERROR(sane not found. install sane)], [])
11484else
11485    AC_MSG_RESULT([internal])
11486    BUILD_TYPE="$BUILD_TYPE SANE"
11487fi
11488
11489dnl ===================================================================
11490dnl Check for system icu
11491dnl ===================================================================
11492ICU_MAJOR=77
11493ICU_MINOR=1
11494ICU_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/icu/source/i18n -I${WORKDIR}/UnpackedTarball/icu/source/common"
11495ICU_LIBS_internal="-L${WORKDIR}/UnpackedTarball/icu/source/lib -licuuc"
11496libo_CHECK_SYSTEM_MODULE([icu],[ICU],[icu-i18n >= 66])
11497if test "$SYSTEM_ICU" = TRUE; then
11498    AC_LANG_PUSH([C++])
11499    AC_MSG_CHECKING([for unicode/rbbi.h])
11500    AC_PREPROC_IFELSE([AC_LANG_SOURCE([[unicode/rbbi.h]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([icu headers not found])])
11501    AC_LANG_POP([C++])
11502
11503    ICU_VERSION=`$PKG_CONFIG --modversion icu-i18n 2>/dev/null`
11504    ICU_MAJOR=`echo $ICU_VERSION | cut -d"." -f1`
11505    ICU_MINOR=`echo $ICU_VERSION | cut -d"." -f2`
11506
11507    if test "$CROSS_COMPILING" != TRUE; then
11508        # using the system icu tools can lead to version confusion, use the
11509        # ones from the build environment when cross-compiling
11510        AC_PATH_PROG(SYSTEM_GENBRK, genbrk, [], [$PATH:/usr/sbin:/sbin])
11511        if test -z "$SYSTEM_GENBRK"; then
11512            AC_MSG_ERROR([\'genbrk\' not found in \$PATH, install the icu development tool \'genbrk\'])
11513        fi
11514        AC_PATH_PROG(SYSTEM_GENCCODE, genccode, [], [$PATH:/usr/sbin:/sbin:/usr/local/sbin])
11515        if test -z "$SYSTEM_GENCCODE"; then
11516            AC_MSG_ERROR([\'genccode\' not found in \$PATH, install the icu development tool \'genccode\'])
11517        fi
11518        AC_PATH_PROG(SYSTEM_GENCMN, gencmn, [], [$PATH:/usr/sbin:/sbin:/usr/local/sbin])
11519        if test -z "$SYSTEM_GENCMN"; then
11520            AC_MSG_ERROR([\'gencmn\' not found in \$PATH, install the icu development tool \'gencmn\'])
11521        fi
11522    fi
11523fi
11524
11525AC_SUBST(SYSTEM_GENBRK)
11526AC_SUBST(SYSTEM_GENCCODE)
11527AC_SUBST(SYSTEM_GENCMN)
11528AC_SUBST(ICU_MAJOR)
11529AC_SUBST(ICU_MINOR)
11530
11531dnl ==================================================================
11532dnl CURL
11533dnl ==================================================================
11534if test "$enable_curl" = "yes"; then
11535    AC_DEFINE([HAVE_FEATURE_CURL])
11536fi
11537
11538dnl ==================================================================
11539dnl Breakpad
11540dnl ==================================================================
11541DEFAULT_CRASHDUMP_VALUE="true"
11542AC_MSG_CHECKING([whether to enable breakpad])
11543if test "$enable_breakpad" != yes; then
11544    AC_MSG_RESULT([no])
11545else
11546    if test "$enable_curl" != "yes"; then
11547        AC_MSG_ERROR([--disable-breakpad must be used when --disable-curl is used])
11548    fi
11549    AC_MSG_RESULT([yes])
11550    ENABLE_BREAKPAD="TRUE"
11551    AC_DEFINE(ENABLE_BREAKPAD)
11552    AC_DEFINE(HAVE_FEATURE_BREAKPAD, 1)
11553    BUILD_TYPE="$BUILD_TYPE BREAKPAD"
11554
11555    AC_MSG_CHECKING([for disable crash dump])
11556    if test "$enable_crashdump" = no; then
11557        DEFAULT_CRASHDUMP_VALUE="false"
11558        AC_MSG_RESULT([yes])
11559    else
11560       AC_MSG_RESULT([no])
11561    fi
11562
11563    AC_MSG_CHECKING([for crashreport config])
11564    if test "$with_symbol_config" = "no"; then
11565        BREAKPAD_SYMBOL_CONFIG="invalid"
11566        AC_MSG_RESULT([no])
11567    else
11568        BREAKPAD_SYMBOL_CONFIG="$with_symbol_config"
11569        AC_DEFINE(BREAKPAD_SYMBOL_CONFIG)
11570        AC_MSG_RESULT([yes])
11571    fi
11572    AC_SUBST(BREAKPAD_SYMBOL_CONFIG)
11573fi
11574AC_SUBST(ENABLE_BREAKPAD)
11575AC_SUBST(DEFAULT_CRASHDUMP_VALUE)
11576
11577dnl ==================================================================
11578dnl libcmis
11579dnl ==================================================================
11580if test "$enable_libcmis" = "yes"; then
11581    if test "$enable_curl" != "yes"; then
11582        AC_MSG_ERROR([--disable-libcmis must be used when --disable-curl is used])
11583    fi
11584fi
11585
11586dnl ===================================================================
11587dnl Orcus
11588dnl ===================================================================
11589libo_CHECK_SYSTEM_MODULE([orcus],[ORCUS],[liborcus-0.20 >= 0.20.2])
11590if test "$with_system_orcus" != "yes"; then
11591    if test "$SYSTEM_BOOST" = "TRUE"; then
11592        dnl Link with Boost.System
11593        dnl This seems to be necessary since boost 1.50 (1.48 does not need it,
11594        dnl 1.49 is untested). The macro BOOST_THREAD_DONT_USE_SYSTEM mentioned
11595        dnl in documentation has no effect.
11596        AX_BOOST_SYSTEM
11597    fi
11598fi
11599dnl FIXME by renaming SYSTEM_LIBORCUS to SYSTEM_ORCUS in the build system world
11600SYSTEM_LIBORCUS=$SYSTEM_ORCUS
11601AC_SUBST([BOOST_SYSTEM_LIB])
11602AC_SUBST(SYSTEM_LIBORCUS)
11603
11604dnl ===================================================================
11605dnl HarfBuzz
11606dnl ===================================================================
11607harfbuzz_required_version=5.1.0
11608
11609GRAPHITE_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/graphite/include -DGRAPHITE2_STATIC"
11610HARFBUZZ_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/harfbuzz/src"
11611case "$_os" in
11612    Linux)
11613        GRAPHITE_LIBS_internal='$(gb_StaticLibrary_WORKDIR)/libgraphite.a'
11614        HARFBUZZ_LIBS_internal='$(gb_UnpackedTarball_workdir)/harfbuzz/builddir/src/libharfbuzz.a $(GRAPHITE_LIBS)'
11615        ;;
11616    WINNT)
11617        GRAPHITE_LIBS_internal='$(gb_StaticLibrary_WORKDIR)/graphite.lib'
11618        HARFBUZZ_LIBS_internal='$(gb_UnpackedTarball_workdir)/harfbuzz/builddir/src/libharfbuzz.a $(GRAPHITE_LIBS)'
11619        ;;
11620    *)
11621        GRAPHITE_LIBS_internal='-L$(gb_StaticLibrary_WORKDIR) -lgraphite'
11622        HARFBUZZ_LIBS_internal='-L$(gb_UnpackedTarball_workdir)/harfbuzz/builddir/src/ -lharfbuzz $(GRAPHITE_LIBS)'
11623        ;;
11624esac
11625libo_CHECK_SYSTEM_MODULE([graphite],[GRAPHITE],[graphite2 >= 0.9.3])
11626libo_CHECK_SYSTEM_MODULE([harfbuzz],[HARFBUZZ],[harfbuzz-icu >= $harfbuzz_required_version])
11627
11628if test "$with_system_harfbuzz" = "yes"; then
11629    if test "$with_system_graphite" = "no"; then
11630        AC_MSG_ERROR([--with-system-graphite must be used when --with-system-harfbuzz is used])
11631    fi
11632    AC_MSG_CHECKING([whether system Harfbuzz is built with Graphite support])
11633    save_LIBS="$LIBS"
11634    save_CFLAGS="$CFLAGS"
11635    LIBS="$LIBS $HARFBUZZ_LIBS"
11636    CFLAGS="$CFLAGS $HARFBUZZ_CFLAGS"
11637    AC_CHECK_FUNC(hb_graphite2_face_get_gr_face,,[AC_MSG_ERROR([Harfbuzz needs to be built with Graphite support.])])
11638    LIBS="$save_LIBS"
11639    CFLAGS="$save_CFLAGS"
11640else
11641    if test "$with_system_graphite" = "yes"; then
11642        AC_MSG_ERROR([--without-system-graphite must be used when --without-system-harfbuzz is used])
11643    fi
11644    # harfbuzz is now built using meson
11645    AC_ARG_VAR(MESON, [point to a specific meson to use instead of autodetecting])
11646    if test -z "$MESON"; then
11647        if test -z "$PYTHON_FOR_BUILD"; then
11648            # we also want to call meson with internal python and use internal meson
11649            BUILD_TYPE="$BUILD_TYPE MESON"
11650            MESON='$(gb_UnpackedTarball_workdir)/meson/meson.py'
11651        else
11652            # autodetect, prefer meson.py / standalone version that can more likely be run
11653            # by different python runtimes
11654            AC_PATH_PROGS(MESON,[meson.py meson],,[$LODE_HOME/packages/meson-1.7.2:$PATH])
11655            if test -z "$MESON"; then
11656                AC_MSG_WARN([meson not found, using internal copy])
11657                BUILD_TYPE="$BUILD_TYPE MESON"
11658                MESON='$(gb_UnpackedTarball_workdir)/meson/meson.py'
11659            else
11660                PathFormat "$MESON"
11661                MESON="$formatted_path"
11662                AC_MSG_CHECKING([whether meson can be run with "$PYTHON_FOR_BUILD $MESON"])
11663                if ($PYTHON_FOR_BUILD $MESON --version >/dev/null) ; then
11664                    AC_MSG_RESULT([yes])
11665                else
11666                    AC_MSG_RESULT([no])
11667                    AC_MSG_ERROR([meson incompatible with the specified python. Try using a different python runtime or a plain release of meson by adding PYTHON=/other/python.version and/or MESON=/path/to/meson.py to autogen.input])
11668                fi
11669            fi
11670        fi
11671        MESON='$(call gb_ExternalExecutable_get_command,python) '"$MESON"
11672    fi
11673    AC_CHECK_PROG(NINJA,ninja,ninja)
11674    if test -z "$MESON" -o -z "$NINJA"; then
11675        AC_MSG_ERROR([you need to have meson and ninja in order to build harfbuzz])
11676    fi
11677fi
11678if test -z "$NINJA" || test "$NINJA" = 'assumed to be available from Visual Studio'; then
11679    x_NINJA=[\#]
11680else
11681    x_NINJA=
11682fi
11683AC_SUBST(x_NINJA)
11684AC_SUBST(NINJA)
11685
11686if test "$USING_X11" = TRUE; then
11687    AC_PATH_X
11688    AC_PATH_XTRA
11689    CPPFLAGS="$CPPFLAGS $X_CFLAGS"
11690
11691    if test -z "$x_includes"; then
11692        x_includes="default_x_includes"
11693    fi
11694    if test -z "$x_libraries"; then
11695        x_libraries="default_x_libraries"
11696    fi
11697    CFLAGS="$CFLAGS $X_CFLAGS"
11698    LDFLAGS="$LDFLAGS $X_LDFLAGS $X_LIBS"
11699    AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS", [AC_MSG_ERROR([X Development libraries not found])])
11700else
11701    x_includes="no_x_includes"
11702    x_libraries="no_x_libraries"
11703fi
11704
11705if test "$USING_X11" = TRUE; then
11706    dnl ===================================================================
11707    dnl Check for extension headers
11708    dnl ===================================================================
11709    AC_CHECK_HEADERS(X11/extensions/shape.h,[],[AC_MSG_ERROR([libXext headers not found])],
11710     [#include <X11/extensions/shape.h>])
11711
11712    # vcl needs ICE and SM
11713    AC_CHECK_HEADERS(X11/ICE/ICElib.h,[],[AC_MSG_ERROR([libICE headers not found])])
11714    AC_CHECK_LIB([ICE], [IceConnectionNumber], [:],
11715        [AC_MSG_ERROR(ICE library not found)])
11716    AC_CHECK_HEADERS(X11/SM/SMlib.h,[],[AC_MSG_ERROR([libSM headers not found])])
11717    AC_CHECK_LIB([SM], [SmcOpenConnection], [:],
11718        [AC_MSG_ERROR(SM library not found)])
11719fi
11720
11721if test "$USING_X11" = TRUE -a "$ENABLE_JAVA" != ""; then
11722    # bean/native/unix/com_sun_star_comp_beans_LocalOfficeWindow.c needs Xt
11723    AC_CHECK_HEADERS(X11/Intrinsic.h,[],[AC_MSG_ERROR([libXt headers not found])])
11724fi
11725
11726dnl ===================================================================
11727dnl Check for system Xrender
11728dnl ===================================================================
11729AC_MSG_CHECKING([whether to use Xrender])
11730if test "$USING_X11" = TRUE -a  "$test_xrender" = "yes"; then
11731    AC_MSG_RESULT([yes])
11732    PKG_CHECK_MODULES(XRENDER, xrender)
11733    XRENDER_CFLAGS=$(printf '%s' "$XRENDER_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11734    FilterLibs "${XRENDER_LIBS}"
11735    XRENDER_LIBS="${filteredlibs}"
11736    AC_CHECK_LIB([Xrender], [XRenderQueryVersion], [:],
11737      [AC_MSG_ERROR(libXrender not found or functional)], [])
11738    AC_CHECK_HEADER(X11/extensions/Xrender.h, [],
11739      [AC_MSG_ERROR(Xrender not found. install X)], [])
11740else
11741    AC_MSG_RESULT([no])
11742fi
11743AC_SUBST(XRENDER_CFLAGS)
11744AC_SUBST(XRENDER_LIBS)
11745
11746dnl ===================================================================
11747dnl Check for XRandr
11748dnl ===================================================================
11749AC_MSG_CHECKING([whether to enable RandR support])
11750if test "$USING_X11" = TRUE -a "$test_randr" = "yes" -a \( "$enable_randr" = "yes" -o "$enable_randr" = "TRUE" \); then
11751    AC_MSG_RESULT([yes])
11752    PKG_CHECK_MODULES(XRANDR, xrandr >= 1.2, ENABLE_RANDR="TRUE", ENABLE_RANDR="")
11753    if test "$ENABLE_RANDR" != "TRUE"; then
11754        AC_CHECK_HEADER(X11/extensions/Xrandr.h, [],
11755                    [AC_MSG_ERROR([X11/extensions/Xrandr.h could not be found. X11 dev missing?])], [])
11756        XRANDR_CFLAGS=" "
11757        AC_CHECK_LIB([Xrandr], [XRRQueryExtension], [:],
11758          [ AC_MSG_ERROR(libXrandr not found or functional) ], [])
11759        XRANDR_LIBS="-lXrandr "
11760        ENABLE_RANDR="TRUE"
11761    fi
11762    XRANDR_CFLAGS=$(printf '%s' "$XRANDR_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11763    FilterLibs "${XRANDR_LIBS}"
11764    XRANDR_LIBS="${filteredlibs}"
11765else
11766    ENABLE_RANDR=""
11767    AC_MSG_RESULT([no])
11768fi
11769AC_SUBST(XRANDR_CFLAGS)
11770AC_SUBST(XRANDR_LIBS)
11771AC_SUBST(ENABLE_RANDR)
11772
11773if test -z "$with_webdav"; then
11774    with_webdav=$test_webdav
11775fi
11776
11777AC_MSG_CHECKING([for WebDAV support])
11778case "$with_webdav" in
11779no)
11780    AC_MSG_RESULT([no])
11781    WITH_WEBDAV=""
11782    ;;
11783*)
11784    AC_MSG_RESULT([yes])
11785    # curl is already mandatory (almost) and checked elsewhere
11786    if test "$enable_curl" = "no"; then
11787        AC_MSG_ERROR(["--without-webdav must be used when --disable-curl is used"])
11788    fi
11789    WITH_WEBDAV=TRUE
11790    ;;
11791esac
11792AC_SUBST(WITH_WEBDAV)
11793
11794dnl ===================================================================
11795dnl Check for disabling cve_tests
11796dnl ===================================================================
11797AC_MSG_CHECKING([whether to execute CVE tests])
11798if test "$enable_cve_tests" = "no"; then
11799    AC_MSG_RESULT([no])
11800    DISABLE_CVE_TESTS=TRUE
11801    AC_SUBST(DISABLE_CVE_TESTS)
11802else
11803    AC_MSG_RESULT([yes])
11804fi
11805
11806dnl ===================================================================
11807dnl Check for disabling nan_tests
11808dnl ===================================================================
11809AC_MSG_CHECKING([whether to execute NaN payload tests])
11810if test "$enable_nan_tests" = "no"; then
11811    AC_MSG_RESULT([no])
11812    DISABLE_NAN_TESTS=TRUE
11813    AC_SUBST(DISABLE_NAN_TESTS)
11814else
11815    AC_MSG_RESULT([yes])
11816fi
11817
11818dnl ===================================================================
11819dnl Check for system openssl
11820dnl ===================================================================
11821ENABLE_OPENSSL=
11822AC_MSG_CHECKING([whether to disable OpenSSL usage])
11823if test "$enable_openssl" = "yes"; then
11824    AC_MSG_RESULT([no])
11825    ENABLE_OPENSSL=TRUE
11826    if test "$_os" = Darwin ; then
11827        # OpenSSL is deprecated when building for 10.7 or later.
11828        #
11829        # https://stackoverflow.com/questions/7406946/why-is-apple-deprecating-openssl-in-macos-10-7-lion
11830        # https://stackoverflow.com/questions/7475914/libcrypto-deprecated-on-mac-os-x-10-7-lion
11831
11832        with_system_openssl=no
11833        libo_CHECK_SYSTEM_MODULE([openssl],[OPENSSL],[openssl])
11834    elif test "$_os" = "FreeBSD" -o "$_os" = "NetBSD" -o "$_os" = "OpenBSD" -o "$_os" = "DragonFly" \
11835            && test "$with_system_openssl" != "no"; then
11836        with_system_openssl=yes
11837        SYSTEM_OPENSSL=TRUE
11838        OPENSSL_CFLAGS=
11839        OPENSSL_LIBS="-lssl -lcrypto"
11840    else
11841        libo_CHECK_SYSTEM_MODULE([openssl],[OPENSSL],[openssl])
11842        if test -n "${SYSTEM_OPENSSL}"; then
11843            AC_DEFINE([SYSTEM_OPENSSL])
11844        fi
11845    fi
11846    if test "$with_system_openssl" = "yes"; then
11847        AC_MSG_CHECKING([whether openssl supports SHA512])
11848        AC_LANG_PUSH([C])
11849        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <openssl/sha.h>]],[[
11850            SHA512_CTX context;
11851]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no, openssl too old. Need >= 0.9.8.])])
11852        AC_LANG_POP(C)
11853    fi
11854else
11855    AC_MSG_RESULT([yes])
11856
11857    # warn that although OpenSSL is disabled, system libraries may depend on it
11858    AC_MSG_WARN([OpenSSL has been disabled. No code compiled here will make use of it but system libraries may create indirect dependencies])
11859    add_warning "OpenSSL has been disabled. No code compiled here will make use of it but system libraries may create indirect dependencies"
11860fi
11861
11862AC_SUBST([ENABLE_OPENSSL])
11863
11864if test "$enable_cipher_openssl_backend" = yes && test "$ENABLE_OPENSSL" != TRUE; then
11865    if test "$libo_fuzzed_enable_cipher_openssl_backend" = yes; then
11866        AC_MSG_NOTICE([Resetting --enable-cipher-openssl-backend=no])
11867        enable_cipher_openssl_backend=no
11868    else
11869        AC_MSG_ERROR([--enable-cipher-openssl-backend needs OpenSSL, but --disable-openssl was given.])
11870    fi
11871fi
11872AC_MSG_CHECKING([whether to enable the OpenSSL backend for rtl/cipher.h])
11873ENABLE_CIPHER_OPENSSL_BACKEND=
11874if test "$enable_cipher_openssl_backend" = yes; then
11875    AC_MSG_RESULT([yes])
11876    ENABLE_CIPHER_OPENSSL_BACKEND=TRUE
11877else
11878    AC_MSG_RESULT([no])
11879fi
11880AC_SUBST([ENABLE_CIPHER_OPENSSL_BACKEND])
11881
11882dnl ===================================================================
11883dnl Select the crypto backends used by LO
11884dnl ===================================================================
11885
11886if test "$build_crypto" = yes; then
11887    if test "$OS" = WNT; then
11888        BUILD_TYPE="$BUILD_TYPE CRYPTO_MSCAPI"
11889        AC_DEFINE([USE_CRYPTO_MSCAPI])
11890    elif test "$ENABLE_NSS" = TRUE; then
11891        BUILD_TYPE="$BUILD_TYPE CRYPTO_NSS"
11892        AC_DEFINE([USE_CRYPTO_NSS])
11893    fi
11894fi
11895
11896ARGON2_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/argon2/include"
11897if test "$COM" = "MSC"; then
11898    ARGON2_LIBS_internal="${WORKDIR}/UnpackedTarball/argon2/vs2015/build/Argon2OptDll.lib"
11899else
11900    ARGON2_LIBS_internal="${WORKDIR}/UnpackedTarball/argon2/libargon2.a"
11901fi
11902libo_CHECK_SYSTEM_MODULE([argon2],[ARGON2],[libargon2])
11903
11904dnl ===================================================================
11905dnl Check for system redland
11906dnl ===================================================================
11907dnl redland: versions before 1.0.8 write RDF/XML that is useless for ODF (@xml:base)
11908dnl raptor2: need at least 2.0.7 for CVE-2012-0037
11909libo_CHECK_SYSTEM_MODULE([redland],[REDLAND],[redland >= 1.0.8 raptor2 >= 2.0.7])
11910if test "$with_system_redland" = "yes"; then
11911    AC_CHECK_LIB([rdf], [librdf_world_set_raptor_init_handler], [:],
11912            [AC_MSG_ERROR(librdf too old. Need >= 1.0.16)], [])
11913else
11914    RAPTOR_MAJOR="0"
11915    RASQAL_MAJOR="3"
11916    REDLAND_MAJOR="0"
11917fi
11918AC_SUBST(RAPTOR_MAJOR)
11919AC_SUBST(RASQAL_MAJOR)
11920AC_SUBST(REDLAND_MAJOR)
11921
11922dnl ===================================================================
11923dnl Check for system hunspell
11924dnl ===================================================================
11925AC_MSG_CHECKING([which libhunspell to use])
11926if test "$with_system_hunspell" = "yes"; then
11927    AC_MSG_RESULT([external])
11928    SYSTEM_HUNSPELL=TRUE
11929    AC_LANG_PUSH([C++])
11930    PKG_CHECK_MODULES(HUNSPELL, hunspell, HUNSPELL_PC="TRUE", HUNSPELL_PC="" )
11931    if test "$HUNSPELL_PC" != "TRUE"; then
11932        AC_CHECK_HEADER(hunspell.hxx, [],
11933            [
11934            AC_CHECK_HEADER(hunspell/hunspell.hxx, [ HUNSPELL_CFLAGS=-I/usr/include/hunspell ],
11935            [AC_MSG_ERROR(hunspell headers not found.)], [])
11936            ], [])
11937        AC_CHECK_LIB([hunspell], [main], [:],
11938           [ AC_MSG_ERROR(hunspell library not found.) ], [])
11939        HUNSPELL_LIBS=-lhunspell
11940    fi
11941    AC_LANG_POP([C++])
11942    HUNSPELL_CFLAGS=$(printf '%s' "$HUNSPELL_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11943    FilterLibs "${HUNSPELL_LIBS}"
11944    HUNSPELL_LIBS="${filteredlibs}"
11945else
11946    AC_MSG_RESULT([internal])
11947    SYSTEM_HUNSPELL=
11948    HUNSPELL_CFLAGS="-I${WORKDIR}/UnpackedTarball/hunspell/src/hunspell"
11949    if test "$COM" = "MSC"; then
11950        HUNSPELL_LIBS='$(gb_StaticLibrary_WORKDIR)/hunspell.lib'
11951    else
11952        HUNSPELL_LIBS="-L${WORKDIR}/UnpackedTarball/hunspell/src/hunspell/.libs -lhunspell-1.7"
11953    fi
11954    BUILD_TYPE="$BUILD_TYPE HUNSPELL"
11955fi
11956AC_SUBST(SYSTEM_HUNSPELL)
11957AC_SUBST(HUNSPELL_CFLAGS)
11958AC_SUBST(HUNSPELL_LIBS)
11959
11960dnl ===================================================================
11961dnl Check for system zxcvbn
11962dnl ===================================================================
11963AC_MSG_CHECKING([which zxcvbn to use])
11964if test "$with_system_zxcvbn" = "yes"; then
11965    AC_MSG_RESULT([external])
11966    SYSTEM_ZXCVBN=TRUE
11967    AC_CHECK_HEADER(zxcvbn.h, [],
11968       [ AC_MSG_ERROR(zxcvbn headers not found.)], [])
11969    AC_CHECK_LIB(zxcvbn, ZxcvbnMatch, [],
11970        [ AC_MSG_ERROR(zxcvbn library not found.)], [])
11971else
11972   AC_MSG_RESULT([internal])
11973   BUILD_TYPE="$BUILD_TYPE ZXCVBN"
11974   SYSTEM_ZXCVBN=
11975fi
11976AC_SUBST(SYSTEM_ZXCVBN)
11977
11978dnl ===================================================================
11979dnl Check for system zxing
11980dnl ===================================================================
11981AC_MSG_CHECKING([whether to use zxing])
11982if test "$enable_zxing" = "no"; then
11983    AC_MSG_RESULT([no])
11984    ENABLE_ZXING=
11985    SYSTEM_ZXING=
11986else
11987    AC_MSG_RESULT([yes])
11988    ENABLE_ZXING=TRUE
11989    AC_MSG_CHECKING([which libzxing to use])
11990    if test "$with_system_zxing" = "yes"; then
11991        AC_MSG_RESULT([external])
11992        SYSTEM_ZXING=TRUE
11993        ZXING_CFLAGS=
11994        AC_LANG_PUSH([C++])
11995        save_CXXFLAGS=$CXXFLAGS
11996        save_IFS=$IFS
11997        IFS=$P_SEP
11998        for i in $CPLUS_INCLUDE_PATH /usr/include; do
11999            dnl Reset IFS as soon as possible, to avoid unexpected side effects (and the
12000            dnl "/usr/include" fallback makes sure we get here at least once; resetting rather than
12001            dnl unsetting follows the advice at <https://git.savannah.gnu.org/gitweb/?p=autoconf.git;
12002            dnl a=commitdiff;h=e51c9919f2cf70185b7916ac040bc0bbfd0f743b> "Add recommendation on (not)
12003            dnl unsetting IFS."):
12004            IFS=$save_IFS
12005            dnl TODO: GCC and Clang treat empty paths in CPLUS_INCLUDE_PATH like ".", but we simply
12006            dnl ignore them here:
12007            if test -z "$i"; then
12008                continue
12009            fi
12010            dnl TODO: White space in $i would cause problems:
12011            CXXFLAGS="$save_CXXFLAGS ${CXXFLAGS_CXX11} -I$i/ZXing"
12012            AC_CHECK_HEADER(MultiFormatWriter.h, [ZXING_CFLAGS=-I$i/ZXing; break],
12013                [unset ac_cv_header_MultiFormatWriter_h], [#include <stdexcept>])
12014        done
12015        CXXFLAGS=$save_CXXFLAGS
12016        if test -z "$ZXING_CFLAGS"; then
12017            AC_MSG_ERROR(zxing headers not found.)
12018        fi
12019        AC_CHECK_LIB([ZXing], [main], [ZXING_LIBS=-lZXing],
12020            [ AC_CHECK_LIB([ZXingCore], [main], [ZXING_LIBS=-lZXingCore],
12021            [ AC_MSG_ERROR(zxing C++ library not found.) ])], [])
12022        AC_LANG_POP([C++])
12023        ZXING_CFLAGS=$(printf '%s' "$ZXING_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12024        FilterLibs "${ZXING_LIBS}"
12025        ZXING_LIBS="${filteredlibs}"
12026    else
12027        AC_MSG_RESULT([internal])
12028        SYSTEM_ZXING=
12029        BUILD_TYPE="$BUILD_TYPE ZXING"
12030        ZXING_CFLAGS="-I${WORKDIR}/UnpackedTarball/zxing/core/src"
12031    fi
12032    if test "$ENABLE_ZXING" = TRUE; then
12033        AC_DEFINE(ENABLE_ZXING)
12034    fi
12035    AC_MSG_CHECKING([whether zxing::tosvg function is available])
12036    AC_LANG_PUSH([C++])
12037    save_CXXFLAGS=$CXXFLAGS
12038    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11 $ZXING_CFLAGS"
12039    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12040            #include <BitMatrix.h>
12041            #include <BitMatrixIO.h>
12042            int main(){
12043                ZXing::BitMatrix matrix(1, 1);
12044                matrix.set(0, 0, true);
12045                ZXing::ToSVG(matrix);
12046                return 0;
12047            }
12048        ])], [
12049            AC_DEFINE([HAVE_ZXING_TOSVG],[1])
12050            AC_MSG_RESULT([yes])
12051        ], [AC_MSG_RESULT([no])])
12052    CXXFLAGS=$save_CXXFLAGS
12053    AC_LANG_POP([C++])
12054    AC_SUBST(HAVE_ZXING_TOSVG)
12055fi
12056AC_SUBST(SYSTEM_ZXING)
12057AC_SUBST(ENABLE_ZXING)
12058AC_SUBST(ZXING_CFLAGS)
12059AC_SUBST(ZXING_LIBS)
12060
12061dnl ===================================================================
12062dnl Check for system box2d
12063dnl ===================================================================
12064AC_MSG_CHECKING([which box2d to use])
12065if test "$with_system_box2d" = "yes"; then
12066    AC_MSG_RESULT([external])
12067    SYSTEM_BOX2D=TRUE
12068    AC_LANG_PUSH([C++])
12069    AC_CHECK_HEADER(box2d/box2d.h, [BOX2D_H_FOUND='TRUE'],
12070        [BOX2D_H_FOUND='FALSE'])
12071    if test "$BOX2D_H_FOUND" = "TRUE"; then # 2.4.0+
12072        _BOX2D_LIB=box2d
12073        AC_DEFINE(BOX2D_HEADER,<box2d/box2d.h>)
12074    else
12075        # fail this. there's no other alternative to check when we are here.
12076        AC_CHECK_HEADER([Box2D/Box2D.h], [],
12077            [AC_MSG_ERROR(box2d headers not found.)])
12078        _BOX2D_LIB=Box2D
12079        AC_DEFINE(BOX2D_HEADER,<Box2D/Box2D.h>)
12080    fi
12081    AC_CHECK_LIB([$_BOX2D_LIB], [main], [:],
12082        [ AC_MSG_ERROR(box2d library not found.) ], [])
12083    BOX2D_LIBS=-l$_BOX2D_LIB
12084    AC_LANG_POP([C++])
12085    BOX2D_CFLAGS=$(printf '%s' "$BOX2D_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12086    FilterLibs "${BOX2D_LIBS}"
12087    BOX2D_LIBS="${filteredlibs}"
12088else
12089    AC_MSG_RESULT([internal])
12090    SYSTEM_BOX2D=
12091    BUILD_TYPE="$BUILD_TYPE BOX2D"
12092fi
12093AC_SUBST(SYSTEM_BOX2D)
12094AC_SUBST(BOX2D_CFLAGS)
12095AC_SUBST(BOX2D_LIBS)
12096
12097dnl ===================================================================
12098dnl Checking for altlinuxhyph
12099dnl ===================================================================
12100AC_MSG_CHECKING([which altlinuxhyph to use])
12101if test "$with_system_altlinuxhyph" = "yes"; then
12102    AC_MSG_RESULT([external])
12103    SYSTEM_HYPH=TRUE
12104    AC_CHECK_HEADER(hyphen.h, [],
12105       [ AC_MSG_ERROR(altlinuxhyph headers not found.)], [])
12106    AC_CHECK_MEMBER(struct _HyphenDict.cset, [],
12107       [ AC_MSG_ERROR(no. You are sure you have altlinuxhyph headers?)],
12108       [#include <hyphen.h>])
12109    AC_CHECK_LIB(hyphen, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhyphen],
12110        [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
12111    if test -z "$HYPHEN_LIB"; then
12112        AC_CHECK_LIB(hyph, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhyph],
12113           [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
12114    fi
12115    if test -z "$HYPHEN_LIB"; then
12116        AC_CHECK_LIB(hnj, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhnj],
12117           [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
12118    fi
12119else
12120    AC_MSG_RESULT([internal])
12121    SYSTEM_HYPH=
12122    BUILD_TYPE="$BUILD_TYPE HYPHEN"
12123    if test "$COM" = "MSC"; then
12124        HYPHEN_LIB='$(gb_StaticLibrary_WORKDIR)/hyphen.lib'
12125    else
12126        HYPHEN_LIB="-L${WORKDIR}/UnpackedTarball/hyphen/.libs -lhyphen"
12127    fi
12128fi
12129AC_SUBST(SYSTEM_HYPH)
12130AC_SUBST(HYPHEN_LIB)
12131
12132dnl ===================================================================
12133dnl Checking for mythes
12134dnl ===================================================================
12135AC_MSG_CHECKING([which mythes to use])
12136if test "$with_system_mythes" = "yes"; then
12137    AC_MSG_RESULT([external])
12138    SYSTEM_MYTHES=TRUE
12139    AC_LANG_PUSH([C++])
12140    PKG_CHECK_MODULES(MYTHES, mythes, MYTHES_PKGCONFIG=yes, MYTHES_PKGCONFIG=no)
12141    if test "$MYTHES_PKGCONFIG" = "no"; then
12142        AC_CHECK_HEADER(mythes.hxx, [],
12143            [ AC_MSG_ERROR(mythes.hxx headers not found.)], [])
12144        AC_CHECK_LIB([mythes-1.2], [main], [:],
12145            [ MYTHES_FOUND=no], [])
12146    if test "$MYTHES_FOUND" = "no"; then
12147        AC_CHECK_LIB(mythes, main, [MYTHES_FOUND=yes],
12148                [ MYTHES_FOUND=no], [])
12149    fi
12150    if test "$MYTHES_FOUND" = "no"; then
12151        AC_MSG_ERROR([mythes library not found!.])
12152    fi
12153    fi
12154    AC_LANG_POP([C++])
12155    MYTHES_CFLAGS=$(printf '%s' "$MYTHES_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12156    FilterLibs "${MYTHES_LIBS}"
12157    MYTHES_LIBS="${filteredlibs}"
12158else
12159    AC_MSG_RESULT([internal])
12160    SYSTEM_MYTHES=
12161    BUILD_TYPE="$BUILD_TYPE MYTHES"
12162    if test "$COM" = "MSC"; then
12163        MYTHES_LIBS='$(gb_StaticLibrary_WORKDIR)/mythes.lib'
12164    else
12165        MYTHES_LIBS="-L${WORKDIR}/UnpackedTarball/mythes/.libs -lmythes-1.2"
12166    fi
12167fi
12168AC_SUBST(SYSTEM_MYTHES)
12169AC_SUBST(MYTHES_CFLAGS)
12170AC_SUBST(MYTHES_LIBS)
12171
12172dnl ===================================================================
12173dnl How should we build the linear programming solver ?
12174dnl ===================================================================
12175
12176ENABLE_COINMP=
12177AC_MSG_CHECKING([whether to build with CoinMP])
12178if test "$enable_coinmp" != "no"; then
12179    ENABLE_COINMP=TRUE
12180    AC_MSG_RESULT([yes])
12181    if test "$with_system_coinmp" = "yes"; then
12182        SYSTEM_COINMP=TRUE
12183        PKG_CHECK_MODULES(COINMP, coinmp coinutils)
12184        FilterLibs "${COINMP_LIBS}"
12185        COINMP_LIBS="${filteredlibs}"
12186    else
12187        BUILD_TYPE="$BUILD_TYPE COINMP"
12188    fi
12189else
12190    AC_MSG_RESULT([no])
12191fi
12192AC_SUBST(ENABLE_COINMP)
12193AC_SUBST(SYSTEM_COINMP)
12194AC_SUBST(COINMP_CFLAGS)
12195AC_SUBST(COINMP_LIBS)
12196
12197ENABLE_LPSOLVE=
12198AC_MSG_CHECKING([whether to build with lpsolve])
12199if test "$enable_lpsolve" != "no"; then
12200    ENABLE_LPSOLVE=TRUE
12201    AC_MSG_RESULT([yes])
12202else
12203    AC_MSG_RESULT([no])
12204fi
12205AC_SUBST(ENABLE_LPSOLVE)
12206
12207if test "$ENABLE_LPSOLVE" = TRUE; then
12208    AC_MSG_CHECKING([which lpsolve to use])
12209    if test "$with_system_lpsolve" = "yes"; then
12210        AC_MSG_RESULT([external])
12211        SYSTEM_LPSOLVE=TRUE
12212        AC_CHECK_HEADER(lpsolve/lp_lib.h, [],
12213           [ AC_MSG_ERROR(lpsolve headers not found.)], [])
12214        save_LIBS=$LIBS
12215        # some systems need this. Like Ubuntu...
12216        AC_CHECK_LIB(m, floor)
12217        AC_CHECK_LIB(dl, dlopen)
12218        AC_CHECK_LIB([lpsolve55], [make_lp], [:],
12219            [ AC_MSG_ERROR(lpsolve library not found or too old.)], [])
12220        LIBS=$save_LIBS
12221    else
12222        AC_MSG_RESULT([internal])
12223        SYSTEM_LPSOLVE=
12224        BUILD_TYPE="$BUILD_TYPE LPSOLVE"
12225        AC_MSG_CHECKING([which colamd to use])
12226        if test "$with_system_colamd" = "yes"; then
12227               AC_MSG_RESULT([external])
12228               SYSTEM_COLAMD=TRUE
12229               # This assumes suitesparse, which has
12230               # /usr/lib/x86_64-linux-gnu/pkgconfig/COLAMD.pc
12231               PKG_CHECK_MODULES([COLAMD], [COLAMD],
12232                      [],
12233                      [
12234                       # older versions don't. Look in /usr/include/suitesparse
12235                       COLAMD_CFLAGS=-I/usr/include/suitesparse
12236                       save_CFLAGS=$CFLAGS
12237                       CFLAGS="$CFLAGS $COLAMD_CFLAGS"
12238                       AC_CHECK_HEADER(colamd.h, [],
12239                               [ AC_MSG_ERROR(colamd.h header not found.)], [])
12240                       CFLAGS=$save_CFLAGS
12241                       AC_CHECK_LIB(colamd, colamd)
12242                       COLAMD_LIBS=-lcolamd
12243                     ])
12244       else
12245               AC_MSG_RESULT([internal])
12246               SYSTEM_COLAMD=
12247       fi
12248    fi
12249fi
12250AC_SUBST(SYSTEM_COLAMD)
12251AC_SUBST(COLAMD_CFLAGS)
12252AC_SUBST(COLAMD_LIBS)
12253AC_SUBST(SYSTEM_LPSOLVE)
12254
12255dnl ===================================================================
12256dnl Checking for libexttextcat
12257dnl ===================================================================
12258libo_CHECK_SYSTEM_MODULE([libexttextcat],[LIBEXTTEXTCAT],[libexttextcat >= 3.4.1])
12259if test "$with_system_libexttextcat" = "yes"; then
12260    SYSTEM_LIBEXTTEXTCAT_DATA=file://`$PKG_CONFIG --variable=pkgdatadir libexttextcat`
12261fi
12262AC_SUBST(SYSTEM_LIBEXTTEXTCAT_DATA)
12263
12264dnl ===================================================================
12265dnl Checking for libnumbertext
12266dnl ===================================================================
12267libo_CHECK_SYSTEM_MODULE([libnumbertext],[LIBNUMBERTEXT],[libnumbertext >= 1.0.6])
12268if test "$with_system_libnumbertext" = "yes"; then
12269    SYSTEM_LIBNUMBERTEXT_DATA=file://`$PKG_CONFIG --variable=pkgdatadir libnumbertext`
12270    SYSTEM_LIBNUMBERTEXT=YES
12271else
12272    SYSTEM_LIBNUMBERTEXT=
12273fi
12274AC_SUBST(SYSTEM_LIBNUMBERTEXT)
12275AC_SUBST(SYSTEM_LIBNUMBERTEXT_DATA)
12276
12277dnl ***************************************
12278dnl testing libc version for Linux...
12279dnl ***************************************
12280if test "$_os" = "Linux"; then
12281    AC_MSG_CHECKING([whether the libc is recent enough])
12282    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
12283    #include <features.h>
12284    #if defined(__GNU_LIBRARY__) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1))
12285    #error glibc >= 2.1 is required
12286    #endif
12287    ]])],, [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([no, upgrade libc])])
12288fi
12289
12290dnl =========================================
12291dnl Check for uuidgen
12292dnl =========================================
12293if test "$_os" = "WINNT"; then
12294    # we must use the uuidgen from the Windows SDK, which will be in the LO_PATH, but isn't in
12295    # the PATH for AC_PATH_PROG. It is already tested above in the WINDOWS_SDK_HOME check.
12296    UUIDGEN=uuidgen.exe
12297    AC_SUBST(UUIDGEN)
12298else
12299    AC_PATH_PROG([UUIDGEN], [uuidgen])
12300    if test -z "$UUIDGEN"; then
12301        AC_MSG_WARN([uuid is needed for building installation sets])
12302    fi
12303fi
12304
12305dnl ***************************************
12306dnl Checking for bison and flex
12307dnl ***************************************
12308AC_PATH_PROG(BISON, bison)
12309if test -z "$BISON"; then
12310    AC_MSG_ERROR([no bison found in \$PATH, install it])
12311else
12312    AC_MSG_CHECKING([the bison version])
12313    _bison_version=`$BISON --version | grep GNU | $SED -e 's@^[[^0-9]]*@@' -e 's@ .*@@' -e 's@,.*@@'`
12314    _bison_longver=`echo $_bison_version | $AWK -F. '{ print \$1*1000+\$2}'`
12315    dnl Accept newer than 2.0; for --enable-compiler-plugins at least 2.3 is known to be bad and
12316    dnl cause
12317    dnl
12318    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]
12319    dnl   typedef union YYSTYPE
12320    dnl           ~~~~~~^~~~~~~
12321    dnl
12322    dnl while at least 3.4.1 is know to be good:
12323    if test "$COMPILER_PLUGINS" = TRUE; then
12324        if test "$_bison_longver" -lt 2004; then
12325            AC_MSG_ERROR([failed ($BISON $_bison_version need 2.4+ for --enable-compiler-plugins)])
12326        fi
12327    else
12328        if test "$_bison_longver" -lt 2000; then
12329            AC_MSG_ERROR([failed ($BISON $_bison_version need 2.0+)])
12330        fi
12331    fi
12332fi
12333AC_SUBST([BISON])
12334
12335AC_PATH_PROG(FLEX, flex)
12336if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
12337    FLEX=`cygpath -m $FLEX`
12338fi
12339if test -z "$FLEX"; then
12340    AC_MSG_ERROR([no flex found in \$PATH, install it])
12341else
12342    AC_MSG_CHECKING([the flex version])
12343    _flex_version=$($FLEX --version | $SED -e 's/^.*\([[[:digit:]]]\{1,\}\.[[[:digit:]]]\{1,\}\.[[[:digit:]]]\{1,\}\).*$/\1/')
12344    if test $(echo $_flex_version | $AWK -F. '{printf("%d%03d%03d", $1, $2, $3)}') -lt 2006000; then
12345        AC_MSG_ERROR([failed ($FLEX $_flex_version found, but need at least 2.6.0)])
12346    fi
12347fi
12348AC_SUBST([FLEX])
12349
12350AC_PATH_PROG(DIFF, diff)
12351if test -z "$DIFF"; then
12352    AC_MSG_ERROR(["diff" not found in \$PATH, install it])
12353fi
12354AC_SUBST([DIFF])
12355
12356AC_PATH_PROG(UNIQ, uniq)
12357if test -z "$UNIQ"; then
12358    AC_MSG_ERROR(["uniq" not found in \$PATH, install it])
12359fi
12360AC_SUBST([UNIQ])
12361
12362dnl ***************************************
12363dnl Checking for patch
12364dnl ***************************************
12365AC_PATH_PROG(PATCH, patch)
12366if test -z "$PATCH"; then
12367    AC_MSG_ERROR(["patch" not found in \$PATH, install it])
12368fi
12369
12370dnl On Solaris or macOS, check if --with-gnu-patch was used
12371if test "$_os" = "SunOS" -o "$_os" = "Darwin" -o "$_os" = "FreeBSD"; then
12372    if test -z "$with_gnu_patch"; then
12373        GNUPATCH=$PATCH
12374    else
12375        if test -x "$with_gnu_patch"; then
12376            GNUPATCH=$with_gnu_patch
12377        else
12378            AC_MSG_ERROR([--with-gnu-patch did not point to an executable])
12379        fi
12380    fi
12381
12382    AC_MSG_CHECKING([whether $GNUPATCH is GNU patch])
12383    if $GNUPATCH --version | grep "Free Software Foundation" >/dev/null 2>/dev/null; then
12384        AC_MSG_RESULT([yes])
12385    else
12386        if $GNUPATCH --version | grep "2\.0-.*-Apple" >/dev/null 2>/dev/null; then
12387            AC_MSG_RESULT([no, but accepted (Apple patch)])
12388        else
12389            AC_MSG_ERROR([no, GNU patch needed. install or specify with --with-gnu-patch=/path/to/it])
12390        fi
12391    fi
12392else
12393    GNUPATCH=$PATCH
12394fi
12395
12396if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
12397    GNUPATCH=`cygpath -m $GNUPATCH`
12398fi
12399
12400dnl We also need to check for --with-gnu-cp
12401
12402if test -z "$with_gnu_cp"; then
12403    # check the place where the good stuff is hidden on Solaris...
12404    if test -x /usr/gnu/bin/cp; then
12405        GNUCP=/usr/gnu/bin/cp
12406    else
12407        AC_PATH_PROGS(GNUCP, gnucp cp)
12408    fi
12409    if test -z $GNUCP; then
12410        AC_MSG_ERROR([Neither gnucp nor cp found. Install GNU cp and/or specify --with-gnu-cp=/path/to/it])
12411    fi
12412else
12413    if test -x "$with_gnu_cp"; then
12414        GNUCP=$with_gnu_cp
12415    else
12416        AC_MSG_ERROR([--with-gnu-cp did not point to an executable])
12417    fi
12418fi
12419
12420if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
12421    GNUCP=`cygpath -m $GNUCP`
12422fi
12423
12424AC_MSG_CHECKING([whether $GNUCP is GNU cp from coreutils with preserve= support])
12425if $GNUCP --version 2>/dev/null | grep "coreutils" >/dev/null 2>/dev/null; then
12426    AC_MSG_RESULT([yes])
12427elif $GNUCP --version 2>/dev/null | grep "GNU fileutils" >/dev/null 2>/dev/null; then
12428    AC_MSG_RESULT([yes])
12429else
12430    case "$build_os" in
12431    darwin*|netbsd*|openbsd*|freebsd*|dragonfly*)
12432        x_GNUCP=[\#]
12433        GNUCP=''
12434        AC_MSG_RESULT([no gnucp found - using the system's cp command])
12435        ;;
12436    *)
12437        AC_MSG_ERROR([no, GNU cp needed. install or specify with --with-gnu-cp=/path/to/it])
12438        ;;
12439    esac
12440fi
12441
12442AC_SUBST(GNUPATCH)
12443AC_SUBST(GNUCP)
12444AC_SUBST(x_GNUCP)
12445
12446dnl ***************************************
12447dnl testing assembler path
12448dnl ***************************************
12449ML_EXE=""
12450if test "$_os" = "WINNT"; then
12451    case "$WIN_HOST_ARCH" in
12452    x86) assembler=ml.exe ;;
12453    x64) assembler=ml64.exe ;;
12454    arm64) assembler=armasm64.exe ;;
12455    esac
12456
12457    AC_MSG_CHECKING([for the MSVC assembler ($assembler)])
12458    if test -f "$MSVC_HOST_PATH/$assembler"; then
12459        ML_EXE=`win_short_path_for_make "$MSVC_HOST_PATH/$assembler"`
12460        AC_MSG_RESULT([$ML_EXE])
12461    else
12462        AC_MSG_ERROR([not found in $MSVC_HOST_PATH])
12463    fi
12464fi
12465
12466AC_SUBST(ML_EXE)
12467
12468dnl ===================================================================
12469dnl We need zip and unzip
12470dnl ===================================================================
12471AC_PATH_PROG(ZIP, zip)
12472test -z "$ZIP" && AC_MSG_ERROR([zip is required])
12473if ! "$ZIP" --filesync < /dev/null 2>/dev/null > /dev/null; then
12474    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],,)
12475fi
12476
12477AC_PATH_PROG(UNZIP, unzip)
12478test -z "$UNZIP" && AC_MSG_ERROR([unzip is required])
12479
12480dnl ===================================================================
12481dnl Zip must be a specific type for different build types.
12482dnl ===================================================================
12483if test $build_os = cygwin; then
12484    if test -n "`$ZIP -h | $GREP -i WinNT`"; then
12485        AC_MSG_ERROR([$ZIP is not the required Cygwin version of Info-ZIP's zip.exe.])
12486    fi
12487fi
12488
12489dnl ===================================================================
12490dnl We need touch with -h option support.
12491dnl ===================================================================
12492AC_PATH_PROG(TOUCH, touch)
12493test -z "$TOUCH" && AC_MSG_ERROR([touch is required])
12494touch "$WARNINGS_FILE"
12495if ! "$TOUCH" -h "$WARNINGS_FILE" 2>/dev/null > /dev/null; then
12496    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],,)
12497fi
12498
12499dnl ===================================================================
12500dnl Check for system epoxy
12501dnl ===================================================================
12502EPOXY_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/epoxy/include"
12503libo_CHECK_SYSTEM_MODULE([epoxy], [EPOXY], [epoxy >= 1.2])
12504
12505dnl ===================================================================
12506dnl Show which vclplugs will be built.
12507dnl ===================================================================
12508R=""
12509
12510libo_ENABLE_VCLPLUG([gen])
12511libo_ENABLE_VCLPLUG([gtk3])
12512libo_ENABLE_VCLPLUG([gtk3_kde5])
12513libo_ENABLE_VCLPLUG([gtk4])
12514libo_ENABLE_VCLPLUG([kf5])
12515libo_ENABLE_VCLPLUG([kf6])
12516libo_ENABLE_VCLPLUG([qt5])
12517libo_ENABLE_VCLPLUG([qt6])
12518
12519if test "$_os" = "WINNT"; then
12520    R="$R win"
12521elif test "$_os" = "Darwin"; then
12522    R="$R osx"
12523elif test "$_os" = "iOS"; then
12524    R="ios"
12525elif test "$_os" = Android; then
12526    R="android"
12527fi
12528
12529build_vcl_plugins="$R"
12530if test -z "$build_vcl_plugins"; then
12531    build_vcl_plugins=" none"
12532fi
12533AC_MSG_NOTICE([VCLplugs to be built:${build_vcl_plugins}])
12534VCL_PLUGIN_INFO=$R
12535AC_SUBST([VCL_PLUGIN_INFO])
12536
12537if test "$DISABLE_DYNLOADING" = TRUE -a -z "$DISABLE_GUI" -a \( -z "$R" -o $(echo "$R" | wc -w) -ne 1 \); then
12538    AC_MSG_ERROR([Can't build --disable-dynamic-loading without --disable-gui and a single VCL plugin"])
12539fi
12540
12541dnl ===================================================================
12542dnl Check for GTK libraries
12543dnl ===================================================================
12544
12545GTK3_CFLAGS=""
12546GTK3_LIBS=""
12547ENABLE_GTKTILEDVIEWER=""
12548if test "$test_gtk3" = yes -a "x$enable_gtk3" = "xyes" -o "x$enable_gtk3_kde5" = "xyes"; then
12549    if test "$with_system_cairo" = no; then
12550        add_warning 'Non-system cairo combined with gtk3 is known to cause trouble (eg. broken image in the splashscreen). Use --with-system-cairo unless you know what you are doing.'
12551    fi
12552    : ${with_system_cairo:=yes}
12553    PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.20 gmodule-no-export-2.0 glib-2.0 >= 2.38 atk >= 2.28.1 cairo)
12554    GTK3_CFLAGS=$(printf '%s' "$GTK3_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12555    GTK3_CFLAGS="$GTK3_CFLAGS -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
12556    FilterLibs "${GTK3_LIBS}"
12557    GTK3_LIBS="${filteredlibs}"
12558
12559    dnl We require egl only for the gtk3 plugin. Otherwise we use glx.
12560    if test "$with_system_epoxy" != "yes"; then
12561        AC_CHECK_LIB(EGL, eglMakeCurrent, [:], AC_MSG_ERROR([libEGL required.]))
12562        AC_CHECK_HEADER(EGL/eglplatform.h, [],
12563                        [AC_MSG_ERROR(EGL headers not found. install mesa-libEGL-devel)], [])
12564    fi
12565elif test -n "$with_gtk3_build" -a "$OS" = "WNT"; then
12566    PathFormat "${with_gtk3_build}/lib/pkgconfig"
12567    if test "$build_os" = "cygwin"; then
12568        dnl cygwin's pkg-config does not recognize "C:/..."-style paths, only "/cygdrive/c/..."
12569        formatted_path_unix=`cygpath -au "$formatted_path_unix"`
12570    fi
12571
12572    PKG_CONFIG_PATH="$formatted_path_unix"; export PKG_CONFIG_PATH
12573    PKG_CHECK_MODULES(GTK3, cairo gdk-3.0 gio-2.0 glib-2.0 gobject-2.0 gtk+-3.0)
12574    GTK3_CFLAGS="$GTK3_CFLAGS -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
12575    FilterLibs "${GTK3_LIBS}"
12576    GTK3_LIBS="${filteredlibs}"
12577    ENABLE_GTKTILEDVIEWER="yes"
12578fi
12579AC_SUBST(GTK3_LIBS)
12580AC_SUBST(GTK3_CFLAGS)
12581AC_SUBST(ENABLE_GTKTILEDVIEWER)
12582
12583GTK4_CFLAGS=""
12584GTK4_LIBS=""
12585if test "$test_gtk4" = yes -a "x$enable_gtk4" = "xyes"; then
12586    if test "$with_system_cairo" = no; then
12587        add_warning 'Non-system cairo combined with gtk4 is assumed to cause trouble; proceed at your own risk.'
12588    fi
12589    : ${with_system_cairo:=yes}
12590    PKG_CHECK_MODULES(GTK4, gtk4 >= 4.10 gmodule-no-export-2.0 glib-2.0 >= 2.38 cairo atk)
12591    GTK4_CFLAGS=$(printf '%s' "$GTK4_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12592    GTK4_CFLAGS="$GTK4_CFLAGS -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
12593    FilterLibs "${GTK4_LIBS}"
12594    GTK4_LIBS="${filteredlibs}"
12595
12596    dnl We require egl only for the gtk4 plugin. Otherwise we use glx.
12597    if test "$with_system_epoxy" != "yes"; then
12598        AC_CHECK_LIB(EGL, eglMakeCurrent, [:], AC_MSG_ERROR([libEGL required.]))
12599        AC_CHECK_HEADER(EGL/eglplatform.h, [],
12600                        [AC_MSG_ERROR(EGL headers not found. install mesa-libEGL-devel)], [])
12601    fi
12602fi
12603AC_SUBST(GTK4_LIBS)
12604AC_SUBST(GTK4_CFLAGS)
12605
12606if test "$enable_introspection" = yes; then
12607    if test "$ENABLE_GTK3" = "TRUE" -o "$ENABLE_GTK3_KDE5" = "TRUE"; then
12608        GOBJECT_INTROSPECTION_REQUIRE(INTROSPECTION_REQUIRED_VERSION)
12609    else
12610        AC_MSG_ERROR([--enable-introspection requires --enable-gtk3])
12611    fi
12612fi
12613
12614# AT-SPI2 tests require gtk3, xvfb-run, dbus-launch and atspi-2
12615if ! test "$ENABLE_GTK3" = TRUE; then
12616    if test "$enable_atspi_tests" = yes; then
12617        AC_MSG_ERROR([--enable-atspi-tests requires --enable-gtk3])
12618    fi
12619    enable_atspi_tests=no
12620fi
12621if ! test "$enable_atspi_tests" = no; then
12622    AC_PATH_PROGS([XVFB_RUN], [xvfb-run], no)
12623    if ! test "$XVFB_RUN" = no; then
12624        dnl make sure the found xvfb-run actually works
12625        AC_MSG_CHECKING([whether $XVFB_RUN works...])
12626        if $XVFB_RUN --auto-servernum true >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
12627            AC_MSG_RESULT([yes])
12628        else
12629            AC_MSG_RESULT([no])
12630            XVFB_RUN=no
12631        fi
12632    fi
12633    if test "$XVFB_RUN" = no; then
12634        if test "$enable_atspi_tests" = yes; then
12635            AC_MSG_ERROR([xvfb-run required by --enable-atspi-tests not found])
12636        fi
12637        enable_atspi_tests=no
12638    fi
12639fi
12640if ! test "$enable_atspi_tests" = no; then
12641    AC_PATH_PROGS([DBUS_LAUNCH], [dbus-launch], no)
12642    if test "$DBUS_LAUNCH" = no; then
12643        if test "$enable_atspi_tests" = yes; then
12644            AC_MSG_ERROR([dbus-launch required by --enable-atspi-tests not found])
12645        fi
12646        enable_atspi_tests=no
12647    fi
12648fi
12649if ! test "$enable_atspi_tests" = no; then
12650    PKG_CHECK_MODULES([ATSPI2], [atspi-2 gobject-2.0],,
12651                      [if test "$enable_atspi_tests" = yes; then
12652                           AC_MSG_ERROR([$ATSPI2_PKG_ERRORS])
12653                       else
12654                           enable_atspi_tests=no
12655                       fi])
12656fi
12657if ! test "x$enable_atspi_tests" = xno; then
12658    PKG_CHECK_MODULES([ATSPI2_2_32], [atspi-2 >= 2.32],
12659                      [have_atspi_scroll_to=1],
12660                      [have_atspi_scroll_to=0])
12661    AC_DEFINE_UNQUOTED([HAVE_ATSPI2_SCROLL_TO], [$have_atspi_scroll_to],
12662                       [Whether AT-SPI2 has the scrollTo API])
12663fi
12664ENABLE_ATSPI_TESTS=
12665test "$enable_atspi_tests" = no || ENABLE_ATSPI_TESTS=TRUE
12666AC_SUBST([ENABLE_ATSPI_TESTS])
12667
12668dnl ===================================================================
12669dnl check for dbus support
12670dnl ===================================================================
12671ENABLE_DBUS=""
12672DBUS_CFLAGS=""
12673DBUS_LIBS=""
12674DBUS_GLIB_CFLAGS=""
12675DBUS_GLIB_LIBS=""
12676DBUS_HAVE_GLIB=""
12677
12678if test "$enable_dbus" = "no"; then
12679    test_dbus=no
12680fi
12681
12682AC_MSG_CHECKING([whether to enable DBUS support])
12683if test "$test_dbus" = "yes"; then
12684    ENABLE_DBUS="TRUE"
12685    AC_MSG_RESULT([yes])
12686    PKG_CHECK_MODULES(DBUS, dbus-1 >= 0.60)
12687    AC_DEFINE(ENABLE_DBUS)
12688    DBUS_CFLAGS=$(printf '%s' "$DBUS_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12689    FilterLibs "${DBUS_LIBS}"
12690    DBUS_LIBS="${filteredlibs}"
12691
12692    # Glib is needed for BluetoothServer
12693    # Sets also DBUS_GLIB_CFLAGS/DBUS_GLIB_LIBS if successful.
12694    PKG_CHECK_MODULES(DBUS_GLIB,[glib-2.0 >= 2.4],
12695        [
12696            DBUS_HAVE_GLIB="TRUE"
12697            AC_DEFINE(DBUS_HAVE_GLIB,1)
12698        ],
12699        AC_MSG_WARN([[No Glib found, Bluetooth support will be disabled]])
12700    )
12701else
12702    AC_MSG_RESULT([no])
12703fi
12704
12705AC_SUBST(ENABLE_DBUS)
12706AC_SUBST(DBUS_CFLAGS)
12707AC_SUBST(DBUS_LIBS)
12708AC_SUBST(DBUS_GLIB_CFLAGS)
12709AC_SUBST(DBUS_GLIB_LIBS)
12710AC_SUBST(DBUS_HAVE_GLIB)
12711
12712AC_MSG_CHECKING([whether to enable Impress remote control])
12713if test -n "$enable_sdremote" -a "$enable_sdremote" != "no"; then
12714    AC_MSG_RESULT([yes])
12715    ENABLE_SDREMOTE=TRUE
12716    SDREMOTE_ENTITLEMENT="	<key>com.apple.security.network.server</key>
12717	<true/>"
12718    AC_MSG_CHECKING([whether to enable Bluetooth support in Impress remote control])
12719
12720    if test $OS = MACOSX; then
12721        # The Bluetooth code doesn't compile since macOS SDK 10.15
12722        if test "$enable_sdremote_bluetooth" = yes; then
12723            AC_MSG_ERROR([macOS SDK $macosx_sdk does not currently support --enable-sdremote-bluetooth])
12724        fi
12725        add_warning "not building the bluetooth part of the sdremote - used api was removed from macOS SDK 10.15"
12726        enable_sdremote_bluetooth=no
12727    fi
12728    # If not explicitly enabled or disabled, default
12729    if test -z "$enable_sdremote_bluetooth"; then
12730        case "$OS" in
12731        LINUX|MACOSX|WNT)
12732            # Default to yes for these
12733            enable_sdremote_bluetooth=yes
12734            ;;
12735        *)
12736            # otherwise no
12737            enable_sdremote_bluetooth=no
12738            ;;
12739        esac
12740    fi
12741    # $enable_sdremote_bluetooth is guaranteed non-empty now
12742
12743    if test "$enable_sdremote_bluetooth" != "no"; then
12744        if test "$OS" = "LINUX"; then
12745            if test "$ENABLE_DBUS" = "TRUE" -a "$DBUS_HAVE_GLIB" = "TRUE"; then
12746                AC_MSG_RESULT([yes])
12747                ENABLE_SDREMOTE_BLUETOOTH=TRUE
12748                dnl ===================================================================
12749                dnl Check for system bluez
12750                dnl ===================================================================
12751                AC_MSG_CHECKING([which Bluetooth header to use])
12752                if test "$with_system_bluez" = "yes"; then
12753                    AC_MSG_RESULT([external])
12754                    AC_CHECK_HEADER(bluetooth/bluetooth.h, [],
12755                        [AC_MSG_ERROR(bluetooth.h not found. install bluez)], [])
12756                    SYSTEM_BLUEZ=TRUE
12757                else
12758                    AC_MSG_RESULT([internal])
12759                    SYSTEM_BLUEZ=
12760                fi
12761            else
12762                AC_MSG_RESULT([no, dbus disabled])
12763                ENABLE_SDREMOTE_BLUETOOTH=
12764                SYSTEM_BLUEZ=
12765            fi
12766        else
12767            AC_MSG_RESULT([yes])
12768            ENABLE_SDREMOTE_BLUETOOTH=TRUE
12769            SYSTEM_BLUEZ=
12770            SDREMOTE_ENTITLEMENT="$SDREMOTE_ENTITLEMENT
12771	<key>com.apple.security.device.bluetooth</key>
12772	<true/>"
12773        fi
12774    else
12775        AC_MSG_RESULT([no])
12776        ENABLE_SDREMOTE_BLUETOOTH=
12777        SYSTEM_BLUEZ=
12778    fi
12779else
12780    ENABLE_SDREMOTE=
12781    SYSTEM_BLUEZ=
12782    AC_MSG_RESULT([no])
12783fi
12784AC_SUBST(ENABLE_SDREMOTE)
12785AC_SUBST(ENABLE_SDREMOTE_BLUETOOTH)
12786AC_SUBST(SDREMOTE_ENTITLEMENT)
12787AC_SUBST(SYSTEM_BLUEZ)
12788
12789dnl ===================================================================
12790dnl Check whether to enable GIO support
12791dnl ===================================================================
12792if test "$ENABLE_GTK4" = "TRUE" -o "$ENABLE_GTK3" = "TRUE" -o "$ENABLE_GTK3_KDE5" = "TRUE"; then
12793    AC_MSG_CHECKING([whether to enable GIO support])
12794    if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_gio" = "yes"; then
12795        dnl Need at least 2.26 for the dbus support.
12796        PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.26],
12797                          [ENABLE_GIO="TRUE"], [ENABLE_GIO=""])
12798        if test "$ENABLE_GIO" = "TRUE"; then
12799            AC_DEFINE(ENABLE_GIO)
12800            GIO_CFLAGS=$(printf '%s' "$GIO_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12801            FilterLibs "${GIO_LIBS}"
12802            GIO_LIBS="${filteredlibs}"
12803        fi
12804    else
12805        AC_MSG_RESULT([no])
12806    fi
12807fi
12808AC_SUBST(ENABLE_GIO)
12809AC_SUBST(GIO_CFLAGS)
12810AC_SUBST(GIO_LIBS)
12811
12812
12813dnl ===================================================================
12814
12815SPLIT_APP_MODULES=""
12816if test "$enable_split_app_modules" = "yes"; then
12817    SPLIT_APP_MODULES="TRUE"
12818fi
12819AC_SUBST(SPLIT_APP_MODULES)
12820
12821SPLIT_OPT_FEATURES=""
12822if test "$enable_split_opt_features" = "yes"; then
12823    SPLIT_OPT_FEATURES="TRUE"
12824fi
12825AC_SUBST(SPLIT_OPT_FEATURES)
12826
12827dnl ===================================================================
12828dnl Check whether the GStreamer libraries are available.
12829dnl ===================================================================
12830
12831ENABLE_GSTREAMER_1_0=""
12832
12833if test "$test_gstreamer_1_0" = yes; then
12834
12835    AC_MSG_CHECKING([whether to enable the GStreamer 1.0 avmedia backend])
12836    if test "$enable_avmedia" = yes -a "$enable_gstreamer_1_0" != no; then
12837        ENABLE_GSTREAMER_1_0="TRUE"
12838        AC_MSG_RESULT([yes])
12839        PKG_CHECK_MODULES( [GSTREAMER_1_0], [gstreamer-1.0 gstreamer-plugins-base-1.0 gstreamer-pbutils-1.0 gstreamer-video-1.0] )
12840        GSTREAMER_1_0_CFLAGS=$(printf '%s' "$GSTREAMER_1_0_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12841        FilterLibs "${GSTREAMER_1_0_LIBS}"
12842        GSTREAMER_1_0_LIBS="${filteredlibs}"
12843        AC_DEFINE(ENABLE_GSTREAMER_1_0)
12844    else
12845        AC_MSG_RESULT([no])
12846    fi
12847fi
12848AC_SUBST(GSTREAMER_1_0_CFLAGS)
12849AC_SUBST(GSTREAMER_1_0_LIBS)
12850AC_SUBST(ENABLE_GSTREAMER_1_0)
12851
12852ENABLE_OPENGL_TRANSITIONS=
12853ENABLE_OPENGL_CANVAS=
12854if test $_os = iOS -o $_os = Android -o "$ENABLE_FUZZERS" = "TRUE"; then
12855   : # disable
12856elif test "$_os" = "Darwin"; then
12857    # We use frameworks on macOS, no need for detail checks
12858    ENABLE_OPENGL_TRANSITIONS=TRUE
12859    AC_DEFINE(HAVE_FEATURE_OPENGL,1)
12860    ENABLE_OPENGL_CANVAS=TRUE
12861elif test $_os = WINNT; then
12862    ENABLE_OPENGL_TRANSITIONS=TRUE
12863    AC_DEFINE(HAVE_FEATURE_OPENGL,1)
12864    ENABLE_OPENGL_CANVAS=TRUE
12865else
12866    if test "$USING_X11" = TRUE; then
12867        AC_CHECK_LIB(GL, glBegin, [:], AC_MSG_ERROR([libGL required.]))
12868        ENABLE_OPENGL_TRANSITIONS=TRUE
12869        AC_DEFINE(HAVE_FEATURE_OPENGL,1)
12870        ENABLE_OPENGL_CANVAS=TRUE
12871    fi
12872fi
12873
12874AC_SUBST(ENABLE_OPENGL_TRANSITIONS)
12875AC_SUBST(ENABLE_OPENGL_CANVAS)
12876
12877dnl =================================================
12878dnl Check whether to build with OpenCL support.
12879dnl =================================================
12880
12881if test $_os != iOS -a $_os != Android -a "$ENABLE_FUZZERS" != "TRUE" -a "$enable_opencl" = "yes"; then
12882    # OPENCL in BUILD_TYPE and HAVE_FEATURE_OPENCL tell that OpenCL is potentially available on the
12883    # platform (optional at run-time, used through clew).
12884    BUILD_TYPE="$BUILD_TYPE OPENCL"
12885    AC_DEFINE(HAVE_FEATURE_OPENCL)
12886fi
12887
12888dnl =================================================
12889dnl Check whether to build with dconf support.
12890dnl =================================================
12891
12892if test $_os != Android -a $_os != iOS -a "$enable_dconf" != no; then
12893    PKG_CHECK_MODULES([DCONF], [dconf >= 0.40.0], [], [
12894        if test "$enable_dconf" = yes; then
12895            AC_MSG_ERROR([dconf not found])
12896        else
12897            enable_dconf=no
12898        fi])
12899fi
12900AC_MSG_CHECKING([whether to enable dconf])
12901if test $_os = Android -o $_os = iOS -o "$enable_dconf" = no; then
12902    DCONF_CFLAGS=
12903    DCONF_LIBS=
12904    ENABLE_DCONF=
12905    AC_MSG_RESULT([no])
12906else
12907    ENABLE_DCONF=TRUE
12908    AC_DEFINE(ENABLE_DCONF)
12909    AC_MSG_RESULT([yes])
12910fi
12911AC_SUBST([DCONF_CFLAGS])
12912AC_SUBST([DCONF_LIBS])
12913AC_SUBST([ENABLE_DCONF])
12914
12915# pdf import?
12916AC_MSG_CHECKING([whether to build the PDF import feature])
12917ENABLE_PDFIMPORT=
12918if test -z "$enable_pdfimport" -o "$enable_pdfimport" = yes; then
12919    AC_MSG_RESULT([yes])
12920    ENABLE_PDFIMPORT=TRUE
12921    AC_DEFINE(HAVE_FEATURE_PDFIMPORT)
12922else
12923    AC_MSG_RESULT([no])
12924fi
12925
12926# Pdfium?
12927AC_MSG_CHECKING([whether to build PDFium])
12928ENABLE_PDFIUM=
12929if test \( -z "$enable_pdfium" -a "$ENABLE_PDFIMPORT" = "TRUE" \) -o "$enable_pdfium" = yes; then
12930    AC_MSG_RESULT([yes])
12931    ENABLE_PDFIUM=TRUE
12932    BUILD_TYPE="$BUILD_TYPE PDFIUM"
12933else
12934    AC_MSG_RESULT([no])
12935fi
12936AC_SUBST(ENABLE_PDFIUM)
12937
12938if test "$ENABLE_PDFIUM" = "TRUE"; then
12939    AC_MSG_CHECKING([which OpenJPEG library to use])
12940    if test "$with_system_openjpeg" = "yes"; then
12941        SYSTEM_OPENJPEG2=TRUE
12942        AC_MSG_RESULT([external])
12943        PKG_CHECK_MODULES( OPENJPEG2, libopenjp2 )
12944        OPENJPEG2_CFLAGS=$(printf '%s' "$OPENJPEG2_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12945        FilterLibs "${OPENJPEG2_LIBS}"
12946        OPENJPEG2_LIBS="${filteredlibs}"
12947    else
12948        SYSTEM_OPENJPEG2=FALSE
12949        AC_MSG_RESULT([internal])
12950    fi
12951
12952    AC_MSG_CHECKING([which Abseil library to use])
12953    if test "$with_system_abseil" = "yes"; then
12954        AC_MSG_RESULT([external])
12955        SYSTEM_ABSEIL=TRUE
12956        AC_LANG_PUSH([C++])
12957        PKG_CHECK_MODULES(ABSEIL, absl_bad_optional_access absl_bad_variant_access absl_inlined_vector )
12958        AC_LANG_POP([C++])
12959        ABSEIL_CFLAGS=$(printf '%s' "$ABSEIL_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12960        FilterLibs "${ABSEIL_LIBS}"
12961        ABSEIL_LIBS="${filteredlibs}"
12962    else
12963        AC_MSG_RESULT([internal])
12964    fi
12965fi
12966AC_SUBST(SYSTEM_OPENJPEG2)
12967AC_SUBST(SYSTEM_ABSEIL)
12968AC_SUBST(ABSEIL_CFLAGS)
12969AC_SUBST(ABSEIL_LIBS)
12970
12971dnl ===================================================================
12972dnl Check for poppler
12973dnl ===================================================================
12974ENABLE_POPPLER=
12975AC_MSG_CHECKING([whether to build Poppler])
12976if test \( -z "$enable_poppler" -a "$ENABLE_PDFIMPORT" = "TRUE" -a $_os != Android \) -o "$enable_poppler" = yes; then
12977    AC_MSG_RESULT([yes])
12978    ENABLE_POPPLER=TRUE
12979    AC_DEFINE(HAVE_FEATURE_POPPLER)
12980else
12981    AC_MSG_RESULT([no])
12982fi
12983AC_SUBST(ENABLE_POPPLER)
12984
12985if test "$ENABLE_PDFIMPORT" = "TRUE" -a "$ENABLE_POPPLER" != "TRUE" -a "$ENABLE_PDFIUM" != "TRUE"; then
12986    AC_MSG_ERROR([Cannot import PDF without either Pdfium or Poppler; please enable either of them.])
12987fi
12988
12989if test "$ENABLE_PDFIMPORT" != "TRUE" -a \( "$ENABLE_POPPLER" = "TRUE" -o "$ENABLE_PDFIUM" = "TRUE" \); then
12990    AC_MSG_ERROR([Cannot enable Pdfium or Poppler when PDF importing is disabled; please enable PDF import first.])
12991fi
12992
12993if test "$ENABLE_PDFIMPORT" = "TRUE" -a "$ENABLE_POPPLER" = "TRUE"; then
12994    dnl ===================================================================
12995    dnl Check for system poppler
12996    dnl ===================================================================
12997    AC_MSG_CHECKING([which PDF import poppler to use])
12998    if test "$with_system_poppler" = "yes"; then
12999        AC_MSG_RESULT([external])
13000        SYSTEM_POPPLER=TRUE
13001        PKG_CHECK_MODULES(POPPLER,[poppler >= 0.14 poppler-cpp])
13002        POPPLER_CFLAGS=$(printf '%s' "$POPPLER_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
13003        FilterLibs "${POPPLER_LIBS}"
13004        POPPLER_LIBS="${filteredlibs}"
13005    else
13006        AC_MSG_RESULT([internal])
13007        SYSTEM_POPPLER=
13008        BUILD_TYPE="$BUILD_TYPE POPPLER"
13009    fi
13010    AC_DEFINE([ENABLE_PDFIMPORT],1)
13011fi
13012AC_SUBST(ENABLE_PDFIMPORT)
13013AC_SUBST(SYSTEM_POPPLER)
13014AC_SUBST(POPPLER_CFLAGS)
13015AC_SUBST(POPPLER_LIBS)
13016
13017# Skia?
13018ENABLE_SKIA=
13019if test "$enable_skia" != "no" -a "$build_skia" = "yes" -a -z "$DISABLE_GUI"; then
13020    # Skia now requires at least freetype2 >= 2.8.1, which is less that what LO requires as system freetype.
13021    if test "$SYSTEM_FREETYPE" = TRUE; then
13022        PKG_CHECK_EXISTS(freetype2 >= 21.0.15, # 21.0.15 = 2.8.1
13023            [skia_freetype_ok=yes],
13024            [skia_freetype_ok=no])
13025    else # internal is ok
13026        skia_freetype_ok=yes
13027    fi
13028    AC_MSG_CHECKING([whether to build Skia])
13029    if test "$skia_freetype_ok" = "yes"; then
13030        if test "$enable_skia" = "debug"; then
13031            AC_MSG_RESULT([yes (debug)])
13032            ENABLE_SKIA_DEBUG=TRUE
13033        else
13034            AC_MSG_RESULT([yes])
13035            ENABLE_SKIA_DEBUG=
13036        fi
13037        ENABLE_SKIA=TRUE
13038        if test "$ENDIANNESS" = "big" && test "$ENABLE_SKIA" = "TRUE"; then
13039            AC_MSG_ERROR([skia doesn't work/isn't supported upstream on big-endian. Use --disable-skia])
13040        fi
13041
13042        AC_DEFINE(HAVE_FEATURE_SKIA)
13043        BUILD_TYPE="$BUILD_TYPE SKIA"
13044
13045        if test "$OS" = "MACOSX"; then
13046            AC_DEFINE(SK_GANESH,1)
13047            AC_DEFINE(SK_METAL,1)
13048            SKIA_GPU=METAL
13049            AC_SUBST(SKIA_GPU)
13050        else
13051            AC_DEFINE(SK_GANESH,1)
13052            AC_DEFINE(SK_VULKAN,1)
13053            SKIA_GPU=VULKAN
13054            AC_SUBST(SKIA_GPU)
13055        fi
13056
13057        if test "$enable_skia_vulkan_validation" = "yes"; then
13058            AC_DEFINE(SK_ENABLE_VK_LAYERS,1)
13059        fi
13060    else
13061        AC_MSG_RESULT([no (freetype too old)])
13062        add_warning "freetype version is too old for Skia library, at least 2.8.1 required, Skia support disabled"
13063    fi
13064
13065else
13066    AC_MSG_CHECKING([whether to build Skia])
13067    AC_MSG_RESULT([no])
13068fi
13069AC_SUBST(ENABLE_SKIA)
13070AC_SUBST(ENABLE_SKIA_DEBUG)
13071
13072LO_CLANG_CXXFLAGS_INTRINSICS_SSE2=
13073LO_CLANG_CXXFLAGS_INTRINSICS_SSSE3=
13074LO_CLANG_CXXFLAGS_INTRINSICS_SSE41=
13075LO_CLANG_CXXFLAGS_INTRINSICS_SSE42=
13076LO_CLANG_CXXFLAGS_INTRINSICS_AVX=
13077LO_CLANG_CXXFLAGS_INTRINSICS_AVX2=
13078LO_CLANG_CXXFLAGS_INTRINSICS_AVX512=
13079LO_CLANG_CXXFLAGS_INTRINSICS_AVX512F=
13080LO_CLANG_CXXFLAGS_INTRINSICS_F16C=
13081LO_CLANG_CXXFLAGS_INTRINSICS_FMA=
13082LO_CLANG_VERSION=
13083HAVE_LO_CLANG_DLLEXPORTINLINES=
13084
13085if test \( "$ENABLE_SKIA" = TRUE -o "$ENABLE_PDFIUM" = TRUE \) -a "$COM_IS_CLANG" != TRUE; then
13086    if test -n "$LO_CLANG_CC" -a -n "$LO_CLANG_CXX"; then
13087        AC_MSG_CHECKING([for Clang])
13088        AC_MSG_RESULT([$LO_CLANG_CC / $LO_CLANG_CXX])
13089    else
13090        if test "$_os" = "WINNT"; then
13091            AC_MSG_CHECKING([for clang-cl])
13092            if test -x "$VC_PRODUCT_DIR/Tools/Llvm/bin/clang-cl.exe"; then
13093                LO_CLANG_CC=`win_short_path_for_make "$VC_PRODUCT_DIR/Tools/Llvm/bin/clang-cl.exe"`
13094            elif test -n "$PROGRAMFILES" -a -x "$(cygpath -u "$PROGRAMFILES/LLVM/bin/clang-cl.exe")"; then
13095                LO_CLANG_CC=`win_short_path_for_make "$PROGRAMFILES/LLVM/bin/clang-cl.exe"`
13096            elif test -x "$(cygpath -u "c:/Program Files/LLVM/bin/clang-cl.exe")"; then
13097                LO_CLANG_CC=`win_short_path_for_make "c:/Program Files/LLVM/bin/clang-cl.exe"`
13098            fi
13099            if test -n "$LO_CLANG_CC"; then
13100                dnl explicitly set -m32/-m64
13101                LO_CLANG_CC="$LO_CLANG_CC --target=$WIN_CLANG_TARGET -m$WIN_HOST_BITS"
13102                LO_CLANG_CXX="$LO_CLANG_CC"
13103                AC_MSG_RESULT([$LO_CLANG_CC])
13104            else
13105                AC_MSG_RESULT([no])
13106            fi
13107
13108            AC_MSG_CHECKING([the dependency generation prefix (clang.exe -showIncludes)])
13109            echo "#include <stdlib.h>" > conftest.c
13110            LO_CLANG_SHOWINCLUDES_PREFIX=`VSLANG=1033 $LO_CLANG_CC $CFLAGS -c -showIncludes conftest.c 2>/dev/null | \
13111                grep 'stdlib\.h' | head -n1 | sed 's/ [[[:alpha:]]]:.*//'`
13112            rm -f conftest.c conftest.obj
13113            if test -z "$LO_CLANG_SHOWINCLUDES_PREFIX"; then
13114                AC_MSG_ERROR([cannot determine the -showIncludes prefix])
13115            else
13116                AC_MSG_RESULT(["$LO_CLANG_SHOWINCLUDES_PREFIX"])
13117            fi
13118        else
13119            AC_CHECK_PROG(LO_CLANG_CC,clang,clang,[])
13120            AC_CHECK_PROG(LO_CLANG_CXX,clang++,clang++,[])
13121        fi
13122    fi
13123    if test -n "$LO_CLANG_CC" -a -n "$LO_CLANG_CXX"; then
13124        clang2_version=`echo __clang_major__.__clang_minor__.__clang_patchlevel__ | $LO_CLANG_CC -E - | tail -1 | sed 's/ //g'`
13125        LO_CLANG_VERSION=`echo "$clang2_version" | $AWK -F. '{ print \$1*10000+(\$2<100?\$2:99)*100+(\$3<100?\$3:99) }'`
13126        if test "$LO_CLANG_VERSION" -lt 50002; then
13127            AC_MSG_WARN(["$clang2_version" is too old or unrecognized, must be at least Clang 5.0.2])
13128            LO_CLANG_CC=
13129            LO_CLANG_CXX=
13130        fi
13131    fi
13132    if test -n "$LO_CLANG_CC" -a -n "$LO_CLANG_CXX" -a "$_os" = "WINNT"; then
13133        save_CXX="$CXX"
13134        CXX="$LO_CLANG_CXX"
13135        AC_MSG_CHECKING([whether $CXX supports -Zc:dllexportInlines-])
13136        AC_LANG_PUSH([C++])
13137        save_CXXFLAGS=$CXXFLAGS
13138        CXXFLAGS="$CXXFLAGS -Werror -Zc:dllexportInlines-"
13139        AC_COMPILE_IFELSE([AC_LANG_SOURCE()], [
13140                HAVE_LO_CLANG_DLLEXPORTINLINES=TRUE
13141                AC_MSG_RESULT([yes])
13142            ], [AC_MSG_RESULT([no])])
13143        CXXFLAGS=$save_CXXFLAGS
13144        AC_LANG_POP([C++])
13145        CXX="$save_CXX"
13146        if test -z "$HAVE_LO_CLANG_DLLEXPORTINLINES"; then
13147            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.])
13148        fi
13149    fi
13150    if test -z "$LO_CLANG_CC" -o -z "$LO_CLANG_CXX"; then
13151        # Skia is the default on Windows and Mac, so hard-require Clang.
13152        # Elsewhere it's used just by the 'gen' VCL backend which is rarely used.
13153        if test "$_os" = "WINNT" -o "$_os" = "Darwin"; then
13154            AC_MSG_ERROR([Clang compiler not found. The Skia library needs to be built using Clang, or use --disable-skia.])
13155        else
13156            AC_MSG_WARN([Clang compiler not found.])
13157        fi
13158    else
13159
13160        save_CXX="$CXX"
13161        CXX="$LO_CLANG_CXX"
13162        # copy&paste (and adjust) of intrinsics checks, since MSVC's -arch doesn't work well for Clang-cl
13163        flag_sse2=-msse2
13164        flag_ssse3=-mssse3
13165        flag_sse41=-msse4.1
13166        flag_sse42=-msse4.2
13167        flag_avx=-mavx
13168        flag_avx2=-mavx2
13169        flag_avx512="-mavx512f -mavx512vl -mavx512bw -mavx512dq -mavx512cd"
13170        flag_avx512f=-mavx512f
13171        flag_f16c=-mf16c
13172        flag_fma=-mfma
13173
13174        AC_MSG_CHECKING([whether $CXX can compile SSE2 intrinsics])
13175        AC_LANG_PUSH([C++])
13176        save_CXXFLAGS=$CXXFLAGS
13177        CXXFLAGS="$CXXFLAGS $flag_sse2"
13178        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
13179            #include <emmintrin.h>
13180            int main () {
13181                __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
13182                c = _mm_xor_si128 (a, b);
13183                return 0;
13184            }
13185            ])],
13186            [can_compile_sse2=yes],
13187            [can_compile_sse2=no])
13188        AC_LANG_POP([C++])
13189        CXXFLAGS=$save_CXXFLAGS
13190        AC_MSG_RESULT([${can_compile_sse2}])
13191        if test "${can_compile_sse2}" = "yes" ; then
13192            LO_CLANG_CXXFLAGS_INTRINSICS_SSE2="$flag_sse2"
13193        fi
13194
13195        AC_MSG_CHECKING([whether $CXX can compile SSSE3 intrinsics])
13196        AC_LANG_PUSH([C++])
13197        save_CXXFLAGS=$CXXFLAGS
13198        CXXFLAGS="$CXXFLAGS $flag_ssse3"
13199        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
13200            #include <tmmintrin.h>
13201            int main () {
13202                __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
13203                c = _mm_maddubs_epi16 (a, b);
13204                return 0;
13205            }
13206            ])],
13207            [can_compile_ssse3=yes],
13208            [can_compile_ssse3=no])
13209        AC_LANG_POP([C++])
13210        CXXFLAGS=$save_CXXFLAGS
13211        AC_MSG_RESULT([${can_compile_ssse3}])
13212        if test "${can_compile_ssse3}" = "yes" ; then
13213            LO_CLANG_CXXFLAGS_INTRINSICS_SSSE3="$flag_ssse3"
13214        fi
13215
13216        AC_MSG_CHECKING([whether $CXX can compile SSE4.1 intrinsics])
13217        AC_LANG_PUSH([C++])
13218        save_CXXFLAGS=$CXXFLAGS
13219        CXXFLAGS="$CXXFLAGS $flag_sse41"
13220        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
13221            #include <smmintrin.h>
13222            int main () {
13223                __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
13224                c = _mm_cmpeq_epi64 (a, b);
13225                return 0;
13226            }
13227            ])],
13228            [can_compile_sse41=yes],
13229            [can_compile_sse41=no])
13230        AC_LANG_POP([C++])
13231        CXXFLAGS=$save_CXXFLAGS
13232        AC_MSG_RESULT([${can_compile_sse41}])
13233        if test "${can_compile_sse41}" = "yes" ; then
13234            LO_CLANG_CXXFLAGS_INTRINSICS_SSE41="$flag_sse41"
13235        fi
13236
13237        AC_MSG_CHECKING([whether $CXX can compile SSE4.2 intrinsics])
13238        AC_LANG_PUSH([C++])
13239        save_CXXFLAGS=$CXXFLAGS
13240        CXXFLAGS="$CXXFLAGS $flag_sse42"
13241        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
13242            #include <nmmintrin.h>
13243            int main () {
13244                __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
13245                c = _mm_cmpgt_epi64 (a, b);
13246                return 0;
13247            }
13248            ])],
13249            [can_compile_sse42=yes],
13250            [can_compile_sse42=no])
13251        AC_LANG_POP([C++])
13252        CXXFLAGS=$save_CXXFLAGS
13253        AC_MSG_RESULT([${can_compile_sse42}])
13254        if test "${can_compile_sse42}" = "yes" ; then
13255            LO_CLANG_CXXFLAGS_INTRINSICS_SSE42="$flag_sse42"
13256        fi
13257
13258        AC_MSG_CHECKING([whether $CXX can compile AVX intrinsics])
13259        AC_LANG_PUSH([C++])
13260        save_CXXFLAGS=$CXXFLAGS
13261        CXXFLAGS="$CXXFLAGS $flag_avx"
13262        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
13263            #include <immintrin.h>
13264            int main () {
13265                __m256 a = _mm256_set1_ps (0.0f), b = _mm256_set1_ps (0.0f), c;
13266                c = _mm256_xor_ps(a, b);
13267                return 0;
13268            }
13269            ])],
13270            [can_compile_avx=yes],
13271            [can_compile_avx=no])
13272        AC_LANG_POP([C++])
13273        CXXFLAGS=$save_CXXFLAGS
13274        AC_MSG_RESULT([${can_compile_avx}])
13275        if test "${can_compile_avx}" = "yes" ; then
13276            LO_CLANG_CXXFLAGS_INTRINSICS_AVX="$flag_avx"
13277        fi
13278
13279        AC_MSG_CHECKING([whether $CXX can compile AVX2 intrinsics])
13280        AC_LANG_PUSH([C++])
13281        save_CXXFLAGS=$CXXFLAGS
13282        CXXFLAGS="$CXXFLAGS $flag_avx2"
13283        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
13284            #include <immintrin.h>
13285            int main () {
13286                __m256i a = _mm256_set1_epi32 (0), b = _mm256_set1_epi32 (0), c;
13287                c = _mm256_maddubs_epi16(a, b);
13288                return 0;
13289            }
13290            ])],
13291            [can_compile_avx2=yes],
13292            [can_compile_avx2=no])
13293        AC_LANG_POP([C++])
13294        CXXFLAGS=$save_CXXFLAGS
13295        AC_MSG_RESULT([${can_compile_avx2}])
13296        if test "${can_compile_avx2}" = "yes" ; then
13297            LO_CLANG_CXXFLAGS_INTRINSICS_AVX2="$flag_avx2"
13298        fi
13299
13300        AC_MSG_CHECKING([whether $CXX can compile AVX512 intrinsics])
13301        AC_LANG_PUSH([C++])
13302        save_CXXFLAGS=$CXXFLAGS
13303        CXXFLAGS="$CXXFLAGS $flag_avx512"
13304        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
13305            #include <immintrin.h>
13306            int main () {
13307                __m512i a = _mm512_loadu_si512(0);
13308                __m512d v1 = _mm512_load_pd(0);
13309                // https://gcc.gnu.org/git/?p=gcc.git;a=commit;f=gcc/config/i386/avx512fintrin.h;h=23bce99cbe7016a04e14c2163ed3fe6a5a64f4e2
13310                __m512d v2 = _mm512_abs_pd(v1);
13311                return 0;
13312            }
13313            ])],
13314            [can_compile_avx512=yes],
13315            [can_compile_avx512=no])
13316        AC_LANG_POP([C++])
13317        CXXFLAGS=$save_CXXFLAGS
13318        AC_MSG_RESULT([${can_compile_avx512}])
13319        if test "${can_compile_avx512}" = "yes" ; then
13320            LO_CLANG_CXXFLAGS_INTRINSICS_AVX512="$flag_avx512"
13321            LO_CLANG_CXXFLAGS_INTRINSICS_AVX512F="$flag_avx512f"
13322        fi
13323
13324        AC_MSG_CHECKING([whether $CXX can compile F16C intrinsics])
13325        AC_LANG_PUSH([C++])
13326        save_CXXFLAGS=$CXXFLAGS
13327        CXXFLAGS="$CXXFLAGS $flag_f16c"
13328        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
13329            #include <immintrin.h>
13330            int main () {
13331                __m128i a = _mm_set1_epi32 (0);
13332                __m128 c;
13333                c = _mm_cvtph_ps(a);
13334                return 0;
13335            }
13336            ])],
13337            [can_compile_f16c=yes],
13338            [can_compile_f16c=no])
13339        AC_LANG_POP([C++])
13340        CXXFLAGS=$save_CXXFLAGS
13341        AC_MSG_RESULT([${can_compile_f16c}])
13342        if test "${can_compile_f16c}" = "yes" ; then
13343            LO_CLANG_CXXFLAGS_INTRINSICS_F16C="$flag_f16c"
13344        fi
13345
13346        AC_MSG_CHECKING([whether $CXX can compile FMA intrinsics])
13347        AC_LANG_PUSH([C++])
13348        save_CXXFLAGS=$CXXFLAGS
13349        CXXFLAGS="$CXXFLAGS $flag_fma"
13350        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
13351            #include <immintrin.h>
13352            int main () {
13353                __m256 a = _mm256_set1_ps (0.0f), b = _mm256_set1_ps (0.0f), c = _mm256_set1_ps (0.0f), d;
13354                d = _mm256_fmadd_ps(a, b, c);
13355                return 0;
13356            }
13357            ])],
13358            [can_compile_fma=yes],
13359            [can_compile_fma=no])
13360        AC_LANG_POP([C++])
13361        CXXFLAGS=$save_CXXFLAGS
13362        AC_MSG_RESULT([${can_compile_fma}])
13363        if test "${can_compile_fma}" = "yes" ; then
13364            LO_CLANG_CXXFLAGS_INTRINSICS_FMA="$flag_fma"
13365        fi
13366
13367        CXX="$save_CXX"
13368    fi
13369fi
13370#
13371# prefix LO_CLANG_CC/LO_CLANG_CXX with ccache if needed
13372#
13373if test "$CCACHE" != "" -a -n "$LO_CLANG_CC" -a -n "$LO_CLANG_CXX"; then
13374    AC_MSG_CHECKING([whether $LO_CLANG_CC is already ccached])
13375    AC_LANG_PUSH([C])
13376    save_CC="$CC"
13377    CC="$LO_CLANG_CC"
13378    save_CFLAGS=$CFLAGS
13379    CFLAGS="$CFLAGS --ccache-skip -O2 -Werror"
13380    dnl an empty program will do, we're checking the compiler flags
13381    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
13382                      [use_ccache=yes], [use_ccache=no])
13383    CFLAGS=$save_CFLAGS
13384    CC=$save_CC
13385    if test $use_ccache = yes -a "${CCACHE##*sccache*}" != ""; then
13386        AC_MSG_RESULT([yes])
13387    else
13388        LO_CLANG_CC="$CCACHE $LO_CLANG_CC"
13389        AC_MSG_RESULT([no])
13390    fi
13391    AC_LANG_POP([C])
13392
13393    AC_MSG_CHECKING([whether $LO_CLANG_CXX is already ccached])
13394    AC_LANG_PUSH([C++])
13395    save_CXX="$CXX"
13396    CXX="$LO_CLANG_CXX"
13397    save_CXXFLAGS=$CXXFLAGS
13398    CXXFLAGS="$CXXFLAGS --ccache-skip -O2 -Werror"
13399    dnl an empty program will do, we're checking the compiler flags
13400    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
13401                      [use_ccache=yes], [use_ccache=no])
13402    if test $use_ccache = yes -a "${CCACHE##*sccache*}" != ""; then
13403        AC_MSG_RESULT([yes])
13404    else
13405        LO_CLANG_CXX="$CCACHE $LO_CLANG_CXX"
13406        AC_MSG_RESULT([no])
13407    fi
13408    CXXFLAGS=$save_CXXFLAGS
13409    CXX=$save_CXX
13410    AC_LANG_POP([C++])
13411fi
13412
13413AC_SUBST(LO_CLANG_CC)
13414AC_SUBST(LO_CLANG_CXX)
13415AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_SSE2)
13416AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_SSSE3)
13417AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_SSE41)
13418AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_SSE42)
13419AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_AVX)
13420AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_AVX2)
13421AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_AVX512)
13422AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_AVX512F)
13423AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_F16C)
13424AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_FMA)
13425AC_SUBST(LO_CLANG_SHOWINCLUDES_PREFIX)
13426AC_SUBST(LO_CLANG_VERSION)
13427AC_SUBST(CLANG_USE_LD)
13428AC_SUBST([HAVE_LO_CLANG_DLLEXPORTINLINES])
13429
13430SYSTEM_GPGMEPP=
13431
13432AC_MSG_CHECKING([whether to enable gpgmepp])
13433if test "$enable_gpgmepp" = no; then
13434    AC_MSG_RESULT([no])
13435elif test "$enable_mpl_subset" = "yes"; then
13436    AC_MSG_RESULT([no (MPL only)])
13437elif test "$enable_fuzzers" = "yes"; then
13438    AC_MSG_RESULT([no (oss-fuzz)])
13439elif test \( \( "$_os" = "Linux" -o "$_os" = "Darwin" \) -a "$ENABLE_NSS" = TRUE \) -o "$_os" = "WINNT" ; then
13440    AC_MSG_RESULT([yes])
13441    dnl ===================================================================
13442    dnl Check for system gpgme
13443    dnl ===================================================================
13444    AC_MSG_CHECKING([which gpgmepp to use])
13445    if test "$with_system_gpgmepp" = "yes"; then
13446        AC_MSG_RESULT([external])
13447        SYSTEM_GPGMEPP=TRUE
13448
13449        # C++ library doesn't come with fancy gpgmepp-config, check for headers the old-fashioned way
13450        AC_CHECK_HEADER(gpgme++/gpgmepp_version.h, [ GPGMEPP_CFLAGS=-I/usr/include/gpgme++ ],
13451            [AC_MSG_ERROR([gpgmepp headers not found, install gpgmepp >= 1.14 development package])], [])
13452        AC_CHECK_HEADER(gpgme.h, [],
13453            [AC_MSG_ERROR([gpgme headers not found, install gpgme development package])], [])
13454        AC_CHECK_LIB(gpgmepp, main, [],
13455            [AC_MSG_ERROR(gpgmepp not found or not functional)], [])
13456        GPGMEPP_LIBS=-lgpgmepp
13457    else
13458        AC_MSG_RESULT([internal])
13459        BUILD_TYPE="$BUILD_TYPE LIBGPGERROR LIBASSUAN GPGMEPP"
13460
13461        GPG_ERROR_CFLAGS="-I${WORKDIR}/UnpackedTarball/libgpg-error/src"
13462        LIBASSUAN_CFLAGS="-I${WORKDIR}/UnpackedTarball/libassuan/src"
13463        if test "$_os" != "WINNT"; then
13464            GPG_ERROR_LIBS="-L${WORKDIR}/UnpackedTarball/libgpg-error/src/.libs -lgpg-error"
13465            LIBASSUAN_LIBS="-L${WORKDIR}/UnpackedTarball/libassuan/src/.libs -lassuan"
13466        fi
13467    fi
13468    ENABLE_GPGMEPP=TRUE
13469    AC_DEFINE([HAVE_FEATURE_GPGME])
13470    AC_PATH_PROG(GPG, gpg)
13471    # TODO: Windows's cygwin gpg does not seem to work with our gpgme,
13472    # so let's exclude that manually for the moment
13473    if test -n "$GPG" -a "$_os" != "WINNT"; then
13474        # make sure we not only have a working gpgme, but a full working
13475        # gpg installation to run OpenPGP signature verification
13476        AC_DEFINE([HAVE_FEATURE_GPGVERIFY])
13477    fi
13478    if test "$_os" = "Linux"; then
13479      uid=`id -u`
13480      AC_MSG_CHECKING([for /run/user/$uid])
13481      if test -d /run/user/$uid; then
13482        AC_MSG_RESULT([yes])
13483        AC_PATH_PROG(GPGCONF, gpgconf)
13484
13485        # Older versions of gpgconf are not working as expected, since
13486        # `gpgconf --remove-socketdir` fails to exit any gpg-agent daemon operating
13487        # on that socket dir that has (indirectly) been started by the tests in xmlsecurity/qa/unit/signing/signing.cxx
13488        # (see commit message of f0305ec0a7d199e605511844d9d6af98b66d4bfd%5E )
13489        AC_MSG_CHECKING([whether version of gpgconf is suitable ... ])
13490        GPGCONF_VERSION=`"$GPGCONF" --version | "$AWK" '/^gpgconf \(GnuPG\)/{print $3}'`
13491        GPGCONF_NUMVER=`echo $GPGCONF_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
13492        if test "$GPGCONF_VERSION" = "2.2_OOo" -o "$GPGCONF_NUMVER" -ge "020200"; then
13493          AC_MSG_RESULT([yes, $GPGCONF_VERSION])
13494          AC_MSG_CHECKING([for gpgconf --create-socketdir... ])
13495          if $GPGCONF --dump-options > /dev/null ; then
13496            if $GPGCONF --dump-options | grep -q create-socketdir ; then
13497              AC_MSG_RESULT([yes])
13498              AC_DEFINE([HAVE_GPGCONF_SOCKETDIR])
13499              AC_DEFINE_UNQUOTED([GPGME_GPGCONF], ["$GPGCONF"])
13500            else
13501              AC_MSG_RESULT([no])
13502            fi
13503          else
13504            AC_MSG_RESULT([no. missing or broken gpgconf?])
13505          fi
13506        else
13507          AC_MSG_RESULT([no, $GPGCONF_VERSION])
13508        fi
13509      else
13510        AC_MSG_RESULT([no])
13511     fi
13512   fi
13513else
13514    AC_MSG_RESULT([no (unsupported OS or missing NSS)])
13515fi
13516AC_SUBST(ENABLE_GPGMEPP)
13517AC_SUBST(SYSTEM_GPGMEPP)
13518AC_SUBST(GPG_ERROR_CFLAGS)
13519AC_SUBST(GPG_ERROR_LIBS)
13520AC_SUBST(LIBASSUAN_CFLAGS)
13521AC_SUBST(LIBASSUAN_LIBS)
13522AC_SUBST(GPGMEPP_CFLAGS)
13523AC_SUBST(GPGMEPP_LIBS)
13524
13525AC_ARG_WITH(system-java-websocket,
13526    AS_HELP_STRING([--with-system-java-websocket],
13527        [Use Java-WebSocket already on system.]),,
13528    [with_system_java_websocket="$with_system_jars"])
13529
13530AC_ARG_WITH(java-websocket-jar,
13531    AS_HELP_STRING([--with-java-websocket-jar=JARFILE],
13532        [Specify path to jarfile manually.]),
13533    JAVA_WEBSOCKET_JAR=$withval)
13534
13535AC_MSG_CHECKING([whether to build Java Websocket for the UNO remote websocket client])
13536if test "$with_java" != "no"; then
13537    AC_MSG_RESULT([yes])
13538    ENABLE_JAVA_WEBSOCKET=TRUE
13539
13540    dnl ===================================================================
13541    dnl Check for system Java-WebSocket
13542    dnl ===================================================================
13543    AC_MSG_CHECKING([which Java-WebSocket to use])
13544    if test "$with_system_java_websocket" = "yes"; then
13545        AC_MSG_RESULT([external])
13546        SYSTEM_JAVA_WEBSOCKET=TRUE
13547        if test -z $JAVA_WEBSOCKET_JAR; then
13548            JAVA_WEBSOCKET_JAR=/usr/share/java/Java-WebSocket/Java-WebSocket.jar
13549        fi
13550        if ! test -f $JAVA_WEBSOCKET_JAR; then
13551            AC_MSG_ERROR(Java-WebSocket.jar not found.)
13552        fi
13553    else
13554        AC_MSG_RESULT([internal])
13555        SYSTEM_JAVA_WEBSOCKET=
13556        BUILD_TYPE="$BUILD_TYPE JAVA_WEBSOCKET"
13557        NEED_ANT=TRUE
13558    fi
13559else
13560    AC_MSG_RESULT([no])
13561    ENABLE_JAVA_WEBSOCKET=
13562fi
13563AC_SUBST(ENABLE_JAVA_WEBSOCKET)
13564AC_SUBST(SYSTEM_JAVA_WEBSOCKET)
13565AC_SUBST(JAVA_WEBSOCKET_JAR)
13566
13567AC_MSG_CHECKING([whether to build the Wiki Publisher extension])
13568if test "x$enable_ext_wiki_publisher" = "xyes" -a "x$enable_extension_integration" != "xno" -a "$with_java" != "no"; then
13569    AC_MSG_RESULT([yes])
13570    ENABLE_MEDIAWIKI=TRUE
13571    BUILD_TYPE="$BUILD_TYPE XSLTML"
13572    if test  "x$with_java" = "xno"; then
13573        AC_MSG_ERROR([Wiki Publisher requires Java! Enable Java if you want to build it.])
13574    fi
13575else
13576    AC_MSG_RESULT([no])
13577    ENABLE_MEDIAWIKI=
13578    SCPDEFS="$SCPDEFS -DWITHOUT_EXTENSION_MEDIAWIKI"
13579fi
13580AC_SUBST(ENABLE_MEDIAWIKI)
13581
13582AC_MSG_CHECKING([whether to build the Report Builder])
13583if test "$enable_report_builder" != "no" -a "$with_java" != "no"; then
13584    AC_MSG_RESULT([yes])
13585    ENABLE_REPORTBUILDER=TRUE
13586    AC_MSG_CHECKING([which jfreereport libs to use])
13587    if test "$with_system_jfreereport" = "yes"; then
13588        SYSTEM_JFREEREPORT=TRUE
13589        AC_MSG_RESULT([external])
13590        if test -z $SAC_JAR; then
13591            SAC_JAR=/usr/share/java/sac.jar
13592        fi
13593        if ! test -f $SAC_JAR; then
13594             AC_MSG_ERROR(sac.jar not found.)
13595        fi
13596
13597        if test -z $LIBXML_JAR; then
13598            if test -f /usr/share/java/libxml-1.0.0.jar; then
13599                LIBXML_JAR=/usr/share/java/libxml-1.0.0.jar
13600            elif test -f /usr/share/java/libxml.jar; then
13601                LIBXML_JAR=/usr/share/java/libxml.jar
13602            else
13603                AC_MSG_ERROR(libxml.jar replacement not found.)
13604            fi
13605        elif ! test -f $LIBXML_JAR; then
13606            AC_MSG_ERROR(libxml.jar not found.)
13607        fi
13608
13609        if test -z $FLUTE_JAR; then
13610            if test -f /usr/share/java/flute-1.3.0.jar; then
13611                FLUTE_JAR=/usr/share/java/flute-1.3.0.jar
13612            elif test -f /usr/share/java/flute.jar; then
13613                FLUTE_JAR=/usr/share/java/flute.jar
13614            else
13615                AC_MSG_ERROR(flute-1.3.0.jar replacement not found.)
13616            fi
13617        elif ! test -f $FLUTE_JAR; then
13618            AC_MSG_ERROR(flute-1.3.0.jar not found.)
13619        fi
13620
13621        if test -z $JFREEREPORT_JAR; then
13622            if test -f /usr/share/java/flow-engine-0.9.2.jar; then
13623                JFREEREPORT_JAR=/usr/share/java/flow-engine-0.9.2.jar
13624            elif test -f /usr/share/java/flow-engine.jar; then
13625                JFREEREPORT_JAR=/usr/share/java/flow-engine.jar
13626            else
13627                AC_MSG_ERROR(jfreereport.jar replacement not found.)
13628            fi
13629        elif ! test -f  $JFREEREPORT_JAR; then
13630                AC_MSG_ERROR(jfreereport.jar not found.)
13631        fi
13632
13633        if test -z $LIBLAYOUT_JAR; then
13634            if test -f /usr/share/java/liblayout-0.2.9.jar; then
13635                LIBLAYOUT_JAR=/usr/share/java/liblayout-0.2.9.jar
13636            elif test -f /usr/share/java/liblayout.jar; then
13637                LIBLAYOUT_JAR=/usr/share/java/liblayout.jar
13638            else
13639                AC_MSG_ERROR(liblayout.jar replacement not found.)
13640            fi
13641        elif ! test -f $LIBLAYOUT_JAR; then
13642                AC_MSG_ERROR(liblayout.jar not found.)
13643        fi
13644
13645        if test -z $LIBLOADER_JAR; then
13646            if test -f /usr/share/java/libloader-1.0.0.jar; then
13647                LIBLOADER_JAR=/usr/share/java/libloader-1.0.0.jar
13648            elif test -f /usr/share/java/libloader.jar; then
13649                LIBLOADER_JAR=/usr/share/java/libloader.jar
13650            else
13651                AC_MSG_ERROR(libloader.jar replacement not found.)
13652            fi
13653        elif ! test -f  $LIBLOADER_JAR; then
13654            AC_MSG_ERROR(libloader.jar not found.)
13655        fi
13656
13657        if test -z $LIBFORMULA_JAR; then
13658            if test -f /usr/share/java/libformula-0.2.0.jar; then
13659                LIBFORMULA_JAR=/usr/share/java/libformula-0.2.0.jar
13660            elif test -f /usr/share/java/libformula.jar; then
13661                LIBFORMULA_JAR=/usr/share/java/libformula.jar
13662            else
13663                AC_MSG_ERROR(libformula.jar replacement not found.)
13664            fi
13665        elif ! test -f $LIBFORMULA_JAR; then
13666                AC_MSG_ERROR(libformula.jar not found.)
13667        fi
13668
13669        if test -z $LIBREPOSITORY_JAR; then
13670            if test -f /usr/share/java/librepository-1.0.0.jar; then
13671                LIBREPOSITORY_JAR=/usr/share/java/librepository-1.0.0.jar
13672            elif test -f /usr/share/java/librepository.jar; then
13673                LIBREPOSITORY_JAR=/usr/share/java/librepository.jar
13674            else
13675                AC_MSG_ERROR(librepository.jar replacement not found.)
13676            fi
13677        elif ! test -f $LIBREPOSITORY_JAR; then
13678            AC_MSG_ERROR(librepository.jar not found.)
13679        fi
13680
13681        if test -z $LIBFONTS_JAR; then
13682            if test -f /usr/share/java/libfonts-1.0.0.jar; then
13683                LIBFONTS_JAR=/usr/share/java/libfonts-1.0.0.jar
13684            elif test -f /usr/share/java/libfonts.jar; then
13685                LIBFONTS_JAR=/usr/share/java/libfonts.jar
13686            else
13687                AC_MSG_ERROR(libfonts.jar replacement not found.)
13688            fi
13689        elif ! test -f $LIBFONTS_JAR; then
13690                AC_MSG_ERROR(libfonts.jar not found.)
13691        fi
13692
13693        if test -z $LIBSERIALIZER_JAR; then
13694            if test -f /usr/share/java/libserializer-1.0.0.jar; then
13695                LIBSERIALIZER_JAR=/usr/share/java/libserializer-1.0.0.jar
13696            elif test -f /usr/share/java/libserializer.jar; then
13697                LIBSERIALIZER_JAR=/usr/share/java/libserializer.jar
13698            else
13699                AC_MSG_ERROR(libserializer.jar replacement not found.)
13700            fi
13701        elif ! test -f $LIBSERIALIZER_JAR; then
13702                AC_MSG_ERROR(libserializer.jar not found.)
13703        fi
13704
13705        if test -z $LIBBASE_JAR; then
13706            if test -f /usr/share/java/libbase-1.0.0.jar; then
13707                LIBBASE_JAR=/usr/share/java/libbase-1.0.0.jar
13708            elif test -f /usr/share/java/libbase.jar; then
13709                LIBBASE_JAR=/usr/share/java/libbase.jar
13710            else
13711                AC_MSG_ERROR(libbase.jar replacement not found.)
13712            fi
13713        elif ! test -f $LIBBASE_JAR; then
13714            AC_MSG_ERROR(libbase.jar not found.)
13715        fi
13716
13717    else
13718        AC_MSG_RESULT([internal])
13719        SYSTEM_JFREEREPORT=
13720        BUILD_TYPE="$BUILD_TYPE JFREEREPORT"
13721        NEED_ANT=TRUE
13722    fi
13723    BUILD_TYPE="$BUILD_TYPE REPORTBUILDER"
13724else
13725    AC_MSG_RESULT([no])
13726    ENABLE_REPORTBUILDER=
13727    SYSTEM_JFREEREPORT=
13728fi
13729AC_SUBST(ENABLE_REPORTBUILDER)
13730AC_SUBST(SYSTEM_JFREEREPORT)
13731AC_SUBST(SAC_JAR)
13732AC_SUBST(LIBXML_JAR)
13733AC_SUBST(FLUTE_JAR)
13734AC_SUBST(JFREEREPORT_JAR)
13735AC_SUBST(LIBBASE_JAR)
13736AC_SUBST(LIBLAYOUT_JAR)
13737AC_SUBST(LIBLOADER_JAR)
13738AC_SUBST(LIBFORMULA_JAR)
13739AC_SUBST(LIBREPOSITORY_JAR)
13740AC_SUBST(LIBFONTS_JAR)
13741AC_SUBST(LIBSERIALIZER_JAR)
13742
13743# scripting provider for BeanShell?
13744AC_MSG_CHECKING([whether to build support for scripts in BeanShell])
13745if test "${enable_scripting_beanshell}" != "no" -a "x$with_java" != "xno"; then
13746    AC_MSG_RESULT([yes])
13747    ENABLE_SCRIPTING_BEANSHELL=TRUE
13748
13749    dnl ===================================================================
13750    dnl Check for system beanshell
13751    dnl ===================================================================
13752    AC_MSG_CHECKING([which beanshell to use])
13753    if test "$with_system_beanshell" = "yes"; then
13754        AC_MSG_RESULT([external])
13755        SYSTEM_BSH=TRUE
13756        if test -z $BSH_JAR; then
13757            BSH_JAR=/usr/share/java/bsh.jar
13758        fi
13759        if ! test -f $BSH_JAR; then
13760            AC_MSG_ERROR(bsh.jar not found.)
13761        fi
13762    else
13763        AC_MSG_RESULT([internal])
13764        SYSTEM_BSH=
13765        BUILD_TYPE="$BUILD_TYPE BSH"
13766    fi
13767else
13768    AC_MSG_RESULT([no])
13769    ENABLE_SCRIPTING_BEANSHELL=
13770    SCPDEFS="$SCPDEFS -DWITHOUT_SCRIPTING_BEANSHELL"
13771fi
13772AC_SUBST(ENABLE_SCRIPTING_BEANSHELL)
13773AC_SUBST(SYSTEM_BSH)
13774AC_SUBST(BSH_JAR)
13775
13776# scripting provider for JavaScript?
13777AC_MSG_CHECKING([whether to build support for scripts in JavaScript])
13778if test "${enable_scripting_javascript}" != "no" -a "x$with_java" != "xno"; then
13779    AC_MSG_RESULT([yes])
13780    ENABLE_SCRIPTING_JAVASCRIPT=TRUE
13781
13782    dnl ===================================================================
13783    dnl Check for system rhino
13784    dnl ===================================================================
13785    AC_MSG_CHECKING([which rhino to use])
13786    if test "$with_system_rhino" = "yes"; then
13787        AC_MSG_RESULT([external])
13788        SYSTEM_RHINO=TRUE
13789        if test -z $RHINO_JAR; then
13790            RHINO_JAR=/usr/share/java/js.jar
13791        fi
13792        if ! test -f $RHINO_JAR; then
13793            AC_MSG_ERROR(js.jar not found.)
13794        fi
13795    else
13796        AC_MSG_RESULT([internal])
13797        SYSTEM_RHINO=
13798        BUILD_TYPE="$BUILD_TYPE RHINO"
13799        NEED_ANT=TRUE
13800    fi
13801else
13802    AC_MSG_RESULT([no])
13803    ENABLE_SCRIPTING_JAVASCRIPT=
13804    SCPDEFS="$SCPDEFS -DWITHOUT_SCRIPTING_JAVASCRIPT"
13805fi
13806AC_SUBST(ENABLE_SCRIPTING_JAVASCRIPT)
13807AC_SUBST(SYSTEM_RHINO)
13808AC_SUBST(RHINO_JAR)
13809
13810# This is only used in Qt5/Qt6/KF5/KF6 checks to determine if /usr/lib64
13811# paths should be added to library search path. So let's put all 64-bit
13812# platforms there.
13813supports_multilib=
13814case "$host_cpu" in
13815x86_64 | powerpc64 | powerpc64le | s390x | aarch64 | mips64 | mips64el | loongarch64 | riscv64)
13816    if test "$SAL_TYPES_SIZEOFLONG" = "8"; then
13817        supports_multilib="yes"
13818    fi
13819    ;;
13820*)
13821    ;;
13822esac
13823
13824dnl ===================================================================
13825dnl QT5 Integration
13826dnl ===================================================================
13827
13828QT5_CFLAGS=""
13829QT5_LIBS=""
13830QT5_GOBJECT_CFLAGS=""
13831QT5_GOBJECT_LIBS=""
13832QT5_HAVE_GOBJECT=""
13833QT5_PLATFORMS_SRCDIR=""
13834if test \( "$test_kf5" = "yes" -a "$ENABLE_KF5" = "TRUE" \) -o \
13835        \( "$test_qt5" = "yes" -a "$ENABLE_QT5" = "TRUE" \) -o \
13836        \( "$test_gtk3_kde5" = "yes" -a "$ENABLE_GTK3_KDE5" = "TRUE" \)
13837then
13838    qt5_incdirs="$QT5INC /usr/include/qt5 /usr/include $x_includes"
13839    qt5_libdirs="$QT5LIB /usr/lib/qt5 /usr/lib $x_libraries"
13840
13841    if test -n "$supports_multilib"; then
13842        qt5_libdirs="$qt5_libdirs /usr/lib64/qt5 /usr/lib64/qt /usr/lib64"
13843    fi
13844
13845    qt5_test_include="QtWidgets/qapplication.h"
13846    if test "$_os" = "Emscripten"; then
13847        qt5_test_library="libQt5Widgets.a"
13848    else
13849        qt5_test_library="libQt5Widgets.so"
13850    fi
13851
13852    dnl Check for qmake5
13853    if test -n "$QT5DIR"; then
13854        AC_PATH_PROG(QMAKE5, [qmake], no, [$QT5DIR/bin])
13855    else
13856        AC_PATH_PROGS(QMAKE5, [qmake-qt5 qmake], no)
13857    fi
13858    if test "$QMAKE5" = "no"; then
13859        AC_MSG_ERROR([Qmake not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
13860    else
13861        qmake5_test_ver="`$QMAKE5 -v 2>&1 | $SED -n -e 's/^Using Qt version \(5\.[[0-9.]]\+\).*$/\1/p'`"
13862        if test -z "$qmake5_test_ver"; then
13863            AC_MSG_ERROR([Wrong qmake for Qt5 found. Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
13864        fi
13865        qmake5_minor_version="`echo $qmake5_test_ver | cut -d. -f2`"
13866        qt5_minimal_minor="15"
13867        if test "$qmake5_minor_version" -lt "$qt5_minimal_minor"; then
13868            AC_MSG_ERROR([The minimal supported Qt5 version is 5.${qt5_minimal_minor}, but your 'qmake -v' reports Qt5 version $qmake5_test_ver.])
13869        else
13870            AC_MSG_NOTICE([Detected Qt5 version: $qmake5_test_ver])
13871        fi
13872    fi
13873
13874    qt5_incdirs="`$QMAKE5 -query QT_INSTALL_HEADERS` $qt5_incdirs"
13875    qt5_libdirs="`$QMAKE5 -query QT_INSTALL_LIBS` $qt5_libdirs"
13876    qt5_platformsdir="`$QMAKE5 -query QT_INSTALL_PLUGINS`/platforms"
13877    QT5_PLATFORMS_SRCDIR="$qt5_platformsdir"
13878
13879    AC_MSG_CHECKING([for Qt5 headers])
13880    qt5_incdir="no"
13881    for inc_dir in $qt5_incdirs; do
13882        if test -r "$inc_dir/$qt5_test_include"; then
13883            qt5_incdir="$inc_dir"
13884            break
13885        fi
13886    done
13887    AC_MSG_RESULT([$qt5_incdir])
13888    if test "x$qt5_incdir" = "xno"; then
13889        AC_MSG_ERROR([Qt5 headers not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
13890    fi
13891    # check for scenario: qt5-qtbase-devel-*.86_64 installed but host is i686
13892    AC_LANG_PUSH([C++])
13893    save_CPPFLAGS=$CPPFLAGS
13894    CPPFLAGS="${CPPFLAGS} -I${qt5_incdir}"
13895    AC_CHECK_HEADER(QtCore/qconfig.h, [],
13896        [AC_MSG_ERROR(qconfig.h header not found.)], [])
13897    CPPFLAGS=$save_CPPFLAGS
13898    AC_LANG_POP([C++])
13899
13900    AC_MSG_CHECKING([for Qt5 libraries])
13901    qt5_libdir="no"
13902    for lib_dir in $qt5_libdirs; do
13903        if test -r "$lib_dir/$qt5_test_library"; then
13904            qt5_libdir="$lib_dir"
13905            break
13906        fi
13907    done
13908    AC_MSG_RESULT([$qt5_libdir])
13909    if test "x$qt5_libdir" = "xno"; then
13910        AC_MSG_ERROR([Qt5 libraries not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
13911    fi
13912
13913    if test "$_os" = "Emscripten"; then
13914        if test ! -f "$QT5_PLATFORMS_SRCDIR"/wasm_shell.html ; then
13915            QT5_PLATFORMS_SRCDIR="${QT5_PLATFORMS_SRCDIR/plugins/src\/plugins}/wasm"
13916        fi
13917        if test ! -f "${qt5_platformsdir}"/libqwasm.a -o ! -f "$QT5_PLATFORMS_SRCDIR"/wasm_shell.html; then
13918            AC_MSG_ERROR([No Qt5 WASM QPA plugin found in ${qt5_platformsdir} or ${QT5_PLATFORMS_SRCDIR}])
13919        fi
13920
13921        EMSDK_LLVM_NM="$(em-config LLVM_ROOT)"/llvm-nm
13922        if ! test -x "$EMSDK_LLVM_NM"; then
13923            AC_MSG_ERROR([Missing llvm-nm expected to be found at "$EMSDK_LLVM_NM".])
13924        fi
13925        if test ! -f "${qt5_libdir}"/libQt5Gui.a; then
13926            AC_MSG_ERROR([No Qt5 WASM libQt5Gui.a in ${qt5_libdir}])
13927        fi
13928        QT5_WASM_SJLJ="`${EMSDK_LLVM_NM} "${qt5_libdir}"/libQt5Gui.a 2>/dev/null | $GREP emscripten_longjmp`"
13929        if test -n "$QT5_WASM_SJLJ"; then
13930            AC_MSG_ERROR(['emscripten_longjmp' symbol found in libQt5Gui.a (missing '-s SUPPORT_LONGJMP=wasm'). See static/README.wasm.md.])
13931        fi
13932    fi
13933
13934    QT5_CFLAGS="-I$qt5_incdir -DQT_NO_VERSION_TAGGING"
13935    QT5_CFLAGS=$(printf '%s' "$QT5_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
13936    QT5_LIBS="-L$qt5_libdir -lQt5Core -lQt5Gui -lQt5Widgets"
13937    if test "$_os" = "Emscripten"; then
13938        QT5_LIBS="$QT5_LIBS -lqtpcre2 -lQt5EventDispatcherSupport -lQt5FontDatabaseSupport -L${qt5_platformsdir} -lqwasm"
13939    fi
13940
13941    if test "$USING_X11" = TRUE; then
13942        if ! test -r "$qt5_incdir/QtX11Extras/QX11Info"; then
13943            AC_MSG_ERROR(['Qt 5 QtX11Extras headers not found.'])
13944        fi
13945
13946        PKG_CHECK_MODULES(QT5_XCB,[xcb],,[AC_MSG_ERROR([XCB not found, which is needed for correct app grouping in X11.])])
13947        QT5_CFLAGS="$QT5_CFLAGS $QT5_XCB_CFLAGS $QT5_XCB_ICCCM_CFLAGS"
13948        QT5_LIBS="$QT5_LIBS $QT5_XCB_LIBS $QT5_XCB_ICCCM_LIBS -lQt5X11Extras"
13949        QT5_USING_X11=1
13950        AC_DEFINE(QT5_USING_X11)
13951    fi
13952
13953    dnl Check for Meta Object Compiler
13954
13955    AC_PATH_PROGS( MOC5, [moc-qt5 moc], no, [`dirname $qt5_libdir`/bin:$QT5DIR/bin:$PATH])
13956    if test "$MOC5" = "no"; then
13957        AC_MSG_ERROR([Qt Meta Object Compiler not found.  Please specify
13958the root of your Qt installation by exporting QT5DIR before running "configure".])
13959    fi
13960
13961    if test "$test_gstreamer_1_0" = yes; then
13962        PKG_CHECK_MODULES(QT5_GOBJECT,[gobject-2.0], [
13963                QT5_HAVE_GOBJECT=1
13964                AC_DEFINE(QT5_HAVE_GOBJECT)
13965            ],
13966            AC_MSG_WARN([[No GObject found, can't use QWidget GStreamer sink on wayland!]])
13967        )
13968    fi
13969fi
13970AC_SUBST(QT5_CFLAGS)
13971AC_SUBST(QT5_LIBS)
13972AC_SUBST(MOC5)
13973AC_SUBST(QT5_GOBJECT_CFLAGS)
13974AC_SUBST(QT5_GOBJECT_LIBS)
13975AC_SUBST(QT5_HAVE_GOBJECT)
13976AC_SUBST(QT5_PLATFORMS_SRCDIR)
13977
13978dnl ===================================================================
13979dnl QT6 Integration
13980dnl ===================================================================
13981
13982QT6_CFLAGS=""
13983QT6_LIBS=""
13984QT6_PLATFORMS_SRCDIR=""
13985ENABLE_QT6_MULTIMEDIA=""
13986if test \( "$test_kf6" = "yes" -a "$ENABLE_KF6" = "TRUE" \) -o \
13987        \( "$test_qt6" = "yes" -a "$ENABLE_QT6" = "TRUE" \)
13988then
13989    qt6_incdirs="$QT6INC /usr/include/qt6 /usr/include $x_includes"
13990    qt6_libdirs="$QT6LIB /usr/lib/qt6 /usr/lib $x_libraries"
13991
13992    if test -n "$supports_multilib"; then
13993        qt6_libdirs="$qt6_libdirs /usr/lib64/qt6 /usr/lib64/qt /usr/lib64"
13994    fi
13995
13996    qt6_test_include="QtWidgets/qapplication.h"
13997    if test "$_os" = "Emscripten"; then
13998        qt6_test_library="libQt6Widgets.a"
13999    else
14000        qt6_test_library="libQt6Widgets.so"
14001    fi
14002
14003    dnl Check for qmake6
14004    if test -n "$QT6DIR"; then
14005        AC_PATH_PROG(QMAKE6, [qmake], no, [$QT6DIR/bin])
14006    else
14007        AC_PATH_PROGS(QMAKE6, [qmake-qt6 qmake6 qmake], no)
14008    fi
14009    if test "$QMAKE6" = "no"; then
14010        AC_MSG_ERROR([Qmake not found.  Please specify the root of your Qt6 installation by exporting QT6DIR before running "configure".])
14011    else
14012        qmake6_test_ver="`$QMAKE6 -v 2>&1 | $SED -n -e 's/^Using Qt version \(6\.[[0-9.]]\+\).*$/\1/p'`"
14013        if test -z "$qmake6_test_ver"; then
14014            AC_MSG_ERROR([Wrong qmake for Qt6 found. Please specify the root of your Qt6 installation by exporting QT6DIR before running "configure".])
14015        fi
14016        AC_MSG_NOTICE([Detected Qt6 version: $qmake6_test_ver])
14017    fi
14018
14019    qt6_incdirs="`$QMAKE6 -query QT_INSTALL_HEADERS` $qt6_incdirs"
14020    qt6_libdirs="`$QMAKE6 -query QT_INSTALL_LIBS` $qt6_libdirs"
14021    qt6_platformsdir="`$QMAKE6 -query QT_INSTALL_PLUGINS`/platforms"
14022    QT6_PLATFORMS_SRCDIR="$qt6_platformsdir"
14023
14024    AC_MSG_CHECKING([for Qt6 headers])
14025    qt6_incdir="no"
14026    for inc_dir in $qt6_incdirs; do
14027        if test -r "$inc_dir/$qt6_test_include"; then
14028            qt6_incdir="$inc_dir"
14029            break
14030        fi
14031    done
14032    AC_MSG_RESULT([$qt6_incdir])
14033    if test "x$qt6_incdir" = "xno"; then
14034        AC_MSG_ERROR([Qt6 headers not found.  Please specify the root of your Qt6 installation by exporting QT6DIR before running "configure".])
14035    fi
14036    # check for scenario: qt6-qtbase-devel-*.86_64 installed but host is i686
14037    AC_LANG_PUSH([C++])
14038    save_CPPFLAGS=$CPPFLAGS
14039    CPPFLAGS="${CPPFLAGS} -I${qt6_incdir}"
14040    AC_CHECK_HEADER(QtCore/qconfig.h, [],
14041        [AC_MSG_ERROR(qconfig.h header not found.)], [])
14042    CPPFLAGS=$save_CPPFLAGS
14043    AC_LANG_POP([C++])
14044
14045    AC_MSG_CHECKING([for Qt6 libraries])
14046    qt6_libdir="no"
14047    for lib_dir in $qt6_libdirs; do
14048        if test -r "$lib_dir/$qt6_test_library"; then
14049            qt6_libdir="$lib_dir"
14050            break
14051        fi
14052    done
14053    AC_MSG_RESULT([$qt6_libdir])
14054    if test "x$qt6_libdir" = "xno"; then
14055        AC_MSG_ERROR([Qt6 libraries not found.  Please specify the root of your Qt6 installation by exporting QT6DIR before running "configure".])
14056    fi
14057
14058    if test "$_os" = "Emscripten"; then
14059        if test ! -f "$QT6_PLATFORMS_SRCDIR"/wasm_shell.html ; then
14060            QT6_PLATFORMS_SRCDIR="${QT6_PLATFORMS_SRCDIR/plugins/src\/plugins}/wasm"
14061        fi
14062        if test ! -f "${qt6_platformsdir}"/libqwasm.a -o ! -f "$QT6_PLATFORMS_SRCDIR"/wasm_shell.html; then
14063            AC_MSG_ERROR([No Qt6 WASM QPA plugin found in ${qt6_platformsdir} or ${QT6_PLATFORMS_SRCDIR}])
14064        fi
14065    fi
14066
14067    QT6_CFLAGS="-I$qt6_incdir -DQT_NO_VERSION_TAGGING"
14068    QT6_CFLAGS=$(printf '%s' "$QT6_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
14069    QT6_LIBS="-L$qt6_libdir -lQt6Core -lQt6Gui -lQt6Widgets"
14070    if test "$_os" = "Emscripten"; then
14071        QT6_LIBS="$QT6_LIBS -lQt6BundledPcre2 -lQt6BundledZLIB -L${qt6_platformsdir} -lqwasm -sGL_ENABLE_GET_PROC_ADDRESS"
14072    else
14073        if ! test "$enable_qt6_multimedia" = "no"; then
14074            if ! test -r "$qt6_incdir/QtMultimediaWidgets/QVideoWidget"; then
14075                AC_MSG_ERROR([Qt 6 QMultimedia not found.])
14076                break
14077            fi
14078            ENABLE_QT6_MULTIMEDIA=TRUE
14079            QT6_LIBS="$QT6_LIBS -lQt6Multimedia -lQt6MultimediaWidgets"
14080        fi
14081    fi
14082
14083    if test "$USING_X11" = TRUE; then
14084        PKG_CHECK_MODULES(QT6_XCB,[xcb],,[AC_MSG_ERROR([XCB not found, which is needed for key modifier handling in X11.])])
14085        QT6_CFLAGS="$QT6_CFLAGS $QT6_XCB_CFLAGS"
14086        QT6_LIBS="$QT6_LIBS $QT6_XCB_LIBS"
14087        QT6_USING_X11=1
14088        AC_DEFINE(QT6_USING_X11)
14089    fi
14090
14091    dnl Check for Meta Object Compiler
14092
14093    for lib_dir in $qt6_libdirs; do
14094        if test -z "$qt6_libexec_dirs"; then
14095            qt6_libexec_dirs="$lib_dir/libexec"
14096        else
14097            qt6_libexec_dirs="$qt6_libexec_dirs:$lib_dir/libexec"
14098        fi
14099    done
14100    AC_PATH_PROGS( MOC6, [moc-qt6 moc], no, [`dirname $qt6_libdir`/libexec:$QT6DIR/libexec:$qt6_libexec_dirs:`echo $qt6_libdirs | $SED -e 's/ /:/g'`:$PATH])
14101    if test "$MOC6" = "no"; then
14102        AC_MSG_ERROR([Qt Meta Object Compiler not found.  Please specify
14103the root of your Qt installation by exporting QT6DIR before running "configure".])
14104    else
14105        moc6_test_ver="`$MOC6 -v 2>&1 | $SED -n -e 's/^moc \(6.*\)/\1/p'`"
14106        if test -z "$moc6_test_ver"; then
14107            AC_MSG_ERROR([Wrong moc for Qt6 found.])
14108        fi
14109        AC_MSG_NOTICE([Detected moc version: $moc_test_ver])
14110    fi
14111fi
14112AC_SUBST(QT6_CFLAGS)
14113AC_SUBST(QT6_LIBS)
14114AC_SUBST(MOC6)
14115AC_SUBST(QT6_PLATFORMS_SRCDIR)
14116AC_SUBST(ENABLE_QT6_MULTIMEDIA)
14117
14118dnl ===================================================================
14119dnl KF5 Integration
14120dnl ===================================================================
14121
14122KF5_CFLAGS=""
14123KF5_LIBS=""
14124KF5_CONFIG="kf5-config"
14125if test \( "$test_kf5" = "yes" -a "$ENABLE_KF5" = "TRUE" \) -o \
14126        \( "$test_gtk3_kde5" = "yes" -a "$ENABLE_GTK3_KDE5" = "TRUE" \)
14127then
14128    if test "$OS" = "HAIKU"; then
14129        haiku_arch="`echo $RTL_ARCH | tr X x`"
14130        kf5_haiku_incdirs="`findpaths -c ' ' -a $haiku_arch B_FIND_PATH_HEADERS_DIRECTORY`"
14131        kf5_haiku_libdirs="`findpaths -c ' ' -a $haiku_arch B_FIND_PATH_DEVELOP_LIB_DIRECTORY`"
14132    fi
14133
14134    kf5_incdirs="$KF5INC /usr/include $kf5_haiku_incdirs $x_includes"
14135    kf5_libdirs="$KF5LIB /usr/lib /usr/lib/kf5 /usr/lib/kf5/devel $kf5_haiku_libdirs $x_libraries"
14136    if test -n "$supports_multilib"; then
14137        kf5_libdirs="$kf5_libdirs /usr/lib64 /usr/lib64/kf5 /usr/lib64/kf5/devel"
14138    fi
14139
14140    kf5_test_include="KF5/KIOFileWidgets/KFileWidget"
14141    kf5_test_library="libKF5KIOFileWidgets.so"
14142    kf5_libdirs="$qt5_libdir $kf5_libdirs"
14143
14144    dnl kf5 KDE4 support compatibility installed
14145    AC_PATH_PROG( KF5_CONFIG, $KF5_CONFIG, no, )
14146    if test "$KF5_CONFIG" != "no"; then
14147        kf5_incdirs="`$KF5_CONFIG --path include` $kf5_incdirs"
14148        kf5_libdirs="`$KF5_CONFIG --path lib` $kf5_libdirs"
14149    fi
14150
14151    dnl Check for KF5 headers
14152    AC_MSG_CHECKING([for KF5 headers])
14153    kf5_incdir="no"
14154    for kf5_check in $kf5_incdirs; do
14155        if test -r "$kf5_check/$kf5_test_include"; then
14156            kf5_incdir="$kf5_check/KF5"
14157            break
14158        fi
14159    done
14160    AC_MSG_RESULT([$kf5_incdir])
14161    if test "x$kf5_incdir" = "xno"; then
14162        AC_MSG_ERROR([KF5 headers not found.  Please specify the root of your KF5 installation by exporting KF5DIR before running "configure".])
14163    fi
14164
14165    dnl Check for KF5 libraries
14166    AC_MSG_CHECKING([for KF5 libraries])
14167    kf5_libdir="no"
14168    for kf5_check in $kf5_libdirs; do
14169        if test -r "$kf5_check/$kf5_test_library"; then
14170            kf5_libdir="$kf5_check"
14171            break
14172        fi
14173    done
14174
14175    AC_MSG_RESULT([$kf5_libdir])
14176    if test "x$kf5_libdir" = "xno"; then
14177        AC_MSG_ERROR([KF5 libraries not found.  Please specify the root of your KF5 installation by exporting KF5DIR before running "configure".])
14178    fi
14179
14180    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 -DQT_NO_VERSION_TAGGING"
14181    KF5_LIBS="-L$kf5_libdir -lKF5CoreAddons -lKF5I18n -lKF5ConfigCore -lKF5WindowSystem -lKF5KIOCore -lKF5KIOWidgets -lKF5KIOFileWidgets -L$qt5_libdir -lQt5Core -lQt5Gui -lQt5Widgets"
14182    KF5_CFLAGS=$(printf '%s' "$KF5_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
14183
14184    if test "$USING_X11" = TRUE; then
14185        KF5_LIBS="$KF5_LIBS -lQt5X11Extras"
14186    fi
14187
14188    AC_LANG_PUSH([C++])
14189    save_CXXFLAGS=$CXXFLAGS
14190    CXXFLAGS="$CXXFLAGS $KF5_CFLAGS"
14191    AC_MSG_CHECKING([whether KDE is >= 5.0])
14192       AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
14193#include <kcoreaddons_version.h>
14194
14195int main(int argc, char **argv) {
14196       static_assert(KCOREADDONS_VERSION_MAJOR == 5);
14197       return 0;
14198}
14199       ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([KDE version too old])],[])
14200    CXXFLAGS=$save_CXXFLAGS
14201    AC_LANG_POP([C++])
14202fi
14203AC_SUBST(KF5_CFLAGS)
14204AC_SUBST(KF5_LIBS)
14205
14206dnl ===================================================================
14207dnl KF6 Integration
14208dnl ===================================================================
14209
14210KF6_CFLAGS=""
14211KF6_LIBS=""
14212if test \( "$test_kf6" = "yes" -a "$ENABLE_KF6" = "TRUE" \)
14213then
14214    if test "$OS" = "HAIKU"; then
14215        haiku_arch="`echo $RTL_ARCH | tr X x`"
14216        kf6_haiku_incdirs="`findpaths -c ' ' -a $haiku_arch B_FIND_PATH_HEADERS_DIRECTORY`"
14217        kf6_haiku_libdirs="`findpaths -c ' ' -a $haiku_arch B_FIND_PATH_DEVELOP_LIB_DIRECTORY`"
14218    fi
14219
14220    kf6_incdirs="$KF6INC /usr/include $kf6_haiku_incdirs $x_includes"
14221    kf6_libdirs="$KF6LIB /usr/lib /usr/lib/kf6 /usr/lib/kf6/devel $kf6_haiku_libdirs $x_libraries"
14222    if test -n "$supports_multilib"; then
14223        kf6_libdirs="$kf6_libdirs /usr/lib64 /usr/lib64/kf6 /usr/lib64/kf6/devel"
14224    fi
14225
14226    kf6_test_include="KF6/KIOFileWidgets/KFileWidget"
14227    kf6_test_library="libKF6KIOFileWidgets.so"
14228    kf6_libdirs="$qt6_libdir $kf6_libdirs"
14229
14230    dnl Check for KF6 headers
14231    AC_MSG_CHECKING([for KF6 headers])
14232    kf6_incdir="no"
14233    for kf6_check in $kf6_incdirs; do
14234        if test -r "$kf6_check/$kf6_test_include"; then
14235            kf6_incdir="$kf6_check/KF6"
14236            break
14237        fi
14238    done
14239    AC_MSG_RESULT([$kf6_incdir])
14240    if test "x$kf6_incdir" = "xno"; then
14241        AC_MSG_ERROR([KF6 headers not found.  Please specify the root of your KF6 installation by exporting KF6DIR before running "configure".])
14242    fi
14243
14244    dnl Check for KF6 libraries
14245    AC_MSG_CHECKING([for KF6 libraries])
14246    kf6_libdir="no"
14247    for kf6_check in $kf6_libdirs; do
14248        if test -r "$kf6_check/$kf6_test_library"; then
14249            kf6_libdir="$kf6_check"
14250            break
14251        fi
14252    done
14253
14254    AC_MSG_RESULT([$kf6_libdir])
14255    if test "x$kf6_libdir" = "xno"; then
14256        AC_MSG_ERROR([KF6 libraries not found.  Please specify the root of your KF6 installation by exporting KF6DIR before running "configure".])
14257    fi
14258
14259    KF6_CFLAGS="-I$kf6_incdir -I$kf6_incdir/KCoreAddons -I$kf6_incdir/KI18n -I$kf6_incdir/KConfig -I$kf6_incdir/KConfigCore -I$kf6_incdir/KWindowSystem -I$kf6_incdir/KIO -I$kf6_incdir/KIOCore -I$kf6_incdir/KIOWidgets -I$kf6_incdir/KIOFileWidgets -I$qt6_incdir -I$qt6_incdir/QtCore -I$qt6_incdir/QtGui -I$qt6_incdir/QtWidgets -DQT_NO_VERSION_TAGGING"
14260    KF6_LIBS="-L$kf6_libdir -lKF6CoreAddons -lKF6I18n -lKF6ConfigCore -lKF6WindowSystem -lKF6KIOCore -lKF6KIOWidgets -lKF6KIOFileWidgets -L$qt6_libdir -lQt6Core -lQt6Gui -lQt6Widgets"
14261    KF6_CFLAGS=$(printf '%s' "$KF6_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
14262
14263    AC_LANG_PUSH([C++])
14264    save_CXXFLAGS=$CXXFLAGS
14265    CXXFLAGS="$CXXFLAGS $KF6_CFLAGS"
14266    dnl KF6 development version as of 2023-06 uses version number 5.240
14267    AC_MSG_CHECKING([whether KDE Frameworks version is >= 6.0])
14268       AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
14269#include <kcoreaddons_version.h>
14270
14271int main(int argc, char **argv) {
14272       static_assert(KCOREADDONS_VERSION_MAJOR == 6);
14273       return 0;
14274}
14275       ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([KDE version too old])],[])
14276    CXXFLAGS=$save_CXXFLAGS
14277    AC_LANG_POP([C++])
14278fi
14279AC_SUBST(KF6_CFLAGS)
14280AC_SUBST(KF6_LIBS)
14281
14282if test "$enable_qt6_multimedia" = "yes" -a "$ENABLE_QT6" != "TRUE"; then
14283    AC_MSG_ERROR([--enable-qt6-multimedia requires --enable-qt6 or --enable-kf6])
14284fi
14285
14286dnl ===================================================================
14287dnl Test whether to include Evolution 2 support
14288dnl ===================================================================
14289AC_MSG_CHECKING([whether to enable evolution 2 support])
14290if test "$enable_evolution2" = yes; then
14291    AC_MSG_RESULT([yes])
14292    PKG_CHECK_MODULES(GOBJECT, gobject-2.0)
14293    GOBJECT_CFLAGS=$(printf '%s' "$GOBJECT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
14294    FilterLibs "${GOBJECT_LIBS}"
14295    GOBJECT_LIBS="${filteredlibs}"
14296    ENABLE_EVOAB2="TRUE"
14297else
14298    AC_MSG_RESULT([no])
14299fi
14300AC_SUBST(ENABLE_EVOAB2)
14301AC_SUBST(GOBJECT_CFLAGS)
14302AC_SUBST(GOBJECT_LIBS)
14303
14304dnl ===================================================================
14305dnl Test which themes to include
14306dnl ===================================================================
14307AC_MSG_CHECKING([which themes to include])
14308# if none given use default subset of available themes
14309if test "x$with_theme" = "x" -o "x$with_theme" = "xyes"; then
14310    with_theme="breeze breeze_dark breeze_dark_svg breeze_svg colibre colibre_svg colibre_dark colibre_dark_svg elementary elementary_svg karasa_jaga karasa_jaga_svg sifr sifr_svg sifr_dark sifr_dark_svg sukapura sukapura_dark sukapura_dark_svg sukapura_svg"
14311fi
14312
14313WITH_THEMES=""
14314if test "x$with_theme" != "xno"; then
14315    for theme in $with_theme; do
14316        case $theme in
14317        breeze|breeze_dark|breeze_dark_svg|breeze_svg|colibre|colibre_svg|colibre_dark|colibre_dark_svg|elementary|elementary_svg|karasa_jaga|karasa_jaga_svg|sifr|sifr_svg|sifr_dark|sifr_dark_svg|sukapura|sukapura_dark|sukapura_dark_svg|sukapura_svg) WITH_THEMES="${WITH_THEMES:+$WITH_THEMES }$theme" ;;
14318        *) AC_MSG_ERROR([Unknown value for --with-theme: $theme]) ;;
14319        esac
14320    done
14321fi
14322AC_MSG_RESULT([$WITH_THEMES])
14323AC_SUBST([WITH_THEMES])
14324
14325###############################################################################
14326# Extensions checking
14327###############################################################################
14328AC_MSG_CHECKING([for extensions integration])
14329if test "x$enable_extension_integration" != "xno"; then
14330    WITH_EXTENSION_INTEGRATION=TRUE
14331    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_INTEGRATION"
14332    AC_MSG_RESULT([yes, use integration])
14333else
14334    WITH_EXTENSION_INTEGRATION=
14335    AC_MSG_RESULT([no, do not integrate])
14336fi
14337AC_SUBST(WITH_EXTENSION_INTEGRATION)
14338
14339dnl Should any extra extensions be included?
14340dnl There are standalone tests for each of these below.
14341WITH_EXTRA_EXTENSIONS=
14342AC_SUBST([WITH_EXTRA_EXTENSIONS])
14343
14344if test "x$with_java" != "xno"; then
14345    libo_CHECK_EXTENSION([NLPSolver],[NLPSOLVER],[nlpsolver],[nlpsolver],[])
14346fi
14347
14348AC_MSG_CHECKING([whether to build opens___.ttf])
14349if test "$enable_build_opensymbol" = "yes"; then
14350    AC_MSG_RESULT([yes])
14351    AC_PATH_PROG(FONTFORGE, fontforge)
14352    if test -z "$FONTFORGE"; then
14353        AC_MSG_ERROR([fontforge not installed])
14354    fi
14355else
14356    AC_MSG_RESULT([no])
14357    BUILD_TYPE="$BUILD_TYPE OPENSYMBOL"
14358fi
14359AC_SUBST(FONTFORGE)
14360
14361dnl ===================================================================
14362dnl Test whether to include fonts
14363dnl ===================================================================
14364WITH_FONTS=
14365WITH_DOCREPAIR_FONTS=
14366AC_MSG_CHECKING([whether to include third-party fonts])
14367if test "$with_fonts" != "no"; then
14368    AC_MSG_RESULT([yes])
14369    WITH_FONTS=TRUE
14370    BUILD_TYPE="$BUILD_TYPE MORE_FONTS"
14371    AC_DEFINE(HAVE_MORE_FONTS)
14372    AC_MSG_CHECKING([whether to include 'docrepair' fonts])
14373    if test "$with_docrepair_fonts" = "yes"; then
14374        AC_MSG_RESULT([yes])
14375        WITH_DOCREPAIR_FONTS=TRUE
14376    fi
14377else
14378    AC_MSG_RESULT([no])
14379    SCPDEFS="$SCPDEFS -DWITHOUT_FONTS"
14380fi
14381AC_SUBST(WITH_FONTS)
14382AC_SUBST(WITH_DOCREPAIR_FONTS)
14383
14384dnl ===================================================================
14385dnl Test whether to enable online update service
14386dnl ===================================================================
14387AC_MSG_CHECKING([whether to enable online update])
14388ENABLE_ONLINE_UPDATE=
14389if test "$enable_online_update" = ""; then
14390    AC_MSG_RESULT([no])
14391else
14392    if test "$enable_online_update" = "mar"; then
14393        AC_MSG_ERROR([--enable-online-update=mar is deprecated, use --enable-online-update-mar instead])
14394    elif test "$enable_online_update" = "yes"; then
14395        if test "$enable_curl" != "yes"; then
14396            AC_MSG_ERROR([--disable-online-update must be used when --disable-curl is used])
14397        fi
14398        AC_MSG_RESULT([yes])
14399        ENABLE_ONLINE_UPDATE="TRUE"
14400    else
14401        AC_MSG_RESULT([no])
14402    fi
14403fi
14404AC_SUBST(ENABLE_ONLINE_UPDATE)
14405
14406
14407dnl ===================================================================
14408dnl Test whether to enable mar online update service
14409dnl ===================================================================
14410AC_MSG_CHECKING([whether to enable mar online update])
14411ENABLE_ONLINE_UPDATE_MAR=
14412if test "$enable_online_update_mar" = yes; then
14413    AC_MSG_RESULT([yes])
14414    BUILD_TYPE="$BUILD_TYPE ONLINEUPDATE"
14415    ENABLE_ONLINE_UPDATE_MAR="TRUE"
14416    AC_DEFINE(HAVE_FEATURE_UPDATE_MAR)
14417else
14418    AC_MSG_RESULT([no])
14419fi
14420AC_SUBST(ENABLE_ONLINE_UPDATE_MAR)
14421
14422AC_MSG_CHECKING([for mar online update baseurl])
14423ONLINEUPDATE_MAR_BASEURL=$with_online_update_mar_baseurl
14424if test -n "$ONLINEUPDATE_MAR_BASEURL"; then
14425    AC_MSG_RESULT([yes])
14426else
14427    AC_MSG_RESULT([no])
14428fi
14429AC_SUBST(ONLINEUPDATE_MAR_BASEURL)
14430
14431AC_MSG_CHECKING([for mar online update certificateder])
14432ONLINEUPDATE_MAR_CERTIFICATEDER=$with_online_update_mar_certificateder
14433if test -n "$ONLINEUPDATE_MAR_CERTIFICATEDER"; then
14434    AC_MSG_RESULT([yes])
14435else
14436    AC_MSG_RESULT([no])
14437fi
14438AC_SUBST(ONLINEUPDATE_MAR_CERTIFICATEDER)
14439
14440AC_MSG_CHECKING([for mar online update certificatename])
14441ONLINEUPDATE_MAR_CERTIFICATENAME=$with_online_update_mar_certificatename
14442if test -n "$ONLINEUPDATE_MAR_CERTIFICATENAME"; then
14443    AC_MSG_RESULT([yes])
14444else
14445    AC_MSG_RESULT([no])
14446fi
14447AC_SUBST(ONLINEUPDATE_MAR_CERTIFICATENAME)
14448
14449AC_MSG_CHECKING([for mar online update certificatepath])
14450ONLINEUPDATE_MAR_CERTIFICATEPATH=$with_online_update_mar_certificatepath
14451if test -n "$ONLINEUPDATE_MAR_CERTIFICATEPATH"; then
14452    AC_MSG_RESULT([yes])
14453else
14454    AC_MSG_RESULT([no])
14455fi
14456AC_SUBST(ONLINEUPDATE_MAR_CERTIFICATEPATH)
14457
14458
14459PRIVACY_POLICY_URL="$with_privacy_policy_url"
14460if test "$ENABLE_ONLINE_UPDATE" = TRUE -o "$ENABLE_BREAKPAD" = "TRUE"; then
14461    if test "x$with_privacy_policy_url" = "xundefined"; then
14462        AC_MSG_FAILURE([online update or breakpad/crashreporting are enabled, but no --with-privacy-policy-url=... was provided])
14463    fi
14464fi
14465AC_SUBST(PRIVACY_POLICY_URL)
14466dnl ===================================================================
14467dnl Test whether we need bzip2
14468dnl ===================================================================
14469SYSTEM_BZIP2=
14470if test "$ENABLE_ONLINE_UPDATE_MAR" = TRUE -o "$enable_python" = internal; then
14471    AC_MSG_CHECKING([whether to use system bzip2])
14472    if test "$with_system_bzip2" = yes; then
14473        SYSTEM_BZIP2=TRUE
14474        AC_MSG_RESULT([yes])
14475        AC_CHECK_HEADER(bzlib.h, [],
14476            [AC_MSG_ERROR(bzlib.h not found. install bzip2)], [])
14477        AC_CHECK_LIB(bz2, BZ2_bzDecompressInit, [BZIP2_LIBS=-lbz2],
14478            [AC_MSG_ERROR(bzip2 not found or functional)], [])
14479    else
14480        AC_MSG_RESULT([no])
14481        BUILD_TYPE="$BUILD_TYPE BZIP2"
14482        if test "$COM" = "MSC"; then
14483            BZIP2_LIBS="${WORKDIR}/UnpackedTarball/bzip2/libbz2.lib"
14484        else
14485            BZIP2_LIBS="-L${WORKDIR}/UnpackedTarball/bzip2 -lbz2"
14486        fi
14487    fi
14488fi
14489AC_SUBST(SYSTEM_BZIP2)
14490AC_SUBST(BZIP2_CFLAGS)
14491AC_SUBST(BZIP2_LIBS)
14492
14493dnl ===================================================================
14494dnl Test whether to enable extension update
14495dnl ===================================================================
14496AC_MSG_CHECKING([whether to enable extension update])
14497ENABLE_EXTENSION_UPDATE=
14498if test "x$enable_extension_update" = "xno"; then
14499    AC_MSG_RESULT([no])
14500else
14501    AC_MSG_RESULT([yes])
14502    ENABLE_EXTENSION_UPDATE="TRUE"
14503    AC_DEFINE(ENABLE_EXTENSION_UPDATE)
14504    SCPDEFS="$SCPDEFS -DENABLE_EXTENSION_UPDATE"
14505fi
14506AC_SUBST(ENABLE_EXTENSION_UPDATE)
14507
14508
14509dnl ===================================================================
14510dnl Test whether to create MSI with LIMITUI=1 (silent install)
14511dnl ===================================================================
14512AC_MSG_CHECKING([whether to create MSI with LIMITUI=1 (silent install)])
14513if test "$enable_silent_msi" = "" -o "$enable_silent_msi" = "no"; then
14514    AC_MSG_RESULT([no])
14515    ENABLE_SILENT_MSI=
14516else
14517    AC_MSG_RESULT([yes])
14518    ENABLE_SILENT_MSI=TRUE
14519    SCPDEFS="$SCPDEFS -DENABLE_SILENT_MSI"
14520fi
14521AC_SUBST(ENABLE_SILENT_MSI)
14522
14523dnl ===================================================================
14524dnl Check for WiX tools.
14525dnl ===================================================================
14526if test "$enable_wix" = "" -o "enable_wix" = "no"; then
14527    AC_MSG_RESULT([no])
14528    ENABLE_WIX=
14529else
14530    AC_MSG_RESULT([yes])
14531    # FIXME: this should do proper detection, but the path is currently
14532    # hardcoded in msicreator/createmsi.py
14533    if ! test -x "/cygdrive/c/Program Files (x86)/WiX Toolset v3.11/bin/candle"; then
14534      AC_MSG_ERROR([WiX requested but WiX toolset v3.11 not found at the expected location])
14535    fi
14536    ENABLE_WIX=TRUE
14537fi
14538AC_SUBST(ENABLE_WIX)
14539
14540AC_MSG_CHECKING([whether and how to use Xinerama])
14541if test "$USING_X11" = TRUE; then
14542    if test "$x_libraries" = "default_x_libraries"; then
14543        XINERAMALIB=`$PKG_CONFIG --variable=libdir xinerama`
14544        if test "x$XINERAMALIB" = x; then
14545           XINERAMALIB="/usr/lib"
14546        fi
14547    else
14548        XINERAMALIB="$x_libraries"
14549    fi
14550    if test -e "$XINERAMALIB/libXinerama.so" -a -e "$XINERAMALIB/libXinerama.a"; then
14551        # we have both versions, let the user decide but use the dynamic one
14552        # per default
14553        USE_XINERAMA=TRUE
14554        if test -z "$with_static_xinerama" -o -n "$with_system_libs"; then
14555            XINERAMA_LINK=dynamic
14556        else
14557            XINERAMA_LINK=static
14558        fi
14559    elif test -e "$XINERAMALIB/libXinerama.so" -a ! -e "$XINERAMALIB/libXinerama.a"; then
14560        # we have only the dynamic version
14561        USE_XINERAMA=TRUE
14562        XINERAMA_LINK=dynamic
14563    elif test -e "$XINERAMALIB/libXinerama.a"; then
14564        # static version
14565        if echo $host_cpu | $GREP -E 'i[[3456]]86' 2>/dev/null >/dev/null; then
14566            USE_XINERAMA=TRUE
14567            XINERAMA_LINK=static
14568        else
14569            USE_XINERAMA=
14570            XINERAMA_LINK=none
14571        fi
14572    else
14573        # no Xinerama
14574        USE_XINERAMA=
14575        XINERAMA_LINK=none
14576    fi
14577    if test "$USE_XINERAMA" = "TRUE"; then
14578        AC_MSG_RESULT([yes, with $XINERAMA_LINK linking])
14579        AC_CHECK_HEADER(X11/extensions/Xinerama.h, [],
14580            [AC_MSG_ERROR(Xinerama header not found.)], [])
14581        XEXTLIBS=`$PKG_CONFIG --variable=libs xext`
14582        if test "x$XEXTLIB" = x; then
14583           XEXTLIBS="-L$XLIB -L$XINERAMALIB -lXext"
14584        fi
14585        XINERAMA_EXTRA_LIBS="$XEXTLIBS"
14586        if test "$_os" = "FreeBSD"; then
14587            XINERAMA_EXTRA_LIBS="$XINERAMA_EXTRA_LIBS -lXt"
14588        fi
14589        if test "$_os" = "Linux"; then
14590            XINERAMA_EXTRA_LIBS="$XINERAMA_EXTRA_LIBS -ldl"
14591        fi
14592        AC_CHECK_LIB([Xinerama], [XineramaIsActive], [:],
14593            [AC_MSG_ERROR(Xinerama not functional?)], [$XINERAMA_EXTRA_LIBS])
14594    else
14595        AC_MSG_ERROR([libXinerama not found or wrong architecture.])
14596    fi
14597else
14598    USE_XINERAMA=
14599    XINERAMA_LINK=none
14600    AC_MSG_RESULT([no])
14601fi
14602AC_SUBST(XINERAMA_LINK)
14603
14604AC_MSG_CHECKING([whether to use non-standard RGBA32 cairo pixel order])
14605if test -z "$enable_cairo_rgba" -a "$_os" = "Android"; then
14606    enable_cairo_rgba=yes
14607fi
14608if test "$enable_cairo_rgba" = yes; then
14609    AC_DEFINE(ENABLE_CAIRO_RGBA)
14610    ENABLE_CAIRO_RGBA=TRUE
14611    AC_MSG_RESULT([yes])
14612else
14613    ENABLE_CAIRO_RGBA=
14614    AC_MSG_RESULT([no])
14615fi
14616AC_SUBST(ENABLE_CAIRO_RGBA)
14617
14618dnl ===================================================================
14619dnl Test whether to build cairo or rely on the system version
14620dnl ===================================================================
14621
14622if test "$test_cairo" = "yes"; then
14623    AC_MSG_CHECKING([whether to use the system cairo])
14624
14625    : ${with_system_cairo:=$with_system_libs}
14626    if test "$with_system_cairo" = "yes" -a "$enable_cairo_rgba" != "yes"; then
14627        SYSTEM_CAIRO=TRUE
14628        AC_MSG_RESULT([yes])
14629
14630        PKG_CHECK_MODULES( CAIRO, cairo >= 1.12.0 )
14631        CAIRO_CFLAGS=$(printf '%s' "$CAIRO_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
14632        FilterLibs "${CAIRO_LIBS}"
14633        CAIRO_LIBS="${filteredlibs}"
14634
14635        if test "$test_xrender" = "yes"; then
14636            AC_MSG_CHECKING([whether Xrender.h defines PictStandardA8])
14637            AC_LANG_PUSH([C])
14638            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <X11/extensions/Xrender.h>]],[[
14639#ifdef PictStandardA8
14640#else
14641      return fail;
14642#endif
14643]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no, X headers too old.])])
14644
14645            AC_LANG_POP([C])
14646        fi
14647    else
14648        AC_MSG_RESULT([no])
14649        BUILD_TYPE="$BUILD_TYPE CAIRO"
14650    fi
14651
14652    if test "$enable_cairo_canvas" != no; then
14653        AC_DEFINE(ENABLE_CAIRO_CANVAS)
14654        ENABLE_CAIRO_CANVAS=TRUE
14655    fi
14656fi
14657
14658AC_SUBST(CAIRO_CFLAGS)
14659AC_SUBST(CAIRO_LIBS)
14660AC_SUBST(ENABLE_CAIRO_CANVAS)
14661AC_SUBST(SYSTEM_CAIRO)
14662
14663dnl ===================================================================
14664dnl Test whether to use avahi
14665dnl ===================================================================
14666if test "$_os" = "WINNT"; then
14667    # Windows uses bundled mDNSResponder
14668    BUILD_TYPE="$BUILD_TYPE MDNSRESPONDER"
14669elif test "$_os" != "Darwin" -a "$enable_avahi" = "yes"; then
14670    PKG_CHECK_MODULES([AVAHI], [avahi-client >= 0.6.10],
14671                      [ENABLE_AVAHI="TRUE"])
14672    AC_DEFINE(HAVE_FEATURE_AVAHI)
14673    AVAHI_CFLAGS=$(printf '%s' "$AVAHI_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
14674    FilterLibs "${AVAHI_LIBS}"
14675    AVAHI_LIBS="${filteredlibs}"
14676fi
14677
14678AC_SUBST(ENABLE_AVAHI)
14679AC_SUBST(AVAHI_CFLAGS)
14680AC_SUBST(AVAHI_LIBS)
14681
14682dnl ===================================================================
14683dnl Test whether to use MSVC /analyze
14684dnl ===================================================================
14685ENABLE_MSVC_ANALYZE=
14686AC_MSG_CHECKING([whether to use MSVC /analyze])
14687if test -n "$enable_msvc_analyze" -a "$enable_msvc_analyze" != "no"; then
14688if test "$_os" = "WINNT"; then
14689    ENABLE_MSVC_ANALYZE=yes
14690    AC_MSG_RESULT([yes])
14691else
14692   AC_MSG_ERROR([--enable-msvc-analyze is only supported on Windows])
14693fi
14694else
14695   AC_MSG_RESULT([no])
14696fi
14697
14698AC_SUBST(ENABLE_MSVC_ANALYZE)
14699
14700dnl ===================================================================
14701dnl Test whether to use liblangtag
14702dnl ===================================================================
14703SYSTEM_LIBLANGTAG=
14704AC_MSG_CHECKING([whether to use system liblangtag])
14705if test "$with_system_liblangtag" = yes; then
14706    SYSTEM_LIBLANGTAG=TRUE
14707    AC_MSG_RESULT([yes])
14708    PKG_CHECK_MODULES( LIBLANGTAG, liblangtag >= 0.4.0)
14709    dnl cf. <https://bitbucket.org/tagoh/liblangtag/commits/9324836a0d1c> "Fix a build issue with inline keyword"
14710    PKG_CHECK_EXISTS([liblangtag >= 0.5.5], [], [AC_DEFINE([LIBLANGTAG_INLINE_FIX])])
14711    LIBLANGTAG_CFLAGS=$(printf '%s' "$LIBLANGTAG_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
14712    FilterLibs "${LIBLANGTAG_LIBS}"
14713    LIBLANGTAG_LIBS="${filteredlibs}"
14714else
14715    SYSTEM_LIBLANGTAG=
14716    AC_MSG_RESULT([no])
14717    BUILD_TYPE="$BUILD_TYPE LIBLANGTAG"
14718    LIBLANGTAG_CFLAGS="-I${WORKDIR}/UnpackedTarball/liblangtag"
14719    if test "$COM" = "MSC"; then
14720        LIBLANGTAG_LIBS="${WORKDIR}/UnpackedTarball/liblangtag/liblangtag/.libs/liblangtag.lib"
14721    else
14722        LIBLANGTAG_LIBS="-L${WORKDIR}/UnpackedTarball/liblangtag/liblangtag/.libs -llangtag"
14723    fi
14724fi
14725AC_SUBST(SYSTEM_LIBLANGTAG)
14726AC_SUBST(LIBLANGTAG_CFLAGS)
14727AC_SUBST(LIBLANGTAG_LIBS)
14728
14729dnl ===================================================================
14730dnl Test whether to build libpng or rely on the system version
14731dnl ===================================================================
14732
14733LIBPNG_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/libpng"
14734LIBPNG_LIBS_internal='-L$(gb_StaticLibrary_WORKDIR) -llibpng'
14735libo_CHECK_SYSTEM_MODULE([libpng],[LIBPNG],[libpng])
14736
14737dnl ===================================================================
14738dnl Test whether to build libtiff or rely on the system version
14739dnl ===================================================================
14740
14741libo_CHECK_SYSTEM_MODULE([libtiff],[LIBTIFF],[libtiff-4])
14742
14743dnl ===================================================================
14744dnl Test whether to build libwebp or rely on the system version
14745dnl ===================================================================
14746
14747libo_CHECK_SYSTEM_MODULE([libwebp],[LIBWEBP],[libwebp])
14748
14749dnl ===================================================================
14750dnl Check for runtime JVM search path
14751dnl ===================================================================
14752if test "$ENABLE_JAVA" != ""; then
14753    AC_MSG_CHECKING([whether to use specific JVM search path at runtime])
14754    if test -n "$with_jvm_path" -a "$with_jvm_path" != "no"; then
14755        AC_MSG_RESULT([yes])
14756        if ! test -d "$with_jvm_path"; then
14757            AC_MSG_ERROR(["$with_jvm_path" not a directory])
14758        fi
14759        if ! test -d "$with_jvm_path"jvm; then
14760            AC_MSG_ERROR(["$with_jvm_path"jvm not found, point with_jvm_path to \[/path/to/\]jvm])
14761        fi
14762        JVM_ONE_PATH_CHECK="$with_jvm_path"
14763        AC_SUBST(JVM_ONE_PATH_CHECK)
14764    else
14765        AC_MSG_RESULT([no])
14766    fi
14767fi
14768
14769dnl ===================================================================
14770dnl Test for the presence of Ant and that it works
14771dnl ===================================================================
14772
14773# java takes the encoding from LC_ALL, and since autoconf forces it to C it
14774# breaks filename decoding, so for the ant section, set it to LANG
14775LC_ALL=$LANG
14776if test "$ENABLE_JAVA" != "" -a "$NEED_ANT" = "TRUE" -a "$cross_compiling" != "yes"; then
14777    ANT_HOME=; export ANT_HOME
14778    WITH_ANT_HOME=; export WITH_ANT_HOME
14779    if test -z "$with_ant_home" -a -n "$LODE_HOME" ; then
14780        if test -x "$LODE_HOME/opt/ant/bin/ant" ; then
14781            if test "$_os" = "WINNT"; then
14782                with_ant_home="`cygpath -m $LODE_HOME/opt/ant`"
14783            else
14784                with_ant_home="$LODE_HOME/opt/ant"
14785            fi
14786        elif test -x  "$LODE_HOME/opt/bin/ant" ; then
14787            with_ant_home="$LODE_HOME/opt/ant"
14788        fi
14789    fi
14790    if test -z "$with_ant_home"; then
14791        AC_PATH_PROGS(ANT, [ant ant.sh ant.bat ant.cmd])
14792    else
14793        if test "$_os" = "WINNT"; then
14794            # AC_PATH_PROGS needs unix path
14795            PathFormat "$with_ant_home"
14796            with_ant_home="$formatted_path_unix"
14797        fi
14798        AbsolutePath "$with_ant_home"
14799        with_ant_home=$absolute_path
14800        AC_PATH_PROGS(ANT, [ant ant.sh ant.bat ant.cmd],,$with_ant_home/bin:$PATH)
14801        WITH_ANT_HOME=$with_ant_home
14802        ANT_HOME=$with_ant_home
14803    fi
14804
14805    if test -z "$ANT"; then
14806        AC_MSG_ERROR([Ant not found - Make sure it's in the path or use --with-ant-home])
14807    else
14808        # resolve relative or absolute symlink
14809        while test -h "$ANT"; do
14810            a_cwd=`pwd`
14811            a_basename=`basename "$ANT"`
14812            a_script=`ls -l "$ANT" | $SED "s/.*${a_basename} -> //g"`
14813            cd "`dirname "$ANT"`"
14814            cd "`dirname "$a_script"`"
14815            ANT="`pwd`"/"`basename "$a_script"`"
14816            cd "$a_cwd"
14817        done
14818
14819        AC_MSG_CHECKING([if $ANT works])
14820        mkdir -p conftest.dir
14821        a_cwd=$(pwd)
14822        cd conftest.dir
14823        cat > conftest.java << EOF
14824        public class conftest {
14825            int testmethod(int a, int b) {
14826                    return a + b;
14827            }
14828        }
14829EOF
14830
14831        cat > conftest.xml << EOF
14832        <project name="conftest" default="conftest">
14833        <target name="conftest">
14834            <javac srcdir="." includes="conftest.java">
14835            </javac>
14836        </target>
14837        </project>
14838EOF
14839
14840        if test -n "$WSL_ONLY_AS_HELPER"; then
14841            # need to set it directly, since ant only tries java, not java.exe from JAVA_HOME
14842            export JAVACMD="$JAVAINTERPRETER"
14843            # similarly it doesn't expect to be called from wsl, so it uses the wsl-realm path when
14844            # building the classpath, but we need the windows-style one for the windows-java
14845            PathFormat "$ANT_HOME"
14846            export LOCALCLASSPATH=";$formatted_path/lib/ant-launcher.jar"
14847        fi
14848        AC_TRY_COMMAND("$ANT" -buildfile conftest.xml 1>&2)
14849        if test $? = 0 -a -f ./conftest.class; then
14850            AC_MSG_RESULT([Ant works])
14851            if test -z "$WITH_ANT_HOME"; then
14852                ANT_HOME=`"$ANT" -diagnostics | $EGREP "ant.home :" | $SED -e "s#ant.home : ##g"`
14853                if test -z "$ANT_HOME"; then
14854                    ANT_HOME=`echo "$ANT" | $SED -n "s/\/bin\/ant.*\$//p"`
14855                fi
14856            else
14857                ANT_HOME="$WITH_ANT_HOME"
14858            fi
14859        else
14860            echo "configure: Ant test failed" >&5
14861            cat conftest.java >&5
14862            cat conftest.xml >&5
14863            AC_MSG_ERROR([Ant does not work - Some Java projects will not build!])
14864        fi
14865        cd "$a_cwd"
14866        rm -fr conftest.dir
14867    fi
14868    if test -z "$ANT_HOME"; then
14869        ANT_HOME="NO_ANT_HOME"
14870    else
14871        PathFormat "$ANT_HOME"
14872        ANT_HOME="$formatted_path_unix"
14873        PathFormat "$ANT"
14874        ANT="$formatted_path_unix"
14875    fi
14876
14877    dnl Checking for ant.jar
14878    if test "$ANT_HOME" != "NO_ANT_HOME"; then
14879        AC_MSG_CHECKING([Ant lib directory])
14880        if test -f $ANT_HOME/lib/ant.jar; then
14881            ANT_LIB="$ANT_HOME/lib"
14882        else
14883            if test -f $ANT_HOME/ant.jar; then
14884                ANT_LIB="$ANT_HOME"
14885            else
14886                if test -f /usr/share/java/ant.jar; then
14887                    ANT_LIB=/usr/share/java
14888                else
14889                    if test -f /usr/share/ant-core/lib/ant.jar; then
14890                        ANT_LIB=/usr/share/ant-core/lib
14891                    else
14892                        if test -f $ANT_HOME/lib/ant/ant.jar; then
14893                            ANT_LIB="$ANT_HOME/lib/ant"
14894                        else
14895                            if test -f /usr/share/lib/ant/ant.jar; then
14896                                ANT_LIB=/usr/share/lib/ant
14897                            else
14898                                AC_MSG_ERROR([Ant libraries not found!])
14899                            fi
14900                        fi
14901                    fi
14902                fi
14903            fi
14904        fi
14905        PathFormat "$ANT_LIB"
14906        ANT_LIB="$formatted_path"
14907        AC_MSG_RESULT([Ant lib directory found.])
14908    fi
14909
14910    ant_minver=1.6.0
14911    ant_minminor1=`echo $ant_minver | cut -d"." -f2`
14912
14913    AC_MSG_CHECKING([whether Ant is >= $ant_minver])
14914    ant_version=`"$ANT" -version | $AWK '$3 == "version" { print $4; }'`
14915    ant_version_major=`echo $ant_version | cut -d. -f1`
14916    ant_version_minor=`echo $ant_version | cut -d. -f2`
14917    echo "configure: ant_version $ant_version " >&5
14918    echo "configure: ant_version_major $ant_version_major " >&5
14919    echo "configure: ant_version_minor $ant_version_minor " >&5
14920    if test "$ant_version_major" -ge "2"; then
14921        AC_MSG_RESULT([yes, $ant_version])
14922    elif test "$ant_version_major" = "1" -a "$ant_version_minor" -ge "$ant_minminor1"; then
14923        AC_MSG_RESULT([yes, $ant_version])
14924    else
14925        AC_MSG_ERROR([no, you need at least Ant >= $ant_minver])
14926    fi
14927
14928    rm -f conftest* core core.* *.core
14929fi
14930AC_SUBST(ANT)
14931AC_SUBST(ANT_HOME)
14932AC_SUBST(ANT_LIB)
14933
14934OOO_JUNIT_JAR=
14935HAMCREST_JAR=
14936if test "$ENABLE_JAVA" != "" -a "$with_junit" != "no" -a "$cross_compiling" != "yes"; then
14937    AC_MSG_CHECKING([for JUnit 4])
14938    if test "$with_junit" = "yes"; then
14939        if test -n "$LODE_HOME" -a -e "$LODE_HOME/opt/share/java/junit.jar" ; then
14940            OOO_JUNIT_JAR="$LODE_HOME/opt/share/java/junit.jar"
14941        elif test -e /usr/share/java/junit4.jar; then
14942            OOO_JUNIT_JAR=/usr/share/java/junit4.jar
14943        else
14944           if test -e /usr/share/lib/java/junit.jar; then
14945              OOO_JUNIT_JAR=/usr/share/lib/java/junit.jar
14946           else
14947              OOO_JUNIT_JAR=/usr/share/java/junit.jar
14948           fi
14949        fi
14950    else
14951        OOO_JUNIT_JAR=$with_junit
14952    fi
14953    if test "$_os" = "WINNT"; then
14954        PathFormat "$OOO_JUNIT_JAR"
14955        OOO_JUNIT_JAR="$formatted_path"
14956    fi
14957    printf 'import org.junit.Before;' > conftest.java
14958    if $JAVACOMPILER -classpath "$OOO_JUNIT_JAR" conftest.java >&5 2>&5; then
14959        AC_MSG_RESULT([$OOO_JUNIT_JAR])
14960    else
14961        AC_MSG_ERROR(
14962[cannot find JUnit 4 jar; please install one in the default location (/usr/share/java),
14963 specify its pathname via --with-junit=..., or disable it via --without-junit])
14964    fi
14965    rm -f conftest.class conftest.java
14966    if test $OOO_JUNIT_JAR != ""; then
14967        BUILD_TYPE="$BUILD_TYPE QADEVOOO"
14968    fi
14969
14970    AC_MSG_CHECKING([for included Hamcrest])
14971    printf 'import org.hamcrest.BaseDescription;' > conftest.java
14972    if $JAVACOMPILER -classpath "$OOO_JUNIT_JAR" conftest.java >&5 2>&5; then
14973        AC_MSG_RESULT([Included in $OOO_JUNIT_JAR])
14974    else
14975        AC_MSG_RESULT([Not included])
14976        AC_MSG_CHECKING([for standalone hamcrest jar.])
14977        if test "$with_hamcrest" = "yes"; then
14978            if test -e /usr/share/lib/java/hamcrest.jar; then
14979                HAMCREST_JAR=/usr/share/lib/java/hamcrest.jar
14980            elif test -e /usr/share/java/hamcrest/core.jar; then
14981                HAMCREST_JAR=/usr/share/java/hamcrest/core.jar
14982            elif test -e /usr/share/java/hamcrest/hamcrest.jar; then
14983                HAMCREST_JAR=/usr/share/java/hamcrest/hamcrest.jar
14984            else
14985                HAMCREST_JAR=/usr/share/java/hamcrest.jar
14986            fi
14987        else
14988            HAMCREST_JAR=$with_hamcrest
14989        fi
14990        if test "$_os" = "WINNT"; then
14991            PathFormat "$HAMCREST_JAR"
14992            HAMCREST_JAR="$formatted_path"
14993        fi
14994        if $JAVACOMPILER -classpath "$HAMCREST_JAR" conftest.java >&5 2>&5; then
14995            AC_MSG_RESULT([$HAMCREST_JAR])
14996        else
14997            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),
14998                          specify its path with --with-hamcrest=..., or disable junit with --without-junit])
14999        fi
15000    fi
15001    rm -f conftest.class conftest.java
15002fi
15003AC_SUBST(OOO_JUNIT_JAR)
15004AC_SUBST(HAMCREST_JAR)
15005# set back LC_ALL to C after the java related tests...
15006LC_ALL=C
15007
15008AC_SUBST(SCPDEFS)
15009
15010#
15011# check for wget and curl
15012#
15013WGET=
15014CURL=
15015
15016if test "$enable_fetch_external" != "no"; then
15017
15018CURL=`command -v curl`
15019
15020for i in wget /usr/bin/wget /usr/local/bin/wget /usr/sfw/bin/wget /opt/sfw/bin/wget /opt/local/bin/wget; do
15021    # wget new enough?
15022    $i --help 2> /dev/null | $GREP no-use-server-timestamps 2>&1 > /dev/null
15023    if test $? -eq 0; then
15024        WGET=$i
15025        break
15026    fi
15027done
15028
15029if test -z "$WGET" -a -z "$CURL"; then
15030    AC_MSG_ERROR([neither wget nor curl found!])
15031fi
15032
15033fi
15034
15035AC_SUBST(WGET)
15036AC_SUBST(CURL)
15037
15038#
15039# check for sha256sum
15040#
15041SHA256SUM=
15042
15043for i in shasum /usr/local/bin/shasum /usr/sfw/bin/shasum /opt/sfw/bin/shasum /opt/local/bin/shasum; do
15044    eval "$i -a 256 --version" > /dev/null 2>&1
15045    ret=$?
15046    if test $ret -eq 0; then
15047        SHA256SUM="$i -a 256"
15048        break
15049    fi
15050done
15051
15052if test -z "$SHA256SUM"; then
15053    for i in sha256sum /usr/local/bin/sha256sum /usr/sfw/bin/sha256sum /opt/sfw/bin/sha256sum /opt/local/bin/sha256sum; do
15054        eval "$i --version" > /dev/null 2>&1
15055        ret=$?
15056        if test $ret -eq 0; then
15057            SHA256SUM=$i
15058            break
15059        fi
15060    done
15061fi
15062
15063if test -z "$SHA256SUM"; then
15064    AC_MSG_ERROR([no sha256sum found!])
15065fi
15066
15067AC_SUBST(SHA256SUM)
15068
15069dnl ===================================================================
15070dnl Dealing with l10n options
15071dnl ===================================================================
15072AC_MSG_CHECKING([which languages to be built])
15073# get list of all languages
15074# generate shell variable from completelangiso= from solenv/inc/langlist.mk
15075# we want en-US at the beginning
15076ALL_LANGS=$($GNUMAKE SRC_ROOT=$SRC_ROOT WITH_LANG="$with_lang" ENABLE_RELEASE_BUILD="$ENABLE_RELEASE_BUILD" -sr -f - <<'EOF' | tr -d '\r'
15077include $(SRC_ROOT)/solenv/inc/langlist.mk
15078all:
15079	$(info en-US $(filter-out en-US,$(sort $(completelangiso))))
15080EOF
15081)
15082
15083# check the configured localizations
15084WITH_LANG="$with_lang"
15085
15086# Check for --without-lang which turns up as $with_lang being "no". Luckily there is no language with code "no".
15087# (Norwegian is "nb" and "nn".)
15088if test "$WITH_LANG" = "no"; then
15089    WITH_LANG=
15090fi
15091
15092if test -z "$WITH_LANG" -o "$WITH_LANG" = "en-US"; then
15093    AC_MSG_RESULT([en-US])
15094else
15095    AC_MSG_RESULT([$WITH_LANG])
15096    GIT_NEEDED_SUBMODULES="translations $GIT_NEEDED_SUBMODULES"
15097    if test -z "$MSGFMT"; then
15098        if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/msgfmt" ; then
15099            MSGFMT="$LODE_HOME/opt/bin/msgfmt"
15100        elif test -x "/opt/lo/bin/msgfmt"; then
15101            MSGFMT="/opt/lo/bin/msgfmt"
15102        else
15103            AC_CHECK_PROGS(MSGFMT, [msgfmt])
15104            if test -z "$MSGFMT"; then
15105                AC_MSG_ERROR([msgfmt not found. Install GNU gettext, or re-run without languages.])
15106            fi
15107        fi
15108    fi
15109    if test -z "$MSGUNIQ"; then
15110        if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/msguniq" ; then
15111            MSGUNIQ="$LODE_HOME/opt/bin/msguniq"
15112        elif test -x "/opt/lo/bin/msguniq"; then
15113            MSGUNIQ="/opt/lo/bin/msguniq"
15114        else
15115            AC_CHECK_PROGS(MSGUNIQ, [msguniq])
15116            if test -z "$MSGUNIQ"; then
15117                AC_MSG_ERROR([msguniq not found. Install GNU gettext, or re-run without languages.])
15118            fi
15119        fi
15120    fi
15121fi
15122AC_SUBST(MSGFMT)
15123AC_SUBST(MSGUNIQ)
15124# check that the list is valid
15125for lang in $WITH_LANG; do
15126    test "$lang" = "ALL" && continue
15127    # need to check for the exact string, so add space before and after the list of all languages
15128    for vl in $ALL_LANGS; do
15129        if test "$vl" = "$lang"; then
15130           break
15131        fi
15132    done
15133    if test "$vl" != "$lang"; then
15134        # if you're reading this - you probably quoted your languages remove the quotes ...
15135        AC_MSG_ERROR([invalid language: '$lang' (vs '$v1'); supported languages are: $ALL_LANGS])
15136    fi
15137done
15138if test -n "$WITH_LANG" -a "$WITH_LANG" != "ALL"; then
15139    echo $WITH_LANG | grep -q en-US
15140    test $? -ne 1 || WITH_LANG=`echo $WITH_LANG en-US`
15141fi
15142# list with substituted ALL
15143WITH_LANG_LIST=`echo $WITH_LANG | sed "s/ALL/$ALL_LANGS/"`
15144test -z "$WITH_LANG_LIST" && WITH_LANG_LIST="en-US"
15145test "$WITH_LANG" = "en-US" && WITH_LANG=
15146if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
15147    test "$WITH_LANG_LIST" = "en-US" || WITH_LANG_LIST=`echo $WITH_LANG_LIST qtz`
15148    ALL_LANGS=`echo $ALL_LANGS qtz`
15149fi
15150AC_SUBST(ALL_LANGS)
15151AC_DEFINE_UNQUOTED(WITH_LANG,"$WITH_LANG")
15152AC_SUBST(WITH_LANG)
15153AC_SUBST(WITH_LANG_LIST)
15154AC_SUBST(GIT_NEEDED_SUBMODULES)
15155
15156WITH_POOR_HELP_LOCALIZATIONS=
15157if test -d "$SRC_ROOT/translations/source"; then
15158    for l in `ls -1 $SRC_ROOT/translations/source`; do
15159        if test ! -d "$SRC_ROOT/translations/source/$l/helpcontent2"; then
15160            WITH_POOR_HELP_LOCALIZATIONS="$WITH_POOR_HELP_LOCALIZATIONS $l"
15161        fi
15162    done
15163fi
15164AC_SUBST(WITH_POOR_HELP_LOCALIZATIONS)
15165
15166if test -n "$with_locales" -a "$with_locales" != ALL; then
15167    WITH_LOCALES="$with_locales"
15168
15169    just_langs="`echo $WITH_LOCALES | sed -e 's/_[A-Z]*//g'`"
15170    # Only languages and scripts for which we actually have ifdefs need to be handled. Also see
15171    # config_host/config_locales.h.in
15172    for locale in $WITH_LOCALES; do
15173        lang=${locale%_*}
15174
15175        AC_DEFINE_UNQUOTED(WITH_LOCALE_$lang, 1)
15176
15177        case $lang in
15178        hi|mr*ne)
15179            AC_DEFINE(WITH_LOCALE_FOR_SCRIPT_Deva)
15180            ;;
15181        bg|ru)
15182            AC_DEFINE(WITH_LOCALE_FOR_SCRIPT_Cyrl)
15183            ;;
15184        esac
15185    done
15186else
15187    AC_DEFINE(WITH_LOCALE_ALL)
15188fi
15189AC_SUBST(WITH_LOCALES)
15190
15191dnl git submodule update --reference
15192dnl ===================================================================
15193if test -n "${GIT_REFERENCE_SRC}"; then
15194    for repo in ${GIT_NEEDED_SUBMODULES}; do
15195        if ! test -d "${GIT_REFERENCE_SRC}"/${repo}; then
15196            AC_MSG_ERROR([referenced git: required repository does not exist: ${GIT_REFERENCE_SRC}/${repo}])
15197        fi
15198    done
15199fi
15200AC_SUBST(GIT_REFERENCE_SRC)
15201
15202dnl git submodules linked dirs
15203dnl ===================================================================
15204if test -n "${GIT_LINK_SRC}"; then
15205    for repo in ${GIT_NEEDED_SUBMODULES}; do
15206        if ! test -d "${GIT_LINK_SRC}"/${repo}; then
15207            AC_MSG_ERROR([linked git: required repository does not exist: ${GIT_LINK_SRC}/${repo}])
15208        fi
15209    done
15210fi
15211AC_SUBST(GIT_LINK_SRC)
15212
15213dnl branding
15214dnl ===================================================================
15215AC_MSG_CHECKING([for alternative branding images directory])
15216# initialize mapped arrays
15217BRAND_INTRO_IMAGES="intro.png intro-highres.png"
15218brand_files="$BRAND_INTRO_IMAGES logo.svg logo_inverted.svg logo-sc.svg logo-sc_inverted.svg about.svg"
15219
15220if test -z "$with_branding" -o "$with_branding" = "no"; then
15221    AC_MSG_RESULT([none])
15222    DEFAULT_BRAND_IMAGES="$brand_files"
15223else
15224    if ! test -d $with_branding ; then
15225        AC_MSG_ERROR([No directory $with_branding, falling back to default branding])
15226    else
15227        AC_MSG_RESULT([$with_branding])
15228        CUSTOM_BRAND_DIR="$with_branding"
15229        for lfile in $brand_files
15230        do
15231            if ! test -f $with_branding/$lfile ; then
15232                AC_MSG_WARN([Branded file $lfile does not exist, using the default one])
15233                DEFAULT_BRAND_IMAGES="$DEFAULT_BRAND_IMAGES $lfile"
15234            else
15235                CUSTOM_BRAND_IMAGES="$CUSTOM_BRAND_IMAGES $lfile"
15236            fi
15237        done
15238        check_for_progress="yes"
15239    fi
15240fi
15241AC_SUBST([BRAND_INTRO_IMAGES])
15242AC_SUBST([CUSTOM_BRAND_DIR])
15243AC_SUBST([CUSTOM_BRAND_IMAGES])
15244AC_SUBST([DEFAULT_BRAND_IMAGES])
15245
15246
15247AC_MSG_CHECKING([for 'intro' progress settings])
15248PROGRESSBARCOLOR=
15249PROGRESSSIZE=
15250PROGRESSPOSITION=
15251PROGRESSFRAMECOLOR=
15252PROGRESSTEXTCOLOR=
15253PROGRESSTEXTBASELINE=
15254
15255if test "$check_for_progress" = "yes" -a -f "$with_branding/progress.conf" ; then
15256    source "$with_branding/progress.conf"
15257    AC_MSG_RESULT([settings found in $with_branding/progress.conf])
15258else
15259    AC_MSG_RESULT([none])
15260fi
15261
15262AC_SUBST(PROGRESSBARCOLOR)
15263AC_SUBST(PROGRESSSIZE)
15264AC_SUBST(PROGRESSPOSITION)
15265AC_SUBST(PROGRESSFRAMECOLOR)
15266AC_SUBST(PROGRESSTEXTCOLOR)
15267AC_SUBST(PROGRESSTEXTBASELINE)
15268
15269
15270dnl ===================================================================
15271dnl Custom build version
15272dnl ===================================================================
15273AC_MSG_CHECKING([for extra build ID])
15274if test -n "$with_extra_buildid" -a "$with_extra_buildid" != "yes" ; then
15275    EXTRA_BUILDID="$with_extra_buildid"
15276fi
15277# in tinderboxes, it is easier to set EXTRA_BUILDID via the environment variable instead of configure switch
15278if test -n "$EXTRA_BUILDID" ; then
15279    AC_MSG_RESULT([$EXTRA_BUILDID])
15280else
15281    AC_MSG_RESULT([not set])
15282fi
15283AC_DEFINE_UNQUOTED([EXTRA_BUILDID], ["$EXTRA_BUILDID"])
15284
15285OOO_VENDOR=
15286AC_MSG_CHECKING([for vendor])
15287if test -z "$with_vendor" -o "$with_vendor" = "no"; then
15288    OOO_VENDOR="$USERNAME"
15289
15290    if test -z "$OOO_VENDOR"; then
15291        OOO_VENDOR="$USER"
15292    fi
15293
15294    if test -z "$OOO_VENDOR"; then
15295        OOO_VENDOR="`id -u -n`"
15296    fi
15297
15298    AC_MSG_RESULT([not set, using $OOO_VENDOR])
15299else
15300    OOO_VENDOR="$with_vendor"
15301    AC_MSG_RESULT([$OOO_VENDOR])
15302fi
15303AC_DEFINE_UNQUOTED(OOO_VENDOR,"$OOO_VENDOR")
15304AC_SUBST(OOO_VENDOR)
15305
15306if test "$_os" = "Android" ; then
15307    ANDROID_PACKAGE_NAME=
15308    AC_MSG_CHECKING([for Android package name])
15309    if test -z "$with_android_package_name" -o "$with_android_package_name" = "no"; then
15310        if test -n "$ENABLE_DEBUG"; then
15311            # Default to the package name that makes ndk-gdb happy.
15312            ANDROID_PACKAGE_NAME="org.libreoffice"
15313        else
15314            ANDROID_PACKAGE_NAME="org.example.libreoffice"
15315        fi
15316
15317        AC_MSG_RESULT([not set, using $ANDROID_PACKAGE_NAME])
15318    else
15319        ANDROID_PACKAGE_NAME="$with_android_package_name"
15320        AC_MSG_RESULT([$ANDROID_PACKAGE_NAME])
15321    fi
15322    AC_SUBST(ANDROID_PACKAGE_NAME)
15323fi
15324
15325AC_MSG_CHECKING([whether to install the compat oo* wrappers])
15326if test "$with_compat_oowrappers" = "yes"; then
15327    WITH_COMPAT_OOWRAPPERS=TRUE
15328    AC_MSG_RESULT(yes)
15329else
15330    WITH_COMPAT_OOWRAPPERS=
15331    AC_MSG_RESULT(no)
15332fi
15333AC_SUBST(WITH_COMPAT_OOWRAPPERS)
15334
15335INSTALLDIRNAME=`echo AC_PACKAGE_NAME | $AWK '{print tolower($0)}'`
15336AC_MSG_CHECKING([for install dirname])
15337if test -n "$with_install_dirname" -a "$with_install_dirname" != "no" -a "$with_install_dirname" != "yes"; then
15338    INSTALLDIRNAME="$with_install_dirname"
15339fi
15340AC_MSG_RESULT([$INSTALLDIRNAME])
15341AC_SUBST(INSTALLDIRNAME)
15342
15343AC_MSG_CHECKING([for prefix])
15344test "x$prefix" = xNONE && prefix=$ac_default_prefix
15345test "x$exec_prefix" = xNONE && exec_prefix=$prefix
15346PREFIXDIR="$prefix"
15347AC_MSG_RESULT([$PREFIXDIR])
15348AC_SUBST(PREFIXDIR)
15349
15350LIBDIR=[$(eval echo $(eval echo $libdir))]
15351AC_SUBST(LIBDIR)
15352
15353DATADIR=[$(eval echo $(eval echo $datadir))]
15354AC_SUBST(DATADIR)
15355
15356MANDIR=[$(eval echo $(eval echo $mandir))]
15357AC_SUBST(MANDIR)
15358
15359DOCDIR=[$(eval echo $(eval echo $docdir))]
15360AC_SUBST(DOCDIR)
15361
15362BINDIR=[$(eval echo $(eval echo $bindir))]
15363AC_SUBST(BINDIR)
15364
15365INSTALLDIR="$LIBDIR/$INSTALLDIRNAME"
15366AC_SUBST(INSTALLDIR)
15367
15368TESTINSTALLDIR="${BUILDDIR}/test-install"
15369AC_SUBST(TESTINSTALLDIR)
15370
15371
15372# ===================================================================
15373# OAuth2 id and secrets
15374# ===================================================================
15375
15376AC_MSG_CHECKING([for Google Drive client id and secret])
15377if test "$with_gdrive_client_id" = "no" -o -z "$with_gdrive_client_id"; then
15378    AC_MSG_RESULT([not set])
15379    GDRIVE_CLIENT_ID="\"\""
15380    GDRIVE_CLIENT_SECRET="\"\""
15381else
15382    AC_MSG_RESULT([set])
15383    GDRIVE_CLIENT_ID="\"$with_gdrive_client_id\""
15384    GDRIVE_CLIENT_SECRET="\"$with_gdrive_client_secret\""
15385fi
15386AC_DEFINE_UNQUOTED(GDRIVE_CLIENT_ID, $GDRIVE_CLIENT_ID)
15387AC_DEFINE_UNQUOTED(GDRIVE_CLIENT_SECRET, $GDRIVE_CLIENT_SECRET)
15388
15389AC_MSG_CHECKING([for Alfresco Cloud client id and secret])
15390if test "$with_alfresco_cloud_client_id" = "no" -o -z "$with_alfresco_cloud_client_id"; then
15391    AC_MSG_RESULT([not set])
15392    ALFRESCO_CLOUD_CLIENT_ID="\"\""
15393    ALFRESCO_CLOUD_CLIENT_SECRET="\"\""
15394else
15395    AC_MSG_RESULT([set])
15396    ALFRESCO_CLOUD_CLIENT_ID="\"$with_alfresco_cloud_client_id\""
15397    ALFRESCO_CLOUD_CLIENT_SECRET="\"$with_alfresco_cloud_client_secret\""
15398fi
15399AC_DEFINE_UNQUOTED(ALFRESCO_CLOUD_CLIENT_ID, $ALFRESCO_CLOUD_CLIENT_ID)
15400AC_DEFINE_UNQUOTED(ALFRESCO_CLOUD_CLIENT_SECRET, $ALFRESCO_CLOUD_CLIENT_SECRET)
15401
15402AC_MSG_CHECKING([for OneDrive client id and secret])
15403if test "$with_onedrive_client_id" = "no" -o -z "$with_onedrive_client_id"; then
15404    AC_MSG_RESULT([not set])
15405    ONEDRIVE_CLIENT_ID="\"\""
15406    ONEDRIVE_CLIENT_SECRET="\"\""
15407else
15408    AC_MSG_RESULT([set])
15409    ONEDRIVE_CLIENT_ID="\"$with_onedrive_client_id\""
15410    ONEDRIVE_CLIENT_SECRET="\"$with_onedrive_client_secret\""
15411fi
15412AC_DEFINE_UNQUOTED(ONEDRIVE_CLIENT_ID, $ONEDRIVE_CLIENT_ID)
15413AC_DEFINE_UNQUOTED(ONEDRIVE_CLIENT_SECRET, $ONEDRIVE_CLIENT_SECRET)
15414
15415
15416dnl ===================================================================
15417dnl Hook up LibreOffice's nodep environmental variable to automake's equivalent
15418dnl --enable-dependency-tracking configure option
15419dnl ===================================================================
15420AC_MSG_CHECKING([whether to enable dependency tracking])
15421DEPS_SYSINCLUDES=
15422if test "$enable_dependency_tracking" = "no"; then
15423    nodep=TRUE
15424    AC_MSG_RESULT([no])
15425elif test "$enable_dependency_tracking" = sysincludes; then
15426    if test "$COM" != GCC; then
15427        AC_MSG_ERROR(
15428            [--enable-dependency-tracking=sysincludes is currently only implemented for GCC-like compilers])
15429    else
15430        AC_MSG_RESULT([yes, including system include files])
15431        DEPS_SYSINCLUDES=TRUE
15432    fi
15433else
15434    AC_MSG_RESULT([yes])
15435fi
15436AC_SUBST(nodep)
15437AC_SUBST([DEPS_SYSINCLUDES])
15438
15439dnl ===================================================================
15440dnl Number of CPUs to use during the build
15441dnl ===================================================================
15442AC_MSG_CHECKING([for number of processors to use])
15443# plain --with-parallelism is just the default
15444if test -n "$with_parallelism" -a "$with_parallelism" != "yes"; then
15445    if test "$with_parallelism" = "no"; then
15446        PARALLELISM=0
15447    else
15448        PARALLELISM=$with_parallelism
15449    fi
15450else
15451    if test "$enable_icecream" = "yes"; then
15452        PARALLELISM="40"
15453    else
15454        case `uname -s` in
15455
15456        Darwin|FreeBSD|NetBSD|OpenBSD)
15457            PARALLELISM=`sysctl -n hw.ncpu`
15458            ;;
15459
15460        Linux)
15461            PARALLELISM=`getconf _NPROCESSORS_ONLN`
15462        ;;
15463        # what else than above does profit here *and* has /proc?
15464        *)
15465            PARALLELISM=`grep $'^processor\t*:' /proc/cpuinfo | wc -l`
15466            ;;
15467        esac
15468
15469        # If we hit the catch-all case, but /proc/cpuinfo doesn't exist or has an
15470        # unexpected format, 'wc -l' will have returned 0 (and we won't use -j at all).
15471    fi
15472fi
15473
15474if test $PARALLELISM -eq 0; then
15475    AC_MSG_RESULT([explicit make -j option needed])
15476else
15477    AC_MSG_RESULT([$PARALLELISM])
15478fi
15479AC_SUBST(PARALLELISM)
15480
15481#
15482# Set up ILIB for MSVC build
15483#
15484ILIB1=
15485if test "$build_os" = "cygwin" -o "$build_os" = "wsl" -o -n "$WSL_ONLY_AS_HELPER"; then
15486    ILIB="."
15487    if test -n "$JAVA_HOME"; then
15488        ILIB="$ILIB;$JAVA_HOME/lib"
15489    fi
15490    ILIB1=-link
15491    PathFormat "${COMPATH}/lib/$WIN_HOST_ARCH"
15492    ILIB="$ILIB;$formatted_path"
15493    ILIB1="$ILIB1 -LIBPATH:$formatted_path"
15494    ILIB="$ILIB;$WINDOWS_SDK_HOME/lib/$WIN_HOST_ARCH"
15495    ILIB1="$ILIB1 -LIBPATH:$WINDOWS_SDK_HOME/lib/$WIN_HOST_ARCH"
15496    if test $WINDOWS_SDK_VERSION = 80 -o $WINDOWS_SDK_VERSION = 81 -o $WINDOWS_SDK_VERSION = 10; then
15497        ILIB="$ILIB;$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/$WIN_HOST_ARCH"
15498        ILIB1="$ILIB1 -LIBPATH:$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/$WIN_HOST_ARCH"
15499    fi
15500    PathFormat "${UCRTSDKDIR}lib/$UCRTVERSION/ucrt/$WIN_HOST_ARCH"
15501    ucrtlibpath_formatted=$formatted_path
15502    ILIB="$ILIB;$ucrtlibpath_formatted"
15503    ILIB1="$ILIB1 -LIBPATH:$ucrtlibpath_formatted"
15504    if test -f "$DOTNET_FRAMEWORK_HOME/lib/mscoree.lib"; then
15505        PathFormat "$DOTNET_FRAMEWORK_HOME/lib"
15506        ILIB="$ILIB;$formatted_path"
15507    else
15508        PathFormat "$DOTNET_FRAMEWORK_HOME/Lib/um/$WIN_HOST_ARCH"
15509        ILIB="$ILIB;$formatted_path"
15510    fi
15511
15512    if test "$cross_compiling" != "yes"; then
15513        ILIB_FOR_BUILD="$ILIB"
15514    fi
15515fi
15516AC_SUBST(ILIB)
15517AC_SUBST(ILIB_FOR_BUILD)
15518
15519AC_MSG_CHECKING([whether $CXX_BASE supports a working C++20 consteval])
15520dnl ...that does not suffer from <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96994> "Missing code
15521dnl from consteval constructor initializing const variable",
15522dnl <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98752> "wrong 'error: ‘this’ is not a constant
15523dnl expression' with consteval constructor", <https://bugs.llvm.org/show_bug.cgi?id=50063> "code
15524dnl using consteval: 'clang/lib/CodeGen/Address.h:38: llvm::Value*
15525dnl clang::CodeGen::Address::getPointer() const: Assertion `isValid()' failed.'" (which should be
15526dnl fixed since Clang 14), <https://developercommunity.visualstudio.com/t/1581879> "Bogus error
15527dnl C7595 with consteval constructor in ternary expression (/std:c++latest)" (which appears to be
15528dnl fixed at least in Visual Studio Community 2022 Preview 17.9.0 Preview 5.0),
15529dnl <https://github.com/llvm/llvm-project/issues/54612> "C++20, consteval, anonymous union:
15530dnl llvm/lib/IR/Instructions.cpp:1491: void llvm::StoreInst::AssertOK(): Assertion
15531dnl `cast<PointerType>(getOperand(1)->getType())->isOpaqueOrPointeeTypeMatches(getOperand(0)->getType())
15532dnl && "Ptr must be a pointer to Val type!"' failed." (which should be fixed since Clang 17), or
15533dnl <https://developercommunity.visualstudio.com/t/Bogus-error-C2440-with-consteval-constru/10579616>
15534dnl "Bogus error C2440 with consteval constructor (/std:c++20)":
15535have_cpp_consteval=
15536AC_LANG_PUSH([C++])
15537save_CXX=$CXX
15538if test "$COM" = MSC && test "$COM_IS_CLANG" != TRUE; then
15539    CXX="env LIB=$ILIB $CXX"
15540fi
15541save_CXXFLAGS=$CXXFLAGS
15542CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
15543AC_RUN_IFELSE([AC_LANG_PROGRAM([
15544        struct S {
15545            consteval S() { i = 1; }
15546            int i = 0;
15547        };
15548        S const s;
15549
15550        struct S1 {
15551             int a;
15552             consteval S1(int n): a(n) {}
15553        };
15554        struct S2 {
15555            S1 x;
15556            S2(): x(0) {}
15557        };
15558
15559        struct S3 {
15560            consteval S3() {}
15561            union {
15562                int a;
15563                unsigned b = 0;
15564            };
15565        };
15566        void f() { S3(); }
15567
15568        struct S4 { consteval S4() = default; };
15569        void f4(bool b) { b ? S4() : S4(); }
15570
15571        struct S5 {
15572            consteval S5() { c = 0; }
15573            char * f() { return &c; }
15574            union {
15575                char c;
15576                int i;
15577            };
15578        };
15579        auto s5 = S5().f();
15580
15581        struct S6 {
15582            consteval S6(char const (&lit)[[2]]) {
15583                buf[[0]] = lit[[0]];
15584                buf[[1]] = lit[[1]];
15585            }
15586            union {
15587                int x;
15588                char buf[[2]];
15589            };
15590        };
15591        void f6() { S6("a"); }
15592    ], [
15593        return (s.i == 1) ? 0 : 1;
15594    ])], [
15595        have_cpp_consteval=1
15596        AC_MSG_RESULT([yes])
15597    ], [AC_MSG_RESULT([no])], [AC_MSG_RESULT([assumed no (cross compiling)])])
15598CXX=$save_CXX
15599CXXFLAGS=$save_CXXFLAGS
15600AC_LANG_POP([C++])
15601if test -n "$have_cpp_consteval" && test "$COM_IS_CLANG" = TRUE && test -n "$BUILDING_PCH_WITH_OBJ"
15602then
15603    AC_MSG_CHECKING([whether $CXX_BASE has working consteval in combination with PCH])
15604    dnl ...that does not suffer from <https://github.com/llvm/llvm-project/issues/81745> "undefined
15605    dnl reference to consteval constructor exported from module" (which also affects PCH, see
15606    dnl <https://lists.freedesktop.org/archives/libreoffice/2024-February/091564.html> "Our Clang
15607    dnl --enable-pch setup is known broken"):
15608    printf 'export module M;\nexport struct S1 { consteval S1(int) {} };' >conftest.cppm
15609    $CXX $CXXFLAGS $CXXFLAGS_CXX11 --precompile conftest.cppm
15610    rm conftest.cppm
15611    AC_LANG_PUSH([C++])
15612    save_CXXFLAGS=$CXXFLAGS
15613    save_LDFLAGS=$LDFLAGS
15614    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
15615    LDFLAGS="$LDFLAGS -fmodule-file=M=conftest.pcm conftest.pcm"
15616    AC_LINK_IFELSE([AC_LANG_PROGRAM([
15617        import M;
15618    ], [
15619        struct S2 { S1 s = 0; };
15620        S2 s;
15621    ])], [
15622        AC_MSG_RESULT([yes])
15623    ], [
15624        have_cpp_consteval=
15625        AC_MSG_RESULT([no])])
15626    CXXFLAGS=$save_CXXFLAGS
15627    LDFLAGS=$save_LDFLAGS
15628    AC_LANG_POP([C++])
15629    rm conftest.pcm
15630fi
15631if test -n "$have_cpp_consteval"; then
15632    AC_DEFINE([HAVE_CPP_CONSTEVAL],[1])
15633fi
15634
15635AC_MSG_CHECKING([whether $CXX_BASE supports a working C++20 std::strong_order])
15636dnl ...which is known to not be implemented in libc++ prior to
15637dnl <https://github.com/llvm/llvm-project/commit/d8380ad977e94498e170b06449c81f1fc27da7b5> "[libc++]
15638dnl [P1614] Implement [cmp.alg]'s std::{strong,weak,partial}_order" in LLVM 14:
15639AC_LANG_PUSH([C++])
15640save_CXX=$CXX
15641if test "$COM" = MSC && test "$COM_IS_CLANG" != TRUE; then
15642    CXX="env LIB=$ILIB $CXX"
15643fi
15644save_CXXFLAGS=$CXXFLAGS
15645CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
15646AC_LINK_IFELSE([AC_LANG_PROGRAM([
15647        #include <compare>
15648    ], [
15649        (void) (std::strong_order(1.0, 2.0) < 0);
15650    ])], [
15651        AC_DEFINE([HAVE_CPP_STRONG_ORDER],[1])
15652        AC_MSG_RESULT([yes])
15653    ], [AC_MSG_RESULT([no])])
15654CXX=$save_CXX
15655CXXFLAGS=$save_CXXFLAGS
15656AC_LANG_POP([C++])
15657
15658# ===================================================================
15659# Creating bigger shared library to link against
15660# ===================================================================
15661AC_MSG_CHECKING([whether to create huge library])
15662MERGELIBS=
15663MERGELIBS_MORE=
15664
15665if test $_os = iOS -o $_os = Android; then
15666    # Never any point in mergelibs for these as we build just static
15667    # libraries anyway...
15668    enable_mergelibs=no
15669fi
15670
15671if test -n "$enable_mergelibs" -a "$enable_mergelibs" != "no"; then
15672    if test "$enable_mergelibs" = "more"; then
15673        MERGELIBS="TRUE"
15674        MERGELIBS_MORE="TRUE"
15675        AC_MSG_RESULT([yes (more)])
15676        AC_DEFINE(ENABLE_MERGELIBS)
15677        AC_DEFINE(ENABLE_MERGELIBS_MORE)
15678    elif test "$enable_mergelibs" = "yes" -o "$enable_mergelibs" = ""; then
15679        MERGELIBS="TRUE"
15680        AC_MSG_RESULT([yes])
15681        AC_DEFINE(ENABLE_MERGELIBS)
15682    else
15683        AC_MSG_ERROR([unknown value --enable-mergelibs=$enable_mergelibs])
15684    fi
15685else
15686    AC_MSG_RESULT([no])
15687fi
15688AC_SUBST([MERGELIBS])
15689AC_SUBST([MERGELIBS_MORE])
15690
15691dnl ===================================================================
15692dnl icerun is a wrapper that stops us spawning tens of processes
15693dnl locally - for tools that can't be executed on the compile cluster
15694dnl this avoids a dozen javac's ganging up on your laptop to kill it.
15695dnl ===================================================================
15696AC_MSG_CHECKING([whether to use icerun wrapper])
15697ICECREAM_RUN=
15698if test "$enable_icecream" = "yes" && command -v icerun >/dev/null ; then
15699    ICECREAM_RUN=icerun
15700    AC_MSG_RESULT([yes])
15701else
15702    AC_MSG_RESULT([no])
15703fi
15704AC_SUBST(ICECREAM_RUN)
15705
15706dnl ===================================================================
15707dnl Setup the ICECC_VERSION for the build the same way it was set for
15708dnl configure, so that CC/CXX and ICECC_VERSION are in sync
15709dnl ===================================================================
15710x_ICECC_VERSION=[\#]
15711if test -n "$ICECC_VERSION" ; then
15712    x_ICECC_VERSION=
15713fi
15714AC_SUBST(x_ICECC_VERSION)
15715AC_SUBST(ICECC_VERSION)
15716
15717dnl ===================================================================
15718
15719AC_MSG_CHECKING([MPL subset])
15720MPL_SUBSET=
15721LICENSE="LGPL"
15722
15723if test "$enable_mpl_subset" = "yes"; then
15724    mpl_error_string=
15725    newline=$'\n    *'
15726    warn_report=false
15727    if test "$enable_report_builder" != "no" -a "$with_java" != "no"; then
15728        warn_report=true
15729    elif test "$ENABLE_REPORTBUILDER" = "TRUE"; then
15730        warn_report=true
15731    fi
15732    if test "$warn_report" = "true"; then
15733        mpl_error_string="$mpl_error_string$newline Need to --disable-report-builder - extended database report builder."
15734    fi
15735    if test "x$enable_postgresql_sdbc" != "xno"; then
15736        mpl_error_string="$mpl_error_string$newline Need to --disable-postgresql-sdbc - the PostgreSQL database backend."
15737    fi
15738    if test "$enable_lotuswordpro" = "yes"; then
15739        mpl_error_string="$mpl_error_string$newline Need to --disable-lotuswordpro - a Lotus Word Pro file format import filter."
15740    fi
15741    if test -n "$ENABLE_POPPLER"; then
15742        if test "x$SYSTEM_POPPLER" = "x"; then
15743            mpl_error_string="$mpl_error_string$newline Need to disable PDF import via poppler (--disable-poppler) or use system library."
15744        fi
15745    fi
15746    # cf. m4/libo_check_extension.m4
15747    if test "x$WITH_EXTRA_EXTENSIONS" != "x"; then
15748        mpl_error_string="$mpl_error_string$newline Need to disable extra extensions enabled using --enable-ext-XXXX."
15749    fi
15750    denied_themes=
15751    filtered_themes=
15752    for theme in $WITH_THEMES; do
15753        case $theme in
15754        breeze|breeze_dark|breeze_dark_svg|breeze_svg|elementary|elementary_svg|karasa_jaga|karasa_jaga_svg) #denylist of icon themes under GPL or LGPL
15755            denied_themes="${denied_themes:+$denied_themes }$theme" ;;
15756        *)
15757            filtered_themes="${filtered_themes:+$filtered_themes }$theme" ;;
15758        esac
15759    done
15760    if test "x$denied_themes" != "x"; then
15761        if test "x$filtered_themes" == "x"; then
15762            filtered_themes="colibre"
15763        fi
15764        mpl_error_string="$mpl_error_string$newline Need to disable icon themes: $denied_themes, use --with-theme=$filtered_themes."
15765    fi
15766
15767    ENABLE_OPENGL_TRANSITIONS=
15768
15769    if test "$enable_lpsolve" != "no" -o "x$ENABLE_LPSOLVE" = "xTRUE"; then
15770        mpl_error_string="$mpl_error_string$newline Need to --disable-lpsolve - calc linear programming solver."
15771    fi
15772
15773    if test "x$mpl_error_string" != "x"; then
15774        AC_MSG_ERROR([$mpl_error_string])
15775    fi
15776
15777    MPL_SUBSET="TRUE"
15778    LICENSE="MPL-2.0"
15779    AC_DEFINE(MPL_HAVE_SUBSET)
15780    AC_MSG_RESULT([only])
15781else
15782    AC_MSG_RESULT([no restrictions])
15783fi
15784AC_SUBST(MPL_SUBSET)
15785AC_SUBST(LICENSE)
15786
15787dnl ===================================================================
15788
15789AC_MSG_CHECKING([formula logger])
15790ENABLE_FORMULA_LOGGER=
15791
15792if test "x$enable_formula_logger" = "xyes"; then
15793    AC_MSG_RESULT([yes])
15794    AC_DEFINE(ENABLE_FORMULA_LOGGER)
15795    ENABLE_FORMULA_LOGGER=TRUE
15796elif test -n "$ENABLE_DBGUTIL" ; then
15797    AC_MSG_RESULT([yes])
15798    AC_DEFINE(ENABLE_FORMULA_LOGGER)
15799    ENABLE_FORMULA_LOGGER=TRUE
15800else
15801    AC_MSG_RESULT([no])
15802fi
15803
15804AC_SUBST(ENABLE_FORMULA_LOGGER)
15805
15806dnl ===================================================================
15807dnl Checking for active Antivirus software.
15808dnl ===================================================================
15809
15810if test $_os = WINNT -a -f "$SRC_ROOT/antivirusDetection.vbs" ; then
15811    AC_MSG_CHECKING([for active Antivirus software])
15812    PathFormat "$SRC_ROOT/antivirusDetection.vbs"
15813    ANTIVIRUS_LIST=`cscript.exe //Nologo ${formatted_path}`
15814    if [ [ "$ANTIVIRUS_LIST" != "NULL" ] ]; then
15815        if [ [ "$ANTIVIRUS_LIST" != "NOT_FOUND" ] ]; then
15816            AC_MSG_RESULT([found])
15817            EICAR_STRING='X5O!P%@AP@<:@4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*'
15818            echo $EICAR_STRING > $SRC_ROOT/eicar
15819            EICAR_TEMP_FILE_CONTENTS=`cat $SRC_ROOT/eicar`
15820            rm $SRC_ROOT/eicar
15821            if [ [ "$EICAR_STRING" != "$EICAR_TEMP_FILE_CONTENTS" ] ]; then
15822                AC_MSG_ERROR([Exclude the build and source directories associated with LibreOffice in the following Antivirus software: $ANTIVIRUS_LIST])
15823            fi
15824            echo $EICAR_STRING > $BUILDDIR/eicar
15825            EICAR_TEMP_FILE_CONTENTS=`cat $BUILDDIR/eicar`
15826            rm $BUILDDIR/eicar
15827            if [ [ "$EICAR_STRING" != "$EICAR_TEMP_FILE_CONTENTS" ] ]; then
15828                AC_MSG_ERROR([Exclude the build and source directories associated with LibreOffice in the following Antivirus software: $ANTIVIRUS_LIST])
15829            fi
15830            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"
15831        else
15832            AC_MSG_RESULT([not found])
15833        fi
15834    else
15835        AC_MSG_RESULT([n/a])
15836    fi
15837fi
15838
15839dnl ===================================================================
15840
15841AC_MSG_CHECKING([for coredumpctl support])
15842if test -z "$with_coredumpctl" && test $_os != Linux; then
15843    with_coredumpctl=no
15844fi
15845if test "$with_coredumpctl" = no; then
15846    WITH_COREDUMPCTL=
15847else
15848    AC_PATH_PROG(COREDUMPCTL, coredumpctl)
15849    AC_PATH_PROG(JQ, jq)
15850    AC_PATH_PROG(SYSTEMD_ESCAPE, systemd-escape)
15851    AC_PATH_PROG(SYSTEMD_RUN, systemd-run)
15852    if test -z "$COREDUMPCTL" || test -z "$JQ" || test -z "$SYSTEMD_ESCAPE" \
15853        || test -z "$SYSTEMD_RUN"
15854    then
15855        if test -z "$with_coredumpctl"; then
15856            WITH_COREDUMPCTL=
15857        else
15858            if test -z "$COREDUMPCTL"; then
15859                AC_MSG_ERROR([coredumpctl not found])
15860            fi
15861            if test -z "$JQ"; then
15862                AC_MSG_ERROR([jq not found])
15863            fi
15864            if test -z "$SYSTEMD_ESCAPE"; then
15865                AC_MSG_ERROR([systemd-escape not found])
15866            fi
15867            if test -z "$SYSTEMD_RUN"; then
15868                AC_MSG_ERROR([systemd-run not found])
15869            fi
15870        fi
15871    else
15872        WITH_COREDUMPCTL=TRUE
15873    fi
15874fi
15875if test -z "$WITH_COREDUMPCTL"; then
15876    AC_MSG_RESULT([no])
15877else
15878    AC_MSG_RESULT([yes])
15879fi
15880AC_SUBST(COREDUMPCTL)
15881AC_SUBST(JQ)
15882AC_SUBST(SYSTEMD_ESCAPE)
15883AC_SUBST(SYSTEMD_RUN)
15884AC_SUBST(WITH_COREDUMPCTL)
15885
15886dnl ===================================================================
15887dnl Checking whether to use a keep-awake helper
15888dnl ===================================================================
15889#"
15890AC_MSG_CHECKING([whether to keep the system awake/prevent it from going into sleep/standby])
15891if test -z "$with_keep_awake" -o "$with_keep_awake" = "no"; then
15892    AC_MSG_RESULT([no])
15893elif test "$with_keep_awake" = "yes"; then
15894    AC_MSG_RESULT([yes (autodetect)])
15895    AC_MSG_CHECKING([for a suitable keep-awake command])
15896    if test "$_os" = "WINNT"; then
15897        PathFormat "$(perl.exe -e 'print $ENV{"PROGRAMFILES"}')"
15898        if test -f "$formatted_path_unix/PowerToys/PowerToys.Awake.exe"; then
15899            AC_MSG_RESULT([using "Awake"])
15900            # need to pass the windows-PID to awake, so get the PGID of the shell first to get
15901            # make's PID and then use that to get the windows-PID.
15902            # lots of quoting for both make ($$) as well as configure ('"'"') make that command
15903            # much scarier looking than it actually is. Using make's shell instead of subshells in
15904            # the recipe to keep the command that's echoed by make short.
15905            KEEP_AWAKE_CMD=$formatted_path/PowerToys/PowerToys.Awake.exe' --display-on False --pid $(shell ps | awk '"'"'/^\s+'"'"'$$(ps | awk '"'"'/^\s+'"'"'$$$$'"'"'\s+/{print $$3}'"'"')'"'"'\s+/{print $$4}'"'"') &'
15906        else
15907            AC_MSG_ERROR(["Awake" not found - install Microsoft PowerToys or specify a custom command])
15908        fi
15909    elif test "$_os" = "Darwin"; then
15910        AC_MSG_RESULT([using "caffeinate"])
15911        KEEP_AWAKE_CMD="caffeinate"
15912    else
15913        AC_MSG_ERROR([no default available for $_os, please specify manually])
15914    fi
15915else
15916    AC_MSG_RESULT([yes (custom command: $with_keep_awake)])
15917    KEEP_AWAKE_CMD=$with_keep_awake
15918fi
15919AC_SUBST(KEEP_AWAKE_CMD)
15920
15921dnl =========================================
15922dnl Check for Jom (parallel nmake)
15923dnl =========================================
15924if test "$_os" = "WINNT"; then
15925    AC_MSG_CHECKING([for jom (parallel nmake)])
15926    AC_PATH_PROG([JOM], [jom.exe])
15927    if test -z "$JOM"; then
15928        AC_MSG_NOTICE([jom can help accelerate your build, but is completely optional. Get it from https://wiki.qt.io/Jom])
15929        AC_MSG_NOTICE([and put it in PATH or add JOM=/unix/style/path/to/jom.exe to your autogen.input to use it])
15930    else
15931        PathFormat "$JOM"
15932        JOM="$formatted_path"
15933    fi
15934    AC_SUBST(JOM)
15935fi
15936
15937dnl ===================================================================
15938dnl Setting up the environment.
15939dnl ===================================================================
15940AC_MSG_NOTICE([setting up the build environment variables...])
15941
15942AC_SUBST(COMPATH)
15943
15944if test "$build_os" = "cygwin" -o "$build_os" = wsl -o -n "$WSL_ONLY_AS_HELPER"; then
15945    if test -d "$COMPATH_unix/atlmfc/lib/spectre"; then
15946        ATL_LIB="$COMPATH/atlmfc/lib/spectre"
15947        ATL_INCLUDE="$COMPATH/atlmfc/include"
15948    elif test -d "$COMPATH_unix/atlmfc/lib"; then
15949        ATL_LIB="$COMPATH/atlmfc/lib"
15950        ATL_INCLUDE="$COMPATH/atlmfc/include"
15951    else
15952        ATL_LIB="$WINDOWS_SDK_HOME/lib" # Doesn't exist for VSE
15953        ATL_INCLUDE="$WINDOWS_SDK_HOME/include/atl"
15954    fi
15955    ATL_LIB="$ATL_LIB/$WIN_HOST_ARCH"
15956    ATL_LIB=`win_short_path_for_make "$ATL_LIB"`
15957    ATL_INCLUDE=`win_short_path_for_make "$ATL_INCLUDE"`
15958fi
15959
15960if test "$build_os" = "cygwin"; then
15961    # sort.exe and find.exe also exist in C:/Windows/system32 so need /usr/bin/
15962    PathFormat "/usr/bin/find.exe"
15963    FIND="$formatted_path"
15964    PathFormat "/usr/bin/sort.exe"
15965    SORT="$formatted_path"
15966    PathFormat "/usr/bin/grep.exe"
15967    WIN_GREP="$formatted_path"
15968    PathFormat "/usr/bin/ls.exe"
15969    WIN_LS="$formatted_path"
15970    PathFormat "/usr/bin/touch.exe"
15971    WIN_TOUCH="$formatted_path"
15972else
15973    FIND=find
15974    SORT=sort
15975fi
15976
15977AC_SUBST(ATL_INCLUDE)
15978AC_SUBST(ATL_LIB)
15979AC_SUBST(FIND)
15980AC_SUBST(SORT)
15981AC_SUBST(WIN_GREP)
15982AC_SUBST(WIN_LS)
15983AC_SUBST(WIN_TOUCH)
15984
15985AC_SUBST(BUILD_TYPE)
15986
15987AC_SUBST(SOLARINC)
15988
15989PathFormat "$PERL"
15990PERL="$formatted_path"
15991AC_SUBST(PERL)
15992
15993if test -n "$TMPDIR"; then
15994    TEMP_DIRECTORY="$TMPDIR"
15995    if test -n "$WSL_ONLY_AS_HELPER"; then
15996       TEMP_DIRECTORY=$(wslpath -m "$TEMP_DIRECTORY")
15997    fi
15998else
15999    TEMP_DIRECTORY="/tmp"
16000fi
16001CYGWIN_BASH="C:/cygwin64/bin/bash.exe"
16002if test "$build_os" = "cygwin"; then
16003    TEMP_DIRECTORY=`cygpath -m "$TEMP_DIRECTORY"`
16004    CYGWIN_BASH=`cygpath -m /usr/bin/bash`
16005fi
16006AC_SUBST(TEMP_DIRECTORY)
16007AC_SUBST(CYGWIN_BASH)
16008
16009# setup the PATH for the environment
16010if test -n "$LO_PATH_FOR_BUILD"; then
16011    LO_PATH="$LO_PATH_FOR_BUILD"
16012    case "$host_os" in
16013    cygwin*|wsl*)
16014        pathmunge "$MSVC_HOST_PATH" "before"
16015        ;;
16016    esac
16017else
16018    LO_PATH="$PATH"
16019
16020    case "$host_os" in
16021
16022    dragonfly*|freebsd*|linux-gnu*|*netbsd*|openbsd*)
16023        if test "$ENABLE_JAVA" != ""; then
16024            pathmunge "$JAVA_HOME/bin" "after"
16025        fi
16026        ;;
16027
16028    cygwin*|wsl*)
16029        # Win32 make needs native paths
16030        if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
16031            LO_PATH=`cygpath -p -m "$PATH"`
16032        fi
16033        if test "$WIN_BUILD_ARCH" = "x64"; then
16034            # needed for msi packaging
16035            pathmunge "$WINDOWS_SDK_BINDIR_NO_ARCH/x86" "before"
16036        fi
16037        if test "$WIN_BUILD_ARCH" = "arm64"; then
16038            # needed for msi packaging - as of 10.0.22621 SDK no arm64 ones yet
16039            pathmunge "$WINDOWS_SDK_BINDIR_NO_ARCH/x86" "before"
16040        fi
16041        # .NET 4.6 and higher don't have bin directory
16042        if test -f "$DOTNET_FRAMEWORK_HOME/bin"; then
16043            pathmunge "$DOTNET_FRAMEWORK_HOME/bin" "before"
16044        fi
16045        pathmunge "$WINDOWS_SDK_HOME/bin" "before"
16046        pathmunge "$CSC_PATH" "before"
16047        pathmunge "$MIDL_PATH" "before"
16048        pathmunge "$AL_PATH" "before"
16049        pathmunge "$MSVC_MULTI_PATH" "before"
16050        pathmunge "$MSVC_BUILD_PATH" "before"
16051        if test -n "$MSBUILD_PATH" ; then
16052            pathmunge "$MSBUILD_PATH" "before"
16053        fi
16054        pathmunge "$WINDOWS_SDK_BINDIR_NO_ARCH/$WIN_BUILD_ARCH" "before"
16055        if test "$ENABLE_JAVA" != ""; then
16056            if test -d "$JAVA_HOME/jre/bin/client"; then
16057                pathmunge "$JAVA_HOME/jre/bin/client" "before"
16058            fi
16059            if test -d "$JAVA_HOME/jre/bin/hotspot"; then
16060                pathmunge "$JAVA_HOME/jre/bin/hotspot" "before"
16061            fi
16062            pathmunge "$JAVA_HOME/bin" "before"
16063        fi
16064        pathmunge "$MSVC_HOST_PATH" "before"
16065        ;;
16066
16067    solaris*)
16068        pathmunge "/usr/css/bin" "before"
16069        if test "$ENABLE_JAVA" != ""; then
16070            pathmunge "$JAVA_HOME/bin" "after"
16071        fi
16072        ;;
16073    esac
16074fi
16075
16076AC_SUBST(LO_PATH)
16077
16078# Allow to pass LO_ELFCHECK_ALLOWLIST from autogen.input to bin/check-elf-dynamic-objects:
16079if test "$LO_ELFCHECK_ALLOWLIST" = x || test "${LO_ELFCHECK_ALLOWLIST-x}" != x; then
16080    x_LO_ELFCHECK_ALLOWLIST=
16081else
16082    x_LO_ELFCHECK_ALLOWLIST=[\#]
16083fi
16084AC_SUBST(x_LO_ELFCHECK_ALLOWLIST)
16085AC_SUBST(LO_ELFCHECK_ALLOWLIST)
16086
16087libo_FUZZ_SUMMARY
16088
16089# Generate a configuration sha256 we can use for deps
16090if test -f config_host.mk; then
16091    config_sha256=`$SHA256SUM config_host.mk | sed "s/ .*//"`
16092fi
16093if test -f config_host_lang.mk; then
16094    config_lang_sha256=`$SHA256SUM config_host_lang.mk | sed "s/ .*//"`
16095fi
16096
16097CFLAGS=$my_original_CFLAGS
16098CXXFLAGS=$my_original_CXXFLAGS
16099CPPFLAGS=$my_original_CPPFLAGS
16100
16101AC_CONFIG_LINKS([include:include])
16102
16103if test -n "$WSL_ONLY_AS_HELPER"; then
16104    # while we configure in linux, we actually compile in "cygwin" (close enough at least)
16105    build=$host
16106    PathFormat "$SRC_ROOT"
16107    SRC_ROOT="$formatted_path"
16108    PathFormat "$BUILDDIR"
16109    BUILDDIR="$formatted_path"
16110    # git-bash has (gnu) tar, curl and sha256sum
16111    CURL="curl.exe"
16112    WGET=
16113    GNUTAR="tar.exe"
16114    SHA256SUM="sha256sum.exe"
16115    COMPRESSIONTOOL="/usr/bin/gzip"
16116    # TODO: maybe switch to strawberry-perl right away?
16117    # only openssl seems to actually require it (for Pod/Usage.pm and maybe more)
16118    PERL="perl.exe"
16119    # use flex, gperf and nasm from wsl-container
16120    # if using absolute path, would need to use double-leading slash for the msys path mangling
16121    FLEX="$WSL $FLEX"
16122    NASM="$WSL $NASM"
16123    # some externals (libebook) check for it with AC_PATH_PROGS, and that only accepts overrides
16124    # with an absolute path/requires the value to begin with a slash
16125    GPERF="/c/Windows/system32/$WSL gperf"
16126    # append strawberry tools dir to PATH (for e.g. windres, ar)
16127    LO_PATH="$LO_PATH:$STRAWBERRY_TOOLS"
16128    # temp-dir needs to be in windows realm, hardcode for now
16129    if test "$TEMP_DIRECTORY" = /tmp; then
16130        mkdir -p tmp
16131        TEMP_DIRECTORY="$BUILDDIR/tmp"
16132    fi
16133fi
16134
16135# Keep in sync with list of files far up, at AC_MSG_CHECKING([for
16136# BUILD platform configuration] - otherwise breaks cross building
16137AC_CONFIG_FILES([
16138                 config_host_lang.mk
16139                 Makefile
16140                 bin/bffvalidator.sh
16141                 bin/odfvalidator.sh
16142                 bin/officeotron.sh
16143                 instsetoo_native/util/openoffice.lst
16144                 sysui/desktop/macosx/Info.plist
16145                 sysui/desktop/macosx/LaunchConstraint.plist
16146                 hardened_runtime.xcent:sysui/desktop/macosx/hardened_runtime.xcent.in
16147                 lo.xcent:sysui/desktop/macosx/lo.xcent.in
16148                 extensions/source/macosx/quicklookpreview/appex/Info.plist
16149                 extensions/source/macosx/quicklookthumbnail/appex/Info.plist
16150                 ])
16151# map unix-style mount dirs to windows directories: /mnt/c/foobar -> C:/foobar
16152# easier to do it in a postprocessing command than to modify every single variable
16153AC_CONFIG_FILES([config_host.mk], [
16154    if test -n "$WSL_ONLY_AS_HELPER"; then
16155        sed -i -e 's#/mnt/\([[:alpha:]]\)/#\u\1:/#g' config_host.mk
16156    fi], [WSL_ONLY_AS_HELPER=$WSL_ONLY_AS_HELPER])
16157# also use windows paths in the vs-code workspace file (esp. for the launch configurations that use
16158# INSTROOT) and also change the default shell from Cygwin to Git Bash
16159AC_CONFIG_FILES([vs-code.code-workspace.template:.vscode/vs-code-template.code-workspace.in], [
16160    if test -n "$WSL_ONLY_AS_HELPER"; then
16161        sed -i -e 's#/mnt/\([[:alpha:]]\)/#\u\1:/#g' \
16162               -e '/defaultProfile/s#Cygwin#Git Bash#' vs-code.code-workspace.template
16163    fi], [WSL_ONLY_AS_HELPER=$WSL_ONLY_AS_HELPER])
16164
16165AC_CONFIG_HEADERS([config_host/config_atspi.h])
16166AC_CONFIG_HEADERS([config_host/config_buildconfig.h])
16167AC_CONFIG_HEADERS([config_host/config_buildid.h])
16168AC_CONFIG_HEADERS([config_host/config_box2d.h])
16169AC_CONFIG_HEADERS([config_host/config_clang.h])
16170AC_CONFIG_HEADERS([config_host/config_cpdb.h])
16171AC_CONFIG_HEADERS([config_host/config_crypto.h])
16172AC_CONFIG_HEADERS([config_host/config_cups.h])
16173AC_CONFIG_HEADERS([config_host/config_dconf.h])
16174AC_CONFIG_HEADERS([config_host/config_eot.h])
16175AC_CONFIG_HEADERS([config_host/config_extensions.h])
16176AC_CONFIG_HEADERS([config_host/config_cairo_canvas.h])
16177AC_CONFIG_HEADERS([config_host/config_cairo_rgba.h])
16178AC_CONFIG_HEADERS([config_host/config_collab.h])
16179AC_CONFIG_HEADERS([config_host/config_cxxabi.h])
16180AC_CONFIG_HEADERS([config_host/config_dbus.h])
16181AC_CONFIG_HEADERS([config_host/config_emscripten.h])
16182AC_CONFIG_HEADERS([config_host/config_features.h])
16183AC_CONFIG_HEADERS([config_host/config_feature_desktop.h])
16184AC_CONFIG_HEADERS([config_host/config_feature_opencl.h])
16185AC_CONFIG_HEADERS([config_host/config_firebird.h])
16186AC_CONFIG_HEADERS([config_host/config_folders.h])
16187AC_CONFIG_HEADERS([config_host/config_fonts.h])
16188AC_CONFIG_HEADERS([config_host/config_fuzzers.h])
16189AC_CONFIG_HEADERS([config_host/config_gio.h])
16190AC_CONFIG_HEADERS([config_host/config_global.h])
16191AC_CONFIG_HEADERS([config_host/config_gpgme.h])
16192AC_CONFIG_HEADERS([config_host/config_java.h])
16193AC_CONFIG_HEADERS([config_host/config_langs.h])
16194AC_CONFIG_HEADERS([config_host/config_lgpl.h])
16195AC_CONFIG_HEADERS([config_host/config_libcxx.h])
16196AC_CONFIG_HEADERS([config_host/config_liblangtag.h])
16197AC_CONFIG_HEADERS([config_host/config_locales.h])
16198AC_CONFIG_HEADERS([config_host/config_mpl.h])
16199AC_CONFIG_HEADERS([config_host/config_oox.h])
16200AC_CONFIG_HEADERS([config_host/config_options.h])
16201AC_CONFIG_HEADERS([config_host/config_options_calc.h])
16202AC_CONFIG_HEADERS([config_host/config_zxing.h])
16203AC_CONFIG_HEADERS([config_host/config_skia.h])
16204AC_CONFIG_HEADERS([config_host/config_typesizes.h])
16205AC_CONFIG_HEADERS([config_host/config_validation.h])
16206AC_CONFIG_HEADERS([config_host/config_vendor.h])
16207AC_CONFIG_HEADERS([config_host/config_vclplug.h])
16208AC_CONFIG_HEADERS([config_host/config_version.h])
16209AC_CONFIG_HEADERS([config_host/config_oauth2.h])
16210AC_CONFIG_HEADERS([config_host/config_poppler.h])
16211AC_CONFIG_HEADERS([config_host/config_python.h])
16212AC_CONFIG_HEADERS([config_host/config_writerperfect.h])
16213AC_CONFIG_HEADERS([config_host/config_wasm_strip.h])
16214AC_CONFIG_HEADERS([solenv/lockfile/autoconf.h])
16215AC_OUTPUT
16216
16217if test "$CROSS_COMPILING" = TRUE; then
16218    (echo; echo export BUILD_TYPE_FOR_HOST=$BUILD_TYPE) >>config_build.mk
16219fi
16220
16221# touch the config timestamp file
16222if test ! -f config_host.mk.stamp; then
16223    echo > config_host.mk.stamp
16224elif test "$config_sha256" = `$SHA256SUM config_host.mk | sed "s/ .*//"`; then
16225    echo "Host Configuration unchanged - avoiding scp2 stamp update"
16226else
16227    echo > config_host.mk.stamp
16228fi
16229
16230# touch the config lang timestamp file
16231if test ! -f config_host_lang.mk.stamp; then
16232    echo > config_host_lang.mk.stamp
16233elif test "$config_lang_sha256" = `$SHA256SUM config_host_lang.mk | sed "s/ .*//"`; then
16234    echo "Language Configuration unchanged - avoiding scp2 stamp update"
16235else
16236    echo > config_host_lang.mk.stamp
16237fi
16238
16239
16240if test \( "$STALE_MAKE" = "TRUE" \) \
16241        -a "$build_os" = "cygwin"; then
16242
16243cat << _EOS
16244****************************************************************************
16245WARNING:
16246Your make version is known to be horribly slow, and hard to debug
16247problems with. To get a reasonably functional make please do:
16248
16249to install a pre-compiled binary make for Win32
16250
16251 mkdir -p /opt/lo/bin
16252 cd /opt/lo/bin
16253 wget https://dev-www.libreoffice.org/bin/cygwin/make-4.2.1-msvc.exe
16254 cp make-4.2.1-msvc.exe make
16255 chmod +x make
16256
16257to install from source:
16258place yourself in a working directory of you choice.
16259
16260 git clone git://git.savannah.gnu.org/make.git
16261
16262 [go to Start menu, open "Visual Studio 2019" or "Visual Studio 2022", and then click "x86 Native Tools Command Prompt" or "x64 Native Tools Command Prompt"]
16263 set PATH=%PATH%;C:\Cygwin\bin
16264 [or Cygwin64, if that is what you have]
16265 cd path-to-make-repo-you-cloned-above
16266 build_w32.bat --without-guile
16267
16268should result in a WinRel/gnumake.exe.
16269Copy it to the Cygwin /opt/lo/bin directory as make.exe
16270
16271Then re-run autogen.sh
16272
16273Note: autogen.sh will try to use /opt/lo/bin/make if the environment variable GNUMAKE is not already defined.
16274Alternatively, you can install the 'new' make where ever you want and make sure that `command -v make` finds it.
16275
16276_EOS
16277fi
16278
16279
16280cat << _EOF
16281****************************************************************************
16282
16283To show information on various make targets and make flags, run:
16284$GNUMAKE help
16285
16286To just build, run:
16287$GNUMAKE
16288
16289_EOF
16290
16291if test $_os != WINNT -a "$CROSS_COMPILING" != TRUE; then
16292    cat << _EOF
16293After the build has finished successfully, you can immediately run what you built using the command:
16294_EOF
16295
16296    if test $_os = Darwin; then
16297        echo open instdir/$PRODUCTNAME_WITHOUT_SPACES.app
16298    else
16299        echo instdir/program/soffice
16300    fi
16301    cat << _EOF
16302
16303If you want to run the unit tests, run:
16304$GNUMAKE check
16305
16306_EOF
16307fi
16308
16309if test -s "$WARNINGS_FILE_FOR_BUILD"; then
16310    echo "BUILD / cross-toolset config, repeated ($WARNINGS_FILE_FOR_BUILD)"
16311    cat "$WARNINGS_FILE_FOR_BUILD"
16312    echo
16313fi
16314
16315if test -s "$WARNINGS_FILE"; then
16316    echo "HOST config ($WARNINGS_FILE)"
16317    cat "$WARNINGS_FILE"
16318fi
16319
16320# Remove unneeded emconfigure artifacts
16321rm -f a.out a.wasm a.out.js a.out.wasm
16322
16323dnl cspell:ignore Randr Xext alignof altlinuxhyph appex bzlib ccached coreutils createmsi cxxabi
16324dnl cspell:ignore cygdrive devel devenv dlsym dtrace emconfigure fpch frobozz gnucp gpgconf gpgme
16325dnl cspell:ignore gpgmepp ifdef ifndef libc libdl libjpipe libstdc longjmp memcpy mscoree msicreator
16326dnl cspell:ignore msiglobal mspdb msys nmake omindex optimised pagein pkgmk qconfig qtbase
16327dnl cspell:ignore quadrigraph rbbi rpms sccache strbuf stringop tosvg ucrt ustring uuidgen vclplugs
16328dnl cspell:ignore vswhere werror wilangid xcent xcrun
16329
16330dnl vim:set shiftwidth=4 softtabstop=4 expandtab:
16331