help-make
[Top][All Lists]
Advanced

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

Re: Environment Variable to Customize .INCLUDE_DIRS


From: Rakesh Sharma
Subject: Re: Environment Variable to Customize .INCLUDE_DIRS
Date: Sat, 23 Jan 2016 07:07:52 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Afif Elghraoui <aelghraoui <at> sdsu.edu> writes:

> 
> Hello,
> I'm looking for a way to be able to store custom makefile rules in 
> special folders.
> I see that the Makefile variable .INCLUDE_DIRS is set to "/usr/include 
> /usr/local/include /usr/include" on my machine by default, but is there 
> an environment variable I can set to add different directories (like 
> $HOME/include) in the same
> way that can be done for CPATH, LIBRARY_PATH, and MANPATH for other 
things?
> 
> I know that i can also pass in a custom include path on the command 
> line, but I would like to have some files with generic rules that I can 
> include without any special command line invocation or hardcoding the 
> absolute path.
> 
> Thanks and regards
> Afif
> 

.INCLUDE_DIRS is a readonly construct in GNU make, so you can't take that 
route to do what you are intending. However, all's not lost; say your 
environment variable is INC_LOCAL, then do this in your makefile:

# these are the makefiles you want included (YMMV)
INC_MKS := a.mk junk.mk

INC_DEFAULT_MKS :=#

ifneq '$(INC_LOCAL)' ''
INC_LOCAL_MKS := $(foreach i,$(INC_MKS),$(if $(wildcard 
$(INC_LOCAL)/$i),$(wildcard $(INC_LOCAL)/$i),$(eval INC_DEFAULT_MKS += $i)))
else
INC_DEFAULT_MKS := $(INC_MKS)
endif

include $(INC_LOCAL_MKS) $(INC_DEFAULT_MKS)

$(info list=$(INC_MKS))
$(info makefiles loaded from the env variable  =$(INC_LOCAL_MKS))
$(info makefiles loaded from the default paths =$(INC_DEFAULT_MKS))





reply via email to

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