-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·48 lines (41 loc) · 1.31 KB
/
build.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
#/bin/bash
################################################################################
#Input:
# $1: Specified compiler
# (e.g. riscv32-unknown-elf-gcc, riscv32-unknown-elf-clang
# or riscv64-unknown-elf-gcc)
# $2: Extra compilation flags for the library
#
# Example:
# ./build.sh "riscv32-unknown-elf-gcc" "-O0 -g3"
###############################################################################
# set the common compilation flags
CFLAG="-Wall -Werror -O3 -ffunction-sections -fdata-sections -fno-strict-aliasing"
# set the compiler
CC="${1}"
# get the extra compilation flags
if [ -n "${2}" ]; then
CFLAG="${CFLAG} ${2}"
fi
# get the toolchain prefix
if [[ ${CC} == *-* ]]; then
TOOLCHAIN_PREFIX="${CC%-*}-"
else
TOOLCHAIN_PREFIX=""
fi
LIB_ROOT=$(readlink -f `dirname ${0}`)
INCLUDE="-I${LIB_ROOT}/Include -I${LIB_ROOT}/internal"
CFLAG="${CFLAG} ${INCLUDE}"
RELEASE_FOLDER="${LIB_ROOT}/release"
echo "**********************************************"
echo " Building libnn library ..."
echo "**********************************************"
echo
make clean -f ${LIB_ROOT}/Makefile_lib.mak
make -f ${LIB_ROOT}/Makefile_lib.mak CFLAGS="${CFLAG}" CROSS_COMPILE="${TOOLCHAIN_PREFIX}" CC="${CC}"
ret=$?
echo
echo "**********************************************"
echo "Building libnn library done!"
echo
exit $ret