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 >
If you use GNU make, then you can even roll your own function to include the generic rules makefiles, like as, (assume that the env variable IPATH holds the list of custom/local include dirs, e.g., $HOME/local/include, etc.) ***** Note: dirs in IPATH are SPACE separated and not COLON ****** # $(call local_include,$1) define local_include include $(strip $(if $(IPATH),\ $(foreach f,$1,\ $(strip \ $(eval k :=)\ $(foreach d,$(IPATH),\ $(if $k,,\ $(if $(wildcard $d/$f),\ $(strip $(wildcard $d/$f)$(eval k += .))\ )\ )\ )\ $(if $k,,$f)\ )\ ),\ $1\ )\ ) endef # put the names of all your generic rules files here GENERIC_RULES := f1.mk junk.mk f4.mk # now have them included from the custom path IPATH # in case found, otherwise attempt from the default i$(eval $(call local_include,$(GENERIC_RULES))) # take a look at where from each of the generic rules # was picked up from... $(info generic rules list=$(INC_MKS)) $(info generic rules coming from:$(MAKEFILE_LIST)) #################################################### _______________________________________________ Help-make mailing list Help-make@gnu.org https://lists.gnu.org/mailman/listinfo/help-make