configure.ac 5.46 KB
Newer Older
1
AC_INIT([Google C++ Mocking Framework],
2
        [1.1.0],
3
4
5
6
7
8
9
10
11
        [googlemock@googlegroups.com],
        [gmock])

# Provide various options to initialize the Autoconf and configure processes.
AC_PREREQ([2.59])
AC_CONFIG_SRCDIR([./COPYING])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([build-aux/config.h])
AC_CONFIG_FILES([Makefile])
shiqian's avatar
shiqian committed
12
AC_CONFIG_FILES([scripts/gmock-config], [chmod +x scripts/gmock-config])
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

# Initialize Automake with various options. We require at least v1.9, prevent
# pedantic complaints about package files, and enable various distribution
# targets.
AM_INIT_AUTOMAKE([1.9 dist-bzip2 dist-zip foreign subdir-objects])

# Check for programs used in building Google Test.
AC_PROG_CC
AC_PROG_CXX
AC_LANG([C++])
AC_PROG_LIBTOOL

# TODO(chandlerc@google.com): Currently we aren't running the Python tests
# against the interpreter detected by AM_PATH_PYTHON, and so we condition
# HAVE_PYTHON by requiring "python" to be in the PATH, and that interpreter's
# version to be >= 2.3. This will allow the scripts to use a "/usr/bin/env"
# hashbang.
PYTHON=  # We *do not* allow the user to specify a python interpreter
AC_PATH_PROG([PYTHON],[python],[:])
AS_IF([test "$PYTHON" != ":"],
      [AM_PYTHON_CHECK_VERSION([$PYTHON],[2.3],[:],[PYTHON=":"])])
AM_CONDITIONAL([HAVE_PYTHON],[test "$PYTHON" != ":"])

# TODO(chandlerc@google.com) Check for the necessary system headers.

# GoogleMock currently has hard dependencies upon GoogleTest above and beyond
# running its own test suite, so we both provide our own version in
# a subdirectory and provide some logic to use a custom version or a system
# installed version.
AC_ARG_WITH([gtest],
            [AS_HELP_STRING([--with-gtest],
                            [Specifies how to find the gtest package. If no
                            arguments are given, the default behavior, a
                            system installed gtest will be used if present,
                            and an internal version built otherwise. If a
                            path is provided, the gtest built or installed at
                            that prefix will be used.])],
            [],
            [with_gtest=yes])
shiqian's avatar
shiqian committed
52
53
54
55
56
57
AC_ARG_ENABLE([external-gtest],
              [AS_HELP_STRING([--disable-external-gtest],
                              [Disables any detection or use of a system
                              installed or user provided gtest. Any option to
                              '--with-gtest' is ignored. (Default is enabled.)])
              ], [], [enable_external_gtest=yes])
58
AS_IF([test "x$with_gtest" == "xno"],
shiqian's avatar
shiqian committed
59
      [AC_MSG_ERROR([dnl
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Support for GoogleTest was explicitly disabled. Currently GoogleMock has a hard
dependency upon GoogleTest to build, please provide a version, or allow
GoogleMock to use any installed version and fall back upon its internal
version.])])

# Setup various GTEST variables. TODO(chandlerc@google.com): When these are
# used below, they should be used such that any pre-existing values always
# trump values we set them to, so that they can be used to selectively override
# details of the detection process.
AC_ARG_VAR([GTEST_CONFIG],
           [The exact path of Google Test's 'gtest-config' script.])
AC_ARG_VAR([GTEST_CPPFLAGS],
           [C-like preprocessor flags for Google Test.])
AC_ARG_VAR([GTEST_CXXFLAGS],
           [C++ compile flags for Google Test.])
AC_ARG_VAR([GTEST_LDFLAGS],
           [Linker path and option flags for Google Test.])
AC_ARG_VAR([GTEST_LIBS],
           [Library linking flags for Google Test.])
AC_ARG_VAR([GTEST_VERSION],
           [The version of Google Test available.])
HAVE_BUILT_GTEST="no"

83
GTEST_MIN_VERSION="1.3.0"
84

shiqian's avatar
shiqian committed
85
86
87
88
89
90
91
92
AS_IF([test "x${enable_external_gtest}" = "xyes"],
      [# Begin filling in variables as we are able.
      AS_IF([test "x${with_gtest}" != "xyes"],
            [AS_IF([test -x "${with_gtest}/scripts/gtest-config"],
                   [GTEST_CONFIG="${with_gtest}/scripts/gtest-config"],
                   [GTEST_CONFIG="${with_gtest}/bin/gtest-config"])
            AS_IF([test -x "${GTEST_CONFIG}"], [],
                  [AC_MSG_ERROR([dnl
93
Unable to locate either a built or installed Google Test at '${with_gtest}'.])
shiqian's avatar
shiqian committed
94
                  ])])
95

shiqian's avatar
shiqian committed
96
97
98
99
100
101
102
103
      AS_IF([test -x "${GTEST_CONFIG}"], [],
            [AC_PATH_PROG([GTEST_CONFIG], [gtest-config])])
      AS_IF([test -x "${GTEST_CONFIG}"],
            [AC_MSG_CHECKING([for Google Test version >= ${GTEST_MIN_VERSION}])
            AS_IF([${GTEST_CONFIG} --min-version=${GTEST_MIN_VERSION}],
                  [AC_MSG_RESULT([yes])
                  HAVE_BUILT_GTEST="yes"],
                  [AC_MSG_RESULT([no])])])])
104
105
106
107
108
109
110

AS_IF([test "x${HAVE_BUILT_GTEST}" = "xyes"],
      [GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags`
      GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags`
      GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
      GTEST_LIBS=`${GTEST_CONFIG} --libs`
      GTEST_VERSION=`${GTEST_CONFIG} --version`],
shiqian's avatar
shiqian committed
111
      [AC_CONFIG_SUBDIRS([gtest])
shiqian's avatar
shiqian committed
112
113
114
115
      # GTEST_CONFIG needs to be executable both in a Makefile environmont and
      # in a shell script environment, so resolve an absolute path for it here.
      GTEST_CONFIG="`pwd -P`/gtest/scripts/gtest-config"
      GTEST_CPPFLAGS='-I$(top_srcdir)/gtest/include'
shiqian's avatar
shiqian committed
116
117
      GTEST_CXXFLAGS='-g'
      GTEST_LDFLAGS=''
shiqian's avatar
shiqian committed
118
      GTEST_LIBS='$(top_builddir)/gtest/lib/libgtest.la'
shiqian's avatar
shiqian committed
119
      GTEST_VERSION="${GTEST_MIN_VERSION}"])
120
121
122
123
124
125

# TODO(chandlerc@google.com) Check the types, structures, and other compiler
# and architecture characteristics.

# Output the generated files. No further autoconf macros may be used.
AC_OUTPUT