Sime makelike wrapper scripts support
Ron Yorston
rmy at pobox.com
Sun Jan 12 13:12:34 UTC 2020
Boris Kotov wrote:
>It would be really handy to have a simple Makefile-like wrapper scripts
>syntax just to execute some common commands on it:
If the Makefiles you want to execute are as simple as the example
you quoted (so you don't need things like make variables) the attached
script will munge a Makefile into a shell script and then run it.
To see the generated script run 'minimake -v non_target'.
Modern versions of BusyBox allow shell scripts to be embedded in the
binary. The script is compressed so in this case it only adds about
450 bytes to the size of the executable.
Ron
-------------- next part --------------
#!/bin/sh
MAKEFILE="Makefile"
if [ $# -gt 2 ] && [ "$1" = "-f" ]
then
MAKEFILE="$2"
shift
shift
fi
(
INCASE=0
while read -r REPLY
do
case $REPLY in
*:)
if [ $INCASE -eq 0 ]
then
printf "if [ \$# -eq 0 ]\n"
printf "then\n"
printf "\tTARGET=\"%s\"\n" "${REPLY%:}"
printf "else\n"
printf "\tTARGET=\"\$1\"\n"
printf "fi\n"
printf "case \"\$TARGET\" in\n"
else
printf "\t;;\n"
fi
printf "%s)\n" "${REPLY%:}"
INCASE=1
;;
"") ;;
*) printf "\t%s\n" "${REPLY##[ ]}";;
esac
done <"$MAKEFILE"
if [ $INCASE -eq 1 ]
then
printf "\t;;\n"
fi
printf "*)\n"
printf "\techo \"No rule to make target '\$1'\"\n"
printf "\t;;\n"
printf "esac\n"
) | sh -s "$@"
More information about the busybox
mailing list