gobject-introspection.mk 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. ################################################################################
  2. #
  3. # gobject-introspection
  4. #
  5. ################################################################################
  6. GOBJECT_INTROSPECTION_VERSION_MAJOR = 1.64
  7. GOBJECT_INTROSPECTION_VERSION = $(GOBJECT_INTROSPECTION_VERSION_MAJOR).1
  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_host_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_TOOLTEMPLATE_PYTHON_PATH
  58. $(SED) '1s%#!.*%#!$(HOST_DIR)/bin/python%' $(@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/python%' $(@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%@TOOLCHAIN_HEADERS_VERSION@%$(BR2_TOOLCHAIN_HEADERS_AT_LEAST)%g" \
  75. $(STAGING_DIR)/usr/bin/g-ir-scanner-qemuwrapper
  76. # Use a modules directory which does not exist so we don't load random things
  77. # which may then get deleted (or their dependencies) and potentially segfault
  78. mkdir -p $(STAGING_DIR)/usr/lib/gio/modules-dummy
  79. endef
  80. GOBJECT_INTROSPECTION_PRE_CONFIGURE_HOOKS += GOBJECT_INTROSPECTION_INSTALL_PRE_WRAPPERS
  81. # Move the real compiler and scanner to .real, and replace them with the wrappers.
  82. # Using .real has the following advantages:
  83. # - There is no need to change the logic for other packages.
  84. # - The wrappers call the .real files using qemu.
  85. define GOBJECT_INTROSPECTION_INSTALL_WRAPPERS
  86. # Move the real binaries to their names.real, then replace them with
  87. # the wrappers.
  88. $(foreach w,g-ir-compiler g-ir-scanner,
  89. mv $(STAGING_DIR)/usr/bin/$(w) $(STAGING_DIR)/usr/bin/$(w).real
  90. $(INSTALL) -D -m 755 \
  91. $(GOBJECT_INTROSPECTION_PKGDIR)/$(w).in $(STAGING_DIR)/usr/bin/$(w)
  92. )
  93. $(SED) "s%@BASENAME_TARGET_CPP@%$(notdir $(TARGET_CPP))%g" \
  94. -e "s%@BASENAME_TARGET_CC@%$(notdir $(TARGET_CC))%g" \
  95. -e "s%@BASENAME_TARGET_CXX@%$(notdir $(TARGET_CXX))%g" \
  96. -e "s%@TARGET_CPPFLAGS@%$(TARGET_CPPFLAGS)%g" \
  97. -e "s%@TARGET_CFLAGS@%$(TARGET_CFLAGS)%g" \
  98. -e "s%@TARGET_CXXFLAGS@%$(TARGET_CXXFLAGS)%g" \
  99. -e "s%@TARGET_LDFLAGS@%$(TARGET_LDFLAGS)%g" \
  100. $(STAGING_DIR)/usr/bin/g-ir-scanner
  101. # Gobject-introspection installs Makefile.introspection in
  102. # $(STAGING_DIR)/usr/share which is needed for autotools-based programs to
  103. # build .gir and .typelib files. Unfortuantly, gobject-introspection-1.0.pc
  104. # uses $(prefix)/share as the directory, which
  105. # causes the host /usr/share being used instead of $(STAGING_DIR)/usr/share.
  106. # Change datarootdir to $(libdir)/../share which will prefix $(STAGING_DIR)
  107. # to the correct location.
  108. $(SED) "s%datarootdir=.*%datarootdir=\$${libdir}/../share%g" \
  109. $(STAGING_DIR)/usr/lib/pkgconfig/gobject-introspection-1.0.pc
  110. # By default, girdir and typelibdir use datadir and libdir as their prefix,
  111. # of which pkg-config appends the sysroot directory. This results in files
  112. # being installed in $(STAGING_DIR)/$(STAGING_DIR)/path/to/files.
  113. # Changing the prefix to exec_prefix prevents this error.
  114. $(SED) "s%girdir=.*%girdir=\$${exec_prefix}/share/gir-1.0%g" \
  115. $(STAGING_DIR)/usr/lib/pkgconfig/gobject-introspection-1.0.pc
  116. $(SED) "s%typelibdir=.*%typelibdir=\$${exec_prefix}/lib/girepository-1.0%g" \
  117. $(STAGING_DIR)/usr/lib/pkgconfig/gobject-introspection-1.0.pc
  118. endef
  119. GOBJECT_INTROSPECTION_POST_INSTALL_STAGING_HOOKS += GOBJECT_INTROSPECTION_INSTALL_WRAPPERS
  120. # Only .typelib files are needed to run.
  121. define GOBJECT_INTROSPECTION_REMOVE_DEVELOPMENT_FILES
  122. find $(TARGET_DIR)/usr/share \( -iname "*.gir" -o -iname \*.rnc \) -delete
  123. endef
  124. GOBJECT_INTROSPECTION_TARGET_FINALIZE_HOOKS += GOBJECT_INTROSPECTION_REMOVE_DEVELOPMENT_FILES
  125. $(eval $(meson-package))
  126. $(eval $(host-meson-package))