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.

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

mercurial