improved all makefiles

This commit is contained in:
Stefano D'Angelo 2024-06-16 12:04:02 +02:00
parent 62767a4397
commit b8a16c226c
10 changed files with 190 additions and 141 deletions

View File

@ -20,37 +20,37 @@
include vars.mk
ifeq (${HAS_MIDI_IN}, yes)
ifeq ($(HAS_MIDI_IN), yes)
MIN_API := 29
else
MIN_API := 26
endif
CC = ${ANDROID_NDK_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi${MIN_API}-clang
CXX = ${ANDROID_NDK_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi${MIN_API}-clang++
JC = javac
CC := $(ANDROID_NDK_DIR)/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi$(MIN_API)-clang
CXX := $(ANDROID_NDK_DIR)/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi$(MIN_API)-clang++
JC := javac
APKSIGNER = ${BUILD_TOOLS_DIR}/apksigner
ZIPALIGN = ${BUILD_TOOLS_DIR}/zipalign
AAPT = ${BUILD_TOOLS_DIR}/aapt
D8 = ${BUILD_TOOLS_DIR}/d8
ADB = ${ANDROID_SDK_DIR}/platform-tools/adb
APKSIGNER := $(BUILD_TOOLS_DIR)/apksigner
ZIPALIGN := $(BUILD_TOOLS_DIR)/zipalign
AAPT := $(BUILD_TOOLS_DIR)/aapt
D8 := $(BUILD_TOOLS_DIR)/d8
ADB := $(ANDROID_SDK_DIR)/platform-tools/adb
JARS := \
${ANDROID_JAR_FILE} \
${ANDROIDX_CORE_FILE} \
${ANDROIDX_LIFECYCLE_COMMON_FILE} \
${ANDROIDX_VERSIONEDPARCELABLE_FILE} \
${KOTLIN_STDLIB_FILE} \
${KOTLINX_COROUTINES_CORE_FILE} \
${KOTLINX_COROUTINES_CORE_JVM_FILE}
$(ANDROID_JAR_FILE) \
$(ANDROIDX_CORE_FILE) \
$(ANDROIDX_LIFECYCLE_COMMON_FILE) \
$(ANDROIDX_VERSIONEDPARCELABLE_FILE) \
$(KOTLIN_STDLIB_FILE) \
$(KOTLINX_COROUTINES_CORE_FILE) \
$(KOTLINX_COROUTINES_CORE_JVM_FILE)
CLASSES_PATH := $(subst .,/,$(JAVA_PACKAGE_NAME))
CLASSES := \
MainActivity \
MainActivity$$WebAppInterface
ifeq (${HAS_MIDI_IN}, yes)
ifeq ($(HAS_MIDI_IN), yes)
CLASSES += MainActivity$$WebAppInterface$$MidiDeviceCallback MainActivity$$WebAppInterface$$1
endif
@ -58,53 +58,57 @@ COMMON_DIR := $(or $(COMMON_DIR),.)
DATA_DIR := $(or $(DATA_DIR),.)
PLUGIN_DIR := $(or $(PLUGIN_DIR),src)
CFLAGS = -O3 -Wall -Wpedantic -Wextra
CFLAGS_ALL = -I${DATA_DIR}/src -I${PLUGIN_DIR} -fPIC ${CFLAGS} ${CFLAGS_EXTRA}
CFLAGS := -O3 -Wall -Wpedantic -Wextra
CFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -fPIC $(CFLAGS) $(CFLAGS_EXTRA)
CXXFLAGS = ${CFLAGS}
CXXFLAGS_ALL = -I${DATA_DIR}/src -I${PLUGIN_DIR} -fPIC -std=c++11 ${CXXFLAGS} ${CXXFLAGS_EXTRA}
CXXFLAGS := $(CFLAGS)
CXXFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -fPIC -std=c++11 $(CXXFLAGS) $(CXXFLAGS_EXTRA)
LDFLAGS =
LDFLAGS_ALL = -shared -static-libstdc++ -landroid
ifeq (${HAS_MIDI_IN}, yes)
LDFLAGS :=
LDFLAGS_ALL := -shared -static-libstdc++ -landroid
ifeq ($(HAS_MIDI_IN), yes)
LDFLAGS += -lamidi
endif
LDFLAGS_ALL += ${LDFLAGS} ${LDFLAGS_EXTRA}
LDFLAGS_ALL += $(LDFLAGS) $(LDFLAGS_EXTRA)
JFLAGS =
JFLAGS_ALL = ${JFLAGS} ${JFLAGS_EXTRA}
JFLAGS :=
JFLAGS_ALL := $(JFLAGS) $(JFLAGS_EXTRA)
C_SRCS = ${C_SRCS_EXTRA}
C_OBJS = $(addprefix build/obj/, $(notdir $(C_SRCS:.c=.o)))
C_SRCS := $(C_SRCS_EXTRA)
C_OBJS := $(addprefix build/obj/, $(notdir $(C_SRCS:.c=.o)))
CXX_SRCS = ${COMMON_DIR}/src/jni.cpp ${CXX_SRCS_EXTRA}
CXX_OBJS = $(addprefix build/obj/, $(notdir $(CXX_SRCS:.cpp=.o)))
CXX_SRCS := $(COMMON_DIR)/src/jni.cpp $(CXX_SRCS_EXTRA)
CXX_OBJS := $(addprefix build/obj/, $(notdir $(CXX_SRCS:.cpp=.o)))
all: build/${BUNDLE_NAME}.apk
ALL := build/$(BUNDLE_NAME).apk
build/${BUNDLE_NAME}.apk: build/gen/${BUNDLE_NAME}.aligned.apk ${KEY_STORE}
${APKSIGNER} sign --ks ${KEY_STORE} --ks-key-alias ${KEY_ALIAS} --ks-pass pass:${STORE_PASS} --key-pass pass:${KEY_PASS} --out $@ build/gen/${BUNDLE_NAME}.aligned.apk
-include $(COMMON_DIR)/vars-extra.mk
build/gen/${BUNDLE_NAME}.aligned.apk: build/gen/${BUNDLE_NAME}.unsigned.apk
${ZIPALIGN} -f -p 4 $^ $@
all: $(ALL)
build/gen/${BUNDLE_NAME}.unsigned.apk: build/apk/classes.dex build/apk/lib/armeabi-v7a/lib${BUNDLE_NAME}.so ${DATA_DIR}/data/AndroidManifest.xml build/assets/index.html | build/gen
${AAPT} package -f -M ${DATA_DIR}/data/AndroidManifest.xml -A build/assets $(foreach jar,$(JARS),-I $(jar)) -F $@ build/apk
build/$(BUNDLE_NAME).apk: build/gen/$(BUNDLE_NAME).aligned.apk $(KEY_STORE)
$(APKSIGNER) sign --ks $(KEY_STORE) --ks-key-alias $(KEY_ALIAS) --ks-pass pass:$(STORE_PASS) --key-pass pass:$(KEY_PASS) --out $@ build/gen/$(BUNDLE_NAME).aligned.apk
build/gen/$(BUNDLE_NAME).aligned.apk: build/gen/$(BUNDLE_NAME).unsigned.apk
$(ZIPALIGN) -f -p 4 $^ $@
build/gen/$(BUNDLE_NAME).unsigned.apk: build/apk/classes.dex build/apk/lib/armeabi-v7a/lib$(BUNDLE_NAME).so $(DATA_DIR)/data/AndroidManifest.xml build/assets/index.html | build/gen
$(AAPT) package -f -M $(DATA_DIR)/data/AndroidManifest.xml -A build/assets $(foreach jar,$(JARS),-I $(jar)) -F $@ build/apk
build/apk/classes.dex: build/apk/my_classes.jar
cd build/apk && ${D8} --min-api ${MIN_API} ../../$^ ${JARS} && cd ../..
cd build/apk && $(D8) --min-api $(MIN_API) ../../$^ $(JARS) && cd ../..
build/apk/my_classes.jar: $(foreach class,$(CLASSES),build/obj/$(CLASSES_PATH)/$(class).class) | build/apk
@echo ${CLASSES_PATH}
${D8} $(foreach class,$(CLASSES),'build/obj/$(CLASSES_PATH)/$(class).class') --min-api ${MIN_API} --output $@ --no-desugaring
@echo $(CLASSES_PATH)
$(D8) $(foreach class,$(CLASSES),'build/obj/$(CLASSES_PATH)/$(class).class') --min-api $(MIN_API) --output $@ --no-desugaring
build/obj/${CLASSES_PATH}/MainActivity.class: ${DATA_DIR}/src/MainActivity.java | build/obj
${JC} ${JFLAGS_ALL} -classpath "$(subst $() $(),:,$(JARS))" -d build/obj $^
build/obj/$(CLASSES_PATH)/MainActivity.class: $(DATA_DIR)/src/MainActivity.java | build/obj
$(JC) $(JFLAGS_ALL) -classpath "$(subst $() $(),:,$(JARS))" -d build/obj $^
build/apk/lib/armeabi-v7a/lib${BUNDLE_NAME}.so: ${C_OBJS} ${CXX_OBJS} | build/apk/lib/armeabi-v7a
${CXX} $^ -o $@ ${CFLAGS_ALL} ${CXXFLAGS_ALL} ${LDFLAGS_ALL}
build/apk/lib/armeabi-v7a/lib$(BUNDLE_NAME).so: $(C_OBJS) $(CXX_OBJS) | build/apk/lib/armeabi-v7a
$(CXX) $^ -o $@ $(CFLAGS_ALL) $(CXXFLAGS_ALL) $(LDFLAGS_ALL)
build/assets/index.html: ${DATA_DIR}/src/index.html | build/assets
build/assets/index.html: $(DATA_DIR)/src/index.html | build/assets
cp $^ $@
build/gen build/apk build/obj build/apk/lib/armeabi-v7a build/assets:
@ -113,9 +117,11 @@ build/gen build/apk build/obj build/apk/lib/armeabi-v7a build/assets:
clean:
rm -fr build
install: build/${BUNDLE_NAME}.apk
[ -n "`${ADB} shell pm list packages | grep ^package:${JAVA_PACKAGE_NAME}`" ] && ${ADB} uninstall ${JAVA_PACKAGE_NAME}; exit 0
${ADB} install $^
install: build/$(BUNDLE_NAME).apk
[ -n "`$(ADB) shell pm list packages | grep ^package:$(JAVA_PACKAGE_NAME)`" ] && $(ADB) uninstall $(JAVA_PACKAGE_NAME); exit 0
$(ADB) install $^
-include $(COMMON_DIR)/rules-extra.mk
.PHONY: all clean install
@ -124,7 +130,9 @@ install: build/${BUNDLE_NAME}.apk
PERCENT := %
$(C_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).c,$$(C_SRCS)) | build/obj
${CC} $^ -o $@ -c ${CFLAGS_ALL}
$(CC) $^ -o $@ -c $(CFLAGS_ALL)
$(CXX_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).cpp,$$(CXX_SRCS)) | build/obj
${CXX} $^ -o $@ -c ${CXXFLAGS_ALL}
$(CXX) $^ -o $@ -c $(CXXFLAGS_ALL)
-include $(COMMON_DIR)/rules-secondexp-extra.mk

View File

@ -21,55 +21,59 @@
include vars.mk
ifeq ($(OS), Windows_NT)
EXE_SUFFIX = .exe
EXE_SUFFIX := .exe
else
UNAME_S = $(shell uname -s)
EXE_SUFFIX =
PREFIX = /usr/local
BINDIR = ${PREFIX}/bin
UNAME_S := $(shell uname -s)
EXE_SUFFIX :=
PREFIX := /usr/local
BINDIR := $(PREFIX)/bin
endif
COMMON_DIR := $(or $(COMMON_DIR),.)
DATA_DIR := $(or $(DATA_DIR),.)
PLUGIN_DIR := $(or $(PLUGIN_DIR),src)
CC = gcc
CXX = g++
CC := gcc
CXX := g++
CFLAGS = -O3 -Wall -Wpedantic -Wextra
CFLAGS_ALL = -I${DATA_DIR}/src -I${PLUGIN_DIR} -I${TINYWAV_DIR} -I${MIDI_PARSER_DIR}/include -fPIC ${CFLAGS} ${CFLAGS_EXTRA}
CFLAGS := -O3 -Wall -Wpedantic -Wextra
CFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(TINYWAV_DIR) -I$(MIDI_PARSER_DIR)/include -fPIC $(CFLAGS) $(CFLAGS_EXTRA)
LDFLAGS =
LDFLAGS_ALL = ${LDFLAGS} ${LDFLAGS_EXTRA}
LDFLAGS :=
LDFLAGS_ALL := $(LDFLAGS) $(LDFLAGS_EXTRA)
CXXFLAGS = ${CFLAGS}
CXXFLAGS_ALL = -I${DATA_DIR}/src -I${PLUGIN_DIR} -I${TINYWAV_DIR} -I${MIDI_PARSER_DIR}/include -fPIC ${CXXFLAGS} ${CXXFLAGS_EXTRA}
CXXFLAGS := $(CFLAGS)
CXXFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(TINYWAV_DIR) -I$(MIDI_PARSER_DIR)/include -fPIC $(CXXFLAGS) $(CXXFLAGS_EXTRA)
ifeq ($(UNAME_S), Darwin)
CFLAGS_ALL := ${CFLAGS_ALL} -arch arm64 -arch x86_64
LDFLAGS_ALL := ${LDFLAGS_ALL} -arch arm64 -arch x86_64
CXXFLAGS_ALL := ${CXXFLAGS_ALL} -arch arm64 -arch x86_64
CFLAGS_ALL := $(CFLAGS_ALL) -arch arm64 -arch x86_64
LDFLAGS_ALL := $(LDFLAGS_ALL) -arch arm64 -arch x86_64
CXXFLAGS_ALL := $(CXXFLAGS_ALL) -arch arm64 -arch x86_64
endif
PROGRAM = ${BUNDLE_NAME}${EXE_SUFFIX}
PROGRAM := $(BUNDLE_NAME)$(EXE_SUFFIX)
C_SRCS = ${COMMON_DIR}/src/main.c ${C_SRCS_EXTRA}
C_SRCS := $(COMMON_DIR)/src/main.c $(C_SRCS_EXTRA)
ifeq ($(HAS_MIDI_IN), yes)
C_SRCS += ${MIDI_PARSER_DIR}/src/midi-parser.c
C_SRCS := $(C_SRCS) $(MIDI_PARSER_DIR)/src/midi-parser.c
endif
C_OBJS = $(addprefix build/obj/, $(notdir $(C_SRCS:.c=.o)))
C_OBJS := $(addprefix build/obj/, $(notdir $(C_SRCS:.c=.o)))
CXX_SRCS = ${CXX_SRCS_EXTRA}
CXX_OBJS = $(addprefix build/obj/, $(notdir $(CXX_SRCS:.cpp=.o)))
CXX_SRCS := $(CXX_SRCS_EXTRA)
CXX_OBJS := $(addprefix build/obj/, $(notdir $(CXX_SRCS:.cpp=.o)))
all: build/${PROGRAM}
ALL := build/$(PROGRAM)
-include $(COMMON_DIR)/vars-extra.mk
all: $(ALL)
ifeq ($(CXX_OBJS),)
build/${PROGRAM}: ${C_OBJS} build/obj/tinywav.o | build
${CC} $^ -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL}
build/$(PROGRAM): $(C_OBJS) build/obj/tinywav.o | build
$(CC) $^ -o $@ $(CFLAGS_ALL) $(LDFLAGS_ALL)
else
build/${PROGRAM}: ${C_OBJS} ${CXX_OBJS} build/obj/tinywav.o | build
${CXX} $^ -o $@ ${CFLAGS_ALL} ${CXXFLAGS_ALL} ${LDFLAGS_ALL}
build/$(PROGRAM): $(C_OBJS) $(CXX_OBJS) build/obj/tinywav.o | build
$(CXX) $^ -o $@ $(CFLAGS_ALL) $(CXXFLAGS_ALL) $(LDFLAGS_ALL)
endif
build build/obj:
@ -82,21 +86,24 @@ ifeq ($(OS), Windows_NT)
.PHONY: all clean
else
install: all
mkdir -p -m 0755 ${BINDIR}
install -m 0755 build/${PROGRAM} ${BINDIR}
install -m 0755 -t $(BINDIR) -D build/$(PROGRAM)
.PHONY: all clean install
endif
-include $(COMMON_DIR)/rules-extra.mk
.SECONDEXPANSION:
PERCENT := %
build/obj/tinywav.o: ${TINYWAV_DIR}/tinywav.c
${CC} $^ -o $@ -c ${CFLAGS_ALL} -Wno-unused-result
build/obj/tinywav.o: $(TINYWAV_DIR)/tinywav.c
$(CC) $^ -o $@ -c $(CFLAGS_ALL) -Wno-unused-result
$(C_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).c,$$(C_SRCS)) | build/obj
${CC} $^ -o $@ -c ${CFLAGS_ALL}
$(CC) $^ -o $@ -c $(CFLAGS_ALL)
$(CXX_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).cpp,$$(CXX_SRCS)) | build/obj
${CXX} $^ -o $@ -c ${CXXFLAGS_ALL}
$(CXX) $^ -o $@ -c $(CXXFLAGS_ALL)
-include $(COMMON_DIR)/rules-secondexp-extra.mk

View File

@ -20,20 +20,22 @@
include vars.mk
TARGET = ${BUNDLE_NAME}
TARGET := $(BUNDLE_NAME)
COMMON_DIR := $(or $(COMMON_DIR),.)
DATA_DIR := $(or $(DATA_DIR),.)
PLUGIN_DIR := $(or $(PLUGIN_DIR),src)
CPP_SOURCES = ${COMMON_DIR}/src/main.cpp ${CXX_SRCS_EXTRA}
CPP_SOURCES := $(COMMON_DIR)/src/main.cpp $(CXX_SRCS_EXTRA)
SYSTEM_FILES_DIR = ${LIBDAISY_DIR}/core
SYSTEM_FILES_DIR := $(LIBDAISY_DIR)/core
include ${SYSTEM_FILES_DIR}/Makefile
include $(SYSTEM_FILES_DIR)/Makefile
C_SOURCES += ${C_SRCS_EXTRA}
C_SOURCES += $(C_SRCS_EXTRA)
CFLAGS += -I${DATA_DIR}/src -I${PLUGIN_DIR} ${CFLAGS_EXTRA}
LDFLAGS += ${LDFLAGS_EXTRA}
CXXFLAGS += -I${DATA_DIR}/src -I${PLUGIN_DIR} ${CXXFLAGS_EXTRA}
CFLAGS += -I$(DATA_DIR)/src -I$(PLUGIN_DIR) $(CFLAGS_EXTRA)
LDFLAGS += $(LDFLAGS_EXTRA)
CXXFLAGS += -I$(DATA_DIR)/src -I$(PLUGIN_DIR) $(CXXFLAGS_EXTRA)
-include $(COMMON_DIR)/extra.mk

View File

@ -25,20 +25,24 @@ DATA_DIR := $(or $(DATA_DIR),.)
PLUGIN_DIR := $(or $(PLUGIN_DIR),src)
SOURCES := \
${DATA_DIR}/src/data.h \
${DATA_DIR}/src/index.html \
${COMMON_DIR}/src/app.swift \
${COMMON_DIR}/src/native.mm \
${COMMON_DIR}/src/app-Bridging-Header.h \
${PLUGIN_DIR}/plugin.h \
${C_SRCS_EXTRA} \
${CXX_SRCS_EXTRA} \
${SRCS_EXTRA}
SOURCES_OUT = $(addprefix build/gen/src/, $(notdir $(SOURCES)))
$(DATA_DIR)/src/data.h \
$(DATA_DIR)/src/index.html \
$(COMMON_DIR)/src/app.swift \
$(COMMON_DIR)/src/native.mm \
$(COMMON_DIR)/src/app-Bridging-Header.h \
$(PLUGIN_DIR)/plugin.h \
$(C_SRCS_EXTRA) \
$(CXX_SRCS_EXTRA) \
$(SRCS_EXTRA)
SOURCES_OUT := $(addprefix build/gen/src/, $(notdir $(SOURCES)))
all: build/gen/${BUNDLE_NAME}.xcodeproj
ALL = build/gen/$(BUNDLE_NAME).xcodeproj
build/gen/${BUNDLE_NAME}.xcodeproj: ${SOURCES_OUT}
-include $(COMMON_DIR)/vars-extra.mk
all: $(ALL)
build/gen/$(BUNDLE_NAME).xcodeproj: $(SOURCES_OUT)
xcodegen generate --spec project.yml -r build/gen -p build/gen
build/gen/src:
@ -47,6 +51,8 @@ build/gen/src:
clean:
rm -fr build
-include $(COMMON_DIR)/rules-extra.mk
.PHONY: all clean
.SECONDEXPANSION:
@ -55,3 +61,5 @@ PERCENT := %
$(SOURCES_OUT): build/gen/src/%: $$(filter $$(PERCENT)/%,$$(SOURCES)) | build/gen/src
cp -R $^ $@
-include $(COMMON_DIR)/rules-secondexp-extra.mk

View File

@ -78,7 +78,7 @@ CXX_OBJS := $(addprefix build/obj/, $(notdir $(CXX_SRCS:.cpp=.o)))
ALL := build/$(BUNDLE_DIR)/manifest.ttl build/$(BUNDLE_DIR)/$(DLL_FILE)
-include vars-extra.mk
-include $(COMMON_DIR)/vars-extra.mk
all: $(ALL)
@ -117,7 +117,7 @@ install-user: all
install -m $$m -t "$(LV2DIR_USER)/$$d" -D $$f; \
done
-include rules-extra.mk
-include $(COMMON_DIR)/rules-extra.mk
.PHONY: all clean install install-user
@ -131,4 +131,4 @@ $(C_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).c,$$
$(CXX_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).cpp,$$(CXX_SRCS)) | build/obj
$(CXX) $^ -o $@ -c $(CXXFLAGS_ALL)
-include rules-secondexp-extra.mk
-include $(COMMON_DIR)/rules-secondexp-extra.mk

View File

@ -93,6 +93,8 @@ ifeq ($(UNAME_S), Darwin)
ALL := $(ALL) build/$(BUNDLE_DIR)/Contents/Info.plist build/$(BUNDLE_DIR)/Contents/PkgInfo
endif
-include $(COMMON_DIR)/vars-extra.mk
all: $(ALL)
ifeq ($(CXX_OBJS),)
@ -132,7 +134,7 @@ install-user: all
install -m $$m -t "$(VST3DIR_USER)/$$d" -D $$f; \
done
-include rules-extra.mk
-include $(COMMON_DIR)/rules-extra.mk
.PHONY: all clean install install-user
@ -146,4 +148,4 @@ $(C_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).c,$$
$(CXX_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).cpp,$$(CXX_SRCS)) | build/obj
$(CXX) $^ -o $@ -c $(CXXFLAGS_ALL)
-include rules-secondexp-extra.mk
-include $(COMMON_DIR)/rules-secondexp-extra.mk

View File

@ -18,8 +18,6 @@
# File author: Stefano D'Angelo
#
ALL += build/web/index.html build/web/cert.pem build/web/key.pem
build/web/index.html: ${DATA_DIR}/src/index.html | build/web
cp $^ $@

View File

@ -23,5 +23,6 @@ var sep = path.sep;
module.exports = function (data, api) {
api.generateFileFromTemplateFile(`src${sep}index.html`, `src${sep}index.html`, data);
api.copyFile(`web-extra.mk`, `web-extra.mk`);
api.copyFile(`vars-extra.mk`, `vars-extra.mk`);
api.copyFile(`rules-extra.mk`, `rules-extra.mk`);
};

View File

@ -0,0 +1,21 @@
#
# 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
#
ALL := $(ALL) build/web/index.html build/web/cert.pem build/web/key.pem

View File

@ -24,13 +24,13 @@ COMMON_DIR := $(or $(COMMON_DIR),.)
DATA_DIR := $(or $(DATA_DIR),.)
PLUGIN_DIR := $(or $(PLUGIN_DIR),src)
CC = clang
CXX = clang++
CC := clang
CXX := clang++
CFLAGS = -Ofast -Wall -Wpedantic -Wextra
CFLAGS_ALL = -I${COMMON_DIR}/src -I${DATA_DIR}/src -I${PLUGIN_DIR} --target=wasm32 -flto -fvisibility=hidden ${CFLAGS} ${CFLAGS_EXTRA}
CFLAGS := -Ofast -Wall -Wpedantic -Wextra
CFLAGS_ALL := -I$(COMMON_DIR)/src -I$(DATA_DIR)/src -I$(PLUGIN_DIR) --target=wasm32 -flto -fvisibility=hidden $(CFLAGS) $(CFLAGS_EXTRA)
LDFLAGS_ALL = \
LDFLAGS_ALL := \
-Wl,--allow-undefined \
-Wl,--no-entry \
-Wl,--lto-O3 \
@ -53,45 +53,43 @@ LDFLAGS_ALL = \
-Wl,--export=processor_set_parameter \
-Wl,-z,stack-size=$$((8*1024*1024)) \
-nostdlib
ifeq (${HAS_MIDI_IN}, yes)
LDFLAGS_ALL += -Wl,--export=processor_midi_msg_in
ifeq ($(HAS_MIDI_IN), yes)
LDFLAGS_ALL := $(LDFLAGS_ALL) -Wl,--export=processor_midi_msg_in
endif
LDFLAGS_ALL += ${LDFLAGS} ${LDFLAGS_EXTRA}
LDFLAGS_ALL := $(LDFLAGS_ALL) $(LDFLAGS) $(LDFLAGS_EXTRA)
CXXFLAGS = ${CFLAGS}
CXXFLAGS_ALL = -I${COMMON_DIR}/src -I${DATA_DIR}/src -I${PLUGIN_DIR} --target=wasm32 -flto -fvisibility=hidden ${CXXFLAGS} ${CXXFLAGS_EXTRA}
CXXFLAGS := $(CFLAGS)
CXXFLAGS_ALL := -I$(COMMON_DIR)/src -I$(DATA_DIR)/src -I$(PLUGIN_DIR) --target=wasm32 -flto -fvisibility=hidden $(CXXFLAGS) $(CXXFLAGS_EXTRA)
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)))
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)))
ifeq ($(CXX_SRCS_EXTRA),)
CXX_SRCS =
CXX_OBJS =
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)))
CXX_SRCS := $(COMMON_DIR)/src/new.cpp $(CXX_SRCS_EXTRA)
CXX_OBJS := $(addprefix build/obj/, $(notdir $(CXX_SRCS:.cpp=.o)))
endif
ALL = build/web/${BUNDLE_NAME}.wasm build/web/${BUNDLE_NAME}_processor.js build/web/${BUNDLE_NAME}.js
ALL := build/web/$(BUNDLE_NAME).wasm build/web/$(BUNDLE_NAME)_processor.js build/web/$(BUNDLE_NAME).js
default: all
-include $(COMMON_DIR)/vars-extra.mk
-include ${COMMON_DIR}/web-extra.mk
all: ${ALL}
all: $(ALL)
ifeq ($(CXX_OBJS),)
build/web/${BUNDLE_NAME}.wasm: ${C_OBJS} | build/web
${CC} $^ -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL}
build/web/$(BUNDLE_NAME).wasm: $(C_OBJS) | build/web
$(CC) $^ -o $@ $(CFLAGS_ALL) $(LDFLAGS_ALL)
else
build/web/${BUNDLE_NAME}.wasm: ${C_OBJS} ${CXX_OBJS} | build/web
${CXX} $^ -o $@ ${CFLAGS_ALL} ${CXXFLAGS_ALL} ${LDFLAGS_ALL}
build/web/$(BUNDLE_NAME).wasm: $(C_OBJS) $(CXX_OBJS) | build/web
$(CXX) $^ -o $@ $(CFLAGS_ALL) $(CXXFLAGS_ALL) $(LDFLAGS_ALL)
endif
build/web/${BUNDLE_NAME}_processor.js: ${DATA_DIR}/src/processor.js | build/web
build/web/$(BUNDLE_NAME)_processor.js: $(DATA_DIR)/src/processor.js | build/web
cp $^ $@
build/web/${BUNDLE_NAME}.js: ${DATA_DIR}/src/module.js | build/web
build/web/$(BUNDLE_NAME).js: $(DATA_DIR)/src/module.js | build/web
cp $^ $@
build/web build/obj:
@ -100,6 +98,8 @@ build/web build/obj:
clean:
rm -fr build
-include $(COMMON_DIR)/rules-extra.mk
.PHONY: all clean
.SECONDEXPANSION:
@ -107,7 +107,9 @@ clean:
PERCENT := %
$(C_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).c,$$(C_SRCS)) | build/obj
${CC} $^ -o $@ -c ${CFLAGS_ALL}
$(CC) $^ -o $@ -c $(CFLAGS_ALL)
$(CXX_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).cpp,$$(CXX_SRCS)) | build/obj
${CXX} $^ -o $@ -c ${CXXFLAGS_ALL}
$(CXX) $^ -o $@ -c $(CXXFLAGS_ALL)
-include $(COMMON_DIR)/rules-secondexp-extra.mk