blob: daacfdd8c30dc643c44798b5ae34bb270ee22cfe [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])
51AS_IF([test "x$with_gtest" == "xno"],
52 [AC_MSG_ERROR([
53Support for GoogleTest was explicitly disabled. Currently GoogleMock has a hard
54dependency upon GoogleTest to build, please provide a version, or allow
55GoogleMock to use any installed version and fall back upon its internal
56version.])])
57
58# Setup various GTEST variables. TODO(chandlerc@google.com): When these are
59# used below, they should be used such that any pre-existing values always
60# trump values we set them to, so that they can be used to selectively override
61# details of the detection process.
62AC_ARG_VAR([GTEST_CONFIG],
63 [The exact path of Google Test's 'gtest-config' script.])
64AC_ARG_VAR([GTEST_CPPFLAGS],
65 [C-like preprocessor flags for Google Test.])
66AC_ARG_VAR([GTEST_CXXFLAGS],
67 [C++ compile flags for Google Test.])
68AC_ARG_VAR([GTEST_LDFLAGS],
69 [Linker path and option flags for Google Test.])
70AC_ARG_VAR([GTEST_LIBS],
71 [Library linking flags for Google Test.])
72AC_ARG_VAR([GTEST_VERSION],
73 [The version of Google Test available.])
74HAVE_BUILT_GTEST="no"
75
76# TODO(chandlerc@google.com): This is arbitrary, but we will need to introduce
77# some features to the GoogleTest build system to help support GoogleMock, and
78# at that point it will become more meaningful.
79GTEST_MIN_VERSION="1.0.0"
80
81# Begin filling in variables as we are able.
82AS_IF([test "x${with_gtest}" != "xyes"],
83 [AS_IF([test -x "${with_gtest}/scripts/gtest-config"],
84 [GTEST_CONFIG="${with_gtest}/scripts/gtest-config"],
85 [GTEST_CONFIG="${with_gtest}/bin/gtest-config"])
86 AS_IF([test -x "${GTEST_CONFIG}"], [],
87 [AC_MSG_ERROR([
88Unable to locate either a built or installed Google Test at '${with_gtest}'.])
89 ])])
90
91AS_IF([test -x "${GTEST_CONFIG}"], [],
92 [AC_PATH_PROG([GTEST_CONFIG], [gtest-config])])
93AS_IF([test -x "${GTEST_CONFIG}"],
94 [AC_MSG_CHECKING([for Google Test with version >= ${GTEST_MIN_VERSION}])
95 AS_IF([${GTEST_CONFIG} --min-version=${GTEST_MIN_VERSION}],
96 [AC_MSG_RESULT([yes])
97 HAVE_BUILT_GTEST="yes"],
98 [AC_MSG_RESULT([no])])])
99
100# TODO(chandlerc@google.com): Need to add support for passing a custom prefix
101# into the gtest-config script..
102AS_IF([test "x${HAVE_BUILT_GTEST}" = "xyes"],
103 [GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags`
104 GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags`
105 GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
106 GTEST_LIBS=`${GTEST_CONFIG} --libs`
107 GTEST_VERSION=`${GTEST_CONFIG} --version`],
108 [AC_MSG_ERROR([TODO(chandlerc@google.com): Need to add support for
109 building the internal gtest.])])
110
111# TODO(chandlerc@google.com) Check the types, structures, and other compiler
112# and architecture characteristics.
113
114# Output the generated files. No further autoconf macros may be used.
115AC_OUTPUT