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([fcntl.h error.h])
49 AC_CHECK_FUNCS([memmove setenv],
50 [],[AC_MSG_ERROR([function is required])])
52 dnl Thanks to gperftools' configure.ac (https://code.google.com/p/gperftools).
53 AC_MSG_CHECKING([for __builtin_expect])
54 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[return __builtin_expect(main != 0, 1)])],
55 [AC_DEFINE([HAVE___BUILTIN_EXPECT], 1,
56 [Define to 1 if the compiler supports __builtin_expect().])
57 AC_MSG_RESULT([yes])],
58 [AC_MSG_RESULT([no])])
60 AC_SEARCH_LIBS([dlsym], [dl], [], [AC_MSG_ERROR([dlsym() is required])])
62 AC_ARG_ENABLE([warnings],
63 [AS_HELP_STRING([--enable-warnings],[enable warning output])],
64 [if test "x$enableval" = xyes; then
65 AC_DEFINE([WARNING], 1, [Define to 1 enable warning output.])
67 AC_ARG_ENABLE([debug],
68 [AS_HELP_STRING([--enable-debug],[enable debug output])],
69 [if test "x$enableval" = xyes; then
70 AC_DEFINE([DEBUG], 1, [Define to 1 enable debug output.])
71 dnl DEBUG implies WARNING
72 AC_DEFINE([WARNING], 1)
75 dnl Used in tests/Makefile.am to build the test only if error() is available.
76 AM_CONDITIONAL([HAVE_ERROR_H],[test "x$ac_cv_header_error_h" = xyes])
77 AM_CONDITIONAL([HAVE_VFORK],[test "x$ac_cv_func_vfork_works" = xyes])
79 AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile])