mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-30 11:06:52 +02:00
Bug 619038 - increase gsettings.m4 power
handle schema checking, installation, uninstallation, cleaning
This commit is contained in:
parent
3e3779b7d0
commit
b59a5551ec
@ -228,23 +228,22 @@ produces a <filename>org.gnome.font-rendering.gschema.xml</filename> file with t
|
|||||||
Schemas are compiled into binary form by the
|
Schemas are compiled into binary form by the
|
||||||
<link linkend="glib-compile-schemas">glib-compile-schemas</link> utility.
|
<link linkend="glib-compile-schemas">glib-compile-schemas</link> utility.
|
||||||
GIO provides a <literal>glib_compile_schemas</literal>
|
GIO provides a <literal>glib_compile_schemas</literal>
|
||||||
variable for the schema compiler, which can be used in
|
variable for the schema compiler.
|
||||||
<filename>configure.in</filename> as follows:
|
</para>
|
||||||
|
<para>
|
||||||
|
You can ignore all of this by using the provided m4 macros. To
|
||||||
|
do this, add to your <filename>configure.ac</filename>:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
GLIB_GSETTINGS
|
GLIB_GSETTINGS
|
||||||
</programlisting>
|
</programlisting>
|
||||||
The corresponding <filename>Makefile.am</filename> fragment looks like
|
The corresponding <filename>Makefile.am</filename> fragment looks like
|
||||||
this:
|
this:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
# gsettingsschemadir and gschema_compile are defined by the GLIB_GSETTINGS
|
# gsettings_SCHEMAS is a list of all the schemas you want to install
|
||||||
# macro in configure.ac
|
gsettings_SCHEMAS = my.app.gschema.xml
|
||||||
gsettingsschema_DATA = my.app.gschema.xml
|
|
||||||
# This rule will check your schemas for validity before installation
|
# include the appropriate makefile rules for schema handling
|
||||||
@GSETTINGS_CHECK_RULE@
|
@GSETTINGS_RULES@
|
||||||
if GSETTINGS_SCHEMAS_INSTALL
|
|
||||||
install-data-hook:
|
|
||||||
$(GLIB_COMPILE_SCHEMAS) $(DESTDIR)$(gsettingsschemadir)
|
|
||||||
endif
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
@ -5,36 +5,67 @@ dnl
|
|||||||
|
|
||||||
AC_DEFUN([GLIB_GSETTINGS],
|
AC_DEFUN([GLIB_GSETTINGS],
|
||||||
[
|
[
|
||||||
AC_ARG_ENABLE(schemas-install,
|
m4_pattern_allow([AM_V_GEN])
|
||||||
AC_HELP_STRING([--disable-schemas-install],
|
AC_ARG_ENABLE(schemas-compile,
|
||||||
[Disable installation of GSettings schemas]),
|
AC_HELP_STRING([--disable-schemas-compile],
|
||||||
[case ${enableval} in
|
[Disable regeneration of gschemas.compiled on install]),
|
||||||
yes|no) ;;
|
[case ${enableval} in
|
||||||
*) AC_MSG_ERROR([bad value ${enableval} for --enable-schemas-install]) ;;
|
yes) GSETTINGS_DISABLE_SCHEMAS_COMPILE="" ;;
|
||||||
esac])
|
no) GSETTINGS_DISABLE_SCHEMAS_COMPILE="1" ;;
|
||||||
AM_CONDITIONAL([GSETTINGS_SCHEMAS_INSTALL], [test "$enable_schemas_install" != no])
|
*) AC_MSG_ERROR([bad value ${enableval} for --enable-schemas-compile]) ;;
|
||||||
|
esac])
|
||||||
|
AC_SUBST([GSETTINGS_DISABLE_SCHEMAS_COMPILE])
|
||||||
PKG_PROG_PKG_CONFIG([0.16])
|
PKG_PROG_PKG_CONFIG([0.16])
|
||||||
|
|
||||||
AC_SUBST(gsettingsschemadir, [${datadir}/glib-2.0/schemas])
|
AC_SUBST(gsettingsschemadir, [${datadir}/glib-2.0/schemas])
|
||||||
AC_SUBST(GLIB_COMPILE_SCHEMAS, `$PKG_CONFIG --variable glib_compile_schemas gio-2.0`)
|
AC_SUBST(GLIB_COMPILE_SCHEMAS, `$PKG_CONFIG --variable glib_compile_schemas gio-2.0`)
|
||||||
if test "x$GLIB_COMPILE_SCHEMAS" = "x"; then
|
if test "x$GLIB_COMPILE_SCHEMAS" = "x"; then
|
||||||
AC_MSG_ERROR([glib-compile-schemas not found.])
|
AC_MSG_ERROR([glib-compile-schemas not found.])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
GSETTINGS_CHECK_RULE='
|
GSETTINGS_RULES='
|
||||||
.PHONY : check-gsettings-schema
|
.PHONY : uninstall-gsettings-schemas install-gsettings-schemas clean-gsettings-schemas
|
||||||
|
|
||||||
check-gsettings-schema: gsettings_schema_validate_stamp
|
mostlyclean-am: clean-gsettings-schemas
|
||||||
MOSTLYCLEANFILES += gsettings_schema_validate_stamp
|
|
||||||
gsettings_schema_validate_stamp: *.gschema.xml
|
%.gschema.valid: %.gschema.xml
|
||||||
$(GLIB_COMPILE_SCHEMAS) --dry-run $(addprefix --schema-file=,$?)
|
$(AM_V_GEN) $(GLIB_COMPILE_SCHEMAS) --dry-run --schema-file=$^ && touch [$]@
|
||||||
touch [$]@
|
|
||||||
|
all-am: $(gsettings_SCHEMAS:.xml=.valid)
|
||||||
|
uninstall-am: uninstall-gsettings-schemas
|
||||||
|
install-data-am: install-gsettings-schemas
|
||||||
|
|
||||||
|
gsettings__base_list = \
|
||||||
|
sed "$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g" | \
|
||||||
|
sed "$$!N;$$!N;$$!N;$$!N;s/\n/ /g"
|
||||||
|
|
||||||
|
install-gsettings-schemas: $(gsettings_SCHEMAS:.xml=.valid)
|
||||||
|
@$(NORMAL_INSTALL)
|
||||||
|
test -z "$(gsettingsschemadir)" || $(MKDIR_P) "$(DESTDIR)$(gsettingsschemadir)"
|
||||||
|
@list='\''$(gsettings_SCHEMAS)'\''; test -n "$(gsettingsschemadir)" || list=; \
|
||||||
|
for p in $$list; do \
|
||||||
|
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
|
||||||
|
echo "$$d$$p"; \
|
||||||
|
done | $(gsettings__base_list) | \
|
||||||
|
while read files; do \
|
||||||
|
echo " $(INSTALL_DATA) $$files '\''$(DESTDIR)$(gsettingsschemadir)'\''"; \
|
||||||
|
$(INSTALL_DATA) $$files "$(DESTDIR)$(gsettingsschemadir)" || exit $$?; \
|
||||||
|
done
|
||||||
|
test -n "$(GSETTINGS_DISABLE_SCHEMAS_COMPILE)$(DESTDIR)" || $(GLIB_COMPILE_SCHEMAS) $(gsettingsschemadir)
|
||||||
|
|
||||||
|
uninstall-gsettings-schemas:
|
||||||
|
@$(NORMAL_UNINSTALL)
|
||||||
|
@list='\''$(gsettings_SCHEMAS)'\''; test -n "$(gsettingsschemadir)" || list=; \
|
||||||
|
files=`for p in $$list; do echo $$p; done | sed -e '\''s|^.*/||'\''`; \
|
||||||
|
test -n "$$files" || exit 0; \
|
||||||
|
echo " ( cd '\''$(DESTDIR)$(gsettingsschemadir)'\'' && rm -f" $$files ")"; \
|
||||||
|
cd "$(DESTDIR)$(gsettingsschemadir)" && rm -f $$files
|
||||||
|
test -n "$(GSETTINGS_DISABLE_SCHEMAS_COMPILE)$(DESTDIR)" || $(GLIB_COMPILE_SCHEMAS) $(gsettingsschemadir)
|
||||||
|
|
||||||
|
clean-gsettings-schemas:
|
||||||
|
rm -f $(gsettings_SCHEMAS:.xml=.valid)
|
||||||
|
|
||||||
all: check-gsettings-schema
|
|
||||||
'
|
'
|
||||||
|
_GSETTINGS_SUBST(GSETTINGS_RULES)
|
||||||
_GSETTINGS_SUBST(GSETTINGS_CHECK_RULE)
|
|
||||||
])
|
])
|
||||||
|
|
||||||
dnl _GSETTINGS_SUBST(VARIABLE)
|
dnl _GSETTINGS_SUBST(VARIABLE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user