configure.ac 7.07 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 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
# Check availability of the Boost System library

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

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(ok)
	  BOOST_SYSTEM_LIB="-l${BOOST_TRY_LIB}"
	  ],[])
	if test "X${BOOST_SYSTEM_LIB}" != X; then
        	break
	fi
done

if test "X${BOOST_SYSTEM_LIB}" = X; then
	AC_MSG_RESULT(not found)
	AC_MSG_ERROR(Unable to link with the boost::system library)
fi

CPPFLAGS="$CPPFLAGS_SAVED"
LIBS="$LIBS_SAVED"
AC_SUBST(BOOST_SYSTEM_LIB)

133
#
134
# Check availability of gtest, which will be used for unit tests.
135
#
136
if test "$gtest_path" != "no"
137
then
138 139
	if test "$gtest_path" != "yes"; then
		GTEST_PATHS=$gtest_path
140 141 142
		if test -x "${gtest_path}/bin/gtest-config" ; then
			GTEST_CONFIG="${gtest_path}/bin/gtest-config"
		fi
143
	else
144
		AC_PATH_PROG([GTEST_CONFIG], [gtest-config])
145
	fi
146 147 148 149 150 151 152 153 154 155
	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"
156
		fi
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
		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
172 173
		AC_MSG_ERROR([Cannot find gtest in: $GTEST_PATHS])
	fi
174
else
175 176 177
	GTEST_INCLUDES=
	GTEST_LDFLAGS=
	GTEST_LDADD=
178
fi
179 180 181 182
AM_CONDITIONAL(HAVE_GTEST, test $gtest_path != "no")
AC_SUBST(GTEST_INCLUDES)
AC_SUBST(GTEST_LDFLAGS)
AC_SUBST(GTEST_LDADD)
183

184
PKG_CHECK_MODULES(SQLITE, sqlite3 >= 3.3.9)
185

186 187 188 189
# Checks for library functions.

AC_CONFIG_FILES([Makefile
                 src/Makefile
190
                 src/bin/Makefile
191
                 src/bin/bind10/Makefile
Jelte Jansen's avatar
Jelte Jansen committed
192
                 src/bin/cmdctl/Makefile
Jeremy C. Reed's avatar
Jeremy C. Reed committed
193
                 src/bin/bindctl/Makefile
Jelte Jansen's avatar
Jelte Jansen committed
194
                 src/bin/cfgmgr/Makefile
195
                 src/bin/host/Makefile
Evan Hunt's avatar
Evan Hunt committed
196
                 src/bin/loadzone/Makefile
197
                 src/bin/msgq/Makefile
198
                 src/bin/auth/Makefile
199
                 src/lib/Makefile
200
                 src/lib/cc/Makefile
Jeremy C. Reed's avatar
Jeremy C. Reed committed
201 202
                 src/lib/python/Makefile
                 src/lib/python/isc/Makefile
Evan Hunt's avatar
Evan Hunt committed
203
                 src/lib/python/isc/auth/Makefile
Jeremy C. Reed's avatar
Jeremy C. Reed committed
204 205 206
                 src/lib/python/isc/cc/Makefile
                 src/lib/python/isc/config/Makefile
                 src/lib/python/isc/Util/Makefile
207
                 src/lib/config/Makefile
Jelte Jansen's avatar
Jelte Jansen committed
208
                 src/lib/dns/Makefile
Jeremy C. Reed's avatar
Jeremy C. Reed committed
209
                 src/lib/dns/tests/Makefile
210
                 src/lib/exceptions/Makefile
211
                 src/lib/auth/Makefile
Jelte Jansen's avatar
Jelte Jansen committed
212
               ])
213
AC_OUTPUT([src/bin/cfgmgr/b10-cfgmgr.py
214
           src/bin/cmdctl/cmdctl.py
215
           src/bin/cmdctl/run_b10-cmdctl.sh
216
           src/bin/cmdctl/unittest/cmdctl_test
217
           src/bin/bind10/bind10.py
Shane Kerr's avatar
Shane Kerr committed
218
           src/bin/bind10/bind10_test
219
           src/bin/bind10/run_bind10.sh
220
           src/bin/bindctl/bindctl
221
           src/bin/bindctl/unittest/bindctl_test
Evan Hunt's avatar
Evan Hunt committed
222 223
           src/bin/loadzone/run_loadzone
           src/bin/loadzone/b10-loadzone.py
224
           src/bin/msgq/msgq.py
225
           src/bin/msgq/msgq_test
226
           src/bin/msgq/run_msgq.sh
227
           src/bin/auth/config.h
Jeremy C. Reed's avatar
Jeremy C. Reed committed
228 229 230 231
           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
232
          ], [
233 234
           chmod +x src/bin/cmdctl/run_b10-cmdctl.sh
           chmod +x src/bin/bind10/run_bind10.sh
235 236
           chmod +x src/bin/cmdctl/unittest/cmdctl_test
           chmod +x src/bin/bindctl/unittest/bindctl_test
237
           chmod +x src/bin/bindctl/bindctl
Evan Hunt's avatar
Evan Hunt committed
238
           chmod +x src/bin/loadzone/run_loadzone
239
           chmod +x src/bin/msgq/run_msgq.sh
Michael Graff's avatar
Michael Graff committed
240
           chmod +x src/bin/msgq/msgq_test
Jeremy C. Reed's avatar
Jeremy C. Reed committed
241 242
	   chmod +x src/lib/dns/gen-rdatacode.py
	   chmod +x src/lib/dns/tests/testdata/gen-wiredata.py
243
          ])
244
AC_OUTPUT