aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 870319de80f680d91047c47b0d3bba35d011cd46 (plain)
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
# Build ghdl module for yosys

# Name or path to the ghdl executable.
GHDL=ghdl

YOSYS_CONFIG=yosys-config
SOEXT=so

CFLAGS ?= -O

LIBGHDL_LIB:=$(shell $(GHDL) --libghdl-library-path)
LIBGHDL_INC:=$(shell $(GHDL) --libghdl-include-dir)

ALL_LDFLAGS=$(LIBGHDL_LIB) -Wl,-rpath,$(dir $(LIBGHDL_LIB)) $(LDFLAGS)
PLUGINDIR:=$(shell $(YOSYS_CONFIG) --datdir)/plugins

ALL_CFLAGS=-fPIC -DYOSYS_ENABLE_GHDL -I$(LIBGHDL_INC) $(CFLAGS)

VER_HASH=$(shell git rev-parse --short HEAD || echo "unknown")

all: ghdl.$(SOEXT)

ghdl.$(SOEXT): ghdl.o
	$(YOSYS_CONFIG) --build $@ $< -shared $(ALL_LDFLAGS)

ghdl.o: src/ghdl.cc
	$(YOSYS_CONFIG) --exec --cxx -c --cxxflags -o $@ $< $(ALL_CFLAGS) -DGHDL_VER_HASH="\"$(VER_HASH)\""

clean: force
	$(RM) -f ghdl.$(SOEXT) ghdl.o

install: ghdl.$(SOEXT)
	$(YOSYS_CONFIG) --exec mkdir -p $(DESTDIR)$(PLUGINDIR)
	$(YOSYS_CONFIG) --exec cp $< $(DESTDIR)$(PLUGINDIR)

-include src/ghdl.d

force: