-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
358 lines (290 loc) · 8.41 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
GIT := git
CURL := curl
ZIP := zip
UNZIP := unzip
JQ := jq
ifdef CROSS_COMPILE
MACHINE := $(CROSS_COMPILE)
else
MACHINE ?= $(shell $(CC) -dumpmachine)
endif
ifneq (,$(findstring x86_64-,$(MACHINE)))
ARCH_X64 := 1
ARCH_CPU := x64
else ifneq (,$(findstring arm64-,$(MACHINE)))
ARCH_ARM64 := 1
ARCH_CPU := arm64
else ifneq (,$(findstring aarch64-,$(MACHINE)))
ARCH_ARM64 := 1
ARCH_CPU := arm64
else
$(error Could not determine CPU architecture of $(MACHINE))
endif
ifneq (,$(findstring -darwin,$(MACHINE)))
ARCH_MAC := 1
ARCH_OS := mac
else ifneq (,$(findstring -mingw32,$(MACHINE)))
ARCH_WIN := 1
ARCH_OS := win
else ifneq (,$(findstring -linux,$(MACHINE)))
ARCH_LIN := 1
ARCH_OS := lin
else
$(error Could not determine operating system of $(MACHINE))
endif
ARCH_NAME := $(ARCH_OS)-$(ARCH_CPU)
# Fetch submodules
submodules:
$(shell $(GIT) submodule update --init --recursive)
# Fetch vcpkg
./dep/vcpkg: submodules
# Bootstrap vcpkg
./dep/vcpkg/bootstrap-vcpkg.sh: ./dep/vcpkg
# Use vcpkg
./dep/vcpkg/vcpkg: ./dep/vcpkg/bootstrap-vcpkg.sh
VCPKG_ROOT ?= ./dep/vcpkg
VCPKG := $(VCPKG_ROOT)/vcpkg
# Rack-SDK
RACK_SDK_VERSION_MAJOR := 2
RACK_SDK_VERSION_MINOR ?= 5
RACK_SDK_VERSION_BUILD ?= 2
RACK_SDK_VERSION ?= $(RACK_SDK_VERSION_MAJOR).$(RACK_SDK_VERSION_MINOR).$(RACK_SDK_VERSION_BUILD)
RACK_SDK_PLATFORM ?= $(ARCH_OS)-$(ARCH_CPU)
RACK_SDK_FILENAME := Rack-SDK-$(RACK_SDK_VERSION)-$(RACK_SDK_PLATFORM).zip
RACK_SDK_URL := https://vcvrack.com/downloads/$(RACK_SDK_FILENAME)
./dep/$(RACK_SDK_FILENAME):
$(shell $(CURL) $(RACK_SDK_URL) -o $@)
./dep/Rack-SDK: ./dep/$(RACK_SDK_FILENAME)
$(shell $(UNZIP) -q ./dep/$(RACK_SDK_FILENAME) -d ./dep)
# Target: 'make sdk'
sdk: ./dep/Rack-SDK
# If RACK_DIR is not defined when calling the Makefile, default to two
# directories above, i.e., `Rack-SDK/plugins/<we are here>`
RACK_DIR ?= ./dep/Rack-SDK
# StoneyVCV
STONEYVCV_VERSION_MAJOR ?= 2
STONEYVCV_VERSION_MINOR ?= 0
STONEYVCV_VERSION_PATCH ?= $(strip $(shell $(GIT) rev-list HEAD | wc -l))
STONEYVCV_VERSION_TWEAK ?= $(strip $(shell $(GIT) rev-parse HEAD))
STONEYVCV_VERSION_BUILD ?= $(strip $(shell $(GIT) rev-parse --short HEAD))
STONEYVCV_VERSION ?= $(STONEYVCV_VERSION_MAJOR).$(STONEYVCV_VERSION_MINOR).$(STONEYVCV_VERSION_PATCH).$(STONEYVCV_VERSION_TWEAK)
version-major:
@echo $(STONEYVCV_VERSION_MAJOR)
version-minor:
@echo $(STONEYVCV_VERSION_MINOR)
version-patch:
@echo $(STONEYVCV_VERSION_PATCH)
version-tweak:
@echo $(STONEYVCV_VERSION_TWEAK)
version-build:
@echo $(STONEYVCV_VERSION_BUILD)
version:
@echo $(STONEYVCV_VERSION)
version-package:
@echo $(STONEYVCV_VERSION_MAJOR).$(STONEYVCV_VERSION_MINOR).$(STONEYVCV_VERSION_PATCH)-r$(STONEYVCV_VERSION_BUILD)
version-all: version-major version-minor version-patch version-tweak
@echo $(STONEYVCV_VERSION)
@echo $(STONEYVCV_VERSION_MAJOR).$(STONEYVCV_VERSION_MINOR).$(STONEYVCV_VERSION_PATCH)-r$(STONEYVCV_VERSION_BUILD)
FLAGS += -DSTONEYVCV_VERSION_MAJOR=$(STONEYVCV_VERSION_MAJOR)
FLAGS += -DSTONEYVCV_VERSION_MINOR=$(STONEYVCV_VERSION_MINOR)
FLAGS += -DSTONEYVCV_VERSION_PATCH=$(STONEYVCV_VERSION_PATCH)
FLAGS += -DSTONEYVCV_VERSION_TWEAK=$(STONEYVCV_VERSION_TWEAK)
# Experimental?
STONEYVCV_EXPERIMENTAL ?= 0
# Component Library?
STONEYVCV_BUILD_COMPONENTLIBRARY ?= 1
# Build plugin?
STONEYVCV_BUILD_PLUGIN ?= 1
# Build modules?
STONEYVCV_BUILD_MODULES ?= $(STONEYVCV_BUILD_PLUGIN)
STONEYVCV_BUILD_HP4 ?= $(STONEYVCV_BUILD_MODULES)
STONEYVCV_BUILD_HP2 ?= $(STONEYVCV_BUILD_MODULES)
STONEYVCV_BUILD_HP1 ?= $(STONEYVCV_BUILD_MODULES)
STONEYVCV_BUILD_VCA ?= $(STONEYVCV_BUILD_MODULES)
STONEYVCV_BUILD_LFO ?= $(STONEYVCV_EXPERIMENTAL)
# ifneq ($(STONEYVCV_BUILD_COMPONENTLIBRARY),$(STONEYVCV_BUILD_PLUGIN))
# $(error STONEYVCV_BUILD_PLUGIN requires that STONEYVCV_BUILD_COMPONENTLIBRARY=1)
# endif
SOURCES += src/StoneyVCV.cpp
ifeq ($(STONEYVCV_BUILD_COMPONENTLIBRARY),1)
FLAGS += -DSTONEYVCV_BUILD_COMPONENTLIBRARY=$(STONEYVCV_BUILD_COMPONENTLIBRARY)
SOURCES += src/StoneyVCV/ComponentLibrary.cpp
SOURCES += src/StoneyVCV/ComponentLibrary/Widget.cpp
SOURCES += src/StoneyVCV/ComponentLibrary/PortWidget.cpp
SOURCES += src/StoneyVCV/ComponentLibrary/PanelWidget.cpp
endif
ifeq ($(STONEYVCV_BUILD_PLUGIN),1)
FLAGS += -DSTONEYVCV_BUILD_PLUGIN=$(STONEYVCV_BUILD_PLUGIN)
SOURCES += src/StoneyVCV/plugin.cpp
ifeq ($(STONEYVCV_BUILD_MODULES),1)
FLAGS += -DSTONEYVCV_BUILD_MODULES=$(STONEYVCV_BUILD_MODULES)
ifeq ($(STONEYVCV_BUILD_HP4),1)
FLAGS += -DSTONEYVCV_BUILD_HP4=$(STONEYVCV_BUILD_HP4)
SOURCES += src/StoneyVCV/HP4.cpp
endif
ifeq ($(STONEYVCV_BUILD_HP2),1)
FLAGS += -DSTONEYVCV_BUILD_HP2=$(STONEYVCV_BUILD_HP2)
SOURCES += src/StoneyVCV/HP2.cpp
endif
ifeq ($(STONEYVCV_BUILD_HP1),1)
FLAGS += -DSTONEYVCV_BUILD_HP1=$(STONEYVCV_BUILD_HP1)
SOURCES += src/StoneyVCV/HP1.cpp
endif
ifeq ($(STONEYVCV_BUILD_VCA),1)
FLAGS += -DSTONEYVCV_BUILD_VCA=$(STONEYVCV_BUILD_VCA)
SOURCES += src/StoneyVCV/VCA.cpp
endif
ifeq ($(STONEYVCV_BUILD_LFO),1)
FLAGS += -DSTONEYVCV_BUILD_LFO=$(STONEYVCV_BUILD_LFO)
SOURCES += src/StoneyVCV/LFO.cpp
endif
endif
endif
# Build tests?
STONEYVCV_BUILD_TESTS ?= 0
ifeq ($(STONEYVCV_BUILD_TESTS),1)
FLAGS += -DSTONEYVCV_BUILD_TESTS=$(STONEYVCV_BUILD_TESTS)
endif
ifdef ARCH_X64
TRIPLET_ARCH := x64
PRESET_ARCH := x64
endif
ifdef ARCH_ARM64
TRIPLET_ARCH := arm64
PRESET_ARCH := arm64
endif
# Include deps
ifdef ARCH_WIN
TRIPLET_OS := mingw-dynamic
PRESET_OS := windows
endif
ifdef ARCH_LIN
TRIPLET_OS := linux
PRESET_OS := linux
endif
ifdef ARCH_MAC
TRIPLET_OS := osx
PRESET_OS := osx
endif
ifdef BUILD_TYPE
PRESET_CONFIG := $(BUILD_TYPE)
else
ifdef DEBUG
PRESET_CONFIG := debug
else
PRESET_CONFIG := release
endif
endif
# The macro NDEBUG controls whether assert() statements are active or not.
ifdef DEBUG
# FLAGS += -Wall
# FLAGS += -Wextra
# FLAGS += -DDEBUG
FLAGS += -D_DEBUG
else
FLAGS += -DNDEBUG
endif
ifdef VERBOSE
PRESET_VERBOSE := -verbose
endif
EXTERNAL_DEPS :=
EXTERNAL_DEPS += StoneyDSP
EXTERNAL_DEPS += Rack-SDK
# EXTERNAL_DEPS += catch2
PKG_CONFIG_PATH := $(PWD)/build/vcpkg_installed/$(TRIPLET_ARCH)-$(TRIPLET_OS)/lib/pkgconfig:$(PKG_CONFIG_PATH)
FLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags $(EXTERNAL_DEPS))
LDFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs $(EXTERNAL_DEPS))
# FLAGS will be passed to both the C and C++ compiler
FLAGS += -I$(PWD)/build/include
CFLAGS +=
CXXFLAGS +=
# Careful about linking to shared libraries, since you can't assume much about
# the user's environment and library search path.
# Static libraries are fine, but they should be added to this plugin's build
# system.
LDFLAGS +=
# Add .cpp files to the build
# SOURCES += $(wildcard src/StoneyVCV/*.cpp)
# Add files to the ZIP package when running `make dist`
# The compiled plugin and "plugin.json" are automatically added.
# DISTRIBUTABLES += include
DISTRIBUTABLES += res
DISTRIBUTABLES += LICENSE
DISTRIBUTABLES += VERSION
DISTRIBUTABLES += README.md
DISTRIBUTABLES += $(wildcard presets)
PRESET ?= $(PRESET_ARCH)-$(PRESET_OS)-$(PRESET_CONFIG)$(PRESET_VERBOSE)
reconfigure: sdk submodules
VCPKG_ROOT=$(VCPKG_ROOT) cmake \
--preset $(PRESET) \
--fresh
configure: sdk submodules
VCPKG_ROOT=$(VCPKG_ROOT) cmake \
--preset $(PRESET)
build: configure
cmake \
--build $(PWD)/build \
--preset $(PRESET)
test: build
ctest \
--test-dir $(PWD)/build \
--preset $(PRESET)
package: test
cmake \
--build $(PWD)/build \
--target $@
package_source: test
cmake \
--build $(PWD)/build \
--target $@
workflow: $(VCPKG_ROOT)/vcpkg
VCPKG_ROOT=$(VCPKG_ROOT) cmake \
--workflow \
--preset $(PRESET) \
--fresh
source: configure
cmake \
--install $(PWD)/build \
--prefix $(PWD)/dist \
--component $@
# package: test
# cmake \
# --install $(PWD)/build \
# --prefix $(PWD)/install
# Include the docs target
./build/docs/html: configure
cd docs
doxygen ./docs/Doxyfile
cd $(PWD)
docs: $(PWD)/build/docs/html
# These are "main" Makefile targets which most Rack plugin devs expect
dep: reconfigure
$(RACK_DIR)/plugin.mk: sdk
# Include the Rack plugin Makefile framework
include $(RACK_DIR)/plugin.mk
# all: dep
# $(MAKE) -f $(RACK_DIR)/plugin.mk $@ -E RACK_DIR=$(RACK_DIR)
# clean:
# $(MAKE) -f $(RACK_DIR)/plugin.mk $@ -E RACK_DIR=$(RACK_DIR)
# $(MAKE) -f ./dep/Makefile $@
.PHONY:
submodules
sdk
verion-major
version-minor
version-patch
version-tweak
version-build
version-package
version-all
version
reconfigure
configure
build
test
package
package_source
workflow
source
docs
dep