]> sjero.net Git - wget/blob - configure.in
[svn] Rewrite parsing and handling of URLs.
[wget] / configure.in
1 dnl Template file for GNU Autoconf
2 dnl Copyright (C) 1995, 1996, 1997, 2001 Free Software Foundation, Inc.
3
4 dnl This program is free software; you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation; either version 2 of the License, or
7 dnl (at your option) any later version.
8
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program; if not, write to the Free Software
16 dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 dnl
19 dnl Process this file with autoconf to produce a configure script.
20 dnl
21
22 AC_INIT(src/version.c)
23 AC_PREREQ(2.12)
24 AC_CONFIG_HEADER(src/config.h)
25
26 dnl
27 dnl What version of Wget are we building?
28 dnl
29 VERSION=`sed -e 's/^.*"\(.*\)";$/\1/' ${srcdir}/src/version.c`
30 echo "configuring for GNU Wget $VERSION"
31 AC_SUBST(VERSION)
32 PACKAGE=wget
33 AC_SUBST(PACKAGE)
34
35 dnl
36 dnl Get cannonical host
37 dnl
38 AC_CANONICAL_HOST
39 AC_DEFINE_UNQUOTED(OS_TYPE, "$host_os")
40
41 dnl
42 dnl Process features.
43 dnl
44 AC_ARG_WITH(socks,
45 [  --with-socks            use the socks library],
46 [AC_DEFINE(HAVE_SOCKS)])
47
48 AC_ARG_WITH(ssl,
49 [  --with-ssl[=SSL_ROOT]   link with libssl [in SSL_ROOT/lib] for https: support])
50
51 AC_ARG_ENABLE(opie,
52 [  --disable-opie          disable support for opie or s/key FTP login],
53 USE_OPIE=$enableval, USE_OPIE=yes)
54 test x"${USE_OPIE}" = xyes && AC_DEFINE(USE_OPIE)
55
56 AC_ARG_ENABLE(digest,
57 [  --disable-digest        disable support for HTTP digest authorization],
58 USE_DIGEST=$enableval, USE_DIGEST=yes)
59 test x"${USE_DIGEST}" = xyes && AC_DEFINE(USE_DIGEST)
60
61 AC_ARG_ENABLE(debug,
62 [  --disable-debug         disable support for debugging output],
63 DEBUG=$enableval, DEBUG=yes)
64 test x"${DEBUG}" = xyes && AC_DEFINE(DEBUG)
65
66 wget_need_md5=no
67
68 case "${USE_OPIE}${USE_DIGEST}" in
69 *yes*)
70         wget_need_md5=yes
71 esac
72 if test x"$USE_OPIE" = xyes; then
73   OPIE_OBJ='ftp-opie$o'
74 fi
75 AC_SUBST(OPIE_OBJ)
76
77 dnl
78 dnl Whether make sets $(MAKE)...
79 dnl
80 AC_PROG_MAKE_SET
81
82 dnl
83 dnl Find a good install
84 dnl
85 AC_PROG_INSTALL
86
87 dnl
88 dnl Find the compiler
89 dnl
90
91 dnl We want these before the checks, so the checks can modify their values.
92 test -z "$CFLAGS"  && CFLAGS= auto_cflags=1
93 test -z "$CC" && cc_specified=yes
94
95 AC_PROG_CC
96
97 dnl
98 dnl if the user hasn't specified CFLAGS, then
99 dnl   if compiler is gcc, then use -O2 and some warning flags
100 dnl   else use os-specific flags or -O
101 dnl
102 if test -n "$auto_cflags"; then
103   if test -n "$GCC"; then
104     CFLAGS="$CFLAGS -O2 -Wall -Wno-implicit"
105   else
106     case "$host_os" in
107       *hpux*)  CFLAGS="$CFLAGS +O3"                      ;;
108       *ultrix* | *osf*) CFLAGS="$CFLAGS -O -Olimit 2000" ;;
109       *)       CFLAGS="$CFLAGS -O" ;;
110     esac
111   fi
112 fi
113
114 dnl
115 dnl Handle AIX
116 dnl
117 AC_AIX
118
119 dnl
120 dnl Configure our included libtool and make sure it's regenerated when needed
121 dnl
122 AC_PROG_LIBTOOL
123 AC_SUBST(LIBTOOL_DEPS)
124
125 dnl
126 dnl In case of {cyg,gnu}win32.  Should be a _target_ test.
127 dnl Might also be erelevant for DJGPP.
128 dnl
129 case "$host_os" in
130   *win32) exeext='.exe';;
131   *) exeext='';;
132 esac
133 AC_SUBST(exeext)
134
135 dnl
136 dnl Check if we can handle prototypes.
137 dnl
138 AM_C_PROTOTYPES
139
140 dnl
141 dnl Checks for typedefs, structures, and compiler characteristics.
142 dnl
143 AC_C_CONST
144 AC_C_INLINE
145 AC_TYPE_SIZE_T
146 AC_TYPE_PID_T
147 dnl #### This generates a warning.  What do I do to shut it up?
148 AC_C_BIGENDIAN
149
150 # Check size of long.
151 AC_CHECK_SIZEOF(long)
152 AC_CHECK_SIZEOF(long long)
153
154 dnl
155 dnl Checks for headers
156 dnl
157 AC_CHECK_HEADERS(string.h stdarg.h unistd.h sys/time.h utime.h sys/utime.h)
158 AC_CHECK_HEADERS(sys/select.h sys/utsname.h pwd.h signal.h)
159 AC_HEADER_TIME
160
161 dnl
162 dnl Return type of signal-handlers
163 dnl
164 AC_TYPE_SIGNAL
165
166 dnl
167 dnl Check for struct utimbuf
168 WGET_STRUCT_UTIMBUF
169
170 dnl
171 dnl Checks for library functions.
172 dnl
173 AC_FUNC_ALLOCA
174 AC_FUNC_MMAP
175 AC_CHECK_FUNCS(strdup strstr strcasecmp strncasecmp strpbrk)
176 AC_CHECK_FUNCS(gettimeofday mktime strptime)
177 AC_CHECK_FUNCS(strerror snprintf vsnprintf select signal symlink access isatty)
178 AC_CHECK_FUNCS(uname gethostname)
179
180 dnl
181 dnl Check if we need to compile in getopt.c.
182 dnl
183 AC_CHECK_FUNC(getopt_long, [], [
184   GETOPT_OBJ='getopt$o'
185 ])
186 AC_SUBST(GETOPT_OBJ)
187
188 dnl
189 dnl Checks for libraries.
190 dnl
191
192 dnl
193 dnl Use the md5 lib if available (Solaris).
194 dnl
195
196 if test x$wget_need_md5 = xyes
197 then
198   AC_DEFINE(HAVE_MD5)
199   AC_CHECK_LIB(md5, MD5Update, [
200     AC_DEFINE(HAVE_SOLARIS_MD5)
201     LIBS="-lmd5 $LIBS"
202     ], [
203     MD5_OBJ='gnu-md5$o'
204     AC_DEFINE(HAVE_BUILTIN_MD5)
205   ])
206 fi
207 AC_SUBST(MD5_OBJ)
208
209 dnl On Solaris, -lnsl is needed to use gethostbyname.  On "NCR MP-RAS
210 dnl 3.0", however, gethostbyname is in libc, but -lnsl is still needed
211 dnl to use -lsocket, as well as for functions such as inet_ntoa.  We
212 dnl look for such known offenders and if one of them is not found, we
213 dnl check if -lnsl is needed.
214
215 wget_check_in_nsl=NONE
216 AC_CHECK_FUNCS(gethostbyname, [], [
217   wget_check_in_nsl=gethostbyname
218 ])
219 AC_CHECK_FUNCS(inet_ntoa, [], [
220   wget_check_in_nsl=inet_ntoa
221 ])
222 if test $wget_check_in_nsl != NONE; then
223   AC_CHECK_LIB(nsl, $wget_check_in_nsl)
224 fi
225
226 AC_CHECK_LIB(socket, socket)
227
228 dnl #### This appears to be deficient with later versions of SOCKS.
229 if test "x${with_socks}" = xyes
230 then
231   AC_CHECK_LIB(resolv, main)
232   AC_CHECK_LIB(socks, Rconnect)
233 fi
234
235 dnl If --with-ssl was specified, make sure we can link with the
236 dnl OpenSSL libs.  We should probably auto-detect this by default.
237
238 if test x"$with_ssl" != x -a x"$with_ssl" != x"no"; then
239   if test x"$with_ssl" = x"yes"; then
240     dnl OpenSSL's default install location is "/usr/local/ssl".  We also
241     dnl allow /usr/local for regular-style install, and /usr for Linux
242     dnl stuff.
243     ssl_all_roots="default /usr/local/ssl /usr/local /opt"
244   else
245     dnl Root has been kindly provided by the user.
246     ssl_all_roots=$with_ssl
247   fi
248
249   wget_save_LIBS=$LIBS
250   wget_save_LDFLAGS=$LDFLAGS
251   wget_save_CC=$CC
252
253   dnl Use libtool for OpenSSL tests to handle the "-R<rpath>" option.
254   CC="$SHELL ./libtool $CC"
255
256   dnl Unfortunately, as of this writing (OpenSSL 0.9.6), the libcrypto
257   dnl shared library doesn't record its dependency on libdl, so we
258   dnl need to check for it ourselves so we won't fail to link due to a
259   dnl lack of -ldl.  Most OSes use dlopen(), but HP-UX uses
260   dnl shl_load().
261   AC_CHECK_LIB(dl,dlopen)
262   AC_CHECK_LIB(dl,shl_load)
263
264   ssl_linked=no
265
266   dnl Now try to find SSL libraries in each of the likely SSL roots.
267   for ssl_root in $ssl_all_roots
268   do
269     if test x"$ssl_root" = xdefault; then
270       dnl Try the default library locations.
271       SSL_INCLUDES=
272     else
273       dnl Try this specific root.
274       SSL_INCLUDES=-I$ssl_root/include
275       dnl It's OK to use -R directly because libtool will
276       dnl interpret it for us.
277       LDFLAGS="-L$ssl_root/lib -R$ssl_root/lib $wget_save_LDFLAGS"
278     fi
279
280     ssl_link_failure=no
281
282     AC_MSG_RESULT(["Looking for SSL libraries in $ssl_root"])
283
284     dnl Make sure that the checks don't run afoul of the cache.  It
285     dnl would be nicer to temporarily turn off the cache, but
286     dnl apparently Autoconf doesn't allow that.
287
288     unset ac_cv_lib_crypto_RSA_new
289     unset ac_cv_lib_ssl_SSL_new
290
291     dnl These checks need to be in this order, or you'll get a link
292     dnl failure if you use a static libcrypto.a and libssl.a rather
293     dnl than shared libraries.
294
295     AC_CHECK_LIB(crypto, RSA_new, , ssl_link_failure=yes)
296     AC_CHECK_LIB(ssl, SSL_new, , ssl_link_failure=yes)
297
298     dnl If ssl_link_failure is still no, the libraries link.  But we
299     dnl still need to check if the program linked with those libraries
300     dnl under these settings with run.  On some systems (Solaris), Gcc
301     dnl adds -L/usr/local/lib to the linking line, but fails to add
302     dnl -R/usr/local/lib, thus creating executables that link, but
303     dnl fail to run.
304
305     dnl If we are cross-compiling, just assume that working linkage
306     dnl implies working executable.
307
308     if test x"$ssl_link_failure" = xno; then
309       dnl Now try to run the thing.
310       AC_MSG_CHECKING("whether SSL libs are resolved at runtime")
311       AC_TRY_RUN([
312 int RSA_new();
313 int SSL_new();
314 main(){return 0;}
315 ],
316         AC_MSG_RESULT("yes"),
317         AC_MSG_RESULT("no"); ssl_link_failure=yes,
318         AC_MSG_RESULT("cross"))
319     fi
320
321     if test x"$ssl_link_failure" = xno; then
322       dnl This echo doesn't look right, but I'm not sure what to use
323       dnl instead.
324       AC_MSG_RESULT("Compiling in support for SSL in $ssl_root")
325       AC_DEFINE(HAVE_SSL)
326       AC_SUBST(SSL_INCLUDES)
327       SSL_OBJ='gen_sslfunc$o'
328       AC_SUBST(SSL_OBJ)
329       ssl_linked=yes
330       break
331     fi
332   done
333
334   if test x"$ssl_linked" = xno; then
335     LD_FLAGS=$wget_save_LDFLAGS
336     LIBS=$wget_save_LIBS
337
338     dnl Perhaps we should abort here.  Dan argues that configure
339     dnl scripts shouldn't abort out of principle, but on the other
340     dnl hand remember that the user explicitly requested linking with
341     dnl SSL.
342
343     dnl IMHO there should be a way to specify whether SSL should be
344     dnl avoided, auto-detected, or required, defaulting to
345     dnl `autodetect'.  Only in the `require' mode the script would
346     dnl abort if SSL is not found.
347     echo
348     echo "WARNING: Failed to link with OpenSSL libraries in $ssl_root/lib."
349     echo "         Wget will be built without support for https://... URLs."
350     echo
351   fi
352
353   CC=$wget_save_CC
354 fi
355
356 dnl
357 dnl Set of available languages.
358 dnl
359 ALL_LINGUAS=`(cd ${srcdir}/po && ls *.po | sed -e 's/\.po$//')`
360
361 dnl Originally this used to be static, looking like this:
362 dnl     ALL_LINGUAS="cs de hr it ..."
363 dnl The downside was that configure needed to be rebuilt whenever a
364 dnl new language was added.
365
366 dnl internationalization macros
367 WGET_WITH_NLS
368
369 dnl
370 dnl Find makeinfo.  If makeinfo is not found, look for Emacs.  If
371 dnl Emacs cannot be found, look for XEmacs.
372 dnl
373
374 AC_CHECK_PROGS(MAKEINFO, makeinfo emacs xemacs)
375
376 case "${MAKEINFO}" in
377    *makeinfo) MAKEINFO="${MAKEINFO} \$(srcdir)/wget.texi"  ;;
378    *emacs | *xemacs) MAKEINFO="${MAKEINFO} -batch -q -no-site-file -eval '(find-file \"\$(srcdir)/wget.texi\")' -l texinfmt -f texinfo-format-buffer -f save-buffer"  ;;
379    *) MAKEINFO="makeinfo \$(srcdir)/wget.texi"            ;;
380 esac
381
382 dnl
383 dnl Find perl and pod2man
384 dnl
385
386 AC_PATH_PROGS(PERL, perl5 perl, no)
387 AC_PATH_PROG(POD2MAN, pod2man, no)
388
389 if test "x${POD2MAN}" = xno; then
390   COMMENT_IF_NO_POD2MAN="# "
391 else
392   COMMENT_IF_NO_POD2MAN=
393 fi
394 AC_SUBST(COMMENT_IF_NO_POD2MAN)
395
396 dnl
397 dnl Create output
398 dnl
399 AC_OUTPUT([Makefile src/Makefile doc/Makefile util/Makefile po/Makefile.in
400            windows/Makefile],
401 [WGET_PROCESS_PO
402 test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h])