OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [tools/] [build/] [install-if-change.in] - Diff between revs 30 and 173

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 30 Rev 173
#!@KSH@ -p
#!@KSH@ -p
#
#
# Either bash or ksh will be ok for this; requires (( )) arithmetic
# Either bash or ksh will be ok for this; requires (( )) arithmetic
#  (-p above just says to not parse $ENV file; makes it faster for
#  (-p above just says to not parse $ENV file; makes it faster for
#   those of us who set $ENV)
#   those of us who set $ENV)
#
#
# install files if they have changed by running 'cmp', then 'install'
# install files if they have changed by running 'cmp', then 'install'
#   as necessary.
#   as necessary.
#
#
#  Optionally, can append a suffix before last existing suffix (if any)
#  Optionally, can append a suffix before last existing suffix (if any)
#
#
# NOTE
# NOTE
#   We avoid using typical install(1M) programs since they have
#   We avoid using typical install(1M) programs since they have
#   large variability across systems and we also need to support ou
#   large variability across systems and we also need to support ou
#   -V option.
#   -V option.
#   So we just copy and chmod by hand.
#   So we just copy and chmod by hand.
#
#
# $Id: install-if-change.in,v 1.2 2001-09-27 12:02:53 chris Exp $
# $Id: install-if-change.in,v 1.2 2001-09-27 12:02:53 chris Exp $
#
#
progname=`basename $0`
progname=`basename $0`
#progname=${0##*/}        # fast basename hack for ksh, bash
#progname=${0##*/}        # fast basename hack for ksh, bash
USAGE=\
USAGE=\
"usage: $progname [ -vmV ] file [ file ... ] dest-directory-or-file
"usage: $progname [ -vmV ] file [ file ... ] dest-directory-or-file
        -v          -- verbose
        -v          -- verbose
        -V suffix   -- suffix to append to targets (before any . suffix)
        -V suffix   -- suffix to append to targets (before any . suffix)
                        eg: -V _g would change 'foo' to 'foo_g' and
                        eg: -V _g would change 'foo' to 'foo_g' and
                                               'libfoo.a' to 'libfoo_g.a'
                                               'libfoo.a' to 'libfoo_g.a'
        -m mode     -- mode for new file(s)"
        -m mode     -- mode for new file(s)"
fatal() {
fatal() {
    if [ "$1" ]
    if [ "$1" ]
    then
    then
        echo $* >&2
        echo $* >&2
    fi
    fi
    echo "$USAGE" 1>&2
    echo "$USAGE" 1>&2
    exit 1
    exit 1
}
}
#
#
# process the options
# process the options
#
#
verbose=""
verbose=""
suffix=""
suffix=""
mode=""
mode=""
while getopts vm:V: OPT
while getopts vm:V: OPT
do
do
    case "$OPT" in
    case "$OPT" in
        v)
        v)
            verbose="yes";;
            verbose="yes";;
        V)
        V)
            eval suffix=$OPTARG;;
            eval suffix=$OPTARG;;
        m)
        m)
            mode="$OPTARG";;
            mode="$OPTARG";;
        *)
        *)
            fatal
            fatal
    esac
    esac
done
done
shiftcount=`expr $OPTIND - 1`
shiftcount=`expr $OPTIND - 1`
shift $shiftcount
shift $shiftcount
args=$*
args=$*
#
#
# Separate source file(s) from dest directory or file
# Separate source file(s) from dest directory or file
#
#
files=""
files=""
dest=""
dest=""
for d in $args
for d in $args
do
do
    files="$files $dest"
    files="$files $dest"
    dest=$d
    dest=$d
done
done
if [ ! "$files" ] || [ ! "$dest" ]
if [ ! "$files" ] || [ ! "$dest" ]
then
then
    fatal "missing files or invalid destination"
    fatal "missing files or invalid destination"
fi
fi
#
#
# Process the arguments
# Process the arguments
#
#
targets=""
targets=""
for f in $files
for f in $files
do
do
    # leaf=`basename $f`
    # leaf=`basename $f`
    leaf=${f##*/}        # fast basename hack for ksh, bash
    leaf=${f##*/}        # fast basename hack for ksh, bash
    target=$dest
    target=$dest
    if [ -d $dest ]
    if [ -d $dest ]
    then
    then
        # if we were given a suffix, then add it as appropriate
        # if we were given a suffix, then add it as appropriate
        if [ "$suffix" ]
        if [ "$suffix" ]
        then
        then
            case $f in
            case $f in
                *.*)
                *.*)
                    # leaf=`echo $leaf |
                    # leaf=`echo $leaf |
                    #   /bin/sed "s/\([~\.]*\)\.\(.*\)$/\1$suffix.\2/"`
                    #   /bin/sed "s/\([~\.]*\)\.\(.*\)$/\1$suffix.\2/"`
                    # ksh,bash hack for above sed script
                    # ksh,bash hack for above sed script
                    leaf=${leaf%%.*}$suffix.${leaf#*.}
                    leaf=${leaf%%.*}$suffix.${leaf#*.}
                    [ "$verbose" = "yes" ] &&
                    [ "$verbose" = "yes" ] &&
                      echo "$progname: $f will be installed as $leaf"
                      echo "$progname: $f will be installed as $leaf"
                    ;;
                    ;;
                *)
                *)
                    leaf=$leaf$suffix;;
                    leaf=$leaf$suffix;;
            esac
            esac
        fi
        fi
        target=$target/$leaf
        target=$target/$leaf
    fi
    fi
    [ ! -r $f ] && fatal "can not read $f"
    [ ! -r $f ] && fatal "can not read $f"
    if cmp -s $f $target
    if cmp -s $f $target
    then
    then
        [ "$verbose" = "yes" ] && echo "'$f' not newer than '$target'"
        [ "$verbose" = "yes" ] && echo "'$f' not newer than '$target'"
    else
    else
        [ "$verbose" = "yes" ] && echo "rm -f $target"
        [ "$verbose" = "yes" ] && echo "rm -f $target"
        rm -f $target
        rm -f $target
        echo "cp -p $f $target"
        echo "cp -p $f $target"
        cp -p $f $target || exit 1
        cp -p $f $target || exit 1
        targets="$targets $target"    # keep list for chmod below
        targets="$targets $target"    # keep list for chmod below
    fi
    fi
done
done
if [ "$mode" -a "$targets" ]
if [ "$mode" -a "$targets" ]
then
then
     [ "$verbose" = "yes" ] && echo "chmod $mode $targets"
     [ "$verbose" = "yes" ] && echo "chmod $mode $targets"
     chmod $mode $targets
     chmod $mode $targets
fi
fi
exit 0
exit 0
# Local Variables: ***
# Local Variables: ***
# mode:ksh ***
# mode:ksh ***
# End: ***
# End: ***
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.