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