#!/bin/sh
# This script will munge the output of "make -n install" into a Bourne
# shell installer script.  It is useful for simplyfing the top level
# Makefiles of multi-directory binary distributions.  Originally written
# for the Linux procps suite by Charles Blake (cblake@bbn.com)

SCRIPT="${1:-do_install}"

exec > $SCRIPT

echo '#!/bin/sh -x
# This is a mkinstall automatically generated installer script.
# There may be some inefficiencies involving subshells doing nothing
# and there may be other time consuming building rules to exclude, but it
# works for most things and subshells are cheap.
'

make -n install                                       |
    sed -e 's/^make.*ntering dir.*`\(.*\).$/(cd \1/g' \
        -e 's/^make.*eaving dir.*$/)/g'               |
    egrep -v '^cc|^gcc|^CC|^g++|^ar|^make'

chmod 755 $SCRIPT
