-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
288 lines (228 loc) · 10.5 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
#!/usr/bin/make -f
# include dpf base makefile definitions
include dpf/Makefile.base.mk
# include version details
include VERSION.mk
VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_MICRO)
# default build target
all: master_me
# ---------------------------------------------------------------------------------------------------------------------
# clean target, removes any build artifacts
clean:
rm -rf bin build
rm -rf dpf/build
rm -f dpf-widgets/opengl/*.d
rm -f dpf-widgets/opengl/*.o
# ---------------------------------------------------------------------------------------------------------------------
# faustpp target, building it ourselves if not available from the system
ifeq ($(shell command -v faustpp 1>/dev/null && echo true),true)
FAUSTPP_TARGET =
FAUSTPP_EXEC = faustpp
else
FAUSTPP_TARGET = build/faustpp/faustpp$(APP_EXT)
FAUSTPP_EXEC = $(CURDIR)/$(FAUSTPP_TARGET)
endif
faustpp:
# never rebuild faustpp
ifneq ($(FAUSTPP_TARGET),)
ifeq ($(wildcard $(FAUSTPP_TARGET)),)
faustpp: $(FAUSTPP_TARGET)
.PHONY: faustpp
endif
endif
# ---------------------------------------------------------------------------------------------------------------------
# bench target, for testing
BENCH_CMD = ./bench/faustbench -notrace -best $(CURDIR)/master_me.dsp
BENCH_FLAGS = $(BUILD_CXX_FLAGS)
BENCH_FLAGS += -Wno-overloaded-virtual -Wno-unused-function -Wno-unused-parameter
BENCH_FLAGS += -I$(shell faust --includedir) -Ibench -Ibench/master_me -DBEST_TESTS
BENCH_FLAGS += -flto
BENCH_FLAGS += $(LINK_FLAGS)
BENCH_TARGETS = all normal prefetch tree-vec unroll prefetch+tree prefetch+unroll tree+unroll
bench: $(BENCH_TARGETS:%=bench/master_me/bench.%$(APP_EXT))
bench/master_me/bench.all$(APP_EXT): bench/master_me/faustbench.cpp
$(CXX) $(BENCH_FLAGS) -fomit-frame-pointer -fprefetch-loop-arrays -ftree-vectorize -funroll-loops $< -o $@
bench/master_me/bench.normal$(APP_EXT): bench/master_me/faustbench.cpp
$(CXX) $(BENCH_FLAGS) $< -o $@
bench/master_me/bench.prefetch$(APP_EXT): bench/master_me/faustbench.cpp
$(CXX) $(BENCH_FLAGS) -fprefetch-loop-arrays $< -o $@
bench/master_me/bench.tree-vec$(APP_EXT): bench/master_me/faustbench.cpp
$(CXX) $(BENCH_FLAGS) -ftree-vectorize $< -o $@
bench/master_me/bench.unroll$(APP_EXT): bench/master_me/faustbench.cpp
$(CXX) $(BENCH_FLAGS) -funroll-loops $< -o $@
bench/master_me/bench.prefetch+trees$(APP_EXT): bench/master_me/faustbench.cpp
$(CXX) $(BENCH_FLAGS) -fprefetch-loop-arrays -ftree-vectorize $< -o $@
bench/master_me/bench.prefetch+unroll$(APP_EXT): bench/master_me/faustbench.cpp
$(CXX) $(BENCH_FLAGS) -fprefetch-loop-arrays -funroll-loops $< -o $@
bench/master_me/bench.tree+unrolls$(APP_EXT): bench/master_me/faustbench.cpp
$(CXX) $(BENCH_FLAGS) -ftree-vectorize -funroll-loops $< -o $@
bench/master_me/faustbench.cpp:
$(BENCH_CMD) -source
.PHONY: bench
# ---------------------------------------------------------------------------------------------------------------------
# dgl target, building the dpf little graphics library
DPF_EXTRA_ARGS = DGL_NAMESPACE=MasterMeDGL
DPF_EXTRA_ARGS += NVG_FONT_TEXTURE_FLAGS=NVG_IMAGE_NEAREST
DPF_EXTRA_ARGS += SKIP_NATIVE_AUDIO_FALLBACK=true
dgl:
ifeq ($(HAVE_OPENGL),true)
$(MAKE) -C dpf/dgl opengl $(DPF_EXTRA_ARGS)
endif
# ---------------------------------------------------------------------------------------------------------------------
# list of plugin source code files to generate, converted from faust dsp files
PLUGIN_TEMPLATE_FILES = $(subst template/,,$(wildcard template/*.*))
PLUGIN_GENERATED_FILES = $(foreach f,$(PLUGIN_TEMPLATE_FILES),pregen/$(f))
PLUGIN_GENERATED_FILES += bin/master_me.lv2/manifest.ttl
PLUGIN_GENERATED_FILES += bin/master_me.lv2/plugin.ttl
PLUGIN_GENERATED_FILES += bin/master_me.lv2/ui.ttl
PLUGIN_GENERATED_FILES += bin/master_me-easy-presets.lv2/manifest.ttl
PLUGIN_GENERATED_FILES += bin/master_me-easy-presets.lv2/presets.ttl
PLUGIN_GENERATED_FILES += build/BuildInfo1.hpp
PLUGIN_GENERATED_FILES += build/BuildInfo2.hpp
PLUGIN_GENERATED_FILES += build/Logo.hpp
gen: $(PLUGIN_GENERATED_FILES)
# ---------------------------------------------------------------------------------------------------------------------
# master_me target, for actual building the plugin after its source code has been generated
master_me: $(PLUGIN_GENERATED_FILES) dgl
$(MAKE) -C plugin
static:
$(MAKE) -C plugin static
# ---------------------------------------------------------------------------------------------------------------------
# install target, does what you think it does
PREFIX ?= /usr/local
DESTDIR ?=
install: master_me
install -d $(DESTDIR)$(PREFIX)/bin
install -d $(DESTDIR)$(PREFIX)/lib/clap
install -d $(DESTDIR)$(PREFIX)/lib/ladspa
install -d $(DESTDIR)$(PREFIX)/lib/lv2/master_me.lv2
install -d $(DESTDIR)$(PREFIX)/lib/lv2/master_me-easy-presets.lv2
install -d $(DESTDIR)$(PREFIX)/lib/vst
install -d $(DESTDIR)$(PREFIX)/lib/vst3/master_me.vst3/$(VST3_BINARY_DIR)
install -m 755 bin/master_me $(DESTDIR)$(PREFIX)/bin/
install -m 644 bin/master_me.clap $(DESTDIR)$(PREFIX)/lib/clap/
install -m 644 bin/master_me-ladspa.* $(DESTDIR)$(PREFIX)/lib/ladspa/
install -m 644 bin/master_me.lv2/* $(DESTDIR)$(PREFIX)/lib/lv2/master_me.lv2/
install -m 644 bin/master_me-easy-presets.lv2/* $(DESTDIR)$(PREFIX)/lib/lv2/master_me-easy-presets.lv2/
install -m 644 bin/master_me-vst.* $(DESTDIR)$(PREFIX)/lib/vst/
install -m 644 bin/master_me.vst3/$(VST3_BINARY_DIR)/* $(DESTDIR)$(PREFIX)/lib/vst3/master_me.vst3/$(VST3_BINARY_DIR)
# ---------------------------------------------------------------------------------------------------------------------
# rules for faust dsp to plugin code conversion
FAUSTPP_ARGS = \
-Dbinary_name="master_me" \
-Dbrand="Klaus Scheuermann" \
-Dhomepage="https://4ohm.de/" \
-Dlabel="master_me" \
-Dlicense="GPLv3+" \
-Dlicenseurl="http://spdx.org/licenses/GPL-3.0-or-later.html" \
-Dlibext=\@libext\@ \
-Duitype=\@uitype\@ \
-Dlv2uri="https://github.com/trummerschlunk/master_me" \
-Dversion_major=$(VERSION_MAJOR) \
-Dversion_minor=$(VERSION_MINOR) \
-Dversion_micro=$(VERSION_MICRO)
# -X-scal
# -X-fm -Xfastmath.cpp
FAUSTPP_OPTS = -X-vec -X-lv -X1 -X-vs -X8
pregen:
mkdir -p build/master_me
$(FAUSTPP_EXEC) $(FAUSTPP_ARGS) $(FAUSTPP_OPTS) -a template/DistrhoPluginInfo.h master_me.dsp -o pregen/DistrhoPluginInfo.h
$(FAUSTPP_EXEC) $(FAUSTPP_ARGS) $(FAUSTPP_OPTS) -a template/Plugin.cpp master_me.dsp -o pregen/Plugin.cpp
$(FAUSTPP_EXEC) $(FAUSTPP_ARGS) -a template/LV2/manifest.ttl master_me.dsp -o pregen/master_me.lv2/manifest.ttl
$(FAUSTPP_EXEC) $(FAUSTPP_ARGS) -a template/LV2/plugin.ttl master_me.dsp -o pregen/master_me.lv2/plugin.ttl
$(FAUSTPP_EXEC) $(FAUSTPP_ARGS) -a template/LV2/ui.ttl master_me.dsp -o pregen/master_me.lv2/ui.ttl
.PHONY: pregen
# ---------------------------------------------------------------------------------------------------------------------
# rules for static LV2 data
ifeq ($(MACOS),true)
UITYPE = Cocoa
else ifeq ($(WINDOWS),true)
UITYPE = Windows
else
UITYPE = X11
endif
bin/master_me.lv2/%: pregen/master_me.lv2/%
mkdir -p bin/master_me.lv2
sed -e "s/@libext@/$(LIB_EXT)/g" -e "s/@uitype@/$(UITYPE)/g" $< > $@
bin/master_me-easy-presets.lv2/%: plugin/master_me-easy-presets.lv2/%
mkdir -p bin/master_me-easy-presets.lv2
cp $< $@
# ---------------------------------------------------------------------------------------------------------------------
# rules for intermediate plugin code generation
ifeq ($(shell echo -e escaped-by-default | grep -- '-e escaped-by-default'),-e escaped-by-default)
NEWLINE = '\\\\$(nothing)n'
else
NEWLINE = '\\$(nothing)n'
endif
# only generated once
build/BuildInfo1.hpp:
mkdir -p build
echo 'constexpr const char kBuildInfoString1[] = ""' > $@
echo '"A plugin by Klaus Scheuermann, made with Faust and DPF$(NEWLINE)"' >> $@
echo '"DSP: Klaus Scheuermann, magnetophon, x42, jkbd$(NEWLINE)"' >> $@
echo '"GUI, Plugin: falkTX$(NEWLINE)"' >> $@
echo '"Supported by the Prototype Fund / German Federal Ministry of Education and Research"' >> $@
echo ';' >> $@
# regenerated on every possible change
build/BuildInfo2.hpp: master_me.dsp plugin/* template/* template/LV2/* VERSION.mk
mkdir -p build
echo 'constexpr const char kBuildInfoString2[] = ""' > $@
ifneq ($(wildcard .git/HEAD),)
echo '"Built using `$(shell git branch --show-current | tr -d "'")` branch with commit:$(NEWLINE)$(shell git log -n 1 --decorate=no --pretty=oneline --abbrev-commit | tr -d "'")"' >> $@
else
echo '"v$(VERSION)"' >> $@
endif
echo ';' >> $@
# convert logo into raw data for C++ code
build/Logo.hpp: img/logo/master_me_white.png img/logo/master_me_white@2x.png
mkdir -p build
./dpf/utils/res2c.py Logo img/logo/ build/
# ---------------------------------------------------------------------------------------------------------------------
# tarball target, generating release source-code tarballs ready for packaging
TAR_ARGS = \
--exclude=".appveyor*" \
--exclude=".ci*" \
--exclude=".clang*" \
--exclude=".drone*" \
--exclude=".editor*" \
--exclude=".git*" \
--exclude="*.kdev*" \
--exclude=".travis*" \
--exclude=".vscode*" \
--exclude="*.d" \
--exclude="*.o" \
--exclude=bin \
--exclude=build \
--exclude=dpf/build \
--exclude=dpf/cmake \
--exclude=dpf/examples \
--exclude=dpf/lac \
--exclude=dpf/tests \
--exclude=dpf-widgets/generic \
--exclude=dpf-widgets/opengl/Blendish* \
--exclude=dpf-widgets/opengl/DearImGuiColorTextEditor* \
--exclude=dpf-widgets/tests \
--transform='s,^\.\.,-.-.,' \
--transform='s,^\.,master_me-$(VERSION),' \
--transform='s,^-\.-\.,..,' \
tarball:
rm -f ../master_me-$(VERSION).tar.xz
tar -c --lzma $(TAR_ARGS) -f ../master_me-$(VERSION).tar.xz .
# ---------------------------------------------------------------------------------------------------------------------
# rules for custom faustpp build
CMAKE_ARGS = -G 'Unix Makefiles'
ifeq ($(DEBUG),true)
CMAKE_ARGS += -DCMAKE_BUILD_TYPE=Debug
else
CMAKE_ARGS += -DCMAKE_BUILD_TYPE=Release
endif
ifeq ($(WINDOWS),true)
CMAKE_ARGS += -DCMAKE_SYSTEM_NAME=Windows
endif
faustpp/CMakeLists.txt:
git clone --recursive https://github.com/falkTX/faustpp.git --depth=1 -b use-internal=boost
build/faustpp/Makefile: faustpp/CMakeLists.txt
cmake -Bbuild/faustpp -Sfaustpp -DFAUSTPP_USE_INTERNAL_BOOST=ON $(CMAKE_ARGS)
build/faustpp/faustpp$(APP_EXT): build/faustpp/Makefile
$(MAKE) -C build/faustpp
# ---------------------------------------------------------------------------------------------------------------------