The hmake compilation tool


Hmake is intended as a replacement for both hbcmake and nhc13make, and also for those complex ghc Makefiles (although I have not tested the ghc option yet). For those who are unfamiliar with hbcmake etc., the big advantage is that you don't have to write a Makefile - the tools extract dependencies automatically from your source files, and issue appropriate commands to rebuild your target. In particular, they know about .hi interface files - even though a source module has changed, if its interface file has not changed, then other modules which import it do not need to be recompiled.

The basic option summary is:

    Usage: hmake [-nhc13|-hbc|-ghc] [-q] [-n] [-g] [opts] target ...

Options

Most options are passed straight through to the appropriate compiler. However, hmake understands and strips the following options.

-nhc13
-hbc
-ghc
specify which compiler you want to use [default is nhc13].
-q Quiet - don't echo compilation commands.
-n Noexec - echo compilation commands but don't execute them.
-g Graph - show module dependency graph (implies -n).

Hmake also makes use of some compiler options if you specify them.

-d objdir Search for (and compile) object files in(to) a separate objdir.
-Pdir/ Search dir for prelude/stdlib interface files.
-Idir/ Search dir for imported modules - compile them if necessary, and link against the resulting .o files.
-idir/ Search dir for imported module interface files - but do not compile them, rather link against an archive .a file in that directory.

Some options are passed to the compiler's runtime system (using whatever underlying mechanism is appropriate for the particular compiler).

-[Hh]size Compiler's heap size.
-[ASV]size Compiler's stack size.
-B Compiler's garbage collector options.

You can force an option which would otherwise be interpreted by another part of the system to be passed to the compiler by enclosing it within +CTS ... -CTS delimiters. For example, with nhc13, to set the final executable's default heapsize rather than the compiler's heapsize, use +CTS -H4mb -CTS.

Recent improvements

Some improvements over the previous tools are:

  • You can store object files in a separate directory from your sources.
  • It understands cpp directives: this is particularly useful for imports which differ depending on which compiler you are using. For example,
            #if defined(__HBC__) || defined(__GLASGOW_HASKELL__)
            import Native
            #elsif __NHC__
            import Binary
            #endif
    
    The compiler symbols are defined automatically - you can also define other symbols with -Dsym[=val] on the commandline.
  • It automatically inserts the -cpp compiler option, but only for those modules which actually require it.
  • If you specify .o or .a files on the commandline, it simply links against them, rather than searching for source dependencies for them.

I'd welcome any bug reports, or ideas for other options or behaviours you would find useful. If you use ghc, please tell me how well (or otherwise) hmake works(!).


The latest updates to these pages are available on the WWW from http://www.cs.york.ac.uk/fp/nhc13/

1998.06.22
York Functional Programming Group
Malcolm.Wallace@cs.york.ac.uk