1#!/bin/bash 2set -e 3ROOT_DIR=$(dirname "$0") 4 5strip_and_copy_to() 6{ 7 if [ "$3" == "clang" ]; 8 then 9 $COMPILER_DIR/bin/llvm-strip $ROOT_DIR/build/$2 10 else 11 if [ "$4" == "linux" ]; 12 then 13 arm-himix410-linux-strip $ROOT_DIR/build/$2 14 else 15 $ROOT_DIR/../../../prebuilts/gcc/linux-x86/arm/arm-linux-ohoseabi-gcc/bin/arm-linux-ohoseabi-strip $ROOT_DIR/build/$2 16 fi 17 fi 18 19 cp $ROOT_DIR/build/$2 $1 20} 21 22copy_to() 23{ 24 if [ -f $ROOT_DIR/build/$2 ];then 25 mkdir -p $1/obj/third_party/wpa_supplicant/wpa_supplicant-2.9 26 cp $ROOT_DIR/build/$2 $1/obj/third_party/wpa_supplicant/wpa_supplicant-2.9/ 27 fi 28} 29 30build_for_ndk() 31{ 32 cp $ROOT_DIR/build/libwpa_client.so $1/ndk/sysroot/usr/lib 33 cp $ROOT_DIR/build/libwpa.so $1/ndk/sysroot/usr/lib 34 cp $ROOT_DIR/src/common/wpa_ctrl.h $1/ndk/sysroot/usr/include 35} 36 37# LIB_TYPE: 0 is static library, 1 is sharedlibrary 38# COMPILER_TYPE gcc or clang 39do_build() 40{ 41 if [ -d "$ROOT_DIR/build/objs" ]; then 42 rm -rf $ROOT_DIR/build/objs 43 fi 44 mkdir -p $ROOT_DIR/build/objs 45 46 make -C $ROOT_DIR/wpa_supplicant/ clean 47 make DEPDIR=$1 COMPILER_TYPE=$3 LIB_TYPE=$2 DEBUG=$4 COMPILER_DIR=$5 KERNEL_TYPE=$6 -C $ROOT_DIR/wpa_supplicant/ -j 48 49 make -C $ROOT_DIR/hostapd/ clean 50 make DEPDIR=$1 COMPILER_TYPE=$3 LIB_TYPE=$2 DEBUG=$4 COMPILER_DIR=$5 KERNEL_TYPE=$6 -C $ROOT_DIR/hostapd/ -j 51 52 make -C $ROOT_DIR/build/ clean 53 make DEPDIR=$1 COMPILER_TYPE=$3 LIB_TYPE=$2 DEBUG=$4 COMPILER_DIR=$5 KERNEL_TYPE=$6 -C $ROOT_DIR/build/ 54 55 if [ "$2" = 1 ]; then 56 strip_and_copy_to $1 libwpa.so $3 $6 57 else 58 copy_to $1 libwpa.a 59 fi 60 61 if [ "$2" = 1 ]; then 62 make DEPDIR=DEPDIR=$1 COMPILER_TYPE=$3 LIB_TYPE=$2 DEBUG=$4 COMPILER_DIR=$5 KERNEL_TYPE=$6 -C $ROOT_DIR/wpa_supplicant/ libwpa_client.so -j 63 strip_and_copy_to $1 libwpa_client.so $3 $6 64 else 65 make DEPDIR=DEPDIR=$1 COMPILER_TYPE=$3 LIB_TYPE=$2 DEBUG=$4 COMPILER_DIR=$5 KERNEL_TYPE=$6 -C $ROOT_DIR/wpa_supplicant/ libwpa_client.a -j 66 copy_to $1 libwpa_client.a 67 fi 68} 69 70main() 71{ 72 OUT_DIR=$1 73 COMPILER_TYPE=$2 74 NDK_FLAG=$3 75 DEBUG=$4 76 COMPILER_DIR=$5 77 KERNEL_TYPE=$6 78 79 if [ "$4" == "debug" ]; then 80 DEBUG=1 81 else 82 DEBUG=0 83 fi 84 85 do_build $OUT_DIR 0 $COMPILER_TYPE $DEBUG $COMPILER_DIR $KERNEL_TYPE 86 do_build $OUT_DIR 1 $COMPILER_TYPE $DEBUG $COMPILER_DIR $KERNEL_TYPE 87 88 if [ "$NDK_FLAG" = true ]; then 89 build_for_ndk $OUT_DIR 90 fi 91} 92 93if [ "x" != "x$7" ]; then 94export SYSROOT_PATH=$7 95fi 96if [ "x" != "x$8" ]; then 97export ARCH_CFLAGS="$8" 98fi 99 100main $1 $2 $3 $4 $5 $6 101