Austin Schuh | 889ac43 | 2018-10-29 22:57:02 -0700 | [diff] [blame^] | 1 | m4_include(../googletest/m4/acx_pthread.m4) |
Austin Schuh | 0cbef62 | 2015-09-06 17:34:52 -0700 | [diff] [blame] | 2 | |
| 3 | AC_INIT([Google C++ Mocking Framework], |
Austin Schuh | 889ac43 | 2018-10-29 22:57:02 -0700 | [diff] [blame^] | 4 | [1.8.0], |
Austin Schuh | 0cbef62 | 2015-09-06 17:34:52 -0700 | [diff] [blame] | 5 | [googlemock@googlegroups.com], |
| 6 | [gmock]) |
| 7 | |
| 8 | # Provide various options to initialize the Autoconf and configure processes. |
| 9 | AC_PREREQ([2.59]) |
| 10 | AC_CONFIG_SRCDIR([./LICENSE]) |
| 11 | AC_CONFIG_AUX_DIR([build-aux]) |
| 12 | AC_CONFIG_HEADERS([build-aux/config.h]) |
| 13 | AC_CONFIG_FILES([Makefile]) |
| 14 | AC_CONFIG_FILES([scripts/gmock-config], [chmod +x scripts/gmock-config]) |
| 15 | |
| 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. |
| 19 | AM_INIT_AUTOMAKE([1.9 dist-bzip2 dist-zip foreign subdir-objects]) |
| 20 | |
| 21 | # Check for programs used in building Google Test. |
| 22 | AC_PROG_CC |
| 23 | AC_PROG_CXX |
| 24 | AC_LANG([C++]) |
| 25 | AC_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. |
| 32 | PYTHON= # We *do not* allow the user to specify a python interpreter |
| 33 | AC_PATH_PROG([PYTHON],[python],[:]) |
| 34 | AS_IF([test "$PYTHON" != ":"], |
| 35 | [AM_PYTHON_CHECK_VERSION([$PYTHON],[2.3],[:],[PYTHON=":"])]) |
| 36 | AM_CONDITIONAL([HAVE_PYTHON],[test "$PYTHON" != ":"]) |
| 37 | |
| 38 | # TODO(chandlerc@google.com) Check for the necessary system headers. |
| 39 | |
| 40 | # Configure pthreads. |
| 41 | AC_ARG_WITH([pthreads], |
| 42 | [AS_HELP_STRING([--with-pthreads], |
| 43 | [use pthreads (default is yes)])], |
| 44 | [with_pthreads=$withval], |
| 45 | [with_pthreads=check]) |
| 46 | |
| 47 | have_pthreads=no |
| 48 | AS_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"]) |
| 55 | AM_CONDITIONAL([HAVE_PTHREADS],[test "x$have_pthreads" == "xyes"]) |
| 56 | AC_SUBST(PTHREAD_CFLAGS) |
| 57 | AC_SUBST(PTHREAD_LIBS) |
| 58 | |
| 59 | # 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. |
| 63 | AC_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]) |
| 73 | AC_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]) |
| 79 | AS_IF([test "x$with_gtest" == "xno"], |
| 80 | [AC_MSG_ERROR([dnl |
| 81 | Support for GoogleTest was explicitly disabled. Currently GoogleMock has a hard |
| 82 | dependency upon GoogleTest to build, please provide a version, or allow |
| 83 | GoogleMock to use any installed version and fall back upon its internal |
| 84 | version.])]) |
| 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. |
| 90 | AC_ARG_VAR([GTEST_CONFIG], |
| 91 | [The exact path of Google Test's 'gtest-config' script.]) |
| 92 | AC_ARG_VAR([GTEST_CPPFLAGS], |
| 93 | [C-like preprocessor flags for Google Test.]) |
| 94 | AC_ARG_VAR([GTEST_CXXFLAGS], |
| 95 | [C++ compile flags for Google Test.]) |
| 96 | AC_ARG_VAR([GTEST_LDFLAGS], |
| 97 | [Linker path and option flags for Google Test.]) |
| 98 | AC_ARG_VAR([GTEST_LIBS], |
| 99 | [Library linking flags for Google Test.]) |
| 100 | AC_ARG_VAR([GTEST_VERSION], |
| 101 | [The version of Google Test available.]) |
| 102 | HAVE_BUILT_GTEST="no" |
| 103 | |
Austin Schuh | 889ac43 | 2018-10-29 22:57:02 -0700 | [diff] [blame^] | 104 | GTEST_MIN_VERSION="1.8.0" |
Austin Schuh | 0cbef62 | 2015-09-06 17:34:52 -0700 | [diff] [blame] | 105 | |
| 106 | AS_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 |
| 114 | Unable to locate either a built or installed Google Test at '${with_gtest}'.]) |
| 115 | ])]) |
| 116 | |
| 117 | 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])])])]) |
| 125 | |
| 126 | AS_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`], |
Austin Schuh | 889ac43 | 2018-10-29 22:57:02 -0700 | [diff] [blame^] | 132 | [ |
| 133 | # GTEST_CONFIG needs to be executable both in a Makefile environment and |
Austin Schuh | 0cbef62 | 2015-09-06 17:34:52 -0700 | [diff] [blame] | 134 | # in a shell script environment, so resolve an absolute path for it here. |
Austin Schuh | 889ac43 | 2018-10-29 22:57:02 -0700 | [diff] [blame^] | 135 | GTEST_CONFIG="`pwd -P`/../googletest/scripts/gtest-config" |
| 136 | GTEST_CPPFLAGS='-I$(top_srcdir)/../googletest/include' |
Austin Schuh | 0cbef62 | 2015-09-06 17:34:52 -0700 | [diff] [blame] | 137 | GTEST_CXXFLAGS='-g' |
| 138 | GTEST_LDFLAGS='' |
Austin Schuh | 889ac43 | 2018-10-29 22:57:02 -0700 | [diff] [blame^] | 139 | GTEST_LIBS='$(top_builddir)/../googletest/lib/libgtest.la' |
Austin Schuh | 0cbef62 | 2015-09-06 17:34:52 -0700 | [diff] [blame] | 140 | GTEST_VERSION="${GTEST_MIN_VERSION}"]) |
| 141 | |
| 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. |
| 146 | AC_OUTPUT |