build/autoconf/mozconfig-find

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rwxr-xr-x

Revert simplistic fix pending revisit of Mozilla integration attempt.

michael@0 1 #! /bin/sh
michael@0 2 #
michael@0 3 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 6
michael@0 7 # mozconfigfind - Loads options from .mozconfig onto configure's
michael@0 8 # command-line. The .mozconfig file is searched for in the
michael@0 9 # order:
michael@0 10 # If $MOZCONFIG is set, use that.
michael@0 11 # If one of $TOPSRCDIR/.mozconfig or $TOPSRCDIR/mozconfig exists, use it.
michael@0 12 # If both exist, or if various legacy locations contain a mozconfig, error.
michael@0 13 # Otherwise, use the default build options.
michael@0 14 #
michael@0 15 topsrcdir=$1
michael@0 16
michael@0 17 abspath() {
michael@0 18 if uname -s | grep -q MINGW; then
michael@0 19 # We have no way to figure out whether we're in gmake or pymake right
michael@0 20 # now. gmake gives us Unix-style paths while pymake gives us Windows-style
michael@0 21 # paths, so attempt to handle both.
michael@0 22 regexes='^\([A-Za-z]:\|\\\\\|\/\) ^\/'
michael@0 23 else
michael@0 24 regexes='^\/'
michael@0 25 fi
michael@0 26
michael@0 27 for regex in $regexes; do
michael@0 28 if echo $1 | grep -q $regex; then
michael@0 29 echo $1
michael@0 30 return
michael@0 31 fi
michael@0 32 done
michael@0 33
michael@0 34 # If we're at this point, we have a relative path
michael@0 35 echo `pwd`/$1
michael@0 36 }
michael@0 37
michael@0 38 if [ -n "$MOZCONFIG" ] && ! [ -f "$MOZCONFIG" ]; then
michael@0 39 echo "Specified MOZCONFIG \"$MOZCONFIG\" does not exist!" 1>&2
michael@0 40 exit 1
michael@0 41 fi
michael@0 42
michael@0 43 if [ -n "$MOZ_MYCONFIG" ]; then
michael@0 44 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
michael@0 45 exit 1
michael@0 46 fi
michael@0 47
michael@0 48 if [ -z "$MOZCONFIG" ] && [ -f "$topsrcdir/.mozconfig" ] && [ -f "$topsrcdir/mozconfig" ]; then
michael@0 49 echo "Both \$topsrcdir/.mozconfig and \$topsrcdir/mozconfig are supported, but you must choose only one. Please remove the other." 1>&2
michael@0 50 exit 1
michael@0 51 fi
michael@0 52
michael@0 53 for _config in "$MOZCONFIG" \
michael@0 54 "$topsrcdir/.mozconfig" \
michael@0 55 "$topsrcdir/mozconfig"
michael@0 56 do
michael@0 57 if test -f "$_config"; then
michael@0 58 abspath $_config
michael@0 59 exit 0
michael@0 60 fi
michael@0 61 done
michael@0 62
michael@0 63 # We used to support a number of other implicit .mozconfig locations. We now
michael@0 64 # detect if we were about to use any of these locations and issue an error if we
michael@0 65 # find any.
michael@0 66 for _config in "$topsrcdir/mozconfig.sh" \
michael@0 67 "$topsrcdir/myconfig.sh" \
michael@0 68 "$HOME/.mozconfig" \
michael@0 69 "$HOME/.mozconfig.sh" \
michael@0 70 "$HOME/.mozmyconfig.sh"
michael@0 71 do
michael@0 72 if test -f "$_config"; then
michael@0 73 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
michael@0 74 exit 1
michael@0 75 fi
michael@0 76 done

mercurial