123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- srcdir=$(cd "$(dirname "$0")"; pwd)
- prefix=/usr/local
- cc=gcc
- cxx=g++
- ld=ld
- objcopy=objcopy
- objdump=objdump
- ar=ar
- addr2line=addr2line
- arch=`uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/'`
- host=$arch
- cross_prefix=
- endian=""
- pretty_print_stacks=yes
- environ_default=yes
- u32_long=
- usage() {
- cat <<-EOF
- Usage: $0 [options]
- Options include:
- --arch=ARCH architecture to compile for ($arch)
- --processor=PROCESSOR processor to compile for ($arch)
- --cross-prefix=PREFIX cross compiler prefix
- --cc=CC c compiler to use ($cc)
- --cxx=CXX c++ compiler to use ($cxx)
- --ld=LD ld linker to use ($ld)
- --prefix=PREFIX where to install things ($prefix)
- --endian=ENDIAN endianness to compile for (little or big, ppc64 only)
- --[enable|disable]-pretty-print-stacks
- enable or disable pretty stack printing (enabled by default)
- --[enable|disable]-default-environ
- enable or disable the generation of a default environ when
- no environ is provided by the user (enabled by default)
- EOF
- exit 1
- }
- while [[ "$1" = -* ]]; do
- opt="$1"; shift
- arg=
- if [[ "$opt" = *=* ]]; then
- arg="${opt#*=}"
- opt="${opt%%=*}"
- fi
- case "$opt" in
- --prefix)
- prefix="$arg"
- ;;
- --arch)
- arch="$arg"
- ;;
- --processor)
- processor="$arg"
- ;;
- --cross-prefix)
- cross_prefix="$arg"
- ;;
- --endian)
- endian="$arg"
- ;;
- --cc)
- cc="$arg"
- ;;
- --cxx)
- cxx="$arg"
- ;;
- --ld)
- ld="$arg"
- ;;
- --enable-pretty-print-stacks)
- pretty_print_stacks=yes
- ;;
- --disable-pretty-print-stacks)
- pretty_print_stacks=no
- ;;
- --enable-default-environ)
- environ_default=yes
- ;;
- --disable-default-environ)
- environ_default=no
- ;;
- --help)
- usage
- ;;
- *)
- usage
- ;;
- esac
- done
- arch_name=$arch
- [ "$arch" = "aarch64" ] && arch="arm64"
- [ "$arch_name" = "arm64" ] && arch_name="aarch64"
- [ -z "$processor" ] && processor="$arch"
- if [ "$processor" = "arm64" ]; then
- processor="cortex-a57"
- elif [ "$processor" = "arm" ]; then
- processor="cortex-a15"
- fi
- if [ "$arch" = "i386" ] || [ "$arch" = "x86_64" ]; then
- testdir=x86
- elif [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then
- testdir=arm
- elif [ "$arch" = "ppc64" ]; then
- testdir=powerpc
- firmware="$testdir/boot_rom.bin"
- if [ "$endian" != "little" ] && [ "$endian" != "big" ]; then
- echo "You must provide endianness (big or little)!"
- usage
- fi
- else
- testdir=$arch
- fi
- if [ ! -d "$srcdir/$testdir" ]; then
- echo "$testdir does not exist!"
- exit 1
- fi
- if [ -f "$srcdir/$testdir/run" ]; then
- ln -fs "$srcdir/$testdir/run" $testdir-run
- fi
- cat << EOF > lib-test.c
- __UINT32_TYPE__
- EOF
- u32_long=$($cross_prefix$cc -E lib-test.c | grep -v '^#' | grep -q long && echo yes)
- rm -f lib-test.c
- if [ "$testdir" = "x86" ]; then
- echo 'int main () {}' > lib-test.c
- $cc -m32 -o /dev/null -lstdc++ -lpthread -lrt lib-test.c &> /dev/null
- exit=$?
- $cxx -m32 -o /dev/null -std=gnu++11 lib-test.c &> /dev/null
- if [ $? -eq 0 -a $exit -eq 0 ]; then
- api=true
- fi
- rm -f lib-test.c
- fi
- if test ! -e Makefile; then
- echo "linking Makefile..."
- ln -s "$srcdir/Makefile" .
- echo "linking tests..."
- mkdir -p $testdir
- ln -sf "$srcdir/$testdir/run" $testdir/
- ln -sf "$srcdir/$testdir/unittests.cfg" $testdir/
- ln -sf "$srcdir/run_tests.sh"
- echo "linking scripts..."
- ln -sf "$srcdir/scripts"
- fi
- rm -f lib/asm
- asm=asm-generic
- if [ -d "$srcdir/lib/$arch/asm" ]; then
- asm="$srcdir/lib/$arch/asm"
- elif [ -d "$srcdir/lib/$testdir/asm" ]; then
- asm="$srcdir/lib/$testdir/asm"
- fi
- mkdir -p lib
- ln -sf "$asm" lib/asm
- cat <<EOF > config.mak
- SRCDIR=$srcdir
- PREFIX=$prefix
- HOST=$host
- ARCH=$arch
- ARCH_NAME=$arch_name
- PROCESSOR=$processor
- CC=$cross_prefix$cc
- CXX=$cross_prefix$cxx
- LD=$cross_prefix$ld
- OBJCOPY=$cross_prefix$objcopy
- OBJDUMP=$cross_prefix$objdump
- AR=$cross_prefix$ar
- ADDR2LINE=$cross_prefix$addr2line
- API=$api
- TEST_DIR=$testdir
- FIRMWARE=$firmware
- ENDIAN=$endian
- PRETTY_PRINT_STACKS=$pretty_print_stacks
- ENVIRON_DEFAULT=$environ_default
- ERRATATXT=errata.txt
- U32_LONG_FMT=$u32_long
- EOF
|