PageRenderTime 17ms CodeModel.GetById 12ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/build/autoconf/mozconfig-find

http://github.com/zpao/v8monkey
Shell | 109 lines | 47 code | 9 blank | 53 comment | 13 complexity | 75cce3851cd447e8e0307f9c92c0bbc0 MD5 | raw file
  1#! /bin/sh
  2#
  3# ***** BEGIN LICENSE BLOCK *****
  4# Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5#
  6# The contents of this file are subject to the Mozilla Public License Version
  7# 1.1 (the "License"); you may not use this file except in compliance with
  8# the License. You may obtain a copy of the License at
  9# http://www.mozilla.org/MPL/
 10#
 11# Software distributed under the License is distributed on an "AS IS" basis,
 12# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 13# for the specific language governing rights and limitations under the
 14# License.
 15#
 16# The Original Code is mozilla.org code.
 17#
 18# The Initial Developer of the Original Code is
 19# Netscape Communications Corporation.
 20# Portions created by the Initial Developer are Copyright (C) 1999
 21# the Initial Developer. All Rights Reserved.
 22#
 23# Contributor(s):
 24#   Stephen Lamm <slamm@netscape.com>
 25#
 26# Alternatively, the contents of this file may be used under the terms of
 27# either of the GNU General Public License Version 2 or later (the "GPL"),
 28# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 29# in which case the provisions of the GPL or the LGPL are applicable instead
 30# of those above. If you wish to allow use of your version of this file only
 31# under the terms of either the GPL or the LGPL, and not to allow others to
 32# use your version of this file under the terms of the MPL, indicate your
 33# decision by deleting the provisions above and replace them with the notice
 34# and other provisions required by the GPL or the LGPL. If you do not delete
 35# the provisions above, a recipient may use your version of this file under
 36# the terms of any one of the MPL, the GPL or the LGPL.
 37#
 38# ***** END LICENSE BLOCK *****
 39
 40# mozconfigfind - Loads options from .mozconfig onto configure's
 41#    command-line. The .mozconfig file is searched for in the 
 42#    order:
 43#       If $MOZCONFIG is set, use that.
 44#       If one of $TOPSRCDIR/.mozconfig or $TOPSRCDIR/mozconfig exists, use it.
 45#       If both exist, or if various legacy locations contain a mozconfig, error.
 46#       Otherwise, use the default build options.
 47#
 48topsrcdir=$1
 49
 50abspath() {
 51  if uname -s | grep -q MINGW; then
 52    # We have no way to figure out whether we're in gmake or pymake right
 53    # now. gmake gives us Unix-style paths while pymake gives us Windows-style
 54    # paths, so attempt to handle both.
 55    regexes='^\([A-Za-z]:\|\\\\\|\/\) ^\/'
 56  else
 57    regexes='^\/'
 58  fi
 59
 60  for regex in $regexes; do
 61    if echo $1 | grep -q $regex; then
 62      echo $1
 63      return
 64    fi
 65  done
 66
 67  # If we're at this point, we have a relative path
 68  echo `pwd`/$1
 69}
 70
 71if [ -n "$MOZCONFIG" ] && ! [ -f "$MOZCONFIG" ]; then
 72  echo "Specified MOZCONFIG \"$MOZCONFIG\" does not exist!" 1>&2
 73  exit 1
 74fi
 75
 76if [ -n "$MOZ_MYCONFIG" ]; then
 77  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
 78  exit 1
 79fi
 80
 81if [ -z "$MOZCONFIG" ] && [ -f "$topsrcdir/.mozconfig" ] && [ -f "$topsrcdir/mozconfig" ]; then
 82  echo "Both \$topsrcdir/.mozconfig and \$topsrcdir/mozconfig are supported, but you must choose only one. Please remove the other." 1>&2
 83  exit 1
 84fi
 85
 86for _config in "$MOZCONFIG" \
 87               "$topsrcdir/.mozconfig" \
 88               "$topsrcdir/mozconfig"
 89do
 90  if test -f "$_config"; then
 91    abspath $_config
 92    exit 0
 93  fi
 94done
 95
 96# We used to support a number of other implicit .mozconfig locations. We now
 97# detect if we were about to use any of these locations and issue an error if we
 98# find any.
 99for _config in "$topsrcdir/mozconfig.sh" \
100               "$topsrcdir/myconfig.sh" \
101               "$HOME/.mozconfig" \
102               "$HOME/.mozconfig.sh" \
103               "$HOME/.mozmyconfig.sh"
104do
105  if test -f "$_config"; then
106    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
107    exit 1
108  fi
109done