forked from randombit/botan
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build_android_mk.sh
executable file
·61 lines (51 loc) · 1.97 KB
/
build_android_mk.sh
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
#!/bin/bash
EXTERNAL_INCLUDEDIR=$1
ABI=$2
function android_mk {
echo 'LOCAL_PATH := $(call my-dir)' > $1
echo '' >> $1
# target libbotan
echo 'include $(CLEAR_VARS)' >> $1
echo 'LOCAL_CLANG := true' >> $1
echo 'LOCAL_ARM_NEON := true' >> $1
echo 'LOCAL_MODULE := libbotan' >> $1
echo 'LOCAL_CPP_EXTENSION := .cpp' >> $1
echo 'LOCAL_CPP_FEATURES := rtti exceptions' >> $1
echo 'LOCAL_CPPFLAGS := -fvisibility=hidden' >> $1
echo 'LOCAL_C_INCLUDES := $(LOCAL_PATH)/build/include' $2 >> $1
echo 'LOCAL_SRC_FILES := \' >> $1
# - write cpp files for target libbotan
grep "^build/obj/lib" Makefile | sed "s/build\/obj\/lib\/[^:]\+: /\t/" | sed "s/$/ \\\\/" >> $1
echo '' >> $1
echo 'include $(BUILD_SHARED_LIBRARY)' >> $1
echo '' >> $1
# target botan-test
echo 'include $(CLEAR_VARS)' >> $1
echo 'LOCAL_CLANG := true' >> $1
echo 'LOCAL_MODULE := botan-test' >> $1
echo 'LOCAL_CPP_EXTENSION := .cpp' >> $1
echo 'LOCAL_CPP_FEATURES := rtti exceptions' >> $1
echo 'LOCAL_C_INCLUDES := $(LOCAL_PATH)/build/include' $2 >> $1
echo 'LOCAL_SHARED_LIBRARIES := libbotan' >> $1
echo 'LOCAL_SRC_FILES := \' >> $1
# - write cpp files for target botan-test
grep "^build/obj/test" Makefile | sed "s/build\/obj\/test\/[^:]\+: /\t/" | sed "s/$/ \\\\/" >> $1
echo '' >> $1
echo 'include $(BUILD_EXECUTABLE)' >> $1
}
function application_mk {
echo 'NDK_TOOLCHAIN_VERSION := clang' > $1
echo 'APP_CPPFLAGS := -D_REENTRANT -Wall -Wextra -Wpedantic -Wshadow -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wunreachable-code -Wno-gnu-include-next' >> $1
echo 'APP_ABI :=' $2 >> $1
echo 'APP_PLATFORM = android-23' >> $1
echo 'APP_STL := c++_static' >> $1
}
# START
echo "Generating Android.mk"
# Construct Android.mk out of the generated Makefile
android_mk Android.mk $EXTERNAL_INCLUDEDIR
echo "Generating botan.mk for the NDK build"
# Construct Application.mk for NDK build
application_mk botan.mk $ABI
# Create link to jni
ln -sfn . jni