configure.in 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. dnl Process this file with autoconf to produce a configure script.
  2. AC_INIT(src)
  3. package="pdnsd"
  4. version=`cut -d - -f 1 "$srcdir"/version`
  5. fullversion=`cat "$srcdir"/version`
  6. packagerelease=`cut -d - -f 2- "$srcdir"/version`
  7. distribution="Generic"
  8. target="autodetect"
  9. cachedir="/var/cache/$package"
  10. ipv4_default=1
  11. have_ipv4="yes"
  12. #newrrs="yes"
  13. query_m="udponly"
  14. have_tcp_server="yes"
  15. adisc="default"
  16. slock="no";
  17. def_id="nobody"
  18. #have_rcsids="no"
  19. udp_queries="yes"
  20. tcp_queries="yes"
  21. tempdir="/tmp"
  22. randomdev=default
  23. freebsd_pthread="4"
  24. specbuild=no
  25. threadlib=default
  26. AM_INIT_AUTOMAKE($package, $version, [no-define])
  27. AM_CONFIG_HEADER(config.h)
  28. AC_GNU_SOURCE
  29. AC_DEFINE_UNQUOTED(VERSION,"$fullversion")
  30. AC_SUBST(fullversion)
  31. AC_SUBST(packagerelease)
  32. AC_ARG_WITH(distribution,
  33. [ --with-distribution=distro Specify target distribution (default=Generic;
  34. others: RedHat, SuSE, Debian, ArchLinux)],
  35. distribution=$withval)
  36. AC_SUBST(distribution)
  37. AC_ARG_WITH(target,
  38. [ --with-target=platform Change compilation target platform (default:
  39. autodetect; others: Linux, BSD, Cygwin)],
  40. target=$withval)
  41. case $target in
  42. Linux|linux)
  43. AC_DEFINE(TARGET, TARGET_LINUX)
  44. target="Linux"
  45. ;;
  46. BSD| bsd)
  47. AC_DEFINE(TARGET, TARGET_BSD)
  48. target="BSD"
  49. ;;
  50. Cygwin|CYGWIN|cygwin)
  51. AC_DEFINE(TARGET, TARGET_CYGWIN)
  52. target="cygwin"
  53. ;;
  54. autodetect)
  55. ;;
  56. *)
  57. AC_MSG_ERROR([--with-target must have Linux, BSD or Cygwin as parameter.])
  58. ;;
  59. esac
  60. AC_ARG_WITH(cachedir,
  61. [ --with-cachedir=dir Default directory for pdnsd cache
  62. (default=/var/cache/pdnsd)],
  63. cachedir=$withval)
  64. AC_DEFINE_UNQUOTED(CACHEDIR, "$cachedir")
  65. AC_SUBST(cachedir)
  66. AC_ARG_ENABLE(isdn,
  67. [ --enable-isdn Enable ISDN support (may cause problems on
  68. some systems; only for Linux)],
  69. test $enableval = "yes" && AC_DEFINE(ISDN_SUPPORT))
  70. AC_ARG_ENABLE(ipv4,
  71. [ --disable-ipv4 Disable IPv4 networking support
  72. (default=enabled)],
  73. have_ipv4=$enableval)
  74. test $have_ipv4 = "yes" && AC_DEFINE(ENABLE_IPV4)
  75. AC_ARG_ENABLE(ipv6,
  76. [ --enable-ipv6 Enable IPv6 networking support],
  77. [ if test $enableval = "yes" ; then
  78. AC_DEFINE(ENABLE_IPV6)
  79. if test $have_ipv4 != "yes" ; then
  80. ipv4_default=0
  81. fi
  82. fi])
  83. AC_ARG_ENABLE(ipv4-startup,
  84. [ --disable-ipv4-startup Disable IPv4 on pdnsd startup by default
  85. (default=enabled)],
  86. [ if test $enableval = "yes" ; then
  87. ipv4_default=1
  88. else
  89. ipv4_default=0
  90. fi])
  91. AC_ARG_ENABLE(ipv6-startup,
  92. [ --enable-ipv6-startup Enable IPV6 on pdnsd startup by default
  93. (default=IPv4)],
  94. [ if test $enableval = "yes" ; then
  95. ipv4_default=0
  96. else
  97. ipv4_default=1
  98. fi])
  99. AC_DEFINE_UNQUOTED(DEFAULT_IPV4, $ipv4_default)
  100. AC_ARG_ENABLE(udp-queries,
  101. [ --disable-udp-queries Disable udp as query method.],
  102. udp_queries=$enableval)
  103. AC_ARG_ENABLE(tcp-queries,
  104. [ --disable-tcp-queries Disable tcp as query method.],
  105. tcp_queries=$enableval)
  106. AC_ARG_WITH(query-method,
  107. [ --with-query-method=qm Specify the query method (default=udponly;
  108. others: tcponly, tcpudp, udptcp)],
  109. query_m=$withval)
  110. case $query_m in
  111. udponly|UDPonly)
  112. AC_DEFINE(M_PRESET, UDP_ONLY)
  113. udp_queries=yes;
  114. ;;
  115. tcponly|TCPonly)
  116. AC_DEFINE(M_PRESET, TCP_ONLY)
  117. tcp_queries=yes;
  118. ;;
  119. tcpudp|TCPUDP)
  120. AC_DEFINE(M_PRESET, TCP_UDP)
  121. udp_queries=yes;
  122. tcp_queries=yes;
  123. ;;
  124. udptcp|UDPTCP)
  125. AC_DEFINE(M_PRESET, UDP_TCP)
  126. udp_queries=yes;
  127. tcp_queries=yes;
  128. ;;
  129. *)
  130. AC_MSG_ERROR([--with-query-method must have udponly, tcponly, tcpudp or udptcp as parameter.])
  131. ;;
  132. esac
  133. test $udp_queries != "yes" && AC_DEFINE(NO_UDP_QUERIES)
  134. test $tcp_queries != "yes" && AC_DEFINE(NO_TCP_QUERIES)
  135. AC_ARG_ENABLE(tcp-server,
  136. [ --disable-tcp-server Disable the TCP serving ability of pdnsd],
  137. have_tcp_server=$enableval)
  138. test $have_tcp_server != "yes" && AC_DEFINE(NO_TCP_SERVER)
  139. AC_ARG_ENABLE(src-addr-disc,
  140. [ --disable-src-addr-disc Disable the UDP source address discovery],
  141. adisc=$enableval)
  142. AC_ARG_ENABLE(socket-locking,
  143. [ --enable-socket-locking Enable the UDP socket locking],
  144. slock=$enableval)
  145. test $slock = "yes" && AC_DEFINE(SOCKET_LOCKING)
  146. AC_ARG_ENABLE(poll,
  147. [ --disable-poll Disable poll(2) and use select(2)
  148. (default=enabled)],
  149. test $enableval != "yes" && AC_DEFINE(NO_POLL))
  150. AC_ARG_ENABLE(new-rrs,
  151. [ --disable-new-rrs Disable new DNS RR types (obsolete, currently ignored)],
  152. newrrs=$enableval)
  153. AC_ARG_ENABLE(strict-rfc2181,
  154. [ --enable-strict-rfc2181 Enforce strict RFC 2181 compliance],
  155. test $enableval = "yes" && AC_DEFINE(RFC2181_ME_HARDER))
  156. AC_ARG_WITH(random-device,
  157. [ --with-random-device=device Specify random device other than
  158. /dev/random; default: C Library random() PRNG;
  159. special value arc4random for BSD C Library
  160. arc4random function (default on FreeBSD)],
  161. randomdev=$withval)
  162. if test "$randomdev" = arc4random ; then
  163. AC_DEFINE(R_ARC4RANDOM)
  164. elif test "$randomdev" = random ; then
  165. AC_DEFINE(R_RANDOM)
  166. elif test "$randomdev" = default ; then
  167. AC_DEFINE(R_DEFAULT)
  168. else
  169. AC_DEFINE_UNQUOTED(RANDOM_DEVICE, "$randomdev")
  170. fi
  171. AC_ARG_ENABLE(underscores,
  172. [ --enable-underscores Allow _ in domain names (obsolete, currently ignored)],
  173. underscores=$enableval)
  174. AC_ARG_WITH(default-id,
  175. [ --with-default-id=id Specify default uid/gid for pdnsd
  176. (default=nobody)],
  177. def_id=$withval)
  178. AC_SUBST(def_id)
  179. AC_ARG_WITH(debug,
  180. [ --with-debug=level Specify debugging level (0 means no debug support)],
  181. AC_DEFINE_UNQUOTED(DEBUG, $withval))
  182. AC_ARG_WITH(verbosity,
  183. [ --with-verbosity=level Specify default message verbosity],
  184. AC_DEFINE_UNQUOTED(VERBOSITY, $withval))
  185. AC_ARG_WITH(hash-buckets,
  186. [ --with-hash-buckets=num Number of hash buckets to use (default=1024).
  187. The number actually used is the smallest power of two
  188. greater or equal to the number specified here.],
  189. powof2=1
  190. hashsz=0
  191. while test $powof2 -lt "$withval"
  192. do
  193. powof2=`expr 2 '*' $powof2`
  194. hashsz=`expr $hashsz '+' 1`
  195. done
  196. AC_DEFINE_UNQUOTED(HASH_SZ, $hashsz)
  197. )
  198. AC_ARG_ENABLE(hash-debug,
  199. [ --enable-hash-debug Debug hash tables (warning: massive output)],
  200. test $enableval = "yes" && AC_DEFINE(DEBUG_HASH))
  201. AC_ARG_ENABLE(rcsids,
  202. [ --enable-rcsids Enable RCS IDs in executables (obsolete, currently ignored)],
  203. have_rcsids=$enableval)
  204. AC_ARG_WITH(tcp-qtimeout,
  205. [ --with-tcp-qtimeout=secs Specify default tcp query timeout (default=30)],
  206. AC_DEFINE_UNQUOTED(TCP_TIMEOUT, $withval))
  207. AC_ARG_ENABLE(tcp-subseq,
  208. [ --enable-tcp-subseq Enable multiple dns querys using one
  209. tcp connection],
  210. test $enableval = "yes" && AC_DEFINE(TCP_SUBSEQ))
  211. AC_ARG_WITH(par-queries,
  212. [ --with-par-queries=num Specify default parallel query number (default=2)],
  213. AC_DEFINE_UNQUOTED(PAR_QUERIES, $withval))
  214. AC_ARG_WITH(max-nameserver-ips,
  215. [ --with-max-nameserver-ips=num Specify maximum number of IP addresses used per nameserver obtained from NS records (default=3)],
  216. AC_DEFINE_UNQUOTED(MAXNAMESERVIPS, $withval))
  217. AC_ARG_ENABLE(specbuild,
  218. [ --enable-specbuild Only used when building pdnsd from spec files],
  219. specbuild=$enableval)
  220. AC_SUBST(specbuild)
  221. AC_ARG_WITH(thread-lib,
  222. [ --with-thread-lib=lib Specify thread library, overriding automatic detection (for Linux only).
  223. Possible values: LinuxThreads,
  224. LinuxThreads2 (implements a fix for newer glibcs)
  225. or NPTL (Native POSIX Thread Library)],
  226. threadlib=$withval)
  227. AC_SUBST(threadlib)
  228. dnl Checks for programs.
  229. AC_PROG_CC
  230. AM_PROG_CC_STDC
  231. AM_PROG_CC_C_O
  232. AC_PROG_INSTALL
  233. dnl For dbm subsystem libraries
  234. AC_PROG_RANLIB
  235. if test "$target" = "autodetect" ; then
  236. AC_MSG_CHECKING([for autodetect build target])
  237. uname_sys=`uname`
  238. if test $? -ne 0 ; then
  239. AC_MSG_RESULT([failed])
  240. AC_MSG_ERROR([uname failed or was not found in path])
  241. else
  242. case "${uname_sys}" in
  243. Linux)
  244. AC_MSG_RESULT(Linux)
  245. AC_DEFINE(TARGET, TARGET_LINUX)
  246. target="Linux"
  247. ;;
  248. FreeBSD|NetBSD|OpenBSD|Darwin)
  249. AC_MSG_RESULT("${uname_sys}")
  250. AC_DEFINE(TARGET, TARGET_BSD)
  251. target="BSD"
  252. ;;
  253. CYGWIN*)
  254. AC_MSG_RESULT("${uname_sys}")
  255. AC_DEFINE(TARGET, TARGET_CYGWIN)
  256. target="cygwin"
  257. ;;
  258. *)
  259. AC_MSG_RESULT([failed])
  260. AC_MSG_ERROR(
  261. [Your system type could not be identified. Try setting it manually using
  262. --with-target])
  263. ;;
  264. esac
  265. fi
  266. fi
  267. #if test "$target" = BSD ; then
  268. # uname_sys=`uname`
  269. # if test "$uname_sys" = FreeBSD ; then
  270. # AC_MSG_CHECKING([for FreeBSD version])
  271. # osrel=`sysctl -n kern.osreldate`
  272. # if test $osrel -ge 500016 ; then
  273. # AC_MSG_RESULT([5.0 (>= 500016)])
  274. # freebsd_pthread="5"
  275. # else
  276. # AC_MSG_RESULT([<=5.0 (< 500016)])
  277. # freebsd_pthread="4"
  278. # fi
  279. # fi
  280. #fi
  281. if test "$adisc" = "default"; then
  282. if test "$target" = "cygwin" ; then
  283. # Don't do UDP source address discovery on Cygwin platform by default.
  284. adisc="no"
  285. else
  286. adisc="yes"
  287. fi
  288. fi
  289. test "$adisc" = "yes" && AC_DEFINE(SRC_ADDR_DISC)
  290. dnl Checks for libraries.
  291. if test "$target" = "Linux"; then
  292. AC_MSG_CHECKING([if we can compile and link with -pthread])
  293. old_CFLAGS="$CFLAGS"
  294. CFLAGS="$CFLAGS -pthread"
  295. AC_LINK_IFELSE([
  296. #include <pthread.h>
  297. void *thread_func(void *data)
  298. {
  299. *((int *)data)=1;
  300. return data;
  301. }
  302. int main()
  303. {
  304. pthread_t thread;
  305. void *retval;
  306. int val;
  307. if(pthread_create(&thread, NULL, thread_func, &val))
  308. return 1;
  309. if(pthread_join(thread,&retval))
  310. return 1;
  311. return (*((int *)retval)!=1);
  312. }
  313. ],
  314. gcc_pthread_flag="yes", gcc_pthread_flag="no")
  315. CFLAGS="$old_CFLAGS"
  316. AC_MSG_RESULT([$gcc_pthread_flag])
  317. if test "$gcc_pthread_flag" = yes ; then
  318. thread_CFLAGS="-pthread"
  319. AC_SUBST(thread_CFLAGS)
  320. else
  321. AC_CHECK_LIB(pthread, pthread_create)
  322. fi
  323. fi
  324. if test "$target" = "BSD" -a `uname` != Darwin ; then
  325. # if test $freebsd_pthread = 4 ; then
  326. thread_CFLAGS="-pthread"
  327. AC_SUBST(thread_CFLAGS)
  328. # else
  329. # AC_CHECK_LIB(c_r, pthread_create, ,
  330. # AC_MSG_ERROR([You must have libc_r installed to build/run pdnsd!]))
  331. # fi;
  332. fi
  333. if test "$target" = "Linux" -a "$threadlib" = default; then
  334. AC_MSG_CHECKING([if this is an NPTL-based system])
  335. old_CFLAGS="$CFLAGS"
  336. CFLAGS="$CFLAGS $thread_CFLAGS"
  337. AC_RUN_IFELSE([
  338. #include <stdio.h>
  339. #include <errno.h>
  340. #include <string.h>
  341. #include <sys/types.h>
  342. #include <unistd.h>
  343. #include <pthread.h>
  344. /* All this function does is return its PID (in a roundabout way). */
  345. void *thread_func(void *data)
  346. {
  347. *((int *)data)=getpid();
  348. return data;
  349. }
  350. int main()
  351. {
  352. pthread_t thread;
  353. void *retval;
  354. int err,mainpid,thrdpid;
  355. err=pthread_create(&thread, NULL, thread_func, &thrdpid);
  356. if(err) {
  357. fprintf(stderr,"pthread_create failed: %s\n",strerror(err));
  358. return 1;
  359. }
  360. err=pthread_join(thread,&retval);
  361. if(err) {
  362. fprintf(stderr,"pthread_join failed: %s\n",strerror(err));
  363. return 1;
  364. }
  365. mainpid=getpid();
  366. /* In LinuxThreads implementations, the pids of the threads will usually differ
  367. in a non Posix-compliant way. */
  368. fprintf(stderr,"main pid=%d, thread pid=%d\n",mainpid,*((int *)retval));
  369. return (*((int *)retval)!=mainpid);
  370. }
  371. ],
  372. [
  373. AC_MSG_RESULT([yes])
  374. threadlib=nptl
  375. ],
  376. [
  377. AC_MSG_RESULT([no])
  378. threadlib=linuxthreads
  379. ],
  380. [
  381. AC_MSG_RESULT([couldn't run test program])
  382. threadlib=linuxthreads
  383. ])
  384. CFLAGS="$old_CFLAGS"
  385. fi
  386. if test "$threadlib" = nptl -o "$threadlib" = NPTL; then
  387. AC_DEFINE(THREADLIB_NPTL)
  388. elif test "$threadlib" = linuxthreads2 -o "$threadlib" = LinuxThreads2 -o "$threadlib" = lt2; then
  389. AC_DEFINE(THREADLIB_LINUXTHREADS2)
  390. fi
  391. dnl Checks for header files.
  392. AC_HEADER_STDC
  393. AC_HEADER_SYS_WAIT
  394. AC_CHECK_HEADERS(fcntl.h malloc.h sys/ioctl.h sys/time.h syslog.h unistd.h)
  395. AC_CHECK_HEADERS(sys/types.h sys/socket.h net/if.h netinet/in.h sys/poll.h,,,
  396. [#include <stdio.h>
  397. #if STDC_HEADERS
  398. # include <stdlib.h>
  399. # include <stddef.h>
  400. #else
  401. # if HAVE_STDLIB_H
  402. # include <stdlib.h>
  403. # endif
  404. #endif
  405. #if HAVE_SYS_SOCKET_H
  406. # include <sys/socket.h>
  407. #endif
  408. ])
  409. dnl Checks for typedefs, structures, and compiler characteristics.
  410. AC_C_CONST
  411. AC_TYPE_PID_T
  412. AC_TYPE_SIZE_T
  413. AC_HEADER_TIME
  414. AC_STRUCT_TM
  415. AC_CHECK_TYPES(socklen_t,, AC_DEFINE(socklen_t,int),[#include <sys/types.h>
  416. #include <sys/socket.h>
  417. #include <net/if.h>
  418. #include <netinet/in.h>])
  419. AC_CHECK_TYPES([struct in6_addr, struct in_pktinfo, struct ifreq],,,[#include <sys/types.h>
  420. #include <sys/socket.h>
  421. #include <net/if.h>
  422. #include <netinet/in.h>])
  423. AC_MSG_CHECKING([for CPP C99 Variadic macro support])
  424. AC_COMPILE_IFELSE([
  425. #define a(...) junk(0,__VA_ARGS__)
  426. extern void junk(int i,...);
  427. int main()
  428. {
  429. a(0);
  430. a("a");
  431. a(0, "a", 1);
  432. return 0;
  433. }
  434. ],
  435. cpp_c99_variadic="yes", cpp_c99_variadic="no")
  436. AC_MSG_RESULT([$cpp_c99_variadic])
  437. if test $cpp_c99_variadic = yes; then
  438. AC_DEFINE(CPP_C99_VARIADIC_MACROS)
  439. else
  440. if test "$GCC" != yes; then
  441. AC_MSG_ERROR([Compiler must support C99 or gcc variadic macros])
  442. fi;
  443. fi
  444. dnl Checks for library functions.
  445. AC_FUNC_ALLOCA
  446. AC_PROG_GCC_TRADITIONAL
  447. AC_FUNC_MEMCMP
  448. AC_TYPE_SIGNAL
  449. AC_FUNC_VPRINTF
  450. AC_SEARCH_LIBS(nanosleep, rt)
  451. AC_SEARCH_LIBS(socket, socket,,,-lnsl)
  452. AC_SEARCH_LIBS(inet_aton, resolv)
  453. AC_CHECK_FUNCS(nanosleep gettimeofday mkfifo select socket strerror uname snprintf vsnprintf, true,
  454. AC_MSG_ERROR([One of the functions required for pdnsd were not found.]))
  455. AC_CHECK_FUNCS(poll, true, AC_DEFINE(NO_POLL))
  456. AC_CHECK_FUNCS(strdup strndup stpcpy stpncpy strlcpy mempcpy getline asprintf vasprintf getpwnam_r inet_ntop inet_pton)
  457. AC_OUTPUT([
  458. pdnsd.spec
  459. Makefile
  460. file-list.base
  461. contrib/Makefile
  462. doc/Makefile
  463. doc/pdnsd.8
  464. doc/pdnsd.conf.5
  465. doc/pdnsd.conf
  466. src/Makefile
  467. src/pdnsd-ctl/Makefile
  468. src/rc/Makefile
  469. src/rc/RedHat/Makefile
  470. src/rc/RedHat/pdnsd
  471. src/rc/SuSE/Makefile
  472. src/rc/SuSE/pdnsd
  473. src/rc/Debian/Makefile
  474. src/rc/Debian/pdnsd
  475. src/rc/Slackware/Makefile
  476. src/rc/Slackware/rc.pdnsd
  477. src/rc/ArchLinux/Makefile
  478. src/rc/ArchLinux/pdnsd
  479. src/test/Makefile
  480. PKGBUILD
  481. ])