Fix build on systems that have a separate libintl library
[centerim5.git] / configure.ac
blob8505a90248702269bd8e3a3825ad8ed8401e8954
1 AC_PREREQ([2.69])
2 AC_INIT([centerim5], [m4_esyscmd([misc/git-version-gen version])],
3         [centerim-devel@centerim.org], [centerim5], [http://www.centerim.org/])
4 # Prevent AC_PROG_CC, AC_PROG_CXX from initializing CFLAGS and CXXFLAGS.
5 : ${CFLAGS=""}
6 : ${CXXFLAGS=""}
7 AC_CONFIG_SRCDIR([config.h.in])
8 AC_CONFIG_AUX_DIR([config])
9 AC_CONFIG_HEADER([config.h])
10 AC_CONFIG_MACRO_DIR([m4])
11 AM_INIT_AUTOMAKE([-Wall subdir-objects])
12 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
14 AC_GNU_SOURCE
16 # Checks for programs.
17 AC_PROG_CC
18 AC_PROG_CC_C99
19 AC_PROG_CXX
20 AX_CXX_COMPILE_STDCXX([11], [noext])
21 AM_PROG_AR
23 LT_INIT([disable-static])
25 # Set compiler flags.
27 AC_ARG_ENABLE([strict], [AC_HELP_STRING([--enable-strict],
28         [enable extra compiler warnings during build])])
29 AC_ARG_ENABLE([debug], [AC_HELP_STRING([--enable-debug],
30         [compile with debugging support])])
32 # If not --enable-debug then try to set -O2 as default.
33 AS_IF([test "$enable_debug" != yes],
34         [save_cflags="$CFLAGS"]
35         [CFLAGS="-O2"]
36         [AC_MSG_CHECKING([whether CC supports -O2])]
37         [AC_LANG_PUSH([C])]
38         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
39                 [AC_MSG_RESULT([yes])]
40                 [AM_CFLAGS="$AM_CFLAGS -O2"],
41                 [AC_MSG_RESULT([no])])]
42         [AC_LANG_POP([C])]
43         [CFLAGS="$save_cflags"]
45         [save_cxxflags="$CXXFLAGS"]
46         [CXXFLAGS="-O2"]
47         [AC_MSG_CHECKING([whether CXX supports -O2])]
48         [AC_LANG_PUSH([C++])]
49         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
50                 [AC_MSG_RESULT([yes])]
51                 [AM_CXXFLAGS="$AM_CXXFLAGS -O2"],
52                 [AC_MSG_RESULT([no])])]
53         [AC_LANG_POP([C++])]
54         [CXXFLAGS="$save_cxxflags"])
56 # If --enable-strict is specified then enable compilation warnings.
57 AS_IF([test "$enable_strict" = yes],
58         [save_cflags="$CFLAGS"]
59         [CFLAGS="-Wall -Wextra -pedantic"]
60         [AC_MSG_CHECKING([whether CC supports -Wall -Wextra -pedantic])]
61         [AC_LANG_PUSH([C])]
62         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
63                 [AC_MSG_RESULT([yes])],
64                 [AC_MSG_RESULT([no])]
65                 [AC_MSG_ERROR([the C compiler does not recognize options -Wall -Wextra -pedantic that are needed by --enable-strict])])]
66         [AC_LANG_POP([C])]
67         [CFLAGS="$save_cflags"]
68         [AM_CFLAGS="$AM_CFLAGS -Wall -Wextra -pedantic"]
70         [save_cxxflags="$CXXFLAGS"]
71         [CXXFLAGS="-Wall -Wextra -pedantic -Wno-long-long -Wsuggest-override"]
72         [AC_MSG_CHECKING([whether CXX supports -Wall -Wextra -pedantic -Wno-long-long -Wsuggest-override])]
73         [AC_LANG_PUSH([C++])]
74         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
75                 [AC_MSG_RESULT([yes])],
76                 [AC_MSG_RESULT([no])]
77                 [AC_MSG_ERROR([the C++ compiler does not recognize options -Wall -Wextra -pedantic -Wno-long-long -Wsuggest-override that are needed by --enable-strict])])]
78         [AC_LANG_POP([C++])]
79         [CXXFLAGS="$save_cxxflags"]
80         [AM_CXXFLAGS="$AM_CXXFLAGS -Wall -Wextra -pedantic -Wno-long-long -Wsuggest-override"])
82 # If --enable-debug is specified then compile with -g -O0.
83 AS_IF([test "$enable_debug" = yes],
84         [save_cflags="$CFLAGS"]
85         [CFLAGS="-g -O0"]
86         [AC_MSG_CHECKING([whether CC supports -g -O0])]
87         [AC_LANG_PUSH([C])]
88         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
89                 [AC_MSG_RESULT([yes])],
90                 [AC_MSG_RESULT([no])]
91                 [AC_MSG_ERROR([the C compiler does not recognize options -g -O0 that are needed by --enable-debug])])]
92         [AC_LANG_POP([C])]
93         [CFLAGS="$save_cflags"]
94         [AM_CFLAGS="$AM_CFLAGS -g -O0"]
96         [save_cxxflags="$CXXFLAGS"]
97         [CXXFLAGS="-g -O0"]
98         [AC_MSG_CHECKING([whether CXX supports -g -O0])]
99         [AC_LANG_PUSH([C++])]
100         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
101                 [AC_MSG_RESULT([yes])],
102                 [AC_MSG_RESULT([no])]
103                 [AC_MSG_ERROR([the C++ compiler does not recognize options -g -O0 that are needed by --enable-debug])])]
104         [AC_LANG_POP([C++])]
105         [CXXFLAGS="$save_cxxflags"]
106         [AM_CXXFLAGS="$AM_CXXFLAGS -g -O0"])
107 AC_SUBST([AM_CFLAGS])
108 AC_SUBST([AM_CXXFLAGS])
109 AS_IF([test "$enable_debug" = yes],
110         [AC_DEFINE([DEBUG], [1], [Define if debugging is enabled.])])
112 # Checks for libraries.
114 # gettext -- v0.18.1 was released on 2010-06-04.
115 AM_GNU_GETTEXT([external])
116 AM_GNU_GETTEXT_VERSION([0.18.1])
118 # libpurple -- v2.9.0 is needed because of PurpleConvChatBuddy::ui_data, this
119 # version was released on 2011-06-23.
120 # find . \( -name \*.c -or -name \*.cpp -o -name \*.h \) -print0 | xargs -0 sed -n 's/.*\(purple_[^( ]*\)(.*/\1/p' | sort -u | less
121 PKG_CHECK_MODULES([PURPLE], [purple >= 2.7.0])
123 # glib -- v2.32.0 is needed because of g_environ_setenv(), this version was
124 # released on 2012-03-24.
125 # find . \( -name \*.c -o -name \*.cpp -o -name \*.h \) -print0 | xargs -0 sed -n 's/.*\(g_[^ (]*\)(.*/\1/p' | sort -u | less
126 PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.32.0])
128 # libsigc++ -- v2.2.0 was released on 2008-02-22.
129 PKG_CHECK_MODULES([SIGC], [sigc++-2.0 >= 2.2.0])
131 # ncursesw -- v5.8 was released on 2011-02-26.
132 PKG_CHECK_MODULES([NCURSESW], [ncursesw >= 5.8])
134 # Checks for tools needed by the termex test framework. Only warn about these
135 # missing dependencies.
137 # tic
138 AC_PATH_PROG([TIC], [tic])
139 AC_ARG_VAR([TIC], [path to tic])
140 AS_IF([test -z "$TIC"],
141         [AC_MSG_WARN([tic was not found, running tests will not be possible])])
143 # python -- v3.5 is needed for termex.py (see the script for details), this
144 # version was released on 2015-09-13.
145 AC_PATH_PROG([PYTHON], [python3])
146 AC_ARG_VAR([PYTHON], [path to python3])
147 AS_IF([test -n "$PYTHON"],
148         [AC_MSG_CHECKING([python3 is at least version 3.5])]
149         [python_version_ok=`$PYTHON -c 'import sys; print(sys.hexversion >= 0x03050000)'`]
150         [AS_IF([test "$python_version_ok" == True],
151                 [AC_MSG_RESULT([yes])],
152                 [AC_MSG_RESULT([no])])])
153 AS_IF([test -z "$PYTHON" -o "$python_version_ok" != True],
154         [AC_MSG_WARN([python >= 3.5 was not found, running tests will not be possible])])
156 AM_CONDITIONAL([TERMEX_TESTS],
157         [test -n "$TIC" -a -n "$PYTHON" -a "$python_version_ok" == True])
159 # CIM_RECURSIVE_EVAL(VALUE, RESULT)
160 # =================================
161 # Interpolate the VALUE in loop until it does not change, and set the result
162 # to $RESULT.
163 # WARNING: It is easy to get an infinite loop with some unsane input.
164 # Taken from http://ac-archive.sourceforge.net/adl/relpaths.html.
165 AC_DEFUN([CIM_RECURSIVE_EVAL],
166 [_lcl_receval="$1"
167 $2=`(test "$prefix" = NONE && prefix="$ac_default_prefix"
168         test "$exec_prefix" = NONE && exec_prefix="$prefix"
169         _lcl_receval_old=''
170         while test "[$]_lcl_receval_old" != "[$]_lcl_receval"; do
171                 _lcl_receval_old="[$]_lcl_receval"
172                 eval _lcl_receval="\"[$]_lcl_receval\""
173         done
174         echo "[$]_lcl_receval")`])
176 # Define locale and pkgdir directories. It would be nicer to do this in
177 # Makefile.ams by adding appropriate '-D' compiler options to respective
178 # CPPFLAGS, which is a common solution that can be seen in other projects. In
179 # that case, it is not needed to resolve the paths at the configure time using
180 # the CIM_RECURSIVE_EVAL function. However this solution unfortunately does not
181 # work correctly when values of the defines are changed, the source files that
182 # use these defines do not get correctly recompiled. To fix this, the defines
183 # have to be put into the config.h file.
184 CIM_RECURSIVE_EVAL([$localedir], [localedir_eval])
185 AC_DEFINE_UNQUOTED([LOCALEDIR], ["$localedir_eval"],
186         [Define to the locale directory.])
188 CIM_RECURSIVE_EVAL([$libdir/AC_PACKAGE_NAME], [pkglibdir_eval])
189 AC_DEFINE_UNQUOTED([PKGLIBDIR], ["$pkglibdir_eval"],
190         [Define to the pkglib directory.])
192 # Create output files.
193 AC_CONFIG_FILES([Makefile
194                  contrib/Makefile
195                  cppconsui/Makefile
196                  doc/Makefile
197                  doc/doxygen-cppconsui.conf
198                  misc/Makefile
199                  plugins/Makefile
200                  po/Makefile.in
201                  src/Makefile
202                  tests/Makefile])
203 AC_OUTPUT