LIBGLIB2_CONF_OPTS += --with-pcre=internal
endif
+# Purge gdb-related files
+ifneq ($(BR2_PACKAGE_GDB),y)
+define LIBGLIB2_REMOVE_GDB_FILES
+ rm -rf $(TARGET_DIR)/usr/share/glib-2.0/gdb
+endef
+endif
+
+# Purge useless binaries from target
define LIBGLIB2_REMOVE_DEV_FILES
rm -rf $(TARGET_DIR)/usr/lib/glib-2.0
- rm -rf $(TARGET_DIR)/usr/share/glib-2.0/gettext
- rmdir --ignore-fail-on-non-empty $(TARGET_DIR)/usr/share/glib-2.0
- rm -f $(addprefix $(TARGET_DIR)/usr/bin/,glib-genmarshal glib-gettextize glib-mkenums gobject-query gtester gtester-report)
+ rm -rf $(addprefix $(TARGET_DIR)/usr/share/glib-2.0/,codegen gettext)
+ rm -f $(addprefix $(TARGET_DIR)/usr/bin/,glib-compile-schemas glib-compile-resources glib-genmarshal glib-gettextize glib-mkenums gobject-query gtester gtester-report)
+ $(LIBGLIB2_REMOVE_GDB_FILES)
endef
LIBGLIB2_POST_INSTALL_TARGET_HOOKS += LIBGLIB2_REMOVE_DEV_FILES
-define LIBGLIB2_REMOVE_GDB_FILES
- rm -rf $(TARGET_DIR)/usr/share/glib-2.0/gdb
- rmdir --ignore-fail-on-non-empty $(TARGET_DIR)/usr/share/glib-2.0
+# Remove schema sources/DTDs, we use staging ones to compile them.
+# Do so at target finalization since other packages install additional
+# ones and we want to deal with it in a single place.
+define LIBGLIB2_REMOVE_TARGET_SCHEMAS
+ rm -f $(TARGET_DIR)/usr/share/glib-2.0/schemas/*.xml \
+ $(TARGET_DIR)/usr/share/glib-2.0/schemas/*.dtd
endef
-ifneq ($(BR2_PACKAGE_GDB),y)
-LIBGLIB2_POST_INSTALL_TARGET_HOOKS += LIBGLIB2_REMOVE_GDB_FILES
+# Compile schemas at target finalization since other packages install
+# them as well, and better do it in a central place.
+# It's used at run time so it doesn't matter defering it.
+define LIBGLIB2_COMPILE_SCHEMAS
+ $(HOST_DIR)/usr/bin/glib-compile-schemas \
+ $(STAGING_DIR)/usr/share/glib-2.0/schemas \
+ --targetdir=$(TARGET_DIR)/usr/share/glib-2.0/schemas
+endef
+
+ifeq ($(BR2_PACKAGE_LIBGLIB2),y)
+TARGET_FINALIZE_HOOKS += LIBGLIB2_REMOVE_TARGET_SCHEMAS
+TARGET_FINALIZE_HOOKS += LIBGLIB2_COMPILE_SCHEMAS
endif
$(eval $(autotools-package))