blob: 60742504cb67a03e1a7ce1d15216a949a85a4b0c [file] [log] [blame]
shiqiane35fdd92008-12-10 05:08:54 +00001AC_INIT([Google C++ Mocking Framework],
2 [1.0.0],
3 [googlemock@googlegroups.com],
4 [gmock])
5
6# Provide various options to initialize the Autoconf and configure processes.
7AC_PREREQ([2.59])
8AC_CONFIG_SRCDIR([./COPYING])
9AC_CONFIG_AUX_DIR([build-aux])
10AC_CONFIG_HEADERS([build-aux/config.h])
11AC_CONFIG_FILES([Makefile])
12
13# Initialize Automake with various options. We require at least v1.9, prevent
14# pedantic complaints about package files, and enable various distribution
15# targets.
16AM_INIT_AUTOMAKE([1.9 dist-bzip2 dist-zip foreign subdir-objects])
17
18# Check for programs used in building Google Test.
19AC_PROG_CC
20AC_PROG_CXX
21AC_LANG([C++])
22AC_PROG_LIBTOOL
23
24# TODO(chandlerc@google.com): Currently we aren't running the Python tests
25# against the interpreter detected by AM_PATH_PYTHON, and so we condition
26# HAVE_PYTHON by requiring "python" to be in the PATH, and that interpreter's
27# version to be >= 2.3. This will allow the scripts to use a "/usr/bin/env"
28# hashbang.
29PYTHON= # We *do not* allow the user to specify a python interpreter
30AC_PATH_PROG([PYTHON],[python],[:])
31AS_IF([test "$PYTHON" != ":"],
32 [AM_PYTHON_CHECK_VERSION([$PYTHON],[2.3],[:],[PYTHON=":"])])
33AM_CONDITIONAL([HAVE_PYTHON],[test "$PYTHON" != ":"])
34
35# TODO(chandlerc@google.com) Check for the necessary system headers.
36
37# GoogleMock currently has hard dependencies upon GoogleTest above and beyond
38# running its own test suite, so we both provide our own version in
39# a subdirectory and provide some logic to use a custom version or a system
40# installed version.
41AC_ARG_WITH([gtest],
42 [AS_HELP_STRING([--with-gtest],
43 [Specifies how to find the gtest package. If no
44 arguments are given, the default behavior, a
45 system installed gtest will be used if present,
46 and an internal version built otherwise. If a
47 path is provided, the gtest built or installed at
48 that prefix will be used.])],
49 [],
50 [with_gtest=yes])
shiqiana92e4962008-12-10 18:34:33 +000051AC_ARG_ENABLE([external-gtest],
52 [AS_HELP_STRING([--disable-external-gtest],
53 [Disables any detection or use of a system
54 installed or user provided gtest. Any option to
55 '--with-gtest' is ignored. (Default is enabled.)])
56 ], [], [enable_external_gtest=yes])
shiqiane35fdd92008-12-10 05:08:54 +000057AS_IF([test "x$with_gtest" == "xno"],
shiqiana92e4962008-12-10 18:34:33 +000058 [AC_MSG_ERROR([dnl
shiqiane35fdd92008-12-10 05:08:54 +000059Support for GoogleTest was explicitly disabled. Currently GoogleMock has a hard
60dependency upon GoogleTest to build, please provide a version, or allow
61GoogleMock to use any installed version and fall back upon its internal
62version.])])
63
64# Setup various GTEST variables. TODO(chandlerc@google.com): When these are
65# used below, they should be used such that any pre-existing values always
66# trump values we set them to, so that they can be used to selectively override
67# details of the detection process.
68AC_ARG_VAR([GTEST_CONFIG],
69 [The exact path of Google Test's 'gtest-config' script.])
70AC_ARG_VAR([GTEST_CPPFLAGS],
71 [C-like preprocessor flags for Google Test.])
72AC_ARG_VAR([GTEST_CXXFLAGS],
73 [C++ compile flags for Google Test.])
74AC_ARG_VAR([GTEST_LDFLAGS],
75 [Linker path and option flags for Google Test.])
76AC_ARG_VAR([GTEST_LIBS],
77 [Library linking flags for Google Test.])
78AC_ARG_VAR([GTEST_VERSION],
79 [The version of Google Test available.])
80HAVE_BUILT_GTEST="no"
81
82# TODO(chandlerc@google.com): This is arbitrary, but we will need to introduce
83# some features to the GoogleTest build system to help support GoogleMock, and
84# at that point it will become more meaningful.
85GTEST_MIN_VERSION="1.0.0"
86
shiqiana92e4962008-12-10 18:34:33 +000087AS_IF([test "x${enable_external_gtest}" = "xyes"],
88 [# Begin filling in variables as we are able.
89 AS_IF([test "x${with_gtest}" != "xyes"],
90 [AS_IF([test -x "${with_gtest}/scripts/gtest-config"],
91 [GTEST_CONFIG="${with_gtest}/scripts/gtest-config"],
92 [GTEST_CONFIG="${with_gtest}/bin/gtest-config"])
93 AS_IF([test -x "${GTEST_CONFIG}"], [],
94 [AC_MSG_ERROR([dnl
shiqiane35fdd92008-12-10 05:08:54 +000095Unable to locate either a built or installed Google Test at '${with_gtest}'.])
shiqiana92e4962008-12-10 18:34:33 +000096 ])])
shiqiane35fdd92008-12-10 05:08:54 +000097
shiqiana92e4962008-12-10 18:34:33 +000098 AS_IF([test -x "${GTEST_CONFIG}"], [],
99 [AC_PATH_PROG([GTEST_CONFIG], [gtest-config])])
100 AS_IF([test -x "${GTEST_CONFIG}"],
101 [AC_MSG_CHECKING([for Google Test version >= ${GTEST_MIN_VERSION}])
102 AS_IF([${GTEST_CONFIG} --min-version=${GTEST_MIN_VERSION}],
103 [AC_MSG_RESULT([yes])
104 HAVE_BUILT_GTEST="yes"],
105 [AC_MSG_RESULT([no])])])])
shiqiane35fdd92008-12-10 05:08:54 +0000106
shiqiane35fdd92008-12-10 05:08:54 +0000107AS_IF([test "x${HAVE_BUILT_GTEST}" = "xyes"],
108 [GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags`
109 GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags`
110 GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
111 GTEST_LIBS=`${GTEST_CONFIG} --libs`
112 GTEST_VERSION=`${GTEST_CONFIG} --version`],
shiqiana92e4962008-12-10 18:34:33 +0000113 [AC_CONFIG_SUBDIRS([gtest])
114 GTEST_CONFIG='$(builddir)/gtest/scripts/gtest-config'
115 GTEST_CPPFLAGS='-I$(srcdir)/gtest/include -I$(srcdir)/gtest'
116 GTEST_CXXFLAGS='-g'
117 GTEST_LDFLAGS=''
118 GTEST_LIBS='$(builddir)/gtest/lib/libgtest.la'
119 GTEST_VERSION="${GTEST_MIN_VERSION}"])
shiqiane35fdd92008-12-10 05:08:54 +0000120
121# TODO(chandlerc@google.com) Check the types, structures, and other compiler
122# and architecture characteristics.
123
124# Output the generated files. No further autoconf macros may be used.
125AC_OUTPUT