From 1bf79e5eef73196cb3eb79975ce75ccc71aae17a Mon Sep 17 00:00:00 2001 From: vanhofen Date: Fri, 24 Jun 2022 21:29:10 +0200 Subject: [PATCH] - add meson package infrastructure --- make/environment-build.mk | 54 ------------------- package/Makefile.in | 1 + package/meson/meson.mk | 4 +- package/ninja/ninja.mk | 2 +- package/pkg-meson.mk | 108 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 112 insertions(+), 57 deletions(-) create mode 100644 package/pkg-meson.mk diff --git a/make/environment-build.mk b/make/environment-build.mk index 64930ea8..fbbc81f7 100644 --- a/make/environment-build.mk +++ b/make/environment-build.mk @@ -214,60 +214,6 @@ TARGET_MAKE_OPTS = \ # ----------------------------------------------------------------------------- -define meson-cross-config # (dest dir) - $(INSTALL) -d $(1) - ( \ - echo "# Note: Buildsystems's and Meson's terminologies differ about the meaning"; \ - echo "# of 'build', 'host' and 'target':"; \ - echo "# - Buildsystems's 'host' is Meson's 'build'"; \ - echo "# - Buildsystems's 'target' is Meson's 'host'"; \ - echo ""; \ - echo "[binaries]"; \ - echo "c = '$(TARGET_CC)'"; \ - echo "cpp = '$(TARGET_CXX)'"; \ - echo "ar = '$(TARGET_AR)'"; \ - echo "strip = '$(TARGET_STRIP)'"; \ - echo "nm = '$(TARGET_NM)'"; \ - echo "pkgconfig = '$(PKG_CONFIG)'"; \ - echo ""; \ - echo "[built-in options]"; \ - echo "c_args = '$(TARGET_CFLAGS)'"; \ - echo "c_link_args = '$(TARGET_LDFLAGS)'"; \ - echo "cpp_args = '$(TARGET_CXXFLAGS)'"; \ - echo "cpp_link_args = '$(TARGET_LDFLAGS)'"; \ - echo "prefix = '$(prefix)'"; \ - echo ""; \ - echo "[properties]"; \ - echo "needs_exe_wrapper = true"; \ - echo "sys_root = '$(TARGET_DIR)'"; \ - echo "pkg_config_libdir = '$(PKG_CONFIG_LIBDIR)'"; \ - echo ""; \ - echo "[host_machine]"; \ - echo "system = 'linux'"; \ - echo "cpu_family = '$(TARGET_ARCH)'"; \ - echo "cpu = '$(TARGET_CPU)'"; \ - echo "endian = '$(TARGET_ENDIAN)'" \ - ) > $(1)/meson-cross.config -endef - -MESON_CONFIGURE = \ - $(call meson-cross-config,$(PKG_BUILD_DIR)/build); \ - unset CC CXX CPP LD AR NM STRIP; \ - PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" \ - $(HOST_MESON) \ - --buildtype=release \ - --cross-file $(PKG_BUILD_DIR)/build/meson-cross.config \ - -Dstrip=false \ - $(PKG_BUILD_DIR) $(PKG_BUILD_DIR)/build - -NINJA = \ - $(HOST_NINJA) -C $(PKG_BUILD_DIR)/build - -NINJA_INSTALL = DESTDIR=$(TARGET_DIR) \ - $(HOST_NINJA) -C $(PKG_BUILD_DIR)/build install - -# ----------------------------------------------------------------------------- - GITHUB = https://github.com GITHUB_SSH = git@github.com BITBUCKET = https://bitbucket.org diff --git a/package/Makefile.in b/package/Makefile.in index 908b89ad..a3fb0a0f 100644 --- a/package/Makefile.in +++ b/package/Makefile.in @@ -29,4 +29,5 @@ include package/pkg-autotools.mk include package/pkg-cmake.mk include package/pkg-individual.mk include package/pkg-kernel-module.mk +include package/pkg-meson.mk include package/pkg-python.mk diff --git a/package/meson/meson.mk b/package/meson/meson.mk index 4ff7be25..57da01da 100644 --- a/package/meson/meson.mk +++ b/package/meson/meson.mk @@ -18,11 +18,11 @@ HOST_MESON_SITE = $(MESON_SITE) HOST_MESON_DEPENDENCIES = host-ninja host-python3 host-python-setuptools -HOST_MESON = $(HOST_DIR)/bin/meson +HOST_MESON_BINARY = $(HOST_DIR)/bin/meson # Avoid interpreter shebang longer than 128 chars define HOST_MESON_SET_INTERPRETER - $(SED) '1s:.*:#!/usr/bin/env python3:' $(HOST_DIR)/bin/meson + $(SED) '1s:.*:#!/usr/bin/env python3:' $(HOST_MESON_BINARY) endef HOST_MESON_HOST_FINALIZE_HOOKS += HOST_MESON_SET_INTERPRETER diff --git a/package/ninja/ninja.mk b/package/ninja/ninja.mk index ff9b2808..eda03804 100644 --- a/package/ninja/ninja.mk +++ b/package/ninja/ninja.mk @@ -16,7 +16,7 @@ HOST_NINJA_DIR = $(NINJA_DIR) HOST_NINJA_SOURCE = $(NINJA_SOURCE) HOST_NINJA_SITE = $(NINJA_SITE) -HOST_NINJA = $(HOST_DIR)/bin/ninja +HOST_NINJA_BINARY = $(HOST_DIR)/bin/ninja host-ninja: | $(HOST_DIR) $(call host-cmake-package) diff --git a/package/pkg-meson.mk b/package/pkg-meson.mk new file mode 100644 index 00000000..97fabc3c --- /dev/null +++ b/package/pkg-meson.mk @@ -0,0 +1,108 @@ +################################################################################ +# +# Meson packages +# +################################################################################ + +define meson-cross-config # (dest dir) + $(INSTALL) -d $(1) + ( \ + echo "# Note: Buildsystems's and Meson's terminologies differ about the meaning"; \ + echo "# of 'build', 'host' and 'target':"; \ + echo "# - Buildsystems's 'host' is Meson's 'build'"; \ + echo "# - Buildsystems's 'target' is Meson's 'host'"; \ + echo ""; \ + echo "[binaries]"; \ + echo "c = '$(TARGET_CC)'"; \ + echo "cpp = '$(TARGET_CXX)'"; \ + echo "ar = '$(TARGET_AR)'"; \ + echo "strip = '$(TARGET_STRIP)'"; \ + echo "nm = '$(TARGET_NM)'"; \ + echo "pkgconfig = '$(PKG_CONFIG)'"; \ + echo ""; \ + echo "[built-in options]"; \ + echo "c_args = '$(TARGET_CFLAGS)'"; \ + echo "c_link_args = '$(TARGET_LDFLAGS)'"; \ + echo "cpp_args = '$(TARGET_CXXFLAGS)'"; \ + echo "cpp_link_args = '$(TARGET_LDFLAGS)'"; \ + echo "prefix = '$(prefix)'"; \ + echo ""; \ + echo "[properties]"; \ + echo "needs_exe_wrapper = true"; \ + echo "sys_root = '$(TARGET_DIR)'"; \ + echo "pkg_config_libdir = '$(PKG_CONFIG_LIBDIR)'"; \ + echo ""; \ + echo "[host_machine]"; \ + echo "system = 'linux'"; \ + echo "cpu_family = '$(TARGET_ARCH)'"; \ + echo "cpu = '$(TARGET_CPU)'"; \ + echo "endian = '$(TARGET_ENDIAN)'" \ + ) > $(1)/meson-cross.config +endef + +define TARGET_MESON_CONFIGURE + $(call meson-cross-config,$(PKG_BUILD_DIR)/build); \ + unset CC CXX CPP LD AR NM STRIP; \ + $(CHDIR)/$($(PKG)_DIR)/$($(PKG)_SUBDIR); \ + $($(PKG)_CONF_ENV) \ + $(HOST_MESON_BINARY) \ + --buildtype=release \ + --cross-file $(PKG_BUILD_DIR)/build/meson-cross.config \ + -Db_pie=false \ + -Dstrip=false \ + $($(PKG)_CONF_OPTS) \ + $(PKG_BUILD_DIR) $(PKG_BUILD_DIR)/build +endef + +define TARGET_NINJA_BUILD + $(CHDIR)/$($(PKG)_DIR)/$($(PKG)_SUBDIR); \ + $(HOST_NINJA_BINARY) -C $(PKG_BUILD_DIR)/build +endef + +define TARGET_NINJA_INSTALL + $(CHDIR)/$($(PKG)_DIR)/$($(PKG)_SUBDIR); \ + DESTDIR=$(TARGET_DIR) \ + $(HOST_NINJA_BINARY) -C $(PKG_BUILD_DIR)/build install +endef + +define meson-package + $(call PREPARE) + $(call TARGET_MESON_CONFIGURE) + $(call TARGET_NINJA_BUILD) + $(call TARGET_NINJA_INSTALL) + $(call TARGET_FOLLOWUP) +endef + +# ----------------------------------------------------------------------------- + +define HOST_MESON_CONFIGURE + unset CC CXX CPP LD AR NM STRIP; \ + PKG_CONFIG=/usr/bin/pkg-config \ + PKG_CONFIG_PATH=$(HOST_DIR)/lib/pkgconfig \ + $(CHDIR)/$($(PKG)_DIR)/$($(PKG)_SUBDIR); \ + $($(PKG)_CONF_ENV) \ + $(HOST_MESON_BINARY) \ + --prefix=/ \ + --buildtype=release \ + $($(PKG)_CONF_OPTS) \ + $(PKG_BUILD_DIR) $(PKG_BUILD_DIR)/build +endef + +define HOST_NINJA_BUID + $(CHDIR)/$($(PKG)_DIR)/$($(PKG)_SUBDIR); \ + $(HOST_NINJA_BINARY) -C $(PKG_BUILD_DIR)/build +endef + +define HOST_NINJA_INSTALL + $(CHDIR)/$($(PKG)_DIR)/$($(PKG)_SUBDIR); \ + DESTDIR=$(HOST_DIR) \ + $(HOST_NINJA_BINARY) -C $(PKG_BUILD_DIR)/build install +endef + +define host-meson-package + $(call PREPARE) + $(call HOST_MESON_CONFIGURE) + $(call HOST_NINJA) + $(call HOST_NINJA_INSTALL) + $(call HOST_FOLLOWUP) +endef