xref: /core/configure.ac (revision 5bf58785)
1dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; fill-column: 100 -*-
2dnl configure.ac serves as input for the GNU autoconf package
3dnl in order to create a configure script.
4
5# The version number in the second argument to AC_INIT should be four numbers separated by
6# periods. Some parts of the code requires the first one to be less than 128 and the others to be less
7# than 256. The four numbers can optionally be followed by a period and a free-form string containing
8# no spaces or periods, like "frobozz-mumble-42" or "alpha0". If the free-form string ends with one or
9# several non-alphanumeric characters, those are split off and used only for the
10# ABOUTBOXPRODUCTVERSIONSUFFIX in openoffice.lst. Why that is necessary, no idea.
11
12AC_INIT([LibreOffice],[25.2.0.0.alpha0+],[],[],[http://documentfoundation.org/])
13
14dnl libnumbertext needs autoconf 2.68, but that can pick up autoconf268 just fine if it is installed
15dnl whereas aclocal (as run by autogen.sh) insists on using autoconf and fails hard
16dnl so check for the version of autoconf that is actually used to create the configure script
17AC_PREREQ([2.59])
18m4_if(m4_version_compare(m4_defn([AC_AUTOCONF_VERSION]), [2.68]), -1,
19    [AC_MSG_ERROR([at least autoconf version 2.68 is needed (you can use AUTOCONF environment variable to point to a suitable one)])])
20
21if test -n "$BUILD_TYPE"; then
22    AC_MSG_ERROR([You have sourced config_host.mk in this shell.  This may lead to trouble, please run in a fresh (login) shell.])
23fi
24
25save_CC=$CC
26save_CXX=$CXX
27
28first_arg_basename()
29{
30    for i in $1; do
31        basename "$i"
32        break
33    done
34}
35
36CC_BASE=`first_arg_basename "$CC"`
37CXX_BASE=`first_arg_basename "$CXX"`
38
39BUILD_TYPE="LibO"
40SCPDEFS=""
41GIT_NEEDED_SUBMODULES=""
42LO_PATH= # used by path_munge to construct a PATH variable
43
44
45FilterLibs()
46{
47    # Return value: $filteredlibs
48
49    filteredlibs=
50    if test "$COM" = "MSC"; then
51        for f in $1; do
52            if test "x$f" != "x${f#-L}"; then
53                filteredlibs="$filteredlibs -LIBPATH:${f:2}"
54            elif test "x$f" != "x${f#-l}"; then
55                filteredlibs="$filteredlibs ${f:2}.lib"
56            else
57                filteredlibs="$filteredlibs $f"
58            fi
59        done
60    else
61        for f in $1; do
62            case "$f" in
63                # let's start with Fedora's paths for now
64                -L/lib|-L/lib/|-L/lib64|-L/lib64/|-L/usr/lib|-L/usr/lib/|-L/usr/lib64|-L/usr/lib64/)
65                    # ignore it: on UNIXoids it is searched by default anyway
66                    # but if it's given explicitly then it may override other paths
67                    # (on macOS it would be an error to use it instead of SDK)
68                    ;;
69                *)
70                    filteredlibs="$filteredlibs $f"
71                    ;;
72            esac
73        done
74    fi
75}
76
77PathFormat()
78{
79    # Args: $1: A pathname. On Cygwin and WSL, in either the Unix or the Windows format. Note that this
80    # function is called also on Unix.
81    #
82    # Return value: $formatted_path and $formatted_path_unix.
83    #
84    # $formatted_path is the argument in Windows format, but using forward slashes instead of
85    # backslashes, using 8.3 pathname components if necessary (if it otherwise would contains spaces
86    # or shell metacharacters).
87    #
88    # $formatted_path_unix is the argument in a form usable in Cygwin or WSL, using 8.3 components if
89    # necessary. On Cygwin, it is the same as $formatted_path, but on WSL it is $formatted_path as a
90    # Unix pathname.
91    #
92    # Errors out if 8.3 names are needed but aren't present for some of the path components.
93
94    # Examples:
95    #
96    # /home/tml/lo/master-optimised => C:/cygwin64/home/tml/lo/master-optimised
97    #
98    # C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe => C:/PROGRA~2/MICROS~3/INSTAL~1/vswhere.exe
99    #
100    # C:\Program Files (x86)\Microsoft Visual Studio\2019\Community => C:/PROGRA~2/MICROS~3/2019/COMMUN~1
101    #
102    # C:/PROGRA~2/WI3CF2~1/10/Include/10.0.18362.0/ucrt => C:/PROGRA~2/WI3CF2~1/10/Include/10.0.18362.0/ucrt
103    #
104    # /cygdrive/c/PROGRA~2/WI3CF2~1/10 => C:/PROGRA~2/WI3CF2~1/10
105    #
106    # C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\ => C:/PROGRA~2/WI3CF2~1/NETFXSDK/4.8/
107    #
108    # /usr/bin/find.exe => C:/cygwin64/bin/find.exe
109
110    if test -n "$UNITTEST_WSL_PATHFORMAT"; then
111        printf "PathFormat $1 ==> "
112    fi
113
114    formatted_path="$1"
115    if test "$build_os" = "cygwin" -o "$build_os" = "wsl"; then
116        if test "$build_os" = "wsl"; then
117            formatted_path=$(echo "$formatted_path" | tr -d '\r')
118        fi
119
120        pf_conv_to_dos=
121        # spaces,parentheses,brackets,braces are problematic in pathname
122        # so are backslashes
123        case "$formatted_path" in
124            *\ * | *\)* | *\(* | *\{* | *\}* | *\[* | *\]* | *\\* )
125                pf_conv_to_dos="yes"
126            ;;
127        esac
128        if test "$pf_conv_to_dos" = "yes"; then
129            if test "$build_os" = "wsl"; then
130                case "$formatted_path" in
131                    /*)
132                        formatted_path=$(wslpath -w "$formatted_path")
133                        ;;
134                esac
135                formatted_path=$($WSL_LO_HELPER --8.3 "$formatted_path")
136            elif test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
137                formatted_path=`cygpath -sm "$formatted_path"`
138            else
139                formatted_path=`cygpath -d "$formatted_path"`
140            fi
141            if test $? -ne 0;  then
142                AC_MSG_ERROR([path conversion failed for "$1".])
143            fi
144        fi
145        fp_count_colon=`echo "$formatted_path" | $GREP -c "[:]"`
146        fp_count_slash=`echo "$formatted_path" | $GREP -c "[/]"`
147        if test "$fp_count_slash$fp_count_colon" != "00"; then
148            if test "$fp_count_colon" = "0"; then
149                new_formatted_path=`realpath "$formatted_path"`
150                if test $? -ne 0;  then
151                    AC_MSG_WARN([realpath failed for "$formatted_path", not necessarily a problem.])
152                else
153                    formatted_path="$new_formatted_path"
154                fi
155            fi
156            if test "$build_os" = "wsl"; then
157                if test "$fp_count_colon" != "0"; then
158                    formatted_path=$(wslpath "$formatted_path")
159                    local final_slash=
160                    case "$formatted_path" in
161                        */)
162                            final_slash=/
163                            ;;
164                    esac
165                    formatted_path=$(wslpath -m $formatted_path)
166                    case "$formatted_path" in
167                        */)
168                            ;;
169                        *)
170                            formatted_path="$formatted_path"$final_slash
171                            ;;
172                    esac
173                else
174                    formatted_path=$(wslpath -m "$formatted_path")
175                fi
176            else
177                formatted_path=`cygpath -m "$formatted_path"`
178            fi
179            if test $? -ne 0;  then
180                AC_MSG_ERROR([path conversion failed for "$1".])
181            fi
182        fi
183        fp_count_space=`echo "$formatted_path" | $GREP -c "[ ]"`
184        if test "$fp_count_space" != "0"; then
185            AC_MSG_ERROR([converted path "$formatted_path" still contains spaces. Short filenames (8.3 filenames) support was disabled on this system?])
186        fi
187    fi
188    if test "$build_os" = "wsl"; then
189        # WSL can't run Windows binaries from Windows pathnames so we need a separate return value in Unix format
190        formatted_path_unix=$(wslpath "$formatted_path")
191    else
192        # But Cygwin can
193        formatted_path_unix="$formatted_path"
194    fi
195    if test -n "$WSL_ONLY_AS_HELPER"; then
196        # if already in unix format, switch to windows format to create shortened path
197        case "$formatted_path" in
198            /*)
199                formatted_path=$(wslpath -m "$formatted_path")
200                ;;
201        esac
202
203        # cd to /mnt/c to avoid wsl/cmd complaining about not supporting UNC paths/the current working directory
204        formatted_path_unix=$(wslpath -u "$(cd /mnt/c; cmd.exe /c $shortpath_cmd "$formatted_path" | tr -d '\r')")
205        # WSL can't run Windows binaries from Windows pathnames so we need a separate return value in Unix format
206        formatted_path=$(wslpath -m "$formatted_path_unix")
207    fi
208}
209
210AbsolutePath()
211{
212    # There appears to be no simple and portable method to get an absolute and
213    # canonical path, so we try creating the directory if does not exist and
214    # utilizing the shell and pwd.
215
216    # Args: $1: A possibly relative pathname
217    # Return value: $absolute_path
218
219    # Convert to unix path, mkdir would treat c:/path as a relative path.
220    PathFormat "$1"
221    local rel="$formatted_path_unix"
222    absolute_path=""
223    test ! -e "$rel" && mkdir -p "$rel"
224    if test -d "$rel" ; then
225        cd "$rel" || AC_MSG_ERROR([absolute path resolution failed for "$rel".])
226        absolute_path="$(pwd)"
227        cd - > /dev/null
228    else
229        AC_MSG_ERROR([Failed to resolve absolute path.  "$rel" does not exist or is not a directory.])
230    fi
231}
232
233WARNINGS_FILE=config.warn
234WARNINGS_FILE_FOR_BUILD=config.Build.warn
235rm -f "$WARNINGS_FILE" "$WARNINGS_FILE_FOR_BUILD"
236have_WARNINGS="no"
237add_warning()
238{
239    if test "$have_WARNINGS" = "no"; then
240        echo "*************************************" > "$WARNINGS_FILE"
241        have_WARNINGS="yes"
242        if command -v tput >/dev/null && test "`tput colors 2>/dev/null || echo 0`" -ge 8; then
243            dnl <esc> as actual byte (U+1b), [ escaped using quadrigraph @<:@
244            COLORWARN='*@<:@1;33;40m WARNING @<:@0m:'
245        else
246            COLORWARN="* WARNING :"
247        fi
248    fi
249    echo "$COLORWARN $@" >> "$WARNINGS_FILE"
250}
251
252dnl Some Mac User have the bad habit of letting a lot of crap
253dnl accumulate in their PATH and even adding stuff in /usr/local/bin
254dnl that confuse the build.
255dnl For the ones that use LODE, let's be nice and protect them
256dnl from themselves
257
258mac_sanitize_path()
259{
260    mac_path="$LODE_HOME/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin"
261dnl a common but nevertheless necessary thing that may be in a fancy
262dnl path location is git, so make sure we have it
263    mac_git_path=`command -v git`
264    if test -n "$mac_git_path" -a -x "$mac_git_path" -a "$mac_git_path" != "/usr/bin/git" ; then
265        mac_path="$mac_path:`dirname $mac_git_path`"
266    fi
267dnl a not so common but nevertheless quite helpful thing that may be in a fancy
268dnl path location is gpg, so make sure we find it
269    mac_gpg_path=`command -v gpg`
270    if test -n "$mac_gpg_path" -a -x "$mac_gpg_path" -a "$mac_gpg_path" != "/usr/bin/gpg" ; then
271        mac_path="$mac_path:`dirname $mac_gpg_path`"
272    fi
273    PATH="$mac_path"
274    unset mac_path
275    unset mac_git_path
276    unset mac_gpg_path
277}
278
279dnl semantically test a three digits version
280dnl $1 - $3 = minimal version
281dnl $4 - $6 = current version
282
283check_semantic_version_three()
284{
285    test "$4" -gt "$1" \
286        -o \( "$4" -eq "$1" -a "$5" -gt "$2" \) \
287        -o \( "$4" -eq "$1" -a "$5" -eq "$2" -a "$6" -ge "$3" \)
288    return $?
289}
290
291dnl calls check_semantic_version_three with digits in named variables $1_MAJOR, $1_MINOR, $1_TINY
292dnl $1 = current version prefix, e.g. EMSCRIPTEN => EMSCRIPTEN_
293dnl $2 = postfix to $1, e.g. MIN => EMSCRIPTEN_MIN_
294
295check_semantic_version_three_prefixed()
296{
297    eval local MIN_MAJOR="\$${1}_${2}_MAJOR"
298    eval local MIN_MINOR="\$${1}_${2}_MINOR"
299    eval local MIN_TINY="\$${1}_${2}_TINY"
300    eval local CUR_MAJOR="\$${1}_MAJOR"
301    eval local CUR_MINOR="\$${1}_MINOR"
302    eval local CUR_TINY="\$${1}_TINY"
303    check_semantic_version_three $MIN_MAJOR $MIN_MINOR $MIN_TINY $CUR_MAJOR $CUR_MINOR $CUR_TINY
304    return $?
305}
306
307echo "********************************************************************"
308echo "*"
309echo "*   Running ${PACKAGE_NAME} build configuration."
310echo "*"
311echo "********************************************************************"
312echo ""
313
314dnl ===================================================================
315dnl checks build and host OSes
316dnl do this before argument processing to allow for platform dependent defaults
317dnl ===================================================================
318
319# are we running in wsl but are called from git-bash/env with mingw64 in path?
320# if so, we aim to run nearly everything in the Windows realm, and only run autogen/configure
321# in wsl and run a few tools via wsl
322WSL_ONLY_AS_HELPER=
323if test -n "$WSL_DISTRO_NAME" && $(echo $PATH |grep -q mingw64); then
324    WSL_ONLY_AS_HELPER=TRUE
325    AC_ARG_WITH([strawberry-perl-portable],
326        [AS_HELP_STRING([--with-strawberry-perl-portable],
327            [Specify the base path to strawberry perl portable])],
328        [],
329        [AC_MSG_ERROR(
330            [for the moment strawberry-perl-portable is a requirement, feel free to replace it])])
331    shortpath_cmd=$(wslpath -m $srcdir/solenv/bin/shortpath.cmd)
332    PathFormat "$with_strawberry_perl_portable"
333    if test ! -f "$formatted_path_unix/perl/bin/perl.exe" -o ! -d "$formatted_path_unix/c/bin"; then
334        AC_MSG_ERROR([$formatted_path doesn't contain perl or the utilities - sure you provided the base path?])
335    fi
336    STRAWBERRY_TOOLS="$formatted_path/c/bin"
337    STRAWBERRY_PERL="$formatted_path/perl/bin/perl.exe"
338    AC_ARG_WITH([wsl-command],
339        [AS_HELP_STRING([--with-wsl-command],
340            [Specify your wsl distro command if it isn't the default/the one used with just wsl.exe341             for example: wsl.exe -d MyDistro -u NonDefaultUser])],
342        [],
343        [with_wsl_command="wsl.exe"])
344    WSL="$with_wsl_command"
345fi
346AC_SUBST([STRAWBERRY_PERL])
347AC_SUBST([WSL])
348
349# Check for WSL (version 2, at least). But if --host is explicitly specified (to really do build for
350# Linux on WSL) trust that.
351if test -z "$host" -a -z "$build" -a "`wslsys -v 2>/dev/null`" != ""; then
352    ac_cv_host="x86_64-pc-wsl"
353    ac_cv_host_cpu="x86_64"
354    ac_cv_host_os="wsl"
355    ac_cv_build="$ac_cv_host"
356    ac_cv_build_cpu="$ac_cv_host_cpu"
357    ac_cv_build_os="$ac_cv_host_os"
358
359    # Emulation of Cygwin's cygpath command for WSL.
360    cygpath()
361    {
362        if test -n "$UNITTEST_WSL_CYGPATH"; then
363            echo -n cygpath "$@" "==> "
364        fi
365
366        # Cygwin's real cygpath has a plethora of options but we use only a few here.
367        local args="$@"
368        local opt
369        local opt_d opt_m opt_u opt_w opt_l opt_s opt_p
370        OPTIND=1
371
372        while getopts dmuwlsp opt; do
373            case "$opt" in
374                \?)
375                    AC_MSG_ERROR([Unimplemented cygpath emulation option in invocation: cygpath $args])
376                    ;;
377                ?)
378                    eval opt_$opt=yes
379                    ;;
380            esac
381        done
382
383        shift $((OPTIND-1))
384
385        if test $# -ne 1; then
386            AC_MSG_ERROR([Invalid cygpath emulation invocation: Pathname missing]);
387        fi
388
389        local input="$1"
390
391        local result
392
393        if test -n "$opt_d" -o -n "$opt_m" -o -n "$opt_w"; then
394            # Print Windows path, possibly in 8.3 form (-d) or with forward slashes (-m)
395
396            if test -n "$opt_u"; then
397                AC_MSG_ERROR([Invalid cygpath invocation: Both Windows and Unix path output requested])
398            fi
399
400            case "$input" in
401                /mnt/*)
402                    # A Windows file in WSL format
403                    input=$(wslpath -w "$input")
404                    ;;
405                [[a-zA-Z]]:\\* | \\* | [[a-zA-Z]]:/* | /*)
406                    # Already in Windows format
407                    ;;
408                /*)
409                    input=$(wslpath -w "$input")
410                    ;;
411                *)
412                    AC_MSG_ERROR([Invalid cygpath invocation: Path '$input' is not absolute])
413                    ;;
414            esac
415            if test -n "$opt_d" -o -n "$opt_s"; then
416                input=$($WSL_LO_HELPER --8.3 "$input")
417            fi
418            if test -n "$opt_m"; then
419                input="${input//\\//}"
420            fi
421            echo "$input"
422        else
423            # Print Unix path
424
425            case "$input" in
426                [[a-zA-Z]]:\\* | \\* | [[a-zA-Z]]:/* | /*)
427                    wslpath -u "$input"
428                    ;;
429                /)
430                    echo "$input"
431                    ;;
432                *)
433                    AC_MSG_ERROR([Invalid cygpath invocation: Path '$input' is not absolute])
434                    ;;
435            esac
436        fi
437    }
438
439    if test -n "$UNITTEST_WSL_CYGPATH"; then
440        BUILDDIR=.
441
442        # Nothing special with these file names, just arbitrary ones picked to test with
443        cygpath -d /usr/lib64/ld-linux-x86-64.so.2
444        cygpath -w /usr/lib64/ld-linux-x86-64.so.2
445        cygpath -m /usr/lib64/ld-linux-x86-64.so.2
446        cygpath -m -s /usr/lib64/ld-linux-x86-64.so.2
447        # At least on my machine for instance this file does have an 8.3 name
448        cygpath -d /mnt/c/windows/WindowsUpdate.log
449        # But for instance this one doesn't
450        cygpath -w /mnt/c/windows/system32/AboutSettingsHandlers.dll
451        cygpath -ws /mnt/c/windows/WindowsUpdate.log
452        cygpath -m /mnt/c/windows/system32/AboutSettingsHandlers.dll
453        cygpath -ms /mnt/c/windows/WindowsUpdate.log
454
455        cygpath -u 'c:\windows\system32\AboutSettingsHandlers.dll'
456        cygpath -u 'c:/windows/system32/AboutSettingsHandlers.dll'
457
458        exit 0
459    fi
460
461    if test -z "$WSL_LO_HELPER"; then
462        if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/wsl-lo-helper" ; then
463            WSL_LO_HELPER="$LODE_HOME/opt/bin/wsl-lo-helper"
464        elif test -x "/opt/lo/bin/wsl-lo-helper"; then
465            WSL_LO_HELPER="/opt/lo/bin/wsl-lo-helper"
466        fi
467    fi
468    if test -z "$WSL_LO_HELPER"; then
469        AC_MSG_ERROR([wsl-lo-helper not found. See solenv/wsl/README.])
470    fi
471fi
472
473AC_CANONICAL_HOST
474AC_CANONICAL_BUILD
475
476if test -n "$UNITTEST_WSL_PATHFORMAT"; then
477    BUILDDIR=.
478    GREP=grep
479
480    # Use of PathFormat must be after AC_CANONICAL_BUILD above
481    PathFormat /
482    printf "$formatted_path , $formatted_path_unix\n"
483
484    PathFormat $PWD
485    printf "$formatted_path , $formatted_path_unix\n"
486
487    PathFormat "$PROGRAMFILESX86"
488    printf "$formatted_path , $formatted_path_unix\n"
489
490    exit 0
491fi
492
493AC_MSG_CHECKING([for product name])
494PRODUCTNAME="AC_PACKAGE_NAME"
495if test -n "$with_product_name" -a "$with_product_name" != no; then
496    PRODUCTNAME="$with_product_name"
497fi
498if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
499    PRODUCTNAME="${PRODUCTNAME}Dev"
500fi
501AC_MSG_RESULT([$PRODUCTNAME])
502AC_SUBST(PRODUCTNAME)
503PRODUCTNAME_WITHOUT_SPACES=$(printf %s "$PRODUCTNAME" | sed 's/ //g')
504AC_SUBST(PRODUCTNAME_WITHOUT_SPACES)
505
506dnl ===================================================================
507dnl Our version is defined by the AC_INIT() at the top of this script.
508dnl ===================================================================
509
510AC_MSG_CHECKING([for package version])
511if test -n "$with_package_version" -a "$with_package_version" != no; then
512    PACKAGE_VERSION="$with_package_version"
513fi
514AC_MSG_RESULT([$PACKAGE_VERSION])
515
516set `echo "$PACKAGE_VERSION" | sed "s/\./ /g"`
517
518LIBO_VERSION_MAJOR=$1
519LIBO_VERSION_MINOR=$2
520LIBO_VERSION_MICRO=$3
521LIBO_VERSION_PATCH=$4
522
523LIBO_VERSION_SUFFIX=$5
524
525# Split out LIBO_VERSION_SUFFIX_SUFFIX... horrible crack. But apparently wanted separately in
526# openoffice.lst as ABOUTBOXPRODUCTVERSIONSUFFIX. Note that the double brackets are for m4's sake,
527# they get undoubled before actually passed to sed.
528LIBO_VERSION_SUFFIX_SUFFIX=`echo "$LIBO_VERSION_SUFFIX" | sed -e 's/.*[[a-zA-Z0-9]]\([[^a-zA-Z0-9]]*\)$/\1/'`
529test -n "$LIBO_VERSION_SUFFIX_SUFFIX" && LIBO_VERSION_SUFFIX="${LIBO_VERSION_SUFFIX%${LIBO_VERSION_SUFFIX_SUFFIX}}"
530# LIBO_VERSION_SUFFIX, if non-empty, should include the period separator
531test -n "$LIBO_VERSION_SUFFIX" && LIBO_VERSION_SUFFIX=".$LIBO_VERSION_SUFFIX"
532
533# The value for key CFBundleVersion in the Info.plist file must be a period-separated list of at most
534# three non-negative integers. Please find more information about CFBundleVersion at
535# https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion
536
537# The value for key CFBundleShortVersionString in the Info.plist file must be a period-separated list
538# of at most three non-negative integers. Please find more information about
539# CFBundleShortVersionString at
540# https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring
541
542# But that is enforced only in the App Store, and we apparently want to break the rules otherwise.
543
544if test "$enable_macosx_sandbox" = yes; then
545    MACOSX_BUNDLE_SHORTVERSION=$LIBO_VERSION_MAJOR.$LIBO_VERSION_MINOR.`expr $LIBO_VERSION_MICRO '*' 1000 + $LIBO_VERSION_PATCH`
546    MACOSX_BUNDLE_VERSION=$MACOSX_BUNDLE_SHORTVERSION
547else
548    MACOSX_BUNDLE_SHORTVERSION=$LIBO_VERSION_MAJOR.$LIBO_VERSION_MINOR.$LIBO_VERSION_MICRO.$LIBO_VERSION_PATCH
549    MACOSX_BUNDLE_VERSION=$MACOSX_BUNDLE_SHORTVERSION$LIBO_VERSION_SUFFIX
550fi
551
552AC_SUBST(LIBO_VERSION_MAJOR)
553AC_SUBST(LIBO_VERSION_MINOR)
554AC_SUBST(LIBO_VERSION_MICRO)
555AC_SUBST(LIBO_VERSION_PATCH)
556AC_SUBST(LIBO_VERSION_SUFFIX)
557AC_SUBST(LIBO_VERSION_SUFFIX_SUFFIX)
558AC_SUBST(MACOSX_BUNDLE_SHORTVERSION)
559AC_SUBST(MACOSX_BUNDLE_VERSION)
560
561AC_DEFINE_UNQUOTED(LIBO_VERSION_MAJOR,$LIBO_VERSION_MAJOR)
562AC_DEFINE_UNQUOTED(LIBO_VERSION_MINOR,$LIBO_VERSION_MINOR)
563AC_DEFINE_UNQUOTED(LIBO_VERSION_MICRO,$LIBO_VERSION_MICRO)
564AC_DEFINE_UNQUOTED(LIBO_VERSION_PATCH,$LIBO_VERSION_PATCH)
565
566git_date=`git log -1 --pretty=format:"%cd" --date=format:'%Y' 2>/dev/null`
567LIBO_THIS_YEAR=${git_date:-2024}
568AC_DEFINE_UNQUOTED(LIBO_THIS_YEAR,$LIBO_THIS_YEAR)
569
570dnl ===================================================================
571dnl Product version
572dnl ===================================================================
573AC_MSG_CHECKING([for product version])
574PRODUCTVERSION="$LIBO_VERSION_MAJOR.$LIBO_VERSION_MINOR"
575AC_MSG_RESULT([$PRODUCTVERSION])
576AC_SUBST(PRODUCTVERSION)
577
578AC_PROG_EGREP
579# AC_PROG_EGREP doesn't set GREP on all systems as well
580AC_PATH_PROG(GREP, grep)
581
582BUILDDIR=`pwd`
583cd $srcdir
584SRC_ROOT=`pwd`
585cd $BUILDDIR
586x_Cygwin=[\#]
587
588dnl ======================================
589dnl Required GObject introspection version
590dnl ======================================
591INTROSPECTION_REQUIRED_VERSION=1.32.0
592
593dnl ===================================================================
594dnl Search all the common names for GNU Make
595dnl ===================================================================
596AC_MSG_CHECKING([for GNU Make])
597
598# try to use our own make if it is available and GNUMAKE was not already defined
599if test -z "$GNUMAKE"; then
600    if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/make" ; then
601        GNUMAKE="$LODE_HOME/opt/bin/make"
602    elif test -x "/opt/lo/bin/make"; then
603        GNUMAKE="/opt/lo/bin/make"
604    fi
605fi
606
607GNUMAKE_WIN_NATIVE=
608for a in "$MAKE" "$GNUMAKE" make gmake gnumake; do
609    if test -n "$a"; then
610        $a --version 2> /dev/null | grep GNU  2>&1 > /dev/null
611        if test $? -eq 0;  then
612            if test "$build_os" = "cygwin"; then
613                if test -n "$($a -v | grep 'Built for Windows')" ; then
614                    GNUMAKE="$(cygpath -m "$(command -v "$(cygpath -u $a)")")"
615                    GNUMAKE_WIN_NATIVE="TRUE"
616                else
617                    GNUMAKE=`command -v $a`
618                fi
619            else
620                GNUMAKE=`command -v $a`
621            fi
622            break
623        fi
624    fi
625done
626AC_MSG_RESULT($GNUMAKE)
627if test -z "$GNUMAKE"; then
628    AC_MSG_ERROR([not found. install GNU Make.])
629else
630    if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
631        AC_MSG_NOTICE([Using a native Win32 GNU Make version.])
632    fi
633fi
634
635win_short_path_for_make()
636{
637    local short_path="$1"
638    if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
639        cygpath -sm "$short_path"
640    elif test -n "$WSL_ONLY_AS_HELPER"; then
641        # when already unix-style path, wslpath doesn't return anything
642        case "$short_path" in
643        /*)
644            echo $short_path
645            exit
646            ;;
647        esac
648        wslpath -m "$(wslpath -u "$short_path")"
649    else
650        cygpath -u "$(cygpath -d "$short_path")"
651    fi
652}
653
654
655if test "$build_os" = "cygwin"; then
656    PathFormat "$SRC_ROOT"
657    SRC_ROOT="$formatted_path"
658    PathFormat "$BUILDDIR"
659    BUILDDIR="$formatted_path"
660    x_Cygwin=
661    AC_MSG_CHECKING(for explicit COMSPEC)
662    if test -z "$COMSPEC"; then
663        AC_MSG_ERROR([COMSPEC not set in environment, please set it and rerun])
664    else
665        AC_MSG_RESULT([found: $COMSPEC])
666    fi
667fi
668
669AC_SUBST(SRC_ROOT)
670AC_SUBST(BUILDDIR)
671AC_SUBST(x_Cygwin)
672AC_DEFINE_UNQUOTED(SRCDIR,"$SRC_ROOT")
673AC_DEFINE_UNQUOTED(SRC_ROOT,"$SRC_ROOT")
674AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR")
675
676if test "z$EUID" = "z0" -a "`uname -o 2>/dev/null`" = "Cygwin"; then
677    AC_MSG_ERROR([You must build LibreOffice as a normal user - not using an administrative account])
678fi
679
680# need sed in os checks...
681AC_PATH_PROGS(SED, sed)
682if test -z "$SED"; then
683    AC_MSG_ERROR([install sed to run this script])
684fi
685
686# Set the ENABLE_LTO variable
687# ===================================================================
688AC_MSG_CHECKING([whether to use link-time optimization])
689if test -n "$enable_lto" -a "$enable_lto" != "no"; then
690    ENABLE_LTO="TRUE"
691    AC_MSG_RESULT([yes])
692else
693    ENABLE_LTO=""
694    AC_MSG_RESULT([no])
695fi
696AC_SUBST(ENABLE_LTO)
697
698AC_ARG_ENABLE(fuzz-options,
699    AS_HELP_STRING([--enable-fuzz-options],
700        [Randomly enable or disable each of those configurable options
701         that are supposed to be freely selectable without interdependencies,
702         or where bad interaction from interdependencies is automatically avoided.])
703)
704
705dnl ===================================================================
706dnl When building for Android, --with-android-ndk,
707dnl --with-android-ndk-toolchain-version and --with-android-sdk are
708dnl mandatory
709dnl ===================================================================
710
711AC_ARG_WITH(android-ndk,
712    AS_HELP_STRING([--with-android-ndk],
713        [Specify location of the Android Native Development Kit. Mandatory when building for Android.]),
714,)
715
716AC_ARG_WITH(android-ndk-toolchain-version,
717    AS_HELP_STRING([--with-android-ndk-toolchain-version],
718        [Specify which toolchain version to use, of those present in the
719        Android NDK you are using. The default (and only supported version currently) is "clang5.0"]),,
720        with_android_ndk_toolchain_version=clang5.0)
721
722AC_ARG_WITH(android-sdk,
723    AS_HELP_STRING([--with-android-sdk],
724        [Specify location of the Android SDK. Mandatory when building for Android.]),
725,)
726
727AC_ARG_WITH(android-api-level,
728    AS_HELP_STRING([--with-android-api-level],
729        [Specify the API level when building for Android. Defaults to 16 for ARM and x86 and to 21 for ARM64 and x86-64]),
730,)
731
732ANDROID_NDK_DIR=
733if test -z "$with_android_ndk" -a -e "$SRC_ROOT/external/android-ndk" -a "$build" != "$host"; then
734    with_android_ndk="$SRC_ROOT/external/android-ndk"
735fi
736if test -n "$with_android_ndk"; then
737    eval ANDROID_NDK_DIR=$with_android_ndk
738
739    ANDROID_API_LEVEL=21
740    if test -n "$with_android_api_level" ; then
741        ANDROID_API_LEVEL="$with_android_api_level"
742    fi
743
744    if test $host_cpu = arm; then
745        LLVM_TRIPLE=armv7a-linux-androideabi
746        ANDROID_SYSROOT_PLATFORM=arm-linux-androideabi
747        ANDROID_APP_ABI=armeabi-v7a
748        ANDROIDCFLAGS="-mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -Wl,--fix-cortex-a8"
749    elif test $host_cpu = aarch64; then
750        LLVM_TRIPLE=aarch64-linux-android
751        ANDROID_SYSROOT_PLATFORM=$LLVM_TRIPLE
752        ANDROID_APP_ABI=arm64-v8a
753    elif test $host_cpu = x86_64; then
754        LLVM_TRIPLE=x86_64-linux-android
755        ANDROID_SYSROOT_PLATFORM=$LLVM_TRIPLE
756        ANDROID_APP_ABI=x86_64
757    else
758        # host_cpu is something like "i386" or "i686" I guess, NDK uses
759        # "x86" in some contexts
760        LLVM_TRIPLE=i686-linux-android
761        ANDROID_SYSROOT_PLATFORM=$LLVM_TRIPLE
762        ANDROID_APP_ABI=x86
763    fi
764
765    # Set up a lot of pre-canned defaults
766
767    if test ! -f $ANDROID_NDK_DIR/RELEASE.TXT; then
768        if test ! -f $ANDROID_NDK_DIR/source.properties; then
769            AC_MSG_ERROR([Unrecognized Android NDK. Missing RELEASE.TXT or source.properties file in $ANDROID_NDK_DIR.])
770        fi
771        ANDROID_NDK_VERSION=`sed -n -e 's/Pkg.Revision = //p' $ANDROID_NDK_DIR/source.properties`
772    else
773        ANDROID_NDK_VERSION=`cut -f1 -d' ' <$ANDROID_NDK_DIR/RELEASE.TXT`
774    fi
775    if test -z "$ANDROID_NDK_VERSION";  then
776        AC_MSG_ERROR([Failed to determine Android NDK version. Please check your installation.])
777    fi
778    case $ANDROID_NDK_VERSION in
779    r9*|r10*)
780        AC_MSG_ERROR([Building for Android requires NDK version >= 23.*])
781        ;;
782    11.1.*|12.1.*|13.1.*|14.1.*|16.*|17.*|18.*|19.*|20.*|21.*|22.*)
783        AC_MSG_ERROR([Building for Android requires NDK version >= 23.*])
784        ;;
785    23.*|24.*|25.*)
786        ;;
787    *)
788        AC_MSG_WARN([Untested Android NDK version $ANDROID_NDK_VERSION, only versions 23.* to 25.* have been used successfully. Proceed at your own risk.])
789        add_warning "Untested Android NDK version $ANDROID_NDK_VERSION, only versions 23.* to 25.* have been used successfully. Proceed at your own risk."
790        ;;
791    esac
792
793    case "$with_android_ndk_toolchain_version" in
794    clang5.0)
795        ANDROID_GCC_TOOLCHAIN_VERSION=4.9
796        ;;
797    *)
798        AC_MSG_ERROR([Unrecognized value for the --with-android-ndk-toolchain-version option. Building for Android is only supported with Clang 5.*])
799    esac
800
801    AC_MSG_NOTICE([using the Android API level... $ANDROID_API_LEVEL])
802
803    # NDK 15 or later toolchain is 64bit-only, except for Windows that we don't support. Using a 64-bit
804    # linker is required if you compile large parts of the code with -g. A 32-bit linker just won't
805    # manage to link the (app-specific) single huge .so that is built for the app in
806    # android/source/ if there is debug information in a significant part of the object files.
807    # (A 64-bit ld.gold grows too much over 10 gigabytes of virtual space when linking such a .so if
808    # all objects have been built with debug information.)
809    case $build_os in
810    linux-gnu*)
811        android_HOST_TAG=linux-x86_64
812        ;;
813    darwin*)
814        android_HOST_TAG=darwin-x86_64
815        ;;
816    *)
817        AC_MSG_ERROR([We only support building for Android from Linux or macOS])
818        # ndk would also support windows and windows-x86_64
819        ;;
820    esac
821    ANDROID_TOOLCHAIN=$ANDROID_NDK_DIR/toolchains/llvm/prebuilt/$android_HOST_TAG
822    ANDROID_COMPILER_BIN=$ANDROID_TOOLCHAIN/bin
823
824    test -z "$AR" && AR=$ANDROID_COMPILER_BIN/llvm-ar
825    test -z "$NM" && NM=$ANDROID_COMPILER_BIN/llvm-nm
826    test -z "$OBJDUMP" && OBJDUMP=$ANDROID_COMPILER_BIN/llvm-objdump
827    test -z "$RANLIB" && RANLIB=$ANDROID_COMPILER_BIN/llvm-ranlib
828    test -z "$STRIP" && STRIP=$ANDROID_COMPILER_BIN/llvm-strip
829
830    ANDROIDCFLAGS="$ANDROIDCFLAGS -target ${LLVM_TRIPLE}${ANDROID_API_LEVEL}"
831    ANDROIDCFLAGS="$ANDROIDCFLAGS -no-canonical-prefixes -ffunction-sections -fdata-sections -Qunused-arguments"
832    if test "$ENABLE_LTO" = TRUE; then
833        # -flto comes from com_GCC_defs.mk, too, but we need to make sure it gets passed as part of
834        # $CC and $CXX when building external libraries
835        ANDROIDCFLAGS="$ANDROIDCFLAGS -flto -fuse-linker-plugin -O2"
836    fi
837
838    ANDROIDCXXFLAGS="$ANDROIDCFLAGS -stdlib=libc++"
839
840    if test -z "$CC"; then
841        CC="$ANDROID_COMPILER_BIN/clang $ANDROIDCFLAGS"
842        CC_BASE="clang"
843    fi
844    if test -z "$CXX"; then
845        CXX="$ANDROID_COMPILER_BIN/clang++ $ANDROIDCXXFLAGS"
846        CXX_BASE="clang++"
847    fi
848fi
849AC_SUBST(ANDROID_NDK_DIR)
850AC_SUBST(ANDROID_NDK_VERSION)
851AC_SUBST(ANDROID_API_LEVEL)
852AC_SUBST(ANDROID_APP_ABI)
853AC_SUBST(ANDROID_GCC_TOOLCHAIN_VERSION)
854AC_SUBST(ANDROID_SYSROOT_PLATFORM)
855AC_SUBST(ANDROID_TOOLCHAIN)
856
857dnl ===================================================================
858dnl --with-android-sdk
859dnl ===================================================================
860ANDROID_SDK_DIR=
861if test -z "$with_android_sdk" -a -e "$SRC_ROOT/external/android-sdk-linux" -a "$build" != "$host"; then
862    with_android_sdk="$SRC_ROOT/external/android-sdk-linux"
863fi
864if test -n "$with_android_sdk"; then
865    eval ANDROID_SDK_DIR=$with_android_sdk
866    PATH="$ANDROID_SDK_DIR/platform-tools:$ANDROID_SDK_DIR/tools:$PATH"
867fi
868AC_SUBST(ANDROID_SDK_DIR)
869
870AC_ARG_ENABLE([android-lok],
871    AS_HELP_STRING([--enable-android-lok],
872        [The Android app from the android/ subdir needs several tweaks all
873         over the place that break the LOK when used in the Online-based
874         Android app.  This switch indicates that the intent of this build is
875         actually the Online-based, non-modified LOK.])
876)
877ENABLE_ANDROID_LOK=
878if test -n "$ANDROID_NDK_DIR" ; then
879    if test "$enable_android_lok" = yes; then
880        ENABLE_ANDROID_LOK=TRUE
881        AC_DEFINE(HAVE_FEATURE_ANDROID_LOK)
882        AC_MSG_NOTICE([building the Android version... for the Online-based Android app])
883    else
884        AC_MSG_NOTICE([building the Android version... for the app from the android/ subdir])
885    fi
886fi
887AC_SUBST([ENABLE_ANDROID_LOK])
888
889libo_FUZZ_ARG_ENABLE([android-editing],
890    AS_HELP_STRING([--enable-android-editing],
891        [Enable the experimental editing feature on Android.])
892)
893ENABLE_ANDROID_EDITING=
894if test "$enable_android_editing" = yes; then
895    ENABLE_ANDROID_EDITING=TRUE
896fi
897AC_SUBST([ENABLE_ANDROID_EDITING])
898
899disable_database_connectivity_dependencies()
900{
901    enable_evolution2=no
902    enable_firebird_sdbc=no
903    enable_mariadb_sdbc=no
904    enable_postgresql_sdbc=no
905    enable_report_builder=no
906}
907
908# ===================================================================
909#
910# Start initial platform setup
911#
912# The using_* variables reflect platform support and should not be
913# changed after the "End initial platform setup" block.
914# This is also true for most test_* variables.
915# ===================================================================
916build_crypto=yes
917test_clucene=no
918test_gdb_index=no
919test_openldap=yes
920test_split_debug=no
921test_webdav=yes
922usable_dlapi=yes
923
924# There is currently just iOS not using salplug, so this explicitly enables it.
925# must: using_freetype_fontconfig
926#  may: using_headless_plugin defaults to $using_freetype_fontconfig
927# must: using_x11
928
929# Default values, as such probably valid just for Linux, set
930# differently below just for Mac OSX, but at least better than
931# hardcoding these as we used to do. Much of this is duplicated also
932# in solenv for old build system and for gbuild, ideally we should
933# perhaps define stuff like this only here in configure.ac?
934
935LINKFLAGSSHL="-shared"
936PICSWITCH="-fpic"
937DLLPOST=".so"
938
939LINKFLAGSNOUNDEFS="-Wl,-z,defs"
940
941INSTROOTBASESUFFIX=
942INSTROOTCONTENTSUFFIX=
943SDKDIRNAME=sdk
944
945HOST_PLATFORM="$host"
946
947host_cpu_for_clang="$host_cpu"
948
949case "$host_os" in
950
951solaris*)
952    using_freetype_fontconfig=yes
953    using_x11=yes
954    build_skia=yes
955    _os=SunOS
956
957    dnl ===========================================================
958    dnl Check whether we're using Solaris 10 - SPARC or Intel.
959    dnl ===========================================================
960    AC_MSG_CHECKING([the Solaris operating system release])
961    _os_release=`echo $host_os | $SED -e s/solaris2\.//`
962    if test "$_os_release" -lt "10"; then
963        AC_MSG_ERROR([use Solaris >= 10 to build LibreOffice])
964    else
965        AC_MSG_RESULT([ok ($_os_release)])
966    fi
967
968    dnl Check whether we're using a SPARC or i386 processor
969    AC_MSG_CHECKING([the processor type])
970    if test "$host_cpu" = "sparc" -o "$host_cpu" = "i386"; then
971        AC_MSG_RESULT([ok ($host_cpu)])
972    else
973        AC_MSG_ERROR([only SPARC and i386 processors are supported])
974    fi
975    ;;
976
977linux-gnu*|k*bsd*-gnu*|linux-musl*)
978    using_freetype_fontconfig=yes
979    using_x11=yes
980    build_skia=yes
981    test_gdb_index=yes
982    test_split_debug=yes
983    if test "$enable_fuzzers" = yes; then
984        test_system_freetype=no
985    fi
986    _os=Linux
987    ;;
988
989gnu)
990    using_freetype_fontconfig=yes
991    using_x11=no
992    _os=GNU
993     ;;
994
995cygwin*|wsl*)
996    # When building on Windows normally with MSVC under Cygwin,
997    # configure thinks that the host platform (the platform the
998    # built code will run on) is Cygwin, even if it obviously is
999    # Windows, which in Autoconf terminology is called
1000    # "mingw32". (Which is misleading as MinGW is the name of the
1001    # tool-chain, not an operating system.)
1002
1003    # Somewhat confusing, yes. But this configure script doesn't
1004    # look at $host etc that much, it mostly uses its own $_os
1005    # variable, set here in this case statement.
1006
1007    using_freetype_fontconfig=no
1008    using_x11=no
1009    test_unix_dlapi=no
1010    test_openldap=no
1011    enable_pagein=no
1012    build_skia=yes
1013    _os=WINNT
1014
1015    DLLPOST=".dll"
1016    LINKFLAGSNOUNDEFS=
1017
1018    if test "$host_cpu" = "aarch64"; then
1019        build_skia=no
1020        enable_gpgmepp=no
1021        enable_coinmp=no
1022        enable_firebird_sdbc=no
1023    fi
1024    ;;
1025
1026darwin*) # macOS
1027    using_freetype_fontconfig=no
1028    using_x11=no
1029    build_skia=yes
1030    enable_pagein=no
1031    if test -n "$LODE_HOME" ; then
1032        mac_sanitize_path
1033        AC_MSG_NOTICE([sanitized the PATH to $PATH])
1034    fi
1035    _os=Darwin
1036    INSTROOTBASESUFFIX=/$PRODUCTNAME_WITHOUT_SPACES.app
1037    INSTROOTCONTENTSUFFIX=/Contents
1038    SDKDIRNAME=${PRODUCTNAME_WITHOUT_SPACES}${PRODUCTVERSION}_SDK
1039    # See "Default values, as such probably valid just for Linux" comment above the case "$host_os"
1040    LINKFLAGSSHL="-dynamiclib"
1041
1042    # -fPIC is default
1043    PICSWITCH=""
1044
1045    DLLPOST=".dylib"
1046
1047    # -undefined error is the default
1048    LINKFLAGSNOUNDEFS=""
1049    case "$host_cpu" in
1050    aarch64|arm64)
1051        # Apple's Clang uses "arm64"
1052        host_cpu_for_clang=arm64
1053    esac
1054;;
1055
1056ios*) # iOS
1057    using_freetype_fontconfig=no
1058    using_x11=no
1059    build_crypto=no
1060    test_libcmis=no
1061    test_openldap=no
1062    test_webdav=no
1063    if test -n "$LODE_HOME" ; then
1064        mac_sanitize_path
1065        AC_MSG_NOTICE([sanitized the PATH to $PATH])
1066    fi
1067    enable_gpgmepp=no
1068    _os=iOS
1069    enable_mpl_subset=yes
1070    enable_lotuswordpro=no
1071    disable_database_connectivity_dependencies
1072    enable_coinmp=no
1073    enable_lpsolve=no
1074    enable_extension_integration=no
1075    enable_xmlhelp=no
1076    with_ppds=no
1077    if test "$enable_ios_simulator" = "yes"; then
1078        host=x86_64-apple-darwin
1079    fi
1080    # See "Default values, as such probably valid just for Linux" comment above the case "$host_os"
1081    LINKFLAGSSHL="-dynamiclib"
1082
1083    # -fPIC is default
1084    PICSWITCH=""
1085
1086    DLLPOST=".dylib"
1087
1088    # -undefined error is the default
1089    LINKFLAGSNOUNDEFS=""
1090
1091    # HOST_PLATFORM is used for external projects and their configury typically doesn't like the "ios"
1092    # part, so use aarch64-apple-darwin for now.
1093    HOST_PLATFORM=aarch64-apple-darwin
1094
1095    # Apple's Clang uses "arm64"
1096    host_cpu_for_clang=arm64
1097;;
1098
1099freebsd*)
1100    using_freetype_fontconfig=yes
1101    using_x11=yes
1102    build_skia=yes
1103    AC_MSG_CHECKING([the FreeBSD operating system release])
1104    if test -n "$with_os_version"; then
1105        OSVERSION="$with_os_version"
1106    else
1107        OSVERSION=`/sbin/sysctl -n kern.osreldate`
1108    fi
1109    AC_MSG_RESULT([found OSVERSION=$OSVERSION])
1110    AC_MSG_CHECKING([which thread library to use])
1111    if test "$OSVERSION" -lt "500016"; then
1112        PTHREAD_CFLAGS="-D_THREAD_SAFE"
1113        PTHREAD_LIBS="-pthread"
1114    elif test "$OSVERSION" -lt "502102"; then
1115        PTHREAD_CFLAGS="-D_THREAD_SAFE"
1116        PTHREAD_LIBS="-lc_r"
1117    else
1118        PTHREAD_CFLAGS=""
1119        PTHREAD_LIBS="-pthread"
1120    fi
1121    AC_MSG_RESULT([$PTHREAD_LIBS])
1122    _os=FreeBSD
1123    ;;
1124
1125*netbsd*)
1126    using_freetype_fontconfig=yes
1127    using_x11=yes
1128    test_gtk3_kde5=no
1129    build_skia=yes
1130    PTHREAD_LIBS="-pthread -lpthread"
1131    _os=NetBSD
1132    ;;
1133
1134openbsd*)
1135    using_freetype_fontconfig=yes
1136    using_x11=yes
1137    PTHREAD_CFLAGS="-D_THREAD_SAFE"
1138    PTHREAD_LIBS="-pthread"
1139    _os=OpenBSD
1140    ;;
1141
1142dragonfly*)
1143    using_freetype_fontconfig=yes
1144    using_x11=yes
1145    build_skia=yes
1146    PTHREAD_LIBS="-pthread"
1147    _os=DragonFly
1148    ;;
1149
1150linux-android*)
1151    # API exists, but seems not really usable since Android 7 AFAIK
1152    usable_dlapi=no
1153    using_freetype_fontconfig=yes
1154    using_headless_plugin=no
1155    using_x11=no
1156    build_crypto=no
1157    test_openldap=no
1158    test_system_freetype=no
1159    test_webdav=no
1160    disable_database_connectivity_dependencies
1161    enable_lotuswordpro=no
1162    enable_mpl_subset=yes
1163    enable_cairo_canvas=no
1164    enable_coinmp=yes
1165    enable_lpsolve=no
1166    enable_odk=no
1167    enable_python=no
1168    enable_xmlhelp=no
1169    _os=Android
1170    ;;
1171
1172haiku*)
1173    using_freetype_fontconfig=yes
1174    using_x11=no
1175    test_gtk3=no
1176    test_gtk3_kde5=no
1177    test_kf5=yes
1178    test_kf6=yes
1179    enable_odk=no
1180    enable_coinmp=no
1181    enable_pdfium=no
1182    enable_sdremote=no
1183    enable_postgresql_sdbc=no
1184    enable_firebird_sdbc=no
1185    _os=Haiku
1186    ;;
1187
1188emscripten)
1189    # API currently just exists in headers, not code
1190    usable_dlapi=no
1191    using_freetype_fontconfig=yes
1192    using_x11=yes
1193    test_openldap=no
1194    test_qt5=yes
1195    test_split_debug=yes
1196    test_system_freetype=no
1197    enable_compiler_plugins=no
1198    enable_customtarget_components=yes
1199    enable_split_debug=yes
1200    enable_wasm_strip=yes
1201    with_system_zlib=no
1202    with_theme="colibre"
1203    _os=Emscripten
1204    ;;
1205
1206*)
1207    AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice for!])
1208    ;;
1209esac
1210
1211AC_SUBST(HOST_PLATFORM)
1212
1213if test -z "$using_x11" -o -z "$using_freetype_fontconfig"; then
1214    AC_MSG_ERROR([You must set \$using_freetype_fontconfig and \$using_x11 for your platform])
1215fi
1216
1217# Set defaults, if not set by platform
1218test "${test_cpdb+set}" = set || test_cpdb="$using_x11"
1219test "${test_cups+set}" = set || test_cups="$using_x11"
1220test "${test_dbus+set}" = set || test_dbus="$using_x11"
1221test "${test_gen+set}" = set || test_gen="$using_x11"
1222test "${test_gstreamer_1_0+set}" = set || test_gstreamer_1_0="$using_x11"
1223test "${test_gtk3+set}" = set || test_gtk3="$using_x11"
1224test "${test_gtk4+set}" = set || test_gtk4="$using_x11"
1225test "${test_kf5+set}" = set || test_kf5="$using_x11"
1226test "${test_kf6+set}" = set || test_kf6="$using_x11"
1227# don't handle test_qt5, so it can disable test_kf5 later
1228test "${test_qt6+set}" = set || test_qt6="$using_x11"
1229test "${test_randr+set}" = set || test_randr="$using_x11"
1230test "${test_xrender+set}" = set || test_xrender="$using_x11"
1231test "${using_headless_plugin+set}" = set || using_headless_plugin="$using_freetype_fontconfig"
1232
1233test "${test_gtk3_kde5+set}" != set -a "$test_kf5" = yes -a "$test_gtk3" = yes && test_gtk3_kde5="yes"
1234# Make sure fontconfig and freetype test both either system or not
1235test "${test_system_fontconfig+set}" != set -a "${test_system_freetype+set}" = set && test_system_fontconfig="$test_system_freetype"
1236test "${test_system_freetype+set}" != set -a "${test_system_fontconfig+set}" = set && test_system_freetype="$test_system_fontconfig"
1237
1238# convenience / platform overriding "fixes"
1239# Don't sort!
1240test "$test_kf5" = yes -a "$test_qt5" = no && test_kf5=no
1241test "$test_kf5" = yes && test_qt5=yes
1242test "$test_gtk3" != yes && enable_gtk3=no
1243test "$test_gtk3" != yes -o "$test_kf5" != yes && test_gtk3_kde5=no
1244test "$using_freetype_fontconfig" = no && using_headless_plugin=no
1245test "$using_freetype_fontconfig" = yes && test_cairo=yes
1246
1247# Keep in sync with the above $using_x11 depending test default list
1248disable_x11_tests()
1249{
1250    test_cpdb=no
1251    test_cups=no
1252    test_dbus=no
1253    test_gen=no
1254    test_gstreamer_1_0=no
1255    test_gtk3_kde5=no
1256    test_gtk3=no
1257    test_gtk4=no
1258    test_kf5=no
1259    test_kf6=no
1260    test_qt5=no
1261    test_qt6=no
1262    test_randr=no
1263    test_xrender=no
1264}
1265
1266test "$using_x11" = yes && USING_X11=TRUE
1267
1268if test "$using_freetype_fontconfig" = yes; then
1269    AC_DEFINE(USE_HEADLESS_CODE)
1270    USE_HEADLESS_CODE=TRUE
1271    if test "$using_headless_plugin" = yes; then
1272        AC_DEFINE(ENABLE_HEADLESS)
1273        ENABLE_HEADLESS=TRUE
1274    fi
1275else
1276    test_fontconfig=no
1277    test_freetype=no
1278fi
1279
1280AC_SUBST(ENABLE_HEADLESS)
1281AC_SUBST(USE_HEADLESS_CODE)
1282
1283AC_MSG_NOTICE([VCL platform has a usable dynamic loading API: $usable_dlapi])
1284AC_MSG_NOTICE([VCL platform uses freetype+fontconfig: $using_freetype_fontconfig])
1285AC_MSG_NOTICE([VCL platform uses headless plugin: $using_headless_plugin])
1286AC_MSG_NOTICE([VCL platform uses X11: $using_x11])
1287
1288# ===================================================================
1289#
1290# End initial platform setup
1291#
1292# ===================================================================
1293
1294if test "$_os" = "Android" ; then
1295    # Verify that the NDK and SDK options are proper
1296    if test -z "$with_android_ndk"; then
1297        AC_MSG_ERROR([the --with-android-ndk option is mandatory, unless it is available at external/android-ndk/.])
1298    elif test ! -f "$ANDROID_NDK_DIR/meta/abis.json"; then
1299        AC_MSG_ERROR([the --with-android-ndk option does not point to an Android NDK])
1300    fi
1301
1302    if test -z "$ANDROID_SDK_DIR"; then
1303        AC_MSG_ERROR([the --with-android-sdk option is mandatory, unless it is available at external/android-sdk-linux/.])
1304    elif test ! -d "$ANDROID_SDK_DIR/platforms"; then
1305        AC_MSG_ERROR([the --with-android-sdk option does not point to an Android SDK])
1306    fi
1307fi
1308
1309AC_SUBST(SDKDIRNAME)
1310
1311AC_SUBST(PTHREAD_CFLAGS)
1312AC_SUBST(PTHREAD_LIBS)
1313
1314# Check for explicit A/C/CXX/OBJC/OBJCXX/LDFLAGS.
1315# By default use the ones specified by our build system,
1316# but explicit override is possible.
1317AC_MSG_CHECKING(for explicit AFLAGS)
1318if test -n "$AFLAGS"; then
1319    AC_MSG_RESULT([$AFLAGS])
1320    x_AFLAGS=
1321else
1322    AC_MSG_RESULT(no)
1323    x_AFLAGS=[\#]
1324fi
1325AC_MSG_CHECKING(for explicit CFLAGS)
1326if test -n "$CFLAGS"; then
1327    AC_MSG_RESULT([$CFLAGS])
1328    x_CFLAGS=
1329else
1330    AC_MSG_RESULT(no)
1331    x_CFLAGS=[\#]
1332fi
1333AC_MSG_CHECKING(for explicit CXXFLAGS)
1334if test -n "$CXXFLAGS"; then
1335    AC_MSG_RESULT([$CXXFLAGS])
1336    x_CXXFLAGS=
1337else
1338    AC_MSG_RESULT(no)
1339    x_CXXFLAGS=[\#]
1340fi
1341AC_MSG_CHECKING(for explicit OBJCFLAGS)
1342if test -n "$OBJCFLAGS"; then
1343    AC_MSG_RESULT([$OBJCFLAGS])
1344    x_OBJCFLAGS=
1345else
1346    AC_MSG_RESULT(no)
1347    x_OBJCFLAGS=[\#]
1348fi
1349AC_MSG_CHECKING(for explicit OBJCXXFLAGS)
1350if test -n "$OBJCXXFLAGS"; then
1351    AC_MSG_RESULT([$OBJCXXFLAGS])
1352    x_OBJCXXFLAGS=
1353else
1354    AC_MSG_RESULT(no)
1355    x_OBJCXXFLAGS=[\#]
1356fi
1357AC_MSG_CHECKING(for explicit LDFLAGS)
1358if test -n "$LDFLAGS"; then
1359    AC_MSG_RESULT([$LDFLAGS])
1360    x_LDFLAGS=
1361else
1362    AC_MSG_RESULT(no)
1363    x_LDFLAGS=[\#]
1364fi
1365AC_SUBST(AFLAGS)
1366AC_SUBST(CFLAGS)
1367AC_SUBST(CXXFLAGS)
1368AC_SUBST(OBJCFLAGS)
1369AC_SUBST(OBJCXXFLAGS)
1370AC_SUBST(LDFLAGS)
1371AC_SUBST(x_AFLAGS)
1372AC_SUBST(x_CFLAGS)
1373AC_SUBST(x_CXXFLAGS)
1374AC_SUBST(x_OBJCFLAGS)
1375AC_SUBST(x_OBJCXXFLAGS)
1376AC_SUBST(x_LDFLAGS)
1377
1378dnl These are potentially set for MSVC, in the code checking for UCRT below:
1379my_original_CFLAGS=$CFLAGS
1380my_original_CXXFLAGS=$CXXFLAGS
1381my_original_CPPFLAGS=$CPPFLAGS
1382
1383dnl The following checks for gcc, cc and then cl (if it weren't guarded for win32)
1384dnl Needs to precede the AC_C_BIGENDIAN and AC_SEARCH_LIBS calls below, which apparently call
1385dnl AC_PROG_CC internally.
1386if test "$_os" != "WINNT"; then
1387    # AC_PROG_CC sets CFLAGS to -g -O2 if not set, avoid that (and avoid -O2 during AC_PROG_CC,
1388    # Clang 12.0.1 occasionally SEGVs on some of the test invocations during AC_PROG_CC with -O2):
1389    save_CFLAGS=$CFLAGS
1390    CFLAGS=-g
1391    AC_PROG_CC
1392    CFLAGS=$save_CFLAGS
1393    if test -z "$CC_BASE"; then
1394        CC_BASE=`first_arg_basename "$CC"`
1395    fi
1396fi
1397
1398if test "$_os" != "WINNT"; then
1399    AC_C_BIGENDIAN([ENDIANNESS=big], [ENDIANNESS=little])
1400else
1401    ENDIANNESS=little
1402fi
1403AC_SUBST(ENDIANNESS)
1404
1405if test "$usable_dlapi" != no; then
1406    AC_DEFINE([HAVE_DLAPI])
1407    if test "$test_unix_dlapi" != no; then
1408        save_LIBS="$LIBS"
1409        AC_SEARCH_LIBS([dlsym], [dl],
1410            [case "$ac_cv_search_dlsym" in -l*) UNIX_DLAPI_LIBS="$ac_cv_search_dlsym";; esac],
1411            [AC_MSG_ERROR([dlsym not found in either libc nor libdl])])
1412        LIBS="$save_LIBS"
1413        AC_DEFINE([HAVE_UNIX_DLAPI])
1414    fi
1415fi
1416AC_SUBST(UNIX_DLAPI_LIBS)
1417
1418# Check for a (GNU) backtrace implementation
1419AC_ARG_VAR([BACKTRACE_CFLAGS], [Compiler flags needed to use backtrace(3)])
1420AC_ARG_VAR([BACKTRACE_LIBS], [Linker flags needed to use backtrace(3)])
1421AS_IF([test "x$BACKTRACE_LIBS$BACKTRACE_CFLAGS" = x], [
1422    save_LIBS="$LIBS"
1423    AC_SEARCH_LIBS([backtrace], [libexecinfo],
1424        [case "$ac_cv_search_backtrace" in -l*) BACKTRACE_LIBS="$ac_cv_search_backtrace";; esac],
1425        [PKG_CHECK_MODULES([BACKTRACE], [libexecinfo], [ac_cv_search_backtrace=], [:])])
1426    LIBS="$save_LIBS"
1427])
1428AS_IF([test "x$ac_cv_search_backtrace" != xno ], [
1429    AC_DEFINE([HAVE_FEATURE_BACKTRACE])
1430])
1431
1432dnl ===================================================================
1433dnl Sanity checks for Emscripten SDK setup
1434dnl ===================================================================
1435
1436EMSCRIPTEN_MIN_MAJOR=3
1437EMSCRIPTEN_MIN_MINOR=1
1438EMSCRIPTEN_MIN_TINY=3
1439EMSCRIPTEN_MIN_VERSION="${EMSCRIPTEN_MIN_MAJOR}.${EMSCRIPTEN_MIN_MINOR}.${EMSCRIPTEN_MIN_TINY}"
1440
1441if test "$_os" = "Emscripten"; then
1442    AC_MSG_CHECKING([if Emscripten is at least $EMSCRIPTEN_MIN_VERSION])
1443    if test -z "$EMSCRIPTEN_VERSION_H"; then
1444        AS_IF([test -z "$EMSDK"],
1445              [AC_MSG_ERROR([No \$EMSDK environment variable.])])
1446        EMSCRIPTEN_VERSION_H=$EMSDK/upstream/emscripten/cache/sysroot/include/emscripten/version.h
1447    fi
1448    if test -f "$EMSCRIPTEN_VERSION_H"; then
1449        EMSCRIPTEN_MAJOR=$($GREP __EMSCRIPTEN_major__ "$EMSCRIPTEN_VERSION_H" | $SED -ne 's/.*__EMSCRIPTEN_major__ //p')
1450        EMSCRIPTEN_MINOR=$($GREP __EMSCRIPTEN_minor__ "$EMSCRIPTEN_VERSION_H" | $SED -ne 's/.*__EMSCRIPTEN_minor__ //p')
1451        EMSCRIPTEN_TINY=$($GREP __EMSCRIPTEN_tiny__ "$EMSCRIPTEN_VERSION_H" | $SED -ne 's/.*__EMSCRIPTEN_tiny__ //p')
1452    else
1453        EMSCRIPTEN_DEFINES=$(echo | emcc -dM -E - | $GREP __EMSCRIPTEN_)
1454        EMSCRIPTEN_MAJOR=$(echo "$EMSCRIPTEN_DEFINES" | $SED -ne 's/.*__EMSCRIPTEN_major__ //p')
1455        EMSCRIPTEN_MINOR=$(echo "$EMSCRIPTEN_DEFINES" | $SED -ne 's/.*__EMSCRIPTEN_minor__ //p')
1456        EMSCRIPTEN_TINY=$(echo "$EMSCRIPTEN_DEFINES" | $SED -ne 's/.*__EMSCRIPTEN_tiny__ //p')
1457    fi
1458
1459    EMSCRIPTEN_VERSION="${EMSCRIPTEN_MAJOR}.${EMSCRIPTEN_MINOR}.${EMSCRIPTEN_TINY}"
1460
1461    check_semantic_version_three_prefixed EMSCRIPTEN MIN
1462    if test $? -eq 0; then
1463        AC_MSG_RESULT([yes ($EMSCRIPTEN_VERSION)])
1464    else
1465        AC_MSG_ERROR([no, found $EMSCRIPTEN_VERSION])
1466    fi
1467
1468    EMSCRIPTEN_ERROR=0
1469    if ! command -v emconfigure >/dev/null 2>&1; then
1470        AC_MSG_WARN([emconfigure must be in your \$PATH])
1471        EMSCRIPTEN_ERROR=1
1472    fi
1473    if test -z "$EMMAKEN_JUST_CONFIGURE"; then
1474        AC_MSG_WARN(["\$EMMAKEN_JUST_CONFIGURE wasn't set by emconfigure. Prefix configure or use autogen.sh])
1475        EMSCRIPTEN_ERROR=1
1476    fi
1477    EMSDK_FILE_PACKAGER="$(em-config EMSCRIPTEN_ROOT)"/tools/file_packager
1478    if ! test -x "$EMSDK_FILE_PACKAGER"; then
1479        AC_MSG_WARN([No file_packager found in $(em-config EMSCRIPTEN_ROOT)/tools/file_packager.])
1480        EMSCRIPTEN_ERROR=1
1481    fi
1482    if test $EMSCRIPTEN_ERROR -ne 0; then
1483        AC_MSG_ERROR(["Please fix your EMSDK setup to build with Emscripten!"])
1484    fi
1485
1486    dnl Some build-side things are conditional on "EMSCRIPTEN in BUILD_TYPE_FOR_HOST":
1487    BUILD_TYPE="$BUILD_TYPE EMSCRIPTEN"
1488fi
1489AC_SUBST(EMSDK_FILE_PACKAGER)
1490AC_SUBST(EMSCRIPTEN_EXTRA_SOFFICE_POST_JS)
1491
1492###############################################################################
1493# Extensions switches --enable/--disable
1494###############################################################################
1495# By default these should be enabled unless having extra dependencies.
1496# If there is extra dependency over configure options then the enable should
1497# be automagic based on whether the requiring feature is enabled or not.
1498# All this options change anything only with --enable-extension-integration.
1499
1500# The name of this option and its help string makes it sound as if
1501# extensions are built anyway, just not integrated in the installer,
1502# if you use --disable-extension-integration. Is that really the
1503# case?
1504
1505AC_ARG_ENABLE(ios-simulator,
1506    AS_HELP_STRING([--enable-ios-simulator],
1507        [build for iOS simulator])
1508)
1509
1510libo_FUZZ_ARG_ENABLE(extension-integration,
1511    AS_HELP_STRING([--disable-extension-integration],
1512        [Disable integration of the built extensions in the installer of the
1513         product. Use this switch to disable the integration.])
1514)
1515
1516AC_ARG_ENABLE(avmedia,
1517    AS_HELP_STRING([--disable-avmedia],
1518        [Disable displaying and inserting AV media in documents. Work in progress, use only if you are hacking on it.]),
1519,test "${enable_avmedia+set}" = set || enable_avmedia=yes)
1520
1521AC_ARG_ENABLE(database-connectivity,
1522    AS_HELP_STRING([--disable-database-connectivity],
1523        [Disable various database connectivity. Work in progress, use only if you are hacking on it.])
1524)
1525
1526# This doesn't mean not building (or "integrating") extensions
1527# (although it probably should; i.e. it should imply
1528# --disable-extension-integration I guess), it means not supporting
1529# any extension mechanism at all
1530libo_FUZZ_ARG_ENABLE(extensions,
1531    AS_HELP_STRING([--disable-extensions],
1532        [Disable all add-on extension functionality. Work in progress, use only if you are hacking on it.])
1533)
1534
1535AC_ARG_ENABLE(scripting,
1536    AS_HELP_STRING([--disable-scripting],
1537        [Disable BASIC, Java, Python and .NET. Work in progress, use only if you are hacking on it.]),
1538,test "${enable_scripting+set}" = set || enable_scripting=yes)
1539
1540# This is mainly for Android and iOS, but could potentially be used in some
1541# special case otherwise, too, so factored out as a separate setting
1542
1543AC_ARG_ENABLE(dynamic-loading,
1544    AS_HELP_STRING([--disable-dynamic-loading],
1545        [Disable any use of dynamic loading of code. Work in progress, use only if you are hacking on it.])
1546)
1547
1548libo_FUZZ_ARG_ENABLE(report-builder,
1549    AS_HELP_STRING([--disable-report-builder],
1550        [Disable the Report Builder.])
1551)
1552
1553libo_FUZZ_ARG_ENABLE(ext-wiki-publisher,
1554    AS_HELP_STRING([--enable-ext-wiki-publisher],
1555        [Enable the Wiki Publisher extension.])
1556)
1557
1558libo_FUZZ_ARG_ENABLE(lpsolve,
1559    AS_HELP_STRING([--disable-lpsolve],
1560        [Disable compilation of the lp solve solver ])
1561)
1562libo_FUZZ_ARG_ENABLE(coinmp,
1563    AS_HELP_STRING([--disable-coinmp],
1564        [Disable compilation of the CoinMP solver ])
1565)
1566
1567libo_FUZZ_ARG_ENABLE(pdfimport,
1568    AS_HELP_STRING([--disable-pdfimport],
1569        [Disable building the PDF import feature.])
1570)
1571
1572libo_FUZZ_ARG_ENABLE(pdfium,
1573    AS_HELP_STRING([--disable-pdfium],
1574        [Disable building PDFium. Results in insecure PDF signature verification.])
1575)
1576
1577libo_FUZZ_ARG_ENABLE(skia,
1578    AS_HELP_STRING([--disable-skia],
1579        [Disable building Skia. Use --enable-skia=debug to build without optimizations.])
1580)
1581
1582###############################################################################
1583
1584dnl ---------- *** ----------
1585
1586libo_FUZZ_ARG_ENABLE(mergelibs,
1587    AS_HELP_STRING([--enable-mergelibs=yes/no/more],
1588        [Merge several of the smaller libraries into one big "merged" library.
1589         The "more" option will link even more of the smaller libraries.
1590         "more" not appropriate for distros which split up LibreOffice into multiple packages.
1591         It is only appropriate for situations where all of LO is delivered in a single install/package. ])
1592)
1593
1594libo_FUZZ_ARG_ENABLE(breakpad,
1595    AS_HELP_STRING([--enable-breakpad],
1596        [Enables breakpad for crash reporting.])
1597)
1598
1599libo_FUZZ_ARG_ENABLE(crashdump,
1600    AS_HELP_STRING([--disable-crashdump],
1601        [Disable dump.ini and dump-file, when --enable-breakpad])
1602)
1603
1604AC_ARG_ENABLE(fetch-external,
1605    AS_HELP_STRING([--disable-fetch-external],
1606        [Disables fetching external tarballs from web sources.])
1607)
1608
1609AC_ARG_ENABLE(fuzzers,
1610    AS_HELP_STRING([--enable-fuzzers],
1611        [Enables building libfuzzer targets for fuzz testing.])
1612)
1613
1614libo_FUZZ_ARG_ENABLE(pch,
1615    AS_HELP_STRING([--enable-pch=<yes/no/system/base/normal/full>],
1616        [Enables precompiled header support for C++. Forced default on Windows/VC build.
1617         Using 'system' will include only external headers, 'base' will add also headers
1618         from base modules, 'normal' will also add all headers except from the module built,
1619         'full' will use all suitable headers even from a module itself.])
1620)
1621
1622libo_FUZZ_ARG_ENABLE(epm,
1623    AS_HELP_STRING([--enable-epm],
1624        [LibreOffice includes self-packaging code, that requires epm, however epm is
1625         useless for large scale package building.])
1626)
1627
1628libo_FUZZ_ARG_ENABLE(odk,
1629    AS_HELP_STRING([--enable-odk],
1630        [Enable building the Office Development Kit, the part that extensions need to build against])
1631)
1632
1633AC_ARG_ENABLE(mpl-subset,
1634    AS_HELP_STRING([--enable-mpl-subset],
1635        [Don't compile any pieces which are not MPL or more liberally licensed])
1636)
1637
1638libo_FUZZ_ARG_ENABLE(evolution2,
1639    AS_HELP_STRING([--enable-evolution2],
1640        [Allows the built-in evolution 2 addressbook connectivity build to be
1641         enabled.])
1642)
1643
1644AC_ARG_ENABLE(avahi,
1645    AS_HELP_STRING([--enable-avahi],
1646        [Determines whether to use Avahi to advertise Impress to remote controls.])
1647)
1648
1649libo_FUZZ_ARG_ENABLE(werror,
1650    AS_HELP_STRING([--enable-werror],
1651        [Turn warnings to errors. (Has no effect in modules where the treating
1652         of warnings as errors is disabled explicitly.)]),
1653,)
1654
1655libo_FUZZ_ARG_ENABLE(assert-always-abort,
1656    AS_HELP_STRING([--enable-assert-always-abort],
1657        [make assert() failures abort even when building without --enable-debug or --enable-dbgutil.]),
1658,)
1659
1660libo_FUZZ_ARG_ENABLE(dbgutil,
1661    AS_HELP_STRING([--enable-dbgutil],
1662        [Provide debugging support from --enable-debug and include additional debugging
1663         utilities such as object counting or more expensive checks.
1664         This is the recommended option for developers.
1665         Note that this makes the build ABI incompatible, it is not possible to mix object
1666         files or libraries from a --enable-dbgutil and a --disable-dbgutil build.]))
1667
1668libo_FUZZ_ARG_ENABLE(debug,
1669    AS_HELP_STRING([--enable-debug],
1670        [Include debugging information, disable compiler optimization and inlining plus
1671         extra debugging code like assertions. Extra large build! (enables -g compiler flag).]))
1672
1673libo_FUZZ_ARG_ENABLE(split-debug,
1674    AS_HELP_STRING([--disable-split-debug],
1675        [Disable using split debug information (-gsplit-dwarf compile flag). Split debug information
1676         saves disk space and build time, but requires tools that support it (both build tools and debuggers).]))
1677
1678libo_FUZZ_ARG_ENABLE(gdb-index,
1679    AS_HELP_STRING([--disable-gdb-index],
1680        [Disables creating debug information in the gdb index format, which makes gdb start faster.
1681         The feature requires a linker that supports the --gdb-index option.]))
1682
1683libo_FUZZ_ARG_ENABLE(sal-log,
1684    AS_HELP_STRING([--enable-sal-log],
1685        [Make SAL_INFO and SAL_WARN calls do something even in a non-debug build.]))
1686
1687libo_FUZZ_ARG_ENABLE(symbols,
1688    AS_HELP_STRING([--enable-symbols],
1689        [Generate debug information.
1690         By default, enabled for --enable-debug and --enable-dbgutil, disabled
1691         otherwise. It is possible to explicitly specify gbuild build targets
1692         (where 'all' means everything, '-' prepended means to not enable, '/' appended means
1693         everything in the directory; there is no ordering, more specific overrides
1694         more general, and disabling takes precedence).
1695         Example: --enable-symbols="all -sw/ -Library_sc".]))
1696
1697libo_FUZZ_ARG_ENABLE(optimized,
1698    AS_HELP_STRING([--enable-optimized=<yes/no/debug>],
1699        [Whether to compile with optimization flags.
1700         By default, disabled for --enable-debug and --enable-dbgutil, enabled
1701         otherwise. Using 'debug' will try to use only optimizations that should
1702         not interfere with debugging. For Emscripten we default to optimized (-O1)
1703         debug build, as otherwise binaries become too large.]))
1704
1705libo_FUZZ_ARG_ENABLE(runtime-optimizations,
1706    AS_HELP_STRING([--disable-runtime-optimizations],
1707        [Statically disable certain runtime optimizations (like rtl/alloc.h or
1708         JVM JIT) that are known to interact badly with certain dynamic analysis
1709         tools (like -fsanitize=address or Valgrind).  By default, disabled iff
1710         CC contains "-fsanitize=*".  (For Valgrind, those runtime optimizations
1711         are typically disabled dynamically via RUNNING_ON_VALGRIND.)]))
1712
1713AC_ARG_WITH(valgrind,
1714    AS_HELP_STRING([--with-valgrind],
1715        [Make availability of Valgrind headers a hard requirement.]))
1716
1717libo_FUZZ_ARG_ENABLE(compiler-plugins,
1718    AS_HELP_STRING([--enable-compiler-plugins],
1719        [Enable compiler plugins that will perform additional checks during
1720         building. Enabled automatically by --enable-dbgutil.
1721         Use --enable-compiler-plugins=debug to also enable debug code in the plugins.]))
1722COMPILER_PLUGINS_DEBUG=
1723if test "$enable_compiler_plugins" = debug; then
1724    enable_compiler_plugins=yes
1725    COMPILER_PLUGINS_DEBUG=TRUE
1726fi
1727
1728libo_FUZZ_ARG_ENABLE(compiler-plugins-analyzer-pch,
1729    AS_HELP_STRING([--disable-compiler-plugins-analyzer-pch],
1730        [Disable use of precompiled headers when running the Clang compiler plugin analyzer.  Not
1731         relevant in the --disable-compiler-plugins case.]))
1732
1733libo_FUZZ_ARG_ENABLE(ooenv,
1734    AS_HELP_STRING([--enable-ooenv],
1735        [Enable ooenv for the instdir installation.]))
1736
1737AC_ARG_ENABLE(lto,
1738    AS_HELP_STRING([--enable-lto],
1739        [Enable link-time optimization. Suitable for (optimised) product builds. Building might take
1740         longer but libraries and executables are optimized for speed. For GCC, best to use the 'gold'
1741         linker.)]))
1742
1743AC_ARG_ENABLE(python,
1744    AS_HELP_STRING([--enable-python=<no/auto/system/internal/fully-internal>],
1745        [Enables or disables Python support at run-time.
1746         Also specifies what Python to use at build-time.
1747         'fully-internal' even forces the internal version for uses of Python
1748         during the build.
1749         On macOS the only choices are
1750         'internal' (default) or 'fully-internal'. Otherwise the default is 'auto'.
1751         ]))
1752
1753libo_FUZZ_ARG_ENABLE(gtk3,
1754    AS_HELP_STRING([--disable-gtk3],
1755        [Determines whether to use Gtk+ 3.0 vclplug on platforms where Gtk+ 3.0 is available.]),
1756,test "${test_gtk3}" = no -o "${enable_gtk3+set}" = set || enable_gtk3=yes)
1757
1758AC_ARG_ENABLE(gtk4,
1759    AS_HELP_STRING([--enable-gtk4],
1760        [Determines whether to use Gtk+ 4.0 vclplug on platforms where Gtk+ 4.0 is available.]))
1761
1762AC_ARG_ENABLE(atspi-tests,
1763    AS_HELP_STRING([--disable-atspi-tests],
1764        [Determines whether to enable AT-SPI2 tests for the GTK3 vclplug.]))
1765
1766AC_ARG_ENABLE(introspection,
1767    AS_HELP_STRING([--enable-introspection],
1768        [Generate files for GObject introspection.  Requires --enable-gtk3.  (Typically used by
1769         Linux distributions.)]))
1770
1771AC_ARG_ENABLE(split-app-modules,
1772    AS_HELP_STRING([--enable-split-app-modules],
1773        [Split file lists for app modules, e.g. base, calc.
1774         Has effect only with make distro-pack-install]),
1775,)
1776
1777AC_ARG_ENABLE(split-opt-features,
1778    AS_HELP_STRING([--enable-split-opt-features],
1779        [Split file lists for some optional features, e.g. pyuno, testtool.
1780         Has effect only with make distro-pack-install]),
1781,)
1782
1783libo_FUZZ_ARG_ENABLE(cairo-canvas,
1784    AS_HELP_STRING([--disable-cairo-canvas],
1785        [Determines whether to build the Cairo canvas on platforms where Cairo is available.]),
1786,)
1787
1788libo_FUZZ_ARG_ENABLE(dbus,
1789    AS_HELP_STRING([--disable-dbus],
1790        [Determines whether to enable features that depend on dbus.
1791         e.g. Presentation mode screensaver control, bluetooth presentation control, automatic font install]),
1792,test "${enable_dbus+set}" = set || enable_dbus=yes)
1793
1794libo_FUZZ_ARG_ENABLE(sdremote,
1795    AS_HELP_STRING([--disable-sdremote],
1796        [Determines whether to enable Impress remote control (i.e. the server component).]),
1797,test "${enable_sdremote+set}" = set || enable_sdremote=yes)
1798
1799libo_FUZZ_ARG_ENABLE(sdremote-bluetooth,
1800    AS_HELP_STRING([--disable-sdremote-bluetooth],
1801        [Determines whether to build sdremote with bluetooth support.
1802         Requires dbus on Linux.]))
1803
1804libo_FUZZ_ARG_ENABLE(gio,
1805    AS_HELP_STRING([--disable-gio],
1806        [Determines whether to use the GIO support.]),
1807,test "${enable_gio+set}" = set || enable_gio=yes)
1808
1809AC_ARG_ENABLE(qt5,
1810    AS_HELP_STRING([--enable-qt5],
1811        [Determines whether to use Qt5 vclplug on platforms where Qt5 is
1812         available.]),
1813,)
1814
1815AC_ARG_ENABLE(qt6,
1816    AS_HELP_STRING([--enable-qt6],
1817        [Determines whether to use Qt6 vclplug on platforms where Qt6 is
1818         available.]),
1819,)
1820
1821AC_ARG_ENABLE(qt6-multimedia,
1822    AS_HELP_STRING([--disable-qt6-multimedia],
1823        [Determines whether to enable media playback using QtMultimedia when using the qt6/kf6 VCL plugins.]))
1824
1825AC_ARG_ENABLE(kf5,
1826    AS_HELP_STRING([--enable-kf5],
1827        [Determines whether to use Qt5/KF5 vclplug on platforms where Qt5 and
1828         KF5 are available.]),
1829,)
1830
1831AC_ARG_ENABLE(kf6,
1832    AS_HELP_STRING([--enable-kf6],
1833        [Determines whether to use KF6 vclplug on platforms where Qt6 and
1834         KF6 are available.]),
1835,)
1836
1837
1838AC_ARG_ENABLE(gtk3_kde5,
1839    AS_HELP_STRING([--enable-gtk3-kde5],
1840        [Determines whether to use Gtk3 vclplug with KF5 file dialogs on
1841         platforms where Gtk3, Qt5 and Plasma is available.]),
1842,)
1843
1844AC_ARG_ENABLE(gen,
1845    AS_HELP_STRING([--enable-gen],
1846        [To select the gen backend in case of --disable-dynamic-loading.
1847         Per default auto-enabled when X11 is used.]),
1848,test "${test_gen}" = no -o "${enable_gen+set}" = set || enable_gen=yes)
1849
1850AC_ARG_ENABLE(gui,
1851    AS_HELP_STRING([--disable-gui],
1852        [Disable use of X11 or Wayland to reduce dependencies (e.g. for building LibreOfficeKit).]),
1853,enable_gui=yes)
1854
1855libo_FUZZ_ARG_ENABLE(randr,
1856    AS_HELP_STRING([--disable-randr],
1857        [Disable RandR support in the vcl project.]),
1858,test "${enable_randr+set}" = set || enable_randr=yes)
1859
1860libo_FUZZ_ARG_ENABLE(gstreamer-1-0,
1861    AS_HELP_STRING([--disable-gstreamer-1-0],
1862        [Disable building with the gstreamer 1.0 avmedia backend.]),
1863,test "${enable_gstreamer_1_0+set}" = set || enable_gstreamer_1_0=yes)
1864
1865libo_FUZZ_ARG_ENABLE([eot],
1866    [AS_HELP_STRING([--enable-eot],
1867        [Enable support for Embedded OpenType fonts.])],
1868,test "${enable_eot+set}" = set || enable_eot=no)
1869
1870libo_FUZZ_ARG_ENABLE(cve-tests,
1871    AS_HELP_STRING([--disable-cve-tests],
1872        [Prevent CVE tests to be executed]),
1873,)
1874
1875AC_ARG_ENABLE(build-opensymbol,
1876    AS_HELP_STRING([--enable-build-opensymbol],
1877        [Do not use the prebuilt opens___.ttf. Build it instead. This needs
1878         fontforge installed.]),
1879,)
1880
1881AC_ARG_ENABLE(dependency-tracking,
1882    AS_HELP_STRING([--enable-dependency-tracking],
1883        [Do not reject slow dependency extractors.])[
1884  --disable-dependency-tracking
1885                          Disables generation of dependency information.
1886                          Speed up one-time builds.],
1887,)
1888
1889AC_ARG_ENABLE(icecream,
1890    AS_HELP_STRING([--enable-icecream],
1891        [Use the 'icecream' distributed compiling tool to speedup the compilation.
1892         It defaults to /opt/icecream for the location of the icecream gcc/g++
1893         wrappers, you can override that using --with-gcc-home=/the/path switch.]),
1894,)
1895
1896AC_ARG_ENABLE(ld,
1897    AS_HELP_STRING([--enable-ld=<linker>],
1898        [Use the specified linker. Both 'gold' and 'lld' linkers generally use less memory and link faster.
1899         By default tries to use the best linker possible, use --disable-ld to use the default linker.
1900         If <linker> contains any ':', the part before the first ':' is used as the value of
1901         -fuse-ld, while the part after the first ':' is used as the value of --ld-path (which is
1902         needed for Clang 12).]),
1903,)
1904
1905AC_ARG_ENABLE(cpdb,
1906    AS_HELP_STRING([--enable-cpdb],
1907        [Build CPDB (Common Print Dialog Backends) support.]),
1908,)
1909
1910libo_FUZZ_ARG_ENABLE(cups,
1911    AS_HELP_STRING([--disable-cups],
1912        [Do not build cups support.])
1913)
1914
1915AC_ARG_ENABLE(ccache,
1916    AS_HELP_STRING([--disable-ccache],
1917        [Do not try to use ccache automatically.
1918         By default we will try to detect if ccache is available; in that case if
1919         CC/CXX are not yet set, and --enable-icecream is not given, we
1920         attempt to use ccache. --disable-ccache disables ccache completely.
1921         Additionally ccache's depend mode is enabled if possible,
1922         use --enable-ccache=nodepend to enable ccache without depend mode.
1923]),
1924,)
1925
1926AC_ARG_ENABLE(z7-debug,
1927    AS_HELP_STRING([--enable-z7-debug],
1928        [Makes the MSVC compiler use -Z7 for debugging instead of the default -Zi. Using this option takes
1929         more disk spaces but allows to use ccache. Final PDB files are created even with this option enabled.
1930         Enabled by default if ccache is detected.]))
1931
1932libo_FUZZ_ARG_ENABLE(online-update,
1933    AS_HELP_STRING([--enable-online-update],
1934        [Enable the online update service that will check for new versions of
1935         LibreOffice. Disabled by default. Requires --with-privacy-policy-url to be set.]),
1936,)
1937
1938libo_FUZZ_ARG_ENABLE(online-update-mar,
1939    AS_HELP_STRING([--enable-online-update-mar],
1940        [Enable the experimental Mozilla-like online update service that will
1941         check for new versions of LibreOffice. Disabled by default.]),
1942,)
1943
1944libo_FUZZ_ARG_WITH(online-update-mar-baseurl,
1945    AS_HELP_STRING([--with-online-update-mar-baseurl=...],
1946        [Set the base URL value for --enable-online-update-mar.
1947         (Can be left off for debug purposes, even if that may render the feature
1948         non-functional.)]),
1949,)
1950
1951libo_FUZZ_ARG_WITH(online-update-mar-certificateder,
1952    AS_HELP_STRING([--with-online-update-mar-certificateder=...],
1953        [Set the certificate DER value for --enable-online-update-mar.
1954         (Can be left off for debug purposes, even if that may render the feature
1955         non-functional.)]),
1956,)
1957
1958libo_FUZZ_ARG_WITH(online-update-mar-certificatename,
1959    AS_HELP_STRING([--with-online-update-mar-certificatename=...],
1960        [Set the certificate name value for --enable-online-update-mar.
1961         (Can be left off for debug purposes, even if that may render the feature
1962         non-functional.)]),
1963,)
1964
1965libo_FUZZ_ARG_WITH(online-update-mar-certificatepath,
1966    AS_HELP_STRING([--with-online-update-mar-certificatepath=...],
1967        [Set the certificate path value for --enable-online-update-mar.
1968         (Can be left off for debug purposes, even if that may render the feature
1969         non-functional.)]),
1970,)
1971
1972libo_FUZZ_ARG_ENABLE(extension-update,
1973    AS_HELP_STRING([--disable-extension-update],
1974        [Disable possibility to update installed extensions.]),
1975,)
1976
1977libo_FUZZ_ARG_ENABLE(release-build,
1978    AS_HELP_STRING([--enable-release-build],
1979        [Enable release build. Note that the "release build" choice is orthogonal to
1980         whether symbols are present, debug info is generated, or optimization
1981         is done.
1982         See https://wiki.documentfoundation.org/Development/DevBuild]),
1983,)
1984
1985libo_FUZZ_ARG_ENABLE(hardening-flags,
1986    AS_HELP_STRING([--enable-hardening-flags],
1987        [Enable automatically using hardening compiler flags. Distros typically
1988         instead use their default configuration via CXXFLAGS, etc. But this provides a
1989         convenient set of default hardening flags for non-distros]),
1990,)
1991
1992AC_ARG_ENABLE(windows-build-signing,
1993    AS_HELP_STRING([--enable-windows-build-signing],
1994        [Enable signing of windows binaries (*.exe, *.dll)]),
1995,)
1996
1997AC_ARG_ENABLE(silent-msi,
1998    AS_HELP_STRING([--enable-silent-msi],
1999        [Enable MSI with LIMITUI=1 (silent install).]),
2000,)
2001
2002AC_ARG_ENABLE(wix,
2003    AS_HELP_STRING([--enable-wix],
2004        [Build Windows installer using WiX.]),
2005,)
2006
2007AC_ARG_ENABLE(macosx-code-signing,
2008    AS_HELP_STRING([--enable-macosx-code-signing=<identity>],
2009        [Sign executables, dylibs, frameworks and the app bundle. If you
2010         don't provide an identity the first suitable certificate
2011         in your keychain is used.]),
2012,)
2013
2014AC_ARG_ENABLE(macosx-package-signing,
2015    AS_HELP_STRING([--enable-macosx-package-signing=<identity>],
2016        [Create a .pkg suitable for uploading to the Mac App Store and sign
2017         it. If you don't provide an identity the first suitable certificate
2018         in your keychain is used.]),
2019,)
2020
2021AC_ARG_ENABLE(macosx-sandbox,
2022    AS_HELP_STRING([--enable-macosx-sandbox],
2023        [Make the app bundle run in a sandbox. Requires code signing.
2024         Is required by apps distributed in the Mac App Store, and implies
2025         adherence to App Store rules.]),
2026,)
2027
2028AC_ARG_WITH(macosx-bundle-identifier,
2029    AS_HELP_STRING([--with-macosx-bundle-identifier=tld.mumble.orifice.TheOffice],
2030        [Define the macOS bundle identifier. Default is the somewhat weird
2031         org.libreoffice.script ("script", huh?).]),
2032,with_macosx_bundle_identifier=org.libreoffice.script)
2033
2034AC_ARG_WITH(macosx-provisioning-profile,
2035    AS_HELP_STRING([--with-macosx-provisioning-profile=/path/to/mac.provisionprofile],
2036        [Specify the path to a provisioning profile to use]),
2037,)
2038
2039AC_ARG_WITH(product-name,
2040    AS_HELP_STRING([--with-product-name='My Own Office Suite'],
2041        [Define the product name. Default is AC_PACKAGE_NAME.]),
2042,with_product_name=$PRODUCTNAME)
2043
2044libo_FUZZ_ARG_ENABLE(community-flavor,
2045    AS_HELP_STRING([--disable-community-flavor],
2046        [Disable the Community branding.]),
2047,)
2048
2049AC_ARG_WITH(package-version,
2050    AS_HELP_STRING([--with-package-version='3.1.4.5'],
2051        [Define the package version. Default is AC_PACKAGE_VERSION. Use only if you distribute an own build for macOS.]),
2052,)
2053
2054libo_FUZZ_ARG_ENABLE(readonly-installset,
2055    AS_HELP_STRING([--enable-readonly-installset],
2056        [Prevents any attempts by LibreOffice to write into its installation. That means
2057         at least that no "system-wide" extensions can be added. Partly experimental work in
2058         progress, probably not fully implemented. Always enabled for macOS.]),
2059,)
2060
2061libo_FUZZ_ARG_ENABLE(mariadb-sdbc,
2062    AS_HELP_STRING([--disable-mariadb-sdbc],
2063        [Disable the build of the MariaDB/MySQL-SDBC driver.])
2064)
2065
2066libo_FUZZ_ARG_ENABLE(postgresql-sdbc,
2067    AS_HELP_STRING([--disable-postgresql-sdbc],
2068        [Disable the build of the PostgreSQL-SDBC driver.])
2069)
2070
2071libo_FUZZ_ARG_ENABLE(lotuswordpro,
2072    AS_HELP_STRING([--disable-lotuswordpro],
2073        [Disable the build of the Lotus Word Pro filter.]),
2074,test "${enable_lotuswordpro+set}" = set || enable_lotuswordpro=yes)
2075
2076libo_FUZZ_ARG_ENABLE(firebird-sdbc,
2077    AS_HELP_STRING([--disable-firebird-sdbc],
2078        [Disable the build of the Firebird-SDBC driver if it doesn't compile for you.]),
2079,test "${enable_firebird_sdbc+set}" = set || enable_firebird_sdbc=yes)
2080
2081AC_ARG_ENABLE(bogus-pkg-config,
2082    AS_HELP_STRING([--enable-bogus-pkg-config],
2083        [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.]),
2084)
2085
2086AC_ARG_ENABLE(openssl,
2087    AS_HELP_STRING([--disable-openssl],
2088        [Disable using libssl/libcrypto from OpenSSL. If disabled,
2089         components will use NSS. Work in progress,
2090         use only if you are hacking on it.]),
2091,enable_openssl=yes)
2092
2093libo_FUZZ_ARG_ENABLE(cipher-openssl-backend,
2094    AS_HELP_STRING([--enable-cipher-openssl-backend],
2095        [Enable using OpenSSL as the actual implementation of the rtl/cipher.h functionality.
2096         Requires --enable-openssl.]))
2097
2098AC_ARG_ENABLE(nss,
2099    AS_HELP_STRING([--disable-nss],
2100        [Disable using NSS. If disabled,
2101         components will use openssl. Work in progress,
2102         use only if you are hacking on it.]),
2103,enable_nss=yes)
2104
2105AC_ARG_ENABLE(library-bin-tar,
2106    AS_HELP_STRING([--enable-library-bin-tar],
2107        [Enable the building and reused of tarball of binary build for some 'external' libraries.
2108        Some libraries can save their build result in a tarball
2109        stored in TARFILE_LOCATION. That binary tarball is
2110        uniquely identified by the source tarball,
2111        the content of the config_host.mk file and the content
2112        of the top-level directory in core for that library
2113        If this option is enabled, then if such a tarfile exist, it will be untarred
2114        instead of the source tarfile, and the build step will be skipped for that
2115        library.
2116        If a proper tarfile does not exist, then the normal source-based
2117        build is done for that library and a proper binary tarfile is created
2118        for the next time.]),
2119)
2120
2121AC_ARG_ENABLE(dconf,
2122    AS_HELP_STRING([--disable-dconf],
2123        [Disable the dconf configuration backend (enabled by default where
2124         available).]))
2125
2126libo_FUZZ_ARG_ENABLE(formula-logger,
2127    AS_HELP_STRING(
2128        [--enable-formula-logger],
2129        [Enable formula logger for logging formula calculation flow in Calc.]
2130    )
2131)
2132
2133AC_ARG_ENABLE(ldap,
2134    AS_HELP_STRING([--disable-ldap],
2135        [Disable LDAP support.]),
2136,enable_ldap=yes)
2137
2138AC_ARG_ENABLE(opencl,
2139    AS_HELP_STRING([--disable-opencl],
2140        [Disable OpenCL support.]),
2141,enable_opencl=yes)
2142
2143libo_FUZZ_ARG_ENABLE(librelogo,
2144    AS_HELP_STRING([--disable-librelogo],
2145        [Do not build LibreLogo.]),
2146,enable_librelogo=yes)
2147
2148AC_ARG_ENABLE(wasm-strip,
2149    AS_HELP_STRING([--enable-wasm-strip],
2150        [Strip the static build like for WASM/emscripten platform.]),
2151,)
2152
2153AC_ARG_WITH(main-module,
2154    AS_HELP_STRING([--with-main-module=<writer/calc>],
2155        [Specify which main module to build for wasm.
2156        Default value is 'writer'.]),
2157,)
2158
2159AC_ARG_ENABLE(xmlhelp,
2160    AS_HELP_STRING([--disable-xmlhelp],
2161        [Disable XML help support]),
2162,enable_xmlhelp=yes)
2163
2164AC_ARG_ENABLE(customtarget-components,
2165    AS_HELP_STRING([--enable-customtarget-components],
2166        [Generates the static UNO object constructor mapping from the build.]))
2167
2168AC_ARG_ENABLE(cli,
2169    AS_HELP_STRING([--disable-cli],
2170        [Disable the generation of old CLI bindings.]),
2171,enable_cli=yes)
2172
2173AC_ARG_ENABLE(dotnet,
2174    AS_HELP_STRING([--enable-dotnet],
2175        [Enables or disables .NET 8.0 support and bindings generation.]))
2176
2177dnl ===================================================================
2178dnl Optional Packages (--with/without-)
2179dnl ===================================================================
2180
2181AC_ARG_WITH(gcc-home,
2182    AS_HELP_STRING([--with-gcc-home],
2183        [Specify the location of gcc/g++ manually. This can be used in conjunction
2184         with --enable-icecream when icecream gcc/g++ wrappers are installed in a
2185         non-default path.]),
2186,)
2187
2188AC_ARG_WITH(gnu-patch,
2189    AS_HELP_STRING([--with-gnu-patch],
2190        [Specify location of GNU patch on Solaris or FreeBSD.]),
2191,)
2192
2193AC_ARG_WITH(build-platform-configure-options,
2194    AS_HELP_STRING([--with-build-platform-configure-options],
2195        [Specify options for the configure script run for the *build* platform in a cross-compilation]),
2196,)
2197
2198AC_ARG_WITH(gnu-cp,
2199    AS_HELP_STRING([--with-gnu-cp],
2200        [Specify location of GNU cp on Solaris or FreeBSD.]),
2201,)
2202
2203AC_ARG_WITH(external-tar,
2204    AS_HELP_STRING([--with-external-tar=<TARFILE_PATH>],
2205        [Specify an absolute path of where to find (and store) tarfiles.]),
2206    TARFILE_LOCATION=$withval ,
2207)
2208
2209AC_ARG_WITH(referenced-git,
2210    AS_HELP_STRING([--with-referenced-git=<OTHER_CHECKOUT_DIR>],
2211        [Specify another checkout directory to reference. This makes use of
2212                 git submodule update --reference, and saves a lot of diskspace
2213                 when having multiple trees side-by-side.]),
2214    GIT_REFERENCE_SRC=$withval ,
2215)
2216
2217AC_ARG_WITH(linked-git,
2218    AS_HELP_STRING([--with-linked-git=<submodules repo basedir>],
2219        [Specify a directory where the repositories of submodules are located.
2220         This uses a method similar to git-new-workdir to get submodules.]),
2221    GIT_LINK_SRC=$withval ,
2222)
2223
2224AC_ARG_WITH(galleries,
2225    AS_HELP_STRING([--with-galleries],
2226        [Specify how galleries should be built. It is possible either to
2227         build these internally from source ("build"),
2228         or to disable them ("no")]),
2229)
2230
2231AC_ARG_WITH(templates,
2232    AS_HELP_STRING([--with-templates],
2233        [Specify we build with or without template files. It is possible either to
2234         build with templates ("yes"),
2235         or to disable them ("no")]),
2236)
2237
2238AC_ARG_WITH(theme,
2239    AS_HELP_STRING([--with-theme="theme1 theme2..."],
2240        [Choose which themes to include. By default those themes with an '*' are included.
2241         Possible choices: *breeze, *breeze_dark, *breeze_dark_svg, *breeze_svg,
2242         *colibre, *colibre_svg, *colibre_dark, *colibre_dark_svg,
2243         *elementary, *elementary_svg,
2244         *karasa_jaga, *karasa_jaga_svg,
2245         *sifr, *sifr_dark, *sifr_dark_svg, *sifr_svg,
2246         *sukapura, *sukapura_dark, *sukapura_dark_svg, *sukapura_svg.]),
2247,)
2248
2249libo_FUZZ_ARG_WITH(helppack-integration,
2250    AS_HELP_STRING([--without-helppack-integration],
2251        [It will not integrate the helppacks to the installer
2252         of the product. Please use this switch to use the online help
2253         or separate help packages.]),
2254,)
2255
2256libo_FUZZ_ARG_WITH(fonts,
2257    AS_HELP_STRING([--without-fonts],
2258        [LibreOffice includes some third-party fonts to provide a reliable basis for
2259         help content, templates, samples, etc. When these fonts are already
2260         known to be available on the system then you should use this option.]),
2261,)
2262
2263AC_ARG_WITH(epm,
2264    AS_HELP_STRING([--with-epm],
2265        [Decides which epm to use. Default is to use the one from the system if
2266         one is built. When either this is not there or you say =internal epm
2267         will be built.]),
2268,)
2269
2270AC_ARG_WITH(package-format,
2271    AS_HELP_STRING([--with-package-format],
2272        [Specify package format(s) for LibreOffice installation sets. The
2273         implicit --without-package-format leads to no installation sets being
2274         generated. Possible values: archive, bsd, deb, dmg,
2275         installed, msi, pkg, and rpm.
2276         Example: --with-package-format='deb rpm']),
2277,)
2278
2279AC_ARG_WITH(tls,
2280    AS_HELP_STRING([--with-tls],
2281        [Decides which TLS/SSL and cryptographic implementations to use for
2282         LibreOffice's code. Default is to use NSS although OpenSSL is also
2283         possible. Notice that selecting NSS restricts the usage of OpenSSL
2284         in LO's code but selecting OpenSSL doesn't restrict by now the
2285         usage of NSS in LO's code. Possible values: openssl, nss.
2286         Example: --with-tls="nss"]),
2287,)
2288
2289AC_ARG_WITH(system-libs,
2290    AS_HELP_STRING([--with-system-libs],
2291        [Use libraries already on system -- enables all --with-system-* flags.]),
2292,)
2293
2294AC_ARG_WITH(system-bzip2,
2295    AS_HELP_STRING([--with-system-bzip2],
2296        [Use bzip2 already on system. Used when --enable-online-update-mar
2297        or --enable-python=internal]),,
2298    [with_system_bzip2="$with_system_libs"])
2299
2300AC_ARG_WITH(system-headers,
2301    AS_HELP_STRING([--with-system-headers],
2302        [Use headers already on system -- enables all --with-system-* flags for
2303         external packages whose headers are the only entities used i.e.
2304         boost/odbc/sane-header(s).]),,
2305    [with_system_headers="$with_system_libs"])
2306
2307AC_ARG_WITH(system-jars,
2308    AS_HELP_STRING([--without-system-jars],
2309        [When building with --with-system-libs, also the needed jars are expected
2310         on the system. Use this to disable that]),,
2311    [with_system_jars="$with_system_libs"])
2312
2313AC_ARG_WITH(system-cairo,
2314    AS_HELP_STRING([--with-system-cairo],
2315        [Use cairo libraries already on system.  Happens automatically for
2316         (implicit) --enable-gtk3.]))
2317
2318AC_ARG_WITH(system-epoxy,
2319    AS_HELP_STRING([--with-system-epoxy],
2320        [Use epoxy libraries already on system.  Happens automatically for
2321         (implicit) --enable-gtk3.]),,
2322       [with_system_epoxy="$with_system_libs"])
2323
2324AC_ARG_WITH(myspell-dicts,
2325    AS_HELP_STRING([--with-myspell-dicts],
2326        [Adds myspell dictionaries to the LibreOffice installation set]),
2327,)
2328
2329AC_ARG_WITH(system-dicts,
2330    AS_HELP_STRING([--without-system-dicts],
2331        [Do not use dictionaries from system paths.]),
2332,)
2333
2334AC_ARG_WITH(external-dict-dir,
2335    AS_HELP_STRING([--with-external-dict-dir],
2336        [Specify external dictionary dir.]),
2337,)
2338
2339AC_ARG_WITH(external-hyph-dir,
2340    AS_HELP_STRING([--with-external-hyph-dir],
2341        [Specify external hyphenation pattern dir.]),
2342,)
2343
2344AC_ARG_WITH(external-thes-dir,
2345    AS_HELP_STRING([--with-external-thes-dir],
2346        [Specify external thesaurus dir.]),
2347,)
2348
2349AC_ARG_WITH(system-zlib,
2350    AS_HELP_STRING([--with-system-zlib],
2351        [Use zlib already on system.]),,
2352    [with_system_zlib=auto])
2353
2354AC_ARG_WITH(system-jpeg,
2355    AS_HELP_STRING([--with-system-jpeg],
2356        [Use jpeg already on system.]),,
2357    [with_system_jpeg="$with_system_libs"])
2358
2359AC_ARG_WITH(system-expat,
2360    AS_HELP_STRING([--with-system-expat],
2361        [Use expat already on system.]),,
2362    [with_system_expat="$with_system_libs"])
2363
2364AC_ARG_WITH(system-libxml,
2365    AS_HELP_STRING([--with-system-libxml],
2366        [Use libxml/libxslt already on system.]),,
2367    [with_system_libxml=auto])
2368
2369AC_ARG_WITH(system-openldap,
2370    AS_HELP_STRING([--with-system-openldap],
2371        [Use the OpenLDAP LDAP SDK already on system.]),,
2372    [with_system_openldap="$with_system_libs"])
2373
2374libo_FUZZ_ARG_ENABLE(poppler,
2375    AS_HELP_STRING([--disable-poppler],
2376        [Disable building Poppler.])
2377)
2378
2379AC_ARG_WITH(system-poppler,
2380    AS_HELP_STRING([--with-system-poppler],
2381        [Use system poppler (only needed for PDF import).]),,
2382    [with_system_poppler="$with_system_libs"])
2383
2384AC_ARG_WITH(system-abseil,
2385    AS_HELP_STRING([--with-system-abseil],
2386        [Use the abseil libraries already on system.]),,
2387    [with_system_abseil="$with_system_libs"])
2388
2389AC_ARG_WITH(system-openjpeg,
2390    AS_HELP_STRING([--with-system-openjpeg],
2391        [Use the OpenJPEG library already on system.]),,
2392    [with_system_openjpeg="$with_system_libs"])
2393
2394libo_FUZZ_ARG_ENABLE(gpgmepp,
2395    AS_HELP_STRING([--disable-gpgmepp],
2396        [Disable building gpgmepp. Do not use in normal cases unless you want to fix potential problems it causes.])
2397)
2398
2399AC_ARG_WITH(system-gpgmepp,
2400    AS_HELP_STRING([--with-system-gpgmepp],
2401        [Use gpgmepp already on system]),,
2402    [with_system_gpgmepp="$with_system_libs"])
2403
2404AC_ARG_WITH(system-mariadb,
2405    AS_HELP_STRING([--with-system-mariadb],
2406        [Use MariaDB/MySQL libraries already on system.]),,
2407    [with_system_mariadb="$with_system_libs"])
2408
2409AC_ARG_ENABLE(bundle-mariadb,
2410    AS_HELP_STRING([--enable-bundle-mariadb],
2411        [When using MariaDB/MySQL libraries already on system, bundle them with the MariaDB Connector/LibreOffice.])
2412)
2413
2414AC_ARG_WITH(system-postgresql,
2415    AS_HELP_STRING([--with-system-postgresql],
2416        [Use PostgreSQL libraries already on system, for building the PostgreSQL-SDBC
2417         driver. If pg_config is not in PATH, use PGCONFIG to point to it.]),,
2418    [with_system_postgresql="$with_system_libs"])
2419
2420AC_ARG_WITH(libpq-path,
2421    AS_HELP_STRING([--with-libpq-path=<absolute path to your libpq installation>],
2422        [Use this PostgreSQL C interface (libpq) installation for building
2423         the PostgreSQL-SDBC extension.]),
2424,)
2425
2426AC_ARG_WITH(system-firebird,
2427    AS_HELP_STRING([--with-system-firebird],
2428        [Use Firebird libraries already on system, for building the Firebird-SDBC
2429         driver. If fb_config is not in PATH, use FBCONFIG to point to it.]),,
2430    [with_system_firebird="$with_system_libs"])
2431
2432AC_ARG_WITH(system-libtommath,
2433            AS_HELP_STRING([--with-system-libtommath],
2434                           [Use libtommath already on system]),,
2435            [with_system_libtommath="$with_system_libs"])
2436
2437AC_ARG_WITH(system-hsqldb,
2438    AS_HELP_STRING([--with-system-hsqldb],
2439        [Use hsqldb already on system.]))
2440
2441AC_ARG_WITH(hsqldb-jar,
2442    AS_HELP_STRING([--with-hsqldb-jar=JARFILE],
2443        [Specify path to jarfile manually.]),
2444    HSQLDB_JAR=$withval)
2445
2446libo_FUZZ_ARG_ENABLE(scripting-beanshell,
2447    AS_HELP_STRING([--disable-scripting-beanshell],
2448        [Disable support for scripts in BeanShell.]),
2449,
2450)
2451
2452AC_ARG_WITH(system-beanshell,
2453    AS_HELP_STRING([--with-system-beanshell],
2454        [Use beanshell already on system.]),,
2455    [with_system_beanshell="$with_system_jars"])
2456
2457AC_ARG_WITH(beanshell-jar,
2458    AS_HELP_STRING([--with-beanshell-jar=JARFILE],
2459        [Specify path to jarfile manually.]),
2460    BSH_JAR=$withval)
2461
2462libo_FUZZ_ARG_ENABLE(scripting-javascript,
2463    AS_HELP_STRING([--disable-scripting-javascript],
2464        [Disable support for scripts in JavaScript.]),
2465,
2466)
2467
2468AC_ARG_WITH(system-rhino,
2469    AS_HELP_STRING([--with-system-rhino],
2470        [Use rhino already on system.]),,
2471    [with_system_rhino="$with_system_jars"])
2472
2473AC_ARG_WITH(rhino-jar,
2474    AS_HELP_STRING([--with-rhino-jar=JARFILE],
2475        [Specify path to jarfile manually.]),
2476    RHINO_JAR=$withval)
2477
2478AC_ARG_WITH(system-jfreereport,
2479    AS_HELP_STRING([--with-system-jfreereport],
2480        [Use JFreeReport already on system.]),,
2481    [with_system_jfreereport="$with_system_jars"])
2482
2483AC_ARG_WITH(sac-jar,
2484    AS_HELP_STRING([--with-sac-jar=JARFILE],
2485        [Specify path to jarfile manually.]),
2486    SAC_JAR=$withval)
2487
2488AC_ARG_WITH(libxml-jar,
2489    AS_HELP_STRING([--with-libxml-jar=JARFILE],
2490        [Specify path to jarfile manually.]),
2491    LIBXML_JAR=$withval)
2492
2493AC_ARG_WITH(flute-jar,
2494    AS_HELP_STRING([--with-flute-jar=JARFILE],
2495        [Specify path to jarfile manually.]),
2496    FLUTE_JAR=$withval)
2497
2498AC_ARG_WITH(jfreereport-jar,
2499    AS_HELP_STRING([--with-jfreereport-jar=JARFILE],
2500        [Specify path to jarfile manually.]),
2501    JFREEREPORT_JAR=$withval)
2502
2503AC_ARG_WITH(liblayout-jar,
2504    AS_HELP_STRING([--with-liblayout-jar=JARFILE],
2505        [Specify path to jarfile manually.]),
2506    LIBLAYOUT_JAR=$withval)
2507
2508AC_ARG_WITH(libloader-jar,
2509    AS_HELP_STRING([--with-libloader-jar=JARFILE],
2510        [Specify path to jarfile manually.]),
2511    LIBLOADER_JAR=$withval)
2512
2513AC_ARG_WITH(libformula-jar,
2514    AS_HELP_STRING([--with-libformula-jar=JARFILE],
2515        [Specify path to jarfile manually.]),
2516    LIBFORMULA_JAR=$withval)
2517
2518AC_ARG_WITH(librepository-jar,
2519    AS_HELP_STRING([--with-librepository-jar=JARFILE],
2520        [Specify path to jarfile manually.]),
2521    LIBREPOSITORY_JAR=$withval)
2522
2523AC_ARG_WITH(libfonts-jar,
2524    AS_HELP_STRING([--with-libfonts-jar=JARFILE],
2525        [Specify path to jarfile manually.]),
2526    LIBFONTS_JAR=$withval)
2527
2528AC_ARG_WITH(libserializer-jar,
2529    AS_HELP_STRING([--with-libserializer-jar=JARFILE],
2530        [Specify path to jarfile manually.]),
2531    LIBSERIALIZER_JAR=$withval)
2532
2533AC_ARG_WITH(libbase-jar,
2534    AS_HELP_STRING([--with-libbase-jar=JARFILE],
2535        [Specify path to jarfile manually.]),
2536    LIBBASE_JAR=$withval)
2537
2538AC_ARG_WITH(system-odbc,
2539    AS_HELP_STRING([--with-system-odbc],
2540        [Use the odbc headers already on system.]),,
2541    [with_system_odbc="auto"])
2542
2543AC_ARG_WITH(system-sane,
2544    AS_HELP_STRING([--with-system-sane],
2545        [Use sane.h already on system.]),,
2546    [with_system_sane="$with_system_headers"])
2547
2548AC_ARG_WITH(system-bluez,
2549    AS_HELP_STRING([--with-system-bluez],
2550        [Use bluetooth.h already on system.]),,
2551    [with_system_bluez="$with_system_headers"])
2552
2553AC_ARG_WITH(system-boost,
2554    AS_HELP_STRING([--with-system-boost],
2555        [Use boost already on system.]),,
2556    [with_system_boost="$with_system_headers"])
2557
2558AC_ARG_WITH(system-dragonbox,
2559    AS_HELP_STRING([--with-system-dragonbox],
2560        [Use dragonbox already on system.]),,
2561    [with_system_dragonbox="$with_system_headers"])
2562
2563AC_ARG_WITH(system-frozen,
2564    AS_HELP_STRING([--with-system-frozen],
2565        [Use frozen already on system.]),,
2566    [with_system_frozen="$with_system_headers"])
2567
2568AC_ARG_WITH(system-libfixmath,
2569    AS_HELP_STRING([--with-system-libfixmath],
2570        [Use libfixmath already on system.]),,
2571    [with_system_libfixmath="$with_system_libs"])
2572
2573AC_ARG_WITH(system-glm,
2574    AS_HELP_STRING([--with-system-glm],
2575        [Use glm already on system.]),,
2576    [with_system_glm="$with_system_headers"])
2577
2578AC_ARG_WITH(system-hunspell,
2579    AS_HELP_STRING([--with-system-hunspell],
2580        [Use libhunspell already on system.]),,
2581    [with_system_hunspell="$with_system_libs"])
2582
2583libo_FUZZ_ARG_ENABLE(cairo-rgba,
2584    AS_HELP_STRING([--enable-cairo-rgba],
2585        [Use RGBA order, instead of default BRGA. Not possible with --with-system-cairo]))
2586
2587libo_FUZZ_ARG_ENABLE(zxing,
2588    AS_HELP_STRING([--disable-zxing],
2589       [Disable use of zxing external library.]))
2590
2591AC_ARG_WITH(system-zxing,
2592    AS_HELP_STRING([--with-system-zxing],
2593        [Use libzxing already on system.]),,
2594    [with_system_zxing="$with_system_libs"])
2595
2596AC_ARG_WITH(system-zxcvbn,
2597    AS_HELP_STRING([--with-system-zxcvbn],
2598        [Use libzxcvbn already on system.]),,
2599    [with_system_zxcvbn="$with_system_libs"])
2600
2601AC_ARG_WITH(system-box2d,
2602    AS_HELP_STRING([--with-system-box2d],
2603        [Use box2d already on system.]),,
2604    [with_system_box2d="$with_system_libs"])
2605
2606AC_ARG_WITH(system-mythes,
2607    AS_HELP_STRING([--with-system-mythes],
2608        [Use mythes already on system.]),,
2609    [with_system_mythes="$with_system_libs"])
2610
2611AC_ARG_WITH(system-altlinuxhyph,
2612    AS_HELP_STRING([--with-system-altlinuxhyph],
2613        [Use ALTLinuxhyph already on system.]),,
2614    [with_system_altlinuxhyph="$with_system_libs"])
2615
2616AC_ARG_WITH(system-lpsolve,
2617    AS_HELP_STRING([--with-system-lpsolve],
2618        [Use lpsolve already on system.]),,
2619    [with_system_lpsolve="$with_system_libs"])
2620
2621AC_ARG_WITH(system-coinmp,
2622    AS_HELP_STRING([--with-system-coinmp],
2623        [Use CoinMP already on system.]),,
2624    [with_system_coinmp="$with_system_libs"])
2625
2626AC_ARG_WITH(system-liblangtag,
2627    AS_HELP_STRING([--with-system-liblangtag],
2628        [Use liblangtag library already on system.]),,
2629    [with_system_liblangtag="$with_system_libs"])
2630
2631AC_ARG_WITH(system-lockfile,
2632    AS_HELP_STRING([--with-system-lockfile[=file]],
2633        [Detect a system lockfile program or use the \$file argument.]))
2634
2635AC_ARG_WITH(webdav,
2636    AS_HELP_STRING([--without-webdav],
2637        [Disable WebDAV support in the UCB.]))
2638
2639AC_ARG_WITH(linker-hash-style,
2640    AS_HELP_STRING([--with-linker-hash-style],
2641        [Use linker with --hash-style=<style> when linking shared objects.
2642         Possible values: "sysv", "gnu", "both". The default value is "gnu"
2643         if supported on the build system, and "sysv" otherwise.]))
2644
2645AC_ARG_WITH(jdk-home,
2646    AS_HELP_STRING([--with-jdk-home=<absolute path to JDK home>],
2647        [If you have installed JDK 8 or later on your system please supply the
2648         path here. Note that this is not the location of the java command but the
2649         location of the entire distribution. In case of cross-compiling, this
2650         is the JDK of the host os. Use --with-build-platform-configure-options
2651         to point to a different build platform JDK.]),
2652,)
2653
2654AC_ARG_WITH(help,
2655    AS_HELP_STRING([--with-help],
2656        [Enable the build of help. There is a special parameter "common" that
2657         can be used to bundle only the common part, .e.g help-specific icons.
2658         This is useful when you build the helpcontent separately.])
2659    [
2660                          Usage:     --with-help    build the old local help
2661                                 --without-help     no local help (default)
2662                                 --with-help=html   build the new HTML local help
2663                                 --with-help=online build the new HTML online help
2664    ],
2665,)
2666
2667AC_ARG_WITH(omindex,
2668   AS_HELP_STRING([--with-omindex],
2669        [Enable the support of xapian-omega index for online help.])
2670   [
2671                         Usage: --with-omindex=server prepare the pages for omindex
2672                                but let xapian-omega be built in server.
2673                                --with-omindex=noxap do not prepare online pages
2674                                for xapian-omega
2675  ],
2676,)
2677
2678libo_FUZZ_ARG_WITH(java,
2679    AS_HELP_STRING([--with-java=<java command>],
2680        [Specify the name of the Java interpreter command. Typically "java"
2681         which is the default.
2682
2683         To build without support for Java components, applets, accessibility
2684         or the XML filters written in Java, use --without-java or --with-java=no.]),
2685    [ test -z "$with_java" -o "$with_java" = "yes" && with_java=java ],
2686    [ test -z "$with_java" -o "$with_java" = "yes" && with_java=java ]
2687)
2688
2689AC_ARG_WITH(jvm-path,
2690    AS_HELP_STRING([--with-jvm-path=<absolute path to parent of jvm home>],
2691        [Use a specific JVM search path at runtime.
2692         e.g. use --with-jvm-path=/usr/lib/ to find JRE/JDK in /usr/lib/jvm/]),
2693,)
2694
2695AC_ARG_WITH(ant-home,
2696    AS_HELP_STRING([--with-ant-home=<absolute path to Ant home>],
2697        [If you have installed Apache Ant on your system, please supply the path here.
2698         Note that this is not the location of the Ant binary but the location
2699         of the entire distribution.]),
2700,)
2701
2702AC_ARG_WITH(symbol-config,
2703    AS_HELP_STRING([--with-symbol-config],
2704        [Configuration for the crashreport symbol upload]),
2705        [],
2706        [with_symbol_config=no])
2707
2708AC_ARG_WITH(export-validation,
2709    AS_HELP_STRING([--without-export-validation],
2710        [Disable validating OOXML and ODF files as exported from in-tree tests.]),
2711,with_export_validation=auto)
2712
2713AC_ARG_WITH(bffvalidator,
2714    AS_HELP_STRING([--with-bffvalidator=<absolute path to BFFValidator>],
2715        [Enables export validation for Microsoft Binary formats (doc, xls, ppt).
2716         Requires installed Microsoft Office Binary File Format Validator.
2717         Note: export-validation (--with-export-validation) is required to be turned on.
2718         See https://web.archive.org/web/20200804155745/https://www.microsoft.com/en-us/download/details.aspx?id=26794]),
2719,with_bffvalidator=no)
2720
2721libo_FUZZ_ARG_WITH(junit,
2722    AS_HELP_STRING([--with-junit=<absolute path to JUnit 4 jar>],
2723        [Specifies the JUnit 4 jar file to use for JUnit-based tests.
2724         --without-junit disables those tests. Not relevant in the --without-java case.]),
2725,with_junit=yes)
2726
2727AC_ARG_WITH(hamcrest,
2728    AS_HELP_STRING([--with-hamcrest=<absolute path to hamcrest jar>],
2729        [Specifies the hamcrest jar file to use for JUnit-based tests.
2730         --without-junit disables those tests. Not relevant in the --without-java case.]),
2731,with_hamcrest=yes)
2732
2733AC_ARG_WITH(perl-home,
2734    AS_HELP_STRING([--with-perl-home=<abs. path to Perl 5 home>],
2735        [If you have installed Perl 5 Distribution, on your system, please
2736         supply the path here. Note that this is not the location of the Perl
2737         binary but the location of the entire distribution.]),
2738,)
2739
2740libo_FUZZ_ARG_WITH(doxygen,
2741    AS_HELP_STRING(
2742        [--with-doxygen=<absolute path to doxygen executable>],
2743        [Specifies the doxygen executable to use when generating ODK C/C++
2744         documentation. --without-doxygen disables generation of ODK C/C++
2745         documentation. Not relevant in the --disable-odk case.]),
2746,with_doxygen=yes)
2747
2748AC_ARG_WITH(visual-studio,
2749    AS_HELP_STRING([--with-visual-studio=<2019/2022/2022preview>],
2750        [Specify which Visual Studio version to use in case several are
2751         installed. Currently 2019 (default) and 2022 are supported.]),
2752,)
2753
2754AC_ARG_WITH(windows-sdk,
2755    AS_HELP_STRING([--with-windows-sdk=<8.0(A)/8.1(A)/10.0>],
2756        [Specify which Windows SDK, or "Windows Kit", version to use
2757         in case the one that came with the selected Visual Studio
2758         is not what you want for some reason. Note that not all compiler/SDK
2759         combinations are supported. The intent is that this option should not
2760         be needed.]),
2761,)
2762
2763AC_ARG_WITH(lang,
2764    AS_HELP_STRING([--with-lang="es sw tu cs sk"],
2765        [Use this option to build LibreOffice with additional UI language support.
2766         English (US) is always included by default.
2767         Separate multiple languages with space.
2768         For all languages, use --with-lang=ALL.]),
2769,)
2770
2771AC_ARG_WITH(locales,
2772    AS_HELP_STRING([--with-locales="en es pt fr zh kr ja"],
2773        [Use this option to limit the locale information built in.
2774         Separate multiple locales with space.
2775         Very experimental and might well break stuff.
2776         Just a desperate measure to shrink code and data size.
2777         By default all the locales available is included.
2778         Just works with --disable-dynloading. Defaults to "ALL".
2779         This option is completely unrelated to --with-lang.])
2780    [
2781                          Affects also our character encoding conversion
2782                          tables for encodings mainly targeted for a
2783                          particular locale, like EUC-CN and EUC-TW for
2784                          zh, ISO-2022-JP for ja.
2785
2786                          Affects also our add-on break iterator data for
2787                          some languages.
2788
2789                          For the default, all locales, don't use this switch at all.
2790                          Specifying just the language part of a locale means all matching
2791                          locales will be included.
2792    ],
2793,)
2794
2795# Kerberos and GSSAPI used only by PostgreSQL as of LibO 3.5
2796# and also by Mariadb/Mysql since LibO 24.8
2797libo_FUZZ_ARG_WITH(krb5,
2798    AS_HELP_STRING([--with-krb5],
2799        [Enable MIT Kerberos 5 support in modules that support it.
2800         By default automatically enabled on platforms
2801         where a good system Kerberos 5 is available.]),
2802,)
2803
2804libo_FUZZ_ARG_WITH(gssapi,
2805    AS_HELP_STRING([--with-gssapi],
2806        [Enable GSSAPI support in modules that support it.
2807         By default automatically enabled on platforms
2808         where a good system GSSAPI is available.]),
2809,)
2810
2811libo_FUZZ_ARG_WITH(lxml,
2812    AS_HELP_STRING([--without-lxml],
2813        [gla11y will use python lxml when available, potentially building a local copy if necessary.
2814         --without-lxml tells it to not use python lxml at all, which means that gla11y will only
2815         report widget classes and ids.]),
2816,)
2817
2818libo_FUZZ_ARG_WITH(latest-c++,
2819    AS_HELP_STRING([--with-latest-c++],
2820        [Try to enable the latest features of the C++ compiler, even if they are not yet part of a
2821         published standard.  This option is ignored when CXXFLAGS_CXX11 is set explicitly.]),,
2822        [with_latest_c__=no])
2823
2824AC_ARG_WITH(gtk3-build,
2825    AS_HELP_STRING([--with-gtk3-build=<absolute path to GTK3 build>],
2826        [(Windows-only) In order to build GtkTiledViewer on Windows, pass the path
2827         to a GTK3 build, like '--with-gtk3-build=C:/gtk-build/gtk/x64/release'.]))
2828
2829AC_ARG_WITH(keep-awake,
2830    AS_HELP_STRING([--with-keep-awake],
2831        [command to prefix make with in order to prevent the system from going to sleep/suspend
2832         while building.
2833         If no command is specified, defaults to using Awake (from Microsoft PowerToys) on Windows
2834         and caffeinate on macOS]))
2835
2836dnl ===================================================================
2837dnl Branding
2838dnl ===================================================================
2839
2840AC_ARG_WITH(branding,
2841    AS_HELP_STRING([--with-branding=/path/to/images],
2842        [Use given path to retrieve branding images set.])
2843    [
2844                          Search for intro.png about.svg and logo.svg.
2845                          If any is missing, default ones will be used instead.
2846
2847                          Search also progress.conf for progress
2848                          settings on intro screen :
2849
2850                          PROGRESSBARCOLOR="255,255,255" Set color of
2851                          progress bar. Comma separated RGB decimal values.
2852                          PROGRESSSIZE="407,6" Set size of progress bar.
2853                          Comma separated decimal values (width, height).
2854                          PROGRESSPOSITION="61,317" Set position of progress
2855                          bar from left,top. Comma separated decimal values.
2856                          PROGRESSFRAMECOLOR="20,136,3" Set color of progress
2857                          bar frame. Comma separated RGB decimal values.
2858                          PROGRESSTEXTCOLOR="0,0,0" Set color of progress
2859                          bar text. Comma separated RGB decimal values.
2860                          PROGRESSTEXTBASELINE="287" Set vertical position of
2861                          progress bar text from top. Decimal value.
2862
2863                          Default values will be used if not found.
2864    ],
2865,)
2866
2867
2868AC_ARG_WITH(extra-buildid,
2869    AS_HELP_STRING([--with-extra-buildid="Tinderbox: Win-x86@6, Branch:master, Date:2012-11-26_00.29.34"],
2870        [Show addition build identification in about dialog.]),
2871,)
2872
2873
2874AC_ARG_WITH(vendor,
2875    AS_HELP_STRING([--with-vendor="John the Builder"],
2876        [Set vendor of the build.]),
2877,)
2878
2879AC_ARG_WITH(privacy-policy-url,
2880    AS_HELP_STRING([--with-privacy-policy-url="https://yourdomain/privacy-policy"],
2881        [The URL to your privacy policy (needed when
2882         enabling online-update or crashreporting via breakpad)]),
2883        [if test "x$with_privacy_policy_url" = "xyes"; then
2884            AC_MSG_FAILURE([you need to specify an argument when using --with-privacy-policy-url])
2885         elif test "x$with_privacy_policy_url" = "xno"; then
2886            with_privacy_policy_url="undefined"
2887         fi]
2888,[with_privacy_policy_url="undefined"])
2889
2890AC_ARG_WITH(android-package-name,
2891    AS_HELP_STRING([--with-android-package-name="org.libreoffice"],
2892        [Set Android package name of the build.]),
2893,)
2894
2895AC_ARG_WITH(compat-oowrappers,
2896    AS_HELP_STRING([--with-compat-oowrappers],
2897        [Install oo* wrappers in parallel with
2898         lo* ones to keep backward compatibility.
2899         Has effect only with make distro-pack-install]),
2900,)
2901
2902AC_ARG_WITH(os-version,
2903    AS_HELP_STRING([--with-os-version=<OSVERSION>],
2904        [For FreeBSD users, use this option to override the detected OSVERSION.]),
2905,)
2906
2907AC_ARG_WITH(parallelism,
2908    AS_HELP_STRING([--with-parallelism],
2909        [Number of jobs to run simultaneously during build. Parallel builds can
2910        save a lot of time on multi-cpu machines. Defaults to the number of
2911        CPUs on the machine, unless you configure --enable-icecream - then to
2912        40.]),
2913,)
2914
2915AC_ARG_WITH(all-tarballs,
2916    AS_HELP_STRING([--with-all-tarballs],
2917        [Download all external tarballs unconditionally]))
2918
2919AC_ARG_WITH(gdrive-client-id,
2920    AS_HELP_STRING([--with-gdrive-client-id],
2921        [Provides the client id of the application for OAuth2 authentication
2922        on Google Drive. If either this or --with-gdrive-client-secret is
2923        empty, the feature will be disabled]),
2924)
2925
2926AC_ARG_WITH(gdrive-client-secret,
2927    AS_HELP_STRING([--with-gdrive-client-secret],
2928        [Provides the client secret of the application for OAuth2
2929        authentication on Google Drive. If either this or
2930        --with-gdrive-client-id is empty, the feature will be disabled]),
2931)
2932
2933AC_ARG_WITH(alfresco-cloud-client-id,
2934    AS_HELP_STRING([--with-alfresco-cloud-client-id],
2935        [Provides the client id of the application for OAuth2 authentication
2936        on Alfresco Cloud. If either this or --with-alfresco-cloud-client-secret is
2937        empty, the feature will be disabled]),
2938)
2939
2940AC_ARG_WITH(alfresco-cloud-client-secret,
2941    AS_HELP_STRING([--with-alfresco-cloud-client-secret],
2942        [Provides the client secret of the application for OAuth2
2943        authentication on Alfresco Cloud. If either this or
2944        --with-alfresco-cloud-client-id is empty, the feature will be disabled]),
2945)
2946
2947AC_ARG_WITH(onedrive-client-id,
2948    AS_HELP_STRING([--with-onedrive-client-id],
2949        [Provides the client id of the application for OAuth2 authentication
2950        on OneDrive. If either this or --with-onedrive-client-secret is
2951        empty, the feature will be disabled]),
2952)
2953
2954AC_ARG_WITH(onedrive-client-secret,
2955    AS_HELP_STRING([--with-onedrive-client-secret],
2956        [Provides the client secret of the application for OAuth2
2957        authentication on OneDrive. If either this or
2958        --with-onedrive-client-id is empty, the feature will be disabled]),
2959)
2960
2961dnl Check for coredumpctl support to present information about crashing test processes:
2962AC_ARG_WITH(coredumpctl,
2963    AS_HELP_STRING([--with-coredumpctl],
2964        [Use coredumpctl (together with systemd-run) to retrieve core dumps of crashing test
2965        processes.]))
2966
2967AC_ARG_WITH(buildconfig-recorded,
2968    AS_HELP_STRING([--with-buildconfig-recorded],
2969        [Put build config into version info reported by LOK. Incompatible with reproducible builds.]),
2970)
2971
2972AC_MSG_CHECKING([whether to record build config])
2973if test -z "$with_buildconfig_recorded"; then
2974    with_buildconfig_recorded=no
2975fi
2976if test "$with_buildconfig_recorded" = no; then
2977    AC_MSG_RESULT([no])
2978else
2979    AC_MSG_RESULT([yes])
2980    # replace backslashes, to get a valid c++ string
2981    config_args=$(echo $ac_configure_args | tr '\\' '/')
2982    AC_DEFINE_UNQUOTED([BUILDCONFIG],[["$config_args"]],[Options passed to configure script])
2983    AC_DEFINE([BUILDCONFIG_RECORDED],[1],[Options passed to configure script])
2984fi
2985
2986dnl ===================================================================
2987dnl Do we want to use pre-build binary tarball for recompile
2988dnl ===================================================================
2989
2990if test "$enable_library_bin_tar" = "yes" ; then
2991    USE_LIBRARY_BIN_TAR=TRUE
2992else
2993    USE_LIBRARY_BIN_TAR=
2994fi
2995AC_SUBST(USE_LIBRARY_BIN_TAR)
2996
2997dnl ===================================================================
2998dnl Test whether build target is Release Build
2999dnl ===================================================================
3000AC_MSG_CHECKING([whether build target is Release Build])
3001if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
3002    AC_MSG_RESULT([no])
3003    ENABLE_RELEASE_BUILD=
3004    dnl Pu the value on one line as make (at least on macOS) seems to ignore
3005    dnl the newlines and then complains about spaces.
3006    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/>'
3007else
3008    AC_MSG_RESULT([yes])
3009    ENABLE_RELEASE_BUILD=TRUE
3010    GET_TASK_ALLOW_ENTITLEMENT=
3011fi
3012AC_SUBST(ENABLE_RELEASE_BUILD)
3013AC_SUBST(GET_TASK_ALLOW_ENTITLEMENT)
3014
3015dnl ===================================================================
3016dnl Test whether build should auto use hardening compiler flags
3017dnl ===================================================================
3018AC_MSG_CHECKING([whether build should auto use hardening compiler flags])
3019if test "$enable_hardening_flags" = "" -o "$enable_hardening_flags" = "no"; then
3020    AC_MSG_RESULT([no])
3021    ENABLE_HARDENING_FLAGS=
3022else
3023    AC_MSG_RESULT([yes])
3024    ENABLE_HARDENING_FLAGS=TRUE
3025fi
3026AC_SUBST(ENABLE_HARDENING_FLAGS)
3027
3028AC_MSG_CHECKING([whether to build a Community flavor])
3029if test -z "$enable_community_flavor" -o "$enable_community_flavor" = "yes"; then
3030    AC_DEFINE(HAVE_FEATURE_COMMUNITY_FLAVOR)
3031    AC_MSG_RESULT([yes])
3032else
3033    AC_MSG_RESULT([no])
3034fi
3035
3036dnl ===================================================================
3037dnl Test whether to sign Windows Build
3038dnl ===================================================================
3039AC_MSG_CHECKING([whether to sign windows build])
3040if test "$enable_windows_build_signing" = "yes" -a "$_os" = "WINNT"; then
3041    AC_MSG_RESULT([yes])
3042    WINDOWS_BUILD_SIGNING="TRUE"
3043else
3044    AC_MSG_RESULT([no])
3045    WINDOWS_BUILD_SIGNING="FALSE"
3046fi
3047AC_SUBST(WINDOWS_BUILD_SIGNING)
3048
3049dnl ===================================================================
3050dnl MacOSX build and runtime environment options
3051dnl ===================================================================
3052
3053AC_ARG_WITH(macosx-version-min-required,
3054    AS_HELP_STRING([--with-macosx-version-min-required=<version>],
3055        [set the minimum OS version needed to run the built LibreOffice])
3056    [
3057                          e. g.: --with-macosx-version-min-required=10.15
3058    ],
3059,)
3060
3061dnl ===================================================================
3062dnl Check for incompatible options set by fuzzing, and reset those
3063dnl automatically to working combinations
3064dnl ===================================================================
3065
3066if test "$libo_fuzzed_enable_dbus" = yes -a "$libo_fuzzed_enable_avahi" -a \
3067        "$enable_dbus" != "$enable_avahi"; then
3068    AC_MSG_NOTICE([Resetting --enable-avahi=$enable_dbus])
3069    enable_avahi=$enable_dbus
3070fi
3071
3072add_lopath_after ()
3073{
3074    if ! echo "$LO_PATH" | $EGREP -q "(^|${P_SEP})$1($|${P_SEP})"; then
3075        LO_PATH="${LO_PATH:+$LO_PATH$P_SEP}$1"
3076    fi
3077}
3078
3079add_lopath_before ()
3080{
3081    local IFS=${P_SEP}
3082    local path_cleanup
3083    local dir
3084    for dir in $LO_PATH ; do
3085        if test "$dir" != "$1" ; then
3086            path_cleanup=${path_cleanup:+$path_cleanup$P_SEP}$dir
3087        fi
3088    done
3089    LO_PATH="$1${path_cleanup:+$P_SEP$path_cleanup}"
3090}
3091
3092dnl ===================================================================
3093dnl check for required programs (grep, awk, sed, bash)
3094dnl ===================================================================
3095
3096pathmunge ()
3097{
3098    local new_path
3099    if test -n "$1"; then
3100        if test "$build_os" = "cygwin"; then
3101            if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
3102                PathFormat "$1"
3103                new_path=`cygpath -sm "$formatted_path"`
3104            else
3105                PathFormat "$1"
3106                new_path=`cygpath -u "$formatted_path"`
3107            fi
3108        else
3109            new_path="$1"
3110        fi
3111        if test "$2" = "after"; then
3112            add_lopath_after "$new_path"
3113        else
3114            add_lopath_before "$new_path"
3115        fi
3116    fi
3117}
3118
3119AC_PROG_AWK
3120AC_PATH_PROG( AWK, $AWK)
3121if test -z "$AWK"; then
3122    AC_MSG_ERROR([install awk to run this script])
3123fi
3124
3125AC_PATH_PROG(BASH, bash)
3126if test -z "$BASH"; then
3127    AC_MSG_ERROR([bash not found in \$PATH])
3128fi
3129AC_SUBST(BASH)
3130
3131# prefer parallel compression tools, if available
3132AC_PATH_PROG(COMPRESSIONTOOL, pigz)
3133if test -z "$COMPRESSIONTOOL"; then
3134    AC_PATH_PROG(COMPRESSIONTOOL, gzip)
3135    if test -z "$COMPRESSIONTOOL"; then
3136        AC_MSG_ERROR([gzip not found in \$PATH])
3137    fi
3138fi
3139AC_SUBST(COMPRESSIONTOOL)
3140
3141AC_MSG_CHECKING([for GNU or BSD tar])
3142for a in $GNUTAR gtar gnutar tar bsdtar /usr/sfw/bin/gtar; do
3143    $a --version 2> /dev/null | grep -E "GNU|bsdtar"  2>&1 > /dev/null
3144    if test $? -eq 0;  then
3145        GNUTAR=$a
3146        break
3147    fi
3148done
3149AC_MSG_RESULT($GNUTAR)
3150if test -z "$GNUTAR"; then
3151    AC_MSG_ERROR([not found. install GNU or BSD tar.])
3152fi
3153AC_SUBST(GNUTAR)
3154
3155AC_MSG_CHECKING([for tar's option to strip components])
3156$GNUTAR --help 2> /dev/null | grep -E "bsdtar|strip-components" 2>&1 >/dev/null
3157if test $? -eq 0; then
3158    STRIP_COMPONENTS="--strip-components"
3159else
3160    $GNUTAR --help 2> /dev/null | grep -E "strip-path" 2>&1 >/dev/null
3161    if test $? -eq 0; then
3162        STRIP_COMPONENTS="--strip-path"
3163    else
3164        STRIP_COMPONENTS="unsupported"
3165    fi
3166fi
3167AC_MSG_RESULT($STRIP_COMPONENTS)
3168if test x$STRIP_COMPONENTS = xunsupported; then
3169    AC_MSG_ERROR([you need a tar that is able to strip components.])
3170fi
3171AC_SUBST(STRIP_COMPONENTS)
3172
3173dnl It is useful to have a BUILD_TYPE keyword to distinguish "normal"
3174dnl desktop OSes from "mobile" ones.
3175
3176dnl We assume that a non-DESKTOP build type is also a non-NATIVE one.
3177dnl In other words, that when building for an OS that is not a
3178dnl "desktop" one but a "mobile" one, we are always cross-compiling.
3179
3180dnl Note the direction of the implication; there is no assumption that
3181dnl cross-compiling would imply a non-desktop OS.
3182
3183if test $_os != iOS -a $_os != Android -a "$enable_fuzzers" != "yes"; then
3184    BUILD_TYPE="$BUILD_TYPE DESKTOP"
3185    AC_DEFINE(HAVE_FEATURE_DESKTOP)
3186    if test "$_os" != Emscripten; then
3187        AC_DEFINE(HAVE_FEATURE_MULTIUSER_ENVIRONMENT)
3188    fi
3189fi
3190
3191# explicitly doesn't include enable_gtk3=no and enable_qt5=yes, so it should
3192# also work with the default gtk3 plugin.
3193if test "$enable_wasm_strip" = "yes"; then
3194    enable_avmedia=no
3195    enable_libcmis=no
3196    enable_coinmp=no
3197    enable_cups=no
3198    test "$_os" = Emscripten && enable_curl=no
3199    enable_database_connectivity=no
3200    enable_dbus=no
3201    enable_dconf=no
3202    test "${enable_dynamic_loading+set}" = set -o "$_os" != Emscripten || enable_dynamic_loading=no
3203    enable_extension_integration=no
3204    enable_extensions=no
3205    enable_extension_update=no
3206    enable_gio=no
3207    enable_gpgmepp=no
3208    enable_ldap=no
3209    enable_lotuswordpro=no
3210    enable_lpsolve=no
3211    enable_nss=no
3212    enable_odk=no
3213    enable_online_update=no
3214    enable_opencl=no
3215    enable_pdfimport=no
3216    enable_randr=no
3217    enable_report_builder=no
3218    enable_scripting=no
3219    enable_sdremote_bluetooth=no
3220    enable_skia=no
3221    enable_xmlhelp=no
3222    enable_zxing=no
3223    test_libepubgen=no
3224    test_libcdr=no
3225    test_libcmis=no
3226    test_libetonyek=no
3227    test_libfreehand=no
3228    test_libmspub=no
3229    test_libpagemaker=no
3230    test_libqxp=no
3231    test_libvisio=no
3232    test_libzmf=no
3233    test_webdav=no
3234    with_galleries=no
3235    with_templates=no
3236    with_webdav=no
3237    with_x=no
3238
3239    test "${with_fonts+set}" = set || with_fonts=yes
3240    test "${with_locales+set}" = set || with_locales=en
3241
3242    AC_DEFINE(ENABLE_WASM_STRIP_ACCESSIBILITY)
3243    AC_DEFINE(ENABLE_WASM_STRIP_WRITER)
3244    AC_DEFINE(ENABLE_WASM_STRIP_CALC)
3245    AC_DEFINE(ENABLE_WASM_STRIP_CANVAS)
3246#    AC_DEFINE(ENABLE_WASM_STRIP_CHART)
3247    AC_DEFINE(ENABLE_WASM_STRIP_DBACCESS)
3248    AC_DEFINE(ENABLE_WASM_STRIP_EPUB)
3249    AC_DEFINE(ENABLE_WASM_STRIP_EXTRA)
3250    AC_DEFINE(ENABLE_WASM_STRIP_GUESSLANG)
3251#    AC_DEFINE(ENABLE_WASM_STRIP_HUNSPELL)
3252    AC_DEFINE(ENABLE_WASM_STRIP_LANGUAGETOOL)
3253    AC_DEFINE(ENABLE_WASM_STRIP_PINGUSER)
3254    AC_DEFINE(ENABLE_WASM_STRIP_PREMULTIPLY)
3255    AC_DEFINE(ENABLE_WASM_STRIP_RECENT)
3256    AC_DEFINE(ENABLE_WASM_STRIP_RECOVERYUI)
3257    AC_DEFINE(ENABLE_WASM_STRIP_SPLASH)
3258    AC_DEFINE(ENABLE_WASM_STRIP_SWEXPORTS)
3259    AC_DEFINE(ENABLE_WASM_STRIP_SCEXPORTS)
3260fi
3261
3262# Whether to build "avmedia" functionality or not.
3263
3264if test "$enable_avmedia" = yes; then
3265    BUILD_TYPE="$BUILD_TYPE AVMEDIA"
3266    AC_DEFINE(HAVE_FEATURE_AVMEDIA)
3267else
3268    test_gstreamer_1_0=no
3269fi
3270
3271# Decide whether to build database connectivity stuff (including Base) or not.
3272if test "$enable_database_connectivity" != no; then
3273    BUILD_TYPE="$BUILD_TYPE DBCONNECTIVITY"
3274    AC_DEFINE(HAVE_FEATURE_DBCONNECTIVITY)
3275else
3276    if test "$_os" = iOS; then
3277        AC_MSG_ERROR([Presumly can't disable DB connectivity on iOS.])
3278    fi
3279    disable_database_connectivity_dependencies
3280fi
3281
3282if test -z "$enable_extensions"; then
3283    # For iOS and Android Viewer, disable extensions unless specifically overridden with --enable-extensions.
3284    if test $_os != iOS && test $_os != Android -o "$ENABLE_ANDROID_LOK" = TRUE ; then
3285        enable_extensions=yes
3286    fi
3287fi
3288
3289DISABLE_SCRIPTING=''
3290if test "$enable_scripting" = yes; then
3291    BUILD_TYPE="$BUILD_TYPE SCRIPTING"
3292    AC_DEFINE(HAVE_FEATURE_SCRIPTING)
3293else
3294    DISABLE_SCRIPTING='TRUE'
3295    SCPDEFS="$SCPDEFS -DDISABLE_SCRIPTING"
3296fi
3297
3298if test $_os = iOS -o $_os = Android -o $_os = Emscripten; then
3299    # Disable dynamic_loading always for iOS and Android
3300    enable_dynamic_loading=no
3301elif test -z "$enable_dynamic_loading"; then
3302    # Otherwise enable it unless specifically disabled
3303    enable_dynamic_loading=yes
3304fi
3305
3306DISABLE_DYNLOADING=''
3307if test "$enable_dynamic_loading" = yes; then
3308    BUILD_TYPE="$BUILD_TYPE DYNLOADING"
3309else
3310    DISABLE_DYNLOADING='TRUE'
3311    if test $_os != iOS -a $_os != Android; then
3312        enable_database_connectivity=no
3313        enable_nss=no
3314        enable_odk=no
3315        enable_python=no
3316        enable_skia=no
3317        with_java=no
3318    fi
3319fi
3320AC_SUBST(DISABLE_DYNLOADING)
3321
3322ENABLE_CUSTOMTARGET_COMPONENTS=
3323if test "$enable_customtarget_components" = yes -a "$DISABLE_DYNLOADING" = TRUE; then
3324    ENABLE_CUSTOMTARGET_COMPONENTS=TRUE
3325    if test -n "$with_locales" -a "$with_locales" != en -a "$with_locales" != ALL; then
3326        AC_MSG_ERROR([Currently just --with-locales=all or en is supported with --enable-customtarget-components])
3327    fi
3328fi
3329AC_SUBST(ENABLE_CUSTOMTARGET_COMPONENTS)
3330
3331if test "$enable_extensions" = yes; then
3332    BUILD_TYPE="$BUILD_TYPE EXTENSIONS"
3333    AC_DEFINE(HAVE_FEATURE_EXTENSIONS)
3334else
3335    enable_extension_integration=no
3336    enable_extension_update=no
3337fi
3338
3339# remember SYSBASE value
3340AC_SUBST(SYSBASE)
3341
3342dnl ===================================================================
3343dnl  Sort out various gallery compilation options
3344dnl ===================================================================
3345WITH_GALLERY_BUILD=TRUE
3346AC_MSG_CHECKING([how to build and package galleries])
3347if test -n "${with_galleries}"; then
3348    if test "$with_galleries" = "build"; then
3349        if test "$enable_database_connectivity" = no; then
3350            AC_MSG_ERROR([DB connectivity is needed for gengal / svx])
3351        fi
3352        AC_MSG_RESULT([build from source images internally])
3353    elif test "$with_galleries" = "no"; then
3354        WITH_GALLERY_BUILD=
3355        AC_MSG_RESULT([disable non-internal gallery build])
3356    else
3357        AC_MSG_ERROR([unknown value --with-galleries=$with_galleries])
3358    fi
3359else
3360    if test $_os != iOS -a $_os != Android; then
3361        AC_MSG_RESULT([internal src images for desktop])
3362    else
3363        WITH_GALLERY_BUILD=
3364        AC_MSG_RESULT([disable src image build])
3365    fi
3366fi
3367AC_SUBST(WITH_GALLERY_BUILD)
3368
3369dnl ===================================================================
3370dnl  Sort out various templates compilation options
3371dnl ===================================================================
3372WITH_TEMPLATES=TRUE
3373AC_MSG_CHECKING([build with or without template files])
3374if test -n "${with_templates}"; then
3375    if test "$with_templates" = "yes"; then
3376        AC_MSG_RESULT([enable all templates])
3377    elif test "$with_templates" = "no"; then
3378        WITH_TEMPLATES=
3379        AC_MSG_RESULT([disable non-internal templates])
3380    else
3381        AC_MSG_ERROR([unknown value --with-templates=$with_templates])
3382    fi
3383else
3384    if test $_os != iOS -a $_os != Android -a $_os != Emscripten; then
3385        AC_MSG_RESULT([enable all templates])
3386    else
3387        WITH_TEMPLATES=
3388        AC_MSG_RESULT([disable non-internal templates])
3389    fi
3390fi
3391AC_SUBST(WITH_TEMPLATES)
3392
3393dnl ===================================================================
3394dnl  Checks if ccache is available
3395dnl ===================================================================
3396CCACHE_DEPEND_MODE=
3397if test "$enable_ccache" = "no"; then
3398    CCACHE=""
3399elif test -n "$enable_ccache" -o \( "$enable_ccache" = "" -a "$enable_icecream" != "yes" \); then
3400    case "%$CC%$CXX%" in
3401    # If $CC and/or $CXX already contain "ccache" (possibly suffixed with some version number etc),
3402    # assume that's good then
3403    *%ccache[[-_' ']]*|*/ccache[[-_' ']]*)
3404        AC_MSG_NOTICE([ccache seems to be included in a pre-defined CC and/or CXX])
3405        CCACHE_DEPEND_MODE=1
3406        ;;
3407    *)
3408        # try to use our own ccache if it is available and CCACHE was not already defined
3409        if test -z "$CCACHE"; then
3410            if test "$_os" = "WINNT"; then
3411                ccache_ext=.exe # e.g. openssl build needs ccache.exe, not just ccache
3412            fi
3413            if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/ccache$ccache_ext" ; then
3414                CCACHE="$LODE_HOME/opt/bin/ccache$ccache_ext"
3415            elif test -x "/opt/lo/bin/ccache$ccache_ext"; then
3416                CCACHE="/opt/lo/bin/ccache$ccache_ext"
3417            fi
3418        fi
3419        AC_PATH_PROG([CCACHE],[ccache],[not found])
3420        if test "$CCACHE" != "not found" -a "$_os" = "WINNT"; then
3421            CCACHE=`win_short_path_for_make "$CCACHE"`
3422            # check that it has MSVC support (it should recognize it in CCACHE_COMPILERTYPE)
3423            rm -f conftest.txt
3424            AC_MSG_CHECKING([whether $CCACHE has MSVC support])
3425            CCACHE_COMPILERTYPE=cl CCACHE_LOGFILE=conftest.txt $CCACHE echo >/dev/null 2>/dev/null
3426            if grep -q 'Config: (environment) compiler_type = cl' conftest.txt; then
3427                AC_MSG_RESULT(yes)
3428            else
3429                AC_MSG_RESULT(no)
3430                CCACHE="not found"
3431            fi
3432            rm -f conftest.txt
3433        fi
3434        if test "$CCACHE" = "not found" -a "$_os" = "WINNT"; then
3435            # on windows/VC perhaps sccache is around?
3436            case "%$CC%$CXX%" in
3437            # If $CC and/or $CXX already contain "sccache" (possibly suffixed with some version number etc),
3438            # assume that's good then
3439            *%sccache[[-_' ']]*|*/sccache[[-_' ']]*)
3440                AC_MSG_NOTICE([sccache seems to be included in a pre-defined CC and/or CXX])
3441                CCACHE_DEPEND_MODE=1
3442                SCCACHE=1
3443                ;;
3444            *)
3445                # for sharing code below, reuse CCACHE env var
3446                AC_PATH_PROG([CCACHE],[sccache],[not found])
3447                if test "$CCACHE" != "not found"; then
3448                    CCACHE=`win_short_path_for_make "$CCACHE"`
3449                    SCCACHE=1
3450                    CCACHE_DEPEND_MODE=1
3451                fi
3452                ;;
3453            esac
3454        fi
3455        if test "$CCACHE" = "not found"; then
3456            CCACHE=""
3457        fi
3458        if test -n "$CCACHE" -a -z "$SCCACHE"; then
3459            CCACHE_DEPEND_MODE=1
3460            # Need to check for ccache version: otherwise prevents
3461            # caching of the results (like "-x objective-c++" for Mac)
3462            if test $_os = Darwin -o $_os = iOS; then
3463                # Check ccache version
3464                AC_MSG_CHECKING([whether version of ccache is suitable])
3465                CCACHE_VERSION=`"$CCACHE" -V | "$AWK" '/^ccache version/{print $3}'`
3466                CCACHE_NUMVER=`echo $CCACHE_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
3467                if test "$CCACHE_VERSION" = "2.4_OOo" -o "$CCACHE_NUMVER" -ge "030100"; then
3468                    AC_MSG_RESULT([yes, $CCACHE_VERSION])
3469                else
3470                    AC_MSG_RESULT([no, $CCACHE_VERSION])
3471                    CCACHE=""
3472                    CCACHE_DEPEND_MODE=
3473                fi
3474            fi
3475        fi
3476        if test "$enable_ccache" = yes && test -z "$CCACHE"; then
3477            AC_MSG_ERROR([No suitable ccache found])
3478        fi
3479        ;;
3480    esac
3481else
3482    CCACHE=""
3483fi
3484if test "$enable_ccache" = "nodepend"; then
3485    CCACHE_DEPEND_MODE=""
3486fi
3487AC_SUBST(CCACHE_DEPEND_MODE)
3488
3489# sccache defaults are good enough
3490if test "$CCACHE" != "" -a -z "$SCCACHE"; then
3491    # e.g. (/home/rene/.config/ccache/ccache.conf) max_size = 20.0G
3492    # or (...) max_size = 20.0 G
3493    # -p works with both 4.2 and 4.4
3494    ccache_size_msg=$([$CCACHE -p | $AWK /max_size/'{ print $4 $5 }' | sed -e 's/\.[0-9]*//'])
3495    ccache_size=$(echo "$ccache_size_msg" | grep "G" | sed -e 's/G.*$//')
3496    if test "$ccache_size" = ""; then
3497        ccache_size=$(echo "$ccache_size_msg" | grep "M" | sed -e 's/\ M.*$//')
3498        if test "$ccache_size" = ""; then
3499            ccache_size=0
3500        fi
3501        # we could not determine the size or it was less than 1GB -> disable auto-ccache
3502        if test $ccache_size -lt 1024; then
3503            CCACHE=""
3504            AC_MSG_WARN([ccache's cache size is less than 1GB using it is counter-productive: Disabling auto-ccache detection])
3505            add_warning "ccache's cache size is less than 1GB using it is counter-productive: auto-ccache detection disabled"
3506        else
3507            # warn that ccache may be too small for debug build
3508            AC_MSG_WARN([ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build])
3509            add_warning "ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build"
3510        fi
3511    else
3512        if test $ccache_size -lt 5; then
3513            #warn that ccache may be too small for debug build
3514            AC_MSG_WARN([ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build])
3515            add_warning "ccache's cache size is less than 5GB using it may be counter-productive for debug or symbol-enabled build"
3516        fi
3517    fi
3518fi
3519
3520ENABLE_Z7_DEBUG=
3521if test "$enable_z7_debug" != no; then
3522    if test "$enable_z7_debug" = yes -o -n "$CCACHE"; then
3523        ENABLE_Z7_DEBUG=TRUE
3524    fi
3525else
3526    AC_MSG_WARN([ccache will not work with --disable-z7-debug])
3527    add_warning "ccache will not work with --disable-z7-debug"
3528fi
3529AC_SUBST(ENABLE_Z7_DEBUG)
3530
3531dnl ===================================================================
3532dnl  Checks for C compiler,
3533dnl  The check for the C++ compiler is later on.
3534dnl ===================================================================
3535if test "$_os" != "WINNT"; then
3536    GCC_HOME_SET="true"
3537    AC_MSG_CHECKING([gcc home])
3538    if test -z "$with_gcc_home"; then
3539        if test "$enable_icecream" = "yes"; then
3540            if test -d "/usr/lib/icecc/bin"; then
3541                GCC_HOME="/usr/lib/icecc/"
3542            elif test -d "/usr/libexec/icecc/bin"; then
3543                GCC_HOME="/usr/libexec/icecc/"
3544            elif test -d "/opt/icecream/bin"; then
3545                GCC_HOME="/opt/icecream/"
3546            else
3547                AC_MSG_ERROR([Could not figure out the location of icecream GCC wrappers, manually use --with-gcc-home])
3548
3549            fi
3550        else
3551            GCC_HOME=`command -v gcc | $SED -e s,/bin/gcc,,`
3552            GCC_HOME_SET="false"
3553        fi
3554    else
3555        GCC_HOME="$with_gcc_home"
3556    fi
3557    AC_MSG_RESULT($GCC_HOME)
3558    AC_SUBST(GCC_HOME)
3559
3560    if test "$GCC_HOME_SET" = "true"; then
3561        if test -z "$CC"; then
3562            CC="$GCC_HOME/bin/gcc"
3563            CC_BASE="gcc"
3564        fi
3565        if test -z "$CXX"; then
3566            CXX="$GCC_HOME/bin/g++"
3567            CXX_BASE="g++"
3568        fi
3569    fi
3570fi
3571
3572COMPATH=`dirname "$CC"`
3573if test "$COMPATH" = "."; then
3574    AC_PATH_PROGS(COMPATH, $CC)
3575    dnl double square bracket to get single because of M4 quote...
3576    COMPATH=`echo $COMPATH | $SED "s@/[[^/:]]*\\\$@@"`
3577fi
3578COMPATH=`echo $COMPATH | $SED "s@/[[Bb]][[Ii]][[Nn]]\\\$@@"`
3579
3580dnl ===================================================================
3581dnl .NET support
3582dnl ===================================================================
3583AC_MSG_CHECKING([whether to build with .NET support])
3584if test "$enable_dotnet" != "no"; then
3585    if test "$DISABLE_SCRIPTING" = TRUE; then
3586        AC_MSG_RESULT([no, overridden by --disable-scripting])
3587        ENABLE_DOTNET=""
3588        enable_dotnet=no
3589    else
3590        AC_MSG_RESULT([yes])
3591        ENABLE_DOTNET="TRUE"
3592    fi
3593else
3594    AC_MSG_RESULT([no])
3595    ENABLE_DOTNET=""
3596fi
3597
3598if test "$ENABLE_DOTNET" = TRUE; then
3599    AC_PATH_PROG(DOTNET, dotnet)
3600    if test "$DOTNET" != ""; then
3601        AC_MSG_CHECKING([whether .NET SDK is installed])
3602        DOTNET_SDK_VERSION=`dotnet --list-sdks`
3603        if test "$DOTNET_SDK_VERSION" != ""; then
3604            AC_MSG_RESULT([yes])
3605            AC_DEFINE(HAVE_FEATURE_DOTNET)
3606        else
3607            AC_MSG_RESULT([no])
3608            ENABLE_DOTNET=""
3609        fi
3610    else
3611        ENABLE_DOTNET=""
3612    fi
3613fi
3614
3615AC_SUBST(ENABLE_DOTNET)
3616
3617dnl set ENABLE_DOTNET="TRUE" for build-time and run-time .NET support
3618dnl set ENABLE_DOTNET="" for no .NET support at all
3619
3620dnl ===================================================================
3621dnl Java support
3622dnl ===================================================================
3623AC_MSG_CHECKING([whether to build with Java support])
3624javacompiler="javac"
3625javadoc="javadoc"
3626if test "$with_java" != "no"; then
3627    if test "$DISABLE_SCRIPTING" = TRUE; then
3628        AC_MSG_RESULT([no, overridden by --disable-scripting])
3629        ENABLE_JAVA=""
3630        with_java=no
3631    else
3632        AC_MSG_RESULT([yes])
3633        ENABLE_JAVA="TRUE"
3634        AC_DEFINE(HAVE_FEATURE_JAVA)
3635    fi
3636else
3637    AC_MSG_RESULT([no])
3638    ENABLE_JAVA=""
3639fi
3640
3641AC_SUBST(ENABLE_JAVA)
3642
3643dnl ENABLE_JAVA="TRUE" if we want there to be *run-time* (and build-time) support for Java
3644
3645dnl ENABLE_JAVA="" indicate no Java support at all
3646
3647dnl ===================================================================
3648dnl Check macOS SDK and compiler
3649dnl ===================================================================
3650
3651if test $_os = Darwin; then
3652
3653    # The SDK in the currently selected Xcode should be found.
3654
3655    AC_MSG_CHECKING([what macOS SDK to use])
3656    # XCode only ships with a single SDK for a while now, and using older SDKs alongside is not
3657    # really supported anymore, instead you'd use different copies of Xcode, each with their own
3658    # SDK, and thus xcrun will pick the SDK that matches the currently selected Xcode version
3659    # also restricting the SDK version to "known good" versions doesn't seem necessary anymore, the
3660    # problems that existed in the PPC days with target versions not being respected or random
3661    # failures seems to be a thing of the past or rather: limiting either the Xcode version or the
3662    # SDK version is enough, no need to do both...
3663    MACOSX_SDK_PATH=`xcrun --sdk macosx --show-sdk-path 2> /dev/null`
3664    if test ! -d "$MACOSX_SDK_PATH"; then
3665        AC_MSG_ERROR([Could not find an appropriate macOS SDK])
3666    fi
3667    macosx_sdk=`xcodebuild -version -sdk "$MACOSX_SDK_PATH" SDKVersion`
3668    MACOSX_SDK_BUILD_VERSION=$(xcodebuild -version -sdk "$MACOSX_SDK_PATH" ProductBuildVersion)
3669    # format changed between 10.9 and 10.10 - up to 10.9 it was just four digits (1090), starting
3670    # with macOS 10.10 it was switched to account for x.y.z with six digits, 10.10 is 101000,
3671    # 10.10.2 is 101002
3672    # we don't target the lower versions anymore, so it doesn't matter that we don't generate the
3673    # correct version in case such an old SDK is specified, it will be rejected later anyway
3674    MACOSX_SDK_VERSION=$(echo $macosx_sdk | $AWK -F. '{ print $1*10000+$2*100+$3 }')
3675    if test $MACOSX_SDK_VERSION -lt 101500; then
3676        AC_MSG_ERROR([macOS SDK $macosx_sdk is not supported, lowest supported version is 10.15])
3677    fi
3678    if test "$host_cpu" = arm64 -a $MACOSX_SDK_VERSION -lt 110000; then
3679        AC_MSG_ERROR([macOS SDK $macosx_sdk is not supported for Apple Silicon (need at least 11.0)])
3680    fi
3681    AC_MSG_RESULT([macOS SDK $macosx_sdk at $MACOSX_SDK_PATH])
3682
3683    AC_MSG_CHECKING([what minimum version of macOS to require])
3684    if test "$with_macosx_version_min_required" = "" ; then
3685        if test "$host_cpu" = x86_64; then
3686            with_macosx_version_min_required="10.15";
3687        else
3688            with_macosx_version_min_required="11.0";
3689        fi
3690    fi
3691    # see same notes about MACOSX_SDK_VERSION above
3692    MAC_OS_X_VERSION_MIN_REQUIRED=$(echo $with_macosx_version_min_required | $AWK -F. '{ print $1*10000+$2*100+$3 }')
3693    if test $MAC_OS_X_VERSION_MIN_REQUIRED -lt 101500; then
3694        AC_MSG_ERROR([with-macosx-version-min-required $with_macosx_version_min_required is not a supported value, minimum supported version is 10.15])
3695    fi
3696    AC_MSG_RESULT([$with_macosx_version_min_required])
3697
3698    AC_MSG_CHECKING([that macosx-version-min-required is coherent with macos-with-sdk])
3699    if test $MAC_OS_X_VERSION_MIN_REQUIRED -gt $MACOSX_SDK_VERSION; then
3700        AC_MSG_ERROR([the version minimum required ($with_macosx_version_min_required) cannot be greater than the sdk level ($macosx_sdk)])
3701    else
3702        AC_MSG_RESULT([yes])
3703    fi
3704
3705    # export this so that "xcrun" invocations later return matching values
3706    DEVELOPER_DIR="${MACOSX_SDK_PATH%/SDKs*}"
3707    DEVELOPER_DIR="${DEVELOPER_DIR%/Platforms*}"
3708    export DEVELOPER_DIR
3709    FRAMEWORKSHOME="$MACOSX_SDK_PATH/System/Library/Frameworks"
3710    MACOSX_DEPLOYMENT_TARGET="$with_macosx_version_min_required"
3711
3712    AC_MSG_CHECKING([whether Xcode is new enough])
3713    my_xcode_ver1=$(xcrun xcodebuild -version | head -n 1)
3714    my_xcode_ver2=${my_xcode_ver1#Xcode }
3715    my_xcode_ver3=$(printf %s "$my_xcode_ver2" | $AWK -F. '{ print $1*100+($2<100?$2:99) }')
3716    if test "$my_xcode_ver3" -ge 1205; then
3717        AC_MSG_RESULT([yes ($my_xcode_ver2)])
3718        if test $MAC_OS_X_VERSION_MIN_REQUIRED -lt 120000; then
3719            if test "$my_xcode_ver3" -ge 1600; then
3720                dnl the Xcode 15 relnotes state that the classic linker will disappear in the next version, but nothing about
3721                dnl fixing the problem with weak symbols/macOS 11 compatibility, so assume for now that Xcode 16 will break it...
3722                AC_MSG_ERROR([Check that Xcode 16 still supports the old linker/that it doesn't break macOS 11 compatibility, then remove this check]);
3723            fi
3724            if test "$my_xcode_ver3" -ge 1500; then
3725                AC_MSG_WARN([Xcode 15 has a new linker that causes runtime crashes on macOS 11])
3726                add_warning "Xcode 15 has a new linker that causes runtime crashes on macOS 11, forcing the old linker."
3727                add_warning "see https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking"
3728                LDFLAGS="$LDFLAGS -Wl,-ld_classic"
3729                # if LDFLAGS weren't set already, a check above sets x_LDFLAGS=[#] to comment-out the export LDFLAGS line in config_host.mk
3730                x_LDFLAGS=
3731            fi
3732        fi
3733    else
3734        AC_MSG_ERROR(["$my_xcode_ver1" is too old or unrecognized, must be at least Xcode 12.5])
3735    fi
3736
3737    my_xcode_ver1=$(xcrun xcodebuild -version | tail -n 1)
3738    MACOSX_XCODE_BUILD_VERSION=${my_xcode_ver1#Build version }
3739
3740    LIBTOOL=/usr/bin/libtool
3741    INSTALL_NAME_TOOL=install_name_tool
3742    if test -z "$save_CC"; then
3743        stdlib=-stdlib=libc++
3744
3745        AC_MSG_CHECKING([what C compiler to use])
3746        CC="`xcrun -find clang`"
3747        CC_BASE=`first_arg_basename "$CC"`
3748        if test "$host_cpu" = x86_64; then
3749            CC+=" -target x86_64-apple-macos"
3750        else
3751            CC+=" -target arm64-apple-macos"
3752        fi
3753        CC+=" -mmacosx-version-min=$with_macosx_version_min_required -isysroot $MACOSX_SDK_PATH"
3754        AC_MSG_RESULT([$CC])
3755
3756        AC_MSG_CHECKING([what C++ compiler to use])
3757        CXX="`xcrun -find clang++`"
3758        CXX_BASE=`first_arg_basename "$CXX"`
3759        if test "$host_cpu" = x86_64; then
3760            CXX+=" -target x86_64-apple-macos"
3761        else
3762            CXX+=" -target arm64-apple-macos"
3763        fi
3764        CXX+=" $stdlib -mmacosx-version-min=$with_macosx_version_min_required -isysroot $MACOSX_SDK_PATH"
3765        AC_MSG_RESULT([$CXX])
3766
3767        INSTALL_NAME_TOOL=`xcrun -find install_name_tool`
3768        AR=`xcrun -find ar`
3769        NM=`xcrun -find nm`
3770        STRIP=`xcrun -find strip`
3771        LIBTOOL=`xcrun -find libtool`
3772        RANLIB=`xcrun -find ranlib`
3773    fi
3774
3775    AC_MSG_CHECKING([whether to do code signing])
3776
3777    if test -z "$enable_macosx_code_signing" -o "$enable_macosx_code_signing" == "no" ; then
3778        AC_MSG_RESULT([no])
3779    else
3780        if test "$enable_macosx_code_signing" = yes; then
3781            # By default use the first suitable certificate (?).
3782
3783            # https://stackoverflow.com/questions/13196291/difference-between-mac-developer-and-3rd-party-mac-developer-application
3784            # says that the "Mac Developer" certificate is useful just for self-testing. For distribution
3785            # outside the Mac App Store, use the "Developer ID Application" one, and for distribution in
3786            # the App Store, the "3rd Party Mac Developer" one. I think it works best to the
3787            # "Developer ID Application" one.
3788            identity="Developer ID Application:"
3789        else
3790            identity=$enable_macosx_code_signing
3791        fi
3792        identity=`security find-identity -p codesigning -v 2>/dev/null | $AWK "/$identity/{print \\$2; exit}"`
3793        if test -n "$identity"; then
3794            MACOSX_CODESIGNING_IDENTITY=$identity
3795            pretty_name=`security find-identity -p codesigning -v | grep "$MACOSX_CODESIGNING_IDENTITY" | sed -e 's/^[[^"]]*"//' -e 's/"//'`
3796            AC_MSG_RESULT([yes, using the identity $MACOSX_CODESIGNING_IDENTITY for $pretty_name])
3797        else
3798            AC_MSG_ERROR([cannot determine identity to use])
3799        fi
3800    fi
3801
3802    AC_MSG_CHECKING([whether to create a Mac App Store package])
3803
3804    if test -z "$enable_macosx_package_signing" || test "$enable_macosx_package_signing" == no; then
3805        AC_MSG_RESULT([no])
3806    elif test -z "$MACOSX_CODESIGNING_IDENTITY"; then
3807        AC_MSG_ERROR([You forgot --enable-macosx-code-signing])
3808    else
3809        if test "$enable_macosx_package_signing" = yes; then
3810            # By default use the first suitable certificate.
3811            # It should be a "3rd Party Mac Developer Installer" one
3812            identity="3rd Party Mac Developer Installer:"
3813        else
3814            identity=$enable_macosx_package_signing
3815        fi
3816        identity=`security find-identity -v 2>/dev/null | $AWK "/$identity/ {print \\$2; exit}"`
3817        if test -n "$identity"; then
3818            MACOSX_PACKAGE_SIGNING_IDENTITY=$identity
3819            pretty_name=`security find-identity -v | grep "$MACOSX_PACKAGE_SIGNING_IDENTITY" | sed -e 's/^[[^"]]*"//' -e 's/"//'`
3820            AC_MSG_RESULT([yes, using the identity $MACOSX_PACKAGE_SIGNING_IDENTITY for $pretty_name])
3821        else
3822            AC_MSG_ERROR([Could not find any suitable '3rd Party Mac Developer Installer' certificate])
3823        fi
3824    fi
3825
3826    if test -n "$MACOSX_CODESIGNING_IDENTITY" -a -n "$MACOSX_PACKAGE_SIGNING_IDENTITY" -a "$MACOSX_CODESIGNING_IDENTITY" = "$MACOSX_PACKAGE_SIGNING_IDENTITY"; then
3827        AC_MSG_ERROR([You should not use the same identity for code and package signing])
3828    fi
3829
3830    AC_MSG_CHECKING([whether to sandbox the application])
3831
3832    if test -n "$ENABLE_JAVA" -a "$enable_macosx_sandbox" = yes; then
3833        AC_MSG_ERROR([macOS sandboxing (actually App Store rules) disallows use of Java])
3834    elif test "$enable_macosx_sandbox" = yes; then
3835        ENABLE_MACOSX_SANDBOX=TRUE
3836        AC_DEFINE(HAVE_FEATURE_MACOSX_SANDBOX)
3837        AC_MSG_RESULT([yes])
3838    else
3839        AC_MSG_RESULT([no])
3840    fi
3841
3842    AC_MSG_CHECKING([what macOS app bundle identifier to use])
3843    MACOSX_BUNDLE_IDENTIFIER=$with_macosx_bundle_identifier
3844    AC_MSG_RESULT([$MACOSX_BUNDLE_IDENTIFIER])
3845
3846    if test -n "$with_macosx_provisioning_profile" ; then
3847        if test ! -f "$with_macosx_provisioning_profile"; then
3848            AC_MSG_ERROR([provisioning profile not found at $with_macosx_provisioning_profile])
3849        else
3850            MACOSX_PROVISIONING_PROFILE=$with_macosx_provisioning_profile
3851            MACOSX_PROVISIONING_INFO=$([security cms -D -i "$MACOSX_PROVISIONING_PROFILE" | \
3852                xmllint --xpath "//key[.='com.apple.application-identifier' or .='com.apple.developer.team-identifier'] \
3853                    | //key[.='com.apple.application-identifier' or .='com.apple.developer.team-identifier']/following-sibling::string[1]" - | \
3854                sed -e 's#><#>\n\t<#g' -e 's#^#\t#'])
3855        fi
3856    fi
3857fi
3858AC_SUBST(MACOSX_SDK_PATH)
3859AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
3860AC_SUBST(MAC_OS_X_VERSION_MIN_REQUIRED)
3861AC_SUBST(INSTALL_NAME_TOOL)
3862AC_SUBST(LIBTOOL) # Note that the macOS libtool command is unrelated to GNU libtool
3863AC_SUBST(MACOSX_CODESIGNING_IDENTITY)
3864AC_SUBST(MACOSX_PACKAGE_SIGNING_IDENTITY)
3865AC_SUBST(ENABLE_MACOSX_SANDBOX)
3866AC_SUBST(MACOSX_BUNDLE_IDENTIFIER)
3867AC_SUBST(MACOSX_PROVISIONING_INFO)
3868AC_SUBST(MACOSX_PROVISIONING_PROFILE)
3869AC_SUBST(MACOSX_SDK_BUILD_VERSION)
3870AC_SUBST(MACOSX_XCODE_BUILD_VERSION)
3871
3872dnl ===================================================================
3873dnl Check iOS SDK and compiler
3874dnl ===================================================================
3875
3876if test $_os = iOS; then
3877    AC_MSG_CHECKING([what iOS SDK to use])
3878
3879    if test "$enable_ios_simulator" = "yes"; then
3880        platformlc=iphonesimulator
3881        versionmin=-mios-simulator-version-min=14.5
3882    else
3883        platformlc=iphoneos
3884        versionmin=-miphoneos-version-min=14.5
3885    fi
3886
3887    sysroot=`xcrun --sdk $platformlc --show-sdk-path`
3888
3889    if ! test -d "$sysroot"; then
3890        AC_MSG_ERROR([Could not find iOS SDK $sysroot])
3891    fi
3892
3893    AC_MSG_RESULT($sysroot)
3894
3895    stdlib="-stdlib=libc++"
3896
3897    AC_MSG_CHECKING([what C compiler to use])
3898    CC="`xcrun -find clang`"
3899    CC_BASE=`first_arg_basename "$CC"`
3900    CC+=" -arch $host_cpu_for_clang -isysroot $sysroot $versionmin"
3901    AC_MSG_RESULT([$CC])
3902
3903    AC_MSG_CHECKING([what C++ compiler to use])
3904    CXX="`xcrun -find clang++`"
3905    CXX_BASE=`first_arg_basename "$CXX"`
3906    CXX+=" -arch $host_cpu_for_clang $stdlib -isysroot $sysroot $versionmin"
3907    AC_MSG_RESULT([$CXX])
3908
3909    INSTALL_NAME_TOOL=`xcrun -find install_name_tool`
3910    AR=`xcrun -find ar`
3911    NM=`xcrun -find nm`
3912    STRIP=`xcrun -find strip`
3913    LIBTOOL=`xcrun -find libtool`
3914    RANLIB=`xcrun -find ranlib`
3915fi
3916
3917AC_MSG_CHECKING([whether to treat the installation as read-only])
3918
3919if test $_os = Darwin; then
3920    enable_readonly_installset=yes
3921elif test "$enable_extensions" != yes; then
3922    enable_readonly_installset=yes
3923fi
3924if test "$enable_readonly_installset" = yes; then
3925    AC_MSG_RESULT([yes])
3926    AC_DEFINE(HAVE_FEATURE_READONLY_INSTALLSET)
3927else
3928    AC_MSG_RESULT([no])
3929fi
3930
3931dnl ===================================================================
3932dnl Structure of install set
3933dnl ===================================================================
3934
3935if test $_os = Darwin; then
3936    LIBO_BIN_FOLDER=MacOS
3937    LIBO_ETC_FOLDER=Resources
3938    LIBO_LIBEXEC_FOLDER=MacOS
3939    LIBO_LIB_FOLDER=Frameworks
3940    LIBO_LIB_PYUNO_FOLDER=Resources
3941    LIBO_SHARE_FOLDER=Resources
3942    LIBO_SHARE_HELP_FOLDER=Resources/help
3943    LIBO_SHARE_JAVA_FOLDER=Resources/java
3944    LIBO_SHARE_PRESETS_FOLDER=Resources/presets
3945    LIBO_SHARE_READMES_FOLDER=Resources/readmes
3946    LIBO_SHARE_RESOURCE_FOLDER=Resources/resource
3947    LIBO_SHARE_SHELL_FOLDER=Resources/shell
3948    LIBO_URE_BIN_FOLDER=MacOS
3949    LIBO_URE_ETC_FOLDER=Resources/ure/etc
3950    LIBO_URE_LIB_FOLDER=Frameworks
3951    LIBO_URE_MISC_FOLDER=Resources/ure/share/misc
3952    LIBO_URE_SHARE_JAVA_FOLDER=Resources/java
3953elif test $_os = WINNT; then
3954    LIBO_BIN_FOLDER=program
3955    LIBO_ETC_FOLDER=program
3956    LIBO_LIBEXEC_FOLDER=program
3957    LIBO_LIB_FOLDER=program
3958    LIBO_LIB_PYUNO_FOLDER=program
3959    LIBO_SHARE_FOLDER=share
3960    LIBO_SHARE_HELP_FOLDER=help
3961    LIBO_SHARE_JAVA_FOLDER=program/classes
3962    LIBO_SHARE_PRESETS_FOLDER=presets
3963    LIBO_SHARE_READMES_FOLDER=readmes
3964    LIBO_SHARE_RESOURCE_FOLDER=program/resource
3965    LIBO_SHARE_SHELL_FOLDER=program/shell
3966    LIBO_URE_BIN_FOLDER=program
3967    LIBO_URE_ETC_FOLDER=program
3968    LIBO_URE_LIB_FOLDER=program
3969    LIBO_URE_MISC_FOLDER=program
3970    LIBO_URE_SHARE_JAVA_FOLDER=program/classes
3971else
3972    LIBO_BIN_FOLDER=program
3973    LIBO_ETC_FOLDER=program
3974    LIBO_LIBEXEC_FOLDER=program
3975    LIBO_LIB_FOLDER=program
3976    LIBO_LIB_PYUNO_FOLDER=program
3977    LIBO_SHARE_FOLDER=share
3978    LIBO_SHARE_HELP_FOLDER=help
3979    LIBO_SHARE_JAVA_FOLDER=program/classes
3980    LIBO_SHARE_PRESETS_FOLDER=presets
3981    LIBO_SHARE_READMES_FOLDER=readmes
3982    if test "$enable_fuzzers" != yes; then
3983        LIBO_SHARE_RESOURCE_FOLDER=program/resource
3984    else
3985        LIBO_SHARE_RESOURCE_FOLDER=resource
3986    fi
3987    LIBO_SHARE_SHELL_FOLDER=program/shell
3988    LIBO_URE_BIN_FOLDER=program
3989    LIBO_URE_ETC_FOLDER=program
3990    LIBO_URE_LIB_FOLDER=program
3991    LIBO_URE_MISC_FOLDER=program
3992    LIBO_URE_SHARE_JAVA_FOLDER=program/classes
3993fi
3994AC_DEFINE_UNQUOTED(LIBO_BIN_FOLDER,"$LIBO_BIN_FOLDER")
3995AC_DEFINE_UNQUOTED(LIBO_ETC_FOLDER,"$LIBO_ETC_FOLDER")
3996AC_DEFINE_UNQUOTED(LIBO_LIBEXEC_FOLDER,"$LIBO_LIBEXEC_FOLDER")
3997AC_DEFINE_UNQUOTED(LIBO_LIB_FOLDER,"$LIBO_LIB_FOLDER")
3998AC_DEFINE_UNQUOTED(LIBO_LIB_PYUNO_FOLDER,"$LIBO_LIB_PYUNO_FOLDER")
3999AC_DEFINE_UNQUOTED(LIBO_SHARE_FOLDER,"$LIBO_SHARE_FOLDER")
4000AC_DEFINE_UNQUOTED(LIBO_SHARE_HELP_FOLDER,"$LIBO_SHARE_HELP_FOLDER")
4001AC_DEFINE_UNQUOTED(LIBO_SHARE_JAVA_FOLDER,"$LIBO_SHARE_JAVA_FOLDER")
4002AC_DEFINE_UNQUOTED(LIBO_SHARE_PRESETS_FOLDER,"$LIBO_SHARE_PRESETS_FOLDER")
4003AC_DEFINE_UNQUOTED(LIBO_SHARE_RESOURCE_FOLDER,"$LIBO_SHARE_RESOURCE_FOLDER")
4004AC_DEFINE_UNQUOTED(LIBO_SHARE_SHELL_FOLDER,"$LIBO_SHARE_SHELL_FOLDER")
4005AC_DEFINE_UNQUOTED(LIBO_URE_BIN_FOLDER,"$LIBO_URE_BIN_FOLDER")
4006AC_DEFINE_UNQUOTED(LIBO_URE_ETC_FOLDER,"$LIBO_URE_ETC_FOLDER")
4007AC_DEFINE_UNQUOTED(LIBO_URE_LIB_FOLDER,"$LIBO_URE_LIB_FOLDER")
4008AC_DEFINE_UNQUOTED(LIBO_URE_MISC_FOLDER,"$LIBO_URE_MISC_FOLDER")
4009AC_DEFINE_UNQUOTED(LIBO_URE_SHARE_JAVA_FOLDER,"$LIBO_URE_SHARE_JAVA_FOLDER")
4010
4011# Not all of them needed in config_host.mk, add more if need arises
4012AC_SUBST(LIBO_BIN_FOLDER)
4013AC_SUBST(LIBO_ETC_FOLDER)
4014AC_SUBST(LIBO_LIB_FOLDER)
4015AC_SUBST(LIBO_LIB_PYUNO_FOLDER)
4016AC_SUBST(LIBO_SHARE_FOLDER)
4017AC_SUBST(LIBO_SHARE_HELP_FOLDER)
4018AC_SUBST(LIBO_SHARE_JAVA_FOLDER)
4019AC_SUBST(LIBO_SHARE_PRESETS_FOLDER)
4020AC_SUBST(LIBO_SHARE_READMES_FOLDER)
4021AC_SUBST(LIBO_SHARE_RESOURCE_FOLDER)
4022AC_SUBST(LIBO_URE_BIN_FOLDER)
4023AC_SUBST(LIBO_URE_ETC_FOLDER)
4024AC_SUBST(LIBO_URE_LIB_FOLDER)
4025AC_SUBST(LIBO_URE_MISC_FOLDER)
4026AC_SUBST(LIBO_URE_SHARE_JAVA_FOLDER)
4027
4028dnl ===================================================================
4029dnl Windows specific tests and stuff
4030dnl ===================================================================
4031
4032reg_get_value()
4033{
4034    # Return value: $regvalue
4035    unset regvalue
4036
4037    if test "$build_os" = "wsl"; then
4038        regvalue=$($WSL_LO_HELPER --read-registry $1 "$2/$3" 2>/dev/null)
4039        return
4040    elif test -n "$WSL_ONLY_AS_HELPER"; then
4041        regvalue=$(reg.exe query "$(echo $2 | tr '/' '\\')" /v "$3" /reg:$1 |sed -ne "s|\s*$3.*REG_SZ\s*\(.*\)[\s\r]*$|\1|p")
4042        return
4043    fi
4044
4045    local _regentry="/proc/registry${1}/${2}/${3}"
4046    if test -f "$_regentry"; then
4047        # Stop bash complaining about \0 bytes in input, as it can't handle them.
4048        # Registry keys read via /proc/registry* are always \0 terminated!
4049        local _regvalue=$(tr -d '\0' < "$_regentry")
4050        if test $? -eq 0; then
4051            regvalue=$_regvalue
4052        fi
4053    fi
4054}
4055
4056# Get a value from the 32-bit side of the Registry
4057reg_get_value_32()
4058{
4059    reg_get_value "32" "$1" "$2"
4060}
4061
4062# Get a value from the 64-bit side of the Registry
4063reg_get_value_64()
4064{
4065    reg_get_value "64" "$1" "$2"
4066}
4067
4068reg_list_values()
4069{
4070    # Return value: $reglist
4071    unset reglist
4072
4073    if test "$build_os" = "wsl"; then
4074        reglist=$($WSL_LO_HELPER --list-registry $1 "$2" 2>/dev/null | tr -d '\r')
4075        return
4076    fi
4077
4078    reglist=$(ls "/proc/registry${1}/${2}")
4079}
4080
4081# List values from the 32-bit side of the Registry
4082reg_list_values_32()
4083{
4084    reg_list_values "32" "$1"
4085}
4086
4087# List values from the 64-bit side of the Registry
4088reg_list_values_64()
4089{
4090    reg_list_values "64" "$1"
4091}
4092
4093case "$host_os" in
4094cygwin*|wsl*)
4095    COM=MSC
4096    OS=WNT
4097    RTL_OS=Windows
4098    if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
4099        P_SEP=";"
4100    else
4101        P_SEP=:
4102    fi
4103    case "$host_cpu" in
4104    x86_64)
4105        CPUNAME=X86_64
4106        RTL_ARCH=X86_64
4107        PLATFORMID=windows_x86_64
4108        WINDOWS_X64=1
4109        SCPDEFS="$SCPDEFS -DWINDOWS_X64"
4110        WIN_HOST_ARCH="x64"
4111        WIN_MULTI_ARCH="x86"
4112        WIN_HOST_BITS=64
4113        ;;
4114    i*86)
4115        CPUNAME=INTEL
4116        RTL_ARCH=x86
4117        PLATFORMID=windows_x86
4118        WIN_HOST_ARCH="x86"
4119        WIN_HOST_BITS=32
4120        WIN_OTHER_ARCH="x64"
4121        ;;
4122    aarch64)
4123        CPUNAME=AARCH64
4124        RTL_ARCH=AARCH64
4125        PLATFORMID=windows_aarch64
4126        WINDOWS_X64=1
4127        SCPDEFS="$SCPDEFS -DWINDOWS_AARCH64"
4128        WIN_HOST_ARCH="arm64"
4129        WIN_HOST_BITS=64
4130        with_ucrt_dir=no
4131        ;;
4132    *)
4133        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4134        ;;
4135    esac
4136
4137    case "$build_cpu" in
4138    x86_64) WIN_BUILD_ARCH="x64" ;;
4139    i*86) WIN_BUILD_ARCH="x86" ;;
4140    aarch64) WIN_BUILD_ARCH="arm64" ;;
4141    *)
4142        AC_MSG_ERROR([Unsupported build_cpu $build_cpu for host_os $host_os])
4143        ;;
4144    esac
4145
4146    SCPDEFS="$SCPDEFS -D_MSC_VER"
4147    ;;
4148esac
4149
4150# multi-arch is an arch, which can execute on the host (x86 on x64), while
4151# other-arch won't, but wouldn't break the build (x64 on x86).
4152if test -n "$WIN_MULTI_ARCH" -a -n "$WIN_OTHER_ARCH"; then
4153    AC_MSG_ERROR([Broken configure.ac file: can't have set \$WIN_MULTI_ARCH and $WIN_OTHER_ARCH])
4154fi
4155
4156
4157if test "$build_cpu" != "$host_cpu" -o "$DISABLE_DYNLOADING" = TRUE; then
4158    # To allow building Windows multi-arch releases without cross-tooling
4159    if test "$DISABLE_DYNLOADING" = TRUE -o \( -z "$WIN_MULTI_ARCH" -a -z "$WIN_OTHER_ARCH" \); then
4160        cross_compiling="yes"
4161    fi
4162fi
4163
4164if test "$cross_compiling" = "yes"; then
4165    export CROSS_COMPILING=TRUE
4166    if test "$enable_dynamic_loading" != yes -a "$enable_wasm_strip" = yes; then
4167        ENABLE_WASM_STRIP=TRUE
4168    fi
4169    if test "$_os" = "Emscripten"; then
4170        if test "$with_main_module" = "calc"; then
4171            ENABLE_WASM_STRIP_WRITER=TRUE
4172        elif test "$with_main_module" = "writer"; then
4173            ENABLE_WASM_STRIP_CALC=TRUE
4174        fi
4175    fi
4176else
4177    CROSS_COMPILING=
4178    BUILD_TYPE="$BUILD_TYPE NATIVE"
4179fi
4180AC_SUBST(CROSS_COMPILING)
4181AC_SUBST(ENABLE_WASM_STRIP)
4182AC_SUBST(ENABLE_WASM_STRIP_WRITER)
4183AC_SUBST(ENABLE_WASM_STRIP_CALC)
4184
4185# Use -isystem (gcc) if possible, to avoid warnings in 3rd party headers.
4186# NOTE: must _not_ be used for bundled external libraries!
4187ISYSTEM=
4188if test "$GCC" = "yes"; then
4189    AC_MSG_CHECKING( for -isystem )
4190    save_CFLAGS=$CFLAGS
4191    CFLAGS="$CFLAGS -isystem /usr/include -Werror"
4192    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ ISYSTEM="-isystem " ],[])
4193    CFLAGS=$save_CFLAGS
4194    if test -n "$ISYSTEM"; then
4195        AC_MSG_RESULT(yes)
4196    else
4197        AC_MSG_RESULT(no)
4198    fi
4199fi
4200if test -z "$ISYSTEM"; then
4201    # fall back to using -I
4202    ISYSTEM=-I
4203fi
4204AC_SUBST(ISYSTEM)
4205
4206dnl ===================================================================
4207dnl  Check which Visual Studio compiler is used
4208dnl ===================================================================
4209
4210map_vs_year_to_version()
4211{
4212    # Return value: $vsversion
4213
4214    unset vsversion
4215
4216    case $1 in
4217    2019)
4218        vsversion=16;;
4219    2022)
4220        vsversion=17;;
4221    2022preview)
4222        vsversion=17.11;;
4223    *)
4224        AC_MSG_ERROR([Assertion failure - invalid argument "$1" to map_vs_year_to_version()]);;
4225    esac
4226}
4227
4228vs_versions_to_check()
4229{
4230    # Args: $1 (optional) : versions to check, in the order of preference
4231    # Return value: $vsversions
4232
4233    unset vsversions
4234
4235    if test -n "$1"; then
4236        map_vs_year_to_version "$1"
4237        vsversions=$vsversion
4238    else
4239        # Default version is 2019
4240        vsversions="16"
4241    fi
4242}
4243
4244win_get_env_from_vsdevcmdbat()
4245{
4246    local WRAPPERBATCHFILEPATH="`mktemp -t wrpXXXXXX.bat`"
4247    printf '@set VSCMD_SKIP_SENDTELEMETRY=1\r\n' > $WRAPPERBATCHFILEPATH
4248    PathFormat "$VC_PRODUCT_DIR"
4249    printf '@call "%s/../Common7/Tools/VsDevCmd.bat" /no_logo\r\n' "$formatted_path" >> $WRAPPERBATCHFILEPATH
4250    # use 'echo.%ENV%' syntax (instead of 'echo %ENV%') to avoid outputting "ECHO is off." in case when ENV is empty or a space
4251    printf '@setlocal\r\n@echo.%%%s%%\r\n@endlocal\r\n' "$1" >> $WRAPPERBATCHFILEPATH
4252    local result
4253    if test "$build_os" = "wsl" -o -n "$WSL_ONLY_AS_HELPER"; then
4254        result=$(cd /mnt/c && cmd.exe /c $(wslpath -w $WRAPPERBATCHFILEPATH) | tr -d '\r')
4255    else
4256        chmod +x $WRAPPERBATCHFILEPATH
4257        result=$("$WRAPPERBATCHFILEPATH" | tr -d '\r')
4258    fi
4259    rm -f $WRAPPERBATCHFILEPATH
4260    printf '%s' "$result"
4261}
4262
4263find_ucrt()
4264{
4265    reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v10.0" "InstallationFolder"
4266    if test -n "$regvalue"; then
4267        PathFormat "$regvalue"
4268        UCRTSDKDIR=$formatted_path_unix
4269        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v10.0" "ProductVersion"
4270        if test -n "$regvalue"; then
4271            UCRTVERSION="$regvalue".0
4272        fi
4273
4274        # Rest if not exist
4275        if ! test -d "${UCRTSDKDIR}Include/$UCRTVERSION/ucrt"; then
4276          UCRTSDKDIR=
4277        fi
4278    fi
4279    if test -z "$UCRTSDKDIR"; then
4280        ide_env_dir="$VC_PRODUCT_DIR/../Common7/Tools/"
4281        ide_env_file="${ide_env_dir}VsDevCmd.bat"
4282        if test -f "$ide_env_file"; then
4283            PathFormat "$(win_get_env_from_vsdevcmdbat UniversalCRTSdkDir)"
4284            UCRTSDKDIR=$formatted_path_unix
4285            UCRTVERSION=$(win_get_env_from_vsdevcmdbat UCRTVersion)
4286            dnl Hack needed at least by tml:
4287            if test "$UCRTVERSION" = 10.0.15063.0 \
4288                -a ! -f "${UCRTSDKDIR}Include/10.0.15063.0/um/sqlext.h" \
4289                -a -f "${UCRTSDKDIR}Include/10.0.14393.0/um/sqlext.h"
4290            then
4291                UCRTVERSION=10.0.14393.0
4292            fi
4293        else
4294          AC_MSG_ERROR([No UCRT found])
4295        fi
4296    fi
4297}
4298
4299find_msvc()
4300{
4301    # Find Visual C++
4302    # Args: $1 (optional) : The VS version year
4303    # Return values: $vctest, $vcyear, $vctoolset, $vcnumwithdot, $vcbuildnumber
4304
4305    unset vctest vctoolset vcnumwithdot vcbuildnumber
4306
4307    vs_versions_to_check "$1"
4308    if test "$build_os" = wsl; then
4309        vswhere="$PROGRAMFILESX86"
4310        if test -z "$vswhere"; then
4311            vswhere="c:\\Program Files (x86)"
4312        fi
4313    elif test -n "$WSL_ONLY_AS_HELPER"; then
4314        vswhere="$(perl.exe -e 'print $ENV{"ProgramFiles(x86)"}')"
4315    else
4316        vswhere="$(perl -e 'print $ENV{"ProgramFiles(x86)"}')"
4317    fi
4318    vswhere+="\\Microsoft Visual Studio\\Installer\\vswhere.exe"
4319    PathFormat "$vswhere"
4320    vswhere=$formatted_path_unix
4321    for ver in $vsversions; do
4322        vswhereoutput=`$vswhere -version "@<:@ $ver , $(expr ${ver%%.*} + 1) @:}@" -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | head -1`
4323        if test -z "$vswhereoutput"; then
4324            vswhereoutput=`$vswhere -prerelease -version "@<:@ $ver , $(expr ${ver%%.*} + 1) @:}@" -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | head -1`
4325        fi
4326        # Fall back to all MS products (this includes VC++ Build Tools)
4327        if ! test -n "$vswhereoutput"; then
4328            AC_MSG_CHECKING([VC++ Build Tools and similar])
4329            vswhereoutput=`$vswhere -products \* -version "@<:@ $ver , $(expr ${ver%%.*} + 1) @:}@" -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | head -1`
4330        fi
4331        if test -n "$vswhereoutput"; then
4332            PathFormat "$vswhereoutput"
4333            vctest=$formatted_path_unix
4334            break
4335        fi
4336    done
4337
4338    if test -n "$vctest"; then
4339        vcnumwithdot="$ver"
4340        if test "${vcnumwithdot%%.*}" = "$vcnumwithdot"; then
4341            vcnumwithdot=$vcnumwithdot.0
4342        fi
4343        case "$vcnumwithdot" in
4344        16.0)
4345            vcyear=2019
4346            vctoolset=v142
4347            ;;
4348        17.0 | 17.11)
4349            vcyear=2022
4350            vctoolset=v143
4351            ;;
4352        esac
4353        vcbuildnumber=`ls $vctest/VC/Tools/MSVC -A1r | head -1`
4354
4355    fi
4356}
4357
4358test_cl_exe()
4359{
4360    AC_MSG_CHECKING([$1 compiler])
4361
4362    CL_EXE_PATH="$2/cl.exe"
4363
4364    if test ! -f "$CL_EXE_PATH"; then
4365        if test "$1" = "multi-arch"; then
4366            AC_MSG_WARN([no compiler (cl.exe) in $2])
4367            return 1
4368        else
4369            AC_MSG_ERROR([no compiler (cl.exe) in $2])
4370        fi
4371    fi
4372
4373    dnl ===========================================================
4374    dnl  Check for the corresponding mspdb*.dll
4375    dnl ===========================================================
4376
4377    # MSVC 15.0 has libraries from 14.0?
4378    mspdbnum="140"
4379
4380    if test ! -e "$2/mspdb${mspdbnum}.dll"; then
4381        AC_MSG_ERROR([No mspdb${mspdbnum}.dll in $2, Visual Studio installation broken?])
4382    fi
4383
4384    # The compiles has to find its shared libraries
4385    OLD_PATH="$PATH"
4386    TEMP_PATH=`cygpath -d "$2"`
4387    PATH="`cygpath -u "$TEMP_PATH"`:$PATH"
4388
4389    if ! "$CL_EXE_PATH" -? </dev/null >/dev/null 2>&1; then
4390        AC_MSG_ERROR([no compiler (cl.exe) in $2])
4391    fi
4392
4393    PATH="$OLD_PATH"
4394
4395    AC_MSG_RESULT([$CL_EXE_PATH])
4396}
4397
4398SOLARINC=
4399MSBUILD_PATH=
4400DEVENV=
4401if test "$_os" = "WINNT"; then
4402    AC_MSG_CHECKING([Visual C++])
4403    find_msvc "$with_visual_studio"
4404    if test -z "$vctest"; then
4405        if test -n "$with_visual_studio"; then
4406            AC_MSG_ERROR([no Visual Studio $with_visual_studio installation found])
4407        else
4408            AC_MSG_ERROR([no Visual Studio installation found])
4409        fi
4410    fi
4411    AC_MSG_RESULT([])
4412
4413    VC_PRODUCT_DIR="$vctest/VC"
4414    COMPATH="$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber"
4415
4416    # $WIN_OTHER_ARCH is a hack to test the x64 compiler on x86, even if it's not multi-arch
4417    if test -n "$WIN_MULTI_ARCH" -o -n "$WIN_OTHER_ARCH"; then
4418        MSVC_MULTI_PATH="$COMPATH/bin/Host$WIN_BUILD_ARCH/${WIN_MULTI_ARCH}${WIN_OTHER_ARCH}"
4419        test_cl_exe "multi-arch" "$MSVC_MULTI_PATH"
4420        if test $? -ne 0; then
4421            WIN_MULTI_ARCH=""
4422            WIN_OTHER_ARCH=""
4423        fi
4424    fi
4425
4426    if test "$WIN_BUILD_ARCH" = "$WIN_HOST_ARCH"; then
4427        MSVC_BUILD_PATH="$COMPATH/bin/Host$WIN_BUILD_ARCH/$WIN_BUILD_ARCH"
4428        test_cl_exe "build" "$MSVC_BUILD_PATH"
4429    fi
4430
4431    if test "$WIN_BUILD_ARCH" != "$WIN_HOST_ARCH"; then
4432        MSVC_HOST_PATH="$COMPATH/bin/Host$WIN_BUILD_ARCH/$WIN_HOST_ARCH"
4433        test_cl_exe "host" "$MSVC_HOST_PATH"
4434    else
4435        MSVC_HOST_PATH="$MSVC_BUILD_PATH"
4436    fi
4437
4438    AC_MSG_CHECKING([for short pathname of VC product directory])
4439    VC_PRODUCT_DIR=`win_short_path_for_make "$VC_PRODUCT_DIR"`
4440    AC_MSG_RESULT([$VC_PRODUCT_DIR])
4441
4442    UCRTSDKDIR=
4443    UCRTVERSION=
4444
4445    AC_MSG_CHECKING([for UCRT location])
4446    find_ucrt
4447    # find_ucrt errors out if it doesn't find it
4448    AC_MSG_RESULT([$UCRTSDKDIR ($UCRTVERSION)])
4449    PathFormat "${UCRTSDKDIR}Include/$UCRTVERSION/ucrt"
4450    ucrtincpath_formatted=$formatted_path
4451    # SOLARINC is used for external modules and must be set too.
4452    # And no, it's not sufficient to set SOLARINC only, as configure
4453    # itself doesn't honour it.
4454    SOLARINC="$SOLARINC -I$ucrtincpath_formatted"
4455    CFLAGS="$CFLAGS -I$ucrtincpath_formatted"
4456    CXXFLAGS="$CXXFLAGS -I$ucrtincpath_formatted"
4457    CPPFLAGS="$CPPFLAGS -I$ucrtincpath_formatted"
4458
4459    AC_SUBST(UCRTSDKDIR)
4460    AC_SUBST(UCRTVERSION)
4461
4462    AC_MSG_CHECKING([for MSBuild.exe location for: $vcnumwithdot])
4463    # Find the proper version of MSBuild.exe to use based on the VS version
4464    reg_get_value_32 HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MSBuild/$vcnumwithdot MSBuildOverrideTasksPath
4465    if test -z "$regvalue" ; then
4466        if test "$WIN_BUILD_ARCH" != "x64"; then
4467            regvalue="$VC_PRODUCT_DIR/../MSBuild/Current/Bin"
4468        else
4469            regvalue="$VC_PRODUCT_DIR/../MSBuild/Current/Bin/amd64"
4470        fi
4471    fi
4472    if test -d "$regvalue" ; then
4473        MSBUILD_PATH=`win_short_path_for_make "$regvalue"`
4474        AC_MSG_RESULT([$regvalue])
4475    else
4476        AC_MSG_ERROR([MSBuild.exe location not found])
4477    fi
4478
4479    # Find the version of devenv.exe
4480    PathFormat "$VC_PRODUCT_DIR/../Common7/IDE/devenv.exe"
4481    DEVENV="$formatted_path"
4482    DEVENV_unix="$formatted_path_unix"
4483    if test ! -e "$DEVENV_unix"; then
4484        AC_MSG_WARN([No devenv.exe found - this is expected for VC++ Build Tools])
4485    fi
4486
4487    dnl Save the true MSVC cl.exe for use when CC/CXX is actually clang-cl,
4488    dnl needed when building CLR code:
4489    if test -z "$MSVC_CXX"; then
4490        # This gives us a posix path with 8.3 filename restrictions
4491        MSVC_CXX=`win_short_path_for_make "$MSVC_HOST_PATH/cl.exe"`
4492    fi
4493
4494    if test -z "$CC"; then
4495        CC=$MSVC_CXX
4496        CC_BASE=`first_arg_basename "$CC"`
4497    fi
4498    if test -z "$CXX"; then
4499        CXX=$MSVC_CXX
4500        CXX_BASE=`first_arg_basename "$CXX"`
4501    fi
4502
4503    if test -n "$CC"; then
4504        # Remove /cl.exe from CC case insensitive
4505        AC_MSG_NOTICE([found Visual C++ $vcyear])
4506
4507        PathFormat "$COMPATH"
4508        COMPATH="$formatted_path"
4509        COMPATH_unix="$formatted_path_unix"
4510        CPPFLAGS="$CPPFLAGS -I$COMPATH/Include"
4511
4512        VCVER=$vcnumwithdot
4513        VCTOOLSET=$vctoolset
4514
4515        # The WINDOWS_SDK_ACCEPTABLE_VERSIONS is mostly an educated guess...  Assuming newer ones
4516        # are always "better", we list them in reverse chronological order.
4517
4518        case "$vcnumwithdot" in
4519        16.0 | 17.0 | 17.11)
4520            WINDOWS_SDK_ACCEPTABLE_VERSIONS="10.0 8.1A 8.1 8.0"
4521            ;;
4522        esac
4523
4524        # The expectation is that --with-windows-sdk should not need to be used
4525        if test -n "$with_windows_sdk"; then
4526            case " $WINDOWS_SDK_ACCEPTABLE_VERSIONS " in
4527            *" "$with_windows_sdk" "*)
4528                WINDOWS_SDK_ACCEPTABLE_VERSIONS=$with_windows_sdk
4529                ;;
4530            *)
4531                AC_MSG_ERROR([Windows SDK $with_windows_sdk is not known to work with VS $vcyear])
4532                ;;
4533            esac
4534        fi
4535
4536        # Make AC_COMPILE_IFELSE etc. work (set by AC_PROG_C, which we don't use for MSVC)
4537        ac_objext=obj
4538        ac_exeext=exe
4539
4540    else
4541        AC_MSG_ERROR([Visual C++ not found after all, huh])
4542    fi
4543
4544    # ERROR if VS version < 16.5
4545    AC_MSG_CHECKING([$CC_BASE is at least Visual Studio 2019 version 16.5])
4546    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
4547        // See <https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros> for mapping
4548        // between Visual Studio versions and _MSC_VER:
4549        #if _MSC_VER < 1925
4550        #error
4551        #endif
4552    ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no])])
4553
4554    # WARN if VS version < 16.10
4555    AC_MSG_CHECKING([$CC_BASE is at least Visual Studio 2019 version 16.10])
4556    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
4557        #if _MSC_VER < 1929
4558        #error
4559        #endif
4560    ]])],[vs2019_recommended_version=yes],[vs2019_recommended_version=no])
4561
4562    if test $vs2019_recommended_version = yes; then
4563        AC_MSG_RESULT([yes])
4564    else
4565        AC_MSG_WARN([no])
4566        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."
4567    fi
4568
4569    # Check for 64-bit (cross-)compiler to use to build the 64-bit
4570    # version of the Explorer extension (and maybe other small
4571    # bits, too) needed when installing a 32-bit LibreOffice on a
4572    # 64-bit OS. The 64-bit Explorer extension is a feature that
4573    # has been present since long in OOo. Don't confuse it with
4574    # building LibreOffice itself as 64-bit code.
4575
4576    BUILD_X64=
4577    CXX_X64_BINARY=
4578
4579    if test "$WIN_HOST_ARCH" = "x86" -a -n "$WIN_OTHER_ARCH"; then
4580        AC_MSG_CHECKING([for the libraries to build the 64-bit Explorer extensions])
4581        if test -f "$COMPATH/atlmfc/lib/x64/atls.lib" -o \
4582             -f "$COMPATH/atlmfc/lib/spectre/x64/atls.lib"
4583        then
4584            BUILD_X64=TRUE
4585            CXX_X64_BINARY=`win_short_path_for_make "$MSVC_MULTI_PATH/cl.exe"`
4586            AC_MSG_RESULT([found])
4587        else
4588            AC_MSG_RESULT([not found])
4589            AC_MSG_WARN([Installation set will not contain 64-bit Explorer extensions])
4590        fi
4591    elif test "$WIN_HOST_ARCH" = "x64"; then
4592        CXX_X64_BINARY=$CXX
4593    fi
4594    AC_SUBST(BUILD_X64)
4595
4596    # These are passed to the environment and then used in gbuild/platform/com_MSC_class.mk
4597    AC_SUBST(CXX_X64_BINARY)
4598
4599    # Check for 32-bit compiler to use to build the 32-bit TWAIN shim
4600    # needed to support TWAIN scan on both 32- and 64-bit systems
4601
4602    case "$WIN_HOST_ARCH" in
4603    x64)
4604        AC_MSG_CHECKING([for a x86 compiler and libraries for 32-bit binaries required for TWAIN support])
4605        if test -n "$CXX_X86_BINARY"; then
4606            BUILD_X86=TRUE
4607            AC_MSG_RESULT([preset])
4608        elif test -n "$WIN_MULTI_ARCH"; then
4609            BUILD_X86=TRUE
4610            CXX_X86_BINARY=`win_short_path_for_make "$MSVC_MULTI_PATH/cl.exe"`
4611            AC_MSG_RESULT([found])
4612        else
4613            AC_MSG_RESULT([not found])
4614            AC_MSG_WARN([Installation set will not contain 32-bit binaries required for TWAIN support])
4615        fi
4616        ;;
4617    x86)
4618        BUILD_X86=TRUE
4619        CXX_X86_BINARY=$MSVC_CXX
4620        ;;
4621    esac
4622    AC_SUBST(BUILD_X86)
4623    AC_SUBST(CXX_X86_BINARY)
4624fi
4625AC_SUBST(VCVER)
4626AC_SUBST(VCTOOLSET)
4627AC_SUBST(DEVENV)
4628AC_SUBST(MSVC_CXX)
4629
4630COM_IS_CLANG=
4631AC_MSG_CHECKING([whether the compiler is actually Clang])
4632AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
4633    #ifndef __clang__
4634    you lose
4635    #endif
4636    int foo=42;
4637    ]])],
4638    [AC_MSG_RESULT([yes])
4639     COM_IS_CLANG=TRUE],
4640    [AC_MSG_RESULT([no])])
4641AC_SUBST(COM_IS_CLANG)
4642
4643CLANGVER=
4644if test "$COM_IS_CLANG" = TRUE; then
4645    AC_MSG_CHECKING([whether Clang is new enough])
4646    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
4647        #if !defined __apple_build_version__
4648        #error
4649        #endif
4650        ]])],
4651        [my_apple_clang=yes],[my_apple_clang=])
4652    if test "$my_apple_clang" = yes; then
4653        AC_MSG_RESULT([assumed yes (Apple Clang)])
4654    elif test "$_os" = Emscripten; then
4655        AC_MSG_RESULT([assumed yes (Emscripten Clang)])
4656    else
4657        if test "$_os" = WINNT; then
4658            dnl In which case, assume clang-cl:
4659            my_args="/EP /TC"
4660        else
4661            my_args="-E -P"
4662        fi
4663        clang_version=`echo __clang_major__.__clang_minor__.__clang_patchlevel__ | $CC $my_args - | sed 's/ //g'`
4664        CLANG_FULL_VERSION=`echo __clang_version__ | $CC $my_args -`
4665        CLANGVER=`echo $clang_version \
4666            | $AWK -F. '{ print \$1*10000+(\$2<100?\$2:99)*100+(\$3<100?\$3:99) }'`
4667        if test "$CLANGVER" -ge 120000; then
4668            AC_MSG_RESULT([yes ($clang_version)])
4669        else
4670            AC_MSG_ERROR(["$CLANG_FULL_VERSION" is too old or unrecognized, must be at least Clang 12])
4671        fi
4672        AC_DEFINE_UNQUOTED(CLANG_VERSION,$CLANGVER)
4673        AC_DEFINE_UNQUOTED(CLANG_FULL_VERSION,$CLANG_FULL_VERSION)
4674    fi
4675fi
4676
4677SHOWINCLUDES_PREFIX=
4678if test "$_os" = WINNT; then
4679    dnl We need to guess the prefix of the -showIncludes output, it can be
4680    dnl localized
4681    AC_MSG_CHECKING([the dependency generation prefix (cl.exe -showIncludes)])
4682    echo "#include <stdlib.h>" > conftest.c
4683    SHOWINCLUDES_PREFIX=`VSLANG=1033 $CC $CFLAGS -c -showIncludes conftest.c 2>/dev/null | \
4684        grep 'stdlib\.h' | head -n1 | sed 's/ [[[:alpha:]]]:.*//'`
4685    rm -f conftest.c conftest.obj
4686    if test -z "$SHOWINCLUDES_PREFIX"; then
4687        AC_MSG_ERROR([cannot determine the -showIncludes prefix])
4688    else
4689        AC_MSG_RESULT(["$SHOWINCLUDES_PREFIX"])
4690    fi
4691fi
4692AC_SUBST(SHOWINCLUDES_PREFIX)
4693
4694#
4695# prefix C with ccache if needed
4696#
4697if test "$CCACHE" != ""; then
4698    AC_MSG_CHECKING([whether $CC_BASE is already ccached])
4699
4700    AC_LANG_PUSH([C])
4701    save_CFLAGS=$CFLAGS
4702    CFLAGS="$CFLAGS --ccache-skip -O2"
4703    # msvc does not fail on unknown options, check stdout
4704    if test "$COM" = MSC; then
4705        CFLAGS="$CFLAGS -nologo"
4706    fi
4707    save_ac_c_werror_flag=$ac_c_werror_flag
4708    ac_c_werror_flag=yes
4709    dnl an empty program will do, we're checking the compiler flags
4710    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
4711                      [use_ccache=yes], [use_ccache=no])
4712    CFLAGS=$save_CFLAGS
4713    ac_c_werror_flag=$save_ac_c_werror_flag
4714    if test $use_ccache = yes -a "${CCACHE/*sccache*/}" != ""; then
4715        AC_MSG_RESULT([yes])
4716    else
4717        CC="$CCACHE $CC"
4718        CC_BASE="ccache $CC_BASE"
4719        AC_MSG_RESULT([no])
4720    fi
4721    AC_LANG_POP([C])
4722fi
4723
4724# ===================================================================
4725# check various GCC options that Clang does not support now but maybe
4726# will somewhen in the future, check them even for GCC, so that the
4727# flags are set
4728# ===================================================================
4729
4730HAVE_GCC_GGDB2=
4731if test "$GCC" = "yes" -a "$_os" != "Emscripten"; then
4732    AC_MSG_CHECKING([whether $CC_BASE supports -ggdb2])
4733    save_CFLAGS=$CFLAGS
4734    CFLAGS="$CFLAGS -Werror -ggdb2"
4735    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_GGDB2=TRUE ],[])
4736    CFLAGS=$save_CFLAGS
4737    if test "$HAVE_GCC_GGDB2" = "TRUE"; then
4738        AC_MSG_RESULT([yes])
4739    else
4740        AC_MSG_RESULT([no])
4741    fi
4742
4743    if test "$host_cpu" = "m68k"; then
4744        AC_MSG_CHECKING([whether $CC_BASE supports -mlong-jump-table-offsets])
4745        save_CFLAGS=$CFLAGS
4746        CFLAGS="$CFLAGS -Werror -mlong-jump-table-offsets"
4747        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_LONG_JUMP_TABLE_OFFSETS=TRUE ],[])
4748        CFLAGS=$save_CFLAGS
4749        if test "$HAVE_GCC_LONG_JUMP_TABLE_OFFSETS" = "TRUE"; then
4750            AC_MSG_RESULT([yes])
4751        else
4752            AC_MSG_ERROR([no])
4753        fi
4754    fi
4755fi
4756AC_SUBST(HAVE_GCC_GGDB2)
4757
4758dnl ===================================================================
4759dnl  Test the gcc version
4760dnl ===================================================================
4761if test "$GCC" = "yes" -a -z "$COM_IS_CLANG"; then
4762    AC_MSG_CHECKING([the GCC version])
4763    _gcc_version=`$CC -dumpfullversion`
4764    gcc_full_version=$(printf '%s' "$_gcc_version" | \
4765        $AWK -F. '{ print $1*10000+$2*100+(NF<3?1:$3) }')
4766    GCC_VERSION=`echo $_gcc_version | $AWK -F. '{ print \$1*100+\$2 }'`
4767
4768    AC_MSG_RESULT([gcc $_gcc_version ($gcc_full_version)])
4769
4770    if test "$gcc_full_version" -lt 120000; then
4771        AC_MSG_ERROR([GCC $_gcc_version is too old, must be at least GCC 12])
4772    fi
4773else
4774    # Explicitly force GCC_VERSION to be empty, even for Clang, to check incorrect uses.
4775    # GCC version should generally be checked only when handling GCC-specific bugs, for testing
4776    # things like features configure checks should be used, otherwise they may e.g. fail with Clang
4777    # (which reports itself as GCC 4.2.1).
4778    GCC_VERSION=
4779fi
4780AC_SUBST(GCC_VERSION)
4781
4782dnl Set the ENABLE_DBGUTIL variable
4783dnl ===================================================================
4784AC_MSG_CHECKING([whether to build with additional debug utilities])
4785if test -n "$enable_dbgutil" -a "$enable_dbgutil" != "no"; then
4786    ENABLE_DBGUTIL="TRUE"
4787    # this is an extra var so it can have different default on different MSVC
4788    # versions (in case there are version specific problems with it)
4789    MSVC_USE_DEBUG_RUNTIME="TRUE"
4790
4791    AC_MSG_RESULT([yes])
4792    # cppunit and graphite expose STL in public headers
4793    if test "$with_system_cppunit" = "yes"; then
4794        AC_MSG_ERROR([--with-system-cppunit conflicts with --enable-dbgutil])
4795    else
4796        with_system_cppunit=no
4797    fi
4798    if test "$with_system_graphite" = "yes"; then
4799        AC_MSG_ERROR([--with-system-graphite conflicts with --enable-dbgutil])
4800    else
4801        with_system_graphite=no
4802    fi
4803    if test "$with_system_orcus" = "yes"; then
4804        AC_MSG_ERROR([--with-system-orcus conflicts with --enable-dbgutil])
4805    else
4806        with_system_orcus=no
4807    fi
4808    if test "$with_system_libcmis" = "yes"; then
4809        AC_MSG_ERROR([--with-system-libcmis conflicts with --enable-dbgutil])
4810    else
4811        with_system_libcmis=no
4812    fi
4813    if test "$with_system_hunspell" = "yes"; then
4814        AC_MSG_ERROR([--with-system-hunspell conflicts with --enable-dbgutil])
4815    else
4816        with_system_hunspell=no
4817    fi
4818    if test "$with_system_gpgmepp" = "yes"; then
4819        AC_MSG_ERROR([--with-system-gpgmepp conflicts with --enable-dbgutil])
4820    else
4821        with_system_gpgmepp=no
4822    fi
4823    if test "$with_system_zxing" = "yes"; then
4824        AC_MSG_ERROR([--with-system-zxing conflicts with --enable-dbgutil])
4825    else
4826        with_system_zxing=no
4827    fi
4828    if test "$with_system_poppler" = "yes"; then
4829        AC_MSG_ERROR([--with-system-poppler conflicts with --enable-dbgutil])
4830    else
4831        with_system_poppler=no
4832    fi
4833    # As mixing system libwps and non-system libnumbertext or vice versa likely causes trouble (see
4834    # 603074c5f2b84de8a24593faf807da784b040625 "Pass _GLIBCXX_DEBUG into external/libwps" and the
4835    # mail thread starting at <https://gcc.gnu.org/ml/gcc/2018-05/msg00057.html> "libstdc++: ODR
4836    # violation when using std::regex with and without -D_GLIBCXX_DEBUG"), simply make sure neither
4837    # of those two is using the system variant:
4838    if test "$with_system_libnumbertext" = "yes"; then
4839        AC_MSG_ERROR([--with-system-libnumbertext conflicts with --enable-dbgutil])
4840    else
4841        with_system_libnumbertext=no
4842    fi
4843    if test "$with_system_libwps" = "yes"; then
4844        AC_MSG_ERROR([--with-system-libwps conflicts with --enable-dbgutil])
4845    else
4846        with_system_libwps=no
4847    fi
4848else
4849    ENABLE_DBGUTIL=""
4850    MSVC_USE_DEBUG_RUNTIME=""
4851    AC_MSG_RESULT([no])
4852fi
4853AC_SUBST(ENABLE_DBGUTIL)
4854AC_SUBST(MSVC_USE_DEBUG_RUNTIME)
4855
4856dnl Set the ENABLE_DEBUG variable.
4857dnl ===================================================================
4858if test -n "$enable_debug" && test "$enable_debug" != "yes" && test "$enable_debug" != "no"; then
4859    AC_MSG_ERROR([--enable-debug now accepts only yes or no, use --enable-symbols])
4860fi
4861if test -n "$ENABLE_DBGUTIL" -a "$enable_debug" = "no"; then
4862    if test -z "$libo_fuzzed_enable_debug"; then
4863        AC_MSG_ERROR([--disable-debug cannot be used with --enable-dbgutil])
4864    else
4865        AC_MSG_NOTICE([Resetting --enable-debug=yes])
4866        enable_debug=yes
4867    fi
4868fi
4869
4870AC_MSG_CHECKING([whether to do a debug build])
4871if test -n "$ENABLE_DBGUTIL" -o \( -n "$enable_debug" -a "$enable_debug" != "no" \) ; then
4872    ENABLE_DEBUG="TRUE"
4873    if test -n "$ENABLE_DBGUTIL" ; then
4874        AC_MSG_RESULT([yes (dbgutil)])
4875    else
4876        AC_MSG_RESULT([yes])
4877    fi
4878else
4879    ENABLE_DEBUG=""
4880    AC_MSG_RESULT([no])
4881fi
4882AC_SUBST(ENABLE_DEBUG)
4883
4884dnl ===================================================================
4885dnl Select the linker to use (gold/lld/ld.bfd/mold).
4886dnl This is done only after compiler checks (need to know if Clang is
4887dnl used, for different defaults) and after checking if a debug build
4888dnl is wanted (non-debug builds get the default linker if not explicitly
4889dnl specified otherwise).
4890dnl All checks for linker features/options should come after this.
4891dnl ===================================================================
4892check_use_ld()
4893{
4894    use_ld=-fuse-ld=${1%%:*}
4895    use_ld_path=${1#*:}
4896    if test "$use_ld_path" != "$1"; then
4897        if test "$COM_IS_CLANG" = TRUE; then
4898            if test "$CLANGVER" -ge 120000; then
4899                use_ld="${use_ld} --ld-path=${use_ld_path}"
4900            else
4901                use_ld="-fuse-ld=${use_ld_path}"
4902            fi
4903        else
4904            # I tried to use gcc's '-B<path>' and a directory + symlink setup in
4905            # $BUILDDIR, but libtool always filtered-out that option, so gcc wouldn't
4906            # pickup the alternative linker, when called by libtool for linking.
4907            # For mold, one can use LD_PRELOAD=/usr/lib/mold/mold-wrapper.so instead.
4908            AC_MSG_ERROR([A linker path is just supported with clang, because of libtool's -B filtering!])
4909        fi
4910    fi
4911    use_ld_fail_if_error=$2
4912    use_ld_ok=
4913    AC_MSG_CHECKING([for $use_ld linker support])
4914    use_ld_ldflags_save="$LDFLAGS"
4915    LDFLAGS="$LDFLAGS $use_ld"
4916    AC_LINK_IFELSE([AC_LANG_PROGRAM([
4917#include <stdio.h>
4918        ],[
4919printf ("hello world\n");
4920        ])], USE_LD=$use_ld, [])
4921    if test -n "$USE_LD"; then
4922        AC_MSG_RESULT( yes )
4923        use_ld_ok=yes
4924    else
4925        if test -n "$use_ld_fail_if_error"; then
4926            AC_MSG_ERROR( no )
4927        else
4928            AC_MSG_RESULT( no )
4929        fi
4930    fi
4931    if test -n "$use_ld_ok"; then
4932        dnl keep the value of LDFLAGS
4933        return 0
4934    fi
4935    LDFLAGS="$use_ld_ldflags_save"
4936    return 1
4937}
4938USE_LD=
4939if test "$enable_ld" != "no"; then
4940    if test "$GCC" = "yes" -a "$_os" != "Emscripten"; then
4941        if test -n "$enable_ld"; then
4942            check_use_ld "$enable_ld" fail_if_error
4943        elif test -z "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
4944            dnl non-debug builds default to the default linker
4945            true
4946        elif test -n "$COM_IS_CLANG"; then
4947            check_use_ld lld
4948            if test $? -ne 0; then
4949                check_use_ld gold
4950                if test $? -ne 0; then
4951                    check_use_ld mold
4952                fi
4953            fi
4954        else
4955            # For gcc first try gold, new versions also support lld/mold.
4956            check_use_ld gold
4957            if test $? -ne 0; then
4958                check_use_ld lld
4959                if test $? -ne 0; then
4960                    check_use_ld mold
4961                fi
4962            fi
4963        fi
4964        ld_output=$(echo 'int main() { return 0; }' | $CC -Wl,-v -x c -o conftest.out - $CFLAGS $LDFLAGS 2>/dev/null)
4965        rm conftest.out
4966        ld_used=$(echo "$ld_output" | grep -E '(^GNU gold|^GNU ld|^LLD|^mold)')
4967        if test -z "$ld_used"; then
4968            ld_used="unknown"
4969        fi
4970        AC_MSG_CHECKING([for linker that is used])
4971        AC_MSG_RESULT([$ld_used])
4972        if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
4973            if echo "$ld_used" | grep -q "^GNU ld"; then
4974                AC_MSG_WARN([The default GNU linker is slow, consider using LLD, mold or the GNU gold linker.])
4975                add_warning "The default GNU linker is slow, consider using LLD, mold or the GNU gold linker."
4976            fi
4977        fi
4978    else
4979        if test "$enable_ld" = "yes"; then
4980            AC_MSG_ERROR([--enable-ld not supported])
4981        fi
4982    fi
4983fi
4984AC_SUBST(USE_LD)
4985AC_SUBST(LD)
4986
4987HAVE_LD_BSYMBOLIC_FUNCTIONS=
4988if test "$GCC" = "yes" -a "$_os" != Emscripten ; then
4989    AC_MSG_CHECKING([for -Bsymbolic-functions linker support])
4990    bsymbolic_functions_ldflags_save=$LDFLAGS
4991    LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
4992    AC_LINK_IFELSE([AC_LANG_PROGRAM([
4993#include <stdio.h>
4994        ],[
4995printf ("hello world\n");
4996        ])], HAVE_LD_BSYMBOLIC_FUNCTIONS=TRUE, [])
4997    if test "$HAVE_LD_BSYMBOLIC_FUNCTIONS" = "TRUE"; then
4998        AC_MSG_RESULT( found )
4999    else
5000        AC_MSG_RESULT( not found )
5001    fi
5002    LDFLAGS=$bsymbolic_functions_ldflags_save
5003fi
5004AC_SUBST(HAVE_LD_BSYMBOLIC_FUNCTIONS)
5005
5006LD_GC_SECTIONS=
5007if test "$GCC" = "yes"; then
5008    for flag in "--gc-sections" "-dead_strip"; do
5009        AC_MSG_CHECKING([for $flag linker support])
5010        ldflags_save=$LDFLAGS
5011        LDFLAGS="$LDFLAGS -Wl,$flag"
5012        AC_LINK_IFELSE([AC_LANG_PROGRAM([
5013#include <stdio.h>
5014            ],[
5015printf ("hello world\n");
5016            ])],[
5017            LD_GC_SECTIONS="-Wl,$flag"
5018            AC_MSG_RESULT( found )
5019            ], [
5020            AC_MSG_RESULT( not found )
5021            ])
5022        LDFLAGS=$ldflags_save
5023        if test -n "$LD_GC_SECTIONS"; then
5024            break
5025        fi
5026    done
5027fi
5028AC_SUBST(LD_GC_SECTIONS)
5029
5030HAVE_EXTERNAL_DWARF=
5031if test "$enable_split_debug" != no; then
5032    use_split_debug=
5033    if test -n "$ENABLE_LTO"; then
5034        : # Inherently incompatible, since no debug info is created while compiling, GCC complains.
5035    elif test "$enable_split_debug" = yes; then
5036        use_split_debug=1
5037    dnl Currently by default enabled only on Linux, feel free to set test_split_debug above also for other platforms.
5038    elif test "$test_split_debug" = "yes" -a -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
5039        use_split_debug=1
5040    fi
5041    if test -n "$use_split_debug"; then
5042        if test "$_os" = "Emscripten"; then
5043            TEST_CC_FLAG=-gsplit-dwarf -gpubnames
5044        else
5045            TEST_CC_FLAG=-gsplit-dwarf
5046        fi
5047        AC_MSG_CHECKING([whether $CC_BASE supports $TEST_CC_FLAG])
5048        save_CFLAGS=$CFLAGS
5049        CFLAGS="$CFLAGS -Werror $TEST_CC_FLAG"
5050        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_EXTERNAL_DWARF=TRUE ],[])
5051        CFLAGS=$save_CFLAGS
5052        if test "$HAVE_EXTERNAL_DWARF" = "TRUE"; then
5053            AC_MSG_RESULT([yes])
5054        else
5055            if test "$enable_split_debug" = yes; then
5056                AC_MSG_ERROR([no])
5057            else
5058                AC_MSG_RESULT([no])
5059            fi
5060        fi
5061    fi
5062    if test -z "$HAVE_EXTERNAL_DWARF" -a "$test_split_debug" = "yes" -a -n "$use_split_debug"; then
5063        AC_MSG_WARN([Compiler is not capable of creating split debug info, linking will require more time and disk space.])
5064        add_warning "Compiler is not capable of creating split debug info, linking will require more time and disk space."
5065    fi
5066fi
5067AC_SUBST(HAVE_EXTERNAL_DWARF)
5068
5069HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR=
5070AC_MSG_CHECKING([whether $CC_BASE supports -Xclang -debug-info-kind=constructor])
5071save_CFLAGS=$CFLAGS
5072CFLAGS="$CFLAGS -Werror -Xclang -debug-info-kind=constructor"
5073AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR=TRUE ],[])
5074CFLAGS=$save_CFLAGS
5075if test "$HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR" = "TRUE"; then
5076    AC_MSG_RESULT([yes])
5077else
5078    AC_MSG_RESULT([no])
5079fi
5080AC_SUBST(HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR)
5081
5082ENABLE_GDB_INDEX=
5083if test "$enable_gdb_index" != "no"; then
5084    dnl Currently by default enabled only on Linux, feel free to set test_gdb_index above also for other platforms.
5085    if test "$enable_gdb_index" = yes -o \( "$test_gdb_index" = "yes" -a -n "$ENABLE_DEBUG$ENABLE_DBGUTIL" \); then
5086        AC_MSG_CHECKING([whether $CC_BASE supports -ggnu-pubnames])
5087        save_CFLAGS=$CFLAGS
5088        CFLAGS="$CFLAGS -Werror -g -ggnu-pubnames"
5089        have_ggnu_pubnames=
5090        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[have_ggnu_pubnames=TRUE],[have_ggnu_pubnames=])
5091        if test "$have_ggnu_pubnames" != "TRUE"; then
5092            if test "$enable_gdb_index" = "yes"; then
5093                AC_MSG_ERROR([no, --enable-gdb-index not supported])
5094            else
5095                AC_MSG_RESULT( no )
5096            fi
5097        else
5098            AC_MSG_RESULT( yes )
5099            AC_MSG_CHECKING([whether $CC_BASE supports -Wl,--gdb-index])
5100            ldflags_save=$LDFLAGS
5101            LDFLAGS="$LDFLAGS -Wl,--gdb-index"
5102            AC_LINK_IFELSE([AC_LANG_PROGRAM([
5103#include <stdio.h>
5104                ],[
5105printf ("hello world\n");
5106                ])], ENABLE_GDB_INDEX=TRUE, [])
5107            if test "$ENABLE_GDB_INDEX" = "TRUE"; then
5108                AC_MSG_RESULT( yes )
5109            else
5110                if test "$enable_gdb_index" = "yes"; then
5111                    AC_MSG_ERROR( no )
5112                else
5113                    AC_MSG_RESULT( no )
5114                fi
5115            fi
5116            LDFLAGS=$ldflags_save
5117        fi
5118        CFLAGS=$save_CFLAGS
5119        fi
5120    if test -z "$ENABLE_GDB_INDEX" -a "$test_gdb_index" = "yes" -a -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
5121        AC_MSG_WARN([Linker is not capable of creating gdb index, debugger startup will be slow.])
5122        add_warning "Linker is not capable of creating gdb index, debugger startup will be slow."
5123    fi
5124fi
5125AC_SUBST(ENABLE_GDB_INDEX)
5126
5127if test -z "$enable_sal_log" && test "$ENABLE_DEBUG" = TRUE; then
5128    enable_sal_log=yes
5129fi
5130if test "$enable_sal_log" = yes; then
5131    ENABLE_SAL_LOG=TRUE
5132fi
5133AC_SUBST(ENABLE_SAL_LOG)
5134
5135dnl Check for enable symbols option
5136dnl ===================================================================
5137AC_MSG_CHECKING([whether to generate debug information])
5138if test -z "$enable_symbols"; then
5139    if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
5140        enable_symbols=yes
5141    else
5142        enable_symbols=no
5143    fi
5144fi
5145if test "$enable_symbols" = yes; then
5146    ENABLE_SYMBOLS_FOR=all
5147    AC_MSG_RESULT([yes])
5148elif test "$enable_symbols" = no; then
5149    ENABLE_SYMBOLS_FOR=
5150    AC_MSG_RESULT([no])
5151else
5152    # Selective debuginfo.
5153    ENABLE_SYMBOLS_FOR="$enable_symbols"
5154    AC_MSG_RESULT([for "$enable_symbols"])
5155fi
5156AC_SUBST(ENABLE_SYMBOLS_FOR)
5157
5158if test -n "$with_android_ndk" -a \( -n "$ENABLE_DEBUG" -o -n "$ENABLE_DBGUTIL" \) -a "$ENABLE_SYMBOLS_FOR" = "all"; then
5159    # Building on Android with full symbols: without enough memory the linker never finishes currently.
5160    AC_MSG_CHECKING([whether enough memory is available for linking])
5161    mem_size=$(grep -o 'MemTotal: *.\+ kB' /proc/meminfo | sed 's/MemTotal: *\(.\+\) kB/\1/')
5162    # Check for 15GB, as Linux reports a bit less than the physical memory size.
5163    if test -n "$mem_size" -a $mem_size -lt 15728640; then
5164        AC_MSG_ERROR([building with full symbols and less than 16GB of memory is not supported])
5165    else
5166        AC_MSG_RESULT([yes])
5167    fi
5168fi
5169
5170ENABLE_OPTIMIZED=
5171ENABLE_OPTIMIZED_DEBUG=
5172AC_MSG_CHECKING([whether to compile with optimization flags])
5173if test -z "$enable_optimized"; then
5174    if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
5175        enable_optimized=no
5176    else
5177        enable_optimized=yes
5178    fi
5179fi
5180if test "$enable_optimized" = yes; then
5181    ENABLE_OPTIMIZED=TRUE
5182    AC_MSG_RESULT([yes])
5183elif test "$enable_optimized" = debug; then
5184    ENABLE_OPTIMIZED_DEBUG=TRUE
5185    AC_MSG_RESULT([yes (debug)])
5186    HAVE_GCC_OG=
5187    if test "$GCC" = "yes" -a "$_os" != "Emscripten"; then
5188        AC_MSG_CHECKING([whether $CC_BASE supports -Og])
5189        save_CFLAGS=$CFLAGS
5190        CFLAGS="$CFLAGS -Werror -Og"
5191        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_OG=TRUE ],[])
5192        CFLAGS=$save_CFLAGS
5193        if test "$HAVE_GCC_OG" = "TRUE"; then
5194            AC_MSG_RESULT([yes])
5195        else
5196            AC_MSG_RESULT([no])
5197        fi
5198    fi
5199    if test -z "$HAVE_GCC_OG" -a "$_os" != "Emscripten"; then
5200        AC_MSG_ERROR([The compiler does not support optimizations suitable for debugging.])
5201    fi
5202else
5203    AC_MSG_RESULT([no])
5204fi
5205AC_SUBST(ENABLE_OPTIMIZED)
5206AC_SUBST(ENABLE_OPTIMIZED_DEBUG)
5207
5208#
5209# determine CPUNAME, OS, ...
5210#
5211case "$host_os" in
5212
5213cygwin*|wsl*)
5214    # Already handled
5215    ;;
5216
5217darwin*)
5218    COM=GCC
5219    OS=MACOSX
5220    RTL_OS=MacOSX
5221    P_SEP=:
5222
5223    case "$host_cpu" in
5224    aarch64|arm64)
5225        if test "$enable_ios_simulator" = "yes"; then
5226            OS=iOS
5227        else
5228            CPUNAME=AARCH64
5229            RTL_ARCH=AARCH64
5230            PLATFORMID=macosx_aarch64
5231        fi
5232        ;;
5233    x86_64)
5234        if test "$enable_ios_simulator" = "yes"; then
5235            OS=iOS
5236        fi
5237        CPUNAME=X86_64
5238        RTL_ARCH=X86_64
5239        PLATFORMID=macosx_x86_64
5240        ;;
5241    *)
5242        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5243        ;;
5244    esac
5245    ;;
5246
5247ios*)
5248    COM=GCC
5249    OS=iOS
5250    RTL_OS=iOS
5251    P_SEP=:
5252
5253    case "$host_cpu" in
5254    aarch64|arm64)
5255        if test "$enable_ios_simulator" = "yes"; then
5256            AC_MSG_ERROR([iOS simulator is only available in macOS not iOS])
5257        fi
5258        ;;
5259    *)
5260        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5261        ;;
5262    esac
5263    CPUNAME=AARCH64
5264    RTL_ARCH=AARCH64
5265    PLATFORMID=ios_arm64
5266    ;;
5267
5268dragonfly*)
5269    COM=GCC
5270    OS=DRAGONFLY
5271    RTL_OS=DragonFly
5272    P_SEP=:
5273
5274    case "$host_cpu" in
5275    i*86)
5276        CPUNAME=INTEL
5277        RTL_ARCH=x86
5278        PLATFORMID=dragonfly_x86
5279        ;;
5280    x86_64)
5281        CPUNAME=X86_64
5282        RTL_ARCH=X86_64
5283        PLATFORMID=dragonfly_x86_64
5284        ;;
5285    *)
5286        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5287        ;;
5288    esac
5289    ;;
5290
5291freebsd*)
5292    COM=GCC
5293    RTL_OS=FreeBSD
5294    OS=FREEBSD
5295    P_SEP=:
5296
5297    case "$host_cpu" in
5298    aarch64)
5299        CPUNAME=AARCH64
5300        PLATFORMID=freebsd_aarch64
5301        RTL_ARCH=AARCH64
5302        ;;
5303    i*86)
5304        CPUNAME=INTEL
5305        RTL_ARCH=x86
5306        PLATFORMID=freebsd_x86
5307        ;;
5308    x86_64|amd64)
5309        CPUNAME=X86_64
5310        RTL_ARCH=X86_64
5311        PLATFORMID=freebsd_x86_64
5312        ;;
5313    powerpc64)
5314        CPUNAME=POWERPC64
5315        RTL_ARCH=PowerPC_64
5316        PLATFORMID=freebsd_powerpc64
5317        ;;
5318    powerpc|powerpcspe)
5319        CPUNAME=POWERPC
5320        RTL_ARCH=PowerPC
5321        PLATFORMID=freebsd_powerpc
5322        ;;
5323    *)
5324        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5325        ;;
5326    esac
5327    ;;
5328
5329haiku*)
5330    COM=GCC
5331    GUIBASE=haiku
5332    RTL_OS=Haiku
5333    OS=HAIKU
5334    P_SEP=:
5335
5336    case "$host_cpu" in
5337    i*86)
5338        CPUNAME=INTEL
5339        RTL_ARCH=x86
5340        PLATFORMID=haiku_x86
5341        ;;
5342    x86_64|amd64)
5343        CPUNAME=X86_64
5344        RTL_ARCH=X86_64
5345        PLATFORMID=haiku_x86_64
5346        ;;
5347    *)
5348        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5349        ;;
5350    esac
5351    ;;
5352
5353kfreebsd*)
5354    COM=GCC
5355    OS=LINUX
5356    RTL_OS=kFreeBSD
5357    P_SEP=:
5358
5359    case "$host_cpu" in
5360
5361    i*86)
5362        CPUNAME=INTEL
5363        RTL_ARCH=x86
5364        PLATFORMID=kfreebsd_x86
5365        ;;
5366    x86_64)
5367        CPUNAME=X86_64
5368        RTL_ARCH=X86_64
5369        PLATFORMID=kfreebsd_x86_64
5370        ;;
5371    *)
5372        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5373        ;;
5374    esac
5375    ;;
5376
5377linux-gnu*|linux-musl*)
5378    COM=GCC
5379    OS=LINUX
5380    RTL_OS=Linux
5381    P_SEP=:
5382
5383    case "$host_cpu" in
5384
5385    aarch64)
5386        CPUNAME=AARCH64
5387        PLATFORMID=linux_aarch64
5388        RTL_ARCH=AARCH64
5389        EPM_FLAGS="-a arm64"
5390        ;;
5391    alpha)
5392        CPUNAME=AXP
5393        RTL_ARCH=ALPHA
5394        PLATFORMID=linux_alpha
5395        ;;
5396    arm*)
5397        CPUNAME=ARM
5398        EPM_FLAGS="-a arm"
5399        RTL_ARCH=ARM_EABI
5400        PLATFORMID=linux_arm_eabi
5401        case "$host_cpu" in
5402        arm*-linux)
5403            RTL_ARCH=ARM_OABI
5404            PLATFORMID=linux_arm_oabi
5405            ;;
5406        esac
5407        ;;
5408    hppa)
5409        CPUNAME=HPPA
5410        RTL_ARCH=HPPA
5411        EPM_FLAGS="-a hppa"
5412        PLATFORMID=linux_hppa
5413        ;;
5414    i*86)
5415        CPUNAME=INTEL
5416        RTL_ARCH=x86
5417        PLATFORMID=linux_x86
5418        ;;
5419    ia64)
5420        CPUNAME=IA64
5421        RTL_ARCH=IA64
5422        PLATFORMID=linux_ia64
5423        ;;
5424    mips)
5425        CPUNAME=MIPS
5426        RTL_ARCH=MIPS_EB
5427        EPM_FLAGS="-a mips"
5428        PLATFORMID=linux_mips_eb
5429        ;;
5430    mips64)
5431        CPUNAME=MIPS64
5432        RTL_ARCH=MIPS64_EB
5433        EPM_FLAGS="-a mips64"
5434        PLATFORMID=linux_mips64_eb
5435        ;;
5436    mips64el)
5437        CPUNAME=MIPS64
5438        RTL_ARCH=MIPS64_EL
5439        EPM_FLAGS="-a mips64el"
5440        PLATFORMID=linux_mips64_el
5441        ;;
5442    mipsel)
5443        CPUNAME=MIPS
5444        RTL_ARCH=MIPS_EL
5445        EPM_FLAGS="-a mipsel"
5446        PLATFORMID=linux_mips_el
5447        ;;
5448    riscv64)
5449        CPUNAME=RISCV64
5450        RTL_ARCH=RISCV64
5451        EPM_FLAGS="-a riscv64"
5452        PLATFORMID=linux_riscv64
5453        ;;
5454    m68k)
5455        CPUNAME=M68K
5456        RTL_ARCH=M68K
5457        PLATFORMID=linux_m68k
5458        ;;
5459    powerpc)
5460        CPUNAME=POWERPC
5461        RTL_ARCH=PowerPC
5462        PLATFORMID=linux_powerpc
5463        ;;
5464    powerpc64)
5465        CPUNAME=POWERPC64
5466        RTL_ARCH=PowerPC_64
5467        PLATFORMID=linux_powerpc64
5468        ;;
5469    powerpc64le)
5470        CPUNAME=POWERPC64
5471        RTL_ARCH=PowerPC_64_LE
5472        PLATFORMID=linux_powerpc64_le
5473        ;;
5474    sparc)
5475        CPUNAME=SPARC
5476        RTL_ARCH=SPARC
5477        PLATFORMID=linux_sparc
5478        ;;
5479    sparc64)
5480        CPUNAME=SPARC64
5481        RTL_ARCH=SPARC64
5482        PLATFORMID=linux_sparc64
5483        ;;
5484    s390x)
5485        CPUNAME=S390X
5486        RTL_ARCH=S390x
5487        PLATFORMID=linux_s390x
5488        ;;
5489    x86_64)
5490        CPUNAME=X86_64
5491        RTL_ARCH=X86_64
5492        PLATFORMID=linux_x86_64
5493        ;;
5494    loongarch64)
5495        CPUNAME=LOONGARCH64
5496        RTL_ARCH=LOONGARCH64
5497        PLATFORMID=linux_loongarch64
5498        ;;
5499    *)
5500        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5501        ;;
5502    esac
5503    ;;
5504
5505linux-android*)
5506    COM=GCC
5507    OS=ANDROID
5508    RTL_OS=Android
5509    P_SEP=:
5510
5511    case "$host_cpu" in
5512
5513    arm|armel)
5514        CPUNAME=ARM
5515        RTL_ARCH=ARM_EABI
5516        PLATFORMID=android_arm_eabi
5517        ;;
5518    aarch64)
5519        CPUNAME=AARCH64
5520        RTL_ARCH=AARCH64
5521        PLATFORMID=android_aarch64
5522        ;;
5523    i*86)
5524        CPUNAME=INTEL
5525        RTL_ARCH=x86
5526        PLATFORMID=android_x86
5527        ;;
5528    x86_64)
5529        CPUNAME=X86_64
5530        RTL_ARCH=X86_64
5531        PLATFORMID=android_x86_64
5532        ;;
5533    *)
5534        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5535        ;;
5536    esac
5537    ;;
5538
5539*netbsd*)
5540    COM=GCC
5541    OS=NETBSD
5542    RTL_OS=NetBSD
5543    P_SEP=:
5544
5545    case "$host_cpu" in
5546    i*86)
5547        CPUNAME=INTEL
5548        RTL_ARCH=x86
5549        PLATFORMID=netbsd_x86
5550        ;;
5551    powerpc)
5552        CPUNAME=POWERPC
5553        RTL_ARCH=PowerPC
5554        PLATFORMID=netbsd_powerpc
5555        ;;
5556    sparc)
5557        CPUNAME=SPARC
5558        RTL_ARCH=SPARC
5559        PLATFORMID=netbsd_sparc
5560        ;;
5561    x86_64)
5562        CPUNAME=X86_64
5563        RTL_ARCH=X86_64
5564        PLATFORMID=netbsd_x86_64
5565        ;;
5566    *)
5567        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5568        ;;
5569    esac
5570    ;;
5571
5572openbsd*)
5573    COM=GCC
5574    OS=OPENBSD
5575    RTL_OS=OpenBSD
5576    P_SEP=:
5577
5578    case "$host_cpu" in
5579    i*86)
5580        CPUNAME=INTEL
5581        RTL_ARCH=x86
5582        PLATFORMID=openbsd_x86
5583        ;;
5584    x86_64)
5585        CPUNAME=X86_64
5586        RTL_ARCH=X86_64
5587        PLATFORMID=openbsd_x86_64
5588        ;;
5589    *)
5590        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5591        ;;
5592    esac
5593    SOLARINC="$SOLARINC -I/usr/local/include"
5594    ;;
5595
5596solaris*)
5597    COM=GCC
5598    OS=SOLARIS
5599    RTL_OS=Solaris
5600    P_SEP=:
5601
5602    case "$host_cpu" in
5603    i*86)
5604        CPUNAME=INTEL
5605        RTL_ARCH=x86
5606        PLATFORMID=solaris_x86
5607        ;;
5608    sparc)
5609        CPUNAME=SPARC
5610        RTL_ARCH=SPARC
5611        PLATFORMID=solaris_sparc
5612        ;;
5613    sparc64)
5614        CPUNAME=SPARC64
5615        RTL_ARCH=SPARC64
5616        PLATFORMID=solaris_sparc64
5617        ;;
5618    *)
5619        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5620        ;;
5621    esac
5622    SOLARINC="$SOLARINC -I/usr/local/include"
5623    ;;
5624
5625emscripten*)
5626    COM=GCC
5627    OS=EMSCRIPTEN
5628    RTL_OS=Emscripten
5629    P_SEP=:
5630
5631    case "$host_cpu" in
5632    wasm32|wasm64)
5633        ;;
5634    *)
5635        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
5636        ;;
5637    esac
5638    CPUNAME=INTEL
5639    RTL_ARCH=x86
5640    PLATFORMID=linux_x86
5641    ;;
5642
5643*)
5644    AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice for!])
5645    ;;
5646esac
5647
5648DISABLE_GUI=""
5649if test "$enable_gui" = "no"; then
5650    if test "$using_x11" != yes; then
5651        AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice with --disable-gui.])
5652    fi
5653    USING_X11=
5654    DISABLE_GUI=TRUE
5655    test_epoxy=no
5656else
5657    AC_DEFINE(HAVE_FEATURE_UI)
5658fi
5659AC_SUBST(DISABLE_GUI)
5660
5661if test "$with_x" = "no"; then
5662    USING_X11=
5663fi
5664
5665if test -z "$USING_X11" -a "$enable_qt5" = "yes" -a "$enable_gen" = "yes"; then
5666    AC_MSG_ERROR([Can't select gen VCL plugin, if --without-x is used!])
5667fi
5668
5669if test "$using_x11" = yes; then
5670    if test "$USING_X11" = TRUE; then
5671        AC_DEFINE(USING_X11)
5672    else
5673        disable_x11_tests
5674        if test "$DISABLE_DYNLOADING" = TRUE; then
5675            test_qt5=yes
5676            test_qt6=yes
5677        fi
5678    fi
5679else
5680    if test "$USING_X11" = TRUE; then
5681        AC_MSG_ERROR([Platform doesn't support X11 (\$using_x11), but \$USING_X11 is set!])
5682    fi
5683fi
5684
5685WORKDIR="${BUILDDIR}/workdir"
5686INSTDIR="${BUILDDIR}/instdir"
5687INSTROOTBASE=${INSTDIR}${INSTROOTBASESUFFIX}
5688INSTROOT=${INSTROOTBASE}${INSTROOTCONTENTSUFFIX}
5689AC_SUBST(COM)
5690AC_SUBST(CPUNAME)
5691AC_SUBST(RTL_OS)
5692AC_SUBST(RTL_ARCH)
5693AC_SUBST(EPM_FLAGS)
5694AC_SUBST(USING_X11)
5695AC_SUBST([INSTDIR])
5696AC_SUBST([INSTROOT])
5697AC_SUBST([INSTROOTBASE])
5698AC_SUBST(OS)
5699AC_SUBST(P_SEP)
5700AC_SUBST(WORKDIR)
5701AC_SUBST(PLATFORMID)
5702AC_SUBST(WINDOWS_X64)
5703AC_DEFINE_UNQUOTED(SDKDIR, "$INSTDIR/$SDKDIRNAME")
5704AC_DEFINE_UNQUOTED(WORKDIR,"$WORKDIR")
5705
5706if test "$OS" = WNT -a "$COM" = MSC; then
5707    case "$CPUNAME" in
5708    INTEL) CPPU_ENV=msci ;;
5709    X86_64) CPPU_ENV=mscx ;;
5710    AARCH64) CPPU_ENV=msca ;;
5711    *)
5712        AC_MSG_ERROR([Unknown \$CPUNAME '$CPUNAME' for $OS / $COM"])
5713        ;;
5714    esac
5715else
5716    CPPU_ENV=gcc3
5717fi
5718AC_SUBST(CPPU_ENV)
5719
5720dnl ===================================================================
5721dnl Test which package format to use
5722dnl ===================================================================
5723AC_MSG_CHECKING([which package format to use])
5724if test -n "$with_package_format" -a "$with_package_format" != no; then
5725    for i in $with_package_format; do
5726        case "$i" in
5727        bsd | deb | pkg | rpm | archive | dmg | installed | msi)
5728            ;;
5729        *)
5730            AC_MSG_ERROR([unsupported format $i. Supported by EPM are:
5731bsd - FreeBSD, NetBSD, or OpenBSD software distribution
5732deb - Debian software distribution
5733pkg - Solaris software distribution
5734rpm - RedHat software distribution
5735
5736LibreOffice additionally supports:
5737archive - .tar.gz or .zip
5738dmg - macOS .dmg
5739installed - installation tree
5740msi - Windows .msi
5741        ])
5742            ;;
5743        esac
5744    done
5745    # fakeroot is needed to ensure correct file ownerships/permissions
5746    # inside deb packages and tar archives created on Linux and Solaris.
5747    if test "$OS" = "LINUX" || test "$OS" = "SOLARIS"; then
5748        AC_PATH_PROG(FAKEROOT, fakeroot, no)
5749        if test "$FAKEROOT" = "no"; then
5750            AC_MSG_ERROR(
5751                [--with-package-format='$with_package_format' requires fakeroot. Install fakeroot.])
5752        fi
5753    fi
5754    PKGFORMAT="$with_package_format"
5755    AC_MSG_RESULT([$PKGFORMAT])
5756else
5757    PKGFORMAT=
5758    AC_MSG_RESULT([none])
5759fi
5760AC_SUBST(PKGFORMAT)
5761
5762dnl ===================================================================
5763dnl handle help related options
5764dnl
5765dnl If you change help related options, please update README.help
5766dnl ===================================================================
5767
5768ENABLE_HTMLHELP=
5769HELP_OMINDEX_PAGE=
5770HELP_ONLINE=
5771WITH_HELPPACKS=
5772
5773AC_MSG_CHECKING([which help to build])
5774if test -n "$with_help" -a "$with_help" != "no"; then
5775    GIT_NEEDED_SUBMODULES="helpcontent2 $GIT_NEEDED_SUBMODULES"
5776    BUILD_TYPE="$BUILD_TYPE HELP"
5777    case "$with_help" in
5778    "html")
5779        ENABLE_HTMLHELP=TRUE
5780        WITH_HELPPACKS=TRUE
5781        SCPDEFS="$SCPDEFS -DWITH_HELPPACKS"
5782        AC_MSG_RESULT([HTML (local)])
5783        ;;
5784    "online")
5785        ENABLE_HTMLHELP=TRUE
5786        HELP_ONLINE=TRUE
5787        AC_MSG_RESULT([HTML (online)])
5788        ;;
5789    yes)
5790        WITH_HELPPACKS=TRUE
5791        SCPDEFS="$SCPDEFS -DWITH_HELPPACKS"
5792        AC_MSG_RESULT([XML (local)])
5793        ;;
5794    *)
5795        AC_MSG_ERROR([Unknown --with-help=$with_help])
5796        ;;
5797    esac
5798else
5799    AC_MSG_RESULT([no])
5800fi
5801
5802AC_MSG_CHECKING([if we need to build the help index tooling])
5803if test \( "$with_help" = yes -o "$enable_extension_integration" != no \) -a -z "$DISABLE_DYNLOADING"; then
5804    BUILD_TYPE="$BUILD_TYPE HELPTOOLS"
5805    test_clucene=yes
5806    AC_MSG_RESULT([yes])
5807else
5808    AC_MSG_RESULT([no])
5809fi
5810
5811AC_MSG_CHECKING([whether to enable xapian-omega support for online help])
5812if test -n "$with_omindex" -a "$with_omindex" != "no"; then
5813    if test "$HELP_ONLINE" != TRUE; then
5814        AC_MSG_ERROR([Can't build xapian-omega index without --help=online])
5815    fi
5816    case "$with_omindex" in
5817    "server")
5818        HELP_OMINDEX_PAGE=TRUE
5819        AC_MSG_RESULT([SERVER])
5820        ;;
5821    "noxap")
5822        AC_MSG_RESULT([NOXAP])
5823        ;;
5824    *)
5825        AC_MSG_ERROR([Unknown --with-omindex=$with_omindex])
5826        ;;
5827    esac
5828else
5829    AC_MSG_RESULT([no])
5830fi
5831
5832AC_MSG_CHECKING([whether to include the XML-help support])
5833if test "$enable_xmlhelp" = yes; then
5834    BUILD_TYPE="$BUILD_TYPE XMLHELP"
5835    test_clucene=yes
5836    AC_DEFINE(HAVE_FEATURE_XMLHELP)
5837    AC_MSG_RESULT([yes])
5838else
5839    if test "$with_help" = yes; then
5840        add_warning "Building the XML help, but LO with disabled xmlhelp support. Generated help can't be accessed from this LO build!"
5841    fi
5842    AC_MSG_RESULT([no])
5843fi
5844
5845dnl Test whether to integrate helppacks into the product's installer
5846AC_MSG_CHECKING([for helppack integration])
5847if test -z "$WITH_HELPPACKS" -o "$with_helppack_integration" = no; then
5848    AC_MSG_RESULT([no integration])
5849else
5850    SCPDEFS="$SCPDEFS -DWITH_HELPPACK_INTEGRATION"
5851    AC_MSG_RESULT([integration])
5852fi
5853
5854AC_SUBST([ENABLE_HTMLHELP])
5855AC_SUBST([HELP_OMINDEX_PAGE])
5856AC_SUBST([HELP_ONLINE])
5857# WITH_HELPPACKS is used only in configure
5858
5859dnl ===================================================================
5860dnl Set up a different compiler to produce tools to run on the build
5861dnl machine when doing cross-compilation
5862dnl ===================================================================
5863
5864m4_pattern_allow([PKG_CONFIG_FOR_BUILD])
5865m4_pattern_allow([PKG_CONFIG_LIBDIR])
5866if test "$cross_compiling" = "yes"; then
5867    AC_MSG_CHECKING([for BUILD platform configuration])
5868    echo
5869    rm -rf CONF-FOR-BUILD config_build.mk
5870    mkdir CONF-FOR-BUILD
5871    # Here must be listed all files needed when running the configure script. In particular, also
5872    # those expanded by the AC_CONFIG_FILES() call near the end of this configure.ac. For clarity,
5873    # keep them in the same order as there.
5874    (cd $SRC_ROOT && tar cf - \
5875        config.guess \
5876        bin/get_config_variables \
5877        solenv/bin/getcompver.awk \
5878        solenv/inc/langlist.mk \
5879        download.lst \
5880        config_host.mk.in \
5881        config_host_lang.mk.in \
5882        Makefile.in \
5883        bin/bffvalidator.sh.in \
5884        bin/odfvalidator.sh.in \
5885        bin/officeotron.sh.in \
5886        instsetoo_native/util/openoffice.lst.in \
5887        config_host/*.in \
5888        sysui/desktop/macosx/Info.plist.in \
5889        sysui/desktop/macosx/hardened_runtime.xcent.in \
5890        sysui/desktop/macosx/lo.xcent.in \
5891        .vscode/vs-code-template.code-workspace.in \
5892        solenv/lockfile/autoconf.h.in \
5893        ) \
5894    | (cd CONF-FOR-BUILD && tar xf -)
5895    cp configure CONF-FOR-BUILD
5896    test -d config_build && cp -p config_build/*.h CONF-FOR-BUILD/config_host 2>/dev/null
5897    (
5898    unset COM USING_X11 OS CPUNAME
5899    unset CC CXX SYSBASE CFLAGS
5900    unset AR LD NM OBJDUMP PKG_CONFIG RANLIB READELF STRIP
5901    unset CPPUNIT_CFLAGS CPPUNIT_LIBS
5902    unset LIBXML_CFLAGS LIBXML_LIBS LIBXSLT_CFLAGS LIBXSLT_LIBS XSLTPROC
5903    unset PKG_CONFIG_LIBDIR PKG_CONFIG_PATH
5904    if test -n "$CC_FOR_BUILD"; then
5905        export CC="$CC_FOR_BUILD"
5906        CC_BASE=`first_arg_basename "$CC"`
5907    fi
5908    if test -n "$CXX_FOR_BUILD"; then
5909        export CXX="$CXX_FOR_BUILD"
5910        CXX_BASE=`first_arg_basename "$CXX"`
5911    fi
5912    test -n "$PKG_CONFIG_FOR_BUILD" && export PKG_CONFIG="$PKG_CONFIG_FOR_BUILD"
5913    cd CONF-FOR-BUILD
5914
5915    # Handle host configuration, which affects the cross-toolset too
5916    sub_conf_opts=""
5917    test -n "$enable_ccache" && sub_conf_opts="$sub_conf_opts --enable-ccache=$enable_ccache"
5918    test -n "$with_ant_home" && sub_conf_opts="$sub_conf_opts --with-ant-home=$with_ant_home"
5919    test "$with_junit" = "no" && sub_conf_opts="$sub_conf_opts --without-junit"
5920    # While we don't need scripting support, we don't have a PYTHON_FOR_BUILD Java equivalent, so must enable scripting for Java
5921    if test -n "$ENABLE_JAVA"; then
5922        case "$_os" in
5923        Android)
5924            # Hack for Android - the build doesn't need a host JDK, so just forward to build for convenience
5925            test -n "$with_jdk_home" && sub_conf_opts="$sub_conf_opts --with-jdk-home=$with_jdk_home"
5926            ;;
5927        *)
5928            if test -z "$with_jdk_home"; then
5929                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.])
5930            fi
5931            ;;
5932        esac
5933    else
5934        sub_conf_opts="$sub_conf_opts --without-java"
5935    fi
5936    test -n "$TARFILE_LOCATION" && sub_conf_opts="$sub_conf_opts --with-external-tar=$TARFILE_LOCATION"
5937    test "$with_galleries" = "no" -o -z "$WITH_GALLERY_BUILD" && sub_conf_opts="$sub_conf_opts --with-galleries=no --disable-database-connectivity"
5938    test "$with_templates" = "no" -o -z "$WITH_TEMPLATES" && sub_conf_opts="$sub_conf_opts --with-templates=no"
5939    test -n "$with_help" -a "$with_help" != "no" && sub_conf_opts="$sub_conf_opts --with-help=$with_help"
5940    test "$enable_extensions" = yes || sub_conf_opts="$sub_conf_opts --disable-extensions"
5941    test "${enable_ld+set}" = set -a "$build_cpu" = "$host_cpu" && sub_conf_opts="$sub_conf_opts --enable-ld=${enable_ld}"
5942    test "${enable_pch+set}" = set && sub_conf_opts="$sub_conf_opts --enable-pch=${enable_pch}"
5943    test "$enable_wasm_strip" = "yes" && sub_conf_opts="$sub_conf_opts --enable-wasm-strip"
5944    test "${with_system_lockfile+set}" = set && sub_conf_opts="$sub_conf_opts --with-system-lockfile=${with_system_lockfile}"
5945    test "${enable_fuzzers}" = yes && sub_conf_opts="$sub_conf_opts --without-system-libxml"
5946    if test "$_os" = "Emscripten"; then
5947        sub_conf_opts="$sub_conf_opts --without-system-libxml --without-system-fontconfig --without-system-freetype --without-system-zlib"
5948        if test "${with_main_module+set}" = set; then
5949            sub_conf_opts="$sub_conf_opts --with-main-module=${with_main_module}"
5950        else
5951            sub_conf_opts="$sub_conf_opts --with-main-module=writer"
5952        fi
5953    fi
5954    # windows uses full-internal python and that in turn relies on openssl, so also enable openssl
5955    # when cross-compiling for aarch64, overriding the defaults below
5956    test "${PLATFORMID}" = "windows_aarch64" && sub_conf_opts="$sub_conf_opts --enable-openssl --with-tls=openssl"
5957
5958    # Don't bother having configure look for stuff not needed for the build platform anyway
5959    # WARNING: any option with an argument containing spaces must be handled separately (see --with-theme)
5960    sub_conf_defaults=" \
5961        --build="$build_alias" \
5962        --disable-cairo-canvas \
5963        --disable-cups \
5964        --disable-customtarget-components \
5965        --disable-firebird-sdbc \
5966        --disable-gpgmepp \
5967        --disable-gstreamer-1-0 \
5968        --disable-gtk3 \
5969        --disable-gtk4 \
5970        --disable-libcmis \
5971        --disable-mariadb-sdbc \
5972        --disable-nss \
5973        --disable-online-update \
5974        --disable-opencl \
5975        --disable-openssl \
5976        --disable-pdfimport \
5977        --disable-postgresql-sdbc \
5978        --disable-skia \
5979        --disable-xmlhelp \
5980        --enable-dynamic-loading \
5981        --enable-icecream="$enable_icecream" \
5982        --without-doxygen \
5983        --without-tls \
5984        --without-webdav \
5985        --without-x \
5986"
5987    # single quotes added for better readability in case of spaces
5988    echo "    Running CONF-FOR-BUILD/configure" \
5989        $sub_conf_defaults \
5990        --with-parallelism="'$with_parallelism'" \
5991        --with-theme="'$with_theme'" \
5992        --with-vendor="'$with_vendor'" \
5993        $sub_conf_opts \
5994        $with_build_platform_configure_options \
5995        --srcdir=$srcdir
5996
5997    ./configure \
5998        $sub_conf_defaults \
5999        --with-parallelism="$with_parallelism" \
6000        --with-theme="$with_theme" \
6001        "--with-vendor=$with_vendor" \
6002        $sub_conf_opts \
6003        $with_build_platform_configure_options \
6004        --srcdir=$srcdir \
6005        2>&1 | sed -e 's/^/    /'
6006    if test [${PIPESTATUS[0]}] -ne 0; then
6007        AC_MSG_ERROR([Running the configure script for BUILD side failed, see CONF-FOR-BUILD/config.log])
6008    fi
6009
6010    # filter permitted build targets
6011    PERMITTED_BUILD_TARGETS="
6012        ARGON2
6013        AVMEDIA
6014        BOOST
6015        BZIP2
6016        CAIRO
6017        CLUCENE
6018        CURL
6019        DBCONNECTIVITY
6020        DESKTOP
6021        DRAGONBOX
6022        DYNLOADING
6023        EPOXY
6024        EXPAT
6025        FROZEN
6026        GLM
6027        GRAPHITE
6028        HARFBUZZ
6029        HELPTOOLS
6030        ICU
6031        LCMS2
6032        LIBJPEG_TURBO
6033        LIBLANGTAG
6034        LibO
6035        LIBFFI
6036        LIBPN
6037        LIBTIFF
6038        LIBWEBP
6039        LIBXML2
6040        LIBXSLT
6041        MDDS
6042        NATIVE
6043        OPENSSL
6044        ORCUS
6045        PYTHON
6046        REPORTBUILDER
6047        SCRIPTING
6048        ZLIB
6049        ZXCVBN
6050"
6051    # converts BUILD_TYPE and PERMITTED_BUILD_TARGETS into non-whitespace,
6052    # newlined lists, to use grep as a filter
6053    PERMITTED_BUILD_TARGETS=$(echo "$PERMITTED_BUILD_TARGETS" | sed -e '/^ *$/d' -e 's/ *//')
6054    BUILD_TARGETS="$(sed -n -e '/^export BUILD_TYPE=/ s/.*=//p' config_host.mk | tr ' ' '\n')"
6055    BUILD_TARGETS="$(echo "$BUILD_TARGETS" | grep -F "$PERMITTED_BUILD_TARGETS" | tr '\n' ' ')"
6056    sed -i -e "s/ BUILD_TYPE=.*$/ BUILD_TYPE=$BUILD_TARGETS/" config_host.mk
6057
6058    cp config_host.mk ../config_build.mk
6059    cp config_host_lang.mk ../config_build_lang.mk
6060    mv config.log ../config.Build.log
6061    mkdir -p ../config_build
6062    mv config_host/*.h ../config_build
6063    test -f "$WARNINGS_FILE" && mv "$WARNINGS_FILE" "../$WARNINGS_FILE_FOR_BUILD"
6064
6065    # all these will get a _FOR_BUILD postfix
6066    DIRECT_FOR_BUILD_SETTINGS="
6067        CC
6068        CPPU_ENV
6069        CXX
6070        ILIB
6071        JAVA_HOME
6072        JAVAIFLAGS
6073        JDK
6074        JDK_SECURITYMANAGER_DISALLOWED
6075        LIBO_BIN_FOLDER
6076        LIBO_LIB_FOLDER
6077        LIBO_URE_LIB_FOLDER
6078        LIBO_URE_MISC_FOLDER
6079        OS
6080        SDKDIRNAME
6081        SYSTEM_LIBXML
6082        SYSTEM_LIBXSLT
6083"
6084    # these overwrite host config with build config
6085    OVERWRITING_SETTINGS="
6086        ANT
6087        ANT_HOME
6088        ANT_LIB
6089        JAVA_SOURCE_VER
6090        JAVA_TARGET_VER
6091        JAVACFLAGS
6092        JAVACOMPILER
6093        JAVADOC
6094        JAVADOCISGJDOC
6095        LOCKFILE
6096        SYSTEM_GENBRK
6097        SYSTEM_GENCCODE
6098        SYSTEM_GENCMN
6099"
6100    # these need some special handling
6101    EXTRA_HANDLED_SETTINGS="
6102        INSTDIR
6103        INSTROOT
6104        PATH
6105        WORKDIR
6106"
6107    OLD_PATH=$PATH
6108    . ./bin/get_config_variables $DIRECT_FOR_BUILD_SETTINGS $OVERWRITING_SETTINGS $EXTRA_HANDLED_SETTINGS
6109    BUILD_PATH=$PATH
6110    PATH=$OLD_PATH
6111
6112    line=`echo "LO_PATH_FOR_BUILD='${BUILD_PATH}'" | sed -e 's,/CONF-FOR-BUILD,,g'`
6113    echo "$line" >>build-config
6114
6115    for V in $DIRECT_FOR_BUILD_SETTINGS; do
6116        VV='$'$V
6117        VV=`eval "echo $VV"`
6118        if test -n "$VV"; then
6119            line=${V}_FOR_BUILD='${'${V}_FOR_BUILD:-$VV'}'
6120            echo "$line" >>build-config
6121        fi
6122    done
6123
6124    for V in $OVERWRITING_SETTINGS; do
6125        VV='$'$V
6126        VV=`eval "echo $VV"`
6127        if test -n "$VV"; then
6128            line=${V}='${'${V}:-$VV'}'
6129            echo "$line" >>build-config
6130        fi
6131    done
6132
6133    for V in INSTDIR INSTROOT WORKDIR; do
6134        VV='$'$V
6135        VV=`eval "echo $VV"`
6136        VV=`echo $VV | sed -e "s,/CONF-FOR-BUILD/\([[a-z]]*\),/\1_for_build,g"`
6137        if test -n "$VV"; then
6138            line="${V}_FOR_BUILD='$VV'"
6139            echo "$line" >>build-config
6140        fi
6141    done
6142
6143    )
6144    test -f CONF-FOR-BUILD/build-config || AC_MSG_ERROR([setup/configure for BUILD side failed, see CONF-FOR-BUILD/config.log])
6145    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])
6146    perl -pi -e 's,/(workdir|instdir)(/|$),/\1_for_build\2,g;' \
6147             -e 's,/CONF-FOR-BUILD,,g;' config_build.mk
6148
6149    eval `cat CONF-FOR-BUILD/build-config`
6150
6151    AC_MSG_RESULT([checking for BUILD platform configuration... done])
6152
6153    rm -rf CONF-FOR-BUILD
6154else
6155    OS_FOR_BUILD="$OS"
6156    CC_FOR_BUILD="$CC"
6157    CPPU_ENV_FOR_BUILD="$CPPU_ENV"
6158    CXX_FOR_BUILD="$CXX"
6159    INSTDIR_FOR_BUILD="$INSTDIR"
6160    INSTROOT_FOR_BUILD="$INSTROOT"
6161    LIBO_BIN_FOLDER_FOR_BUILD="$LIBO_BIN_FOLDER"
6162    LIBO_LIB_FOLDER_FOR_BUILD="$LIBO_LIB_FOLDER"
6163    LIBO_URE_LIB_FOLDER_FOR_BUILD="$LIBO_URE_LIB_FOLDER"
6164    LIBO_URE_MISC_FOLDER_FOR_BUILD="$LIBO_URE_MISC_FOLDER"
6165    SDKDIRNAME_FOR_BUILD="$SDKDIRNAME"
6166    WORKDIR_FOR_BUILD="$WORKDIR"
6167fi
6168AC_SUBST(OS_FOR_BUILD)
6169AC_SUBST(INSTDIR_FOR_BUILD)
6170AC_SUBST(INSTROOT_FOR_BUILD)
6171AC_SUBST(LIBO_BIN_FOLDER_FOR_BUILD)
6172AC_SUBST(LIBO_LIB_FOLDER_FOR_BUILD)
6173AC_SUBST(LIBO_URE_LIB_FOLDER_FOR_BUILD)
6174AC_SUBST(LIBO_URE_MISC_FOLDER_FOR_BUILD)
6175AC_SUBST(SDKDIRNAME_FOR_BUILD)
6176AC_SUBST(WORKDIR_FOR_BUILD)
6177AC_SUBST(CC_FOR_BUILD)
6178AC_SUBST(CXX_FOR_BUILD)
6179AC_SUBST(CPPU_ENV_FOR_BUILD)
6180
6181dnl ===================================================================
6182dnl Check for lockfile deps
6183dnl ===================================================================
6184if test -z "$CROSS_COMPILING"; then
6185    test -n "$LOCKFILE" -a "${with_system_lockfile+set}" != set && with_system_lockfile="$LOCKFILE"
6186    test "${with_system_lockfile+set}" = set || with_system_lockfile=no
6187    AC_MSG_CHECKING([which lockfile binary to use])
6188    case "$with_system_lockfile" in
6189    yes)
6190        AC_MSG_RESULT([external])
6191        AC_PATH_PROGS([LOCKFILE],[dotlockfile lockfile])
6192        ;;
6193    no)
6194        AC_MSG_RESULT([internal])
6195        ;;
6196    *)
6197        if test -x "$with_system_lockfile"; then
6198            LOCKFILE="$with_system_lockfile"
6199        else
6200            AC_MSG_ERROR(['$with_system_lockfile' is not executable.])
6201        fi
6202        AC_MSG_RESULT([$with_system_lockfile])
6203        ;;
6204    esac
6205fi
6206
6207if test -n "$LOCKFILE" -a "$DISABLE_DYNLOADING" = TRUE; then
6208    add_warning "The default system lockfile has increasing poll intervals up to 60s, so linking executables may be delayed."
6209fi
6210
6211AC_CHECK_HEADERS([getopt.h paths.h sys/param.h])
6212AC_CHECK_FUNCS([utime utimes])
6213AC_SUBST(LOCKFILE)
6214
6215dnl ===================================================================
6216dnl Check for syslog header
6217dnl ===================================================================
6218AC_CHECK_HEADER(syslog.h, AC_DEFINE(HAVE_SYSLOG_H))
6219
6220dnl Set the ENABLE_WERROR variable. (Activate --enable-werror)
6221dnl ===================================================================
6222AC_MSG_CHECKING([whether to turn warnings to errors])
6223if test -n "$enable_werror" -a "$enable_werror" != "no"; then
6224    ENABLE_WERROR="TRUE"
6225    PYTHONWARNINGS="error"
6226    AC_MSG_RESULT([yes])
6227else
6228    if test -n "$LODE_HOME" -a -z "$enable_werror"; then
6229        ENABLE_WERROR="TRUE"
6230        PYTHONWARNINGS="error"
6231        AC_MSG_RESULT([yes])
6232    else
6233        AC_MSG_RESULT([no])
6234    fi
6235fi
6236AC_SUBST(ENABLE_WERROR)
6237AC_SUBST(PYTHONWARNINGS)
6238
6239dnl Check for --enable-assert-always-abort, set ASSERT_ALWAYS_ABORT
6240dnl ===================================================================
6241AC_MSG_CHECKING([whether to have assert() failures abort even without --enable-debug])
6242if test -z "$enable_assert_always_abort"; then
6243   if test "$ENABLE_DEBUG" = TRUE; then
6244       enable_assert_always_abort=yes
6245   else
6246       enable_assert_always_abort=no
6247   fi
6248fi
6249if test "$enable_assert_always_abort" = "yes"; then
6250    ASSERT_ALWAYS_ABORT="TRUE"
6251    AC_MSG_RESULT([yes])
6252else
6253    ASSERT_ALWAYS_ABORT="FALSE"
6254    AC_MSG_RESULT([no])
6255fi
6256AC_SUBST(ASSERT_ALWAYS_ABORT)
6257
6258# Determine whether to use ooenv for the instdir installation
6259# ===================================================================
6260if test $_os != "WINNT" -a $_os != "Darwin"; then
6261    AC_MSG_CHECKING([whether to use ooenv for the instdir installation])
6262    if test -z "$enable_ooenv"; then
6263        if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
6264            enable_ooenv=yes
6265        else
6266            enable_ooenv=no
6267        fi
6268    fi
6269    if test "$enable_ooenv" = "no"; then
6270        AC_MSG_RESULT([no])
6271    else
6272        ENABLE_OOENV="TRUE"
6273        AC_MSG_RESULT([yes])
6274    fi
6275fi
6276AC_SUBST(ENABLE_OOENV)
6277
6278if test "$test_kf5" = "yes" -a "$enable_kf5" = "yes"; then
6279    if test "$enable_qt5" = "no"; then
6280        AC_MSG_ERROR([KF5 support depends on QT5, so it conflicts with --disable-qt5])
6281    else
6282        enable_qt5=yes
6283    fi
6284fi
6285
6286if test "$test_kf6" = "yes" -a "$enable_kf6" = "yes"; then
6287    if test "$enable_qt6" = "no"; then
6288        AC_MSG_ERROR([KF6 support depends on QT6, so it conflicts with --disable-qt6])
6289    else
6290        enable_qt6=yes
6291    fi
6292fi
6293
6294
6295AC_MSG_CHECKING([whether to build the pagein binaries for oosplash])
6296if test "${enable_pagein}" != no -a -z "$DISABLE_DYNLOADING"; then
6297    AC_MSG_RESULT([yes])
6298    ENABLE_PAGEIN=TRUE
6299    AC_DEFINE(HAVE_FEATURE_PAGEIN)
6300else
6301    AC_MSG_RESULT([no])
6302fi
6303AC_SUBST(ENABLE_PAGEIN)
6304
6305
6306AC_MSG_CHECKING([whether to enable CPDB support])
6307ENABLE_CPDB=""
6308CPDB_CFLAGS=""
6309CPDB_LIBS=""
6310if test "$test_cpdb" = yes -a "x$enable_cpdb" = "xyes"; then
6311    ENABLE_CPDB="TRUE"
6312    AC_MSG_RESULT([yes])
6313    PKG_CHECK_MODULES(CPDB, cpdb-frontend)
6314    CPDB_CFLAGS=$(printf '%s' "$CPDB_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
6315    FilterLibs "${CPDB_LIBS}"
6316    CPDB_LIBS="${filteredlibs}"
6317    AC_DEFINE([ENABLE_CPDB],[1])
6318else
6319    AC_MSG_RESULT([no])
6320fi
6321AC_SUBST(ENABLE_CPDB)
6322AC_SUBST(CPDB_LIBS)
6323AC_SUBST(CPDB_CFLAGS)
6324
6325dnl ===================================================================
6326dnl check for cups support
6327dnl ===================================================================
6328
6329AC_MSG_CHECKING([whether to enable CUPS support])
6330if test "$test_cups" = yes -a "$enable_cups" != no; then
6331    ENABLE_CUPS=TRUE
6332    AC_MSG_RESULT([yes])
6333
6334    AC_MSG_CHECKING([whether cups support is present])
6335    AC_CHECK_LIB([cups], [cupsPrintFiles], [:])
6336    AC_CHECK_HEADER(cups/cups.h, AC_DEFINE(HAVE_CUPS_H))
6337    if test "$ac_cv_lib_cups_cupsPrintFiles" != "yes" -o "$ac_cv_header_cups_cups_h" != "yes"; then
6338        AC_MSG_ERROR([Could not find CUPS. Install libcups2-dev or cups-devel.])
6339    fi
6340else
6341    AC_MSG_RESULT([no])
6342fi
6343
6344AC_SUBST(ENABLE_CUPS)
6345
6346libo_CHECK_SYSTEM_MODULE([fontconfig],[FONTCONFIG],[fontconfig >= 2.12.0],,system,TRUE)
6347
6348dnl whether to find & fetch external tarballs?
6349dnl ===================================================================
6350if test -z "$TARFILE_LOCATION" -a -n "$LODE_HOME" ; then
6351   if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
6352       TARFILE_LOCATION="`cygpath -m $LODE_HOME/ext_tar`"
6353   else
6354       TARFILE_LOCATION="$LODE_HOME/ext_tar"
6355   fi
6356fi
6357if test -z "$TARFILE_LOCATION"; then
6358    if test -d "$SRC_ROOT/src" ; then
6359        mv "$SRC_ROOT/src" "$SRC_ROOT/external/tarballs"
6360        ln -s "$SRC_ROOT/external/tarballs" "$SRC_ROOT/src"
6361    fi
6362    TARFILE_LOCATION="$SRC_ROOT/external/tarballs"
6363else
6364    AbsolutePath "$TARFILE_LOCATION"
6365    PathFormat "${absolute_path}"
6366    TARFILE_LOCATION="${formatted_path_unix}"
6367fi
6368PathFormat "$TARFILE_LOCATION"
6369TARFILE_LOCATION_NATIVE="$formatted_path"
6370AC_SUBST(TARFILE_LOCATION)
6371AC_SUBST(TARFILE_LOCATION_NATIVE)
6372
6373AC_MSG_CHECKING([whether we want to fetch tarballs])
6374if test "$enable_fetch_external" != "no"; then
6375    if test "$with_all_tarballs" = "yes"; then
6376        AC_MSG_RESULT([yes, all of them])
6377        DO_FETCH_TARBALLS="ALL"
6378    else
6379        AC_MSG_RESULT([yes, if we use them])
6380        DO_FETCH_TARBALLS="TRUE"
6381    fi
6382else
6383    AC_MSG_RESULT([no])
6384    DO_FETCH_TARBALLS=
6385fi
6386AC_SUBST(DO_FETCH_TARBALLS)
6387
6388dnl Test whether to include MySpell dictionaries
6389dnl ===================================================================
6390AC_MSG_CHECKING([whether to include MySpell dictionaries])
6391if test "$with_myspell_dicts" = "yes"; then
6392    AC_MSG_RESULT([yes])
6393    WITH_MYSPELL_DICTS=TRUE
6394    BUILD_TYPE="$BUILD_TYPE DICTIONARIES"
6395    GIT_NEEDED_SUBMODULES="dictionaries $GIT_NEEDED_SUBMODULES"
6396else
6397    AC_MSG_RESULT([no])
6398    WITH_MYSPELL_DICTS=
6399fi
6400AC_SUBST(WITH_MYSPELL_DICTS)
6401
6402# There are no "system" myspell, hyphen or mythes dictionaries on macOS, Windows, Android or iOS.
6403if test $_os = Darwin -o $_os = WINNT -o $_os = iOS -o $_os = Android; then
6404    if test "$with_system_dicts" = yes; then
6405        AC_MSG_ERROR([There are no system dicts on this OS in the formats the 3rd-party libs we use expect]);
6406    fi
6407    with_system_dicts=no
6408fi
6409
6410AC_MSG_CHECKING([whether to use dicts from external paths])
6411if test -z "$with_system_dicts" -o "$with_system_dicts" != "no"; then
6412    AC_MSG_RESULT([yes])
6413    SYSTEM_DICTS=TRUE
6414    AC_MSG_CHECKING([for spelling dictionary directory])
6415    if test -n "$with_external_dict_dir"; then
6416        DICT_SYSTEM_DIR=file://$with_external_dict_dir
6417    else
6418        DICT_SYSTEM_DIR=file:///usr/share/hunspell
6419        if test ! -d /usr/share/hunspell -a -d /usr/share/myspell; then
6420            DICT_SYSTEM_DIR=file:///usr/share/myspell
6421        fi
6422    fi
6423    AC_MSG_RESULT([$DICT_SYSTEM_DIR])
6424    AC_MSG_CHECKING([for hyphenation patterns directory])
6425    if test -n "$with_external_hyph_dir"; then
6426        HYPH_SYSTEM_DIR=file://$with_external_hyph_dir
6427    else
6428        HYPH_SYSTEM_DIR=file:///usr/share/hyphen
6429    fi
6430    AC_MSG_RESULT([$HYPH_SYSTEM_DIR])
6431    AC_MSG_CHECKING([for thesaurus directory])
6432    if test -n "$with_external_thes_dir"; then
6433        THES_SYSTEM_DIR=file://$with_external_thes_dir
6434    else
6435        THES_SYSTEM_DIR=file:///usr/share/mythes
6436    fi
6437    AC_MSG_RESULT([$THES_SYSTEM_DIR])
6438else
6439    AC_MSG_RESULT([no])
6440    SYSTEM_DICTS=
6441fi
6442AC_SUBST(SYSTEM_DICTS)
6443AC_SUBST(DICT_SYSTEM_DIR)
6444AC_SUBST(HYPH_SYSTEM_DIR)
6445AC_SUBST(THES_SYSTEM_DIR)
6446
6447dnl ===================================================================
6448dnl Precompiled headers.
6449ENABLE_PCH=""
6450AC_MSG_CHECKING([whether to enable pch feature])
6451if test -z "$enable_pch"; then
6452    if test "$_os" = "WINNT"; then
6453        # Enabled by default on Windows.
6454        enable_pch=yes
6455        # never use sccache on auto-enabled PCH builds, except if requested explicitly
6456        if test -z "$enable_ccache" -a "$SCCACHE"; then
6457            CCACHE=""
6458        fi
6459    else
6460        enable_pch=no
6461    fi
6462fi
6463if test "$enable_pch" != no -a "$_os" = Emscripten; then
6464    AC_MSG_ERROR([PCH currently isn't supported for Emscripten with native EH (nEH) because of missing Sj/Lj support with nEH in clang.])
6465fi
6466if test "$enable_pch" != "no" -a "$_os" != "WINNT" -a "$GCC" != "yes" ; then
6467    AC_MSG_ERROR([Precompiled header not yet supported for your platform/compiler])
6468fi
6469if test "$enable_pch" = "system"; then
6470    ENABLE_PCH="1"
6471    AC_MSG_RESULT([yes (system headers)])
6472elif test "$enable_pch" = "base"; then
6473    ENABLE_PCH="2"
6474    AC_MSG_RESULT([yes (system and base headers)])
6475elif test "$enable_pch" = "normal"; then
6476    ENABLE_PCH="3"
6477    AC_MSG_RESULT([yes (normal)])
6478elif test "$enable_pch" = "full"; then
6479    ENABLE_PCH="4"
6480    AC_MSG_RESULT([yes (full)])
6481elif test "$enable_pch" = "yes"; then
6482    # Pick a suitable default.
6483    if test "$GCC" = "yes"; then
6484        # With Clang and GCC higher levels do not seem to make a noticeable improvement,
6485        # while making the PCHs larger and rebuilds more likely.
6486        ENABLE_PCH="2"
6487        AC_MSG_RESULT([yes (system and base headers)])
6488    else
6489        # With MSVC the highest level makes a significant difference,
6490        # and it was the default when there used to be no PCH levels.
6491        ENABLE_PCH="4"
6492        AC_MSG_RESULT([yes (full)])
6493    fi
6494elif test "$enable_pch" = "no"; then
6495    AC_MSG_RESULT([no])
6496else
6497    AC_MSG_ERROR([Unknown value for --enable-pch])
6498fi
6499AC_SUBST(ENABLE_PCH)
6500# ccache 3.7.1 and older do not properly detect/handle -include .gch in CCACHE_DEPEND mode
6501if test -n "$ENABLE_PCH" -a -n "$CCACHE_DEPEND_MODE" -a "$GCC" = "yes" -a "$COM_IS_CLANG" != "TRUE"; then
6502    AC_PATH_PROG([CCACHE_BIN],[ccache],[not found])
6503    if test "$CCACHE_BIN" != "not found"; then
6504        AC_MSG_CHECKING([ccache version])
6505        CCACHE_VERSION=`"$CCACHE_BIN" -V | "$AWK" '/^ccache version/{print $3}'`
6506        CCACHE_NUMVER=`echo $CCACHE_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
6507        AC_MSG_RESULT([$CCACHE_VERSION])
6508        AC_MSG_CHECKING([whether ccache depend mode works properly with GCC PCH])
6509        if test "$CCACHE_NUMVER" -gt "030701"; then
6510            AC_MSG_RESULT([yes])
6511        else
6512            AC_MSG_RESULT([no (not newer than 3.7.1)])
6513            CCACHE_DEPEND_MODE=
6514        fi
6515    fi
6516fi
6517
6518PCH_INSTANTIATE_TEMPLATES=
6519if test -n "$ENABLE_PCH"; then
6520    AC_MSG_CHECKING([whether $CC supports -fpch-instantiate-templates])
6521    save_CFLAGS=$CFLAGS
6522    CFLAGS="$CFLAGS -Werror -fpch-instantiate-templates"
6523    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ PCH_INSTANTIATE_TEMPLATES="-fpch-instantiate-templates" ],[])
6524    CFLAGS=$save_CFLAGS
6525    if test -n "$PCH_INSTANTIATE_TEMPLATES"; then
6526        AC_MSG_RESULT(yes)
6527    else
6528        AC_MSG_RESULT(no)
6529    fi
6530fi
6531AC_SUBST(PCH_INSTANTIATE_TEMPLATES)
6532
6533BUILDING_PCH_WITH_OBJ=
6534if test -n "$ENABLE_PCH"; then
6535    AC_MSG_CHECKING([whether $CC supports -Xclang -building-pch-with-obj])
6536    save_CFLAGS=$CFLAGS
6537    CFLAGS="$CFLAGS -Werror -Xclang -building-pch-with-obj"
6538    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ BUILDING_PCH_WITH_OBJ="-Xclang -building-pch-with-obj" ],[])
6539    CFLAGS=$save_CFLAGS
6540    if test -n "$BUILDING_PCH_WITH_OBJ"; then
6541        AC_MSG_RESULT(yes)
6542    else
6543        AC_MSG_RESULT(no)
6544    fi
6545fi
6546AC_SUBST(BUILDING_PCH_WITH_OBJ)
6547
6548PCH_CODEGEN=
6549PCH_NO_CODEGEN=
6550fpch_prefix=
6551if test "$COM" = MSC; then
6552    fpch_prefix="-Xclang "
6553fi
6554if test -n "$BUILDING_PCH_WITH_OBJ"; then
6555    AC_MSG_CHECKING([whether $CC supports ${fpch_prefix}-fpch-codegen])
6556    save_CFLAGS=$CFLAGS
6557    CFLAGS="$CFLAGS -Werror ${fpch_prefix}-fpch-codegen"
6558    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],
6559        [ PCH_CODEGEN="${fpch_prefix}-fpch-codegen" ],[])
6560    CFLAGS=$save_CFLAGS
6561    CFLAGS="$CFLAGS -Werror ${fpch_prefix}-fno-pch-codegen"
6562    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],
6563        [ PCH_NO_CODEGEN="${fpch_prefix}-fno-pch-codegen" ],[])
6564    CFLAGS=$save_CFLAGS
6565    if test -n "$PCH_CODEGEN"; then
6566        AC_MSG_RESULT(yes)
6567    else
6568        AC_MSG_RESULT(no)
6569    fi
6570fi
6571AC_SUBST(PCH_CODEGEN)
6572AC_SUBST(PCH_NO_CODEGEN)
6573PCH_DEBUGINFO=
6574if test -n "$BUILDING_PCH_WITH_OBJ"; then
6575    AC_MSG_CHECKING([whether $CC supports ${fpch_prefix}-fpch-debuginfo])
6576    save_CFLAGS=$CFLAGS
6577    CFLAGS="$CFLAGS -Werror ${fpch_prefix}-fpch-debuginfo"
6578    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ PCH_DEBUGINFO="${fpch_prefix}-fpch-debuginfo" ],[])
6579    CFLAGS=$save_CFLAGS
6580    if test -n "$PCH_DEBUGINFO"; then
6581        AC_MSG_RESULT(yes)
6582    else
6583        AC_MSG_RESULT(no)
6584    fi
6585fi
6586AC_SUBST(PCH_DEBUGINFO)
6587
6588TAB=`printf '\t'`
6589
6590AC_MSG_CHECKING([the GNU Make version])
6591_make_version=`$GNUMAKE --version | grep GNU | $GREP -v GPL | $SED -e 's@^[[^0-9]]*@@' -e 's@ .*@@' -e 's@,.*@@'`
6592_make_longver=`echo $_make_version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
6593if test "$_make_longver" -ge "040000"; then
6594    AC_MSG_RESULT([$GNUMAKE $_make_version])
6595else
6596    AC_MSG_ERROR([failed ($GNUMAKE version >= 4.0 needed)])
6597fi
6598
6599_make_ver_check=`$GNUMAKE --version | grep "Built for Windows"`
6600STALE_MAKE=
6601if test "$_make_ver_check" = ""; then
6602   STALE_MAKE=TRUE
6603fi
6604
6605HAVE_LD_HASH_STYLE=FALSE
6606WITH_LINKER_HASH_STYLE=
6607AC_MSG_CHECKING([for --hash-style gcc linker support])
6608if test "$GCC" = "yes"; then
6609    if test -z "$with_linker_hash_style" -o "$with_linker_hash_style" = "yes"; then
6610        hash_styles="gnu sysv"
6611    elif test "$with_linker_hash_style" = "no"; then
6612        hash_styles=
6613    else
6614        hash_styles="$with_linker_hash_style"
6615    fi
6616
6617    for hash_style in $hash_styles; do
6618        test "$HAVE_LD_HASH_STYLE" = "TRUE" && continue
6619        hash_style_ldflags_save=$LDFLAGS
6620        LDFLAGS="$LDFLAGS -Wl,--hash-style=$hash_style"
6621
6622        AC_RUN_IFELSE([AC_LANG_PROGRAM(
6623            [
6624#include <stdio.h>
6625            ],[
6626printf ("");
6627            ])],
6628            [
6629                  HAVE_LD_HASH_STYLE=TRUE
6630                  WITH_LINKER_HASH_STYLE=$hash_style
6631            ],
6632            [HAVE_LD_HASH_STYLE=FALSE],
6633            [HAVE_LD_HASH_STYLE=FALSE])
6634        LDFLAGS=$hash_style_ldflags_save
6635    done
6636
6637    if test "$HAVE_LD_HASH_STYLE" = "TRUE"; then
6638        AC_MSG_RESULT( $WITH_LINKER_HASH_STYLE )
6639    else
6640        AC_MSG_RESULT( no )
6641    fi
6642    LDFLAGS=$hash_style_ldflags_save
6643else
6644    AC_MSG_RESULT( no )
6645fi
6646AC_SUBST(HAVE_LD_HASH_STYLE)
6647AC_SUBST(WITH_LINKER_HASH_STYLE)
6648
6649dnl ===================================================================
6650dnl Check whether there's a Perl version available.
6651dnl ===================================================================
6652if test -z "$with_perl_home"; then
6653    AC_PATH_PROG(PERL, perl)
6654else
6655    test "$build_os" = "cygwin" && with_perl_home=`cygpath -u "$with_perl_home"`
6656    _perl_path="$with_perl_home/bin/perl"
6657    if test -x "$_perl_path"; then
6658        PERL=$_perl_path
6659    else
6660        AC_MSG_ERROR([$_perl_path not found])
6661    fi
6662fi
6663
6664dnl ===================================================================
6665dnl Testing for Perl version 5 or greater.
6666dnl $] is the Perl version variable, it is returned as an integer
6667dnl ===================================================================
6668if test "$PERL"; then
6669    AC_MSG_CHECKING([the Perl version])
6670    ${PERL} -e "exit($]);"
6671    _perl_version=$?
6672    if test "$_perl_version" -lt 5; then
6673        AC_MSG_ERROR([found Perl $_perl_version, use Perl 5])
6674    fi
6675    AC_MSG_RESULT([Perl $_perl_version])
6676else
6677    AC_MSG_ERROR([Perl not found, install Perl 5])
6678fi
6679
6680dnl ===================================================================
6681dnl Testing for required Perl modules
6682dnl ===================================================================
6683
6684AC_MSG_CHECKING([for required Perl modules])
6685perl_use_string="use Cwd ; use Digest::MD5"
6686if test "$_os" = "WINNT"; then
6687    if test -n "$PKGFORMAT"; then
6688        for i in $PKGFORMAT; do
6689            case "$i" in
6690            msi)
6691                # for getting fonts versions to use in MSI
6692                perl_use_string="$perl_use_string ; use Font::TTF::Font"
6693                ;;
6694            esac
6695        done
6696    fi
6697fi
6698if test "$with_system_hsqldb" = "yes"; then
6699    perl_use_string="$perl_use_string ; use Archive::Zip"
6700fi
6701if test "$enable_openssl" = "yes" -a "$with_system_openssl" != "yes"; then
6702    # OpenSSL needs that to build
6703    perl_use_string="$perl_use_string ; use FindBin"
6704fi
6705if $PERL -e "$perl_use_string">/dev/null 2>&1; then
6706    AC_MSG_RESULT([all modules found])
6707else
6708    AC_MSG_RESULT([failed to find some modules])
6709    # Find out which modules are missing.
6710    for i in $perl_use_string; do
6711        if test "$i" != "use" -a "$i" != ";"; then
6712            if ! $PERL -e "use $i;">/dev/null 2>&1; then
6713                missing_perl_modules="$missing_perl_modules $i"
6714            fi
6715        fi
6716    done
6717    AC_MSG_ERROR([
6718    The missing Perl modules are: $missing_perl_modules
6719    Install them as superuser/administrator with "cpan -i $missing_perl_modules"])
6720fi
6721
6722dnl ===================================================================
6723dnl Check for pkg-config
6724dnl ===================================================================
6725if test "$_os" != "WINNT"; then
6726    PKG_PROG_PKG_CONFIG
6727fi
6728AC_SUBST(PKG_CONFIG)
6729AC_SUBST(PKG_CONFIG_PATH)
6730AC_SUBST(PKG_CONFIG_LIBDIR)
6731
6732if test "$_os" != "WINNT"; then
6733
6734    # If you use CC=/path/to/compiler/foo-gcc or even CC="ccache
6735    # /path/to/compiler/foo-gcc" you need to set the AR etc env vars
6736    # explicitly. Or put /path/to/compiler in PATH yourself.
6737
6738    toolprefix=gcc
6739    if test "$COM_IS_CLANG" = "TRUE"; then
6740        toolprefix=llvm
6741    fi
6742    AC_CHECK_TOOLS(AR,$toolprefix-ar ar)
6743    AC_CHECK_TOOLS(NM,$toolprefix-nm nm)
6744    AC_CHECK_TOOLS(RANLIB,$toolprefix-ranlib ranlib)
6745    AC_CHECK_TOOLS(OBJDUMP,$toolprefix-objdump objdump)
6746    AC_CHECK_TOOLS(READELF,$toolprefix-readelf readelf)
6747    AC_CHECK_TOOLS(STRIP,$toolprefix-strip strip)
6748fi
6749AC_SUBST(AR)
6750AC_SUBST(NM)
6751AC_SUBST(OBJDUMP)
6752AC_SUBST(RANLIB)
6753AC_SUBST(READELF)
6754AC_SUBST(STRIP)
6755
6756dnl ===================================================================
6757dnl pkg-config checks on macOS
6758dnl ===================================================================
6759
6760if test $_os = Darwin; then
6761    AC_MSG_CHECKING([for bogus pkg-config])
6762    if test -n "$PKG_CONFIG"; then
6763        if test "$PKG_CONFIG" = /usr/bin/pkg-config && ls -l /usr/bin/pkg-config | $GREP -q Mono.framework; then
6764            AC_MSG_ERROR([yes, from Mono. This *will* break the build. Please remove or hide $PKG_CONFIG])
6765        else
6766            if test "$enable_bogus_pkg_config" = "yes"; then
6767                AC_MSG_RESULT([yes, user-approved from unknown origin.])
6768            else
6769                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.])
6770            fi
6771        fi
6772    else
6773        AC_MSG_RESULT([no, good])
6774    fi
6775fi
6776
6777find_csc()
6778{
6779    # Return value: $csctest
6780
6781    unset csctest
6782
6783    reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/NET Framework Setup/NDP/v4/Client" "InstallPath"
6784    if test -n "$regvalue"; then
6785        csctest=$regvalue
6786        return
6787    fi
6788}
6789
6790find_al()
6791{
6792    # Return value: $altest
6793
6794    unset altest
6795
6796    # We need this check to detect 4.6.1 or above.
6797    for ver in 4.8.1 4.8 4.7.2 4.7.1 4.7 4.6.2 4.6.1; do
6798        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/NETFXSDK/$ver/WinSDK-NetFx40Tools" "InstallationFolder"
6799        PathFormat "$regvalue"
6800        if test -n "$regvalue" -a \( -f "$formatted_path_unix/al.exe" -o -f "$formatted_path_unix/bin/al.exe" \); then
6801            altest=$regvalue
6802            return
6803        fi
6804    done
6805
6806    reg_list_values_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows"
6807    for x in $reglist; do
6808        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/$x/WinSDK-NetFx40Tools" "InstallationFolder"
6809        PathFormat "$regvalue"
6810        if test -n "$regvalue" -a \( -f "$formatted_path_unix/al.exe" -o -f "$formatted_path_unix/bin/al.exe" \); then
6811            altest=$regvalue
6812            return
6813        fi
6814    done
6815}
6816
6817find_dotnetsdk()
6818{
6819    unset frametest
6820
6821    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
6822        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/NETFXSDK/$ver" "KitsInstallationFolder"
6823        if test -n "$regvalue"; then
6824            frametest=$regvalue
6825            return
6826        fi
6827    done
6828    AC_MSG_ERROR([The Windows NET SDK (minimum 4.6) not found, check the installation])
6829}
6830
6831find_winsdk_version()
6832{
6833    # Args: $1 : SDK version as in "8.0", "8.1A" etc
6834    # Return values: $winsdktest, $winsdkbinsubdir, $winsdklibsubdir
6835
6836    unset winsdktest winsdkbinsubdir winsdklibsubdir
6837
6838    case "$1" in
6839    8.0|8.0A)
6840        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows Kits/Installed Roots" "KitsRoot"
6841        if test -n "$regvalue"; then
6842            winsdktest=$regvalue
6843            winsdklibsubdir=win8
6844            return
6845        fi
6846        ;;
6847    8.1|8.1A)
6848        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows Kits/Installed Roots" "KitsRoot81"
6849        if test -n "$regvalue"; then
6850            winsdktest=$regvalue
6851            winsdklibsubdir=winv6.3
6852            return
6853        fi
6854        ;;
6855    10.0)
6856        reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v${1}" "InstallationFolder"
6857        if test -n "$regvalue"; then
6858            winsdktest=$regvalue
6859            reg_get_value_32 "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v${1}" "ProductVersion"
6860            if test -n "$regvalue"; then
6861                winsdkbinsubdir="$regvalue".0
6862                winsdklibsubdir=$winsdkbinsubdir
6863                local tmppath="$winsdktest\\Include\\$winsdklibsubdir"
6864                PathFormat "$tmppath"
6865                local tmppath_unix=$formatted_path_unix
6866                # test exist the SDK path
6867                if test ! -d "$tmppath_unix"; then
6868                   AC_MSG_ERROR([The Windows SDK not found, check the installation])
6869                fi
6870            fi
6871            return
6872        fi
6873        ;;
6874    esac
6875}
6876
6877find_winsdk()
6878{
6879    # Return value: From find_winsdk_version
6880
6881    unset winsdktest
6882
6883    for ver in $WINDOWS_SDK_ACCEPTABLE_VERSIONS; do
6884        find_winsdk_version $ver
6885        if test -n "$winsdktest"; then
6886            return
6887        fi
6888    done
6889}
6890
6891find_msms()
6892{
6893    # Return value: $msmdir
6894    local version="$1"
6895
6896    AC_MSG_CHECKING([for MSVC $version merge modules directory])
6897    local my_msm_file="Microsoft_VC${version}_CRT_x86.msm"
6898    local my_msm_dir
6899
6900    echo "$as_me:$LINENO: searching for $my_msm_file" >&5
6901
6902    msmdir=
6903    case "$VCVER" in
6904    16.0 | 17.0 | 17.11)
6905        for l in `ls -1 $VC_PRODUCT_DIR/redist/MSVC/`; do
6906            my_msm_dir="$VC_PRODUCT_DIR/redist/MSVC/$l/MergeModules/"
6907            echo "$as_me:$LINENO: looking for $my_msm_dir${my_msm_file}])" >&5
6908            if test -e "$my_msm_dir${my_msm_file}"; then
6909                msmdir=$my_msm_dir
6910            fi
6911        done
6912        ;;
6913    esac
6914
6915    if test -n "$msmdir"; then
6916        msmdir=`cygpath -m "$msmdir"`
6917        AC_MSG_RESULT([$msmdir])
6918    else
6919        if test "$ENABLE_RELEASE_BUILD" = "TRUE" ; then
6920            AC_MSG_FAILURE([not found])
6921        else
6922            AC_MSG_WARN([not found (check config.log)])
6923            add_warning "MSM ${my_msm_file} not found"
6924        fi
6925    fi
6926}
6927
6928find_msvc_x64_dlls()
6929{
6930    # Return value: $msvcdllpath, $msvcdlls
6931
6932    AC_MSG_CHECKING([for MSVC x64 DLL path])
6933
6934    dnl Order crtver in increasing order. Then check the directories returned by
6935    dnl ls in an inner loop; assuming they are also ordered in increasing order,
6936    dnl the result will be the highest CRT version found in the highest directory.
6937
6938    msvcdllpath="$VC_PRODUCT_DIR/redist/x64/Microsoft.VC${VCVER}.CRT"
6939    case "$VCVER" in
6940    16.0 | 17.0 | 17.11)
6941        for crtver in 141 142 143; do
6942            for l in `ls -1 $VC_PRODUCT_DIR/redist/MSVC/`; do
6943                echo "$as_me:$LINENO: testing $VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC$crtver.CRT" >&5
6944                if test -d "$VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC$crtver.CRT"; then
6945                    msvcdllpath="$VC_PRODUCT_DIR/redist/MSVC/$l/x64/Microsoft.VC$crtver.CRT"
6946                fi
6947            done
6948        done
6949        ;;
6950    esac
6951    AC_MSG_RESULT([$msvcdllpath])
6952    AC_MSG_CHECKING([for MSVC x64 DLLs])
6953    msvcdlls="msvcp140.dll vcruntime140.dll"
6954    for dll in $msvcdlls; do
6955        if ! test -f "$msvcdllpath/$dll"; then
6956            AC_MSG_FAILURE([missing $dll])
6957        fi
6958    done
6959    AC_MSG_RESULT([found all ($msvcdlls)])
6960}
6961
6962dnl =========================================
6963dnl Check for the Windows  SDK.
6964dnl =========================================
6965if test "$_os" = "WINNT"; then
6966    AC_MSG_CHECKING([for Windows SDK])
6967    if test "$build_os" = "cygwin" -o "$build_os" = "wsl" -o -n "$WSL_ONLY_AS_HELPER"; then
6968        find_winsdk
6969        WINDOWS_SDK_HOME=$winsdktest
6970
6971        # normalize if found
6972        if test -n "$WINDOWS_SDK_HOME"; then
6973            PathFormat "$WINDOWS_SDK_HOME"
6974            WINDOWS_SDK_HOME=$formatted_path_unix
6975        fi
6976
6977        WINDOWS_SDK_LIB_SUBDIR=$winsdklibsubdir
6978        # The variable also contains the Windows SDK version
6979        echo $WINDOWS_SDK_LIB_SUBDIR
6980        IFS='.' read -r SDK_v1 SDK_v2 SDK_v3 SDK_v4 <<< "$WINDOWS_SDK_LIB_SUBDIR"
6981        # Assuming maximum of 5 digits for each part and ignoring last part
6982        SDK_NORMALIZED_VER=$((SDK_v1 * 10000000000 + SDK_v2 * 100000 + SDK_v3))
6983        # 10.0.20348.0 is the minimum required version
6984        if test "$SDK_NORMALIZED_VER" -lt 100000020348; then
6985            AC_MSG_ERROR([You need Windows SDK greater than or equal 10.0.20348.0])
6986        fi
6987    fi
6988
6989    if test -n "$WINDOWS_SDK_HOME"; then
6990        # Remove a possible trailing backslash
6991        WINDOWS_SDK_HOME=`echo $WINDOWS_SDK_HOME | $SED 's/\/$//'`
6992
6993        if test -f "$WINDOWS_SDK_HOME/Include/adoint.h" \
6994             -a -f "$WINDOWS_SDK_HOME/Include/SqlUcode.h" \
6995             -a -f "$WINDOWS_SDK_HOME/Include/usp10.h"; then
6996            have_windows_sdk_headers=yes
6997        elif test -f "$WINDOWS_SDK_HOME/Include/um/adoint.h" \
6998             -a -f "$WINDOWS_SDK_HOME/Include/um/SqlUcode.h" \
6999             -a -f "$WINDOWS_SDK_HOME/Include/um/usp10.h"; then
7000            have_windows_sdk_headers=yes
7001        elif test -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/adoint.h" \
7002             -a -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/SqlUcode.h" \
7003             -a -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/usp10.h"; then
7004            have_windows_sdk_headers=yes
7005        else
7006            have_windows_sdk_headers=no
7007        fi
7008
7009        if test -f "$WINDOWS_SDK_HOME/lib/user32.lib"; then
7010            have_windows_sdk_libs=yes
7011        elif test -f "$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/$WIN_BUILD_ARCH/user32.lib"; then
7012            have_windows_sdk_libs=yes
7013        else
7014            have_windows_sdk_libs=no
7015        fi
7016
7017        if test $have_windows_sdk_headers = no -o $have_windows_sdk_libs = no; then
7018            AC_MSG_ERROR([Some (all?) Windows SDK files not found, please check if all needed parts of
7019the  Windows SDK are installed.])
7020        fi
7021    fi
7022
7023    if test -z "$WINDOWS_SDK_HOME"; then
7024        AC_MSG_RESULT([no, hoping the necessary headers and libraries will be found anyway!?])
7025    elif echo $WINDOWS_SDK_HOME | grep "8.0" >/dev/null 2>/dev/null; then
7026        WINDOWS_SDK_VERSION=80
7027        AC_MSG_RESULT([found Windows SDK 8.0 ($WINDOWS_SDK_HOME)])
7028    elif echo $WINDOWS_SDK_HOME | grep "8.1" >/dev/null 2>/dev/null; then
7029        WINDOWS_SDK_VERSION=81
7030        AC_MSG_RESULT([found Windows SDK 8.1 ($WINDOWS_SDK_HOME)])
7031    elif echo $WINDOWS_SDK_HOME | grep "/10" >/dev/null 2>/dev/null; then
7032        WINDOWS_SDK_VERSION=10
7033        AC_MSG_RESULT([found Windows SDK 10.0 ($WINDOWS_SDK_HOME)])
7034    else
7035        AC_MSG_ERROR([Found legacy Windows Platform SDK ($WINDOWS_SDK_HOME)])
7036    fi
7037    PathFormat "$WINDOWS_SDK_HOME"
7038    WINDOWS_SDK_HOME="$formatted_path"
7039    WINDOWS_SDK_HOME_unix="$formatted_path_unix"
7040    if test "$build_os" = "cygwin" -o "$build_os" = "wsl" -o -n "$WSL_ONLY_AS_HELPER"; then
7041        SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/include -I$COMPATH/Include"
7042        if test -d "$WINDOWS_SDK_HOME_unix/include/um"; then
7043            SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/include/um -I$WINDOWS_SDK_HOME/include/shared"
7044        elif test -d "$WINDOWS_SDK_HOME_unix/Include/$winsdklibsubdir/um"; then
7045            SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um -I$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/shared"
7046        fi
7047    fi
7048
7049    dnl TODO: solenv/bin/modules/installer/windows/msiglobal.pm wants to use a
7050    dnl WiLangId.vbs that is included only in some SDKs (e.g., included in v7.1
7051    dnl but not in v8.0), so allow this to be overridden with a
7052    dnl WINDOWS_SDK_WILANGID for now; a full-blown --with-windows-sdk-wilangid
7053    dnl and configuration error if no WiLangId.vbs is found would arguably be
7054    dnl better, but I do not know under which conditions exactly it is needed by
7055    dnl msiglobal.pm:
7056    if test -z "$WINDOWS_SDK_WILANGID" -a -n "$WINDOWS_SDK_HOME"; then
7057        WINDOWS_SDK_WILANGID_unix=$WINDOWS_SDK_HOME_unix/Samples/sysmgmt/msi/scripts/WiLangId.vbs
7058        if ! test -e "$WINDOWS_SDK_WILANGID_unix" ; then
7059            WINDOWS_SDK_WILANGID_unix="${WINDOWS_SDK_HOME_unix}/bin/${WINDOWS_SDK_LIB_SUBDIR}/${WIN_BUILD_ARCH}/WiLangId.vbs"
7060        fi
7061        if ! test -e "$WINDOWS_SDK_WILANGID_unix" ; then
7062            WINDOWS_SDK_WILANGID_unix=$WINDOWS_SDK_HOME_unix/bin/$WIN_BUILD_ARCH/WiLangId.vbs
7063        fi
7064        if ! test -e "$WINDOWS_SDK_WILANGID_unix" ; then
7065            WINDOWS_SDK_WILANGID_unix="C:/Program Files (x86)/Windows Kits/8.1/bin/$WIN_BUILD_ARCH/WiLangId.vbs"
7066        fi
7067        PathFormat "$WINDOWS_SDK_WILANGID_unix"
7068        WINDOWS_SDK_WILANGID="$formatted_path"
7069    fi
7070    if test -n "$with_lang" -a "$with_lang" != "en-US"; then
7071        if test -n "$with_package_format" -a "$with_package_format" != no; then
7072            for i in "$with_package_format"; do
7073                if test "$i" = "msi"; then
7074                    if ! test -e "$WINDOWS_SDK_WILANGID_unix" ; then
7075                        AC_MSG_ERROR([WiLangId.vbs not found - building translated packages will fail])
7076                    fi
7077                fi
7078            done
7079        fi
7080    fi
7081fi
7082AC_SUBST(WINDOWS_SDK_HOME)
7083AC_SUBST(WINDOWS_SDK_LIB_SUBDIR)
7084AC_SUBST(WINDOWS_SDK_VERSION)
7085AC_SUBST(WINDOWS_SDK_WILANGID)
7086
7087if test "$build_os" = "cygwin" -o "$build_os" = "wsl" -o -n "$WSL_ONLY_AS_HELPER"; then
7088    dnl Check midl.exe; this being the first check for a tool in the SDK bin
7089    dnl dir, it also determines that dir's path w/o an arch segment if any,
7090    dnl WINDOWS_SDK_BINDIR_NO_ARCH:
7091    AC_MSG_CHECKING([for midl.exe])
7092
7093    find_winsdk
7094    PathFormat "$winsdktest"
7095    winsdktest_unix="$formatted_path_unix"
7096
7097    if test -n "$winsdkbinsubdir" \
7098        -a -f "$winsdktest_unix/Bin/$winsdkbinsubdir/$WIN_BUILD_ARCH/midl.exe"
7099    then
7100        MIDL_PATH=$winsdktest_unix/Bin/$winsdkbinsubdir/$WIN_BUILD_ARCH
7101        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME_unix/Bin/$winsdkbinsubdir
7102    elif test -f "$winsdktest_unix/Bin/$WIN_BUILD_ARCH/midl.exe"; then
7103        MIDL_PATH=$winsdktest_unix/Bin/$WIN_BUILD_ARCH
7104        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME_unix/Bin
7105    elif test -f "$winsdktest_unix/Bin/midl.exe"; then
7106        MIDL_PATH=$winsdktest_unix/Bin
7107        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME_unix/Bin
7108    fi
7109    PathFormat "$MIDL_PATH"
7110    if test ! -f "$formatted_path_unix/midl.exe"; then
7111        AC_MSG_ERROR([midl.exe not found in $winsdktest/Bin/$WIN_BUILD_ARCH, Windows SDK installation broken?])
7112    else
7113        AC_MSG_RESULT([$MIDL_PATH/midl.exe])
7114    fi
7115
7116    # Convert to posix path with 8.3 filename restrictions ( No spaces )
7117    MIDL_PATH=`win_short_path_for_make "$MIDL_PATH"`
7118
7119    if test -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msiinfo.exe" \
7120         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msidb.exe" \
7121         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/uuidgen.exe" \
7122         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msitran.exe"; then :
7123    elif test -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msiinfo.exe" \
7124         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msidb.exe" \
7125         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/uuidgen.exe" \
7126         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msitran.exe"; then :
7127    elif test -f "$WINDOWS_SDK_HOME/bin/x86/msiinfo.exe" \
7128         -a -f "$WINDOWS_SDK_HOME/bin/x86/msidb.exe" \
7129         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/uuidgen.exe" \
7130         -a -f "$WINDOWS_SDK_HOME/bin/x86/msitran.exe"; then :
7131    else
7132        AC_MSG_ERROR([Some (all?) Windows Installer tools in the Windows SDK are missing, please install.])
7133    fi
7134
7135    PathFormat "$MIDL_PATH"
7136    MIDL_PATH="$formatted_path"
7137
7138    if test "$enable_cli" = yes; then
7139        dnl Check csc.exe
7140        AC_MSG_CHECKING([for csc.exe])
7141        find_csc
7142        PathFormat "$csctest"
7143        csctest_unix="$formatted_path_unix"
7144        if test -f "$csctest_unix/csc.exe"; then
7145            CSC_PATH="$csctest"
7146        fi
7147        if test ! -f "$csctest_unix/csc.exe"; then
7148            AC_MSG_ERROR([csc.exe not found as $CSC_PATH/csc.exe])
7149        else
7150            AC_MSG_RESULT([$CSC_PATH/csc.exe])
7151        fi
7152
7153        CSC_PATH=`win_short_path_for_make "$CSC_PATH"`
7154
7155        dnl Check al.exe
7156        AC_MSG_CHECKING([for al.exe])
7157        if test -n "$winsdkbinsubdir" \
7158            -a -f "$winsdktest_unix/Bin/$winsdkbinsubdir/$WIN_BUILD_ARCH/al.exe"
7159        then
7160            AL_PATH="$winsdktest/Bin/$winsdkbinsubdir/$WIN_BUILD_ARCH"
7161        elif test -f "$winsdktest_unix/Bin/$WIN_BUILD_ARCH/al.exe"; then
7162            AL_PATH="$winsdktest/Bin/$WIN_BUILD_ARCH"
7163        elif test -f "$winsdktest_unix/Bin/al.exe"; then
7164            AL_PATH="$winsdktest/Bin"
7165        fi
7166
7167        if test -z "$AL_PATH"; then
7168            find_al
7169            PathFormat "$altest"
7170            altest_unix="$formatted_path_unix"
7171            if test -f "$altest_unix/bin/al.exe"; then
7172                AL_PATH="$altest/bin"
7173            elif test -f "$altest_unix/al.exe"; then
7174                AL_PATH="$altest"
7175            fi
7176        fi
7177        PathFormat "$AL_PATH"
7178        if test ! -f "$formatted_path_unix/al.exe"; then
7179            AC_MSG_ERROR([al.exe not found as $AL_PATH/al.exe])
7180        else
7181            AC_MSG_RESULT([$AL_PATH/al.exe])
7182        fi
7183
7184        AL_PATH=`win_short_path_for_make "$AL_PATH"`
7185
7186        dnl Check mscoree.lib / .NET Framework dir
7187        AC_MSG_CHECKING(.NET Framework)
7188        find_dotnetsdk
7189        PathFormat "$frametest"
7190        frametest="$formatted_path_unix"
7191        if test -f "$frametest/Lib/um/$WIN_BUILD_ARCH/mscoree.lib"; then
7192            DOTNET_FRAMEWORK_HOME="$frametest"
7193        else
7194            if test -f "$winsdktest_unix/lib/mscoree.lib" -o -f "$winsdktest_unix/lib/$winsdklibsubdir/um/$WIN_BUILD_ARCH/mscoree.lib"; then
7195                DOTNET_FRAMEWORK_HOME="$winsdktest"
7196            fi
7197        fi
7198        PathFormat "$DOTNET_FRAMEWORK_HOME"
7199        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
7200            AC_MSG_ERROR([mscoree.lib not found])
7201        fi
7202        AC_MSG_RESULT([found: $DOTNET_FRAMEWORK_HOME])
7203
7204        PathFormat "$AL_PATH"
7205        AL_PATH="$formatted_path"
7206
7207        PathFormat "$DOTNET_FRAMEWORK_HOME"
7208        DOTNET_FRAMEWORK_HOME="$formatted_path"
7209
7210        PathFormat "$CSC_PATH"
7211        CSC_PATH="$formatted_path"
7212
7213        ENABLE_CLI="TRUE"
7214    else
7215        ENABLE_CLI=""
7216    fi
7217else
7218    ENABLE_CLI=""
7219fi
7220AC_SUBST(ENABLE_CLI)
7221
7222dnl ===================================================================
7223dnl Testing for C++ compiler and version...
7224dnl ===================================================================
7225
7226if test "$_os" != "WINNT"; then
7227    # AC_PROG_CXX sets CXXFLAGS to -g -O2 if not set, avoid that (and avoid -O2 during AC_PROG_CXX,
7228    # see AC_PROG_CC above):
7229    save_CXXFLAGS=$CXXFLAGS
7230    CXXFLAGS=-g
7231    AC_PROG_CXX
7232    CXXFLAGS=$save_CXXFLAGS
7233    if test -z "$CXX_BASE"; then
7234        CXX_BASE=`first_arg_basename "$CXX"`
7235    fi
7236fi
7237
7238dnl check for GNU C++ compiler version
7239if test "$GXX" = "yes" -a -z "$COM_IS_CLANG"; then
7240    AC_MSG_CHECKING([the GNU C++ compiler version])
7241
7242    _gpp_version=`$CXX -dumpversion`
7243    _gpp_majmin=`echo $_gpp_version | $AWK -F. '{ print \$1*100+\$2 }'`
7244
7245    if test "$_gpp_majmin" -lt "700"; then
7246        AC_MSG_ERROR([You need to use GNU C++ compiler version >= 7.0 to build LibreOffice, you have $_gpp_version.])
7247    else
7248        AC_MSG_RESULT([ok (g++ $_gpp_version)])
7249    fi
7250
7251    dnl see https://issuetracker.google.com/issues/36962819
7252        glibcxx_threads=no
7253        AC_LANG_PUSH([C++])
7254        AC_REQUIRE_CPP
7255        AC_MSG_CHECKING([whether $CXX_BASE is broken with boost.thread])
7256        AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
7257            #include <bits/c++config.h>]],[[
7258            #if !defined(_GLIBCXX_HAVE_GTHR_DEFAULT) \
7259            && !defined(_GLIBCXX__PTHREADS) \
7260            && !defined(_GLIBCXX_HAS_GTHREADS)
7261            choke me
7262            #endif
7263        ]])],[AC_MSG_RESULT([yes])
7264        glibcxx_threads=yes],[AC_MSG_RESULT([no])])
7265        AC_LANG_POP([C++])
7266        if test $glibcxx_threads = yes; then
7267            BOOST_CXXFLAGS="-D_GLIBCXX_HAS_GTHREADS"
7268        fi
7269fi
7270AC_SUBST(BOOST_CXXFLAGS)
7271
7272#
7273# prefx CXX with ccache if needed
7274#
7275if test "$CCACHE" != ""; then
7276    AC_MSG_CHECKING([whether $CXX_BASE is already ccached])
7277    AC_LANG_PUSH([C++])
7278    save_CXXFLAGS=$CXXFLAGS
7279    CXXFLAGS="$CXXFLAGS --ccache-skip -O2"
7280    # msvc does not fail on unknown options, check stdout
7281    if test "$COM" = MSC; then
7282        CXXFLAGS="$CXXFLAGS -nologo"
7283    fi
7284    save_ac_cxx_werror_flag=$ac_cxx_werror_flag
7285    ac_cxx_werror_flag=yes
7286    dnl an empty program will do, we're checking the compiler flags
7287    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
7288                      [use_ccache=yes], [use_ccache=no])
7289    if test $use_ccache = yes -a "${CCACHE/*sccache*/}" != ""; then
7290        AC_MSG_RESULT([yes])
7291    else
7292        CXX="$CCACHE $CXX"
7293        CXX_BASE="ccache $CXX_BASE"
7294        AC_MSG_RESULT([no])
7295    fi
7296    CXXFLAGS=$save_CXXFLAGS
7297    ac_cxx_werror_flag=$save_ac_cxx_werror_flag
7298    AC_LANG_POP([C++])
7299fi
7300
7301dnl ===================================================================
7302dnl Find pre-processors.(should do that _after_ messing with CC/CXX)
7303dnl ===================================================================
7304
7305if test "$_os" != "WINNT"; then
7306    AC_PROG_CXXCPP
7307
7308    dnl Check whether there's a C pre-processor.
7309    AC_PROG_CPP
7310fi
7311
7312
7313dnl ===================================================================
7314dnl Find integral type sizes and alignments
7315dnl ===================================================================
7316
7317if test "$_os" != "WINNT"; then
7318
7319    AC_CHECK_SIZEOF(long)
7320    AC_CHECK_SIZEOF(short)
7321    AC_CHECK_SIZEOF(int)
7322    AC_CHECK_SIZEOF(long long)
7323    AC_CHECK_SIZEOF(double)
7324    AC_CHECK_SIZEOF(void*)
7325    AC_CHECK_SIZEOF(size_t)
7326
7327    SAL_TYPES_SIZEOFSHORT=$ac_cv_sizeof_short
7328    SAL_TYPES_SIZEOFINT=$ac_cv_sizeof_int
7329    SAL_TYPES_SIZEOFLONG=$ac_cv_sizeof_long
7330    SAL_TYPES_SIZEOFLONGLONG=$ac_cv_sizeof_long_long
7331    SAL_TYPES_SIZEOFPOINTER=$ac_cv_sizeof_voidp
7332    SIZEOF_SIZE_T=$ac_cv_sizeof_size_t
7333
7334    dnl Allow build without AC_CHECK_ALIGNOF, grrr
7335    m4_pattern_allow([AC_CHECK_ALIGNOF])
7336    m4_ifdef([AC_CHECK_ALIGNOF],
7337        [
7338            AC_CHECK_ALIGNOF(short,[#include <stddef.h>])
7339            AC_CHECK_ALIGNOF(int,[#include <stddef.h>])
7340            AC_CHECK_ALIGNOF(long,[#include <stddef.h>])
7341            AC_CHECK_ALIGNOF(double,[#include <stddef.h>])
7342        ],
7343        [
7344            case "$_os-$host_cpu" in
7345            Linux-i686)
7346                test -z "$ac_cv_alignof_short" && ac_cv_alignof_short=2
7347                test -z "$ac_cv_alignof_int" && ac_cv_alignof_int=4
7348                test -z "$ac_cv_alignof_long" && ac_cv_alignof_long=4
7349                test -z "$ac_cv_alignof_double" && ac_cv_alignof_double=4
7350                ;;
7351            Linux-x86_64)
7352                test -z "$ac_cv_alignof_short" && ac_cv_alignof_short=2
7353                test -z "$ac_cv_alignof_int" && ac_cv_alignof_int=4
7354                test -z "$ac_cv_alignof_long" && ac_cv_alignof_long=8
7355                test -z "$ac_cv_alignof_double" && ac_cv_alignof_double=8
7356                ;;
7357            *)
7358                if test -z "$ac_cv_alignof_short" -o \
7359                        -z "$ac_cv_alignof_int" -o \
7360                        -z "$ac_cv_alignof_long" -o \
7361                        -z "$ac_cv_alignof_double"; then
7362                   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.])
7363                fi
7364                ;;
7365            esac
7366        ])
7367
7368    SAL_TYPES_ALIGNMENT2=$ac_cv_alignof_short
7369    SAL_TYPES_ALIGNMENT4=$ac_cv_alignof_int
7370    if test $ac_cv_sizeof_long -eq 8; then
7371        SAL_TYPES_ALIGNMENT8=$ac_cv_alignof_long
7372    elif test $ac_cv_sizeof_double -eq 8; then
7373        SAL_TYPES_ALIGNMENT8=$ac_cv_alignof_double
7374    else
7375        AC_MSG_ERROR([Cannot find alignment of 8 byte types.])
7376    fi
7377
7378    dnl Check for large file support
7379    AC_SYS_LARGEFILE
7380    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
7381        LFS_CFLAGS="$ac_cv_sys_largefile_opts"
7382    elif test -n "$ac_cv_sys_file_offset_bits" -a "$ac_cv_sys_file_offset_bits" != "no"; then
7383        LFS_CFLAGS="-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
7384    fi
7385    if test -n "$ac_cv_sys_large_files" -a "$ac_cv_sys_large_files" != "no"; then
7386        LFS_CFLAGS="$LFS_CFLAGS -D_LARGE_FILES"
7387    fi
7388else
7389    # Hardcode for MSVC
7390    SAL_TYPES_SIZEOFSHORT=2
7391    SAL_TYPES_SIZEOFINT=4
7392    SAL_TYPES_SIZEOFLONG=4
7393    SAL_TYPES_SIZEOFLONGLONG=8
7394    if test $WIN_HOST_BITS -eq 32; then
7395        SAL_TYPES_SIZEOFPOINTER=4
7396        SIZEOF_SIZE_T=4
7397    else
7398        SAL_TYPES_SIZEOFPOINTER=8
7399        SIZEOF_SIZE_T=8
7400    fi
7401    SAL_TYPES_ALIGNMENT2=2
7402    SAL_TYPES_ALIGNMENT4=4
7403    SAL_TYPES_ALIGNMENT8=8
7404    LFS_CFLAGS=''
7405fi
7406AC_SUBST(LFS_CFLAGS)
7407AC_SUBST(SIZEOF_SIZE_T)
7408
7409AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFSHORT,$SAL_TYPES_SIZEOFSHORT)
7410AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFINT,$SAL_TYPES_SIZEOFINT)
7411AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFLONG,$SAL_TYPES_SIZEOFLONG)
7412AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFLONGLONG,$SAL_TYPES_SIZEOFLONGLONG)
7413AC_DEFINE_UNQUOTED(SAL_TYPES_SIZEOFPOINTER,$SAL_TYPES_SIZEOFPOINTER)
7414AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT2,$SAL_TYPES_ALIGNMENT2)
7415AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT4,$SAL_TYPES_ALIGNMENT4)
7416AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT8,$SAL_TYPES_ALIGNMENT8)
7417
7418dnl Calc jumbo sheets (1m+ rows) depend on 64 bit tools::Long .
7419AC_MSG_CHECKING([whether jumbo sheets are supported])
7420if test "$_os" != "WINNT"; then
7421    if test $SAL_TYPES_SIZEOFLONG -gt 4; then
7422        AC_MSG_RESULT([yes])
7423        ENABLE_JUMBO_SHEETS=TRUE
7424        AC_DEFINE(HAVE_FEATURE_JUMBO_SHEETS)
7425    else
7426        AC_MSG_RESULT([no])
7427    fi
7428else
7429    if test $WIN_HOST_BITS -gt 32; then
7430        # 64bit windows is special-cased for tools::Long because long is 32bit
7431        AC_MSG_RESULT([yes])
7432        ENABLE_JUMBO_SHEETS=TRUE
7433        AC_DEFINE(HAVE_FEATURE_JUMBO_SHEETS)
7434    else
7435        AC_MSG_RESULT([no])
7436    fi
7437fi
7438AC_SUBST(ENABLE_JUMBO_SHEETS)
7439
7440dnl ===================================================================
7441dnl Check whether to enable runtime optimizations
7442dnl ===================================================================
7443ENABLE_RUNTIME_OPTIMIZATIONS=
7444AC_MSG_CHECKING([whether to enable runtime optimizations])
7445if test -z "$enable_runtime_optimizations"; then
7446    for i in $CC; do
7447        case $i in
7448        -fsanitize=*)
7449            enable_runtime_optimizations=no
7450            break
7451            ;;
7452        esac
7453    done
7454fi
7455if test "$enable_runtime_optimizations" != no; then
7456    ENABLE_RUNTIME_OPTIMIZATIONS=TRUE
7457    AC_DEFINE(ENABLE_RUNTIME_OPTIMIZATIONS)
7458    AC_MSG_RESULT([yes])
7459else
7460    AC_MSG_RESULT([no])
7461fi
7462AC_SUBST([ENABLE_RUNTIME_OPTIMIZATIONS])
7463
7464dnl ===================================================================
7465dnl Check if valgrind headers are available
7466dnl ===================================================================
7467ENABLE_VALGRIND=
7468if test "$cross_compiling" != yes -a "$with_valgrind" != no; then
7469    prev_cppflags=$CPPFLAGS
7470    # Is VALGRIND_CFLAGS something one is supposed to have in the environment,
7471    # or where does it come from?
7472    CPPFLAGS="$CPPFLAGS $VALGRIND_CFLAGS"
7473    AC_CHECK_HEADER([valgrind/valgrind.h],
7474        [ENABLE_VALGRIND=TRUE])
7475    CPPFLAGS=$prev_cppflags
7476fi
7477AC_SUBST([ENABLE_VALGRIND])
7478if test -z "$ENABLE_VALGRIND"; then
7479    if test "$with_valgrind" = yes; then
7480        AC_MSG_ERROR([--with-valgrind specified but no Valgrind headers found])
7481    fi
7482    VALGRIND_CFLAGS=
7483fi
7484AC_SUBST([VALGRIND_CFLAGS])
7485
7486
7487dnl ===================================================================
7488dnl Check if SDT probes (for systemtap, gdb, dtrace) are available
7489dnl ===================================================================
7490
7491# We need at least the sys/sdt.h include header.
7492AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND='TRUE'], [SDT_H_FOUND='FALSE'])
7493if test "$SDT_H_FOUND" = "TRUE"; then
7494    # Found sys/sdt.h header, now make sure the c++ compiler works.
7495    # Old g++ versions had problems with probes in constructors/destructors.
7496    AC_MSG_CHECKING([working sys/sdt.h and c++ support])
7497    AC_LANG_PUSH([C++])
7498    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
7499    #include <sys/sdt.h>
7500    class ProbeClass
7501    {
7502    private:
7503      int& ref;
7504      const char *name;
7505
7506    public:
7507      ProbeClass(int& v, const char *n) : ref(v), name(n)
7508      {
7509        DTRACE_PROBE2(_test_, cons, name, ref);
7510      }
7511
7512      void method(int min)
7513      {
7514        DTRACE_PROBE3(_test_, meth, name, ref, min);
7515        ref -= min;
7516      }
7517
7518      ~ProbeClass()
7519      {
7520        DTRACE_PROBE2(_test_, dest, name, ref);
7521      }
7522    };
7523    ]],[[
7524    int i = 64;
7525    DTRACE_PROBE1(_test_, call, i);
7526    ProbeClass inst = ProbeClass(i, "call");
7527    inst.method(24);
7528    ]])], [AC_MSG_RESULT([yes]); AC_DEFINE([USE_SDT_PROBES])],
7529          [AC_MSG_RESULT([no, sdt.h or c++ compiler too old])])
7530    AC_LANG_POP([C++])
7531fi
7532AC_CONFIG_HEADERS([config_host/config_probes.h])
7533
7534dnl ===================================================================
7535dnl GCC features
7536dnl ===================================================================
7537HAVE_GCC_STACK_CLASH_PROTECTION=
7538HARDENING_CFLAGS=
7539HARDENING_OPT_CFLAGS=
7540if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
7541    AC_MSG_CHECKING([whether $CC_BASE supports -grecord-gcc-switches])
7542    save_CFLAGS=$CFLAGS
7543    CFLAGS="$CFLAGS -Werror -grecord-gcc-switches"
7544    AC_LINK_IFELSE(
7545        [AC_LANG_PROGRAM(, [[return 0;]])],
7546        [AC_MSG_RESULT([yes]); HARDENING_CFLAGS="$HARDENING_CFLAGS -grecord-gcc-switches"],
7547        [AC_MSG_RESULT([no])])
7548    CFLAGS=$save_CFLAGS
7549
7550    AC_MSG_CHECKING([whether $CC_BASE supports -D_FORTIFY_SOURCE=2])
7551    save_CFLAGS=$CFLAGS
7552    CFLAGS="$CFLAGS -Werror -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=2"
7553    if test "$ENABLE_OPTIMIZED" = TRUE; then
7554        CFLAGS="$CFLAGS -O2"
7555    fi
7556    AC_LINK_IFELSE(
7557        [AC_LANG_PROGRAM([[#include <string.h>]], [[return 0;]])],
7558        [AC_MSG_RESULT([yes]); HARDENING_OPT_CFLAGS="$HARDENING_OPT_CFLAGS -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=2"],
7559        [AC_MSG_RESULT([no])])
7560    CFLAGS=$save_CFLAGS
7561
7562    AC_MSG_CHECKING([whether $CC_BASE supports -D_GLIBCXX_ASSERTIONS])
7563    save_CFLAGS=$CFLAGS
7564    CFLAGS="$CFLAGS -Werror -Wp,-D_GLIBCXX_ASSERTIONS"
7565    AC_LINK_IFELSE(
7566        [AC_LANG_PROGRAM(, [[return 0;]])],
7567        [AC_MSG_RESULT([yes]); HARDENING_CFLAGS="$HARDENING_CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"],
7568        [AC_MSG_RESULT([no])])
7569    CFLAGS=$save_CFLAGS
7570
7571    AC_MSG_CHECKING([whether $CC_BASE supports -fstack-clash-protection])
7572    save_CFLAGS=$CFLAGS
7573    CFLAGS="$CFLAGS -Werror -fstack-clash-protection"
7574    AC_LINK_IFELSE(
7575        [AC_LANG_PROGRAM(, [[return 0;]])],
7576        [AC_MSG_RESULT([yes]); HAVE_GCC_STACK_CLASH_PROTECTION=TRUE; HARDENING_CFLAGS="$HARDENING_CFLAGS -fstack-clash-protection"],
7577        [AC_MSG_RESULT([no])])
7578    CFLAGS=$save_CFLAGS
7579
7580    AC_MSG_CHECKING([whether $CC_BASE supports -fcf-protection])
7581    save_CFLAGS=$CFLAGS
7582    CFLAGS="$CFLAGS -Werror -fcf-protection"
7583    AC_LINK_IFELSE(
7584        [AC_LANG_PROGRAM(, [[return 0;]])],
7585        [AC_MSG_RESULT([yes]); HARDENING_CFLAGS="$HARDENING_CFLAGS -fcf-protection"],
7586        [AC_MSG_RESULT([no])])
7587    CFLAGS=$save_CFLAGS
7588
7589    AC_MSG_CHECKING([whether $CC_BASE supports -mno-avx])
7590    save_CFLAGS=$CFLAGS
7591    CFLAGS="$CFLAGS -Werror -mno-avx"
7592    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_AVX=TRUE ],[])
7593    CFLAGS=$save_CFLAGS
7594    if test "$HAVE_GCC_AVX" = "TRUE"; then
7595        AC_MSG_RESULT([yes])
7596    else
7597        AC_MSG_RESULT([no])
7598    fi
7599
7600    AC_MSG_CHECKING([whether $CC_BASE supports atomic functions])
7601    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
7602    int v = 0;
7603    if (__sync_add_and_fetch(&v, 1) != 1 ||
7604        __sync_sub_and_fetch(&v, 1) != 0)
7605        return 1;
7606    __sync_synchronize();
7607    if (__sync_val_compare_and_swap(&v, 0, 1) != 0 ||
7608        v != 1)
7609        return 1;
7610    return 0;
7611]])],[HAVE_GCC_BUILTIN_ATOMIC=TRUE],[])
7612    if test "$HAVE_GCC_BUILTIN_ATOMIC" = "TRUE"; then
7613        AC_MSG_RESULT([yes])
7614        AC_DEFINE(HAVE_GCC_BUILTIN_ATOMIC)
7615    else
7616        AC_MSG_RESULT([no])
7617    fi
7618
7619    AC_MSG_CHECKING([whether $CXX_BASE defines __base_class_type_info in cxxabi.h])
7620    AC_LANG_PUSH([C++])
7621    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7622            #include <cstddef>
7623            #include <cxxabi.h>
7624            std::size_t f() { return sizeof(__cxxabiv1::__base_class_type_info); }
7625        ])], [
7626            AC_DEFINE([HAVE_CXXABI_H_BASE_CLASS_TYPE_INFO],[1])
7627            AC_MSG_RESULT([yes])
7628        ], [AC_MSG_RESULT([no])])
7629    AC_LANG_POP([C++])
7630
7631    AC_MSG_CHECKING([whether $CXX_BASE defines __class_type_info in cxxabi.h])
7632    AC_LANG_PUSH([C++])
7633    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7634            #include <cstddef>
7635            #include <cxxabi.h>
7636            std::size_t f() { return sizeof(__cxxabiv1::__class_type_info); }
7637        ])], [
7638            AC_DEFINE([HAVE_CXXABI_H_CLASS_TYPE_INFO],[1])
7639            AC_MSG_RESULT([yes])
7640        ], [AC_MSG_RESULT([no])])
7641    AC_LANG_POP([C++])
7642
7643    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_allocate_exception in cxxabi.h])
7644    AC_LANG_PUSH([C++])
7645    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7646            #include <cxxabi.h>
7647            void * f() { return __cxxabiv1::__cxa_allocate_exception(0); }
7648        ])], [
7649            AC_DEFINE([HAVE_CXXABI_H_CXA_ALLOCATE_EXCEPTION],[1])
7650            AC_MSG_RESULT([yes])
7651        ], [AC_MSG_RESULT([no])])
7652    AC_LANG_POP([C++])
7653
7654    AC_MSG_CHECKING([whether $CXX_BASE defines __cxa_eh_globals in cxxabi.h])
7655    AC_LANG_PUSH([C++])
7656    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7657            #include <cstddef>
7658            #include <cxxabi.h>
7659            std::size_t f() { return sizeof(__cxxabiv1::__cxa_eh_globals); }
7660        ])], [
7661            AC_DEFINE([HAVE_CXXABI_H_CXA_EH_GLOBALS],[1])
7662            AC_MSG_RESULT([yes])
7663        ], [AC_MSG_RESULT([no])])
7664    AC_LANG_POP([C++])
7665
7666    AC_MSG_CHECKING([whether $CXX_BASE defines __cxa_exception in cxxabi.h])
7667    AC_LANG_PUSH([C++])
7668    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7669            #include <cstddef>
7670            #include <cxxabi.h>
7671            std::size_t f() { return sizeof(__cxxabiv1::__cxa_exception); }
7672        ])], [
7673            AC_DEFINE([HAVE_CXXABI_H_CXA_EXCEPTION],[1])
7674            AC_MSG_RESULT([yes])
7675        ], [AC_MSG_RESULT([no])])
7676    AC_LANG_POP([C++])
7677
7678    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_get_globals in cxxabi.h])
7679    AC_LANG_PUSH([C++])
7680    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7681            #include <cxxabi.h>
7682            void * f() { return __cxxabiv1::__cxa_get_globals(); }
7683        ])], [
7684            AC_DEFINE([HAVE_CXXABI_H_CXA_GET_GLOBALS],[1])
7685            AC_MSG_RESULT([yes])
7686        ], [AC_MSG_RESULT([no])])
7687    AC_LANG_POP([C++])
7688
7689    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_current_exception_type in cxxabi.h])
7690    AC_LANG_PUSH([C++])
7691    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7692            #include <cxxabi.h>
7693            void * f() { return __cxxabiv1::__cxa_current_exception_type(); }
7694        ])], [
7695            AC_DEFINE([HAVE_CXXABI_H_CXA_CURRENT_EXCEPTION_TYPE],[1])
7696            AC_MSG_RESULT([yes])
7697        ], [AC_MSG_RESULT([no])])
7698    AC_LANG_POP([C++])
7699
7700    AC_MSG_CHECKING([whether $CXX_BASE declares __cxa_throw in cxxabi.h])
7701    AC_LANG_PUSH([C++])
7702    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7703            #include <cxxabi.h>
7704            void f() { __cxxabiv1::__cxa_throw(0, 0, 0); }
7705        ])], [
7706            AC_DEFINE([HAVE_CXXABI_H_CXA_THROW],[1])
7707            AC_MSG_RESULT([yes])
7708        ], [AC_MSG_RESULT([no])])
7709    AC_LANG_POP([C++])
7710
7711    AC_MSG_CHECKING([whether $CXX_BASE defines __si_class_type_info in cxxabi.h])
7712    AC_LANG_PUSH([C++])
7713    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7714            #include <cstddef>
7715            #include <cxxabi.h>
7716            std::size_t f() { return sizeof(__cxxabiv1::__si_class_type_info); }
7717        ])], [
7718            AC_DEFINE([HAVE_CXXABI_H_SI_CLASS_TYPE_INFO],[1])
7719            AC_MSG_RESULT([yes])
7720        ], [AC_MSG_RESULT([no])])
7721    AC_LANG_POP([C++])
7722
7723    AC_MSG_CHECKING([whether $CXX_BASE defines __vmi_class_type_info in cxxabi.h])
7724    AC_LANG_PUSH([C++])
7725    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7726            #include <cstddef>
7727            #include <cxxabi.h>
7728            std::size_t f() { return sizeof(__cxxabiv1::__vmi_class_type_info); }
7729        ])], [
7730            AC_DEFINE([HAVE_CXXABI_H_VMI_CLASS_TYPE_INFO],[1])
7731            AC_MSG_RESULT([yes])
7732        ], [AC_MSG_RESULT([no])])
7733    AC_LANG_POP([C++])
7734fi
7735
7736AC_SUBST(HAVE_GCC_AVX)
7737AC_SUBST(HAVE_GCC_BUILTIN_ATOMIC)
7738AC_SUBST(HAVE_GCC_STACK_CLASH_PROTECTION)
7739AC_SUBST(HARDENING_CFLAGS)
7740AC_SUBST(HARDENING_OPT_CFLAGS)
7741
7742dnl ===================================================================
7743dnl Identify the C++ library
7744dnl ===================================================================
7745
7746AC_MSG_CHECKING([what the C++ library is])
7747HAVE_LIBSTDCPP=
7748HAVE_LIBCPP=
7749AC_LANG_PUSH([C++])
7750AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
7751#include <utility>
7752#ifndef __GLIBCXX__
7753foo bar
7754#endif
7755]])],
7756    [CPP_LIBRARY=GLIBCXX
7757     cpp_library_name="GNU libstdc++"
7758     HAVE_LIBSTDCPP=TRUE
7759    ],
7760    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
7761#include <utility>
7762#ifndef _LIBCPP_VERSION
7763foo bar
7764#endif
7765]])],
7766    [CPP_LIBRARY=LIBCPP
7767     cpp_library_name="LLVM libc++"
7768     AC_DEFINE([HAVE_LIBCPP])
7769     HAVE_LIBCPP=TRUE
7770    ],
7771    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
7772#include <utility>
7773#ifndef _MSC_VER
7774foo bar
7775#endif
7776]])],
7777    [CPP_LIBRARY=MSVCRT
7778     cpp_library_name="Microsoft"
7779    ],
7780    AC_MSG_ERROR([Could not figure out what C++ library this is]))))
7781AC_MSG_RESULT([$cpp_library_name])
7782AC_LANG_POP([C++])
7783AC_SUBST([HAVE_LIBSTDCPP])
7784AC_SUBST([HAVE_LIBCPP])
7785
7786if test -z "${LIBCPP_DEBUG+x}" -a -z "$CROSS_COMPILING" -a -n "$HAVE_LIBCPP" -a -n "$ENABLE_DBGUTIL"
7787then
7788    # Libc++ has two levels of debug mode, assertions mode enabled with -D_LIBCPP_DEBUG=0,
7789    # and actual debug mode enabled with -D_LIBCPP_DEBUG=1 (and starting with LLVM15
7790    # assertions mode will be separate and controlled by -D_LIBCPP_ENABLE_ASSERTIONS=1,
7791    # although there will be backwards compatibility).
7792    # Debug mode is supported by libc++ only if built for it, e.g. Mac libc++ isn't,
7793    # and there would be undefined references to debug functions.
7794    # Moreover std::to_string() has a bug (https://reviews.llvm.org/D125184).
7795    # So check if debug mode can be used and disable or downgrade it to assertions
7796    # if needed.
7797    AC_MSG_CHECKING([if libc++ has a usable debug mode])
7798    AC_LANG_PUSH([C++])
7799    libcpp_debug_links=
7800    AC_LINK_IFELSE([AC_LANG_SOURCE([[
7801#define _LIBCPP_DEBUG 0 // only assertions
7802#include <vector>
7803int main()
7804{
7805    std::vector<int> v;
7806    v.push_back( 1 );
7807    return v[ 3 ];
7808}
7809]])], [libcpp_debug_links=1])
7810    if test -n "$libcpp_debug_links"; then
7811        # we can use at least assertions, check if debug mode works
7812        AC_RUN_IFELSE([AC_LANG_SOURCE([[
7813#define _LIBCPP_DEBUG 1 // debug mode
7814#include <string>
7815#include <vector>
7816int foo(const std::vector<int>& v) { return *v.begin(); }
7817int main()
7818{
7819    std::vector<int> v;
7820    v.push_back( 1 );
7821    std::string s = "xxxxxxxxxxxxxxxxxxxxxxxxx" + std::to_string(10);
7822    return (foo(v) + s.size()) != 0 ? 0 : 1;
7823}
7824]])],
7825        [AC_MSG_RESULT(yes)
7826         LIBCPP_DEBUG=-D_LIBCPP_DEBUG=1
7827        ],
7828        [AC_MSG_RESULT(no, using only assertions)
7829         LIBCPP_DEBUG=-D_LIBCPP_DEBUG=0
7830        ]
7831        )
7832    else
7833        AC_MSG_RESULT(no)
7834    fi
7835    AC_LANG_POP([C++])
7836fi
7837AC_SUBST([LIBCPP_DEBUG])
7838
7839dnl ===================================================================
7840dnl Check for gperf
7841dnl ===================================================================
7842AC_PATH_PROG(GPERF, gperf)
7843if test -z "$GPERF"; then
7844    AC_MSG_ERROR([gperf not found but needed. Install it.])
7845fi
7846if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
7847    GPERF=`cygpath -m $GPERF`
7848fi
7849AC_MSG_CHECKING([whether gperf is new enough])
7850my_gperf_ver1=$($GPERF --version | head -n 1)
7851my_gperf_ver2=${my_gperf_ver1#GNU gperf }
7852my_gperf_ver3=$(printf %s "$my_gperf_ver2" | $AWK -F. '{ print $1*100+($2<100?$2:99) }')
7853if test "$my_gperf_ver3" -ge 301; then
7854    AC_MSG_RESULT([yes ($my_gperf_ver2)])
7855else
7856    AC_MSG_ERROR(["$my_gperf_ver1" is too old or unrecognized, must be at least gperf 3.1])
7857fi
7858AC_SUBST(GPERF)
7859
7860dnl ===================================================================
7861dnl Check for system libcmis
7862dnl ===================================================================
7863libo_CHECK_SYSTEM_MODULE([libcmis],[LIBCMIS],[libcmis-0.6 >= 0.6.1],enabled)
7864
7865dnl ===================================================================
7866dnl C++11
7867dnl ===================================================================
7868
7869if test -z "${CXXFLAGS_CXX11+x}"; then
7870    AC_MSG_CHECKING([whether $CXX_BASE supports C++20])
7871    if test "$COM" = MSC -a "$COM_IS_CLANG" != TRUE; then
7872        if test "$with_latest_c__" = yes; then
7873            CXXFLAGS_CXX11=-std:c++latest
7874        else
7875            CXXFLAGS_CXX11=-std:c++20
7876        fi
7877        CXXFLAGS_CXX11="$CXXFLAGS_CXX11 -permissive- -Zc:__cplusplus,preprocessor"
7878    elif test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
7879        my_flags='-std=c++20 -std=c++2a'
7880        if test "$with_latest_c__" = yes; then
7881            my_flags="-std=c++26 -std=c++2c -std=c++23 -std=c++2b $my_flags"
7882        fi
7883        for flag in $my_flags; do
7884            if test "$COM" = MSC; then
7885                flag="-Xclang $flag"
7886            fi
7887            save_CXXFLAGS=$CXXFLAGS
7888            CXXFLAGS="$CXXFLAGS $flag -Werror"
7889            AC_LANG_PUSH([C++])
7890            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
7891                #include <algorithm>
7892                #include <functional>
7893                #include <vector>
7894
7895                void f(std::vector<int> & v, std::function<bool(int, int)> fn) {
7896                    std::sort(v.begin(), v.end(), fn);
7897                }
7898                ]])],[CXXFLAGS_CXX11=$flag])
7899            AC_LANG_POP([C++])
7900            CXXFLAGS=$save_CXXFLAGS
7901            if test -n "$CXXFLAGS_CXX11"; then
7902                break
7903            fi
7904        done
7905    fi
7906    if test -n "$CXXFLAGS_CXX11"; then
7907        AC_MSG_RESULT([yes ($CXXFLAGS_CXX11)])
7908    else
7909        AC_MSG_ERROR(no)
7910    fi
7911fi
7912AC_SUBST(CXXFLAGS_CXX11)
7913
7914if test "$GCC" = "yes"; then
7915    save_CXXFLAGS=$CXXFLAGS
7916    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
7917    CHECK_L_ATOMIC
7918    CXXFLAGS=$save_CXXFLAGS
7919    AC_SUBST(ATOMIC_LIB)
7920fi
7921
7922AC_MSG_CHECKING([whether $CXX_BASE supports C++11 without Language Defect 757])
7923save_CXXFLAGS=$CXXFLAGS
7924CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
7925AC_LANG_PUSH([C++])
7926
7927AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
7928#include <stddef.h>
7929
7930template <typename T, size_t S> char (&sal_n_array_size( T(&)[S] ))[S];
7931
7932namespace
7933{
7934        struct b
7935        {
7936                int i;
7937                int j;
7938        };
7939}
7940]], [[
7941struct a
7942{
7943        int i;
7944        int j;
7945};
7946a thinga[]={{0,0}, {1,1}};
7947b thingb[]={{0,0}, {1,1}};
7948size_t i = sizeof(sal_n_array_size(thinga));
7949size_t j = sizeof(sal_n_array_size(thingb));
7950return !(i != 0 && j != 0);
7951]])
7952    ], [ AC_MSG_RESULT(yes) ],
7953    [ AC_MSG_ERROR(no)])
7954AC_LANG_POP([C++])
7955CXXFLAGS=$save_CXXFLAGS
7956
7957HAVE_GCC_FNO_SIZED_DEALLOCATION=
7958if test "$GCC" = yes; then
7959    AC_MSG_CHECKING([whether $CXX_BASE supports -fno-sized-deallocation])
7960    AC_LANG_PUSH([C++])
7961    save_CXXFLAGS=$CXXFLAGS
7962    CXXFLAGS="$CXXFLAGS -fno-sized-deallocation"
7963    AC_LINK_IFELSE([AC_LANG_PROGRAM()],[HAVE_GCC_FNO_SIZED_DEALLOCATION=TRUE])
7964    CXXFLAGS=$save_CXXFLAGS
7965    AC_LANG_POP([C++])
7966    if test "$HAVE_GCC_FNO_SIZED_DEALLOCATION" = TRUE; then
7967        AC_MSG_RESULT([yes])
7968    else
7969        AC_MSG_RESULT([no])
7970    fi
7971fi
7972AC_SUBST([HAVE_GCC_FNO_SIZED_DEALLOCATION])
7973
7974AC_MSG_CHECKING([whether $CXX_BASE supports C++2a constinit sorted vectors])
7975AC_LANG_PUSH([C++])
7976save_CXXFLAGS=$CXXFLAGS
7977CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
7978AC_COMPILE_IFELSE([AC_LANG_SOURCE([
7979        #include <algorithm>
7980        #include <initializer_list>
7981        #include <vector>
7982        template<typename T> class S {
7983        private:
7984            std::vector<T> v_;
7985        public:
7986            constexpr S(std::initializer_list<T> i): v_(i) { std::sort(v_.begin(), v_.end()); }
7987        };
7988        constinit S<int> s{3, 2, 1};
7989    ])], [
7990        AC_DEFINE([HAVE_CPP_CONSTINIT_SORTED_VECTOR],[1])
7991        AC_MSG_RESULT([yes])
7992    ], [AC_MSG_RESULT([no])])
7993CXXFLAGS=$save_CXXFLAGS
7994AC_LANG_POP([C++])
7995
7996AC_MSG_CHECKING([whether $CXX_BASE implements C++ DR P1155R3])
7997AC_LANG_PUSH([C++])
7998save_CXXFLAGS=$CXXFLAGS
7999CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
8000AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8001        struct S1 { S1(S1 &&); };
8002        struct S2: S1 {};
8003        S1 f(S2 s) { return s; }
8004    ])], [
8005        AC_DEFINE([HAVE_P1155R3],[1])
8006        AC_MSG_RESULT([yes])
8007    ], [AC_MSG_RESULT([no])])
8008CXXFLAGS=$save_CXXFLAGS
8009AC_LANG_POP([C++])
8010
8011AC_MSG_CHECKING([whether $CXX_BASE supports C++20 std::atomic_ref])
8012HAVE_CXX20_ATOMIC_REF=
8013AC_LANG_PUSH([C++])
8014save_CXXFLAGS=$CXXFLAGS
8015CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
8016AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8017        #include <atomic>
8018        int x;
8019        std::atomic_ref<int> y(x);
8020    ])], [
8021        HAVE_CXX20_ATOMIC_REF=TRUE
8022        AC_MSG_RESULT([yes])
8023    ], [AC_MSG_RESULT([no])])
8024CXXFLAGS=$save_CXXFLAGS
8025AC_LANG_POP([C++])
8026AC_SUBST([HAVE_CXX20_ATOMIC_REF])
8027
8028dnl Supported since GCC 9 and Clang 10 (which each also started to support -Wdeprecated-copy, but
8029dnl which is included in -Wextra anyway):
8030HAVE_WDEPRECATED_COPY_DTOR=
8031if test "$GCC" = yes; then
8032    AC_MSG_CHECKING([whether $CXX_BASE supports -Wdeprecated-copy-dtor])
8033    AC_LANG_PUSH([C++])
8034    save_CXXFLAGS=$CXXFLAGS
8035    CXXFLAGS="$CXXFLAGS -Werror -Wdeprecated-copy-dtor"
8036    AC_COMPILE_IFELSE([AC_LANG_SOURCE()], [
8037            HAVE_WDEPRECATED_COPY_DTOR=TRUE
8038            AC_MSG_RESULT([yes])
8039        ], [AC_MSG_RESULT([no])])
8040    CXXFLAGS=$save_CXXFLAGS
8041    AC_LANG_POP([C++])
8042fi
8043AC_SUBST([HAVE_WDEPRECATED_COPY_DTOR])
8044
8045dnl At least GCC 8.2 with -O2 (i.e., --enable-optimized) causes a false-positive -Wmaybe-
8046dnl uninitialized warning for code like
8047dnl
8048dnl   OString f();
8049dnl   boost::optional<OString> * g(bool b) {
8050dnl       boost::optional<OString> o;
8051dnl       if (b) o = f();
8052dnl       return new boost::optional<OString>(o);
8053dnl   }
8054dnl
8055dnl (as is e.g. present, in a slightly more elaborate form, in
8056dnl librdf_TypeConverter::extractNode_NoLock in unoxml/source/rdf/librdf_repository.cxx); the below
8057dnl code is meant to be a faithfully stripped-down and self-contained version of the above code:
8058HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED=
8059if test "$GCC" = yes && test "$COM_IS_CLANG" != TRUE; then
8060    AC_MSG_CHECKING([whether $CXX_BASE might report false -Werror=maybe-uninitialized])
8061    AC_LANG_PUSH([C++])
8062    save_CXXFLAGS=$CXXFLAGS
8063    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11 -Werror -Wmaybe-uninitialized"
8064    if test "$ENABLE_OPTIMIZED" = TRUE; then
8065        CXXFLAGS="$CXXFLAGS -O2"
8066    else
8067        CXXFLAGS="$CXXFLAGS -O0"
8068    fi
8069    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
8070            #include <new>
8071            void f1(int);
8072            struct S1 {
8073                ~S1() { f1(n); }
8074                int n = 0;
8075            };
8076            struct S2 {
8077                S2() {}
8078                S2(S2 const & s) { if (s.init) set(*reinterpret_cast<S1 const *>(s.stg)); }
8079                ~S2() { if (init) reinterpret_cast<S1 *>(stg)->S1::~S1(); }
8080                void set(S1 s) {
8081                    new (stg) S1(s);
8082                    init = true;
8083                }
8084                bool init = false;
8085                char stg[sizeof (S1)];
8086            } ;
8087            S1 f2();
8088            S2 * f3(bool b) {
8089                S2 o;
8090                if (b) o.set(f2());
8091                return new S2(o);
8092            }
8093        ]])], [AC_MSG_RESULT([no])], [
8094            HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED=TRUE
8095            AC_MSG_RESULT([yes])
8096        ])
8097    CXXFLAGS=$save_CXXFLAGS
8098    AC_LANG_POP([C++])
8099fi
8100AC_SUBST([HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED])
8101
8102dnl Check for <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87296#c5> "[8/9/10/11 Regression]
8103dnl -Wstringop-overflow false positive due to using MEM_REF type of &MEM" (fixed in GCC 11), which
8104dnl hits us e.g. with GCC 10 and --enable-optimized at
8105dnl
8106dnl   In file included from include/rtl/string.hxx:49,
8107dnl                    from include/rtl/ustring.hxx:43,
8108dnl                    from include/osl/file.hxx:35,
8109dnl                    from include/codemaker/global.hxx:28,
8110dnl                    from include/codemaker/options.hxx:23,
8111dnl                    from codemaker/source/commoncpp/commoncpp.cxx:24:
8112dnl   In function ‘char* rtl::addDataHelper(char*, const char*, std::size_t)’,
8113dnl       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,
8114dnl       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,
8115dnl       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,
8116dnl       inlined from ‘rtl::OString codemaker::cpp::scopedCppName(const rtl::OString&, bool)’ at codemaker/source/commoncpp/commoncpp.cxx:53:55:
8117dnl   include/rtl/stringconcat.hxx:78:15: error: writing 2 bytes into a region of size 1 [-Werror=stringop-overflow=]
8118dnl      78 |         memcpy( buffer, data, length );
8119dnl         |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
8120HAVE_BROKEN_GCC_WSTRINGOP_OVERFLOW=
8121if test "$GCC" = yes && test "$COM_IS_CLANG" != TRUE; then
8122    AC_MSG_CHECKING([whether $CXX_BASE might report false -Werror=stringop-overflow=])
8123    AC_LANG_PUSH([C++])
8124    save_CXXFLAGS=$CXXFLAGS
8125    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11 -Werror -Wstringop-overflow"
8126    if test "$ENABLE_OPTIMIZED" = TRUE; then
8127        CXXFLAGS="$CXXFLAGS -O2"
8128    else
8129        CXXFLAGS="$CXXFLAGS -O0"
8130    fi
8131    dnl Test code taken from <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87296#c0>:
8132    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
8133            void fill(char const * begin, char const * end, char c);
8134            struct q {
8135                char ids[4];
8136                char username[6];
8137            };
8138            void test(q & c) {
8139                fill(c.ids, c.ids + sizeof(c.ids), '\0');
8140                __builtin_strncpy(c.username, "root", sizeof(c.username));
8141            }
8142        ]])], [AC_MSG_RESULT([no])], [
8143            HAVE_BROKEN_GCC_WSTRINGOP_OVERFLOW=TRUE
8144            AC_MSG_RESULT([yes])
8145        ])
8146    CXXFLAGS=$save_CXXFLAGS
8147    AC_LANG_POP([C++])
8148fi
8149AC_SUBST([HAVE_BROKEN_GCC_WSTRINGOP_OVERFLOW])
8150
8151HAVE_DLLEXPORTINLINES=
8152if test "$_os" = "WINNT"; then
8153    AC_MSG_CHECKING([whether $CXX_BASE supports -Zc:dllexportInlines-])
8154    AC_LANG_PUSH([C++])
8155    save_CXXFLAGS=$CXXFLAGS
8156    CXXFLAGS="$CXXFLAGS -Werror -Zc:dllexportInlines-"
8157    AC_COMPILE_IFELSE([AC_LANG_SOURCE()], [
8158            HAVE_DLLEXPORTINLINES=TRUE
8159            AC_MSG_RESULT([yes])
8160        ], [AC_MSG_RESULT([no])])
8161    CXXFLAGS=$save_CXXFLAGS
8162    AC_LANG_POP([C++])
8163fi
8164AC_SUBST([HAVE_DLLEXPORTINLINES])
8165
8166dnl ===================================================================
8167dnl CPU Intrinsics support - SSE, AVX
8168dnl ===================================================================
8169
8170CXXFLAGS_INTRINSICS_SSE2=
8171CXXFLAGS_INTRINSICS_SSSE3=
8172CXXFLAGS_INTRINSICS_SSE41=
8173CXXFLAGS_INTRINSICS_SSE42=
8174CXXFLAGS_INTRINSICS_AVX=
8175CXXFLAGS_INTRINSICS_AVX2=
8176CXXFLAGS_INTRINSICS_AVX512=
8177CXXFLAGS_INTRINSICS_AVX512F=
8178CXXFLAGS_INTRINSICS_F16C=
8179CXXFLAGS_INTRINSICS_FMA=
8180
8181if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
8182    # GCC, Clang or Clang-cl (clang-cl + MSVC's -arch options don't work well together)
8183    flag_sse2=-msse2
8184    flag_ssse3=-mssse3
8185    flag_sse41=-msse4.1
8186    flag_sse42=-msse4.2
8187    flag_avx=-mavx
8188    flag_avx2=-mavx2
8189    flag_avx512="-mavx512f -mavx512vl -mavx512bw -mavx512dq -mavx512cd"
8190    flag_avx512f=-mavx512f
8191    flag_f16c=-mf16c
8192    flag_fma=-mfma
8193else
8194    # With MSVC using -arch is in fact not necessary for being able
8195    # to use CPU intrinsics, code using AVX512F intrinsics will compile
8196    # even if compiled with -arch:AVX, the -arch option really only affects
8197    # instructions generated for C/C++ code.
8198    # So use the matching same (or lower) -arch options, but only in order
8199    # to generate the best matching instructions for the C++ code surrounding
8200    # the intrinsics.
8201    # SSE2 is the default for x86/x64, so no need to specify the option.
8202    flag_sse2=
8203    # No specific options for these, use the next lower.
8204    flag_ssse3="$flag_sse2"
8205    flag_sse41="$flag_sse2"
8206    flag_sse42="$flag_sse2"
8207    flag_avx=-arch:AVX
8208    flag_avx2=-arch:AVX2
8209    flag_avx512=-arch:AVX512
8210    # Using -arch:AVX512 would enable more than just AVX512F, so use only AVX2.
8211    flag_avx512f=-arch:AVX2
8212    # No MSVC options for these.
8213    flag_f16c="$flag_sse2"
8214    flag_fma="$flag_sse2"
8215fi
8216
8217AC_MSG_CHECKING([whether $CXX can compile SSE2 intrinsics])
8218AC_LANG_PUSH([C++])
8219save_CXXFLAGS=$CXXFLAGS
8220CXXFLAGS="$CXXFLAGS $flag_sse2"
8221AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8222    #include <emmintrin.h>
8223    int main () {
8224        __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
8225        c = _mm_xor_si128 (a, b);
8226        return 0;
8227    }
8228    ])],
8229    [can_compile_sse2=yes],
8230    [can_compile_sse2=no])
8231AC_LANG_POP([C++])
8232CXXFLAGS=$save_CXXFLAGS
8233AC_MSG_RESULT([${can_compile_sse2}])
8234if test "${can_compile_sse2}" = "yes" ; then
8235    CXXFLAGS_INTRINSICS_SSE2="$flag_sse2"
8236fi
8237
8238AC_MSG_CHECKING([whether $CXX can compile SSSE3 intrinsics])
8239AC_LANG_PUSH([C++])
8240save_CXXFLAGS=$CXXFLAGS
8241CXXFLAGS="$CXXFLAGS $flag_ssse3"
8242AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8243    #include <tmmintrin.h>
8244    int main () {
8245        __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
8246        c = _mm_maddubs_epi16 (a, b);
8247        return 0;
8248    }
8249    ])],
8250    [can_compile_ssse3=yes],
8251    [can_compile_ssse3=no])
8252AC_LANG_POP([C++])
8253CXXFLAGS=$save_CXXFLAGS
8254AC_MSG_RESULT([${can_compile_ssse3}])
8255if test "${can_compile_ssse3}" = "yes" ; then
8256    CXXFLAGS_INTRINSICS_SSSE3="$flag_ssse3"
8257fi
8258
8259AC_MSG_CHECKING([whether $CXX can compile SSE4.1 intrinsics])
8260AC_LANG_PUSH([C++])
8261save_CXXFLAGS=$CXXFLAGS
8262CXXFLAGS="$CXXFLAGS $flag_sse41"
8263AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8264    #include <smmintrin.h>
8265    int main () {
8266        __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
8267        c = _mm_cmpeq_epi64 (a, b);
8268        return 0;
8269    }
8270    ])],
8271    [can_compile_sse41=yes],
8272    [can_compile_sse41=no])
8273AC_LANG_POP([C++])
8274CXXFLAGS=$save_CXXFLAGS
8275AC_MSG_RESULT([${can_compile_sse41}])
8276if test "${can_compile_sse41}" = "yes" ; then
8277    CXXFLAGS_INTRINSICS_SSE41="$flag_sse41"
8278fi
8279
8280AC_MSG_CHECKING([whether $CXX can compile SSE4.2 intrinsics])
8281AC_LANG_PUSH([C++])
8282save_CXXFLAGS=$CXXFLAGS
8283CXXFLAGS="$CXXFLAGS $flag_sse42"
8284AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8285    #include <nmmintrin.h>
8286    int main () {
8287        __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
8288        c = _mm_cmpgt_epi64 (a, b);
8289        return 0;
8290    }
8291    ])],
8292    [can_compile_sse42=yes],
8293    [can_compile_sse42=no])
8294AC_LANG_POP([C++])
8295CXXFLAGS=$save_CXXFLAGS
8296AC_MSG_RESULT([${can_compile_sse42}])
8297if test "${can_compile_sse42}" = "yes" ; then
8298    CXXFLAGS_INTRINSICS_SSE42="$flag_sse42"
8299fi
8300
8301AC_MSG_CHECKING([whether $CXX can compile AVX intrinsics])
8302AC_LANG_PUSH([C++])
8303save_CXXFLAGS=$CXXFLAGS
8304CXXFLAGS="$CXXFLAGS $flag_avx"
8305AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8306    #include <immintrin.h>
8307    int main () {
8308        __m256 a = _mm256_set1_ps (0.0f), b = _mm256_set1_ps (0.0f), c;
8309        c = _mm256_xor_ps(a, b);
8310        return 0;
8311    }
8312    ])],
8313    [can_compile_avx=yes],
8314    [can_compile_avx=no])
8315AC_LANG_POP([C++])
8316CXXFLAGS=$save_CXXFLAGS
8317AC_MSG_RESULT([${can_compile_avx}])
8318if test "${can_compile_avx}" = "yes" ; then
8319    CXXFLAGS_INTRINSICS_AVX="$flag_avx"
8320fi
8321
8322AC_MSG_CHECKING([whether $CXX can compile AVX2 intrinsics])
8323AC_LANG_PUSH([C++])
8324save_CXXFLAGS=$CXXFLAGS
8325CXXFLAGS="$CXXFLAGS $flag_avx2"
8326AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8327    #include <immintrin.h>
8328    int main () {
8329        __m256i a = _mm256_set1_epi32 (0), b = _mm256_set1_epi32 (0), c;
8330        c = _mm256_maddubs_epi16(a, b);
8331        return 0;
8332    }
8333    ])],
8334    [can_compile_avx2=yes],
8335    [can_compile_avx2=no])
8336AC_LANG_POP([C++])
8337CXXFLAGS=$save_CXXFLAGS
8338AC_MSG_RESULT([${can_compile_avx2}])
8339if test "${can_compile_avx2}" = "yes" ; then
8340    CXXFLAGS_INTRINSICS_AVX2="$flag_avx2"
8341fi
8342
8343AC_MSG_CHECKING([whether $CXX can compile AVX512 intrinsics])
8344AC_LANG_PUSH([C++])
8345save_CXXFLAGS=$CXXFLAGS
8346CXXFLAGS="$CXXFLAGS $flag_avx512"
8347AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8348    #include <immintrin.h>
8349    int main () {
8350        __m512i a = _mm512_loadu_si512(0);
8351        __m512d v1 = _mm512_load_pd(0);
8352        // https://gcc.gnu.org/git/?p=gcc.git;a=commit;f=gcc/config/i386/avx512fintrin.h;h=23bce99cbe7016a04e14c2163ed3fe6a5a64f4e2
8353        __m512d v2 = _mm512_abs_pd(v1);
8354        return 0;
8355    }
8356    ])],
8357    [can_compile_avx512=yes],
8358    [can_compile_avx512=no])
8359AC_LANG_POP([C++])
8360CXXFLAGS=$save_CXXFLAGS
8361AC_MSG_RESULT([${can_compile_avx512}])
8362if test "${can_compile_avx512}" = "yes" ; then
8363    CXXFLAGS_INTRINSICS_AVX512="$flag_avx512"
8364    CXXFLAGS_INTRINSICS_AVX512F="$flag_avx512f"
8365fi
8366
8367AC_MSG_CHECKING([whether $CXX can compile F16C intrinsics])
8368AC_LANG_PUSH([C++])
8369save_CXXFLAGS=$CXXFLAGS
8370CXXFLAGS="$CXXFLAGS $flag_f16c"
8371AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8372    #include <immintrin.h>
8373    int main () {
8374        __m128i a = _mm_set1_epi32 (0);
8375        __m128 c;
8376        c = _mm_cvtph_ps(a);
8377        return 0;
8378    }
8379    ])],
8380    [can_compile_f16c=yes],
8381    [can_compile_f16c=no])
8382AC_LANG_POP([C++])
8383CXXFLAGS=$save_CXXFLAGS
8384AC_MSG_RESULT([${can_compile_f16c}])
8385if test "${can_compile_f16c}" = "yes" ; then
8386    CXXFLAGS_INTRINSICS_F16C="$flag_f16c"
8387fi
8388
8389AC_MSG_CHECKING([whether $CXX can compile FMA intrinsics])
8390AC_LANG_PUSH([C++])
8391save_CXXFLAGS=$CXXFLAGS
8392CXXFLAGS="$CXXFLAGS $flag_fma"
8393AC_COMPILE_IFELSE([AC_LANG_SOURCE([
8394    #include <immintrin.h>
8395    int main () {
8396        __m256 a = _mm256_set1_ps (0.0f), b = _mm256_set1_ps (0.0f), c = _mm256_set1_ps (0.0f), d;
8397        d = _mm256_fmadd_ps(a, b, c);
8398        return 0;
8399    }
8400    ])],
8401    [can_compile_fma=yes],
8402    [can_compile_fma=no])
8403AC_LANG_POP([C++])
8404CXXFLAGS=$save_CXXFLAGS
8405AC_MSG_RESULT([${can_compile_fma}])
8406if test "${can_compile_fma}" = "yes" ; then
8407    CXXFLAGS_INTRINSICS_FMA="$flag_fma"
8408fi
8409
8410AC_SUBST([CXXFLAGS_INTRINSICS_SSE2])
8411AC_SUBST([CXXFLAGS_INTRINSICS_SSSE3])
8412AC_SUBST([CXXFLAGS_INTRINSICS_SSE41])
8413AC_SUBST([CXXFLAGS_INTRINSICS_SSE42])
8414AC_SUBST([CXXFLAGS_INTRINSICS_AVX])
8415AC_SUBST([CXXFLAGS_INTRINSICS_AVX2])
8416AC_SUBST([CXXFLAGS_INTRINSICS_AVX512])
8417AC_SUBST([CXXFLAGS_INTRINSICS_AVX512F])
8418AC_SUBST([CXXFLAGS_INTRINSICS_F16C])
8419AC_SUBST([CXXFLAGS_INTRINSICS_FMA])
8420
8421dnl ===================================================================
8422dnl system stl sanity tests
8423dnl ===================================================================
8424if test "$_os" != "WINNT"; then
8425
8426    AC_LANG_PUSH([C++])
8427
8428    save_CPPFLAGS="$CPPFLAGS"
8429    if test -n "$MACOSX_SDK_PATH"; then
8430        CPPFLAGS="-isysroot $MACOSX_SDK_PATH $CPPFLAGS"
8431    fi
8432
8433    # Assume visibility is not broken with libc++. The below test is very much designed for libstdc++
8434    # only.
8435    if test "$CPP_LIBRARY" = GLIBCXX; then
8436        dnl gcc#19664, gcc#22482, rhbz#162935
8437        AC_MSG_CHECKING([if STL headers are visibility safe (GCC bug 22482)])
8438        AC_EGREP_HEADER(visibility push, string, stlvisok=yes, stlvisok=no)
8439        AC_MSG_RESULT([$stlvisok])
8440        if test "$stlvisok" = "no"; then
8441            AC_MSG_ERROR([Your libstdc++ headers are not visibility safe. This is no longer supported.])
8442        fi
8443    fi
8444
8445    # As the below test checks things when linking self-compiled dynamic libraries, it presumably is irrelevant
8446    # when we don't make any dynamic libraries?
8447    if test "$DISABLE_DYNLOADING" = ""; then
8448        AC_MSG_CHECKING([if $CXX_BASE is -fvisibility-inlines-hidden safe (Clang bug 11250)])
8449        cat > conftestlib1.cc <<_ACEOF
8450template<typename T> struct S1 { virtual ~S1() {} virtual void f() {} };
8451struct S2: S1<int> { virtual ~S2(); };
8452S2::~S2() {}
8453_ACEOF
8454        cat > conftestlib2.cc <<_ACEOF
8455template<typename T> struct S1 { virtual ~S1() {} virtual void f() {} };
8456struct S2: S1<int> { virtual ~S2(); };
8457struct S3: S2 { virtual ~S3(); }; S3::~S3() {}
8458_ACEOF
8459        gccvisinlineshiddenok=yes
8460        if ! $CXX $CXXFLAGS $CPPFLAGS $LINKFLAGSSHL -fPIC -fvisibility-inlines-hidden conftestlib1.cc -o libconftest1$DLLPOST >/dev/null 2>&5; then
8461            gccvisinlineshiddenok=no
8462        else
8463            dnl At least Clang -fsanitize=address and -fsanitize=undefined are
8464            dnl known to not work with -z defs (unsetting which makes the test
8465            dnl moot, though):
8466            my_linkflagsnoundefs=$LINKFLAGSNOUNDEFS
8467            if test "$COM_IS_CLANG" = TRUE; then
8468                for i in $CXX $CXXFLAGS; do
8469                    case $i in
8470                    -fsanitize=*)
8471                        my_linkflagsnoundefs=
8472                        break
8473                        ;;
8474                    esac
8475                done
8476            fi
8477            if ! $CXX $CXXFLAGS $CPPFLAGS $LINKFLAGSSHL -fPIC -fvisibility-inlines-hidden conftestlib2.cc -L. -lconftest1 $my_linkflagsnoundefs -o libconftest2$DLLPOST >/dev/null 2>&5; then
8478                gccvisinlineshiddenok=no
8479            fi
8480        fi
8481
8482        rm -fr libconftest*
8483        AC_MSG_RESULT([$gccvisinlineshiddenok])
8484        if test "$gccvisinlineshiddenok" = "no"; then
8485            AC_MSG_ERROR([Your gcc/clang is not -fvisibility-inlines-hidden safe. This is no longer supported.])
8486        fi
8487    fi
8488
8489   AC_MSG_CHECKING([if $CXX_BASE has a visibility bug with class-level attributes (GCC bug 26905)])
8490    cat >visibility.cxx <<_ACEOF
8491#pragma GCC visibility push(hidden)
8492struct __attribute__ ((visibility ("default"))) TestStruct {
8493  static void Init();
8494};
8495__attribute__ ((visibility ("default"))) void TestFunc() {
8496  TestStruct::Init();
8497}
8498_ACEOF
8499    if ! $CXX $CXXFLAGS $CPPFLAGS -fpic -S visibility.cxx; then
8500        gccvisbroken=yes
8501    else
8502        case "$host_cpu" in
8503        i?86|x86_64)
8504            if test "$_os" = "Darwin" -o "$_os" = "iOS"; then
8505                gccvisbroken=no
8506            else
8507                if $EGREP -q '@PLT|@GOT' visibility.s || test "$ENABLE_LTO" = "TRUE"; then
8508                    gccvisbroken=no
8509                else
8510                    gccvisbroken=yes
8511                fi
8512            fi
8513            ;;
8514        *)
8515            gccvisbroken=no
8516            ;;
8517        esac
8518    fi
8519    rm -f visibility.s visibility.cxx
8520
8521    AC_MSG_RESULT([$gccvisbroken])
8522    if test "$gccvisbroken" = "yes"; then
8523        AC_MSG_ERROR([Your gcc is not -fvisibility=hidden safe. This is no longer supported.])
8524    fi
8525
8526    CPPFLAGS="$save_CPPFLAGS"
8527
8528    AC_MSG_CHECKING([if CET endbranch is recognized])
8529cat > endbr.s <<_ACEOF
8530endbr32
8531_ACEOF
8532    HAVE_ASM_END_BRANCH_INS_SUPPORT=
8533    if $CXX -c endbr.s -o endbr.o >/dev/null 2>&5; then
8534        AC_MSG_RESULT([yes])
8535        HAVE_ASM_END_BRANCH_INS_SUPPORT=TRUE
8536    else
8537        AC_MSG_RESULT([no])
8538    fi
8539    rm -f endbr.s endbr.o
8540    AC_SUBST(HAVE_ASM_END_BRANCH_INS_SUPPORT)
8541
8542    AC_LANG_POP([C++])
8543fi
8544
8545dnl ===================================================================
8546dnl  Clang++ tests
8547dnl ===================================================================
8548
8549HAVE_GCC_FNO_ENFORCE_EH_SPECS=
8550if test "$GCC" = "yes"; then
8551    AC_MSG_CHECKING([whether $CXX_BASE supports -fno-enforce-eh-specs])
8552    AC_LANG_PUSH([C++])
8553    save_CXXFLAGS=$CXXFLAGS
8554    CXXFLAGS="$CFLAGS -Werror -fno-enforce-eh-specs"
8555    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_FNO_ENFORCE_EH_SPECS=TRUE ],[])
8556    CXXFLAGS=$save_CXXFLAGS
8557    AC_LANG_POP([C++])
8558    if test "$HAVE_GCC_FNO_ENFORCE_EH_SPECS" = "TRUE"; then
8559        AC_MSG_RESULT([yes])
8560    else
8561        AC_MSG_RESULT([no])
8562    fi
8563fi
8564AC_SUBST(HAVE_GCC_FNO_ENFORCE_EH_SPECS)
8565
8566dnl ===================================================================
8567dnl Compiler plugins
8568dnl ===================================================================
8569
8570COMPILER_PLUGINS=
8571# currently only Clang
8572
8573if test "$COM_IS_CLANG" != "TRUE"; then
8574    if test "$libo_fuzzed_enable_compiler_plugins" = yes -a "$enable_compiler_plugins" = yes; then
8575        AC_MSG_NOTICE([Resetting --enable-compiler-plugins=no])
8576        enable_compiler_plugins=no
8577    fi
8578fi
8579
8580COMPILER_PLUGINS_COM_IS_CLANG=
8581if test "$COM_IS_CLANG" = "TRUE"; then
8582    if test -n "$enable_compiler_plugins"; then
8583        compiler_plugins="$enable_compiler_plugins"
8584    elif test -n "$ENABLE_DBGUTIL"; then
8585        compiler_plugins=test
8586    else
8587        compiler_plugins=no
8588    fi
8589    if test "$compiler_plugins" != no -a "$my_apple_clang" != yes; then
8590        if test "$CLANGVER" -lt 120001; then
8591            if test "$compiler_plugins" = yes; then
8592                AC_MSG_ERROR(
8593                    [Clang $CLANGVER is too old to build compiler plugins; need >= 12.0.1.])
8594            else
8595                compiler_plugins=no
8596            fi
8597        fi
8598    fi
8599    if test "$compiler_plugins" != "no"; then
8600        dnl The prefix where Clang resides, override to where Clang resides if
8601        dnl using a source build:
8602        if test -z "$CLANGDIR"; then
8603            CLANGDIR=$(dirname $(dirname $($CXX -print-prog-name=$(basename $(printf '%s\n' $CXX | grep clang | head -n 1)))))
8604        fi
8605        # Assume Clang is self-built, but allow overriding COMPILER_PLUGINS_CXX to the compiler Clang was built with.
8606        if test -z "$COMPILER_PLUGINS_CXX"; then
8607            COMPILER_PLUGINS_CXX=[$(echo $CXX | sed -e 's/-fsanitize=[^ ]*//g')]
8608        fi
8609        clangbindir=$CLANGDIR/bin
8610        if test "$build_os" = "cygwin"; then
8611            clangbindir=$(cygpath -u "$clangbindir")
8612        fi
8613        AC_PATH_PROG(LLVM_CONFIG, llvm-config,[],"$clangbindir" $PATH)
8614        if test -n "$LLVM_CONFIG"; then
8615            COMPILER_PLUGINS_CXXFLAGS=$($LLVM_CONFIG --cxxflags)
8616            COMPILER_PLUGINS_LINKFLAGS=$($LLVM_CONFIG --ldflags --libs --system-libs | tr '\n' ' ')
8617            if test -z "$CLANGLIBDIR"; then
8618                CLANGLIBDIR=$($LLVM_CONFIG --libdir)
8619            fi
8620            # Try if clang is built from source (in which case its includes are not together with llvm includes).
8621            # src-root is [llvm-toplevel-src-dir]/llvm, clang is [llvm-toplevel-src-dir]/clang
8622            if $LLVM_CONFIG --src-root >/dev/null 2>&1; then
8623                clangsrcdir=$(dirname $($LLVM_CONFIG --src-root))
8624                if test -n "$clangsrcdir" -a -d "$clangsrcdir" -a -d "$clangsrcdir/clang/include"; then
8625                    COMPILER_PLUGINS_CXXFLAGS="$COMPILER_PLUGINS_CXXFLAGS -I$clangsrcdir/clang/include"
8626                fi
8627            fi
8628            # obj-root is [llvm-toplevel-obj-dir]/, clang is [llvm-toplevel-obj-dir]/tools/clang
8629            clangobjdir=$($LLVM_CONFIG --obj-root)
8630            if test -n "$clangobjdir" -a -d "$clangobjdir" -a -d "$clangobjdir/tools/clang/include"; then
8631                COMPILER_PLUGINS_CXXFLAGS="$COMPILER_PLUGINS_CXXFLAGS -I$clangobjdir/tools/clang/include"
8632            fi
8633        fi
8634        AC_MSG_NOTICE([compiler plugins compile flags: $COMPILER_PLUGINS_CXXFLAGS])
8635        AC_LANG_PUSH([C++])
8636        save_CXX=$CXX
8637        save_CXXCPP=$CXXCPP
8638        save_CPPFLAGS=$CPPFLAGS
8639        save_CXXFLAGS=$CXXFLAGS
8640        save_LDFLAGS=$LDFLAGS
8641        save_LIBS=$LIBS
8642        CXX=$COMPILER_PLUGINS_CXX
8643        CXXCPP="$COMPILER_PLUGINS_CXX -E"
8644        CPPFLAGS="$COMPILER_PLUGINS_CXXFLAGS"
8645        CXXFLAGS="$COMPILER_PLUGINS_CXXFLAGS"
8646        AC_CHECK_HEADER(clang/Basic/SourceLocation.h,
8647            [COMPILER_PLUGINS=TRUE],
8648            [
8649            if test "$compiler_plugins" = "yes"; then
8650                AC_MSG_ERROR([Cannot find Clang headers to build compiler plugins.])
8651            else
8652                AC_MSG_WARN([Cannot find Clang headers to build compiler plugins, plugins disabled])
8653                add_warning "Cannot find Clang headers to build compiler plugins, plugins disabled."
8654            fi
8655            ])
8656        dnl TODO: Windows doesn't use LO_CLANG_SHARED_PLUGINS for now, see corresponding TODO
8657        dnl comment in compilerplugins/Makefile-clang.mk:
8658        if test -n "$COMPILER_PLUGINS" && test "$_os" != "WINNT"; then
8659            LDFLAGS=""
8660            AC_MSG_CHECKING([for clang libraries to use])
8661            if test -z "$CLANGTOOLLIBS"; then
8662                LIBS="-lclang-cpp $COMPILER_PLUGINS_LINKFLAGS"
8663                AC_LINK_IFELSE([
8664                    AC_LANG_PROGRAM([[#include "clang/Basic/SourceLocation.h"]],
8665                        [[ clang::FullSourceLoc().dump(); ]])
8666                ],[CLANGTOOLLIBS="$LIBS"],[])
8667            fi
8668            dnl If the above check for the combined -lclang-cpp failed, fall back to a hand-curated
8669            dnl list of individual -lclang* (but note that that list can become outdated over time,
8670            dnl see e.g. the since-reverted 5078591de9a0e65ca560a4f1913e90dfe95f66bf "CLANGTOOLLIBS
8671            dnl needs to include -lclangSupport now"):
8672            if test -z "$CLANGTOOLLIBS"; then
8673                LIBS="-lclangTooling -lclangFrontend -lclangDriver -lclangParse -lclangSema -lclangEdit \
8674 -lclangAnalysis -lclangAST -lclangLex -lclangSerialization -lclangBasic $COMPILER_PLUGINS_LINKFLAGS"
8675                AC_LINK_IFELSE([
8676                    AC_LANG_PROGRAM([[#include "clang/Basic/SourceLocation.h"]],
8677                        [[ clang::FullSourceLoc().dump(); ]])
8678                ],[CLANGTOOLLIBS="$LIBS"],[])
8679            fi
8680            AC_MSG_RESULT([$CLANGTOOLLIBS])
8681            if test -z "$CLANGTOOLLIBS"; then
8682                if test "$compiler_plugins" = "yes"; then
8683                    AC_MSG_ERROR([Cannot find Clang libraries to build compiler plugins.])
8684                else
8685                    AC_MSG_WARN([Cannot find Clang libraries to build compiler plugins, plugins disabled])
8686                    add_warning "Cannot find Clang libraries to build compiler plugins, plugins disabled."
8687                fi
8688                COMPILER_PLUGINS=
8689            fi
8690            if test -n "$COMPILER_PLUGINS"; then
8691                if test -z "$CLANGSYSINCLUDE"; then
8692                    if test -n "$LLVM_CONFIG"; then
8693                        # Path to the clang system headers (no idea if there's a better way to get it).
8694                        CLANGSYSINCLUDE=$($LLVM_CONFIG --libdir)/clang/$($LLVM_CONFIG --version | sed 's/git\|svn//')/include
8695                    fi
8696                fi
8697            fi
8698        fi
8699        CXX=$save_CXX
8700        CXXCPP=$save_CXXCPP
8701        CPPFLAGS=$save_CPPFLAGS
8702        CXXFLAGS=$save_CXXFLAGS
8703        LDFLAGS=$save_LDFLAGS
8704        LIBS="$save_LIBS"
8705        AC_LANG_POP([C++])
8706
8707        AC_MSG_CHECKING([whether the compiler for building compilerplugins is actually Clang])
8708        AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
8709            #ifndef __clang__
8710            you lose
8711            #endif
8712            int foo=42;
8713            ]])],
8714            [AC_MSG_RESULT([yes])
8715             COMPILER_PLUGINS_COM_IS_CLANG=TRUE],
8716            [AC_MSG_RESULT([no])])
8717        AC_SUBST(COMPILER_PLUGINS_COM_IS_CLANG)
8718    fi
8719else
8720    if test "$enable_compiler_plugins" = "yes"; then
8721        AC_MSG_ERROR([Compiler plugins are currently supported only with the Clang compiler.])
8722    fi
8723fi
8724COMPILER_PLUGINS_ANALYZER_PCH=
8725if test "$enable_compiler_plugins_analyzer_pch" != no; then
8726    COMPILER_PLUGINS_ANALYZER_PCH=TRUE
8727fi
8728AC_SUBST(COMPILER_PLUGINS)
8729AC_SUBST(COMPILER_PLUGINS_ANALYZER_PCH)
8730AC_SUBST(COMPILER_PLUGINS_COM_IS_CLANG)
8731AC_SUBST(COMPILER_PLUGINS_CXX)
8732AC_SUBST(COMPILER_PLUGINS_CXXFLAGS)
8733AC_SUBST(COMPILER_PLUGINS_CXX_LINKFLAGS)
8734AC_SUBST(COMPILER_PLUGINS_DEBUG)
8735AC_SUBST(COMPILER_PLUGINS_TOOLING_ARGS)
8736AC_SUBST(CLANGDIR)
8737AC_SUBST(CLANGLIBDIR)
8738AC_SUBST(CLANGTOOLLIBS)
8739AC_SUBST(CLANGSYSINCLUDE)
8740
8741# Plugin to help linker.
8742# Add something like LD_PLUGIN=/usr/lib64/LLVMgold.so to your autogen.input.
8743# This makes --enable-lto build with clang work.
8744AC_SUBST(LD_PLUGIN)
8745
8746AC_CHECK_FUNCS(posix_fallocate, HAVE_POSIX_FALLOCATE=YES, [HAVE_POSIX_FALLOCATE=NO])
8747AC_SUBST(HAVE_POSIX_FALLOCATE)
8748
8749JITC_PROCESSOR_TYPE=""
8750if test "$_os" = "Linux" -a "$host_cpu" = "powerpc"; then
8751    # IBMs JDK needs this...
8752    JITC_PROCESSOR_TYPE=6
8753    export JITC_PROCESSOR_TYPE
8754fi
8755AC_SUBST([JITC_PROCESSOR_TYPE])
8756
8757# Misc Windows Stuff
8758AC_ARG_WITH(ucrt-dir,
8759    AS_HELP_STRING([--with-ucrt-dir],
8760        [path to the directory with the arch-specific MSU packages of the Windows Universal CRT redistributables
8761        (MS KB 2999226) for packaging into the installsets (without those the target system needs to install
8762        the UCRT or Visual C++ Runtimes manually). The directory must contain the following 6 files:
8763            Windows6.1-KB2999226-x64.msu
8764            Windows6.1-KB2999226-x86.msu
8765            Windows8.1-KB2999226-x64.msu
8766            Windows8.1-KB2999226-x86.msu
8767            Windows8-RT-KB2999226-x64.msu
8768            Windows8-RT-KB2999226-x86.msu
8769        A zip archive including those files is available from Microsoft site:
8770        https://www.microsoft.com/en-us/download/details.aspx?id=48234]),
8771,)
8772
8773UCRT_REDISTDIR="$with_ucrt_dir"
8774if test $_os = "WINNT"; then
8775    find_msvc_x64_dlls
8776    MSVC_DLL_PATH=`win_short_path_for_make "$msvcdllpath"`
8777    MSVC_DLLS="$msvcdlls"
8778    if echo "$msvcdllpath" | grep -q "VC143.CRT$"; then
8779        with_redist=143
8780    elif echo "$msvcdllpath" | grep -q "VC142.CRT$"; then
8781        with_redist=142
8782    elif echo "$msvcdllpath" | grep -q "VC141.CRT$"; then
8783        with_redist=141
8784    fi
8785    for i in $PKGFORMAT; do
8786        if test "$i" = msi; then
8787            find_msms "$with_redist"
8788            if test -n "$msmdir"; then
8789                MSM_PATH=`win_short_path_for_make "$msmdir"`
8790                SCPDEFS="$SCPDEFS -DWITH_VC_REDIST=$with_redist"
8791            fi
8792            break
8793        fi
8794    done
8795
8796    if test "$UCRT_REDISTDIR" = "no"; then
8797        dnl explicitly disabled
8798        UCRT_REDISTDIR=""
8799    else
8800        PathFormat "$UCRT_REDISTDIR"
8801        UCRT_REDISTDIR="$formatted_path"
8802        UCRT_REDISTDIR_unix="$formatted_path_unix"
8803        if ! test -f "$UCRT_REDISTDIR_unix/Windows6.1-KB2999226-x64.msu" -a \
8804                  -f "$UCRT_REDISTDIR_unix/Windows6.1-KB2999226-x86.msu" -a \
8805                  -f "$UCRT_REDISTDIR_unix/Windows8.1-KB2999226-x64.msu" -a \
8806                  -f "$UCRT_REDISTDIR_unix/Windows8.1-KB2999226-x86.msu" -a \
8807                  -f "$UCRT_REDISTDIR_unix/Windows8-RT-KB2999226-x64.msu" -a \
8808                  -f "$UCRT_REDISTDIR_unix/Windows8-RT-KB2999226-x86.msu"; then
8809            UCRT_REDISTDIR=""
8810            if test -n "$PKGFORMAT"; then
8811               for i in $PKGFORMAT; do
8812                   case "$i" in
8813                   msi)
8814                       AC_MSG_WARN([--without-ucrt-dir not specified or MSUs not found - installer will have runtime dependency])
8815                       add_warning "--without-ucrt-dir not specified or MSUs not found - installer will have runtime dependency"
8816                       ;;
8817                   esac
8818               done
8819            fi
8820        fi
8821    fi
8822fi
8823
8824AC_SUBST(UCRT_REDISTDIR)
8825AC_SUBST(MSVC_DLL_PATH)
8826AC_SUBST(MSVC_DLLS)
8827AC_SUBST(MSM_PATH)
8828
8829
8830dnl ===================================================================
8831dnl Checks for Java
8832dnl ===================================================================
8833if test "$ENABLE_JAVA" != ""; then
8834
8835    # Windows-specific tests
8836    if test "$build_os" = "cygwin" -o -n "$WSL_ONLY_AS_HELPER"; then
8837        if test -z "$with_jdk_home"; then
8838            dnl See <https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-EEED398E-AE37-4D12-
8839            dnl AB10-49F82F720027> section "Windows Registry Key Changes":
8840            reg_get_value "$WIN_HOST_BITS" "HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/JDK" "CurrentVersion"
8841            if test -n "$regvalue"; then
8842                ver=$regvalue
8843                reg_get_value "$WIN_HOST_BITS" "HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/JDK/$ver" "JavaHome"
8844                with_jdk_home=$regvalue
8845            fi
8846            howfound="found automatically"
8847        else
8848            howfound="you passed"
8849        fi
8850        PathFormat "$with_jdk_home"
8851        with_jdk_home="$formatted_path_unix"
8852
8853        if ! test -f "$with_jdk_home/lib/jvm.lib" -a -f "$with_jdk_home/bin/java.exe"; then
8854            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])
8855        fi
8856        with_java="java.exe"
8857        javacompiler="javac.exe"
8858        javadoc="javadoc.exe"
8859    fi
8860
8861    # 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.
8862    # /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java, but /usr does not contain the JDK libraries
8863    if test -z "$with_jdk_home" -a "$_os" = "Darwin" -a -x /usr/libexec/java_home; then
8864        with_jdk_home=`/usr/libexec/java_home`
8865    fi
8866
8867    JAVA_HOME=; export JAVA_HOME
8868    if test -z "$with_jdk_home"; then
8869        AC_PATH_PROG(JAVAINTERPRETER, $with_java)
8870    else
8871        _java_path="$with_jdk_home/bin/$with_java"
8872        dnl Check if there is a Java interpreter at all.
8873        if test -x "$_java_path"; then
8874            JAVAINTERPRETER=$_java_path
8875        else
8876            AC_MSG_ERROR([$_java_path not found, pass --with-jdk-home])
8877        fi
8878    fi
8879
8880    dnl Check that the JDK found is correct architecture (at least 2 reasons to
8881    dnl check: officebean needs to link -ljawt, and libjpipe.so needs to be
8882    dnl loaded by java to run JunitTests:
8883    if test "$build_os" = "cygwin" -a "$cross_compiling" != "yes"; then
8884        shortjdkhome=`cygpath -d "$with_jdk_home"`
8885        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
8886            AC_MSG_WARN([You are building 64-bit binaries but the JDK $howfound is 32-bit])
8887            AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a 64-bit JDK])
8888        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
8889            AC_MSG_WARN([You are building 32-bit binaries but the JDK $howfound is 64-bit])
8890            AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a (32-bit) JDK])
8891        fi
8892
8893        if test x`echo "$JAVAINTERPRETER" | $GREP -i '\.exe$'` = x; then
8894            JAVAINTERPRETER="${JAVAINTERPRETER}.exe"
8895        fi
8896        JAVAINTERPRETER=`win_short_path_for_make "$JAVAINTERPRETER"`
8897    elif test "$cross_compiling" != "yes"; then
8898        case $CPUNAME in
8899            AARCH64|AXP|X86_64|IA64|POWERPC64|S390X|SPARC64|MIPS64|RISCV64|LOONGARCH64)
8900                if test -f "$JAVAINTERPRETER" -a "`$JAVAINTERPRETER -version 2>&1 | $GREP -i 64-bit`" = "" >/dev/null; then
8901                    AC_MSG_WARN([You are building 64-bit binaries but the JDK $JAVAINTERPRETER is 32-bit])
8902                    AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a 64-bit JDK])
8903                fi
8904                ;;
8905            *) # assumption: everything else 32-bit
8906                if test -f "$JAVAINTERPRETER" -a "`$JAVAINTERPRETER -version 2>&1 | $GREP -i 64-bit`" != ""  >/dev/null; then
8907                    AC_MSG_WARN([You are building 32-bit binaries but the JDK $howfound is 64-bit])
8908                    AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a (32-bit) JDK])
8909                fi
8910                ;;
8911        esac
8912    fi
8913fi
8914
8915dnl ===================================================================
8916dnl Checks for JDK.
8917dnl ===================================================================
8918
8919# Whether all the complexity here actually is needed any more or not, no idea.
8920
8921JDK_SECURITYMANAGER_DISALLOWED=
8922MODULAR_JAVA=
8923if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then
8924    _gij_longver=0
8925    AC_MSG_CHECKING([the installed JDK])
8926    if test -n "$JAVAINTERPRETER"; then
8927        dnl java -version sends output to stderr!
8928        if test `$JAVAINTERPRETER -version 2>&1 | $GREP -c "Kaffe"` -gt 0; then
8929            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
8930        elif test `$JAVAINTERPRETER --version 2>&1 | $GREP -c "GNU libgcj"` -gt 0; then
8931            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
8932        elif test `$JAVAINTERPRETER -version 2>&1 | $AWK '{ print }' | $GREP -c "BEA"` -gt 0; then
8933            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
8934        elif test `$JAVAINTERPRETER -version 2>&1 | $AWK '{ print }' | $GREP -c "IBM"` -gt 0; then
8935            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.ac])
8936        else
8937            JDK=sun
8938
8939            dnl Sun JDK specific tests
8940            _jdk=`$JAVAINTERPRETER -version 2>&1 | $AWK -F'"' '{ print \$2 }' | $SED '/^$/d' | $SED s/[[-A-Za-z]]*//`
8941            _jdk_ver=`echo "$_jdk" | $AWK -F. '{ print (($1 * 100) + $2) * 100 + $3;}'`
8942
8943            if test "$_jdk_ver" -lt 10800; then
8944                AC_MSG_ERROR([JDK is too old, you need at least 8 ($_jdk_ver < 10800)])
8945            fi
8946            dnl TODO: Presumably, the Security Manager will not merely be disallowed, but be
8947            dnl completely removed in some Java version > 18 (see
8948            dnl <https://openjdk.java.net/jeps/411> "Deprecate the Security Manager for Removal"):
8949            if test "$_jdk_ver" -ge 180000; then
8950                JDK_SECURITYMANAGER_DISALLOWED=TRUE
8951            fi
8952
8953            JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*java,,p"`
8954            if test "$_os" = "WINNT"; then
8955                JAVA_HOME=`echo $JAVA_HOME | $SED "s,\.[[eE]][[xX]][[eE]]$,,"`
8956            fi
8957            AC_MSG_RESULT([found $JAVA_HOME (JDK $_jdk)])
8958
8959            dnl Check whether the build Java supports modules
8960            if test "$_jdk_ver" -ge 90000; then
8961                MODULAR_JAVA=TRUE
8962            else
8963                AC_MSG_WARN([Modular jars will not be built. They need at least Java 9 ($_jdk_ver < 90000)])
8964                add_warning "Modular jars will not be built. They need at least Java 9 ($_jdk_ver < 90000)"
8965            fi
8966
8967            # set to limit VM usage for JunitTests
8968            JAVAIFLAGS=-Xmx64M
8969            # set to limit VM usage for javac
8970            JAVACFLAGS=-J-Xmx128M
8971        fi
8972    else
8973        AC_MSG_ERROR([Java not found. You need at least JDK 8])
8974    fi
8975else
8976    if test -z "$ENABLE_JAVA"; then
8977        dnl Java disabled
8978        JAVA_HOME=
8979        export JAVA_HOME
8980    elif test "$cross_compiling" = "yes"; then
8981        # Just assume compatibility of build and host JDK
8982        JDK=$JDK_FOR_BUILD
8983        JAVAIFLAGS=$JAVAIFLAGS_FOR_BUILD
8984    fi
8985fi
8986
8987dnl ===================================================================
8988dnl Checks for javac
8989dnl ===================================================================
8990if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then
8991    : ${JAVA_SOURCE_VER=8}
8992    : ${JAVA_TARGET_VER=8}
8993    if test -z "$with_jdk_home"; then
8994        AC_PATH_PROG(JAVACOMPILER, $javacompiler)
8995    else
8996        _javac_path="$with_jdk_home/bin/$javacompiler"
8997        dnl Check if there is a Java compiler at all.
8998        if test -x "$_javac_path"; then
8999            JAVACOMPILER=$_javac_path
9000        fi
9001    fi
9002    if test -z "$JAVACOMPILER"; then
9003        AC_MSG_ERROR([$javacompiler not found set with_jdk_home])
9004    fi
9005    if test "$build_os" = "cygwin"; then
9006        if test x`echo "$JAVACOMPILER" | $GREP -i '\.exe$'` = x; then
9007            JAVACOMPILER="${JAVACOMPILER}.exe"
9008        fi
9009        JAVACOMPILER=`win_short_path_for_make "$JAVACOMPILER"`
9010    fi
9011fi
9012
9013dnl ===================================================================
9014dnl Checks for javadoc
9015dnl ===================================================================
9016if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then
9017    if test -z "$with_jdk_home"; then
9018        AC_PATH_PROG(JAVADOC, $javadoc)
9019    else
9020        _javadoc_path="$with_jdk_home/bin/$javadoc"
9021        dnl Check if there is a javadoc at all.
9022        if test -x "$_javadoc_path"; then
9023            JAVADOC=$_javadoc_path
9024        else
9025            AC_PATH_PROG(JAVADOC, $javadoc)
9026        fi
9027    fi
9028    if test -z "$JAVADOC"; then
9029        AC_MSG_ERROR([$_javadoc_path not found set with_jdk_home])
9030    fi
9031    if test "$build_os" = "cygwin"; then
9032        if test x`echo "$JAVADOC" | $GREP -i '\.exe$'` = x; then
9033            JAVADOC="${JAVADOC}.exe"
9034        fi
9035        JAVADOC=`win_short_path_for_make "$JAVADOC"`
9036    fi
9037
9038    if test `$JAVADOC --version 2>&1 | $GREP -c "gjdoc"` -gt 0; then
9039    JAVADOCISGJDOC="yes"
9040    fi
9041fi
9042AC_SUBST(JAVADOC)
9043AC_SUBST(JAVADOCISGJDOC)
9044
9045if test "$ENABLE_JAVA" != "" -a \( "$cross_compiling" != "yes" -o -n "$with_jdk_home" \); then
9046    # check if JAVA_HOME was (maybe incorrectly?) set automatically to /usr
9047    if test "$JAVA_HOME" = "/usr" -a "x$with_jdk_home" = "x"; then
9048        if basename $(readlink $(readlink $JAVACOMPILER)) >/dev/null 2>/dev/null; then
9049           # try to recover first by looking whether we have an alternative
9050           # system as in Debian or newer SuSEs where following /usr/bin/javac
9051           # over /etc/alternatives/javac leads to the right bindir where we
9052           # just need to strip a bit away to get a valid JAVA_HOME
9053           JAVA_HOME=$(readlink $(readlink $JAVACOMPILER))
9054        elif readlink $JAVACOMPILER >/dev/null 2>/dev/null; then
9055            # maybe only one level of symlink (e.g. on Mac)
9056            JAVA_HOME=$(readlink $JAVACOMPILER)
9057            if test "$(dirname $JAVA_HOME)" = "."; then
9058                # we've got no path to trim back
9059                JAVA_HOME=""
9060            fi
9061        else
9062            # else warn
9063            AC_MSG_WARN([JAVA_HOME is set to /usr - this is very likely to be incorrect])
9064            AC_MSG_WARN([if this is the case, please inform the correct JAVA_HOME with --with-jdk-home])
9065            add_warning "JAVA_HOME is set to /usr - this is very likely to be incorrect"
9066            add_warning "if this is the case, please inform the correct JAVA_HOME with --with-jdk-home"
9067        fi
9068        dnl now that we probably have the path to the real javac, make a JAVA_HOME out of it...
9069        if test "$JAVA_HOME" != "/usr"; then
9070            if test "$_os" = "Darwin" -o "$OS_FOR_BUILD" = MACOSX; then
9071                dnl Leopard returns a non-suitable path with readlink - points to "Current" only
9072                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/Current/Commands/javac$,/CurrentJDK/Home,)
9073                dnl Tiger already returns a JDK path...
9074                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/CurrentJDK/Commands/javac$,/CurrentJDK/Home,)
9075            else
9076                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/bin/javac$,,)
9077                dnl check that we have a directory as certain distros eg gentoo substitute javac for a script
9078                dnl that checks which version to run
9079                if test -f "$JAVA_HOME"; then
9080                    JAVA_HOME=""; # set JAVA_HOME to null if it's a file
9081                fi
9082            fi
9083        fi
9084    fi
9085    # as we drop out of this, JAVA_HOME may have been set to the empty string by readlink
9086
9087    dnl now if JAVA_HOME has been set to empty, then call findhome to find it
9088    if test -z "$JAVA_HOME"; then
9089        if test "x$with_jdk_home" = "x"; then
9090            cat > findhome.java <<_ACEOF
9091[import java.io.File;
9092
9093class findhome
9094{
9095    public static void main(String args[])
9096    {
9097        String jrelocation = System.getProperty("java.home");
9098        File jre = new File(jrelocation);
9099        System.out.println(jre.getParent());
9100    }
9101}]
9102_ACEOF
9103            AC_MSG_CHECKING([if javac works])
9104            javac_cmd="$JAVACOMPILER findhome.java 1>&2"
9105            AC_TRY_EVAL(javac_cmd)
9106            if test $? = 0 -a -f ./findhome.class; then
9107                AC_MSG_RESULT([javac works])
9108            else
9109                echo "configure: javac test failed" >&5
9110                cat findhome.java >&5
9111                AC_MSG_ERROR([javac does not work - java projects will not build!])
9112            fi
9113            AC_MSG_CHECKING([if gij knows its java.home])
9114            JAVA_HOME=`$JAVAINTERPRETER findhome`
9115            if test $? = 0 -a "$JAVA_HOME" != ""; then
9116                AC_MSG_RESULT([$JAVA_HOME])
9117            else
9118                echo "configure: java test failed" >&5
9119                cat findhome.java >&5
9120                AC_MSG_ERROR([gij does not know its java.home - use --with-jdk-home])
9121            fi
9122            # clean-up after ourselves
9123            rm -f ./findhome.java ./findhome.class
9124        else
9125            JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*$with_java,,p"`
9126        fi
9127    fi
9128
9129    # now check if $JAVA_HOME is really valid
9130    if test "$_os" = "Darwin" -o "$OS_FOR_BUILD" = MACOSX; then
9131        if test ! -f "$JAVA_HOME/lib/jvm.cfg" -a "x$with_jdk_home" = "x"; then
9132            AC_MSG_WARN([JAVA_HOME was not explicitly informed with --with-jdk-home. the configure script])
9133            AC_MSG_WARN([attempted to find JAVA_HOME automatically, but apparently it failed])
9134            AC_MSG_WARN([in case JAVA_HOME is incorrectly set, some projects will not be built correctly])
9135            add_warning "JAVA_HOME was not explicitly informed with --with-jdk-home. the configure script"
9136            add_warning "attempted to find JAVA_HOME automatically, but apparently it failed"
9137            add_warning "in case JAVA_HOME is incorrectly set, some projects will not be built correctly"
9138        fi
9139    fi
9140    PathFormat "$JAVA_HOME"
9141    JAVA_HOME="$formatted_path_unix"
9142fi
9143
9144if test -z "$JAWTLIB" -a -n "$ENABLE_JAVA" -a "$_os" != Android -a \
9145    "$_os" != Darwin
9146then
9147    AC_MSG_CHECKING([for JAWT lib])
9148    if test "$_os" = WINNT; then
9149        # The path to $JAVA_HOME/lib/$JAWTLIB is part of $ILIB:
9150        JAWTLIB=jawt.lib
9151    else
9152        case "$host_cpu" in
9153        arm*)
9154            AS_IF([test -e "$JAVA_HOME/jre/lib/aarch32/libjawt.so"], [my_java_arch=aarch32], [my_java_arch=arm])
9155            JAVA_ARCH=$my_java_arch
9156            ;;
9157        i*86)
9158            my_java_arch=i386
9159            ;;
9160        m68k)
9161            my_java_arch=m68k
9162            ;;
9163        powerpc)
9164            my_java_arch=ppc
9165            ;;
9166        powerpc64)
9167            my_java_arch=ppc64
9168            ;;
9169        powerpc64le)
9170            AS_IF([test -e "$JAVA_HOME/jre/lib/ppc64le/libjawt.so"], [my_java_arch=ppc64le], [my_java_arch=ppc64])
9171            JAVA_ARCH=$my_java_arch
9172            ;;
9173        sparc64)
9174            my_java_arch=sparcv9
9175            ;;
9176        x86_64)
9177            my_java_arch=amd64
9178            ;;
9179        *)
9180            my_java_arch=$host_cpu
9181            ;;
9182        esac
9183        # This is where JDK9 puts the library
9184        if test -e "$JAVA_HOME/lib/libjawt.so"; then
9185            JAWTLIB="-L$JAVA_HOME/lib/ -ljawt"
9186        else
9187            JAWTLIB="-L$JAVA_HOME/jre/lib/$my_java_arch -ljawt"
9188        fi
9189        AS_IF([test "$JAVA_ARCH" != ""], [AC_DEFINE_UNQUOTED([JAVA_ARCH], ["$JAVA_ARCH"])])
9190    fi
9191    AC_MSG_RESULT([$JAWTLIB])
9192fi
9193AC_SUBST(JAWTLIB)
9194
9195if test -n "$ENABLE_JAVA" -a -z "$JAVAINC"; then
9196    case "$host_os" in
9197
9198    cygwin*|wsl*)
9199        JAVAINC="-I$JAVA_HOME/include/win32"
9200        JAVAINC="$JAVAINC -I$JAVA_HOME/include"
9201        ;;
9202
9203    darwin*)
9204        if test -d "$JAVA_HOME/include/darwin"; then
9205            JAVAINC="-I$JAVA_HOME/include  -I$JAVA_HOME/include/darwin"
9206        else
9207            JAVAINC=${ISYSTEM}$FRAMEWORKSHOME/JavaVM.framework/Versions/Current/Headers
9208        fi
9209        ;;
9210
9211    dragonfly*)
9212        JAVAINC="-I$JAVA_HOME/include"
9213        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
9214        ;;
9215
9216    freebsd*)
9217        JAVAINC="-I$JAVA_HOME/include"
9218        JAVAINC="$JAVAINC -I$JAVA_HOME/include/freebsd"
9219        JAVAINC="$JAVAINC -I$JAVA_HOME/include/bsd"
9220        JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux"
9221        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
9222        ;;
9223
9224    k*bsd*-gnu*)
9225        JAVAINC="-I$JAVA_HOME/include"
9226        JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux"
9227        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
9228        ;;
9229
9230    linux-gnu*)
9231        JAVAINC="-I$JAVA_HOME/include"
9232        JAVAINC="$JAVAINC -I$JAVA_HOME/include/linux"
9233        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
9234        ;;
9235
9236    *netbsd*)
9237        JAVAINC="-I$JAVA_HOME/include"
9238        JAVAINC="$JAVAINC -I$JAVA_HOME/include/netbsd"
9239        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
9240       ;;
9241
9242    openbsd*)
9243        JAVAINC="-I$JAVA_HOME/include"
9244        JAVAINC="$JAVAINC -I$JAVA_HOME/include/openbsd"
9245        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
9246        ;;
9247
9248    solaris*)
9249        JAVAINC="-I$JAVA_HOME/include"
9250        JAVAINC="$JAVAINC -I$JAVA_HOME/include/solaris"
9251        test -d "$JAVA_HOME/include/native_thread" && JAVAINC="$JAVAINC -I$JAVA_HOME/include/native_thread"
9252        ;;
9253    esac
9254fi
9255SOLARINC="$SOLARINC $JAVAINC"
9256
9257if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then
9258    JAVA_HOME_FOR_BUILD=$JAVA_HOME
9259    JAVAIFLAGS_FOR_BUILD=$JAVAIFLAGS
9260    JDK_FOR_BUILD=$JDK
9261    JDK_SECURITYMANAGER_DISALLOWED_FOR_BUILD=$JDK_SECURITYMANAGER_DISALLOWED
9262fi
9263
9264AC_SUBST(JAVACFLAGS)
9265AC_SUBST(JAVACOMPILER)
9266AC_SUBST(JAVAINTERPRETER)
9267AC_SUBST(JAVAIFLAGS)
9268AC_SUBST(JAVAIFLAGS_FOR_BUILD)
9269AC_SUBST(JAVA_HOME)
9270AC_SUBST(JAVA_HOME_FOR_BUILD)
9271AC_SUBST(JDK)
9272AC_SUBST(JDK_FOR_BUILD)
9273AC_SUBST(JDK_SECURITYMANAGER_DISALLOWED_FOR_BUILD)
9274AC_SUBST(JAVA_SOURCE_VER)
9275AC_SUBST(JAVA_TARGET_VER)
9276AC_SUBST(MODULAR_JAVA)
9277
9278
9279dnl ===================================================================
9280dnl Export file validation
9281dnl ===================================================================
9282AC_MSG_CHECKING([whether to enable export file validation])
9283if test "$with_export_validation" != "no"; then
9284    if test -z "$ENABLE_JAVA"; then
9285        if test "$with_export_validation" = "yes"; then
9286            AC_MSG_ERROR([requested, but Java is disabled])
9287        else
9288            AC_MSG_RESULT([no, as Java is disabled])
9289        fi
9290    elif ! test -d "${SRC_ROOT}/schema"; then
9291        if test "$with_export_validation" = "yes"; then
9292            AC_MSG_ERROR([requested, but schema directory is missing (it is excluded from tarballs)])
9293        else
9294            AC_MSG_RESULT([no, schema directory is missing (it is excluded from tarballs)])
9295        fi
9296    else
9297        AC_MSG_RESULT([yes])
9298        AC_DEFINE(HAVE_EXPORT_VALIDATION)
9299
9300        AC_PATH_PROGS(ODFVALIDATOR, odfvalidator)
9301        if test -z "$ODFVALIDATOR"; then
9302            # remember to download the ODF toolkit with validator later
9303            AC_MSG_NOTICE([no odfvalidator found, will download it])
9304            BUILD_TYPE="$BUILD_TYPE ODFVALIDATOR"
9305            ODFVALIDATOR="$BUILDDIR/bin/odfvalidator.sh"
9306
9307            # and fetch name of odfvalidator jar name from download.lst
9308            ODFVALIDATOR_JAR=`$SED -n -e "s/^ODFVALIDATOR_JAR *:= *\(.*\) */\1/p" $SRC_ROOT/download.lst`
9309            AC_SUBST(ODFVALIDATOR_JAR)
9310
9311            if test -z "$ODFVALIDATOR_JAR"; then
9312                AC_MSG_ERROR([cannot determine odfvalidator jar location (--with-export-validation)])
9313            fi
9314        fi
9315        if test "$build_os" = "cygwin"; then
9316            # In case of Cygwin it will be executed from Windows,
9317            # so we need to run bash and absolute path to validator
9318            # so instead of "odfvalidator" it will be
9319            # something like "bash.exe C:\cygwin\opt\lo\bin\odfvalidator"
9320            ODFVALIDATOR="bash.exe `cygpath -m "$ODFVALIDATOR"`"
9321        else
9322            ODFVALIDATOR="sh $ODFVALIDATOR"
9323        fi
9324        AC_SUBST(ODFVALIDATOR)
9325
9326
9327        AC_PATH_PROGS(OFFICEOTRON, officeotron)
9328        if test -z "$OFFICEOTRON"; then
9329            # remember to download the officeotron with validator later
9330            AC_MSG_NOTICE([no officeotron found, will download it])
9331            BUILD_TYPE="$BUILD_TYPE OFFICEOTRON"
9332            OFFICEOTRON="$BUILDDIR/bin/officeotron.sh"
9333
9334            # and fetch name of officeotron jar name from download.lst
9335            OFFICEOTRON_JAR=`$SED -n -e "s/^OFFICEOTRON_JAR *:= *\(.*\) */\1/p" $SRC_ROOT/download.lst`
9336            AC_SUBST(OFFICEOTRON_JAR)
9337
9338            if test -z "$OFFICEOTRON_JAR"; then
9339                AC_MSG_ERROR([cannot determine officeotron jar location (--with-export-validation)])
9340            fi
9341        else
9342            # check version of existing officeotron
9343            OFFICEOTRON_VER=`$OFFICEOTRON --version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
9344            if test 0"$OFFICEOTRON_VER" -lt 704; then
9345                AC_MSG_ERROR([officeotron too old])
9346            fi
9347        fi
9348        if test "$build_os" = "cygwin"; then
9349            # In case of Cygwin it will be executed from Windows,
9350            # so we need to run bash and absolute path to validator
9351            # so instead of "odfvalidator" it will be
9352            # something like "bash.exe C:\cygwin\opt\lo\bin\odfvalidator"
9353            OFFICEOTRON="bash.exe `cygpath -m "$OFFICEOTRON"`"
9354        else
9355            OFFICEOTRON="sh $OFFICEOTRON"
9356        fi
9357    fi
9358    AC_SUBST(OFFICEOTRON)
9359else
9360    AC_MSG_RESULT([no])
9361fi
9362
9363AC_MSG_CHECKING([for Microsoft Binary File Format Validator])
9364if test "$with_bffvalidator" != "no"; then
9365    AC_DEFINE(HAVE_BFFVALIDATOR)
9366
9367    if test "$with_export_validation" = "no"; then
9368        AC_MSG_ERROR([Please enable export validation (-with-export-validation)!])
9369    fi
9370
9371    if test "$with_bffvalidator" = "yes"; then
9372        BFFVALIDATOR=`win_short_path_for_make "$PROGRAMFILES/Microsoft Office/BFFValidator/BFFValidator.exe"`
9373    else
9374        BFFVALIDATOR="$with_bffvalidator"
9375    fi
9376
9377    if test "$build_os" = "cygwin"; then
9378        if test -n "$BFFVALIDATOR" -a -e "`cygpath $BFFVALIDATOR`"; then
9379            AC_MSG_RESULT($BFFVALIDATOR)
9380        else
9381            AC_MSG_ERROR([bffvalidator not found, but required by --with-bffvalidator])
9382        fi
9383    elif test -n "$BFFVALIDATOR"; then
9384        # We are not in Cygwin but need to run Windows binary with wine
9385        AC_PATH_PROGS(WINE, wine)
9386
9387        # so swap in a shell wrapper that converts paths transparently
9388        BFFVALIDATOR_EXE="$BFFVALIDATOR"
9389        BFFVALIDATOR="sh $BUILDDIR/bin/bffvalidator.sh"
9390        AC_SUBST(BFFVALIDATOR_EXE)
9391        AC_MSG_RESULT($BFFVALIDATOR)
9392    else
9393        AC_MSG_ERROR([bffvalidator not found, but required by --with-bffvalidator])
9394    fi
9395    AC_SUBST(BFFVALIDATOR)
9396else
9397    AC_MSG_RESULT([no])
9398fi
9399
9400dnl ===================================================================
9401dnl Check for epm (not needed for Windows)
9402dnl ===================================================================
9403AC_MSG_CHECKING([whether to enable EPM for packing])
9404if test "$enable_epm" = "yes"; then
9405    AC_MSG_RESULT([yes])
9406    if test "$_os" != "WINNT"; then
9407        if test $_os = Darwin; then
9408            EPM=internal
9409        elif test -n "$with_epm"; then
9410            EPM=$with_epm
9411        else
9412            AC_PATH_PROG(EPM, epm, no)
9413        fi
9414        if test "$EPM" = "no" -o "$EPM" = "internal"; then
9415            AC_MSG_NOTICE([EPM will be built.])
9416            BUILD_TYPE="$BUILD_TYPE EPM"
9417            EPM=${WORKDIR}/UnpackedTarball/epm/epm
9418        else
9419            # Gentoo has some epm which is something different...
9420            AC_MSG_CHECKING([whether the found epm is the right epm])
9421            if $EPM | grep "ESP Package Manager" >/dev/null 2>/dev/null; then
9422                AC_MSG_RESULT([yes])
9423            else
9424                AC_MSG_ERROR([no. Install ESP Package Manager (https://jimjag.github.io/epm/) and/or specify the path to the right epm])
9425            fi
9426            AC_MSG_CHECKING([epm version])
9427            EPM_VERSION=`$EPM | grep 'ESP Package Manager' | cut -d' ' -f4 | $SED -e s/v//`
9428            if test "`echo $EPM_VERSION | cut -d'.' -f1`" -gt "3" || \
9429               test "`echo $EPM_VERSION | cut -d'.' -f1`" -eq "3" -a "`echo $EPM_VERSION | cut -d'.' -f2`" -ge "7"; then
9430                AC_MSG_RESULT([OK, >= 3.7])
9431            else
9432                AC_MSG_RESULT([too old. epm >= 3.7 is required.])
9433                AC_MSG_ERROR([Install ESP Package Manager (https://jimjag.github.io/epm/) and/or specify the path to the right epm])
9434            fi
9435        fi
9436    fi
9437
9438    if echo "$PKGFORMAT" | $EGREP rpm 2>&1 >/dev/null; then
9439        AC_MSG_CHECKING([for rpm])
9440        for a in "$RPM" rpmbuild rpm; do
9441            $a --usage >/dev/null 2> /dev/null
9442            if test $? -eq 0; then
9443                RPM=$a
9444                break
9445            else
9446                $a --version >/dev/null 2> /dev/null
9447                if test $? -eq 0; then
9448                    RPM=$a
9449                    break
9450                fi
9451            fi
9452        done
9453        if test -z "$RPM"; then
9454            AC_MSG_ERROR([not found])
9455        elif "$RPM" --help 2>&1 | $EGREP buildroot >/dev/null; then
9456            RPM_PATH=`command -v $RPM`
9457            AC_MSG_RESULT([$RPM_PATH])
9458            SCPDEFS="$SCPDEFS -DWITH_RPM"
9459        else
9460            AC_MSG_ERROR([cannot build packages. Try installing rpmbuild.])
9461        fi
9462    fi
9463    if echo "$PKGFORMAT" | $EGREP deb 2>&1 >/dev/null; then
9464        AC_PATH_PROG(DPKG, dpkg, no)
9465        if test "$DPKG" = "no"; then
9466            AC_MSG_ERROR([dpkg needed for deb creation. Install dpkg.])
9467        fi
9468    fi
9469    if echo "$PKGFORMAT" | $EGREP rpm 2>&1 >/dev/null || \
9470       echo "$PKGFORMAT" | $EGREP pkg 2>&1 >/dev/null; then
9471        if test "$with_epm" = "no" -a "$_os" != "Darwin"; then
9472            if test "`echo $EPM_VERSION | cut -d'.' -f1`" -lt "4"; then
9473                AC_MSG_CHECKING([whether epm is patched for LibreOffice's needs])
9474                if grep "Patched for .*Office" $EPM >/dev/null 2>/dev/null; then
9475                    AC_MSG_RESULT([yes])
9476                else
9477                    AC_MSG_RESULT([no])
9478                    if echo "$PKGFORMAT" | $GREP -q rpm; then
9479                        _pt="rpm"
9480                        AC_MSG_WARN([the rpms will need to be installed with --nodeps])
9481                        add_warning "the rpms will need to be installed with --nodeps"
9482                    else
9483                        _pt="pkg"
9484                    fi
9485                    AC_MSG_WARN([the ${_pt}s will not be relocatable])
9486                    add_warning "the ${_pt}s will not be relocatable"
9487                    AC_MSG_WARN([if you want to make sure installation without --nodeps and
9488                                 relocation will work, you need to patch your epm with the
9489                                 patch in epm/epm-3.7.patch or build with
9490                                 --with-epm=internal which will build a suitable epm])
9491                fi
9492            fi
9493        fi
9494    fi
9495    if echo "$PKGFORMAT" | $EGREP pkg 2>&1 >/dev/null; then
9496        AC_PATH_PROG(PKGMK, pkgmk, no)
9497        if test "$PKGMK" = "no"; then
9498            AC_MSG_ERROR([pkgmk needed for Solaris pkg creation. Install it.])
9499        fi
9500    fi
9501    AC_SUBST(RPM)
9502    AC_SUBST(DPKG)
9503    AC_SUBST(PKGMK)
9504else
9505    for i in $PKGFORMAT; do
9506        case "$i" in
9507        bsd | deb | pkg | rpm | native | portable)
9508            AC_MSG_ERROR(
9509                [--with-package-format='$PKGFORMAT' requires --enable-epm])
9510            ;;
9511        esac
9512    done
9513    AC_MSG_RESULT([no])
9514    EPM=NO
9515fi
9516AC_SUBST(EPM)
9517
9518ENABLE_LWP=
9519if test "$enable_lotuswordpro" = "yes"; then
9520    ENABLE_LWP="TRUE"
9521fi
9522AC_SUBST(ENABLE_LWP)
9523
9524dnl ===================================================================
9525dnl Check for building ODK
9526dnl ===================================================================
9527AC_MSG_CHECKING([whether to build the ODK])
9528if test "$enable_odk" = yes; then
9529    if test "$DISABLE_DYNLOADING" = TRUE; then
9530        AC_MSG_ERROR([can't build ODK for --disable-dynamic-loading builds])
9531    fi
9532    AC_MSG_RESULT([yes])
9533    BUILD_TYPE="$BUILD_TYPE ODK"
9534else
9535    AC_MSG_RESULT([no])
9536fi
9537
9538if test "$enable_odk" != yes; then
9539    unset DOXYGEN
9540else
9541    if test "$with_doxygen" = no; then
9542        AC_MSG_CHECKING([for doxygen])
9543        unset DOXYGEN
9544        AC_MSG_RESULT([no])
9545    else
9546        if test "$with_doxygen" = yes; then
9547            AC_PATH_PROG([DOXYGEN], [doxygen])
9548            if test -z "$DOXYGEN"; then
9549                AC_MSG_ERROR([doxygen not found in \$PATH; specify its pathname via --with-doxygen=..., or disable its use via --without-doxygen])
9550            fi
9551            if $DOXYGEN -g - | grep -q "HAVE_DOT *= *YES"; then
9552                if ! dot -V 2>/dev/null; then
9553                    AC_MSG_ERROR([dot not found in \$PATH but doxygen defaults to HAVE_DOT=YES; install graphviz or disable its use via --without-doxygen])
9554                fi
9555            fi
9556        else
9557            AC_MSG_CHECKING([for doxygen])
9558            PathFormat "$with_doxygen"
9559            DOXYGEN="$formatted_path_unix"
9560            AC_MSG_RESULT([$formatted_path])
9561        fi
9562        if test -n "$DOXYGEN"; then
9563            DOXYGEN_VERSION=`$DOXYGEN --version 2>/dev/null`
9564            DOXYGEN_NUMVERSION=`echo $DOXYGEN_VERSION | $AWK -F. '{ print \$1*10000 + \$2*100 + \$3 }'`
9565            if ! test "$DOXYGEN_NUMVERSION" -ge "10804" ; then
9566                AC_MSG_ERROR([found doxygen is too old; need at least version 1.8.4 or specify --without-doxygen])
9567            fi
9568        fi
9569        if test -n "$WSL_ONLY_AS_HELPER"; then
9570            dnl what really should be tested is whether it is doxygen from windows-realm
9571            dnl i.e. one that runs on the windows-side and deals with windows-pathnames
9572            dnl using doxygen from wsl container would be possible, but there's a performance
9573            dnl penalty when accessing the files outside the container
9574            AC_MSG_CHECKING([whether doxygen is a windows executable])
9575            if $(file "$DOXYGEN" | grep -q "PE32"); then
9576                AC_MSG_RESULT([yes])
9577            else
9578                AC_MSG_RESULT([no])
9579                AC_MSG_ERROR([please provide a path to a windows version of doxygen or use --without-doxygen])
9580            fi
9581        fi
9582    fi
9583fi
9584AC_SUBST([DOXYGEN])
9585
9586dnl ==================================================================
9587dnl libfuzzer
9588dnl ==================================================================
9589AC_MSG_CHECKING([whether to enable fuzzers])
9590if test "$enable_fuzzers" != yes; then
9591    AC_MSG_RESULT([no])
9592else
9593    if test -z $LIB_FUZZING_ENGINE; then
9594      AC_MSG_ERROR(['LIB_FUZZING_ENGINE' must be set when using --enable-fuzzers. Examples include '-fsanitize=fuzzer'.])
9595    fi
9596    AC_MSG_RESULT([yes])
9597    ENABLE_FUZZERS="TRUE"
9598    AC_DEFINE([ENABLE_FUZZERS],1)
9599    BUILD_TYPE="$BUILD_TYPE FUZZERS"
9600fi
9601AC_SUBST(LIB_FUZZING_ENGINE)
9602
9603dnl ===================================================================
9604dnl Check for system zlib
9605dnl ===================================================================
9606if test "$with_system_zlib" = "auto"; then
9607    case "$_os" in
9608    WINNT)
9609        with_system_zlib="$with_system_libs"
9610        ;;
9611    *)
9612        if test "$enable_fuzzers" != "yes"; then
9613            with_system_zlib=yes
9614        else
9615            with_system_zlib=no
9616        fi
9617        ;;
9618    esac
9619fi
9620
9621dnl we want to use libo_CHECK_SYSTEM_MODULE here too, but macOS is too stupid
9622dnl and has no pkg-config for it at least on some tinderboxes,
9623dnl so leaving that out for now
9624dnl libo_CHECK_SYSTEM_MODULE([zlib],[ZLIB],[zlib])
9625AC_MSG_CHECKING([which zlib to use])
9626if test "$with_system_zlib" = "yes"; then
9627    AC_MSG_RESULT([external])
9628    SYSTEM_ZLIB=TRUE
9629    AC_CHECK_HEADER(zlib.h, [],
9630        [AC_MSG_ERROR(zlib.h not found. install zlib)], [])
9631    AC_CHECK_LIB(z, deflate, [ ZLIB_LIBS=-lz ],
9632        [AC_MSG_ERROR(zlib not found or functional)], [])
9633else
9634    AC_MSG_RESULT([internal])
9635    SYSTEM_ZLIB=
9636    BUILD_TYPE="$BUILD_TYPE ZLIB"
9637    ZLIB_CFLAGS="-I${WORKDIR}/UnpackedTarball/zlib"
9638    if test "$COM" = "MSC"; then
9639        ZLIB_LIBS='$(gb_StaticLibrary_WORKDIR)/zlib.lib'
9640    else
9641        ZLIB_LIBS='-L$(gb_StaticLibrary_WORKDIR) -lzlib'
9642    fi
9643fi
9644AC_SUBST(ZLIB_CFLAGS)
9645AC_SUBST(ZLIB_LIBS)
9646AC_SUBST(SYSTEM_ZLIB)
9647
9648dnl ===================================================================
9649dnl Check for system jpeg
9650dnl ===================================================================
9651AC_MSG_CHECKING([which libjpeg to use])
9652if test "$with_system_jpeg" = "yes"; then
9653    AC_MSG_RESULT([external])
9654    SYSTEM_LIBJPEG=TRUE
9655    AC_CHECK_HEADER(jpeglib.h, [ LIBJPEG_CFLAGS= ],
9656        [AC_MSG_ERROR(jpeg.h not found. install libjpeg)], [])
9657    AC_CHECK_LIB(jpeg, jpeg_resync_to_restart, [ LIBJPEG_LIBS="-ljpeg" ],
9658        [AC_MSG_ERROR(jpeg library not found or functional)], [])
9659else
9660    SYSTEM_LIBJPEG=
9661    AC_MSG_RESULT([internal, libjpeg-turbo])
9662    BUILD_TYPE="$BUILD_TYPE LIBJPEG_TURBO"
9663
9664    case "$host_cpu" in
9665    x86_64 | amd64 | i*86 | x86 | ia32)
9666        AC_CHECK_PROGS(NASM, [nasm nasmw yasm])
9667        if test -z "$NASM" -a "$build_os" = "cygwin"; then
9668            if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/nasm"; then
9669                NASM="$LODE_HOME/opt/bin/nasm"
9670            elif test -x "/opt/lo/bin/nasm"; then
9671                NASM="/opt/lo/bin/nasm"
9672            fi
9673        fi
9674
9675        if test -n "$NASM"; then
9676            AC_MSG_CHECKING([for object file format of host system])
9677            case "$host_os" in
9678              cygwin* | mingw* | pw32* | wsl*)
9679                case "$host_cpu" in
9680                  x86_64)
9681                    objfmt='Win64-COFF'
9682                    ;;
9683                  *)
9684                    objfmt='Win32-COFF'
9685                    ;;
9686                esac
9687              ;;
9688              msdosdjgpp* | go32*)
9689                objfmt='COFF'
9690              ;;
9691              os2-emx*) # not tested
9692                objfmt='MSOMF' # obj
9693              ;;
9694              linux*coff* | linux*oldld*)
9695                objfmt='COFF' # ???
9696              ;;
9697              linux*aout*)
9698                objfmt='a.out'
9699              ;;
9700              linux*)
9701                case "$host_cpu" in
9702                  x86_64)
9703                    objfmt='ELF64'
9704                    ;;
9705                  *)
9706                    objfmt='ELF'
9707                    ;;
9708                esac
9709              ;;
9710              kfreebsd* | freebsd* | netbsd* | openbsd*)
9711                if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
9712                  objfmt='BSD-a.out'
9713                else
9714                  case "$host_cpu" in
9715                    x86_64 | amd64)
9716                      objfmt='ELF64'
9717                      ;;
9718                    *)
9719                      objfmt='ELF'
9720                      ;;
9721                  esac
9722                fi
9723              ;;
9724              solaris* | sunos* | sysv* | sco*)
9725                case "$host_cpu" in
9726                  x86_64)
9727                    objfmt='ELF64'
9728                    ;;
9729                  *)
9730                    objfmt='ELF'
9731                    ;;
9732                esac
9733              ;;
9734              darwin* | rhapsody* | nextstep* | openstep* | macos*)
9735                case "$host_cpu" in
9736                  x86_64)
9737                    objfmt='Mach-O64'
9738                    ;;
9739                  *)
9740                    objfmt='Mach-O'
9741                    ;;
9742                esac
9743              ;;
9744              *)
9745                objfmt='ELF ?'
9746              ;;
9747            esac
9748
9749            AC_MSG_RESULT([$objfmt])
9750            if test "$objfmt" = 'ELF ?'; then
9751              objfmt='ELF'
9752              AC_MSG_WARN([unexpected host system. assumed that the format is $objfmt.])
9753            fi
9754
9755            AC_MSG_CHECKING([for object file format specifier (NAFLAGS) ])
9756            case "$objfmt" in
9757              MSOMF)      NAFLAGS='-fobj -DOBJ32 -DPIC';;
9758              Win32-COFF) NAFLAGS='-fwin32 -DWIN32 -DPIC';;
9759              Win64-COFF) NAFLAGS='-fwin64 -DWIN64 -D__x86_64__ -DPIC';;
9760              COFF)       NAFLAGS='-fcoff -DCOFF -DPIC';;
9761              a.out)      NAFLAGS='-faout -DAOUT -DPIC';;
9762              BSD-a.out)  NAFLAGS='-faoutb -DAOUT -DPIC';;
9763              ELF)        NAFLAGS='-felf -DELF -DPIC';;
9764              ELF64)      NAFLAGS='-felf64 -DELF -D__x86_64__ -DPIC';;
9765              RDF)        NAFLAGS='-frdf -DRDF -DPIC';;
9766              Mach-O)     NAFLAGS='-fmacho -DMACHO -DPIC';;
9767              Mach-O64)   NAFLAGS='-fmacho64 -DMACHO -D__x86_64__ -DPIC';;
9768            esac
9769            AC_MSG_RESULT([$NAFLAGS])
9770
9771            AC_MSG_CHECKING([whether the assembler ($NASM $NAFLAGS) works])
9772            cat > conftest.asm << EOF
9773            [%line __oline__ "configure"
9774                    section .text
9775                    global  _main,main
9776            _main:
9777            main:   xor     eax,eax
9778                    ret
9779            ]
9780EOF
9781            try_nasm='$NASM $NAFLAGS -o conftest.o conftest.asm'
9782            if AC_TRY_EVAL(try_nasm) && test -s conftest.o; then
9783              AC_MSG_RESULT(yes)
9784            else
9785              echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
9786              cat conftest.asm >&AS_MESSAGE_LOG_FD
9787              rm -rf conftest*
9788              AC_MSG_RESULT(no)
9789              AC_MSG_WARN([installation or configuration problem: assembler cannot create object files.])
9790              NASM=""
9791            fi
9792
9793        fi
9794
9795        if test -z "$NASM"; then
9796cat << _EOS
9797****************************************************************************
9798You need yasm or nasm (Netwide Assembler) to build the internal jpeg library optimally.
9799To get one please:
9800
9801_EOS
9802            if test "$build_os" = "cygwin"; then
9803cat << _EOS
9804install a pre-compiled binary for Win32
9805
9806mkdir -p /opt/lo/bin
9807cd /opt/lo/bin
9808wget https://dev-www.libreoffice.org/bin/cygwin/nasm.exe
9809chmod +x nasm
9810
9811or get and install one from https://www.nasm.us/
9812
9813Then re-run autogen.sh
9814
9815Note: autogen.sh will try to use /opt/lo/bin/nasm if the environment variable NASM is not already defined.
9816Alternatively, you can install the 'new' nasm where ever you want and make sure that \`command -v nasm\` finds it.
9817
9818_EOS
9819            else
9820cat << _EOS
9821consult https://github.com/libjpeg-turbo/libjpeg-turbo/blob/main/BUILDING.md
9822
9823_EOS
9824            fi
9825            AC_MSG_WARN([no suitable nasm (Netwide Assembler) found])
9826            add_warning "no suitable nasm (Netwide Assembler) found for internal libjpeg-turbo"
9827        fi
9828      ;;
9829    esac
9830fi
9831
9832AC_SUBST(NASM)
9833AC_SUBST(NAFLAGS)
9834AC_SUBST(LIBJPEG_CFLAGS)
9835AC_SUBST(LIBJPEG_LIBS)
9836AC_SUBST(SYSTEM_LIBJPEG)
9837
9838dnl ===================================================================
9839dnl Check for system clucene
9840dnl ===================================================================
9841libo_CHECK_SYSTEM_MODULE([clucene],[CLUCENE],[libclucene-core])
9842if test "$SYSTEM_CLUCENE" = TRUE; then
9843    AC_LANG_PUSH([C++])
9844    save_CXXFLAGS=$CXXFLAGS
9845    save_CPPFLAGS=$CPPFLAGS
9846    CXXFLAGS="$CXXFLAGS $CLUCENE_CFLAGS"
9847    CPPFLAGS="$CPPFLAGS $CLUCENE_CFLAGS"
9848    dnl https://sourceforge.net/p/clucene/bugs/200/
9849    dnl https://bugzilla.redhat.com/show_bug.cgi?id=794795
9850    AC_CHECK_HEADER([CLucene/analysis/cjk/CJKAnalyzer.h], [],
9851                 [AC_MSG_ERROR([Your version of libclucene has contribs-lib missing.])], [#include <CLucene.h>])
9852    CXXFLAGS=$save_CXXFLAGS
9853    CPPFLAGS=$save_CPPFLAGS
9854    AC_LANG_POP([C++])
9855    CLUCENE_LIBS="$CLUCENE_LIBS -lclucene-contribs-lib"
9856fi
9857
9858dnl ===================================================================
9859dnl Check for system expat
9860dnl ===================================================================
9861libo_CHECK_SYSTEM_MODULE([expat], [EXPAT], [expat])
9862
9863dnl ===================================================================
9864dnl Check for system xmlsec
9865dnl ===================================================================
9866libo_CHECK_SYSTEM_MODULE([xmlsec], [XMLSEC], [xmlsec1-nss >= 1.2.35])
9867
9868AC_MSG_CHECKING([whether to enable Embedded OpenType support])
9869if test "$enable_eot" = "yes"; then
9870    ENABLE_EOT="TRUE"
9871    AC_DEFINE([ENABLE_EOT])
9872    AC_MSG_RESULT([yes])
9873
9874    libo_CHECK_SYSTEM_MODULE([libeot],[LIBEOT],[libeot >= 0.01])
9875else
9876    ENABLE_EOT=
9877    AC_MSG_RESULT([no])
9878fi
9879AC_SUBST([ENABLE_EOT])
9880
9881dnl ===================================================================
9882dnl Check for DLP libs
9883dnl ===================================================================
9884REVENGE_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/librevenge/inc"
9885AS_IF([test "$COM" = "MSC"],
9886      [librevenge_libdir='$(gb_Library_DLLDIR)'],
9887      [librevenge_libdir="${WORKDIR}/UnpackedTarball/librevenge/src/lib/.libs"]
9888)
9889REVENGE_LIBS_internal="-L${librevenge_libdir} -lrevenge-0.0"
9890libo_CHECK_SYSTEM_MODULE([librevenge],[REVENGE],[librevenge-0.0 >= 0.0.1])
9891
9892libo_CHECK_SYSTEM_MODULE([libodfgen],[ODFGEN],[libodfgen-0.1])
9893
9894libo_CHECK_SYSTEM_MODULE([libepubgen],[EPUBGEN],[libepubgen-0.1])
9895
9896WPD_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/libwpd/inc"
9897AS_IF([test "$COM" = "MSC"],
9898      [libwpd_libdir='$(gb_Library_DLLDIR)'],
9899      [libwpd_libdir="${WORKDIR}/UnpackedTarball/libwpd/src/lib/.libs"]
9900)
9901WPD_LIBS_internal="-L${libwpd_libdir} -lwpd-0.10"
9902libo_CHECK_SYSTEM_MODULE([libwpd],[WPD],[libwpd-0.10])
9903
9904libo_CHECK_SYSTEM_MODULE([libwpg],[WPG],[libwpg-0.3])
9905
9906libo_CHECK_SYSTEM_MODULE([libwps],[WPS],[libwps-0.4])
9907libo_PKG_VERSION([WPS], [libwps-0.4], [0.4.14])
9908
9909libo_CHECK_SYSTEM_MODULE([libvisio],[VISIO],[libvisio-0.1])
9910
9911libo_CHECK_SYSTEM_MODULE([libcdr],[CDR],[libcdr-0.1])
9912
9913libo_CHECK_SYSTEM_MODULE([libmspub],[MSPUB],[libmspub-0.1])
9914
9915libo_CHECK_SYSTEM_MODULE([libmwaw],[MWAW],[libmwaw-0.3 >= 0.3.21])
9916libo_PKG_VERSION([MWAW], [libmwaw-0.3], [0.3.21])
9917
9918libo_CHECK_SYSTEM_MODULE([libetonyek],[ETONYEK],[libetonyek-0.1])
9919libo_PKG_VERSION([ETONYEK], [libetonyek-0.1], [0.1.10])
9920
9921libo_CHECK_SYSTEM_MODULE([libfreehand],[FREEHAND],[libfreehand-0.1])
9922
9923libo_CHECK_SYSTEM_MODULE([libebook],[EBOOK],[libe-book-0.1])
9924libo_PKG_VERSION([EBOOK], [libe-book-0.1], [0.1.2])
9925
9926libo_CHECK_SYSTEM_MODULE([libabw],[ABW],[libabw-0.1])
9927
9928libo_CHECK_SYSTEM_MODULE([libpagemaker],[PAGEMAKER],[libpagemaker-0.0])
9929
9930libo_CHECK_SYSTEM_MODULE([libqxp],[QXP],[libqxp-0.0])
9931
9932libo_CHECK_SYSTEM_MODULE([libzmf],[ZMF],[libzmf-0.0])
9933
9934libo_CHECK_SYSTEM_MODULE([libstaroffice],[STAROFFICE],[libstaroffice-0.0])
9935libo_PKG_VERSION([STAROFFICE], [libstaroffice-0.0], [0.0.7])
9936
9937dnl ===================================================================
9938dnl Check for system lcms2
9939dnl ===================================================================
9940if test "$with_system_lcms2" != "yes"; then
9941    SYSTEM_LCMS2=
9942fi
9943LCMS2_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/lcms2/include"
9944LCMS2_LIBS_internal="-L${WORKDIR}/UnpackedTarball/lcms2/src/.libs -llcms2"
9945libo_CHECK_SYSTEM_MODULE([lcms2],[LCMS2],[lcms2])
9946if test "$GCC" = "yes"; then
9947    LCMS2_CFLAGS="${LCMS2_CFLAGS} -Wno-long-long"
9948fi
9949if test "$COM" = "MSC"; then # override the above
9950    LCMS2_LIBS=${WORKDIR}/UnpackedTarball/lcms2/bin/lcms2.lib
9951fi
9952
9953dnl ===================================================================
9954dnl Check for system cppunit
9955dnl ===================================================================
9956if test "$_os" != "Android" ; then
9957    libo_CHECK_SYSTEM_MODULE([cppunit],[CPPUNIT],[cppunit >= 1.14.0])
9958fi
9959
9960dnl ===================================================================
9961dnl Check whether freetype is available
9962dnl
9963dnl FreeType has 3 different kinds of versions
9964dnl * release, like 2.4.10
9965dnl * libtool, like 13.0.7 (this what pkg-config returns)
9966dnl * soname
9967dnl FreeType's docs/VERSION.DLL provides a table mapping between the three
9968dnl
9969dnl 9.9.3 is 2.2.0
9970dnl When the minimal version is at least 2.8.1, remove Skia's check down below.
9971dnl ===================================================================
9972FREETYPE_CFLAGS_internal="${ISYSTEM}${WORKDIR}/UnpackedTarball/freetype/include"
9973if test "x$ac_config_site_64bit_host" = xYES; then
9974    FREETYPE_LIBS_internal="-L${WORKDIR}/UnpackedTarball/freetype/instdir/lib64 -lfreetype"
9975else
9976    FREETYPE_LIBS_internal="-L${WORKDIR}/UnpackedTarball/freetype/instdir/lib -lfreetype"
9977fi
9978libo_CHECK_SYSTEM_MODULE([freetype],[FREETYPE],[freetype2 >= 9.9.3],,system,TRUE)
9979
9980# ===================================================================
9981# Check for system libxslt
9982# to prevent incompatibilities between internal libxml2 and external libxslt,
9983# or vice versa, use with_system_libxml here
9984# ===================================================================
9985if test "$with_system_libxml" = "auto"; then
9986    case "$_os" in
9987    WINNT|iOS|Android)
9988        with_system_libxml="$with_system_libs"
9989        ;;
9990    Emscripten)
9991        with_system_libxml=no
9992        ;;
9993    *)
9994        if test "$enable_fuzzers" != "yes"; then
9995            with_system_libxml=yes
9996        else
9997            with_system_libxml=no
9998        fi
9999        ;;
10000    esac
10001fi
10002
10003AC_MSG_CHECKING([which libxslt to use])
10004if test "$with_system_libxml" = "yes"; then
10005    AC_MSG_RESULT([external])
10006    SYSTEM_LIBXSLT=TRUE
10007    if test "$_os" = "Darwin"; then
10008        dnl make sure to use SDK path
10009        LIBXSLT_CFLAGS="-I$MACOSX_SDK_PATH/usr/include/libxml2"
10010        LIBEXSLT_CFLAGS="$LIBXSLT_CFLAGS"
10011        dnl omit -L/usr/lib
10012        LIBXSLT_LIBS="-lxslt -lxml2 -lz -lpthread -liconv -lm"
10013        LIBEXSLT_LIBS="-lexslt $LIBXSLT_LIBS"
10014    else
10015        PKG_CHECK_MODULES(LIBXSLT, libxslt)
10016        LIBXSLT_CFLAGS=$(printf '%s' "$LIBXSLT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10017        FilterLibs "${LIBXSLT_LIBS}"
10018        LIBXSLT_LIBS="${filteredlibs}"
10019        PKG_CHECK_MODULES(LIBEXSLT, libexslt)
10020        LIBEXSLT_CFLAGS=$(printf '%s' "$LIBEXSLT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10021        FilterLibs "${LIBEXSLT_LIBS}"
10022        LIBEXSLT_LIBS=$(printf '%s' "${filteredlibs}" | sed -e "s/-lgpg-error//"  -e "s/-lgcrypt//")
10023    fi
10024
10025    dnl Check for xsltproc
10026    AC_PATH_PROG(XSLTPROC, xsltproc, no)
10027    if test "$XSLTPROC" = "no"; then
10028        AC_MSG_ERROR([xsltproc is required])
10029    fi
10030else
10031    AC_MSG_RESULT([internal])
10032    SYSTEM_LIBXSLT=
10033    BUILD_TYPE="$BUILD_TYPE LIBXSLT"
10034fi
10035AC_SUBST(SYSTEM_LIBXSLT)
10036if test -z "$SYSTEM_LIBXSLT_FOR_BUILD"; then
10037    SYSTEM_LIBXSLT_FOR_BUILD="$SYSTEM_LIBXSLT"
10038fi
10039AC_SUBST(SYSTEM_LIBXSLT_FOR_BUILD)
10040
10041AC_SUBST(LIBEXSLT_CFLAGS)
10042AC_SUBST(LIBEXSLT_LIBS)
10043AC_SUBST(LIBXSLT_CFLAGS)
10044AC_SUBST(LIBXSLT_LIBS)
10045AC_SUBST(XSLTPROC)
10046
10047# ===================================================================
10048# Check for system libxml
10049# ===================================================================
10050AC_MSG_CHECKING([which libxml to use])
10051if test "$with_system_libxml" = "yes"; then
10052    AC_MSG_RESULT([external])
10053    SYSTEM_LIBXML=TRUE
10054    if test "$_os" = "Darwin"; then
10055        dnl make sure to use SDK path
10056        LIBXML_CFLAGS="-I$MACOSX_SDK_PATH/usr/include/libxml2"
10057        dnl omit -L/usr/lib
10058        LIBXML_LIBS="-lxml2 -lz -lpthread -liconv -lm"
10059    elif test $_os = iOS; then
10060        dnl make sure to use SDK path
10061        usr=`echo '#include <stdlib.h>' | $CC -E -MD - | grep usr/include/stdlib.h | head -1 | sed -e 's,# 1 ",,' -e 's,/usr/include/.*,/usr,'`
10062        LIBXML_CFLAGS="-I$usr/include/libxml2"
10063        LIBXML_LIBS="-L$usr/lib -lxml2 -liconv"
10064    else
10065        PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= 2.0)
10066        LIBXML_CFLAGS=$(printf '%s' "$LIBXML_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
10067        FilterLibs "${LIBXML_LIBS}"
10068        LIBXML_LIBS="${filteredlibs}"
10069    fi
10070
10071    dnl Check for xmllint
10072    AC_PATH_PROG(XMLLINT, xmllint, no)
10073    if test "$XMLLINT" = "no"; then
10074        AC_MSG_ERROR([xmllint is required])
10075    fi
10076else
10077    AC_MSG_RESULT([internal])
10078    SYSTEM_LIBXML=
10079    LIBXML_CFLAGS="-I${WORKDIR}/UnpackedTarball/libxml2/include"
10080    if test "$COM" = "MSC"; then
10081        LIBXML_CFLAGS="${LIBXML_CFLAGS} -I${WORKDIR}/UnpackedTarball/icu/source/i18n -I${WORKDIR}/UnpackedTarball/icu/source/common"
10082    fi
10083    if test "$COM" = "MSC"; then
10084        LIBXML_LIBS="${WORKDIR}/UnpackedTarball/libxml2/win32/bin.msvc/libxml2.lib"
10085    else
10086        LIBXML_LIBS="-L${WORKDIR}/UnpackedTarball/libxml2/.libs -lxml2"
10087        if test "$DISABLE_DYNLOADING" = TRUE; then
10088            LIBXML_LIBS="$LIBXML_LIBS -lm"
10089        fi
10090    fi
10091    BUILD_TYPE="$BUILD_TYPE LIBXML2"
10092fi
10093AC_SUBST(SYSTEM_LIBXML)
10094if test -z "$SYSTEM_LIBXML_FOR_BUILD"; then
10095    SYSTEM_LIBXML_FOR_BUILD="$SYSTEM_LIBXML"
10096fi
10097AC_SUBST(SYSTEM_LIBXML_FOR_BUILD)
10098AC_SUBST(LIBXML_CFLAGS)
10099AC_SUBST(LIBXML_LIBS)
10100AC_SUBST(XMLLINT)
10101
10102# =====================================================================
10103# Checking for a Python interpreter with version >= 3.3.
10104# Optionally user can pass an option to configure, i. e.
10105# ./configure PYTHON=/usr/bin/python
10106# =====================================================================
10107if test $_os = Darwin -a "$enable_python" != no -a "$enable_python" != fully-internal -a "$enable_python" != internal -a "$enable_python" != system; then
10108    # Only allowed choices for macOS are 'no', 'internal' (default), and 'fully-internal'
10109    # unless PYTHON is defined as above which allows 'system'
10110    enable_python=internal
10111fi
10112if test "$build_os" != "cygwin" -a "$enable_python" != fully-internal; then
10113    if test -n "$PYTHON"; then
10114        PYTHON_FOR_BUILD=$PYTHON
10115    else
10116        # This allows a lack of system python with no error, we use internal one in that case.
10117        AM_PATH_PYTHON([3.3],, [:])
10118        # Clean PYTHON_VERSION checked below if cross-compiling
10119        PYTHON_VERSION=""
10120        if test "$PYTHON" != ":"; then
10121            PYTHON_FOR_BUILD=$PYTHON
10122        fi
10123    fi
10124fi
10125
10126# Checks for Python to use for Pyuno
10127AC_MSG_CHECKING([which Python to use for Pyuno])
10128case "$enable_python" in
10129no|disable)
10130    if test -z "$PYTHON_FOR_BUILD" -a "$cross_compiling" != yes; then
10131        # Python is required to build LibreOffice. In theory we could separate the build-time Python
10132        # requirement from the choice whether to include Python stuff in the installer, but why
10133        # bother?
10134        AC_MSG_ERROR([Python is required at build time.])
10135    fi
10136    enable_python=no
10137    AC_MSG_RESULT([none])
10138    ;;
10139""|yes|auto)
10140    if test "$DISABLE_SCRIPTING" = TRUE; then
10141        if test -z "$PYTHON_FOR_BUILD" -a "$cross_compiling" != yes; then
10142            AC_MSG_ERROR([Python support can't be disabled without cross-compiling or a system python.])
10143        fi
10144        AC_MSG_RESULT([none, overridden by --disable-scripting])
10145        enable_python=no
10146    elif test $build_os = cygwin -o $build_os = wsl; then
10147        dnl When building on Windows we don't attempt to use any installed
10148        dnl "system"  Python.
10149        AC_MSG_RESULT([fully internal])
10150        enable_python=internal
10151    elif test "$cross_compiling" = yes; then
10152        AC_MSG_RESULT([system])
10153        enable_python=system
10154    else
10155        # Unset variables set by the above AM_PATH_PYTHON so that
10156        # we actually do check anew.
10157        AC_MSG_RESULT([])
10158        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
10159        AM_PATH_PYTHON([3.3],, [:])
10160        AC_MSG_CHECKING([which Python to use for Pyuno])
10161        if test "$PYTHON" = ":"; then
10162            if test -z "$PYTHON_FOR_BUILD"; then
10163                AC_MSG_RESULT([fully internal])
10164            else
10165                AC_MSG_RESULT([internal])
10166            fi
10167            enable_python=internal
10168        else
10169            AC_MSG_RESULT([system])
10170            enable_python=system
10171        fi
10172    fi
10173    ;;
10174internal)
10175    AC_MSG_RESULT([internal])
10176    ;;
10177fully-internal)
10178    AC_MSG_RESULT([fully internal])
10179    enable_python=internal
10180    ;;
10181system)
10182    AC_MSG_RESULT([system])
10183    if test "$_os" = Darwin -a -z "$PYTHON"; then
10184        AC_MSG_ERROR([--enable-python=system doesn't work on macOS because the version provided is obsolete])
10185    fi
10186    ;;
10187*)
10188    AC_MSG_ERROR([Incorrect --enable-python option])
10189    ;;
10190esac
10191
10192if test $enable_python != no; then
10193    BUILD_TYPE="$BUILD_TYPE PYUNO"
10194fi
10195
10196if test $enable_python = system; then
10197    if test -n "$PYTHON_CFLAGS" -a -n "$PYTHON_LIBS"; then
10198        # Fallback: Accept these in the environment, or as set above
10199        # for MacOSX.
10200        :
10201    elif test "$cross_compiling" != yes; then
10202        # Unset variables set by the above AM_PATH_PYTHON so that
10203        # we actually do check anew.
10204        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
10205        # This causes an error if no python command is found
10206        AM_PATH_PYTHON([3.3])
10207        python_include=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('INCLUDEPY'));"`
10208        python_version=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('VERSION'));"`
10209        python_libs=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBS'));"`
10210        python_libdir=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBDIR'));"`
10211        if test -z "$PKG_CONFIG"; then
10212            PYTHON_CFLAGS="-I$python_include"
10213            PYTHON_LIBS="-L$python_libdir -lpython$python_version $python_libs"
10214        elif $PKG_CONFIG --exists python-$python_version-embed; then
10215            PYTHON_CFLAGS="`$PKG_CONFIG --cflags python-$python_version-embed`"
10216            PYTHON_LIBS="`$PKG_CONFIG --libs python-$python_version-embed` $python_libs"
10217        elif $PKG_CONFIG --exists python-$python_version; then
10218            PYTHON_CFLAGS="`$PKG_CONFIG --cflags python-$python_version`"
10219            PYTHON_LIBS="`$PKG_CONFIG --libs python-$python_version` $python_libs"
10220        else
10221            PYTHON_CFLAGS="-I$python_include"
10222            PYTHON_LIBS="-L$python_libdir -lpython$python_version $python_libs"
10223        fi
10224        FilterLibs "${PYTHON_LIBS}"
10225        PYTHON_LIBS="${filteredlibs}"
10226    else
10227        dnl How to find out the cross-compilation Python installation path?
10228        AC_MSG_CHECKING([for python version])
10229        AS_IF([test -n "$PYTHON_VERSION"],
10230              [AC_MSG_RESULT([$PYTHON_VERSION])],
10231              [AC_MSG_RESULT([not found])
10232               AC_MSG_ERROR([no usable python found])])
10233        test -n "$PYTHON_CFLAGS" && break
10234    fi
10235
10236    dnl Check if the headers really work
10237    save_CPPFLAGS="$CPPFLAGS"
10238    CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
10239    AC_CHECK_HEADER(Python.h)
10240    CPPFLAGS="$save_CPPFLAGS"
10241
10242    # let the PYTHON_FOR_BUILD match the same python installation that
10243    # provides PYTHON_CFLAGS/PYTHON_LDFLAGS for pyuno, which should be
10244    # better for PythonTests.
10245    PYTHON_FOR_BUILD=$PYTHON
10246fi
10247
10248if test "$with_lxml" != no; then
10249    if test -z "$PYTHON_FOR_BUILD"; then
10250        case $build_os in
10251            cygwin)
10252                AC_MSG_WARN([No system-provided python lxml, gla11y will only report widget classes and ids])
10253                ;;
10254            *)
10255                if test "$cross_compiling" != yes ; then
10256                    BUILD_TYPE="$BUILD_TYPE LXML"
10257                fi
10258                ;;
10259        esac
10260    else
10261        AC_MSG_CHECKING([for python lxml])
10262        if $PYTHON_FOR_BUILD -c "import lxml.etree as ET" 2> /dev/null ; then
10263            AC_MSG_RESULT([yes])
10264        else
10265            case $build_os in
10266                cygwin)
10267                    AC_MSG_RESULT([no, gla11y will only report widget classes and ids])
10268                    ;;
10269                *)
10270                    if test "$cross_compiling" != yes -a "x$ac_cv_header_Python_h" = "xyes"; then
10271                        if test -n ${SYSTEM_LIBXSLT} -o -n ${SYSTEM_LIBXML}; then
10272                            AC_MSG_RESULT([no, and no system libxml/libxslt, gla11y will only report widget classes and ids])
10273                        else
10274                            BUILD_TYPE="$BUILD_TYPE LXML"
10275                            AC_MSG_RESULT([no, using internal lxml])
10276                        fi
10277                    else
10278                        AC_MSG_RESULT([no, and system does not provide python development headers, gla11y will only report widget classes and ids])
10279                    fi
10280                    ;;
10281            esac
10282        fi
10283    fi
10284fi
10285
10286if test \( "$cross_compiling" = yes -a -z "$PYTHON_FOR_BUILD" \) -o "$enable_python" = internal; then
10287    SYSTEM_PYTHON=
10288    PYTHON_VERSION_MAJOR=3
10289    PYTHON_VERSION_MINOR=9
10290    PYTHON_VERSION=${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.19
10291    if ! grep -q -i python.*${PYTHON_VERSION} ${SRC_ROOT}/download.lst; then
10292        AC_MSG_ERROR([PYTHON_VERSION ${PYTHON_VERSION} but no matching file in download.lst])
10293    fi
10294    AC_DEFINE_UNQUOTED([PYTHON_VERSION_STRING], [L"${PYTHON_VERSION}"])
10295
10296    # Embedded Python dies without Home set
10297    if test "$HOME" = ""; then
10298        export HOME=""
10299    fi
10300fi
10301
10302dnl By now enable_python should be "system", "internal" or "no"
10303case $enable_python in
10304system)
10305    SYSTEM_PYTHON=TRUE
10306
10307    if test "x$ac_cv_header_Python_h" != "xyes"; then
10308       AC_MSG_ERROR([Python headers not found. You probably want to set both the PYTHON_CFLAGS and PYTHON_LIBS environment variables.])
10309    fi
10310
10311    AC_LANG_PUSH(C)
10312    CFLAGS="$CFLAGS $PYTHON_CFLAGS"
10313    AC_MSG_CHECKING([for correct python library version])
10314       AC_RUN_IFELSE([AC_LANG_SOURCE([[
10315#include <Python.h>
10316
10317int main(int argc, char **argv) {
10318   if ((PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 3)) return 0;
10319   else return 1;
10320}
10321       ]])],[AC_MSG_RESULT([ok])],[AC_MSG_ERROR([Python >= 3.3 is needed when building with Python 3])],[AC_MSG_RESULT([skipped; cross-compiling])])
10322    AC_LANG_POP(C)
10323
10324    dnl FIXME Check if the Python library can be linked with, too?
10325    ;;
10326
10327internal)
10328    BUILD_TYPE="$BUILD_TYPE PYTHON"
10329    if test "$OS" = LINUX -o "$OS" = WNT ; then
10330        BUILD_TYPE="$BUILD_TYPE LIBFFI"
10331    fi
10332    ;;
10333no)
10334    DISABLE_PYTHON=TRUE
10335    SYSTEM_PYTHON=
10336    ;;
10337*)
10338    AC_MSG_ERROR([Internal configure script error, invalid enable_python value "$enable_python"])
10339    ;;
10340esac
10341
10342AC_SUBST(DISABLE_PYTHON)
10343AC_SUBST(SYSTEM_PYTHON)
10344AC_SUBST(PYTHON_CFLAGS)
10345AC_SUBST(PYTHON_FOR_BUILD)
10346AC_SUBST(PYTHON_LIBS)
10347AC_SUBST(PYTHON_VERSION)
10348AC_SUBST(PYTHON_VERSION_MAJOR)
10349AC_SUBST(PYTHON_VERSION_MINOR)
10350
10351AC_MSG_CHECKING([whether to build LibreLogo])
10352case "$enable_python" in
10353no|disable)
10354    AC_MSG_RESULT([no; Python disabled])
10355    ;;
10356*)
10357    if test "${enable_librelogo}" = "no"; then
10358        AC_MSG_RESULT([no])
10359    else
10360        AC_MSG_RESULT([yes])
10361        BUILD_TYPE="${BUILD_TYPE} LIBRELOGO"
10362        AC_DEFINE([ENABLE_LIBRELOGO],1)
10363    fi
10364    ;;
10365esac
10366AC_SUBST(ENABLE_LIBRELOGO)
10367
10368ENABLE_MARIADBC=
10369MARIADBC_MAJOR=1
10370MARIADBC_MINOR=0
10371MARIADBC_MICRO=2
10372AC_MSG_CHECKING([whether to build the MariaDB/MySQL SDBC driver])
10373if test "x$enable_mariadb_sdbc" != "xno" -a "$enable_mpl_subset" != "yes"; then
10374    ENABLE_MARIADBC=TRUE
10375    AC_MSG_RESULT([yes])
10376    BUILD_TYPE="$BUILD_TYPE MARIADBC"
10377else
10378    AC_MSG_RESULT([no])
10379fi
10380AC_SUBST(ENABLE_MARIADBC)
10381AC_SUBST(MARIADBC_MAJOR)
10382AC_SUBST(MARIADBC_MINOR)
10383AC_SUBST(MARIADBC_MICRO)
10384
10385if test "$ENABLE_MARIADBC" = "TRUE"; then
10386    dnl ===================================================================
10387    dnl Check for system MariaDB
10388    dnl ===================================================================
10389
10390    if test "$with_gssapi" = "yes" -a "$enable_openssl" = "no"; then
10391        AC_MSG_ERROR([GSSAPI needs OpenSSL, but --disable-openssl was given.])
10392    fi
10393
10394    AC_MSG_CHECKING([which MariaDB to use])
10395    if test "$with_system_mariadb" = "yes"; then
10396        AC_MSG_RESULT([external])
10397        SYSTEM_MARIADB_CONNECTOR_C=TRUE
10398        #AC_PATH_PROG(MARIADBCONFIG, [mariadb_config])
10399        if test -z "$MARIADBCONFIG"; then
10400            AC_PATH_PROG(MARIADBCONFIG, [mysql_config])
10401            if test -z "$MARIADBCONFIG"; then
10402                AC_MSG_ERROR([mysql_config is missing. Install MySQL client library development package.])
10403                #AC_MSG_ERROR([mariadb_config and mysql_config are missing. Install MariaDB or MySQL client library development package.])
10404            fi
10405        fi
10406        AC_MSG_CHECKING([MariaDB version])
10407        MARIADB_VERSION=`$MARIADBCONFIG --version`
10408        MARIADB_MAJOR=`$MARIADBCONFIG --version | cut -d"." -f1`
10409        if test "$MARIADB_MAJOR" -ge "5"; then
10410            AC_MSG_RESULT([OK])
10411        else
10412            AC_MSG_ERROR([too old, use 5.0.x or later])
10413        fi
10414        AC_MSG_CHECKING([for MariaDB Client library])
10415        MARIADB_CFLAGS=`$MARIADBCONFIG --cflags`
10416        if test "$COM_IS_CLANG" = TRUE; then
10417            MARIADB_CFLAGS=$(printf '%s' "$MARIADB_CFLAGS" | sed -e s/-fstack-protector-strong//)
10418        fi
10419        MARIADB_LIBS=`$MARIADBCONFIG --libs_r`
10420        dnl At least mariadb-5.5.34-3.fc20.x86_64 plus
10421        dnl mariadb-5.5.34-3.fc20.i686 reports 64-bit specific output even under
10422        dnl linux32:
10423        if test "$OS" = LINUX -a "$CPUNAME" = INTEL; then
10424            MARIADB_CFLAGS=$(printf '%s' "$MARIADB_CFLAGS" | sed -e s/-m64//)
10425            MARIADB_LIBS=$(printf '%s' "$MARIADB_LIBS" \
10426                | sed -e 's|/lib64/|/lib/|')
10427        fi
10428        FilterLibs "${MARIADB_LIBS}"
10429        MARIADB_LIBS="${filteredlibs}"
10430        AC_MSG_RESULT([includes '$MARIADB_CFLAGS', libraries '$MARIADB_LIBS'])
10431        AC_MSG_CHECKING([whether to bundle the MySQL/MariaDB client library])
10432        if test "$enable_bundle_mariadb" = "yes"; then
10433            AC_MSG_RESULT([yes])
10434            BUNDLE_MARIADB_CONNECTOR_C=TRUE
10435            LIBMARIADB=lib$(echo "${MARIADB_LIBS}" | sed -e 's/[[[:space:]]]\{1,\}-l\([[^[:space:]]]\{1,\}\)/\
10436\1\
10437/g' -e 's/^-l\([[^[:space:]]]\{1,\}\)[[[:space:]]]*/\
10438\1\
10439/g' | grep -E '(mysqlclient|mariadb)')
10440            if test "$_os" = "Darwin"; then
10441                LIBMARIADB=${LIBMARIADB}.dylib
10442                if test "$with_gssapi" != "no"; then
10443                    WITH_GSSAPI=TRUE
10444                    save_LIBS=$LIBS
10445                    AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
10446                        [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
10447                    GSSAPI_LIBS=$LIBS
10448                    LIBS=$save_LIBS
10449                fi
10450            elif test "$_os" = "WINNT"; then
10451                LIBMARIADB=${LIBMARIADB}.dll
10452            else
10453                LIBMARIADB=${LIBMARIADB}.so
10454                if test "$with_gssapi" != "no"; then
10455                    WITH_GSSAPI=TRUE
10456                    save_LIBS=$LIBS
10457                    AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
10458                        [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
10459                    GSSAPI_LIBS=$LIBS
10460                    LIBS=$save_LIBS
10461                fi
10462            fi
10463            LIBMARIADB_PATH=$($MARIADBCONFIG --variable=pkglibdir)
10464            AC_MSG_CHECKING([for $LIBMARIADB in $LIBMARIADB_PATH])
10465            if test -e "$LIBMARIADB_PATH/$LIBMARIADB"; then
10466                AC_MSG_RESULT([found.])
10467                PathFormat "$LIBMARIADB_PATH"
10468                LIBMARIADB_PATH="$formatted_path"
10469            else
10470                AC_MSG_ERROR([not found.])
10471            fi
10472        else
10473            AC_MSG_RESULT([no])
10474            BUNDLE_MARIADB_CONNECTOR_C=
10475        fi
10476    else
10477        AC_MSG_RESULT([internal])
10478        SYSTEM_MARIADB_CONNECTOR_C=
10479        MARIADB_CFLAGS="-I${WORKDIR}/UnpackedTarball/mariadb-connector-c/include"
10480        MARIADB_LIBS='-L$(gb_StaticLibrary_WORKDIR) -lmariadb-connector-c'
10481        BUILD_TYPE="$BUILD_TYPE MARIADB_CONNECTOR_C"
10482    fi
10483
10484    AC_SUBST(SYSTEM_MARIADB_CONNECTOR_C)
10485    AC_SUBST(MARIADB_CFLAGS)
10486    AC_SUBST(MARIADB_LIBS)
10487    AC_SUBST(LIBMARIADB)
10488    AC_SUBST(LIBMARIADB_PATH)
10489    AC_SUBST(BUNDLE_MARIADB_CONNECTOR_C)
10490fi
10491
10492dnl ===================================================================
10493dnl Check for system hsqldb
10494dnl ===================================================================
10495if test "$with_java" != "no" -a "$cross_compiling" != "yes"; then
10496    AC_MSG_CHECKING([which hsqldb to use])
10497    if test "$with_system_hsqldb" = "yes"; then
10498        AC_MSG_RESULT([external])
10499        SYSTEM_HSQLDB=TRUE
10500        if test -z $HSQLDB_JAR; then
10501            HSQLDB_JAR=/usr/share/java/hsqldb.jar
10502        fi
10503        if ! test -f $HSQLDB_JAR; then
10504               AC_MSG_ERROR(hsqldb.jar not found.)
10505        fi
10506        AC_MSG_CHECKING([whether hsqldb is 1.8.0.x])
10507        export HSQLDB_JAR
10508        if $PERL -e \
10509           'use Archive::Zip;
10510            my $file = "$ENV{'HSQLDB_JAR'}";
10511            my $zip = Archive::Zip->new( $file );
10512            my $mf = $zip->contents ( "META-INF/MANIFEST.MF" );
10513            if ( $mf =~ m/Specification-Version: 1.8.*/ )
10514            {
10515                push @l, split(/\n/, $mf);
10516                foreach my $line (@l)
10517                {
10518                    if ($line =~ m/Specification-Version:/)
10519                    {
10520                        ($t, $version) = split (/:/,$line);
10521                        $version =~ s/^\s//;
10522                        ($a, $b, $c, $d) = split (/\./,$version);
10523                        if ($c == "0" && $d > "8")
10524                        {
10525                            exit 0;
10526                        }
10527                        else
10528                        {
10529                            exit 1;
10530                        }
10531                    }
10532                }
10533            }
10534            else
10535            {
10536                exit 1;
10537            }'; then
10538            AC_MSG_RESULT([yes])
10539        else
10540            AC_MSG_ERROR([no, you need hsqldb >= 1.8.0.9 but < 1.8.1])
10541        fi
10542    else
10543        AC_MSG_RESULT([internal])
10544        SYSTEM_HSQLDB=
10545        BUILD_TYPE="$BUILD_TYPE HSQLDB"
10546        NEED_ANT=TRUE
10547    fi
10548else
10549    if test "$with_java" != "no" -a -z "$HSQLDB_JAR"; then
10550        BUILD_TYPE="$BUILD_TYPE HSQLDB"
10551    fi
10552fi
10553AC_SUBST(SYSTEM_HSQLDB)
10554AC_SUBST(HSQLDB_JAR)
10555
10556dnl ===================================================================
10557dnl Check for PostgreSQL stuff
10558dnl ===================================================================
10559AC_MSG_CHECKING([whether to build the PostgreSQL SDBC driver])
10560if test "x$enable_postgresql_sdbc" != "xno"; then
10561    AC_MSG_RESULT([yes])
10562    SCPDEFS="$SCPDEFS -DWITH_POSTGRESQL_SDBC"
10563
10564    if test "$with_krb5" = "yes" -a "$enable_openssl" = "no"; then
10565        AC_MSG_ERROR([krb5 needs OpenSSL, but --disable-openssl was given.])
10566    fi
10567    if test "$with_gssapi" = "yes" -a "$enable_openssl" = "no"; then
10568        AC_MSG_ERROR([GSSAPI needs OpenSSL, but --disable-openssl was given.])
10569    fi
10570
10571    postgres_interface=""
10572    if test "$with_system_postgresql" = "yes"; then
10573        postgres_interface="external PostgreSQL"
10574        SYSTEM_POSTGRESQL=TRUE
10575        if test "$_os" = Darwin; then
10576            supp_path=''
10577            for d in /Library/PostgreSQL/9.*/bin /sw/opt/postgresql/9.*/bin /opt/local/lib/postgresql9*/bin; do
10578                pg_supp_path="$P_SEP$d$pg_supp_path"
10579            done
10580        fi
10581        AC_PATH_PROG(PGCONFIG, pg_config, ,$PATH$pg_supp_path)
10582        if test -n "$PGCONFIG"; then
10583            POSTGRESQL_INC=-I$(${PGCONFIG} --includedir)
10584            POSTGRESQL_LIB="-L$(${PGCONFIG} --libdir)"
10585        else
10586            PKG_CHECK_MODULES(POSTGRESQL, libpq, [
10587              POSTGRESQL_INC=$POSTGRESQL_CFLAGS
10588              POSTGRESQL_LIB=$POSTGRESQL_LIBS
10589            ],[
10590              AC_MSG_ERROR([pg_config or 'pkg-config libpq' needed; set PGCONFIG if not in PATH])
10591            ])
10592        fi
10593        FilterLibs "${POSTGRESQL_LIB}"
10594        POSTGRESQL_LIB="${filteredlibs}"
10595    else
10596        # if/when anything else than PostgreSQL uses Kerberos,
10597        # move this out of `test "x$enable_postgresql_sdbc" != "xno"'
10598        WITH_KRB5=
10599        WITH_GSSAPI=
10600        case "$_os" in
10601        Darwin)
10602            # macOS has system MIT Kerberos 5 since 10.4
10603            if test "$with_krb5" != "no"; then
10604                WITH_KRB5=TRUE
10605                save_LIBS=$LIBS
10606                # Not sure whether it makes any sense here to search multiple potential libraries; it is not likely
10607                # that the libraries where these functions are located on macOS will change, is it?
10608                AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
10609                    [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
10610                KRB5_LIBS=$LIBS
10611                LIBS=$save_LIBS
10612                AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
10613                    [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
10614                KRB5_LIBS="$KRB5_LIBS $LIBS"
10615                LIBS=$save_LIBS
10616            fi
10617            if test "$with_gssapi" != "no"; then
10618                WITH_GSSAPI=TRUE
10619                save_LIBS=$LIBS
10620                AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
10621                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
10622                GSSAPI_LIBS=$LIBS
10623                LIBS=$save_LIBS
10624            fi
10625            ;;
10626        WINNT)
10627            if test "$with_krb5" = "yes" -o "$with_gssapi" = "yes"; then
10628                AC_MSG_ERROR([Refusing to enable MIT Kerberos 5 or GSSAPI on Windows.])
10629            fi
10630            ;;
10631        Linux|GNU|*BSD|DragonFly)
10632            if test "$with_krb5" != "no"; then
10633                WITH_KRB5=TRUE
10634                save_LIBS=$LIBS
10635                AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
10636                    [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
10637                KRB5_LIBS=$LIBS
10638                LIBS=$save_LIBS
10639                AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
10640                    [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
10641                KRB5_LIBS="$KRB5_LIBS $LIBS"
10642                LIBS=$save_LIBS
10643            fi
10644            if test "$with_gssapi" != "no"; then
10645                WITH_GSSAPI=TRUE
10646                save_LIBS=$LIBS
10647                AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
10648                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
10649                GSSAPI_LIBS=$LIBS
10650                LIBS=$save_LIBS
10651            fi
10652            ;;
10653        *)
10654            if test "$with_krb5" = "yes"; then
10655                WITH_KRB5=TRUE
10656                save_LIBS=$LIBS
10657                AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
10658                    [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
10659                KRB5_LIBS=$LIBS
10660                LIBS=$save_LIBS
10661                AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
10662                    [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
10663                KRB5_LIBS="$KRB5_LIBS $LIBS"
10664                LIBS=$save_LIBS
10665            fi
10666            if test "$with_gssapi" = "yes"; then
10667                WITH_GSSAPI=TRUE
10668                save_LIBS=$LIBS
10669                AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
10670                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
10671                LIBS=$save_LIBS
10672                GSSAPI_LIBS=$LIBS
10673            fi
10674        esac
10675
10676        if test -n "$with_libpq_path"; then
10677            SYSTEM_POSTGRESQL=TRUE
10678            postgres_interface="external libpq"
10679            POSTGRESQL_LIB="-L${with_libpq_path}/lib/"
10680            POSTGRESQL_INC=-I"${with_libpq_path}/include/"
10681        else
10682            SYSTEM_POSTGRESQL=
10683            postgres_interface="internal"
10684            POSTGRESQL_LIB=""
10685            POSTGRESQL_INC="%OVERRIDE_ME%"
10686            BUILD_TYPE="$BUILD_TYPE POSTGRESQL"
10687        fi
10688    fi
10689
10690    AC_MSG_CHECKING([PostgreSQL C interface])
10691    AC_MSG_RESULT([$postgres_interface])
10692
10693    if test "${SYSTEM_POSTGRESQL}" = "TRUE"; then
10694        AC_MSG_NOTICE([checking system PostgreSQL prerequisites])
10695        save_CFLAGS=$CFLAGS
10696        save_CPPFLAGS=$CPPFLAGS
10697        save_LIBS=$LIBS
10698        CPPFLAGS="${CPPFLAGS} ${POSTGRESQL_INC}"
10699        LIBS="${LIBS} ${POSTGRESQL_LIB}"
10700        AC_CHECK_HEADER([libpq-fe.h], [], [AC_MSG_ERROR([libpq-fe.h is needed])], [])
10701        AC_CHECK_LIB([pq], [PQconnectdbParams], [:],
10702            [AC_MSG_ERROR(libpq not found or too old. Need >= 9.0)], [])
10703        CFLAGS=$save_CFLAGS
10704        CPPFLAGS=$save_CPPFLAGS
10705        LIBS=$save_LIBS
10706    fi
10707    BUILD_POSTGRESQL_SDBC=TRUE
10708else
10709    AC_MSG_RESULT([no])
10710fi
10711AC_SUBST(WITH_KRB5)
10712AC_SUBST(WITH_GSSAPI)
10713AC_SUBST(GSSAPI_LIBS)
10714AC_SUBST(KRB5_LIBS)
10715AC_SUBST(BUILD_POSTGRESQL_SDBC)
10716AC_SUBST(SYSTEM_POSTGRESQL)
10717AC_SUBST(POSTGRESQL_INC)
10718AC_SUBST(POSTGRESQL_LIB)
10719
10720dnl ===================================================================
10721dnl Check for Firebird stuff
10722dnl ===================================================================
10723ENABLE_FIREBIRD_SDBC=
10724if test "$enable_firebird_sdbc" = "yes" ; then
10725    SCPDEFS="$SCPDEFS -DWITH_FIREBIRD_SDBC"
10726
10727    dnl ===================================================================
10728    dnl Check for system Firebird
10729    dnl ===================================================================
10730    AC_MSG_CHECKING([which Firebird to use])
10731    if test "$with_system_firebird" = "yes"; then
10732        AC_MSG_RESULT([external])
10733        SYSTEM_FIREBIRD=TRUE
10734        AC_PATH_PROG(FIREBIRDCONFIG, [fb_config])
10735        if test -z "$FIREBIRDCONFIG"; then
10736            AC_MSG_NOTICE([No fb_config -- using pkg-config])
10737            PKG_CHECK_MODULES([FIREBIRD], [fbclient >= 3], [FIREBIRD_PKGNAME=fbclient], [
10738                PKG_CHECK_MODULES([FIREBIRD], [fbembed], [FIREBIRD_PKGNAME=fbembed])
10739            ])
10740            FIREBIRD_VERSION=`pkg-config --modversion "$FIREBIRD_PKGNAME"`
10741        else
10742            AC_MSG_NOTICE([fb_config found])
10743            FIREBIRD_VERSION=`$FIREBIRDCONFIG --version`
10744            AC_MSG_CHECKING([for Firebird Client library])
10745            FIREBIRD_CFLAGS=`$FIREBIRDCONFIG --cflags`
10746            FIREBIRD_LIBS=`$FIREBIRDCONFIG --embedlibs`
10747            FilterLibs "${FIREBIRD_LIBS}"
10748            FIREBIRD_LIBS="${filteredlibs}"
10749        fi
10750        AC_MSG_RESULT([includes `$FIREBIRD_CFLAGS', libraries `$FIREBIRD_LIBS'])
10751        AC_MSG_CHECKING([Firebird version])
10752        if test -n "${FIREBIRD_VERSION}"; then
10753            FIREBIRD_MAJOR=`echo $FIREBIRD_VERSION | cut -d"." -f1`
10754            if test "$FIREBIRD_MAJOR" -ge "3"; then
10755                AC_MSG_RESULT([OK])
10756            else
10757                AC_MSG_ERROR([Ensure firebird >= 3 is installed])
10758            fi
10759        else
10760            save_CFLAGS="${CFLAGS}"
10761            CFLAGS="${CFLAGS} ${FIREBIRD_CFLAGS}"
10762            AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <ibase.h>
10763#if defined(FB_API_VER) && FB_API_VER == 30
10764int fb_api_is_30(void) { return 0; }
10765#else
10766#error "Wrong Firebird API version"
10767#endif]])],AC_MSG_RESULT([OK]),AC_MSG_ERROR([Ensure firebird 3.0.x is installed]))
10768            CFLAGS="$save_CFLAGS"
10769        fi
10770        ENABLE_FIREBIRD_SDBC=TRUE
10771        AC_DEFINE([ENABLE_FIREBIRD_SDBC],1)
10772    elif test "$enable_database_connectivity" = no; then
10773        AC_MSG_RESULT([none])
10774    elif test "$cross_compiling" = "yes"; then
10775        AC_MSG_RESULT([none])
10776    else
10777        dnl Embedded Firebird has version 3.0
10778        dnl We need libatomic_ops for any non X86/X64 system
10779        if test "${CPUNAME}" != INTEL -a "${CPUNAME}" != X86_64; then
10780            dnl ===================================================================
10781            dnl Check for system libatomic_ops
10782            dnl ===================================================================
10783            libo_CHECK_SYSTEM_MODULE([libatomic_ops],[LIBATOMIC_OPS],[atomic_ops >= 0.7.2])
10784            if test "$with_system_libatomic_ops" = "yes"; then
10785                SYSTEM_LIBATOMIC_OPS=TRUE
10786                AC_CHECK_HEADERS(atomic_ops.h, [],
10787                [AC_MSG_ERROR(atomic_ops.h not found. install libatomic_ops)], [])
10788            else
10789                SYSTEM_LIBATOMIC_OPS=
10790                LIBATOMIC_OPS_CFLAGS="-I${WORKDIR}/UnpackedTarball/libatomic_ops/include"
10791                LIBATOMIC_OPS_LIBS="-latomic_ops"
10792                BUILD_TYPE="$BUILD_TYPE LIBATOMIC_OPS"
10793            fi
10794        fi
10795
10796        AC_MSG_RESULT([internal])
10797        SYSTEM_FIREBIRD=
10798        FIREBIRD_CFLAGS="-I${WORKDIR}/UnpackedTarball/firebird/gen/Release/firebird/include"
10799        FIREBIRD_LIBS="-lfbclient"
10800
10801        if test "$with_system_libtommath" = "yes"; then
10802            SYSTEM_LIBTOMMATH=TRUE
10803            dnl check for tommath presence
10804            save_LIBS=$LIBS
10805            AC_CHECK_HEADER(tommath.h,,AC_MSG_ERROR(Include file for tommath not found - please install development tommath package))
10806            AC_CHECK_LIB(tommath, mp_init, LIBTOMMATH_LIBS=-ltommath, AC_MSG_ERROR(Library tommath not found - please install development tommath package))
10807            LIBS=$save_LIBS
10808        else
10809            SYSTEM_LIBTOMMATH=
10810            LIBTOMMATH_CFLAGS="-I${WORKDIR}/UnpackedTarball/libtommath"
10811            LIBTOMMATH_LIBS="-ltommath"
10812            BUILD_TYPE="$BUILD_TYPE LIBTOMMATH"
10813        fi
10814
10815        BUILD_TYPE="$BUILD_TYPE FIREBIRD"
10816        ENABLE_FIREBIRD_SDBC=TRUE
10817        AC_DEFINE([ENABLE_FIREBIRD_SDBC],1)
10818    fi
10819fi
10820AC_SUBST(ENABLE_FIREBIRD_SDBC)
10821AC_SUBST(SYSTEM_LIBATOMIC_OPS)
10822AC_SUBST(LIBATOMIC_OPS_CFLAGS)
10823AC_SUBST(LIBATOMIC_OPS_LIBS)
10824AC_SUBST(SYSTEM_FIREBIRD)
10825AC_SUBST(FIREBIRD_CFLAGS)
10826AC_SUBST(FIREBIRD_LIBS)
10827AC_SUBST(SYSTEM_LIBTOMMATH)
10828AC_SUBST(LIBTOMMATH_CFLAGS)
10829AC_SUBST(LIBTOMMATH_LIBS)
10830
10831dnl ===================================================================
10832dnl Check for system curl
10833dnl ===================================================================
10834libo_CHECK_SYSTEM_MODULE([curl],[CURL],[libcurl >= 7.68.0],enabled)
10835
10836dnl ===================================================================
10837dnl Check for system boost
10838dnl ===================================================================
10839AC_MSG_CHECKING([which boost to use])
10840if test "$with_system_boost" = "yes"; then
10841    AC_MSG_RESULT([external])
10842    SYSTEM_BOOST=TRUE
10843    AX_BOOST_BASE([1.69],,[AC_MSG_ERROR([no suitable Boost found])])
10844    AX_BOOST_DATE_TIME
10845    AX_BOOST_FILESYSTEM
10846    AX_BOOST_IOSTREAMS
10847    AX_BOOST_LOCALE
10848    AC_LANG_PUSH([C++])
10849    save_CXXFLAGS=$CXXFLAGS
10850    CXXFLAGS="$CXXFLAGS $BOOST_CPPFLAGS $CXXFLAGS_CXX11"
10851    AC_CHECK_HEADER(boost/shared_ptr.hpp, [],
10852       [AC_MSG_ERROR(boost/shared_ptr.hpp not found. install boost)], [])
10853    AC_CHECK_HEADER(boost/spirit/include/classic_core.hpp, [],
10854       [AC_MSG_ERROR(boost/spirit/include/classic_core.hpp not found. install boost >= 1.36)], [])
10855    CXXFLAGS=$save_CXXFLAGS
10856    AC_LANG_POP([C++])
10857    # this is in m4/ax_boost_base.m4
10858    FilterLibs "${BOOST_LDFLAGS}"
10859    BOOST_LDFLAGS="${filteredlibs}"
10860else
10861    AC_MSG_RESULT([internal])
10862    BUILD_TYPE="$BUILD_TYPE BOOST"
10863    SYSTEM_BOOST=
10864    if test "${COM}" = "GCC" -o "${COM_IS_CLANG}" = "TRUE"; then
10865        # use warning-suppressing wrapper headers
10866        BOOST_CPPFLAGS="-I${SRC_ROOT}/external/boost/include -I${WORKDIR}/UnpackedTarball/boost"
10867    else
10868        BOOST_CPPFLAGS="-I${WORKDIR}/UnpackedTarball/boost"
10869    fi
10870fi
10871AC_SUBST(SYSTEM_BOOST)
10872
10873dnl ===================================================================
10874dnl Check for system mdds
10875dnl ===================================================================
10876MDDS_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/mdds/include"
10877libo_CHECK_SYSTEM_MODULE([mdds],[MDDS],[mdds-2.1 >= 2.1.0])
10878
10879dnl ===================================================================
10880dnl Check for system dragonbox
10881dnl ===================================================================
10882AC_MSG_CHECKING([which dragonbox to use])
10883if test "$with_system_dragonbox" = "yes"; then
10884    AC_MSG_RESULT([external])
10885    SYSTEM_DRAGONBOX=TRUE
10886    AC_LANG_PUSH([C++])
10887    save_CPPFLAGS=$CPPFLAGS
10888    # This is where upstream installs to, unfortunately no .pc or so...
10889    DRAGONBOX_CFLAGS=-I/usr/include/dragonbox-1.1.3
10890    CPPFLAGS="$CPPFLAGS $DRAGONBOX_CFLAGS"
10891    AC_CHECK_HEADER([dragonbox/dragonbox.h], [],
10892       [AC_MSG_ERROR([dragonbox/dragonbox.h not found. install dragonbox])], [])
10893    AC_LANG_POP([C++])
10894    CPPFLAGS=$save_CPPFLAGS
10895else
10896    AC_MSG_RESULT([internal])
10897    BUILD_TYPE="$BUILD_TYPE DRAGONBOX"
10898    SYSTEM_DRAGONBOX=
10899fi
10900AC_SUBST([SYSTEM_DRAGONBOX])
10901AC_SUBST([DRAGONBOX_CFLAGS])
10902
10903dnl ===================================================================
10904dnl Check for system frozen
10905dnl ===================================================================
10906AC_MSG_CHECKING([which frozen to use])
10907if test "$with_system_frozen" = "yes"; then
10908    AC_MSG_RESULT([external])
10909    SYSTEM_FROZEN=TRUE
10910    AC_LANG_PUSH([C++])
10911    save_CPPFLAGS=$CPPFLAGS
10912    AC_CHECK_HEADER([frozen/unordered_map.h], [],
10913       [AC_MSG_ERROR([frozen/unordered_map.h not found. install frozen headers])], [])
10914    AC_LANG_POP([C++])
10915    CPPFLAGS=$save_CPPFLAGS
10916else
10917    AC_MSG_RESULT([internal])
10918    BUILD_TYPE="$BUILD_TYPE FROZEN"
10919    SYSTEM_FROZEN=
10920fi
10921AC_SUBST([SYSTEM_FROZEN])
10922AC_SUBST([FROZEN_CFLAGS])
10923
10924dnl ===================================================================
10925dnl Check for system libfixmath
10926dnl ===================================================================
10927AC_MSG_CHECKING([which libfixmath to use])
10928if test "$with_system_libfixmath" = "yes"; then
10929    AC_MSG_RESULT([external])
10930    SYSTEM_LIBFIXMATH=TRUE
10931    AC_LANG_PUSH([C++])
10932    AC_CHECK_HEADER([libfixmath/fix16.hpp], [],
10933       [AC_MSG_ERROR([libfixmath/fix16.hpp not found. install libfixmath])], [])
10934    AC_CHECK_LIB([libfixmath], [fix16_mul], [LIBFIXMATH_LIBS=-llibfixmath],
10935                 [AC_CHECK_LIB([fixmath], [fix16_mul], [LIBFIXMATH_LIBS=-lfixmath],
10936                               [AC_MSG_ERROR(libfixmath lib not found or functional)])])
10937    AC_LANG_POP([C++])
10938else
10939    AC_MSG_RESULT([internal])
10940    SYSTEM_LIBFIXMATH=
10941    LIBFIXMATH_LIBS=
10942fi
10943AC_SUBST([SYSTEM_LIBFIXMATH])
10944AC_SUBST([LIBFIXMATH_LIBS])
10945
10946dnl ===================================================================
10947dnl Check for system glm
10948dnl ===================================================================
10949AC_MSG_CHECKING([which glm to use])
10950if test "$with_system_glm" = "yes"; then
10951    AC_MSG_RESULT([external])
10952    SYSTEM_GLM=TRUE
10953    AC_LANG_PUSH([C++])
10954    AC_CHECK_HEADER([glm/glm.hpp], [],
10955       [AC_MSG_ERROR([glm/glm.hpp not found. install glm])], [])
10956    AC_LANG_POP([C++])
10957else
10958    AC_MSG_RESULT([internal])
10959    BUILD_TYPE="$BUILD_TYPE GLM"
10960    SYSTEM_GLM=
10961    GLM_CFLAGS="${ISYSTEM}${WORKDIR}/UnpackedTarball/glm"
10962fi
10963AC_SUBST([GLM_CFLAGS])
10964AC_SUBST([SYSTEM_GLM])
10965
10966dnl ===================================================================
10967dnl Check for system odbc
10968dnl ===================================================================
10969AC_MSG_CHECKING([which odbc headers to use])
10970if test "$with_system_odbc" = "yes" -o '(' "$with_system_headers" = "yes" -a "$with_system_odbc" = "auto" ')' -o '(' "$_os" = "WINNT" -a  "$with_system_odbc" != "no" ')'; then
10971    AC_MSG_RESULT([external])
10972    SYSTEM_ODBC_HEADERS=TRUE
10973
10974    if test "$build_os" = "cygwin" -o "$build_os" = "wsl" -o -n "$WSL_ONLY_AS_HELPER"; then
10975        save_CPPFLAGS=$CPPFLAGS
10976        find_winsdk
10977        PathFormat "$winsdktest"
10978        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"
10979        AC_CHECK_HEADER(sqlext.h, [],
10980            [AC_MSG_ERROR(odbc not found. install odbc)],
10981            [#include <windows.h>])
10982        CPPFLAGS=$save_CPPFLAGS
10983    else
10984        AC_CHECK_HEADER(sqlext.h, [],
10985            [AC_MSG_ERROR(odbc not found. install odbc)],[])
10986    fi
10987elif test "$enable_database_connectivity" = no; then
10988    AC_MSG_RESULT([none])
10989else
10990    AC_MSG_RESULT([internal])
10991    SYSTEM_ODBC_HEADERS=
10992fi
10993AC_SUBST(SYSTEM_ODBC_HEADERS)
10994
10995dnl ===================================================================
10996dnl Check for system NSS
10997dnl ===================================================================
10998if test "$enable_fuzzers" != "yes" -a "$enable_nss" = "yes"; then
10999    libo_CHECK_SYSTEM_MODULE([nss],[NSS],[nss >= 3.9.3 nspr >= 4.8],,system-if-linux)
11000    AC_DEFINE(HAVE_FEATURE_NSS)
11001    ENABLE_NSS=TRUE
11002elif test $_os != iOS -a "$enable_openssl" != "no"; then
11003    with_tls=openssl
11004fi
11005AC_SUBST(ENABLE_NSS)
11006
11007dnl ===================================================================
11008dnl Enable LDAP support
11009dnl ===================================================================
11010
11011if test "$test_openldap" = yes; then
11012    AC_MSG_CHECKING([whether to enable LDAP support])
11013    if test "$enable_ldap" = yes -a \( "$enable_openssl" = yes -o "$with_system_openldap" = yes \); then
11014        AC_MSG_RESULT([yes])
11015        ENABLE_LDAP=TRUE
11016    else
11017        if test "$enable_ldap" != "yes"; then
11018            AC_MSG_RESULT([no])
11019        else
11020            AC_MSG_RESULT([no (needs OPENSSL or system openldap)])
11021        fi
11022    fi
11023
11024dnl ===================================================================
11025dnl Check for system openldap
11026dnl ===================================================================
11027
11028    if test "$ENABLE_LDAP" = TRUE; then
11029        AC_MSG_CHECKING([which openldap library to use])
11030        if test "$with_system_openldap" = yes; then
11031            AC_MSG_RESULT([external])
11032            SYSTEM_OPENLDAP=TRUE
11033            AC_CHECK_HEADERS(ldap.h, [], [AC_MSG_ERROR(ldap.h not found. install openldap libs)], [])
11034            AC_CHECK_LIB([ldap], [ldap_simple_bind_s], [:], [AC_MSG_ERROR(openldap lib not found or functional)], [])
11035            AC_CHECK_LIB([ldap], [ldap_set_option], [:], [AC_MSG_ERROR(openldap lib not found or functional)], [])
11036        else
11037            AC_MSG_RESULT([internal])
11038            BUILD_TYPE="$BUILD_TYPE OPENLDAP"
11039        fi
11040    fi
11041fi
11042
11043AC_SUBST(ENABLE_LDAP)
11044AC_SUBST(SYSTEM_OPENLDAP)
11045
11046dnl ===================================================================
11047dnl Check for TLS/SSL and cryptographic implementation to use
11048dnl ===================================================================
11049AC_MSG_CHECKING([which TLS/SSL and cryptographic implementation to use])
11050if test -n "$with_tls"; then
11051    case $with_tls in
11052    openssl)
11053        AC_DEFINE(USE_TLS_OPENSSL)
11054        TLS=OPENSSL
11055        AC_MSG_RESULT([$TLS])
11056
11057        if test "$enable_openssl" != "yes"; then
11058            AC_MSG_ERROR(["Disabling OpenSSL was requested, but the requested TLS to use is actually OpenSSL."])
11059        fi
11060
11061        # warn that OpenSSL has been selected but not all TLS code has this option
11062        AC_MSG_WARN([TLS/SSL implementation to use is OpenSSL but some code may still depend on NSS])
11063        add_warning "TLS/SSL implementation to use is OpenSSL but some code may still depend on NSS"
11064        ;;
11065    nss)
11066        AC_DEFINE(USE_TLS_NSS)
11067        TLS=NSS
11068        AC_MSG_RESULT([$TLS])
11069        ;;
11070    no)
11071        AC_MSG_RESULT([none])
11072        AC_MSG_WARN([Skipping TLS/SSL])
11073        ;;
11074    *)
11075        AC_MSG_RESULT([])
11076        AC_MSG_ERROR([unsupported implementation $with_tls. Supported are:
11077openssl - OpenSSL
11078nss - Mozilla's Network Security Services (NSS)
11079    ])
11080        ;;
11081    esac
11082else
11083    # default to using NSS, it results in smaller oox lib
11084    AC_DEFINE(USE_TLS_NSS)
11085    TLS=NSS
11086    AC_MSG_RESULT([$TLS])
11087fi
11088AC_SUBST(TLS)
11089
11090dnl ===================================================================
11091dnl Check for system sane
11092dnl ===================================================================
11093AC_MSG_CHECKING([which sane header to use])
11094if test "$with_system_sane" = "yes"; then
11095    AC_MSG_RESULT([external])
11096    AC_CHECK_HEADER(sane/sane.h, [],
11097      [AC_MSG_ERROR(sane not found. install sane)], [])
11098else
11099    AC_MSG_RESULT([internal])
11100    BUILD_TYPE="$BUILD_TYPE SANE"
11101fi
11102
11103dnl ===================================================================
11104dnl Check for system icu
11105dnl ===================================================================
11106ICU_MAJOR=74
11107ICU_MINOR=2
11108ICU_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/icu/source/i18n -I${WORKDIR}/UnpackedTarball/icu/source/common"
11109ICU_LIBS_internal="-L${WORKDIR}/UnpackedTarball/icu/source/lib"
11110libo_CHECK_SYSTEM_MODULE([icu],[ICU],[icu-i18n >= 66])
11111if test "$SYSTEM_ICU" = TRUE; then
11112    AC_LANG_PUSH([C++])
11113    AC_MSG_CHECKING([for unicode/rbbi.h])
11114    AC_PREPROC_IFELSE([AC_LANG_SOURCE([[unicode/rbbi.h]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([icu headers not found])])
11115    AC_LANG_POP([C++])
11116
11117    ICU_VERSION=`$PKG_CONFIG --modversion icu-i18n 2>/dev/null`
11118    ICU_MAJOR=`echo $ICU_VERSION | cut -d"." -f1`
11119    ICU_MINOR=`echo $ICU_VERSION | cut -d"." -f2`
11120
11121    if test "$CROSS_COMPILING" != TRUE; then
11122        # using the system icu tools can lead to version confusion, use the
11123        # ones from the build environment when cross-compiling
11124        AC_PATH_PROG(SYSTEM_GENBRK, genbrk, [], [$PATH:/usr/sbin:/sbin])
11125        if test -z "$SYSTEM_GENBRK"; then
11126            AC_MSG_ERROR([\'genbrk\' not found in \$PATH, install the icu development tool \'genbrk\'])
11127        fi
11128        AC_PATH_PROG(SYSTEM_GENCCODE, genccode, [], [$PATH:/usr/sbin:/sbin:/usr/local/sbin])
11129        if test -z "$SYSTEM_GENCCODE"; then
11130            AC_MSG_ERROR([\'genccode\' not found in \$PATH, install the icu development tool \'genccode\'])
11131        fi
11132        AC_PATH_PROG(SYSTEM_GENCMN, gencmn, [], [$PATH:/usr/sbin:/sbin:/usr/local/sbin])
11133        if test -z "$SYSTEM_GENCMN"; then
11134            AC_MSG_ERROR([\'gencmn\' not found in \$PATH, install the icu development tool \'gencmn\'])
11135        fi
11136    fi
11137fi
11138
11139AC_SUBST(SYSTEM_GENBRK)
11140AC_SUBST(SYSTEM_GENCCODE)
11141AC_SUBST(SYSTEM_GENCMN)
11142AC_SUBST(ICU_MAJOR)
11143AC_SUBST(ICU_MINOR)
11144
11145dnl ==================================================================
11146dnl CURL
11147dnl ==================================================================
11148if test "$enable_curl" = "yes"; then
11149    AC_DEFINE([HAVE_FEATURE_CURL])
11150fi
11151
11152dnl ==================================================================
11153dnl Breakpad
11154dnl ==================================================================
11155DEFAULT_CRASHDUMP_VALUE="true"
11156AC_MSG_CHECKING([whether to enable breakpad])
11157if test "$enable_breakpad" != yes; then
11158    AC_MSG_RESULT([no])
11159else
11160    if test "$enable_curl" != "yes"; then
11161        AC_MSG_ERROR([--disable-breakpad must be used when --disable-curl is used])
11162    fi
11163    AC_MSG_RESULT([yes])
11164    ENABLE_BREAKPAD="TRUE"
11165    AC_DEFINE(ENABLE_BREAKPAD)
11166    AC_DEFINE(HAVE_FEATURE_BREAKPAD, 1)
11167    BUILD_TYPE="$BUILD_TYPE BREAKPAD"
11168
11169    AC_MSG_CHECKING([for disable crash dump])
11170    if test "$enable_crashdump" = no; then
11171        DEFAULT_CRASHDUMP_VALUE="false"
11172        AC_MSG_RESULT([yes])
11173    else
11174       AC_MSG_RESULT([no])
11175    fi
11176
11177    AC_MSG_CHECKING([for crashreport config])
11178    if test "$with_symbol_config" = "no"; then
11179        BREAKPAD_SYMBOL_CONFIG="invalid"
11180        AC_MSG_RESULT([no])
11181    else
11182        BREAKPAD_SYMBOL_CONFIG="$with_symbol_config"
11183        AC_DEFINE(BREAKPAD_SYMBOL_CONFIG)
11184        AC_MSG_RESULT([yes])
11185    fi
11186    AC_SUBST(BREAKPAD_SYMBOL_CONFIG)
11187fi
11188AC_SUBST(ENABLE_BREAKPAD)
11189AC_SUBST(DEFAULT_CRASHDUMP_VALUE)
11190
11191dnl ==================================================================
11192dnl libcmis
11193dnl ==================================================================
11194if test "$enable_libcmis" = "yes"; then
11195    if test "$enable_curl" != "yes"; then
11196        AC_MSG_ERROR([--disable-libcmis must be used when --disable-curl is used])
11197    fi
11198fi
11199
11200dnl ===================================================================
11201dnl Orcus
11202dnl ===================================================================
11203libo_CHECK_SYSTEM_MODULE([orcus],[ORCUS],[liborcus-0.18 >= 0.19.1])
11204if test "$with_system_orcus" != "yes"; then
11205    if test "$SYSTEM_BOOST" = "TRUE"; then
11206        dnl Link with Boost.System
11207        dnl This seems to be necessary since boost 1.50 (1.48 does not need it,
11208        dnl 1.49 is untested). The macro BOOST_THREAD_DONT_USE_SYSTEM mentioned
11209        dnl in documentation has no effect.
11210        AX_BOOST_SYSTEM
11211    fi
11212fi
11213dnl FIXME by renaming SYSTEM_LIBORCUS to SYSTEM_ORCUS in the build system world
11214SYSTEM_LIBORCUS=$SYSTEM_ORCUS
11215AC_SUBST([BOOST_SYSTEM_LIB])
11216AC_SUBST(SYSTEM_LIBORCUS)
11217
11218dnl ===================================================================
11219dnl HarfBuzz
11220dnl ===================================================================
11221harfbuzz_required_version=5.1.0
11222
11223GRAPHITE_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/graphite/include -DGRAPHITE2_STATIC"
11224HARFBUZZ_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/harfbuzz/src"
11225case "$_os" in
11226    Linux)
11227        GRAPHITE_LIBS_internal='$(gb_StaticLibrary_WORKDIR)/libgraphite.a'
11228        HARFBUZZ_LIBS_internal="${WORKDIR}/UnpackedTarball/harfbuzz/src/.libs/libharfbuzz.a"
11229        ;;
11230    *)
11231        GRAPHITE_LIBS_internal='-L$(gb_StaticLibrary_WORKDIR) -lgraphite'
11232        HARFBUZZ_LIBS_internal="-L${WORKDIR}/UnpackedTarball/harfbuzz/src/.libs -lharfbuzz"
11233        ;;
11234esac
11235libo_CHECK_SYSTEM_MODULE([graphite],[GRAPHITE],[graphite2 >= 0.9.3])
11236libo_CHECK_SYSTEM_MODULE([harfbuzz],[HARFBUZZ],[harfbuzz-icu >= $harfbuzz_required_version])
11237
11238if test "$COM" = "MSC"; then # override the above
11239    GRAPHITE_LIBS='$(gb_StaticLibrary_WORKDIR)/graphite.lib'
11240    HARFBUZZ_LIBS="${WORKDIR}/UnpackedTarball/harfbuzz/src/.libs/libharfbuzz.lib"
11241fi
11242
11243if test "$with_system_harfbuzz" = "yes"; then
11244    if test "$with_system_graphite" = "no"; then
11245        AC_MSG_ERROR([--with-system-graphite must be used when --with-system-harfbuzz is used])
11246    fi
11247    AC_MSG_CHECKING([whether system Harfbuzz is built with Graphite support])
11248    save_LIBS="$LIBS"
11249    save_CFLAGS="$CFLAGS"
11250    LIBS="$LIBS $HARFBUZZ_LIBS"
11251    CFLAGS="$CFLAGS $HARFBUZZ_CFLAGS"
11252    AC_CHECK_FUNC(hb_graphite2_face_get_gr_face,,[AC_MSG_ERROR([Harfbuzz needs to be built with Graphite support.])])
11253    LIBS="$save_LIBS"
11254    CFLAGS="$save_CFLAGS"
11255else
11256    if test "$with_system_graphite" = "yes"; then
11257        AC_MSG_ERROR([--without-system-graphite must be used when --without-system-harfbuzz is used])
11258    fi
11259fi
11260
11261if test "$USING_X11" = TRUE; then
11262    AC_PATH_X
11263    AC_PATH_XTRA
11264    CPPFLAGS="$CPPFLAGS $X_CFLAGS"
11265
11266    if test -z "$x_includes"; then
11267        x_includes="default_x_includes"
11268    fi
11269    if test -z "$x_libraries"; then
11270        x_libraries="default_x_libraries"
11271    fi
11272    CFLAGS="$CFLAGS $X_CFLAGS"
11273    LDFLAGS="$LDFLAGS $X_LDFLAGS $X_LIBS"
11274    AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS", [AC_MSG_ERROR([X Development libraries not found])])
11275else
11276    x_includes="no_x_includes"
11277    x_libraries="no_x_libraries"
11278fi
11279
11280if test "$USING_X11" = TRUE; then
11281    dnl ===================================================================
11282    dnl Check for extension headers
11283    dnl ===================================================================
11284    AC_CHECK_HEADERS(X11/extensions/shape.h,[],[AC_MSG_ERROR([libXext headers not found])],
11285     [#include <X11/extensions/shape.h>])
11286
11287    # vcl needs ICE and SM
11288    AC_CHECK_HEADERS(X11/ICE/ICElib.h,[],[AC_MSG_ERROR([libICE headers not found])])
11289    AC_CHECK_LIB([ICE], [IceConnectionNumber], [:],
11290        [AC_MSG_ERROR(ICE library not found)])
11291    AC_CHECK_HEADERS(X11/SM/SMlib.h,[],[AC_MSG_ERROR([libSM headers not found])])
11292    AC_CHECK_LIB([SM], [SmcOpenConnection], [:],
11293        [AC_MSG_ERROR(SM library not found)])
11294fi
11295
11296if test "$USING_X11" = TRUE -a "$ENABLE_JAVA" != ""; then
11297    # bean/native/unix/com_sun_star_comp_beans_LocalOfficeWindow.c needs Xt
11298    AC_CHECK_HEADERS(X11/Intrinsic.h,[],[AC_MSG_ERROR([libXt headers not found])])
11299fi
11300
11301dnl ===================================================================
11302dnl Check for system Xrender
11303dnl ===================================================================
11304AC_MSG_CHECKING([whether to use Xrender])
11305if test "$USING_X11" = TRUE -a  "$test_xrender" = "yes"; then
11306    AC_MSG_RESULT([yes])
11307    PKG_CHECK_MODULES(XRENDER, xrender)
11308    XRENDER_CFLAGS=$(printf '%s' "$XRENDER_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11309    FilterLibs "${XRENDER_LIBS}"
11310    XRENDER_LIBS="${filteredlibs}"
11311    AC_CHECK_LIB([Xrender], [XRenderQueryVersion], [:],
11312      [AC_MSG_ERROR(libXrender not found or functional)], [])
11313    AC_CHECK_HEADER(X11/extensions/Xrender.h, [],
11314      [AC_MSG_ERROR(Xrender not found. install X)], [])
11315else
11316    AC_MSG_RESULT([no])
11317fi
11318AC_SUBST(XRENDER_CFLAGS)
11319AC_SUBST(XRENDER_LIBS)
11320
11321dnl ===================================================================
11322dnl Check for XRandr
11323dnl ===================================================================
11324AC_MSG_CHECKING([whether to enable RandR support])
11325if test "$USING_X11" = TRUE -a "$test_randr" = "yes" -a \( "$enable_randr" = "yes" -o "$enable_randr" = "TRUE" \); then
11326    AC_MSG_RESULT([yes])
11327    PKG_CHECK_MODULES(XRANDR, xrandr >= 1.2, ENABLE_RANDR="TRUE", ENABLE_RANDR="")
11328    if test "$ENABLE_RANDR" != "TRUE"; then
11329        AC_CHECK_HEADER(X11/extensions/Xrandr.h, [],
11330                    [AC_MSG_ERROR([X11/extensions/Xrandr.h could not be found. X11 dev missing?])], [])
11331        XRANDR_CFLAGS=" "
11332        AC_CHECK_LIB([Xrandr], [XRRQueryExtension], [:],
11333          [ AC_MSG_ERROR(libXrandr not found or functional) ], [])
11334        XRANDR_LIBS="-lXrandr "
11335        ENABLE_RANDR="TRUE"
11336    fi
11337    XRANDR_CFLAGS=$(printf '%s' "$XRANDR_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11338    FilterLibs "${XRANDR_LIBS}"
11339    XRANDR_LIBS="${filteredlibs}"
11340else
11341    ENABLE_RANDR=""
11342    AC_MSG_RESULT([no])
11343fi
11344AC_SUBST(XRANDR_CFLAGS)
11345AC_SUBST(XRANDR_LIBS)
11346AC_SUBST(ENABLE_RANDR)
11347
11348if test -z "$with_webdav"; then
11349    with_webdav=$test_webdav
11350fi
11351
11352AC_MSG_CHECKING([for WebDAV support])
11353case "$with_webdav" in
11354no)
11355    AC_MSG_RESULT([no])
11356    WITH_WEBDAV=""
11357    ;;
11358*)
11359    AC_MSG_RESULT([yes])
11360    # curl is already mandatory (almost) and checked elsewhere
11361    if test "$enable_curl" = "no"; then
11362        AC_MSG_ERROR(["--without-webdav must be used when --disable-curl is used"])
11363    fi
11364    WITH_WEBDAV=TRUE
11365    ;;
11366esac
11367AC_SUBST(WITH_WEBDAV)
11368
11369dnl ===================================================================
11370dnl Check for disabling cve_tests
11371dnl ===================================================================
11372AC_MSG_CHECKING([whether to execute CVE tests])
11373if test "$enable_cve_tests" = "no"; then
11374    AC_MSG_RESULT([no])
11375    DISABLE_CVE_TESTS=TRUE
11376    AC_SUBST(DISABLE_CVE_TESTS)
11377else
11378    AC_MSG_RESULT([yes])
11379fi
11380
11381dnl ===================================================================
11382dnl Check for system openssl
11383dnl ===================================================================
11384ENABLE_OPENSSL=
11385AC_MSG_CHECKING([whether to disable OpenSSL usage])
11386if test "$enable_openssl" = "yes"; then
11387    AC_MSG_RESULT([no])
11388    ENABLE_OPENSSL=TRUE
11389    if test "$_os" = Darwin ; then
11390        # OpenSSL is deprecated when building for 10.7 or later.
11391        #
11392        # https://stackoverflow.com/questions/7406946/why-is-apple-deprecating-openssl-in-macos-10-7-lion
11393        # https://stackoverflow.com/questions/7475914/libcrypto-deprecated-on-mac-os-x-10-7-lion
11394
11395        with_system_openssl=no
11396        libo_CHECK_SYSTEM_MODULE([openssl],[OPENSSL],[openssl])
11397    elif test "$_os" = "FreeBSD" -o "$_os" = "NetBSD" -o "$_os" = "OpenBSD" -o "$_os" = "DragonFly" \
11398            && test "$with_system_openssl" != "no"; then
11399        with_system_openssl=yes
11400        SYSTEM_OPENSSL=TRUE
11401        OPENSSL_CFLAGS=
11402        OPENSSL_LIBS="-lssl -lcrypto"
11403    else
11404        libo_CHECK_SYSTEM_MODULE([openssl],[OPENSSL],[openssl])
11405        if test -n "${SYSTEM_OPENSSL}"; then
11406            AC_DEFINE([SYSTEM_OPENSSL])
11407        fi
11408    fi
11409    if test "$with_system_openssl" = "yes"; then
11410        AC_MSG_CHECKING([whether openssl supports SHA512])
11411        AC_LANG_PUSH([C])
11412        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <openssl/sha.h>]],[[
11413            SHA512_CTX context;
11414]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no, openssl too old. Need >= 0.9.8.])])
11415        AC_LANG_POP(C)
11416    fi
11417else
11418    AC_MSG_RESULT([yes])
11419
11420    # warn that although OpenSSL is disabled, system libraries may depend on it
11421    AC_MSG_WARN([OpenSSL has been disabled. No code compiled here will make use of it but system libraries may create indirect dependencies])
11422    add_warning "OpenSSL has been disabled. No code compiled here will make use of it but system libraries may create indirect dependencies"
11423fi
11424
11425AC_SUBST([ENABLE_OPENSSL])
11426
11427if test "$enable_cipher_openssl_backend" = yes && test "$ENABLE_OPENSSL" != TRUE; then
11428    if test "$libo_fuzzed_enable_cipher_openssl_backend" = yes; then
11429        AC_MSG_NOTICE([Resetting --enable-cipher-openssl-backend=no])
11430        enable_cipher_openssl_backend=no
11431    else
11432        AC_MSG_ERROR([--enable-cipher-openssl-backend needs OpenSSL, but --disable-openssl was given.])
11433    fi
11434fi
11435AC_MSG_CHECKING([whether to enable the OpenSSL backend for rtl/cipher.h])
11436ENABLE_CIPHER_OPENSSL_BACKEND=
11437if test "$enable_cipher_openssl_backend" = yes; then
11438    AC_MSG_RESULT([yes])
11439    ENABLE_CIPHER_OPENSSL_BACKEND=TRUE
11440else
11441    AC_MSG_RESULT([no])
11442fi
11443AC_SUBST([ENABLE_CIPHER_OPENSSL_BACKEND])
11444
11445dnl ===================================================================
11446dnl Select the crypto backends used by LO
11447dnl ===================================================================
11448
11449if test "$build_crypto" = yes; then
11450    if test "$OS" = WNT; then
11451        BUILD_TYPE="$BUILD_TYPE CRYPTO_MSCAPI"
11452        AC_DEFINE([USE_CRYPTO_MSCAPI])
11453    elif test "$ENABLE_NSS" = TRUE; then
11454        BUILD_TYPE="$BUILD_TYPE CRYPTO_NSS"
11455        AC_DEFINE([USE_CRYPTO_NSS])
11456    fi
11457fi
11458
11459ARGON2_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/argon2/include"
11460if test "$COM" = "MSC"; then
11461    ARGON2_LIBS_internal="${WORKDIR}/UnpackedTarball/argon2/vs2015/build/Argon2OptDll.lib"
11462else
11463    ARGON2_LIBS_internal="${WORKDIR}/UnpackedTarball/argon2/libargon2.a"
11464fi
11465libo_CHECK_SYSTEM_MODULE([argon2],[ARGON2],[libargon2])
11466
11467dnl ===================================================================
11468dnl Check for system redland
11469dnl ===================================================================
11470dnl redland: versions before 1.0.8 write RDF/XML that is useless for ODF (@xml:base)
11471dnl raptor2: need at least 2.0.7 for CVE-2012-0037
11472libo_CHECK_SYSTEM_MODULE([redland],[REDLAND],[redland >= 1.0.8 raptor2 >= 2.0.7])
11473if test "$with_system_redland" = "yes"; then
11474    AC_CHECK_LIB([rdf], [librdf_world_set_raptor_init_handler], [:],
11475            [AC_MSG_ERROR(librdf too old. Need >= 1.0.16)], [])
11476else
11477    RAPTOR_MAJOR="0"
11478    RASQAL_MAJOR="3"
11479    REDLAND_MAJOR="0"
11480fi
11481AC_SUBST(RAPTOR_MAJOR)
11482AC_SUBST(RASQAL_MAJOR)
11483AC_SUBST(REDLAND_MAJOR)
11484
11485dnl ===================================================================
11486dnl Check for system hunspell
11487dnl ===================================================================
11488AC_MSG_CHECKING([which libhunspell to use])
11489if test "$with_system_hunspell" = "yes"; then
11490    AC_MSG_RESULT([external])
11491    SYSTEM_HUNSPELL=TRUE
11492    AC_LANG_PUSH([C++])
11493    PKG_CHECK_MODULES(HUNSPELL, hunspell, HUNSPELL_PC="TRUE", HUNSPELL_PC="" )
11494    if test "$HUNSPELL_PC" != "TRUE"; then
11495        AC_CHECK_HEADER(hunspell.hxx, [],
11496            [
11497            AC_CHECK_HEADER(hunspell/hunspell.hxx, [ HUNSPELL_CFLAGS=-I/usr/include/hunspell ],
11498            [AC_MSG_ERROR(hunspell headers not found.)], [])
11499            ], [])
11500        AC_CHECK_LIB([hunspell], [main], [:],
11501           [ AC_MSG_ERROR(hunspell library not found.) ], [])
11502        HUNSPELL_LIBS=-lhunspell
11503    fi
11504    AC_LANG_POP([C++])
11505    HUNSPELL_CFLAGS=$(printf '%s' "$HUNSPELL_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11506    FilterLibs "${HUNSPELL_LIBS}"
11507    HUNSPELL_LIBS="${filteredlibs}"
11508else
11509    AC_MSG_RESULT([internal])
11510    SYSTEM_HUNSPELL=
11511    HUNSPELL_CFLAGS="-I${WORKDIR}/UnpackedTarball/hunspell/src/hunspell"
11512    if test "$COM" = "MSC"; then
11513        HUNSPELL_LIBS='$(gb_StaticLibrary_WORKDIR)/hunspell.lib'
11514    else
11515        HUNSPELL_LIBS="-L${WORKDIR}/UnpackedTarball/hunspell/src/hunspell/.libs -lhunspell-1.7"
11516    fi
11517    BUILD_TYPE="$BUILD_TYPE HUNSPELL"
11518fi
11519AC_SUBST(SYSTEM_HUNSPELL)
11520AC_SUBST(HUNSPELL_CFLAGS)
11521AC_SUBST(HUNSPELL_LIBS)
11522
11523dnl ===================================================================
11524dnl Check for system zxcvbn
11525dnl ===================================================================
11526AC_MSG_CHECKING([which zxcvbn to use])
11527if test "$with_system_zxcvbn" = "yes"; then
11528    AC_MSG_RESULT([external])
11529    SYSTEM_ZXCVBN=TRUE
11530    AC_CHECK_HEADER(zxcvbn.h, [],
11531       [ AC_MSG_ERROR(zxcvbn headers not found.)], [])
11532    AC_CHECK_LIB(zxcvbn, ZxcvbnMatch, [],
11533        [ AC_MSG_ERROR(zxcvbn library not found.)], [])
11534else
11535   AC_MSG_RESULT([internal])
11536   BUILD_TYPE="$BUILD_TYPE ZXCVBN"
11537   SYSTEM_ZXCVBN=
11538fi
11539AC_SUBST(SYSTEM_ZXCVBN)
11540
11541dnl ===================================================================
11542dnl Check for system zxing
11543dnl ===================================================================
11544AC_MSG_CHECKING([whether to use zxing])
11545if test "$enable_zxing" = "no"; then
11546    AC_MSG_RESULT([no])
11547    ENABLE_ZXING=
11548    SYSTEM_ZXING=
11549else
11550    AC_MSG_RESULT([yes])
11551    ENABLE_ZXING=TRUE
11552    AC_MSG_CHECKING([which libzxing to use])
11553    if test "$with_system_zxing" = "yes"; then
11554        AC_MSG_RESULT([external])
11555        SYSTEM_ZXING=TRUE
11556        ZXING_CFLAGS=
11557        AC_LANG_PUSH([C++])
11558        save_CXXFLAGS=$CXXFLAGS
11559        save_IFS=$IFS
11560        IFS=$P_SEP
11561        for i in $CPLUS_INCLUDE_PATH /usr/include; do
11562            dnl Reset IFS as soon as possible, to avoid unexpected side effects (and the
11563            dnl "/usr/include" fallback makes sure we get here at least once; resetting rather than
11564            dnl unsetting follows the advice at <https://git.savannah.gnu.org/gitweb/?p=autoconf.git;
11565            dnl a=commitdiff;h=e51c9919f2cf70185b7916ac040bc0bbfd0f743b> "Add recommendation on (not)
11566            dnl unsetting IFS."):
11567            IFS=$save_IFS
11568            dnl TODO: GCC and Clang treat empty paths in CPLUS_INCLUDE_PATH like ".", but we simply
11569            dnl ignore them here:
11570            if test -z "$i"; then
11571                continue
11572            fi
11573            dnl TODO: White space in $i would cause problems:
11574            CXXFLAGS="$save_CXXFLAGS ${CXXFLAGS_CXX11} -I$i/ZXing"
11575            AC_CHECK_HEADER(MultiFormatWriter.h, [ZXING_CFLAGS=-I$i/ZXing; break],
11576                [unset ac_cv_header_MultiFormatWriter_h], [#include <stdexcept>])
11577        done
11578        CXXFLAGS=$save_CXXFLAGS
11579        if test -z "$ZXING_CFLAGS"; then
11580            AC_MSG_ERROR(zxing headers not found.)
11581        fi
11582        AC_CHECK_LIB([ZXing], [main], [ZXING_LIBS=-lZXing],
11583            [ AC_CHECK_LIB([ZXingCore], [main], [ZXING_LIBS=-lZXingCore],
11584            [ AC_MSG_ERROR(zxing C++ library not found.) ])], [])
11585        AC_LANG_POP([C++])
11586        ZXING_CFLAGS=$(printf '%s' "$ZXING_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11587        FilterLibs "${ZXING_LIBS}"
11588        ZXING_LIBS="${filteredlibs}"
11589    else
11590        AC_MSG_RESULT([internal])
11591        SYSTEM_ZXING=
11592        BUILD_TYPE="$BUILD_TYPE ZXING"
11593        ZXING_CFLAGS="-I${WORKDIR}/UnpackedTarball/zxing/core/src"
11594    fi
11595    if test "$ENABLE_ZXING" = TRUE; then
11596        AC_DEFINE(ENABLE_ZXING)
11597    fi
11598    AC_MSG_CHECKING([whether zxing::tosvg function is available])
11599    AC_LANG_PUSH([C++])
11600    save_CXXFLAGS=$CXXFLAGS
11601    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11 $ZXING_CFLAGS"
11602    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
11603            #include <BitMatrix.h>
11604            #include <BitMatrixIO.h>
11605            int main(){
11606                ZXing::BitMatrix matrix(1, 1);
11607                matrix.set(0, 0, true);
11608                ZXing::ToSVG(matrix);
11609                return 0;
11610            }
11611        ])], [
11612            AC_DEFINE([HAVE_ZXING_TOSVG],[1])
11613            AC_MSG_RESULT([yes])
11614        ], [AC_MSG_RESULT([no])])
11615    CXXFLAGS=$save_CXXFLAGS
11616    AC_LANG_POP([C++])
11617    AC_SUBST(HAVE_ZXING_TOSVG)
11618fi
11619AC_SUBST(SYSTEM_ZXING)
11620AC_SUBST(ENABLE_ZXING)
11621AC_SUBST(ZXING_CFLAGS)
11622AC_SUBST(ZXING_LIBS)
11623
11624dnl ===================================================================
11625dnl Check for system box2d
11626dnl ===================================================================
11627AC_MSG_CHECKING([which box2d to use])
11628if test "$with_system_box2d" = "yes"; then
11629    AC_MSG_RESULT([external])
11630    SYSTEM_BOX2D=TRUE
11631    AC_LANG_PUSH([C++])
11632    AC_CHECK_HEADER(box2d/box2d.h, [BOX2D_H_FOUND='TRUE'],
11633        [BOX2D_H_FOUND='FALSE'])
11634    if test "$BOX2D_H_FOUND" = "TRUE"; then # 2.4.0+
11635        _BOX2D_LIB=box2d
11636        AC_DEFINE(BOX2D_HEADER,<box2d/box2d.h>)
11637    else
11638        # fail this. there's no other alternative to check when we are here.
11639        AC_CHECK_HEADER([Box2D/Box2D.h], [],
11640            [AC_MSG_ERROR(box2d headers not found.)])
11641        _BOX2D_LIB=Box2D
11642        AC_DEFINE(BOX2D_HEADER,<Box2D/Box2D.h>)
11643    fi
11644    AC_CHECK_LIB([$_BOX2D_LIB], [main], [:],
11645        [ AC_MSG_ERROR(box2d library not found.) ], [])
11646    BOX2D_LIBS=-l$_BOX2D_LIB
11647    AC_LANG_POP([C++])
11648    BOX2D_CFLAGS=$(printf '%s' "$BOX2D_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11649    FilterLibs "${BOX2D_LIBS}"
11650    BOX2D_LIBS="${filteredlibs}"
11651else
11652    AC_MSG_RESULT([internal])
11653    SYSTEM_BOX2D=
11654    BUILD_TYPE="$BUILD_TYPE BOX2D"
11655fi
11656AC_SUBST(SYSTEM_BOX2D)
11657AC_SUBST(BOX2D_CFLAGS)
11658AC_SUBST(BOX2D_LIBS)
11659
11660dnl ===================================================================
11661dnl Checking for altlinuxhyph
11662dnl ===================================================================
11663AC_MSG_CHECKING([which altlinuxhyph to use])
11664if test "$with_system_altlinuxhyph" = "yes"; then
11665    AC_MSG_RESULT([external])
11666    SYSTEM_HYPH=TRUE
11667    AC_CHECK_HEADER(hyphen.h, [],
11668       [ AC_MSG_ERROR(altlinuxhyph headers not found.)], [])
11669    AC_CHECK_MEMBER(struct _HyphenDict.cset, [],
11670       [ AC_MSG_ERROR(no. You are sure you have altlinuyhyph headers?)],
11671       [#include <hyphen.h>])
11672    AC_CHECK_LIB(hyphen, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhyphen],
11673        [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
11674    if test -z "$HYPHEN_LIB"; then
11675        AC_CHECK_LIB(hyph, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhyph],
11676           [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
11677    fi
11678    if test -z "$HYPHEN_LIB"; then
11679        AC_CHECK_LIB(hnj, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhnj],
11680           [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
11681    fi
11682else
11683    AC_MSG_RESULT([internal])
11684    SYSTEM_HYPH=
11685    BUILD_TYPE="$BUILD_TYPE HYPHEN"
11686    if test "$COM" = "MSC"; then
11687        HYPHEN_LIB='$(gb_StaticLibrary_WORKDIR)/hyphen.lib'
11688    else
11689        HYPHEN_LIB="-L${WORKDIR}/UnpackedTarball/hyphen/.libs -lhyphen"
11690    fi
11691fi
11692AC_SUBST(SYSTEM_HYPH)
11693AC_SUBST(HYPHEN_LIB)
11694
11695dnl ===================================================================
11696dnl Checking for mythes
11697dnl ===================================================================
11698AC_MSG_CHECKING([which mythes to use])
11699if test "$with_system_mythes" = "yes"; then
11700    AC_MSG_RESULT([external])
11701    SYSTEM_MYTHES=TRUE
11702    AC_LANG_PUSH([C++])
11703    PKG_CHECK_MODULES(MYTHES, mythes, MYTHES_PKGCONFIG=yes, MYTHES_PKGCONFIG=no)
11704    if test "$MYTHES_PKGCONFIG" = "no"; then
11705        AC_CHECK_HEADER(mythes.hxx, [],
11706            [ AC_MSG_ERROR(mythes.hxx headers not found.)], [])
11707        AC_CHECK_LIB([mythes-1.2], [main], [:],
11708            [ MYTHES_FOUND=no], [])
11709    if test "$MYTHES_FOUND" = "no"; then
11710        AC_CHECK_LIB(mythes, main, [MYTHES_FOUND=yes],
11711                [ MYTHES_FOUND=no], [])
11712    fi
11713    if test "$MYTHES_FOUND" = "no"; then
11714        AC_MSG_ERROR([mythes library not found!.])
11715    fi
11716    fi
11717    AC_LANG_POP([C++])
11718    MYTHES_CFLAGS=$(printf '%s' "$MYTHES_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
11719    FilterLibs "${MYTHES_LIBS}"
11720    MYTHES_LIBS="${filteredlibs}"
11721else
11722    AC_MSG_RESULT([internal])
11723    SYSTEM_MYTHES=
11724    BUILD_TYPE="$BUILD_TYPE MYTHES"
11725    if test "$COM" = "MSC"; then
11726        MYTHES_LIBS='$(gb_StaticLibrary_WORKDIR)/mythes.lib'
11727    else
11728        MYTHES_LIBS="-L${WORKDIR}/UnpackedTarball/mythes/.libs -lmythes-1.2"
11729    fi
11730fi
11731AC_SUBST(SYSTEM_MYTHES)
11732AC_SUBST(MYTHES_CFLAGS)
11733AC_SUBST(MYTHES_LIBS)
11734
11735dnl ===================================================================
11736dnl How should we build the linear programming solver ?
11737dnl ===================================================================
11738
11739ENABLE_COINMP=
11740AC_MSG_CHECKING([whether to build with CoinMP])
11741if test "$enable_coinmp" != "no"; then
11742    ENABLE_COINMP=TRUE
11743    AC_MSG_RESULT([yes])
11744    if test "$with_system_coinmp" = "yes"; then
11745        SYSTEM_COINMP=TRUE
11746        PKG_CHECK_MODULES(COINMP, coinmp coinutils)
11747        FilterLibs "${COINMP_LIBS}"
11748        COINMP_LIBS="${filteredlibs}"
11749    else
11750        BUILD_TYPE="$BUILD_TYPE COINMP"
11751    fi
11752else
11753    AC_MSG_RESULT([no])
11754fi
11755AC_SUBST(ENABLE_COINMP)
11756AC_SUBST(SYSTEM_COINMP)
11757AC_SUBST(COINMP_CFLAGS)
11758AC_SUBST(COINMP_LIBS)
11759
11760ENABLE_LPSOLVE=
11761AC_MSG_CHECKING([whether to build with lpsolve])
11762if test "$enable_lpsolve" != "no"; then
11763    ENABLE_LPSOLVE=TRUE
11764    AC_MSG_RESULT([yes])
11765else
11766    AC_MSG_RESULT([no])
11767fi
11768AC_SUBST(ENABLE_LPSOLVE)
11769
11770if test "$ENABLE_LPSOLVE" = TRUE; then
11771    AC_MSG_CHECKING([which lpsolve to use])
11772    if test "$with_system_lpsolve" = "yes"; then
11773        AC_MSG_RESULT([external])
11774        SYSTEM_LPSOLVE=TRUE
11775        AC_CHECK_HEADER(lpsolve/lp_lib.h, [],
11776           [ AC_MSG_ERROR(lpsolve headers not found.)], [])
11777        save_LIBS=$LIBS
11778        # some systems need this. Like Ubuntu...
11779        AC_CHECK_LIB(m, floor)
11780        AC_CHECK_LIB(dl, dlopen)
11781        AC_CHECK_LIB([lpsolve55], [make_lp], [:],
11782            [ AC_MSG_ERROR(lpsolve library not found or too old.)], [])
11783        LIBS=$save_LIBS
11784    else
11785        AC_MSG_RESULT([internal])
11786        SYSTEM_LPSOLVE=
11787        BUILD_TYPE="$BUILD_TYPE LPSOLVE"
11788    fi
11789fi
11790AC_SUBST(SYSTEM_LPSOLVE)
11791
11792dnl ===================================================================
11793dnl Checking for libexttextcat
11794dnl ===================================================================
11795libo_CHECK_SYSTEM_MODULE([libexttextcat],[LIBEXTTEXTCAT],[libexttextcat >= 3.4.1])
11796if test "$with_system_libexttextcat" = "yes"; then
11797    SYSTEM_LIBEXTTEXTCAT_DATA=file://`$PKG_CONFIG --variable=pkgdatadir libexttextcat`
11798fi
11799AC_SUBST(SYSTEM_LIBEXTTEXTCAT_DATA)
11800
11801dnl ===================================================================
11802dnl Checking for libnumbertext
11803dnl ===================================================================
11804libo_CHECK_SYSTEM_MODULE([libnumbertext],[LIBNUMBERTEXT],[libnumbertext >= 1.0.6])
11805if test "$with_system_libnumbertext" = "yes"; then
11806    SYSTEM_LIBNUMBERTEXT_DATA=file://`$PKG_CONFIG --variable=pkgdatadir libnumbertext`
11807    SYSTEM_LIBNUMBERTEXT=YES
11808else
11809    SYSTEM_LIBNUMBERTEXT=
11810fi
11811AC_SUBST(SYSTEM_LIBNUMBERTEXT)
11812AC_SUBST(SYSTEM_LIBNUMBERTEXT_DATA)
11813
11814dnl ***************************************
11815dnl testing libc version for Linux...
11816dnl ***************************************
11817if test "$_os" = "Linux"; then
11818    AC_MSG_CHECKING([whether the libc is recent enough])
11819    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
11820    #include <features.h>
11821    #if defined(__GNU_LIBRARY__) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1))
11822    #error glibc >= 2.1 is required
11823    #endif
11824    ]])],, [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([no, upgrade libc])])
11825fi
11826
11827dnl =========================================
11828dnl Check for uuidgen
11829dnl =========================================
11830if test "$_os" = "WINNT"; then
11831    # we must use the uuidgen from the Windows SDK, which will be in the LO_PATH, but isn't in
11832    # the PATH for AC_PATH_PROG. It is already tested above in the WINDOWS_SDK_HOME check.
11833    UUIDGEN=uuidgen.exe
11834    AC_SUBST(UUIDGEN)
11835else
11836    AC_PATH_PROG([UUIDGEN], [uuidgen])
11837    if test -z "$UUIDGEN"; then
11838        AC_MSG_WARN([uuid is needed for building installation sets])
11839    fi
11840fi
11841
11842dnl ***************************************
11843dnl Checking for bison and flex
11844dnl ***************************************
11845AC_PATH_PROG(BISON, bison)
11846if test -z "$BISON"; then
11847    AC_MSG_ERROR([no bison found in \$PATH, install it])
11848else
11849    AC_MSG_CHECKING([the bison version])
11850    _bison_version=`$BISON --version | grep GNU | $SED -e 's@^[[^0-9]]*@@' -e 's@ .*@@' -e 's@,.*@@'`
11851    _bison_longver=`echo $_bison_version | $AWK -F. '{ print \$1*1000+\$2}'`
11852    dnl Accept newer than 2.0; for --enable-compiler-plugins at least 2.3 is known to be bad and
11853    dnl cause
11854    dnl
11855    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]
11856    dnl   typedef union YYSTYPE
11857    dnl           ~~~~~~^~~~~~~
11858    dnl
11859    dnl while at least 3.4.1 is know to be good:
11860    if test "$COMPILER_PLUGINS" = TRUE; then
11861        if test "$_bison_longver" -lt 2004; then
11862            AC_MSG_ERROR([failed ($BISON $_bison_version need 2.4+ for --enable-compiler-plugins)])
11863        fi
11864    else
11865        if test "$_bison_longver" -lt 2000; then
11866            AC_MSG_ERROR([failed ($BISON $_bison_version need 2.0+)])
11867        fi
11868    fi
11869fi
11870AC_SUBST([BISON])
11871
11872AC_PATH_PROG(FLEX, flex)
11873if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
11874    FLEX=`cygpath -m $FLEX`
11875fi
11876if test -z "$FLEX"; then
11877    AC_MSG_ERROR([no flex found in \$PATH, install it])
11878else
11879    AC_MSG_CHECKING([the flex version])
11880    _flex_version=$($FLEX --version | $SED -e 's/^.*\([[[:digit:]]]\{1,\}\.[[[:digit:]]]\{1,\}\.[[[:digit:]]]\{1,\}\).*$/\1/')
11881    if test $(echo $_flex_version | $AWK -F. '{printf("%d%03d%03d", $1, $2, $3)}') -lt 2006000; then
11882        AC_MSG_ERROR([failed ($FLEX $_flex_version found, but need at least 2.6.0)])
11883    fi
11884fi
11885AC_SUBST([FLEX])
11886
11887AC_PATH_PROG(DIFF, diff)
11888if test -z "$DIFF"; then
11889    AC_MSG_ERROR(["diff" not found in \$PATH, install it])
11890fi
11891AC_SUBST([DIFF])
11892
11893AC_PATH_PROG(UNIQ, uniq)
11894if test -z "$UNIQ"; then
11895    AC_MSG_ERROR(["uniq" not found in \$PATH, install it])
11896fi
11897AC_SUBST([UNIQ])
11898
11899dnl ***************************************
11900dnl Checking for patch
11901dnl ***************************************
11902AC_PATH_PROG(PATCH, patch)
11903if test -z "$PATCH"; then
11904    AC_MSG_ERROR(["patch" not found in \$PATH, install it])
11905fi
11906
11907dnl On Solaris or macOS, check if --with-gnu-patch was used
11908if test "$_os" = "SunOS" -o "$_os" = "Darwin" -o "$_os" = "FreeBSD"; then
11909    if test -z "$with_gnu_patch"; then
11910        GNUPATCH=$PATCH
11911    else
11912        if test -x "$with_gnu_patch"; then
11913            GNUPATCH=$with_gnu_patch
11914        else
11915            AC_MSG_ERROR([--with-gnu-patch did not point to an executable])
11916        fi
11917    fi
11918
11919    AC_MSG_CHECKING([whether $GNUPATCH is GNU patch])
11920    if $GNUPATCH --version | grep "Free Software Foundation" >/dev/null 2>/dev/null; then
11921        AC_MSG_RESULT([yes])
11922    else
11923        if $GNUPATCH --version | grep "2\.0-.*-Apple" >/dev/null 2>/dev/null; then
11924            AC_MSG_RESULT([no, but accepted (Apple patch)])
11925            add_warning "patch utility is not GNU patch. Apple's patch should work OK, but it might experience issues where GNU patch doesn't."
11926        else
11927            AC_MSG_ERROR([no, GNU patch needed. install or specify with --with-gnu-patch=/path/to/it])
11928        fi
11929    fi
11930else
11931    GNUPATCH=$PATCH
11932fi
11933
11934if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
11935    GNUPATCH=`cygpath -m $GNUPATCH`
11936fi
11937
11938dnl We also need to check for --with-gnu-cp
11939
11940if test -z "$with_gnu_cp"; then
11941    # check the place where the good stuff is hidden on Solaris...
11942    if test -x /usr/gnu/bin/cp; then
11943        GNUCP=/usr/gnu/bin/cp
11944    else
11945        AC_PATH_PROGS(GNUCP, gnucp cp)
11946    fi
11947    if test -z $GNUCP; then
11948        AC_MSG_ERROR([Neither gnucp nor cp found. Install GNU cp and/or specify --with-gnu-cp=/path/to/it])
11949    fi
11950else
11951    if test -x "$with_gnu_cp"; then
11952        GNUCP=$with_gnu_cp
11953    else
11954        AC_MSG_ERROR([--with-gnu-cp did not point to an executable])
11955    fi
11956fi
11957
11958if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
11959    GNUCP=`cygpath -m $GNUCP`
11960fi
11961
11962AC_MSG_CHECKING([whether $GNUCP is GNU cp from coreutils with preserve= support])
11963if $GNUCP --version 2>/dev/null | grep "coreutils" >/dev/null 2>/dev/null; then
11964    AC_MSG_RESULT([yes])
11965elif $GNUCP --version 2>/dev/null | grep "GNU fileutils" >/dev/null 2>/dev/null; then
11966    AC_MSG_RESULT([yes])
11967else
11968    case "$build_os" in
11969    darwin*|netbsd*|openbsd*|freebsd*|dragonfly*)
11970        x_GNUCP=[\#]
11971        GNUCP=''
11972        AC_MSG_RESULT([no gnucp found - using the system's cp command])
11973        ;;
11974    *)
11975        AC_MSG_ERROR([no, GNU cp needed. install or specify with --with-gnu-cp=/path/to/it])
11976        ;;
11977    esac
11978fi
11979
11980AC_SUBST(GNUPATCH)
11981AC_SUBST(GNUCP)
11982AC_SUBST(x_GNUCP)
11983
11984dnl ***************************************
11985dnl testing assembler path
11986dnl ***************************************
11987ML_EXE=""
11988if test "$_os" = "WINNT"; then
11989    case "$WIN_HOST_ARCH" in
11990    x86) assembler=ml.exe ;;
11991    x64) assembler=ml64.exe ;;
11992    arm64) assembler=armasm64.exe ;;
11993    esac
11994
11995    AC_MSG_CHECKING([for the MSVC assembler ($assembler)])
11996    if test -f "$MSVC_HOST_PATH/$assembler"; then
11997        ML_EXE=`win_short_path_for_make "$MSVC_HOST_PATH/$assembler"`
11998        AC_MSG_RESULT([$ML_EXE])
11999    else
12000        AC_MSG_ERROR([not found in $MSVC_HOST_PATH])
12001    fi
12002fi
12003
12004AC_SUBST(ML_EXE)
12005
12006dnl ===================================================================
12007dnl We need zip and unzip
12008dnl ===================================================================
12009AC_PATH_PROG(ZIP, zip)
12010test -z "$ZIP" && AC_MSG_ERROR([zip is required])
12011if ! "$ZIP" --filesync < /dev/null 2>/dev/null > /dev/null; then
12012    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],,)
12013fi
12014
12015AC_PATH_PROG(UNZIP, unzip)
12016test -z "$UNZIP" && AC_MSG_ERROR([unzip is required])
12017
12018dnl ===================================================================
12019dnl Zip must be a specific type for different build types.
12020dnl ===================================================================
12021if test $build_os = cygwin; then
12022    if test -n "`$ZIP -h | $GREP -i WinNT`"; then
12023        AC_MSG_ERROR([$ZIP is not the required Cygwin version of Info-ZIP's zip.exe.])
12024    fi
12025fi
12026
12027dnl ===================================================================
12028dnl We need touch with -h option support.
12029dnl ===================================================================
12030AC_PATH_PROG(TOUCH, touch)
12031test -z "$TOUCH" && AC_MSG_ERROR([touch is required])
12032touch "$WARNINGS_FILE"
12033if ! "$TOUCH" -h "$WARNINGS_FILE" 2>/dev/null > /dev/null; then
12034    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],,)
12035fi
12036
12037dnl ===================================================================
12038dnl Check for system epoxy
12039dnl ===================================================================
12040EPOXY_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/epoxy/include"
12041libo_CHECK_SYSTEM_MODULE([epoxy], [EPOXY], [epoxy >= 1.2])
12042
12043dnl ===================================================================
12044dnl Show which vclplugs will be built.
12045dnl ===================================================================
12046R=""
12047
12048libo_ENABLE_VCLPLUG([gen])
12049libo_ENABLE_VCLPLUG([gtk3])
12050libo_ENABLE_VCLPLUG([gtk3_kde5])
12051libo_ENABLE_VCLPLUG([gtk4])
12052libo_ENABLE_VCLPLUG([kf5])
12053libo_ENABLE_VCLPLUG([kf6])
12054libo_ENABLE_VCLPLUG([qt5])
12055libo_ENABLE_VCLPLUG([qt6])
12056
12057if test "$_os" = "WINNT"; then
12058    R="$R win"
12059elif test "$_os" = "Darwin"; then
12060    R="$R osx"
12061elif test "$_os" = "iOS"; then
12062    R="ios"
12063elif test "$_os" = Android; then
12064    R="android"
12065fi
12066
12067build_vcl_plugins="$R"
12068if test -z "$build_vcl_plugins"; then
12069    build_vcl_plugins=" none"
12070fi
12071AC_MSG_NOTICE([VCLplugs to be built:${build_vcl_plugins}])
12072VCL_PLUGIN_INFO=$R
12073AC_SUBST([VCL_PLUGIN_INFO])
12074
12075if test "$DISABLE_DYNLOADING" = TRUE -a -z "$DISABLE_GUI" -a \( -z "$R" -o $(echo "$R" | wc -w) -ne 1 \); then
12076    AC_MSG_ERROR([Can't build --disable-dynamic-loading without --disable-gui and a single VCL plugin"])
12077fi
12078
12079dnl ===================================================================
12080dnl Check for GTK libraries
12081dnl ===================================================================
12082
12083GTK3_CFLAGS=""
12084GTK3_LIBS=""
12085ENABLE_GTKTILEDVIEWER=""
12086if test "$test_gtk3" = yes -a "x$enable_gtk3" = "xyes" -o "x$enable_gtk3_kde5" = "xyes"; then
12087    if test "$with_system_cairo" = no; then
12088        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.'
12089    fi
12090    : ${with_system_cairo:=yes}
12091    PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.20 gtk+-unix-print-3.0 gmodule-no-export-2.0 glib-2.0 >= 2.38 atk >= 2.28.1 cairo)
12092    GTK3_CFLAGS=$(printf '%s' "$GTK3_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12093    GTK3_CFLAGS="$GTK3_CFLAGS -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
12094    FilterLibs "${GTK3_LIBS}"
12095    GTK3_LIBS="${filteredlibs}"
12096
12097    dnl We require egl only for the gtk3 plugin. Otherwise we use glx.
12098    if test "$with_system_epoxy" != "yes"; then
12099        AC_CHECK_LIB(EGL, eglMakeCurrent, [:], AC_MSG_ERROR([libEGL required.]))
12100        AC_CHECK_HEADER(EGL/eglplatform.h, [],
12101                        [AC_MSG_ERROR(EGL headers not found. install mesa-libEGL-devel)], [])
12102    fi
12103elif test -n "$with_gtk3_build" -a "$OS" = "WNT"; then
12104    PathFormat "${with_gtk3_build}/lib/pkgconfig"
12105    if test "$build_os" = "cygwin"; then
12106        dnl cygwin's pkg-config does not recognize "C:/..."-style paths, only "/cygdrive/c/..."
12107        formatted_path_unix=`cygpath -au "$formatted_path_unix"`
12108    fi
12109
12110    PKG_CONFIG_PATH="$formatted_path_unix"; export PKG_CONFIG_PATH
12111    PKG_CHECK_MODULES(GTK3, cairo gdk-3.0 gio-2.0 glib-2.0 gobject-2.0 gtk+-3.0)
12112    GTK3_CFLAGS="$GTK3_CFLAGS -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
12113    FilterLibs "${GTK3_LIBS}"
12114    GTK3_LIBS="${filteredlibs}"
12115    ENABLE_GTKTILEDVIEWER="yes"
12116fi
12117AC_SUBST(GTK3_LIBS)
12118AC_SUBST(GTK3_CFLAGS)
12119AC_SUBST(ENABLE_GTKTILEDVIEWER)
12120
12121GTK4_CFLAGS=""
12122GTK4_LIBS=""
12123if test "$test_gtk4" = yes -a "x$enable_gtk4" = "xyes"; then
12124    if test "$with_system_cairo" = no; then
12125        add_warning 'Non-system cairo combined with gtk4 is assumed to cause trouble; proceed at your own risk.'
12126    fi
12127    : ${with_system_cairo:=yes}
12128    PKG_CHECK_MODULES(GTK4, gtk4 >= 4.10 gmodule-no-export-2.0 glib-2.0 >= 2.38 cairo atk)
12129    GTK4_CFLAGS=$(printf '%s' "$GTK4_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12130    GTK4_CFLAGS="$GTK4_CFLAGS -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
12131    FilterLibs "${GTK4_LIBS}"
12132    GTK4_LIBS="${filteredlibs}"
12133
12134    dnl We require egl only for the gtk4 plugin. Otherwise we use glx.
12135    if test "$with_system_epoxy" != "yes"; then
12136        AC_CHECK_LIB(EGL, eglMakeCurrent, [:], AC_MSG_ERROR([libEGL required.]))
12137        AC_CHECK_HEADER(EGL/eglplatform.h, [],
12138                        [AC_MSG_ERROR(EGL headers not found. install mesa-libEGL-devel)], [])
12139    fi
12140fi
12141AC_SUBST(GTK4_LIBS)
12142AC_SUBST(GTK4_CFLAGS)
12143
12144if test "$enable_introspection" = yes; then
12145    if test "$ENABLE_GTK3" = "TRUE" -o "$ENABLE_GTK3_KDE5" = "TRUE"; then
12146        GOBJECT_INTROSPECTION_REQUIRE(INTROSPECTION_REQUIRED_VERSION)
12147    else
12148        AC_MSG_ERROR([--enable-introspection requires --enable-gtk3])
12149    fi
12150fi
12151
12152# AT-SPI2 tests require gtk3, xvfb-run, dbus-launch and atspi-2
12153if ! test "$ENABLE_GTK3" = TRUE; then
12154    if test "$enable_atspi_tests" = yes; then
12155        AC_MSG_ERROR([--enable-atspi-tests requires --enable-gtk3])
12156    fi
12157    enable_atspi_tests=no
12158fi
12159if ! test "$enable_atspi_tests" = no; then
12160    AC_PATH_PROGS([XVFB_RUN], [xvfb-run], no)
12161    if ! test "$XVFB_RUN" = no; then
12162        dnl make sure the found xvfb-run actually works
12163        AC_MSG_CHECKING([whether $XVFB_RUN works...])
12164        if $XVFB_RUN --auto-servernum true >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
12165            AC_MSG_RESULT([yes])
12166        else
12167            AC_MSG_RESULT([no])
12168            XVFB_RUN=no
12169        fi
12170    fi
12171    if test "$XVFB_RUN" = no; then
12172        if test "$enable_atspi_tests" = yes; then
12173            AC_MSG_ERROR([xvfb-run required by --enable-atspi-tests not found])
12174        fi
12175        enable_atspi_tests=no
12176    fi
12177fi
12178if ! test "$enable_atspi_tests" = no; then
12179    AC_PATH_PROGS([DBUS_LAUNCH], [dbus-launch], no)
12180    if test "$DBUS_LAUNCH" = no; then
12181        if test "$enable_atspi_tests" = yes; then
12182            AC_MSG_ERROR([dbus-launch required by --enable-atspi-tests not found])
12183        fi
12184        enable_atspi_tests=no
12185    fi
12186fi
12187if ! test "$enable_atspi_tests" = no; then
12188    PKG_CHECK_MODULES([ATSPI2], [atspi-2 gobject-2.0],,
12189                      [if test "$enable_atspi_tests" = yes; then
12190                           AC_MSG_ERROR([$ATSPI2_PKG_ERRORS])
12191                       else
12192                           enable_atspi_tests=no
12193                       fi])
12194fi
12195if ! test "x$enable_atspi_tests" = xno; then
12196    PKG_CHECK_MODULES([ATSPI2_2_32], [atspi-2 >= 2.32],
12197                      [have_atspi_scroll_to=1],
12198                      [have_atspi_scroll_to=0])
12199    AC_DEFINE_UNQUOTED([HAVE_ATSPI2_SCROLL_TO], [$have_atspi_scroll_to],
12200                       [Whether AT-SPI2 has the scrollTo API])
12201fi
12202ENABLE_ATSPI_TESTS=
12203test "$enable_atspi_tests" = no || ENABLE_ATSPI_TESTS=TRUE
12204AC_SUBST([ENABLE_ATSPI_TESTS])
12205
12206dnl ===================================================================
12207dnl check for dbus support
12208dnl ===================================================================
12209ENABLE_DBUS=""
12210DBUS_CFLAGS=""
12211DBUS_LIBS=""
12212DBUS_GLIB_CFLAGS=""
12213DBUS_GLIB_LIBS=""
12214DBUS_HAVE_GLIB=""
12215
12216if test "$enable_dbus" = "no"; then
12217    test_dbus=no
12218fi
12219
12220AC_MSG_CHECKING([whether to enable DBUS support])
12221if test "$test_dbus" = "yes"; then
12222    ENABLE_DBUS="TRUE"
12223    AC_MSG_RESULT([yes])
12224    PKG_CHECK_MODULES(DBUS, dbus-1 >= 0.60)
12225    AC_DEFINE(ENABLE_DBUS)
12226    DBUS_CFLAGS=$(printf '%s' "$DBUS_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12227    FilterLibs "${DBUS_LIBS}"
12228    DBUS_LIBS="${filteredlibs}"
12229
12230    # Glib is needed for BluetoothServer
12231    # Sets also DBUS_GLIB_CFLAGS/DBUS_GLIB_LIBS if successful.
12232    PKG_CHECK_MODULES(DBUS_GLIB,[glib-2.0 >= 2.4],
12233        [
12234            DBUS_HAVE_GLIB="TRUE"
12235            AC_DEFINE(DBUS_HAVE_GLIB,1)
12236        ],
12237        AC_MSG_WARN([[No Glib found, Bluetooth support will be disabled]])
12238    )
12239else
12240    AC_MSG_RESULT([no])
12241fi
12242
12243AC_SUBST(ENABLE_DBUS)
12244AC_SUBST(DBUS_CFLAGS)
12245AC_SUBST(DBUS_LIBS)
12246AC_SUBST(DBUS_GLIB_CFLAGS)
12247AC_SUBST(DBUS_GLIB_LIBS)
12248AC_SUBST(DBUS_HAVE_GLIB)
12249
12250AC_MSG_CHECKING([whether to enable Impress remote control])
12251if test -n "$enable_sdremote" -a "$enable_sdremote" != "no"; then
12252    AC_MSG_RESULT([yes])
12253    ENABLE_SDREMOTE=TRUE
12254    SDREMOTE_ENTITLEMENT="	<key>com.apple.security.network.server</key>
12255	<true/>"
12256    AC_MSG_CHECKING([whether to enable Bluetooth support in Impress remote control])
12257
12258    if test $OS = MACOSX && test "$MACOSX_SDK_VERSION" -ge 101500; then
12259        # The Bluetooth code doesn't compile with macOS SDK 10.15
12260        if test "$enable_sdremote_bluetooth" = yes; then
12261            AC_MSG_ERROR([macOS SDK $macosx_sdk does not currently support --enable-sdremote-bluetooth])
12262        fi
12263        add_warning "not building the bluetooth part of the sdremote - used api was removed from macOS SDK 10.15"
12264        enable_sdremote_bluetooth=no
12265    fi
12266    # If not explicitly enabled or disabled, default
12267    if test -z "$enable_sdremote_bluetooth"; then
12268        case "$OS" in
12269        LINUX|MACOSX|WNT)
12270            # Default to yes for these
12271            enable_sdremote_bluetooth=yes
12272            ;;
12273        *)
12274            # otherwise no
12275            enable_sdremote_bluetooth=no
12276            ;;
12277        esac
12278    fi
12279    # $enable_sdremote_bluetooth is guaranteed non-empty now
12280
12281    if test "$enable_sdremote_bluetooth" != "no"; then
12282        if test "$OS" = "LINUX"; then
12283            if test "$ENABLE_DBUS" = "TRUE" -a "$DBUS_HAVE_GLIB" = "TRUE"; then
12284                AC_MSG_RESULT([yes])
12285                ENABLE_SDREMOTE_BLUETOOTH=TRUE
12286                dnl ===================================================================
12287                dnl Check for system bluez
12288                dnl ===================================================================
12289                AC_MSG_CHECKING([which Bluetooth header to use])
12290                if test "$with_system_bluez" = "yes"; then
12291                    AC_MSG_RESULT([external])
12292                    AC_CHECK_HEADER(bluetooth/bluetooth.h, [],
12293                        [AC_MSG_ERROR(bluetooth.h not found. install bluez)], [])
12294                    SYSTEM_BLUEZ=TRUE
12295                else
12296                    AC_MSG_RESULT([internal])
12297                    SYSTEM_BLUEZ=
12298                fi
12299            else
12300                AC_MSG_RESULT([no, dbus disabled])
12301                ENABLE_SDREMOTE_BLUETOOTH=
12302                SYSTEM_BLUEZ=
12303            fi
12304        else
12305            AC_MSG_RESULT([yes])
12306            ENABLE_SDREMOTE_BLUETOOTH=TRUE
12307            SYSTEM_BLUEZ=
12308            SDREMOTE_ENTITLEMENT="$SDREMOTE_ENTITLEMENT
12309	<key>com.apple.security.device.bluetooth</key>
12310	<true/>"
12311        fi
12312    else
12313        AC_MSG_RESULT([no])
12314        ENABLE_SDREMOTE_BLUETOOTH=
12315        SYSTEM_BLUEZ=
12316    fi
12317else
12318    ENABLE_SDREMOTE=
12319    SYSTEM_BLUEZ=
12320    AC_MSG_RESULT([no])
12321fi
12322AC_SUBST(ENABLE_SDREMOTE)
12323AC_SUBST(ENABLE_SDREMOTE_BLUETOOTH)
12324AC_SUBST(SDREMOTE_ENTITLEMENT)
12325AC_SUBST(SYSTEM_BLUEZ)
12326
12327dnl ===================================================================
12328dnl Check whether to enable GIO support
12329dnl ===================================================================
12330if test "$ENABLE_GTK4" = "TRUE" -o "$ENABLE_GTK3" = "TRUE" -o "$ENABLE_GTK3_KDE5" = "TRUE"; then
12331    AC_MSG_CHECKING([whether to enable GIO support])
12332    if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_gio" = "yes"; then
12333        dnl Need at least 2.26 for the dbus support.
12334        PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.26],
12335                          [ENABLE_GIO="TRUE"], [ENABLE_GIO=""])
12336        if test "$ENABLE_GIO" = "TRUE"; then
12337            AC_DEFINE(ENABLE_GIO)
12338            GIO_CFLAGS=$(printf '%s' "$GIO_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12339            FilterLibs "${GIO_LIBS}"
12340            GIO_LIBS="${filteredlibs}"
12341        fi
12342    else
12343        AC_MSG_RESULT([no])
12344    fi
12345fi
12346AC_SUBST(ENABLE_GIO)
12347AC_SUBST(GIO_CFLAGS)
12348AC_SUBST(GIO_LIBS)
12349
12350
12351dnl ===================================================================
12352
12353SPLIT_APP_MODULES=""
12354if test "$enable_split_app_modules" = "yes"; then
12355    SPLIT_APP_MODULES="TRUE"
12356fi
12357AC_SUBST(SPLIT_APP_MODULES)
12358
12359SPLIT_OPT_FEATURES=""
12360if test "$enable_split_opt_features" = "yes"; then
12361    SPLIT_OPT_FEATURES="TRUE"
12362fi
12363AC_SUBST(SPLIT_OPT_FEATURES)
12364
12365dnl ===================================================================
12366dnl Check whether the GStreamer libraries are available.
12367dnl ===================================================================
12368
12369ENABLE_GSTREAMER_1_0=""
12370
12371if test "$test_gstreamer_1_0" = yes; then
12372
12373    AC_MSG_CHECKING([whether to enable the GStreamer 1.0 avmedia backend])
12374    if test "$enable_avmedia" = yes -a "$enable_gstreamer_1_0" != no; then
12375        ENABLE_GSTREAMER_1_0="TRUE"
12376        AC_MSG_RESULT([yes])
12377        PKG_CHECK_MODULES( [GSTREAMER_1_0], [gstreamer-1.0 gstreamer-plugins-base-1.0 gstreamer-pbutils-1.0 gstreamer-video-1.0] )
12378        GSTREAMER_1_0_CFLAGS=$(printf '%s' "$GSTREAMER_1_0_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12379        FilterLibs "${GSTREAMER_1_0_LIBS}"
12380        GSTREAMER_1_0_LIBS="${filteredlibs}"
12381        AC_DEFINE(ENABLE_GSTREAMER_1_0)
12382    else
12383        AC_MSG_RESULT([no])
12384    fi
12385fi
12386AC_SUBST(GSTREAMER_1_0_CFLAGS)
12387AC_SUBST(GSTREAMER_1_0_LIBS)
12388AC_SUBST(ENABLE_GSTREAMER_1_0)
12389
12390ENABLE_OPENGL_TRANSITIONS=
12391ENABLE_OPENGL_CANVAS=
12392if test $_os = iOS -o $_os = Android -o "$ENABLE_FUZZERS" = "TRUE"; then
12393   : # disable
12394elif test "$_os" = "Darwin"; then
12395    # We use frameworks on macOS, no need for detail checks
12396    ENABLE_OPENGL_TRANSITIONS=TRUE
12397    AC_DEFINE(HAVE_FEATURE_OPENGL,1)
12398    ENABLE_OPENGL_CANVAS=TRUE
12399elif test $_os = WINNT; then
12400    ENABLE_OPENGL_TRANSITIONS=TRUE
12401    AC_DEFINE(HAVE_FEATURE_OPENGL,1)
12402    ENABLE_OPENGL_CANVAS=TRUE
12403else
12404    if test "$USING_X11" = TRUE; then
12405        AC_CHECK_LIB(GL, glBegin, [:], AC_MSG_ERROR([libGL required.]))
12406        ENABLE_OPENGL_TRANSITIONS=TRUE
12407        AC_DEFINE(HAVE_FEATURE_OPENGL,1)
12408        ENABLE_OPENGL_CANVAS=TRUE
12409    fi
12410fi
12411
12412AC_SUBST(ENABLE_OPENGL_TRANSITIONS)
12413AC_SUBST(ENABLE_OPENGL_CANVAS)
12414
12415dnl =================================================
12416dnl Check whether to build with OpenCL support.
12417dnl =================================================
12418
12419if test $_os != iOS -a $_os != Android -a "$ENABLE_FUZZERS" != "TRUE" -a "$enable_opencl" = "yes"; then
12420    # OPENCL in BUILD_TYPE and HAVE_FEATURE_OPENCL tell that OpenCL is potentially available on the
12421    # platform (optional at run-time, used through clew).
12422    BUILD_TYPE="$BUILD_TYPE OPENCL"
12423    AC_DEFINE(HAVE_FEATURE_OPENCL)
12424fi
12425
12426dnl =================================================
12427dnl Check whether to build with dconf support.
12428dnl =================================================
12429
12430if test $_os != Android -a $_os != iOS -a "$enable_dconf" != no; then
12431    PKG_CHECK_MODULES([DCONF], [dconf >= 0.40.0], [], [
12432        if test "$enable_dconf" = yes; then
12433            AC_MSG_ERROR([dconf not found])
12434        else
12435            enable_dconf=no
12436        fi])
12437fi
12438AC_MSG_CHECKING([whether to enable dconf])
12439if test $_os = Android -o $_os = iOS -o "$enable_dconf" = no; then
12440    DCONF_CFLAGS=
12441    DCONF_LIBS=
12442    ENABLE_DCONF=
12443    AC_MSG_RESULT([no])
12444else
12445    ENABLE_DCONF=TRUE
12446    AC_DEFINE(ENABLE_DCONF)
12447    AC_MSG_RESULT([yes])
12448fi
12449AC_SUBST([DCONF_CFLAGS])
12450AC_SUBST([DCONF_LIBS])
12451AC_SUBST([ENABLE_DCONF])
12452
12453# pdf import?
12454AC_MSG_CHECKING([whether to build the PDF import feature])
12455ENABLE_PDFIMPORT=
12456if test -z "$enable_pdfimport" -o "$enable_pdfimport" = yes; then
12457    AC_MSG_RESULT([yes])
12458    ENABLE_PDFIMPORT=TRUE
12459    AC_DEFINE(HAVE_FEATURE_PDFIMPORT)
12460else
12461    AC_MSG_RESULT([no])
12462fi
12463
12464# Pdfium?
12465AC_MSG_CHECKING([whether to build PDFium])
12466ENABLE_PDFIUM=
12467if test \( -z "$enable_pdfium" -a "$ENABLE_PDFIMPORT" = "TRUE" \) -o "$enable_pdfium" = yes; then
12468    AC_MSG_RESULT([yes])
12469    ENABLE_PDFIUM=TRUE
12470    BUILD_TYPE="$BUILD_TYPE PDFIUM"
12471else
12472    AC_MSG_RESULT([no])
12473fi
12474AC_SUBST(ENABLE_PDFIUM)
12475
12476if test "$ENABLE_PDFIUM" = "TRUE"; then
12477    AC_MSG_CHECKING([which OpenJPEG library to use])
12478    if test "$with_system_openjpeg" = "yes"; then
12479        SYSTEM_OPENJPEG2=TRUE
12480        AC_MSG_RESULT([external])
12481        PKG_CHECK_MODULES( OPENJPEG2, libopenjp2 )
12482        OPENJPEG2_CFLAGS=$(printf '%s' "$OPENJPEG2_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12483        FilterLibs "${OPENJPEG2_LIBS}"
12484        OPENJPEG2_LIBS="${filteredlibs}"
12485    else
12486        SYSTEM_OPENJPEG2=FALSE
12487        AC_MSG_RESULT([internal])
12488    fi
12489
12490    AC_MSG_CHECKING([which Abseil library to use])
12491    if test "$with_system_abseil" = "yes"; then
12492        AC_MSG_RESULT([external])
12493        SYSTEM_ABSEIL=TRUE
12494        AC_LANG_PUSH([C++])
12495        PKG_CHECK_MODULES(ABSEIL, absl_bad_optional_access absl_bad_variant_access absl_inlined_vector )
12496        AC_LANG_POP([C++])
12497        ABSEIL_CFLAGS=$(printf '%s' "$ABSEIL_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12498        FilterLibs "${ABSEIL_LIBS}"
12499        ABSEIL_LIBS="${filteredlibs}"
12500    else
12501        AC_MSG_RESULT([internal])
12502    fi
12503fi
12504AC_SUBST(SYSTEM_OPENJPEG2)
12505AC_SUBST(SYSTEM_ABSEIL)
12506AC_SUBST(ABSEIL_CFLAGS)
12507AC_SUBST(ABSEIL_LIBS)
12508
12509dnl ===================================================================
12510dnl Check for poppler
12511dnl ===================================================================
12512ENABLE_POPPLER=
12513AC_MSG_CHECKING([whether to build Poppler])
12514if test \( -z "$enable_poppler" -a "$ENABLE_PDFIMPORT" = "TRUE" -a $_os != Android \) -o "$enable_poppler" = yes; then
12515    AC_MSG_RESULT([yes])
12516    ENABLE_POPPLER=TRUE
12517    AC_DEFINE(HAVE_FEATURE_POPPLER)
12518else
12519    AC_MSG_RESULT([no])
12520fi
12521AC_SUBST(ENABLE_POPPLER)
12522
12523if test "$ENABLE_PDFIMPORT" = "TRUE" -a "$ENABLE_POPPLER" != "TRUE" -a "$ENABLE_PDFIUM" != "TRUE"; then
12524    AC_MSG_ERROR([Cannot import PDF without either Pdfium or Poppler; please enable either of them.])
12525fi
12526
12527if test "$ENABLE_PDFIMPORT" != "TRUE" -a \( "$ENABLE_POPPLER" = "TRUE" -o "$ENABLE_PDFIUM" = "TRUE" \); then
12528    AC_MSG_ERROR([Cannot enable Pdfium or Poppler when PDF importing is disabled; please enable PDF import first.])
12529fi
12530
12531if test "$ENABLE_PDFIMPORT" = "TRUE" -a "$ENABLE_POPPLER" = "TRUE"; then
12532    dnl ===================================================================
12533    dnl Check for system poppler
12534    dnl ===================================================================
12535    AC_MSG_CHECKING([which PDF import poppler to use])
12536    if test "$with_system_poppler" = "yes"; then
12537        AC_MSG_RESULT([external])
12538        SYSTEM_POPPLER=TRUE
12539        PKG_CHECK_MODULES(POPPLER,[poppler >= 0.14 poppler-cpp])
12540        POPPLER_CFLAGS=$(printf '%s' "$POPPLER_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
12541        FilterLibs "${POPPLER_LIBS}"
12542        POPPLER_LIBS="${filteredlibs}"
12543    else
12544        AC_MSG_RESULT([internal])
12545        SYSTEM_POPPLER=
12546        BUILD_TYPE="$BUILD_TYPE POPPLER"
12547    fi
12548    AC_DEFINE([ENABLE_PDFIMPORT],1)
12549fi
12550AC_SUBST(ENABLE_PDFIMPORT)
12551AC_SUBST(SYSTEM_POPPLER)
12552AC_SUBST(POPPLER_CFLAGS)
12553AC_SUBST(POPPLER_LIBS)
12554
12555# Skia?
12556ENABLE_SKIA=
12557if test "$enable_skia" != "no" -a "$build_skia" = "yes" -a -z "$DISABLE_GUI"; then
12558    # Skia now requires at least freetype2 >= 2.8.1, which is less that what LO requires as system freetype.
12559    if test "$SYSTEM_FREETYPE" = TRUE; then
12560        PKG_CHECK_EXISTS(freetype2 >= 21.0.15, # 21.0.15 = 2.8.1
12561            [skia_freetype_ok=yes],
12562            [skia_freetype_ok=no])
12563    else # internal is ok
12564        skia_freetype_ok=yes
12565    fi
12566    AC_MSG_CHECKING([whether to build Skia])
12567    if test "$skia_freetype_ok" = "yes"; then
12568        if test "$enable_skia" = "debug"; then
12569            AC_MSG_RESULT([yes (debug)])
12570            ENABLE_SKIA_DEBUG=TRUE
12571        else
12572            AC_MSG_RESULT([yes])
12573            ENABLE_SKIA_DEBUG=
12574        fi
12575        ENABLE_SKIA=TRUE
12576        if test "$ENDIANNESS" = "big" && test "$ENABLE_SKIA" = "TRUE"; then
12577            AC_MSG_ERROR([skia doesn't work/isn't supported upstream on big-endian. Use --disable-skia])
12578        fi
12579
12580        AC_DEFINE(HAVE_FEATURE_SKIA)
12581        BUILD_TYPE="$BUILD_TYPE SKIA"
12582
12583        if test "$OS" = "MACOSX"; then
12584            AC_DEFINE(SK_GANESH,1)
12585            AC_DEFINE(SK_METAL,1)
12586            SKIA_GPU=METAL
12587            AC_SUBST(SKIA_GPU)
12588        else
12589            AC_DEFINE(SK_GANESH,1)
12590            AC_DEFINE(SK_VULKAN,1)
12591            SKIA_GPU=VULKAN
12592            AC_SUBST(SKIA_GPU)
12593        fi
12594    else
12595        AC_MSG_RESULT([no (freetype too old)])
12596        add_warning "freetype version is too old for Skia library, at least 2.8.1 required, Skia support disabled"
12597    fi
12598
12599else
12600    AC_MSG_CHECKING([whether to build Skia])
12601    AC_MSG_RESULT([no])
12602fi
12603AC_SUBST(ENABLE_SKIA)
12604AC_SUBST(ENABLE_SKIA_DEBUG)
12605
12606LO_CLANG_CXXFLAGS_INTRINSICS_SSE2=
12607LO_CLANG_CXXFLAGS_INTRINSICS_SSSE3=
12608LO_CLANG_CXXFLAGS_INTRINSICS_SSE41=
12609LO_CLANG_CXXFLAGS_INTRINSICS_SSE42=
12610LO_CLANG_CXXFLAGS_INTRINSICS_AVX=
12611LO_CLANG_CXXFLAGS_INTRINSICS_AVX2=
12612LO_CLANG_CXXFLAGS_INTRINSICS_AVX512=
12613LO_CLANG_CXXFLAGS_INTRINSICS_AVX512F=
12614LO_CLANG_CXXFLAGS_INTRINSICS_F16C=
12615LO_CLANG_CXXFLAGS_INTRINSICS_FMA=
12616LO_CLANG_VERSION=
12617HAVE_LO_CLANG_DLLEXPORTINLINES=
12618
12619if test "$ENABLE_SKIA" = TRUE -a "$COM_IS_CLANG" != TRUE; then
12620    if test -n "$LO_CLANG_CC" -a -n "$LO_CLANG_CXX"; then
12621        AC_MSG_CHECKING([for Clang])
12622        AC_MSG_RESULT([$LO_CLANG_CC / $LO_CLANG_CXX])
12623    else
12624        if test "$_os" = "WINNT"; then
12625            AC_MSG_CHECKING([for clang-cl])
12626            if test -x "$VC_PRODUCT_DIR/Tools/Llvm/bin/clang-cl.exe"; then
12627                LO_CLANG_CC=`win_short_path_for_make "$VC_PRODUCT_DIR/Tools/Llvm/bin/clang-cl.exe"`
12628            elif test -n "$PROGRAMFILES" -a -x "$(cygpath -u "$PROGRAMFILES/LLVM/bin/clang-cl.exe")"; then
12629                LO_CLANG_CC=`win_short_path_for_make "$PROGRAMFILES/LLVM/bin/clang-cl.exe"`
12630            elif test -x "$(cygpath -u "c:/Program Files/LLVM/bin/clang-cl.exe")"; then
12631                LO_CLANG_CC=`win_short_path_for_make "c:/Program Files/LLVM/bin/clang-cl.exe"`
12632            fi
12633            if test -n "$LO_CLANG_CC"; then
12634                dnl explicitly set -m32/-m64
12635                LO_CLANG_CC="$LO_CLANG_CC -m$WIN_HOST_BITS"
12636                LO_CLANG_CXX="$LO_CLANG_CC"
12637                AC_MSG_RESULT([$LO_CLANG_CC])
12638            else
12639                AC_MSG_RESULT([no])
12640            fi
12641
12642            AC_MSG_CHECKING([the dependency generation prefix (clang.exe -showIncludes)])
12643            echo "#include <stdlib.h>" > conftest.c
12644            LO_CLANG_SHOWINCLUDES_PREFIX=`VSLANG=1033 $LO_CLANG_CC $CFLAGS -c -showIncludes conftest.c 2>/dev/null | \
12645                grep 'stdlib\.h' | head -n1 | sed 's/ [[[:alpha:]]]:.*//'`
12646            rm -f conftest.c conftest.obj
12647            if test -z "$LO_CLANG_SHOWINCLUDES_PREFIX"; then
12648                AC_MSG_ERROR([cannot determine the -showIncludes prefix])
12649            else
12650                AC_MSG_RESULT(["$LO_CLANG_SHOWINCLUDES_PREFIX"])
12651            fi
12652        else
12653            AC_CHECK_PROG(LO_CLANG_CC,clang,clang,[])
12654            AC_CHECK_PROG(LO_CLANG_CXX,clang++,clang++,[])
12655        fi
12656    fi
12657    if test -n "$LO_CLANG_CC" -a -n "$LO_CLANG_CXX"; then
12658        clang2_version=`echo __clang_major__.__clang_minor__.__clang_patchlevel__ | $LO_CLANG_CC -E - | tail -1 | sed 's/ //g'`
12659        LO_CLANG_VERSION=`echo "$clang2_version" | $AWK -F. '{ print \$1*10000+(\$2<100?\$2:99)*100+(\$3<100?\$3:99) }'`
12660        if test "$LO_CLANG_VERSION" -lt 50002; then
12661            AC_MSG_WARN(["$clang2_version" is too old or unrecognized, must be at least Clang 5.0.2])
12662            LO_CLANG_CC=
12663            LO_CLANG_CXX=
12664        fi
12665    fi
12666    if test -n "$LO_CLANG_CC" -a -n "$LO_CLANG_CXX" -a "$_os" = "WINNT"; then
12667        save_CXX="$CXX"
12668        CXX="$LO_CLANG_CXX"
12669        AC_MSG_CHECKING([whether $CXX supports -Zc:dllexportInlines-])
12670        AC_LANG_PUSH([C++])
12671        save_CXXFLAGS=$CXXFLAGS
12672        CXXFLAGS="$CXXFLAGS -Werror -Zc:dllexportInlines-"
12673        AC_COMPILE_IFELSE([AC_LANG_SOURCE()], [
12674                HAVE_LO_CLANG_DLLEXPORTINLINES=TRUE
12675                AC_MSG_RESULT([yes])
12676            ], [AC_MSG_RESULT([no])])
12677        CXXFLAGS=$save_CXXFLAGS
12678        AC_LANG_POP([C++])
12679        CXX="$save_CXX"
12680        if test -z "$HAVE_LO_CLANG_DLLEXPORTINLINES"; then
12681            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.])
12682        fi
12683    fi
12684    if test -z "$LO_CLANG_CC" -o -z "$LO_CLANG_CXX"; then
12685        # Skia is the default on Windows and Mac, so hard-require Clang.
12686        # Elsewhere it's used just by the 'gen' VCL backend which is rarely used.
12687        if test "$_os" = "WINNT" -o "$_os" = "Darwin"; then
12688            AC_MSG_ERROR([Clang compiler not found. The Skia library needs to be built using Clang, or use --disable-skia.])
12689        else
12690            AC_MSG_WARN([Clang compiler not found.])
12691        fi
12692    else
12693
12694        save_CXX="$CXX"
12695        CXX="$LO_CLANG_CXX"
12696        # copy&paste (and adjust) of intrinsics checks, since MSVC's -arch doesn't work well for Clang-cl
12697        flag_sse2=-msse2
12698        flag_ssse3=-mssse3
12699        flag_sse41=-msse4.1
12700        flag_sse42=-msse4.2
12701        flag_avx=-mavx
12702        flag_avx2=-mavx2
12703        flag_avx512="-mavx512f -mavx512vl -mavx512bw -mavx512dq -mavx512cd"
12704        flag_avx512f=-mavx512f
12705        flag_f16c=-mf16c
12706        flag_fma=-mfma
12707
12708        AC_MSG_CHECKING([whether $CXX can compile SSE2 intrinsics])
12709        AC_LANG_PUSH([C++])
12710        save_CXXFLAGS=$CXXFLAGS
12711        CXXFLAGS="$CXXFLAGS $flag_sse2"
12712        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12713            #include <emmintrin.h>
12714            int main () {
12715                __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
12716                c = _mm_xor_si128 (a, b);
12717                return 0;
12718            }
12719            ])],
12720            [can_compile_sse2=yes],
12721            [can_compile_sse2=no])
12722        AC_LANG_POP([C++])
12723        CXXFLAGS=$save_CXXFLAGS
12724        AC_MSG_RESULT([${can_compile_sse2}])
12725        if test "${can_compile_sse2}" = "yes" ; then
12726            LO_CLANG_CXXFLAGS_INTRINSICS_SSE2="$flag_sse2"
12727        fi
12728
12729        AC_MSG_CHECKING([whether $CXX can compile SSSE3 intrinsics])
12730        AC_LANG_PUSH([C++])
12731        save_CXXFLAGS=$CXXFLAGS
12732        CXXFLAGS="$CXXFLAGS $flag_ssse3"
12733        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12734            #include <tmmintrin.h>
12735            int main () {
12736                __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
12737                c = _mm_maddubs_epi16 (a, b);
12738                return 0;
12739            }
12740            ])],
12741            [can_compile_ssse3=yes],
12742            [can_compile_ssse3=no])
12743        AC_LANG_POP([C++])
12744        CXXFLAGS=$save_CXXFLAGS
12745        AC_MSG_RESULT([${can_compile_ssse3}])
12746        if test "${can_compile_ssse3}" = "yes" ; then
12747            LO_CLANG_CXXFLAGS_INTRINSICS_SSSE3="$flag_ssse3"
12748        fi
12749
12750        AC_MSG_CHECKING([whether $CXX can compile SSE4.1 intrinsics])
12751        AC_LANG_PUSH([C++])
12752        save_CXXFLAGS=$CXXFLAGS
12753        CXXFLAGS="$CXXFLAGS $flag_sse41"
12754        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12755            #include <smmintrin.h>
12756            int main () {
12757                __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
12758                c = _mm_cmpeq_epi64 (a, b);
12759                return 0;
12760            }
12761            ])],
12762            [can_compile_sse41=yes],
12763            [can_compile_sse41=no])
12764        AC_LANG_POP([C++])
12765        CXXFLAGS=$save_CXXFLAGS
12766        AC_MSG_RESULT([${can_compile_sse41}])
12767        if test "${can_compile_sse41}" = "yes" ; then
12768            LO_CLANG_CXXFLAGS_INTRINSICS_SSE41="$flag_sse41"
12769        fi
12770
12771        AC_MSG_CHECKING([whether $CXX can compile SSE4.2 intrinsics])
12772        AC_LANG_PUSH([C++])
12773        save_CXXFLAGS=$CXXFLAGS
12774        CXXFLAGS="$CXXFLAGS $flag_sse42"
12775        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12776            #include <nmmintrin.h>
12777            int main () {
12778                __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
12779                c = _mm_cmpgt_epi64 (a, b);
12780                return 0;
12781            }
12782            ])],
12783            [can_compile_sse42=yes],
12784            [can_compile_sse42=no])
12785        AC_LANG_POP([C++])
12786        CXXFLAGS=$save_CXXFLAGS
12787        AC_MSG_RESULT([${can_compile_sse42}])
12788        if test "${can_compile_sse42}" = "yes" ; then
12789            LO_CLANG_CXXFLAGS_INTRINSICS_SSE42="$flag_sse42"
12790        fi
12791
12792        AC_MSG_CHECKING([whether $CXX can compile AVX intrinsics])
12793        AC_LANG_PUSH([C++])
12794        save_CXXFLAGS=$CXXFLAGS
12795        CXXFLAGS="$CXXFLAGS $flag_avx"
12796        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12797            #include <immintrin.h>
12798            int main () {
12799                __m256 a = _mm256_set1_ps (0.0f), b = _mm256_set1_ps (0.0f), c;
12800                c = _mm256_xor_ps(a, b);
12801                return 0;
12802            }
12803            ])],
12804            [can_compile_avx=yes],
12805            [can_compile_avx=no])
12806        AC_LANG_POP([C++])
12807        CXXFLAGS=$save_CXXFLAGS
12808        AC_MSG_RESULT([${can_compile_avx}])
12809        if test "${can_compile_avx}" = "yes" ; then
12810            LO_CLANG_CXXFLAGS_INTRINSICS_AVX="$flag_avx"
12811        fi
12812
12813        AC_MSG_CHECKING([whether $CXX can compile AVX2 intrinsics])
12814        AC_LANG_PUSH([C++])
12815        save_CXXFLAGS=$CXXFLAGS
12816        CXXFLAGS="$CXXFLAGS $flag_avx2"
12817        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12818            #include <immintrin.h>
12819            int main () {
12820                __m256i a = _mm256_set1_epi32 (0), b = _mm256_set1_epi32 (0), c;
12821                c = _mm256_maddubs_epi16(a, b);
12822                return 0;
12823            }
12824            ])],
12825            [can_compile_avx2=yes],
12826            [can_compile_avx2=no])
12827        AC_LANG_POP([C++])
12828        CXXFLAGS=$save_CXXFLAGS
12829        AC_MSG_RESULT([${can_compile_avx2}])
12830        if test "${can_compile_avx2}" = "yes" ; then
12831            LO_CLANG_CXXFLAGS_INTRINSICS_AVX2="$flag_avx2"
12832        fi
12833
12834        AC_MSG_CHECKING([whether $CXX can compile AVX512 intrinsics])
12835        AC_LANG_PUSH([C++])
12836        save_CXXFLAGS=$CXXFLAGS
12837        CXXFLAGS="$CXXFLAGS $flag_avx512"
12838        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12839            #include <immintrin.h>
12840            int main () {
12841                __m512i a = _mm512_loadu_si512(0);
12842                __m512d v1 = _mm512_load_pd(0);
12843                // https://gcc.gnu.org/git/?p=gcc.git;a=commit;f=gcc/config/i386/avx512fintrin.h;h=23bce99cbe7016a04e14c2163ed3fe6a5a64f4e2
12844                __m512d v2 = _mm512_abs_pd(v1);
12845                return 0;
12846            }
12847            ])],
12848            [can_compile_avx512=yes],
12849            [can_compile_avx512=no])
12850        AC_LANG_POP([C++])
12851        CXXFLAGS=$save_CXXFLAGS
12852        AC_MSG_RESULT([${can_compile_avx512}])
12853        if test "${can_compile_avx512}" = "yes" ; then
12854            LO_CLANG_CXXFLAGS_INTRINSICS_AVX512="$flag_avx512"
12855            LO_CLANG_CXXFLAGS_INTRINSICS_AVX512F="$flag_avx512f"
12856        fi
12857
12858        AC_MSG_CHECKING([whether $CXX can compile F16C intrinsics])
12859        AC_LANG_PUSH([C++])
12860        save_CXXFLAGS=$CXXFLAGS
12861        CXXFLAGS="$CXXFLAGS $flag_f16c"
12862        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12863            #include <immintrin.h>
12864            int main () {
12865                __m128i a = _mm_set1_epi32 (0);
12866                __m128 c;
12867                c = _mm_cvtph_ps(a);
12868                return 0;
12869            }
12870            ])],
12871            [can_compile_f16c=yes],
12872            [can_compile_f16c=no])
12873        AC_LANG_POP([C++])
12874        CXXFLAGS=$save_CXXFLAGS
12875        AC_MSG_RESULT([${can_compile_f16c}])
12876        if test "${can_compile_f16c}" = "yes" ; then
12877            LO_CLANG_CXXFLAGS_INTRINSICS_F16C="$flag_f16c"
12878        fi
12879
12880        AC_MSG_CHECKING([whether $CXX can compile FMA intrinsics])
12881        AC_LANG_PUSH([C++])
12882        save_CXXFLAGS=$CXXFLAGS
12883        CXXFLAGS="$CXXFLAGS $flag_fma"
12884        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
12885            #include <immintrin.h>
12886            int main () {
12887                __m256 a = _mm256_set1_ps (0.0f), b = _mm256_set1_ps (0.0f), c = _mm256_set1_ps (0.0f), d;
12888                d = _mm256_fmadd_ps(a, b, c);
12889                return 0;
12890            }
12891            ])],
12892            [can_compile_fma=yes],
12893            [can_compile_fma=no])
12894        AC_LANG_POP([C++])
12895        CXXFLAGS=$save_CXXFLAGS
12896        AC_MSG_RESULT([${can_compile_fma}])
12897        if test "${can_compile_fma}" = "yes" ; then
12898            LO_CLANG_CXXFLAGS_INTRINSICS_FMA="$flag_fma"
12899        fi
12900
12901        CXX="$save_CXX"
12902    fi
12903fi
12904#
12905# prefix LO_CLANG_CC/LO_CLANG_CXX with ccache if needed
12906#
12907if test "$CCACHE" != "" -a -n "$LO_CLANG_CC" -a -n "$LO_CLANG_CXX"; then
12908    AC_MSG_CHECKING([whether $LO_CLANG_CC is already ccached])
12909    AC_LANG_PUSH([C])
12910    save_CC="$CC"
12911    CC="$LO_CLANG_CC"
12912    save_CFLAGS=$CFLAGS
12913    CFLAGS="$CFLAGS --ccache-skip -O2 -Werror"
12914    dnl an empty program will do, we're checking the compiler flags
12915    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
12916                      [use_ccache=yes], [use_ccache=no])
12917    CFLAGS=$save_CFLAGS
12918    CC=$save_CC
12919    if test $use_ccache = yes -a "${CCACHE/*sccache*/}" != ""; then
12920        AC_MSG_RESULT([yes])
12921    else
12922        LO_CLANG_CC="$CCACHE $LO_CLANG_CC"
12923        AC_MSG_RESULT([no])
12924    fi
12925    AC_LANG_POP([C])
12926
12927    AC_MSG_CHECKING([whether $LO_CLANG_CXX is already ccached])
12928    AC_LANG_PUSH([C++])
12929    save_CXX="$CXX"
12930    CXX="$LO_CLANG_CXX"
12931    save_CXXFLAGS=$CXXFLAGS
12932    CXXFLAGS="$CXXFLAGS --ccache-skip -O2 -Werror"
12933    dnl an empty program will do, we're checking the compiler flags
12934    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
12935                      [use_ccache=yes], [use_ccache=no])
12936    if test $use_ccache = yes -a "${CCACHE/*sccache*/}" != ""; then
12937        AC_MSG_RESULT([yes])
12938    else
12939        LO_CLANG_CXX="$CCACHE $LO_CLANG_CXX"
12940        AC_MSG_RESULT([no])
12941    fi
12942    CXXFLAGS=$save_CXXFLAGS
12943    CXX=$save_CXX
12944    AC_LANG_POP([C++])
12945fi
12946
12947AC_SUBST(LO_CLANG_CC)
12948AC_SUBST(LO_CLANG_CXX)
12949AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_SSE2)
12950AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_SSSE3)
12951AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_SSE41)
12952AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_SSE42)
12953AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_AVX)
12954AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_AVX2)
12955AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_AVX512)
12956AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_AVX512F)
12957AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_F16C)
12958AC_SUBST(LO_CLANG_CXXFLAGS_INTRINSICS_FMA)
12959AC_SUBST(LO_CLANG_SHOWINCLUDES_PREFIX)
12960AC_SUBST(LO_CLANG_VERSION)
12961AC_SUBST(CLANG_USE_LD)
12962AC_SUBST([HAVE_LO_CLANG_DLLEXPORTINLINES])
12963
12964SYSTEM_GPGMEPP=
12965
12966AC_MSG_CHECKING([whether to enable gpgmepp])
12967if test "$enable_gpgmepp" = no; then
12968    AC_MSG_RESULT([no])
12969elif test "$enable_mpl_subset" = "yes"; then
12970    AC_MSG_RESULT([no (MPL only)])
12971elif test "$enable_fuzzers" = "yes"; then
12972    AC_MSG_RESULT([no (oss-fuzz)])
12973elif test \( \( "$_os" = "Linux" -o "$_os" = "Darwin" \) -a "$ENABLE_NSS" = TRUE \) -o "$_os" = "WINNT" ; then
12974    AC_MSG_RESULT([yes])
12975    dnl ===================================================================
12976    dnl Check for system gpgme
12977    dnl ===================================================================
12978    AC_MSG_CHECKING([which gpgmepp to use])
12979    if test "$with_system_gpgmepp" = "yes"; then
12980        AC_MSG_RESULT([external])
12981        SYSTEM_GPGMEPP=TRUE
12982
12983        # C++ library doesn't come with fancy gpgmepp-config, check for headers the old-fashioned way
12984        AC_CHECK_HEADER(gpgme++/gpgmepp_version.h, [ GPGMEPP_CFLAGS=-I/usr/include/gpgme++ ],
12985            [AC_MSG_ERROR([gpgmepp headers not found, install gpgmepp >= 1.14 development package])], [])
12986        AC_CHECK_HEADER(gpgme.h, [],
12987            [AC_MSG_ERROR([gpgme headers not found, install gpgme development package])], [])
12988        AC_CHECK_LIB(gpgmepp, main, [],
12989            [AC_MSG_ERROR(gpgmepp not found or not functional)], [])
12990        GPGMEPP_LIBS=-lgpgmepp
12991    else
12992        AC_MSG_RESULT([internal])
12993        BUILD_TYPE="$BUILD_TYPE LIBGPGERROR LIBASSUAN GPGMEPP"
12994
12995        GPG_ERROR_CFLAGS="-I${WORKDIR}/UnpackedTarball/libgpg-error/src"
12996        LIBASSUAN_CFLAGS="-I${WORKDIR}/UnpackedTarball/libassuan/src"
12997        if test "$_os" != "WINNT"; then
12998            GPG_ERROR_LIBS="-L${WORKDIR}/UnpackedTarball/libgpg-error/src/.libs -lgpg-error"
12999            LIBASSUAN_LIBS="-L${WORKDIR}/UnpackedTarball/libassuan/src/.libs -lassuan"
13000        fi
13001    fi
13002    ENABLE_GPGMEPP=TRUE
13003    AC_DEFINE([HAVE_FEATURE_GPGME])
13004    AC_PATH_PROG(GPG, gpg)
13005    # TODO: Windows's cygwin gpg does not seem to work with our gpgme,
13006    # so let's exclude that manually for the moment
13007    if test -n "$GPG" -a "$_os" != "WINNT"; then
13008        # make sure we not only have a working gpgme, but a full working
13009        # gpg installation to run OpenPGP signature verification
13010        AC_DEFINE([HAVE_FEATURE_GPGVERIFY])
13011    fi
13012    if test "$_os" = "Linux"; then
13013      uid=`id -u`
13014      AC_MSG_CHECKING([for /run/user/$uid])
13015      if test -d /run/user/$uid; then
13016        AC_MSG_RESULT([yes])
13017        AC_PATH_PROG(GPGCONF, gpgconf)
13018
13019        # Older versions of gpgconf are not working as expected, since
13020        # `gpgconf --remove-socketdir` fails to exit any gpg-agent daemon operating
13021        # on that socket dir that has (indirectly) been started by the tests in xmlsecurity/qa/unit/signing/signing.cxx
13022        # (see commit message of f0305ec0a7d199e605511844d9d6af98b66d4bfd%5E )
13023        AC_MSG_CHECKING([whether version of gpgconf is suitable ... ])
13024        GPGCONF_VERSION=`"$GPGCONF" --version | "$AWK" '/^gpgconf \(GnuPG\)/{print $3}'`
13025        GPGCONF_NUMVER=`echo $GPGCONF_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
13026        if test "$GPGCONF_VERSION" = "2.2_OOo" -o "$GPGCONF_NUMVER" -ge "020200"; then
13027          AC_MSG_RESULT([yes, $GPGCONF_VERSION])
13028          AC_MSG_CHECKING([for gpgconf --create-socketdir... ])
13029          if $GPGCONF --dump-options > /dev/null ; then
13030            if $GPGCONF --dump-options | grep -q create-socketdir ; then
13031              AC_MSG_RESULT([yes])
13032              AC_DEFINE([HAVE_GPGCONF_SOCKETDIR])
13033              AC_DEFINE_UNQUOTED([GPGME_GPGCONF], ["$GPGCONF"])
13034            else
13035              AC_MSG_RESULT([no])
13036            fi
13037          else
13038            AC_MSG_RESULT([no. missing or broken gpgconf?])
13039          fi
13040        else
13041          AC_MSG_RESULT([no, $GPGCONF_VERSION])
13042        fi
13043      else
13044        AC_MSG_RESULT([no])
13045     fi
13046   fi
13047else
13048    AC_MSG_RESULT([no (unsupported OS or missing NSS)])
13049fi
13050AC_SUBST(ENABLE_GPGMEPP)
13051AC_SUBST(SYSTEM_GPGMEPP)
13052AC_SUBST(GPG_ERROR_CFLAGS)
13053AC_SUBST(GPG_ERROR_LIBS)
13054AC_SUBST(LIBASSUAN_CFLAGS)
13055AC_SUBST(LIBASSUAN_LIBS)
13056AC_SUBST(GPGMEPP_CFLAGS)
13057AC_SUBST(GPGMEPP_LIBS)
13058
13059AC_MSG_CHECKING([whether to build Java Websocket for the UNO remote websocket client])
13060if test "$with_java" != "no"; then
13061    AC_MSG_RESULT([yes])
13062    ENABLE_JAVA_WEBSOCKET=TRUE
13063    BUILD_TYPE="$BUILD_TYPE JAVA_WEBSOCKET"
13064    NEED_ANT=TRUE
13065else
13066    AC_MSG_RESULT([no])
13067    ENABLE_JAVA_WEBSOCKET=
13068fi
13069AC_SUBST(ENABLE_JAVA_WEBSOCKET)
13070
13071AC_MSG_CHECKING([whether to build the Wiki Publisher extension])
13072if test "x$enable_ext_wiki_publisher" = "xyes" -a "x$enable_extension_integration" != "xno" -a "$with_java" != "no"; then
13073    AC_MSG_RESULT([yes])
13074    ENABLE_MEDIAWIKI=TRUE
13075    BUILD_TYPE="$BUILD_TYPE XSLTML"
13076    if test  "x$with_java" = "xno"; then
13077        AC_MSG_ERROR([Wiki Publisher requires Java! Enable Java if you want to build it.])
13078    fi
13079else
13080    AC_MSG_RESULT([no])
13081    ENABLE_MEDIAWIKI=
13082    SCPDEFS="$SCPDEFS -DWITHOUT_EXTENSION_MEDIAWIKI"
13083fi
13084AC_SUBST(ENABLE_MEDIAWIKI)
13085
13086AC_MSG_CHECKING([whether to build the Report Builder])
13087if test "$enable_report_builder" != "no" -a "$with_java" != "no"; then
13088    AC_MSG_RESULT([yes])
13089    ENABLE_REPORTBUILDER=TRUE
13090    AC_MSG_CHECKING([which jfreereport libs to use])
13091    if test "$with_system_jfreereport" = "yes"; then
13092        SYSTEM_JFREEREPORT=TRUE
13093        AC_MSG_RESULT([external])
13094        if test -z $SAC_JAR; then
13095            SAC_JAR=/usr/share/java/sac.jar
13096        fi
13097        if ! test -f $SAC_JAR; then
13098             AC_MSG_ERROR(sac.jar not found.)
13099        fi
13100
13101        if test -z $LIBXML_JAR; then
13102            if test -f /usr/share/java/libxml-1.0.0.jar; then
13103                LIBXML_JAR=/usr/share/java/libxml-1.0.0.jar
13104            elif test -f /usr/share/java/libxml.jar; then
13105                LIBXML_JAR=/usr/share/java/libxml.jar
13106            else
13107                AC_MSG_ERROR(libxml.jar replacement not found.)
13108            fi
13109        elif ! test -f $LIBXML_JAR; then
13110            AC_MSG_ERROR(libxml.jar not found.)
13111        fi
13112
13113        if test -z $FLUTE_JAR; then
13114            if test -f /usr/share/java/flute-1.3.0.jar; then
13115                FLUTE_JAR=/usr/share/java/flute-1.3.0.jar
13116            elif test -f /usr/share/java/flute.jar; then
13117                FLUTE_JAR=/usr/share/java/flute.jar
13118            else
13119                AC_MSG_ERROR(flute-1.3.0.jar replacement not found.)
13120            fi
13121        elif ! test -f $FLUTE_JAR; then
13122            AC_MSG_ERROR(flute-1.3.0.jar not found.)
13123        fi
13124
13125        if test -z $JFREEREPORT_JAR; then
13126            if test -f /usr/share/java/flow-engine-0.9.2.jar; then
13127                JFREEREPORT_JAR=/usr/share/java/flow-engine-0.9.2.jar
13128            elif test -f /usr/share/java/flow-engine.jar; then
13129                JFREEREPORT_JAR=/usr/share/java/flow-engine.jar
13130            else
13131                AC_MSG_ERROR(jfreereport.jar replacement not found.)
13132            fi
13133        elif ! test -f  $JFREEREPORT_JAR; then
13134                AC_MSG_ERROR(jfreereport.jar not found.)
13135        fi
13136
13137        if test -z $LIBLAYOUT_JAR; then
13138            if test -f /usr/share/java/liblayout-0.2.9.jar; then
13139                LIBLAYOUT_JAR=/usr/share/java/liblayout-0.2.9.jar
13140            elif test -f /usr/share/java/liblayout.jar; then
13141                LIBLAYOUT_JAR=/usr/share/java/liblayout.jar
13142            else
13143                AC_MSG_ERROR(liblayout.jar replacement not found.)
13144            fi
13145        elif ! test -f $LIBLAYOUT_JAR; then
13146                AC_MSG_ERROR(liblayout.jar not found.)
13147        fi
13148
13149        if test -z $LIBLOADER_JAR; then
13150            if test -f /usr/share/java/libloader-1.0.0.jar; then
13151                LIBLOADER_JAR=/usr/share/java/libloader-1.0.0.jar
13152            elif test -f /usr/share/java/libloader.jar; then
13153                LIBLOADER_JAR=/usr/share/java/libloader.jar
13154            else
13155                AC_MSG_ERROR(libloader.jar replacement not found.)
13156            fi
13157        elif ! test -f  $LIBLOADER_JAR; then
13158            AC_MSG_ERROR(libloader.jar not found.)
13159        fi
13160
13161        if test -z $LIBFORMULA_JAR; then
13162            if test -f /usr/share/java/libformula-0.2.0.jar; then
13163                LIBFORMULA_JAR=/usr/share/java/libformula-0.2.0.jar
13164            elif test -f /usr/share/java/libformula.jar; then
13165                LIBFORMULA_JAR=/usr/share/java/libformula.jar
13166            else
13167                AC_MSG_ERROR(libformula.jar replacement not found.)
13168            fi
13169        elif ! test -f $LIBFORMULA_JAR; then
13170                AC_MSG_ERROR(libformula.jar not found.)
13171        fi
13172
13173        if test -z $LIBREPOSITORY_JAR; then
13174            if test -f /usr/share/java/librepository-1.0.0.jar; then
13175                LIBREPOSITORY_JAR=/usr/share/java/librepository-1.0.0.jar
13176            elif test -f /usr/share/java/librepository.jar; then
13177                LIBREPOSITORY_JAR=/usr/share/java/librepository.jar
13178            else
13179                AC_MSG_ERROR(librepository.jar replacement not found.)
13180            fi
13181        elif ! test -f $LIBREPOSITORY_JAR; then
13182            AC_MSG_ERROR(librepository.jar not found.)
13183        fi
13184
13185        if test -z $LIBFONTS_JAR; then
13186            if test -f /usr/share/java/libfonts-1.0.0.jar; then
13187                LIBFONTS_JAR=/usr/share/java/libfonts-1.0.0.jar
13188            elif test -f /usr/share/java/libfonts.jar; then
13189                LIBFONTS_JAR=/usr/share/java/libfonts.jar
13190            else
13191                AC_MSG_ERROR(libfonts.jar replacement not found.)
13192            fi
13193        elif ! test -f $LIBFONTS_JAR; then
13194                AC_MSG_ERROR(libfonts.jar not found.)
13195        fi
13196
13197        if test -z $LIBSERIALIZER_JAR; then
13198            if test -f /usr/share/java/libserializer-1.0.0.jar; then
13199                LIBSERIALIZER_JAR=/usr/share/java/libserializer-1.0.0.jar
13200            elif test -f /usr/share/java/libserializer.jar; then
13201                LIBSERIALIZER_JAR=/usr/share/java/libserializer.jar
13202            else
13203                AC_MSG_ERROR(libserializer.jar replacement not found.)
13204            fi
13205        elif ! test -f $LIBSERIALIZER_JAR; then
13206                AC_MSG_ERROR(libserializer.jar not found.)
13207        fi
13208
13209        if test -z $LIBBASE_JAR; then
13210            if test -f /usr/share/java/libbase-1.0.0.jar; then
13211                LIBBASE_JAR=/usr/share/java/libbase-1.0.0.jar
13212            elif test -f /usr/share/java/libbase.jar; then
13213                LIBBASE_JAR=/usr/share/java/libbase.jar
13214            else
13215                AC_MSG_ERROR(libbase.jar replacement not found.)
13216            fi
13217        elif ! test -f $LIBBASE_JAR; then
13218            AC_MSG_ERROR(libbase.jar not found.)
13219        fi
13220
13221    else
13222        AC_MSG_RESULT([internal])
13223        SYSTEM_JFREEREPORT=
13224        BUILD_TYPE="$BUILD_TYPE JFREEREPORT"
13225        NEED_ANT=TRUE
13226    fi
13227    BUILD_TYPE="$BUILD_TYPE REPORTBUILDER"
13228else
13229    AC_MSG_RESULT([no])
13230    ENABLE_REPORTBUILDER=
13231    SYSTEM_JFREEREPORT=
13232fi
13233AC_SUBST(ENABLE_REPORTBUILDER)
13234AC_SUBST(SYSTEM_JFREEREPORT)
13235AC_SUBST(SAC_JAR)
13236AC_SUBST(LIBXML_JAR)
13237AC_SUBST(FLUTE_JAR)
13238AC_SUBST(JFREEREPORT_JAR)
13239AC_SUBST(LIBBASE_JAR)
13240AC_SUBST(LIBLAYOUT_JAR)
13241AC_SUBST(LIBLOADER_JAR)
13242AC_SUBST(LIBFORMULA_JAR)
13243AC_SUBST(LIBREPOSITORY_JAR)
13244AC_SUBST(LIBFONTS_JAR)
13245AC_SUBST(LIBSERIALIZER_JAR)
13246
13247# scripting provider for BeanShell?
13248AC_MSG_CHECKING([whether to build support for scripts in BeanShell])
13249if test "${enable_scripting_beanshell}" != "no" -a "x$with_java" != "xno"; then
13250    AC_MSG_RESULT([yes])
13251    ENABLE_SCRIPTING_BEANSHELL=TRUE
13252
13253    dnl ===================================================================
13254    dnl Check for system beanshell
13255    dnl ===================================================================
13256    AC_MSG_CHECKING([which beanshell to use])
13257    if test "$with_system_beanshell" = "yes"; then
13258        AC_MSG_RESULT([external])
13259        SYSTEM_BSH=TRUE
13260        if test -z $BSH_JAR; then
13261            BSH_JAR=/usr/share/java/bsh.jar
13262        fi
13263        if ! test -f $BSH_JAR; then
13264            AC_MSG_ERROR(bsh.jar not found.)
13265        fi
13266    else
13267        AC_MSG_RESULT([internal])
13268        SYSTEM_BSH=
13269        BUILD_TYPE="$BUILD_TYPE BSH"
13270    fi
13271else
13272    AC_MSG_RESULT([no])
13273    ENABLE_SCRIPTING_BEANSHELL=
13274    SCPDEFS="$SCPDEFS -DWITHOUT_SCRIPTING_BEANSHELL"
13275fi
13276AC_SUBST(ENABLE_SCRIPTING_BEANSHELL)
13277AC_SUBST(SYSTEM_BSH)
13278AC_SUBST(BSH_JAR)
13279
13280# scripting provider for JavaScript?
13281AC_MSG_CHECKING([whether to build support for scripts in JavaScript])
13282if test "${enable_scripting_javascript}" != "no" -a "x$with_java" != "xno"; then
13283    AC_MSG_RESULT([yes])
13284    ENABLE_SCRIPTING_JAVASCRIPT=TRUE
13285
13286    dnl ===================================================================
13287    dnl Check for system rhino
13288    dnl ===================================================================
13289    AC_MSG_CHECKING([which rhino to use])
13290    if test "$with_system_rhino" = "yes"; then
13291        AC_MSG_RESULT([external])
13292        SYSTEM_RHINO=TRUE
13293        if test -z $RHINO_JAR; then
13294            RHINO_JAR=/usr/share/java/js.jar
13295        fi
13296        if ! test -f $RHINO_JAR; then
13297            AC_MSG_ERROR(js.jar not found.)
13298        fi
13299    else
13300        AC_MSG_RESULT([internal])
13301        SYSTEM_RHINO=
13302        BUILD_TYPE="$BUILD_TYPE RHINO"
13303        NEED_ANT=TRUE
13304    fi
13305else
13306    AC_MSG_RESULT([no])
13307    ENABLE_SCRIPTING_JAVASCRIPT=
13308    SCPDEFS="$SCPDEFS -DWITHOUT_SCRIPTING_JAVASCRIPT"
13309fi
13310AC_SUBST(ENABLE_SCRIPTING_JAVASCRIPT)
13311AC_SUBST(SYSTEM_RHINO)
13312AC_SUBST(RHINO_JAR)
13313
13314# This is only used in Qt5/Qt6/KF5/KF6 checks to determine if /usr/lib64
13315# paths should be added to library search path. So let's put all 64-bit
13316# platforms there.
13317supports_multilib=
13318case "$host_cpu" in
13319x86_64 | powerpc64 | powerpc64le | s390x | aarch64 | mips64 | mips64el | loongarch64 | riscv64)
13320    if test "$SAL_TYPES_SIZEOFLONG" = "8"; then
13321        supports_multilib="yes"
13322    fi
13323    ;;
13324*)
13325    ;;
13326esac
13327
13328dnl ===================================================================
13329dnl QT5 Integration
13330dnl ===================================================================
13331
13332QT5_CFLAGS=""
13333QT5_LIBS=""
13334QT5_GOBJECT_CFLAGS=""
13335QT5_GOBJECT_LIBS=""
13336QT5_HAVE_GOBJECT=""
13337QT5_PLATFORMS_SRCDIR=""
13338if test \( "$test_kf5" = "yes" -a "$ENABLE_KF5" = "TRUE" \) -o \
13339        \( "$test_qt5" = "yes" -a "$ENABLE_QT5" = "TRUE" \) -o \
13340        \( "$test_gtk3_kde5" = "yes" -a "$ENABLE_GTK3_KDE5" = "TRUE" \)
13341then
13342    qt5_incdirs="$QT5INC /usr/include/qt5 /usr/include $x_includes"
13343    qt5_libdirs="$QT5LIB /usr/lib/qt5 /usr/lib $x_libraries"
13344
13345    if test -n "$supports_multilib"; then
13346        qt5_libdirs="$qt5_libdirs /usr/lib64/qt5 /usr/lib64/qt /usr/lib64"
13347    fi
13348
13349    qt5_test_include="QtWidgets/qapplication.h"
13350    if test "$_os" = "Emscripten"; then
13351        qt5_test_library="libQt5Widgets.a"
13352    else
13353        qt5_test_library="libQt5Widgets.so"
13354    fi
13355
13356    dnl Check for qmake5
13357    if test -n "$QT5DIR"; then
13358        AC_PATH_PROG(QMAKE5, [qmake], no, [$QT5DIR/bin])
13359    else
13360        AC_PATH_PROGS(QMAKE5, [qmake-qt5 qmake], no)
13361    fi
13362    if test "$QMAKE5" = "no"; then
13363        AC_MSG_ERROR([Qmake not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
13364    else
13365        qmake5_test_ver="`$QMAKE5 -v 2>&1 | $SED -n -e 's/^Using Qt version \(5\.[[0-9.]]\+\).*$/\1/p'`"
13366        if test -z "$qmake5_test_ver"; then
13367            AC_MSG_ERROR([Wrong qmake for Qt5 found. Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
13368        fi
13369        qmake5_minor_version="`echo $qmake5_test_ver | cut -d. -f2`"
13370        qt5_minimal_minor="15"
13371        if test "$qmake5_minor_version" -lt "$qt5_minimal_minor"; then
13372            AC_MSG_ERROR([The minimal supported Qt5 version is 5.${qt5_minimal_minor}, but your 'qmake -v' reports Qt5 version $qmake5_test_ver.])
13373        else
13374            AC_MSG_NOTICE([Detected Qt5 version: $qmake5_test_ver])
13375        fi
13376    fi
13377
13378    qt5_incdirs="`$QMAKE5 -query QT_INSTALL_HEADERS` $qt5_incdirs"
13379    qt5_libdirs="`$QMAKE5 -query QT_INSTALL_LIBS` $qt5_libdirs"
13380    qt5_platformsdir="`$QMAKE5 -query QT_INSTALL_PLUGINS`/platforms"
13381    QT5_PLATFORMS_SRCDIR="$qt5_platformsdir"
13382
13383    AC_MSG_CHECKING([for Qt5 headers])
13384    qt5_incdir="no"
13385    for inc_dir in $qt5_incdirs; do
13386        if test -r "$inc_dir/$qt5_test_include"; then
13387            qt5_incdir="$inc_dir"
13388            break
13389        fi
13390    done
13391    AC_MSG_RESULT([$qt5_incdir])
13392    if test "x$qt5_incdir" = "xno"; then
13393        AC_MSG_ERROR([Qt5 headers not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
13394    fi
13395    # check for scenario: qt5-qtbase-devel-*.86_64 installed but host is i686
13396    AC_LANG_PUSH([C++])
13397    save_CPPFLAGS=$CPPFLAGS
13398    CPPFLAGS="${CPPFLAGS} -I${qt5_incdir}"
13399    AC_CHECK_HEADER(QtCore/qconfig.h, [],
13400        [AC_MSG_ERROR(qconfig.h header not found.)], [])
13401    CPPFLAGS=$save_CPPFLAGS
13402    AC_LANG_POP([C++])
13403
13404    AC_MSG_CHECKING([for Qt5 libraries])
13405    qt5_libdir="no"
13406    for lib_dir in $qt5_libdirs; do
13407        if test -r "$lib_dir/$qt5_test_library"; then
13408            qt5_libdir="$lib_dir"
13409            break
13410        fi
13411    done
13412    AC_MSG_RESULT([$qt5_libdir])
13413    if test "x$qt5_libdir" = "xno"; then
13414        AC_MSG_ERROR([Qt5 libraries not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
13415    fi
13416
13417    if test "$_os" = "Emscripten"; then
13418        if test ! -f "$QT5_PLATFORMS_SRCDIR"/wasm_shell.html ; then
13419            QT5_PLATFORMS_SRCDIR="${QT5_PLATFORMS_SRCDIR/plugins/src\/plugins}/wasm"
13420        fi
13421        if test ! -f "${qt5_platformsdir}"/libqwasm.a -o ! -f "$QT5_PLATFORMS_SRCDIR"/wasm_shell.html; then
13422            AC_MSG_ERROR([No Qt5 WASM QPA plugin found in ${qt5_platformsdir} or ${QT5_PLATFORMS_SRCDIR}])
13423        fi
13424
13425        EMSDK_LLVM_NM="$(em-config LLVM_ROOT)"/llvm-nm
13426        if ! test -x "$EMSDK_LLVM_NM"; then
13427            AC_MSG_ERROR([Missing llvm-nm expected to be found at "$EMSDK_LLVM_NM".])
13428        fi
13429        if test ! -f "${qt5_libdir}"/libQt5Gui.a; then
13430            AC_MSG_ERROR([No Qt5 WASM libQt5Gui.a in ${qt5_libdir}])
13431        fi
13432        QT5_WASM_SJLJ="`${EMSDK_LLVM_NM} "${qt5_libdir}"/libQt5Gui.a 2>/dev/null | $GREP emscripten_longjmp`"
13433        if test -n "$QT5_WASM_SJLJ"; then
13434            AC_MSG_ERROR(['emscripten_longjmp' symbol found in libQt5Gui.a (missing '-s SUPPORT_LONGJMP=wasm'). See static/README.wasm.md.])
13435        fi
13436    fi
13437
13438    QT5_CFLAGS="-I$qt5_incdir -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT -DQT_NO_VERSION_TAGGING"
13439    QT5_CFLAGS=$(printf '%s' "$QT5_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
13440    QT5_LIBS="-L$qt5_libdir -lQt5Core -lQt5Gui -lQt5Widgets -lQt5Network"
13441    if test "$_os" = "Emscripten"; then
13442        QT5_LIBS="$QT5_LIBS -lqtpcre2 -lQt5EventDispatcherSupport -lQt5FontDatabaseSupport -L${qt5_platformsdir} -lqwasm"
13443    fi
13444
13445    if test "$USING_X11" = TRUE; then
13446        PKG_CHECK_MODULES(QT5_XCB,[xcb],,[AC_MSG_ERROR([XCB not found, which is needed for correct app grouping in X11.])])
13447        QT5_CFLAGS="$QT5_CFLAGS $QT5_XCB_CFLAGS $QT5_XCB_ICCCM_CFLAGS"
13448        QT5_LIBS="$QT5_LIBS $QT5_XCB_LIBS $QT5_XCB_ICCCM_LIBS -lQt5X11Extras"
13449        QT5_USING_X11=1
13450        AC_DEFINE(QT5_USING_X11)
13451    fi
13452
13453    dnl Check for Meta Object Compiler
13454
13455    AC_PATH_PROGS( MOC5, [moc-qt5 moc], no, [`dirname $qt5_libdir`/bin:$QT5DIR/bin:$PATH])
13456    if test "$MOC5" = "no"; then
13457        AC_MSG_ERROR([Qt Meta Object Compiler not found.  Please specify
13458the root of your Qt installation by exporting QT5DIR before running "configure".])
13459    fi
13460
13461    if test "$test_gstreamer_1_0" = yes; then
13462        PKG_CHECK_MODULES(QT5_GOBJECT,[gobject-2.0], [
13463                QT5_HAVE_GOBJECT=1
13464                AC_DEFINE(QT5_HAVE_GOBJECT)
13465            ],
13466            AC_MSG_WARN([[No GObject found, can't use QWidget GStreamer sink on wayland!]])
13467        )
13468    fi
13469fi
13470AC_SUBST(QT5_CFLAGS)
13471AC_SUBST(QT5_LIBS)
13472AC_SUBST(MOC5)
13473AC_SUBST(QT5_GOBJECT_CFLAGS)
13474AC_SUBST(QT5_GOBJECT_LIBS)
13475AC_SUBST(QT5_HAVE_GOBJECT)
13476AC_SUBST(QT5_PLATFORMS_SRCDIR)
13477
13478dnl ===================================================================
13479dnl QT6 Integration
13480dnl ===================================================================
13481
13482QT6_CFLAGS=""
13483QT6_LIBS=""
13484QT6_PLATFORMS_SRCDIR=""
13485ENABLE_QT6_MULTIMEDIA=""
13486if test \( "$test_kf6" = "yes" -a "$ENABLE_KF6" = "TRUE" \) -o \
13487        \( "$test_qt6" = "yes" -a "$ENABLE_QT6" = "TRUE" \)
13488then
13489    qt6_incdirs="$QT6INC /usr/include/qt6 /usr/include $x_includes"
13490    qt6_libdirs="$QT6LIB /usr/lib/qt6 /usr/lib $x_libraries"
13491
13492    if test -n "$supports_multilib"; then
13493        qt6_libdirs="$qt6_libdirs /usr/lib64/qt6 /usr/lib64/qt /usr/lib64"
13494    fi
13495
13496    qt6_test_include="QtWidgets/qapplication.h"
13497    if test "$_os" = "Emscripten"; then
13498        qt6_test_library="libQt6Widgets.a"
13499    else
13500        qt6_test_library="libQt6Widgets.so"
13501    fi
13502
13503    dnl Check for qmake6
13504    if test -n "$QT6DIR"; then
13505        AC_PATH_PROG(QMAKE6, [qmake], no, [$QT6DIR/bin])
13506    else
13507        AC_PATH_PROGS(QMAKE6, [qmake-qt6 qmake6 qmake], no)
13508    fi
13509    if test "$QMAKE6" = "no"; then
13510        AC_MSG_ERROR([Qmake not found.  Please specify the root of your Qt6 installation by exporting QT6DIR before running "configure".])
13511    else
13512        qmake6_test_ver="`$QMAKE6 -v 2>&1 | $SED -n -e 's/^Using Qt version \(6\.[[0-9.]]\+\).*$/\1/p'`"
13513        if test -z "$qmake6_test_ver"; then
13514            AC_MSG_ERROR([Wrong qmake for Qt6 found. Please specify the root of your Qt6 installation by exporting QT6DIR before running "configure".])
13515        fi
13516        AC_MSG_NOTICE([Detected Qt6 version: $qmake6_test_ver])
13517    fi
13518
13519    qt6_incdirs="`$QMAKE6 -query QT_INSTALL_HEADERS` $qt6_incdirs"
13520    qt6_libdirs="`$QMAKE6 -query QT_INSTALL_LIBS` $qt6_libdirs"
13521    qt6_platformsdir="`$QMAKE6 -query QT_INSTALL_PLUGINS`/platforms"
13522    QT6_PLATFORMS_SRCDIR="$qt6_platformsdir"
13523
13524    AC_MSG_CHECKING([for Qt6 headers])
13525    qt6_incdir="no"
13526    for inc_dir in $qt6_incdirs; do
13527        if test -r "$inc_dir/$qt6_test_include"; then
13528            qt6_incdir="$inc_dir"
13529            break
13530        fi
13531    done
13532    AC_MSG_RESULT([$qt6_incdir])
13533    if test "x$qt6_incdir" = "xno"; then
13534        AC_MSG_ERROR([Qt6 headers not found.  Please specify the root of your Qt6 installation by exporting QT6DIR before running "configure".])
13535    fi
13536    # check for scenario: qt6-qtbase-devel-*.86_64 installed but host is i686
13537    AC_LANG_PUSH([C++])
13538    save_CPPFLAGS=$CPPFLAGS
13539    CPPFLAGS="${CPPFLAGS} -I${qt6_incdir}"
13540    AC_CHECK_HEADER(QtCore/qconfig.h, [],
13541        [AC_MSG_ERROR(qconfig.h header not found.)], [])
13542    CPPFLAGS=$save_CPPFLAGS
13543    AC_LANG_POP([C++])
13544
13545    AC_MSG_CHECKING([for Qt6 libraries])
13546    qt6_libdir="no"
13547    for lib_dir in $qt6_libdirs; do
13548        if test -r "$lib_dir/$qt6_test_library"; then
13549            qt6_libdir="$lib_dir"
13550            break
13551        fi
13552    done
13553    AC_MSG_RESULT([$qt6_libdir])
13554    if test "x$qt6_libdir" = "xno"; then
13555        AC_MSG_ERROR([Qt6 libraries not found.  Please specify the root of your Qt6 installation by exporting QT6DIR before running "configure".])
13556    fi
13557
13558    if test "$_os" = "Emscripten"; then
13559        if test ! -f "$QT6_PLATFORMS_SRCDIR"/wasm_shell.html ; then
13560            QT6_PLATFORMS_SRCDIR="${QT6_PLATFORMS_SRCDIR/plugins/src\/plugins}/wasm"
13561        fi
13562        if test ! -f "${qt6_platformsdir}"/libqwasm.a -o ! -f "$QT6_PLATFORMS_SRCDIR"/wasm_shell.html; then
13563            AC_MSG_ERROR([No Qt6 WASM QPA plugin found in ${qt6_platformsdir} or ${QT6_PLATFORMS_SRCDIR}])
13564        fi
13565    fi
13566
13567    QT6_CFLAGS="-I$qt6_incdir -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT -DQT_NO_VERSION_TAGGING"
13568    QT6_CFLAGS=$(printf '%s' "$QT6_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
13569    QT6_LIBS="-L$qt6_libdir -lQt6Core -lQt6Gui -lQt6Widgets -lQt6Network"
13570    if test "$_os" = "Emscripten"; then
13571        QT6_LIBS="$QT6_LIBS -lQt6BundledPcre2 -lQt6BundledZLIB -L${qt6_platformsdir} -lqwasm -sGL_ENABLE_GET_PROC_ADDRESS"
13572    else
13573        if ! test "$enable_qt6_multimedia" = "no"; then
13574            if ! test -r "$qt6_incdir/QtMultimediaWidgets/QVideoWidget"; then
13575                AC_MSG_ERROR([Qt 6 QMultimedia not found.])
13576                break
13577            fi
13578            ENABLE_QT6_MULTIMEDIA=TRUE
13579            QT6_LIBS="$QT6_LIBS -lQt6Multimedia -lQt6MultimediaWidgets"
13580        fi
13581    fi
13582
13583    if test "$USING_X11" = TRUE; then
13584        PKG_CHECK_MODULES(QT6_XCB,[xcb],,[AC_MSG_ERROR([XCB not found, which is needed for key modifier handling in X11.])])
13585        QT6_CFLAGS="$QT6_CFLAGS $QT6_XCB_CFLAGS"
13586        QT6_LIBS="$QT6_LIBS $QT6_XCB_LIBS"
13587        QT6_USING_X11=1
13588        AC_DEFINE(QT6_USING_X11)
13589    fi
13590
13591    dnl Check for Meta Object Compiler
13592
13593    for lib_dir in $qt6_libdirs; do
13594        if test -z "$qt6_libexec_dirs"; then
13595            qt6_libexec_dirs="$lib_dir/libexec"
13596        else
13597            qt6_libexec_dirs="$qt6_libexec_dirs:$lib_dir/libexec"
13598        fi
13599    done
13600    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])
13601    if test "$MOC6" = "no"; then
13602        AC_MSG_ERROR([Qt Meta Object Compiler not found.  Please specify
13603the root of your Qt installation by exporting QT6DIR before running "configure".])
13604    else
13605        moc6_test_ver="`$MOC6 -v 2>&1 | $SED -n -e 's/^moc \(6.*\)/\1/p'`"
13606        if test -z "$moc6_test_ver"; then
13607            AC_MSG_ERROR([Wrong moc for Qt6 found.])
13608        fi
13609        AC_MSG_NOTICE([Detected moc version: $moc_test_ver])
13610    fi
13611fi
13612AC_SUBST(QT6_CFLAGS)
13613AC_SUBST(QT6_LIBS)
13614AC_SUBST(MOC6)
13615AC_SUBST(QT6_PLATFORMS_SRCDIR)
13616AC_SUBST(ENABLE_QT6_MULTIMEDIA)
13617
13618dnl ===================================================================
13619dnl KF5 Integration
13620dnl ===================================================================
13621
13622KF5_CFLAGS=""
13623KF5_LIBS=""
13624KF5_CONFIG="kf5-config"
13625if test \( "$test_kf5" = "yes" -a "$ENABLE_KF5" = "TRUE" \) -o \
13626        \( "$test_gtk3_kde5" = "yes" -a "$ENABLE_GTK3_KDE5" = "TRUE" \)
13627then
13628    if test "$OS" = "HAIKU"; then
13629        haiku_arch="`echo $RTL_ARCH | tr X x`"
13630        kf5_haiku_incdirs="`findpaths -c ' ' -a $haiku_arch B_FIND_PATH_HEADERS_DIRECTORY`"
13631        kf5_haiku_libdirs="`findpaths -c ' ' -a $haiku_arch B_FIND_PATH_DEVELOP_LIB_DIRECTORY`"
13632    fi
13633
13634    kf5_incdirs="$KF5INC /usr/include $kf5_haiku_incdirs $x_includes"
13635    kf5_libdirs="$KF5LIB /usr/lib /usr/lib/kf5 /usr/lib/kf5/devel $kf5_haiku_libdirs $x_libraries"
13636    if test -n "$supports_multilib"; then
13637        kf5_libdirs="$kf5_libdirs /usr/lib64 /usr/lib64/kf5 /usr/lib64/kf5/devel"
13638    fi
13639
13640    kf5_test_include="KF5/KIOFileWidgets/KFileWidget"
13641    kf5_test_library="libKF5KIOFileWidgets.so"
13642    kf5_libdirs="$qt5_libdir $kf5_libdirs"
13643
13644    dnl kf5 KDE4 support compatibility installed
13645    AC_PATH_PROG( KF5_CONFIG, $KF5_CONFIG, no, )
13646    if test "$KF5_CONFIG" != "no"; then
13647        kf5_incdirs="`$KF5_CONFIG --path include` $kf5_incdirs"
13648        kf5_libdirs="`$KF5_CONFIG --path lib` $kf5_libdirs"
13649    fi
13650
13651    dnl Check for KF5 headers
13652    AC_MSG_CHECKING([for KF5 headers])
13653    kf5_incdir="no"
13654    for kf5_check in $kf5_incdirs; do
13655        if test -r "$kf5_check/$kf5_test_include"; then
13656            kf5_incdir="$kf5_check/KF5"
13657            break
13658        fi
13659    done
13660    AC_MSG_RESULT([$kf5_incdir])
13661    if test "x$kf5_incdir" = "xno"; then
13662        AC_MSG_ERROR([KF5 headers not found.  Please specify the root of your KF5 installation by exporting KF5DIR before running "configure".])
13663    fi
13664
13665    dnl Check for KF5 libraries
13666    AC_MSG_CHECKING([for KF5 libraries])
13667    kf5_libdir="no"
13668    for kf5_check in $kf5_libdirs; do
13669        if test -r "$kf5_check/$kf5_test_library"; then
13670            kf5_libdir="$kf5_check"
13671            break
13672        fi
13673    done
13674
13675    AC_MSG_RESULT([$kf5_libdir])
13676    if test "x$kf5_libdir" = "xno"; then
13677        AC_MSG_ERROR([KF5 libraries not found.  Please specify the root of your KF5 installation by exporting KF5DIR before running "configure".])
13678    fi
13679
13680    KF5_CFLAGS="-I$kf5_incdir -I$kf5_incdir/KCoreAddons -I$kf5_incdir/KI18n -I$kf5_incdir/KConfigCore -I$kf5_incdir/KWindowSystem -I$kf5_incdir/KIOCore -I$kf5_incdir/KIOWidgets -I$kf5_incdir/KIOFileWidgets -I$qt5_incdir -I$qt5_incdir/QtCore -I$qt5_incdir/QtGui -I$qt5_incdir/QtWidgets -I$qt5_incdir/QtNetwork -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT -DQT_NO_VERSION_TAGGING"
13681    KF5_LIBS="-L$kf5_libdir -lKF5CoreAddons -lKF5I18n -lKF5ConfigCore -lKF5WindowSystem -lKF5KIOCore -lKF5KIOWidgets -lKF5KIOFileWidgets -L$qt5_libdir -lQt5Core -lQt5Gui -lQt5Widgets -lQt5Network"
13682    KF5_CFLAGS=$(printf '%s' "$KF5_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
13683
13684    if test "$USING_X11" = TRUE; then
13685        KF5_LIBS="$KF5_LIBS -lQt5X11Extras"
13686    fi
13687
13688    AC_LANG_PUSH([C++])
13689    save_CXXFLAGS=$CXXFLAGS
13690    CXXFLAGS="$CXXFLAGS $KF5_CFLAGS"
13691    AC_MSG_CHECKING([whether KDE is >= 5.0])
13692       AC_RUN_IFELSE([AC_LANG_SOURCE([[
13693#include <kcoreaddons_version.h>
13694
13695int main(int argc, char **argv) {
13696       if (KCOREADDONS_VERSION_MAJOR == 5 && KCOREADDONS_VERSION_MINOR >= 0) return 0;
13697       else return 1;
13698}
13699       ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([KDE version too old])],[])
13700    CXXFLAGS=$save_CXXFLAGS
13701    AC_LANG_POP([C++])
13702fi
13703AC_SUBST(KF5_CFLAGS)
13704AC_SUBST(KF5_LIBS)
13705
13706dnl ===================================================================
13707dnl KF6 Integration
13708dnl ===================================================================
13709
13710KF6_CFLAGS=""
13711KF6_LIBS=""
13712if test \( "$test_kf6" = "yes" -a "$ENABLE_KF6" = "TRUE" \)
13713then
13714    if test "$OS" = "HAIKU"; then
13715        haiku_arch="`echo $RTL_ARCH | tr X x`"
13716        kf6_haiku_incdirs="`findpaths -c ' ' -a $haiku_arch B_FIND_PATH_HEADERS_DIRECTORY`"
13717        kf6_haiku_libdirs="`findpaths -c ' ' -a $haiku_arch B_FIND_PATH_DEVELOP_LIB_DIRECTORY`"
13718    fi
13719
13720    kf6_incdirs="$KF6INC /usr/include $kf6_haiku_incdirs $x_includes"
13721    kf6_libdirs="$KF6LIB /usr/lib /usr/lib/kf6 /usr/lib/kf6/devel $kf6_haiku_libdirs $x_libraries"
13722    if test -n "$supports_multilib"; then
13723        kf6_libdirs="$kf6_libdirs /usr/lib64 /usr/lib64/kf6 /usr/lib64/kf6/devel"
13724    fi
13725
13726    kf6_test_include="KF6/KIOFileWidgets/KFileWidget"
13727    kf6_test_library="libKF6KIOFileWidgets.so"
13728    kf6_libdirs="$qt6_libdir $kf6_libdirs"
13729
13730    dnl Check for KF6 headers
13731    AC_MSG_CHECKING([for KF6 headers])
13732    kf6_incdir="no"
13733    for kf6_check in $kf6_incdirs; do
13734        if test -r "$kf6_check/$kf6_test_include"; then
13735            kf6_incdir="$kf6_check/KF6"
13736            break
13737        fi
13738    done
13739    AC_MSG_RESULT([$kf6_incdir])
13740    if test "x$kf6_incdir" = "xno"; then
13741        AC_MSG_ERROR([KF6 headers not found.  Please specify the root of your KF6 installation by exporting KF6DIR before running "configure".])
13742    fi
13743
13744    dnl Check for KF6 libraries
13745    AC_MSG_CHECKING([for KF6 libraries])
13746    kf6_libdir="no"
13747    for kf6_check in $kf6_libdirs; do
13748        if test -r "$kf6_check/$kf6_test_library"; then
13749            kf6_libdir="$kf6_check"
13750            break
13751        fi
13752    done
13753
13754    AC_MSG_RESULT([$kf6_libdir])
13755    if test "x$kf6_libdir" = "xno"; then
13756        AC_MSG_ERROR([KF6 libraries not found.  Please specify the root of your KF6 installation by exporting KF6DIR before running "configure".])
13757    fi
13758
13759    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 -I$qt6_incdir/QtNetwork -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT -DQT_NO_VERSION_TAGGING"
13760    KF6_LIBS="-L$kf6_libdir -lKF6CoreAddons -lKF6I18n -lKF6ConfigCore -lKF6WindowSystem -lKF6KIOCore -lKF6KIOWidgets -lKF6KIOFileWidgets -L$qt6_libdir -lQt6Core -lQt6Gui -lQt6Widgets -lQt6Network"
13761    KF6_CFLAGS=$(printf '%s' "$KF6_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
13762
13763    AC_LANG_PUSH([C++])
13764    save_CXXFLAGS=$CXXFLAGS
13765    CXXFLAGS="$CXXFLAGS $KF6_CFLAGS"
13766    dnl KF6 development version as of 2023-06 uses version number 5.240
13767    AC_MSG_CHECKING([whether KDE is >= 5.240])
13768       AC_RUN_IFELSE([AC_LANG_SOURCE([[
13769#include <kcoreaddons_version.h>
13770
13771int main(int argc, char **argv) {
13772       if (KCOREADDONS_VERSION_MAJOR == 6 || (KCOREADDONS_VERSION_MAJOR == 5 && KCOREADDONS_VERSION_MINOR >= 240)) return 0;
13773       else return 1;
13774}
13775       ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([KDE version too old])],[])
13776    CXXFLAGS=$save_CXXFLAGS
13777    AC_LANG_POP([C++])
13778fi
13779AC_SUBST(KF6_CFLAGS)
13780AC_SUBST(KF6_LIBS)
13781
13782if test "$enable_qt6_multimedia" = "yes" -a "$ENABLE_QT6" != "TRUE"; then
13783    AC_MSG_ERROR([--enable-qt6-multimedia requires --enable-qt6 or --enable-kf6])
13784fi
13785
13786dnl ===================================================================
13787dnl Test whether to include Evolution 2 support
13788dnl ===================================================================
13789AC_MSG_CHECKING([whether to enable evolution 2 support])
13790if test "$enable_evolution2" = yes; then
13791    AC_MSG_RESULT([yes])
13792    PKG_CHECK_MODULES(GOBJECT, gobject-2.0)
13793    GOBJECT_CFLAGS=$(printf '%s' "$GOBJECT_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
13794    FilterLibs "${GOBJECT_LIBS}"
13795    GOBJECT_LIBS="${filteredlibs}"
13796    ENABLE_EVOAB2="TRUE"
13797else
13798    AC_MSG_RESULT([no])
13799fi
13800AC_SUBST(ENABLE_EVOAB2)
13801AC_SUBST(GOBJECT_CFLAGS)
13802AC_SUBST(GOBJECT_LIBS)
13803
13804dnl ===================================================================
13805dnl Test which themes to include
13806dnl ===================================================================
13807AC_MSG_CHECKING([which themes to include])
13808# if none given use default subset of available themes
13809if test "x$with_theme" = "x" -o "x$with_theme" = "xyes"; then
13810    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"
13811fi
13812
13813WITH_THEMES=""
13814if test "x$with_theme" != "xno"; then
13815    for theme in $with_theme; do
13816        case $theme in
13817        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" ;;
13818        *) AC_MSG_ERROR([Unknown value for --with-theme: $theme]) ;;
13819        esac
13820    done
13821fi
13822AC_MSG_RESULT([$WITH_THEMES])
13823AC_SUBST([WITH_THEMES])
13824
13825###############################################################################
13826# Extensions checking
13827###############################################################################
13828AC_MSG_CHECKING([for extensions integration])
13829if test "x$enable_extension_integration" != "xno"; then
13830    WITH_EXTENSION_INTEGRATION=TRUE
13831    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_INTEGRATION"
13832    AC_MSG_RESULT([yes, use integration])
13833else
13834    WITH_EXTENSION_INTEGRATION=
13835    AC_MSG_RESULT([no, do not integrate])
13836fi
13837AC_SUBST(WITH_EXTENSION_INTEGRATION)
13838
13839dnl Should any extra extensions be included?
13840dnl There are standalone tests for each of these below.
13841WITH_EXTRA_EXTENSIONS=
13842AC_SUBST([WITH_EXTRA_EXTENSIONS])
13843
13844libo_CHECK_EXTENSION([Numbertext],[NUMBERTEXT],[numbertext],[numbertext],[b7cae45ad2c23551fd6ccb8ae2c1f59e-numbertext_0.9.5.oxt])
13845if test "x$with_java" != "xno"; then
13846    libo_CHECK_EXTENSION([NLPSolver],[NLPSOLVER],[nlpsolver],[nlpsolver],[])
13847fi
13848
13849AC_MSG_CHECKING([whether to build opens___.ttf])
13850if test "$enable_build_opensymbol" = "yes"; then
13851    AC_MSG_RESULT([yes])
13852    AC_PATH_PROG(FONTFORGE, fontforge)
13853    if test -z "$FONTFORGE"; then
13854        AC_MSG_ERROR([fontforge not installed])
13855    fi
13856else
13857    AC_MSG_RESULT([no])
13858    BUILD_TYPE="$BUILD_TYPE OPENSYMBOL"
13859fi
13860AC_SUBST(FONTFORGE)
13861
13862dnl ===================================================================
13863dnl Test whether to include fonts
13864dnl ===================================================================
13865AC_MSG_CHECKING([whether to include third-party fonts])
13866if test "$with_fonts" != "no"; then
13867    AC_MSG_RESULT([yes])
13868    WITH_FONTS=TRUE
13869    BUILD_TYPE="$BUILD_TYPE MORE_FONTS"
13870    AC_DEFINE(HAVE_MORE_FONTS)
13871else
13872    AC_MSG_RESULT([no])
13873    WITH_FONTS=
13874    SCPDEFS="$SCPDEFS -DWITHOUT_FONTS"
13875fi
13876AC_SUBST(WITH_FONTS)
13877
13878
13879dnl ===================================================================
13880dnl Test whether to enable online update service
13881dnl ===================================================================
13882AC_MSG_CHECKING([whether to enable online update])
13883ENABLE_ONLINE_UPDATE=
13884if test "$enable_online_update" = ""; then
13885    AC_MSG_RESULT([no])
13886else
13887    if test "$enable_online_update" = "mar"; then
13888        AC_MSG_ERROR([--enable-online-update=mar is deprecated, use --enable-online-update-mar instead])
13889    elif test "$enable_online_update" = "yes"; then
13890        if test "$enable_curl" != "yes"; then
13891            AC_MSG_ERROR([--disable-online-update must be used when --disable-curl is used])
13892        fi
13893        AC_MSG_RESULT([yes])
13894        ENABLE_ONLINE_UPDATE="TRUE"
13895    else
13896        AC_MSG_RESULT([no])
13897    fi
13898fi
13899AC_SUBST(ENABLE_ONLINE_UPDATE)
13900
13901
13902dnl ===================================================================
13903dnl Test whether to enable mar online update service
13904dnl ===================================================================
13905AC_MSG_CHECKING([whether to enable mar online update])
13906ENABLE_ONLINE_UPDATE_MAR=
13907if test "$enable_online_update_mar" = yes; then
13908    AC_MSG_RESULT([yes])
13909    BUILD_TYPE="$BUILD_TYPE ONLINEUPDATE"
13910    ENABLE_ONLINE_UPDATE_MAR="TRUE"
13911    AC_DEFINE(HAVE_FEATURE_UPDATE_MAR)
13912else
13913    AC_MSG_RESULT([no])
13914fi
13915AC_SUBST(ENABLE_ONLINE_UPDATE_MAR)
13916
13917AC_MSG_CHECKING([for mar online update baseurl])
13918ONLINEUPDATE_MAR_BASEURL=$with_online_update_mar_baseurl
13919if test -n "$ONLINEUPDATE_MAR_BASEURL"; then
13920    AC_MSG_RESULT([yes])
13921else
13922    AC_MSG_RESULT([no])
13923fi
13924AC_SUBST(ONLINEUPDATE_MAR_BASEURL)
13925
13926AC_MSG_CHECKING([for mar online update certificateder])
13927ONLINEUPDATE_MAR_CERTIFICATEDER=$with_online_update_mar_certificateder
13928if test -n "$ONLINEUPDATE_MAR_CERTIFICATEDER"; then
13929    AC_MSG_RESULT([yes])
13930else
13931    AC_MSG_RESULT([no])
13932fi
13933AC_SUBST(ONLINEUPDATE_MAR_CERTIFICATEDER)
13934
13935AC_MSG_CHECKING([for mar online update certificatename])
13936ONLINEUPDATE_MAR_CERTIFICATENAME=$with_online_update_mar_certificatename
13937if test -n "$ONLINEUPDATE_MAR_CERTIFICATENAME"; then
13938    AC_MSG_RESULT([yes])
13939else
13940    AC_MSG_RESULT([no])
13941fi
13942AC_SUBST(ONLINEUPDATE_MAR_CERTIFICATENAME)
13943
13944AC_MSG_CHECKING([for mar online update certificatepath])
13945ONLINEUPDATE_MAR_CERTIFICATEPATH=$with_online_update_mar_certificatepath
13946if test -n "$ONLINEUPDATE_MAR_CERTIFICATEPATH"; then
13947    AC_MSG_RESULT([yes])
13948else
13949    AC_MSG_RESULT([no])
13950fi
13951AC_SUBST(ONLINEUPDATE_MAR_CERTIFICATEPATH)
13952
13953
13954PRIVACY_POLICY_URL="$with_privacy_policy_url"
13955if test "$ENABLE_ONLINE_UPDATE" = TRUE -o "$ENABLE_BREAKPAD" = "TRUE"; then
13956    if test "x$with_privacy_policy_url" = "xundefined"; then
13957        AC_MSG_FAILURE([online update or breakpad/crashreporting are enabled, but no --with-privacy-policy-url=... was provided])
13958    fi
13959fi
13960AC_SUBST(PRIVACY_POLICY_URL)
13961dnl ===================================================================
13962dnl Test whether we need bzip2
13963dnl ===================================================================
13964SYSTEM_BZIP2=
13965if test "$ENABLE_ONLINE_UPDATE_MAR" = "TRUE" -o "$enable_python" = internal; then
13966    AC_MSG_CHECKING([whether to use system bzip2])
13967    if test "$with_system_bzip2" = yes; then
13968        SYSTEM_BZIP2=TRUE
13969        AC_MSG_RESULT([yes])
13970        PKG_CHECK_MODULES(BZIP2, bzip2)
13971        FilterLibs "${BZIP2_LIBS}"
13972        BZIP2_LIBS="${filteredlibs}"
13973    else
13974        AC_MSG_RESULT([no])
13975        BUILD_TYPE="$BUILD_TYPE BZIP2"
13976    fi
13977fi
13978AC_SUBST(SYSTEM_BZIP2)
13979AC_SUBST(BZIP2_CFLAGS)
13980AC_SUBST(BZIP2_LIBS)
13981
13982dnl ===================================================================
13983dnl Test whether to enable extension update
13984dnl ===================================================================
13985AC_MSG_CHECKING([whether to enable extension update])
13986ENABLE_EXTENSION_UPDATE=
13987if test "x$enable_extension_update" = "xno"; then
13988    AC_MSG_RESULT([no])
13989else
13990    AC_MSG_RESULT([yes])
13991    ENABLE_EXTENSION_UPDATE="TRUE"
13992    AC_DEFINE(ENABLE_EXTENSION_UPDATE)
13993    SCPDEFS="$SCPDEFS -DENABLE_EXTENSION_UPDATE"
13994fi
13995AC_SUBST(ENABLE_EXTENSION_UPDATE)
13996
13997
13998dnl ===================================================================
13999dnl Test whether to create MSI with LIMITUI=1 (silent install)
14000dnl ===================================================================
14001AC_MSG_CHECKING([whether to create MSI with LIMITUI=1 (silent install)])
14002if test "$enable_silent_msi" = "" -o "$enable_silent_msi" = "no"; then
14003    AC_MSG_RESULT([no])
14004    ENABLE_SILENT_MSI=
14005else
14006    AC_MSG_RESULT([yes])
14007    ENABLE_SILENT_MSI=TRUE
14008    SCPDEFS="$SCPDEFS -DENABLE_SILENT_MSI"
14009fi
14010AC_SUBST(ENABLE_SILENT_MSI)
14011
14012dnl ===================================================================
14013dnl Check for WiX tools.
14014dnl ===================================================================
14015if test "$enable_wix" = "" -o "enable_wix" = "no"; then
14016    AC_MSG_RESULT([no])
14017    ENABLE_WIX=
14018else
14019    AC_MSG_RESULT([yes])
14020    # FIXME: this should do proper detection, but the path is currently
14021    # hardcoded in msicreator/createmsi.py
14022    if ! test -x "/cygdrive/c/Program Files (x86)/WiX Toolset v3.11/bin/candle"; then
14023      AC_MSG_ERROR([WiX requested but WiX toolset v3.11 not found at the expected location])
14024    fi
14025    ENABLE_WIX=TRUE
14026fi
14027AC_SUBST(ENABLE_WIX)
14028
14029AC_MSG_CHECKING([whether and how to use Xinerama])
14030if test "$USING_X11" = TRUE; then
14031    if test "$x_libraries" = "default_x_libraries"; then
14032        XINERAMALIB=`$PKG_CONFIG --variable=libdir xinerama`
14033        if test "x$XINERAMALIB" = x; then
14034           XINERAMALIB="/usr/lib"
14035        fi
14036    else
14037        XINERAMALIB="$x_libraries"
14038    fi
14039    if test -e "$XINERAMALIB/libXinerama.so" -a -e "$XINERAMALIB/libXinerama.a"; then
14040        # we have both versions, let the user decide but use the dynamic one
14041        # per default
14042        USE_XINERAMA=TRUE
14043        if test -z "$with_static_xinerama" -o -n "$with_system_libs"; then
14044            XINERAMA_LINK=dynamic
14045        else
14046            XINERAMA_LINK=static
14047        fi
14048    elif test -e "$XINERAMALIB/libXinerama.so" -a ! -e "$XINERAMALIB/libXinerama.a"; then
14049        # we have only the dynamic version
14050        USE_XINERAMA=TRUE
14051        XINERAMA_LINK=dynamic
14052    elif test -e "$XINERAMALIB/libXinerama.a"; then
14053        # static version
14054        if echo $host_cpu | $GREP -E 'i[[3456]]86' 2>/dev/null >/dev/null; then
14055            USE_XINERAMA=TRUE
14056            XINERAMA_LINK=static
14057        else
14058            USE_XINERAMA=
14059            XINERAMA_LINK=none
14060        fi
14061    else
14062        # no Xinerama
14063        USE_XINERAMA=
14064        XINERAMA_LINK=none
14065    fi
14066    if test "$USE_XINERAMA" = "TRUE"; then
14067        AC_MSG_RESULT([yes, with $XINERAMA_LINK linking])
14068        AC_CHECK_HEADER(X11/extensions/Xinerama.h, [],
14069            [AC_MSG_ERROR(Xinerama header not found.)], [])
14070        XEXTLIBS=`$PKG_CONFIG --variable=libs xext`
14071        if test "x$XEXTLIB" = x; then
14072           XEXTLIBS="-L$XLIB -L$XINERAMALIB -lXext"
14073        fi
14074        XINERAMA_EXTRA_LIBS="$XEXTLIBS"
14075        if test "$_os" = "FreeBSD"; then
14076            XINERAMA_EXTRA_LIBS="$XINERAMA_EXTRA_LIBS -lXt"
14077        fi
14078        if test "$_os" = "Linux"; then
14079            XINERAMA_EXTRA_LIBS="$XINERAMA_EXTRA_LIBS -ldl"
14080        fi
14081        AC_CHECK_LIB([Xinerama], [XineramaIsActive], [:],
14082            [AC_MSG_ERROR(Xinerama not functional?)], [$XINERAMA_EXTRA_LIBS])
14083    else
14084        AC_MSG_ERROR([libXinerama not found or wrong architecture.])
14085    fi
14086else
14087    USE_XINERAMA=
14088    XINERAMA_LINK=none
14089    AC_MSG_RESULT([no])
14090fi
14091AC_SUBST(XINERAMA_LINK)
14092
14093AC_MSG_CHECKING([whether to use non-standard RGBA32 cairo pixel order])
14094if test -z "$enable_cairo_rgba" -a "$_os" = "Android"; then
14095    enable_cairo_rgba=yes
14096fi
14097if test "$enable_cairo_rgba" = yes; then
14098    AC_DEFINE(ENABLE_CAIRO_RGBA)
14099    ENABLE_CAIRO_RGBA=TRUE
14100    AC_MSG_RESULT([yes])
14101else
14102    ENABLE_CAIRO_RGBA=
14103    AC_MSG_RESULT([no])
14104fi
14105AC_SUBST(ENABLE_CAIRO_RGBA)
14106
14107dnl ===================================================================
14108dnl Test whether to build cairo or rely on the system version
14109dnl ===================================================================
14110
14111if test "$test_cairo" = "yes"; then
14112    AC_MSG_CHECKING([whether to use the system cairo])
14113
14114    : ${with_system_cairo:=$with_system_libs}
14115    if test "$with_system_cairo" = "yes" -a "$enable_cairo_rgba" != "yes"; then
14116        SYSTEM_CAIRO=TRUE
14117        AC_MSG_RESULT([yes])
14118
14119        PKG_CHECK_MODULES( CAIRO, cairo >= 1.12.0 )
14120        CAIRO_CFLAGS=$(printf '%s' "$CAIRO_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
14121        FilterLibs "${CAIRO_LIBS}"
14122        CAIRO_LIBS="${filteredlibs}"
14123
14124        if test "$test_xrender" = "yes"; then
14125            AC_MSG_CHECKING([whether Xrender.h defines PictStandardA8])
14126            AC_LANG_PUSH([C])
14127            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <X11/extensions/Xrender.h>]],[[
14128#ifdef PictStandardA8
14129#else
14130      return fail;
14131#endif
14132]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no, X headers too old.])])
14133
14134            AC_LANG_POP([C])
14135        fi
14136    else
14137        AC_MSG_RESULT([no])
14138        BUILD_TYPE="$BUILD_TYPE CAIRO"
14139    fi
14140
14141    if test "$enable_cairo_canvas" != no; then
14142        AC_DEFINE(ENABLE_CAIRO_CANVAS)
14143        ENABLE_CAIRO_CANVAS=TRUE
14144    fi
14145fi
14146
14147AC_SUBST(CAIRO_CFLAGS)
14148AC_SUBST(CAIRO_LIBS)
14149AC_SUBST(ENABLE_CAIRO_CANVAS)
14150AC_SUBST(SYSTEM_CAIRO)
14151
14152dnl ===================================================================
14153dnl Test whether to use avahi
14154dnl ===================================================================
14155if test "$_os" = "WINNT"; then
14156    # Windows uses bundled mDNSResponder
14157    BUILD_TYPE="$BUILD_TYPE MDNSRESPONDER"
14158elif test "$_os" != "Darwin" -a "$enable_avahi" = "yes"; then
14159    PKG_CHECK_MODULES([AVAHI], [avahi-client >= 0.6.10],
14160                      [ENABLE_AVAHI="TRUE"])
14161    AC_DEFINE(HAVE_FEATURE_AVAHI)
14162    AVAHI_CFLAGS=$(printf '%s' "$AVAHI_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
14163    FilterLibs "${AVAHI_LIBS}"
14164    AVAHI_LIBS="${filteredlibs}"
14165fi
14166
14167AC_SUBST(ENABLE_AVAHI)
14168AC_SUBST(AVAHI_CFLAGS)
14169AC_SUBST(AVAHI_LIBS)
14170
14171dnl ===================================================================
14172dnl Test whether to use liblangtag
14173dnl ===================================================================
14174SYSTEM_LIBLANGTAG=
14175AC_MSG_CHECKING([whether to use system liblangtag])
14176if test "$with_system_liblangtag" = yes; then
14177    SYSTEM_LIBLANGTAG=TRUE
14178    AC_MSG_RESULT([yes])
14179    PKG_CHECK_MODULES( LIBLANGTAG, liblangtag >= 0.4.0)
14180    dnl cf. <https://bitbucket.org/tagoh/liblangtag/commits/9324836a0d1c> "Fix a build issue with inline keyword"
14181    PKG_CHECK_EXISTS([liblangtag >= 0.5.5], [], [AC_DEFINE([LIBLANGTAG_INLINE_FIX])])
14182    LIBLANGTAG_CFLAGS=$(printf '%s' "$LIBLANGTAG_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
14183    FilterLibs "${LIBLANGTAG_LIBS}"
14184    LIBLANGTAG_LIBS="${filteredlibs}"
14185else
14186    SYSTEM_LIBLANGTAG=
14187    AC_MSG_RESULT([no])
14188    BUILD_TYPE="$BUILD_TYPE LIBLANGTAG"
14189    LIBLANGTAG_CFLAGS="-I${WORKDIR}/UnpackedTarball/liblangtag"
14190    if test "$COM" = "MSC"; then
14191        LIBLANGTAG_LIBS="${WORKDIR}/UnpackedTarball/liblangtag/liblangtag/.libs/liblangtag.lib"
14192    else
14193        LIBLANGTAG_LIBS="-L${WORKDIR}/UnpackedTarball/liblangtag/liblangtag/.libs -llangtag"
14194    fi
14195fi
14196AC_SUBST(SYSTEM_LIBLANGTAG)
14197AC_SUBST(LIBLANGTAG_CFLAGS)
14198AC_SUBST(LIBLANGTAG_LIBS)
14199
14200dnl ===================================================================
14201dnl Test whether to build libpng or rely on the system version
14202dnl ===================================================================
14203
14204LIBPNG_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/libpng"
14205LIBPNG_LIBS_internal='-L$(gb_StaticLibrary_WORKDIR) -llibpng'
14206libo_CHECK_SYSTEM_MODULE([libpng],[LIBPNG],[libpng])
14207
14208dnl ===================================================================
14209dnl Test whether to build libtiff or rely on the system version
14210dnl ===================================================================
14211
14212libo_CHECK_SYSTEM_MODULE([libtiff],[LIBTIFF],[libtiff-4])
14213
14214dnl ===================================================================
14215dnl Test whether to build libwebp or rely on the system version
14216dnl ===================================================================
14217
14218libo_CHECK_SYSTEM_MODULE([libwebp],[LIBWEBP],[libwebp])
14219
14220dnl ===================================================================
14221dnl Check for runtime JVM search path
14222dnl ===================================================================
14223if test "$ENABLE_JAVA" != ""; then
14224    AC_MSG_CHECKING([whether to use specific JVM search path at runtime])
14225    if test -n "$with_jvm_path" -a "$with_jvm_path" != "no"; then
14226        AC_MSG_RESULT([yes])
14227        if ! test -d "$with_jvm_path"; then
14228            AC_MSG_ERROR(["$with_jvm_path" not a directory])
14229        fi
14230        if ! test -d "$with_jvm_path"jvm; then
14231            AC_MSG_ERROR(["$with_jvm_path"jvm not found, point with_jvm_path to \[/path/to/\]jvm])
14232        fi
14233        JVM_ONE_PATH_CHECK="$with_jvm_path"
14234        AC_SUBST(JVM_ONE_PATH_CHECK)
14235    else
14236        AC_MSG_RESULT([no])
14237    fi
14238fi
14239
14240dnl ===================================================================
14241dnl Test for the presence of Ant and that it works
14242dnl ===================================================================
14243
14244# java takes the encoding from LC_ALL, and since autoconf forces it to C it
14245# breaks filename decoding, so for the ant section, set it to LANG
14246LC_ALL=$LANG
14247if test "$ENABLE_JAVA" != "" -a "$NEED_ANT" = "TRUE" -a "$cross_compiling" != "yes"; then
14248    ANT_HOME=; export ANT_HOME
14249    WITH_ANT_HOME=; export WITH_ANT_HOME
14250    if test -z "$with_ant_home" -a -n "$LODE_HOME" ; then
14251        if test -x "$LODE_HOME/opt/ant/bin/ant" ; then
14252            if test "$_os" = "WINNT"; then
14253                with_ant_home="`cygpath -m $LODE_HOME/opt/ant`"
14254            else
14255                with_ant_home="$LODE_HOME/opt/ant"
14256            fi
14257        elif test -x  "$LODE_HOME/opt/bin/ant" ; then
14258            with_ant_home="$LODE_HOME/opt/ant"
14259        fi
14260    fi
14261    if test -z "$with_ant_home"; then
14262        AC_PATH_PROGS(ANT, [ant ant.sh ant.bat ant.cmd])
14263    else
14264        if test "$_os" = "WINNT"; then
14265            # AC_PATH_PROGS needs unix path
14266            PathFormat "$with_ant_home"
14267            with_ant_home="$formatted_path_unix"
14268        fi
14269        AbsolutePath "$with_ant_home"
14270        with_ant_home=$absolute_path
14271        AC_PATH_PROGS(ANT, [ant ant.sh ant.bat ant.cmd],,$with_ant_home/bin:$PATH)
14272        WITH_ANT_HOME=$with_ant_home
14273        ANT_HOME=$with_ant_home
14274    fi
14275
14276    if test -z "$ANT"; then
14277        AC_MSG_ERROR([Ant not found - Make sure it's in the path or use --with-ant-home])
14278    else
14279        # resolve relative or absolute symlink
14280        while test -h "$ANT"; do
14281            a_cwd=`pwd`
14282            a_basename=`basename "$ANT"`
14283            a_script=`ls -l "$ANT" | $SED "s/.*${a_basename} -> //g"`
14284            cd "`dirname "$ANT"`"
14285            cd "`dirname "$a_script"`"
14286            ANT="`pwd`"/"`basename "$a_script"`"
14287            cd "$a_cwd"
14288        done
14289
14290        AC_MSG_CHECKING([if $ANT works])
14291        mkdir -p conftest.dir
14292        a_cwd=$(pwd)
14293        cd conftest.dir
14294        cat > conftest.java << EOF
14295        public class conftest {
14296            int testmethod(int a, int b) {
14297                    return a + b;
14298            }
14299        }
14300EOF
14301
14302        cat > conftest.xml << EOF
14303        <project name="conftest" default="conftest">
14304        <target name="conftest">
14305            <javac srcdir="." includes="conftest.java">
14306            </javac>
14307        </target>
14308        </project>
14309EOF
14310
14311        if test -n "$WSL_ONLY_AS_HELPER"; then
14312            # need to set it directly, since ant only tries java, not java.exe from JAVA_HOME
14313            export JAVACMD="$JAVAINTERPRETER"
14314            # similarly it doesn't expect to be called from wsl, so it uses the wsl-realm path when
14315            # building the classpath, but we need the windows-style one for the windows-java
14316            PathFormat "$ANT_HOME"
14317            export LOCALCLASSPATH=";$formatted_path/lib/ant-launcher.jar"
14318        fi
14319        AC_TRY_COMMAND("$ANT" -buildfile conftest.xml 1>&2)
14320        if test $? = 0 -a -f ./conftest.class; then
14321            AC_MSG_RESULT([Ant works])
14322            if test -z "$WITH_ANT_HOME"; then
14323                ANT_HOME=`"$ANT" -diagnostics | $EGREP "ant.home :" | $SED -e "s#ant.home : ##g"`
14324                if test -z "$ANT_HOME"; then
14325                    ANT_HOME=`echo "$ANT" | $SED -n "s/\/bin\/ant.*\$//p"`
14326                fi
14327            else
14328                ANT_HOME="$WITH_ANT_HOME"
14329            fi
14330        else
14331            echo "configure: Ant test failed" >&5
14332            cat conftest.java >&5
14333            cat conftest.xml >&5
14334            AC_MSG_ERROR([Ant does not work - Some Java projects will not build!])
14335        fi
14336        cd "$a_cwd"
14337        rm -fr conftest.dir
14338    fi
14339    if test -z "$ANT_HOME"; then
14340        ANT_HOME="NO_ANT_HOME"
14341    else
14342        PathFormat "$ANT_HOME"
14343        ANT_HOME="$formatted_path_unix"
14344        PathFormat "$ANT"
14345        ANT="$formatted_path_unix"
14346    fi
14347
14348    dnl Checking for ant.jar
14349    if test "$ANT_HOME" != "NO_ANT_HOME"; then
14350        AC_MSG_CHECKING([Ant lib directory])
14351        if test -f $ANT_HOME/lib/ant.jar; then
14352            ANT_LIB="$ANT_HOME/lib"
14353        else
14354            if test -f $ANT_HOME/ant.jar; then
14355                ANT_LIB="$ANT_HOME"
14356            else
14357                if test -f /usr/share/java/ant.jar; then
14358                    ANT_LIB=/usr/share/java
14359                else
14360                    if test -f /usr/share/ant-core/lib/ant.jar; then
14361                        ANT_LIB=/usr/share/ant-core/lib
14362                    else
14363                        if test -f $ANT_HOME/lib/ant/ant.jar; then
14364                            ANT_LIB="$ANT_HOME/lib/ant"
14365                        else
14366                            if test -f /usr/share/lib/ant/ant.jar; then
14367                                ANT_LIB=/usr/share/lib/ant
14368                            else
14369                                AC_MSG_ERROR([Ant libraries not found!])
14370                            fi
14371                        fi
14372                    fi
14373                fi
14374            fi
14375        fi
14376        PathFormat "$ANT_LIB"
14377        ANT_LIB="$formatted_path"
14378        AC_MSG_RESULT([Ant lib directory found.])
14379    fi
14380
14381    ant_minver=1.6.0
14382    ant_minminor1=`echo $ant_minver | cut -d"." -f2`
14383
14384    AC_MSG_CHECKING([whether Ant is >= $ant_minver])
14385    ant_version=`"$ANT" -version | $AWK '$3 == "version" { print $4; }'`
14386    ant_version_major=`echo $ant_version | cut -d. -f1`
14387    ant_version_minor=`echo $ant_version | cut -d. -f2`
14388    echo "configure: ant_version $ant_version " >&5
14389    echo "configure: ant_version_major $ant_version_major " >&5
14390    echo "configure: ant_version_minor $ant_version_minor " >&5
14391    if test "$ant_version_major" -ge "2"; then
14392        AC_MSG_RESULT([yes, $ant_version])
14393    elif test "$ant_version_major" = "1" -a "$ant_version_minor" -ge "$ant_minminor1"; then
14394        AC_MSG_RESULT([yes, $ant_version])
14395    else
14396        AC_MSG_ERROR([no, you need at least Ant >= $ant_minver])
14397    fi
14398
14399    rm -f conftest* core core.* *.core
14400fi
14401AC_SUBST(ANT)
14402AC_SUBST(ANT_HOME)
14403AC_SUBST(ANT_LIB)
14404
14405OOO_JUNIT_JAR=
14406HAMCREST_JAR=
14407if test "$ENABLE_JAVA" != "" -a "$with_junit" != "no" -a "$cross_compiling" != "yes"; then
14408    AC_MSG_CHECKING([for JUnit 4])
14409    if test "$with_junit" = "yes"; then
14410        if test -n "$LODE_HOME" -a -e "$LODE_HOME/opt/share/java/junit.jar" ; then
14411            OOO_JUNIT_JAR="$LODE_HOME/opt/share/java/junit.jar"
14412        elif test -e /usr/share/java/junit4.jar; then
14413            OOO_JUNIT_JAR=/usr/share/java/junit4.jar
14414        else
14415           if test -e /usr/share/lib/java/junit.jar; then
14416              OOO_JUNIT_JAR=/usr/share/lib/java/junit.jar
14417           else
14418              OOO_JUNIT_JAR=/usr/share/java/junit.jar
14419           fi
14420        fi
14421    else
14422        OOO_JUNIT_JAR=$with_junit
14423    fi
14424    if test "$_os" = "WINNT"; then
14425        PathFormat "$OOO_JUNIT_JAR"
14426        OOO_JUNIT_JAR="$formatted_path"
14427    fi
14428    printf 'import org.junit.Before;' > conftest.java
14429    if $JAVACOMPILER -classpath "$OOO_JUNIT_JAR" conftest.java >&5 2>&5; then
14430        AC_MSG_RESULT([$OOO_JUNIT_JAR])
14431    else
14432        AC_MSG_ERROR(
14433[cannot find JUnit 4 jar; please install one in the default location (/usr/share/java),
14434 specify its pathname via --with-junit=..., or disable it via --without-junit])
14435    fi
14436    rm -f conftest.class conftest.java
14437    if test $OOO_JUNIT_JAR != ""; then
14438        BUILD_TYPE="$BUILD_TYPE QADEVOOO"
14439    fi
14440
14441    AC_MSG_CHECKING([for included Hamcrest])
14442    printf 'import org.hamcrest.BaseDescription;' > conftest.java
14443    if $JAVACOMPILER -classpath "$OOO_JUNIT_JAR" conftest.java >&5 2>&5; then
14444        AC_MSG_RESULT([Included in $OOO_JUNIT_JAR])
14445    else
14446        AC_MSG_RESULT([Not included])
14447        AC_MSG_CHECKING([for standalone hamcrest jar.])
14448        if test "$with_hamcrest" = "yes"; then
14449            if test -e /usr/share/lib/java/hamcrest.jar; then
14450                HAMCREST_JAR=/usr/share/lib/java/hamcrest.jar
14451            elif test -e /usr/share/java/hamcrest/core.jar; then
14452                HAMCREST_JAR=/usr/share/java/hamcrest/core.jar
14453            elif test -e /usr/share/java/hamcrest/hamcrest.jar; then
14454                HAMCREST_JAR=/usr/share/java/hamcrest/hamcrest.jar
14455            else
14456                HAMCREST_JAR=/usr/share/java/hamcrest.jar
14457            fi
14458        else
14459            HAMCREST_JAR=$with_hamcrest
14460        fi
14461        if test "$_os" = "WINNT"; then
14462            PathFormat "$HAMCREST_JAR"
14463            HAMCREST_JAR="$formatted_path"
14464        fi
14465        if $JAVACOMPILER -classpath "$HAMCREST_JAR" conftest.java >&5 2>&5; then
14466            AC_MSG_RESULT([$HAMCREST_JAR])
14467        else
14468            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),
14469                          specify its path with --with-hamcrest=..., or disable junit with --without-junit])
14470        fi
14471    fi
14472    rm -f conftest.class conftest.java
14473fi
14474AC_SUBST(OOO_JUNIT_JAR)
14475AC_SUBST(HAMCREST_JAR)
14476# set back LC_ALL to C after the java related tests...
14477LC_ALL=C
14478
14479AC_SUBST(SCPDEFS)
14480
14481#
14482# check for wget and curl
14483#
14484WGET=
14485CURL=
14486
14487if test "$enable_fetch_external" != "no"; then
14488
14489CURL=`command -v curl`
14490
14491for i in wget /usr/bin/wget /usr/local/bin/wget /usr/sfw/bin/wget /opt/sfw/bin/wget /opt/local/bin/wget; do
14492    # wget new enough?
14493    $i --help 2> /dev/null | $GREP no-use-server-timestamps 2>&1 > /dev/null
14494    if test $? -eq 0; then
14495        WGET=$i
14496        break
14497    fi
14498done
14499
14500if test -z "$WGET" -a -z "$CURL"; then
14501    AC_MSG_ERROR([neither wget nor curl found!])
14502fi
14503
14504fi
14505
14506AC_SUBST(WGET)
14507AC_SUBST(CURL)
14508
14509#
14510# check for sha256sum
14511#
14512SHA256SUM=
14513
14514for i in shasum /usr/local/bin/shasum /usr/sfw/bin/shasum /opt/sfw/bin/shasum /opt/local/bin/shasum; do
14515    eval "$i -a 256 --version" > /dev/null 2>&1
14516    ret=$?
14517    if test $ret -eq 0; then
14518        SHA256SUM="$i -a 256"
14519        break
14520    fi
14521done
14522
14523if test -z "$SHA256SUM"; then
14524    for i in sha256sum /usr/local/bin/sha256sum /usr/sfw/bin/sha256sum /opt/sfw/bin/sha256sum /opt/local/bin/sha256sum; do
14525        eval "$i --version" > /dev/null 2>&1
14526        ret=$?
14527        if test $ret -eq 0; then
14528            SHA256SUM=$i
14529            break
14530        fi
14531    done
14532fi
14533
14534if test -z "$SHA256SUM"; then
14535    AC_MSG_ERROR([no sha256sum found!])
14536fi
14537
14538AC_SUBST(SHA256SUM)
14539
14540dnl ===================================================================
14541dnl Dealing with l10n options
14542dnl ===================================================================
14543AC_MSG_CHECKING([which languages to be built])
14544# get list of all languages
14545# generate shell variable from completelangiso= from solenv/inc/langlist.mk
14546# we want en-US at the beginning
14547ALL_LANGS=$($GNUMAKE SRC_ROOT=$SRC_ROOT WITH_LANG="$with_lang" ENABLE_RELEASE_BUILD="$ENABLE_RELEASE_BUILD" -sr -f - <<'EOF' | tr -d '\r'
14548include $(SRC_ROOT)/solenv/inc/langlist.mk
14549all:
14550	$(info en-US $(filter-out en-US,$(sort $(completelangiso))))
14551EOF
14552)
14553
14554# check the configured localizations
14555WITH_LANG="$with_lang"
14556
14557# Check for --without-lang which turns up as $with_lang being "no". Luckily there is no language with code "no".
14558# (Norwegian is "nb" and "nn".)
14559if test "$WITH_LANG" = "no"; then
14560    WITH_LANG=
14561fi
14562
14563if test -z "$WITH_LANG" -o "$WITH_LANG" = "en-US"; then
14564    AC_MSG_RESULT([en-US])
14565else
14566    AC_MSG_RESULT([$WITH_LANG])
14567    GIT_NEEDED_SUBMODULES="translations $GIT_NEEDED_SUBMODULES"
14568    if test -z "$MSGFMT"; then
14569        if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/msgfmt" ; then
14570            MSGFMT="$LODE_HOME/opt/bin/msgfmt"
14571        elif test -x "/opt/lo/bin/msgfmt"; then
14572            MSGFMT="/opt/lo/bin/msgfmt"
14573        else
14574            AC_CHECK_PROGS(MSGFMT, [msgfmt])
14575            if test -z "$MSGFMT"; then
14576                AC_MSG_ERROR([msgfmt not found. Install GNU gettext, or re-run without languages.])
14577            fi
14578        fi
14579    fi
14580    if test -z "$MSGUNIQ"; then
14581        if test -n "$LODE_HOME" -a -x "$LODE_HOME/opt/bin/msguniq" ; then
14582            MSGUNIQ="$LODE_HOME/opt/bin/msguniq"
14583        elif test -x "/opt/lo/bin/msguniq"; then
14584            MSGUNIQ="/opt/lo/bin/msguniq"
14585        else
14586            AC_CHECK_PROGS(MSGUNIQ, [msguniq])
14587            if test -z "$MSGUNIQ"; then
14588                AC_MSG_ERROR([msguniq not found. Install GNU gettext, or re-run without languages.])
14589            fi
14590        fi
14591    fi
14592fi
14593AC_SUBST(MSGFMT)
14594AC_SUBST(MSGUNIQ)
14595# check that the list is valid
14596for lang in $WITH_LANG; do
14597    test "$lang" = "ALL" && continue
14598    # need to check for the exact string, so add space before and after the list of all languages
14599    for vl in $ALL_LANGS; do
14600        if test "$vl" = "$lang"; then
14601           break
14602        fi
14603    done
14604    if test "$vl" != "$lang"; then
14605        # if you're reading this - you prolly quoted your languages remove the quotes ...
14606        AC_MSG_ERROR([invalid language: '$lang' (vs '$v1'); supported languages are: $ALL_LANGS])
14607    fi
14608done
14609if test -n "$WITH_LANG" -a "$WITH_LANG" != "ALL"; then
14610    echo $WITH_LANG | grep -q en-US
14611    test $? -ne 1 || WITH_LANG=`echo $WITH_LANG en-US`
14612fi
14613# list with substituted ALL
14614WITH_LANG_LIST=`echo $WITH_LANG | sed "s/ALL/$ALL_LANGS/"`
14615test -z "$WITH_LANG_LIST" && WITH_LANG_LIST="en-US"
14616test "$WITH_LANG" = "en-US" && WITH_LANG=
14617if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
14618    test "$WITH_LANG_LIST" = "en-US" || WITH_LANG_LIST=`echo $WITH_LANG_LIST qtz`
14619    ALL_LANGS=`echo $ALL_LANGS qtz`
14620fi
14621AC_SUBST(ALL_LANGS)
14622AC_DEFINE_UNQUOTED(WITH_LANG,"$WITH_LANG")
14623AC_SUBST(WITH_LANG)
14624AC_SUBST(WITH_LANG_LIST)
14625AC_SUBST(GIT_NEEDED_SUBMODULES)
14626
14627WITH_POOR_HELP_LOCALIZATIONS=
14628if test -d "$SRC_ROOT/translations/source"; then
14629    for l in `ls -1 $SRC_ROOT/translations/source`; do
14630        if test ! -d "$SRC_ROOT/translations/source/$l/helpcontent2"; then
14631            WITH_POOR_HELP_LOCALIZATIONS="$WITH_POOR_HELP_LOCALIZATIONS $l"
14632        fi
14633    done
14634fi
14635AC_SUBST(WITH_POOR_HELP_LOCALIZATIONS)
14636
14637if test -n "$with_locales" -a "$with_locales" != ALL; then
14638    WITH_LOCALES="$with_locales"
14639
14640    just_langs="`echo $WITH_LOCALES | sed -e 's/_[A-Z]*//g'`"
14641    # Only languages and scripts for which we actually have ifdefs need to be handled. Also see
14642    # config_host/config_locales.h.in
14643    for locale in $WITH_LOCALES; do
14644        lang=${locale%_*}
14645
14646        AC_DEFINE_UNQUOTED(WITH_LOCALE_$lang, 1)
14647
14648        case $lang in
14649        hi|mr*ne)
14650            AC_DEFINE(WITH_LOCALE_FOR_SCRIPT_Deva)
14651            ;;
14652        bg|ru)
14653            AC_DEFINE(WITH_LOCALE_FOR_SCRIPT_Cyrl)
14654            ;;
14655        esac
14656    done
14657else
14658    AC_DEFINE(WITH_LOCALE_ALL)
14659fi
14660AC_SUBST(WITH_LOCALES)
14661
14662dnl git submodule update --reference
14663dnl ===================================================================
14664if test -n "${GIT_REFERENCE_SRC}"; then
14665    for repo in ${GIT_NEEDED_SUBMODULES}; do
14666        if ! test -d "${GIT_REFERENCE_SRC}"/${repo}; then
14667            AC_MSG_ERROR([referenced git: required repository does not exist: ${GIT_REFERENCE_SRC}/${repo}])
14668        fi
14669    done
14670fi
14671AC_SUBST(GIT_REFERENCE_SRC)
14672
14673dnl git submodules linked dirs
14674dnl ===================================================================
14675if test -n "${GIT_LINK_SRC}"; then
14676    for repo in ${GIT_NEEDED_SUBMODULES}; do
14677        if ! test -d "${GIT_LINK_SRC}"/${repo}; then
14678            AC_MSG_ERROR([linked git: required repository does not exist: ${GIT_LINK_SRC}/${repo}])
14679        fi
14680    done
14681fi
14682AC_SUBST(GIT_LINK_SRC)
14683
14684dnl branding
14685dnl ===================================================================
14686AC_MSG_CHECKING([for alternative branding images directory])
14687# initialize mapped arrays
14688BRAND_INTRO_IMAGES="intro.png intro-highres.png"
14689brand_files="$BRAND_INTRO_IMAGES logo.svg logo_inverted.svg logo-sc.svg logo-sc_inverted.svg about.svg"
14690
14691if test -z "$with_branding" -o "$with_branding" = "no"; then
14692    AC_MSG_RESULT([none])
14693    DEFAULT_BRAND_IMAGES="$brand_files"
14694else
14695    if ! test -d $with_branding ; then
14696        AC_MSG_ERROR([No directory $with_branding, falling back to default branding])
14697    else
14698        AC_MSG_RESULT([$with_branding])
14699        CUSTOM_BRAND_DIR="$with_branding"
14700        for lfile in $brand_files
14701        do
14702            if ! test -f $with_branding/$lfile ; then
14703                AC_MSG_WARN([Branded file $lfile does not exist, using the default one])
14704                DEFAULT_BRAND_IMAGES="$DEFAULT_BRAND_IMAGES $lfile"
14705            else
14706                CUSTOM_BRAND_IMAGES="$CUSTOM_BRAND_IMAGES $lfile"
14707            fi
14708        done
14709        check_for_progress="yes"
14710    fi
14711fi
14712AC_SUBST([BRAND_INTRO_IMAGES])
14713AC_SUBST([CUSTOM_BRAND_DIR])
14714AC_SUBST([CUSTOM_BRAND_IMAGES])
14715AC_SUBST([DEFAULT_BRAND_IMAGES])
14716
14717
14718AC_MSG_CHECKING([for 'intro' progress settings])
14719PROGRESSBARCOLOR=
14720PROGRESSSIZE=
14721PROGRESSPOSITION=
14722PROGRESSFRAMECOLOR=
14723PROGRESSTEXTCOLOR=
14724PROGRESSTEXTBASELINE=
14725
14726if test "$check_for_progress" = "yes" -a -f "$with_branding/progress.conf" ; then
14727    source "$with_branding/progress.conf"
14728    AC_MSG_RESULT([settings found in $with_branding/progress.conf])
14729else
14730    AC_MSG_RESULT([none])
14731fi
14732
14733AC_SUBST(PROGRESSBARCOLOR)
14734AC_SUBST(PROGRESSSIZE)
14735AC_SUBST(PROGRESSPOSITION)
14736AC_SUBST(PROGRESSFRAMECOLOR)
14737AC_SUBST(PROGRESSTEXTCOLOR)
14738AC_SUBST(PROGRESSTEXTBASELINE)
14739
14740
14741dnl ===================================================================
14742dnl Custom build version
14743dnl ===================================================================
14744AC_MSG_CHECKING([for extra build ID])
14745if test -n "$with_extra_buildid" -a "$with_extra_buildid" != "yes" ; then
14746    EXTRA_BUILDID="$with_extra_buildid"
14747fi
14748# in tinderboxes, it is easier to set EXTRA_BUILDID via the environment variable instead of configure switch
14749if test -n "$EXTRA_BUILDID" ; then
14750    AC_MSG_RESULT([$EXTRA_BUILDID])
14751else
14752    AC_MSG_RESULT([not set])
14753fi
14754AC_DEFINE_UNQUOTED([EXTRA_BUILDID], ["$EXTRA_BUILDID"])
14755
14756OOO_VENDOR=
14757AC_MSG_CHECKING([for vendor])
14758if test -z "$with_vendor" -o "$with_vendor" = "no"; then
14759    OOO_VENDOR="$USERNAME"
14760
14761    if test -z "$OOO_VENDOR"; then
14762        OOO_VENDOR="$USER"
14763    fi
14764
14765    if test -z "$OOO_VENDOR"; then
14766        OOO_VENDOR="`id -u -n`"
14767    fi
14768
14769    AC_MSG_RESULT([not set, using $OOO_VENDOR])
14770else
14771    OOO_VENDOR="$with_vendor"
14772    AC_MSG_RESULT([$OOO_VENDOR])
14773fi
14774AC_DEFINE_UNQUOTED(OOO_VENDOR,"$OOO_VENDOR")
14775AC_SUBST(OOO_VENDOR)
14776
14777if test "$_os" = "Android" ; then
14778    ANDROID_PACKAGE_NAME=
14779    AC_MSG_CHECKING([for Android package name])
14780    if test -z "$with_android_package_name" -o "$with_android_package_name" = "no"; then
14781        if test -n "$ENABLE_DEBUG"; then
14782            # Default to the package name that makes ndk-gdb happy.
14783            ANDROID_PACKAGE_NAME="org.libreoffice"
14784        else
14785            ANDROID_PACKAGE_NAME="org.example.libreoffice"
14786        fi
14787
14788        AC_MSG_RESULT([not set, using $ANDROID_PACKAGE_NAME])
14789    else
14790        ANDROID_PACKAGE_NAME="$with_android_package_name"
14791        AC_MSG_RESULT([$ANDROID_PACKAGE_NAME])
14792    fi
14793    AC_SUBST(ANDROID_PACKAGE_NAME)
14794fi
14795
14796AC_MSG_CHECKING([whether to install the compat oo* wrappers])
14797if test "$with_compat_oowrappers" = "yes"; then
14798    WITH_COMPAT_OOWRAPPERS=TRUE
14799    AC_MSG_RESULT(yes)
14800else
14801    WITH_COMPAT_OOWRAPPERS=
14802    AC_MSG_RESULT(no)
14803fi
14804AC_SUBST(WITH_COMPAT_OOWRAPPERS)
14805
14806INSTALLDIRNAME=`echo AC_PACKAGE_NAME | $AWK '{print tolower($0)}'`
14807AC_MSG_CHECKING([for install dirname])
14808if test -n "$with_install_dirname" -a "$with_install_dirname" != "no" -a "$with_install_dirname" != "yes"; then
14809    INSTALLDIRNAME="$with_install_dirname"
14810fi
14811AC_MSG_RESULT([$INSTALLDIRNAME])
14812AC_SUBST(INSTALLDIRNAME)
14813
14814AC_MSG_CHECKING([for prefix])
14815test "x$prefix" = xNONE && prefix=$ac_default_prefix
14816test "x$exec_prefix" = xNONE && exec_prefix=$prefix
14817PREFIXDIR="$prefix"
14818AC_MSG_RESULT([$PREFIXDIR])
14819AC_SUBST(PREFIXDIR)
14820
14821LIBDIR=[$(eval echo $(eval echo $libdir))]
14822AC_SUBST(LIBDIR)
14823
14824DATADIR=[$(eval echo $(eval echo $datadir))]
14825AC_SUBST(DATADIR)
14826
14827MANDIR=[$(eval echo $(eval echo $mandir))]
14828AC_SUBST(MANDIR)
14829
14830DOCDIR=[$(eval echo $(eval echo $docdir))]
14831AC_SUBST(DOCDIR)
14832
14833BINDIR=[$(eval echo $(eval echo $bindir))]
14834AC_SUBST(BINDIR)
14835
14836INSTALLDIR="$LIBDIR/$INSTALLDIRNAME"
14837AC_SUBST(INSTALLDIR)
14838
14839TESTINSTALLDIR="${BUILDDIR}/test-install"
14840AC_SUBST(TESTINSTALLDIR)
14841
14842
14843# ===================================================================
14844# OAuth2 id and secrets
14845# ===================================================================
14846
14847AC_MSG_CHECKING([for Google Drive client id and secret])
14848if test "$with_gdrive_client_id" = "no" -o -z "$with_gdrive_client_id"; then
14849    AC_MSG_RESULT([not set])
14850    GDRIVE_CLIENT_ID="\"\""
14851    GDRIVE_CLIENT_SECRET="\"\""
14852else
14853    AC_MSG_RESULT([set])
14854    GDRIVE_CLIENT_ID="\"$with_gdrive_client_id\""
14855    GDRIVE_CLIENT_SECRET="\"$with_gdrive_client_secret\""
14856fi
14857AC_DEFINE_UNQUOTED(GDRIVE_CLIENT_ID, $GDRIVE_CLIENT_ID)
14858AC_DEFINE_UNQUOTED(GDRIVE_CLIENT_SECRET, $GDRIVE_CLIENT_SECRET)
14859
14860AC_MSG_CHECKING([for Alfresco Cloud client id and secret])
14861if test "$with_alfresco_cloud_client_id" = "no" -o -z "$with_alfresco_cloud_client_id"; then
14862    AC_MSG_RESULT([not set])
14863    ALFRESCO_CLOUD_CLIENT_ID="\"\""
14864    ALFRESCO_CLOUD_CLIENT_SECRET="\"\""
14865else
14866    AC_MSG_RESULT([set])
14867    ALFRESCO_CLOUD_CLIENT_ID="\"$with_alfresco_cloud_client_id\""
14868    ALFRESCO_CLOUD_CLIENT_SECRET="\"$with_alfresco_cloud_client_secret\""
14869fi
14870AC_DEFINE_UNQUOTED(ALFRESCO_CLOUD_CLIENT_ID, $ALFRESCO_CLOUD_CLIENT_ID)
14871AC_DEFINE_UNQUOTED(ALFRESCO_CLOUD_CLIENT_SECRET, $ALFRESCO_CLOUD_CLIENT_SECRET)
14872
14873AC_MSG_CHECKING([for OneDrive client id and secret])
14874if test "$with_onedrive_client_id" = "no" -o -z "$with_onedrive_client_id"; then
14875    AC_MSG_RESULT([not set])
14876    ONEDRIVE_CLIENT_ID="\"\""
14877    ONEDRIVE_CLIENT_SECRET="\"\""
14878else
14879    AC_MSG_RESULT([set])
14880    ONEDRIVE_CLIENT_ID="\"$with_onedrive_client_id\""
14881    ONEDRIVE_CLIENT_SECRET="\"$with_onedrive_client_secret\""
14882fi
14883AC_DEFINE_UNQUOTED(ONEDRIVE_CLIENT_ID, $ONEDRIVE_CLIENT_ID)
14884AC_DEFINE_UNQUOTED(ONEDRIVE_CLIENT_SECRET, $ONEDRIVE_CLIENT_SECRET)
14885
14886
14887dnl ===================================================================
14888dnl Hook up LibreOffice's nodep environmental variable to automake's equivalent
14889dnl --enable-dependency-tracking configure option
14890dnl ===================================================================
14891AC_MSG_CHECKING([whether to enable dependency tracking])
14892if test "$enable_dependency_tracking" = "no"; then
14893    nodep=TRUE
14894    AC_MSG_RESULT([no])
14895else
14896    AC_MSG_RESULT([yes])
14897fi
14898AC_SUBST(nodep)
14899
14900dnl ===================================================================
14901dnl Number of CPUs to use during the build
14902dnl ===================================================================
14903AC_MSG_CHECKING([for number of processors to use])
14904# plain --with-parallelism is just the default
14905if test -n "$with_parallelism" -a "$with_parallelism" != "yes"; then
14906    if test "$with_parallelism" = "no"; then
14907        PARALLELISM=0
14908    else
14909        PARALLELISM=$with_parallelism
14910    fi
14911else
14912    if test "$enable_icecream" = "yes"; then
14913        PARALLELISM="40"
14914    else
14915        case `uname -s` in
14916
14917        Darwin|FreeBSD|NetBSD|OpenBSD)
14918            PARALLELISM=`sysctl -n hw.ncpu`
14919            ;;
14920
14921        Linux)
14922            PARALLELISM=`getconf _NPROCESSORS_ONLN`
14923        ;;
14924        # what else than above does profit here *and* has /proc?
14925        *)
14926            PARALLELISM=`grep $'^processor\t*:' /proc/cpuinfo | wc -l`
14927            ;;
14928        esac
14929
14930        # If we hit the catch-all case, but /proc/cpuinfo doesn't exist or has an
14931        # unexpected format, 'wc -l' will have returned 0 (and we won't use -j at all).
14932    fi
14933fi
14934
14935if test $PARALLELISM -eq 0; then
14936    AC_MSG_RESULT([explicit make -j option needed])
14937else
14938    AC_MSG_RESULT([$PARALLELISM])
14939fi
14940AC_SUBST(PARALLELISM)
14941
14942#
14943# Set up ILIB for MSVC build
14944#
14945ILIB1=
14946if test "$build_os" = "cygwin" -o "$build_os" = "wsl" -o -n "$WSL_ONLY_AS_HELPER"; then
14947    ILIB="."
14948    if test -n "$JAVA_HOME"; then
14949        ILIB="$ILIB;$JAVA_HOME/lib"
14950    fi
14951    ILIB1=-link
14952    PathFormat "${COMPATH}/lib/$WIN_HOST_ARCH"
14953    ILIB="$ILIB;$formatted_path"
14954    ILIB1="$ILIB1 -LIBPATH:$formatted_path"
14955    ILIB="$ILIB;$WINDOWS_SDK_HOME/lib/$WIN_HOST_ARCH"
14956    ILIB1="$ILIB1 -LIBPATH:$WINDOWS_SDK_HOME/lib/$WIN_HOST_ARCH"
14957    if test $WINDOWS_SDK_VERSION = 80 -o $WINDOWS_SDK_VERSION = 81 -o $WINDOWS_SDK_VERSION = 10; then
14958        ILIB="$ILIB;$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/$WIN_HOST_ARCH"
14959        ILIB1="$ILIB1 -LIBPATH:$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/$WIN_HOST_ARCH"
14960    fi
14961    PathFormat "${UCRTSDKDIR}lib/$UCRTVERSION/ucrt/$WIN_HOST_ARCH"
14962    ucrtlibpath_formatted=$formatted_path
14963    ILIB="$ILIB;$ucrtlibpath_formatted"
14964    ILIB1="$ILIB1 -LIBPATH:$ucrtlibpath_formatted"
14965    if test -f "$DOTNET_FRAMEWORK_HOME/lib/mscoree.lib"; then
14966        PathFormat "$DOTNET_FRAMEWORK_HOME/lib"
14967        ILIB="$ILIB;$formatted_path"
14968    else
14969        PathFormat "$DOTNET_FRAMEWORK_HOME/Lib/um/$WIN_HOST_ARCH"
14970        ILIB="$ILIB;$formatted_path"
14971    fi
14972
14973    if test "$cross_compiling" != "yes"; then
14974        ILIB_FOR_BUILD="$ILIB"
14975    fi
14976fi
14977AC_SUBST(ILIB)
14978AC_SUBST(ILIB_FOR_BUILD)
14979
14980AC_MSG_CHECKING([whether $CXX_BASE supports a working C++20 consteval])
14981dnl ...that does not suffer from <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96994> "Missing code
14982dnl from consteval constructor initializing const variable",
14983dnl <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98752> "wrong 'error: ‘this’ is not a constant
14984dnl expression' with consteval constructor", <https://bugs.llvm.org/show_bug.cgi?id=50063> "code
14985dnl using consteval: 'clang/lib/CodeGen/Address.h:38: llvm::Value*
14986dnl clang::CodeGen::Address::getPointer() const: Assertion `isValid()' failed.'" (which should be
14987dnl fixed since Clang 14), <https://developercommunity.visualstudio.com/t/1581879> "Bogus error
14988dnl C7595 with consteval constructor in ternary expression (/std:c++latest)" (which appears to be
14989dnl fixed at least in Visual Studio Community 2022 Preview 17.9.0 Preview 5.0),
14990dnl <https://github.com/llvm/llvm-project/issues/54612> "C++20, consteval, anonymous union:
14991dnl llvm/lib/IR/Instructions.cpp:1491: void llvm::StoreInst::AssertOK(): Assertion
14992dnl `cast<PointerType>(getOperand(1)->getType())->isOpaqueOrPointeeTypeMatches(getOperand(0)->getType())
14993dnl && "Ptr must be a pointer to Val type!"' failed." (which should be fixed since Clang 17), or
14994dnl <https://developercommunity.visualstudio.com/t/Bogus-error-C2440-with-consteval-constru/10579616>
14995dnl "Bogus error C2440 with consteval constructor (/std:c++20)":
14996have_cpp_consteval=
14997AC_LANG_PUSH([C++])
14998save_CXX=$CXX
14999if test "$COM" = MSC && test "$COM_IS_CLANG" != TRUE; then
15000    CXX="env LIB=$ILIB $CXX"
15001fi
15002save_CXXFLAGS=$CXXFLAGS
15003CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
15004AC_RUN_IFELSE([AC_LANG_PROGRAM([
15005        struct S {
15006            consteval S() { i = 1; }
15007            int i = 0;
15008        };
15009        S const s;
15010
15011        struct S1 {
15012             int a;
15013             consteval S1(int n): a(n) {}
15014        };
15015        struct S2 {
15016            S1 x;
15017            S2(): x(0) {}
15018        };
15019
15020        struct S3 {
15021            consteval S3() {}
15022            union {
15023                int a;
15024                unsigned b = 0;
15025            };
15026        };
15027        void f() { S3(); }
15028
15029        struct S4 { consteval S4() = default; };
15030        void f4(bool b) { b ? S4() : S4(); }
15031
15032        struct S5 {
15033            consteval S5() { c = 0; }
15034            char * f() { return &c; }
15035            union {
15036                char c;
15037                int i;
15038            };
15039        };
15040        auto s5 = S5().f();
15041
15042        struct S6 {
15043            consteval S6(char const (&lit)[[2]]) {
15044                buf[[0]] = lit[[0]];
15045                buf[[1]] = lit[[1]];
15046            }
15047            union {
15048                int x;
15049                char buf[[2]];
15050            };
15051        };
15052        void f6() { S6("a"); }
15053    ], [
15054        return (s.i == 1) ? 0 : 1;
15055    ])], [
15056        have_cpp_consteval=1
15057        AC_MSG_RESULT([yes])
15058    ], [AC_MSG_RESULT([no])], [AC_MSG_RESULT([assumed no (cross compiling)])])
15059CXX=$save_CXX
15060CXXFLAGS=$save_CXXFLAGS
15061AC_LANG_POP([C++])
15062if test -n "$have_cpp_consteval" && test "$COM_IS_CLANG" = TRUE && test -n "$BUILDING_PCH_WITH_OBJ"
15063then
15064    AC_MSG_CHECKING([whether $CXX_BASE has working consteval in combination with PCH])
15065    dnl ...that does not suffer from <https://github.com/llvm/llvm-project/issues/81745> "undefined
15066    dnl reference to consteval constructor exported from module" (which also affects PCH, see
15067    dnl <https://lists.freedesktop.org/archives/libreoffice/2024-February/091564.html> "Our Clang
15068    dnl --enable-pch setup is known broken"):
15069    printf 'export module M;\nexport struct S1 { consteval S1(int) {} };' >conftest.cppm
15070    $CXX $CXXFLAGS $CXXFLAGS_CXX11 --precompile conftest.cppm
15071    rm conftest.cppm
15072    AC_LANG_PUSH([C++])
15073    save_CXXFLAGS=$CXXFLAGS
15074    save_LDFLAGS=$LDFLAGS
15075    CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
15076    LDFLAGS="$LDFLAGS -fmodule-file=M=conftest.pcm conftest.pcm"
15077    AC_LINK_IFELSE([AC_LANG_PROGRAM([
15078        import M;
15079    ], [
15080        struct S2 { S1 s = 0; };
15081        S2 s;
15082    ])], [
15083        AC_MSG_RESULT([yes])
15084    ], [
15085        have_cpp_consteval=
15086        AC_MSG_RESULT([no])])
15087    CXXFLAGS=$save_CXXFLAGS
15088    LDFLAGS=$save_LDFLAGS
15089    AC_LANG_POP([C++])
15090    rm conftest.pcm
15091fi
15092if test -n "$have_cpp_consteval"; then
15093    AC_DEFINE([HAVE_CPP_CONSTEVAL],[1])
15094fi
15095
15096AC_MSG_CHECKING([whether $CXX_BASE supports a working C++20 std::strong_order])
15097dnl ...which is known to not be implemented in libc++ prior to
15098dnl <https://github.com/llvm/llvm-project/commit/d8380ad977e94498e170b06449c81f1fc27da7b5> "[libc++]
15099dnl [P1614] Implement [cmp.alg]'s std::{strong,weak,partial}_order" in LLVM 14:
15100AC_LANG_PUSH([C++])
15101save_CXX=$CXX
15102if test "$COM" = MSC && test "$COM_IS_CLANG" != TRUE; then
15103    CXX="env LIB=$ILIB $CXX"
15104fi
15105save_CXXFLAGS=$CXXFLAGS
15106CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
15107AC_LINK_IFELSE([AC_LANG_PROGRAM([
15108        #include <compare>
15109    ], [
15110        (void) (std::strong_order(1.0, 2.0) < 0);
15111    ])], [
15112        AC_DEFINE([HAVE_CPP_STRONG_ORDER],[1])
15113        AC_MSG_RESULT([yes])
15114    ], [AC_MSG_RESULT([no])])
15115CXX=$save_CXX
15116CXXFLAGS=$save_CXXFLAGS
15117AC_LANG_POP([C++])
15118
15119# ===================================================================
15120# Creating bigger shared library to link against
15121# ===================================================================
15122AC_MSG_CHECKING([whether to create huge library])
15123MERGELIBS=
15124MERGELIBS_MORE=
15125
15126if test $_os = iOS -o $_os = Android; then
15127    # Never any point in mergelibs for these as we build just static
15128    # libraries anyway...
15129    enable_mergelibs=no
15130fi
15131
15132if test -n "$enable_mergelibs" -a "$enable_mergelibs" != "no"; then
15133    if test "$enable_mergelibs" = "more"; then
15134        MERGELIBS="TRUE"
15135        MERGELIBS_MORE="TRUE"
15136        AC_MSG_RESULT([yes (more)])
15137        AC_DEFINE(ENABLE_MERGELIBS)
15138        AC_DEFINE(ENABLE_MERGELIBS_MORE)
15139    elif test "$enable_mergelibs" = "yes" -o "$enable_mergelibs" = ""; then
15140        MERGELIBS="TRUE"
15141        AC_MSG_RESULT([yes])
15142        AC_DEFINE(ENABLE_MERGELIBS)
15143    else
15144        AC_MSG_ERROR([unknown value --enable-mergelibs=$enable_mergelibs])
15145    fi
15146else
15147    AC_MSG_RESULT([no])
15148fi
15149AC_SUBST([MERGELIBS])
15150AC_SUBST([MERGELIBS_MORE])
15151
15152dnl ===================================================================
15153dnl icerun is a wrapper that stops us spawning tens of processes
15154dnl locally - for tools that can't be executed on the compile cluster
15155dnl this avoids a dozen javac's ganging up on your laptop to kill it.
15156dnl ===================================================================
15157AC_MSG_CHECKING([whether to use icerun wrapper])
15158ICECREAM_RUN=
15159if test "$enable_icecream" = "yes" && command -v icerun >/dev/null ; then
15160    ICECREAM_RUN=icerun
15161    AC_MSG_RESULT([yes])
15162else
15163    AC_MSG_RESULT([no])
15164fi
15165AC_SUBST(ICECREAM_RUN)
15166
15167dnl ===================================================================
15168dnl Setup the ICECC_VERSION for the build the same way it was set for
15169dnl configure, so that CC/CXX and ICECC_VERSION are in sync
15170dnl ===================================================================
15171x_ICECC_VERSION=[\#]
15172if test -n "$ICECC_VERSION" ; then
15173    x_ICECC_VERSION=
15174fi
15175AC_SUBST(x_ICECC_VERSION)
15176AC_SUBST(ICECC_VERSION)
15177
15178dnl ===================================================================
15179
15180AC_MSG_CHECKING([MPL subset])
15181MPL_SUBSET=
15182LICENSE="LGPL"
15183
15184if test "$enable_mpl_subset" = "yes"; then
15185    mpl_error_string=
15186    newline=$'\n    *'
15187    warn_report=false
15188    if test "$enable_report_builder" != "no" -a "$with_java" != "no"; then
15189        warn_report=true
15190    elif test "$ENABLE_REPORTBUILDER" = "TRUE"; then
15191        warn_report=true
15192    fi
15193    if test "$warn_report" = "true"; then
15194        mpl_error_string="$mpl_error_string$newline Need to --disable-report-builder - extended database report builder."
15195    fi
15196    if test "x$enable_postgresql_sdbc" != "xno"; then
15197        mpl_error_string="$mpl_error_string$newline Need to --disable-postgresql-sdbc - the PostgreSQL database backend."
15198    fi
15199    if test "$enable_lotuswordpro" = "yes"; then
15200        mpl_error_string="$mpl_error_string$newline Need to --disable-lotuswordpro - a Lotus Word Pro file format import filter."
15201    fi
15202    if test -n "$ENABLE_POPPLER"; then
15203        if test "x$SYSTEM_POPPLER" = "x"; then
15204            mpl_error_string="$mpl_error_string$newline Need to disable PDF import via poppler (--disable-poppler) or use system library."
15205        fi
15206    fi
15207    # cf. m4/libo_check_extension.m4
15208    if test "x$WITH_EXTRA_EXTENSIONS" != "x"; then
15209        mpl_error_string="$mpl_error_string$newline Need to disable extra extensions enabled using --enable-ext-XXXX."
15210    fi
15211    denied_themes=
15212    filtered_themes=
15213    for theme in $WITH_THEMES; do
15214        case $theme in
15215        breeze|breeze_dark|breeze_dark_svg|breeze_svg|elementary|elementary_svg|karasa_jaga|karasa_jaga_svg) #denylist of icon themes under GPL or LGPL
15216            denied_themes="${denied_themes:+$denied_themes }$theme" ;;
15217        *)
15218            filtered_themes="${filtered_themes:+$filtered_themes }$theme" ;;
15219        esac
15220    done
15221    if test "x$denied_themes" != "x"; then
15222        if test "x$filtered_themes" == "x"; then
15223            filtered_themes="colibre"
15224        fi
15225        mpl_error_string="$mpl_error_string$newline Need to disable icon themes: $denied_themes, use --with-theme=$filtered_themes."
15226    fi
15227
15228    ENABLE_OPENGL_TRANSITIONS=
15229
15230    if test "$enable_lpsolve" != "no" -o "x$ENABLE_LPSOLVE" = "xTRUE"; then
15231        mpl_error_string="$mpl_error_string$newline Need to --disable-lpsolve - calc linear programming solver."
15232    fi
15233
15234    if test "x$mpl_error_string" != "x"; then
15235        AC_MSG_ERROR([$mpl_error_string])
15236    fi
15237
15238    MPL_SUBSET="TRUE"
15239    LICENSE="MPL-2.0"
15240    AC_DEFINE(MPL_HAVE_SUBSET)
15241    AC_MSG_RESULT([only])
15242else
15243    AC_MSG_RESULT([no restrictions])
15244fi
15245AC_SUBST(MPL_SUBSET)
15246AC_SUBST(LICENSE)
15247
15248dnl ===================================================================
15249
15250AC_MSG_CHECKING([formula logger])
15251ENABLE_FORMULA_LOGGER=
15252
15253if test "x$enable_formula_logger" = "xyes"; then
15254    AC_MSG_RESULT([yes])
15255    AC_DEFINE(ENABLE_FORMULA_LOGGER)
15256    ENABLE_FORMULA_LOGGER=TRUE
15257elif test -n "$ENABLE_DBGUTIL" ; then
15258    AC_MSG_RESULT([yes])
15259    AC_DEFINE(ENABLE_FORMULA_LOGGER)
15260    ENABLE_FORMULA_LOGGER=TRUE
15261else
15262    AC_MSG_RESULT([no])
15263fi
15264
15265AC_SUBST(ENABLE_FORMULA_LOGGER)
15266
15267dnl ===================================================================
15268dnl Checking for active Antivirus software.
15269dnl ===================================================================
15270
15271if test $_os = WINNT -a -f "$SRC_ROOT/antivirusDetection.vbs" ; then
15272    AC_MSG_CHECKING([for active Antivirus software])
15273    PathFormat "$SRC_ROOT/antivirusDetection.vbs"
15274    ANTIVIRUS_LIST=`cscript.exe //Nologo ${formatted_path}`
15275    if [ [ "$ANTIVIRUS_LIST" != "NULL" ] ]; then
15276        if [ [ "$ANTIVIRUS_LIST" != "NOT_FOUND" ] ]; then
15277            AC_MSG_RESULT([found])
15278            EICAR_STRING='X5O!P%@AP@<:@4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*'
15279            echo $EICAR_STRING > $SRC_ROOT/eicar
15280            EICAR_TEMP_FILE_CONTENTS=`cat $SRC_ROOT/eicar`
15281            rm $SRC_ROOT/eicar
15282            if [ [ "$EICAR_STRING" != "$EICAR_TEMP_FILE_CONTENTS" ] ]; then
15283                AC_MSG_ERROR([Exclude the build and source directories associated with LibreOffice in the following Antivirus software: $ANTIVIRUS_LIST])
15284            fi
15285            echo $EICAR_STRING > $BUILDDIR/eicar
15286            EICAR_TEMP_FILE_CONTENTS=`cat $BUILDDIR/eicar`
15287            rm $BUILDDIR/eicar
15288            if [ [ "$EICAR_STRING" != "$EICAR_TEMP_FILE_CONTENTS" ] ]; then
15289                AC_MSG_ERROR([Exclude the build and source directories associated with LibreOffice in the following Antivirus software: $ANTIVIRUS_LIST])
15290            fi
15291            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"
15292        else
15293            AC_MSG_RESULT([not found])
15294        fi
15295    else
15296        AC_MSG_RESULT([n/a])
15297    fi
15298fi
15299
15300dnl ===================================================================
15301
15302AC_MSG_CHECKING([for coredumpctl support])
15303if test -z "$with_coredumpctl" && test $_os != Linux; then
15304    with_coredumpctl=no
15305fi
15306if test "$with_coredumpctl" = no; then
15307    WITH_COREDUMPCTL=
15308else
15309    AC_PATH_PROG(COREDUMPCTL, coredumpctl)
15310    AC_PATH_PROG(JQ, jq)
15311    AC_PATH_PROG(SYSTEMD_ESCAPE, systemd-escape)
15312    AC_PATH_PROG(SYSTEMD_RUN, systemd-run)
15313    if test -z "$COREDUMPCTL" || test -z "$JQ" || test -z "$SYSTEMD_ESCAPE" \
15314        || test -z "$SYSTEMD_RUN"
15315    then
15316        if test -z "$with_coredumpctl"; then
15317            WITH_COREDUMPCTL=
15318        else
15319            if test -z "$COREDUMPCTL"; then
15320                AC_MSG_ERROR([coredumpctl not found])
15321            fi
15322            if test -z "$JQ"; then
15323                AC_MSG_ERROR([jq not found])
15324            fi
15325            if test -z "$SYSTEMD_ESCAPE"; then
15326                AC_MSG_ERROR([systemd-escape not found])
15327            fi
15328            if test -z "$SYSTEMD_RUN"; then
15329                AC_MSG_ERROR([systemd-run not found])
15330            fi
15331        fi
15332    else
15333        WITH_COREDUMPCTL=TRUE
15334    fi
15335fi
15336if test -z "$WITH_COREDUMPCTL"; then
15337    AC_MSG_RESULT([no])
15338else
15339    AC_MSG_RESULT([yes])
15340fi
15341AC_SUBST(COREDUMPCTL)
15342AC_SUBST(JQ)
15343AC_SUBST(SYSTEMD_ESCAPE)
15344AC_SUBST(SYSTEMD_RUN)
15345AC_SUBST(WITH_COREDUMPCTL)
15346
15347dnl ===================================================================
15348dnl Checking whether to use a keep-awake helper
15349dnl ===================================================================
15350#"
15351AC_MSG_CHECKING([whether to keep the system awake/prevent it from going into sleep/standby])
15352if test -z "$with_keep_awake" -o "$with_keep_awake" = "no"; then
15353    AC_MSG_RESULT([no])
15354elif test "$with_keep_awake" = "yes"; then
15355    AC_MSG_RESULT([yes (autodetect)])
15356    AC_MSG_CHECKING([for a suitable keep-awake command])
15357    if test "$_os" = "WINNT"; then
15358        PathFormat "$(perl.exe -e 'print $ENV{"PROGRAMFILES"}')"
15359        if test -f "$formatted_path_unix/PowerToys/PowerToys.Awake.exe"; then
15360            AC_MSG_RESULT([using "Awake"])
15361            # need to pass the windows-PID to awake, so get the PGID of the shell first to get
15362            # make's PID and then use that to get the windows-PID.
15363            # lots of quoting for both make ($$) as well as configure ('"'"') make that command
15364            # much scarier looking than it actually is. Using make's shell instead of subshells in
15365            # the recipe to keep the command that's echoed by make short.
15366            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}'"'"') &'
15367        else
15368            AC_MSG_ERROR(["Awake" not found - install Microsoft PowerToys or specify a custom command])
15369        fi
15370    elif test "$_os" = "Darwin"; then
15371        AC_MSG_RESULT([using "caffeinate"])
15372        KEEP_AWAKE_CMD="caffeinate"
15373    else
15374        AC_MSG_ERROR([no default available for $_os, please specify manually])
15375    fi
15376else
15377    AC_MSG_RESULT([yes (custom command: $with_keep_awake)])
15378fi
15379AC_SUBST(KEEP_AWAKE_CMD)
15380
15381dnl ===================================================================
15382dnl Setting up the environment.
15383dnl ===================================================================
15384AC_MSG_NOTICE([setting up the build environment variables...])
15385
15386AC_SUBST(COMPATH)
15387
15388if test "$build_os" = "cygwin" -o "$build_os" = wsl -o -n "$WSL_ONLY_AS_HELPER"; then
15389    if test -d "$COMPATH_unix/atlmfc/lib/spectre"; then
15390        ATL_LIB="$COMPATH/atlmfc/lib/spectre"
15391        ATL_INCLUDE="$COMPATH/atlmfc/include"
15392    elif test -d "$COMPATH_unix/atlmfc/lib"; then
15393        ATL_LIB="$COMPATH/atlmfc/lib"
15394        ATL_INCLUDE="$COMPATH/atlmfc/include"
15395    else
15396        ATL_LIB="$WINDOWS_SDK_HOME/lib" # Doesn't exist for VSE
15397        ATL_INCLUDE="$WINDOWS_SDK_HOME/include/atl"
15398    fi
15399    ATL_LIB="$ATL_LIB/$WIN_HOST_ARCH"
15400    ATL_LIB=`win_short_path_for_make "$ATL_LIB"`
15401    ATL_INCLUDE=`win_short_path_for_make "$ATL_INCLUDE"`
15402fi
15403
15404if test "$build_os" = "cygwin"; then
15405    # sort.exe and find.exe also exist in C:/Windows/system32 so need /usr/bin/
15406    PathFormat "/usr/bin/find.exe"
15407    FIND="$formatted_path"
15408    PathFormat "/usr/bin/sort.exe"
15409    SORT="$formatted_path"
15410    PathFormat "/usr/bin/grep.exe"
15411    WIN_GREP="$formatted_path"
15412    PathFormat "/usr/bin/ls.exe"
15413    WIN_LS="$formatted_path"
15414    PathFormat "/usr/bin/touch.exe"
15415    WIN_TOUCH="$formatted_path"
15416else
15417    FIND=find
15418    SORT=sort
15419fi
15420
15421AC_SUBST(ATL_INCLUDE)
15422AC_SUBST(ATL_LIB)
15423AC_SUBST(FIND)
15424AC_SUBST(SORT)
15425AC_SUBST(WIN_GREP)
15426AC_SUBST(WIN_LS)
15427AC_SUBST(WIN_TOUCH)
15428
15429AC_SUBST(BUILD_TYPE)
15430
15431AC_SUBST(SOLARINC)
15432
15433PathFormat "$PERL"
15434PERL="$formatted_path"
15435AC_SUBST(PERL)
15436
15437if test -n "$TMPDIR"; then
15438    TEMP_DIRECTORY="$TMPDIR"
15439    if test -n "$WSL_ONLY_AS_HELPER"; then
15440       TEMP_DIRECTORY=$(wslpath -m "$TEMP_DIRECTORY")
15441    fi
15442else
15443    TEMP_DIRECTORY="/tmp"
15444fi
15445CYGWIN_BASH="C:/cygwin64/bin/bash.exe"
15446if test "$build_os" = "cygwin"; then
15447    TEMP_DIRECTORY=`cygpath -m "$TEMP_DIRECTORY"`
15448    CYGWIN_BASH=`cygpath -m /usr/bin/bash`
15449fi
15450AC_SUBST(TEMP_DIRECTORY)
15451AC_SUBST(CYGWIN_BASH)
15452
15453# setup the PATH for the environment
15454if test -n "$LO_PATH_FOR_BUILD"; then
15455    LO_PATH="$LO_PATH_FOR_BUILD"
15456    case "$host_os" in
15457    cygwin*|wsl*)
15458        pathmunge "$MSVC_HOST_PATH" "before"
15459        ;;
15460    esac
15461else
15462    LO_PATH="$PATH"
15463
15464    case "$host_os" in
15465
15466    dragonfly*|freebsd*|linux-gnu*|*netbsd*|openbsd*)
15467        if test "$ENABLE_JAVA" != ""; then
15468            pathmunge "$JAVA_HOME/bin" "after"
15469        fi
15470        ;;
15471
15472    cygwin*|wsl*)
15473        # Win32 make needs native paths
15474        if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
15475            LO_PATH=`cygpath -p -m "$PATH"`
15476        fi
15477        if test "$WIN_BUILD_ARCH" = "x64"; then
15478            # needed for msi packaging
15479            pathmunge "$WINDOWS_SDK_BINDIR_NO_ARCH/x86" "before"
15480        fi
15481        if test "$WIN_BUILD_ARCH" = "arm64"; then
15482            # needed for msi packaging - as of 10.0.22621 SDK no arm64 ones yet
15483            # the x86 ones probably would work just as well...
15484            pathmunge "$WINDOWS_SDK_BINDIR_NO_ARCH/arm" "before"
15485        fi
15486        # .NET 4.6 and higher don't have bin directory
15487        if test -f "$DOTNET_FRAMEWORK_HOME/bin"; then
15488            pathmunge "$DOTNET_FRAMEWORK_HOME/bin" "before"
15489        fi
15490        pathmunge "$WINDOWS_SDK_HOME/bin" "before"
15491        pathmunge "$CSC_PATH" "before"
15492        pathmunge "$MIDL_PATH" "before"
15493        pathmunge "$AL_PATH" "before"
15494        pathmunge "$MSVC_MULTI_PATH" "before"
15495        pathmunge "$MSVC_BUILD_PATH" "before"
15496        if test -n "$MSBUILD_PATH" ; then
15497            pathmunge "$MSBUILD_PATH" "before"
15498        fi
15499        pathmunge "$WINDOWS_SDK_BINDIR_NO_ARCH/$WIN_BUILD_ARCH" "before"
15500        if test "$ENABLE_JAVA" != ""; then
15501            if test -d "$JAVA_HOME/jre/bin/client"; then
15502                pathmunge "$JAVA_HOME/jre/bin/client" "before"
15503            fi
15504            if test -d "$JAVA_HOME/jre/bin/hotspot"; then
15505                pathmunge "$JAVA_HOME/jre/bin/hotspot" "before"
15506            fi
15507            pathmunge "$JAVA_HOME/bin" "before"
15508        fi
15509        pathmunge "$MSVC_HOST_PATH" "before"
15510        ;;
15511
15512    solaris*)
15513        pathmunge "/usr/css/bin" "before"
15514        if test "$ENABLE_JAVA" != ""; then
15515            pathmunge "$JAVA_HOME/bin" "after"
15516        fi
15517        ;;
15518    esac
15519fi
15520
15521AC_SUBST(LO_PATH)
15522
15523# Allow to pass LO_ELFCHECK_ALLOWLIST from autogen.input to bin/check-elf-dynamic-objects:
15524if test "$LO_ELFCHECK_ALLOWLIST" = x || test "${LO_ELFCHECK_ALLOWLIST-x}" != x; then
15525    x_LO_ELFCHECK_ALLOWLIST=
15526else
15527    x_LO_ELFCHECK_ALLOWLIST=[\#]
15528fi
15529AC_SUBST(x_LO_ELFCHECK_ALLOWLIST)
15530AC_SUBST(LO_ELFCHECK_ALLOWLIST)
15531
15532libo_FUZZ_SUMMARY
15533
15534# Generate a configuration sha256 we can use for deps
15535if test -f config_host.mk; then
15536    config_sha256=`$SHA256SUM config_host.mk | sed "s/ .*//"`
15537fi
15538if test -f config_host_lang.mk; then
15539    config_lang_sha256=`$SHA256SUM config_host_lang.mk | sed "s/ .*//"`
15540fi
15541
15542CFLAGS=$my_original_CFLAGS
15543CXXFLAGS=$my_original_CXXFLAGS
15544CPPFLAGS=$my_original_CPPFLAGS
15545
15546AC_CONFIG_LINKS([include:include])
15547
15548if test -n "$WSL_ONLY_AS_HELPER"; then
15549    # while we configure in linux, we actually compile in "cygwin" (close enough at least)
15550    build=$host
15551    PathFormat "$SRC_ROOT"
15552    SRC_ROOT="$formatted_path"
15553    PathFormat "$BUILDDIR"
15554    BUILDDIR="$formatted_path"
15555    # git-bash has (gnu) tar, curl and sha256sum
15556    CURL="curl.exe"
15557    WGET=
15558    GNUTAR="tar.exe"
15559    SHA256SUM="sha256sum.exe"
15560    # TODO: maybe switch to strawberry-perl right away?
15561    # only openssl seems to actually require it (for Pod/Usage.pm and maybe more)
15562    PERL="perl.exe"
15563    # use flex, gperf and nasm from wsl-container
15564    # if using absolute path, would need to use double-leading slash for the msys path mangling
15565    FLEX="$WSL $FLEX"
15566    NASM="$WSL $NASM"
15567    # some externals (libebook) check for it with AC_PATH_PROGS, and that only accepts overrides
15568    # with an absolute path/requires the value to begin with a slash
15569    GPERF="/c/Windows/system32/$WSL gperf"
15570    # append strawberry tools dir to PATH (for e.g. windres, ar)
15571    LO_PATH="$LO_PATH:$STRAWBERRY_TOOLS"
15572    # temp-dir needs to be in windows realm, hardcode for now
15573    if test "$TEMP_DIRECTORY" = /tmp; then
15574        mkdir -p tmp
15575        TEMP_DIRECTORY="$BUILDDIR/tmp"
15576    fi
15577fi
15578
15579# Keep in sync with list of files far up, at AC_MSG_CHECKING([for
15580# BUILD platform configuration] - otherwise breaks cross building
15581AC_CONFIG_FILES([
15582                 config_host_lang.mk
15583                 Makefile
15584                 bin/bffvalidator.sh
15585                 bin/odfvalidator.sh
15586                 bin/officeotron.sh
15587                 instsetoo_native/util/openoffice.lst
15588                 sysui/desktop/macosx/Info.plist
15589                 hardened_runtime.xcent:sysui/desktop/macosx/hardened_runtime.xcent.in
15590                 lo.xcent:sysui/desktop/macosx/lo.xcent.in
15591                 vs-code.code-workspace.template:.vscode/vs-code-template.code-workspace.in])
15592# map unix-style mount dirs to windows directories: /mnt/c/foobar -> C:/foobar
15593# easier to do it in a postprocessing command than to modify every single variable
15594AC_CONFIG_FILES([config_host.mk], [
15595    if test -n "$WSL_ONLY_AS_HELPER"; then
15596        sed -i -e 's#/mnt/\([[:alpha:]]\)/#\u\1:/#g' config_host.mk
15597    fi], [WSL_ONLY_AS_HELPER=$WSL_ONLY_AS_HELPER])
15598
15599AC_CONFIG_HEADERS([config_host/config_atspi.h])
15600AC_CONFIG_HEADERS([config_host/config_buildconfig.h])
15601AC_CONFIG_HEADERS([config_host/config_buildid.h])
15602AC_CONFIG_HEADERS([config_host/config_box2d.h])
15603AC_CONFIG_HEADERS([config_host/config_clang.h])
15604AC_CONFIG_HEADERS([config_host/config_cpdb.h])
15605AC_CONFIG_HEADERS([config_host/config_crypto.h])
15606AC_CONFIG_HEADERS([config_host/config_dconf.h])
15607AC_CONFIG_HEADERS([config_host/config_eot.h])
15608AC_CONFIG_HEADERS([config_host/config_extensions.h])
15609AC_CONFIG_HEADERS([config_host/config_cairo_canvas.h])
15610AC_CONFIG_HEADERS([config_host/config_cairo_rgba.h])
15611AC_CONFIG_HEADERS([config_host/config_cxxabi.h])
15612AC_CONFIG_HEADERS([config_host/config_dbus.h])
15613AC_CONFIG_HEADERS([config_host/config_features.h])
15614AC_CONFIG_HEADERS([config_host/config_feature_desktop.h])
15615AC_CONFIG_HEADERS([config_host/config_feature_opencl.h])
15616AC_CONFIG_HEADERS([config_host/config_firebird.h])
15617AC_CONFIG_HEADERS([config_host/config_folders.h])
15618AC_CONFIG_HEADERS([config_host/config_fonts.h])
15619AC_CONFIG_HEADERS([config_host/config_fuzzers.h])
15620AC_CONFIG_HEADERS([config_host/config_gio.h])
15621AC_CONFIG_HEADERS([config_host/config_global.h])
15622AC_CONFIG_HEADERS([config_host/config_gpgme.h])
15623AC_CONFIG_HEADERS([config_host/config_java.h])
15624AC_CONFIG_HEADERS([config_host/config_langs.h])
15625AC_CONFIG_HEADERS([config_host/config_lgpl.h])
15626AC_CONFIG_HEADERS([config_host/config_libcxx.h])
15627AC_CONFIG_HEADERS([config_host/config_liblangtag.h])
15628AC_CONFIG_HEADERS([config_host/config_locales.h])
15629AC_CONFIG_HEADERS([config_host/config_mpl.h])
15630AC_CONFIG_HEADERS([config_host/config_oox.h])
15631AC_CONFIG_HEADERS([config_host/config_options.h])
15632AC_CONFIG_HEADERS([config_host/config_options_calc.h])
15633AC_CONFIG_HEADERS([config_host/config_zxing.h])
15634AC_CONFIG_HEADERS([config_host/config_skia.h])
15635AC_CONFIG_HEADERS([config_host/config_typesizes.h])
15636AC_CONFIG_HEADERS([config_host/config_validation.h])
15637AC_CONFIG_HEADERS([config_host/config_vendor.h])
15638AC_CONFIG_HEADERS([config_host/config_vclplug.h])
15639AC_CONFIG_HEADERS([config_host/config_version.h])
15640AC_CONFIG_HEADERS([config_host/config_oauth2.h])
15641AC_CONFIG_HEADERS([config_host/config_poppler.h])
15642AC_CONFIG_HEADERS([config_host/config_python.h])
15643AC_CONFIG_HEADERS([config_host/config_writerperfect.h])
15644AC_CONFIG_HEADERS([config_host/config_wasm_strip.h])
15645AC_CONFIG_HEADERS([solenv/lockfile/autoconf.h])
15646AC_OUTPUT
15647
15648if test "$CROSS_COMPILING" = TRUE; then
15649    (echo; echo export BUILD_TYPE_FOR_HOST=$BUILD_TYPE) >>config_build.mk
15650fi
15651
15652# touch the config timestamp file
15653if test ! -f config_host.mk.stamp; then
15654    echo > config_host.mk.stamp
15655elif test "$config_sha256" = `$SHA256SUM config_host.mk | sed "s/ .*//"`; then
15656    echo "Host Configuration unchanged - avoiding scp2 stamp update"
15657else
15658    echo > config_host.mk.stamp
15659fi
15660
15661# touch the config lang timestamp file
15662if test ! -f config_host_lang.mk.stamp; then
15663    echo > config_host_lang.mk.stamp
15664elif test "$config_lang_sha256" = `$SHA256SUM config_host_lang.mk | sed "s/ .*//"`; then
15665    echo "Language Configuration unchanged - avoiding scp2 stamp update"
15666else
15667    echo > config_host_lang.mk.stamp
15668fi
15669
15670
15671if test \( "$STALE_MAKE" = "TRUE" \) \
15672        -a "$build_os" = "cygwin"; then
15673
15674cat << _EOS
15675****************************************************************************
15676WARNING:
15677Your make version is known to be horribly slow, and hard to debug
15678problems with. To get a reasonably functional make please do:
15679
15680to install a pre-compiled binary make for Win32
15681
15682 mkdir -p /opt/lo/bin
15683 cd /opt/lo/bin
15684 wget https://dev-www.libreoffice.org/bin/cygwin/make-4.2.1-msvc.exe
15685 cp make-4.2.1-msvc.exe make
15686 chmod +x make
15687
15688to install from source:
15689place yourself in a working directory of you choice.
15690
15691 git clone git://git.savannah.gnu.org/make.git
15692
15693 [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"]
15694 set PATH=%PATH%;C:\Cygwin\bin
15695 [or Cygwin64, if that is what you have]
15696 cd path-to-make-repo-you-cloned-above
15697 build_w32.bat --without-guile
15698
15699should result in a WinRel/gnumake.exe.
15700Copy it to the Cygwin /opt/lo/bin directory as make.exe
15701
15702Then re-run autogen.sh
15703
15704Note: autogen.sh will try to use /opt/lo/bin/make if the environment variable GNUMAKE is not already defined.
15705Alternatively, you can install the 'new' make where ever you want and make sure that `command -v make` finds it.
15706
15707_EOS
15708fi
15709
15710
15711cat << _EOF
15712****************************************************************************
15713
15714To show information on various make targets and make flags, run:
15715$GNUMAKE help
15716
15717To just build, run:
15718$GNUMAKE
15719
15720_EOF
15721
15722if test $_os != WINNT -a "$CROSS_COMPILING" != TRUE; then
15723    cat << _EOF
15724After the build has finished successfully, you can immediately run what you built using the command:
15725_EOF
15726
15727    if test $_os = Darwin; then
15728        echo open instdir/$PRODUCTNAME_WITHOUT_SPACES.app
15729    else
15730        echo instdir/program/soffice
15731    fi
15732    cat << _EOF
15733
15734If you want to run the unit tests, run:
15735$GNUMAKE check
15736
15737_EOF
15738fi
15739
15740if test -s "$WARNINGS_FILE_FOR_BUILD"; then
15741    echo "BUILD / cross-toolset config, repeated ($WARNINGS_FILE_FOR_BUILD)"
15742    cat "$WARNINGS_FILE_FOR_BUILD"
15743    echo
15744fi
15745
15746if test -s "$WARNINGS_FILE"; then
15747    echo "HOST config ($WARNINGS_FILE)"
15748    cat "$WARNINGS_FILE"
15749fi
15750
15751# Remove unneeded emconfigure artifacts
15752rm -f a.out a.wasm a.out.js a.out.wasm
15753
15754dnl vim:set shiftwidth=4 softtabstop=4 expandtab:
15755