您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

488 行
12 KiB

  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_PREREQ([2.61])
  4. AC_INIT([lighttpd],[2.0.0],[contact@lighttpd.net])
  5. AC_CONFIG_SRCDIR([src/main/lighttpd_worker.c])
  6. AC_CONFIG_HEADER([include/lighttpd/config.h])
  7. AC_CONFIG_MACRO_DIR([m4])
  8. dnl HOW FUCKING BROKEN IS AUTOMAKE...
  9. dnl serial-tests is not recognized before 1.12, and required for serial tests with 1.13
  10. dnl if you don't use the default (symlinked) automake on your box, set AUTOMAKE to the path you're using
  11. m4_define([serial_tests], [
  12. m4_esyscmd([case `${AUTOMAKE:-automake} --version | head -n 1` in
  13. *1.11.*|*1.10.*|*1.9.*);;
  14. *) echo serial-tests;;
  15. esac])
  16. ])
  17. AM_INIT_AUTOMAKE([-Wall -Wno-portability -Wno-override -Werror foreign dist-bzip2 tar-ustar] serial_tests)
  18. dnl check environment
  19. AC_USE_SYSTEM_EXTENSIONS
  20. # Checks for programs.
  21. AC_PROG_CC
  22. AC_PROG_MAKE_SET
  23. AC_PROG_INSTALL
  24. # AC_PROG_RANLIB
  25. AM_PROG_AR
  26. AC_PATH_PROG([RAGEL], [ragel])
  27. if test "x$RAGEL" = "x"; then
  28. AC_MSG_ERROR([ragel not found])
  29. fi
  30. AC_SUBST([RAGEL])
  31. dnl libtool
  32. AC_DISABLE_STATIC
  33. AC_ENABLE_SHARED
  34. m4_ifndef([PKG_PROG_PKG_CONFIG], [m4_fatal([pkg-config not installed])])
  35. m4_ifndef([AC_PROG_LIBTOOL], [m4_fatal([libtool not installed])])
  36. AC_PROG_LIBTOOL
  37. # Checks for header files.
  38. AC_HEADER_STDC
  39. AC_HEADER_SYS_WAIT
  40. AC_CHECK_HEADERS([ \
  41. unistd.h \
  42. stddef.h \
  43. sys/mman.h \
  44. sys/resource.h \
  45. sys/sendfile.h \
  46. sys/types.h \
  47. sys/uio.h \
  48. sys/un.h \
  49. execinfo.h \
  50. ])
  51. # pkglibdir
  52. AC_ARG_WITH(
  53. [pkglibdir],
  54. AS_HELP_STRING([--with-pkglibdir=dir],
  55. [specify directory for driver files (default LIBDIR/lighttpd-VERSION]),
  56. [pkglibdir=$withval],
  57. [pkglibdir=$libdir/lighttpd-$PACKAGE_VERSION])
  58. AC_SUBST(pkglibdir)
  59. # libexecdir
  60. libexecdir=$libexecdir/lighttpd2
  61. AC_SUBST([libexecdir])
  62. # Checks for libraries.
  63. # glib/gthread (gthread includes glib)
  64. PKG_CHECK_MODULES([GTHREAD], [gthread-2.0 >= 2.16.0], [],[AC_MSG_ERROR("gthread-2.0 >= 2.16.0 not found")])
  65. # gmodule
  66. PKG_CHECK_MODULES([GMODULE], [gmodule-2.0 >= 2.16.0], [],[AC_MSG_ERROR("gmodule-2.0 >= 2.16.0 not found")])
  67. AC_MSG_CHECKING([for libev support])
  68. AC_ARG_WITH([libev],
  69. [AS_HELP_STRING([--with-libev@<:@=PATH@:>@],[Search for libev in PATH/include and PATH/lib])],
  70. [WITH_LIBEV=$withval],[WITH_LIBEV=yes])
  71. LIBEV_CFLAGS=""
  72. LIBEV_LIBS=""
  73. PKG_CHECK_MODULES([LIBEV], [libev], [], [
  74. # no pkg-config for libev, searching manually:
  75. if test "$WITH_LIBEV" != "yes"; then
  76. LIBEV_CFLAGS="-I$WITH_LIBEV/include"
  77. LIBEV_LIBS="-L$WITH_LIBEV/lib -lev"
  78. else
  79. AC_CHECK_HEADERS([ev.h],[
  80. AC_CHECK_LIB([ev], [ev_time], [
  81. LIBEV_LIBS="-lev"
  82. ],[
  83. AC_MSG_ERROR([libev not found])
  84. ]
  85. )],[
  86. AC_MSG_ERROR([libev not found])
  87. ]
  88. )
  89. fi
  90. ])
  91. AC_SUBST([LIBEV_CFLAGS])
  92. AC_SUBST([LIBEV_LIBS])
  93. dnl Large File Support
  94. AC_ARG_ENABLE([lfs],
  95. [AS_HELP_STRING([--disable-lfs],[disable large file support])],
  96. [case "${enableval}" in
  97. yes) lfs=true ;;
  98. no) lfs=false ;;
  99. *) AC_MSG_ERROR([bad value ${enableval} for --enable-lfs]) ;;
  100. esac],[lfs=true])
  101. if test x$lfs = xtrue; then
  102. CFLAGS="${CFLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES"
  103. fi
  104. dnl Check for gnutls
  105. AC_ARG_WITH([gnutls], [AS_HELP_STRING([--with-gnutls],[gnutls library for ssl/tls])],
  106. [WITH_GNUTLS=$withval],[WITH_GNUTLS=no])
  107. if test "$WITH_GNUTLS" != "no"; then
  108. PKG_CHECK_MODULES([GNUTLS], [gnutls],[],[
  109. AC_MSG_ERROR([gnutls not found])
  110. ])
  111. AC_SUBST([GNUTLS_CFLAGS])
  112. AC_SUBST([GNUTLS_LIBS])
  113. USE_GNUTLS=true
  114. fi
  115. AM_CONDITIONAL([USE_GNUTLS], [test "$USE_GNUTLS" = "true"])
  116. dnl Check for libidn, needed to decode SNI names
  117. AC_ARG_WITH([sni], [AS_HELP_STRING([--with-sni],[SNI support for gnutls/openssl, needs libidn])],
  118. [WITH_SNI=$withval],[WITH_SNI=no])
  119. if test "$WITH_SNI" != "no"; then
  120. PKG_CHECK_MODULES([IDN], [libidn],[],[
  121. AC_MSG_ERROR([libidn not found])
  122. ])
  123. AC_SUBST([IDN_CFLAGS])
  124. AC_SUBST([IDN_LIBS])
  125. AC_DEFINE([USE_SNI], [1], [use sni])
  126. USE_SNI=true
  127. fi
  128. AM_CONDITIONAL([USE_SNI], [test "$USE_SNI" = "true"])
  129. dnl Check for lua
  130. AC_MSG_CHECKING([for lua])
  131. AC_ARG_WITH([lua], [AS_HELP_STRING([--with-lua],[lua engine (recommended)])],
  132. [WITH_LUA=$withval],[WITH_LUA=no])
  133. AC_MSG_RESULT([$WITH_LUA])
  134. if test "$WITH_LUA" != "no"; then
  135. # try pkgconfig
  136. if test "$WITH_LUA" = "yes"; then
  137. LUAPC=lua
  138. else
  139. LUAPC=$WITH_LUA
  140. fi
  141. PKG_CHECK_MODULES([LUA], [$LUAPC >= 5.1], [
  142. AC_DEFINE([HAVE_LUA], [1], [liblua])
  143. AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
  144. ],[
  145. # for debian based systems
  146. PKG_CHECK_MODULES([LUA], [lua5.1 >= 5.1], [
  147. AC_DEFINE([HAVE_LUA], [1], [liblua])
  148. AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
  149. ],[
  150. # for freebsd
  151. PKG_CHECK_MODULES([LUA], [lua-5.1 >= 5.1], [
  152. AC_DEFINE([HAVE_LUA], [1], [liblua])
  153. AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
  154. ],[
  155. AC_MSG_ERROR([lua not found])
  156. ])
  157. ])
  158. ])
  159. AC_SUBST([LUA_CFLAGS])
  160. AC_SUBST([LUA_LIBS])
  161. USE_LUA=true
  162. fi
  163. AM_CONDITIONAL([USE_LUA], [test "$USE_LUA" = "true"])
  164. # Checks for typedefs, structures, and compiler characteristics.
  165. AC_C_CONST
  166. AC_TYPE_UID_T
  167. AC_TYPE_PID_T
  168. AC_TYPE_SIZE_T
  169. AC_HEADER_TIME
  170. ## solaris needs -lsocket -lnsl
  171. AC_SEARCH_LIBS([socket],[socket])
  172. AC_SEARCH_LIBS([inet_addr],[nsl socket])
  173. ## freebsd: kvm
  174. AC_SEARCH_LIBS([kvm_open],[kvm])
  175. ## math functions
  176. AC_SEARCH_LIBS([fmod],[m])
  177. # Checks for library functions.
  178. AC_CHECK_FUNCS([ \
  179. chroot \
  180. getrlimit \
  181. gmtime_r \
  182. inet_aton \
  183. inet_ntop \
  184. localtime_r \
  185. madvise \
  186. mmap \
  187. posix_fadvise \
  188. sendfile \
  189. sendfile64 \
  190. sendfilev \
  191. writev \
  192. accept4 \
  193. ])
  194. dnl Check for IPv6 support
  195. AC_ARG_ENABLE([ipv6],
  196. [AS_HELP_STRING([--disable-ipv6],[disable IPv6 support])],
  197. [case "${enableval}" in
  198. yes) ipv6=true ;;
  199. no) ipv6=false ;;
  200. *) AC_MSG_ERROR([bad value ${enableval} for --enable-ipv6]) ;;
  201. esac],[ipv6=true])
  202. if test x$ipv6 = xtrue; then
  203. AC_CACHE_CHECK([for IPv6 support], [ac_cv_ipv6_support],
  204. [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h>
  205. #include <sys/socket.h>
  206. #include <netinet/in.h>]], [[struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0; ]])],[ac_cv_ipv6_support=yes],[ac_cv_ipv6_support=no])])
  207. if test "$ac_cv_ipv6_support" = yes; then
  208. AC_DEFINE([HAVE_IPV6],[1],[Whether to enable IPv6 support])
  209. fi
  210. fi
  211. dnl Check for struct sockaddr_storage
  212. AC_CACHE_CHECK([for struct sockaddr_storage support], [ac_cv_sockaddr_storage_support],
  213. [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <sys/socket.h> ]], [[struct sockaddr_storage s; ]])],[ac_cv_sockaddr_storage_support=yes],[ac_cv_sockaddr_storage_support=no])])
  214. if test "ac_cv_sockaddr_storage_support" = yes; then
  215. AC_DEFINE([HAVE_SOCKADDR_STORAGE],[1],[Whether we have struct sockaddr_storage])
  216. fi
  217. dnl Checking for libunwind
  218. AC_MSG_CHECKING(for libunwind)
  219. AC_ARG_WITH(libunwind,
  220. AC_HELP_STRING([--with-libunwind],[Include libunwind support for backtraces on assert failures]),
  221. [WITH_LIBUNWIND=$withval],[WITH_LIBUNWIND=no])
  222. if test "$WITH_LIBUNWIND" != "no"; then
  223. have_libunwind=no
  224. PKG_CHECK_MODULES(LIBUNWIND, libunwind, [have_libunwind=yes], [
  225. # pkg-config failed, search manually
  226. OLDLIBS="$LIBS"
  227. LIBS="$LIBS -lunwind"
  228. AC_CACHE_CHECK([for libunwind support], [ac_cv_libunwind],
  229. [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  230. # define UNW_LOCAL_ONLY
  231. # include <libunwind.h>
  232. ]], [[
  233. unw_context_t context;
  234. unw_getcontext(&context);
  235. ]])],[ac_cv_libunwind=yes],[ac_cv_libunwind=no])])
  236. LIBS="$OLDLIBS"
  237. if test "$ac_cv_libunwind" = yes; then
  238. LIBUNWIND_CFLAGS=
  239. LIBUNWIND_LIBS=-lunwind
  240. fi
  241. have_libunwind="$ac_cv_libunwind"
  242. ])
  243. if test "$have_libunwind" = yes; then
  244. AC_DEFINE(HAVE_LIBUNWIND, 1, [Have libunwind support])
  245. else
  246. AC_MSG_ERROR("couldn't find libunwind")
  247. fi
  248. AC_SUBST([LIBUNWIND_CFLAGS])
  249. AC_SUBST([LIBUNWIND_LIBS])
  250. fi
  251. dnl Check for openssl
  252. AC_MSG_CHECKING([for OpenSSL])
  253. AC_ARG_WITH([openssl],
  254. AS_HELP_STRING([--with-openssl@<:@=DIR@:>@],[Include openssl support (default no)]),
  255. [WITH_OPENSSL=$withval],[WITH_OPENSSL=no])
  256. OPENSSL_CFLAGS=""
  257. OPENSSL_LIBS=""
  258. if test "$WITH_OPENSSL" != "no"; then
  259. use_openssl=yes
  260. if test "$WITH_OPENSSL" != "yes"; then
  261. OPENSSL_CFLAGS="-I$WITH_OPENSSL/include"
  262. OPENSSL_LIBS="-L$WITH_OPENSSL/lib"
  263. fi
  264. else
  265. use_openssl=no
  266. fi
  267. AC_MSG_RESULT([$use_openssl])
  268. AC_ARG_WITH([openssl-includes],
  269. [AS_HELP_STRING([--with-openssl-includes=DIR],[OpenSSL includes])],
  270. [ use_openssl=yes OPENSSL_CFLAGS="-I$withval" ]
  271. )
  272. AC_ARG_WITH([openssl-libs],
  273. [AS_HELP_STRING([--with-openssl-libs=DIR],[OpenSSL libraries])],
  274. [ use_openssl=yes OPENSSL_LIBS="-L$withval" ]
  275. )
  276. AC_ARG_WITH([kerberos5],
  277. [AS_HELP_STRING([--with-kerberos5],[use Kerberos5 support with OpenSSL])],
  278. [ use_kerberos=yes ], [use_kerberos=no]
  279. )
  280. if test "x$use_openssl" = "xyes"; then
  281. if test "x$use_kerberos" != "xyes"; then
  282. OPENSSL_CFLAGS="$OPENSSL_CFLAGS -DOPENSSL_NO_KRB5"
  283. fi
  284. OLD_LIBS="$LIBS"
  285. OLD_LDFLAGS="$LDFLAGS"
  286. OLD_CPPFLAGS="$CPPFLAGS"
  287. LDFLAGS="$LDFLAGS $OPENSSL_LIBS"
  288. CPPFLAGS="$CPPFLAGS $OPENSSL_CFLAGS"
  289. AC_CHECK_HEADERS([openssl/ssl.h])
  290. AC_CHECK_LIB([crypto], [BIO_f_base64], [
  291. AC_CHECK_LIB([ssl], [SSL_new], [
  292. OPENSSL_LIBS="$OPENSSL_LIBS -lssl -lcrypto"
  293. have_openssl=yes
  294. AC_DEFINE([HAVE_OPENSSL], [], [Have openssl])
  295. ], [], [ -lcrypto "$DL_LIB" ])
  296. ], [], [])
  297. LIBS="$OLD_LIBS"
  298. LDFLAGS="$OLD_LDFLAGS"
  299. CPPFLAGS="$OLD_CPPFLAGS"
  300. if test "x$have_openssl" != "xyes"; then
  301. AC_MSG_ERROR([Couldn't find openssl])
  302. fi
  303. AC_SUBST([OPENSSL_CFLAGS])
  304. AC_SUBST([OPENSSL_LIBS])
  305. fi
  306. AM_CONDITIONAL([USE_OPENSSL], [test "x$have_openssl" = "xyes"])
  307. # mod-deflate:
  308. use_mod_deflate=no
  309. # check for zlib
  310. AC_MSG_CHECKING([for zlib support])
  311. AC_ARG_WITH([zlib], [AS_HELP_STRING([--with-zlib],[Enable zlib support for mod_deflate])],
  312. [WITH_ZLIB=$withval],[WITH_ZLIB=yes])
  313. AC_MSG_RESULT([$WITH_ZLIB])
  314. if test "$WITH_BZIP2" != "no"; then
  315. AC_CHECK_LIB([z], [deflate], [
  316. AC_CHECK_HEADERS([zlib.h],[
  317. Z_LIB=-lz
  318. use_mod_deflate=yes
  319. AC_DEFINE([HAVE_ZLIB], [1], [with zlib])
  320. ])
  321. ])
  322. fi
  323. AC_SUBST([Z_LIB])
  324. # check for bzip2
  325. AC_MSG_CHECKING([for bzip2 support])
  326. AC_ARG_WITH([bzip2], [AS_HELP_STRING([--with-bzip2],[Enable bzip2 support for mod_deflate])],
  327. [WITH_BZIP2=$withval],[WITH_BZIP2=yes])
  328. AC_MSG_RESULT([$WITH_BZIP2])
  329. if test "$WITH_BZIP2" != "no"; then
  330. AC_CHECK_LIB([bz2], [BZ2_bzCompress], [
  331. AC_CHECK_HEADERS([bzlib.h],[
  332. BZ_LIB=-lbz2
  333. use_mod_deflate=yes
  334. AC_DEFINE([HAVE_BZIP], [1], [with bzip2])
  335. ])
  336. ])
  337. fi
  338. AC_SUBST([BZ_LIB])
  339. AM_CONDITIONAL([USE_MOD_DEFLATE], [test "x$use_mod_deflate" = "xyes"])
  340. AC_ARG_ENABLE([profiler],
  341. [AS_HELP_STRING([--enable-profiler],[enable memory profiler support])],[
  342. profiler=yes
  343. AC_DEFINE([WITH_PROFILER], [1], [profiler])
  344. AC_CHECK_HEADERS([execinfo.h])
  345. ],[])
  346. AM_CONDITIONAL([WITH_PROFILER], [test "x$profiler" = "xyes"])
  347. dnl search for crypt_r and (fallback) for crypt
  348. save_LIBS=$LIBS
  349. LIBS=
  350. AC_SEARCH_LIBS([crypt_r],[crypt],[
  351. AC_DEFINE([HAVE_CRYPT_R], [1], [crypt_r])
  352. AC_CHECK_HEADERS([crypt.h],[
  353. AC_DEFINE([HAVE_CRYPT_H], [1], [crypt.h])
  354. ])
  355. CRYPT_LIB=$LIBS
  356. ],[
  357. AC_SEARCH_LIBS([crypt],[crypt],[
  358. AC_CHECK_HEADERS([crypt.h],[
  359. AC_DEFINE([HAVE_CRYPT_H], [1], [crypt.h])
  360. ])
  361. CRYPT_LIB=$LIBS
  362. ])
  363. ])
  364. LIBS=$save_LIBS
  365. AC_SUBST([CRYPT_LIB])
  366. # check for extra compiler options (warning options)
  367. if test "${GCC}" = "yes"; then
  368. CFLAGS="${CFLAGS} -Wall -W -Wshadow -pedantic -std=gnu99"
  369. fi
  370. AC_ARG_ENABLE([extra-warnings],
  371. [AS_HELP_STRING([--enable-extra-warnings],[enable extra warnings (gcc specific)])],
  372. [case "${enableval}" in
  373. yes) extrawarnings=true ;;
  374. no) extrawarnings=false ;;
  375. *) AC_MSG_ERROR([bad value ${enableval} for --enable-extra-warnings]) ;;
  376. esac],[extrawarnings=false])
  377. if test x$extrawarnings = xtrue; then
  378. CFLAGS="${CFLAGS} -g -O2 -g2 -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wcast-align -Wsign-compare -Wnested-externs -Wpointer-arith -Wmissing-prototypes -Wshadow -Wno-pointer-sign -Wformat-security -Wl,--as-needed -Wl,--no-undefined"
  379. fi
  380. AC_CONFIG_FILES([Makefile \
  381. contrib/Makefile \
  382. doc/Makefile \
  383. include/Makefile \
  384. include/lighttpd/Makefile \
  385. src/Makefile \
  386. src/common/Makefile \
  387. src/main/Makefile \
  388. src/angel/Makefile \
  389. src/modules/Makefile \
  390. src/unittests/Makefile \
  391. src/lighttpd2.pc \
  392. tests/Makefile \
  393. ])
  394. AC_OUTPUT