You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
3.6 KiB

  1. # To build your package using meson:
  2. #
  3. # PKG_BUILD_DEPENDS:=meson/host
  4. # include ../../devel/meson/meson.mk
  5. # MESON_ARGS+=-Dfoo -Dbar=baz
  6. #
  7. # To pass additional environment variables to meson:
  8. #
  9. # MESON_VARS+=FOO=bar
  10. #
  11. # Default configure/compile/install targets are provided, but can be
  12. # overwritten if required:
  13. #
  14. # define Build/Configure
  15. # $(call Build/Configure/Meson)
  16. # ...
  17. # endef
  18. #
  19. # same for Build/Compile and Build/Install
  20. #
  21. # Host packages are built in the same fashion, just use these vars instead:
  22. #
  23. # HOST_BUILD_DEPENDS:=meson/host
  24. # MESON_HOST_ARGS+=-Dfoo -Dbar=baz
  25. # MESON_HOST_VARS+=FOO=bar
  26. include $(dir $(lastword $(MAKEFILE_LIST)))/../../devel/ninja/ninja.mk
  27. MESON_DIR:=$(STAGING_DIR_HOSTPKG)/lib/meson
  28. MESON_HOST_BUILD_DIR:=$(HOST_BUILD_DIR)/openwrt-build
  29. MESON_HOST_VARS:=
  30. MESON_HOST_ARGS:=
  31. MESON_BUILD_DIR:=$(PKG_BUILD_DIR)/openwrt-build
  32. MESON_VARS:=
  33. MESON_ARGS:=
  34. define Meson
  35. $(2) $(STAGING_DIR_HOST)/bin/$(PYTHON) $(MESON_DIR)/meson.py $(1)
  36. endef
  37. define Meson/CreateNativeFile
  38. $(STAGING_DIR_HOST)/bin/sed \
  39. -e "s|@CC@|$(HOSTCC)|" \
  40. -e "s|@CXX@|$(HOSTCXX)|" \
  41. -e "s|@PKGCONFIG@|$(PKG_CONFIG)|" \
  42. -e "s|@CFLAGS@|$(foreach FLAG,$(HOST_CFLAGS) $(HOST_CPPFLAGS),'$(FLAG)',)|" \
  43. -e "s|@CXXFLAGS@|$(foreach FLAG,$(HOST_CXXFLAGS) $(HOST_CPPFLAGS),'$(FLAG)',)|" \
  44. -e "s|@LDFLAGS@|$(foreach FLAG,$(HOST_LDFLAGS),'$(FLAG)',)|" \
  45. -e "s|@PREFIX@|$(STAGING_DIR_HOSTPKG)|" \
  46. < $(MESON_DIR)/openwrt-native.txt.in \
  47. > $(1)
  48. endef
  49. define Meson/CreateCrossFile
  50. $(STAGING_DIR_HOST)/bin/sed \
  51. -e "s|@CC@|$(TARGET_CC)|" \
  52. -e "s|@CXX@|$(TARGET_CXX)|" \
  53. -e "s|@AR@|$(TARGET_AR)|" \
  54. -e "s|@STRIP@|$(TARGET_CROSS)strip|" \
  55. -e "s|@NM@|$(TARGET_NM)|" \
  56. -e "s|@LD@|$(TARGET_CROSS)ld|" \
  57. -e "s|@PKGCONFIG@|$(PKG_CONFIG)|" \
  58. -e "s|@CFLAGS@|$(foreach FLAG,$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS),'$(FLAG)',)|" \
  59. -e "s|@CXXFLAGS@|$(foreach FLAG,$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS),'$(FLAG)',)|" \
  60. -e "s|@LDFLAGS@|$(foreach FLAG,$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS),'$(FLAG)',)|" \
  61. -e "s|@ARCH@|$(ARCH)|" \
  62. -e "s|@CPU@|$(CONFIG_TARGET_SUBTARGET)|" \
  63. -e "s|@ENDIAN@|$(if $(CONFIG_BIG_ENDIAN),big,little)|" \
  64. < $(MESON_DIR)/openwrt-cross.txt.in \
  65. > $(1)
  66. endef
  67. define Host/Configure/Meson
  68. $(call Meson/CreateNativeFile,$(HOST_BUILD_DIR)/openwrt-native.txt)
  69. $(call Meson, \
  70. --native-file $(HOST_BUILD_DIR)/openwrt-native.txt \
  71. $(MESON_HOST_ARGS) \
  72. $(MESON_HOST_BUILD_DIR) \
  73. $(HOST_BUILD_DIR), \
  74. $(MESON_HOST_VARS))
  75. endef
  76. define Host/Compile/Meson
  77. $(call Ninja,-C $(MESON_HOST_BUILD_DIR),)
  78. endef
  79. define Host/Install/Meson
  80. $(call Ninja,-C $(MESON_HOST_BUILD_DIR) install,)
  81. endef
  82. define Host/Uninstall/Meson
  83. -$(call Ninja,-C $(MESON_HOST_BUILD_DIR) uninstall,)
  84. endef
  85. define Build/Configure/Meson
  86. $(call Meson/CreateNativeFile,$(PKG_BUILD_DIR)/openwrt-native.txt)
  87. $(call Meson/CreateCrossFile,$(PKG_BUILD_DIR)/openwrt-cross.txt)
  88. $(call Meson, \
  89. --buildtype plain \
  90. --native-file $(PKG_BUILD_DIR)/openwrt-native.txt \
  91. --cross-file $(PKG_BUILD_DIR)/openwrt-cross.txt \
  92. $(MESON_ARGS) \
  93. $(MESON_BUILD_DIR) \
  94. $(PKG_BUILD_DIR), \
  95. $(MESON_VARS))
  96. endef
  97. define Build/Compile/Meson
  98. $(call Ninja,-C $(MESON_BUILD_DIR),)
  99. endef
  100. define Build/Install/Meson
  101. $(call Ninja,-C $(MESON_BUILD_DIR) install,DESTDIR="$(PKG_INSTALL_DIR)")
  102. endef
  103. Host/Configure=$(call Host/Configure/Meson)
  104. Host/Compile=$(call Host/Compile/Meson)
  105. Host/Install=$(call Host/Install/Meson)
  106. Host/Uninstall=$(call Host/Uninstall/Meson)
  107. Build/Configure=$(call Build/Configure/Meson)
  108. Build/Compile=$(call Build/Compile/Meson)
  109. Build/Install=$(call Build/Install/Meson)