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

4
AC_PREREQ([2.59])
5
AC_INIT(bind10, 10.0.0, bind10-bugs@isc.org)
6 7 8 9 10 11 12
AC_CONFIG_SRCDIR(README)
AM_INIT_AUTOMAKE
AC_CONFIG_HEADERS([config.h])

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
13 14
AC_PROG_LIBTOOL

15 16 17 18
# Use C++ language
AC_LANG_CPLUSPLUS
AX_COMPILER_VENDOR

19 20 21
m4_define([_AM_PYTHON_INTERPRETER_LIST], [python python3 python3.1])
AM_PATH_PYTHON([3.1])

22 23
# default compiler warning settings
if test "X$GCC" = "Xyes"; then
24
CXXFLAGS="-g -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare"
25 26 27 28 29 30 31
fi

# produce PIC unless we disable shared libraries. need this for python bindings.
if test $enable_shared != "no" -a "X$GCC" = "Xyes"; then
   CXXFLAGS="$CXXFLAGS -fPIC"
fi

32 33
# Checks for libraries.

34 35 36
AC_SEARCH_LIBS(inet_pton, [nsl])
AC_SEARCH_LIBS(recvfrom, [socket])

37 38 39 40 41 42
# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_TYPE_SIZE_T

43 44 45 46 47 48 49 50 51
AC_MSG_CHECKING(for sa_len in struct sockaddr)
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>],
[struct sockaddr sa; sa.sa_len = 0; return (0);],
        [AC_MSG_RESULT(yes)
        AC_DEFINE(HAVE_SIN_LEN, 1, Define to 1 if sockaddr_in has a sin_len member)],
        AC_MSG_RESULT(no))

52
AC_ARG_WITH(lcov,
53
[  --with-lcov[=PROGRAM]         enable gtest and coverage target using the specified lcov], lcov="$withval", lcov="no")
54

55
AC_ARG_WITH(gtest,
56
[  --with-gtest=PATH       specify a path to gtest header files (PATH/include) and library (PATH/lib)],
57
    gtest_path="$withval", gtest_path="no")
58 59 60 61 62 63


USE_LCOV="no"
if test "$lcov" != "no"; then
	# force gtest if not set
	if test "$gtest_path" = "no"; then
64 65
#		AC_MSG_ERROR("lcov needs gtest for test coverage report")
		AC_MSG_NOTICE([gtest support is now enabled, because used by coverage tests])
66 67 68
		gtest_path="yes"
	fi
	if test "$lcov" != "yes"; then
69
		LCOV=$lcov
70
	else
71
		AC_PATH_PROG([LCOV], [lcov])
72
	fi
73 74 75 76
	if test -x "${LCOV}"; then
		USE_LCOV="yes"
	else
		AC_MSG_ERROR([Cannot find lcov.])
77 78 79 80 81 82
	fi
	# is genhtml always in the same directory?
	GENHTML=`echo "$LCOV" | sed s/lcov$/genhtml/`
	if test ! -x $GENHTML; then
		AC_MSG_ERROR([genhtml not found, needed for lcov])
	fi
83
	# GCC specific?
84
	CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage"
85
	LIBS=" $LIBS -lgcov"
86 87 88 89 90 91 92
	AC_SUBST(CPPFLAGS)
	AC_SUBST(LIBS)
	AC_SUBST(LCOV)
	AC_SUBST(GENHTML)
fi
AC_SUBST(USE_LCOV)

93 94 95 96 97
# Check availability of the Boost System library

AC_MSG_CHECKING([for boost::system library])
AC_ARG_WITH([boostlib],
AC_HELP_STRING([--with-boostlib=PATH],
98 99 100
  [specify a path to boost libraries if it is not automatically found, or "no" to disable it]),
  [boostlib_path="$withval"], [boostlib_path="auto"])
if test "$boostlib_path" != "no" -a "$boostlib_path" != "auto"; then
101 102 103
	BOOST_LDFLAGS="-L$boostlib_path"
fi

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
if test "$boostlib_path" != "no"; then
	LDFLAGS_SAVED="$LDFLAGS"
	LIBS_SAVED="$LIBS"
	CPPFLAGS_SAVED="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS -Iext"

	for BOOST_TRY_LIB in boost_system boost_system-mt; do
		LDFLAGS="$LDFLAGS_SAVED ${BOOST_LDFLAGS}"
		LIBS="$LIBS_SAVED -l${BOOST_TRY_LIB}"
		AC_TRY_LINK([#include <boost/system/error_code.hpp>],
			[ boost::system::error_code error_code;
			std::string message(error_code.message());
			return 0; ],
			[ AC_MSG_RESULT(yes)
			BOOST_SYSTEM_LIB="-l${BOOST_TRY_LIB}"
			],[])
		if test "X${BOOST_SYSTEM_LIB}" != X; then
        		break
		fi
	done

	LDFLAGS="$LDFLAGS_SAVED"
	CPPFLAGS="$CPPFLAGS_SAVED"
	LIBS="$LIBS_SAVED"
fi
129 130

if test "X${BOOST_SYSTEM_LIB}" = X; then
131
	AC_MSG_RESULT(no)
132 133
else
	AC_DEFINE(HAVE_BOOSTLIB, 1, Define to 1 if boost libraries are available)
134 135
fi

136 137
AM_CONDITIONAL(HAVE_BOOSTLIB, test "X${BOOST_SYSTEM_LIB}" != X)
AC_SUBST(BOOST_LDFLAGS)
138 139
AC_SUBST(BOOST_SYSTEM_LIB)

140
#
141
# Check availability of gtest, which will be used for unit tests.
142
#
143
if test "$gtest_path" != "no"
144
then
145 146
	if test "$gtest_path" != "yes"; then
		GTEST_PATHS=$gtest_path
147 148 149
		if test -x "${gtest_path}/bin/gtest-config" ; then
			GTEST_CONFIG="${gtest_path}/bin/gtest-config"
		fi
150
	else
151
		AC_PATH_PROG([GTEST_CONFIG], [gtest-config])
152
	fi
153 154 155 156 157 158 159 160 161 162
	if test -x "${GTEST_CONFIG}" ; then :
		# using cppflags instead of cxxflags
		GTEST_INCLUDES=`${GTEST_CONFIG} --cppflags`
		GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
		GTEST_LDADD=`${GTEST_CONFIG} --libs`
		GTEST_FOUND="true"
	else
		AC_MSG_WARN([Unable to locate Google Test gtest-config.])
		if test -z "${GTEST_PATHS}" ; then
			GTEST_PATHS="/usr /usr/local"
163
		fi
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
		GTEST_FOUND="false"
	fi
	if test "${GTEST_FOUND}" != "true"; then
		GTEST_FOUND="false"
		for dir in $GTEST_PATHS; do
			if test -f "$dir/include/gtest/gtest.h"; then
				GTEST_INCLUDES="-I$dir/include"
				GTEST_LDFLAGS="-L$dir/lib"
				GTEST_LDADD="-lgtest"
				GTEST_FOUND="true"
				break
			fi
		done
	fi
	if test "${GTEST_FOUND}" != "true"; then
179 180
		AC_MSG_ERROR([Cannot find gtest in: $GTEST_PATHS])
	fi
181
else
182 183 184
	GTEST_INCLUDES=
	GTEST_LDFLAGS=
	GTEST_LDADD=
185
fi
186 187 188 189
AM_CONDITIONAL(HAVE_GTEST, test $gtest_path != "no")
AC_SUBST(GTEST_INCLUDES)
AC_SUBST(GTEST_LDFLAGS)
AC_SUBST(GTEST_LDADD)
190

191
PKG_CHECK_MODULES(SQLITE, sqlite3 >= 3.3.9)
192

193 194 195 196
# Checks for library functions.

AC_CONFIG_FILES([Makefile
                 src/Makefile
197
                 src/bin/Makefile
198
                 src/bin/bind10/Makefile
Jelte Jansen's avatar
Jelte Jansen committed
199
                 src/bin/cmdctl/Makefile
Jeremy C. Reed's avatar
Jeremy C. Reed committed
200
                 src/bin/bindctl/Makefile
Jelte Jansen's avatar
Jelte Jansen committed
201
                 src/bin/cfgmgr/Makefile
202
                 src/bin/host/Makefile
Evan Hunt's avatar
Evan Hunt committed
203
                 src/bin/loadzone/Makefile
204
                 src/bin/msgq/Makefile
205
                 src/bin/auth/Makefile
Likun Zhang's avatar
Likun Zhang committed
206
                 src/bin/xfrin/Makefile
207
                 src/lib/Makefile
208
                 src/lib/cc/Makefile
Jeremy C. Reed's avatar
Jeremy C. Reed committed
209 210
                 src/lib/python/Makefile
                 src/lib/python/isc/Makefile
Evan Hunt's avatar
Evan Hunt committed
211
                 src/lib/python/isc/auth/Makefile
Jeremy C. Reed's avatar
Jeremy C. Reed committed
212 213 214
                 src/lib/python/isc/cc/Makefile
                 src/lib/python/isc/config/Makefile
                 src/lib/python/isc/Util/Makefile
215
                 src/lib/config/Makefile
Jelte Jansen's avatar
Jelte Jansen committed
216
                 src/lib/dns/Makefile
Jeremy C. Reed's avatar
Jeremy C. Reed committed
217
                 src/lib/dns/tests/Makefile
218
                 src/lib/exceptions/Makefile
219
                 src/lib/auth/Makefile
Jelte Jansen's avatar
Jelte Jansen committed
220
               ])
221
AC_OUTPUT([src/bin/cfgmgr/b10-cfgmgr.py
222
           src/bin/cmdctl/cmdctl.py
223
           src/bin/cmdctl/run_b10-cmdctl.sh
224
           src/bin/cmdctl/unittest/cmdctl_test
Likun Zhang's avatar
Likun Zhang committed
225 226 227
           src/bin/xfrin/unittest/xfrin_test
           src/bin/xfrin/xfrin.py
           src/bin/xfrin/run_b10-xfrin.sh
228
           src/bin/bind10/bind10.py
229
           src/bin/bind10/tests/bind10_test
230
           src/bin/bind10/run_bind10.sh
231
           src/bin/bindctl/bindctl
232
           src/bin/bindctl/unittest/bindctl_test
Evan Hunt's avatar
Evan Hunt committed
233 234
           src/bin/loadzone/run_loadzone
           src/bin/loadzone/b10-loadzone.py
235
           src/bin/msgq/msgq.py
236
           src/bin/msgq/msgq_test
237
           src/bin/msgq/run_msgq.sh
238
           src/bin/auth/spec_config.h
Jeremy C. Reed's avatar
Jeremy C. Reed committed
239 240 241 242
           src/lib/config/data_def_unittests_config.h
           src/lib/python/isc/config/unittests/config_test
           src/lib/dns/gen-rdatacode.py
           src/lib/dns/tests/testdata/gen-wiredata.py
243
          ], [
244
           chmod +x src/bin/cmdctl/run_b10-cmdctl.sh
Likun Zhang's avatar
Likun Zhang committed
245
           chmod +x src/bin/xfrin/run_b10-xfrin.sh
246
           chmod +x src/bin/bind10/run_bind10.sh
247
           chmod +x src/bin/cmdctl/unittest/cmdctl_test
Likun Zhang's avatar
Likun Zhang committed
248
           chmod +x src/bin/xfrin/unittest/xfrin_test
249
           chmod +x src/bin/bindctl/unittest/bindctl_test
250
           chmod +x src/bin/bindctl/bindctl
Evan Hunt's avatar
Evan Hunt committed
251
           chmod +x src/bin/loadzone/run_loadzone
252
           chmod +x src/bin/msgq/run_msgq.sh
Michael Graff's avatar
Michael Graff committed
253
           chmod +x src/bin/msgq/msgq_test
Jeremy C. Reed's avatar
Jeremy C. Reed committed
254 255
	   chmod +x src/lib/dns/gen-rdatacode.py
	   chmod +x src/lib/dns/tests/testdata/gen-wiredata.py
256
          ])
257
AC_OUTPUT