-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
80 lines (67 loc) · 2.06 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
# for out-of-tree build support
SRC_DIR := $(dir $(firstword $(MAKEFILE_LIST)))
VPATH := $(SRC_DIR)
YOSYS_CONFIG := $(YOSYS_PREFIX)yosys-config
PLUGINDIR:=$(shell $(YOSYS_CONFIG) --datdir)/plugins
CXXFLAGS :=
SRCS = $(wildcard $(SRC_DIR)/src/*.cc)
OBJS = $(patsubst $(SRC_DIR)/src/%.cc,build/%.o,$(SRCS))
build: build/slang.so
configure-slang:
@mkdir -p $(@D)
@if [ ! -f "$(SRC_DIR)/third_party/slang/CMakeLists.txt" ]; then \
echo "The content of the slang submodule seems to be missing."; \
echo "Initialize the submodule with"; \
echo ""; \
echo " git submodule init"; \
echo " git submodule update third_party/slang"; \
echo ""; \
exit 1; \
fi
cmake -S $(SRC_DIR)/third_party/slang -B build/slang \
-DCMAKE_INSTALL_PREFIX=build/slang_install \
-DSLANG_INCLUDE_TESTS=OFF \
-DSLANG_INCLUDE_TOOLS=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DSLANG_USE_MIMALLOC=OFF \
-DCMAKE_CXX_FLAGS="-fPIC" \
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=ON \
-DCMAKE_DISABLE_FIND_PACKAGE_fmt=ON \
-DCMAKE_INSTALL_LIBDIR=lib
build/slang/.configured:
$(MAKE) configure-slang
touch $@
build-slang: build/slang/.configured
$(MAKE) -C $(dir $^)
$(MAKE) -C $(dir $^) install
touch build/slang_install/.built
build/slang_install/.built:
$(MAKE) build-slang
clean-slang:
rm -rf build/slang build/slang_install
clean-objects:
rm -f $(OBJS)
clean: clean-objects
rm -f build/slang.so
clean-all: clean clean-slang
install: build/slang.so
mkdir -p $(PLUGINDIR)
cp $< $(PLUGINDIR)
-include $(OBJS:.o=.d)
build/%.o: src/%.cc build/slang_install/.built
@mkdir -p $(@D)
@echo " CXX $@"
@$(YOSYS_CONFIG) --exec --cxx --cxxflags -O3 -g -I . -MD \
-c -o $@ $< -std=c++20 \
$(CXXFLAGS) \
-DSLANG_BOOST_SINGLE_HEADER \
-Ibuild/slang_install/include
build/slang.so: $(OBJS)
@mkdir -p $(@D)
@echo " LINK $@"
@$(YOSYS_CONFIG) --exec --cxx --cxxflags --ldflags -g -o $@ \
$(CXXFLAGS) \
-shared $^ --ldlibs \
build/slang_install/lib/libsvlang.a \
build/slang_install/lib/libfmt.a
.PHONY: build configure-slang build-slang clean-slang clean-objects clean clean-all install