File: Makefile.android

package info (click to toggle)
fluidsynth 2.4.4%2Bdfsg-1%2Bdeb13u1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,328 kB
  • sloc: ansic: 43,529; cpp: 1,434; xml: 1,020; makefile: 71; sh: 46
file content (141 lines) | stat: -rw-r--r-- 4,774 bytes parent folder | download | duplicates (3)
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
#
# The public targets in this Makefile are: build, clean, wipe
#
# What `build` target does:
#
# - build cerbero to build glib, libogg, libvorbis, libflac, and libsndfile.
# - build glib-2.0.so and many other dependency shared libraries
# - build Oboe shared library
# - build libfluidsynth.so
# - build libfluidsynth-assetloader.so
#
# Android app developers are supposed to copy all those shared
# libraries into their apks (per ABI).
#
PWD=$(shell pwd)
CERBERO=$(PWD)/external/cerbero
OBOE=$(PWD)/external/oboe
CMAKE=cmake
JOBS=$(shell nproc)

ANDROID_NDK = $(PWD)/external/cerbero/build/android-ndk-21

ABIS_SIMPLE = x86 x86-64 armv7 arm64


DIST_PATH=$(CERBERO)/build/dist
OBOE_BUILD_PATH=$(OBOE)/build

all: build

.PHONY: prepare
prepare: checkout-oboe checkout-cerbero
	for abi in $(ABIS_SIMPLE) ; do \
		cd $(CERBERO) && ./cerbero-uninstalled -c config/cross-android-$$abi.cbc bootstrap --jobs $(JOBS) && cd $(PWD) ; \
	done

.PHONY: checkout-oboe
checkout-oboe: $(OBOE)
	cd $(OBOE) && git checkout 1.5.0

$(OBOE):
	git clone https://github.com/Google/oboe.git $(OBOE) 

.PHONY: checkout-cerbero
checkout-cerbero: $(CERBERO)
	cd $(CERBERO) && git checkout e9f18b3b340de1648d885a0542d2f06c3fcfffe8

$(CERBERO):
	git clone https://github.com/falrm/cerbero.git $(CERBERO)

.PHONY: build
build: build-oboe dist-oboe build-deps-cerbero dist-deps-cerbero build-fluidsynth dist-fluidsynth build-fluidsynth-assetloader dist-fluidsynth-assetloader

.PHONY: build-deps-cerbero
build-deps-cerbero:
	for abi in $(ABIS_SIMPLE) ; do \
		cd $(CERBERO) && ./cerbero-uninstalled -c config/cross-android-$$abi.cbc build --jobs $(JOBS) glib libsndfile && cd $(PWD) ; \
	done

define run_make_abi_target
	make -f Makefile.android BUILD_ABI=$(1) A_ABI=$(2) $(3)
endef
define run_make_abi_target-unsafe
	if make -f Makefile.android BUILD_ABI=$(1) A_ABI=$(2) $(3) ; then \
		echo "ignore failure for $(1)..." ; \
	fi
endef

define run_make_for_all_abi
	$(call run_make_abi_target,x86,x86,$(1) )
	$(call run_make_abi_target,x86_64,x86_64,$(1) )
	$(call run_make_abi_target,armv7,armeabi-v7a,$(1) )
	$(call run_make_abi_target-unsafe,arm64,arm64-v8a,$(1) )
endef

.PHONY: dist-deps-cerbero
dist-deps-cerbero:
	$(call run_make_for_all_abi, dist-deps-cerbero-one)

.PHONY: dist-fluidsynth
dist-fluidsynth:
	$(call run_make_for_all_abi, dist-fluidsynth-one)

.PHONY: build-oboe
build-oboe:
	$(call run_make_for_all_abi, build-oboe-one)

.PHONY: dist-oboe
dist-oboe:
	$(call run_make_for_all_abi, dist-oboe-one)

.PHONY: build-fluidsynth
build-fluidsynth:
	$(call run_make_for_all_abi, build-fluidsynth-one)

build-fluidsynth-one:
	mkdir -p build/$(A_ABI) && cd build/$(A_ABI) && \
	LD_RUN_PATH=$(DIST_PATH)/android-$(BUILD_ABI)/lib:$(OBOE_BUILD_PATH)/$(A_ABI) \
	LD_LIBRARY_PATH=$(DIST_PATH)/android_$(BUILD_ABI)/lib \
	PKG_CONFIG_PATH=$(DIST_PATH)/android_$(BUILD_ABI)/lib/pkgconfig/:$(OBOE_BUILD_PATH)/$(A_ABI) \
	PKG_CONFIG_LIBDIR=$(DIST_PATH)/android_$(BUILD_ABI)/lib/pkgconfig/:$(OBOE_BUILD_PATH)/$(A_ABI) \
	$(CMAKE) -DCMAKE_INSTALL_PREFIX=$(PWD)/dist/$(A_ABI) \
		-Denable-floats=1 \
		-DCMAKE_VERBOSE_MAKEFILE=1 \
		-DCMAKE_TOOLCHAIN_FILE=$(ANDROID_NDK)/build/cmake/android.toolchain.cmake \
		-Denable-opensles=on -Denable-oboe=on -Denable-oss=off -Denable-libsndfile=on \
		-DANDROID_NATIVE_API_LEVEL=android-27 -DANDROID_PLATFORM=android-27 -DANDROID_ABI=$(A_ABI) ../../../.. && \
	make -j$(JOBS)

build-oboe-one:
	mkdir -p $(OBOE)/build/$(A_ABI) && cd $(OBOE)/build/$(A_ABI) && \
		$(CMAKE) -DCMAKE_TOOLCHAIN_FILE=$(ANDROID_NDK)/build/cmake/android.toolchain.cmake -DANDROID_ABI=$(A_ABI) -DANDROID_NATIVE_API_LEVEL=android-27 -DANDROID_PLATFORM=android-27 -DBUILD_SHARED_LIBS=on ../.. && make -j$(JOBS)
	cp oboe-1.0.pc $(OBOE)/build/$(A_ABI)

dist-oboe-one:
	mkdir -p dist/$(A_ABI) && cp $(OBOE)/build/$(A_ABI)/*.so dist/$(A_ABI)/

dist-deps-cerbero-one:
	mkdir -p dist/$(A_ABI) && cd dist/$(A_ABI) && cp ../../external/cerbero/build/dist/android_$(BUILD_ABI)/lib/*.so . && cd ../..	

dist-fluidsynth-one:
	mkdir -p dist/$(A_ABI) && cd dist/$(A_ABI) && cp ../../build/$(A_ABI)/src/libfluidsynth.so . && cd ../..
	cp -r ../../include/fluidsynth build/$(A_ABI)/include/

build-fluidsynth-assetloader:
	cd fluidsynth-assetloader && ./ext-build.sh

dist-fluidsynth-assetloader:
	cp fluidsynth-assetloader/build/x86/*.so dist/x86/
	cp fluidsynth-assetloader/build/x86_64/*.so dist/x86_64/
	cp fluidsynth-assetloader/build/armeabi-v7a/*.so dist/armeabi-v7a/
	cp fluidsynth-assetloader/build/arm64-v8a/*.so dist/arm64-v8a/

clean:
	rm -rf dist/* build/* external/oboe/build/* obj/local/* fluidsynth-asset-loader/build/*

.PHONY: wipe
wipe: $(CERBERO)
	for abi in $(ABIS_SIMPLE) ; do \
		cd $(CERBERO) && ./cerbero-uninstalled -c config/cross-android-$$abi.cbc wipe && cd ../.. ; \
	done