Added support for autoconf 2.59.
[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.1])
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_foreach([pct_arg],$*,[
26 m4_case(pct_arg,
27 [use-gnulib], [
28 m4_undefine([PCT_USE_GNULIB])
29 m4_define([PCT_USE_GNULIB],[yes])
30 ],
31 [require-cxx], [
32 m4_undefine([PCT_REQUIRE_CXX])
33 m4_define([PCT_REQUIRE_CXX],[yes])
34 ],
35 [ignore-shared-ptr], [
36 m4_undefine([PCT_IGNORE_SHARED_PTR])
37 m4_define([PCT_IGNORE_SHARED_PTR],[yes])
38 ])
39 ])
40
41 # We need to prevent canonical target
42 # from injecting -O2 into CFLAGS - but we won't modify anything if we have
43 # set CFLAGS on the command line, since that should take ultimate precedence
44 AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"],
45 [CFLAGS=""])
46 AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
47 [CXXFLAGS=""])
48
49 AC_CANONICAL_TARGET
50
51 AM_INIT_AUTOMAKE(-Wall -Werror nostdinc subdir-objects)
52
53 m4_if(PCT_USE_GNULIB,yes,[ gl_EARLY ])
54
55 AC_REQUIRE([AC_PROG_CC])
56
57 dnl Once we can use a modern autoconf, we can use this
58 dnl AC_PROG_CC_C99
59 AC_PROG_CXX
60 AC_PROG_CPP
61 AM_PROG_CC_C_O
62
63 gl_USE_SYSTEM_EXTENSIONS
64
65
66 PANDORA_LIBTOOL
67
68 dnl autoconf doesn't automatically provide a fail-if-no-C++ macro
69 dnl so we check c++98 features and fail if we don't have them, mainly
70 dnl for that reason
71 PANDORA_CHECK_CXX_STANDARD
72 m4_if(PCT_REQUIRE_CXX, [yes], [
73 AS_IF([test "$ac_cv_cxx_stdcxx_98" = "no"],[
74 AC_MSG_ERROR([No working C++ Compiler has been found. ${PACKAGE} requires a C++ compiler that can handle C++98])
75 ])
76 ])
77
78 PANDORA_SHARED_PTR
79 m4_if(PCT_IGNORE_SHARED_PTR, [no], [
80 AS_IF([test "$ac_cv_shared_ptr_namespace" = "missing"],[
81 AC_MSG_WARN([a usable shared_ptr implementation was not found. Let someone know what your platform is.])
82 ])
83 ])
84
85 m4_if(PCT_USE_GNULIB, [yes], [gl_INIT])
86
87 AC_C_BIGENDIAN
88 AC_C_CONST
89 AC_C_INLINE
90 AC_C_VOLATILE
91
92 AC_HEADER_TIME
93 AC_TYPE_SIZE_T
94 AC_FUNC_MALLOC
95 AC_FUNC_REALLOC
96
97
98 AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
99
100 AC_SYS_LARGEFILE
101
102 AS_IF([test "$GCC" = "yes"], PANDORA_ENSURE_GCC_VERSION)
103
104 PANDORA_CHECK_C_VERSION
105 PANDORA_CHECK_CXX_VERSION
106
107 PANDORA_OPTIMIZE
108 PANDORA_64BIT
109 PANDORA_WARNINGS(PCT_ALL_ARGS)
110
111 gl_VISIBILITY
112
113 PANDORA_ENABLE_DTRACE
114 PANDORA_HEADER_ASSERT
115
116 AC_CHECK_PROGS([DOXYGEN], [doxygen])
117 AC_CHECK_PROGS([PERL], [perl])
118
119 AS_IF([test "x${gl_LIBOBJS}" != "x"],[
120 AS_IF([test "$GCC" = "yes"],[
121 AM_CPPFLAGS="-isystem \$(top_srcdir)/gnulib -isystem \$(top_builddir)/gnulib ${AM_CPPFLAGS}"
122 ],[
123 AM_CPPFLAGS="-I\$(top_srcdir)/gnulib -I\$(top_builddir)/gnulib ${AM_CPPFLAGS}"
124 ])
125 ])
126
127 AM_CPPFLAGS="-I\${top_srcdir} -I\${top_builddir} ${AM_CPPFLAGS}"
128 AM_CFLAGS="${AM_CFLAGS} ${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
129 AM_CXXFLAGS="${AM_CXXFLAGS} ${CXX_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
130
131 AC_SUBST([AM_CFLAGS])
132 AC_SUBST([AM_CXXFLAGS])
133 AC_SUBST([AM_CPPFLAGS])
134
135 ])