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