forked from meganz/MEGAcmd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
638 lines (552 loc) · 18.5 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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
##
# @file configure.ac
# @brief an input file for autoconf tool
# (c) 2013 by Mega Limited, Auckland, New Zealand
#
# This file is part of the MEGAcmd.
#
# MEGAcmd is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# @copyright Simplified (2-clause) BSD License.
#
# You should have received a copy of the license along with this
# program.
##
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
m4_include([sdk/m4/ax_check_compile_flag.m4])
m4_include([sdk/m4/ax_check_link_flag.m4])
m4_include([sdk/m4/ax_cxx_compile_stdcxx.m4])
m4_include([sdk/m4/ax_atomic.m4])
m4_define([megacmd_major_version], [$(cat src/megacmdversion.h | grep "define MEGACMD_MAJOR" | cut -d" " -f 3)])
m4_define([megacmd_minor_version], [$(cat src/megacmdversion.h | grep "define MEGACMD_MINOR" | cut -d" " -f 3)])
m4_define([megacmd_micro_version], [$(cat src/megacmdversion.h | grep "define MEGACMD_MICRO" | cut -d" " -f 3)])
m4_define([megacmd_version],
[megacmd_major_version.megacmd_minor_version.megacmd_micro_version])
# libtool interface versioning
m4_define([megacmd_lt_revision], [0])
m4_define([megacmd_lt_current], [$(grep define <src/megacmdversion.h | awk '{print @S|@3}' | awk 'BEGIN { RS = "" ; FS = "\n" } {printf @S|@1*10000+@S|@2*100+@S|@3}')])
m4_define([megacmd_lt_age], [0])
AC_INIT([MEGAcmd], m4_esyscmd([ grep define < src/megacmdversion.h | awk '{print $3}' | awk 'BEGIN { RS = "" ; FS = "\n" } {printf $1"."$2"."$3}']), [https://github.com/meganz/megacmd])
AC_PROG_CC
AC_CONFIG_FILES(Makefile)
AC_OUTPUT
AC_CONFIG_SUBDIRS(sdk)
# Define _GNU_SOURCE
# AC_GNU_SOURCE
AC_USE_SYSTEM_EXTENSIONS
AM_INIT_AUTOMAKE([1.11 foreign silent-rules])
AC_CONFIG_HEADERS([src/megacmdconfig.h]) #this avoids inline definitions of stuff already defined in sdk's config.h (e.g: -DPACKAGE_NAME)
LT_INIT([shared disable-static win32-dll])
#AC_CONFIG_MACRO_DIR([m4])
# enable silent build
m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])
AM_SILENT_RULES([yes])
LT_CURRENT=megacmd_lt_current
LT_REVISION=megacmd_lt_revision
LT_AGE=megacmd_lt_age
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_PID_T
AC_TYPE_OFF_T
AH_VERBATIM([__STDC_FORMAT_MACROS],
[/* C99 says: define this to get the PRI... macros from stdint.h */
#ifndef __STDC_FORMAT_MACROS
# define __STDC_FORMAT_MACROS 1
#endif])
AC_CHECK_TYPES([ssize_t])
AC_CANONICAL_HOST
# Check programs
AC_PROG_OBJCXX
AC_PROG_CXX
if test "$CXX" = no || test "$CXX:$GXX" = "g++:"; then
AC_MSG_ERROR([C++ compiler not found !])
fi
AC_PROG_LIBTOOL
AM_SANITY_CHECK
# Check for cppcheck
AC_CHECK_PROG(HAVE_CPPCHECK, cppcheck, yes)
AM_CONDITIONAL(CPPCHECK, test -n "$HAVE_CPPCHECK")
# set C++
AC_LANG_CPLUSPLUS
# Check for C++11 standard
AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory], [default])
# Check headers
AC_STDC_HEADERS
AC_HEADER_STDC
AC_HEADER_STDBOOL
AC_HEADER_DIRENT
# Add 64-bits file support on some hosts
AC_SYS_LARGEFILE
# use new interfaces
AC_FUNC_FSEEKO
AC_TYPE_OFF_T
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_SIZEOF([uint64_t])
AC_STRUCT_TM
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h sys/socket.h sys/timeb.h htonl glob.h malloc.h sys/malloc.h malloc/malloc.h])
# Runtime checks
AC_ARG_ENABLE(sanitizer,
AS_HELP_STRING([--enable-sanitizer@<:@=LIST@:>@],
[compile with (potentially expensive) runtime checks enabled. LIST can be used to enable only certain checks.
Available checks are: asan, ubsan, tsan, all (enables ubsan, asan), none.]),
[ac_checks="${enableval}"], [])
IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="$IFS,"
for check in $ac_checks
do
case $check in
no)
CHECKS_CXXFLAGS=""
CHECKS_CPPFLAGS=""
CHECKS_LDFLAGS=""
;;
all)
# Only enable Address and UB Sanitizer, as ThreadSanitizer cannot be enabled with ASan.
CHECKS_CXXFLAGS="-fsanitize=address -fsanitize=undefined -fno-common"
CHECKS_CPPFLAGS="-fsanitize=address -fsanitize=undefined -fno-common"
CHECKS_LDFLAGS="-fsanitize=address -fsanitize=undefined"
enable_debug="yes"
;;
asan)
CHECKS_CXXFLAGS="-fsanitize=address -fno-common $CHECKS_CXXFLAGS"
CHECKS_CPPFLAGS="-fsanitize=address -fno-common $CHECKS_CPPFLAGS"
CHECKS_LDFLAGS="-fsanitize=address $CHECKS_LDFLAGS"
enable_debug="yes"
;;
ubsan)
CHECKS_CXXFLAGS="-fsanitize=undefined $CHECKS_CXXFLAGS"
CHECKS_CPPFLAGS="-fsanitize=undefined $CHECKS_CPPFLAGS"
CHECKS_LDFLAGS="-fsanitize=undefined $CHECKS_LDFLAGS"
enable_debug="yes"
;;
tsan)
CHECKS_CXXFLAGS="-fsanitize=thread $CHECKS_CXXFLAGS"
CHECKS_CPPFLAGS="-fsanitize=thread $CHECKS_CPPFLAGS"
CHECKS_LDFLAGS="-fsanitize=thread $CHECKS_LDFLAGS"
enable_debug="yes"
;;
*) AC_MSG_ERROR([unknown check $check]) ;;
esac
done
IFS="$ac_save_IFS"
CXXFLAGS="$CHECKS_CXXFLAGS $CXXFLAGS"
CPPFLAGS="$CHECKS_CPPFLAGS $CPPFLAGS"
LDFLAGS="$CHECKS_LDFLAGS $LDFLAGS"
# Debug
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug], [enable support for running in debug mode]),
[], [enable_debug=no])
# Enable debug flags / build
if test "x$enable_debug" = "xyes" ; then
AM_CXXFLAGS="-Wall -ggdb3 -Og -fno-omit-frame-pointer"
CXXFLAGS="-Wall -ggdb3 -Og -fno-omit-frame-pointer"
AC_SUBST([AM_CXXFLAGS])
AC_DEFINE(DEBUG, 1, [Define to enable debug logging])
else
CXXFLAGS="$CXXFLAGS -DNDEBUG=1"
fi
# Check if we can use -fPIC flag
AX_CHECK_COMPILE_FLAG([-fPIC], [
AX_CHECK_LINK_FLAG([-fPIC],
[CXXFLAGS="$CXXFLAGS -fPIC"]
)
])
# Enable backups
CXXFLAGS="$CXXFLAGS -DENABLE_BACKUPS=1"
AM_CONDITIONAL(ENABLE_STATIC, test x$enable_static = xyes)
AC_SUBST(ENABLE_STATIC)
# TARGET OS:
WIN32=no
DARWIN=no
ANDROID=no
LINUX=no
AC_MSG_CHECKING([if building for Win32 platform])
case $host in
*-*-cygwin*)
LIBS_EXTRA="-luser32 -lkernel32"
WIN32=yes
;;
*-*-mingw*)
LIBS_EXTRA="-lws2_32 -lcrypt32 -lole32 -lwinmm -lshlwapi -lshell32"
CXXFLAGS="$CXXFLAGS -DUNICODE -DWINVER=0x0501 -DHAVE_STRUCT_TIMESPEC"
WIN32=yes
;;
*-apple-darwin*)
AC_DEFINE([_XOPEN_SOURCE], [500], [Define _XOPEN_SOURCE])
AC_DEFINE([_DARWIN_C_SOURCE], [1], [Define _DARWIN_C_SOURCE])
DARWIN=yes
;;
*-android*)
ANDROID=yes
;;
*-linux*)
LINUX=yes
;;
*)
LIBS_EXTRA=""
;;
esac
AC_MSG_RESULT([${WIN32}])
AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
AM_CONDITIONAL([DARWIN], [test "${DARWIN}" = "yes"])
AM_CONDITIONAL([ANDROID], [test "${ANDROID}" = "yes"])
AM_CONDITIONAL([LINUX], [test "${LINUX}" = "yes"])
SAVE_LDFLAGS=$LDFLAGS
SAVE_CXXFLAGS=$CXXFLAGS
SAVE_CPPFLAGS=$CPPFLAGS
#
# PCRE
#
#with megacmd 0.9.4 & sdk 3.2.0, libpcrecpp is no linked in megasdk even when compiled with --with-pcre. Hence we need to check here
#Plus, contrary to what the sdk will do, if non-specified and available we default it to true
#libpcre
AC_MSG_CHECKING(for libpcrecpp)
pcre=false
AC_ARG_WITH(pcre,
AS_HELP_STRING(--with-pcre=PATH, base of libpcrecpp installation),
[
case $with_pcre in
no)
pcre=false
;;
yes)
AC_CHECK_HEADERS([pcrecpp.h],, [
AC_MSG_ERROR([pcrecpp.h header not found or not usable])
])
AC_CHECK_LIB(pcrecpp, [main], [PCRE_LIBS="-lpcrecpp"],[
AC_MSG_ERROR([Could not find libpcrecpp])
])
AC_CHECK_LIB(pcre, [pcre_compile], [PCRE_LIBS="$PCRE_LIBS -lpcre"],[
AC_MSG_ERROR([Could not find libpcre])
])
pcre=true
;;
*)
# determine if library is installed
if test -d "$with_pcre/lib64"; then
LDFLAGS="-L$with_pcre/lib64 $LDFLAGS"
CXXFLAGS="-I$with_pcre/include $CXXFLAGS"
CPPFLAGS="-I$with_pcre/include $CPPFLAGS"
AC_CHECK_HEADERS(pcrecpp.h,
PCRE_CXXFLAGS="-I$with_pcre/include"
PCRE_CPPFLAGS="-I$with_pcre/include"
PCRE_LDFLAGS="-L$with_pcre/lib64",
AC_MSG_ERROR([pcrecpp.h header not found or not usable])
)
else
LDFLAGS="-L$with_pcre/lib32 $LDFLAGS"
CXXFLAGS="-I$with_pcre/include $CXXFLAGS"
CPPFLAGS="-I$with_pcre/include $CPPFLAGS"
AC_CHECK_HEADERS(pcrecpp.h,
PCRE_CXXFLAGS="-I$with_pcre/include"
PCRE_CPPFLAGS="-I$with_pcre/include"
PCRE_LDFLAGS="-L$with_pcre/lib32",
AC_MSG_ERROR([pcrecpp.h header not found or not usable])
)
fi
AC_CHECK_LIB(pcrecpp, [main], [PCRE_LIBS="-lpcrecpp"],[
AC_MSG_ERROR([Could not find libpcrecpp])
])
AC_CHECK_LIB(pcre, [pcre_compile], [PCRE_LIBS="$PCRE_LIBS -lpcre"],[
AC_MSG_ERROR([Could not find libpcre])
])
pcre=true
#restore
LDFLAGS=$SAVE_LDFLAGS
CXXFLAGS=$SAVE_CXXFLAGS
CPPFLAGS=$SAVE_CPPFLAGS
;;
esac
],
[AC_MSG_RESULT([--with-pcre not specified])
AC_CHECK_HEADERS([pcrecpp.h], [pcre=true], [])
AC_CHECK_LIB(pcrecpp, [main], [PCRE_LIBS="-lpcrecpp"],[])
AC_CHECK_LIB(pcre, [pcre_compile], [PCRE_LIBS="$PCRE_LIBS -lpcre"],[])
])
if test "x$pcre" = "xtrue" ; then
AC_DEFINE(USE_PCRE, [1], [Define to use libpcre])
fi
AM_CONDITIONAL([USE_PCRE], [test "x$pcre" = "xtrue"])
AC_SUBST(PCRE_CXXFLAGS)
AC_SUBST(PCRE_CPPFLAGS)
AC_SUBST(PCRE_LDFLAGS)
AC_SUBST(PCRE_LIBS)
#################################################
### CLIENTS SPECIFIC DEPENDENCIES ###
#################################################
#termcap
AC_MSG_CHECKING(for termcap)
AC_ARG_WITH(termcap,
AS_HELP_STRING(--with-termcap=PATH, base of termcap installation),
[AC_MSG_RESULT($with_termcap)
case $with_termcap in
no)
;;
yes)
AC_CHECK_LIB([termcap], [tputs], [TERMCAP_LIBS="-ltermcap"],
[AC_MSG_NOTICE([termcap library not found or not usable.])]
)
;;
*)
# determine if library is installed
if test -d "$with_termcap/lib"; then
LDFLAGS="-L$with_termcap/lib $LDFLAGS"
CXXFLAGS="-I$with_termcap/include $CXXFLAGS"
CPPFLAGS="-I$with_termcap/include $CPPFLAGS"
AC_CHECK_HEADERS([termcap.h],[
TERMCAP_LDFLAGS="-L$with_termcap/lib"
TERMCAP_CXXFLAGS="-I$with_termcap/include"
TERMCAP_CPPFLAGS="-I$with_termcap/include"],
AC_MSG_NOTICE([termcap.h header not found or not usable])
)
else
LDFLAGS="-L$with_termcap $LDFLAGS"
CXXFLAGS="-I$with_termcap $CXXFLAGS"
CPPFLAGS="-I$with_termcap $CPPFLAGS"
AC_CHECK_HEADERS([termcap.h],[
TERMCAP_LDFLAGS="-L$with_termcap"
TERMCAP_CXXFLAGS="-I$with_termcap"
TERMCAP_CPPFLAGS="-I$with_termcap"],
AC_MSG_NOTICE([termcap.h header not found or not usable])
)
fi
AC_CHECK_LIB([termcap], [tputs], [TERMCAP_LIBS="-ltermcap"], [
AC_MSG_NOTICE([termcap library not found or not usable.])])
#restore
LDFLAGS=$SAVE_LDFLAGS
CXXFLAGS=$SAVE_CXXFLAGS
CPPFLAGS=$SAVE_CPPFLAGS
;;
esac
],
[AC_MSG_RESULT([--with-termcap not specified])
AC_CHECK_LIB([termcap], [tputs], [TERMCAP_LIBS="-ltermcap"],
[AC_MSG_NOTICE([termcap library not found or not usable.])]
)
]
)
AC_SUBST(TERMCAP_LDFLAGS)
AC_SUBST(TERMCAP_LIBS)
AC_SUBST(TERMCAP_CXXFLAGS)
AC_SUBST(TERMCAP_CPPFLAGS)
# ReadLine
AC_MSG_CHECKING(for Readline)
AC_ARG_WITH(readline,
AS_HELP_STRING(--with-readline=PATH, base of Readline installation),
[AC_MSG_RESULT($with_readline)
case $with_readline in
no)
AC_MSG_ERROR([readline library is required for the sample client.])
;;
yes)
AC_CHECK_HEADERS([readline/readline.h],, [
AC_MSG_ERROR([readline/readline.h header not found or not usable])
])
# readline requires termcap (or ncurses)
SAVE_LIBS=$LIBS
LIBS="$TERMCAP_LIBS $LIBS"
AC_CHECK_LIB([readline], [rl_save_prompt], [RL_LIBS="-lreadline"], [
AC_MSG_ERROR([readline library is required for the sample client.])],
[$LIBS])
LIBS=$SAVE_LIBS
;;
*)
# determine if library is installed
if test -d "$with_readline/lib"; then
LDFLAGS="-L$with_readline/lib $LDFLAGS"
CXXFLAGS="-I$with_readline/include $CXXFLAGS"
CPPFLAGS="-I$with_readline/include $CPPFLAGS"
AC_CHECK_HEADERS([readline/readline.h], [
RL_LDFLAGS="-L$with_readline/lib "
RL_CXXFLAGS="-I$with_readline/include "],
AC_MSG_ERROR([readline/readline.h header not found or not usable])
)
else
LDFLAGS="-L$with_readline $LDFLAGS"
CXXFLAGS="-I$with_readline $CXXFLAGS"
CPPFLAGS="-I$with_readline $CPPFLAGS"
AC_CHECK_HEADERS([readline/readline.h], [
RL_LDFLAGS="-L$with_readline"
RL_CXXFLAGS="-I$with_readline"],
AC_MSG_ERROR([readline/readline.h header not found or not usable])
)
fi
# readline requires termcap (or ncurses)
SAVE_LIBS=$LIBS
LIBS="$TERMCAP_LIBS $LIBS"
AC_CHECK_LIB([readline], [rl_save_prompt], [RL_LIBS="-lreadline"], [
AC_MSG_ERROR([readline library is required for the sample client.])])
LIBS=$SAVE_LIBS
#restore
LDFLAGS=$SAVE_LDFLAGS
CXXFLAGS=$SAVE_CXXFLAGS
CPPFLAGS=$SAVE_CPPFLAGS
;;
esac
],
[AC_MSG_RESULT([--with-readline not specified])
AC_CHECK_HEADERS([readline/readline.h],, [
AC_MSG_ERROR([readline/readline.h header not found or not usable])
])
# readline requires termcap (or ncurses)
SAVE_LIBS=$LIBS
LIBS="$TERMCAP_LIBS $LIBS"
AC_CHECK_LIB([readline], [rl_save_prompt], [RL_LIBS="-lreadline"], [
AC_MSG_ERROR([readline library is required for the sample client.])])
LIBS=$SAVE_LIBS
]
)
AC_SUBST(RL_LDFLAGS)
AC_SUBST(RL_LIBS)
AC_SUBST(RL_CXXFLAGS)
# SQLite3
sqlite=false
AC_MSG_CHECKING(for SQLite)
AC_ARG_WITH(sqlite,
AS_HELP_STRING(--with-sqlite=PATH, base of SQLite installation),
[AC_MSG_RESULT($with_sqlite)
case $with_sqlite in
no)
sqlite=false
;;
yes)
AC_CHECK_HEADERS([sqlite3.h],, [
AC_MSG_ERROR([sqlite3.h header not found or not usable])
])
AC_CHECK_LIB(sqlite3, [sqlite3_open], [DB_LIBS="-lsqlite3"],[
AC_MSG_ERROR([Could not find libsqlite3])
])
AC_SUBST(DB_LIBS)
sqlite=true
;;
*)
# determine if library is installed
if test -d "$with_sqlite/lib"; then
LDFLAGS="-L$with_sqlite/lib $LDFLAGS"
CXXFLAGS="-I$with_sqlite/include $CXXFLAGS"
AC_CHECK_HEADERS(sqlite3.h,[
DB_LDFLAGS="-L$with_sqlite/lib"
DB_CXXFLAGS="-I$with_sqlite/include"
DB_CPPFLAGS="-I$with_sqlite/include"],
AC_MSG_ERROR([sqlite3.h header not found or not usable])
)
# use sqlite3 library
AC_CHECK_LIB(sqlite3, [main], [DB_LIBS="-lsqlite3"],[
AC_MSG_ERROR([Could not find libsqlite3])
])
AC_SUBST(DB_LIBS)
else
LDFLAGS="-L$with_sqlite $LDFLAGS"
CXXFLAGS="-I$with_sqlite $CXXFLAGS"
AC_CHECK_HEADERS(sqlite3.h,[
DB_LDFLAGS="-L$with_sqlite"
DB_CXXFLAGS="-I$with_sqlite"
DB_CPPFLAGS="-I$with_sqlite"],
AC_MSG_ERROR([sqlite3.h header not found or not usable])
)
DB_LIBS="-lsqlite3"
AC_SUBST(DB_LIBS)
fi
sqlite=true
#restore
LDFLAGS=$SAVE_LDFLAGS
CXXFLAGS=$SAVE_CXXFLAGS
CPPFLAGS=$SAVE_CPPFLAGS
;;
esac
],
[AC_MSG_RESULT([--with-sqlite not specified])]
)
AM_CONDITIONAL(USE_SQLITE, test x$sqlite = xtrue)
AC_SUBST(DB_CXXFLAGS)
AC_SUBST(DB_CPPFLAGS)
AC_SUBST(DB_LDFLAGS)
# check if no DB layer is selected, use SQLite by the default
if test "x$sqlite" = "xfalse" ; then
AC_MSG_NOTICE([Using SQLite3 as the default DB access layer.])
AC_CHECK_HEADERS([sqlite3.h],, [
AC_MSG_ERROR([sqlite3.h header not found or not usable])
])
AC_CHECK_LIB(sqlite3, [sqlite3_open], [DB_LIBS="-lsqlite3"],[
AC_MSG_ERROR([Could not find libsqlite3])
])
sqlite=true
AM_CONDITIONAL(USE_SQLITE, test x$sqlite = xtrue)
AC_SUBST(DB_LIBS)
fi
if test "x$sqlite" = "xtrue" ; then
AC_DEFINE(USE_SQLITE, [1], [Define to use SQLite])
fi
#PTHREAD
# check for Pthreads
AC_ARG_ENABLE(posix-threads,
AS_HELP_STRING(--disable-posix-threads, disable POSIX threads support),
[enable_posix_threads=no],
[enable_posix_threads=yes])
if test x$enable_posix_threads != xno; then
AC_CHECK_LIB(pthread, pthread_create, [HAVE_PTHREAD=yes], [HAVE_PTHREAD=no])
else
HAVE_PTHREAD=no
fi
if test "$HAVE_PTHREAD" = "yes"; then
AC_DEFINE(USE_PTHREAD, 1, [Defined if pthreads are available])
if test "$HAVE_PTHREAD" = "yes"; then
SAVE_LDFLAGS="-pthread $SAVE_LDFLAGS"
LDFLAGS="-pthread $LDFLAGS"
fi
fi
AM_CONDITIONAL([HAVE_PTHREAD], [test "${HAVE_PTHREAD}" = "yes"])
## Tests
AC_MSG_CHECKING([if building MEGAcmd tests])
AC_ARG_ENABLE(megacmd-tests,
AS_HELP_STRING([--enable-megacmd-tests], [build MEGAcmd test applications]),
[], [enable_megacmd_tests=no])
if test "x$enable_megacmd_tests" = "xyes" ; then
AC_ARG_WITH(gtest,
AS_HELP_STRING(--with-gtest=PATH, specify GTest location),
[AC_SUBST([GTEST_DIR],[$with_gtest])],
[AC_MSG_ERROR([GTest location must be specified. You can pass simply "--with-gtest" if expected to be in your include path])]
)
fi
AM_CONDITIONAL([BUILD_MEGACMD_TESTS], [test "$enable_megacmd_tests" = "yes"])
AC_MSG_RESULT([$enable_megacmd_tests])
# Add -latomic to LDFLAGS if needed
CHECK_ATOMIC()
#This will simulate compilation of sdk and extract the includes defined for it. Thus we can
# take care of the configuration done for the subproject withtout having to recheck here
AC_OUTPUT
LMEGAINC=$(cd sdk; for i in $(make -n 2>/dev/null | grep "\-I" | grep megaapi ); do echo $i; done | grep "\-I" | sort | uniq | awk '{printf $0" "}')
AC_SUBST(LMEGAINC)
# Output
#AC_CONFIG_FILES([
# Makefile
#])
AC_OUTPUT
#~ AC_OUTPUT([sdk/Makefile])
AC_MSG_NOTICE([MEGAcmd configuration:
MEGACMD version: megacmd_version
Install prefix: $prefix
Compiler: $CXX
CXXFLAGS: $CXXFLAGS
CPPFLAGS: $CPPFLAGS
LDFLAGS: $LDFLAGS
debug: $enable_debug
static: $enable_static
posix threads: $enable_posix_threads
Readline: $RL_CXXFLAGS $RL_LDFLAGS $RL_LIBS
Termcap: $TERMCAP_CXXFLAGS $TERMCAP_LDFLAGS $TERMCAP_LIBS
PCRE: $PCRE_CXXFLAGS $PCRE_LDFLAGS $PCRE_LIBS
SDK includes: $LMEGAINC
MEGAcmd Tests: $enable_megacmd_tests
])