1*4882a593Smuzhiyun################################################################################ 2*4882a593Smuzhiyun# 3*4882a593Smuzhiyun# gobject-introspection 4*4882a593Smuzhiyun# 5*4882a593Smuzhiyun################################################################################ 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunGOBJECT_INTROSPECTION_VERSION_MAJOR = 1.68 8*4882a593SmuzhiyunGOBJECT_INTROSPECTION_VERSION = $(GOBJECT_INTROSPECTION_VERSION_MAJOR).0 9*4882a593SmuzhiyunGOBJECT_INTROSPECTION_SITE = http://ftp.gnome.org/pub/GNOME/sources/gobject-introspection/$(GOBJECT_INTROSPECTION_VERSION_MAJOR) 10*4882a593SmuzhiyunGOBJECT_INTROSPECTION_SOURCE = gobject-introspection-$(GOBJECT_INTROSPECTION_VERSION).tar.xz 11*4882a593SmuzhiyunGOBJECT_INTROSPECTION_INSTALL_STAGING = YES 12*4882a593SmuzhiyunGOBJECT_INTROSPECTION_AUTORECONF = YES 13*4882a593SmuzhiyunGOBJECT_INTROSPECTION_LICENSE = LGPL-2.0+, GPL-2.0+, BSD-2-Clause 14*4882a593SmuzhiyunGOBJECT_INTROSPECTION_LICENSE_FILES = COPYING.LGPL COPYING.GPL giscanner/scannerlexer.l 15*4882a593Smuzhiyun 16*4882a593SmuzhiyunGOBJECT_INTROSPECTION_DEPENDENCIES = \ 17*4882a593Smuzhiyun host-autoconf-archive \ 18*4882a593Smuzhiyun host-gobject-introspection \ 19*4882a593Smuzhiyun host-prelink-cross \ 20*4882a593Smuzhiyun host-qemu \ 21*4882a593Smuzhiyun libffi \ 22*4882a593Smuzhiyun libglib2 \ 23*4882a593Smuzhiyun python3 \ 24*4882a593Smuzhiyun zlib 25*4882a593Smuzhiyun 26*4882a593SmuzhiyunHOST_GOBJECT_INTROSPECTION_DEPENDENCIES = \ 27*4882a593Smuzhiyun host-bison \ 28*4882a593Smuzhiyun host-flex \ 29*4882a593Smuzhiyun host-libglib2 \ 30*4882a593Smuzhiyun host-python3 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun# g-ir-scanner will default to /usr/bin/ld for linking if this is not set. 33*4882a593SmuzhiyunGOBJECT_INTROSPECTION_NINJA_ENV += \ 34*4882a593Smuzhiyun CC="$(TARGET_CC)" 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun# When building, gobject-introspection uses tools/g-ir-scanner to build several 37*4882a593Smuzhiyun# .gir and .typelib files. g-ir-scanner does not use LDFLAGS, and by default, 38*4882a593Smuzhiyun# links to the system-installed libglib2 path. To remedy this issue, defining 39*4882a593Smuzhiyun# LD_LIBRARY_PATH forces g-ir-scanner to use our host installed libglib2 files. 40*4882a593SmuzhiyunHOST_GOBJECT_INTROSPECTION_NINJA_ENV += \ 41*4882a593Smuzhiyun LD_LIBRARY_PATH="$(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):)$(HOST_DIR)/lib" 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun# Use the host gi-scanner to prevent the scanner from generating incorrect 44*4882a593Smuzhiyun# elf classes. 45*4882a593SmuzhiyunGOBJECT_INTROSPECTION_CONF_OPTS = \ 46*4882a593Smuzhiyun -Dgi_cross_use_prebuilt_gi=true \ 47*4882a593Smuzhiyun -Dgi_cross_binary_wrapper="$(STAGING_DIR)/usr/bin/g-ir-scanner-qemuwrapper" \ 48*4882a593Smuzhiyun -Dgi_cross_ldd_wrapper="$(STAGING_DIR)/usr/bin/g-ir-scanner-lddwrapper" \ 49*4882a593Smuzhiyun -Dbuild_introspection_data=true \ 50*4882a593Smuzhiyun -Ddoctool=disabled 51*4882a593Smuzhiyun 52*4882a593Smuzhiyunifeq ($(BR2_PACKAGE_CAIRO),y) 53*4882a593SmuzhiyunGOBJECT_INTROSPECTION_DEPENDENCIES += cairo 54*4882a593SmuzhiyunGOBJECT_INTROSPECTION_CONF_OPTS += -Dcairo=enabled 55*4882a593Smuzhiyunelse 56*4882a593SmuzhiyunGOBJECT_INTROSPECTION_CONF_OPTS += -Dcairo=disabled 57*4882a593Smuzhiyunendif 58*4882a593Smuzhiyun 59*4882a593Smuzhiyun# GI_SCANNER_DISABLE_CACHE=1 prevents g-ir-scanner from writing cache data to ${HOME} 60*4882a593SmuzhiyunGOBJECT_INTROSPECTION_CONF_ENV = \ 61*4882a593Smuzhiyun GI_SCANNER_DISABLE_CACHE=1 62*4882a593Smuzhiyun 63*4882a593SmuzhiyunHOST_GOBJECT_INTROSPECTION_CONF_ENV = \ 64*4882a593Smuzhiyun GI_SCANNER_DISABLE_CACHE=1 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun# Make sure g-ir-tool-template uses the host python. 67*4882a593Smuzhiyundefine GOBJECT_INTROSPECTION_FIX_TOOLS_PYTHON_PATH 68*4882a593Smuzhiyun $(SED) '1s%#!.*%#!$(HOST_DIR)/bin/python3%' $(@D)/tools/g-ir-tool-template.in 69*4882a593Smuzhiyunendef 70*4882a593SmuzhiyunHOST_GOBJECT_INTROSPECTION_PRE_CONFIGURE_HOOKS += GOBJECT_INTROSPECTION_FIX_TOOLTEMPLATE_PYTHON_PATH 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun# Perform the following: 73*4882a593Smuzhiyun# - Just as above, Ensure that g-ir-tool-template.in uses the host python. 74*4882a593Smuzhiyun# - Install all of the wrappers needed to build gobject-introspection. 75*4882a593Smuzhiyun# - Create a safe modules directory which does not exist so we don't load random things 76*4882a593Smuzhiyun# which may then get deleted (or their dependencies) and potentially segfault 77*4882a593Smuzhiyundefine GOBJECT_INTROSPECTION_INSTALL_PRE_WRAPPERS 78*4882a593Smuzhiyun $(SED) '1s%#!.*%#!$(HOST_DIR)/bin/python3%' $(@D)/tools/g-ir-tool-template.in 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun $(INSTALL) -D -m 755 $(GOBJECT_INTROSPECTION_PKGDIR)/g-ir-scanner-lddwrapper.in \ 81*4882a593Smuzhiyun $(STAGING_DIR)/usr/bin/g-ir-scanner-lddwrapper 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun $(INSTALL) -D -m 755 $(GOBJECT_INTROSPECTION_PKGDIR)/g-ir-scanner-qemuwrapper.in \ 84*4882a593Smuzhiyun $(STAGING_DIR)/usr/bin/g-ir-scanner-qemuwrapper 85*4882a593Smuzhiyun $(SED) "s%@QEMU_USER@%$(QEMU_USER)%g" \ 86*4882a593Smuzhiyun $(STAGING_DIR)/usr/bin/g-ir-scanner-qemuwrapper 87*4882a593Smuzhiyun $(SED) "s%@QEMU_USERMODE_ARGS@%$(call qstrip,$(BR2_PACKAGE_HOST_QEMU_USER_MODE_ARGS))%g" \ 88*4882a593Smuzhiyun $(STAGING_DIR)/usr/bin/g-ir-scanner-qemuwrapper 89*4882a593Smuzhiyun $(SED) "s%@TOOLCHAIN_HEADERS_VERSION@%$(BR2_TOOLCHAIN_HEADERS_AT_LEAST)%g" \ 90*4882a593Smuzhiyun $(STAGING_DIR)/usr/bin/g-ir-scanner-qemuwrapper 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun # Use a modules directory which does not exist so we don't load random things 93*4882a593Smuzhiyun # which may then get deleted (or their dependencies) and potentially segfault 94*4882a593Smuzhiyun mkdir -p $(STAGING_DIR)/usr/lib/gio/modules-dummy 95*4882a593Smuzhiyunendef 96*4882a593SmuzhiyunGOBJECT_INTROSPECTION_PRE_CONFIGURE_HOOKS += GOBJECT_INTROSPECTION_INSTALL_PRE_WRAPPERS 97*4882a593Smuzhiyun 98*4882a593Smuzhiyun# Move the real compiler and scanner to .real, and replace them with the wrappers. 99*4882a593Smuzhiyun# Using .real has the following advantages: 100*4882a593Smuzhiyun# - There is no need to change the logic for other packages. 101*4882a593Smuzhiyun# - The wrappers call the .real files using qemu. 102*4882a593Smuzhiyundefine GOBJECT_INTROSPECTION_INSTALL_WRAPPERS 103*4882a593Smuzhiyun # Move the real binaries to their names.real, then replace them with 104*4882a593Smuzhiyun # the wrappers. 105*4882a593Smuzhiyun $(foreach w,g-ir-compiler g-ir-scanner, 106*4882a593Smuzhiyun mv $(STAGING_DIR)/usr/bin/$(w) $(STAGING_DIR)/usr/bin/$(w).real 107*4882a593Smuzhiyun $(INSTALL) -D -m 755 \ 108*4882a593Smuzhiyun $(GOBJECT_INTROSPECTION_PKGDIR)/$(w).in $(STAGING_DIR)/usr/bin/$(w) 109*4882a593Smuzhiyun ) 110*4882a593Smuzhiyun $(SED) "s%@BASENAME_TARGET_CPP@%$(notdir $(TARGET_CPP))%g" \ 111*4882a593Smuzhiyun -e "s%@BASENAME_TARGET_CC@%$(notdir $(TARGET_CC))%g" \ 112*4882a593Smuzhiyun -e "s%@BASENAME_TARGET_CXX@%$(notdir $(TARGET_CXX))%g" \ 113*4882a593Smuzhiyun -e "s%@TARGET_CPPFLAGS@%$(TARGET_CPPFLAGS)%g" \ 114*4882a593Smuzhiyun -e "s%@TARGET_CFLAGS@%$(TARGET_CFLAGS)%g" \ 115*4882a593Smuzhiyun -e "s%@TARGET_CXXFLAGS@%$(TARGET_CXXFLAGS)%g" \ 116*4882a593Smuzhiyun -e "s%@TARGET_LDFLAGS@%$(TARGET_LDFLAGS)%g" \ 117*4882a593Smuzhiyun $(STAGING_DIR)/usr/bin/g-ir-scanner 118*4882a593Smuzhiyun 119*4882a593Smuzhiyun # Gobject-introspection installs Makefile.introspection in 120*4882a593Smuzhiyun # $(STAGING_DIR)/usr/share which is needed for autotools-based programs to 121*4882a593Smuzhiyun # build .gir and .typelib files. Unfortunately, gobject-introspection-1.0.pc 122*4882a593Smuzhiyun # uses $(prefix)/share as the directory, which 123*4882a593Smuzhiyun # causes the host /usr/share being used instead of $(STAGING_DIR)/usr/share. 124*4882a593Smuzhiyun # Change datadir to $(libdir)/../share which will prefix $(STAGING_DIR) 125*4882a593Smuzhiyun # to the correct location. 126*4882a593Smuzhiyun $(SED) "s%^datadir=.*%datadir=\$${libdir}/../share%g" \ 127*4882a593Smuzhiyun $(STAGING_DIR)/usr/lib/pkgconfig/gobject-introspection-1.0.pc 128*4882a593Smuzhiyun 129*4882a593Smuzhiyun # By default, girdir and typelibdir use datadir and libdir as their prefix, 130*4882a593Smuzhiyun # of which pkg-config appends the sysroot directory. This results in files 131*4882a593Smuzhiyun # being installed in $(STAGING_DIR)/$(STAGING_DIR)/path/to/files. 132*4882a593Smuzhiyun # Changing the prefix to prefix prevents this error. 133*4882a593Smuzhiyun $(SED) "s%girdir=.*%girdir=\$${prefix}/share/gir-1.0%g" \ 134*4882a593Smuzhiyun $(STAGING_DIR)/usr/lib/pkgconfig/gobject-introspection-1.0.pc 135*4882a593Smuzhiyun 136*4882a593Smuzhiyun $(SED) "s%typelibdir=.*%typelibdir=\$${prefix}/lib/girepository-1.0%g" \ 137*4882a593Smuzhiyun $(STAGING_DIR)/usr/lib/pkgconfig/gobject-introspection-1.0.pc 138*4882a593Smuzhiyun 139*4882a593Smuzhiyun # Set includedir to $(STAGING_DIR)/usr/share/gir-1.0 instead of . or 140*4882a593Smuzhiyun # g-ir-compiler won't find .gir files resulting in a build failure for 141*4882a593Smuzhiyun # autotools-based based programs 142*4882a593Smuzhiyun $(SED) "s%includedir=.%includedir=$(STAGING_DIR)/usr/share/gir-1.0%g" \ 143*4882a593Smuzhiyun $(STAGING_DIR)/usr/share/gobject-introspection-1.0/Makefile.introspection 144*4882a593Smuzhiyunendef 145*4882a593SmuzhiyunGOBJECT_INTROSPECTION_POST_INSTALL_STAGING_HOOKS += GOBJECT_INTROSPECTION_INSTALL_WRAPPERS 146*4882a593Smuzhiyun 147*4882a593Smuzhiyun# Only .typelib files are needed to run. 148*4882a593Smuzhiyundefine GOBJECT_INTROSPECTION_REMOVE_DEVELOPMENT_FILES 149*4882a593Smuzhiyun find $(TARGET_DIR)/usr/share \( -iname "*.gir" -o -iname \*.rnc \) -delete 150*4882a593Smuzhiyunendef 151*4882a593SmuzhiyunGOBJECT_INTROSPECTION_TARGET_FINALIZE_HOOKS += GOBJECT_INTROSPECTION_REMOVE_DEVELOPMENT_FILES 152*4882a593Smuzhiyun 153*4882a593Smuzhiyun$(eval $(meson-package)) 154*4882a593Smuzhiyun$(eval $(host-meson-package)) 155