11#
2- # Copyright 2019-2020 Xilinx, Inc.
2+ # Copyright 2019-2022 Xilinx, Inc.
33#
44# Licensed under the Apache License, Version 2.0 (the "License");
55# you may not use this file except in compliance with the License.
1212# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313# See the License for the specific language governing permissions and
1414# limitations under the License.
15+ # vitis makefile-generator v2.0.8
1516#
1617# +-------------------------------------------------------------------------------
1718# The following parameters are assigned with default values. These parameters can
@@ -25,29 +26,109 @@ DEBUG := no
2526# 'estimate' for estimate report generation
2627# 'system' for system report generation
2728ifneq ($(REPORT ) , no)
28- LDCLFLAGS += --report estimate
29- LDCLFLAGS += --report system
29+ VPP_LDFLAGS += --report estimate
30+ VPP_LDFLAGS += --report system
3031endif
3132
3233# Generates profile summary report
3334ifeq ($(PROFILE ) , yes)
34- LDCLFLAGS += --profile_kernel data:all:all:all
35+ VPP_LDFLAGS += --profile_kernel data:all:all:all
3536endif
3637
3738# Generates debug summary report
3839ifeq ($(DEBUG ) , yes)
39- LDCLFLAGS += --dk protocol:all:all:all
40+ VPP_LDFLAGS += --dk protocol:all:all:all
4041endif
4142
42- # Check environment setup
43+ # Check vitis setup
4344ifndef XILINX_VITIS
4445 XILINX_VITIS = /opt/xilinx/Vitis/$(TOOL_VERSION )
4546 export XILINX_VITIS
4647endif
48+
49+ .PHONY : check_device
50+ check_device :
51+ @set -eu; \
52+ inallowlist=False; \
53+ inblocklist=False; \
54+ for dev in $( PLATFORM_ALLOWLIST) ; \
55+ do if [[ $$ (echo $( PLATFORM_NAME) | grep $$ dev) != " " ]]; \
56+ then inallowlist=True; fi ; \
57+ done ; \
58+ for dev in $( PLATFORM_BLOCKLIST) ; \
59+ do if [[ $$ (echo $( PLATFORM_NAME) | grep $$ dev) != " " ]]; \
60+ then inblocklist=True; fi ; \
61+ done ; \
62+ if [[ $$ inallowlist == False ]]; \
63+ then echo " [Warning]: The device $( PLATFORM_NAME) not in allowlist." ; \
64+ fi ; \
65+ if [[ $$ inblocklist == True ]]; \
66+ then echo " [ERROR]: The device $( PLATFORM_NAME) in blocklist." ; exit 1; \
67+ fi ;
68+
69+ # get HOST_ARCH by PLATFORM
70+ ifneq (,$(PLATFORM ) )
71+ HOST_ARCH_temp = $(shell platforminfo -p $(PLATFORM ) | grep 'CPU Type' | sed 's/.* ://' | sed '/ai_engine/d' | sed 's/^[[:space:]]* //')
72+ ifeq ($(HOST_ARCH_temp ) , x86)
73+ HOST_ARCH := x86
74+ else ifeq ($(HOST_ARCH_temp), cortex-a9)
75+ HOST_ARCH := aarch32
76+ else ifneq (,$(findstring cortex-a, $(HOST_ARCH_temp)))
77+ HOST_ARCH := aarch64
78+ endif
79+ endif
80+
81+
82+
83+ # Special processing for tool version/platform type
84+ VITIS_VER = $(shell v++ --version | grep 'v++' | sed 's/^[[:space:]]* //' | sed -e 's/^[* ]* v++ v//g' | cut -d " " -f1)
85+ # 1) for versal flow from 2022.1
86+ DEVICE_TYPE = $(shell platforminfo -p $(PLATFORM ) | grep 'FPGA Family' | sed 's/.* ://' | sed '/ai_engine/d' | sed 's/^[[:space:]]* //')
87+ ifeq ($(DEVICE_TYPE ) , versal)
88+ ifeq ($(shell expr $(VITIS_VER ) \>= 2022.1) , 1)
89+ LINK_TARGET_FMT := xsa
90+ else
91+ LINK_TARGET_FMT := xclbin
92+ endif
93+ else
94+ LINK_TARGET_FMT := xclbin
95+ endif
96+ # 2) dfx flow
97+ dfx_hw := off
98+ ifeq ($(findstring _dfx_, $(PLATFORM_NAME ) ) ,_dfx_)
99+ ifeq ($(TARGET ) ,hw)
100+ dfx_hw := on
101+ endif
102+ endif
103+ # 3) for embeded sw_emu flow from 2022.2
104+ ps_on_x86 := off
105+ ifneq ($(HOST_ARCH ) , x86)
106+ ifeq ($(shell expr $(VITIS_VER ) \>= 2022.2) , 1)
107+ ifeq ($(TARGET ) , sw_emu)
108+ ps_on_x86 := on
109+ HOST_ARCH := x86
110+ endif
111+ endif
112+ endif
113+
114+ # when x86 arch, check XRT setup
115+ ifeq ($(HOST_ARCH ) , x86)
47116ifndef XILINX_XRT
48117 XILINX_XRT = /opt/xilinx/xrt
49118 export XILINX_XRT
50119endif
120+ endif
121+
122+ # check if need sd_card
123+ ifeq ($(HOST_ARCH ) , aarch32)
124+ SD_CARD_NEEDED := on
125+ endif
126+ ifeq ($(HOST_ARCH ) , aarch64)
127+ SD_CARD_NEEDED := on
128+ endif
129+ ifeq ($(ps_on_x86 ) , on)
130+ SD_CARD_NEEDED := on
131+ endif
51132
52133# Checks for Device Family
53134ifeq ($(HOST_ARCH ) , aarch32)
@@ -56,24 +137,49 @@ else ifeq ($(HOST_ARCH), aarch64)
56137 DEV_FAM = Ultrascale
57138endif
58139
59- B_NAME = $(shell dirname $(XPLATFORM ) )
60-
61140# Checks for Correct architecture
62141ifneq ($(HOST_ARCH ) , $(filter $(HOST_ARCH ) ,aarch64 aarch32 x86) )
63142$(error HOST_ARCH variable not set, please set correctly and rerun)
64143endif
65144
66- # Checks for SYSROOT
145+ .PHONY : check_version check_sysroot check_kimage check_rootfs
146+ check_version :
147+ ifneq (, $(shell which git) )
148+ ifneq (,$(wildcard $(XFLIB_DIR ) /.git) )
149+ @cd $(XFLIB_DIR) && git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -n 1 && cd -
150+ endif
151+ endif
152+
153+ # Set/Check SYSROOT/K_IMAGE/ROOTFS
154+ ifneq ($(HOST_ARCH ) , x86)
155+ ifneq (,$(findstring zc706, $(PLATFORM_NAME ) ) )
156+ K_IMAGE ?= $(SYSROOT ) /../../uImage
157+ else
158+ K_IMAGE ?= $(SYSROOT ) /../../Image
159+ endif
160+ ROOTFS ?= $(SYSROOT ) /../../rootfs.ext4
161+ endif
162+
67163check_sysroot :
68164ifneq ($(HOST_ARCH ) , x86)
69- ifndef SYSROOT
165+ ifeq (, $( wildcard $( SYSROOT ) ) )
70166 $(error SYSROOT ENV variable is not set, please set ENV variable correctly and rerun)
71167endif
72168endif
169+ check_kimage :
170+ ifneq ($(HOST_ARCH ) , x86)
171+ ifeq (,$(wildcard $(K_IMAGE ) ) )
172+ $(error K_IMAGE ENV variable is not set, please set ENV variable correctly and rerun)
173+ endif
174+ endif
175+ check_rootfs :
176+ ifneq ($(HOST_ARCH ) , x86)
177+ ifeq (,$(wildcard $(ROOTFS ) ) )
178+ $(error ROOTFS ENV variable is not set, please set ENV variable correctly and rerun)
179+ endif
180+ endif
73181
74- # Checks for g++
75182CXX := g++
76- VITIS_VER = $(shell v++ --version | grep 'v++' | sed 's/^[[:space:]]* //' | sed -e 's/^[* ]* v++ v//g' | cut -d " " -f1)
77183ifeq ($(HOST_ARCH ) , x86)
78184ifeq ($(shell expr $(VITIS_VER ) \>= 2022.1) , 1)
79185CXX_VER := 8.3.0
@@ -94,16 +200,40 @@ endif
94200$(warning [WARNING] : g++ version too old. Using g++ provided by the tool: $(CXX ) )
95201endif
96202endif
97- else ifeq ($(HOST_ARCH), aarch64)
203+ else
204+ ifeq ($(HOST_ARCH ) , aarch64)
98205CXX := $(XILINX_VITIS ) /gnu/aarch64/lin/aarch64-linux/bin/aarch64-linux-gnu-g++
99206else ifeq ($(HOST_ARCH), aarch32)
100207CXX := $(XILINX_VITIS ) /gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin/arm-linux-gnueabihf-g++
101208endif
209+ endif
210+
211+ # Check OS and setting env for xrt c++ api
212+ OSDIST = $(shell lsb_release -i |awk -F: '{print tolower($$2) }' | tr -d ' \t' )
213+ OSREL = $(shell lsb_release -r |awk -F: '{print tolower($$2) }' |tr -d ' \t')
214+
215+ # for centos and redhat
216+ ifneq ($(findstring centos,$(OSDIST ) ) ,)
217+ ifeq (7,$(shell echo $(OSREL ) | awk -F. '{print tolower($$1) }' ))
218+ ifeq ($(HOST_ARCH ) , x86)
219+ XRT_CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0
220+ endif
221+ endif
222+ else ifneq ($(findstring redhat,$(OSDIST)),)
223+ ifeq (7,$(shell echo $(OSREL ) | awk -F. '{print tolower($$1) }' ))
224+ ifeq ($(HOST_ARCH ) , x86)
225+ XRT_CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0
226+ endif
227+ endif
228+ endif
102229
103230# Setting VPP
104231VPP := v++
105232
106233# Cheks for aiecompiler
234+ AIECXX := aiecompiler
235+ AIESIMULATOR := aiesimulator
236+ X86SIMULATOR := x86simulator
107237
108238.PHONY : check_vivado
109239check_vivado :
@@ -124,80 +254,70 @@ ifeq (,$(wildcard $(XILINX_XRT)/lib/libxilinxopencl.so))
124254endif
125255
126256export PATH := $(XILINX_VITIS ) /bin:$(XILINX_XRT ) /bin:$(PATH )
257+ ifeq ($(HOST_ARCH ) , x86)
127258ifeq (,$(LD_LIBRARY_PATH ) )
128259LD_LIBRARY_PATH := $(XILINX_XRT ) /lib
129260else
130261LD_LIBRARY_PATH := $(XILINX_XRT ) /lib:$(LD_LIBRARY_PATH )
131262endif
132-
133- # check target
134- ifeq ($(filter $(TARGET ) ,sw_emu hw_emu hw) ,)
135- $(error TARGET is not sw_emu, hw_emu or hw)
136263endif
137264
138- ifneq (,$(wildcard $(DEVICE ) ) )
139- # Use DEVICE as a file path
140- XPLATFORM := $(DEVICE )
265+ ifneq (,$(wildcard $(PLATFORM ) ) )
266+ # Use PLATFORM as a file path
267+ XPLATFORM := $(PLATFORM )
141268else
142- # Use DEVICE as a file name pattern
269+ # Use PLATFORM as a file name pattern
143270# 1. search paths specified by variable
144271ifneq (,$(PLATFORM_REPO_PATHS ) )
145272# 1.1 as exact name
146- XPLATFORM := $(strip $(foreach p, $(subst :, ,$(PLATFORM_REPO_PATHS ) ) , $(wildcard $(p ) /$(DEVICE ) /$(DEVICE ) .xpfm) ) )
273+ XPLATFORM := $(strip $(foreach p, $(subst :, ,$(PLATFORM_REPO_PATHS ) ) , $(wildcard $(p ) /$(PLATFORM ) /$(PLATFORM ) .xpfm) ) )
147274# 1.2 as a pattern
148275ifeq (,$(XPLATFORM ) )
149276XPLATFORMS := $(foreach p, $(subst :, ,$(PLATFORM_REPO_PATHS ) ) , $(wildcard $(p ) /* /* .xpfm) )
150- XPLATFORM := $(strip $(foreach p, $(XPLATFORMS ) , $(shell echo $(p ) | awk '$$1 ~ /$(DEVICE ) /') ) )
277+ XPLATFORM := $(strip $(foreach p, $(XPLATFORMS ) , $(shell echo $(p ) | awk '$$1 ~ /$(PLATFORM ) /') ) )
151278endif # 1.2
152279endif # 1
153280# 2. search Vitis installation
154281ifeq (,$(XPLATFORM ) )
155282# 2.1 as exact name
156- XPLATFORM := $(strip $(wildcard $(XILINX_VITIS ) /platforms/$(DEVICE ) /$(DEVICE ) .xpfm) )
283+ XPLATFORM := $(strip $(wildcard $(XILINX_VITIS ) /platforms/$(PLATFORM ) /$(PLATFORM ) .xpfm) )
157284# 2.2 as a pattern
158285ifeq (,$(XPLATFORM ) )
159286XPLATFORMS := $(wildcard $(XILINX_VITIS ) /platforms/* /* .xpfm)
160- XPLATFORM := $(strip $(foreach p, $(XPLATFORMS ) , $(shell echo $(p ) | awk '$$1 ~ /$(DEVICE ) /') ) )
287+ XPLATFORM := $(strip $(foreach p, $(XPLATFORMS ) , $(shell echo $(p ) | awk '$$1 ~ /$(PLATFORM ) /') ) )
161288endif # 2.2
162289endif # 2
163290# 3. search default locations
164291ifeq (,$(XPLATFORM ) )
165292# 3.1 as exact name
166- XPLATFORM := $(strip $(wildcard /opt/xilinx/platforms/$(DEVICE ) /$(DEVICE ) .xpfm) )
293+ XPLATFORM := $(strip $(wildcard /opt/xilinx/platforms/$(PLATFORM ) /$(PLATFORM ) .xpfm) )
167294# 3.2 as a pattern
168295ifeq (,$(XPLATFORM ) )
169296XPLATFORMS := $(wildcard /opt/xilinx/platforms/* /* .xpfm)
170- XPLATFORM := $(strip $(foreach p, $(XPLATFORMS ) , $(shell echo $(p ) | awk '$$1 ~ /$(DEVICE ) /') ) )
297+ XPLATFORM := $(strip $(foreach p, $(XPLATFORMS ) , $(shell echo $(p ) | awk '$$1 ~ /$(PLATFORM ) /') ) )
171298endif # 3.2
172299endif # 3
173300endif
174301
175302define MSG_PLATFORM
176- No platform matched pattern '$(DEVICE ) '.
303+ No platform matched pattern '$(PLATFORM ) '.
177304Available platforms are: $(XPLATFORMS )
178- To add more platform directories, set the PLATFORM_REPO_PATHS variable or point DEVICE variable to the full path of platform .xpfm file.
305+ To add more platform directories, set the PLATFORM_REPO_PATHS variable or point PLATFORM variable to the full path of platform .xpfm file.
179306endef
180307export MSG_PLATFORM
181308
182- define MSG_DEVICE
183- More than one platform matched: $(XPLATFORM )
184- Please set DEVICE variable more accurately to select only one platform file, or set DEVICE variable to the full path of the platform .xpfm file.
185- endef
186- export MSG_DEVICE
187309
188310.PHONY : check_platform
189311check_platform :
190312ifeq (,$(XPLATFORM ) )
191313 @echo "$${MSG_PLATFORM}" && false
192314endif
193- ifneq (,$(word 2,$(XPLATFORM ) ) )
194- @echo "$${MSG_DEVICE}" && false
195- endif
196315# Check ends
197316
198317# device2xsa - create a filesystem friendly name from device name
199318# $(1) - full name of device
200- device2xsa = $(strip $(patsubst % .xpfm, % , $(shell basename $(DEVICE ) ) ) )
319+ PLATFORM_NAME = $(strip $(patsubst % .xpfm, % , $(shell basename $(PLATFORM ) ) ) )
320+
201321
202322# Cleaning stuff
203323RM = rm -f
@@ -206,9 +326,3 @@ RMDIR = rm -rf
206326MV = mv -f
207327CP = cp -rf
208328ECHO: = @echo
209- ifneq (,$(shell echo $(XPLATFORM ) | awk '/xilinx_u280_xdma_201920_3/') )
210- VPP_FLAGS += --advanced.param compiler.ignorePlatformCompatibilityCheck=true
211- ifeq ($(TARGET ) , hw)
212- VPP_LDFLAGS += --advanced.param compiler.userPreSysLinkOverlayTcl=preSysLink.tcl
213- endif
214- endif
0 commit comments