-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathacinclude.m4
More file actions
262 lines (243 loc) · 8.11 KB
/
acinclude.m4
File metadata and controls
262 lines (243 loc) · 8.11 KB
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
dnl @synopsis ACX_LOCATEFILE(filename,path-list,[action if found],[action if not found])
dnl
dnl Locates a file in a given search path
dnl
dnl the directory containing the target file is available as acx_founddir
dnl the path-list is available as acx_searchpath
dnl
dnl Author: Derek Feichtinger <derek.feichtinger@cern.ch>
dnl
dnl Version info: $Id: acinclude.m4,v 1.6 2008/05/19 11:36:17 dfeich Exp $
dnl Checked in by $Author: dfeich $
dnl ========================================================================
AC_DEFUN([ACX_LOCATEFILE],[
acx_searchpath="$2"
acx_founddir=""
AC_MSG_CHECKING([for $1 in $2])
for dir in $2 ; do
if test -f "$[]dir/$1" ; then
acx_founddir="$[]dir/"
break
fi
done
if test x"$[]acx_founddir" = x ; then
AC_MSG_RESULT([no])
ifelse([$4], ,: ,[$4])
else
AC_MSG_RESULT([found])
ifelse([$3], ,: ,[$3])
fi
])
dnl @synopsis ACX_MSG_ERROR(error-message)
dnl
dnl like AC_MSG_ERROR, but also prints out some important
dnl environment settings
AC_DEFUN([ACX_MSG_ERROR],[
AC_MSG_ERROR([$1
(CPPFLAGS="$[]CPPFLAGS) (LDFLAGS="$[]LDFLAGS")
(CFLAGS="$[]CFLAGS") (CXXFLAGS="$[]CXXFLAGS")])
])
dnl @synopsis ACX_WITH_BASEDIR
dnl ############################################################
dnl # give the user an easy way to specify a base installation
dnl # directory dir, where headers and libraries are found in
dnl # $dir/include and $dir/lib
AC_DEFUN([ACX_WITH_BASEDIR],[
AC_ARG_WITH(base-directory,
[ --with-base-directory=PATH add PATH/include and PATH/lib to search paths],
[
acx_base_incdir="$withval/include"
acx_base_libdir="$withval/lib"
acx_base_bindir="$withval/bin"
BASE_INCDIR="-I$withval/include"
BASE_LIBDIR="-L$withval/lib"
]
)
AC_SUBST(BASE_INCDIR)
AC_SUBST(BASE_LIBDIR)
])
dnl @synopsis ACX_COLLECT_OPTION(optionname,[optvalue])
dnl collects option names for an informative printout with
dnl the ACX_PRINTOPTIONS macro. Relies on the existence of
dnl an associated activate_FEATURE variable
AC_DEFUN([ACX_COLLECT_OPTION],[
acx_optionvar="$[]acx_optionvar $1"
ifelse($2, , :,activate_$1=$2)
#opt activate_$1=default_yes|default_no
])
dnl @synopsis ACX_LIBOPTION(optionname,enable-help-text,[yes|no])
dnl
dnl a default value for activate_FEATURE set before the evaluation of this
dnl macro will be honored.
dnl all options get collected in acx_optionvar for later printout with
dnl the ACX_PRINTOPTIONS macro
dnl specifying one of the --with-feature-*dir options will set the activate
dnl state of the feature to yes, except if it has been deliberately turned off
dnl with the --enable-feature=no or --disable-feature options
AC_DEFUN([ACX_LIBOPTION],[
if test x"$[]activate_$1" = x; then
ifelse($3, yes,activate_$1=default_yes,activate_$1=default_no)
fi
AC_ARG_ENABLE($1,[[ --enable-$1 $2 (default=$3)]],[[activate_$1=$enableval]],[[:]])
AC_ARG_WITH($1-libdir,[[ --with-$1-libdir=PATH path containing $1 library]],
[acx_$1_libdir=$[]withval
if test $[]activate_$1 = default_no; then activate_$1=yes;fi
if test $[]activate_$1 = default_yes; then activate_$1=yes;fi
])
AC_ARG_WITH($1-incdir,[[ --with-$1-incdir=PATH path containing $1 headers]],
[acx_$1_incdir=$[]withval
if test $[]activate_$1 = default_no; then activate_$1=yes;fi
if test $[]activate_$1 = default_yes; then activate_$1=yes;fi
])
if test x"$[]acx_$1_libdir" != x; then
translit($1,`a-z',`A-Z')_LIBDIR="-L$[]acx_$1_libdir"
fi
if test x"$[]acx_$1_incdir" != x; then
translit($1,`a-z',`A-Z')_INCDIR="-I$[]acx_$1_incdir"
fi
AC_SUBST(translit($1,`a-z',`A-Z')_LIBDIR)
AC_SUBST(translit($1,`a-z',`A-Z')_INCDIR)
ACX_COLLECT_OPTION($1)
#opt acx_$1_libdir=PATH
#opt acx_$1_incdir=PATH
])
dnl @synopsis ACX_PRINTOPTIONS
dnl
dnl prints a summary about option selections and default files
dnl that have been read.
dnl Relies on the oprions having been recorded by ACX_COLLECT_OPTION
dnl or ACX_LIBOPTION and default files having been read with ACX_LOAD_DEFAULTS
AC_DEFUN([ACX_PRINTOPTIONS],[
echo
if test x"$[]acx_defaultfiles" != x; then
echo "Defaults read from: $[]acx_defaultfiles"
fi
echo "SELECTED OPTIONS"
echo "----------------"
for opt in $[]acx_optionvar; do
optvar="activate_$[]opt"
optval="\$$[]optvar"
optval=`eval echo "$[]optval"`
optinc=acx_"$[]opt"_incdir
optincval="\$$[]optinc"
optincval=`eval echo "$[]optincval"`
optlib=acx_"$[]opt"_libdir
optlibval="\$$[]optlib"
optlibval=`eval echo "$[]optlibval"`
defaultval=`expr x"$[]optval" : 'xdefault_\(.*\)'`
if test x"$[]defaultval" != x; then
optval=$[]defaultval
bydefault="(by default)"
else
bydefault=" "
fi
if test x"$[]optval" != xyes; then
optincval="";optlibval=""
fi
echo "$[]opt: $[]optval $[]bydefault $[]optincval $[]optlibval"
done
])
dnl @synopsis ACX_LOAD_DEFAULTS(filename)
dnl
dnl Loads (sources) a file containing default settings.
dnl The location of the file has to be given relative
dnl to the srcdir
AC_DEFUN([ACX_LOAD_DEFAULTS],[
acx_tmp="$[]srcdir/$1"
AC_MSG_CHECKING([for defaults file $[]acx_tmp])
if test -r "$[]acx_tmp"; then
AC_MSG_RESULT([found - sourcing...])
source $[]acx_tmp
acx_defaultfiles="$acx_defaultfiles $[]acx_tmp"
else
AC_MSG_RESULT([NOT FOUND])
fi
])
dnl AX_HAVE_EPOLL([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl AX_HAVE_EPOLL_PWAIT([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl (c) 2008 Peter Simons <simons@cryp.to>
dnl http://autoconf-archive.cryp.to/ax_have_epoll.html
dnl
dnl modified the acceptable Unix version for AX_HAVE_EPOLL
dnl to be 2,6,12 (original macro had 2.5.45)
AC_DEFUN([AX_HAVE_EPOLL], [dnl
ax_have_epoll_cppflags="${CPPFLAGS}"
AC_CHECK_HEADER([linux/version.h], [CPPFLAGS="${CPPFLAGS} -DHAVE_LINUX_VERSION_H"])
AC_MSG_CHECKING([for Linux epoll(7) interface])
AC_CACHE_VAL([ax_cv_have_epoll], [dnl
AC_LINK_IFELSE([dnl
AC_LANG_PROGRAM([dnl
#include <sys/epoll.h>
#ifdef HAVE_LINUX_VERSION_H
# include <linux/version.h>
# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
# error linux kernel version is too old to have epoll
# endif
#endif
], [dnl
int fd, rc;
struct epoll_event ev;
fd = epoll_create(128);
rc = epoll_wait(fd, &ev, 1, 0);])],
[ax_cv_have_epoll=yes],
[ax_cv_have_epoll=no])])
CPPFLAGS="${ax_have_epoll_cppflags}"
AS_IF([test "${ax_cv_have_epoll}" = "yes"],
[AC_MSG_RESULT([yes])
$1],[AC_MSG_RESULT([no])
$2])
])dnl
AC_DEFUN([AX_HAVE_EPOLL_PWAIT], [dnl
ax_have_epoll_cppflags="${CPPFLAGS}"
AC_CHECK_HEADER([linux/version.h],
[CPPFLAGS="${CPPFLAGS} -DHAVE_LINUX_VERSION_H"])
AC_MSG_CHECKING([for Linux epoll(7) interface with signals extension])
AC_CACHE_VAL([ax_cv_have_epoll_pwait], [dnl
AC_LINK_IFELSE([dnl
AC_LANG_PROGRAM([dnl
#ifdef HAVE_LINUX_VERSION_H
# include <linux/version.h>
# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
# error linux kernel version is too old to have epoll_pwait
# endif
#endif
#include <sys/epoll.h>
#include <signal.h>
], [dnl
int fd, rc;
struct epoll_event ev;
fd = epoll_create(128);
rc = epoll_wait(fd, &ev, 1, 0);
rc = epoll_pwait(fd, &ev, 1, 0, (sigset_t const *)(0));])],
[ax_cv_have_epoll_pwait=yes],
[ax_cv_have_epoll_pwait=no])])
CPPFLAGS="${ax_have_epoll_cppflags}"
AS_IF([test "${ax_cv_have_epoll_pwait}" = "yes"],
[AC_MSG_RESULT([yes])
$1],[AC_MSG_RESULT([no])
$2])
])dnl
dnl AC_SYS_DEV_POLL([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl Dave Benson <daveb@ffem.org> 2008-04-12
dnl from http://autoconf-archive.cryp.to/ac_sys_dev_poll.html
dnl
AC_DEFUN([AC_SYS_DEV_POLL], [AC_CACHE_CHECK(for /dev/poll support, ac_cv_dev_poll,
AC_TRY_COMPILE([#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/poll.h>
#include <sys/devpoll.h>],
[
struct dvpoll p;
p.dp_timeout = 0;
p.dp_nfds = 0;
p.dp_fds = (struct pollfd *) 0;
return 0;
],
ac_cv_dev_poll=yes
[$1],
ac_cv_dev_poll=no
[$2]
)
)
])