aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 795540f6eb8feaa0c0ad8998819221e6f0996604 (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
export CC  = clang
export CXX = clang++

export SYSTEMC_HOME := $(PWD)/INSTALL

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

SRCS = $(shell find src test -type f -name \*.h -or -name \*.cc)
BINS = $(SRCS:src/%.cc=BUILD/pg-%)

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

build: config
	ninja -C BUILD $(NINJA_FLAGS)

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

run/%: config
	ninja -C BUILD $(NINJA_FLAGS) pg-$*
	BUILD/pg-$*

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

config: BUILD/CMakeCache.txt cmake/CMakeLists-sysc-external.txt cmake/CMakeLists-sysc-fetch.txt
BUILD/CMakeCache.txt: CMakeLists.txt
	# SystemC options:
	#   BUILD_SHARED_LIBS
	cmake -B BUILD -S . \
	      -G Ninja \
	      -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
	      -DCMAKE_BUILD_TYPE=DEBUG \
	      -DCMAKE_CXX_STANDARD=14 \
	      -DBUILD_SHARED_LIBS=OFF \
	      #-DCMAKE_FIND_DEBUG_MODE=ON
	ln -sfn BUILD/compile_commands.json

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

targets:
	ninja -C BUILD -t targets

fmt:
	clang-format -i $(SRCS)

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

clean:
	ninja -C BUILD clean

distclean:
	$(RM) -r BUILD compile_commands.json