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