~markwright/scalestack/zeromq

« back to all changes in this revision

Viewing changes to m4/pandora_canonical.m4

  • Committer: Eric Day
  • Date: 2010-02-21 10:36:03 UTC
  • Revision ID: eday@oddments.org-20100221103603-u0agc1fsduqhl728
Initial commit with build system and basic module loading.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.109])
 
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
dnl The standard setup for how we build Pandora projects
 
27
AC_DEFUN([PANDORA_CANONICAL_TARGET],[
 
28
  AC_REQUIRE([PANDORA_FORCE_DEPEND_TRACKING])
 
29
  ifdef([m4_define],,[define([m4_define],   defn([define]))])
 
30
  ifdef([m4_undefine],,[define([m4_undefine],   defn([undefine]))])
 
31
  m4_define([PCT_ALL_ARGS],[$*])
 
32
  m4_define([PCT_REQUIRE_CXX],[no])
 
33
  m4_define([PCT_FORCE_GCC42],[no])
 
34
  m4_define([PCT_DONT_SUPPRESS_INCLUDE],[no])
 
35
  m4_define([PCT_VERSION_FROM_VC],[no])
 
36
  m4_define([PCT_USE_VISIBILITY],[yes])
 
37
  m4_foreach([pct_arg],[$*],[
 
38
    m4_case(pct_arg,
 
39
      [require-cxx], [
 
40
        m4_undefine([PCT_REQUIRE_CXX])
 
41
        m4_define([PCT_REQUIRE_CXX],[yes])
 
42
      ],
 
43
      [force-gcc42], [
 
44
        m4_undefine([PCT_FORCE_GCC42])
 
45
        m4_define([PCT_FORCE_GCC42],[yes])
 
46
      ],
 
47
      [skip-visibility], [
 
48
        m4_undefine([PCT_USE_VISIBILITY])
 
49
        m4_define([PCT_USE_VISIBILITY],[no])
 
50
      ],
 
51
      [dont-suppress-include], [
 
52
        m4_undefine([PCT_DONT_SUPPRESS_INCLUDE])
 
53
        m4_define([PCT_DONT_SUPPRESS_INCLUDE],[yes])
 
54
      ],
 
55
      [version-from-vc], [
 
56
        m4_undefine([PCT_VERSION_FROM_VC])
 
57
        m4_define([PCT_VERSION_FROM_VC],[yes])
 
58
    ])
 
59
  ])
 
60
 
 
61
  AC_CONFIG_MACRO_DIR([m4])
 
62
 
 
63
  m4_if(m4_substr(m4_esyscmd(test -d src && echo 0),0,1),0,[
 
64
    AC_CONFIG_HEADERS([src/config.h])
 
65
  ],[
 
66
    AC_CONFIG_HEADERS([config.h])
 
67
  ])
 
68
 
 
69
  # We need to prevent canonical target
 
70
  # from injecting -O2 into CFLAGS - but we won't modify anything if we have
 
71
  # set CFLAGS on the command line, since that should take ultimate precedence
 
72
  AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"],
 
73
        [CFLAGS=""])
 
74
  AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
 
75
        [CXXFLAGS=""])
 
76
  
 
77
  AC_CANONICAL_TARGET
 
78
  
 
79
  m4_if(PCT_DONT_SUPRESS_INCLUDE,yes,[
 
80
    AM_INIT_AUTOMAKE(-Wall -Werror subdir-objects foreign)
 
81
  ],[
 
82
    AM_INIT_AUTOMAKE(-Wall -Werror nostdinc subdir-objects foreign)
 
83
  ])
 
84
 
 
85
  m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
 
86
 
 
87
  m4_if(m4_substr(m4_esyscmd(test -d gnulib && echo 0),0,1),0,[
 
88
    gl_EARLY
 
89
  ])
 
90
  
 
91
  AC_REQUIRE([AC_PROG_CC])
 
92
  AC_REQUIRE([PANDORA_MAC_GCC42])
 
93
  AC_REQUIRE([PANDORA_64BIT])
 
94
 
 
95
  m4_if(PCT_VERSION_FROM_VC,yes,[
 
96
    PANDORA_VC_VERSION
 
97
  ])
 
98
  PANDORA_VERSION
 
99
 
 
100
  dnl Once we can use a modern autoconf, we can use this
 
101
  dnl AC_PROG_CC_C99
 
102
  AC_REQUIRE([AC_PROG_CXX])
 
103
  PANDORA_EXTENSIONS
 
104
  AM_PROG_CC_C_O
 
105
 
 
106
 
 
107
  m4_if(PCT_FORCE_GCC42, [yes], [
 
108
    AS_IF([test "$GCC" = "yes"], PANDORA_ENSURE_GCC_VERSION)
 
109
  ])
 
110
 
 
111
  PANDORA_PLATFORM
 
112
 
 
113
  PANDORA_LIBTOOL
 
114
 
 
115
  dnl autoconf doesn't automatically provide a fail-if-no-C++ macro
 
116
  dnl so we check c++98 features and fail if we don't have them, mainly
 
117
  dnl for that reason
 
118
  PANDORA_CHECK_CXX_STANDARD
 
119
  m4_if(PCT_REQUIRE_CXX, [yes], [
 
120
    AS_IF([test "$ac_cv_cxx_stdcxx_98" = "no"],[
 
121
      AC_MSG_ERROR([No working C++ Compiler has been found. ${PACKAGE} requires a C++ compiler that can handle C++98])
 
122
    ])
 
123
 
 
124
  ])
 
125
  
 
126
  m4_if(m4_substr(m4_esyscmd(test -d gnulib && echo 0),0,1),0,[
 
127
    gl_INIT
 
128
    AC_CONFIG_LIBOBJ_DIR([gnulib])
 
129
  ])
 
130
 
 
131
  PANDORA_CHECK_C_VERSION
 
132
  PANDORA_CHECK_CXX_VERSION
 
133
 
 
134
  AC_C_BIGENDIAN
 
135
  AC_C_CONST
 
136
  AC_C_INLINE
 
137
  AC_C_VOLATILE
 
138
  AC_C_RESTRICT
 
139
 
 
140
  AC_HEADER_TIME
 
141
  AC_STRUCT_TM
 
142
  AC_TYPE_SIZE_T
 
143
  AC_SYS_LARGEFILE
 
144
  PANDORA_CLOCK_GETTIME
 
145
 
 
146
  # off_t is not a builtin type
 
147
  AC_CHECK_SIZEOF(off_t, 4)
 
148
  AS_IF([test "$ac_cv_sizeof_off_t" -eq 0],[
 
149
    AC_MSG_ERROR("${PACKAGE} needs an off_t type.")
 
150
  ])
 
151
 
 
152
  AC_CHECK_SIZEOF(size_t)
 
153
  AS_IF([test "$ac_cv_sizeof_size_t" -eq 0],[
 
154
    AC_MSG_ERROR("${PACKAGE} needs an size_t type.")
 
155
  ])
 
156
 
 
157
  AC_DEFINE_UNQUOTED([SIZEOF_SIZE_T],[$ac_cv_sizeof_size_t],[Size of size_t as computed by sizeof()])
 
158
  AC_CHECK_SIZEOF(long long)
 
159
  AC_DEFINE_UNQUOTED([SIZEOF_LONG_LONG],[$ac_cv_sizeof_long_long],[Size of long long as computed by sizeof()])
 
160
  AC_CACHE_CHECK([if time_t is unsigned], [ac_cv_time_t_unsigned],[
 
161
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
 
162
      [[
 
163
#include <time.h>
 
164
      ]],
 
165
      [[
 
166
      int array[(((time_t)-1) > 0) ? 1 : -1];
 
167
      ]])
 
168
    ],[
 
169
      ac_cv_time_t_unsigned=yes
 
170
    ],[
 
171
      ac_cv_time_t_unsigned=no
 
172
    ])
 
173
  ])
 
174
  AS_IF([test "$ac_cv_time_t_unsigned" = "yes"],[
 
175
    AC_DEFINE([TIME_T_UNSIGNED], 1, [Define to 1 if time_t is unsigned])
 
176
  ])
 
177
 
 
178
  AC_CHECK_LIBM
 
179
  
 
180
  AC_CHECK_FUNC(setsockopt, [], [AC_CHECK_LIB(socket, setsockopt)])
 
181
  AC_CHECK_FUNC(bind, [], [AC_CHECK_LIB(bind, bind)])
 
182
 
 
183
 
 
184
 
 
185
  PANDORA_OPTIMIZE
 
186
 
 
187
  AC_LANG_PUSH(C++)
 
188
  # Test whether madvise() is declared in C++ code -- it is not on some
 
189
  # systems, such as Solaris
 
190
  AC_CHECK_DECLS([madvise], [], [], [AC_INCLUDES_DEFAULT[
 
191
  #if HAVE_SYS_MMAN_H
 
192
  #include <sys/types.h>
 
193
  #include <sys/mman.h>
 
194
  #endif
 
195
  ]])
 
196
  AC_LANG_POP()
 
197
 
 
198
  PANDORA_HAVE_GCC_ATOMICS
 
199
 
 
200
  m4_if(PCT_USE_VISIBILITY,[yes],[
 
201
    dnl We need to inject error into the cflags to test if visibility works or not
 
202
    save_CFLAGS="${CFLAGS}"
 
203
    CFLAGS="${CFLAGS} -Werror"
 
204
    PANDORA_VISIBILITY
 
205
    CFLAGS="${save_CFLAGS}"
 
206
  ])
 
207
 
 
208
  PANDORA_HEADER_ASSERT
 
209
 
 
210
  PANDORA_WARNINGS(PCT_ALL_ARGS)
 
211
 
 
212
  PANDORA_ENABLE_DTRACE
 
213
 
 
214
  AC_LIB_PREFIX
 
215
  PANDORA_HAVE_BETTER_MALLOC
 
216
 
 
217
  AC_CHECK_PROGS([DOXYGEN], [doxygen])
 
218
  AC_CHECK_PROGS([PERL], [perl])
 
219
  AC_CHECK_PROGS([DPKG_GENSYMBOLS], [dpkg-gensymbols], [:])
 
220
 
 
221
  AM_CONDITIONAL(HAVE_DPKG_GENSYMBOLS,[test "x${DPKG_GENSYMBOLS}" != "x:"])
 
222
 
 
223
  PANDORA_WITH_GETTEXT
 
224
 
 
225
  AS_IF([test "x${gl_LIBOBJS}" != "x"],[
 
226
    AS_IF([test "$GCC" = "yes"],[
 
227
      AM_CPPFLAGS="-isystem \${top_srcdir}/gnulib -isystem \${top_builddir}/gnulib ${AM_CPPFLAGS}"
 
228
    ],[
 
229
    AM_CPPFLAGS="-I\${top_srcdir}/gnulib -I\${top_builddir}/gnulib ${AM_CPPFLAGS}"
 
230
    ])
 
231
  ])
 
232
  m4_if(m4_substr(m4_esyscmd(test -d src && echo 0),0,1),0,[
 
233
    AM_CPPFLAGS="-I\$(top_srcdir)/src -I\$(top_builddir)/src ${AM_CPPFLAGS}"
 
234
  ],[
 
235
    AM_CPPFLAGS="-I\$(top_srcdir) -I\$(top_builddir) ${AM_CPPFLAGS}"
 
236
  ])
 
237
 
 
238
  PANDORA_USE_PIPE
 
239
 
 
240
 
 
241
  AM_CFLAGS="${AM_CFLAGS} ${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
 
242
  AM_CXXFLAGS="${AM_CXXFLAGS} ${CXX_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
 
243
 
 
244
  AC_SUBST([AM_CFLAGS])
 
245
  AC_SUBST([AM_CXXFLAGS])
 
246
  AC_SUBST([AM_CPPFLAGS])
 
247
  AC_SUBST([AM_LDFLAGS])
 
248
 
 
249
])