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.

139 lines
4.1 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. ifneq ($(findstring i386,$(CONFIG_ARCH)),)
  35. MESON_ARCH:="x86"
  36. else ifneq ($(findstring powerpc64,$(CONFIG_ARCH)),)
  37. MESON_ARCH:="ppc64"
  38. else ifneq ($(findstring powerpc,$(CONFIG_ARCH)),)
  39. MESON_ARCH:="ppc"
  40. else ifneq ($(findstring mips64el,$(CONFIG_ARCH)),)
  41. MESON_ARCH:="mips64"
  42. else ifneq ($(findstring mipsel,$(CONFIG_ARCH)),)
  43. MESON_ARCH:="mips"
  44. else ifneq ($(findstring armeb,$(CONFIG_ARCH)),)
  45. MESON_ARCH:="arm"
  46. else
  47. MESON_ARCH:=$(CONFIG_ARCH)
  48. endif
  49. define Meson
  50. $(2) $(STAGING_DIR_HOST)/bin/$(PYTHON) $(MESON_DIR)/meson.py $(1)
  51. endef
  52. define Meson/CreateNativeFile
  53. $(STAGING_DIR_HOST)/bin/sed \
  54. -e "s|@CC@|$(foreach BIN,$(HOSTCC),'$(BIN)',)|" \
  55. -e "s|@CXX@|$(foreach BIN,$(HOSTCXX),'$(BIN)',)|" \
  56. -e "s|@PKGCONFIG@|$(PKG_CONFIG)|" \
  57. -e "s|@CFLAGS@|$(foreach FLAG,$(HOST_CFLAGS) $(HOST_CPPFLAGS),'$(FLAG)',)|" \
  58. -e "s|@CXXFLAGS@|$(foreach FLAG,$(HOST_CXXFLAGS) $(HOST_CPPFLAGS),'$(FLAG)',)|" \
  59. -e "s|@LDFLAGS@|$(foreach FLAG,$(HOST_LDFLAGS),'$(FLAG)',)|" \
  60. -e "s|@PREFIX@|$(STAGING_DIR_HOSTPKG)|" \
  61. < $(MESON_DIR)/openwrt-native.txt.in \
  62. > $(1)
  63. endef
  64. define Meson/CreateCrossFile
  65. $(STAGING_DIR_HOST)/bin/sed \
  66. -e "s|@CC@|$(foreach BIN,$(TARGET_CC),'$(BIN)',)|" \
  67. -e "s|@CXX@|$(foreach BIN,$(TARGET_CXX),'$(BIN)',)|" \
  68. -e "s|@AR@|$(TARGET_AR)|" \
  69. -e "s|@STRIP@|$(TARGET_CROSS)strip|" \
  70. -e "s|@NM@|$(TARGET_NM)|" \
  71. -e "s|@PKGCONFIG@|$(PKG_CONFIG)|" \
  72. -e "s|@CFLAGS@|$(foreach FLAG,$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS),'$(FLAG)',)|" \
  73. -e "s|@CXXFLAGS@|$(foreach FLAG,$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS),'$(FLAG)',)|" \
  74. -e "s|@LDFLAGS@|$(foreach FLAG,$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS),'$(FLAG)',)|" \
  75. -e "s|@ARCH@|$(MESON_ARCH)|" \
  76. -e "s|@CPU@|$(CONFIG_TARGET_SUBTARGET)|" \
  77. -e "s|@ENDIAN@|$(if $(CONFIG_BIG_ENDIAN),big,little)|" \
  78. < $(MESON_DIR)/openwrt-cross.txt.in \
  79. > $(1)
  80. endef
  81. define Host/Configure/Meson
  82. $(call Meson/CreateNativeFile,$(HOST_BUILD_DIR)/openwrt-native.txt)
  83. $(call Meson, \
  84. --native-file $(HOST_BUILD_DIR)/openwrt-native.txt \
  85. $(MESON_HOST_ARGS) \
  86. $(MESON_HOST_BUILD_DIR) \
  87. $(HOST_BUILD_DIR), \
  88. $(MESON_HOST_VARS))
  89. endef
  90. define Host/Compile/Meson
  91. $(call Ninja,-C $(MESON_HOST_BUILD_DIR),)
  92. endef
  93. define Host/Install/Meson
  94. $(call Ninja,-C $(MESON_HOST_BUILD_DIR) install,)
  95. endef
  96. define Host/Uninstall/Meson
  97. -$(call Ninja,-C $(MESON_HOST_BUILD_DIR) uninstall,)
  98. endef
  99. define Build/Configure/Meson
  100. $(call Meson/CreateNativeFile,$(PKG_BUILD_DIR)/openwrt-native.txt)
  101. $(call Meson/CreateCrossFile,$(PKG_BUILD_DIR)/openwrt-cross.txt)
  102. $(call Meson, \
  103. --buildtype plain \
  104. --native-file $(PKG_BUILD_DIR)/openwrt-native.txt \
  105. --cross-file $(PKG_BUILD_DIR)/openwrt-cross.txt \
  106. $(MESON_ARGS) \
  107. $(MESON_BUILD_DIR) \
  108. $(MESON_BUILD_DIR)/.., \
  109. $(MESON_VARS))
  110. endef
  111. define Build/Compile/Meson
  112. $(call Ninja,-C $(MESON_BUILD_DIR),)
  113. endef
  114. define Build/Install/Meson
  115. $(call Ninja,-C $(MESON_BUILD_DIR) install,DESTDIR="$(PKG_INSTALL_DIR)")
  116. endef
  117. Host/Configure=$(call Host/Configure/Meson)
  118. Host/Compile=$(call Host/Compile/Meson)
  119. Host/Install=$(call Host/Install/Meson)
  120. Host/Uninstall=$(call Host/Uninstall/Meson)
  121. Build/Configure=$(call Build/Configure/Meson)
  122. Build/Compile=$(call Build/Compile/Meson)
  123. Build/Install=$(call Build/Install/Meson)