help-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

inheriting makefiles


From: Mike Maxwell
Subject: inheriting makefiles
Date: Wed, 11 Sep 2002 14:21:43 -0400

I want a makefile in a particular directory to recursively include all the
makefiles in the dirs above it (up to my home dir), so that each directory's
makefile inherits the definitions from the makefile in its parent
directory--a simple inheritance hierarchy.  I can't figure out how to do
this.

The obvious way would seem to be to put something like the ff. in each
makefile, near the top:

    ifndef LANG_MAKEFILE #Don't include this makefile > once
    LANG_MAKEFILE = Languages/makefile

    #Get defns from parent makefile:
    include ../makefile

    <defns, recipes etc. go here>

    endif #ifndef LANG_MAKEFILE

The ifndef...endif construct is to prevent multiple inclusions of the _same_
makefile, similar to what is often done in .h files.  Of course the
particular defn is different at each level of the directory structure.

The obvious way doesn't work.  I get the immediate parent makefile included,
but nothing more.  Apparently 'include' doesn't actually chdir to the parent
directory, so "../makefile" always refers to the same file, namely one in
the immediate parent dir of the original makefile.

Maybe there's some tricky way to do this with $(CURDIR), although I don't
see what it is at the moment, since there doesn't seem to be any function to
strip off a directory level at a time.

Suggestions?
--
     Mike Maxwell
     Linguistic Data Consortium
     maxwell@ldc.upenn.edu








reply via email to

[Prev in Thread] Current Thread [Next in Thread]