diff --git a/templates/android-make/Makefile b/templates/android-make/Makefile index 03618b7..a0443ca 100644 --- a/templates/android-make/Makefile +++ b/templates/android-make/Makefile @@ -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 diff --git a/templates/cmd-make/Makefile b/templates/cmd-make/Makefile index 073799e..c75a5bd 100644 --- a/templates/cmd-make/Makefile +++ b/templates/cmd-make/Makefile @@ -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 diff --git a/templates/daisy-seed-make/Makefile b/templates/daisy-seed-make/Makefile index 9975da7..d901154 100644 --- a/templates/daisy-seed-make/Makefile +++ b/templates/daisy-seed-make/Makefile @@ -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 diff --git a/templates/ios-make/Makefile b/templates/ios-make/Makefile index ae15b94..4d84418 100644 --- a/templates/ios-make/Makefile +++ b/templates/ios-make/Makefile @@ -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 diff --git a/templates/lv2-make/Makefile b/templates/lv2-make/Makefile index 9e24679..68b19d4 100644 --- a/templates/lv2-make/Makefile +++ b/templates/lv2-make/Makefile @@ -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 diff --git a/templates/vst3-make/Makefile b/templates/vst3-make/Makefile index 75ba37f..1f0eb6d 100644 --- a/templates/vst3-make/Makefile +++ b/templates/vst3-make/Makefile @@ -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 diff --git a/templates/web-demo/web-extra.mk b/templates/web-demo/rules-extra.mk similarity index 93% rename from templates/web-demo/web-extra.mk rename to templates/web-demo/rules-extra.mk index 9414cc3..0232124 100644 --- a/templates/web-demo/web-extra.mk +++ b/templates/web-demo/rules-extra.mk @@ -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 $^ $@ diff --git a/templates/web-demo/tibia-index.js b/templates/web-demo/tibia-index.js index 42b8a8d..9cefaa8 100644 --- a/templates/web-demo/tibia-index.js +++ b/templates/web-demo/tibia-index.js @@ -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`); }; diff --git a/templates/web-demo/vars-extra.mk b/templates/web-demo/vars-extra.mk new file mode 100644 index 0000000..59f5792 --- /dev/null +++ b/templates/web-demo/vars-extra.mk @@ -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 . +# +# File author: Stefano D'Angelo +# + +ALL := $(ALL) build/web/index.html build/web/cert.pem build/web/key.pem diff --git a/templates/web-make/Makefile b/templates/web-make/Makefile index eaf770c..93b329f 100644 --- a/templates/web-make/Makefile +++ b/templates/web-make/Makefile @@ -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