-
Notifications
You must be signed in to change notification settings - Fork 64
/
configure.in
243 lines (196 loc) · 5.73 KB
/
configure.in
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
dnl $Id: configure.in,v 1.22 2004/02/13 06:14:01 marius Exp $
AC_INIT([trickle], [1.07])
AC_CONFIG_SRCDIR([trickle.c])
AC_CANONICAL_SYSTEM
dnl AC_LIBTOOL_DLOPEN
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(config.h)
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_CC
AM_PROG_LIBTOOL
AC_PROG_MAKE_SET
dnl intitialization
if test "x$prefix" = "xNONE"; then
prefix="/usr/local"
fi
dnl Checks for programs.
AC_PROG_RANLIB
AC_PROG_INSTALL
dnl Platform specific stuff
case "$host" in
*-*-hpux*)
AC_DEFINE(SPT_TYPE,SPT_PSTAT)
LIBS="$LIBS -lxnet -lsec"
;;
esac
dnl Checks for standard libraries.
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_LIB(dl, dlopen, [ LIBDL="-ldl"
LIBS="$LIBS -ldl" ],,)
AC_SUBST(LIBDL)
dnl ugly ugly hack
AC_CHECK_LIB(c, err, [ ERRO="" ], [ ERRO="err.o" ],)
AC_SUBST(ERRO)
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
dnl Checks for pthread
threadsafe="yes"
AC_ARG_ENABLE([threadsafe],
[AC_HELP_STRING([--disable-threadsafe],[disable trickle thread safety (default enabled)])],
[threadsafe=$enableval]
)
if test "x$threadsafe" = xyes; then
AX_PTHREAD([AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],
[AC_MSG_ERROR(cannot find pthread. use configure script option --disable-threadsafe to compile trickle without thread safety)])
fi
dnl Check for __progname; from OpenSSHp
AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
AC_TRY_LINK([],
[ extern char *__progname; printf("%s", __progname); ],
[ ac_cv_libc_defines___progname="yes" ],
[ ac_cv_libc_defines___progname="no" ]
)
])
if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
AC_DEFINE(HAVE___PROGNAME)
fi
AC_CHECK_HEADERS(sys/ioctl.h sys/time.h err.h time.h unistd.h stdint.h netinet/in.h asm/poll.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_CHECK_TYPE(u_int64_t, unsigned long long)
AC_CHECK_TYPE(u_int32_t, unsigned int)
AC_CHECK_TYPE(u_int16_t, unsigned short)
AC_CHECK_TYPE(u_int8_t, unsigned char)
AC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t],[unsigned long],[])], [#include <netinet/in.h>])
dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(socket)
AC_REPLACE_FUNCS(strlcat strlcpy daemon setenv strsep)
dnl XXX
AC_CHECK_FUNCS(sendfile)
dnl Checks for libevent
AC_MSG_CHECKING(for libevent)
AC_ARG_WITH(libevent,
[ --with-libevent=DIR use libevent in DIR],
[ case "$withval" in
yes|no)
AC_MSG_RESULT(no)
;;
*)
AC_MSG_RESULT($withval)
if test -f $withval/include/event.h -a -f $withval/lib/libevent.a; then
owd=`pwd`
if cd $withval; then withval=`pwd`; cd $owd; fi
EVENTINC="-I$withval/include"
EVENTLIB="-L$withval/lib -levent"
elif test -f $withval/event.h -a -f $withval/libevent.a; then
owd=`pwd`
if cd $withval; then withval=`pwd`; cd $owd; fi
EVENTINC="-I$withval"
EVENTLIB="-L$withval -levent"
else
AC_ERROR(event.h or libevent.a not found in $withval)
fi
;;
esac ],
[ if test -f ${prefix}/include/event.h -a -f ${prefix}/lib/libevent.a;
then
EVENTINC="-I${prefix}/include"
EVENTLIB="-L${prefix}/lib -levent"
elif test -f /usr/include/event.h; then
EVENTLIB="-levent"
else
AC_MSG_RESULT(no)
AC_ERROR(libevent not found)
fi
AC_MSG_RESULT(yes) ]
)
AC_SUBST(EVENTINC)
AC_SUBST(EVENTLIB)
dnl check if underscores are needed
AC_MSG_CHECKING(if underscores are needed for symbols)
AC_TRY_RUN(
#include <dlfcn.h>
#include <stdio.h>
int underscoreprobe(void) { return (31415); }
int
main(int argc, char **argv)
{
void *dh;
if ((dh = dlopen(NULL, 0)) == NULL)
exit(1);
if (dlsym(dh, "_underscoreprobe") != NULL)
exit(0);
exit(1);
}, [AC_MSG_RESULT(yes)
AC_DEFINE(DL_NEED_UNDERSCORE)], AC_MSG_RESULT(no), AC_MSG_RESULT(no))
HAVEMETHOD=no
AC_MSG_CHECKING(if we can access libc without dlopen)
AC_TRY_RUN(
#include <dlfcn.h>
#include <stdio.h>
int
main(int argc, char **argv)
{
void *dh;
dh = (void *)-1L;
if (dlsym(dh, "printf") != NULL || dlsym(dh, "_printf") != NULL)
exit(0);
exit(1);
}, [AC_MSG_RESULT(yes)
AC_DEFINE(NODLOPEN)
HAVEMETHOD=yes], AC_MSG_RESULT(no), AC_MSG_RESULT(no))
if test "$HAVEMETHOD" = "no"; then
dnl ugly, ugly hack
LIBCGUESS=`echo /lib/libc.so.*`
USRLIBCGUESS=`echo /usr/lib/libc.so*`
if test "$USRLIBCGUESS" = "/usr/lib/libc.so.*"; then
USRLIBCGUESS=""
fi
if test "$LIBCGUESS" = "/lib/libc.so.*"; then
LIBCGUESS=""
fi
for TESTLIB in libc.so `echo $USRLIBCGUESS` `echo $LIBCGUESS`
do
AC_MSG_CHECKING(if we can access libc with $TESTLIB)
AC_TRY_RUN(
#include <dlfcn.h>
#include <stdio.h>
int
main(int argc, char **argv)
{
void *dh;
if (dlopen("$TESTLIB", RTLD_LAZY) != NULL)
exit(0);
exit(1);
}, [AC_MSG_RESULT(yes)
AC_DEFINE_UNQUOTED(DLOPENLIBC, "$TESTLIB")
HAVEMETHOD=yes], AC_MSG_RESULT(no), AC_MSG_RESULT(no))
if test "$HAVEMETHOD" = "yes"; then
break
fi
done
fi
if test "$HAVEMETHOD" = "no"; then
AC_MSG_ERROR(cannot figure out how to access libc)
fi
if test "x$sysconfdir" = "x$prefix/etc"; then
csysconfdir="$prefix/etc"
else
csysconfdir="$sysconfdir"
fi
clibdir="$prefix/lib/trickle"
AC_DEFINE_UNQUOTED(SYSCONFDIR, "$csysconfdir")
AC_DEFINE_UNQUOTED(LIBDIR, "$clibdir")
havesendfile=no
AC_CHECK_FUNCS(sendfile, [havesendfile=yes], )
if test "$havesendfile" = "yes"; then
AC_DEFINE(HAVE_SENDFILE, 1, [Define if your system has the sendfile system call])
fi
AC_OUTPUT(Makefile)