forked from meganz/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
1476 lines (1293 loc) · 41.7 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
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
##
# @file configure.ac
# @brief an input file for autoconf tool
#
# (c) 2013-2015 by Mega Limited, Auckland, New Zealand
#
# This file is part of the MEGA SDK - Client Access Engine.
#
# Applications using the MEGA API must present a valid application key
# and comply with the the rules set forth in the Terms of Service.
#
# The MEGA SDK 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([m4/ax_prog_doxygen.m4])
m4_include([m4/curlchk.m4])
m4_include([m4/ax_check_compile_flag.m4])
m4_include([m4/ax_check_link_flag.m4])
AC_PREREQ([2.61])
# The Mega SDK version number is generated into config.h.
# The version in Git should reflect the *next* version planned.
m4_define([mega_major_version], [2])
m4_define([mega_minor_version], [6])
m4_define([mega_micro_version], [0])
m4_define([mega_version],
[mega_major_version.mega_minor_version.mega_micro_version])
# libtool interface versioning
m4_define([mega_lt_revision], [0])
m4_define([mega_lt_current], [m4_eval(100 * mega_minor_version + mega_micro_version)])
m4_define([mega_lt_age], [0])
AC_INIT([libmega], [mega_version], [https://github.com/meganz/sdk])
# Define _GNU_SOURCE
# AC_GNU_SOURCE
AC_USE_SYSTEM_EXTENSIONS
AM_INIT_AUTOMAKE([1.11 foreign silent-rules])
AC_CONFIG_HEADERS([include/mega/config.h])
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])
MEGA_MAJOR_VERSION=mega_major_version
MEGA_MINOR_VERSION=mega_minor_version
MEGA_MICRO_VERSION=mega_micro_version
AC_SUBST(MEGA_MAJOR_VERSION)
AC_SUBST(MEGA_MINOR_VERSION)
AC_SUBST(MEGA_MICRO_VERSION)
AC_DEFINE(MEGA_MAJOR_VERSION, [mega_major_version],
[MEGA SDK major version.])
AC_DEFINE(MEGA_MINOR_VERSION, [mega_minor_version],
[MEGA SDK minor version.])
AC_DEFINE(MEGA_MICRO_VERSION, [mega_micro_version],
[MEGA SDK micro version.])
LT_CURRENT=mega_lt_current
LT_REVISION=mega_lt_revision
LT_AGE=mega_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
AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
# Check programs
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 headers
AC_STDC_HEADERS
AC_HEADER_STDC
AC_HEADER_STDBOOL
AC_HEADER_DIRENT
AC_DEFINE(__STDC_CONSTANT_MACROS, [], [Force definition of constant macros for C++])
AC_DEFINE(__STDC_FORMAT_MACROS, [], [Force definition of format macros for C++])
AC_DEFINE(__STDC_LIMIT_MACROS, [], [Force definition of limit macros for C++])
# 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])
# 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 -g -ggdb3 -O0"
CXXFLAGS="-Wall -g -ggdb3 -O0"
AC_SUBST([AM_CXXFLAGS])
AC_DEFINE(DEBUG, 1, [Define to enable debug logging])
fi
# Check if we can use -fPIC flag
AX_CHECK_COMPILE_FLAG([-fPIC], [
AX_CHECK_LINK_FLAG([-fPIC],
[CXXFLAGS="$CXXFLAGS -fPIC"]
)
])
AM_CONDITIONAL(ENABLE_STATIC, test x$enable_static = xyes)
AC_SUBST(ENABLE_STATIC)
AC_CHECK_LIB(dl, dlopen, [LIBS="-ldl $LIBS"])
# Check for inotify support.
AC_ARG_ENABLE(inotify,
AS_HELP_STRING([--enable-inotify], [enable inotify support [default=yes]])],
[enable_inotify=$enableval],
[enable_inotify=yes]
)
AS_IF([test "x$enable_inotify" = "xyes"], [
AC_CHECK_HEADERS([sys/inotify.h mcheck.h])
AC_CHECK_FUNCS([inotify_init1], [AC_DEFINE([USE_INOTIFY], [1], [Use inotify API])])
])
# Check for particular functions
AC_CHECK_FUNCS(fdopendir select)
AC_CHECK_LIB([sendfile], [sendfile])
AC_CHECK_LIB([socket], [socket])
AC_CHECK_LIB([rt], [clock_gettime])
# check for malloc only on for native builds
# users report issues with cross-compiling builds
#AS_IF([test "x$cross_compiling" != "xyes"], [AC_FUNC_MALLOC AC_FUNC_REALLOC])
# Check if building for Win32, determine Win32 API libs
WIN32=no
DARWIN=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"
CXXFLAGS="$CXXFLAGS -DUNICODE"
WIN32=yes
;;
*-apple-darwin*)
AC_DEFINE([_XOPEN_SOURCE], [500], [Define _XOPEN_SOURCE])
AC_DEFINE([_DARWIN_C_SOURCE], [1], [Define _DARWIN_C_SOURCE])
DARWIN=yes
;;
*)
LIBS_EXTRA=""
;;
esac
AC_MSG_RESULT([${WIN32}])
AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
AM_CONDITIONAL([DARWIN], [test "${DARWIN}" = "yes"])
AC_SUBST(LIBS_EXTRA)
# 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])
fi
# hardening options
AC_ARG_ENABLE(gcc-hardening,
AS_HELP_STRING(--disable-gcc-hardening, disable compiler security checks),
[],
[enable_gcc_hardening=no])
if test x$enable_gcc_hardening != xno; then
CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2"
AX_CHECK_COMPILE_FLAG([-fstack-protector-all], [
AX_CHECK_LINK_FLAG([-fstack-protector-all],
[CXXFLAGS="$CXXFLAGS -fstack-protector-all"]
)
])
fi
# sync subsystem
AC_ARG_ENABLE(sync,
AS_HELP_STRING([--enable-sync], [include sync subsystem [default=yes]]),
[enable_sync=$enableval],
[enable_sync=yes])
if test x$enable_sync = xyes; then
AC_DEFINE(ENABLE_SYNC, 1, [Defined if sync subsystem is enabled])
fi
# MEGA API
AC_ARG_ENABLE(megaapi,
AS_HELP_STRING([--disable-megaapi], [disable MEGA API support]),
[enable_megaapi=no],
[enable_megaapi=yes])
if test x$enable_megaapi = xyes; then
AC_DEFINE(USE_MEGAAPI, 1, [Defined if MEGA API enabled])
fi
AM_CONDITIONAL([BUILD_MEGAAPI], [test "$enable_megaapi" = "yes"])
# Chat
AC_ARG_ENABLE(chat,
AS_HELP_STRING([--enable-chat], [enable chat support]),
[], [enable_chat=no])
if test "x$enable_chat" = "xyes" ; then
AC_DEFINE(ENABLE_CHAT, 1, [Define to enable chat])
fi
SAVE_LDFLAGS=$LDFLAGS
SAVE_CXXFLAGS=$CXXFLAGS
SAVE_CPPFLAGS=$CPPFLAGS
#libcryptopp
CRYPTO_LIBS="-lcryptopp"
AC_MSG_CHECKING(for libcryptopp)
cryptopp=false
AC_ARG_WITH(cryptopp,
AS_HELP_STRING(--with-cryptopp=PATH, base of libcrypto installation),
[
case $with_cryptopp in
no)
cryptopp=false
;;
yes)
AC_CHECK_HEADERS([cryptopp/cryptlib.h],, [
AC_MSG_ERROR([cryptopp/cryptlib.h header not found or not usable])
])
AC_CHECK_LIB(cryptopp, [main], [CRYPTO_LIBS="-lcryptopp"],[
AC_MSG_ERROR([Could not find libcryptopp])
])
cryptopp=true
;;
*)
# determine if library is installed
if test -d "$with_cryptopp/lib"; then
LDFLAGS="-L$with_cryptopp/lib $LDFLAGS"
CXXFLAGS="-I$with_cryptopp/include $CXXFLAGS"
CPPFLAGS="-I$with_cryptopp/include $CPPFLAGS"
AC_CHECK_HEADERS(cryptopp/cryptlib.h,
CRYPTO_CXXFLAGS="-I$with_cryptopp/include"
CRYPTO_CPPFLAGS="-I$with_cryptopp/include"
CRYPTO_LDFLAGS="-L$with_cryptopp/lib",
AC_MSG_ERROR([cryptopp/cryptlib.h header not found or not usable])
)
# assume we are using crypto source directory
else
LDFLAGS="-L$with_cryptopp/cryptopp $LDFLAGS"
CXXFLAGS="-I$with_cryptopp $CXXFLAGS"
CPPFLAGS="-I$with_cryptopp $CPPFLAGS"
AC_CHECK_HEADERS(cryptopp/cryptlib.h,
CRYPTO_CXXFLAGS="-I$with_cryptopp"
CRYPTO_CPPFLAGS="-I$with_cryptopp"
CRYPTO_LDFLAGS="-L$with_cryptopp/cryptopp",
AC_MSG_ERROR([cryptopp/cryptlib.h header not found or not usable])
)
fi
AC_CHECK_LIB(cryptopp, [main], [CRYPTO_LIBS="-lcryptopp"],[
AC_MSG_ERROR([Could not find libcryptopp])
])
cryptopp=true
#restore
LDFLAGS=$SAVE_LDFLAGS
CXXFLAGS=$SAVE_CXXFLAGS
CPPFLAGS=$SAVE_CPPFLAGS
;;
esac
],
[AC_MSG_RESULT([--with-cryptopp not specified])
AC_CHECK_HEADERS([cryptopp/cryptlib.h],, [
AC_MSG_ERROR([cryptopp/cryptlib.h header not found or not usable])
])
AC_CHECK_LIB(cryptopp, [main], [CRYPTO_LIBS="-lcryptopp"],[
AC_MSG_ERROR([Could not find libcryptopp])
])
])
AC_SUBST(CRYPTO_CXXFLAGS)
AC_SUBST(CRYPTO_CPPFLAGS)
AC_SUBST(CRYPTO_LDFLAGS)
AC_SUBST(CRYPTO_LIBS)
AC_DEFINE(USE_CRYPTOPP, [1], [Define to use libcryptopp])
#libsodium
AC_MSG_CHECKING(for libsodium)
sodium=false
AC_ARG_WITH(sodium,
AS_HELP_STRING(--with-sodium=PATH, base of libsodium installation),
[
case $with_sodium in
no)
sodium=false
;;
yes)
AC_CHECK_HEADERS([sodium/core.h],, [
AC_MSG_ERROR([sodium/core.h header not found or not usable])
])
AC_CHECK_LIB(sodium, [sodium_init], [SODIUM_LIBS="-lsodium"],[
AC_MSG_ERROR([Could not find libsodium])
])
sodium=true
;;
*)
# determine if library is installed
if test -d "$with_sodium/lib"; then
LDFLAGS="-L$with_sodium/lib $LDFLAGS"
CXXFLAGS="-I$with_sodium/include $CXXFLAGS"
CPPFLAGS="-I$with_sodium/include $CPPFLAGS"
AC_CHECK_HEADERS(sodium/core.h,
SODIUM_CXXFLAGS="-I$with_sodium/include"
SODIUM_CPPFLAGS="-I$with_sodium/include"
SODIUM_LDFLAGS="-L$with_sodium/lib",
AC_MSG_ERROR([sodium/sodium.h header not found or not usable])
)
# assume we are using sodium source directory
else
LDFLAGS="-L$with_sodium/src/libsodium/.libs $LDFLAGS"
CXXFLAGS="-I$with_sodium/src/libsodium/include $CXXFLAGS"
CPPFLAGS="-I$with_sodium/src/libsodium/include $CPPFLAGS"
AC_CHECK_HEADERS(sodium/core.h,
SODIUM_CXXFLAGS="-I$with_sodium/src/libsodium/include"
SODIUM_CPPFLAGS="-I$with_sodium/src/libsodium/include"
SODIUM_LDFLAGS="-L$with_sodium/src/libsodium/.libs",
AC_MSG_ERROR([sodium/core.h header not found or not usable])
)
fi
AC_CHECK_LIB(sodium, [sodium_init], [SODIUM_LIBS="-lsodium"],[
AC_MSG_ERROR([Could not find libsodium])
])
sodium=true
#restore
LDFLAGS=$SAVE_LDFLAGS
CXXFLAGS=$SAVE_CXXFLAGS
CPPFLAGS=$SAVE_CPPFLAGS
;;
esac
],
[AC_MSG_RESULT([--with-sodium not specified])
AC_CHECK_HEADERS([sodium/core.h], [sodium=true], [])
AC_CHECK_LIB(sodium, [sodium_init], [SODIUM_LIBS="-lsodium"],[])
]
)
AC_SUBST(SODIUM_CXXFLAGS)
AC_SUBST(SODIUM_CPPFLAGS)
AC_SUBST(SODIUM_LDFLAGS)
AC_SUBST(SODIUM_LIBS)
if test "x$sodium" = "xtrue" ; then
AC_DEFINE(USE_SODIUM, [1], [Define to use libsodium])
fi
AM_CONDITIONAL([USE_SODIUM], [test "x$sodium" = "xtrue"])
#
# Zlib
#
#zlib
AC_MSG_CHECKING(for zlib)
zlib=false
AC_ARG_WITH(zlib,
AS_HELP_STRING(--with-zlib=PATH, base of zlib installation),
[
case $with_zlib in
no)
zlib=false
;;
yes)
AC_CHECK_HEADERS([zlib.h],, [
AC_MSG_ERROR([zlib.h header not found or not usable])
])
AC_CHECK_LIB(z, [main], [ZLIB_LIBS="-lz"],[
AC_MSG_ERROR([Could not find zlib])
])
zlib=true
;;
*)
if test -d "$with_zlib/lib"; then
LDFLAGS="-L$with_zlib/lib $LDFLAGS"
CXXFLAGS="-I$with_zlib/include $CXXFLAGS"
CPPFLAGS="-I$with_zlib/include $CPPFLAGS"
AC_CHECK_HEADERS(zlib.h,
ZLIB_CXXFLAGS="-I$with_zlib/include"
ZLIB_CPPFLAGS="-I$with_zlib/include"
ZLIB_LDFLAGS="-L$with_zlib/lib",
AC_MSG_ERROR([zlib.h header not found or not usable])
)
AC_CHECK_LIB(z, [main], [ZLIB_LIBS="-lz"],[
AC_MSG_ERROR([Could not find zlib])
])
else
LDFLAGS="-L$with_zlib $LDFLAGS"
CXXFLAGS="-I$with_zlib $CXXFLAGS"
CPPFLAGS="-I$with_zlib $CPPFLAGS"
AC_CHECK_HEADERS(zlib.h,
ZLIB_CXXFLAGS="-I$with_zlib"
ZLIB_CPPFLAGS="-I$with_zlib"
ZLIB_LDFLAGS="-L$with_zlib",
AC_MSG_ERROR([zlib.h header not found or not usable])
)
AC_CHECK_LIB(z, [main], [ZLIB_LIBS="-lz"],[
AC_MSG_ERROR([Could not find zlib])
])
fi
zlib=true
#restore
LDFLAGS=$SAVE_LDFLAGS
CXXFLAGS=$SAVE_CXXFLAGS
CPPFLAGS=$SAVE_CPPFLAGS
;;
esac
],
[AC_MSG_RESULT([--with-zlib not specified])
AC_CHECK_HEADERS([zlib.h],, [
AC_MSG_ERROR([zlib.h header not found or not usable])
])
AC_CHECK_LIB(z, [main], [ZLIB_LIBS="-lz"],[
AC_MSG_ERROR([Could not find zlib])
])
])
AC_SUBST(ZLIB_CXXFLAGS)
AC_SUBST(ZLIB_CPPFLAGS)
AC_SUBST(ZLIB_LDFLAGS)
AC_SUBST(ZLIB_LIBS)
AC_DEFINE(USE_ZLIB, [1], [Define to use zlib])
#
# ** DB layer **
#
# 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)
# Berkeley DB
db=false
AC_MSG_CHECKING(for Berkeley DB)
AC_ARG_WITH(db,
AS_HELP_STRING(--with-db=PATH, base of Berkeley DB installation),
[AC_MSG_RESULT($with_db)
case $with_db in
no)
db=false
;;
yes)
AC_CHECK_HEADERS([db_cxx.h],, [
AC_MSG_ERROR([db_cxx.h header not found or not usable])
])
AC_CHECK_LIB(db_cxx, [open], [DB_LIBS="-ldb_cxx"],[
AC_MSG_ERROR([Could not find libdb_cxx])
])
AC_SUBST(DB_LIBS)
db=true
;;
*)
# set temp variables
LDFLAGS="-L$with_db/lib $LDFLAGS"
CXXFLAGS="-I$with_db/include $CXXFLAGS"
AC_CHECK_HEADERS(db_cxx.h,
DB_LDFLAGS="-L$with_db/lib"
DB_CXXFLAGS="-I$with_db/include",
AC_MSG_ERROR([db_cxx.h header not found or not usable])
)
AC_CHECK_LIB(db_cxx, [open], [DB_LIBS="-ldb_cxx"],[
AC_MSG_ERROR([Could not find libdb_cxx])
])
AC_SUBST(DB_LIBS)
db=true
#restore
LDFLAGS=$SAVE_LDFLAGS
CXXFLAGS=$SAVE_CXXFLAGS
;;
esac
],
[AC_MSG_RESULT([--with-db not specified])]
)
AM_CONDITIONAL(USE_DB, test "x$db = xtrue")
AC_SUBST(DB_CXXFLAGS)
AC_SUBST(DB_LDFLAGS)
# check if both DB layers are selected
if test "x$sqlite" = "xtrue" ; then
if test "x$db" = "xtrue" ; then
AC_MSG_ERROR([Please provide exactly one DB access layer, either --with-sqlite or --with-db.])
fi
fi
# check if no DB layer is selected, use SQLite by the default
if test "x$sqlite" = "xfalse" ; then
if test "x$db" = "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
fi
if test "x$sqlite" = "xtrue" ; then
AC_DEFINE(USE_SQLITE, [1], [Define to use SQLite])
AC_DEFINE(USE_DB, [0], [Define to use Berkeley DB])
else
AC_DEFINE(USE_SQLITE, [0], [Define to use SQLite])
AC_DEFINE(USE_DB, [1], [Define to use Berkeley DB])
fi
#
# ** Posix dependent libraries **
#
openssl=false
cares=false
if test "x$WIN32" = "xno" ; then
# OpenSSL
AC_MSG_CHECKING(for OpenSSL)
AC_ARG_WITH([openssl],
AS_HELP_STRING(--with-openssl=PATH, base of OpenSSL installation),
[
case $with_openssl in
no)
AC_MSG_ERROR([Please specify path to OpenSSL installation directory!])
;;
yes)
AC_CHECK_HEADERS([openssl/ssl.h], [],
AC_MSG_ERROR([ssl.h header not found or not usable])
)
LIBS="-lcrypto $LIBS"
AC_CHECK_LIB(ssl, [SSL_new], [LIBSSL_LIBS="-lssl -lcrypto"],
AC_MSG_ERROR([Could not find OpenSSL library!])
)
LIBS=$SAVE_LIBS
AC_SUBST(LIBSSL_LIBS)
openssl=true
;;
*)
# determine if library is installed
LDFLAGS="-L$with_openssl/lib $LDFLAGS"
CXXFLAGS="-I$with_openssl/include $CXXFLAGS"
LIBSSL_LDFLAGS="-L$with_openssl/lib"
LIBSSL_FLAGS="-I$with_openssl/include"
SAVE_LIBS=$LIBS
LIBS="-lcrypto $LIBS"
AC_CHECK_HEADERS([openssl/ssl.h], [],
AC_MSG_ERROR([ssl.h header not found or not usable])
)
AC_CHECK_LIB(ssl, [SSL_new], [LIBSSL_LIBS="-lssl -lcrypto"],
AC_MSG_ERROR([Could not find OpenSSL library!])
)
AC_SUBST(LIBSSL_FLAGS)
AC_SUBST(LIBSSL_LDFLAGS)
AC_SUBST(LIBSSL_LIBS)
openssl=true
#restore
LIBS=$SAVE_LIBS
LDFLAGS=$SAVE_LDFLAGS
CXXFLAGS=$SAVE_CXXFLAGS
CPPFLAGS=$SAVE_CPPFLAGS
;;
esac
],
[
AC_MSG_RESULT([--with-openssl not specified])
AC_CHECK_HEADERS([openssl/ssl.h], [],
AC_MSG_ERROR([ssl.h header not found or not usable])
)
LIBS="-lcrypto $LIBS"
AC_CHECK_LIB(ssl, [SSL_new], [LIBSSL_LIBS="-lssl -lcrypto"],
AC_MSG_ERROR([Could not find OpenSSL library!])
)
LIBS=$SAVE_LIBS
AC_SUBST(LIBSSL_LIBS)
openssl=true
]
)
# c-ares
AC_MSG_CHECKING(for c-ares)
AC_ARG_WITH([cares],
AS_HELP_STRING(--with-cares=PATH, base of c-ares installation),
[
case $with_cares in
no)
AC_MSG_ERROR([Please specify path to c-ares installation directory!])
;;
yes)
AC_CHECK_HEADERS([ares.h], [],
AC_MSG_ERROR([ares.h header not found or not usable])
)
AC_CHECK_LIB(cares, [ares_library_init], [CARES_LIBS="-lcares"],
AC_MSG_ERROR([Could not find c-ares library!])
)
AC_SUBST(CARES_LIBS)
cares=true
;;
*)
# determine if library is installed
LDFLAGS="-L$with_cares/lib $LDFLAGS"
CXXFLAGS="-I$with_cares/include $CXXFLAGS"
CARES_LDFLAGS="-L$with_cares/lib"
CARES_FLAGS="-I$with_cares/include"
AC_CHECK_HEADERS([ares.h], [],
AC_MSG_ERROR([ares.h header not found or not usable])
)
AC_CHECK_LIB(cares, [ares_library_init], [CARES_LIBS="-lcares"],
AC_MSG_ERROR([Could not find c-ares library!])
)
AC_SUBST(CARES_FLAGS)
AC_SUBST(CARES_LDFLAGS)
AC_SUBST(CARES_LIBS)
cares=true
#restore
LDFLAGS=$SAVE_LDFLAGS
CXXFLAGS=$SAVE_CXXFLAGS
CPPFLAGS=$SAVE_CPPFLAGS
;;
esac
],
[
AC_MSG_RESULT([--with-cares not specified])
AC_CHECK_HEADERS([ares.h], [],
AC_MSG_ERROR([ares.h header not found or not usable])
)
AC_CHECK_LIB(cares, [ares_library_init], [CARES_LIBS="-lcares"],
AC_MSG_ERROR([Could not find c-ares library!])
)
AC_SUBST(CARES_LIBS)
cares=true
]
)
# cURL
AC_ARG_ENABLE(curl-checks,
AS_HELP_STRING([--enable-curl-checks], [enable cURL checks [default=yes]])],
[enable_curl_checks=$enableval],
[enable_curl_checks=yes]
)
# check for cURL library
AC_ARG_WITH([curl],
AS_HELP_STRING(--with-curl=PATH, base of cURL installation),
[
case $with_curl in
no)
AC_MSG_ERROR([Please specify path to cURL installation directory!])
;;
yes)
LIBCURL_LIBS="-lcurl"
SAVE_LIBS=$LIBS
LIBS="-lcurl $LIBS"
AC_CHECK_HEADERS([curl/curl.h], [],
AC_MSG_ERROR([curl.h header not found or not usable])
)
AC_CHECK_LIB(curl, [main], [],
AC_MSG_ERROR([Could not find libcurl!])
)
AC_SUBST(LIBCURL_LIBS)
if test "x$enable_curl_checks" = "xyes" ; then
CURL_CHK()
else
AC_MSG_NOTICE([skipping cURL checks.])
fi
LIBS=$SAVE_LIBS
;;
*)
# determine if library is installed
LDFLAGS="-L$with_curl/lib $LDFLAGS"
CXXFLAGS="-I$with_curl/include $CXXFLAGS"
SAVE_LIBS=$LIBS
LIBS="-lcurl $LIBS"
LIBCURL_LIBS="-L$with_curl/lib -lcurl"
LIBCURL_FLAGS="-I$with_curl/include"
AC_CHECK_HEADERS([curl/curl.h], [],
AC_MSG_ERROR([curl.h header not found or not usable])
)
AC_CHECK_LIB(curl, [main], [],
AC_MSG_ERROR([Could not find libcurl!])
)
AC_SUBST(LIBCURL_FLAGS)
AC_SUBST(LIBCURL_LIBS)
if test "x$enable_curl_checks" = "xyes" ; then
CURL_CHK()
else
AC_MSG_NOTICE([skipping cURL checks.])
fi
#restore
LIBS=$SAVE_LIBS
LDFLAGS=$SAVE_LDFLAGS
CXXFLAGS=$SAVE_CXXFLAGS
CPPFLAGS=$SAVE_CPPFLAGS
;;
esac
],
[
LIBCURL_LIBS="-lcurl"
SAVE_LIBS=$LIBS
LIBS="-lcurl $LIBS"
AC_CHECK_HEADERS([curl/curl.h], [],
AC_MSG_ERROR([curl.h header not found or not usable])
)
AC_CHECK_LIB(curl, [main], [],
AC_MSG_ERROR([Could not find libcurl!])
)
AC_SUBST(LIBCURL_LIBS)
if test "x$enable_curl_checks" = "xyes" ; then
CURL_CHK()
else
AC_MSG_NOTICE([skipping cURL checks.])
fi
LIBS=$SAVE_LIBS
]
)
fi
# define on all platforms
AM_CONDITIONAL(HAVE_OPENSSL, test x$openssl = xtrue)
if test "x$openssl" = "xtrue" ; then
AC_DEFINE(USE_OPENSSL, [1], [Define to use OpenSSL])
else
AC_DEFINE(USE_OPENSSL, [0], [Define to use OpenSSL])
fi
# define on all platforms
AM_CONDITIONAL(HAVE_CARES, test x$cares = xtrue)
if test "x$cares" = "xtrue" ; then
AC_DEFINE(USE_CARES, [1], [Define to use c-ares])
else
AC_DEFINE(USE_CARES, [0], [Define to use c-ares])
fi
# determine platform include path
if test "x$WIN32" = "xyes" ; then
platform_include="mega/win32"
else
platform_include="mega/posix"
fi
AC_SUBST(platform_include)
# Examples
AC_MSG_CHECKING([if building example applications])
AC_ARG_ENABLE(examples,
AS_HELP_STRING([--enable-examples], [build example applications]),
[], [enable_examples=yes])
AM_CONDITIONAL([BUILD_EXAMPLES], [test "$enable_examples" = "yes"])
AC_MSG_RESULT([$enable_examples])
# FreeImage
freeimage=false
AC_MSG_CHECKING(for FreeImage)
AC_ARG_WITH(freeimage,
AS_HELP_STRING(--with-freeimage=PATH, base of FreeImage installation),
[AC_MSG_RESULT($with_freeimage)
case $with_freeimage in
no)
freeimage=false
;;
yes)
AC_CHECK_HEADERS([FreeImage.h],, [
AC_MSG_ERROR([FreeImage.h header not found or not usable])
])
AC_CHECK_LIB([freeimage], [main], [FI_LIBS="-lfreeimage"], [
AC_MSG_ERROR([FreeImage library is not found!])])
freeimage=true
;;
*)
# determine if library is installed
if test -d "$with_freeimage/lib"; then
LDFLAGS="-L$with_freeimage/lib $LDFLAGS"
CXXFLAGS="-I$with_freeimage/include $CXXFLAGS"
CPPFLAGS="-I$with_freeimage/include $CPPFLAGS"
AC_CHECK_HEADERS([FreeImage.h],[
FI_LDFLAGS="-L$with_freeimage/lib"
FI_CXXFLAGS="-I$with_freeimage/include"
FI_CPPFLAGS="-I$with_freeimage/include"],
AC_MSG_ERROR([FreeImage.h header not found or not usable])
)
else
LDFLAGS="-L$with_freeimage/Dist $LDFLAGS"
CXXFLAGS="-I$with_freeimage/Dist $CXXFLAGS"
CPPFLAGS="-I$with_freeimage/Dist $CPPFLAGS"
AC_CHECK_HEADERS([FreeImage.h],[
FI_LDFLAGS="-L$with_freeimage/Dist"
FI_CXXFLAGS="-I$with_freeimage/Dist"
FI_CPPFLAGS="-I$with_freeimage/Dist"],
AC_MSG_ERROR([FreeImage.h header not found or not usable])
)
fi
# check and set FI library
AC_CHECK_LIB([freeimage], [main], [FI_LIBS="-lfreeimage"], [
AC_MSG_ERROR([FreeImage library is not found!])])
#restore
LDFLAGS=$SAVE_LDFLAGS
CXXFLAGS=$SAVE_CXXFLAGS
CPPFLAGS=$SAVE_CPPFLAGS
freeimage=true
;;
esac
],
[AC_MSG_RESULT([--with-freeimage not specified])
AC_CHECK_HEADERS([FreeImage.h],, [
AC_MSG_ERROR([FreeImage.h header not found or not usable])
])
AC_CHECK_LIB([freeimage], [main], [FI_LIBS="-lfreeimage"], [
AC_MSG_ERROR([FreeImage library is not found!])])
freeimage=true
]
)
AC_SUBST(FI_LDFLAGS)
AC_SUBST(FI_LIBS)
if test x$enable_static = xyes; then
AC_DEFINE(FREEIMAGE_LIB, [1], [Define to use FreeImage as a static library.])
AM_CONDITIONAL([FREEIMAGE_LIB], [test "x$freeimage" = "xtrue"])
else