forked from kevinpt/vhdl-extras
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
100 lines (66 loc) · 1.99 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
# VHDL make file
RTL_ROOT := rtl
VCOM_FLAGS := -source -quiet
BUILD_DIR := build
TAG_DIR := $(BUILD_DIR)/tags
LIB_BASE_DIR := $(BUILD_DIR)/lib
VERSION := $(shell grep -e "^version" doc/conf.py | sed -e "s/.*'\([^']*\)'/\1/")
DIST_NAME := vhdl-extras-$(VERSION)
DIST_DIR := $(BUILD_DIR)/dist/$(DIST_NAME)
NO_COLOR=\x1b[0m
SUCC_COLOR=\x1b[32;01m
ERROR_COLOR=\x1b[31;01m
WARN_COLOR=\x1b[33;01m
OK=$(OK_COLOR)[OK]$(NO_COLOR)
# Find the RTL source files
RTL_DIRS := $(wildcard $(RTL_ROOT)/*)
LIB_DIRS := $(foreach sdir, $(RTL_DIRS), $(LIB_BASE_DIR)/$(notdir $(sdir)) )
VPATH = $(RTL_DIRS)
VPATH += $(TAG_DIR)
# Skip XST specific timing package
EXCLUDE_RTL := timing_ops_xilinx.vhdl
RTL := $(filter-out $(EXCLUDE_RTL), $(foreach sdir, $(RTL_DIRS), $(notdir $(wildcard $(sdir)/*.vhd*))))
RTL := $(filter %.vhd %.vhdl, $(RTL))
TAG_OBJS := $(foreach fname, $(RTL), $(basename $(notdir $(fname))).tag)
.SUFFIXES:
.SUFFIXES: .vhdl .vhd
define BUILD_VHDL
@dir=`dirname $<`; \
if [ -z $${dir##*_*} ]; then \
std=$${dir##*_}; \
else \
std=93; \
fi; \
echo "** Compiling:" std=$$std lib=`basename $$dir` $<; \
vcom $(VCOM_FLAGS) -$$std -work `basename $$dir` $<
@touch $(TAG_DIR)/$@
endef
%.tag: %.vhdl
$(BUILD_VHDL)
%.tag: %.vhd
$(BUILD_VHDL)
.PHONY: compile clean dist
compile: $(TAG_OBJS)
clean:
rm -rf $(BUILD_DIR)
dist: $(DIST_DIR)
rm -rf $(DIST_DIR)/* $(DIST_DIR)/.* 2>&-; hg clone . $(DIST_DIR)
cd $(BUILD_DIR)/dist; tar czf $(DIST_NAME).tgz $(DIST_NAME); zip -q -r $(DIST_NAME).zip $(DIST_NAME)
# Generate dependency rules
RULES := auto_rules.mk
$(BUILD_DIR)/$(RULES): $(RTL) | $(BUILD_DIR)
@echo Making rules
@python scripts/vdep.py $^ > $@
include $(BUILD_DIR)/$(RULES)
$(BUILD_DIR):
mkdir $(BUILD_DIR)
$(TAG_DIR): | $(BUILD_DIR)
mkdir $(TAG_DIR)
$(LIB_BASE_DIR): | $(BUILD_DIR)
mkdir $(LIB_BASE_DIR)
$(LIB_DIRS): | $(LIB_BASE_DIR)
@echo $(LIB_DIRS) | xargs -n 1 vlib
$(TAG_OBJS): | $(TAG_DIR) $(LIB_DIRS) $(BUILD_DIR)/$(RULES)
#all: $(TAG_OBJS)
$(DIST_DIR): | $(BUILD_DIR)
mkdir -p $(DIST_DIR)