From e3e0caa53eb04673341cae79e9a3e1bf0538cc93 Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Thu, 31 Mar 2016 08:54:20 +0200 Subject: [PATCH] Automatically detect protobuf (similar to Lua) No need to `--enable-protobuf`. If you want to skip protobuf detection, `--without-protobuf` is your friend. We also fail configure if `--with-protobuf=yes` and protobuf is not found. --- configure.ac | 3 +-- m4/pdns_enable_protobuf.m4 | 14 -------------- m4/pdns_with_protobuf.m4 | 27 +++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 16 deletions(-) delete mode 100644 m4/pdns_enable_protobuf.m4 create mode 100644 m4/pdns_with_protobuf.m4 diff --git a/configure.ac b/configure.ac index 1e7bb8d29..388e1c1da 100644 --- a/configure.ac +++ b/configure.ac @@ -176,6 +176,7 @@ AC_ARG_ENABLE([tools], AC_MSG_RESULT([$enable_tools]) AM_CONDITIONAL([TOOLS], [test "x$enable_tools" != "xno"]) +PDNS_WITH_PROTOBUF for a in $modules $dynmodules; do case "$a" in @@ -272,8 +273,6 @@ PDNS_ENABLE_COVERAGE PDNS_ENABLE_SANITIZERS PDNS_ENABLE_MALLOC_TRACE -PDNS_ENABLE_PROTOBUF - AC_SUBST(LIBS) AC_SUBST([AM_CPPFLAGS], diff --git a/m4/pdns_enable_protobuf.m4 b/m4/pdns_enable_protobuf.m4 deleted file mode 100644 index 4c58899e8..000000000 --- a/m4/pdns_enable_protobuf.m4 +++ /dev/null @@ -1,14 +0,0 @@ -AC_DEFUN([PDNS_ENABLE_PROTOBUF], [ - AC_MSG_CHECKING([whether to enable protobuf support]) - AC_ARG_ENABLE([protobuf], - AS_HELP_STRING([--enable-protobuf],[enable protobuf support @<:@default=no@:>@]), - [enable_protobuf=$enableval], - [enable_protobuf=no], - ) - AC_MSG_RESULT([$enable_protobuf]) - AS_IF([test "x$enable_protobuf" = "xyes"], [ - PKG_CHECK_MODULES([PROTOBUF], [protobuf], [HAVE_PROTOBUF=1], [AC_MSG_ERROR([Could not find protobuf])]) - ], [HAVE_PROTOBUF=0]) - AM_CONDITIONAL([HAVE_PROTOBUF], [test "$HAVE_PROTOBUF" -eq 1]) - AS_IF([test "$HAVE_PROTOBUF" -eq 1], [AC_DEFINE([HAVE_PROTOBUF], [1], [Define if using protobuf.])]) -]) diff --git a/m4/pdns_with_protobuf.m4 b/m4/pdns_with_protobuf.m4 new file mode 100644 index 000000000..39d4e1c96 --- /dev/null +++ b/m4/pdns_with_protobuf.m4 @@ -0,0 +1,27 @@ +AC_DEFUN([PDNS_WITH_PROTOBUF], [ + AC_MSG_CHECKING([if we need to link in protobuf]) + AC_ARG_WITH([protobuf], + AS_HELP_STRING([--with-protobuf],[enable protobuf support @<:@default=auto@:>@]), + [with_protobuf=$withval], + [with_protobuf=auto], + ) + AC_MSG_RESULT([$with_protobuf]) + + AS_IF([test "x$with_protobuf" != "xno"], [ + AS_IF([test "x$with_protobuf" = "xyes" -o "x$with_protobuf" = "xauto"], [ + PKG_CHECK_MODULES([PROTOBUF], [protobuf], [ ], [ ]) + AC_CHECK_PROG([PROTOC], [protoc], [protoc]) + ]) + ]) + AS_IF([test "x$with_protobuf" = "xyes"], [ + AS_IF([test x"$PROTOBUF_LIBS" = "x"], [ + AC_MSG_ERROR([Protobuf requested but libraries were not found]) + ]) + AS_IF([test x"$PROTOC" = "x"], [ + AC_MSG_ERROR([Protobuf requested but the protobuf compiler was not found]) + ]) + ]) + AM_CONDITIONAL([HAVE_PROTOBUF], [test x"$PROTOBUF_LIBS" != "x"]) + AM_CONDITIONAL([HAVE_PROTOC], [test x"$PROTOC" != "x"]) + AS_IF([test x"$PROTOBUF_LIBS" != "x"], [AC_DEFINE([HAVE_PROTOBUF], [1], [Define if using protobuf.])]) +]) -- 2.40.0