]> ruderich.org/simon Gitweb - coloredstderr/coloredstderr.git/blob - configure.ac
configure.ac: warn if TLS is not available
[coloredstderr/coloredstderr.git] / configure.ac
1 dnl Copyright (C) 2013-2014  Simon Ruderich
2 dnl
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.
7 dnl
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.
12 dnl
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/>.
15
16
17 AC_PREREQ([2.69])
18 AC_INIT([coloredstderr],[0.1],[simon@ruderich.org])
19
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])
24
25 AM_PROG_AR
26 AM_INIT_AUTOMAKE([foreign -Wall -Werror])
27 LT_PREREQ([2.4])
28 LT_INIT([disable-static])
29
30 AC_PROG_CC
31 dnl Used by test suite.
32 AC_PROG_SED
33 AC_PROG_EGREP
34
35 if test "x$GCC" = xyes; then
36     CFLAGS="-Wall -Wextra -Wconversion $CFLAGS"
37 fi
38
39 AC_CHECK_HEADERS([err.h error.h])
40 AC_CHECK_HEADERS([fcntl.h],
41                  [],[AC_MSG_ERROR([header is required])])
42
43 AC_TYPE_PID_T
44 AC_TYPE_SIZE_T
45 AC_TYPE_SSIZE_T
46
47 AC_C_INLINE
48 AX_C___ATTRIBUTE__
49 AX_TLS
50
51 AC_CHECK_MEMBER([struct _IO_FILE._fileno],
52                 [AC_DEFINE([HAVE_STRUCT__IO_FILE__FILENO], 1,
53                            [Define to 1 if `_fileno' is a member of `struct _IO_FILE'.])],
54                 [],[[#include <libio.h>]]) dnl ' fix for vim syntax coloring
55
56 AC_FUNC_FORK
57 AC_CHECK_FUNCS([memmove setenv],
58                [],[AC_MSG_ERROR([function is required])])
59 AC_CHECK_FUNCS([execvpe])
60 dnl These are not in POSIX.
61 AC_CHECK_FUNCS([fwrite_unlocked fputs_unlocked fputc_unlocked])
62 dnl Internal functions in libc implementations which must be hooked.
63 AC_CHECK_FUNCS([__overflow __swbuf])
64
65 dnl Thanks to gperftools' configure.ac (https://code.google.com/p/gperftools).
66 AC_MSG_CHECKING([for __builtin_expect])
67 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[return __builtin_expect(main != 0, 1)])],
68                [AC_DEFINE([HAVE___BUILTIN_EXPECT], 1,
69                           [Define to 1 if the compiler supports __builtin_expect().])
70                 AC_MSG_RESULT([yes])],
71                [AC_MSG_RESULT([no])])
72
73 AC_SEARCH_LIBS([dlsym], [dl], [], [AC_MSG_ERROR([dlsym() is required])])
74
75 AC_ARG_ENABLE([warnings],
76               [AS_HELP_STRING([--enable-warnings],[enable warning output])],
77               [if test "x$enableval" = xyes; then
78                    AC_DEFINE([WARNING], 1, [Define to 1 enable warning output.])
79                fi])
80 AC_ARG_ENABLE([debug],
81               [AS_HELP_STRING([--enable-debug],[enable debug output])],
82               [if test "x$enableval" = xyes; then
83                    AC_DEFINE([DEBUG], 1, [Define to 1 enable debug output.])
84                    dnl DEBUG implies WARNING
85                    AC_DEFINE([WARNING], 1)
86                fi])
87
88 dnl Used in tests/Makefile.am to build the test only if function is available.
89 AM_CONDITIONAL([HAVE_ERR_H],[test "x$ac_cv_header_err_h" = xyes])
90 AM_CONDITIONAL([HAVE_ERROR_H],[test "x$ac_cv_header_error_h" = xyes])
91 AM_CONDITIONAL([HAVE_VFORK],[test "x$ac_cv_func_vfork_works" = xyes])
92
93 AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile])
94 AC_OUTPUT
95
96 if test x"$ac_cv_tls" != x"none"; then
97     AC_MSG_WARN([thread-local storage not supported by compiler, \
98 possible race condition in threaded programs])
99 fi