2
dnl ## OSSP sa - Socket Abstraction
3
dnl ## Copyright (c) 2001-2004 Ralf S. Engelschall <rse@engelschall.com>
4
dnl ## Copyright (c) 2001-2004 The OSSP Project <http://www.ossp.org/>
5
dnl ## Copyright (c) 2001-2004 Cable & Wireless <http://www.cw.com/>
7
dnl ## This file is part of OSSP sa, a socket abstraction library which
8
dnl ## can be found at http://www.ossp.org/pkg/lib/sa/.
10
dnl ## Permission to use, copy, modify, and distribute this software for
11
dnl ## any purpose with or without fee is hereby granted, provided that
12
dnl ## the above copyright notice and this permission notice appear in all
15
dnl ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
16
dnl ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17
dnl ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18
dnl ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
19
dnl ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
dnl ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21
dnl ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
22
dnl ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
dnl ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
dnl ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25
dnl ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28
dnl ## aclocal.m4: GNU Autoconf local macro definitions
32
dnl ## Check whether compiler option works
35
dnl ## AC_COMPILER_OPTION(<name>, <display>, <option>,
36
dnl ## <action-success>, <action-failure>)
39
AC_DEFUN(AC_COMPILER_OPTION,[dnl
40
AC_MSG_CHECKING(whether compiler option(s) $2 work)
41
AC_CACHE_VAL(ac_cv_compiler_option_$1,[
44
AC_TRY_COMPILE([],[], ac_cv_compiler_option_$1=yes, ac_cv_compiler_option_$1=no)
47
if test ".$ac_cv_compiler_option_$1" = .yes; then
48
ifelse([$4], , :, [$4])
50
ifelse([$5], , :, [$5])
52
AC_MSG_RESULT([$ac_cv_compiler_option_$1])
56
dnl ## Debugging Support
59
dnl ## AC_CHECK_DEBUGGING
62
AC_DEFUN(AC_CHECK_DEBUGGING,[dnl
63
AC_ARG_ENABLE(debug,dnl
64
[ --enable-debug build for debugging (default=no)],
66
if test ".$ac_cv_prog_gcc" = ".yes"; then
69
* ) CFLAGS="$CFLAGS -O2" ;;
73
* ) CFLAGS="$CFLAGS -g" ;;
77
* ) AC_COMPILER_OPTION(pipe, -pipe, -pipe, CFLAGS="$CFLAGS -pipe") ;;
79
AC_COMPILER_OPTION(defdbg, -DDEBUG, -DDEBUG, CFLAGS="$CFLAGS -DDEBUG")
80
CFLAGS="$CFLAGS -pedantic"
81
CFLAGS="$CFLAGS -Wall"
83
WMORE="$WMORE -Wbad-function-cast"
84
WMORE="$WMORE -Wcast-align"
85
WMORE="$WMORE -Winline"
86
WMORE="$WMORE -Wmissing-declarations"
87
WMORE="$WMORE -Wmissing-prototypes"
88
WMORE="$WMORE -Wmultichar"
89
WMORE="$WMORE -Wnested-externs"
90
WMORE="$WMORE -Wno-system-headers"
91
WMORE="$WMORE -Wpointer-arith"
92
WMORE="$WMORE -Wredundant-decls"
93
WMORE="$WMORE -Wshadow"
94
WMORE="$WMORE -Wstrict-prototypes"
95
AC_COMPILER_OPTION(wmore, -W<xxx>, $WMORE, CFLAGS="$CFLAGS $WMORE")
96
AC_COMPILER_OPTION(wnolonglong, -Wno-long-long, -Wno-long-long, CFLAGS="$CFLAGS -Wno-long-long")
100
* ) CFLAGS="$CFLAGS -g" ;;
105
if test ".$ac_cv_prog_gcc" = ".yes"; then
108
* ) AC_COMPILER_OPTION(pipe, -pipe, -pipe, CFLAGS="$CFLAGS -pipe") ;;
112
*-g* ) CFLAGS=`echo "$CFLAGS" |\
113
sed -e 's/ -g / /g' -e 's/ -g$//' -e 's/^-g //g' -e 's/^-g$//'` ;;
116
*-g* ) CXXFLAGS=`echo "$CXXFLAGS" |\
117
sed -e 's/ -g / /g' -e 's/ -g$//' -e 's/^-g //g' -e 's/^-g$//'` ;;
121
AC_MSG_CHECKING(for compilation debug mode)
122
AC_MSG_RESULT([$msg])
123
if test ".$msg" = .enabled; then
129
dnl ## Check for an external/extension library.
130
dnl ## - is aware of <libname>-config style scripts
131
dnl ## - searches under standard paths include, lib, etc.
132
dnl ## - searches under subareas like .libs, etc.
135
dnl ## AC_CHECK_EXTLIB(<realname>, <libname>, <func>, <header>,
136
dnl ## [<success-action> [, <fail-action>]])
138
dnl ## CFLAGS = @CFLAGS@
139
dnl ## LDFLAGS = @LDFLAGS@
142
dnl ## $ ./configure --with-<libname>[=DIR]
145
AC_DEFUN(AC_CHECK_EXTLIB,[dnl
147
[ --with-]m4_substr([$2[[=DIR]] ], 0, 19)[build with external $1 library (default=no)]], [dnl
148
if test ".$with_$2" = .yes; then
149
# via config script in PATH
150
$2_version=`($2-config --version) 2>/dev/null`
151
if test ".$$2_version" != .; then
152
CPPFLAGS="$CPPFLAGS `$2-config --cflags`"
153
CFLAGS="$CFLAGS `$2-config --cflags`"
154
LDFLAGS="$LDFLAGS `$2-config --ldflags`"
157
if test -d "$with_$2"; then
160
for dir in $with_$2/bin $with_$2; do
161
if test -f "$dir/$2-config" && test ! -f "$dir/$2-config.in"; then
162
$2_version=`($dir/$2-config --version) 2>/dev/null`
163
if test ".$$2_version" != .; then
164
CPPFLAGS="$CPPFLAGS `$dir/$2-config --cflags`"
165
CFLAGS="$CFLAGS `$dir/$2-config --cflags`"
166
LDFLAGS="$LDFLAGS `$dir/$2-config --ldflags`"
172
# in standard sub-areas
173
if test ".$found" = .0; then
174
for dir in $with_$2/include/$2 $with_$2/include $with_$2; do
175
if test -f "$dir/$4"; then
176
CPPFLAGS="$CPPFLAGS -I$dir"
177
CFLAGS="$CFLAGS -I$dir"
182
for dir in $with_$2/lib/$2 $with_$2/lib $with_$2; do
183
if test -f "$dir/lib$2.la" && test -d "$dir/.libs"; then
184
LDFLAGS="$LDFLAGS -L$dir -L$dir/.libs"
187
elif test -f "$dir/lib$2.a" || test -f "$dir/lib$2.so"; then
188
LDFLAGS="$LDFLAGS -L$dir"
195
if test ".$found" = .0; then
197
for file in x `find $with_$2 -name "$4" -type f -print`; do
198
test .$file = .x && continue
199
dir=`echo $file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'`
200
CPPFLAGS="$CPPFLAGS -I$dir"
201
CFLAGS="$CFLAGS -I$dir"
203
for file in x `find $with_$2 -name "lib$2.[aso]" -type f -print`; do
204
test .$file = .x && continue
205
dir=`echo $file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'`
206
LDFLAGS="$LDFLAGS -L$dir"
215
ac_var="ac_cv_header_`echo $4 | sed 'y%./+-%__p_%'`"
216
eval "ac_val=\$$ac_var"
217
if test ".$ac_val" != .yes; then
220
if test ".$ac_cv_lib_$2_$3" != .yes; then
223
if test ".$with_$2" = .no; then
224
AC_ERROR([Unable to find $1 library])
227
if test ".$with_$2" = .; then
231
AC_MSG_CHECKING(whether to build against external $1 library)
232
if test ".$with_$2" = .yes; then
233
ifelse([$5], , :, [$5])
235
ifelse([$6], , :, [$6])
237
AC_MSG_RESULT([$with_$2])