forked from meganz/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
2148 lines (1878 loc) · 61.8 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])
m4_include([m4/ax_cxx_compile_stdcxx.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], [$(cat include/mega/version.h | grep "define MEGA_MAJOR" | cut -d" " -f 3)])
m4_define([mega_minor_version], [$(cat include/mega/version.h | grep "define MEGA_MINOR" | cut -d" " -f 3)])
m4_define([mega_micro_version], [$(cat include/mega/version.h | grep "define MEGA_MICRO" | cut -d" " -f 3)])
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], [$(grep define <include/mega/version.h | awk '{print @S|@3}' | awk 'BEGIN { RS = "" ; FS = "\n" } {printf @S|@1*10000+@S|@2*100+@S|@3}')])
m4_define([mega_lt_age], [0])
AC_INIT([libmega], m4_esyscmd([ grep define < include/mega/version.h | awk '{print $3}' | awk 'BEGIN { RS = "" ; FS = "\n" } {printf $1"."$2"."$3}']), [https://github.com/meganz/sdk])
#override default /usr/local prefix
AC_PREFIX_DEFAULT([/])
# 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])
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_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(CPPCHECK, cppcheck, yes)
AM_CONDITIONAL(CPPCHECK, test -n "$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
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="$CXXFLAGS -Wall -g -ggdb3 -O0"
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"]
)
])
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
ANDROID=no
LINUX=no
AC_MSG_CHECKING([platform options])
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
;;
*-*-msys*)
LIBS_EXTRA="-lws2_32 -lcrypt32 -lole32 -lwinmm -lshlwapi -lshell32"
CXXFLAGS="$CXXFLAGS -DUNICODE -DWINVER=0x0501 -DHAVE_STRUCT_TIMESPEC -Wl,-no-undefined"
LIBMEGA_EXTRALDFLAGS="-no-undefined"
AC_SUBST(LIBMEGA_EXTRALDFLAGS)
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"])
AC_SUBST(LIBS_EXTRA)
if test -n "$IOSC_TARGET"; then
# bu=yes
AC_DEFINE(USE_IOS, 1, [Use IOS])
fi
AM_CONDITIONAL([USE_IOS], [test -n "$IOSC_TARGET"])
# 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
AM_CONDITIONAL([HAVE_PTHREAD], [test "${HAVE_PTHREAD}" = "yes"])
# 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
if test "x$enable_sync" = "xyes" && (test "x$enable_java" = "xyes" || test "x$enable_python" = "xyes" || test "x$enable_php" = "xyes"); then
AC_MSG_ERROR([--enable-sync not allowed when building bindings (php/python/java)!])
fi
],
[enable_sync=yes])
if test "x$enable_java" = "xyes" || test "x$enable_python" = "xyes" || test "x$enable_php" = "xyes" ; then
enable_sync=no
fi
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=${enableval}],
[enable_megaapi=yes])
if test "x$enable_megaapi" != "xno"; then
[enable_megaapi=yes]
AC_DEFINE(USE_MEGAAPI, 1, [Defined if MEGA API enabled])
fi
AM_CONDITIONAL([BUILD_MEGAAPI], [test "x$enable_megaapi" = "xyes"])
# Java
AC_MSG_CHECKING([if building Java bindings])
AC_ARG_ENABLE(java,
AS_HELP_STRING([--enable-java], [build Java language bindings]),
[AC_MSG_RESULT([yes])],
[
AC_MSG_RESULT([no])
enable_java=no]
)
AC_ARG_WITH(java-include-dir,
AS_HELP_STRING([--with-java-include-dir=DIR], [look in DIR for Java headers]),
[JAVA_INCLUDE_DIR=$withval],)
AC_SUBST(JAVA_INCLUDE_DIR)
if test "x$enable_java" = "xyes" ; then
AX_PKG_SWIG(2.0.0, [], [
AC_MSG_ERROR([SWIG executable not found!])
])
AX_SWIG_ENABLE_CXX
AX_SWIG_MULTI_MODULE_SUPPORT
if test -z "$SWIG"; then
AC_MSG_ERROR([SWIG executable not found!])
fi
AC_CHECK_PROG(JAVA, java, yes, no)
if test "x$JAVA" = "xno"; then
AC_MSG_ERROR([no java binary in PATH])
fi
AC_CHECK_PROG(JAVAC, javac, yes, no)
if test "x$JAVAC" = "xno"; then
AC_MSG_ERROR([no javac binary in PATH])
fi
AC_CHECK_PROG(JAR, jar, yes, no)
if test "x$JAR" = "xno"; then
AC_MSG_ERROR([no jar binary in PATH])
fi
SAVE_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS -I$JAVA_INCLUDE_DIR"
# on Fedora / CentOS jni_md.h header is not included
if test -d "$JAVA_INCLUDE_DIR/linux"; then
CPPFLAGS="$CPPFLAGS -I$JAVA_INCLUDE_DIR/linux"
JAVA_INCLUDE_DIR_LINUX="$JAVA_INCLUDE_DIR/linux"
AC_SUBST(JAVA_INCLUDE_DIR_LINUX)
fi
AC_CHECK_HEADER(jni.h,, [AC_MSG_ERROR([could not find jni.h, please specify JAVA include directory using --with-java-include-dir option.])])
CPPFLAGS=$SAVE_CPPFLAGS
fi
AM_CONDITIONAL([BUILD_JAVA], [test "$enable_java" = "yes"])
# Chat
AC_ARG_ENABLE(chat,
AS_HELP_STRING([--enable-chat], [enable chat support]),
[], [enable_chat=no])
if test "x$enable_chat" = "xyes" || test "x$enable_java" = "xyes" || test "x$enable_python" = "xyes" || test "x$enable_php" = "xyes" ; then
enable_chat=yes
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.h],, [
AC_MSG_ERROR([sodium.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.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.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.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.h], [sodium=true], [
if test "x$enable_chat" = "xyes" ; then
AC_MSG_ERROR([sodium.h header not found or not usable])
fi
])
AC_CHECK_LIB(sodium, [sodium_init], [SODIUM_LIBS="-lsodium"],[
if test "x$enable_chat" = "xyes" ; then
AC_MSG_ERROR([Could not find libsodium])
fi
])
]
)
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"])
#
# PCRE
#
#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_SUBST(PCRE_CXXFLAGS)
AC_SUBST(PCRE_CPPFLAGS)
AC_SUBST(PCRE_LDFLAGS)
AC_SUBST(PCRE_LIBS)
if test "x$pcre" = "xtrue" ; then
AC_DEFINE(USE_PCRE, [1], [Define to use libpcre])
fi
AM_CONDITIONAL([USE_PCRE], [test "x$pcre" = "xtrue"])
#
# LIBRAW
#
#libraw
SAVE_LIBS="$LIBS"
LIBS="$LIBS -fopenmp"
AC_MSG_CHECKING(for libraw)
libraw=undef
AC_ARG_WITH(libraw,
AS_HELP_STRING(--with-libraw=PATH, base of libraw installation),
[
case $with_libraw in
no)
libraw=false
;;
yes)
AC_CHECK_HEADERS([libraw/libraw.h],, [
AC_MSG_ERROR([libraw/libraw.h header not found or not usable])
])
AC_CHECK_LIB(raw, [libraw_init], [LIBRAW_LIBS="$LIBRAW_LIBS -lraw -fopenmp"],[
AC_MSG_ERROR([Could not find libraw])
])
libraw=true
;;
*)
# determine if library is installed
if test -d "$with_libraw/lib"; then
LDFLAGS="-L$with_libraw/lib $LDFLAGS"
CXXFLAGS="-I$with_libraw/include $CXXFLAGS"
CPPFLAGS="-I$with_libraw/include $CPPFLAGS"
AC_CHECK_HEADERS(libraw/libraw.h,
LIBRAW_CXXFLAGS="-I$with_libraw/include"
LIBRAW_CPPFLAGS="-I$with_libraw/include"
LIBRAW_LDFLAGS="-L$with_libraw/lib",
AC_MSG_ERROR([libraw/libraw.h header not found or not usable])
)
fi
AC_CHECK_LIB(raw, [libraw_init], [LIBRAW_LIBS="$LIBRAW_LIBS -lraw -fopenmp"],[
AC_MSG_ERROR([Could not find libraw])
])
libraw=true
#restore
LDFLAGS=$SAVE_LDFLAGS
CXXFLAGS=$SAVE_CXXFLAGS
CPPFLAGS=$SAVE_CPPFLAGS
;;
esac
],
)
AC_SUBST(LIBRAW_CXXFLAGS)
AC_SUBST(LIBRAW_CPPFLAGS)
AC_SUBST(LIBRAW_LDFLAGS)
AC_SUBST(LIBRAW_LIBS)
if test "x$libraw" = "xundef" ; then
AC_CHECK_HEADERS([libraw/libraw.h],
[
AC_CHECK_LIB(raw, [libraw_init],
[
libraw=true
LIBRAW_LIBS="$LIBRAW_LIBS -lraw -fopenmp"
],[
AC_MSG_NOTICE([Could not find libraw])
])
]
, [
AC_MSG_NOTICE([libraw/libraw.h header not found or not usable])
])
fi
if test "x$libraw" = "xtrue" ; then
AC_DEFINE(HAVE_LIBRAW, [1], [Define to use libraw])
fi
AM_CONDITIONAL([USE_LIBRAW], [test "x$libraw" = "xtrue"])
LIBS="$SAVE_LIBS"
#
# LIBUV
#
#libuv
LIBUV_LIBS=""
AC_MSG_CHECKING(for libuv)
libuv=false
AC_ARG_WITH(libuv,
AS_HELP_STRING(--with-libuv=PATH, base of libuv installation),
[
case $with_libuv in
no)
libuv=false
;;
yes)
AC_CHECK_HEADERS([uv.h],, [
AC_MSG_ERROR([uv.h header not found or not usable])
])
AC_CHECK_LIB(uv, [uv_run], [LIBUV_LIBS="-luv"],[
AC_MSG_ERROR([Could not find libuv])
])
libuv=true
;;
*)
if test -f "$with_libuv/lib/pkgconfig/libuv.pc"; then
UV_LIBS=`cat $with_libuv/lib/pkgconfig/libuv.pc | grep "Libs:" | awk '{$1=""; $2=""; print $0}'`
fi
SAVE_LIBS=$LIBS
# determine if library is installed
if test -d "$with_libuv/lib"; then
LIBS="-L$with_libuv/lib $UV_LIBS $LIBS" #TODO: These are actually lost: let's assume these library dependencies are included somewhere else
LDFLAGS="-L$with_libuv/lib $UV_LDFLAGS $LDFLAGS"
CXXFLAGS="-I$with_libuv/include $UV_CXXFLAGS $CXXFLAGS"
CPPFLAGS="-I$with_libuv/include $UV_CPPFLAGS $CPPFLAGS"
AC_CHECK_HEADERS(uv.h,
LIBUV_CXXFLAGS="-I$with_libuv/include"
LIBUV_CPPFLAGS="-I$with_libuv/include"
LIBUV_LDFLAGS="-L$with_libuv/lib",
AC_MSG_ERROR([uv.h header not found or not usable])
)
# assume we are using libuv source directory
else
LIBS="-L$with_libuv/uv $UV_LIBS $LIBS"
LDFLAGS="-L$with_libuv/uv $UV_LDFLAGS $LDFLAGS"
CXXFLAGS="-I$with_libuv $UV_CXXFLAGS $CXXFLAGS"
CPPFLAGS="-I$with_libuv $UV_CPPFLAGS $CPPFLAGS"
AC_CHECK_HEADERS(uv.h,
LIBUV_CXXFLAGS="-I$with_libuv"
LIBUV_CPPFLAGS="-I$with_libuv"
LIBUV_LDFLAGS="-L$with_libuv/uv",
AC_MSG_ERROR([uv.h header not found or not usable])
)
fi
AC_CHECK_LIB(uv, [uv_run], [LIBUV_LIBS="-luv"],[
SAVE_LIBS="$LIBS"
LIBS="$LIBS -pthread"
AC_CHECK_LIB(uv, [uv_close], [LIBUV_LIBS="-luv -pthread"],[ #different symbol to avoid cached value
AC_MSG_ERROR([Could not find libuv])
])
LIBS="$SAVE_LIBS"
])
libuv=true
#restore
LIBS=$SAVE_LIBS
LDFLAGS=$SAVE_LDFLAGS
CXXFLAGS=$SAVE_CXXFLAGS
CPPFLAGS=$SAVE_CPPFLAGS
;;
esac
],
[
AC_MSG_RESULT([--with-libuv not specified])
libuv=false
AC_CHECK_HEADERS([uv.h],
AC_CHECK_LIB(uv, [uv_run], [
LIBUV_LIBS="-luv"
libuv=true
],[
if test "x$libuv" != "xtrue"; then
SAVE_LIBS="$LIBS"
LIBS="$LIBS -pthread"
AC_CHECK_LIB(uv, [uv_close], [ #different symbol to avoid cached value
LIBUV_LIBS="-luv -pthread"
libuv=true
],
[
AC_MSG_RESULT([Could not find libuv])
libuv=false
])
LIBS="$SAVE_LIBS"
fi
]
)
,)
]
)
AC_SUBST(LIBUV_CXXFLAGS)
AC_SUBST(LIBUV_CPPFLAGS)
AC_SUBST(LIBUV_LDFLAGS)
AC_SUBST(LIBUV_LIBS)
if test "x$libuv" = "xtrue" ; then
AC_DEFINE(HAVE_LIBUV, [1], [Define to use libuv])
fi
AM_CONDITIONAL([USE_LIBUV], [test "x$libuv" = "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)