Mk is a reboot of the Plan 9 mk command, which itself is a successor to make. It is a fork of mk by Daniel C. Jones.
If you have gccgo, you can build and install mk with make:
$ make
$ make install
You can also use go
to install mk with any Go implementation:
$ go get github.com/lenticularis39/mk
mk stays mostly faithful to Plan 9, but makes a few changes.
- A clean, modern implementation in Go.
- Parallel by default.
- Use Go regular expressions, which are perl-like, instead of Plan 9 regex.
- Regex matches are substituted into rule prerequisites with
$stem1
,$stem2
, etc., rather than\1
,\2
, etc. - Allow blank lines in recipes. A recipe is any indented block of text, and continues until a non-indented character or the end of the file.
- Add an 'S' attribute to execute recipes with programs other than sh. This way, you don't have to separate your six line python script into its own file. Just stick it directly in the mkfile.
mk [options] [target] ...
-f filename
Use the given file as the mkfile.-n
Dry run, print commands without actually executing.-r
Force building of the immediate targets.-a
Force building the targets and of all their dependencies.-p
Maximum number of jobs to execute in parallel (default: 8)-i
Show rules that will execute and prompt before executing.
Non-shell recipes are a major addition over Plan 9 mk. They can be used with the
S[command]
attribute, where command
is an arbitrary command that the recipe
will be piped into. For example, here's a recipe to add the read numbers from a
file and write their mean to another file. Unlike a typical recipe, it's written
in Julia.
mean.txt:Sjulia: input.txt
println(open("$target", "w"),
mean(map(parseint, eachline(open("$prereq")))))
Functional, but with some bugs and some unimplemented minor features.