Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics
[simgrid.git] / src / nws_portability / configure.in
1 #
2 # configure.in for the Portability library used mainly in NWS
3 #
4 # $Id$
5 #
6
7 # Process this file with autoconf to produce a configure script.
8 AC_INIT(protocol.c)
9 AC_CONFIG_HEADER([Include/config_portability.h:Include/config_portability.h.in])
10
11 # Checks the host we are running on.
12 AC_CANONICAL_HOST
13
14 # Set paths and common variables and NWS top directory (if compiling with
15 # NWS)
16 if test -n "$TOP"; then
17         NWS_TOP="${TOP}"
18 else 
19         NWS_TOP=`pwd`
20 fi
21 TOP=`pwd`
22 INCLUDES="-I${TOP}/Include"
23 ARFLAGS="cr"
24 test_debug="no"
25 test_thread="no"
26 use_alarm_signal="no"
27
28 # Set default for CFLAGS
29 CFLAGS="-DHAVE_CONFIG_H"
30
31 # test for command line options
32 AC_ARG_ENABLE(debug,
33         [  --enable-debug         include debugging info when compiling],
34                 [if test "${withval}" != "yes"; then
35                         test_debug="yes"
36                 fi])
37
38 AC_ARG_ENABLE(threads,
39         [  --enable-threads        test for threads support],
40                 [if test "${enableval}" != "no"; then
41                         test_thread="yes"
42                 fi])
43
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)
49                 fi],
50         [AC_DEFINE(USE_ALARM_SIGNAL)
51          use_alarm_signal="yes"])
52
53 # Checks for programs.
54 AC_PATH_PROG(AR, ar)
55 AC_PROG_CC
56 # Setting up debug options
57 if test "${test_debug}" = "yes"; then
58         CFLAGS="${CFLAGS} -g "
59 else 
60         CFLAGS="${CFLAGS} -O2"
61         if test "${GCC}" = "yes" ; then
62                 CFLAGS="${CFLAGS} -finline-functions"
63         fi
64 fi
65
66 AC_PROG_INSTALL
67 AC_PROG_RANLIB
68 AC_PATH_PROG(RM, rm)
69 AC_PATH_PROG(CP, cp)
70 AC_PATH_PROG(TAR, tar)
71 AC_PATH_PROG(CTAGS, ctags)
72
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)
78 else
79         AC_PATH_PROG(PROFILE, prof)
80 fi
81
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)
88 fi
89
90 # Checks for header files and symbols declared in headers.
91 AC_HEADER_STDC
92 AC_HEADER_SYS_WAIT
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)
96 fi
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)
100
101 dnl IPADDRESS="unsigned int"
102 dnl if test "${SIZEOF_LONG}" = "4" ; then
103 dnl     IPADDRESS="unsigned long"
104 dnl fi
105
106 dnl end workaround
107
108
109
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.
115 AC_TRY_COMPILE(
116   [#include <sys/types.h>
117    #include <sys/socket.h>],
118   [extern int getpeername(int socket, struct sockaddr *addr, socklen_t *len);],
119   SOCKLEN_T=socklen_t,
120   AC_TRY_COMPILE(
121     [#include <sys/types.h>
122      #include <sys/socket.h>],
123     [extern int getpeername(int socket, struct sockaddr *addr, size_t *len);],
124     SOCKLEN_T=size_t,
125     AC_TRY_COMPILE(
126       [#include <sys/types.h>
127        #include <sys/socket.h>],
128       [socklen_t len; Psocklen_t lenP = &len;
129        (void)getpeername(0, 0, lenP);],
130        SOCKLEN_T=socklen_t,
131        SOCKLEN_T=int
132     )
133   )
134 )
135
136
137 # Checks for typedefs, structures, and compiler characteristics.
138 AC_C_CONST
139 AC_TYPE_MODE_T
140 AC_TYPE_PID_T
141 AC_TYPE_SIZE_T
142 AC_HEADER_TIME
143 AC_STRUCT_TM
144
145 # Checks for library functions.
146 dnl AC_FUNC_FORK
147 dnl AC_FUNC_MALLOC
148 dnl AC_FUNC_STAT
149 AC_TYPE_SIGNAL
150 AC_FUNC_VPRINTF
151
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]))
154 fi
155
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])
157
158 # Substitute these variables.
159 AC_SUBST(AR)
160 AC_SUBST(ARFLAGS)
161 AC_SUBST(INCLUDES)
162 AC_SUBST(PREFIX_DIR)
163 # the following should be automatically substitute by autoconf but for
164 # consistency we put them here
165 AC_SUBST(CC)
166 AC_SUBST(CFLAGS)
167 AC_SUBST(LDFLAGS)
168 AC_SUBST(RM)
169 AC_SUBST(TAR)
170 AC_SUBST(CP)
171 AC_SUBST(CTAGS)
172 AC_SUBST(TOP)
173 AC_SUBST(NWS_TOP)
174 AC_SUBST(uint32_t)
175
176 # Define new variables to substitute.
177 AC_DEFINE_UNQUOTED(SOCKLEN_T, ${SOCKLEN_T})
178 AC_SUBST(SOCKLEN_T)
179
180 dnl AC_DEFINE_UNQUOTED(IPADDRESS, ${IPADDRESS})
181 dnl AC_SUBST(IPADDRESS)
182
183 AC_DEFINE_UNQUOTED(TOP, "$TOP")
184
185
186 AC_OUTPUT([Makedefs])