forked from shgoupf/snap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
183 lines (153 loc) · 6.13 KB
/
Makefile
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
#
# Copyright 2016-2018 International Business Machines
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
SHELL=/bin/bash
PLATFORM ?= $(shell uname -i)
export SNAP_ROOT=$(abspath .)
config_subdirs += $(SNAP_ROOT)/scripts
software_subdirs += $(SNAP_ROOT)/software
hardware_subdirs += $(SNAP_ROOT)/hardware
action_subdirs += $(SNAP_ROOT)/actions
snap_config = .snap_config
snap_config_bak = .snap_config_test.bak
snap_config_new = .snap_config_test.new
snap_config_sh = .snap_config.sh
snap_config_cflags = .snap_config.cflags
snap_env_sh = snap_env.sh
clean_subdirs += $(config_subdirs) $(software_subdirs) $(hardware_subdirs) $(action_subdirs)
# Only build if the subdirectory is really existent
.PHONY: help $(software_subdirs) software $(action_subdirs) apps actions $(hardware_subdirs) hardware test install uninstall snap_env hw_project model sim image cloud_enable cloud_base cloud_action cloud_merge snap_config config menuconfig xconfig gconfig oldconfig clean clean_config clean_env gitclean
help:
@echo "Main targets for the SNAP Framework make process:";
@echo "=================================================";
@echo "* snap_config Configure SNAP framework";
@echo "* model Build simulation model for simulator specified via target snap_config";
@echo "* image Build a complete FPGA bitstream (will take more than one hour)";
@echo "* hardware Build simulation model and FPGA bitstream (combines targets 'model' and 'image')";
@echo "* hw_project Create Vivado project";
@echo "* sim Start a simulation";
@echo "* software Build software libraries and tools for SNAP";
@echo "* apps Build the applications for all actions";
@echo "* clean Remove all files generated in make process";
@echo "* clean_config As target 'clean' plus reset of the configuration";
@echo "* help Print this message";
@echo;
@echo "The hardware related targets 'model', 'image', 'hardware', 'hw_project' and 'sim'";
@echo "do only exist on an x86 platform";
@echo;
ifeq ($(PLATFORM),x86_64)
all: $(software_subdirs) $(action_subdirs) $(hardware_subdirs)
else
all: $(software_subdirs) $(action_subdirs)
endif
# Disabling implicit rule for shell scripts
%: %.sh
$(software_subdirs):
@if [ -d $@ ]; then \
echo "Enter: $@"; \
$(MAKE) -C $@ || exit 1; \
echo "Exit: $@"; \
fi
software: $(software_subdirs)
$(action_subdirs):
@if [ -d $@ ]; then \
echo "Enter: $@"; \
$(MAKE) -C $@ || exit 1; \
echo "Exit: $@"; \
fi
apps actions: $(action_subdirs)
# Install/uninstall
test install uninstall:
@for dir in $(software_subdirs) $(action_subdirs); do \
if [ -d $$dir ]; then \
$(MAKE) -s -C $$dir $@ || exit 1; \
fi \
done
ifeq ($(PLATFORM),x86_64)
$(hardware_subdirs): $(snap_env_sh)
@if [ -d $@ ]; then \
$(MAKE) -s -C $@ || exit 1; \
fi
hardware: $(hardware_subdirs)
# Model build and config
hw_project model sim image cloud_enable cloud_base cloud_action: $(snap_env_sh)
@for dir in $(hardware_subdirs); do \
if [ -d $$dir ]; then \
$(MAKE) -s -C $$dir $@ || exit 1; \
fi \
done
cloud_merge:
@ignore_action_root=ignore_action_root $(MAKE) $(snap_env_sh)
@for dir in $(hardware_subdirs); do \
if [ -d $$dir ]; then \
ignore_action_root=ignore_action_root $(MAKE) -s -C $$dir $@ || exit 1; \
fi \
done
else #noteq ($(PLATFORM),x86_64)
.PHONY: wrong_platform
wrong_platform:
@echo; echo "\nSNAP hardware builds and simulation are possible on x86 platform only\n"; echo;
$(hardware_subdirs) hardware hw_project model sim image cloud_base cloud_action cloud_merge: wrong_platform
endif
# SNAP Config
config menuconfig xconfig gconfig oldconfig:
@echo "$@: Setting up SNAP configuration"
@touch $(snap_config) && sed '/^#/ d' <$(snap_config) >$(snap_config_bak)
@for dir in $(config_subdirs); do \
if [ -d $$dir ]; then \
$(MAKE) -s -C $$dir $@ || exit 1; \
fi \
done
@sed '/^#/ d' <$(snap_config) >$(snap_config_new)
@if [ -n "`diff -q $(snap_config_bak) $(snap_config_new)`" ]; then \
$(MAKE) -C hardware clean; \
fi
@$(RM) $(snap_config_bak) $(snap_config_new)
snap_config:
@$(MAKE) -s menuconfig || exit 1
@$(MAKE) -s snap_env snap_env_parm=config
@echo "SNAP config done"
$(snap_config_sh):
@$(MAKE) -s menuconfig || exit 1
@echo "SNAP config done"
# Prepare SNAP Environment
$(snap_env_sh) snap_env: $(snap_config_sh)
@$(SNAP_ROOT)/snap_env $(snap_env_parm) $(ignore_action_root) $(snap_config_sh)
%.defconfig:
@if [ ! -f defconfig/$@ ]; then \
echo "ERROR: Configuration $@ not existing!"; \
exit 2 ; \
fi
@cp defconfig/$@ $(snap_config)
@$(MAKE) -s oldconfig
@$(MAKE) -s snap_env
clean:
@for dir in $(clean_subdirs); do \
if [ -d $$dir ]; then \
$(MAKE) -s -C $$dir $@ || exit 1; \
fi \
done
@find . -depth -name '*~' -exec rm -rf '{}' \; -print
@find . -depth -name '.#*' -exec rm -rf '{}' \; -print
clean_config: clean
@$(RM) $(snap_config)
@$(RM) $(snap_config_sh)
@$(RM) $(snap_config_cflags)
clean_env: clean_config
@$(RM) $(snap_env_sh)
gitclean:
@echo -e "[GITCLEAN............] cleaning and resetting snap git";
git clean -f -d -x
git reset --hard