Commit 1d70d3df authored by Stephen Morris's avatar Stephen Morris
Browse files

[2342] Enable MySQL support with flag in configure.ac

parent fdbdac11
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
CXXFLAGS Process this file with autoconf to produce a configure script.
AC_PREREQ([2.59])
AC_INIT(bind10-devel, 20120817, bind10-dev@isc.org)
......@@ -730,6 +729,64 @@ AC_LINK_IFELSE(
)
CPPFLAGS=$CPPFLAGS_SAVED
LIBS=$LIBS_SAVED
#===
# Check for MySql. The path to the mysql_config program is given with
# the --with-mysql-config (default to /usr/bin/mysql-config).
mysql_config="no"
AC_ARG_WITH([mysql-config],
AC_HELP_STRING([--with-mysql-config=PATH],
[specify the path to the mysql_config script]),
[mysql_config="$withval"])
if test "${mysql_config}" = "yes" ; then
MYSQL_CONFIG="/usr/bin/mysql_config"
elif test "${mysql_config}" != "no" ; then
MYSQL_CONFIG="${withval}"
fi
if test "$MYSQL_CONFIG" != "" ; then
if test -d "$MYSQL_CONFIG" ; then
AC_MSG_ERROR([Specified mysql_config program ${MYSQL_CONFIG} is a directory])
fi
if ! test -x "$MYSQL_CONFIG" ; then
AC_MSG_ERROR([--with-mysql-config should point to a mysql_config program])
fi
MYSQL_CPPFLAGS=`$MYSQL_CONFIG --cflags`
MYSQL_LIBS=`$MYSQL_CONFIG --libs`
AC_SUBST(MYSQL_CPPFLAGS)
AC_SUBST(MYSQL_LIBS)
# Check that a simple program using MySQL functions can compile and link.
CPPFLAGS_SAVED="$CPPFLAGS"
LIBS_SAVED="$LIBS"
CPPFLAGS="$MYSQL_CPPFLAGS $CPPFLAGS"
LIBS="$MYSQL_LIBS $LIBS"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <mysql/mysql.h>],
[MYSQL mysql_handle;
(void) mysql_init(&mysql_handle);
])],
[AC_MSG_RESULT([checking for MySQL headers and library... yes])],
[AC_MSG_RESULT([checking for MySQL headers and library... no])
AC_MSG_ERROR([Needs MySQL library])]
)
CPPFLAGS=$CPPFLAGS_SAVED
LIBS=$LIBS_SAVED
# Note that MYSQL is present in the config.h file
AC_DEFINE([HAVE_MYSQL], [1], [MySQL is present])
fi
# ... and at the shell level, so Makefile.am can take action depending on this.
AM_CONDITIONAL(HAVE_MYSQL, test "$MYSQL_CONFIG" != "")
# Check for log4cplus
log4cplus_path="yes"
......@@ -1409,6 +1466,8 @@ dnl includes too
${LOG4CPLUS_LIBS}
SQLite: $SQLITE_CFLAGS
$SQLITE_LIBS
MySQL: $MYSQL_CPPFLAGS
$MYSQL_LIBS
Features:
$enable_features
......
......@@ -2,6 +2,9 @@ SUBDIRS = . tests
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
AM_CPPFLAGS += $(BOOST_INCLUDES)
if HAVE_MYSQL
AM_CPPFLAGS += $(MYSQL_CPPFLAGS)
endif
AM_CXXFLAGS = $(B10_CXXFLAGS)
......@@ -24,7 +27,9 @@ libb10_dhcp___la_SOURCES += iface_mgr_sun.cc
libb10_dhcp___la_SOURCES += lease_mgr.cc lease_mgr.h
libb10_dhcp___la_SOURCES += lease_mgr_factory.cc lease_mgr_factory.h
libb10_dhcp___la_SOURCES += libdhcp++.cc libdhcp++.h
if HAVE_MYSQL
libb10_dhcp___la_SOURCES += mysql_lease_mgr.cc mysql_lease_mgr.h
endif
libb10_dhcp___la_SOURCES += option4_addrlst.cc option4_addrlst.h
libb10_dhcp___la_SOURCES += option6_addrlst.cc option6_addrlst.h
libb10_dhcp___la_SOURCES += option6_iaaddr.cc option6_iaaddr.h
......@@ -33,11 +38,21 @@ libb10_dhcp___la_SOURCES += option.cc option.h
libb10_dhcp___la_SOURCES += pkt4.cc pkt4.h
libb10_dhcp___la_SOURCES += pkt6.cc pkt6.h
libb10_dhcp___la_CXXFLAGS = $(AM_CXXFLAGS)
libb10_dhcp___la_CPPFLAGS = $(AM_CPPFLAGS) $(LOG4CPLUS_INCLUDES)
libb10_dhcp___la_LIBADD = $(top_builddir)/src/lib/asiolink/libb10-asiolink.la
libb10_dhcp___la_LIBADD += $(top_builddir)/src/lib/util/libb10-util.la
libb10_dhcp___la_LDFLAGS = -no-undefined -version-info 2:0:0
if HAVE_MYSQL
libb10_dhcp___la_LDFLAGS += $(MYSQL_LIBS)
endif
libb10_dhcpsrv_la_SOURCES = cfgmgr.cc cfgmgr.h
libb10_dhcpsrv_la_SOURCES += pool.cc pool.h
libb10_dhcpsrv_la_SOURCES += subnet.cc subnet.h
libb10_dhcpsrv_la_SOURCES += triplet.h
libb10_dhcpsrv_la_SOURCES += addr_utilities.cc addr_utilities.h
libb10_dhcpsrv_la_CXXFLAGS = $(AM_CXXFLAGS)
libb10_dhcpsrv_la_CPPFLAGS = $(AM_CPPFLAGS) $(LOG4CPLUS_INCLUDES)
libb10_dhcpsrv_la_LIBADD = $(top_builddir)/src/lib/asiolink/libb10-asiolink.la
......@@ -46,12 +61,6 @@ libb10_dhcpsrv_la_LDFLAGS = -no-undefined -version-info 2:0:0
EXTRA_DIST = README
libb10_dhcp___la_CXXFLAGS = $(AM_CXXFLAGS)
libb10_dhcp___la_CPPFLAGS = $(AM_CPPFLAGS) $(LOG4CPLUS_INCLUDES)
libb10_dhcp___la_LIBADD = $(top_builddir)/src/lib/asiolink/libb10-asiolink.la
libb10_dhcp___la_LIBADD += $(top_builddir)/src/lib/util/libb10-util.la
libb10_dhcp___la_LDFLAGS = -no-undefined -version-info 2:0:0
if USE_CLANGPP
# Disable unused parameter warning caused by some of the
# Boost headers when compiling with clang.
......
......@@ -14,10 +14,6 @@
#include "config.h"
// TEMP
#define HAVE_MYSQL 1
#include <algorithm>
#include <iostream>
#include <iterator>
......@@ -30,7 +26,10 @@
#include <boost/algorithm/string.hpp>
#include <exceptions/exceptions.h>
#include <dhcp/lease_mgr_factory.h>
#ifdef HAVE_MYSQL
#include <dhcp/mysql_lease_mgr.h>
#endif
using namespace std;
......
......@@ -4,6 +4,9 @@ AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/lib/dhcp/tests\"
AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\"
# Temp
AM_CPPFLAGS += -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing
AM_CPPFLAGS += -DUNIV_LINUX
AM_CXXFLAGS = $(B10_CXXFLAGS)
......@@ -30,7 +33,9 @@ libdhcp___unittests_SOURCES += duid_unittest.cc
libdhcp___unittests_SOURCES += iface_mgr_unittest.cc
libdhcp___unittests_SOURCES += lease_mgr_factory_unittest.cc
libdhcp___unittests_SOURCES += lease_mgr_unittest.cc
if HAVE_MYSQL
libdhcp___unittests_SOURCES += mysql_lease_mgr_unittest.cc
endif
libdhcp___unittests_SOURCES += libdhcp++_unittest.cc
libdhcp___unittests_SOURCES += option4_addrlst_unittest.cc
libdhcp___unittests_SOURCES += option6_addrlst_unittest.cc
......@@ -43,6 +48,10 @@ libdhcp___unittests_SOURCES += pkt6_unittest.cc
libdhcp___unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) $(LOG4CPLUS_INCLUDES)
libdhcp___unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
libdhcp___unittests_CXXFLAGS = $(AM_CXXFLAGS)
if HAVE_MYSQL
libdhcp___unittests_CPPFLAGS += $(MYSQL_CPPFLAGS)
libdhcp___unittests_LDFLAGS += $(MYSQL_LIBS)
endif
libdhcpsrv_unittests_SOURCES = run_unittests.cc
libdhcpsrv_unittests_SOURCES += addr_utilities_unittest.cc
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment