Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | #!/bin/sh |
michael@0 | 2 | |
michael@0 | 3 | # These variables are automatically filled in by the configure script. |
michael@0 | 4 | name="@PACKAGE_TARNAME@" |
michael@0 | 5 | version="@PACKAGE_VERSION@" |
michael@0 | 6 | |
michael@0 | 7 | show_usage() |
michael@0 | 8 | { |
michael@0 | 9 | echo "Usage: gtest-config [OPTIONS...]" |
michael@0 | 10 | } |
michael@0 | 11 | |
michael@0 | 12 | show_help() |
michael@0 | 13 | { |
michael@0 | 14 | show_usage |
michael@0 | 15 | cat <<\EOF |
michael@0 | 16 | |
michael@0 | 17 | The `gtest-config' script provides access to the necessary compile and linking |
michael@0 | 18 | flags to connect with Google C++ Testing Framework, both in a build prior to |
michael@0 | 19 | installation, and on the system proper after installation. The installation |
michael@0 | 20 | overrides may be issued in combination with any other queries, but will only |
michael@0 | 21 | affect installation queries if called on a built but not installed gtest. The |
michael@0 | 22 | installation queries may not be issued with any other types of queries, and |
michael@0 | 23 | only one installation query may be made at a time. The version queries and |
michael@0 | 24 | compiler flag queries may be combined as desired but not mixed. Different |
michael@0 | 25 | version queries are always combined with logical "and" semantics, and only the |
michael@0 | 26 | last of any particular query is used while all previous ones ignored. All |
michael@0 | 27 | versions must be specified as a sequence of numbers separated by periods. |
michael@0 | 28 | Compiler flag queries output the union of the sets of flags when combined. |
michael@0 | 29 | |
michael@0 | 30 | Examples: |
michael@0 | 31 | gtest-config --min-version=1.0 || echo "Insufficient Google Test version." |
michael@0 | 32 | |
michael@0 | 33 | g++ $(gtest-config --cppflags --cxxflags) -o foo.o -c foo.cpp |
michael@0 | 34 | g++ $(gtest-config --ldflags --libs) -o foo foo.o |
michael@0 | 35 | |
michael@0 | 36 | # When using a built but not installed Google Test: |
michael@0 | 37 | g++ $(../../my_gtest_build/scripts/gtest-config ...) ... |
michael@0 | 38 | |
michael@0 | 39 | # When using an installed Google Test, but with installation overrides: |
michael@0 | 40 | export GTEST_PREFIX="/opt" |
michael@0 | 41 | g++ $(gtest-config --libdir="/opt/lib64" ...) ... |
michael@0 | 42 | |
michael@0 | 43 | Help: |
michael@0 | 44 | --usage brief usage information |
michael@0 | 45 | --help display this help message |
michael@0 | 46 | |
michael@0 | 47 | Installation Overrides: |
michael@0 | 48 | --prefix=<dir> overrides the installation prefix |
michael@0 | 49 | --exec-prefix=<dir> overrides the executable installation prefix |
michael@0 | 50 | --libdir=<dir> overrides the library installation prefix |
michael@0 | 51 | --includedir=<dir> overrides the header file installation prefix |
michael@0 | 52 | |
michael@0 | 53 | Installation Queries: |
michael@0 | 54 | --prefix installation prefix |
michael@0 | 55 | --exec-prefix executable installation prefix |
michael@0 | 56 | --libdir library installation directory |
michael@0 | 57 | --includedir header file installation directory |
michael@0 | 58 | --version the version of the Google Test installation |
michael@0 | 59 | |
michael@0 | 60 | Version Queries: |
michael@0 | 61 | --min-version=VERSION return 0 if the version is at least VERSION |
michael@0 | 62 | --exact-version=VERSION return 0 if the version is exactly VERSION |
michael@0 | 63 | --max-version=VERSION return 0 if the version is at most VERSION |
michael@0 | 64 | |
michael@0 | 65 | Compilation Flag Queries: |
michael@0 | 66 | --cppflags compile flags specific to the C-like preprocessors |
michael@0 | 67 | --cxxflags compile flags appropriate for C++ programs |
michael@0 | 68 | --ldflags linker flags |
michael@0 | 69 | --libs libraries for linking |
michael@0 | 70 | |
michael@0 | 71 | EOF |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | # This function bounds our version with a min and a max. It uses some clever |
michael@0 | 75 | # POSIX-compliant variable expansion to portably do all the work in the shell |
michael@0 | 76 | # and avoid any dependency on a particular "sed" or "awk" implementation. |
michael@0 | 77 | # Notable is that it will only ever compare the first 3 components of versions. |
michael@0 | 78 | # Further components will be cleanly stripped off. All versions must be |
michael@0 | 79 | # unadorned, so "v1.0" will *not* work. The minimum version must be in $1, and |
michael@0 | 80 | # the max in $2. TODO(chandlerc@google.com): If this ever breaks, we should |
michael@0 | 81 | # investigate expanding this via autom4te from AS_VERSION_COMPARE rather than |
michael@0 | 82 | # continuing to maintain our own shell version. |
michael@0 | 83 | check_versions() |
michael@0 | 84 | { |
michael@0 | 85 | major_version=${version%%.*} |
michael@0 | 86 | minor_version="0" |
michael@0 | 87 | point_version="0" |
michael@0 | 88 | if test "${version#*.}" != "${version}"; then |
michael@0 | 89 | minor_version=${version#*.} |
michael@0 | 90 | minor_version=${minor_version%%.*} |
michael@0 | 91 | fi |
michael@0 | 92 | if test "${version#*.*.}" != "${version}"; then |
michael@0 | 93 | point_version=${version#*.*.} |
michael@0 | 94 | point_version=${point_version%%.*} |
michael@0 | 95 | fi |
michael@0 | 96 | |
michael@0 | 97 | min_version="$1" |
michael@0 | 98 | min_major_version=${min_version%%.*} |
michael@0 | 99 | min_minor_version="0" |
michael@0 | 100 | min_point_version="0" |
michael@0 | 101 | if test "${min_version#*.}" != "${min_version}"; then |
michael@0 | 102 | min_minor_version=${min_version#*.} |
michael@0 | 103 | min_minor_version=${min_minor_version%%.*} |
michael@0 | 104 | fi |
michael@0 | 105 | if test "${min_version#*.*.}" != "${min_version}"; then |
michael@0 | 106 | min_point_version=${min_version#*.*.} |
michael@0 | 107 | min_point_version=${min_point_version%%.*} |
michael@0 | 108 | fi |
michael@0 | 109 | |
michael@0 | 110 | max_version="$2" |
michael@0 | 111 | max_major_version=${max_version%%.*} |
michael@0 | 112 | max_minor_version="0" |
michael@0 | 113 | max_point_version="0" |
michael@0 | 114 | if test "${max_version#*.}" != "${max_version}"; then |
michael@0 | 115 | max_minor_version=${max_version#*.} |
michael@0 | 116 | max_minor_version=${max_minor_version%%.*} |
michael@0 | 117 | fi |
michael@0 | 118 | if test "${max_version#*.*.}" != "${max_version}"; then |
michael@0 | 119 | max_point_version=${max_version#*.*.} |
michael@0 | 120 | max_point_version=${max_point_version%%.*} |
michael@0 | 121 | fi |
michael@0 | 122 | |
michael@0 | 123 | test $(($major_version)) -lt $(($min_major_version)) && exit 1 |
michael@0 | 124 | if test $(($major_version)) -eq $(($min_major_version)); then |
michael@0 | 125 | test $(($minor_version)) -lt $(($min_minor_version)) && exit 1 |
michael@0 | 126 | if test $(($minor_version)) -eq $(($min_minor_version)); then |
michael@0 | 127 | test $(($point_version)) -lt $(($min_point_version)) && exit 1 |
michael@0 | 128 | fi |
michael@0 | 129 | fi |
michael@0 | 130 | |
michael@0 | 131 | test $(($major_version)) -gt $(($max_major_version)) && exit 1 |
michael@0 | 132 | if test $(($major_version)) -eq $(($max_major_version)); then |
michael@0 | 133 | test $(($minor_version)) -gt $(($max_minor_version)) && exit 1 |
michael@0 | 134 | if test $(($minor_version)) -eq $(($max_minor_version)); then |
michael@0 | 135 | test $(($point_version)) -gt $(($max_point_version)) && exit 1 |
michael@0 | 136 | fi |
michael@0 | 137 | fi |
michael@0 | 138 | |
michael@0 | 139 | exit 0 |
michael@0 | 140 | } |
michael@0 | 141 | |
michael@0 | 142 | # Show the usage line when no arguments are specified. |
michael@0 | 143 | if test $# -eq 0; then |
michael@0 | 144 | show_usage |
michael@0 | 145 | exit 1 |
michael@0 | 146 | fi |
michael@0 | 147 | |
michael@0 | 148 | while test $# -gt 0; do |
michael@0 | 149 | case $1 in |
michael@0 | 150 | --usage) show_usage; exit 0;; |
michael@0 | 151 | --help) show_help; exit 0;; |
michael@0 | 152 | |
michael@0 | 153 | # Installation overrides |
michael@0 | 154 | --prefix=*) GTEST_PREFIX=${1#--prefix=};; |
michael@0 | 155 | --exec-prefix=*) GTEST_EXEC_PREFIX=${1#--exec-prefix=};; |
michael@0 | 156 | --libdir=*) GTEST_LIBDIR=${1#--libdir=};; |
michael@0 | 157 | --includedir=*) GTEST_INCLUDEDIR=${1#--includedir=};; |
michael@0 | 158 | |
michael@0 | 159 | # Installation queries |
michael@0 | 160 | --prefix|--exec-prefix|--libdir|--includedir|--version) |
michael@0 | 161 | if test -n "${do_query}"; then |
michael@0 | 162 | show_usage |
michael@0 | 163 | exit 1 |
michael@0 | 164 | fi |
michael@0 | 165 | do_query=${1#--} |
michael@0 | 166 | ;; |
michael@0 | 167 | |
michael@0 | 168 | # Version checking |
michael@0 | 169 | --min-version=*) |
michael@0 | 170 | do_check_versions=yes |
michael@0 | 171 | min_version=${1#--min-version=} |
michael@0 | 172 | ;; |
michael@0 | 173 | --max-version=*) |
michael@0 | 174 | do_check_versions=yes |
michael@0 | 175 | max_version=${1#--max-version=} |
michael@0 | 176 | ;; |
michael@0 | 177 | --exact-version=*) |
michael@0 | 178 | do_check_versions=yes |
michael@0 | 179 | exact_version=${1#--exact-version=} |
michael@0 | 180 | ;; |
michael@0 | 181 | |
michael@0 | 182 | # Compiler flag output |
michael@0 | 183 | --cppflags) echo_cppflags=yes;; |
michael@0 | 184 | --cxxflags) echo_cxxflags=yes;; |
michael@0 | 185 | --ldflags) echo_ldflags=yes;; |
michael@0 | 186 | --libs) echo_libs=yes;; |
michael@0 | 187 | |
michael@0 | 188 | # Everything else is an error |
michael@0 | 189 | *) show_usage; exit 1;; |
michael@0 | 190 | esac |
michael@0 | 191 | shift |
michael@0 | 192 | done |
michael@0 | 193 | |
michael@0 | 194 | # These have defaults filled in by the configure script but can also be |
michael@0 | 195 | # overridden by environment variables or command line parameters. |
michael@0 | 196 | prefix="${GTEST_PREFIX:-@prefix@}" |
michael@0 | 197 | exec_prefix="${GTEST_EXEC_PREFIX:-@exec_prefix@}" |
michael@0 | 198 | libdir="${GTEST_LIBDIR:-@libdir@}" |
michael@0 | 199 | includedir="${GTEST_INCLUDEDIR:-@includedir@}" |
michael@0 | 200 | |
michael@0 | 201 | # We try and detect if our binary is not located at its installed location. If |
michael@0 | 202 | # it's not, we provide variables pointing to the source and build tree rather |
michael@0 | 203 | # than to the install tree. This allows building against a just-built gtest |
michael@0 | 204 | # rather than an installed gtest. |
michael@0 | 205 | bindir="@bindir@" |
michael@0 | 206 | this_relative_bindir=`dirname $0` |
michael@0 | 207 | this_bindir=`cd ${this_relative_bindir}; pwd -P` |
michael@0 | 208 | if test "${this_bindir}" = "${this_bindir%${bindir}}"; then |
michael@0 | 209 | # The path to the script doesn't end in the bindir sequence from Autoconf, |
michael@0 | 210 | # assume that we are in a build tree. |
michael@0 | 211 | build_dir=`dirname ${this_bindir}` |
michael@0 | 212 | src_dir=`cd ${this_bindir}/@top_srcdir@; pwd -P` |
michael@0 | 213 | |
michael@0 | 214 | # TODO(chandlerc@google.com): This is a dangerous dependency on libtool, we |
michael@0 | 215 | # should work to remove it, and/or remove libtool altogether, replacing it |
michael@0 | 216 | # with direct references to the library and a link path. |
michael@0 | 217 | gtest_libs="${build_dir}/lib/libgtest.la @PTHREAD_CFLAGS@ @PTHREAD_LIBS@" |
michael@0 | 218 | gtest_ldflags="" |
michael@0 | 219 | |
michael@0 | 220 | # We provide hooks to include from either the source or build dir, where the |
michael@0 | 221 | # build dir is always preferred. This will potentially allow us to write |
michael@0 | 222 | # build rules for generated headers and have them automatically be preferred |
michael@0 | 223 | # over provided versions. |
michael@0 | 224 | gtest_cppflags="-I${build_dir}/include -I${src_dir}/include" |
michael@0 | 225 | gtest_cxxflags="@PTHREAD_CFLAGS@" |
michael@0 | 226 | else |
michael@0 | 227 | # We're using an installed gtest, although it may be staged under some |
michael@0 | 228 | # prefix. Assume (as our own libraries do) that we can resolve the prefix, |
michael@0 | 229 | # and are present in the dynamic link paths. |
michael@0 | 230 | gtest_ldflags="-L${libdir}" |
michael@0 | 231 | gtest_libs="-l${name} @PTHREAD_CFLAGS@ @PTHREAD_LIBS@" |
michael@0 | 232 | gtest_cppflags="-I${includedir}" |
michael@0 | 233 | gtest_cxxflags="@PTHREAD_CFLAGS@" |
michael@0 | 234 | fi |
michael@0 | 235 | |
michael@0 | 236 | # Do an installation query if requested. |
michael@0 | 237 | if test -n "$do_query"; then |
michael@0 | 238 | case $do_query in |
michael@0 | 239 | prefix) echo $prefix; exit 0;; |
michael@0 | 240 | exec-prefix) echo $exec_prefix; exit 0;; |
michael@0 | 241 | libdir) echo $libdir; exit 0;; |
michael@0 | 242 | includedir) echo $includedir; exit 0;; |
michael@0 | 243 | version) echo $version; exit 0;; |
michael@0 | 244 | *) show_usage; exit 1;; |
michael@0 | 245 | esac |
michael@0 | 246 | fi |
michael@0 | 247 | |
michael@0 | 248 | # Do a version check if requested. |
michael@0 | 249 | if test "$do_check_versions" = "yes"; then |
michael@0 | 250 | # Make sure we didn't receive a bad combination of parameters. |
michael@0 | 251 | test "$echo_cppflags" = "yes" && show_usage && exit 1 |
michael@0 | 252 | test "$echo_cxxflags" = "yes" && show_usage && exit 1 |
michael@0 | 253 | test "$echo_ldflags" = "yes" && show_usage && exit 1 |
michael@0 | 254 | test "$echo_libs" = "yes" && show_usage && exit 1 |
michael@0 | 255 | |
michael@0 | 256 | if test "$exact_version" != ""; then |
michael@0 | 257 | check_versions $exact_version $exact_version |
michael@0 | 258 | # unreachable |
michael@0 | 259 | else |
michael@0 | 260 | check_versions ${min_version:-0.0.0} ${max_version:-9999.9999.9999} |
michael@0 | 261 | # unreachable |
michael@0 | 262 | fi |
michael@0 | 263 | fi |
michael@0 | 264 | |
michael@0 | 265 | # Do the output in the correct order so that these can be used in-line of |
michael@0 | 266 | # a compiler invocation. |
michael@0 | 267 | output="" |
michael@0 | 268 | test "$echo_cppflags" = "yes" && output="$output $gtest_cppflags" |
michael@0 | 269 | test "$echo_cxxflags" = "yes" && output="$output $gtest_cxxflags" |
michael@0 | 270 | test "$echo_ldflags" = "yes" && output="$output $gtest_ldflags" |
michael@0 | 271 | test "$echo_libs" = "yes" && output="$output $gtest_libs" |
michael@0 | 272 | echo $output |
michael@0 | 273 | |
michael@0 | 274 | exit 0 |