gobject-introspection.mk 6.7 KB

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