Tom Browder <tom.brow...@gmail.com> wrote:
> On Fri, Jun 5, 2009 at 14:45, Paul Jarc <p...@po.cwru.edu> wrote:
>> Change the subdirectory Makefile to use:
>> % :
>>      ( cd $(MASTERDIR); $(MAKE) RUNDIR=`pwd` $@ )
>
> Thanks, Paul, but that didn't work, probably because in the top
> Makefile the RUNDIR is in relative form while your construction puts
> it in absolute form.

In that case:
% :
        cd $(MASTERDIR) && \
        pwd=`$(MASTERDIR)/relative-pwd` &&
        $(MAKE) RUNDIR="$${pwd?}" $@

Where $(MASTERDIR)/relative-pwd is this script:

#!/bin/sh
topdir=`dirname "$0"` &&
topdir=`(cd "${topdir?}" && pwd -P)` &&
subdir=`pwd -P` &&
case ${subdir?}/ in
  "${topdir?}"/*)
    length=`wc -c <<EOT
${topdir?}
EOT
` &&
    length=`expr ${length?} + 1` &&
    cut -c "${length?}"- <<EOT
${subdir?}
EOT
    ;;
  *)
    echo "Sorry, you're outside my jurisdiction." >&2 &&
    exit 1;;
esac


Reply via email to