xref: /aoo42x/main/configure.ac (revision 24687b4c)
1dnl /******************************************************************
2dnl *     vi:set sw=3 ts=3 et:
3dnl *
4dnl * Name: configure.in
5dnl * Auth: Willem van Dorp, Ross Nicholson, Oisin Boydell - Sun Microsystems Ireland
6dnl * Date: $Date: 2008-09-08 07:38:40 $
7dnl *
8dnl * Desc: This file serves as input for the GNU autoconf package
9dnl *       in order to create a configure script.
10dnl *       In this stage configure just checks the pre-requisites
11dnl *       necessary to build OpenOffice.org
12dnl *
13dnl *
14dnl ******************************************************************/
15AC_REVISION( $Revision: 1.290 $ )
16AC_PREREQ(2.50)
17AC_INIT()
18echo "$@" >config.parms
19AC_ARG_WITH(gnu-patch,
20[  --with-gnu-patch        Specify location of GNU patch on Solaris or FreeBSD
21],,)
22AC_ARG_ENABLE(agg,
23[  --enable-agg           Use internal agg
24],,)
25AC_ARG_WITH(gnu-cp,
26[  --with-gnu-cp           Specify location of GNU cp on Solaris or FreeBSD
27],,)
28AC_ARG_WITH(gperf,
29[  --with-gperf           Specify location of gperf on Solaris or FreeBSD
30],,)
31AC_ARG_ENABLE(graphite,
32[  --enable-graphite       Enables the compilation of Graphite smart font rendering
33],,)
34AC_ARG_WITH(system-graphite,
35[  --with-system-graphite    use graphite library already installed on system
36],,)
37AC_ARG_ENABLE(ldap,
38[  --disable-ldap          Disables the use of LDAP backend via Netscape/Mozilla
39                          or OpenLDAP LDAP SDK
40],,)
41AC_ARG_ENABLE(fetch-external,
42[  --disable-fetch-external Disables fetching external tarballs from web sources.
43],,)
44AC_ARG_WITH(external-tar,
45[  --with-external-tar=<TARFILE PATH>   Specify path to tarfiles manually ],
46[ TARFILE_LOCATION="$withval"
47])
48AC_ARG_WITH(openldap,
49[  --with-openldap         Enables the use of the OpenLDAP LDAP SDK instead
50                          of the Netscape/Mozilla one
51],,)
52AC_ARG_ENABLE(lockdown,
53[  --enable-lockdown       Enables the gconf integration work in OOo
54],,)
55AC_ARG_ENABLE(vba,
56[  --disable-vba           disables the vba compatibility feature
57],,)
58AC_ARG_WITH(vba-package-format,
59[  --with-vba-package-format   specify package format for vba compatibility api.
60                          Specifying  "builtin" means the api component and
61                          associated type library are  part of the installation set.
62                          Specifying "extn" creates an uno extension that is
63                          part of the installation set ( located in the program
64                          directory ) that MUST be optionly registered using
65                          either the unopkg executeable or the extension manager
66                          gui.
67
68                          Note: "builtin" is the default, "extn" can cause
69                          problems.
70                          Usage: --with-vba-package-format="builtin" or
71                                 --with-vba-package-format="extn"
72],,)
73AC_ARG_ENABLE(pch,
74[  --enable-pch            EXPERIMENTAL: Enables precompiled header support for C++.
75],,)
76AC_ARG_ENABLE(mozilla,
77[  --disable-mozilla       OO.o usually includes a strangely hacked up mozilla
78                          binary for your platform, to build without this
79                          version, use this option.
80],,enable_mozilla="yes")
81AC_ARG_WITH(fonts,
82[  --without-fonts         OOo includes some third-party fonts to provide a reliable
83                          basis for help content, templates, samples, etc.
84                          When these fonts are already known to be available on the
85                          system then you should use this option.
86],,)
87AC_ARG_WITH(ppds,
88[  --without-ppds          Removes Postscript Printer definition files from
89                          openoffice.org installation set, for people building
90                          for specific distributions where PPDs are known to be
91                          already available (every recent distro with CUPS
92                          backend)
93],,)
94AC_ARG_WITH(afms,
95[  --without-afms          Removes bitmap font files from openoffice.org
96                          installation set, for people building for specific
97                          distributions where AFM files or TrueType Fonts
98                          are known to be available.
99],,)
100AC_ARG_ENABLE(epm,
101[  --disable-epm           OO.o includes self-packaging code, that requires
102                          epm, however epm is useless for large scale
103                          package building.
104],,enable_epm="yes")
105AC_ARG_WITH(epm,
106[  --with-epm		  Decides which epm to use. Default is to use
107			  the one from the system if one is built. When
108			  either this is not there or you say =internal
109			  epm will be built.
110],,)
111AC_ARG_WITH(package-format,
112[  --with-package-format   specify package format(s) for OOo installsets.
113                          Default is "normal" one of the OS/Distribution.
114
115                          Usage: --with-package-format="foo bar"
116],,)
117AC_ARG_ENABLE(odk,
118[  --disable-odk           OO.o includes an ODK, office development kit
119                          which some packagers may with to build without
120],,enable_odk="yes")
121AC_ARG_ENABLE(mathmldtd,
122[  --disable-mathmldtd     disable mathmldtd
123                          (useful for distributions that want to avoid packaging
124                          it)
125],,enable_mathmldtd="yes")
126AC_ARG_ENABLE(evolution2,
127[  --enable-evolution2     Allows the built-in evolution 2 addressbook
128                          connectivity build to be enabled.
129],,)
130AC_ARG_WITH(system-stdlibs,
131[  --with-system-stdlibs   use libstdc++/libgcc_s already on system
132],,)
133AC_ARG_ENABLE(cups,
134[  --disable-cups          disable CUPS support (for printing on UNIX)
135],,enable_cups=yes)
136AC_ARG_ENABLE(fontconfig,
137[  --disable-fontconfig    disable support for the fontconfig library
138],,enable_fontconfig=yes)
139AC_ARG_ENABLE(directx,
140[  --disable-directx       Remove DirectX implementation for the new XCanvas
141                          interface. The DirectX support requires more stuff
142                          installed on Windows to compile.
143                          (DirectX SDK, GDI+ libs)
144],,enable_directx=yes)
145AC_ARG_ENABLE(activex,
146[  --disable-activex       Disable the use of ActiveX for windows build.
147                          This switch is mandatory when using VC++ 2005/2008 Express.
148],,)
149
150AC_ARG_ENABLE(atl,
151[  --disable-atl          Disable the use of ATL for windows build.
152                          This switch is mandatory when using VC++ 2005/2008 Express.
153],,)
154
155AC_ARG_ENABLE(symbols,
156[  --enable-symbols        Include debugging symbols in output.
157                          WARNING - a complete build needs 8 Gb of space and
158                          takes much longer. (enables -g compiler flag)
159
160                          --enable-symbols=SMALL sets the gcc -g1 setting
161                          which is smaller.
162
163                          Enabling symbols disables the stripping of the solver
164                          (--disable-strip-solver).
165],,)
166AC_ARG_ENABLE(strip-solver,
167[  --disable-strip-solver  Disable the stripping of the solver.
168                          By default the solver is stripped unless a build with
169                          debugging symbols (--enable-symbols) is requested.
170
171                          This switch allows to override this setting.
172],,)
173AC_ARG_ENABLE(werror,
174[  --enable-werror         Turn warnings to errors. (Has no effect in modules
175                          where the treating of warnings as errors is disabled
176                          explicitly)
177],,)
178AC_ARG_ENABLE(debug,
179[  --enable-debug          Include debugging symbols from --enable-symbols
180                          plus extra debugging code.  Extra large build!
181                          (enables -g compiler flag and dmake debug=true)
182],,)
183AC_ARG_ENABLE(dbgutil,
184[  --enable-dbgutil        Include additional debugging utilities, such as
185                          assertions, object counting, etc. Larger build.
186                          Independent from --enable-debug
187],,)
188AC_ARG_ENABLE(crashdump,
189[  --enable-crashdump      Enable the crashdump feature code.
190],,)
191AC_ARG_ENABLE(cl-standard,
192[  --enable-cl-standard    For Microsoft C/C++ compiler users, use non-optimizing
193                          standard compiler. ( This just disables optimization
194                          options and therefore removes a lot of warnings when
195                          using the cheaper standard compiler. )
196],,)
197AC_ARG_ENABLE(gtk,
198[  --disable-gtk           Determines whether to use Gtk+ vclplug on platforms
199                          where Gtk+ is available.
200],,enable_gtk=yes)
201AC_ARG_ENABLE(gstreamer,
202[  --disable-gstreamer     Determines whether to use the GStreamer media
203                          backend on platforms where GStreamer is available.
204],,enable_gstreamer=yes)
205AC_ARG_ENABLE(systray,
206[  --disable-systray       Determines whether to build the systray quickstarter.
207],,enable_systray=yes)
208AC_ARG_ENABLE(cairo,
209[  --enable-cairo          Determines whether to use Cairo library on
210                          platforms where Cairo is available.
211],,enable_cairo=no)
212AC_ARG_WITH(system-cairo,
213[  --with-system-cairo      Use Cairo libraries already on system
214],,)
215AC_ARG_ENABLE(cairo-canvas,
216[  --disable-cairo-canvas  Determines whether to build the Cairo canvas on
217                          platforms where Cairo is available.
218],,enable_cairo_canvas=yes)
219AC_ARG_ENABLE(opengl,
220[  --enable-opengl         Determines whether to build the OpenGL 3D slide
221                          transitions component
222],,enable_opengl=no)
223AC_ARG_ENABLE(dbus,
224[  --enable-dbus           Determines whether to enable presentation mode
225                          screensaver control under GNOME via DBUS
226],,enable_dbus=no)
227AC_ARG_ENABLE(gconf,
228[  --disable-gconf         Determines whether to use the GConf support
229],,enable_gconf=yes)
230AC_ARG_ENABLE(gnome-vfs,
231[  --disable-gnome-vfs     Determines whether to use the Gnome Virtual Filing
232                          System on platforms where that VFS is available
233],,enable_gnome_vfs=yes)
234AC_ARG_ENABLE(gio,
235[  --enable-gio            Determines whether to use the GIO support
236],,enable_gio=no)
237AC_ARG_ENABLE(static-gtk,
238[  --enable-static-gtk     Modules that are linked against gtk libraries use
239                          the static libraries instead of the dynamic ones.
240                          (enables -Bstatic linker flag for gtk libraries)
241],,)
242AC_ARG_ENABLE(layout,
243[  --enable-layout         Enable the compilation and use of layout dialogs
244],,)
245AC_ARG_ENABLE(build-mozilla,
246[  --disable-build-mozilla Use this option if you do not want to build the
247                          mozilla components from the mozilla source code but
248                          take precompiled zips
249],,)
250AC_ARG_WITH(mozilla-version,
251[  --with-mozilla-version  Choose which version of mozilla to use while building
252                          mozilla. Default: 1.7.5.
253                          Note that not all versions are supported.
254],,)
255AC_ARG_WITH(mozilla-toolkit,
256[  --with-mozilla-toolkit  Choose which GUI toolkit to use while building mozilla
257                          components. Default: gtk2
258],,)
259AC_ARG_ENABLE(nss_module,
260[  --disable-nss-module    Whether to use provided NSS module
261],,enable_nss_module=yes)
262AC_ARG_ENABLE(kde,
263[  --enable-kde            Determines whether to use Qt/KDE vclplug on platforms
264                          where Qt and KDE are available.
265],,)
266AC_ARG_ENABLE(kdeab,
267[  --disable-kdeab         Disable the KDE address book support
268],,if test "$enable_kde" = "yes"; then enable_kdeab=yes; fi)
269AC_ARG_ENABLE(kde4,
270[  --enable-kde4            Determines whether to use Qt4/KDE4 vclplug on platforms
271                          where Qt4 and KDE4 are available. May be used with --enable-kde
272                          if you want to support both KDE3 and KDE4.
273],,)
274AC_ARG_ENABLE(binfilter,
275[  --enable-binfilter      Enable legacy binary file formats filters
276],,)
277AC_ARG_ENABLE(rpath,
278[  --disable-rpath         Disable the use of relative paths in shared libraries
279],,)
280AC_ARG_ENABLE(pam,
281[  --disable-pam           Disable pam support.
282],,)
283AC_ARG_ENABLE(pam-link,
284[  --enable-pam-link       link with libpam instead of dynamically open it
285],,)
286AC_ARG_ENABLE(crypt-link,
287[  --disable-crypt-link    disable linking with libcrypt instead of dynamically
288                          open it (needed for ancient GNU/Linux distributions
289                          without crypt()/libcrypt)
290],,enable_crypt_link=yes)
291AC_ARG_ENABLE(xrender-link,
292[  --enable-xrender-link   link with libXrender instead of dynamically open it
293],,)
294AC_ARG_ENABLE(randr,
295[  --disable-randr         disable RandR support in the vcl project
296],,enable_randr=yes)
297AC_ARG_ENABLE(randr-link,
298[  --disable-randr-link    disable linking with libXrandr, instead dynamically
299                           open it at runtime
300],,enable_randr_link=yes)
301AC_ARG_WITH(myspell-dicts,
302[  --without-myspell-dicts Removes myspell dictionaries from openoffice.org
303                          installation set, for people building for specific
304                          distributions where the myspell dictionaries are
305                          installed from other sources
306],,)
307AC_ARG_WITH(system-dicts,
308[  --with-system-dicts    Use dictionaries from system paths- Specify
309                         them via --with-{dict,hyph,thes}-path=/path
310			 if you want to override the default ones
311],,)
312AC_ARG_WITH(external-dict-dir,
313[  --with-external-dict-dir Specify external dictionary dir
314],,)
315AC_ARG_WITH(external-hyph-dir,
316[  --with-external-hyph-dir Specify external hyphenation pattern dir
317],,)
318AC_ARG_WITH(external-thes-dir,
319[  --with-external-thes-dir Specify external thesaurus dir
320],,)
321AC_ARG_WITH(system-libs,
322[  --with-system-libs      Use libs already on system -- enables all
323                          --with-system-* flags except mozilla and
324                          odbc/sane/xrender-header(s)
325],,)
326AC_ARG_WITH(system-headers,
327[  --with-system-headers   Use headers already on system -- enables all
328                          --with-system-* flags for external packages
329                          whose headers are the only entities used i.e.
330                          boost/vigra/odbc/sane/xrender-header(s)
331],,)
332AC_ARG_WITH(system-jars,
333[  --without-system-jars   When building with --with-system-libs, also the
334                          needed jars are expected on the system. Use this to
335                          disable that.
336                          (except for the db case where --with-system-db
337                          *has to* imply using the db.jar from there, too)
338],,)
339AC_ARG_WITH(system-zlib,
340[  --with-system-zlib      Use zlib already on system
341],,)
342AC_ARG_WITH(system-openssl,
343[  --with-system-openssl   Use OpenSSL already on system
344],,)
345AC_ARG_WITH(system-jpeg,
346[  --with-system-jpeg      Use jpeg already on system
347],,)
348AC_ARG_WITH(system-expat,
349[  --with-system-expat     Use expat already on system
350],,)
351AC_ARG_WITH(system-libwpd,
352[  --with-system-libwpd    Use libwpd already on system
353],,)
354AC_ARG_WITH(system-libxml,
355[  --with-system-libxml    Use libxml already on system
356],,)
357AC_ARG_WITH(system-python,
358[  --with-system-python    Use python already on system
359],,)
360AC_ARG_WITH(system-icu,
361[  --with-system-icu       Use icu already on system
362],,)
363AC_ARG_WITH(system-poppler,
364[  --with-system-poppler   Use poppler already on system
365],,)
366AC_ARG_WITH(system-db,
367[  --with-system-db        Use berkeley db already on system
368],,)
369AC_ARG_WITH(system-lucene,
370[  --with-system-lucene    Use lucene already on system
371],,)
372AC_ARG_WITH(lucene-core-jar,
373[  --with-lucene-core-jar=JARFILE   Specify path to jarfile manually ],
374[ LUCENE_CORE_JAR="$withval"
375])
376AC_ARG_WITH(lucene-analyzers-jar,
377[  --with-lucene-analyzers-jar=JARFILE   Specify path to jarfile manually ],
378[ LUCENE_ANALYZERS_JAR="$withval"
379])
380AC_ARG_ENABLE(mysql-connector,
381[  --enable-mysql-connector     enables the build of the MySQL Connector/OOo extension.
382                                This requires access to the MySQL Connector/C (aka libmysql) to be given, too, with
383                                either the --with-system-mysql or --with-libmysql-path option.
384],,)
385AC_ARG_WITH(system-mysql,
386[  --with-system-mysql          Use MySQL libraries already on system, for building the MySQL Connector/OOo extension.
387                                Requires MYSQLCONFIG to point to the mysql_config executable.
388],,)
389AC_ARG_WITH(libmysql-path,
390[  --with-libmysql-path         Use Connector/C (libmysql) installation for building the MySQL Connector/OOo extension.
391
392                                Usage: --with-libmysql-path=<absolute path to your Connector/C installation>
393],,)
394AC_ARG_WITH(system-mysql-cppconn,
395[  --with-system-mysql-cppconn  Use MySQL C++ Connector libraries already on system
396],,)
397AC_ARG_WITH(system-hsqldb,
398[  --with-system-hsqldb    Use hsqldb already on system
399],,)
400AC_ARG_WITH(hsqldb-jar,
401[  --with-hsqldb-jar=JARFILE   Specify path to jarfile manually ],
402[ HSQLDB_JAR="$withval"
403])
404AC_ARG_WITH(system-beanshell,
405[  --with-system-beanshell Use beanshell already on system
406],,)
407AC_ARG_WITH(beanshell-jar,
408[  --with-beanshell-jar=JARFILE   Specify path to jarfile manually ],
409[ BSH_JAR="$withval"
410])
411AC_ARG_ENABLE(presenter-extra-ui,
412[  --enable-presenter-extra-ui   enables extra functionality during slideshow,
413                                 e.g. selecting pen color, erasing drawings etc.
414],,enable_presenter_extra_ui=no)
415AC_ARG_ENABLE(minimizer,
416[  --enable-minimizer          enables the build of the Presentation Minimizer extension
417],,)
418AC_ARG_ENABLE(presenter-console,
419[  --enable-presenter-console          enables the build of the Presenter Console extension
420],,)
421AC_ARG_ENABLE(pdfimport,
422[  --enable-pdfimport          enables the build of the PDF Import extension
423],,)
424AC_ARG_ENABLE(wiki-publisher,
425[  --enable-wiki-publisher      enables the build of the Wiki Publisher extension
426],,)
427AC_ARG_WITH(commons-codec-jar,
428[  --with-commons-codec-jar=JARFILE   Specify path to jarfile manually ],
429[ COMMONS_CODEC_JAR="$withval"
430])
431AC_ARG_WITH(commons-lang-jar,
432[  --with-commons-lang-jar=JARFILE   Specify path to jarfile manually ],
433[ COMMONS_LANG_JAR="$withval"
434])
435AC_ARG_WITH(commons-httpclient-jar,
436[  --with-commons-httpclient-jar=JARFILE   Specify path to jarfile manually ],
437[ COMMONS_HTTPCLIENT_JAR="$withval"
438])
439AC_ARG_WITH(commons-logging-jar,
440[  --with-commons-logging-jar=JARFILE   Specify path to jarfile manually ],
441[ COMMONS_LOGGING_JAR="$withval"
442])
443AC_ARG_WITH(servlet-api-jar,
444[  --servlet-api-jar=JARFILE   Specify path to jarfile manually ],
445[ SERVLETAPI_JAR="$withval"
446])
447AC_ARG_ENABLE(report-builder,
448[  --enable-report-builder  enables the build of the Report Builder extension
449],,)
450AC_ARG_WITH(sac-jar,
451[  --with-sac-jar=JARFILE   Specify path to jarfile manually (for Report Builder extension) ],
452[ SAC_JAR="$withval"
453])
454AC_ARG_WITH(libxml-jar,
455[  --with-libxml-jar=JARFILE   Specify path to jarfile manually (for Report Builder extension) ],
456[ LIBXML_JAR="$withval"
457])
458AC_ARG_WITH(flute-jar,
459[  --with-flute-jar=JARFILE   Specify path to jarfile manually (for Report Builder extension) ],
460[ FLUTE_JAR="$withval"
461])
462AC_ARG_WITH(jfreereport-jar,
463[  --with-jfreereport-jar=JARFILE   Specify path to jarfile manually (for Report Builder extension) ],
464[ JFREEREPORT_JAR="$withval"
465])
466AC_ARG_WITH(liblayout-jar,
467[  --with-liblayout-jar=JARFILE   Specify path to jarfile manually (for Report Builder extension) ],
468[ LIBLAYOUT_JAR="$withval"
469])
470AC_ARG_WITH(libloader-jar,
471[  --with-libloader-jar=JARFILE   Specify path to jarfile manually (for Report Builder extension) ],
472[ LIBLOADER_JAR="$withval"
473])
474AC_ARG_WITH(libloader-jar,
475[  --with-libloader-jar=JARFILE   Specify path to jarfile manually (for Report Builder extension) ],
476[ LIBLOADER_JAR="$withval"
477])
478AC_ARG_WITH(libformula-jar,
479[  --with-libformula-jar=JARFILE   Specify path to jarfile manually (for Report Builder extension) ],
480[ LIBFORMULA_JAR="$withval"
481])
482AC_ARG_WITH(librepository-jar,
483[  --with-librepository-jar=JARFILE   Specify path to jarfile manually (for Report Builder extension) ],
484[ LIBREPOSITORY_JAR="$withval"
485])
486AC_ARG_WITH(libfonts-jar,
487[  --with-libfonts-jar=JARFILE   Specify path to jarfile manually (for Report Builder extension) ],
488[ LIBFONTS_JAR="$withval"
489])
490AC_ARG_WITH(libserializer-jar,
491[  --with-libserializer-jar=JARFILE   Specify path to jarfile manually (for Report Builder extension) ],
492[ LIBSERIALIZER_JAR="$withval"
493])
494AC_ARG_WITH(libbase-jar,
495[  --with-libbase-jar=JARFILE   Specify path to jarfile manually (for Report Builder extension) ],
496[ LIBBASE_JAR="$withval"
497])
498AC_ARG_WITH(system-saxon,
499[  --with-system-saxon     Use saxon already on system
500],,)
501AC_ARG_WITH(saxon-jar,
502[  --with-saxon-jar=JARFILE   Specify path to jarfile manually ],
503[ SAXON_JAR="$withval"
504])
505AC_ARG_WITH(system-libxslt,
506[  --with-system-libxslt   Use libxslt already on system
507],,)
508AC_ARG_WITH(system-odbc,
509[  --with-system-odbc-headers     Use the odbc headers already on system
510],,)
511AC_ARG_WITH(system-sane,
512[  --with-system-sane-header      Use sane.h already on system
513],,)
514AC_ARG_WITH(system-xrender,
515[  --with-system-xrender-headers  Use XRender headers already on system
516],,)
517AC_ARG_WITH(system-curl,
518[  --with-system-curl      Use curl already on system
519],,)
520AC_ARG_WITH(system-boost,
521[  --with-system-boost     Use boost already on system
522],,)
523AC_ARG_WITH(system-mdds,
524[  --with-system-mdds      Use mdds already on system
525],,)
526AC_ARG_WITH(system-vigra,
527[  --with-system-vigra     Use vigra already on system
528],,)
529AC_ARG_ENABLE(Xaw,
530[  --disable-Xaw           Disables the use of Xaw for the Netscape/Mozilla
531                           plugin
532],,)
533AC_ARG_WITH(system-neon,
534[  --with-system-neon      Use neon already on system
535],,)
536AC_ARG_WITH(system-agg,
537[  --with-system-agg       Use AGG already on system
538],,)
539AC_ARG_WITH(system-hunspell,
540[  --with-system-hunspell   Use libhunspell already on system
541],,)
542AC_ARG_WITH(system-mythes,
543[  --with-system-mythes    Use mythes already on system
544],,)
545AC_ARG_WITH(system-altlinuxhyph,
546[  --with-system-altlinuxhyph    Use ALTLinuxhyph already on system
547],,)
548AC_ARG_WITH(system-libtextcat,
549[  --with-system-libtextcat      Use libtextcat already on system
550],,)
551AC_ARG_WITH(external-libtextcat-data,
552[  --with-system-libtextcat-data Use libtextcat data already on system
553],,)
554AC_ARG_WITH(system-cppunit,
555[  --with-system-cppunit         Use cppunit already on system
556],,)
557AC_ARG_WITH(system-redland,
558[  --with-system-redland   Use redland library already on system
559],,)
560AC_ARG_WITH(system-mozilla,
561[  --with-system-mozilla   Use mozilla already on system. Note that some
562                          components cannot be built against a contemporary
563                          mozilla. The flavour used can be specified by
564                          --with-system-mozilla=<flavour>. Supported are:
565                          libxul (default), xulrunner, firefox, seamonkey,
566                          mozilla
567], WITH_SYSTEM_MOZILLA=$withval, WITH_SYSTEM_MOZILLA=no)
568AC_ARG_WITH(stlport,
569[  --with-stlport         The location that STLport is installed in. The STL
570                          header files are assumed to be in
571                          stlport-home/stlport and the STLPort library in
572                          stlport-home/lib.
573
574                          Usage: --with-stlport=<absolute path to stlport home>
575
576                          Warning!!, disabling using --without-stlport or
577                          enabling using --with-stlport on a platform that
578                          defaults to the opposite will break ABI compatability
579], WITH_STLPORT=$withval , WITH_STLPORT=auto)
580AC_ARG_WITH(jdk-home,
581[  --with-jdk-home         if you have installed JDK 1.3 or later on your system
582                          please supply the path here.
583                          Note that this is not the location of the Java binary
584                          but the location of the entire distribution.
585
586                          Usage: --with-jdk-home=<absolute path to JDK home>
587],,)
588AC_ARG_WITH(gxx_include_path,
589[  --with-gxx-include-path if you want to override the autodetected g++ include
590                          path.
591
592                          Usage: --with-gxx-include-path=<absolute path to g++ include dir>
593],,)
594AC_ARG_WITH(java,
595[  --with-java             Build with[[out]] Java support.  If you use
596                          --without-java/--with-java=no then the build will have
597                          no support for Java components, applets, accessibility
598                          or XML filters.
599], if test "$withval" = "yes"; then WITH_JAVA=java; else WITH_JAVA=$withval; fi, WITH_JAVA=java)
600AC_ARG_ENABLE(gcjaot,
601[  --enable-gcjaot         Build with[[out]] using Ahead of Time java compilation
602                          support to speed up buildsi by compiling the jars also
603                          to native code..
604                          --enable-gcjaot is only known to work with bytecode
605                          created with gcj or ecj
606],,)
607AC_ARG_WITH(ant-home,
608[  --with-ant-home         If you have installed Jakarta Ant on your system,
609                          please supply the path here.
610                          Note that this is not the location of the Ant binary
611                          but the location of the entire distribution.
612
613                          Usage: --with-ant-home=<absolute path to Ant home>
614],,)
615AC_ARG_WITH(junit,
616[  --with-junit            Specifies the JUnit 4 jar file to use for JUnit-based
617                          tests.  --without-junit disables those tests.  Not
618                          relevant in the --without-java case.
619
620                          Usage: --with-junit=<absolute path to JUnit 4 jar>
621],,with_junit=yes)
622AC_ARG_WITH(perl-home,
623[  --with-perl-home        If you have installed the Perl 5 Distribution, on your
624                          system, please supply the path here.
625                          Note that this is not the location of the Perl binary
626                          but the location of the entire distribution.
627
628                          Usage: --with-perl-home=<absolute path to Perl 5 home>
629],,)
630AC_ARG_WITH(cl-home,
631[  --with-cl-home          For Windows NT users, please supply the path
632                          for the Microsoft C/C++ compiler.
633                          Note that this is not the location of the compiler
634                          binary but the location of the entire distribution.
635
636                          Usage: --with-cl-home=<absolute path to Microsoft C/C++ compiler home>
637],,)
638AC_ARG_WITH(mspdb-path,
639[  --with-mspdb-path       For Microsoft C/C++ compiler users, please supply the
640                          path pointing to the mspdb71.dll (.NET 2003).
641
642                          Usage: --with-mspdb-path=<absolute path to mspdb71.dll>
643],,)
644AC_ARG_WITH(midl-path,
645[  --with-midl-path        For Microsoft C/C++ .NET compiler users, please supply
646                          the path pointing to the midl.exe.
647
648                          Usage: --with-midl-path=<absolute path to midl.exe>
649],,)
650AC_ARG_WITH(csc-path,
651[  --with-csc-path         For Microsoft C/C++ .NET compiler users, please supply
652                          the path pointing to the csc.exe.
653
654                          Usage: --with-csc-path=<absolute path to csc.exe>
655],,)
656AC_ARG_WITH(nsis-path,
657[  --with-nsis-path        For Windows users, please supply the path to the
658                          "Nullsoft Scriptable Install System" (NSIS). If NSIS
659                          is found in the path or this option is supplied a self
660                          contained executable installer for OpenOffice.org will
661                          be created.
662
663                          Usage: --with-nsis-path=<absolute path to nsis.exe>
664],,)
665AC_ARG_WITH(frame-home,
666[  --with-frame-home       For Microsoft C/C++ .NET compiler users, please supply
667                          the path pointing to lib/mscoree.lib, usually
668                          something like:
669                          "/cygdrive/c/Program Files/Microsoft Visual Studio .NET/FrameworkSDK"
670
671                          MS Visual Toolkit compiler users, please supply the
672                          path pointing to lib/msvcrt.lib, usually something
673                          like:
674                          "/cygdrive/c/Program Files/Microsoft Visual Studio .NET 2003/Vc7"
675
676                          Usage: --with-frame-home=<absolute path to Framework SDK [[home]]>
677],,)
678AC_ARG_WITH(psdk-home,
679[  --with-psdk-home        For Windows users, please supply the path to the
680                          Microsoft Platform SDK.
681
682                          Usage: --with-psdk-home=<absolute path to Microsoft Platform SDK>
683],,)
684AC_ARG_WITH(directx-home,
685[  --with-directx-home     For Windows users, please supply the path to the
686                          Microsoft DirectX SDK.
687
688                          Usage: --with-directx-home=<absolute path to Microsoft DirectX SDK>
689],,)
690AC_ARG_WITH(mozilla-build,
691[  --with-mozilla-build    For Windows users, please supply the path to the
692                          mozilla build tools.
693
694                          Usage: --with-mozilla-build=<absolute path to mozilla build tools>
695
696						  At the moment of this writing, an installer for the mozilla build tools
697						  can be obtained from http://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/win32.
698],[MOZILLABUILD=$withval],)
699AC_ARG_WITH(local-solenv,
700[  --with-local-solenv     If you have solenv in a location other than ./solenv,
701                          please supply the path here.
702
703                          Usage: --with-local-solenv=<absolute path to solenv>
704],,)
705AC_ARG_WITH(local-solver,
706[  --with-local-solver     if you have solver in a location other than ./solver,
707                          please supply the path here.
708
709                          Usage: --with-local-solver=<absolute path to solver>
710],,)
711AC_ARG_ENABLE(check-only,
712[  --enable-check-only     Use this option option if you just want to check your
713                          environment.  This option stops the generation of an
714                          ????env.set
715
716                          Usage: --enable-check-only=yes
717],,)
718AC_ARG_ENABLE(ccache-skip,
719[[  --enable-ccache-skip    [default=auto] allow the use of --ccache-skip to
720                          escape compiler flags that would otherwise prevent
721                          caching of the result (currently used on Mac only)
722                          NOTE: requires patched version because of a bug in
723                          ccache (see issue 104567 for details and patch)
724                          explicitly enable if your version of ccache does not
725                          identify as version 2.4_OOo
726]],,enable_ccache_skip=auto)
727AC_ARG_WITH(lang,
728[  --with-lang             Use this option to build OpenOffice.org with
729                          additional language support. English (US) is always
730                          included by default. Separate multiple languages with
731                          space. For all languages, use --with-lang=ALL.
732
733                          Usage: --with-lang="es sw tu cs sk"
734],,)
735AC_ARG_WITH(poor-help-localizations,
736[  --with-poor-help-localizations
737                           Use this option to specify which languages have
738                          unusable help localizations. Separate multiple
739                          languages with space.
740
741                          Usage: --with-poor-help-localizations="af ar be-BY ca"
742],,)
743AC_ARG_WITH(dict,
744[  --with-dict             Use this option to build OpenOffice.org with
745                          dictionary support. ALL dictionaries are always
746                          included by default unless overridden with
747                          this option. Separate multiple dictionaries with
748                          commas. For all dictionaries, use --with-dict=ALL.
749
750                          Usage: --with-dict=ENGB,ENUS,ITIT
751],,)
752AC_ARG_WITH(intro-bitmaps,
753[  --with-intro-bitmaps    Prefer the specified intro bitmaps over the
754                          the default one.  Can be more than one (separated by
755                          commas), the order means priority of fallback if the
756                          first does not exist (in the installed tree).
757
758                          Usage: --with-intro-bitmaps=/path/my_ooo_intro.bmp
759],,)
760AC_ARG_WITH(about-bitmaps,
761[  --with-about-bitmaps    Similarly to --with-intro-bitmaps, this allows
762                          specification of bitmaps for the About box.
763
764                          Usage: --with-about-bitmaps=/path/my_ooo_about.bmp
765],,)
766AC_ARG_WITH(vendor,
767[  --with-vendor           Set vendor of the build.
768
769                          Usage: --with-vendor="John the Builder"
770],,)
771AC_ARG_WITH(unix-wrapper,
772[  --with-unix-wrapper    Redefines the name of the UNIX wrapper that will be used
773                          in the desktop files and in the desktop-integration RPMs.
774
775                          Usage: --with-unix-wrapper=ooffice
776],,)
777AC_ARG_WITH(asm-home,
778[  --with-asm-home         For Windows users, please supply the path for the
779                          ml.exe assembler.
780
781                          Usage: --with-asm-home=<path to ml.exe directory>
782],,)
783AC_ARG_WITH(os-version,
784[  --with-os-version       For FreeBSD users, use this option option to override
785                          the detected OSVERSION.
786
787                          Usage: --with-os-version=<OSVERSION>
788],,)
789AC_ARG_WITH(unzip-home,
790[  --with-unzip-home       Deprecated: use --with-zip-home instead],,)
791AC_ARG_WITH(zip-home,
792[  --with-zip-home         If you use a non standard zip, for example windows
793                          please supply the path for zip
794
795                          Usage: --with-zip-home=<path to zip executable>
796],,)
797AC_ARG_WITH(mingwin,
798[  --with-mingwin          For Windows users, use the mingwin32 compiler within
799                          cygwin environment
800
801                          Usage: --with-mingwin=yes
802
803                          For !Windows use, use the mingw32 C++ compiler to
804                          (re-) build unowinreg.dll. Specify the MinGW C++
805                          Compilers name.
806
807                          Usage: --with-mingwin=i586-mingw32msvc-g++
808],WITH_MINGWIN=$withval,WITH_MINGWIN=0)
809AC_ARG_WITH(build-version,
810[  --with-build-version    Allows the builder to add a custom version tag
811                          that will appear in the Help/About box for QA
812                          purposes.
813
814                          Usage: --with-build-version="Built by Jim"
815],with_build_version=$withval)
816AC_ARG_WITH(alloc,
817[  --with-alloc            Define which allocator to build with
818                          (choices are oo, system, tcmalloc, jemalloc)
819
820                          Note that on FreeBSD/NetBSD system==jemalloc
821],,)
822AC_ARG_ENABLE(verbose,
823[  --enable-verbose        Increase build verbosity.
824  --disable-verbose       Decrease build verbosity.
825],,)
826AC_ARG_ENABLE(dependency-tracking,
827[  --disable-dependency-tracking  Disables generation of dependency information.
828],,)
829AC_ARG_ENABLE(copyleft,
830[  --enable-copyleft      Whether to use copyleft components.
831],,)
832AC_ARG_WITH(arm-target,
833[  --arm-target        The minimal targeted arm processor
834                          used for the build environment.
835                          Cases :
836                            arm-target < 6 : armv4t compatibility
837                            arm-target = 6 : exact armv6 compatibility
838                    	    arm-target > 6 : armv7-a compatibility
839
840                          Usage: --with-arm-target=7
841],with_arm_target=$withval,with_arm_target=4)
842
843BUILD_TYPE="OOo"
844
845dnl ===================================================================
846dnl Message.
847dnl ===================================================================
848echo "********************************************************************"
849echo "*                                                                  *"
850echo "*   OpenOffice.org build configuration.                            *"
851echo "*                                                                  *"
852echo "*   The configure process checks your platform to see whether      *"
853echo "*   you can build OpenOffice.org on it.                            *"
854echo "*   This process checks all pre-requisites and generates a file    *"
855echo "*   containing the necessary environment variables.                *"
856echo "*   Source this file after configure has ended successfully.       *"
857echo "*                                                                  *"
858echo "*   Any warning that is generated during the configure process     *"
859echo "*   must be taken into account since it can be a reason for        *"
860echo "*   an unsuccessful build of OpenOffice.org                        *"
861echo "*                                                                  *"
862echo "********************************************************************"
863echo ""
864echo "********************************************************************"
865echo "*                                                                  *"
866echo "*   Checking the platform pre-requisites.                          *"
867echo "*                                                                  *"
868echo "********************************************************************"
869echo ""
870dnl ===================================================================
871dnl Configure pre-requisites.
872dnl ===================================================================
873cat /dev/null > warn
874
875AC_MSG_CHECKING([configure is up-to-date])
876if test "configure" -ot "configure.in"
877then
878   AC_MSG_ERROR([configure is not up-to-date, run autoconf first!])
879fi
880
881AC_PROG_EGREP
882AC_PROG_AWK
883AC_PATH_PROG( AWK, $AWK)
884if test -z "$AWK"; then
885   AC_MSG_ERROR([install awk to run this script])
886fi
887
888AC_PATH_PROGS(SED, sed )
889if test -z "$SED"; then
890   AC_MSG_ERROR([install sed to run this script])
891fi
892
893AC_MSG_CHECKING([for solenv environment])
894if test -z "$with_local_solenv"; then
895   LOCAL_SOLENV="DEFAULT"
896   AC_MSG_RESULT([default])
897else
898   LOCAL_SOLENV=$with_local_solenv
899   AC_MSG_RESULT([$with_local_solenv])
900fi
901AC_SUBST(LOCAL_SOLENV)
902
903if test "$LOCAL_SOLENV" = "DEFAULT"; then
904  _solenv="./solenv"
905else
906  _solenv="$LOCAL_SOLENV"
907fi
908AC_SUBST(_solenv)
909
910if test -e $_solenv/inc/minor.mk; then
911   # Get UPD number from ./solenv/inc/minor.mk
912   UPD="`grep RSCVERSION= $_solenv/inc/minor.mk | $AWK -F"=" '{ print $2 }'`"
913   AC_SUBST(UPD)
914   SOURCEVERSION="`grep SOURCEVERSION= $_solenv/inc/minor.mk | $AWK -F"=" '{ print $2 }'`"
915   AC_SUBST(SOURCEVERSION)
916else
917   AC_MSG_ERROR([$_solenv/inc/minor.mk missing but needed for architecture/os detecion and proper environment script generation...])
918fi
919
920dnl ===================================================================
921dnl Checks for the operating system and processor.
922dnl ===================================================================
923AC_CANONICAL_SYSTEM
924if test "$build" != "$host" -o "$build" != "$target" \
925  -o "$host" != "$target"; then
926	AC_MSG_WARN([cross-compiling by any means is not supported (yet)!])
927	echo "cross-compiling by any means is not supported (yet)!" >> warn
928fi
929
930if echo "$build_os" | grep cygwin; then
931   AC_MSG_CHECKING([Cygwin version])
932   CygwinVer=`uname -r`
933   AC_MSG_RESULT([$CygwinVer])
934   if test "`echo $CygwinVer | $AWK -F . '{ print $1$2 }'`" -lt "15"; then
935      AC_MSG_ERROR([You need at least Cygwin V1.5.x])
936   fi
937else
938   CygwinVer="false"
939fi
940
941dnl ===================================================================
942dnl The following is a list of supported systems.
943dnl Sequential to keep the logic very simple
944dnl These values may be checked and reset later.
945dnl ===================================================================
946case "$build_os" in
947	solaris*)
948		test_gtk=yes
949		test_cairo=yes
950		test_kde=yes
951		test_cups=yes
952        test_randr=yes
953		test_freetype=yes
954        test_gstreamer=yes
955		_os=SunOS
956		AC_PATH_PROG( GNUTAR, gtar,,$PATH:/usr/sfw/bin)
957		if test -z "$GNUTAR"; then
958			AC_MSG_ERROR([gtar (gnu tar) not found but needed. Install it (SUN Freeware package).])
959		fi
960		AC_SUBST(GNUTAR)
961
962		dnl ===========================================================
963		dnl check whether we're using solaris 6,7,8 - sparc or intel.
964		dnl ===========================================================
965   		AC_MSG_CHECKING([the Solaris operating system release])
966   		_os_release=`echo $build_os | $SED -e s/solaris2\.//`
967		if test "$_os_release" -lt "6"; then
968      			AC_MSG_ERROR([use solaris >= 6 to build OpenOffice.org])
969   		else
970      			AC_MSG_RESULT([ok ($_os_release)])
971   		fi
972
973   		dnl check whether we're using a sparc or i386 processor
974   		AC_MSG_CHECKING([the processor type])
975   		if test "$build_cpu" = "sparc" -o "$build_cpu" = "i386"; then
976      			AC_MSG_RESULT([ok ($build_cpu)])
977   		else
978      			AC_MSG_ERROR([only sparc and i386 processors are supported])
979   		fi
980		;;
981	linux-gnu*|k*bsd*-gnu*)
982		test_gtk=yes
983		test_cairo=yes
984		test_kde=yes
985		test_kde4=yes
986		test_cups=yes
987        test_randr=yes
988		test_freetype=yes
989        test_gstreamer=yes
990        _os=Linux
991		;;
992	gnu)
993		test_cups=no
994		_os=GNU
995		;;
996	cygwin*) # Windows
997		test_cups=no
998		test_cairo=yes
999		test_freetype=no
1000        test_gstreamer=no
1001		_os=WINNT
1002		;;
1003	darwin*) # Mac OS X
1004		test_cups=yes
1005		test_gtk=yes
1006		test_cairo=yes
1007        test_randr=no
1008		test_freetype=no
1009        test_gstreamer=no
1010		_os=Darwin
1011      if test "$enable_systray" = "yes" && test "$enable_gtk" != "no"; then
1012         AC_MSG_WARN([Disabling gtk-quickstarter - not supported on Mac. Use --disable-systray])
1013         echo "Disabling gtk-quickstarter - not supported on Mac. Use --disable-systray" >>warn
1014         enable_systray=no
1015      fi
1016		;;
1017	os2*)
1018		test_x=no
1019		test_cups=no
1020        test_randr=no
1021		test_gtk=no
1022		test_freetype=no
1023        test_gstreamer=no
1024		_os=OS2
1025		;;
1026	freebsd*)
1027		test_gtk=yes
1028		test_cairo=yes
1029		test_kde=yes
1030		test_kde4=yes
1031		test_cups=yes
1032        test_randr=yes
1033		test_freetype=yes
1034        test_gstreamer=yes
1035		AC_MSG_CHECKING([the FreeBSD operating system release])
1036		if test -n "$with_os_version"; then
1037			OSVERSION="$with_os_version"
1038		else
1039			OSVERSION=`/sbin/sysctl -n kern.osreldate`
1040		fi
1041		AC_MSG_RESULT([found OSVERSION=$OSVERSION])
1042		AC_MSG_CHECKING([which thread library to use])
1043		if test "$OSVERSION" -lt "500016"; then
1044			PTHREAD_CFLAGS="-D_THREAD_SAFE"
1045			PTHREAD_LIBS="-pthread"
1046		elif test "$OSVERSION" -lt "502102"; then
1047			PTHREAD_CFLAGS="-D_THREAD_SAFE"
1048			PTHREAD_LIBS="-lc_r"
1049		else
1050			PTHREAD_CFLAGS=""
1051			PTHREAD_LIBS="-pthread"
1052		fi
1053		AC_MSG_RESULT([$PTHREAD_LIBS])
1054		_os=FreeBSD
1055		;;
1056	osf)
1057		test_cups=no
1058        test_randr=no
1059		_os=OSF1
1060		;;
1061	netbsd)
1062		test_gtk=yes
1063		test_cairo=yes
1064		test_kde=yes
1065		test_kde4=yes
1066		test_cups=no
1067        test_randr=yes
1068		test_freetype=yes
1069        test_gstreamer=yes
1070		PTHREAD_CFLAGS="-pthread"
1071		PTHREAD_LIBS="-pthread -lpthread"
1072		_os=NetBSD
1073		;;
1074	aix*)
1075		test_cups=no
1076        test_randr=no
1077		test_freetype=yes
1078        test_gstreamer=yes
1079	   PTHREAD_LIBS=-pthread
1080		echo "AIX is an alpha port --- Use at own risk" >> warn
1081		_os=AIX
1082		;;
1083   *)
1084   AC_MSG_ERROR([$_os operating system is not suitable to build OpenOffice.org!])
1085   ;;
1086esac
1087
1088AC_SUBST(OSVERSION)
1089AC_SUBST(PTHREAD_CFLAGS)
1090AC_SUBST(PTHREAD_LIBS)
1091
1092
1093dnl Ensure pkg-config is initialized before any possible use
1094PKG_PROG_PKG_CONFIG
1095
1096
1097dnl ===================================================================
1098dnl Set the ENABLE_CRASHDUMP variable.
1099dnl ===================================================================
1100AC_MSG_CHECKING([whether to enable crashdump feature])
1101if test "$enable_crashdump" = "yes"; then
1102   ENABLE_CRASHDUMP="TRUE"
1103   BUILD_TYPE="$BUILD_TYPE CRASHREP"
1104   AC_MSG_RESULT([yes])
1105else
1106   ENABLE_CRASHDUMP=""
1107   AC_MSG_RESULT([no])
1108fi
1109AC_SUBST(ENABLE_CRASHDUMP)
1110
1111if test "$_os" = "WINNT"; then
1112   BUILD_TYPE="$BUILD_TYPE TWAIN"
1113fi
1114
1115if test "$_os" = "WINNT"; then
1116   dnl ===================================================================
1117   dnl Set the VC_STANDARD variable.
1118   dnl ===================================================================
1119   AC_MSG_CHECKING([whether to use the standard non-optimizing compiler])
1120   if test "$enable_cl_standard" = "" -o "$enable_cl_standard" = "no"; then
1121      VC_STANDARD=""
1122      AC_MSG_RESULT([no])
1123   else
1124      VC_STANDARD="TRUE"
1125      AC_MSG_RESULT([yes])
1126   fi
1127   AC_SUBST(VC_STANDARD)
1128fi
1129
1130dnl ===================================================================
1131dnl Set the ENABLE_WERROR variable. (Activate --enable-werror)
1132dnl ===================================================================
1133AC_MSG_CHECKING([whether to turn warnings to errors])
1134if test -n "$enable_werror" && test "$enable_werror" != "no"; then
1135   ENABLE_WERROR="TRUE"
1136   AC_MSG_RESULT([yes])
1137   AC_MSG_WARN([Turning warnings to errors has no effect in modules or])
1138   AC_MSG_WARN([on platforms where it has been disabled explicitely])
1139   echo "Turning warnings to errors has no effect in modules or on platforms where it has been disabled explicitely" >> warn
1140else
1141   ENABLE_WERROR="FALSE"
1142   AC_MSG_RESULT([no])
1143fi
1144AC_SUBST(ENABLE_WERROR)
1145
1146dnl ===================================================================
1147dnl Set the ENABLE_DEBUG variable. (Activate --enable-symbols)
1148dnl ===================================================================
1149AC_MSG_CHECKING([whether to do a debug build])
1150if test -n "$enable_debug" && test "$enable_debug" != "no"; then
1151   ENABLE_DEBUG="TRUE"
1152   if test -z "$enable_symbols"; then
1153      enable_symbols="yes"
1154   fi
1155   AC_MSG_RESULT([yes])
1156else
1157   ENABLE_DEBUG="FALSE"
1158   AC_MSG_RESULT([no])
1159fi
1160AC_SUBST(ENABLE_DEBUG)
1161
1162dnl ===================================================================
1163dnl Set the ENABLE_DBGUTIL variable
1164dnl ===================================================================
1165AC_MSG_CHECKING([whether to build with additional debug utilities])
1166if test -n "$enable_dbgutil" && test "$enable_dbgutil" != "no"; then
1167   PROEXT=""
1168   PRODUCT=""
1169   PROFULLSWITCH=""
1170   AC_MSG_RESULT([yes])
1171else
1172   PRODUCT="full"
1173   PROFULLSWITCH="product=full"
1174   PROEXT=".pro"
1175   AC_MSG_RESULT([no, full product build])
1176fi
1177AC_SUBST(PRODUCT)
1178AC_SUBST(PROFULLSWITCH)
1179AC_SUBST(PROEXT)
1180
1181dnl ===================================================================
1182dnl First setting is whether to include symbols into final build.
1183dnl ===================================================================
1184AC_MSG_CHECKING([whether to include symbols into final build])
1185if test -n "$enable_symbols" && test "$enable_symbols" != "no"; then
1186	if test "$enable_symbols" = "yes" -o "$enable_symbols" = "TRUE"; then
1187		ENABLE_SYMBOLS="TRUE"
1188		AC_MSG_RESULT([yes])
1189	else
1190		if test "$enable_symbols" = "SMALL" -o "$enable_symbols" = "small"; then
1191			ENABLE_SYMBOLS="SMALL"
1192			AC_MSG_RESULT([yes, small ones])
1193		else if test "$enable_symbols" != "no" ; then
1194			     echo enable symbols is: $enable_symbols
1195			     AC_MSG_ERROR([--enable-symbols only accepts yes, TRUE or SMALL as parameter.])
1196           	     else
1197              		     ENABLE_SYMBOLS=
1198		     fi
1199		fi
1200	fi
1201else
1202   ENABLE_SYMBOLS=
1203   AC_MSG_RESULT([no])
1204fi
1205AC_SUBST(ENABLE_SYMBOLS)
1206
1207dnl ===================================================================
1208dnl Determine if the solver is to be stripped or not.
1209dnl ===================================================================
1210AC_MSG_CHECKING([whether to strip the solver or not.])
1211if test -n "$enable_strip_solver"; then
1212   if test "$enable_strip_solver" = "yes"; then
1213      DISABLE_STRIP=
1214   else if test "$enable_strip_solver" = "no"; then
1215           DISABLE_STRIP="TRUE"
1216        else
1217           AC_MSG_ERROR([--disable-strip-solver only accepts yes or no as parameter.])
1218        fi
1219   fi
1220else
1221   if test -n "$ENABLE_SYMBOLS"; then
1222      DISABLE_STRIP="TRUE"
1223   else
1224      DISABLE_STRIP=
1225   fi
1226fi
1227AC_SUBST(DISABLE_STRIP)
1228
1229dnl ===================================================================
1230dnl Build options
1231dnl ===================================================================
1232
1233AC_MSG_CHECKING([whether to enable copyleft components])
1234if test "$enable_copyleft" != "yes"; then
1235
1236   enable_mozilla="no"
1237   enable_nss_module="no"
1238   enable_gstreamer="no"
1239   with_myspell_dicts="no"
1240
1241   DISABLE_HUNSPELL="TRUE"
1242   DISABLE_HYPHEN="TRUE"
1243   DISABLE_SAXON="TRUE"
1244
1245   BUILD_EPM="NO"
1246
1247   AC_MSG_RESULT([yes])
1248
1249else
1250
1251   DISABLE_HUNSPELL=
1252   DISABLE_HYPHEN=
1253   DISABLE_SAXON=
1254
1255   AC_MSG_RESULT([no])
1256
1257fi
1258AC_SUBST(DISABLE_HUNSPELL)
1259AC_SUBST(DISABLE_HYPHEN)
1260AC_SUBST(DISABLE_SAXON)
1261AC_SUBST(BUILD_EPM)
1262
1263
1264AC_MSG_CHECKING([whether to enable native CUPS support])
1265if test "$test_cups" = "yes" -a \( "$enable_cups" = "yes" -o "$enable_cups" = "TRUE" \) ; then
1266   ENABLE_CUPS="TRUE"
1267   AC_MSG_RESULT([yes])
1268else
1269   ENABLE_CUPS=""
1270   AC_MSG_RESULT([no])
1271fi
1272AC_SUBST(ENABLE_CUPS)
1273
1274AC_MSG_CHECKING([whether to enable fontconfig support])
1275if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a \( "$enable_fontconfig" = "yes" -o "$enable_fontconfig" = "TRUE" \); then
1276   ENABLE_FONTCONFIG="TRUE"
1277   AC_MSG_RESULT([yes])
1278else
1279   ENABLE_FONTCONFIG=""
1280   AC_MSG_RESULT([no])
1281fi
1282AC_SUBST(ENABLE_FONTCONFIG)
1283
1284dnl ===================================================================
1285dnl find external tarballs.
1286dnl ===================================================================
1287if test -z $TARFILE_LOCATION; then
1288   TARFILE_LOCATION="DEFAULT"
1289fi
1290AC_SUBST(TARFILE_LOCATION)
1291
1292if test -z "$enable_fetch_external" || test "$enable_fetch_external" = "yes" \
1293   && test -z "$with_system_libs" -a "$with_system_jars" != "no"; then
1294   DO_FETCH_TARBALLS="yes"
1295fi
1296AC_SUBST(DO_FETCH_TARBALLS)
1297
1298dnl ===================================================================
1299dnl Disable legacy binary file formats filters
1300dnl ===================================================================
1301AC_MSG_CHECKING([whether to enable filters for legacy binary file formats (StarOffice 5.2)])
1302if test "$enable_binfilter" = "yes"; then
1303   WITH_BINFILTER="YES"
1304   BUILD_TYPE="$BUILD_TYPE BINFILTER"
1305   AC_MSG_RESULT([yes])
1306else
1307   WITH_BINFILTER="NO"
1308   AC_MSG_RESULT([no])
1309fi
1310AC_SUBST(WITH_BINFILTER)
1311
1312if test "$_os" = "WINNT"; then
1313   AC_MSG_CHECKING([whether to use DirectX])
1314   ENABLE_DIRECT_DRAW=""
1315   if test "$enable_directx" = "yes" -o "$enable_directx" = "TRUE" -o "$enable_directx" = ""; then
1316      ENABLE_DIRECTX="TRUE"
1317      AC_MSG_RESULT([yes])
1318   else
1319      ENABLE_DIRECTX=""
1320      AC_MSG_RESULT([no])
1321   fi
1322   AC_SUBST(ENABLE_DIRECTX)
1323
1324   AC_MSG_CHECKING([whether to use ActiveX])
1325   if test "$enable_activex" = "yes" -o "$enable_activex" = "TRUE" -o "$enable_activex" = ""; then
1326      DISABLE_ACTIVEX=""
1327      AC_MSG_RESULT([yes])
1328   else
1329      DISABLE_ACTIVEX="TRUE"
1330      AC_MSG_RESULT([no])
1331   fi
1332   AC_SUBST(DISABLE_ACTIVEX)
1333
1334   AC_MSG_CHECKING([whether to use ATL])
1335   if test "$enable_atl" = "yes" -o "$enable_atl" = "TRUE" -o "$enable_atl" = ""; then
1336      DISABLE_ATL=""
1337      AC_MSG_RESULT([yes])
1338   else
1339      DISABLE_ATL="TRUE"
1340      AC_MSG_RESULT([no])
1341   fi
1342   AC_SUBST(DISABLE_ATL)
1343
1344fi
1345
1346dnl ===================================================================
1347dnl Disable rpath in shared libraries?
1348dnl ===================================================================
1349AC_MSG_CHECKING([whether to use RPATH in shared libraries])
1350if test "$enable_rpath" = "no"; then
1351   ENABLE_RPATH="no"
1352else
1353   ENABLE_RPATH="yes"
1354fi
1355AC_MSG_RESULT([$ENABLE_RPATH])
1356AC_SUBST(ENABLE_RPATH)
1357
1358dnl Test whether to include MySpell dictionaries
1359dnl ===================================================================
1360AC_MSG_CHECKING([whether to include MySpell dictionaries])
1361if test -z "$with_myspell_dicts" || test "$with_myspell_dicts" = "yes"; then
1362  AC_MSG_RESULT([yes])
1363  WITH_MYSPELL_DICTS=YES
1364  BUILD_TYPE="$BUILD_TYPE DICTIONARIES"
1365else
1366  AC_MSG_RESULT([no])
1367  WITH_MYSPELL_DICTS=NO
1368fi
1369AC_SUBST(WITH_MYSPELL_DICTS)
1370
1371if test "$WITH_MYSPELL_DICTS" = "NO"; then
1372  AC_MSG_CHECKING([whether to use dicts from external paths])
1373  if test -n "$with_system_dicts" -a "$with_system_dicts" = "yes"; then
1374	AC_MSG_RESULT([yes])
1375	SYSTEM_DICTS=YES
1376	AC_MSG_CHECKING([for spelling dictionary directory])
1377	if test -n "$with_external_dict_dir"; then
1378		DICT_SYSTEM_DIR=file://$with_external_dict_dir
1379	else
1380		DICT_SYSTEM_DIR=file:///usr/share/hunspell
1381	fi
1382	AC_MSG_RESULT([$DICT_SYSTEM_DIR])
1383	AC_MSG_CHECKING([for hyphenation patterns directory])
1384	if test -n "$with_external_hyph_dir"; then
1385		HYPH_SYSTEM_DIR=file://$with_external_hyph_dir
1386	else
1387		HYPH_SYSTEM_DIR=file:///usr/share/hyphen
1388	fi
1389	AC_MSG_RESULT([$HYPH_SYSTEM_DIR])
1390	AC_MSG_CHECKING([for thesaurus directory])
1391	if test -n "$with_external_thes_dir"; then
1392		THES_SYSTEM_DIR=file://$with_external_thes_dir
1393	else
1394		THES_SYSTEM_DIR=file:///usr/share/mythes
1395	fi
1396	AC_MSG_RESULT([$THES_SYSTEM_DIR])
1397  else
1398  	AC_MSG_RESULT([no])
1399  	SYSTEM_DICTS=NO
1400  fi
1401fi
1402AC_SUBST(SYSTEM_DICTS)
1403AC_SUBST(DICT_SYSTEM_DIR)
1404AC_SUBST(HYPH_SYSTEM_DIR)
1405AC_SUBST(THES_SYSTEM_DIR)
1406
1407if test $_os = "WINNT"; then
1408   AC_MSG_CHECKING([Windows build environment sanity])
1409   dnl ===================================================================
1410   dnl Sanity check! Native windows programs cannot use cygwin symlinks!
1411   dnl ===================================================================
1412   dnl As long as awk instead of $AWK is used somewhere in the sources,
1413   dnl check for $AWK and awk. $AWK is pointing to gawk in cygwin.
1414      if test -L $AWK -o -L `which awk` -o -L `which tar` -o -L `which gunzip` ; then
1415         AC_MSG_ERROR([$AWK, awk, tar or gunzip is a cygwin symlink!
1416Native windows programs cannot use cygwin symlinks. Remove the symbolic
1417link, and copy the program to the name of the link.])
1418      fi
1419   dnl ===================================================================
1420   dnl Another sanity check! More a band-aid. winenv.* adds guw.exe to
1421   dnl CC and CXX but the configure checks here assume that guw.exe
1422   dnl (if needed at all) is not yet present.
1423   dnl ===================================================================
1424   CC=`echo $CC | $SED "s/^guw.exe //"`
1425   CXX=`echo $CXX | $SED "s/^guw.exe //"`
1426   dnl ===================================================================
1427   dnl If $CC is set to a MinGW compiler, e.g. "gcc -mno-cygwin" enable
1428   dnl $WITH_MINGWIN
1429   dnl ===================================================================
1430      if test -n "$CC";then
1431         if test "`$CC -dumpmachine 2>/dev/null | $SED -e 's/^.*-//'`" = "mingw32"; then
1432            WITH_MINGWIN="yes"
1433         fi
1434      fi
1435   dnl ===================================================================
1436   if test "$WITH_MINGWIN" = "yes" ; then
1437      if test -z "$CC"; then
1438         CC="gcc -mno-cygwin"
1439         CXX="g++ -mno-cygwin"
1440      fi
1441   fi
1442   AC_MSG_RESULT([ok])
1443fi
1444AC_SUBST(WITH_MINGWIN)
1445
1446dnl ===================================================================
1447dnl Extra check for Windows. cygwin builds need gcc to build dmake
1448dnl and g++ to build guw.exe although MS cl (or MinGW) is used to
1449dnl build OOo.
1450dnl ===================================================================
1451if test "$_os" = "WINNT" ; then
1452   AC_MSG_CHECKING([for cygwin gcc/g++])
1453   if which gcc > /dev/null && which g++ > /dev/null ; then
1454      AC_MSG_RESULT([found])
1455   else
1456      AC_MSG_ERROR([cygwin gcc and g++ are needed, please install them.])
1457   fi
1458fi
1459
1460
1461dnl ===================================================================
1462dnl Check whether the bash shell can be used.
1463dnl ===================================================================
1464AC_PATH_PROG(SHELLPATH, bash)
1465if test -z "$SHELLPATH"; then
1466   AC_MSG_ERROR([bash not found in \$PATH])
1467else
1468   SHELLPATH=`echo $SHELLPATH | $SED -n "s/\/bash$//p"`
1469fi
1470AC_SUBST(SHELLPATH)
1471
1472dnl ===================================================================
1473dnl  Checks for c compiler,
1474dnl  The check for the c++ compiler is later on.
1475dnl ===================================================================
1476AC_MSG_CHECKING([gcc home])
1477if test -z "$with_gcc_home"; then
1478	GCC_HOME=`which gcc | $SED -e s,/bin/gcc,,`
1479else
1480	GCC_HOME="$with_gcc_home"
1481fi
1482AC_MSG_RESULT($GCC_HOME)
1483AC_SUBST(GCC_HOME)
1484
1485save_CC=$CC
1486save_CXX=$CXX
1487
1488if test -n "$with_gcc_home"; then
1489   if test -z "$CC"; then
1490      CC="$with_gcc_home/bin/gcc"
1491   fi
1492fi
1493
1494dnl The following checks for gcc, cc and then cl (if it weren't guarded for win32)
1495if test "$_os" != "WINNT" -o "$WITH_MINGWIN" = "yes"; then
1496   AC_PROG_CC
1497fi
1498
1499COMPATH=`dirname "$CC"`
1500if test "$COMPATH" = "." ; then
1501    AC_PATH_PROGS(COMPATH, $CC)
1502    dnl double square bracket to get single because of M4 quote...
1503    COMPATH=`echo $COMPATH | $SED "s@/[[^/:]]*\\\$@@"`;
1504fi
1505COMPATH=`echo $COMPATH | $SED "s@/[[Bb]][[Ii]][[Nn]]\\\$@@"`;
1506
1507dnl ===================================================================
1508dnl  Test the gcc version,  3 is OK
1509dnl ===================================================================
1510GCCVER=20995
1511if test \( "$_os" != "WINNT" -o "$WITH_MINGWIN" = "yes" \) -a "$GCC" = "yes"; then
1512    AC_MSG_CHECKING([the GNU gcc compiler version])
1513   _gcc_version=`$CC -dumpversion`
1514   _gcc_major=`echo $_gcc_version | $AWK -F. '{ print \$1 }'`
1515   GCCVER=`echo $_gcc_version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
1516
1517   if test "$_gcc_major" -lt "3"; then
1518      AC_MSG_ERROR([found version "$_gcc_version", use version 3+ of the gcc compiler])
1519   else
1520      if test "$GCCVER" -eq "030203"; then
1521	    if test "$ENABLE_SYMBOLS" = "SMALL"; then
1522           AC_MSG_ERROR([version "$_gcc_version" gives internal error with small.])
1523	    fi
1524      fi
1525   fi
1526   if test "$_os" = "Darwin" -a "$GCCVER" -ge "040100" ; then
1527      if test -z "$save_CC" -a -x "$GCC_HOME/bin/gcc-4.0" ; then
1528         export CC=$GCC_HOME/bin/gcc-4.0
1529          dnl  export CC to have it available in set_soenv -> config.guess
1530         GCCVER2=`"$CC" -dumpversion | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
1531         if test "$GCCVER2" -ge "040000" -a "$GCCVER2" -lt "040100" ; then
1532            GCCVER=$GCCVER2
1533         fi
1534      fi
1535      if test "$GCCVER" -ge "040100" ; then
1536         AC_MSG_ERROR([You need to use the gcc-4.0 compiler (gcc $_gcc_version won't work with the MacOSX10.4u.sdk) - set CC accordingly])
1537      else
1538         AC_MSG_RESULT([implicitly using CC=$CC])
1539      fi
1540   else
1541      AC_MSG_RESULT([checked (gcc $_gcc_version)])
1542   fi
1543   if test "$_os" = "SunOS"; then
1544      AC_MSG_CHECKING([gcc linker])
1545      if $CC -Wl,--version 2>&1 |head -n 1| grep -v GNU > /dev/null;then
1546          AC_MSG_ERROR([failed (not GNU ld). Use GNU ld instead of Sun ld on Solaris])
1547      fi
1548      AC_MSG_RESULT([ok (GNU ld)])
1549   fi
1550fi
1551AC_SUBST(GCCVER)
1552
1553HAVE_LD_BSYMBOLIC_FUNCTIONS=
1554if test "$GCC" = "yes"; then
1555   AC_MSG_CHECKING( for -Bsymbolic-functions linker support )
1556   bsymbolic_functions_ldflags_save=$LDFLAGS
1557   LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions -Wl,--dynamic-list-cpp-new -Wl,--dynamic-list-cpp-typeinfo"
1558   AC_LINK_IFELSE([AC_LANG_PROGRAM([
1559   #include <stdio.h>
1560   ],[
1561    printf ("hello world\n");
1562   ])], HAVE_LD_BSYMBOLIC_FUNCTIONS=TRUE, [])
1563   if test "z$HAVE_LD_BSYMBOLIC_FUNCTIONS" = "zTRUE"; then
1564     AC_MSG_RESULT( found )
1565   else
1566     AC_MSG_RESULT( not found )
1567   fi
1568   LDFLAGS=$bsymbolic_functions_ldflags_save
1569fi
1570AC_SUBST(HAVE_LD_BSYMBOLIC_FUNCTIONS)
1571
1572dnl ===================================================================
1573dnl Set the ENABLE_PCH variable. (Activate --enable-pch)
1574dnl ===================================================================
1575AC_MSG_CHECKING([whether to enable pch feature])
1576if test -n "$enable_pch" && test "$enable_pch" != "no"; then
1577   if test "$_os" = "WINNT" -a "$WITH_MINGWIN" != "yes"; then
1578	   ENABLE_PCH="TRUE"
1579	   AC_MSG_RESULT([yes])
1580dnl There is no PCH support in GCC versions prior to this
1581   elif test "$GCC" = "yes" -a "$GCCVER" -gt "030400"; then
1582	   ENABLE_PCH="TRUE"
1583	   AC_MSG_RESULT([yes])
1584   else
1585	   ENABLE_PCH=""
1586	   AC_MSG_WARN([Precompiled header not yet supported for your platform/compiler])
1587   fi
1588else
1589   ENABLE_PCH=""
1590   AC_MSG_RESULT([no])
1591fi
1592AC_SUBST(ENABLE_PCH)
1593
1594dnl ===================================================================
1595dnl Search all the common names for GNU make
1596dnl ===================================================================
1597AC_MSG_CHECKING([for GNU make])
1598for a in "$MAKE" $GNUMAKE make gmake gnumake; do
1599      $a --version 2> /dev/null | grep GNU  2>&1 > /dev/null
1600      if test $? -eq 0;  then
1601           GNUMAKE=$a
1602           break
1603      fi
1604done
1605AC_MSG_RESULT($GNUMAKE)
1606if test -z "$GNUMAKE"; then
1607    AC_MSG_ERROR([not found. install GNU make.])
1608fi
1609
1610AC_MSG_CHECKING([the GNU make version])
1611_make_version=`$GNUMAKE --version | grep GNU | $SED -e 's@^[[^0-9]]*@@' -e 's@ .*@@' -e 's@,.*@@'`;
1612_make_longver=`echo $_make_version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
1613if test "$_make_longver" -ge "038100" ; then
1614   AC_MSG_RESULT([$GNUMAKE $_make_version])
1615else
1616   AC_MSG_ERROR([failed ($GNUMAKE version >= 3.81 needed])
1617fi
1618AC_SUBST(GNUMAKE)
1619
1620dnl ===================================================================
1621dnl Search all the common names for GNU or BSD tar
1622dnl ===================================================================
1623AC_MSG_CHECKING([for GNU or BSD compatible tar])
1624for a in $GNUTAR gtar gnutar bsdtar tar; do
1625      $a --version 2> /dev/null | egrep "GNU|libarchive"  2>&1 > /dev/null
1626      if test $? -eq 0;  then
1627           GNUTAR=$a
1628           break
1629      fi
1630done
1631AC_MSG_RESULT($GNUTAR)
1632if test -z "$GNUTAR"; then
1633    AC_MSG_ERROR([not found. install GNU tar.])
1634fi
1635
1636AC_SUBST(GNUTAR)
1637
1638dnl ===================================================================
1639dnl  Test the solaris compiler version
1640dnl ===================================================================
1641if test "$_os" = "SunOS"; then
1642   if test "$CC" = "cc"; then
1643      AC_PATH_PROGS(_cc, cc)
1644      COMPATH=`echo $_cc | $SED -n "s/\/bin\/cc//p"`
1645      AC_MSG_CHECKING([the SunStudio C/C++ compiler version])
1646      dnl cc -V outputs to standard error!!!!
1647      _sunstudio_string=`$CC -V 2>&1 | grep '^cc' | sed -e 's/.* C //'`
1648      _sunstudio_version=`echo $_sunstudio_string | $AWK '{ print $1 }'`
1649      _sunstudio_major=`echo $_sunstudio_version | $AWK -F. '{ print $1 }'`
1650      if test "$_sunstudio_major" != "5"; then
1651         AC_MSG_ERROR([found version "$_sunstudio_version", use version 5.5, 5.7, 5.8 or 5.9 of the SunStudio C/C++ compiler])
1652      else
1653         _sunstudio_minor=`echo $_sunstudio_version | $AWK -F. '{ if ($2 == 5) print "true"; else if ($2 == 7) print "true"; else if ($2 == 8) print "true"; else if ($2 == 9) print "true"; else print "false" }'`
1654         if test "$_sunstudio_minor" = "false"; then
1655            AC_MSG_ERROR([found version "$_sunstudio_version", use version 5.5, 5.7, 5.8 or 5.9 of the SunStudio C/C++ compiler])
1656         else
1657            dnl compiler will do
1658            AC_MSG_RESULT([checked])
1659         fi
1660      fi
1661   fi
1662fi
1663
1664if test "$GCC" = "yes"; then
1665   AC_MSG_CHECKING( for --hash-style=both linker support )
1666   hash_style_ldflags_save=$LDFLAGS
1667   LDFLAGS="$LDFLAGS -Wl,--hash-style=both"
1668   AC_LINK_IFELSE([AC_LANG_PROGRAM([
1669   #include <stdio.h>
1670   ],[
1671    printf ("hello world\n");
1672   ])], HAVE_LD_HASH_STYLE=TRUE, HAVE_LD_HASH_STYLE=FALSE)
1673   if test "z$HAVE_LD_HASH_STYLE" = "zTRUE"; then
1674     AC_MSG_RESULT( found )
1675   else
1676     AC_MSG_RESULT( not found )
1677   fi
1678   LDFLAGS=$hash_style_ldflags_save
1679fi
1680AC_SUBST(HAVE_LD_HASH_STYLE)
1681
1682dnl ===================================================================
1683dnl  Test the Compaq compiler for OSF1
1684dnl ===================================================================
1685if test "$_os" = "OSF1"; then
1686   if test "$CC" = "cc"; then
1687      AC_PATH_PROGS(_cc, cc)
1688      COMPATH=`echo $_cc | $SED -n "s/\/bin\/cc//p"`
1689      AC_MSG_WARN([******* $_cc , $COMPATH])
1690      AC_MSG_CHECKING([the Compaq C compiler version])
1691      dnl cc -V outputs to standard error!!!!
1692      _compaqc_version=`$CC -V 2>&1 | $AWK '{ print $3 }'`
1693      _compaqc_major=`echo $_compaqc_version | $AWK -F. '{ print $1 }'`
1694      if test "$_compaqc_major" != "T6"; then
1695         AC_MSG_ERROR([found version "$_compaqc_version", use version 6 of the Compaq C compiler])
1696      else
1697         dnl compiler will do
1698         AC_MSG_RESULT([checked])
1699      fi
1700   fi
1701fi
1702
1703dnl ===================================================================
1704dnl Check whether there's a Perl version available.
1705dnl ===================================================================
1706if test -z "$with_perl_home"; then
1707   AC_PATH_PROG(PERL, perl)
1708else
1709   if test "$_os" = "WINNT"; then
1710      with_perl_home=`cygpath -u "$with_perl_home"`
1711   fi
1712   _perl_path="$with_perl_home/bin/perl"
1713   if test -x "$_perl_path"; then
1714      PERL=$_perl_path
1715   else
1716      AC_MSG_ERROR([$_perl_path not found])
1717   fi
1718fi
1719
1720dnl ===================================================================
1721dnl Testing for Perl version 5 or greater.
1722dnl $] is the perl version variable, it is returned as an integer
1723dnl ===================================================================
1724if test "$PERL"; then
1725   AC_MSG_CHECKING([the Perl version])
1726   ${PERL} -e "exit($]);"
1727   _perl_version=$?
1728   if test "$_perl_version" -lt 5; then
1729      AC_MSG_ERROR([found Perl version "$_perl_version", use version 5 of Perl])
1730   fi
1731   AC_MSG_RESULT([checked (perl $_perl_version)])
1732else
1733   AC_MSG_ERROR([Perl not found, install version 5 of Perl])
1734fi
1735AC_SUBST(PERL)
1736
1737dnl ===================================================================
1738dnl Testing for required Perl modules
1739dnl ===================================================================
1740AC_MSG_CHECKING([for required Perl modules])
1741if `$PERL -e 'use Archive::Zip;'`; then
1742	AC_MSG_RESULT([all modules found])
1743else
1744	AC_MSG_ERROR([Failed to find some modules])
1745fi
1746
1747dnl ===================================================================
1748dnl  Check which Microsoft C/C++ or MinGW compiler is used for WINNT
1749dnl ===================================================================
1750if test "$_os" = "WINNT"; then
1751	if test "$WITH_MINGWIN" != "yes"; then
1752		AC_MSG_CHECKING([for friendly registry keys])
1753		# VS.Net 2003, VS.Net 2005
1754		if test -z "$with_cl_home"; then
1755			vctest=`./oowintool --msvc-productdir`;
1756			if test -x "$vctest/bin/cl.exe"; then
1757				with_cl_home=$vctest;
1758			fi
1759		else
1760			with_cl_home=`cygpath -u "$with_cl_home"`
1761		fi
1762		AC_MSG_RESULT([done])
1763
1764		dnl ===========================================================
1765		dnl  Check for mspdb71.dll/mspdb80.dll
1766		dnl ===========================================================
1767		dnl  .NET 2003/5/8 Compiler
1768		if test -n "$with_mspdb_path";then
1769			with_mspdb_path=`cygpath -u "$with_mspdb_path"`
1770		fi
1771		if test -e "$with_mspdb_path/mspdb71.dll" -o -e "$with_mspdb_path/mspdb80.dll"; then
1772			MSPDB_PATH="$with_mspdb_path"
1773		fi
1774		dnl .NET 2003 case
1775		if test -z "$MSPDB_PATH" -a -e "$with_cl_home/../Common7/IDE/mspdb71.dll"; then
1776			MSPDB_PATH="$with_cl_home/../Common7/IDE"
1777		fi
1778		dnl .NET 2005/2008 case
1779		if test -z "$MSPDB_PATH" -a -e "$with_cl_home/../Common7/IDE/mspdb80.dll"; then
1780			MSPDB_PATH="$with_cl_home/../Common7/IDE"
1781		fi
1782		dnl Windows SDK 6.0 case
1783		if test -z "$MSPDB_PATH" -a -e "$with_cl_home/bin/mspdb80.dll"; then
1784			MSPDB_PATH="$with_cl_home/bin"
1785		fi
1786
1787		if test -z "$MSPDB_PATH";then
1788			dnl AC_PATH_PROG only checks if MSPDB_PATH is still empty
1789			AC_PATH_PROG(MSPDB_PATH, mspdb80.dll)
1790			AC_PATH_PROG(MSPDB_PATH, mspdb71.dll)
1791			MSPDB_PATH=`dirname "$MSPDB_PATH"`
1792		fi
1793
1794		if test -z "$MSPDB_PATH"; then
1795			AC_MSG_ERROR([You need a mspdb71.dll/mspdb80.dll, make sure it's in the path or use --with-mspdb-path])
1796		fi
1797		MSPDB_PATH=`cygpath -d "$MSPDB_PATH"`
1798		MSPDB_PATH=`cygpath -u "$MSPDB_PATH"`
1799		dnl The path needs to be added before cl is called
1800		PATH="$MSPDB_PATH:$PATH"
1801
1802		AC_MSG_CHECKING([the Microsoft C/C++ Compiler])
1803   		if test -x "$with_cl_home/bin/cl.exe"; then
1804   			CC="$with_cl_home/bin/cl.exe"
1805   		else
1806   			AC_PATH_PROG(CC, cl.exe)
1807   		fi
1808  		if test -e "$CC"; then
1809			# This gives us a posix path with 8.3 filename restrictions
1810			CC=`cygpath -d "$CC"`
1811			CC=`cygpath -u "$CC"`
1812			# Remove /cl.exe from CC case insensitive
1813			AC_MSG_RESULT([found ($CC)])
1814			COMPATH=`echo $CC | $SED 's@\/[[Bb]][[Ii]][[Nn]]\/[[cC]][[lL]]\.[[eE]][[xX]][[eE]]@@'`
1815			export INCLUDE=`cygpath -d "$COMPATH/Include"`
1816			dnl  Check which Microsoft C/C++ compiler is found
1817			AC_MSG_CHECKING([the Version of Microsoft C/C++ Compiler])
1818dnl      The following find microsoft, matches nn.nn.nnnn then pulls numbers out.
1819			CCNUMVER=`$CC 2>&1 | $AWK "/Microsoft/ && /..\\...\\...../ {
1820							x = match( \\\$0, /..\\...\\...../ )
1821							CCversion = substr( \\\$0, RSTART, RLENGTH)
1822							tokencount = split (CCversion,vertoken,\".\")
1823							for ( i = 1 ; i <= tokencount ; i++ ) {
1824								printf (\"%04d\",vertoken[[i]] )
1825							}
1826							}"`
1827			AC_MSG_RESULT([found Compiler version $CCNUMVER.])
1828			if test "$CCNUMVER" -ge "001500000000"; then
1829				COMEX=12
1830				MSVSVER=2008
1831				AC_MSG_RESULT([found .NET 2008 / VS 9.0.])
1832			elif test "$CCNUMVER" -ge "001400000000"; then
1833				COMEX=11
1834				MSVSVER=2005
1835				AC_MSG_RESULT([found .NET 2005.])
1836			elif test "$CCNUMVER" -ge "001300102240"; then
1837				COMEX=10
1838				MSVSVER=2003
1839				AC_MSG_RESULT([found .NET 2003.])
1840			else
1841				AC_MSG_ERROR([Compiler too old. Use Microsoft C/C++ .NET 2003/2005 compiler.])
1842			fi
1843		else
1844			AC_MSG_ERROR([Microsoft C/C++ Compiler not found. Use --with-cl-home or set path to cl.exe.])
1845		fi
1846	else
1847		AC_MSG_CHECKING([the Mingwin32 C++ Compiler])
1848		if test `$CC -dumpmachine | $SED -e 's/^.*-//'` = "mingw32"; then
1849			AC_MSG_RESULT([found.])
1850			if $CC -dumpspecs | grep -q "mno-cygwin"; then
1851				USE_MINGW="cygwin"
1852			else
1853				USE_MINGW="pure-mingw"
1854			fi
1855		else
1856			AC_MSG_ERROR([Mingwin32 C++ Compiler not found.])
1857		fi
1858	fi
1859fi
1860AC_SUBST(COMEX)
1861AC_SUBST(MSPDB_PATH)
1862AC_SUBST(USE_MINGW)
1863
1864dnl ===================================================================
1865dnl  .NET needs special treatment
1866dnl ===================================================================
1867if test "$_os" = "WINNT"; then
1868if test "$WITH_MINGWIN" = "yes" || test "$COMEX" -ge "10"; then
1869	dnl Check midl.exe
1870	AC_PATH_PROG(MIDL_PATH, midl.exe)
1871	if test -n "$MIDL_PATH";then
1872		MIDL_PATH=`dirname "$MIDL_PATH"`
1873	fi
1874	if test -n "$with_midl_path";then
1875		with_midl_path=`cygpath -u "$with_midl_path"`
1876	fi
1877	if test -x "$with_midl_path/midl.exe"; then
1878		MIDL_PATH="$with_midl_path"
1879	fi
1880	if test -z "$MIDL_PATH" -a -e "$with_cl_home/../Common7/Tools/Bin/midl.exe"; then
1881		MIDL_PATH="$with_cl_home/../Common7/Tools/Bin"
1882	fi
1883	if test -z "$MIDL_PATH" ; then
1884      vstest=`./oowintool --msvs-productdir`;
1885      if test -x "$vstest/Common7/Tools/Bin/midl.exe" ; then
1886		  MIDL_PATH="$vstest/Common7/Tools/Bin"
1887      fi
1888	fi
1889	if test -z "$MIDL_PATH" ; then
1890		psdktest=`./oowintool --psdk-home`
1891		if test -x "$psdktest/Bin/midl.exe" ; then
1892			MIDL_PATH="$psdktest/Bin"
1893		fi
1894	fi
1895	if test ! -x "$MIDL_PATH/midl.exe"; then
1896		AC_MSG_ERROR([midl.exe not found. Make sure it's in the path or use --with-midl-path])
1897	fi
1898	# Convert to posix path with 8.3 filename restrictions ( No spaces )
1899	MIDL_PATH=`cygpath -d "$MIDL_PATH"`
1900	MIDL_PATH=`cygpath -u "$MIDL_PATH"`
1901
1902	dnl Check csc.exe
1903	AC_PATH_PROG(CSC_PATH, csc.exe)
1904	if test -n "$CSC_PATH";then
1905		CSC_PATH=`dirname "$CSC_PATH"`
1906	fi
1907	if test -n "$with_csc_path";then
1908		with_csc_path=`cygpath -u "$with_csc_path"`
1909	fi
1910	if test -x "$with_csc_path/csc.exe"; then
1911		CSC_PATH="$with_csc_path"
1912	else
1913	   csctest=`./oowintool --csc-compilerdir`;
1914	   if test -x "$csctest/csc.exe"; then
1915	      CSC_PATH="$csctest"
1916	   fi
1917	fi
1918	if test ! -x "$CSC_PATH/csc.exe"; then
1919		AC_MSG_ERROR([csc.exe not found. Make sure it's in the path or use --with-csc-path])
1920	fi
1921	# Convert to posix path with 8.3 filename restrictions ( No spaces )
1922	CSC_PATH=`cygpath -d "$CSC_PATH"`
1923	CSC_PATH=`cygpath -u "$CSC_PATH"`
1924
1925    dnl Check mscoree.lib / .NET Frameworks dir
1926    dnl For VS2003/2005 $with_frame_home has to point to the directory with lib/mscoree.lib.
1927       AC_MSG_CHECKING(.NET Framework)
1928	    if test -n "$with_frame_home"; then
1929		with_frame_home=`cygpath -u "$with_frame_home"`
1930	    fi
1931	    if test -f "$with_frame_home/lib/mscoree.lib"; then
1932		    FRAME_HOME="$with_frame_home"
1933	    fi
1934	    if test -z "$FRAME_HOME" -a -e "$with_cl_home/../SDK/v1.1/lib/mscoree.lib"; then
1935		    FRAME_HOME="$with_cl_home/../SDK/v1.1"
1936	    fi
1937	    if test -z "$FRAME_HOME" ; then
1938          frametest=`./oowintool --dotnetsdk-dir`
1939          if test -f "$frametest/lib/mscoree.lib"; then
1940             FRAME_HOME="$frametest"
1941          else
1942             frametest=`./oowintool --psdk-home`
1943             if test -f "$frametest/lib/mscoree.lib"; then
1944                FRAME_HOME="$frametest"
1945             fi
1946          fi
1947	    fi
1948	    if test ! -f "$FRAME_HOME/lib/mscoree.lib"; then
1949		AC_MSG_ERROR([mscoree.lib (.NET Framework) not found. Make sure you use --with-frame-home])
1950	    fi
1951	    AC_MSG_RESULT(found)
1952	# Convert to posix path with 8.3 filename restrictions ( No spaces )
1953	FRAME_HOME=`cygpath -d "$FRAME_HOME"`
1954	FRAME_HOME=`cygpath -u "$FRAME_HOME"`
1955fi
1956AC_SUBST(MIDL_PATH)
1957AC_SUBST(CSC_PATH)
1958AC_SUBST(FRAME_HOME)
1959fi
1960
1961dnl ===================================================================
1962dnl Check if stdc headers are available excluding windows.
1963dnl ===================================================================
1964if test "$_os" != "WINNT" -o "$WITH_MINGWIN" = "yes"; then
1965   AC_HEADER_STDC
1966fi
1967
1968dnl ===================================================================
1969dnl Find pre-processors.
1970dnl ===================================================================
1971if test "$_os" != "WINNT" -o "$WITH_MINGWIN" = "yes"; then
1972   AC_PROG_CXXCPP
1973
1974dnl Check whether there's a C pre-processor.
1975dnl ===================================================================
1976dnl When using SunStudio compiler, there is a bug with the cc
1977dnl preprocessor, so use CC preprocessor as the cc preprocessor
1978dnl See Issuezilla #445.
1979dnl ===================================================================
1980   if test "$_os" = "SunOS"; then
1981      CPP=$CXXCPP
1982   else
1983      AC_PROG_CPP
1984   fi
1985fi
1986
1987AC_CHECK_SIZEOF(long)
1988SIZEOF_LONG=$ac_cv_sizeof_long
1989AC_SUBST(SIZEOF_LONG)
1990AC_C_BIGENDIAN
1991WORDS_BIGENDIAN=$ac_cv_c_bigendian
1992AC_SUBST(WORDS_BIGENDIAN)
1993
1994dnl Check for large file support
1995AC_SYS_LARGEFILE
1996if test -n "$ac_cv_sys_file_offset_bits"; then
1997   LFS_CFLAGS="-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
1998fi
1999if test -n "$ac_cv_sys_large_files" && test "$ac_cv_sys_large_files" != "no"; then
2000   LFS_CFLAGS="$LFS_CFLAGS -D_LARGE_FILES"
2001fi
2002AC_SUBST(LFS_CFLAGS)
2003
2004dnl ===================================================================
2005dnl Check if valgrind.h is available
2006dnl ===================================================================
2007if test -n "$enable_dbgutil" && test "$enable_dbgutil" != "no"; then
2008   dnl Test $prefix (currently only testing for /usr and /usr/local)
2009   dnl so that VALGRIND_CFLAGS = -I$prefix/include/valgrind
2010   VALGRIND_CFLAGS=""
2011   prev_cppflags=$CPPFLAGS
2012   if test -z "$VALGRIND_CFLAGS"; then
2013      CPPFLAGS="-I/usr/include/valgrind"
2014      AC_CHECK_HEADER([valgrind.h], [VALGRIND_CFLAGS=$CPPFLAGS], [unset ac_cv_header_valgrind_h])
2015   fi
2016   if test -z "$VALGRIND_CFLAGS"; then
2017      CPPFLAGS="-I/usr/local/include/valgrind"
2018      AC_CHECK_HEADER([valgrind.h], [VALGRIND_CFLAGS=$CPPFLAGS], [])
2019   fi
2020   if test -n "$VALGRIND_CFLAGS"; then
2021      CPPFLAGS=$VALGRIND_CFLAGS
2022      AC_CHECK_HEADER([memcheck.h], [], [VALGRIND_CFLAGS=""])
2023   fi
2024   CPPFLAGS=$prev_cppflags
2025fi
2026AC_SUBST([VALGRIND_CFLAGS])
2027
2028dnl ===================================================================
2029dnl Check if cups/cups.h is available
2030dnl ===================================================================
2031if test "$test_cups" = "yes" -a "$ENABLE_CUPS" = "TRUE" ; then
2032    AC_CHECK_HEADER(cups/cups.h, [],
2033                    [AC_MSG_ERROR([cups/cups.h could not be found. libcupsys2-dev or cups???-devel missing?])], [])
2034fi
2035
2036dnl ===================================================================
2037dnl Check if PAM/pam_appl.h is available on Linux or FreeBSD
2038dnl ===================================================================
2039if test "$_os" = "Linux" -o "$_os" = "FreeBSD" -o "$_os" = "GNU"; then
2040  AC_MSG_CHECKING([whether to enable pam support])
2041  if test -z "$enable_pam" || test "$enable_pam" != "no"; then
2042    AC_MSG_RESULT([yes])
2043    PAM=YES
2044    AC_CHECK_HEADER(security/pam_appl.h, [],
2045                    [AC_MSG_ERROR([pam_appl.h could not be found. libpam-dev or pam-devel missing?])], [])
2046    AC_MSG_CHECKING([whether to link to libpam])
2047    if test -n "$enable_pam_link" -a "$enable_pam_link" != "no"; then
2048      AC_MSG_RESULT([yes])
2049      PAM_LINK=YES
2050      AC_CHECK_LIB(pam, pam_start, [],
2051          [AC_MSG_ERROR(libpam not found or functional)], [])
2052    else
2053      AC_MSG_RESULT([no, dynamically open it])
2054      PAM_LINK=NO
2055    fi
2056  else
2057    AC_MSG_RESULT([no])
2058    PAM=NO
2059    PAM_LINK=NO
2060    dnl check getspnam_r for needed args (4 or 5)
2061    AX_FUNC_WHICH_GETSPNAM_R
2062  fi
2063fi
2064AC_SUBST(PAM)
2065AC_SUBST(NEW_SHADOW_API)
2066AC_SUBST(PAM_LINK)
2067
2068if test "$_os" = "Linux"; then
2069    AC_MSG_CHECKING([whether to link to libcrypt])
2070    if test -n "$enable_crypt_link" -a "$enable_crypt_link" != "no"; then
2071        AC_MSG_RESULT([yes])
2072        CRYPT_LINK=YES
2073        AC_CHECK_LIB(crypt, crypt, [],
2074            [AC_MSG_ERROR(libcrypt not found or functional)], [])
2075    else
2076        AC_MSG_RESULT([no, dynamically open it])
2077        CRYPT_LINK=NO
2078    fi
2079fi
2080AC_SUBST(CRYPT_LINK)
2081
2082dnl ===================================================================
2083dnl Testing for c++ compiler and version...
2084dnl ===================================================================
2085if test -n "$with_gcc_home"; then
2086   if test -z "$CXX"; then
2087      CXX="$with_gcc_home/bin/g++"
2088   fi
2089fi
2090
2091if test "$_os" = "WINNT" -a "$WITH_MINGWIN" != "yes"; then
2092   if test -e "$CC"; then
2093      CXX="$CC"
2094   fi
2095fi
2096
2097dnl Autoconf 2.53 can do this test for cl.exe, 2.13 can't!
2098if test "$_os" != "WINNT" -o "$WITH_MINGWIN" = "yes"; then
2099   AC_PROG_CXX
2100fi
2101
2102dnl check if we are using a buggy version of g++ (currently 3.4.0, 3.4.1 and trunk)
2103if test "$GXX" = "yes"; then
2104   AC_MSG_CHECKING([the GNU C++ compiler version])
2105
2106   _gpp_version=`$CXX -dumpversion`
2107   _gpp_majmin=`echo $_gpp_version | $AWK -F. '{ print \$1*100+\$2 }'`
2108
2109   if test "$_os" = "Darwin" -a "$_gpp_majmin" -ge "401" ; then
2110      if test -z "$save_CXX" -a -x "$GCC_HOME/bin/g++-4.0" ; then
2111         CXX=$GCC_HOME/bin/g++-4.0
2112         _gpp_majmin_2=`"$CXX" -dumpversion | $AWK -F. '{ print \$1*100+\$2 }'`
2113         if test "$_gpp_majmin_2" -ge "400" -a "$_gpp_majmin_2" -lt "401" ; then
2114            _gpp_majmin=$_gpp_majmin_2
2115         fi
2116      fi
2117      if test "$_gpp_majmin" -ge "401" ; then
2118         AC_MSG_ERROR([You need to use the g++-4.0 compiler (g++ $_gpp_version won't work with the MacOSX10.4u.sdk) - set CXX accordingly])
2119      else
2120         AC_MSG_RESULT([implicitly using CXX=$CXX])
2121      fi
2122   else
2123      AC_MSG_RESULT([checked (g++ $_gpp_version)])
2124   fi
2125
2126   if test "$_gpp_majmin" = "304"; then
2127      AC_MSG_CHECKING([whether $CXX has the enum bug])
2128AC_TRY_RUN([
2129extern "C" void abort (void);
2130extern "C" void exit (int status);
2131
2132enum E { E0, E1, E2, E3, E4, E5 };
2133
2134void
2135test (enum E e)
2136{
2137  if (e == E2 || e == E3 || e == E1)
2138  exit (1);
2139}
2140
2141int
2142main (void)
2143{
2144  test (E4);
2145  test (E5);
2146  test (E0);
2147  return 0;
2148}
2149],[AC_MSG_ERROR([your version of the GNU C++ compile has a bug which prevents OpenOffice.org from being compiled correctly - please check http://gcc.gnu.org/ml/gcc-patches/2004-07/msg00968.html for details.])], [AC_MSG_RESULT([no])])
2150   fi
2151fi
2152
2153dnl ===================================================================
2154dnl Set the gcc/gxx include directories
2155dnl ===================================================================
2156# Removed the special FreeBSD treatment. The problem was that with_gxx_include_path
2157# often contains an i386 which is expanded as a macro. Solved in stlport.
2158if test "$GXX" = "yes"; then
2159   AC_MSG_CHECKING([for g++ include path])
2160   if test -z "$with_gxx_include_path"; then
2161      with_gxx_include_path=`echo "#include <cstring>" | $CXX -E -xc++ - | $SED -n '/.*1*"\(.*\)\/cstring".*/s//\1/p' | head -n 1`
2162      if test "$with_gxx_include_path" = "/usr/libexec/(null)/include"; then
2163          with_gxx_include_path="/usr/include"
2164      fi
2165      if test "$WITH_MINGWIN" = "yes"; then
2166         with_gxx_include_path=`cygpath -d "$with_gxx_include_path"`
2167         with_gxx_include_path=`cygpath -u "$with_gxx_include_path"`
2168      fi
2169      if echo $with_gxx_include_path | grep -q linux; then
2170         # workaround for Mandriva - issue 100049
2171         with_gxx_include_path=`cd $with_gxx_include_path && pwd`
2172      fi
2173   fi
2174fi
2175dnl This is the original code...
2176dnl with_gxx_include_path=`$CXX -print-search-dirs | grep instal |$AWK '{ print \$2 }'`/include
2177if test -z "$with_gxx_include_path"; then
2178   with_gxx_include_path="NO_GXX_INCLUDE"
2179   AC_MSG_RESULT([no g++ includes])
2180else
2181   AC_MSG_RESULT([$with_gxx_include_path])
2182fi
2183GXX_INCLUDE_PATH="$with_gxx_include_path"
2184AC_SUBST(GXX_INCLUDE_PATH)
2185
2186dnl ===================================================================
2187dnl Set the mingw runtime library include directories
2188dnl ===================================================================
2189if test "$WITH_MINGWIN" = "yes"; then
2190   AC_MSG_CHECKING([for mingwin runtime include path])
2191   cat >conftest.$ac_ext <<_ACEOF
2192#include <stddef.h>
2193#include <bits/c++config.h>
2194_ACEOF
2195   _mingw_lib_include_path=`$CXX -E -xc++ conftest.$ac_ext | $SED -n -e '/.*1*"\(.*\)\/stddef.h".*/s//\1/p' -e '/.*1*"\(.*\)\/bits\/c++config.h".*/s//\1/p' | sort -u | xargs echo`
2196   rm conftest.$ac_ext
2197   if test -n "$_mingw_lib_include_path"; then
2198      _temp=""
2199      for a in $_mingw_lib_include_path
2200         do
2201            a=`cygpath -d "$a"`
2202            _temp="$_temp "`cygpath -u "$a"`
2203         done
2204      _mingw_lib_include_path=$_temp
2205   fi
2206   if test -z "$_mingw_lib_include_path"; then
2207      _mingw_lib_include_path="NO_LIB_INCLUDE"
2208      AC_MSG_RESULT([no mingwin runtime includes])
2209   else
2210      AC_MSG_RESULT([$_mingw_lib_include_path])
2211   fi
2212  MINGW_LIB_INCLUDE_PATH="$_mingw_lib_include_path"
2213  AC_SUBST(MINGW_LIB_INCLUDE_PATH)
2214dnl mingw gcc 4.4.0 needs backward in include path to use hash_set/hash_map
2215   AC_MSG_CHECKING([for mingwin c++ backward include path])
2216   cat >conftest.$ac_ext <<_ACEOF
2217#include <hash_set>
2218_ACEOF
2219   _mingw_backward_include_path=`$CXX -E -xc++ -Wno-deprecated conftest.$ac_ext 2>&5| $SED -n -e '/.*1*"\(.*\)\/hash_set".*/s//\1/p' | sort -u | xargs echo`
2220   rm conftest.$ac_ext
2221   if test -n "$_mingw_backward_include_path"; then
2222      _mingw_backward_include_path=`cygpath -d $_mingw_backward_include_path`
2223      _mingw_backward_include_path=`cygpath -u $_mingw_backward_include_path`
2224      AC_MSG_RESULT([$_mingw_backward_include_path])
2225   else
2226      _mingw_backward_include_path="NO_BACKWARD_INCLUDE"
2227      AC_MSG_RESULT([no mingwin c++ backward includes])
2228   fi
2229  MINGW_BACKWARD_INCLUDE_PATH="$_mingw_backward_include_path"
2230  AC_SUBST(MINGW_BACKWARD_INCLUDE_PATH)
2231  mingw_crtbegin=`$CC -print-file-name=crtbegin.o`
2232  MINGW_CLIB_DIR=`dirname $mingw_crtbegin`
2233  AC_MSG_CHECKING([whether to use dynamic libgcc])
2234  if test -e "$MINGW_CLIB_DIR/libgcc_s.a"; then
2235    AC_MSG_CHECKING([dynamic libgcc name])
2236    MINGW_GCCDLL_pattern=`nm $MINGW_CLIB_DIR/libgcc_s.a | sed -ne 's@.* _libgcc\(.*\)_dll_iname@libgcc\1.dll@p' | uniq | sed -e 's@_@?@g'`
2237    MINGW_GCCDLL=`cd $COMPATH/bin && ls $MINGW_GCCDLL_pattern 2>/dev/null`
2238    if test -n "$MINGW_GCCDLL"; then
2239        MINGW_SHARED_GCCLIB=YES
2240        AC_MSG_RESULT([use $MINGW_GCCDLL])
2241    else
2242        AC_MSG_RESULT([no])
2243    fi
2244  else
2245    AC_MSG_RESULT([no])
2246  fi
2247  if test -e "$MINGW_CLIB_DIR/libgcc_eh.a"; then
2248      MINGW_GCCLIB_EH=YES
2249  fi
2250  AC_MSG_CHECKING([whether to use dynamic libstdc++])
2251  MINGW_SHARED_LIBSTDCPP=
2252  if test -e "$MINGW_CLIB_DIR/libstdc++_s.a" ; then
2253    MINGW_SHARED_LIBSTDCPP=stdc++_s
2254  fi
2255  if test -e "$MINGW_CLIB_DIR/libstdc++.dll.a" ; then
2256    MINGW_SHARED_LIBSTDCPP=stdc++.dll
2257  fi
2258  if test -n "$MINGW_SHARED_LIBSTDCPP" ; then
2259    AC_MSG_CHECKING([dynamic libstdc++ name])
2260    MINGW_GXXDLL_pattern=`nm $MINGW_CLIB_DIR/lib$MINGW_SHARED_LIBSTDCPP.a | sed -ne 's@.* _libstdc__\(.*\)_dll_iname@libstdc++\1.dll@p' | uniq | sed -e 's@_@?@g'`
2261    MINGW_GXXDLL=`cd $COMPATH/bin && ls $MINGW_GXXDLL_pattern 2>/dev/null`
2262    if test -n "$MINGW_GXXDLL"; then
2263        MINGW_SHARED_LIBSTDCPP=-l$MINGW_SHARED_LIBSTDCPP
2264        MINGW_SHARED_GXXLIB=YES
2265        AC_MSG_RESULT([use $MINGW_GXXDLL])
2266    else
2267        MINGW_SHARED_LIBSTDCPP=
2268        AC_MSG_RESULT([no])
2269    fi
2270  else
2271    AC_MSG_RESULT([no])
2272  fi
2273  MINGW_CLIB_DIR=`cygpath $MINGW_CLIB_DIR`
2274  AC_SUBST(MINGW_CLIB_DIR)
2275  AC_SUBST(MINGW_SHARED_GCCLIB)
2276  AC_SUBST(MINGW_GCCLIB_EH)
2277  AC_SUBST(MINGW_SHARED_GXXLIB)
2278  AC_SUBST(MINGW_SHARED_LIBSTDCPP)
2279  AC_SUBST(MINGW_GCCDLL)
2280  AC_SUBST(MINGW_GXXDLL)
2281fi
2282
2283dnl ===================================================================
2284dnl Extra checking for the SUN OS compiler
2285dnl ===================================================================
2286if test "$_os" = "SunOS"; then
2287   dnl SunStudio C++ compiler packaged with SunStudio C compiler
2288   if test "$CC" = "cc"; then
2289   AC_MSG_CHECKING([SunStudio C++ Compiler])
2290      if test "$CXX" != "CC"; then
2291         AC_MSG_WARN([SunStudio C++ was not found])
2292         echo "SunStudio C++ was not found" >> warn
2293      else
2294         AC_MSG_RESULT([checked])
2295      fi
2296   fi
2297fi
2298dnl ===================================================================
2299dnl Extra checking for the OSF compiler
2300dnl ===================================================================
2301if test "$_os" = "OSF1"; then
2302   AC_MSG_CHECKING([Compaq C++ compiler version])
2303   dnl cxx -V outputs to standard error!!!!
2304   _compaqcxx_version=`$CXX -V 2>&1 | $AWK '{ print $3 }'`
2305   _compaqcxx_major=`echo $_compaqcxx_version | $AWK -F. '{ print $1 }'`
2306   if test "$_compaqcxx_major" != "V6"; then
2307      AC_MSG_WARN([found version "$_compaqc_version", use version 6 of the Compaq C++ compiler])
2308      echo "found version $_compaqc_version, use version 6 of the Compaq C++ compiler" >> warn
2309   else
2310      dnl compiler will do
2311      AC_MSG_RESULT([checked])
2312   fi
2313fi
2314
2315dnl *************************************************************
2316dnl Testing for exception handling - dwarf2 or sjlj exceptions...
2317dnl *************************************************************
2318AC_MSG_CHECKING([exception type])
2319AC_LANG_PUSH([C++])
2320if test "$WITH_MINGWIN" = "yes"; then
2321  AC_TRY_LINK(
2322	[#include <iostream>
2323
2324extern "C" void _Unwind_SjLj_RaiseException(void) __attribute__ ((__noreturn__));
2325
2326	],
2327	[_Unwind_SjLj_RaiseException() ],
2328	[exceptions_type="sjlj"],
2329	[exceptions_type="dwarf2"]
2330  )
2331fi
2332
2333AC_MSG_RESULT($exceptions_type)
2334AC_LANG_POP([C++])
2335EXCEPTIONS="$exceptions_type"
2336AC_SUBST(EXCEPTIONS)
2337
2338dnl **************************************************************
2339dnl Testing for required  Solaris and SunStudio compiler patches...
2340dnl **************************************************************
2341dnl Check whether the OS is SunOS.
2342if test "$_os" = "SunOS"; then
2343   _temp=`showrev -p | $AWK -F" " '{ print $2 }'`
2344   if test "$_os_release" = "7"; then
2345      dnl ***************
2346      dnl patch 106327-06
2347      dnl ***************
2348      AC_MSG_CHECKING([for patch 106327-06 or greater])
2349      _patch=`echo $_temp | $AWK '/106327-06/ { print "found" }'`
2350      _patch="false"
2351      for i in $_temp
2352      do
2353         _patch_major=`echo $i | $AWK -F"-" '{ print $1 }'`
2354         if test "$_patch_major" = "106327"; then
2355            _patch_rev=`echo $i | $AWK -F"-" '{ print $2 }'`
2356            if test "$_patch_rev" -ge "6"; then
2357               _patch="found"
2358            fi
2359        fi
2360      done
2361      if test "$_patch" = "found"; then
2362         AC_MSG_RESULT([found])
2363      else
2364         AC_MSG_WARN([patch 106327-06 not found, please install compiler patch 106327-06 or greater])
2365         echo "patch 106327-06 not found, please install compiler patch 106327-06 or greater" >> warn
2366      fi
2367      dnl ***************
2368      dnl patch 106950-11
2369      dnl ***************
2370      AC_MSG_CHECKING([for patch 106950-11 or greater])
2371      _patch=`echo $_temp | $AWK '/106950-11/ { print "found" }'`
2372      _patch="false"
2373      for i in $_temp
2374      do
2375         _patch_major=`echo $i | $AWK -F"-" '{ print $1 }'`
2376         if test "$_patch_major" = "106950"; then
2377            _patch_rev=`echo $i | $AWK -F"-" '{ print $2 }'`
2378            if test "$_patch_rev" -ge "11"; then
2379               _patch="found"
2380            fi
2381         fi
2382      done
2383      if test "$_patch" = "found"; then
2384         AC_MSG_RESULT([found])
2385      else
2386         AC_MSG_WARN([patch 106950-11 not found, please install linker patch 106950-11 or greater])
2387         echo "patch 106950-11 not found, please install linker patch 106950-11 or greater" >> warn
2388      fi
2389   else
2390      if test "$_os_release" = "6"; then
2391         dnl ***************
2392         dnl patch 105591-09
2393         dnl ***************
2394         AC_MSG_CHECKING([for patch 105591-09 or greater])
2395         _patch=`echo $_temp | $AWK '/105591-09/ { print "found" }'`
2396         _patch="false"
2397         for i in $_temp
2398         do
2399            _patch_major=`echo $i | $AWK -F"-" '{ print $1 }'`
2400            if test "$_patch_major" = "105591"; then
2401               _patch_rev=`echo $i | $AWK -F"-" '{ print $2 }'`
2402               if test "$_patch_rev" -ge "9"; then
2403                  _patch="found"
2404               fi
2405           fi
2406         done
2407         if test "$_patch" = "found"; then
2408            AC_MSG_RESULT([found])
2409         else
2410            AC_MSG_WARN([patch 105591-09 not found, please install compiler patch 105591-09 or greater])
2411            echo "patch 105591-09 not found, please install compiler patch 105591-09 or greater" >> warn
2412         fi
2413         dnl ***************
2414         dnl patch 107733-08
2415         dnl ***************
2416         AC_MSG_CHECKING([for patch 107733-08 or greater])
2417         _patch=`echo $_temp | $AWK '/107733-08/ { print "found" }'`
2418         _patch="false"
2419         for i in $_temp
2420         do
2421            _patch_major=`echo $i | $AWK -F"-" '{ print $1 }'`
2422            if test "$_patch_major" = "107733"; then
2423               _patch_rev=`echo $i | $AWK -F"-" '{ print $2 }'`
2424               if test "$_patch_rev" -ge "8"; then
2425                  _patch="found"
2426               fi
2427           fi
2428         done
2429         if test "$_patch" = "found"; then
2430            AC_MSG_RESULT([found])
2431         else
2432            AC_MSG_WARN([patch 107733-06 not found, please install linker patch 107733-08 or greater])
2433            echo "patch 107733-06 not found, please install linker patch 107733-08 or greater" >> warn
2434         fi
2435      fi
2436   fi
2437fi
2438
2439dnl ===================================================================
2440dnl Checks for what the default STL should be
2441dnl ===================================================================
2442   AC_MSG_CHECKING([what the default STL should be])
2443   DEFAULT_TO_STLPORT="no"
2444   if test "$_os" = "Linux"; then
2445     case "$build_cpu" in
2446       i?86)
2447	 case "$build_os" in k*bsd*-gnu*)
2448	 	DEFAULT_TO_STLPORT="no"
2449		;;
2450	 *)
2451         	DEFAULT_TO_STLPORT="yes"
2452		;;
2453	  esac
2454         ;;
2455       *)
2456         DEFAULT_TO_STLPORT="no"
2457         ;;
2458     esac
2459   elif test "$_os" = "SunOS"; then
2460      DEFAULT_TO_STLPORT="yes"
2461   elif test "$_os" = "WINNT" -a "$WITH_MINGWIN" != "yes"; then
2462      DEFAULT_TO_STLPORT="yes"
2463   elif test "$_os" = "OS2"; then
2464      DEFAULT_TO_STLPORT="yes"
2465   elif test "$_os" = "FreeBSD"; then
2466      DEFAULT_TO_STLPORT="no"
2467   fi
2468   if test "$DEFAULT_TO_STLPORT" = "yes"; then
2469      AC_MSG_RESULT([stlport])
2470   else
2471      AC_MSG_RESULT([system])
2472   fi
2473   if test "$WITH_STLPORT" = "auto"; then
2474      WITH_STLPORT=$DEFAULT_TO_STLPORT
2475   fi
2476
2477dnl ===================================================================
2478dnl Checks for STLPORT
2479dnl ===================================================================
2480   AC_MSG_CHECKING([for STL providing headers])
2481   STLPORT4=""
2482   USE_SYSTEM_STL=""
2483   if test "$WITH_STLPORT" = "yes"; then
2484      AC_MSG_RESULT([using internal stlport.])
2485      if test "$DEFAULT_TO_STLPORT" != "yes"; then
2486         AC_MSG_WARN([using stlport. Warning, breaks your ABI compatability!])
2487         echo "using stlport. Warning, breaks your ABI compatability!" >>warn
2488      fi
2489   elif test "$WITH_STLPORT" = "no"; then
2490      AC_MSG_RESULT([using system STL])
2491      USE_SYSTEM_STL="YES"
2492      if test "$DEFAULT_TO_STLPORT" != "no"; then
2493         AC_MSG_WARN([using system STL. Warning, breaks your ABI compatability!])
2494         echo "using system STL. Warning, breaks your ABI compatability!" >>warn
2495      fi
2496   else
2497      STLPORT4=$WITH_STLPORT
2498      if test "$_os" != "WINNT" -o "$WITH_MINGWIN" = "yes"; then
2499         AC_TRY_CPP($STLPORT4/stlport/hash_map, AC_MSG_RESULT([checked.]), AC_MSG_ERROR([STLport headers not found.]))
2500      else
2501         dnl AC_TRY_CPP doesn't work for MSVC because C++ preprocessor is not found by autoconf.
2502         if test -f "$STLPORT4/stlport/hash_map"; then
2503            AC_MSG_RESULT([checked.])
2504         else
2505            AC_MSG_ERROR([STLport headers not found.])
2506         fi
2507      fi
2508      if test "$_os" != "WINNT" -o "$WITH_MINGWIN" = "yes"; then
2509         AC_MSG_CHECKING([for STLport libraries])
2510         if test "$_os" = "SunOS"; then
2511		      if test -f "$STLPORT4/lib/libstlport_sunpro.so"; then
2512			      AC_MSG_RESULT([checked])
2513		      elif test -f "$STLPORT4/lib/libstlport.so"; then
2514			      AC_MSG_RESULT([checked])
2515			      STLPORT_VER=500
2516		      else
2517			      AC_MSG_ERROR([STLport libraries not found])
2518		      fi
2519	      elif test "$_os" = "Darwin"; then
2520		      if test -f "$STLPORT4/lib/libstlport_gcc.dylib"; then
2521			      AC_MSG_RESULT([checked])
2522		      elif test -f "$STLPORT4/lib/libstlport.dylib"; then
2523			      AC_MSG_RESULT([checked])
2524			      STLPORT_VER=500
2525		      else
2526			      AC_MSG_ERROR([STLport libraries not found])
2527		      fi
2528		   else
2529			   if test -f "$STLPORT4/lib/libstlport_gcc.so"; then
2530				   AC_MSG_RESULT([checked])
2531			   elif test -f "$STLPORT4/lib/libstlport.so"; then
2532				   AC_MSG_RESULT([checked])
2533				   STLPORT_VER=500
2534			   else
2535				   AC_MSG_ERROR([STLport libraries not found])
2536			   fi
2537		   fi
2538	   fi
2539      if test "$DEFAULT_TO_STLPORT" != "yes"; then
2540         AC_MSG_WARN([using stlport. Warning, breaks your ABI compatability!])
2541         echo "using stlport. Warning, breaks your ABI compatability!" >>warn
2542      fi
2543   fi
2544
2545if test -z "$STLPORT4"; then
2546  STLPORT4="NO_STLPORT4"
2547fi
2548if test -z "$STLPORT_VER"; then
2549  STLPORT_VER=400
2550fi
2551AC_SUBST(STLPORT4)
2552AC_SUBST(STLPORT_VER)
2553AC_SUBST(USE_SYSTEM_STL)
2554
2555dnl ===================================================================
2556dnl visibility feature
2557dnl ===================================================================
2558if test "$GCC" = "yes"; then
2559   AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
2560   save_CFLAGS=$CFLAGS
2561   CFLAGS="$CFLAGS -fvisibility=hidden"
2562   AC_TRY_LINK([], [ return 0; ], [ HAVE_GCC_VISIBILITY_FEATURE=TRUE ], [])
2563   CFLAGS=$save_CFLAGS
2564   if test "$HAVE_GCC_VISIBILITY_FEATURE" = "TRUE"; then
2565      AC_MSG_RESULT([yes])
2566   else
2567      AC_MSG_RESULT([no])
2568   fi
2569fi
2570
2571# ===================================================================
2572# use --ccache-skip?
2573# ===================================================================
2574dnl used to escape compiler options for ccache that otherwise prevent
2575dnl caching of the results (like "-x objective-c++" for Mac)
2576AC_MSG_CHECKING([whether we are allowed and able to use --ccache-skip])
2577if test "$_os" != "Darwin" ; then
2578   AC_MSG_RESULT([only used on Mac currently, skipping])
2579elif test "$enable_ccache_skip" = "no" ; then
2580   AC_MSG_RESULT([no - diabled explicitly])
2581elif test "$enable_ccache_skip" = "yes" ; then
2582   AC_MSG_RESULT([yes - enabled explicitly, skipping checks])
2583   AC_SUBST([USE_CCACHE], [YES])
2584elif test "$enable_ccache_skip" = "auto" ; then
2585   # checking for ccache presence/version
2586   AC_MSG_RESULT([probing...])
2587   AC_PATH_PROG([CCACHE],[ccache],[not_found])
2588   if test "$CCACHE" = "not_found" ; then
2589      AC_MSG_NOTICE([not enabling --ccache-skip (ccache not found)])
2590   else
2591      # check ccache version
2592      AC_MSG_CHECKING([whether version of ccache is suitable])
2593      CCACHE_VERSION=`"$CCACHE" -V | "$AWK" '/^ccache version/{print $3}'`
2594      if test "$CCACHE_VERSION" = "2.4_OOo"; then
2595         AC_MSG_RESULT([yes])
2596         AC_MSG_CHECKING([whether ccache is actually used for the build])
2597         AC_LANG_PUSH([C++])
2598         save_CXXFLAGS=$CXXFLAGS
2599         CXXFLAGS="$CXXFLAGS --ccache-skip -O2"
2600         dnl an empty program will do, we're checking the compiler flags
2601         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
2602            [use_ccache=yes], [use_ccache=no])
2603         if test $use_ccache = yes ; then
2604            AC_MSG_RESULT([yes, will enable --ccache-skip])
2605            AC_SUBST([USE_CCACHE], [YES])
2606         else
2607            AC_MSG_RESULT([no, will not enable --ccache-skip])
2608         fi
2609         CXXFLAGS=$save_CXXFLAGS
2610         AC_LANG_POP([C++])
2611      else
2612         AC_MSG_RESULT([no])
2613         AC_MSG_NOTICE([ccache version $CCACHE_VERSION not accepted. See description for --enable-ccache-skip])
2614      fi
2615   fi
2616else
2617   AC_MSG_ERROR([invalid option to --enable-ccache-skip. Valid values are "auto", "yes" and "no"])
2618fi
2619
2620dnl ===================================================================
2621dnl system stl sanity tests
2622dnl ===================================================================
2623if test "$USE_SYSTEM_STL" = "YES"; then
2624   AC_MSG_CHECKING([if hash_map will be in __gnu_cxx namespace])
2625   AC_LANG_PUSH([C++])
2626
2627   AC_TRY_COMPILE([#include <ext/hash_map>
2628using namespace __gnu_cxx;
2629],[hash_map<int, int> t; return 0;],
2630  ac_cv_cxx_have_ext_hash_map=yes, ac_cv_cxx_have_ext_hash_map=no)
2631
2632   if test "$ac_cv_cxx_have_ext_hash_map" = "no"; then
2633      AC_MSG_ERROR([Can't find hash_map. Try with --with-stlport])
2634   else
2635      AC_MSG_RESULT([$ac_cv_cxx_have_ext_hash_map])
2636   fi
2637
2638   if test "$HAVE_GCC_VISIBILITY_FEATURE" = "TRUE"; then
2639      AC_MSG_CHECKING([if STL headers are visibility safe])
2640      AC_EGREP_HEADER(visibility push, string, stlvisok=yes, stlvisok=no)
2641      AC_MSG_RESULT([$stlvisok])
2642      if test "$stlvisok" = "no"; then
2643         AC_MSG_WARN([Your gcc STL headers are not visibility safe. Disabling visibility])
2644         echo "Your gcc STL headers are not visibility safe. Disabling visibility" >> warn
2645         unset HAVE_GCC_VISIBILITY_FEATURE
2646      fi
2647   fi
2648
2649   if test "$HAVE_GCC_VISIBILITY_FEATURE" = "TRUE"; then
2650      sharedlink_ldflags_save=$LDFLAGS
2651      LDFLAGS="$LDFLAGS -fvisibility-inlines-hidden -fpic -shared"
2652
2653      AC_MSG_CHECKING([if gcc is -fvisibility-inlines-hidden safe with STL headers])
2654      AC_TRY_LINK([#include <sstream>
2655using namespace std;
2656],[istringstream strm( "test" ); return 0;],
2657      $EGREP -q  unresolvable conftest.err;
2658      if test $? -eq 0; then gccvisok=no; else gccvisok=yes; fi,
2659      gccvisok=no)
2660      AC_MSG_RESULT([$gccvisok])
2661      if test "$gccvisok" = "no"; then
2662         AC_MSG_WARN([Your gcc is not -fvisibility-inlines-hidden safe. Disabling visibility])
2663         echo "Your gcc is not -fvisibility-inlines-hidden safe. Disabling visibility" >> warn
2664         unset HAVE_GCC_VISIBILITY_FEATURE
2665      fi
2666
2667      LDFLAGS=$sharedlink_ldflags_save
2668   fi
2669
2670   if test "$HAVE_GCC_VISIBILITY_FEATURE" = "TRUE"; then
2671      AC_MSG_CHECKING([if gcc has a visibility bug with class-level attributes (GCC bug 26905)])
2672      cat >visibility.cxx <<_ACEOF
2673#pragma GCC visibility push(hidden)
2674struct __attribute__ ((visibility ("default"))) TestStruct {
2675  static void Init();
2676};
2677__attribute__ ((visibility ("default"))) void TestFunc() {
2678  TestStruct::Init();
2679}
2680_ACEOF
2681      if ! $CXX $CXXFLAGS $CPPFLAGS -fpic -S visibility.cxx 2>/dev/null > /dev/null; then
2682         gccvisbroken=yes
2683      else
2684         case "$build_cpu" in
2685            i?86|x86_64)
2686               if $EGREP -q '@PLT' visibility.s; then
2687                  gccvisbroken=no
2688               else
2689                  gccvisbroken=yes
2690               fi
2691               ;;
2692            *)
2693               gccvisbroken=no
2694               ;;
2695         esac
2696      fi
2697      rm -f visibility.s visibility.cxx
2698
2699      AC_MSG_RESULT([$gccvisbroken])
2700      if test "$gccvisbroken" = "yes"; then
2701         AC_MSG_WARN([Your gcc is not -fvisibility=hidden safe. Disabling visibility])
2702         echo "Your gcc is not -fvisibility=hidden safe. Disabling visibility" >> warn
2703         unset HAVE_GCC_VISIBILITY_FEATURE
2704      fi
2705   fi
2706
2707   AC_LANG_POP([C++])
2708fi
2709
2710AC_SUBST(HAVE_GCC_VISIBILITY_FEATURE)
2711
2712dnl ===================================================================
2713dnl allocator
2714dnl ===================================================================
2715AC_MSG_CHECKING([which memory allocator to use])
2716if test "$with_alloc" = "system"; then
2717    AC_MSG_RESULT([system])
2718    ALLOC="SYS_ALLOC";
2719    AC_CHECK_FUNCS([malloc realloc calloc free])
2720fi
2721if test "$with_alloc" = "tcmalloc"; then
2722    AC_MSG_RESULT(tcmalloc)
2723    if ! echo $build_cpu | grep -E 'i[[3456]]86' 2>/dev/null >/dev/null; then
2724        AC_MSG_ERROR([tcmalloc only available/usable on ix86])
2725    fi
2726    AC_CHECK_LIB(tcmalloc, malloc, [],
2727        [AC_MSG_ERROR(tcmalloc not found or functional. Install the Google Profiling Tools)], [])
2728    ALLOC="TCMALLOC";
2729fi
2730if test "$with_alloc" = "jemalloc"; then
2731  if test "$_os" != "FreeBSD" -o "$_os" != "NetBSD"; then
2732    AC_MSG_RESULT(jemalloc)
2733    save_CFLAGS=$CFLAGS
2734    CFLAGS="$CFLAGS -pthread"
2735    AC_CHECK_LIB(jemalloc, malloc, [],
2736        [AC_MSG_ERROR(jemalloc not found or functional. Install the jemalloc allocator.)], [])
2737    ALLOC="JEMALLOC";
2738    CFLAGS=$save_CFLAGS
2739  else
2740    AC_MSG_RESULT([system])
2741    ALLOC="SYS_ALLOC";
2742    AC_CHECK_FUNCS([malloc realloc calloc free])
2743  fi
2744fi
2745if test "$with_alloc" = "internal" -o -z "$with_alloc"; then
2746   AC_MSG_RESULT([internal])
2747fi
2748AC_SUBST(ALLOC)
2749
2750dnl ===================================================================
2751dnl Custom build version
2752dnl ===================================================================
2753
2754AC_MSG_CHECKING([whether to add custom build version])
2755if test "z$with_build_version" != "z"; then
2756   BUILD_VER_STRING=$with_build_version
2757   AC_MSG_RESULT([yes, $BUILD_VER_STRING])
2758else
2759   BUILD_VER_STRING=
2760   AC_MSG_RESULT([no])
2761fi
2762AC_SUBST(BUILD_VER_STRING)
2763
2764dnl ===================================================================
2765dnl Java support enable
2766dnl ===================================================================
2767AC_MSG_CHECKING([whether to build with Java support])
2768if test "$WITH_JAVA" != "no"; then
2769   AC_MSG_RESULT([yes])
2770   SOLAR_JAVA="TRUE"
2771else
2772   AC_MSG_RESULT([no])
2773   SOLAR_JAVA=""
2774
2775   AC_MSG_WARN([building without java will mean some features will not be available])
2776   echo "building without java will mean some features will not be available" >>warn
2777fi
2778AC_SUBST(SOLAR_JAVA)
2779
2780if test "$_os" = "Linux" && test "$build_cpu" = "powerpc"; then
2781   # IBMs JDK needs this...
2782   JITC_PROCESSOR_TYPE=6
2783   export JITC_PROCESSOR_TYPE
2784fi
2785
2786if test "$_os" = "WINNT"; then
2787   if test -z "$with_jdk_home"; then
2788      _jdk_home=`./oowintool --jdk-home`
2789       if test -d "$_jdk_home"; then
2790          with_jdk_home="$_jdk_home"
2791       fi
2792   else
2793      with_jdk_home=`cygpath -u "$with_jdk_home"`
2794   fi
2795fi
2796
2797dnl ===================================================================
2798dnl Checks for java
2799dnl ===================================================================
2800if test "$SOLAR_JAVA" != ""; then
2801   JAVA_HOME=; export JAVA_HOME
2802   if test -z "$with_jdk_home"; then
2803      AC_PATH_PROG(JAVAINTERPRETER, $WITH_JAVA)
2804   else
2805      _java_path="$with_jdk_home/bin/$WITH_JAVA"
2806      dnl Check if there is a java interpreter at all.
2807      if test -x "$_java_path"; then
2808         JAVAINTERPRETER=$_java_path
2809      else
2810         AC_MSG_ERROR([$_java_path not found, please use --with-jdk-home])
2811      fi
2812   fi
2813   if test "$_os" = "WINNT"; then
2814      if test x`echo "$JAVAINTERPRETER" | grep -i '\.exe$'` = x; then
2815          JAVAINTERPRETER="${JAVAINTERPRETER}.exe"
2816      fi
2817      JAVAINTERPRETER=`cygpath -d "$JAVAINTERPRETER"`
2818      JAVAINTERPRETER=`cygpath -u "$JAVAINTERPRETER"`
2819   elif test "$_os" = "Darwin"; then
2820      dnl HACK:  There currently is only a 32 bit version of OOo for Mac OS X,
2821      dnl and Tiger java complains about -d32 while Snow Leopard java needs it
2822      dnl to run in 32 bit mode and be able to load OOo jnilibs:
2823      AC_MSG_CHECKING([whether to pass -d32 to Java interpreter])
2824      if "$JAVAINTERPRETER" -d32 >&5 2>&5; then
2825         AC_MSG_RESULT([yes])
2826         JAVAIFLAGS=-d32
2827      else
2828         AC_MSG_RESULT([no])
2829      fi
2830   fi
2831fi
2832
2833dnl ===================================================================
2834dnl Checks for JDK.
2835dnl ===================================================================
2836if test "$SOLAR_JAVA" != ""; then
2837   _gij_longver=0
2838   AC_MSG_CHECKING([the installed JDK])
2839   if test -n "$JAVAINTERPRETER"; then
2840      dnl java -version sends output to stderr!
2841      if test `$JAVAINTERPRETER -version 2>&1 | grep -c "Kaffe"` -gt 0; then
2842         AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.in])
2843#        dnl Kaffe specific tests
2844#        KAFFE_VER=`$JAVAINTERPRETER -version 2>&1 | $EGREP "  Version:" | $SED -r "s/.*  Version: ([[0-9\.]]*).*/\1/"`
2845#        if test -z "$KAFFE_VER"; then
2846#          AC_MSG_ERROR([looks like Kaffe but version detection failed])
2847#        fi
2848#        _kaffe_ver=`echo "$KAFFE_VER" | $AWK -F. '{ print (($1 * 100) + $2) * 100 + $3;}'`
2849#        if test "$_kaffe_ver" -lt 10100; then
2850#           AC_MSG_ERROR([Kaffe is too old ($KAFFE_VER - $_kaffe_ver), you need at least 1.1.0])
2851#        fi
2852#        JDK=kaffe
2853#
2854#        dnl TODO: define some project exclusion variables
2855#
2856#        AC_MSG_RESULT([checked (Kaffe $KAFFE_VER)])
2857#        AC_MSG_WARN([EXPERIMENTAL: Kaffe is not a full JDK replacement - some projects will fail to compile])
2858#        echo "EXPERIMENTAL: Kaffe is not a full JDK replacement - some projects will fail to compile" >>warn
2859#        JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*java,,p"`
2860      elif test `$JAVAINTERPRETER --version 2>&1 | grep -c "GNU libgcj"` -gt 0; then
2861        JDK=gcj
2862        AC_MSG_RESULT([checked (gcj)])
2863        _gij_version=`$JAVAINTERPRETER --version | grep GNU | $SED -e 's@^[[^0-9]]*@@' -e 's@ .*@@' -e 's@,.*@@'`;
2864        _gij_longver=`echo $_gij_version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
2865
2866      elif test `$JAVAINTERPRETER -version 2>&1 | awk '{ print }' | grep -c "BEA"` -gt 0; then
2867         AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.in])
2868#        JDK=bea
2869#
2870#        dnl BEA JDK specific tests
2871#        _jdk=`$JAVAINTERPRETER -version 2>&1 | $AWK -F'"' '{ print \$2 }' | $SED s/[[-A-Za-z]]*//`
2872#        _jdk_ver=`echo "$_jdk" | $AWK -F. '{ print (($1 * 100) + $2) * 100 + $3;}'`
2873#
2874#        if test "$_jdk_ver" -lt 10500; then
2875#          AC_MSG_ERROR([JDK is too old, you need at least BEA JDK 1.5.0])
2876#        fi
2877#
2878#        AC_MSG_RESULT([checked (BEA JDK $_jdk)])
2879#
2880#        if test "$with_jdk_home" = ""; then
2881#             AC_MSG_ERROR([In order to successfully build OpenOffice.org using the BEA JDK,
2882#you must use the "--with-jdk-home" configure option explicitly])
2883#        fi
2884#
2885#        AC_MSG_WARN([A bug in certain BEA JREs can prevent you from successfully compiling some modules])
2886#        echo "A bug in certain BEA JREs can prevent you from successfully compiling some modules" >>warn
2887#
2888#        JAVA_HOME=$with_jdk_home
2889#
2890      elif test `$JAVAINTERPRETER -version 2>&1 | awk '{ print }' | grep -c "IBM"` -gt 0; then
2891        JDK=ibm
2892
2893        dnl IBM JDK specific tests
2894        _jdk=`$JAVAINTERPRETER -version 2>&1 | $AWK -F'"' '{ print \$2 }' | $SED s/[[-A-Za-z]]*//`
2895        _jdk_ver=`echo "$_jdk" | $AWK -F. '{ print (($1 * 100) + $2) * 100 + $3;}'`
2896
2897        if test "$_jdk_ver" -lt 10500; then
2898             AC_MSG_ERROR([IBM JDK is too old, you need at least 1.5])
2899        fi
2900
2901        AC_MSG_RESULT([checked (IBM JDK $_jdk)])
2902
2903        if test "$with_jdk_home" = ""; then
2904             AC_MSG_ERROR([In order to successfully build OpenOffice.org using the IBM JDK,
2905you must use the "--with-jdk-home" configure option explicitly])
2906        fi
2907
2908        JAVA_HOME=$with_jdk_home
2909
2910      else
2911        JDK=sun
2912
2913        dnl SUN JDK specific tests
2914        _jdk=`$JAVAINTERPRETER -version 2>&1 | $AWK -F'"' '{ print \$2 }' | $SED s/[[-A-Za-z]]*//`
2915        _jdk_ver=`echo "$_jdk" | $AWK -F. '{ print (($1 * 100) + $2) * 100 + $3;}'`
2916
2917        if test "$_jdk_ver" -lt 10500; then
2918             AC_MSG_ERROR([JDK is too old, you need at least 1.5])
2919        fi
2920        AC_MSG_RESULT([checked (JDK $_jdk)])
2921        JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*java,,p"`
2922        if test "$_os" = "WINNT"; then
2923          JAVA_HOME=`echo $JAVA_HOME | $SED "s,\.[[eE]][[xX]][[eE]]$,,"`
2924        fi
2925        if test "$_os" = "OS2"; then
2926          JAVA_HOME=`echo $JAVA_HOME | $SED "s,\.[[eE]][[xX]][[eE]]$,,"`
2927        fi
2928      fi
2929   else
2930      AC_MSG_ERROR([JAVA not found. You need at least jdk-1.5, or gcj-4])
2931   fi
2932else
2933   dnl Java disabled
2934   JAVA_HOME=NO_JAVA_HOME ; export JAVA_HOME
2935fi
2936
2937dnl ===================================================================
2938dnl Checks for javac
2939dnl ===================================================================
2940if test "$SOLAR_JAVA" != ""; then
2941    if test "$JDK" = "gcj"; then
2942        javacompiler=`echo $WITH_JAVA | $SED -e "s/gij/gcj/g" | $SED -e "s/java/javac/g"`
2943    else
2944        javacompiler="javac"
2945    fi
2946    if test "$_os" = "OS2"; then
2947      if test x`echo "$javacompiler" | grep -i '\.exe$'` = x; then
2948          javacompiler="${javacompiler}.exe"
2949      fi
2950    fi
2951    if test -z "$with_jdk_home"; then
2952        AC_PATH_PROG(JAVACOMPILER, $javacompiler)
2953    else
2954        _javac_path="$with_jdk_home/bin/$javacompiler"
2955        dnl Check if there is a java compiler at all.
2956        if test -x "$_javac_path"; then
2957            JAVACOMPILER=$_javac_path
2958        fi
2959    fi
2960    if test -z "$JAVACOMPILER"; then
2961      AC_MSG_ERROR([$javacompiler not found, please use --with-jdk-home])
2962    fi
2963    if test "$_os" = "WINNT"; then
2964       if test x`echo "$JAVACOMPILER" | grep -i '\.exe$'` = x; then
2965          JAVACOMPILER="${JAVACOMPILER}.exe"
2966       fi
2967       JAVACOMPILER=`cygpath -d "$JAVACOMPILER"`
2968       JAVACOMPILER=`cygpath -u "$JAVACOMPILER"`
2969    fi
2970    if test "$_os" = "OS2"; then
2971       if test x`echo "$JAVACOMPILER" | grep -i '\.exe$'` = x; then
2972          JAVACOMPILER="${JAVACOMPILER}.exe"
2973       fi
2974    fi
2975
2976    if test `$JAVACOMPILER -version 2>&1 | grep -c "Eclipse Java Compiler"` -gt 0; then
2977        AC_MSG_CHECKING([re-checking JDK])
2978        JDK=gcj
2979        AC_MSG_RESULT([checked (ecj)])
2980        #TODO: what's to do here? some switch to do 1.5 compiling?
2981        JAVAFLAGS="-source 1.5 -target 1.5"
2982        _gij_longver="40200"
2983    fi
2984fi
2985
2986JAVACISGCJ=""
2987dnl ===================================================================
2988dnl Checks that javac is gcj
2989dnl ===================================================================
2990if test "$SOLAR_JAVA" != ""; then
2991    if test `$JAVACOMPILER --version 2>&1 | grep -c "GCC"` -gt 0; then
2992        JAVACISGCJ="yes"
2993    fi
2994fi
2995AC_SUBST(JAVACISGCJ)
2996
2997dnl ===================================================================
2998dnl Checks for javadoc
2999dnl ===================================================================
3000if test "$SOLAR_JAVA" != ""; then
3001    if test -z "$with_jdk_home"; then
3002        AC_PATH_PROG(JAVADOC, javadoc)
3003    else
3004        _javadoc_path="$with_jdk_home/bin/javadoc"
3005        if test "$_os" = "OS2"; then
3006          if test x`echo "$_javadoc_path" | grep -i '\.exe$'` = x; then
3007              _javadoc_path="${_javadoc_path}.exe"
3008          fi
3009        fi
3010        dnl Check if there is a javadoc at all.
3011        if test -x "$_javadoc_path"; then
3012            JAVADOC=$_javadoc_path
3013        else
3014            AC_PATH_PROG(JAVADOC, javadoc)
3015        fi
3016    fi
3017    if test -z "$JAVADOC"; then
3018      AC_MSG_ERROR([$_javadoc_path not found, please use --with-jdk-home])
3019    fi
3020    if test "$_os" = "WINNT"; then
3021        if test x`echo "$JAVADOC" | grep -i '\.exe$'` = x; then
3022            JAVADOC="${JAVADOC}.exe"
3023        fi
3024        JAVADOC=`cygpath -d "$JAVADOC"`
3025        JAVADOC=`cygpath -u "$JAVADOC"`
3026    fi
3027    if test "$_os" = "OS2"; then
3028        if test x`echo "$JAVADOC" | grep -i '\.exe$'` = x; then
3029            JAVADOC="${JAVADOC}.exe"
3030        fi
3031    fi
3032fi
3033
3034if test "$SOLAR_JAVA" != ""; then
3035    dnl first check if we have been asked to autodetect JAVA_HOME with a recent gij
3036    if test "$JDK" = "gcj" -a -z "$JAVA_HOME"; then
3037      if test "x$with_jdk_home" = "x" -a "$_gij_longver" -ge "40200"; then
3038        cat > findhome.java <<_ACEOF
3039[import java.io.File;
3040
3041class findhome
3042{
3043    public static void main(String args[])
3044    {
3045        String jrelocation = System.getProperty("java.home");
3046        File jre = new File(jrelocation);
3047        System.out.println(jre.getParent());
3048    }
3049}]
3050_ACEOF
3051        AC_MSG_CHECKING([if javac works])
3052        javac_cmd="$JAVACOMPILER findhome.java 1>&2"
3053        AC_TRY_EVAL(javac_cmd)
3054        if test $? = 0 && test -f ./findhome.class ; then
3055          AC_MSG_RESULT([javac works])
3056        else
3057          echo "configure: javac test failed" >&5
3058          cat findhome.java >&5
3059          AC_MSG_ERROR([javac does not work - java projects will not build!])
3060        fi
3061
3062        AC_MSG_CHECKING([if gij knows its java.home])
3063        JAVA_HOME=`$JAVAINTERPRETER findhome`
3064        if test $? = 0 && test "$JAVA_HOME" != "" ; then
3065          AC_MSG_RESULT([$JAVA_HOME])
3066        else
3067          echo "configure: java test failed" >&5
3068          cat findhome.java >&5
3069          AC_MSG_ERROR([gij does not know its java.home - use --with-jdk-home])
3070        fi
3071      else
3072        JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*$WITH_JAVA,,p"`
3073      fi
3074    fi
3075
3076    dnl second sanity check JAVA_HOME if possible
3077    if test "$JDK" != "gcj" -o "$_gij_longver" -ge "40200"; then
3078      # check if JAVA_HOME was (maybe incorrectly?) set automatically to /usr
3079      if test "$JAVA_HOME" = "/usr" -a "x$with_jdk_home" = "x"; then
3080         javac_link_f=`readlink -f "$JAVACOMPILER" 2>/dev/null`
3081         if test $? == 0 && test "$JAVACOMPILER" != "$javac_link_f"; then
3082          # try to recover first by looking whether we have a alternatives
3083          # system as in Debian or newer SuSEs where following /usr/bin/javac
3084          # over /etc/alternatives/javac leads to the right bindir where we
3085          # just need to strip a bit away to get a valid JAVA_HOME
3086          # Solaris 11 is even worse, because target is relative, so use -f
3087            JAVA_HOME="$javac_link_f"
3088         elif readlink $JAVACOMPILER >/dev/null 2>/dev/null; then
3089          # Darwin readlink(1) is so primitive it doesn't even support -f
3090          # maybe only one level of symlink (e.g. on Mac)
3091            JAVA_HOME=`readlink $JAVACOMPILER`
3092         else
3093          # else warn
3094          AC_MSG_WARN([JAVA_HOME is set to /usr - this is very likely to be incorrect])
3095          AC_MSG_WARN([if this is the case, please inform the correct JAVA_HOME with --with-jdk-home])
3096          echo "JAVA_HOME is set to /usr - this is very likely to be incorrect" >> warn
3097          echo "if this is the case, please inform the correct JAVA_HOME with --with-jdk-home" >> warn
3098          fi
3099         dnl now that we have the path to the real javac, make a JAVA_HOME out of it..
3100         if test "$JAVA_HOME" != "/usr"; then
3101            if test "$_os" = "Darwin"; then
3102               dnl Leopard returns a non-suitable path with readlink - points to "Current" only
3103               JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/Current/Commands/javac$,/CurrentJDK/Home,)
3104               dnl Tiger already returns a JDK path..
3105               JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/CurrentJDK/Commands/javac$,/CurrentJDK/Home,)
3106            else
3107               JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/bin/javac$,,)
3108            fi
3109         fi
3110      fi
3111      # now check if $JAVA_HOME is really valid
3112      if test "$_os" = "Darwin"; then
3113         if test ! -f "$JAVA_HOME/lib/jvm.cfg" -a "x$with_jdk_home" = "x"; then
3114            JAVA_HOME_OK="NO"
3115         fi
3116      elif test ! -d "$JAVA_HOME/jre" -a "x$with_jdk_home" = "x"; then
3117         JAVA_HOME_OK="NO"
3118      fi
3119      if test "$JAVA_HOME_OK" = "NO"; then
3120         AC_MSG_WARN([JAVA_HOME was not explicitly informed with --with-jdk-home. the configure script])
3121         AC_MSG_WARN([attempted to find JAVA_HOME automatically, but apparently it failed])
3122         AC_MSG_WARN([in case JAVA_HOME is incorrectly set, some projects with not be built correctly])
3123         echo "JAVA_HOME was not explicitly informed with --with-jdk-home. the configure script" >> warn
3124         echo "attempted to find JAVA_HOME automatically, but apparently it failed" >> warn
3125         echo "in case JAVA_HOME is incorrectly set, some projects with not be built correctly" >> warn
3126#         if test "$JDK" = "gcj"; then
3127#             echo "e.g. install java-1.4.2-gcj-compat-devel and use --with-jdk-home=/usr/lib/jvm/java-1.4.2-gcj" >> warn
3128#         fi
3129      fi
3130    fi
3131fi
3132
3133AWTLIB=
3134if test "$SOLAR_JAVA" != ""; then
3135   AC_MSG_CHECKING([for jawt lib name])
3136   if test "$JDK" = "gcj"; then
3137      save_CFLAGS=$CFLAGS
3138      save_LDFLAGS=$LDFLAGS
3139      CFLAGS="$CFLAGS -I$JAVA_HOME/include"
3140      LDFLAGS="$LDFLAGS -L$JAVA_HOME/lib -lgcj"
3141      exec 6>/dev/null # no output
3142      AC_CHECK_HEADER(jni.h, [],
3143                    [AC_MSG_ERROR([jni.h could not be found. Mismatch between gcc and libgcj or libgcj-devel missing?])], [])
3144      AC_CHECK_LIB(gcjawt, JAWT_GetAWT, [ AWTLIB="-lgcjawt -lgcj"] )
3145      exec 6>&1 # output on again
3146      CFLAGS=$save_CFLAGS
3147      LDFLAGS=$save_LDFLAGS
3148   fi
3149   # IBM SDK 1.5.0-sr5 includes libjawt.so with unresolved symbols.
3150   # A workaround is to link also against libpmawt.so
3151   if test "$JDK" = "ibm" ; then
3152      save_CFLAGS=$CFLAGS
3153      save_LDFLAGS=$LDFLAGS
3154      save_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
3155      CFLAGS="$CFLAGS -I$JAVA_HOME/include"
3156      LDFLAGS="$LDFLAGS -L$JAVA_HOME/jre/bin"
3157      LD_LIBRARY_PATH=$JAVA_HOME/jre/bin:$JAVA_HOME/jre/bin/classic:$JAVA_HOME/jre/bin/xawt:$LD_LIBRARY_PATH
3158      export LD_LIBRARY_PATH
3159      exec 6>/dev/null # no output
3160      AC_CHECK_HEADER(jni.h, [],
3161                    [AC_MSG_ERROR([jni.h could not be found.])], [])
3162      AC_CHECK_LIB(jawt, JAWT_GetAWT, [ AWTLIB="-ljawt"] )
3163      if test -z "$AWTLIB"; then
3164         LDFLAGS="$LDFLAGS -L$JAVA_HOME/jre/bin/xawt -ljawt"
3165         AC_CHECK_LIB(mawt, JAWT_GetAWT, [ AWTLIB="-L$JAVA_HOME/jre/bin/xawt -ljawt -lmawt"])
3166      fi
3167      exec 6>&1 # output on again
3168      CFLAGS=$save_CFLAGS
3169      LDFLAGS=$save_LDFLAGS
3170      LD_LIBRARY_PATH=$save_LD_LIBRARY_PATH
3171   fi
3172   if test -z "$AWTLIB"; then
3173      AWTLIB=-ljawt
3174   fi
3175   AC_MSG_RESULT([$AWTLIB])
3176   AC_SUBST(AWTLIB)
3177fi
3178
3179dnl ===================================================================
3180dnl Check for optional gcj for AOT
3181dnl ===================================================================
3182if test "$SOLAR_JAVA" != ""; then
3183  AC_MSG_CHECKING([whether to enable gcj aot compilation])
3184  if test -n "$enable_gcjaot" && test "$enable_gcjaot" != "no"; then
3185     AC_MSG_RESULT([yes])
3186     if test `echo $WITH_JAVA | grep -c "gij"` -eq 0; then
3187        gcjaot="gcj"
3188     else
3189        gcjaot=`echo $WITH_JAVA | $SED -e "s/gij/gcj/g"`
3190     fi
3191     AC_MSG_RESULT([$gcjaot])
3192     if test -n "$with_jdk_home"; then
3193        _javac_path="$with_jdk_home/bin/$gcjaot"
3194        dnl Check if there is a gcj at all.
3195        if test -x "$_javac_path"; then
3196           JAVAAOTCOMPILER=$_javac_path
3197        fi
3198     fi
3199     if test -z "$JAVAAOTCOMPILER"; then
3200        AC_PATH_PROG(JAVAAOTCOMPILER, $gcjaot)
3201     fi
3202     if test -z "$JAVAAOTCOMPILER"; then
3203        AC_MSG_WARN([$gcjaot not found, please use --with-jdk-home])
3204     fi
3205  else
3206     AC_MSG_RESULT([no])
3207  fi
3208fi
3209
3210AC_SUBST(JAVA_HOME)
3211AC_SUBST(JDK)
3212AC_SUBST(JAVAFLAGS)
3213AC_SUBST(JAVAINTERPRETER)
3214AC_SUBST(JAVAIFLAGS)
3215AC_SUBST(JAVACOMPILER)
3216AC_SUBST(JAVAAOTCOMPILER)
3217AC_SUBST(JAVADOC)
3218
3219dnl ===================================================================
3220dnl Checks for specific files.
3221dnl ===================================================================
3222
3223dnl ===================================================================
3224dnl Checks for programs.
3225dnl ===================================================================
3226
3227dnl ===================================================================
3228dnl Check whether we already have dmake
3229dnl ===================================================================
3230AC_PATH_PROG(DMAKE, dmake, no)
3231if test "$DMAKE" = "no"; then
3232    BUILD_DMAKE=YES
3233    echo "dmake will be built on ./bootstrap"
3234else
3235    AC_MSG_CHECKING([whether the found dmake is the right dmake])
3236    # we need to find out whether that dmake we found is "our" dmake
3237    # or the dmake from Sun's SunStudio Compiler which is something
3238    # different
3239    # This test _should_ work because the one accepts -V (ours) and one
3240    # (the other) not...
3241    $DMAKE -V 2>/dev/null | grep 'dmake .* Version .*' >/dev/null
3242    if test $? -eq 0; then
3243       BUILD_DMAKE=NO
3244       AC_MSG_RESULT([yes])
3245       AC_MSG_CHECKING([the dmake version])
3246       DMAKE_VERSION=`$DMAKE -V | $AWK '$3 == "Version" {print $4}'`
3247       if test "`echo $DMAKE_VERSION | cut -d'.' -f1`" -gt "4"; then
3248	 AC_MSG_RESULT([OK, >= 4.11])
3249       elif test "`echo $DMAKE_VERSION | cut -d'.' -f1`" = "4" && \
3250	    test "`echo $DMAKE_VERSION | cut -d'.' -f2`" -ge "11"; then
3251	 AC_MSG_RESULT([OK, >= 4.11])
3252       else
3253	 AC_MSG_RESULT([too old. >= 4.11 is needed])
3254	 echo "A newer dmake will be built on ./bootstrap"
3255	 BUILD_DMAKE=YES
3256       fi
3257    else
3258       AC_MSG_RESULT([no])
3259       echo "dmake will be built on ./bootstrap"
3260       BUILD_DMAKE=YES
3261    fi
3262fi
3263AC_SUBST(BUILD_DMAKE)
3264
3265AC_MSG_CHECKING([whether to enable EPM for packing])
3266if test "$enable_epm" = "yes"; then
3267   AC_MSG_RESULT([yes])
3268   dnl ===================================================================
3269   dnl Check for epm - not needed for windows
3270   dnl ===================================================================
3271   if test "$_os" != "WINNT"; then
3272      if test -n "$with_epm"; then
3273	      EPM=$with_epm
3274      else
3275         AC_PATH_PROG(EPM, epm, no)
3276      fi
3277      if test "$EPM" = "no" || test "$EPM" = "internal"; then
3278         echo "EPM will be built."
3279         BUILD_EPM=YES
3280         BUILD_TYPE="$BUILD_TYPE EPM"
3281      else
3282         # Gentoo has some epm which is something different...
3283         AC_MSG_CHECKING([whether the found epm is the right epm])
3284         if $EPM | grep "ESP Package Manager" >/dev/null 2>/dev/null; then
3285            AC_MSG_RESULT([yes])
3286         else
3287            AC_MSG_ERROR([no. Install ESP Package Manager (www.easysw.com/epm) and/or specify the path to the right epm])
3288         fi
3289         AC_MSG_CHECKING([epm version])
3290         EPM_VERSION=`$EPM | grep 'ESP Package Manager' | cut -d' ' -f4 | $SED -e s/v//`
3291	 if test "`echo $EPM_VERSION | cut -d'.' -f1`" -gt "3" || \
3292	       test "`echo $EPM_VERSION | cut -d'.' -f1`" -eq "3" -a "`echo $EPM_VERSION | cut -d'.' -f2`" -ge "7"; then
3293           AC_MSG_RESULT([OK, >= 3.7])
3294           BUILD_EPM=NO
3295	        if test "$_os" = "Darwin"; then
3296               AC_MSG_CHECKING([which PackageMaker EPM thinks to use])
3297        	      _pm=`strings $EPM | grep PackageMaker | cut -d" " -f1`
3298        	      if test "$_pm" = "/Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker"; then
3299          		      AC_MSG_ERROR([$_pm; PackageMaker expected in wrong path. Either patch your epm with the right path (/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker) or use internal patched epm (--with-epm=internal)])
3300        	      elif test "$_pm" = "/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker"; then
3301          		    AC_MSG_RESULT([$_pm, ok])
3302        	      else # we never should get here, but go safe
3303			          AC_MSG_ERROR([$_pm; PackageMaker expected in unknown path. Either patch your epm with the right path (/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker) or use internal patched epm (--with-epm=internal)])
3304		          fi
3305	       fi
3306	 else
3307           AC_MSG_RESULT([too old. epm >= 3.7 is required.])
3308           echo "EPM will be built."
3309           BUILD_EPM=YES
3310           BUILD_TYPE="$BUILD_TYPE EPM"
3311	 fi
3312      fi
3313   fi
3314
3315   # test which package format to use
3316   AC_MSG_CHECKING([which package format to use])
3317
3318   # defaults
3319   case "$_os" in
3320	OS2)
3321		PKGFORMAT=native
3322		;;
3323	Darwin)
3324		PKGFORMAT=dmg
3325		;;
3326	SunOS)
3327		PKGFORMAT=pkg
3328		;;
3329	Linux)
3330      # if building on Debian, default should be deb...
3331      if test -e /etc/debian_version; then
3332         PKGFORMAT=deb
3333      else
3334         PKGFORMAT=rpm
3335      fi
3336		;;
3337	AIX)
3338		PKGFORMAT=aix
3339		;;
3340	*BSD)
3341		PKGFORMAT=bsd
3342		;;
3343	OSF1)
3344		PKGFORMAT=setld
3345		;;
3346    WINNT)
3347        PKGFORMAT=msi
3348        ;;
3349	# we never should get here since we check the arciecture/os at the beginning,
3350	# but go sure...
3351	*)
3352		AC_MSG_ERROR([unknown system])
3353   esac
3354   if test -n "$with_package_format"; then
3355	for i in $with_package_format; do
3356		case "$i" in
3357			aix | bsd | deb | inst | tardist | osx | pkg | rpm | setld | native | portable | archive | dmg | installed | msi)
3358			;;
3359		*)
3360			AC_MSG_ERROR([unsupported format $i. Supported by EPM are:
3361aix - AIX software distribution
3362bsd - FreeBSD, NetBSD, or OpenBSD software distribution
3363depot or swinstall - HP-UX software distribution
3364deb - Debian software distribution
3365inst or tardist - IRIX software distribution
3366osx - MacOS X software distribution
3367pkg - Solaris software distribution
3368rpm - RedHat software distribution
3369setld - Tru64 (setld) software distribution
3370native - "Native" software distribution for the platform
3371portable - Portable software distribution
3372OOo additionally supports:
3373archive - .tar.gz or .zip
3374dmg - Mac OS X .dmg
3375installed - installation tree
3376msi - Windows .msi
3377			])
3378			;;
3379		esac
3380	done
3381	PKGFORMAT="$with_package_format"
3382   fi
3383   AC_MSG_RESULT([$PKGFORMAT])
3384   if echo "$PKGFORMAT" | $EGREP rpm 2>&1 >/dev/null; then
3385      AC_MSG_CHECKING([for rpm])
3386      for a in "$RPM" rpmbuild rpm; do
3387         $a --usage >/dev/null 2> /dev/null
3388         if test $? -eq 0; then
3389            RPM=$a
3390            break
3391         else
3392            $a --version >/dev/null 2> /dev/null
3393            if test $? -eq 0; then
3394               RPM=$a
3395               break
3396            fi
3397         fi
3398       done
3399       if test -z "$RPM" ; then
3400          AC_MSG_ERROR([not found])
3401       elif "$RPM" --usage 2>&1 | $EGREP -- -bb >/dev/null; then
3402          RPM_PATH=`which $RPM`
3403          AC_MSG_RESULT([$RPM_PATH])
3404       else
3405          AC_MSG_ERROR([cannot build packages. Try installing rpmbuild.])
3406       fi
3407   fi
3408   if echo "$PKGFORMAT" | $EGREP deb 2>&1 >/dev/null; then
3409      AC_PATH_PROG(DPKG, dpkg, no)
3410      if test "$DPKG" = "no"; then
3411         AC_MSG_ERROR([dpkg needed for deb creation. Install dpkg.])
3412      fi
3413   fi
3414   if echo "PKGFORMAT" | $EGREP osx 2>&1 >/dev/null; then
3415      if test "$_os" = "Darwin"; then
3416         AC_MSG_CHECKING([for PackageMaker availability])
3417         if ! test -x /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker; then
3418            AC_MSG_ERROR([not installed. Please install Apples Dev Tools])
3419         else
3420            AC_MSG_RESULT([ok])
3421         fi
3422      else
3423         AC_MSG_ERROR([PackageMaker needed to build OSX packages and you are not on OSX...])
3424       fi
3425   fi
3426   if echo "$PKGFORMAT" | $EGREP rpm 2>&1 >/dev/null || \
3427      echo "$PKGFORMAT" | $EGREP pkg 2>&1 >/dev/null; then
3428      	if test "$EPM" != "no" && test "$EPM" != "internal"; then
3429           if test "`echo $EPM_VERSION | cut -d'.' -f1`" -lt "4"; then
3430               AC_MSG_CHECKING([whether epm is patched for OOos needs])
3431               if grep "Patched for OpenOffice.org" $EPM >/dev/null 2>/dev/null; then
3432                  AC_MSG_RESULT([yes])
3433               else
3434                  AC_MSG_RESULT([no])
3435                  if echo "$PKGFORMAT" | grep -q rpm; then
3436                      _pt="rpm"
3437                      AC_MSG_WARN([the rpms will need to be installed with --nodeps])
3438                      echo "the rpms will need to be installed with --nodeps" >> warn
3439                  else
3440                      _pt="pkg"
3441                  fi
3442                  AC_MSG_WARN([the ${_pt}s will not be relocateable])
3443                  echo "the ${_pt}s will not be relocateable" >> warn
3444                  AC_MSG_WARN([if you want to make sure installation without --nodeps and
3445                  relocation will work, you need to patch your epm with the
3446                  patch in epm/epm-3.7.patch or build with
3447                  --with-epm=internal which will build a suitable epm])
3448               fi
3449           fi
3450        fi
3451   fi
3452   if echo "$PKGFORMAT" | $EGREP pkg 2>&1 >/dev/null; then
3453      AC_PATH_PROG(PKGMK, pkgmk, no)
3454      if test "$PKGMK" = "no"; then
3455         AC_MSG_ERROR([pkgmk needed for Solaris pkg creation. Install it.])
3456      fi
3457   fi
3458   AC_SUBST(BUILD_EPM)
3459   AC_SUBST(RPM)
3460   AC_SUBST(DPKG)
3461   AC_SUBST(PKGMK)
3462else
3463   AC_MSG_RESULT([no])
3464   EPM=NO
3465   PKGFORMAT=native
3466fi
3467AC_SUBST(EPM)
3468AC_SUBST(PKGFORMAT)
3469
3470dnl ===================================================================
3471dnl Check for gperf
3472dnl ===================================================================
3473AC_PATH_PROG(GPERF, gperf)
3474if test -z "$with_gperf"; then
3475    AC_PATH_PROG(GPERF, gperf)
3476    if test -z "$GPERF"; then
3477       AC_MSG_ERROR([gperf not found but needed. Install it and/or specify --with-gperf=/path/to/it.])
3478    fi
3479else
3480  if test -x "$with_gperf"; then
3481    GPERF=$with_gperf
3482  else
3483    AC_MSG_ERROR([--with-gperf did not point to an executable])
3484  fi
3485fi
3486AC_MSG_CHECKING([gperf version])
3487if test "`$GPERF --version | $EGREP ^GNU\ gperf | $AWK '{ print $3 }' | cut -d. -f1`" -ge "3"; then
3488	AC_MSG_RESULT([OK])
3489   GPERF=$GPERF
3490else
3491	AC_MSG_ERROR([too old, you need at least 3.0.0])
3492fi
3493AC_SUBST(GPERF)
3494
3495dnl ===================================================================
3496dnl Check for building stax
3497dnl ===================================================================
3498AC_MSG_CHECKING([whether to build the stax])
3499if test -f "./stax/download/jsr173_1.0_api.jar"; then
3500   BUILD_STAX=NO
3501   AC_MSG_RESULT([no, will use the prebuilt stax/download/jsr173_1.0_api.jar])
3502else
3503   BUILD_STAX=YES
3504   AC_MSG_RESULT([yes])
3505fi
3506AC_SUBST(BUILD_STAX)
3507
3508dnl ===================================================================
3509dnl Check for building ODK
3510dnl ===================================================================
3511AC_MSG_CHECKING([whether to build the ODK])
3512if test "z$enable_odk" = "z" -o "$enable_odk" != "no"; then
3513   AC_MSG_RESULT([yes])
3514   if test "$WITH_JAVA" != "no"; then
3515   AC_MSG_CHECKING([for external/unowinreg/unowinreg.dll])
3516   if ! test -f "./external/unowinreg/unowinreg.dll"; then
3517      HAVE_UNOWINREG_DLL=no
3518   else
3519      HAVE_UNOWINREG_DLL=yes
3520   fi
3521   if test "$HAVE_UNOWINREG_DLL" = "yes"; then
3522      AC_MSG_RESULT([found])
3523      BUILD_UNOWINREG=NO
3524   else
3525      if test "$_os" = "WINNT"; then
3526         AC_MSG_RESULT([not found, will be built])
3527      else
3528         AC_MSG_WARN([not found, will be cross-built using mingw32])
3529      fi
3530      BUILD_UNOWINREG=YES
3531   fi
3532   if test "$_os" != "WINNT" && test "$BUILD_UNOWINREG" = "YES"; then
3533      if test -z "$WITH_MINGWIN" || test "$WITH_MINGWIN" = "0"; then
3534         AC_MSG_ERROR([for rebuilding unowinreg.dll you need the mingw32 C++ compiler.
3535         Specify mingw32 g++ executable name with --with-mingwin.
3536         Or use prebuilt one from http://tools.openoffice.org/unowinreg_prebuild/680/ and
3537         put it into external/unowinreg])
3538      fi
3539      if echo "$WITH_MINGWIN" | $EGREP -q "/"; then
3540         if ! test -x "$WITH_MINGWIN"; then MINGWCXX=false; else MINGWCXX=`basename $WITH_MINGWIN`; fi
3541      else
3542         AC_CHECK_TOOL(MINGWCXX, $WITH_MINGWIN, false)
3543      fi
3544      if test "$MINGWCXX" = "false"; then
3545         AC_MSG_ERROR(specified MinGW32 C++ cross-compiler not found. Install it or correct name.)
3546      fi
3547      AC_MSG_CHECKING(whether we are using the MinGW32 cross C++ compiler)
3548      if ! echo "`$MINGWCXX -dumpmachine`" | grep -q mingw32; then
3549         AC_MSG_ERROR(no)
3550      else
3551         AC_MSG_RESULT(yes)
3552      fi
3553      if echo "$WITH_MINGWIN" | $EGREP -q "/"; then
3554         if ! test -x "`echo $WITH_MINGWIN | $SED -e s/g++/strip/ | $SED -e s/c++/strip/`"; then MINGSTRIP=false; else MINGWSTRIP=$(basename $(echo $WITH_MINGWIN | $SED -e s/g++/strip/ | $SED -e s/c++/strip/)); fi
3555      else
3556         AC_CHECK_TOOL(MINGWSTRIP, `echo $WITH_MINGWIN | $SED -e s/g++/strip/ | $SED -e s/c++/strip/`, false)
3557      fi
3558      if test "$MINGWSTRIP" = "false"; then
3559         AC_MSG_ERROR(MinGW32 binutils needed. Install them.)
3560      fi
3561      AC_LANG_PUSH([C++])
3562      save_CXX=$CXX
3563      save_CXXCPP=$CXXCPP
3564      CXX=$MINGWCXX
3565      CXXCPP="$MINGWCXX -E"
3566      save_CXXFLAGS=$CXXFLAGS
3567      save_CPPFLAGS=$CPPFLAGS
3568      CXXFLAGS="$CXXFLAGS -I$JAVA_HOME/include"
3569      CPPFLAGS="$CPPFLAGS -I$JAVA_HOME/include"
3570      # LIBS contains -lcrypt etc due to teh AC_CHECK_LIBS which obviously
3571      # do not make sense here (and 'd make the check fail)
3572      save_LIBS=$LIBS
3573      LIBS=""
3574      AC_HAVE_LIBRARY(kernel32)
3575      AC_HAVE_LIBRARY(advapi32)
3576      AC_CHECK_HEADER(windows.h, [], [AC_MSG_ERROR([windows.h missing])])
3577      CXXFLAGS=$save_CXXFLAGS
3578      CPPFLAGS=$save_CPPFLAGS
3579      CXX=$save_CXX
3580      CXXCPP=$save_CXXCPP
3581      LIBS=$save_LIBS
3582      AC_LANG_POP([C++])
3583      fi
3584   fi
3585   BUILD_TYPE="$BUILD_TYPE ODK"
3586else
3587   AC_MSG_RESULT([no])
3588   BUILD_UNOWINREG=NO
3589fi
3590AC_SUBST(BUILD_UNOWINREG)
3591AC_SUBST(MINGWCXX)
3592AC_SUBST(MINGWSTRIP)
3593
3594dnl ===================================================================
3595dnl Check for system stdlibs
3596dnl ===================================================================
3597AC_MSG_CHECKING([whether to provide libstdc++/libgcc_s in the installset])
3598if test -n "$with_system_stdlibs" -o -n "$with_system_libs" && \
3599   test "$with_system_stdlibs" != "no"; then
3600   AC_MSG_RESULT([no])
3601   SYSTEM_STDLIBS=YES
3602else
3603   AC_MSG_RESULT([yes])
3604   SYSTEM_STDLIBS=NO
3605fi
3606AC_SUBST(SYSTEM_STDLIBS)
3607
3608dnl ===================================================================
3609dnl Check for system zlib
3610dnl ===================================================================
3611if test "$_os" = "Darwin" && test "$with_system_zlib" != "no"; then
3612   with_system_zlib=yes
3613fi
3614AC_MSG_CHECKING([which zlib to use])
3615if test -n "$with_system_zlib" -o -n "$with_system_libs" && \
3616	test "$with_system_zlib" != "no"; then
3617    AC_MSG_RESULT([external])
3618    SYSTEM_ZLIB=YES
3619    AC_CHECK_HEADER(zlib.h, [],
3620        [AC_MSG_ERROR(zlib.h not found. install zlib)], [])
3621    AC_CHECK_LIB(z, deflate, [ ZLIB=-lz ],
3622        [AC_MSG_ERROR(zlib not found or functional)], [])
3623else
3624    AC_MSG_RESULT([internal])
3625    SYSTEM_ZLIB=NO
3626    BUILD_TYPE="$BUILD_TYPE ZLIB"
3627fi
3628AC_SUBST(SYSTEM_ZLIB)
3629
3630dnl ===================================================================
3631dnl Check for system jpeg
3632dnl ===================================================================
3633AC_MSG_CHECKING([which jpeg to use])
3634if test -n "$with_system_jpeg" -o -n "$with_system_libs" && \
3635	test "$with_system_jpeg" != "no"; then
3636    AC_MSG_RESULT([external])
3637    SYSTEM_JPEG=YES
3638    AC_CHECK_HEADER(jpeglib.h, [],
3639        [AC_MSG_ERROR(jpeg.h not found. install libjpeg)], [])
3640    AC_CHECK_LIB(jpeg, jpeg_resync_to_restart, [ JPEG3RDLIB=-ljpeg ],
3641	[AC_MSG_CHECKING(jpeg library not found or fuctional)], [])
3642else
3643    AC_MSG_RESULT([internal])
3644    SYSTEM_JPEG=NO
3645    BUILD_TYPE="$BUILD_TYPE JPEG"
3646fi
3647AC_SUBST(SYSTEM_JPEG)
3648
3649dnl ===================================================================
3650dnl Check for system expat
3651dnl ===================================================================
3652AC_MSG_CHECKING([which expat to use])
3653if test -n "$with_system_expat" -o -n "$with_system_libs" && \
3654	test "$with_system_expat" != "no"; then
3655    AC_MSG_RESULT([external])
3656    SYSTEM_EXPAT=YES
3657    AC_CHECK_HEADER(expat.h, [],
3658        [AC_MSG_ERROR(expat.h not found. install expat)], [])
3659    AC_CHECK_LIB(expat, XML_ParserCreate, [],
3660	[AC_MSG_RESULT(expat library not found or functional.)], [])
3661else
3662    AC_MSG_RESULT([internal])
3663    SYSTEM_EXPAT=NO
3664    BUILD_TYPE="$BUILD_TYPE EXPAT"
3665fi
3666AC_SUBST(SYSTEM_EXPAT)
3667
3668dnl ===================================================================
3669dnl Check for system libwpd
3670dnl ===================================================================
3671AC_MSG_CHECKING([which libwpd to use])
3672if test -n "$with_system_libwpd" -o -n "$with_system_libs" && \
3673        test "$with_system_libwpd" != "no"; then
3674    AC_MSG_RESULT([external])
3675    SYSTEM_LIBWPD=YES
3676    PKG_CHECK_MODULES( LIBWPD, libwpd-0.8 )
3677fi
3678AC_SUBST(SYSTEM_LIBWPD)
3679AC_SUBST(LIBWPD_CFLAGS)
3680AC_SUBST(LIBWPD_LIBS)
3681
3682dnl ===================================================================
3683dnl Check for system cppunit
3684dnl ===================================================================
3685AC_MSG_CHECKING([which cppunit to use])
3686if test -n "$with_system_cppunit" -o -n "$with_system_libs" && \
3687        test "$with_system_cppunit" != "no"; then
3688    AC_MSG_RESULT([external])
3689    SYSTEM_CPPUNIT=YES
3690    # might work for earlier, too but go sure:
3691    PKG_CHECK_MODULES( CPPUNIT, cppunit >= 1.12.0 )
3692else
3693    AC_MSG_RESULT([internal])
3694    SYSTEM_CPPUNIT=NO
3695    BUILD_TYPE="$BUILD_TYPE CPPUNIT"
3696fi
3697AC_SUBST(SYSTEM_CPPUNIT)
3698AC_SUBST(CPPUNIT_CFLAGS)
3699AC_SUBST(CPPUNIT_LIBS)
3700
3701dnl ===================================================================
3702dnl Check whether freetype is available
3703dnl ===================================================================
3704if test  "$test_freetype" = "yes"; then
3705   AC_MSG_CHECKING([whether freetype is available])
3706	PKG_CHECK_MODULES( FREETYPE, freetype2 >= 2.0 )
3707fi
3708AC_SUBST(FREETYPE_CFLAGS)
3709AC_SUBST(FREETYPE_LIBS)
3710
3711dnl ===================================================================
3712dnl Check whether freetype2 supports emboldening
3713dnl ===================================================================
3714if test  "$test_freetype" = "yes"; then
3715    save_CPPFLAGS="$CPPFLAGS"
3716    save_LDFLAGS="$LDFLAGS"
3717    save_LIBS="$LIBS"
3718    CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS"
3719    LDFLAGS="$LDFLAGS $FREETYPE_LIBS"
3720    AC_CHECK_LIB(freetype, FT_GlyphSlot_Embolden,
3721                 [USE_FT_EMBOLDEN="YES"], [USE_FT_EMBOLDEN="NO"], [])
3722    LDFLAGS="$save_LDFLAGS"
3723    CPPFLAGS="$save_CPPFLAGS"
3724    LIBS="$save_LIBS"
3725fi
3726AC_SUBST(USE_FT_EMBOLDEN)
3727
3728if test -n "$with_system_libxslt" -o -n "$with_system_libs" && \
3729   test "$with_system_libxslt" != "no"; then
3730    if test -z "$with_system_libxml" -a -z "$with_system_libs" || \
3731      test "$with_system_libxml" = "no"; then
3732      # somehow AC_MSG_WARN won't work...
3733       echo "to prevent incompatibilities between internal libxml2 and libxslt, the office will be build with system-libxml"
3734       echo "to prevent incompatibilities between internal libxml2 and libxslt, the office will be build with system-libxml" >> warn
3735       with_system_libxml=yes
3736    fi
3737fi
3738if test -n "$with_system_libxml" -o -n "$with_system_libs" && \
3739   test "$with_system_libxml" != "no"; then
3740    if test -z "$with_system_libxslt" -a -z "$with_system_libs" || \
3741      test "$with_system_libxslt" = "no"; then
3742      # somehow AC_MSG_WARN won't work...
3743       echo "to prevent incompatibilities between internal libxslt and libxml2, the office will be build with system-libxslt"
3744       echo "to prevent incompatibilities between internal libxslt and libxml2, the office will be build with system-libxslt" >> warn
3745       with_system_libxslt=yes
3746    fi
3747fi
3748
3749dnl ===================================================================
3750dnl Check for system libxslt
3751dnl ===================================================================
3752AC_MSG_CHECKING([which libxslt to use])
3753if test -n "$with_system_libxslt" -o -n "$with_system_libs" -o \
3754       "$_os" = "Darwin" && \
3755   test "$with_system_libxslt" != "no"; then
3756   AC_MSG_RESULT([external])
3757   SYSTEM_LIBXSLT=YES
3758
3759   PKG_CHECK_MODULES_MACHACK(LIBXSLT, xslt-config, libxslt)
3760
3761   dnl Check for xsltproc
3762   AC_PATH_PROG(XSLTPROC, xsltproc, no)
3763   if test "$XSLTPROC" = "no"; then
3764      AC_MSG_ERROR([xsltproc is required])
3765   fi
3766else
3767   AC_MSG_RESULT([internal])
3768   SYSTEM_LIBXSLT=NO
3769   BUILD_TYPE="$BUILD_TYPE LIBXSLT"
3770fi
3771AC_SUBST(SYSTEM_LIBXSLT)
3772AC_SUBST(LIBXSLT_CFLAGS)
3773AC_SUBST(LIBXSLT_LIBS)
3774
3775
3776dnl ===================================================================
3777dnl Check for system libxml
3778dnl ===================================================================
3779AC_MSG_CHECKING([which libxml to use])
3780if test -n "$with_system_libxml" -o -n "$with_system_libs" -o \
3781            "$_os" = "Darwin" && \
3782	test "$with_system_libxml" != "no"; then
3783    AC_MSG_RESULT([external])
3784    SYSTEM_LIBXML=YES
3785    PKG_CHECK_MODULES_MACHACK(LIBXML, xml2-config, libxml-2.0 >= 2.0)
3786    BUILD_TYPE="$BUILD_TYPE LIBXMLSEC"
3787else
3788    AC_MSG_RESULT([internal])
3789    SYSTEM_LIBXML=NO
3790    BUILD_TYPE="$BUILD_TYPE LIBXML2 LIBXMLSEC"
3791fi
3792AC_SUBST(SYSTEM_LIBXML)
3793AC_SUBST(LIBXML_CFLAGS)
3794AC_SUBST(LIBXML_LIBS)
3795
3796dnl ===================================================================
3797dnl Check for system python
3798dnl ===================================================================
3799AC_MSG_CHECKING([which python to use])
3800if test "$_os" = "Darwin" && test "$with_system_python" != "no"; then
3801   with_system_python=yes
3802   AC_MSG_RESULT([compiling against MacOSX10.4u.sdk (python version 2.3)])
3803   PYTHON_CFLAGS="-I/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Python.framework/Versions/2.3/include/python2.3"
3804   PYTHON_LIBS="-framework Python"
3805elif test -n "$with_system_python" -o -n "$with_system_libs" && \
3806	test "$with_system_python" != "no"; then
3807   with_system_python=yes
3808   AC_MSG_RESULT([external])
3809   AM_PATH_PYTHON([2.2])
3810
3811   python_include=`$PYTHON -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('INCLUDEPY');"`
3812   python_version=`$PYTHON -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('VERSION');"`
3813   PYTHON_CFLAGS="-I$python_include"
3814   PYTHON_LIBS="-lpython$python_version"
3815fi
3816if test "$with_system_python" = "yes" ; then
3817   SYSTEM_PYTHON=YES
3818   dnl check if the headers really work:
3819   save_CPPFLAGS="$CPPFLAGS"
3820   CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
3821   AC_CHECK_HEADER(Python.h, [],
3822       [AC_MSG_ERROR(Python headers not found)], [])
3823   CPPFLAGS="$save_CPPFLAGS"
3824else
3825   SYSTEM_PYTHON=NO
3826   BUILD_TYPE="$BUILD_TYPE PYTHON"
3827   AC_MSG_RESULT([internal])
3828   # Embedded python dies without Home set
3829   if test "z$HOME" = "z"; then
3830      export HOME="";
3831   fi
3832   # bz2 tarball and bzip2 is not standard
3833   if test -z "$BZIP2"; then
3834	AC_PATH_PROG( BZIP2, bzip2)
3835	if test -z "$BZIP2"; then
3836   		AC_MSG_ERROR([the internal Python module has a .tar.bz2. You need bzip2])
3837   	fi
3838   fi
3839fi
3840AC_SUBST(SYSTEM_PYTHON)
3841AC_SUBST(PYTHON_CFLAGS)
3842AC_SUBST(PYTHON_LIBS)
3843HOME=`echo $HOME | sed 's:\\\\:/:g'`
3844AC_SUBST(HOME)
3845
3846dnl ===================================================================
3847dnl Check for system berkley db
3848dnl ===================================================================
3849AC_MSG_CHECKING([which db to use])
3850if test -n "$with_system_db" -o -n "$with_system_libs" && \
3851	test "$with_system_db" != "no"; then
3852    SYSTEM_DB=YES
3853    AC_MSG_RESULT([external])
3854    AC_CHECK_HEADER(db.h, [ DB_INCLUDES=/usr/include ],
3855        [
3856             CFLAGS=-I/usr/include/db4
3857             AC_CHECK_HEADER(db4/db.h,
3858             [ DB_INCLUDES=/usr/include/db4 ],
3859             [ AC_MSG_ERROR(no. install the db4 libraries) ], []+             )
3860        ], []
3861    )
3862    AC_MSG_CHECKING([whether db is at least 4.1])
3863    AC_TRY_RUN([
3864#include <db.h>
3865
3866int main(int argc, char **argv) {
3867       if(DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)) return 0;
3868       else return 1;
3869}
3870    ], [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([no. you need at least db 4.1])])
3871    AC_HAVE_LIBRARY(db, [],
3872      [AC_MSG_ERROR([db not installed or functional])], [])
3873    SCPDEFS="$SCPDEFS -DSYSTEM_DB"
3874else
3875    AC_MSG_RESULT([internal])
3876    SYSTEM_DB=NO
3877    BUILD_TYPE="$BUILD_TYPE BERKELEYDB"
3878fi
3879AC_SUBST(SYSTEM_DB)
3880AC_SUBST(DB_VERSION)
3881AC_SUBST(DB_INCLUDES)
3882AC_SUBST(DB_JAR)
3883
3884dnl ===================================================================
3885dnl Check for system lucene
3886dnl ===================================================================
3887AC_MSG_CHECKING([which lucene to use])
3888if test -n "$with_system_lucene" -o -n "$with_system_libs" && \
3889       test "$with_system_lucene" != "no" && test "$with_system_jars" != "no"; then
3890        AC_MSG_RESULT([external])
3891        SYSTEM_LUCENE=YES
3892        if test -z $LUCENE_CORE_JAR; then
3893          AC_CHECK_FILE(/usr/share/java/lucene-core-2.3.jar,
3894            [ LUCENE_CORE_JAR=/usr/share/java/lucene-core-2.3.jar ],
3895            [
3896              AC_CHECK_FILE(/usr/share/java/lucene-core.jar,
3897                [ LUCENE_CORE_JAR=/usr/share/java/lucene-core.jar ],
3898                [ AC_CHECK_FILE(/usr/share/java/lucene.jar,
3899                   [ LUCENE_CORE_JAR=/usr/share/java/lucene.jar ],
3900                   [ AC_MSG_ERROR(lucene-core.jar replacement not found)]
3901                  )
3902                ]
3903              )
3904            ]
3905          )
3906        else
3907          AC_CHECK_FILE($LUCENE_CORE_JAR, [],
3908               [AC_MSG_ERROR(lucene-core.jar not found.)], [])
3909        fi
3910
3911        if test -z $LUCENE_ANALYZERS_JAR; then
3912          AC_CHECK_FILE(/usr/share/java/lucene-analyzers-2.3.jar,
3913            [ LUCENE_ANALYZERS_JAR=/usr/share/java/lucene-analyzers-2.3.jar ],
3914            [
3915              AC_CHECK_FILE(/usr/share/java/lucene-contrib/lucene-analyzers.jar,
3916                [ LUCENE_ANALYZERS_JAR=/usr/share/java/lucene-contrib/lucene-analyzers.jar ],
3917                [ AC_MSG_ERROR(lucene-analyzers.jar replacement not found.)]
3918              )
3919            ]
3920          )
3921        else
3922          AC_CHECK_FILE($LUCENE_CORE_JAR, [],
3923               [ AC_MSG_ERROR(lucene-analyzers.jar not found.)], [])
3924        fi
3925        AC_MSG_CHECKING([whether lucene is version 2.x])
3926        export LUCENE_CORE_JAR
3927        if $PERL -e 'use Archive::Zip;
3928            my $file = "$ENV{'LUCENE_CORE_JAR'}";
3929            my $zip = Archive::Zip->new( $file );
3930            my $mf = $zip->contents ( "META-INF/MANIFEST.MF" );
3931            if ( $mf =~ m/Specification-Version: 2.*/ ) {
3932                exit 0;
3933            } else {
3934                exit 1;
3935            }'; then
3936            AC_MSG_RESULT([yes])
3937         else
3938            AC_MSG_ERROR([no, you need lucene 2])
3939         fi
3940
3941else
3942    AC_MSG_RESULT([internal])
3943    SYSTEM_LUCENE=NO
3944    BUILD_TYPE="$BUILD_TYPE LUCENE"
3945fi
3946AC_SUBST(SYSTEM_LUCENE)
3947AC_SUBST(LUCENE_CORE_JAR)
3948AC_SUBST(LUCENE_ANALYZERS_JAR)
3949
3950AC_MSG_CHECKING([whether to build the MySQL Connector extension])
3951if test -n "$enable_mysql_connector" -a "$enable_mysql_connector" != "no"; then
3952  AC_MSG_RESULT([yes])
3953  ENABLE_MYSQLC=YES
3954  AC_MSG_CHECKING([for mysqlc module])
3955  if test -d mysqlc; then
3956   AC_MSG_RESULT([OK])
3957  else
3958   AC_MSG_ERROR([not existing. get it (did you get the -extensions tarball?)])
3959  fi
3960  BUILD_TYPE="$BUILD_TYPE MYSQLC"
3961else
3962  AC_MSG_RESULT([no])
3963  ENABLE_MYSQLC=NO
3964fi
3965AC_SUBST(ENABLE_MYSQLC)
3966
3967if test "$ENABLE_MYSQLC" = "YES"; then
3968dnl ===================================================================
3969dnl Check for system MySQL
3970dnl ===================================================================
3971AC_MSG_CHECKING([for mysql pre-requisites])
3972if test -n "$with_system_mysql" -o -n "$with_system_libs" && \
3973       test "$with_system_mysql" != "no" && test "$with_system_libs" != "no"; then
3974	AC_MSG_RESULT([external MySQL])
3975	SYSTEM_MYSQL=YES
3976	AC_PATH_PROG( MYSQLCONFIG, mysql_config)
3977	AC_MSG_CHECKING([MySQL version])
3978	if test -z "$MYSQLCONFIG" -o ! -x "$MYSQLCONFIG" ; then
3979		AC_MSG_ERROR([can not find/execute mysql_config]);
3980	fi
3981	MYSQL_VERSION=`$MYSQLCONFIG --version`
3982	MYSQL_MAJOR=`$MYSQLCONFIG --version | cut -d"." -f1`
3983	if test "$MYSQL_MAJOR" -ge "5"; then
3984		AC_MSG_RESULT([OK])
3985	else
3986		AC_MSG_ERROR([too old, use 5.0.x or 5.1.x])
3987	fi
3988	AC_MSG_CHECKING([for MySQL Client library])
3989	MYSQL_INC=`$MYSQLCONFIG --include`
3990	MYSQL_LIB=`$MYSQLCONFIG --libs`
3991	MYSQL_DEFINES=`$MYSQLCONFIG --cflags | sed -e s,$MYSQL_INC,,`
3992	AC_MSG_RESULT([includes $MYSQL_INC, libraries $MYSQL_LIB])
3993else
3994    SYSTEM_MYSQL=NO
3995    if test -n "$with_libmysql_path"; then
3996        AC_MSG_RESULT([external Connector/C (libmysql)])
3997        LIBMYSQL=libmysql.so
3998        if test "$_os" = "Darwin"; then
3999            LIBMYSQL=libmysql.dylib
4000        elif test "$_os" = "WINNT"; then
4001            LIBMYSQL=libmysql.dll
4002        fi
4003        AC_MSG_CHECKING([for $LIBMYSQL])
4004        if test -e "$with_libmysql_path/lib/$LIBMYSQL"; then
4005            AC_MSG_RESULT([found.])
4006            LIBMYSQL_PATH=$with_libmysql_path
4007        else
4008            AC_MSG_ERROR([not found. Please specify proper path in --with-libmysql-path.])
4009        fi
4010    else
4011        AC_MSG_ERROR([not given. Please specify either --with-system-mysql or --with-libmysql-path])
4012    fi
4013fi
4014AC_SUBST(SYSTEM_MYSQL)
4015AC_SUBST(MYSQL_INC)
4016AC_SUBST(MYSQL_LIB)
4017AC_SUBST(MYSQL_DEFINES)
4018AC_SUBST(LIBMYSQL_PATH)
4019
4020AC_LANG_PUSH([C++])
4021dnl ===================================================================
4022dnl Check for system MySQL C++ Connector
4023dnl ===================================================================
4024# FIXME!
4025# who thought this too-generic cppconn dir was a good idea?
4026AC_MSG_CHECKING([MySQL Connector/C++])
4027if test -n "$with_system_mysql_cppconn" -o -n "$with_system_libs" && \
4028		test "$with_system_mysql_cppconn" != "no" && test "$with_system_libs" != "no"; then
4029	AC_MSG_RESULT([external])
4030	SYSTEM_MYSQL_CPPCONN=YES
4031        AC_LANG_PUSH([C++])
4032	AC_CHECK_HEADER(mysql_driver.h, [],
4033					[AC_MSG_ERROR(mysql_driver.h not found. install MySQL C++ Connectivity)], [])
4034	AC_CHECK_LIB(mysqlcppconn, main, [],
4035					[AC_MSG_ERROR(MySQL C++ Connectivity lib not found or functional)], [])
4036   AC_MSG_CHECKING([version])
4037      AC_TRY_RUN([
4038#include <mysql_driver.h>
4039
4040int main(int argc, char **argv) {
4041	sql::Driver *driver;
4042	driver = get_driver_instance();
4043	if (driver->getMajorVersion() > 1 || \
4044	   (driver->getMajorVersion() == 1 && driver->getMinorVersion() > 0) || \
4045	   (driver->getMajorVersion() == 1 && driver->getMinorVersion() == 0 && driver->getPatchVersion() >= 6))
4046        return 0;
4047      else
4048        return 1;
4049}
4050      ], [AC_MSG_RESULT(OK)], [AC_MSG_ERROR([not suitable, we need >= 1.0.6])])
4051        AC_LANG_POP([C++])
4052
4053else
4054	AC_MSG_RESULT([no])
4055	SYSTEM_MYSQL_CPPCONN=
4056fi
4057AC_LANG_POP([C++])
4058AC_SUBST(SYSTEM_MYSQL_CPPCONN)
4059fi
4060
4061dnl ===================================================================
4062dnl Check for system hsqldb
4063dnl ===================================================================
4064AC_MSG_CHECKING([which hsqldb to use])
4065if test -n "$with_system_hsqldb" -o -n "$with_system_libs" && \
4066       test "$with_system_hsqldb" != "no" && test "$with_system_jars" != "no"; then
4067        AC_MSG_RESULT([external])
4068        SYSTEM_HSQLDB=YES
4069        if test -z $HSQLDB_JAR; then
4070               HSQLDB_JAR=/usr/share/java/hsqldb.jar
4071        fi
4072        AC_CHECK_FILE($HSQLDB_JAR, [],
4073               [AC_MSG_ERROR(hsqldb.jar not found.)], [])
4074        AC_MSG_CHECKING([whether hsqldb is 1.8.0.x])
4075        export HSQLDB_JAR
4076        if $PERL -e 'use Archive::Zip;
4077            my $file = "$ENV{'HSQLDB_JAR'}";
4078            my $zip = Archive::Zip->new( $file );
4079            my $mf = $zip->contents ( "META-INF/MANIFEST.MF" );
4080            if ( $mf =~ m/Specification-Version: 1.8.*/ ) {
4081               push @l, split(/\n/, $mf);
4082               foreach my $line (@l) {
4083                  if ($line =~ m/Specification-Version:/) {
4084                      ($t, $version) = split (/:/,$line);
4085                      $version =~ s/^\s//;
4086                      ($a, $b, $c, $d) = split (/\./,$version);
4087                      if ($c == "0" && $d > "8")  {
4088                          exit 0;
4089                      } else {
4090                          exit 1;
4091                      }
4092                  }
4093               }
4094            } else {
4095                exit 1;
4096            }'; then
4097            AC_MSG_RESULT([yes])
4098         else
4099            AC_MSG_ERROR([no, you need hsqldb >= 1.8.0.9 but < 1.8.1])
4100         fi
4101else
4102    AC_MSG_RESULT([internal])
4103    SYSTEM_HSQLDB=NO
4104    BUILD_TYPE="$BUILD_TYPE HSQLDB"
4105fi
4106AC_SUBST(SYSTEM_HSQLDB)
4107AC_SUBST(HSQLDB_JAR)
4108
4109dnl ===================================================================
4110dnl Check for system beanshell
4111dnl ===================================================================
4112AC_MSG_CHECKING([which beanshell to use])
4113if test -n "$with_system_beanshell" -o -n "$with_system_libs" && \
4114       test "$with_system_beanshell" != "no" && test "$with_system_jars" != "no"; then
4115        AC_MSG_RESULT([external])
4116        SYSTEM_BSH=YES
4117        if test -z $BSH_JAR; then
4118               BSH_JAR=/usr/share/java/bsh.jar
4119        fi
4120        AC_CHECK_FILE($BSH_JAR, [],
4121               [AC_MSG_ERROR(bsh.jar not found.)], [])
4122else
4123    AC_MSG_RESULT([internal])
4124    SYSTEM_BSH=NO
4125    BUILD_TYPE="$BUILD_TYPE BSH"
4126fi
4127AC_SUBST(SYSTEM_BSH)
4128AC_SUBST(BSH_JAR)
4129
4130
4131dnl ===================================================================
4132dnl Check for system saxon
4133dnl ===================================================================
4134if test -n "$enable_copyleft" -a "$enable_copyleft" != "no"; then
4135AC_MSG_CHECKING([which saxon to use])
4136if test -n "$with_system_saxon" -o -n "$with_system_libs" && \
4137       test "$with_system_saxon" != "no" && test "$with_system_jars" != "no"; then
4138        AC_MSG_RESULT([external])
4139        SYSTEM_SAXON=YES
4140        if test -z $SAXON_JAR; then
4141          AC_CHECK_FILE(/usr/share/java/saxon9.jar,
4142            [ SAXON_JAR=/usr/share/java/saxon9.jar ],
4143            [
4144              AC_CHECK_FILE(/usr/share/java/saxon.jar,
4145                [ SAXON_JAR=/usr/share/java/saxon.jar ],
4146                [ AC_CHECK_FILE(/usr/share/java/saxon9.jar,
4147                    [ SAXON_JAR=/usr/share/java/saxon9.jar ],
4148                    [ AC_MSG_ERROR(saxon.jar replacement not found)]
4149                  )
4150                ]
4151              )
4152            ]
4153          )
4154        else
4155          AC_CHECK_FILE($SAXON_JAR, [],
4156               [AC_MSG_ERROR(saxon.jar replacement not found.)], [])
4157        fi
4158        if test -n "$SERIALIZER_JAR"; then
4159          AC_CHECK_FILE($SERIALIZER_JAR, [],
4160               [AC_MSG_ERROR(serializer.jar not found.)], [])
4161          AC_SUBST(SERIALIZER_JAR)
4162        fi
4163
4164dnl Saxon comes in two practically available versions, the out-of-date saxonb which
4165dnl supports the java extensions that OOo uses, and the up-to-date saxon he
4166dnl "home edition" version, which is crippled to not support those java extensions.
4167dnl And as an aside the he one also needs to be tweaked to include
4168dnl a META-INF/services to broadcast that it supports the jaxp transform factory
4169
4170        AC_MSG_CHECKING([if saxon works])
4171        cat > saxontest.java <<_ACEOF
4172[import javax.xml.transform.TransformerFactory;
4173import javax.xml.transform.Transformer;
4174import javax.xml.transform.stream.StreamSource;
4175import java.io.*;
4176
4177import net.sf.saxon.FeatureKeys;
4178
4179class saxontest {
4180    public static void main(String[] args) {
4181      System.setProperty("javax.xml.transform.TransformerFactory",
4182        "net.sf.saxon.TransformerFactoryImpl");
4183      try {
4184        TransformerFactory tfactory = TransformerFactory.newInstance();
4185	// some external saxons (Debian, Ubuntu, ...) have this disabled
4186	// per default
4187	tfactory.setAttribute(FeatureKeys.ALLOW_EXTERNAL_FUNCTIONS, new Boolean(true));
4188        System.out.println("TransformerFactory is" +
4189          tfactory.getClass().getName());
4190        Transformer transformer = tfactory.newTransformer(
4191          new StreamSource(new File(args[0])));
4192      } catch(Exception e){
4193        e.printStackTrace(System.err);
4194        System.exit(-1);
4195      }
4196      System.exit(0);
4197    }
4198}
4199]
4200_ACEOF
4201        cat > saxontest.xsl<<_ACEOF
4202[<?xml version="1.0" encoding="UTF-8"?>
4203<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4204 <xsl:template match="/">
4205  <xsl:value-of select="math:sqrt(1)" xmlns:math="java:java.lang.Math"/>
4206 </xsl:template>
4207</xsl:stylesheet>
4208]
4209_ACEOF
4210        javac_cmd="$JAVACOMPILER -cp $SAXON_JAR saxontest.java 1>&2"
4211        AC_TRY_EVAL(javac_cmd)
4212        if test $? = 0 && test -f ./saxontest.class ; then
4213            java_cmd="$JAVAINTERPRETER -cp $SAXON_JAR:. saxontest saxontest.xsl 1>&2"
4214            AC_TRY_EVAL(java_cmd)
4215            if test $? = 0; then
4216              AC_MSG_RESULT([yes])
4217            else
4218              cat saxontest.java >&5
4219              AC_MSG_RESULT([no])
4220              AC_MSG_ERROR([Non-functional saxon jar, e.g. crippled saxon-he instead of saxonb])
4221            fi
4222        else
4223          AC_MSG_RESULT([no])
4224          cat saxontest.java >&5
4225          AC_MSG_ERROR([saxontest could not be compiled, non-functional saxon jar])
4226        fi
4227else
4228    AC_MSG_RESULT([internal])
4229    SYSTEM_SAXON=NO
4230    NEED_SAXON=TRUE
4231fi
4232AC_SUBST(SYSTEM_SAXON)
4233AC_SUBST(SAXON_JAR)
4234
4235if test -n "$NEED_SAXON"; then
4236   BUILD_TYPE="$BUILD_TYPE SAXON"
4237fi
4238fi
4239
4240dnl ===================================================================
4241dnl Check for system curl
4242dnl ===================================================================
4243if test "$_os" = "Darwin" && test "$with_system_curl" != "no"; then
4244   with_system_curl=yes
4245fi
4246AC_MSG_CHECKING([which curl to use])
4247if test -n "$with_system_curl" -o -n "$with_system_libs" && \
4248	test "$with_system_curl" != "no"; then
4249   AC_MSG_RESULT([external])
4250   SYSTEM_CURL=YES
4251
4252   AC_PATH_PROG( CURLCONFIG, curl-config)
4253   if test -z "$CURLCONFIG"; then
4254      AC_MSG_ERROR([install curl to run this script])
4255   fi
4256
4257   # check curl version
4258   AC_MSG_CHECKING([whether curl is >= 7.13.1])
4259   if test "`$CURLCONFIG --version | $AWK -F' ' '{print $2}' | $AWK -F. '{ print $1 }'`" -gt "7" -a \
4260	"`$CURLCONFIG --version | $AWK -F' ' '{print $2}' | $AWK -F. '{ print $2 }'`" -gt "13" -a \
4261	"`$CURLCONFIG --version | $AWK -F' ' '{print $2}' | $AWK -F. '{ print $3 }'`" -gt "1"; then
4262      AC_MSG_ERROR([no, you need at least curl 7.13,1])
4263   else
4264      AC_MSG_RESULT([yes])
4265   fi
4266   CURL_LIBS=`$CURLCONFIG --libs`
4267   CURL_CFLAGS=`$CURLCONFIG --cflags`
4268else
4269   AC_MSG_RESULT([internal])
4270   SYSTEM_CURL=NO
4271   BUILD_TYPE="$BUILD_TYPE CURL"
4272fi
4273AC_SUBST(SYSTEM_CURL)
4274AC_SUBST(CURL_CFLAGS)
4275AC_SUBST(CURL_LIBS)
4276
4277dnl ===================================================================
4278dnl Check for system mdds
4279dnl ===================================================================
4280AC_MSG_CHECKING([which mdds to use])
4281if test -n "$with_system_mdds" -o -n "$with_system_headers" && \
4282	test "$with_system_mdds" != "no"; then
4283    AC_MSG_RESULT([external])
4284    SYSTEM_MDDS=YES
4285    AC_LANG_PUSH([C++])
4286    AC_CHECK_HEADER(mdds/flat_segment_tree.hpp, [],
4287        [AC_MSG_ERROR(mdds/flat_segment_tree.hpp not found. install mdds)], [])
4288    AC_LANG_POP([C++])
4289else
4290   AC_MSG_RESULT([internal])
4291   BUILD_TYPE="$BUILD_TYPE MDDS"
4292   SYSTEM_MDDS=NO
4293fi
4294AC_SUBST(SYSTEM_MDDS)
4295
4296dnl ===================================================================
4297dnl Check for system boost
4298dnl ===================================================================
4299AC_MSG_CHECKING([which boost to use])
4300if test -n "$with_system_boost" -o -n "$with_system_headers" && \
4301	test "$with_system_boost" != "no"; then
4302   AC_MSG_RESULT([external])
4303   SYSTEM_BOOST=YES
4304   AC_LANG_PUSH([C++])
4305   AC_CHECK_HEADER(boost/shared_ptr.hpp, [],
4306       [AC_MSG_ERROR(boost/shared_ptr.hpp not found. install boost)], [])
4307   AC_CHECK_HEADER(boost/spirit/include/classic_core.hpp, [],
4308       [AC_MSG_ERROR(boost/spirit/include/classic_core.hpp not found. install boost >= 1.36)], [])
4309   AC_CHECK_HEADER(boost/function.hpp, [],
4310       [AC_MSG_ERROR(boost/function.hpp not found. install boost)], [])
4311
4312   save_CXXFLAGS=$CXXFLAGS
4313   CXXFLAGS="$CXXFLAGS -fno-exceptions"
4314   AC_MSG_CHECKING([whether boost/function.hpp compiles with -fno-exceptions])
4315   AC_TRY_COMPILE([#include <boost/function.hpp>
4316], [],
4317   ac_cv_cxx_boost_no_exceptons_broken=no, ac_cv_cxx_boost_no_exceptons_broken=yes)
4318
4319   if test "$ac_cv_cxx_boost_no_exceptons_broken" = "yes"; then
4320	AC_MSG_ERROR([no, see https://bugzilla.redhat.com/show_bug.cgi?id=477131])
4321   else
4322  	AC_MSG_RESULT([yes])
4323   fi
4324   CXXFLAGS=$save_CXXFLAGS
4325   AC_LANG_POP([C++])
4326else
4327   AC_MSG_RESULT([internal])
4328   BUILD_TYPE="$BUILD_TYPE BOOST"
4329   SYSTEM_BOOST=NO
4330fi
4331AC_SUBST(SYSTEM_BOOST)
4332
4333dnl ===================================================================
4334dnl Check for system vigra
4335dnl ===================================================================
4336AC_MSG_CHECKING([which vigra to use])
4337if test -n "$with_system_vigra" -o -n "$with_system_headers" && \
4338	test "$with_system_vigra" != "no"; then
4339   AC_MSG_RESULT([external])
4340   SYSTEM_VIGRA=YES
4341   AC_LANG_PUSH([C++])
4342   AC_CHECK_HEADER(vigra/copyimage.hxx, [],
4343       [AC_MSG_ERROR(vigra/copyimage.hxx not found. install vigra)], [])
4344   AC_LANG_POP([C++])
4345else
4346   AC_MSG_RESULT([internal])
4347   BUILD_TYPE="$BUILD_TYPE VIGRA"
4348   SYSTEM_VIGRA=NO
4349fi
4350AC_SUBST(SYSTEM_VIGRA)
4351
4352dnl ===================================================================
4353dnl Check for system odbc
4354dnl ===================================================================
4355AC_MSG_CHECKING([which odbc headers to use])
4356if test -n "$with_system_odbc_headers" -o -n "$with_system_headers" && \
4357	test "$with_system_odbc_headers" != "no"; then
4358   AC_MSG_RESULT([external])
4359   SYSTEM_ODBC_HEADERS=YES
4360
4361   AC_CHECK_HEADER(sqlext.h, [],
4362      [AC_MSG_ERROR(odbc not found. install odbc)], [])
4363else
4364   AC_MSG_RESULT([internal])
4365   SYSTEM_ODBC_HEADERS=NO
4366   BUILD_TYPE="$BUILD_TYPE UNIXODBC"
4367fi
4368AC_SUBST(SYSTEM_ODBC_HEADERS)
4369
4370AC_MSG_CHECKING([whether to enable build of Mozilla/Mozilla NSS-using components])
4371if test "$enable_mozilla" = "no"; then
4372   AC_MSG_RESULT([no])
4373   WITH_MOZILLA=NO
4374   ENABLE_NSS_MODULE=NO
4375else
4376   AC_MSG_RESULT([yes])
4377   WITH_MOZILLA=YES
4378fi
4379AC_SUBST(WITH_MOZILLA)
4380
4381AC_MSG_CHECKING([whether to build Mozilla addressbook connectivity])
4382if test "$enable_mozilla" = "no"; then
4383   AC_MSG_RESULT([no])
4384elif test "$with_system_mozilla" = "yes"; then
4385   AC_MSG_RESULT([no, not possible with system-mozilla])
4386else
4387   AC_MSG_RESULT([yes])
4388fi
4389
4390AC_MSG_CHECKING([whether to build XML Security support])
4391if test "$enable_mozilla" = "no"; then
4392   AC_MSG_RESULT([no, since Mozilla (NSS) disabled but needed])
4393else
4394   AC_MSG_RESULT([yes])
4395fi
4396
4397AC_MSG_CHECKING([whether to build LDAP configuration backend])
4398if test -z "$enable_ldap" || test "$enable_ldap" = "yes"; then
4399   if test "$enable_mozilla" = "yes" || test "$with_openldap" = "yes"; then
4400      AC_MSG_RESULT([yes])
4401      WITH_LDAP=YES
4402   else
4403      AC_MSG_RESULT([no. Either Mozilla or OpenLDAP needed])
4404      WITH_LDAP=NO
4405   fi
4406else
4407   AC_MSG_RESULT([no])
4408   WITH_LDAP=NO
4409fi
4410
4411if test "$WITH_LDAP" = "YES"; then
4412   dnl ===================================================================
4413   dnl Test whether we want to use the Mozilla or the OpenLDAP LDAP SDK
4414   dnl ===================================================================
4415   AC_MSG_CHECKING([which LDAP SDK to use])
4416   if test -n "$with_openldap" && test "$with_openldap" != "no"; then
4417  	   AC_MSG_RESULT([OpenLDAP])
4418	   WITH_OPENLDAP=YES
4419	   AC_CHECK_HEADERS(ldap.h, [],
4420		   [AC_MSG_ERROR(ldap.h not found. install openldap libs)], [])
4421	   AC_CHECK_LIB(ldap, ldap_simple_bind_s, [],
4422		   [AC_MSG_ERROR(openldap lib not found or functional)], [])
4423	   # rumours say that OpenLDAP doesn't have that function. I looked and
4424	   # it has it. Test for it to be sure
4425         AC_CHECK_LIB(ldap, ldap_set_option, [],
4426                [AC_MSG_ERROR(openldap lib not found or functional)], [])
4427   else
4428	   AC_MSG_RESULT([Netscape/Mozilla])
4429	   # TODO. Actually do a sanity check and check for
4430	   # LDAP_OPT_SIZELIMIT and LDAP_X_OPT_CONNECT_TIMEOUT
4431	   WITH_OPENLDAP=NO
4432   fi
4433fi
4434AC_SUBST(WITH_LDAP)
4435AC_SUBST(WITH_OPENLDAP)
4436
4437dnl ===================================================================
4438dnl Check for system mozilla
4439dnl ===================================================================
4440AC_MSG_CHECKING([which mozilla to use])
4441if test -n "$with_system_mozilla" && test "$with_system_mozilla" != "no"; then
4442    AC_MSG_RESULT([external])
4443    SYSTEM_MOZILLA=YES
4444    ENABLE_NSS_MODULE=NO
4445    enable_nss_module=no
4446    AC_MSG_CHECKING([which Mozilla flavour to use])
4447    if test -n "$with_system_mozilla" && test "$with_system_mozilla" = "libxul"; then
4448      MOZ_FLAVOUR=libxul
4449    elif test -n "$with_system_mozilla" && test "$with_system_mozilla" = "xulrunner"; then
4450      MOZ_FLAVOUR=xulrunner
4451    elif test -n "$with_system_mozilla" && test "$with_system_mozilla" = "seamonkey"; then
4452      MOZ_FLAVOUR=seamonkey
4453    elif test -n "$with_system_mozilla" && test "$with_system_mozilla" = "firefox"; then
4454      MOZ_FLAVOUR=firefox
4455    elif test -n "$with_system_mozilla" && test "$with_system_mozilla" = "mozilla"; then
4456      MOZ_FLAVOUR=mozilla
4457    else
4458      MOZ_FLAVOUR=libxul
4459    fi
4460    tmp=`echo $MOZ_FLAVOUR | $PERL -e 'print ucfirst(<STDIN>);'`
4461    AC_MSG_RESULT($tmp)
4462
4463    PKG_CHECK_MODULES( MOZ_NSS, nss, STANDALONENSS="TRUE", STANDALONENSS="" )
4464    if test -z "$STANDALONENSS"; then
4465        PKG_CHECK_MODULES( MOZ_NSS, $MOZ_FLAVOUR-nss )
4466    else
4467        NSS_LIB="-L`$PKG_CONFIG --variable=libdir nss`"
4468        AC_SUBST(NSS_LIB)
4469    fi
4470
4471    if $PKG_CONFIG --exists nspr ; then
4472      PKG_CHECK_MODULES( MOZ_NSPR, nspr )
4473      NSPR_LIB="-L`$PKG_CONFIG --variable=libdir nspr`"
4474      AC_SUBST(NSPR_LIB)
4475    else
4476      PKG_CHECK_MODULES( MOZ_NSPR, $MOZ_FLAVOUR-nspr )
4477    fi
4478
4479    if test "$MOZ_FLAVOUR" != "libxul"; then
4480      PKG_CHECK_MODULES( MOZILLAXPCOM, $MOZ_FLAVOUR-xpcom, HASXPCOM="TRUE", HASXPCOM="" )
4481      MOZ_INC=`$PKG_CONFIG --variable=includedir $MOZ_FLAVOUR-xpcom`
4482      MOZ_LIB=`$PKG_CONFIG --variable=libdir $MOZ_FLAVOUR-xpcom`
4483    fi
4484
4485    if test -z "$HASXPCOM"; then
4486      PKG_CHECK_MODULES( MOZILLAXPCOM, libxul )
4487      MOZ_INC=`$PKG_CONFIG --variable=includedir libxul`
4488      MOZ_LIB=`$PKG_CONFIG --variable=libdir libxul`
4489      if ! test -e "$MOZ_LIB/libxul.so"; then
4490         MOZ_LIB=`$PKG_CONFIG --variable=sdkdir libxul`
4491         if test -e "$MOZ_LIB/sdk/lib/libxul.so"; then
4492            MOZ_LIB="$MOZ_LIB/sdk/lib"
4493         fi
4494      fi
4495    fi
4496
4497    save_CPPFLAGS="$CPPFLAGS"
4498    save_LDFLAGS="$LDFLAGS"
4499    save_LIBS="$LIBS"
4500    CPPFLAGS="$CPPFLAGS $MOZ_NSS_CFLAGS"
4501    LDFLAGS="$LDFLAGS $MOZ_NSS_LIBS"
4502    AC_CHECK_LIB(nss3, PK11_GetCertFromPrivateKey, [],
4503      [AC_MSG_ERROR(PK11_GetCertFromPrivateKey missing but needed.
4504See https://bugzilla.mozilla.org/show_bug.cgi?id=262274.
4505Fixed since nss 3.9.3 (contained by e.g. mozilla >= 1.7.5))], [])
4506    LDFLAGS="$save_LDFLAGS"
4507    CPPFLAGS="$save_CPPFLAGS"
4508    LIBS="$save_LIBS"
4509
4510    MOZ_LIB_XPCOM=$MOZILLAXPCOM_LIBS
4511    if test "$WITH_LDAP" != "NO" && test "$WITH_OPENLDAP" != "YES"; then
4512      AC_MSG_CHECKING([whether $tmp was compiled with --enable-ldap])
4513      if test -d "$MOZ_INC/ldap"; then
4514         AC_MSG_RESULT([yes])
4515         MOZ_LDAP_CFLAGS="-I$MOZ_INC"
4516      else
4517        AC_MSG_ERROR([no.
4518Could not find LDAP header include files in $MOZ_INC/ldap.
4519Please recompile $tmp with --enable-ldap or use --with-openldap.])
4520      fi
4521    fi
4522
4523    #e.g. http://fedoraproject.org/wiki/Releases/FeatureXULRunnerAPIChanges
4524    #the plugin pkg-config etc. reverts to "mozilla-plugin" with libxul
4525    if test "$MOZ_FLAVOUR" = "libxul"; then
4526        MOZ_FLAVOUR="mozilla"
4527    fi
4528
4529elif test "$enable_mozilla" = "no"; then
4530    AC_MSG_RESULT([none])
4531    WITH_MOZILLA=NO
4532    ENABLE_NSS_MODULE=NO
4533    enable_nss_module=no
4534else
4535    AC_MSG_RESULT([internal])
4536    SYSTEM_MOZILLA=NO
4537    BUILD_TYPE="$BUILD_TYPE MOZ"
4538if test -z "$with_mozilla_version"; then
4539   MOZILLA_VERSION=
4540else
4541   AC_MSG_CHECKING([which mozilla version to build])
4542   MOZILLA_VERSION=$with_mozilla_version
4543   enable_build_mozilla=1
4544   AC_MSG_RESULT([$MOZILLA_VERSION])
4545fi
4546
4547AC_SUBST(MOZILLA_VERSION)
4548
4549AC_MSG_CHECKING([for toolkit mozilla should use])
4550if test -z "$with_mozilla_toolkit"; then
4551   if test "$_os" != "WINNT" ; then
4552      if test "$_os" = "Darwin" ; then
4553         MOZILLA_TOOLKIT=mac
4554         AC_MSG_RESULT([mac])
4555      else
4556         MOZILLA_TOOLKIT=gtk2
4557         AC_MSG_RESULT([gtk2])
4558      fi
4559   fi
4560else
4561   MOZILLA_TOOLKIT=$with_mozilla_toolkit
4562   enable_build_mozilla=1
4563   AC_MSG_RESULT([$MOZILLA_TOOLKIT])
4564fi
4565#if test "$_os" = "Darwin" && test "$MOZILLA_TOOLKIT" != "gtk2"; then
4566#   #only gtk2 toolkit supported - xlib or cocoa nees glib1 and libIDL1 - the latter is not
4567#   #available using fink, mac (carbon) doesn't work because xcode installs conflicting headers
4568#   AC_MSG_ERROR([Only gtk2 toolkit supported on Mac, sorry.])
4569#fi
4570
4571AC_SUBST(MOZILLA_TOOLKIT)
4572
4573# default to enabling build mozilla
4574if test "$enable_build_mozilla" != "no"; then
4575      enable_build_mozilla=yes
4576else
4577      enable_build_mozilla=
4578fi
4579
4580AC_MSG_CHECKING([whether to build Mozilla/SeaMonkey])
4581if test -n "$enable_build_mozilla"; then
4582   BUILD_MOZAB="TRUE"
4583   AC_MSG_RESULT([yes])
4584else
4585   BUILD_MOZAB=""
4586   AC_MSG_RESULT([no])
4587fi
4588
4589AC_MSG_CHECKING([whether to build provided NSS module])
4590if test "$enable_nss_module" != "no"; then
4591   ENABLE_NSS_MODULE="YES"
4592   BUILD_TYPE="$BUILD_TYPE NSS"
4593   AC_MSG_RESULT([yes])
4594   if test "$_os" = "WINNT"; then
4595      AC_MSG_CHECKING([for Mozilla build tooling])
4596      if test -z "$MOZILLABUILD" ; then
4597AC_MSG_ERROR([Mozilla build tooling not found.
4598Use the --with-mozilla-build option after installling the tools obtained
4599from http://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/win32])
4600      else
4601         if test \( "$WITH_MINGWIN" = "yes" \) ; then
4602            if test ! -d "$MOZILLABUILD" ; then
4603AC_MSG_ERROR([Mozilla build tooling incomplete!])
4604            else
4605               AC_MSG_RESULT([ok])
4606            fi
4607         else
4608            if test ! -d "$MOZILLABUILD/moztools" \
4609               -o ! -d "$MOZILLABUILD/msys" ; then
4610AC_MSG_ERROR([Mozilla build tooling incomplete!])
4611            else
4612               AC_MSG_RESULT([ok])
4613            fi
4614         fi
4615      fi
4616   fi
4617else
4618   ENABLE_NSS_MODULE="NO"
4619   AC_MSG_RESULT([no])
4620fi
4621
4622if test "$BUILD_MOZAB" = "TRUE"; then
4623  if test "$_os" = "WINNT"; then
4624    if test "$WITH_MINGWIN" != "yes"; then
4625      # compiling with MSVC. Only supported platform here is MSVS2005 at the moment.
4626      if test "$MSVSVER" != "2005"; then
4627        AC_MSG_ERROR([Building SeaMonkey is supported with Microsoft Visual Studio .NET 2005 only.])
4628      fi
4629    else
4630      AC_MSG_WARN([Building SeaMonkey with mingwin is not tested, and likely to break.])
4631      echo "Building SeaMonkey with mingwin is not tested, and likely to break." >> warn
4632    fi
4633  fi
4634
4635   if test -z "$MOZILLA_VERSION"; then
4636      MOZILLA_VERSION=1.1.14
4637   fi
4638   MOZILLA_SOURCE_VERSION="seamonkey-${MOZILLA_VERSION}.source"
4639   MOZILLA_FETCH_FILE=`grep $MOZILLA_SOURCE_VERSION ooo.lst`
4640   AC_MSG_CHECKING([for mozilla sources])
4641   if test -z "$MOZILLA_FETCH_FILE"; then
4642      AC_MSG_RESULT([not found])
4643      HAVE_MOZILLA_TARBALL=n
4644   else
4645      AC_MSG_CHECKING([for $MOZILLA_FETCH_FILE])
4646      if test ! -e "$TARFILE_LOCATION/$MOZILLA_FETCH_FILE"; then
4647         if test -z "$DO_FETCH"; then
4648            AC_MSG_RESULT([will be fetched])
4649            HAVE_MOZILLA_TARBALL=y
4650         else
4651            AC_MSG_RESULT([not found])
4652            HAVE_MOZILLA_TARBALL=n
4653         fi
4654      else
4655         AC_MSG_RESULT([found])
4656         HAVE_MOZILLA_TARBALL=y
4657      fi
4658   fi
4659   if test "$HAVE_MOZILLA_TARBALL" != "y"; then
4660      AC_MSG_ERROR([Mozilla/SeaMonkey source archive not found.
4661Use "./fetch_tarballs.sh ooo.lst" to download.])
4662   fi
4663   if test "$_os" = "WINNT"; then
4664      AC_MSG_CHECKING([for moztools binaries])
4665      if test ! -e "$TARFILE_LOCATION/vc8-moztools.zip" ; then
4666        AC_MSG_ERROR([The following file is missing in $TARFILE_LOCATION: vc8-moztools.zip
4667(from ftp://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/win32/historic/vc8/)])
4668      else
4669         AC_MSG_RESULT([ok])
4670      fi
4671   elif test "$_os" = "Darwin"; then
4672      if test "$MOZILLA_TOOLKIT" = "gtk2"; then
4673         AC_MSG_NOTICE([checking whether mozilla can be built...])
4674         PKG_CHECK_MODULES(MOZGTK2, gtk+-2.0 >= 2.4 libIDL-2.0 >= 0.8, AC_MSG_NOTICE([OK - can build mozilla]), AC_MSG_ERROR([Prerequisites to build mozilla not met. Either use the precompiled mozilla binaries or install the missing packages]))
4675      else
4676         PKG_CHECK_MODULES(MOZLIBREQ, libIDL-2.0 >= 0.6.3,  MOZIDL="TRUE", MOZIDL="")
4677         if test -z "$MOZIDL"; then
4678            AC_MSG_ERROR([libIDL 0.6.3 or newer is needed to build mozilla with mac toolkit.])
4679         fi
4680      fi
4681   else
4682      # Generic Unix/Linux section
4683      if test "$MOZILLA_TOOLKIT" = "gtk2"; then
4684         PKG_CHECK_MODULES(MOZLIBREQ, gtk+-2.0, MOZGTK="TRUE", MOZGTK="")
4685         if test -z "$MOZGTK"; then
4686            AC_MSG_ERROR([GTK2 is needed to build mozilla.])
4687         fi
4688         PKG_CHECK_MODULES(MOZLIBREQ, libIDL-2.0 >= 0.8.0, MOZIDL="TRUE", MOZIDL="")
4689         if test -z "$MOZIDL"; then
4690            AC_MSG_ERROR([libIDL >= 0.8.0 is needed when using GTK2 to build mozilla.])
4691         fi
4692      else
4693         PKG_CHECK_MODULES(MOZLIBREQ, gtk+ >= 1.2.3, MOZGTK="TRUE", MOZGTK="")
4694         if test -z "$MOZGTK"; then
4695            AC_MSG_ERROR([gtk 1.2 is needed when not using GTK2 to build mozilla.])
4696         fi
4697         PKG_CHECK_MODULES(MOZLIBREQ, libidl >= 0.6.3 libidl <= 0.6.8, MOZIDL="TRUE", MOZIDL="")
4698         if test -z "$MOZIDL"; then
4699            AC_MSG_ERROR([libIDL 0.6.3 - 0.6.8 is needed when not using GTK2 to build mozilla.])
4700         fi
4701      fi
4702   fi
4703fi
4704
4705AC_SUBST(BUILD_MOZAB)
4706
4707fi
4708AC_SUBST(ENABLE_NSS_MODULE)
4709AC_SUBST(MOZILLABUILD)
4710AC_SUBST(SYSTEM_MOZILLA)
4711AC_SUBST(MOZ_FLAVOUR)
4712AC_SUBST(MOZ_INC)
4713AC_SUBST(MOZ_LIB)
4714AC_SUBST(MOZ_LIB_XPCOM)
4715AC_SUBST(MOZ_NSPR_CFLAGS)
4716AC_SUBST(MOZ_NSS_CFLAGS)
4717AC_SUBST(MOZ_LDAP_CFLAGS)
4718
4719dnl ===================================================================
4720dnl Check for system sane
4721dnl ===================================================================
4722AC_MSG_CHECKING([which sane header to use])
4723if test -n "$with_system_sane_header" -o -n "$with_system_headers" && \
4724	test "$with_system_sane_header" != "no"; then
4725   AC_MSG_RESULT([external])
4726   SYSTEM_SANE_HEADER=YES
4727   AC_CHECK_HEADER(sane/sane.h, [],
4728      [AC_MSG_ERROR(sane not found. install sane)], [])
4729else
4730   AC_MSG_RESULT([internal])
4731   SYSTEM_SANE_HEADER=NO
4732   BUILD_TYPE="$BUILD_TYPE SANE"
4733fi
4734AC_SUBST(SYSTEM_SANE_HEADER)
4735
4736dnl ===================================================================
4737dnl Check for system icu
4738dnl ===================================================================
4739AC_MSG_CHECKING([which icu to use])
4740if test -n "$with_system_icu" -o -n "$with_system_libs" && \
4741	test "$with_system_icu" != "no"; then
4742   AC_MSG_RESULT([external])
4743   SYSTEM_ICU=YES
4744   AC_LANG_PUSH([C++])
4745   AC_MSG_CHECKING([for unicode/rbbi.h])
4746   AC_TRY_CPP(unicode/rbbi.h, AC_MSG_RESULT([checked.]), AC_MSG_ERROR([icu headers not found.]))
4747   AC_LANG_POP([C++])
4748   AC_PATH_PROG(SYSTEM_GENBRK, genbrk, [], [$PATH:/usr/sbin:/sbin])
4749   if test -z "$SYSTEM_GENBRK"; then
4750      AC_MSG_ERROR([\"genbrk\" not found in \$PATH, install the icu development tool \"genbrk"\])
4751   fi
4752   AC_PATH_PROG(SYSTEM_GENCCODE, genccode, [], [$PATH:/usr/sbin:/sbin])
4753   if test -z "$SYSTEM_GENCCODE"; then
4754      AC_MSG_ERROR([\"genccode\" not found in \$PATH, install the icu development tool \"genccode"\])
4755   fi
4756   AC_PATH_PROG(SYSTEM_GENCMN, gencmn, [], [$PATH:/usr/sbin:/sbin])
4757   if test -z "$SYSTEM_GENCMN"; then
4758      AC_MSG_ERROR([\"gencmn\" not found in \$PATH, install the icu development tool \"gencmn"\])
4759   fi
4760
4761   AC_PATH_PROG( ICUCONFIG, icu-config)
4762   AC_MSG_CHECKING([ICU version])
4763   ICU_VERSION=`$ICUCONFIG --version`
4764   ICU_MAJOR=`$ICUCONFIG --version | cut -d"." -f1`
4765   ICU_MINOR=`$ICUCONFIG --version | cut -d"." -f2`
4766   ICU_MICRO=`$ICUCONFIG --version | cut -d"." -f3`
4767
4768   if test "$ICU_MAJOR" -ge "4"; then
4769      AC_MSG_RESULT([OK])
4770   else
4771      AC_MSG_ERROR([not suitable, only >= 4.0 supported currently])
4772   fi
4773
4774else
4775    AC_MSG_RESULT([internal])
4776    SYSTEM_ICU=NO
4777    BUILD_TYPE="$BUILD_TYPE ICU"
4778fi
4779AC_SUBST(SYSTEM_ICU)
4780AC_SUBST(SYSTEM_GENBRK)
4781AC_SUBST(SYSTEM_GENCCODE)
4782AC_SUBST(SYSTEM_GENCMN)
4783AC_SUBST(ICU_MAJOR)
4784AC_SUBST(ICU_MINOR)
4785AC_SUBST(ICU_MICRO)
4786
4787dnl ===================================================================
4788dnl Graphite
4789dnl ===================================================================
4790
4791AC_MSG_CHECKING([whether to enable graphite support])
4792if test "$_os" = "WINNT" -o "$_os" = "Linux" && test "z$enable_graphite" = "z" -o "$enable_graphite" != "no" ; then
4793    AC_MSG_RESULT([yes])
4794    ENABLE_GRAPHITE="TRUE"
4795    AC_MSG_CHECKING([which graphite to use])
4796    if test -n "$with_system_graphite" -o -n "$with_system_libs" && \
4797        test "$with_system_graphite" != "no"; then
4798        AC_MSG_RESULT([external])
4799        SYSTEM_GRAPHITE=YES
4800        PKG_CHECK_MODULES( GRAPHITE, silgraphite )
4801    else
4802        AC_MSG_RESULT([internal])
4803        SYSTEM_GRAPHITE=NO
4804        BUILD_TYPE="$BUILD_TYPE GRAPHITE"
4805    fi
4806else
4807   AC_MSG_RESULT([no])
4808fi
4809AC_SUBST(ENABLE_GRAPHITE)
4810AC_SUBST(SYSTEM_GRAPHITE)
4811AC_SUBST(GRAPHITE_LIBS)
4812AC_SUBST(GRAPHITE_CFLAGS)
4813
4814dnl ===================================================================
4815dnl Checks for libraries.
4816dnl ===================================================================
4817dnl Check for Mac OS X native GUI, which may is now required; the X11 build is no longer supported
4818dnl See if we have the AppKit framework for building with Quartz graphics.
4819
4820if test  "$_os" = "Darwin"; then
4821   if test "x$with_x" = "xyes"; then
4822      AC_MSG_ERROR([X11 build is no longer supported on MacOSX, please use the native aqua build])
4823   else
4824      AC_MSG_CHECKING([for /System/Library/Frameworks/AppKit.framework])
4825      if test -d "/System/Library/Frameworks/AppKit.framework/"; then
4826         AC_MSG_RESULT([yes])
4827         x_includes="no_x_includes"
4828         x_libraries="no_x_libraries"
4829         dnl disable some things used on other Unix versions but not on the aqua build
4830         enable_gtk=no
4831         enable_cups=no
4832         ENABLE_CUPS=""
4833         AC_SUBST(ENABLE_CUPS)
4834      else
4835         AC_MSG_ERROR([No AppKit.framewrok found])
4836      fi
4837   fi
4838fi
4839
4840dnl ***************************************
4841dnl testing for X libraries and includes...
4842dnl ***************************************
4843if test "$_os" = "Darwin" -a "x$x_includes" = "xno_x_includes"; then
4844   echo "Do Nothing for _os = Darwin"
4845   dnl Mac OS X using Aqua graphics. Don't check for X11.
4846   :
4847elif test "$_os" = "OS2" ; then
4848   echo "Do Nothing for _os = OS2. Don't check for X11."
4849   dnl OS/2 uses native graphics. Don't check for X11.
4850   :
4851elif test "$_os" != "WINNT" ; then
4852   AC_PATH_X
4853   AC_PATH_XTRA
4854   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
4855
4856   if test "x$x_includes" = "x"; then
4857     x_includes="default_x_includes"
4858   fi
4859   if test "x$x_libraries" = "x"; then
4860     x_libraries="default_x_libraries"
4861   fi
4862   dnl The variables $x_libraries and $x_includes are set.
4863   if test -z "$x_libraries"; then
4864      AC_MSG_ERROR([No X libraries found]) # Exit
4865   fi
4866   if test -z "$x_includes"; then
4867      AC_MSG_ERROR([No X includes found]) # Exit
4868   fi
4869   CFLAGS=$X_CFLAGS
4870   LDFLAGS="$X_LDFLAGS $X_LIBS"
4871   AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS", [AC_MSG_ERROR([X Development libraries not found])])
4872   dnl Check if the XauDisposeAuth symbol is provided by libXau.
4873   AC_CHECK_LIB(Xau, XauDisposeAuth, XAU_LIBS="-lXau", [])
4874else
4875   x_includes="no_x_includes"
4876   x_libraries="no_x_libraries"
4877fi
4878if test -z "$x_includes"; then
4879   x_includes="no_x_includes"
4880fi
4881if test -z "$x_libraries"; then
4882   x_libraries="no_x_libraries"
4883fi
4884if test "$x_includes" = "default_x_includes"; then
4885   XINC="/usr/include"
4886else
4887   XINC="$x_includes"
4888fi
4889AC_SUBST(XINC)
4890if test "$x_libraries" = "default_x_libraries"; then
4891   XLIB=`$PKG_CONFIG --variable=libdir x11`
4892   if test "x$XLIB" = x; then
4893         XLIB="/usr/lib"
4894   fi
4895else
4896   XLIB="$x_libraries"
4897fi
4898AC_SUBST(XLIB)
4899AC_SUBST(XAU_LIBS)
4900
4901if test "$_os" != "WINNT" -a "$_os" != "OS2" -a "$_os" != "Darwin"; then
4902   dnl ===================================================================
4903   dnl Check for using Xaw
4904   dnl ===================================================================
4905   AC_MSG_CHECKING([whether to use Xaw])
4906   if test "$enable_Xaw" = "no"; then
4907       DISABLE_XAW=TRUE
4908       AC_MSG_RESULT([no])
4909       AC_CHECK_HEADERS(X11/Composite.h,[],[AC_MSG_ERROR([Xt include headers not found])],
4910         [#include <X11/Intrinsic.h>])
4911   else
4912       AC_MSG_RESULT([yes])
4913       AC_CHECK_HEADERS(X11/Xaw/Label.h,[],[AC_MSG_ERROR([Xaw include headers not found])],
4914         [#include <X11/Intrinsic.h>])
4915       AC_CHECK_LIB(Xaw, main, [],
4916           [AC_MSG_ERROR(Xaw library not found or functional)], [])
4917   fi
4918fi
4919AC_SUBST(DISABLE_XAW)
4920
4921
4922
4923dnl ===================================================================
4924dnl Check if fontconfig/fontconfig.h is available
4925dnl ===================================================================
4926if test "$ENABLE_FONTCONFIG" = "TRUE" ; then
4927    AC_CHECK_HEADER(fontconfig/fontconfig.h, [],
4928                    [AC_MSG_ERROR([fontconfig/fontconfig.h could not be found. libfontconfig1-dev or fontconfig???-devel missing?])], [])
4929    AC_MSG_CHECKING([whether fontconfig is >= 2.2.0])
4930    AC_TRY_RUN([
4931#include <fontconfig/fontconfig.h>
4932
4933int main(int argc, char **argv) {
4934	if(FC_MAJOR > 2 || (FC_MAJOR == 2 && FC_MINOR >= 2)) return 0;
4935	else return 1;
4936}
4937], [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([no, fontconfig >= 2.2.0 needed])])
4938fi
4939
4940dnl ===================================================================
4941dnl Check for system Xrender
4942dnl ===================================================================
4943AC_MSG_CHECKING([whether to link to Xrender])
4944if test -n "$enable_xrender_link" -a "$enable_xrender_link" != "no"; then
4945   AC_MSG_RESULT([yes])
4946   XRENDER_LINK=YES
4947   with_system_xrender_headers=yes
4948else
4949   AC_MSG_RESULT([no, dynamically open it])
4950   XRENDER_LINK=NO
4951fi
4952AC_MSG_CHECKING([which Xrender headers to use])
4953if test -n "$with_system_xrender_headers" -o -n "$with_system_headers" && \
4954	test "$with_system_xrender_headers" != "no"; then
4955   AC_MSG_RESULT([external])
4956   SYSTEM_XRENDER_HEADERS=YES
4957   AC_CHECK_HEADER(X11/extensions/Xrender.h, [],
4958      [AC_MSG_ERROR(Xrender not found. install X)], [])
4959else
4960   AC_MSG_RESULT([internal])
4961   SYSTEM_XRENDER_HEADERS=NO
4962   BUILD_TYPE="$BUILD_TYPE X11_EXTENSIONS"
4963fi
4964if test "$XRENDER_LINK" = "YES"; then
4965   AC_CHECK_LIB(Xrender, XRenderQueryVersion, [],
4966      [AC_MSG_ERROR(libXrender not found or functional)], [])
4967fi
4968AC_SUBST(SYSTEM_XRENDER_HEADERS)
4969AC_SUBST(XRENDER_LINK)
4970
4971dnl ===================================================================
4972dnl Check for XRandr
4973dnl ===================================================================
4974AC_MSG_CHECKING([whether to enable RandR support])
4975if test "$test_randr" = "yes" -a \( "$enable_randr" = "yes" -o "$enable_randr" = "TRUE" \) ; then
4976   if test -z "$enable_randr_link" -o "$enable_randr_link" = "no"; then
4977	  XRANDR_DLOPEN="TRUE"
4978	  AC_MSG_RESULT([resorting to dlopen libXrandr at runtime])
4979   else
4980	  XRANDR_DLOPEN="FALSE"
4981      PKG_CHECK_MODULES(XRANDR, xrandr >= 1.2, ENABLE_RANDR="TRUE", ENABLE_RANDR="")
4982      if test "$ENABLE_RANDR" != "TRUE"; then
4983         AC_CHECK_HEADER(X11/extensions/Xrandr.h, [],
4984                        [AC_MSG_ERROR([X11/extensions/Xrandr.h could not be found. X11 dev missing?])], [])
4985         XRANDR_CFLAGS=" "
4986         AC_CHECK_LIB(Xrandr, XRRQueryExtension, [],
4987              [ AC_MSG_ERROR(libXrandr not found or functional) ], [])
4988         XRANDR_LIBS="-lXrandr "
4989         ENABLE_RANDR="TRUE"
4990	     AC_MSG_RESULT([enabling RandR support])
4991      fi
4992   fi
4993else
4994   ENABLE_RANDR=""
4995   AC_MSG_RESULT([no])
4996fi
4997AC_SUBST(XRANDR_DLOPEN)
4998AC_SUBST(XRANDR_CFLAGS)
4999AC_SUBST(XRANDR_LIBS)
5000AC_SUBST(ENABLE_RANDR)
5001
5002dnl ===================================================================
5003dnl Check for system neon
5004dnl ===================================================================
5005AC_MSG_CHECKING([which neon is used])
5006if test -n "$with_system_neon" -o -n "$with_system_libs" && \
5007	test "$with_system_neon" != "no"; then
5008        AC_MSG_RESULT([external])
5009        PKG_CHECK_MODULES(NEON, neon >= 0.26.0, , AC_MSG_ERROR([you need neon >= 0.26.x for system-neon]))
5010        NEON_VERSION="`$PKG_CONFIG --modversion neon | $SED 's/\.//g'`"
5011        NEON_CFLAGS="$NEON_CFLAGS -DSYSTEM_NEON -DUSE_DAV_LOCKS=1"
5012        SYSTEM_NEON=YES
5013fi
5014AC_SUBST(SYSTEM_NEON)
5015AC_SUBST(NEON_VERSION)
5016AC_SUBST(NEON_LIBS)
5017AC_SUBST(NEON_CFLAGS)
5018
5019dnl ===================================================================
5020dnl Check for system openssl
5021dnl ===================================================================
5022if test "$_os" = "Darwin" && test "$with_system_openssl" != "no"; then
5023   with_system_openssl=yes
5024fi
5025AC_MSG_CHECKING([which libssl to use])
5026if test -n "$with_system_openssl" -o -n "$with_system_libs" && \
5027        test "$with_system_openssl" != "no"; then
5028    AC_MSG_RESULT([external])
5029    # Mac OS builds should get out without extra stuff is the Mac porters'
5030    # wish. And pkg-config is although Xcode ships a .pc for openssl
5031    if test "$_os" = "Darwin" -o "$_os" = "FreeBSD"; then
5032        OPENSSL_CFLAGS=
5033        OPENSSL_LIBS="-lssl -lcrypto"
5034    else
5035    	PKG_CHECK_MODULES( OPENSSL, openssl )
5036    fi
5037    SYSTEM_OPENSSL=YES
5038else
5039    AC_MSG_RESULT([internal])
5040    SYSTEM_OPENSSL=NO
5041    BUILD_TYPE="$BUILD_TYPE OPENSSL"
5042fi
5043AC_SUBST(SYSTEM_OPENSSL)
5044AC_SUBST(OPENSSL_CFLAGS)
5045AC_SUBST(OPENSSL_LIBS)
5046
5047dnl ===================================================================
5048dnl Test for enabling agg
5049dnl ===================================================================
5050AC_MSG_CHECKING([whether to enable agg])
5051if test "$enable_agg" = "yes"; then
5052  AC_MSG_RESULT([yes])
5053  AC_SUBST(ENABLE_AGG)
5054  ENABLE_AGG=YES
5055  AGG_VERSION=2400
5056else
5057  AC_MSG_RESULT([no])
5058  ENABLE_AGG=NO
5059
5060  dnl ===================================================================
5061  dnl Check for system AGG
5062  dnl ===================================================================
5063  AC_MSG_CHECKING([which AGG to use])
5064  if test -n "$with_system_agg" -o -n "$with_system_libs" && \
5065     test "$with_system_agg" != "no"; then
5066         AC_MSG_RESULT([external])
5067         PKG_CHECK_MODULES(AGG, libagg >= 2.3)
5068         AC_MSG_CHECKING([agg version])
5069         # workaround; if AGG_CFLAGS is empty (broken libagg.pc in 2.3), add /usr/include/agg2 anyway
5070         # (/usr/include gets stripped from pkg-config output)
5071         if test -z "$AGG_CFLAGS" || test "$AGG_CFLAGS" = " "; then
5072            AGG_INCDIR="`$PKG_CONFIG --variable includedir libagg`/agg2"
5073         else
5074            AGG_INCDIR="`echo $AGG_CFLAGS | $SED -e s/-I//`"
5075         fi
5076	 if $PKG_CONFIG --modversion libagg | grep -q 2.3 || \
5077	 	$PKG_CONFIG --modversion libagg | grep -q 2.4; then
5078            # 2.4's libagg.pc.in still contains 2.3 :/
5079            if $EGREP -q "Version 2.4" `echo $AGG_INCDIR`/agg_basics.h; then
5080               AC_MSG_RESULT([2.4])
5081               AGG_VERSION=2400
5082            else
5083               AC_MSG_RESULT([2.3])
5084               AGG_VERSION=2300
5085            fi
5086            SYSTEM_AGG=YES
5087	 else
5088	    AC_MSG_ERROR([only agg 2.3 and 2.4 are supported])
5089	 fi
5090  else
5091         AC_MSG_RESULT([internal])
5092         SYSTEM_AGG=NO
5093         BUILD_TYPE="$BUILD_TYPE AGG"
5094  fi
5095  AC_SUBST(SYSTEM_AGG)
5096  AC_SUBST(AGG_VERSION)
5097fi
5098
5099dnl ===================================================================
5100dnl Check for system redland
5101dnl ===================================================================
5102AC_MSG_CHECKING([which redland library to use])
5103if test -n "$with_system_redland" -o -n "$with_system_libs" && \
5104	test "$with_system_redland" != "no"; then
5105	AC_MSG_RESULT([external])
5106	SYSTEM_REDLAND=YES
5107   dnl versions before 1.0.8 write RDF/XML that is useless for ODF (@xml:base)
5108   PKG_CHECK_MODULES(REDLAND, redland >= 1.0.8)
5109else
5110	AC_MSG_RESULT([internal])
5111	BUILD_TYPE="$BUILD_TYPE REDLAND"
5112	SYSTEM_REDLAND=NO
5113fi
5114AC_SUBST(SYSTEM_REDLAND)
5115AC_SUBST(REDLAND_CFLAGS)
5116AC_SUBST(REDLAND_LIBS)
5117
5118dnl ===================================================================
5119dnl Check for system hunspell
5120dnl ===================================================================
5121
5122if test -n "$enable_copyleft" -a "$enable_copyleft" != "no"; then
5123
5124AC_MSG_CHECKING([which libhunspell to use])
5125if test -n "$with_system_hunspell" -o -n "$with_system_libs" && \
5126	test "$with_system_hunspell" != "no"; then
5127    AC_MSG_RESULT([external])
5128    SYSTEM_HUNSPELL=YES
5129    AC_LANG_PUSH([C++])
5130    PKG_CHECK_MODULES(HUNSPELL, hunspell, HUNSPELL_PC="TRUE", HUNSPELL_PC="" )
5131    if test "$HUNSPELL_PC" != "TRUE"; then
5132      AC_CHECK_HEADER(hunspell.hxx, [],
5133      [
5134      AC_CHECK_HEADER(hunspell/hunspell.hxx, [ HUNSPELL_CFLAGS=-I/usr/include/hunspell ],
5135           [AC_MSG_ERROR(hunspell headers not found.)], [])
5136         ], [])
5137      AC_CHECK_LIB(hunspell, main, [],
5138           [ AC_MSG_ERROR(hunspell library not found.) ], [])
5139      HUNSPELL_LIBS=-lhunspell
5140     fi
5141    AC_LANG_POP([C++])
5142else
5143    AC_MSG_RESULT([internal])
5144    SYSTEM_HUNSPELL=NO
5145    BUILD_TYPE="$BUILD_TYPE HUNSPELL"
5146fi
5147AC_SUBST(SYSTEM_HUNSPELL)
5148AC_SUBST(HUNSPELL_CFLAGS)
5149AC_SUBST(HUNSPELL_LIBS)
5150
5151dnl ===================================================================
5152dnl Checking for altlinuxhyph
5153dnl ===================================================================
5154AC_MSG_CHECKING([which altlinuxhyph to use])
5155if test -n "$with_system_altlinuxhyph" -o -n "$with_system_libs" && \
5156	test "$with_system_altlinuxhyph" != "no"; then
5157    AC_MSG_RESULT([external])
5158    SYSTEM_HYPH=YES
5159    AC_CHECK_HEADER(hyphen.h, [],
5160       [ AC_MSG_ERROR(altlinuxhyph headers not found.)], [])
5161    AC_CHECK_MEMBER(struct _HyphenDict.cset, [],
5162       [ AC_MSG_ERROR(no. You are sure you have altlinuyhyph headers?)],
5163       [#include <hyphen.h>])
5164    AC_CHECK_LIB(hyphen, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhyphen],
5165        [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
5166    if test -z "$HYPHEN_LIB"; then
5167       AC_CHECK_LIB(hyph, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhyph],
5168           [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
5169    fi
5170    if test -z "$HYPHEN_LIB"; then
5171       AC_CHECK_LIB(hnj, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhnj],
5172           [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
5173    fi
5174else
5175    AC_MSG_RESULT([internal])
5176    SYSTEM_HYPH=NO
5177    BUILD_TYPE="$BUILD_TYPE HYPHEN"
5178fi
5179AC_SUBST(SYSTEM_HYPH)
5180AC_SUBST(HYPHEN_LIB)
5181
5182dnl ===================================================================
5183dnl Checking for mythes
5184dnl ===================================================================
5185AC_MSG_CHECKING([which mythes to use])
5186if test -n "$with_system_mythes" -o -n "$with_system_libs" && \
5187   test "$with_system_mythes" != "no"; then
5188    AC_MSG_RESULT([external])
5189    SYSTEM_MYTHES=YES
5190    AC_LANG_PUSH([C++])
5191    PKG_CHECK_MODULES(MYTHES, mythes, MYTHES_PKGCONFIG=yes, MYTHES_PKGCONFIG=no)
5192    if test "$MYTHES_PKGCONFIG" = "no"; then
5193        AC_CHECK_HEADER(mythes.hxx, [],
5194            [ AC_MSG_ERROR(mythes.hxx headers not found.)], [])
5195        AC_CHECK_LIB(mythes-1.2, main, [],
5196            [ MYTHES_FOUND=no], [])
5197 	if test "$MYTHES_FOUND" = "no"; then
5198            AC_CHECK_LIB(mythes, main, [MYTHES_FOUND=yes],
5199                [ MYTHES_FOUND=no], [])
5200	fi
5201	if test "$MYTHES_FOUND" = "no"; then
5202		AC_MSG_ERROR([mythes library not found!.])
5203	fi
5204    fi
5205    AC_LANG_POP([C++])
5206else
5207    AC_MSG_RESULT([internal])
5208    SYSTEM_MYTHES=NO
5209    BUILD_TYPE="$BUILD_TYPE MYTHES"
5210fi
5211AC_SUBST(SYSTEM_MYTHES)
5212AC_SUBST(MYTHES_CFLAGS)
5213AC_SUBST(MYTHES_LIBS)
5214
5215fi
5216
5217dnl ===================================================================
5218dnl Checking for libtextcat
5219dnl ===================================================================
5220AC_MSG_CHECKING([which libtextcat to use])
5221if test -n "$with_system_libtextcat" && test "$with_system_libtextcat" != "no"; then
5222    AC_MSG_RESULT([external])
5223    SYSTEM_LIBTEXTCAT=YES
5224    AC_CHECK_HEADER(libtextcat/textcat.h, [],
5225       [ AC_MSG_ERROR(libtextcat headers not found.)], [])
5226    AC_CHECK_LIB(textcat, special_textcat_Init, ,
5227        [ AC_MSG_ERROR(libtextcat library not found or not suitable. libtextcat typically needs to be patched)], [])
5228else
5229    AC_MSG_RESULT([internal])
5230    SYSTEM_LIBTEXTCAT=NO
5231    BUILD_TYPE="$BUILD_TYPE LIBTEXTCAT"
5232fi
5233AC_SUBST(SYSTEM_LIBTEXTCAT)
5234
5235AC_MSG_CHECKING([which libtextcat data directory to use])
5236if test -n "$with_system_libtextcat_data" && test "$with_system_libtextcat_data" != "no"; then
5237    if test "$with_system_libtextcat_data" = "yes"; then
5238        SYSTEM_LIBTEXTCAT_DATA=file:///usr/share/libtextcat
5239    else
5240        SYSTEM_LIBTEXTCAT_DATA=file://$with_system_libtextcat_data
5241    fi
5242    AC_MSG_RESULT([$SYSTEM_LIBTEXTCAT_DATA])
5243else
5244    AC_MSG_RESULT([internal])
5245    BUILD_TYPE="$BUILD_TYPE LIBTEXTCATDATA"
5246fi
5247AC_SUBST(SYSTEM_LIBTEXTCAT_DATA)
5248
5249dnl ***************************************
5250dnl testing libc version for Linux...
5251dnl ***************************************
5252if test "$_os" = "Linux"; then
5253   AC_MSG_CHECKING([whether libc is >= 2.1.1])
5254   exec 6>/dev/null # no output
5255   AC_CHECK_LIB(c, gnu_get_libc_version, HAVE_LIBC=yes; export HAVE_LIBC)
5256   exec 6>&1 # output on again
5257   if test "$HAVE_LIBC"; then
5258      AC_MSG_RESULT([yes])
5259   else
5260      AC_MSG_ERROR([no, upgrade libc])
5261   fi
5262fi
5263
5264if test "$_os" != "WNT"; then
5265  AC_CHECK_FUNCS(getopt, HAVE_GETOPT=YES, [HAVE_GETOPT=NO])
5266  AC_CHECK_FUNCS(readdir_r, HAVE_READDIR_R=YES, [HAVE_READDIR_R=NO])
5267  if test "$HAVE_GETOPT" = "YES" -a "$HAVE_READDIR_R" = "YES"; then
5268	SYSTEM_LIBC=YES
5269  fi
5270else
5271  HAVE_GETOPT=NO
5272  HAVE_READDIR_R=NO
5273  SYSTEM_LIBC=YES
5274fi
5275AC_SUBST(HAVE_GETOPT)
5276AC_SUBST(HAVE_READDIR_R)
5277AC_SUBST(SYSTEM_LIBC)
5278
5279dnl =========================================
5280dnl Check for the Microsoft Platform SDK.
5281dnl =========================================
5282dnl FIXME: I don't know yet if PSDK works with MinGW, keep it until I know better,
5283dnl and add "-a \( "$WITH_MINGWIN" != "yes" \)" then
5284if test \( "$_os" = "WINNT" \) ; then
5285	AC_MSG_CHECKING([for PSDK files])
5286	if test -z "$with_psdk_home"; then
5287		# This first line will detect a February 2003 Microsoft Platform SDK
5288		PSDK_HOME=`./oowintool --psdk-home`
5289        # But there might be also an April 2005 PSDK, unfortunately MS changed
5290        # the registry entry. (we prefer the old version!?)
5291        if test -z "$PSDK_HOME"; then
5292          PSDK_HOME=`cat /proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MicrosoftSDK/InstalledSDKs/*/Install\ Dir 2> /dev/null | tr '\000' '\n' | head -n 1`
5293        fi
5294            # normalize if found
5295            if test -n "$PSDK_HOME"; then
5296              PSDK_HOME=`cygpath -d "$PSDK_HOME"`
5297              PSDK_HOME=`cygpath -u "$PSDK_HOME"`
5298           fi
5299	else
5300           PSDK_HOME=`cygpath -u "$with_psdk_home"`
5301	fi
5302        # Remove a possible trailing backslash
5303        PSDK_HOME=`echo $PSDK_HOME | $SED 's/\/$//'`
5304    # Problem with current PSDK (iz 49865)
5305    if test -f "$PSDK_HOME/Lib/libcp.lib"; then
5306        AC_MSG_ERROR([
5307
5308Some modules do not build correctly with MS Platform SDK - April 2005
5309Edition if the library ($PSDK_HOME/Lib/libcp.lib) is found.
5310Remove/rename/backup that file and restart configure. Details about this
5311problem can be found in issue 49856.])
5312    fi
5313# WIndows SDK has different headers
5314	if test \( -f "$PSDK_HOME/Include/adoint.h" \) \
5315		 -a \( -f "$PSDK_HOME/Include/SqlUcode.h" \) \
5316		 -a \( -f "$PSDK_HOME/Include/usp10.h" \); then
5317		HAVE_PSDK_H="yes"
5318	else
5319		HAVE_PSDK_H="no"
5320	fi
5321	if test -f "$PSDK_HOME/lib/unicows.lib"; then
5322		HAVE_PSDK_LIB="yes"
5323	else
5324		HAVE_PSDK_LIB="no"
5325	fi
5326    if test "$HAVE_PSDK_H" = "no" -o "$HAVE_PSDK_LIB" = "no"; then
5327        AC_MSG_ERROR([Some (all?) PSDK files not found, please check if all needed Platform SDKs
5328are installed or use --with-psdk-home .])
5329    fi
5330    if test ! -x "$PSDK_HOME/bin/msiinfo.exe" \
5331         -o ! -x "$PSDK_HOME/bin/msidb.exe" \
5332         -o ! -x "$PSDK_HOME/bin/uuidgen.exe" \
5333         -o ! -x "$PSDK_HOME/bin/msitran.exe" ; then
5334        AC_MSG_ERROR([Some (all) files of the Windows Installer SDK are missing, please install.])
5335    fi
5336    AC_MSG_RESULT([SDK files found ...)])
5337dnl Check if this is the right SDK.
5338    if echo $PSDK_HOME | grep "v6.1" >/dev/null 2>/dev/null; then
5339        AC_MSG_RESULT([Found Windows SDK 6.1 ($PSDK_HOME)])
5340        WINDOWS_VISTA_PSDK=TRUE
5341    elif echo $PSDK_HOME | grep "v6.0" >/dev/null 2>/dev/null; then
5342        AC_MSG_RESULT([Found Windows SDK 6.0 ($PSDK_HOME)])
5343        WINDOWS_VISTA_PSDK=TRUE
5344    else
5345        AC_MSG_RESULT([Found Legacy Windows Platform SDK ($PSDK_HOME)])
5346    fi
5347fi
5348AC_SUBST(PSDK_HOME)
5349AC_SUBST(WINDOWS_VISTA_PSDK)
5350
5351dnl =========================================
5352dnl Check for the Microsoft DirectX SDK.
5353dnl =========================================
5354if test \( "$_os" = "WINNT" \) ; then
5355    AC_MSG_CHECKING([for DirectX SDK files])
5356    if test -z "$with_directx_home"; then
5357        dnl A standard installation of the DirectX SDK sets $DXSDK_DIR
5358        if test -n "$DXSDK_DIR"; then
5359            DIRECTXSDK_HOME=`cygpath -d "$DXSDK_DIR"`
5360            DIRECTXSDK_HOME=`cygpath -u "$DIRECTXSDK_HOME"`
5361        fi
5362        # At this point $DIRECTXSDK_HOME might still be undefined. This will lead to
5363        # the "DirectX SDK files not found" error later
5364    else
5365	DIRECTXSDK_HOME=`cygpath -u "$with_directx_home"`
5366    fi
5367    # Remove a possible trailing backslash
5368    DIRECTXSDK_HOME=`echo $DIRECTXSDK_HOME | $SED 's/\/$//'`
5369
5370    if test -f "$DIRECTXSDK_HOME/Include/ddraw.h" ; then
5371        HAVE_DIRECTDRAW_H="yes"
5372    else
5373        HAVE_DIRECTDRAW_H="no"
5374    fi
5375    if test -f "$DIRECTXSDK_HOME/Include/d3d9.h" ; then
5376        HAVE_DIRECTXSDK_H="yes"
5377    else
5378        HAVE_DIRECTXSDK_H="no"
5379    fi
5380
5381    # MS changed the location of the libraries with dec 2004 directx sdk
5382    if test -d "$DIRECTXSDK_HOME/lib/x86" ; then
5383        DIRECTXSDK_LIB="$DIRECTXSDK_HOME/lib/x86"
5384    else
5385        DIRECTXSDK_LIB="$DIRECTXSDK_HOME/lib"
5386    fi
5387    if test -f "$DIRECTXSDK_LIB/ddraw.lib" ; then
5388        HAVE_DIRECTDRAW_LIB="yes"
5389    else
5390        HAVE_DIRECTDRAW_LIB="no"
5391    fi
5392    if test -f "$DIRECTXSDK_LIB/d3d9.lib" ; then
5393        HAVE_DIRECTXSDK_LIB="yes"
5394    else
5395        HAVE_DIRECTXSDK_LIB="no"
5396    fi
5397
5398    if test "$HAVE_DIRECTDRAW_H" = "yes" -a "$HAVE_DIRECTDRAW_LIB" = "yes" ; then
5399       ENABLE_DIRECT_DRAW="TRUE"
5400    fi
5401    if test "$HAVE_DIRECTXSDK_H" = "yes" -a "$HAVE_DIRECTXSDK_LIB" = "yes" ; then
5402       HAVE_DIRECTXSDK="yes"
5403    else
5404       HAVE_DIRECTXSDK="no"
5405    fi
5406
5407    if test -n "$ENABLE_DIRECTX"; then
5408	    if test "$HAVE_DIRECTDRAW" = "yes" -o "$HAVE_DIRECTXSDK" = "yes" ; then
5409		    AC_MSG_RESULT([found])
5410	    else
5411		    AC_MSG_ERROR([DirectX SDK files not found, please use --with-directx-home or --disable-directx.])
5412	    fi
5413    else
5414		DIRECTXSDK_HOME=""
5415		AC_MSG_RESULT([disabled])
5416    fi
5417fi
5418AC_SUBST(ENABLE_DIRECT_DRAW)
5419AC_SUBST(DIRECTXSDK_HOME)
5420AC_SUBST(DIRECTXSDK_LIB)
5421
5422dnl ============================================
5423dnl Check for Nullsoft Scriptable Install System
5424dnl ============================================
5425NSIS_PATH=""
5426if test "$_os" = "WINNT" ; then
5427    AC_MSG_CHECKING([for NSIS])
5428    AC_PATH_PROG(NSIS_PATH, nsis.exe)
5429    if test -n "$NSIS_PATH"; then
5430        NSIS_PATH=`dirname "$NSIS_PATH"`
5431    fi
5432    if test -n "$with_nsis_path"; then
5433        with_nsis_path=`cygpath -u "$with_nsis_path"`
5434    fi
5435    if test -e "$with_nsis_path/nsis.exe"; then
5436        NSIS_PATH="$with_nsis_path"
5437    fi
5438    nsistest=`./oowintool --nsis-dir`;
5439    if test -x "$nsistest/nsis.exe"; then
5440        NSIS_PATH="$nsistest"
5441    fi
5442    if test -z "$NSIS_PATH"; then
5443        AC_MSG_WARN([NSIS not found, no self contained installer will be build.])
5444        echo "NSIS not found, no self contained installer will be build." >> warn
5445    else
5446        NSIS_PATH=`cygpath -d "$NSIS_PATH"`
5447        NSIS_PATH=`cygpath -u "$NSIS_PATH"`
5448        AC_MSG_RESULT([found ($NSIS_PATH)])
5449    fi
5450fi
5451AC_SUBST(NSIS_PATH)
5452
5453dnl ***************************************
5454dnl testing bison and flex exist
5455dnl ***************************************
5456AC_PATH_PROG(BISON, bison)
5457if test -z "$BISON"; then
5458   AC_MSG_ERROR([no bison found in \$PATH, install bison])
5459else
5460   AC_MSG_CHECKING([the bison version])
5461   _bison_version=`$BISON --version | grep GNU | $SED -e 's@^[[^0-9]]*@@' -e 's@ .*@@' -e 's@,.*@@'`;
5462    _bison_longver=`echo $_bison_version | $AWK -F. '{ print \$1*1000+\$2}'`
5463    # Accept newer than 1.875 or older(equal) than 1.75
5464    if test "$_bison_longver" -ge 1875 -o "$_bison_longver" -le 1075; then
5465       if test "$_bison_version" = "1.875" ; then
5466          AC_MSG_WARN([suspect ($BISON $_bison_version)])
5467          echo "Suspect ($BISON $_bison_version) suggest upgrade" >> warn
5468       else
5469          AC_MSG_RESULT([checked ($BISON $_bison_version)])
5470       fi
5471    else
5472       AC_MSG_ERROR([failed ($BISON $_bison_version need 1.875+ (or 1.75 and older))])
5473    fi
5474fi
5475AC_PATH_PROG(FLEX, flex)
5476if test -z "$FLEX"; then
5477   AC_MSG_ERROR([no flex found in \$PATH, install flex])
5478fi
5479dnl ***************************************
5480dnl testing that patch exists
5481dnl ***************************************
5482AC_PATH_PROG(PATCH, patch)
5483if test -z "$PATCH"; then
5484   AC_MSG_ERROR([\"patch\" not found in \$PATH, install the development tool named\"patch"\])
5485fi
5486
5487dnl On Solaris, FreeBSD or MacOS X, check if --with-gnu-patch was used
5488if test "$_os" = "SunOS" -o "$_os" = "FreeBSD" -o "$_os" = "Darwin"; then
5489   if test -z "$with_gnu_patch"; then
5490      GNUPATCH=$PATCH
5491   else
5492      if test -x "$with_gnu_patch"; then
5493	      GNUPATCH=$with_gnu_patch
5494      else
5495         AC_MSG_ERROR([--with-gnu-patch did not point to an executable])
5496      fi
5497   fi
5498
5499   AC_MSG_CHECKING([whether $GNUPATCH is GNU patch])
5500   if $GNUPATCH --version | grep "Free Software Foundation" >/dev/null 2>/dev/null; then
5501	   AC_MSG_RESULT([yes])
5502   else
5503      AC_MSG_ERROR([no, GNU patch needed. install or specify with --with-gnu-patch=/path/to/it])
5504   fi
5505fi
5506
5507dnl We also need to check for --with-gnu-cp
5508
5509if test -z "$with_gnu_cp"; then
5510   # check the place where the good stuff is hidden on Solaris...
5511   if test -x /usr/gnu/bin/cp; then
5512      GNUCP=/usr/gnu/bin/cp
5513   else
5514      AC_PATH_PROGS(GNUCP, gnucp cp)
5515   fi
5516   if test -z $GNUCP; then
5517      AC_MSG_ERROR([Neither gnucp nor cp found. Install GNU cp and/or specify --with-gnu-cp=/path/to/it])
5518   fi
5519else
5520   if test -x "$with_gnu_cp"; then
5521      GNUCP=$with_gnu_cp
5522   else
5523      AC_MSG_ERROR([--with-gnu-cp did not point to an executable])
5524   fi
5525fi
5526
5527AC_MSG_CHECKING([whether $GNUCP is GNU cp from coreutils with preserve= support])
5528if $GNUCP --version 2>/dev/null | grep "coreutils" >/dev/null 2>/dev/null; then
5529   AC_MSG_RESULT([yes])
5530else
5531   AC_MSG_RESULT([no])
5532   GNUCP=''
5533fi
5534
5535if test -z "$GNUCP"; then
5536   if test "$_os" = "SunOS" -o "$_os" = "FreeBSD"; then
5537      AC_MSG_ERROR([no, GNU cp from coreutils is needed. install or specify with --with-gnu-cp=/path/to/it])
5538   else
5539      AC_MSG_RESULT([no GNU cp from coreutils found - using the system's cp command])
5540   fi
5541fi
5542
5543AC_SUBST(GNUPATCH)
5544AC_SUBST(GNUCP)
5545
5546dnl ***************************************
5547dnl testing bash tools path on Windows
5548dnl ***************************************
5549if test "$_os" = "WINNT"; then
5550    CYGWIN_PATH=""
5551    AC_PATH_PROG(CYGWIN_PATH, bash)
5552    CYGWIN_PATH=`dirname "$CYGWIN_PATH"`
5553fi
5554if test -z "$CYGWIN_PATH"; then
5555   CYGWIN_PATH="NO_CYGWIN"
5556fi
5557AC_SUBST(CYGWIN_PATH)
5558
5559dnl ***************************************
5560dnl testing ml.exe assembler path
5561dnl ***************************************
5562if test "$_os" = "WINNT" -a "$WITH_MINGWIN" != "yes"; then
5563  AC_MSG_CHECKING([ml.exe assembler path])
5564  if test -n "$with_asm_home"; then
5565    with_asm_home=`cygpath -u "$with_asm_home"`
5566  fi
5567  if test ! -x "$with_asm_home/ml.exe"; then
5568    AC_PATH_PROG(ML_EXE, ml.exe)
5569    if test -z "$ML_EXE"; then
5570      if test -x "$with_cl_home/bin/ml.exe"; then
5571        with_asm_home=$with_cl_home/bin
5572        AC_MSG_RESULT([found ($with_asm_home)])
5573      else
5574        AC_MSG_ERROR([Configure did not find ml.exe assembler.])
5575      fi
5576    else
5577       with_asm_home="ASM_IN_PATH"
5578    fi
5579  fi
5580  AC_MSG_RESULT([$ASM_HOME])
5581else
5582  with_asm_home="NO_ASM_HOME"
5583fi
5584ASM_HOME="$with_asm_home"
5585AC_SUBST(ASM_HOME)
5586
5587dnl ===================================================================
5588dnl testing handle deprecated unzip switch
5589dnl ===================================================================
5590if test -z "$with_zip_home"; then
5591	with_zip_home="$with_unzip_home"
5592fi
5593dnl ===================================================================
5594dnl Zip will be found where you tell me to find it
5595dnl ===================================================================
5596if test -n "$with_zip_home" ; then
5597    if test "$_os" = "WINNT"; then
5598        with_zip_home=`cygpath -u "$with_zip_home"`
5599    fi
5600    ZIP="$with_zip_home/zip"
5601    UNZIP="$with_zip_home/unzip"
5602    ZIP_HOME="$with_zip_home"
5603else
5604    AC_PATH_PROG(ZIP, zip)
5605    AC_PATH_PROG(UNZIP, unzip)
5606    ZIP_HOME=`dirname "$ZIP"`
5607fi
5608dnl ===================================================================
5609dnl Zip must be available or else it is an error, all platforms
5610dnl ===================================================================
5611if test -z "$ZIP" -o -z "$UNZIP"; then
5612    AC_MSG_ERROR([Zip/Unzip are required to build, please install or use --with-zip-home],,)
5613fi
5614
5615dnl ===================================================================
5616dnl Zip must be a specific type for different build types.
5617dnl ===================================================================
5618if test "$_os" = "WINNT"; then
5619    if test -n "`$ZIP -h | grep -i WinNT`" ; then
5620AC_MSG_ERROR([$ZIP found in the path is not the required cygwin version of Info-ZIPs zip.exe.])
5621    fi
5622fi
5623AC_SUBST(ZIP_HOME)
5624
5625dnl ===================================================================
5626dnl Windows builds need dbghelp.dll in external/dbghelp/
5627dnl ===================================================================
5628if test "$_os" = "WINNT"; then
5629   AC_MSG_CHECKING([for dbghelp.dll])
5630   if test -x ./external/dbghelp/dbghelp.dll; then
5631      AC_MSG_RESULT([found and executable])
5632   else
5633      AC_MSG_ERROR([dbghelp.dll is missing in external/dbghelp/.
5634Get it from the Microsoft site and put it into external/dbghelp.
5635(Note: Microsoft seems to enjoy changing the exact location of this file. You
5636may have to search Microsoft's website.) Last time it was seen at:
5637<http://www.microsoft.com/downloads/release.asp?releaseid=30682>.])
5638   fi
5639fi
5640
5641dnl ===================================================================
5642dnl Windows builds - use oowintool to copy CRT dlls and manifest
5643dnl ===================================================================
5644if test "$_os" = "WINNT" -a "$WITH_MINGWIN" != "yes"; then
5645       if ./oowintool --msvc-copy-dlls ./external/msvcp ; then
5646          :
5647       else
5648          AC_MSG_ERROR([oowintool failed to copy CRT])
5649       fi
5650fi
5651
5652dnl ===================================================================
5653dnl Windows builds need gdiplus.dll in external/gdiplus/
5654dnl ===================================================================
5655if test "$_os" = "WINNT"; then
5656   AC_MSG_CHECKING([for gdiplus.dll])
5657   if test -x ./external/gdiplus/gdiplus.dll; then
5658      AC_MSG_RESULT([found and executable])
5659   else
5660      AC_MSG_ERROR([gdiplus.dll is missing in external/gdiplus/.
5661Get it from the Microsoft site and put it into external/gdiplus.
5662You may have to search Microsoft's website. Last time it was seen at:
5663<http://www.microsoft.com/downloads/details.aspx?familyid=6A63AB9C-DF12-4D41-933C-BE590FEAA05A&displaylang=en>.])
5664   fi
5665fi
5666
5667dnl ===================================================================
5668dnl Test which vclplugs have to be built.
5669dnl ===================================================================
5670AC_MSG_CHECKING([which VCLplugs shall be built])
5671ENABLE_GTK=""
5672if test "x$enable_gtk" = "xyes"; then
5673    ENABLE_GTK="TRUE"
5674    R="gtk"
5675fi
5676AC_SUBST(ENABLE_GTK)
5677
5678ENABLE_KDE=""
5679if test "x$enable_kde" = "xyes"; then
5680    ENABLE_KDE="TRUE"
5681    R="$R kde"
5682fi
5683AC_SUBST(ENABLE_KDE)
5684
5685ENABLE_KDE4=""
5686if test "x$enable_kde4" = "xyes"; then
5687    ENABLE_KDE4="TRUE"
5688    R="$R kde4"
5689fi
5690AC_SUBST(ENABLE_KDE4)
5691
5692if test -z "$R"; then
5693	AC_MSG_RESULT([none])
5694else
5695	AC_MSG_RESULT([$R])
5696fi
5697
5698dnl ===================================================================
5699dnl GCONF check
5700dnl ===================================================================
5701
5702ENABLE_GCONF=""
5703AC_MSG_CHECKING([whether to enable GConf support])
5704if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$_os" != "OS2" -a "$enable_gconf" = "yes"; then
5705    ENABLE_GCONF="TRUE"
5706    AC_MSG_RESULT([yes])
5707    PKG_CHECK_MODULES( GCONF, gconf-2.0 )
5708else
5709    AC_MSG_RESULT([no])
5710fi
5711AC_SUBST(ENABLE_GCONF)
5712
5713dnl ===================================================================
5714dnl Gnome VFS check
5715dnl ===================================================================
5716
5717ENABLE_GNOMEVFS=""
5718AC_MSG_CHECKING([whether to enable GNOME VFS support])
5719if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_gnome_vfs" = "yes"; then
5720    ENABLE_GNOMEVFS="TRUE"
5721    AC_MSG_RESULT([yes])
5722    PKG_CHECK_MODULES( GNOMEVFS, gnome-vfs-2.0 >= 2.6.0 )
5723    if test "$ENABLE_GCONF" != "TRUE"; then
5724        PKG_CHECK_MODULES( GCONF, gconf-2.0 )
5725    fi
5726else
5727    AC_MSG_RESULT([no])
5728fi
5729AC_SUBST(ENABLE_GNOMEVFS)
5730
5731dnl ===================================================================
5732dnl Check whether the gtk 2.0 libraries are available.
5733dnl ===================================================================
5734
5735GTK_CFLAGS=""
5736GTK_LIBS=""
5737ENABLE_SYSTRAY_GTK=""
5738ENABLE_DBUS=""
5739if test  "$test_gtk" = "yes"; then
5740
5741   if test "$ENABLE_GTK" = "TRUE" ; then
5742      PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.4 gdk-pixbuf-xlib-2.0 >= 2.2 ,,AC_MSG_ERROR([requirements to build the gtk-plugin not met. Use --disable-gtk or install the missing packages]))
5743      PKG_CHECK_MODULES(GTHREAD, gthread-2.0,,AC_MSG_ERROR([requirements to build the gtk-plugin not met. Use --disable-gtk or install the missing packages]))
5744      BUILD_TYPE="$BUILD_TYPE GTK"
5745
5746      if test "x$enable_systray" = "xyes"; then
5747         PKG_CHECK_MODULES(GTK_2_16,gtk+-2.0 >= 2.16.0,
5748                           [ENABLE_SYSTRAY_GTK="TRUE"
5749                            BUILD_TYPE="$BUILD_TYPE SYSTRAY_GTK"],
5750                           [ENABLE_SYSTRAY_GTK=""])
5751      fi
5752
5753      AC_MSG_CHECKING([whether to enable DBUS support])
5754      if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_dbus" = "yes"; then
5755          ENABLE_DBUS="TRUE"
5756          AC_MSG_RESULT([yes])
5757          PKG_CHECK_MODULES( DBUS, dbus-glib-1 >= 0.70 )
5758      else
5759          AC_MSG_RESULT([no])
5760      fi
5761
5762      AC_MSG_CHECKING([whether to enable GIO support])
5763      if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_gio" = "yes"; then
5764          if test "$ENABLE_GNOMEVFS" = "TRUE" ; then
5765             AC_MSG_ERROR([please use --enable-gio only together with --disable-gnome-vfs.])
5766          fi
5767          ENABLE_GIO="TRUE"
5768          AC_MSG_RESULT([yes])
5769          PKG_CHECK_MODULES( GIO, gio-2.0 )
5770      else
5771          AC_MSG_RESULT([no])
5772      fi
5773
5774   fi
5775
5776fi
5777AC_SUBST(ENABLE_GIO)
5778AC_SUBST(ENABLE_DBUS)
5779AC_SUBST(ENABLE_SYSTRAY_GTK)
5780AC_SUBST(GTK_CFLAGS)
5781AC_SUBST(GTK_LIBS)
5782AC_SUBST(GTHREAD_CFLAGS)
5783AC_SUBST(GTHREAD_LIBS)
5784
5785dnl ===================================================================
5786dnl Check whether the GStreamer libraries are available.
5787dnl ===================================================================
5788
5789GSTREAMER_CFLAGS=""
5790GSTREAMER_LIBS=""
5791ENABLE_GSTREAMER=""
5792
5793if test "$test_gstreamer" = "yes"; then
5794    AC_MSG_CHECKING([whether to build the GStreamer media backend])
5795    if test "x$enable_gstreamer" != "xno" ; then
5796        PKG_CHECK_MODULES( GSTREAMER, gtk+-2.0 >= 2.4 gthread-2.0 gstreamer-0.10 gstreamer-interfaces-0.10 ,,AC_MSG_ERROR([requirements to build the GStreamer media backend not met. Use --disable-gstreamer or install the missing packages]))
5797        ENABLE_GSTREAMER="TRUE"
5798        AC_MSG_RESULT([yes])
5799    else
5800        AC_MSG_RESULT([no])
5801    fi
5802fi
5803AC_SUBST(ENABLE_GSTREAMER)
5804AC_SUBST(GSTREAMER_CFLAGS)
5805AC_SUBST(GSTREAMER_LIBS)
5806
5807dnl ===================================================================
5808dnl Check the ARM target
5809dnl ===================================================================
5810
5811if test "$_os" = "Linux" && echo "$build_cpu" | $GREP -q arm; then
5812    # default value
5813    ARM_TARGET=ARMV4T
5814    AC_MSG_CHECKING([which ARM processor optimization to use])
5815    if test "$with_arm_target" -lt "6"; then
5816	ARM_TARGET=ARMV4T
5817    elif test "$with_arm_target" = "6"; then
5818	ARM_TARGET=ARMV6
5819    elif test "$with_arm_target" -gt "6"; then
5820	ARM_TARGET=ARMV7
5821    fi
5822    AC_MSG_RESULT([$ARM_TARGET])
5823    AC_SUBST(ARM_TARGET)
5824fi
5825
5826dnl ===================================================================
5827dnl Check whether the Cairo libraries are available.
5828dnl ===================================================================
5829
5830ENABLE_CAIRO=""
5831BUILD_PIXMAN=""
5832SYSTEM_CAIRO=""
5833
5834if test  "$test_cairo" = "yes"; then
5835
5836    AC_MSG_CHECKING([whether to use cairo])
5837    if test "x$enable_cairo" != "xno" ; then
5838        ENABLE_CAIRO="TRUE"
5839	AC_MSG_RESULT([yes])
5840        AC_MSG_CHECKING([which cairo to use])
5841        if test -n "$with_system_cairo" -o -n "$with_system_libs" && \
5842           test "$with_system_cairo" != "no"; then
5843           AC_MSG_RESULT([external])
5844           SYSTEM_CAIRO=YES
5845
5846           PKG_CHECK_MODULES( CAIRO, cairo >= 1.0.2 )
5847	   if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$ENABLE_FONTCONFIG" != "TRUE" ; then
5848	      AC_MSG_ERROR([Cairo library requires fontconfig.])
5849	   fi
5850           if test "$with_system_xrender_headers" = "yes"; then
5851              AC_MSG_CHECKING([whether Xrender.h defines PictStandardA8])
5852              AC_TRY_RUN([
5853#include <X11/extensions/Xrender.h>
5854
5855int main(int argc, char **argv) {
5856#ifdef PictStandardA8
5857      return 0;
5858#else
5859      return 1;
5860#endif
5861}
5862               ], [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([no, X headers too old.])])
5863           fi
5864        else
5865           BUILD_TYPE="$BUILD_TYPE CAIRO"
5866	   dnl === compiler fails on pixman with 64bit architectures...===
5867	   if test "$build_cpu" != "x86_64"; then
5868	      BUILD_PIXMAN=YES
5869	   fi
5870           AC_MSG_RESULT([internal])
5871        fi
5872    else
5873	   AC_MSG_RESULT([no])
5874    fi
5875fi
5876
5877AC_SUBST(ENABLE_CAIRO)
5878AC_SUBST(BUILD_PIXMAN)
5879AC_SUBST(SYSTEM_CAIRO)
5880AC_SUBST(CAIRO_CFLAGS)
5881AC_SUBST(CAIRO_LIBS)
5882
5883ENABLE_CAIRO_CANVAS="FALSE"
5884if test "$enable_cairo_canvas" = "yes" -a "$ENABLE_CAIRO" = "TRUE" ; then
5885   ENABLE_CAIRO_CANVAS="TRUE"
5886fi
5887AC_SUBST(ENABLE_CAIRO_CANVAS)
5888
5889dnl ===================================================================
5890dnl Check whether the OpenGL libraries are available
5891dnl ===================================================================
5892
5893AC_MSG_CHECKING([whether to build the OpenGL Transitions component])
5894ENABLE_OPENGL=
5895
5896if test "x$enable_opengl" != "xno" ; then
5897   AC_MSG_RESULT([yes])
5898   AC_CHECK_HEADER(GL/gl.h, [],
5899                   [AC_MSG_ERROR([OpenGL headers not found])], [])
5900   AC_CHECK_LIB(GL, main, [],
5901     [AC_MSG_ERROR(libGL not installed or functional)], [])
5902   AC_CHECK_LIB(GLU, main, [],
5903     [AC_MSG_ERROR(libGLU not installed or functional)], [])
5904   ENABLE_OPENGL=TRUE
5905else
5906   AC_MSG_RESULT([no])
5907fi
5908
5909AC_SUBST(ENABLE_OPENGL)
5910
5911AC_MSG_CHECKING([whether to build extra presenter ui])
5912if test -n "$enable_presenter_extra_ui" -a "$enable_presenter_extra_ui" != "no"; then
5913   AC_MSG_RESULT([yes])
5914   ENABLE_PRESENTER_EXTRA_UI=YES
5915else
5916   AC_MSG_RESULT([no])
5917   ENABLE_PRESENTER_EXTRA_UI=NO
5918fi
5919AC_SUBST(ENABLE_PRESENTER_EXTRA_UI)
5920
5921AC_MSG_CHECKING([whether to build the Presentation Minimizer extension])
5922if test -n "$enable_minimizer" -a "$enable_minimizer" != "no"; then
5923   AC_MSG_RESULT([yes])
5924   ENABLE_MINIMIZER=YES
5925else
5926   AC_MSG_RESULT([no])
5927   ENABLE_MINIMIZER=NO
5928fi
5929AC_SUBST(ENABLE_MINIMIZER)
5930
5931AC_MSG_CHECKING([whether to build the Presenter Screen extension])
5932if test -n "$enable_presenter_console" -a "$enable_presenter_screen" != "no"; then
5933   AC_MSG_RESULT([yes])
5934   ENABLE_PRESENTER_SCREEN=YES
5935else
5936   AC_MSG_RESULT([no])
5937   ENABLE_PRESENTER_SCREEN=NO
5938fi
5939AC_SUBST(ENABLE_PRESENTER_SCREEN)
5940
5941AC_MSG_CHECKING([whether to build the PDF Import extension])
5942if test -n "$enable_pdfimport" -a "$enable_pdfimport" != "no"; then
5943  AC_MSG_RESULT([yes])
5944  ENABLE_PDFIMPORT=YES
5945
5946  dnl ===================================================================
5947  dnl Check for system poppler
5948  dnl ===================================================================
5949  AC_MSG_CHECKING([whether to use system pdf backend])
5950  if test -n "$with_system_poppler" -o -n "$with_system_libs" && \
5951       test "$with_system_poppler" != "no"; then
5952      AC_MSG_RESULT([external])
5953      SYSTEM_POPPLER=YES
5954      PKG_CHECK_MODULES( POPPLER, poppler >= 0.8.0 )
5955  else
5956      AC_MSG_RESULT([no])
5957      SYSTEM_POPPLER=NO
5958      ENABLE_PDFIMPORT=NO
5959  fi
5960else
5961   AC_MSG_RESULT([no])
5962   ENABLE_PDFIMPORT=NO
5963fi
5964AC_SUBST(ENABLE_PDFIMPORT)
5965AC_SUBST(SYSTEM_POPPLER)
5966AC_SUBST(POPPLER_CFLAGS)
5967AC_SUBST(POPPLER_LIBS)
5968
5969if test "$ENABLE_PRESENTER_SCREEN" = "YES" -o "$ENABLE_MINIMIZER" = "YES" -o "$ENABLE_PDFIMPORT" = "YES"; then
5970  AC_MSG_CHECKING([for sdext module])
5971  if test -d ./sdext; then
5972   AC_MSG_RESULT([OK])
5973  else
5974   AC_MSG_ERROR([not existing. get it (did you get the -extensions tarball?)])
5975  fi
5976  BUILD_TYPE="$BUILD_TYPE SDEXT"
5977fi
5978
5979AC_MSG_CHECKING([whether to build the Wiki Publisher extension])
5980if test -n "$enable_wiki_publisher" -a "$enable_wiki_publisher" != "no" && test  "$WITH_JAVA" != "no"; then
5981  AC_MSG_RESULT([yes])
5982  AC_MSG_CHECKING([for swext module])
5983  if test -d ./swext; then
5984   AC_MSG_RESULT([OK])
5985  else
5986   AC_MSG_ERROR([not existing. get it (did you get the -extensions tarball?)])
5987  fi
5988  ENABLE_MEDIAWIKI=YES
5989  BUILD_TYPE="$BUILD_TYPE SWEXT"
5990else
5991  AC_MSG_RESULT([no])
5992  ENABLE_MEDIAWIKI=NO
5993fi
5994AC_SUBST(ENABLE_MEDIAWIKI)
5995
5996if test "$ENABLE_MEDIAWIKI" = "YES"; then
5997  AC_MSG_CHECKING([which Servlet API Jar to use])
5998  if test -n "$with_system_servlet_api"; then
5999    AC_MSG_RESULT([external])
6000    SYSTEM_SERVLETAPI=YES
6001      if test -z "$SERVLETAPI_JAR"; then
6002	SERVLETAPI_JAR=/usr/share/java/servlet-api.jar
6003      fi
6004      AC_CHECK_FILE($SERVLETAPI_JAR, [],
6005             [AC_MSG_ERROR(servlet-api.jar not found.)], [])
6006  else
6007    AC_MSG_RESULT([internal])
6008    SYSTEM_SERVLETAPI=NO
6009    BUILD_TYPE="$BUILD_TYPE TOMCAT"
6010  fi
6011fi
6012AC_SUBST(SYSTEM_SERVLETAPI)
6013AC_SUBST(SERVLETAPI_JAR)
6014
6015AC_MSG_CHECKING([whether to build the Report Builder extension])
6016if test -n "$enable_report_builder" -a "$enable_report_builder" != "no" && test "$WITH_JAVA" != "no"; then
6017  AC_MSG_RESULT([yes])
6018  ENABLE_REPORTBUILDER=YES
6019  SYSTEM_JFREEREPORT=YES
6020  AC_MSG_CHECKING([for reportbuilder module])
6021  if test -d ./reportbuilder; then
6022    AC_MSG_RESULT([OK])
6023  else
6024    AC_MSG_ERROR([not existing. get it (did you get the -extensions tarball?)])
6025  fi
6026  AC_MSG_CHECKING([which jfreereport libs to use (for Report Builder extension)])
6027  AC_MSG_RESULT([external])
6028  if test -z $SAC_JAR; then
6029         SAC_JAR=/usr/share/java/sac.jar
6030  fi
6031  AC_CHECK_FILE($SAC_JAR, [],
6032         [AC_MSG_ERROR(sac.jar not found.)], [])
6033
6034  if test -z $LIBXML_JAR; then
6035    AC_CHECK_FILE(/usr/share/java/libxml-1.0.0.jar,
6036      [ LIBXML_JAR=/usr/share/java/libxml-1.0.0.jar ],
6037      [
6038        AC_CHECK_FILE(/usr/share/java/libxml.jar,
6039          [ LIBXML_JAR=/usr/share/java/libxml.jar ],
6040          [AC_MSG_ERROR(libxml.jar replacement not found.)]
6041        )
6042      ]
6043    )
6044  else
6045    AC_CHECK_FILE($LIBXML_JAR, [],
6046         [AC_MSG_ERROR(libxml.jar not found.)], [])
6047  fi
6048
6049  if test -z $FLUTE_JAR; then
6050    AC_CHECK_FILE(/usr/share/java/flute-1.3.0.jar,
6051      [ FLUTE_JAR=/usr/share/java/flute-1.3.0.jar ],
6052      [
6053        AC_CHECK_FILE(/usr/share/java/flute.jar,
6054          [ FLUTE_JAR=/usr/share/java/flute.jar ],
6055          [ AC_MSG_ERROR(flute-1.3.0.jar replacement not found.)]
6056        )
6057      ]
6058    )
6059  else
6060    AC_CHECK_FILE($FLUTE_JAR, [],
6061         [AC_MSG_ERROR(flute-1.3.0.jar not found.)], [])
6062  fi
6063
6064  if test -z $JFREEREPORT_JAR; then
6065    AC_CHECK_FILE(/usr/share/java/flow-engine-0.9.2.jar,
6066      [ JFREEREPORT_JAR=/usr/share/java/flow-engine-0.9.2.jar ],
6067      [
6068        AC_CHECK_FILE(/usr/share/java/flow-engine.jar,
6069          [ JFREEREPORT_JAR=/usr/share/java/flow-engine.jar ],
6070          [AC_MSG_ERROR(jfreereport.jar replacement not found.)]
6071        )
6072      ]
6073    )
6074  else
6075    AC_CHECK_FILE($JFREEREPORT_JAR, [],
6076         [AC_MSG_ERROR(jfreereport.jar not found.)], [])
6077  fi
6078
6079  if test -z $LIBLAYOUT_JAR; then
6080    AC_CHECK_FILE(/usr/share/java/liblayout-0.2.9.jar,
6081      [ LIBLAYOUT_JAR=/usr/share/java/liblayout-0.2.9.jar ],
6082      [
6083        AC_CHECK_FILE(/usr/share/java/liblayout.jar,
6084          [ LIBLAYOUT_JAR=/usr/share/java/liblayout.jar ],
6085          [AC_MSG_ERROR(liblayout.jar replacement not found.)]
6086        )
6087      ]
6088    )
6089  else
6090    AC_CHECK_FILE($LIBLAYOUT_JAR, [],
6091         [AC_MSG_ERROR(liblayout.jar not found.)], [])
6092  fi
6093
6094  if test -z $LIBLOADER_JAR; then
6095    AC_CHECK_FILE(/usr/share/java/libloader-1.0.0.jar,
6096      [ LIBLOADER_JAR=/usr/share/java/libloader-1.0.0.jar ],
6097      [
6098        AC_CHECK_FILE(/usr/share/java/libloader.jar,
6099          [ LIBLOADER_JAR=/usr/share/java/libloader.jar ],
6100          [AC_MSG_ERROR(libloader.jar replacement not found.)]
6101        )
6102      ]
6103    )
6104  else
6105    AC_CHECK_FILE($LIBLOADER_JAR, [],
6106         [AC_MSG_ERROR(libloader.jar not found.)], [])
6107  fi
6108
6109  if test -z $LIBFORMULA_JAR; then
6110    AC_CHECK_FILE(/usr/share/java/libformula-0.2.0.jar,
6111      [ LIBFORMULA_JAR=/usr/share/java/libformula-0.2.0.jar ],
6112      [
6113        AC_CHECK_FILE(/usr/share/java/libformula.jar,
6114          [ LIBFORMULA_JAR=/usr/share/java/libformula.jar ],
6115          [AC_MSG_ERROR(libformula.jar replacement not found.)]
6116        )
6117      ]
6118    )
6119  else
6120    AC_CHECK_FILE($LIBFORMULA_JAR, [],
6121         [AC_MSG_ERROR(libformula.jar not found.)], [])
6122  fi
6123
6124  if test -z $LIBREPOSITORY_JAR; then
6125    AC_CHECK_FILE(/usr/share/java/librepository-1.0.0.jar,
6126      [ LIBREPOSITORY_JAR=/usr/share/java/librepository-1.0.0.jar ],
6127      [
6128        AC_CHECK_FILE(/usr/share/java/librepository.jar,
6129          [ LIBREPOSITORY_JAR=/usr/share/java/librepository.jar ],
6130          [AC_MSG_ERROR(librepository.jar replacement not found.)]
6131        )
6132      ]
6133    )
6134  else
6135    AC_CHECK_FILE($LIBREPOSITORY_JAR, [],
6136         [AC_MSG_ERROR(librepository.jar not found.)], [])
6137  fi
6138
6139  if test -z $LIBFONTS_JAR; then
6140    AC_CHECK_FILE(/usr/share/java/libfonts-1.0.0.jar,
6141      [ LIBFONTS_JAR=/usr/share/java/libfonts-1.0.0.jar ],
6142      [
6143        AC_CHECK_FILE(/usr/share/java/libfonts.jar,
6144          [ LIBFONTS_JAR=/usr/share/java/libfonts.jar ],
6145          [AC_MSG_ERROR(libfonts.jar replacement not found.)]
6146        )
6147      ]
6148    )
6149  else
6150    AC_CHECK_FILE($LIBFONTS_JAR, [],
6151         [AC_MSG_ERROR(libfonts.jar not found.)], [])
6152  fi
6153
6154  if test -z $LIBSERIALIZER_JAR; then
6155    AC_CHECK_FILE(/usr/share/java/libserializer-1.0.0.jar,
6156      [ LIBSERIALIZER_JAR=/usr/share/java/libserializer-1.0.0.jar ],
6157      [
6158        AC_CHECK_FILE(/usr/share/java/libserializer.jar,
6159          [ LIBSERIALIZER_JAR=/usr/share/java/libserializer.jar ],
6160          [AC_MSG_ERROR(libserializer.jar replacement not found.)]
6161        )
6162      ]
6163    )
6164  else
6165    AC_CHECK_FILE($LIBSERIALIZER_JAR, [],
6166         [AC_MSG_ERROR(libserializer.jar not found.)], [])
6167  fi
6168
6169
6170  if test -z $LIBBASE_JAR; then
6171    AC_CHECK_FILE(/usr/share/java/libbase-1.0.0.jar,
6172      [ LIBBASE_JAR=/usr/share/java/libbase-1.0.0.jar ],
6173      [
6174        AC_CHECK_FILE(/usr/share/java/libbase.jar,
6175          [ LIBBASE_JAR=/usr/share/java/libbase.jar ],
6176          [AC_MSG_ERROR(libbase.jar replacement not found.)]
6177        )
6178      ]
6179    )
6180  else
6181    AC_CHECK_FILE($LIBBASE_JAR, [],
6182         [AC_MSG_ERROR(libbase.jar not found.)], [])
6183  fi
6184  BUILD_TYPE="$BUILD_TYPE REPORTBUILDER"
6185else
6186  AC_MSG_RESULT([no])
6187  ENABLE_REPORTBUILDER=NO
6188fi
6189AC_SUBST(ENABLE_REPORTBUILDER)
6190AC_SUBST(SYSTEM_JFREEREPORT)
6191AC_SUBST(SAC_JAR)
6192AC_SUBST(LIBXML_JAR)
6193AC_SUBST(FLUTE_JAR)
6194AC_SUBST(JFREEREPORT_JAR)
6195AC_SUBST(LIBBASE_JAR)
6196AC_SUBST(LIBLAYOUT_JAR)
6197AC_SUBST(LIBLOADER_JAR)
6198AC_SUBST(LIBFORMULA_JAR)
6199AC_SUBST(LIBREPOSITORY_JAR)
6200AC_SUBST(LIBFONTS_JAR)
6201AC_SUBST(LIBSERIALIZER_JAR)
6202
6203# this has to be here because both the wiki publisher and the SRB use
6204# commons-logging
6205if test "$ENABLE_MEDIAWIKI" = "YES" -o "$ENABLE_REPORTBUILDER" = "YES"; then
6206  AC_MSG_CHECKING([which Apache commons-* libs to use])
6207  if test "$with_system_apache_commons" = "yes"; then
6208    SYSTEM_APACHE_COMMONS=YES
6209    AC_MSG_RESULT([external])
6210    if test "$ENABLE_MEDIAWIKI" = "YES"; then
6211      if test -z $COMMONS_CODEC_JAR; then
6212        AC_CHECK_FILE(/usr/share/java/commons-codec-1.3.jar,
6213          [ COMMONS_CODEC_JAR=/usr/share/java/commons-codec-1.3.jar ],
6214          [
6215            AC_CHECK_FILE(/usr/share/java/commons-codec.jar,
6216              [ COMMONS_CODEC_JAR=/usr/share/java/commons-codec.jar ],
6217              [AC_MSG_ERROR(commons-codec.jar replacement not found.)]
6218            )
6219          ]
6220        )
6221      else
6222        AC_CHECK_FILE($COMMONS_CODEC_JAR, [],
6223             [AC_MSG_ERROR(commons-codec.jar not found.)], [])
6224      fi
6225
6226      if test -z $COMMONS_LANG_JAR; then
6227        AC_CHECK_FILE(/usr/share/java/commons-lang-2.3.jar,
6228          [ COMMONS_LANG_JAR=/usr/share/java/commons-lang-2.3.jar ],
6229          [
6230            AC_CHECK_FILE(/usr/share/java/commons-lang.jar,
6231              [ COMMONS_LANG_JAR=/usr/share/java/commons-lang.jar ],
6232              [AC_MSG_ERROR(commons-lang.jar replacement not found.)]
6233            )
6234          ]
6235        )
6236      else
6237        AC_CHECK_FILE($COMMONS_LANG_JAR, [],
6238             [AC_MSG_ERROR(commons-lang.jar not found.)], [])
6239      fi
6240
6241      if test -z $COMMONS_HTTPCLIENT_JAR; then
6242        AC_CHECK_FILE(/usr/share/java/commons-httpclient-3.1.jar,
6243          [ COMMONS_HTTPCLIENT_JAR=/usr/share/java/commons-httpclient-3.1.jar ],
6244          [
6245            AC_CHECK_FILE(/usr/share/java/commons-httpclient.jar,
6246              [ COMMONS_HTTPCLIENT_JAR=/usr/share/java/commons-httpclient.jar ],
6247              [AC_MSG_ERROR(commons-httpclient.jar replacement not found.)]
6248            )
6249          ]
6250        )
6251      else
6252        AC_CHECK_FILE($COMMONS_HTTPCLIENT_JAR, [],
6253             [AC_MSG_ERROR(commons-httpclient.jar not found.)], [])
6254      fi
6255    fi
6256    if test "$ENABLE_MEDIAWIKI" = "YES" -o "$ENABLE_REPORTBUILDER" = "YES"; then
6257      if test -z $COMMONS_LOGGING_JAR; then
6258        AC_CHECK_FILE(/usr/share/java/commons-logging-1.1.1.jar,
6259          [ COMMONS_LOGGING_JAR=/usr/share/java/commons-logging-1.1.1.jar ],
6260          [
6261            AC_CHECK_FILE(/usr/share/java/commons-logging.jar,
6262              [ COMMONS_LOGGING_JAR=/usr/share/java/commons-logging.jar ],
6263              [AC_MSG_ERROR(commons-logging.jar replacement not found.)]
6264            )
6265          ]
6266        )
6267      else
6268        AC_CHECK_FILE($COMMONS_LOGGING_JAR, [],
6269             [AC_MSG_ERROR(commons-logging.jar not found.)], [])
6270      fi
6271    fi
6272  else
6273    AC_MSG_RESULT([internal])
6274    SYSTEM_APACHE_COMMONS=NO
6275    BUILD_TYPE="$BUILD_TYPE APACHE_COMMONS TOMCAT"
6276  fi
6277fi
6278AC_SUBST(SYSTEM_APACHE_COMMONS)
6279AC_SUBST(COMMONS_CODEC_JAR)
6280AC_SUBST(COMMONS_LANG_JAR)
6281AC_SUBST(COMMONS_HTTPCLIENT_JAR)
6282AC_SUBST(COMMONS_LOGGING_JAR)
6283
6284dnl ===================================================================
6285dnl Check whether the Qt and KDE libraries are available.
6286dnl ===================================================================
6287
6288KDE_CFLAGS=""
6289KDE_LIBS=""
6290MOC="moc"
6291if test "$test_kde" = "yes" -a "$ENABLE_KDE" = "TRUE" ; then
6292    dnl Search paths for Qt and KDE
6293    if test "$build_cpu" != "x86_64" ; then
6294        qt_incdirs="$QTINC /usr/local/qt/include /usr/include/qt /usr/include /usr/X11R6/include/X11/qt /usr/X11R6/include/qt /usr/lib/qt3/include /usr/lib/qt/include /usr/share/qt3/include $x_includes"
6295        qt_libdirs="$QTLIB /usr/local/qt/lib /usr/lib/qt /usr/lib /usr/X11R6/lib/X11/qt /usr/X11R6/lib/qt /usr/lib/qt3/lib /usr/lib/qt/lib /usr/share/qt3/lib $x_libraries"
6296    else
6297        qt_incdirs="$QTINC /usr/local/qt/include /usr/include/qt /usr/include /usr/X11R6/include/X11/qt /usr/X11R6/include/qt /usr/lib64/qt3/include /usr/lib64/qt/include /usr/share/qt3/include /usr/lib/qt3/include /usr/lib/qt/include $x_includes"
6298        qt_libdirs="$QTLIB /usr/local/qt/lib64 /usr/lib64/qt /usr/lib64 /usr/X11R6/lib64/X11/qt /usr/X11R6/lib64/qt /usr/lib64/qt3/lib64 /usr/lib64/qt/lib64 /usr/share/qt3/lib64 /usr/local/qt/lib /usr/lib/qt /usr/lib /usr/X11R6/lib/X11/qt /usr/X11R6/lib/qt /usr/lib/qt3/lib /usr/lib/qt/lib /usr/share/qt3/lib $x_libraries"
6299    fi
6300    if test -n "$QTDIR" ; then
6301        qt_incdirs="$QTDIR/include $qt_incdirs"
6302        if test "$build_cpu" != "x86_64" ; then
6303            qt_libdirs="$QTDIR/lib $qt_libdirs"
6304        else
6305            qt_libdirs="$QTDIR/lib64 $QTDIR/lib $qt_libdirs"
6306        fi
6307    fi
6308    if test "$build_cpu" != "x86_64" ; then
6309        kde_incdirs="/usr/lib/kde/include /usr/local/kde/include /usr/local/include /usr/kde/include /usr/include/kde /opt/kde3/include /opt/kde/include $x_includes"
6310        kde_libdirs="/usr/lib/kde/lib /usr/local/kde/lib /usr/kde/lib /usr/lib/kde /usr/lib/kde3 /usr/X11R6/lib /usr/local/lib /opt/kde3/lib /opt/kde/lib /usr/X11R6/kde/lib /usr/lib $x_libraries"
6311    else
6312        kde_incdirs="/usr/lib64/kde/include /usr/lib/kde/include /usr/local/kde/include /usr/local/include /usr/kde/include /usr/include/kde /opt/kde3/include /opt/kde/include $x_includes"
6313        kde_libdirs="/usr/lib64/kde/lib64 /usr/local/kde/lib64 /usr/kde/lib64 /usr/lib64/kde /usr/lib64/kde3 /usr/X11R6/lib64 /usr/local/lib64 /opt/kde3/lib64 /opt/kde/lib64 /usr/X11R6/kde/lib64 /usr/lib/kde/lib /usr/local/kde/lib /usr/kde/lib /usr/lib/kde /usr/lib/kde3 /usr/lib /usr/X11R6/lib /usr/local/lib /opt/kde3/lib /opt/kde/lib /usr/X11R6/kde/lib /usr/lib64 $x_libraries"
6314    fi
6315    if test -n "$KDEDIR" ; then
6316        kde_incdirs="$KDEDIR/include $kde_incdirs"
6317        if test "$build_cpu" != "x86_64" ; then
6318            kde_libdirs="$KDEDIR/lib $kde_libdirs"
6319        else
6320            kde_libdirs="$KDEDIR/lib64 $KDEDIR/lib $kde_libdirs"
6321        fi
6322    fi
6323
6324    dnl What to test
6325    qt_test_include="qstyle.h"
6326    qt_test_library="libqt-mt.so"
6327    kde_test_include="ksharedptr.h"
6328    kde_test_library="libkdeui.so"
6329
6330    dnl Check for Qt headers
6331    AC_MSG_CHECKING([for Qt headers])
6332    qt_incdir="no"
6333    for kde_check in $qt_incdirs ; do
6334        if test -r "$kde_check/$qt_test_include" ; then
6335            qt_incdir="$kde_check"
6336            break
6337        fi
6338    done
6339    AC_MSG_RESULT([$qt_incdir])
6340    if test "x$qt_incdir" = "xno" ; then
6341        AC_MSG_ERROR([Qt headers not found.  Please specify the root of
6342your Qt installation by exporting QTDIR before running "configure".])
6343    fi
6344
6345    dnl Check for Qt libraries
6346    AC_MSG_CHECKING([for Qt libraries])
6347    qt_libdir="no"
6348    for qt_check in $qt_libdirs ; do
6349        if test -r "$qt_check/$qt_test_library" ; then
6350            qt_libdir="$qt_check"
6351            break
6352        fi
6353    done
6354    AC_MSG_RESULT([$qt_libdir])
6355    if test "x$qt_libdir" = "xno" ; then
6356        AC_MSG_ERROR([Qt libraries not found.  Please specify the root of
6357your Qt installation by exporting QTDIR before running "configure".])
6358    fi
6359
6360    dnl Check for Meta Object Compiler
6361    AC_PATH_PROG( MOC, moc, no, [$QTDIR/bin:$PATH] )
6362    if test "$MOC" = "no" ; then
6363        AC_MSG_ERROR([Qt Meta Object Compiler not found.  Please specify
6364the root of your Qt installation by exporting QTDIR before running "configure".])
6365    fi
6366
6367    dnl Check for KDE headers
6368    AC_MSG_CHECKING([for KDE headers])
6369    kde_incdir="no"
6370    for kde_check in $kde_incdirs ; do
6371        if test -r "$kde_check/$kde_test_include" ; then
6372            kde_incdir="$kde_check"
6373            break
6374        fi
6375    done
6376    AC_MSG_RESULT([$kde_incdir])
6377    if test "x$kde_incdir" = "xno" ; then
6378        AC_MSG_ERROR([KDE headers not found.  Please specify the root of
6379your KDE installation by exporting KDEDIR before running "configure".])
6380    fi
6381
6382    dnl Check for KDE libraries
6383    AC_MSG_CHECKING([for KDE libraries])
6384    kde_libdir="no"
6385    for kde_check in $kde_libdirs ; do
6386        if test -r "$kde_check/$kde_test_library" ; then
6387            kde_libdir="$kde_check"
6388            break
6389        fi
6390    done
6391    AC_MSG_RESULT([$kde_libdir])
6392    if test "x$kde_libdir" = "xno" ; then
6393        AC_MSG_ERROR([KDE libraries not found.  Please specify the root of
6394your KDE installation by exporting KDEDIR before running "configure".])
6395    fi
6396
6397    dnl Set the variables
6398    KDE_CFLAGS="-I$qt_incdir -I$kde_incdir -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT"
6399    KDE_LIBS="-L$kde_libdir -L$qt_libdir -lkdeui -lkdecore -lqt-mt"
6400fi
6401AC_SUBST(KDE_CFLAGS)
6402AC_SUBST(KDE_LIBS)
6403AC_SUBST(MOC)
6404
6405dnl ===================================================================
6406dnl KDE4 Integration
6407dnl ===================================================================
6408
6409KDE4_CFLAGS=""
6410KDE4_LIBS=""
6411MOC4="moc"
6412if test "$test_kde4" = "yes" -a "$ENABLE_KDE4" = "TRUE" ; then
6413   qt_incdirs="$QT4INC $QT4DIR /usr/include/qt4 /usr/include $x_includes"
6414   qt_libdirs="$QT4LIB /usr/lib $x_libraries"
6415
6416   kde_incdirs="/usr/include /usr/include/kde4 $x_includes"
6417   kde_libdirs="/usr/lib /usr/lib/kde4 /usr/lib/kde4/devel $x_libraries"
6418
6419   if test "$build_cpu" = "x86_64" ; then
6420      qt_libdirs="$qt_libdirs /usr/lib64/qt4 /usr/lib64/qt /usr/lib64"
6421      kde_libdirs="$kde_libdirs /usr/lib64 /usr/lib64/kde4 /usr/lib64/kde4/devel"
6422   fi
6423
6424   if test -n "$KDE4DIR" ; then
6425      kde_incdirs="$KDE4DIR/include $kde_incdirs"
6426      if test "$build_cpu" != "x86_64" ; then
6427         kde_libdirs="$KDE4DIR/lib $kde_libdirs"
6428      else
6429         kde_libdirs="$KDE4DIR/lib64 $KDE4DIR/lib $kde_libdirs"
6430      fi
6431   fi
6432
6433   qt_test_include="Qt/qobject.h"
6434   qt_test_library="libQtCore.so"
6435   kde_test_include="ksharedptr.h"
6436   kde_test_library="libkdeui.so"
6437
6438   AC_MSG_CHECKING([for Qt4 headers])
6439   qt_header_dir="no"
6440   for inc_dir in $qt_incdirs ; do
6441      if test -r "$inc_dir/$qt_test_include" ; then
6442         qt_header_dir="$inc_dir"
6443         break
6444      fi
6445   done
6446
6447   AC_MSG_RESULT([$qt_header_dir])
6448   if test "x$qt_header_dir" = "xno" ; then
6449      AC_MSG_ERROR([Qt4 headers not found.  Please specify the root of your Qt4 installation by exporting QT4DIR before running "configure".])
6450   fi
6451
6452   AC_MSG_CHECKING([for Qt4 libraries])
6453   qt_lib_dir="no"
6454   for lib_dir in $qt_libdirs ; do
6455      if test -r "$lib_dir/$qt_test_library" ; then
6456         qt_lib_dir="$lib_dir"
6457         break
6458      fi
6459   done
6460
6461   AC_MSG_RESULT([$qt_lib_dir])
6462
6463   if test "x$qt_lib_dir" = "xno" ; then
6464      AC_MSG_ERROR([Qt4 libraries not found.  Please specify the root of your Qt4 installation by exporting QT4DIR before running "configure".])
6465   fi
6466
6467   dnl Check for Meta Object Compiler
6468   AC_PATH_PROG( MOCQT4, moc-qt4, no, [$QT4DIR/bin:$PATH] )
6469   MOC4="$MOCQT4"
6470   if test "$MOC4" = "no" ; then
6471      AC_PATH_PROG( MOC4, moc, no, [$PATH:$QT4DIR/bin] )
6472      if test "$MOC4" = "no" ; then
6473         AC_MSG_ERROR([Qt Meta Object Compiler not found.  Please specify the root of your Qt installation by exporting QT4DIR before running "configure".])
6474      fi
6475   fi
6476
6477   dnl Check for KDE4 headers
6478   AC_MSG_CHECKING([for KDE4 headers])
6479   kde_incdir="no"
6480   for kde_check in $kde_incdirs ; do
6481      if test -r "$kde_check/$kde_test_include" ; then
6482         kde_incdir="$kde_check"
6483         break
6484      fi
6485   done
6486   AC_MSG_RESULT([$kde_incdir])
6487   if test "x$kde_incdir" = "xno" ; then
6488      AC_MSG_ERROR([KDE4 headers not found.  Please specify the root of your KDE4 installation by exporting KDE4DIR before running "configure".])
6489   fi
6490
6491   dnl Check for KDE4 libraries
6492   AC_MSG_CHECKING([for KDE4 libraries])
6493   kde_libdir="no"
6494   for kde_check in $kde_libdirs ; do
6495      if test -r "$kde_check/$kde_test_library" ; then
6496         kde_libdir="$kde_check"
6497         break
6498      fi
6499   done
6500
6501   AC_MSG_RESULT([$kde_libdir])
6502   if test "x$kde_libdir" = "xno" ; then
6503      AC_MSG_ERROR([KDE4 libraries not found.  Please specify the root of your KDE4 installation by exporting KDE4DIR before running "configure".])
6504   fi
6505
6506   KDE4_CFLAGS="`pkg-config --cflags QtCore` `pkg-config --cflags QtGui` -I$kde_incdir -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT"
6507   KDE4_LIBS="-L$kde_libdir -L$qt_lib_dir -lkdeui -lkdecore -lQtCore -lQtGui"
6508fi
6509AC_SUBST(KDE4_CFLAGS)
6510AC_SUBST(KDE4_LIBS)
6511AC_SUBST(MOC4)
6512
6513dnl ===================================================================
6514dnl Test for the enabling the lockdown pieces
6515dnl ===================================================================
6516AC_MSG_CHECKING([whether to enable the lockdown pieces])
6517ENABLE_LOCKDOWN=""
6518if test -n "$enable_lockdown" && test "$enable_lockdown" != "no"; then
6519  ENABLE_LOCKDOWN=YES
6520  AC_MSG_RESULT([yes])
6521else
6522  AC_MSG_RESULT([no])
6523fi
6524AC_SUBST(ENABLE_LOCKDOWN)
6525
6526dnl ===================================================================
6527dnl Test whether to include Evolution 2 support
6528dnl ===================================================================
6529AC_MSG_CHECKING([whether to enable evolution 2 support])
6530if test "$enable_evolution2" = "yes" -o "$enable_evolution2" = "TRUE"; then
6531   AC_MSG_RESULT([yes])
6532   PKG_CHECK_MODULES(GOBJECT, gobject-2.0)
6533   ENABLE_EVOAB2="TRUE"
6534else
6535   ENABLE_EVOAB2=""
6536   AC_MSG_RESULT([no])
6537fi
6538AC_SUBST(ENABLE_EVOAB2)
6539AC_SUBST(GOBJECT_CFLAGS)
6540AC_SUBST(GOBJECT_LIBS)
6541
6542dnl ===================================================================
6543dnl Test whether to include KDE AB support
6544dnl ===================================================================
6545AC_MSG_CHECKING([whether to enable KDE address book support])
6546if test "$enable_kdeab" = "yes" && test "$enable_kde" = "yes"; then
6547   AC_MSG_RESULT([yes])
6548   AC_LANG_PUSH([C++])
6549   save_CXXFLAGS=$CXXFLAGS
6550   CXXFLAGS="$CXXFLAGS $KDE_CFLAGS"
6551   AC_MSG_CHECKING([whether KDE is between 3.2 and 3.6])
6552       AC_TRY_RUN([
6553#include <kdeversion.h>
6554
6555int main(int argc, char **argv) {
6556       if (KDE_VERSION_MAJOR == 3 && 2 <= KDE_VERSION_MINOR && KDE_VERSION_MINOR <= 6) return 0;
6557       else return 1;
6558}
6559       ], [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([KDE version too old or too recent, please use another version of KDE or disable KDE address book support])])
6560   CXXFLAGS=$save_CXXFLAGS
6561   AC_LANG_POP([C++])
6562   ENABLE_KAB=TRUE
6563else
6564   AC_MSG_RESULT([no])
6565   ENABLE_KAB=
6566fi
6567AC_SUBST(ENABLE_KAB)
6568
6569dnl ===================================================================
6570dnl Test whether to include MathMLDTD
6571dnl ===================================================================
6572AC_MSG_CHECKING([whether to include MathMLDTD])
6573if test -n "$enable_mathmldtd"; then
6574  if test "$enable_mathmldtd" = "no"; then
6575    AC_MSG_RESULT([no])
6576    SCPDEFS="$SCPDEFS -DWITHOUT_MATHMLDTD"
6577  else
6578    AC_MSG_RESULT([yes])
6579    BUILD_TYPE="$BUILD_TYPE MATHMLDTD"
6580  fi
6581else
6582  AC_MSG_RESULT([no])
6583  SCPDEFS="$SCPDEFS -DWITHOUT_MATHMLDTD"
6584fi
6585
6586dnl ===================================================================
6587dnl Test whether to include fonts
6588dnl ===================================================================
6589AC_MSG_CHECKING([whether to include third-party fonts])
6590if test "$with_fonts" != "no" ; then
6591  AC_MSG_RESULT([yes])
6592  WITH_FONTS=YES
6593  BUILD_TYPE="$BUILD_TYPE MORE_FONTS"
6594else
6595  AC_MSG_RESULT([no])
6596  WITH_FONTS=NO
6597  SCPDEFS="$SCPDEFS -DWITHOUT_FONTS"
6598fi
6599AC_SUBST(WITH_FONTS)
6600
6601dnl ===================================================================
6602dnl Test whether to include ppds
6603dnl ===================================================================
6604AC_MSG_CHECKING([whether to include PPDs])
6605if test "$with_ppds" != "no"; then
6606  AC_MSG_RESULT([yes])
6607else
6608  AC_MSG_RESULT([no])
6609  WITHOUT_PPDS=YES
6610  SCPDEFS="$SCPDEFS -DWITHOUT_PPDS"
6611fi
6612AC_SUBST(WITHOUT_PPDS)
6613
6614dnl ===================================================================
6615dnl Test whether to include afms
6616dnl ===================================================================
6617AC_MSG_CHECKING([whether to include AFMs])
6618if test "$with_afms" != "no"; then
6619  AC_MSG_RESULT([yes])
6620  BUILD_TYPE="$BUILD_TYPE AFMS"
6621else
6622  AC_MSG_RESULT([no])
6623  WITHOUT_AFMS=YES
6624  SCPDEFS="$SCPDEFS -DWITHOUT_AFMS"
6625fi
6626AC_SUBST(WITHOUT_AFMS)
6627
6628AC_SUBST(SCPDEFS)
6629
6630AC_MSG_CHECKING([whether and how to use Xinerama])
6631if test "$_os" = "Darwin"; then
6632   USE_XINERAMA=YES
6633   XINERAMA_LINK=dynamic
6634   AC_MSG_RESULT([yes])
6635elif test "$_os" = "Linux" -o "$_os" = "FreeBSD"; then
6636   if test -e "$XLIB/libXinerama.so" -a -e "$XLIB/libXinerama.a"; then
6637      # we have both versions, let the user decide but use the dynamic one
6638      # per default
6639      USE_XINERAMA=YES
6640      if test -z "$with_static_xinerama" -o -n "$with_system_libs"; then
6641         XINERAMA_LINK=dynamic
6642      else
6643         XINERAMA_LINK=static
6644      fi
6645   elif test -e "$XLIB/libXinerama.so" -a ! -e "$XLIB/libXinerama.a"; then
6646      # we have only the dynamic version
6647      USE_XINERAMA=YES
6648      XINERAMA_LINK=dynamic
6649   elif test -e "$XLIB/libXinerama.a"; then
6650      # static version
6651      if echo $build_cpu | grep -E 'i[[3456]]86' 2>/dev/null >/dev/null; then
6652         USE_XINERAMA=YES
6653         XINERAMA_LINK=static
6654      else
6655         USE_XINERAMA=NO
6656         XINERAMA_LINK=none
6657      fi
6658   else
6659      # no Xinerama
6660      USE_XINERAMA=NO
6661      XINERAMA_LINK=none
6662   fi
6663   if test "$USE_XINERAMA" = "YES"; then
6664      AC_MSG_RESULT([yes, with $XINERAMA_LINK linking])
6665      AC_CHECK_HEADER(X11/extensions/Xinerama.h, [],
6666          [AC_MSG_ERROR(Xinerama header not found.)], [])
6667      XINERAMA_EXTRA_LIBS="-L$XLIB -lXext"
6668      if test "$_os" = "FreeBSD"; then
6669          XINERAMA_EXTRA_LIBS="$XINERAMA_EXTRA_LIBS -lXt"
6670      fi
6671      if test "$_os" = "Linux"; then
6672          XINERAMA_EXTRA_LIBS="$XINERAMA_EXTRA_LIBS -ldl"
6673      fi
6674      AC_CHECK_LIB(Xinerama, XineramaIsActive, [],
6675          [AC_MSG_ERROR(Xinerama not functional?)], [$XINERAMA_EXTRA_LIBS])
6676   else
6677      AC_MSG_RESULT([no, libXinerama not found or wrong architecture.])
6678   fi
6679else
6680   AC_MSG_RESULT([no])
6681fi
6682AC_SUBST(USE_XINERAMA)
6683AC_SUBST(XINERAMA_LINK)
6684
6685dnl ===================================================================
6686dnl always rely on the system version of gdk-pixbuf
6687dnl ===================================================================
6688
6689SYSTEM_GDKPIXBUF=YES
6690AC_SUBST(SYSTEM_GDKPIXBUF)
6691
6692dnl ===================================================================
6693dnl always rely on the system version of glib
6694dnl ===================================================================
6695
6696SYSTEM_GLIB=YES
6697AC_SUBST(SYSTEM_GLIB)
6698
6699dnl ===================================================================
6700dnl always rely on the system version of gettext
6701dnl ===================================================================
6702
6703SYSTEM_GETTEXT=YES
6704AC_SUBST(SYSTEM_GETTEXT)
6705
6706dnl ===================================================================
6707dnl always rely on the system version of pango
6708dnl ===================================================================
6709
6710SYSTEM_PANGO=YES
6711AC_SUBST(SYSTEM_PANGO)
6712
6713dnl ===================================================================
6714dnl Test whether to build libpng or rely on the system version
6715dnl ===================================================================
6716AC_MSG_CHECKING([whether to build own version of libpng])
6717
6718case "$_os" in
6719	WINNT*) # Windows
6720	    SYSTEM_LIBPNG=NO
6721	    AC_MSG_RESULT([yes])
6722		;;
6723	Darwin*)
6724	    SYSTEM_LIBPNG=NO
6725	    AC_MSG_RESULT([yes])
6726	    ;;
6727   *)
6728   SYSTEM_LIBPNG=YES
6729   AC_MSG_RESULT([no])
6730   ;;
6731esac
6732AC_SUBST(SYSTEM_LIBPNG)
6733
6734dnl ===================================================================
6735dnl Test whether to build libjpeg or rely on the system version
6736dnl ===================================================================
6737dnl FIXME: this is currently because we have jpeg-6b for our filters
6738dnl        and jpeg-8 as dependency for librsvg
6739dnl        this should be unified into using only one version for both
6740
6741AC_MSG_CHECKING([whether to build own version of libjpeg])
6742
6743if test "$SYSTEM_JPEG" = "YES"; then
6744SYSTEM_LIBJPEG=YES
6745else
6746case "$_os" in
6747	WINNT*) # Windows
6748	    SYSTEM_LIBJPEG=NO
6749	    AC_MSG_RESULT([yes])
6750		;;
6751	Darwin*)
6752	    SYSTEM_LIBJPEG=NO
6753	    AC_MSG_RESULT([yes])
6754	    ;;
6755   *)
6756   SYSTEM_LIBJPEG=YES
6757   AC_MSG_RESULT([no])
6758   ;;
6759esac
6760fi
6761
6762if test "$SYSTEM_LIBJPEG" = "YES"; then
6763   AC_MSG_RESULT([no])
6764else
6765   AC_MSG_RESULT([yes])
6766fi
6767AC_SUBST(SYSTEM_LIBJPEG)
6768
6769
6770dnl ===================================================================
6771dnl Test for the presence of Ant and that it works
6772dnl ===================================================================
6773
6774if test "$SOLAR_JAVA" != ""; then
6775ANT_HOME=; export ANT_HOME
6776WITH_ANT_HOME=; export WITH_ANT_HOME
6777if test -z "$with_ant_home"; then
6778   AC_PATH_PROGS(ANT, [jakarta-ant ant ant.sh ant.bat ant.cmd])
6779else
6780   if test "$_os" = "WINNT"; then
6781      with_ant_home=`cygpath -u "$with_ant_home"`
6782   fi
6783   AC_PATH_PROGS(ANT, [jakarta-ant ant ant.sh ant.bat ant.cmd],,$with_ant_home/bin:$PATH)
6784   WITH_ANT_HOME=$with_ant_home
6785   ANT_HOME=$with_ant_home
6786fi
6787
6788if test -z "$ANT"; then
6789  AC_MSG_ERROR([Ant not found - Make sure it's in the path or use --with-ant-home])
6790else
6791  # resolve relative or absolute symlink
6792  while test -h "$ANT"; do
6793     a_cwd=`pwd`
6794     a_basename=`basename "$ANT"`
6795     a_script=`ls -l "$ANT" | sed "s/.*${a_basename} -> //g"`
6796     cd "`dirname "$ANT"`"
6797     cd "`dirname "$a_script"`"
6798     ANT="`pwd`"/"`basename "$a_script"`"
6799     cd "$a_cwd"
6800  done
6801
6802  if test "$_os" = "OS2"; then
6803    ANT_HOME=`echo $ANT | $SED -n "s/\/bin\/ant.*\$//p"`
6804    export ANT_HOME
6805  fi
6806
6807  AC_MSG_CHECKING([if $ANT works])
6808cat > conftest.java << EOF
6809    public class conftest {
6810	int testmethod(int a, int b) {
6811            return a + b;
6812	}
6813    }
6814EOF
6815
6816cat > conftest.xml << EOF
6817    <project name="conftest" default="conftest">
6818	<target name="conftest">
6819            <javac srcdir="." includes="conftest.java">
6820	    </javac>
6821	</target>
6822    </project>
6823EOF
6824  oldJAVA_HOME=$JAVA_HOME
6825  if test "$JAVACISGCJ" = "yes"; then
6826    JAVA_HOME=; export JAVA_HOME
6827    ant_cmd="$ANT -Dbuild.compiler=gcj -buildfile conftest.xml 1>&2"
6828  else
6829    ant_cmd="$ANT -buildfile conftest.xml 1>&2"
6830  fi
6831  AC_TRY_EVAL(ant_cmd)
6832  if test $? = 0 && test -f ./conftest.class ; then
6833    AC_MSG_RESULT([Ant works])
6834    if test -z "$WITH_ANT_HOME"; then
6835        ANT_HOME=`$ANT -diagnostics | $EGREP "ant.home :" | $SED -e "s#ant.home : ##g"`
6836        if test -z "$ANT_HOME"; then
6837            ANT_HOME=`echo $ANT | $SED -n "s/\/bin\/ant.*\$//p"`
6838        fi
6839    else
6840        ANT_HOME="$WITH_ANT_HOME"
6841    fi
6842  else
6843    echo "configure: Ant test failed" >&5
6844    cat conftest.java >&5
6845    cat conftest.xml >&5
6846    AC_MSG_WARN([Ant does not work - Some Java projects will not build!])
6847    ANT_HOME=""
6848    echo "Ant does not work - Some Java projects will not build!" >>warn
6849  fi
6850  JAVA_HOME=$oldJAVA_HOME
6851  rm -f conftest* core core.* *.core
6852fi
6853if test -z "$ANT_HOME"; then
6854   ANT_HOME="NO_ANT_HOME"
6855fi
6856AC_SUBST(ANT_HOME)
6857
6858dnl Checking for ant.jar
6859if test "$ANT_HOME" != "NO_ANT_HOME"; then
6860   AC_MSG_CHECKING([Ant lib directory])
6861   if test -f $ANT_HOME/lib/ant.jar; then
6862	  ANT_LIB="$ANT_HOME/lib"
6863   else
6864      if test -f $ANT_HOME/ant.jar; then
6865	     ANT_LIB="$ANT_HOME"
6866      else
6867          if test -f /usr/share/java/ant.jar; then
6868              ANT_LIB=/usr/share/java
6869          else
6870             if test -f /usr/share/ant-core/lib/ant.jar; then
6871                 ANT_LIB=/usr/share/ant-core/lib
6872             else
6873                if test -f $ANT_HOME/lib/ant/ant.jar; then
6874                    ANT_LIB="$ANT_HOME/lib/ant"
6875                else
6876                   if test -f /usr/share/lib/ant/ant.jar; then
6877                       ANT_LIB=/usr/share/lib/ant
6878                   else
6879                       AC_MSG_ERROR([Ant libraries not found!])
6880                   fi
6881                fi
6882             fi
6883          fi
6884      fi
6885   fi
6886   AC_MSG_RESULT([Ant lib directory found.])
6887fi
6888AC_SUBST(ANT_LIB)
6889fi
6890
6891ant_minver=1.6.0
6892# update for more extensions...
6893if test "$ENABLE_MEDIAWIKI" = "YES"; then
6894  ant_minver=1.7.0
6895fi
6896ant_minminor1=`echo $ant_minver | cut -d"." -f2`
6897
6898AC_MSG_CHECKING([whether ant is >= $ant_minver])
6899ant_version=`$ANT -version | $AWK '{ print $4; }'`
6900ant_version_major=`echo $ant_version | cut -d. -f1`
6901ant_version_minor=`echo $ant_version | cut -d. -f2`
6902echo "configure: ant_version $ant_version " >&5
6903echo "configure: ant_version_major $ant_version_major " >&5
6904echo "configure: ant_version_minor $ant_version_minor " >&5
6905if test "$ant_version_major" -ge "2"; then
6906   AC_MSG_RESULT([yes, $ant_version])
6907elif test "$ant_version_major" = "1" && test "$ant_version_minor" -ge "$ant_minminor1"; then
6908   AC_MSG_RESULT([yes, $ant_version])
6909else
6910   AC_MSG_ERROR([no, you need at least ant >= $ant_minver])
6911fi
6912
6913if test "$ENABLE_MEDIAWIKI" = "YES"; then
6914AC_MSG_CHECKING([whether ant supports mapper type="regexp"])
6915rm -rf confdir
6916mkdir confdir
6917cat > conftest.java << EOF
6918    public class conftest {
6919        int testmethod(int a, int b) {
6920            return a + b;
6921        }
6922    }
6923EOF
6924
6925cat > conftest.xml << EOF
6926    <project name="conftest" default="conftest">
6927        <target name="conftest" depends="copytest">
6928            <javac srcdir="." includes="conftest.java">
6929            </javac>
6930        </target>
6931        <target name="copytest">
6932             <copy todir="confdir">
6933                 <fileset dir="confdir" includes="**/*.abc" casesensitive="yes"/>
6934                 <filterset/>
6935                 <mapper type="regexp" from="^(.*[/\\])foo([/\\].*)" to="\1baa\2"/>
6936             </copy>
6937        </target>
6938    </project>
6939EOF
6940  if test "$JAVACISGCJ" = "yes"; then
6941    JAVA_HOME=; export JAVA_HOME
6942    ant_cmd="$ANT -Dbuild.compiler=gcj -buildfile conftest.xml 1>&2"
6943  else
6944    ant_cmd="$ANT -buildfile conftest.xml 1>&2"
6945  fi
6946  AC_TRY_EVAL(ant_cmd)
6947  if test $? = 0 && test -f ./conftest.class ; then
6948    AC_MSG_RESULT([yes])
6949    rm -rf confdir
6950  else
6951    echo "configure: Ant test failed" >&5
6952    cat conftest.java >&5
6953    cat conftest.xml >&5
6954    rm -rf confdir
6955    AC_MSG_ERROR([no. Did you install ant-apache-regexp?])
6956  fi
6957fi
6958rm -f conftest* core core.* *.core
6959
6960OOO_JUNIT_JAR=
6961if test "$SOLAR_JAVA" != "" && test "$with_junit" != "no"; then
6962    AC_MSG_CHECKING([for JUnit 4])
6963    if test "$with_junit" = "yes"; then
6964        if test -e /usr/share/java/junit4.jar; then
6965            OOO_JUNIT_JAR=/usr/share/java/junit4.jar
6966        else
6967           if test -e /usr/share/lib/java/junit.jar; then
6968              OOO_JUNIT_JAR=/usr/share/lib/java/junit.jar
6969           else
6970              OOO_JUNIT_JAR=/usr/share/java/junit.jar
6971           fi
6972        fi
6973    else
6974        OOO_JUNIT_JAR=$with_junit
6975    fi
6976    if test "$_os" = "WINNT"; then
6977        OOO_JUNIT_JAR=`cygpath -m "$OOO_JUNIT_JAR"`
6978    fi
6979    "$JAVA_HOME/bin/jar" tf "$OOO_JUNIT_JAR" 2>&5 | \
6980        grep org/junit/Before.class > /dev/null 2>&5
6981    if test $? -eq 0; then
6982        AC_MSG_RESULT([$OOO_JUNIT_JAR])
6983    else
6984        AC_MSG_RESULT([no])
6985        AC_MSG_ERROR([cannot find JUnit 4 jar; please install one in the default
6986location (/usr/share/java), specify its pathname via
6987--with-junit=..., or disable it via --without-junit])
6988    fi
6989fi
6990AC_SUBST(OOO_JUNIT_JAR)
6991
6992AC_MSG_CHECKING([which languages to be built])
6993WITH_LANG="$with_lang"
6994if test -z "$WITH_LANG"; then
6995   AC_MSG_RESULT([en-US])
6996else
6997   AC_MSG_RESULT([$WITH_LANG])
6998fi
6999AC_SUBST(WITH_LANG)
7000
7001AC_MSG_CHECKING([which languages have poor help localizations])
7002WITH_POOR_HELP_LOCALIZATIONS="$with_poor_help_localizations"
7003if test -z "$WITH_POOR_HELP_LOCALIZATIONS"; then
7004   AC_MSG_RESULT([none])
7005else
7006   AC_MSG_RESULT([$WITH_POOR_HELP_LOCALIZATIONS])
7007fi
7008AC_SUBST(WITH_POOR_HELP_LOCALIZATIONS)
7009
7010AC_MSG_CHECKING([which dictionaries to include])
7011if test -z "$with_dict"; then
7012   WITH_DICT=,ALL,
7013   AC_MSG_RESULT([ALL])
7014else
7015   WITH_DICT=","$with_dict","
7016   AC_MSG_RESULT([$with_dict])
7017fi
7018AC_SUBST(WITH_DICT)
7019
7020AC_MSG_CHECKING([for additional 'intro' bitmaps])
7021INTRO_BITMAPS=
7022if test -z "$with_intro_bitmaps" -o "$with_intro_bitmaps" = "no" ; then
7023   INTRO_BITMAPS=
7024   AC_MSG_RESULT([none])
7025else
7026   for bitmap in `echo $with_intro_bitmaps | tr ',' ' '` ; do
7027      case "$bitmap" in
7028         *.bmp) ;;
7029         *)     bitmap= ; AC_MSG_WARN([Intro bitmaps should be .bmp files!]) ;;
7030      esac
7031      if test -n "$bitmap" ; then
7032         INTRO_BITMAPS="$INTRO_BITMAPS $bitmap"
7033      fi
7034   done
7035   AC_MSG_RESULT([$INTRO_BITMAPS])
7036fi
7037AC_SUBST(INTRO_BITMAPS)
7038
7039AC_MSG_CHECKING([for additional 'about' bitmaps])
7040ABOUT_BITMAPS=
7041if test -z "$with_about_bitmaps" -o "$with_about_bitmaps" = "no" ; then
7042   ABOUT_BITMAPS=
7043   AC_MSG_RESULT([none])
7044else
7045   for bitmap in `echo $with_about_bitmaps | tr ',' ' '` ; do
7046      case "$bitmap" in
7047         *.bmp) ;;
7048         *)     bitmap= ; AC_MSG_WARN([About bitmaps should be .bmp files!]) ;;
7049      esac
7050      if test -n "$bitmap" ; then
7051         ABOUT_BITMAPS="$ABOUT_BITMAPS $bitmap"
7052      fi
7053   done
7054   AC_MSG_RESULT([$ABOUT_BITMAPS])
7055fi
7056AC_SUBST(ABOUT_BITMAPS)
7057
7058OOO_VENDOR=
7059AC_MSG_CHECKING([for vendor])
7060if test -z "$with_vendor" -o "$with_vendor" = "no" ; then
7061   AC_MSG_RESULT([not set])
7062else
7063   OOO_VENDOR="$with_vendor"
7064   AC_MSG_RESULT([$OOO_VENDOR])
7065fi
7066AC_SUBST(OOO_VENDOR)
7067
7068UNIXWRAPPERNAME=
7069AC_MSG_CHECKING([for UNIX wrapper name])
7070if test -z "$with_unix_wrapper" -o "$with_unix_wrapper" = "no"  -o "$with_unix_wrapper" = "yes" ; then
7071   AC_MSG_RESULT([not set])
7072else
7073   UNIXWRAPPERNAME="$with_unix_wrapper"
7074   AC_MSG_RESULT([$UNIXWRAPPERNAME])
7075fi
7076AC_SUBST(UNIXWRAPPERNAME)
7077
7078AC_MSG_CHECKING([whether to statically link to Gtk])
7079if test -n "$enable_static_gtk" && test "$enable_static_gtk" != "no"; then
7080   ENABLE_STATIC_GTK="TRUE"
7081   AC_MSG_RESULT([yes])
7082else
7083   ENABLE_STATIC_GTK="FALSE"
7084   AC_MSG_RESULT([no])
7085fi
7086AC_SUBST(ENABLE_STATIC_GTK)
7087
7088AC_MSG_CHECKING([whether to use layout dialogs])
7089if test -n "$enable_layout" && test "$enable_layout" != "no"; then
7090   ENABLE_LAYOUT="TRUE"
7091   AC_MSG_RESULT([yes])
7092else
7093   ENABLE_LAYOUT="FALSE"
7094   AC_MSG_RESULT([no])
7095fi
7096AC_SUBST(ENABLE_LAYOUT)
7097
7098# ===================================================================
7099# De- or increase default verbosity of build process
7100# ===================================================================
7101AC_MSG_CHECKING([build verbosity])
7102if test -n "$enable_verbose"; then
7103   if test "$enable_verbose" = "yes"; then
7104      VERBOSE="TRUE"
7105      AC_MSG_RESULT([high])
7106   fi
7107   if test "$enable_verbose" = "no"; then
7108      VERBOSE="FALSE"
7109      AC_MSG_RESULT([low])
7110   fi
7111else
7112   AC_MSG_RESULT([not set])
7113fi
7114AC_SUBST(VERBOSE)
7115
7116dnl ===================================================================
7117dnl Hook up OOos nodep environmental variable to automake's equivalent
7118dnl --enable-dependency-tracking configure option
7119dnl ===================================================================
7120AC_MSG_CHECKING([whether to enable dependency tracking])
7121if test "$enable_dependency_tracking" = "no"; then
7122    nodep=TRUE
7123    AC_MSG_RESULT([no])
7124else
7125    AC_MSG_RESULT([yes])
7126fi
7127AC_SUBST(nodep)
7128
7129dnl ===================================================================
7130dnl Setting up the environment.
7131dnl ===================================================================
7132echo "********************************************************************"
7133echo "*                                                                  *"
7134echo "*   Setting up the build environment variables.                    *"
7135echo "*                                                                  *"
7136echo "********************************************************************"
7137
7138if test -z "$COMPATH"; then
7139   AC_MSG_ERROR([No compiler found.])
7140fi
7141AC_SUBST(COMPATH)
7142
7143AC_MSG_CHECKING([solver path])
7144if test -z "$with_local_solver"; then
7145   LOCAL_SOLVER="DEFAULT"
7146   AC_MSG_RESULT([default])
7147else
7148   LOCAL_SOLVER=$with_local_solver
7149   AC_MSG_RESULT([$with_local_solver])
7150fi
7151AC_SUBST(LOCAL_SOLVER)
7152
7153AC_SUBST(BUILD_TYPE)
7154
7155# make sure config.guess is +x; we execute config.guess, so it has to be so;
7156chmod +x ./config.guess
7157
7158AC_OUTPUT([set_soenv Makefile])
7159
7160dnl Executing the set_soenv script to setup the environment variables.
7161chmod a+x set_soenv
7162if test -z "$enable_check_only"; then
7163   './set_soenv'
7164else
7165   echo
7166   echo Test Complete
7167   echo No environment file will be generated
7168   echo
7169   num_warnings=`wc -l warn`
7170   _num=`echo $num_warnings | $AWK '{ print $1 }'`
7171   if test $_num -gt 0; then
7172      echo The following warning\(s\) were generated by configure
7173      echo ----------------------------------------------------
7174      echo
7175      cat warn
7176      echo
7177   else
7178      echo There were no warnings
7179   fi
7180   echo
7181fi
7182