b68698980165bc9bc9aafcde5fe9d7de7ed01375
[empathy.git] / m4 / gsettings.m4
1 dnl GLIB_GSETTINGS
2 dnl Defines GSETTINGS_SCHEMAS_INSTALL which controls whether
3 dnl the schema should be compiled
4 dnl
5
6 AC_DEFUN([GLIB_GSETTINGS],
7 [
8   m4_pattern_allow([AM_V_GEN])
9   AC_ARG_ENABLE(schemas-compile,
10                 AC_HELP_STRING([--disable-schemas-compile],
11                                [Disable regeneration of gschemas.compiled on install]),
12                 [case ${enableval} in
13                   yes) GSETTINGS_DISABLE_SCHEMAS_COMPILE=""  ;;
14                   no)  GSETTINGS_DISABLE_SCHEMAS_COMPILE="1" ;;
15                   *) AC_MSG_ERROR([bad value ${enableval} for --enable-schemas-compile]) ;;
16                  esac])
17   AC_SUBST([GSETTINGS_DISABLE_SCHEMAS_COMPILE])
18   PKG_PROG_PKG_CONFIG([0.16])
19   AC_SUBST(gsettingsschemadir, [${datadir}/glib-2.0/schemas])
20   AC_SUBST(GLIB_COMPILE_SCHEMAS, `$PKG_CONFIG --variable glib_compile_schemas gio-2.0`)
21   if test "x$GLIB_COMPILE_SCHEMAS" = "x"; then
22     AC_MSG_ERROR([glib-compile-schemas not found.])
23   fi
24
25   GSETTINGS_RULES='
26 .PHONY : uninstall-gsettings-schemas install-gsettings-schemas clean-gsettings-schemas
27
28 mostlyclean-am: clean-gsettings-schemas
29
30 %.gschema.valid: %.gschema.xml
31         $(AM_V_GEN) if test -f "$^"; then d=; else d="$(srcdir)/"; fi; $(GLIB_COMPILE_SCHEMAS) --dry-run --schema-file=$${d}$^ && touch [$]@
32
33 all-am: $(gsettings_SCHEMAS:.xml=.valid)
34 uninstall-am: uninstall-gsettings-schemas
35 install-data-am: install-gsettings-schemas
36
37 .SECONDARY: $(gsettings_SCHEMAS)
38
39 gsettings__base_list = \
40   sed "$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g" | \
41   sed "$$!N;$$!N;$$!N;$$!N;s/\n/ /g"
42
43 install-gsettings-schemas: $(gsettings_SCHEMAS:.xml=.valid)
44         @$(NORMAL_INSTALL)
45         test -z "$(gsettingsschemadir)" || $(MKDIR_P) "$(DESTDIR)$(gsettingsschemadir)"
46         @list='\''$(gsettings_SCHEMAS)'\''; test -n "$(gsettingsschemadir)" || list=; \
47         for p in $$list; do \
48           if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
49           echo "$$d$$p"; \
50         done | $(gsettings__base_list) | \
51         while read files; do \
52           echo " $(INSTALL_DATA) $$files '\''$(DESTDIR)$(gsettingsschemadir)'\''"; \
53           $(INSTALL_DATA) $$files "$(DESTDIR)$(gsettingsschemadir)" || exit $$?; \
54         done
55         test -n "$(GSETTINGS_DISABLE_SCHEMAS_COMPILE)$(DESTDIR)" || $(GLIB_COMPILE_SCHEMAS) $(gsettingsschemadir)
56
57 uninstall-gsettings-schemas:
58         @$(NORMAL_UNINSTALL)
59         @list='\''$(gsettings_SCHEMAS)'\''; test -n "$(gsettingsschemadir)" || list=; \
60         files=`for p in $$list; do echo $$p; done | sed -e '\''s|^.*/||'\''`; \
61         test -n "$$files" || exit 0; \
62         echo " ( cd '\''$(DESTDIR)$(gsettingsschemadir)'\'' && rm -f" $$files ")"; \
63         cd "$(DESTDIR)$(gsettingsschemadir)" && rm -f $$files
64         test -n "$(GSETTINGS_DISABLE_SCHEMAS_COMPILE)$(DESTDIR)" || $(GLIB_COMPILE_SCHEMAS) --uninstall $(gsettingsschemadir)
65
66 clean-gsettings-schemas:
67         rm -f $(gsettings_SCHEMAS:.xml=.valid)
68
69 '
70   _GSETTINGS_SUBST(GSETTINGS_RULES)
71 ])
72
73 dnl _GSETTINGS_SUBST(VARIABLE)
74 dnl Abstract macro to do either _AM_SUBST_NOTMAKE or AC_SUBST
75 AC_DEFUN([_GSETTINGS_SUBST],
76 [
77 AC_SUBST([$1])
78 m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([$1])])
79 ]
80 )