blob: f8fc12f074738997d9593b2df1ad71d40d169aff [file] [log] [blame]
manarabdelatyb41301c2021-04-19 23:30:35 +02001# SPDX-FileCopyrightText: 2020 Efabless Corporation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15# SPDX-License-Identifier: Apache-2.0
16
17CARAVEL_ROOT?=$(shell pwd)/caravel-lite
18UPRJ_ROOT?=$(shell pwd)
19
20# Install lite version of caravel, (1): caravel-lite, (0): caravel
21CARAVEL_LITE?=1
22
23ifeq ($(CARAVEL_LITE),1)
24 CARAVEL_NAME := caravel-lite
25 CARAVEL_REPO := https://github.com/Manarabdelaty/caravel-lite
26else
27 CARAVEL_NAME := caravel
28 CARAVEL_REPO := https://github.com/efabless/caravel
29endif
30
31# Install caravel as submodule, (1): submodule, (0): clone
32SUBMODULE?=1
33
34# Include Caravel Makefile Targets
35.PHONY: %
36%:
37 $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@
38
39# Verify Target for running simulations
40.PHONY: verify
41verify:
42 cd ./verilog/dv/ && \
43 $(MAKE) -j$(THREADS) all
44 cd ./verilog/dv/ && \
45 SIM=GL $(MAKE) -j$(THREADS) all
46
47# Openlane Makefile Targets
48BLOCKS = $(shell cd openlane && find * -maxdepth 0 -type d)
49.PHONY: $(BLOCKS)
50$(BLOCKS):
51 cd openlane && $(MAKE) $*
52
53# Install caravel
54.PHONY: install
55install:
56ifeq ($(SUBMODULE),1)
57 @echo "Installing $(CARAVEL_NAME) as a submodule.."
58 @git submodule add $(CARAVEL_REPO)
59 $(MAKE) simlink
60else
61 @echo "Installing $(CARAVEL_NAME).."
62 @git clone $(CARAVEL_REPO) $(CARAVEL_ROOT)
63endif
64
65# Create symbolic links to caravel's main files
66.PHONY: simlink
67simlink: check-caravel
68 @ln -sf $(CARAVEL_ROOT)/openlane/Makefile openlane/Makefile
69 @ln -sf $(CARAVEL_ROOT)/openlane/user_project_wrapper_empty/pin_order.cfg openlane/user_project_wrapper/pin_order.cfg
70
71# Update Caravel
72.PHONY: update_caravel
73update_caravel: check-caravel
74ifeq ($(CARAVEL_LITE),1)
75 cd $(CARAVEL_ROOT)/ && \
76 git checkout main && \
77 git pull
78else
79 cd $(CARAVEL_ROOT)/ && \
80 git checkout master && \
81 git pull
82endif
83
84# Uninstall Caravel
85.PHONY: uninstall
86uninstall:
87ifeq ($(SUBMODULE),1)
88 git submodule deinit -f $(CARAVEL_ROOT)
89 rm -rf .git/modules/$(CARAVEL_NAME)
90 git rm -f $(CARAVEL_ROOT)
91else
92 rm -rf $(CARAVEL_ROOT)
93endif
94
95# Clean
96.PHONY: clean
97clean:
98 cd ./verilog/dv/ && \
99 $(MAKE) -j$(THREADS) clean
100
101check-caravel:
102 @if [ ! -d "$(CARAVEL_ROOT)" ]; then \
103 echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \
104 exit 1; \
105 fi