xref: /OK3568_Linux_fs/external/security/rk_tee_user/v1/build.sh (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#!/bin/bash
2WORK_DIR_TOP=$(cd `dirname $0` ; pwd)
3
4#./build.sh or ./build.sh 3232 to compile CA TA with 32 bits
5#./build.sh 6432 to compile CA with 64 bits and TA with 32 bits
6#./build.sh ta to compile TA with 32 bits
7
8TOOLCHAIN_PREBUILTS=$WORK_DIR_TOP/../../../../prebuilts
9
10if [ ! -d "$TOOLCHAIN_PREBUILTS" ]; then
11	TOOLCHAIN_PREBUILTS=$WORK_DIR_TOP/../../../prebuilts
12fi
13
14TOOLCHAIN_PATH_ARM32=$TOOLCHAIN_PREBUILTS/gcc/linux-x86/arm/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin
15TOOLCHAIN_PATH_AARCH64=$TOOLCHAIN_PREBUILTS/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin
16CROSS_COMPILE32=arm-linux-gnueabihf-
17CROSS_COMPILE64=aarch64-linux-gnu-
18
19if [ -z "$AARCH64_TOOLCHAIN" ]; then
20	AARCH64_TOOLCHAIN=$TOOLCHAIN_PATH_AARCH64/$CROSS_COMPILE64
21else
22	AARCH64_TOOLCHAIN=`readlink -f $AARCH64_TOOLCHAIN`
23	TOOLCHAIN_PATH_AARCH64=`dirname $AARCH64_TOOLCHAIN`
24fi
25
26if [ -z "$ARM32_TOOLCHAIN" ]; then
27	ARM32_TOOLCHAIN=$TOOLCHAIN_PATH_ARM32/$CROSS_COMPILE32
28else
29	ARM32_TOOLCHAIN=`readlink -f $ARM32_TOOLCHAIN`
30	TOOLCHAIN_PATH_ARM32=`dirname $ARM32_TOOLCHAIN`
31fi
32
33make TA_DEV_KIT_DIR=$WORK_DIR_TOP/export-user_ta clean
34BUILD_CATA_BITS="$1"
35
36if [ "$BUILD_CATA_BITS" == "3264" ] || [ "$BUILD_CATA_BITS" == "6464" ]; then
37	if [ ! -d "${TOOLCHAIN_PATH_AARCH64}" ]; then
38		echo "Toolchain error! Need toolchain: ${TOOLCHAIN_PATH_AARCH64}"
39		echo "You can get it from following address:"
40		echo "https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads"
41		exit
42	fi
43else
44	if [ ! -d "${TOOLCHAIN_PATH_ARM32}" ]; then
45		echo "Toolchain error! Need toolchain: ${TOOLCHAIN_PATH_ARM32}"
46		echo "You can get it from following address:"
47		echo "https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads"
48		exit
49	fi
50fi
51
52if [ "$BUILD_CATA_BITS" == "3232" ]; then
53	export BUILD_CA=y
54	make CROSS_COMPILE_HOST=$ARM32_TOOLCHAIN \
55	CROSS_COMPILE_TA=$ARM32_TOOLCHAIN \
56	CROSS_COMPILE_user_ta=$ARM32_TOOLCHAIN \
57	CROSS_COMPILE=$ARM32_TOOLCHAIN \
58	TA_DEV_KIT_DIR=$WORK_DIR_TOP/export-user_ta \
59	COMPILE_NS_USER=32 \
60	O=$WORK_DIR_TOP/out
61fi
62
63if [ "$BUILD_CATA_BITS" == "6432" ]; then
64	export BUILD_CA=y
65	make CROSS_COMPILE_HOST=$AARCH64_TOOLCHAIN \
66	CROSS_COMPILE_TA=$ARM32_TOOLCHAIN \
67	CROSS_COMPILE_user_ta=$ARM32_TOOLCHAIN \
68	CROSS_COMPILE=$ARM32_TOOLCHAIN \
69	TA_DEV_KIT_DIR=$WORK_DIR_TOP/export-user_ta \
70	COMPILE_NS_USER=64 \
71	O=$WORK_DIR_TOP/out
72fi
73
74if [ "$BUILD_CATA_BITS" == "" ]; then
75	export BUILD_CA=y
76	make CROSS_COMPILE_HOST=$ARM32_TOOLCHAIN \
77	CROSS_COMPILE_TA=$ARM32_TOOLCHAIN \
78	CROSS_COMPILE_user_ta=$ARM32_TOOLCHAIN \
79	CROSS_COMPILE=$ARM32_TOOLCHAIN \
80	TA_DEV_KIT_DIR=$WORK_DIR_TOP/export-user_ta \
81	COMPILE_NS_USER=32 \
82	O=$WORK_DIR_TOP/out
83fi
84if [ "$BUILD_CATA_BITS" == "ta" ]; then
85	make CROSS_COMPILE_HOST=$ARM32_TOOLCHAIN \
86	CROSS_COMPILE_TA=$ARM32_TOOLCHAIN \
87	CROSS_COMPILE_user_ta=$ARM32_TOOLCHAIN \
88	CROSS_COMPILE=$ARM32_TOOLCHAIN \
89	TA_DEV_KIT_DIR=$WORK_DIR_TOP/export-user_ta \
90	COMPILE_NS_USER=32 \
91	O=$WORK_DIR_TOP/out
92fi
93