this should not set a SSL path to LDFLAGS or CPPFLAGS unless it really needs
[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
526 dnl **********************************************************************
527 dnl Check for the presence of SSL libraries and headers
528 dnl **********************************************************************
529
530 dnl Default to compiler & linker defaults for SSL files & libraries.
531 OPT_SSL=off
532 AC_ARG_WITH(ssl,dnl
533 [  --with-ssl[=DIR]        where to look for SSL [compiler/linker default paths]
534                           DIR points to the SSL installation [/usr/local/ssl]],
535   OPT_SSL=$withval
536 )
537
538 if test X"$OPT_SSL" = Xno
539 then
540   AC_MSG_WARN(SSL/https support disabled)  
541 else
542
543   dnl Check for and handle argument to --with-ssl.
544   EXTRA_SSL=
545
546   case "$OPT_SSL" in
547   yes)
548     EXTRA_SSL=/usr/local/ssl ;;
549   *)
550     EXTRA_SSL=$OPT_SSL ;;
551   esac
552
553   AC_CHECK_LIB(crypto, CRYPTO_lock,[
554      HAVECRYPTO="yes"
555      ],[
556      OLDLDFLAGS="$LDFLAGS"
557      OLDCPPFLAGS="$CPPFLAGS"
558      LDFLAGS="$LDFLAGS -L$EXTRA_SSL/lib"
559      CPPFLAGS="$CPPFLAGS -I$EXTRA_SSL/include/openssl -I$EXTRA_SSL/include"
560      AC_CHECK_LIB(crypto, CRYPTO_add_lock,[
561        HAVECRYPTO="yes" ], [
562        LDFLAGS="$OLDLDFLAGS"
563        CPPFLAGS="$OLDCPPFLAGS"
564        ])
565     ])
566
567
568   if test "$HAVECRYPTO" = "yes"; then
569     dnl This is only reasonable to do if crypto actually is there: check for
570     dnl SSL libs NOTE: it is important to do this AFTER the crypto lib
571
572     LIBS="$LIBS -lcrypto"
573
574     AC_CHECK_LIB(ssl, SSL_connect)
575
576     if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
577         dnl we didn't find the SSL lib, try the RSAglue/rsaref stuff
578         AC_MSG_CHECKING(for ssl with RSAglue/rsaref libs in use);
579         OLIBS=$LIBS
580         LIBS="$LIBS -lRSAglue -lrsaref"
581         AC_CHECK_LIB(ssl, SSL_connect)
582         if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
583             dnl still no SSL_connect
584             AC_MSG_RESULT(no)
585             LIBS=$OLIBS
586         else
587             AC_MSG_RESULT(yes)
588         fi
589     fi
590
591
592     dnl Check for SSLeay headers
593     AC_CHECK_HEADERS(openssl/x509.h openssl/rsa.h openssl/crypto.h \
594                      openssl/pem.h openssl/ssl.h openssl/err.h,
595       OPENSSL_ENABLED=1)
596
597     if test $ac_cv_header_openssl_x509_h = no; then
598       AC_CHECK_HEADERS(x509.h rsa.h crypto.h pem.h ssl.h err.h,
599         OPENSSL_ENABLED=1)
600     fi
601
602     AC_SUBST(OPENSSL_ENABLED)
603
604   fi
605
606   if test X"$OPT_SSL" != Xoff &&
607      test "$OPENSSL_ENABLED" != "1"; then
608     AC_MSG_ERROR([OpenSSL libs and/or directories were not found where specified!])
609   fi
610
611
612   dnl these can only exist if openssl exists
613
614   AC_CHECK_FUNCS( RAND_status \
615                   RAND_screen \
616                   RAND_egd )
617
618 fi
619
620 dnl **********************************************************************
621 dnl Check for the presence of ZLIB libraries and headers
622 dnl **********************************************************************
623
624 dnl Default to compiler & linker defaults for files & libraries.
625 dnl OPT_ZLIB=no
626 dnl AC_ARG_WITH(zlib,dnl
627 dnl [  --with-zlib[=DIR]  where to look for ZLIB [compiler/linker default paths]
628 dnl                      DIR points to the ZLIB installation prefix [/usr/local]],
629 dnl  OPT_ZLIB=$withval,
630 dnl )
631
632 dnl Check for & handle argument to --with-zlib.
633 dnl
634 dnl NOTE:  We *always* look for ZLIB headers & libraries, all this option
635 dnl        does is change where we look (by adjusting LIBS and CPPFLAGS.)
636 dnl
637
638 dnl AC_MSG_CHECKING(where to look for ZLIB)
639 dnl if test X"$OPT_ZLIB" = Xno
640 dnl then
641 dnl     AC_MSG_RESULT([defaults (or given in environment)])
642 dnl else
643 dnl     test X"$OPT_ZLIB" = Xyes && OPT_ZLIB=/usr/local
644 dnl     LIBS="$LIBS -L$OPT_ZLIB/lib"
645 dnl     CPPFLAGS="$CPPFLAGS -I$OPT_ZLIB/include"
646 dnl     AC_MSG_RESULT([$OPT_ZLIB])
647 dnl fi
648
649 dnl z lib?
650 dnl AC_CHECK_FUNC(gzread, , AC_CHECK_LIB(z, gzread))
651
652
653 dnl Default is to try the thread-safe versions of a few functions
654 OPT_THREAD=on
655 AC_ARG_ENABLE(thread,dnl
656 [  --disable-thread       tell configure to not look for thread-safe functions],
657   OPT_THREAD=off
658 )
659
660 if test X"$OPT_THREAD" = Xoff
661 then
662   AC_MSG_WARN(libcurl will not get built using thread-safe functions)
663   AC_DEFINE(DISABLED_THREADSAFE, 1, \
664 Set to explicitly specify we don't want to use thread-safe functions)
665 else
666
667   dnl dig around for gethostbyname_r()
668   CURL_CHECK_GETHOSTBYNAME_R()
669
670   dnl dig around for gethostbyaddr_r()
671   CURL_CHECK_GETHOSTBYADDR_R()
672
673   dnl poke around for inet_ntoa_r()
674   CURL_CHECK_INET_NTOA_R()
675
676   dnl is there a localtime_r()
677   CURL_CHECK_LOCALTIME_R()
678
679 fi
680
681 dnl **********************************************************************
682 dnl Back to "normal" configuring
683 dnl **********************************************************************
684
685 dnl Checks for header files.
686 AC_HEADER_STDC
687 AC_CHECK_HEADERS( \
688         unistd.h \
689         malloc.h \
690         stdlib.h \
691         arpa/inet.h \
692         net/if.h \
693         netinet/in.h \
694         netinet/if_ether.h \
695         netdb.h \
696         sys/select.h \
697         sys/socket.h \
698         sys/sockio.h \
699         sys/stat.h \
700         sys/types.h \
701         sys/time.h \
702         getopt.h \
703         sys/param.h \
704         termios.h \
705         termio.h \
706         sgtty.h \
707         fcntl.h \
708         dlfcn.h \
709         alloca.h \
710         winsock.h \
711         time.h \
712         io.h \
713         pwd.h
714 )
715
716 dnl Check for libz header
717 dnl AC_CHECK_HEADERS(zlib.h)
718
719 dnl Checks for typedefs, structures, and compiler characteristics.
720 AC_C_CONST
721 AC_TYPE_SIZE_T
722 AC_HEADER_TIME
723
724 # mprintf() checks:
725
726 # check for 'long double'
727 AC_CHECK_SIZEOF(long double, 8)
728 # check for 'long long'
729 AC_CHECK_SIZEOF(long long, 4)
730
731 # check for ssize_t
732 AC_CHECK_TYPE(ssize_t, int)
733
734 dnl
735 dnl We can't just AC_CHECK_TYPE() for socklen_t since it doesn't appear
736 dnl in the standard headers. We egrep for it in the socket headers and
737 dnl if it is used there we assume we have the type defined, otherwise
738 dnl we search for it with AC_CHECK_TYPE() the "normal" way
739 dnl
740
741 if test "$ac_cv_header_sys_socket_h" = "yes"; then
742    AC_MSG_CHECKING(for socklen_t in sys/socket.h)
743    AC_EGREP_HEADER(socklen_t,
744     sys/socket.h,
745     socklen_t=yes
746     AC_MSG_RESULT(yes),
747     AC_MSG_RESULT(no))
748 fi
749
750 if test "$socklen_t" != "yes"; then
751   # check for socklen_t the standard way if it wasn't found before
752   AC_CHECK_TYPE(socklen_t, int)
753 fi
754
755
756 dnl Get system canonical name
757 AC_CANONICAL_HOST
758 AC_DEFINE_UNQUOTED(OS, "${host}")
759
760 dnl Checks for library functions.
761 dnl AC_PROG_GCC_TRADITIONAL
762 AC_TYPE_SIGNAL
763 dnl AC_FUNC_VPRINTF
764 AC_CHECK_FUNCS( socket \
765                 select \
766                 strdup \
767                 strstr \
768                 strftime \
769                 uname \
770                 strcasecmp \
771                 stricmp \
772                 strcmpi \
773                 gethostname \
774                 gethostbyaddr \
775                 getservbyname \
776                 gettimeofday \
777                 inet_addr \
778                 inet_ntoa \
779                 tcsetattr \
780                 tcgetattr \
781                 perror \
782                 closesocket \
783                 setvbuf \
784                 sigaction \
785                 signal \
786                 getpass_r \
787                 strlcat \
788                 getpwuid \
789                 geteuid
790 )
791
792 dnl removed 'getpass' check on October 26, 2000
793
794 if test "$ac_cv_func_select" != "yes"; then
795   AC_MSG_ERROR(Can't work without an existing select() function)
796 fi
797 if test "$ac_cv_func_socket" != "yes"; then
798   AC_MSG_ERROR(Can't work without an existing socket() function)
799 fi
800
801 AC_PATH_PROG( PERL, perl, , 
802   $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
803 AC_SUBST(PERL)
804
805 AC_PATH_PROGS( NROFF, gnroff nroff, , 
806   $PATH:/usr/bin/:/usr/local/bin )
807 AC_SUBST(NROFF)
808
809 AC_PROG_YACC
810
811 dnl AC_PATH_PROG( RANLIB, ranlib, /usr/bin/ranlib, 
812 dnl   $PATH:/usr/bin/:/usr/local/bin )
813 dnl AC_SUBST(RANLIB)
814
815 AC_OUTPUT( Makefile \
816            docs/Makefile \
817            docs/examples/Makefile \
818            include/Makefile \
819            include/curl/Makefile \
820            src/Makefile \
821            lib/Makefile \
822            tests/Makefile \
823            tests/data/Makefile \
824            packages/Makefile \
825            packages/Win32/Makefile \
826            packages/Linux/Makefile \
827            packages/Linux/RPM/Makefile \
828            packages/Linux/RPM/curl.spec \
829            packages/Linux/RPM/curl-ssl.spec \
830            perl/Makefile \
831            perl/Curl_easy/Makefile \
832            php/Makefile \
833            php/examples/Makefile \
834            curl-config
835 )
836