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