-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.mk
executable file
·136 lines (117 loc) · 4.05 KB
/
utils.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#+-------------------------------------------------------------------------------
# The following parameters are assigned with default values. These parameters can
# be overridden through the make command line
#+-------------------------------------------------------------------------------
PROFILE := no
#Generates profile summary report
ifeq ($(PROFILE), yes)
VPP_LDFLAGS += --profile.data all:all:all
endif
DEBUG := no
#Generates debug summary report
ifeq ($(DEBUG), yes)
VPP_LDFLAGS += --dk list_ports
endif
#Setting PLATFORM
ifeq ($(PLATFORM),)
ifneq ($(DEVICE),)
$(warning WARNING: DEVICE is deprecated in make command. Please use PLATFORM instead)
PLATFORM := $(DEVICE)
endif
endif
#Checks for XILINX_VITIS
check-vitis:
ifndef XILINX_VITIS
$(error XILINX_VITIS variable is not set, please set correctly and rerun)
endif
#Checks for XILINX_XRT
check-xrt:
ifeq ($(HOST_ARCH), x86)
ifndef XILINX_XRT
$(error XILINX_XRT variable is not set, please set correctly and rerun)
endif
else
ifndef XILINX_VITIS
$(error XILINX_VITIS variable is not set, please set correctly and rerun)
endif
endif
check-device:
@set -eu; \
inallowlist=False; \
inblocklist=False; \
if [ "$(PLATFORM_ALLOWLIST)" = "" ]; \
then inallowlist=True; \
fi; \
for dev in $(PLATFORM_ALLOWLIST); \
do if [[ $$(echo $(PLATFORM) | grep $$dev) != "" ]]; \
then inallowlist=True; fi; \
done ;\
for dev in $(PLATFORM_BLOCKLIST); \
do if [[ $$(echo $(PLATFORM) | grep $$dev) != "" ]]; \
then inblocklist=True; fi; \
done ;\
if [[ $$inblocklist == True ]]; \
then echo "[ERROR]: This example is not supported for $(PLATFORM)."; exit 1;\
fi; \
if [[ $$inallowlist == False ]]; \
then echo "[Warning]: The platform $(PLATFORM) not in allowlist."; \
fi;
#Checks for Correct architecture
ifneq ($(HOST_ARCH), $(filter $(HOST_ARCH),aarch64 aarch32 x86))
$(error HOST_ARCH variable not set, please set correctly and rerun)
endif
#Setting CXX
CXX := g++
#Checks for EDGE_COMMON_SW
ifneq ($(HOST_ARCH), x86)
ifndef EDGE_COMMON_SW
$(error EDGE_COMMON_SW variable is not set, please set correctly and rerun)
endif
ifeq ($(HOST_ARCH), aarch64)
SYSROOT := $(EDGE_COMMON_SW)/sysroots/cortexa72-cortexa53-xilinx-linux
SD_IMAGE_FILE := $(EDGE_COMMON_SW)/Image
CXX := $(XILINX_VITIS)/gnu/aarch64/lin/aarch64-linux/bin/aarch64-linux-gnu-g++
else ifeq ($(HOST_ARCH), aarch32)
SYSROOT := $(EDGE_COMMON_SW)/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi/
SD_IMAGE_FILE := $(EDGE_COMMON_SW)/uImage
CXX := $(XILINX_VITIS)/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin/arm-linux-gnueabihf-g++
endif
endif
gen_run_app:
ifneq ($(HOST_ARCH), x86)
rm -rf run_app.sh
$(ECHO) 'export LD_LIBRARY_PATH=/mnt:/tmp:$$LD_LIBRARY_PATH' >> run_app.sh
$(ECHO) 'export PATH=$$PATH:/sbin' >> run_app.sh
$(ECHO) 'export XILINX_XRT=/usr' >> run_app.sh
ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu))
$(ECHO) 'export XILINX_VITIS=$$PWD' >> run_app.sh
$(ECHO) 'export XCL_EMULATION_MODE=$(TARGET)' >> run_app.sh
endif
$(ECHO) '$(EXECUTABLE) vector_addition.xclbin' >> run_app.sh
$(ECHO) 'return_code=$$?' >> run_app.sh
$(ECHO) 'if [ $$return_code -ne 0 ]; then' >> run_app.sh
$(ECHO) 'echo "ERROR: host run failed, RC=$$return_code"' >> run_app.sh
$(ECHO) 'fi' >> run_app.sh
$(ECHO) 'echo "INFO: host run completed."' >> run_app.sh
endif
check-platform:
ifndef PLATFORM
$(error PLATFORM not set. Please set the PLATFORM properly and rerun. Run "make help" for more details.)
endif
# device2xsa - create a filesystem friendly name from device name
# $(1) - full name of device
device2xsa = $(strip $(patsubst %.xpfm, % , $(shell basename $(PLATFORM))))
############################## Deprecated Checks and Running Rules ##############################
check:
$(ECHO) "WARNING: \"make check\" is a deprecated command. Please use \"make run\" instead"
make run
exe:
$(ECHO) "WARNING: \"make exe\" is a deprecated command. Please use \"make host\" instead"
make host
# Cleaning stuff
RM = rm -f
RMDIR = rm -rf
ECHO:= @echo
docs: README.rst
README.rst: description.json
$(XF_PROJ_ROOT)/common/utility/readme_gen/readme_gen.py description.json