2 # configure.in for the Portability library used mainly in NWS
7 # Process this file with autoconf to produce a configure script.
9 AC_CONFIG_HEADER([Include/config_portability.h:Include/config_portability.h.in])
11 # Checks the host we are running on.
14 # Set paths and common variables and NWS top directory (if compiling with
16 if test -n "$TOP"; then
22 INCLUDES="-I${TOP}/Include"
28 # Set default for CFLAGS
29 CFLAGS="-DHAVE_CONFIG_H"
31 # test for command line options
33 [ --enable-debug include debugging info when compiling],
34 [if test "${withval}" != "yes"; then
38 AC_ARG_ENABLE(threads,
39 [ --enable-threads test for threads support],
40 [if test "${enableval}" != "no"; then
44 AC_ARG_ENABLE(sigalarm,
45 [ --disable-sigalarm don't use SIGALRM],
46 [if test "${enableval}" != "no"; then
47 use_alarm_signal="yes"
48 AC_DEFINE(USE_ALARM_SIGNAL)
50 [AC_DEFINE(USE_ALARM_SIGNAL)
51 use_alarm_signal="yes"])
53 # Checks for programs.
56 # Setting up debug options
57 if test "${test_debug}" = "yes"; then
58 CFLAGS="${CFLAGS} -g "
60 CFLAGS="${CFLAGS} -O2"
61 if test "${GCC}" = "yes" ; then
62 CFLAGS="${CFLAGS} -finline-functions"
70 AC_PATH_PROG(TAR, tar)
71 AC_PATH_PROG(CTAGS, ctags)
73 # Set compiler and linker switches
74 if test "${CC}" = "gcc"; then
75 # Adding all annoying warning compilers message
76 CFLAGS="${CFLAGS} -Wall -pedantic -Wshadow -Wpointer-arith -Wwrite-strings"
77 AC_PATH_PROG(PROFILE, gprof)
79 AC_PATH_PROG(PROFILE, prof)
82 # Checks for libraries.
83 dnl LDFLAGS="${LDFLAGS} -lm"
84 AC_CHECK_LIB(nsl, inet_ntoa)
85 AC_CHECK_LIB(socket, socket)
86 if test "${test_thread}" = "yes"; then
87 AC_CHECK_LIB(pthread, pthread_mutex_lock)
90 # Checks for header files and symbols declared in headers.
93 AC_CHECK_HEADERS([arpa/inet.h errno.h netdb.h netinet/in.h stddef.h stdlib.h string.h strings.h sys/socket.h sys/time.h unistd.h math.h inttypes.h])
94 if test "${test_thread}" = "yes"; then
95 AC_CHECK_HEADERS(pthread.h)
97 dnl TYPES is only for autoconf2.50 and 2.13 has a broken TYPE: cheap workaround
98 dnl AC_CHECK_TYPES(uint32_t)
99 AC_CHECK_TYPE(uint32_t, unsigned long)
101 dnl IPADDRESS="unsigned int"
102 dnl if test "${SIZEOF_LONG}" = "4" ; then
103 dnl IPADDRESS="unsigned long"
110 # The third parameter to getpeername() is a pointer to socklen_t, size_t, or
111 # int on various systems. Worse yet, some systems define socklen_t but use a
112 # different type in the getpeername() prototype, and Solaris Intel defines
113 # Psocklen_t, which is a pointer to either socklen_t or void. We use SOCKLEN_T
114 # in the NWS code, defining it the proper type for the system.
116 [#include <sys/types.h>
117 #include <sys/socket.h>],
118 [extern int getpeername(int socket, struct sockaddr *addr, socklen_t *len);],
121 [#include <sys/types.h>
122 #include <sys/socket.h>],
123 [extern int getpeername(int socket, struct sockaddr *addr, size_t *len);],
126 [#include <sys/types.h>
127 #include <sys/socket.h>],
128 [socklen_t len; Psocklen_t lenP = &len;
129 (void)getpeername(0, 0, lenP);],
137 # Checks for typedefs, structures, and compiler characteristics.
145 # Checks for library functions.
152 if test "$use_alarm_signal" != "no"; then
153 AC_CHECK_FUNC(alarm, AC_DEFINE(HAVE_ALARM), AC_MSG_ERROR([Can't do without alarm!! Try to configure with --disable-sigalarm]))
156 AC_CHECK_FUNCS([endpwent ftruncate gethostbyaddr gethostbyaddr_r gethostbyname gethostname uname gettimeofday inet_aton inet_ntoa memset mkdir select socket strcasecmp strchr strdup strerror sysconf getrusage siginterrupt sighold sigrelse strnlen fileno sqrt])
158 # Substitute these variables.
163 # the following should be automatically substitute by autoconf but for
164 # consistency we put them here
176 # Define new variables to substitute.
177 AC_DEFINE_UNQUOTED(SOCKLEN_T, ${SOCKLEN_T})
180 dnl AC_DEFINE_UNQUOTED(IPADDRESS, ${IPADDRESS})
181 dnl AC_SUBST(IPADDRESS)
183 AC_DEFINE_UNQUOTED(TOP, "$TOP")
186 AC_OUTPUT([Makedefs])