Customized make file inclusion

Dmitry Samersoff Dmitry.Samersoff at oracle.com
Mon Jan 16 10:45:55 UTC 2012


David,

I'm not sure I catch you idea correct.
May be we can just create a directory, something like make.d
and then do

for i in make.d/*
do
   -include ...
done

-Dmitry




On 2012-01-16 09:01, David Holmes wrote:
> Presently the build system contains some files, and directives involving
> those files, that supports the building of the Java SE Embedded product.
> What I would like to do is remove direct support for this and replace it
> with a more general mechanism that allows for custom make files to be
> included from an arbitrary location - which then allows for the removal
> of the embedded specific files.
> 
> Initially I've modeled this on some other conditional mechanisms by
> defining the default location for non-OpenJDK builds, checking its
> existence and then using that as a guard for the individual files.
> 
> http://cr.openjdk.java.net/~dholmes/custom-make/webrev/
> 
> ! ifneq ($(OPENJDK),true)
> !   CUSTOM_MAKE_DIR_REL=closed
> ! else
> !   CUSTOM_MAKE_DIR_REL=NO_SUCH_PATH
> ! endi
> ! CUSTOM_MAKE_DIR=$(BUILDDIR)/$(CUSTOM_MAKE_DIR_REL)
> 
> + # Use this variable to guard inclusion of the custom files
> + HAS_CUSTOM_MAKE := $(shell if [ -d $(CUSTOM_MAKE_DIR) ]; then echo 1;
> else echo 0; fi)
> 
> ...
> 
> + ifeq ($(HAS_CUSTOM_MAKE),1)
> +   include $(CUSTOM_MAKE_DIR)/Defs.gmk
> + endif
> 
> Initially there are only two hooks for these custom files:
> 
> 1. At the end common/Defs.gmk (as it gets included by all the Makefiles)
> 2. In the top-level JDK Makefile, including a custom Release.gmk
> 
> Naturally these map to the existing uses of the *-embedded.gmk files.
> 
> It then occurred to me that if someone wanted to add an additional hook
> somewhere else, that it might be best to check for the existence of the
> actual file rather than a root directory for all such files. That led me
> to consider a function custom_include(<filename>) to hide the existence
> logic. But I wasn't sure if a function could contain an include
> directive and upon checking on that I discovered a much simpler
> approach: the -include directive. This is like the include directive but
> does not trigger an error if the file does not exist. So we would simply
> have this in Defs.gmk:
> 
>  ifneq ($(OPENJDK),true)
>    CUSTOM_MAKE_DIR_REL=closed
>  else
>    CUSTOM_MAKE_DIR_REL=NO_SUCH_PATH
>  endif
>  CUSTOM_MAKE_DIR=$(BUILDDIR)/$(CUSTOM_MAKE_DIR_REL)
> 
> and then
> 
> -include $(CUSTOM_MAKE_DIR)/<path-to-file.gmk>
> 
> wherever we needed it (again initially only the two locations I mentioned).
> 
> I'd like to hear people's opinions on this.
> 
> Thanks,
> David


-- 
Dmitry Samersoff
Java Hotspot development team, SPB04
* There will come soft rains ...



More information about the build-dev mailing list