1#!/bin/sh
2srcdir=`(cd $1 && pwd)`
3builddir=$2
4pattern='[ 	]*REQUIRES[ 	]*=' # Each [...] has a space and a tab
5find "$srcdir"/src/* -name .svn -prune -o -name build-system -prune \
6   -o -name 'Makefile.*.mk' -print \
7   | while read x; do
8      echo "\$(builddir)/Makefile.mk: \$(wildcard $x)" >&3
9      unmet=''
10      for r in `sed -ne "s/^$pattern//p" $x`; do
11         [ -f $builddir/../status/$r.enabled ]  ||  unmet="$unmet $r"
12      done
13      if [ -n "$unmet" ]; then
14         echo
15         echo "### Skipping $x per unmet requirement(s):$unmet"
16         echo
17         continue
18      fi
19      echo
20      echo "### Extra macro definitions from $x"
21      echo
22      echo "#line 1 \"$x\""
23      sed -e "s/^\($pattern\)/# \\1/" "$x"
24   done >> "$builddir/Makefile.mk" 3>"$builddir/Makefile.mk.d"
25"$srcdir"/scripts/common/impl/report_duplicates.awk \
26   src="$srcdir/src/build-system/Makefile.mk.in" "$builddir/Makefile.mk"
27