1# $NetBSD: configure.ac,v 1.11 2007/08/06 04:42:53 lukem Exp $ 2# 3# Process this file with autoconf to produce a configure script. 4 5AC_INIT([tnftp], [20070806], [lukem@NetBSD.org]) 6AC_PREREQ([2.61]) 7AC_REVISION([$Revision: 1.11 $]) 8 9AS_SHELL_SANITIZE 10 11AC_CONFIG_SRCDIR([tnftp.h]) 12AC_CONFIG_AUX_DIR(build-aux) 13AC_CONFIG_HEADERS([config.h]) 14 15# 16# Arguments for which features are included. 17# 18AC_CANONICAL_TARGET 19AC_ARG_PROGRAM 20AC_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]) 26AC_ARG_ENABLE([ipv6], 27 [AS_HELP_STRING([--enable-ipv6], 28 [enable IPv6 support (if your OS supports it). 29 (default: enabled)])], 30 [opt_ipv6=$enableval], 31 [opt_ipv6=yes]) 32AC_ARG_WITH([socks], 33 [AS_HELP_STRING([--with-socks], 34 [enable support for (Dante) SOCKS5 proxy])], 35 [], 36 [with_socks=check]) 37 38# 39# Autoheader templates symbols. 40# 41AH_TEMPLATE([HAVE_POLL], 42 [Define if we have poll() and it is not emulated.]) 43AH_TEMPLATE([HAVE_PRINTF_QD], 44 [Define if *printf() uses %qd to print `long long' 45 (otherwise uses %lld).]) 46AH_TEMPLATE([HAVE_PRINTF_LONG_LONG], 47 [Define if `long long' is supported and 48 *printf() supports %lld or %qd to print them.]) 49AH_TEMPLATE([USE_SOCKS], 50 [Define if using (Dante) SOCKS5 proxy.]) 51 52# 53# Checks for programs. 54# 55AC_PROG_MAKE_SET 56AC_PROG_CC 57AC_PROG_AWK 58AC_PROG_INSTALL 59AC_CHECK_TOOL([AR], [ar], [:]) 60AC_CHECK_TOOL([RANLIB], [ranlib], [:]) 61 62# 63# Checks for tool features. 64# 65AS_CASE([$target_os], 66 [darwin*], 67 [# Mac OS X linker needs -search_paths_first so our private libraries 68 # are used before system libraries. 69 # 70 old_LDFLAGS=$LDFLAGS 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])], 75 [AC_MSG_RESULT([no]) 76 LDFLAGS=$old_LDFLAGS])], 77 ) 78 79# 80# Checks for libraries. 81# 82AS_IF([test "$opt_editcomplete" = yes], 83 [AC_SEARCH_LIBS([tgetent], 84 [termcap termlib curses ncurses tinfo], 85 [], 86 [AC_MSG_ERROR( 87 [no relevant library found containing tgetent])]) 88 AC_SEARCH_LIBS([el_init], 89 [edit], 90 [have_libedit=yes], [have_libedit=no])]) 91 92AC_SEARCH_LIBS([gethostbyname], [nsl]) 93AC_SEARCH_LIBS([socket], 94 [socket], 95 [], 96 [AC_CHECK_LIB([socket], 97 [socket], 98 [LIBS="-lsocket -lnsl $LIBS"], 99 [], 100 [-lnsl])]) 101 102# Check for (Dante) SOCKS5. 103# 104AS_IF([test "$with_socks" != no], 105 [AC_SEARCH_LIBS([SOCKSinit], 106 [socksd socks], 107 [AC_DEFINE([USE_SOCKS], [1]) 108 AS_IF([test "$opt_ipv6" = yes], 109 [AC_MSG_WARN( 110 [IPv6 is incompatible with socks, disabling IPv6 support]) 111 opt_ipv6=no])], 112 [AS_IF([test "$with_socks" != check], 113 [AC_MSG_FAILURE( 114 [--with-socks was given, but SOCKSinit() wasn't found])])])]) 115 116# 117# Checks for header files. 118# 119accheck_includes=' 120#include <stdio.h> 121#if defined(HAVE_SYS_TYPES_H) 122# include <sys/types.h> 123#endif 124#if defined(HAVE_SYS_STAT_H) 125# include <sys/stat.h> 126#endif 127#if defined(STDC_HEADERS) 128# include <stdarg.h> 129# include <stdlib.h> 130# include <string.h> 131#endif 132#if defined(HAVE_LIBGEN_H) 133# include <libgen.h> 134#endif 135#if defined(HAVE_PWD_H) 136# include <pwd.h> 137#endif 138#if defined(HAVE_UNISTD_H) 139# include <unistd.h> 140#endif 141#if defined(HAVE_POLL_H) 142# include <poll.h> 143#elif defined(HAVE_SYS_POLL_H) 144# include <sys/poll.h> 145#endif 146#if defined(HAVE_SYS_SOCKET_H) 147# include <sys/socket.h> 148#endif 149#if defined(HAVE_NETINET_IN_H) 150# include <netinet/in.h> 151#endif 152#if defined(HAVE_NETINET_IN_SYSTM_H) 153# include <netinet/in_systm.h> 154#endif 155#if defined(HAVE_NETDB_H) 156# include <netdb.h> 157#endif 158#if defined(HAVE_ARPA_INET_H) 159# include <arpa/inet.h> 160#endif 161#if defined(HAVE_DIRENT_H) 162# include <dirent.h> 163#else 164# define dirent direct 165# if defined(HAVE_SYS_NDIR_H) 166# include <sys/ndir.h> 167# endif 168# if defined(HAVE_SYS_DIR_H) 169# include <sys/dir.h> 170# endif 171# if defined(HAVE_NDIR_H) 172# include <ndir.h> 173# endif 174#endif 175' # accheck_includes 176 177AC_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]) 180AC_HEADER_DIRENT 181AC_HEADER_RESOLV 182AC_HEADER_STAT 183AC_HEADER_STDC 184AC_HEADER_TIME 185AC_HEADER_TIOCGWINSZ 186AC_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]) 193 194# 195# Checks for typedefs, structures, and compiler characteristics. 196# 197AC_CHECK_DECLS([AI_NUMERICHOST, dirname, fclose, getpass, h_errno, pclose, 198 optarg, optind], 199 [], [], [$accheck_includes]) 200AC_TYPE_LONG_DOUBLE 201AC_TYPE_LONG_LONG_INT 202AC_TYPE_UINT32_T 203AC_TYPE_OFF_T 204AC_TYPE_PID_T 205AC_TYPE_SIGNAL 206AC_TYPE_SIZE_T 207AC_STRUCT_TM 208AC_CHECK_MEMBERS([struct sockaddr.sa_len, struct sockaddr_in.sin_len, 209 struct dirent.d_namlen], 210 [], [], [$accheck_includes]) 211AC_CHECK_TYPES([in_port_t, sa_family_t, socklen_t, struct addrinfo], 212 [], [], [$accheck_includes]) 213AC_SYS_LARGEFILE 214 215# If IPv6 is enabled, check for necessary items. 216# 217AS_IF([test "$opt_ipv6" = yes], 218 [AC_CHECK_DECLS([AF_INET6, NS_IN6ADDRSZ], [], [], 219[$accheck_includes 220#if defined(HAVE_ARPA_NAMESER_H) 221#include <arpa/nameser.h> 222#endif 223]) 224 AC_CHECK_TYPES([struct sockaddr_in6], [], [], [$accheck_includes])]) 225 226# 227# Checks for library functions. 228# 229#XXX remove alloca use 230AC_FUNC_ALLOCA 231AC_FUNC_CLOSEDIR_VOID 232AC_FUNC_FORK 233AC_FUNC_FSEEKO 234AC_FUNC_STRCOLL 235AC_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]) 239AC_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 \ 244 utime]) 245AS_IF([test "$ac_cv_func_getpgrp" = yes], [AC_FUNC_GETPGRP]) 246AS_IF([test "$ac_cv_func_strptime" = yes], [AC_CHECK_DECLS([strptime])]) 247 248# Always replace glob(); the vendor's may not be secure. 249# 250AC_LIBOBJ([glob]) 251 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. 255# 256AS_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([[ 260#include <stdio.h> 261int main() { 262 char buf[100]; 263 sprintf(buf, "%lld", 4294967300LL); 264 return (strcmp(buf, "4294967300")); 265} 266]])], 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([[ 274#include <stdio.h> 275int main() { 276 char buf[100]; 277 sprintf(buf, "%qd", 4294967300LL); 278 return (strcmp(buf, "4294967300")); 279} 280]])], 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])])]) 292 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(). 297# 298AC_CHECK_TYPES([struct pollfd], [], [], [$accheck_includes]) 299AC_CHECK_FUNC([poll], 300 [AC_CHECK_DECL([_POLL_EMUL_H_], 301 [], 302 [AC_DEFINE([HAVE_POLL], [1])], 303 [$accheck_includes])]) 304 305# Assume libedit is not up-to-date and force own version. 306# 307have_libedit=no 308AS_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" 314 LIBS="-ledit $LIBS" 315 LIBEDIT=libedit.a 316 LIBDEPENDS="$LIBDEPENDS ../libedit/libedit.a"], 317 [AC_MSG_RESULT([yes])])], 318 [CFLAGS="-DNO_EDITCOMPLETE $CFLAGS"]) 319 320# Replace sl_init() (et al) if it provides the older API. 321# 322AS_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, 326 "foo");]])], 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])])]) 331 332# Replace getaddrinfo() if missing or AI_NUMERICHOST isn't declared. 333# 334AC_MSG_CHECKING([for working getaddrinfo()]) 335AS_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])])]) 341 342# Check for VIS_WHITE in <vis.h> 343# 344AS_IF([test "$ac_cv_header_vis_h" = yes], 345 [AC_CHECK_DECL([VIS_WHITE], [], [], [ 346#include <vis.h> 347])]) 348 349# Build libnetbsd if necessary. 350# 351AS_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"]) 357 358# 359# Create the Makefiles. 360# 361AC_SUBST(INCLUDES) 362AC_SUBST(LIBEDIT) 363AC_SUBST(LIBNETBSD) 364AC_SUBST(LIBDEPENDS) 365 366AC_CONFIG_FILES([Makefile 367 libedit/Makefile 368 libedit/makelist 369 libnetbsd/Makefile 370 src/Makefile]) 371 372AC_OUTPUT 373