From 3b706021d06b9dbbe5848e524da09b527f75ad4f Mon Sep 17 00:00:00 2001
From: "b.vikram@xilinx.com" <b.vikram@xilinx.com>
Date: Thu, 11 Feb 2021 23:20:31 +0530
Subject: [PATCH] sw_apps :versal_plm: Changes to ensure versionless build
 works with yocto flow

The syntax of updating BSP_SEQUENTIAL_FILES variable in copy_bsp.sh is updated.
Using COMPILER, ARCHIVER and AASEMBLER variables in bsp Makefile instead of
hardcoding them. This would help yocto flow as it does not use mb-gcc.

Signed-off-by: Vikram Sreenivasa Batchali <b.vikram@xilinx.com>
Acked-by: Krishna Chaitanya Patakamuri <krishna.chaitanya.patakamuri@xilinx.com>
---
 lib/sw_apps/versal_plm/misc/Makefile      | 10 ++++++----
 lib/sw_apps/versal_plm/misc/copy_bsp.sh   | 16 ++++++++--------
 lib/sw_apps/zynq_fsbl/misc/copy_bsp.sh    |  6 +++---
 lib/sw_apps/zynqmp_fsbl/misc/copy_bsp.sh  |  8 ++++----
 lib/sw_apps/zynqmp_pmufw/misc/Makefile    | 10 ++++++----
 lib/sw_apps/zynqmp_pmufw/misc/copy_bsp.sh |  8 ++++----
 6 files changed, 31 insertions(+), 27 deletions(-)

diff --git a/lib/sw_apps/versal_plm/misc/Makefile b/lib/sw_apps/versal_plm/misc/Makefile
index 23ac27b52b..d1be4ffc8e 100644
--- a/lib/sw_apps/versal_plm/misc/Makefile
+++ b/lib/sw_apps/versal_plm/misc/Makefile
@@ -1,5 +1,7 @@
 # Makefile generated by Xilinx.
-
+COMPILER := mb-gcc
+ARCHIVER := mb-gcc-ar
+ASSEMBLER := mb-as
 DRIVER_LIB_VERSION = 1.0
 PROCESSOR = psv_pmc_0
 LIBRARIES = ${PROCESSOR}/lib/libxil.a
@@ -28,7 +30,7 @@ par_libs: $(addsuffix /make.libs,$(PAR_SUBDIRS))
 	@echo 'Finished building libraries parallelly.'
 
 archive:
-	mb-gcc-ar -r  $(LIBRARIES) $(wildcard $(PROCESSOR)/lib/*.o)
+	$(ARCHIVER) -r  $(LIBRARIES) $(wildcard $(PROCESSOR)/lib/*.o)
 
 clean: $(addsuffix /make.clean,$(SUBDIRS))
 	rm -f ${PROCESSOR}/lib/libxil.a
@@ -38,11 +40,11 @@ $(PROCESSOR)/lib/libxil.a: $(PROCESSOR)/lib/libxil_init.a
 
 %/make.include: $(if $(wildcard $(PROCESSOR)/lib/libxil_init.a),$(PROCESSOR)/lib/libxil.a,)
 	@echo "Running Make include in $(subst /make.include,,$@)"
-	$(MAKE) -C $(subst /make.include,,$@) -s include  "SHELL=$(SHELL)" "COMPILER=mb-gcc" "ASSEMBLER=mb-as" "ARCHIVER=mb-gcc-ar" "COMPILER_FLAGS=  -O2 -c -mcpu=v10.0 -mlittle-endian -mxl-barrel-shift -mxl-pattern-compare" "EXTRA_COMPILER_FLAGS=-g -ffunction-sections -fdata-sections -Wall -Wextra -Os -flto -ffat-lto-objects"
+	$(MAKE) -C $(subst /make.include,,$@) -s include  "SHELL=$(SHELL)" "COMPILER=$(COMPILER)" "ASSEMBLER=$(ASSEMBLER)" "ARCHIVER=$(ARCHIVER)" "COMPILER_FLAGS=  -O2 -c -mcpu=v10.0 -mlittle-endian -mxl-barrel-shift -mxl-pattern-compare" "EXTRA_COMPILER_FLAGS=-g -ffunction-sections -fdata-sections -Wall -Wextra -Os -flto -ffat-lto-objects"
 
 %/make.libs: include
 	@echo "Running Make libs in $(subst /make.libs,,$@)"
-	$(MAKE) -C $(subst /make.libs,,$@) -s libs  "SHELL=$(SHELL)" "COMPILER=mb-gcc" "ASSEMBLER=mb-as" "ARCHIVER=mb-gcc-ar" "COMPILER_FLAGS=  -O2 -c -mcpu=v10.0 -mlittle-endian -mxl-barrel-shift -mxl-pattern-compare" "EXTRA_COMPILER_FLAGS=-g -ffunction-sections -fdata-sections -Wall -Wextra -Os -flto -ffat-lto-objects"
+	$(MAKE) -C $(subst /make.libs,,$@) -s libs  "SHELL=$(SHELL)" "COMPILER=$(COMPILER)" "ASSEMBLER=$(ASSEMBLER)" "ARCHIVER=$(ARCHIVER)" "COMPILER_FLAGS=  -O2 -c -mcpu=v10.0 -mlittle-endian -mxl-barrel-shift -mxl-pattern-compare" "EXTRA_COMPILER_FLAGS=-g -ffunction-sections -fdata-sections -Wall -Wextra -Os -flto -ffat-lto-objects"
 
 %/make.clean: 
 	$(MAKE) -C $(subst /make.clean,,$@) -s clean 
diff --git a/lib/sw_apps/versal_plm/misc/copy_bsp.sh b/lib/sw_apps/versal_plm/misc/copy_bsp.sh
index 2e4e393b5d..4f082de37c 100755
--- a/lib/sw_apps/versal_plm/misc/copy_bsp.sh
+++ b/lib/sw_apps/versal_plm/misc/copy_bsp.sh
@@ -48,33 +48,33 @@ fi
 mkdir -p $BSP_DIR/libsrc/xilffs
 cp -r $SERVICES_DIR/xilffs/src $BSP_DIR/libsrc/xilffs/
 cp -r $SERVICES_DIR/xilffs/src/include/* $BSP_DIR/include/
-set BSP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/xilffs/src/Makefile
+BSP_SEQUENTIAL_MAKEFILES="$BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/xilffs/src/Makefile"
 
 mkdir -p $BSP_DIR/libsrc/xilpdi
 cp -r $SERVICES_DIR/xilpdi/src $BSP_DIR/libsrc/xilpdi/
 cp -r $SERVICES_DIR/xilpdi/src/*.h $BSP_DIR/include/
-set BSP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/xilpdi/src/Makefile
+BSP_SEQUENTIAL_MAKEFILES="$BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/xilpdi/src/Makefile"
 
 mkdir -p $BSP_DIR/libsrc/xilplmi
 cp -r $SERVICES_DIR/xilplmi/src $BSP_DIR/libsrc/xilplmi/
-set BSP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/xilplmi/src/Makefile
+BSP_SEQUENTIAL_MAKEFILES="$BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/xilplmi/src/Makefile"
 
 mkdir -p $BSP_DIR/libsrc/xilpuf
 cp -r $SERVICES_DIR/xilpuf/src $BSP_DIR/libsrc/xilpuf/
 cp -r $SERVICES_DIR/xilpuf/src/*.h $BSP_DIR/include/
-set SP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/xilpuf/src/Makefile
+BSP_SEQUENTIAL_MAKEFILES="$BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/xilpuf/src/Makefile"
 
 mkdir -p $BSP_DIR/libsrc/xilloader
 cp -r $SERVICES_DIR/xilloader/src $BSP_DIR/libsrc/xilloader/
 cp -r $SERVICES_DIR/xilloader/src/*.h $BSP_DIR/include/
-set BSP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/xilloader/src/Makefile
+BSP_SEQUENTIAL_MAKEFILES="$BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/xilloader/src/Makefile"
 
 mkdir -p $BSP_DIR/libsrc/xilpm/src/
 cp -r $SERVICES_DIR/xilpm/src/versal/common/* $BSP_DIR/libsrc/xilpm/src/
 cp -r $SERVICES_DIR/xilpm/src/versal/server/* $BSP_DIR/libsrc/xilpm/src/
 cp -r $SERVICES_DIR/xilpm/src/versal/common/*.h $BSP_DIR/include/
 cp -r $SERVICES_DIR/xilpm/src/versal/server/*.h $BSP_DIR/include/
-set BSP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/xilpm/src/versal/common/Makefile
+BSP_SEQUENTIAL_MAKEFILES="$BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/xilpm/src/versal/common/Makefile"
 
 mkdir -p $BSP_DIR/libsrc/xilsecure/src/
 cp -r $SERVICES_DIR/xilsecure/src/Makefile $BSP_DIR/libsrc/xilsecure/src/
@@ -84,7 +84,7 @@ cp -r $SERVICES_DIR/xilsecure/src/common/*.h $BSP_DIR/include/
 cp -r $SERVICES_DIR/xilsecure/src/versal/*.h $BSP_DIR/include/
 mv $BSP_DIR/libsrc/xilsecure/src/libxilsecure_pmc.a $BSP_DIR/libsrc/xilsecure/src/libxilsecure.a
 rm $BSP_DIR/libsrc/xilsecure/src/libxilsecure_*.a
-set BSP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/xilsecure/src/Makefile
+BSP_SEQUENTIAL_MAKEFILES="$BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/xilsecure/src/Makefile"
 
 mkdir -p $BSP_DIR/libsrc/xilsem
 cp -r $SERVICES_DIR/xilsem/src $BSP_DIR/libsrc/xilsem/
@@ -116,7 +116,7 @@ do
     cp -r $DRIVERS_DIR/$line/src/*.h $BSP_DIR/include/
 # copy all the HSM generated driver files DRIVER_g.c
 	cp $WORKING_DIR/x"$line"_g.c $BSP_DIR/libsrc/$line/src/
-	set BSP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/$line/src/Makefile
+	BSP_SEQUENTIAL_MAKEFILES="$BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/$line/src/Makefile"
 done < $DRIVERS_LIST
 
 #copy the processor code.
diff --git a/lib/sw_apps/zynq_fsbl/misc/copy_bsp.sh b/lib/sw_apps/zynq_fsbl/misc/copy_bsp.sh
index 70dae119b2..70a83ffd50 100755
--- a/lib/sw_apps/zynq_fsbl/misc/copy_bsp.sh
+++ b/lib/sw_apps/zynq_fsbl/misc/copy_bsp.sh
@@ -75,18 +75,18 @@ do
     cp -r $DRIVERS_DIR/$line/src $BSP_DIR/libsrc/$line
 # copy all the HSM generated driver files DRIVER_g.c
 #    cp $BOARD_DIR/x"$line"_g.c $BSP_DIR/libsrc/$line/src/
-     set BSP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/$line/src/Makefile
+    BSP_SEQUENTIAL_MAKEFILES="$BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/$line/src/Makefile"
 
 done < $DRIVERS_LIST
 
 # copy the libraries required
 cp -r $SERVICES_DIR/xilffs/ $BSP_DIR/libsrc/
 cp -r $SERVICES_DIR/xilffs/src/include/* $BSP_DIR/include/
-set BSP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/xilffs/src/Makefile
+BSP_SEQUENTIAL_MAKEFILES="$BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/xilffs/src/Makefile"
 
 cp -r $SERVICES_DIR/xilrsa/ $BSP_DIR/libsrc/
 cp -r $SERVICES_DIR/xilrsa/src/include/* $BSP_DIR/include/
-set BSP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/xilrsa/src/Makefile
+BSP_SEQUENTIAL_MAKEFILES="$BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/xilrsa/src/Makefile"
 
 #copy the xparameters.h
 cp $BOARD_DIR/xparameters.h $BSP_DIR/include/
diff --git a/lib/sw_apps/zynqmp_fsbl/misc/copy_bsp.sh b/lib/sw_apps/zynqmp_fsbl/misc/copy_bsp.sh
index 8cc6e3a66e..120aeb8fc7 100755
--- a/lib/sw_apps/zynqmp_fsbl/misc/copy_bsp.sh
+++ b/lib/sw_apps/zynqmp_fsbl/misc/copy_bsp.sh
@@ -65,7 +65,7 @@ fi
 mkdir -p $BSP_DIR/libsrc/xilffs
 cp -r $SERVICES_DIR/xilffs/src $BSP_DIR/libsrc/xilffs/
 cp -r $SERVICES_DIR/xilffs/src/include/* $BSP_DIR/include/
-set BSP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/xilffs/src/Makefile
+BSP_SEQUENTIAL_MAKEFILES="$BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/xilffs/src/Makefile"
 
 mkdir -p $BSP_DIR/libsrc/xilsecure/src/
 cp -r $SERVICES_DIR/xilsecure/src/Makefile $BSP_DIR/libsrc/xilsecure/src/
@@ -73,13 +73,13 @@ cp -r $SERVICES_DIR/xilsecure/src/common/* $BSP_DIR/libsrc/xilsecure/src/
 cp -r $SERVICES_DIR/xilsecure/src/zynqmp/* $BSP_DIR/libsrc/xilsecure/src/
 cp -r $SERVICES_DIR/xilsecure/src/common/*.h $BSP_DIR/include/
 cp -r $SERVICES_DIR/xilsecure/src/zynqmp/*.h $BSP_DIR/include/
-set BSP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/xilsecure/src/Makefile
+BSP_SEQUENTIAL_MAKEFILES="BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/xilsecure/src/Makefile"
 
 cp -r $SERVICES_DIR/xilpm/ $BSP_DIR/libsrc/
 cp -r $SERVICES_DIR/xilpm/src/zynqmp/client/common/* $BSP_DIR/libsrc/xilpm/src/
 cp -r $SERVICES_DIR/xilpm/src/zynqmp/client/common/*.h $BSP_DIR/include/
 cp $WORKING_DIR/pm_cfg_obj.c  $BSP_DIR/libsrc/xilpm/src/
-set BSP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/xilpm/src/zynqmp/client/common/Makefile
+BSP_SEQUENTIAL_MAKEFILES="BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/xilpm/src/zynqmp/client/common/Makefile"
 
 rm -rf $BSP_DIR/libsrc/xilpm/src/zynqmp/
 rm -rf $BSP_DIR/libsrc/xilpm/src/versal/
@@ -161,7 +161,7 @@ do
 
 	# copy all the HSM generated driver files DRIVER_g.c
 	#   cp $BOARD_DIR/x"$line"_g.c $BSP_DIR/libsrc/$line/src/
-	set BSP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/$line/src/Makefile
+	BSP_SEQUENTIAL_MAKEFILES="$BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/$line/src/Makefile"
 
 done < $DRIVERS_LIST
 
diff --git a/lib/sw_apps/zynqmp_pmufw/misc/Makefile b/lib/sw_apps/zynqmp_pmufw/misc/Makefile
index 142581b2b9..a773498512 100644
--- a/lib/sw_apps/zynqmp_pmufw/misc/Makefile
+++ b/lib/sw_apps/zynqmp_pmufw/misc/Makefile
@@ -1,5 +1,7 @@
 # Makefile generated by Xilinx.
-
+COMPILER := mb-gcc
+ARCHIVER := mb-gcc-ar
+ASSEMBLER := mb-as
 DRIVER_LIB_VERSION = 1.0
 PROCESSOR = psu_pmu_0
 LIBRARIES = ${PROCESSOR}/lib/libxil.a
@@ -28,7 +30,7 @@ par_libs: $(addsuffix /make.libs,$(PAR_SUBDIRS))
 	@echo 'Finished building libraries parallelly.'
 
 archive:
-	mb-gcc-ar -r  $(LIBRARIES) $(wildcard $(PROCESSOR)/lib/*.o)
+	$(ARCHIVER) -r  $(LIBRARIES) $(wildcard $(PROCESSOR)/lib/*.o)
 
 clean: $(addsuffix /make.clean,$(SUBDIRS))
 	rm -f ${PROCESSOR}/lib/libxil.a
@@ -38,11 +40,11 @@ $(PROCESSOR)/lib/libxil.a: $(PROCESSOR)/lib/libxil_init.a
 
 %/make.include: $(if $(wildcard $(PROCESSOR)/lib/libxil_init.a),$(PROCESSOR)/lib/libxil.a,)
 	@echo "Running Make include in $(subst /make.include,,$@)"
-	$(MAKE) -C $(subst /make.include,,$@) -s include  "SHELL=$(SHELL)" "COMPILER=mb-gcc" "ARCHIVER=mb-ar" "COMPILER_FLAGS=  -O2 -c -mcpu=v9.2 -mlittle-endian -mxl-barrel-shift -mxl-pattern-compare -mxl-soft-mul" "EXTRA_COMPILER_FLAGS=-ffunction-sections -fdata-sections -Wall -Wextra -Os -flto -ffat-lto-objects"
+	$(MAKE) -C $(subst /make.include,,$@) -s include  "SHELL=$(SHELL)" "COMPILER=$(COMPILER)" "ARCHIVER=$(ARCHIVER)" "COMPILER_FLAGS=  -O2 -c -mcpu=v9.2 -mlittle-endian -mxl-barrel-shift -mxl-pattern-compare -mxl-soft-mul" "EXTRA_COMPILER_FLAGS=-ffunction-sections -fdata-sections -Wall -Wextra -Os -flto -ffat-lto-objects"
 
 %/make.libs: include
 	@echo "Running Make libs in $(subst /make.libs,,$@)"
-	$(MAKE) -C $(subst /make.libs,,$@) -s libs  "SHELL=$(SHELL)" "COMPILER=mb-gcc" "ARCHIVER=mb-ar" "COMPILER_FLAGS=  -O2 -c -mcpu=v9.2 -mlittle-endian -mxl-barrel-shift -mxl-pattern-compare -mxl-soft-mul" "EXTRA_COMPILER_FLAGS=-ffunction-sections -fdata-sections -Wall -Wextra -Os -flto -ffat-lto-objects"
+	$(MAKE) -C $(subst /make.libs,,$@) -s libs  "SHELL=$(SHELL)" "COMPILER=$(COMPILER)" "ARCHIVER=$(ARCHIVER)" "COMPILER_FLAGS=  -O2 -c -mcpu=v9.2 -mlittle-endian -mxl-barrel-shift -mxl-pattern-compare -mxl-soft-mul" "EXTRA_COMPILER_FLAGS=-ffunction-sections -fdata-sections -Wall -Wextra -Os -flto -ffat-lto-objects"
 
 %/make.clean:
 	$(MAKE) -C $(subst /make.clean,,$@) -s clean
diff --git a/lib/sw_apps/zynqmp_pmufw/misc/copy_bsp.sh b/lib/sw_apps/zynqmp_pmufw/misc/copy_bsp.sh
index c683e4f73d..be8616968e 100755
--- a/lib/sw_apps/zynqmp_pmufw/misc/copy_bsp.sh
+++ b/lib/sw_apps/zynqmp_pmufw/misc/copy_bsp.sh
@@ -52,14 +52,14 @@ cp -r $SERVICES_DIR/xilfpga/src/interface/zynqmp/xilfpga_pcap.c $BSP_DIR/libsrc/
 cp -r $SERVICES_DIR/xilfpga/src/*.h $BSP_DIR/include/
 cp -r $SERVICES_DIR/xilfpga/src/interface/zynqmp/*.h $BSP_DIR/include/
 rm -r $BSP_DIR/libsrc/xilfpga/src/interface/
-set BSP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/xilfpga/src/Makefile
+BSP_SEQUENTIAL_MAKEFILES="$BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/xilfpga/src/Makefile"
 mkdir -p $BSP_DIR/libsrc/xilsecure/src/
 cp -r $SERVICES_DIR/xilsecure/src/Makefile $BSP_DIR/libsrc/xilsecure/src/
 cp -r $SERVICES_DIR/xilsecure/src/common/* $BSP_DIR/libsrc/xilsecure/src/
 cp -r $SERVICES_DIR/xilsecure/src/zynqmp/* $BSP_DIR/libsrc/xilsecure/src/
 cp -r $SERVICES_DIR/xilsecure/src/common/*.h $BSP_DIR/include/
 cp -r $SERVICES_DIR/xilsecure/src/zynqmp/*.h $BSP_DIR/include/
-set BSP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/xilsecure/src/Makefile
+BSP_SEQUENTIAL_MAKEFILES="$BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/xilsecure/src/Makefile"
 cp -r $SERVICES_DIR/xilskey/ $BSP_DIR/libsrc/
 
 # remove the xilskey library files which are not required for PMU
@@ -81,7 +81,7 @@ rm -r $BSP_DIR/libsrc/xilskey/src/include/xilskey_bbram.h
 # copy the xilskey library header files to include directory
 cp -r $BSP_DIR/libsrc/xilskey/src/*.h $BSP_DIR/include/
 cp -r $BSP_DIR/libsrc/xilskey/src/include/*.h $BSP_DIR/include/
-set BSP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/xilskey/src/Makefile
+BSP_SEQUENTIAL_MAKEFILES="$BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/xilskey/src/Makefile"
 
 # copy bsp standalone code
 cp  $STANDALONE_DIR/common/*  $BSP_DIR/libsrc/standalone/src/
@@ -108,7 +108,7 @@ do
     cp -r $DRIVERS_DIR/$line/src/*.h $BSP_DIR/include/
 # copy all the HSM generated driver files DRIVER_g.c
 	cp $WORKING_DIR/x"$line"_g.c $BSP_DIR/libsrc/$line/src/
-	set BSP_SEQUENTIAL_MAKEFILES += $BSP_DIR/libsrc/$line/src/Makefile
+	BSP_SEQUENTIAL_MAKEFILES="$BSP_SEQUENTIAL_MAKEFILES $BSP_DIR/libsrc/$line/src/Makefile"
 
 done < $DRIVERS_LIST
 
-- 
2.17.1

