Updating for 1.0.2 release
[awesomized/libmemcached] / m4 / pandora_canonical.m4
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.
5
6 dnl Which version of the canonical setup we're using
7 AC_DEFUN([PANDORA_CANONICAL_VERSION],[0.175])
8
9 AC_DEFUN([PANDORA_BLOCK_BAD_OPTIONS],[
10 AS_IF([test "x${prefix}" = "x"],[
11 AC_MSG_ERROR([--prefix requires an argument])
12 ])
13 ])
14
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],[$*],[
27 m4_case(pct_arg,
28 [require-cxx], [
29 m4_undefine([PCT_REQUIRE_CXX])
30 m4_define([PCT_REQUIRE_CXX],[yes])
31 ],
32 [force-gcc42], [
33 m4_undefine([PCT_FORCE_GCC42])
34 m4_define([PCT_FORCE_GCC42],[yes])
35 ],
36 [skip-visibility], [
37 m4_undefine([PCT_USE_VISIBILITY])
38 m4_define([PCT_USE_VISIBILITY],[no])
39 ],
40 [dont-suppress-include], [
41 m4_undefine([PCT_DONT_SUPPRESS_INCLUDE])
42 m4_define([PCT_DONT_SUPPRESS_INCLUDE],[yes])
43 ],
44 [no-vc-changelog], [
45 m4_undefine([PCT_NO_VC_CHANGELOG])
46 m4_define([PCT_NO_VC_CHANGELOG],[yes])
47 ],
48 [version-from-vc], [
49 m4_undefine([PCT_VERSION_FROM_VC])
50 m4_define([PCT_VERSION_FROM_VC],[yes])
51 ])
52 ])
53
54 PANDORA_BLOCK_BAD_OPTIONS
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 AM_INIT_AUTOMAKE(-Wall -Werror -Wno-portability subdir-objects foreign tar-ustar)
65
66 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
67
68 m4_if(m4_substr(m4_esyscmd(test -d gnulib && echo 0),0,1),0,[
69 gl_EARLY
70 ],[
71 PANDORA_EXTENSIONS
72 ])
73
74 AC_REQUIRE([AC_PROG_CC])
75 m4_if(PCT_FORCE_GCC42, [yes], [
76 AC_REQUIRE([PANDORA_ENSURE_GCC_VERSION])
77 ])
78 AC_REQUIRE([PANDORA_64BIT])
79
80 m4_if(PCT_NO_VC_CHANGELOG,yes,[
81 vc_changelog=no
82 ],[
83 vc_changelog=yes
84 ])
85 m4_if(PCT_VERSION_FROM_VC,yes,[
86 PANDORA_VC_INFO_HEADER
87 ],[
88 PANDORA_TEST_VC_DIR
89
90 changequote(<<, >>)dnl
91 PANDORA_RELEASE_ID=`echo $VERSION | sed 's/[^0-9]//g'`
92 changequote([, ])dnl
93
94 PANDORA_RELEASE_COMMENT=""
95 AC_DEFINE_UNQUOTED([PANDORA_RELEASE_VERSION],["$VERSION"],
96 [Version of the software])
97
98 AC_SUBST(PANDORA_RELEASE_COMMENT)
99 AC_SUBST(PANDORA_RELEASE_VERSION)
100 AC_SUBST(PANDORA_RELEASE_ID)
101 ])
102 PANDORA_VERSION
103
104 dnl Once we can use a modern autoconf, we can use this
105 dnl AC_PROG_CC_C99
106 AC_REQUIRE([AC_PROG_CXX])
107 PANDORA_EXTENSIONS
108 AM_PROG_CC_C_O
109
110
111
112 PANDORA_PLATFORM
113
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
116 dnl for that reason
117 PANDORA_CHECK_CXX_STANDARD
118 m4_if(PCT_REQUIRE_CXX, [yes], [
119 AS_IF([test "$ac_cv_cxx_stdcxx_98" = "no"],[
120 AC_MSG_ERROR([No working C++ Compiler has been found. ${PACKAGE} requires a C++ compiler that can handle C++98])
121 ])
122 ])
123 PANDORA_CXX_CSTDINT
124 PANDORA_CXX_CINTTYPES
125
126 m4_if(m4_substr(m4_esyscmd(test -d gnulib && echo 0),0,1),0,[
127 gl_INIT
128 AC_CONFIG_LIBOBJ_DIR([gnulib])
129 ])
130
131 PANDORA_CHECK_C_VERSION
132 PANDORA_CHECK_CXX_VERSION
133
134 AC_HEADER_TIME
135 AC_STRUCT_TM
136 AC_TYPE_SIZE_T
137 AC_SYS_LARGEFILE
138 PANDORA_CLOCK_GETTIME
139
140 AC_CHECK_HEADERS(sys/socket.h)
141
142 # off_t is not a builtin type
143 AC_CHECK_SIZEOF(off_t, 4)
144 AS_IF([test "$ac_cv_sizeof_off_t" -eq 0],[
145 AC_MSG_ERROR("${PACKAGE} needs an off_t type.")
146 ])
147
148 AC_CHECK_SIZEOF(size_t)
149 AS_IF([test "$ac_cv_sizeof_size_t" -eq 0],[
150 AC_MSG_ERROR("${PACKAGE} needs an size_t type.")
151 ])
152
153 AC_DEFINE_UNQUOTED([SIZEOF_SIZE_T],[$ac_cv_sizeof_size_t],[Size of size_t as computed by sizeof()])
154 AC_CHECK_SIZEOF(long long)
155 AC_DEFINE_UNQUOTED([SIZEOF_LONG_LONG],[$ac_cv_sizeof_long_long],[Size of long long as computed by sizeof()])
156 AC_CACHE_CHECK([if time_t is unsigned], [ac_cv_time_t_unsigned],[
157 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
158 [[
159 #include <time.h>
160 ]],
161 [[
162 int array[(((time_t)-1) > 0) ? 1 : -1];
163 ]])
164 ],[
165 ac_cv_time_t_unsigned=yes
166 ],[
167 ac_cv_time_t_unsigned=no
168 ])
169 ])
170 AS_IF([test "$ac_cv_time_t_unsigned" = "yes"],[
171 AC_DEFINE([TIME_T_UNSIGNED], 1, [Define to 1 if time_t is unsigned])
172 ])
173
174 AC_CACHE_CHECK([if system defines RUSAGE_THREAD], [ac_cv_rusage_thread],[
175 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
176 [[
177 #include <sys/time.h>
178 #include <sys/resource.h>
179 ]],[[
180 int x= RUSAGE_THREAD;
181 ]])
182 ],[
183 ac_cv_rusage_thread=yes
184 ],[
185 ac_cv_rusage_thread=no
186 ])
187 ])
188 AS_IF([test "$ac_cv_rusage_thread" = "no"],[
189 AC_DEFINE([RUSAGE_THREAD], [RUSAGE_SELF],
190 [Define if system doesn't define])
191 ])
192
193 AC_CHECK_FUNC(setsockopt, [], [AC_CHECK_LIB(socket, setsockopt)])
194 AC_CHECK_FUNC(bind, [], [AC_CHECK_LIB(bind, bind)])
195
196
197
198 PANDORA_OPTIMIZE
199
200 PANDORA_HAVE_GCC_ATOMICS
201
202 PANDORA_HEADER_ASSERT
203
204 PANDORA_WARNINGS(PCT_ALL_ARGS)
205
206 PANDORA_ENABLE_DTRACE
207
208 AC_LIB_PREFIX
209 PANDORA_HAVE_BETTER_MALLOC
210
211 AC_CHECK_PROGS([PERL], [perl])
212 AC_CHECK_PROGS([DPKG_GENSYMBOLS], [dpkg-gensymbols], [:])
213 AC_CHECK_PROGS([LCOV], [lcov], [echo lcov not found])
214 AC_CHECK_PROGS([LCOV_GENHTML], [genhtml], [echo genhtml not found])
215
216 AC_CHECK_PROGS([SPHINXBUILD], [sphinx-build], [:])
217 AS_IF([test "x${SPHINXBUILD}" != "x:"],[
218 AC_CACHE_CHECK([if sphinx is new enough],[ac_cv_recent_sphinx],[
219
220 ${SPHINXBUILD} -Q -C -b man -d conftest.d . . >/dev/null 2>&1
221 AS_IF([test $? -eq 0],[ac_cv_recent_sphinx=yes],
222 [ac_cv_recent_sphinx=no])
223 rm -rf conftest.d
224 ])
225 ])
226
227 AM_CONDITIONAL(HAVE_DPKG_GENSYMBOLS,[test "x${DPKG_GENSYMBOLS}" != "x:"])
228 AM_CONDITIONAL(HAVE_SPHINX,[test "x${SPHINXBUILD}" != "x:"])
229 AM_CONDITIONAL(HAVE_RECENT_SPHINX,[test "x${ac_cv_recent_sphinx}" = "xyes"])
230
231 AS_IF([test "x${gl_LIBOBJS}" != "x"],[
232 AS_IF([test "$GCC" = "yes"],[
233 AM_CPPFLAGS="-isystem \${top_srcdir}/gnulib -isystem \${top_builddir}/gnulib ${AM_CPPFLAGS}"
234 ],[
235 AM_CPPFLAGS="-I\${top_srcdir}/gnulib -I\${top_builddir}/gnulib ${AM_CPPFLAGS}"
236 ])
237 ])
238 m4_if(m4_substr(m4_esyscmd(test -d src && echo 0),0,1),0,[
239 AM_CPPFLAGS="-I\$(top_srcdir)/src -I\$(top_builddir)/src ${AM_CPPFLAGS}"
240 ],[
241 AM_CPPFLAGS="-I\$(top_srcdir) -I\$(top_builddir) ${AM_CPPFLAGS}"
242 ])
243
244 PANDORA_USE_PIPE
245
246 AM_CFLAGS="-std=c99 ${AM_CFLAGS} ${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
247 AM_CXXFLAGS="${AM_CXXFLAGS} ${CXX_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
248
249 AC_SUBST([AM_CFLAGS])
250 AC_SUBST([AM_CXXFLAGS])
251 AC_SUBST([AM_CPPFLAGS])
252 AC_SUBST([AM_LDFLAGS])
253
254 ])