Customized make file inclusion

David Holmes david.holmes at oracle.com
Mon Jan 16 11:41:04 UTC 2012


On 16/01/2012 8:45 PM, Dmitry Samersoff wrote:
> 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

No that's not what I'm trying to do. Take a look at where the existing 
Defs-embedded.gmk and Relese-embedded.gmk files get included and then 
consider generalizing that mechanism so that those files can reside in 
an entirely different repository. Those files have to be included at 
certain places for things to work correctly. Eg. The custom Defs.gmk has 
to be included by the main Defs.gmk file.

David
-----

> -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
>
>



More information about the build-dev mailing list