summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/configure.ac
blob: b0992a58b1f4ce19581fc4b78fc2ef7251777cd8 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
#  Licensed to the Apache Software Foundation (ASF) under one
#  or more contributor license agreements.  See the NOTICE file
#  distributed with this work for additional information
#  regarding copyright ownership.  The ASF licenses this file
#  to you under the Apache License, Version 2.0 (the
#  "License"); you may not use this file except in compliance
#  with the License.  You may obtain a copy of the License at
#  
#    http://www.apache.org/licenses/LICENSE-2.0
#    
#  Unless required by applicable law or agreed to in writing,
#  software distributed under the License is distributed on an
#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#  KIND, either express or implied.  See the License for the
#  specific language governing permissions and limitations
#  under the License.

dnl run autogen.sh to generate the configure script.

AC_PREREQ(2.59)
AC_INIT(tuscany-sca, 1.0, dev@tuscany.apache.org)
AC_CONFIG_MACRO_DIR([m4])
AC_CANONICAL_SYSTEM
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE([tar-ustar])
AC_PREFIX_DEFAULT(/usr/local/tuscany/sca)

# Check for required programs.
AC_MSG_NOTICE([checking for programs])
if test "${CXX}" = ""; then
  AC_MSG_CHECKING([for clang++])
  if test -x "/usr/bin/clang++"; then
    # Use CLang++/LLVM if available
    CXX=/usr/bin/clang++
    CC=/usr/bin/clang
    AC_MSG_RESULT(/usr/bin/clang++)
    AM_CONDITIONAL([WANT_LLVM], true)
    AC_DEFINE([WANT_LLVM], 1, [compile with clang++/llvm])
  else
    AM_CONDITIONAL([WANT_LLVM], false)
  fi
else
  AM_CONDITIONAL([WANT_LLVM], false)
fi
AC_PROG_CXX
AC_PROG_AWK
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_LIBTOOL

# Initialize default GCC C++ and LD options.
cxxname=`basename ${CXX}`
if test "${cxxname}" = "clang++"; then
  cxxtype="clang"
else
  cxxtype="gcc"
fi
#cxxflags="${CXXFLAGS}"
cxxflags=""
ldflags="${LDFLAGS}"
defaultlibs="${LIBS}"

# Configure TUSCANY_SCACPP path variable.
TUSCANY_SCACPP=`echo "${TUSCANY_SCACPP}"`
if test "${TUSCANY_SCACPP}" = ""; then
  pwd=`pwd`
  AC_SUBST([TUSCANY_SCACPP], ["${pwd}"])
fi

# Check for required header files.
AC_MSG_NOTICE([checking for header files])
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS([string.h sys/time.h])

# Check for typedefs, structures, and compiler characteristics.
AC_MSG_NOTICE([checking for typedefs, structures, and compiler characteristics])
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T

# Check for required library functions.
AC_MSG_NOTICE([checking for library functions])
AC_CHECK_FUNCS([gettimeofday select])

# Check for running on Darwin.
AC_MSG_CHECKING([if running on Darwin])
UNAME=`uname -s`
if test "${UNAME}" = "Darwin"; then
  AC_DEFINE([IS_DARWIN], 1, [running on Darwin])
  AC_MSG_RESULT(yes)
  libsuffix=".dylib"
  AC_SUBST([libsuffix],[".dylib"])
  AM_CONDITIONAL([DARWIN], true)
else
  AC_MSG_RESULT(no)
  libsuffix=".so"
  AC_SUBST([libsuffix],[".so"])
  AM_CONDITIONAL([DARWIN], false)
fi

# Enable debugging and compile-time warnings.
AC_MSG_CHECKING([whether to compile with debugging and compile-time warnings])
AC_ARG_ENABLE(maintainer-mode, [AS_HELP_STRING([--enable-maintainer-mode], [compile with debugging and compile-time warnings [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_maintainer_mode=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_maintainer_mode}" = "true"; then
  cxxflags="${cxxflags} -ggdb -g3 -Werror -Wall -Wextra -Wno-ignored-qualifiers -Wno-strict-aliasing -Winit-self -Wmissing-include-dirs -Wcast-qual -Wcast-align -Wwrite-strings -Wpointer-arith -Waddress -Wredundant-decls -std=c++0x -fmessage-length=0"
  if test "${cxxtype}" = "clang"; then
    cxxflags="${cxxflags} -O1 -stdlib=libc++ -Qunused-arguments -Wno-return-type-c-linkage"
  else
    cxxflags="${cxxflags} -O2 -Wlogical-op -Wconversion"
  fi
  AM_CONDITIONAL([WANT_MAINTAINER_MODE], true)
  AC_DEFINE([WANT_MAINTAINER_MODE], 1, [compile with debugging and compile-time warnings])
else
  cxxflags="${cxxflags} -g -std=c++0x -fmessage-length=0"
  if test "${cxxtype}" = "clang"; then
    cxxflags="${cxxflags} -O1 -stdlib=libc++ -Qunused-arguments"
  else
    cxxflags="${cxxflags} -O2"
  fi
  AM_CONDITIONAL([WANT_MAINTAINER_MODE], false)
fi

# Enable profiling with gprof.
AC_MSG_CHECKING([whether to compile with profiling])
AC_ARG_ENABLE(profiling, [AS_HELP_STRING([--enable-profiling], [compile with profiling [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_profiling=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_profiling}" = "true"; then
  cxxflags="${cxxflags} -pg"
  ldflags="${ldflags} -pg"
  AM_CONDITIONAL([WANT_PROFILING], true)
  AC_DEFINE([WANT_PROFILING], 1, [compile with profiling])
else
  AM_CONDITIONAL([WANT_PROFILING], false)
fi

# Enable memory checking with electric fence.
AC_MSG_CHECKING([whether to enable electric fence])
AC_ARG_ENABLE(efence, [AS_HELP_STRING([--enable-efence], [link with electric fence [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_efence=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_efence}" = "true"; then
  ldflags="${ldflags} -lefence"
  AM_CONDITIONAL([WANT_EFENCE], true)
  AC_DEFINE([WANT_EFENCE], 1, [link with electric fence])
else
  AM_CONDITIONAL([WANT_EFENCE], false)
fi

# Enable usage of mmap for memory allocation.
AC_MSG_CHECKING([whether to use mmap for memory allocation])
AC_ARG_ENABLE(malloc-mmap, [AS_HELP_STRING([--enable-malloc-mmap], [use mmap for memory allocation [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_malloc_mmap=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_malloc_mmap}" = "true"; then
  AM_CONDITIONAL([WANT_MALLOC_MMAP], true)
  AC_DEFINE([WANT_MALLOC_MMAP], 1, [use mmap for memory allocation])
else
  AM_CONDITIONAL([WANT_MALLOC_MMAP], false)
fi

# Enable multi-threading support.
AC_MSG_CHECKING([whether to compile for multi-threaded execution])
AC_ARG_ENABLE(threads, [AS_HELP_STRING([--enable-threads], [compile for multi-threaded execution [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_threads=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_threads}" = "true"; then
  AC_CHECK_LIB([pthread], [pthread_create], [], [AC_MSG_ERROR([couldn't find a suitable libpthread])])
  LIBS="${defaultlibs}"
  cxxflags="${cxxflags} -D_REENTRANT"
  ldflags="${ldflags} -lpthread"
  AM_CONDITIONAL([WANT_THREADS], true)
  AC_DEFINE([WANT_THREADS], 1, [compile for multi-threaded execution])
else
  AM_CONDITIONAL([WANT_THREADS], false)
fi

# Configure exuberant ctags.
TAGSFILE="`pwd`/tags"
AC_SUBST([CTAGSFLAGS], ["${CTAGSFLAGS} --c++-kinds=+p --fields=+iaS --extra=+q --append --tag-relative=yes -f ${TAGSFILE}"])

# Enable Doxygen documentation.
AC_MSG_CHECKING([whether to build Doxygen documentation])
AC_ARG_ENABLE(doxygen, [AS_HELP_STRING([--enable-doxygen], [build Doxygen documentation [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_doxygen=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_doxygen}" = "true"; then
    AC_PATH_PROG(DOXYGEN, doxygen, , ${PATH})
    if test "${DOXYGEN}" = ""; then
      AC_MSG_ERROR([could not find doxygen])
    fi
  AM_CONDITIONAL([WANT_DOXYGEN], true)
  AC_DEFINE([WANT_DOXYGEN], 1, [build Doxygen documentation])
else
  AM_CONDITIONAL([WANT_DOXYGEN], false)
fi

# Configure path to CURL.
AC_MSG_CHECKING([for curl])
AC_ARG_WITH([curl], [AC_HELP_STRING([--with-curl=PATH], [path to installed curl [default=/usr]])], [
  CURL_PREFIX="${withval}"
  LIBCURL_INCLUDE="${withval}/include"
  LIBCURL_LIB="${withval}/lib"
  AC_MSG_RESULT("${withval}")
], [
  CURL_PREFIX="/usr"
  LIBCURL_INCLUDE="/usr/include"
  LIBCURL_LIB="/usr/lib"
  AC_MSG_RESULT(/usr)
])
AC_SUBST(CURL_PREFIX)
AC_DEFINE_UNQUOTED([CURL_PREFIX], "${CURL_PREFIX}", [path to installed curl])
AC_SUBST(LIBCURL_INCLUDE)
AC_SUBST(LIBCURL_LIB)
LIBS="-L${LIBCURL_LIB} ${defaultlibs}"
AC_CHECK_LIB([curl], [curl_global_init], [], [AC_MSG_ERROR([couldn't find a suitable libcurl, use --with-libcurl=PATH])])

# Configure path to libxml2 includes and lib.
AC_MSG_CHECKING([for libxml2])
AC_ARG_WITH([libxml2], [AC_HELP_STRING([--with-libxml2=PATH], [path to installed libxml2 [default=/usr]])], [
  LIBXML2_INCLUDE="${withval}/include/libxml2"
  LIBXML2_LIB="${withval}/lib"
  AC_MSG_RESULT("${withval}")
], [
  LIBXML2_INCLUDE="/usr/include/libxml2"
  LIBXML2_LIB="/usr/lib"
  AC_MSG_RESULT(/usr)
])
AC_SUBST(LIBXML2_INCLUDE)
AC_SUBST(LIBXML2_LIB)
LIBS="-L${LIBXML2_LIB} ${defaultlibs}"
AC_CHECK_LIB([xml2], [xmlInitParser], [], [AC_MSG_ERROR([couldn't find a suitable libxml2, use --with-libxml2=PATH])])

# Configure path to jansson includes and lib.
AC_MSG_CHECKING([for jansson])
AC_ARG_WITH([jansson], [AC_HELP_STRING([--with-jansson=PATH], [path to installed jansson [default=/usr]])], [
  JANSSON_INCLUDE="${withval}/include"
  JANSSON_LIB="${withval}/lib"
  AC_MSG_RESULT("${withval}")
], [
  JANSSON_INCLUDE="/usr/include"
  JANSSON_LIB="/usr/lib"
  AC_MSG_RESULT(/usr)
])
AC_SUBST(JANSSON_INCLUDE)
AC_SUBST(JANSSON_LIB)
LIBS="-L${JANSSON_LIB} ${defaultlibs}"
AC_CHECK_LIB([jansson], [json_loads], [], [AC_MSG_ERROR([couldn't find a suitable libjansson, use --with-jansson=PATH])])

# Configure path to Apache APR and HTTPD includes and libs.
AC_MSG_CHECKING([for apr])
AC_ARG_WITH([apr], [AC_HELP_STRING([--with-apr=PATH], [path to installed Apache APR [default=/usr]])], [
  APR_INCLUDE="${withval}/include/apr-1"
  APR_LIB="${withval}/lib"
  AC_MSG_RESULT("${withval}")
], [
  APR_INCLUDE="/usr/include/apr-1"
  APR_LIB="/usr/lib"
  AC_MSG_RESULT(/usr)
])
AC_SUBST(APR_INCLUDE)
AC_SUBST(APR_LIB)
LIBS="-L${APR_LIB} ${defaultlibs}"
AC_CHECK_LIB([apr-1], [apr_pool_initialize], [], [AC_MSG_ERROR([couldn't find a suitable libapr-1, use --with-apr=PATH])])

AC_MSG_CHECKING([for apr-util])
AC_ARG_WITH([apr-util], [AC_HELP_STRING([--with-apr-util=PATH], [path to installed Apache APR util [default=/usr]])], [
  APRUTIL_INCLUDE="${withval}/include/apr-1"
  APRUTIL_LIB="${withval}/lib"
  AC_MSG_RESULT("${withval}")
], [
  APRUTIL_INCLUDE="/usr/include/apr-1"
  APRUTIL_LIB="/usr/lib"
  AC_MSG_RESULT(/usr)
])
AC_SUBST(APRUTIL_INCLUDE)
AC_SUBST(APRUTIL_LIB)
LIBS="-L${APRUTIL_LIB} ${defaultlibs}"
AC_CHECK_LIB([aprutil-1], [apr_memcache_server_create], [], [AC_MSG_ERROR([couldn't find a suitable libaprutil-1, use --with-apr-util=PATH])])

AC_MSG_CHECKING([for httpd])
AC_ARG_WITH([httpd], [AC_HELP_STRING([--with-httpd=PATH], [path to installed Apache HTTPD [default=/usr]])], [
  HTTPD_PREFIX="${withval}"
  HTTPD_APACHECTL_PREFIX="${withval}/bin/apachectl"
  HTTPD_MODULES_PREFIX="${withval}"
  HTTPD_INCLUDE="${withval}/include"
  AC_MSG_RESULT("${withval}")
], [
  HTTPD_PREFIX="/usr"
  HTTPD_APACHECTL_PREFIX="/usr/sbin/apache2ctl"
  HTTPD_MODULES_PREFIX="/usr/lib/apache2"
  HTTPD_INCLUDE="/usr/include/apache2"
  AC_MSG_RESULT(/usr)
])
AC_SUBST(HTTPD_PREFIX)
AC_DEFINE_UNQUOTED([HTTPD_PREFIX], "${HTTPD_PREFIX}", [path to installed Apache HTTPD])
AC_SUBST(HTTPD_APACHECTL_PREFIX)
AC_SUBST(HTTPD_MODULES_PREFIX)
AC_SUBST(HTTPD_INCLUDE)
AC_MSG_CHECKING([for ${APACHECTL_PREFIX}])
if test -x "${HTTPD_APACHECTL_PREFIX}"; then
    AC_MSG_RESULT(found)
else
    AC_MSG_ERROR([couldn't find apachectl, use --with-httpd=PATH])
fi
AC_MSG_CHECKING([for ${HTTPD_PREFIX}/bin/htpasswd])
if test -x "${HTTPD_PREFIX}/bin/htpasswd"; then
    AC_MSG_RESULT(found)
else
    AC_MSG_ERROR([couldn't find htpasswd, use --with-httpd=PATH])
fi

# Configure path to memcached.
AC_MSG_CHECKING([for memcached])
AC_ARG_WITH([memcached], [AC_HELP_STRING([--with-memcached=PATH], [path to installed memcached [default=/usr]])], [
  MEMCACHED_PREFIX="${withval}"
  AC_MSG_RESULT("${withval}")
], [
  MEMCACHED_PREFIX="/usr"
  AC_MSG_RESULT(/usr)
])
AC_SUBST(MEMCACHED_PREFIX)
AC_DEFINE_UNQUOTED([MEMCACHED_PREFIX], "${MEMCACHED_PREFIX}", [path to installed memcached])
AC_MSG_CHECKING([for ${MEMCACHED_PREFIX}/bin/memcached])
if test -x "${MEMCACHED_PREFIX}/bin/memcached"; then
    AC_MSG_RESULT(found)
else
    AC_MSG_ERROR([couldn't find memcached, use --with-memcached=PATH])
fi

# Configure path to tinycdb.
AC_MSG_CHECKING([for tinycdb])
AC_ARG_WITH([tinycdb], [AC_HELP_STRING([--with-tinycdb=PATH], [path to installed tinycdb [default=/usr]])], [
  TINYCDB_PREFIX="${withval}"
  TINYCDB_INCLUDE="${withval}/include"
  TINYCDB_LIB="${withval}/lib"
  AC_MSG_RESULT("${withval}")
], [
  TINYCDB_PREFIX="/usr"
  TINYCDB_INCLUDE="/usr/include"
  TINYCDB_LIB="/usr/lib"
  AC_MSG_RESULT(/usr)
])
AC_SUBST(TINYCDB_PREFIX)
AC_DEFINE_UNQUOTED([TINYCDB_PREFIX], "${TINYCDB_PREFIX}", [path to installed tinycdb])
AC_SUBST(TINYCDB_INCLUDE)
AC_SUBST(TINYCDB_LIB)
LIBS="-L${TINYCDB_LIB} ${defaultlibs}"
AC_CHECK_LIB([cdb], [cdb_make_start], [], [AC_MSG_ERROR([couldn't find a suitable libcdb, use --with-tinycdb=PATH])])

# Configure default includes and ldflags
cxxflags="${cxxflags} ${INCLUDES} -I. -I${TUSCANY_SCACPP}/kernel -I${APR_INCLUDE} -I${APRUTIL_INCLUDE} -I${HTTPD_INCLUDE} -I${LIBXML2_INCLUDE} -I${JANSSON_INCLUDE} -I${LIBCURL_INCLUDE}"
ldflags="${ldflags} -ldl -L${APR_LIB} -R${APR_LIB} -lapr-1 -L${APRUTIL_LIB} -R${APRUTIL_LIB} -laprutil-1"
ldflags="${ldflags} -L${LIBCURL_LIB} -R${LIBCURL_LIB} -L${JANSSON_LIB} -R${JANSSON_LIB} -L${LIBXML2_LIB} -R${LIBXML2_LIB}"

# Enable Python support.
AC_MSG_CHECKING([whether to enable Python support])
AC_ARG_ENABLE(python, [AS_HELP_STRING([--enable-python], [enable Python support [default=yes]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_python=true
    ;;
  esac ],
[
  AC_MSG_RESULT(yes)
  want_python=true
])
if test "${want_python}" = "true"; then

  # Configure path to Python includes and lib.
  AC_MSG_CHECKING([for python])
  AC_ARG_WITH([python], [AC_HELP_STRING([--with-python=PATH], [path to installed Python [default=/usr]])], [
    PYTHON_PREFIX="${withval}"
    PYTHON_INCLUDE="${withval}/include"
    PYTHON_LIB="${withval}/lib"
    AC_MSG_RESULT("${withval}")
  ], [
    PYTHON_PREFIX="/usr"
    PYTHON_INCLUDE="/usr/include"
    PYTHON_LIB="/usr/lib"
    AC_MSG_RESULT(/usr)
  ])
  AC_SUBST(PYTHON_PREFIX)
  AC_DEFINE_UNQUOTED([PYTHON_PREFIX], "${PYTHON_PREFIX}", [path to installed Python])
  AC_SUBST(PYTHON_INCLUDE)
  AC_SUBST(PYTHON_LIB)
  LIBS="-L${PYTHON_LIB} ${defaultlibs}"
  if test -f "${PYTHON_LIB}/libpython2.7${libsuffix}"; then
      PYTHON_VERSION="2.7"
      AC_DEFINE([PYTHON_VERSION], 27, [Python version])
  else
      PYTHON_VERSION="2.6"
      AC_DEFINE([PYTHON_VERSION], 26, [Python version])
  fi
  AC_SUBST(PYTHON_VERSION)
  AC_CHECK_LIB([python${PYTHON_VERSION}], [Py_Initialize], [], [AC_MSG_ERROR([couldn't find a suitable libpython, use --with-python=PATH])])
  AM_CONDITIONAL([WANT_PYTHON], true)
  AC_DEFINE([WANT_PYTHON], 1, [enable Python support])

else
  AM_CONDITIONAL([WANT_PYTHON], false)
fi

# Configure path to Page Speed.
AC_MSG_CHECKING([for pagespeed])
AC_ARG_WITH([pagespeed], [AC_HELP_STRING([--with-pagespeed=PATH], [path to installed Page Speed [default=/usr/bin]])], [
  PAGESPEED_PREFIX="${withval}"
  AC_MSG_RESULT("${withval}")
], [
  PAGESPEED_PREFIX="/usr/bin"
  AC_MSG_RESULT(/usr/bin)
])
AC_SUBST(PAGESPEED_PREFIX)

# Enable Page Speed optimizations.
AC_MSG_CHECKING([whether to run Page Speed optimizations])
AC_ARG_ENABLE(pagespeed, [AS_HELP_STRING([--enable-pagespeed], [run Page Speed optimizations [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_pagespeed=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_pagespeed}" = "true"; then
    AC_PATH_PROG(MINIFY_HTML, minify_html_bin, , ${PAGESPEED_PREFIX})
    if test "${MINIFY_HTML}" = ""; then
      AC_MSG_ERROR([could not find Page Speed minify_html_bin])
    fi
    AC_PATH_PROG(MINIFY_JS, jsmin_bin, , ${PAGESPEED_PREFIX})
    if test "${MINIFY_JS}" = ""; then
      AC_MSG_ERROR([could not find Page Speed jsmin_bin])
    fi
  AM_CONDITIONAL([WANT_PAGESPEED], true)
  AC_DEFINE([WANT_PAGESPEED], 1, [run Page Speed optimizations])
  AC_DEFINE_UNQUOTED([PAGESPEED_PREFIX], "${PAGESPEED_PREFIX}", [path to installed Page Speed])
else
  AM_CONDITIONAL([WANT_PAGESPEED], false)
fi

# Enable OpenCL support.
AC_MSG_CHECKING([whether to enable OpenCL support])
AC_ARG_ENABLE(opencl, [AS_HELP_STRING([--enable-opencl], [enable OpenCL support [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_opencl=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_opencl}" = "true"; then

  # Configure path to OpenCL includes and lib.
  AC_MSG_CHECKING([for opencl])
  AC_ARG_WITH([opencl-include], [AC_HELP_STRING([--with-opencl-include=PATH], [path to installed OpenCL 1.1 include dir [default=/usr/include]])], [
    OPENCL_INCLUDE="${withval}"
    AC_MSG_RESULT("${withval}")
  ], [
    OPENCL_INCLUDE="/usr/include"
    AC_MSG_RESULT(/usr/include)
  ])
  AC_SUBST(OPENCL_INCLUDE)
  AC_ARG_WITH([opencl-lib], [AC_HELP_STRING([--with-opencl-lib=PATH], [path to installed OpenCL 1.1 lib dir [default=/usr/lib]])], [
    OPENCL_LIB="${withval}"
    AC_MSG_RESULT("${withval}")
  ], [
    OPENCL_LIB="/usr/lib"
    AC_MSG_RESULT(/usr/lib)
  ])
  AC_SUBST(OPENCL_LIB)
  if test "${UNAME}" != "Darwin"; then
    LIBS="-L${OPENCL_LIB} ${defaultlibs}"
    AC_CHECK_LIB([OpenCL], [clGetDeviceIDs], [], [AC_MSG_ERROR([couldn't find a suitable libOpenCL, use --with-opencl=PATH])])
  fi
  AM_CONDITIONAL([WANT_OPENCL], true)
  AC_DEFINE([WANT_OPENCL], 1, [enable OpenCL support])

else
  AM_CONDITIONAL([WANT_OPENCL], false)
fi

# Enable Java support.
AC_MSG_CHECKING([whether to enable Java support])
AC_ARG_ENABLE(java, [AS_HELP_STRING([--enable-java], [enable Java support [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_java=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_java}" = "true"; then

  # Configure path to Java includes and lib.
  AC_MSG_CHECKING([for java])
  AC_ARG_WITH([java], [AC_HELP_STRING([--with-java=PATH], [path to installed Java [default=/usr/lib/jvm/default-java]])], [
    JAVA_PREFIX="${withval}"
    JAVA_INCLUDE="${withval}/include"
    JAVAC="${withval}/bin/javac"
    JAR="${withval}/bin/jar" 
    AC_MSG_RESULT("${withval}")
  ], [
    JAVA_PREFIX="/usr/lib/jvm/default-java"
    JAVA_INCLUDE="/usr/lib/jvm/default-java/include"
    JAVAC="/usr/lib/jvm/default-java/bin/javac"
    JAR="/usr/lib/jvm/default-java/bin/jar" 
    AC_MSG_RESULT(/usr/lib/jvm/default-java)
  ])
  AC_SUBST(JAVA_PREFIX)
  AC_DEFINE_UNQUOTED([JAVA_PREFIX], "${JAVA_PREFIX}", [path to installed Java])
  AC_SUBST(JAVA_INCLUDE)
  AC_SUBST(JAVAC)
  AC_SUBST(JAR)

  # Detect most common Java VMs
  JAVA_LIBJAVA_SO=`find ${JAVA_PREFIX}/jre/lib -name libjava.so`
  if test "${JAVA_LIBJAVA_SO}" != ""; then
    JAVA_LIBJAVA=`dirname "${JAVA_LIBJAVA_SO}"`
    JAVA_LIBJVM_SO=`find ${JAVA_PREFIX}/jre/lib -name libjvm.so`
    JAVA_J9_VM=`echo "${JAVA_LIBJVM}" | grep "j9vm"`
    if test "${JAVA_J9_VM}" != ""; then
      # IBM J9 VM
      AC_MSG_NOTICE([checking for J9 Java VM])
      JAVA_LIBJVM=`dirname "${JAVA_LIBJVM_SO}"`
      JAVA_CHECK_LIB="-L${JAVA_LIBJAVA} -Wl,-R${JAVA_LIBJAVA} -L${JAVA_LIBJVM} -Wl,-R${JAVA_LIBJVM}"
      LIBS="${JAVA_CHECK_LIB} ${defaultlibs}"
      AC_CHECK_LIB([java], [JNI_CreateJavaVM], [JAVA_LDFLAGS="${JAVA_CHECK_LIB} -ljava -ljvm -ljsig"], [], [-ljvm -ljsig])
      if test "${JAVA_LDFLAGS}" != ""; then
        AC_DEFINE([JAVA_J9_VM], 1, [J9 Java VM])
      fi
    else
      # SUN JDK or OpenJDK VM
      AC_MSG_NOTICE([checking for OpenJDK Java VM])
      JAVA_LIBJVM_SO=`find ${JAVA_PREFIX}/jre/lib -name libjvm.so | grep server`
      JAVA_LIBJVM=`dirname "${JAVA_LIBJVM_SO}"`
      AC_MSG_NOTICE([libjava ${JAVA_LIBJAVA} libjvm ${LIBJVM}])
      JAVA_CHECK_LIB="-L${JAVA_LIBJAVA} -Wl,-R${JAVA_LIBJAVA} -L${JAVA_LIBJVM} -Wl,-R${JAVA_LIBJVM}"
      LIBS="${JAVA_CHECK_LIB} ${defaultlibs}"
      AC_CHECK_LIB([java], [JNI_CreateJavaVM], [JAVA_LDFLAGS="${JAVA_CHECK_LIB} -ljava -ljvm -lverify"], [], [-ljvm -lverify])
      if test "${JAVA_LDFLAGS}" != ""; then
        AC_DEFINE([JAVA_OPENJDK_VM], 1, [OpenJDK Java VM])
      fi
    fi
  else
    JAVA_LIBHARMONYVM_SO=`find ${JAVA_PREFIX}/jre/bin -name libharmonyvm.so`
    if test "${JAVA_LIBHARMONYVM_SO}" != ""; then
      # Apache Harmony VM
      JAVA_LIBHARMONYVM=`dirname "${JAVA_LIBHARMONYVM_SO}"`
      JAVA_LIBJAVA=`dirname "${JAVA_LIBHARMONYVM}"`
      AC_MSG_NOTICE([checking for Apache Harmony Java VM])
      JAVA_CHECK_LIB="-L${JAVA_LIBJAVA} -Wl,-R${JAVA_LIBJAVA} -L${JAVA_LIBHARMONYVM} -Wl,-R${JAVA_LIBHARMONYVM}"
      LIBS="${JAVA_CHECK_LIB} ${defaultlibs}"
      AC_CHECK_LIB([harmonyvm], [JNI_CreateJavaVM], [JAVA_LDFLAGS="${JAVA_CHECK_LIB} -lharmonyvm -lhythr -licuuc -lch ${JAVA_LIBHARMONYVM}/libicudata.so.34"], [], [-lhythr -licuuc -lch ${JAVA_LIBHARMONYVM}/libicudata.so.34])
      if test "${JAVA_LDFLAGS}" != ""; then
        AC_DEFINE([JAVA_HARMONY_VM], 1, [Apache Harmony Java VM])
      fi
    fi
  fi
  if test "${JAVA_LDFLAGS}" = ""; then
    AC_MSG_ERROR([couldn't find a suitable Java JNI library, use --with-java=PATH])
  fi
  AC_MSG_CHECKING([for javac])
  if test -x "${JAVAC}"; then
    AC_MSG_RESULT("${JAVAC}")
  else
    AC_MSG_ERROR([couldn't find a suitable javac tool, use --with-java=PATH])
  fi
  AC_MSG_CHECKING([for jar])
  if test -x "${JAR}"; then
    AC_MSG_RESULT("${JAR}")
  else
    AC_MSG_ERROR([couldn't find a suitable jar tool, use --with-java=PATH])
  fi 
  AM_CONDITIONAL([WANT_JAVA], true)
  AC_DEFINE([WANT_JAVA], 1, [enable Java support])
else
  AM_CONDITIONAL([WANT_JAVA], false)
  JAVA_LDFLAGS=""
fi
AC_SUBST(JAVA_LDFLAGS)

# Enable support for OpenID.
AC_MSG_CHECKING([whether to enable OpenID support])
AC_ARG_ENABLE(openid, [AS_HELP_STRING([--enable-openid], [enable OpenID support [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_openid=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_openid}" = "true"; then

  # Configure path to mod-auth-openid
  AC_MSG_CHECKING([for mod-auth-openid])
  AC_ARG_WITH([mod-auth-openid], [AC_HELP_STRING([--with-mod-auth-openid=PATH], [path to installed mod-auth-openid [default=/usr/local]])], [
    MODAUTHOPENID_PREFIX="${withval}"
    AC_MSG_RESULT("${withval}")
  ], [
    MODAUTHOPENID_PREFIX="/usr/local/"
    AC_MSG_RESULT(/usr/local)
  ])
  AC_SUBST(MODAUTHOPENID_PREFIX)
  AC_DEFINE_UNQUOTED([MODAUTHOPENID_PREFIX], "${MODAUTHOPENID_PREFIX}", [path to installed mod-auth-openid])

  AM_CONDITIONAL([WANT_OPENID], true)
  AC_DEFINE([WANT_OPENID], 1, [enable OpenID support])

else
  AM_CONDITIONAL([WANT_OPENID], false)
fi

# Enable support for OAuth.
AC_MSG_CHECKING([whether to enable OAuth support])
AC_ARG_ENABLE(oauth, [AS_HELP_STRING([--enable-oauth], [enable OAuth support [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_oauth=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_oauth}" = "true"; then

  # Configure path to Liboauth includes and lib.
  AC_MSG_CHECKING([for liboauth])
  AC_ARG_WITH([liboauth], [AC_HELP_STRING([--with-liboauth=PATH], [path to liboauth [default=/usr/local]])], [
    LIBOAUTH_INCLUDE="${withval}/include"
    LIBOAUTH_LIB="${withval}/lib"
    AC_MSG_RESULT("${withval}")
  ], [
    LIBOAUTH_INCLUDE="/usr/local/include"
    LIBOAUTH_LIB="/usr/local/lib"
    AC_MSG_RESULT(/usr/local)
  ])
  AC_SUBST(LIBOAUTH_INCLUDE)
  AC_SUBST(LIBOAUTH_LIB)
  LIBS="-L${LIBOAUTH_LIB} ${defaultlibs}"
  AC_CHECK_LIB([oauth], [oauth_sign_url2], [], [AC_MSG_ERROR([couldn't find a suitable liboauth, use --with-liboauth=PATH])], [-lssl])
  
  AM_CONDITIONAL([WANT_OAUTH], true)
  AC_DEFINE([WANT_OAUTH], 1, [enable OAuth support])

else
  AM_CONDITIONAL([WANT_OAUTH], false)
fi

# Enable support for modsecurity.
AC_MSG_CHECKING([whether to enable mod-security support])
AC_ARG_ENABLE(mod-security, [AS_HELP_STRING([--enable-mod-security], [enable mod-security support [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_modsecurity=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_modsecurity}" = "true"; then

  # Configure path to mod-security
  AC_MSG_CHECKING([for mod-security])
  AC_ARG_WITH([mod-security], [AC_HELP_STRING([--with-mod-security=PATH], [path to installed mod-security [default=/usr/local]])], [
    MODSECURITY_PREFIX="${withval}"
    AC_MSG_RESULT("${withval}")
  ], [
    MODSECURITY_PREFIX="/usr/local/"
    AC_MSG_RESULT(/usr/local)
  ])
  AC_SUBST(MODSECURITY_PREFIX)
  AC_DEFINE_UNQUOTED([MODSECURITY_PREFIX], "${MODSECURITY_PREFIX}", [path to installed mod-security])

  AM_CONDITIONAL([WANT_MODSECURITY], true)
  AC_DEFINE([WANT_MODSECURITY], 1, [enable mod-security support])

else
  AM_CONDITIONAL([WANT_MODSECURITY], false)
fi

# Enable support for Google AppEngine.
AC_MSG_CHECKING([whether to enable Google AppEngine support])
AC_ARG_ENABLE(gae, [AS_HELP_STRING([--enable-gae], [enable Google AppEngine support [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_gae=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_gae}" = "true"; then

  # Configure path to Google AppEngine SDK.
  AC_MSG_CHECKING([for gae])
  AC_ARG_WITH([gae], [AC_HELP_STRING([--with-gae=PATH], [path to installed Google AppEngine 1.3.2 [default=${HOME}/google_appengine]])], [
    GAE_PREFIX="${withval}"
    AC_MSG_RESULT("${withval}")
  ], [
    GAE_PREFIX="${HOME}/google_appengine"
    AC_MSG_RESULT(${HOME}/google_appengine)
  ])
  AC_SUBST(GAE_PREFIX)

  AM_CONDITIONAL([WANT_GAE], true)
  AC_DEFINE([WANT_GAE], 1, [enable Google AppEngine support])
else
  AM_CONDITIONAL([WANT_GAE], false)
fi

# Enable support for Libcloud.
AC_MSG_CHECKING([whether to enable libcloud support])
AC_ARG_ENABLE(libcloud, [AS_HELP_STRING([--enable-libcloud], [enable libcloud support [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_libcloud=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_libcloud}" = "true"; then

  # Configure path to Apache Libcloud.
  AC_MSG_CHECKING([for libcloud])
  AC_ARG_WITH([libcloud], [AC_HELP_STRING([--with-libcloud=PATH], [path to installed Apache libcloud [default=/usr/local]])], [
    LIBCLOUD_LIB="${withval}/lib/python"
    AC_MSG_RESULT("${withval}")
  ], [
    LIBCLOUD_LIB="/usr/local/lib/python${PYTHON_VERSION}/site-packages"
    AC_MSG_RESULT(/usr/local)
  ])
  AC_SUBST(LIBCLOUD_LIB)

  AM_CONDITIONAL([WANT_LIBCLOUD], true)
  AC_DEFINE([WANT_LIBCLOUD], 1, [enable libcloud support])
else
  AM_CONDITIONAL([WANT_LIBCLOUD], false)
fi

# Enable Web service component.
AC_MSG_CHECKING([whether to enable the Web service component])
AC_ARG_ENABLE(webservice, [AS_HELP_STRING([--enable-webservice], [enable Web service component [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_webservice=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_webservice}" = "true"; then

  # Configure path to Apache Axis2C includes and lib.
  AC_MSG_CHECKING([for axis2c])
  AC_ARG_WITH([axis2c], [AC_HELP_STRING([--with-axis2c=PATH], [path to installed Apache Axis2C [default=/usr/local/axis2c]])], [
    AXIS2C_PREFIX="${withval}"
    AXIS2C_INCLUDE="${withval}/include/axis2-1.6.0"
    AXIS2C_LIB="${withval}/lib"
    AC_MSG_RESULT("${withval}")
  ], [
    AXIS2C_PREFIX="/usr/local/axis2c"
    AXIS2C_INCLUDE="/usr/local/axis2c/include/axis2-1.6.0"
    AXIS2C_LIB="/usr/local/axis2c/lib"
    AC_MSG_RESULT(/usr/local/axis2c)
  ])
  AC_SUBST(AXIS2C_PREFIX)
  AC_DEFINE_UNQUOTED([AXIS2C_PREFIX], "${AXIS2C_PREFIX}", [path to installed Axis2C])
  AC_SUBST(AXIS2C_INCLUDE)
  AC_SUBST(AXIS2C_LIB)
  LIBS="-L${AXIS2C_LIB} ${defaultlibs}"
  AC_CHECK_LIB([axis2_engine], [axis2_svc_client_create], [], [AC_MSG_ERROR([couldn't find a suitable libaxis2_engine, use --with-axis2c=PATH])])

  AM_CONDITIONAL([WANT_WEBSERVICE], true)
  AC_DEFINE([WANT_WEBSERVICE], 1, [enable Web service component])

else
  AM_CONDITIONAL([WANT_WEBSERVICE], false)
fi

# Enable SQL Database component.
AC_MSG_CHECKING([whether to enable the SQL Database component])
AC_ARG_ENABLE(sqldb, [AS_HELP_STRING([--enable-sqldb], [enable SQL Database component [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_sqldb=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_sqldb}" = "true"; then

  # Configure path to PostgreSQL.
  AC_MSG_CHECKING([for pgsql])
  AC_ARG_WITH([pgsql], [AC_HELP_STRING([--with-pgsql=PATH], [path to installed PostgreSQL [default=/usr/local/pgsql]])], [
    PGSQL_PREFIX="${withval}"
    PGSQL_INCLUDE="${withval}/include"
    PGSQL_LIB="${withval}/lib"
    AC_MSG_RESULT("${withval}")
  ], [
    PGSQL_PREFIX="/usr/local/pgsql"
    PGSQL_INCLUDE="/usr/local/pgsql/include"
    PGSQL_LIB="/usr/local/pgsql/lib"
    AC_MSG_RESULT(/usr/local)
  ])
  AC_SUBST(PGSQL_PREFIX)
  AC_DEFINE_UNQUOTED([PGSQL_PREFIX], "${PGSQL_PREFIX}", [path to installed PostgreSQL])
  AC_SUBST(PGSQL_INCLUDE)
  AC_SUBST(PGSQL_LIB)

  # Configure path to PgBouncer.
  AC_MSG_CHECKING([for pgbouncer])
  AC_ARG_WITH([pgbouncer], [AC_HELP_STRING([--with-pgbouncer=PATH], [path to installed PgBouncer [default=/usr/local]])], [
    PGBOUNCER_PREFIX="${withval}"
    AC_MSG_RESULT("${withval}")
  ], [
    PGBOUNCER_PREFIX="/usr/local"
    AC_MSG_RESULT(/usr/local)
  ])
  AC_SUBST(PGBOUNCER_PREFIX)
  AC_DEFINE_UNQUOTED([PGBOUNCER_PREFIX], "${PGBOUNCER_PREFIX}", [path to installed PgBouncer])

  AM_CONDITIONAL([WANT_SQLDB], true)
  AC_DEFINE([WANT_SQLDB], 1, [enable SQL Database component])
else
  AM_CONDITIONAL([WANT_SQLDB], false)
fi

# Enable Queue component.
AC_MSG_CHECKING([whether to enable the Queue component])
AC_ARG_ENABLE(queue, [AS_HELP_STRING([--enable-queue], [enable Queue component [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_queue=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_queue}" = "true"; then

  # Configure path to Apache Qpid/C++.
  AC_MSG_CHECKING([for qpidc])
  AC_ARG_WITH([qpidc], [AC_HELP_STRING([--with-qpidc=PATH], [path to installed Apache Qpid/C++ [default=/usr/local]])], [
    QPIDC_PREFIX="${withval}"
    QPIDC_INCLUDE="${withval}/include"
    QPIDC_LIB="${withval}/lib"
    AC_MSG_RESULT("${withval}")
  ], [
    QPIDC_PREFIX="/usr/local"
    QPIDC_INCLUDE="/usr/local/include"
    QPIDC_LIB="/usr/local/lib"
    AC_MSG_RESULT(/usr/local)
  ])
  AC_SUBST(QPIDC_PREFIX)
  AC_DEFINE_UNQUOTED([QPIDC_PREFIX], "${QPIDC_PREFIX}", [path to installed Qpid/C++])
  AC_SUBST(QPIDC_INCLUDE)
  AC_SUBST(QPIDC_LIB)

  if test "${want_threads}" != "true"; then
    AC_MSG_ERROR([--enable-queue requires multi-threading, use --enable-threads])
  fi
  LIBS="-L${QPIDC_LIB} ${defaultlibs}"
  AC_CHECK_LIB([qpidclient], [_init], [], [AC_MSG_ERROR([couldn't find a suitable libqpidclient, use --with-qpidc=PATH])])

  AM_CONDITIONAL([WANT_QUEUE], true)
  AC_DEFINE([WANT_QUEUE], 1, [enable Queue component])
else
  AM_CONDITIONAL([WANT_QUEUE], false)
fi

# Enable Chat component.
AC_MSG_CHECKING([whether to enable the Chat component])
AC_ARG_ENABLE(chat, [AS_HELP_STRING([--enable-chat], [enable Chat component [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_chat=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_chat}" = "true"; then

  # Configure path to Libstrophe includes and lib.
  AC_MSG_CHECKING([for libstrophe])
  AC_ARG_WITH([libstrophe], [AC_HELP_STRING([--with-libstrophe=PATH], [path to libstrophe [default=/usr/local]])], [
    LIBSTROPHE_INCLUDE="${withval}/include"
    LIBSTROPHE_LIB="${withval}/lib"
    AC_MSG_RESULT("${withval}")
  ], [
    LIBSTROPHE_INCLUDE="/usr/local/include"
    LIBSTROPHE_LIB="/usr/local/lib"
    AC_MSG_RESULT(/usr/local)
  ])
  AC_SUBST(LIBSTROPHE_INCLUDE)
  AC_SUBST(LIBSTROPHE_LIB)
  if test "${want_threads}" != "true"; then
    AC_MSG_ERROR([--enable-chat requires multi-threading, use --enable-threads])
  fi
  LIBS="-L${LIBSTROPHE_LIB} ${defaultlibs}"
  AC_CHECK_LIB([strophe], [xmpp_initialize], [], [AC_MSG_ERROR([couldn't find a suitable libstrophe, use --with-libstrophe=PATH])], [-lssl -lresolv])
  
  # Configure path to Vysper
  AC_MSG_CHECKING([for vysper])
  AC_ARG_WITH([vysper], [AC_HELP_STRING([--with-vysper=PATH], [path to Apache Vysper [default=${HOME}/vysper-1.0.0]])], [
    VYSPER_PREFIX="${withval}"
    AC_MSG_RESULT("${withval}")
  ], [
    VYSPER_PREFIX="${HOME}/vysper-1.0.0"
    AC_MSG_RESULT(${HOME}/vysper-1.0.0)
  ])
  AC_SUBST(VYSPER_PREFIX)
  AC_CHECK_FILE([${VYSPER_PREFIX}/lib/vysper-core-0.6.jar], [want_vysper=true], [])
  if test "${want_vysper}" = "true"; then
    AM_CONDITIONAL([WANT_VYSPER], true)
  else
    AM_CONDITIONAL([WANT_VYSPER], false)
  fi

  AM_CONDITIONAL([WANT_CHAT], true)
  AC_DEFINE([WANT_CHAT], 1, [enable Chat component])

else
  AM_CONDITIONAL([WANT_CHAT], false)
  AM_CONDITIONAL([WANT_VYSPER], false)
fi

# Enable Log component.
AC_MSG_CHECKING([whether to enable the Log component])
AC_ARG_ENABLE(log, [AS_HELP_STRING([--enable-log], [enable Log component [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_log=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_log}" = "true"; then

  # Configure path to Apache Thrift (and Facebook fb303).
  AC_MSG_CHECKING([for thrift])
  AC_ARG_WITH([thrift], [AC_HELP_STRING([--with-thrift=PATH], [path to installed Apache Thrift [default=/usr/local]])], [
    THRIFT_PREFIX="${withval}"
    THRIFT_INCLUDE="${withval}/include/thrift"
    THRIFT_LIB="${withval}/lib"
    FB303_PREFIX="${withval}/contrib/fb303"
    FB303_INCLUDE="${withval}/contrib/fb303/include/thrift"
    FB303_LIB="${withval}/contrib/fb303/lib"
    AC_MSG_RESULT("${withval}")
  ], [
    THRIFT_PREFIX="/usr/local"
    THRIFT_INCLUDE="/usr/local/include"
    THRIFT_LIB="/usr/local/lib"
    FB303_PREFIX="/usr/local"
    FB303_INCLUDE="/usr/local/include"
    FB303_LIB="/usr/local/lib"
    AC_MSG_RESULT(/usr/local)
  ])
  AC_SUBST(THRIFT_PREFIX)
  AC_DEFINE_UNQUOTED([THRIFT_PREFIX], "${THRIFT_PREFIX}", [path to installed Apache Thrift])
  AC_SUBST(THRIFT_INCLUDE)
  AC_SUBST(THRIFT_LIB)
  AC_SUBST(FB303_PREFIX)
  AC_SUBST(FB303_INCLUDE)
  AC_SUBST(FB303_LIB)
  
  # Configure path to Facebook Scribe.
  AC_MSG_CHECKING([for scribe])
  AC_ARG_WITH([scribe], [AC_HELP_STRING([--with-scribe=PATH], [path to installed Facebook Scribe [default=/usr/local]])], [
    SCRIBE_PREFIX="${withval}"
    SCRIBE_INCLUDE="${withval}/include"
    SCRIBE_LIB="${withval}/lib"
    AC_MSG_RESULT("${withval}")
  ], [
    SCRIBE_PREFIX="/usr/local"
    SCRIBE_INCLUDE="/usr/local/include"
    SCRIBE_LIB="/usr/local/lib"
    AC_MSG_RESULT(/usr/local)
  ])
  AC_SUBST(SCRIBE_PREFIX)
  AC_DEFINE_UNQUOTED([SCRIBE_PREFIX], "${SCRIBE_PREFIX}", [path to installed Facebook Scribe])
  AC_SUBST(SCRIBE_INCLUDE)
  AC_SUBST(SCRIBE_LIB)

  LIBS="-L${THRIFT_LIB} -L${FB303_LIB} -L${SCRIBE_LIB} ${defaultlibs}"
  AC_CHECK_LIB([thrift], [_init], [], [AC_MSG_ERROR([couldn't find a suitable libthrift, use --with-thrift=PATH])])
  AC_CHECK_LIB([fb303], [_init], [], [AC_MSG_ERROR([couldn't find a suitable libfb303, use --with-thrift=PATH])])
  AC_CHECK_LIB([scribe], [_init], [], [AC_MSG_ERROR([couldn't find a suitable libscribe, use --with-scribe=PATH])])

  AM_CONDITIONAL([WANT_LOG], true)
  AC_DEFINE([WANT_LOG], 1, [enable Log component])
else
  AM_CONDITIONAL([WANT_LOG], false)
fi

# Configure GCC C++ and LD options.
AC_SUBST([DEFAULT_CXXFLAGS], ["${cxxflags}"])
AC_SUBST([CXXFLAGS], ["${cxxflags}"])
AC_SUBST([LDFLAGS], ["${ldflags}"])
AC_SUBST([DEFAULT_LDFLAGS], ["${ldflags}"])
LIBS="${defaultlibs}"

AC_CONFIG_FILES([Makefile
                 etc/Makefile
                 kernel/Makefile
                 modules/Makefile
                 modules/scheme/Makefile
                 modules/atom/Makefile
                 modules/rss/Makefile
                 modules/js/Makefile
                 modules/json/Makefile
                 modules/scdl/Makefile
                 modules/http/Makefile
                 modules/server/Makefile
                 modules/python/Makefile
                 modules/opencl/Makefile
                 modules/java/Makefile
                 modules/openid/Makefile
                 modules/oauth/Makefile
                 modules/wsgi/Makefile
                 modules/xml/Makefile
                 components/Makefile
                 components/cache/Makefile
                 components/log/Makefile
                 components/chat/Makefile
                 components/constdb/Makefile
                 components/filedb/Makefile
                 components/http/Makefile
                 components/smtp/Makefile
                 components/queue/Makefile
                 components/sqldb/Makefile
                 components/webservice/Makefile
                 hosting/Makefile
                 hosting/server/Makefile
                 samples/Makefile
                 samples/store-scheme/Makefile
                 samples/store-cpp/Makefile
                 samples/store-python/Makefile
                 samples/store-java/Makefile
                 samples/store-gae/Makefile
                 samples/store-sql/Makefile
                 samples/store-constdb/Makefile
                 samples/store-vhost/Makefile
                 samples/store-cluster/Makefile
                 samples/relay-python/Makefile
                 samples/relay-gae/Makefile
                 doc/Makefile
                 doc/Doxyfile
                 macos/Makefile
                 ubuntu/Makefile
                 ])
AC_OUTPUT