]> git.lyx.org Git - lyx.git/blob - configure.ac
8ae4fd1d26c30a6ba21323b6a9fe87451c9885f3
[lyx.git] / configure.ac
1 dnl Process with autoconf to generate configure script   -*- sh -*-
2
3 AC_INIT(LyX,2.0.0svn,[lyx-devel@lists.lyx.org],[lyx])
4 AC_SUBST(LYX_DATE, ["Sat, Nov 15, 2008"])
5 AC_PREREQ(2.52)
6 AC_CONFIG_SRCDIR(src/main.cpp)
7 AC_CONFIG_HEADERS([config.h])
8
9 AC_CONFIG_AUX_DIR(config)
10
11 # First check the version
12 LYX_CHECK_VERSION
13 LYX_VERSION_SUFFIX
14 # Check how the files should be packaged
15 AC_CANONICAL_TARGET
16 LYX_USE_PACKAGING
17 # We need to define these variables here and the no-define option of
18 # AM_INIT_AUTOMAKE above because we alter $PACKAGE in LYX_USE_PACKAGING.
19 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
20
21 dnl default maintainer mode to true for development versions
22 if test "${enable_maintainer_mode+set}" != set; then
23   enable_maintainer_mode=$lyx_devel_version
24 fi
25 AM_MAINTAINER_MODE
26
27 save_PACKAGE=$PACKAGE
28 AM_INIT_AUTOMAKE([foreign dist-bzip2 no-define 1.5])
29 PACKAGE=$save_PACKAGE
30
31 ### Set the execute permissions of the various scripts correctly
32 for file in config/install-sh config/mkinstalldirs ; do
33   chmod 755 ${srcdir}/${file}
34 done
35
36 ### Check for programs
37 dnl AC_PROG_MAKE_SET
38 dnl AC_PROG_INSTALL
39
40 # Check for installed python
41 AM_PATH_PYTHON(2.3.4,, :)
42
43 # Work around a problem in automake 1.4: when invoking install-strip,
44 # INSTALL_PROGRAM is changed to 'install -s', and since
45 # INSTALL_SCRIPT==INSTALL_PROGRAM, we get errors with fileutils-4.0
46 # which returns an error condition when stripping fails.
47 INSTALL_SCRIPT='${INSTALL}'
48
49 ### we will also need a C compiler to compile GNU gettext
50 AC_PROG_CC
51 AC_USE_SYSTEM_EXTENSIONS
52
53 ### we need to know the byte order for unicode conversions
54 AC_C_BIGENDIAN
55
56 ### check which frontend we want to use
57 LYX_USE_FRONTENDS
58
59 ### Check for a C++ compiler
60 LYX_PROG_CXX
61 ### Some checks on what the C++ compiler can(not) do
62 AC_LANG(C++)
63 dnl we do not need that currently (and probably all our supported
64 dnl compiler allow that)
65 dnl LYX_CXX_PARTIAL
66 dnl LYX_CXX_EXPLICIT
67 dnl LYX_CXX_GLOBAL_CSTD
68 dnl LYX_STD_COUNT
69 dnl we disable rtti for now
70 dnl LYX_CXX_RTTI
71 dnl AC_CHECK_HEADERS(ostream istream sstream locale limits ios)
72 dnl LYX_CXX_STL_MODERN_STREAMS
73
74 ### Objective-C compiler
75 AC_PROG_OBJC
76 _AM_DEPENDENCIES([OBJC])
77
78 ### and now some special lyx flags.
79 AC_ARG_ENABLE(assertions,
80   AC_HELP_STRING([--enable-assertions],[add runtime sanity checks in the program]),,
81   [if test $lyx_devel_version = yes -o $lyx_prerelease = yes ; then
82         enable_assertions=yes;
83     else
84         enable_assertions=no;
85     fi;])
86 if test "x$enable_assertions" = xyes ; then
87    lyx_flags="assertions $lyx_flags"
88    AC_DEFINE(ENABLE_ASSERTIONS,1,
89     [Define if you want assertions to be enabled in the code])
90 fi
91
92 ### Library Files
93 dnl AC_CHECK_LIB(m, sin)
94
95 ### Add extra directories to check for libraries.
96 LYX_WITH_DIR([extra-lib],[extra library directory],extra_lib, NONE)
97 LYX_LOOP_DIR($lyx_cv_extra_lib,LYX_ADD_LIB_DIR(lyx_ldflags,$dir))
98 test ! x"$lyx_ldflags" = x && LDFLAGS="$lyx_ldflags $LDFLAGS"
99
100 ### Add extra directories to check for include files.
101 LYX_WITH_DIR([extra-inc],[extra include directory],extra_inc, NONE)
102 LYX_LOOP_DIR($lyx_cv_extra_inc,LYX_ADD_INC_DIR(lyx_cppflags,$dir))
103 test ! x"$lyx_cppflags" = x && CPPFLAGS="$lyx_cppflags $CPPFLAGS"
104
105 ### Add both includes and libraries
106 LYX_WITH_DIR([extra-prefix],[extra lib+include directory],extra_prefix, NONE, ${prefix})
107 LYX_LOOP_DIR($lyx_cv_extra_prefix,[
108 LYX_ADD_INC_DIR(CPPFLAGS,$dir/include)
109   LYX_ADD_LIB_DIR(LDFLAGS,$dir/lib)])
110
111 ### These are needed in windows
112 AC_CHECK_LIB(shlwapi, main, [LIBSHLWAPI=-lshlwapi])
113 AC_SUBST(LIBSHLWAPI)
114 AC_CHECK_LIB(gdi32, main)
115
116 AC_ARG_WITH(mythes,
117   [  --without-mythes        do not use the MyThes library],
118   [lyx_use_mythes=$withval])
119 if test x$lyx_use_mythes != xno; then
120 AC_CHECK_LIB(mythes, main,
121         [AC_DEFINE(HAVE_LIBMYTHES,1,[Define this if you have the MyThes library])
122          MYTHES_LIBS="-lmythes"
123          lyx_flags="mythes $lyx_flags"
124         ])
125 AC_CHECK_HEADER(mythes.hxx,[
126   ac_cv_header_mythes_h=yes
127   lyx_cv_mythes_h_location="<mythes.hxx>"])
128 AC_CHECK_HEADER(mythes/mythes.hxx,[
129   ac_cv_header_mythes_h=yes
130   lyx_cv_mythes_h_location="<mythes/mythes.hxx>"])
131 AC_DEFINE_UNQUOTED(MYTHES_H_LOCATION,$lyx_cv_mythes_h_location,[Location of mythes.hxx])
132 fi
133 AC_SUBST(MYTHES_LIBS)
134
135 AC_ARG_WITH(aiksaurus,
136   [  --without-aiksaurus     do not use the Aiksaurus library],
137   [lyx_use_aiksaurus=$withval])
138 if test x$lyx_use_aiksaurus != xno; then
139 AC_CHECK_LIB(Aiksaurus, main,
140         [AC_DEFINE(HAVE_LIBAIKSAURUS,1,[Define this if you have the AikSaurus library])
141          AIKSAURUS_LIBS="-lAiksaurus"
142          lyx_flags="aiksaurus $lyx_flags"
143         ])
144 AC_CHECK_HEADER(Aiksaurus.h,[
145   ac_cv_header_aiksaurus_h=yes
146   lyx_cv_aiksaurus_h_location="<Aiksaurus.h>"])
147 AC_CHECK_HEADER(Aiksaurus/Aiksaurus.h,[
148   ac_cv_header_aiksaurus_h=yes
149   lyx_cv_aiksaurus_h_location="<Aiksaurus/Aiksaurus.h>"])
150 AC_DEFINE_UNQUOTED(AIKSAURUS_H_LOCATION,$lyx_cv_aiksaurus_h_location,[Location of Aiksaurus.h])
151 fi
152 AC_SUBST(AIKSAURUS_LIBS)
153
154 LYX_USE_INCLUDED_BOOST
155
156 # Needed for our char_type
157 AC_CHECK_SIZEOF(wchar_t)
158
159 ### We need iconv for unicode support (Qt4 frontend requires it too)
160 AM_ICONV
161 if test "$am_cv_func_iconv" = no; then
162   LYX_ERROR([Cannot find required library iconv])
163 else
164   LIBS="$LIBS $LIBICONV"
165 fi
166
167 ### check for compression support
168 AC_CHECK_HEADERS(zlib.h,
169  [AC_CHECK_LIB(z, gzopen, [LIBS="$LIBS -lz"], LYX_LIB_ERROR(libz,zlib))],
170  [LYX_LIB_ERROR(zlib.h,zlib)])
171
172
173 ### check which frontend we want to use
174
175 dnl The code below is not in a macro, because this would cause big
176 dnl problems with the AC_REQUIRE contained in QT_DO_IT_ALL.
177 for frontend in $FRONTENDS ; do
178   case "$frontend" in
179     qt4)
180           QT4_DO_IT_ALL
181           FRONTENDS_PROGS="$FRONTENDS_PROGS lyx-qt4\$(EXEEXT)"
182           FRONTENDS_SUBDIRS="$FRONTENDS_SUBDIRS qt4"
183           RPM_FRONTEND="qt4"
184           FRONTEND_INFO="${FRONTEND_INFO}\
185   Qt 4 Frontend:\n\
186       Qt 4 version:\t\t${QT4_VERSION}\n"
187 dnl qt 4 build will fail without moc or uic
188           if test -z "$MOC4"; then
189             LYX_ERROR([moc 4 binary not found !])
190           fi
191           if test -z "$UIC4"; then
192             LYX_ERROR([uic 4 binary not found !])
193           fi
194           if test -z "$QT4_LIB"; then
195             LYX_ERROR([qt 4 library not found !])
196           fi
197       ;;
198     *)
199           LYX_ERROR(Unknown frontend '$frontend');;
200   esac
201 done
202
203 # fix the value of the prefixes.
204 test "x$prefix" = xNONE && prefix=$default_prefix
205 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
206 if echo $prefix |grep ' ' >/dev/null 2>/dev/null ; then
207   LYX_WARNING([The installation prefix \"${prefix}\" contains a space, which
208    causes problems with the Makefiles. The installation will be done in
209    directory \"`pwd`/installprefix\" instead. Please move its contents to
210    the right place after installation.])
211   prefix=`pwd`/installprefix
212 fi
213
214 ### Setup GNU gettext
215 dnl GNU gettext is written in C
216 AC_LANG_PUSH(C)
217 dnl Dirty trick ahead: disable macro AC_GNU_SOURCE because it triggers a bug with autoconf 2.62.
218 dnl this can be removed if gettext is been updated to avoid that.
219 m4_undefine([AC_GNU_SOURCE])
220 m4_defun([AC_GNU_SOURCE],[])
221 AM_GNU_GETTEXT
222 AM_GNU_GETTEXT_VERSION([0.16.1])
223 AC_LANG_POP(C)
224
225 # some standard header files
226 AC_HEADER_DIRENT
227 AC_HEADER_MAJOR
228 AC_CHECK_HEADERS(sys/time.h sys/types.h sys/select.h strings.h locale.h io.h process.h NewAPIs.h utime.h sys/utime.h)
229
230 # some standard structures
231 AC_HEADER_STAT
232 AC_HEADER_TIME
233
234 # some standard types
235 AC_CHECK_TYPE(mode_t,[AC_DEFINE(HAVE_MODE_T, 1, [Define this to 1 if your compiler supports the mode_t type.])])
236 AC_TYPE_OFF_T
237 AC_TYPE_PID_T
238 AC_TYPE_SIGNAL
239 AC_TYPE_SIZE_T
240 AC_TYPE_UID_T
241
242 AC_CHECK_FUNCS(strerror)
243 LYX_CHECK_DECL(istreambuf_iterator, iterator)
244 LYX_CHECK_DECL(mkstemp,[unistd.h stdlib.h])
245
246 # Check the form of mkdir()
247 AC_FUNC_MKDIR
248
249 dnl This is a slight hack: the tests generated by autoconf 2.52 do not
250 dnl work correctly because of some conflict with stdlib.h with g++ 2.96
251 dnl We aim to remove this eventually, since we should test as much as
252 dnl possible with the compiler which will use the functions (JMarc)
253 AC_LANG_PUSH(C)
254 AC_CHECK_FUNCS(chmod close _close getpid _getpid lstat mkfifo mkstemp mktemp open _open pclose _pclose popen _popen readlink)
255 AC_LANG_POP(C)
256
257 LYX_CHECK_SPELL_ENGINES
258
259 lyx_client_subdir=true
260 AC_LANG_PUSH(C)
261 dnl LIBS already contains some X extra libs that may interfere.
262 save_LIBS="$LIBS"
263 LIBS=
264 AC_CHECK_FUNCS(fcntl,
265   [AC_SEARCH_LIBS([gethostbyname], [nsl])
266    AC_SEARCH_LIBS([socket], [socket], [],
267      [AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"],
268                 [], [-lnsl])])],
269   [lyx_client_subdir=false])
270 AC_SUBST(SOCKET_LIBS,$LIBS)
271 LIBS="$save_LIBS"
272 AM_CONDITIONAL(BUILD_CLIENT_SUBDIR, $lyx_client_subdir)
273 AC_LANG_POP(C)
274
275 lyx_win_res=false;
276 case ${host} in
277     *mingw*|*cygwin*) lyx_win_res=true;;
278 esac
279 AM_CONDITIONAL(LYX_WIN_RESOURCE, $lyx_win_res)
280 LYX_SET_VERSION_INFO
281
282 AC_FUNC_SELECT_ARGTYPES
283
284 ### Some information on what just happened
285 real_bindir=`eval "echo \`eval \"echo ${bindir}\"\`"`
286 real_pkgdatadir=`eval "echo \`eval \"echo \\\`eval \\\"echo ${pkgdatadir}\\\"\\\`\"\`"`
287 real_localedir=`eval "echo \`eval \"echo ${datadir}/locale\"\`"`
288 VERSION_INFO="Configuration\n\
289   Host type:                    ${host}\n\
290   Special build flags:          ${lyx_flags}\n\
291   C   Compiler:                 ${CC} ${CC_VERSION}\n\
292   C   Compiler LyX flags:       ${AM_CPPFLAGS} ${AM_CFLAGS}\n\
293   C   Compiler flags:           ${CPPFLAGS} ${CFLAGS}\n\
294   C++ Compiler:                 ${CXX} ${CXX_VERSION}\n\
295   C++ Compiler LyX flags:       ${AM_CPPFLAGS} ${AM_CXXFLAGS}\n\
296   C++ Compiler flags:           ${CPPFLAGS} ${CXXFLAGS}\n\
297   Linker flags:                 ${AM_LDFLAGS}\n\
298   Linker user flags:            ${LDFLAGS}\n\
299 ${FRONTEND_INFO}\
300   Packaging:                    ${lyx_use_packaging}\n\
301   LyX binary dir:               ${real_bindir}\n\
302   LyX files dir:                ${real_pkgdatadir}\n"
303
304 AC_SUBST(VERSION_INFO)
305 AC_SUBST(RPM_FRONTEND)
306 AC_SUBST(AM_CPPFLAGS)
307 AC_SUBST(AM_CXXFLAGS)
308 AC_SUBST(AM_CFLAGS)
309 AC_SUBST(AM_LDFLAGS)
310 AC_SUBST(real_pkgdatadir)
311
312 ## Some config.h stuff
313
314 AH_TOP([
315 /* -*- C++ -*- */
316 /*
317  * \file config.h
318  * This file is part of LyX, the document processor.
319  * Licence details can be found in the file COPYING.
320  *
321  * This is the compilation configuration file for LyX.
322  * It was generated by autoconfs configure.
323  * You might want to change some of the defaults if something goes wrong
324  * during the compilation.
325  */
326
327 #ifndef _CONFIG_H
328 #define _CONFIG_H
329 ])
330
331 AH_BOTTOM([
332 /************************************************************
333  ** You should not need to change anything beyond this point */
334
335 #ifndef HAVE_STRERROR
336 #if defined(__cplusplus)
337 extern "C"
338 #endif
339 char * strerror(int n);
340 #endif
341
342 #if defined(HAVE_OSTREAM) && defined(HAVE_LOCALE) && defined(HAVE_SSTREAM)
343 #  define USE_BOOST_FORMAT 1
344 #else
345 #  define USE_BOOST_FORMAT 0
346 #endif
347
348 #define BOOST_USER_CONFIG <config.h>
349
350 #if !defined(ENABLE_ASSERTIONS)
351 #  define BOOST_DISABLE_ASSERTS 1
352 #endif
353 #define BOOST_ENABLE_ASSERT_HANDLER 1
354
355 #define BOOST_DISABLE_THREADS 1
356 #define BOOST_NO_WREGEX 1
357 #define BOOST_NO_WSTRING 1
358
359 #ifdef __CYGWIN__
360 #  define BOOST_POSIX 1
361 #  define BOOST_POSIX_API 1
362 #  define BOOST_POSIX_PATH 1
363 #endif
364
365 #if defined(HAVE_NEWAPIS_H)
366 #  define WANT_GETFILEATTRIBUTESEX_WRAPPER 1
367 #endif
368
369 /*
370  * the FreeBSD libc uses UCS4, but libstdc++ has no proper wchar_t
371  * support compiled in:
372  * http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#3_9
373  * And we are not interested at all what libc
374  * does: What we need is a 32bit wide wchar_t, and a libstdc++ that
375  * has the needed wchar_t support and uses UCS4. Whether it
376  * implements this with the help of libc, or whether it has own code
377  * does not matter for us, because we do not use libc directly (Georg)
378 */
379 #if defined(HAVE_WCHAR_T) && SIZEOF_WCHAR_T == 4 && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
380 #  define USE_WCHAR_T
381 #endif
382
383 #endif
384 ])
385
386
387 AC_ARG_ENABLE(monolithic-boost,
388   AC_HELP_STRING([--enable-monolithic-boost],
389                 [Use monolithic boost compilations]),,
390   [enable_monolithic_boost=no])
391 AM_CONDITIONAL(MONOLITHIC_BOOST, test "$enable_monolithic_boost" = "yes")
392
393 AC_ARG_ENABLE(monolithic-client,
394   AC_HELP_STRING([--enable-monolithic-client],
395                 [Use monolithic client compilations]),,
396   [enable_monolithic_client=no])
397 AM_CONDITIONAL(MONOLITHIC_CLIENT, test "$enable_monolithic_client" = "yes")
398
399 AC_ARG_ENABLE(monolithic-insets,
400   AC_HELP_STRING([--enable-monolithic-insets],
401                 [Use monolithic insets compilations]),,
402   [enable_monolithic_insets=no])
403 AM_CONDITIONAL(MONOLITHIC_INSETS, test "$enable_monolithic_insets" = "yes")
404
405 AC_ARG_ENABLE(monolithic-mathed,
406   AC_HELP_STRING([--enable-monolithic-mathed],
407                 [Use monolithic mathed compilations]),,
408   [enable_monolithic_mathed=no])
409 AM_CONDITIONAL(MONOLITHIC_MATHED, test "$enable_monolithic_mathed" = "yes")
410
411 AC_ARG_ENABLE(monolithic-core,
412   AC_HELP_STRING([--enable-monolithic-core],
413                 [Use monolithic core files compilations]),,
414   [enable_monolithic_core=no])
415 AM_CONDITIONAL(MONOLITHIC_CORE, test "$enable_monolithic_core" = "yes")
416
417 AC_ARG_ENABLE(monolithic-tex2lyx,
418   AC_HELP_STRING([--enable-monolithic-tex2lyx],
419                 [Use monolithic tex2lyx compilations]),,
420   [enable_monolithic_tex2lyx=no])
421 AM_CONDITIONAL(MONOLITHIC_TEX2LYX, test "$enable_monolithic_tex2lyx" = "yes")
422
423 AC_ARG_ENABLE(monolithic-frontend-qt4,
424   AC_HELP_STRING([--enable-monolithic-frontend-qt4],
425                 [Use monolithic compilation of the Qt 4 frontend. Only recommended with > 512 MB of RAM]),,
426   [enable_monolithic_frontend_qt4=no])
427 AM_CONDITIONAL(MONOLITHIC_FRONTEND_QT4, test "$enable_monolithic_frontend_qt4" = "yes")
428
429 MSYS_AC_CANONICAL_PATH(lyx_abs_top_srcdir, ${srcdir})
430 MSYS_AC_CANONICAL_PATH(lyx_abs_installed_localedir, ${real_localedir})
431 MSYS_AC_CANONICAL_PATH(lyx_abs_installed_datadir, ${real_pkgdatadir})
432
433 AC_DEFINE_UNQUOTED([LYX_ABS_TOP_SRCDIR],
434         "${lyx_abs_top_srcdir}", [Top source directory])
435 AC_DEFINE_UNQUOTED([LYX_ABS_INSTALLED_LOCALEDIR],
436         "${lyx_abs_installed_localedir}",[Hard coded locale directory])
437 AC_DEFINE_UNQUOTED([LYX_ABS_INSTALLED_DATADIR],
438         "${lyx_abs_installed_datadir}",[Hard system support directory])
439 AC_DEFINE_UNQUOTED([PROGRAM_SUFFIX],
440         "${version_suffix}",[Program version suffix])
441
442 AC_DEFINE_UNQUOTED([LYX_DATE],"$LYX_DATE",[Date of release])
443 AC_DEFINE_UNQUOTED([VERSION_INFO],"$VERSION_INFO",[Full version info])
444 AC_DEFINE_UNQUOTED([LYX_DIR_VER],"$lyx_dir_ver",[Versioned env var for system dir])
445 AC_DEFINE_UNQUOTED([LYX_USERDIR_VER],"$lyx_userdir_ver",[Versioned env var for user dir])
446 AC_DEFINE_UNQUOTED([LYX_MAJOR_VERSION],$lyx_major,[Major version number])
447 AC_DEFINE_UNQUOTED([LYX_MINOR_VERSION],$lyx_minor,[Minor version number])
448 AC_DEFINE_UNQUOTED([LYX_RELEASE_LEVEL],$lyx_release,[Release version number])
449 AC_DEFINE_UNQUOTED([LYX_RELEASE_PATCH],$lyx_patch,[Patch version number])
450
451 AC_CONFIG_FILES([Makefile \
452       lyx.1:lyx.1in \
453       boost/Makefile \
454       config/Makefile \
455       development/Makefile \
456       development/MacOSX/Makefile \
457       development/MacOSX/Info.plist \
458       development/MacOSX/lyxrc.dist \
459       development/MacOSX/spotlight/Makefile \
460       development/lyx.spec \
461       intl/Makefile \
462       lib/Makefile \
463       lib/doc/Makefile \
464       lib/lyx2lyx/lyx2lyx_version.py \
465       lib/lyx2lyx/Makefile \
466       m4/Makefile \
467       po/Makefile.in \
468       sourcedoc/Doxyfile \
469       sourcedoc/Makefile \
470       src/client/Makefile \
471       src/Makefile \
472       src/tex2lyx/Makefile \
473       src/support/Makefile \
474       src/frontends/Makefile \
475       src/frontends/qt4/Makefile
476 ])
477
478
479 AC_OUTPUT
480
481 # show version information
482 echo
483 printf "$VERSION_INFO"
484 echo
485
486 # Display a final warning if there has been a LYX_ERROR
487 LYX_CHECK_ERRORS