configure.in 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. #
  2. # ngIRCd -- The Next Generation IRC Daemon
  3. # Copyright (c)2001-2006 Alexander Barton <alex@barton.de>
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. # Please read the file COPYING, README and AUTHORS for more information.
  10. #
  11. # $Id: configure.in,v 1.118.2.6 2006/10/01 16:21:56 alex Exp $
  12. #
  13. # -- Initialisation --
  14. AC_PREREQ(2.50)
  15. AC_INIT(ngircd, 0.10.0)
  16. AC_CONFIG_SRCDIR(src/ngircd/ngircd.c)
  17. AC_CANONICAL_TARGET
  18. AM_INIT_AUTOMAKE(1.6)
  19. AM_CONFIG_HEADER(src/config.h)
  20. # -- Templates for config.h --
  21. AH_TEMPLATE([DEBUG], [Define if debug-mode should be enabled])
  22. AH_TEMPLATE([HAVE_socklen_t], [Define if socklen_t exists])
  23. AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
  24. AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
  25. AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
  26. AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
  27. AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
  28. AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
  29. AH_TEMPLATE([ZEROCONF], [Define if support for Zeroconf should be included])
  30. AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
  31. AH_TEMPLATE([TARGET_OS], [Target operating system name])
  32. AH_TEMPLATE([TARGET_VENDOR], [Target system vendor])
  33. AH_TEMPLATE([TARGET_CPU], [Target CPU name])
  34. # -- C Compiler --
  35. AC_PROG_CC
  36. # -- Helper programs --
  37. AC_PROG_AWK
  38. AC_PROG_INSTALL
  39. AC_PROG_LN_S
  40. AC_PROG_MAKE_SET
  41. AC_PROG_RANLIB
  42. # -- Compiler Features --
  43. AM_C_PROTOTYPES
  44. AC_C_CONST
  45. # -- Hard coded system and compiler dependencies/features/options ... --
  46. AC_DEFUN([GCC_STACK_PROTECT_CC],[
  47. ssp_cc=yes
  48. # we use -fstack-protector-all for the test to enfoce the use of the guard variable
  49. AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
  50. ssp_old_cflags="$CFLAGS"
  51. CFLAGS="$CFLAGS -fstack-protector-all"
  52. AC_TRY_LINK(,,, ssp_cc=no)
  53. echo $ssp_cc
  54. CFLAGS="$ssp_old_cflags"
  55. if test "X$ssp_cc" = "Xyes"; then
  56. CFLAGS="$CFLAGS -fstack-protector"
  57. AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
  58. fi
  59. ])
  60. if test "$GCC" = "yes"; then
  61. # We are using the GNU C compiler. Good!
  62. CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
  63. GCC_STACK_PROTECT_CC
  64. fi
  65. case "$target_os" in
  66. hpux*)
  67. # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
  68. # (tested with HP/UX 11.11)
  69. CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
  70. ;;
  71. esac
  72. # Add additional CFLAGS, eventually specified on the command line:
  73. test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
  74. CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
  75. # -- Headers --
  76. AC_HEADER_STDC
  77. AC_HEADER_TIME
  78. AC_HEADER_SYS_WAIT
  79. AC_CHECK_HEADERS([ \
  80. ctype.h errno.h fcntl.h netdb.h netinet/in.h stdlib.h string.h \
  81. strings.h sys/socket.h sys/time.h unistd.h \
  82. ],,AC_MSG_ERROR([required C header missing!]))
  83. AC_CHECK_HEADERS([arpa/inet.h ctype.h malloc.h stdbool.h stddef.h varargs.h])
  84. # -- Datatypes --
  85. AC_MSG_CHECKING(whether socklen_t exists)
  86. AC_TRY_COMPILE([
  87. #include <sys/types.h>
  88. #include <sys/socket.h>
  89. ],[
  90. socklen_t a, b;
  91. a = 2; b = 4; a += b;
  92. ],[
  93. AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
  94. ],[
  95. AC_MSG_RESULT(no)
  96. ])
  97. AC_TYPE_SIGNAL
  98. AC_TYPE_SIZE_T
  99. # -- Libraries --
  100. AC_CHECK_LIB(UTIL,memmove)
  101. AC_CHECK_LIB(socket,bind)
  102. AC_CHECK_LIB(nsl,gethostent)
  103. # -- Functions --
  104. AC_FUNC_FORK
  105. AC_FUNC_STRFTIME
  106. AC_CHECK_FUNCS([ \
  107. bind gethostbyaddr gethostbyname gethostname inet_ntoa malloc memmove \
  108. memset realloc setsid setsockopt socket strcasecmp strchr strerror \
  109. strstr waitpid],,AC_MSG_ERROR([required function missing!]))
  110. AC_CHECK_FUNCS(inet_aton isdigit sigaction snprintf vsnprintf strdup strlcpy strlcat)
  111. AC_CHECK_FUNCS(select,[AC_CHECK_HEADERS(sys/select.h)],
  112. AC_MSG_ERROR([required function select() is missing!])
  113. )
  114. # -- Configuration options --
  115. x_syslog_on=no
  116. AC_ARG_WITH(syslog,
  117. [ --without-syslog disable syslog (autodetected by default)],
  118. [ if test "$withval" != "no"; then
  119. if test "$withval" != "yes"; then
  120. CFLAGS="-I$withval/include $CFLAGS"
  121. CPPFLAGS="-I$withval/include $CPPFLAGS"
  122. LDFLAGS="-L$withval/lib $LDFLAGS"
  123. fi
  124. AC_CHECK_LIB(be, syslog)
  125. AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
  126. AC_MSG_ERROR([Can't enable syslog!])
  127. )
  128. fi
  129. ],
  130. [
  131. AC_CHECK_LIB(be, syslog)
  132. AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
  133. ]
  134. )
  135. if test "$x_syslog_on" = "yes"; then
  136. AC_DEFINE(SYSLOG, 1)
  137. AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
  138. fi
  139. x_zlib_on=no
  140. AC_ARG_WITH(zlib,
  141. [ --without-zlib disable zlib compression (autodetected by default)],
  142. [ if test "$withval" != "no"; then
  143. if test "$withval" != "yes"; then
  144. CFLAGS="-I$withval/include $CFLAGS"
  145. CPPFLAGS="-I$withval/include $CPPFLAGS"
  146. LDFLAGS="-L$withval/lib $LDFLAGS"
  147. fi
  148. AC_CHECK_LIB(z, deflate)
  149. AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
  150. AC_MSG_ERROR([Can't enable zlib!])
  151. )
  152. fi
  153. ],
  154. [ AC_CHECK_LIB(z, deflate)
  155. AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
  156. ]
  157. )
  158. if test "$x_zlib_on" = "yes"; then
  159. AC_DEFINE(ZLIB, 1)
  160. AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
  161. fi
  162. x_io_backend=select
  163. AC_ARG_WITH(epoll,
  164. [ --without-epoll disable epoll support (autodetected by default)],
  165. [ if test "$withval" != "no"; then
  166. if test "$withval" != "yes"; then
  167. CFLAGS="-I$withval/include $CFLAGS"
  168. CPPFLAGS="-I$withval/include $CPPFLAGS"
  169. LDFLAGS="-L$withval/lib $LDFLAGS"
  170. fi
  171. AC_CHECK_FUNCS(epoll_create, x_io_backend=epoll,
  172. AC_MSG_ERROR([Can't enable epoll support!])
  173. )
  174. fi
  175. ],
  176. [
  177. AC_CHECK_FUNCS(epoll_create, x_io_backend=epoll)
  178. ]
  179. )
  180. AC_ARG_WITH(kqueue,
  181. [ --without-kqueue disable kqueue support (autodetected by default)],
  182. [ if test "$withval" != "no"; then
  183. if test "$withval" != "yes"; then
  184. CFLAGS="-I$withval/include $CFLAGS"
  185. CPPFLAGS="-I$withval/include $CPPFLAGS"
  186. LDFLAGS="-L$withval/lib $LDFLAGS"
  187. fi
  188. AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue,
  189. AC_MSG_ERROR([Can't enable kqueue support!])
  190. )
  191. fi
  192. ],
  193. [
  194. AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue)
  195. ]
  196. )
  197. x_tcpwrap_on=no
  198. AC_ARG_WITH(tcp-wrappers,
  199. [ --with-tcp-wrappers enable TCP wrappers support],
  200. [ if test "$withval" != "no"; then
  201. if test "$withval" != "yes"; then
  202. CFLAGS="-I$withval/include $CFLAGS"
  203. CPPFLAGS="-I$withval/include $CPPFLAGS"
  204. LDFLAGS="-L$withval/lib $LDFLAGS"
  205. fi
  206. AC_MSG_CHECKING(for hosts_access)
  207. LIBS="-lwrap $LIBS"
  208. AC_TRY_LINK([
  209. #include <tcpd.h>
  210. int allow_severity = 0;
  211. int deny_severity = 0;
  212. ],[
  213. tcpd_warn("link test");
  214. ],[
  215. AC_MSG_RESULT(yes)
  216. AC_DEFINE(TCPWRAP, 1)
  217. x_tcpwrap_on=yes
  218. ],[
  219. AC_MSG_RESULT(no)
  220. AC_MSG_ERROR([Can't enable TCP wrappers!])
  221. ])
  222. fi
  223. ]
  224. )
  225. x_zeroconf_on=no
  226. AC_ARG_WITH(zeroconf,
  227. [ --with-zeroconf enable support for "Zeroconf"],
  228. [ if test "$withval" != "no"; then
  229. if test "$withval" != "yes"; then
  230. CFLAGS="-I$withval/include $CFLAGS"
  231. CPPFLAGS="-I$withval/include $CPPFLAGS"
  232. LDFLAGS="-L$withval/lib $LDFLAGS"
  233. fi
  234. AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_zeroconf_on=osx,
  235. [
  236. AC_CHECK_LIB(pthread, pthread_mutexattr_init)
  237. AC_CHECK_LIB(howl, sw_discovery_init)
  238. AC_CHECK_FUNCS(sw_discovery_init, \
  239. x_zeroconf_on=howl, \
  240. AC_MSG_ERROR([Can't enable Zeroconf!]))
  241. ])
  242. fi
  243. ]
  244. )
  245. if test "$x_zeroconf_on" = "osx"; then
  246. AC_CHECK_HEADERS([DNSServiceDiscovery/DNSServiceDiscovery.h \
  247. mach/port.h],,AC_MSG_ERROR([required C header missing!]))
  248. AC_DEFINE(ZEROCONF, 1)
  249. fi
  250. if test "$x_zeroconf_on" = "howl"; then
  251. for dir in /usr/local/include /usr/local/include/howl* \
  252. /usr/include /usr/include/howl* \
  253. /usr/local/include/avahi* /usr/include/avahi*; do
  254. test -d "$dir" || continue
  255. AC_MSG_CHECKING([for Howl headers in $dir])
  256. if test -f "$dir/rendezvous/rendezvous.h"; then
  257. if test "$dir" != "/usr/local/include" -a \
  258. "$dir" != "/usr/include"; then
  259. CFLAGS="-I$dir $CFLAGS"
  260. CPPFLAGS="-I$dir $CPPFLAGS"
  261. fi
  262. AC_MSG_RESULT(yes)
  263. break
  264. else
  265. AC_MSG_RESULT(no)
  266. fi
  267. done
  268. AC_CHECK_HEADERS([rendezvous/rendezvous.h],, \
  269. AC_MSG_ERROR([required C header missing!]))
  270. AC_DEFINE(ZEROCONF, 1)
  271. fi
  272. x_identauth_on=no
  273. AC_ARG_WITH(ident,
  274. [ --with-ident enable "IDENT" ("AUTH") protocol support],
  275. [ if test "$withval" != "no"; then
  276. if test "$withval" != "yes"; then
  277. CFLAGS="-I$withval/include $CFLAGS"
  278. CPPFLAGS="-I$withval/include $CPPFLAGS"
  279. LDFLAGS="-L$withval/lib $LDFLAGS"
  280. fi
  281. AC_CHECK_LIB(ident, ident_id)
  282. AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
  283. AC_MSG_ERROR([Can't enable IDENT support!])
  284. )
  285. fi
  286. ]
  287. )
  288. if test "$x_identauth_on" = "yes"; then
  289. AC_DEFINE(IDENTAUTH, 1)
  290. AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
  291. fi
  292. x_ircplus_on=yes
  293. AC_ARG_ENABLE(ircplus,
  294. [ --disable-ircplus disable IRC+ protocol],
  295. if test "$enableval" = "no"; then x_ircplus_on=no; fi
  296. )
  297. if test "$x_ircplus_on" = "yes"; then
  298. AC_DEFINE(IRCPLUS, 1)
  299. fi
  300. x_sniffer_on=no; x_debug_on=no
  301. AC_ARG_ENABLE(sniffer,
  302. [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
  303. if test "$enableval" = "yes"; then
  304. AC_DEFINE(SNIFFER, 1)
  305. x_sniffer_on=yes; x_debug_on=yes
  306. fi
  307. )
  308. AC_ARG_ENABLE(debug,
  309. [ --enable-debug show additional debug output],
  310. if test "$enableval" = "yes"; then x_debug_on=yes; fi
  311. )
  312. if test "$x_debug_on" = "yes"; then
  313. AC_DEFINE(DEBUG, 1)
  314. test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
  315. fi
  316. x_strict_rfc_on=no
  317. AC_ARG_ENABLE(strict-rfc,
  318. [ --enable-strict-rfc strict RFC conformance -- may break clients!],
  319. if test "$enableval" = "yes"; then
  320. AC_DEFINE(STRICT_RFC, 1)
  321. x_strict_rfc_on=yes
  322. fi
  323. )
  324. # -- Definitions --
  325. AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
  326. AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
  327. AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
  328. # Add additional CFLAGS, eventually specified on the command line, but after
  329. # running this configure script. Useful for "-Werror" for example.
  330. test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
  331. # -- Generate files --
  332. AC_OUTPUT([ \
  333. Makefile \
  334. doc/Makefile \
  335. doc/src/Makefile \
  336. src/Makefile \
  337. src/portab/Makefile \
  338. src/tool/Makefile \
  339. src/ngircd/Makefile \
  340. src/testsuite/Makefile \
  341. man/Makefile \
  342. contrib/Makefile \
  343. contrib/Debian/Makefile \
  344. contrib/MacOSX/Makefile \
  345. ])
  346. type dpkg >/dev/null 2>&1
  347. if test $? -eq 0; then
  348. # Generate debian/ link if the dpkg command exists
  349. # (read: if we are running on a debian compatible system)
  350. echo "creating Debian-specific links ..."
  351. test -f debian/rules || ln -s contrib/Debian debian
  352. fi
  353. # -- Result --
  354. echo
  355. echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
  356. echo
  357. # Someone please show me a better way :) [borrowed by OpenSSH]
  358. B=`eval echo ${bindir}` ; B=`eval echo ${B}`
  359. S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
  360. C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
  361. M=`eval echo ${mandir}` ; M=`eval echo ${M}`
  362. D=`eval echo ${datadir}/doc/${PACKAGE}` ; D=`eval echo ${D}`
  363. echo " Target: ${target}"
  364. test "$target" != "$host" && echo " Host: ${host}"
  365. echo " Compiler: ${CC}"
  366. test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
  367. test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
  368. test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
  369. test -n "$LIBS" && echo " Libraries: ${LIBS}"
  370. echo
  371. echo " 'ngircd' binary: $S"
  372. echo " Configuration file: $C"
  373. echo " Manual pages: $M"
  374. echo " Documentation: $D"
  375. echo
  376. echo $ECHO_N " Syslog support: $ECHO_C"
  377. test "$x_syslog_on" = "yes" \
  378. && echo $ECHO_N "yes $ECHO_C" \
  379. || echo $ECHO_N "no $ECHO_C"
  380. echo $ECHO_N " Enable debug code: $ECHO_C"
  381. test "$x_debug_on" = "yes" \
  382. && echo "yes" \
  383. || echo "no"
  384. echo $ECHO_N " zlib compression: $ECHO_C"
  385. test "$x_zlib_on" = "yes" \
  386. && echo $ECHO_N "yes $ECHO_C" \
  387. || echo $ECHO_N "no $ECHO_C"
  388. echo $ECHO_N " IRC sniffer: $ECHO_C"
  389. test "$x_sniffer_on" = "yes" \
  390. && echo "yes" \
  391. || echo "no"
  392. echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
  393. test "$x_tcpwrap_on" = "yes" \
  394. && echo $ECHO_N "yes $ECHO_C" \
  395. || echo $ECHO_N "no $ECHO_C"
  396. echo $ECHO_N " Strict RFC mode: $ECHO_C"
  397. test "$x_strict_rfc_on" = "yes" \
  398. && echo "yes" \
  399. || echo "no"
  400. echo $ECHO_N " Zeroconf support: $ECHO_C"
  401. case "$x_zeroconf_on" in
  402. osx)
  403. echo $ECHO_N "Apple $ECHO_C"
  404. ;;
  405. howl)
  406. echo $ECHO_N "Howl $ECHO_C"
  407. ;;
  408. *)
  409. echo $ECHO_N "no $ECHO_C"
  410. ;;
  411. esac
  412. echo $ECHO_N " IRC+ protocol: $ECHO_C"
  413. test "$x_ircplus_on" = "yes" \
  414. && echo "yes" \
  415. || echo "no"
  416. echo $ECHO_N " IDENT support: $ECHO_C"
  417. test "$x_identauth_on" = "yes" \
  418. && echo $ECHO_N "yes $ECHO_C" \
  419. || echo $ECHO_N "no $ECHO_C"
  420. echo $ECHO_N " I/O backend: $ECHO_C"
  421. echo "\"$x_io_backend()\""
  422. echo
  423. # -eof-