-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
134 lines (109 loc) · 3.86 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
.PHONY: help \
install-matlab install-octave install \
uninstall-matlab uninstall-octave uninstall \
test-matlab test-octave test
MATLAB?=matlab
OCTAVE?=octave
TESTDIR=$(CURDIR)/tests
ROOTDIR=$(CURDIR)/MOcov
ADDPATH=orig_dir=pwd();cd('$(ROOTDIR)');addpath(pwd);cd(orig_dir)
RMPATH=rmpath('$(ROOTDIR)');
SAVEPATH=savepath();exit(0)
INSTALL=$(ADDPATH);$(SAVEPATH)
UNINSTALL=$(RMPATH);$(SAVEPATH)
help:
@echo "Usage: make <target>, where <target> is one of:"
@echo "------------------------------------------------------------------"
@echo " install to add MOcov to the Matlab and GNU Octave"
@echo " search paths, using whichever is present"
@echo " uninstall to remove MOcov from the Matlab and GNU"
@echo " Octave search paths, using whichever is"
@echo " present"
@echo " test to run tests using the Matlab and GNU Octave"
@echo " search paths, whichever is present"
@echo ""
@echo " install-matlab to add MOcov to the Matlab search path"
@echo " install-octave to add MOcov to the GNU Octave search path"
@echo " uninstall-matlab to remove MOcov from the Matlab search path"
@echo " uninstall-octave to remove MOcov from the GNU Octave search"
@echo " path"
@echo " test-matlab to run tests using Matlab [1]"
@echo " test-octave to run tests using GNU Octave [1]"
@echo ""
@echo "[1] requires MOxUnit: https://github.com/MOxUnit/MOxUnit
@echo "------------------------------------------------------------------"
@echo ""
@echo "Environmental variables for storing test results:"
@echo " JUNIT_XML_FILE JUnit-like XML output with test result"
@echo ""
RUNTESTS_ARGS='${TESTDIR}'
ifdef JUNIT_XML_FILE
RUNTESTS_ARGS +=,'-junit_xml_file','$(JUNIT_XML_FILE)'
export JUNIT_XML_FILE
endif
TEST=$(ADDPATH);if(isempty(which('moxunit_runtests'))),error('MOxUnit is required; see https://github.com/MOxUnit/MOxUnit');end;success=moxunit_runtests($(RUNTESTS_ARGS));exit(~success);
MATLAB_BIN=$(shell which $(MATLAB))
OCTAVE_BIN=$(shell which $(OCTAVE))
ifeq ($(MATLAB_BIN),)
# for Apple OSX, try to locate Matlab elsewhere if not found
MATLAB_BIN=$(shell ls /Applications/MATLAB_R20*/bin/${MATLAB} 2>/dev/null | tail -1)
endif
MATLAB_RUN=$(MATLAB_BIN) -nojvm -nodisplay -nosplash -r
OCTAVE_RUN=$(OCTAVE_BIN) --no-gui --quiet --eval
install-matlab:
@if [ -n "$(MATLAB_BIN)" ]; then \
$(MATLAB_RUN) "$(INSTALL)"; \
else \
echo "matlab binary could not be found, skipping"; \
fi;
install-octave:
@if [ -n "$(OCTAVE_BIN)" ]; then \
$(OCTAVE_RUN) "$(INSTALL)"; \
else \
echo "octave binary could not be found, skipping"; \
fi;
install:
@if [ -z "$(MATLAB_BIN)$(OCTAVE_BIN)" ]; then \
@echo "Neither matlab binary nor octave binary could be found" \
exit 1; \
fi;
$(MAKE) install-matlab
$(MAKE) install-octave
uninstall-matlab:
@if [ -n "$(MATLAB_BIN)" ]; then \
$(MATLAB_RUN) "$(UNINSTALL)"; \
else \
echo "matlab binary could not be found, skipping"; \
fi;
uninstall-octave:
@if [ -n "$(OCTAVE_BIN)" ]; then \
$(OCTAVE_RUN) "$(UNINSTALL)"; \
else \
echo "octave binary could not be found, skipping"; \
fi;
uninstall:
@if [ -z "$(MATLAB_BIN)$(OCTAVE_BIN)" ]; then \
@echo "Neither matlab binary nor octave binary could be found" \
exit 1; \
fi;
$(MAKE) uninstall-matlab
$(MAKE) uninstall-octave
test-matlab:
@if [ -n "$(MATLAB_BIN)" ]; then \
$(MATLAB_RUN) "$(TEST)"; \
else \
echo "matlab binary could not be found, skipping"; \
fi;
test-octave:
if [ -n "$(OCTAVE_BIN)" ]; then \
$(OCTAVE_RUN) "$(TEST)"; \
else \
echo "octave binary could not be found, skipping"; \
fi;
test:
@if [ -z "$(MATLAB_BIN)$(OCTAVE_BIN)" ]; then \
@echo "Neither matlab binary nor octave binary could be found" \
exit 1; \
fi;
$(MAKE) test-matlab
$(MAKE) test-octave