forked from rose-compiler/rose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·420 lines (370 loc) · 17.8 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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
#! /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_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
--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=
ACLOCAL_HOME=$(aclocal --print-ac-dir)
# 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 libtool)" ]; then
echo "checking that $(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
if [ -n "$(type glibtoolize)" ]; then
libtoolize_name="$(which glibtoolize)"
elif [ -n "$(type libtoolize)" ]; then
echo "checking that $(which libtoolize) is GNU libtoolize..."
libtoolize --version
if [ $? -ne 0 ]; then
echo "Error: $(which libtoolize) is not GNU libtoolize!"
exit 1
else
libtoolize_name="$(which libtoolize)"
fi
fi
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
# Pei-Hung 10/25/2017
# libltdl copied through libtoolize would require a specific version of aclocal and automake depending on the libtool version.
# rerun aclocal in libltdl source directory will regenerate aclocal.m4 and eliminate that software dependence.
# JL 03/16/2018 libtool development package required
echo "+ $libtoolize_name --force --copy --ltdl --automake"
$libtoolize_name --force --copy --ltdl --automake
if [ $? -ne 0 ]; then
echo "libtool error: you may need to install libtool development package";
echo " build stopped";
exit 1;
else
cd libltdl
echo "+ autoreconf"
autoreconf
if [ $? -ne 0 ]; then
echo "autoreconf error: build stopped";
exit 1;
fi
cd .. # cd back to top directory
fi
else
echo "$0: error: libtool $LIBTOOL_VERSION is too old (); skipping libtoolize" 2>&1
exit 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
###############################################################################################################################
# Read the ROSE version string from the first line of the "ROSE_VERSION" file and insert it wherever it's needed.
###############################################################################################################################
if [ ! -r ROSE_VERSION ]; then
echo "$0: cannot find the 'ROSE_VERSION' file containing the ROSE version string" >&2
exit 1
fi
rose_version=$(head -n1 ROSE_VERSION)
if [ "$rose_version" = "" ]; then
echo "$0: 'ROSE_VERSION' file does not contain a ROSE version string" >&2
exit 1
fi
sed -i~ -e '/^AC_INIT(/ s/^\(AC_INIT *(\[.*\], *\[\).*\(\] *).*\)/\1'"$rose_version"'\2/' configure.ac
###############################################################################################################################
# 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_4.12/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_4.12/misc/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_4.12/src/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_4.12/src/disp/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_4.12/lib/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_5.0/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_5.0/misc/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_5.0/src/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_5.0/src/disp/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_5.0/lib/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_6.0/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_6.0/misc/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_6.0/src/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_6.0/src/disp/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_6.0/lib/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_6.1/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_6.1/misc/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_6.1/src/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_6.1/src/disp/Makefile.in \
src/frontend/CxxFrontend/EDG/EDG_6.1/lib/Makefile.in \
src/frontend/CxxFrontend/EDG/edgRose/Makefile.in
do
mkdir -p $(dirname $file)
touch $file
done
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 [ "$do_header_file_dependence_checking" = "no" ]; then
header_file_dependence_checking=--ignore-deps
fi
(set -ex
aclocal -I $ROSE_DISTRIBUTION/config -I $ROSE_DISTRIBUTION/acmacros -I $ACLOCAL_HOME $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).
# DQ (10/2/2015): The remaining warning that we want to specific to subdir-objects is in catagory "unsupported"
# automake -a -c -i
# automake -a -c $header_file_dependence_checking
# automake -a -c $header_file_dependence_checking --warnings=none
automake -a -c $header_file_dependence_checking --warnings=no-unsupported
) 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
# The configure script is chatty by default. It has a "--quiet" switch and a "--verbose" switch, but these
# orthogonal. In other words, you can invoke configure with "--quiet --verbose" and it actually means something
# (although I'm not certain exactly what it means, but it's different than just "--quiet", or just "--verbose", or
# neither). The following patch makes the configure script quiet by default and causes "--quiet" and "--verbose" to be
# inverses of one another. Not that bit a deal if the patch fails since the original configure script already accepts
# "--quiet" and "--verbose", it will just have the wrong defaults and treat them as orthogonal concepts. [Robb Matzke,
# 2019-01-19]
patch -p0 <<'EOF'
--- configure 2019-01-19 15:23:24.640101972 -0500
+++ configure.patched 2019-01-19 15:25:23.344418954 -0500
@@ -1966,7 +1966,7 @@
program_prefix=NONE
program_suffix=NONE
program_transform_name=s,x,x,
-silent=
+silent=yes
site=
srcdir=
verbose=
@@ -2238,7 +2238,7 @@
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil)
- silent=yes ;;
+ silent=yes verbose= ;;
-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
@@ -2289,7 +2289,7 @@
target_alias=$ac_optarg ;;
-v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
+ verbose=yes silent= ;;
-version | --version | --versio | --versi | --vers | -V)
ac_init_version=: ;;
EOF
###############################################################################################################################
# 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
# 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
# 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
cat <<EOF
+---------------------------------------+
| \$ROSE_BLD/build terminated normally. |
+---------------------------------------+
Now, create an empty build directory and within that
directory run \$ROSE_SRC/configure to initialize your new
build directory for "make". \$ROSE_SRC is the absolute
path of your ROSE source tree.
Full installation instructions can be found here:
https://github.com/rose-compiler/rose/wiki/How-to-Set-Up-ROSE
Thank you for using ROSE.
EOF