From 394381bf3fe824fe0b3ffa00bc066105a2ce1864 Mon Sep 17 00:00:00 2001 From: shiqian Date: Tue, 9 Dec 2008 01:35:11 +0000 Subject: Necessary changes to gtest-config.in for supporting the up-coming release of Google C++ Mocking Framework. By Chandler Carruth. git-svn-id: http://googletest.googlecode.com/svn/trunk@153 861a406c-534a-0410-8894-cb66d6ee9925 --- scripts/gtest-config.in | 163 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 119 insertions(+), 44 deletions(-) (limited to 'scripts') diff --git a/scripts/gtest-config.in b/scripts/gtest-config.in index 50b18c9..b82d5a1 100755 --- a/scripts/gtest-config.in +++ b/scripts/gtest-config.in @@ -1,56 +1,61 @@ #!/bin/sh # These variables are automatically filled in by the configure script. -prefix="@prefix@" -exec_prefix="@exec_prefix@" -libdir="@libdir@" -includedir="@includedir@" name="@PACKAGE_TARNAME@" version="@PACKAGE_VERSION@" -gtest_ldflags="-L${libdir}" -gtest_libs="-l${name}" -gtest_cppflags="-I${includedir}" -gtest_cxxflags="" - show_usage() { - cat < overrides the installation prefix + --exec-prefix= overrides the executable installation prefix + --libdir= overrides the library installation prefix + --includedir= overrides the header file installation prefix + Installation Queries: --prefix installation prefix --exec-prefix executable installation prefix --libdir library installation directory --includedir header file installation directory - --version the version of the INC installation + --version the version of the Google Test installation Version Queries: --min-version=VERSION return 0 if the version is at least VERSION @@ -68,11 +73,13 @@ EOF # This function bounds our version with a min and a max. It uses some clever # POSIX-compliant variable expansion to portably do all the work in the shell -# and avoid any dependency on a particular "sed" implementation. Notable is -# that it will only ever compare the first 3 components of versions. Further -# components will be cleanly stripped off. All versions must be unadorned, so -# "v1.0" will *not* work. The minimum version must be in $1, and the max in -# $2. +# and avoid any dependency on a particular "sed" or "awk" implementation. +# Notable is that it will only ever compare the first 3 components of versions. +# Further components will be cleanly stripped off. All versions must be +# unadorned, so "v1.0" will *not* work. The minimum version must be in $1, and +# the max in $2. TODO(chandlerc@google.com): If this ever breaks, we should +# investigate expanding this via autom4te from AS_VERSION_COMPARE rather than +# continuing to maintain our own shell version. check_versions() { major_version=${version%%.*} @@ -140,13 +147,25 @@ fi while test $# -gt 0; do case $1 in - --usage) show_usage; exit 0;; - --help) show_help; exit 0;; - --prefix) echo $prefix; exit 0;; - --exec-prefix) echo $exec_prefix; exit 0;; - --libdir) echo $libdir; exit 0;; - --includedir) echo $includedir; exit 0;; - --version) echo $version; exit 0;; + --usage) show_usage; exit 0;; + --help) show_help; exit 0;; + + # Installation overrides + --prefix=*) GTEST_PREFIX=${1#--prefix=};; + --exec-prefix=*) GTEST_EXEC_PREFIX=${1#--exec-prefix=};; + --libdir=*) GTEST_LIBDIR=${1#--libdir=};; + --includedir=*) GTEST_INCLUDEDIR=${1#--includedir=};; + + # Installation queries + --prefix|--exec-prefix|--libdir|--includedir|--version) + if test -n "${do_query}"; then + show_usage + exit 1 + fi + do_query=${1#--} + ;; + + # Version checking --min-version=*) do_check_versions=yes min_version=${1#--min-version=} @@ -159,17 +178,73 @@ while test $# -gt 0; do do_check_versions=yes exact_version=${1#--exact-version=} ;; - --cppflags) echo_cppflags=yes;; - --cxxflags) echo_cxxflags=yes;; - --ldflags) echo_ldflags=yes;; - --libs) echo_libs=yes;; + + # Compiler flag output + --cppflags) echo_cppflags=yes;; + --cxxflags) echo_cxxflags=yes;; + --ldflags) echo_ldflags=yes;; + --libs) echo_libs=yes;; # Everything else is an error - *) show_usage; exit 1;; + *) show_usage; exit 1;; esac shift done +# These have defaults filled in by the configure script but can also be +# overridden by environment variables or command line parameters. +prefix="${GTEST_PREFIX:-@prefix@}" +exec_prefix="${GTEST_EXEC_PREFIX:-@exec_prefix@}" +libdir="${GTEST_LIBDIR:-@libdir@}" +includedir="${GTEST_INCLUDEDIR:-@includedir@}" + +# We try and detect if our binary is not located at its installed location. If +# it's not, we provide variables pointing to the source and build tree rather +# than to the install tree. This allows building against a just-built gtest +# rather than an installed gtest. +bindir="@bindir@" +this_relative_bindir=`dirname $0` +this_bindir=`cd ${this_relative_bindir}; pwd -P` +if test "${this_bindir}" = "${this_bindir%${bindir}}"; then + # The path to the script doesn't end in the bindir sequence from Autoconf, + # assume that we are in a build tree. + build_dir=`dirname ${this_bindir}` + src_dir=`cd ${this_bindir}/@top_srcdir@; pwd -P` + + # TODO(chandlerc@google.com): This is a dangerous dependency on libtool, we + # should work to remove it, and/or remove libtool altogether, replacing it + # with direct references to the library and a link path. + gtest_libs="${build_dir}/lib/libgtest.la" + gtest_ldflags="" + + # We provide hooks to include from either the source or build dir, where the + # build dir is always preferred. This will potentially allow us to write + # build rules for generated headers and have them automatically be preferred + # over provided versions. + gtest_cppflags="-I${build_dir}/include -I${src_dir}/include" + gtest_cxxflags="" +else + # We're using an installed gtest, although it may be staged under some + # prefix. Assume (as our own libraries do) that we can resolve the prefix, + # and are present in the dynamic link paths. + gtest_ldflags="-L${libdir}" + gtest_libs="-l${name}" + gtest_cppflags="-I${includedir}" + gtest_cxxflags="" +fi + +# Do an installation query if requested. +if test -n "$do_query"; then + case $do_query in + prefix) echo $prefix; exit 0;; + exec-prefix) echo $exec_prefix; exit 0;; + libdir) echo $libdir; exit 0;; + includedir) echo $includedir; exit 0;; + version) echo $version; exit 0;; + *) show_usage; exit 1;; + esac +fi + # Do a version check if requested. if test "$do_check_versions" = "yes"; then # Make sure we didn't receive a bad combination of parameters. -- cgit v1.2.1