1dnl _GP_ARG_DISABLE_ALL
2dnl Adds the --disable-all-plugins option
3dnl Sets gp_enable_all=[$enableval|auto]
4AC_DEFUN([_GP_ARG_DISABLE_ALL],
5[
6    AC_ARG_ENABLE([all-plugins],
7                  [AS_HELP_STRING([--disable-all-plugins],
8                                  [Disable all plugins])],
9                  [gp_enable_all=$enableval],
10                  [gp_enable_all=auto])
11])
12
13dnl GP_ARG_DISABLE(PluginName, default)
14dnl - default can either be yes(enabled) or no(disabled), or auto(to be used
15dnl   with GP_CHECK_PLUGIN_DEPS)
16dnl Generates --enable/disable options with help strings
17AC_DEFUN([GP_ARG_DISABLE],
18[
19    AC_REQUIRE([_GP_ARG_DISABLE_ALL])
20
21    AC_ARG_ENABLE(m4_tolower(AS_TR_SH($1)),
22        AS_HELP_STRING(m4_join(-,
23                               --m4_if($2, no, enable, disable),
24                               m4_tolower(AS_TR_SH($1))),
25                       [Do not build the $1 plugin]),
26        m4_tolower(AS_TR_SH(enable_$1))=$enableval,
27        [AS_CASE([$gp_enable_all],
28                 [no],  [m4_tolower(AS_TR_SH(enable_$1))=no],
29                 [yes], [m4_tolower(AS_TR_SH(enable_$1))=yes],
30                        [m4_tolower(AS_TR_SH(enable_$1))=$2])])
31])
32
33dnl GP_CHECK_PLUGIN_DEPS(PluginName, VARIABLE-PREFIX,  modules...)
34dnl Checks whether modules exist using PKG_CHECK_MODULES, and error
35dnl out/disables plugins appropriately depending on enable_$plugin
36AC_DEFUN([GP_CHECK_PLUGIN_DEPS],
37[
38    AC_REQUIRE([GP_CHECK_GTK_VERSION])
39
40    gtk_dep=m4_bmatch([$3], [gtk\+-2\.0], [2], [gtk\+-3\.0], [3], [0])
41    if test $gtk_dep -ne 0; then
42        GP_CHECK_PLUGIN_GTKN_ONLY([$1], [$gtk_dep])
43    fi
44
45    if test "$m4_tolower(AS_TR_SH(enable_$1))" = "yes"; then
46        PKG_CHECK_MODULES([$2], [$3])
47    elif test "$m4_tolower(AS_TR_SH(enable_$1))" = "auto"; then
48        PKG_CHECK_MODULES([$2], [$3],
49                          [],
50                          [m4_tolower(AS_TR_SH(enable_$1))=no])
51    fi
52])
53
54dnl GP_COMMIT_PLUGIN_STATUS(PluginName)
55dnl Commits the enabled status of a plugin
56dnl This macro must be called once for each plugin after all other GP macros.
57AC_DEFUN([GP_COMMIT_PLUGIN_STATUS],
58[
59    dnl if choice wasn't made yet, enable it
60    if test "$m4_tolower(AS_TR_SH(enable_$1))" = "auto"; then
61        m4_tolower(AS_TR_SH(enable_$1))=yes
62    fi
63    AM_CONDITIONAL(m4_toupper(AS_TR_SH(ENABLE_$1)),
64                   test "$m4_tolower(AS_TR_SH(enable_$1))" = yes)
65    GP_STATUS_PLUGIN_ADD([$1], [$m4_tolower(AS_TR_SH(enable_$1))])
66])
67
68dnl GP_CHECK_MINGW
69dnl Checks whether we're building for MinGW, and defines appropriate stuff
70dnl if it is the case.
71dnl Most importantly, AM_CODITIONALs MINGW
72AC_DEFUN([GP_CHECK_MINGW],
73[
74	case "${host}" in
75		*mingw*)
76			AC_DEFINE([WIN32], [1], [we are cross compiling for WIN32])
77			AM_CONDITIONAL([MINGW], true)
78			;;
79		*)
80			AM_CONDITIONAL([MINGW], false)
81			;;
82	esac
83])
84