Makefile 1.16 KB
Newer Older
Anders Blomdell's avatar
Anders Blomdell committed
1
2
CTEST = test_start_stop test_io test_moberg4simulink
PYTEST=test_py
Anders Blomdell's avatar
Anders Blomdell committed
3
JULIATEST=test_jl
Anders Blomdell's avatar
Anders Blomdell committed
4
5
CCFLAGS += -Wall -Werror -I$(shell pwd) -g
LDFLAGS += -L$(shell pwd)/build/ -lmoberg
Anders Blomdell's avatar
Anders Blomdell committed
6
7
8
9
ENV_TEST = LD_LIBRARY_PATH=../build \
           XDG_CONFIG_HOME=.config \
           XDG_CONFIG_DIRS=. \
	   JULIA_LOAD_PATH=../adaptors/julia
Anders Blomdell's avatar
Anders Blomdell committed
10
11
LDFLAGS_test_moberg4simulink = -lmoberg4simulink
CCFLAGS_test_moberg4simulink = -I../adaptors/matlab -Wall -Werror -I$(shell pwd) -g
Anders Blomdell's avatar
Anders Blomdell committed
12
13
PYTHON2PATH=$(shell realpath ../adaptors/python/install/usr/lib*/python2*/site-packages)
PYTHON3PATH=$(shell realpath ../adaptors/python/install/usr/lib*/python3*/site-packages)
Anders Blomdell's avatar
Anders Blomdell committed
14
all:
Anders Blomdell's avatar
Anders Blomdell committed
15
16

.PHONY: test
Anders Blomdell's avatar
Anders Blomdell committed
17
test: $(PYTEST:%=run_py_%) $(JULIATEST:%=run_jl_%) $(CTEST:%=run_c_%) 
Anders Blomdell's avatar
Anders Blomdell committed
18
19
	echo Tests run

Anders Blomdell's avatar
Anders Blomdell committed
20
21
.PHONY: run_c_%
run_c_%:build/%
Anders Blomdell's avatar
Anders Blomdell committed
22
	$(ENV_TEST) valgrind --leak-check=full ./build/$*
Anders Blomdell's avatar
Anders Blomdell committed
23

Anders Blomdell's avatar
Anders Blomdell committed
24
25
26
27
28
.PHONY: run_py_%
run_py_%: %.py
	$(ENV_TEST) PYTHONPATH=$(PYTHON2PATH) python2 $*.py
	$(ENV_TEST) PYTHONPATH=$(PYTHON3PATH) python3 $*.py

Anders Blomdell's avatar
Anders Blomdell committed
29
30
31
32
.PHONY: run_jl_%
run_jl_%: %.jl
	$(ENV_TEST) julia $*.jl

Anders Blomdell's avatar
Anders Blomdell committed
33
.PRECIOUS: build/%
Anders Blomdell's avatar
Anders Blomdell committed
34

Anders Blomdell's avatar
Anders Blomdell committed
35
build/%: %.c | build
Anders Blomdell's avatar
Anders Blomdell committed
36
	$(CC) $(CCFLAGS) $(CCFLAGS_$*) $(LDFLAGS) $(LDFLAGS_$*) -o $@ $<
Anders Blomdell's avatar
Anders Blomdell committed
37
38
39
40
41
42

build:
	mkdir build

clean:
	rm -f vgcore.* *~
43
	rm -rf build