2 AC_INIT([liboauth], [-], [robin AT gareus DOT org], [], [http://liboauth.sourceforge.net/])
5 AC_PATH_PROG(SED, sed, "", $PATH:/bin:/usr/bin:/usr/local/bin)
6 if test -z "$SED"; then
7 AC_MSG_WARN([sed was not found])
10 AC_MSG_CHECKING([liboauth version])
11 VERSION=`$SED -ne 's/^#define LIBOAUTH_VERSION "\(.*\)"/\1/p' ${srcdir}/src/oauth.h 2>/dev/null`
12 AC_MSG_RESULT($VERSION)
13 if test -z "$VERSION"; then
14 AC_MSG_ERROR([version number can not be retrieved from src/oauth.h])
17 VERSION_CUR=`$SED -ne 's/^#define LIBOAUTH_CUR *\([0-9]*\)/\1/p' ${srcdir}/src/oauth.h 2>/dev/null`
18 VERSION_REV=`$SED -ne 's/^#define LIBOAUTH_REV *\([0-9]*\)/\1/p' ${srcdir}/src/oauth.h 2>/dev/null`
19 VERSION_AGE=`$SED -ne 's/^#define LIBOAUTH_AGE *\([0-9]*\)/\1/p' ${srcdir}/src/oauth.h 2>/dev/null`
20 VERSION_INFO=${VERSION_CUR}:${VERSION_REV}:${VERSION_AGE}
22 AC_CONFIG_SRCDIR([src/oauth.c])
23 AC_CONFIG_TESTDIR([tests])
24 AC_CANONICAL_TARGET([])
25 AC_COPYRIGHT([Copyright (C) Robin Gareus 2007-2012])
26 AM_INIT_AUTOMAKE(liboauth,$VERSION)
28 AM_CONFIG_HEADER(src/config.h)
31 AC_SUBST(VERSION_INFO)
32 ISODATE=`date +%Y-%m-%d`
45 AC_CONFIG_MACRO_DIR([m4])
48 AC_CHECK_HEADERS(unistd.h time.h string.h alloca.h stdio.h stdarg.h math.h)
56 AH_TEMPLATE([HAVE_CURL], [Define as 1 if you have libcurl])
57 AH_TEMPLATE([USE_BUILTIN_HASH], [Define to use neither NSS nor OpenSSL])
58 AH_TEMPLATE([USE_NSS], [Define to use NSS instead of OpenSSL])
59 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.])
60 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.])
63 TEST_UNICODE=-DTEST_UNICODE
65 dnl *** Target specific settings ***
76 AC_SUBST(TEST_UNICODE)
79 dnl *** misc complier/linker flags ***
80 LIBOAUTH_CFLAGS="-Wall"
81 LIBOAUTH_LDFLAGS="${LIBOAUTH_CFLAGS} -export-symbols-regex '^oauth_.*'"
82 #LIBOAUTH_CFLAGS="${LIBOAUTH_CFLAGS} -g -posix -std=c99 -pedantic"
84 AC_MSG_CHECKING([if -Wl,--as-needed works])
86 LDFLAGS="$LDFLAGS -Wl,--as-needed"
90 LIBOAUTH_LDFLAGS="$LIBOAUTH_LDFLAGS -Wl,--as-needed"
92 [AC_MSG_RESULT([no])])
95 AC_SUBST(LIBOAUTH_CFLAGS)
96 AC_SUBST(LIBOAUTH_LDFLAGS)
99 dnl *** PKGconfig oauth.pc.in ***
103 dnl *** configuration options ***
104 AC_ARG_ENABLE(curl, AC_HELP_STRING([--disable-curl],[do not use (command-line) curl]))
105 AC_ARG_ENABLE(libcurl, AC_HELP_STRING([--disable-libcurl],[do not use libcurl]))
106 AC_ARG_ENABLE(builtinhash, AC_HELP_STRING([--enable-builtinhash],[do use neither NSS nor OpenSSL: only HMAC/SHA1 signatures - no RSA/PK11]))
107 AC_ARG_ENABLE(nss, AC_HELP_STRING([--enable-nss],[use NSS instead of OpenSSL]))
108 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]))
111 dnl ** check for commandline executable curl
112 if test "${enable_curl}" != "no"; then
113 AC_PATH_PROG(CURLCMD, curl, no, $PATH:/bin:/usr/bin:/usr/local/bin)
114 if test "$CURLCMD" != "no"; then
115 AC_DEFINE(HAVE_SHELL_CURL, 1)
116 report_curl="shell command"
120 dnl ** check for libcurl
121 AS_IF([test "${enable_libcurl}" != "no"], [
122 PKG_CHECK_MODULES(CURL, libcurl,
123 [ AC_DEFINE(HAVE_CURL, 1) HAVE_CURL=1 PC_REQ="$PC_REQ libcurl" PC_LIB="$PC_LIB ${CURL_LIBS}" report_curl="libcurl" ] ,
125 AC_CHECK_HEADERS(curl/curl.h)
126 AC_CHECK_LIB([curl], [curl_global_init],
127 [AC_DEFINE(HAVE_CURL, 1) HAVE_CURL=1 PC_REQ="$PC_REQ libcurl" PC_LIB="$PC_LIB -lcurl" report_curl="libcurl" ]
133 report_curltimeout="-"
134 if test -n "${with_curltimeout}"; then
135 if test "${with_curltimeout}" == "yes"; then
136 AC_DEFINE(OAUTH_CURL_TIMEOUT, 60)
137 report_curltimeout="60"
139 if test "${with_curltimeout}" -gt 0; then
140 AC_DEFINE_UNQUOTED(OAUTH_CURL_TIMEOUT, [${with_curltimeout}])
141 report_curltimeout=${with_curltimeout}
146 AC_SUBST(CURL_CFLAGS)
149 dnl ** crypto/hash lib (OpenSSL or NSS)
150 AS_IF([test "${enable_builtinhash}" == "yes"], [
151 AC_DEFINE(USE_BUILTIN_HASH, 1) USE_BUILTIN_HASH=1
154 report_hash="built-in HMAC/SHA1 - no RSA"
156 using built-in HMAC/SHA1 hash algorithm without RSA/PK11 support.
157 This option is not recommended for general use and should only
158 be used on small devices (AVR, mircocontrollers) where neither
159 NSS nor OpenSSL is available.
162 AS_IF([test "${enable_nss}" == "yes"], [
163 PKG_CHECK_MODULES(NSS, nss, [ AC_DEFINE(USE_NSS, 1) USE_NSS=1 PC_REQ="$PC_REQ nss" ])
164 HASH_LIBS=${NSS_LIBS}
165 HASH_CFLAGS=${NSS_CFLAGS}
168 AC_CHECK_HEADERS(openssl/hmac.h)
169 if test -z "${HASH_LIBS}"; then
172 if test -z "${HASH_CFLAGS}"; then
175 report_hash="OpenSSL"
176 PC_LIB="$PC_LIB ${HASH_LIBS}"
177 PC_REQ="$PC_REQ libcrypto"
180 NOTE: OpenSSL is not compatible with GPL applications.
181 Even if only linked with GPL code you are not allowed to distibute your app.
182 However liboauth provides an exeption (to the GPL) to circumvent this issue
183 (see README, src/hash.c). Nevertheless, double-check your licensing.
185 liboauth itself is licensed under MIT license and comatible with the GPL.
187 Either way, you are probably better off using NSS (configure --enable-nss);
188 future versions of liboauth will default to the Mozilla NSS.
190 see http://people.gnome.org/~markmc/openssl-and-the-gpl.html
196 AC_SUBST(HASH_CFLAGS)
199 AC_ARG_VAR(DOXYGEN, Doxygen)
200 AC_PATH_PROG(DOXYGEN, doxygen, no)
202 if test "$DOXYGEN" != "no"; then
203 DOXMAKE='run "make dox" to generate API html reference: doc/html/index.html'
207 dnl (needed for Doxyfile.in)
208 AC_ARG_VAR(DOT, The 'dot' program from graphviz)
209 AC_PATH_PROG(DOT, dot, no)
210 if test "$DOT" != "no"; then
212 DOTPATH=$( dirname "$DOT" )
221 dnl (needed for Doxyfile.in)
222 AC_ARG_VAR(PERL, Perl)
223 AC_PATH_PROG(PERL, perl, no)
224 if test "$PERL" == "no"; then
225 AC_MSG_WARN([dude, where's your perl? doxygen will not like this!)])
228 # PKGconfig oauth.pc.in
234 subdirs="src doc tests"
237 AC_OUTPUT(Makefile src/Makefile doc/Makefile tests/Makefile liboauth.lsm oauth.pc Doxyfile doc/mainpage.dox)
242 -----------------------
245 interface revision: $VERSION_INFO
246 hash/signature: $report_hash
247 http integration: $report_curl
248 libcurl-timeout: $report_curltimeout
249 generate documentation: $DOXYGEN
250 installation prefix: $prefix
251 CFLAGS: $LIBOAUTH_CFLAGS $CFLAGS
252 LDFLAGS: $LIBOAUTH_LDFLAGS $LDFLAGS
254 type "make" followed my "make install" as root.