forked from nova-video-player/aos-AVP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.mk
358 lines (287 loc) · 11 KB
/
core.mk
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
#VERBOSE=1
ndk_jobs :=
#ndk_v := NDK_TOOLCHAIN_VERSION=4.9
AVOS_NATIVE_DEPS :=
JAVA_DEPS :=
build_type :=
prev_build_type = $(shell cat $(AVOS_DIR)/obj/build_type 2>/dev/null)
phony_rules :=
native_rules :=
native_clean_rules :=
os := $(shell echo $(shell uname -s) | tr '[:upper:]' '[:lower:]')
ifeq ($(os), darwin)
readlink_prefix := g
# FIXME: current limitation of bigsur
#JAVA18 := $(shell /usr/libexec/java_home -v 1.8)
JAVA_VERSION := $(shell /usr/libexec/java_home -V 2>&1 | grep -v 'Internet Plug-Ins' | gsed -nE -e 's/^ *(1\.8[^ ]*).*$$/\1/p')
JAVA18 := $(shell unset JAVA_HOME; /usr/libexec/java_home -v $(JAVA_VERSION) )
endif
ifeq ($(os), linux)
JAVA18 := $(shell update-alternatives --list java | sed -nE -e 's/(.*java-8[^/]*).*/\1/p')
ifeq (,$(JAVA18))
JAVA18 := $(shell update-alternatives --list java | sed -nE -e 's/(.*jdk-8[^/]*).*/\1/p')
endif
endif
READLINK := $(readlink_prefix)readlink
ndk_ver := 22
ifneq (,$(ANDROID_SDK))
android_sdk := $(ANDROID_SDK)
endif
ifneq (,$(ANDROID_HOME))
android_sdk := $(ANDROID_HOME)
endif
ifneq (,$(ANDROID_SDK_ROOT))
android_sdk := $(ANDROID_SDK_ROOT)
$(info android_sdk is $(android_sdk))
endif
ifneq ($(wildcard $(android_sdk)/ndk/.*),)
android_ndk := $(shell ls -d $(android_sdk)/ndk/* | sort -V | tail -n 1)
endif
ifneq ($(wildcard $(android_sdk)/ndk-bundle/.*),)
android_ndk := $(android_sdk)/ndk-bundle
endif
$(info android_ndk is $(android_ndk))
ifneq (,$(ASAN))
asan := $(ASAN)
endif
ndk_debug :=
ifeq (,$(NDK_CPU_ARM_NEON))
NDK_CPU_ARM_NEON = 1
endif
ifeq (,$(NDK_CPU_X86))
NDK_CPU_X86 = 1
endif
ifeq (,$(NDK_CPU_ARM_64))
NDK_CPU_ARM_64= 1
endif
ifeq (,$(NDK_CPU_X86_64))
NDK_CPU_X86_64 = 1
endif
NDK_APP_ABI :=
ifeq ($(NDK_CPU_ARM_NEON),1)
NDK_APP_ABI += armeabi-v7a
endif
ifeq ($(NDK_CPU_X86),1)
NDK_APP_ABI += x86
endif
ifeq ($(NDK_CPU_ARM_64),1)
NDK_APP_ABI += arm64-v8a
endif
ifeq ($(NDK_CPU_X86_64),1)
NDK_APP_ABI += x86_64
endif
REPO_TOP_DIR := $(shell pwd)
AVOS_DIR := native/avos
FFMPEG_DIR := native/ffmpeg-android-builder
DAV1D_DIR := native/dav1d-android-builder
OPUS_DIR := native/opus-android-builder
NATIVE_PKG_LIST := \
FileCoreLibrary \
native/torrentd \
native/libyuv \
native/libnativehelper
$(foreach PKG,$(NATIVE_PKG_LIST),$(eval PKG_EXTRA_DEPS_$(PKG) := native_build_$(PKG)))
NATIVE_LIST := $(NATIVE_PKG_LIST) \
$(AVOS_DIR)
NATIVE_CLEAN_DEPS_$(AVOS_DIR) := \
native/avos/jni/Android.mk \
native/avos/codecs.mk \
native/avos/main.mk \
native/avos/ndkbuild.mk \
native/avos/avos_config_android.mk \
native/avos/common.mk \
native/avos/sound.mk \
native/avos/fb.mk
ifeq (1,$(VERBOSE))
ndk_v += V=1
endif
ifeq (,$(MAKE_JOBS))
ndk_jobs = -j 12
else
ndk_jobs = -j $(MAKE_JOBS)
endif
ifneq (,$(NDK_DEBUG))
ndk_debug := NDK_DEBUG=$(NDK_DEBUG)
endif
ifeq (DEBUG,$(BUILD))
build_type := debug
endif
ifeq (RELEASE,$(BUILD))
build_type := release
endif
ifeq (,$(build_type))
BUILD := DEBUG
build_type := debug
endif
define gen_native_build
native_rules += native_build_$(1)
native_clean_rules += native_clean_$(1)
ifeq (,NATIVE_CLEAN_DEPS_$(1))
NATIVE_CLEAN_DEPS_$(1):=
endif
$(1)/obj/clean: $(NATIVE_CLEAN_DEPS_$(1))
@if [ -d "$(1)/obj" ]; then \
echo "mk changed; force clean"; \
make native_clean_$(1); \
fi;
native_build_$(1): $(1)/obj/clean
@if [ -n "$(prev_build_type)" -a "$(prev_build_type)" != "$(build_type)" ];then \
echo "BUILD type changed; force clean"; \
make native_clean_$(1); \
fi;
@if [ -d $(1) ];then \
mkdir -p $(1)/obj; \
echo $(build_type) > $(1)/obj/build_type; \
touch $(1)/obj/clean; \
REPO_TOP_DIR=$(REPO_TOP_DIR) BUILD=$(BUILD) NDK_APP_ABI="$(NDK_APP_ABI)" ASAN="$(asan)" android_ndk=$(android_ndk) $(android_ndk)/ndk-build $(ndk_debug) $(ndk_v) $(ndk_jobs) -C $(1); \
fi;
native_clean_$(1):
@if [ -d $(1) ];then \
$(android_ndk)/ndk-build -C $(1) clean; \
rm -rf $(1)/obj; \
rm -rf $(1)/libs/*/*; \
fi;
endef
all: AVP/android-ndk
cd Video; ANDROID_SDK_ROOT=$(android_sdk) PATH=$(android_sdk)/cmdline-tools/tools/bin:$(android_sdk)/tools/bin:$(PATH) ./gradlew aND
AVP/android-ndk:
echo "installing android ndk..."
PATH=$(android_sdk)/cmdline-tools/tools/bin:$(android_sdk)/tools/bin:$$PATH
if [ -z "$(android_sdk)" ]; then sdkmanager ndk-bundle; fi
$(foreach PKG,$(NATIVE_LIST),$(eval $(call gen_native_build,$(PKG))))
.PHONY: $(phony_rules)
define cp_ffmpeg_libs
@if [ "$(NDK_CPU_ARM_NEON)" = "1" ];then \
mkdir -p $(1)/libs/armeabi-v7a; \
cp $(DAV1D_DIR)/build-armeabi-v7a/src/libdav1d.so $(1)/libs/armeabi-v7a/libdav1d.so; \
cp $(OPUS_DIR)/lib/armeabi-v7a/libopus.so $(1)/libs/armeabi-v7a/libopus.so; \
cp -r $(FFMPEG_DIR)/dist-$(2)-armeabi-v7a/lib/*so $(1)/libs/armeabi-v7a; \
fi;
@if [ "$(NDK_CPU_X86)" = "1" ];then \
mkdir -p $(1)/libs/x86; \
cp $(DAV1D_DIR)/build-x86/src/libdav1d.so $(1)/libs/x86/libdav1d.so; \
cp $(OPUS_DIR)/lib/x86/libopus.so $(1)/libs/x86/libopus.so; \
cp -r $(FFMPEG_DIR)/dist-$(2)-x86/lib/*so $(1)/libs/x86; \
fi
@if [ "$(NDK_CPU_ARM_64)" = "1" ];then \
mkdir -p $(1)/libs/arm64-v8a; \
cp $(DAV1D_DIR)/build-arm64-v8a/src/libdav1d.so $(1)/libs/arm64-v8a/libdav1d.so; \
cp $(OPUS_DIR)/lib/arm64-v8a/libopus.so $(1)/libs/arm64-v8a/libopus.so; \
cp -r $(FFMPEG_DIR)/dist-$(2)-arm64-v8a/lib/*so $(1)/libs/arm64-v8a; \
fi
@if [ "$(NDK_CPU_X86_64)" = "1" ];then \
mkdir -p $(1)/libs/x86_64; \
cp $(DAV1D_DIR)/build-x86_64/src/libdav1d.so $(1)/libs/x86_64/libdav1d.so; \
cp $(OPUS_DIR)/lib/x86_64/libopus.so $(1)/libs/x86_64/libopus.so; \
cp -r $(FFMPEG_DIR)/dist-$(2)-x86_64/lib/*so $(1)/libs/x86_64; \
fi
endef
define make_hacks
@if [ "$(ASAN)" != 1 && "$(NDK_CPU_X86)" = "1" ];then \
echo -----------------------------------------; \
echo -----------------------------------------; \
echo create fake _no_neon libs in $(1)/libs/x86 because Intel wants to see the exact same number of ARM and x86 libs otherwise it will Houdini us; \
echo -----------------------------------------; \
echo -----------------------------------------; \
rm -f $(1)/libs/x86/*no_neon*;\
for i in $(1)/libs/armeabi-v7a/*;do \
touch $(1)/libs/x86/$$(basename $$i) ;\
done ;\
if [ "$$(ls $(1)/libs/x86 |wc -l)" != "$$(ls $(1)/libs/armeabi-v7a |wc -l)" ];then echo "Mismatching x86/armeabi-v7a libs"; 1;fi ;\
fi
endef
define make_avos
MAKE_JOBS=$(MAKE_JOBS) BUILD=$(BUILD) $(ndk_debug) NDK_APP_ABI="$(NDK_APP_ABI)" LIBAV_CONFIG=$(2) make native_build_native/avos
@if [ "$(NDK_CPU_ARM_NEON)" = "1" ];then \
mkdir -p $(1)/libs/armeabi-v7a; \
cp -r $(AVOS_DIR)/libs/armeabi-v7a/*so $(1)/libs/armeabi-v7a; \
fi
@if [ "$(NDK_CPU_ARM_NO_NEON)" = "1" ];then \
mkdir -p $(1)/libs/armeabi-v7a; \
cp -r $(AVOS_DIR)/libs/armeabi/*no_neon.so $(1)/libs/armeabi-v7a; \
cp $(AVOS_DIR)/libs/armeabi/libcputest.so $(1)/libs/armeabi-v7a; \
fi
@if [ "$(NDK_CPU_X86)" = "1" ];then \
mkdir -p $(1)/libs/x86; \
cp -r $(AVOS_DIR)/libs/x86/*so $(1)/libs/x86; \
fi
@if [ "$(NDK_CPU_ARM_64)" = "1" ];then \
mkdir -p $(1)/libs/arm64-v8a; \
cp -r $(AVOS_DIR)/libs/arm64-v8a/*so $(1)/libs/arm64-v8a; \
fi
@if [ "$(NDK_CPU_X86_64)" = "1" ];then \
mkdir -p $(1)/libs/x86_64; \
cp -r $(AVOS_DIR)/libs/x86_64/*so $(1)/libs/x86_64; \
fi
$(call make_hacks,$(1),$(2))
endef
native_avos: native_build_native/avos
clean_prebuilt:
rm -rf native/torrentd/libs
rm -rf $(FFMPEG_DIR)/dist-*
rm -rf $(DAV1D_DIR)/build-*
rm -rf $(OPUS_DIR)/lib/*
rm -rf MediaLib/libs/trakt-java.jar
rm -rf MediaLib/libs/cling-*-2.1.2.jar
rm -rf MediaLib/libs/seamless-*-1.1.2.jar
rm -rf FileCoreLibrary/libs/jcifs-ng.jar
$(FFMPEG_DIR)/dist-full-arm64-v8a/lib/libavcodec.so:
make native_build_native/ffmpeg-android-builder
native_avos_base: $(FFMPEG_DIR)/dist-full-arm64-v8a/lib/libavcodec.so
$(call cp_ffmpeg_libs,MediaLib,base)
$(call make_avos,MediaLib,base)
native_avos_full: native_build_native/ffmpeg-android-builder
$(call cp_ffmpeg_libs,MediaLib,full)
$(call make_avos,MediaLib,full)
native_build_native/ffmpeg-android-builder: native_build_native/dav1d-android-builder native_build_native/opus-android-builder
cd native/ffmpeg-android-builder; REPO_TOP_DIR=$(REPO_TOP_DIR) bash bootstrap_avp_ffmpeg.sh
native_build_native/dav1d-android-builder:
cd native/dav1d-android-builder; REPO_TOP_DIR=$(REPO_TOP_DIR) bash bootstrap_avp_dav1d.sh
native_build_native/opus-android-builder:
cd native/opus-android-builder; REPO_TOP_DIR=$(REPO_TOP_DIR) bash build.sh
native_build_native/torrentd: native_build_native/boost native_build_native/libtorrent
native_build_native/boost:
cd native/boost; REPO_TOP_DIR=$(REPO_TOP_DIR) bash bootstrap_avp_boost.sh
native_build_native/libtorrent:
cd native/libtorrent-android-builder; REPO_TOP_DIR=$(REPO_TOP_DIR) bash bootstrap_libtorrent.sh
native/torrentd/libs/arm64-v8a/torrentd:
make native_build_native/torrentd
native_torrentd: native/torrentd/libs/arm64-v8a/torrentd
rm -f MediaLib/libs/armeabi/libtorrentd.so ;\
for i in armeabi-v7a arm64-v8a x86 x86_64;do \
mkdir -p MediaLib/libs/$$i ;\
cp native/torrentd/libs/$$i/torrentd MediaLib/libs/$$i/libtorrentd.so ;\
done
trakt-java: MediaLib/libs/trakt-java.jar
jcifs-ng: FileCoreLibrary/libs/jcifs-ng.jar
cling-objects = MediaLib/libs/cling-core-2.1.2.jar MediaLib/libs/cling-support-2.1.2.jar
seamless-objects = MediaLib/libs/seamless-util-1.1.2.jar MediaLib/libs/seamless-http-1.1.2.jar MediaLib/libs/seamless-xml-1.1.2.jar MediaLib/libs/seamless-swing-1.1.2.jar
seamless: $(seamless-objects)
cling: $(cling-objects)
MediaLib/libs/cling-core-2.1.2.jar:
MediaLib/libs/cling-support-2.1.2.jar:
cd external/cling; JAVA_HOME="$(JAVA18)" mvn install -Dmaven.source.skip -DskipTests -Dmaven.javadoc.skip=true && mv */target/cling*2.1.2.jar ../../MediaLib/libs
MediaLib/libs/seamless-util-1.1.2.jar:
MediaLib/libs/seamless-http-1.1.2.jar:
MediaLib/libs/seamless-xml-1.1.2.jar:
MediaLib/libs/seamless-swing-1.1.2.jar:
cd external/seamless; JAVA_HOME="$(JAVA18)" mvn install -Dmaven.source.skip -DskipTests -Dmaven.javadoc.skip=true && mv */target/seamless*1.1.2.jar ../../MediaLib/libs
FileCoreLibrary/libs/jcifs-ng.jar:
cd external/jcifs-ng; mvn install -Dmaven.source.skip -DskipTests -Dmaven.javadoc.skip=true -Dgpg.skip=true && mv ./target/jcifs-ng-*.jar ../../FileCoreLibrary/libs/jcifs-ng.jar
MediaLib/libs/trakt-java.jar:
cd external/trakt-java; mvn install -Dmaven.source.skip -DskipTests -Dmaven.javadoc.skip=true && mv ./target/trakt-java-*.jar ../../MediaLib/libs/trakt-java.jar
external_build: jcifs-ng seamless cling
external_clean: external_clean_jcifs-ng external_clean_cling external_clean_seamless
external_clean_jcifs-ng:
cd external/jcifs-ng; mvn clean; rm -f ../../FileCoreLibrary/libs/jcifs-ng.jar
external_clean_trakt-java:
cd external/trakt-java; mvn clean; rm -f ../../MediaLib/libs/trakt-java.jar
external_clean_cling:
cd external/cling; mvn clean; rm -f ../../MediaLib/libs/cling*-2.1.2.jar
external_clean_seamless:
cd external/seamless; mvn clean; rm -f ../../MediaLib/libs/seamless*-1.1.2.jar
native_libyuv: native_build_native/libyuv
native_libnativehelper: native_build_native/libnativehelper
native : $(native_rules)
native_clean: $(native_clean_rules)
clean: native_clean external_clean