This repository has been archived by the owner on Feb 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
/
configure.ac
231 lines (193 loc) · 6.87 KB
/
configure.ac
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
AC_PREREQ(2.62)
## ---[ VERSION ]-------------------------------------------------------------
AC_INIT()
: ${R_HOME=`R RHOME`}
if test -z "${R_HOME}"; then
echo "could not determine R_HOME"
exit 1
fi
CC=`"${R_HOME}/bin/R" CMD config CC`
CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS`
CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
LDFLAGS=`"${R_HOME}/bin/R" CMD config LDFLAGS`
CXX=`"${R_HOME}/bin/R" CMD config CXX`
if test -z "$CXX"; then
AC_MSG_ERROR([No C++ compiler is available])
fi
CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS`
AC_LANG(C++)
RBIN="${R_HOME}/bin/R"
## OS checking borrowed from rgl package by Duncan Murdoch
##AC_CONFIG_AUX_DIR(src/build/autoconf)
if test `uname` = "Darwin" ; then
darwin="yes"
## we want the *build* cputype and not the host one.
cmd=`echo $CC $CFLAGS | grep -E 'x86_64|ppc64|-m64'`
if test -n "$cmd"; then
have_64bit="yes"
else
have_64bit="no"
fi
else
darwin="no"
fi
# check the presense of pkg-config (from Cairo package)
AC_PATH_PROG([PKGCONF],[pkg-config],[],[$PATH:/usr/local/bin:ext/bin:ext:/sw/bin:/opt/bin])
# ---[ X11 ]------------------------------------------------------------------
AC_PATH_X
AC_CHECK_LIB(X11, XOpenDisplay, [HAVE_LIBX11=TRUE], [HAVE_LIBX11=FALSE])
if test "$HAVE_LIBX11" == TRUE; then
AC_MSG_RESULT([X11 library found.])
DONT_HAVE_X11=''
#DONT_HAVE_X11='-Dcimg_display=0'
else
AC_MSG_RESULT([X11 library not found, please install X11 library if you need the display capabilities of CImg.])
DONT_HAVE_X11='-Dcimg_display=0'
fi
if test x$no_x = xyes ; then
AC_MSG_ERROR([X11 not found but required, configure aborted.])
fi
if test -n "${x_includes}"; then
CPPFLAGS="${CPPFLAGS} -I${x_includes}"
fi
if test -n "${x_libraries}"; then
LIBS="${LIBS} -L${x_libraries} -lX11"
else
LIBS="${LIBS} -lX11"
fi
if test x$L_LIB != x; then
LIBS="${L_LIB} ${LIBS}"
fi
# from mwaved package by jrwishart
# Check if the FFTW Library exists on the system
AC_MSG_NOTICE([Checking if FFTW3 library is available using pkg-config])
## --- FFTW 3 ----------------------------------------------------------------
PKG_CHECK_MODULES(FFTW, fftw3, [HAVE_FFTW=TRUE], [HAVE_FFTW=FALSE])
if test "$HAVE_FFTW" == TRUE; then
HAVE_FFTW='-Dcimg_use_fftw3'
AC_MSG_RESULT([FFTW3 found!])
else
HAVE_FFTW=''
# Return message that package requires FFTW3 library
AC_MSG_RESULT([FFTW library not found, please install fftw3 for better FFT support.])
fi
#check for libtiff
#(from Cairo and modified)
if test "xx$PKGCONF" != "xx"; then
AC_MSG_CHECKING([whether pkg-config knows about libtiff-4])
if "${PKGCONF}" --exists libtiff-4; then
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([for configurable backends])
TIFF_LIBS=`"${PKGCONF}" --libs libtiff-4`
TIFF_CFLAGS=`"${PKGCONF}" --cflags libtiff-4`
TIFF_CFLAGS="${TIFF_CFLAGS} -Dcimg_use_tiff"
AC_MSG_CHECKING([whether --static is needed])
saveLIBS="$LIBS"
LIBS="$saveLIBS ${TIFF_LIBS}"
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY(TIFFOpen)],
[AC_MSG_RESULT([no])],
[TIFF_LIBS=`"${PKGCONF}" --libs --static libtiff-4`
LIBS="$saveLIBS ${TIFF_LIBS}"
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY(TIFFOpen)],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([neither works, abandoning pkg-config])
TIFF_LIBS=''
])
])
LIBS="$saveLIBS"
else
AC_MSG_RESULT([no])
fi
else
#(from rtiff package)
AC_CHECK_LIB([tiff], [TIFFOpen], [have_tiff=yes], [have_tiff=no])
if test "x${have_tiff}" = xyes; then
TIFF_LIBS="-ltiff"
TIFF_CFLAGS="-Dcimg_use_tiff"
else
## version for Mac macOS, static libtiff 4.0.x
unset ac_cv_lib_tiff_TIFFOpen
echo 'Try static libs needed on macOS'
AC_CHECK_LIB([tiff], [TIFFOpen], [have_tiff=yes], [have_tiff=no],
[-llzma -ljpeg -lz])
if test "x${have_tiff}" = xyes; then
TIFF_CFLAGS="-Dcimg_use_tiff"
TIFF_LIBS="-ltiff -llzma -ljpeg -lz"
else
echo Could not find libtiff. Install libtiff for better tiff support
TIFF_CFLAGS=""
TIFF_LIBS=""
fi
fi
fi
# Check for OpenMP (from randomForests package)
dnl AC_OPENMP
dnl RBIN="${R_HOME}/bin/R"
dnl # Since some systems have broken OMP libraries we also check that the
dnl # actual package will work.
dnl ac_pkg_openmp=no
dnl if test -n "${OPENMP_CFLAGS}"; then
dnl AC_MSG_CHECKING([whether OpenMP will work in a package])
dnl AC_LANG_CONFTEST([AC_LANG_PROGRAM([[#include <omp.h>]], [[ return omp_get_num_threads (); ]])])
dnl "$RBIN" CMD SHLIB conftest.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD && "$RBIN" --vanilla -q -e "dyn.load(paste('conftest',.Platform\$dynlib.ext,sep=''))" 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD && ac_pkg_openmp=yes
dnl AC_MSG_RESULT([${ac_pkg_openmp}])
dnl fi
dnl # If ${ac_pkg_openmp} = "yes" then we have OMP, otherwise it will be "no".
dnl if test "${ac_pkg_openmp}" = no; then
dnl OPENMP_CFLAGS=''
dnl HAVE_OPENMP=''
dnl AC_MSG_WARN([OpenMP does NOT appear to be supported on this system.])
dnl else
dnl HAVE_OPENMP='-Dcimg_use_openmp'
dnl fi
dnl AC_SUBST(OPENMP_CFLAGS)
dnl AC_SUBST(HAVE_OPENMP)
# Checks for OpenMP.
#m4_include([m4/ax_openmp.m4])
#AX_OPENMP
#OpenMP detection taken from ARTP2 code, as per CRAN recommendation
#https://github.com/zhangh12/ARTP2/blob/master/configure.ac
AC_LANG(C++)
dnl this the meat of R's m4/openmp.m4
OPENMP_[]_AC_LANG_PREFIX[]FLAGS=
AC_ARG_ENABLE([openmp],
[AS_HELP_STRING([--disable-openmp], [do not use OpenMP])])
if test "$enable_openmp" != no; then
AC_CACHE_CHECK([for $[]_AC_CC[] option to support OpenMP],
[ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp],
[AC_LINK_IFELSE([_AC_LANG_OPENMP],
[ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp='none needed'],
[ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp='unsupported'
for ac_option in -fopenmp -xopenmp -qopenmp \
-openmp -mp -omp -qsmp=omp -homp \
-fopenmp=libomp \
-Popenmp --openmp; do
ac_save_[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $ac_option"
AC_LINK_IFELSE([_AC_LANG_OPENMP],
[ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp=$ac_option])
_AC_LANG_PREFIX[]FLAGS=$ac_save_[]_AC_LANG_PREFIX[]FLAGS
if test "$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp" != unsupported; then
break
fi
done])])
case $ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp in #(
"none needed" | unsupported)
;; #(
*)
OPENMP_[]_AC_LANG_PREFIX[]FLAGS=$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp ;;
esac
fi
AC_SUBST(OPENMP_CXXFLAGS)
# Now substitute these variables in src/Makevars.in to create src/Makevars
AC_SUBST(DONT_HAVE_X11)
AC_SUBST(HAVE_FFTW)
AC_SUBST(FFTW_CFLAGS)
AC_SUBST(FFTW_LIBS)
AC_SUBST(TIFF_CFLAGS)
AC_SUBST(TIFF_LIBS)
## --- Output ----------------------------------------------------------------
AC_SUBST(CPPFLAGS)
AC_SUBST(CXXFLAGS)
AC_SUBST(LIBS)
AC_OUTPUT(src/Makevars)