]> git.lyx.org Git - features.git/blob - configure.ac
e937a5047f9257bff37430a375bf84578ec5e979
[features.git] / configure.ac
1 dnl Process with autoconf to generate configure script   -*- sh -*-
2
3 AC_INIT(LyX,2.1.0dev,[lyx-devel@lists.lyx.org],[lyx])
4 AC_PRESERVE_HELP_ORDER
5 # Use ISO format only. The frontend needs to parse this
6 AC_SUBST(LYX_DATE, ["2011-04-29"])
7 AC_PREREQ(2.60)
8 AC_CONFIG_SRCDIR(src/main.cpp)
9 AC_CONFIG_HEADERS([config.h])
10
11 AC_CONFIG_AUX_DIR(config)
12
13 # First check the version
14 LYX_CHECK_VERSION
15 LYX_VERSION_SUFFIX
16 # Check how the files should be packaged
17 AC_CANONICAL_TARGET
18 LYX_USE_PACKAGING
19 # We need to define these variables here and the no-define option of
20 # AM_INIT_AUTOMAKE above because we alter $PACKAGE in LYX_USE_PACKAGING.
21 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
22
23 dnl Default maintainer mode to true for development versions
24 if test "${enable_maintainer_mode+set}" != set; then
25   enable_maintainer_mode=$lyx_devel_version
26 fi
27 AM_MAINTAINER_MODE
28
29 save_PACKAGE=$PACKAGE
30 AM_INIT_AUTOMAKE([foreign dist-bzip2 no-define 1.8])
31 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
32 PACKAGE=$save_PACKAGE
33
34 # Allow to build some parts of the code as one big chunk
35 m4_define([ALLPARTS],[boost,client,insets,mathed,core,tex2lyx,frontend_qt4])
36 AC_ARG_ENABLE(monolithic-build,
37   AC_HELP_STRING([--enable-monolithic-build@<:@=LIST@:>@],
38                 [Use monolithic build for modules in LIST (default: ALLPARTS)]),
39   [test "$enable_monolithic_build" = yes && enable_monolithic_build="ALLPARTS"
40    test "$enable_monolithic_build" = no && enable_monolithic_build=
41    IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=" ,"
42    for i in $enable_monolithic_build ; do
43        eval "enable_monolithic_$i=yes"
44    done
45    IFS="$ac_save_ifs"],
46   [enable_monolithic_build=])
47
48 AM_CONDITIONAL(MONOLITHIC_BOOST, test "x$enable_monolithic_boost" = "xyes")
49 AM_CONDITIONAL(MONOLITHIC_CLIENT, test "x$enable_monolithic_client" = "xyes")
50 AM_CONDITIONAL(MONOLITHIC_INSETS, test "x$enable_monolithic_insets" = "xyes")
51 AM_CONDITIONAL(MONOLITHIC_MATHED, test "x$enable_monolithic_mathed" = "xyes")
52 AM_CONDITIONAL(MONOLITHIC_CORE, test "x$enable_monolithic_core" = "xyes")
53 AM_CONDITIONAL(MONOLITHIC_TEX2LYX, test "x$enable_monolithic_tex2lyx" = "xyes")
54 AM_CONDITIONAL(MONOLITHIC_FRONTEND_QT4, test "x$enable_monolithic_frontend_qt4" = "xyes")
55
56 ### Set the execute permissions of the various scripts correctly
57 for file in config/install-sh ; do
58   chmod 755 ${srcdir}/${file}
59 done
60
61 # Check for installed python
62 AM_PATH_PYTHON(2.4.0,, :)
63
64 ### we need to know the byte order for unicode conversions
65 AC_C_BIGENDIAN
66
67 ### check which frontend we want to use
68 LYX_USE_FRONTENDS
69
70 ### Check for a C++ compiler
71 LYX_PROG_CXX
72
73 ### Objective-C compiler
74 AC_PROG_OBJC
75 _AM_DEPENDENCIES([OBJC])
76
77 ### Add extra directories to check for libraries.
78 LYX_WITH_DIR([extra-lib],[extra library directory],extra_lib, NONE)
79 LYX_LOOP_DIR($lyx_cv_extra_lib,LYX_ADD_LIB_DIR(lyx_ldflags,$dir))
80 test ! x"$lyx_ldflags" = x && LDFLAGS="$lyx_ldflags $LDFLAGS"
81
82 ### Add extra directories to check for include files.
83 LYX_WITH_DIR([extra-inc],[extra include directory],extra_inc, NONE)
84 LYX_LOOP_DIR($lyx_cv_extra_inc,LYX_ADD_INC_DIR(lyx_cppflags,$dir))
85 test ! x"$lyx_cppflags" = x && CPPFLAGS="$lyx_cppflags $CPPFLAGS"
86
87 ### Add both includes and libraries
88 LYX_WITH_DIR([extra-prefix],[extra lib+include directory],extra_prefix, NONE, ${prefix})
89 LYX_LOOP_DIR($lyx_cv_extra_prefix,[
90 LYX_ADD_INC_DIR(CPPFLAGS,$dir/include)
91   LYX_ADD_LIB_DIR(LDFLAGS,$dir/lib)])
92
93 ### These are needed in windows
94 AC_CHECK_LIB(shlwapi, main, [LIBSHLWAPI=-lshlwapi])
95 AC_SUBST(LIBSHLWAPI)
96 AC_CHECK_LIB(psapi, main, [LIBPSAPI=-lpsapi])
97 AC_SUBST(LIBPSAPI)
98 AC_CHECK_LIB(gdi32, main)
99
100 LYX_USE_INCLUDED_BOOST
101 LYX_USE_INCLUDED_MYTHES
102
103 # Needed for our char_type
104 AC_CHECK_SIZEOF(wchar_t)
105
106 ### We need iconv for unicode support (Qt4 frontend requires it too)
107 AM_ICONV
108 if test "$am_cv_func_iconv" = no; then
109   AC_MSG_ERROR([cannot find required library iconv.])
110 else
111   LIBS="$LIBS $LIBICONV"
112 fi
113
114 ### check for compression support
115 AC_CHECK_HEADERS(zlib.h,
116  [AC_CHECK_LIB(z, gzopen, [LIBS="$LIBS -lz"], LYX_LIB_ERROR(libz,zlib))],
117  [LYX_LIB_ERROR(zlib.h,zlib)])
118
119 ### check for file magic support (currently optional)
120 AC_CHECK_HEADERS(magic.h,
121  [AC_CHECK_LIB(magic, magic_open, [LIBS="$LIBS -lmagic"],
122   LYX_WARNING([cannot find libmagic. Please check that the libmagic library
123    is correctly installed on your system.
124    Falling back to builtin file format detection.]))],
125  [LYX_WARNING([cannot find magic.h. Please check that the libmagic library
126    is correctly installed on your system.
127    Falling back to builtin file format detection.])])
128
129
130 ### check which frontend we want to use
131
132 dnl The code below is not in a macro, because this would cause big
133 dnl problems with the AC_REQUIRE contained in QT4_DO_IT_ALL.
134 for frontend in $FRONTENDS ; do
135   case "$frontend" in
136     qt4)
137           QT4_DO_IT_ALL([4.5.0])
138           FRONTENDS_PROGS="$FRONTENDS_PROGS lyx-qt4\$(EXEEXT)"
139           FRONTENDS_SUBDIRS="$FRONTENDS_SUBDIRS qt4"
140           RPM_FRONTEND="qt4"
141           FRONTEND_INFO="${FRONTEND_INFO}\
142   Qt 4 Frontend:\n\
143       Qt 4 version:\t\t${QT4_VERSION}\n"
144 dnl qt 4 build will fail without moc, uic, or bc
145           if test -z "$MOC4"; then
146             AC_MSG_ERROR([cannot find moc binary.])
147           fi
148           if test -z "$UIC4"; then
149             AC_MSG_ERROR([cannot find uic binary.!])
150           fi
151           if test -z "$QT4_LIB"; then
152             AC_MSG_ERROR([cannot find qt4 library.])
153           fi
154           if test "$bc_found" = "no"; then
155             AC_MSG_ERROR([cannot find bc program.])
156           fi
157       ;;
158     *)
159           AC_MSG_ERROR([unknown frontend '$frontend'.]);;
160   esac
161 done
162
163 # fix the value of the prefixes.
164 test "x$prefix" = xNONE && prefix=$default_prefix
165 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
166 if echo $prefix |grep ' ' >/dev/null 2>/dev/null ; then
167   LYX_WARNING([the installation prefix \"${prefix}\" contains a space, which
168    causes problems with the Makefiles. The installation will be done in
169    directory \"`pwd`/installprefix\" instead. Please move its contents to
170    the right place after installation.])
171   prefix=`pwd`/installprefix
172 fi
173
174 ### Setup GNU gettext
175 dnl GNU gettext is written in C
176 AC_LANG_PUSH(C)
177 dnl Dirty trick ahead: disable macro AC_GNU_SOURCE because it triggers a bug with autoconf 2.62.
178 dnl this can be removed if gettext is been updated to avoid that.
179 m4_undefine([AC_GNU_SOURCE])
180 m4_defun([AC_GNU_SOURCE],[])
181 AM_GNU_GETTEXT([no-libtool])
182 AM_GNU_GETTEXT_VERSION([0.16.1])
183 AC_LANG_POP(C)
184
185 # some standard header files
186 AC_HEADER_MAJOR
187 AC_CHECK_HEADERS(sys/time.h sys/types.h sys/select.h locale.h utime.h sys/utime.h)
188
189 # some standard types
190 AC_CHECK_TYPE(mode_t,[AC_DEFINE(HAVE_MODE_T, 1, [Define this to 1 if your compiler supports the mode_t type.])])
191 AC_TYPE_OFF_T
192 AC_TYPE_PID_T
193 AC_TYPE_SIZE_T
194 AC_TYPE_UID_T
195
196 LYX_CHECK_DEF(PATH_MAX, limits.h, [int n = PATH_MAX;])
197
198 AC_CHECK_FUNCS(chmod close _close fork getpid _getpid lstat mkfifo open _open pclose _pclose popen _popen readlink strerror unsetenv)
199 # Check the form of mkdir()
200 AC_FUNC_MKDIR
201 AC_FUNC_SELECT_ARGTYPES
202
203 LYX_CHECK_SPELL_ENGINES
204
205 lyx_client_subdir=true
206 AC_LANG_PUSH(C)
207 dnl LIBS already contains some X extra libs that may interfere.
208 save_LIBS="$LIBS"
209 LIBS=
210 AC_CHECK_FUNCS(fcntl,
211   [AC_SEARCH_LIBS([gethostbyname], [nsl])
212    AC_SEARCH_LIBS([socket], [socket], [],
213      [AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"],
214                 [], [-lnsl])])],
215   [lyx_client_subdir=false])
216 AC_SUBST(SOCKET_LIBS,$LIBS)
217 LIBS="$save_LIBS"
218 AM_CONDITIONAL(BUILD_CLIENT_SUBDIR, $lyx_client_subdir)
219 AC_LANG_POP(C)
220
221 lyx_win_res=false;
222 case ${host} in
223     *mingw*|*cygwin*) lyx_win_res=true;;
224 esac
225 AM_CONDITIONAL(LYX_WIN_RESOURCE, $lyx_win_res)
226 LYX_SET_VERSION_INFO
227
228
229 ### Some information on what just happened
230 real_bindir=`eval "echo \`eval \"echo ${bindir}\"\`"`
231 real_pkgdatadir=`eval "echo \`eval \"echo \\\`eval \\\"echo ${pkgdatadir}\\\"\\\`\"\`"`
232 real_localedir=`eval "echo \`eval \"echo ${datadir}/locale\"\`"`
233 VERSION_INFO="Configuration\n\
234   Host type:                    ${host}\n\
235   Special build flags:         ${lyx_flags}\n\
236   C++ Compiler:                 ${CXX} ${CXX_VERSION}\n\
237   C++ Compiler LyX flags:       ${AM_CPPFLAGS} ${AM_CXXFLAGS}\n\
238   C++ Compiler flags:           ${CPPFLAGS} ${CXXFLAGS}\n\
239   Linker flags:                 ${AM_LDFLAGS}\n\
240   Linker user flags:            ${LDFLAGS}\n\
241 ${FRONTEND_INFO}\
242   Packaging:                    ${lyx_use_packaging}\n\
243   LyX binary dir:               ${real_bindir}\n\
244   LyX files dir:                ${real_pkgdatadir}\n"
245
246 AC_SUBST(VERSION_INFO)
247 AC_SUBST(RPM_FRONTEND)
248 AC_SUBST(AM_CPPFLAGS)
249 AC_SUBST(AM_CXXFLAGS)
250 AC_SUBST(AM_CFLAGS)
251 AC_SUBST(AM_LDFLAGS)
252 AC_SUBST(real_pkgdatadir)
253
254 ## Some config.h stuff
255
256 AH_TOP([
257 /* -*- C++ -*- */
258 /*
259  * \file config.h
260  * This file is part of LyX, the document processor.
261  * Licence details can be found in the file COPYING.
262  *
263  * This is the compilation configuration file for LyX.
264  * It was generated by autoconfs configure.
265  * You might want to change some of the defaults if something goes wrong
266  * during the compilation.
267  */
268
269 #ifndef _CONFIG_H
270 #define _CONFIG_H
271 ])
272
273 AH_BOTTOM([
274 /************************************************************
275  ** You should not need to change anything beyond this point */
276
277 #ifndef HAVE_STRERROR
278 #if defined(__cplusplus)
279 extern "C"
280 #endif
281 char * strerror(int n);
282 #endif
283
284 #if defined(HAVE_OSTREAM) && defined(HAVE_LOCALE) && defined(HAVE_SSTREAM)
285 #  define USE_BOOST_FORMAT 1
286 #else
287 #  define USE_BOOST_FORMAT 0
288 #endif
289
290 #define BOOST_USER_CONFIG <config.h>
291
292 #if !defined(ENABLE_ASSERTIONS)
293 #  define BOOST_DISABLE_ASSERTS 1
294 #endif
295 #define BOOST_ENABLE_ASSERT_HANDLER 1
296
297 #define BOOST_DISABLE_THREADS 1
298 #define BOOST_NO_WREGEX 1
299 #define BOOST_NO_WSTRING 1
300
301 // TR1 regex not supported in GCC <= 4.5
302 #ifndef LYX_USE_TR1
303 #  if __GNUC__ == 4 
304 #    define LYX_USE_TR1
305 #  endif
306 #endif
307
308 #ifdef __CYGWIN__
309 #  define NOMINMAX
310 #  define BOOST_POSIX 1
311 #  define BOOST_POSIX_API 1
312 #  define BOOST_POSIX_PATH 1
313 #endif
314
315 /*
316  * the FreeBSD libc uses UCS4, but libstdc++ has no proper wchar_t
317  * support compiled in:
318  * http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#3_9
319  * And we are not interested at all what libc
320  * does: What we need is a 32bit wide wchar_t, and a libstdc++ that
321  * has the needed wchar_t support and uses UCS4. Whether it
322  * implements this with the help of libc, or whether it has own code
323  * does not matter for us, because we do not use libc directly (Georg)
324 */
325 #if defined(HAVE_WCHAR_T) && SIZEOF_WCHAR_T == 4 && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
326 #  define USE_WCHAR_T
327 #endif
328
329 #endif
330 ])
331
332 MSYS_AC_CANONICAL_PATH(lyx_abs_top_srcdir, ${srcdir})
333 MSYS_AC_CANONICAL_PATH(lyx_abs_installed_localedir, ${real_localedir})
334 MSYS_AC_CANONICAL_PATH(lyx_abs_installed_datadir, ${real_pkgdatadir})
335
336 AC_DEFINE_UNQUOTED([LYX_ABS_TOP_SRCDIR],
337         "${lyx_abs_top_srcdir}", [Top source directory])
338 AC_DEFINE_UNQUOTED([LYX_ABS_INSTALLED_LOCALEDIR],
339         "${lyx_abs_installed_localedir}",[Hard coded locale directory])
340 AC_DEFINE_UNQUOTED([LYX_ABS_INSTALLED_DATADIR],
341         "${lyx_abs_installed_datadir}",[Hard system support directory])
342 AC_DEFINE_UNQUOTED([PROGRAM_SUFFIX],
343         "${version_suffix}",[Program version suffix])
344
345 AC_DEFINE_UNQUOTED([LYX_DATE],"$LYX_DATE",[Date of release])
346 AC_DEFINE_UNQUOTED([VERSION_INFO],"$VERSION_INFO",[Full version info])
347 AC_DEFINE_UNQUOTED([LYX_DIR_VER],"$lyx_dir_ver",[Versioned env var for system dir])
348 AC_DEFINE_UNQUOTED([LYX_USERDIR_VER],"$lyx_userdir_ver",[Versioned env var for user dir])
349 AC_DEFINE_UNQUOTED([LYX_MAJOR_VERSION],$lyx_major,[Major version number])
350 AC_DEFINE_UNQUOTED([LYX_MINOR_VERSION],$lyx_minor,[Minor version number])
351 AC_DEFINE_UNQUOTED([LYX_RELEASE_LEVEL],$lyx_release,[Release version number])
352 AC_DEFINE_UNQUOTED([LYX_RELEASE_PATCH],$lyx_patch,[Patch version number])
353
354 AC_CONFIG_FILES([Makefile \
355       lyx.1:lyx.1in \
356       boost/Makefile \
357       config/Makefile \
358       development/Makefile \
359       development/MacOSX/Makefile \
360       development/MacOSX/Info.plist \
361       development/MacOSX/lyxrc.dist \
362       development/MacOSX/spotlight/Makefile \
363       development/cygwin/Makefile \
364       development/cygwin/lyxrc.dist \
365       development/lyx.spec \
366       intl/Makefile \
367       lib/lyx.desktop-temp:lib/lyx.desktop.in
368       lib/Makefile \
369       lib/doc/Makefile \
370       lib/lyx2lyx/lyx2lyx_version.py \
371       lib/lyx2lyx/Makefile \
372       m4/Makefile \
373       po/Makefile.in \
374       sourcedoc/Doxyfile \
375       sourcedoc/Makefile \
376       src/client/Makefile \
377       src/client/lyxclient.1:src/client/lyxclient.1in \
378       src/Makefile \
379       src/tex2lyx/Makefile \
380       src/tex2lyx/tex2lyx.1:src/tex2lyx/tex2lyx.1in \
381       src/support/Makefile \
382       src/frontends/Makefile \
383       src/frontends/qt4/Makefile
384 ])
385
386
387 AC_OUTPUT
388
389 # show version information
390 echo
391 printf "$VERSION_INFO"
392 echo
393
394 # Display a final warning if there has been a LYX_WARNING
395 LYX_CHECK_WARNINGS
396
397 cat <<EOF
398 Configuration of LyX was successful.
399 Type 'make' to compile the program,
400 and then 'make install' to install it.
401 EOF