From e3f07ba913fd4d4e19b461f6c04fb275f080f125 Mon Sep 17 00:00:00 2001
From: Dmitry Ilyin <dima@doty.ru>
Date: Wed, 28 Sep 2022 18:53:06 +0300
Subject: [PATCH] Use specific BR version for specific platforms (#494)

---
 .github/workflows/matrix_build.yml | 13 +++++++++----
 Makefile                           | 23 ++++++++++++++++-------
 2 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/.github/workflows/matrix_build.yml b/.github/workflows/matrix_build.yml
index f33aee60..2543feb0 100644
--- a/.github/workflows/matrix_build.yml
+++ b/.github/workflows/matrix_build.yml
@@ -83,8 +83,9 @@ jobs:
           echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
           echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV
 
-          make prepare
-          TOOLNAME=$(make BOARD=unknown_unknown_${{ matrix.platform }}_openipc toolname)
+          BOARD=unknown_unknown_${{ matrix.platform }}_openipc
+          make BOARD=$BOARD prepare
+          TOOLNAME=$(make BOARD=$BOARD toolname)
           echo "TOOLNAME=$TOOLNAME" >> $GITHUB_ENV
           URL=https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG_NAME}/${TOOLNAME}.tgz
           echo Checking $URL
@@ -368,8 +369,9 @@ jobs:
 
       - name: Determine toolchain name
         run: |
-          make prepare
-          TOOLNAME=$(make BOARD=unknown_unknown_${{ matrix.platform }}_openipc toolname)
+          BOARD=unknown_unknown_${{ matrix.platform }}_openipc
+          make BOARD=$BOARD prepare
+          TOOLNAME=$(make BOARD=$BOARD toolname)
           echo "TOOLNAME=$TOOLNAME" >> $GITHUB_ENV
 
       - uses: actions/download-artifact@v3
@@ -434,6 +436,9 @@ jobs:
             ;;
             glibc)
               PREFIX="${PREFIX}gnu${ABI}"
+              RPCH=/tmp/extsdk/${PREFIX}/sysroot/usr/include/rpc/rpc.h
+              check_glibc_rpc_feature() { test -f $RPCH && echo y || echo n ; }
+              echo "${TLEXT}_INET_RPC=$(check_glibc_rpc_feature)" >> $CONF_PATH
             ;;
           esac
           echo "${TLEXT}_CUSTOM_PREFIX=\"${PREFIX}\"" >> $CONF_PATH
diff --git a/Makefile b/Makefile
index d04cc105..855dbfeb 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,6 @@
-
-ROOT_DIR      := $(CURDIR)
-BR_VER        ?= 2020.02.12
-BR_DIR        := $(ROOT_DIR)/buildroot-$(BR_VER)
-
-ifeq ($(PLATFORM),)
+ifneq ($(PLATFORM),)
+	PLATFORM := $(error Setting PLATFORM in make arguments is deprecated, please remove it)
+else
     ifneq ($(BOARD),)
 		FULL_PATH := $(shell find br-ext-chip-* -name "$(BOARD)*_defconfig")
 		ifeq ($(FULL_PATH),)
@@ -13,12 +10,24 @@ ifeq ($(PLATFORM),)
 		endif
 
 		PLATFORM := $(shell echo $(FULL_PATH) | cut -d '/' -f 1 | cut -d '-' -f 4 )
+
+		FAMILY := $(shell grep "/board/" $(FULL_PATH) | head -1 | cut -d "/" -f 3)
+		ifeq ($(FAMILY),hi3516cv500)
+			BR_VER ?= 2021.02.12
+		endif
     endif
 endif
 
+ROOT_DIR      := $(CURDIR)
 BR_EXT_DIR    := $(ROOT_DIR)/br-ext-chip-$(PLATFORM)
 SCRIPTS_DIR   := $(ROOT_DIR)/scripts
-#BOARDS       := $(shell ls -1 $(BR_EXT_DIR)/configs)
+
+BR_VER        ?= 2020.02.12
+BR_DIR        := $(ROOT_DIR)/buildroot-$(BR_VER)
+
+ifeq ($(BR_VER),2021.02.12)
+	DUMMY := $(shell rm general/package/all-patches/m4/0003-c-stack-stop-using-SIGSTKSZ.patch 2>/dev/null)
+endif
 
 .PHONY: usage help clean distclean prepare install-deps all toolchain-params run-tests overlayed-rootfs-%