dnl Process this file with autoconf to produce a configure script.
dnl
AC_INIT(ncftp/main.c)
AC_PREREQ(2.13)
AC_CONFIG_HEADER(config.h)
wi_ARG_DISABLE_CCDV
AC_ARG_WITH(curses,[  --without-curses        do not try to find and use the curses library],nc_cv_curses=$withval,nc_cv_curses=yes)
wi_ARG_ENABLE_DEBUG
AC_ARG_WITH(ncurses,[  --without-ncurses       do not try to find and use the ncurses library],nc_cv_ncurses=$withval,nc_cv_ncurses=yes)
wi_ARG_DISABLE_PRECOMP
dnl AC_ARG_WITH(readline,[  --without-readline      do not try to find and use the readline library],nc_cv_readline=$withval,nc_cv_readline=yes)
wi_ARG_WITH_SOCKS5



dnl ---------------------------------------------------------------------------
dnl Environment and compiler settings.
dnl ---------------------------------------------------------------------------
dnl
wi_ENV_VAR_MESSAGES
wi_OS_VAR
if test -f sh/install-sh ; then chmod 755 sh/*.sh sh/config.* sh/install-sh ; fi
AC_CONFIG_AUX_DIR([sh])
AC_PROG_CC
wi_CC_PRECOMP
wi_REQUEST_NO_Y2K_WARNINGS
wi_CFLAGS_LFS64
wi_CFLAGS_REENTRANT
wi_SFLAG
AC_OBJEXT
AC_EXEEXT
wi_DEFINE_UNAME
wi_EXTRA_SYSV_SUNOS_DIRS	dnl	For better curses library on SunOS 4



dnl ---------------------------------------------------------------------------
dnl Checks for header files.
dnl ---------------------------------------------------------------------------
dnl
AC_HEADER_STDC
dnl Readline headers #ifdefs for string.h, sio needs strings.h for AIX
AC_CHECK_HEADERS(arpa/nameser.h gnu/libc-version.h locale.h net/errno.h nserve.h resolv.h sgtty.h string.h strings.h sys/ioctl.h syslog.h sys/socket.h sys/time.h sys/types.h sys/utsname.h sys/systeminfo.h termio.h termios.h time.h utime.h unistd.h)
AC_TIME_WITH_SYS_TIME

dnl	# sio
wi_UNIX_DOMAIN_SOCKETS
SIO_OBJS_U=''
SIO_SOBJS_U=''
if test "$wi_cv_unix_domain_sockets" = yes ; then
	SIO_OBJS_U='$(OBJS_U) '
	SIO_SOBJS_U='$(SOBJS_U) '
fi
AC_SUBST(SIO_OBJS_U)
AC_SUBST(SIO_SOBJS_U)
dnl	# sio



dnl ---------------------------------------------------------------------------
dnl Checks for libraries.
dnl ---------------------------------------------------------------------------
dnl
wi_NET_LIBS
wi_LIB_SOCKS5

LIBCURSES=''
if test "$nc_cv_curses" = yes ; then
	wi_LIB_CURSES
fi
dnl if test "$nc_cv_readline" = yes ; then
dnl 	wi_LIB_READLINE
dnl fi



dnl ---------------------------------------------------------------------------
dnl Checks for typedefs, structures, and compiler characteristics.
dnl ---------------------------------------------------------------------------
dnl
AC_C_CONST
AC_TYPE_SIZE_T
AC_TYPE_OFF_T
AC_TYPE_MODE_T
AC_TYPE_PID_T
AC_TYPE_UID_T
wi_VOID_MAIN_RETURN_TYPE
wi_USE_LONG_LONG
wi_STRUCT_TIMEVAL_FIELD_TYPES
wi_UNISTD_FUNC_PARAM_TYPES
wi_FUNC_SELECT_ARGTYPES
wi_STRUCT_STAT64
wi_TYPE_SIG_ATOMIC_T
wi_GETOPT
wi__RES_DEFDNAME	dnl				# sio
wi_STRUCT_CMSGHDR	dnl				# sio
wi_MSGHDR_CONTROL	dnl				# sio
wi_MSGHDR_ACCRIGHTS	dnl				# sio
wi_HEADER_SYS_SELECT_H	dnl				# sio



dnl ---------------------------------------------------------------------------
dnl Checks for library functions.
dnl ---------------------------------------------------------------------------
dnl
wi_FUNC_GETCWD
AC_CHECK_FUNCS(fstat64 getdomainname gethostname getpass getpassphrase gnu_get_libc_release gnu_get_libc_version inet_aton inet_ntop llseek lseek64 lstat64 memmove mktime open64 pathconf readlink res_init setlocale setpgid setpgrp setsid setvbuf sigaction sigsetjmp stat64 strcasecmp strcoll strdup strerror strncoll strstr strtoq symlink sysconf sysctl sysinfo syslog uname waitpid)
AC_CHECK_FUNCS(gethostbyaddr_r gethostbyname_r gethostbyname2_r getlogin_r getpwnam_r _posix_getpwnam_r getpwuid_r _posix_getpwuid_r getservbyname_r getservbyport_r gmtime_r localtime_r readdir_r)
wi_SNPRINTF
wi_FUNC_SIGSETJMP
AC_FUNC_SETPGRP
AC_FUNC_SETVBUF_REVERSED
wi_CURSES_FEATURES
if test "x$LIBCURSES" = "x" ; then
	VIS_DPROGS="# ../bin/ncftpbookmarks${EXEEXT}"
else
	VIS_DPROGS="../bin/ncftpbookmarks${EXEEXT}"
fi



dnl ---------------------------------------------------------------------------
dnl Checks for system characteristics.
dnl ---------------------------------------------------------------------------
dnl
AC_SYS_LONG_FILE_NAMES
AC_PROG_MAKE_SET
wi_PROG_TAR
wi_CREATE_TAR_FILES
AC_PROG_RANLIB
AC_PROG_INSTALL
wi_PROG_CCDV
wi_MANDIR
wi_SUBST_LONGEST_INT_HEADER([libncftp/ncftp.h])
wi_SUBST_STAT_HEADER([libncftp/ncftp.h])
wi_REMOVE_UNKNOWN_PREPROCESSING_DIRECTIVES_FROM_FILE([libncftp/ncftp.h])
LIBSET='$(LIB)'
Z30='#'
if test -x /usr/local/bin/incrementor ; then
	Z30='	-@/usr/local/bin/incrementor -b -f version.c -f version.o'
fi
wi_RESOLVE_PATH([$srcdir], MAINDIR)
wi_RESOLVE_PATH([$MAINDIR/libncftp/ncftp.h], [libncftp_h])
wi_DIRNAME(libncftp_h)
wi_RESOLVE_PATH([$MAINDIR/sio/sio.h], [sio_h])
wi_DIRNAME(sio_h)
wi_RESOLVE_PATH([$MAINDIR/Strn/Strn.h], [strn_h])
wi_DIRNAME(strn_h)
CPPFLAGS="-I${MAINDIR} -I${libncftp_h} -I${sio_h} -I${strn_h} $CPPFLAGS"
LDFLAGS="-L${libncftp_h} -L${sio_h} -L${strn_h} $LDFLAGS"
wi_BEAUTIFY_ENVIRONMENT_VARIABLES



dnl ---------------------------------------------------------------------------
dnl Extra steps to work with precompiled headers.
dnl ---------------------------------------------------------------------------
dnl
LIBNCFTP_PRECOMP="libncftp/pch.mk.none"
SIO_PRECOMP="sio/pch.mk.none"
if test "${wi_cv_cc_precomp}_${wi_cv_cc_precomp_type}" = "yes_gcc_gch_files" ; then
	LIBNCFTP_PRECOMP="libncftp/pch.mk.gcc-gch"
	SIO_PRECOMP="sio/pch.mk.gcc-gch"
elif test "${wi_cv_cc_precomp}_${SYS}" = "yes_macosx" ; then
	LIBNCFTP_PRECOMP="libncftp/pch.mk.$SYS"
	SIO_PRECOMP="sio/pch.mk.$SYS"
fi
AC_SUBST_FILE(LIBNCFTP_PRECOMP)
AC_SUBST_FILE(SIO_PRECOMP)



dnl ---------------------------------------------------------------------------
dnl Version lookups for Makefile variables.
dnl ---------------------------------------------------------------------------
dnl
changequote(<<, >>)dnl
LIBNCFTP_VERSION=`sed -n '/kLibraryVersion/{
	s/^[^0-9]*//
	s/\ .*$//
	p
	q
}' libncftp/ncftp.h`

NCFTP_VERSION=`sed -n '/gVersion\[\]/{
	s/^[^0-9]*//
	s/\/.*$//
	p
	q
}' ncftp/version.c`

SIO_VERSION=`sed -n '/kSioVersion/{
	s/^[^0-9]*//
	s/\ .*$//
	p
	q
}' sio/sio.h`

STRN_VERSION=`sed -n '/gStrnLibVersion\[\]/{
	s/^[^0-9]*//
	s/\".*$//
	p
	q
}' Strn/Strncpy.c`
changequote([, ])dnl



dnl ---------------------------------------------------------------------------
dnl Create Makefiles and config.h files.
dnl ---------------------------------------------------------------------------
dnl
AC_SUBST(CC)
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(LIBS)
AC_SUBST(SFLAG)
AC_SUBST(STRIP)
AC_SUBST(DEFS)
AC_SUBST(MAKE)
AC_SUBST(Z30)
AC_SUBST(LIBSET)
AC_SUBST(MAINDIR)
AC_SUBST(NCFTP_VERSION)
AC_SUBST(LIBNCFTP_VERSION)
AC_SUBST(SIO_VERSION)
AC_SUBST(STRN_VERSION)
AC_SUBST(VIS_DPROGS)
AC_OUTPUT_COMMANDS([/bin/rm -f ./ncftp/readln.o])
AC_OUTPUT([Makefile Makefile.bin ncftp/Makefile libncftp/Makefile Strn/Makefile sio/Makefile sh_util/Makefile vis/Makefile])
