forked from ropensci/git2r
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
413 lines (343 loc) · 12.5 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
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
# git2r, R bindings to the libgit2 library.
# Copyright (C) 2013-2017 The git2r contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2,
# as published by the Free Software Foundation.
#
# git2r is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
AC_PREREQ([2.69])
AC_INIT([git2r], [see.DESCRIPTION.file], [https://github.com/ropensci/git2r/issues])
AC_CONFIG_SRCDIR([src/git2r.c])
AC_CONFIG_AUX_DIR([tools])
m4_include([tools/libcurl.m4])
AC_CANONICAL_HOST
# Checks for programs.
AC_PROG_CC
## check for brew on OS X
AC_DEFUN([AC_PROG_BREW], [AC_CHECK_PROG(BREW,brew,yes)])
case "${host_os}" in
darwin*)
AC_PROG_BREW
if test "x${BREW}" = xyes; then
BREW_DIR=`brew --prefix`
fi
;;
esac
# Check for pkg-config
PKG_PROG_PKG_CONFIG
# Optional include and library paths
# zlib include and library path
AC_ARG_WITH([zlib-include],
AC_HELP_STRING([--with-zlib-include=INCLUDE_PATH],
[the location of the zlib header files]),
[zlib_include_path=$withval])
AC_ARG_WITH([zlib-lib],
AC_HELP_STRING([--with-zlib-lib=LIB_PATH],
[the location of the zlib library]),
[zlib_lib_path=$withval])
# LibSSH2 include and library path
AC_ARG_WITH([libssh2-include],
AC_HELP_STRING([--with-libssh2-include=INCLUDE_PATH],
[the location of the LibSSH2 header files]),
[libssh2_include_path=$withval])
AC_ARG_WITH([libssh2-lib],
AC_HELP_STRING([--with-libssh2-lib=LIB_PATH],
[the location of the LibSSH2 library]),
[libssh2_lib_path=$withval])
# libssl include and library path
AC_ARG_WITH([libssl-include],
AC_HELP_STRING([--with-libssl-include=INCLUDE_PATH],
[the location of the libssl header files]),
[libssl_include_path=$withval])
AC_ARG_WITH([libssl-lib],
AC_HELP_STRING([--with-libssl-lib=LIB_PATH],
[the location of the libssl library]),
[libssl_lib_path=$withval])
# Find the compiler and compiler flags to use
: ${R_HOME=`R RHOME`}
if test -z "${R_HOME}"; then
echo "could not determine R_HOME"
exit 1
fi
RBIN="${R_HOME}/bin/R"
CC=`"${RBIN}" CMD config CC`
CFLAGS=`"${RBIN}" CMD config CFLAGS`
CPPFLAGS=`"${RBIN}" CMD config CPPFLAGS`
CPICFLAGS=`"${RBIN}" CMD config CPICFLAGS`
# Use R to determine architecture of the machine
AC_MSG_CHECKING([size of void*])
sizeof_voidp=`"${RBIN}" --slave --vanilla -e "cat(.Machine\\$sizeof.pointer)"`
AC_MSG_RESULT([$sizeof_voidp])
if test "x$sizeof_voidp" = "x8"; then
CPPFLAGS="${CPPFLAGS} -DGIT_ARCH_64"
elif test "x$sizeof_voidp" = "x4"; then
CPPFLAGS="${CPPFLAGS} -DGIT_ARCH_32"
else
AC_MSG_FAILURE([Unsupported architecture])
fi
# Check for zlib
have_zlib=no
# Check for optional zlib include path
if test [ -n "$zlib_include_path" ] ; then
CPPFLAGS="-I${zlib_include_path} ${CPPFLAGS}"
fi
# Check for optional zlib lib path
if test [ -n "$zlib_lib_path" ] ; then
LIBS="-L${zlib_lib_path} ${LIBS}"
fi
AC_SEARCH_LIBS([inflate], [z], [have_zlib=yes])
if test "x${have_zlib}" = xno; then
if test [ -n "$PKG_CONFIG" ] ; then
PKG_CHECK_MODULES([zlib], [zlib],
[CPPFLAGS="${zlib_CFLAGS} ${CPPFLAGS}"
LIBS="${zlib_LIBS} ${LIBS}"
have_zlib=yes], [ ])
fi
fi
if test "x${have_zlib}" = xno; then
AC_MSG_FAILURE([
---------------------------------------------
The zlib library that is required to build
git2r was not found.
Please install:
zlib1g-dev (package on e.g. Debian and Ubuntu)
zlib-devel (package on e.g. Fedora, CentOS and RHEL)
and try again.
If the zlib library is installed on your
system but the git2r configuration is
unable to find it, you can specify the
include and lib path to zlib with:
R CMD INSTALL --configure-args='--with-zlib-include=INCLUDE_PATH --with-zlib-lib=LIB_PATH' git2r
---------------------------------------------])
fi
# Check for SSL
have_ssl=no
# Check for optional libssl include path
if test [ -n "$libssl_include_path" ] ; then
CPPFLAGS="-I${libssl_include_path} ${CPPFLAGS}"
fi
# Check for optional libssl lib path
if test [ -n "$libssl_lib_path" ] ; then
LIBS="-L${libssl_lib_path} ${LIBS}"
fi
if test "x${OPENSSL_INCLUDES}" = x; then :; else
CPPFLAGS="${CPPFLAGS} -I${OPENSSL_INCLUDES}"
fi
# On OS X, add path to libssl in brew
case "${host_os}" in
darwin*)
if test "x${BREW}" = xyes; then
CPPFLAGS="${CPPFLAGS} -I${BREW_DIR}/opt/openssl/include"
LIBS="${LIBS} -L${BREW_DIR}/opt/openssl/lib"
fi
;;
esac
AC_SEARCH_LIBS([EVP_EncryptInit],
[crypto],
[AC_SEARCH_LIBS([SSL_library_init], [ssl], [have_ssl=yes])
AC_SEARCH_LIBS([OPENSSL_init_ssl], [ssl], [have_ssl=yes])])
if test "x${have_ssl}" = xno; then
if test [ -n "$PKG_CONFIG" ] ; then
PKG_CHECK_MODULES([openssl], [openssl],
[CPPFLAGS="${openssl_CFLAGS} ${CPPFLAGS}"
LIBS="${openssl_LIBS} ${LIBS}"
have_ssl=yes], [ ])
fi
fi
if test "x${have_ssl}" = xno; then
AC_MSG_FAILURE([
---------------------------------------------
The OpenSSL library that is required to
build git2r was not found.
Please install:
libssl-dev (package on e.g. Debian and Ubuntu)
openssl-devel (package on e.g. Fedora, CentOS and RHEL)
openssl (Homebrew package on OS X)
and try again.
If the OpenSSL library is installed on
your system but the git2r configuration
is unable to find it, you can specify
the include and lib path to OpenSSL with:
R CMD INSTALL --configure-args='--with-libssl-include=INCLUDE_PATH --with-libssl-lib=LIB_PATH' git2r
---------------------------------------------])
fi
# Check for LibSSH2
have_ssh2=no
# Check for optional libssh2 include path
if test [ -n "$libssh2_include_path" ] ; then
CPPFLAGS="-I${libssh2_include_path} ${CPPFLAGS}"
fi
# Check for optional libssh2 lib path
if test [ -n "$libssh2_lib_path" ] ; then
LIBS="-L${libssh2_lib_path} ${LIBS}"
fi
case "${host_os}" in
darwin*)
# Save flags
oCPPFLAGS="${CPPFLAGS}"
oLIBS="${LIBS}"
# On OS X, try to find libssh2 in brew
if test "x${BREW}" = xyes; then
CPPFLAGS="${CPPFLAGS} -I${BREW_DIR}/opt/libssh2/include"
LIBS="${LIBS} -L${BREW_DIR}/opt/libssh2/lib"
AC_SEARCH_LIBS([libssh2_version], [ssh2], [have_ssh2=yes])
fi
if test "x${have_ssh2}" = xno; then
CPPFLAGS="${oCPPFLAGS}"
LIBS="${oLIBS}"
AC_MSG_NOTICE([Download and build libssh2])
mkdir -p libssh2 && \
curl -fsSL https://www.libssh2.org/download/libssh2-1.8.0.tar.gz | \
tar xz --strip 1 -C libssh2
mkdir -p src/libgit2/deps/libssh2
LIBSSH2_INST_DIR="${PWD}/src/libgit2/deps/libssh2"
cp -f tools/missing libssh2
cd libssh2
./configure --with-pic --with-openssl --disable-examples-build \
--disable-shared --enable-static --prefix=$LIBSSH2_INST_DIR \
CC="${CC}" CFLAGS="${CFLAGS} ${CPICFLAGS} -Wno-deprecated-declarations" \
CPPFLAGS="${CPPFLAGS}" && make && make install && have_ssh2=yes
cd ..
rm -rf libssh2
if test "x${have_ssh2}" = xyes; then
LIBSSH2_CFLAGS="-Ilibgit2/deps/libssh2/include"
LIBSSH2_LIBS="-Llibgit2/deps/libssh2/lib -lssh2"
fi
fi
;;
*)
AC_SEARCH_LIBS([libssh2_version], [ssh2], [have_ssh2=yes])
;;
esac
if test "x${have_ssh2}" = xno; then
if test [ -n "$PKG_CONFIG" ] ; then
PKG_CHECK_MODULES([libssh2], [libssh2],
[CPPFLAGS="${libssh2_CFLAGS} ${CPPFLAGS}"
LIBS="${libssh2_LIBS} ${LIBS}"
have_ssh2=yes], [ ])
fi
fi
if test "x${have_ssh2}" = xno; then
AC_MSG_WARN([
---------------------------------------------
Unable to find the LibSSH2 library on this
system. Building a version without support
for SSH transport.
To build with SSH support, please install:
libssh2-1-dev (package on e.g. Debian and Ubuntu)
libssh2-devel (package on e.g. Fedora, CentOS and RHEL)
libssh2 (Homebrew package on OS X)
and try again.
If the LibSSH2 library is installed on
your system but the git2r configuration
is unable to find it, you can specify
the include and lib path to LibSSH2 with:
R CMD INSTALL --configure-args='--with-libssh2-include=INCLUDE_PATH --with-libssh2-lib=LIB_PATH' git2r
---------------------------------------------])
fi
# Check for iconv
have_iconv=no
case "${host_os}" in
darwin*)
AM_ICONV
if test "x${am_cv_func_iconv}" = xyes; then
have_iconv=yes
fi
;;
esac
# Check for libcurl
LIBCURL_CHECK_CONFIG(, , [have_libcurl=yes], [have_libcurl=no])
# Configuration specific for solaris
case "${host_os}" in
solaris*)
AC_SEARCH_LIBS(connect, [socket])
AC_SEARCH_LIBS(gethostbyname, [nsl socket])
# Include and use regex on solaris
CPPFLAGS="-Ilibgit2/deps/regex ${CPPFLAGS}"
GIT2R_SRC_REGEX=libgit2/deps/regex/regex.o
;;
esac
# Add include paths for git2r
CPPFLAGS="-I. -Ilibgit2/src -Ilibgit2/include -Ilibgit2/deps/http-parser ${CPPFLAGS}"
# Add definitions
CPPFLAGS="${CPPFLAGS} -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DGIT_OPENSSL -DLIBGIT2_NO_FEATURES_H -DR_NO_REMAP"
# Specify sha1 implementation
case "${host_os}" in
darwin*)
PKG_CFLAGS="-Wno-deprecated-declarations"
CPPFLAGS="${CPPFLAGS} -DGIT_SHA1_COMMON_CRYPTO"
;;
*)
CPPFLAGS="${CPPFLAGS} -DGIT_SHA1_OPENSSL"
;;
esac
# Add definition for ssh
if test "x${have_ssh2}" = xyes; then
CPPFLAGS="${CPPFLAGS} -DGIT_SSH"
fi
# Add definition for curl
if test "x${have_libcurl}" = xyes; then
CPPFLAGS="${CPPFLAGS} -DGIT_CURL"
fi
# Add definition for iconv
if test "x${have_iconv}" = xyes; then
CPPFLAGS="${CPPFLAGS} -DGIT_USE_ICONV"
fi
# Add definitions specific for solaris
case "${host_os}" in
solaris*)
CPPFLAGS="${CPPFLAGS} -D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
;;
esac
# Checks for structures
AC_CHECK_MEMBER([struct stat.st_mtim],
[CPPFLAGS="${CPPFLAGS} -DGIT_USE_STAT_MTIM"],
[], [AC_INCLUDES_DEFAULT])
AC_CHECK_MEMBER([struct stat.st_mtimespec],
[CPPFLAGS="${CPPFLAGS} -DGIT_USE_STAT_MTIMESPEC"],
[], [AC_INCLUDES_DEFAULT])
AC_CHECK_MEMBER([struct stat.st_mtime_nsec],
[CPPFLAGS="${CPPFLAGS} -DGIT_USE_STAT_MTIME_NSEC"],
[], [AC_INCLUDES_DEFAULT])
if test "x$ac_cv_member_struct_stat_st_mtim" = "xyes"; then
AC_CHECK_MEMBER([struct stat.st_mtim.tv_nsec],
[CPPFLAGS="${CPPFLAGS} -DGIT_USE_NSEC"],
[], [AC_INCLUDES_DEFAULT])
elif test "x$ac_cv_member_struct_stat_st_mtimespec" = "xyes"; then
AC_CHECK_MEMBER([struct stat.st_mtimespec.tv_nsec],
[CPPFLAGS="${CPPFLAGS} -DGIT_USE_NSEC"],
[], [AC_INCLUDES_DEFAULT])
else
CPPFLAGS="${CPPFLAGS} -DGIT_USE_NSEC"
fi
# Checks for library functions.
AC_CHECK_FUNCS([futimens qsort_r qsort_s])
if test $ac_cv_func_futimens = yes; then
CPPFLAGS="${CPPFLAGS} -DHAVE_FUTIMENS"
fi
if test $ac_cv_func_qsort_r = yes; then
CPPFLAGS="${CPPFLAGS} -DHAVE_QSORT_R"
fi
if test $ac_cv_func_qsort_s = yes; then
CPPFLAGS="${CPPFLAGS} -DHAVE_QSORT_S"
fi
AC_SUBST(GIT2R_SRC_REGEX)
AC_SUBST([PKG_CFLAGS], ["${PKG_CFLAGS} ${LIBSSH2_CFLAGS}"])
AC_SUBST([PKG_CPPFLAGS], ["${CPPFLAGS} ${LIBCURL_CPPFLAGS}"])
AC_SUBST([PKG_LIBS], ["${LIBS} ${LIBSSH2_LIBS} ${LIBCURL} ${LIBICONV}"])
AC_CONFIG_FILES([src/Makevars])
echo "
----- Results of the git2r package configure -----
OpenSSL to talk over HTTPS...........: ${have_ssl}
LibSSH2 to enable the SSH transport..: ${have_ssh2}
--------------------------------------------------
"
AC_OUTPUT