export BASE_DIR=$PWD
export HOST=x86_64-linux-gnu
export TARGET=arm-hisiv600-linux-gnueabi
export TARDIR=$BASE_DIR/install/arm-hisiv600-linux
export SYSROOT=$TARDIR/target
export PATH=$TARDIR/bin:$PATH

GLIBC_DIR=glibc-linaro-2.20-2014.11

rm -rf $BASE_DIR/glibc_build
mkdir $BASE_DIR/glibc_build
pushd $BASE_DIR/glibc_build
BUILD_CC="gcc" CC="$TARDIR/bin/$TARGET-gcc -mcpu=cortex-a17.cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4" CXX="$TARDIR/bin/$TARGET-g++ -mcpu=cortex-a17.cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4" CFLAGS="-g -O2" ../$GLIBC_DIR/configure --prefix=/usr --with-headers=$SYSROOT/usr/include/ --build=$HOST  --host=$TARGET --enable-profile --without-gd --without-cvs --disable-multi-arch --enable-obsolete-rpc --enable-add-ons libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes libc_cv_ctors_header=yes --enable-kernel=2.6.32 '--with-pkgversion=Hisilicon_v600_20180630' --with-bugurl=http://www.hisilicon.com/cn/service/claim.html|tee chh_config.log
make install_root=$SYSROOT install-bootstrap-headers=yes install-headers
mkdir -p $SYSROOT/usr/lib/a17_a7_softfp_neon-vfpv4
make csu/subdir_lib
cp csu/crt1.o csu/crti.o csu/crtn.o $SYSROOT/usr/lib/a17_a7_softfp_neon-vfpv4/
$TARDIR/bin/$TARGET-gcc -mcpu=cortex-a17.cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4  -o $SYSROOT/usr/lib/a17_a7_softfp_neon-vfpv4/libc.so -nostdlib -nostartfiles -shared -x c /dev/null
popd

rm -rf $BASE_DIR/glibc_build
mkdir $BASE_DIR/glibc_build
pushd $BASE_DIR/glibc_build
echo "slibdir=/lib/a17_a7_softfp_neon-vfpv4" >> configparms
echo "libdir=/usr/lib/a17_a7_softfp_neon-vfpv4" >> configparms
BUILD_CC="gcc" CC="$TARDIR/bin/$TARGET-gcc -mcpu=cortex-a17.cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4" CXX="$TARDIR/bin/$TARGET-g++ -mcpu=cortex-a17.cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4" CFLAGS="-g -O2" ../$GLIBC_DIR/configure --prefix=/usr --with-headers=$SYSROOT/usr/include/ --build=$HOST  --host=$TARGET --enable-profile --without-gd --without-cvs --disable-multi-arch --enable-obsolete-rpc --enable-add-ons libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes libc_cv_ctors_header=yes --enable-kernel=2.6.32 '--with-pkgversion=Hisilicon_v600_20180630' --with-bugurl=http://www.hisilicon.com/cn/service/claim.html
make
make install_root=$SYSROOT install
popd
