source: rtems/c/build-tools/install-if-change.in @ 11cfb6f7

4.104.114.84.95
Last change on this file since 11cfb6f7 was 11cfb6f7, checked in by Joel Sherrill <joel.sherrill@…>, on 10/14/98 at 20:19:30

Patch from Ralf Corsepius <corsepiu@…>:

  1. Rtems contains some perl scripts that use hard-coded paths to /usr/bin/perl or /usr/local/bin/perl I have already fixed these problems by adding some checks to configure.in. While doing this, I also cleaned up some more autoconf related problems for generating shell scripts. This patch might seem a bit scary to you, but I am quite confident it won't break something (I've been testing it for almost a week now, however it might introduce typos for a limited number configurations I don't have access to - But it shouldn't be a problem for you to test them :-).

I expect to get this finished tonight, hence you will very likely
have the patch when you get up tomorrow.

Changes:

  • Check for PERL and disable all PERL scripts if perl wasn't found.
  • Generate all KSHELL-scripts with autoconf instead of make-script
  • Automatic dependency handling for autoconf generated KSHELL or PERL scripts (make/rtems.cfg)

Notes:

  • this patch contains new files and deletes some other files.
  • The patch is relative to rtems-4.0.0-beta4 with my previous rtems-rc-981014-1.diff patch applied.

Testing:

I tested it with sh-rtems and posix under linux. Now all targets
which are touched by this patch and which are not used while building
for sh-rtems and posix still need to be tested. AFAIS, only the
sparc/erc32 BSP should be affected by this criterion. And if you
like to, you should also consider testing it on a Cygwin32 and a
Solaris host for one arbitrary BSP.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1#!@KSH@ -p
2#
3# Either bash or ksh will be ok for this; requires (( )) arithmetic
4#  (-p above just says to not parse $ENV file; makes it faster for
5#   those of us who set $ENV)
6#
7# install files if they have changed by running 'cmp', then 'install'
8#   as necessary.
9#
10#  Optionally, can append a suffix before last existing suffix (if any)
11#
12# NOTE
13#   We avoid using typical install(1M) programs since they have
14#   large variability across systems and we also need to support ou
15#   -V option.
16#   So we just copy and chmod by hand.
17#
18# $Id$
19#
20
21progname=`basename $0`
22#progname=${0##*/}        # fast basename hack for ksh, bash
23
24USAGE=\
25"usage: $progname [ -vmV ] file [ file ... ] dest-directory-or-file
26        -v          -- verbose
27        -V suffix   -- suffix to append to targets (before any . suffix)
28                        eg: -V _g would change 'foo' to 'foo_g' and
29                                               'libfoo.a' to 'libfoo_g.a'
30        -m mode     -- mode for new file(s)"
31
32fatal() {
33    if [ "$1" ]
34    then
35        echo $* >&2
36    fi
37    echo "$USAGE" 1>&2
38    exit 1
39}
40
41#
42# process the options
43#
44
45verbose=""
46suffix=""
47mode=""
48
49while getopts vm:V: OPT
50do
51    case "$OPT" in
52        v)
53            verbose="yes";;
54        V)
55            eval suffix=$OPTARG;;
56        m)
57            mode="$OPTARG";;
58        *)
59            fatal
60    esac
61done
62
63shiftcount=`expr $OPTIND - 1`
64shift $shiftcount
65
66args=$*
67
68#
69# Separate source file(s) from dest directory or file
70#
71
72files=""
73dest=""
74for d in $args
75do
76    files="$files $dest"
77    dest=$d
78done
79
80if [ ! "$files" ] || [ ! "$dest" ]
81then
82    fatal "missing files or invalid destination"
83fi
84
85#
86# Process the arguments
87#
88
89targets=""
90for f in $files
91do
92    # leaf=`basename $f`
93    leaf=${f##*/}        # fast basename hack for ksh, bash
94
95    target=$dest
96    if [ -d $dest ]
97    then
98        # if we were given a suffix, then add it as appropriate
99        if [ "$suffix" ]
100        then
101            case $f in
102                *.*)
103                    # leaf=`echo $leaf |
104                    #   /bin/sed "s/\([~\.]*\)\.\(.*\)$/\1$suffix.\2/"`
105                    # ksh,bash hack for above sed script
106                    leaf=${leaf%%.*}$suffix.${leaf#*.}
107
108                    [ "$verbose" = "yes" ] &&
109                      echo "$progname: $f will be installed as $leaf"
110                    ;;
111                *)
112                    leaf=$leaf$suffix;;
113            esac
114        fi
115        target=$target/$leaf
116    fi
117
118    [ ! -r $f ] && fatal "can not read $f"
119
120    if cmp -s $f $target
121    then
122        [ "$verbose" = "yes" ] && echo "'$f' not newer than '$target'"
123    else
124        [ "$verbose" = "yes" ] && echo "rm -f $target"
125        rm -f $target
126        echo "cp -p $f $target"
127        cp -p $f $target || exit 1
128        targets="$targets $target"    # keep list for chmod below
129    fi
130done
131
132if [ "$mode" -a "$targets" ]
133then
134     [ "$verbose" = "yes" ] && echo "chmod $mode $targets"
135     chmod $mode $targets
136fi
137
138exit 0
139
140# Local Variables: ***
141# mode:ksh ***
142# End: ***
Note: See TracBrowser for help on using the repository browser.