maint: run "make update-copyright"
[platform/upstream/automake.git] / lib / acinstall
1 #! /bin/sh
2
3 # Install an aclocal-style M4 file.  A script is needed to do this
4 # because we want to do serial-number checking; newer versions of
5 # macro files should always be preferred.
6
7 # Usage:
8 #  acinstall file directory installprogram [install-args]...
9
10 # Copyright 1996-2012 Free Software Foundation, Inc.
11
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2, or (at your option)
15 # any later version.
16
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21
22 # You should have received a copy of the GNU General Public License
23 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
25 file="$1"
26 dir="$2"
27 shift
28 shift
29
30 localserial=`grep '^# serial ' $file | sed -e 's/^# serial \([0-9][0-9]*\).*$/\1/; q'`
31 if test -z "$localserial"; then
32    echo "acinstall: no serial number in $file" 1>&2
33    exit 1
34 fi
35
36 # Maybe if the installed file has no serial number we should just
37 # assume it is ancient.
38 instserial=`grep '^# serial ' $dir/$file | sed -e 's/^# serial \([0-9][0-9]*\).*$/\1/; q'`
39 if test -z "$instserial"; then
40    echo "acinstall: no serial number in $dir/$file" 1>&2
41    exit 1
42 fi
43
44 if test $localserial -lt $instserial; then
45    # Installed file is newer.
46    exit 0
47 fi
48
49 # Install the file.
50 $* $file $dir/$file