Release CenterIM 5.0.0
[centerim5.git] / configure.ac
blob5b265a707e23ae0a8fdea097d885eb96aa21e9ca
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 AM_ICONV()
115 AS_IF([test "$am_cv_func_iconv" != yes],
116         [AC_MSG_ERROR([iconv not found])])
118 # gettext -- v0.19.3 was released on 2014-10-16.
119 AM_GNU_GETTEXT([external])
120 AM_GNU_GETTEXT_VERSION([0.19.3])
122 # libpurple -- v2.9.0 is needed because of PurpleConvChatBuddy::ui_data, this
123 # version was released on 2011-06-23.
124 # find . \( -name \*.c -or -name \*.cpp -o -name \*.h \) -print0 | xargs -0 sed -n 's/.*\(purple_[^( ]*\)(.*/\1/p' | sort -u | less
125 PKG_CHECK_MODULES([PURPLE], [purple >= 2.7.0])
127 # glib -- v2.32.0 is needed because of g_environ_setenv(), this version was
128 # released on 2012-03-24.
129 # find . \( -name \*.c -o -name \*.cpp -o -name \*.h \) -print0 | xargs -0 sed -n 's/.*\(g_[^ (]*\)(.*/\1/p' | sort -u | less
130 PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.32.0])
132 # libsigc++ -- v2.2.0 was released on 2008-02-22.
133 PKG_CHECK_MODULES([SIGC], [sigc++-2.0 >= 2.2.0])
135 # ncursesw -- v5.8 was released on 2011-02-26.
136 PKG_CHECK_MODULES([NCURSESW], [ncursesw >= 5.8])
138 # Checks for tools needed by the termex test framework. Only warn about these
139 # missing dependencies.
141 # tic
142 AC_PATH_PROG([TIC], [tic])
143 AC_ARG_VAR([TIC], [path to tic])
144 AS_IF([test -z "$TIC"],
145         [AC_MSG_WARN([tic was not found, running tests will not be possible])])
147 # python -- v3.5 is needed for termex.py (see the script for details), this
148 # version was released on 2015-09-13.
149 AC_PATH_PROG([PYTHON], [python3])
150 AC_ARG_VAR([PYTHON], [path to python3])
151 AS_IF([test -n "$PYTHON"],
152         [AC_MSG_CHECKING([python3 is at least version 3.5])]
153         [python_version_ok=`$PYTHON -c 'import sys; print(sys.hexversion >= 0x03050000)'`]
154         [AS_IF([test "$python_version_ok" == True],
155                 [AC_MSG_RESULT([yes])],
156                 [AC_MSG_RESULT([no])])])
157 AS_IF([test -z "$PYTHON" -o "$python_version_ok" != True],
158         [AC_MSG_WARN([python >= 3.5 was not found, running tests will not be possible])])
160 AM_CONDITIONAL([TERMEX_TESTS],
161         [test -n "$TIC" -a -n "$PYTHON" -a "$python_version_ok" == True])
163 # CIM_RECURSIVE_EVAL(VALUE, RESULT)
164 # =================================
165 # Interpolate the VALUE in loop until it does not change, and set the result
166 # to $RESULT.
167 # WARNING: It is easy to get an infinite loop with some unsane input.
168 # Taken from http://ac-archive.sourceforge.net/adl/relpaths.html.
169 AC_DEFUN([CIM_RECURSIVE_EVAL],
170 [_lcl_receval="$1"
171 $2=`(test "$prefix" = NONE && prefix="$ac_default_prefix"
172         test "$exec_prefix" = NONE && exec_prefix="$prefix"
173         _lcl_receval_old=''
174         while test "[$]_lcl_receval_old" != "[$]_lcl_receval"; do
175                 _lcl_receval_old="[$]_lcl_receval"
176                 eval _lcl_receval="\"[$]_lcl_receval\""
177         done
178         echo "[$]_lcl_receval")`])
180 # Define locale and pkgdir directories. It would be nicer to do this in
181 # Makefile.ams by adding appropriate '-D' compiler options to respective
182 # CPPFLAGS, which is a common solution that can be seen in other projects. In
183 # that case, it is not needed to resolve the paths at the configure time using
184 # the CIM_RECURSIVE_EVAL function. However this solution unfortunately does not
185 # work correctly when values of the defines are changed, the source files that
186 # use these defines do not get correctly recompiled. To fix this, the defines
187 # have to be put into the config.h file.
188 CIM_RECURSIVE_EVAL([$localedir], [localedir_eval])
189 AC_DEFINE_UNQUOTED([LOCALEDIR], ["$localedir_eval"],
190         [Define to the locale directory.])
192 CIM_RECURSIVE_EVAL([$libdir/AC_PACKAGE_NAME], [pkglibdir_eval])
193 AC_DEFINE_UNQUOTED([PKGLIBDIR], ["$pkglibdir_eval"],
194         [Define to the pkglib directory.])
196 # Create output files.
197 AC_CONFIG_FILES([Makefile
198                  contrib/Makefile
199                  cppconsui/Makefile
200                  doc/Makefile
201                  doc/doxygen-cppconsui.conf
202                  misc/Makefile
203                  plugins/Makefile
204                  po/Makefile.in
205                  src/Makefile
206                  tests/Makefile])
207 AC_OUTPUT