A version of `make` that supports (almost) all Erlang source types

I decided to make a fairly small extension to the `make` module:

It addresses two limitations that I’ve personally found a bit annoying:

  • It supports all file types that can be built using `erlc` (except `.idl`)
  • It allows for selective loading of compiled modules in the `Emakefile`

The latter is useful if you have parse-transforms. E.g.

uwmbp:plain_fsm uwiger$ cat Emakefile
{“src/plain_fsm_xform.erl”, [debug_info, {i, “include/”}, {outdir, “ebin/”}, load]}.
{“src/*”,  [debug_info, {i, “include/”}, {outdir, “ebin/”}]}.

uwmbp:plain_fsm uwiger$ erl -make
Recompile: src/plain_fsm_xform
Recompile: src/plain_fsm
Recompile: src/fsm_example
src/fsm_example.erl: undefined parse transform ‘plain_fsm_xform’

With the suggested change:

uwmbp:plain_fsm uwiger$ ~/git/otp/bin/erl -make
Recompile: src/plain_fsm_xform.erl
Recompile: src/plain_fsm.erl
Recompile: src/fsm_example.erl
src/fsm_example.erl:26:2: Warning: behaviour plain_fsm undefined
% 26| -behaviour(plain_fsm).
% | ^

(The behavior warning is a different, path-related, issue)

Re. the first item, it seems reasonable to me that Erlang’s `make` should support at least the different source types supported by `erlc`. This is a minimalistic way of achieving that.

From the test suite:

uwmbp:non_erl uwiger$ mkdir out
uwmbp:non_erl uwiger$ ls out/
uwmbp:non_erl uwiger$ cat Emakefile
{“../calx_{lexer,parser}.?rl”, [{erlc, “-o out”}]}.
uwmbp:non_erl uwiger$ $ERL_TOP/bin/erl -make
Recompile: ../calx_parser.yrl
Recompile: ../calx_lexer.xrl
uwmbp:non_erl uwiger$ ls out/
calx_lexer.erl calx_parser.erl