Home | History | Annotate | Download | only in googlemock
      1 m4_include(../googletest/m4/acx_pthread.m4)
      2 
      3 AC_INIT([Google C++ Mocking Framework],
      4         [1.8.0],
      5         [googlemock (a] 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_MACRO_DIRS([m4])
     12 AC_CONFIG_AUX_DIR([build-aux])
     13 AC_CONFIG_HEADERS([build-aux/config.h])
     14 AC_CONFIG_FILES([Makefile])
     15 AC_CONFIG_FILES([scripts/gmock-config], [chmod +x scripts/gmock-config])
     16 
     17 # Initialize Automake with various options. We require at least v1.9, prevent
     18 # pedantic complaints about package files, and enable various distribution
     19 # targets.
     20 AM_INIT_AUTOMAKE([1.9 dist-bzip2 dist-zip foreign subdir-objects])
     21 
     22 # Check for programs used in building Google Test.
     23 AC_PROG_CC
     24 AC_PROG_CXX
     25 AC_LANG([C++])
     26 AC_PROG_LIBTOOL
     27 
     28 PYTHON=  # We *do not* allow the user to specify a python interpreter
     29 AC_PATH_PROG([PYTHON],[python],[:])
     30 AS_IF([test "$PYTHON" != ":"],
     31       [AM_PYTHON_CHECK_VERSION([$PYTHON],[2.3],[:],[PYTHON=":"])])
     32 AM_CONDITIONAL([HAVE_PYTHON],[test "$PYTHON" != ":"])
     33 
     34 # Configure pthreads.
     35 AC_ARG_WITH([pthreads],
     36             [AS_HELP_STRING([--with-pthreads],
     37                [use pthreads (default is yes)])],
     38             [with_pthreads=$withval],
     39             [with_pthreads=check])
     40 
     41 have_pthreads=no
     42 AS_IF([test "x$with_pthreads" != "xno"],
     43       [ACX_PTHREAD(
     44         [],
     45         [AS_IF([test "x$with_pthreads" != "xcheck"],
     46                [AC_MSG_FAILURE(
     47                  [--with-pthreads was specified, but unable to be used])])])
     48        have_pthreads="$acx_pthread_ok"])
     49 AM_CONDITIONAL([HAVE_PTHREADS],[test "x$have_pthreads" == "xyes"])
     50 AC_SUBST(PTHREAD_CFLAGS)
     51 AC_SUBST(PTHREAD_LIBS)
     52 
     53 # GoogleMock currently has hard dependencies upon GoogleTest above and beyond
     54 # running its own test suite, so we both provide our own version in
     55 # a subdirectory and provide some logic to use a custom version or a system
     56 # installed version.
     57 AC_ARG_WITH([gtest],
     58             [AS_HELP_STRING([--with-gtest],
     59                             [Specifies how to find the gtest package. If no
     60                             arguments are given, the default behavior, a
     61                             system installed gtest will be used if present,
     62                             and an internal version built otherwise. If a
     63                             path is provided, the gtest built or installed at
     64                             that prefix will be used.])],
     65             [],
     66             [with_gtest=yes])
     67 AC_ARG_ENABLE([external-gtest],
     68               [AS_HELP_STRING([--disable-external-gtest],
     69                               [Disables any detection or use of a system
     70                               installed or user provided gtest. Any option to
     71                               '--with-gtest' is ignored. (Default is enabled.)])
     72               ], [], [enable_external_gtest=yes])
     73 AS_IF([test "x$with_gtest" == "xno"],
     74       [AC_MSG_ERROR([dnl
     75 Support for GoogleTest was explicitly disabled. Currently GoogleMock has a hard
     76 dependency upon GoogleTest to build, please provide a version, or allow
     77 GoogleMock to use any installed version and fall back upon its internal
     78 version.])])
     79 
     80 # Setup various GTEST variables.
     81 AC_ARG_VAR([GTEST_CONFIG],
     82            [The exact path of Google Test's 'gtest-config' script.])
     83 AC_ARG_VAR([GTEST_CPPFLAGS],
     84            [C-like preprocessor flags for Google Test.])
     85 AC_ARG_VAR([GTEST_CXXFLAGS],
     86            [C++ compile flags for Google Test.])
     87 AC_ARG_VAR([GTEST_LDFLAGS],
     88            [Linker path and option flags for Google Test.])
     89 AC_ARG_VAR([GTEST_LIBS],
     90            [Library linking flags for Google Test.])
     91 AC_ARG_VAR([GTEST_VERSION],
     92            [The version of Google Test available.])
     93 HAVE_BUILT_GTEST="no"
     94 
     95 GTEST_MIN_VERSION="1.8.0"
     96 
     97 AS_IF([test "x${enable_external_gtest}" = "xyes"],
     98       [# Begin filling in variables as we are able.
     99       AS_IF([test "x${with_gtest}" != "xyes"],
    100             [AS_IF([test -x "${with_gtest}/scripts/gtest-config"],
    101                    [GTEST_CONFIG="${with_gtest}/scripts/gtest-config"],
    102                    [GTEST_CONFIG="${with_gtest}/bin/gtest-config"])
    103             AS_IF([test -x "${GTEST_CONFIG}"], [],
    104                   [AC_MSG_ERROR([dnl
    105 Unable to locate either a built or installed Google Test at '${with_gtest}'.])
    106                   ])])
    107 
    108       AS_IF([test -x "${GTEST_CONFIG}"], [],
    109             [AC_PATH_PROG([GTEST_CONFIG], [gtest-config])])
    110       AS_IF([test -x "${GTEST_CONFIG}"],
    111             [AC_MSG_CHECKING([for Google Test version >= ${GTEST_MIN_VERSION}])
    112             AS_IF([${GTEST_CONFIG} --min-version=${GTEST_MIN_VERSION}],
    113                   [AC_MSG_RESULT([yes])
    114                   HAVE_BUILT_GTEST="yes"],
    115                   [AC_MSG_RESULT([no])])])])
    116 
    117 AS_IF([test "x${HAVE_BUILT_GTEST}" = "xyes"],
    118       [GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags`
    119       GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags`
    120       GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
    121       GTEST_LIBS=`${GTEST_CONFIG} --libs`
    122       GTEST_VERSION=`${GTEST_CONFIG} --version`],
    123       [
    124       # GTEST_CONFIG needs to be executable both in a Makefile environment and
    125       # in a shell script environment, so resolve an absolute path for it here.
    126       GTEST_CONFIG="`pwd -P`/../googletest/scripts/gtest-config"
    127       GTEST_CPPFLAGS='-I$(top_srcdir)/../googletest/include'
    128       GTEST_CXXFLAGS='-g'
    129       GTEST_LDFLAGS=''
    130       GTEST_LIBS='$(top_builddir)/../googletest/lib/libgtest.la'
    131       GTEST_VERSION="${GTEST_MIN_VERSION}"])
    132 
    133 # Output the generated files. No further autoconf macros may be used.
    134 AC_OUTPUT
    135