-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
183 lines (143 loc) · 5.67 KB
/
Copy pathMakefile
File metadata and controls
183 lines (143 loc) · 5.67 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
THIS_MK_ABSPATH := $(abspath $(lastword $(MAKEFILE_LIST)))
THIS_MK_DIR := $(dir $(THIS_MK_ABSPATH))
# Enable pipefail for all commands
SHELL=/bin/bash -o pipefail
# Enable second expansion
.SECONDEXPANSION:
# Clear all built in suffixes
.SUFFIXES:
NOOP :=
SPACE := $(NOOP) $(NOOP)
COMMA := ,
HOSTNAME := $(shell hostname)
##############################################################################
# Environment check
##############################################################################
##############################################################################
# Configuration
##############################################################################
WORK_ROOT := $(abspath $(THIS_MK_DIR)/work)
INSTALL_RELATIVE_ROOT ?= install
INSTALL_ROOT ?= $(abspath $(THIS_MK_DIR)/$(INSTALL_RELATIVE_ROOT))
PYTHON3 ?= python3
VENV_DIR := venv
VENV_PY := $(VENV_DIR)/bin/python
VENV_PIP := $(VENV_DIR)/bin/pip
ifneq ($(https_proxy),)
PIP_PROXY := --proxy $(https_proxy)
else
PIP_PROXY :=
endif
VENV_PIP_INSTALL := $(VENV_PIP) install $(PIP_PROXY) --timeout 90 --trusted-host pypi.org --trusted-host files.pythonhosted.org
##############################################################################
# Set default goal before any targets. The default goal here is "test"
##############################################################################
DEFAULT_TARGET := help
.DEFAULT_GOAL := default
.PHONY: default
default: $(DEFAULT_TARGET)
##############################################################################
# Makefile starts here
##############################################################################
###############################################################################
# Design Targets
###############################################################################
%/output_files:
mkdir -p $@
$(INSTALL_ROOT) $(INSTALL_ROOT)/designs $(INSTALL_ROOT)/not_shipped:
mkdir -p $@
# Initialize variables
ALL_TARGET_STEM_NAMES =
ALL_TARGET_ALL_NAMES =
# Define function to create targets
# create_ghrd_target
# $(1) - Base directory name. i.e. cv_soc_devkit_ghrd
# $(2) - Target name. i.e. cyclonev-soc-devkit-baseline. Format is <devkit>-<name>
# $(3) - Revision name. i.e. soc_system
# $(4) - Config target. i.e. generate-cyclonev-soc-devkit-baseline
define create_ghrd_target
ALL_TARGET_STEM_NAMES += $(strip $(2))
ALL_TARGET_ALL_NAMES += $(strip $(2))-all
.PHONY: $(strip $(2))-prep
$(strip $(2))-prep: prepare-tools | $(strip $(1))/output_files
.PHONY: $(strip $(2))-generate-design
$(strip $(2))-generate-design: prepare-tools | $(strip $(1))/output_files
$(MAKE) -C $(strip $(1)) $(strip $(4))
$(MAKE) -C $(strip $(1)) apply_pin_assignment
.PHONY: $(strip $(2))-build
$(strip $(2))-build: $(strip $(1))/output_files
cd $(strip $(1)) && quartus_map $(strip $(3))
cd $(strip $(1)) && quartus_fit $(strip $(3))
cd $(strip $(1)) && quartus_asm $(strip $(3))
cd $(strip $(1)) && quartus_sta $(strip $(3)) --mode=finalize
cd $(strip $(1)) && touch output_files/$(strip $(3)).sof
$(MAKE) -C $(strip $(1)) create_rbf
.PHONY: $(strip $(2))-sw-build
$(strip $(2))-sw-build:
.PHONY: $(strip $(2))-test
$(strip $(2))-test:
.PHONY: $(strip $(2))-install-sof
$(strip $(2))-install-sof: | $(INSTALL_ROOT)/designs
cp -f $(strip $(1))/output_files/$(strip $(3)).sof $(INSTALL_ROOT)/designs/$(strip $(2)).sof
cp -f $(strip $(1))/output_files/$(strip $(3)).rbf $(INSTALL_ROOT)/designs/$(strip $(2)).rbf
.PHONY: $(strip $(2))-package-design
$(strip $(2))-package-design: | $(INSTALL_ROOT)/designs
cd $(strip $(1)) && zip -r $(INSTALL_ROOT)/designs/$(strip $(2)).zip * -x .gitignore "output_files/*" "db/*" "tmp-clearbox/*"
.PHONY: $(strip $(2))-all
$(strip $(2))-all:
$(MAKE) $(strip $(2))-generate-design
$(MAKE) $(strip $(2))-package-design
$(MAKE) $(strip $(2))-prep
$(MAKE) $(strip $(2))-build
$(MAKE) $(strip $(2))-sw-build
$(MAKE) $(strip $(2))-test
$(MAKE) $(strip $(2))-install-sof
endef
# Create the recipes by calling create_ghrd_target on each design
$(eval $(call create_ghrd_target, cv_soc_devkit_ghrd, cyclonev-soc-devkit-baseline, soc_system, generate-cyclonev-soc-devkit-baseline))
###############################################################################
# UTILITY TARGETS
###############################################################################
# Deep clean using git
.PHONY: dev-clean
dev-clean :
git clean -dfx --exclude=/.vscode --exclude=.lfsconfig
# Using git
.PHONY: dev-update
dev-update :
git pull
git submodule update --init --recursive
.PHONY: clean
clean:
git clean -dfx --exclude=/.vscode --exclude=.lfsconfig --exclude=$(VENV_DIR)
# Prep workspace
venv:
$(PYTHON3) -m venv $(VENV_DIR)
$(VENV_PIP_INSTALL) --upgrade pip
$(VENV_PIP_INSTALL) -r requirements.txt
.PHONY: venv-freeze
venv-freeze:
$(VENV_PIP) freeze > requirements.txt
sed -i -e 's/==/~=/g' requirements.txt
.PHONY: prepare-tools
prepare-tools : venv
# Include not_shipped Makefile if present
-include not_shipped/Makefile.mk
###############################################################################
# Toplevel Targets
###############################################################################
.PHONY: prep
prep: prepare-tools
.PHONY: pre-prep
pre-prep:
.PHONY: package-designs
package-designs: $(addsuffix -package-designs,$(ALL_TARGET_STEM_NAMES))
###############################################################################
# HELP
###############################################################################
.PHONY: help
help:
$(info GHRD Build)
$(info ----------------)
$(info ALL Targets : $(ALL_TARGET_ALL_NAMES))
$(info Stem names : $(ALL_TARGET_STEM_NAMES))