gobject-introspection.mk 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. ################################################################################
  2. #
  3. # gobject-introspection
  4. #
  5. ################################################################################
  6. GOBJECT_INTROSPECTION_VERSION_MAJOR = 1.82
  7. GOBJECT_INTROSPECTION_VERSION = $(GOBJECT_INTROSPECTION_VERSION_MAJOR).0
  8. GOBJECT_INTROSPECTION_SITE = https://download.gnome.org/sources/gobject-introspection/$(GOBJECT_INTROSPECTION_VERSION_MAJOR)
  9. GOBJECT_INTROSPECTION_SOURCE = gobject-introspection-$(GOBJECT_INTROSPECTION_VERSION).tar.xz
  10. GOBJECT_INTROSPECTION_INSTALL_STAGING = YES
  11. GOBJECT_INTROSPECTION_LICENSE = LGPL-2.0+, GPL-2.0+, BSD-2-Clause
  12. GOBJECT_INTROSPECTION_LICENSE_FILES = COPYING.LGPL COPYING.GPL giscanner/scannerlexer.l
  13. # gobject-introspection depends on the bootstrap version of libglib2
  14. # during the build because the full version depends on
  15. # gobject-introspection (applies to target and host packages
  16. # alike). "select BR2_PACKAGE_LIBGLIB2" in Config.in ensures the full
  17. # libglib2 gets installed together with gobject-introspection.
  18. GOBJECT_INTROSPECTION_DEPENDENCIES = \
  19. host-autoconf-archive \
  20. host-gobject-introspection \
  21. host-qemu \
  22. libffi \
  23. libglib2-bootstrap \
  24. python3 \
  25. zlib
  26. HOST_GOBJECT_INTROSPECTION_DEPENDENCIES = \
  27. host-bison \
  28. host-flex \
  29. host-libglib2-bootstrap \
  30. host-python3
  31. # g-ir-scanner will default to /usr/bin/ld for linking if this is not set.
  32. GOBJECT_INTROSPECTION_NINJA_ENV += \
  33. CC="$(TARGET_CC)"
  34. # When building, gobject-introspection uses tools/g-ir-scanner to build several
  35. # .gir and .typelib files. g-ir-scanner does not use LDFLAGS, and by default,
  36. # links to the system-installed libglib2 path. To remedy this issue, defining
  37. # LD_LIBRARY_PATH forces g-ir-scanner to use our host installed libglib2 files.
  38. HOST_GOBJECT_INTROSPECTION_NINJA_ENV += \
  39. LD_LIBRARY_PATH="$(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):)$(HOST_DIR)/lib"
  40. # Use the host gi-scanner to prevent the scanner from generating incorrect
  41. # elf classes.
  42. GOBJECT_INTROSPECTION_CONF_OPTS = \
  43. -Dgi_cross_use_prebuilt_gi=true \
  44. -Dgi_cross_binary_wrapper="$(STAGING_DIR)/usr/bin/g-ir-scanner-qemuwrapper" \
  45. -Dgi_cross_ldd_wrapper="$(STAGING_DIR)/usr/bin/g-ir-scanner-lddwrapper" \
  46. -Dbuild_introspection_data=true \
  47. -Ddoctool=disabled \
  48. -Dcairo=disabled
  49. # GI_SCANNER_DISABLE_CACHE=1 prevents g-ir-scanner from writing cache data to ${HOME}
  50. GOBJECT_INTROSPECTION_CONF_ENV = \
  51. GI_SCANNER_DISABLE_CACHE=1
  52. HOST_GOBJECT_INTROSPECTION_CONF_ENV = \
  53. GI_SCANNER_DISABLE_CACHE=1
  54. # Make sure g-ir-tool-template uses the host python.
  55. define GOBJECT_INTROSPECTION_FIX_TOOLS_PYTHON_PATH
  56. $(SED) '1s%#!.*%#!$(HOST_DIR)/bin/python3%' $(@D)/tools/g-ir-tool-template.in
  57. endef
  58. HOST_GOBJECT_INTROSPECTION_PRE_CONFIGURE_HOOKS += GOBJECT_INTROSPECTION_FIX_TOOLS_PYTHON_PATH
  59. # Perform the following:
  60. # - Just as above, Ensure that g-ir-tool-template.in uses the host python.
  61. # - Install all of the wrappers needed to build gobject-introspection.
  62. # - Create a safe modules directory which does not exist so we don't load random things
  63. # which may then get deleted (or their dependencies) and potentially segfault
  64. define GOBJECT_INTROSPECTION_INSTALL_PRE_WRAPPERS
  65. $(SED) '1s%#!.*%#!$(HOST_DIR)/bin/python3%' $(@D)/tools/g-ir-tool-template.in
  66. $(INSTALL) -D -m 755 $(GOBJECT_INTROSPECTION_PKGDIR)/g-ir-scanner-lddwrapper.in \
  67. $(STAGING_DIR)/usr/bin/g-ir-scanner-lddwrapper
  68. $(SED) "s%@TARGET_OBJDUMP@%$(TARGET_OBJDUMP)%" \
  69. $(STAGING_DIR)/usr/bin/g-ir-scanner-lddwrapper
  70. $(INSTALL) -D -m 755 $(GOBJECT_INTROSPECTION_PKGDIR)/g-ir-scanner-qemuwrapper.in \
  71. $(STAGING_DIR)/usr/bin/g-ir-scanner-qemuwrapper
  72. $(SED) "s%@QEMU_USER@%$(QEMU_USER)%g" \
  73. $(STAGING_DIR)/usr/bin/g-ir-scanner-qemuwrapper
  74. $(SED) "s%@QEMU_USERMODE_ARGS@%$(call qstrip,$(BR2_PACKAGE_HOST_QEMU_USER_MODE_ARGS))%g" \
  75. $(STAGING_DIR)/usr/bin/g-ir-scanner-qemuwrapper
  76. $(SED) "s%@TOOLCHAIN_HEADERS_VERSION@%$(BR2_TOOLCHAIN_HEADERS_AT_LEAST)%g" \
  77. $(STAGING_DIR)/usr/bin/g-ir-scanner-qemuwrapper
  78. # Use a modules directory which does not exist so we don't load random things
  79. # which may then get deleted (or their dependencies) and potentially segfault
  80. mkdir -p $(STAGING_DIR)/usr/lib/gio/modules-dummy
  81. endef
  82. GOBJECT_INTROSPECTION_PRE_CONFIGURE_HOOKS += GOBJECT_INTROSPECTION_INSTALL_PRE_WRAPPERS
  83. # Move the real compiler and scanner to .real, and replace them with the wrappers.
  84. # Using .real has the following advantages:
  85. # - There is no need to change the logic for other packages.
  86. # - The wrappers call the .real files using qemu.
  87. define GOBJECT_INTROSPECTION_INSTALL_WRAPPERS
  88. # Move the real binaries to their names.real, then replace them with
  89. # the wrappers.
  90. $(foreach w,g-ir-compiler g-ir-scanner,
  91. mv $(STAGING_DIR)/usr/bin/$(w) $(STAGING_DIR)/usr/bin/$(w).real
  92. $(INSTALL) -D -m 755 \
  93. $(GOBJECT_INTROSPECTION_PKGDIR)/$(w).in $(STAGING_DIR)/usr/bin/$(w)
  94. )
  95. $(SED) "s%@BASENAME_TARGET_CPP@%$(notdir $(TARGET_CPP))%g" \
  96. -e "s%@BASENAME_TARGET_CC@%$(notdir $(TARGET_CC))%g" \
  97. -e "s%@BASENAME_TARGET_CXX@%$(notdir $(TARGET_CXX))%g" \
  98. -e "s%@TARGET_CPPFLAGS@%$(TARGET_CPPFLAGS)%g" \
  99. -e "s%@TARGET_CFLAGS@%$(TARGET_CFLAGS)%g" \
  100. -e "s%@TARGET_CXXFLAGS@%$(TARGET_CXXFLAGS)%g" \
  101. -e "s%@TARGET_LDFLAGS@%$(TARGET_LDFLAGS)%g" \
  102. $(STAGING_DIR)/usr/bin/g-ir-scanner
  103. # Gobject-introspection installs Makefile.introspection in
  104. # $(STAGING_DIR)/usr/share which is needed for autotools-based programs to
  105. # build .gir and .typelib files. Unfortunately, gobject-introspection-1.0.pc
  106. # uses $(prefix)/share as the directory, which
  107. # causes the host /usr/share being used instead of $(STAGING_DIR)/usr/share.
  108. # Change datadir to $(libdir)/../share which will prefix $(STAGING_DIR)
  109. # to the correct location.
  110. # Since we use libdir to define datadir, we must define datadir after
  111. # libdir is defined.
  112. $(SED) "\%^datadir=%d; s%^\(libdir=.*\)$$%\1\ndatadir=\$${libdir}/../share%" \
  113. $(STAGING_DIR)/usr/lib/pkgconfig/gobject-introspection-1.0.pc
  114. # By default, girdir and typelibdir use datadir and libdir as their prefix,
  115. # of which pkg-config appends the sysroot directory. This results in files
  116. # being installed in $(STAGING_DIR)/$(STAGING_DIR)/path/to/files.
  117. # Changing the prefix to prefix prevents this error.
  118. $(SED) "s%girdir=.*%girdir=\$${prefix}/share/gir-1.0%g" \
  119. $(STAGING_DIR)/usr/lib/pkgconfig/gobject-introspection-1.0.pc
  120. $(SED) "s%typelibdir=.*%typelibdir=\$${prefix}/lib/girepository-1.0%g" \
  121. $(STAGING_DIR)/usr/lib/pkgconfig/gobject-introspection-1.0.pc
  122. # Set includedir to $(STAGING_DIR)/usr/share/gir-1.0 instead of . or
  123. # g-ir-compiler won't find .gir files resulting in a build failure for
  124. # autotools-based based programs
  125. $(SED) "s%includedir=.%includedir=$(STAGING_DIR)/usr/share/gir-1.0%g" \
  126. $(STAGING_DIR)/usr/share/gobject-introspection-1.0/Makefile.introspection
  127. endef
  128. GOBJECT_INTROSPECTION_POST_INSTALL_STAGING_HOOKS += GOBJECT_INTROSPECTION_INSTALL_WRAPPERS
  129. # Only .typelib files are needed to run.
  130. define GOBJECT_INTROSPECTION_REMOVE_DEVELOPMENT_FILES
  131. find $(TARGET_DIR)/usr/share \( -iname "*.gir" -o -iname \*.rnc \) -delete
  132. endef
  133. GOBJECT_INTROSPECTION_TARGET_FINALIZE_HOOKS += GOBJECT_INTROSPECTION_REMOVE_DEVELOPMENT_FILES
  134. $(eval $(meson-package))
  135. $(eval $(host-meson-package))