Backed out changeset 3732f69b6d81 (bug 843019) for mochitest-bc failures.
[gecko.git] / build / unix / print-depth-path.sh
blob056cb4c616c57836e820368caf97fdcd34041cd1
1 #!/bin/sh
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This script will print the depth path for a mozilla directory based
9 # on the info in Makefile
11 # It's a hack. It's brute force. It's horrible.
12 # It don't use Artificial Intelligence. It don't use Virtual Reality.
13 # It's not perl. It's not python. But it works.
15 # Usage: print-depth-path.sh
17 # Send comments, improvements, bugs to jim_nance@yahoo.com
20 # Make sure a Makefile exists
21 if [ ! -f Makefile ]
22 then
23 echo
24 echo "There ain't no 'Makefile' over here: $pwd, dude."
25 echo
27 exit
30 # awk can be quite primitave. Try enhanced versions first
31 for AWK in gawk nawk awk; do
32 if type $AWK 2>/dev/null 1>/dev/null; then
33 break;
35 done
37 $AWK -v PWD=`pwd` '
39 if($1 == "DEPTH") {
40 DEPTH=$0
44 END {
45 sub("^.*DEPTH.*=[ \t]*", "", DEPTH)
46 dlen = split(DEPTH, darray, "/")
47 plen = split(PWD, parray, "/")
49 fsep=""
50 for(i=plen-dlen; i<=plen; i++) {
51 printf("%s%s", fsep, parray[i])
52 fsep="/"
54 printf("\n")
55 }' Makefile