michael@0: #!/bin/bash michael@0: # this script creates a wrapper shell script for an executable. The idea is the actual executable cannot be michael@0: # executed natively (it was cross compiled), but we want to run tests natively. Running this script michael@0: # as part of the compilation process will move the non-native executable to a new location, and replace it michael@0: # with a script that will run it under qemu. michael@0: while [[ -n $1 ]]; do michael@0: case $1 in michael@0: --qemu) QEMU="$2"; shift 2;; michael@0: --libdir) LIBDIR="$2"; shift 2;; michael@0: --ld) LD="$2"; shift 2;; michael@0: *) exe="$1"; shift;; michael@0: esac michael@0: done michael@0: if [[ -z $LIBDIR ]]; then michael@0: echo "You need to specify a directory for the cross libraries when you configure the shell" michael@0: echo "You can do this with --with-cross-lib=" michael@0: exit 1 michael@0: fi michael@0: LD=${LD:-$LIBDIR/ld-linux.so.3} michael@0: mv $exe $exe.target michael@0: # Just hardcode the path to the executable. It'll be pretty obvious if it is doing the wrong thing. michael@0: michael@0: echo $'#!/bin/bash\n' $QEMU -E LD_LIBRARY_PATH="${LIBDIR}" "$LD" "$(readlink -f "$exe.target")" '"$@"' >"$exe" michael@0: chmod +x $exe