pandora-build v0.75. Also fixed visibility which had accidentally been turned off.
[awesomized/libmemcached] / m4 / pandora_canonical.m4
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.
5
6 dnl Which version of the canonical setup we're using
7 AC_DEFUN([PANDORA_CANONICAL_VERSION],[0.75])
8
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
13 ])
14 ])
15
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_foreach([pct_arg],[$*],[
28 m4_case(pct_arg,
29 [use-gnulib], [
30 m4_undefine([PCT_USE_GNULIB])
31 m4_define([PCT_USE_GNULIB],[yes])
32 ],
33 [require-cxx], [
34 m4_undefine([PCT_REQUIRE_CXX])
35 m4_define([PCT_REQUIRE_CXX],[yes])
36 ],
37 [ignore-shared-ptr], [
38 m4_undefine([PCT_IGNORE_SHARED_PTR])
39 m4_define([PCT_IGNORE_SHARED_PTR],[yes])
40 ],
41 [force-gcc42], [
42 m4_undefine([PCT_FORCE_GCC42])
43 m4_define([PCT_FORCE_GCC42],[yes])
44 ],
45 [src-in-src], [
46 m4_undefine([PCT_SRC_IN_SRC])
47 m4_define([PCT_SRC_IN_SRC],[yes])
48 ])
49 ])
50
51 # We need to prevent canonical target
52 # from injecting -O2 into CFLAGS - but we won't modify anything if we have
53 # set CFLAGS on the command line, since that should take ultimate precedence
54 AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"],
55 [CFLAGS=""])
56 AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
57 [CXXFLAGS=""])
58
59 AC_CANONICAL_TARGET
60
61 AM_INIT_AUTOMAKE(-Wall -Werror nostdinc subdir-objects foreign)
62 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
63
64 m4_if(PCT_USE_GNULIB,yes,[ gl_EARLY ])
65
66 AC_REQUIRE([AC_PROG_CC])
67 AC_REQUIRE([PANDORA_MAC_GCC42])
68 AC_REQUIRE([PANDORA_64BIT])
69
70 dnl Once we can use a modern autoconf, we can use this
71 dnl AC_PROG_CC_C99
72 AC_REQUIRE([AC_PROG_CXX])
73 PANDORA_EXTENSIONS
74 AM_PROG_CC_C_O
75
76
77 m4_if(PCT_FORCE_GCC42, [yes], [
78 AS_IF([test "$GCC" = "yes"], PANDORA_ENSURE_GCC_VERSION)
79 ])
80
81 PANDORA_PLATFORM
82
83 PANDORA_LIBTOOL
84
85 AS_IF([test "$lt_cv_prog_gnu_ld" = "yes"],[
86 AM_LDFLAGS="${AM_LDFLAGS} -Wl,--default-symver"
87 ])
88
89 dnl autoconf doesn't automatically provide a fail-if-no-C++ macro
90 dnl so we check c++98 features and fail if we don't have them, mainly
91 dnl for that reason
92 PANDORA_CHECK_CXX_STANDARD
93 m4_if(PCT_REQUIRE_CXX, [yes], [
94 AS_IF([test "$ac_cv_cxx_stdcxx_98" = "no"],[
95 AC_MSG_ERROR([No working C++ Compiler has been found. ${PACKAGE} requires a C++ compiler that can handle C++98])
96 ])
97
98 ])
99
100 PANDORA_SHARED_PTR
101 m4_if(PCT_IGNORE_SHARED_PTR, [no], [
102 AS_IF([test "$ac_cv_shared_ptr_namespace" = "missing"],[
103 AC_MSG_WARN([a usable shared_ptr implementation was not found. Let someone know what your platform is.])
104 ])
105 ])
106
107 m4_if(PCT_USE_GNULIB, [yes], [
108 gl_INIT
109 AC_CONFIG_LIBOBJ_DIR([gnulib])
110 ])
111
112 PANDORA_CHECK_C_VERSION
113 PANDORA_CHECK_CXX_VERSION
114
115 AC_C_BIGENDIAN
116 AC_C_CONST
117 AC_C_INLINE
118 AC_C_VOLATILE
119 AC_C_RESTRICT
120
121 AC_HEADER_TIME
122 AC_TYPE_SIZE_T
123 AC_SYS_LARGEFILE
124
125 # off_t is not a builtin type
126 AC_CHECK_SIZEOF(off_t, 4)
127 AS_IF([test "$ac_cv_sizeof_off_t" -eq 0],[
128 AC_MSG_ERROR("${PACKAGE} needs an off_t type.")
129 ])
130
131 AC_CHECK_SIZEOF(size_t)
132 AS_IF([test "$ac_cv_sizeof_size_t" -eq 0],[
133 AC_MSG_ERROR("${PACKAGE} needs an size_t type.")
134 ])
135
136 AC_DEFINE_UNQUOTED([SIZEOF_SIZE_T],[$ac_cv_sizeof_size_t],[Size of size_t as computed by sizeof()])
137 AC_CHECK_SIZEOF(long long)
138 AC_DEFINE_UNQUOTED([SIZEOF_LONG_LONG],[$ac_cv_sizeof_long_long],[Size of long long as computed by sizeof()])
139 AC_CACHE_CHECK([if time_t is unsigned], [ac_cv_time_t_unsigned],[
140 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
141 [[
142 #include <time.h>
143 ]],
144 [[
145 int array[(((time_t)-1) > 0) ? 1 : -1];
146 ]])
147 ],[
148 ac_cv_time_t_unsigned=yes
149 ],[
150 ac_cv_time_t_unsigned=no
151 ])
152 ])
153 AS_IF([test "$ac_cv_time_t_unsigned" = "yes"],[
154 AC_DEFINE([TIME_T_UNSIGNED], 1, [Define to 1 if time_t is unsigned])
155 ])
156
157 dnl AC_FUNC_ALLOCA would test for stack direction if we didn't have a working
158 dnl alloca - but we need to know it anyway for check_stack_overrun.
159 PANDORA_STACK_DIRECTION
160
161 save_LIBS="${LIBS}"
162 LIBS=""
163 AC_CHECK_LIB(m, floor, [], AC_CHECK_LIB(m, __infinity))
164 LIBM="${LIBS}"
165 LIBS="${save_LIBS}"
166 AC_SUBST([LIBM])
167
168 AC_CHECK_FUNC(setsockopt, [], [AC_CHECK_LIB(socket, setsockopt)])
169 AC_CHECK_FUNC(bind, [], [AC_CHECK_LIB(bind, bind)])
170
171
172
173 PANDORA_OPTIMIZE
174
175 AC_LANG_PUSH(C++)
176 # Test whether madvise() is declared in C++ code -- it is not on some
177 # systems, such as Solaris
178 AC_CHECK_DECLS([madvise], [], [], [AC_INCLUDES_DEFAULT[
179 #if HAVE_SYS_MMAN_H
180 #include <sys/types.h>
181 #include <sys/mman.h>
182 #endif
183 ]])
184 AC_LANG_POP()
185
186 PANDORA_HAVE_GCC_ATOMICS
187
188 dnl We need to inject error into the cflags to test if visibility works or not
189 save_CFLAGS="${CFLAGS}"
190 CFLAGS="${CFLAGS} -Werror"
191 gl_VISIBILITY
192 CFLAGS="${save_CFLAGS}"
193
194 PANDORA_HEADER_ASSERT
195
196 PANDORA_WARNINGS(PCT_ALL_ARGS)
197
198 PANDORA_ENABLE_DTRACE
199
200 AC_LIB_PREFIX
201 PANDORA_HAVE_BETTER_MALLOC
202
203 AC_CHECK_PROGS([DOXYGEN], [doxygen])
204 AC_CHECK_PROGS([PERL], [perl])
205
206 AS_IF([test "x${gl_LIBOBJS}" != "x"],[
207 AS_IF([test "$GCC" = "yes"],[
208 AM_CPPFLAGS="-isystem \$(top_srcdir)/gnulib -isystem \$(top_builddir)/gnulib ${AM_CPPFLAGS}"
209 ],[
210 AM_CPPFLAGS="-I\$(top_srcdir)/gnulib -I\$(top_builddir)/gnulib ${AM_CPPFLAGS}"
211 ])
212 ])
213 AS_IF([test "PCT_SRC_IN_SRC" = "yes"],[
214 AM_CPPFLAGS="-I\$(top_srcdir)/src -I\$(top_builddir)/src ${AM_CPPFLAGS}"
215 ])
216
217 PANDORA_USE_PIPE
218
219
220 AM_CPPFLAGS="-I\${top_srcdir} -I\${top_builddir} ${AM_CPPFLAGS}"
221 AM_CFLAGS="${AM_CFLAGS} ${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
222 AM_CXXFLAGS="${AM_CXXFLAGS} ${CXX_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
223
224 AC_SUBST([AM_CFLAGS])
225 AC_SUBST([AM_CXXFLAGS])
226 AC_SUBST([AM_CPPFLAGS])
227 AC_SUBST([AM_LDFLAGS])
228
229 ])