cvs commit: fptools/ghc/driver/ghc Makefile fptools/ghc/driver/ghci Makefile - PS

Marcin 'Qrczak' Kowalczyk qrczak@knm.org.pl
28 Jun 2001 21:22:10 GMT


Thu, 28 Jun 2001 13:09:52 +1000, Manuel M. T. Chakravarty <chak@cse.unsw.edu.au> pisze:

> BTW, I found the following article very interesting:
> 
>   http://www.canb.auug.org.au/~millerp/rmch/recu-make-cons-harm.html
> 
> It's title is ``Recursive Make Considered Harmful.'' :-)

After reading that article I switched to a single Makefile in QForeign
and it indeed made Makefiles more clear and faster.

Instead of including a common makefile with rules in each submakefile,
the central Makefile includes definitions of variables from each
subdirectory. Variables are processed according to their names.

For example libraries for tests/CursesTest program are stored in
variable called LDLIBS-tests/CursesTest, and libraries common for all
files in tests subdirectory are stored in variable called LDLIBS-tests.
They are gathered using a macro:
    local = $($(1)-$(patsubst %/,%,$(dir $(2)))) $($(1)-$(2))
and then:
    LDLIBS = $(call local,LDLIBS,$@)
so $(LDLIBS) expands to whatever libraries are needed for the file
being currently linked.

The biggest problem with a central Makefile is when the set of files
to process depends on previous runs of commands. I.e. when Makefile
rules are not declarative :-)

-- 
 __("<  Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK