forked from JoeDog/siege
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
466 lines (421 loc) · 12.2 KB
/
configure.ac
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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
dnl REQUIRE AUTOCONF 2.50 OR HIGHER...
AC_PREREQ(2.50)
dnl
dnl Process this file with autoconf to produce a configure script.
dnl
AC_INIT
AC_CONFIG_SRCDIR([src/setup.h])
AC_CONFIG_HEADERS(include/config.h)
dnl
dnl Define the utils directory
dnl
AC_CONFIG_AUX_DIR(utils)
dnl VERSION=`sed -e 's/^.*"\(.*\)";$/\1/' ${srcdir}/src/version.c`
VERSION=`sed -ne 's/.*version_string.*"\(.*\)"\;/\1/p' ${srcdir}/src/version.c`
PROGRAM=`sed -ne 's/.*program_name.*"\(.*\)"\;/\1/p' ${srcdir}/src/version.c`
AUTHOR=`sed -ne 's/.*author_name.*"\(.*\)"\;/\1/p' ${srcdir}/src/version.c`
EMAIL=`sed -ne 's/.*email_address.*"\(.*\)"\;/\1/p' ${srcdir}/src/version.c`
AM_INIT_AUTOMAKE($PROGRAM, $VERSION)
DATE=`${CONFIG_SHELL} ${srcdir}/utils/mkstamp`
AC_SUBST(DATE)
AC_SUBST(PROGRAM)
AC_SUBST(AUTHOR)
AC_SUBST(EMAIL)
dnl
dnl canonicalize the host
dnl
AC_CANONICAL_HOST
PLATFORM="${host_vendor}-${host_cpu}-${host_os}"
AC_SUBST(PLATFORM)
dnl Check for AIX weirdos
AC_AIX
dnl Checks for programs.
AC_PROG_CC
AM_PROG_LIBTOOL
dnl
dnl Program support
dnl
AC_PATH_PROG( PERL, perl, false )
AC_PROG_SHELL
AC_PROG_MAKE_SET
AC_PROG_INSTALL
case "$host_os" in
*aix*)
if test -n "${CC}" ; then
AC_CHECK_PROGS(CC_R, xlc_r cc_r cc)
if test "$CC_R" = cc ; then
AC_MSG_ERROR([pthread support requires cc_r (or other suitable compiler) on AIX])
else
CC=$CC_R
AC_SUBST(CC)
fi
fi
;;
esac
if test -n "$GCC"; then
oldCFLAGS=$CFLAGS
CFLAGS="$CFLAGS -W -Wall -Werror -Wunused-value"
AC_MSG_CHECKING(for buggy pthread mutex initializers)
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([#include <pthread.h>],
[pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_lock(&m); ])],
[buggy_init="no"], [buggy_init="yes"])
if test $buggy_init = "no" ; then
WARN_CFLAGS="-W -Wall -Wunused-value"
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes)
WARN_CFLAGS="-W -Wall -Wno-missing-braces -Wunused-value"
fi
fi
CFLAGS=$oldCFLAGS
AC_SUBST(WARN_CFLAGS)
AC_MSG_CHECKING([for dlopen() in -ldld])
olibs=$LIBS
LIBS="$LIBS -ldld"
AC_TRY_LINK(,
[ extern void* dlopen(); dlopen(); ],
AC_MSG_RESULT(yes);
LIBS=$olibs;
LDL=-ldld
AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
AC_MSG_RESULT(no);
LDL=
LIBS=$olibs)
AC_MSG_CHECKING([for dlopen() in -ldl])
olibs=$LIBS
LIBS="$LIBS -ldl"
AC_TRY_LINK(,
[ extern void* dlopen(); dlopen(); ],
AC_MSG_RESULT(yes);
LIBS=$olibs;
LDL=-ldl,
AC_MSG_RESULT(no);
LDL=
LIBS=$olibs)
AC_SUBST(LDL)
dnl
dnl check for random device
dnl
AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
[if test -r "/dev/random" && test -r "/dev/urandom" ; then
ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
if test "$ac_cv_have_dev_random" = yes; then
AC_DEFINE([HAVE_DEV_RANDOM], 1, [Discovered a random device])
fi
dnl
dnl with SSL support
dnl
MYSSL=off
sslfound=locate
SSL_INCLUDE=
SSL_LDFLAGS=
SSL_LIBS=
AC_ARG_WITH(ssl,dnl
[ --with-ssl=ARG where ARG is the ssl directory or "no" ],
[ MYSSL="$withval" ])
AC_ARG_WITH(nossl,dnl
[ --without-ssl do NOT use SSL (same as --with-ssl=no) ],
[ MYSSL="no" ])
if test "$MYSSL" = "no"
then
AC_MSG_RESULT(checking for ssl support... no)
else
AC_MSG_RESULT(checking for ssl support... yes)
fi
dnl
dnl Check for ssl libraries
dnl
if test "$MYSSL" = "no"
then
AC_MSG_RESULT(HTTPS/ssl support disabled)
else
AC_CHECK_HEADERS($MYSSL/include/openssl/opensslv.h, sslfound=yes, sslfound=locate)
if test $sslfound = "locate"; then
dnl the user probably misunderstood the option....
for dir in /usr /usr/local /usr/local/ssl /usr/pkg /usr/lib/ssl /usr/include/ssl /usr/include; do
AC_CHECK_HEADERS($dir/include/openssl/opensslv.h, sslfound=yes, sslfound=no)
if test $sslfound = "yes" ; then
SSL_CFLAGS="-DOPENSSL_NO_KRB5"
SSL_LDFLAGS="-L$dir/lib"
SSL_INCLUDE="-I$dir/include/openssl -I$dir/include"
SSL_LIBS="-lssl -lcrypto"
AC_MSG_CHECKING([for OpenSSL version])
CPPFLAGS="$SSL_INCLUDE"
AC_EGREP_CPP(yes,[
#include <openssl/opensslv.h>
#if OPENSSL_VERSION_NUMBER >= 0x0090800fL
yes
#endif
],[
SSL_LIBS="$LDL $SSL_LIBS"
AC_MSG_RESULT([>= 0.9.8 (appropriate flag set)])
],[
AC_MSG_RESULT([< 0.9.8])
])
AC_SUBST(SSL_CFLAGS)
AC_SUBST(SSL_INCLUDE)
AC_SUBST(SSL_LDFLAGS)
AC_SUBST(SSL_LIBS)
AC_DEFINE([HAVE_SSL], 1, [Discovered OpenSSL library for HTTPS])
break
fi
done
else
echo "found ssl in $MYSSL"
SSL_CFLAGS="-DOPENSSL_NO_KRB5"
SSL_LDFLAGS="-L$MYSSL/lib"
SSL_INCLUDE="-I$MYSSL/include/openssl -I$MYSSL/include"
SSL_LIBS="-lssl -lcrypto"
AC_MSG_CHECKING([for OpenSSL version])
CPPFLAGS="$SSL_INCLUDE"
AC_EGREP_CPP(yes,[
#include <openssl/opensslv.h>
#if OPENSSL_VERSION_NUMBER >= 0x0090800fL
yes
#endif
],[
SSL_LIBS="$LDL $SSL_LIBS"
AC_MSG_RESULT([>= 0.9.8 (appropriate flag set)])
],[
AC_MSG_RESULT([< 0.9.8])
])
AC_SUBST(SSL_CFLAGS)
AC_SUBST(SSL_INCLUDE)
AC_SUBST(SSL_LDFLAGS)
AC_SUBST(SSL_LIBS)
AC_DEFINE(HAVE_SSL)
fi
fi
AC_C_INLINE
AC_CHECK_TYPE(int8_t, char)
AC_CHECK_TYPE(int16_t, short)
AC_CHECK_TYPE(int32_t, int)
AC_CHECK_TYPE(int64_t, long long)
AC_CHECK_TYPE(uint8_t, unsigned char)
AC_CHECK_TYPE(uint16_t, unsigned short)
AC_CHECK_TYPE(uint32_t, unsigned int)
AC_CHECK_TYPE(uint64_t, unsigned long long)
AC_CHECK_TYPE(u_int32_t,unsigned int)
AC_CHECK_TYPE(ssize_t, int)
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h)
AC_CHECK_HEADERS(limits.h)
AC_CHECK_HEADERS(unistd.h)
AC_CHECK_HEADERS(signal.h)
AC_CHECK_HEADERS(sys/socket.h)
AC_CHECK_HEADERS(sys/select.h)
AC_CHECK_HEADERS(sys/time.h sys/times.h)
AC_CHECK_HEADERS(sys/resource.h)
AC_CHECK_HEADERS(errno.h)
AC_CHECK_HEADERS(arpa/inet.h)
AC_CHECK_HEADERS(netinet/in.h)
AC_CHECK_HEADERS(netdb.h)
AC_CHECK_HEADERS(pthread.h)
AC_CHECK_HEADERS(string.h)
AC_CHECK_HEADERS(strings.h)
AC_CHECK_HEADERS(sched.h)
AC_CHECK_HEADERS(openssl/e_os.h)
AC_CHECK_HEADERS(openssl/e_os2.h)
dnl
dnl Checks for typedefs, structures, and compiler characteristics.
dnl
AC_C_CONST
AC_TYPE_SIZE_T
AC_HEADER_TIME
dnl
dnl Return type of signal-handlers
dnl
AC_TYPE_SIGNAL
dnl
dnl Checks for library functions.
dnl
AC_FUNC_ALLOCA
AC_CHECK_FUNCS(strchr memcpy strncpy strstr strlen)
AC_CHECK_FUNCS(strncasecmp strncmp)
AC_CHECK_FUNCS(socket, , AC_CHECK_LIB(socket, socket))
AC_CHECK_FUNCS(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))
AC_CHECK_FUNCS(snprintf)
AC_CHECK_FUNCS(strdup)
AC_CHECK_FUNCS(rand_r)
AC_CHECK_FUNCS(localtime_r)
AC_CHECK_FUNCS(getipnodebyname)
AC_CHECK_FUNCS(freehostent)
AC_CHECK_FUNCS(getopt_long)
AC_CHECK_FUNCS(poll)
dnl
dnl Check for socket library
dnl
AC_CHECK_LIB(socket, socket)
dnl
dnl Check for pthread support
dnl
PTHREAD_CFLAGS=error
PTHREAD_LDFLAGS=error
dnl If it's error, then the user didn't
dnl define it.
if test "x$PTHREAD_LDFLAGS" = xerror; then
AC_CHECK_LIB(pthread, pthread_attr_init, [
PTHREAD_CFLAGS="-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
PTHREAD_LDFLAGS="-lpthread" ])
fi
if test "x$PTHREAD_LDFLAGS" = xerror; then
AC_CHECK_LIB(pthreads, pthread_attr_init, [
PTHREAD_CFLAGS="-D_THREAD_SAFE"
PTHREAD_LDFLAGS="-lpthreads" ])
fi
if test "x$PTHREAD_LDFLAGS" = xerror; then
AC_CHECK_LIB(c_r, pthread_attr_init, [
PTHREAD_CFLAGS="-D_THREAD_SAFE -pthread"
PTHREAD_LDFLAGS="-pthread" ])
fi
if test "x$PTHREAD_LDFLAGS" = xerror; then
AC_CHECK_FUNC(pthread_attr_init, [
PTHREAD_CFLAGS="-D_REENTRANT"
PTHREAD_LDFLAGS="-lpthread" ])
fi
if test $PTHREAD_LDFLAGS = "error"; then
AC_MSG_WARN(pthread library NOT found: guessing and hoping for the best....)
PTHREAD_CFLAGS="-D_REENTRANT"
PTHREAD_LDFLAGS="-lpthread"
fi
AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_LDFLAGS)
dnl
dnl On some platforms, notably Solaris, these
dnl variables are assigned literally by the user
dnl and not implied. (don't know why...)
case "$host_os" in
*solaris*)
if test -z "$ac_given_sysconfdir" ;
then
sysconfdir="$prefix/etc"
fi
if test -z "$ac_given_localstatedir" ;
then
localstatedir="$prefix/var"
fi
;;
*) ;;
esac
dnl
dnl Create <joedog/joepath.h> header file
dnl
AC_OUTPUT_COMMANDS([
outfile=include/joedog/joepath.h
tmpfile=${outfile}
cat > $tmpfile << _EOF_
/**
* Path Header
*
* Copyright (C) 2000-2013 by
* Jeffrey Fulmer - <[email protected]>, et al.
* This file is distributed as part of Siege
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef JOEPATH_H
#define JOEPATH_H
#define SIEGE_HOME "$prefix"
#define URL_FILE "$sysconfdir/urls.txt"
#define CNF_FILE "$sysconfdir/siegerc"
#define LOG_FILE "$localstatedir/siege.log"
#define PLATFORM "$platform"
#endif/*JOEPATH_H*/
_EOF_
], [ prefix=$prefix sysconfdir=$sysconfdir localstatedir=$localstatedir platform=$PLATFORM ])
echo "PLATFORM: $PLATFORM"
dnl
dnl update dates and versioning in doc
dnl
AC_OUTPUT_COMMANDS([
for file in doc/bombardment.1 doc/layingsiege.7 doc/siege.1 doc/siege.config.1 \
doc/siege2csv.1 doc/siegerc doc/urls_txt.5;
do
rm -f $file
sed -e "s|%_VERSION%|$VERSION|" \
-e "s|%_PROGRAM%|$PROGRAM|" \
-e "s|%_DATE%|$DATE|" \
-e "s|%_AUTHOR%|$AUTHOR|" \
-e "s|%_EMAIL%|$EMAIL|" \
< $file.in > $file
done
], [ VERSION=$VERSION DATE="$DATE" PROGRAM="$PROGRAM" AUTHOR="$AUTHOR" EMAIL="$EMAIL" ])
dnl
dnl create siege.config utility
dnl
AC_OUTPUT_COMMANDS([
infile=utils/siege.config.in
outfile=utils/siege.config
rm -f $outfile
sed -e "s|%_PREFIX%|$bindir|" \
-e "s|%_SHELL%|$sh|" \
< $infile > $outfile
cat doc/siegerc >> $outfile
echo "_EOF_" >> $outfile
echo "echo \"New configuration template added to \$rcfile\"" >> $outfile
echo "echo \"Run siege -C to view the current settings in that file\"" >> $outfile
echo "exit" >> $outfile
echo "" >> $outfile
], [ bindir=$exec_prefix$bindir sh=$SHELL ])
dnl
dnl create bombardment utility
dnl
AC_OUTPUT_COMMANDS([
infile=utils/bombardment.in
outfile=utils/bombardment
rm -f $outfile
sed -e "s|%_PREFIX%|$bindir|" \
-e "s|%_SHELL%|$sh|" \
< $infile > $outfile
], [ bindir=$exec_prefix$bindir sh=$SHELL ])
dnl
dnl create siege2csv utility
dnl
AC_OUTPUT_COMMANDS([
infile=utils/siege2csv.in
outfile=utils/siege2csv.pl
rm -f $outfile
sed -e "s|%_PREFIX%|$bindir|" \
-e "s|%_PERL%|$LREP|" \
< $infile > $outfile
], [ bindir=$exec_prefix$bindir LREP=$PERL ])
dnl
dnl Write platform to file for support reporting
dnl
AC_OUTPUT_COMMANDS([
outfile=PLATFORM
tmpfile=${outfile}
cat > $tmpfile << _EOF_
$PLATFORM
_EOF_
], [PLATFORM=$PLATFORM])
AC_OUTPUT(Makefile src/Makefile doc/Makefile html/Makefile lib/Makefile lib/joedog/Makefile include/Makefile include/joedog/Makefile utils/Makefile)
echo
echo "--------------------------------------------------------"
echo "Configuration is complete"
echo
echo "Run the following commands to complete the installation:"
echo " make "
echo " make install"
echo
echo "To upgrade an old siegerc file (optional): "
echo " mv ~/.siegerc.new ~/.siegerc"
echo
echo "For complete documentation: http://www.joedog.org"
echo "--------------------------------------------------------"