mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 18:08:03 +02:00
[configure.ac.enable] Add all-powerful hook registration macro
This commit is contained in:
parent
61ef0ebdc3
commit
7d39e4cbd7
1 changed files with 73 additions and 9 deletions
|
|
@ -6,6 +6,7 @@ dnl cairo-features.h and other generated files.
|
|||
dnl
|
||||
|
||||
dnl ===========================================================================
|
||||
|
||||
dnl
|
||||
dnl cairo_cache_version should be increased every time that the feature
|
||||
dnl detection stuff changes in a way that removing the config.cache file may be
|
||||
|
|
@ -14,10 +15,9 @@ dnl changes; it doesn't have any effect on any other cached thing.)
|
|||
dnl
|
||||
m4_define(cairo_cache_version, 5)
|
||||
|
||||
dnl ===========================================================================
|
||||
dnl
|
||||
dnl Define a macro to enable features
|
||||
dnl - Macro: _CAIRO_ENABLE_FULL (ID, NAME, ARG, TAG, DEFAULT, WHAT, COMMANDS)
|
||||
dnl - Macro: _CAIRO_ENABLE_FULL (ID, NAME, ARG, TAG, WHAT, DEFAULT, COMMANDS)
|
||||
dnl
|
||||
dnl where:
|
||||
dnl
|
||||
|
|
@ -26,10 +26,10 @@ dnl NAME is the human-readable name of the feature, eg. "FreeType font"
|
|||
dnl ARG is what enables the feature, eg. "ft" for --enable-ft
|
||||
dnl TAG is the feature conditional, eg. CAIRO_HAS_FT_FONT
|
||||
dnl WHAT is the type of feature:
|
||||
dnl "surface" for surface backends
|
||||
dnl "font" for font backends
|
||||
dnl "functions" for set of functions
|
||||
dnl "" for private configurations
|
||||
dnl "surface" for surface backends
|
||||
dnl "font" for font backends
|
||||
dnl "functions" for set of functions
|
||||
dnl "" for private configurations
|
||||
dnl DEFAULT is the default state of the feature:
|
||||
dnl "no" for experimental backends, eg. your favorite new backend
|
||||
dnl "yes" for mandatory backends, eg. png
|
||||
|
|
@ -53,9 +53,9 @@ AC_DEFUN([_CAIRO_ENABLE_FULL],
|
|||
m4_define([cr_feature_commands], [$7])
|
||||
|
||||
AC_ARG_ENABLE(cr_feature_arg,
|
||||
AS_HELP_STRING([--enable-]cr_feature_arg[=@<:@no/auto/yes@:>@],
|
||||
[Enable cairo's ]cr_feature_name[ feature @<:@default=]cr_feature_default[@:>@]),
|
||||
enable_$1=$enableval, enable_$1=cr_feature_default)
|
||||
AS_HELP_STRING([--enable-]cr_feature_arg[=@<:@no/auto/yes@:>@],
|
||||
[Enable cairo's ]cr_feature_name[ feature @<:@default=]cr_feature_default[@:>@]),
|
||||
enable_$1=$enableval, enable_$1=cr_feature_default)
|
||||
case $enable_$1 in
|
||||
no)
|
||||
use_$1="no (disabled, use --enable-cr_feature_arg to enable)"
|
||||
|
|
@ -101,6 +101,10 @@ AC_DEFUN([_CAIRO_ENABLE_FULL],
|
|||
])
|
||||
])
|
||||
|
||||
|
||||
_CAIRO_FEATURE_HOOKS(cr_feature, cr_feature_name, cr_feature_default, cr_feature_what)
|
||||
|
||||
|
||||
if test "x$use_$1" = xyes; then
|
||||
|
||||
CAIRO_FEATURE_VARS_FOREACH([cr_var], [[test -n "$]cr_feature[_]cr_var[" && CAIRO_]cr_var[="$]cr_feature[_]cr_var[ $CAIRO_]cr_var["]
|
||||
|
|
@ -255,6 +259,7 @@ AC_DEFUN([CAIRO_ENABLE_FUNCTIONS],
|
|||
|
||||
|
||||
dnl ===========================================================================
|
||||
|
||||
dnl
|
||||
dnl CAIRO_FEATURE_VARS_REGISTER(VARS, INITIAL-VALUE=[])
|
||||
dnl
|
||||
|
|
@ -283,6 +288,65 @@ AC_DEFUN([CAIRO_FEATURE_VARS_FOREACH],
|
|||
m4_foreach_w([$1], m4_expand(CAIRO_FEATURE_VARS), [$2])
|
||||
])
|
||||
|
||||
dnl ===========================================================================
|
||||
|
||||
m4_define([_CAIRO_FEATURE_HOOK_MATCH],
|
||||
[
|
||||
m4_case([$1],
|
||||
[*], [$3],
|
||||
[$2], [$3],
|
||||
[!$2], ,
|
||||
[m4_bmatch([$1], [^!], [$3])])
|
||||
])
|
||||
|
||||
m4_define([_CAIRO_FEATURE_HOOKS])
|
||||
|
||||
dnl
|
||||
dnl CAIRO_FEATURE_HOOK_REGISTER(WHAT, DEFAULT, COMMANDS)
|
||||
dnl
|
||||
dnl Runs COMMANDS for features matching WHAT and DEFAULT.
|
||||
dnl
|
||||
dnl WHAT and DEFAULT are matched like this:
|
||||
dnl [*] matches all values
|
||||
dnl [val] matches [val]
|
||||
dnl [!val] matches anything other than [val]
|
||||
dnl
|
||||
dnl The following macros can be used in COMMANDS:
|
||||
dnl
|
||||
dnl cr_feature expands to the feature id, eg "ft"
|
||||
dnl cr_feature_name expands to the human-readable name of the feature, eg. "FreeType font"
|
||||
dnl cr_feature_default expands to the default state of the feature:
|
||||
dnl "no" for experimental backends, eg. your favorite new backend
|
||||
dnl "yes" for mandatory backends, eg. png
|
||||
dnl "auto" for other supported backends, eg. xlib
|
||||
dnl cr_what expands to the type of feature:
|
||||
dnl "surface" for surface backends
|
||||
dnl "font" for font backends
|
||||
dnl "functions" for set of functions
|
||||
dnl "" for private configurations
|
||||
dnl
|
||||
dnl These four values are also set as $1 to $4. To know if feature was
|
||||
dnl enabled, compare $use_$1 to string "yes". As in:
|
||||
dnl
|
||||
dnl AS_IF([test "x$use_$1" = "xyes"],
|
||||
dnl [
|
||||
dnl code goes here...
|
||||
dnl ])
|
||||
dnl
|
||||
dnl Hooks are run for each feature in the order they are added.
|
||||
dnl
|
||||
AC_DEFUN([CAIRO_FEATURE_HOOK_REGISTER],
|
||||
[
|
||||
m4_append([_CAIRO_FEATURE_HOOKS],
|
||||
[
|
||||
_CAIRO_FEATURE_HOOK_MATCH(m4_expand([$1]), cr_feature_what,
|
||||
[_CAIRO_FEATURE_HOOK_MATCH(m4_expand([$2]), cr_feature_default,
|
||||
[$3]
|
||||
)])
|
||||
], m4_newline)
|
||||
])
|
||||
|
||||
|
||||
dnl ===========================================================================
|
||||
dnl
|
||||
dnl Report
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue