1 dnl Copyright (C) 2009 Sun Microsystems
2 dnl This file is free software; Sun Microsystems
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.80])
9 AC_DEFUN([PANDORA_FORCE_DEPEND_TRACKING],[
10 dnl Force dependency tracking on for Sun Studio builds
11 AS_IF([test "x${enable_dependency_tracking}" = "x"],[
12 enable_dependency_tracking=yes
16 dnl The standard setup for how we build Pandora projects
17 AC_DEFUN([PANDORA_CANONICAL_TARGET],[
18 AC_REQUIRE([PANDORA_FORCE_DEPEND_TRACKING])
19 ifdef([m4_define],,[define([m4_define], defn([define]))])
20 ifdef([m4_undefine],,[define([m4_undefine], defn([undefine]))])
21 m4_define([PCT_ALL_ARGS],[$*])
22 m4_define([PCT_USE_GNULIB],[no])
23 m4_define([PCT_REQUIRE_CXX],[no])
24 m4_define([PCT_IGNORE_SHARED_PTR],[no])
25 m4_define([PCT_FORCE_GCC42],[no])
26 m4_define([PCT_SRC_IN_SRC],[no])
27 m4_define([PCT_VERSION_FROM_VC],[no])
28 m4_define([PCT_USE_VISIBILITY],[yes])
29 m4_foreach([pct_arg],[$*],[
32 m4_undefine([PCT_USE_GNULIB])
33 m4_define([PCT_USE_GNULIB],[yes])
36 m4_undefine([PCT_REQUIRE_CXX])
37 m4_define([PCT_REQUIRE_CXX],[yes])
39 [ignore-shared-ptr], [
40 m4_undefine([PCT_IGNORE_SHARED_PTR])
41 m4_define([PCT_IGNORE_SHARED_PTR],[yes])
44 m4_undefine([PCT_FORCE_GCC42])
45 m4_define([PCT_FORCE_GCC42],[yes])
48 m4_undefine([PCT_USE_VISIBILITY])
49 m4_define([PCT_USE_VISIBILITY],[no])
52 m4_undefine([PCT_SRC_IN_SRC])
53 m4_define([PCT_SRC_IN_SRC],[yes])
56 m4_undefine([PCT_VERSION_FROM_VC])
57 m4_define([PCT_VERSION_FROM_VC],[yes])
61 # We need to prevent canonical target
62 # from injecting -O2 into CFLAGS - but we won't modify anything if we have
63 # set CFLAGS on the command line, since that should take ultimate precedence
64 AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"],
66 AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
71 AM_INIT_AUTOMAKE(-Wall -Werror nostdinc subdir-objects foreign)
72 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
74 m4_if(PCT_USE_GNULIB,yes,[ gl_EARLY ])
76 AC_REQUIRE([AC_PROG_CC])
77 AC_REQUIRE([PANDORA_MAC_GCC42])
78 AC_REQUIRE([PANDORA_64BIT])
80 m4_if(PCT_VERSION_FROM_VC,yes,[
85 dnl Once we can use a modern autoconf, we can use this
87 AC_REQUIRE([AC_PROG_CXX])
92 m4_if(PCT_FORCE_GCC42, [yes], [
93 AS_IF([test "$GCC" = "yes"], PANDORA_ENSURE_GCC_VERSION)
100 AS_IF([test "$lt_cv_prog_gnu_ld" = "yes"],[
101 ${LD} --help | grep default-symver >/dev/null 2>&1
102 AS_IF([test $? -eq 0],[
103 AM_LDFLAGS="${AM_LDFLAGS} -Wl,--default-symver"
107 dnl autoconf doesn't automatically provide a fail-if-no-C++ macro
108 dnl so we check c++98 features and fail if we don't have them, mainly
110 PANDORA_CHECK_CXX_STANDARD
111 m4_if(PCT_REQUIRE_CXX, [yes], [
112 AS_IF([test "$ac_cv_cxx_stdcxx_98" = "no"],[
113 AC_MSG_ERROR([No working C++ Compiler has been found. ${PACKAGE} requires a C++ compiler that can handle C++98])
119 m4_if(PCT_IGNORE_SHARED_PTR, [no], [
120 AS_IF([test "$ac_cv_shared_ptr_namespace" = "missing"],[
121 AC_MSG_WARN([a usable shared_ptr implementation was not found. Let someone know what your platform is.])
125 m4_if(PCT_USE_GNULIB, [yes], [
127 AC_CONFIG_LIBOBJ_DIR([gnulib])
130 PANDORA_CHECK_C_VERSION
131 PANDORA_CHECK_CXX_VERSION
143 # off_t is not a builtin type
144 AC_CHECK_SIZEOF(off_t, 4)
145 AS_IF([test "$ac_cv_sizeof_off_t" -eq 0],[
146 AC_MSG_ERROR("${PACKAGE} needs an off_t type.")
149 AC_CHECK_SIZEOF(size_t)
150 AS_IF([test "$ac_cv_sizeof_size_t" -eq 0],[
151 AC_MSG_ERROR("${PACKAGE} needs an size_t type.")
154 AC_DEFINE_UNQUOTED([SIZEOF_SIZE_T],[$ac_cv_sizeof_size_t],[Size of size_t as computed by sizeof()])
155 AC_CHECK_SIZEOF(long long)
156 AC_DEFINE_UNQUOTED([SIZEOF_LONG_LONG],[$ac_cv_sizeof_long_long],[Size of long long as computed by sizeof()])
157 AC_CACHE_CHECK([if time_t is unsigned], [ac_cv_time_t_unsigned],[
158 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
163 int array[(((time_t)-1) > 0) ? 1 : -1];
166 ac_cv_time_t_unsigned=yes
168 ac_cv_time_t_unsigned=no
171 AS_IF([test "$ac_cv_time_t_unsigned" = "yes"],[
172 AC_DEFINE([TIME_T_UNSIGNED], 1, [Define to 1 if time_t is unsigned])
175 dnl AC_FUNC_ALLOCA would test for stack direction if we didn't have a working
176 dnl alloca - but we need to know it anyway for check_stack_overrun.
177 PANDORA_STACK_DIRECTION
181 AC_CHECK_LIB(m, floor, [], AC_CHECK_LIB(m, __infinity))
186 AC_CHECK_FUNC(setsockopt, [], [AC_CHECK_LIB(socket, setsockopt)])
187 AC_CHECK_FUNC(bind, [], [AC_CHECK_LIB(bind, bind)])
194 # Test whether madvise() is declared in C++ code -- it is not on some
195 # systems, such as Solaris
196 AC_CHECK_DECLS([madvise], [], [], [AC_INCLUDES_DEFAULT[
198 #include <sys/types.h>
199 #include <sys/mman.h>
204 PANDORA_HAVE_GCC_ATOMICS
206 m4_if(PCT_USE_VISIBILITY,[yes],[
207 dnl We need to inject error into the cflags to test if visibility works or not
208 save_CFLAGS="${CFLAGS}"
209 CFLAGS="${CFLAGS} -Werror"
211 CFLAGS="${save_CFLAGS}"
214 PANDORA_HEADER_ASSERT
216 PANDORA_WARNINGS(PCT_ALL_ARGS)
218 PANDORA_ENABLE_DTRACE
221 PANDORA_HAVE_BETTER_MALLOC
223 AC_CHECK_PROGS([DOXYGEN], [doxygen])
224 AC_CHECK_PROGS([PERL], [perl])
226 AS_IF([test "x${gl_LIBOBJS}" != "x"],[
227 AS_IF([test "$GCC" = "yes"],[
228 AM_CPPFLAGS="-isystem \$(top_srcdir)/gnulib -isystem \$(top_builddir)/gnulib ${AM_CPPFLAGS}"
230 AM_CPPFLAGS="-I\$(top_srcdir)/gnulib -I\$(top_builddir)/gnulib ${AM_CPPFLAGS}"
233 AS_IF([test "PCT_SRC_IN_SRC" = "yes"],[
234 AM_CPPFLAGS="-I\$(top_srcdir)/src -I\$(top_builddir)/src ${AM_CPPFLAGS}"
240 AM_CPPFLAGS="-I\${top_srcdir} -I\${top_builddir} ${AM_CPPFLAGS}"
241 AM_CFLAGS="${AM_CFLAGS} ${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
242 AM_CXXFLAGS="${AM_CXXFLAGS} ${CXX_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
244 AC_SUBST([AM_CFLAGS])
245 AC_SUBST([AM_CXXFLAGS])
246 AC_SUBST([AM_CPPFLAGS])
247 AC_SUBST([AM_LDFLAGS])