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.
6
dnl Which version of the canonical setup we're using
7
AC_DEFUN([PANDORA_CANONICAL_VERSION],[0.175])
9
AC_DEFUN([PANDORA_BLOCK_BAD_OPTIONS],[
10
AS_IF([test "x${prefix}" = "x"],[
11
AC_MSG_ERROR([--prefix requires an argument])
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_USE_VISIBILITY],[yes])
25
m4_foreach([pct_arg],[$*],[
28
m4_undefine([PCT_REQUIRE_CXX])
29
m4_define([PCT_REQUIRE_CXX],[yes])
32
m4_undefine([PCT_FORCE_GCC42])
33
m4_define([PCT_FORCE_GCC42],[yes])
36
m4_undefine([PCT_USE_VISIBILITY])
37
m4_define([PCT_USE_VISIBILITY],[no])
39
[dont-suppress-include], [
40
m4_undefine([PCT_DONT_SUPPRESS_INCLUDE])
41
m4_define([PCT_DONT_SUPPRESS_INCLUDE],[yes])
45
PANDORA_BLOCK_BAD_OPTIONS
47
# We need to prevent canonical target
48
# from injecting -O2 into CFLAGS - but we won't modify anything if we have
49
# set CFLAGS on the command line, since that should take ultimate precedence
50
AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"],
52
AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
55
AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability subdir-objects foreign tar-ustar])
57
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
59
m4_if(m4_substr(m4_esyscmd(test -d gnulib && echo 0),0,1),0,[
65
AC_REQUIRE([AC_PROG_CC])
66
m4_if(PCT_FORCE_GCC42, [yes], [
67
AC_REQUIRE([PANDORA_ENSURE_GCC_VERSION])
69
AC_REQUIRE([PANDORA_64BIT])
71
m4_if(PCT_NO_VC_CHANGELOG,yes,[
77
dnl Once we can use a modern autoconf, we can use this
79
AC_REQUIRE([AC_PROG_CXX])
87
dnl autoconf doesn't automatically provide a fail-if-no-C++ macro
88
dnl so we check c++98 features and fail if we don't have them, mainly
90
m4_if(PCT_REQUIRE_CXX, [yes], [
91
AS_IF([test "$ac_cv_cxx_stdcxx_98" = "no"],[
92
AC_MSG_ERROR([No working C++ Compiler has been found. ${PACKAGE} requires a C++ compiler that can handle C++98])
96
m4_if(m4_substr(m4_esyscmd(test -d gnulib && echo 0),0,1),0,[
98
AC_CONFIG_LIBOBJ_DIR([gnulib])
101
PANDORA_CHECK_CXX_VERSION
107
PANDORA_CLOCK_GETTIME
109
AC_CHECK_HEADERS(sys/socket.h)
111
# off_t is not a builtin type
112
AC_CHECK_SIZEOF(off_t, 4)
113
AS_IF([test "$ac_cv_sizeof_off_t" -eq 0],[
114
AC_MSG_ERROR("${PACKAGE} needs an off_t type.")
117
AC_CHECK_SIZEOF(size_t)
118
AS_IF([test "$ac_cv_sizeof_size_t" -eq 0],[
119
AC_MSG_ERROR("${PACKAGE} needs an size_t type.")
122
AC_DEFINE_UNQUOTED([SIZEOF_SIZE_T],[$ac_cv_sizeof_size_t],[Size of size_t as computed by sizeof()])
123
AC_CHECK_SIZEOF(long long)
124
AC_DEFINE_UNQUOTED([SIZEOF_LONG_LONG],[$ac_cv_sizeof_long_long],[Size of long long as computed by sizeof()])
125
AC_CACHE_CHECK([if time_t is unsigned], [ac_cv_time_t_unsigned],[
126
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
131
int array[(((time_t)-1) > 0) ? 1 : -1];
134
ac_cv_time_t_unsigned=yes
136
ac_cv_time_t_unsigned=no
139
AS_IF([test "$ac_cv_time_t_unsigned" = "yes"],[
140
AC_DEFINE([TIME_T_UNSIGNED], 1, [Define to 1 if time_t is unsigned])
143
AC_CHECK_FUNC(setsockopt, [], [AC_CHECK_LIB(socket, setsockopt)])
144
AC_CHECK_FUNC(bind, [], [AC_CHECK_LIB(bind, bind)])
150
PANDORA_HAVE_GCC_ATOMICS
152
PANDORA_WARNINGS(PCT_ALL_ARGS)
154
PANDORA_ENABLE_DTRACE
157
PANDORA_HAVE_BETTER_MALLOC
159
m4_if(m4_substr(m4_esyscmd(test -d src && echo 0),0,1),0,[
160
AM_CPPFLAGS="-I\$(top_srcdir)/src -I\$(top_builddir)/src ${AM_CPPFLAGS}"
162
AM_CPPFLAGS="-I\$(top_srcdir) -I\$(top_builddir) ${AM_CPPFLAGS}"
167
AM_CFLAGS="-std=c99 ${AM_CFLAGS} ${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
168
AM_CXXFLAGS="${AM_CXXFLAGS} ${CXX_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
170
AC_SUBST([AM_CFLAGS])
171
AC_SUBST([AM_CXXFLAGS])
172
AC_SUBST([AM_CPPFLAGS])
173
AC_SUBST([AM_LDFLAGS])