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