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.155])
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,[
114
dnl Once we can use a modern autoconf, we can use this
116
AC_REQUIRE([AC_PROG_CXX])
126
dnl autoconf doesn't automatically provide a fail-if-no-C++ macro
127
dnl so we check c++98 features and fail if we don't have them, mainly
129
PANDORA_CHECK_CXX_STANDARD
130
m4_if(PCT_REQUIRE_CXX, [yes], [
131
AS_IF([test "$ac_cv_cxx_stdcxx_98" = "no"],[
132
AC_MSG_ERROR([No working C++ Compiler has been found. ${PACKAGE} requires a C++ compiler that can handle C++98])
136
PANDORA_CXX_CINTTYPES
138
m4_if(m4_substr(m4_esyscmd(test -d gnulib && echo 0),0,1),0,[
140
AC_CONFIG_LIBOBJ_DIR([gnulib])
143
PANDORA_CHECK_C_VERSION
144
PANDORA_CHECK_CXX_VERSION
156
PANDORA_CLOCK_GETTIME
158
AC_CHECK_HEADERS(sys/socket.h)
160
# off_t is not a builtin type
161
AC_CHECK_SIZEOF(off_t, 4)
162
AS_IF([test "$ac_cv_sizeof_off_t" -eq 0],[
163
AC_MSG_ERROR("${PACKAGE} needs an off_t type.")
166
AC_CHECK_SIZEOF(size_t)
167
AS_IF([test "$ac_cv_sizeof_size_t" -eq 0],[
168
AC_MSG_ERROR("${PACKAGE} needs an size_t type.")
171
AC_DEFINE_UNQUOTED([SIZEOF_SIZE_T],[$ac_cv_sizeof_size_t],[Size of size_t as computed by sizeof()])
172
AC_CHECK_SIZEOF(long long)
173
AC_DEFINE_UNQUOTED([SIZEOF_LONG_LONG],[$ac_cv_sizeof_long_long],[Size of long long as computed by sizeof()])
174
AC_CACHE_CHECK([if time_t is unsigned], [ac_cv_time_t_unsigned],[
175
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
180
int array[(((time_t)-1) > 0) ? 1 : -1];
183
ac_cv_time_t_unsigned=yes
185
ac_cv_time_t_unsigned=no
188
AS_IF([test "$ac_cv_time_t_unsigned" = "yes"],[
189
AC_DEFINE([TIME_T_UNSIGNED], 1, [Define to 1 if time_t is unsigned])
193
dnl Bug on FreeBSD - LIBM check doesn't set the damn variable
196
AC_CHECK_FUNC(setsockopt, [], [AC_CHECK_LIB(socket, setsockopt)])
197
AC_CHECK_FUNC(bind, [], [AC_CHECK_LIB(bind, bind)])
204
# Test whether madvise() is declared in C++ code -- it is not on some
205
# systems, such as Solaris
206
AC_CHECK_DECLS([madvise], [], [], [AC_INCLUDES_DEFAULT[
208
#include <sys/types.h>
209
#include <sys/mman.h>
214
PANDORA_HAVE_GCC_ATOMICS
216
save_CFLAGS="${CFLAGS}"
217
CFLAGS="${CFLAGS} -Werror"
218
PANDORA_CHECK_VISIBILITY
219
CFLAGS="${save_CFLAGS}"
220
m4_if(PCT_USE_VISIBILITY,[yes],[
221
PANDORA_ENABLE_VISIBILITY
224
PANDORA_HEADER_ASSERT
226
PANDORA_WARNINGS(PCT_ALL_ARGS)
228
PANDORA_ENABLE_DTRACE
231
PANDORA_HAVE_BETTER_MALLOC
233
AC_CHECK_PROGS([DOXYGEN], [doxygen])
234
AC_CHECK_PROGS([PERL], [perl])
235
AC_CHECK_PROGS([DPKG_GENSYMBOLS], [dpkg-gensymbols], [:])
236
AC_CHECK_PROGS([SPHINXBUILD], [sphinx-build], [:])
238
AM_CONDITIONAL(HAVE_DPKG_GENSYMBOLS,[test "x${DPKG_GENSYMBOLS}" != "x:"])
239
AM_CONDITIONAL(HAVE_SPHINX,[test "x${SPHINXBUILD}" != "x:"])
241
m4_if(m4_substr(m4_esyscmd(test -d po && echo 0),0,1),0, [
243
IT_PROG_INTLTOOL([0.35],[no-xml])
245
GETTEXT_PACKAGE=$PACKAGE
246
AC_CHECK_LIB(intl, libintl_gettext)
247
AC_SUBST([GETTEXT_PACKAGE])
248
AS_IF([test "x${USE_NLS}" = "xyes" -a "x${pandora_have_intltool}" = "xyes"],
249
[AC_DEFINE([ENABLE_NLS],[1],[Turn on language support])
250
AC_CONFIG_FILES([po/Makefile.in])
253
AM_CONDITIONAL(BUILD_PO,[test "x${USE_NLS}" = "xyes" -a "x${pandora_have_intltool}" = "xyes"])
255
AS_IF([test "x${gl_LIBOBJS}" != "x"],[
256
AS_IF([test "$GCC" = "yes"],[
257
AM_CPPFLAGS="-isystem \${top_srcdir}/gnulib -isystem \${top_builddir}/gnulib ${AM_CPPFLAGS}"
259
AM_CPPFLAGS="-I\${top_srcdir}/gnulib -I\${top_builddir}/gnulib ${AM_CPPFLAGS}"
262
m4_if(m4_substr(m4_esyscmd(test -d src && echo 0),0,1),0,[
263
AM_CPPFLAGS="-I\$(top_srcdir)/src -I\$(top_builddir)/src ${AM_CPPFLAGS}"
265
AM_CPPFLAGS="-I\$(top_srcdir) -I\$(top_builddir) ${AM_CPPFLAGS}"
274
/* _SYS_FEATURE_TESTS_H is Solaris, _FEATURES_H is GCC */
275
#if defined( _SYS_FEATURE_TESTS_H) || defined(_FEATURES_H)
276
#error "You should include config.h as your first include file"
279
#include "config/top.h"
282
cat > config/top.h.stamp <<EOF_CONFIG_TOP
284
#if defined(i386) && !defined(__i386__)
288
#if defined(_FILE_OFFSET_BITS)
289
# undef _FILE_OFFSET_BITS
293
diff config/top.h.stamp config/top.h >/dev/null 2>&1 || mv config/top.h.stamp config/top.h
294
rm -f config/top.h.stamp
297
#if defined(__cplusplus)
299
# include CINTTYPES_H
302
# include <inttypes.h>
305
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
306
typedef unsigned long int ulong;
309
/* To hide the platform differences between MS Windows and Unix, I am
310
* going to use the Microsoft way and #define the Microsoft-specific
311
* functions to the unix way. Microsoft use a separate subsystem for sockets,
312
* but Unix normally just use a filedescriptor on the same functions. It is
313
* a lot easier to map back to the unix way with macros than going the other
314
* way without side effect ;-)
316
#ifdef TARGET_OS_WINDOWS
317
#define random() rand()
318
#define srandom(a) srand(a)
319
#define get_socket_errno() WSAGetLastError()
321
#define INVALID_SOCKET -1
322
#define SOCKET_ERROR -1
323
#define closesocket(a) close(a)
324
#define get_socket_errno() errno
327
#endif /* __CONFIG_H__ */
330
AM_CFLAGS="${AM_CFLAGS} ${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
331
AM_CXXFLAGS="${AM_CXXFLAGS} ${CXX_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
333
AC_SUBST([AM_CFLAGS])
334
AC_SUBST([AM_CXXFLAGS])
335
AC_SUBST([AM_CPPFLAGS])
336
AC_SUBST([AM_LDFLAGS])