-
Notifications
You must be signed in to change notification settings - Fork 20
/
web.mk
136 lines (110 loc) · 4.34 KB
/
web.mk
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
ifeq ($(CONFIG),Debug)
EMCCFLAGS ?= -g
endif
ifeq ($(CONFIG),Release)
EMCCFLAGS ?= -Oz # optimise for size
endif
LIBSOURCE = $(BUILDROOT)/LibSource
SOURCE = $(BUILDROOT)/Source
BUILDSOURCE = $(BUILD)/Source
DAISYSP = $(BUILDROOT)/Libraries/DaisySP/Source
# emscripten
EMCC ?= emcc
EMAR ?= emar
EMCCFLAGS += -fno-rtti -fno-exceptions
# EMCCFLAGS += -s ASSERTIONS=1 -Wall
EMCCFLAGS += -I$(SOURCE) -I$(PATCHSOURCE) -I$(LIBSOURCE) -I$(BUILDSOURCE) -I$(BUILD)
EMCCFLAGS += -I$(BUILD)/Source
EMCCFLAGS += -I$(DAISYSP)
EMCCFLAGS += -I$(DAISYSP)/Control
EMCCFLAGS += -I$(DAISYSP)/Drums
EMCCFLAGS += -I$(DAISYSP)/Dynamics
EMCCFLAGS += -I$(DAISYSP)/Effects
EMCCFLAGS += -I$(DAISYSP)/Filters
EMCCFLAGS += -I$(DAISYSP)/Noise
EMCCFLAGS += -I$(DAISYSP)/PhysicalModeling
EMCCFLAGS += -I$(DAISYSP)/Synthesis
EMCCFLAGS += -I$(DAISYSP)/Utility
EMCCFLAGS += -ILibraries -ILibraries/KissFFT -DHV_SIMD_NONE -DDSY_CORE_DSP -DDSY_CUSTOM_DSP
EMCCFLAGS += -Wno-warn-absolute-paths
EMCCFLAGS += -Wno-unknown-warning-option
EMCCFLAGS += --memory-init-file 0 # don't create separate memory init file .mem
EMCCFLAGS += -s EXPORTED_FUNCTIONS="['_WEB_setup','_WEB_setParameter','_WEB_getParameter','_WEB_processBlock','_WEB_getPatchName','_WEB_getParameterName','_WEB_getMessage','_WEB_getStatus','_WEB_getButtons','_WEB_setButton', '_WEB_processMidi', '_malloc']"
EMCCFLAGS += -s "EXTRA_EXPORTED_RUNTIME_METHODS=['cwrap']"
EMCCFLAGS += "-DPATCHNAME=\"$(PATCHNAME)\""
include $(BUILDROOT)/sources.mk
CPP_SRC += Source/Patch.cpp
CPP_SRC += Source/PatchProcessor.cpp
CPP_SRC += Source/message.cpp
CPP_SRC += WebSource/web.cpp
C_SRC += Libraries/KissFFT/kiss_fft.c
ifdef MAXIMILIAN
EMCC_SRC := $(filter-out $(PATCHSOURCE)/$(MAXIMILIAN).cpp, $(EMCC_SRC))
endif
WEBDIR = $(BUILD)/web
EMCCFLAGS += -s WASM=0 # disables wasm output
CPPFLAGS =
CFLAGS = $(EMCCFLAGS) -std=gnu11
CXXFLAGS = $(EMCCFLAGS) -std=gnu++17
LDFLAGS = $(EMCCFLAGS)
EMCC_OBJS = $(addprefix $(WEBDIR)/, $(notdir $(CPP_SRC:.cpp=.o)))
EMCC_OBJS += $(addprefix $(WEBDIR)/, $(notdir $(C_SRC:.c=.o)))
EMDAISYSP_CPP_SRC = $(wildcard $(DAISYSP)/*/*.cpp)
EMDAISYSP_OBJS = $(addprefix $(WEBDIR)/, $(notdir $(EMDAISYSP_CPP_SRC:.cpp=.o)))
PATCH_C_SRC = $(wildcard $(BUILDSOURCE)/*.c)
PATCH_C_SRC += $(wildcard $(PATCHSOURCE)/*.c)
PATCH_CPP_SRC = $(SOURCE)/PatchProgram.cpp
PATCH_CPP_SRC += $(wildcard $(BUILDSOURCE)/*.cpp)
PATCH_CPP_SRC += $(wildcard $(PATCHSOURCE)/*.cpp)
PATCH_OBJS = $(addprefix $(WEBDIR)/, $(notdir $(PATCH_CPP_SRC:.cpp=.o)))
PATCH_OBJS += $(addprefix $(WEBDIR)/, $(notdir $(PATCH_C_SRC:.c=.o)))
OBJS = $(addprefix $(BUILD)/,$(notdir $(C_SRC:.c=.o)))
OBJS += $(addprefix $(BUILD)/,$(notdir $(CPP_SRC:.cpp=.o)))
# OBJS += $(addprefix $(BUILD)/,$(notdir $(S_SRC:.S=.o)))
# Set up search path
vpath %.c $(sort $(dir $(C_SRC)))
vpath %.cpp $(sort $(dir $(CPP_SRC)))
vpath %.s $(sort $(dir $(S_SRC)))
vpath %.S $(sort $(dir $(S_SRC)))
vpath %.cpp $(sort $(dir $(EMDAISYSP_CPP_SRC)))
vpath %.cpp $(SOURCE)
vpath %.c $(SOURCE)
vpath %.s $(SOURCE)
vpath %.cpp $(LIBSOURCE)
vpath %.c $(LIBSOURCE)
vpath %.s $(LIBSOURCE)
vpath %.cpp $(PATCHSOURCE)
vpath %.c $(PATCHSOURCE)
vpath %.s $(PATCHSOURCE)
vpath %.cpp $(BUILDSOURCE)
vpath %.c $(BUILDSOURCE)
vpath %.s $(BUILDSOURCE)
vpath %.cpp WebSource
vpath %.c Libraries/KissFFT
ifeq ($(CONFIG),Debug)
EMCCFLAGS += -s ASSERTIONS=1
endif
PHONY: libs web minify
# JavaScript minifiers
#CLOSURE = java -jar Tools/node_modules/google-closure-compiler/compiler.jar --language_in=ECMASCRIPT5
UGLIFYJS = Tools/node_modules/uglify-js/bin/uglifyjs
$(WEBDIR)/$(TARGET).js: $(PATCH_OBJS)
$(EMCC) $(LDFLAGS) $(PATCH_OBJS) -o $(WEBDIR)/$(TARGET).js Libraries/libowlweb.a -Wl,--whole-archive Libraries/libdaisyspweb.a -Wl,--no-whole-archive
@cp WebSource/*.js WebSource/*.html $(WEBDIR)
$(WEBDIR)/%.min.js: $(WEBDIR)/%.js
@$(UGLIFYJS) -o $@ $<
# @$(CLOSURE) --js_output_file=$@ $<
Libraries/libowlweb.a: $(EMCC_OBJS)
$(EMAR) rcs $@ $^
Libraries/libdaisyspweb.a: $(EMDAISYSP_OBJS)
$(EMAR) rcs $@ $^
libs: Libraries/libowlweb.a Libraries/libdaisyspweb.a
# compile and generate dependency info
$(WEBDIR)/%.o: %.c
@$(EMCC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
@$(EMCC) -MM -MT"$@" $(CPPFLAGS) $(CFLAGS) $< > $(@:.o=.d)
$(WEBDIR)/%.o: %.cpp
@$(EMCC) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
@$(EMCC) -MM -MT"$@" $(CPPFLAGS) $(CXXFLAGS) $< > $(@:.o=.d)
web: $(WEBDIR)/$(TARGET).js ;
minify: $(WEBDIR)/$(TARGET).min.js ;