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