/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. # mozconfigfind - Loads options from .mozconfig onto configure's
  40. # command-line. The .mozconfig file is searched for in the
  41. # order:
  42. # If $MOZCONFIG is set, use that.
  43. # If one of $TOPSRCDIR/.mozconfig or $TOPSRCDIR/mozconfig exists, use it.
  44. # If both exist, or if various legacy locations contain a mozconfig, error.
  45. # Otherwise, use the default build options.
  46. #
  47. topsrcdir=$1
  48. abspath() {
  49. if uname -s | grep -q MINGW; then
  50. # We have no way to figure out whether we're in gmake or pymake right
  51. # now. gmake gives us Unix-style paths while pymake gives us Windows-style
  52. # paths, so attempt to handle both.
  53. regexes='^\([A-Za-z]:\|\\\\\|\/\) ^\/'
  54. else
  55. regexes='^\/'
  56. fi
  57. for regex in $regexes; do
  58. if echo $1 | grep -q $regex; then
  59. echo $1
  60. return
  61. fi
  62. done
  63. # If we're at this point, we have a relative path
  64. echo `pwd`/$1
  65. }
  66. if [ -n "$MOZCONFIG" ] && ! [ -f "$MOZCONFIG" ]; then
  67. echo "Specified MOZCONFIG \"$MOZCONFIG\" does not exist!" 1>&2
  68. exit 1
  69. fi
  70. if [ -n "$MOZ_MYCONFIG" ]; then
  71. 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
  72. exit 1
  73. fi
  74. if [ -z "$MOZCONFIG" ] && [ -f "$topsrcdir/.mozconfig" ] && [ -f "$topsrcdir/mozconfig" ]; then
  75. echo "Both \$topsrcdir/.mozconfig and \$topsrcdir/mozconfig are supported, but you must choose only one. Please remove the other." 1>&2
  76. exit 1
  77. fi
  78. for _config in "$MOZCONFIG" \
  79. "$topsrcdir/.mozconfig" \
  80. "$topsrcdir/mozconfig"
  81. do
  82. if test -f "$_config"; then
  83. abspath $_config
  84. exit 0
  85. fi
  86. done
  87. # We used to support a number of other implicit .mozconfig locations. We now
  88. # detect if we were about to use any of these locations and issue an error if we
  89. # find any.
  90. for _config in "$topsrcdir/mozconfig.sh" \
  91. "$topsrcdir/myconfig.sh" \
  92. "$HOME/.mozconfig" \
  93. "$HOME/.mozconfig.sh" \
  94. "$HOME/.mozmyconfig.sh"
  95. do
  96. if test -f "$_config"; then
  97. 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
  98. exit 1
  99. fi
  100. done