* fixed all headers to use extern "C" so C/C++ linking will work properly
[libundertow.git] / configure.ac
blob587bd3771fe6262da3b50371b56643b324973c5e
1 AC_INIT([libundertow], [0.0.2],
2         [http://www.syntaxjockey.com/projects/libundertow],
3         [libundertow])
4 AM_INIT_AUTOMAKE(no-define)
5 AC_PROG_LIBTOOL
6 AM_CONFIG_HEADER(config.h)
8 # set library version.  for more information see:
9 # http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91
10 LT_CURRENT=0
11 LT_REVISION=0
12 LT_AGE=0
13 AC_SUBST(LT_CURRENT)
14 AC_SUBST(LT_REVISION)
15 AC_SUBST(LT_AGE)
17 # Checks for programs.
18 AC_PROG_CXX
19 AC_PROG_CC
20 AC_PROG_CPP
21 AC_PROG_INSTALL
22 AC_PROG_LN_S
23 AC_PROG_MAKE_SET
24 PKG_PROG_PKG_CONFIG
26 # parse configure switches
27 AC_ARG_ENABLE(bittorrent,
28               AS_HELP_STRING([--enable-bittorrent],
29                              [Enable support for bittorrent downloads (autodetect)]),
30               enable_bittorrent=$enableval)
31 AC_ARG_ENABLE(internal-sqlite,
32               AS_HELP_STRING([--enable-internal-sqlite],
33                              [Use internal copy of sqlite3 (autodetect)]),
34               enable_sqlite=$enableval)
36 # Checks for header files.
37 AC_HEADER_STDC
38 AC_CHECK_HEADERS([stdlib.h string.h sys/time.h unistd.h])
40 # Checks for typedefs, structures, and compiler characteristics.
41 AC_C_CONST
42 AC_TYPE_SIZE_T
43 AC_HEADER_TIME
45 # Checks for library functions.
46 AC_FUNC_MALLOC
47 AC_FUNC_REALLOC
48 AC_CHECK_FUNCS([gettimeofday pthread_create])
50 # Checks for libraries.
51 PKG_CHECK_MODULES(libcurl,[libcurl],,
52                   [AC_MSG_FAILURE([$libcurl_PKG_ERRORS])])
53 PKG_CHECK_MODULES(libxml2,[libxml-2.0],,
54                   [AC_MSG_FAILURE([$libxml2_PKG_ERRORS])])
56 # Determine whether to build support for bittorrent downloads
57 if test x$enable_bittorrent = xyes; then
58     PKG_CHECK_MODULES(libtorrent,[libtorrent],,
59                       [AC_MSG_FAILURE([$libtorrent_PKG_ERRORS])])
60     AC_DEFINE(ENABLE_BITTORRENT, "1", [Define to 1 to enable bittorrent downloads])
63 # Determine whether to use the system sqlite library, or our internal copy
64 if test x$enable_sqlite = xyes; then
65     sqlite_LIBS="../external/sqlite/libsqlite3.la"
66     sqlite_CFLAGS="-I../external/sqlite"
67     INTERNAL_SQLITE="sqlite"
68     AC_SUBST(sqlite_LIBS)
69     AC_SUBST(sqlite_CFLAGS)
70     AC_SUBST(INTERNAL_SQLITE)
71     AC_MSG_NOTICE([using internal copy of libsqlite3])
72 elif test x$enable_sqlite = xno; then
73     PKG_CHECK_MODULES(sqlite,[sqlite3],,[AC_MSG_FAILURE([$sqlite_PKG_ERRORS])])
74 else
75     PKG_CHECK_MODULES(sqlite,[sqlite3],
76         [
77             AC_MSG_CHECKING([whether libsqlite3 is threadsafe])
78             AC_LANG_PUSH(C)
79             AC_LINK_IFELSE(
80                 [
81                     AC_LANG_PROGRAM(
82                         [ #include <sqlite3.h> ],
83                         [ int main (void) { return sqlite3_threadsafe(); } ]
84                     )
85                 ],
86                 [
87                     AC_RUN_IFELSE(
88                         [
89                             AC_LANG_PROGRAM(
90                                 [#include <sqlite3.h>],
91                                 [int main (void) { return sqlite3_threadsafe(); } ]
92                             )
93                         ],
94                         [
95                             AC_MSG_RESULT([yes])
96                         ],
97                         [
98                             AC_MSG_RESULT([no, using internal copy of libsqlite3])
99                             sqlite_LIBS="../external/sqlite/libsqlite3.la"
100                             sqlite_CFLAGS="-I../external/sqlite"
101                             INTERNAL_SQLITE="sqlite"
102                         ]
103                     )
104                 ],
105                 [
106                     AC_MSG_RESULT([no, using internal copy of libsqlite3])
107                     sqlite_LIBS="../external/sqlite/libsqlite3.la"
108                     sqlite_CFLAGS="-I../external/sqlite"
109                     INTERNAL_SQLITE="sqlite"
110                     AC_SUBST(INTERNAL_SQLITE)
111                 ]
112             )
113             AC_LANG_POP()
114         ],
115         [
116             AC_MSG_NOTICE([building libundertow with internal copy of libsqlite3])
117             sqlite_LIBS="../external/sqlite/libsqlite3.la"
118             sqlite_CFLAGS="-I../external/sqlite"
119             INTERNAL_SQLITE="sqlite"
120             AC_SUBST(sqlite_LIBS)
121             AC_SUBST(sqlite_CFLAGS)
122             AC_SUBST(INTERNAL_SQLITE)
123         ]
124     )
127 # output
128 AC_CONFIG_FILES([Makefile
129                  libundertow-0.pc
130                  external/Makefile
131                  external/sqlite/Makefile
132                  src/Makefile
133                  tests/Makefile])
134 AC_OUTPUT