forked from PolMine/RcppCWB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·212 lines (187 loc) · 7.98 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
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
#!/bin/sh
# Step 1: Configure CWB
#
# The CWB includes specialized configurations (for macOS, Linux, Solaris).
# We check whether RcppCWB is installed on a system for which a specialized
# configuration is available. If not, the standard unix configuration is
# used.
# Get compiler used by R
CC_R=`$R_HOME/bin/R CMD config CC`
CARBON=""
SOCKETLIB=""
OS=`uname -s`
echo "* operating system detected for CWB configuration: $OS"
case $OS in
Darwin)
ARCH=`uname -m`
case $ARCH in
arm64)
echo "* compiling for darwin-arm64"
CWB_PLATFORM_CONFIG_FILE="darwin-arm64"
CWB_PLATFORM_CONFIG_FILE_CC="unix";;
*)
echo "* compiling for darwin-64"
CWB_PLATFORM_CONFIG_FILE="darwin-64"
CWB_PLATFORM_CONFIG_FILE_CC="unix";;
esac
;;
Linux)
# the 'uname -s' command returns 'Linux' on Fedora, Debian and Ubuntu
DISTRO=`awk -F= '$1=="ID" { print $2 ;}' /etc/os-release`
case "$DISTRO" in
ubuntu)
SUPPORT="supported";;
fedora)
SUPPORT="supported";;
debian)
SUPPORT="supported";;
centos)
SUPPORT="supported";;
*)
SUPPORT="unsupported, adapting the configuration may be necessary";;
esac
echo "* Linux distribution ID: $DISTRO ($SUPPORT)";
# For Debian, Fedora and Ubuntu, the generic Linux configuration works,
# there are no known required adaptions so far. If another distribution is used,
# the previous message informs users that adaptions may be necessary.
ARCH=`lscpu | head -n 1 | grep -oP '\w+$'`
case "$ARCH" in
x86_64)
CWB_PLATFORM_CONFIG_FILE="linux-64";;
i386)
CWB_PLATFORM_CONFIG_FILE="linux";;
*)
echo "* unknown architecture ($ARCH), using Linux config as default"
CWB_PLATFORM_CONFIG_FILE="linux"
;;
esac
# The compiler is set in the unix config file for all architectures
CWB_PLATFORM_CONFIG_FILE_CC="unix";;
SunOS)
CPU_INFO=`psrinfo -pv | sed -n '2p'`
case $CPU_INFO in
SPARK)
CWB_PLATFORM_CONFIG_FILE="solaris_spark"
CWB_PLATFORM_CONFIG_FILE_CC="solaris_spark"
;;
*)
CWB_PLATFORM_CONFIG_FILE="solaris_x86"
CWB_PLATFORM_CONFIG_FILE_CC="solaris_x86"
;;
esac
SOCKETLIB='-lsocket';;
*)
CWB_PLATFORM_CONFIG_FILE="unix"
CWB_PLATFORM_CONFIG_FILE_CC="unix"
echo "* OS unknown, resorting to Unix as CWB default configuration (modifications may be necessary)"
;;
esac
# Inform user about CWB configuration used. To safeguard portability, no inplace
# sed modification (sed option -i is not available on Solaris)
echo "* using CWB platform configuration file: $CWB_PLATFORM_CONFIG_FILE"
sed -e "s/PLATFORM=.*/PLATFORM=$CWB_PLATFORM_CONFIG_FILE/" ./src/cwb/config.mk > ./src/cwb/config.mk.mod
rm ./src/cwb/config.mk
mv ./src/cwb/config.mk.mod ./src/cwb/config.mk
# Adapt CWB configuration file that defines compiler to use compiler chosen
# by user (Makeconf, Makevars file)
echo "* adapt CWB configuration file to use compiler: $CC_R"
sed -e "s/#[[:space:]]*CC[[:space:]]*=[[:space:]]*gcc/CC = $CC_R/" ./src/cwb/config/platform/${CWB_PLATFORM_CONFIG_FILE_CC} > ./tmpfile
rm ./src/cwb/config/platform/${CWB_PLATFORM_CONFIG_FILE_CC}
mv ./tmpfile ./src/cwb/config/platform/${CWB_PLATFORM_CONFIG_FILE_CC}
# Check availability of glib2.0 (download on macOS)
if [ -x "`command -v pkg-config`" ]; then
printf "* using pkg-config to check whether glib-2.0 is available ... ";
pkg-config --exists glib-2.0
PKG_CONFIG_GLIB_INFO=$?
if [ $PKG_CONFIG_GLIB_INFO = 0 ]; then
printf "yes\n";
if [ $OS = "Darwin" ]; then
CARBON="-framework Carbon"
fi
else
printf "no\n";
if [ $OS = "Darwin" ]; then
echo "* glib2.0 missing, downloading static library from GitHub (https://github.com/PolMine/libglib)";
${R_HOME}/bin/Rscript ./tools/maclibs.R `pwd`
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:`pwd`/macos/libglib-master/pkgconfig
# Setting further args required to compile agains glib2.0 in this scenario
CARBON="-framework Carbon"
else
echo "----------------------- CONFIGURATION ERROR --------------------------"
echo "Configuration failed because 'glib-2.0' was not found. Try installing:"
echo " * deb: libglib2.0-dev (Debian, Ubuntu, etc)"
echo " * yum: glib* (Fedora, CentOS, etc)"
echo " * csw: glib2 (Solaris)"
echo "----------------------------------------------------------------------"
/opt/csw/bin/pkgutil -y -i -W glib2
fi
fi
else
echo "WARNING: Aborting as the 'pkg-config' tool required to find include paths is missing."
echo "Check whether 'pkg-config' is installed and make sure that 'pkg-config' is on your PATH."
exit 1
fi
printf "* using pkg-config to get linker flags for glib-2.0: "
GLIB_LINKER_FLAGS="`pkg-config --libs glib-2.0`"
printf "%s\n" "$GLIB_LINKER_FLAGS"
# Check availability of pcre2
printf "* check whether pcre2 is available ... ";
if [ -x "`command -v pcre2-config`" ]; then
PCRE2_VERSION=`pcre2-config --version`
printf "yes (version: $PCRE2_VERSION)\n"
else
printf "no\n"
echo "----------------------- CONFIGURATION ERROR --------------------------"
echo "Configuration failed because 'pcre2' is not available. Try installing:"
echo " * deb: libpcre2 libpcre2-dev (Debian, Ubuntu, etc)"
echo " * yum: pcre2 pcre2-devel (Fedora, CentOS, etc)"
echo " * csw: libpcre2_dev (Solaris)"
echo "----------------------------------------------------------------------"
fi
printf "* checking whether pcre2test is available ... ";
if [ -x "`command -v pcre2test`" ]; then
printf "yes\n";
printf "* check whether pcre2 has been configured with unicode properties support ... ";
case "`pcre2test -C unicode`" in
0)
printf "no\n";
echo "------------------------------- WARNING -------------------------------"
echo "No Unicode properties support found for pcre2. RcppCWB may not work as"
echo "intended and throw errors. Recommended solution:"
echo "Configure pcre2 without '--disable-unicode' option and re-compile."
echo "------------------------------------------------------------------------";;
1)
printf "yes\n";;
*)
printf "unknown\n";;
esac
else
printf "no\n";
fi
printf "* using pcre2-config to get libdirs for pcre2 (8bit): "
PCRE2_LIBDIRS="`pcre2-config --libs8`"
printf "%s\n" "$PCRE2_LIBDIRS"
printf "* using pcre2-config to get cflags for pcre2: "
PCRE2_CFLAGS="`pcre2-config --cflags`"
printf "%s\n" "$PCRE2_CFLAGS"
# Step 2: Generate Makevars file
#
# The Makevars file is generated here, to pass the directory where RcppCWB
# is build (variable PKG_DIR) into the Makevars file.
BUILD_DIR="`pwd`"
printf "* using build directory: %s\n" ${BUILD_DIR}
CWB_DIR="`pwd`/src/cwb"
if [ -f ./src/Makevars ]; then rm ./src/Makevars; fi
printf "PKG_CPPFLAGS=-I%s/src/cwb/cqp -I%s/src/cwb/cl -I%s/src/cwb/CQi %s\n" ${BUILD_DIR} ${BUILD_DIR} ${BUILD_DIR} "$PCRE2_CFLAGS" > ./src/Makevars
printf "PKG_LIBS=-L%s/cl -L%s/cqp -L%s/utils -lcwb -lcqp -lcl %s %s %s %s\n" ${CWB_DIR} ${CWB_DIR} ${CWB_DIR} "$GLIB_LINKER_FLAGS" "$PCRE2_LIBDIRS" "$SOCKETLIB" "$CARBON" >> ./src/Makevars
printf "\${SHLIB}: libcl.a libcqp.a libcwb.a\n" >>./src/Makevars
printf "libcl.a: depend\n" >> ./src/Makevars
printf "\tcd cwb; R_PACKAGE_SOURCE=%s PKG_CONFIG_PATH=%s \${MAKE} cl\n" ${CWB_DIR} ${PKG_CONFIG_PATH} >> ./src/Makevars
printf "libcqp.a: depend\n" >> ./src/Makevars
printf "\tcd cwb; R_PACKAGE_SOURCE=%s PKG_CONFIG_PATH=%s \${MAKE} cqp\n" ${CWB_DIR} ${PKG_CONFIG_PATH} >> ./src/Makevars
printf "libcwb.a: depend\n" >> ./src/Makevars
printf "\tcd cwb; R_PACKAGE_SOURCE=%s PKG_CONFIG_PATH=%s \${MAKE} utils\n" ${CWB_DIR} ${PKG_CONFIG_PATH} >> ./src/Makevars
printf "depend: clean\n" >> ./src/Makevars
printf "\tcd cwb; R_PACKAGE_SOURCE=%s PKG_CONFIG_PATH=%s \${MAKE} depend\n" ${CWB_DIR} ${PKG_CONFIG_PATH} >> ./src/Makevars
printf "clean:\n" >> ./src/Makevars
printf "\tcd cwb; R_PACKAGE_SOURCE=%s PKG_CONFIG_PATH=%s \${MAKE} clean\n" ${CWB_DIR} ${PKG_CONFIG_PATH} >> ./src/Makevars