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