uploaded liboauth for tizen_3.0
[platform/upstream/liboauth.git] / configure.ac
1 AC_PREREQ(2.57)
2 AC_INIT([liboauth], [-], [robin AT gareus DOT org], [], [http://liboauth.sourceforge.net/])
3 #AM_MAINTAINER_MODE
4
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])
8 fi
9
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])
15 fi
16
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}
21
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)
27
28 AM_CONFIG_HEADER(src/config.h)
29
30 AC_SUBST(VERSION)
31 AC_SUBST(VERSION_INFO)
32 ISODATE=`date +%Y-%m-%d`
33 AC_SUBST(ISODATE)
34
35 AC_CANONICAL_HOST
36
37 AC_PROG_INSTALL
38 AC_PROG_CC
39 AC_PROG_MAKE_SET
40 AC_PROG_LN_S
41 AC_PROG_LIBTOOL
42 AM_PROG_LIBTOOL
43 AM_PROG_CC_C_O
44 AC_LIBTOOL_WIN32_DLL
45 AC_CONFIG_MACRO_DIR([m4])
46
47 AC_HEADER_STDC
48 AC_CHECK_HEADERS(unistd.h time.h string.h alloca.h stdio.h stdarg.h math.h)
49
50 AC_HEADER_MAJOR
51 AC_FUNC_ALLOCA
52 AC_STRUCT_TM
53 AC_STRUCT_ST_BLOCKS
54 AC_FUNC_CLOSEDIR_VOID
55
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.])
61
62 EXESUF=
63 TEST_UNICODE=-DTEST_UNICODE
64
65 dnl *** Target specific settings ***
66 case $target_os in
67   *darwin*)
68   ;;
69   *mingw32*|*win*)
70     EXESUF=.exe
71     TEST_UNICODE=
72   ;;
73   *)    
74   ;;
75 esac
76 AC_SUBST(TEST_UNICODE)
77 AC_SUBST(EXESUF)
78
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"
83
84 AC_MSG_CHECKING([if -Wl,--as-needed works])
85 LDFLAGS_save=$LDFLAGS
86 LDFLAGS="$LDFLAGS -Wl,--as-needed"
87 AC_TRY_LINK([], [],
88             [
89              AC_MSG_RESULT([yes])
90              LIBOAUTH_LDFLAGS="$LIBOAUTH_LDFLAGS -Wl,--as-needed"
91             ], 
92             [AC_MSG_RESULT([no])])
93 LDFLAGS=$LDFLAGS_save
94
95 AC_SUBST(LIBOAUTH_CFLAGS)
96 AC_SUBST(LIBOAUTH_LDFLAGS)
97
98
99 dnl *** PKGconfig oauth.pc.in ***
100 PC_REQ=""
101 PC_LIB=""
102
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]))
109
110 report_curl="no"
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"
117   fi
118 fi
119
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" ] , 
124     [
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" ]
128       )
129     ]
130   )
131 ])
132
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"
138   else 
139     if test "${with_curltimeout}" -gt 0; then
140     AC_DEFINE_UNQUOTED(OAUTH_CURL_TIMEOUT, [${with_curltimeout}])
141     report_curltimeout=${with_curltimeout}
142     fi
143   fi
144 fi
145
146 AC_SUBST(CURL_CFLAGS)
147 AC_SUBST(CURL_LIBS)
148
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
152     HASH_LIBS=""
153     HASH_CFLAGS=""
154     report_hash="built-in HMAC/SHA1 - no RSA"
155     AC_MSG_NOTICE([
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.
160     ])
161 ], [
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}
166     report_hash="NSS"
167   ], [
168     AC_CHECK_HEADERS(openssl/hmac.h)
169     if test -z "${HASH_LIBS}"; then
170     HASH_LIBS="-lcrypto"
171     fi
172     if test -z "${HASH_CFLAGS}"; then
173     HASH_CFLAGS=""
174     fi
175     report_hash="OpenSSL"
176     PC_LIB="$PC_LIB ${HASH_LIBS}"
177     PC_REQ="$PC_REQ libcrypto"
178     AC_MSG_NOTICE([
179
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.
184    
185     liboauth itself is licensed under MIT license and comatible with the GPL. 
186
187     Either way, you are probably better off using NSS (configure --enable-nss);
188     future versions of liboauth will default to the Mozilla NSS.
189      
190     see http://people.gnome.org/~markmc/openssl-and-the-gpl.html
191     ])
192   ])
193 ])
194
195 AC_SUBST(HASH_LIBS)
196 AC_SUBST(HASH_CFLAGS)
197
198 dnl *** doxygen ***
199 AC_ARG_VAR(DOXYGEN, Doxygen)
200 AC_PATH_PROG(DOXYGEN, doxygen, no)
201
202 if test "$DOXYGEN" != "no"; then
203   DOXMAKE='run "make dox" to generate API html reference: doc/html/index.html'
204 fi
205
206 dnl *** graphviz ***
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
211   HAVEDOT=YES
212   DOTPATH=$( dirname "$DOT" )
213 else
214   HAVEDOT=NO
215 fi
216 AC_SUBST(HAVEDOT)
217 AC_SUBST(DOTPATH)
218
219
220 dnl *** perl ***
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!)])
226 fi
227
228 # PKGconfig oauth.pc.in
229 AC_SUBST(PC_REQ)
230 AC_SUBST(PC_LIB)
231
232
233 dnl *** output ***
234 subdirs="src doc tests"
235 AC_SUBST(subdirs)
236
237 AC_OUTPUT(Makefile src/Makefile doc/Makefile tests/Makefile liboauth.lsm oauth.pc Doxyfile doc/mainpage.dox)
238
239 AC_MSG_NOTICE([
240
241  liboauth configured:
242  -----------------------
243
244   version:                $VERSION
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
253
254  type "make" followed my "make install" as root.
255  $DOXMAKE
256 ])