[erlang-patches] Producing dependencies Makefile for Erlang using erlc(1)

Jean-Sébastien Pédron <>
Wed Oct 29 16:12:33 CET 2008

Hash: SHA1


When using erlc(1) and standard Makefiles to compile Erlang source
files, there's currently no way to track header dependencies. Thus, if a
header is modified, a module that depends on it will be recompiled only
if the dependency is explicitly indicated in the Makefile. This becomes
problematic when the header is external (for instance, a header from
another application, such as xmerl.hrl).

Attached is a patch that adds support for producing dependencies
Makefiles to erlc(1) and compiler(3). It was modeled after GCC.

For example, let's take the following module:

The command "erlc -M mod1.erl" will output:
    mod1.beam: mod1.erl header1.hrl

The patch adds the following options to erlc(1) and compiler(3):

    -M          generate a rule describing dependencies; output on
    -MF File    rule(s) is(are) written to `File'.
    -MT Target  change the name of the rule emitted.
    -MQ Target  same as -MT but quote special characters for make(1).
    -MG         consider missing headers as generated files and add the
                to the dependencies
    -MP         add a phony target for each dependency.
    -MD         same as -M -MT file.Pbeam

They're the same as GCC. The following options are not supported:

    -MM         ignore system headers
    -MMD        same as -MD but ignore system headers

I choose to keep the same names as GCC because I'm working on Erlang
support in Automake and it wants to use these options. Regarding
compiler(3), options could have a more Erlang-fashion name.

The patch, against R12B-4, includes the documentation updates. But I
don't know how to make it, so it's untested.


PS: I already sent an older patch to erlang-questions@ more than a year
ago. The attached patch obsoletes it.

- --
Jean-Sébastien Pédron

PGP Key: http://www.dumbbell.fr/pgp/pubkey.asc

Version: GnuPG v1.4.9 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: otp_src_R12B-4-makedep-d.patch
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20081029/3c3a79ab/attachment.ksh>

More information about the erlang-patches mailing list