-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·342 lines (305 loc) · 15 KB
/
build
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
#! /bin/bash
# This script needs /bin/bash rather than /bin/sh
###############################################################################
# Note that due to ROSE compatibility with libtool 1.5 and 2.0, some warnings #
# may be output from configure.in and aclocal.m4. These messages come from #
# aclocal, autoheader, autoconf, and automake and can be safely ignored. In #
# fact, they should be filtered out already by the autoconf-filter.pl script. #
# --The Rose Project Management. #
###############################################################################
# Directory containing this script, which must be the top of the source tree.
srcdir="$(dirname "$0")"
#srcdir="${0%/*}"
#srcdir="$(cd $srcdir && pwd)"
# Name of a file that would exist in a ROSE source tree but not other projects
# that might be using this same build script.
SOME_ROSE_FILE="scripts/autoconf-filter.pl"
# This is the default location for build to use as a reference
# to its macro definitions used by Autoconf and Automake.
ROSE_DISTRIBUTION=${ROSE_DISTRIBUTION:-.}
# Parse command-line
do_quiet=yes
do_timing=
# Turn this on by default (header file dependence checking).
# On second through make the default OFF and allow users to activate it using --allow-header-file-dependence-checking
# since this works for Linux (RedHat), but fails for OSX and Ubuntu (and needs to be reviewed with the author of the
# UPC configuration checking when he gets back (or any other excuse will work).
# do_header_file_dependence_checking=yes
do_header_file_dependence_checking=no
while [[ "$#" -gt 0 ]]; do
arg="$1"; shift
case "$arg" in
--quiet)
do_quiet=yes
;;
--verbose)
do_quiet=
;;
--timing)
do_timing=yes
;;
--no-timing)
do_timing=
;;
--srcpath=*)
ROSE_DISTRIBUTION="${arg#*=}"
;;
--srcpath)
ROSE_DISTRIBUTION="$1"; shift
;;
-i)
do_header_file_dependence_checking=no
;;
--ignore-header-file-dependence-checking)
do_header_file_dependence_checking=no
;;
--allow-header-file-dependence-checking)
do_header_file_dependence_checking=yes
;;
*)
echo "$0: unrecognized argument: $arg" >&2
exit 1
;;
esac
done
# If there's no autoconf-filter.pl script in this source tree, then we're building in some project external to ROSE, and
# the "--srcpath" must be specified (or obtained from a config file).
if [ ! -e "$srcdir/$SOME_ROSE_FILE" -a "$ROSE_DISTRIBUTION" = "." ]; then
[ -r $srcdir/config/ROSE_SOURCES ] && ROSE_DISTRIBUTION="$(head -n1 $srcdir/config/ROSE_SOURCES)"
fi
if [ ! -x "$ROSE_DISTRIBUTION/scripts/autoconf-filter.pl" ]; then
echo "$0: use '--srcpath=DIR' to point to the ROSE source tree" >&2
exit 1
fi
# Extracts dotted version number from a tool's "--version" message. Assigns result to $VERSION.
get_version () {
local message=$1
export VERSION=$(echo $message | head -n1 | perl -pe 's/.*?([0-9\.]+).*/$1/')
}
# Returns ok (0) if $need is at least as large as $have, where both are version numbers
# of the form X.Y.Z where X, Y, and Z are non-negative integers. Returns not-ok (1) otherwise.
version_ok () {
local have="$1" need="$2"
local have_major=$(echo $have |cut -d. -f1)
local have_minor=$(echo $have |cut -d. -f2)
local have_patch=$(echo $have |cut -d. -f3)
if [[ -z $have_patch ]]; then have_patch=0; fi
local need_major=$(echo $need |cut -d. -f1)
local need_minor=$(echo $need |cut -d. -f2)
local need_patch=$(echo $need |cut -d. -f3)
if [[ -z $need_patch ]]; then need_patch=0; fi
OK=0; NOT_OK=1
if (( have_major > need_major )); then return $OK; fi
if (( have_major < need_major )); then return $NOT_OK; fi
if (( have_minor > need_minor )); then return $OK; fi
if (( have_minor < need_minor )); then return $NOT_OK; fi
if (( have_patch > need_patch )); then return $OK; fi
if (( have_patch < need_patch )); then return $NOT_OK; fi
return $OK
}
# DQ (12/22/2005): remove the autoconf caches
rm -rf autom4te.cache
###############################################################################################################################
# Test libtool version and run libtoolize. Warn if the libtool version is too old, but run it anyway. Show the command that
# is run by preceding it with a "+ " on stderr as is the usual debugging style for shell scripts.
###############################################################################################################################
echo "checking for glibtool..."
libtoolize_name=
# Liao 2/9/2011. Ensure the libtool on Mac is the gnu one
#
# Look for libtoolize, glibtoolize in various places.
# Liao 2/9/2011. We have better handling now
#
OS="$(uname -s)"
if [ "x$OS" = "xDarwin" ]; then
if [ -n "$(type glibtool)" ]; then
echo "Found glibtool... $(which glibtool)"
elif [ -n "$(type glibtool)" ]; then
echo "checking if $(which libtool) is GNU libtool..."
libtool --version
if [ $? -ne 0 ]; then
echo "Error: $(which libtool) is not GNU libtool!"
exit 1
else
echo "Found glibtool... $(which libtool)"
fi
fi
libtoolize_name="$(which glibtoolize)"
if [ ! -n "$libtoolize_name" ]; then
echo "glibtoolize not found!"
exit 1
fi
fi
if [ ! -n "$libtoolize_name" ]; then
libtoolize_name="$(which libtoolize)"
fi
if [ ! -n "$libtoolize_name" ]; then
# If the user is running build then libtool should be available.
echo "$0: neither libtoolize nor glibtoolize were found in the user's path."
exit 1
fi
# Version required and version actually present.
LIBTOOL_VERSION_PREREQ=1.5.6
get_version "$($libtoolize_name --version)"
LIBTOOL_VERSION="$VERSION"
if [[ -z "$LIBTOOL_VERSION" ]]; then
echo "$0: warning: cannot determine libtool version; skipping libtoolize" 2>&1
elif version_ok "$LIBTOOL_VERSION" "$LIBTOOL_VERSION_PREREQ"; then
(set -x; $libtoolize_name --force --copy --ltdl --automake)
else
echo "$0: warning: libtool $LIBTOOL_VERSION is too old (require >= $LIBTOOL_VERSION_PREREQ); skipping libtoolize" 2>&1
fi
# Liao 2/15/2011
# check flex and yacc
# the assumption is that ./build should only run from a developer version, which requires flex and yacc
# check them in ./configure is inappropriate since the distribution package should already pack generated parsers/scanners.
if [[ -z "$(type flex)" ]]; then
echo "Cannot find flex in your path! Please install GNU flex."
exit 1;
fi
if [[ -z "$(type yacc)" ]]; then
echo "Cannot find yacc in your path! Please install GNU bison."
exit 1;
fi
###############################################################################################################################
# Test version of automake. Having the wrong version of automake is a common problem. We can't test for it in the
# configure.in and we want to catch the problem as early as possible. So we test for it here. This appears to be the only
# place to test for the correct version of automake -- autoconf can use the AC_PREREQ macro, but there is no AM_PREREQ macro
# for automake. [DQ 2009-09-26]
###############################################################################################################################
AUTOMAKE_VERSION_REQ=1.9.6
get_version "`automake --version`"; AUTOMAKE_VERSION=$VERSION
if [[ -z "$AUTOMAKE_VERSION" ]]; then
echo "$0: warning: cannot determine automake version" 2>&1
elif version_ok "$AUTOMAKE_VERSION" "$AUTOMAKE_VERSION_PREREQ"; then
:
else
echo "$0: warning: automake $AUTOMAKE_VERSION is too old (require >= $AUTOMAKE_VERSION_PREREQ)" 2>&1
fi
###############################################################################################################################
# Link in optional projects to the configure scripts.
#
# Each subdirectory of "projects" which which has a file named "rose.config" will be enabled in the build system. The contents
# of the projects's rose.config is copied into config/projects.m4 which is called from ROSE's configure.in.
#
# Usually, the only thing that rose.config will need is the list of Makefiles, which is done with the AC_CONFIG_FILES autoconf
# macro:
# AC_CONFIG_FILES([projects/foo/Makefile projects/foo/subdir/Makefile])
###############################################################################################################################
(
echo "dnl This file generated by the ROSE build script."
echo "AC_DEFUN([ROSE_OPTIONAL_PROJECTS],["
echo "OPTIONAL_PROJECTS="
echo "AC_SUBST(OPTIONAL_PROJECTS)"
for project in projects/*; do
if [[ -f "$project/rose.config" ]]; then
echo "+ NOTE: Adding optional $project" >&2
echo
echo
echo "dnl -----------------------------------------------------------------------------------------------------"
echo "dnl -- This part of the file comes from $project/rose.config"
echo "dnl -----------------------------------------------------------------------------------------------------"
echo "AC_MSG_NOTICE([configuring optional $project])"
echo "OPTIONAL_PROJECTS=\"\$OPTIONAL_PROJECTS ${project#projects/}\""
echo
cat "$project/rose.config"
fi
done
echo "])"
) >config/support-projects.m4
###############################################################################################################################
# Run autoconf tools: aclocal, autoheader, autoconf, and automake
###############################################################################################################################
# Debugging (esp. for NMI machines)
[[ -n "$ACLOCAL_INCLUDES" ]] && echo "ACLOCAL_INCLUDES=$ACLOCAL_INCLUDES"
# Automake will expect these files to always exist even if they are in a conditional. Since we know
# that they will not be used during the build process itself, we can create zero-length dummy files.
# This list should be the same as in configure.in (search for CLASSPATH_COND_IF)
if [[ ! -e src/frontend/CxxFrontend/EDG/Makefile.am ]]; then
for file in \
src/frontend/CxxFrontend/EDG/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_3.3/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_3.3/misc/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_3.3/src/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_3.10/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_3.10/misc/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_3.10/src/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_3.10/src/disp/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_3.10/lib/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_4.0/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_4.0/misc/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_4.0/src/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_4.0/src/disp/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_4.0/lib/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_4.3/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_4.3/misc/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_4.3/src/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_4.3/src/disp/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_4.3/lib/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_SAGE_Connection/Makefile.in \
src/frontend/CxxFrontend/EDG/edgRose/Makefile.in \
src/frontend/CxxFrontend/EDG/edg43Rose/Makefile.in
do
mkdir -p $(dirname $file)
touch $file
done
# TV (05/25/2011): To work when distributed as binary EDG 4.x needs this file
touch src/frontend/CxxFrontend/EDG/EDG_4.0/lib/predefined_macros.txt
touch src/frontend/CxxFrontend/EDG/EDG_4.3/lib/predefined_macros.txt
fi
# Run all autoconf, indenting their output for readability. Exit if a tool fails (this is different than the
# semantics of the original version of this script). The '-I' switches of aclocal are because some macros may be
# installed in non-standard locations (e.g., libxml's on NMI build machines).
header_file_dependence_checking=
if test "x$do_header_file_dependence_checking" = "xno"; then
header_file_dependence_checking=--ignore-deps
fi
(set -ex
aclocal -I $ROSE_DISTRIBUTION/config -I $ROSE_DISTRIBUTION/acmacros -I /usr/share/aclocal $ACLOCAL_INCLUDES
autoheader
autoconf
# DQ (10/17/2011): Allow header file dependencies to be built by default (-a: --add-missing, -c: --copy; made more explicitly clear).
# automake -a -c -i
automake -a -c $header_file_dependence_checking
) 2>&1 |$ROSE_DISTRIBUTION/scripts/autoconf-filter.pl |sed '/^[^+]/s/^/ /'
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
echo "$0: unable to initialize your build environment!" 2>&1
exit 1
fi
###############################################################################################################################
# Finishing up details
###############################################################################################################################
# Automake manual says that if we use AM_CONFIG_HEADER we have to build the stamp-h.in files
touch stamp-h.in
touch stamp-h1.in
# Add some dynamically-generated targets that run tests on various sample binaries. [RPM]
if [[ -f tests/roseTests/binaryTests/Makefile.in ]]; then
(cd $ROSE_DISTRIBUTION && ./scripts/sample_binary_rules.pl) || exit 1
fi
# When timing is selected, add a "time" command to the front of the compiles. This must be done before the --quiet
# handler below is run to get the right output command.
if [[ -n "$do_timing" ]]; then
echo "$0: converting makefiles for timing (use --no-timing to prevent this)" 2>&1
find . -name Makefile.in | grep -v libharu | grep -v libltdl | xargs sed -i~ \
-e "s:^\(LT\)\{0,1\}\(CXX\)\{0,1\}COMPILE =:& echo \"\`pwd\`/\$@\" >> `pwd`/compile_times; /usr/bin/time -o `pwd`/compile_times -a :"
fi
# Rewrite a couple of makefile rules to be less verbose so (1) we can actually see the warning messages
# and (2) XEmacs doesn't get regexp stack overflows when parsing compiler output. See also scripts/rosegit/bin/rosegit-make.
#
# Note:
# The '$(CXX)...' commands must be replaced also because automake generates them for *.o targets that depend on a *.C that
# includes a directory component. For example, the automake rule:
# rdis_SOURCES=RDis/main.C
# generates a Makefile rule like:
# main.o: RDis/main.C
# $(CXX) $(DEFS) ....... `test -f 'RDis/main.C' || echo '$(srcdir)/'`RDis/main.C
# It seems that this might be an error on the part of automake since it bypasses libtool. [RPM 2009-04-04]
#
if [[ -n "$do_quiet" ]]; then
(set -ex; $ROSE_DISTRIBUTION/scripts/quiet-mode) || true;
fi
# Save "--srcpath" value so rosegit-env can pick it up. No need to do this for ROSE itself, just projects using the
# ROSE build script.
if [ ! -e "$srcdir/$SOME_ROSE_FILE" ]; then
echo $ROSE_DISTRIBUTION >$srcdir/config/ROSE_SOURCES 2>/dev/null
fi