~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to m4/pandora_canonical.m4

  • Committer: Brian Aker
  • Date: 2009-05-20 23:51:08 UTC
  • mfrom: (1022.2.18 mordred)
  • Revision ID: brian@gaz-20090520235108-nb5he1em112798pb
Merge Monty

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.161])
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
 
AC_DEFUN([PANDORA_BLOCK_BAD_OPTIONS],[
27
 
  AS_IF([test "x${prefix}" = "x"],[
28
 
    AC_MSG_ERROR([--prefix requires an argument])
29
 
  ])
30
 
])
31
 
 
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],[$*],[
44
 
    m4_case(pct_arg,
45
 
      [require-cxx], [
46
 
        m4_undefine([PCT_REQUIRE_CXX])
47
 
        m4_define([PCT_REQUIRE_CXX],[yes])
48
 
      ],
49
 
      [force-gcc42], [
50
 
        m4_undefine([PCT_FORCE_GCC42])
51
 
        m4_define([PCT_FORCE_GCC42],[yes])
52
 
      ],
53
 
      [skip-visibility], [
54
 
        m4_undefine([PCT_USE_VISIBILITY])
55
 
        m4_define([PCT_USE_VISIBILITY],[no])
56
 
      ],
57
 
      [dont-suppress-include], [
58
 
        m4_undefine([PCT_DONT_SUPPRESS_INCLUDE])
59
 
        m4_define([PCT_DONT_SUPPRESS_INCLUDE],[yes])
60
 
      ],
61
 
      [version-from-vc], [
62
 
        m4_undefine([PCT_VERSION_FROM_VC])
63
 
        m4_define([PCT_VERSION_FROM_VC],[yes])
64
 
    ])
65
 
  ])
66
 
 
67
 
  AC_CONFIG_MACRO_DIR([m4])
68
 
 
69
 
  m4_if(m4_substr(m4_esyscmd(test -d src && echo 0),0,1),0,[
70
 
    AC_CONFIG_HEADERS([src/config.h])
71
 
  ],[
72
 
    AC_CONFIG_HEADERS([config.h])
73
 
  ])
74
 
 
75
 
  PANDORA_BLOCK_BAD_OPTIONS
76
 
 
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"],
81
 
        [CFLAGS=""])
82
 
  AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
83
 
        [CXXFLAGS=""])
84
 
  
85
 
  AC_CANONICAL_TARGET
86
 
  
87
 
  m4_if(PCT_DONT_SUPRESS_INCLUDE,yes,[
88
 
    AM_INIT_AUTOMAKE(-Wall -Werror -Wno-portability subdir-objects foreign tar-ustar)
89
 
  ],[
90
 
    AM_INIT_AUTOMAKE(-Wall -Werror -Wno-portability nostdinc subdir-objects foreign tar-ustar)
91
 
  ])
92
 
 
93
 
  m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
94
 
 
95
 
  m4_if(m4_substr(m4_esyscmd(test -d gnulib && echo 0),0,1),0,[
96
 
    gl_EARLY
97
 
  ],[
98
 
    PANDORA_EXTENSIONS 
99
 
  ])
100
 
  
101
 
  AC_REQUIRE([AC_PROG_CC])
102
 
  m4_if(PCT_FORCE_GCC42, [yes], [
103
 
    AC_REQUIRE([PANDORA_ENSURE_GCC_VERSION])
104
 
  ])
105
 
  AC_REQUIRE([PANDORA_64BIT])
106
 
 
107
 
  m4_if(PCT_VERSION_FROM_VC,yes,[
108
 
    PANDORA_VC_VERSION
109
 
  ],[
110
 
    PANDORA_TEST_VC_DIR
111
 
 
112
 
    changequote(<<, >>)dnl
113
 
    PANDORA_RELEASE_ID=`echo $VERSION | sed 's/[^0-9]//g'`
114
 
    changequote([, ])dnl
115
 
 
116
 
    PANDORA_RELEASE_COMMENT=""
117
 
    AC_DEFINE_UNQUOTED([PANDORA_RELEASE_VERSION],["$VERSION"],
118
 
                       [Version of the software])
119
 
 
120
 
    AC_SUBST(PANDORA_RELEASE_COMMENT)
121
 
    AC_SUBST(PANDORA_RELEASE_VERSION)
122
 
    AC_SUBST(PANDORA_RELEASE_ID)
123
 
  ])
124
 
  PANDORA_VERSION
125
 
 
126
 
  dnl Once we can use a modern autoconf, we can use this
127
 
  dnl AC_PROG_CC_C99
128
 
  AC_REQUIRE([AC_PROG_CXX])
129
 
  PANDORA_EXTENSIONS
130
 
  AM_PROG_CC_C_O
131
 
 
132
 
 
133
 
 
134
 
  PANDORA_PLATFORM
135
 
 
136
 
  PANDORA_LIBTOOL
137
 
 
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
140
 
  dnl for that reason
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])
145
 
    ])
146
 
  ])
147
 
  PANDORA_CXX_CSTDINT
148
 
  PANDORA_CXX_CINTTYPES
149
 
  
150
 
  m4_if(m4_substr(m4_esyscmd(test -d gnulib && echo 0),0,1),0,[
151
 
    gl_INIT
152
 
    AC_CONFIG_LIBOBJ_DIR([gnulib])
153
 
  ])
154
 
 
155
 
  PANDORA_CHECK_C_VERSION
156
 
  PANDORA_CHECK_CXX_VERSION
157
 
 
158
 
  AC_C_BIGENDIAN
159
 
  AC_C_CONST
160
 
  AC_C_INLINE
161
 
  AC_C_VOLATILE
162
 
  AC_C_RESTRICT
163
 
 
164
 
  AC_HEADER_TIME
165
 
  AC_STRUCT_TM
166
 
  AC_TYPE_SIZE_T
167
 
  AC_SYS_LARGEFILE
168
 
  PANDORA_CLOCK_GETTIME
169
 
 
170
 
  AC_CHECK_HEADERS(sys/socket.h)
171
 
 
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.")
176
 
  ])
177
 
 
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.")
181
 
  ])
182
 
 
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(
188
 
      [[
189
 
#include <time.h>
190
 
      ]],
191
 
      [[
192
 
      int array[(((time_t)-1) > 0) ? 1 : -1];
193
 
      ]])
194
 
    ],[
195
 
      ac_cv_time_t_unsigned=yes
196
 
    ],[
197
 
      ac_cv_time_t_unsigned=no
198
 
    ])
199
 
  ])
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])
202
 
  ])
203
 
 
204
 
  AC_CACHE_CHECK([if system defines RUSAGE_THREAD], [ac_cv_rusage_thread],[
205
 
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
206
 
      [[
207
 
#include <sys/time.h>
208
 
#include <sys/resource.h>
209
 
      ]],[[
210
 
      int x= RUSAGE_THREAD;
211
 
      ]])
212
 
    ],[
213
 
      ac_cv_rusage_thread=yes
214
 
    ],[
215
 
      ac_cv_rusage_thread=no
216
 
    ])
217
 
  ])
218
 
  AS_IF([test "$ac_cv_rusage_thread" = "no"],[
219
 
    AC_DEFINE([RUSAGE_THREAD], [RUSAGE_SELF],
220
 
      [Define if system doesn't define])
221
 
  ])
222
 
 
223
 
  AC_CHECK_LIBM
224
 
  dnl Bug on FreeBSD - LIBM check doesn't set the damn variable
225
 
  AC_SUBST([LIBM])
226
 
  
227
 
  AC_CHECK_FUNC(setsockopt, [], [AC_CHECK_LIB(socket, setsockopt)])
228
 
  AC_CHECK_FUNC(bind, [], [AC_CHECK_LIB(bind, bind)])
229
 
 
230
 
 
231
 
 
232
 
  PANDORA_OPTIMIZE
233
 
 
234
 
  AC_LANG_PUSH(C++)
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[
238
 
  #if HAVE_SYS_MMAN_H
239
 
  #include <sys/types.h>
240
 
  #include <sys/mman.h>
241
 
  #endif
242
 
  ]])
243
 
  AC_LANG_POP()
244
 
 
245
 
  PANDORA_HAVE_GCC_ATOMICS
246
 
 
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
253
 
  ])
254
 
 
255
 
  PANDORA_HEADER_ASSERT
256
 
 
257
 
  PANDORA_WARNINGS(PCT_ALL_ARGS)
258
 
 
259
 
  PANDORA_ENABLE_DTRACE
260
 
 
261
 
  AC_LIB_PREFIX
262
 
  PANDORA_HAVE_BETTER_MALLOC
263
 
 
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])
269
 
 
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],[
273
 
    
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])
277
 
    rm -rf conftest.d
278
 
    ])
279
 
  ])
280
 
 
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"])
284
 
 
285
 
  m4_if(m4_substr(m4_esyscmd(test -d po && echo 0),0,1),0, [
286
 
    AM_PO_SUBDIRS
287
 
    IT_PROG_INTLTOOL([0.35],[no-xml])
288
 
    
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])
295
 
      ])
296
 
  ])
297
 
  AM_CONDITIONAL(BUILD_PO,[test "x${USE_NLS}" = "xyes" -a "x${pandora_have_intltool}" = "xyes"])
298
 
 
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}"
302
 
    ],[
303
 
    AM_CPPFLAGS="-I\${top_srcdir}/gnulib -I\${top_builddir}/gnulib ${AM_CPPFLAGS}"
304
 
    ])
305
 
  ])
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}"
308
 
  ],[
309
 
    AM_CPPFLAGS="-I\$(top_srcdir) -I\$(top_builddir) ${AM_CPPFLAGS}"
310
 
  ])
311
 
 
312
 
  PANDORA_USE_PIPE
313
 
 
314
 
  AH_TOP([
315
 
#ifndef __CONFIG_H__
316
 
#define __CONFIG_H__
317
 
 
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"
321
 
#endif
322
 
 
323
 
#include "config/top.h"
324
 
])
325
 
  mkdir -p config
326
 
  cat > config/top.h.stamp <<EOF_CONFIG_TOP
327
 
 
328
 
#if defined(i386) && !defined(__i386__)
329
 
#define __i386__
330
 
#endif
331
 
 
332
 
#if defined(_FILE_OFFSET_BITS)
333
 
# undef _FILE_OFFSET_BITS
334
 
#endif
335
 
EOF_CONFIG_TOP
336
 
 
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
339
 
 
340
 
  AH_BOTTOM([
341
 
#if defined(__cplusplus)
342
 
# include CSTDINT_H
343
 
# include CINTTYPES_H
344
 
#else
345
 
# include <stdint.h>
346
 
# include <inttypes.h>
347
 
#endif
348
 
 
349
 
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
350
 
typedef unsigned long int ulong;
351
 
#endif
352
 
 
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 ;-)
359
 
 */
360
 
#ifdef TARGET_OS_WINDOWS
361
 
#define random() rand()
362
 
#define srandom(a) srand(a)
363
 
#define get_socket_errno() WSAGetLastError()
364
 
#else
365
 
#define INVALID_SOCKET -1
366
 
#define SOCKET_ERROR -1
367
 
#define closesocket(a) close(a)
368
 
#define get_socket_errno() errno
369
 
#endif
370
 
 
371
 
#if defined(__cplusplus)
372
 
# if defined(DEBUG)
373
 
#  include <cassert>
374
 
#  include <cstddef>
375
 
# endif
376
 
template<typename To, typename From>
377
 
inline To implicit_cast(From const &f) {
378
 
  return f;
379
 
}
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
385
 
  // completely.
386
 
  if (false) {
387
 
    implicit_cast<From*, To>(0);
388
 
  }
389
 
 
390
 
#if defined(DEBUG)
391
 
  assert(f == NULL || dynamic_cast<To>(f) != NULL);  // RTTI: debug mode only!
392
 
#endif
393
 
  return static_cast<To>(f);
394
 
}
395
 
#endif /* defined(__cplusplus) */
396
 
 
397
 
#endif /* __CONFIG_H__ */
398
 
  ])
399
 
 
400
 
  AM_CFLAGS="${AM_CFLAGS} ${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
401
 
  AM_CXXFLAGS="${AM_CXXFLAGS} ${CXX_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
402
 
 
403
 
  AC_SUBST([AM_CFLAGS])
404
 
  AC_SUBST([AM_CXXFLAGS])
405
 
  AC_SUBST([AM_CPPFLAGS])
406
 
  AC_SUBST([AM_LDFLAGS])
407
 
 
408
 
])