blob: 65a48b4a316d03a689d48e9f71c01c0d701fd89c [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])
shiqian281b1d22008-12-11 00:13:55 +000012AC_CONFIG_FILES([scripts/gmock-config], [chmod +x scripts/gmock-config])
shiqiane35fdd92008-12-10 05:08:54 +000013
14# Initialize Automake with various options. We require at least v1.9, prevent
15# pedantic complaints about package files, and enable various distribution
16# targets.
17AM_INIT_AUTOMAKE([1.9 dist-bzip2 dist-zip foreign subdir-objects])
18
19# Check for programs used in building Google Test.
20AC_PROG_CC
21AC_PROG_CXX
22AC_LANG([C++])
23AC_PROG_LIBTOOL
24
25# TODO(chandlerc@google.com): Currently we aren't running the Python tests
26# against the interpreter detected by AM_PATH_PYTHON, and so we condition
27# HAVE_PYTHON by requiring "python" to be in the PATH, and that interpreter's
28# version to be >= 2.3. This will allow the scripts to use a "/usr/bin/env"
29# hashbang.
30PYTHON= # We *do not* allow the user to specify a python interpreter
31AC_PATH_PROG([PYTHON],[python],[:])
32AS_IF([test "$PYTHON" != ":"],
33 [AM_PYTHON_CHECK_VERSION([$PYTHON],[2.3],[:],[PYTHON=":"])])
34AM_CONDITIONAL([HAVE_PYTHON],[test "$PYTHON" != ":"])
35
36# TODO(chandlerc@google.com) Check for the necessary system headers.
37
38# GoogleMock currently has hard dependencies upon GoogleTest above and beyond
39# running its own test suite, so we both provide our own version in
40# a subdirectory and provide some logic to use a custom version or a system
41# installed version.
42AC_ARG_WITH([gtest],
43 [AS_HELP_STRING([--with-gtest],
44 [Specifies how to find the gtest package. If no
45 arguments are given, the default behavior, a
46 system installed gtest will be used if present,
47 and an internal version built otherwise. If a
48 path is provided, the gtest built or installed at
49 that prefix will be used.])],
50 [],
51 [with_gtest=yes])
shiqiana92e4962008-12-10 18:34:33 +000052AC_ARG_ENABLE([external-gtest],
53 [AS_HELP_STRING([--disable-external-gtest],
54 [Disables any detection or use of a system
55 installed or user provided gtest. Any option to
56 '--with-gtest' is ignored. (Default is enabled.)])
57 ], [], [enable_external_gtest=yes])
shiqiane35fdd92008-12-10 05:08:54 +000058AS_IF([test "x$with_gtest" == "xno"],
shiqiana92e4962008-12-10 18:34:33 +000059 [AC_MSG_ERROR([dnl
shiqiane35fdd92008-12-10 05:08:54 +000060Support for GoogleTest was explicitly disabled. Currently GoogleMock has a hard
61dependency upon GoogleTest to build, please provide a version, or allow
62GoogleMock to use any installed version and fall back upon its internal
63version.])])
64
65# Setup various GTEST variables. TODO(chandlerc@google.com): When these are
66# used below, they should be used such that any pre-existing values always
67# trump values we set them to, so that they can be used to selectively override
68# details of the detection process.
69AC_ARG_VAR([GTEST_CONFIG],
70 [The exact path of Google Test's 'gtest-config' script.])
71AC_ARG_VAR([GTEST_CPPFLAGS],
72 [C-like preprocessor flags for Google Test.])
73AC_ARG_VAR([GTEST_CXXFLAGS],
74 [C++ compile flags for Google Test.])
75AC_ARG_VAR([GTEST_LDFLAGS],
76 [Linker path and option flags for Google Test.])
77AC_ARG_VAR([GTEST_LIBS],
78 [Library linking flags for Google Test.])
79AC_ARG_VAR([GTEST_VERSION],
80 [The version of Google Test available.])
81HAVE_BUILT_GTEST="no"
82
shiqian281b1d22008-12-11 00:13:55 +000083GTEST_MIN_VERSION="1.2.1"
shiqiane35fdd92008-12-10 05:08:54 +000084
shiqiana92e4962008-12-10 18:34:33 +000085AS_IF([test "x${enable_external_gtest}" = "xyes"],
86 [# Begin filling in variables as we are able.
87 AS_IF([test "x${with_gtest}" != "xyes"],
88 [AS_IF([test -x "${with_gtest}/scripts/gtest-config"],
89 [GTEST_CONFIG="${with_gtest}/scripts/gtest-config"],
90 [GTEST_CONFIG="${with_gtest}/bin/gtest-config"])
91 AS_IF([test -x "${GTEST_CONFIG}"], [],
92 [AC_MSG_ERROR([dnl
shiqiane35fdd92008-12-10 05:08:54 +000093Unable to locate either a built or installed Google Test at '${with_gtest}'.])
shiqiana92e4962008-12-10 18:34:33 +000094 ])])
shiqiane35fdd92008-12-10 05:08:54 +000095
shiqiana92e4962008-12-10 18:34:33 +000096 AS_IF([test -x "${GTEST_CONFIG}"], [],
97 [AC_PATH_PROG([GTEST_CONFIG], [gtest-config])])
98 AS_IF([test -x "${GTEST_CONFIG}"],
99 [AC_MSG_CHECKING([for Google Test version >= ${GTEST_MIN_VERSION}])
100 AS_IF([${GTEST_CONFIG} --min-version=${GTEST_MIN_VERSION}],
101 [AC_MSG_RESULT([yes])
102 HAVE_BUILT_GTEST="yes"],
103 [AC_MSG_RESULT([no])])])])
shiqiane35fdd92008-12-10 05:08:54 +0000104
shiqiane35fdd92008-12-10 05:08:54 +0000105AS_IF([test "x${HAVE_BUILT_GTEST}" = "xyes"],
106 [GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags`
107 GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags`
108 GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
109 GTEST_LIBS=`${GTEST_CONFIG} --libs`
110 GTEST_VERSION=`${GTEST_CONFIG} --version`],
shiqiana92e4962008-12-10 18:34:33 +0000111 [AC_CONFIG_SUBDIRS([gtest])
shiqian281b1d22008-12-11 00:13:55 +0000112 # GTEST_CONFIG needs to be executable both in a Makefile environmont and
113 # in a shell script environment, so resolve an absolute path for it here.
114 GTEST_CONFIG="`pwd -P`/gtest/scripts/gtest-config"
115 GTEST_CPPFLAGS='-I$(top_srcdir)/gtest/include'
shiqiana92e4962008-12-10 18:34:33 +0000116 GTEST_CXXFLAGS='-g'
117 GTEST_LDFLAGS=''
shiqian281b1d22008-12-11 00:13:55 +0000118 GTEST_LIBS='$(top_builddir)/gtest/lib/libgtest.la'
shiqiana92e4962008-12-10 18:34:33 +0000119 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