Permalink
Newer
Older
100644 135 lines (109 sloc) 3.86 KB
Dec 17, 2015 @nno BIG: initial commit
1 .PHONY: help \
2 install-matlab install-octave install \
3 uninstall-matlab uninstall-octave uninstall \
4 test-matlab test-octave test
5
6 MATLAB?=matlab
7 OCTAVE?=octave
8
9 TESTDIR=$(CURDIR)/tests
10 ROOTDIR=$(CURDIR)/MOcov
11
Dec 17, 2015 @nno BIG: major refactoring
12 ADDPATH=orig_dir=pwd();cd('$(ROOTDIR)');addpath(pwd);cd(orig_dir)
Dec 17, 2015 @nno BIG: initial commit
13 RMPATH=rmpath('$(ROOTDIR)');
14 SAVEPATH=savepath();exit(0)
15
16 INSTALL=$(ADDPATH);$(SAVEPATH)
17 UNINSTALL=$(RMPATH);$(SAVEPATH)
18
19 help:
20 @echo "Usage: make <target>, where <target> is one of:"
21 @echo "------------------------------------------------------------------"
22 @echo " install to add MOcov to the Matlab and GNU Octave"
23 @echo " search paths, using whichever is present"
24 @echo " uninstall to remove MOcov from the Matlab and GNU"
25 @echo " Octave search paths, using whichever is"
26 @echo " present"
Dec 17, 2015 @nno BIG: major refactoring
27 @echo " test to run tests using the Matlab and GNU Octave"
Dec 17, 2015 @nno BIG: initial commit
28 @echo " search paths, whichever is present"
29 @echo ""
30 @echo " install-matlab to add MOcov to the Matlab search path"
31 @echo " install-octave to add MOcov to the GNU Octave search path"
32 @echo " uninstall-matlab to remove MOcov from the Matlab search path"
33 @echo " uninstall-octave to remove MOcov from the GNU Octave search"
34 @echo " path"
Dec 17, 2015 @nno BIG: major refactoring
35 @echo " test-matlab to run tests using Matlab [1]"
36 @echo " test-octave to run tests using GNU Octave [1]"
37 @echo ""
38 @echo "[1] requires MOxUnit: https://github.com/MOxUnit/MOxUnit
Dec 17, 2015 @nno BIG: initial commit
39 @echo "------------------------------------------------------------------"
40 @echo ""
Dec 17, 2015 @nno BIG: major refactoring
41 @echo "Environmental variables for storing test results:"
42 @echo " JUNIT_XML_FILE JUnit-like XML output with test result"
Dec 17, 2015 @nno BIG: initial commit
43 @echo ""
44
Dec 17, 2015 @nno BIG: major refactoring
45 RUNTESTS_ARGS='${TESTDIR}'
46 ifdef JUNIT_XML_FILE
47 RUNTESTS_ARGS +=,'-junit_xml_file','$(JUNIT_XML_FILE)'
48 export JUNIT_XML_FILE
Dec 17, 2015 @nno BIG: initial commit
49 endif
Dec 17, 2015 @nno BIG: major refactoring
50
Dec 17, 2015 @nno BIG: initial commit
51
Dec 17, 2015 @nno BIG: major refactoring
52 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);
Dec 17, 2015 @nno BIG: initial commit
53
54 MATLAB_BIN=$(shell which $(MATLAB))
55 OCTAVE_BIN=$(shell which $(OCTAVE))
56
57 ifeq ($(MATLAB_BIN),)
58 # for Apple OSX, try to locate Matlab elsewhere if not found
59 MATLAB_BIN=$(shell ls /Applications/MATLAB_R20*/bin/${MATLAB} 2>/dev/null | tail -1)
60 endif
61
62 MATLAB_RUN=$(MATLAB_BIN) -nojvm -nodisplay -nosplash -r
63 OCTAVE_RUN=$(OCTAVE_BIN) --no-gui --quiet --eval
64
65 install-matlab:
66 @if [ -n "$(MATLAB_BIN)" ]; then \
67 $(MATLAB_RUN) "$(INSTALL)"; \
68 else \
69 echo "matlab binary could not be found, skipping"; \
70 fi;
71
72 install-octave:
73 @if [ -n "$(OCTAVE_BIN)" ]; then \
74 $(OCTAVE_RUN) "$(INSTALL)"; \
75 else \
76 echo "octave binary could not be found, skipping"; \
77 fi;
78
79 install:
80 @if [ -z "$(MATLAB_BIN)$(OCTAVE_BIN)" ]; then \
81 @echo "Neither matlab binary nor octave binary could be found" \
82 exit 1; \
83 fi;
84 $(MAKE) install-matlab
85 $(MAKE) install-octave
86
87
88 uninstall-matlab:
89 @if [ -n "$(MATLAB_BIN)" ]; then \
90 $(MATLAB_RUN) "$(UNINSTALL)"; \
91 else \
92 echo "matlab binary could not be found, skipping"; \
93 fi;
94
95 uninstall-octave:
96 @if [ -n "$(OCTAVE_BIN)" ]; then \
97 $(OCTAVE_RUN) "$(UNINSTALL)"; \
98 else \
99 echo "octave binary could not be found, skipping"; \
100 fi;
101
102 uninstall:
103 @if [ -z "$(MATLAB_BIN)$(OCTAVE_BIN)" ]; then \
104 @echo "Neither matlab binary nor octave binary could be found" \
105 exit 1; \
106 fi;
107 $(MAKE) uninstall-matlab
108 $(MAKE) uninstall-octave
109
110
Dec 17, 2015 @nno BIG: major refactoring
111 test-matlab:
Dec 17, 2015 @nno BIG: initial commit
112 @if [ -n "$(MATLAB_BIN)" ]; then \
Dec 17, 2015 @nno BIG: major refactoring
113 $(MATLAB_RUN) "$(TEST)"; \
Dec 17, 2015 @nno BIG: initial commit
114 else \
115 echo "matlab binary could not be found, skipping"; \
116 fi;
117
Dec 17, 2015 @nno BIG: major refactoring
118 test-octave:
Dec 17, 2015 @nno BIG: initial commit
119 if [ -n "$(OCTAVE_BIN)" ]; then \
Dec 17, 2015 @nno BIG: major refactoring
120 $(OCTAVE_RUN) "$(TEST)"; \
Dec 17, 2015 @nno BIG: initial commit
121 else \
122 echo "octave binary could not be found, skipping"; \
123 fi;
124
Dec 17, 2015 @nno BIG: major refactoring
125 test:
Dec 17, 2015 @nno BIG: initial commit
126 @if [ -z "$(MATLAB_BIN)$(OCTAVE_BIN)" ]; then \
127 @echo "Neither matlab binary nor octave binary could be found" \
128 exit 1; \
129 fi;
Dec 17, 2015 @nno BIG: major refactoring
130 $(MAKE) test-matlab
131 $(MAKE) test-octave
Dec 17, 2015 @nno BIG: initial commit
132
133
134