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