1 dnl Copyright (C) 2013 Simon Ruderich
3 dnl This program is free software: you can redistribute it and/or modify
4 dnl it under the terms of the GNU General Public License as published by
5 dnl the Free Software Foundation, either version 3 of the License, or
6 dnl (at your option) any later version.
8 dnl This program is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 dnl GNU General Public License for more details.
13 dnl You should have received a copy of the GNU General Public License
14 dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
18 AC_INIT([coloredstderr],[0.1],[simon@ruderich.org])
20 AC_CONFIG_AUX_DIR([build-aux])
21 AC_CONFIG_MACRO_DIR([m4])
22 AC_CONFIG_HEADERS([config.h])
23 AC_CONFIG_SRCDIR([src/coloredstderr.c])
26 AM_INIT_AUTOMAKE([foreign -Wall -Werror])
28 LT_INIT([disable-static])
31 dnl Used by test suite.
35 if test "x$GCC" = xyes; then
36 CFLAGS="-Wall -Wextra -Wconversion $CFLAGS"
39 AC_CHECK_HEADERS([error.h])
40 AC_CHECK_HEADERS([fcntl.h],
41 [],[AC_MSG_ERROR([header is required])])
51 AC_CHECK_FUNCS([memmove setenv],
52 [],[AC_MSG_ERROR([function is required])])
53 AC_CHECK_FUNCS([execvpe])
55 dnl Thanks to gperftools' configure.ac (https://code.google.com/p/gperftools).
56 AC_MSG_CHECKING([for __builtin_expect])
57 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[return __builtin_expect(main != 0, 1)])],
58 [AC_DEFINE([HAVE___BUILTIN_EXPECT], 1,
59 [Define to 1 if the compiler supports __builtin_expect().])
60 AC_MSG_RESULT([yes])],
61 [AC_MSG_RESULT([no])])
63 AC_SEARCH_LIBS([dlsym], [dl], [], [AC_MSG_ERROR([dlsym() is required])])
65 AC_ARG_ENABLE([warnings],
66 [AS_HELP_STRING([--enable-warnings],[enable warning output])],
67 [if test "x$enableval" = xyes; then
68 AC_DEFINE([WARNING], 1, [Define to 1 enable warning output.])
70 AC_ARG_ENABLE([debug],
71 [AS_HELP_STRING([--enable-debug],[enable debug output])],
72 [if test "x$enableval" = xyes; then
73 AC_DEFINE([DEBUG], 1, [Define to 1 enable debug output.])
74 dnl DEBUG implies WARNING
75 AC_DEFINE([WARNING], 1)
78 dnl Used in tests/Makefile.am to build the test only if error() is available.
79 AM_CONDITIONAL([HAVE_ERROR_H],[test "x$ac_cv_header_error_h" = xyes])
80 AM_CONDITIONAL([HAVE_VFORK],[test "x$ac_cv_func_vfork_works" = xyes])
82 AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile])