-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautogen.sh
executable file
·193 lines (165 loc) · 5.21 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/bin/sh
############################# MPC License ##############################
# Wed Nov 19 15:19:19 CET 2008 #
# Copyright or (C) or Copr. Commissariat a l'Energie Atomique #
# #
# IDDN.FR.001.230040.000.S.P.2007.000.10000 #
# This file is part of the MPC Runtime. #
# #
# This software is governed by the CeCILL-C license under French law #
# and abiding by the rules of distribution of free software. You can #
# use, modify and/ or redistribute the software under the terms of #
# the CeCILL-C license as circulated by CEA, CNRS and INRIA at the #
# following URL http://www.cecill.info. #
# #
# The fact that you are presently reading this means that you have #
# had knowledge of the CeCILL-C license and that you accept its #
# terms. #
# #
# Authors: #
# - CARRIBAULT Patrick patrick.carribault@cea.fr #
# - PERACHE Marc marc.perache@cea.fr #
# - JAEGER Julien julien.jaeger@cea.fr #
# #
########################################################################
# Path to the configure script
SCRIPT=$(readlink -f "$0")
# Directory containing configure
SCRIPTPATH=$(dirname "$SCRIPT")
# Where MPC is currently being BUILT
PROJECT_BUILD_DIR=$(readlink -f "$PWD")
# Move to script directory first.
cd $SCRIPTPATH
ret=0
err()
{
1>&2 printf "Error: $@\n"
ret=1
}
die()
{
err "$1"
exit 1
}
extract_version()
{
"$1" --version | head -n 1 | grep -E -o "[0-9]+(\.[0-9]+)*"
}
spack_tips()
{
echo "========================="
echo "Consider running:"
echo "$ spack install autoconf@${ac_expect} automake@${am_expect} libtool@${lt_expect}"
echo "$ spack load autoconf@${ac_expect} automake@${am_expect} libtool@${lt_expect}"
echo "========================="
}
arc=$(command -v autoreconf)
ac=$(command -v autoconf)
am=$(command -v automake)
lt=$(command -v libtoolize)
ptch=$(command -v patch)
test -n "$arc" || err "No 'autoreconf' command in PATH. Please install autoconf first."
test -n "$ac" || err "No 'autoconf' command in PATH. Please install autoconf first."
test -n "$am" || err "No 'automake' command in PATH. Please install automake first."
test -n "$lt" || err "No 'libtoolize' command in PATH. Please install libtool first."
test -n "$ptch" || err "No 'patch' command in PATH. Please install patch first."
if test "$ret" = "0"; then
$arc -vi -W syntax
ret=$?
fi
if test "$ret" != "0"; then
die "Abort configuration due to error(s) above.\n"
fi
#
# Patching Phase
#
#
# Check if a patch is already applied to a given file
# Args:
# - $1 : Magic Pattern
#
# Returns:
# - PATCHED = yes | no
#
check_for_patch()
{
CNT=$(grep -c "$1" "${SCRIPTPATH}/configure")
if test "x${CNT}" = "x0"; then
PATCHED="no"
else
PATCHED="yes"
fi
}
#
# Add a comment in the configure to notify that patch is done
#
# Args:
# - $1 : watermark to be added
#
watermark_configure()
{
echo "# MPC has applied patch $1" >> "${SCRIPTPATH}/configure"
}
#
# Parse patch watermark
#
# Args:
# - $1: path to patch
#
# Returns:
# - WATERMARK: what is to be used to mark patch done
#
parse_watermark()
{
WATERMARK=$(basename "$1" | sed "s/\.patch//g" | cut -d "-" -f 2)
if test -z "${WATERMARK}"; then
die "Could not parse watermark in $1"
fi
}
#
# Apply all patches located in config/conf_patches/
#
# THEY must follow these guidelines:
# - Named as ORDER-MAGIC.patch
# - ORDER is the order of application 000 to 999
# - MAGIC is BOTH the patch description and patch watermark
apply_configuration_patches()
{
for i in "${SCRIPTPATH}"/config/conf_patches/*.patch
do
parse_watermark "$i"
check_for_patch "${WATERMARK}"
if test "x${PATCHED}" = "xno"; then
patch -p1 < "$i" || die "Could not apply ${WATERMARK} patch"
watermark_configure "${WATERMARK}"
echo "PATCH: ${WATERMARK} APPLIED"
else
echo "PATCH: ${WATERMARK} already APPLIED"
fi
done
}
apply_configuration_patches
# Here is the patch description
# 001-MPC_FORTRAN_FIX_LIB_WITH_SPACE
#
# Fix for Fortran libraries in libtools as reported in
#
# https://debbugs.gnu.org/cgi/bugreport.cgi?bug=10972
# https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21137
# https://github.com/open-mpi/ompi/issues/576
#
# 002-MPC_FLANG_SUPPORT
#
# Allow libtool to know flang (taken from OpenMPI)
# facing the exact same issues
#
# https://github.com/open-mpi/ompi/commit/6f8010c685d6fb0554c80cde9f131996081f7105
#
# Mark the configure as GENERATED with ./autogen.sh (if needed)
#
IS_AUTOGEN=$(tail -n 1 "${SCRIPTPATH}/configure"| grep -c "MPC_AUTOGEN_WAS_USED")
if test "x${IS_AUTOGEN}" = "x0"; then
echo "# MPC_AUTOGEN_WAS_USED" >> "${SCRIPTPATH}/configure"
fi
# Go back to build dir
cd $PROJECT_BUILD_DIR