Permalink
Browse files

Add helper macros for enable/disable plugin granularity

* GP_ARG_DISABLE -- wrapper over AC_ARG_ENABLE for plugins
* GP_CHECK_PLUGIN_DEPS -- wrapper for PKG_CHECK_MODULES

git-svn-id: https://geany-plugins.svn.sourceforge.net/svnroot/geany-plugins/trunk/geany-plugins@1704 e8383189-8249-0410-b506-acc975200cbd
  • Loading branch information...
hyperair committed Nov 5, 2010
1 parent fc3309f commit 9ed7b87f2245d4c9842c1c9dc628d22513497966
Showing with 37 additions and 0 deletions.
  1. +37 −0 build/common.m4
View
@@ -0,0 +1,37 @@
+dnl GP_ARG_DISABLE(PluginName, default)
+dnl - default can either be yes(enabled) or no(disabled)
+dnl Generates --enable/disable options with help strings
+
+AC_DEFUN([GP_ARG_DISABLE],
+[
+ AC_ARG_ENABLE(m4_tolower(AS_TR_SH($1)),
+ AS_HELP_STRING(m4_join(-,
+ --m4_if($2, no, enable, disable),
+ m4_tolower(AS_TR_SH($1))),
+ [Do not build the $1 plugin]),
+ m4_tolower(AS_TR_SH(enable_$1))=$enableval,
+ m4_tolower(AS_TR_SH(enable_$1))=$2)
+
+ dnl if enableval is not auto, then we make the decision here. Otherwise this
+ dnl this needs to be done in GP_CHECK_PLUGIN_DEPS
+ if test "$m4_tolower(AS_TR_SH(enable_$1))" != "auto"; then
+ AM_CONDITIONAL(m4_toupper(ENABLE_$1),
+ test "m4_tolower($AS_TR_SH(enable_$1))" = "yes")
+ fi
+])
+
+dnl GP_CHECK_PLUGIN_DEPS(PluginName, VARIABLE-PREFIX, modules...)
+dnl Checks whether modules exist using PKG_CHECK_MODULES, and enables/disables
+dnl plugins appropriately if enable_$plugin=auto
+AC_DEFUN([GP_CHECK_PLUGIN_DEPS],
+[
+ if test "$m4_tolower(AS_TR_SH(enable_$1))" = "yes"; then
+ PKG_CHECK_MODULES($2, $3)
+ elif test "$m4_tolower(AS_TR_SH(enable_$1))" = "auto"; then
+ PKG_CHECK_MODULES($2, $3,
+ [m4_tolower(AS_TR_SH(enable_$1))=yes],
+ [m4_tolower(AS_TR_SH(enable_$1))=no])
+ fi
+
+ AM_CONDITIONAL(m4_toupper(ENABLE_$2), test "$m4_tolower(AS_TR_SH(enable_$1_)" = yes)
+])

0 comments on commit 9ed7b87

Please sign in to comment.