@@ -36,14 +36,164 @@ while [ -h "$source" ] ; do
36
36
fi
37
37
done
38
38
39
+ function printHelp {
40
+ if [[ " $OSTYPE " == " darwin" * ]]; then
41
+ echo " usage: configure_fastr [--help] [--configure-etc [--enable-native-compilers-toolchain]] [--gcc-lib-path <path>]"
42
+ else
43
+ echo " usage: configure_fastr [--help] [--configure-etc [--enable-native-compilers-toolchain]]"
44
+ fi
45
+
46
+ echo " "
47
+ echo " optional arguments:"
48
+ echo " --configure-etc Configure the files in the 'etc' folder. Unless '--enable-native-compilers-toolchain' is specified, the configuration will not affect the 'etc/Makeconf' file to preserve the original compilers toolchain configuration."
49
+ echo " --enable-native-compilers-toolchain Include the 'etc/Makefile' file into the configuration. It will replace the original compiler toolchain configuration in 'etc/Makefile' with the native compilers toolchain."
50
+ if [[ " $OSTYPE " == " darwin" * ]]; then
51
+ echo " --gcc-lib-path <path> Use the <path> to locate the required gfortran libraries."
52
+ fi
53
+
54
+ echo " "
55
+ echo " examples:"
56
+ echo " * Basic FastR configuration:"
57
+ echo " "
58
+ echo " configure_fastr"
59
+ echo " "
60
+ echo " * An advanced FastR configuration with an additional configuration of the 'etc' folder except 'etc/Makefile':"
61
+ echo " "
62
+ echo " configure_fastr --configure-etc"
63
+ echo " "
64
+ if [[ " $OSTYPE " == " darwin" * ]]; then
65
+ echo " * The most advanced FastR configuration with the complete configuration of the 'etc' folder. It also specifies the GCC path to locate the required libraries:"
66
+ echo " "
67
+ echo " configure_fastr --configure-etc --enable-native-compilers-toolchain --gcc-lib-path /usr/local/Cellar/gcc\@4.9/4.9.4_1/lib/gcc/4.9/"
68
+ else
69
+ echo " * The most advanced FastR configuration with the complete configuration of the 'etc' folder:"
70
+ echo " "
71
+ echo " configure_fastr --configure-etc --enable-native-compilers-toolchain"
72
+ fi
73
+ echo " "
74
+ }
75
+
76
+ GCC_LIB_PATH=" "
77
+ CONFIGURE_ARGS=" "
78
+ CONFIGURE_ETC=0
79
+ while [[ $# -gt 0 ]]; do
80
+ case $1 in
81
+ --help)
82
+ printHelp
83
+ exit 0
84
+ ;;
85
+ --gcc-lib-path)
86
+ shift
87
+ GCC_LIB_PATH=$1
88
+ ;;
89
+ --configure-etc)
90
+ CONFIGURE_ETC=1
91
+ ;;
92
+ * )
93
+ CONFIGURE_ARGS=" $CONFIGURE_ARGS $1 "
94
+ ;;
95
+ esac
96
+ shift
97
+ done
98
+
39
99
(
40
- export GRAALVM_VERSION=` grep -o ' GRAALVM_VERSION=.*' " $( dirname " $source " ) /../../../../release" | cut -d= -f2`
41
- cd -P " $( dirname " $source " ) /../etc"
42
- ./configure --with-x=no --with-aqua=no --enable-memory-profiling FFLAGS=-O2 $@
43
- ed Makeconf < edMakeconf.etc
44
- export R_DEFAULT_PACKAGES=base
45
- R_LIBS_USER=` ../bin/R --slave -e ' cat(path.expand(Sys.getenv("R_LIBS_USER")))' `
46
- echo " Creating user specific library directory: $R_LIBS_USER "
47
- mkdir -p " $R_LIBS_USER "
48
- echo " DONE"
100
+ if [[ " $OSTYPE " == " linux-gnu" ]]; then
101
+ echo " int main(){}" | gcc -x c -Wl,--no-as-needed -lgfortran -lgcc_s -lquadmath -o /dev/null - > /dev/null 2> /dev/null
102
+ res=$?
103
+ if [[ $res != 0 ]]; then
104
+ echo " Cannot build a simple C program linking with libgfortran, libgcc_s, and libquadmath."
105
+ echo " Please install GCC using:"
106
+ echo " On Debian based systems: apt-get install build-essential"
107
+ echo " On CentOS/RHEL: yum groupinstall \" Developent Tools\" "
108
+ echo " "
109
+ printHelp
110
+ exit 1
111
+ fi
112
+ elif [[ " $OSTYPE " == " darwin" * ]]; then
113
+ cd -P " $( dirname " $source " ) /../lib"
114
+ # correct paths on Mac OSX
115
+ GFORTRAN_LIBRARIES=" libgfortran.3.dylib libgfortran.5.dylib libquadmath.0.dylib libgomp.1.dylib libgcc_s.1.dylib"
116
+ # This allows determining if all libraries were found after the main loop
117
+ GFORTRAN_LIBRARIES_CHECK=" libgfortran libquadmath libgomp libgcc_s"
118
+ GFORTRAN_LOCATIONS=" $GCC_LIB_PATH /opt/local/lib /opt/local/lib/libgcc /usr/local/gfortran/lib"
119
+ TARGET_LIBRARIES=" ` find ../library/* | grep " \(\.dylib\|\.so\)$" ` ` find * | grep " \(\.dylib\|\.so\)$" ` "
120
+ FOUND=" "
121
+ LAST_FOUND=" "
122
+ for GFORTRAN_LIB in $GFORTRAN_LIBRARIES
123
+ do
124
+ # Remove the 'dylib' extension
125
+ GFORTRAN_LIB_BASE=${GFORTRAN_LIB% .* }
126
+ # Remove the number extension
127
+ GFORTRAN_LIB_BASE=${GFORTRAN_LIB_BASE% .* }
128
+ if [ " $LAST_FOUND " = " $GFORTRAN_LIB_BASE " ] ; then
129
+ # A previous version of the current library has already been found
130
+ echo " skipping $GFORTRAN_LIB "
131
+ continue ;
132
+ fi
133
+
134
+ for LOCATION in $GFORTRAN_LOCATIONS
135
+ do
136
+ if test -f " ${LOCATION} /${GFORTRAN_LIB} " ; then
137
+ LIB_LOCATION=" ${LOCATION} /${GFORTRAN_LIB} "
138
+ FOUND=" $FOUND $GFORTRAN_LIB_BASE "
139
+ LAST_FOUND=$GFORTRAN_LIB_BASE
140
+
141
+ echo " ${GFORTRAN_LIB} found at ${LIB_LOCATION} "
142
+ for TARGET_LIB in $TARGET_LIBRARIES
143
+ do
144
+ # don't look at symlinks
145
+ if [ ! -L " ${TARGET_LIB} " ] ; then
146
+ # grep for the current path of this gfortran library in this library's linking info
147
+ CURRENT_LIB_NAME=` otool -L ${TARGET_LIB} | grep -o " \t.*${GFORTRAN_LIB_BASE} " `
148
+ if [ ! -z " $CURRENT_LIB_NAME " ] ; then
149
+ if [ " $CURRENT_LIB_NAME " != " $LIB_LOCATION " ] ; then
150
+ # change to the new location
151
+ echo " changing path to ${GFORTRAN_LIB} in ${TARGET_LIB} to $LIB_LOCATION "
152
+ install_name_tool -change $CURRENT_LIB_NAME $LIB_LOCATION ${TARGET_LIB}
153
+ fi
154
+ fi
155
+ fi
156
+ done
157
+
158
+ break
159
+
160
+ fi
161
+ done
162
+ done
163
+
164
+ if [ " $FOUND " != " $GFORTRAN_LIBRARIES_CHECK " ] ; then
165
+ echo " From expected libraries '$GFORTRAN_LIBRARIES_CHECK ' found only '$FOUND '."
166
+ echo " Please ensure that you have gcc installed on your system, e.g., using homebrew or MacPorts (brew install gcc)."
167
+ echo " If it is installed in a non-standard location, you can specify its location using the '--gcc-lib-path' parameter."
168
+ echo " "
169
+ printHelp
170
+ exit 1
171
+ fi
172
+
173
+ else
174
+ echo " Unknown operating system."
175
+ echo " FastR may still work."
176
+ echo " Make sure that GCC including gfortran and OpenMP is installed on your system."
177
+ fi
178
+
179
+ if [[ $CONFIGURE_ETC = 1 ]]; then
180
+ export GRAALVM_VERSION=` grep -o ' GRAALVM_VERSION=.*' " ../../../../release" | cut -d= -f2`
181
+ cd ../etc
182
+ echo " Running the configure script..."
183
+ ./configure --with-x=no --with-aqua=no --enable-memory-profiling FFLAGS=-O2 $CONFIGURE_ARGS > configure.log 2>&1
184
+ res=$?
185
+ if [[ $res != 0 ]]; then
186
+ echo " The configuration step failed."
187
+ echo " The log was saved into ${PWD} /configure.log"
188
+ echo " FastR may still work, but compilation of some R packages may fail"
189
+ exit 1
190
+ fi
191
+ ed Makeconf < edMakeconf.etc > /dev/null 2> /dev/null
192
+ export R_DEFAULT_PACKAGES=base
193
+ R_LIBS_USER=` " ../bin/R" --slave -e ' cat(path.expand(Sys.getenv("R_LIBS_USER")))' `
194
+ echo " Creating user specific library directory: $R_LIBS_USER "
195
+ mkdir -p " $R_LIBS_USER "
196
+ echo " DONE"
197
+ fi
198
+
49
199
)
0 commit comments