forked from code4craft/pdnsd
-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathconfigure.in
548 lines (481 loc) · 14.1 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
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
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
dnl Process this file with autoconf to produce a configure script.
AC_INIT(src)
package="pdnsd"
version=`cut -d - -f 1 "$srcdir"/version`
fullversion=`cat "$srcdir"/version`
packagerelease=`cut -d - -f 2- "$srcdir"/version`
distribution="Generic"
target="autodetect"
cachedir="/var/cache/$package"
ipv4_default=1
have_ipv4="yes"
#newrrs="yes"
query_m="udponly"
have_tcp_server="yes"
adisc="default"
slock="no";
def_id="nobody"
#have_rcsids="no"
udp_queries="yes"
tcp_queries="yes"
tempdir="/tmp"
randomdev=default
freebsd_pthread="4"
specbuild=no
threadlib=default
AM_INIT_AUTOMAKE($package, $version, [no-define])
AM_CONFIG_HEADER(config.h)
AC_GNU_SOURCE
AC_DEFINE_UNQUOTED(VERSION,"$fullversion")
AC_SUBST(fullversion)
AC_SUBST(packagerelease)
AC_ARG_WITH(distribution,
[ --with-distribution=distro Specify target distribution (default=Generic;
others: RedHat, SuSE, Debian, ArchLinux)],
distribution=$withval)
AC_SUBST(distribution)
AC_ARG_WITH(target,
[ --with-target=platform Change compilation target platform (default:
autodetect; others: Linux, BSD, Cygwin)],
target=$withval)
case $target in
Linux|linux)
AC_DEFINE(TARGET, TARGET_LINUX)
target="Linux"
;;
BSD| bsd)
AC_DEFINE(TARGET, TARGET_BSD)
target="BSD"
;;
Cygwin|CYGWIN|cygwin)
AC_DEFINE(TARGET, TARGET_CYGWIN)
target="cygwin"
;;
autodetect)
;;
*)
AC_MSG_ERROR([--with-target must have Linux, BSD or Cygwin as parameter.])
;;
esac
AC_ARG_WITH(cachedir,
[ --with-cachedir=dir Default directory for pdnsd cache
(default=/var/cache/pdnsd)],
cachedir=$withval)
AC_DEFINE_UNQUOTED(CACHEDIR, "$cachedir")
AC_SUBST(cachedir)
AC_ARG_ENABLE(isdn,
[ --enable-isdn Enable ISDN support (may cause problems on
some systems; only for Linux)],
test $enableval = "yes" && AC_DEFINE(ISDN_SUPPORT))
AC_ARG_ENABLE(ipv4,
[ --disable-ipv4 Disable IPv4 networking support
(default=enabled)],
have_ipv4=$enableval)
test $have_ipv4 = "yes" && AC_DEFINE(ENABLE_IPV4)
AC_ARG_ENABLE(ipv6,
[ --enable-ipv6 Enable IPv6 networking support],
[ if test $enableval = "yes" ; then
AC_DEFINE(ENABLE_IPV6)
if test $have_ipv4 != "yes" ; then
ipv4_default=0
fi
fi])
AC_ARG_ENABLE(ipv4-startup,
[ --disable-ipv4-startup Disable IPv4 on pdnsd startup by default
(default=enabled)],
[ if test $enableval = "yes" ; then
ipv4_default=1
else
ipv4_default=0
fi])
AC_ARG_ENABLE(ipv6-startup,
[ --enable-ipv6-startup Enable IPV6 on pdnsd startup by default
(default=IPv4)],
[ if test $enableval = "yes" ; then
ipv4_default=0
else
ipv4_default=1
fi])
AC_DEFINE_UNQUOTED(DEFAULT_IPV4, $ipv4_default)
AC_ARG_ENABLE(udp-queries,
[ --disable-udp-queries Disable udp as query method.],
udp_queries=$enableval)
AC_ARG_ENABLE(tcp-queries,
[ --disable-tcp-queries Disable tcp as query method.],
tcp_queries=$enableval)
AC_ARG_WITH(query-method,
[ --with-query-method=qm Specify the query method (default=udponly;
others: tcponly, tcpudp, udptcp)],
query_m=$withval)
case $query_m in
udponly|UDPonly)
AC_DEFINE(M_PRESET, UDP_ONLY)
udp_queries=yes;
;;
tcponly|TCPonly)
AC_DEFINE(M_PRESET, TCP_ONLY)
tcp_queries=yes;
;;
tcpudp|TCPUDP)
AC_DEFINE(M_PRESET, TCP_UDP)
udp_queries=yes;
tcp_queries=yes;
;;
udptcp|UDPTCP)
AC_DEFINE(M_PRESET, UDP_TCP)
udp_queries=yes;
tcp_queries=yes;
;;
*)
AC_MSG_ERROR([--with-query-method must have udponly, tcponly, tcpudp or udptcp as parameter.])
;;
esac
test $udp_queries != "yes" && AC_DEFINE(NO_UDP_QUERIES)
test $tcp_queries != "yes" && AC_DEFINE(NO_TCP_QUERIES)
AC_ARG_ENABLE(tcp-server,
[ --disable-tcp-server Disable the TCP serving ability of pdnsd],
have_tcp_server=$enableval)
test $have_tcp_server != "yes" && AC_DEFINE(NO_TCP_SERVER)
AC_ARG_ENABLE(src-addr-disc,
[ --disable-src-addr-disc Disable the UDP source address discovery],
adisc=$enableval)
AC_ARG_ENABLE(socket-locking,
[ --enable-socket-locking Enable the UDP socket locking],
slock=$enableval)
test $slock = "yes" && AC_DEFINE(SOCKET_LOCKING)
AC_ARG_ENABLE(poll,
[ --disable-poll Disable poll(2) and use select(2)
(default=enabled)],
test $enableval != "yes" && AC_DEFINE(NO_POLL))
AC_ARG_ENABLE(new-rrs,
[ --disable-new-rrs Disable new DNS RR types (obsolete, currently ignored)],
newrrs=$enableval)
AC_ARG_ENABLE(strict-rfc2181,
[ --enable-strict-rfc2181 Enforce strict RFC 2181 compliance],
test $enableval = "yes" && AC_DEFINE(RFC2181_ME_HARDER))
AC_ARG_WITH(random-device,
[ --with-random-device=device Specify random device other than
/dev/random; default: C Library random() PRNG;
special value arc4random for BSD C Library
arc4random function (default on FreeBSD)],
randomdev=$withval)
if test "$randomdev" = arc4random ; then
AC_DEFINE(R_ARC4RANDOM)
elif test "$randomdev" = random ; then
AC_DEFINE(R_RANDOM)
elif test "$randomdev" = default ; then
AC_DEFINE(R_DEFAULT)
else
AC_DEFINE_UNQUOTED(RANDOM_DEVICE, "$randomdev")
fi
AC_ARG_ENABLE(underscores,
[ --enable-underscores Allow _ in domain names (obsolete, currently ignored)],
underscores=$enableval)
AC_ARG_WITH(default-id,
[ --with-default-id=id Specify default uid/gid for pdnsd
(default=nobody)],
def_id=$withval)
AC_SUBST(def_id)
AC_ARG_WITH(debug,
[ --with-debug=level Specify debugging level (0 means no debug support)],
AC_DEFINE_UNQUOTED(DEBUG, $withval))
AC_ARG_WITH(verbosity,
[ --with-verbosity=level Specify default message verbosity],
AC_DEFINE_UNQUOTED(VERBOSITY, $withval))
AC_ARG_WITH(hash-buckets,
[ --with-hash-buckets=num Number of hash buckets to use (default=1024).
The number actually used is the smallest power of two
greater or equal to the number specified here.],
powof2=1
hashsz=0
while test $powof2 -lt "$withval"
do
powof2=`expr 2 '*' $powof2`
hashsz=`expr $hashsz '+' 1`
done
AC_DEFINE_UNQUOTED(HASH_SZ, $hashsz)
)
AC_ARG_ENABLE(hash-debug,
[ --enable-hash-debug Debug hash tables (warning: massive output)],
test $enableval = "yes" && AC_DEFINE(DEBUG_HASH))
AC_ARG_ENABLE(rcsids,
[ --enable-rcsids Enable RCS IDs in executables (obsolete, currently ignored)],
have_rcsids=$enableval)
AC_ARG_WITH(tcp-qtimeout,
[ --with-tcp-qtimeout=secs Specify default tcp query timeout (default=30)],
AC_DEFINE_UNQUOTED(TCP_TIMEOUT, $withval))
AC_ARG_ENABLE(tcp-subseq,
[ --enable-tcp-subseq Enable multiple dns querys using one
tcp connection],
test $enableval = "yes" && AC_DEFINE(TCP_SUBSEQ))
AC_ARG_WITH(par-queries,
[ --with-par-queries=num Specify default parallel query number (default=2)],
AC_DEFINE_UNQUOTED(PAR_QUERIES, $withval))
AC_ARG_WITH(max-nameserver-ips,
[ --with-max-nameserver-ips=num Specify maximum number of IP addresses used per nameserver obtained from NS records (default=3)],
AC_DEFINE_UNQUOTED(MAXNAMESERVIPS, $withval))
AC_ARG_ENABLE(specbuild,
[ --enable-specbuild Only used when building pdnsd from spec files],
specbuild=$enableval)
AC_SUBST(specbuild)
AC_ARG_WITH(thread-lib,
[ --with-thread-lib=lib Specify thread library, overriding automatic detection (for Linux only).
Possible values: LinuxThreads,
LinuxThreads2 (implements a fix for newer glibcs)
or NPTL (Native POSIX Thread Library)],
threadlib=$withval)
AC_SUBST(threadlib)
dnl Checks for programs.
AC_PROG_CC
AM_PROG_CC_STDC
AM_PROG_CC_C_O
AC_PROG_INSTALL
dnl For dbm subsystem libraries
AC_PROG_RANLIB
if test "$target" = "autodetect" ; then
AC_MSG_CHECKING([for autodetect build target])
uname_sys=`uname`
if test $? -ne 0 ; then
AC_MSG_RESULT([failed])
AC_MSG_ERROR([uname failed or was not found in path])
else
case "${uname_sys}" in
Linux)
AC_MSG_RESULT(Linux)
AC_DEFINE(TARGET, TARGET_LINUX)
target="Linux"
;;
FreeBSD|NetBSD|OpenBSD|Darwin)
AC_MSG_RESULT("${uname_sys}")
AC_DEFINE(TARGET, TARGET_BSD)
target="BSD"
;;
CYGWIN*)
AC_MSG_RESULT("${uname_sys}")
AC_DEFINE(TARGET, TARGET_CYGWIN)
target="cygwin"
;;
*)
AC_MSG_RESULT([failed])
AC_MSG_ERROR(
[Your system type could not be identified. Try setting it manually using
--with-target])
;;
esac
fi
fi
#if test "$target" = BSD ; then
# uname_sys=`uname`
# if test "$uname_sys" = FreeBSD ; then
# AC_MSG_CHECKING([for FreeBSD version])
# osrel=`sysctl -n kern.osreldate`
# if test $osrel -ge 500016 ; then
# AC_MSG_RESULT([5.0 (>= 500016)])
# freebsd_pthread="5"
# else
# AC_MSG_RESULT([<=5.0 (< 500016)])
# freebsd_pthread="4"
# fi
# fi
#fi
if test "$adisc" = "default"; then
if test "$target" = "cygwin" ; then
# Don't do UDP source address discovery on Cygwin platform by default.
adisc="no"
else
adisc="yes"
fi
fi
test "$adisc" = "yes" && AC_DEFINE(SRC_ADDR_DISC)
dnl Checks for libraries.
if test "$target" = "Linux"; then
AC_MSG_CHECKING([if we can compile and link with -pthread])
old_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -pthread"
AC_LINK_IFELSE([
#include <pthread.h>
void *thread_func(void *data)
{
*((int *)data)=1;
return data;
}
int main()
{
pthread_t thread;
void *retval;
int val;
if(pthread_create(&thread, NULL, thread_func, &val))
return 1;
if(pthread_join(thread,&retval))
return 1;
return (*((int *)retval)!=1);
}
],
gcc_pthread_flag="yes", gcc_pthread_flag="no")
CFLAGS="$old_CFLAGS"
AC_MSG_RESULT([$gcc_pthread_flag])
if test "$gcc_pthread_flag" = yes ; then
thread_CFLAGS="-pthread"
AC_SUBST(thread_CFLAGS)
else
AC_CHECK_LIB(pthread, pthread_create)
fi
fi
if test "$target" = "BSD" -a `uname` != Darwin ; then
# if test $freebsd_pthread = 4 ; then
thread_CFLAGS="-pthread"
AC_SUBST(thread_CFLAGS)
# else
# AC_CHECK_LIB(c_r, pthread_create, ,
# AC_MSG_ERROR([You must have libc_r installed to build/run pdnsd!]))
# fi;
fi
if test "$target" = "Linux" -a "$threadlib" = default; then
AC_MSG_CHECKING([if this is an NPTL-based system])
old_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $thread_CFLAGS"
AC_RUN_IFELSE([
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <pthread.h>
/* All this function does is return its PID (in a roundabout way). */
void *thread_func(void *data)
{
*((int *)data)=getpid();
return data;
}
int main()
{
pthread_t thread;
void *retval;
int err,mainpid,thrdpid;
err=pthread_create(&thread, NULL, thread_func, &thrdpid);
if(err) {
fprintf(stderr,"pthread_create failed: %s\n",strerror(err));
return 1;
}
err=pthread_join(thread,&retval);
if(err) {
fprintf(stderr,"pthread_join failed: %s\n",strerror(err));
return 1;
}
mainpid=getpid();
/* In LinuxThreads implementations, the pids of the threads will usually differ
in a non Posix-compliant way. */
fprintf(stderr,"main pid=%d, thread pid=%d\n",mainpid,*((int *)retval));
return (*((int *)retval)!=mainpid);
}
],
[
AC_MSG_RESULT([yes])
threadlib=nptl
],
[
AC_MSG_RESULT([no])
threadlib=linuxthreads
],
[
AC_MSG_RESULT([couldn't run test program])
threadlib=linuxthreads
])
CFLAGS="$old_CFLAGS"
fi
if test "$threadlib" = nptl -o "$threadlib" = NPTL; then
AC_DEFINE(THREADLIB_NPTL)
elif test "$threadlib" = linuxthreads2 -o "$threadlib" = LinuxThreads2 -o "$threadlib" = lt2; then
AC_DEFINE(THREADLIB_LINUXTHREADS2)
fi
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h malloc.h sys/ioctl.h sys/time.h syslog.h unistd.h)
AC_CHECK_HEADERS(sys/types.h sys/socket.h net/if.h netinet/in.h sys/poll.h,,,
[#include <stdio.h>
#if STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#else
# if HAVE_STDLIB_H
# include <stdlib.h>
# endif
#endif
#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM
AC_CHECK_TYPES(socklen_t,, AC_DEFINE(socklen_t,int),[#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>])
AC_CHECK_TYPES([struct in6_addr, struct in_pktinfo, struct ifreq],,,[#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>])
AC_MSG_CHECKING([for CPP C99 Variadic macro support])
AC_COMPILE_IFELSE([
#define a(...) junk(0,__VA_ARGS__)
extern void junk(int i,...);
int main()
{
a(0);
a("a");
a(0, "a", 1);
return 0;
}
],
cpp_c99_variadic="yes", cpp_c99_variadic="no")
AC_MSG_RESULT([$cpp_c99_variadic])
if test $cpp_c99_variadic = yes; then
AC_DEFINE(CPP_C99_VARIADIC_MACROS)
else
if test "$GCC" != yes; then
AC_MSG_ERROR([Compiler must support C99 or gcc variadic macros])
fi;
fi
dnl Checks for library functions.
AC_FUNC_ALLOCA
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MEMCMP
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_SEARCH_LIBS(nanosleep, rt)
AC_SEARCH_LIBS(socket, socket,,,-lnsl)
AC_SEARCH_LIBS(inet_aton, resolv)
AC_CHECK_FUNCS(nanosleep gettimeofday mkfifo select socket strerror uname snprintf vsnprintf, true,
AC_MSG_ERROR([One of the functions required for pdnsd were not found.]))
AC_CHECK_FUNCS(poll, true, AC_DEFINE(NO_POLL))
AC_CHECK_FUNCS(strdup strndup stpcpy stpncpy strlcpy mempcpy getline asprintf vasprintf getpwnam_r inet_ntop inet_pton)
AC_OUTPUT([
pdnsd.spec
Makefile
file-list.base
contrib/Makefile
doc/Makefile
doc/pdnsd.8
doc/pdnsd.conf.5
doc/pdnsd.conf
src/Makefile
src/pdnsd-ctl/Makefile
src/rc/Makefile
src/rc/RedHat/Makefile
src/rc/RedHat/pdnsd
src/rc/SuSE/Makefile
src/rc/SuSE/pdnsd
src/rc/Debian/Makefile
src/rc/Debian/pdnsd
src/rc/Slackware/Makefile
src/rc/Slackware/rc.pdnsd
src/rc/ArchLinux/Makefile
src/rc/ArchLinux/pdnsd
src/test/Makefile
PKGBUILD
])