Boris wrote:
>Sure, to avoid any confusion I would't use the name "Makefile".
>"Minimake" sounds clear to me, and the cli `mim`.
I like the command name 'mim' (which Merriam-Webster tells me is an
adjective meaning 'affectedly shy or modest'). By extension I think the
file should be called 'Mimfile'. This avoids any misleading reference to
make. As Eli correctly points out (and I should have) the script misses
the main distinguishing feature of make, that it handles dependencies.
I've tidied up the script a bit. Its usage is:
mim [-f FILE] [SHELL_OPTIONS] [TARGET] ...
Some implementation details are exposed which differ from make:
- The default FILE is 'Mimfile' but an alternative name can be provided.
- SHELL_OPTIONS are consumed by the shell that runs the generated script.
'-x' and '-v' might be useful.
- Unlike with make arguments after TARGET aren't treated as additional
targets, instead they're made available to the script that's run.
Essentially mim is a way to specify commands that take the form:
mim sub_command sub_command_options...
The new script is attached. I've also made a patch to incorporate the
script into BusyBox, though whether it will prove acceptable is out of
my hands.
Ron
#!/bin/sh
MIMFILE="Mimfile"
if [ $# -ge 2 ] && [ "$1" = "-f" ]
then
MIMFILE="$2"
shift 2
fi
if [ ! -f "$MIMFILE" ]
then
printf "Unable to open '%s'\n" "$MIMFILE"
exit 1
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 "\tshift\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 <"$MIMFILE"
if [ $INCASE -eq 1 ]
then
printf "\t;;\n"
fi
printf "*)\n"
printf "\techo \"Unknown command '\$TARGET'\"\n"
printf "\texit 1\n"
printf "\t;;\n"
printf "esac\n"
) | sh -s "$@"
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox