1################################################################################
2#
3# libglib2
4#
5################################################################################
6
7LIBGLIB2_VERSION_MAJOR = 2.76
8LIBGLIB2_VERSION = $(LIBGLIB2_VERSION_MAJOR).1
9LIBGLIB2_SOURCE = glib-$(LIBGLIB2_VERSION).tar.xz
10LIBGLIB2_SITE = https://download.gnome.org/sources/glib/$(LIBGLIB2_VERSION_MAJOR)
11LIBGLIB2_LICENSE = LGPL-2.1+
12LIBGLIB2_LICENSE_FILES = COPYING
13LIBGLIB2_CPE_ID_VENDOR = gnome
14LIBGLIB2_CPE_ID_PRODUCT = glib
15LIBGLIB2_INSTALL_STAGING = YES
16
17LIBGLIB2_CFLAGS = $(TARGET_CFLAGS)
18LIBGLIB2_LDFLAGS = $(TARGET_LDFLAGS) $(TARGET_NLS_LIBS)
19
20# glib/valgrind.h contains inline asm not compatible with thumb1
21ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y)
22LIBGLIB2_CFLAGS += -marm
23endif
24
25HOST_LIBGLIB2_CONF_OPTS = \
26	-Ddtrace=false \
27	-Dglib_debug=disabled \
28	-Dlibelf=disabled \
29	-Dselinux=disabled \
30	-Dsystemtap=false \
31	-Dxattr=false \
32	-Dtests=false \
33	-Doss_fuzz=disabled
34
35LIBGLIB2_DEPENDENCIES = \
36	host-pkgconf host-libglib2 \
37	libffi pcre2 zlib $(TARGET_NLS_DEPENDENCIES)
38
39HOST_LIBGLIB2_DEPENDENCIES = \
40	host-gettext \
41	host-libffi \
42	host-pcre2 \
43	host-pkgconf \
44	host-util-linux \
45	host-zlib
46
47# We explicitly specify a giomodule-dir to avoid having a value
48# containing ${libdir} in gio-2.0.pc. Indeed, a value depending on
49# ${libdir} would be prefixed by the sysroot by pkg-config, causing a
50# bogus installation path once combined with $(DESTDIR).
51LIBGLIB2_CONF_OPTS = \
52	-Dglib_debug=disabled \
53	-Dlibelf=disabled \
54	-Dgio_module_dir=/usr/lib/gio/modules \
55	-Dtests=false \
56	-Doss_fuzz=disabled
57
58LIBGLIB2_MESON_EXTRA_PROPERTIES = \
59	have_c99_vsnprintf=true \
60	have_c99_snprintf=true \
61	have_unix98_printf=true
62
63ifeq ($(BR2_PACKAGE_ELFUTILS),y)
64LIBGLIB2_DEPENDENCIES += elfutils
65endif
66
67ifeq ($(BR2_PACKAGE_LIBICONV),y)
68LIBGLIB2_DEPENDENCIES += libiconv
69endif
70
71ifeq ($(BR2_PACKAGE_LIBSELINUX),y)
72LIBGLIB2_CONF_OPTS += -Dselinux=enabled -Dxattr=true
73LIBGLIB2_DEPENDENCIES += libselinux
74else
75LIBGLIB2_CONF_OPTS += -Dselinux=disabled -Dxattr=false
76endif
77
78# Purge gdb-related files
79ifneq ($(BR2_PACKAGE_GDB),y)
80define LIBGLIB2_REMOVE_GDB_FILES
81	rm -rf $(TARGET_DIR)/usr/share/glib-2.0/gdb
82endef
83endif
84
85ifeq ($(BR2_PACKAGE_UTIL_LINUX_LIBMOUNT),y)
86LIBGLIB2_CONF_OPTS += -Dlibmount=enabled
87ifeq ($(BR2_PACKAGE_UTIL_LINUX_LIBS),y)
88LIBGLIB2_DEPENDENCIES += util-linux-libs
89else
90LIBGLIB2_DEPENDENCIES += util-linux
91endif
92else
93LIBGLIB2_CONF_OPTS += -Dlibmount=disabled
94endif
95
96# Purge useless binaries from target
97define LIBGLIB2_REMOVE_DEV_FILES
98	rm -rf $(TARGET_DIR)/usr/lib/glib-2.0
99	rm -rf $(addprefix $(TARGET_DIR)/usr/share/glib-2.0/,codegen gettext)
100	rm -f $(addprefix $(TARGET_DIR)/usr/bin/,gdbus-codegen glib-compile-schemas glib-compile-resources glib-genmarshal glib-gettextize glib-mkenums gobject-query gtester gtester-report)
101	$(LIBGLIB2_REMOVE_GDB_FILES)
102endef
103
104LIBGLIB2_POST_INSTALL_TARGET_HOOKS += LIBGLIB2_REMOVE_DEV_FILES
105
106# Newer versions of libglib2 prefix glib-genmarshal, gobject-query,
107# glib-mkenums, glib_compile_schemas, glib_compile_resources and gdbus-codegen
108# with ${bindir}. Unfortunately, this will resolve to the host systems /bin/
109# directory, which will cause compilation issues if the host does not have these
110# programs. By removing the ${bindir}/ prefix, these programs are resolved in
111# PATH instead.
112define LIBGLIB2_REMOVE_BINDIR_PREFIX_FROM_PC_FILE
113	$(SED) 's%$${bindir}/%%g' $(addprefix $(STAGING_DIR)/usr/lib/pkgconfig/, glib-2.0.pc gio-2.0.pc)
114endef
115LIBGLIB2_POST_INSTALL_TARGET_HOOKS += LIBGLIB2_REMOVE_BINDIR_PREFIX_FROM_PC_FILE
116
117# Remove schema sources/DTDs, we use staging ones to compile them.
118# Do so at target finalization since other packages install additional
119# ones and we want to deal with it in a single place.
120define LIBGLIB2_REMOVE_TARGET_SCHEMAS
121	rm -f $(TARGET_DIR)/usr/share/glib-2.0/schemas/*.xml \
122		$(TARGET_DIR)/usr/share/glib-2.0/schemas/*.dtd
123endef
124
125# Compile schemas at target finalization since other packages install
126# them as well, and better do it in a central place.
127# It's used at run time so it doesn't matter defering it.
128define LIBGLIB2_COMPILE_SCHEMAS
129	$(HOST_DIR)/bin/glib-compile-schemas \
130		$(STAGING_DIR)/usr/share/glib-2.0/schemas \
131		--targetdir=$(TARGET_DIR)/usr/share/glib-2.0/schemas
132endef
133
134LIBGLIB2_TARGET_FINALIZE_HOOKS += LIBGLIB2_REMOVE_TARGET_SCHEMAS
135LIBGLIB2_TARGET_FINALIZE_HOOKS += LIBGLIB2_COMPILE_SCHEMAS
136
137$(eval $(meson-package))
138$(eval $(host-meson-package))
139
140LIBGLIB2_HOST_BINARY = $(HOST_DIR)/bin/glib-genmarshal
141