[config] Make macros more robust

- FORK_ macros now correctly ignore non-empty but blank default actions
- Removed test variable left in last commit
This commit is contained in:
Scott Shambarger 2017-01-06 12:49:57 -08:00
parent ce4ef0aa23
commit c4195239d2
2 changed files with 17 additions and 16 deletions

View File

@ -18,10 +18,10 @@ AC_PROG_SED
AC_PROG_MKDIR_P AC_PROG_MKDIR_P
LT_INIT([disable-static]) LT_INIT([disable-static])
AC_PATH_PROG([GPERF], [gperf]) AC_PATH_PROG([GPERF], [[gperf]])
AS_IF([[test -z "$GPERF"]], AS_IF([[test -z "$GPERF"]],
[AS_IF([[test -f "$srcdir/src/dmap_fields_hash.h"]], [AS_IF([[test -f "$srcdir/src/dmap_fields_hash.h"]],
[AM_MISSING_PROG([GPERF], [gperf]) [AM_MISSING_PROG([GPERF], [[gperf]])
AC_MSG_NOTICE([[ AC_MSG_NOTICE([[
GNU gperf not found, but it's output appears to be present. GNU gperf not found, but it's output appears to be present.
@ -30,11 +30,10 @@ to install it.]])],
[AC_MSG_ERROR([[GNU gperf required, please install it.]])]) [AC_MSG_ERROR([[GNU gperf required, please install it.]])])
]) ])
AC_DEFUN([antlr3], [FAIL_TEST]) AC_PATH_PROG([ANTLR], [[antlr3]])
AC_PATH_PROG([ANTLR], [antlr3])
AS_IF([[test -z "$ANTLR"]], AS_IF([[test -z "$ANTLR"]],
[AS_IF([[test -f "$srcdir/src/SMARTPLLexer.h"]], [AS_IF([[test -f "$srcdir/src/SMARTPLLexer.h"]],
[AM_MISSING_PROG([ANTLR], [antlr3]) [AM_MISSING_PROG([ANTLR], [[antlr3]])
AC_MSG_NOTICE([[ AC_MSG_NOTICE([[
antlr3 not found, but it's output appears to be present. antlr3 not found, but it's output appears to be present.
@ -250,7 +249,7 @@ FORK_ARG_ENABLE([LastFM support], [lastfm], [LASTFM],
AM_CONDITIONAL([COND_LASTFM], [[test "x$enable_lastfm" = "xyes"]]) AM_CONDITIONAL([COND_LASTFM], [[test "x$enable_lastfm" = "xyes"]])
dnl ChromeCast support with libprotobuf-c dnl ChromeCast support with libprotobuf-c
FORK_ARG_ENABLE([ChromeCast support], [chromecast], [CHROMECAST], FORK_ARG_ENABLE([Chromecast support], [chromecast], [CHROMECAST],
[AS_IF([[test "x$with_json" = "xno"]], [AS_IF([[test "x$with_json" = "xno"]],
[AC_MSG_ERROR([[Chromecast support requires json-c]])]) [AC_MSG_ERROR([[Chromecast support requires json-c]])])
FORK_MODULES_CHECK([FORKED], [LIBPROTOBUF_C], FORK_MODULES_CHECK([FORKED], [LIBPROTOBUF_C],

View File

@ -31,7 +31,7 @@ dnl with working CPPFLAGS/LIBS for additional checks. DESCRIPTION used as
dnl friendly name in error messages to help user identify software. dnl friendly name in error messages to help user identify software.
dnl Restores original CPPFLAGS and LIBS when done. Expands dnl Restores original CPPFLAGS and LIBS when done. Expands
dnl ACTION-IF-NOT-FOUND if ENV_* not set, and FUNCTION in LIBRARY not dnl ACTION-IF-NOT-FOUND if ENV_* not set, and FUNCTION in LIBRARY not
dnl found overriding default error. (NOTE: default must be empty to get error) dnl found overriding default error.
AC_DEFUN([FORK_LIB_REQUIRE], AC_DEFUN([FORK_LIB_REQUIRE],
[AS_VAR_PUSHDEF([FORK_MSG], [fork_msg_$3]) [AS_VAR_PUSHDEF([FORK_MSG], [fork_msg_$3])
AC_ARG_VAR([$3_CFLAGS], [C compiler flags for $2, overriding search]) AC_ARG_VAR([$3_CFLAGS], [C compiler flags for $2, overriding search])
@ -55,7 +55,8 @@ and $3_LIBS."]])
$1_LIBS="-l$4 $][$1_LIBS"] $1_LIBS="-l$4 $][$1_LIBS"]
AC_TRY_LINK_FUNC([[$5]], [AC_MSG_RESULT([[-l$4]])], AC_TRY_LINK_FUNC([[$5]], [AC_MSG_RESULT([[-l$4]])],
[AC_MSG_RESULT([[no]]) [AC_MSG_RESULT([[no]])
m4_default([$8], [AC_MSG_FAILURE([[Function $5 in lib$4 not found.$]FORK_MSG])])]) m4_default_nblank([$8],
[AC_MSG_FAILURE([[Function $5 in lib$4 not found.$]FORK_MSG])])])
]) ])
]) ])
]) ])
@ -74,8 +75,7 @@ dnl FUNCTION and include HEADER. Appends working package values to
dnl TARGET_CPPFLAGS and TARGET_LIBS. Expands optional ACTION-IF-FOUND with dnl TARGET_CPPFLAGS and TARGET_LIBS. Expands optional ACTION-IF-FOUND with
dnl working CPPFLAGS/LIBS for additional checks. Expands dnl working CPPFLAGS/LIBS for additional checks. Expands
dnl ACTION-IF-NOT-FOUND only if package not found (not link/include failures) dnl ACTION-IF-NOT-FOUND only if package not found (not link/include failures)
dnl overriding default error. (NOTE: default must be empty to get error!) dnl overriding default error. Restores original CPPFLAGS and LIBS when done.
dnl Restores original CPPFLAGS and LIBS when done.
AC_DEFUN([FORK_MODULES_CHECK], AC_DEFUN([FORK_MODULES_CHECK],
[PKG_CHECK_MODULES([$2], [[$3]], [PKG_CHECK_MODULES([$2], [[$3]],
[[save_$2_LIBS=$LIBS; save_$2_CPPFLAGS=$CPPFLAGS] [[save_$2_LIBS=$LIBS; save_$2_CPPFLAGS=$CPPFLAGS]
@ -85,7 +85,8 @@ AC_DEFUN([FORK_MODULES_CHECK],
m4_ifval([$5], [AC_CHECK_HEADER([[$5]], [], m4_ifval([$5], [AC_CHECK_HEADER([[$5]], [],
[AC_MSG_ERROR([[Unable to find header $5]])])]) [AC_MSG_ERROR([[Unable to find header $5]])])])
$6 $6
[LIBS=$save_$2_LIBS; CPPFLAGS=$save_$2_CPPFLAGS]], [$7]) [LIBS=$save_$2_LIBS; CPPFLAGS=$save_$2_CPPFLAGS]],
m4_default_nblank_quoted([$7]))
]) ])
dnl FORK_ARG_WITH_CHECK(TARGET, DESCRIPTION, OPTION, ENV, MODULES, [FUNCTION], dnl FORK_ARG_WITH_CHECK(TARGET, DESCRIPTION, OPTION, ENV, MODULES, [FUNCTION],
@ -96,9 +97,9 @@ dnl if they are available). Expands FORK_MODULES_CHECK with remaining
dnl arguments. Defines HAVE_ENV to 1 if package found. DESCRIPTION is used dnl arguments. Defines HAVE_ENV to 1 if package found. DESCRIPTION is used
dnl in option help. Shell variable with_OPTION set to yes before dnl in option help. Shell variable with_OPTION set to yes before
dnl ACTION-IF-FOUND. Default ACTION-IF-NOT-FOUND will fail dnl ACTION-IF-FOUND. Default ACTION-IF-NOT-FOUND will fail
dnl if --with-OPTION given, and MODULES not found, or sets shell var dnl if --with-OPTION given and MODULES not found, or sets shell var
dnl with_OPTION to no (setting NOT-FOUND overrides this behavior to allow dnl with_OPTION to no if option was check. A non-empty ACTION-IF-NOT-FOUND
dnl alternate checks). dnl overrides this behavior to allow alternate checks.
AC_DEFUN([FORK_ARG_WITH_CHECK], AC_DEFUN([FORK_ARG_WITH_CHECK],
[AC_ARG_WITH([[$3]], [AS_HELP_STRING([--with-$3], [AC_ARG_WITH([[$3]], [AS_HELP_STRING([--with-$3],
[with $2 (default=check)])], [], [with $2 (default=check)])], [],
@ -109,9 +110,10 @@ AC_DEFUN([FORK_ARG_WITH_CHECK],
AC_DEFINE([HAVE_$4], 1, AC_DEFINE([HAVE_$4], 1,
[Define to 1 to build with $2]) [Define to 1 to build with $2])
$8], $8],
[m4_default([$9], [AS_IF([[test "x$with_$3" != "xcheck"]], [m4_default_nblank([$9], [AS_IF([[test "x$with_$3" != "xcheck"]],
[AC_MSG_FAILURE([[--with-$3 was given, but test for $5 failed]])]) [AC_MSG_FAILURE([[--with-$3 was given, but test for $5 failed]])])
[with_$3=no]])])dnl keep default empty! [with_$3=no]])
])
]) ])
]) ])