#!/bin/bash

rm -f hisogpt_64
rm -f hisogpt_32
rm -f hisogpt_aa64

/opt/diet64/bin/diet -Os gcc -D_FILE_OFFSET_BITS=64  hisogpt.c crc32.c -o  hisogpt_64
/opt/diet32/bin/diet -Os gcc -D_FILE_OFFSET_BITS=64 -m32 hisogpt.c crc32.c -o  hisogpt_32

aarch64-buildroot-linux-uclibc-gcc -Os -static -D_FILE_OFFSET_BITS=64  hisogpt.c crc32.c -o  hisogpt_aa64
mips64el-linux-musl-gcc -mips64r2 -mabi=64 -static -Os -D_FILE_OFFSET_BITS=64 hisogpt.c crc32.c -o  hisogpt_m64e


#gcc -D_FILE_OFFSET_BITS=64 -static -Wall hisogpt.c  -o  hisotool_64
#gcc -D_FILE_OFFSET_BITS=64  -Wall  -m32  hisogpt.c  -o  hisotool_32

if [ -e hisogpt_64 ] && [ -e hisogpt_32 ] && [ -e hisogpt_aa64 ] && [ -e hisogpt_m64e ]; then
    echo -e '\n############### SUCCESS ###############\n'
    mv hisogpt_64 ../INSTALL/tool/x86_64/hisogpt
    mv hisogpt_32 ../INSTALL/tool/i386/hisogpt
    
    aarch64-buildroot-linux-uclibc-strip --strip-all hisogpt_aa64
    mv hisogpt_aa64 ../INSTALL/tool/aarch64/hisogpt
    
    mips64el-linux-musl-strip --strip-all hisogpt_m64e
    mv hisogpt_m64e ../INSTALL/tool/mips64el/hisogpt
    
else
    echo -e '\n############### FAILED ################\n'
    exit 1
fi

