aboutsummaryrefslogtreecommitdiffstats
path: root/configure.in
blob: 9299100ad381d2d0f4c99d583de0369149795cfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
AC_PREREQ(2.12)
AC_COPYRIGHT(test)

rm -f config.cache

AC_INIT(acconfig.h)

AC_CANONICAL_SYSTEM
AC_ARG_PROGRAM

AM_INIT_AUTOMAKE(sualibrary,0.1.2)

AC_PREFIX_DEFAULT(/usr/local)
if test "x$prefix" = "xNONE"; then
  prefix=$ac_default_prefix
  ac_configure_args="$ac_configure_args --prefix $prefix"
fi

# keep this order because automake gets confused apart from the authors
AM_CONFIG_HEADER(config.h:config.h.in)

# Checks for programs.
AC_PROG_AWK
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_CXX
AC_PROG_RANLIB


# Checks for libraries.
# create only shared libtool-libraries (add --enable-shared)
AC_ENABLE_SHARED(no)
# AM_DISABLE_SHARED

# set the following to yes, if you want to create static
# libtool-libraries, else no
AC_ENABLE_STATIC(yes)

# create a working libtool-script
if test -z "$LIBTOOL"; then
  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  AC_LIBTOOL_DLOPEN
  AM_PROG_LIBTOOL
  # LIBTOOL="$LIBTOOL --silent"
  # AC_SUBST(LIBTOOL)
  AC_LANG_RESTORE
  LIBTOOL_SHELL='/bin/sh ./libtool'
else
  LIBTOOL_SHELL=$LIBTOOL
fi


# activate the following for some additional tests
#   (compat, crypt, socket, nsl, ...)

all_libraries="$USER_LDFLAGS $all_libraries"
all_includes="$all_includes $USER_INCLUDES"
AC_SUBST(all_includes)
AC_SUBST(all_libraries)
AC_SUBST(AUTODIRS)

# Checks for header files.

AC_HEADER_STDC
AC_HEADER_TIME
AC_CHECK_HEADERS(strings.h sys/file.h sys/time.h unistd.h netinet/in.h netdb.h \
sys/socket.h netinet/icmp6.h)
AC_CHECK_HEADERS(sys/poll.h, AC_DEFINE(HAVE_SYS_POLL_H))


# Checks for typedefs, structures, and compiler characteristics.

# ----------------------
# Packages configuration - Blatantly stolen from zebra !
# ----------------------
AC_ARG_ENABLE(ipv6,
[  --disable-ipv6          turn off IPv6 support ])

# ----------
# IPv6 check
# ----------
AC_MSG_CHECKING(whether this OS does have IPv6 stack)
if test "${enable_ipv6}" = "no"; then
	  AC_MSG_RESULT(disabled)
else
# ----------
# INRIA IPv6
# ----------
if grep IPV6_INRIA_VERSION /usr/include/netinet/in.h >/dev/null 2>&1; then
	cv_ipv6=yes
	AC_DEFINE(HAVE_IPV6)
	AC_DEFINE(INRIA_IPV6)
	LIB_IPV6=""
	AC_MSG_RESULT(INRIA IPv6)
fi
# ---------
# KAME IPv6
# ---------
if grep WIDE /usr/include/netinet6/in6.h >/dev/null 2>&1; then
	cv_ipv6=yes
	AC_DEFINE(HAVE_IPV6)
	AC_DEFINE(KAME)
	if test -d /usr/local/v6/lib -a -f /usr/local/v6/lib/libinet6.a; then
    	LIB_IPV6="-L/usr/local/v6/lib -linet6"
    fi
    AC_MSG_RESULT(KAME)
fi
# ---------
# NRL check
# ---------
if grep NRL /usr/include/netinet6/in6.h >/dev/null 2>&1; then
   cv_ipv6=yes
   AC_DEFINE(HAVE_IPV6)
   AC_DEFINE(NRL)
   if test x"$opsys" = x"bsdi";then
	   AC_DEFINE(BSDI_NRL)
       AC_MSG_RESULT(BSDI_NRL)
   else
       AC_MSG_RESULT(NRL)
   fi
fi
# ----------
# Linux IPv6
# ----------
if test "${enable_ipv6}" = "yes"; then
   AC_EGREP_CPP(yes, [#
   #include <linux/version.h>
   /* 2.1.128 or later */
   #if LINUX_VERSION_CODE >= 0x020180
   yes
   #endif],
   [cv_ipv6=yes; cv_linux_ipv6=yes;AC_MSG_RESULT(Linux IPv6)])
else
if test x`ls /proc/net/ipv6_route 2>/dev/null` = x"/proc/net/ipv6_route"
   	then
	    cv_ipv6=yes
		cv_linux_ipv6=yes
	    AC_MSG_RESULT(Linux IPv6)
	fi
fi
if test "$cv_linux_ipv6" = "yes";then
   	AC_DEFINE(HAVE_IPV6)
   	AC_MSG_CHECKING(for GNU libc 2.1)
   	AC_EGREP_CPP(yes, [
#include <features.h>
#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
	yes
#endif], [glibc=yes; AC_MSG_RESULT(yes)], AC_MSG_RESULT(no))
    AC_DEFINE(LINUX_IPV6)
	if test "$glibc" != "yes"; then
		INCLUDES="-I/usr/inet6/include"
	    if test x`ls /usr/inet6/lib/libinet6.a 2>/dev/null` != x;then
	        LIB_IPV6="-L/usr/inet6/lib -linet6"
        fi
   fi
fi

fi

# -----------------------
# Set IPv6 related values
# -----------------------
LIBS="$LIB_IPV6 $LIBS"
AC_SUBST(LIB_IPV6)

# -----------------------------------
# check sin6_scope_id of sockaddr_in6
# -----------------------------------
if test "$cv_ipv6" = yes; then
	AC_MSG_CHECKING(whether struct sockaddr_in6 has a sin6_scope_id field)
	AC_TRY_COMPILE([#include <sys/types.h>
#include <netinet/in.h>
],[static struct sockaddr_in6 ac_i;int ac_j = sizeof(ac_i.sin6_scope_id);],
[AC_MSG_RESULT(yes)
 AC_DEFINE(HAVE_SIN6_SCOPE_ID)],
 AC_MSG_RESULT(no))
fi
	
# -----------------------------------
# Check for New Socket API (RFC2292BIS)
# -----------------------------------
AC_MSG_CHECKING(for rfc2292bis support)
AC_TRY_COMPILE([#include <sys/types.h>
#include <netinet/in.h>],
         [int x = IPV6_RECVPKTINFO;],
         [AC_DEFINE(USE_RFC2292BIS)
          AC_MSG_RESULT(yes)],
         [AC_MSG_RESULT(no)])


AC_MSG_CHECKING(for struct in_pktinfo)
AC_TRY_COMPILE([#include <sys/types.h>
#include <netinet/in.h>],
         [struct in_pktinfo x; x.ipi_ifindex = 0;],
         [AC_DEFINE(HAVE_PKTINFO)
          AC_MSG_RESULT(yes)],
         [AC_MSG_RESULT(no)])

# This is taken from the ethereal configuration scripts.
# We check whether user wants to build gtk-based programs
# These need to be enabled explicitly
GTK_OK=yes

# GTK checks
# We don't add $GLIB_LIBS to LIBS, because we don't want to force all
# programs to be built with GTK+.
#

AM_PATH_GTK(1.2.0, CFLAGS="$CFLAGS $GTK_CFLAGS", GTK_OK=no)
if  test "x$GTK_OK" = "xno" ; then
    AC_MSG_RESULT(GTK distribution not found - disabling sctpd compilation.)
    AC_MSG_RESULT(On FreeBSD, you might want to do: ln -s gtk12-config gtk-config)
fi

# GLib checks
# This doesn't add GLIB_CFLAGS to CFLAGS, because AM_PATH_GTK will add
# GTK_CFLAGS to CFLAGS, and GTK_CFLAGS is a superset of CFLAGS.
# However, this means that both @GLIB_LIBS@ and @GTK_LIBS@ will be
# set when generating the Makefile, so we can make programs that require
# only GLib link with @GLIB_LIBS@ and make programs that require GTK+
# link with @GTK_LIBS@ (which includes @GLIB_LIBS@).
# We don't add $GLIB_LIBS to LIBS, because we don't want to force all
# programs to be built with GLib.
#

enable_sctpd="no"
# gtkprogs_bin=""
sctpd_SUBDIRS=""
# Honor GLIB_CFLAGS
AM_PATH_GLIB(1.2.0, CFLAGS="$CFLAGS $GLIB_CFLAGS", AC_MSG_ERROR(GLib distribution not found. On FreeBSD do: ln -s glib12-config glib-config), gmodule)


#AC_SUBST(gtkprogs_bin)
AC_SUBST(sctp_SUBDIRS)


# Checks for library functions.
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_LIB(sctp, sctp_eventloop)

# removed libefence....this should be used though, when we REALLY debug :-)
AC_CHECK_LIB(efence, malloc)
AC_CHECK_LIB(glib, g_main_add_poll)


AC_CHECK_HEADERS(ncurses.h, AC_DEFINE(HAVE_NCURSES_H))
# AC_CHECK_HEADERS(curses.h, AC_DEFINE(HAVE_CURSES_H))
AC_CHECK_LIB(ncurses, initscr, found_ncurses_lib=yes,found_ncurses_lib=no)

if test "x$found_ncurses_lib" = "xyes" -a "x$ac_cv_header_ncurses_h" = "xyes" ; then
    curses_LIBS="-lncurses"
    # CPPFLAGS="$CPPFLAGS -I/usr/include/ncurses.h"
    cursesprogs_BIN="monitor chat echo_monitor"
else
#    AC_CHECK_LIB(curses, initscr, found_curses_lib=yes,found_curses_lib=no)
#    if test "x$found_curses_lib" = "xyes" -a "x$ac_cv_header_curses_h" = "xyes" ; then
#        curses_LIBS="-lcurses"
        # CPPFLAGS="$CPPFLAGS -I/usr/include/curses.h"
#        cursesprogs_BIN="monitor chat echo_monitor"
#    else
        cursesprogs_BIN=""
        curses_LIBS=""
        AC_MSG_WARN(nCurses libraries seem to be missing. Not compiling Curses-Programs! Please contact ajung@exp-math.uni-essen.de in case this test should not have failed!)
#    fi
fi
AC_SUBST(cursesprogs_BIN)
AC_SUBST(curses_LIBS)

if test "$GTK_OK" = "yes" ; then
	sctp_LIBS="-L/usr/local/lib/ -lsctp"
	gtk_LIBS="$GTK_LIBS"
	glib_LIBS="$GLIB_LIBS"
else
	sctp_LIBS="-L/usr/local/lib/ -lsctp"
	gtk_LIBS=""
	glib_LIBS="$GLIB_LIBS"
fi

AC_SUBST(sctp_LIBS)
AC_SUBST(gtk_LIBS)
AC_SUBST(glib_LIBS)

AC_CHECK_LIB(c, inet_ntop, [AC_DEFINE(HAVE_INET_NTOP)])
AC_CHECK_LIB(c, inet_pton, [AC_DEFINE(HAVE_INET_PTON)])
AC_CHECK_LIB(c, inet_aton, [AC_DEFINE(HAVE_INET_ATON)])

# Checks for library functions.
AC_FUNC_VPRINTF
AC_FUNC_MEMCMP
AC_CHECK_FUNCS(gettimeofday socket strerror poll getuid setuid geteuid random)
AC_CHECK_FUNCS(getaddrinfo, [have_getaddrinfo=yes], [have_getaddrinfo=no])


# checks for host/build/target system type
AC_CANONICAL_HOST
case $host_os in
bsdi*)
	CFLAGS="$CFLAGS -DBSDI"
    thread_LIBS="-lpthread"
	# CFLAGS="$CFLAGS `glib-config --cflags`"
	#LDFLAGS="$LDFLAGS `glib-config --libs`"
	;;
freebsd*)
    CFLAGS="$CFLAGS -DFreeBSD -Wall -pthread"
    CXXFLAGS="$CXXFLAGS -DFreeBSD -Wall -pthread"
    thread_LIBS=""
    # CFLAGS="$CFLAGS `glib12-config --cflags`"
    #LDFLAGS="$LDFLAGS `glib12-config --libs`"
    ;;
hpux*)
    CFLAGS="$CFLAGS -DSNAKE"
    test -z "$GCC" && TRY_CFLAGS="$TRY_CFLAGS -Wp,-H600000"
    thread_LIBS="-lpthread"
    # CFLAGS="$CFLAGS `glib-config --cflags`"
    #LDFLAGS="$LDFLAGS `glib-config --libs`"
	;;
linux*)
    CFLAGS="$CFLAGS -Wall -DLINUX "
    CXXFLAGS="$CXXFLAGS -Wall -DLINUX "
    thread_LIBS="-lpthread"
    # CFLAGS="$CFLAGS `glib-config --cflags`"
    #LDFLAGS="`glib-config --libs` $LDFLAGS"
    ;;
openbsd*)
    LIBS="$LIBS -lcompat"
    thread_LIBS="-lpthread"
    # CFLAGS="$CFLAGS `glib-config --cflags`"
    #LDFLAGS="$LDFLAGS `glib-config --libs`"
    ;;
solaris*)
    CFLAGS="$CFLAGS -Wall -DSOLARIS -D__sun -DSUN -DSUNOS_5"
    CXXFLAGS="$CXXFLAGS -Wall -DSOLARIS -D__sun -DSUN -DSUNOS_5"
    thread_LIBS="-lpthread"
    LDFLAGS="$LDFLAGS -lsocket -lnsl -lrt -lresolv"
    # CFLAGS="$CFLAGS `glib-config --cflags`"
    # LDFLAGS="$LDFLAGS `glib-config --libs`"
    ;;
sunos4*)
    CFLAGS="$CFLAGS -DSUN -DSUN4"
    thread_LIBS="-lpthread"
    # CFLAGS="$CFLAGS `glib-config --cflags`"
    # LDFLAGS="$LDFLAGS `glib-config --libs`"
    ;;
darwin*)
    CFLAGS="$CFLAGS -DDARWIN"
    CXXFLAGS="$CXXFLAGS -DDARWIN"
    thread_LIBS="-lpthread"
    # CFLAGS="$CFLAGS `glib-config --cflags`"
    # LDFLAGS="$LDFLAGS `glib-config --libs`"
    ;;
esac
AC_SUBST(thread_LIBS)



# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_STRUCT_TM
AC_CHECK_SIZEOF(char, 1)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(long long, 8)				

AC_MSG_CHECKING(for type socklen_t)
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <netinet/in.h>],
[socklen_t x; x = 0;],
[AC_DEFINE(HAVE_SOCKLEN_T)
 AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])




# add here all your Makefiles. These will be created by configure
AC_OUTPUT(Makefile sualibrary/Makefile sualibrary/docs/Makefile sualibrary/docs/en/Makefile sualibrary/sua/Makefile sualibrary/testup/Makefile )