PageRenderTime 10ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/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#
41# This script will print the depth path for a mozilla directory based
42# on the info in Makefile
43#
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.
47#
48# Usage: print-depth-path.sh
49#
50# Send comments, improvements, bugs to jim_nance@yahoo.com
51# 
52
53# Make sure a Makefile exists
54if [ ! -f Makefile ]
55then
56	echo
57	echo "There ain't no 'Makefile' over here: $pwd, dude."
58	echo
59
60	exit
61fi
62
63# awk can be quite primitave.  Try enhanced versions first
64for AWK in gawk nawk awk; do
65    if type $AWK 2>/dev/null 1>/dev/null; then
66        break;
67    fi
68done
69
70$AWK -v PWD=`pwd` '
71{
72    if($1 == "DEPTH") {
73        DEPTH=$0
74    }
75}
76
77END {
78    sub("^.*DEPTH.*=[ \t]*", "", DEPTH)
79    dlen = split(DEPTH, darray, "/")
80    plen = split(PWD,   parray, "/")
81
82    fsep=""
83    for(i=plen-dlen; i<=plen; i++) {
84        printf("%s%s", fsep, parray[i])
85        fsep="/"
86    }
87    printf("\n")
88}' Makefile
89