gobject-introspection.mk 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. ################################################################################
  2. #
  3. # gobject-introspection
  4. #
  5. ################################################################################
  6. GOBJECT_INTROSPECTION_VERSION_MAJOR = 1.68
  7. GOBJECT_INTROSPECTION_VERSION = $(GOBJECT_INTROSPECTION_VERSION_MAJOR).0
  8. GOBJECT_INTROSPECTION_SITE = http://ftp.gnome.org/pub/GNOME/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_AUTORECONF = YES
  12. GOBJECT_INTROSPECTION_LICENSE = LGPL-2.0+, GPL-2.0+, BSD-2-Clause
  13. GOBJECT_INTROSPECTION_LICENSE_FILES = COPYING.LGPL COPYING.GPL giscanner/scannerlexer.l
  14. GOBJECT_INTROSPECTION_DEPENDENCIES = \
  15. host-autoconf-archive \
  16. host-gobject-introspection \
  17. host-prelink-cross \
  18. host-qemu \
  19. libffi \
  20. libglib2 \
  21. python3 \
  22. zlib
  23. HOST_GOBJECT_INTROSPECTION_DEPENDENCIES = \
  24. host-bison \
  25. host-flex \
  26. host-libglib2 \
  27. host-python3
  28. # g-ir-scanner will default to /usr/bin/ld for linking if this is not set.
  29. GOBJECT_INTROSPECTION_NINJA_ENV += \
  30. CC="$(TARGET_CC)"
  31. # When building, gobject-introspection uses tools/g-ir-scanner to build several
  32. # .gir and .typelib files. g-ir-scanner does not use LDFLAGS, and by default,
  33. # links to the system-installed libglib2 path. To remedy this issue, defining
  34. # LD_LIBRARY_PATH forces g-ir-scanner to use our host installed libglib2 files.
  35. HOST_GOBJECT_INTROSPECTION_NINJA_ENV += \
  36. LD_LIBRARY_PATH="$(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):)$(HOST_DIR)/lib"
  37. # Use the host gi-scanner to prevent the scanner from generating incorrect
  38. # elf classes.
  39. GOBJECT_INTROSPECTION_CONF_OPTS = \
  40. -Dgi_cross_use_prebuilt_gi=true \
  41. -Dgi_cross_binary_wrapper="$(STAGING_DIR)/usr/bin/g-ir-scanner-qemuwrapper" \
  42. -Dgi_cross_ldd_wrapper="$(STAGING_DIR)/usr/bin/g-ir-scanner-lddwrapper" \
  43. -Dbuild_introspection_data=true \
  44. -Ddoctool=disabled
  45. ifeq ($(BR2_PACKAGE_CAIRO),y)
  46. GOBJECT_INTROSPECTION_DEPENDENCIES += cairo
  47. GOBJECT_INTROSPECTION_CONF_OPTS += -Dcairo=enabled
  48. else
  49. GOBJECT_INTROSPECTION_CONF_OPTS += -Dcairo=disabled
  50. endif
  51. # GI_SCANNER_DISABLE_CACHE=1 prevents g-ir-scanner from writing cache data to ${HOME}
  52. GOBJECT_INTROSPECTION_CONF_ENV = \
  53. GI_SCANNER_DISABLE_CACHE=1
  54. HOST_GOBJECT_INTROSPECTION_CONF_ENV = \
  55. GI_SCANNER_DISABLE_CACHE=1
  56. # Make sure g-ir-tool-template uses the host python.
  57. define GOBJECT_INTROSPECTION_FIX_TOOLS_PYTHON_PATH
  58. $(SED) '1s%#!.*%#!$(HOST_DIR)/bin/python3%' $(@D)/tools/g-ir-tool-template.in
  59. endef
  60. HOST_GOBJECT_INTROSPECTION_PRE_CONFIGURE_HOOKS += GOBJECT_INTROSPECTION_FIX_TOOLTEMPLATE_PYTHON_PATH
  61. # Perform the following:
  62. # - Just as above, Ensure that g-ir-tool-template.in uses the host python.
  63. # - Install all of the wrappers needed to build gobject-introspection.
  64. # - Create a safe modules directory which does not exist so we don't load random things
  65. # which may then get deleted (or their dependencies) and potentially segfault
  66. define GOBJECT_INTROSPECTION_INSTALL_PRE_WRAPPERS
  67. $(SED) '1s%#!.*%#!$(HOST_DIR)/bin/python3%' $(@D)/tools/g-ir-tool-template.in
  68. $(INSTALL) -D -m 755 $(GOBJECT_INTROSPECTION_PKGDIR)/g-ir-scanner-lddwrapper.in \
  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. $(SED) "s%^datadir=.*%datadir=\$${libdir}/../share%g" \
  111. $(STAGING_DIR)/usr/lib/pkgconfig/gobject-introspection-1.0.pc
  112. # By default, girdir and typelibdir use datadir and libdir as their prefix,
  113. # of which pkg-config appends the sysroot directory. This results in files
  114. # being installed in $(STAGING_DIR)/$(STAGING_DIR)/path/to/files.
  115. # Changing the prefix to prefix prevents this error.
  116. $(SED) "s%girdir=.*%girdir=\$${prefix}/share/gir-1.0%g" \
  117. $(STAGING_DIR)/usr/lib/pkgconfig/gobject-introspection-1.0.pc
  118. $(SED) "s%typelibdir=.*%typelibdir=\$${prefix}/lib/girepository-1.0%g" \
  119. $(STAGING_DIR)/usr/lib/pkgconfig/gobject-introspection-1.0.pc
  120. # Set includedir to $(STAGING_DIR)/usr/share/gir-1.0 instead of . or
  121. # g-ir-compiler won't find .gir files resulting in a build failure for
  122. # autotools-based based programs
  123. $(SED) "s%includedir=.%includedir=$(STAGING_DIR)/usr/share/gir-1.0%g" \
  124. $(STAGING_DIR)/usr/share/gobject-introspection-1.0/Makefile.introspection
  125. endef
  126. GOBJECT_INTROSPECTION_POST_INSTALL_STAGING_HOOKS += GOBJECT_INTROSPECTION_INSTALL_WRAPPERS
  127. # Only .typelib files are needed to run.
  128. define GOBJECT_INTROSPECTION_REMOVE_DEVELOPMENT_FILES
  129. find $(TARGET_DIR)/usr/share \( -iname "*.gir" -o -iname \*.rnc \) -delete
  130. endef
  131. GOBJECT_INTROSPECTION_TARGET_FINALIZE_HOOKS += GOBJECT_INTROSPECTION_REMOVE_DEVELOPMENT_FILES
  132. $(eval $(meson-package))
  133. $(eval $(host-meson-package))