diff options
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 336 |
1 files changed, 336 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac new file mode 100644 index 00000000..248d87da --- /dev/null +++ b/configure.ac | |||
@@ -0,0 +1,336 @@ | |||
1 | # -*- Autoconf -*- | ||
2 | # Process this file with autoconf to produce a configure script. | ||
3 | |||
4 | AC_PREREQ([2.65]) | ||
5 | AC_INIT([tox], [0.0.0], [http://tox.im]) | ||
6 | AC_CONFIG_AUX_DIR(configure_aux) | ||
7 | AC_CONFIG_SRCDIR([toxcore/net_crypto.c]) | ||
8 | AC_CONFIG_HEADERS([config.h]) | ||
9 | AM_INIT_AUTOMAKE([1.10 -Wall]) | ||
10 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) | ||
11 | AC_CONFIG_MACRO_DIR([m4]) | ||
12 | |||
13 | if test "x${prefix}" = "xNONE"; then | ||
14 | prefix="${ac_default_prefix}" | ||
15 | fi | ||
16 | |||
17 | BUILD_DHT_BOOTSTRAP_DAEMON="yes" | ||
18 | BUILD_NTOX="yes" | ||
19 | BUILD_TESTS="yes" | ||
20 | |||
21 | NCURSES_FOUND="no" | ||
22 | LIBCONFIG_FOUND="no" | ||
23 | LIBCHECK_FOUND="no" | ||
24 | |||
25 | AC_ARG_ENABLE([tests], | ||
26 | [AC_HELP_STRING([--disable-tests], [build unit tests (default: auto)]) ], | ||
27 | [ | ||
28 | if test "x$enableval" = "xno"; then | ||
29 | BUILD_TESTS="no" | ||
30 | elif test "x$enableval" = "xyes"; then | ||
31 | BUILD_TESTS="yes" | ||
32 | fi | ||
33 | ] | ||
34 | ) | ||
35 | |||
36 | AC_ARG_ENABLE([ntox], | ||
37 | [AC_HELP_STRING([--disable-ntox], [build nTox client (default: auto)]) ], | ||
38 | [ | ||
39 | if test "x$enableval" = "xno"; then | ||
40 | BUILD_NTOX="no" | ||
41 | elif test "x$enableval" = "xyes"; then | ||
42 | BUILD_NTOX="yes" | ||
43 | fi | ||
44 | ] | ||
45 | ) | ||
46 | |||
47 | AC_ARG_ENABLE([dht-bootstrap-daemon], | ||
48 | [AC_HELP_STRING([--disable-dht-boostrap-daemon], [build DHT bootstrap daemon (default: auto)]) ], | ||
49 | [ | ||
50 | if test "x$enableval" = "xno"; then | ||
51 | BUILD_DHT_BOOTSTRAP_DAEMON="no" | ||
52 | elif test "x$enableval" = "xyes"; then | ||
53 | BUILD_DHT_BOOTSTRAP_DAEMON="yes" | ||
54 | fi | ||
55 | ] | ||
56 | ) | ||
57 | |||
58 | DEPSEARCH= | ||
59 | LIBSODIUM_SEARCH_HEADERS= | ||
60 | LIBSODIUM_SEARCH_LIBS= | ||
61 | |||
62 | AC_ARG_WITH(dependency-search, | ||
63 | AC_HELP_STRING([--with-dependency-search=DIR], | ||
64 | [search for dependencies in DIR, i.e. look for libraries in | ||
65 | DIR/lib and for headers in DIR/include]), | ||
66 | [ | ||
67 | DEPSEARCH="$withval" | ||
68 | ] | ||
69 | ) | ||
70 | |||
71 | if test -n "$DEPSEARCH"; then | ||
72 | CFLAGS="$CFLAGS -I$DEPSEARCH/include" | ||
73 | CPPFLAGS="$CPPFLAGS -I$DEPSEARCH/include" | ||
74 | LDFLAGS="$LDFLAGS -L$DEPSEARCH/lib" | ||
75 | export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$DEPSEARCH/lib/pkgconfig | ||
76 | fi | ||
77 | |||
78 | AC_ARG_WITH(libsodium-headers, | ||
79 | AC_HELP_STRING([--with-libsodium-headers=DIR], | ||
80 | [search for libsodium header files in DIR]), | ||
81 | [ | ||
82 | LIBSODIUM_SEARCH_HEADERS="$withval" | ||
83 | AC_MSG_NOTICE([Will search for libsodium header files in $withval]) | ||
84 | ] | ||
85 | ) | ||
86 | |||
87 | AC_ARG_WITH(libsodium-libs, | ||
88 | AC_HELP_STRING([--with-libsodium-libs=DIR], | ||
89 | [search for libsodium libraries in DIR]), | ||
90 | [ | ||
91 | LIBSODIUM_SEARCH_LIBS="$withval" | ||
92 | AC_MSG_NOTICE([Will search for libsodium libraries in $withval]) | ||
93 | ] | ||
94 | ) | ||
95 | |||
96 | # Checks for programs. | ||
97 | AC_PROG_CC | ||
98 | AM_PROG_CC_C_O | ||
99 | AC_PROG_LIBTOOL | ||
100 | |||
101 | WIN32=no | ||
102 | AC_CANONICAL_HOST | ||
103 | case $host_os in | ||
104 | *mingw*) | ||
105 | WIN32="yes" | ||
106 | AC_MSG_WARN([nTox is not supported on $host_os yet, disabling]) | ||
107 | BUILD_NTOX="no" | ||
108 | ;; | ||
109 | *solaris*) | ||
110 | LIBS="$LIBS -lssp -lsocket -lnsl" | ||
111 | ;; | ||
112 | esac | ||
113 | AM_CONDITIONAL(WIN32, test "x$WIN32" = "xyes") | ||
114 | |||
115 | # Checks for libraries. | ||
116 | LIBSODIUM_LIBS= | ||
117 | LIBSODIUM_LDFLAGS= | ||
118 | LDFLAGS_SAVE="$LDFLAGS" | ||
119 | if test -n "$LIBSODIUM_SEARCH_LIBS"; then | ||
120 | LDFLAGS="-L$LIBSODIUM_SEARCH_LIBS $LDFLAGS" | ||
121 | AC_CHECK_LIB(sodium, randombytes_random, | ||
122 | [ | ||
123 | LIBSODIUM_LDFLAGS="-L$LIBSODIUM_SEARCH_LIBS" | ||
124 | LIBSODIUM_LIBS="-lsodium" | ||
125 | ], | ||
126 | [ | ||
127 | AC_MSG_ERROR([required library libsodium was not found in requested location $LIBSODIUM_SEARCH_LIBS]) | ||
128 | ] | ||
129 | ) | ||
130 | else | ||
131 | AC_CHECK_LIB(sodium, randombytes_random, | ||
132 | [], | ||
133 | [ | ||
134 | AC_MSG_ERROR([required library libsodium was not found on your system, please check http://download.libsodium.org/libsodium/releases/]) | ||
135 | ] | ||
136 | ) | ||
137 | fi | ||
138 | |||
139 | LDFLAGS="$LDFLAGS_SAVE" | ||
140 | AC_SUBST(LIBSODIUM_LIBS) | ||
141 | AC_SUBST(LIBSODIUM_LDFLAGS) | ||
142 | |||
143 | # Checks for header files. | ||
144 | AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h]) | ||
145 | |||
146 | LIBSODIUM_CFLAGS= | ||
147 | CFLAGS_SAVE="$CFLAGS" | ||
148 | CPPFLAGS_SAVE="$CPPFLAGS" | ||
149 | if test -n "$LIBSODIUM_SEARCH_HEADERS"; then | ||
150 | CFLAGS="-I$LIBSODIUM_SEARCH_HEADERS $CFLAGS" | ||
151 | CPPFLAGS="-I$LIBSODIUM_SEARCH_HEADERS $CPPFLAGS" | ||
152 | AC_CHECK_HEADER(sodium.h, | ||
153 | [ | ||
154 | LIBSODIUM_CFLAGS="-I$LIBSODIUM_SEARCH_HEADERS" | ||
155 | ], | ||
156 | [ | ||
157 | AC_MSG_ERROR([header files for required library libsodium was not found in requested location $LIBSODIUM_SEARCH_HEADERS]) | ||
158 | ] | ||
159 | ) | ||
160 | else | ||
161 | AC_CHECK_HEADER(sodium.h, | ||
162 | [], | ||
163 | [ | ||
164 | AC_MSG_ERROR([header files for required library libsodium was not found on your system, please check http://download.libsodium.org/libsodium/releases/]) | ||
165 | ] | ||
166 | ) | ||
167 | fi | ||
168 | CFLAGS="$CFLAGS_SAVE" | ||
169 | CPPFLAGS="$CPPFLAGS_SAVE" | ||
170 | AC_SUBST(LIBSODIUM_CFLAGS) | ||
171 | |||
172 | # Checks for typedefs, structures, and compiler characteristics. | ||
173 | AC_HEADER_STDBOOL | ||
174 | AC_TYPE_INT16_T | ||
175 | AC_TYPE_INT32_T | ||
176 | AC_TYPE_PID_T | ||
177 | AC_TYPE_SIZE_T | ||
178 | AC_TYPE_UINT16_T | ||
179 | AC_TYPE_UINT32_T | ||
180 | AC_TYPE_UINT64_T | ||
181 | AC_TYPE_UINT8_T | ||
182 | |||
183 | # Checks for library functions. | ||
184 | AC_FUNC_FORK | ||
185 | AC_FUNC_MALLOC | ||
186 | AC_FUNC_REALLOC | ||
187 | AC_CHECK_FUNCS([gettimeofday memset socket strchr]) | ||
188 | |||
189 | # pkg-config based tests | ||
190 | PKG_PROG_PKG_CONFIG | ||
191 | |||
192 | if test -n "$PKG_CONFIG"; then | ||
193 | if test "x$BUILD_TESTS" = "xyes"; then | ||
194 | PKG_CHECK_MODULES([CHECK], [check], | ||
195 | [ | ||
196 | LIBCHECK_FOUND="yes" | ||
197 | ], | ||
198 | [ | ||
199 | AC_MSG_WARN([libcheck not found, not building unit tests: $CHECK_PKG_ERRORS]) | ||
200 | BUILD_TESTS="no" | ||
201 | ]) | ||
202 | fi | ||
203 | |||
204 | if test "x$BUILD_DHT_BOOTSTRAP_DAEMON" = "xyes"; then | ||
205 | PKG_CHECK_MODULES([LIBCONFIG], [libconfig >= 1.4.6], | ||
206 | [ | ||
207 | LIBCONFIG_FOUND="yes" | ||
208 | ], | ||
209 | [ | ||
210 | AC_MSG_WARN([$LIBCONFIG_PKG_ERRORS]) | ||
211 | AC_MSG_WARN([libconfig not available, will not build DHT botstrap daemon]) | ||
212 | BUILD_DHT_BOOTSTRAP_DAEMON="no" | ||
213 | ]) | ||
214 | fi | ||
215 | |||
216 | if test "x$BUILD_NTOX" = "xyes"; then | ||
217 | PKG_CHECK_MODULES([NCURSES], [ncurses], | ||
218 | [ | ||
219 | NCURSES_FOUND="yes" | ||
220 | ], | ||
221 | [ | ||
222 | AC_MSG_WARN([$NCURSES_PKG_ERRORS]) | ||
223 | ]) | ||
224 | fi | ||
225 | else | ||
226 | AC_MSG_WARN([pkg-config was not found on your sytem]) | ||
227 | fi | ||
228 | |||
229 | if (test "x$BUILD_NTOX" = "xyes") && (test "x$NCURSES_FOUND" != "xyes"); then | ||
230 | AC_PATH_PROG([CURSES_CONFIG], [ncurses5-config], [no]) | ||
231 | if test "x$CURSES_CONFIG" != "xno"; then | ||
232 | AC_MSG_CHECKING(ncurses cflags) | ||
233 | NCURSES_CFLAGS=`${CURSES_CONFIG} --cflags` | ||
234 | AC_MSG_RESULT($NCURSES_CFLAGS) | ||
235 | |||
236 | AC_MSG_CHECKING(ncurses libraries) | ||
237 | NCURSES_LIBS=`${CURSES_CONFIG} --libs` | ||
238 | AC_MSG_RESULT($NCURSES_LIBS) | ||
239 | |||
240 | AC_SUBST(NCURSES_CFLAGS) | ||
241 | AC_SUBST(NCURSES_LIBS) | ||
242 | NCURSES_FOUND="yes" | ||
243 | fi | ||
244 | |||
245 | if test "x$NCURSES_FOUND" != "xyes"; then | ||
246 | AC_CHECK_HEADER([curses.h], | ||
247 | [], | ||
248 | [ | ||
249 | AC_MSG_WARN([not building nTox client because headers for the curses library were not found on your system]) | ||
250 | BUILD_NTOX="no" | ||
251 | ] | ||
252 | ) | ||
253 | if test "x$BUILD_NTOX" = "xyes"; then | ||
254 | AC_CHECK_LIB([ncurses], [clear], | ||
255 | [], | ||
256 | [ | ||
257 | unset ac_cv_lib_ncurses_clear | ||
258 | AC_CHECK_LIB([ncurses], [clear], | ||
259 | [], | ||
260 | [ | ||
261 | AC_MSG_WARN([not building nTox client because required library ncurses was not found on your system]) | ||
262 | BUILD_NTOX="no" | ||
263 | ], | ||
264 | [ | ||
265 | -ltinfo | ||
266 | ] | ||
267 | ) | ||
268 | ] | ||
269 | ) | ||
270 | fi | ||
271 | fi | ||
272 | fi | ||
273 | |||
274 | if (test "x$BUILD_DHT_BOOTSTRAP_DAEMON" = "xyes") && \ | ||
275 | (test "x$LIBCONFIG_FOUND" = "xno"); then | ||
276 | AC_CHECK_HEADER(libconfig.h, | ||
277 | [], | ||
278 | [ | ||
279 | AC_MSG_WARN([header files for library libconfig was not found on your system, not building DHT bootstrap daemon]) | ||
280 | BUILD_DHT_BOOTSTRAP_DAEMON="no" | ||
281 | ] | ||
282 | ) | ||
283 | |||
284 | if test "x$BUILD_DHT_BOOTSTRAP_DAEMON" = "xyes"; then | ||
285 | AC_CHECK_LIB(config, config_read, | ||
286 | [], | ||
287 | [ | ||
288 | AC_MSG_WARN([library libconfig was not found on the system]) | ||
289 | BUILD_DHT_BOOTSTRAP_DAEMON="no" | ||
290 | ] | ||
291 | ) | ||
292 | fi | ||
293 | fi | ||
294 | |||
295 | if (test "x$BUILD_TESTS" = "xyes") && (test "x$LIBCHECK_FOUND" = "xno"); then | ||
296 | AC_CHECK_HEADER([check.h], | ||
297 | [], | ||
298 | [ | ||
299 | AC_MSG_WARN([header file for check library was not found on your system, unit tests will be disabled]) | ||
300 | BUILD_TESTS="no" | ||
301 | ] | ||
302 | ) | ||
303 | |||
304 | if test "x$BUILD_TESTS" = "xyes"; then | ||
305 | AC_CHECK_LIB([check], [suite_create], | ||
306 | [], | ||
307 | [ | ||
308 | AC_MSG_WARN([library check was not found on the system, unit tests will be disabled]) | ||
309 | BUILD_TESTS="no" | ||
310 | ] | ||
311 | ) | ||
312 | fi | ||
313 | fi | ||
314 | |||
315 | if test "x$WIN32" = "xyes"; then | ||
316 | AC_CHECK_LIB(ws2_32, main, | ||
317 | [ | ||
318 | WINSOCK2_LIBS="-lws2_32" | ||
319 | AC_SUBST(WINSOCK2_LIBS) | ||
320 | ], | ||
321 | [ | ||
322 | AC_MSG_ERROR([required library was not found on the system, please check your MinGW installation]) | ||
323 | ] | ||
324 | ) | ||
325 | fi | ||
326 | |||
327 | AM_CONDITIONAL(BUILD_DHT_BOOTSTRAP_DAEMON, test "x$BUILD_DHT_BOOTSTRAP_DAEMON" = "xyes") | ||
328 | |||
329 | AM_CONDITIONAL(BUILD_TESTS, test "x$BUILD_TESTS" = "xyes") | ||
330 | AM_CONDITIONAL(BUILD_NTOX, test "x$BUILD_NTOX" = "xyes") | ||
331 | |||
332 | AC_CONFIG_FILES([Makefile | ||
333 | build/Makefile | ||
334 | libtoxcore.pc | ||
335 | ]) | ||
336 | AC_OUTPUT | ||