michael@0: #! /bin/sh michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: # mozconfigfind - Loads options from .mozconfig onto configure's michael@0: # command-line. The .mozconfig file is searched for in the michael@0: # order: michael@0: # If $MOZCONFIG is set, use that. michael@0: # If one of $TOPSRCDIR/.mozconfig or $TOPSRCDIR/mozconfig exists, use it. michael@0: # If both exist, or if various legacy locations contain a mozconfig, error. michael@0: # Otherwise, use the default build options. michael@0: # michael@0: topsrcdir=$1 michael@0: michael@0: abspath() { michael@0: if uname -s | grep -q MINGW; then michael@0: # We have no way to figure out whether we're in gmake or pymake right michael@0: # now. gmake gives us Unix-style paths while pymake gives us Windows-style michael@0: # paths, so attempt to handle both. michael@0: regexes='^\([A-Za-z]:\|\\\\\|\/\) ^\/' michael@0: else michael@0: regexes='^\/' michael@0: fi michael@0: michael@0: for regex in $regexes; do michael@0: if echo $1 | grep -q $regex; then michael@0: echo $1 michael@0: return michael@0: fi michael@0: done michael@0: michael@0: # If we're at this point, we have a relative path michael@0: echo `pwd`/$1 michael@0: } michael@0: michael@0: if [ -n "$MOZCONFIG" ] && ! [ -f "$MOZCONFIG" ]; then michael@0: echo "Specified MOZCONFIG \"$MOZCONFIG\" does not exist!" 1>&2 michael@0: exit 1 michael@0: fi michael@0: michael@0: if [ -n "$MOZ_MYCONFIG" ]; then michael@0: 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: exit 1 michael@0: fi michael@0: michael@0: if [ -z "$MOZCONFIG" ] && [ -f "$topsrcdir/.mozconfig" ] && [ -f "$topsrcdir/mozconfig" ]; then michael@0: echo "Both \$topsrcdir/.mozconfig and \$topsrcdir/mozconfig are supported, but you must choose only one. Please remove the other." 1>&2 michael@0: exit 1 michael@0: fi michael@0: michael@0: for _config in "$MOZCONFIG" \ michael@0: "$topsrcdir/.mozconfig" \ michael@0: "$topsrcdir/mozconfig" michael@0: do michael@0: if test -f "$_config"; then michael@0: abspath $_config michael@0: exit 0 michael@0: fi michael@0: done michael@0: michael@0: # We used to support a number of other implicit .mozconfig locations. We now michael@0: # detect if we were about to use any of these locations and issue an error if we michael@0: # find any. michael@0: for _config in "$topsrcdir/mozconfig.sh" \ michael@0: "$topsrcdir/myconfig.sh" \ michael@0: "$HOME/.mozconfig" \ michael@0: "$HOME/.mozconfig.sh" \ michael@0: "$HOME/.mozmyconfig.sh" michael@0: do michael@0: if test -f "$_config"; then michael@0: 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: exit 1 michael@0: fi michael@0: done