1 # $NetBSD: configure.ac,v 1.11 2007/08/06 04:42:53 lukem Exp $
3 # Process this file with autoconf to produce a configure script.
5 AC_INIT([tnftp], [20070806], [lukem@NetBSD.org])
7 AC_REVISION([$Revision: 1.11 $])
11 AC_CONFIG_SRCDIR([tnftp.h])
12 AC_CONFIG_AUX_DIR(build-aux)
13 AC_CONFIG_HEADERS([config.h])
16 # Arguments for which features are included.
20 AC_ARG_ENABLE([editcomplete],
21 [AS_HELP_STRING([--enable-editcomplete],
22 [turn on command line editing and completion.
23 (default: enabled)])],
24 [opt_editcomplete=$enableval],
25 [opt_editcomplete=yes])
27 [AS_HELP_STRING([--enable-ipv6],
28 [enable IPv6 support (if your OS supports it).
29 (default: enabled)])],
30 [opt_ipv6=$enableval],
33 [AS_HELP_STRING([--with-socks],
34 [enable support for (Dante) SOCKS5 proxy])],
39 # Autoheader templates symbols.
41 AH_TEMPLATE([HAVE_POLL],
42 [Define if we have poll() and it is not emulated.])
43 AH_TEMPLATE([HAVE_PRINTF_QD],
44 [Define if *printf() uses %qd to print `long long'
45 (otherwise uses %lld).])
46 AH_TEMPLATE([HAVE_PRINTF_LONG_LONG],
47 [Define if `long long' is supported and
48 *printf() supports %lld or %qd to print them.])
49 AH_TEMPLATE([USE_SOCKS],
50 [Define if using (Dante) SOCKS5 proxy.])
53 # Checks for programs.
59 AC_CHECK_TOOL([AR], [ar], [:])
60 AC_CHECK_TOOL([RANLIB], [ranlib], [:])
63 # Checks for tool features.
67 [# Mac OS X linker needs -search_paths_first so our private libraries
68 # are used before system libraries.
71 LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
72 AC_MSG_CHECKING([if ld accepts -search_paths_first])
73 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[int i;]])],
74 [AC_MSG_RESULT([yes])],
76 LDFLAGS=$old_LDFLAGS])],
80 # Checks for libraries.
82 AS_IF([test "$opt_editcomplete" = yes],
83 [AC_SEARCH_LIBS([tgetent],
84 [termcap termlib curses ncurses tinfo],
87 [no relevant library found containing tgetent])])
88 AC_SEARCH_LIBS([el_init],
90 [have_libedit=yes], [have_libedit=no])])
92 AC_SEARCH_LIBS([gethostbyname], [nsl])
93 AC_SEARCH_LIBS([socket],
96 [AC_CHECK_LIB([socket],
98 [LIBS="-lsocket -lnsl $LIBS"],
102 # Check for (Dante) SOCKS5.
104 AS_IF([test "$with_socks" != no],
105 [AC_SEARCH_LIBS([SOCKSinit],
107 [AC_DEFINE([USE_SOCKS], [1])
108 AS_IF([test "$opt_ipv6" = yes],
110 [IPv6 is incompatible with socks, disabling IPv6 support])
112 [AS_IF([test "$with_socks" != check],
114 [--with-socks was given, but SOCKSinit() wasn't found])])])])
117 # Checks for header files.
121 #if defined(HAVE_SYS_TYPES_H)
122 # include <sys/types.h>
124 #if defined(HAVE_SYS_STAT_H)
125 # include <sys/stat.h>
127 #if defined(STDC_HEADERS)
132 #if defined(HAVE_LIBGEN_H)
135 #if defined(HAVE_PWD_H)
138 #if defined(HAVE_UNISTD_H)
141 #if defined(HAVE_POLL_H)
143 #elif defined(HAVE_SYS_POLL_H)
144 # include <sys/poll.h>
146 #if defined(HAVE_SYS_SOCKET_H)
147 # include <sys/socket.h>
149 #if defined(HAVE_NETINET_IN_H)
150 # include <netinet/in.h>
152 #if defined(HAVE_NETINET_IN_SYSTM_H)
153 # include <netinet/in_systm.h>
155 #if defined(HAVE_NETDB_H)
158 #if defined(HAVE_ARPA_INET_H)
159 # include <arpa/inet.h>
161 #if defined(HAVE_DIRENT_H)
164 # define dirent direct
165 # if defined(HAVE_SYS_NDIR_H)
166 # include <sys/ndir.h>
168 # if defined(HAVE_SYS_DIR_H)
169 # include <sys/dir.h>
171 # if defined(HAVE_NDIR_H)
177 AC_CHECK_HEADERS([sys/types.h sys/ioctl.h sys/param.h sys/stat.h \
178 sys/socket.h sys/syslimits.h sys/time.h sys/wait.h],
179 [], [], [$accheck_includes])
186 AC_CHECK_HEADERS([arpa/ftp.h arpa/inet.h arpa/nameser.h err.h \
187 fcntl.h libgen.h limits.h malloc.h \
188 netinet/in.h netinet/in_systm.h netinet/ip.h \
189 paths.h poll.h pwd.h sys/poll.h regex.h \
190 setjmp.h signal.h stddef.h termcap.h termios.h \
191 unistd.h utime.h vis.h],
192 [], [], [$accheck_includes])
195 # Checks for typedefs, structures, and compiler characteristics.
197 AC_CHECK_DECLS([AI_NUMERICHOST, dirname, fclose, getpass, h_errno, pclose,
199 [], [], [$accheck_includes])
201 AC_TYPE_LONG_LONG_INT
208 AC_CHECK_MEMBERS([struct sockaddr.sa_len, struct sockaddr_in.sin_len,
209 struct dirent.d_namlen],
210 [], [], [$accheck_includes])
211 AC_CHECK_TYPES([in_port_t, sa_family_t, socklen_t, struct addrinfo],
212 [], [], [$accheck_includes])
215 # If IPv6 is enabled, check for necessary items.
217 AS_IF([test "$opt_ipv6" = yes],
218 [AC_CHECK_DECLS([AF_INET6, NS_IN6ADDRSZ], [], [],
220 #if defined(HAVE_ARPA_NAMESER_H)
221 #include <arpa/nameser.h>
224 AC_CHECK_TYPES([struct sockaddr_in6], [], [], [$accheck_includes])])
227 # Checks for library functions.
229 #XXX remove alloca use
231 AC_FUNC_CLOSEDIR_VOID
235 AC_REPLACE_FUNCS([dirname err fgetln getaddrinfo getnameinfo \
236 inet_ntop inet_pton mkstemp setprogname sl_init snprintf \
237 strdup strerror strlcat strlcpy strptime strsep strunvis \
238 strvis timegm usleep utimes])
239 AC_CHECK_FUNCS([getcwd gethostbyaddr gethostbyname gethostbyname2 gethostname \
240 getpass getpassphrase getpgrp gettimeofday isascii \
241 memchr memmove memset realpath regcomp \
242 select setlocale socket strcasecmp strchr strcspn strdup \
243 strerror strncasecmp strpbrk strrchr strstr strtol strtoul \
245 AS_IF([test "$ac_cv_func_getpgrp" = yes], [AC_FUNC_GETPGRP])
246 AS_IF([test "$ac_cv_func_strptime" = yes], [AC_CHECK_DECLS([strptime])])
248 # Always replace glob(); the vendor's may not be secure.
252 # We assume that if sprintf() supports %lld or %qd,
253 # then all of *printf() does. If not, disable long long
254 # support because we don't know how to display it.
256 AS_IF([test "$ac_cv_type_long_long_int" = yes],
257 [AC_MSG_CHECKING([*printf() support for %lld])
258 can_printf_longlong=no
259 AC_RUN_IFELSE([AC_LANG_SOURCE([[
263 sprintf(buf, "%lld", 4294967300LL);
264 return (strcmp(buf, "4294967300"));
267 [AC_MSG_RESULT([yes])
268 can_printf_longlong=yes],
269 [AC_MSG_RESULT([no])],
270 [AC_MSG_RESULT([unknown - cross-compiling])])
271 AS_IF([test "$can_printf_longlong" != yes],
272 [AC_MSG_CHECKING([*printf() support for %qd])
273 AC_RUN_IFELSE([AC_LANG_SOURCE([[
277 sprintf(buf, "%qd", 4294967300LL);
278 return (strcmp(buf, "4294967300"));
281 [AC_MSG_RESULT([yes])
282 can_printf_longlong=yes
283 AC_DEFINE([HAVE_PRINTF_QD], [1])],
284 [AC_MSG_RESULT([no])],
285 [AC_MSG_RESULT([unknown - cross-compiling])])])
286 AC_MSG_CHECKING([if *printf() can print long long ints])
287 AS_IF([test "$can_printf_longlong" = yes],
288 [AC_MSG_RESULT([yes])
289 AC_DEFINE([HAVE_PRINTF_LONG_LONG], [1])
290 AC_REPLACE_FUNCS([strtoll])],
291 [AC_MSG_RESULT([no])])])
293 # Handle Darwin 7 having a poll() compatibility function,
294 # and don't use it if it's emulated.
295 # Be conservative, if we don't find one of poll.h or sys/poll.h,
296 # don't attempt to use poll().
298 AC_CHECK_TYPES([struct pollfd], [], [], [$accheck_includes])
299 AC_CHECK_FUNC([poll],
300 [AC_CHECK_DECL([_POLL_EMUL_H_],
302 [AC_DEFINE([HAVE_POLL], [1])],
303 [$accheck_includes])])
305 # Assume libedit is not up-to-date and force own version.
308 AS_IF([test "$opt_editcomplete" = yes],
309 [AC_MSG_CHECKING([for up-to-date libedit])
310 AS_IF([test "$have_libedit" = no],
311 [AC_MSG_RESULT([no - using my own])
312 INCLUDES="-I\${srcdir}/../libedit $INCLUDES"
313 LDFLAGS="-L../libedit $LDFLAGS"
316 LIBDEPENDS="$LIBDEPENDS ../libedit/libedit.a"],
317 [AC_MSG_RESULT([yes])])],
318 [CFLAGS="-DNO_EDITCOMPLETE $CFLAGS"])
320 # Replace sl_init() (et al) if it provides the older API.
322 AS_IF([test "$ac_cv_func_sl_init" = yes],
323 [AC_MSG_CHECKING([if sl_add() returns int])
324 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stringlist.h>]],
325 [[int f = sl_add((StringList *)0,
327 [AC_MSG_RESULT([yes])],
328 [AC_MSG_RESULT([no - using local version])
329 AC_LIBOBJ([sl_init])],
330 [AC_MSG_RESULT([unknown - cross-compiling])])])
332 # Replace getaddrinfo() if missing or AI_NUMERICHOST isn't declared.
334 AC_MSG_CHECKING([for working getaddrinfo()])
335 AS_IF([test "$ac_cv_have_decl_AI_NUMERICHOST" = yes],
336 [AC_MSG_RESULT([yes])],
337 [AS_IF([test "$ac_cv_func_getaddrinfo" = yes],
338 [AC_LIBOBJ([getaddrinfo])
339 AC_MSG_RESULT([no - using local version])],
340 [AC_MSG_RESULT([using local version])])])
342 # Check for VIS_WHITE in <vis.h>
344 AS_IF([test "$ac_cv_header_vis_h" = yes],
345 [AC_CHECK_DECL([VIS_WHITE], [], [], [
349 # Build libnetbsd if necessary.
351 AS_IF([test -n "$LIBOBJS"],
352 [INCLUDES="$INCLUDES -I\${srcdir}/../libnetbsd"
353 LDFLAGS="$LDFLAGS -L../libnetbsd"
354 LIBS="$LIBS -lnetbsd"
355 LIBNETBSD=libnetbsd.a
356 LIBDEPENDS="$LIBDEPENDS ../libnetbsd/libnetbsd.a"])
359 # Create the Makefiles.
366 AC_CONFIG_FILES([Makefile