configure.ac 5.28 KB
Newer Older
1 2 3 4 5
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.69])
AC_INIT([sds-keyval], [0.1], [robl@mcs.anl.gov])
Rob Latham's avatar
Rob Latham committed
6
AM_INIT_AUTOMAKE([1.13.4 -Wall -Werror foreign subdir-objects silent-rules])
7 8 9
AM_SILENT_RULES([yes])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([src/sds-keyval.h])
Rob Latham's avatar
Rob Latham committed
10
AC_CONFIG_HEADERS([src/kv-config.h])
11 12 13 14 15 16 17
LT_PREREQ([2.2])
# LT_INIT needs to know about AR
AM_PROG_AR
LT_INIT([dlopen])

# Checks for programs.
AC_PROG_CC
18 19
# subdir objects needs a bit of help
AM_PROG_CC_C_O
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
AC_PROG_CXX
AC_PROG_INSTALL

# Checks for libraries.
# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_INT64_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T

# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC

Shane Snyder's avatar
Shane Snyder committed
36
AX_CXX_COMPILE_STDCXX(11, noext, mandatory)
37

38 39 40 41 42 43
#pkg-config and libraries supporting that
PKG_PROG_PKG_CONFIG
if test "x$PKG_CONFIG" == "x"; then
   AC_MSG_ERROR([Could not find pkg-config utility!])
fi

44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
# coreutils checks for OSX
AC_ARG_VAR([TIMEOUT], timeout program)
AC_ARG_VAR([MKTEMP], mktemp program)

if test -z "$TIMEOUT" ; then
    AC_CHECK_PROGS(TIMEOUT, [timeout gtimeout])
    if test -z "$TIMEOUT" ; then
        AC_MSG_ERROR([Could not find timeout command (can optionally provide via the TIMEOUT variable)])
    fi
else
    AC_SUBST([TIMEOUT], ["$TIMEOUT"])
fi

if test -z "$MKTEMP" ; then
    AC_CHECK_PROGS(MKTEMP, [mktemp gmktemp])
    if test -z "$MKTEMP" ; then
        AC_MSG_ERROR([Could not find mktemp command (can optionally provide via the MKTEMP variable)])
    fi
else
    AC_SUBST([MKTEMP], ["$MKTEMP"])
fi

66 67 68 69 70 71
PKG_CHECK_MODULES([MARGO],[margo],[],
      AC_MSG_ERROR([Could not find working margo installation!]) )
LIBS="$MARGO_LIBS $LIBS"
CPPFLAGS="$MARGO_CFLAGS $CPPFLAGS"
CFLAGS="$MARGO_CFLAGS $CFLAGS"

Matthieu Dorier's avatar
Matthieu Dorier committed
72 73
SERVER_DEPS_PKG=""

74 75 76
PKG_CHECK_MODULES([SSG], [ssg], [],
		  AC_MSG_ERROR([Could not find ssg]) )
CFLAGS="$SSG_CFLAGS $CFLAGS"
Matthieu Dorier's avatar
Matthieu Dorier committed
77
SERVER_LIBS_PKG="$SSG_LIBS $SERVER_LIBS_PKG"
78 79 80 81

PKG_CHECK_MODULES([CHPLACEMENT], [ch-placement], [],
		  AC_MSG_ERROR([Could not find ch-placement]) )
CFLAGS="$CHPLACEMENT_CFLAGS $CFLAGS"
Matthieu Dorier's avatar
Matthieu Dorier committed
82
SERVER_LIBS_PKG="$CHPLAEMENT_LIBS $SERVER_LIBS_PKG"
83
GROUP_LIBS="$CHPLACEMENT_LIBS $CLIENT_LIBS"
84

Rob Latham's avatar
Rob Latham committed
85 86 87 88 89 90 91
# uncertain what the lowest Boost we need is.
# Ubuntu 14.04 has boost 1.54. Seems like a good starting point
AX_BOOST_BASE([1.54], ,
	      AC_MSG_ERROR([sdskeyval requires Boost but was unable to find it]))
AX_BOOST_SYSTEM
AX_BOOST_FILESYSTEM

Matthieu Dorier's avatar
Matthieu Dorier committed
92
SERVER_LIBS_EXT="$SERVER_LIBS_EXT ${BOOST_LDFLAGS} ${BOOST_FILESYSTEM_LIB} ${BOOST_SYSTEM_LIB}"
Rob Latham's avatar
Rob Latham committed
93

94 95 96 97
# we have three possible backends for our datastore.  If none are selected,
# then nothing will initialize the class and well that doesn't make any sense
# anyway.  Set BwTree as a default option as it's self-contained to the tree.
# Other backends can be selected
98 99

bwtree_backend=yes
100 101 102 103 104 105 106 107
leveldb_backend=no
berkelydb_backend=no

AC_ARG_ENABLE([leveldb],
	      AS_HELP_STRING([--enable-leveldb], [Select "leveldb" as storage
			      backend (default is no)]),
	      [leveldb_backend=${enableval}]
)
108
AC_ARG_ENABLE([bwtree],
109
	     AS_HELP_STRING([--enable-bwtree], [Enable BwTree as server
110 111
			     backend.  (default is no) ]),
	     [bwtree_backend=${enableval}], [bwtree_backend=no]
112 113
)

114 115 116
AC_ARG_WITH([berkeleydb],[AS_HELP_STRING([--with-berkeleydb@<:@=DIR@:>@],
			[location of BerkeleyDB installation])])
if test "x${with_berkeleydb}" != "x" ; then
117
	AC_LANG_PUSH([C++])
118 119 120
	CPPFLAGS="$CPPFLAGS -I${with_berkeleydb}/include"
	CXXFLAGS="$CXXFLAGS -I${with_berkeleydb}/include"
	LIBS="$LIBS -L${with_berkeleydb}/lib/ -ldb_cxx -ldb_stl"
121
	AC_CHECK_HEADERS([db_cxx.h], ,
122
			AC_ERROR("Could not find Berkely DB C++ headers"))
123
	AC_CHECK_HEADERS([dbstl_map.h],,
124
			AC_ERROR("Could not find Berkely DB STL headers"))
125
	AC_DEFINE([USE_BDB], 1, [Use Berkely DB backend])
Matthieu Dorier's avatar
Matthieu Dorier committed
126
	SERVER_LIBS_EXT="${SERVER_LIBS_EXT} -L${with_berkeleydb}/lib -ldb_cxx -ldb_stl"
127
	AC_LANG_POP
128
	berkelydb_backend=yes
129 130 131
fi

if test "x${leveldb_backend}" == xyes ; then
132
        PKG_CHECK_MODULES([LEVELDB],[leveldb],[
Matthieu Dorier's avatar
Matthieu Dorier committed
133
            SERVER_LIBS_PKG="$LEVELDB_LIBS $SERVER_LIBS_PKG"
134 135
            CPPFLAGS="$LEVELDB_CFLAGS $CPPFLAGS"
            CFLAGS="$LEVELDB_CFLAGS $CFLAGS"
Matthieu Dorier's avatar
Matthieu Dorier committed
136
            SERVER_DEPS_PKG="${SERVER_DEPS_PKG} leveldb"
137
            AC_DEFINE([USE_LEVELDB], 1, [use leveldb backend])
138 139 140 141 142
        ], [
            # fall back to conventional tests if no pkgconfig
            AC_CHECK_HEADERS([leveldb/c.h], ,
                             AC_ERROR("Could not find leveldb headers"))
            AC_DEFINE([USE_LEVELDB], 1, [use leveldb backend])
Matthieu Dorier's avatar
Matthieu Dorier committed
143
	    SERVER_LIBS_EXT="${SERVER_LIBS_EXT} -lleveldb"
144
        ])
145 146 147 148
fi

if test "x${bwtree_backend}" == xyes ; then
	AC_DEFINE([USE_BWTREE], 1, [use BwTree backend])
149
	AC_MSG_WARN([BwTree backend is deprecated])
Rob Latham's avatar
Rob Latham committed
150
	CPPFLAGS="-I${srcdir}/src/BwTree/src ${CPPFLAGS}"
151
	CXXFLAGS="-pthread -g -Wall -mcx16 -Wno-invalid-offsetof ${CXXFLAGS}"
152
fi
Rob Latham's avatar
Rob Latham committed
153

154 155 156
AM_CONDITIONAL([BUILD_BDB], [test "x${berkelydb_backend}" == xyes])
AM_CONDITIONAL([BUILD_LEVELDB], [test "x${leveldb_backend}" == xyes])
AM_CONDITIONAL([BUILD_BWTREE], [test "x${bwtree_backend}" == xyes])
157

Matthieu Dorier's avatar
Matthieu Dorier committed
158 159
SERVER_LIBS="$SERVER_LIBS_PKG $SERVER_LIBS_EXT"

160
AC_SUBST(SERVER_LIBS)
Matthieu Dorier's avatar
Matthieu Dorier committed
161 162 163
AC_SUBST(SERVER_LIBS_PKG)
AC_SUBST(SERVER_LIBS_EXT)
AC_SUBST(SERVER_DEPS_PKG)
164
AC_SUBST(GROUP_LIBS)
Matthieu Dorier's avatar
Matthieu Dorier committed
165
AC_CONFIG_FILES([Makefile maint/sdskv-client.pc maint/sdskv-server.pc])
166 167
AC_OUTPUT