3 # AMANDA_FUNC_SELECT_ARG_TYPE
7 # Figure out the select() argument type. DEFINEs SELECT_ARG_TYPE.
9 AC_DEFUN([AMANDA_FUNC_SELECT_ARG_TYPE],
11 AC_REQUIRE([AC_HEADER_TIME])
21 [for select() argument type],
22 amanda_cv_select_arg_type,
25 cat <<EOF >conftest.$ac_ext
27 #ifdef TIME_WITH_SYS_TIME
28 # include <sys/time.h>
31 # ifdef HAVE_SYS_TIME_H
32 # include <sys/time.h>
37 #ifdef HAVE_SYS_TYPES_H
38 # include <sys/types.h>
40 #ifdef HAVE_SYS_SELECT_H
41 # include <sys/select.h>
43 #ifdef HAVE_SYS_SOCKET_H
44 # include <sys/socket.h>
53 (void)select(0, (fd_set *) 0, (fd_set *) 0, (fd_set *) 0, 0);
55 (void)select(0, (int *) 0, (int *) 0, (int *) 0, 0);
61 # Figure out the select argument type by first trying to
62 # compile with the fd_set argument. If the compile fails,
63 # then we know to use the int. If it suceeds, then try to
64 # use the int. If the int fails, then use fd_set. If
65 # both suceeed, then do a line count on the number of
66 # lines that the compiler spit out, assuming that the
67 # compile outputing more lines had more errors.
68 amanda_cv_select_arg_type=no
69 select_compile="${CC-cc} -c $CFLAGS $CPPFLAGS"
70 $select_compile -DFD_SET_POINTER conftest.$ac_ext 1>conftest.fd_set 2>&1
71 if test $? -ne 0; then
72 amanda_cv_select_arg_type=int
74 if test "$amanda_cv_select_arg_type" = no; then
75 $select_compile conftest.$ac_ext 1>conftest.int 2>&1
76 if test $? -ne 0; then
77 amanda_cv_select_arg_type=fd_set
80 if test "$amanda_cv_select_arg_type" = no; then
81 wc_fdset=`wc -l <conftest.fd_set`
82 wc_int=`wc -l <conftest.int`
83 if test "$wc_fdset" -le "$wc_int"; then
84 amanda_cv_select_arg_type=fd_set
86 amanda_cv_select_arg_type=int
92 AC_DEFINE_UNQUOTED(SELECT_ARG_TYPE,$amanda_cv_select_arg_type,[Define to type of select arguments. ])
98 # AMANDA_FUNC_SETSOCKOPT_SO_SNDTIMEO
102 # Check if setsockopt can use the SO_SNDTIMEO option.
103 # This defines HAVE_SO_SNDTIMEO if setsockopt works with SO_SNDTIMEO.
105 AC_DEFUN([AMANDA_FUNC_SETSOCKOPT_SO_SNDTIMEO],
107 AC_REQUIRE([AC_HEADER_TIME])
114 [for setsockopt SO_SNDTIMEO option],
115 amanda_cv_setsockopt_SO_SNDTIMEO,
119 #include <sys/types.h>
120 #include <sys/socket.h>
121 #ifdef TIME_WITH_SYS_TIME
122 # include <sys/time.h>
125 # ifdef HAVE_SYS_TIME_H
126 # include <sys/time.h>
134 int sock = socket(AF_INET, SOCK_STREAM, 0);
135 struct timeval timeout;
138 return (setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO,
139 (void *)&timeout, sizeof(timeout)));
145 amanda_cv_setsockopt_SO_SNDTIMEO=yes,
146 amanda_cv_setsockopt_SO_SNDTIMEO=no,
147 amanda_cv_setsockopt_SO_SNDTIMEO=no
151 if test "$amanda_cv_setsockopt_SO_SNDTIMEO" = yes; then
152 AC_DEFINE(HAVE_SO_SNDTIMEO,1,[Define if SO_SNDTIMEO is available. ])
159 # AMANDA_FUNC_GETTIMEOFDAY_ARGS
163 # Check for the one or two argument version of gettimeofday. DEFINEs
164 # HAVE_TWO_ARG_GETTIMEOFDAY if the two argument version is present.
166 AC_DEFUN([AMANDA_FUNC_GETTIMEOFDAY_ARGS],
168 AC_REQUIRE([AC_HEADER_TIME])
175 [for gettimeofday number of arguments],
176 amanda_cv_gettimeofday_args,
180 #ifdef TIME_WITH_SYS_TIME
181 # include <sys/time.h>
184 # ifdef HAVE_SYS_TIME_H
185 # include <sys/time.h>
193 struct timezone zone;
194 gettimeofday(&val, &zone);
196 amanda_cv_gettimeofday_args=2,
197 amanda_cv_gettimeofday_args=1
201 if test "$amanda_cv_gettimeofday_args" = 2; then
202 AC_DEFINE(HAVE_TWO_ARG_GETTIMEOFDAY,1,[Define if gettimeofday takes two arguments. ])
209 # ICE_CHECK_DECL (FUNCTION, HEADER-FILE...)
213 # If FUNCTION is available, define `HAVE_FUNCTION'. If it is declared
214 # in one of the headers named in the whitespace-separated list
215 # HEADER_FILE, define `HAVE_FUNCTION_DECL` (in all capitals).
217 AC_DEFUN([ICE_CHECK_DECL],
220 AC_CHECK_FUNCS($1, ice_have_$1=yes)
221 if test "${ice_have_$1}" = yes; then
222 AC_MSG_CHECKING(for $1 declaration in $2)
223 AC_CACHE_VAL(ice_cv_have_$1_decl,
225 ice_cv_have_$1_decl=no
227 ice_re_params='[a-zA-Z_][a-zA-Z0-9_]*'
228 ice_re_word='(^|[^a-zA-Z0-9_])'
231 # Check for ordinary declaration
232 AC_EGREP_HEADER([${ice_re_word}$1[ ]*\(], $header,
233 ice_cv_have_$1_decl=yes)
234 if test "$ice_cv_have_$1_decl" = yes; then
237 # Check for "fixed" declaration like "getpid _PARAMS((int))"
238 AC_EGREP_HEADER([${ice_re_word}$1[ ]*$ice_re_params\(\(], $header,
239 ice_cv_have_$1_decl=yes)
240 if test "$ice_cv_have_$1_decl" = yes; then
245 AC_MSG_RESULT($ice_cv_have_$1_decl)
246 if test "$ice_cv_have_$1_decl" = yes; then
247 AC_DEFINE_UNQUOTED([HAVE_]translit($1,[a-z],[A-Z])[_DECL],1,[Define if $1 is declared. ])
254 # AMANDA_FUNC_SETPGID
258 # Search for the function HAVE_SETPGID, and run an ICE_CHECK_DECL on it if so.
260 AC_DEFUN([AMANDA_FUNC_SETPGID],
262 AC_CHECK_FUNC(setpgid, [
263 AC_DEFINE(HAVE_SETPGID,1,[Define if setpgid() is available. ])
264 ICE_CHECK_DECL(setpgid,sys/types.h unistd.h)