summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/configure.ac
blob: 2c71c557eb89b2726da6e5bba15bed4e3937023d (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
#  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])
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

# 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)
  AC_SUBST([libsuffix],[".dylib"])
  AM_CONDITIONAL([DARWIN], true)
else
  AC_MSG_RESULT(no)
  AC_SUBST([libsuffix],[".so"])
  AM_CONDITIONAL([DARWIN], false)
fi

# Configure path to libcurl includes and lib.
AC_MSG_CHECKING([for libcurl])
AC_ARG_WITH([libcurl], [AC_HELP_STRING([--with-libcurl=PATH], [path to installed libcurl [default=/usr]])], [
  LIBCURL_INCLUDE="${withval}/include"
  LIBCURL_LIB="${withval}/lib"
  AC_MSG_RESULT("${withval}")
], [
  LIBCURL_INCLUDE="/usr/include"
  LIBCURL_LIB="/usr/lib"
  AC_MSG_RESULT(/usr)
])
AC_SUBST(LIBCURL_INCLUDE)
AC_SUBST(LIBCURL_LIB)

# 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)

# Configure path to libmozjs includes and lib.
AC_MSG_CHECKING([for js-include])
xulrunner=`ls /usr/include | grep "xulrunner" | tail -1`
if test "$xulrunner" = ""; then
  xulrunner="xulrunner-1.9.1.8"
fi
AC_ARG_WITH([js-include], [AC_HELP_STRING([--with-js-include=PATH], [path to installed SpiderMonkey include dir
             [default=/usr/include/$xulrunner/unstable]])], [
  JS_INCLUDE="${withval}"
  AC_MSG_RESULT("${withval}")
], [
  JS_INCLUDE="/usr/include/$xulrunner/unstable"
  AC_MSG_RESULT(/usr/include/$xulrunner/unstable)
])
AC_MSG_CHECKING([for js-lib])
AC_ARG_WITH([js-lib], [AC_HELP_STRING([--with-js-lib=PATH], [path to installed SpiderMonkey lib dir [default=/usr/lib/$xulrunner]])], [
  JS_LIB="${withval}"
  AC_MSG_RESULT("${withval}")
], [
  JS_LIB="/usr/lib/$xulrunner"
  AC_MSG_RESULT(/usr/lib/$xulrunner)
])
AC_SUBST(JS_INCLUDE)
AC_SUBST(JS_LIB)

# 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/local/apache2]])], [
  APR_INCLUDE="${withval}/include"
  APR_LIB="${withval}/lib"
  AC_MSG_RESULT("${withval}")
], [
  APR_INCLUDE="/usr/local/apache2/include"
  APR_LIB="/usr/local/apache2/lib"
  AC_MSG_RESULT(/usr/local/apache2/lib)
])
AC_SUBST(APR_INCLUDE)
AC_SUBST(APR_LIB)

AC_MSG_CHECKING([for httpd])
AC_ARG_WITH([httpd], [AC_HELP_STRING([--with-httpd=PATH], [path to installed Apache HTTPD [default=/usr/local/apache2]])], [
  HTTPD_PREFIX="${withval}"
  HTTPD_INCLUDE="${withval}/include"
  AC_MSG_RESULT("${withval}")
], [
  HTTPD_PREFIX="/usr/local/apache2"
  HTTPD_INCLUDE="/usr/local/apache2/include"
  AC_MSG_RESULT(/usr/local/apache2/lib)
])
AC_SUBST(HTTPD_PREFIX)
AC_SUBST(HTTPD_INCLUDE)

# 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)

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

# Initialize default GCC C++ and LD options.
cxxflags=""
ldflags="${LDFLAGS}"
defaultlibs="${LIBS}"

# Configure default includes.
cxxflags="${cxxflags} ${INCLUDES} -I. -I${TUSCANY_SCACPP}/kernel -I${APR_INCLUDE} -I${LIBXML2_INCLUDE} -I${JS_INCLUDE} -I${LIBCURL_INCLUDE}"

# Check for libraries required by all modules and add them to LD options.
AC_MSG_NOTICE([checking for required libraries])
LIBS="-L${APR_LIB} ${defaultlibs}"
AC_CHECK_LIB([apr-1], [apr_pool_initialize], [AC_MSG_NOTICE([found])], [AC_MSG_ERROR([couldn't find a suitable libapr-1, use --with-apr=PATH])])
ldflags="${ldflags} -L${APR_LIB} -R${APR_LIB} -lapr-1 -laprutil-1"

# Check for libraries only required by some modules and add their search path to LD options.  
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])])
LIBS="-L${JS_LIB} ${defaultlibs}"
AC_CHECK_LIB([mozjs], [JS_NewContext], [], [AC_MSG_ERROR([couldn't find a suitable libmozjs, use --with-js-lib=PATH])])
LIBS="-L${LIBXML2_LIB} ${defaultlibs}"
AC_CHECK_LIB([xml2], [xmlInitParser], [], [AC_MSG_ERROR([couldn't find a suitable libxml2, use --with-libxml2=PATH])])
ldflags="${ldflags} -L${LIBCURL_LIB} -R${LIBCURL_LIB} -L${JS_LIB} -R${JS_LIB} -L${LIBXML2_LIB} -R${LIBXML2_LIB}"

# 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])

# 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} -D_DEBUG -O0 -ggdb -g3 -Werror -Wall -Wextra -Wno-ignored-qualifiers -Winit-self -Wmissing-include-dirs -Wcast-qual -Wcast-align -Wwrite-strings -Wpointer-arith -Wconversion -Waddress -Wlogical-op -Wredundant-decls -std=c++0x -fmessage-length=0"
  ldflags="${ldflags} -pg"
  AM_CONDITIONAL([WANT_MAINTAINER_MODE], true)
  AC_DEFINE([WANT_MAINTAINER_MODE], 1, [compile with debugging and compile-time warnings])
else
  cxxflags="${cxxflags} -O3 -std=c++0x -fmessage-length=0"
  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 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 Python 2.6 includes and lib.
AC_MSG_CHECKING([for python])
AC_ARG_WITH([python], [AC_HELP_STRING([--with-python=PATH], [path to installed Python 2.6 [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_SUBST(PYTHON_INCLUDE)
AC_SUBST(PYTHON_LIB)

# Enable Python 2.6 support.
AC_MSG_CHECKING([whether to enable Python support])
AC_ARG_ENABLE(python, [AS_HELP_STRING([--enable-python], [enable Python support [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_python=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_python}" = "true"; then
  LIBS="-L${PYTHON_LIB} ${default_LIBS}"
  AC_CHECK_LIB([python2.6], [Py_Initialize], [], [AC_MSG_ERROR([couldn't find a suitable libpython2.6, 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 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_SUBST(JAVA_INCLUDE)
AC_SUBST(JAVAC)
AC_SUBST(JAR)

# 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
  # Detect most common Java VMs
  if test -f "${JAVA_PREFIX}/jre/lib/i386/libjava.so"; then
    if test -f "${JAVA_PREFIX}/jre/lib/i386/server/libjvm.so"; then
      # Server VM
      AC_MSG_NOTICE([checking for server Java VM])
      JAVA_CHECK_LIB="-L${JAVA_PREFIX}/jre/lib/i386 -R${JAVA_PREFIX}/jre/lib/i386 -L${JAVA_PREFIX}/jre/lib/i386/server -R${JAVA_PREFIX}/jre/lib/i386/server"
      LIBS="${JAVA_CHECK_LIB} ${default_LIBS}"
      AC_CHECK_LIB([java], [JNI_CreateJavaVM], [JAVA_LDFLAGS="${JAVA_CHECK_LIB} -ljava"], [], [-ljvm -lverify])
      if test "${JAVA_LDFLAGS}" != ""; then
        AC_DEFINE([JAVA_SERVER_VM], 1, [Server Java VM])
      fi
    else
      if test -f "${JAVA_PREFIX}/jre/lib/i386/j9vm/libjvm.so"; then
        # J9 VM
        AC_MSG_NOTICE([checking for J9 Java VM])
        JAVA_CHECK_LIB="-L${JAVA_PREFIX}/jre/lib/i386 -R${JAVA_PREFIX}/jre/lib/i386 -L${JAVA_PREFIX}/jre/lib/i386/j9vm -R${JAVA_PREFIX}/jre/lib/i386/j9vm"
        LIBS="${JAVA_CHECK_LIB} ${default_LIBS}"
        AC_CHECK_LIB([java], [JNI_CreateJavaVM], [JAVA_LDFLAGS="${JAVA_CHECK_LIB} -ljava"], [], [-ljvm -ljsig])
        if test "${JAVA_LDFLAGS}" != ""; then
          AC_DEFINE([JAVA_J9_VM], 1, [J9 Java VM])
        fi
      fi
    fi
  else
    if test -f "${JAVA_PREFIX}/jre/bin/default/libharmonyvm.so"; then
      # Apache Harmony VM
      AC_MSG_NOTICE([checking for Apache Harmony Java VM])
      JAVA_CHECK_LIB="-L${JAVA_PREFIX}/jre/bin -R${JAVA_PREFIX}/jre/bin -L${JAVA_PREFIX}/jre/bin/default -R${JAVA_PREFIX}/jre/bin/default"
      LIBS="${JAVA_CHECK_LIB} ${default_LIBS}"
      AC_CHECK_LIB([harmonyvm], [JNI_CreateJavaVM], [JAVA_LDFLAGS="${JAVA_CHECK_LIB} -lharmonyvm"], [], [-lhythr -licuuc -lch ${JAVA_PREFIX}/jre/bin/default/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="-L${JAVA_PREFIX}/jre/lib -R${JAVA_PREFIX}/jre/lib -ljava"
fi
AC_SUBST(JAVA_LDFLAGS)

# 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_SUBST(AXIS2C_INCLUDE)
AC_SUBST(AXIS2C_LIB)

# 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
  LIBS="-L${AXIS2C_LIB} ${default_LIBS}"
  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 Store component.
AC_MSG_CHECKING([whether to enable the Store component])
AC_ARG_ENABLE(store, [AS_HELP_STRING([--enable-store], [enable Store component [default=no]])],
[ case "${enableval}" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    want_store=true
    ;;
  esac ],
[ AC_MSG_RESULT(no)])
if test "${want_store}" = "true"; then
  AM_CONDITIONAL([WANT_STORE], true)
  AC_DEFINE([WANT_STORE], 1, [enable Store component])
else
  AM_CONDITIONAL([WANT_STORE], false)
fi

# Configure path to Apache Qpid/C++ includes and lib.
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_SUBST(QPIDC_INCLUDE)
AC_SUBST(QPIDC_LIB)

# 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
  if test "${want_threads}" != "true"; then
    AC_MSG_ERROR([--enable-queue requires multi-threading, use --enable-threads])
  fi
  LIBS="-L${QPIDC_LIB} ${default_LIBS}"
  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

# 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 source [default=${HOME}/libstrophe]])], [
  LIBSTROPHE_INCLUDE="${withval}"
  LIBSTROPHE_LIB="${withval}"
  AC_MSG_RESULT("${withval}")
], [
  LIBSTROPHE_INCLUDE="${HOME}/libstrophe"
  LIBSTROPHE_LIB="${HOME}/libstrophe"
  AC_MSG_RESULT(${HOME}/libstrophe)
])
AC_SUBST(LIBSTROPHE_INCLUDE)
AC_SUBST(LIBSTROPHE_LIB)

# 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)

# 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
  if test "${want_threads}" != "true"; then
    AC_MSG_ERROR([--enable-chat requires multi-threading, use --enable-threads])
  fi
  LIBS="-L${LIBSTROPHE_LIB} ${default_LIBS}"
  AC_CHECK_LIB([strophe], [xmpp_initialize], [], [AC_MSG_ERROR([couldn't find a suitable libstrophe, use --with-libstrophe=PATH])], [-lexpat -lssl -lresolv])
  AM_CONDITIONAL([WANT_CHAT], true)
  AC_DEFINE([WANT_CHAT], 1, [enable Chat component])

  # Check for Vysper
  AC_CHECK_FILE([${VYSPER_PREFIX}/lib/vysper-core-0.5.jar], [want_vysper=true], [])
  if test "${want_vysper}" = "true"; then
    AM_CONDITIONAL([WANT_VYSPER], true)
  else
    AM_CONDITIONAL([WANT_VYSPER], false)
  fi
else
  AM_CONDITIONAL([WANT_CHAT], false)
  AM_CONDITIONAL([WANT_VYSPER], false)
fi

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

AC_CONFIG_FILES([Makefile
                 kernel/Makefile
                 modules/Makefile
                 modules/scheme/Makefile
                 modules/atom/Makefile
                 modules/json/Makefile
                 modules/scdl/Makefile
                 modules/http/Makefile
                 modules/python/Makefile
                 modules/java/Makefile
                 modules/server/Makefile
                 modules/wsgi/Makefile
                 components/Makefile
                 components/cache/Makefile
                 components/log/Makefile
                 components/chat/Makefile
                 components/queue/Makefile
                 components/store/Makefile
                 components/webservice/Makefile
                 samples/Makefile
                 test/Makefile
                 test/store-scheme/Makefile
                 test/store-cpp/Makefile
                 test/store-python/Makefile
                 test/store-java/Makefile
                 test/store-wsgi/Makefile
                 doc/Makefile
                 doc/Doxyfile
                 ])
AC_OUTPUT