2021-06-17 21:21:44 +00:00
|
|
|
# To build your package using meson:
|
|
|
|
#
|
|
|
|
# include $(INCLUDE_DIR)/meson.mk
|
|
|
|
# MESON_ARGS+=-Dfoo -Dbar=baz
|
|
|
|
#
|
|
|
|
# To pass additional environment variables to meson:
|
|
|
|
#
|
|
|
|
# MESON_VARS+=FOO=bar
|
|
|
|
#
|
|
|
|
# Default configure/compile/install targets are provided, but can be
|
|
|
|
# overwritten if required:
|
|
|
|
#
|
|
|
|
# define Build/Configure
|
|
|
|
# $(call Build/Configure/Meson)
|
|
|
|
# ...
|
|
|
|
# endef
|
|
|
|
#
|
|
|
|
# same for Build/Compile and Build/Install
|
|
|
|
#
|
|
|
|
# Host packages are built in the same fashion, just use these vars instead:
|
|
|
|
#
|
|
|
|
# MESON_HOST_ARGS+=-Dfoo -Dbar=baz
|
|
|
|
# MESON_HOST_VARS+=FOO=bar
|
|
|
|
|
|
|
|
MESON_DIR:=$(STAGING_DIR_HOST)/lib/meson
|
|
|
|
|
|
|
|
MESON_HOST_BUILD_DIR:=$(HOST_BUILD_DIR)/openwrt-build
|
|
|
|
MESON_HOST_VARS:=
|
|
|
|
MESON_HOST_ARGS:=
|
|
|
|
|
|
|
|
MESON_BUILD_DIR:=$(PKG_BUILD_DIR)/openwrt-build
|
|
|
|
MESON_VARS:=
|
|
|
|
MESON_ARGS:=
|
|
|
|
|
|
|
|
ifneq ($(findstring i386,$(CONFIG_ARCH)),)
|
|
|
|
MESON_ARCH:="x86"
|
|
|
|
else ifneq ($(findstring powerpc64,$(CONFIG_ARCH)),)
|
|
|
|
MESON_ARCH:="ppc64"
|
|
|
|
else ifneq ($(findstring powerpc,$(CONFIG_ARCH)),)
|
|
|
|
MESON_ARCH:="ppc"
|
|
|
|
else ifneq ($(findstring mips64el,$(CONFIG_ARCH)),)
|
|
|
|
MESON_ARCH:="mips64"
|
|
|
|
else ifneq ($(findstring mipsel,$(CONFIG_ARCH)),)
|
|
|
|
MESON_ARCH:="mips"
|
|
|
|
else ifneq ($(findstring armeb,$(CONFIG_ARCH)),)
|
|
|
|
MESON_ARCH:="arm"
|
|
|
|
else
|
|
|
|
MESON_ARCH:=$(CONFIG_ARCH)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# this is undefined for just x64_64
|
|
|
|
ifeq ($(origin CPU_TYPE),undefined)
|
|
|
|
MESON_CPU:="generic"
|
|
|
|
else
|
|
|
|
MESON_CPU:="$(CPU_TYPE)$(if $(CPU_SUBTYPE),+$(CPU_SUBTYPE))"
|
|
|
|
endif
|
|
|
|
|
|
|
|
define Meson
|
2021-11-22 08:51:08 +00:00
|
|
|
$(2) $(STAGING_DIR_HOST)/bin/$(PYTHON) $(STAGING_DIR_HOST)/bin/meson.py $(1)
|
2021-06-17 21:21:44 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Meson/CreateNativeFile
|
|
|
|
$(STAGING_DIR_HOST)/bin/sed \
|
|
|
|
-e "s|@CC@|$(foreach BIN,$(HOSTCC),'$(BIN)',)|" \
|
|
|
|
-e "s|@CXX@|$(foreach BIN,$(HOSTCXX),'$(BIN)',)|" \
|
|
|
|
-e "s|@PKGCONFIG@|$(PKG_CONFIG)|" \
|
2021-10-24 18:10:26 +00:00
|
|
|
-e "s|@CMAKE@|$(STAGING_DIR_HOST)/bin/cmake|" \
|
2022-03-16 23:18:07 +00:00
|
|
|
-e "s|@PYTHON@|$(STAGING_DIR_HOST)/bin/python3|" \
|
2021-06-17 21:21:44 +00:00
|
|
|
-e "s|@CFLAGS@|$(foreach FLAG,$(HOST_CFLAGS) $(HOST_CPPFLAGS),'$(FLAG)',)|" \
|
|
|
|
-e "s|@CXXFLAGS@|$(foreach FLAG,$(HOST_CXXFLAGS) $(HOST_CPPFLAGS),'$(FLAG)',)|" \
|
|
|
|
-e "s|@LDFLAGS@|$(foreach FLAG,$(HOST_LDFLAGS),'$(FLAG)',)|" \
|
|
|
|
-e "s|@PREFIX@|$(HOST_BUILD_PREFIX)|" \
|
|
|
|
< $(MESON_DIR)/openwrt-native.txt.in \
|
|
|
|
> $(1)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Meson/CreateCrossFile
|
|
|
|
$(STAGING_DIR_HOST)/bin/sed \
|
|
|
|
-e "s|@CC@|$(foreach BIN,$(TARGET_CC),'$(BIN)',)|" \
|
|
|
|
-e "s|@CXX@|$(foreach BIN,$(TARGET_CXX),'$(BIN)',)|" \
|
2023-01-27 15:33:25 +00:00
|
|
|
-e "s|@LD@|$(foreach FLAG,$(TARGET_LINKER),'$(FLAG)',)|" \
|
2021-06-17 21:21:44 +00:00
|
|
|
-e "s|@AR@|$(TARGET_AR)|" \
|
|
|
|
-e "s|@STRIP@|$(TARGET_CROSS)strip|" \
|
|
|
|
-e "s|@NM@|$(TARGET_NM)|" \
|
|
|
|
-e "s|@PKGCONFIG@|$(PKG_CONFIG)|" \
|
2021-10-24 18:10:26 +00:00
|
|
|
-e "s|@CMAKE@|$(STAGING_DIR_HOST)/bin/cmake|" \
|
2022-03-16 23:18:07 +00:00
|
|
|
-e "s|@PYTHON@|$(STAGING_DIR_HOST)/bin/python3|" \
|
2021-06-17 21:21:44 +00:00
|
|
|
-e "s|@CFLAGS@|$(foreach FLAG,$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS),'$(FLAG)',)|" \
|
|
|
|
-e "s|@CXXFLAGS@|$(foreach FLAG,$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS),'$(FLAG)',)|" \
|
|
|
|
-e "s|@LDFLAGS@|$(foreach FLAG,$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS),'$(FLAG)',)|" \
|
|
|
|
-e "s|@ARCH@|$(MESON_ARCH)|" \
|
|
|
|
-e "s|@CPU@|$(MESON_CPU)|" \
|
|
|
|
-e "s|@ENDIAN@|$(if $(CONFIG_BIG_ENDIAN),big,little)|" \
|
|
|
|
< $(MESON_DIR)/openwrt-cross.txt.in \
|
|
|
|
> $(1)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Host/Configure/Meson
|
|
|
|
$(call Meson/CreateNativeFile,$(HOST_BUILD_DIR)/openwrt-native.txt)
|
|
|
|
$(call Meson, \
|
2024-02-21 21:13:34 +00:00
|
|
|
setup \
|
2021-06-17 21:21:44 +00:00
|
|
|
--native-file $(HOST_BUILD_DIR)/openwrt-native.txt \
|
2024-02-21 21:16:35 +00:00
|
|
|
-Ddefault_library=static \
|
2021-06-17 21:21:44 +00:00
|
|
|
$(MESON_HOST_ARGS) \
|
|
|
|
$(MESON_HOST_BUILD_DIR) \
|
2022-01-31 02:52:15 +00:00
|
|
|
$(MESON_HOST_BUILD_DIR)/.., \
|
2021-06-17 21:21:44 +00:00
|
|
|
$(MESON_HOST_VARS))
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Host/Compile/Meson
|
|
|
|
+$(NINJA) -C $(MESON_HOST_BUILD_DIR) $(1)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Host/Install/Meson
|
|
|
|
+$(NINJA) -C $(MESON_HOST_BUILD_DIR) install
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Host/Uninstall/Meson
|
|
|
|
+$(NINJA) -C $(MESON_HOST_BUILD_DIR) uninstall || true
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Configure/Meson
|
|
|
|
$(call Meson/CreateNativeFile,$(PKG_BUILD_DIR)/openwrt-native.txt)
|
|
|
|
$(call Meson/CreateCrossFile,$(PKG_BUILD_DIR)/openwrt-cross.txt)
|
|
|
|
$(call Meson, \
|
2024-02-21 21:13:34 +00:00
|
|
|
setup \
|
2024-11-09 23:32:05 +00:00
|
|
|
--buildtype $(if $(CONFIG_DEBUG),debug,plain) \
|
2021-06-17 21:21:44 +00:00
|
|
|
--native-file $(PKG_BUILD_DIR)/openwrt-native.txt \
|
|
|
|
--cross-file $(PKG_BUILD_DIR)/openwrt-cross.txt \
|
2024-02-21 21:16:35 +00:00
|
|
|
-Ddefault_library=both \
|
2021-06-17 21:21:44 +00:00
|
|
|
$(MESON_ARGS) \
|
|
|
|
$(MESON_BUILD_DIR) \
|
|
|
|
$(MESON_BUILD_DIR)/.., \
|
|
|
|
$(MESON_VARS))
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Compile/Meson
|
|
|
|
+$(NINJA) -C $(MESON_BUILD_DIR) $(1)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Install/Meson
|
|
|
|
+DESTDIR="$(PKG_INSTALL_DIR)" $(NINJA) -C $(MESON_BUILD_DIR) install
|
|
|
|
endef
|
|
|
|
|
|
|
|
Host/Configure=$(call Host/Configure/Meson)
|
|
|
|
Host/Compile=$(call Host/Compile/Meson)
|
|
|
|
Host/Install=$(call Host/Install/Meson)
|
|
|
|
Host/Uninstall=$(call Host/Uninstall/Meson)
|
|
|
|
Build/Configure=$(call Build/Configure/Meson)
|
|
|
|
Build/Compile=$(call Build/Compile/Meson)
|
|
|
|
Build/Install=$(call Build/Install/Meson)
|