]> git.lyx.org Git - lyx.git/blob - configure.ac
bc80ec095eefd0fec3f6e0b4c2ffe0e2b3911fdd
[lyx.git] / configure.ac
1 dnl Process with autoconf to generate configure script   -*- sh -*-
2
3 AC_INIT(LyX,1.5.0svn,[lyx-devel@lists.lyx.org],[lyx])
4 AC_PREREQ(2.52)
5 AC_CONFIG_SRCDIR(src/main.C)
6 AC_CONFIG_HEADERS([src/config.h])
7
8 AC_CONFIG_AUX_DIR(config)
9
10 # First check the version
11 LYX_CHECK_VERSION
12 LYX_VERSION_SUFFIX
13 # Check how the files should be packaged
14 AC_CANONICAL_TARGET
15 LYX_USE_PACKAGING
16 # We need to define these variables here and the no-define option of
17 # AM_INIT_AUTOMAKE above because we alter $PACKAGE in LYX_USE_PACKAGING. 
18 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
19
20 dnl default maintainer mode to true for development versions
21 if test "${enable_maintainer_mode+set}" != set; then
22   enable_maintainer_mode=$lyx_devel_version
23 fi
24 AM_MAINTAINER_MODE
25
26 save_PACKAGE=$PACKAGE
27 AM_INIT_AUTOMAKE([foreign dist-bzip2 tar-ustar no-define 1.9])
28 PACKAGE=$save_PACKAGE
29
30 ### Set the execute permissions of the various scripts correctly
31 for file in config/install-sh config/mkinstalldirs lib/configure ; do
32   chmod 755 ${srcdir}/${file}
33 done
34
35 ### Check for programs
36 AC_PROG_MAKE_SET
37 AC_PROG_INSTALL
38
39 AC_PROG_AWK
40 test "$AWK" = gawk && AWK="gawk --posix"
41
42 #AC_PROG_RANLIB
43 AC_CHECK_PROG(KPSEWHICH, kpsewhich, kpsewhich, :)
44 if test "x$KPSEWHICH" = xkpsewhich ; then
45     AC_DEFINE(HAVE_KPSEWHICH, 1,
46     [Define this if you have the kpsewhich program working on your system.])
47 fi
48 AC_CHECK_PROGS(M4, gm4 gnum4 m4, m4)
49
50 # Check for installed python
51 AM_PATH_PYTHON(1.5.2,, :)
52
53 # Work around a problem in automake 1.4: when invoking install-strip,
54 # INSTALL_PROGRAM is changed to 'install -s', and since
55 # INSTALL_SCRIPT==INSTALL_PROGRAM, we get errors with fileutils-4.0
56 # which returns an error condition when stripping fails.
57 INSTALL_SCRIPT='${INSTALL}'
58
59 ### we will also need a C compiler to compile GNU gettext
60 AC_PROG_CC
61
62 ### check for special systems
63 AC_ISC_POSIX
64 AC_AIX
65
66 ### check which frontend we want to use
67 LYX_USE_FRONTENDS
68
69 ### Check for a C++ compiler
70 LYX_PROG_CXX
71 ### Some checks on what the C++ compiler can(not) do
72 AC_LANG(C++)
73 dnl we do not need that currently (and probably all our supported
74 dnl compiler allow that)
75 dnl LYX_CXX_PARTIAL
76 LYX_CXX_EXPLICIT
77 LYX_CXX_GLOBAL_CSTD
78 LYX_STD_COUNT
79 dnl we disable rtti for now
80 dnl LYX_CXX_RTTI
81 AC_CHECK_HEADERS(ostream istream sstream locale limits ios)
82 LYX_CXX_STL_MODERN_STREAMS
83
84 ### and now some special lyx flags.
85 AC_ARG_ENABLE(assertions,
86   AC_HELP_STRING([--enable-assertions],[add runtime sanity checks in the program]),,
87   [if test $lyx_devel_version = yes -o $lyx_prerelease = yes ; then
88         enable_assertions=yes;
89     else
90         enable_assertions=no;
91     fi;])
92 if test "x$enable_assertions" = xyes ; then
93    lyx_flags="assertions $lyx_flags"
94    AC_DEFINE(ENABLE_ASSERTIONS,1,
95     [Define if you want assertions to be enabled in the code])
96 fi
97
98 ### Library Files
99 dnl by testing these we check if it is ok to have
100 dnl -lc and -lm as args to the compiler
101 AC_CHECK_LIB(m, sin)
102 AC_CHECK_LIB(c, fopen)
103
104 ### Add extra directories to check for libraries.
105 LYX_WITH_DIR([extra-lib],[extra library directory],extra_lib, NONE)
106 LYX_LOOP_DIR($lyx_cv_extra_lib,LYX_ADD_LIB_DIR(lyx_ldflags,$dir))
107 test ! x"$lyx_ldflags" = x && LDFLAGS="$lyx_ldflags $LDFLAGS"
108
109 ### Add extra directories to check for include files.
110 LYX_WITH_DIR([extra-inc],[extra include directory],extra_inc, NONE)
111 LYX_LOOP_DIR($lyx_cv_extra_inc,LYX_ADD_INC_DIR(lyx_cppflags,$dir))
112 test ! x"$lyx_cppflags" = x && CPPFLAGS="$lyx_cppflags $CPPFLAGS"
113
114 ### Add both includes and libraries
115 LYX_WITH_DIR([extra-prefix],[extra lib+include directory],extra_prefix, NONE, ${prefix})
116 LYX_LOOP_DIR($lyx_cv_extra_prefix,[
117 LYX_ADD_INC_DIR(CPPFLAGS,$dir/include)
118   LYX_ADD_LIB_DIR(LDFLAGS,$dir/lib)])
119
120 AC_ARG_WITH(aiksaurus,
121   [  --without-aiksaurus     do not use the Aiksaurus library],
122   [lyx_use_aiksaurus=$withval])
123 if test x$lyx_use_aiksaurus != xno; then
124 AC_CHECK_LIB(Aiksaurus, main,
125         [AC_DEFINE(HAVE_LIBAIKSAURUS,1,[Define this if you have the AikSaurus library])
126          AIKSAURUS_LIBS="-lAiksaurus"
127          lyx_flags="aiksaurus $lyx_flags"
128         ])
129 AC_CHECK_HEADER(Aiksaurus.h,[
130   ac_cv_header_aiksaurus_h=yes
131   lyx_cv_aiksaurus_h_location="<Aiksaurus.h>"])
132 AC_CHECK_HEADER(Aiksaurus/Aiksaurus.h,[
133   ac_cv_header_aiksaurus_h=yes
134   lyx_cv_aiksaurus_h_location="<Aiksaurus/Aiksaurus.h>"])
135 AC_DEFINE_UNQUOTED(AIKSAURUS_H_LOCATION,$lyx_cv_aiksaurus_h_location,[Location of Aiksaurus.h])
136 fi
137 AC_SUBST(AIKSAURUS_LIBS)
138
139 LYX_USE_INCLUDED_BOOST
140
141 ### Setup libtool
142 AC_DISABLE_SHARED
143 AC_LIBTOOL_WIN32_DLL
144 #AM_PROG_LIBTOOL
145 LYX_PROG_LIBTOOL
146
147 ### Check for some Cygwin-specific details.
148 CHECK_WITH_CYGWIN
149
150 ### Check for X libraries
151 AC_PATH_XTRA
152 case $have_x in
153   yes) LIBS="$X_PRE_LIBS $LIBS $X_LIBS -lX11 $X_EXTRA_LIBS"
154        CPPFLAGS="$CPPFLAGS $X_CFLAGS";;
155   no) LYX_ERROR(dnl
156 [Cannot find X window libraries and/or headers. Check your installation.
157   If you use a Linux system, check that you have installed
158   the development tools.]);;
159   disable) ;;
160 esac
161
162 ### check which frontend we want to use
163
164 dnl The code below is not in a macro, because this would cause big
165 dnl problems with the AC_REQUIRE contained in QT_DO_IT_ALL.
166 for frontend in $FRONTENDS ; do
167   case "$frontend" in
168     xforms)
169           XFORMS_DO_IT_ALL
170           FRONTENDS_PROGS="$FRONTENDS_PROGS lyx-xforms\$(EXEEXT)"
171           FRONTENDS_SUBDIRS="$FRONTENDS_SUBDIRS xforms"
172           RPM_FRONTEND="xforms"
173           FRONTEND_INFO="${FRONTEND_INFO}\
174   XForms Frontend:\n\
175       libXpm version:\t\t${XPM_VERSION}\n\
176       libforms version:\t\t${XFORMS_VERSION}\n"
177           ;;
178     gtk)
179           PKG_CHECK_MODULES(GTK_FRONTEND, gtkmm-2.4 libglademm-2.4 xft)
180           FRONTENDS_PROGS="$FRONTENDS_PROGS lyx-gtk\$(EXEEXT)"
181           FRONTENDS_SUBDIRS="$FRONTENDS_SUBDIRS gtk"
182           RPM_FRONTEND="gtk"
183           GTKMM_VERSION=`pkg-config --modversion gtkmm-2.4`
184           LIBGLADEMM_VERSION=`pkg-config --modversion libglademm-2.4`
185           FRONTEND_INFO="${FRONTEND_INFO}\
186   GTK Frontend:\n\
187     libgtkmm version:\t\t${GTKMM_VERSION}\n\
188     libglademm version:\t\t${LIBGLADEMM_VERSION}\n"
189           ;;
190
191     qt)
192           QT_DO_IT_ALL
193           FRONTENDS_PROGS="$FRONTENDS_PROGS lyx-qt\$(EXEEXT)"
194           FRONTENDS_SUBDIRS="$FRONTENDS_SUBDIRS qt2"
195           RPM_FRONTEND="qt"
196           FRONTEND_INFO="${FRONTEND_INFO}\
197   Qt Frontend:\n\
198       Qt version:\t\t${QT_VERSION}\n"
199 dnl qt build will fail without moc or uic
200           if test -z "$MOC"; then
201             LYX_ERROR([moc binary not found !])
202           fi
203           if test -z "$UIC"; then
204             LYX_ERROR([uic binary not found !])
205           fi
206           if test -z "$QT_LIB"; then
207             LYX_ERROR([qt library not found !])
208           fi
209       ;;
210     qt4)
211           QT4_DO_IT_ALL
212           FRONTENDS_PROGS="$FRONTENDS_PROGS lyx-qt4\$(EXEEXT)"
213           FRONTENDS_SUBDIRS="$FRONTENDS_SUBDIRS qt4"
214           RPM_FRONTEND="qt4"
215           FRONTEND_INFO="${FRONTEND_INFO}\
216   Qt 4 Frontend:\n\
217       Qt 4 version:\t\t${QT4_VERSION}\n"
218 dnl qt 4 build will fail without moc or uic
219           if test -z "$MOC4"; then
220             LYX_ERROR([moc 4 binary not found !])
221           fi
222           if test -z "$UIC4"; then
223             LYX_ERROR([uic 4 binary not found !])
224           fi
225           if test -z "$QT4_LIB"; then
226             LYX_ERROR([qt 4 library not found !])
227           fi
228       ;;
229     *)
230           LYX_ERROR(Unknown frontend '$frontend');;
231   esac
232 done
233
234 # fix the value of the prefixes.
235 test "x$prefix" = xNONE && prefix=$default_prefix
236 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
237 if echo $prefix |grep ' ' >/dev/null 2>/dev/null ; then
238   LYX_WARNING([The installation prefix \"${prefix}\" contains a space, which
239    causes problems with the Makefiles. The installation will be done in
240    directory \"`pwd`/installprefix\" instead. Please move its contents to
241    the right place after installation.])
242   prefix=`pwd`/installprefix
243 fi
244
245 ### Setup GNU gettext
246 dnl GNU gettext is written in C
247 AC_LANG_PUSH(C)
248 AM_GNU_GETTEXT
249 AC_LANG_POP(C)
250
251 # some standard header files
252 AC_HEADER_DIRENT
253 AC_HEADER_MAJOR
254 AC_CHECK_HEADERS(sys/time.h sys/types.h sys/select.h strings.h locale.h utime.h sys/utime.h io.h process.h NewAPIs.h)
255
256 # some standard structures
257 AC_HEADER_STAT
258 AC_HEADER_TIME
259
260 # some standard types
261 AC_TYPE_MODE_T
262 AC_TYPE_OFF_T
263 AC_TYPE_PID_T
264 AC_TYPE_SIGNAL
265 AC_TYPE_SIZE_T
266 AC_TYPE_UID_T
267
268 AC_CHECK_FUNCS(strerror)
269 LYX_CHECK_DECL(istreambuf_iterator, iterator)
270 LYX_CHECK_DECL(mkstemp,[unistd.h stdlib.h])
271
272 # Check the form of mkdir()
273 AC_FUNC_MKDIR
274
275 AC_ARG_ENABLE(compression-support, AC_HELP_STRING([--enable-compression-support],[Support for compressed files.]),[
276     case "${enableval}" in
277         yes) use_compression=true ;;
278         no) use_compression=false ;;
279         *) AC_MSG_ERROR(bad value ${enableval} for --enable-compression-support) ;;
280     esac
281 ],[use_compression=true])
282 if test $use_compression=true ; then
283         AC_CHECK_HEADERS(zlib.h, use_compression=true, use_compression=false)
284         AC_CHECK_LIB(z, gzopen,[use_compression=true;LIBS="$LIBS -lz"], use_compression=false)
285         if test $use_compression = true ; then
286                 AC_DEFINE(USE_COMPRESSION, 1, [Define as 1 if you want to support compressed files.])
287                 lyx_flags="compression $lyx_flags"
288         fi
289 fi
290 AM_CONDITIONAL(USE_COMPRESSION, test x$use_compression = xtrue)
291 AC_MSG_CHECKING([whether to support compressed files])
292 AC_MSG_RESULT($use_compression)
293
294
295 dnl This is a slight hack: the tests generated by autoconf 2.52 do not
296 dnl work correctly because of some conflict with stdlib.h with g++ 2.96
297 dnl We aim to remove this eventually, since we should test as much as
298 dnl possible with the compiler which will use the functions (JMarc)
299 AC_LANG_PUSH(C)
300 AC_CHECK_FUNCS(close _close getpid _getpid lstat mkfifo mkstemp mktemp open _open pclose _pclose popen _popen readlink)
301 AC_LANG_POP(C)
302
303 LYX_CHECK_SPELL_ENGINES
304
305 lyx_client_subdir=true
306 AC_LANG_PUSH(C)
307 dnl LIBS already contains some X extra libs that may interfere.
308 save_LIBS="$LIBS"
309 LIBS=
310 AC_CHECK_FUNCS(fcntl,
311   [AC_SEARCH_LIBS([gethostbyname], [nsl])
312    AC_SEARCH_LIBS([socket], [socket], [], 
313      [AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"],
314                 [], [-lnsl])])], 
315   [lyx_client_subdir=false])
316 AC_SUBST(SOCKET_LIBS,$LIBS)
317 LIBS="$save_LIBS"
318 AM_CONDITIONAL(BUILD_CLIENT_SUBDIR, $lyx_client_subdir)
319 AC_LANG_POP(C)
320
321 AC_FUNC_SELECT_ARGTYPES
322
323 ### Some information on what just happened
324 real_bindir=`eval "echo \`eval \"echo ${bindir}\"\`"`
325 real_pkgdatadir=`eval "echo \`eval \"echo ${pkgdatadir}\"\`"`
326 real_localedir=`eval "echo \`eval \"echo ${datadir}/locale\"\`"`
327 VERSION_INFO="Configuration\n\
328   Host type:                      ${host}\n\
329   Special build flags:            ${lyx_flags}\n\
330   C   Compiler:                   ${CC} ${CC_VERSION}\n\
331   C   Compiler LyX flags:         ${AM_CPPFLAGS} ${AM_CFLAGS}\n\
332   C   Compiler flags:             ${CPPFLAGS} ${CFLAGS}\n\
333   C++ Compiler:                   ${CXX} ${CXX_VERSION}\n\
334   C++ Compiler LyX flags:         ${AM_CPPFLAGS} ${AM_CXXFLAGS}\n\
335   C++ Compiler flags:             ${CPPFLAGS} ${CXXFLAGS}\n\
336   Linker flags:                   ${AM_LDFLAGS}\n\
337   Linker user flags:              ${LDFLAGS}\n\
338 ${FRONTEND_INFO}\
339   Packaging:                      ${lyx_use_packaging}\n\
340   LyX binary dir:                 ${real_bindir}\n\
341   LyX files dir:                  ${real_pkgdatadir}\n"
342
343 MSYS_AC_CANONICAL_PATH(LYX_ABS_TOP_SRCDIR, ${srcdir})
344 MSYS_AC_CANONICAL_PATH(LYX_ABS_INSTALLED_LOCALEDIR, ${real_localedir})
345 MSYS_AC_CANONICAL_PATH(LYX_ABS_INSTALLED_DATADIR, ${real_pkgdatadir})
346
347 AC_SUBST(VERSION_INFO)
348 AC_SUBST(RPM_FRONTEND)
349 AC_SUBST(AM_CPPFLAGS)
350 AC_SUBST(AM_CXXFLAGS)
351 AC_SUBST(AM_CFLAGS)
352 AC_SUBST(AM_LDFLAGS)
353 AC_SUBST(LYX_ABS_TOP_SRCDIR)
354 AC_SUBST(LYX_ABS_INSTALLED_LOCALEDIR)
355 AC_SUBST(LYX_ABS_INSTALLED_DATADIR)
356
357 ## Some config.h stuff
358
359 AH_TOP([
360 /* -*- C++ -*- */
361 /*
362  * \file config.h
363  * This file is part of LyX, the document processor.
364  * Licence details can be found in the file COPYING.
365  *
366  * This is the compilation configuration file for LyX.
367  * It was generated by autoconfs configure.
368  * You might want to change some of the defaults if something goes wrong
369  * during the compilation.
370  */
371
372 #ifndef _CONFIG_H
373 #define _CONFIG_H
374 ])
375
376 AH_BOTTOM([
377 /************************************************************
378  ** You should not need to change anything beyond this point */
379
380 #ifndef HAVE_STRERROR
381 #if defined(__cplusplus)
382 extern "C"
383 #endif
384 char * strerror(int n);
385 #endif
386
387 #ifdef HAVE_MKSTEMP
388 #ifndef HAVE_DECL_MKSTEMP
389 #if defined(__cplusplus)
390 extern "C"
391 #endif
392 int mkstemp(char*);
393 #endif
394 #endif
395
396 #ifdef __EMX__
397 #include "support/os2_defines.h"
398 #endif
399
400 #if defined(HAVE_OSTREAM) && defined(HAVE_LOCALE) && defined(HAVE_SSTREAM)
401 #define USE_BOOST_FORMAT 1
402 #else
403 #define USE_BOOST_FORMAT 0
404 #endif
405
406 #define BOOST_USER_CONFIG <config.h>
407
408 #if defined(ENABLE_ASSERTIONS)
409 #define BOOST_ENABLE_ASSERT_HANDLER 1
410 #else
411 #define BOOST_DISABLE_ASSERTS 1
412 #endif
413
414 #define BOOST_DISABLE_THREADS 1
415 #define BOOST_NO_WREGEX 1
416 #define BOOST_NO_WSTRING 1
417
418 #ifdef __CYGWIN__
419 #define BOOST_POSIX 1
420 #endif
421
422 #if defined(HAVE_NEWAPIS_H)
423 #define WANT_GETFILEATTRIBUTESEX_WRAPPER 1
424 #endif
425
426 #endif
427 ])
428
429 ### Finish the work.
430 AC_CONFIG_SUBDIRS(lib)
431 AC_CONFIG_FILES([Makefile  m4/Makefile \
432        boost/Makefile \
433        boost/libs/Makefile \
434        boost/libs/filesystem/Makefile \
435        boost/libs/filesystem/src/Makefile \
436        boost/libs/regex/Makefile \
437        boost/libs/regex/src/Makefile \
438        boost/libs/signals/Makefile \
439        boost/libs/signals/src/Makefile \
440        config/Makefile \
441        development/Makefile \
442        development/lyx.spec \
443        lib/Makefile \
444        lib/doc/Makefile \
445        lib/lyx2lyx/Makefile \
446        intl/Makefile \
447        po/Makefile.in \
448        sourcedoc/Doxyfile \
449        sourcedoc/Makefile \
450        src/client/Makefile \
451        src/Makefile \
452        src/version.C-tmp:src/version.C.in \
453        src/tex2lyx/Makefile \
454        src/mathed/Makefile \
455        src/graphics/Makefile \
456        src/insets/Makefile \
457        src/support/Makefile \
458        src/support/tests/Makefile \
459        src/frontends/Makefile \
460        src/frontends/controllers/Makefile \
461        src/frontends/controllers/tests/Makefile \
462        src/frontends/xforms/Makefile \
463        src/frontends/xforms/lyx_forms.h-tmp:src/frontends/xforms/lyx_forms.h.in \
464        src/frontends/xforms/lyx_xpm.h-tmp:src/frontends/xforms/lyx_xpm.h.in \
465        src/frontends/xforms/forms/Makefile \
466        src/frontends/gtk/Makefile \
467        src/frontends/gtk/gimages/Makefile \
468        src/frontends/gtk/glade/Makefile \
469        src/frontends/qt2/Makefile \
470        src/frontends/qt2/moc/Makefile \
471        src/frontends/qt2/ui/Makefile \
472        src/frontends/qt2/ui/moc/Makefile \
473        src/frontends/qt4/Makefile \
474        src/frontends/qt4/moc/Makefile \
475        src/frontends/qt4/ui/Makefile \
476 ])
477
478 AC_OUTPUT
479 # show version information
480 echo
481 printf "$VERSION_INFO"
482 echo
483
484 # Display a final warning if there has been a LYX_ERROR
485 LYX_CHECK_ERRORS