help-make
[Top][All Lists]
Advanced

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

A behavior I wonder about


From: Soren A
Subject: A behavior I wonder about
Date: Thu, 12 Sep 2002 06:17:06 +0000 (UTC)
User-agent: Xnews/L5

Hello,

Using GNU 'make' in various unusual ways, I have discovered a thing that
seemed a bit odd to me at first. 

If I want to access, from inside a Makefile, the directories which are
going to be searched for included makefiles (via the 'include'
directive), I may look at the built-in macro MAKEFLAGS or MFLAGS. Is
there any other possibility that I missed in the documentation? It would
be cool if there was a macro like "MAKEDIRS" that could be checked. 

Assuming that what I know is all there is to know about accessing the
'include' dirs, then ... what I might get for MAKEFLAGS is something
that looks like this: 

 --warn-undefined-variables -wI /cdv/g/src/common-vmk

and what I have in my environment is put there by a statement that looks
like this: 

export MAKEFLAGS="--unix --warn-undefined-variables --print-directory \
--include-dir=/cdv/g/src/common-vmk"

There's an anomaly in that 'make' seems to drop the '--print-directory'
flag entirely. Maybe that's documented so let's skip that for the
moment. 

What 'make' seems to do is to create a string that embodies the most
compressed, brief possible form the options statement could take. What
is mostly of interest to me is that the single-letter options 'w' (and
if '-k' is given as an argument, it too) are bunched together with the
first -I statement. In order to get access to which directories are
being searched for Makefiles (and I do acknowledge that this is an
unusual thing to want to do and probably hasn't come up much), the
intervening option letters between '-' and 'I' must be removed. This
requires quite a little bit of manipulation to accomplish: 

  DEFNUL =
  s = $(DEFNUL) # what we want is the SPACE between
                # the null macro and the hash.
  DECRUFTED = $(filter-out - -- --%,$(MFLAGS))
  LOOK4WHERE= $(subst -I$s,,$(patsubst -%I,-I,$(DECRUFTED)))

(BTW, then, once we have a list of include dirs to search, we can do 
something like this:

 FOUND_CPUTOOL = $(firstword \
 $(wildcard $(addsuffix /get_hostcpu.mk,$(LOOK4WHERE) \
   /usr/local/include)))

and can do something with that file we've found, if we find it.)

Is make-3.80 to have something of greater convenience in this regard,
that we haven't had until now? Like a "MAKEDIRS" or "MAKE_INCLUDE_PATH"? 

  Best Regards,
   Soren A






reply via email to

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