]> git.lyx.org Git - lyx.git/blob - configure.ac
5d1bbb19f75f82514fcb9996a2345ad83ee6e4e0
[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_SUBST(LYX_DATE, ["Fri, Jul 13, 2006"])
5 AC_PREREQ(2.52)
6 AC_CONFIG_SRCDIR(src/main.C)
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 tar-ustar no-define 1.9])
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 LYX_CXX_EXPLICIT
81 LYX_CXX_GLOBAL_CSTD
82 LYX_STD_COUNT
83 dnl we disable rtti for now
84 dnl LYX_CXX_RTTI
85 AC_CHECK_HEADERS(ostream istream sstream locale limits ios)
86 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 by testing these we check if it is ok to have
104 dnl -lc and -lm as args to the compiler
105 AC_CHECK_LIB(m, sin)
106 AC_CHECK_LIB(c, fopen)
107
108 ### Add extra directories to check for libraries.
109 LYX_WITH_DIR([extra-lib],[extra library directory],extra_lib, NONE)
110 LYX_LOOP_DIR($lyx_cv_extra_lib,LYX_ADD_LIB_DIR(lyx_ldflags,$dir))
111 test ! x"$lyx_ldflags" = x && LDFLAGS="$lyx_ldflags $LDFLAGS"
112
113 ### Add extra directories to check for include files.
114 LYX_WITH_DIR([extra-inc],[extra include directory],extra_inc, NONE)
115 LYX_LOOP_DIR($lyx_cv_extra_inc,LYX_ADD_INC_DIR(lyx_cppflags,$dir))
116 test ! x"$lyx_cppflags" = x && CPPFLAGS="$lyx_cppflags $CPPFLAGS"
117
118 ### Add both includes and libraries
119 LYX_WITH_DIR([extra-prefix],[extra lib+include directory],extra_prefix, NONE, ${prefix})
120 LYX_LOOP_DIR($lyx_cv_extra_prefix,[
121 LYX_ADD_INC_DIR(CPPFLAGS,$dir/include)
122   LYX_ADD_LIB_DIR(LDFLAGS,$dir/lib)])
123
124 ### These are needed in windows
125 AC_CHECK_LIB(shlwapi, main, [LIBSHLWAPI=-lshlwapi])
126 AC_SUBST(LIBSHLWAPI)
127 AC_CHECK_LIB(gdi32, main)
128
129 AC_ARG_WITH(aiksaurus,
130   [  --without-aiksaurus     do not use the Aiksaurus library],
131   [lyx_use_aiksaurus=$withval])
132 if test x$lyx_use_aiksaurus != xno; then
133 AC_CHECK_LIB(Aiksaurus, main,
134         [AC_DEFINE(HAVE_LIBAIKSAURUS,1,[Define this if you have the AikSaurus library])
135          AIKSAURUS_LIBS="-lAiksaurus"
136          lyx_flags="aiksaurus $lyx_flags"
137         ])
138 AC_CHECK_HEADER(Aiksaurus.h,[
139   ac_cv_header_aiksaurus_h=yes
140   lyx_cv_aiksaurus_h_location="<Aiksaurus.h>"])
141 AC_CHECK_HEADER(Aiksaurus/Aiksaurus.h,[
142   ac_cv_header_aiksaurus_h=yes
143   lyx_cv_aiksaurus_h_location="<Aiksaurus/Aiksaurus.h>"])
144 AC_DEFINE_UNQUOTED(AIKSAURUS_H_LOCATION,$lyx_cv_aiksaurus_h_location,[Location of Aiksaurus.h])
145 fi
146 AC_SUBST(AIKSAURUS_LIBS)
147
148 LYX_USE_INCLUDED_BOOST
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 AC_DISABLE_SHARED
157 AC_LIBTOOL_WIN32_DLL
158 #AM_PROG_LIBTOOL
159 LYX_PROG_LIBTOOL
160
161 ### Check for X libraries
162 AC_PATH_XTRA
163 case $have_x in
164   yes) LIBS="$X_PRE_LIBS $LIBS $X_LIBS -lX11 $X_EXTRA_LIBS"
165        CPPFLAGS="$CPPFLAGS $X_CFLAGS";;
166   no) LYX_ERROR(dnl
167 [Cannot find X window libraries and/or headers. Check your installation.
168   If you use a Linux system, check that you have installed
169   the development tools.]);;
170   disable) ;;
171 esac
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     gtk)
180           PKG_CHECK_MODULES(GTK_FRONTEND, gtkmm-2.4 libglademm-2.4 xft)
181           FRONTENDS_PROGS="$FRONTENDS_PROGS lyx-gtk\$(EXEEXT)"
182           FRONTENDS_SUBDIRS="$FRONTENDS_SUBDIRS gtk"
183           RPM_FRONTEND="gtk"
184           GTKMM_VERSION=`pkg-config --modversion gtkmm-2.4`
185           LIBGLADEMM_VERSION=`pkg-config --modversion libglademm-2.4`
186           FRONTEND_INFO="${FRONTEND_INFO}\
187   GTK Frontend:\n\
188     libgtkmm version:\t\t${GTKMM_VERSION}\n\
189     libglademm version:\t\t${LIBGLADEMM_VERSION}\n"
190           ;;
191
192     qt3)
193           QT_DO_IT_ALL
194           FRONTENDS_PROGS="$FRONTENDS_PROGS lyx-qt3\$(EXEEXT)"
195           FRONTENDS_SUBDIRS="$FRONTENDS_SUBDIRS qt3"
196           RPM_FRONTEND="qt3"
197           FRONTEND_INFO="${FRONTEND_INFO}\
198   Qt Frontend:\n\
199       Qt version:\t\t${QT_VERSION}\n"
200 dnl qt build will fail without moc or uic
201           if test -z "$MOC"; then
202             LYX_ERROR([moc binary not found !])
203           fi
204           if test -z "$UIC"; then
205             LYX_ERROR([uic binary not found !])
206           fi
207           if test -z "$QT_LIB"; then
208             LYX_ERROR([qt library not found !])
209           fi
210       ;;
211     qt4)
212           QT4_DO_IT_ALL
213           FRONTENDS_PROGS="$FRONTENDS_PROGS lyx-qt4\$(EXEEXT)"
214           FRONTENDS_SUBDIRS="$FRONTENDS_SUBDIRS qt4"
215           RPM_FRONTEND="qt4"
216           FRONTEND_INFO="${FRONTEND_INFO}\
217   Qt 4 Frontend:\n\
218       Qt 4 version:\t\t${QT4_VERSION}\n"
219 dnl qt 4 build will fail without moc or uic
220           if test -z "$MOC4"; then
221             LYX_ERROR([moc 4 binary not found !])
222           fi
223           if test -z "$UIC4"; then
224             LYX_ERROR([uic 4 binary not found !])
225           fi
226           if test -z "$QT4_LIB"; then
227             LYX_ERROR([qt 4 library not found !])
228           fi
229       ;;
230     *)
231           LYX_ERROR(Unknown frontend '$frontend');;
232   esac
233 done
234
235 # fix the value of the prefixes.
236 test "x$prefix" = xNONE && prefix=$default_prefix
237 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
238 if echo $prefix |grep ' ' >/dev/null 2>/dev/null ; then
239   LYX_WARNING([The installation prefix \"${prefix}\" contains a space, which
240    causes problems with the Makefiles. The installation will be done in
241    directory \"`pwd`/installprefix\" instead. Please move its contents to
242    the right place after installation.])
243   prefix=`pwd`/installprefix
244 fi
245
246 ### We need iconv for unicode support
247 AM_ICONV
248 if test "$am_cv_func_iconv" = no; then
249   LYX_ERROR([Cannot find required library iconv])
250 fi
251
252 ### Setup GNU gettext
253 dnl GNU gettext is written in C
254 AC_LANG_PUSH(C)
255 AM_GNU_GETTEXT
256 AC_LANG_POP(C)
257
258 # some standard header files
259 AC_HEADER_DIRENT
260 AC_HEADER_MAJOR
261 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)
262
263 # some standard structures
264 AC_HEADER_STAT
265 AC_HEADER_TIME
266
267 # some standard types
268 AC_TYPE_MODE_T
269 AC_TYPE_OFF_T
270 AC_TYPE_PID_T
271 AC_TYPE_SIGNAL
272 AC_TYPE_SIZE_T
273 AC_TYPE_UID_T
274
275 AC_CHECK_FUNCS(strerror)
276 LYX_CHECK_DECL(istreambuf_iterator, iterator)
277 LYX_CHECK_DECL(mkstemp,[unistd.h stdlib.h])
278
279 # Check the form of mkdir()
280 AC_FUNC_MKDIR
281
282 # check for compression support
283 AC_CHECK_HEADERS(zlib.h,
284  [AC_CHECK_LIB(z, gzopen, [LIBS="$LIBS -lz"], LYX_LIB_ERROR(libz,zlib))],
285  [LYX_LIB_ERROR(zlib.h,zlib)])
286
287 dnl This is a slight hack: the tests generated by autoconf 2.52 do not
288 dnl work correctly because of some conflict with stdlib.h with g++ 2.96
289 dnl We aim to remove this eventually, since we should test as much as
290 dnl possible with the compiler which will use the functions (JMarc)
291 AC_LANG_PUSH(C)
292 AC_CHECK_FUNCS(close _close getpid _getpid lstat mkfifo mkstemp mktemp open _open pclose _pclose popen _popen readlink)
293 AC_LANG_POP(C)
294
295 LYX_CHECK_SPELL_ENGINES
296
297 lyx_client_subdir=true
298 AC_LANG_PUSH(C)
299 dnl LIBS already contains some X extra libs that may interfere.
300 save_LIBS="$LIBS"
301 LIBS=
302 AC_CHECK_FUNCS(fcntl,
303   [AC_SEARCH_LIBS([gethostbyname], [nsl])
304    AC_SEARCH_LIBS([socket], [socket], [],
305      [AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"],
306                 [], [-lnsl])])],
307   [lyx_client_subdir=false])
308 AC_SUBST(SOCKET_LIBS,$LIBS)
309 LIBS="$save_LIBS"
310 AM_CONDITIONAL(BUILD_CLIENT_SUBDIR, $lyx_client_subdir)
311 AC_LANG_POP(C)
312
313 AC_FUNC_SELECT_ARGTYPES
314
315 ### Some information on what just happened
316 real_bindir=`eval "echo \`eval \"echo ${bindir}\"\`"`
317 real_pkgdatadir=`eval "echo \`eval \"echo ${pkgdatadir}\"\`"`
318 real_localedir=`eval "echo \`eval \"echo ${datadir}/locale\"\`"`
319 VERSION_INFO="Configuration\n\
320   Host type:                      ${host}\n\
321   Special build flags:            ${lyx_flags}\n\
322   C   Compiler:                   ${CC} ${CC_VERSION}\n\
323   C   Compiler LyX flags:         ${AM_CPPFLAGS} ${AM_CFLAGS}\n\
324   C   Compiler flags:             ${CPPFLAGS} ${CFLAGS}\n\
325   C++ Compiler:                   ${CXX} ${CXX_VERSION}\n\
326   C++ Compiler LyX flags:         ${AM_CPPFLAGS} ${AM_CXXFLAGS}\n\
327   C++ Compiler flags:             ${CPPFLAGS} ${CXXFLAGS}\n\
328   Linker flags:                   ${AM_LDFLAGS}\n\
329   Linker user flags:              ${LDFLAGS}\n\
330 ${FRONTEND_INFO}\
331   Packaging:                      ${lyx_use_packaging}\n\
332   LyX binary dir:                 ${real_bindir}\n\
333   LyX files dir:                  ${real_pkgdatadir}\n"
334
335 MSYS_AC_CANONICAL_PATH(LYX_ABS_TOP_SRCDIR, ${srcdir})
336 MSYS_AC_CANONICAL_PATH(LYX_ABS_INSTALLED_LOCALEDIR, ${real_localedir})
337 MSYS_AC_CANONICAL_PATH(LYX_ABS_INSTALLED_DATADIR, ${real_pkgdatadir})
338
339 AC_SUBST(VERSION_INFO)
340 AC_SUBST(RPM_FRONTEND)
341 AC_SUBST(AM_CPPFLAGS)
342 AC_SUBST(AM_CXXFLAGS)
343 AC_SUBST(AM_CFLAGS)
344 AC_SUBST(AM_LDFLAGS)
345 AC_SUBST(LYX_ABS_TOP_SRCDIR)
346 AC_SUBST(LYX_ABS_INSTALLED_LOCALEDIR)
347 AC_SUBST(LYX_ABS_INSTALLED_DATADIR)
348
349 ## Some config.h stuff
350
351 AH_TOP([
352 /* -*- C++ -*- */
353 /*
354  * \file config.h
355  * This file is part of LyX, the document processor.
356  * Licence details can be found in the file COPYING.
357  *
358  * This is the compilation configuration file for LyX.
359  * It was generated by autoconfs configure.
360  * You might want to change some of the defaults if something goes wrong
361  * during the compilation.
362  */
363
364 #ifndef _CONFIG_H
365 #define _CONFIG_H
366 ])
367
368 AH_BOTTOM([
369 /************************************************************
370  ** You should not need to change anything beyond this point */
371
372 #ifndef HAVE_STRERROR
373 #if defined(__cplusplus)
374 extern "C"
375 #endif
376 char * strerror(int n);
377 #endif
378
379 #ifdef HAVE_MKSTEMP
380 #ifndef HAVE_DECL_MKSTEMP
381 #if defined(__cplusplus)
382 extern "C"
383 #endif
384 int mkstemp(char*);
385 #endif
386 #endif
387
388 #if defined(HAVE_OSTREAM) && defined(HAVE_LOCALE) && defined(HAVE_SSTREAM)
389 #  define USE_BOOST_FORMAT 1
390 #else
391 #  define USE_BOOST_FORMAT 0
392 #endif
393
394 #define BOOST_USER_CONFIG <config.h>
395
396 #if !defined(ENABLE_ASSERTIONS)
397 #  define BOOST_DISABLE_ASSERTS 1
398 #endif
399 #define BOOST_ENABLE_ASSERT_HANDLER 1
400
401 #define BOOST_DISABLE_THREADS 1
402 #define BOOST_NO_WREGEX 1
403 #define BOOST_NO_WSTRING 1
404
405 #ifdef __CYGWIN__
406 #  define BOOST_POSIX 1
407 #endif
408
409 #if defined(HAVE_NEWAPIS_H)
410 #  define WANT_GETFILEATTRIBUTESEX_WRAPPER 1
411 #endif
412
413 #endif
414 ])
415
416 ### Finish the work.
417 AC_CONFIG_FILES([Makefile  m4/Makefile \
418        boost/Makefile \
419        boost/libs/Makefile \
420        boost/libs/filesystem/Makefile \
421        boost/libs/filesystem/src/Makefile \
422        boost/libs/iostreams/Makefile \
423        boost/libs/iostreams/src/Makefile \
424        boost/libs/regex/Makefile \
425        boost/libs/regex/src/Makefile \
426        boost/libs/signals/Makefile \
427        boost/libs/signals/src/Makefile \
428        config/Makefile \
429        development/Makefile \
430        development/lyx.spec \
431        lib/Makefile \
432        lib/doc/Makefile \
433        lib/lyx2lyx/lyx2lyx_version.py \
434        lib/lyx2lyx/Makefile \
435        intl/Makefile \
436        po/Makefile.in \
437        sourcedoc/Doxyfile \
438        sourcedoc/Makefile \
439        src/client/Makefile \
440        src/Makefile \
441        src/version.C-tmp:src/version.C.in \
442        src/tex2lyx/Makefile \
443        src/mathed/Makefile \
444        src/graphics/Makefile \
445        src/insets/Makefile \
446        src/support/Makefile \
447        src/support/tests/Makefile \
448        src/frontends/Makefile \
449        src/frontends/controllers/Makefile \
450        src/frontends/controllers/tests/Makefile \
451        src/frontends/gtk/Makefile \
452        src/frontends/gtk/gimages/Makefile \
453        src/frontends/gtk/glade/Makefile \
454        src/frontends/qt3/Makefile \
455        src/frontends/qt3/ui/Makefile \
456        src/frontends/qt3/ui/moc/Makefile \
457        src/frontends/qt4/Makefile \
458        src/frontends/qt4/ui/Makefile \
459 ])
460
461 AC_OUTPUT
462 # show version information
463 echo
464 printf "$VERSION_INFO"
465 echo
466
467 # Display a final warning if there has been a LYX_ERROR
468 LYX_CHECK_ERRORS