Nico Baggus added more error codes to the VMS stuff.
[platform/upstream/curl.git] / configure.in
1 dnl $Id$
2 dnl Process this file with autoconf to produce a configure script.
3
4 dnl Ensure that this file is processed with autoconf 2.50 or newer
5 dnl Don't even think about removing this check!
6 AC_PREREQ(2.50)
7
8 dnl First some basic init macros
9 AC_INIT
10 AC_CONFIG_SRCDIR([lib/urldata.h])
11 AM_CONFIG_HEADER(lib/config.h src/config.h tests/server/config.h)
12
13 dnl figure out the libcurl version
14 VERSION=`sed -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' ${srcdir}/include/curl/curl.h`
15 AM_INIT_AUTOMAKE(curl,$VERSION)
16
17 dnl
18 dnl we extract the numerical version for curl-config only
19 VERSIONNUM=`sed -ne 's/^#define LIBCURL_VERSION_NUM 0x\(.*\)/\1/p' ${srcdir}/include/curl/curl.h`
20 AC_SUBST(VERSIONNUM)
21
22 dnl Solaris pkgadd support definitions
23 PKGADD_PKG="HAXXcurl"
24 PKGADD_NAME="cURL - a client that groks URLs"
25 PKGADD_VENDOR="curl.haxx.se"
26 AC_SUBST(PKGADD_PKG)
27 AC_SUBST(PKGADD_NAME)
28 AC_SUBST(PKGADD_VENDOR)
29
30
31 dnl
32 dnl Detect the canonical host and target build environment
33 dnl
34
35 AC_CANONICAL_HOST
36 dnl Get system canonical name
37 AC_DEFINE_UNQUOTED(OS, "${host}")
38
39 dnl Check for AIX weirdos
40 AC_AIX
41
42 dnl Checks for programs.
43 AC_PROG_CC
44
45 dnl check for how to do large files
46 AC_SYS_LARGEFILE
47
48 dnl check for cygwin stuff
49 AC_LIBTOOL_WIN32_DLL
50
51 dnl libtool setup
52 AM_PROG_LIBTOOL
53
54 dnl The install stuff has already been taken care of by the automake stuff
55 dnl AC_PROG_INSTALL
56 AC_PROG_MAKE_SET
57
58 dnl ************************************************************
59 dnl lame option to switch on debug options
60 dnl
61 AC_MSG_CHECKING([whether to enable debug options])
62 AC_ARG_ENABLE(debug,
63 [  --enable-debug               Enable pedantic debug options
64   --disable-debug               Disable debug options],
65 [ case "$enableval" in
66   no)
67        AC_MSG_RESULT(no)
68        ;;
69   *)   AC_MSG_RESULT(yes)
70
71     CPPFLAGS="$CPPFLAGS -DMALLOCDEBUG"
72     CFLAGS="-W -Wall -Wwrite-strings -pedantic -Wundef -Wpointer-arith -Wcast-align -Wnested-externs -g" 
73        ;;
74   esac ],
75        AC_MSG_RESULT(no)
76 )
77
78 dnl **********************************************************************
79 dnl Checks for IPv6
80 dnl **********************************************************************
81
82 AC_MSG_CHECKING([whether to enable ipv6])
83 AC_ARG_ENABLE(ipv6,
84 [  --enable-ipv6                Enable ipv6 (with ipv4) support
85   --disable-ipv6                Disable ipv6 support],
86 [ case "$enableval" in
87   no)
88        AC_MSG_RESULT(no)
89        ipv6=no
90        ;;
91   *)   AC_MSG_RESULT(yes)
92        ipv6=yes
93        ;;
94   esac ],
95
96   AC_TRY_RUN([ /* is AF_INET6 available? */
97 #include <sys/types.h>
98 #include <sys/socket.h>
99 main()
100 {
101  if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
102    exit(1);
103  else
104    exit(0);
105 }
106 ],
107   AC_MSG_RESULT(yes)
108   ipv6=yes,
109   AC_MSG_RESULT(no)
110   ipv6=no,
111   AC_MSG_RESULT(no)
112   ipv6=no
113 ))
114
115 if test "$ipv6" = "yes"; then
116   CURL_CHECK_WORKING_GETADDRINFO
117 fi
118
119
120 dnl **********************************************************************
121 dnl Checks for libraries.
122 dnl **********************************************************************
123
124 dnl gethostbyname in the nsl lib?
125 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))
126
127 if test "$ac_cv_lib_nsl_gethostbyname" != "yes" -a "$ac_cv_func_gethostbyname" != "yes"; then
128   dnl gethostbyname in the socket lib?
129   AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(socket, gethostbyname))
130 fi
131
132 dnl At least one system has been identified to require BOTH nsl and
133 dnl socket libs to link properly.
134 if test "$ac_cv_lib_nsl_gethostbyname" = "$ac_cv_func_gethostbyname"; then
135   AC_MSG_CHECKING([trying both nsl and socket libs])
136   my_ac_save_LIBS=$LIBS
137   LIBS="-lnsl -lsocket $LIBS"
138   AC_TRY_LINK( ,
139              [gethostbyname();],
140              my_ac_link_result=success,
141              my_ac_link_result=failure )
142
143   if test "$my_ac_link_result" = "failure"; then
144     AC_MSG_RESULT([no])
145     AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
146     dnl restore LIBS
147     LIBS=$my_ac_save_LIBS
148   else
149     AC_MSG_RESULT([yes])
150   fi
151 fi
152
153 dnl resolve lib?
154 AC_CHECK_FUNC(strcasecmp, , AC_CHECK_LIB(resolve, strcasecmp))
155
156 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
157   AC_CHECK_LIB(resolve, strcasecmp,
158               [LIBS="-lresolve $LIBS"],
159                ,
160                -lnsl)
161 fi
162
163 dnl socket lib?
164 AC_CHECK_FUNC(connect, , AC_CHECK_LIB(socket, connect))
165
166 dnl ucb lib?
167 AC_CHECK_FUNC(gethostname, , AC_CHECK_LIB(ucb, gethostname))
168
169 dnl dl lib?
170 AC_CHECK_FUNC(dlclose, , AC_CHECK_LIB(dl, dlopen))
171
172 dnl **********************************************************************
173 dnl Check how non-blocking sockets are set
174 dnl **********************************************************************
175 AC_ARG_ENABLE(nonblocking,
176 [  --enable-nonblocking  Makes the script detect how to do it
177   --disable-nonblocking Makes the script disable non-blocking sockets],
178 [
179   if test "$enableval" = "no" ; then
180     AC_MSG_WARN([non-blocking sockets disabled])
181     AC_DEFINE(HAVE_DISABLED_NONBLOCKING)
182   else
183     CURL_CHECK_NONBLOCKING_SOCKET
184   fi
185 ],
186 [
187   CURL_CHECK_NONBLOCKING_SOCKET
188 ])
189
190 dnl **********************************************************************
191 dnl Check for the random seed preferences 
192 dnl **********************************************************************
193
194 AC_ARG_WITH(egd-socket,
195     [  --with-egd-socket=FILE  Entropy Gathering Daemon socket pathname],
196     [ EGD_SOCKET="$withval" ]
197 )
198 if test -n "$EGD_SOCKET" ; then
199         AC_DEFINE_UNQUOTED(EGD_SOCKET, "$EGD_SOCKET")
200 fi
201
202 dnl Check for user-specified random device
203 AC_ARG_WITH(random,
204     [  --with-random=FILE      read randomness from FILE (default=/dev/urandom)],
205     [ RANDOM_FILE="$withval" ],
206     [
207         dnl Check for random device
208         AC_CHECK_FILE("/dev/urandom",
209             [
210                 RANDOM_FILE="/dev/urandom";
211             ]
212         )
213     ]
214 )
215 if test -n "$RANDOM_FILE" ; then
216         AC_SUBST(RANDOM_FILE)
217         AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE")
218 fi
219
220 dnl **********************************************************************
221 dnl Check for the presence of Kerberos4 libraries and headers
222 dnl **********************************************************************
223
224 AC_ARG_WITH(krb4-includes,
225  [  --with-krb4-includes[=DIR]   Specify location of kerberos4 headers],[
226  CPPFLAGS="$CPPFLAGS -I$withval"
227  KRB4INC="$withval"
228  want_krb4=yes
229  ])
230
231 AC_ARG_WITH(krb4-libs,
232  [  --with-krb4-libs[=DIR]   Specify location of kerberos4 libs],[
233  LDFLAGS="$LDFLAGS -L$withval"
234  KRB4LIB="$withval"
235  want_krb4=yes
236  ])
237
238
239 OPT_KRB4=off
240 AC_ARG_WITH(krb4,dnl
241 [  --with-krb4[=DIR]       where to look for Kerberos4],[
242   OPT_KRB4="$withval"
243   if test X"$OPT_KRB4" != Xyes
244   then
245     LDFLAGS="$LDFLAGS -L$OPT_KRB4/lib"
246     KRB4LIB="$OPT_KRB4/lib"
247     CPPFLAGS="$CPPFLAGS -I$OPT_KRB4/include"
248     KRB4INC="$OPT_KRB4/include"
249   fi
250   want_krb4="yes"
251  ])
252
253 AC_MSG_CHECKING([if Kerberos4 support is requested])
254
255 if test "$want_krb4" = yes
256 then
257   if test "$ipv6" = "yes"; then
258     echo krb4 is not compatible with IPv6
259     exit 1
260   fi
261   AC_MSG_RESULT(yes)
262
263   dnl Check for & handle argument to --with-krb4
264
265   AC_MSG_CHECKING(where to look for Kerberos4)
266   if test X"$OPT_KRB4" = Xyes
267   then
268     AC_MSG_RESULT([defaults])
269   else
270     AC_MSG_RESULT([libs in $KRB4LIB, headers in $KRB4INC])
271   fi
272
273   dnl Check for DES library
274   AC_CHECK_LIB(des, des_pcbc_encrypt,
275   [
276     AC_CHECK_HEADERS(des.h)
277
278     dnl resolv lib?
279     AC_CHECK_FUNC(res_search, , AC_CHECK_LIB(resolv, res_search))
280
281     dnl Check for the Kerberos4 library
282     AC_CHECK_LIB(krb, krb_net_read,
283     [
284       dnl Check for header files
285       AC_CHECK_HEADERS(krb.h)
286
287       dnl we found the required libraries, add to LIBS
288       LIBS="-lkrb -ldes $LIBS"
289
290       dnl Check for function krb_get_our_ip_for_realm
291       dnl this is needed for NAT networks
292       AC_CHECK_FUNCS(krb_get_our_ip_for_realm)
293
294       dnl add define KRB4
295       AC_DEFINE(KRB4)
296
297       dnl substitute it too!
298       KRB4_ENABLED=1
299       AC_SUBST(KRB4_ENABLED)
300
301       dnl the krb4 stuff needs a strlcpy()
302       AC_CHECK_FUNCS(strlcpy)
303
304     ])
305   ])
306 else
307   AC_MSG_RESULT(no)
308 fi
309
310
311 dnl **********************************************************************
312 dnl Check for the presence of SSL libraries and headers
313 dnl **********************************************************************
314
315 dnl Default to compiler & linker defaults for SSL files & libraries.
316 OPT_SSL=off
317 AC_ARG_WITH(ssl,dnl
318 [  --with-ssl[=DIR]        where to look for SSL [compiler/linker default paths]
319                           DIR points to the SSL installation [/usr/local/ssl]],
320   OPT_SSL=$withval
321 )
322
323 if test X"$OPT_SSL" = Xno
324 then
325   AC_MSG_WARN(SSL/https support disabled)  
326 else
327
328   dnl Check for and handle argument to --with-ssl.
329
330   dnl save the pre-ssl check flags for a while
331   CLEANLDFLAGS="$LDFLAGS"
332   CLEANCPPFLAGS="$CPPFLAGS"
333
334   case "$OPT_SSL" in
335   yes)
336     EXTRA_SSL=/usr/local/ssl ;;
337   off)
338     EXTRA_SSL= ;;
339   *)
340     dnl check the given spot right away!
341     EXTRA_SSL=$OPT_SSL
342     LDFLAGS="$LDFLAGS -L$EXTRA_SSL/lib"
343     CPPFLAGS="$CPPFLAGS -I$EXTRA_SSL/include/openssl -I$EXTRA_SSL/include"
344     ;;
345   esac
346
347   AC_CHECK_LIB(crypto, CRYPTO_lock,[
348      HAVECRYPTO="yes"
349      ],[
350      OLDLDFLAGS="$LDFLAGS"
351      OLDCPPFLAGS="$CPPFLAGS"
352      LDFLAGS="$CLEANLDFLAGS -L$EXTRA_SSL/lib"
353      CPPFLAGS="$CLEANCPPFLAGS -I$EXTRA_SSL/include/openssl -I$EXTRA_SSL/include"
354      AC_CHECK_LIB(crypto, CRYPTO_add_lock,[
355        HAVECRYPTO="yes" ], [
356        LDFLAGS="$OLDLDFLAGS"
357        CPPFLAGS="$OLDCPPFLAGS"
358        ])
359     ])
360
361
362   if test "$HAVECRYPTO" = "yes"; then
363     dnl This is only reasonable to do if crypto actually is there: check for
364     dnl SSL libs NOTE: it is important to do this AFTER the crypto lib
365
366     AC_CHECK_LIB(crypto, CRYPTO_add_lock)
367     AC_CHECK_LIB(ssl, SSL_connect)
368
369     if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
370         dnl we didn't find the SSL lib, try the RSAglue/rsaref stuff
371         AC_MSG_CHECKING(for ssl with RSAglue/rsaref libs in use);
372         OLIBS=$LIBS
373         LIBS="$LIBS -lRSAglue -lrsaref"
374         AC_CHECK_LIB(ssl, SSL_connect)
375         if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
376             dnl still no SSL_connect
377             AC_MSG_RESULT(no)
378             LIBS=$OLIBS
379         else
380             AC_MSG_RESULT(yes)
381         fi
382     fi
383
384
385     dnl Check for SSLeay headers
386     AC_CHECK_HEADERS(openssl/x509.h openssl/rsa.h openssl/crypto.h \
387                      openssl/pem.h openssl/ssl.h openssl/err.h,
388       OPENSSL_ENABLED=1)
389
390     if test $ac_cv_header_openssl_x509_h = no; then
391       AC_CHECK_HEADERS(x509.h rsa.h crypto.h pem.h ssl.h err.h,
392         OPENSSL_ENABLED=1)
393     fi
394
395     dnl Check for the OpenSSL engine header, it is kind of "separated"
396     dnl from the main SSL check
397     AC_CHECK_HEADERS(openssl/engine.h)
398
399     AC_SUBST(OPENSSL_ENABLED)
400
401   fi
402
403   if test X"$OPT_SSL" != Xoff &&
404      test "$OPENSSL_ENABLED" != "1"; then
405     AC_MSG_ERROR([OpenSSL libs and/or directories were not found where specified!])
406   fi
407
408
409   dnl these can only exist if openssl exists
410
411   AC_CHECK_FUNCS( RAND_status \
412                   RAND_screen \
413                   RAND_egd )
414
415 fi
416
417 dnl **********************************************************************
418 dnl Check for the presence of ZLIB libraries and headers
419 dnl **********************************************************************
420
421 dnl Default to compiler & linker defaults for files & libraries.
422 dnl OPT_ZLIB=no
423 dnl AC_ARG_WITH(zlib,dnl
424 dnl [  --with-zlib[=DIR]  where to look for ZLIB [compiler/linker default paths]
425 dnl                      DIR points to the ZLIB installation prefix [/usr/local]],
426 dnl  OPT_ZLIB=$withval,
427 dnl )
428
429 dnl Check for & handle argument to --with-zlib.
430 dnl
431 dnl NOTE:  We *always* look for ZLIB headers & libraries, all this option
432 dnl        does is change where we look (by adjusting LIBS and CPPFLAGS.)
433 dnl
434
435 dnl AC_MSG_CHECKING(where to look for ZLIB)
436 dnl if test X"$OPT_ZLIB" = Xno
437 dnl then
438 dnl     AC_MSG_RESULT([defaults (or given in environment)])
439 dnl else
440 dnl     test X"$OPT_ZLIB" = Xyes && OPT_ZLIB=/usr/local
441 dnl     LIBS="$LIBS -L$OPT_ZLIB/lib"
442 dnl     CPPFLAGS="$CPPFLAGS -I$OPT_ZLIB/include"
443 dnl     AC_MSG_RESULT([$OPT_ZLIB])
444 dnl fi
445
446 dnl z lib?
447 dnl AC_CHECK_FUNC(gzread, , AC_CHECK_LIB(z, gzread))
448
449
450 dnl Default is to try the thread-safe versions of a few functions
451 OPT_THREAD=on
452 AC_ARG_ENABLE(thread,dnl
453 [  --disable-thread       tell configure to not look for thread-safe functions],
454   OPT_THREAD=off
455 )
456
457 if test X"$OPT_THREAD" = Xoff
458 then
459   AC_MSG_WARN(libcurl will not get built using thread-safe functions)
460   AC_DEFINE(DISABLED_THREADSAFE, 1, \
461 Set to explicitly specify we don't want to use thread-safe functions)
462 else
463
464   dnl dig around for gethostbyname_r()
465   CURL_CHECK_GETHOSTBYNAME_R()
466
467   dnl dig around for gethostbyaddr_r()
468   CURL_CHECK_GETHOSTBYADDR_R()
469
470   dnl poke around for inet_ntoa_r()
471   CURL_CHECK_INET_NTOA_R()
472
473   dnl is there a localtime_r()
474   CURL_CHECK_LOCALTIME_R()
475
476   AC_CHECK_FUNCS( gmtime_r )
477
478 fi
479
480 dnl **********************************************************************
481 dnl Back to "normal" configuring
482 dnl **********************************************************************
483
484 dnl Checks for header files.
485 AC_HEADER_STDC
486 AC_CHECK_HEADERS( \
487         unistd.h \
488         malloc.h \
489         stdlib.h \
490         arpa/inet.h \
491         net/if.h \
492         netinet/in.h \
493         netinet/if_ether.h \
494         netdb.h \
495         sys/select.h \
496         sys/socket.h \
497         sys/sockio.h \
498         sys/stat.h \
499         sys/types.h \
500         sys/time.h \
501         sys/param.h \
502         termios.h \
503         termio.h \
504         sgtty.h \
505         fcntl.h \
506         dlfcn.h \
507         alloca.h \
508         winsock.h \
509         time.h \
510         io.h \
511         pwd.h \
512         utime.h \
513         sys/utime.h
514 )
515
516 dnl Check for libz header
517 dnl AC_CHECK_HEADERS(zlib.h)
518
519 dnl Checks for typedefs, structures, and compiler characteristics.
520 AC_C_CONST
521 AC_TYPE_SIZE_T
522 AC_HEADER_TIME
523
524 # mprintf() checks:
525
526 # check for 'long double'
527 # AC_CHECK_SIZEOF(long double, 8)
528 # check for 'long long'
529 # AC_CHECK_SIZEOF(long long, 4)
530
531 # check for ssize_t
532 AC_CHECK_TYPE(ssize_t, int)
533
534 TYPE_SOCKLEN_T
535 TYPE_IN_ADDR_T
536
537 dnl Checks for library functions.
538 dnl AC_PROG_GCC_TRADITIONAL
539 AC_TYPE_SIGNAL
540 dnl AC_FUNC_VPRINTF
541 AC_CHECK_FUNCS( socket \
542                 select \
543                 strdup \
544                 strstr \
545                 strtok_r \
546                 strftime \
547                 uname \
548                 strcasecmp \
549                 stricmp \
550                 strcmpi \
551                 gethostname \
552                 gethostbyaddr \
553                 gettimeofday \
554                 inet_addr \
555                 inet_ntoa \
556                 tcsetattr \
557                 tcgetattr \
558                 perror \
559                 closesocket \
560                 setvbuf \
561                 sigaction \
562                 signal \
563                 getpass_r \
564                 strlcat \
565                 getpwuid \
566                 geteuid \
567                 dlopen \
568                 utime
569 )
570
571 dnl removed 'getpass' check on October 26, 2000
572
573 if test "$ac_cv_func_select" != "yes"; then
574   AC_MSG_ERROR(Can't work without an existing select() function)
575 fi
576 if test "$ac_cv_func_socket" != "yes"; then
577   AC_MSG_ERROR(Can't work without an existing socket() function)
578 fi
579
580 AC_PATH_PROG( PERL, perl, , 
581   $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
582 AC_SUBST(PERL)
583
584 AC_PATH_PROGS( NROFF, gnroff nroff, , 
585   $PATH:/usr/bin/:/usr/local/bin )
586 AC_SUBST(NROFF)
587
588 AC_PROG_YACC
589
590 dnl AC_PATH_PROG( RANLIB, ranlib, /usr/bin/ranlib, 
591 dnl   $PATH:/usr/bin/:/usr/local/bin )
592 dnl AC_SUBST(RANLIB)
593
594 AC_CONFIG_FILES([Makefile \
595            docs/Makefile \
596            docs/examples/Makefile \
597            include/Makefile \
598            include/curl/Makefile \
599            src/Makefile \
600            multi/Makefile \
601            lib/Makefile \
602            tests/Makefile \
603            tests/data/Makefile \
604            tests/server/Makefile \
605            packages/Makefile \
606            packages/Win32/Makefile \
607            packages/Win32/cygwin/Makefile \
608            packages/Linux/Makefile \
609            packages/Linux/RPM/Makefile \
610            packages/Linux/RPM/curl.spec \
611            packages/Linux/RPM/curl-ssl.spec \
612            packages/Solaris/Makefile \
613            curl-config
614 ])
615 AC_OUTPUT
616