Permalink
Browse files

Dedicated autoconf macros for libraries detection

They live as private macros in varnish.m4, which is now included in the
Varnish build during the autogen phase. This way it is now possible to
dogfood on macros we distribute downstream. Considering how simple they
are, they could be made public macros for the convenience of VMOD or VUT
writers.

We don't need to have the LIBS-saving-dance in configure.ac for every
single dependency.
  • Loading branch information...
1 parent 76876e7 commit d6216ccaa5302456bbf097c84abd9d22868bd0ca @Dridi Dridi committed Nov 26, 2016
Showing with 29 additions and 39 deletions.
  1. +1 −1 autogen.sh
  2. +1 −1 bin/varnishd/Makefile.am
  3. +7 −37 configure.ac
  4. +20 −0 varnish.m4
View
@@ -45,7 +45,7 @@ fi
set -ex
$LIBTOOLIZE --copy --force
-aclocal -I m4
+aclocal -I m4 -I .
autoheader
automake --add-missing --copy --foreign
autoconf
@@ -157,7 +157,7 @@ varnishd_LDADD = \
@SAN_LDFLAGS@ \
@JEMALLOC_LDADD@ \
@PCRE_LIBS@ \
- ${DL_LIBS} ${PTHREAD_LIBS} ${NET_LIBS} ${LIBM} ${LIBUMEM}
+ ${DL_LIBS} ${PTHREAD_LIBS} ${NET_LIBS} ${LIBM} ${UMEM_LIBS}
noinst_PROGRAMS = vhp_gen_hufdec
vhp_gen_hufdec_SOURCES = hpack/vhp_gen_hufdec.c
View
@@ -65,40 +65,18 @@ AC_ARG_WITH([dot],
AM_CONDITIONAL(HAVE_DOT,[test "x$DOT" != "xno"])
# Checks for libraries.
-save_LIBS="${LIBS}"
-LIBS=""
-AC_CHECK_LIB(rt, clock_gettime)
-RT_LIBS="${LIBS}"
-LIBS="${save_LIBS}"
-AC_SUBST(RT_LIBS)
-
-save_LIBS="${LIBS}"
-LIBS=""
-AC_CHECK_LIB(dl, dlopen)
-DL_LIBS="${LIBS}"
-LIBS="${save_LIBS}"
-AC_SUBST(DL_LIBS)
+_VARNISH_SEARCH_LIBS(pthread, pthread_create, [thr pthread c_r])
+_VARNISH_CHECK_LIB(rt, clock_gettime)
+_VARNISH_CHECK_LIB(dl, dlopen)
+_VARNISH_CHECK_LIB(socket, socket)
+_VARNISH_CHECK_LIB(nsl, getaddrinfo)
+NET_LIBS="${SOCKET_LIBS} ${NSL_LIBS}"
AX_WITH_CURSES
if test "x$ax_cv_curses" != xyes; then
AC_MSG_ERROR([requires an X/Open-compatible Curses library])
fi
-save_LIBS="${LIBS}"
-LIBS=""
-AC_SEARCH_LIBS(pthread_create, [thr pthread c_r])
-PTHREAD_LIBS="${LIBS}"
-LIBS="${save_LIBS}"
-AC_SUBST(PTHREAD_LIBS)
-
-save_LIBS="${LIBS}"
-LIBS=""
-AC_CHECK_LIB(socket, socket)
-AC_CHECK_LIB(nsl, getaddrinfo)
-NET_LIBS="${LIBS}"
-LIBS="${save_LIBS}"
-AC_SUBST(NET_LIBS)
-
# XXX: This _may_ be for OS/X
AC_CHECK_LIBM
AC_SUBST(LIBM)
@@ -320,17 +298,9 @@ AC_SUBST(JEMALLOC_LDADD)
# Userland slab allocator, available only on Solaris
case $target in
*-*-solaris*)
- AC_CHECK_HEADERS([umem.h])
- if test "$ac_cv_have_umem_h" = yes; then
- save_LIBS="${LIBS}"
- LIBS=""
- AC_CHECK_LIB(umem, umem_alloc)
- LIBUMEM="${LIBS}"
- LIBS="${save_LIBS}"
- fi
+ AC_CHECK_HEADERS([umem.h], [_VARNISH_CHECK_LIB(umem, umem_alloc)])
;;
esac
-AC_SUBST(LIBUMEM)
# These functions are provided by libcompat on platforms where they
# are not available
View
@@ -42,6 +42,26 @@
# any time. Public macros starting with VARNISH_ are documented and will
# maintain backwards compatibility with older versions of Varnish Cache.
+# _VARNISH_CHECK_LIB(LIB, FUNC)
+# -----------------------------
+AC_DEFUN([_VARNISH_CHECK_LIB], [
+ save_LIBS="${LIBS}"
+ LIBS=""
+ AC_CHECK_LIB([$1], [$2])
+ AC_SUBST(m4_toupper($1_LIBS), [$LIBS])
+ LIBS="${save_LIBS}"
+])
+
+# _VARNISH_SEARCH_LIBS(VAR, FUNC, LIBS)
+# -------------------------------------
+AC_DEFUN([_VARNISH_SEARCH_LIBS], [
+ save_LIBS="${LIBS}"
+ LIBS=""
+ AC_SEARCH_LIBS([$2], [$3])
+ AC_SUBST(m4_toupper($1_LIBS), [$LIBS])
+ LIBS="${save_LIBS}"
+])
+
# _VARNISH_PKG_CONFIG
# --------------------
AC_DEFUN([_VARNISH_PKG_CONFIG], [

0 comments on commit d6216cc

Please sign in to comment.