aboutsummaryrefslogtreecommitdiff
path: root/tools/android/packaging/Makefile.in
blob: d3a4d17c625a3cd445a7fec1518c76d2497fffea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
include ../../depends/Makefile.include

BUILD_TYPE:=@CMAKE_BUILD_TYPE@
BUILD_TYPE_LC:=$(shell echo $(BUILD_TYPE) | tr A-Z a-z)

OBJS = libshairplay.so \
  libass.so

PLATFORM_OBJS =
EXCLUDED_ADDONS =

CMAKE_SOURCE_DIR = $(shell cd $(CURDIR)/../../..; pwd)
APP_PACKAGE_DIR = $(subst .,/,@APP_PACKAGE@)
COPYDIRS = system addons media
GCC_VERSION=$(shell $(CC) -dumpversion)
ZIP=zip

ifeq ($(KODI_ANDROID_STORE_FILE),)
export KODI_ANDROID_STORE_FILE:=$(HOME)/.android/debug.keystore
endif

ifeq ($(KODI_ANDROID_STORE_PASSWORD),)
export KODI_ANDROID_STORE_PASSWORD:=android
endif

ifeq ($(KODI_ANDROID_KEY_ALIAS),)
export KODI_ANDROID_KEY_ALIAS:=androiddebugkey
endif

ifeq ($(KODI_ANDROID_KEY_PASSWORD),)
export KODI_ANDROID_KEY_PASSWORD:=android
endif

#this fixes a android ndk fuckup where the paths to
#prebuilt stuff follow different name schemes for
#arm and x86
ifeq ($(findstring x86_64,$(CPU)),x86_64)
  ARCH=x86_64
else ifeq ($(findstring x86,$(CPU)),x86)
  ARCH=x86
else ifeq ($(findstring arm64,$(CPU)),arm64)
  ARCH=arm64
else ifeq ($(findstring arm,$(CPU)),arm)
  ARCH=arm
endif

# libc++
STLLIB=$(TOOLCHAIN)/sysroot/usr/lib/$(HOST)/libc++_shared.so

# check for java 1.8
JAVA8=$(shell java -version 2>&1 | grep -q '1.8.[0-9]' && echo yes)
ifeq ($(JAVA8),yes)
  JAVAC_EXTRA_ARGS = -source 1.7 -target 1.7
endif

SRCLIBS = $(addprefix $(PREFIX)/lib/,$(OBJS))
DSTLIBS = $(CPU)/lib/lib@APP_NAME_LC@.so $(addprefix $(CPU)/lib/,$(OBJS)) $(addprefix $(CPU)/lib/,$(PLATFORM_OBJS))
libs= $(DSTLIBS)

all: apk

apk: apk-clean sharedapk package

obb: apk-clean sharedobb

apk-obb: apk-clean sharedobb package

xbmc/assets:
	mkdir -p xbmc/assets

shared:
	mkdir -p assets
	cp -rfp $(PREFIX)/share/@APP_NAME_LC@/* ./assets
	cp -rfp $(DEPENDS_PATH)/share/kodi/* ./assets || true
	find `pwd`/assets/ -depth -name ".git" -exec rm -rf {} \;
	find `pwd`/assets/ -name "*.so" -exec rm {} \;
	find `pwd`/assets/addons/skin.*/media/* -depth -not -iname "Textures.xbt" -exec rm -rf {} \;
	cd `pwd`/assets/addons; rm -rf $(EXCLUDED_ADDONS)
	cp $(CMAKE_SOURCE_DIR)/privacy-policy.txt assets

sharedapk: shared | xbmc/assets
	cp -rfp assets/* ./xbmc/assets

sharedobb: shared
	rm -f $(CMAKE_SOURCE_DIR)/main.@APP_NAME_LC@.obb
	$(ZIP) -9 -q -r $(CMAKE_SOURCE_DIR)/main.@APP_NAME_LC@.obb assets
	@echo "$(CMAKE_SOURCE_DIR)/main.@APP_NAME_LC@.obb created"

python: | xbmc/assets
	mkdir -p xbmc/assets/python@PYTHON_VERSION@/lib/
	cp -rfp $(PREFIX)/lib/python@PYTHON_VERSION@ xbmc/assets/python@PYTHON_VERSION@/lib/
	cd xbmc/assets/python@PYTHON_VERSION@/lib/python@PYTHON_VERSION@/; rm -rf test config config-@PYTHON_VERSION@ lib-dynload ; find . -name "*.so" -exec rm -f {} \;

res:
	mkdir -p xbmc/res xbmc/res/raw xbmc/res/values images
	@echo "native_arch=$(CPU)" > xbmc/res/raw/xbmc.properties
	cp -fp $(CMAKE_SOURCE_DIR)/media/splash.* xbmc/res/drawable/
	cp -fp media/drawable-hdpi/ic_launcher.png xbmc/res/drawable-hdpi/ic_launcher.png
	cp -fp media/drawable-ldpi/ic_launcher.png xbmc/res/drawable-ldpi/ic_launcher.png
	cp -fp media/drawable-mdpi/ic_launcher.png xbmc/res/drawable-mdpi/ic_launcher.png
	cp -fp media/drawable-xhdpi/ic_launcher.png xbmc/res/drawable-xhdpi/ic_launcher.png
	cp -fp media/drawable-xxhdpi/ic_launcher.png xbmc/res/drawable-xxhdpi/ic_launcher.png
	cp -fp $(CMAKE_SOURCE_DIR)/media/splash.* xbmc/res/drawable-xxxhdpi/
	cp -fp media/drawable-xxxhdpi/ic_launcher.png xbmc/res/drawable-xxxhdpi/ic_launcher.png
	cp -fp media/drawable-xhdpi/banner.png xbmc/res/drawable-xhdpi/banner.png
	cp -fp $(CMAKE_SOURCE_DIR)/media/icon80x80.png xbmc/res/drawable/ic_recommendation_80dp.png
	cp xbmc/strings.xml xbmc/res/values/
	cp xbmc/colors.xml xbmc/res/values/
	cp xbmc/searchable.xml xbmc/res/xml/

libs: $(PREFIX)/lib/@APP_NAME_LC@/lib@APP_NAME_LC@.so
	rm -rf xbmc/lib/$(CPU) xbmc/obj/local/$(CPU)
	mkdir -p xbmc/lib/$(CPU) xbmc/assets/python@PYTHON_VERSION@/lib/ xbmc/obj/local/$(CPU)
	cp -fpL $(SRCLIBS) xbmc/obj/local/$(CPU)/
	cp -fp $(PREFIX)/lib/@APP_NAME_LC@/lib@APP_NAME_LC@.so xbmc/obj/local/$(CPU)/
	find $(PREFIX)/lib/@APP_NAME_LC@/addons -name "*.so" -exec cp -fp {} xbmc/obj/local/$(CPU)/ \; || true
	find $(PREFIX)/share/@APP_NAME_LC@/addons -name "*.so" -exec cp -fp {} xbmc/obj/local/$(CPU)/ \; || true
	find $(DEPENDS_PATH)/share/kodi/addons -name "*.so" -exec cp -fp {} xbmc/obj/local/$(CPU)/ \; || true
	find $(DEPENDS_PATH)/lib/kodi/addons -name "*.so" -exec cp -fp {} xbmc/obj/local/$(CPU)/ \; || true
	find $(PREFIX)/lib/@APP_NAME_LC@/system -name "*.so" -exec cp -fp {} xbmc/obj/local/$(CPU)/ \;
	DIR=${CURDIR}; cd $(PREFIX)/lib/python@PYTHON_VERSION@/site-packages; for i in `find Cryptodome -name \*.so` ; do FN=`echo $$i | cut -c1- | tr "/" "_" | sed -e 's/\.cpython-[0-9]\{2,3\}-.*\\./\./g' -e 's/\.abi[0-9]\\././'` ;cp $$i $$DIR/xbmc/obj/local/$(CPU)/$$FN ; done
	cd xbmc/obj/local/$(CPU)/; find . -name "*.so" -not -name "lib*.so" | sed "s/\.\///" | xargs -I@ mv @ lib@
	cp -fp xbmc/obj/local/$(CPU)/*.so xbmc/lib/$(CPU)/
	$(STRIP) --strip-unneeded xbmc/lib/$(CPU)/*.so
	(test -s $(STLLIB) && install -p $(STLLIB) ./xbmc/lib/$(CPU)/) || true

java: res
	mkdir -p xbmc/java/$(APP_PACKAGE_DIR) xbmc/obj
	@cp -R xbmc/src/* xbmc/java/$(APP_PACKAGE_DIR)/

package: libs python java
	@echo "Gradle build and sign..."
	ANDROID_HOME=$(SDKROOT) ./gradlew assemble$(BUILD_TYPE)
	@cp xbmc/build/outputs/apk/$(BUILD_TYPE_LC)/xbmc-$(BUILD_TYPE_LC).apk $(CMAKE_SOURCE_DIR)/@APP_NAME_LC@app-$(CPU)-$(BUILD_TYPE_LC).apk

$(PREFIX)/lib/xbmc/lib@APP_NAME_LC@.so: $(SRCLIBS)
	$(MAKE) -C ../../depends/target/xbmc

$(SRCLIBS):

apk-clean:
	rm -rf images
	rm -rf xbmc/java
	rm -rf xbmc/lib
	rm -rf xbmc/assets
	rm -rf xbmc/obj
	rm -rf xbmc/res/raw
	rm -rf xbmc/res/values
	rm -f xbmc/res/drawable/splash.*
	rm -f xbmc/res/drawable-xxxhdpi/splash.*
	rm -rf assets

.PHONY: force libs assets python sharedapk sharedobb res package