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-01-23 08:22:00 +00:00
|
|
|
include vars.mk
|
|
|
|
|
2024-01-23 14:18:39 +00:00
|
|
|
ifeq (${HAS_MIDI_IN}, yes)
|
|
|
|
MIN_API := 29
|
|
|
|
else
|
|
|
|
MIN_API := 26
|
|
|
|
endif
|
|
|
|
|
2024-02-03 06:06:58 +00:00
|
|
|
CC = ${ANDROID_NDK_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi${MIN_API}-clang
|
2024-01-23 14:18:39 +00:00
|
|
|
CXX = ${ANDROID_NDK_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi${MIN_API}-clang++
|
2024-02-03 06:06:58 +00:00
|
|
|
JC = javac
|
2024-01-23 08:22:00 +00:00
|
|
|
|
|
|
|
APKSIGNER = ${BUILD_TOOLS_DIR}/apksigner
|
|
|
|
ZIPALIGN = ${BUILD_TOOLS_DIR}/zipalign
|
|
|
|
AAPT = ${BUILD_TOOLS_DIR}/aapt
|
|
|
|
D8 = ${BUILD_TOOLS_DIR}/d8
|
2024-01-23 09:39:30 +00:00
|
|
|
ADB = ${ANDROID_SDK_DIR}/platform-tools/adb
|
2024-01-23 08:22:00 +00:00
|
|
|
|
|
|
|
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}
|
|
|
|
|
2024-01-23 09:39:30 +00:00
|
|
|
CLASSES_PATH := $(subst .,/,$(JAVA_PACKAGE_NAME))
|
2024-01-23 08:22:00 +00:00
|
|
|
|
2024-01-23 14:18:39 +00:00
|
|
|
CLASSES := \
|
|
|
|
MainActivity \
|
|
|
|
MainActivity$$WebAppInterface
|
2024-01-28 10:54:30 +00:00
|
|
|
ifeq (${HAS_MIDI_IN}, yes)
|
|
|
|
CLASSES += MainActivity$$WebAppInterface$$MidiDeviceCallback MainActivity$$WebAppInterface$$1
|
|
|
|
endif
|
|
|
|
|
2024-02-01 08:55:06 +00:00
|
|
|
COMMON_DIR := $(or $(COMMON_DIR),.)
|
|
|
|
DATA_DIR := $(or $(DATA_DIR),.)
|
|
|
|
PLUGIN_DIR := $(or $(PLUGIN_DIR),src)
|
|
|
|
|
2024-02-03 06:06:58 +00:00
|
|
|
CFLAGS = -O3 -Wall -Wpedantic -Wextra
|
|
|
|
CFLAGS_ALL = -I${DATA_DIR}/src -I${PLUGIN_DIR} -fPIC ${CFLAGS} ${CFLAGS_EXTRA}
|
2024-01-31 08:14:18 +00:00
|
|
|
|
2024-02-03 06:06:58 +00:00
|
|
|
CXXFLAGS = ${CFLAGS}
|
|
|
|
CXXFLAGS_ALL = -I${DATA_DIR}/src -I${PLUGIN_DIR} -fPIC -std=c++11 ${CXXFLAGS} ${CXXFLAGS_EXTRA}
|
2024-01-23 08:22:00 +00:00
|
|
|
|
2024-01-31 08:14:18 +00:00
|
|
|
LDFLAGS =
|
2024-02-20 10:23:09 +00:00
|
|
|
LDFLAGS_ALL = -shared -static-libstdc++ -landroid
|
2024-01-28 10:54:30 +00:00
|
|
|
ifeq (${HAS_MIDI_IN}, yes)
|
|
|
|
LDFLAGS += -lamidi
|
|
|
|
endif
|
2024-01-31 08:14:18 +00:00
|
|
|
LDFLAGS_ALL += ${LDFLAGS} ${LDFLAGS_EXTRA}
|
2024-01-28 10:54:30 +00:00
|
|
|
|
2024-02-03 06:06:58 +00:00
|
|
|
JFLAGS =
|
|
|
|
JFLAGS_ALL = ${JFLAGS} ${JFLAGS_EXTRA}
|
|
|
|
|
|
|
|
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}
|
2024-02-01 19:51:02 +00:00
|
|
|
CXX_OBJS = $(addprefix build/obj/, $(notdir $(CXX_SRCS:.cpp=.o)))
|
2024-02-01 19:48:22 +00:00
|
|
|
|
2024-01-23 08:22:00 +00:00
|
|
|
all: build/${BUNDLE_NAME}.apk
|
|
|
|
|
|
|
|
build/${BUNDLE_NAME}.apk: build/gen/${BUNDLE_NAME}.aligned.apk ${KEY_STORE}
|
2024-01-23 09:39:30 +00:00
|
|
|
${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
|
2024-01-23 08:22:00 +00:00
|
|
|
|
|
|
|
build/gen/${BUNDLE_NAME}.aligned.apk: build/gen/${BUNDLE_NAME}.unsigned.apk
|
|
|
|
${ZIPALIGN} -f -p 4 $^ $@
|
|
|
|
|
2024-02-01 08:55:06 +00:00
|
|
|
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
|
2024-01-23 08:22:00 +00:00
|
|
|
|
|
|
|
build/apk/classes.dex: build/apk/my_classes.jar
|
|
|
|
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
|
2024-01-23 09:39:30 +00:00
|
|
|
@echo ${CLASSES_PATH}
|
2024-01-23 08:22:00 +00:00
|
|
|
${D8} $(foreach class,$(CLASSES),'build/obj/$(CLASSES_PATH)/$(class).class') --min-api ${MIN_API} --output $@ --no-desugaring
|
|
|
|
|
2024-02-01 08:55:06 +00:00
|
|
|
build/obj/${CLASSES_PATH}/MainActivity.class: ${DATA_DIR}/src/MainActivity.java | build/obj
|
|
|
|
${JC} ${JFLAGS_ALL} -classpath "$(subst $() $(),:,$(JARS))" -d build/obj $^
|
2024-01-23 08:22:00 +00:00
|
|
|
|
2024-02-03 06:06:58 +00:00
|
|
|
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}
|
2024-01-23 14:18:39 +00:00
|
|
|
|
2024-02-01 08:55:06 +00:00
|
|
|
build/assets/index.html: ${DATA_DIR}/src/index.html | build/assets
|
2024-01-23 09:39:30 +00:00
|
|
|
cp $^ $@
|
|
|
|
|
2024-01-23 14:18:39 +00:00
|
|
|
build/gen build/apk build/obj build/apk/lib/armeabi-v7a build/assets:
|
2024-01-23 08:22:00 +00:00
|
|
|
mkdir -p $@
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -fr build
|
|
|
|
|
|
|
|
install: build/${BUNDLE_NAME}.apk
|
2024-01-23 09:39:30 +00:00
|
|
|
[ -n "`${ADB} shell pm list packages | grep ^package:${JAVA_PACKAGE_NAME}`" ] && ${ADB} uninstall ${JAVA_PACKAGE_NAME}; exit 0
|
2024-01-23 08:22:00 +00:00
|
|
|
${ADB} install $^
|
|
|
|
|
|
|
|
.PHONY: all clean install
|
2024-02-03 06:06: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}
|