Fix crash on \t with no arguments
[xy_vsfilter.git] / src / log4cplus / configure.in
blobf3a7e318f12d97c9d05bfd7e2b6b8d7d060d34ae
1 dnl Process this file with autoconf to produce a configure script.
2 dnl This version of log4cplus requires the follwing autotools versions:
3 dnl autoconf-2.67
4 dnl automake-1.11.1
5 dnl libtool-2.2.10
7 AC_INIT([log4cplus],[1.0.4])
8 AC_CANONICAL_TARGET
9 AC_CONFIG_SRCDIR([src/logger.cxx])
10 AC_CONFIG_MACRO_DIR([m4])
11 AM_INIT_AUTOMAKE([1.11.1 no-define nostdinc gnu -Wall])
14 # +1 : ? : +1  == new interface that does not break old one
15 # +1 : ? : 0   == new interfac that breaks old one
16 #  ? : ? : 0   == no new interfaces, but breaks apps
17 #  ? :+1 : ?   == just some internal changes, nothing breaks but might work
18 #                 better
19 # CURRENT : REVISION : AGE
20 LT_VERSION=4:0:0
21 AC_SUBST([LT_VERSION])
23 dnl Sane locale?
25 AH_TEMPLATE([LOG4CPLUS_WORKING_LOCALE],
26   [Define for compilers/standard libraries that support more than
27    just the "C" locale.])
29 AC_ARG_WITH([working-locale],
30   [AS_HELP_STRING([--with-working-locale],
31     [Use std::locale for char->wchar_t conversion.])],
32   [],
33   [with_working_locale=no])
35 AS_IF([test "x$with_working_locale" = "xyes"],
36   [AC_DEFINE([LOG4CPLUS_WORKING_LOCALE], [1])],
37   [])
39 dnl Debugging or release build?
41 AC_ARG_ENABLE([debugging],
42   [AS_HELP_STRING([--enable-debugging],
43     [Turns off optimization and adds switches that generate debugging
44     information.])],
45   [],
46   [enable_debugging=no])
48 AH_TEMPLATE([LOG4CPLUS_DEBUGGING],
49   [Defined for --enable-debugging builds.])
51 AS_IF([test "x$enable_debugging" = "xyes"],
52   [AC_DEFINE([LOG4CPLUS_DEBUGGING])
53    LOG4CPLUS_NDEBUG=-UNDEBUG],
54   [LOG4CPLUS_NDEBUG=-DNDEBUG])
55 AC_SUBST([LOG4CPLUS_NDEBUG])
57 dnl Turn warnings on/off?
59 AC_ARG_ENABLE([warnings],
60   [AC_HELP_STRING([--enable-warnings],
61     [Use compiler warnings option, e.g. -Wall. Enabled by default.])],
62   [],
63   [enable_warnings=yes])
65 dnl first check for c/c++ compilers
66 AC_PROG_CXX
67 AC_PROG_CXXCPP
68 AC_LANG([C++])
70 AS_CASE(["$target_os"],
71   [mingw*],
72   [dnl Undefining __STRICT_ANSI__ is a workaround for MinGW
73    dnl compilation problem.  C++ <cwchar> header does not compile in
74    dnl GCC 4.4.0 because some functions like swprintf() are not
75    dnl visible.
76    CPPFLAGS="${CPPFLAGS} -U__STRICT_ANSI__"
77    CPPFLAGS="${CPPFLAGS} -DWIN32 -D_WIN32"
78    use_winsock_sockets=yes])
80 AM_CONDITIONAL([WINSOCK_SOCKETS], [test "x$use_winsock_sockets" = "xyes"])
82 dnl Libtool setup.
84 LT_PREREQ([2.2.6])
85 LT_INIT([win32-dll])
87 dnl Check for compiler specifics.
89 AC_CXX_COMPILER_VENDOR([ac_cxx_compiler_vendor])
91 AS_CASE([$ac_cxx_compiler_vendor],
92   [gnu],
93   [AS_IF([test "x$enable_warnings" = "xyes"],
94      [AX_CXXFLAGS_GCC_OPTION([-Wall])
95       AX_CXXFLAGS_GCC_OPTION([-Wextra])
96       dnl The -ansi flag removes declarations of some useful functions
97       dnl from headers.
98       dnl AX_CXXFLAGS_GCC_OPTION([-ansi])
99       AX_CXXFLAGS_GCC_OPTION([-pedantic])
100       AX_CXXFLAGS_GCC_OPTION([-Wshadow])])
102    AS_IF([test "x$enable_debugging" = "xyes"],
103      [AX_CXXFLAGS_GCC_OPTION([-g3])
104       AX_CXXFLAGS_GCC_OPTION([-fkeep-inline-functions])],
105      [AX_CXXFLAGS_GCC_OPTION([-O2])])
107    dnl The --enable-auto-import and --enable-runtime-pseudo-reloc
108    dnl options are required for log4cplus to work when compiled with
109    dnl Cygwin's GCC 4.3.x.
110    AS_CASE(["$target_os"],
111      [cygwin*|mingw*],
112      [LDFLAGS="${LDFLAGS} -Wl,--enable-auto-import"
113       LDFLAGS="${LDFLAGS} -Wl,--enable-runtime-pseudo-reloc"])],
115   [sun],
116   [AS_IF([test "x$enable_warnings" = "xyes"],
117      [AX_CXXFLAGS_SUN_OPTION([+w])])
118    AX_CXXFLAGS_SUN_OPTION([-library=stlport4])
119    AX_CXXFLAGS_SUN_OPTION([-library=Crun])])
121 AX_DECLSPEC([LOG4CPLUS_DECLSPEC])
122 AS_IF([test "x$ac_cv_declspec" = "xyes" || test "x$ac_cv__attribute__visibility" = "xyes"],
123   [AS_CASE([$ac_cxx_compiler_vendor],
124     [gnu],
125     [AS_IF([test "x$ac_cv_declspec" = "xyes" || test "x$ac_cv__attribute__visibility" = "xyes"],
126        [AX_CXXFLAGS_GCC_OPTION([-fvisibility=hidden])])])])
128 dnl Checks for libraries.
130 AC_SEARCH_LIBS([strerror], [cposix])
131 AC_SEARCH_LIBS([clock_gettime], [posix4])
132 AC_SEARCH_LIBS([nanosleep], [rt])
133 AC_SEARCH_LIBS([gethostent], [nsl])
134 AC_SEARCH_LIBS([setsockopt], [socket])
136 dnl Windows/MinGW specific.
138 AC_LANG_PUSH([C])
139 AC_HAVE_LIBRARY([kernel32])
140 AC_HAVE_LIBRARY([advapi32])
141 AC_HAVE_LIBRARY([ws2_32])
142 AC_LANG_POP([C])
144 dnl Checks for header files.
146 AC_HEADER_STDC
148 LOG4CPLUS_CHECK_HEADER([sys/types.h], [LOG4CPLUS_HAVE_SYS_TYPES_H])
149 LOG4CPLUS_CHECK_HEADER([sys/socket.h], [LOG4CPLUS_HAVE_SYS_SOCKET_H])
150 LOG4CPLUS_CHECK_HEADER([sys/time.h], [LOG4CPLUS_HAVE_SYS_TIME_H])
151 LOG4CPLUS_CHECK_HEADER([sys/timeb.h], [LOG4CPLUS_HAVE_SYS_TIMEB_H])
152 LOG4CPLUS_CHECK_HEADER([sys/stat.h], [LOG4CPLUS_HAVE_SYS_STAT_H])
153 LOG4CPLUS_CHECK_HEADER([syslog.h], [LOG4CPLUS_HAVE_SYSLOG_H])
154 LOG4CPLUS_CHECK_HEADER([netinet/in.h], [LOG4CPLUS_HAVE_NETINET_IN_H])
155 LOG4CPLUS_CHECK_HEADER([netdb.h], [LOG4CPLUS_HAVE_NETDB_H])
156 LOG4CPLUS_CHECK_HEADER([unistd.h], [LOG4CPLUS_HAVE_UNISTD_H])
157 LOG4CPLUS_CHECK_HEADER([stdio.h], [LOG4CPLUS_HAVE_STDIO_H])
158 LOG4CPLUS_CHECK_HEADER([wchar.h], [LOG4CPLUS_HAVE_WCHAR_H])
159 LOG4CPLUS_CHECK_HEADER([stdarg.h], [LOG4CPLUS_HAVE_STDARG_H])
160 LOG4CPLUS_CHECK_HEADER([time.h], [LOG4CPLUS_HAVE_TIME_H])
161 LOG4CPLUS_CHECK_HEADER([errno.h], [LOG4CPLUS_HAVE_ERRNO_H])
163 dnl Checks for library functions.
165 LOG4CPLUS_CHECK_FUNCS([gmtime_r], [LOG4CPLUS_HAVE_GMTIME_R])
166 LOG4CPLUS_CHECK_FUNCS([localtime_r], [LOG4CPLUS_HAVE_LOCALTIME_R])
167 LOG4CPLUS_CHECK_FUNCS([gettimeofday], [LOG4CPLUS_HAVE_GETTIMEOFDAY])
168 LOG4CPLUS_CHECK_FUNCS([clock_gettime], [LOG4CPLUS_HAVE_CLOCK_GETTIME])
169 LOG4CPLUS_CHECK_FUNCS([getpid], [LOG4CPLUS_HAVE_GETPID])
170 LOG4CPLUS_CHECK_FUNCS([ftime], [LOG4CPLUS_HAVE_FTIME])
171 LOG4CPLUS_CHECK_FUNCS([stat], [LOG4CPLUS_HAVE_STAT])
172 LOG4CPLUS_CHECK_FUNCS([lstat], [LOG4CPLUS_HAVE_LSTAT])
173 LOG4CPLUS_CHECK_FUNCS([htons], [LOG4CPLUS_HAVE_HTONS])
174 LOG4CPLUS_CHECK_FUNCS([ntohs], [LOG4CPLUS_HAVE_NTOHS])
175 LOG4CPLUS_CHECK_FUNCS([htonl], [LOG4CPLUS_HAVE_HTONL])
176 LOG4CPLUS_CHECK_FUNCS([ntohl], [LOG4CPLUS_HAVE_NTOHL])
178 AH_TEMPLATE([LOG4CPLUS_HAVE_ENAMETOOLONG])
179 AC_CACHE_CHECK([for ENAMETOOLONG], [ax_cv_have_enametoolong],
180   [AC_COMPILE_IFELSE(
181     [AC_LANG_PROGRAM([#include <errno.h>], [int value = ENAMETOOLONG;])],
182     [ax_cv_have_enametoolong=yes],
183     [ax_cv_have_enametoolong=no])])
184 AS_IF([test "x$ax_cv_have_enametoolong" = "xyes"],
185   [AC_DEFINE([LOG4CPLUS_HAVE_ENAMETOOLONG])])
187 AH_TEMPLATE([LOG4CPLUS_HAVE_GETADDRINFO])
188 AX_GETADDRINFO
189 AS_IF([test "x$ax_cv_have_getaddrinfo" = "xyes"],
190   [AC_DEFINE([LOG4CPLUS_HAVE_GETADDRINFO])])
192 AH_TEMPLATE([LOG4CPLUS_HAVE_GETHOSTBYNAME_R])
193 AX_GETHOSTBYNAME_R
194 AS_IF([test "x$ax_cv_have_gethostbyname_r" = "xyes"],
195   [AC_DEFINE([LOG4CPLUS_HAVE_GETHOSTBYNAME_R])])
197 dnl Check for the existance of type socklen_t.
198 TYPE_SOCKLEN_T
201 dnl Check for single-threaded compilation
203 AH_TEMPLATE([LOG4CPLUS_USE_PTHREADS])
205 AC_ARG_ENABLE([threads],
206   [AS_HELP_STRING([--enable-threads=yes/no],
207     [Use this option to create a singled-threaded version of this library])],
208   [AS_CASE(["${enableval}"],
209     [yes], [],
210     [no], [],
211     [AC_MSG_ERROR([bad value ${enableval} for --enable-threads])])],
212   [enable_threads=yes])
214 AS_IF([test x$enable_threads = xyes],
215   [AC_MSG_NOTICE([Creating a multi-threaded library.])
217    CPPFLAGS="$CPPFLAGS -D_REENTRANT"
219    AS_CASE(["$target_os"],
220      [mingw*], [],
221      [ACX_PTHREAD([],
222        [AC_MSG_ERROR([Requested threads support but no threads were found.])])])
224    CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
225    CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
226    LIBS="$PTHREAD_LIBS $LIBS"],
228   [AC_MSG_NOTICE([Creating a single-threaded library])
229    AC_DEFINE([LOG4CPLUS_SINGLE_THREADED], [1],
230      [Define if this is a single-threaded library.])])
232 AM_CONDITIONAL([MULTI_THREADED], [test x$enable_threads = xyes])
234 AH_TOP([#ifndef LOG4CPLUS_CONFIG_H])
235 AH_TOP([#define LOG4CPLUS_CONFIG_H])
236 AH_BOTTOM([#endif // LOG4CPLUS_CONFIG_H])
238 AC_CONFIG_HEADERS([include/log4cplus/config.h])
239 AC_CONFIG_HEADERS([include/log4cplus/config/defines.hxx])
240 AC_CONFIG_FILES([Makefile
241            include/Makefile
242            src/Makefile
243            loggingserver/Makefile
244            tests/Makefile
245            tests/appender_test/Makefile
246            tests/configandwatch_test/Makefile
247            tests/customloglevel_test/Makefile
248            tests/fileappender_test/Makefile
249            tests/filter_test/Makefile
250            tests/hierarchy_test/Makefile
251            tests/loglog_test/Makefile
252            tests/ndc_test/Makefile
253            tests/ostream_test/Makefile
254            tests/patternlayout_test/Makefile
255            tests/performance_test/Makefile
256            tests/priority_test/Makefile
257            tests/propertyconfig_test/Makefile
258            tests/socket_test/Makefile
259            tests/thread_test/Makefile
260            tests/timeformat_test/Makefile])
261 AC_OUTPUT