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.
6
dnl Which version of the canonical setup we're using
7
AC_DEFUN([PANDORA_CANONICAL_VERSION],[0.161])
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"])
16
dnl Force dependency tracking on for Sun Studio builds
17
AS_IF([test "x${enable_dependency_tracking}" = "x"],[
18
enable_dependency_tracking=yes
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
26
AC_DEFUN([PANDORA_BLOCK_BAD_OPTIONS],[
27
AS_IF([test "x${prefix}" = "x"],[
28
AC_MSG_ERROR([--prefix requires an argument])
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_VERSION_FROM_VC],[no])
42
m4_define([PCT_USE_VISIBILITY],[yes])
43
m4_foreach([pct_arg],[$*],[
46
m4_undefine([PCT_REQUIRE_CXX])
47
m4_define([PCT_REQUIRE_CXX],[yes])
50
m4_undefine([PCT_FORCE_GCC42])
51
m4_define([PCT_FORCE_GCC42],[yes])
54
m4_undefine([PCT_USE_VISIBILITY])
55
m4_define([PCT_USE_VISIBILITY],[no])
57
[dont-suppress-include], [
58
m4_undefine([PCT_DONT_SUPPRESS_INCLUDE])
59
m4_define([PCT_DONT_SUPPRESS_INCLUDE],[yes])
62
m4_undefine([PCT_VERSION_FROM_VC])
63
m4_define([PCT_VERSION_FROM_VC],[yes])
67
AC_CONFIG_MACRO_DIR([m4])
69
m4_if(m4_substr(m4_esyscmd(test -d src && echo 0),0,1),0,[
70
AC_CONFIG_HEADERS([src/config.h])
72
AC_CONFIG_HEADERS([config.h])
75
PANDORA_BLOCK_BAD_OPTIONS
77
# We need to prevent canonical target
78
# from injecting -O2 into CFLAGS - but we won't modify anything if we have
79
# set CFLAGS on the command line, since that should take ultimate precedence
80
AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"],
82
AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
87
m4_if(PCT_DONT_SUPRESS_INCLUDE,yes,[
88
AM_INIT_AUTOMAKE(-Wall -Werror -Wno-portability subdir-objects foreign tar-ustar)
90
AM_INIT_AUTOMAKE(-Wall -Werror -Wno-portability nostdinc subdir-objects foreign tar-ustar)
93
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
95
m4_if(m4_substr(m4_esyscmd(test -d gnulib && echo 0),0,1),0,[
101
AC_REQUIRE([AC_PROG_CC])
102
m4_if(PCT_FORCE_GCC42, [yes], [
103
AC_REQUIRE([PANDORA_ENSURE_GCC_VERSION])
105
AC_REQUIRE([PANDORA_64BIT])
107
m4_if(PCT_VERSION_FROM_VC,yes,[
112
changequote(<<, >>)dnl
113
PANDORA_RELEASE_ID=`echo $VERSION | sed 's/[^0-9]//g'`
116
PANDORA_RELEASE_COMMENT=""
117
AC_DEFINE_UNQUOTED([PANDORA_RELEASE_VERSION],["$VERSION"],
118
[Version of the software])
120
AC_SUBST(PANDORA_RELEASE_COMMENT)
121
AC_SUBST(PANDORA_RELEASE_VERSION)
122
AC_SUBST(PANDORA_RELEASE_ID)
126
dnl Once we can use a modern autoconf, we can use this
128
AC_REQUIRE([AC_PROG_CXX])
138
dnl autoconf doesn't automatically provide a fail-if-no-C++ macro
139
dnl so we check c++98 features and fail if we don't have them, mainly
141
PANDORA_CHECK_CXX_STANDARD
142
m4_if(PCT_REQUIRE_CXX, [yes], [
143
AS_IF([test "$ac_cv_cxx_stdcxx_98" = "no"],[
144
AC_MSG_ERROR([No working C++ Compiler has been found. ${PACKAGE} requires a C++ compiler that can handle C++98])
148
PANDORA_CXX_CINTTYPES
150
m4_if(m4_substr(m4_esyscmd(test -d gnulib && echo 0),0,1),0,[
152
AC_CONFIG_LIBOBJ_DIR([gnulib])
155
PANDORA_CHECK_C_VERSION
156
PANDORA_CHECK_CXX_VERSION
168
PANDORA_CLOCK_GETTIME
170
AC_CHECK_HEADERS(sys/socket.h)
172
# off_t is not a builtin type
173
AC_CHECK_SIZEOF(off_t, 4)
174
AS_IF([test "$ac_cv_sizeof_off_t" -eq 0],[
175
AC_MSG_ERROR("${PACKAGE} needs an off_t type.")
178
AC_CHECK_SIZEOF(size_t)
179
AS_IF([test "$ac_cv_sizeof_size_t" -eq 0],[
180
AC_MSG_ERROR("${PACKAGE} needs an size_t type.")
183
AC_DEFINE_UNQUOTED([SIZEOF_SIZE_T],[$ac_cv_sizeof_size_t],[Size of size_t as computed by sizeof()])
184
AC_CHECK_SIZEOF(long long)
185
AC_DEFINE_UNQUOTED([SIZEOF_LONG_LONG],[$ac_cv_sizeof_long_long],[Size of long long as computed by sizeof()])
186
AC_CACHE_CHECK([if time_t is unsigned], [ac_cv_time_t_unsigned],[
187
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
192
int array[(((time_t)-1) > 0) ? 1 : -1];
195
ac_cv_time_t_unsigned=yes
197
ac_cv_time_t_unsigned=no
200
AS_IF([test "$ac_cv_time_t_unsigned" = "yes"],[
201
AC_DEFINE([TIME_T_UNSIGNED], 1, [Define to 1 if time_t is unsigned])
204
AC_CACHE_CHECK([if system defines RUSAGE_THREAD], [ac_cv_rusage_thread],[
205
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
207
#include <sys/time.h>
208
#include <sys/resource.h>
210
int x= RUSAGE_THREAD;
213
ac_cv_rusage_thread=yes
215
ac_cv_rusage_thread=no
218
AS_IF([test "$ac_cv_rusage_thread" = "no"],[
219
AC_DEFINE([RUSAGE_THREAD], [RUSAGE_SELF],
220
[Define if system doesn't define])
224
dnl Bug on FreeBSD - LIBM check doesn't set the damn variable
227
AC_CHECK_FUNC(setsockopt, [], [AC_CHECK_LIB(socket, setsockopt)])
228
AC_CHECK_FUNC(bind, [], [AC_CHECK_LIB(bind, bind)])
235
# Test whether madvise() is declared in C++ code -- it is not on some
236
# systems, such as Solaris
237
AC_CHECK_DECLS([madvise], [], [], [AC_INCLUDES_DEFAULT[
239
#include <sys/types.h>
240
#include <sys/mman.h>
245
PANDORA_HAVE_GCC_ATOMICS
247
save_CFLAGS="${CFLAGS}"
248
CFLAGS="${CFLAGS} -Werror"
249
PANDORA_CHECK_VISIBILITY
250
CFLAGS="${save_CFLAGS}"
251
m4_if(PCT_USE_VISIBILITY,[yes],[
252
PANDORA_ENABLE_VISIBILITY
255
PANDORA_HEADER_ASSERT
257
PANDORA_WARNINGS(PCT_ALL_ARGS)
259
PANDORA_ENABLE_DTRACE
262
PANDORA_HAVE_BETTER_MALLOC
264
AC_CHECK_PROGS([DOXYGEN], [doxygen])
265
AC_CHECK_PROGS([PERL], [perl])
266
AC_CHECK_PROGS([DPKG_GENSYMBOLS], [dpkg-gensymbols], [:])
267
AC_CHECK_PROGS([LCOV], [lcov], [echo lcov not found])
268
AC_CHECK_PROGS([LCOV_GENHTML], [genhtml], [echo genhtml not found])
270
AC_CHECK_PROGS([SPHINXBUILD], [sphinx-build], [:])
271
AS_IF([test "x${SPHINXBUILD}" != "x:"],[
272
AC_CACHE_CHECK([if sphinx is new enough],[ac_cv_recent_sphinx],[
274
${SPHINXBUILD} -Q -C -b man -d conftest.d . . >/dev/null 2>&1
275
AS_IF([test $? -eq 0],[ac_cv_recent_sphinx=yes],
276
[ac_cv_recent_sphinx=no])
281
AM_CONDITIONAL(HAVE_DPKG_GENSYMBOLS,[test "x${DPKG_GENSYMBOLS}" != "x:"])
282
AM_CONDITIONAL(HAVE_SPHINX,[test "x${SPHINXBUILD}" != "x:"])
283
AM_CONDITIONAL(HAVE_RECENT_SPHINX,[test "x${ac_cv_recent_sphinx}" = "xyes"])
285
m4_if(m4_substr(m4_esyscmd(test -d po && echo 0),0,1),0, [
287
IT_PROG_INTLTOOL([0.35],[no-xml])
289
GETTEXT_PACKAGE=$PACKAGE
290
AC_CHECK_LIB(intl, libintl_gettext)
291
AC_SUBST([GETTEXT_PACKAGE])
292
AS_IF([test "x${USE_NLS}" = "xyes" -a "x${pandora_have_intltool}" = "xyes"],
293
[AC_DEFINE([ENABLE_NLS],[1],[Turn on language support])
294
AC_CONFIG_FILES([po/Makefile.in])
297
AM_CONDITIONAL(BUILD_PO,[test "x${USE_NLS}" = "xyes" -a "x${pandora_have_intltool}" = "xyes"])
299
AS_IF([test "x${gl_LIBOBJS}" != "x"],[
300
AS_IF([test "$GCC" = "yes"],[
301
AM_CPPFLAGS="-isystem \${top_srcdir}/gnulib -isystem \${top_builddir}/gnulib ${AM_CPPFLAGS}"
303
AM_CPPFLAGS="-I\${top_srcdir}/gnulib -I\${top_builddir}/gnulib ${AM_CPPFLAGS}"
306
m4_if(m4_substr(m4_esyscmd(test -d src && echo 0),0,1),0,[
307
AM_CPPFLAGS="-I\$(top_srcdir)/src -I\$(top_builddir)/src ${AM_CPPFLAGS}"
309
AM_CPPFLAGS="-I\$(top_srcdir) -I\$(top_builddir) ${AM_CPPFLAGS}"
318
/* _SYS_FEATURE_TESTS_H is Solaris, _FEATURES_H is GCC */
319
#if defined( _SYS_FEATURE_TESTS_H) || defined(_FEATURES_H)
320
#error "You should include config.h as your first include file"
323
#include "config/top.h"
326
cat > config/top.h.stamp <<EOF_CONFIG_TOP
328
#if defined(i386) && !defined(__i386__)
332
#if defined(_FILE_OFFSET_BITS)
333
# undef _FILE_OFFSET_BITS
337
diff config/top.h.stamp config/top.h >/dev/null 2>&1 || mv config/top.h.stamp config/top.h
338
rm -f config/top.h.stamp
341
#if defined(__cplusplus)
343
# include CINTTYPES_H
346
# include <inttypes.h>
349
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
350
typedef unsigned long int ulong;
353
/* To hide the platform differences between MS Windows and Unix, I am
354
* going to use the Microsoft way and #define the Microsoft-specific
355
* functions to the unix way. Microsoft use a separate subsystem for sockets,
356
* but Unix normally just use a filedescriptor on the same functions. It is
357
* a lot easier to map back to the unix way with macros than going the other
358
* way without side effect ;-)
360
#ifdef TARGET_OS_WINDOWS
361
#define random() rand()
362
#define srandom(a) srand(a)
363
#define get_socket_errno() WSAGetLastError()
365
#define INVALID_SOCKET -1
366
#define SOCKET_ERROR -1
367
#define closesocket(a) close(a)
368
#define get_socket_errno() errno
371
#if defined(__cplusplus)
376
template<typename To, typename From>
377
inline To implicit_cast(From const &f) {
380
template<typename To, typename From> // use like this: down_cast<T*>(foo);
381
inline To down_cast(From* f) { // so we only accept pointers
382
// Ensures that To is a sub-type of From *. This test is here only
383
// for compile-time type checking, and has no overhead in an
384
// optimized build at run-time, as it will be optimized away
387
implicit_cast<From*, To>(0);
391
assert(f == NULL || dynamic_cast<To>(f) != NULL); // RTTI: debug mode only!
393
return static_cast<To>(f);
395
#endif /* defined(__cplusplus) */
397
#endif /* __CONFIG_H__ */
400
AM_CFLAGS="${AM_CFLAGS} ${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
401
AM_CXXFLAGS="${AM_CXXFLAGS} ${CXX_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
403
AC_SUBST([AM_CFLAGS])
404
AC_SUBST([AM_CXXFLAGS])
405
AC_SUBST([AM_CPPFLAGS])
406
AC_SUBST([AM_LDFLAGS])