/build/unix/print-depth-path.sh

http://github.com/zpao/v8monkey · Shell · 89 lines · 34 code · 4 blank · 51 comment · 4 complexity · 4d73511412aeefa7e3131635cf346572 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) 1998
  21. # the Initial Developer. All Rights Reserved.
  22. #
  23. # Contributor(s):
  24. # jim_nance@yahoo.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. # This script will print the depth path for a mozilla directory based
  41. # on the info in Makefile
  42. #
  43. # It's a hack. It's brute force. It's horrible.
  44. # It don't use Artificial Intelligence. It don't use Virtual Reality.
  45. # It's not perl. It's not python. But it works.
  46. #
  47. # Usage: print-depth-path.sh
  48. #
  49. # Send comments, improvements, bugs to jim_nance@yahoo.com
  50. #
  51. # Make sure a Makefile exists
  52. if [ ! -f Makefile ]
  53. then
  54. echo
  55. echo "There ain't no 'Makefile' over here: $pwd, dude."
  56. echo
  57. exit
  58. fi
  59. # awk can be quite primitave. Try enhanced versions first
  60. for AWK in gawk nawk awk; do
  61. if type $AWK 2>/dev/null 1>/dev/null; then
  62. break;
  63. fi
  64. done
  65. $AWK -v PWD=`pwd` '
  66. {
  67. if($1 == "DEPTH") {
  68. DEPTH=$0
  69. }
  70. }
  71. END {
  72. sub("^.*DEPTH.*=[ \t]*", "", DEPTH)
  73. dlen = split(DEPTH, darray, "/")
  74. plen = split(PWD, parray, "/")
  75. fsep=""
  76. for(i=plen-dlen; i<=plen; i++) {
  77. printf("%s%s", fsep, parray[i])
  78. fsep="/"
  79. }
  80. printf("\n")
  81. }' Makefile