build/autoconf/mozconfig-find

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/build/autoconf/mozconfig-find	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,76 @@
     1.4 +#! /bin/sh
     1.5 +#
     1.6 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.7 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.9 +
    1.10 +# mozconfigfind - Loads options from .mozconfig onto configure's
    1.11 +#    command-line. The .mozconfig file is searched for in the 
    1.12 +#    order:
    1.13 +#       If $MOZCONFIG is set, use that.
    1.14 +#       If one of $TOPSRCDIR/.mozconfig or $TOPSRCDIR/mozconfig exists, use it.
    1.15 +#       If both exist, or if various legacy locations contain a mozconfig, error.
    1.16 +#       Otherwise, use the default build options.
    1.17 +#
    1.18 +topsrcdir=$1
    1.19 +
    1.20 +abspath() {
    1.21 +  if uname -s | grep -q MINGW; then
    1.22 +    # We have no way to figure out whether we're in gmake or pymake right
    1.23 +    # now. gmake gives us Unix-style paths while pymake gives us Windows-style
    1.24 +    # paths, so attempt to handle both.
    1.25 +    regexes='^\([A-Za-z]:\|\\\\\|\/\) ^\/'
    1.26 +  else
    1.27 +    regexes='^\/'
    1.28 +  fi
    1.29 +
    1.30 +  for regex in $regexes; do
    1.31 +    if echo $1 | grep -q $regex; then
    1.32 +      echo $1
    1.33 +      return
    1.34 +    fi
    1.35 +  done
    1.36 +
    1.37 +  # If we're at this point, we have a relative path
    1.38 +  echo `pwd`/$1
    1.39 +}
    1.40 +
    1.41 +if [ -n "$MOZCONFIG" ] && ! [ -f "$MOZCONFIG" ]; then
    1.42 +  echo "Specified MOZCONFIG \"$MOZCONFIG\" does not exist!" 1>&2
    1.43 +  exit 1
    1.44 +fi
    1.45 +
    1.46 +if [ -n "$MOZ_MYCONFIG" ]; then
    1.47 +  echo "Your environment currently has the MOZ_MYCONFIG variable set to \"$MOZ_MYCONFIG\". MOZ_MYCONFIG is no longer supported. Please use MOZCONFIG instead." 1>&2
    1.48 +  exit 1
    1.49 +fi
    1.50 +
    1.51 +if [ -z "$MOZCONFIG" ] && [ -f "$topsrcdir/.mozconfig" ] && [ -f "$topsrcdir/mozconfig" ]; then
    1.52 +  echo "Both \$topsrcdir/.mozconfig and \$topsrcdir/mozconfig are supported, but you must choose only one. Please remove the other." 1>&2
    1.53 +  exit 1
    1.54 +fi
    1.55 +
    1.56 +for _config in "$MOZCONFIG" \
    1.57 +               "$topsrcdir/.mozconfig" \
    1.58 +               "$topsrcdir/mozconfig"
    1.59 +do
    1.60 +  if test -f "$_config"; then
    1.61 +    abspath $_config
    1.62 +    exit 0
    1.63 +  fi
    1.64 +done
    1.65 +
    1.66 +# We used to support a number of other implicit .mozconfig locations. We now
    1.67 +# detect if we were about to use any of these locations and issue an error if we
    1.68 +# find any.
    1.69 +for _config in "$topsrcdir/mozconfig.sh" \
    1.70 +               "$topsrcdir/myconfig.sh" \
    1.71 +               "$HOME/.mozconfig" \
    1.72 +               "$HOME/.mozconfig.sh" \
    1.73 +               "$HOME/.mozmyconfig.sh"
    1.74 +do
    1.75 +  if test -f "$_config"; then
    1.76 +    echo "You currently have a mozconfig at \"$_config\". This implicit location is no longer supported. Please move it to $topsrcdir/.mozconfig or specify it explicitly via \$MOZCONFIG." 1>&2
    1.77 +    exit 1
    1.78 +  fi
    1.79 +done

mercurial