forked from chapel-lang/chapel
-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure
executable file
·165 lines (149 loc) · 4.25 KB
/
configure
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
#!/bin/bash
if [ ! -d util ]
then
echo Error: missing util/. Must be run from CHPL_HOME.
exit -1
fi
if [ ! -d compiler/main ]
then
echo Error: missing compiler/main/. Must be run from CHPL_HOME.
exit -1
fi
# Let ORIG_CHPL_HOME be PWD or CHPL_HOME
ORIG_CHPL_HOME="${CHPL_HOME:-$PWD}"
export CHPL_HOME="$PWD"
# PREFIX is for split installations, e.g. /usr/bin/chpl, /usr/share/chapel
PREFIX=/usr/local
PREFIX_SET=0
# DEST_DIR is for installations basically copying source layout
# Different from DESTDIR, which is for staged installs
# this variable is for installing the Chapel directory in one place
# (to mirror release / source checkout)
DEST_DIR=""
DEST_DIR_SET=0
# Argument parsing
for arg in "$@"
do
case $arg in
#e.g. -s|--short)
--prefix=*)
PREFIX="${arg#*=}"
PREFIX_SET=1
shift
;;
--chpl-home=*)
DEST_DIR="${arg#*=}"
DEST_DIR_SET=1
shift
;;
*)
echo
echo "Usage: $0 [--prefix=PREFIX] [--chpl-home=DEST_DIR]"
echo
echo " --prefix=PREFIX selects a split installation"
echo " e.g. PREFIX could be /usr/ to install"
echo " to /usr/bin/chpl, /usr/share/chapel/"
echo " e.g. /usr/share/chapel/<vers>/modules"
echo
echo " --chpl-home=DEST_DIR selects a bundled installation"
echo " e.g. DEST_DIR could be /opt/chapel/ to install"
echo " to /opt/chapel with subdirectories"
echo " matching the source code / release"
echo " e.g. /opt/chapel/modules"
echo
exit -1
;;
esac
done
# Check that PREFIX and DEST_DIR are not both set.
if [ "$PREFIX_SET" -ne 0 ]
then
if [ "$DEST_DIR_SET" -ne 0 ]
then
echo "Error: both --prefix and --chpl-home were provided"
exit -1
fi
fi
# Save configured installation prefix/dir
rm -f configured-chpl-home
rm -f configured-prefix
CONFIGURED=""
if [ "$DEST_DIR_SET" -ne 0 ]
then
case $DEST_DIR in
(/*) pathchk -- "$1";;
(*)
echo "error: expected an absolute directory name for --chpl-home: $DEST_DIR"
exit -1
;;
esac
# Save target installation directory for 'make install' / install.sh
echo "$DEST_DIR" > configured-chpl-home
CONFIGURED=configured-chpl-home
else
case $PREFIX in
(/*) pathchk -- "$1";;
(*)
echo "error: expected an absolute directory name for --prefix: $PREFIX"
exit -1
;;
esac
# Save prefix for building the compiler
echo "$PREFIX" > configured-prefix
CONFIGURED=configured-prefix
fi
# Check that the file we added exists in ORIG_CHPL_HOME
if [ ! -f "$ORIG_CHPL_HOME/$CONFIGURED" ]
then
echo "Error: CHPL_HOME is not the same as PWD. Please reset or unset CHPL_HOME"
echo " CHPL_HOME is $ORIG_CHPL_HOME"
echo " PWD is $PWD"
echo
echo " try"
echo
echo " unset CHPL_HOME"
echo
exit -1
fi
# Save currently selected configuration
# Since printchplenv uses chplconfig, we generate a temporary file
# and then move it.
# Note that the resulting chplconfig is expected to cover the same
# material as any existing chplconfig.
./util/printchplenv --all --simple --overrides --anonymize > configured-chplconfig
mv configured-chplconfig chplconfig
# Compile the Python scripts in util before installation.
# We want to do this before installing, but not in the install script
# because that might have elevated privileges. We don't need to do
# it for typical use of a source release (since Python will handle it).
make compile-util-python
echo
echo " Currently selected Chapel configuration:"
echo
./util/printchplenv --anonymize
echo
echo " Selected installation options:"
echo
if [ "$DEST_DIR_SET" -ne 0 ]
then
echo "install to CHPL_HOME: $DEST_DIR"
else
echo "PREFIX: $PREFIX"
fi
echo
echo " To change the selected Chapel configuration, set environment variables."
echo " See doc/rst/usingchapel/chplenv.rst"
echo " To change installation options, see ./configure --help"
echo
echo " If the configuration above is appropriate, build Chapel with:"
echo
echo "make"
echo
echo " and possibly install it with"
echo
echo "make install"
echo
echo " Once Chapel is in your PATH, you can verify basic functionality with:"
echo
echo "make check"
echo