-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile.programs
400 lines (325 loc) · 15.6 KB
/
Makefile.programs
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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
## Humdrum extras programs makefile for linux on Intel computers.
##
## Programmer: Craig Stuart Sapp <[email protected]>
## Creation Date: Sun Apr 3 15:34:28 PDT 2005
## Last Modified: Sat Jan 27 09:47:06 PM PST 2024
## Filename: ...humextra/Makefile.programs
##
## Description: This Makefile creates the Humdrum Extras library
## lib/libhumextra.a for linux, using gcc 2.7.2.1 or higher
## Also, gives basic guidelines of how to compile for Windows
## using MinGW.
##
## To run this makefile, type (without quotes) "make -f Makefile.programs"
## (or "gmake -f Makefile.programs" on FreeBSD computers), although it
## is intended to be used the file "Makefile" which runs this makefile
## with the command "make programs". Note that you have to first
## create the library file with the makefile "Makefile.library".
##
## Without arguments, this makefile will compile all programs.
## If you give a program name as an argument, it will compile
## just that program. E.g.: "make -f Makefile.programs blank" or used
## in conjunction with "Makefile", type "make blank", which will
## compile the "blank" program and place it in the ./bin directory.
##
###########################################################################
# #
# Operating System OSTYPEs available in the humextra library #
# compilation: but probably not used in humextra: #
# #
# HPUX = Hewlett-Packard Unix Workstations. #
# IRIX = SGI computers with IRIX OS. #
# LINUX = Linux running on intel computers #
# NEXTI = NeXT OS on Intel Hardware #
# NEXTM = NeXT OS on Motorola Hardware #
# SUN = Sun SPARCstations #
# VISUAL = Windows 95/NT using Microsoft Visual C++ 6.0 #
# OSXPC = Apple Macintosh OS 10.x, Intel CPU #
# #
# Look at the sigConfiguration.h file for various things which need #
# to be defined specifically for each OS. Only one of these defines #
# can be defined at a time. #
# #
###########################################################################
#
# You can set the OSTYPE variable by uncommenting one of the lines below;
# otherwise, it will be set automatically in the next section of the
# Makefile if the configuration should be OSXPC or LINUX. For example,
#OSTYPE = LINUX
#OSTYPE = OSXPC
ARCH =
# Set the environmental variable $MACOSX_DEPLOYMENT_TARGET to
# "10.4" in Apple OS X to compile for OS X 10.4 and later (for example,
# you can compile for OS X 10.4 computers even if you are using a 10.6
# computer).
ENV =
# if OSTYPE is not defined, then this if statement will be run:
ifeq ($(origin OSTYPE), undefined)
ifeq ($(shell uname),Darwin)
OSTYPE = OSXPC
# Use the following to compile for a particular version of OS X:
# ENV = MACOSX_DEPLOYMENT_TARGET=10.6
# Use the following to compile for 32-bit architecture on 64-bit comps:
#ARCH = -m32 -arch i386
else
OSTYPE = LINUX
# use the following to compile for 32-bit architecture on 64-bit comps:
# (you will need 32-bit libraries in order to do this)
# ARCH = -m32
endif
endif
# Next if statement needed for some versions of make which already set OSTYPE:
ifeq ($(OSTYPE),linux)
OSTYPE = LINUX
# use the following to compile for 32-bit architecture on 64-bit comps:
# (you will need 32-bit libraries in order to do this)
# ARCH = -m32
endif
# Cygwin (and MinGW?) adds the string ".exe" to the end of compiled programs.
# so select EXTEN = .exe when compiling in cygwin
EXTEN =
ifeq ($(shell uname),CYGWIN_NT-5.1)
EXTEN = .exe
endif
###########################################################################
# #
# The OSSUBTYPE is for determining which type of sound drivers are being #
# used in linux. This variable is only needed when compiling interactive #
# MIDI programs. Most humextra programs do not need this variable. #
# There are three possibilities: #
# #
# OSSUBTYPE = ALSA : ALSA 1.0 interface (http://www.alsa-project.org)#
# OSSUBTYPE = OSS : OSS interface (http://www.4front-tech.com) #
# OSSUBTYPE = : use this for OS X since there is only CoreMIDI #
# #
# Two additional options are available for older systems: #
# OSSUBTYPE = ALSA09 : ALSA 0.9 interface (http://www.alsa-project.org)#
# OSSUBTYPE = ALSA05 : ALSA 0.5 interface (http://www.alsa-project.org)#
# #
# Note: The Improv library accesses the internal/external MIDI devices #
# in OSS, but only the external MIDI devices in ALSA. OSS can be #
# emulated in ALSA 0.9 and higher, but seems to be broken in ALSA 1.0. #
# #
# Choose one of the following OSSUBTYPE defines: #
# #
#OSSUBTYPE = ALSA
#OSSUBTYPE = OSS
#OSSUBTYPE =
# If OSSUBTYPE is not set manually above, then automatically determine
# what the value should be (only works for LINUX and OSXPC).
ifeq ($(origin OSSUBTYPE), undefined)
ifeq ($(OSTYPE),OSXPC)
OSSUBTYPE =
endif
ifeq ($(OSTYPE),LINUX)
ifneq ($(wildcard /proc/asound/version),)
OSSUBTYPE = ALSA
else
OSSUBTYPE = OSS
endif
endif
endif
###########################################################################
# #
# Beginning of user-modifiable configuration variables #
# #
SRCDIR = cli
INCDIR = include
OBJDIR = obj
LIBDIR = lib
LIBFILE = humextra
TARGDIR = bin
# LANG=C: Nuts to the GCC error beautification committee.
COMPILER = LANG=C $(ENV) g++ $(ARCH)
# MinGW compiling setup (used to compile for Microsoft Windows but actual
# compiling can be done in Linux). You have to install MinGW and these
# variables will probably have to be changed to the correct paths:
#COMPILER = /opt/xmingw/bin/i386-mingw32msvc-g++
#OBJDIR = obj-win
#TARGDIR = bin-win
#LIBDIR = lib-win
#POSTFLAGS = -Wl,--export-all-symbols -Wl,--enable-auto-import \
# -Wl,--no-whole-archive -lmingw32 -L$(LIBDIR) -l$(LIBFILE)
DEFINES = $(addprefix -D,$(OSTYPE))
DEFINES += $(addprefix -D,$(OSSUBTYPE))
PREFLAGS = -O3 -Wall -I$(INCDIR) $(DEFINES)
# SigCollection class uses C++11 standard
PREFLAGS += -std=c++14
# Add -static flag to compile without dynamics libraries for better portability:
# (-static flag doesn't work well with gethostbyname() used in Humdrum parser)
#PREFLAGS += -static
POSTFLAGS ?= -L$(LIBDIR) -l$(LIBFILE)
###########################################################################
##
## Linking to external libraries:
## There are four external libraries which are used to compile the
## humextra programs:
## (1) PCRE (http://www.pcre.org)
## This is used for working with regular expressions. May be
## fased out when GCC version 5+ is ubiquitous on linux computers.
## GCC 5+ implments C++11 standard which includes regular expressions
## for C++ (however, they are based on JavaScript regular expressions
## rather than PERL, so we will see).
## (2) CenterpointXML by Guenter Obiltschnig
## Now orphaned C++ library for parsing XML file. Will be updated
## to pugixml (http://www.pugixml.org) in the future.
## (3) midifile (http://midifile.sapp.org)
## Used to parse or create Standard MIDI Files.
## (4) improv (http://improv.sapp.org)
## Used for cross-platform real-time MIDI playback.
##
# The following setup is for PERL-Compatible Regular Expression library
# linking (for themax2 in particular, but also in many other humextra
# programs as well). Therefore it is used when linking all programs.
ifneq ($(wildcard external/pcre-8.35),)
PREFLAGS += -Iexternal/pcre-8.35
POSTFLAGS += -lpcre
PCRE := yes
endif
# The following setup is for compiling XML parsing code
# which uses the CenterPoint XML classes:
ifneq ($(wildcard external/centerpoint),)
XML_PREFLAGS = -Iexternal/centerpoint/include
XML_POSTFLAGS = -lcslxml
XML := yes
endif
# The following setup is for MIDI files parsing:
ifneq ($(wildcard external/midifile),)
MIDIFILE_PREFLAGS = -Iexternal/midifile/include
MIDIFILE_POSTFLAGS = -Lexternal/midifile/lib -lmidifile
MIDIFILE := yes
endif
# For compiling programs with interactive MIDI (such as humplay), you
# first need to compile the improv library which can be downloaded
# from http://improv.sapp.org (Makefile.library tries to do this).
ifneq ($(wildcard external/improv/lib/libimprov.a),)
IMPROV_PREFLAGS = -Iexternal/improv/include
IMPROV_POSTFLAGS = -Lexternal/improv/lib -limprov
IMPROV_PREFLAGS += -Iexternal/midifile/include
IMPROV_POSTFLAGS += -Lexternal/midifile/lib -l midifile
IMPROV := yes
# Thread library needed for MIDI input programs in Linux:
# Probably also need in OS X?
ifeq ($(OSTYPE),LINUX)
IMPROV_POSTFLAGS += -L/usr/lib -lpthread
endif
endif
###################################
#
# Interactive MIDI program compiling setup
#
# extra setup for compiling interactive MIDI programs:
ifneq ($(origin IMPROV),undefined)
# On Apple OS X computers, include MIDI related libraries:
ifeq ($(OSTYPE),OSXPC)
IMPROV_POSTFLAGS += -framework CoreMIDI -framework CoreServices
IMPROV_POSTFLAGS += -framework AudioUnit -framework AudioToolbox
endif
# On Linux computers, include MIDI related libraries:
ifeq ($(OSTYPE),LINUX)
# include pthread library for MIDI input parsing:
# Add the ALSA library interface, if using ALSA:
ifeq ($(OSSUBTYPE),ALSA)
IMPROV_PREFLAGS += -I/usr/include/alsa
IMPROV_POSTFLAGS += -lasound
endif
endif
endif
# #
# End of user-modifiable variables. #
# #
###########################################################################
# setting up the directory paths to search for program source code
vpath %.cpp $(SRCDIR)
# generating a list of the programs to compile with "make all"
PROGS1=$(notdir $(patsubst %.cpp,%,$(wildcard $(SRCDIR)/*.cpp)))
PROGS=$(PROGS1)
# Prepare a list of scripts to link into bin directory.
SCRIPTS_PERL=$(wildcard scripts/perl/*)
SCRIPTS=$(SCRIPTS_PERL)
# Targets which don't actually refer to files
.PHONY : bin scripts cli src-library include obj bin-win obj-win
###########################################################################
# #
# #
examples: all
# The clear target is needed to force recompiling all cli programs (otherwise
# they are not recompiled with depedency updates correctly).
clear:
@echo "Clearing previously compiled programs:"
-rm -f $(addprefix $(TARGDIR)/,$(PROGS))
all: clear bin scripts $(addprefix $(TARGDIR)/,$(PROGS))
@echo "Finished compiling all programs."
info:
@echo "Programs to compile: $(PROGS)" | fmt
bin:
-mkdir -p $(TARGDIR)
# link all scripts into the bin directory
scripts:
-for i in $(SCRIPTS); do ln -s ../$$i bin/`basename $$i`; done
###########################################################################
##
## Certain programs require different external libraries, so give the
## required external library dependencies by program here. All programs
## are preseumed to require PCRE, so that is added to the default
## PREFLAGS and POSTFLAGS variable
##
xml2hum: PREFLAGS += $(XML_PREFLAGS)
xml2hum: POSTFLAGS += $(XML_POSTFLAGS)
$(TARGDIR)/xml2hum: PREFLAGS += $(XML_PREFLAGS)
$(TARGDIR)/xml2hum: POSTFLAGS += $(XML_POSTFLAGS)
hum2mid: PREFLAGS += $(MIDIFILE_PREFLAGS)
hum2mid: POSTFLAGS += $(MIDIFILE_POSTFLAGS)
$(TARGDIR)/hum2mid: PREFLAGS += $(MIDIFILE_PREFLAGS)
$(TARGDIR)/hum2mid: POSTFLAGS += $(MIDIFILE_POSTFLAGS)
mid2hum: PREFLAGS += $(MIDIFILE_PREFLAGS)
mid2hum: POSTFLAGS += $(MIDIFILE_POSTFLAGS)
$(TARGDIR)/mid2hum: PREFLAGS += $(MIDIFILE_PREFLAGS)
$(TARGDIR)/mid2hum: POSTFLAGS += $(MIDIFILE_POSTFLAGS)
mkeyscape: PREFLAGS += $(MIDIFILE_PREFLAGS)
mkeyscape: POSTFLAGS += $(MIDIFILE_POSTFLAGS)
$(TARGDIR)/mkeyscape: PREFLAGS += $(MIDIFILE_PREFLAGS)
$(TARGDIR)/mkeyscape: POSTFLAGS += $(MIDIFILE_POSTFLAGS)
humplay: PREFLAGS += $(IMPROV_PREFLAGS) $(ALSA_PREFLAGS)
humplay: POSTFLAGS += $(IMPROV_POSTFLAGS) $(ALSA_POSTFLAGS)
$(TARGDIR)/humplay: PREFLAGS += $(IMPROV_PREFLAGS) $(ALSA_PREFLAGS)
$(TARGDIR)/humplay: POSTFLAGS += $(IMPROV_POSTFLAGS) $(ALSA_POSTFLAGS)
###########################################################################
#
# Defining explicit rules for program sourcefile dependencies:
#
% : $(notdir %.cpp)
@if [[ "$@" == "humplay" ]]; then \
if [[ -e "external/improv/lib/libimprov.a" ]]; then \
mkdir -p $(TARGDIR); \
echo "[CC] $@"; \
$(COMPILER) $(PREFLAGS) -o $(TARGDIR)/$@ $< $(POSTFLAGS) \
&& strip $(TARGDIR)/$@$(EXTEN); \
else \
echo "Skipping compilation of $@"; \
fi \
else \
mkdir -p $(TARGDIR); \
echo "[CC] $@"; \
$(COMPILER) $(PREFLAGS) -o $(TARGDIR)/$@ $< $(POSTFLAGS) \
&& strip $(TARGDIR)/$@$(EXTEN); \
fi
$(TARGDIR)/% : $(notdir %.cpp)
@if [[ "$@" == "$(TARGDIR)/humplay" ]]; then \
if [[ -e "external/improv/lib/libimprov.a" ]]; then \
mkdir -p $(TARGDIR); \
echo "[CC] $@"; \
$(COMPILER) $(PREFLAGS) -o $@ $< $(POSTFLAGS) \
&& strip $@$(EXTEN); \
else \
echo "Skipping compilation of $@"; \
fi \
else \
mkdir -p $(TARGDIR); \
echo "[CC] $@"; \
$(COMPILER) $(PREFLAGS) -o $@ $< $(POSTFLAGS) \
&& strip $@$(EXTEN); \
fi
# #
# #
###########################################################################