Merge from m-c to fix last bustage.
[mozilla-central.git] / build / unix / print-depth-path.sh
blob4d22d55b0dcc11d8ce562be0b0767b40dd26ff8f
1 #!/bin/sh
3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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.
16 # The Original Code is mozilla.org code.
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.
23 # Contributor(s):
24 # jim_nance@yahoo.com
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.
38 # ***** END LICENSE BLOCK *****
41 # This script will print the depth path for a mozilla directory based
42 # on the info in Makefile
44 # It's a hack. It's brute force. It's horrible.
45 # It don't use Artificial Intelligence. It don't use Virtual Reality.
46 # It's not perl. It's not python. But it works.
48 # Usage: print-depth-path.sh
50 # Send comments, improvements, bugs to jim_nance@yahoo.com
53 # Make sure a Makefile exists
54 if [ ! -f Makefile ]
55 then
56 echo
57 echo "There ain't no 'Makefile' over here: $pwd, dude."
58 echo
60 exit
63 # awk can be quite primitave. Try enhanced versions first
64 for AWK in gawk nawk awk; do
65 if type $AWK 2>/dev/null 1>/dev/null; then
66 break;
68 done
70 $AWK -v PWD=`pwd` '
72 if($1 == "DEPTH") {
73 DEPTH=$0
77 END {
78 sub("^.*DEPTH.*=[ \t]*", "", DEPTH)
79 dlen = split(DEPTH, darray, "/")
80 plen = split(PWD, parray, "/")
82 fsep=""
83 for(i=plen-dlen; i<=plen; i++) {
84 printf("%s%s", fsep, parray[i])
85 fsep="/"
87 printf("\n")
88 }' Makefile