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# Build locations
24includebuild_dir=@includebuild_dir@
25libbuild_dir=@libbuild_dir@
26binbuild_dir=@binbuild_dir@
27sbinbuild_dir=@sbinbuild_dir@
28
29# Assume PROF_LIBNAME=MPE_LIBNAME.
30PROF_LIBNAME=@MPE_LIBNAME@
31CPRP="@CPRP@"
32RM="@RM@"
33LN_S="@LN_S@"
34MPI_IMPL=@MPI_IMPL@
35MPE_BUILD_FORTRAN2C=@MPE_BUILD_FORTRAN2C@
36
37Show=eval
38prefix_override=0
39
40make_target=linktest
41make_mperun=
42
43for arg in "$@" ; do
44    case "$arg" in
45        -t)
46            Show=echo
47            ;;
48        -run)
49            make_target=runtest
50            ;;
51        -run=*)
52            make_target=runtest
53            # Added extra quotes '\"' and '\"' so -run= can accept blanks.
54            make_mperun="MPERUN=\"`echo $arg | sed -e 's/-run=//g'`\""
55            ;;
56        -echo)                    set -x ;;
57        -help|-u|-usage|-h)
58cat <<EOF
59Check MPE build at $libbuild_dir.
60-t                  - Try only; do NO actual checking.
61-run                - Do build runtests instead of linktests with
62                      MPERUN="$bindir/mpiexec -n 4".
63-run=<mpiexec_cmd>  - Do build runtests instead of linktests with
64                      MPERUN=<mpiexec_cmd>.
65EOF
66            exit 1
67            ;;
68        *)
69            # Silently skip empty arguments (these can occur on
70            # some systems and within some scripts; they are
71            # harmless)
72            if [ -n "$arg" ] ; then
73                echo "mpecheckbuild: Unrecognized argument $arg ."
74                exit 1
75            fi
76            ;;
77    esac
78done
79
80if [ "$SHELL_ECHO" = "on" ] ; then
81    set -x
82fi
83
84if [ ! -s $libbuild_dir/lib${PROF_LIBNAME}.a ] ; then
85    echo "Could not find $libbuild_dir/lib${PROF_LIBNAME}.a !"
86    echo "You must build MPE before checking the build!"
87    echo "Try to do a \"make\" first."
88    exit 1
89fi
90
91# Set up Examples directory for the MPE Logging programs
92logging_dirname="src/wrappers/test"
93graphics_dirname="src/graphics/contrib/test"
94collchk_dirname="src/collchk/test"
95for pkg in logging graphics collchk ; do
96    dirname=${pkg}_dirname
97    eval dirvalue=\$"$dirname"
98    if [ -f $libbuild_dir/../$dirvalue/Makefile ] ; then
99        echo "Running build $make_target for C $pkg program..."
100        $Show "( cd $libbuild_dir/../$dirvalue && \
101                 $MAKE ${make_target}_C $make_mperun )"
102        if test "$MPE_BUILD_FORTRAN2C" = "yes" ; then
103            echo "Running build $make_target for Fortran $pkg program..."
104            $Show "( cd $libbuild_dir/../$dirvalue && \
105                     $MAKE ${make_target}_F77 $make_mperun )"
106        fi
107    fi
108done
109