4 rm -f /tmp/bfin-reset-PATH.$$
5 echo "${PATH}" > /tmp/bfin-reset-PATH.$$
7 trap "rm -f /tmp/bfin-reset-PATH.$$" EXIT
11 local quiet=false use_ccache=true
12 [[ $1 == -q || $1 == --quiet ]] && quiet=true && shift
13 [[ $1 == -nc ]] && use_ccache=false && shift
15 if [[ -d /usr/local/src/blackfin/toolchains/current ]] ; then
16 set -- $(eval echo /usr/local/src/blackfin/toolchains/current/{linux-uclibc,uclinux,elf})
18 for d in /opt/uClinux /opt/uClinux-svn ; do
19 [ -d "$d" ] && set -- $d
23 if [[ $# -eq 0 ]] ; then
24 echo "bfin_path: unable to locate a good toolchain" 1>&2
27 elif [[ $# -eq 1 ]] ; then
30 for pp in elf uclinux linux-uclibc ; do
31 if [[ -e $1/out-${pp}/bin ]] ; then
33 elif [[ -e $1/bfin-${pp}/bin ]] ; then
40 set -- $(eval echo $1/${p}{${ppp:1}}/bin)
42 echo export _BFIN_PATH=\'$*\'
45 pushd ${p} > /dev/null || return 1
46 local ccache=$(type -P ccache)
47 ${use_ccache} || ccache=""
48 if [[ -n ${ccache} ]] && [[ ! -d ccache ]] ; then
49 if ! mkdir -p ccache >& /dev/null ; then
52 echo "FAIL: ccache creation with $p; please do:"
53 echo " sudo mkdir '${p}/ccache'"
54 echo " sudo chown ${USER}:users '${p}/ccache'"
58 if [[ -n ${ccache} ]] && [[ -d ccache ]] ; then
59 if [[ ! -d ccache/scripts ]] ; then
60 mkdir -p ccache/{output,scripts,symlinks}
64 cat <<-EOF > scripts/.wrapper
68 p=\${p%/ccache/scripts}
69 export CCACHE_DIR=\${p}/ccache/output
70 export PATH=\${p}:\${PATH}
71 exec \${p}/ccache/symlinks/\${x} "\$@"
73 chmod a+rx scripts/.wrapper
75 x=$(find .. -maxdepth 1 -name '*-gcc' -printf '%P')
77 cat <<-EOF > scripts/${xx}
80 p=\${p%/ccache/scripts}
81 export CCACHE_DIR=\${p}/ccache/output
82 export PATH=\${p}:\${PATH}
85 chmod a+rx scripts/${xx}
87 for x in gcc c++ g++ ; do
88 for xx in $(find .. -maxdepth 1 '(' -name "*-${x}" -o -name "*-${x}-*" ')' -printf '%P ') ; do
89 ln scripts/.wrapper scripts/${xx}
90 ln -fs ${ccache} symlinks/${xx}
94 echo export UCLINUX_USE_CCACHE=no # we handle it ourself
95 ${quiet} || echo "Adding ${p} (w/ccache)" 1>&2
96 export PATH=${PATH}:${p}/ccache/scripts:${p}
97 echo export PATH=\"${PATH}\"
99 ${quiet} || echo "Adding ${p} to PATH" 1>&2
100 export PATH=${PATH}:${p}
101 echo export PATH=\"${PATH}\"
109 for g in bfin-{{linux-uclibc,uclinux,elf}-gdb{,tui},gdbproxy,jtag} ; do
110 type -P ${g} >& /dev/null && alias ${g}="${g} --quiet"
111 type -P ${g} >& /dev/null && alias ${g}="${g} --quiet"
115 export PATH=$(</tmp/bfin-reset-PATH.$$)
116 rm -f /tmp/bfin-reset-PATH.$$
118 for f in /usr/local/src/blackfin/git/toolchain/distribution/snapshots/bfin-alias ~/.profile.d/bfin-alias.sh ; do
119 [[ -e ${f} ]] && source "${f}"
122 for g in $(alias 2>&1 | sed -n '/^alias bfin-/{s:^alias ::;s:=.*::;p}') ; do
125 for g in $(declare 2>&1 | awk '$0 ~ /^bfin-/ { print $1 }') ; do
132 if [[ -z ${ver} || -n $2 ]] ; then
133 echo "Usage: bfin-set-gcc-ver <gcc ver>"
138 for b in ${_BFIN_PATH} ; do
139 for bb in $(echo ${b}/*-${ver}) ; do
141 if [[ ! -x ${bb} ]] ; then
142 echo "Not found: ${bb}"
146 cp -a "${b}-${ver}" "${b}"
147 echo "${b##*/} -> ${bb##*/}"
165 [[ -z $elf ]] && echo "Usage: bfin-cpu-uboot <init> <elf>" && return 1
166 killall -q bfin-gdbproxy
167 bfin-gdbproxy -q bfin --reset &
170 bfin-elf-gdb -q -batch \
171 --ex "target remote localhost:2000" \
175 --ex "call memset(&_bss_start, 0, &_bss_end - &_bss_start)" \
183 local localserv=$(</usr/local/src/blackfin/.svn.local)
184 local remotserv="svn+ssh://${USER}@firewall-sources.blackfin.uclinux.org"
185 [[ -z ${localserv} ]] && return 1
187 normalize_svn_trail() {
190 while [[ ${val} == */svn ]] || [[ ${val} == */ ]] ; do
196 normalize_svn_lead() {
199 while [[ ${val} == svn/* ]] || [[ ${val} == /* ]] ; do
206 normalize_svn_trail localserv
207 normalize_svn_trail remotserv
209 local newurl url=$(svn info | grep ^URL:) oldurl
210 [[ -z ${url} ]] && return 1
215 url=${url#${remotserv}}
216 normalize_svn_lead url
217 newurl=${localserv}/svn/${url}
220 url=${url#${localserv}}
221 normalize_svn_lead url
222 newurl=${remotserv}/svn/${url}
225 echo "Unknown url: ${url}; switching to local"
226 remotserv=${url##*//}
227 remotserv=${remotserv#*/}
228 newurl="${localserv}/svn/${remotserv##svn/}"
231 (set -x; svn switch --relocate ${oldurl} ${newurl} "$@")
233 unset normalize_svn_trail
234 unset normalize_svn_lead