1 #!/usr/bin/bash
   2 #
   3 # We need to run ctfconvert on all the .o files in qemu. However, some of these
   4 # .o files contain some snippets that are going to cause ctfconvert to fail. If
   5 # ctfconvert is run with the -i option, it will delete the .o file. This is bad.
   6 # Instead we end up using a temporary file and move over it. 
   7 #
   8 
   9 sh_arg0=$(basename $0)
  10 
  11 function fail
  12 {
  13         local msg="$*"
  14         [[ -z "$msg" ]] && msg="failed"
  15         echo "$sh_arg0: $msg" >&2
  16         exit 1
  17 }
  18 
  19 [[ $# -eq 1 ]] || fail "missing arguments"
  20 
  21 # CTFCONVERT may contain a wildcard, so expand it out:
  22 ctfconvert=$(echo ${CTFCONVERT})
  23 [[ -x ${ctfconvert} ]] || fail "could not find ctfconvert at $CTFCONVERT"
  24 
  25 echo "Converting $1"
  26 $ctfconvert -L VERSION -o $1.ctf $1
  27 [[ $? -ne 0 ]] && exit 1
  28 mv $1.ctf $1
  29 exit 0