⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 configure.in

📁 伯克利做的SFTP安全文件传输协议
💻 IN
字号:
# configure.in for SafeTP    -*- sh -*-# Process this file with autoconf to produce a configure script.# starting point generated with 'autoscan', then edited by hand# this simply names a file somewhere in the source tree to verify# we are in the right directoryAC_INIT(addent.h)# supply a default CXXFLAGS if none is already suppliedCXXFLAGS=${CXXFLAGS-"-g -Wall"}# check for c++ compilerAC_PROG_CXX# check for C compiler too since we need it for the endianness# checks belowAC_PROG_CC# find system type (using this macro means we must include# the files install-sh, config.sub, and config.guess (all from# the autoconf distribution) in our source tree!)AC_CANONICAL_SYSTEM# for lack of any better idea, I am just going to define this for# any Makefile generated by ./configureCPPFLAGS="$CPPFLAGS -D__UNIX__"case "$target" in  # solaris  *solaris*)    AC_MSG_RESULT(adding Solaris-specific stuff)    # need two more libraries to get socket functions    #   socket: most socket funcs    #   nsl: gethostbyname, inet_addr    LDFLAGS="$LDFLAGS -lsocket -lnsl"    # under Solaris 2.51, I apparently needed some more:    #   iostream: cout, etc. (C++ iostream.h stuff)    #   m: log, pow    # but since I no longer have access to a machine to test this,    # nor do I know what $target is for Solaris 2.51, I'm just going    # to leave this as a defunct comment    #LDFLAGS="$LDFLAGS -L/usr/sww/lib -liostream -lm"    ;;  # linux  *linux*)    AC_MSG_RESULT(adding linux-specific stuff)    # need some definitions    #   __LINUX__: identify platform    #   _POSIX_SOURCE: get L_cuserid despite __STRICT_ANSI__, and also    #                  get tzset with EDG compiler    CPPFLAGS="$CPPFLAGS -D__LINUX__ -D_POSIX_SOURCE"    ;;  # DEC OSF/1  *osf*)    AC_MSG_RESULT(adding OSF-specific stuff)    # _XOPEN_SOURCE_EXTENDED: don't remember why I need it    # __OSF1__: identify platform for socklength arg stuff    CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED -D__OSF1__"    ;;  # FreeBSD  *freebsd*)    AC_MSG_RESULT(adding FreeBSD-specific stuff)    CPPFLAGS="$CPPFLAGS -D__FREEBSD__"    ;;  # SCO  *-sco*)    AC_MSG_RESULT(adding SCO-specific stuff)        # like Solaris, above    LDFLAGS="$LDFLAGS -lsocket -lnsl"    ;;esac# Checks for header files.AC_HEADER_STDCAC_CHECK_HEADERS(strings.h sys/time.h unistd.h)# Checks for typedefs, structures, and compiler characteristics.AC_C_CONSTAC_C_INLINEAC_HEADER_TIME# Checks for library functions.AC_FUNC_MEMCMPAC_CHECK_FUNCS(mkdir select socket)# now that I'm setting CXXFLAGS above, -O2 doesn't come in by default;# if users asks for it explicitly, they take the risk themselves#  # Hmmm... what to say... how about: GCC SUCKS A**!!!  I have wasted 30#  # hours or so tracking down 3 different optimizer bugs in this#  # #@!$%^$!$@$@!$@!#!@$%#@$ compiler (1 in gcc-2.95.2, 2 in egcs-1.1.2).#  # ENOUGH.  SafeTP will *never* be compiled with optimizations again!#  AC_MSG_RESULT(disabling optimizer because it BITES)#  CFLAGS=`echo $CFLAGS | sed 's/-O./ /' | sed 's/-O//'`#  CXXFLAGS=`echo $CXXFLAGS | sed 's/-O./ /' | sed 's/-O//'`# from now on, do tests using the C++ compilerAC_LANG(C++)# does the compiler want -I. to see headers in the current directory,# while it is compiling sources in another directory?AC_MSG_CHECKING(whether the compiler wants -I. for headers in cwd)compile="$CXX -E crypto/trivincl.cpp $CPPFLAGS"if $compile >/dev/null 2>&1; then  AC_MSG_RESULT(no)else  AC_MSG_RESULT(yes)  CPPFLAGS="$CPPFLAGS -I."  compile="$CXX -E $CPPFLAGS crypto/trivincl.cpp"  if $compile >/dev/null 2>&1; then    # ok    true  else    AC_MSG_ERROR([      Even after adding -I. to CPPFLAGS I still cannot compile a simple      program in crypto/ which includes typ.h.  Something is wrong with      the compiler installation.      This is what I tried (try it yourself to see the error):        $compile    ])  fifi# does the compiler give a big complaint when I use old-style headers?AC_MSG_CHECKING(whether I should pass -Wno-deprecated)if $CXX -c $CPPFLAGS $CXXFLAGS cout1.cpp 2>&1 | grep deprecated >/dev/null; then  AC_MSG_RESULT(yes)  PREV_CXXFLAGS="$CXXFLAGS"  CXXFLAGS="$CXXFLAGS -Wno-deprecated"  # make sure this doesn't break something  AC_MSG_CHECKING(whether compiler accepts -Wno-deprecated)  if $CXX -c $CPPFLAGS $CXXFLAGS cout1.cpp >/dev/null 2>&1; then    AC_MSG_RESULT(yes)  else    AC_MSG_RESULT(no)        # if it doesn't accept it, then revert to previous flags and live    # with the warning message    CXXFLAGS="$PREV_CXXFLAGS"  fielse  AC_MSG_RESULT(no)fi# are exceptions enabled?AC_MSG_CHECKING(whether exceptions are enabled)AC_TRY_COMPILE([],  [    try {      throw (int)5;    }    catch (int x) {    }  ],  [AC_MSG_RESULT(yes)],  [AC_MSG_ERROR([    The use of exceptions causes a compile-time error, so they are    probably not enabled in your compiler.    For older versions of gcc, the -fhandle-exceptions flag might need    to be specified in CXXFLAGS.  For other compilers, check its    documentation.  ])])# determine endianness# NOTE: this requires autoconf version 2.53 or later; earlier versions# (such as 2.52) have an AC_C_BIGENDIAN that does not run the arguments# passed to itAC_C_BIGENDIAN(  CPPFLAGS="$CPPFLAGS -DSAFETP_BIG_ENDIAN",  CPPFLAGS="$CPPFLAGS -DSAFETP_LITTLE_ENDIAN")# check that we got one of themif echo "$CPPFLAGS" | grep ENDIAN >/dev/null; then  # ok  trueelse  # why doesn't autoconf have a way that I can check the version at  # 'autoconf' invocation time?  AC_MSG_ERROR([    I did not get any endianness setting; maybe ./configure was created    with a version of autoconf prior to 2.53?  ])fi# does sockutil.cpp compile?  in particular, which value of# SOCKLEN_TYPE will work?AC_MSG_CHECKING(proper type for SOCKLEN_TYPE)if echo "$CPPFLAGS" | grep SOCKLEN_TYPE >/dev/null; then  # user has already specified  AC_MSG_RESULT(user-specified)  found_one=trueelse  # we will search for one  found_one=false  for candidate in "socklen_t" "int" "unsigned" "long" "unsigned long"; do    if $CXX -c sockutil.cpp $CPPFLAGS "-DSOCKLEN_TYPE=$candidate" $CXXFLAGS >/dev/null 2>&1; then      # this candidate works      AC_MSG_RESULT($candidate)      CPPFLAGS="$CPPFLAGS -DSOCKLEN_TYPE=$candidate"      found_one=true      break    fi  donefi# did we find a candidate?if $found_one; then  # make sure one last time; this will cover user-specified case too  compile="$CXX -c sockutil.cpp $CPPFLAGS $CXXFLAGS"  if $compile >/dev/null 2>&1; then    # ok    true  else    AC_MSG_ERROR([      I failed to compile sockutil.cpp, even after finding a candidate      (or it was specified on the command line).      This is what I tried (try it yourself to see the error):        $compile    ])  fielse  # nope  AC_MSG_ERROR([    I cannot compile sockutil.cpp.    The most typical cause is an unexpected type for the third parameter    to the accept() call.  I already tried several, including socklen_t.    If you know what the correct type is (try "man accept"?), specify it    in with "./configure CPPFLAGS=-DSOCKLEN_TYPE=<type>".    This is one command line I tried (try it yourself to see the error):      $CXX -c sockutil.cpp $CPPFLAGS -DSOCKLEN_TYPE=socklen_t $CXXFLAGS  ])fi# does cout1 work?AC_MSG_CHECKING(whether simple uses of 'cout' work)compile="$CXX -o cout1 cout1.cpp $CPPFLAGS $CXXFLAGS $LDFLAGS"if $compile >/dev/null 2>&1; then  if ./cout1 >/dev/null; then    AC_MSG_RESULT(yes)  else    AC_MSG_ERROR([      A simple C++ program using 'cout' does not work.      One common reason is a misconfiguration of the shared libraries needed      for C++ programs, particularly libstdc++.so.  Sometimes this gets put      into /usr/local/lib when the system search path does not include that      directory.  If this is the problem, try moving or symlinking it into      /usr/lib.      The compilation command I used was        $compile      and then I did        ./cout1      which failed.    ])  fielse  AC_MSG_ERROR([    I could not compile a simple C++ program that uses 'cout'.  Something     is wrong with the compiler (or libraries) installation.    This is what I tried (try it yourself to see the error):      $compile  ])fi# where to look for GMP components; the current directory (since# that's a convenient place to put symlinks), and any directory# off this one's parent whose name starts with "gmp"places_to_look=`echo . ../gmp*`AC_MSG_RESULT(I may look for GMP files in these directories: $places_to_look)# find libgmp.a, the GNU multi-precision library, available# from http://www.swox.com/gmp/AC_CHECK_LIB(gmp, mpz_invert, LDFLAGS="$LDFLAGS -lgmp", [  # since I don't want to force people to install gmp, let's be  # a bit lenient about where it might be  AC_MSG_CHECKING(for libgmp.a)  # search for it (hack: exclude sftpd's "nt" directory)  (find $places_to_look -name libgmp.a -print | grep -v '/nt/') \     > conftest.lst 2>/dev/null  if test `wc -l < conftest.lst` -gt 0 ; then    # found at least one, use the first    where_gmp=`head -1 conftest.lst`    AC_MSG_RESULT(found $where_gmp)    LDFLAGS="$LDFLAGS $where_gmp"        # hit it with ranlib for good measure; discard errors    ranlib $where_gmp >/dev/null 2>&1  else    # didn't find it    AC_MSG_ERROR([      I could not find libgmp.a (the GNU multi-precision math library).        - If you do not have it, get it from http://www.swox.com/gmp/,          compile it in a directory that is a peer of this one, and          then run ./configure again.  Sparc users, you may want to          look at http://safetp.cs.berkeley.edu/sun.arch.html first.        - If you do have it, you can put a symlink in the current          directory, like this:            ln -s /some/place/libgmp.a .          and then run ./configure again.    ])  fi])# find gmp.h, the header for libgmp.aAC_CHECK_HEADER(gmp.h, true, [  # similar to above, search for gmp.h myself  AC_MSG_CHECKING(for gmp.h)  # search for it (hack: exclude sftpd's "nt" directory)  (find $places_to_look -name gmp.h -print | grep -v '/nt/') \     > conftest.lst 2>/dev/null  if test `wc -l < conftest.lst` -gt 0 ; then    # found at least one, use the first    where_gmph=`head -1 conftest.lst`    dir_gmph=`echo $where_gmph | sed 's#/[^/]*$##'`    AC_MSG_RESULT([found $where_gmph; it is in directory $dir_gmph])    CPPFLAGS="$CPPFLAGS -I$dir_gmph"  else    # didn't find it    AC_MSG_ERROR([      I could not find gmp.h (the header for the libgmp.a).      Since I already found libgmp.a, I am assuming you do have this      file somewhere.  You can put a symlink in the current directory,      like this:        ln -s /some/place/gmp.h .      and then run ./configure again    ])    exit 1  fi])# try a simple GMP programAC_MSG_CHECKING(whether GMP works)compile="$CXX -o testgmp testgmp.cpp $CPPFLAGS $CXXFLAGS $LDFLAGS"if $compile >/dev/null 2>&1; then  if ./testgmp >/dev/null 2>&1; then    AC_MSG_RESULT(yes)  else    AC_MSG_ERROR([      A simple GMP test program failed to run correctly.              Something is wrong with how GMP is installed.      This is what I tried (try it yourself to see the error):        $compile        ./testgmp    ])  fielse  AC_MSG_ERROR([    A simple GMP test program failed to compile.      Something is wrong with how GMP is installed.  One possible cause is    having two different versions installed, where the header (gmp.h)     from one version is used during compilation, and the library     (libgmp.a) from another is used during linking.        Another possibility is that GMP and SafeTP are using different ABIs.    See http://safetp.cs.berkeley.edu/sun.arch.html for some hints in    that case.    This is what I tried (try it yourself to see the error):      $compile  ])fi# does /dev/random exist and work?AC_MSG_CHECKING(whether /dev/random exists and works)has_dev_random=falsecompile="$CXX -o nonport nonport.cpp -DTEST_NONPORT $CPPFLAGS $CXXFLAGS $LDFLAGS"if $compile >/dev/null 2>&1; then  # run this inside a subshell to avoid the ugly printout that happens  # when a process exits because of a signal  if (./nonport -hasRandom || exit) 2>/dev/null; then    AC_MSG_RESULT(yes)    has_dev_random=true  else    AC_MSG_RESULT(no)    # try /dev/srandom instead; this is for OpenBSD.    AC_MSG_CHECKING(whether /dev/srandom is an alternative)    compile="$CXX -o nonport nonport.cpp -DTEST_NONPORT -DUSE_DEV_SRANDOM $CPPFLAGS $CXXFLAGS $LDFLAGS"    if $compile >/dev/null 2>&1 && \       (./nonport -hasRandom || exit) 2>/dev/null; then      AC_MSG_RESULT(yes)      has_dev_random="true (/dev/srandom)"      CPPFLAGS="$CPPFLAGS -DUSE_DEV_SRANDOM"    else      AC_MSG_RESULT(no)      has_dev_random=false      CPPFLAGS="$CPPFLAGS -DNO_DEV_RANDOM"    fi    # remove the executable, because we want 'make' to recompile this    # now that the CPPFLAGS have been adjusted    rm nonport  fielse  AC_MSG_ERROR([    Cannot compile nonport.cpp.      Something is wrong with the compiler install, or the compilation flags    passed to configure (see ./configure --help=short).    This is what I tried (try it yourself to see the error):      $compile  ])fi# strip leading space from $LDFLAGS, since it often gets oneLDFLAGS=`echo $LDFLAGS`# construct a summary which will be displayed by ./config.statusAC_CONFIG_COMMANDS([summary], [# if we'll be using $PATH to find it, mention which one we'll findif echo $CXX | grep '/' >/dev/null; then  # not using $PATH  which_CXX=""else  # using $PATH  which_CXX="(currently "`which $CXX`")"ficat <<EOFSafeTP configuration:  Target description:       $target  Has working /dev/random:  $has_dev_random  C++ compiler:             $CXX $which_CXX  C++ compilation flags:    $CXXFLAGS  Libraries:                $LDFLAGS  Preprocessor flags:EOFecho "$CPPFLAGS" | fmt -70 | sed 's/^ */    /'cat <<EOFYou can now run 'make' (or 'gmake' if that is what GNU make is called).EOF], [  # these assignments communicate shell variables from  # ./configure to ./config.status; this works by catting this section  # into config.status with double-quote expansion, so what gets catted  # has variables expanded  target=$target  has_dev_random='$has_dev_random'  CXX='$CXX'  CXXFLAGS='$CXXFLAGS'  LDFLAGS='$LDFLAGS'  CPPFLAGS='$CPPFLAGS'])# finish the configure script and generate the Makefile; make it# unwritable to avoid accidentally editing a generated fileAC_CONFIG_FILES(Makefile, chmod a-w Makefile)AC_OUTPUT()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -