1#! /bin/sh
2#
3# This script has to be built by configure.
4#
5# This is a script to install MPE Profiling Environment. It can be invoked with
6#
7#    make installcheck  ( if you used -prefix at configure time )
8#
9#    or,
10#
11#    make installcheck PREFIX=Path_to_the_installation_of_MPE
12#
13# in the top-level MPE __build__ directory which could be the same
14# or different from the source directory
15#
16
17MAKE="@MAKE@"
18
19# Location of sources
20# top_srcdir=@top_srcdir@
21top_srcdir=@top_srcdir_abs@       # in absolute path
22
23# Installation directories: Default paths (set at configure time)
24prefix=@prefix@
25exec_prefix=@exec_prefix@
26includedir=@includedir@
27libdir=@libdir@
28bindir=@bindir@
29sbindir=@sbindir@
30datadir=@datadir@
31sysconfdir=@sysconfdir@
32
33# Assume PROF_LIBNAME=MPE_LIBNAME.
34PROF_LIBNAME=@MPE_LIBNAME@
35CPRP="@CPRP@"
36RM="@RM@"
37LN_S="@LN_S@"
38MPI_IMPL=@MPI_IMPL@
39MPE_BUILD_FORTRAN2C=@MPE_BUILD_FORTRAN2C@
40
41Show=eval
42prefix_override=0
43
44make_target=linktest
45
46for arg in "$@" ; do
47    case "$arg" in
48        -prefix=*)
49            prefix=`echo $arg | sed -e 's/-prefix=//g'`
50            if [ "$prefix" != "@prefix@" ] ; then
51                prefix_override=1
52            fi
53            ;;
54        -package=*)
55            PACKAGE=`echo $arg | sed -e 's/-package=//g'`
56            ;;
57        -t)
58            Show=echo
59            ;;
60        -run)
61            make_target=runtest
62            ;;
63        -run=*)
64            make_target=runtest
65            # Added extra quotes '\"' and '\"' so -run= can accept blanks.
66            make_mperun="MPERUN=\"`echo $arg | sed -e 's/-run=//g'`\""
67            ;;
68        -echo)                    set -x ;;
69        -help|-u|-usage|-h)
70cat <<EOF
71Check MPE installation at $prefix.
72-prefix=path        - Destination directory.
73-package=name       - Set the package name for sharedir(examplesdir).
74-t                  - Try only; do NO actual checking.
75-run                - Do installation runtests instead of linktests with
76                      MPERUN="$bindir/mpiexec -n 4".
77-run=<mpiexec_cmd>  - Do installation runtests instead of linktests with
78                      MPERUN=<mpiexec_cmd>.
79EOF
80            exit 1
81            ;;
82        *)
83            # Silently skip empty arguments (these can occur on
84            # some systems and within some scripts; they are
85            # harmless)
86            if [ -n "$arg" ] ; then
87                echo "mpecheckinstall: Unrecognized argument $arg ."
88                exit 1
89            fi
90            ;;
91    esac
92done
93
94if [ "$SHELL_ECHO" = "on" ] ; then
95    set -x
96fi
97
98# Check if installation location is set
99if [ ! -n "$prefix" ] ; then
100    echo "Set an installation location with -prefix=<location> ."
101    exit 1
102fi
103
104# If the prefix was set, we want to override these choices
105# use autoconf variables, @...@, here, as they are set w.r.t. $prefix.
106if [ "$prefix_override" = 1 ] ; then
107    exec_prefix=@exec_prefix@
108    includedir=@includedir@
109    libdir=@libdir@
110    bindir=@bindir@
111    sbindir=@sbindir@
112    datadir=@datadir@
113fi
114
115if [ ! -s $libdir/lib${PROF_LIBNAME}.a ] ; then
116    echo "Could not find $libdir/lib${PROF_LIBNAME}.a !"
117    echo "You must install MPE before checking the installation!"
118    echo "Try to do \"make install\" or \"mpeinstall\" first."
119    exit 1
120fi
121
122sharedir=$datadir
123if [ -n "$PACKAGE" ] ; then
124    sharedir=$datadir/$PACKAGE
125fi
126
127# Set up Examples directory for the MPE Logging programs
128for pkg in logging graphics collchk ; do
129    examplesdir=$sharedir/examples/${pkg}
130    if [ -f $examplesdir/Makefile ] ; then
131        echo "Running installation $make_target for C $pkg program..."
132        $Show "( cd $examplesdir && $MAKE ${make_target}_C $make_mperun )"
133        if test "$MPE_BUILD_FORTRAN2C" = "yes" ; then
134            echo "Running installation $make_target for Fortran $pkg program..."
135            $Show "( cd $examplesdir && $MAKE ${make_target}_F77 $make_mperun )"
136        fi
137    fi
138done
139