#! /bin/csh -f
#
#	mminstall [-s <strip-destdir>] <destdir> <files>
#
echo "entering mminstall"
if ($#argv > 1) then
    if ("$argv[1]" == "-s") then
	shift argv
	set sdir=$argv[1]
	shift argv
	if ($#argv > 1) then
	    if ("$cwd" == "$1") then
		echo "mminstall: ERROR!  Cannot install to self ($1)"
		exit 0
	    endif
	    if ("$cwd" == "$sdir") then
		echo "mminstall: ERROR!  Cannot install to self ($sdir)"
		exit 0
	    endif
	    if (! -e $sdir) then
		echo "mminstall: mkdir $sdir"
		mkdir $sdir
	    endif
	    foreach file ($argv[2-])
		if (-e $file) then
		    cmp -s $1/$file $file
		    if ($status) then
			/bin/rm -f $1/$file
			cp $file $1/$file
			echo "mminstall: $1/$file"
		    endif
		    stripc $file /tmp/tmp$$
		    cmp -s $sdir/$file /tmp/tmp$$
		    if ($status) then
			/bin/rm -f $sdir/$file
			cp /tmp/tmp$$ $sdir/$file
			echo "mminstall: $sdir/$file"
		    endif
		endif
	    end
	endif
    else
	if (! -e $1) then
	    echo "mminstall: mkdir $1"
	    mkdir $1
	endif
	if ("$cwd" == "$1") then
	    echo "mminstall: ERROR!  Cannot install to self ($1)"
	    exit 0
	endif
	foreach file ($argv[2-])
	    if (-e $file) then
		cmp -s $1/$file $file
		if ($status) then
		    /bin/rm -f $1/$file
		    cp $file $1/$file
		    echo "mminstall: $1/$file"
		endif
	    endif
	end
    endif
    /bin/rm -f /tmp/tmp$$
endif

exit 0
