linux_setup.sh


#! /bin/sh
#
#  Setup Linux shell scripts for PicoWeb devleopment
#
scripts="gas pwavrld pwbuild pwload pwnetld"
programs="ar as ld nm ranlib readelf strip make gcc"
avrbindir=/usr/local/avr/bin
gccbindir=/usr/local/lib/gcc-lib/avr/2.95.2/

id=`id -u`
case $id in 0);; *) echo "must be root to run this script!"; exit 1;; esac

ego=`basename $0`
pwd=`pwd`

bad=0
for i in $scripts
do
	if [ ! -f $i ]; then bad=1; break; fi
done

dir=`dirname $0`
echo setting up for PicoWeb developement in $dir

if [ $bad = 1 ]; then
	if [ "$dir" = "." -o "$dir" = "" ]; then
		echo "run this program with a full path name!"
		echo "example:"
		echo "    /usr/local/pwdev/$ego"
		echo "not:"
		echo "    $ego"
		exit 1
	fi
fi

echo "make shell scripts executable"
for i in $scripts
do
	file=$dir/$i
        if [ ! -f $dir/$i ]; then
		echo "can't find script $file!"
		exit 1;
        fi
        if [ ! -x $dir/$i ]; then
		cmd="chmod a+x $file"
		echo $cmd
		eval $cmd
		case $? in 0);; *) exit 1;; esac
	fi
done
echo "done"

avr=$dir/avr
echo "setting \"$avr\" to run setuid as root"
chown root $avr
case $? in 0);; *) exit 1;; esac
chgrp root $avr
case $? in 0);; *) exit 1;; esac
chmod a+s $avr
case $? in 0);; *) exit 1;; esac
echo "done"

echo "removing exta CR's from source files"
dos2unix="perl $dir/dos2unix.pl -verbose"
cd $dir
$dos2unix *.pl
$dos2unix ../lib/*.asm
$dos2unix ../lib/*.h
$dos2unix ../lib/*.inc
cd $pwd
echo "done"

echo "linking to AVR tools in directory $dir"
if [ ! -d $avrbindir ]; then
	echo "can't find AVR binary directory $avrbindir!"
	exit 1
fi
cd $dir
for i in $programs
do
	tool=avr-$i
	link=$avrbindir/$i
	if [ ! -x $link ]; then
		link=`which $i`
		if [ ! -x $link ]; then
			echo "can't find executable $link!"
			exit 1
		fi
	fi
	if [ -f $tool ]; then
		x=`ls -l $tool | sed -e 's/.* //'`
		if [ "$x" = "$link" ]; then
			continue
		fi
		cmd="rm -f $tool"
		echo $cmd
		eval $cmd
	fi
	cmd="ln -s $link $tool"
	echo $cmd
	eval $cmd
	case $? in 0);; *) exit 1;; esac
done
cd $pwd
echo "done"

echo "checking for gcc directory $dir"
if [ ! -d $gccbindir ]; then
	echo "error! can't find gcc binary directory $gccbindir!"
fi
echo "done"

echo "------------------------------------------------------------------------"
echo " You will need to put the directroy $dir"
echo " in your search path to run the PicoWeb development system"
echo "------------------------------------------------------------------------"
exit 0

Back