blob: 01aa01f01288108f17036ebc9dc3320895fcda0b [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
manarabdelaty32b6e9f2021-04-20 10:49:37 +020017CARAVEL_ROOT?=caravel
manarabdelatyb41301c2021-04-19 23:30:35 +020018
19# Install lite version of caravel, (1): caravel-lite, (0): caravel
20CARAVEL_LITE?=1
21
22ifeq ($(CARAVEL_LITE),1)
23 CARAVEL_NAME := caravel-lite
manarabdelaty9619ef12021-04-20 11:34:31 +020024 CARAVEL_REPO := https://github.com/efabless/caravel-lite
manarabdelatyb41301c2021-04-19 23:30:35 +020025else
26 CARAVEL_NAME := caravel
27 CARAVEL_REPO := https://github.com/efabless/caravel
28endif
29
30# Install caravel as submodule, (1): submodule, (0): clone
31SUBMODULE?=1
32
33# Include Caravel Makefile Targets
34.PHONY: %
35%:
36 $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@
37
38# Verify Target for running simulations
39.PHONY: verify
40verify:
41 cd ./verilog/dv/ && \
42 $(MAKE) -j$(THREADS) all
43 cd ./verilog/dv/ && \
44 SIM=GL $(MAKE) -j$(THREADS) all
45
46# Openlane Makefile Targets
47BLOCKS = $(shell cd openlane && find * -maxdepth 0 -type d)
48.PHONY: $(BLOCKS)
49$(BLOCKS):
50 cd openlane && $(MAKE) $*
51
52# Install caravel
53.PHONY: install
54install:
55ifeq ($(SUBMODULE),1)
56 @echo "Installing $(CARAVEL_NAME) as a submodule.."
manarabdelaty32b6e9f2021-04-20 10:49:37 +020057 @git submodule add --name $(CARAVEL_NAME) $(CARAVEL_REPO) $(CARAVEL_ROOT)
Jeff DiCorpoa2af4232021-04-20 01:23:54 +000058 @git submodule update --init
manarabdelatyb41301c2021-04-19 23:30:35 +020059 $(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
manarabdelatye542bdf2021-04-20 11:15:40 +020068 mkdir -p openlane
69 mkdir -p openlane/user_project_wrapper
70 cd openlane &&\
71 ln -sf ../$(CARAVEL_ROOT)/openlane/Makefile Makefile
72 cd openlane/user_project_wrapper &&\
73 ln -sf ../../$(CARAVEL_ROOT)/openlane/user_project_wrapper_empty/pin_order.cfg pin_order.cfg
manarabdelatyb41301c2021-04-19 23:30:35 +020074
75# Update Caravel
76.PHONY: update_caravel
77update_caravel: check-caravel
Jeff DiCorpoa2af4232021-04-20 01:23:54 +000078ifeq ($(SUBMODULE),1)
79 @git submodule update --init
manarabdelatyb41301c2021-04-19 23:30:35 +020080else
81 cd $(CARAVEL_ROOT)/ && \
82 git checkout master && \
83 git pull
84endif
85
86# Uninstall Caravel
87.PHONY: uninstall
88uninstall:
89ifeq ($(SUBMODULE),1)
90 git submodule deinit -f $(CARAVEL_ROOT)
91 rm -rf .git/modules/$(CARAVEL_NAME)
92 git rm -f $(CARAVEL_ROOT)
93else
94 rm -rf $(CARAVEL_ROOT)
95endif
96
97# Clean
98.PHONY: clean
99clean:
100 cd ./verilog/dv/ && \
101 $(MAKE) -j$(THREADS) clean
102
103check-caravel:
104 @if [ ! -d "$(CARAVEL_ROOT)" ]; then \
105 echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \
106 exit 1; \
Jeff DiCorpofb944f92021-04-20 00:40:50 +0000107 fi