annotate build-aux/mk-hg-id.sh @ 22020:e154d23b2fd1

maint: reduce multiple mentions of the HG-ID file name and contents * build-aux/mk-hg-id.sh: Use ${hg_id} variable everywhere HG-ID is mentioned. * Makefile.am (all-local): Use $(HG_ID_VAR) instead of reading HG-ID again. * libgui/src/module.mk (libgui/src/liboctgui-build-info.cc): Likewise. * libinterp/module.mk (libinterp/liboctinterp-build-info.cc): Likewise. * liboctave/module.mk (liboctave/liboctave-build-info.cc): Likewise. * src/module.mk (src/octave-build-info.cc): Likewise.
author Mike Miller <mtmiller@octave.org>
date Fri, 01 Jul 2016 08:14:50 -0700
parents f6e119d0bdfd
children 3a2b891d0b33 3ac9f9ecfae5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21976
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 #! /bin/sh
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2 #
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 # Copyright (C) 2016 John W. Eaton
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4 #
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 # This file is part of Octave.
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6 #
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 # Octave is free software; you can redistribute it and/or modify it
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 # under the terms of the GNU General Public License as published by the
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 # Free Software Foundation; either version 3 of the License, or (at
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 # your option) any later version.
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 #
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 # Octave is distributed in the hope that it will be useful, but WITHOUT
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 # for more details.
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 #
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 # You should have received a copy of the GNU General Public License
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 # along with Octave; see the file COPYING. If not, see
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 # <http://www.gnu.org/licenses/>.
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 # Generate a header file that provides the public symbols from Octave's
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22 # autoconf-generated config.h file. See the notes at the top of the
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 # generated octave-config.h file for more details.
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 set -e
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 if [ $# -ne 1 ] && [ $# -ne 2 ]; then
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 echo "usage: mk-hg-id.sh SRCDIR [--disable]" 1>&2
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 exit 1
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 fi
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 srcdir="$1"
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 hg_id=HG-ID
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 move_if_change="$srcdir/build-aux/move-if-change"
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 if [ $# -eq 2 ] && [ x"$2" = x--disable ]; then
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 echo "hg-id-disabled" > ${hg_id}-t
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 ${move_if_change} ${hg_id}-t ${hg_id}
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 elif [ -d $srcdir/.hg ]; then
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 ( cd $srcdir && hg identify --id || echo "unknown" ) > ${hg_id}-t
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 ${move_if_change} ${hg_id}-t ${hg_id}
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 elif [ ! -f $srcdir/${hg_id} ]; then
22020
e154d23b2fd1 maint: reduce multiple mentions of the HG-ID file name and contents
Mike Miller <mtmiller@octave.org>
parents: 21976
diff changeset
44 echo "WARNING: $srcdir/${hg_id} is missing!" 1>&2
21976
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 echo "unknown" > ${hg_id}-t && mv ${hg_id}-t ${hg_id}
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 else
22020
e154d23b2fd1 maint: reduce multiple mentions of the HG-ID file name and contents
Mike Miller <mtmiller@octave.org>
parents: 21976
diff changeset
47 echo "preserving existing ${hg_id} file" 1>&2
21976
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 if [ "x$srcdir" != "x." ] && [ -f $srcdir/${hg_id} ] && [ ! -f ${hg_id} ]; then
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 cp ${srcdir}/${hg_id} ${hg_id}
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 touch -r ${srcdir}/${hg_id} ${hg_id}
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 fi
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 fi
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 if [ "`cat ${hg_id}`" = "hg-id-disabled" ]; then
22020
e154d23b2fd1 maint: reduce multiple mentions of the HG-ID file name and contents
Mike Miller <mtmiller@octave.org>
parents: 21976
diff changeset
55 echo "WARNING: ${hg_id} is 'hg-id-disabled'" 1>&2
21976
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 fi
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57
f6e119d0bdfd avoid tagging HG-ID as .PHONY
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 cat ${hg_id}