]> git.lyx.org Git - lyx.git/blob - configure.ac
TR1: also use tr1-regex when using msvc10
[lyx.git] / configure.ac
1 dnl Process with autoconf to generate configure script   -*- sh -*-
2
3 AC_INIT(LyX,2.0.0svn,[lyx-devel@lists.lyx.org],[lyx])
4 # Use ISO format only. The frontend needs to parse this
5 AC_SUBST(LYX_DATE, ["2010-06-15"])
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.3.4,, :)
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
101 # Needed for our char_type
102 AC_CHECK_SIZEOF(wchar_t)
103
104 ### We need iconv for unicode support (Qt4 frontend requires it too)
105 AM_ICONV
106 if test "$am_cv_func_iconv" = no; then
107   LYX_ERROR([Cannot find required library iconv])
108 else
109   LIBS="$LIBS $LIBICONV"
110 fi
111
112 ### check for compression support
113 AC_CHECK_HEADERS(zlib.h,
114  [AC_CHECK_LIB(z, gzopen, [LIBS="$LIBS -lz"], LYX_LIB_ERROR(libz,zlib))],
115  [LYX_LIB_ERROR(zlib.h,zlib)])
116
117
118 ### check which frontend we want to use
119
120 dnl The code below is not in a macro, because this would cause big
121 dnl problems with the AC_REQUIRE contained in QT4_DO_IT_ALL.
122 for frontend in $FRONTENDS ; do
123   case "$frontend" in
124     qt4)
125           QT4_DO_IT_ALL
126           FRONTENDS_PROGS="$FRONTENDS_PROGS lyx-qt4\$(EXEEXT)"
127           FRONTENDS_SUBDIRS="$FRONTENDS_SUBDIRS qt4"
128           RPM_FRONTEND="qt4"
129           FRONTEND_INFO="${FRONTEND_INFO}\
130   Qt 4 Frontend:\n\
131       Qt 4 version:\t\t${QT4_VERSION}\n"
132 dnl qt 4 build will fail without moc or uic
133           if test -z "$MOC4"; then
134             LYX_ERROR([moc 4 binary not found !])
135           fi
136           if test -z "$UIC4"; then
137             LYX_ERROR([uic 4 binary not found !])
138           fi
139           if test -z "$QT4_LIB"; then
140             LYX_ERROR([qt 4 library not found !])
141           fi
142       ;;
143     *)
144           LYX_ERROR(Unknown frontend '$frontend');;
145   esac
146 done
147
148 # fix the value of the prefixes.
149 test "x$prefix" = xNONE && prefix=$default_prefix
150 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
151 if echo $prefix |grep ' ' >/dev/null 2>/dev/null ; then
152   LYX_WARNING([The installation prefix \"${prefix}\" contains a space, which
153    causes problems with the Makefiles. The installation will be done in
154    directory \"`pwd`/installprefix\" instead. Please move its contents to
155    the right place after installation.])
156   prefix=`pwd`/installprefix
157 fi
158
159 ### Setup GNU gettext
160 dnl GNU gettext is written in C
161 AC_LANG_PUSH(C)
162 dnl Dirty trick ahead: disable macro AC_GNU_SOURCE because it triggers a bug with autoconf 2.62.
163 dnl this can be removed if gettext is been updated to avoid that.
164 m4_undefine([AC_GNU_SOURCE])
165 m4_defun([AC_GNU_SOURCE],[])
166 AM_GNU_GETTEXT([no-libtool])
167 AM_GNU_GETTEXT_VERSION([0.16.1])
168 AC_LANG_POP(C)
169
170 # some standard header files
171 AC_HEADER_MAJOR
172 AC_CHECK_HEADERS(sys/time.h sys/types.h sys/select.h locale.h utime.h sys/utime.h)
173
174 # some standard structures
175 AC_HEADER_STAT
176 AC_HEADER_TIME
177
178 # some standard types
179 AC_CHECK_TYPE(mode_t,[AC_DEFINE(HAVE_MODE_T, 1, [Define this to 1 if your compiler supports the mode_t type.])])
180 AC_TYPE_OFF_T
181 AC_TYPE_PID_T
182 AC_TYPE_SIGNAL
183 AC_TYPE_SIZE_T
184 AC_TYPE_UID_T
185
186 AC_CHECK_FUNCS(chmod close _close fork getpid _getpid lstat mkfifo open _open pclose _pclose popen _popen readlink strerror)
187 # Check the form of mkdir()
188 AC_FUNC_MKDIR
189 AC_FUNC_SELECT_ARGTYPES
190
191 LYX_CHECK_SPELL_ENGINES
192
193 lyx_client_subdir=true
194 AC_LANG_PUSH(C)
195 dnl LIBS already contains some X extra libs that may interfere.
196 save_LIBS="$LIBS"
197 LIBS=
198 AC_CHECK_FUNCS(fcntl,
199   [AC_SEARCH_LIBS([gethostbyname], [nsl])
200    AC_SEARCH_LIBS([socket], [socket], [],
201      [AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"],
202                 [], [-lnsl])])],
203   [lyx_client_subdir=false])
204 AC_SUBST(SOCKET_LIBS,$LIBS)
205 LIBS="$save_LIBS"
206 AM_CONDITIONAL(BUILD_CLIENT_SUBDIR, $lyx_client_subdir)
207 AC_LANG_POP(C)
208
209 lyx_win_res=false;
210 case ${host} in
211     *mingw*|*cygwin*) lyx_win_res=true;;
212 esac
213 AM_CONDITIONAL(LYX_WIN_RESOURCE, $lyx_win_res)
214 LYX_SET_VERSION_INFO
215
216
217 ### Some information on what just happened
218 real_bindir=`eval "echo \`eval \"echo ${bindir}\"\`"`
219 real_pkgdatadir=`eval "echo \`eval \"echo \\\`eval \\\"echo ${pkgdatadir}\\\"\\\`\"\`"`
220 real_localedir=`eval "echo \`eval \"echo ${datadir}/locale\"\`"`
221 VERSION_INFO="Configuration\n\
222   Host type:                    ${host}\n\
223   Special build flags:          ${lyx_flags}\n\
224   C   Compiler:                 ${CC} ${CC_VERSION}\n\
225   C   Compiler LyX flags:       ${AM_CPPFLAGS} ${AM_CFLAGS}\n\
226   C   Compiler flags:           ${CPPFLAGS} ${CFLAGS}\n\
227   C++ Compiler:                 ${CXX} ${CXX_VERSION}\n\
228   C++ Compiler LyX flags:       ${AM_CPPFLAGS} ${AM_CXXFLAGS}\n\
229   C++ Compiler flags:           ${CPPFLAGS} ${CXXFLAGS}\n\
230   Linker flags:                 ${AM_LDFLAGS}\n\
231   Linker user flags:            ${LDFLAGS}\n\
232 ${FRONTEND_INFO}\
233   Packaging:                    ${lyx_use_packaging}\n\
234   LyX binary dir:               ${real_bindir}\n\
235   LyX files dir:                ${real_pkgdatadir}\n"
236
237 AC_SUBST(VERSION_INFO)
238 AC_SUBST(RPM_FRONTEND)
239 AC_SUBST(AM_CPPFLAGS)
240 AC_SUBST(AM_CXXFLAGS)
241 AC_SUBST(AM_CFLAGS)
242 AC_SUBST(AM_LDFLAGS)
243 AC_SUBST(real_pkgdatadir)
244
245 ## Some config.h stuff
246
247 AH_TOP([
248 /* -*- C++ -*- */
249 /*
250  * \file config.h
251  * This file is part of LyX, the document processor.
252  * Licence details can be found in the file COPYING.
253  *
254  * This is the compilation configuration file for LyX.
255  * It was generated by autoconfs configure.
256  * You might want to change some of the defaults if something goes wrong
257  * during the compilation.
258  */
259
260 #ifndef _CONFIG_H
261 #define _CONFIG_H
262 ])
263
264 AH_BOTTOM([
265 /************************************************************
266  ** You should not need to change anything beyond this point */
267
268 #ifndef HAVE_STRERROR
269 #if defined(__cplusplus)
270 extern "C"
271 #endif
272 char * strerror(int n);
273 #endif
274
275 #if defined(HAVE_OSTREAM) && defined(HAVE_LOCALE) && defined(HAVE_SSTREAM)
276 #  define USE_BOOST_FORMAT 1
277 #else
278 #  define USE_BOOST_FORMAT 0
279 #endif
280
281 #define BOOST_USER_CONFIG <config.h>
282
283 #if !defined(ENABLE_ASSERTIONS)
284 #  define BOOST_DISABLE_ASSERTS 1
285 #endif
286 #define BOOST_ENABLE_ASSERT_HANDLER 1
287
288 #define BOOST_DISABLE_THREADS 1
289 #define BOOST_NO_WREGEX 1
290 #define BOOST_NO_WSTRING 1
291
292 // TR1 regex not supported in GCC <= 4.5
293 #ifndef LYX_USE_TR1
294 #  if defined(_MSC_VER) && (_MSC_VER >= 1600)
295 #    define LYX_USE_TR1
296 #    define LYX_USE_TR1_REGEX
297 #  endif
298 #  if __GNUC__ == 4 && __GNUC_MINOR__ >= 4
299 #    define LYX_USE_TR1
300 #  endif
301 #endif
302
303 #ifdef __CYGWIN__
304 #  define NOMINMAX
305 #  define BOOST_POSIX 1
306 #  define BOOST_POSIX_API 1
307 #  define BOOST_POSIX_PATH 1
308 #endif
309
310 /*
311  * the FreeBSD libc uses UCS4, but libstdc++ has no proper wchar_t
312  * support compiled in:
313  * http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#3_9
314  * And we are not interested at all what libc
315  * does: What we need is a 32bit wide wchar_t, and a libstdc++ that
316  * has the needed wchar_t support and uses UCS4. Whether it
317  * implements this with the help of libc, or whether it has own code
318  * does not matter for us, because we do not use libc directly (Georg)
319 */
320 #if defined(HAVE_WCHAR_T) && SIZEOF_WCHAR_T == 4 && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
321 #  define USE_WCHAR_T
322 #endif
323
324 #endif
325 ])
326
327 MSYS_AC_CANONICAL_PATH(lyx_abs_top_srcdir, ${srcdir})
328 MSYS_AC_CANONICAL_PATH(lyx_abs_installed_localedir, ${real_localedir})
329 MSYS_AC_CANONICAL_PATH(lyx_abs_installed_datadir, ${real_pkgdatadir})
330
331 AC_DEFINE_UNQUOTED([LYX_ABS_TOP_SRCDIR],
332         "${lyx_abs_top_srcdir}", [Top source directory])
333 AC_DEFINE_UNQUOTED([LYX_ABS_INSTALLED_LOCALEDIR],
334         "${lyx_abs_installed_localedir}",[Hard coded locale directory])
335 AC_DEFINE_UNQUOTED([LYX_ABS_INSTALLED_DATADIR],
336         "${lyx_abs_installed_datadir}",[Hard system support directory])
337 AC_DEFINE_UNQUOTED([PROGRAM_SUFFIX],
338         "${version_suffix}",[Program version suffix])
339
340 AC_DEFINE_UNQUOTED([LYX_DATE],"$LYX_DATE",[Date of release])
341 AC_DEFINE_UNQUOTED([VERSION_INFO],"$VERSION_INFO",[Full version info])
342 AC_DEFINE_UNQUOTED([LYX_DIR_VER],"$lyx_dir_ver",[Versioned env var for system dir])
343 AC_DEFINE_UNQUOTED([LYX_USERDIR_VER],"$lyx_userdir_ver",[Versioned env var for user dir])
344 AC_DEFINE_UNQUOTED([LYX_MAJOR_VERSION],$lyx_major,[Major version number])
345 AC_DEFINE_UNQUOTED([LYX_MINOR_VERSION],$lyx_minor,[Minor version number])
346 AC_DEFINE_UNQUOTED([LYX_RELEASE_LEVEL],$lyx_release,[Release version number])
347 AC_DEFINE_UNQUOTED([LYX_RELEASE_PATCH],$lyx_patch,[Patch version number])
348
349 AC_CONFIG_FILES([Makefile \
350       lyx.1:lyx.1in \
351       boost/Makefile \
352       config/Makefile \
353       development/Makefile \
354       development/MacOSX/Makefile \
355       development/MacOSX/Info.plist \
356       development/MacOSX/lyxrc.dist \
357       development/MacOSX/spotlight/Makefile \
358       development/cygwin/Makefile \
359       development/cygwin/lyxrc.dist \
360       development/lyx.spec \
361       intl/Makefile \
362       lib/Makefile \
363       lib/doc/Makefile \
364       lib/lyx2lyx/lyx2lyx_version.py \
365       lib/lyx2lyx/Makefile \
366       m4/Makefile \
367       po/Makefile.in \
368       sourcedoc/Doxyfile \
369       sourcedoc/Makefile \
370       src/client/Makefile \
371       src/client/lyxclient.1:src/client/lyxclient.1in \
372       src/Makefile \
373       src/tex2lyx/Makefile \
374       src/tex2lyx/tex2lyx.1:src/tex2lyx/tex2lyx.1in \
375       src/support/Makefile \
376       src/frontends/Makefile \
377       src/frontends/qt4/Makefile
378 ])
379
380
381 AC_OUTPUT
382
383 # show version information
384 echo
385 printf "$VERSION_INFO"
386 echo
387
388 # Display a final warning if there has been a LYX_ERROR
389 LYX_CHECK_ERRORS