-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfigure.ac
431 lines (359 loc) · 14.1 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
# Define package version here.
define(CW_VERSION_MAJOR, 1)
define(CW_VERSION_MINOR, 1)
define(CW_VERSION_REVISION, 2)
define(CW_PACKAGE_NAME, [libcwd])
define(CW_BUGREPORT, [libcwd@alinoe.com])
# Compile configuration.
define(CW_COMPILE_FLAGS, [-W -Wall -Woverloaded-virtual -Wundef -Wpointer-arith -Wwrite-strings -Wno-inline -Wno-unknown-pragmas])
define(CW_THREADS, [no])
# Version info, see http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
#
# CW_INTERFACE_VERSION : Current interface version, increment whenever the interface is changed.
# CW_INTERFACE_VERSION_REVISION : Revision, increment every public release; or set to 0 when the interface is changed.
# CW_INTERFACE_AGE : Increment if interfaces have been added; or set to 0 when interfaces have been removed.
define(CW_INTERFACE_VERSION, 8)
define(CW_INTERFACE_VERSION_REVISION, 1)
define(CW_INTERFACE_AGE, 3)
# cwm4/configure_ac_top.m4 calls CW_OPG_CXXFLAGS, but we want it to call our CW_OPG_FLAGS.
define([CW_OPG_CXXFLAGS], [
CW_OPG_FLAGS([$1], [$2])
AC_DISABLE_STATIC
])
# Include cwm4 header.
m4_include([cwm4/configure_ac_top.m4])
# We use doxygen for documentation.
CW_DOXYGEN([])
# Libtool version info
VERSIONINFO="CW_INTERFACE_VERSION:CW_INTERFACE_VERSION_REVISION:CW_INTERFACE_AGE"
AC_SUBST(VERSIONINFO)
# For version code used in check_configuration().
VERSION_MAJOR=CW_VERSION_MAJOR
VERSION_MINOR=CW_VERSION_MINOR
VERSION_REVISION=CW_VERSION_REVISION
AC_SUBST(VERSION_MAJOR)
AC_SUBST(VERSION_MINOR)
AC_SUBST(VERSION_REVISION)
PROJECT_VERSION=CW_VERSION_MAJOR.CW_VERSION_MINOR.CW_VERSION_REVISION
AC_SUBST(PROJECT_VERSION)
# Workaround
true=
AC_SUBST(true)
# Set a decent default value in case we don't have the right libraries.
case "$host" in
*sparc*) CW_CONFIG_BUILTIN_RETURN_ADDRESS_OFFSET="0" ;;
*) CW_CONFIG_BUILTIN_RETURN_ADDRESS_OFFSET="-1" ;;
esac
AC_SUBST(CW_CONFIG_BUILTIN_RETURN_ADDRESS_OFFSET)
# Manual configuration options of libcwd.
AC_ARG_ENABLE(libcwd, [
Options of package libcwd:])
libcwd_config_glibcxx_debug=no
AC_ARG_ENABLE(glibcxx_debug,
[ --enable-glibcxx_debug compile libcwd with -D_GLIBCXX_DEBUG.
See http://gcc.gnu.org/onlinedocs/libstdc++/debug.html.],
libcwd_config_glibcxx_debug=$enableval)
libcwd_config_alloc=yes
AC_ARG_ENABLE(alloc,
[ --disable-alloc disable memory allocation debugging support.],
libcwd_config_alloc=$enableval)
libcwd_config_magic=yes
AC_ARG_ENABLE(magic,
[ --disable-magic disable magic numbers in memory allocation debugging.],
libcwd_config_magic=$enableval)
AC_ARG_WITH(redzone,
[ --with-redzone@<:@=ARG@:>@ The minimum size of a redzone in bytes @<:@default=0@:>@],
[libcwd_config_redzone=$withval], [libcwd_config_redzone=0])
AC_DEFINE_UNQUOTED([LIBCWD_REDZONE], $libcwd_config_redzone, [The minimum size of a redzone in bytes.])
libcwd_config_marker=yes
AC_ARG_ENABLE(marker,
[ --disable-marker disable memory allocation markers.],
libcwd_config_marker=$enableval)
libcwd_config_location=yes
AC_ARG_ENABLE(location,
[ --disable-location disable the ability to lookup source file and line
number, you might need this on a non-ELF32 system.],
libcwd_config_location=$enableval)
libcwd_config_debug=no
AC_ARG_ENABLE(debug,
[ --enable-debug enable debugging of libcwd itself.],
libcwd_config_debug=$enableval)
libcwd_config_debug_output=yes
AC_ARG_ENABLE(debug-output,
[ --disable-debug-output disable debug output of --enable-debug.],
libcwd_config_debug_output=$enableval)
libcwd_config_debugm=no
AC_ARG_ENABLE(debugm,
[ --enable-debugm enable debugging of memory allocation debugging code
in libcwd itself.],
libcwd_config_debugm=$enableval)
libcwd_config_threading=yes
AC_ARG_ENABLE(threading,
[ --disable-threading don't compile libcwd_r, the thread-safe version of
libcwd.],
libcwd_config_threading=$enableval)
libcwd_config_nonthreading=yes
AC_ARG_ENABLE(nonthreading,
[ --disable-nonthreading don't compile libcwd, the thread-unsafe version of
libcwd.],
libcwd_config_nonthreading=$enableval)
libcwd_config_debugt=no
AC_ARG_ENABLE(debugt,
[ --enable-debugt enable debugging of threading debugging code
in libcwd itself.],
libcwd_config_debugt=$enableval)
AC_ARG_VAR(THREADSMAX, [The maximum number of simultaneously running threads that are supported [1024].])
if test -z "$THREADSMAX"; then
THREADSMAX=1024
fi
AC_DEFINE_UNQUOTED([CW_THREADSMAX], $THREADSMAX, [The maximum number of simultaneously running threads that are supported.])
# Restore the environment variables used when running `configure' when
# `config.status --recheck' was invoked.
# Always let CXX and CXXCPP override cached values
CW_ENVIRONMENT
# Remember the original environment variable.
CXXFLAGS_env="$CXXFLAGS"
# Check for compiler and preprocessor.
if test -n "$CC"; then
unset ac_cv_prog_CC
unset am_cv_CC_dependencies_compiler_type
unset am_cv_CXX_dependencies_compiler_type
fi
AC_PROG_CC
AC_PROG_CXX
AC_PROG_CXXCPP
# __cxa_atexit not being used is always wrong, but not really our concern if we are configured with --disable-alloc.
if test x"$libcwd_config_alloc" = x"yes"; then
dnl Test if g++ was configured correctly.
CW_ATEXITTEST
fi
# Check if C compiler and C++ compiler versions match.
CW_COMPILER_VERSIONS
# Clear the cache values of all remaining tests if important
# environment variables have been changed since last run.
CW_CLEAN_CACHE
# Figure out linker characteristics
CW_RPATH_OPTION
# Checks for other programs.
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_AWK
AC_PATH_PROG(PS, ps, /bin/ps, $PATH)
# The PS_WIDE_PID_OPTION test is not needed when --disable-location is used.
if test x"$libcwd_config_location" = x"yes"; then
CW_SYS_PS_WIDE_PID_OPTION
fi
AC_DEFINE_UNQUOTED(CW_PATH_PROG_PS, "$PS", [Full path to the 'ps' executable.])
if test -e ./libtool -a "X$enable_shared" = "X"; then
dnl Configuration needed by the testsuite, extract this from the generated 'libtool'
enable_shared=`./libtool --config | grep '^build_libtool_libs=' | sed -e 's/build_libtool_libs=//'`
enable_static=`./libtool --config | grep '^build_old_libs=' | sed -e 's/build_old_libs=//'`
fi
# Used in sys.h to force recompilation.
CC_FINGER_PRINT="$cw_cv_sys_CC_finger_print"
AC_SUBST([CC_FINGER_PRINT])
CXX_FINGER_PRINT="$cw_cv_sys_CXX_finger_print"
AC_SUBST([CXX_FINGER_PRINT])
CXXCPP_FINGER_PRINT="$cw_cv_sys_CXXCPP_finger_print"
AC_SUBST([CXXCPP_FINGER_PRINT])
# Configuration defines of config.h.
AC_SUBST(CW_CONFIG_ALLOC)
CW_CONFIG_ALLOC=0
AC_SUBST(CW_CONFIG_MAGIC)
CW_CONFIG_MAGIC=0
AC_SUBST(CW_CONFIG_GLIBCXX_DEBUG)
CW_CONFIG_GLIBCXX_DEBUG=0
AC_SUBST(CW_CONFIG_LOCATION)
CW_CONFIG_LOCATION=0
AC_SUBST(CW_CONFIG_LIBBFD)
CW_CONFIG_LIBBFD=0
AC_SUBST(CW_CONFIG_DEBUG)
CW_CONFIG_DEBUG=0
AC_SUBST(CW_CONFIG_DEBUGOUTPUT)
CW_CONFIG_DEBUGOUTPUT=0
AC_SUBST(CW_CONFIG_DEBUGM)
CW_CONFIG_DEBUGM=0
AC_SUBST(CW_CONFIG_DEBUGT)
CW_CONFIG_DEBUGT=0
AC_SUBST(CW_CONFIG_MARKER)
CW_CONFIG_MARKER=0
AC_SUBST(CW_CONFIG_HAVE___LIBC_MALLOC)
CW_CONFIG_HAVE___LIBC_MALLOC=undef
AC_SUBST(CW_CONFIG_HAVE__LIBC_MALLOC)
CW_CONFIG_HAVE__LIBC_MALLOC=undef
AC_SUBST(CW_CONFIG_HAVE_DLOPEN)
CW_CONFIG_HAVE_DLOPEN=undef
AC_SUBST(CW_CONFIG_HAVE_POSIX_MEMALIGN)
CW_CONFIG_HAVE_POSIX_MEMALIGN=undef
AC_SUBST(CW_CONFIG_HAVE_ALIGNED_ALLOC)
CW_CONFIG_HAVE_ALIGNED_ALLOC=undef
AC_SUBST(CW_CONFIG_HAVE_MEMALIGN)
CW_CONFIG_HAVE_MEMALIGN=undef
AC_SUBST(CW_CONFIG_HAVE_VALLOC)
CW_CONFIG_HAVE_VALLOC=undef
# Configuration needed by the testsuite.
AC_SUBST(enable_shared)
AC_SUBST(enable_static)
AC_SUBST(libcwd_config_threading)
AC_SUBST(libcwd_config_nonthreading)
if test "$libcwd_config_alloc" = yes; then
CW_CONFIG_ALLOC=1
fi
if test "$libcwd_config_magic" = yes; then
CW_CONFIG_MAGIC=1
fi
PCCFLAGS="-DCWDEBUG"
AC_SUBST(PCCFLAGS)
if test "$libcwd_config_glibcxx_debug" = yes; then
CW_CONFIG_GLIBCXX_DEBUG=1
CXXFLAGS="$CXXFLAGS -D_GLIBCXX_DEBUG"
PCCFLAGS="$PCCFLAGS -D_GLIBCXX_DEBUG"
fi
PCCFLAGSR="$PCCFLAGS -DLIBCWD_THREAD_SAFE"
AC_SUBST(PCCFLAGSR)
# Set language requirements for the tests below.
AC_LANG([C++])
AC_REQUIRE_CPP
AC_CHECK_FUNCS(__libc_malloc _libc_malloc)
if test "$libcwd_config_location" = yes -o \
\("$ac_cv_func___libc_malloc" != yes -a "$ac_cv_func__libc_malloc" != yes\) ; then
# Check if we have dlopen in libc or libdl.
AC_CHECK_LIB(c, dlopen, [AC_DEFINE_UNQUOTED(HAVE_DLOPEN, 1, [Defined if dlopen is available.])],
[AC_CHECK_LIB(dl, dlopen, [LIBS="-ldl $LIBS"; AC_DEFINE_UNQUOTED(HAVE_DLOPEN)])])
fi
if test "$libcwd_config_location" = yes ; then
CW_CONFIG_LOCATION=1
fi
AC_SUBST(CW_CONFIG_HAVE_PTHREADS)
CW_CONFIG_HAVE_PTHREADS=undef
AC_SUBST(LIB_THREADS)
AC_SUBST(LIB_THREADS_SHARED)
if test "$libcwd_config_threading" = yes; then
dnl Check if we have POSIX threads
AC_LANG_SAVE
AC_LANG([C])
CFLAGS="-pthread"
AC_SEARCH_LIBS(pthread_create, pthread,
[AC_CHECK_HEADER(pthread.h,
[CW_CONFIG_HAVE_PTHREADS=define],
[AC_MSG_WARN([
**************************************************************************
* Sorry but libcwd only supports POSIX Threads at the moment and I can't *
* find the header file pthread.h. Only the thread unsafe library libcwd *
* will be compiled. Use --disable-threading to suppress this warning. *
**************************************************************************
])
libcwd_config_threading=no])],
[AC_MSG_WARN([
**************************************************************************
* Sorry but libcwd only supports POSIX Threads at the moment. Your libc *
* doesn't include posix threads by itself and I can't find -lpthread. *
* Use --disable-threading to suppress this warning. *
**************************************************************************
])
libcwd_config_threading=no])
if test "$libcwd_config_threading" = yes; then
if test "$ac_cv_search_pthread_create" = "none required"; then
dnl Even if nothing is required, we still need to use -lpthread explicitly
dnl while linking a shared library, otherwise the versioning info of
dnl versioned symbols will be missing! This is needed for pthread_create
dnl itself even!.
AC_CHECK_LIB(pthread, pthread_create, [LIB_THREADS_SHARED=-lpthread])
fi
fi
AC_LANG_RESTORE
if test "$libcwd_config_threading" = yes; then
dnl pthread_kill_other_threads_np is a GNU extension, therefore we need to
dnl define _GNU_SOURCE. The extension also needs -lpthread to be available.
AC_DEFINE_UNQUOTED(CW_NEED__GNU_SOURCE, 1, [This is needed when using threading, for example to get 'pthread_kill_other_threads_np'.])
SAVE_LIBS="$LIBS"
LIBS="$LIBS $LIB_THREADS $LIB_THREADS_SHARED"
AC_CHECK_FUNCS(pthread_kill_other_threads_np)
LIBS="$SAVE_LIBS"
fi
fi
# This test needs the full set of libraries we just determined.
#CW_SYS_BUILTIN_RETURN_ADDRESS_OFFSET
if test "$libcwd_config_debug" = yes; then
CW_CONFIG_DEBUG=1
fi
if test "$libcwd_config_debug_output" = yes; then
CW_CONFIG_DEBUGOUTPUT=1
fi
if test "$libcwd_config_debugm" = yes; then
CW_CONFIG_DEBUGM=1
fi
if test "$libcwd_config_debugt" = yes; then
CW_CONFIG_DEBUGT=1
fi
if test "$libcwd_config_marker" = yes; then
CW_CONFIG_MARKER=1
fi
AM_CONDITIONAL(ENABLETHREADING, test x$libcwd_config_threading = xyes)
AM_CONDITIONAL(ENABLENONTHREADING, test x$libcwd_config_nonthreading = xyes)
AM_CONDITIONAL(ENABLESHARED, test x$enable_shared = xyes)
AM_CONDITIONAL(ENABLESTATIC, test x$enable_static = xyes)
# Checks for header files.
AC_HEADER_STAT
AC_CHECK_HEADERS(_G_config.h link.h pwd.h sys/resource.h malloc.h unistd.h)
# Check for global variable.
if test "$ac_cv_header_link_h" = yes; then
AC_CHECK_FUNCS(_dl_loaded _rtld_global)
fi
# Check for typedefs.
AC_TYPE_UID_T
CW_TYPE_GETGROUPS
# Check for structures.
# Check for compiler/system characteristics.
CW_BUG_REDEFINES([sys/resource.h])
CW_SYS_MALLOC_OVERHEAD
CW_BUG_G_CONFIG_H
CW_SYS_RECURSIVE_BUILTIN_RETURN_ADDRESS
CW_SYS_FRAME_ADDRESS_OFFSET
AC_C_BIGENDIAN
# Check for library functions.
AC_CHECK_FUNCS(getgid getegid getgroups wmemcpy sysconf valloc memalign aligned_alloc)
AC_CHECK_DECL([_SC_PAGESIZE],
AC_DEFINE_UNQUOTED([HAVE__SC_PAGESIZE], 1, [Defined if we have _SC_PAGESIZE.]),
[], [#include <unistd.h>])
AC_CHECK_DECL([posix_memalign],
AC_DEFINE_UNQUOTED([HAVE_POSIX_MEMALIGN], 1, [Defined if we have posix_memalign.]), [],
[#define _XOPEN_SOURCE 600
#include <cstdlib>])
if test "$ac_cv_func___libc_malloc" = "yes"; then
CW_CONFIG_HAVE___LIBC_MALLOC=define
else if test "$ac_cv_func__libc_malloc" = "yes"; then
CW_CONFIG_HAVE__LIBC_MALLOC=define
fi fi
if test "$ac_cv_lib_c_dlopen" = "yes" -o "$ac_cv_lib_dl_dlopen" = "yes"; then
CW_CONFIG_HAVE_DLOPEN=define
fi
if test "$ac_cv_func_valloc" = "yes"; then
CW_CONFIG_HAVE_VALLOC=define
fi
if test "$ac_cv_func_memalign" = "yes"; then
CW_CONFIG_HAVE_MEMALIGN=define
fi
if test "$ac_cv_have_decl_posix_memalign" = "yes"; then
CW_CONFIG_HAVE_POSIX_MEMALIGN=define
fi
if test "$ac_cv_func_aligned_alloc" = "yes"; then
CW_CONFIG_HAVE_ALIGNED_ALLOC=define
fi
# Check for system services.
# Set up build directory
test ! -d include && mkdir include
# The install prefix is hardcoded in the library in order to find the default rc file.
libcwd_datarootdir=`eval echo "$datadir"`
libcwd_datadir=`eval echo "$libcwd_datarootdir/$PACKAGE" | sed -e 's|NONE|'$ac_default_prefix'|'`
AC_DEFINE_UNQUOTED([CW_DATADIR], "$libcwd_datadir", [Data directory where the default rcfile is read from.])
# Generate include/libcwd/config.h, include/libcwd/sys.h and include/sys.h, preserving timestamp when they are not changed.
CW_CONFIG_FILE([include/libcwd], [config.h])
CW_CONFIG_FILE([include/libcwd], [sys.h])
CW_CONFIG_FILE([include], [sys.h])
# Output the other configuration files.
AC_CONFIG_FILES([libcwd.spec] [libcwd.lsm] [maintMakefile] [utils/Makefile] [include/Makefile]
[include/libcwd/Makefile] [testsuite/Makefile] [cutee/Makefile] [tests/Makefile]
[doc/styles/Makefile] [doc/tutorial/Makefile] [libcwd.pc] [libcwd_r.pc])
# Include cwm4 footer.
m4_include([cwm4/configure_ac_bottom.m4])