added signal in case sigaction is missing
[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' 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
30 dnl **********************************************************************
31 dnl Checks for libraries.
32 dnl **********************************************************************
33
34 dnl nsl lib?
35 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))
36
37 dnl At least one system has been identified to require BOTH nsl and
38 dnl socket libs to link properly.
39 if test "$ac_cv_lib_nsl_gethostbyname" = "$ac_cv_func_gethostbyname"; then
40   AC_MSG_CHECKING([trying both nsl and socket libs])
41   my_ac_save_LIBS=$LIBS
42   LIBS="-lnsl -lsocket $LIBS"
43   AC_TRY_LINK( ,
44              [gethostbyname();],
45              my_ac_link_result=success,
46              my_ac_link_result=failure )
47
48   if test "$my_ac_link_result" = "failure"; then
49     AC_MSG_RESULT([no])
50     AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
51     dnl restore LIBS
52     LIBS=$my_ac_save_LIBS
53   else
54     AC_MSG_RESULT([yes])
55   fi
56 fi
57
58 dnl resolve lib?
59 AC_CHECK_FUNC(strcasecmp, , AC_CHECK_LIB(resolve, strcasecmp))
60
61 if test "$ac_cv_lib_resolve_strcasecmp" = "$ac_cv_func_strcasecmp"; then
62   AC_CHECK_LIB(resolve, strcasecmp,
63               [LIBS="-lresolve $LIBS"],
64                ,
65                -lnsl)
66 fi
67
68 dnl socket lib?
69 AC_CHECK_FUNC(connect, , AC_CHECK_LIB(socket, connect))
70
71 dnl ucb lib?
72 AC_CHECK_FUNC(gethostname, , AC_CHECK_LIB(ucb, gethostname))
73
74 dnl dl lib?
75 AC_CHECK_FUNC(dlopen, , AC_CHECK_LIB(dl, dlopen))
76
77 dnl **********************************************************************
78 dnl Check for the presence of Kerberos4 libraries and headers
79 dnl **********************************************************************
80
81 AC_ARG_WITH(krb4-includes,
82  [  --with-krb4-includes[=DIR]   Specify location of kerberos4 headers],[
83  CPPFLAGS="$CPPFLAGS -I$withval"
84  KRB4INC="$withval"
85  want_krb4=yes
86  ])
87
88 AC_ARG_WITH(krb4-libs,
89  [  --with-krb4-libs[=DIR]   Specify location of kerberos4 libs],[
90  LDFLAGS="$LDFLAGS -L$withval"
91  KRB4LIB="$withval"
92  want_krb4=yes
93  ])
94
95
96 OPT_KRB4=off
97 AC_ARG_WITH(krb4,dnl
98 [  --with-krb4[=DIR]       where to look for Kerberos4],[
99   OPT_KRB4="$withval"
100   if test X"$OPT_KRB4" != Xyes
101   then
102     LDFLAGS="$LDFLAGS -L$OPT_KRB4/lib"
103     KRB4LIB="$OPT_KRB4/lib"
104     CPPFLAGS="$CPPFLAGS -I$OPT_KRB4/include"
105     KRB4INC="$OPT_KRB4/include"
106   fi
107   want_krb4="yes"
108  ])
109
110 AC_MSG_CHECKING([if Kerberos4 support is requested])
111
112 if test "$want_krb4" = yes
113 then
114   AC_MSG_RESULT(yes)
115
116   dnl Check for & handle argument to --with-krb4
117
118   AC_MSG_CHECKING(where to look for Kerberos4)
119   if test X"$OPT_KRB4" = Xyes
120   then
121     AC_MSG_RESULT([defaults])
122   else
123     AC_MSG_RESULT([libs in $KRB4LIB, headers in $KRB4INC])
124   fi
125
126   dnl Check for DES library
127   AC_CHECK_LIB(des, des_pcbc_encrypt,
128   [
129     AC_CHECK_HEADERS(des.h)
130
131     dnl resolv lib?
132     AC_CHECK_FUNC(res_search, , AC_CHECK_LIB(resolv, res_search))
133
134     dnl Check for the Kerberos4 library
135     AC_CHECK_LIB(krb, krb_net_read,
136     [
137       dnl Check for header files
138       AC_CHECK_HEADERS(krb.h)
139
140       dnl we found the required libraries, add to LIBS
141       LIBS="-lkrb -ldes $LIBS"
142
143       dnl Check for function krb_get_our_ip_for_realm
144       dnl this is needed for NAT networks
145       AC_CHECK_FUNCS(krb_get_our_ip_for_realm)
146
147       dnl add define KRB4
148       AC_DEFINE(KRB4)
149
150       dnl the krb4 stuff needs a strlcpy()
151       AC_CHECK_FUNCS(strlcpy)
152
153     ])
154   ])
155 else
156   AC_MSG_RESULT(no)
157 fi
158
159 dnl **********************************************************************
160 dnl Check for the presence of SSL libraries and headers
161 dnl **********************************************************************
162
163 dnl Default to compiler & linker defaults for SSL files & libraries.
164 OPT_SSL=off
165 AC_ARG_WITH(ssl,dnl
166 [  --with-ssl[=DIR]        where to look for SSL [compiler/linker default paths]
167                           DIR points to the SSL installation [/usr/local/ssl]],
168   OPT_SSL=$withval
169 )
170
171 if test X"$OPT_SSL" = Xno
172 then
173   AC_MSG_WARN(SSL/https support disabled)  
174 else
175
176   dnl Check for & handle argument to --with-ssl.
177
178   AC_MSG_CHECKING(where to look for SSL)
179   if test X"$OPT_SSL" = Xoff
180   then
181         AC_MSG_RESULT([defaults (or given in environment)])
182   else
183         test X"$OPT_SSL" = Xyes && OPT_SSL=/usr/local/ssl
184         LIBS="$LIBS -L$OPT_SSL/lib"
185         CPPFLAGS="$CPPFLAGS -I$OPT_SSL/include/openssl -I$OPT_SSL/include"
186         AC_MSG_RESULT([$OPT_SSL])
187   fi
188
189   dnl check for crypto libs (part of SSLeay)
190   AC_CHECK_LIB(crypto, CRYPTO_lock)
191
192   if test $ac_cv_lib_crypto_CRYPTO_lock = yes; then
193     dnl This is only reasonable to do if crypto actually is there: check for
194     dnl SSL libs NOTE: it is important to do this AFTER the crypto lib
195     AC_CHECK_LIB(ssl, SSL_connect)
196
197     dnl Check for SSLeay headers
198     AC_CHECK_HEADERS(openssl/x509.h openssl/rsa.h openssl/crypto.h openssl/pem.h openssl/ssl.h openssl/err.h)
199
200     if test $ac_cv_header_openssl_x509_h = no; then
201       AC_CHECK_HEADERS(x509.h rsa.h crypto.h pem.h ssl.h err.h)
202     fi
203
204   fi
205
206   dnl these can only exist if openssl exists
207
208   AC_CHECK_FUNCS( RAND_status \
209                   RAND_screen )
210
211 fi
212
213 dnl **********************************************************************
214 dnl Check for the presence of ZLIB libraries and headers
215 dnl **********************************************************************
216
217 dnl Default to compiler & linker defaults for files & libraries.
218 dnl OPT_ZLIB=no
219 dnl AC_ARG_WITH(zlib,dnl
220 dnl [  --with-zlib[=DIR]  where to look for ZLIB [compiler/linker default paths]
221 dnl                      DIR points to the ZLIB installation prefix [/usr/local]],
222 dnl  OPT_ZLIB=$withval,
223 dnl )
224
225 dnl Check for & handle argument to --with-zlib.
226 dnl
227 dnl NOTE:  We *always* look for ZLIB headers & libraries, all this option
228 dnl        does is change where we look (by adjusting LIBS and CPPFLAGS.)
229 dnl
230
231 dnl AC_MSG_CHECKING(where to look for ZLIB)
232 dnl if test X"$OPT_ZLIB" = Xno
233 dnl then
234 dnl     AC_MSG_RESULT([defaults (or given in environment)])
235 dnl else
236 dnl     test X"$OPT_ZLIB" = Xyes && OPT_ZLIB=/usr/local
237 dnl     LIBS="$LIBS -L$OPT_ZLIB/lib"
238 dnl     CPPFLAGS="$CPPFLAGS -I$OPT_ZLIB/include"
239 dnl     AC_MSG_RESULT([$OPT_ZLIB])
240 dnl fi
241
242 dnl z lib?
243 dnl AC_CHECK_FUNC(gzread, , AC_CHECK_LIB(z, gzread))
244
245
246 dnl Default is to try the thread-safe versions of a few functions
247 OPT_THREAD=on
248 AC_ARG_ENABLE(thread,dnl
249 [  --disable-thread       tell configure to not look for thread-safe functions],
250   OPT_THREAD=off
251 )
252
253 if test X"$OPT_THREAD" = Xoff
254 then
255   AC_MSG_WARN(libcurl will not get built using thread-safe functions)
256   AC_DEFINE(DISABLED_THREADSAFE, 1, \
257 Set to explicitly specify we don't want to use thread-safe functions)
258 else
259   dnl check for number of arguments to gethostbyname_r. it might take
260   dnl either 3, 5, or 6 arguments.
261   AC_CHECK_FUNCS(gethostbyname_r,[
262     AC_MSG_CHECKING(if gethostbyname_r takes 3 arguments)
263     AC_TRY_RUN([
264 #include <string.h>
265 #include <sys/types.h>
266 #include <netdb.h>
267
268 int
269 main () {
270 struct hostent h;
271 struct hostent_data hdata;
272 char *name = "localhost";
273 int rc;
274 memset(&h, 0, sizeof(struct hostent));
275 memset(&hdata, 0, sizeof(struct hostent_data));
276 rc = gethostbyname_r(name, &h, &hdata);
277 exit (rc != 0 ? 1 : 0); }],[
278       AC_MSG_RESULT(yes)
279       AC_DEFINE(HAVE_GETHOSTBYNAME_R_3)
280       ac_cv_gethostbyname_args=3],[
281       AC_MSG_RESULT(no)
282       AC_MSG_CHECKING(if gethostbyname_r with -D_REENTRANT takes 3 arguments)
283       AC_TRY_RUN([
284 #define _REENTRANT
285
286 #include <string.h>
287 #include <sys/types.h>
288 #include <netdb.h>
289
290 int
291 main () {
292 struct hostent h;
293 struct hostent_data hdata;
294 char *name = "localhost";
295 int rc;
296 memset(&h, 0, sizeof(struct hostent));
297 memset(&hdata, 0, sizeof(struct hostent_data));
298 rc = gethostbyname_r(name, &h, &hdata);
299 exit (rc != 0 ? 1 : 0); }],[
300         AC_MSG_RESULT(yes)
301         AC_DEFINE(HAVE_GETHOSTBYNAME_R_3)
302         AC_DEFINE(NEED_REENTRANT)
303         ac_cv_gethostbyname_args=3],[
304         AC_MSG_RESULT(no)
305         AC_MSG_CHECKING(if gethostbyname_r takes 5 arguments)
306         AC_TRY_RUN([
307 #include <sys/types.h>
308 #include <netdb.h>
309
310 int
311 main () {
312 struct hostent *hp;
313 struct hostent h;
314 char *name = "localhost";
315 char buffer[8192];
316 int h_errno;
317 hp = gethostbyname_r(name, &h, buffer, 8192, &h_errno);
318 exit (hp == NULL ? 1 : 0); }],[
319           AC_MSG_RESULT(yes)
320           AC_DEFINE(HAVE_GETHOSTBYNAME_R_5)
321           ac_cv_gethostbyname_args=5],[
322           AC_MSG_RESULT(no)
323           AC_MSG_CHECKING(if gethostbyname_r takes 6 arguments)
324           AC_TRY_RUN([
325 #include <sys/types.h>
326 #include <netdb.h>
327
328 int
329 main () {
330 struct hostent h;
331 struct hostent *hp;
332 char *name = "localhost";
333 char buf[8192];
334 int rc;
335 int h_errno;
336 rc = gethostbyname_r(name, &h, buf, 8192, &hp, &h_errno);
337 exit (rc != 0 ? 1 : 0); }],[
338             AC_MSG_RESULT(yes)
339             AC_DEFINE(HAVE_GETHOSTBYNAME_R_6)
340             ac_cv_gethostbyname_args=6],[
341             AC_MSG_RESULT(no)
342             have_missing_r_funcs="$have_missing_r_funcs gethostbyname_r"],
343             [ac_cv_gethostbyname_args=0])],
344           [ac_cv_gethostbyname_args=0])],
345         [ac_cv_gethostbyname_args=0])],
346       [ac_cv_gethostbyname_args=0])])
347
348   dnl check for number of arguments to gethostbyaddr_r. it might take
349   dnl either 5, 7, or 8 arguments.
350   AC_CHECK_FUNCS(gethostbyaddr_r,[
351     AC_MSG_CHECKING(if gethostbyaddr_r takes 5 arguments)
352     AC_TRY_COMPILE([
353 #include <sys/types.h>
354 #include <netdb.h>],[
355 char * address;
356 int length;
357 int type;
358 struct hostent h;
359 struct hostent_data hdata;
360 int rc;
361 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
362       AC_MSG_RESULT(yes)
363       AC_DEFINE(HAVE_GETHOSTBYADDR_R_5)
364       ac_cv_gethostbyaddr_args=5],[
365       AC_MSG_RESULT(no)
366       AC_MSG_CHECKING(if gethostbyaddr_r with -D_REENTRANT takes 5 arguments)
367       AC_TRY_COMPILE([
368 #define _REENTRANT
369 #include <sys/types.h>
370 #include <netdb.h>],[
371 char * address;
372 int length;
373 int type;
374 struct hostent h;
375 struct hostent_data hdata;
376 int rc;
377 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
378         AC_MSG_RESULT(yes)
379         AC_DEFINE(HAVE_GETHOSTBYADDR_R_5)
380         AC_DEFINE(NEED_REENTRANT)
381         ac_cv_gethostbyaddr_args=5],[
382         AC_MSG_RESULT(no)
383         AC_MSG_CHECKING(if gethostbyaddr_r takes 7 arguments)
384         AC_TRY_COMPILE([
385 #include <sys/types.h>
386 #include <netdb.h>],[
387 char * address;
388 int length;
389 int type;
390 struct hostent h;
391 char buffer[8192];
392 int h_errnop;
393 struct hostent * hp;
394
395 hp = gethostbyaddr_r(address, length, type, &h,
396                      buffer, 8192, &h_errnop);],[
397           AC_MSG_RESULT(yes)
398           AC_DEFINE(HAVE_GETHOSTBYADDR_R_7)
399           ac_cv_gethostbyaddr_args=7],[
400           AC_MSG_RESULT(no)
401           AC_MSG_CHECKING(if gethostbyaddr_r takes 8 arguments)
402           AC_TRY_COMPILE([
403 #include <sys/types.h>
404 #include <netdb.h>],[
405 char * address;
406 int length;
407 int type;
408 struct hostent h;
409 char buffer[8192];
410 int h_errnop;
411 struct hostent * hp;
412 int rc;
413
414 rc = gethostbyaddr_r(address, length, type, &h,
415                      buffer, 8192, &hp, &h_errnop);],[
416             AC_MSG_RESULT(yes)
417             AC_DEFINE(HAVE_GETHOSTBYADDR_R_8)
418             ac_cv_gethostbyaddr_args=8],[
419             AC_MSG_RESULT(no)
420             have_missing_r_funcs="$have_missing_r_funcs gethostbyaddr_r"])])])])])
421
422   dnl determine if function definition for inet_ntoa_r exists.
423   AC_CHECK_FUNCS(inet_ntoa_r,[
424     AC_MSG_CHECKING(whether inet_ntoa_r is declared)
425     AC_EGREP_CPP(inet_ntoa_r,[
426 #include <arpa/inet.h>],[
427       AC_DEFINE(HAVE_INET_NTOA_R_DECL)
428       AC_MSG_RESULT(yes)],[
429       AC_MSG_RESULT(no)
430       AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
431       AC_EGREP_CPP(inet_ntoa_r,[
432 #define _REENTRANT
433 #include <arpa/inet.h>],[
434         AC_DEFINE(HAVE_INET_NTOA_R_DECL)
435         AC_DEFINE(NEED_REENTRANT)
436         AC_MSG_RESULT(yes)],
437         AC_MSG_RESULT(no))])])
438
439   dnl check for a few thread-safe functions
440   AC_CHECK_FUNCS(localtime_r,[
441     AC_MSG_CHECKING(whether localtime_r is declared)
442     AC_EGREP_CPP(localtime_r,[
443 #include <time.h>],[
444       AC_MSG_RESULT(yes)],[
445       AC_MSG_RESULT(no)
446       AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
447       AC_EGREP_CPP(localtime_r,[
448 #define _REENTRANT
449 #include <time.h>],[
450         AC_DEFINE(NEED_REENTRANT)
451         AC_MSG_RESULT(yes)],
452         AC_MSG_RESULT(no))])])
453 fi
454
455 dnl **********************************************************************
456 dnl Back to "normal" configuring
457 dnl **********************************************************************
458
459 dnl Checks for header files.
460 AC_HEADER_STDC
461 AC_CHECK_HEADERS( \
462         unistd.h \
463         malloc.h \
464         stdlib.h \
465         arpa/inet.h \
466         net/if.h \
467         netinet/in.h \
468         netinet/if_ether.h \
469         netdb.h \
470         sys/select.h \
471         sys/socket.h \
472         sys/sockio.h \
473         sys/stat.h \
474         sys/types.h \
475         sys/time.h \
476         getopt.h \
477         sys/param.h \
478         termios.h \
479         termio.h \
480         sgtty.h \
481         fcntl.h \
482         dlfcn.h \
483         alloca.h \
484         winsock.h \
485         time.h \
486         io.h \
487 )
488
489 dnl Check for libz header
490 dnl AC_CHECK_HEADERS(zlib.h)
491
492 dnl Checks for typedefs, structures, and compiler characteristics.
493 AC_C_CONST
494 AC_TYPE_SIZE_T
495 AC_HEADER_TIME
496
497 # mprintf() checks:
498
499 # check for 'long double'
500 AC_CHECK_SIZEOF(long double, 8)
501 # check for 'long long'
502 AC_CHECK_SIZEOF(long long, 4)
503
504 dnl Get system canonical name
505 AC_CANONICAL_HOST
506 AC_DEFINE_UNQUOTED(OS, "${host}")
507
508 dnl Checks for library functions.
509 dnl AC_PROG_GCC_TRADITIONAL
510 AC_TYPE_SIGNAL
511 dnl AC_FUNC_VPRINTF
512 AC_CHECK_FUNCS( socket \
513                 select \
514                 strdup \
515                 strstr \
516                 strftime \
517                 uname \
518                 strcasecmp \
519                 stricmp \
520                 strcmpi \
521                 gethostname \
522                 gethostbyaddr \
523                 getservbyname \
524                 gettimeofday \
525                 inet_addr \
526                 inet_ntoa \
527                 tcsetattr \
528                 tcgetattr \
529                 perror \
530                 closesocket \
531                 setvbuf \
532                 sigaction \
533                 signal
534 )
535
536 dnl removed 'getpass' check on October 26, 2000
537
538 if test "$ac_cv_func_select" != "yes"; then
539   AC_MSG_ERROR(Can't work without an existing socket() function)
540 fi
541
542 AC_PATH_PROG( PERL, perl, , 
543   $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
544 AC_SUBST(PERL)
545
546 AC_PATH_PROGS( NROFF, gnroff nroff, , 
547   $PATH:/usr/bin/:/usr/local/bin )
548 AC_SUBST(NROFF)
549
550 AC_PROG_YACC
551
552 dnl AC_PATH_PROG( RANLIB, ranlib, /usr/bin/ranlib, 
553 dnl   $PATH:/usr/bin/:/usr/local/bin )
554 dnl AC_SUBST(RANLIB)
555
556 AC_OUTPUT( Makefile \
557            docs/Makefile \
558            include/Makefile \
559            include/curl/Makefile \
560            src/Makefile \
561            lib/Makefile )
562 dnl        perl/checklinks.pl \
563 dnl        perl/getlinks.pl \
564 dnl        perl/formfind.pl \
565 dnl        perl/recursiveftpget.pl  )