blob: 05b90c4b9823e3a97c6bf42cebc0d1618fd6042e [file] [log] [blame]
zhanyong.wan5905ba02010-02-24 17:21:37 +00001m4_include(gtest/m4/acx_pthread.m4)
2
shiqiane35fdd92008-12-10 05:08:54 +00003AC_INIT([Google C++ Mocking Framework],
zhanyong.wan79d82b62011-02-24 07:31:48 +00004 [1.6.0],
shiqiane35fdd92008-12-10 05:08:54 +00005 [googlemock@googlegroups.com],
6 [gmock])
7
8# Provide various options to initialize the Autoconf and configure processes.
9AC_PREREQ([2.59])
vladlosev5aa8dd92011-09-09 07:06:32 +000010AC_CONFIG_SRCDIR([./LICENSE])
shiqiane35fdd92008-12-10 05:08:54 +000011AC_CONFIG_AUX_DIR([build-aux])
12AC_CONFIG_HEADERS([build-aux/config.h])
13AC_CONFIG_FILES([Makefile])
shiqian281b1d22008-12-11 00:13:55 +000014AC_CONFIG_FILES([scripts/gmock-config], [chmod +x scripts/gmock-config])
shiqiane35fdd92008-12-10 05:08:54 +000015
16# Initialize Automake with various options. We require at least v1.9, prevent
17# pedantic complaints about package files, and enable various distribution
18# targets.
19AM_INIT_AUTOMAKE([1.9 dist-bzip2 dist-zip foreign subdir-objects])
20
21# Check for programs used in building Google Test.
22AC_PROG_CC
23AC_PROG_CXX
24AC_LANG([C++])
25AC_PROG_LIBTOOL
26
27# TODO(chandlerc@google.com): Currently we aren't running the Python tests
28# against the interpreter detected by AM_PATH_PYTHON, and so we condition
29# HAVE_PYTHON by requiring "python" to be in the PATH, and that interpreter's
30# version to be >= 2.3. This will allow the scripts to use a "/usr/bin/env"
31# hashbang.
32PYTHON= # We *do not* allow the user to specify a python interpreter
33AC_PATH_PROG([PYTHON],[python],[:])
34AS_IF([test "$PYTHON" != ":"],
35 [AM_PYTHON_CHECK_VERSION([$PYTHON],[2.3],[:],[PYTHON=":"])])
36AM_CONDITIONAL([HAVE_PYTHON],[test "$PYTHON" != ":"])
37
38# TODO(chandlerc@google.com) Check for the necessary system headers.
39
zhanyong.wan5905ba02010-02-24 17:21:37 +000040# Configure pthreads.
41AC_ARG_WITH([pthreads],
42 [AS_HELP_STRING([--with-pthreads],
43 [use pthreads (default is yes)])],
44 [with_pthreads=$withval],
45 [with_pthreads=check])
46
47have_pthreads=no
48AS_IF([test "x$with_pthreads" != "xno"],
49 [ACX_PTHREAD(
50 [],
51 [AS_IF([test "x$with_pthreads" != "xcheck"],
52 [AC_MSG_FAILURE(
53 [--with-pthreads was specified, but unable to be used])])])
54 have_pthreads="$acx_pthread_ok"])
55AM_CONDITIONAL([HAVE_PTHREADS],[test "x$have_pthreads" == "xyes"])
56AC_SUBST(PTHREAD_CFLAGS)
57AC_SUBST(PTHREAD_LIBS)
58
shiqiane35fdd92008-12-10 05:08:54 +000059# GoogleMock currently has hard dependencies upon GoogleTest above and beyond
60# running its own test suite, so we both provide our own version in
61# a subdirectory and provide some logic to use a custom version or a system
62# installed version.
63AC_ARG_WITH([gtest],
64 [AS_HELP_STRING([--with-gtest],
65 [Specifies how to find the gtest package. If no
66 arguments are given, the default behavior, a
67 system installed gtest will be used if present,
68 and an internal version built otherwise. If a
69 path is provided, the gtest built or installed at
70 that prefix will be used.])],
71 [],
72 [with_gtest=yes])
shiqiana92e4962008-12-10 18:34:33 +000073AC_ARG_ENABLE([external-gtest],
74 [AS_HELP_STRING([--disable-external-gtest],
75 [Disables any detection or use of a system
76 installed or user provided gtest. Any option to
77 '--with-gtest' is ignored. (Default is enabled.)])
78 ], [], [enable_external_gtest=yes])
shiqiane35fdd92008-12-10 05:08:54 +000079AS_IF([test "x$with_gtest" == "xno"],
shiqiana92e4962008-12-10 18:34:33 +000080 [AC_MSG_ERROR([dnl
shiqiane35fdd92008-12-10 05:08:54 +000081Support for GoogleTest was explicitly disabled. Currently GoogleMock has a hard
82dependency upon GoogleTest to build, please provide a version, or allow
83GoogleMock to use any installed version and fall back upon its internal
84version.])])
85
86# Setup various GTEST variables. TODO(chandlerc@google.com): When these are
87# used below, they should be used such that any pre-existing values always
88# trump values we set them to, so that they can be used to selectively override
89# details of the detection process.
90AC_ARG_VAR([GTEST_CONFIG],
91 [The exact path of Google Test's 'gtest-config' script.])
92AC_ARG_VAR([GTEST_CPPFLAGS],
93 [C-like preprocessor flags for Google Test.])
94AC_ARG_VAR([GTEST_CXXFLAGS],
95 [C++ compile flags for Google Test.])
96AC_ARG_VAR([GTEST_LDFLAGS],
97 [Linker path and option flags for Google Test.])
98AC_ARG_VAR([GTEST_LIBS],
99 [Library linking flags for Google Test.])
100AC_ARG_VAR([GTEST_VERSION],
101 [The version of Google Test available.])
102HAVE_BUILT_GTEST="no"
103
zhanyong.wan79d82b62011-02-24 07:31:48 +0000104GTEST_MIN_VERSION="1.6.0"
shiqiane35fdd92008-12-10 05:08:54 +0000105
shiqiana92e4962008-12-10 18:34:33 +0000106AS_IF([test "x${enable_external_gtest}" = "xyes"],
107 [# Begin filling in variables as we are able.
108 AS_IF([test "x${with_gtest}" != "xyes"],
109 [AS_IF([test -x "${with_gtest}/scripts/gtest-config"],
110 [GTEST_CONFIG="${with_gtest}/scripts/gtest-config"],
111 [GTEST_CONFIG="${with_gtest}/bin/gtest-config"])
112 AS_IF([test -x "${GTEST_CONFIG}"], [],
113 [AC_MSG_ERROR([dnl
shiqiane35fdd92008-12-10 05:08:54 +0000114Unable to locate either a built or installed Google Test at '${with_gtest}'.])
shiqiana92e4962008-12-10 18:34:33 +0000115 ])])
shiqiane35fdd92008-12-10 05:08:54 +0000116
shiqiana92e4962008-12-10 18:34:33 +0000117 AS_IF([test -x "${GTEST_CONFIG}"], [],
118 [AC_PATH_PROG([GTEST_CONFIG], [gtest-config])])
119 AS_IF([test -x "${GTEST_CONFIG}"],
120 [AC_MSG_CHECKING([for Google Test version >= ${GTEST_MIN_VERSION}])
121 AS_IF([${GTEST_CONFIG} --min-version=${GTEST_MIN_VERSION}],
122 [AC_MSG_RESULT([yes])
123 HAVE_BUILT_GTEST="yes"],
124 [AC_MSG_RESULT([no])])])])
shiqiane35fdd92008-12-10 05:08:54 +0000125
shiqiane35fdd92008-12-10 05:08:54 +0000126AS_IF([test "x${HAVE_BUILT_GTEST}" = "xyes"],
127 [GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags`
128 GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags`
129 GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
130 GTEST_LIBS=`${GTEST_CONFIG} --libs`
131 GTEST_VERSION=`${GTEST_CONFIG} --version`],
shiqiana92e4962008-12-10 18:34:33 +0000132 [AC_CONFIG_SUBDIRS([gtest])
shiqian281b1d22008-12-11 00:13:55 +0000133 # GTEST_CONFIG needs to be executable both in a Makefile environmont and
134 # in a shell script environment, so resolve an absolute path for it here.
135 GTEST_CONFIG="`pwd -P`/gtest/scripts/gtest-config"
136 GTEST_CPPFLAGS='-I$(top_srcdir)/gtest/include'
shiqiana92e4962008-12-10 18:34:33 +0000137 GTEST_CXXFLAGS='-g'
138 GTEST_LDFLAGS=''
shiqian281b1d22008-12-11 00:13:55 +0000139 GTEST_LIBS='$(top_builddir)/gtest/lib/libgtest.la'
shiqiana92e4962008-12-10 18:34:33 +0000140 GTEST_VERSION="${GTEST_MIN_VERSION}"])
shiqiane35fdd92008-12-10 05:08:54 +0000141
142# TODO(chandlerc@google.com) Check the types, structures, and other compiler
143# and architecture characteristics.
144
145# Output the generated files. No further autoconf macros may be used.
146AC_OUTPUT