-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
370 lines (302 loc) · 12.7 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
## GNU/BSD makefile for the Humdrum Toolkit.
##
## Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu>
## Creation Date: Mon Jun 2 18:42:00 PDT 2014
## Last Modified: Mon Jun 2 19:02:24 PDT 2014
## Filename: ...humdrum/Makefile
##
## Description: This Makefile will compile C programs in the toolkit-source
## directory, then copy all other humdrum programs and help files
## into the humdrum/bin directory. To compile the C programs, you must
## first have gcc installed on your computer. Windows users
## should install in the cygwin unix terminal (available from
## http://www.cygwin.com) in which to use the Humdrum Toolkit.
##
## To run this makefile, type (without quotes) "make bin". After successful
## compiling, you must add the bin directory to your command search path.
## This can be done automatically with the command "make install" if you
## are doing a single-user installation.
##
.PHONY: all awk shell help clean cprogs install bin regression support data
BINDIR = bin
# Variables used to give hints about setup for $PATH environmental variable:
HUMDRUM_PATH := $(shell echo $$PATH | tr : '\n' | grep 'humdrum/bin' | head -n 1)
HUMDRUM_TARGET := $(shell echo `pwd`/bin)
# Variables needed for remove-data target:
VALUE1 = $(shell if [ -r .gitmodules ]; then grep -A2 -n -m1 '^\[submodule "data"\]' .gitmodules | sed 's/[^0-9].*//'; fi)
VALUE2 = $(shell if [ ! -z $(VALUE1) ]; then echo "$(VALUE1)+2" | bc; fi)
# Variables needed for remove-webdoc target:
VALUE3 = $(shell if [ -r .gitmodules ]; then grep -A2 -n -m1 '^\[submodule "webdoc"\]' .gitmodules | sed 's/[^0-9].*//'; fi)
VALUE4 = $(shell if [ ! -z $(VALUE3) ]; then echo "$(VALUE3)+2" | bc; fi)
###########################################################################
##
## Default target which lists main targets that the makefile can run.
##
all:
@echo
@echo "Available make targets:"
@echo "[0;32mmake[0m -- Print this list."
@echo "[0;32mmake bin[0m -- Create the bin directory from toolkit-source files."
@echo "[0;32mmake checkpath[0m -- Check that the PATH variable is correctly configured;"
@echo " otherwise, run [0;32mmake install[0m to add bin directory"
@echo " to PATH in ~/.profile."
@echo "[0;32mmake install[0m -- Add bin directoy in command path (for single-user"
@echo " installations)."
@echo "[0;32mmake regression[0m -- Check Humdrum Tookit programs for configuration errors."
@echo "[0;32mmake data[0m -- Download humdrum-data repository (into 'data' subdirectory)."
@echo "[0;32mmake webdoc[0m -- Download Humdrum documentation website repository"
@echo " (into 'webdoc' subdirectory)."
@echo "[0;32mmake clean[0m -- Delete automatic content (bin, data, webdoc)."
@echo
###########################################################################
##
## Compile C programs and construct the humdrum/bin directory.
##
bin: awk shell help cprogs support
@echo "[0;32m"
@echo "*** Type '[0;31mmake checkpath[0;32m' to have the computer examine"
@echo "*** the PATH enviroment variable and make sugguestions about the"
@echo "*** next step in installation of the Humdrum Toolkit."
@echo "[0m"
###########################################################################
##
## Remove all automatically generated content.
##
clean: remove-data remove-webdoc
rm -rf $(BINDIR)
###########################################################################
##
## Targets that add content to bin directory
##
cprogs:
ifeq (($shell which gcc),)
@echo "[0;31m"
@echo "*** Error: you must first install gcc. If you are using OS X Mavericks"
@echo "*** or later, then install with the command:"
@echo "*** [0;32mxcode-select --install[0;31m"
@echo "*** If you are using a flavor of linux, then try either of these commands:"
@echo "*** [0;32myum install gcc[0;31m"
@echo "*** [0;32mapt-get install gcc[0;31m"
@echo "[0m"
exit 1
endif
-(cd toolkit-source/c-programs; $(ENV) $(MAKE))
awk:
mkdir -p $(BINDIR)
cp toolkit-source/awk-programs/* $(BINDIR)/
shell:
mkdir -p $(BINDIR)
cp toolkit-source/shell-scripts/* $(BINDIR)/
help:
mkdir -p $(BINDIR)/helpscrn
-cp toolkit-source/helpscrn/* $(BINDIR)/helpscrn/
support:
mkdir -p $(BINDIR)
-cp toolkit-source/support-files/* $(BINDIR)
@chmod 0755 $(BINDIR)/ekern1.sed
###########################################################################
##
## Targets that install man pages.
##
man:
if [ -d /usr/share/man/man1 ]; \
then \
cp toolkit-source/man/man1/*.1* /usr/share/man/man1; \
fi
###########################################################################
##
## Targets for adding/removing data repository
##
data: checkgit
git submodule add -f https://github.com/humdrum-tools/humdrum-data data
git submodule update --init --recursive
remove-data: checkgit
ifneq ($(VALUE2),)
-git submodule deinit -f data
-git rm --cached data
-rm -rf data
-rm -rf .git/modules/data
cat .gitmodules | sed '$(VALUE1),$(VALUE2)d' > .gitmodules-temp
-mv .gitmodules-temp .gitmodules
endif
-if [ -r .gitmodules ]; \
then \
if [ `wc -l .gitmodules | sed 's/^ *//; s/ .*//'` == "0" ]; \
then \
rm .gitmodules; \
fi; \
fi
###########################################################################
##
## Targets for adding/removing Humdrum website documentation
##
webdoc: checkgit
git submodule add -f https://github.com/humdrum-tools/humdrum-tools.github.io webdoc
git submodule update --init --recursive
remove-webdoc: checkgit
ifneq ($(VALUE4),)
-git submodule deinit -f webdoc
-git rm --cached webdoc
-rm -rf webdoc
-rm -rf .git/modules/webdoc
cat .gitmodules | sed '$(VALUE3),$(VALUE4)d' > .gitmodules-temp
-mv .gitmodules-temp .gitmodules
endif
-if [ -r .gitmodules ]; \
then \
if [ `wc -l .gitmodules | sed 's/^ *//; s/ .*//'` == "0" ]; \
then \
rm .gitmodules; \
fi; \
fi
###########################################################################
##
## Update repository and any submodules to their respective master versions:
##
pull: update
update: checkgit
git pull
ifneq ($(wildcard .gitmodules),)
git submodule update --init --recursive
git submodule foreach "(git checkout master; git pull origin master)"
endif
###########################################################################
##
## Run regression tests. Run each regression test and repor the results
## for each test.
##
regressions: regression
regression-tests: regression
tests: regression
test: regression
regression:
(cd toolkit-source/regression-tests; $(MAKE) -s verbose)
## "make regression-quiet" will test install programs to see if they
## are working as expected, reporting only problem tests.
regression-quiet:
(cd toolkit-source/regression-tests; $(MAKE) -s)
###########################################################################
##
## Installing target for setting up $PATH environmental variable.
##
## "make install" Will add the current humdrum/bin directory to the
## .profile file in the user's home directory. If the super user
## is installing the Humdrum Toolkit, then they should instead manually
## add the installation bin directory into the /etc/profile file.
install:
ifeq (,$(HUMDRUM_PATH))
echo "export PATH=`pwd`/bin:\$$PATH" >> ~/.profile
source ~/.profile
@echo "[0;32m"
@echo "*** `pwd`/bin added to command search path"
@echo "*** in ~/.profile. Now either close this shell and restart"
@echo "*** another, or type the command:"
@echo "*** [0;31msource ~/.profile[0;32m"
@echo "*** to update the \$$PATH environmental variable in the current"
@echo "*** shell. Then type:"
@echo "*** [0;31mwhich census[0;32m"
@echo "*** to verify that the Humdrum Tools are accessible."
@echo "*** The computer should reply to the above command with this string:"
@echo "*** [0;31m`pwd`/bin/census[0;32m"
@echo "*** If so, then the Humdrum Toolkit is installed and ready to use!"
@echo "*** You can also run regression tests to check command behaviors:"
@echo "*** [0;31mmake regression[0;32m"
@echo "*** And you can download sample Humdrum scores into the 'data' subdirectory:"
@echo "*** [0;31mmake data[0;32m"
@echo "[0m"
else ifneq ($(HUMDRUM_PATH),$(HUMDRUM_TARGET))
echo "export PATH=`pwd`/bin:\$$PATH" >> ~/.profile
source ~/.profile
@echo "[0;31m"
@echo "*** `pwd`/bin added to command search path"
@echo "*** in ~/.profile. A different humdrum/bin directory already"
@echo "*** exists in the command search path. This installation will"
@echo "*** shadow the one in:"
@echo "*** [0;32m$(HUMDRUM_PATH)[0;31m"
@echo "*** Now either close this shell and restart another, or type the command:"
@echo "*** [0;32msource ~/.profile[0;31m"
@echo "*** to update the \$$PATH environmental variable in the current shell."
@echo "*** Then type:"
@echo "*** [0;32mwhich census[0;31m"
@echo "*** to verify that the Humdrum Tools are accessible."
@echo "*** The computer should reply to the above command with this string:"
@echo "*** [0;32m`pwd`/bin/census[0;31m"
@echo "*** If so, then the Humdrum Toolkit is installed and ready to use!"
@echo "*** You can also run regression tests to check command behaviors:"
@echo "*** [0;32mmake regression[0;31m"
@echo "*** And you can download sample Humdrum scores into the 'data' subdirectory:"
@echo "*** [0;32mmake data[0;31m"
@echo "[0m"
else
@echo "[0;32m"
@echo "*** The humdrum/bin directory is registered in the PATH environment variable."
@echo "*** Test that the Humdrum Toolkit programs are available by typing the command:"
@echo "*** [0;31mwhich census[0;32m"
@echo "*** The computer should reply to the above command with this string:"
@echo "*** [0;31m`pwd`/bin/census[0;32m"
@echo "*** If so, then the Humdrum Toolkit is installed and ready to use!"
@echo "*** You can also run regression tests to check command behaviors:"
@echo "*** [0;31mmake regression[0;32m"
@echo "*** And you can download sample Humdrum scores into the 'data' subdirectory:"
@echo "*** [0;31mmake data[0;32m"
@echo "[0m"
endif
###########################################################################
##
## See of the command path is found in $PATH.
##
checkpath:
ifeq (,$(HUMDRUM_PATH))
@echo "[0;31m"
@echo "*** For a single-user installation, this is typically is done with the command:"
@echo "*** [0;32mecho \"PATH=\$$PATH:`pwd`/humdrum/bin\" >> ~/.profile"
@echo "*** or type 'make install' to have this Makefile do this for you."
@echo "*** System-wide installation by a super-user should be done by adding the"
@echo "*** above command to >> /etc/profile instead of >> ~/.profile."
@echo "[0m"
else ifneq ($(HUMDRUM_PATH),$(HUMDRUM_TARGET))
@echo "[0;31m"
@echo "*** A different humdrum/bin directory already exists in the command search";
@echo "*** path. This installation will be shadowed by the one in:";
@echo "*** [0;32m$(HUMDRUM_PATH)[0;31m"
@echo "*** Either move this installation to that location or remove the other"
@echo "*** installation from the command search path (typically by editing the"
@echo "*** PATH variable in ~/.profile or in /etc/profile)."
@echo "***"
@echo "*** Typing '[0;32mmake install[0;31m' for a single-user installation will hide the"
@echo "*** other installation in $(HUMDRUM_PATH) and use"
@echo "*** this one instead."
@echo "[0m"
else
@echo "[0;32m"
@echo "*** The humdrum command path is configured properly in the PATH environment"
@echo "*** variable. Type '[0;31mwhich mint[0;32m' to verify that you can see a program in the"
@echo "*** humdrum/bin directory. If the terminal replies with:"
@echo "*** [0;31m$(HUMDRUM_PATH)/mint[0;32m"
@echo "*** then the Humdrum Toolkit is set up properly and ready to use."
@echo "*** You can also run regression tests to check command behaviors:"
@echo "*** [0;31mmake regression[0;32m"
@echo "*** And you can download sample Humdrum scores into the 'data' subdirectory:"
@echo "*** [0;31mmake data[0;32m"
@echo "[0m"
endif
###########################################################################
##
## When doing certain targets, git is presumed to be installed, and
## is presumed to be the method of downloading the repository.
##
checkgit:
ifeq ($(shell which git),)
@echo "[0;31m"
@echo "*** Error: to use the update target, you must have git command installed"
@echo "[0m"
exit 1
endif
ifeq ($(wildcard .git),)
@echo "[0;31m"
@echo "*** Error: to use the update target, you must have installed"
@echo "*** the Humdrum Toolkit with git:"
@echo "*** [0;32mgit clone https://github.com/humdrum-tools/humdrum[0;31m"
@echo "[0m"
exit 1
endif