media/webrtc/trunk/testing/gtest/scripts/gtest-config.in

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/webrtc/trunk/testing/gtest/scripts/gtest-config.in	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,274 @@
     1.4 +#!/bin/sh
     1.5 +
     1.6 +# These variables are automatically filled in by the configure script.
     1.7 +name="@PACKAGE_TARNAME@"
     1.8 +version="@PACKAGE_VERSION@"
     1.9 +
    1.10 +show_usage()
    1.11 +{
    1.12 +  echo "Usage: gtest-config [OPTIONS...]"
    1.13 +}
    1.14 +
    1.15 +show_help()
    1.16 +{
    1.17 +  show_usage
    1.18 +  cat <<\EOF
    1.19 +
    1.20 +The `gtest-config' script provides access to the necessary compile and linking
    1.21 +flags to connect with Google C++ Testing Framework, both in a build prior to
    1.22 +installation, and on the system proper after installation. The installation
    1.23 +overrides may be issued in combination with any other queries, but will only
    1.24 +affect installation queries if called on a built but not installed gtest. The
    1.25 +installation queries may not be issued with any other types of queries, and
    1.26 +only one installation query may be made at a time. The version queries and
    1.27 +compiler flag queries may be combined as desired but not mixed. Different
    1.28 +version queries are always combined with logical "and" semantics, and only the
    1.29 +last of any particular query is used while all previous ones ignored. All
    1.30 +versions must be specified as a sequence of numbers separated by periods.
    1.31 +Compiler flag queries output the union of the sets of flags when combined.
    1.32 +
    1.33 + Examples:
    1.34 +  gtest-config --min-version=1.0 || echo "Insufficient Google Test version."
    1.35 +
    1.36 +  g++ $(gtest-config --cppflags --cxxflags) -o foo.o -c foo.cpp
    1.37 +  g++ $(gtest-config --ldflags --libs) -o foo foo.o
    1.38 +
    1.39 +  # When using a built but not installed Google Test:
    1.40 +  g++ $(../../my_gtest_build/scripts/gtest-config ...) ...
    1.41 +
    1.42 +  # When using an installed Google Test, but with installation overrides:
    1.43 +  export GTEST_PREFIX="/opt"
    1.44 +  g++ $(gtest-config --libdir="/opt/lib64" ...) ...
    1.45 +
    1.46 + Help:
    1.47 +  --usage                    brief usage information
    1.48 +  --help                     display this help message
    1.49 +
    1.50 + Installation Overrides:
    1.51 +  --prefix=<dir>             overrides the installation prefix
    1.52 +  --exec-prefix=<dir>        overrides the executable installation prefix
    1.53 +  --libdir=<dir>             overrides the library installation prefix
    1.54 +  --includedir=<dir>         overrides the header file installation prefix
    1.55 +
    1.56 + Installation Queries:
    1.57 +  --prefix                   installation prefix
    1.58 +  --exec-prefix              executable installation prefix
    1.59 +  --libdir                   library installation directory
    1.60 +  --includedir               header file installation directory
    1.61 +  --version                  the version of the Google Test installation
    1.62 +
    1.63 + Version Queries:
    1.64 +  --min-version=VERSION      return 0 if the version is at least VERSION
    1.65 +  --exact-version=VERSION    return 0 if the version is exactly VERSION
    1.66 +  --max-version=VERSION      return 0 if the version is at most VERSION
    1.67 +
    1.68 + Compilation Flag Queries:
    1.69 +  --cppflags                 compile flags specific to the C-like preprocessors
    1.70 +  --cxxflags                 compile flags appropriate for C++ programs
    1.71 +  --ldflags                  linker flags
    1.72 +  --libs                     libraries for linking
    1.73 +
    1.74 +EOF
    1.75 +}
    1.76 +
    1.77 +# This function bounds our version with a min and a max. It uses some clever
    1.78 +# POSIX-compliant variable expansion to portably do all the work in the shell
    1.79 +# and avoid any dependency on a particular "sed" or "awk" implementation.
    1.80 +# Notable is that it will only ever compare the first 3 components of versions.
    1.81 +# Further components will be cleanly stripped off. All versions must be
    1.82 +# unadorned, so "v1.0" will *not* work. The minimum version must be in $1, and
    1.83 +# the max in $2. TODO(chandlerc@google.com): If this ever breaks, we should
    1.84 +# investigate expanding this via autom4te from AS_VERSION_COMPARE rather than
    1.85 +# continuing to maintain our own shell version.
    1.86 +check_versions()
    1.87 +{
    1.88 +  major_version=${version%%.*}
    1.89 +  minor_version="0"
    1.90 +  point_version="0"
    1.91 +  if test "${version#*.}" != "${version}"; then
    1.92 +    minor_version=${version#*.}
    1.93 +    minor_version=${minor_version%%.*}
    1.94 +  fi
    1.95 +  if test "${version#*.*.}" != "${version}"; then
    1.96 +    point_version=${version#*.*.}
    1.97 +    point_version=${point_version%%.*}
    1.98 +  fi
    1.99 +
   1.100 +  min_version="$1"
   1.101 +  min_major_version=${min_version%%.*}
   1.102 +  min_minor_version="0"
   1.103 +  min_point_version="0"
   1.104 +  if test "${min_version#*.}" != "${min_version}"; then
   1.105 +    min_minor_version=${min_version#*.}
   1.106 +    min_minor_version=${min_minor_version%%.*}
   1.107 +  fi
   1.108 +  if test "${min_version#*.*.}" != "${min_version}"; then
   1.109 +    min_point_version=${min_version#*.*.}
   1.110 +    min_point_version=${min_point_version%%.*}
   1.111 +  fi
   1.112 +
   1.113 +  max_version="$2"
   1.114 +  max_major_version=${max_version%%.*}
   1.115 +  max_minor_version="0"
   1.116 +  max_point_version="0"
   1.117 +  if test "${max_version#*.}" != "${max_version}"; then
   1.118 +    max_minor_version=${max_version#*.}
   1.119 +    max_minor_version=${max_minor_version%%.*}
   1.120 +  fi
   1.121 +  if test "${max_version#*.*.}" != "${max_version}"; then
   1.122 +    max_point_version=${max_version#*.*.}
   1.123 +    max_point_version=${max_point_version%%.*}
   1.124 +  fi
   1.125 +
   1.126 +  test $(($major_version)) -lt $(($min_major_version)) && exit 1
   1.127 +  if test $(($major_version)) -eq $(($min_major_version)); then
   1.128 +    test $(($minor_version)) -lt $(($min_minor_version)) && exit 1
   1.129 +    if test $(($minor_version)) -eq $(($min_minor_version)); then
   1.130 +      test $(($point_version)) -lt $(($min_point_version)) && exit 1
   1.131 +    fi
   1.132 +  fi
   1.133 +
   1.134 +  test $(($major_version)) -gt $(($max_major_version)) && exit 1
   1.135 +  if test $(($major_version)) -eq $(($max_major_version)); then
   1.136 +    test $(($minor_version)) -gt $(($max_minor_version)) && exit 1
   1.137 +    if test $(($minor_version)) -eq $(($max_minor_version)); then
   1.138 +      test $(($point_version)) -gt $(($max_point_version)) && exit 1
   1.139 +    fi
   1.140 +  fi
   1.141 +
   1.142 +  exit 0
   1.143 +}
   1.144 +
   1.145 +# Show the usage line when no arguments are specified.
   1.146 +if test $# -eq 0; then
   1.147 +  show_usage
   1.148 +  exit 1
   1.149 +fi
   1.150 +
   1.151 +while test $# -gt 0; do
   1.152 +  case $1 in
   1.153 +    --usage)          show_usage;         exit 0;;
   1.154 +    --help)           show_help;          exit 0;;
   1.155 +
   1.156 +    # Installation overrides
   1.157 +    --prefix=*)       GTEST_PREFIX=${1#--prefix=};;
   1.158 +    --exec-prefix=*)  GTEST_EXEC_PREFIX=${1#--exec-prefix=};;
   1.159 +    --libdir=*)       GTEST_LIBDIR=${1#--libdir=};;
   1.160 +    --includedir=*)   GTEST_INCLUDEDIR=${1#--includedir=};;
   1.161 +
   1.162 +    # Installation queries
   1.163 +    --prefix|--exec-prefix|--libdir|--includedir|--version)
   1.164 +      if test -n "${do_query}"; then
   1.165 +        show_usage
   1.166 +        exit 1
   1.167 +      fi
   1.168 +      do_query=${1#--}
   1.169 +      ;;
   1.170 +
   1.171 +    # Version checking
   1.172 +    --min-version=*)
   1.173 +      do_check_versions=yes
   1.174 +      min_version=${1#--min-version=}
   1.175 +      ;;
   1.176 +    --max-version=*)
   1.177 +      do_check_versions=yes
   1.178 +      max_version=${1#--max-version=}
   1.179 +      ;;
   1.180 +    --exact-version=*)
   1.181 +      do_check_versions=yes
   1.182 +      exact_version=${1#--exact-version=}
   1.183 +      ;;
   1.184 +
   1.185 +    # Compiler flag output
   1.186 +    --cppflags)       echo_cppflags=yes;;
   1.187 +    --cxxflags)       echo_cxxflags=yes;;
   1.188 +    --ldflags)        echo_ldflags=yes;;
   1.189 +    --libs)           echo_libs=yes;;
   1.190 +
   1.191 +    # Everything else is an error
   1.192 +    *)                show_usage;         exit 1;;
   1.193 +  esac
   1.194 +  shift
   1.195 +done
   1.196 +
   1.197 +# These have defaults filled in by the configure script but can also be
   1.198 +# overridden by environment variables or command line parameters.
   1.199 +prefix="${GTEST_PREFIX:-@prefix@}"
   1.200 +exec_prefix="${GTEST_EXEC_PREFIX:-@exec_prefix@}"
   1.201 +libdir="${GTEST_LIBDIR:-@libdir@}"
   1.202 +includedir="${GTEST_INCLUDEDIR:-@includedir@}"
   1.203 +
   1.204 +# We try and detect if our binary is not located at its installed location. If
   1.205 +# it's not, we provide variables pointing to the source and build tree rather
   1.206 +# than to the install tree. This allows building against a just-built gtest
   1.207 +# rather than an installed gtest.
   1.208 +bindir="@bindir@"
   1.209 +this_relative_bindir=`dirname $0`
   1.210 +this_bindir=`cd ${this_relative_bindir}; pwd -P`
   1.211 +if test "${this_bindir}" = "${this_bindir%${bindir}}"; then
   1.212 +  # The path to the script doesn't end in the bindir sequence from Autoconf,
   1.213 +  # assume that we are in a build tree.
   1.214 +  build_dir=`dirname ${this_bindir}`
   1.215 +  src_dir=`cd ${this_bindir}/@top_srcdir@; pwd -P`
   1.216 +
   1.217 +  # TODO(chandlerc@google.com): This is a dangerous dependency on libtool, we
   1.218 +  # should work to remove it, and/or remove libtool altogether, replacing it
   1.219 +  # with direct references to the library and a link path.
   1.220 +  gtest_libs="${build_dir}/lib/libgtest.la @PTHREAD_CFLAGS@ @PTHREAD_LIBS@"
   1.221 +  gtest_ldflags=""
   1.222 +
   1.223 +  # We provide hooks to include from either the source or build dir, where the
   1.224 +  # build dir is always preferred. This will potentially allow us to write
   1.225 +  # build rules for generated headers and have them automatically be preferred
   1.226 +  # over provided versions.
   1.227 +  gtest_cppflags="-I${build_dir}/include -I${src_dir}/include"
   1.228 +  gtest_cxxflags="@PTHREAD_CFLAGS@"
   1.229 +else
   1.230 +  # We're using an installed gtest, although it may be staged under some
   1.231 +  # prefix. Assume (as our own libraries do) that we can resolve the prefix,
   1.232 +  # and are present in the dynamic link paths.
   1.233 +  gtest_ldflags="-L${libdir}"
   1.234 +  gtest_libs="-l${name} @PTHREAD_CFLAGS@ @PTHREAD_LIBS@"
   1.235 +  gtest_cppflags="-I${includedir}"
   1.236 +  gtest_cxxflags="@PTHREAD_CFLAGS@"
   1.237 +fi
   1.238 +
   1.239 +# Do an installation query if requested.
   1.240 +if test -n "$do_query"; then
   1.241 +  case $do_query in
   1.242 +    prefix)           echo $prefix;       exit 0;;
   1.243 +    exec-prefix)      echo $exec_prefix;  exit 0;;
   1.244 +    libdir)           echo $libdir;       exit 0;;
   1.245 +    includedir)       echo $includedir;   exit 0;;
   1.246 +    version)          echo $version;      exit 0;;
   1.247 +    *)                show_usage;         exit 1;;
   1.248 +  esac
   1.249 +fi
   1.250 +
   1.251 +# Do a version check if requested.
   1.252 +if test "$do_check_versions" = "yes"; then
   1.253 +  # Make sure we didn't receive a bad combination of parameters.
   1.254 +  test "$echo_cppflags" = "yes" && show_usage && exit 1
   1.255 +  test "$echo_cxxflags" = "yes" && show_usage && exit 1
   1.256 +  test "$echo_ldflags" = "yes"  && show_usage && exit 1
   1.257 +  test "$echo_libs" = "yes"     && show_usage && exit 1
   1.258 +
   1.259 +  if test "$exact_version" != ""; then
   1.260 +    check_versions $exact_version $exact_version
   1.261 +    # unreachable
   1.262 +  else
   1.263 +    check_versions ${min_version:-0.0.0} ${max_version:-9999.9999.9999}
   1.264 +    # unreachable
   1.265 +  fi
   1.266 +fi
   1.267 +
   1.268 +# Do the output in the correct order so that these can be used in-line of
   1.269 +# a compiler invocation.
   1.270 +output=""
   1.271 +test "$echo_cppflags" = "yes" && output="$output $gtest_cppflags"
   1.272 +test "$echo_cxxflags" = "yes" && output="$output $gtest_cxxflags"
   1.273 +test "$echo_ldflags" = "yes"  && output="$output $gtest_ldflags"
   1.274 +test "$echo_libs" = "yes"     && output="$output $gtest_libs"
   1.275 +echo $output
   1.276 +
   1.277 +exit 0

mercurial