-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
206 lines (164 loc) · 6.33 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
BUILDROOT ?= .
ifndef CONFIG
ifdef TEST
CONFIG=Debug
else
CONFIG=Release
endif
endif
ifndef PLATFORM
PLATFORM=OWL2
endif
DEPS = .FORCE
TARGET ?= patch
ifdef FAUST
# options for FAUST compilation
PATCHNAME ?= $(FAUST)
PATCHCLASS ?= FaustPatch
PATCHFILE ?= FaustPatch.hpp
DEPS += faust
else ifdef HEAVY
# options for Heavy PD compilation
PATCHNAME ?= $(HEAVY)
PATCHCLASS ?= HeavyPatch
PATCHFILE ?= HeavyPatch.hpp
DEPS += heavy
else ifdef GEN
# options for Max/MSP Gen compilation
PATCHNAME ?= $(GEN)
PATCHCLASS ?= GenPatch
PATCHFILE ?= GenPatch.hpp
DEPS += gen
else ifdef MAXIMILIAN
# options for Maximilian compilation
PATCHNAME ?= $(MAXIMILIAN)
PATCHCLASS ?= MaximilianPatch
PATCHFILE ?= MaximilianPatch.hpp
DEPS += maximilian
else ifdef SOUL
# options for SOUL patch compilation
PATCHNAME ?= $(SOUL)
PATCHCLASS ?= SoulPatch
PATCHFILE ?= SoulPatch.hpp
SOULCLASS ?= $(SOUL)
ifneq ("$(wildcard $(PATCHSOURCE)/$(SOUL).soulpatch)","")
SOULFILE ?= $(SOUL).soulpatch
else
SOULFILE ?= $(SOUL).soul
endif
SOULHPP ?= $(SOUL).hpp
DEPS += soul
else ifdef TEST
PATCHNAME = $(TEST)
PATCHCLASS = $(PATCHNAME)Patch
PATCHFILE = $(PATCHNAME)Patch.hpp
else
# options for C++ compilation
PATCHNAME ?= "Template"
PATCHCLASS ?= $(PATCHNAME)Patch
PATCHFILE ?= $(PATCHNAME)Patch.hpp
endif
PATCHIN ?= 2
PATCHOUT ?= 2
SLOT ?= 0
OWLDEVICE ?= OWL-*
BUILD ?= $(BUILDROOT)/Build
PATCHSOURCE ?= $(BUILDROOT)/PatchSource
FIRMWARESENDER ?= Tools/FirmwareSender
# set up tests
TEST_FILES = $(notdir $(wildcard $(BUILDROOT)/TestPatches/*TestPatch.hpp))
TESTS = $(filter-out ShortFastFourierTest, $(TEST_FILES:%Patch.hpp=%))
export BUILD BUILDROOT TARGET
export PATCHNAME PATCHCLASS PATCHSOURCE
export PATCHFILE PATCHIN PATCHOUT
export HEAVYTOKEN HEAVYSERVICETOKEN HEAVY
export SOUL SOULCLASS SOULFILE SOULHPP
export CONFIG PLATFORM
DEPS += $(BUILD)/registerpatch.cpp $(BUILD)/registerpatch.h $(BUILD)/Source/startup.s
all: libs patch web
.PHONY: .FORCE patch libs faust gen heavy soul maximilian web minify map as native test run check tables resource size clean realclean sysex load store docs help
.FORCE:
@mkdir -p $(BUILD)/Source
@mkdir -p $(BUILD)/web
@mkdir -p $(BUILD)/Test
$(BUILD)/registerpatch.cpp: .FORCE
@echo "REGISTER_PATCH($(PATCHCLASS), \"$(PATCHNAME)\", $(PATCHIN), $(PATCHOUT));" > $@
$(BUILD)/registerpatch.h: .FORCE
@echo Building patch $(PATCHNAME)
@echo "#include \"$(PATCHFILE)\"" > $@
$(BUILD)/Source/startup.s: .FORCE
@echo '.string "'$(PATCHNAME)'"' > $(BUILD)/Source/progname.s
$(BUILD)/%.syx: $(BUILD)/%.bin
@$(FIRMWARESENDER) -q -in $< -save $@
patch: $(DEPS) ## build patch binary
@$(MAKE) -s -f compile.mk compile
libs: .FORCE ## build patch libraries
@$(MAKE) -s -f compile.mk libs
@$(MAKE) -s -f web.mk libs
web: $(DEPS) ## build Javascript patch
@$(MAKE) -s -f web.mk web
@echo Built javascript $(PATCHNAME) in $(BUILD)/web/$(TARGET).js
minify: $(DEPS)
@$(MAKE) -s -f web.mk minify
faust: .FORCE
@$(MAKE) -s -f faust.mk faust
heavy: .FORCE
@$(MAKE) -s -f heavy.mk heavy
gen: .FORCE
@$(MAKE) -s -f gen.mk gen
maximilian: .FORCE
@$(MAKE) -s -f maximilian.mk maximilian
soul: .FORCE
@$(MAKE) -s -f soul.mk soul
sysex: patch $(BUILD)/$(TARGET).syx ## package patch binary as MIDI sysex
@echo Built sysex $(PATCHNAME) in $(BUILD)/$(TARGET).syx
load: patch ## upload patch to attached OWL via MIDI
@echo Sending patch $(PATCHNAME) to $(OWLDEVICE) to load
@$(FIRMWARESENDER) -q -in $(BUILD)/$(TARGET).bin -out "$(OWLDEVICE)" -run
store: patch ## upload and save patch to attached OWL
@echo Sending patch $(PATCHNAME) to $(OWLDEVICE) to store in slot $(SLOT)
@$(FIRMWARESENDER) -q -in $(BUILD)/$(TARGET).bin -out "$(OWLDEVICE)" -store $(SLOT)
resource: $(RESOURCE) ## upload and save resource to attached OWL
@echo Sending resource $(RESOURCE) to $(OWLDEVICE) to store in slot $(SLOT)
@$(FIRMWARESENDER) -q -in $(RESOURCE) -out "$(OWLDEVICE)" -store $(SLOT)
docs: ## generate HTML documentation
@doxygen Doxyfile
tables: ## compile tools and generate lookup tables
@$(MAKE) -s -f tables.mk tables
clean: ## remove generated patch files
@rm -rf $(BUILD)/*
realclean: clean ## remove all library object files
@find Libraries/ -name '*.[a|o]' -delete
size: patch ## show binary size metrics and large object summary
@$(MAKE) -s -f compile.mk size
map: patch ## build map file (Build/patch.map)
@$(MAKE) -s -f compile.mk map
@echo Built $(PATCHNAME) map in $(BUILD)/$(TARGET).map
as: patch ## build assembly file (Build/patch.s)
@$(MAKE) -s -f compile.mk as
@echo Built $(PATCHNAME) assembly in $(BUILD)/$(TARGET).s
native: $(DEPS) ## build native executable of patch
@$(MAKE) -s -f native.mk native
test: $(DEPS) ## test patch natively
@$(MAKE) -s -f native.mk test
run: $(DEPS) ## run patch natively
@$(MAKE) -s -f native.mk run
grind: $(DEPS) ## run valgrind on patch natively
@$(MAKE) -s -f native.mk grind
tests: ## run all unit tests
@for nm in $(TESTS) ; do \
$(MAKE) -s TEST=$$nm test || exit;\
done
check: tests ## run test patches and unit tests
@unset PATCHNAME PATCHCLASS PATCHFILE && $(MAKE) PATCHSOURCE=TestPatches/CppTest PATCHNAME=CppTest clean patch web run
@unset PATCHNAME PATCHCLASS PATCHFILE && $(MAKE) PATCHSOURCE=TestPatches/DaisySPTest PATCHNAME=DaisySPTest clean patch web run
@unset PATCHNAME PATCHCLASS PATCHFILE && $(MAKE) PATCHSOURCE=TestPatches/GenTest GEN=MIDItestMinMax clean patch web run
# @unset PATCHNAME PATCHCLASS PATCHFILE && $(MAKE) PATCHSOURCE=TestPatches/FaustTest FAUST=FaustTest clean patch web run # FAUST is not installed for CI
@cp FaustSource/*.h TestPatches/FaustTest && unset PATCHNAME PATCHCLASS PATCHFILE && $(MAKE) PATCHSOURCE=TestPatches/FaustTest PATCHNAME=Faust clean patch web run
# @unset PATCHNAME PATCHCLASS PATCHFILE SOULCLASS SOULFILE SOULHPP && $(MAKE) PATCHSOURCE=TestPatches/SoulTest SOUL=SineSynth clean patch web run # SOUL is not installed for CI
@unset PATCHNAME PATCHCLASS PATCHFILE && $(MAKE) PATCHSOURCE=TestPatches/SoulTest PATCHNAME=Soul clean patch web run
@pip install -r Tools/hvcc/requirements.txt && unset PATCHNAME PATCHCLASS PATCHFILE && $(MAKE) PATCHSOURCE=TestPatches/HeavyTest HEAVY=HeavyTest clean patch web run
help: ## show this help
@echo 'Usage: make [target] ...'
@echo 'Targets:'
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/^\(.*\): .*##\(.*\)/\1:#\2/' | column -t -c 2 -s '#'