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

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

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_RANLIB

15 16
AC_PROG_LIBTOOL

17 18 19
m4_define([_AM_PYTHON_INTERPRETER_LIST], [python python3 python3.1])
AM_PATH_PYTHON([3.1])

20 21 22 23 24 25 26 27 28 29
# default compiler warning settings
if test "X$GCC" = "Xyes"; then
CXXFLAGS="-g -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare"
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

30 31 32 33 34 35 36 37
# Checks for libraries.

# Checks for header files.

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

38 39 40 41 42 43 44 45 46
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))

47
AC_ARG_WITH(lcov,
48
[  --with-lcov[=PROGRAM]         enable gtest and coverage target using the specified lcov], lcov="$withval", lcov="no")
49

50
AC_ARG_WITH(gtest,
51
[  --with-gtest=PATH       specify a path to gtest header files (PATH/include) and library (PATH/lib)],
52
    gtest_path="$withval", gtest_path="no")
53 54 55 56 57 58


USE_LCOV="no"
if test "$lcov" != "no"; then
	# force gtest if not set
	if test "$gtest_path" = "no"; then
59 60
#		AC_MSG_ERROR("lcov needs gtest for test coverage report")
		AC_MSG_NOTICE([gtest support is now enabled, because used by coverage tests])
61 62 63
		gtest_path="yes"
	fi
	if test "$lcov" != "yes"; then
64
		LCOV=$lcov
65
	else
66
		AC_PATH_PROG([LCOV], [lcov])
67
	fi
68 69 70 71
	if test -x "${LCOV}"; then
		USE_LCOV="yes"
	else
		AC_MSG_ERROR([Cannot find lcov.])
72 73 74 75 76 77
	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
78
	# GCC specific?
79
	CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage"
80
	LIBS=" $LIBS -lgcov"
81 82 83 84 85 86 87 88
	AC_SUBST(CPPFLAGS)
	AC_SUBST(LIBS)
	AC_SUBST(LCOV)
	AC_SUBST(GENHTML)
fi
AC_SUBST(USE_LCOV)

#
89
# Check availability of gtest, which will be used for unit tests.
90
#
91
if test "$gtest_path" != "no"
92
then
93 94
	if test "$gtest_path" != "yes"; then
		GTEST_PATHS=$gtest_path
95 96 97
		if test -x "${gtest_path}/bin/gtest-config" ; then
			GTEST_CONFIG="${gtest_path}/bin/gtest-config"
		fi
98
	else
99
		AC_PATH_PROG([GTEST_CONFIG], [gtest-config])
100
	fi
101 102 103 104 105 106 107 108 109 110
	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"
111
		fi
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
		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
127 128
		AC_MSG_ERROR([Cannot find gtest in: $GTEST_PATHS])
	fi
129
else
130 131 132
	GTEST_INCLUDES=
	GTEST_LDFLAGS=
	GTEST_LDADD=
133
fi
134 135 136 137
AM_CONDITIONAL(HAVE_GTEST, test $gtest_path != "no")
AC_SUBST(GTEST_INCLUDES)
AC_SUBST(GTEST_LDFLAGS)
AC_SUBST(GTEST_LDADD)
138

139 140 141 142
# Checks for library functions.

AC_CONFIG_FILES([Makefile
                 src/Makefile
143
                 src/bin/Makefile
144
                 src/bin/bind10/Makefile
145
                 src/bin/cmd-ctrld/Makefile
Jeremy C. Reed's avatar
Jeremy C. Reed committed
146
                 src/bin/bindctl/Makefile
147
                 src/bin/host/Makefile
148
                 src/bin/msgq/Makefile
149
                 src/bin/parkinglot/Makefile
150
                 src/lib/Makefile
151 152
                 src/lib/cc/Makefile
                 src/lib/cc/cpp/Makefile
153 154
                 src/lib/config/Makefile
                 src/lib/config/cpp/Makefile
Jelte Jansen's avatar
Jelte Jansen committed
155
                 src/lib/dns/Makefile
156
                 src/lib/dns/cpp/Makefile
Jelte Jansen's avatar
Jelte Jansen committed
157
               ])
158
AC_OUTPUT([src/bin/bind-cfgd/bind-cfgd
159
           src/bin/cmd-ctrld/cmd-ctrld
160
           src/bin/bind10/bind10
Shane Kerr's avatar
Shane Kerr committed
161
           src/bin/bind10/bind10_test
162
           src/bin/bindctl/bindctl
163 164
           src/bin/msgq/msgq
           src/bin/msgq/msgq_test
165
           src/bin/parkinglot/config.h
166 167
          ], [
           chmod +x src/bin/bind-cfgd/bind-cfgd
168
           chmod +x src/bin/cmd-ctrld/cmd-ctrld
169
           chmod +x src/bin/bind10/bind10
170
           chmod +x src/bin/bindctl/bindctl
Michael Graff's avatar
Michael Graff committed
171 172
           chmod +x src/bin/msgq/msgq
           chmod +x src/bin/msgq/msgq_test
173
          ])
174
AC_OUTPUT