2024-02-22 11:31:35 +00:00
|
|
|
#
|
|
|
|
# Tibia
|
|
|
|
#
|
|
|
|
# Copyright (C) 2023, 2024 Orastron Srl unipersonale
|
|
|
|
#
|
|
|
|
# Tibia is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, version 3 of the License.
|
|
|
|
#
|
|
|
|
# Tibia is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Tibia. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
# File author: Stefano D'Angelo
|
|
|
|
#
|
|
|
|
|
2024-12-12 06:39:25 +00:00
|
|
|
TEMPLATE := web
|
|
|
|
|
2024-01-17 16:31:14 +00:00
|
|
|
include vars.mk
|
|
|
|
|
2024-12-12 06:39:25 +00:00
|
|
|
COMMON_DIR ?= .
|
|
|
|
DATA_DIR ?= .
|
|
|
|
PLUGIN_DIR ?= src
|
2024-12-12 11:06:17 +00:00
|
|
|
API_DIR ?= $(PLUGIN_DIR)
|
2024-12-12 06:39:25 +00:00
|
|
|
MKINC_DIR ?= $(COMMON_DIR)
|
|
|
|
|
2024-12-13 10:38:34 +00:00
|
|
|
BUILD_BIN_DIR := build/web
|
|
|
|
BUILD_DATA_DIR := build/web
|
|
|
|
|
2024-12-12 06:39:25 +00:00
|
|
|
-include $(MKINC_DIR)/vars-pre.mk
|
2024-02-01 05:59:10 +00:00
|
|
|
|
2024-06-16 10:04:02 +00:00
|
|
|
CC := clang
|
|
|
|
CXX := clang++
|
2024-01-31 08:14:18 +00:00
|
|
|
|
2024-06-16 10:04:02 +00:00
|
|
|
CFLAGS := -Ofast -Wall -Wpedantic -Wextra
|
2024-12-12 11:06:17 +00:00
|
|
|
CFLAGS_ALL := -I$(COMMON_DIR)/src -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) --target=wasm32 -flto -fvisibility=hidden $(CFLAGS_EXTRA) $(CFLAGS)
|
2024-01-31 08:14:18 +00:00
|
|
|
|
2024-06-16 10:04:02 +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-06-16 10:04:02 +00:00
|
|
|
ifeq ($(HAS_MIDI_IN), yes)
|
|
|
|
LDFLAGS_ALL := $(LDFLAGS_ALL) -Wl,--export=processor_midi_msg_in
|
2024-01-19 16:28:00 +00:00
|
|
|
endif
|
2024-12-12 06:39:25 +00:00
|
|
|
LDFLAGS_ALL := $(LDFLAGS_ALL) $(LDFLAGS_EXTRA) $(LDFLAGS)
|
2024-01-19 16:28:00 +00:00
|
|
|
|
2024-06-16 10:04:02 +00:00
|
|
|
CXXFLAGS := $(CFLAGS)
|
2024-12-12 11:06:17 +00:00
|
|
|
CXXFLAGS_ALL := -I$(COMMON_DIR)/src -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) --target=wasm32 -flto -fvisibility=hidden $(CXXFLAGS_EXTRA) $(CXXFLAGS)
|
2024-02-02 16:44:58 +00:00
|
|
|
|
2024-06-16 10:04:02 +00:00
|
|
|
C_SRCS := $(COMMON_DIR)/src/processor.c $(COMMON_DIR)/src/walloc.c $(COMMON_DIR)/src/string.c
|
|
|
|
C_OBJS := $(addprefix build/obj/, $(notdir $(C_SRCS:.c=.o)))
|
2024-02-01 19:48:22 +00:00
|
|
|
|
2024-02-02 16:44:58 +00:00
|
|
|
ifeq ($(CXX_SRCS_EXTRA),)
|
2024-12-12 06:39:25 +00:00
|
|
|
CXX_SRCS :=
|
|
|
|
CXX_OBJS :=
|
2024-02-02 16:44:58 +00:00
|
|
|
else
|
2024-12-12 06:39:25 +00:00
|
|
|
CXX_SRCS := $(COMMON_DIR)/src/new.cpp $(CXX_SRCS_EXTRA)
|
|
|
|
CXX_OBJS := $(addprefix build/obj/, $(notdir $(CXX_SRCS:.cpp=.o)))
|
2024-02-02 16:44:58 +00:00
|
|
|
endif
|
|
|
|
|
2024-12-14 05:59:42 +00:00
|
|
|
DIRS := build build/obj build/web build/web/$(BUNDLE_NAME)
|
|
|
|
|
2024-12-09 15:07:06 +00:00
|
|
|
ALL := build/web/$(BUNDLE_NAME)/module.wasm build/web/$(BUNDLE_NAME)/processor.js build/web/$(BUNDLE_NAME)/module.js
|
2024-01-18 17:13:31 +00:00
|
|
|
|
2024-12-12 06:39:25 +00:00
|
|
|
-include $(MKINC_DIR)/vars-extra.mk
|
2024-01-18 17:13:31 +00:00
|
|
|
|
2024-06-16 10:04:02 +00:00
|
|
|
all: $(ALL)
|
2024-01-17 16:31:14 +00:00
|
|
|
|
2024-02-02 16:44:58 +00:00
|
|
|
ifeq ($(CXX_OBJS),)
|
2024-12-09 15:07:06 +00:00
|
|
|
build/web/$(BUNDLE_NAME)/module.wasm: $(C_OBJS) | build/web/$(BUNDLE_NAME)
|
2024-06-16 10:04:02 +00:00
|
|
|
$(CC) $^ -o $@ $(CFLAGS_ALL) $(LDFLAGS_ALL)
|
2024-02-02 16:44:58 +00:00
|
|
|
else
|
2024-12-09 15:07:06 +00:00
|
|
|
build/web/$(BUNDLE_NAME)/module.wasm: $(C_OBJS) $(CXX_OBJS) | build/web/$(BUNDLE_NAME)
|
2024-06-16 10:04:02 +00:00
|
|
|
$(CXX) $^ -o $@ $(CFLAGS_ALL) $(CXXFLAGS_ALL) $(LDFLAGS_ALL)
|
2024-02-02 16:44:58 +00:00
|
|
|
endif
|
2024-01-18 14:30:38 +00:00
|
|
|
|
2024-12-09 15:07:06 +00:00
|
|
|
build/web/$(BUNDLE_NAME)/processor.js: $(DATA_DIR)/src/processor.js | build/web/$(BUNDLE_NAME)
|
2024-01-18 14:30:38 +00:00
|
|
|
cp $^ $@
|
2024-01-17 16:31:14 +00:00
|
|
|
|
2024-12-11 08:40:50 +00:00
|
|
|
build/web/$(BUNDLE_NAME)/module.js: $(DATA_DIR)/src/module.js | build/web/$(BUNDLE_NAME)
|
2024-01-18 17:13:31 +00:00
|
|
|
cp $^ $@
|
|
|
|
|
2024-12-14 05:59:42 +00:00
|
|
|
$(DIRS):
|
2024-01-17 16:31:14 +00:00
|
|
|
mkdir -p $@
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -fr build
|
|
|
|
|
2024-12-12 06:39:25 +00:00
|
|
|
-include $(MKINC_DIR)/rules-extra.mk
|
2024-06-16 10:04:02 +00:00
|
|
|
|
2024-01-17 16:31:14 +00:00
|
|
|
.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
|
2024-06-16 10:04:02 +00:00
|
|
|
$(CC) $^ -o $@ -c $(CFLAGS_ALL)
|
2024-02-02 16:44:58 +00:00
|
|
|
|
|
|
|
$(CXX_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).cpp,$$(CXX_SRCS)) | build/obj
|
2024-06-16 10:04:02 +00:00
|
|
|
$(CXX) $^ -o $@ -c $(CXXFLAGS_ALL)
|
|
|
|
|
2024-12-12 06:39:25 +00:00
|
|
|
-include $(MKINC_DIR)/rules-secondexp-extra.mk
|