2024-01-17 16:31:14 +00:00
|
|
|
include vars.mk
|
|
|
|
|
2024-02-01 05:59:10 +00:00
|
|
|
COMMON_DIR := $(or $(COMMON_DIR),.)
|
|
|
|
DATA_DIR := $(or $(DATA_DIR),.)
|
|
|
|
PLUGIN_DIR := $(or $(PLUGIN_DIR),src)
|
|
|
|
|
2024-01-17 16:31:14 +00:00
|
|
|
CC = clang
|
2024-02-02 16:44:58 +00:00
|
|
|
CXX = clang++
|
2024-01-31 08:14:18 +00:00
|
|
|
|
|
|
|
CFLAGS = -Ofast -Wall -Wpedantic -Wextra
|
2024-02-01 05:59:10 +00:00
|
|
|
CFLAGS_ALL = -I${COMMON_DIR}/src -I${DATA_DIR}/src -I${PLUGIN_DIR} --target=wasm32 -flto -fvisibility=hidden ${CFLAGS} ${CFLAGS_EXTRA}
|
2024-01-31 08:14:18 +00:00
|
|
|
|
|
|
|
LDFLAGS_ALL = \
|
2024-01-17 16:31:14 +00:00
|
|
|
-Wl,--allow-undefined \
|
|
|
|
-Wl,--no-entry \
|
|
|
|
-Wl,--lto-O3 \
|
|
|
|
-Wl,-strip-all \
|
|
|
|
-Wl,--export-table \
|
2024-02-08 14:53:17 +00:00
|
|
|
-Wl,--export=malloc \
|
|
|
|
-Wl,--export=realloc \
|
|
|
|
-Wl,--export=calloc \
|
|
|
|
-Wl,--export=free \
|
|
|
|
-Wl,--export=memset \
|
2024-02-21 08:03:50 +00:00
|
|
|
-Wl,--export=memcpy \
|
2024-01-18 14:30:38 +00:00
|
|
|
-Wl,--export=processor_new \
|
|
|
|
-Wl,--export=processor_free \
|
2024-01-19 14:33:53 +00:00
|
|
|
-Wl,--export=processor_get_x_buf \
|
2024-02-07 16:22:29 +00:00
|
|
|
-Wl,--export=processor_get_x \
|
|
|
|
-Wl,--export=processor_get_zero_buf \
|
2024-01-19 14:33:53 +00:00
|
|
|
-Wl,--export=processor_get_y_buf \
|
|
|
|
-Wl,--export=processor_get_out_params \
|
2024-01-18 14:30:38 +00:00
|
|
|
-Wl,--export=processor_process \
|
|
|
|
-Wl,--export=processor_set_parameter \
|
2024-01-17 16:31:14 +00:00
|
|
|
-Wl,-z,stack-size=$$((8*1024*1024)) \
|
|
|
|
-nostdlib
|
2024-01-19 16:28:00 +00:00
|
|
|
ifeq (${HAS_MIDI_IN}, yes)
|
2024-01-31 08:14:18 +00:00
|
|
|
LDFLAGS_ALL += -Wl,--export=processor_midi_msg_in
|
2024-01-19 16:28:00 +00:00
|
|
|
endif
|
2024-01-31 08:14:18 +00:00
|
|
|
LDFLAGS_ALL += ${LDFLAGS} ${LDFLAGS_EXTRA}
|
2024-01-19 16:28:00 +00:00
|
|
|
|
2024-02-02 16:44:58 +00:00
|
|
|
CXXFLAGS = ${CFLAGS}
|
|
|
|
CXXFLAGS_ALL = -I${COMMON_DIR}/src -I${DATA_DIR}/src -I${PLUGIN_DIR} --target=wasm32 -flto -fvisibility=hidden ${CXXFLAGS} ${CXXFLAGS_EXTRA}
|
|
|
|
|
2024-02-21 08:03:50 +00:00
|
|
|
C_SRCS = ${COMMON_DIR}/src/processor.c ${COMMON_DIR}/src/walloc.c ${COMMON_DIR}/src/string.c
|
2024-02-01 19:48:22 +00:00
|
|
|
C_OBJS = $(addprefix build/obj/, $(notdir $(C_SRCS:.c=.o)))
|
|
|
|
|
2024-02-02 16:44:58 +00:00
|
|
|
ifeq ($(CXX_SRCS_EXTRA),)
|
|
|
|
CXX_SRCS =
|
|
|
|
CXX_OBJS =
|
|
|
|
else
|
|
|
|
CXX_SRCS = ${COMMON_DIR}/src/new.cpp ${CXX_SRCS_EXTRA}
|
|
|
|
CXX_OBJS = $(addprefix build/obj/, $(notdir $(CXX_SRCS:.cpp=.o)))
|
|
|
|
endif
|
|
|
|
|
2024-02-06 10:18:43 +00:00
|
|
|
ALL = build/web/${BUNDLE_NAME}.wasm build/web/${BUNDLE_NAME}_processor.js build/web/${BUNDLE_NAME}.js
|
2024-01-18 17:13:31 +00:00
|
|
|
|
|
|
|
default: all
|
|
|
|
|
2024-02-01 05:59:10 +00:00
|
|
|
-include ${COMMON_DIR}/demo.mk
|
2024-01-18 17:13:31 +00:00
|
|
|
|
|
|
|
all: ${ALL}
|
2024-01-17 16:31:14 +00:00
|
|
|
|
2024-02-02 16:44:58 +00:00
|
|
|
ifeq ($(CXX_OBJS),)
|
2024-02-06 10:18:43 +00:00
|
|
|
build/web/${BUNDLE_NAME}.wasm: ${C_OBJS} | build/web
|
2024-02-01 19:48:22 +00:00
|
|
|
${CC} $^ -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL}
|
2024-02-02 16:44:58 +00:00
|
|
|
else
|
2024-02-06 10:18:43 +00:00
|
|
|
build/web/${BUNDLE_NAME}.wasm: ${C_OBJS} ${CXX_OBJS} | build/web
|
2024-02-02 16:44:58 +00:00
|
|
|
${CXX} $^ -o $@ ${CFLAGS_ALL} ${CXXFLAGS_ALL} ${LDFLAGS_ALL}
|
|
|
|
endif
|
2024-01-18 14:30:38 +00:00
|
|
|
|
2024-02-06 10:18:43 +00:00
|
|
|
build/web/${BUNDLE_NAME}_processor.js: ${DATA_DIR}/src/processor.js | build/web
|
2024-01-18 14:30:38 +00:00
|
|
|
cp $^ $@
|
2024-01-17 16:31:14 +00:00
|
|
|
|
2024-02-06 10:18:43 +00:00
|
|
|
build/web/${BUNDLE_NAME}.js: ${DATA_DIR}/src/module.js | build/web
|
2024-01-18 17:13:31 +00:00
|
|
|
cp $^ $@
|
|
|
|
|
2024-02-06 10:18:43 +00:00
|
|
|
build/web build/obj:
|
2024-01-17 16:31:14 +00:00
|
|
|
mkdir -p $@
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -fr build
|
|
|
|
|
|
|
|
.PHONY: all clean
|
2024-02-02 16:44:58 +00:00
|
|
|
|
|
|
|
.SECONDEXPANSION:
|
|
|
|
|
|
|
|
PERCENT := %
|
|
|
|
|
|
|
|
$(C_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).c,$$(C_SRCS)) | build/obj
|
|
|
|
${CC} $^ -o $@ -c ${CFLAGS_ALL}
|
|
|
|
|
|
|
|
$(CXX_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).cpp,$$(CXX_SRCS)) | build/obj
|
|
|
|
${CXX} $^ -o $@ -c ${CXXFLAGS_ALL}
|