]> sjero.net Git - wget/blob - configure.in
27c0d535603fddf07510e0f0ab5353d3ccb793f9
[wget] / configure.in
1 dnl Template file for GNU Autoconf
2 dnl Copyright (C) 1995, 1996, 1997 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 case "${USE_OPIE}${USE_DIGEST}" in
67 *yes*)
68         MD5_OBJ='md5$o'
69 esac
70 if test x"$USE_OPIE" = xyes; then
71   OPIE_OBJ='ftp-opie$o'
72 fi
73 AC_SUBST(MD5_OBJ)
74 AC_SUBST(OPIE_OBJ)
75
76 dnl
77 dnl Whether make sets $(MAKE)...
78 dnl
79 AC_PROG_MAKE_SET
80
81 dnl
82 dnl Find a good install
83 dnl
84 AC_PROG_INSTALL
85
86 dnl
87 dnl Configure our included libtool and make sure it's regenerated when needed
88 dnl
89 AM_PROG_LIBTOOL
90 AC_SUBST(LIBTOOL_DEPS)
91
92 dnl
93 dnl Find the compiler
94 dnl
95
96 dnl We want these before the checks, so the checks can modify their values.
97 test -z "$CFLAGS"  && CFLAGS= auto_cflags=1
98 test -z "$CC" && cc_specified=yes
99
100 AC_PROG_CC
101
102 dnl
103 dnl if the user hasn't specified CFLAGS, then
104 dnl   if compiler is gcc, then use -O2 and some warning flags
105 dnl   else use os-specific flags or -O
106 dnl
107 if test -n "$auto_cflags"; then
108   if test -n "$GCC"; then
109     CFLAGS="$CFLAGS -O2 -Wall -Wno-implicit"
110   else
111     case "$host_os" in
112       *hpux*)  CFLAGS="$CFLAGS +O3"                      ;;
113       *ultrix* | *osf*) CFLAGS="$CFLAGS -O -Olimit 2000" ;;
114       *)       CFLAGS="$CFLAGS -O" ;;
115     esac
116   fi
117 fi
118
119 dnl
120 dnl Handle AIX
121 dnl
122 AC_AIX
123
124 dnl
125 dnl In case of {cyg,gnu}win32.  Should be a _target_ test.
126 dnl Might also be erelevant for DJGPP.
127 dnl
128 case "$host_os" in
129   *win32) exeext='.exe';;
130   *) exeext='';;
131 esac
132 AC_SUBST(exeext)
133
134 dnl
135 dnl Check if we can handle prototypes.
136 dnl
137 AM_C_PROTOTYPES
138
139 dnl
140 dnl Checks for typedefs, structures, and compiler characteristics.
141 dnl
142 AC_C_CONST
143 AC_C_INLINE
144 AC_TYPE_SIZE_T
145 AC_TYPE_PID_T
146 dnl #### This generates a warning.  What do I do to shut it up?
147 AC_C_BIGENDIAN
148
149 # Check size of long.
150 AC_CHECK_SIZEOF(long)
151 AC_CHECK_SIZEOF(long long)
152
153 dnl
154 dnl Checks for headers
155 dnl
156 AC_CHECK_HEADERS(string.h stdarg.h unistd.h sys/time.h utime.h sys/utime.h)
157 AC_CHECK_HEADERS(sys/select.h sys/utsname.h pwd.h signal.h)
158 AC_HEADER_TIME
159
160 dnl
161 dnl Return type of signal-handlers
162 dnl
163 AC_TYPE_SIGNAL
164
165 dnl
166 dnl Check for struct utimbuf
167 WGET_STRUCT_UTIMBUF
168
169 dnl
170 dnl Checks for library functions.
171 dnl
172 AC_FUNC_ALLOCA
173 AC_FUNC_MMAP
174 AC_CHECK_FUNCS(strdup strstr strcasecmp strncasecmp)
175 AC_CHECK_FUNCS(gettimeofday mktime strptime)
176 AC_CHECK_FUNCS(strerror snprintf vsnprintf select signal symlink access isatty)
177 AC_CHECK_FUNCS(uname gethostname)
178
179 AC_CHECK_FUNCS(gethostbyname, [], [
180   AC_CHECK_LIB(nsl, gethostbyname)
181 ])
182
183 dnl
184 dnl Checks for libraries.
185 dnl
186
187 AC_CHECK_LIB(socket, socket)
188
189 dnl #### This appears to be deficient with later versions of SOCKS.
190 if test "x${with_socks}" = xyes
191 then
192   AC_CHECK_LIB(resolv, main)
193   AC_CHECK_LIB(socks, Rconnect)
194 fi
195
196 dnl OpenSSL is a third-party library, which makes checking for it a
197 dnl pain.  Before proceeding, we need to figure out whether to use the
198 dnl `-R' flag.
199
200 dnl Try to autodetect runtime library flag (usually -R), and whether
201 dnl it works (or at least does no harm).  Note that this is used
202 dnl merely for the configure test below.  The actual linking is
203 dnl performed by libtool.  Wouldn't it be nice if libtool also
204 dnl provided "querying" that we need in configure?
205 AC_MSG_CHECKING("for runtime libraries flag")
206 case "$opsys" in
207   sol2 ) dash_r="-R" ;;
208   decosf* | linux* | irix*) dash_r="-rpath " ;;
209   *)
210     dash_r=""
211     for try_dash_r in "-R" "-R " "-rpath "; do
212       OLD_LDFLAGS=$LDFLAGS
213       LDFLAGS="${try_dash_r}/no/such/file-or-directory $LDFLAGS"
214       AC_TRY_LINK(, , dash_r="$try_dash_r")
215       LDFLAGS=$ODL_LDFLAGS
216       test -n "$dash_r" && break
217     done ;;
218 esac
219 if test -n "$dash_r";
220   then AC_MSG_RESULT("\"${dash_r}\"")
221   else AC_MSG_RESULT(NONE)
222 fi
223
224 dnl If --with-ssl was specified, make sure we can link with the
225 dnl OpenSSL libs.  We should probably auto-detect this by default.
226
227 if test x"$with_ssl" != x -a x"$with_ssl" != x"no"; then
228   if test x"$with_ssl" = x"yes"; then
229     dnl OpenSSL's default install location is "/usr/local/ssl".  We also
230     dnl allow /usr/local for regular-style install, and /usr for Linux
231     dnl stuff.
232     ssl_all_roots="default /usr/local/ssl /usr/local /opt"
233   else
234     dnl Root has been kindly provided by the user.
235     ssl_all_roots=$with_ssl
236   fi
237
238   OLD_LIBS=$LIBS
239   OLD_LDFLAGS=$LDFLAGS
240
241   dnl Unfortunately, as of this writing (OpenSSL 0.9.6), the libcrypto
242   dnl shared library doesn't record its dependency on libdl, so we
243   dnl need to check for it ourselves so we won't fail to link due to a
244   dnl lack of -ldl.  Most OSes use dlopen(), but HP-UX uses
245   dnl shl_load().
246   AC_CHECK_LIB(dl,dlopen)
247   AC_CHECK_LIB(dl,shl_load)
248
249   ssl_linked=no
250
251   dnl Now try to find SSL libraries in each of the likely SSL roots.
252   for ssl_root in $ssl_all_roots
253   do
254     LIBS=$OLD_LIBS
255
256     if test x"$ssl_root" = xdefault; then
257       dnl Try the default library locations.
258       SSL_INCLUDES=
259       LDFLAGS=$OLD_LDFLAGS
260     else
261       dnl Try this specific root.
262       SSL_INCLUDES=-I$ssl_root/include
263       SSL_DASH_L="-L$ssl_root/lib"
264       SSL_DASH_R=
265       dnl Only use -R<foo> on systems which support a -R variant.
266       if test x"$dash_r" != x; then
267         SSL_DASH_R="${dash_r}$ssl_root/lib"
268       fi
269       LDFLAGS="$SSL_DASH_L $SSL_DASH_R $OLD_LDFLAGS"
270     fi
271
272     ssl_link_failure=no
273
274     AC_MSG_RESULT(["Looking for SSL libraries in $ssl_root"])
275
276     dnl Make sure that the checks don't run afoul of the cache.  It
277     dnl would be nicer to temporarily turn off the cache, but
278     dnl apparently Autoconf doesn't allow that.
279
280     unset ac_cv_lib_crypto_RSA_new
281     unset ac_cv_lib_ssl_SSL_new
282
283     dnl These checks need to be in this order, or you'll get a link
284     dnl failure if you use a static libcrypto.a and libssl.a rather
285     dnl than shared libraries.
286
287     AC_CHECK_LIB(crypto,RSA_new,,ssl_link_failure=yes)
288     AC_CHECK_LIB(ssl,SSL_new,,ssl_link_failure=yes)
289
290     dnl If ssl_link_failure is still no, the libraries link.  But we
291     dnl still need to check if the program linked with those libraries
292     dnl under these settings with run.  On some systems (Solaris), Gcc
293     dnl adds -L/usr/local/lib to the linking line, but fails to add
294     dnl -R/usr/local/lib, thus creating executables that link, but
295     dnl fail to run.
296
297     dnl If we are cross-compiling, just assume that working linkage
298     dnl implies working executable.
299
300     if test x"$ssl_link_failure" = xno; then
301       dnl Now try to run the thing.
302       AC_MSG_CHECKING("whether runtime linking works")
303       AC_TRY_RUN([
304 char RSA_new();
305 char SSL_new();
306 main(){return 0;}
307 ], AC_MSG_RESULT("yes"), AC_MSG_RESULT("no"); ssl_link_failure=yes, true)
308     fi
309
310     if test x"$ssl_link_failure" = xno; then
311       dnl This echo doesn't look right, but I'm not sure what to use
312       dnl instead.
313       AC_MSG_RESULT("Compiling in support for SSL in $ssl_root")
314       AC_DEFINE(HAVE_SSL)
315       AC_SUBST(SSL_INCLUDES)
316       SSL_OBJ='gen_sslfunc$o'
317       AC_SUBST(SSL_OBJ)
318       ssl_linked=yes
319       break
320     fi
321   done
322
323   if test x"$ssl_linked" = xno; then
324     LD_FLAGS=$OLD_LDFLAGS
325     LIBS=$OLD_LIBS
326     dnl Perhaps we should abort here.  Remember that the user
327     dnl explicitly requested linking with SSL.
328     echo
329     echo "WARNING: Failed to link with OpenSSL libraries in $ssl_root/lib."
330     echo "         Wget will be built without support for https://... URLs."
331     echo
332   fi
333 fi
334
335 dnl
336 dnl Set of available languages.
337 dnl
338 ALL_LINGUAS=`(cd ${srcdir}/po && ls *.po | sed -e 's/\.po$//')`
339
340 dnl Originally this used to be static, looking like this:
341 dnl     ALL_LINGUAS="cs de hr it ..."
342 dnl The downside was that configure needed to be rebuilt whenever a
343 dnl new language was added.
344
345 dnl internationalization macros
346 WGET_WITH_NLS
347
348 dnl
349 dnl Find makeinfo.  If makeinfo is not found, look for Emacs.  If
350 dnl Emacs cannot be found, look for XEmacs.
351 dnl
352
353 AC_CHECK_PROGS(MAKEINFO, makeinfo emacs xemacs)
354
355 case "${MAKEINFO}" in
356    *makeinfo) MAKEINFO="${MAKEINFO} \$(srcdir)/wget.texi"  ;;
357    *emacs | *xemacs) MAKEINFO="${MAKEINFO} -batch -q -no-site-file -eval '(find-file \"\$(srcdir)/wget.texi\")' -l texinfmt -f texinfo-format-buffer -f save-buffer"  ;;
358    *) MAKEINFO="makeinfo \$(srcdir)/wget.texi"            ;;
359 esac
360
361 dnl
362 dnl Find perl and pod2man
363 dnl
364
365 AC_PATH_PROGS(PERL, perl5 perl, no)
366 AC_PATH_PROG(POD2MAN, pod2man, no)
367
368 if test "x${POD2MAN}" = xno; then
369   COMMENT_IF_NO_POD2MAN="# "
370 else
371   COMMENT_IF_NO_POD2MAN=
372 fi
373 AC_SUBST(COMMENT_IF_NO_POD2MAN)
374
375 dnl
376 dnl Create output
377 dnl
378 AC_OUTPUT([Makefile src/Makefile doc/Makefile util/Makefile po/Makefile.in
379            windows/Makefile],
380 [WGET_PROCESS_PO
381 test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h])