manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 1 | # 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 | |
manarabdelaty | 32b6e9f | 2021-04-20 10:49:37 +0200 | [diff] [blame] | 17 | CARAVEL_ROOT?=caravel |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 18 | |
| 19 | # Install lite version of caravel, (1): caravel-lite, (0): caravel |
| 20 | CARAVEL_LITE?=1 |
| 21 | |
| 22 | ifeq ($(CARAVEL_LITE),1) |
| 23 | CARAVEL_NAME := caravel-lite |
manarabdelaty | 9619ef1 | 2021-04-20 11:34:31 +0200 | [diff] [blame] | 24 | CARAVEL_REPO := https://github.com/efabless/caravel-lite |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 25 | else |
| 26 | CARAVEL_NAME := caravel |
| 27 | CARAVEL_REPO := https://github.com/efabless/caravel |
| 28 | endif |
| 29 | |
| 30 | # Install caravel as submodule, (1): submodule, (0): clone |
| 31 | SUBMODULE?=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 |
| 40 | verify: |
| 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 |
| 47 | BLOCKS = $(shell cd openlane && find * -maxdepth 0 -type d) |
| 48 | .PHONY: $(BLOCKS) |
| 49 | $(BLOCKS): |
| 50 | cd openlane && $(MAKE) $* |
| 51 | |
| 52 | # Install caravel |
| 53 | .PHONY: install |
| 54 | install: |
| 55 | ifeq ($(SUBMODULE),1) |
| 56 | @echo "Installing $(CARAVEL_NAME) as a submodule.." |
manarabdelaty | 32b6e9f | 2021-04-20 10:49:37 +0200 | [diff] [blame] | 57 | @git submodule add --name $(CARAVEL_NAME) $(CARAVEL_REPO) $(CARAVEL_ROOT) |
Jeff DiCorpo | a2af423 | 2021-04-20 01:23:54 +0000 | [diff] [blame] | 58 | @git submodule update --init |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 59 | $(MAKE) simlink |
| 60 | else |
| 61 | @echo "Installing $(CARAVEL_NAME).." |
| 62 | @git clone $(CARAVEL_REPO) $(CARAVEL_ROOT) |
| 63 | endif |
| 64 | |
| 65 | # Create symbolic links to caravel's main files |
| 66 | .PHONY: simlink |
| 67 | simlink: check-caravel |
manarabdelaty | e542bdf | 2021-04-20 11:15:40 +0200 | [diff] [blame] | 68 | 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 |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 74 | |
| 75 | # Update Caravel |
| 76 | .PHONY: update_caravel |
| 77 | update_caravel: check-caravel |
Jeff DiCorpo | a2af423 | 2021-04-20 01:23:54 +0000 | [diff] [blame] | 78 | ifeq ($(SUBMODULE),1) |
| 79 | @git submodule update --init |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 80 | else |
| 81 | cd $(CARAVEL_ROOT)/ && \ |
| 82 | git checkout master && \ |
| 83 | git pull |
| 84 | endif |
| 85 | |
| 86 | # Uninstall Caravel |
| 87 | .PHONY: uninstall |
| 88 | uninstall: |
| 89 | ifeq ($(SUBMODULE),1) |
| 90 | git submodule deinit -f $(CARAVEL_ROOT) |
| 91 | rm -rf .git/modules/$(CARAVEL_NAME) |
| 92 | git rm -f $(CARAVEL_ROOT) |
| 93 | else |
| 94 | rm -rf $(CARAVEL_ROOT) |
| 95 | endif |
| 96 | |
| 97 | # Clean |
| 98 | .PHONY: clean |
| 99 | clean: |
| 100 | cd ./verilog/dv/ && \ |
| 101 | $(MAKE) -j$(THREADS) clean |
| 102 | |
| 103 | check-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 DiCorpo | fb944f9 | 2021-04-20 00:40:50 +0000 | [diff] [blame] | 107 | fi |