blob: dabd404f57365d3e71d5bcc70de26353aff7c783 [file] [log] [blame]
Christian Lavoieafc6d8f2011-02-20 02:39:19 +00001#!/usr/bin/env bash
2# Copyright 2009 The Go Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style
4# license that can be found in the LICENSE file.
5
6OUT="Make.deps"
7TMP="Make.deps.tmp"
8
9if [ -f $OUT ] && ! [ -w $OUT ]; then
10 echo "$0: $OUT is read-only; aborting." 1>&2
11 exit 1
12fi
13
14# Get list of directories from Makefile
15dirs=$(sed '1,/^DIRS=/d; /^$/,$d; s/\\//g' Makefile)
16dirs2=$(sed '1,/^DIRS=/d; /^$/,$d; s/\\//g' $GOROOT/src/pkg/Makefile)
17dirpat=$(echo $dirs $dirs2 | sed 's/ /|/g; s/.*/^(&)$/')
18
19for dir in $dirs; do (
20 cd $dir || exit 1
21
22 sources=$(sed -n 's/\.go\\/.go/p' Makefile)
23 sources=$(ls $sources 2> /dev/null) # remove .s, .c, etc.
24
25 deps=$(
26 sed -n '/^import.*"/p; /^import[ \t]*(/,/^)/p' $sources /dev/null |
27 cut -d '"' -f2 |
28 egrep "$dirpat" |
29 grep -v "^$dir\$" |
30 sed 's/$/.install/' |
31 sort -u
32 )
33
34 echo $dir.install: $deps
35) done > $TMP
36
37for dir in $dirs2; do (
38 echo $dir.install: \${GOROOT}/pkg/\${GOOS}_\${GOARCH}/${dir}.a
39) done >> $TMP
40
41mv $TMP $OUT