[Sam Ravnborg]
> > This does not stop any attemp to make a simple wrapper that
> > creates and maintain a BUILD_TREE.
> > To check timestamps and link accordinly should not take too much
> > time, at least not at the second run.

[Greg Banks]
> Ok, why don't you and Peter Samuelson get together, create such a thing and
> we can compare it against kbuild2.5?  If it's simple and a win, great!

Not sure about a win - but the following is certainly simple.  It took
me 5 or 10 minutes.  Perhaps there are cases it doesn't handle, but
I'm thinking it should work for most things.

TOTALLY UNTESTED, since it's intended solely as a proof of concept.
Also, I don't have any shadow trees already set up.

Peter


#!/bin/sh
# mkshadow: a hack to make a build tree from shadow source trees
#
# If something doesn't like the symlinks, replace 'ln -s' with 'ln'.
# Then you get hard links which should work anywhere, but which easily
# get out of sync with reality when you patch / edit the original
# files, depending on your editor.

if [ -z "$KBUILD_SRCTREE_000" ]; then
  echo "no KBUILD_SRCTREE_000, nothing to do"
  exit 0
fi

obj=$KBUILD_OBJTREE
test -n "$obj" || obj=.
src=$(set | sed -ne '/^KBUILD_SRCTREE_[0-9][0-9][0-9]=/s//p')
test -n "$src" || src=.

cd $obj
for s in $src; do
  if [ ${s#/} = $s ]; then
    echo "source tree '$s' is not absolute"
    exit 1
  elif [ $(cd $s; pwd -P) = $(pwd -P) ]; then
    echo "source tree $(pwd -P) is also the object tree"
    echo "this is not allowed"
    exit 1
  fi
  (cd $s; find * -type d) | xargs mkdir -p;
  (cd $s;
   exec find * \( -type d -exec mkdir \{} \; \) -o \
     \( -type f ! -name \*.prepend ! -name \*.append -print \) ) |
    while read f; do
      rm -f $f;
      ln -s $s/$f $f
    done
done

for s in $src; do
  (cd $s;
   exec find * -type f -name \*.prepend ) |
    while read f; do
      base=${f%.prepend}
      if [ -f $base ]; then mv $base $base.; else touch $base.; fi
      cat $s/$f $base. > $base
      rm $base.
    done
  (cd $s;
   exec find * -type f -name \*.append ) |
    while read f; do
      base=${f%.append}
      if [ -f $base ]; then mv $base $base.; else touch $base.; fi
      cat $s/$f $base. > $base
      rm $base.
    done
done


-------------------------------------------------------
This sf.net email is sponsored by: Jabber Inc.
Don't miss the IM event of the season | Special offer for OSDN members! 
JabConf 2002, Aug. 20-22, Keystone, CO http://www.jabberconf.com/osdn
_______________________________________________
kbuild-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/kbuild-devel

Reply via email to