www.usr.com/support/gpl/USR9107_release.1.4.tar.gz
[bcm963xx.git] / userapps / opensource / sshd / configure.in
index 462c150..e327ea7 100755 (executable)
@@ -1,11 +1,14 @@
 #                                               -*- Autoconf -*-
-# Process this file with autoconf to produce a configure script.
+# Process this file with autoconf and autoheader to produce a configure script.
 
-# This Autoconf file was cobbled from various locations.
+# This Autoconf file was cobbled from various locations. In particular, a bunch
+# of the platform checks have been taken straight from OpenSSH's configure.ac
+# Huge thanks to them for dealing with the horrible platform-specifics :)
 
 AC_PREREQ(2.50)
-AC_INIT(algo.c)
+AC_INIT(buffer.c)
 
+OLDCFLAGS=$CFLAGS
 # Checks for programs.
 AC_PROG_CC
 AC_PROG_MAKE_SET
@@ -15,6 +18,11 @@ if test -z "$LD" ; then
 fi
 AC_SUBST(LD)   
 
+if test -z "$OLDCFLAGS" && test "$GCC" = "yes"; then
+       AC_MSG_RESULT(No \$CFLAGS set... using "-Os -W -Wall" for GCC)
+       CFLAGS="-Os -W -Wall"
+fi
+
 # Host specific options
 # this isn't a definitive list of hosts, they are just added as required
 AC_CANONICAL_HOST
@@ -24,6 +32,7 @@ case "$host" in
 *-*-linux*)
        no_ptmx_check=1
        ;;
+
 *-*-solaris*)
        CFLAGS="$CFLAGS -I/usr/local/include"
        LDFLAGS="$LDFLAGS -L/usr/local/lib -R/usr/local/lib"
@@ -37,32 +46,40 @@ case "$host" in
        else
                AC_MSG_RESULT(no)
        fi
+       AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
+       AC_CHECK_LIB(nsl, yp_match, LIBS="$LIBS -lnsl")
        ;;
 
+*-*-aix*)
+       AC_DEFINE(AIX,,Using AIX)
+       # OpenSSH thinks it's broken. If it isn't, let me know.
+       AC_DEFINE(BROKEN_GETADDRINFO,,Broken getaddrinfo)
+       ;;
+       
+*-*-hpux*)
+       LIBS="$LIBS -lsec"
+       # It's probably broken.
+       AC_DEFINE(BROKEN_GETADDRINFO,,Broken getaddrinfo)
+       ;;
+*-dec-osf*)
+       AC_DEFINE(BROKEN_GETADDRINFO,,Broken getaddrinfo)
+       ;;
 esac
 
+AC_CHECK_TOOL(AR, ar, :)
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+AC_CHECK_TOOL(STRIP, strip, :)
+AC_CHECK_TOOL(INSTALL, install, :)
+
 dnl Can't use login() or logout() with uclibc
 AC_CHECK_DECL(__UCLIBC__, 
        [
-       AC_DEFINE(DISABLE_LOGIN,,)
+       no_loginfunc_check=1
        AC_MSG_RESULT(Using uClibc - login() and logout() probably don't work, so we won't use them.)
        ],,,)
 
-dnl If we're crosscompiling we can't check setpgrp. We know Linux allows void
-dnl form, so don't check in that case */
-AC_CHECK_DECL(__linux__,
-       [
-       AC_DEFINE(SETPGRP_VOID,,)
-       AC_MSG_RESULT(setpgrp(void) is correct for Linux.)
-       ],
-       [
-       AC_FUNC_SETPGRP
-       ],,)
-
 # Checks for libraries.
 AC_CHECK_LIB(crypt, crypt, LIBS="$LIBS -lcrypt")
-AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
-AC_CHECK_LIB(util, logout, LIBS="$LIBS -lutil")
 
 # Check if zlib is needed
 AC_ARG_WITH(zlib,
@@ -100,19 +117,56 @@ AC_ARG_ENABLE(zlib,
        ]
 )
 
+# Check if pam is needed
+AC_ARG_WITH(pam,
+       [  --with-pam=PATH        Use pam in PATH],
+       [
+               # option is given
+               if test -d "$withval/lib"; then
+                       LDFLAGS="-L${withval}/lib ${LDFLAGS}"
+               else
+                       LDFLAGS="-L${withval} ${LDFLAGS}"
+               fi
+               if test -d "$withval/include"; then
+                       CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
+               else
+                       CPPFLAGS="-I${withval} ${CPPFLAGS}"
+               fi
+       ]
+)
+
+
+AC_ARG_ENABLE(pam,
+       [  --enable-pam          Try to include PAM support],
+       [
+               if test "x$enableval" = "xyes"; then
+                       AC_CHECK_LIB(pam, pam_authenticate, , AC_MSG_ERROR([*** PAM missing - install first or check config.log ***]))
+                       AC_MSG_RESULT(Enabling PAM)
+               else
+                       AC_DEFINE(DISABLE_PAM,, Use PAM)
+                       AC_MSG_RESULT(Disabling PAM)
+               fi
+       ],
+       [
+               # disable it by default
+               AC_DEFINE(DISABLE_PAM,, Use PAM)
+               AC_MSG_RESULT(Disabling PAM)
+       ]
+)
+
 AC_ARG_ENABLE(openpty,
        [  --disable-openpty       Don't use openpty, use alternative method],
        [
                if test "x$enableval" = "xno"; then
                        AC_MSG_RESULT(Not using openpty)
                else
-                       AC_CHECK_FUNCS(openpty)
                        AC_MSG_RESULT(Using openpty if available)
+                       AC_SEARCH_LIBS(openpty, util, [AC_DEFINE(HAVE_OPENPTY,,Have openpty() function)])
                fi
        ],
        [
-               AC_CHECK_FUNCS(openpty)
                AC_MSG_RESULT(Using openpty if available)
+               AC_SEARCH_LIBS(openpty, util, [AC_DEFINE(HAVE_OPENPTY)])
        ]
 )
                
@@ -132,10 +186,27 @@ AC_ARG_ENABLE(syslog,
        ]
 )
 
+AC_ARG_ENABLE(shadow,
+       [  --disable-shadow        Don't use shadow passwords (if available)],
+       [
+               if test "x$enableval" = "xno"; then
+                       AC_MSG_RESULT(Not using shadow passwords)
+               else
+                       AC_CHECK_HEADERS([shadow.h])
+                       AC_MSG_RESULT(Using shadow passwords if available)
+               fi
+       ],
+       [
+               AC_CHECK_HEADERS([shadow.h])
+               AC_MSG_RESULT(Using shadow passwords if available)
+       ]
+)
+                       
+
 # Checks for header files.
 AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS([fcntl.h limits.h netinet/in.h netinet/tcp.h shadow.h stdlib.h string.h sys/socket.h sys/time.h termios.h unistd.h crypt.h pty.h ioctl.h libutil.h libgen.h inttypes.h sys/stropts.h utmp.h utmpx.h lastlog.h paths.h])
+AC_CHECK_HEADERS([fcntl.h limits.h netinet/in.h netinet/tcp.h stdlib.h string.h sys/socket.h sys/time.h termios.h unistd.h crypt.h pty.h ioctl.h libutil.h libgen.h inttypes.h stropts.h utmp.h utmpx.h lastlog.h paths.h util.h netdb.h security/pam_appl.h pam/pam_appl.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
@@ -146,6 +217,118 @@ AC_TYPE_SIZE_T
 AC_HEADER_TIME
 
 AC_CHECK_TYPES([uint16_t, u_int16_t, struct sockaddr_storage])
+AC_CHECK_TYPE([socklen_t], ,[
+       AC_MSG_CHECKING([for socklen_t equivalent])
+       AC_CACHE_VAL([curl_cv_socklen_t_equiv],
+       [
+       # Systems have either "struct sockaddr *" or
+       # "void *" as the second argument to getpeername
+       curl_cv_socklen_t_equiv=
+       for arg2 in "struct sockaddr" void; do
+               for t in int size_t unsigned long "unsigned long"; do
+               AC_TRY_COMPILE([
+                       #include <sys/types.h>
+                       #include <sys/socket.h>
+
+                       int getpeername (int, $arg2 *, $t *);
+               ],[
+                       $t len;
+                       getpeername(0,0,&len);
+               ],[
+                       curl_cv_socklen_t_equiv="$t"
+                       break
+               ])
+               done
+       done
+
+       if test "x$curl_cv_socklen_t_equiv" = x; then
+               AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
+       fi
+       ])
+       AC_MSG_RESULT($curl_cv_socklen_t_equiv)
+       AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
+                       [type to use in place of socklen_t if not defined])],
+       [#include <sys/types.h>
+       #include <sys/socket.h>])
+
+# for the fake-rfc2553 stuff - straight from OpenSSH
+
+AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
+       AC_TRY_COMPILE(
+               [
+#include <sys/types.h>
+#include <sys/socket.h>
+               ],
+               [ struct sockaddr_storage s; ],
+               [ ac_cv_have_struct_sockaddr_storage="yes" ],
+               [ ac_cv_have_struct_sockaddr_storage="no" ]
+       )
+])
+if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
+       AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE)
+fi
+
+AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
+       AC_TRY_COMPILE(
+               [
+#include <sys/types.h>
+#include <netinet/in.h>
+               ],
+               [ struct sockaddr_in6 s; s.sin6_family = 0; ],
+               [ ac_cv_have_struct_sockaddr_in6="yes" ],
+               [ ac_cv_have_struct_sockaddr_in6="no" ]
+       )
+])
+if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
+       AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6,,Have struct sockaddr_in6)
+fi
+
+AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
+       AC_TRY_COMPILE(
+               [
+#include <sys/types.h>
+#include <netinet/in.h>
+               ],
+               [ struct in6_addr s; s.s6_addr[0] = 0; ],
+               [ ac_cv_have_struct_in6_addr="yes" ],
+               [ ac_cv_have_struct_in6_addr="no" ]
+       )
+])
+if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
+       AC_DEFINE(HAVE_STRUCT_IN6_ADDR,,Have struct in6_addr)
+fi
+
+AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
+       AC_TRY_COMPILE(
+               [
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+               ],
+               [ struct addrinfo s; s.ai_flags = AI_PASSIVE; ],
+               [ ac_cv_have_struct_addrinfo="yes" ],
+               [ ac_cv_have_struct_addrinfo="no" ]
+       )
+])
+if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
+       AC_DEFINE(HAVE_STRUCT_ADDRINFO,,Have struct addrinfo)
+fi
+
+
+# IRIX has a const char return value for gai_strerror()
+AC_CHECK_FUNCS(gai_strerror,[
+       AC_DEFINE(HAVE_GAI_STRERROR)
+       AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+
+const char *gai_strerror(int);],[
+char *str;
+
+str = gai_strerror(0);],[
+               AC_DEFINE(HAVE_CONST_GAI_STRERROR_PROTO, 1,
+               [Define if gai_strerror() returns const char *])])])
 
 # for loginrec.c
 
@@ -167,7 +350,6 @@ AC_CHECK_FUNCS(endutent getutent getutid getutline pututline setutent)
 AC_CHECK_FUNCS(utmpname)
 AC_CHECK_FUNCS(endutxent getutxent getutxid getutxline pututxline )
 AC_CHECK_FUNCS(setutxent utmpxname)
-AC_SEARCH_LIBS(login, util, [AC_DEFINE(HAVE_LOGIN,,Have login())])
 AC_CHECK_FUNCS(logout updwtmp logwtmp)
 
 dnl Added from OpenSSH 3.6.1p2's configure.ac
@@ -193,9 +375,10 @@ AC_ARG_ENABLE(wtmpx,
        [  --disable-wtmpx         Disable use of wtmpx even if detected [no]],
        [ AC_DEFINE(DISABLE_WTMPX,,Disable use of wtmpx) ]
 )
-AC_ARG_ENABLE(libutil,
-       [  --disable-libutil       Disable use of libutil (login() etc.) [no]],
-       [ AC_DEFINE(DISABLE_LOGIN,,Disable use of login()) ]
+AC_ARG_ENABLE(loginfunc,
+       [  --disable-loginfunc     Disable use of login() etc. [no]],
+       [ no_loginfunc_check=1
+       AC_MSG_RESULT(Not using login() etc) ]
 )
 AC_ARG_ENABLE(pututline,
        [  --disable-pututline     Disable use of pututline() etc. ([uw]tmp) [no]],
@@ -216,6 +399,11 @@ AC_ARG_WITH(lastlog,
        ]
 )
 
+if test -z "$no_loginfunc_check"; then
+       dnl    Checks for libutil functions (login(), logout() etc, not openpty() )
+       AC_SEARCH_LIBS(login, util bsd, [AC_DEFINE(HAVE_LOGIN,,Have login() function)])
+       AC_CHECK_FUNCS(logout updwtmp logwtmp)
+fi
 
 dnl lastlog, [uw]tmpx? detection
 dnl  NOTE: set the paths in the platform section to avoid the
@@ -398,14 +586,31 @@ AC_PROG_GCC_TRADITIONAL
 AC_FUNC_MEMCMP
 AC_FUNC_SELECT_ARGTYPES
 AC_TYPE_SIGNAL
-AC_CHECK_FUNCS([dup2 getspnam getusershell memset putenv select socket strdup clearenv strlcpy strlcat])
+AC_CHECK_FUNCS([dup2 getspnam getusershell memset putenv select socket strdup clearenv strlcpy strlcat daemon basename _getpty getaddrinfo freeaddrinfo getnameinfo])
+
+AC_SEARCH_LIBS(basename, gen, AC_DEFINE(HAVE_BASENAME))
 
 # Solaris needs ptmx
 if test -z "$no_ptmx_check" ; then
-       AC_CHECK_FILE("/dev/ptmx", AC_DEFINE(USE_DEV_PTMX,,Use /dev/ptmx))
+       if test x"$cross_compiling" = x"no" ; then
+               AC_CHECK_FILE("/dev/ptmx", AC_DEFINE(USE_DEV_PTMX,,Use /dev/ptmx))
+       else
+               AC_MSG_RESULT(Not checking for /dev/ptmx, we're cross-compiling)
+       fi
+fi
+
+if test -z "$no_ptc_check" ; then
+       if test x"$cross_compiling" = x"no" ; then
+               AC_CHECK_FILE("/dev/ptc", AC_DEFINE(HAVE_DEV_PTS_AND_PTC,,Use /dev/ptc & /dev/pts))
+       else
+               AC_MSG_RESULT(Not checking for /dev/ptc & /dev/pts\, we're cross-compiling)
+       fi
 fi
 
+AC_EXEEXT
 AC_CONFIG_HEADER(config.h)
 AC_OUTPUT(Makefile)
+AC_OUTPUT(libtomcrypt/Makefile)
+AC_OUTPUT(libtommath/Makefile)
 AC_MSG_RESULT()
 AC_MSG_RESULT(Now edit options.h to choose features.)