1######################################################################## 2# # 3# This software is part of the ast package # 4# Copyright (c) 1994-2011 AT&T Intellectual Property # 5# and is licensed under the # 6# Eclipse Public License, Version 1.0 # 7# by AT&T Intellectual Property # 8# # 9# A copy of the License is available at # 10# http://www.eclipse.org/org/documents/epl-v10.html # 11# (with md5 checksum b35adb5213ca9657e911e9befb180842) # 12# # 13# Information and Software Systems Research # 14# AT&T Research # 15# Florham Park NJ # 16# # 17# Glenn Fowler <gsf@research.att.com> # 18# # 19######################################################################## 20: cross compiler a.out execution 21 22command=crossexec 23 24tmp=/tmp/cross$$ 25 26case `(getopts '[-][123:xyz]' opt --xyz; echo 0$opt) 2>/dev/null` in 270123) ARGV0="-a $command" 28 USAGE=$' 29[-? 30@(#)$Id: crossexec (AT&T Labs Research) 2004-01-04 $ 31] 32'$USAGE_LICENSE$' 33[+NAME?crossexec - cross compiler a.out execution] 34[+DESCRIPTION?\bcrossexec\b runs a cross-compiled \acommand\a in an environment 35 that supports a cross-compilation architecture different from the 36 current host. The cross environment is determined by \acrosstype\a, 37 usually a host type name produced by \bpackage\b(1). \acrosstype\a 38 is used to find an entry in \b$HOME/.crossexec\b that specifies 39 the cross compiler host and access details.] 40[+?The exit status of \bcrossexec\b is the exit status of \acommand\a.] 41[+CROSS ENVIRONMENT FILE?\b$HOME/.crossexec\b contains one line for each 42 supported \acrosstype\a. Each line contains 5 tab separated fields. 43 Field default values are specified as \b-\b. The fields are:]{ 44 [+crosstype?The host type produced by \bpackage\b(1).] 45 [+host?The host name.] 46 [+user?The user name on \ahost\a. The default is the current user.] 47 [+dir?The directory to copy \acommand\a and execute it. The default 48 is the \auser\a \b$HOME\b on \ahost\a.] 49 [+shell?The command used to get shell access to \ahost\a. Currently 50 only \brsh\b and \bssh\b are supported.] 51 [+copy?The command used to copy \acommand\a to \ahost\a. Currently 52 only \brcp\b and \bscp\b are supported.] 53} 54[n:show?Show the underlying commands but do not execute.] 55 56crosstype command [ option ... ] [ file ... ] 57 58[+SEE ALSO?\brcp\b(1), \brsh\b(1), \bscp\b(1), \bssh\b(1)] 59' 60 ;; 61*) ARGV0="" 62 USAGE="crosstype command [ option ... ] [ file ... ]" 63 ;; 64esac 65 66usage() 67{ 68 OPTIND=0 69 getopts $ARGV0 "$USAGE" OPT '-?' 70 exit 2 71} 72 73exec= 74 75# get the options and operands 76 77while getopts $ARGV0 "$USAGE" OPT 78do case $OPT in 79 n) exec=echo ;; 80 *) usage ;; 81 esac 82done 83shift $OPTIND-1 84case $# in 85[01]) usage ;; 86esac 87 88type=$1 89shift 90cmd=$1 91shift 92 93# get the host info 94 95info=$HOME/.$command 96if test ! -r $info 97then echo "$command: $info: not found" >&2 98 exit 1 99fi 100ifs=${IFS-' 101 '} 102while : 103do IFS=' ' 104 read hosttype hostname usr dir sh cp 105 code=$? 106 IFS=$ifs 107 case $code in 108 0) ;; 109 *) echo "$command: $type: unknown cross compiler host type" >&2 110 exit 1 111 ;; 112 esac 113 case $hosttype in 114 $type) break ;; 115 esac 116done < $info 117 118# fill in the defaults 119 120case $usr in 121-) cpu= shu= ;; 122*) cpu=${usr}@ shu="-l $usr" ;; 123esac 124case $dir in 125-) dir= ;; 126esac 127case $sh in 128''|-) sh=ssh ;; 129esac 130case $cp in 131''|-) cp=scp ;; 132scp) cp="$cp -q" ;; 133esac 134 135trap "rm -f $tmp" 0 1 2 3 15 136$exec $cp $cmd $cpu$hostname:$dir </dev/null || exit 1 137cmd=./${cmd##*/} 138$exec $sh $shu $hostname "cd $dir; LD_LIBRARY_PATH=: $cmd $@ </dev/null 2>/dev/null; code=\$?; rm -f $cmd; echo $command: exit \$code >&2" </dev/null 2>$tmp 139exit `sed -e '/^'$command': exit [0-9][0-9]*$/!d' -e 's/.* //' $tmp` 140