aboutsummaryrefslogtreecommitdiffstats
path: root/mk/meta2deps.sh
diff options
context:
space:
mode:
Diffstat (limited to 'mk/meta2deps.sh')
-rwxr-xr-xmk/meta2deps.sh95
1 files changed, 83 insertions, 12 deletions
diff --git a/mk/meta2deps.sh b/mk/meta2deps.sh
index 9c76b77964dd..f63aee329b6b 100755
--- a/mk/meta2deps.sh
+++ b/mk/meta2deps.sh
@@ -49,8 +49,8 @@
# The output, is a set of absolute paths with "SB" like:
#.nf
#
-# $SB/obj-i386/junos/gnu/lib/csu
-# $SB/obj-i386/junos/gnu/lib/libgcc
+# $SB/obj-i386/bsd/gnu/lib/csu
+# $SB/obj-i386/bsd/gnu/lib/libgcc
# $SB/obj-i386/bsd/include
# $SB/obj-i386/bsd/lib/csu/i386-elf
# $SB/obj-i386/bsd/lib/libc
@@ -77,9 +77,9 @@
# RCSid:
-# $Id: meta2deps.sh,v 1.5 2013/02/10 19:21:46 sjg Exp $
+# $Id: meta2deps.sh,v 1.6 2013/05/11 05:16:26 sjg Exp $
-# Copyright (c) 2010-2012, Juniper Networks, Inc.
+# Copyright (c) 2010-2013, Juniper Networks, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -115,16 +115,89 @@ meta2dirs() {
sort -u
}
+add_list() {
+ sep=' '
+ suffix=
+ while :
+ do
+ case "$1" in
+ "|") sep="$1"; shift;;
+ -s) suffix="$2"; shift 2;;
+ *) break;;
+ esac
+ done
+ name=$1
+ shift
+ eval list="\$$name"
+ for top in "$@"
+ do
+ case "$sep$list$sep" in
+ *"$sep$top$suffix$sep"*) continue;;
+ esac
+ list="${list:+$list$sep}$top$suffix"
+ done
+ eval "$name=\"$list\""
+}
+
meta2deps() {
DPDEPS=
+ SRCTOPS=$SRCTOP
+ OBJROOTS=
while :
do
case "$1" in
*=*) eval export "$1"; shift;;
+ -a) MACHINE_ARCH=$2; shift 2;;
+ -m) MACHINE=$2; shift 2;;
+ -C) CURDIR=$2; shift 2;;
+ -H) HOST_TARGET=$2; shift 2;;
+ -S) add_list SRCTOPS $2; shift 2;;
+ -O) add_list OBJROOTS $2; shift 2;;
+ -R) RELDIR=$2; shift 2;;
+ -T) TARGET_SPEC=$2; shift 2;;
*) break;;
esac
done
+ _th= _o=
+ case "$MACHINE" in
+ host) _ht=$HOST_TARGET;;
+ esac
+
+ for o in $OBJROOTS
+ do
+ case "$MACHINE,/$o/" in
+ host,*$HOST_TARGET*) ;;
+ *$MACHINE*|*${TARGET_SPEC:-$MACHINE}*) ;;
+ *) add_list _o $o; continue;;
+ esac
+ for x in $_ht $TARGET_SPEC $MACHINE
+ do
+ case "$o" in
+ "") continue;;
+ */$x/) add_list _o ${o%$x/}; o=;;
+ */$x) add_list _o ${o%$x}; o=;;
+ *$x/) add_list _o ${o%$x/}; o=;;
+ *$x) add_list _o ${o%$x}; o=;;
+ esac
+ done
+ done
+ OBJROOTS="$_o"
+
+ case "$OBJTOP" in
+ "")
+ for o in $OBJROOTS
+ do
+ OBJTOP=$o${TARGET_SPEC:-$MACHINE}
+ break
+ done
+ ;;
+ esac
+ src_re=
+ obj_re=
+ add_list '|' -s '/*' src_re $SRCTOPS
+ add_list '|' -s '*' obj_re $OBJROOTS
+
[ -z "$RELDIR" ] && unset DPDEPS
tf=/tmp/m2d$$-$USER
rm -f $tf.*
@@ -166,8 +239,7 @@ meta2deps() {
esac
case "$op,$path" in
- *.dirdep) continue;;
- W,*srcrel) continue;;
+ W,*srcrel|*.dirdep) continue;;
C,*)
case "$path" in
/*) cwd=$path;;
@@ -182,8 +254,7 @@ meta2deps() {
;;
*) dir=${path%/*}
case "$path" in
- $SB/*|${SB_BACKING_SB:-$SB}/*) ;;
- $SB_OBJROOT*) ;;
+ $src_re|$obj_re) ;;
/*/stage/*) ;;
/*) continue;;
*) for path in $ldir/$path $cwd/$path
@@ -215,7 +286,7 @@ meta2deps() {
esac
case "$dir" in
${CURDIR:-.}|${CURDIR:-.}/*|"") continue;;
- $SRCTOP/*|${SB_BACKING_SB:-$SB}/src/*)
+ $src_re)
# avoid repeating ourselves...
case "$DPDEPS,$seensrc," in
,*)
@@ -241,7 +312,7 @@ meta2deps() {
[ -f $path ] || continue
case "$dir" in
$CWD) continue;; # ignore
- $SRCTOP/*|${SB_BACKING_SB:-$SB}/src/*)
+ $src_re)
seenit="$seenit,$seen"
echo $dir >> $tf.srcdep
case "$DPDEPS,$reldir,$seensrc," in
@@ -267,7 +338,7 @@ meta2deps() {
fi
seenit="$seenit,$seen"
case "$dir" in
- $SB/*|${SB_OBJROOT:-$SB/}*|${SB_BACKING_SB:-$SB}/*)
+ $obj_re)
echo $dir;;
esac
done > $tf.dirdep
@@ -283,7 +354,7 @@ meta2deps() {
# qualified with .<machine> as needed.
# We strip .$MACHINE though
xargs cat < $f | sort -u |
- sed "s,^# ,,;s,^,$OBJTOP/,;s,\.$MACHINE\$,,"
+ sed "s,^# ,,;s,^,$OBJTOP/,;s,\.${TARGET_SPEC:-$MACHINE}\$,,;s,\.$MACHINE\$,,"
;;
*) sort -u $f;;
esac