MErge
[m6w6/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_FORCE_DEPEND_TRACKING],[
10 AC_ARG_ENABLE([fat-binaries],
11 [AS_HELP_STRING([--enable-fat-binaries],
12 [Enable fat binary support on OSX @<:@default=off@:>@])],
13 [ac_enable_fat_binaries="$enableval"],
14 [ac_enable_fat_binaries="no"])
15
16 dnl Force dependency tracking on for Sun Studio builds
17 AS_IF([test "x${enable_dependency_tracking}" = "x"],[
18 enable_dependency_tracking=yes
19 ])
20 dnl If we're building OSX Fat Binaries, we have to turn off -M options
21 AS_IF([test "x${ac_enable_fat_binaries}" = "xyes"],[
22 enable_dependency_tracking=no
23 ])
24 ])
25
26 AC_DEFUN([PANDORA_BLOCK_BAD_OPTIONS],[
27 AS_IF([test "x${prefix}" = "x"],[
28 AC_MSG_ERROR([--prefix requires an argument])
29 ])
30 ])
31
32 dnl The standard setup for how we build Pandora projects
33 AC_DEFUN([PANDORA_CANONICAL_TARGET],[
34 AC_REQUIRE([PANDORA_FORCE_DEPEND_TRACKING])
35 ifdef([m4_define],,[define([m4_define], defn([define]))])
36 ifdef([m4_undefine],,[define([m4_undefine], defn([undefine]))])
37 m4_define([PCT_ALL_ARGS],[$*])
38 m4_define([PCT_REQUIRE_CXX],[no])
39 m4_define([PCT_FORCE_GCC42],[no])
40 m4_define([PCT_DONT_SUPPRESS_INCLUDE],[no])
41 m4_define([PCT_NO_VC_CHANGELOG],[no])
42 m4_define([PCT_VERSION_FROM_VC],[no])
43 m4_define([PCT_USE_VISIBILITY],[yes])
44 m4_foreach([pct_arg],[$*],[
45 m4_case(pct_arg,
46 [require-cxx], [
47 m4_undefine([PCT_REQUIRE_CXX])
48 m4_define([PCT_REQUIRE_CXX],[yes])
49 ],
50 [force-gcc42], [
51 m4_undefine([PCT_FORCE_GCC42])
52 m4_define([PCT_FORCE_GCC42],[yes])
53 ],
54 [skip-visibility], [
55 m4_undefine([PCT_USE_VISIBILITY])
56 m4_define([PCT_USE_VISIBILITY],[no])
57 ],
58 [dont-suppress-include], [
59 m4_undefine([PCT_DONT_SUPPRESS_INCLUDE])
60 m4_define([PCT_DONT_SUPPRESS_INCLUDE],[yes])
61 ],
62 [no-vc-changelog], [
63 m4_undefine([PCT_NO_VC_CHANGELOG])
64 m4_define([PCT_NO_VC_CHANGELOG],[yes])
65 ],
66 [version-from-vc], [
67 m4_undefine([PCT_VERSION_FROM_VC])
68 m4_define([PCT_VERSION_FROM_VC],[yes])
69 ])
70 ])
71
72 PANDORA_BLOCK_BAD_OPTIONS
73
74 # We need to prevent canonical target
75 # from injecting -O2 into CFLAGS - but we won't modify anything if we have
76 # set CFLAGS on the command line, since that should take ultimate precedence
77 AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"],
78 [CFLAGS=""])
79 AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
80 [CXXFLAGS=""])
81
82 AM_INIT_AUTOMAKE(-Wall -Werror -Wno-portability subdir-objects foreign tar-ustar)
83
84 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
85
86 m4_if(m4_substr(m4_esyscmd(test -d gnulib && echo 0),0,1),0,[
87 gl_EARLY
88 ],[
89 PANDORA_EXTENSIONS
90 ])
91
92 AC_REQUIRE([AC_PROG_CC])
93 m4_if(PCT_FORCE_GCC42, [yes], [
94 AC_REQUIRE([PANDORA_ENSURE_GCC_VERSION])
95 ])
96 AC_REQUIRE([PANDORA_64BIT])
97
98 m4_if(PCT_NO_VC_CHANGELOG,yes,[
99 vc_changelog=no
100 ],[
101 vc_changelog=yes
102 ])
103 m4_if(PCT_VERSION_FROM_VC,yes,[
104 PANDORA_VC_INFO_HEADER
105 ],[
106 PANDORA_TEST_VC_DIR
107
108 changequote(<<, >>)dnl
109 PANDORA_RELEASE_ID=`echo $VERSION | sed 's/[^0-9]//g'`
110 changequote([, ])dnl
111
112 PANDORA_RELEASE_COMMENT=""
113 AC_DEFINE_UNQUOTED([PANDORA_RELEASE_VERSION],["$VERSION"],
114 [Version of the software])
115
116 AC_SUBST(PANDORA_RELEASE_COMMENT)
117 AC_SUBST(PANDORA_RELEASE_VERSION)
118 AC_SUBST(PANDORA_RELEASE_ID)
119 ])
120 PANDORA_VERSION
121
122 dnl Once we can use a modern autoconf, we can use this
123 dnl AC_PROG_CC_C99
124 AC_REQUIRE([AC_PROG_CXX])
125 PANDORA_EXTENSIONS
126 AM_PROG_CC_C_O
127
128
129
130 PANDORA_PLATFORM
131
132 dnl autoconf doesn't automatically provide a fail-if-no-C++ macro
133 dnl so we check c++98 features and fail if we don't have them, mainly
134 dnl for that reason
135 PANDORA_CHECK_CXX_STANDARD
136 m4_if(PCT_REQUIRE_CXX, [yes], [
137 AS_IF([test "$ac_cv_cxx_stdcxx_98" = "no"],[
138 AC_MSG_ERROR([No working C++ Compiler has been found. ${PACKAGE} requires a C++ compiler that can handle C++98])
139 ])
140 ])
141 PANDORA_CXX_CSTDINT
142 PANDORA_CXX_CINTTYPES
143
144 m4_if(m4_substr(m4_esyscmd(test -d gnulib && echo 0),0,1),0,[
145 gl_INIT
146 AC_CONFIG_LIBOBJ_DIR([gnulib])
147 ])
148
149 PANDORA_CHECK_C_VERSION
150 PANDORA_CHECK_CXX_VERSION
151
152 AC_C_BIGENDIAN
153 AC_C_CONST
154 AC_C_INLINE
155 AC_C_VOLATILE
156 AC_C_RESTRICT
157
158 AC_HEADER_TIME
159 AC_STRUCT_TM
160 AC_TYPE_SIZE_T
161 AC_SYS_LARGEFILE
162 PANDORA_CLOCK_GETTIME
163
164 AC_CHECK_HEADERS(sys/socket.h)
165
166 # off_t is not a builtin type
167 AC_CHECK_SIZEOF(off_t, 4)
168 AS_IF([test "$ac_cv_sizeof_off_t" -eq 0],[
169 AC_MSG_ERROR("${PACKAGE} needs an off_t type.")
170 ])
171
172 AC_CHECK_SIZEOF(size_t)
173 AS_IF([test "$ac_cv_sizeof_size_t" -eq 0],[
174 AC_MSG_ERROR("${PACKAGE} needs an size_t type.")
175 ])
176
177 AC_DEFINE_UNQUOTED([SIZEOF_SIZE_T],[$ac_cv_sizeof_size_t],[Size of size_t as computed by sizeof()])
178 AC_CHECK_SIZEOF(long long)
179 AC_DEFINE_UNQUOTED([SIZEOF_LONG_LONG],[$ac_cv_sizeof_long_long],[Size of long long as computed by sizeof()])
180 AC_CACHE_CHECK([if time_t is unsigned], [ac_cv_time_t_unsigned],[
181 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
182 [[
183 #include <time.h>
184 ]],
185 [[
186 int array[(((time_t)-1) > 0) ? 1 : -1];
187 ]])
188 ],[
189 ac_cv_time_t_unsigned=yes
190 ],[
191 ac_cv_time_t_unsigned=no
192 ])
193 ])
194 AS_IF([test "$ac_cv_time_t_unsigned" = "yes"],[
195 AC_DEFINE([TIME_T_UNSIGNED], 1, [Define to 1 if time_t is unsigned])
196 ])
197
198 AC_CACHE_CHECK([if system defines RUSAGE_THREAD], [ac_cv_rusage_thread],[
199 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
200 [[
201 #include <sys/time.h>
202 #include <sys/resource.h>
203 ]],[[
204 int x= RUSAGE_THREAD;
205 ]])
206 ],[
207 ac_cv_rusage_thread=yes
208 ],[
209 ac_cv_rusage_thread=no
210 ])
211 ])
212 AS_IF([test "$ac_cv_rusage_thread" = "no"],[
213 AC_DEFINE([RUSAGE_THREAD], [RUSAGE_SELF],
214 [Define if system doesn't define])
215 ])
216
217 AC_CHECK_FUNC(setsockopt, [], [AC_CHECK_LIB(socket, setsockopt)])
218 AC_CHECK_FUNC(bind, [], [AC_CHECK_LIB(bind, bind)])
219
220
221
222 PANDORA_OPTIMIZE
223
224 AC_LANG_PUSH(C++)
225 # Test whether madvise() is declared in C++ code -- it is not on some
226 # systems, such as Solaris
227 AC_CHECK_DECLS([madvise], [], [], [AC_INCLUDES_DEFAULT[
228 #if HAVE_SYS_MMAN_H
229 #include <sys/types.h>
230 #include <sys/mman.h>
231 #endif
232 ]])
233 AC_LANG_POP()
234
235 PANDORA_HAVE_GCC_ATOMICS
236
237 PANDORA_HEADER_ASSERT
238
239 PANDORA_WARNINGS(PCT_ALL_ARGS)
240
241 PANDORA_ENABLE_DTRACE
242
243 AC_LIB_PREFIX
244 PANDORA_HAVE_BETTER_MALLOC
245 PANDORA_WITH_VALGRIND
246
247 AC_CHECK_PROGS([DOXYGEN], [doxygen])
248 AC_CHECK_PROGS([PERL], [perl])
249 AC_CHECK_PROGS([DPKG_GENSYMBOLS], [dpkg-gensymbols], [:])
250 AC_CHECK_PROGS([LCOV], [lcov], [echo lcov not found])
251 AC_CHECK_PROGS([LCOV_GENHTML], [genhtml], [echo genhtml not found])
252
253 AC_CHECK_PROGS([SPHINXBUILD], [sphinx-build], [:])
254 AS_IF([test "x${SPHINXBUILD}" != "x:"],[
255 AC_CACHE_CHECK([if sphinx is new enough],[ac_cv_recent_sphinx],[
256
257 ${SPHINXBUILD} -Q -C -b man -d conftest.d . . >/dev/null 2>&1
258 AS_IF([test $? -eq 0],[ac_cv_recent_sphinx=yes],
259 [ac_cv_recent_sphinx=no])
260 rm -rf conftest.d
261 ])
262 ])
263
264 AM_CONDITIONAL(HAVE_DPKG_GENSYMBOLS,[test "x${DPKG_GENSYMBOLS}" != "x:"])
265 AM_CONDITIONAL(HAVE_SPHINX,[test "x${SPHINXBUILD}" != "x:"])
266 AM_CONDITIONAL(HAVE_RECENT_SPHINX,[test "x${ac_cv_recent_sphinx}" = "xyes"])
267
268 m4_if(m4_substr(m4_esyscmd(test -d po && echo 0),0,1),0, [
269 AM_PO_SUBDIRS
270 IT_PROG_INTLTOOL([0.35],[no-xml])
271
272 GETTEXT_PACKAGE=$PACKAGE
273 AC_CHECK_LIB(intl, libintl_gettext)
274 AC_SUBST([GETTEXT_PACKAGE])
275 AS_IF([test "x${USE_NLS}" = "xyes" -a "x${pandora_have_intltool}" = "xyes"],
276 [AC_DEFINE([ENABLE_NLS],[1],[Turn on language support])
277 AC_CONFIG_FILES([po/Makefile.in])
278 ])
279 ])
280 AM_CONDITIONAL(BUILD_PO,[test "x${USE_NLS}" = "xyes" -a "x${pandora_have_intltool}" = "xyes"])
281
282 AS_IF([test "x${gl_LIBOBJS}" != "x"],[
283 AS_IF([test "$GCC" = "yes"],[
284 AM_CPPFLAGS="-isystem \${top_srcdir}/gnulib -isystem \${top_builddir}/gnulib ${AM_CPPFLAGS}"
285 ],[
286 AM_CPPFLAGS="-I\${top_srcdir}/gnulib -I\${top_builddir}/gnulib ${AM_CPPFLAGS}"
287 ])
288 ])
289 m4_if(m4_substr(m4_esyscmd(test -d src && echo 0),0,1),0,[
290 AM_CPPFLAGS="-I\$(top_srcdir)/src -I\$(top_builddir)/src ${AM_CPPFLAGS}"
291 ],[
292 AM_CPPFLAGS="-I\$(top_srcdir) -I\$(top_builddir) ${AM_CPPFLAGS}"
293 ])
294
295 PANDORA_USE_PIPE
296
297 AM_CFLAGS="-std=c99 ${AM_CFLAGS} ${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
298 AM_CXXFLAGS="${AM_CXXFLAGS} ${CXX_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
299
300 AC_SUBST([AM_CFLAGS])
301 AC_SUBST([AM_CXXFLAGS])
302 AC_SUBST([AM_CPPFLAGS])
303 AC_SUBST([AM_LDFLAGS])
304
305 ])