-
Notifications
You must be signed in to change notification settings - Fork 6
/
acinclude.m4
142 lines (136 loc) · 4.34 KB
/
acinclude.m4
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
dnl $Id$
dnl local macro definitions for M's configure.in
dnl package,message,variable,default,helpmessage
AC_DEFUN([M_OVERRIDES],
[AC_MSG_CHECKING(for $2)
define([M_FUNC], regexp([$5], [--[^-]*-], \&))dnl
define([M_VAR],
ifelse( M_FUNC,--with-, withval,
M_FUNC,--without-, withval,
M_FUNC,--enable-, enableval,
M_FUNC,--disable-, enableval,
withval))dnl
define([M_FUNC],
ifelse(M_VAR, enableval, [defn([AC_ARG_ENABLE])],
[defn([AC_ARG_WITH])]))dnl
M_FUNC($1,[ $5],
[case "$]M_VAR[" in
yes) m_cv_$3=1 ;;
no) m_cv_$3=0 ;;
*) m_cv_$3="$]M_VAR[" ;;
esac],
AC_CACHE_VAL(m_cv_$3,m_cv_$3='$4')[dnl])dnl
undefine([M_FUNC])undefine([M_VAR])dnl
$3="$m_cv_$3"
case "$m_cv_$3" in
''|0) AC_MSG_RESULT(no) ;;
1) AC_MSG_RESULT(yes) ;;
*) AC_MSG_RESULT($m_cv_$3) ;;
esac])
dnl M_CHECK_MYLIB(LIBRARY, FUNCTION, LIBPATHLIST [, ACTION-IF-FOUND
dnl [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES [, EXTRA-MSG]]]])
AC_DEFUN([M_CHECK_MYLIB],
[AC_MSG_CHECKING([for $2 in -l$1$7])
dnl Use a cache variable name containing both the library and function name,
dnl because the test really is for library $1 defining function $2, not
dnl just for library $1. Separate tests with the same $1 and different $2s
dnl may have different results.
m_lib_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'`
AC_CACHE_VAL(m_cv_lib_$m_lib_var,
[m_save_LIBS="$LIBS"
for j in "." $3 ; do
LIBS="-L$j -l$1 $6 $LIBS"
AC_TRY_LINK(dnl
ifelse([$2], [main], , dnl Avoid conflicting decl of main.
[/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char $2();
]),
[$2()],
[eval "m_cv_lib_$m_lib_var=\"libpath_$m_lib_var=-L$j\""
eval eval "`echo '$m_cv_lib_'$m_lib_var`"
LIBS="$m_save_LIBS"
break
],
eval "m_cv_lib_$m_lib_var=no")
LIBS="$m_save_LIBS"
done
])dnl
if eval "test \"`echo '$m_cv_lib_'$m_lib_var`\" != no"; then
if test x$j = "x."; then
unset j
fi
AC_MSG_RESULT(yes (in ${j-standard location}))
eval eval "`echo '$m_cv_lib_'$m_lib_var`"
ifelse([$4], ,
[ changequote(, )dnl
m_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
changequote([, ])dnl
AC_DEFINE_UNQUOTED($m_tr_lib)
eval eval "`echo '$m_cv_lib_'$m_lib_var`"
eval "LIBS=\"`echo '$libpath_'$m_lib_var` -l$1 $LIBS\""
], [$4])
else
AC_MSG_RESULT(no)
ifelse([$5], , , [$5])dnl
fi
])
dnl M_CHECK_MYHEADER(HEADER-FILE, LIBPATHLIST, [ACTION-IF-FOUND
dnl [, ACTION-IF-NOT-FOUND [, EXTRA-MSG [, EXTRA-SUFFIX]]]])
dnl
dnl Explanation of not obvious arguments:
dnl EXTRA-MSG is an additional message printed after standardd one
dnl ("checking for header")
dnl EXTRA-SUFFIX is the extra suffix to add to the cache variable, useful
dnl when you need to check for the same header in different
dnl paths (example: Python.h)
AC_DEFUN([M_CHECK_MYHEADER],
[ m_safe=`echo "$1$6" | sed 'y%./+-%__p_%'`
AC_MSG_CHECKING([for $1$5])
AC_CACHE_VAL(m_cv_header_$m_safe,
[ m_save_CPPFLAGS="$CPPFLAGS"
for j in "." $2 ; do
CPPFLAGS="-I$j $CPPFLAGS"
AC_TRY_CPP(dnl
[#include <$1>],
[
if test "$j" = "."; then
j="/usr/include"
fi
eval "m_cv_header_$m_safe=$j"
CPPFLAGS="$m_save_CPPFLAGS"
break
],
[ eval "m_cv_header_$m_safe=no" ]
)
CPPFLAGS="$m_save_CPPFLAGS"
done
]
)
if eval "test \"`echo '$m_cv_header_'$m_safe`\" != no"; then
dnl FIXME surely there must be a simpler way? (VZ)
dir=`eval echo $\`eval echo m_cv_header_$m_safe\``
if test x$dir != x"/usr/include"; then
dirshow=$dir
eval "CPPFLAGS=\"-I$dir $CPPFLAGS\""
fi
AC_MSG_RESULT(yes (in ${dirshow-standard location}))
ifelse([$3], , :, [$3])
else
AC_MSG_RESULT(no)
ifelse([$4], , , [$4])dnl
fi
]
)
dnl M_ADD_CXXFLAGS_IF_SUPPORTED(OPTION)
dnl
dnl Check if the C++ compiler supports the given option and adds it to CXXFLAGS
dnl if it does.
AC_DEFUN([M_ADD_CXXFLAGS_IF_SUPPORTED], [
AX_CXX_CHECK_FLAG($1,,,[CXXFLAGS="$CXXFLAGS $1"])
])