📄 configure.in
字号:
dnldnl autoconf script for UNP 3/e Volume 1 source code.dnl Process this file with autoconf to produce a configure script.dnldnl The end result of running configure is the "config.h" file and thednl "Make.defines" file in the current directory. These two files arednl created from the "config.h.in" and "Make.defines.in" files in thednl current directory.dnldnl The header "unp.h" that is in every source directory then does adnl #include "../config.h" and the Makefile in each source directorydnl then does a include of ../Make.defines.dnlAC_REVISION($Revision: 1.13 $)AC_INIT(lib/unp.h)AC_CANONICAL_HOSTAC_CONFIG_HEADER(config.h)dnl The following cpu_vendor_os string goes into config.h.dnlAC_DEFINE_UNQUOTED(CPU_VENDOR_OS, "$host", [CPU, vendor, and operating system])dnl ##################################################################dnl Checks for programs.dnldnl Some system-specific stuff ...dnl Some operating systems require additional flags in order to get alldnl the definitions that we're looking for in some system headers.dnl The configure script uses both CFLAGS and CPPFLAGS when compiling.case "$host_os" in*aix*) CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE" ;;*osf*) CPPFLAGS="$CPPFLAGS -D_SOCKADDR_LEN" ;;esacAC_PROG_CCAC_PROG_RANLIBdnl ##################################################################dnl Checks for libraries.dnl The order of these tests is the *reverse* order of the libraries indnl the LIBS variable that is constructed: each new one gets prepended,dnl not appended.dnldnl We are building three strings here; something like:dnl LIBS="-lresolv -lsocket -lnsl -lpthread"dnl LIBS_XTI="-lxti -lresolv -lnsl -lpthread"dnl LIBUNP="./libunp.a"dnl LIBUNPXTI="./libunpxti.a"dnldnl If a threads library is found, need to update CFLAGS too.dnlAC_CHECK_LIB(pthread, pthread_create)if test "$ac_cv_lib_pthread_pthread_create" = yes ; then CFLAGS="$CFLAGS -D_REENTRANT"else AC_CHECK_LIB(pthreads, pthread_create) if test "$ac_cv_lib_pthreads_pthread_create" = yes ; then CFLAGS="$CFLAGS -D_REENTRANT" fifiAC_CHECK_LIB(nsl, t_open)AC_SEARCH_LIBS(socket, socket)dnl Bind 8.1.1 places its library in /usr/local/bind/lib/libbind.a; we checkdnl for it first. Also check for libbind.a in user's home directory.dnl If there is a libresolv.a in the user's HOME directory, we will usednl that instead of -lresolv. Need this for people interested in buildingdnl an IPv6-knowledgable resolver, instead of using the system provideddnl resolver (which is often way out of date).dnlAC_MSG_CHECKING(for /usr/local/bind/lib/libbind.a)if test -f /usr/local/bind/lib/libbind.a ; then AC_MSG_RESULT(yes) LIBS="/usr/local/bind/lib/libbind.a $LIBS"else AC_MSG_RESULT(no) AC_MSG_CHECKING(for $HOME/libbind.a) if test -f $HOME/libbind.a ; then AC_MSG_RESULT(yes) LIBS="$HOME/libbind.a $LIBS" else AC_MSG_RESULT(no) AC_MSG_CHECKING(for $HOME/libresolv.a) if test -f $HOME/libresolv.a ; then AC_MSG_RESULT(yes) LIBS="$HOME/libresolv.a $LIBS" else AC_MSG_RESULT(no) AC_CHECK_LIB(resolv, res_init) fi fifidnl Now check for XTI library.dnlAC_CHECK_LIB(xti, t_open)dnl We now need to check for our own libraries, but we cannot prependdnl them to the LIBS variable, as that variable is used when compilingdnl programs later in this script, and that would mess things up.dnldnl If the user has a file named $HOME/libunp.a, then use it.dnl Else store our library in current directory.dnl I use this because my source directory is NFS mounted from my variousdnl systems, but I have a unique home directory on each system.dnlAC_MSG_CHECKING(for $HOME/libunp.a)if test -f $HOME/libunp.a ; then AC_MSG_RESULT(yes) LIBUNP="$HOME/libunp.a" LIBUNP_NAME=$HOME/libunp.aelse AC_MSG_RESULT(no, using ./libunp.a) LIBUNP="../libunp.a" LIBUNP_NAME=../libunp.afidnl If the user has a file named $HOME/libunpxti.a, then use it.dnl Else store our library in current directory.dnl Same reasoning as above.dnlAC_MSG_CHECKING(for $HOME/libunpxti.a)if test -f $HOME/libunpxti.a ; then AC_MSG_RESULT(yes) LIBUNPXTI="$HOME/libunpxti.a" LIBUNPXTI_NAME=$HOME/libunpxti.aelse AC_MSG_RESULT(no, using ./libunpxti.a) LIBUNPXTI="../libunpxti.a" LIBUNPXTI_NAME=../libunpxti.afidnl ##################################################################dnl Checks for header files.dnldnl The list of headers in the AC_CHECK_HEADERS macro is the same as indnl our "unp.h" header, followed by our "unpxti.h" header.dnlAC_HEADER_STDCdnldnl The includes (the 4th argument to AC_CHECK_HEADERS) here arednl the defeault set ($ac_includes_default) plus <sys/param.h>dnl for <sys/sysctl.h> on NetBSD and OpenBSD.AC_CHECK_HEADERS(sys/types.h sys/socket.h sys/time.h time.h netinet/in.h arpa/inet.h errno.h fcntl.h netdb.h signal.h stdio.h stdlib.h string.h sys/stat.h sys/uio.h unistd.h sys/wait.h sys/un.h sys/param.h sys/select.h sys/sysctl.h poll.h sys/event.h strings.h sys/ioctl.h sys/filio.h sys/sockio.h pthread.h net/if_dl.h xti.h xti_inet.h netconfig.h netdir.h stropts.h, [], [], [#include <stdio.h>#if HAVE_SYS_TYPES_H# include <sys/types.h>#endif#if HAVE_SYS_STAT_H# include <sys/stat.h>#endif#if STDC_HEADERS# include <stdlib.h># include <stddef.h>#else# if HAVE_STDLIB_H# include <stdlib.h># endif#endif#if HAVE_STRING_H# if !STDC_HEADERS && HAVE_MEMORY_H# include <memory.h># endif# include <string.h>#endif#if HAVE_STRINGS_H# include <strings.h>#endif#if HAVE_INTTYPES_H# include <inttypes.h>#else# if HAVE_STDINT_H# include <stdint.h># endif#endif#if HAVE_UNISTD_H# include <unistd.h>#endif#if HAVE_SYS_PARAM_H# include <sys/param.h>#endif])dnl ##################################################################dnl Checks for typedefs.dnldnl We use our own AC_UNP_CHECK_TYPE macro, instead of AC_CHECK_TYPE,dnl to #include more headers. Our macro is defined in "aclocal.m4".dnlAC_HEADER_TIMEAC_UNP_CHECK_TYPE(uint8_t, unsigned char, 8-bit unsigned type)AC_UNP_CHECK_TYPE(int16_t, short, 16 bit signed type)AC_UNP_CHECK_TYPE(uint16_t, unsigned short, 16 bit unsigned type)AC_UNP_CHECK_TYPE(int32_t, int, 32 bit signed type)AC_UNP_CHECK_TYPE(uint32_t, unsigned int, 32 bit unsigned type)AC_UNP_CHECK_TYPE(size_t, unsigned int, unsigned integer type of the result of the sizeof operator)AC_UNP_CHECK_TYPE(ssize_t, int, a signed type appropriate for a count of bytes or an error indication)AC_UNP_CHECK_TYPE(socklen_t, unsigned int, a type appropriate for address, hostname, buffer, etc. lengths)dnldnl The SA_FAMILY_T in the following is #defined later, as its definitiondnl depends on whether socket address structures have a length field or not.dnlAC_UNP_CHECK_TYPE(sa_family_t, SA_FAMILY_T, the type of the sa_family struct member)dnl We also have our own macro to check for XTI definitions, that candnl be defined after #include of our "unpxti.h" header.dnlAC_UNPXTI_CHECK_TYPE(t_scalar_t, int32_t, scalar type)AC_UNPXTI_CHECK_TYPE(t_uscalar_t, uint32_t, unsigned scalar type)dnl ##################################################################dnl Check if sockaddr{} has sa_len member.dnlAC_CHECK_MEMBER([struct sockaddr.sa_len], AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, define if socket address structures have length fields),,[#include <sys/types.h>#include <sys/socket.h>])dnl Now we can complete the definition for sa_family_t, if needed.dnl The size of this datatype depends whether socket address structuresdnl have a length field or not.dnlif test $ac_cv_type_sa_family_t = no ; then if test $ac_cv_member_struct_sockaddr_sa_len = yes ; then AC_DEFINE(SA_FAMILY_T, uint8_t, the size of the sa_family field in a socket address structure) else AC_DEFINE(SA_FAMILY_T, uint16_t) fifidnldnl Check for sockaddr_storage.dnl If it's present, check for ss_family.dnl If ss_family isn't there, check for __ss_family anddnl #define ss_family __ss_family if so.dnl If neither is there, I don't know what to do.dnlAC_CHECK_TYPES([struct sockaddr_storage], AC_CHECK_MEMBER([struct sockaddr_storage.ss_family],, AC_CHECK_MEMBER([struct sockaddr_storage.__ss_family], AC_DEFINE([ss_family],[__ss_family],[define to __ss_family if sockaddr_storage has that instead of ss_family]), AC_MSG_ERROR([cannot find ss_family in sockaddr_storage]),[#include <sys/types.h>#include <sys/socket.h>]),[#include <sys/types.h>#include <sys/socket.h>]),,[#include <sys/types.h>#include <sys/socket.h>])dnl Check if msghdr{} has msg_control member.dnlAC_CHECK_MEMBER([struct msghdr.msg_control], AC_DEFINE(HAVE_MSGHDR_MSG_CONTROL, 1, define if struct msghdr contains the msg_control member),,[#include <sys/types.h>#include <sys/socket.h>])dnldnl Check for ifr_mtu in ifreq - some systems have SIOCGIFMTUdnl but don't have ifr_mtu!!AC_CHECK_MEMBERS([struct ifreq.ifr_mtu],,,[#include <sys/types.h>#include <sys/socket.h>#include <net/if.h>])dnl ##################################################################dnl Check for function prototypes in headers.dnl AC_CHECK_FUNC_PROTO is our own macro in "aclocal.m4".dnlAC_CHECK_FUNC_PROTO(getaddrinfo, netdb.h)AC_CHECK_FUNC_PROTO(getnameinfo, netdb.h)AC_CHECK_FUNC_PROTO(gethostname, unistd.h)AC_CHECK_FUNC_PROTO(getrusage, sys/resource.h)AC_CHECK_FUNC_PROTO(hstrerror, netdb.h)AC_CHECK_FUNC_PROTO(if_nametoindex, net/if.h)AC_CHECK_FUNC_PROTO(inet_aton, arpa/inet.h)AC_CHECK_FUNC_PROTO(inet_pton, arpa/inet.h)AC_CHECK_FUNC_PROTO(pselect, sys/select.h)AC_CHECK_FUNC_PROTO(snprintf, stdio.h)AC_CHECK_FUNC_PROTO(sockatmark, sys/socket.h)dnldnl autoheader doesn't know how to handle the above, so we havednl to help it out.AH_TEMPLATE(HAVE_GETADDRINFO_PROTO, define if getaddrinfo prototype is in <netdb.h>)AH_TEMPLATE(HAVE_GETNAMEINFO_PROTO, define if getnameinfo prototype is in <netdb.h>)AH_TEMPLATE(HAVE_GETHOSTNAME_PROTO, define if gethostname prototype is in <unistd.h>)AH_TEMPLATE(HAVE_GETRUSAGE_PROTO, define if getrusage prototype is in <sys/resource.h>)AH_TEMPLATE(HAVE_HSTRERROR_PROTO, define if hstrerror prototype is in <netdb.h>)AH_TEMPLATE(HAVE_IF_NAMETOINDEX_PROTO, define if if_nametoindex prototype is in <net/if.h>)AH_TEMPLATE(HAVE_INET_ATON_PROTO, define if inet_aton prototype is in <arpa/inet.h>)AH_TEMPLATE(HAVE_INET_PTON_PROTO, define if inet_pton prototype is in <arpa/inet.h>)AH_TEMPLATE(HAVE_PSELECT_PROTO, define if pselect prototype is in <sys/stat.h>)AH_TEMPLATE(HAVE_SNPRINTF_PROTO, define if snprintf prototype is in <stdio.h>)AH_TEMPLATE(HAVE_SOCKATMARK_PROTO, define if sockatmark prototype is in <sys/socket.h>)dnl ##################################################################dnl Check for structure definitions.dnlAC_CHECK_TYPE(struct addrinfo, AC_DEFINE(HAVE_ADDRINFO_STRUCT, 1, Define to 1 if <netdb.h> defines struct addrinfo),,[#include <netdb.h>])dnlAC_CHECK_TYPE(struct if_nameindex, AC_DEFINE(HAVE_IF_NAMEINDEX_STRUCT, 1, Define to 1 if <net/if.h> defines struct if_nameindex),,[#include <sys/types.h>#include <sys/socket.h>#include <net/if.h>])dnlAC_CHECK_TYPE([struct sockaddr_dl], AC_DEFINE(HAVE_SOCKADDR_DL_STRUCT, 1, Define to 1 if <net/if_dl.h> defines struct sockaddr_dl),,[#include <sys/types.h>#include <sys/socket.h>#include <net/if_dl.h>])dnl OpenBSD puts struct timespec in <sys/time.h> instead of <time.h>,dnl thus this complex test.AC_CHECK_TYPE([struct timespec], AC_DEFINE(HAVE_TIMESPEC_STRUCT, 1, Define to 1 if <time.h> or <sys/time.h> defines struct timespec),,[#if TIME_WITH_SYS_TIME#include <sys/time.h>#include <time.h>#else#if HAVE_SYS_TIME_H#include <sys/time.h>#else#include <time.h>#endif#endif])dnl ##################################################################dnl Check for XTI devices.dnlAC_MSG_CHECKING(for /dev/tcp)if test -r /dev/tcp ; then AC_DEFINE(HAVE_DEV_TCP, 1, Define to 1 if the /dev/tcp device exists) AC_MSG_RESULT(yes)else AC_MSG_RESULT(no) AC_MSG_CHECKING(for /dev/xti/tcp) if test -r /dev/xti/tcp ; then AC_DEFINE(HAVE_DEV_XTI_TCP, 1, Define to 1 if the /dev/xti/tcp device exists) AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) AC_MSG_CHECKING(for /dev/streams/xtiso/tcp) if test -r /dev/streams/xtiso/tcp ; then AC_DEFINE(HAVE_DEV_STREAMS_XTISO_TCP, 1, Define to 1 if the /dev/streams/xtiso/tcp device exists) AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi fifi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -