-
Notifications
You must be signed in to change notification settings - Fork 4
/
autogen.sh
executable file
·171 lines (143 loc) · 4.07 KB
/
autogen.sh
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#! /usr/bin/env bash
##########################################
## Generic Utility Functions
##########################################
echo_n() {
# "echo_n" isn't portable, must portably implement with printf
printf "%s" "$*"
}
check_autotools_version()
{
tool=$1
req_ver=$2
curr_ver=$($tool --version | head -1 | cut -f4 -d' ' | xargs echo -n)
if [ "$curr_ver" -ge "$req_ver" ]; then
echo ""
echo "$tool version mismatch ($req_ver) required"
exit
fi
}
##########################################
## Input Initialization
##########################################
# default MPI path
# drop any error reported by which command.
tmp_mpidir=`which mpicc 2>/dev/null`
mpidir=`echo $tmp_mpidir| sed -e 's_/[^/]*$__g'`/../
mpih_path=
# Detect Cray MPI
if [ "$mpidir" = "/../" ] || [ -d /opt/cray/ ] ; then
if [ ! -z "$CRAY_MPICH_DIR" ] ; then
mpidir=$CRAY_MPICH_DIR
elif [ ! -z "$CRAY_MPICH2_DIR" ] ; then
mpidir=$CRAY_MPICH2_DIR
fi
fi
# user specified MPI path
for arg in "$@" ; do
case $arg in
-with-mpi=*|--with-mpi=*)
mpidir=`echo "A$arg" | sed -e 's/.*=//'`
;;
--help|-h|-help)
cat <<EOF
./autogen.sh [ --with-mpi=/path/to/mpi/installation ]
EOF
exit
;;
esac
done
##########################################
## Autotools Version Check
##########################################
echo_n "Checking for autoconf version..."
check_autotools_version autoconf 2.69
echo "done"
echo_n "Checking for automake version..."
check_autotools_version automake 1.15
echo "done"
echo_n "Checking for libtool version..."
check_autotools_version libtool 2.4.6
echo "done"
echo ""
##########################################
## MPI Wrapper Generation
##########################################
# - output
wrap_file=src/user/mpi_wrap.c
# - MPI
echo_n "Checking header file mpi.h at $mpidir ..."
mpih_file=$mpidir/include/mpi.h
if [ ! -f $mpih_file ];then
echo "not found (error)"
exit 1
else
echo "done"
mpih_path=`cd $(dirname $mpih_file) ; pwd ; cd $OLDPWD`/mpi.h
echo "Found $mpih_path"
fi
echo_n "Generating MPI wrappers... "
./maint/buildiface --infile $mpih_path --outfile $wrap_file
echo "done"
# - MPI IO
echo ""
echo_n "Checking header file mpio.h at $mpidir ..."
mpioh_file=$mpidir/include/mpio.h
if [ ! -f $mpioh_file ];then
echo "not found"
else
echo "done"
mpioh_path=`cd $(dirname $mpioh_file) ; pwd ; cd $OLDPWD`/mpio.h
echo "Found $mpioh_path"
# add IO functions only when MPI supports it
echo_n "Generating MPI IO wrappers... "
./maint/buildiface --infile $mpioh_path --outfile $wrap_file --append
echo "done"
fi
##########################################
## Others
##########################################
# It is very easy to not clone recursively.
# This will fix this issue if it exists and is otherwise innocuous.
# Conditionalizing it on the presence of .git means it will not
# run when the user did not clone the code.
if [ -d ".git" ] ; then
if [ ! -f "src/hwloc/autogen.sh" ] || [ ! -f "src/openpa/autogen.sh" ] ; then
echo "=== Attempting to initialize missing submodules ==="
(git submodule init && git submodule update) || exit 1
fi
fi
subdirs=test
# copy confdb
echo ""
for subdir in $subdirs ; do
subconfdb_dir=$subdir/confdb
echo_n "Syncronizing confdb -> $subconfdb_dir... "
if [ -x $subconfdb_dir ] ; then
rm -rf "$subconfdb_dir"
fi
cp -pPR confdb "$subconfdb_dir"
echo "done"
done
# apply patch for submodules
echo ""
echo "=== Applying patches ==="
( maint/apply_patch.bash )
echo "done"
# autogen for submodules
extdirs="src/hwloc src/openpa"
for extdir in $extdirs ; do
if [ -d "$extdir" -o -L "$extdir" ] ; then
echo ""
echo "=== Running third-party initialization in $extdir ==="
(cd $extdir && ./autogen.sh) || exit 1
echo "done"
fi
done
# generate configures
for subdir in . $subdirs ; do
echo ""
echo "=== Generating configure in $subdir ==="
(cd $subdir && autoreconf -vif) || exit 1
echo "done"
done