1#!/bin/sh
2#
3# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4#                         University Research and Technology
5#                         Corporation.  All rights reserved.
6# Copyright (c) 2004-2005 The University of Tennessee and The University
7#                         of Tennessee Research Foundation.  All rights
8#                         reserved.
9# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10#                         University of Stuttgart.  All rights reserved.
11# Copyright (c) 2004-2005 The Regents of the University of California.
12#                         All rights reserved.
13# Copyright (c) 2009-2015 Cisco Systems, Inc.  All rights reserved.
14# Copyright (c) 2015      Research Organization for Information Science
15#                         and Technology (RIST). All rights reserved.
16# Copyright (c) 2015      Los Alamos National Security, LLC. All rights
17#                         reserved.
18# $COPYRIGHT$
19#
20# Additional copyrights may follow
21#
22# $HEADER$
23#
24
25srcdir=$1
26builddir=$PWD
27distdir=$builddir/$2
28OMPI_REPO_REV=$3
29
30if test x"$2" = x ; then
31    echo "*** ERROR: Must supply relative distdir as argv[2] -- aborting"
32    exit 1
33elif test ! -d "$distdir" ; then
34    echo "*** ERROR: dist dir does not exist"
35    echo "*** ERROR:   $distdir"
36    exit 1
37fi
38
39# We can catch some hard (but possible) to do mistakes by looking at
40# our repo's revision, but only if we are in the source tree.
41# Otherwise, use what configure told us, at the cost of allowing one
42# or two corner cases in (but otherwise VPATH builds won't work).
43repo_rev=$OMPI_REPO_REV
44if test -d .git ; then
45    repo_rev=$(config/opal_get_version.sh VERSION --repo-rev)
46fi
47
48#
49# Update VERSION:repo_rev with the best value we have.
50#
51perl -pi -e 's/^repo_rev=.*/repo_rev='$repo_rev'/' -- "${distdir}/VERSION"
52# need to reset the timestamp to not annoy AM dependencies
53touch -r "${srcdir}/VERSION" "${distdir}/VERSION"
54
55echo "*** Updated VERSION file with repo rev: $repo_rev"
56echo "*** (via dist-hook / config/distscript.sh)"
57