-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
146 lines (126 loc) · 4.36 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
# -*- mode: autoconf; autoconf-indentation: 4; -*-
#
# Modified from github.com/eddelbuettel/rprotobuf/configure.ac
#
# Copyright (C) 2009 - 2017 Dirk Eddelbuettel <[email protected]>
# Portions Copyright (C) 2010 Romain Francois
# Portions Copyright (C) 2013 Murray Stokely
# Portions Copyright (C) 2016 Craig Radcliffe
# require at least autoconf 2.69
AC_PREREQ(2.69)
# Process this file with autoconf to produce a configure script.
AC_INIT([transitr],[0.3.0.9000])
# We are using C++
AC_LANG(C++)
AC_REQUIRE_CPP
AC_PROG_CC
AC_PROG_CXX
AC_OPENMP
AC_DEFUN([AC_PROG_PKGCONFIG], [AC_CHECK_PROG(PKGCONFIG,pkg-config,yes)])
AC_PROG_PKGCONFIG
# PKG_CHECK_MODULES ([EIGEN], [eigen3])
AC_CHECK_HEADER([eigen3/Eigen/Dense],,AC_MSG_ERROR([No eigen3 library]))
## use pkg-config for ProtoBuf settings
##
if test x"${PKGCONFIG}" == x"yes"; then
if pkg-config --exists protobuf; then
protobuf_cxxflags=`pkg-config --cflags protobuf`
protobuf_libs=`pkg-config --libs protobuf`
else
protobuf_cxxflags=""
protobuf_libs="-lprotobuf"
fi
if pkg-config --exists libcurl; then
curl_cxxflags=`pkg-config --cflags libcurl`
curl_libs=`pkg-config --libs libcurl`
else
curl_cxxflags=""
curl_libs="-libcurl"
fi
if pkg-config --exists gsl; then
gsl_cxxflags=`pkg-config --cflags gsl`
gsl_libs=`pkg-config --libs gsl`
else
gsl_cxxflags=""
gsl_libs="-lm -lgsl -lgslcblas"
fi
else
# Add a reasonable default of -lprotobuf and -lcurl if we don't have pkg-config
protobuf_cxxflags=""
protobuf_libs="-lprotobuf"
curl_cxxflags=""
curl_libs="-libcurl"
gsl_cxxflags=""
gsl_libs="-lm -lgsl -lgslcblas"
fi
## And make sure these flags are used for the tests below.
CPPFLAGS="${protobuf_cxxflags} ${CPPFLAGS}"
CXXFLAGS="${protobuf_cxxflags} ${CXXFLAGS}"
## look for protoc, the ProtoBuf compiler
AC_DEFUN([AC_PROG_PROTOC], [AC_CHECK_PROG(PROTOC,protoc,yes)])
AC_PROG_PROTOC
if test x"${PROTOC}" == x"no" ; then
echo "
Your installation does not appear to have protoc installed.
Please make sure that you have a working and complete ProtoBuf installation.
"
exit 1
fi
## check for header and ability to link
## first for headers Debian has in libprotobuf-dev
protobuf_common_header=google/protobuf/stubs/common.h
protobuf_common_header_cache_var=AS_TR_SH([ac_cv_header_$protobuf_common_header])
AC_CHECK_HEADER([$protobuf_common_header],,
[
# If it didn't work, try adding /usr/local directly then trying again
AC_MSG_WARN([Protobuf headers not found with default CXXFLAGS and CPPFLAGS, manually trying /usr/local/include])
CPPFLAGS="${protobuf_cxxflags} ${CPPFLAGS} -I/usr/local/include"
CXXFLAGS="${protobuf_cxxflags} ${CXXFLAGS} -I/usr/local/include -L/usr/local/lib"
# unset the cache variable for this particular header
# check, so we can check again with different defaults
# specified.
AC_MSG_WARN([Unsetting $protobuf_common_header_cache_var])
AS_UNSET([$protobuf_common_header_cache_var])
AC_CHECK_HEADER([$protobuf_common_header],,
[AC_MSG_ERROR([ERROR: ProtoBuf headers required; use '-Iincludedir' in CXXFLAGS for unusual locations.])])
])
## second for headers Debian has in libprotoc-dev
AC_CHECK_HEADER(google/protobuf/compiler/code_generator.h,,
[AC_MSG_ERROR([ERROR: ProtoBuf compiler headers required; use '-Iincludedir' in CXXFLAGS for unusual locations.])])
## third check the lib itself
LIBS="$LIBS $protobuf_libs"
## also check for minimum version
AC_MSG_CHECKING([if ProtoBuf version >= 2.2.0])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <google/protobuf/stubs/common.h>
int main() {
if (GOOGLE_PROTOBUF_VERSION >= 2001000) {
exit (0);
} else {
exit(1);
}
}
]])],
[pb_version_ok=yes],
[pb_version_ok=no],
[pb_version_ok=yes])
if test x"${pb_version_ok}" == x"no"; then
AC_MSG_ERROR([Need ProtoBuf version >= 2.2.0])
else
AC_MSG_RESULT([yes])
fi
AC_DEFUN([AC_PROG_R], [AC_CHECK_PROG(R,R,yes)])
AC_PROG_R
# ## now use all these
AC_SUBST([PKG_CPPFLAGS],["${PKG_CPPFLAGS} ${CXXFLAGS} ${protobuf_cxxflags} ${curl_cxxflags} ${OPENMP_CXXFLAGS}"])
AC_SUBST([PKG_LIBS],["${PKG_LIBS} ${protobuf_libs} ${curl_libs} ${gsl_libs}"])
AC_CONFIG_FILES([src/Makevars])
AC_OUTPUT
echo "
transitr $PACKAGE_VERSION
=========================
cflags: ${PKG_CPPFLAGS}
libs: ${PKG_LIBS}
cppflags: ${CPPFLAGS}
cxxflags: ${CXXFLAGS}
"