~ruther/vhdl-makefile-template

ref: 61aa59a8b05d7bd9f806efc30ad7a85d1b18b257 vhdl-makefile-template/xil/Makefile -rw-r--r-- 1.2 KiB
61aa59a8 — František Boháček fix: order of statements in makefile 3 years ago
                                                                                
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
DEVICE := xc6slx9
PACKAGE := 2ftg256

WORKDIR := ./work

IMPACT := impact
XFLOW := xflow

# SOURCES is expected to be set to list of files separated by space
# TOP_ENTITY is expected to be set to top entity's name
# TOP_ENTITY_VHDL is expected to be set to top entity's vhdl file path

TOP_ENTITY_BIT := $(WORKDIR)/$(TOP_ENTITY).bit
TOP_ENTITY_BIT_ESCAPED := $(shell echo $(TOP_ENTITY_BIT) | sed "s=\/=\\\/=g")

IMPACT_BATCH := impact.cmd
IMPACT_BATCH_TEMPLATE := impact.cmd.tmplt

PROJECT_FILE := $(shell pwd)/$(TOP_ENTITY).prj

.PHONY: all compile flash clean

all: compile flash

$(WORKDIR):
	mkdir $(WORKDIR)

$(PROJECT_FILE):
	echo "$(SOURCES)" | tr " " "\n" | sed -e "s/^/work /" - > $(PROJECT_FILE)

compile: clean $(WORKDIR) $(PROJECT_FILE)
	cp $(SRCDIR)/*.ucf $(WORKDIR)
	$(XFLOW) -p $(DEVICE)-$(PACKAGE) -synth xst_vhdl.opt -implement balanced.opt -config bitgen.opt $(PROJECT_FILE) -wd work

$(IMPACT_BATCH):
	sed -e "s=<bitfile>=$(TOP_ENTITY_BIT_ESCAPED)=g" $(IMPACT_BATCH_TEMPLATE) > $(IMPACT_BATCH)

flash: $(IMPACT_BATCH)
	$(IMPACT) -batch $(IMPACT_BATCH)

clean:
	$(RM) -rf $(WORKDIR)
	$(RM) -rf $(PROJECT_FILE)
	$(RM) -rf $(IMPACT_BATCH)
	$(RM) -rf _impactbatch.log
	$(RM) -rf xflow.his
Do not follow this link