99#ini flags
1010config_file = 0
1111
12+ def mk_copyright (target ):
13+ target .write ("""#
14+ # Copyright 2019-2020 Xilinx, Inc.
15+ #
16+ # Licensed under the Apache License, Version 2.0 (the "License");
17+ # you may not use this file except in compliance with the License.
18+ # You may obtain a copy of the License at
19+ #
20+ # http://www.apache.org/licenses/LICENSE-2.0
21+ #
22+ # Unless required by applicable law or agreed to in writing, software
23+ # distributed under the License is distributed on an "AS IS" BASIS,
24+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25+ # See the License for the specific language governing permissions and
26+ # limitations under the License.
27+ # makefile-generator v1.0.3
28+ #
29+ """ )
30+ return
31+
1232def create_params (target ,data ):
1333 target .write ("############################## Setting up Project Variables ##############################\n " )
1434 target .write ("# Points to top directory of Git repository\n " )
@@ -20,7 +40,7 @@ def create_params(target,data):
2040 target .write ("$(shell bash -c '%s')" % MK_PATH )
2141 target .write ("\n " )
2242 target .write ("PWD = $(shell readlink -f .)\n " )
23- target .write ("ABS_COMMON_REPO = $(shell readlink -f $(COMMON_REPO))\n " )
43+ target .write ("XF_PROJ_ROOT = $(shell readlink -f $(COMMON_REPO))\n " )
2444 target .write ("\n " )
2545 target .write ("TARGET := hw\n " )
2646 target .write ("HOST_ARCH := x86\n " )
@@ -52,15 +72,15 @@ def create_params(target,data):
5272 for cmdargs in cmd_args [0 :]:
5373 target .write (" " )
5474 cmdargs = cmdargs .replace ('BUILD' , '$(BUILD_DIR)' )
55- cmdargs = cmdargs .replace ('REPO_DIR' ,'$(ABS_COMMON_REPO )' )
75+ cmdargs = cmdargs .replace ('REPO_DIR' ,'$(XF_PROJ_ROOT )' )
5676 cmdargs = cmdargs .replace ('PROJECT' , '.' )
5777 target .write (cmdargs )
5878 target .write ("\n " )
5979 if not ("platform_type" in data and data ["platform_type" ] == "pcie" ):
6080 target .write ("SDCARD := " )
6181 target .write ("sd_card\n " )
6282 target .write ("\n " )
63- target .write ("include $(ABS_COMMON_REPO )/common/includes/opencl/opencl.mk\n " )
83+ target .write ("include $(XF_PROJ_ROOT )/common/includes/opencl/opencl.mk\n " )
6484 if "config_make" in data :
6585 target .write ("include " )
6686 target .write (data ["config_make" ])
@@ -81,15 +101,15 @@ def add_host_flags(target, data):
81101 for path in data ["host" ]["compiler" ]["includepaths" ]:
82102 path = path .replace ('BUILD' , '$(BUILD_DIR)' )
83103 path = path .replace ('PROJECT' , '.' )
84- path = path .replace ('REPO_DIR' ,'$(ABS_COMMON_REPO )' )
104+ path = path .replace ('REPO_DIR' ,'$(XF_PROJ_ROOT )' )
85105 target .write ("CXXFLAGS += -I" + path + "\n " )
86106
87107 target .write ("HOST_SRCS += " )
88108 source_flag = 0
89109 if "sources" in data ["host" ]["compiler" ]:
90110 for src in data ["host" ]["compiler" ]["sources" ]:
91111 src = src .replace ('PROJECT' , '.' )
92- src = src .replace ('REPO_DIR' ,'$(ABS_COMMON_REPO )' )
112+ src = src .replace ('REPO_DIR' ,'$(XF_PROJ_ROOT )' )
93113 target .write (src + " " )
94114 source_flag += 1
95115 if not source_flag :
@@ -134,16 +154,16 @@ def add_kernel_flags(target, data):
134154
135155 if "v++" in data :
136156 target .write ("VPP_FLAGS += \n " )
137- target .write ("CLFLAGS += " )
157+ target .write ("VPP_FLAGS += " )
138158 target .write ("-t $(TARGET) --platform $(DEVICE) --save-temps \n " )
139159 target .write ("ifneq ($(TARGET), hw)\n " )
140- target .write ("\t CLFLAGS += -g\n " )
160+ target .write ("\t VPP_FLAGS += -g\n " )
141161 target .write ("endif\n " )
142162 if "containers" in data :
143163 for con in data ["containers" ]:
144164 for acc in con ["accelerators" ]:
145165 if "max_memory_ports" in acc :
146- target .write ("CLFLAGS += " )
166+ target .write ("VPP_FLAGS += " )
147167 target .write (" --max_memory_ports " )
148168 target .write (acc ["name" ])
149169 target .write ("\n " )
@@ -152,7 +172,7 @@ def add_kernel_flags(target, data):
152172 for con in data ["containers" ]:
153173 for acc in con ["accelerators" ]:
154174 if "clflags" in acc :
155- target .write ("CLFLAGS_ " + acc ["name" ]+ " += " )
175+ target .write ("VPP_FLAGS_ " + acc ["name" ]+ " += " )
156176 flags = acc ["clflags" ].split (" " )
157177 for flg in flags [0 :]:
158178 target .write (" " )
@@ -174,7 +194,7 @@ def add_kernel_flags(target, data):
174194 if "ldclflags" in con :
175195 target .write ("\n " )
176196 target .write ("# Kernel linker flags\n " )
177- target .write ("LDCLFLAGS +=" )
197+ target .write ("VPP_LDFLAGS +=" )
178198 ldclflags = con ["ldclflags" ].split (" " )
179199 for flg in ldclflags [0 :]:
180200 target .write (" " )
@@ -192,7 +212,7 @@ def add_kernel_flags(target, data):
192212 if not config_add :
193213 target .write ("\n " )
194214 target .write ("# Adding config files to linker\n " )
195- target .write ("LDCLFLAGS_ " + con ["name" ]+ " += " )
215+ target .write ("VPP_LDFLAGS_ " + con ["name" ]+ " += " )
196216 target .write ("--config " + con ["name" ]+ ".cfg " )
197217 config_add = 1
198218 target .write ("\n " )
@@ -214,7 +234,7 @@ def add_kernel_flags(target, data):
214234 for path in data ["v++" ]["compiler" ]["includepaths" ]:
215235 path = path .replace ('BUILD' , '$(BUILD_DIR)' )
216236 path = path .replace ('PROJECT' , '.' )
217- path = path .replace ('REPO_DIR' ,'$(ABS_COMMON_REPO )' )
237+ path = path .replace ('REPO_DIR' ,'$(XF_PROJ_ROOT )' )
218238 target .write ("VPP_FLAGS += -I" + path + "\n " )
219239 target .write ("\n " )
220240
@@ -226,7 +246,7 @@ def add_kernel_flags(target, data):
226246 for path in clflags :
227247 path = path .replace ('BUILD' , '$(BUILD_DIR)' )
228248 path = path .replace ('PROJECT' , '.' )
229- path = path .replace ('REPO_DIR' ,'$(ABS_COMMON_REPO )' )
249+ path = path .replace ('REPO_DIR' ,'$(XF_PROJ_ROOT )' )
230250 target .write (" " + path )
231251 target .write ("\n \n " )
232252
@@ -272,14 +292,12 @@ def building_kernel(target, data):
272292 target .write ("\n " )
273293 target .write ("\t mkdir -p $(TEMP_DIR)\n " )
274294 target .write ("\t $(VPP) " )
275- if "v++" in data :
276- target .write ("$(VPP_FLAGS) " )
295+ target .write ("$(VPP_FLAGS) " )
296+ if "clflags" in acc :
297+ target .write ("$(VPP_FLAGS_" + acc ["name" ]+ ") " )
277298 target .write ("-c -k " )
278299 target .write (acc ["name" ])
279- target .write (" $(CLFLAGS) " )
280- if "clflags" in acc :
281- target .write ("$(CLFLAGS_" + acc ["name" ]+ ") " )
282- target .write ("--temp_dir " )
300+ target .write (" --temp_dir " )
283301 target .write ("$(TEMP_DIR) " )
284302 target .write (" -I'$(<D)'" )
285303 target .write (" -o'$@' '$<'\n " )
@@ -292,23 +310,21 @@ def building_kernel(target, data):
292310 target .write ("_OBJS)\n " )
293311 target .write ("\t mkdir -p $(BUILD_DIR)\n " )
294312 target .write ("ifeq ($(HOST_ARCH), x86)\n " )
295- target .write ("\t $(VPP) " )
296- if "v++" in data :
297- target .write ("$(VPP_FLAGS) " )
298- target .write ("-l $(LDCLFLAGS) $(CLFLAGS) --temp_dir " )
313+ target .write ("\t $(VPP) $(VPP_FLAGS) " )
314+ target .write ("-l $(VPP_LDFLAGS) --temp_dir " )
299315 target .write ("$(BUILD_DIR) " )
300316
301317 if "accelerators" in con :
302318 for acc in con ["accelerators" ]:
303319 if "compute_units" in acc or "num_compute_units" in acc :
304- target .write (" $(LDCLFLAGS_ " + con ["name" ]+ ")" )
320+ target .write (" $(VPP_LDFLAGS_ " + con ["name" ]+ ")" )
305321 break
306322 target .write (" -o'$(BUILD_DIR)/" + con ["name" ] + ".link.xclbin' $(+)\n " )
307323
308324 target .write ("\t $(VPP) -p $(BUILD_DIR)/" + con ["name" ] + ".link.xclbin -t $(TARGET) --platform $(DEVICE) " )
309325 target .write ("--package.out_dir $(PACKAGE_OUT) -o $(BUILD_DIR)/" + con ["name" ] + ".xclbin\n " )
310326 target .write ("else\n " )
311- target .write ("\t $(VPP) -l $(LDCLFLAGS) $(CLFLAGS ) --temp_dir $(BUILD_DIR) " )
327+ target .write ("\t $(VPP) $(VPP_FLAGS) -l $(VPP_LDFLAGS ) --temp_dir $(BUILD_DIR) " )
312328 target .write ("-o'$(BUILD_DIR)/" + con ["name" ] + ".xclbin' $(+)\n " )
313329 target .write ("endif\n " )
314330 target .write ("\n " )
@@ -326,22 +342,20 @@ def building_kernel_rtl(target, data):
326342 target .write ("_OBJS)\n " )
327343 target .write ("\t mkdir -p $(BUILD_DIR)\n " )
328344 target .write ("ifeq ($(HOST_ARCH), x86)\n " )
329- target .write ("\t $(VPP) " )
330- if "v++" in data :
331- target .write ("$(VPP_FLAGS) " )
332- target .write ("-l $(LDCLFLAGS) $(CLFLAGS) --temp_dir " )
345+ target .write ("\t $(VPP) $(VPP_FLAGS) " )
346+ target .write ("-l $(VPP_LDFLAGS) --temp_dir " )
333347 target .write ("$(BUILD_DIR) " )
334348
335349 if "accelerators" in con :
336350 for acc in con ["accelerators" ]:
337351 if "compute_units" in acc or "num_compute_units" in acc :
338- target .write (" $(LDCLFLAGS_ " + con ["name" ]+ ")" )
352+ target .write (" $(VPP_LDFLAGS_ " + con ["name" ]+ ")" )
339353 target .write (" -o'$(BUILD_DIR)/" + con ["name" ] + ".link.xclbin' $(+)\n " )
340354
341355 target .write ("\t $(VPP) -p $(BUILD_DIR)/" + con ["name" ] + ".link.xclbin -t $(TARGET) --platform $(DEVICE) " )
342356 target .write ("--package.out_dir $(PACKAGE_OUT) -o $(BUILD_DIR)/" + con ["name" ] + ".xclbin\n " )
343357 target .write ("else\n " )
344- target .write ("\t $(VPP) -l $(LDCLFLAGS) $(CLFLAGS ) --temp_dir $(BUILD_DIR) " )
358+ target .write ("\t $(VPP) $(VPP_FLAGS) -l $(VPP_LDFLAGS ) --temp_dir $(BUILD_DIR) " )
345359 target .write ("-o'$(BUILD_DIR)/" + con ["name" ] + ".xclbin' $(+)\n " )
346360 target .write ("endif\n " )
347361 return
@@ -500,7 +514,7 @@ def mk_run(target, data):
500514 target .write ("\n " )
501515 args = post_launch ["launch_cmd" ]
502516 args = args .replace ('BUILD' , '$(BUILD_DIR)' )
503- args = args .replace ('REPO_DIR' ,'$(ABS_COMMON_REPO )' )
517+ args = args .replace ('REPO_DIR' ,'$(XF_PROJ_ROOT )' )
504518 args = args .replace ('HOST_EXE' , '$(EXE_FILE)' )
505519 target .write ("\t " + args )
506520 if not ("platform_type" in data and data ["platform_type" ] == "pcie" ):
@@ -555,7 +569,7 @@ def mk_run(target, data):
555569 target .write ("\n " )
556570 args = post_launch ["launch_cmd" ]
557571 args = args .replace ('BUILD' , '$(BUILD_DIR)' )
558- args = args .replace ('REPO_DIR' ,'$(ABS_COMMON_REPO )' )
572+ args = args .replace ('REPO_DIR' ,'$(XF_PROJ_ROOT )' )
559573 args = args .replace ('HOST_EXE' , '$(EXE_FILE)' )
560574 target .write ("\t " + args )
561575 if not ("platform_type" in data and data ["platform_type" ] == "pcie" ):
@@ -589,7 +603,7 @@ def mk_sdcard(target, data):
589603 for arg in args :
590604 if "xclbin" not in arg :
591605 arg = arg .replace ('BUILD' , '$(BUILD_DIR)' )
592- arg = arg .replace ('REPO_DIR' ,'$(ABS_COMMON_REPO )' )
606+ arg = arg .replace ('REPO_DIR' ,'$(XF_PROJ_ROOT )' )
593607 arg = arg .replace ('PROJECT' , '.' )
594608 extra_file_list .append (arg )
595609 target .write ("ifneq ($(HOST_ARCH), x86)\n " )
@@ -622,7 +636,7 @@ def aws_build(target):
622636 target .write ("\t $(COMMON_REPO)/common/utility/aws/run_aws.py $(BINARY_CONTAINERS)\n \n " )
623637
624638def mk_help (target ):
625- target .write ("############################## Help Section ##############################\n " )
639+ target .write ("\n ############################## Help Section ##############################\n " )
626640
627641 target .write (".PHONY: help\n " )
628642 target .write ("\n " )
@@ -681,12 +695,12 @@ def report_gen(target, data):
681695 target .write ("\n " )
682696 target .write ("#Generates profile summary report\n " )
683697 target .write ("ifeq ($(PROFILE), yes)\n " )
684- target .write ("LDCLFLAGS += --profile_kernel data:all:all:all\n " )
698+ target .write ("VPP_LDFLAGS += --profile_kernel data:all:all:all\n " )
685699 target .write ("endif\n " )
686700 target .write ("\n " )
687701
688702 target .write ("DEBUG := no\n " )
689- target .write ("B_TEMP = `$(ABS_COMMON_REPO )/common/utility/parse_platform_list.py $(DEVICE)`\n " )
703+ target .write ("B_TEMP = `$(XF_PROJ_ROOT )/common/utility/parse_platform_list.py $(DEVICE)`\n " )
690704 if not ("platform_type" in data and data ["platform_type" ] == "pcie" ):
691705 target .write ("PERL := \n " )
692706 target .write ("QEMU_IMODE := no\n " )
@@ -699,12 +713,12 @@ def report_gen(target, data):
699713 target .write ("ifeq ($(QEMU_IMODE), yes)\n " )
700714 target .write ("\t LAUNCH_EMULATOR_CMD = $(LAUNCH_EMULATOR)\n " )
701715 target .write ("else\n " )
702- target .write ("\t LAUNCH_EMULATOR_CMD = $(PERL) $(ABS_COMMON_REPO )/common/utility/run_emulation.pl \" ${LAUNCH_EMULATOR} | tee run_app.log\" \" ${RUN_APP_SCRIPT} $(TARGET)\" \" ${RESULT_STRING}\" \" 7\" \n " )
716+ target .write ("\t LAUNCH_EMULATOR_CMD = $(PERL) $(XF_PROJ_ROOT )/common/utility/run_emulation.pl \" ${LAUNCH_EMULATOR} | tee run_app.log\" \" ${RUN_APP_SCRIPT} $(TARGET)\" \" ${RESULT_STRING}\" \" 7\" \n " )
703717 target .write ("endif\n " )
704718 target .write ("\n " )
705719 target .write ("#Generates debug summary report\n " )
706720 target .write ("ifeq ($(DEBUG), yes)\n " )
707- target .write ("LDCLFLAGS += --dk list_ports\n " )
721+ target .write ("VPP_LDFLAGS += --dk list_ports\n " )
708722 target .write ("endif\n " )
709723 target .write ("\n " )
710724
@@ -817,11 +831,12 @@ def readme_gen(target):
817831 target .write ("docs: README.rst\n " )
818832 target .write ("\n " )
819833 target .write ("README.rst: description.json\n " )
820- target .write ("\t $(ABS_COMMON_REPO )/common/utility/readme_gen/readme_gen.py description.json" )
834+ target .write ("\t $(XF_PROJ_ROOT )/common/utility/readme_gen/readme_gen.py description.json" )
821835 target .write ("\n " )
822836
823837
824838def create_mk (target , data ):
839+ mk_copyright (target )
825840 mk_help (target )
826841 create_params (target ,data )
827842 add_host_flags (target , data )
0 commit comments