1#!/bin/sh -f
2#
3# Copyright © 2004-2005 The Trustees of Indiana University and Indiana
4#                         University Research and Technology
5#                         Corporation.  All rights reserved.
6# Copyright © 2004-2005 The University of Tennessee and The University
7#                         of Tennessee Research Foundation.  All rights
8#                         reserved.
9# Copyright © 2004-2005 High Performance Computing Center Stuttgart,
10#                         University of Stuttgart.  All rights reserved.
11# Copyright © 2004-2005 The Regents of the University of California.
12#                         All rights reserved.
13# Copyright © 2010-2014   Inria.  All rights reserved.
14# Copyright © 2009-2014 Cisco Systems, Inc.  All rights reserved.
15# $COPYRIGHT$
16#
17# Additional copyrights may follow
18#
19# $HEADER$
20#
21
22builddir="`pwd`"
23
24srcdir=$1
25cd "$srcdir"
26srcdir=`pwd`
27cd "$builddir"
28
29distdir="$builddir/$2"
30HWLOC_VERSION=$3
31
32if test "$distdir" = ""; then
33    echo "Must supply relative distdir as argv[2] -- aborting"
34    exit 1
35elif test "$HWLOC_VERSION" = ""; then
36    echo "Must supply version as argv[1] -- aborting"
37    exit 1
38fi
39
40#========================================================================
41
42start=`date`
43cat <<EOF
44
45Creating hwloc distribution
46In directory: `pwd`
47Srcdir: $srcdir
48Builddir: $builddir
49Version: $HWLOC_VERSION
50Started: $start
51
52EOF
53
54umask 022
55
56if test ! -d "$distdir"; then
57    echo "*** ERROR: dist dir does not exist"
58    echo "*** ERROR:   $distdir"
59    exit 1
60fi
61
62if test ! -d $srcdir/doc/doxygen-doc; then
63    echo "*** The srcdir does not already have a doxygen-doc tree built."
64    echo "*** hwloc's config/distscript.csh requires the docs to be built"
65    echo "*** in the srcdir before executing 'make dist'."
66    exit 1
67fi
68
69# Trivial helper function
70doit() {
71    echo $*
72    eval $*
73}
74
75echo "*** Copying doxygen-doc tree to dist..."
76echo "*** Directory: srcdir: $srcdir, distdir: $distdir, pwd: `pwd`"
77doit mkdir -p $distdir/doc/doxygen-doc
78doit chmod -R a=rwx $distdir/doc/doxygen-doc
79doit rm -rf $distdir/doc/doxygen-doc
80
81# We want to copy the entire directory tree to the distdir.  In some
82# cases, doxygen-doc may be a sym link, so we want the copy to follow
83# the sym links.  It's a bit of a portability nightmare, so try a few
84# different ways...
85# This seems to work on OS X and Linux (but not Solaris)
86doit "tar c -C $srcdir -h -f - doc/doxygen-doc | tar x -C $distdir -f -"
87if test ! -d $distdir/doc/doxygen-doc; then
88    # This seems to work on Linux and Solaris
89    doit cp -rpf $srcdir/doc/doxygen-doc/ $distdir/doc
90fi
91if test ! -d $distdir/doc/doxygen-doc; then
92    # This seems to work on OS X (probably redundant, but we know it works)
93    doit cp -rpf $srcdir/doc/doxygen-doc $distdir/doc
94fi
95# If we still failed, just error out
96if test ! -d $distdir/doc/doxygen-doc; then
97    echo "ERROR: Cannot seem to copy a directory to the distdir :-("
98    exit 1
99fi
100
101echo "*** Copying new README"
102ls -lf $distdir/README
103doit cp -pf $srcdir/README $distdir
104
105#########################################################
106# VERY IMPORTANT: Now go into the new distribution tree #
107#########################################################
108cd "$distdir"
109echo "*** Now in distdir: $distdir"
110
111#
112# Remove all the latex source files from the distribution tree (the
113# PDFs are still there; we're just removing the latex source because
114# some of the filenames get really, really long...).
115#
116
117echo "*** Removing latex source from dist tree"
118doit rm -rf doc/doxygen-doc/latex
119
120#
121# All done
122#
123
124cat <<EOF
125*** hwloc version $HWLOC_VERSION distribution created
126
127Started: $start
128Ended:   `date`
129
130EOF
131