1#
2# Copyright (c) 2004,2008 Oracle.  All rights reserved.
3#
4# http://www.apache.org/licenses/LICENSE-2.0.txt
5#
6
7AC_INIT(mod_db4.c)
8AC_CONFIG_HEADER(config.h)
9AC_PROG_CXX
10
11AC_LANG_PUSH(C++)
12if test "$cross_compiling" = no; then
13    AC_MSG_CHECKING([that C++ compiler can compile simple program])
14fi
15AC_TRY_RUN([int main() { return 0; }],
16           AC_MSG_RESULT(yes),
17           AC_MSG_RESULT(no);AC_MSG_ERROR([a working C++ compiler is required]))
18
19# Allow user to specify flags
20AC_ARG_WITH(cxxflags,
21        [  --with-cxxflags           Specify additional flags to pass to compiler],
22        [
23                if test "x$withval" != "xno" ; then
24                        CXXFLAGS="$withval $CXXFLAGS"
25                fi
26        ]       
27)
28CXXFLAGS=`echo $CXXFLAGS | sed -e 's/-O2//g;' | sed -e 's/-g//g;'`
29AC_ARG_WITH(ldflags,
30        [  --with-ldflags          Specify additional flags to pass to linker],
31        [
32                if test "x$withval" != "xno" ; then
33                        LDFLAGS="$withval $LDFLAGS"
34                fi
35        ]       
36)
37
38AC_ARG_WITH(libs,
39        [  --with-libs             Specify additional libraries],
40        [
41                if test "x$withval" != "xno" ; then
42                        LIBS="$withval $LIBS"
43                fi
44        ]       
45)
46
47AC_ARG_WITH(mm,
48        [  --with-mm             Specify additional libraries],
49        [
50                if test "x$withval" != "xno" ; then
51                        LIBS="-L$withval/lib $LIBS"
52                        CPPFLAGS="-I$withval/include $CPPFLAGS"
53                fi
54        ]       
55
56)
57
58AC_ARG_WITH(db4,
59        [  --with-db4             Specify additional libraries],
60        [
61                if test "x$withval" != "xno" ; then
62                        LIBS="-L$withval/lib $LIBS"
63                        CPPFLAGS="-I$withval/include $CPPFLAGS"
64                fi
65        ]       
66
67)
68
69AC_ARG_WITH(apxs,
70[  --with-apxs[=FILE]   Build shared Apache module. FILE is optional
71                        pathname to the Apache apxs tool; defaults to
72                        "apxs".],
73[
74  if test "$withval" = "yes"; then
75    withval="apxs"
76  fi
77  APXS="$withval"
78  AC_SUBST(APXS)
79],
80[
81  AC_MSG_ERROR([apxs is required])
82])
83
84LIBS="$LIBS -ldb_cxx"
85
86AC_CACHE_CHECK(for union semun,cv_semun,
87  AC_TRY_COMPILE([
88#include <sys/types.h>
89#include <sys/ipc.h>
90#include <sys/sem.h>
91  ],
92  [union semun x;],
93  [
94    cv_semun=yes
95  ],[
96    cv_semun=no
97  ])
98)
99if test "$cv_semun" = "yes"; then
100  AC_DEFINE(HAVE_SEMUN, 1, [ ])
101else
102  AC_DEFINE(HAVE_SEMUN, 0, [ ])
103fi
104
105AC_SUBST(LDFLAGS)
106AC_SUBST(LIBS)
107AC_SUBST(CPPFLAGS)
108AC_SUBST(CXXFLAGS)
109
110AC_CHECK_LIB(mm, mm_core_create, , [ AC_MSG_ERROR([libmm required]) ])
111
112AC_SUBST(HAVE_SEMUN)
113AC_OUTPUT(Makefile)
114
115