1 dnl Copyright (C) 2009 Sun Microsystems, Inc.
2 dnl This file is free software; Sun Microsystems, Inc.
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
6 dnl Which version of the canonical setup we're using
7 AC_DEFUN([PANDORA_CANONICAL_VERSION],[0.175])
9 AC_DEFUN([PANDORA_BLOCK_BAD_OPTIONS],[
10 AS_IF([test "x${prefix}" = "x"],[
11 AC_MSG_ERROR([--prefix requires an argument])
15 dnl The standard setup for how we build Pandora projects
16 AC_DEFUN([PANDORA_CANONICAL_TARGET],[
17 ifdef([m4_define],,[define([m4_define], defn([define]))])
18 ifdef([m4_undefine],,[define([m4_undefine], defn([undefine]))])
19 m4_define([PCT_ALL_ARGS],[$*])
20 m4_define([PCT_REQUIRE_CXX],[no])
21 m4_define([PCT_FORCE_GCC42],[no])
22 m4_define([PCT_DONT_SUPPRESS_INCLUDE],[no])
23 m4_define([PCT_NO_VC_CHANGELOG],[no])
24 m4_define([PCT_VERSION_FROM_VC],[no])
25 m4_define([PCT_USE_VISIBILITY],[yes])
26 m4_foreach([pct_arg],[$*],[
29 m4_undefine([PCT_REQUIRE_CXX])
30 m4_define([PCT_REQUIRE_CXX],[yes])
33 m4_undefine([PCT_FORCE_GCC42])
34 m4_define([PCT_FORCE_GCC42],[yes])
37 m4_undefine([PCT_USE_VISIBILITY])
38 m4_define([PCT_USE_VISIBILITY],[no])
40 [dont-suppress-include], [
41 m4_undefine([PCT_DONT_SUPPRESS_INCLUDE])
42 m4_define([PCT_DONT_SUPPRESS_INCLUDE],[yes])
45 m4_undefine([PCT_NO_VC_CHANGELOG])
46 m4_define([PCT_NO_VC_CHANGELOG],[yes])
49 m4_undefine([PCT_VERSION_FROM_VC])
50 m4_define([PCT_VERSION_FROM_VC],[yes])
54 PANDORA_BLOCK_BAD_OPTIONS
56 # We need to prevent canonical target
57 # from injecting -O2 into CFLAGS - but we won't modify anything if we have
58 # set CFLAGS on the command line, since that should take ultimate precedence
59 AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"],
61 AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
64 AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability subdir-objects foreign tar-ustar])
66 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
68 m4_if(m4_substr(m4_esyscmd(test -d gnulib && echo 0),0,1),0,[
74 AC_REQUIRE([AC_PROG_CC])
75 m4_if(PCT_FORCE_GCC42, [yes], [
76 AC_REQUIRE([PANDORA_ENSURE_GCC_VERSION])
78 AC_REQUIRE([PANDORA_64BIT])
80 m4_if(PCT_NO_VC_CHANGELOG,yes,[
85 m4_if(PCT_VERSION_FROM_VC,yes,[
86 PANDORA_VC_INFO_HEADER
90 changequote(<<, >>)dnl
91 PANDORA_RELEASE_ID=`echo $VERSION | sed 's/[^0-9]//g'`
94 PANDORA_RELEASE_COMMENT=""
95 AC_DEFINE_UNQUOTED([PANDORA_RELEASE_VERSION],["$VERSION"],
96 [Version of the software])
98 AC_SUBST(PANDORA_RELEASE_COMMENT)
99 AC_SUBST(PANDORA_RELEASE_VERSION)
100 AC_SUBST(PANDORA_RELEASE_ID)
104 dnl Once we can use a modern autoconf, we can use this
106 AC_REQUIRE([AC_PROG_CXX])
114 dnl autoconf doesn't automatically provide a fail-if-no-C++ macro
115 dnl so we check c++98 features and fail if we don't have them, mainly
117 m4_if(PCT_REQUIRE_CXX, [yes], [
118 AS_IF([test "$ac_cv_cxx_stdcxx_98" = "no"],[
119 AC_MSG_ERROR([No working C++ Compiler has been found. ${PACKAGE} requires a C++ compiler that can handle C++98])
123 m4_if(m4_substr(m4_esyscmd(test -d gnulib && echo 0),0,1),0,[
125 AC_CONFIG_LIBOBJ_DIR([gnulib])
128 PANDORA_CHECK_C_VERSION
129 PANDORA_CHECK_CXX_VERSION
135 PANDORA_CLOCK_GETTIME
137 AC_CHECK_HEADERS(sys/socket.h)
139 # off_t is not a builtin type
140 AC_CHECK_SIZEOF(off_t, 4)
141 AS_IF([test "$ac_cv_sizeof_off_t" -eq 0],[
142 AC_MSG_ERROR("${PACKAGE} needs an off_t type.")
145 AC_CHECK_SIZEOF(size_t)
146 AS_IF([test "$ac_cv_sizeof_size_t" -eq 0],[
147 AC_MSG_ERROR("${PACKAGE} needs an size_t type.")
150 AC_DEFINE_UNQUOTED([SIZEOF_SIZE_T],[$ac_cv_sizeof_size_t],[Size of size_t as computed by sizeof()])
151 AC_CHECK_SIZEOF(long long)
152 AC_DEFINE_UNQUOTED([SIZEOF_LONG_LONG],[$ac_cv_sizeof_long_long],[Size of long long as computed by sizeof()])
153 AC_CACHE_CHECK([if time_t is unsigned], [ac_cv_time_t_unsigned],[
154 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
159 int array[(((time_t)-1) > 0) ? 1 : -1];
162 ac_cv_time_t_unsigned=yes
164 ac_cv_time_t_unsigned=no
167 AS_IF([test "$ac_cv_time_t_unsigned" = "yes"],[
168 AC_DEFINE([TIME_T_UNSIGNED], 1, [Define to 1 if time_t is unsigned])
171 AC_CHECK_FUNC(setsockopt, [], [AC_CHECK_LIB(socket, setsockopt)])
172 AC_CHECK_FUNC(bind, [], [AC_CHECK_LIB(bind, bind)])
178 PANDORA_HAVE_GCC_ATOMICS
180 PANDORA_HEADER_ASSERT
182 PANDORA_WARNINGS(PCT_ALL_ARGS)
184 PANDORA_ENABLE_DTRACE
187 PANDORA_HAVE_BETTER_MALLOC
189 AC_CHECK_PROGS([PERL], [perl])
190 AC_CHECK_PROGS([DPKG_GENSYMBOLS], [dpkg-gensymbols], [:])
191 AC_CHECK_PROGS([LCOV], [lcov], [echo lcov not found])
192 AC_CHECK_PROGS([LCOV_GENHTML], [genhtml], [echo genhtml not found])
194 AC_CHECK_PROGS([SPHINXBUILD], [sphinx-build], [:])
195 AS_IF([test "x${SPHINXBUILD}" != "x:"],[
196 AC_CACHE_CHECK([if sphinx is new enough],[ac_cv_recent_sphinx],[
198 ${SPHINXBUILD} -Q -C -b man -d conftest.d . . >/dev/null 2>&1
199 AS_IF([test $? -eq 0],[ac_cv_recent_sphinx=yes],
200 [ac_cv_recent_sphinx=no])
205 AM_CONDITIONAL(HAVE_DPKG_GENSYMBOLS,[test "x${DPKG_GENSYMBOLS}" != "x:"])
206 AM_CONDITIONAL(HAVE_SPHINX,[test "x${SPHINXBUILD}" != "x:"])
207 AM_CONDITIONAL(HAVE_RECENT_SPHINX,[test "x${ac_cv_recent_sphinx}" = "xyes"])
209 AS_IF([test "x${gl_LIBOBJS}" != "x"],[
210 AS_IF([test "$GCC" = "yes"],[
211 AM_CPPFLAGS="-isystem \${top_srcdir}/gnulib -isystem \${top_builddir}/gnulib ${AM_CPPFLAGS}"
213 AM_CPPFLAGS="-I\${top_srcdir}/gnulib -I\${top_builddir}/gnulib ${AM_CPPFLAGS}"
216 m4_if(m4_substr(m4_esyscmd(test -d src && echo 0),0,1),0,[
217 AM_CPPFLAGS="-I\$(top_srcdir)/src -I\$(top_builddir)/src ${AM_CPPFLAGS}"
219 AM_CPPFLAGS="-I\$(top_srcdir) -I\$(top_builddir) ${AM_CPPFLAGS}"
224 AM_CFLAGS="-std=c99 ${AM_CFLAGS} ${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
225 AM_CXXFLAGS="${AM_CXXFLAGS} ${CXX_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
227 AC_SUBST([AM_CFLAGS])
228 AC_SUBST([AM_CXXFLAGS])
229 AC_SUBST([AM_CPPFLAGS])
230 AC_SUBST([AM_LDFLAGS])