NAME    = gsettings-desktop-schemas
VERSION = 50.1

CATEGORIES = utils

DESCRIPTION = GSettings desktop-wide schemas
define BLURB
Collection of GSettings schemas for desktop settings shared across
GTK3/GNOME applications, including file chooser, proxy, datetime,
network, and other desktop configuration schemas.
endef

DYNURLS          = https://github.com/GNOME/gsettings-desktop-schemas/archive/refs/tags/50.1.tar.gz
GITHUB_REFERENCE = 50.1.tar.gz
DISTFILES        = gsettings-desktop-schemas-50.1.tar.gz

LICENSE = COPYING

WORKSRC = $(WORKDIR)/gsettings-desktop-schemas-50.1

# Pure schema package -- no build system needed
CONFIGURE_SCRIPTS =
BUILD_SCRIPTS     =
INSTALL_SCRIPTS   =
TEST_SCRIPTS      =

PACKAGES                              = OZSWgsettingsschemas
SPKG_DESC_OZSWgsettingsschemas        = GSettings desktop-wide schemas
SPKG_CLASSES                          = cswdictconf
RUNTIME_DEP_PKGS_OZSWgsettingsschemas = OZSWglib OZSWgtk3

include gar/category.mk

.DEFAULT_GOAL := all

SCHEMADIR = $(datadir)/glib-2.0/schemas

pre-install:
	mkdir -p $(DESTDIR)$(SCHEMADIR)
	# Install only the gnome schemas (gtk3 owns org.gtk.Settings.*.gschema.xml)
	for f in $(WORKSRC)/schemas/*.gschema.xml.in; do \
	    base=$$(basename $$f .in); \
	    /usr/bin/gsed 's|@datadir@|$(BUILD_PREFIX)/share|g' $$f \
	        > $(DESTDIR)$(SCHEMADIR)/$$base; \
	done
	# Compile gschemas.compiled using a tmpdir with all schemas combined
	# (both our new ones and the already-installed gtk3 schemas) so the
	# compiled binary is complete on the target system.
	tmpdir=$$(mktemp -d /tmp/gschemas.XXXXXX); \
	cp $(BUILD_PREFIX)/share/glib-2.0/schemas/*.gschema.xml $$tmpdir/ 2>/dev/null || true; \
	cp $(DESTDIR)$(SCHEMADIR)/*.gschema.xml $$tmpdir/; \
	$(BUILD_PREFIX)/bin/glib-compile-schemas $$tmpdir/ 2>/dev/null || true; \
	cp $$tmpdir/gschemas.compiled $(DESTDIR)$(SCHEMADIR)/; \
	rm -rf $$tmpdir
	@$(MAKECOOKIE)
