forked from NU-CUCIS/ph5concat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acinclude.m4
147 lines (140 loc) · 4.95 KB
/
acinclude.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#
# Copyright (C) 2019, Northwestern University and Fermi National Accelerator Laboratory
# See COPYRIGHT notice in top-level directory.
#
#
dnl Convert a string to all uppercase.
dnl
define([uppercase],
[translit($1, abcdefghijklmnopqrstuvwxyz, ABCDEFGHIJKLMNOPQRSTUVWXYZ)])
dnl
dnl check the availability of one MPI executable in $2
dnl
dnl $2 can be a single command, This is the case when user set the environment.
dnl The variable may contain the executable name followed by zeor or more
dnl command-line options. In the latter case, we check the first string token,
dnl the command name, and ignore the rest command-line options. For example,
dnl UD_MPI_PATH_PROG([MPICC], [mpicc -O2])
dnl
dnl In addition, the first token of $2 may contain the full path of
dnl the command. For example, UD_MPI_PATH_PROG([MPICC], [/usr/bin/mpicc -O2])
dnl
AC_DEFUN([UD_MPI_PATH_PROG], [
if test "x$2" = x ; then
AC_MSG_ERROR("2nd argument cannot be NULL")
fi
dnl 1st token in $2 must be the program name, rests are command-line options
ac_first_token=`echo $2 | cut -d" " -f1`
ac_rest_tokens=`echo $2 | cut -d" " -s -f2-`
dnl First check if ac_first_token contain a full path
dnl If yes, check, check if the file exists. Need not check MPI_INSTALL.
ac_mpi_prog_path=`AS_DIRNAME(["$ac_first_token"])`
if test "x$ac_mpi_prog_path" != "x." ; then
AC_MSG_CHECKING([whether $ac_first_token exists and is executable])
if test -x "$ac_first_token" ; then
AC_MSG_RESULT([yes])
$1="$2"
else
AC_MSG_RESULT([no])
$1=
fi
else
dnl ac_first_token does not contain a full path
ac_mpi_prog_$1=
if test "x$MPI_INSTALL" != x ; then
dnl First, check if it can be found under $MPI_INSTALL, i.e.
dnl --with-mpi is used on configure command line
if test -d "${MPI_INSTALL}/bin" ; then
AC_MSG_CHECKING([$ac_first_token under ${MPI_INSTALL}/bin])
if test -x "$MPI_INSTALL/bin/$ac_first_token" ; then
AC_MSG_RESULT([yes])
ac_mpi_prog_$1=$MPI_INSTALL/bin/$ac_first_token
else
AC_MSG_RESULT([no])
fi
else
dnl ${MPI_INSTALL}/bin does not exist, search $MPI_INSTALL
AC_MSG_CHECKING([$ac_first_token under ${MPI_INSTALL}])
if test -x "$MPI_INSTALL/$ac_first_token" ; then
AC_MSG_RESULT([yes])
ac_mpi_prog_$1=$MPI_INSTALL/$ac_first_token
else
AC_MSG_RESULT([no])
fi
fi
if test "x$ac_mpi_prog_$1" != x ; then
$1="${ac_mpi_prog_$1} $ac_rest_tokens"
else
$1=
fi
else
dnl MPI_INSTALL is not set, i.e. --with-mpi is not used
AC_PATH_PROG([ac_mpi_prog_$1], [$ac_first_token])
if test "x$ac_mpi_prog_$1" != x ; then
$1="${ac_mpi_prog_$1} $ac_rest_tokens"
else
$1=
fi
fi
fi
])
dnl
dnl check the availability of a list of MPI executables
dnl
dnl Note $2 can be a list of executable commands to be searched with each
dnl command being the executable file name without command-line option. This is
dnl the case when user does not set the environment variable, for example
dnl MPICC, and we must search one from the candidate list. For example,
dnl UD_MPI_PATH_PROGS([MPICC], [mpicc mpixlc mpifccpx mpipgcc])
dnl
AC_DEFUN([UD_MPI_PATH_PROGS], [
ac_mpi_prog_$1=
if test "x$MPI_INSTALL" != x ; then
if test -d "${MPI_INSTALL}/bin" ; then
AC_PATH_PROGS([ac_mpi_prog_$1], [$2], [], [$MPI_INSTALL/bin])
else
dnl ${MPI_INSTALL}/bin does not exist, search $MPI_INSTALL
AC_PATH_PROGS([ac_mpi_prog_$1], [$2], [], [$MPI_INSTALL])
fi
else
AC_PATH_PROGS([ac_mpi_prog_$1], [$2])
fi
if test "x${ac_mpi_prog_$1}" = x ; then
dnl AC_CHECK_FILES fails when $2 is not found in cross compile
dnl AC_CHECK_FILES([$2], [ac_mpi_prog_$1=$2])
AC_PATH_PROGS([ac_mpi_prog_$1], [$2])
dnl AC_CHECK_PROGS([ac_mpi_prog_$1], [$2])
dnl AC_CHECK_PROGS([ac_mpi_prog_$1], [$2], [], [/])
dnl ac_first_token=`echo $2 | cut -d" " -f1`
dnl if test -f $ac_first_token ; then
dnl ac_mpi_prog_$1=$2
dnl fi
fi
$1=${ac_mpi_prog_$1}
])
dnl
dnl Check how sed command handling in-place option -i and define SED_I
dnl
AC_DEFUN([UD_PROG_SED_I],
[
AC_REQUIRE([AC_PROG_SED])
AC_CACHE_CHECK([for sed handling option -i ], ac_cv_SED_I,[
cat > conftest.sed_i <<EOF
test str1
EOF
ac_cv_err=`$SED -i '' -e 's|str1|str2|g' conftest.sed_i 2>&1`
if test "x$ac_cv_err" = x ; then
ac_cv_SED_I="$SED -i ''"
else
ac_cv_err=`sed -i'' -e 's|str1|str2|g' conftest.sed_i 2>&1`
if test "x$ac_cv_err" = x ; then
ac_cv_SED_I="$SED -i''"
else
AC_MSG_ERROR("No proper sed -i option found")
fi
fi
AS_UNSET(ac_cv_err)])
SED_I="$ac_cv_SED_I"
AC_SUBST(SED_I)
rm -f conftest.sed_i
])