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