m4: provide additional pkg-config macros
The macros provide a succint way to run a pkg-config check over modules depending on a --with-name configure option. There is a flexible variant to have custom behaviour if the package is found or not and two more limited ones that just set HAVE_NAME make and preprocessor variables.pull/15/head
parent
6759cdb4ef
commit
5f35ec35a8
74
pkg.m4
74
pkg.m4
|
@ -157,3 +157,77 @@ else
|
||||||
$3
|
$3
|
||||||
fi[]dnl
|
fi[]dnl
|
||||||
])# PKG_CHECK_MODULES
|
])# PKG_CHECK_MODULES
|
||||||
|
|
||||||
|
# PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
|
||||||
|
# [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
|
||||||
|
# [DESCRIPTION], [DEFAULT])
|
||||||
|
#
|
||||||
|
# Prepare a "--with-" configure option using the lowercase [VARIABLE-PREFIX]
|
||||||
|
# name, merging the behaviour of AC_ARG_WITH and PKG_CHECK_MODULES in a single
|
||||||
|
# macro
|
||||||
|
#
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
AC_DEFUN([PKG_WITH_MODULES],
|
||||||
|
[
|
||||||
|
m4_pushdef([with_arg], m4_tolower([$1]))
|
||||||
|
|
||||||
|
m4_pushdef([description],
|
||||||
|
[m4_default([$5], [build with ]with_arg[ support])])
|
||||||
|
|
||||||
|
m4_pushdef([def_arg], [m4_default([$6], [auto])])
|
||||||
|
m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
|
||||||
|
m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
|
||||||
|
|
||||||
|
m4_case(def_arg,
|
||||||
|
[yes],[m4_pushdef([with_without], [--without-]with_arg)],
|
||||||
|
[m4_pushdef([with_without],[--with-]with_arg)])
|
||||||
|
|
||||||
|
AC_ARG_WITH(with_arg,
|
||||||
|
AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
|
||||||
|
[AS_TR_SH([with_]with_arg)=def_arg])
|
||||||
|
|
||||||
|
AS_CASE([$AS_TR_SH([with_]with_arg)],
|
||||||
|
[yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
|
||||||
|
[auto],[PKG_CHECK_MODULES([$1],[$2],
|
||||||
|
[m4_n([def_action_if_found]) $3],
|
||||||
|
[m4_n([def_action_if_not_found]) $4])])
|
||||||
|
|
||||||
|
m4_popdef([with_arg])
|
||||||
|
m4_popdef([description])
|
||||||
|
m4_popdef([def_arg])
|
||||||
|
|
||||||
|
]) dnl PKG_WITH_MODULES
|
||||||
|
|
||||||
|
# PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
|
||||||
|
# [DESCRIPTION], [DEFAULT])
|
||||||
|
#
|
||||||
|
# Convenience macro to trigger AM_CONDITIONAL after
|
||||||
|
# PKG_WITH_MODULES check.
|
||||||
|
#
|
||||||
|
# HAVE_[VARIABLE-PREFIX] is exported as make variable.
|
||||||
|
#
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
AC_DEFUN([PKG_HAVE_WITH_MODULES],
|
||||||
|
[
|
||||||
|
PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
|
||||||
|
|
||||||
|
AM_CONDITIONAL([HAVE_][$1],
|
||||||
|
[test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
|
||||||
|
])
|
||||||
|
|
||||||
|
# PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
|
||||||
|
# [DESCRIPTION], [DEFAULT])
|
||||||
|
#
|
||||||
|
# Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
|
||||||
|
# PKG_WITH_MODULES check.
|
||||||
|
#
|
||||||
|
# HAVE_[VARIABLE-PREFIX] is exported as make and preprocessor variable.
|
||||||
|
#
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
|
||||||
|
[
|
||||||
|
PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
|
||||||
|
|
||||||
|
AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
|
||||||
|
[AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
|
||||||
|
])
|
||||||
|
|
Loading…
Reference in New Issue