configure.ac 6.1 KB

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