general autoconf and automake fixes
[platform/upstream/curl.git] / configure.in
1 dnl $Id$
2 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT
4 AC_CONFIG_SRCDIR([lib/urldata.h])
5 AM_CONFIG_HEADER(config.h src/config.h)
6
7 VERSION=`sed -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' ${srcdir}/include/curl/curl.h`
8 AM_INIT_AUTOMAKE(curl,$VERSION)
9
10 dnl
11 dnl Detect the canonical host and target build environment
12 dnl
13
14 AC_CANONICAL_HOST
15 dnl Get system canonical name
16 AC_DEFINE_UNQUOTED(OS, "${host}")
17
18 dnl Check for AIX weirdos
19 AC_AIX
20
21 dnl Checks for programs.
22 AC_PROG_CC
23
24 dnl check for how to do large files
25 AC_SYS_LARGEFILE
26
27 AM_PROG_LIBTOOL
28
29 dnl The install stuff has already been taken care of by the automake stuff
30 dnl AC_PROG_INSTALL
31 AC_PROG_MAKE_SET
32
33 dnl ************************************************************
34 dnl lame option to switch on debug options
35 dnl
36 AC_MSG_CHECKING([whether to enable debug options])
37 AC_ARG_ENABLE(debug,
38 [  --enable-debug               Enable pedantic debug options
39   --disable-debug               Disable debug options],
40 [ case "$enableval" in
41   no)
42        AC_MSG_RESULT(no)
43        ;;
44   *)   AC_MSG_RESULT(yes)
45
46     CPPFLAGS="$CPPFLAGS -DMALLOCDEBUG"
47     CFLAGS="-Wall -pedantic -g" 
48        ;;
49   esac ],
50        AC_MSG_RESULT(no)
51 )
52
53
54 dnl
55 dnl check for working getaddrinfo()
56 dnl
57 AC_DEFUN(CURL_CHECK_WORKING_GETADDRINFO,[
58   AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
59   AC_TRY_RUN( [
60 #include <netdb.h>
61 #include <sys/types.h>
62 #include <sys/socket.h>
63
64 void main(void) {
65     struct addrinfo hints, *ai;
66     int error;
67
68     memset(&hints, 0, sizeof(hints));
69     hints.ai_family = AF_UNSPEC;
70     hints.ai_socktype = SOCK_STREAM;
71     error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
72     if (error) {
73         exit(1);
74     }
75     else {
76         exit(0);
77     }
78 }
79 ],[
80   ac_cv_working_getaddrinfo="yes"
81 ],[
82   ac_cv_working_getaddrinfo="no"
83 ],[
84   ac_cv_working_getaddrinfo="yes"
85 ])])
86 if test "$ac_cv_working_getaddrinfo" = "yes"; then
87   AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
88   AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
89
90   IPV6_ENABLED=1
91   AC_SUBST(IPV6_ENABLED)
92 fi
93 ])
94
95
96 AC_DEFUN(CURL_CHECK_LOCALTIME_R,
97 [
98   dnl check for a few thread-safe functions
99   AC_CHECK_FUNCS(localtime_r,[
100     AC_MSG_CHECKING(whether localtime_r is declared)
101     AC_EGREP_CPP(localtime_r,[
102 #include <time.h>],[
103       AC_MSG_RESULT(yes)],[
104       AC_MSG_RESULT(no)
105       AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
106       AC_EGREP_CPP(localtime_r,[
107 #define _REENTRANT
108 #include <time.h>],[
109         AC_DEFINE(NEED_REENTRANT)
110         AC_MSG_RESULT(yes)],
111         AC_MSG_RESULT(no))])])
112 ])
113
114 AC_DEFUN(CURL_CHECK_INET_NTOA_R,
115 [
116   dnl determine if function definition for inet_ntoa_r exists.
117   AC_CHECK_FUNCS(inet_ntoa_r,[
118     AC_MSG_CHECKING(whether inet_ntoa_r is declared)
119     AC_EGREP_CPP(inet_ntoa_r,[
120 #include <arpa/inet.h>],[
121       AC_DEFINE(HAVE_INET_NTOA_R_DECL)
122       AC_MSG_RESULT(yes)],[
123       AC_MSG_RESULT(no)
124       AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
125       AC_EGREP_CPP(inet_ntoa_r,[
126 #define _REENTRANT
127 #include <arpa/inet.h>],[
128         AC_DEFINE(HAVE_INET_NTOA_R_DECL)
129         AC_DEFINE(NEED_REENTRANT)
130         AC_MSG_RESULT(yes)],
131         AC_MSG_RESULT(no))])])
132
133 ])
134
135 AC_DEFUN(CURL_CHECK_GETHOSTBYADDR_R,
136 [
137   dnl check for number of arguments to gethostbyaddr_r. it might take
138   dnl either 5, 7, or 8 arguments.
139   AC_CHECK_FUNCS(gethostbyaddr_r,[
140     AC_MSG_CHECKING(if gethostbyaddr_r takes 5 arguments)
141     AC_TRY_COMPILE([
142 #include <sys/types.h>
143 #include <netdb.h>],[
144 char * address;
145 int length;
146 int type;
147 struct hostent h;
148 struct hostent_data hdata;
149 int rc;
150 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
151       AC_MSG_RESULT(yes)
152       AC_DEFINE(HAVE_GETHOSTBYADDR_R_5)
153       ac_cv_gethostbyaddr_args=5],[
154       AC_MSG_RESULT(no)
155       AC_MSG_CHECKING(if gethostbyaddr_r with -D_REENTRANT takes 5 arguments)
156       AC_TRY_COMPILE([
157 #define _REENTRANT
158 #include <sys/types.h>
159 #include <netdb.h>],[
160 char * address;
161 int length;
162 int type;
163 struct hostent h;
164 struct hostent_data hdata;
165 int rc;
166 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
167         AC_MSG_RESULT(yes)
168         AC_DEFINE(HAVE_GETHOSTBYADDR_R_5)
169         AC_DEFINE(NEED_REENTRANT)
170         ac_cv_gethostbyaddr_args=5],[
171         AC_MSG_RESULT(no)
172         AC_MSG_CHECKING(if gethostbyaddr_r takes 7 arguments)
173         AC_TRY_COMPILE([
174 #include <sys/types.h>
175 #include <netdb.h>],[
176 char * address;
177 int length;
178 int type;
179 struct hostent h;
180 char buffer[8192];
181 int h_errnop;
182 struct hostent * hp;
183
184 hp = gethostbyaddr_r(address, length, type, &h,
185                      buffer, 8192, &h_errnop);],[
186           AC_MSG_RESULT(yes)
187           AC_DEFINE(HAVE_GETHOSTBYADDR_R_7)
188           ac_cv_gethostbyaddr_args=7],[
189           AC_MSG_RESULT(no)
190           AC_MSG_CHECKING(if gethostbyaddr_r takes 8 arguments)
191           AC_TRY_COMPILE([
192 #include <sys/types.h>
193 #include <netdb.h>],[
194 char * address;
195 int length;
196 int type;
197 struct hostent h;
198 char buffer[8192];
199 int h_errnop;
200 struct hostent * hp;
201 int rc;
202
203 rc = gethostbyaddr_r(address, length, type, &h,
204                      buffer, 8192, &hp, &h_errnop);],[
205             AC_MSG_RESULT(yes)
206             AC_DEFINE(HAVE_GETHOSTBYADDR_R_8)
207             ac_cv_gethostbyaddr_args=8],[
208             AC_MSG_RESULT(no)
209             have_missing_r_funcs="$have_missing_r_funcs gethostbyaddr_r"])])])])])
210
211
212 ])
213
214 AC_DEFUN(CURL_CHECK_GETHOSTBYNAME_R,
215 [
216   dnl check for number of arguments to gethostbyname_r. it might take
217   dnl either 3, 5, or 6 arguments.
218   AC_CHECK_FUNCS(gethostbyname_r,[
219     AC_MSG_CHECKING(if gethostbyname_r takes 3 arguments)
220     AC_TRY_RUN([
221 #include <string.h>
222 #include <sys/types.h>
223 #include <netdb.h>
224
225 int
226 main () {
227 struct hostent h;
228 struct hostent_data hdata;
229 char *name = "localhost";
230 int rc;
231 memset(&h, 0, sizeof(struct hostent));
232 memset(&hdata, 0, sizeof(struct hostent_data));
233 rc = gethostbyname_r(name, &h, &hdata);
234 exit (rc != 0 ? 1 : 0); }],[
235       AC_MSG_RESULT(yes)
236       AC_DEFINE(HAVE_GETHOSTBYNAME_R_3)
237       ac_cv_gethostbyname_args=3],[
238       AC_MSG_RESULT(no)
239       AC_MSG_CHECKING(if gethostbyname_r with -D_REENTRANT takes 3 arguments)
240       AC_TRY_RUN([
241 #define _REENTRANT
242
243 #include <string.h>
244 #include <sys/types.h>
245 #include <netdb.h>
246
247 int
248 main () {
249 struct hostent h;
250 struct hostent_data hdata;
251 char *name = "localhost";
252 int rc;
253 memset(&h, 0, sizeof(struct hostent));
254 memset(&hdata, 0, sizeof(struct hostent_data));
255 rc = gethostbyname_r(name, &h, &hdata);
256 exit (rc != 0 ? 1 : 0); }],[
257         AC_MSG_RESULT(yes)
258         AC_DEFINE(HAVE_GETHOSTBYNAME_R_3)
259         AC_DEFINE(NEED_REENTRANT)
260         ac_cv_gethostbyname_args=3],[
261         AC_MSG_RESULT(no)
262         AC_MSG_CHECKING(if gethostbyname_r takes 5 arguments)
263         AC_TRY_RUN([
264 #include <sys/types.h>
265 #include <netdb.h>
266
267 int
268 main () {
269 struct hostent *hp;
270 struct hostent h;
271 char *name = "localhost";
272 char buffer[8192];
273 int h_errno;
274 hp = gethostbyname_r(name, &h, buffer, 8192, &h_errno);
275 exit (hp == NULL ? 1 : 0); }],[
276           AC_MSG_RESULT(yes)
277           AC_DEFINE(HAVE_GETHOSTBYNAME_R_5)
278           ac_cv_gethostbyname_args=5],[
279           AC_MSG_RESULT(no)
280           AC_MSG_CHECKING(if gethostbyname_r takes 6 arguments)
281           AC_TRY_RUN([
282 #include <sys/types.h>
283 #include <netdb.h>
284
285 int
286 main () {
287 struct hostent h;
288 struct hostent *hp;
289 char *name = "localhost";
290 char buf[8192];
291 int rc;
292 int h_errno;
293 rc = gethostbyname_r(name, &h, buf, 8192, &hp, &h_errno);
294 exit (rc != 0 ? 1 : 0); }],[
295             AC_MSG_RESULT(yes)
296             AC_DEFINE(HAVE_GETHOSTBYNAME_R_6)
297             ac_cv_gethostbyname_args=6],[
298             AC_MSG_RESULT(no)
299             have_missing_r_funcs="$have_missing_r_funcs gethostbyname_r"],
300             [ac_cv_gethostbyname_args=0])],
301           [ac_cv_gethostbyname_args=0])],
302         [ac_cv_gethostbyname_args=0])],
303       [ac_cv_gethostbyname_args=0])])
304
305 if test "$ac_cv_func_gethostbyname_r" = "yes"; then
306   if test "$ac_cv_gethostbyname_args" = "0"; then
307     dnl there's a gethostbyname_r() function, but we don't know how
308     dnl many arguments it wants!
309     AC_MSG_ERROR([couldn't figure out how to use gethostbyname_r()])
310   fi
311 fi
312
313 ])
314
315 dnl **********************************************************************
316 dnl Checks for IPv6
317 dnl **********************************************************************
318
319 AC_MSG_CHECKING([whether to enable ipv6])
320 AC_ARG_ENABLE(ipv6,
321 [  --enable-ipv6                Enable ipv6 (with ipv4) support
322   --disable-ipv6                Disable ipv6 support],
323 [ case "$enableval" in
324   no)
325        AC_MSG_RESULT(no)
326        ipv6=no
327        ;;
328   *)   AC_MSG_RESULT(yes)
329        ipv6=yes
330        ;;
331   esac ],
332
333   AC_TRY_RUN([ /* is AF_INET6 available? */
334 #include <sys/types.h>
335 #include <sys/socket.h>
336 main()
337 {
338  if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
339    exit(1);
340  else
341    exit(0);
342 }
343 ],
344   AC_MSG_RESULT(yes)
345   ipv6=yes,
346   AC_MSG_RESULT(no)
347   ipv6=no,
348   AC_MSG_RESULT(no)
349   ipv6=no
350 ))
351
352 if test "$ipv6" = "yes"; then
353   CURL_CHECK_WORKING_GETADDRINFO
354 fi
355
356
357 dnl **********************************************************************
358 dnl Checks for libraries.
359 dnl **********************************************************************
360
361 dnl gethostbyname in the nsl lib?
362 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))
363
364 if test "$ac_cv_lib_nsl_gethostbyname" != "yes" -a "$ac_cv_func_gethostbyname" != "yes"; then
365   dnl gethostbyname in the socket lib?
366   AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(socket, gethostbyname))
367 fi
368
369 dnl At least one system has been identified to require BOTH nsl and
370 dnl socket libs to link properly.
371 if test "$ac_cv_lib_nsl_gethostbyname" = "$ac_cv_func_gethostbyname"; then
372   AC_MSG_CHECKING([trying both nsl and socket libs])
373   my_ac_save_LIBS=$LIBS
374   LIBS="-lnsl -lsocket $LIBS"
375   AC_TRY_LINK( ,
376              [gethostbyname();],
377              my_ac_link_result=success,
378              my_ac_link_result=failure )
379
380   if test "$my_ac_link_result" = "failure"; then
381     AC_MSG_RESULT([no])
382     AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
383     dnl restore LIBS
384     LIBS=$my_ac_save_LIBS
385   else
386     AC_MSG_RESULT([yes])
387   fi
388 fi
389
390 dnl resolve lib?
391 AC_CHECK_FUNC(strcasecmp, , AC_CHECK_LIB(resolve, strcasecmp))
392
393 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
394   AC_CHECK_LIB(resolve, strcasecmp,
395               [LIBS="-lresolve $LIBS"],
396                ,
397                -lnsl)
398 fi
399
400 dnl socket lib?
401 AC_CHECK_FUNC(connect, , AC_CHECK_LIB(socket, connect))
402
403 dnl ucb lib?
404 AC_CHECK_FUNC(gethostname, , AC_CHECK_LIB(ucb, gethostname))
405
406 dnl dl lib?
407 AC_CHECK_FUNC(dlopen, , AC_CHECK_LIB(dl, dlopen))
408
409 dnl **********************************************************************
410 dnl Check for the random seed preferences 
411 dnl **********************************************************************
412
413 AC_ARG_WITH(egd-socket,
414     [  --with-egd-socket=FILE  Entropy Gathering Daemon socket pathname],
415     [ EGD_SOCKET="$withval" ]
416 )
417 if test -n "$EGD_SOCKET" ; then
418         AC_DEFINE_UNQUOTED(EGD_SOCKET, "$EGD_SOCKET")
419 fi
420
421 dnl Check for user-specified random device
422 AC_ARG_WITH(random,
423     [  --with-random=FILE      read randomness from FILE (default=/dev/urandom)],
424     [ RANDOM_FILE="$withval" ],
425     [
426         dnl Check for random device
427         AC_CHECK_FILE("/dev/urandom",
428             [
429                 RANDOM_FILE="/dev/urandom";
430             ]
431         )
432     ]
433 )
434 if test -n "$RANDOM_FILE" ; then
435         AC_SUBST(RANDOM_FILE)
436         AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE")
437 fi
438
439 dnl **********************************************************************
440 dnl Check for the presence of Kerberos4 libraries and headers
441 dnl **********************************************************************
442
443 AC_ARG_WITH(krb4-includes,
444  [  --with-krb4-includes[=DIR]   Specify location of kerberos4 headers],[
445  CPPFLAGS="$CPPFLAGS -I$withval"
446  KRB4INC="$withval"
447  want_krb4=yes
448  ])
449
450 AC_ARG_WITH(krb4-libs,
451  [  --with-krb4-libs[=DIR]   Specify location of kerberos4 libs],[
452  LDFLAGS="$LDFLAGS -L$withval"
453  KRB4LIB="$withval"
454  want_krb4=yes
455  ])
456
457
458 OPT_KRB4=off
459 AC_ARG_WITH(krb4,dnl
460 [  --with-krb4[=DIR]       where to look for Kerberos4],[
461   OPT_KRB4="$withval"
462   if test X"$OPT_KRB4" != Xyes
463   then
464     LDFLAGS="$LDFLAGS -L$OPT_KRB4/lib"
465     KRB4LIB="$OPT_KRB4/lib"
466     CPPFLAGS="$CPPFLAGS -I$OPT_KRB4/include"
467     KRB4INC="$OPT_KRB4/include"
468   fi
469   want_krb4="yes"
470  ])
471
472 AC_MSG_CHECKING([if Kerberos4 support is requested])
473
474 if test "$want_krb4" = yes
475 then
476   if test "$ipv6" = "yes"; then
477     echo krb4 is not compatible with IPv6
478     exit 1
479   fi
480   AC_MSG_RESULT(yes)
481
482   dnl Check for & handle argument to --with-krb4
483
484   AC_MSG_CHECKING(where to look for Kerberos4)
485   if test X"$OPT_KRB4" = Xyes
486   then
487     AC_MSG_RESULT([defaults])
488   else
489     AC_MSG_RESULT([libs in $KRB4LIB, headers in $KRB4INC])
490   fi
491
492   dnl Check for DES library
493   AC_CHECK_LIB(des, des_pcbc_encrypt,
494   [
495     AC_CHECK_HEADERS(des.h)
496
497     dnl resolv lib?
498     AC_CHECK_FUNC(res_search, , AC_CHECK_LIB(resolv, res_search))
499
500     dnl Check for the Kerberos4 library
501     AC_CHECK_LIB(krb, krb_net_read,
502     [
503       dnl Check for header files
504       AC_CHECK_HEADERS(krb.h)
505
506       dnl we found the required libraries, add to LIBS
507       LIBS="-lkrb -ldes $LIBS"
508
509       dnl Check for function krb_get_our_ip_for_realm
510       dnl this is needed for NAT networks
511       AC_CHECK_FUNCS(krb_get_our_ip_for_realm)
512
513       dnl add define KRB4
514       AC_DEFINE(KRB4)
515
516       dnl substitute it too!
517       KRB4_ENABLED=1
518       AC_SUBST(KRB4_ENABLED)
519
520       dnl the krb4 stuff needs a strlcpy()
521       AC_CHECK_FUNCS(strlcpy)
522
523     ])
524   ])
525 else
526   AC_MSG_RESULT(no)
527 fi
528
529
530 dnl **********************************************************************
531 dnl Check for the presence of SSL libraries and headers
532 dnl **********************************************************************
533
534 dnl Default to compiler & linker defaults for SSL files & libraries.
535 OPT_SSL=off
536 AC_ARG_WITH(ssl,dnl
537 [  --with-ssl[=DIR]        where to look for SSL [compiler/linker default paths]
538                           DIR points to the SSL installation [/usr/local/ssl]],
539   OPT_SSL=$withval
540 )
541
542 if test X"$OPT_SSL" = Xno
543 then
544   AC_MSG_WARN(SSL/https support disabled)  
545 else
546
547   dnl Check for and handle argument to --with-ssl.
548   EXTRA_SSL=
549
550   case "$OPT_SSL" in
551   yes)
552     EXTRA_SSL=/usr/local/ssl ;;
553   *)
554     EXTRA_SSL=$OPT_SSL ;;
555   esac
556
557   AC_CHECK_LIB(crypto, CRYPTO_lock,[
558      HAVECRYPTO="yes"
559      ],[
560      OLDLDFLAGS="$LDFLAGS"
561      OLDCPPFLAGS="$CPPFLAGS"
562      LDFLAGS="$LDFLAGS -L$EXTRA_SSL/lib"
563      CPPFLAGS="$CPPFLAGS -I$EXTRA_SSL/include/openssl -I$EXTRA_SSL/include"
564      AC_CHECK_LIB(crypto, CRYPTO_add_lock,[
565        HAVECRYPTO="yes" ], [
566        LDFLAGS="$OLDLDFLAGS"
567        CPPFLAGS="$OLDCPPFLAGS"
568        ])
569     ])
570
571
572   if test "$HAVECRYPTO" = "yes"; then
573     dnl This is only reasonable to do if crypto actually is there: check for
574     dnl SSL libs NOTE: it is important to do this AFTER the crypto lib
575
576     AC_CHECK_LIB(crypto, CRYPTO_add_lock)
577     AC_CHECK_LIB(ssl, SSL_connect)
578
579     if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
580         dnl we didn't find the SSL lib, try the RSAglue/rsaref stuff
581         AC_MSG_CHECKING(for ssl with RSAglue/rsaref libs in use);
582         OLIBS=$LIBS
583         LIBS="$LIBS -lRSAglue -lrsaref"
584         AC_CHECK_LIB(ssl, SSL_connect)
585         if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
586             dnl still no SSL_connect
587             AC_MSG_RESULT(no)
588             LIBS=$OLIBS
589         else
590             AC_MSG_RESULT(yes)
591         fi
592     fi
593
594
595     dnl Check for SSLeay headers
596     AC_CHECK_HEADERS(openssl/x509.h openssl/rsa.h openssl/crypto.h \
597                      openssl/pem.h openssl/ssl.h openssl/err.h,
598       OPENSSL_ENABLED=1)
599
600     if test $ac_cv_header_openssl_x509_h = no; then
601       AC_CHECK_HEADERS(x509.h rsa.h crypto.h pem.h ssl.h err.h,
602         OPENSSL_ENABLED=1)
603     fi
604
605     AC_SUBST(OPENSSL_ENABLED)
606
607   fi
608
609   if test X"$OPT_SSL" != Xoff &&
610      test "$OPENSSL_ENABLED" != "1"; then
611     AC_MSG_ERROR([OpenSSL libs and/or directories were not found where specified!])
612   fi
613
614
615   dnl these can only exist if openssl exists
616
617   AC_CHECK_FUNCS( RAND_status \
618                   RAND_screen \
619                   RAND_egd )
620
621 fi
622
623 dnl **********************************************************************
624 dnl Check for the presence of ZLIB libraries and headers
625 dnl **********************************************************************
626
627 dnl Default to compiler & linker defaults for files & libraries.
628 dnl OPT_ZLIB=no
629 dnl AC_ARG_WITH(zlib,dnl
630 dnl [  --with-zlib[=DIR]  where to look for ZLIB [compiler/linker default paths]
631 dnl                      DIR points to the ZLIB installation prefix [/usr/local]],
632 dnl  OPT_ZLIB=$withval,
633 dnl )
634
635 dnl Check for & handle argument to --with-zlib.
636 dnl
637 dnl NOTE:  We *always* look for ZLIB headers & libraries, all this option
638 dnl        does is change where we look (by adjusting LIBS and CPPFLAGS.)
639 dnl
640
641 dnl AC_MSG_CHECKING(where to look for ZLIB)
642 dnl if test X"$OPT_ZLIB" = Xno
643 dnl then
644 dnl     AC_MSG_RESULT([defaults (or given in environment)])
645 dnl else
646 dnl     test X"$OPT_ZLIB" = Xyes && OPT_ZLIB=/usr/local
647 dnl     LIBS="$LIBS -L$OPT_ZLIB/lib"
648 dnl     CPPFLAGS="$CPPFLAGS -I$OPT_ZLIB/include"
649 dnl     AC_MSG_RESULT([$OPT_ZLIB])
650 dnl fi
651
652 dnl z lib?
653 dnl AC_CHECK_FUNC(gzread, , AC_CHECK_LIB(z, gzread))
654
655
656 dnl Default is to try the thread-safe versions of a few functions
657 OPT_THREAD=on
658 AC_ARG_ENABLE(thread,dnl
659 [  --disable-thread       tell configure to not look for thread-safe functions],
660   OPT_THREAD=off
661 )
662
663 if test X"$OPT_THREAD" = Xoff
664 then
665   AC_MSG_WARN(libcurl will not get built using thread-safe functions)
666   AC_DEFINE(DISABLED_THREADSAFE, 1, \
667 Set to explicitly specify we don't want to use thread-safe functions)
668 else
669
670   dnl dig around for gethostbyname_r()
671   CURL_CHECK_GETHOSTBYNAME_R()
672
673   dnl dig around for gethostbyaddr_r()
674   CURL_CHECK_GETHOSTBYADDR_R()
675
676   dnl poke around for inet_ntoa_r()
677   CURL_CHECK_INET_NTOA_R()
678
679   dnl is there a localtime_r()
680   CURL_CHECK_LOCALTIME_R()
681
682 fi
683
684 dnl **********************************************************************
685 dnl Back to "normal" configuring
686 dnl **********************************************************************
687
688 dnl Checks for header files.
689 AC_HEADER_STDC
690 AC_CHECK_HEADERS( \
691         unistd.h \
692         malloc.h \
693         stdlib.h \
694         arpa/inet.h \
695         net/if.h \
696         netinet/in.h \
697         netinet/if_ether.h \
698         netdb.h \
699         sys/select.h \
700         sys/socket.h \
701         sys/sockio.h \
702         sys/stat.h \
703         sys/types.h \
704         sys/time.h \
705         getopt.h \
706         sys/param.h \
707         termios.h \
708         termio.h \
709         sgtty.h \
710         fcntl.h \
711         dlfcn.h \
712         alloca.h \
713         winsock.h \
714         time.h \
715         io.h \
716         pwd.h
717 )
718
719 dnl Check for libz header
720 dnl AC_CHECK_HEADERS(zlib.h)
721
722 dnl Checks for typedefs, structures, and compiler characteristics.
723 AC_C_CONST
724 AC_TYPE_SIZE_T
725 AC_HEADER_TIME
726
727 # mprintf() checks:
728
729 # check for 'long double'
730 AC_CHECK_SIZEOF(long double, 8)
731 # check for 'long long'
732 AC_CHECK_SIZEOF(long long, 4)
733
734 # check for ssize_t
735 AC_CHECK_TYPE(ssize_t, int)
736
737 dnl
738 dnl We can't just AC_CHECK_TYPE() for socklen_t since it doesn't appear
739 dnl in the standard headers. We egrep for it in the socket headers and
740 dnl if it is used there we assume we have the type defined, otherwise
741 dnl we search for it with AC_CHECK_TYPE() the "normal" way
742 dnl
743
744 if test "$ac_cv_header_sys_socket_h" = "yes"; then
745    AC_MSG_CHECKING(for socklen_t in sys/socket.h)
746    AC_EGREP_HEADER(socklen_t,
747     sys/socket.h,
748     socklen_t=yes
749     AC_MSG_RESULT(yes),
750     AC_MSG_RESULT(no))
751 fi
752
753 if test "$socklen_t" != "yes"; then
754   # check for socklen_t the standard way if it wasn't found before
755   AC_CHECK_TYPE(socklen_t, int)
756 fi
757
758 dnl Checks for library functions.
759 dnl AC_PROG_GCC_TRADITIONAL
760 AC_TYPE_SIGNAL
761 dnl AC_FUNC_VPRINTF
762 AC_CHECK_FUNCS( socket \
763                 select \
764                 strdup \
765                 strstr \
766                 strftime \
767                 uname \
768                 strcasecmp \
769                 stricmp \
770                 strcmpi \
771                 gethostname \
772                 gethostbyaddr \
773                 getservbyname \
774                 gettimeofday \
775                 inet_addr \
776                 inet_ntoa \
777                 tcsetattr \
778                 tcgetattr \
779                 perror \
780                 closesocket \
781                 setvbuf \
782                 sigaction \
783                 signal \
784                 getpass_r \
785                 strlcat \
786                 getpwuid \
787                 geteuid
788 )
789
790 dnl removed 'getpass' check on October 26, 2000
791
792 if test "$ac_cv_func_select" != "yes"; then
793   AC_MSG_ERROR(Can't work without an existing select() function)
794 fi
795 if test "$ac_cv_func_socket" != "yes"; then
796   AC_MSG_ERROR(Can't work without an existing socket() function)
797 fi
798
799 AC_PATH_PROG( PERL, perl, , 
800   $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
801 AC_SUBST(PERL)
802
803 AC_PATH_PROGS( NROFF, gnroff nroff, , 
804   $PATH:/usr/bin/:/usr/local/bin )
805 AC_SUBST(NROFF)
806
807 AC_PROG_YACC
808
809 dnl AC_PATH_PROG( RANLIB, ranlib, /usr/bin/ranlib, 
810 dnl   $PATH:/usr/bin/:/usr/local/bin )
811 dnl AC_SUBST(RANLIB)
812
813 AC_CONFIG_FILES([Makefile \
814            docs/Makefile \
815            docs/examples/Makefile \
816            include/Makefile \
817            include/curl/Makefile \
818            src/Makefile \
819            lib/Makefile \
820            tests/Makefile \
821            tests/data/Makefile \
822            packages/Makefile \
823            packages/Win32/Makefile \
824            packages/Linux/Makefile \
825            packages/Linux/RPM/Makefile \
826            packages/Linux/RPM/curl.spec \
827            packages/Linux/RPM/curl-ssl.spec \
828            perl/Makefile \
829            perl/Curl_easy/Makefile \
830            php/Makefile \
831            php/examples/Makefile \
832            curl-config
833 ])
834 AC_OUTPUT
835