| 1 |
#!/bin/sh -e |
| 2 |
|
| 3 |
SRCDIR=$1 ; shift |
| 4 |
OBJDIR=$1 ; shift |
| 5 |
dirs=$1 |
| 6 |
|
| 7 |
if test $(cd ${SRCDIR} ; pwd) = $(cd ${SRCDIR} ; cd ${OBJDIR} ; pwd) |
| 8 |
then |
| 9 |
echo "failed. ${OBJDIR} == ${SRCDIR}" |
| 10 |
exit 1 |
| 11 |
fi |
| 12 |
|
| 13 |
cd ${SRCDIR} |
| 14 |
mkdir -p ${OBJDIR} |
| 15 |
|
| 16 |
# Generate sub-directories first |
| 17 |
|
| 18 |
find ${dirs} -type d -print | while read dirname |
| 19 |
do |
| 20 |
if test -r $dirname/Makefile |
| 21 |
then |
| 22 |
( |
| 23 |
echo Generating ${OBJDIR}/$dirname/Makefile |
| 24 |
cd ${OBJDIR} |
| 25 |
mkdir -p $dirname |
| 26 |
cd $dirname |
| 27 |
|
| 28 |
top_builddir=$(echo $dirname | sed -e 's;[^/]*;..;g') |
| 29 |
|
| 30 |
cat <<EOF >Makefile.tmp |
| 31 |
# Generated by $0 |
| 32 |
|
| 33 |
# define autoconf style names such as srcdir, builddir, abs_srcdir, |
| 34 |
# top_srcdir, abs_top_srcdir, ... |
| 35 |
include ${top_builddir}/../mk/dirs.mk |
| 36 |
|
| 37 |
include \${srcdir}/Makefile |
| 38 |
EOF |
| 39 |
mv Makefile.tmp Makefile |
| 40 |
) |
| 41 |
fi |
| 42 |
done |
| 43 |
|
| 44 |
# OBJDIR makefile is just different enough |
| 45 |
|
| 46 |
cat <<EOF > $OBJDIR/Makefile.tmp |
| 47 |
# Generated by $0 |
| 48 |
|
| 49 |
# define autoconf style names such as srcdir, builddir, abs_srcdir, |
| 50 |
# top_srcdir, abs_top_srcdir, ... |
| 51 |
include ../mk/dirs.mk |
| 52 |
|
| 53 |
programs config man install clean install-programs: |
| 54 |
set -e ; \\ |
| 55 |
for d in \$(SUBDIRS) ; \\ |
| 56 |
do \\ |
| 57 |
( cd \$\$d && \$(MAKE) \$@ ) ; \\ |
| 58 |
done |
| 59 |
EOF |
| 60 |
|
| 61 |
mv $OBJDIR/Makefile.tmp $OBJDIR/Makefile |