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