]> sjero.net Git - wget/blob - aclocal.m4
[svn] Look for and use socklen_t.
[wget] / aclocal.m4
1 AC_DEFUN(AM_C_PROTOTYPES,
2 [AC_REQUIRE([AM_PROG_CC_STDC])
3 AC_BEFORE([$0], [AC_C_INLINE])
4 AC_MSG_CHECKING([for function prototypes])
5 if test "$am_cv_prog_cc_stdc" != no; then
6   AC_MSG_RESULT(yes)
7   AC_DEFINE(PROTOTYPES)
8   U= ANSI2KNR=
9 else
10   AC_MSG_RESULT(no)
11   U=_ ANSI2KNR=./ansi2knr
12   # Ensure some checks needed by ansi2knr itself.
13   AC_HEADER_STDC
14   AC_CHECK_HEADERS(string.h)
15 fi
16 AC_SUBST(U)dnl
17 AC_SUBST(ANSI2KNR)dnl
18 ])
19
20
21 # serial 1
22
23 # @defmac AC_PROG_CC_STDC
24 # @maindex PROG_CC_STDC
25 # @ovindex CC
26 # If the C compiler in not in ANSI C mode by default, try to add an option
27 # to output variable @code{CC} to make it so.  This macro tries various
28 # options that select ANSI C on some system or another.  It considers the
29 # compiler to be in ANSI C mode if it defines @code{__STDC__} to 1 and
30 # handles function prototypes correctly.
31 #
32 # If you use this macro, you should check after calling it whether the C
33 # compiler has been set to accept ANSI C; if not, the shell variable
34 # @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
35 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
36 # program @code{ansi2knr}, which comes with Ghostscript.
37 # @end defmac
38
39 AC_DEFUN(AM_PROG_CC_STDC,
40 [AC_REQUIRE([AC_PROG_CC])
41 AC_MSG_CHECKING([for ${CC-cc} option to accept ANSI C])
42 AC_CACHE_VAL(am_cv_prog_cc_stdc,
43 [am_cv_prog_cc_stdc=no
44 ac_save_CC="$CC"
45 # Don't try gcc -ansi; that turns off useful extensions and
46 # breaks some systems' header files.
47 # AIX                   -qlanglvl=ansi
48 # Ultrix and OSF/1      -std1
49 # HP-UX                 -Aa -D_HPUX_SOURCE
50 for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE"
51 do
52   CC="$ac_save_CC $ac_arg"
53   AC_TRY_COMPILE(
54 [#if !defined(__STDC__)
55 choke me
56 #endif
57 /* DYNIX/ptx V4.1.3 can't compile sys/stat.h with -Xc -D__EXTENSIONS__. */
58 #ifdef _SEQUENT_
59 # include <sys/types.h>
60 # include <sys/stat.h>
61 #endif
62 ], [
63 int test (int i, double x);
64 struct s1 {int (*f) (int a);};
65 struct s2 {int (*f) (double a);};],
66 [am_cv_prog_cc_stdc="$ac_arg"; break])
67 done
68 CC="$ac_save_CC"
69 ])
70 AC_MSG_RESULT($am_cv_prog_cc_stdc)
71 case "x$am_cv_prog_cc_stdc" in
72   x|xno) ;;
73   *) CC="$CC $am_cv_prog_cc_stdc" ;;
74 esac
75 ])
76
77 AC_DEFUN([WGET_STRUCT_UTIMBUF],
78 [AC_MSG_CHECKING([for struct utimbuf])
79 if test x"$ac_cv_header_utime_h" = xyes; then
80   AC_EGREP_CPP([struct[         ]+utimbuf],
81     [#include <utime.h>],
82     [AC_DEFINE(HAVE_STRUCT_UTIMBUF)
83       AC_MSG_RESULT(yes)],
84     AC_MSG_RESULT(no))
85 else
86   AC_MSG_RESULT(no)
87 fi])
88
89
90 dnl Check for socklen_t.  The third argument of accept, getsockname,
91 dnl etc. is int * on some systems, but size_t * on others.  POSIX
92 dnl finally standardized on socklen_t, but older systems don't have
93 dnl it.  If socklen_t exists, we use it, else if accept() accepts
94 dnl size_t *, we use that, else we use int.
95
96 AC_DEFUN([WGET_SOCKLEN_T], [
97   AC_MSG_CHECKING(for socklen_t)
98   AC_TRY_COMPILE([
99 #include <sys/types.h>
100 #include <sys/socket.h>
101 socklen_t x;
102 ],
103     [], [AC_MSG_RESULT(yes)], [
104       AC_TRY_COMPILE([
105 #include <sys/types.h>
106 #include <sys/socket.h>
107 int accept (int, struct sockaddr *, size_t *);
108 ],
109       [], [
110       AC_MSG_RESULT(size_t)
111       AC_DEFINE(socklen_t, size_t)
112     ], [
113       AC_MSG_RESULT(int)
114       AC_DEFINE(socklen_t, int)
115     ])
116   ])
117 ])
118
119
120
121 dnl ************************************************************
122 dnl START OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
123 dnl ************************************************************
124
125 AC_DEFUN([TYPE_STRUCT_SOCKADDR_IN6],[
126   ds6_have_sockaddr_in6=
127   AC_CHECK_TYPES([struct sockaddr_in6],[
128     ds6_have_sockaddr_in6=yes
129   ],[
130     ds6_have_sockaddr_in6=no
131   ],[
132 #include <sys/types.h>
133 #include <sys/socket.h>
134 #include <netinet/in.h>
135   ])
136
137   if test "X$ds6_have_sockaddr_in6" = "Xyes"; then :
138     $1
139   else :
140     $2
141   fi
142 ])
143
144
145 AC_DEFUN([MEMBER_SIN6_SCOPE_ID],[
146   AC_REQUIRE([TYPE_STRUCT_SOCKADDR_IN6])
147   
148   ds6_member_sin6_scope_id=
149   if test "X$ds6_have_sockaddr_in6" = "Xyes"; then
150     AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],[
151       ds6_member_sin6_scope_id=yes
152     ],[
153       ds6_member_sin6_scope_id=no
154     ],[
155 #include <sys/types.h>
156 #include <sys/socket.h>
157 #include <netinet/in.h>
158     ])
159   fi
160
161   if test "X$ds6_member_sin6_scope_id" = "Xyes"; then
162     AC_DEFINE([HAVE_SOCKADDR_IN6_SCOPE_ID], 1,
163       [Define if struct sockaddr_in6 has the sin6_scope_id member])
164     $1
165   else :
166     $2
167   fi
168 ])
169
170
171 AC_DEFUN([PROTO_INET6],[
172   AC_CACHE_CHECK([for INET6 protocol support], [ds6_cv_proto_inet6],[
173     AC_TRY_CPP([
174 #include <sys/types.h>
175 #include <sys/socket.h>
176
177 #ifndef PF_INET6
178 #error Missing PF_INET6
179 #endif
180 #ifndef AF_INET6
181 #error Mlssing AF_INET6
182 #endif
183     ],[
184       ds6_cv_proto_inet6=yes
185     ],[
186       ds6_cv_proto_inet6=no
187     ])
188   ])
189
190   if test "X$ds6_cv_proto_inet6" = "Xyes"; then :
191     $1
192   else :
193     $2
194   fi
195 ])
196
197
198 AC_DEFUN([GETADDRINFO_AI_ADDRCONFIG],[
199   AC_CACHE_CHECK([if getaddrinfo supports AI_ADDRCONFIG],
200     [ds6_cv_gai_ai_addrconfig],[
201     AC_TRY_CPP([
202 #include <netdb.h>
203
204 #ifndef AI_ADDRCONFIG
205 #error Missing AI_ADDRCONFIG
206 #endif
207     ],[
208       ds6_cv_gai_ai_addrconfig=yes
209     ],[
210       ds6_cv_gai_ai_addrconfig=no
211     ])
212   ])
213
214   if test "X$ds6_cv_gai_ai_addrconfig" = "Xyes"; then :
215     $1
216   else :
217     $2
218   fi
219 ])
220
221
222 AC_DEFUN([GETADDRINFO_AI_ALL],[
223   AC_CACHE_CHECK([if getaddrinfo supports AI_ALL],[ds6_cv_gai_ai_all],[
224     AC_TRY_CPP([
225 #include <netdb.h>
226
227 #ifndef AI_ALL
228 #error Missing AI_ALL
229 #endif
230     ],[
231       ds6_cv_gai_ai_all=yes
232     ],[
233       ds6_cv_gai_ai_all=no
234     ])
235   ])
236
237   if test "X$ds6_cv_gai_ai_all" = "Xyes"; then :
238     $1
239   else :
240     $2
241   fi
242 ])
243
244
245 AC_DEFUN([GETADDRINFO_AI_V4MAPPED],[
246   AC_CACHE_CHECK([if getaddrinfo supports AI_V4MAPPED],[ds6_cv_gai_ai_v4mapped],[
247     AC_TRY_CPP([
248 #include <netdb.h>
249
250 #ifndef AI_V4MAPPED
251 #error Missing AI_V4MAPPED
252 #endif
253     ],[
254       ds6_cv_gai_ai_v4mapped=yes
255     ],[
256       ds6_cv_gai_ai_v4mapped=no
257     ])
258   ])
259
260   if test "X$ds6_cv_gai_ai_v4mapped" = "Xyes"; then :
261     $1
262   else :
263     $2
264   fi
265 ])
266
267 dnl ************************************************************
268 dnl END OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
269 dnl ************************************************************
270 \f
271 # This code originates from Ulrich Drepper's AM_WITH_NLS.
272
273 AC_DEFUN(WGET_WITH_NLS,
274   [AC_MSG_CHECKING([whether NLS is requested])
275     dnl Default is enabled NLS
276     AC_ARG_ENABLE(nls,
277       [  --disable-nls           do not use Native Language Support],
278       HAVE_NLS=$enableval, HAVE_NLS=yes)
279     AC_MSG_RESULT($HAVE_NLS)
280
281     dnl If something goes wrong, we may still decide not to use NLS.
282     dnl For this reason, defer AC_SUBST'ing HAVE_NLS until the very
283     dnl last moment.
284
285     if test x"$HAVE_NLS" = xyes; then
286       AC_MSG_RESULT([language catalogs: $ALL_LINGUAS])
287       AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
288         [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
289       AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
290           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
291       AC_SUBST(MSGFMT)
292       AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
293       CATOBJEXT=.gmo
294       INSTOBJEXT=.mo
295       DATADIRNAME=share
296
297       dnl Test whether we really found GNU xgettext.
298       if test "$XGETTEXT" != ":"; then
299         dnl If it is no GNU xgettext we define it as : so that the
300         dnl Makefiles still can work.
301         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
302           : ;
303         else
304           AC_MSG_RESULT(
305             [found xgettext programs is not GNU xgettext; ignore it])
306           XGETTEXT=":"
307         fi
308       fi
309
310       AC_CHECK_HEADERS(locale.h libintl.h)
311
312       dnl Prefer gettext found in -lintl to the one in libc.
313       dnl Otherwise it can happen that we include libintl.h from
314       dnl /usr/local/lib, but fail to specify -lintl, which results in
315       dnl link or run-time failures.  (Symptom: libintl_bindtextdomain
316       dnl not found at link-time.)
317
318       AC_CHECK_LIB(intl, gettext, [
319         dnl gettext is in libintl; announce the fact manually.
320         LIBS="-lintl $LIBS"
321         AC_DEFINE(HAVE_GETTEXT)
322       ], [
323         AC_CHECK_FUNCS(gettext, [], [
324           AC_MSG_RESULT([gettext not found; disabling NLS])
325           HAVE_NLS=no
326         ])
327       ])
328
329       dnl These rules are solely for the distribution goal.  While doing this
330       dnl we only have to keep exactly one list of the available catalogs
331       dnl in configure.in.
332       for lang in $ALL_LINGUAS; do
333         GMOFILES="$GMOFILES $lang.gmo"
334         POFILES="$POFILES $lang.po"
335       done
336       dnl Construct list of names of catalog files to be constructed.
337       for lang in $ALL_LINGUAS; do
338         CATALOGS="$CATALOGS ${lang}${CATOBJEXT}"
339       done
340
341       dnl Make all variables we use known to autoconf.
342       AC_SUBST(CATALOGS)
343       AC_SUBST(CATOBJEXT)
344       AC_SUBST(DATADIRNAME)
345       AC_SUBST(GMOFILES)
346       AC_SUBST(INSTOBJEXT)
347       AC_SUBST(INTLLIBS)
348       AC_SUBST(POFILES)
349     fi
350     AC_SUBST(HAVE_NLS)
351     dnl Some independently maintained files, such as po/Makefile.in,
352     dnl use `USE_NLS', so support it.
353     USE_NLS=$HAVE_NLS
354     AC_SUBST(USE_NLS)
355     if test "x$HAVE_NLS" = xyes; then
356       AC_DEFINE(HAVE_NLS)
357     fi
358   ])
359
360 dnl Generate list of files to be processed by xgettext which will
361 dnl be included in po/Makefile.
362 dnl
363 dnl This is not strictly an Autoconf macro, because it is run from
364 dnl within `config.status' rather than from within configure.  This
365 dnl is why special rules must be applied for it.
366 AC_DEFUN(WGET_PROCESS_PO,
367   [
368    dnl I wonder what the following several lines do...
369    if test "x$srcdir" != "x."; then
370      if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
371        posrcprefix="$srcdir/"
372      else
373        posrcprefix="../$srcdir/"
374      fi
375    else
376      posrcprefix="../"
377    fi
378    rm -f po/POTFILES
379    dnl Use `echo' rather than AC_MSG_RESULT, because this is run from
380    dnl `config.status'.
381    echo "generating po/POTFILES from $srcdir/po/POTFILES.in"
382    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\,"  \
383        -e "\$s/\(.*\) \\\\/\1/" \
384         < $srcdir/po/POTFILES.in > po/POTFILES
385    echo "creating po/Makefile"
386    sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
387   ])
388
389 # Search path for a program which passes the given test.
390 # Ulrich Drepper <drepper@cygnus.com>, 1996.
391 #
392 # This file may be copied and used freely without restrictions.  It
393 # can be used in projects which are not available under the GNU Public
394 # License but which still want to provide support for the GNU gettext
395 # functionality.  Please note that the actual code is *not* freely
396 # available.
397
398 # serial 1
399
400 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
401 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
402 AC_DEFUN(AM_PATH_PROG_WITH_TEST,
403 [# Extract the first word of "$2", so it can be a program name with args.
404 set dummy $2; ac_word=[$]2
405 AC_MSG_CHECKING([for $ac_word])
406 AC_CACHE_VAL(ac_cv_path_$1,
407 [case "[$]$1" in
408   /*)
409   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
410   ;;
411   *)
412   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
413   for ac_dir in ifelse([$5], , $PATH, [$5]); do
414     test -z "$ac_dir" && ac_dir=.
415     if test -f $ac_dir/$ac_word; then
416       if [$3]; then
417         ac_cv_path_$1="$ac_dir/$ac_word"
418         break
419       fi
420     fi
421   done
422   IFS="$ac_save_ifs"
423 dnl If no 4th arg is given, leave the cache variable unset,
424 dnl so AC_PATH_PROGS will keep looking.
425 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
426 ])dnl
427   ;;
428 esac])dnl
429 $1="$ac_cv_path_$1"
430 if test -n "[$]$1"; then
431   AC_MSG_RESULT([$]$1)
432 else
433   AC_MSG_RESULT(no)
434 fi
435 AC_SUBST($1)dnl
436 ])
437
438 # Include libtool code.
439
440 builtin(include, libtool.m4)dnl