2
# Process this file with autoconf to produce a configure script.
8
AC_INIT([OpenPGM], [m4_esyscmd([perl version.pl %major.%minor])], [openpgm-dev@googlegroups.com], [openpgm], [http://code.google.com/p/openpgm/])
9
AC_CONFIG_SRCDIR([reed_solomon.c])
10
AC_CONFIG_MACRO_DIR([m4])
15
AM_INIT_AUTOMAKE([1.10 no-define foreign])
16
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
18
AC_SUBST([RELEASE_INFO], [m4_esyscmd([perl version.pl %major.%minor])])
19
AC_SUBST([VERSION_INFO], [m4_esyscmd([perl version.pl 0:%micro])])
21
# Checks for programs.
25
AC_PATH_PROG(PERL, perl)
26
AC_PATH_PROG(PYTHON, python)
28
# nb: earliest verifiable version is 2.2.
29
m4_ifdef([LT_PREREQ], [LT_PREREQ([2.2])])
30
m4_ifdef([LT_INIT], [LT_INIT])
31
AC_SUBST([LIBTOOL_DEPS])
35
# Apply system specific rules.
37
CFLAGS="$CFLAGS -D_REENTRANT"
40
CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600 -D_BSD_SOURCE"
43
CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600 -D__EXTENSIONS__"
44
AC_SEARCH_LIBS([socket], [socket])
45
AC_SEARCH_LIBS([gethostname], [nsl])
46
AC_SEARCH_LIBS([inet_aton], [resolv])
47
AC_SEARCH_LIBS([kstat_open], [kstat])
53
# Checks for libraries.
54
AC_SEARCH_LIBS([sqrt], [m])
55
AC_SEARCH_LIBS([pthread_mutex_trylock], [pthread])
56
AC_SEARCH_LIBS([clock_gettime], [rt])
58
# Checks for header files.
60
AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h inttypes.h libintl.h limits.h locale.h malloc.h memory.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h sys/timeb.h syslog.h unistd.h wchar.h])
62
# Checks for typedefs, structures, and compiler characteristics.
79
# Checks for library functions.
80
# TODO: gettext() fails out-of-the-box from AutoConf.
86
AC_CHECK_FUNCS([atexit clock_gettime floor ftime gethostbyaddr gethostbyname gethostname gettimeofday inet_ntoa memmove memset regcomp select setenv setlocale socket sqrt stpcpy strcasecmp strchr strdup strerror strncasecmp strpbrk strrchr strstr strtol strtoul strtoull])
89
AC_MSG_CHECKING([for pthread_spinlock])
91
[AC_LANG_PROGRAM([[#include <pthread.h>]],
92
[[pthread_spinlock_t spinlock; pthread_spin_lock (&spinlock);]])],
94
CFLAGS="$CFLAGS -DCONFIG_HAVE_POSIX_SPINLOCK"],
95
[AC_MSG_RESULT([no])])
97
AC_CHECK_FUNC([getprotobyname_r])
98
if test "x$ac_cv_func_getprotobyname_r" = "xyes"; then
99
AC_MSG_CHECKING([for 4- or 5-param getprotobyname_r])
101
[AC_LANG_PROGRAM([[#include <netdb.h>]],
102
[[getprotobyname_r ((const char*)0, (struct protoent*)0, (char*)0, (size_t)0, (struct protoent**)0);]])],
103
[AC_MSG_RESULT([5-param])
104
CFLAGS="$CFLAGS -DCONFIG_HAVE_GETPROTOBYNAME_R2"],
105
[AC_MSG_RESULT([4-param])
106
CFLAGS="$CFLAGS -DCONFIG_HAVE_GETPROTOBYNAME_R"])
108
# NSS networks lookup, IPv4 only
109
AC_CHECK_FUNC([getnetent],
110
CFLAGS="$CFLAGS -DCONFIG_HAVE_GETNETENT",)
112
AC_MSG_CHECKING([for C99 variadic macros])
114
[AC_LANG_PROGRAM([[#include <stdio.h>
115
#define error(...) fprintf (stderr, __VA_ARGS__)]],
117
[AC_MSG_RESULT([yes])
118
CFLAGS="$CFLAGS -DCONFIG_HAVE_ISO_VARARGS"],
119
[AC_MSG_RESULT([no])])
120
AC_MSG_CHECKING([for GNU-style variadic macros])
122
[AC_LANG_PROGRAM([[#include <stdio.h>
123
#define error(x...) fprintf (stderr, x)]],
125
[AC_MSG_RESULT([yes])
126
CFLAGS="$CFLAGS -DCONFIG_HAVE_GNUC_VARARGS"],
127
[AC_MSG_RESULT([no])])
128
# stack memory api header
129
AC_MSG_CHECKING([for alloca.h])
131
[AC_LANG_PROGRAM([[#include <alloca.h>]],
132
[[void* ptr = alloca (1);]])],
133
[AC_MSG_RESULT([yes])
134
CFLAGS="$CFLAGS -DCONFIG_HAVE_ALLOCA_H"],
135
[AC_MSG_RESULT([no])])
137
AC_MSG_CHECKING([for eventfd])
139
[AC_LANG_PROGRAM([[#include <sys/eventfd.h>]],
140
[[eventfd (0, 0);]])],
141
[AC_MSG_RESULT([yes])
142
CFLAGS="$CFLAGS -DCONFIG_HAVE_EVENTFD"],
143
[AC_MSG_RESULT([no])])
144
# useful /proc system
145
AC_CHECK_FILE([/proc/cpuinfo],
146
CFLAGS="$CFLAGS -DCONFIG_HAVE_PROC",)
147
# example: crash handling
148
AC_CHECK_FUNC([backtrace],
149
CFLAGS="$CFLAGS -DCONFIG_HAVE_BACKTRACE",)
151
AC_CHECK_FUNC([pselect],
152
CFLAGS="$CFLAGS -DCONFIG_HAVE_PSELECT",)
153
AC_CHECK_FILE([/dev/rtc],
154
CFLAGS="$CFLAGS -DCONFIG_HAVE_RTC",)
155
AC_MSG_CHECKING([for RDTSC instruction])
162
[AC_LANG_PROGRAM(,[[unsigned long lo, hi;
163
__asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));]])],
164
[AC_MSG_RESULT([yes])
165
CFLAGS="$CFLAGS -DCONFIG_HAVE_TSC"],
166
[AC_MSG_RESULT([no])])
169
AC_CHECK_FILE([/dev/hpet],
170
CFLAGS="$CFLAGS -DCONFIG_HAVE_HPET",)
172
AC_CHECK_FUNC([poll],
173
CFLAGS="$CFLAGS -DCONFIG_HAVE_POLL",)
174
AC_CHECK_FUNC([epoll_ctl],
175
CFLAGS="$CFLAGS -DCONFIG_HAVE_EPOLL",)
176
# interface enumeration
177
AC_CHECK_FUNC([getifaddrs],
178
CFLAGS="$CFLAGS -DCONFIG_HAVE_GETIFADDRS",)
179
AC_MSG_CHECKING([for struct ifreq.ifr_netmask])
181
[AC_LANG_PROGRAM([[#include <sys/types.h>
182
#include <ifaddrs.h>]],
183
[[struct ifaddrs ifa;
184
ifa.ifa_netmask = (struct sockaddr*)0;]])],
185
[AC_MSG_RESULT([yes])
186
CFLAGS="$CFLAGS -DCONFIG_HAVE_IFR_NETMASK"],
187
[AC_MSG_RESULT([no])])
189
AC_CHECK_MEMBER([struct _WSAMSG.name],
190
CFLAGS="$CFLAGS -DCONFIG_HAVE_WSACMSGHDR",)
192
AC_MSG_CHECKING([for struct group_req.gr_interface])
194
[AC_LANG_PROGRAM([[#include <netinet/in.h>]],
195
[[struct group_req gr;
196
gr.gr_interface = 0;]])],
197
[AC_MSG_RESULT([yes])
198
CFLAGS="$CFLAGS -DCONFIG_HAVE_MCAST_JOIN"],
199
[AC_MSG_RESULT([no])])
200
AC_MSG_CHECKING([for struct ip_mreqn.imr_ifindex])
202
[AC_LANG_PROGRAM([[#include <netinet/in.h>]],
203
[[struct ip_mreqn mreqn;
204
mreqn.imr_ifindex = 0;]])],
205
[AC_MSG_RESULT([yes])
206
CFLAGS="$CFLAGS -DCONFIG_HAVE_IP_MREQN"],
207
[AC_MSG_RESULT([no])])
208
# sprintf, caveat http://savannah.gnu.org/patch/?6848 (ax_c_printf_thsep)
209
AC_MSG_CHECKING([for printf thousands' grouping])
211
[AC_LANG_PROGRAM(,[[printf ("%'d", 1000000);]])],
212
[AC_MSG_RESULT([yes])
213
CFLAGS="$CFLAGS -DCONFIG_HAVE_SPRINTF_GROUPING"],
214
[AC_MSG_RESULT([no])])
215
AC_CHECK_FUNC([vasprintf],
216
CFLAGS="$CFLAGS -DCONFIG_HAVE_VASPRINTF",)
217
# symbol linking scope
218
# nb: sun x86 ld doesn't support DSO visibility but the compiler raises
219
# warnings and these are easier to detect in autoconf.
220
save_CFLAGS="$CFLAGS"
221
CFLAGS="$CFLAGS -Werror"
222
AC_MSG_CHECKING([for hidden visibility attribute])
224
[AC_LANG_PROGRAM([[#ifdef __SUNPRO_C
227
__attribute__((visibility("hidden")))
229
void moo (void) {};]],
231
[AC_MSG_RESULT([yes])
232
CFLAGS="$save_CFLAGS -DCONFIG_HAVE_DSO_VISIBILITY"],
234
CFLAGS="$save_CFLAGS"])
237
CFLAGS="$CFLAGS -DCONFIG_BIND_INADDR_ANY"
238
# IP header order as per IP(4) on FreeBSD
239
AC_MSG_CHECKING([for raw IP sockets ip_{len,off} host byte ordering])
244
*bsd*|*darwin*|*osf*|*unixware*)
246
CFLAGS="$CFLAGS -DCONFIG_HOST_ORDER_IP_LEN -DCONFIG_HOST_ORDER_IP_OFF"
252
# extended assembler on SPARC
255
AC_MSG_CHECKING([for SPARC extended assembler])
257
[AC_LANG_PROGRAM([[#include <stdint.h>
258
uint32_t add32_with_carry (uint32_t a, uint32_t b) {
259
__asm__ ( "addcc %2, %0, %0\n\taddx %0, %%g0, %0" : "=r" (a) : "0" (a), "r" (b) : "cc");
262
[[uint32_t c = add32_with_carry (1, 2);]])],
263
[AC_MSG_RESULT([yes])],
264
[AC_MSG_RESULT([optimization required])
265
CFLAGS="$CFLAGS -xO1"])
270
# ticket spinlock friendly: unaligned pointers & atomic ops (excl. Sun Pro)
271
AC_MSG_CHECKING([for unaligned pointers])
273
[AC_LANG_PROGRAM([[char* nezumi = "mouse";]],
274
[[short x = *(short*)(nezumi + 2)]])],
275
[AC_MSG_RESULT([yes])
276
pgm_unaligned_pointers=yes],
278
pgm_unaligned_pointers=no])
279
AC_MSG_CHECKING([for intrinsic atomic ops])
280
# AC_PREPROC_IFELSE not always portable
282
[AC_LANG_SOURCE([[#if defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) )
284
#elif defined( __sun )
285
/* Solaris intrinsic */
286
#elif defined( __APPLE__ )
287
/* Darwin intrinsic */
288
#elif defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 401 )
289
/* GCC 4.0.1 intrinsic */
290
#elif defined( _WIN32 )
291
/* Windows intrinsic */
293
# error "Unsupported atomic ops."
295
[AC_MSG_RESULT([yes])
296
if test "$pgm_unaligned_pointers" = yes; then
297
CFLAGS="$CFLAGS -DCONFIG_TICKET_SPINLOCK -DCONFIG_DUMB_RWSPINLOCK"
299
CFLAGS="$CFLAGS -DCONFIG_TICKET_SPINLOCK"
301
[AC_MSG_RESULT([no])])
303
AC_CONFIG_FILES([Makefile "openpgm-${RELEASE_INFO}.pc"])