help-make
[Top][All Lists]
Advanced

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

Re: Re: setting a make " include" path right from the get-go


From: j . bezem
Subject: Re: Re: setting a make " include" path right from the get-go
Date: Tue, 9 Dec 2008 14:39:56 +0100 (MET)

> On Tue, 9 Dec 2008, Sam Ravnborg wrote:
> 
> > >
> > >   i want to clean all that up and have make use an include-dir path
> > > and be able to change all of the above to, of course, the simpler:
> > >
> > >   include someutil.mak
> >
> > Why not just use:
> >
> > include $(call magic,someutil.mak)
> >
> > Where magic is a macro that based on a variabes passed
> > or something decide on the directory to try.
> >
> > Something like this mockup for example:
> > magic = $(if $(wildcard $(mydir)/$1),$(mydir)/$1, \
> >             $(if $(wildcard $(anotherdir)/$1),$(anotherdir)/$1,NOTFOUND))
> >
> > mydir could be set recursively or could be the dir of Makefile or
> > could be absolute.
> > In other words the possibilities are many to fidn the dir.
> 
>   perhaps i'm just being thick, but i don't see how this solves the
> problem.  sure, that "magic" macro would work fine.  but where would a
> makefile get its definition?  it could get it via including a handy
> makefile of macros.  and where would it find that handy makefile of
> macros to include?  oh ...
> 
>   i would still like the ability to define something like
> --include-dir at the top level, and have that option propagate
> throughout my build to be used by all subsequent sub-makes.  can't
> that be done?
> 
> rday
> 
> p.s.  as a top-level solution, i can set up the alias
> 
>   alias mymake="make -I..."
> 
> and tell everyone to use "mymake" from now on, so that's how i could
> get my includes into that top-level makefile.  but it's the subsequent
> propagation through all submakes that is still an issue.
> 
>   perhaps i should just set an environment variable and have everyone
> do:
> 
> include ${MKFILESDIR}/handy.mak
> 
> but i still consider that aesthetically unpleasant.  i want people to
> need to say nothing other than:
> 
> include handy.mak
> 

If you can change the top-level make, why not set a variable to the directory 
(absolute path) from which the makefiles shall be included:

  export MAKE_INCLUDE_DIR ?= /var/make/includes

and then use 

  vpath %.mak $(MAKE_INCLUDE_DIR)

in every sub-make (or in a generally used include-make)?

Or is this too simple?

BR,

Johan Bezem
http://www.bezem.de/creating-a-make-template-using-gnu-make/





reply via email to

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