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

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

Re: inheriting makefiles


From: Johan Bezem
Subject: Re: inheriting makefiles
Date: Fri, 20 Sep 2002 12:09:00 +0200

Hi Mike,

I've done it both ways:
- Since my makefiles are called recursively from the root dir up to the
leaves, I use a construct like this:
  # Compile the include path to refer to all include
  # directories recursively; use $(wildcard to filter-out
  # non-existing directories
  export YT_INCLUDEPATH := $(strip $(wildcard $(YT_SRCVPATH)/include
$(YT_INCLUDEPATH)))
This works, since each recursive instance enhances YT_INCLUDEPATH with a new
directory, if it exists.
- And then, I needed to know where the root of the project is, whenever
make is initially run from a directory somewhere in the middle. Make needs
help, in this case, so I wrote a small shell script, using bash:
#!/usr/local/bin/bash
pvarroot=.
while [ ! ${pvarroot} -ef / ]; do
  if [ -r ${pvarroot}/make/main.mk ]; then
    break;
  fi
  pvarroot=${pvarroot}/..
done;
if [ ! ${pvarroot} -ef / ]; then
  echo ${pvarroot};
fi
As docs: The root is singled out by looking for a subdirectory called
'make' containing my main make-include file 'main.mk'; fool-proof enough
for my purposes.

BTW, CURDIR is set once for each instance of make, set to the current
directory (cwd) where the instance has been started. So, if you only include
makefiles, and never spawn another instance of the process 'make', CURDIR
will remain the same...
I start with one make instance in a certain directory, and for each
subdirectory containing a file 'Makefile' a new process is started from that
directory. Then the above techniques work.

HTH,

Johan Bezem
CSK Software AG


Mike Maxwell wrote:
> 
> I wrote:
> > 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.
> 
> ...and also because $(CURDIR) apparently isn't defined at 'include' time
> (only after 'make' reads in all the makefiles).
> 
> BTW, I forgot to mention--I'm running Gnu make v3.75 under Solaris v7.





reply via email to

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