• Stars
    star
    170
  • Rank 223,357 (Top 5 %)
  • Language
    Go
  • License
    Other
  • Created over 11 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

make remade

Logo

Mk is a reboot of the Plan 9 mk command, which itself is a successor to make. This tool is for anyone who loves make, but hates all its stupid bullshit.

Installation

  1. Install Go.
  2. Run go get github.com/dcjones/mk
  3. Make sure $GOPATH/bin is in your PATH.

Why Plan 9 mk is better than make

Way back in the 90s, some smart guys at Bell Labs got together and decided to write new operating system to replace Unix. The idea was to keep everything that was great about Unix, but totally disregard backwards compatibility in a quest for something better. The operating system they designed, Plan 9, had a lot of terrific ideas, and though some were cherry picked, the OS as a whole never really caught on.

Among the gems in Plan 9 was a rewrite of the venerable Unix make command, in the form of mk. Simply put, mk is make, but with a large collection of relatively minor improvements, adding up to something more consistent, elegant, and powerful. To name a few specifics:

  1. Recipes are delimited by any indentation, not tab characters in particular.
  2. Phony targets are handled separately from file targets. Your mkfile won't be broken by having a file named 'clean'.
  3. Attributes instead of weird special targets like .SECONDARY:.
  4. Special variables like $target, $prereq, and $stem in place of make's pointlessly cryptic $@, $^, and $*.
  5. In addition to suffix rules (e.g. %.o: %.c), mk has more powerful regular expression rules.
  6. Sane handling of rules with multiple targets.
  7. An optional attribute to delete targets when a recipe fails, so you aren't left with corrupt output.
  8. Plan 9 mkfiles can not only include other mkfiles, but pipe in the output of recipes. Your mkfile can configure itself by doing something like <|sh config.sh.
  9. A generalized mechanism to determine if a target is out of date, for when timestamps won't cut it.
  10. Variables are expanded in recipes only if they are defined. They way you usually don't have to escape $.

And much more! Read Maintaining Files on Plan 9 with Mk for good overview.

Improvements over Plan 9 mk

This mk stays mostly faithful to Plan 9, but makes a few (in my opinion) improvements.

  1. A clean, modern implementation in Go, that doesn't depend on the whole Plan 9 stack.
  2. Parallel by default. Modern computers can build more than one C file at a time. Cases that should not be run in parallel are the exception. Use -p=1 if this is the case.
  3. Use Go regular expressions, which are perl-like. The original mk used plan9 regex, which few people know or care to learn.
  4. Regex matches are substituted into rule prerequisites with $stem1, $stem2, etc, rather than \1, \2, etc.
  5. 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. (Similar to blocks in Python.)
  6. 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.
  7. Pretty colors.

Usage

mk [options] [target] ...

Options

  • -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

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")))))

Current State

Functional, but with some bugs and some unimplemented minor features. Give it a try and see what you think!

More Repositories

1

hat-trie

An efficient trie implementation.
C
252
star
2

fastq-tools

Small utilities for working with fastq sequence files.
C
114
star
3

coitrees

A very fast interval tree data structure
Rust
111
star
4

quip

Compressing next-generation sequencing data with extreme prejudice.
C
78
star
5

Judo.jl

A Julia document generator
Julia
57
star
6

proseg

Probabilistic cell segmentation for in situ spatial transcriptomics
Rust
44
star
7

isolator

Rapid and robust analysis of RNA-Seq experiments.
C
32
star
8

colormake

colorize GNU make output
Python
30
star
9

polee

Analyzing RNA-Seq with approximate likelihood
Julia
26
star
10

subsample

Randomly sample lines from massive text files efficiently
C
17
star
11

RecursiveSparseBlocks.jl

julia interface to the librsb sparse matrix library
Julia
16
star
12

Skia.jl

Experimental skia bindings
Julia
11
star
13

seqbias

An R package to correct for sequence bias in RNA-Seq experiments.
C++
10
star
14

fastlog

A faster, reduced-precision logarithm function.
C
8
star
15

Switch.jl

A C-style switch statement for Julia
Julia
8
star
16

vanity

scRNA-Seq normalization for the vain
Python
7
star
17

cbgb

computational biology grab-bag: messy one-off scripts for a variety of tasks
C
6
star
18

Zlib.jl

zlib bindings for Julia
Julia
6
star
19

maxspin

Quantifying spatial information in spatial transcriptomics
Jupyter Notebook
5
star
20

PoleeClassifier.jl

Julia
5
star
21

color.jl

Pretty colors for Julia
Julia
5
star
22

sls

Stochastic L-Systems in Python
Python
5
star
23

Showoff.jl

Nicely format an array of n things for tables and plots
Julia
5
star
24

LazySequences.jl

Lazy sequences.
Julia
4
star
25

ragel-julia

A Julia backend for Ragel
C++
4
star
26

SpuriousCoexpression.jl

Benchmarking tool for spatial transcriptomics segmentation
Julia
3
star
27

ulam-death-spiral

Exposing the depravity of the natural numbers.
CoffeeScript
3
star
28

isolator-paper

The Isolator Paper
Jupyter Notebook
3
star
29

gtf-parse-off

Experiments with parsing gene transfer format
Ragel in Ruby Host
3
star
30

seqsim

A simplistic RNA-Seq simulator.
C++
2
star
31

vim-mk

Vim syntax for mk
Vim Script
2
star
32

AnnDatas.jl

Julia compatibility for the anndata python module
Julia
2
star
33

quip-paper

A paper describing and evaluating the quip compression algorithm.
C
2
star
34

HATTries.jl

julia hat-trie bindings
Julia
1
star
35

GatedLinearNetworks.jl

A gaussian gated linear networks implementation
Julia
1
star
36

gadfly-static-html

Static HTML documentation for Gadfly
JavaScript
1
star
37

dotfiles

Vim Script
1
star
38

peakolator

World's fastest genomic segmentation algorithm.
C
1
star
39

Stepwell.jl

Julia
1
star
40

quip-website

A very simple website for quip.
JavaScript
1
star
41

peakolator-legacy

Some old code.
C++
1
star
42

julia-minimalist-vim

Alternate vim syntax definitions for Julia
Vim Script
1
star