aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 83d354406b433f57387feadad3966886450267a6 (plain) (blame)
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
export CC  = clang
export CXX = clang++

export SYSTEMC_HOME := $(PWD)/INSTALL

V ?= 0
ifeq ($V,1)
	NINJA_FLAGS  += --verbose
	CCTEST_FLAGS += --verbose
endif

SRCS = $(wildcard src/*.cc)
BINS = $(SRCS:src/%.cc=BUILD/PLAYGROUND/%)

# -- SYSTEMC PLAYGROUND --------------------------------------------------------

build: INSTALL/lib/libsystemc.a BUILD/PLAYGROUND/CMakeCache.txt $(SRCS)
	ninja -C BUILD/PLAYGROUND $(NINJA_FLAGS)

run: build
	@for B in $(BINS); do \
		echo "==> $$B"; \
		$$B; \
	done

test: build
	cd BUILD/PLAYGROUND/test && ctest --output-on-failure $(CCTEST_FLAGS)

BUILD/PLAYGROUND/CMakeCache.txt: CMakeLists.txt
	cmake -B BUILD/PLAYGROUND $@ -S . \
	      -G Ninja \
	      -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
	      -DCMAKE_BUILD_TYPE=DEBUG \
	      #-DCMAKE_FIND_DEBUG_MODE=ON
	ln -sfn BUILD/PLAYGROUND/compile_commands.json
	#ninja -C $@ -t compdb > compile_commands.json

# -- SYSTEMC -------------------------------------------------------------------

INSTALL/lib/libsystemc.a: BUILD/SYSC/CMakeCache.txt
	ninja -C BUILD/SYSC install $(NINJA_FLAGS)

BUILD/SYSC/CMakeCache.txt: systemc
	cmake -B BUILD/SYSC -S systemc \
	      -G Ninja \
	      -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
	      -DCMAKE_BUILD_TYPE=DEBUG \
	      -DCMAKE_INSTALL_PREFIX=$(PWD)/INSTALL \
	      -DBUILD_SHARED_LIBS=OFF \
	      -DCMAKE_CXX_STANDARD=14

systemc:
	git clone --depth=1 https://github.com/accellera-official/systemc.git

# -- UTIL ----------------------------------------------------------------------

fmt:
	clang-format -i $(shell find src test -type f -name \*.h -or -name \*.cc)

# -- CLEAN ---------------------------------------------------------------------

clean:
	$(RM) -r BUILD/PLAYGROUND compile_commands.json

distclean: clean
	$(RM) -r BUILD INSTALL systemc