diff --git a/.gitignore b/.gitignore index 785b2f9695f..ad36c970a5c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,15 @@ distrib packages native/*/work* +native/*/status* cross/*/work* cross/*/build* +cross/*/status* kernel/*/work* spk/*/work* spk/*/build* spk/*/publish* +spk/*/status* diyspk/*/work* toolchain/*/work* toolchain/*/*_done diff --git a/Makefile b/Makefile index bd7f202bd2f..dd97b0711f3 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,26 @@ +# Include framework self-test +include mk/spksrc.test-rules.mk + AVAILABLE_TCS = $(notdir $(wildcard toolchain/syno-*)) AVAILABLE_ARCHS = $(notdir $(subst syno-,/,$(AVAILABLE_TCS))) SUPPORTED_SPKS = $(sort $(patsubst spk/%/Makefile,%,$(wildcard spk/*/Makefile))) +ifneq ($(firstword $(MAKECMDGOALS)),test) all: $(SUPPORTED_SPKS) +endif all-noarch: - @for spk in $(sort $(dir $(wildcard spk/*/Makefile))) ; \ + @for spk in $(filter-out $(dir $(wildcard spk/*/BROKEN)),$(dir $(wildcard spk/*/Makefile))) ; \ do \ grep -q "override ARCH" "$${spk}/Makefile" && $(MAKE) -C $${spk} ; \ done - +ifneq ($(firstword $(MAKECMDGOALS)),test) clean: $(addsuffix -clean,$(SUPPORTED_SPKS)) clean: native-clean cross-clean +endif dist-clean: clean dist-clean: kernel-clean toolchain-clean toolkit-clean @@ -50,7 +56,7 @@ cross-clean: done spk-clean: - @for spk in $(dir $(wildcard spk/*/Makefile)) ; \ + @for spk in $(filter-out $(dir $(wildcard spk/*/BROKEN)),$(dir $(wildcard spk/*/Makefile))) ; \ do \ $(MAKE) -C $${spk} clean ; \ done @@ -58,27 +64,36 @@ spk-clean: %: spk/%/Makefile cd $(dir $^) && env $(MAKE) -%-clean: spk/%/Makefile - cd $(dir $^) && env $(MAKE) clean - native-%: native/%/Makefile cd $(dir $^) && env $(MAKE) native-%-clean: native/%/Makefile cd $(dir $^) && env $(MAKE) clean +# build dependency flat list for all packages +dependency-flat: + @echo $(filter-out $(dir $(wildcard spk/*/BROKEN)),$(dir $(wildcard spk/*/Makefile))) + @for spk in $(filter-out $(dir $(wildcard spk/*/BROKEN)),$(dir $(wildcard spk/*/Makefile))) ; \ + do \ + echo "$(MAKE) -s -C $${spk} dependency-flat" ; \ + $(MAKE) -s -C $${spk} dependency-flat ; \ + done + # build dependency tree for all packages -# and take the tree output only (starting with a tab) dependency-tree: - @for spk in $(dir $(wildcard spk/*/Makefile)) ; \ + @echo $(filter-out $(dir $(wildcard spk/*/BROKEN)),$(dir $(wildcard spk/*/Makefile))) + @for spk in $(filter-out $(dir $(wildcard spk/*/BROKEN)),$(dir $(wildcard spk/*/Makefile))) ; \ do \ - $(MAKE) -C $${spk} dependency-tree | grep -P "^[\t]" ; \ + echo "$(MAKE) --no-print-directory -C $${spk} dependency-tree" ; \ + $(MAKE) --no-print-directory -C $${spk} dependency-tree ; \ done # build dependency list for all packages dependency-list: - @for spk in $(dir $(wildcard spk/*/Makefile)) ; \ + @echo $(filter-out $(dir $(wildcard spk/*/BROKEN)),$(dir $(wildcard spk/*/Makefile))) + @for spk in $(filter-out $(dir $(wildcard spk/*/BROKEN)),$(dir $(wildcard spk/*/Makefile))) ; \ do \ + echo "$(MAKE) -s -C $${spk} dependency-list" ; \ $(MAKE) -s -C $${spk} dependency-list ; \ done @@ -166,6 +181,7 @@ local.mk: @echo "DISTRIBUTOR_URL =" >> $@ @echo "REPORT_URL =" >> $@ @echo "DEFAULT_TC =" >> $@ + @echo "#PSTAT = on" >> $@ @echo "#PARALLEL_MAKE = max" >> $@ dsm-%: local.mk diff --git a/cross/libwebp/Makefile b/cross/libwebp/Makefile index 8e0c22afa20..a35463f8f01 100644 --- a/cross/libwebp/Makefile +++ b/cross/libwebp/Makefile @@ -12,23 +12,12 @@ HOMEPAGE = https://developers.google.com/speed/webp COMMENT = WebP codec: library to encode and decode images in WebP format. LICENSE = https://github.com/webmproject/libwebp/blob/master/COPYING -GNU_CONFIGURE = 1 -PRE_CONFIGURE_TARGET = libwebp_pre_configure -CONFIGURE_ARGS = --disable-static -CONFIGURE_ARGS += --enable-libwebpdecoder +CMAKE_USE_NINJA = 1 -ADDITIONAL_CPPFLAGS = -O +include ../../mk/spksrc.cross-cmake.mk -include ../../mk/spksrc.common.mk -# newer gcc require definition of -std=c11 -ifneq ($(call version_lt,$(TCVERSION),6.1)$(call version_ge,$(TCVERSION),3.0),11) -ifneq ($(findstring $(ARCH),$(ARMv5_ARCHS)),$(ARCH)) -ADDITIONAL_CPPFLAGS += -std=c11 +# gcc version below 5.x requires enforcing c11 +# fallback to default for armv5 using older gcc +ifeq ($(call version_le, $(TC_GCC), 5)$(call version_gt,$(TC_GCC),4.7),11) +ADDITIONAL_CFLAGS += -std=c11 endif -endif - -include ../../mk/spksrc.cross-cc.mk - -.PHONY: libwebp_pre_configure -libwebp_pre_configure: - $(RUN) ./autogen.sh diff --git a/cross/mysql-connector-c/Makefile b/cross/mysql-connector-c/Makefile index cd1da65ebc4..65514b8d4f2 100644 --- a/cross/mysql-connector-c/Makefile +++ b/cross/mysql-connector-c/Makefile @@ -13,6 +13,7 @@ COMMENT = MySQL C API (libmysqlclient) LICENSE = GNU GPLv2 USE_NATIVE_CMAKE_LEGACY = 1 +CMAKE_USE_NINJA = 1 include ../../mk/spksrc.cross-cmake.mk diff --git a/cross/openjpeg/Makefile b/cross/openjpeg/Makefile index 9ef44f27ac7..c9d28e6be99 100644 --- a/cross/openjpeg/Makefile +++ b/cross/openjpeg/Makefile @@ -13,6 +13,7 @@ COMMENT = OpenJPEG is an open-source JPEG 2000 codec written in C language. LICENSE = BSD 2-clause simplified CMAKE_USE_NINJA = 1 +CMAKE_ARGS += -Wno-dev CMAKE_ARGS += -DBUILD_STATIC_LIBS=OFF CMAKE_ARGS += -DOPENJP2_COMPILE_OPTIONS="-O" # deactivate build of tools (we use the library only) diff --git a/cross/x265/Makefile b/cross/x265/Makefile index 0cb5b5fce43..ecf50817aea 100644 --- a/cross/x265/Makefile +++ b/cross/x265/Makefile @@ -3,7 +3,7 @@ PKG_VERS = 3.5 PKG_EXT = tar.gz PKG_DIST_NAME = $(PKG_NAME)_$(PKG_VERS).$(PKG_EXT) PKG_DIST_SITE = https://bitbucket.org/multicoreware/x265_git/downloads -PKG_DIR = $(PKG_NAME)_$(PKG_VERS)/source +PKG_DIR = $(PKG_NAME)_$(PKG_VERS) OPTIONAL_DEPENDS = native/nasm @@ -11,78 +11,46 @@ HOMEPAGE = http://x265.org/ COMMENT = x265 is an open source HEVC encoder. LICENSE = GPL -CONFIGURE_TARGET = x265_configure +PRE_CONFIGURE_TARGET = x265_pre_configure +PRE_COMPILE_TARGET = x265_pre_compile -CMAKE_ARGS = -DCMAKE_INSTALL_PREFIX=$(INSTALL_PREFIX) -CMAKE_ARGS += -DCMAKE_CROSSCOMPILING=TRUE -CMAKE_ARGS += -DCMAKE_SYSTEM_NAME=Linux -CMAKE_ARGS += -DCMAKE_C_COMPILER=$(TC_PATH)$(TC_PREFIX)gcc -CMAKE_ARGS += -DCMAKE_CXX_COMPILER=$(TC_PATH)$(TC_PREFIX)g++ -CMAKE_ARGS += -DCMAKE_INSTALL_RPATH=$(INSTALL_PREFIX)/lib -CMAKE_ARGS += -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE -CMAKE_ARGS += -DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE -CMAKE_ARGS += -DENABLE_LIBNUMA=OFF -CMAKE_ARGS += -DENABLE_PIC=ON -#CMAKE_ARGS += -DENABLE_CLI=OFF +CMAKE_USE_NINJA = 1 +CMAKE_USE_NASM = 1 +CMAKE_SOURCE_DIR = source + +# Build directories for default, 12 and 10 bit depth +CMAKE_BUILD_DIR = $(WORK_DIR)/$(PKG_DIR)/buildAll +CMAKE_BUILD_12B = $(WORK_DIR)/$(PKG_DIR)/build12bit +CMAKE_BUILD_10B = $(WORK_DIR)/$(PKG_DIR)/build10bit # additional cmake args for the build of 10 and 12 bit depth libraries -CMAKE_BITLIB_ARGS = +CMAKE_ARGS_BITLIB += -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF +CMAKE_ARGS_BITLIB += -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DEXTRA_LINK_FLAGS="-ldl" +# provide cmake toolchain path when building bitlibs +CMAKE_ARGS_BITLIB += -DCMAKE_TOOLCHAIN_FILE=$(CMAKE_TOOLCHAIN_PKG) # additional cmake args for the final multilib build -CMAKE_MULTILIB_ARGS = +ADDITIONAL_CMAKE_ARGS += -DEXTRA_LIB="x265_main10.a;x265_main12.a" -DEXTRA_LINK_FLAGS="-ldl -L." +ADDITIONAL_CMAKE_ARGS += -DLINKED_10BIT=ON -DLINKED_12BIT=ON -DENABLE_SHARED=ON include ../../mk/spksrc.common.mk -ifeq ($(findstring $(ARCH),$(ARMv5_ARCHS)),$(ARCH)) -CMAKE_ARGS += -DCMAKE_SYSTEM_PROCESSOR=armv5 -CMAKE_ARGS += -DCROSS_COMPILE_ARM=ON -CMAKE_ARGS += -DENABLE_ASSEMBLY=OFF -endif - -ifeq ($(findstring $(ARCH),$(ARMv7_ARCHS) $(ARMv7L_ARCHS)),$(ARCH)) -CMAKE_ARGS += -DCMAKE_SYSTEM_PROCESSOR=armv7 -CMAKE_ARGS += -DCROSS_COMPILE_ARM=ON -CMAKE_ARGS += -DENABLE_ASSEMBLY=OFF -endif - -ifeq ($(findstring $(ARCH),$(ARMv8_ARCHS)),$(ARCH)) -CMAKE_ARGS += -DCMAKE_SYSTEM_PROCESSOR=aarch64 -CMAKE_ARGS += -DCROSS_COMPILE_ARM=ON # asm code for HIGH_BIT_DEPTH is not compatible with arm64/aarch64 # https://bitbucket.org/multicoreware/x265_git/issues/549/fail-to-build-for-aarch64-and-armhf -CMAKE_BITLIB_ARGS += -DENABLE_ASSEMBLY=OFF -endif - -ifeq ($(findstring $(ARCH),$(PPC_ARCHS)),$(ARCH)) -CMAKE_ARGS += -DCMAKE_SYSTEM_PROCESSOR=ppc64 -CMAKE_ARGS += -DCMAKE_CXX_FLAGS=-m32 -CMAKE_ARGS += -DENABLE_ALTIVEC=OFF -CMAKE_ARGS += -DCPU_POWER8=OFF +ifeq ($(findstring $(ARCH),$(ARM_ARCHS) $(PPC_ARCHS)),$(ARCH)) CMAKE_ARGS += -DENABLE_ASSEMBLY=OFF endif -# Define x86asm ifeq ($(findstring $(ARCH),$(i686_ARCHS) $(x64_ARCHS)),$(ARCH)) -BUILD_DEPENDS = native/nasm -NASM_PATH = $(abspath $(PWD)/../../native/nasm/work-native/install/usr/local/bin) -CMAKE_ARGS += -DNASM_EXECUTABLE=$(NASM_PATH)/nasm -ENV += AS=$(NASM_PATH)/nasm -ENV += PATH=$(NASM_PATH):$$PATH -endif - -ifeq ($(findstring $(ARCH),$(x64_ARCHS)),$(ARCH)) -CMAKE_ARGS += -DCMAKE_SYSTEM_PROCESSOR=x86_64 CMAKE_ARGS += -DCMAKE_ASM_NASM_FLAGS=-w-macro-params-legacy endif -ifeq ($(findstring $(ARCH),$(i686_ARCHS)),$(ARCH)) -CMAKE_ARGS += -DCMAKE_SYSTEM_PROCESSOR=x86 # asm code for HIGH_BIT_DEPTH is not compatible with 32-bit arch -CMAKE_BITLIB_ARGS += -DENABLE_ASSEMBLY=OFF -CMAKE_MULTILIB_ARGS += -DCMAKE_ASM_NASM_FLAGS=-w-macro-params-legacy +ifeq ($(findstring $(ARCH),$(i686_ARCHS)),$(ARCH)) +CMAKE_ARGS_BITLIB += -DENABLE_ASSEMBLY=OFF endif -include ../../mk/spksrc.cross-cc.mk +include ../../mk/spksrc.cross-cmake.mk # gcc version above 4.8 required to support hdr10plus ifeq ($(call version_le, $(TC_GCC), 4.8),1) @@ -102,36 +70,18 @@ CMAKE_ARGS += -DNO_ATOMICS=ON CMAKE_ARGS += -DCMAKE_CXX_FLAGS="-DSPKSRC_FIX_PPC853X_4_3" endif +.PHONY: x265_pre_configure +x265_pre_configure: $(CMAKE_TOOLCHAIN_PKG) + @$(MSG) Configure 12BIT libraries + $(RUN) cmake -S $(WORK_DIR)/$(PKG_DIR)/source -B $(CMAKE_BUILD_12B) $(CMAKE_ARGS) $(CMAKE_ARGS_BITLIB) -DMAIN12=ON -G Ninja + @$(MSG) Configure 10BIT libraries + $(RUN) cmake -S $(WORK_DIR)/$(PKG_DIR)/source -B $(CMAKE_BUILD_10B) $(CMAKE_ARGS) $(CMAKE_ARGS_BITLIB) -G Ninja -.PHONY: $(PKG_DIR)/libx265_main12.a $(PKG_DIR)/libx265_main10.a x265_configure - -# First create specific static libraries with build options for 12 and 10 bit depth -PKG_WORK_DIR = $(WORK_DIR)/$(PKG_NAME)_$(PKG_VERS) -PKG_BUILD_12BIT = $(PKG_WORK_DIR)/build12bit -PKG_BUILD_10BIT = $(PKG_WORK_DIR)/build10bit - -CMAKE_BITLIB_ARGS += -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -CMAKE_BITLIB_ARGS += -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DEXTRA_LINK_FLAGS="-ldl" - -$(PKG_DIR)/libx265_main12.a: - mkdir --parents $(PKG_BUILD_12BIT) - @$(MSG) Configure for 12BIT libraries - cd $(PKG_BUILD_12BIT) && cmake $(CMAKE_ARGS) $(CMAKE_BITLIB_ARGS) -DMAIN12=ON ../source +.PHONY: x265_pre_compile +x265_pre_compile: @$(MSG) Build 12BIT libraries - cd $(PKG_BUILD_12BIT) && $(MAKE) $(COMPILE_MAKE_OPTIONS) - @$(RUN) ln -sf $(PKG_BUILD_12BIT)/libx265.a libx265_main12.a - -$(PKG_DIR)/libx265_main10.a: - @$(MSG) Configure for 10BIT libraries - mkdir --parents $(PKG_BUILD_10BIT) - cd $(PKG_BUILD_10BIT) && cmake $(CMAKE_ARGS) $(CMAKE_BITLIB_ARGS) ../source + @$(RUN) ninja -C $(CMAKE_BUILD_12B) @$(MSG) Build 10BIT libraries - cd $(PKG_BUILD_10BIT) && $(MAKE) $(COMPILE_MAKE_OPTIONS) - @$(RUN) ln -sf $(PKG_BUILD_10BIT)/libx265.a libx265_main10.a - -# Aggregate them all together in default 8 bit depth build -CMAKE_MULTILIB_ARGS += -DEXTRA_LIB="x265_main10.a;x265_main12.a" -DEXTRA_LINK_FLAGS="-ldl -L." -CMAKE_MULTILIB_ARGS += -DLINKED_10BIT=ON -DLINKED_12BIT=ON -DENABLE_SHARED=ON - -x265_configure: $(PKG_DIR)/libx265_main12.a $(PKG_DIR)/libx265_main10.a - @$(RUN) cmake $(CMAKE_ARGS) $(CMAKE_MULTILIB_ARGS) . + @$(RUN) ninja -C $(CMAKE_BUILD_10B) + @$(RUN) ln -sf $(CMAKE_BUILD_12B)/libx265.a $(CMAKE_BUILD_DIR)/libx265_main12.a + @$(RUN) ln -sf $(CMAKE_BUILD_10B)/libx265.a $(CMAKE_BUILD_DIR)/libx265_main10.a diff --git a/cross/x265/patches/001-fix-dynamicHDR-flags-arm64.patch b/cross/x265/patches/001-fix-dynamicHDR-flags-arm64.patch index 3c3509d5bcd..edc24a5af16 100644 --- a/cross/x265/patches/001-fix-dynamicHDR-flags-arm64.patch +++ b/cross/x265/patches/001-fix-dynamicHDR-flags-arm64.patch @@ -1,7 +1,7 @@ # set ARM64 flags the same way as in parent CMakeLists.txt # ---- dynamicHDR10/CMakeLists.txt.orig 2021-03-16 12:53:00.000000000 +0000 -+++ dynamicHDR10/CMakeLists.txt 2022-03-26 13:06:56.201819727 +0000 +--- source/dynamicHDR10/CMakeLists.txt.orig 2021-03-16 12:53:00.000000000 +0000 ++++ source/dynamicHDR10/CMakeLists.txt 2022-03-26 13:06:56.201819727 +0000 @@ -43,7 +43,11 @@ endif() endif() diff --git a/cross/x265/patches/002-detect512-on-all-archs.patch b/cross/x265/patches/002-detect512-on-all-archs.patch index 8db178e34ee..73063703e81 100644 --- a/cross/x265/patches/002-detect512-on-all-archs.patch +++ b/cross/x265/patches/002-detect512-on-all-archs.patch @@ -1,5 +1,5 @@ ---- common/cpu.cpp-orig 2019-12-10 22:31:19.000525673 -0500 -+++ common/cpu.cpp 2019-12-10 22:28:41.983368481 -0500 +--- source/common/cpu.cpp-orig 2019-12-10 22:31:19.000525673 -0500 ++++ source/common/cpu.cpp 2019-12-10 22:28:41.983368481 -0500 @@ -110,6 +110,11 @@ const cpu_name_t cpu_names[] = { "", 0 }, }; diff --git a/cross/x265/patches/003-fix-version-info-arm64.patch b/cross/x265/patches/003-fix-version-info-arm64.patch index edd2c902e5c..dce11059a12 100644 --- a/cross/x265/patches/003-fix-version-info-arm64.patch +++ b/cross/x265/patches/003-fix-version-info-arm64.patch @@ -1,8 +1,8 @@ # fix version info for ARM64 # https://bitbucket.org/multicoreware/x265_git/issues/604/linux-arm-aarch64-build-failing-for-high # ---- common/version.cpp.orig 2021-03-16 12:53:00.000000000 +0000 -+++ common/version.cpp 2022-03-26 13:24:42.935435144 +0000 +--- source/common/version.cpp.orig 2021-03-16 12:53:00.000000000 +0000 ++++ source/common/version.cpp 2022-03-26 13:24:42.935435144 +0000 @@ -71,7 +71,7 @@ #define ONOS "[Unk-OS]" #endif diff --git a/cross/zstd/Makefile b/cross/zstd/Makefile index 2b35ba47c2f..f360485c5b6 100644 --- a/cross/zstd/Makefile +++ b/cross/zstd/Makefile @@ -11,8 +11,8 @@ HOMEPAGE = https://facebook.github.io/zstd/ COMMENT = Zstandard is a fast compression algorithm, providing high compression ratios. LICENSE = GPLv2/BSD -MESON_BUILD_DIR = build/meson -NINJA_BUILD_DIR = . +MESON_BASE_DIR = $(WORK_DIR)/$(PKG_DIR)/build/meson +#CMAKE_BASE_DIR = $(WORK_DIR)/$(PKG_DIR)/build/cmake include ../../mk/spksrc.common.mk diff --git a/mk/spksrc.archs.mk b/mk/spksrc.archs.mk index 79c7ddde9bd..42f07d0b301 100644 --- a/mk/spksrc.archs.mk +++ b/mk/spksrc.archs.mk @@ -1,5 +1,16 @@ # Common arch definitions +### + +# Set basedir in case called from spkrc/ or from normal sub-dir +ifeq ($(BASEDIR),) +ifneq ($(shell basename $(CURDIR)),spksrc) +BASEDIR = ../../ +endif +endif + +### + # All available CPU architectures # Distinct SRM and DSM archs to allow handling of different TCVERSION ranges. @@ -33,7 +44,7 @@ x64_ARCHS = $(GENERIC_x64_ARCH) apollolake avoton braswell broadwell broadwellnk # Arch groups ALL_ARCHS = $(x64_ARCHS) $(i686_ARCHS) $(PPC_ARCHS) $(ARM_ARCHS) -ARCHS_WITH_GENERIC_SUPPORT = $(sort $(foreach version, $(AVAILABLE_TCVERSIONS), $(foreach arch, $(GENERIC_ARCHS), $(addsuffix -$(version),$(shell sed -n 's/^TC_ARCH = \(.*\)/\1/p' ../../toolchain/syno-$(arch)-$(version)/Makefile 2>/dev/null))))) +ARCHS_WITH_GENERIC_SUPPORT = $(sort $(foreach version, $(AVAILABLE_TCVERSIONS), $(foreach arch, $(GENERIC_ARCHS), $(addsuffix -$(version),$(shell sed -n 's/^TC_ARCH = \(.*\)/\1/p' $(BASEDIR)toolchain/syno-$(arch)-$(version)/Makefile 2>/dev/null))))) # PPC_ARCHS except qoriq OLD_PPC_ARCHS = powerpc ppc824x ppc853x ppc854x diff --git a/mk/spksrc.common-rules.mk b/mk/spksrc.common-rules.mk new file mode 100644 index 00000000000..283ef7c1dbe --- /dev/null +++ b/mk/spksrc.common-rules.mk @@ -0,0 +1,41 @@ +# Common rules, shared by all makefiles + +### + +.PHONY: clean +clean: + rm -fr work work-* build-*.log publish-*.log status-*.log + +.PHONY: smart-clean +smart-clean: + rm -rf $(WORK_DIR)/$(PKG_DIR) + rm -f $(WORK_DIR)/.$(COOKIE_PREFIX)* + +.PHONY: changelog +changelog: + git log --pretty=format:"- %s" -- $(CURDIR) + +# If the first argument is "rustup"... +ifeq (rustup,$(firstword $(MAKECMDGOALS))) + # use the rest as arguments for "rustup" + RUSTUP_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) + # ...and turn them into do-nothing targets + $(eval $(RUSTUP_ARGS):;@:) +endif + +.PHONY: rustup +rustup: + @rustup $(RUSTUP_ARGS) + +### + +### For make dependency-tree +include ../../mk/spksrc.dependency-tree.mk + +### For make digests +include ../../mk/spksrc.generate-digests.mk + +### For make kernel-required +include ../../mk/spksrc.kernel.mk + +### diff --git a/mk/spksrc.common.mk b/mk/spksrc.common.mk index 16d3dabd5c5..3eac0a497ea 100644 --- a/mk/spksrc.common.mk +++ b/mk/spksrc.common.mk @@ -1,5 +1,17 @@ # Common definitions, shared by all makefiles +### + +# Set basedir in case called from spkrc/ or from normal sub-dir +ifeq ($(BASEDIR),) +ifneq ($(shell basename $(CURDIR)),spksrc) +BASEDIR = ../../ +endif +endif + +# For legacy reasons keep $(PWD) call +PWD := $(CURDIR) + # all will be the default target, regardless of what is defined in the other # makefiles. default: all @@ -35,19 +47,19 @@ PIP_DOWNLOAD_ARGS = download --no-index --find-links $(PIP_DISTRIB_DIR) --disabl LANGUAGES = chs cht csy dan enu fre ger hun ita jpn krn nld nor plk ptb ptg rus spn sve trk # Available toolchains formatted as '{ARCH}-{TC}' -AVAILABLE_TOOLCHAINS = $(subst syno-,,$(sort $(notdir $(wildcard ../../toolchain/syno-*)))) +AVAILABLE_TOOLCHAINS = $(subst syno-,,$(sort $(notdir $(wildcard $(BASEDIR)toolchain/syno-*)))) AVAILABLE_TCVERSIONS = $(sort $(foreach arch,$(AVAILABLE_TOOLCHAINS),$(shell echo ${arch} | cut -f2 -d'-'))) # Available toolchains formatted as '{ARCH}-{TC}' -AVAILABLE_KERNEL = $(subst syno-,,$(sort $(notdir $(wildcard ../../kernel/syno-*)))) +AVAILABLE_KERNEL = $(subst syno-,,$(sort $(notdir $(wildcard $(BASEDIR)kernel/syno-*)))) AVAILABLE_KERNEL_VERSIONS = $(sort $(foreach arch,$(AVAILABLE_KERNEL),$(shell echo ${arch} | cut -f2 -d'-'))) SUPPORTED_KERNEL_VERSIONS = 6.2.4 7.0 # Global arch definitions -include ../../mk/spksrc.archs.mk +include $(BASEDIR)mk/spksrc.archs.mk # Load local configuration -LOCAL_CONFIG_MK = ../../local.mk +LOCAL_CONFIG_MK = $(BASEDIR)local.mk ifneq ($(wildcard $(LOCAL_CONFIG_MK)),) include $(LOCAL_CONFIG_MK) endif @@ -103,18 +115,16 @@ endif # Enable stats over parallel build mode ifneq ($(filter 1 on ON,$(PSTAT)),) PSTAT_TIME = time -o $(PSTAT_LOG) --append -else -PSTAT_TIME = endif # Always send PSTAT output to proper log file # independantly from active Makefile location ifeq ($(filter cross diyspk spk,$(shell basename $(dir $(abspath $(dir $$PWD))))),) -PSTAT_LOG = $(shell pwdx $$(ps -o ppid= $$(echo $$PPID)) | cut -f2 -d:)/build.stats.log +PSTAT_LOG = $(shell pwdx $$(ps -o ppid= $$(echo $$PPID)) | cut -f2 -d:)/status-build.log else ifneq ($(wildcard $(WORK_DIR)),) -PSTAT_LOG = $(WORK_DIR)/../build.stats.log +PSTAT_LOG = $(WORK_DIR)/../status-build.log else -PSTAT_LOG = $(shell pwd)/build.stats.log +PSTAT_LOG = $(CURDIR)/status-build.log endif # Terminal colors diff --git a/mk/spksrc.compile.mk b/mk/spksrc.compile.mk index 5815157f05d..8cd50832eda 100644 --- a/mk/spksrc.compile.mk +++ b/mk/spksrc.compile.mk @@ -31,21 +31,19 @@ endif compile_msg: @$(MSG) "Compiling for $(NAME)" -ifneq ($(filter 1 on ON,$(PSTAT)),) -ifeq ($(filter cross spk,$(shell basename $(dir $(abspath $(dir $$PWD))))),) - @$(MSG) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: $(shell basename $(dir $(abspath $(dir $$PWD)))), NAME: $(NAME) >> $(PSTAT_LOG) +ifeq ($(filter cross spk,$(shell basename $(dir $(abspath $(CURDIR))))),) + @$(MSG) $$(date +%Y%m%d-%H%M%S) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: $(shell basename $(CURDIR)), NAME: $(NAME) >> $(PSTAT_LOG) else - @$(MSG) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: $(ARCH)-$(TCVERSION), NAME: $(NAME) >> $(PSTAT_LOG) -endif + @$(MSG) $$(date +%Y%m%d-%H%M%S) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: $(ARCH)-$(TCVERSION), NAME: $(NAME) >> $(PSTAT_LOG) endif pre_compile_target: compile_msg compile_target: $(PRE_COMPILE_TARGET) ifeq ($(filter $(NCPUS),0 1),) - @$(RUN) $(PSTAT_TIME) $(MAKE) -j$(NCPUS) $(COMPILE_MAKE_OPTIONS) + @$(RUN) $(MAKE) -j$(NCPUS) $(COMPILE_MAKE_OPTIONS) else - @$(RUN) $(PSTAT_TIME) $(MAKE) $(COMPILE_MAKE_OPTIONS) + @$(RUN) $(MAKE) $(COMPILE_MAKE_OPTIONS) endif diff --git a/mk/spksrc.cross-cc.mk b/mk/spksrc.cross-cc.mk index a5998cb38d0..b467d5135b5 100644 --- a/mk/spksrc.cross-cc.mk +++ b/mk/spksrc.cross-cc.mk @@ -53,68 +53,10 @@ include ../../mk/spksrc.install.mk plist: install include ../../mk/spksrc.plist.mk - -### Clean rules -smart-clean: - rm -rf $(WORK_DIR)/$(PKG_DIR) - rm -f $(WORK_DIR)/.$(COOKIE_PREFIX)* - -clean: - rm -fr work work-* build-*.log - all: install plist -### For make kernel-required (used by spksrc.spk.mk) -include ../../mk/spksrc.kernel-required.mk - -### For make digests -include ../../mk/spksrc.generate-digests.mk -### For make dependency-tree -include ../../mk/spksrc.dependency-tree.mk - -.PHONY: all-archs -all-archs: $(addprefix arch-,$(AVAILABLE_TOOLCHAINS)) - -#### - -all-supported: SHELL:=/bin/bash -all-supported: - @$(MSG) Pre-build native dependencies for parallel build - @for depend in $$($(MAKE) dependency-list) ; \ - do \ - if [ "$${depend%/*}" = "native" ]; then \ - $(MSG) "Pre-processing $${depend}" ; \ - $(MSG) " env $(ENV) $(MAKE) -C ../../$$depend" ; \ - env $(ENV) $(MAKE) -C ../../$$depend 2>&1 | tee --append build-$${depend%/*}-$${depend#*/}.log ; \ - [ $${PIPESTATUS[0]} -eq 0 ] || false ; \ - fi ; \ - done ; \ - $(MAKE) $(addprefix supported-arch-,$(SUPPORTED_ARCHS)) - -supported-arch-%: - @$(MSG) BUILDING package for arch $* with SynoCommunity toolchain - -@MAKEFLAGS= $(PSTAT_TIME) $(MAKE) arch-$* 2>&1 | tee --append build-$*.log - -cross-cc_msg: -ifneq ($(filter 1 on ON,$(PSTAT)),) - @$(MSG) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: $(subst build-arch-,,$(MAKECMDGOALS)), NAME: $(NAME) >> $(PSTAT_LOG) -endif - -arch-%: - @$(MSG) Building package for arch $(or $(filter $(addprefix %, $(DEFAULT_TC)), $(filter %$(word 2,$(subst -, ,$*)), $(filter $(firstword $(subst -, ,$*))%, $(AVAILABLE_TOOLCHAINS)))), $*) - $(MAKE) $(addprefix build-arch-, $(or $(filter $(addprefix %, $(DEFAULT_TC)), $(filter %$(word 2,$(subst -, ,$*)), $(filter $(firstword $(subst -, ,$*))%, $(AVAILABLE_TOOLCHAINS)))),$*)) - -build-arch-%: SHELL:=/bin/bash -build-arch-%: cross-cc_msg - @$(MSG) Building package for arch $* -ifneq ($(filter 1 on ON,$(PSTAT)),) - @$(MSG) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: $*, NAME: $(NAME) [BEGIN] >> $(PSTAT_LOG) -endif - @MAKEFLAGS= $(PSTAT_TIME) $(MAKE) ARCH=$(firstword $(subst -, ,$*)) TCVERSION=$(lastword $(subst -, ,$*)) 2>&1 | tee --append build-$*.log ; \ - [ $${PIPESTATUS[0]} -eq 0 ] || false -ifneq ($(filter 1 on ON,$(PSTAT)),) - @$(MSG) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: $*, NAME: $(NAME) [END] >> $(PSTAT_LOG) -endif +### For arch-* and all- +include ../../mk/spksrc.supported.mk #### diff --git a/mk/spksrc.cross-cmake-env.mk b/mk/spksrc.cross-cmake-env.mk index 41695288c80..b0000ada2cb 100644 --- a/mk/spksrc.cross-cmake-env.mk +++ b/mk/spksrc.cross-cmake-env.mk @@ -69,7 +69,7 @@ endif # Use native cmake (latest stable) ifeq ($(strip $(USE_NATIVE_CMAKE)),1) BUILD_DEPENDS += native/cmake - CMAKE_PATH = $(abspath $(PWD)/../../native/cmake/work-native/install/usr/local/bin) + CMAKE_PATH = $(abspath $(CURDIR)/../../native/cmake/work-native/install/usr/local/bin) ENV += PATH=$(CMAKE_PATH):$$PATH export PATH := $(CMAKE_PATH):$(PATH) endif @@ -77,14 +77,14 @@ endif # Use native cmake (Debian 10 "Buster") ifeq ($(strip $(USE_NATIVE_CMAKE_LEGACY)),1) BUILD_DEPENDS += native/cmake-legacy - CMAKE_PATH = $(abspath $(PWD)/../../native/cmake-legacy/work-native/install/usr/local/bin) + CMAKE_PATH = $(abspath $(CURDIR)/../../native/cmake-legacy/work-native/install/usr/local/bin) ENV += PATH=$(CMAKE_PATH):$$PATH export PATH := $(CMAKE_PATH):$(PATH) endif # Use ninja to build ifeq ($(strip $(CMAKE_USE_NINJA)),) - CMAKE_USE_NINJA = 0 + CMAKE_USE_NINJA = 1 endif ifeq ($(strip $(CMAKE_USE_NINJA)),1) CMAKE_ARGS += -G Ninja @@ -98,12 +98,12 @@ endif # .s is raw assembly passed to as # .S is assembly which expects to be preprocessed by a cpp then fed to assembler # Setting the following for ARM may help: -# ENV += AS=$(abspath $(PWD)/../../toolchain/syno-$(ARCH)-$(TCVERSION)/work/$(TC_TARGET)/bin/$(TC_PREFIX)gcc) +# ENV += AS=$(abspath $(CURDIR)/../../toolchain/syno-$(ARCH)-$(TCVERSION)/work/$(TC_TARGET)/bin/$(TC_PREFIX)gcc) ifeq ($(strip $(CMAKE_USE_NASM)),1) # Define x86asm ifeq ($(findstring $(ARCH),$(i686_ARCHS) $(x64_ARCHS)),$(ARCH)) DEPENDS += native/nasm - NASM_PATH = $(abspath $(PWD)/../../native/nasm/work-native/install/usr/local/bin) + NASM_PATH = $(abspath $(CURDIR)/../../native/nasm/work-native/install/usr/local/bin) ENV += PATH=$(NASM_PATH):$$PATH ENV += AS=$(NASM_PATH)/nasm ENABLE_ASSEMBLY = ON @@ -123,9 +123,13 @@ ifeq ($(strip $(CMAKE_DESTDIR)),) CMAKE_DESTDIR = $(INSTALL_DIR) endif +ifeq ($(strip $(CMAKE_BASE_DIR)),) + CMAKE_BASE_DIR = $(WORK_DIR)/$(PKG_DIR) +endif + # set default build directory ifeq ($(strip $(CMAKE_BUILD_DIR)),) - CMAKE_BUILD_DIR = $(WORK_DIR)/$(PKG_DIR)/build + CMAKE_BUILD_DIR = $(CMAKE_BASE_DIR)/build endif # Define per arch specific common options diff --git a/mk/spksrc.cross-cmake.mk b/mk/spksrc.cross-cmake.mk index 4522b0da379..6cab67812fb 100644 --- a/mk/spksrc.cross-cmake.mk +++ b/mk/spksrc.cross-cmake.mk @@ -3,6 +3,9 @@ # prerequisites: # - cross/module depends on cmake # +# remarks: +# - most content is taken from spksrc.cross-cc.mk and modified for cmake +# # Common makefiles include ../../mk/spksrc.common.mk @@ -11,7 +14,24 @@ include ../../mk/spksrc.directories.mk # cmake specific configurations include ../../mk/spksrc.cross-cmake-env.mk -#### +# Configure the included makefiles +URLS = $(PKG_DIST_SITE)/$(PKG_DIST_NAME) +NAME = $(PKG_NAME) +COOKIE_PREFIX = $(PKG_NAME)- +ifneq ($(PKG_DIST_FILE),) +LOCAL_FILE = $(PKG_DIST_FILE) +else +LOCAL_FILE = $(PKG_DIST_NAME) +endif +DIST_FILE = $(DISTRIB_DIR)/$(LOCAL_FILE) +DIST_EXT = $(PKG_EXT) + +ifneq ($(ARCH),) +ARCH_SUFFIX = -$(ARCH)-$(TCVERSION) +TC = syno$(ARCH_SUFFIX) +endif + +### # configure using cmake ifeq ($(strip $(CONFIGURE_TARGET)),) @@ -19,11 +39,13 @@ CONFIGURE_TARGET = cmake_configure_target endif # install -ifeq ($(strip $(CMAKE_DIR)),) -CMAKE_DIR = $(WORK_DIR)/$(PKG_DIR) +ifeq ($(strip $(CMAKE_SOURCE_DIR)),) +CMAKE_SOURCE_DIR = $(CMAKE_BASE_DIR) endif -ifneq ($(strip $(CMAKE_USE_NINJA)),1) +ifeq ($(strip $(CMAKE_USE_NINJA)),1) +include ../../mk/spksrc.cross-ninja.mk +else # compile ifeq ($(strip $(COMPILE_TARGET)),) COMPILE_TARGET = cmake_compile_target @@ -35,6 +57,45 @@ INSTALL_TARGET = cmake_install_target endif endif +ifeq ($(strip $(CMAKE_USE_TOOLCHAIN_FILE)),ON) +CMAKE_ARGS += -DCMAKE_TOOLCHAIN_FILE=$(CMAKE_TOOLCHAIN_PKG) +endif + +### + +include ../../mk/spksrc.pre-check.mk + +include ../../mk/spksrc.cross-env.mk + +include ../../mk/spksrc.download.mk + +include ../../mk/spksrc.depend.mk + +checksum: download +include ../../mk/spksrc.checksum.mk + +extract: checksum depend +include ../../mk/spksrc.extract.mk + +patch: extract +include ../../mk/spksrc.patch.mk + +configure: patch +include ../../mk/spksrc.configure.mk + +compile: configure +include ../../mk/spksrc.compile.mk + +install: compile +include ../../mk/spksrc.install.mk + +plist: install +include ../../mk/spksrc.plist.mk + +all: install plist + +### + .PHONY: $(CMAKE_TOOLCHAIN_PKG) $(CMAKE_TOOLCHAIN_PKG): @$(MSG) Generating $(CMAKE_TOOLCHAIN_PKG) @@ -74,8 +135,6 @@ endif echo 'set(ENV{PKG_CONFIG_LIBDIR} "$(abspath $(PKG_CONFIG_LIBDIR))")' .PHONY: cmake_configure_target - -# default cmake configure: cmake_configure_target: $(CMAKE_TOOLCHAIN_PKG) @$(MSG) - CMake configure @$(MSG) - Dependencies = $(DEPENDS) @@ -83,30 +142,20 @@ cmake_configure_target: $(CMAKE_TOOLCHAIN_PKG) @$(MSG) - Use Toolchain File = $(CMAKE_USE_TOOLCHAIN_FILE) [$(CMAKE_TOOLCHAIN_PKG)] @$(MSG) - Use NASM = $(CMAKE_USE_NASM) @$(MSG) - Use DESTDIR = $(CMAKE_USE_DESTDIR) + @$(MSG) - CMake = $(shell which cmake) [$(shell cmake --version | head -1 | awk '{print $$NF}')] @$(MSG) - Path DESTDIR = $(CMAKE_DESTDIR) @$(MSG) - Path BUILD_DIR = $(CMAKE_BUILD_DIR) - @$(MSG) - Path CMAKE_DIR = $(CMAKE_DIR) + @$(MSG) - Path CMAKE_SOURCE_DIR = $(CMAKE_SOURCE_DIR) $(RUN) rm -rf CMakeCache.txt CMakeFiles - $(RUN) mkdir --parents $(CMAKE_BUILD_DIR) -ifeq ($(strip $(CMAKE_USE_TOOLCHAIN_FILE)),ON) - cd $(CMAKE_BUILD_DIR) && env $(ENV) cmake -DCMAKE_TOOLCHAIN_FILE=$(CMAKE_TOOLCHAIN_PKG) $(CMAKE_ARGS) $(CMAKE_DIR) -else - cd $(CMAKE_BUILD_DIR) && env $(ENV) cmake $(CMAKE_ARGS) $(CMAKE_DIR) -endif + $(RUN) cmake -S $(CMAKE_SOURCE_DIR) -B $(CMAKE_BUILD_DIR) $(CMAKE_ARGS) $(ADDITIONAL_CMAKE_ARGS) .PHONY: cmake_compile_target -ifeq ($(strip $(CMAKE_USE_NINJA)),1) -include ../../mk/spksrc.cross-ninja.mk -else - # default compile: cmake_compile_target: @$(MSG) - CMake compile -ifneq ($(filter 1 on ON,$(PSTAT)),) - @$(MSG) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: $(ARCH)-$(TCVERSION), NAME: $(NAME) >> $(PSTAT_LOG) -endif - env $(ENV) $(PSTAT_TIME) cmake --build $(CMAKE_BUILD_DIR) -j $(NCPUS) + @$(MSG) $$(date +%Y%m%d-%H%M%S) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: $(ARCH)-$(TCVERSION), NAME: $(NAME) >> $(PSTAT_LOG) + $(RUN) cmake --build $(CMAKE_BUILD_DIR) -j $(NCPUS) .PHONY: cmake_install_target @@ -114,11 +163,11 @@ endif cmake_install_target: @$(MSG) - CMake install ifeq ($(strip $(CMAKE_USE_DESTDIR)),0) - cd $(CMAKE_BUILD_DIR) && env $(ENV) $(MAKE) install + $(RUN) cmake --install $(CMAKE_BUILD_DIR) else - cd $(CMAKE_BUILD_DIR) && env $(ENV) $(MAKE) install DESTDIR=$(CMAKE_DESTDIR) -endif + $(RUN) DESTDIR=$(CMAKE_DESTDIR) cmake --install $(CMAKE_BUILD_DIR) endif -# call-up regular build process -include ../../mk/spksrc.cross-cc.mk + +### For arch-* and all- +include ../../mk/spksrc.supported.mk diff --git a/mk/spksrc.cross-dotnet.mk b/mk/spksrc.cross-dotnet.mk index 9abf6302c1b..3e2b02d82bc 100644 --- a/mk/spksrc.cross-dotnet.mk +++ b/mk/spksrc.cross-dotnet.mk @@ -89,26 +89,10 @@ include ../../mk/spksrc.install.mk plist: install include ../../mk/spksrc.plist.mk - -clean: - rm -fr work work-* build-*.log - - all: install plist -### For make digests -include ../../mk/spksrc.generate-digests.mk - -### For make dependency-tree -include ../../mk/spksrc.dependency-tree.mk - -.PHONY: all-archs -all-archs: $(addprefix arch-,$(AVAILABLE_ARCHS)) - -#### -arch-%: - @$(MSG) Building package for arch $* - @MAKEFLAGS= $(MAKE) ARCH=$(basename $(subst -,.,$(basename $(subst .,,$*)))) TCVERSION=$(if $(findstring $*,$(basename $(subst -,.,$(basename $(subst .,,$*))))),$(DEFAULT_TC),$(notdir $(subst -,/,$*))) 2>&1 | tee --append build-$*.log +### For arch-* and all- +include ../../mk/spksrc.supported.mk #### diff --git a/mk/spksrc.cross-env.mk b/mk/spksrc.cross-env.mk index d87c818eb44..61b94ea9626 100644 --- a/mk/spksrc.cross-env.mk +++ b/mk/spksrc.cross-env.mk @@ -27,7 +27,7 @@ TC_VARS_MK = $(WORK_DIR)/tc_vars.mk TC_VARS_CMAKE = $(WORK_DIR)/tc_vars.cmake TC_VARS_MESON = $(WORK_DIR)/tc_vars.meson -# These two variables are needed to build the CFLAGS and LDFLAGS env variables +# Mandatory to build the CFLAGS and LDFLAGS env variables export INSTALL_DIR export INSTALL_PREFIX diff --git a/mk/spksrc.cross-go-env.mk b/mk/spksrc.cross-go-env.mk index 712d359edd7..be2a745afc9 100644 --- a/mk/spksrc.cross-go-env.mk +++ b/mk/spksrc.cross-go-env.mk @@ -56,6 +56,9 @@ ENV += PATH=$(WORK_DIR)/../../../native/go/work-native/go/bin/:$$PATH ENV += GOARCH=$(GO_ARCH) ENV += GOOS=$(GOOS) +# Ensure downloaded mod are u+rw +ENV += GOFLAGS=-modcacherw + ifneq ($(strip $(GO_BIN_DIR)),) GO_BUILD_ARGS := -o $(GO_BIN_DIR) $(GO_BUILD_ARGS) endif diff --git a/mk/spksrc.cross-go.mk b/mk/spksrc.cross-go.mk index 20410f415a2..9162dc00a9b 100644 --- a/mk/spksrc.cross-go.mk +++ b/mk/spksrc.cross-go.mk @@ -99,31 +99,10 @@ include ../../mk/spksrc.install.mk plist: install include ../../mk/spksrc.plist.mk - -### Clean rules -smart-clean: - rm -rf $(EXTRACT_PATH)/ - rm -f $(WORK_DIR)/.$(COOKIE_PREFIX)* - -clean: - rm -fr work work-* build-*.log - - all: install plist -### For make digests -include ../../mk/spksrc.generate-digests.mk - -### For make dependency-tree -include ../../mk/spksrc.dependency-tree.mk - -.PHONY: all-archs -all-archs: $(addprefix arch-,$(AVAILABLE_ARCHS)) - -#### -arch-%: - @$(MSG) Building package for arch $* - @MAKEFLAGS= $(MAKE) ARCH=$(basename $(subst -,.,$(basename $(subst .,,$*)))) TCVERSION=$(if $(findstring $*,$(basename $(subst -,.,$(basename $(subst .,,$*))))),$(DEFAULT_TC),$(notdir $(subst -,/,$*))) 2>&1 | tee --append build-$*.log +### For arch-* and all- +include ../../mk/spksrc.supported.mk #### diff --git a/mk/spksrc.kernel-configure.mk b/mk/spksrc.cross-kernel-configure.mk similarity index 100% rename from mk/spksrc.kernel-configure.mk rename to mk/spksrc.cross-kernel-configure.mk diff --git a/mk/spksrc.kernel-flags.mk b/mk/spksrc.cross-kernel-flags.mk similarity index 100% rename from mk/spksrc.kernel-flags.mk rename to mk/spksrc.cross-kernel-flags.mk diff --git a/mk/spksrc.kernel-headers.mk b/mk/spksrc.cross-kernel-headers.mk similarity index 100% rename from mk/spksrc.kernel-headers.mk rename to mk/spksrc.cross-kernel-headers.mk diff --git a/mk/spksrc.kernel-module.mk b/mk/spksrc.cross-kernel-module.mk similarity index 100% rename from mk/spksrc.kernel-module.mk rename to mk/spksrc.cross-kernel-module.mk diff --git a/mk/spksrc.cross-kernel.mk b/mk/spksrc.cross-kernel.mk new file mode 100644 index 00000000000..882259003c9 --- /dev/null +++ b/mk/spksrc.cross-kernel.mk @@ -0,0 +1,83 @@ +# Common makefiles +include ../../mk/spksrc.common.mk +include ../../mk/spksrc.directories.mk + +# Common kernel variables +include ../../mk/spksrc.cross-kernel-flags.mk + +# Configure the included makefiles +NAME = $(KERNEL_NAME) +URLS = $(KERNEL_DIST_SITE)/$(KERNEL_DIST_NAME) +COOKIE_PREFIX = $(PKG_NAME)- + +ifneq ($(strip $(REQUIRE_KERNEL_MODULE)),) +PKG_NAME = linux-$(subst syno-,,$(NAME)) +PKG_DIR = $(PKG_NAME) +else +PKG_NAME = linux +PKG_DIR = $(PKG_NAME) +endif + +ifneq ($(KERNEL_DIST_FILE),) +LOCAL_FILE = $(KERNEL_DIST_FILE) +# download.mk uses PKG_DIST_FILE +PKG_DIST_FILE = $(KERNEL_DIST_FILE) +else +LOCAL_FILE = $(KERNEL_DIST_NAME) +endif +DISTRIB_DIR = $(KERNEL_DIR)/$(KERNEL_VERS) +DIST_FILE = $(DISTRIB_DIR)/$(LOCAL_FILE) +DIST_EXT = $(KERNEL_EXT) +EXTRACT_CMD = $(EXTRACT_CMD.$(KERNEL_EXT)) --skip-old-files --strip-components=$(KERNEL_STRIP) $(KERNEL_PREFIX) + +##### + +# Prior to interacting with the kernel files +# move the kernel source tree to its final destination +POST_EXTRACT_TARGET = kernel_post_extract_target + +# By default do not install kernel headers +INSTALL_TARGET = nop + +##### + +TC ?= syno-$(KERNEL_ARCH)-$(KERNEL_VERS) + +##### + +include ../../mk/spksrc.cross-env.mk + +include ../../mk/spksrc.download.mk + +checksum: download +include ../../mk/spksrc.checksum.mk + +extract: checksum +include ../../mk/spksrc.extract.mk + +patch: extract +include ../../mk/spksrc.patch.mk + +kernel_configure: patch +include ../../mk/spksrc.cross-kernel-configure.mk + +kernel_module: kernel_configure +include ../../mk/spksrc.cross-kernel-module.mk + +install: kernel_module +include ../../mk/spksrc.cross-kernel-headers.mk + +install: kernel_headers +include ../../mk/spksrc.install.mk + +plist: install +include ../../mk/spksrc.plist.mk + +### For make digests +include ../../mk/spksrc.generate-digests.mk + +.PHONY: kernel_post_extract_target +kernel_post_extract_target: + mv $(WORK_DIR)/$(KERNEL_DIST) $(WORK_DIR)/$(PKG_DIR) + +all: install plist diff --git a/mk/spksrc.cross-meson-env.mk b/mk/spksrc.cross-meson-env.mk index 110d224b742..dded0734872 100644 --- a/mk/spksrc.cross-meson-env.mk +++ b/mk/spksrc.cross-meson-env.mk @@ -1,8 +1,14 @@ # meson cross-compilation definitions +# Set default base meson directory +# Exceptionnally it is under a sub-directory (ex: zstd) +ifeq ($(strip $(MESON_BASE_DIR)),) +MESON_BASE_DIR = $(WORK_DIR)/$(PKG_DIR) +endif + # Set default build directory ifeq ($(strip $(MESON_BUILD_DIR)),) -MESON_BUILD_DIR = builddir +MESON_BUILD_DIR = $(MESON_BASE_DIR)/builddir endif # Set other build options diff --git a/mk/spksrc.cross-meson.mk b/mk/spksrc.cross-meson.mk index ed5b292567f..759e1aa2594 100644 --- a/mk/spksrc.cross-meson.mk +++ b/mk/spksrc.cross-meson.mk @@ -16,6 +16,9 @@ ifeq ($(strip $(CONFIGURE_TARGET)),) CONFIGURE_TARGET = meson_configure_target endif +# call-up ninja build process +include ../../mk/spksrc.cross-ninja.mk + .PHONY: meson_configure_target # default meson configure: @@ -25,10 +28,7 @@ meson_configure_target: @$(MSG) - Build path = $(WORK_DIR)/$(PKG_DIR)/$(MESON_BUILD_DIR) @$(MSG) - Configure ARGS = $(CONFIGURE_ARGS) @$(MSG) - Install prefix = $(INSTALL_PREFIX) - cd $(WORK_DIR)/$(PKG_DIR) && env $(ENV) meson setup $(MESON_BUILD_DIR) -Dprefix=$(INSTALL_PREFIX) $(CONFIGURE_ARGS) - -# call-up ninja build process -include ../../mk/spksrc.cross-ninja.mk + cd $(MESON_BASE_DIR) && env $(ENV) meson setup $(MESON_BUILD_DIR) -Dprefix=$(INSTALL_PREFIX) $(CONFIGURE_ARGS) # call-up regular build process include ../../mk/spksrc.cross-cc.mk diff --git a/mk/spksrc.cross-ninja.mk b/mk/spksrc.cross-ninja.mk index ecd22a57b72..750800aee3c 100644 --- a/mk/spksrc.cross-ninja.mk +++ b/mk/spksrc.cross-ninja.mk @@ -7,31 +7,38 @@ # Force path to pkg-config for cross-building ENV += PKG_CONFIG=/usr/bin/pkg-config +# CMake - begin +ifeq ($(strip $(CMAKE_USE_NINJA)),1) + # Set default build directory ifeq ($(strip $(NINJA_BUILD_DIR)),) -ifeq ($(strip $(CMAKE_USE_NINJA)),1) NINJA_BUILD_DIR = $(CMAKE_BUILD_DIR) -else -NINJA_BUILD_DIR = $(MESON_BUILD_DIR) -endif endif # set default use destdir ifeq ($(strip $(NINJA_USE_DESTDIR)),) ifneq ($(strip $(CMAKE_USE_DESTDIR)),) NINJA_USE_DESTDIR = $(CMAKE_USE_DESTDIR) -else -NINJA_USE_DESTDIR = 1 endif endif # set default destdir directory ifeq ($(strip $(NINJA_DESTDIR)),) -ifeq ($(strip $(CMAKE_USE_NINJA)),1) NINJA_DESTDIR = $(CMAKE_DESTDIR) +endif + +# CMake - end +# Meson - begin (default) else + +# Set default build directory +NINJA_BUILD_DIR = $(MESON_BUILD_DIR) +# set default use destdir +NINJA_USE_DESTDIR = 1 +# set default destdir directory NINJA_DESTDIR = $(INSTALL_DIR) -endif + +# Meson - end (default) endif # compile @@ -53,7 +60,7 @@ ninja_compile_target: ifeq ($(strip $(CMAKE_USE_NINJA)),1) @$(MSG) - Use NASM = $(CMAKE_USE_NASM) endif - cd $(WORK_DIR)/$(PKG_DIR) && env $(ENV) ninja -C $(NINJA_BUILD_DIR) + $(RUN) ninja -C $(NINJA_BUILD_DIR) .PHONY: ninja_install_target @@ -63,7 +70,7 @@ ninja_install_target: @$(MSG) - Ninja installation path = $(NINJA_DESTDIR) @$(MSG) - Ninja use DESTDIR = $(NINJA_USE_DESTDIR) ifeq ($(strip $(NINJA_USE_DESTDIR)),0) - cd $(WORK_DIR)/$(PKG_DIR) && env $(ENV) $(PSTAT_TIME) ninja -j $(NCPUS) -C $(NINJA_BUILD_DIR) install + $(RUN) ninja -C $(NINJA_BUILD_DIR) install else - cd $(WORK_DIR)/$(PKG_DIR) && env $(ENV) DESTDIR=$(NINJA_DESTDIR) $(PSTAT_TIME) ninja -j $(NCPUS) -C $(NINJA_BUILD_DIR) install + $(RUN) DESTDIR=$(NINJA_DESTDIR) ninja -C $(NINJA_BUILD_DIR) install endif diff --git a/mk/spksrc.cross-rust-env.mk b/mk/spksrc.cross-rust-env.mk index 9a3a1a138fd..0aa88bfa86e 100644 --- a/mk/spksrc.cross-rust-env.mk +++ b/mk/spksrc.cross-rust-env.mk @@ -1,19 +1,25 @@ # Configuration for rust compiler # -# Add cargo for rust compiler to default PATH -ifneq ($(BASE_DISTRIB_DIR),) -# Enforce newer cmake when building tier-3 toolchains -CMAKE_PATH = $(abspath $(WORK_DIR)/../../../native/cmake/work-native/install/usr/local/bin) -export CARGO_HOME=$(BASE_DISTRIB_DIR)/cargo -export RUSTUP_HOME=$(BASE_DISTRIB_DIR)/rustup -export PATH:=$(abspath $(BASE_DISTRIB_DIR)/cargo/bin):$(CMAKE_PATH):$(PATH) -endif - ifeq ($(RUSTUP_DEFAULT_TOOLCHAIN),) RUSTUP_DEFAULT_TOOLCHAIN = stable endif +# Set to 1 to force building from +# source Tier-3 toolchains (qoriq) +ifeq ($(RUST_BUILD_TOOLCHAIN),) +RUST_BUILD_TOOLCHAIN = 0 +endif + +# Enforce using newer cmake when building Tier-3 toolchains +ifeq ($(RUST_BUILD_TOOLCHAIN),1) +DEPENDS += native/cmake +CMAKE_PATH = $(abspath $(WORK_DIR)/../../../native/cmake/work-native/install/usr/local/bin) +ifeq ($(findstring cmake,$(subst /,,$(subst :,,$(PATH)))),) +export PATH:=$(CMAKE_PATH):$(PATH) +endif +endif + # When calling directly from toolchain/syno-- # ARCH variable is still unset thus using $(TC_ARCH) although # in generic archs we must rely on $(TC_NANE) @@ -38,7 +44,6 @@ ifeq ($(findstring $(RUST_ARCH), $(ARMv8_ARCHS)),$(RUST_ARCH)) RUST_TARGET = aarch64-unknown-linux-gnu endif ifeq ($(findstring $(RUST_ARCH), $(PPC_ARCHS)),$(RUST_ARCH)) -RUST_BUILD_TOOLCHAIN = 0 RUST_TARGET = powerpc-unknown-linux-gnuspe TC_RUSTUP_TOOLCHAIN = stage$(RUSTUP_DEFAULT_TOOLCHAIN_STAGE)-$(RUST_TARGET) endif diff --git a/mk/spksrc.cross-rust.mk b/mk/spksrc.cross-rust.mk index fdc54cb5904..f9ec673d1ac 100644 --- a/mk/spksrc.cross-rust.mk +++ b/mk/spksrc.cross-rust.mk @@ -99,33 +99,10 @@ include ../../mk/spksrc.install.mk plist: install include ../../mk/spksrc.plist.mk - -### Clean rules -smart-clean: - rm -rf $(WORK_DIR)/$(PKG_DIR) - rm -f $(WORK_DIR)/.$(COOKIE_PREFIX)* - -clean: - rm -fr work work-* build-*.log - all: install plist -### For make kernel-required (used by spksrc.spk.mk) -include ../../mk/spksrc.kernel-required.mk - -### For make digests -include ../../mk/spksrc.generate-digests.mk - -### For make dependency-tree -include ../../mk/spksrc.dependency-tree.mk - -.PHONY: all-archs -all-archs: $(addprefix arch-,$(AVAILABLE_TOOLCHAINS)) - -#### -arch-%: - @$(MSG) Building package for arch $* - @MAKEFLAGS= $(MAKE) ARCH=$(basename $(subst -,.,$(basename $(subst .,,$*)))) TCVERSION=$(if $(findstring $*,$(basename $(subst -,.,$(basename $(subst .,,$*))))),$(DEFAULT_TC),$(notdir $(subst -,/,$*))) 2>&1 | tee --append build-$*.log +### For arch-* and all- +include ../../mk/spksrc.supported.mk #### diff --git a/mk/spksrc.dependency-tree.mk b/mk/spksrc.dependency-tree.mk index bf58db2c9f8..ccd1f7f981a 100644 --- a/mk/spksrc.dependency-tree.mk +++ b/mk/spksrc.dependency-tree.mk @@ -38,7 +38,7 @@ dependency-list: .PHONY: dependency-flat dependency-flat: - @echo "$(CURDIR)" | grep -Po "/\K(spk|cross|native|diyspk)/.*" + @echo "$(CURDIR)" | grep -Po "/\K(spk|cross|native|diyspk|toolchain)/.*" @for depend in $$(echo "$(BUILD_DEPENDS) $(DEPENDS) $(OPTIONAL_DEPENDS)" | tr ' ' '\n' | sort -u | tr '\n' ' ') ; \ do \ DEPENDENCY_WALK=1 $(MAKE) -s -C ../../$$depend dependency-flat ; \ diff --git a/mk/spksrc.directories.mk b/mk/spksrc.directories.mk index f02c506a9e9..c4d823efe13 100644 --- a/mk/spksrc.directories.mk +++ b/mk/spksrc.directories.mk @@ -9,22 +9,20 @@ # * Binaries and libraries are strip in $(STAGING_DIR) # * The full content of $(STAGING_DIR) is packed, it will then be unpacked on the target in $(INSTALL_PREFIX) -PWD := $(shell pwd) - -BASE_DISTRIB_DIR = $(PWD)/../../distrib +BASE_DISTRIB_DIR = $(CURDIR)/../../distrib PIP_DISTRIB_DIR = $(DISTRIB_DIR)/pip PIP_CACHE_DIR = $(WORK_DIR)/pip TOOLCHAIN_DIR = $(BASE_DISTRIB_DIR)/toolchain TOOLKIT_DIR = $(BASE_DISTRIB_DIR)/toolkit KERNEL_DIR = $(BASE_DISTRIB_DIR)/kernel -PACKAGES_DIR = $(PWD)/../../packages +PACKAGES_DIR = $(CURDIR)/../../packages # Default download location, see spksrc.download.mk ifeq ($(strip $(DISTRIB_DIR)),) DISTRIB_DIR = $(BASE_DISTRIB_DIR) endif ifndef WORK_DIR -WORK_DIR = $(PWD)/work$(ARCH_SUFFIX) +WORK_DIR = $(CURDIR)/work$(ARCH_SUFFIX) endif ifndef INSTALL_DIR @@ -44,7 +42,7 @@ endif endif ifndef KERNEL_SOURCE_DIR -KERNEL_SOURCE_DIR = $(PWD)/../../kernel/syno-$(ARCH)-$(TCVERSION)/work/linux +KERNEL_SOURCE_DIR = $(CURDIR)/../../kernel/syno-$(ARCH)-$(TCVERSION)/work/linux endif ifeq ($(strip $(STAGING_INSTALL_PREFIX)),) @@ -81,6 +79,15 @@ ifndef STAGING_INSTALL_WHEELHOUSE STAGING_INSTALL_WHEELHOUSE = $(STAGING_INSTALL_PREFIX)/share/wheelhouse endif +# Mandatory directories to access rust based toolchain +CARGO_HOME=$(abspath $(BASE_DISTRIB_DIR)/cargo) +RUSTUP_HOME=$(abspath $(BASE_DISTRIB_DIR)/rustup) +export CARGO_HOME +export RUSTUP_HOME +ifeq ($(findstring cargo,$(subst /,,$(subst :,,$(PATH)))),) +export PATH:=$(abspath $(BASE_DISTRIB_DIR)/cargo/bin):$(PATH) +endif + define create_target_dir @mkdir -p $$(dirname $@) endef diff --git a/mk/spksrc.install-resources.mk b/mk/spksrc.install-resources.mk index 24b30ed929f..542f56b1626 100644 --- a/mk/spksrc.install-resources.mk +++ b/mk/spksrc.install-resources.mk @@ -58,48 +58,10 @@ include ../../mk/spksrc.install.mk plist: install include ../../mk/spksrc.plist.mk - -### Clean rules -smart-clean: - rm -rf $(WORK_DIR)/$(PKG_DIR) - rm -f $(WORK_DIR)/.$(COOKIE_PREFIX)* - -clean: - rm -fr work work-* build-*.log - all: install plist -### For make digests -include ../../mk/spksrc.generate-digests.mk - -### For make dependency-tree -include ../../mk/spksrc.dependency-tree.mk - -.PHONY: all-archs -all-archs: $(addprefix arch-,$(AVAILABLE_TOOLCHAINS)) - -#### -all-supported: SHELL:=/bin/bash -all-supported: - @$(MSG) Pre-build native dependencies for parallel build - @for depend in $$($(MAKE) dependency-list) ; \ - do \ - if [ "$${depend%/*}" = "native" ]; then \ - $(MSG) "Pre-processing $${depend}" ; \ - $(MSG) " env $(ENV) $(MAKE) -C ../../$$depend" ; \ - env $(ENV) $(MAKE) -C ../../$$depend 2>&1 | tee --append build-$${depend%/*}-$${depend#*/}.log ; \ - [ $${PIPESTATUS[0]} -eq 0 ] || false ; \ - fi ; \ - done ; \ - $(MAKE) $(addprefix supported-arch-,$(SUPPORTED_ARCHS)) - -supported-arch-%: - @$(MSG) BUILDING package for arch $* with SynoCommunity toolchain - -@MAKEFLAGS= $(PSTAT_TIME) $(MAKE) arch-$* 2>&1 | tee --append build-$*.log - -arch-%: - @$(MSG) Building package for arch $* - @MAKEFLAGS= $(MAKE) ARCH=$(basename $(subst -,.,$(basename $(subst .,,$*)))) TCVERSION=$(if $(findstring $*,$(basename $(subst -,.,$(basename $(subst .,,$*))))),$(DEFAULT_TC),$(notdir $(subst -,/,$*))) 2>&1 | tee --append build-$*.log +### For arch-* and all- +include ../../mk/spksrc.supported.mk #### diff --git a/mk/spksrc.kernel-required.mk b/mk/spksrc.kernel-required.mk deleted file mode 100644 index 3bfcb1fff76..00000000000 --- a/mk/spksrc.kernel-required.mk +++ /dev/null @@ -1,15 +0,0 @@ -#### used as subroutine to test whether any dependency has REQUIRE_KERNEL defined - -.PHONY: kernel-required -kernel-required: - @if [ -n "$(REQUIRE_KERNEL)" -o -n "$(REQUIRE_KERNEL_MODULE)" ]; then \ - exit 1 ; \ - fi - @for depend in $(BUILD_DEPENDS) $(DEPENDS) ; do \ - if $(MAKE) --no-print-directory -C ../../$$depend kernel-required >/dev/null 2>&1 ; then \ - exit 0 ; \ - else \ - exit 1 ; \ - fi ; \ - done - diff --git a/mk/spksrc.kernel.mk b/mk/spksrc.kernel.mk index b81b1c487ce..24d90bc9ec6 100644 --- a/mk/spksrc.kernel.mk +++ b/mk/spksrc.kernel.mk @@ -1,86 +1,47 @@ -# Common makefiles -include ../../mk/spksrc.common.mk -include ../../mk/spksrc.directories.mk +### -# Common kernel variables -include ../../mk/spksrc.kernel-flags.mk - -# Configure the included makefiles -NAME = $(KERNEL_NAME) -URLS = $(KERNEL_DIST_SITE)/$(KERNEL_DIST_NAME) -COOKIE_PREFIX = $(PKG_NAME)- - -ifneq ($(strip $(REQUIRE_KERNEL_MODULE)),) -PKG_NAME = linux-$(subst syno-,,$(NAME)) -PKG_DIR = $(PKG_NAME) -else -PKG_NAME = linux -PKG_DIR = $(PKG_NAME) -endif - -ifneq ($(KERNEL_DIST_FILE),) -LOCAL_FILE = $(KERNEL_DIST_FILE) -# download.mk uses PKG_DIST_FILE -PKG_DIST_FILE = $(KERNEL_DIST_FILE) -else -LOCAL_FILE = $(KERNEL_DIST_NAME) +KERNEL_REQUIRED = $(MAKE) kernel-required +ifeq ($(strip $(KERNEL_REQUIRED)),) +ALL_ACTION = $(sort $(basename $(subst -,.,$(basename $(subst .,,$(ARCHS_WITH_KERNEL_SUPPORT)))))) endif -DISTRIB_DIR = $(KERNEL_DIR)/$(KERNEL_VERS) -DIST_FILE = $(DISTRIB_DIR)/$(LOCAL_FILE) -DIST_EXT = $(KERNEL_EXT) -EXTRACT_CMD = $(EXTRACT_CMD.$(KERNEL_EXT)) --skip-old-files --strip-components=$(KERNEL_STRIP) $(KERNEL_PREFIX) - -##### - -# Prior to interacting with the kernel files -# move the kernel source tree to its final destination -POST_EXTRACT_TARGET = kernel_post_extract_target - -# By default do not install kernel headers -INSTALL_TARGET = nop - -##### - -TC ?= syno-$(KERNEL_ARCH)-$(KERNEL_VERS) - -##### - -include ../../mk/spksrc.cross-env.mk - -include ../../mk/spksrc.download.mk - -checksum: download -include ../../mk/spksrc.checksum.mk - -extract: checksum -include ../../mk/spksrc.extract.mk - -patch: extract -include ../../mk/spksrc.patch.mk - -kernel_configure: patch -include ../../mk/spksrc.kernel-configure.mk - -kernel_module: kernel_configure -include ../../mk/spksrc.kernel-module.mk - -install: kernel_module -include ../../mk/spksrc.kernel-headers.mk - -install: kernel_headers -include ../../mk/spksrc.install.mk - -plist: install -include ../../mk/spksrc.plist.mk - -### For make digests -include ../../mk/spksrc.generate-digests.mk - -.PHONY: kernel_post_extract_target -kernel_post_extract_target: - mv $(WORK_DIR)/$(KERNEL_DIST) $(WORK_DIR)/$(PKG_DIR) - -clean: - rm -fr work work-* -all: install plist +#### used as subroutine to test whether any dependency has REQUIRE_KERNEL defined + +.PHONY: kernel-required +kernel-required: + @if [ -n "$(REQUIRE_KERNEL)" -o -n "$(REQUIRE_KERNEL_MODULE)" ]; then \ + exit 1 ; \ + fi + @for depend in $(BUILD_DEPENDS) $(DEPENDS) ; do \ + if $(MAKE) --no-print-directory -C ../../$$depend kernel-required >/dev/null 2>&1 ; then \ + exit 0 ; \ + else \ + exit 1 ; \ + fi ; \ + done + +#### + +kernel-modules-%: SHELL:=/bin/bash +kernel-modules-%: + @if [ "$(filter $(DEFAULT_TC),lastword $(subst -, ,$(MAKECMDGOALS)))" ]; then \ + archs2process="$(filter $(addprefix %-,$(SUPPORTED_KERNEL_VERSIONS)),$(filter $(addsuffix -$(word 1,$(subst ., ,$(word 2,$(subst -, ,$*))))%,$(shell sed -n -e '/TC_ARCH/ s/.*= *//p' ../../toolchain/syno-$*/Makefile)), $(LEGACY_ARCHS)))" ; \ + elif [ "$(filter $(GENERIC_ARCHS),$(subst -, ,$(MAKECMDGOALS)))" ]; then \ + archs2process="$(filter $(addprefix %-,$(lastword $(subst -, ,$(MAKECMDGOALS)))),$(filter $(addsuffix -$(word 1,$(subst ., ,$(word 2,$(subst -, ,$*))))%,$(shell sed -n -e '/TC_ARCH/ s/.*= *//p' ../../toolchain/syno-$*/Makefile)), $(LEGACY_ARCHS)))" ; \ + else \ + archs2process=$* ; \ + fi ; \ + $(MSG) ARCH to be processed: $${archs2process} ; \ + set -e ; \ + for arch in $${archs2process} ; do \ + $(MSG) "Processing $${arch} ARCH" ; \ + MAKEFLAGS= $(PSTAT_TIME) $(MAKE) WORK_DIR=$(CURDIR)/work-$* ARCH=$$(echo $${arch} | cut -f1 -d-) TCVERSION=$$(echo $${arch} | cut -f2 -d-) strip 2>&1 | tee --append build-$*-kernel-modules.log ; \ + [ $${PIPESTATUS[0]} -eq 0 ] || false ; \ + $(MAKE) spkclean ; \ + rm -fr $(CURDIR)/work-$*/$(addprefix linux-, $${arch}) ; \ + $(MAKE) -C ../../toolchain/syno-$${arch} clean ; \ + done + +kernel-arch-%: + $(MAKE) $(addprefix kernel-modules-, $(or $(filter $(addprefix %, $(DEFAULT_TC)), $(filter %$(word 2,$(subst -, ,$*)), $(filter $(firstword $(subst -, ,$*))%, $(AVAILABLE_TOOLCHAINS)))),$*)) + $(MAKE) REQUIRE_KERNEL_MODULE= REQUIRE_KERNEL= WORK_DIR=$(CURDIR)/work-$* $(addprefix build-arch-, $*) diff --git a/mk/spksrc.main-depends.mk b/mk/spksrc.main-depends.mk index 1dc90b495d7..7067f09c1e6 100644 --- a/mk/spksrc.main-depends.mk +++ b/mk/spksrc.main-depends.mk @@ -14,7 +14,6 @@ ARCH_SUFFIX = -$(ARCH)-$(TCVERSION) TC = syno$(ARCH_SUFFIX) endif - ##### ifneq ($(REQUIRE_KERNEL),) @@ -39,44 +38,10 @@ include ../../mk/spksrc.install.mk plist: install include ../../mk/spksrc.plist.mk -### Clean rules -smart-clean: - rm -rf $(WORK_DIR)/$(PKG_DIR) - rm -f $(WORK_DIR)/.$(COOKIE_PREFIX)* - -clean: - rm -rf work work-* build-*.log - all: install plist -### For make dependency-tree -include ../../mk/spksrc.dependency-tree.mk - -.PHONY: all-archs -all-archs: $(addprefix arch-,$(AVAILABLE_TOOLCHAINS)) - -#### -all-supported: SHELL:=/bin/bash -all-supported: - @$(MSG) Pre-build native dependencies for parallel build - @for depend in $$($(MAKE) dependency-list) ; \ - do \ - if [ "$${depend%/*}" = "native" ]; then \ - $(MSG) "Pre-processing $${depend}" ; \ - $(MSG) " env $(ENV) $(MAKE) -C ../../$$depend" ; \ - env $(ENV) $(MAKE) -C ../../$$depend 2>&1 | tee --append build-$${depend%/*}-$${depend#*/}.log ; \ - [ $${PIPESTATUS[0]} -eq 0 ] || false ; \ - fi ; \ - done ; \ - $(MAKE) $(addprefix supported-arch-,$(SUPPORTED_ARCHS)) - -supported-arch-%: - @$(MSG) BUILDING package for arch $* with SynoCommunity toolchain - -@MAKEFLAGS= $(PSTAT_TIME) $(MAKE) arch-$* 2>&1 | tee --append build-$*.log - -arch-%: - @$(MSG) Building package for arch $* - @MAKEFLAGS= $(MAKE) ARCH=$(basename $(subst -,.,$(basename $(subst .,,$*)))) TCVERSION=$(if $(findstring $*,$(basename $(subst -,.,$(basename $(subst .,,$*))))),$(DEFAULT_TC),$(notdir $(subst -,/,$*))) 2>&1 | tee --append build-$*.log +### For managing make all- +include ../../mk/spksrc.supported.mk #### diff --git a/mk/spksrc.native-cc.mk b/mk/spksrc.native-cc.mk index 9f036a0fc6e..a533496cfda 100644 --- a/mk/spksrc.native-cc.mk +++ b/mk/spksrc.native-cc.mk @@ -3,7 +3,7 @@ include ../../mk/spksrc.common.mk include ../../mk/spksrc.directories.mk # Force build in native tool directory, not cross directory. -WORK_DIR := $(PWD)/work-native +WORK_DIR := $(CURDIR)/work-native # Package dependent URLS = $(PKG_DIST_SITE)/$(PKG_DIST_NAME) @@ -49,17 +49,11 @@ include ../../mk/spksrc.install.mk cat_PLIST: @true - -### Clean rules -clean: - rm -fr $(WORK_DIR) - all: install -### For make digests -include ../../mk/spksrc.generate-digests.mk +#### -### For make dependency-tree -include ../../mk/spksrc.dependency-tree.mk +### Include common rules +include ../../mk/spksrc.common-rules.mk -#### +### diff --git a/mk/spksrc.native-cmake.mk b/mk/spksrc.native-cmake.mk index bd788a1f4ff..8e5e2bbdaab 100644 --- a/mk/spksrc.native-cmake.mk +++ b/mk/spksrc.native-cmake.mk @@ -1,7 +1,7 @@ -# Build CMake programs +# Build native CMake programs # -# prerequisites: -# - cross/module depends on cmake +# remarks: +# - most content is taken from spksrc.native-cc.mk and modified for cmake # # Common makefiles @@ -9,7 +9,7 @@ include ../../mk/spksrc.common.mk include ../../mk/spksrc.directories.mk # Force build in native tool directrory, not cross directory. -WORK_DIR := $(PWD)/work-native +WORK_DIR := $(CURDIR)/work-native # Package dependend URLS = $(PKG_DIST_SITE)/$(PKG_DIST_NAME) @@ -25,11 +25,6 @@ DIST_EXT = $(PKG_EXT) ##### -include ../../mk/spksrc.native-env.mk - -# cmake specific configurations -include ../../mk/spksrc.native-cmake-env.mk - # configure using cmake ifeq ($(strip $(CONFIGURE_TARGET)),) CONFIGURE_TARGET = cmake_configure_target @@ -52,6 +47,50 @@ INSTALL_TARGET = cmake_install_target endif endif +### + +.NOTPARALLEL: + +include ../../mk/spksrc.native-env.mk + +# cmake specific configurations +include ../../mk/spksrc.native-cmake-env.mk + +include ../../mk/spksrc.download.mk + +include ../../mk/spksrc.depend.mk + +checksum: download +include ../../mk/spksrc.checksum.mk + +extract: checksum depend +include ../../mk/spksrc.extract.mk + +patch: extract +include ../../mk/spksrc.patch.mk + +configure: patch +include ../../mk/spksrc.configure.mk + +compile: configure +include ../../mk/spksrc.compile.mk + +install: compile +include ../../mk/spksrc.install.mk + +.PHONY: cat_PLIST +cat_PLIST: + @true + +all: install + +### + +### Include common rules +include ../../mk/spksrc.common-rules.mk + +### + .PHONY: cmake_configure_target # default cmake configure: @@ -75,7 +114,7 @@ else # default compile: cmake_compile_target: @$(MSG) - CMake compile - env $(ENV) $(PSTAT_TIME) cmake --build $(CMAKE_BUILD_DIR) -j $(NCPUS) + env $(ENV) cmake --build $(CMAKE_BUILD_DIR) -j $(NCPUS) .PHONY: cmake_install_target @@ -89,5 +128,4 @@ else endif endif -# call-up regular build process -include ../../mk/spksrc.native-cc.mk +#### diff --git a/mk/spksrc.native-env.mk b/mk/spksrc.native-env.mk index f01062ccbc1..d0ddbeb99d2 100644 --- a/mk/spksrc.native-env.mk +++ b/mk/spksrc.native-env.mk @@ -1,3 +1,5 @@ +### + PKG_CONFIG_LIBDIR = $(INSTALL_DIR)/$(INSTALL_PREFIX)/lib/pkgconfig INSTALL_DIR = $(WORK_DIR)/install diff --git a/mk/spksrc.native-install.mk b/mk/spksrc.native-install.mk index 66fc566c162..1eb3fb91b41 100644 --- a/mk/spksrc.native-install.mk +++ b/mk/spksrc.native-install.mk @@ -10,7 +10,7 @@ include ../../mk/spksrc.common.mk include ../../mk/spksrc.directories.mk # Force build in native tool directory, not cross directory. -WORK_DIR := $(PWD)/work-native +WORK_DIR := $(CURDIR)/work-native # Package dependent URLS = $(PKG_DIST_SITE)/$(PKG_DIST_NAME) @@ -27,15 +27,14 @@ DIST_EXT = $(PKG_EXT) ##### -.NOTPARALLEL: - - ifneq ($(REQUIRE_KERNEL),) @$(error native-install cannot be used when REQUIRE_KERNEL is set) endif ##### +.NOTPARALLEL: + include ../../mk/spksrc.native-env.mk include ../../mk/spksrc.download.mk @@ -62,16 +61,11 @@ endif cat_PLIST: @true -### Clean rules -clean: - rm -fr work work-* - all: install -### For make digests -include ../../mk/spksrc.generate-digests.mk +#### -### For make dependency-tree -include ../../mk/spksrc.dependency-tree.mk +### Include common rules +include ../../mk/spksrc.common-rules.mk -#### +### diff --git a/mk/spksrc.native-meson.mk b/mk/spksrc.native-meson.mk index 66d928c8a2b..3edb2874a7c 100644 --- a/mk/spksrc.native-meson.mk +++ b/mk/spksrc.native-meson.mk @@ -9,7 +9,7 @@ include ../../mk/spksrc.common.mk include ../../mk/spksrc.directories.mk # Force build in native tool directrory, not cross directory. -WORK_DIR := $(PWD)/work-native +WORK_DIR := $(CURDIR)/work-native # Package dependend URLS = $(PKG_DIST_SITE)/$(PKG_DIST_NAME) @@ -25,28 +25,19 @@ DIST_EXT = $(PKG_EXT) ##### -.NOTPARALLEL: - -include ../../mk/spksrc.native-env.mk - -# meson specific configurations -include ../../mk/spksrc.native-meson-env.mk - # configure using meson ifeq ($(strip $(CONFIGURE_TARGET)),) CONFIGURE_TARGET = meson_configure_target endif -.PHONY: meson_configure_target +### -# default meson configure: -meson_configure_target: - @$(MSG) - Meson configure - @$(MSG) - Dependencies = $(DEPENDS) - @$(MSG) - Build path = $(WORK_DIR)/$(PKG_DIR)/$(MESON_BUILD_DIR) - @$(MSG) - Configure ARGS = $(CONFIGURE_ARGS) - @$(MSG) - Install prefix = $(INSTALL_PREFIX) - cd $(WORK_DIR)/$(PKG_DIR) && env $(ENV) meson $(MESON_BUILD_DIR) -Dprefix=$(INSTALL_PREFIX) $(CONFIGURE_ARGS) +.NOTPARALLEL: + +include ../../mk/spksrc.native-env.mk + +# meson specific configurations +include ../../mk/spksrc.native-meson-env.mk # call-up ninja build process include ../../mk/spksrc.cross-ninja.mk @@ -77,16 +68,24 @@ include ../../mk/spksrc.install.mk cat_PLIST: @true -### Clean rules -clean: - rm -fr $(WORK_DIR) - all: install -### For make digests -include ../../mk/spksrc.generate-digests.mk +### + +### Include common rules +include ../../mk/spksrc.common-rules.mk + +### + +.PHONY: meson_configure_target -### For make dependency-tree -include ../../mk/spksrc.dependency-tree.mk +# default meson configure: +meson_configure_target: + @$(MSG) - Meson configure + @$(MSG) - Dependencies = $(DEPENDS) + @$(MSG) - Build path = $(WORK_DIR)/$(PKG_DIR)/$(MESON_BUILD_DIR) + @$(MSG) - Configure ARGS = $(CONFIGURE_ARGS) + @$(MSG) - Install prefix = $(INSTALL_PREFIX) + cd $(WORK_DIR)/$(PKG_DIR) && env $(ENV) meson $(MESON_BUILD_DIR) -Dprefix=$(INSTALL_PREFIX) $(CONFIGURE_ARGS) -#### +### diff --git a/mk/spksrc.plist.mk b/mk/spksrc.plist.mk index e0f8fe43ea2..8cce00f4ef3 100644 --- a/mk/spksrc.plist.mk +++ b/mk/spksrc.plist.mk @@ -26,7 +26,7 @@ cat_PLIST: then \ $(PLIST_TRANSFORM) PLIST ; \ # If there is a PLIST.auto file or if parent directory is kernel \ - elif [ -f PLIST.auto -o $$(basename $$(dirname $$(pwd))) = "kernel" ] ; \ + elif [ -f PLIST.auto -o $$(basename $$(dirname $(CURDIR))) = "kernel" ] ; \ then \ cat $(WORK_DIR)/$(PKG_NAME).plist | sort | while read -r file ; \ do \ diff --git a/mk/spksrc.publish.mk b/mk/spksrc.publish.mk new file mode 100644 index 00000000000..8c7e21b7b48 --- /dev/null +++ b/mk/spksrc.publish.mk @@ -0,0 +1,62 @@ +### + +# make publish-all- +ifeq (publish,$(findstring publish,$(subst -, ,$(firstword $(MAKECMDGOALS))))) +ACTION=publish- +endif +ifeq ($(PUBLISH_URL),) +TARGET_ARCH=error-publish_url +endif +ifeq ($(PUBLISH_API_KEY),) +TARGET_ARCH=error-api_key +endif + +#### + +.PHONY: $(ACTION)$(TARGET_TYPE)-arch-error-publish_url $(ACTION)$(TARGET_TYPE)-arch-error-api_key + +$(ACTION)$(TARGET_TYPE)-arch-error-publish_url: + @$(MSG) ######################################################## + @$(MSG) ERROR - Set PUBLISH_URL in local.mk + @$(MSG) ######################################################## + $(error) + +$(ACTION)$(TARGET_TYPE)-arch-error-api_key: + @$(MSG) ######################################################## + @$(MSG) ERROR - Set PUBLISH_API_KEY in local.mk + @$(MSG) ######################################################## + $(error) + +### + +.PHONY: publish-all-$(TARGET_TYPE) + +publish-all-$(TARGET_TYPE): $(addprefix publish-$(TARGET_TYPE)-arch-,$(TARGET_ARCH)) + +$(ACTION)$(TARGET_TYPE)-arch-%: $(TARGET_TYPE)-arch-% + -@MAKEFLAGS= $(MAKE) publish-arch-$* + +publish-arch-%: + $(MAKE) $(addprefix publish-build-arch-, $(or $(filter $(addprefix %, $(DEFAULT_TC)), $(filter %$(word 2,$(subst -, ,$*)), $(filter $(firstword $(subst -, ,$*))%, $(AVAILABLE_TOOLCHAINS)))),$*)) + +### + +publish-build-arch-%: SHELL:=/bin/bash +publish-build-arch-%: + @$(MSG) PUBLISHING package for arch $* to http://synocommunity.com | tee --append build-$*.log + @MAKEFLAGS= $(MAKE) ARCH=$(firstword $(subst -, ,$*)) TCVERSION=$(lastword $(subst -, ,$*)) publish 2>&1 | tee --append publish-$*.log >(grep -e '^http' -e '^{"package":' -e '^{"message":' >> status-publish.log) ; \ + status=$${PIPESTATUS[0]} ; \ + [ $${status[0]} -eq 0 ] || false + +### + +publish: + @response=$$(http --verify=no --ignore-stdin --auth $(PUBLISH_API_KEY): POST $(PUBLISH_URL)/packages @$(SPK_FILE_NAME) --print=hb) ; \ + response_code=$$(echo "$$response" | grep -Fi "HTTP/1.1" | awk '{print $$2}') ; \ + if [ "$$response_code" = "201" ] ; then \ + output=$$(echo "$$response" | awk '/^[[:space:]]*$$/ {p=1;next} p') ; \ + echo "Package published successfully\n$$output" | tee --append publish-$*.log ; \ + else \ + echo "ERROR: Failed to publish package - HTTP response code $$response_code\n$$response" | tee --append publish-$*.log ; \ + exit 1 ; \ + fi diff --git a/mk/spksrc.python.mk b/mk/spksrc.python.mk index 10381950d82..60101cf763c 100644 --- a/mk/spksrc.python.mk +++ b/mk/spksrc.python.mk @@ -5,7 +5,7 @@ # PYTHON_PACKAGE Must be set to the python spk folder (python310, python311, ...) # set default spk/python* path to use -PYTHON_PACKAGE_ROOT = $(realpath $(shell pwd)/../$(PYTHON_PACKAGE)/work-$(ARCH)-$(TCVERSION)) +PYTHON_PACKAGE_ROOT = $(realpath $(CURDIR)/../../spk/$(PYTHON_PACKAGE)/work-$(ARCH)-$(TCVERSION)) include ../../mk/spksrc.archs.mk @@ -50,7 +50,7 @@ PYTHONPATH = $(PYTHON_SITE_PACKAGES_NATIVE):$(PYTHON_LIB_NATIVE):$(PYTHON_STAGIN PYTHON_LIBS := $(wildcard $(PYTHON_STAGING_PREFIX)/lib/pkgconfig/*.pc) # Re-use all python dependencies and mark as already done -PYTHON_DEPENDS := $(foreach cross,$(foreach pkg_name,$(shell $(MAKE) dependency-list -C $(realpath $(PYTHON_PACKAGE_ROOT)/../) 2>/dev/null | grep ^$(PYTHON_PACKAGE) | cut -f2 -d:),$(shell sed -n 's/^PKG_NAME = \(.*\)/\1/p' $(realpath $(shell pwd)/../../$(pkg_name)/Makefile))),$(wildcard $(PYTHON_PACKAGE_ROOT)/.$(cross)-*_done)) +PYTHON_DEPENDS := $(foreach cross,$(foreach pkg_name,$(shell $(MAKE) dependency-list -C $(realpath $(PYTHON_PACKAGE_ROOT)/../) 2>/dev/null | grep ^$(PYTHON_PACKAGE) | cut -f2 -d:),$(shell sed -n 's/^PKG_NAME = \(.*\)/\1/p' $(realpath $(CURDIR)/../../$(pkg_name)/Makefile))),$(wildcard $(PYTHON_PACKAGE_ROOT)/.$(cross)-*_done)) # call-up pre-depend to prepare the shared python build environment PRE_DEPEND_TARGET = python_pre_depend diff --git a/mk/spksrc.spk.mk b/mk/spksrc.spk.mk index 4e5f9bd8320..f5219946e99 100644 --- a/mk/spksrc.spk.mk +++ b/mk/spksrc.spk.mk @@ -473,28 +473,10 @@ $(SPK_FILE_NAME): $(WORK_DIR)/package.tgz $(WORK_DIR)/INFO info-checksum icons s package: $(SPK_FILE_NAME) -### Publish rules -publish: package -ifeq ($(PUBLISH_URL),) - $(error Set PUBLISH_URL in local.mk) -endif -ifeq ($(PUBLISH_API_KEY),) - $(error Set PUBLISH_API_KEY in local.mk) -endif - @response=$$(http --verify=no --ignore-stdin --auth $(PUBLISH_API_KEY): POST $(PUBLISH_URL)/packages @$(SPK_FILE_NAME) --print=hb); \ - response_code=$$(echo "$$response" | grep -Fi "HTTP/1.1" | awk '{print $$2}'); \ - if [ "$$response_code" = "201" ]; then \ - output=$$(echo "$$response" | awk '/^[[:space:]]*$$/ {p=1;next} p'); \ - echo "Package published successfully\n$$output" | tee --append publish-$*.log; \ - else \ - echo "ERROR: Failed to publish package - HTTP response code $$response_code\n$$response" | tee --append publish-$*.log; \ - exit 1; \ - fi +all: package -### Clean rules -clean: - rm -fr work work-* build-*.log publish-*.log +### spk-specific clean rules # Remove work-*/* directories while keeping # work-*/.*|.plist status files @@ -565,187 +547,10 @@ pythonclean: wheelcleanall pythoncleanall: pythonclean rm -fr work-*/[Pp]ython* work-*/.python* -all: package -ifneq ($(filter 1 on ON,$(PSTAT)),) - @$(MSG) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: $(ARCH)-$(TCVERSION) >> $(PSTAT_LOG) -endif - -### For make dependency-tree -include ../../mk/spksrc.dependency-tree.mk - -.PHONY: all-archs -all-archs: $(addprefix arch-,$(AVAILABLE_TOOLCHAINS)) - -.PHONY: publish-all-archs -publish-all-archs: $(addprefix publish-arch-,$(AVAILABLE_TOOLCHAINS)) - -#### -# make all-supported -ifeq (supported,$(subst all-,,$(subst publish-,,$(firstword $(MAKECMDGOALS))))) -ACTION = supported -# make setup not invoked -ifeq ($(strip $(SUPPORTED_ARCHS)),) -ALL_ACTION = error -else -ALL_ACTION = $(SUPPORTED_ARCHS) -endif - -# make all-latest -else ifeq (latest,$(subst all-,,$(subst publish-,,$(firstword $(MAKECMDGOALS))))) -ACTION = latest -ALL_ACTION = $(LATEST_ARCHS) -endif - -# make publish-all-supported | make publish-all-latest -ifeq (publish,$(subst -all-latest,,$(subst -all-supported,,$(firstword $(MAKECMDGOALS))))) -PUBLISH = publish- -.NOTPARALLEL: -endif - -KERNEL_REQUIRED = $(MAKE) kernel-required -ifeq ($(strip $(KERNEL_REQUIRED)),) -ALL_ACTION = $(sort $(basename $(subst -,.,$(basename $(subst .,,$(ARCHS_WITH_KERNEL_SUPPORT)))))) -endif - -#### - -.PHONY: publish-all-$(ACTION) all-$(ACTION) pre-build-native - -pre-build-native: SHELL:=/bin/bash -pre-build-native: - @$(MSG) Pre-build native dependencies for parallel build - @for depend in $$($(MAKE) dependency-list) ; \ - do \ - if [ "$${depend%/*}" = "native" ]; then \ - $(MSG) "Pre-processing $${depend}" ; \ - $(MSG) " env $(ENV) $(MAKE) -C ../../$$depend" ; \ - env $(ENV) $(MAKE) -C ../../$$depend 2>&1 | tee --append build-$${depend%/*}-$${depend#*/}.log ; \ - [ $${PIPESTATUS[0]} -eq 0 ] || false ; \ - fi ; \ - done -ifneq ($(filter all,$(subst -, ,$(MAKECMDGOALS))),) - $(MAKE) $(addprefix $(PUBLISH)$(ACTION)-arch-,$(ALL_ACTION)) -endif - -$(PUBLISH)all-$(ACTION): | pre-build-native - -spk_msg: -ifneq ($(filter 1 on ON,$(PSTAT)),) - @$(MSG) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: $(MAKECMDGOALS), SPK: $(SPK_NAME) >> $(PSTAT_LOG) -endif - -supported-arch-error: - @$(MSG) ######################################################## - @$(MSG) ERROR - Please run make setup from spksrc root directory - @$(MSG) ######################################################## - -supported-arch-%: spk_msg - @$(MSG) "BUILDING package for arch $* (all-supported)" | tee --append build-$*.log - -@MAKEFLAGS= $(PSTAT_TIME) GCC_DEBUG_INFO="$(GCC_DEBUG_INFO)" $(MAKE) $(addprefix arch-, $*) - -publish-supported-arch-%: spk_msg - @$(MSG) "BUILDING and PUBLISHING package for arch $* (publish-all-supported)" | tee --append build-$*.log - -@MAKEFLAGS= $(PSTAT_TIME) GCC_DEBUG_INFO="$(GCC_DEBUG_INFO)" $(MAKE) $(addprefix publish-arch-, $*) - -latest-arch-%: spk_msg - @$(MSG) "BUILDING package for arch $* (all-latest)" | tee --append build-$*.log - -@MAKEFLAGS= $(PSTAT_TIME) GCC_DEBUG_INFO="$(GCC_DEBUG_INFO)" $(MAKE) $(addprefix arch-, $*) - -publish-latest-arch-%: spk_msg - @$(MSG) "BUILDING and PUBLISHING package for arch $* (publish-all-latest)" | tee --append build-$*.log - -@MAKEFLAGS= $(PSTAT_TIME) GCC_DEBUG_INFO="$(GCC_DEBUG_INFO)" $(MAKE) $(addprefix publish-arch-, $*) - -#### - -all-legacy: spk_msg - @$(MSG) BUILDING package for legacy DSM and SRM archs - $(MAKE) legacy-toolchain-5.2 legacy-toolchain-1.2 - -publish-all-legacy: spk_msg - @$(MSG) BUILDING and PUBLISHING package for legacy DSM archs - $(MAKE) publish-legacy-toolchain-5.2 - -#### - -legacy-toolchain-%: spk_msg - @$(MSG) BUILDING packages for toolchain $* - @for arch in $(sort $(basename $(subst -,.,$(basename $(subst .,,$(filter %$*, $(LEGACY_ARCHS))))))) ; \ - do \ - $(MAKE) arch-$$arch-$* ; \ - done \ - -publish-legacy-toolchain-%: spk_msg - @$(MSG) BUILDING and PUBLISHING packages for toolchain $* - @for arch in $(sort $(basename $(subst -,.,$(basename $(subst .,,$(filter %$*, $(LEGACY_ARCHS))))))) ; \ - do \ - $(MAKE) publish-arch-$$arch-$* ; \ - done \ - -#### - -kernel-modules-%: SHELL:=/bin/bash -kernel-modules-%: - @if [ "$(filter $(DEFAULT_TC),lastword $(subst -, ,$(MAKECMDGOALS)))" ]; then \ - archs2process="$(filter $(addprefix %-,$(SUPPORTED_KERNEL_VERSIONS)),$(filter $(addsuffix -$(word 1,$(subst ., ,$(word 2,$(subst -, ,$*))))%,$(shell sed -n -e '/TC_ARCH/ s/.*= *//p' ../../toolchain/syno-$*/Makefile)), $(LEGACY_ARCHS)))" ; \ - elif [ "$(filter $(GENERIC_ARCHS),$(subst -, ,$(MAKECMDGOALS)))" ]; then \ - archs2process="$(filter $(addprefix %-,$(lastword $(subst -, ,$(MAKECMDGOALS)))),$(filter $(addsuffix -$(word 1,$(subst ., ,$(word 2,$(subst -, ,$*))))%,$(shell sed -n -e '/TC_ARCH/ s/.*= *//p' ../../toolchain/syno-$*/Makefile)), $(LEGACY_ARCHS)))" ; \ - else \ - archs2process=$* ; \ - fi ; \ - $(MSG) ARCH to be processed: $${archs2process} ; \ - set -e ; \ - for arch in $${archs2process} ; do \ - $(MSG) "Processing $${arch} ARCH" ; \ - MAKEFLAGS= $(PSTAT_TIME) $(MAKE) WORK_DIR=$(PWD)/work-$* ARCH=$$(echo $${arch} | cut -f1 -d-) TCVERSION=$$(echo $${arch} | cut -f2 -d-) strip 2>&1 | tee --append build-$*.log ; \ - [ $${PIPESTATUS[0]} -eq 0 ] || false ; \ - $(MAKE) spkclean ; \ - rm -fr $(PWD)/work-$*/$(addprefix linux-, $${arch}) ; \ - $(MAKE) -C ../../toolchain/syno-$${arch} clean ; \ - done - -arch-%: | pre-build-native -ifneq ($(strip $(REQUIRE_KERNEL_MODULE)),) - $(MAKE) $(addprefix kernel-modules-, $(or $(filter $(addprefix %, $(DEFAULT_TC)), $(filter %$(word 2,$(subst -, ,$*)), $(filter $(firstword $(subst -, ,$*))%, $(AVAILABLE_TOOLCHAINS)))),$*)) - $(MAKE) REQUIRE_KERNEL_MODULE= REQUIRE_KERNEL= WORK_DIR=$(PWD)/work-$* $(addprefix build-arch-, $*) -else - # handle and allow parallel build for: arch- | make arch--X.Y - @$(MSG) BUILDING package for arch $(or $(filter $(addprefix %, $(DEFAULT_TC)), $(filter %$(word 2,$(subst -, ,$*)), $(filter $(firstword $(subst -, ,$*))%, $(AVAILABLE_TOOLCHAINS)))), $*) - $(MAKE) $(addprefix build-arch-, $(or $(filter $(addprefix %, $(DEFAULT_TC)), $(filter %$(word 2,$(subst -, ,$*)), $(filter $(firstword $(subst -, ,$*))%, $(AVAILABLE_TOOLCHAINS)))),$*)) -endif - -build-arch-%: SHELL:=/bin/bash -build-arch-%: spk_msg - @$(MSG) BUILDING package for arch $* -ifneq ($(filter 1 on ON,$(PSTAT)),) - @$(MSG) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: $*, SPK: $(SPK_NAME) [BEGIN] >> $(PSTAT_LOG) -endif - @MAKEFLAGS= $(PSTAT_TIME) GCC_DEBUG_INFO="$(GCC_DEBUG_INFO)" $(MAKE) ARCH=$(firstword $(subst -, ,$*)) TCVERSION=$(lastword $(subst -, ,$*)) 2>&1 | tee --append build-$*.log ; \ - [ $${PIPESTATUS[0]} -eq 0 ] || false -ifneq ($(filter 1 on ON,$(PSTAT)),) - @$(MSG) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: $*, SPK: $(SPK_NAME) [END] >> $(PSTAT_LOG) -endif - - -publish-arch-%: SHELL:=/bin/bash -publish-arch-%: spk_msg -ifneq ($(strip $(REQUIRE_KERNEL_MODULE)),) - $(MAKE) $(addprefix kernel-modules-, $(or $(filter $(addprefix %, $(DEFAULT_TC)), $(filter %$(word 2,$(subst -, ,$*)), $(filter $(firstword $(subst -, ,$*))%, $(AVAILABLE_TOOLCHAINS)))),$*)) - $(MAKE) REQUIRE_KERNEL_MODULE= REQUIRE_KERNEL= WORK_DIR=$(PWD)/work-$* $(addprefix publish-arch-, $*) -else - # handle and allow parallel build for: arch- | make arch--X.Y - @$(MSG) BUILDING and PUBLISHING package for arch $* - @MAKEFLAGS= $(PSTAT_TIME) GCC_DEBUG_INFO="$(GCC_DEBUG_INFO)" $(MAKE) ARCH=$(basename $(subst -,.,$(basename $(subst .,,$*)))) TCVERSION=$(if $(findstring $*,$(basename $(subst -,.,$(basename $(subst .,,$*))))),$(DEFAULT_TC),$(notdir $(subst -,/,$*))) publish 2>&1 | tee --append build-$*.log >(grep -e '^http' -e '^{"package":' -e '^{"message":' >> publish-$*.log) ; \ - [ $${PIPESTATUS[0]} -eq 0 ] || false -endif - -#### - -changelog: - @echo $(shell git log --pretty=format:"- %s" -- $(PWD)) - -#### +### For managing make all- +include ../../mk/spksrc.supported.mk -### For make kernel-required -include ../../mk/spksrc.kernel-required.mk +### For managing make publish-all- +include ../../mk/spksrc.publish.mk -#### +### diff --git a/mk/spksrc.supported.mk b/mk/spksrc.supported.mk new file mode 100644 index 00000000000..9c64329de5f --- /dev/null +++ b/mk/spksrc.supported.mk @@ -0,0 +1,80 @@ +#### + +### Include common rules +include ../../mk/spksrc.common-rules.mk + + +### + +# make all-supported +ifeq (supported,$(findstring supported,$(subst -, ,$(firstword $(MAKECMDGOALS))))) +TARGET_TYPE = supported +TARGET_ARCH = $(SUPPORTED_ARCHS) + +# make all-latest +else ifeq (latest,$(findstring latest,$(subst -, ,$(firstword $(MAKECMDGOALS))))) +TARGET_TYPE = latest +TARGET_ARCH = $(LATEST_ARCHS) +endif + +# error: make setup not invoked +ifneq ($(strip $(TARGET_TYPE)),) +ifeq ($(strip $(SUPPORTED_ARCHS)),) +TARGET_ARCH = error +endif +endif + +#### + +.PHONY: supported-arch-error + +$(ACTION)$(TARGET_TYPE)-arch-error: + @$(MSG) ######################################################## + @$(MSG) ERROR - Please run make setup from spksrc root directory + @$(MSG) ######################################################## + +### + +.PHONY: all-$(TARGET_TYPE) pre-build-native + +all-$(TARGET_TYPE): $(addprefix $(TARGET_TYPE)-arch-,$(TARGET_ARCH)) + +pre-build-native: SHELL:=/bin/bash +pre-build-native: + @$(MSG) $$(date +%Y%m%d-%H%M%S) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: native, NAME: n/a [BEGIN] >> $(PSTAT_LOG) + @$(MSG) Pre-build native dependencies for parallel build [START] + @for depend in $$($(MAKE) dependency-list) ; \ + do \ + if [ "$${depend%/*}" = "native" ]; then \ + $(MSG) "Pre-processing $${depend}" | tee --append build-$${depend%/*}-$${depend#*/}.log ; \ + $(MSG) " env $(ENV) $(MAKE) -C ../../$$depend" | tee --append build-$${depend%/*}-$${depend#*/}.log ; \ + env $(ENV) $(MAKE) -C ../../$$depend 2>&1 | tee --append build-$${depend%/*}-$${depend#*/}.log ; \ + [ $${PIPESTATUS[0]} -eq 0 ] || false ; \ + fi ; \ + done ; \ + $(MSG) Pre-build native dependencies for parallel build [END] ; \ + $(MSG) $$(date +%Y%m%d-%H%M%S) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: native, NAME: n/a [END] >> $(PSTAT_LOG) + @$(MSG) PROCESSING archs $(TARGET_ARCH) + +$(TARGET_TYPE)-arch-% &: pre-build-native + -@MAKEFLAGS= GCC_DEBUG_INFO="$(GCC_DEBUG_INFO)" $(MAKE) arch-$* + +ifneq ($(strip $(REQUIRE_KERNEL_MODULE)),) +arch-% &: kernel-arch-% +else +arch-%: +endif + $(PSTAT_TIME) $(MAKE) $(addprefix build-arch-, $(or $(filter $(addprefix %, $(DEFAULT_TC)), $(filter %$(word 2,$(subst -, ,$*)), $(filter $(firstword $(subst -, ,$*))%, $(AVAILABLE_TOOLCHAINS)))),$*)) | tee --append build-$*.log + +#### + +build-arch-%: SHELL:=/bin/bash +build-arch-%: + @$(MSG) BUILDING package for arch $* with SynoCommunity toolchain + @$(MSG) $$(date +%Y%m%d-%H%M%S) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: $*, NAME: $(NAME) [BEGIN] >> $(PSTAT_LOG) + @MAKEFLAGS= GCC_DEBUG_INFO="$(GCC_DEBUG_INFO)" $(MAKE) ARCH=$(firstword $(subst -, ,$*)) TCVERSION=$(lastword $(subst -, ,$*)) 2>&1 ; \ + status=$${PIPESTATUS[0]} ; \ + $(MSG) $$(date +%Y%m%d-%H%M%S) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: $*, NAME: $(NAME) [END] >> $(PSTAT_LOG) ; \ + [ $${status[0]} -eq 0 ] || false + +#### diff --git a/mk/spksrc.tc-rust.mk b/mk/spksrc.tc-rust.mk index df6ba910779..69918445c71 100644 --- a/mk/spksrc.tc-rust.mk +++ b/mk/spksrc.tc-rust.mk @@ -111,8 +111,6 @@ else @$(MSG) "Target $(RUST_TARGET) unavailable..." ifeq ($(RUST_BUILD_TOOLCHAIN),1) @$(MSG) "Build rust target $(RUST_TARGET) from sources" - @$(MSG) "Enforce usage of CMake 3.20.0 or higher" - @$(MAKE) -C ../../native/cmake @$(MSG) "Building Tier-3 rust target: $(RUST_TARGET)" @(cd $(WORK_DIR) && [ ! -d rust ] && git clone --depth 1 https://github.com/rust-lang/rust.git || true) @(cd $(WORK_DIR)/rust && rm -f config.toml && ./x setup compiler) @@ -127,9 +125,6 @@ ifeq ($(RUST_BUILD_TOOLCHAIN),1) done @$(MSG) "Building Tier 3 rust target: $(RUST_TARGET) - stage$(RUSTUP_DEFAULT_TOOLCHAIN_STAGE) complete" rustup show -else - @$(MSG) "Install rust target $(RUST_TARGET) from native" - @$(MAKE) -C ../../native/rust-qoriq endif endif diff --git a/mk/spksrc.tc.mk b/mk/spksrc.tc.mk index 47ffb7a3085..6cda4c398e4 100644 --- a/mk/spksrc.tc.mk +++ b/mk/spksrc.tc.mk @@ -3,11 +3,16 @@ SHELL := $(SHELL) -e default: all -WORK_DIR := $(shell pwd)/work +WORK_DIR := $(CURDIR)/work include ../../mk/spksrc.directories.mk include ../../mk/spksrc.common.mk +### Include common rules +include ../../mk/spksrc.common-rules.mk + +include ../../mk/spksrc.cross-rust-env.mk + # Include cross-cmake-env.mk to generate its toolchain file include ../../mk/spksrc.cross-cmake-env.mk @@ -39,6 +44,8 @@ TC_LOCAL_VARS_MESON = $(WORK_DIR)/tc_vars.meson RUN = cd $(WORK_DIR)/$(TC_TARGET) && env $(ENV) +include ../../mk/spksrc.depend.mk + download: include ../../mk/spksrc.download.mk @@ -63,7 +70,7 @@ include ../../mk/spksrc.tc-flags.mk rustc: flag include ../../mk/spksrc.tc-rust.mk -all: rustc $(TC_LOCAL_VARS_CMAKE) $(TC_LOCAL_VARS_MESON) $(TC_LOCAL_VARS_MK) +all: rustc depend $(TC_LOCAL_VARS_CMAKE) $(TC_LOCAL_VARS_MESON) $(TC_LOCAL_VARS_MK) .PHONY: $(TC_LOCAL_VARS_MK) $(TC_LOCAL_VARS_MK): @@ -185,9 +192,5 @@ else @echo TC_KERNEL := $(TC_KERNEL) endif -### Clean rules -clean: - rm -fr $(WORK_DIR) - ### For make digests include ../../mk/spksrc.generate-digests.mk diff --git a/mk/spksrc.test-rules.mk b/mk/spksrc.test-rules.mk new file mode 100644 index 00000000000..df4a32c9d9b --- /dev/null +++ b/mk/spksrc.test-rules.mk @@ -0,0 +1,115 @@ +# Framework testing common rules, shared by all makefiles + +include mk/spksrc.common.mk + +### + +# If the first argument is "test"... +ifeq (test,$(firstword $(MAKECMDGOALS))) + # use the rest as arguments for "test" + TEST_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) + # ...and turn them into do-nothing targets + $(eval $(TEST_ARGS):;@:) +ifeq ($(strip $(TEST_ARGS)),) + $(error Argument missing for 'make test') +endif +endif + +.PHONY: test +test: + $(MAKE) test-$(TEST_ARGS) + +### + +TEST_DEFAULT_SPK = spk/demoservice diyspk/tmux +TEST_DEFAULT = cross/tree cross/libtree cross/zsh +TEST_RUSTC = cross/bat +TEST_CMAKE = cross/intel-gmmlib +TEST_GNUCONFIGURE = cross/ncursesw +TEST_MESON = cross/libdrm +TEST_FFMPEG = spk/ffmpeg5 +TEST_FFMPEG_DEP = spk/tvheadend +TEST_PYTHON = spk/python311 +TEST_PYTHON_DEP = spk/borgbackup + +.PHONY: test-all +test-all: test-dependency-tree test-dependency-flat test-dependency-list +test-all: test-clean +test-all: test-depend +test-all: test-download test-digests +test-all: test-extract test-patch +test-all: test-compile test-install +test-all: test-toolchain +test-all: test-rustc test-cmake test-gnuconfigure test-meson +test-all: test-python +test-all: test-ffmpeg + +.PHONY: test-info +test-info: + @echo SUPPORTED_ARCHS: $(SUPPORTED_ARCHS) + @echo LATEST_ARCHS: $(LATEST_ARCHS) + @echo SUPPORTED_KERNEL_VERSIONS: $(SUPPORTED_KERNEL_VERSIONS) + +# Testing against toolchain and simple build use-cases +# Process 'clean' on toolchains at the end as otherwise rebuilt +.PHONY: test-% +test-%: SHELL:=/bin/bash +test-%: + @if echo "$*" | grep -Eq '^(clean|download|digests)'; then \ + for do_test in $(TEST_DEFAULT) ; do \ + echo "make -C $${do_test} $*" ; \ + make -C $${do_test} $* ; \ + done ; \ + elif echo "$*" | grep -Eq '^(dependency-*)'; then \ + for do_test in $(TEST_DEFAULT) ; do \ + echo "make --no-print-directory -C $${do_test} $*" ; \ + make --no-print-directory -C $${do_test} $* ; \ + done ; \ + else \ + for arch in $(SUPPORTED_ARCHS) ; do \ + for do_test in $(TEST_DEFAULT) ; do \ + echo "make -C $${do_test} ARCH=$${arch%%-*} TCVERSION=$${arch##*-} $*" ; \ + make -C $${do_test} ARCH=$${arch%%-*} TCVERSION=$${arch##*-} $* ; \ + done ; \ + done ; \ + fi + +.PHONY: test-clean +test-clean: native-clean cross-clean spk-clean + +.PHONY: test-dependency-% +test-dependency-%: dependency-$* + +.PHONY: test-toolchain +test-toolchain: $(addprefix test-toolchain-,$(SUPPORTED_ARCHS)) + +.PHONY: test-toolchain-% +test-toolchain-%: + make -C toolchain/syno-$* clean + make -C toolchain/syno-$* + +.PHONY: test-rustc +test-rustc: + PARALLEL_MAKE=max make -j2 -C $(TEST_RUSTC) all-supported + +.PHONY: test-cmake +test-cmake: + PARALLEL_MAKE=max make -j2 -C $(TEST_CMAKE) all-supported + +.PHONY: test-gnuconfigure +test-gnuconfigure: + PARALLEL_MAKE=max make -j2 -C $(TEST_GNUCONFIGURE) all-supported + +.PHONY: test-meson +test-meson: + PARALLEL_MAKE=max make -j2 -C $(TEST_MESON) all-supported + +.PHONY: test-ffmpeg +test-ffmpeg: + PARALLEL_MAKE=max make -j2 -C $(TEST_FFMPEG) all-supported + PARALLEL_MAKE=max make -j2 -C $(TEST_FFMPEG_DEP) all-supported + +.PHONY: test-python +test-python: + PARALLEL_MAKE=max make -j2 -C $(TEST_PYTHON) all-supported + PARALLEL_MAKE=max make -j2 -C $(TEST_PYTHON_DEP) all-supported diff --git a/mk/spksrc.toolkit.mk b/mk/spksrc.toolkit.mk index b090ccaa141..1f86020b5fd 100644 --- a/mk/spksrc.toolkit.mk +++ b/mk/spksrc.toolkit.mk @@ -3,7 +3,7 @@ SHELL := $(SHELL) -e default: all -WORK_DIR := $(shell pwd)/work +WORK_DIR := $(CURDIR)/work include ../../mk/spksrc.directories.mk include ../../mk/spksrc.common.mk @@ -47,9 +47,5 @@ include ../../mk/spksrc.toolkit-fix.mk all: toolkit_fix -### Clean rules -clean: - rm -fr $(WORK_DIR) - ### For make digests include ../../mk/spksrc.generate-digests.mk diff --git a/spk/gateone/BROKEN b/spk/gateone/BROKEN new file mode 100644 index 00000000000..252799035bc --- /dev/null +++ b/spk/gateone/BROKEN @@ -0,0 +1,2 @@ +Declared as broken, ref: +https://github.com/SynoCommunity/spksrc/pull/6002#issuecomment-1984544927 diff --git a/toolchain/syno-qoriq-6.2.4/Makefile b/toolchain/syno-qoriq-6.2.4/Makefile index ab31fc4a80b..9fb31a0bff5 100644 --- a/toolchain/syno-qoriq-6.2.4/Makefile +++ b/toolchain/syno-qoriq-6.2.4/Makefile @@ -11,10 +11,15 @@ TC_SYSROOT = $(TC_TARGET)/sysroot TC_EXTRA_CFLAGS = -mcpu=8548 -mhard-float -mfloat-gprs=double TC_RUSTFLAGS = -C target-cpu=e500 +OPTIONAL_DEPENDS = native/rust-qoriq POST_FIX_TARGET = qoriq_post_fix_target include ../../mk/spksrc.tc.mk +ifneq ($(RUST_BUILD_TOOLCHAIN),1) +DEPENDS = native/rust-qoriq +endif + .PHONY: qoriq_post_fix_target qoriq_post_fix_target: @cd $(WORK_DIR)/$(TC_TARGET)/bin ; \