-
Notifications
You must be signed in to change notification settings - Fork 21
/
configure.ac
265 lines (222 loc) · 7.99 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
AC_PREREQ(2.57)
AC_INIT([liboauth], m4_esyscmd_s([sed -ne 's/^#define LIBOAUTH_VERSION "\(.*\)"/\1/p' src/oauth.h]), [robin AT gareus DOT org], [], [http://liboauth.sourceforge.net/])
#AM_MAINTAINER_MODE
AC_PATH_PROG(SED, sed, "", $PATH:/bin:/usr/bin:/usr/local/bin)
if test -z "$SED"; then
AC_MSG_WARN([sed was not found])
fi
AC_MSG_CHECKING([liboauth version])
VERSION=`$SED -ne 's/^#define LIBOAUTH_VERSION "\(.*\)"/\1/p' ${srcdir}/src/oauth.h 2>/dev/null`
AC_MSG_RESULT($VERSION)
if test -z "$VERSION"; then
AC_MSG_ERROR([version number can not be retrieved from src/oauth.h])
fi
VERSION_CUR=`$SED -ne 's/^#define LIBOAUTH_CUR *\([0-9]*\)/\1/p' ${srcdir}/src/oauth.h 2>/dev/null`
VERSION_REV=`$SED -ne 's/^#define LIBOAUTH_REV *\([0-9]*\)/\1/p' ${srcdir}/src/oauth.h 2>/dev/null`
VERSION_AGE=`$SED -ne 's/^#define LIBOAUTH_AGE *\([0-9]*\)/\1/p' ${srcdir}/src/oauth.h 2>/dev/null`
VERSION_INFO=${VERSION_CUR}:${VERSION_REV}:${VERSION_AGE}
AC_CONFIG_SRCDIR([src/oauth.c])
AC_CONFIG_TESTDIR([tests])
AC_CANONICAL_TARGET([])
AC_COPYRIGHT([Copyright (C) Robin Gareus 2007-2012])
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(src/config.h)
AC_SUBST(VERSION)
AC_SUBST(VERSION_INFO)
ISODATE=`date +%Y-%m-%d`
AC_SUBST(ISODATE)
AC_CANONICAL_HOST
AC_PROG_INSTALL
AC_PROG_CC
AC_PROG_MAKE_SET
AC_PROG_LN_S
AC_PROG_LIBTOOL
AM_PROG_LIBTOOL
AM_PROG_CC_C_O
AC_LIBTOOL_WIN32_DLL
AC_CONFIG_MACRO_DIR([m4])
AC_HEADER_STDC
AC_CHECK_HEADERS(unistd.h time.h string.h alloca.h stdio.h stdarg.h math.h)
AC_HEADER_MAJOR
AC_FUNC_ALLOCA
AC_STRUCT_TM
AC_STRUCT_ST_BLOCKS
AC_FUNC_CLOSEDIR_VOID
AH_TEMPLATE([HAVE_STRTOK_R], [Define as 1 if the c library provides strtok_r])
AH_TEMPLATE([HAVE_CURL], [Define as 1 if you have libcurl])
AH_TEMPLATE([USE_BUILTIN_HASH], [Define to use neither NSS nor OpenSSL])
AH_TEMPLATE([USE_NSS], [Define to use NSS instead of OpenSSL])
AH_TEMPLATE([HAVE_SHELL_CURL], [Define if you can invoke curl via a shell command. This is only used if HAVE_CURL is not defined.])
AH_TEMPLATE([OAUTH_CURL_TIMEOUT], [Define the number of seconds for the HTTP request to timeout; if not defined no timeout (or libcurl default) is used.])
EXESUF=
TEST_UNICODE=-DTEST_UNICODE
dnl *** Target specific settings ***
case $target_os in
*darwin*)
;;
*mingw32*|*win*)
EXESUF=.exe
TEST_UNICODE=
;;
*)
;;
esac
AC_SUBST(TEST_UNICODE)
AC_SUBST(EXESUF)
dnl *** misc complier/linker flags ***
LIBOAUTH_CFLAGS="-Wall"
LIBOAUTH_LDFLAGS="${LIBOAUTH_CFLAGS} -export-symbols-regex '^oauth_.*'"
#LIBOAUTH_CFLAGS="${LIBOAUTH_CFLAGS} -g -posix -std=c99 -pedantic"
AC_MSG_CHECKING([if -Wl,--as-needed works])
LDFLAGS_save=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,--as-needed"
AC_TRY_LINK([], [],
[
AC_MSG_RESULT([yes])
LIBOAUTH_LDFLAGS="$LIBOAUTH_LDFLAGS -Wl,--as-needed"
],
[AC_MSG_RESULT([no])])
LDFLAGS=$LDFLAGS_save
AC_SUBST(LIBOAUTH_CFLAGS)
AC_SUBST(LIBOAUTH_LDFLAGS)
dnl *** PKGconfig oauth.pc.in ***
PC_LIB=""
dnl *** configuration options ***
AC_ARG_ENABLE(curl, AC_HELP_STRING([--disable-curl],[do not use (command-line) curl]))
AC_ARG_ENABLE(libcurl, AC_HELP_STRING([--disable-libcurl],[do not use libcurl]))
AC_ARG_ENABLE(builtinhash, AC_HELP_STRING([--enable-builtinhash],[do use neither NSS nor OpenSSL: only HMAC/SHA1 signatures - no RSA/PK11]))
AC_ARG_ENABLE(nss, AC_HELP_STRING([--enable-nss],[use NSS instead of OpenSSL]))
AC_ARG_WITH([curltimeout], AC_HELP_STRING([--with-curltimeout@<:@=<int>@:>@],[use CURLOPT_TIMEOUT with libcurl HTTP requests. Timeout is given in seconds (default=60). Note: using this option also sets CURLOPT_NOSIGNAL. see http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTTIMEOUT]))
AC_CHECK_FUNC(strtok_r, [AC_DEFINE(HAVE_STRTOK_R, 1)], [])
report_curl="no"
dnl ** check for commandline executable curl
if test "${enable_curl}" != "no"; then
AC_PATH_PROG(CURLCMD, curl, no, $PATH:/bin:/usr/bin:/usr/local/bin)
if test "$CURLCMD" != "no"; then
AC_DEFINE(HAVE_SHELL_CURL, 1)
report_curl="shell command"
fi
fi
dnl ** check for libcurl
AS_IF([test "${enable_libcurl}" != "no"], [
PKG_CHECK_MODULES(CURL, libcurl,
[ AC_DEFINE(HAVE_CURL, 1) HAVE_CURL=1 PC_LIB="$PC_LIB`$PKG_CONFIG --static --libs libcurl` " report_curl="libcurl" ] ,
[
AC_CHECK_HEADERS(curl/curl.h)
AC_CHECK_LIB([curl], [curl_global_init],
[AC_DEFINE(HAVE_CURL, 1) HAVE_CURL=1 PC_LIB="$PC_LIB-lcurl " report_curl="libcurl" ]
)
]
)
])
report_curltimeout="-"
if test -n "${with_curltimeout}"; then
if test "${with_curltimeout}" = "yes"; then
AC_DEFINE(OAUTH_CURL_TIMEOUT, 60)
report_curltimeout="60"
else
if test "${with_curltimeout}" -gt 0; then
AC_DEFINE_UNQUOTED(OAUTH_CURL_TIMEOUT, [${with_curltimeout}])
report_curltimeout=${with_curltimeout}
fi
fi
fi
AC_SUBST(CURL_CFLAGS)
AC_SUBST(CURL_LIBS)
dnl ** crypto/hash lib (OpenSSL or NSS)
AS_IF([test "${enable_builtinhash}" = "yes"], [
AC_DEFINE(USE_BUILTIN_HASH, 1) USE_BUILTIN_HASH=1
HASH_LIBS=""
HASH_CFLAGS=""
report_hash="built-in HMAC/SHA1 - no RSA"
AC_MSG_NOTICE([
using built-in HMAC/SHA1 hash algorithm without RSA/PK11 support.
This option is not recommended for general use and should only
be used on small devices (AVR, mircocontrollers) where neither
NSS nor OpenSSL is available.
])
], [
AS_IF([test "${enable_nss}" = "yes"], [
PKG_CHECK_MODULES(NSS, nss,
[ AC_DEFINE(USE_NSS, 1) USE_NSS=1 PC_LIB="$PC_LIB`$PKG_CONFIG --static --libs nss` "
HASH_LIBS=${NSS_LIBS}
HASH_CFLAGS=${NSS_CFLAGS}
report_hash="NSS" ])
], [
PKG_CHECK_MODULES(OPENSSL, libcrypto,
[ PC_LIB="$PC_LIB`$PKG_CONFIG --static --libs libcrypto` "
HASH_LIBS=${OPENSSL_LIBS}
HASH_CFLAGS=${OPENSSL_CFLAGS}
report_hash="OpenSSL" ] ,
[
AC_CHECK_HEADERS(openssl/hmac.h)
if test -z "${HASH_LIBS}"; then
HASH_LIBS="-lcrypto"
fi
if test -z "${HASH_CFLAGS}"; then
HASH_CFLAGS=""
fi
report_hash="OpenSSL"
PC_LIB="$PC_LIB${HASH_LIBS} "
AC_MSG_NOTICE([
NOTE: OpenSSL is not compatible with GPL applications.
Even if only linked with GPL code you are not allowed to distibute your app.
However liboauth provides an exeption (to the GPL) to circumvent this issue
(see README, src/hash.c). Nevertheless, double-check your licensing.
liboauth itself is licensed under MIT license and comatible with the GPL.
Either way, you are probably better off using NSS (configure --enable-nss);
future versions of liboauth will default to the Mozilla NSS.
see http://people.gnome.org/~markmc/openssl-and-the-gpl.html
])
]
)
])
])
AC_SUBST(HASH_LIBS)
AC_SUBST(HASH_CFLAGS)
dnl *** doxygen ***
AC_ARG_VAR(DOXYGEN, Doxygen)
AC_PATH_PROG(DOXYGEN, doxygen, no)
if test "$DOXYGEN" != "no"; then
DOXMAKE='run "make dox" to generate API html reference: doc/html/index.html'
fi
dnl *** graphviz ***
dnl (needed for Doxyfile.in)
AC_ARG_VAR(DOT, The 'dot' program from graphviz)
AC_PATH_PROG(DOT, dot, no)
if test "$DOT" != "no"; then
HAVEDOT=YES
DOTPATH=$( dirname "$DOT" )
else
HAVEDOT=NO
fi
AC_SUBST(HAVEDOT)
AC_SUBST(DOTPATH)
dnl *** perl ***
dnl (needed for Doxyfile.in)
AC_ARG_VAR(PERL, Perl)
AC_PATH_PROG(PERL, perl, no)
if test "$PERL" = "no"; then
AC_MSG_WARN([dude, where's your perl? doxygen will not like this!)])
fi
# PKGconfig oauth.pc.in
AC_SUBST(PC_LIB)
dnl *** output ***
subdirs="src doc tests"
AC_SUBST(subdirs)
AC_OUTPUT(Makefile src/Makefile doc/Makefile tests/Makefile liboauth.lsm oauth.pc Doxyfile doc/mainpage.dox)
AC_MSG_NOTICE([
liboauth configured:
-----------------------
version: $VERSION
interface revision: $VERSION_INFO
hash/signature: $report_hash
http integration: $report_curl
libcurl-timeout: $report_curltimeout
generate documentation: $DOXYGEN
installation prefix: $prefix
CFLAGS: $LIBOAUTH_CFLAGS $CFLAGS
LDFLAGS: $LIBOAUTH_LDFLAGS $LDFLAGS
type "make" followed my "make install" as root.
$DOXMAKE
])