MainSupport.gmk revision 2016:ec69c5bf68a6
133965Sjdp# 2218822Sdim# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. 377298Sobrien# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 433965Sjdp# 533965Sjdp# This code is free software; you can redistribute it and/or modify it 633965Sjdp# under the terms of the GNU General Public License version 2 only, as 733965Sjdp# published by the Free Software Foundation. Oracle designates this 833965Sjdp# particular file as subject to the "Classpath" exception as provided 933965Sjdp# by Oracle in the LICENSE file that accompanied this code. 1033965Sjdp# 1133965Sjdp# This code is distributed in the hope that it will be useful, but WITHOUT 1233965Sjdp# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1333965Sjdp# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1433965Sjdp# version 2 for more details (a copy is included in the LICENSE file that 1533965Sjdp# accompanied this code). 1633965Sjdp# 1733965Sjdp# You should have received a copy of the GNU General Public License version 1833965Sjdp# 2 along with this work; if not, write to the Free Software Foundation, 1933965Sjdp# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2033965Sjdp# 2133965Sjdp# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22104834Sobrien# or visit www.oracle.com if you need additional information or have any 2333965Sjdp# questions. 2433965Sjdp# 2533965Sjdp 2677298Sobrien################################################################################ 2733965Sjdp# This file contains helper functions for Main.gmk. 2833965Sjdp################################################################################ 2933965Sjdp 3033965Sjdpifndef _MAINSUPPORT_GMK 3177298Sobrien_MAINSUPPORT_GMK := 1 3233965Sjdp 3333965Sjdp# Run the tests specified by $1. 3433965Sjdpdefine RunTests 3533965Sjdp ($(CD) $(SRC_ROOT)/test && $(MAKE) $(MAKE_ARGS) -j1 -k MAKEFLAGS= \ 3677298Sobrien JT_HOME=$(JT_HOME) PRODUCT_HOME=$(JDK_IMAGE_DIR) \ 3733965Sjdp TEST_IMAGE_DIR=$(TEST_IMAGE_DIR) \ 3833965Sjdp ALT_OUTPUTDIR=$(OUTPUT_ROOT) TEST_JOBS=$(TEST_JOBS) \ 3933965Sjdp JOBS=$(JOBS) $1) || true 4033965Sjdpendef 4177298Sobrien 4233965Sjdp# Cleans the dir given as $1 4333965Sjdpdefine CleanDir 4433965Sjdp @$(PRINTF) "Cleaning $(strip $1) build artifacts ..." 4533965Sjdp @$(PRINTF) "\n" $(LOG_DEBUG) 4633965Sjdp ($(CD) $(OUTPUT_ROOT) && $(RM) -r $1) 4733965Sjdp @$(PRINTF) " done\n" 4833965Sjdpendef 4933965Sjdp 5033965Sjdpdefine CleanSupportDir 5133965Sjdp @$(PRINTF) "Cleaning $(strip $1) build artifacts ..." 5233965Sjdp @$(PRINTF) "\n" $(LOG_DEBUG) 5333965Sjdp $(RM) -r $(SUPPORT_OUTPUTDIR)/$(strip $1) 5433965Sjdp @$(PRINTF) " done\n" 5533965Sjdpendef 5633965Sjdp 5777298Sobriendefine CleanTest 5833965Sjdp @$(PRINTF) "Cleaning test $(strip $1) ..." 5977298Sobrien @$(PRINTF) "\n" $(LOG_DEBUG) 6033965Sjdp $(RM) -r $(SUPPORT_OUTPUTDIR)/test/$(strip $(subst -,/,$1)) 6133965Sjdp # Remove as much of the test directory structure as is empty 6277298Sobrien $(RMDIR) -p $(dir $(SUPPORT_OUTPUTDIR)/test/$(strip $(subst -,/,$1))) 2> /dev/null || true 6333965Sjdp @$(PRINTF) " done\n" 6433965Sjdpendef 6533965Sjdp 6633965Sjdpdefine Clean-gensrc 6777298Sobrien @$(PRINTF) "Cleaning gensrc $(if $1,for $(strip $1) )..." 6833965Sjdp @$(PRINTF) "\n" $(LOG_DEBUG) 6933965Sjdp $(RM) -r $(SUPPORT_OUTPUTDIR)/gensrc/$(strip $1) 7033965Sjdp @$(PRINTF) " done\n" 7177298Sobrienendef 7233965Sjdp 7377298Sobriendefine Clean-java 74130561Sobrien @$(PRINTF) "Cleaning java $(if $1,for $(strip $1) )..." 75130561Sobrien @$(PRINTF) "\n" $(LOG_DEBUG) 7633965Sjdp $(RM) -r $(JDK_OUTPUTDIR)/modules/$(strip $1) 7777298Sobrien $(RM) -r $(SUPPORT_OUTPUTDIR)/special_classes/$(strip $1) 7877298Sobrien $(PRINTF) " done\n" 7977298Sobrien $(PRINTF) "Cleaning headers $(if $1,for $(strip $1)) ..." 8077298Sobrien $(RM) -r $(SUPPORT_OUTPUTDIR)/headers/$(strip $1) 8177298Sobrien @$(PRINTF) " done\n" 8233965Sjdpendef 8333965Sjdp 8433965Sjdpdefine Clean-native 8533965Sjdp @$(PRINTF) "Cleaning native $(if $1,for $(strip $1) )..." 8633965Sjdp @$(PRINTF) "\n" $(LOG_DEBUG) 8777298Sobrien $(RM) -r $(SUPPORT_OUTPUTDIR)/native/$(strip $1) 8877298Sobrien $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1) 8933965Sjdp $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_libs-stripped/$(strip $1) 9077298Sobrien $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_cmds/$(strip $1) 9177298Sobrien $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_cmds-stripped/$(strip $1) 9233965Sjdp @$(PRINTF) " done\n" 9377298Sobrienendef 9477298Sobrien 9533965Sjdpdefine Clean-include 9677298Sobrien @$(PRINTF) "Cleaning include $(if $1,for $(strip $1) )..." 9733965Sjdp @$(PRINTF) "\n" $(LOG_DEBUG) 9833965Sjdp $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_include/$(strip $1) 9933965Sjdp @$(PRINTF) " done\n" 10033965Sjdpendef 10133965Sjdp 10233965Sjdpdefine Clean-docs 10333965Sjdp @$(PRINTF) "Cleaning docs ..." 10433965Sjdp @$(PRINTF) "\n" $(LOG_DEBUG) 10533965Sjdp $(RM) -r $(SUPPORT_OUTPUTDIR)/docs 10633965Sjdp $(RM) -r $(IMAGES_OUTPUTDIR)/docs 10733965Sjdp $(RM) $(OUTPUT_ROOT)/bundles/jdk-*-docs.zip 10833965Sjdp @$(PRINTF) " done\n" 10977298Sobrienendef 11077298Sobrien 11133965Sjdpdefine CleanModule 11233965Sjdp $(call Clean-gensrc, $1) 11333965Sjdp $(call Clean-java, $1) 11433965Sjdp $(call Clean-native, $1) 11533965Sjdp $(call Clean-include, $1) 11633965Sjdpendef 11733965Sjdp 11833965Sjdp 11933965Sjdp################################################################################ 12033965Sjdp 12133965SjdpMAKE_TOPDIR_LIST := $(JDK_TOPDIR) $(CORBA_TOPDIR) $(LANGTOOLS_TOPDIR) \ 12233965Sjdp $(HOTSPOT_TOPDIR) 12333965SjdpMAKE_MAKEDIR_LIST := make 12433965Sjdp 12533965Sjdp# Helper macro for DeclareRecipesForPhase 12633965Sjdp# Declare a recipe for calling the module and phase specific makefile. 12733965Sjdp# If there are multiple makefiles to call, create a rule for each topdir 12877298Sobrien# that contains a makefile with the target $module-$suffix-$repodir, 12977298Sobrien# (i.e: java.base-gensrc-jdk) 13033965Sjdp# Normally there is only one makefile, and the target will just be 13133965Sjdp# $module-$suffix 13233965Sjdp# Param 1: Name of list to add targets to 13333965Sjdp# Param 2: Module name 13433965Sjdp# Param 3: Topdir 13533965Sjdpdefine DeclareRecipeForModuleMakefile 13633965Sjdp ifeq ($$($1_MULTIPLE_MAKEFILES), true) 13733965Sjdp $2-$$($1_TARGET_SUFFIX): $2-$$($1_TARGET_SUFFIX)-$$(notdir $3) 13833965Sjdp $1 += $2-$$($1_TARGET_SUFFIX)-$$(notdir $3) 13933965Sjdp 14033965Sjdp $2-$$($1_TARGET_SUFFIX)-$$(notdir $3): 14133965Sjdp else 14233965Sjdp $2-$$($1_TARGET_SUFFIX): 14333965Sjdp endif 14433965Sjdp ifeq ($$($1_USE_WRAPPER), true) 14533965Sjdp +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \ 14633965Sjdp -f ModuleWrapper.gmk \ 14733965Sjdp $$(addprefix -I, $$(wildcard $$(addprefix $3/, $(MAKE_MAKEDIR_LIST)) \ 14833965Sjdp $$(addsuffix /$$($1_MAKE_SUBDIR), $$(addprefix $3/, $(MAKE_MAKEDIR_LIST))))) \ 14933965Sjdp MODULE=$2 MAKEFILE_PREFIX=$$($1_FILE_PREFIX)) 15033965Sjdp else 15133965Sjdp +($(CD) $$(dir $$(firstword $$(wildcard $$(patsubst %, \ 15233965Sjdp $3/%/$$($1_MAKE_SUBDIR)/$$($1_FILE_PREFIX)-$2.gmk, $(MAKE_MAKEDIR_LIST))))) \ 15333965Sjdp && $(MAKE) $(MAKE_ARGS) \ 15433965Sjdp -f $$($1_FILE_PREFIX)-$2.gmk \ 15533965Sjdp $$(addprefix -I, $$(wildcard $$(addprefix $3/, $(MAKE_MAKEDIR_LIST)) \ 15633965Sjdp $$(addsuffix /$$($1_MAKE_SUBDIR), $$(addprefix $3/, $(MAKE_MAKEDIR_LIST))))) \ 15733965Sjdp MODULE=$2) 15833965Sjdp endif 15933965Sjdp 16033965Sjdpendef 16177298Sobrien 16277298Sobrien# Helper macro for DeclareRecipesForPhase 16333965Sjdp# Param 1: Name of list to add targets to 16433965Sjdp# Param 2: Module name 16533965Sjdpdefine DeclareRecipesForPhaseAndModule 16633965Sjdp $1_$2_TOPDIRS := $$(strip $$(sort $$(foreach d, $(MAKE_TOPDIR_LIST), \ 16733965Sjdp $$(patsubst $$d/%, $$d, $$(filter $$d/%, \ 16833965Sjdp $$(wildcard $$(patsubst %, %/$$($1_MAKE_SUBDIR)/$$($1_FILE_PREFIX)-$2.gmk, \ 16977298Sobrien $$(foreach s, $(MAKE_MAKEDIR_LIST), \ 17033965Sjdp $$(addsuffix /$$s, $(MAKE_TOPDIR_LIST)))))))))) 17133965Sjdp 17277298Sobrien # Only declare recipes if there are makefiles to call 17377298Sobrien ifneq ($$($1_$2_TOPDIRS), ) 17433965Sjdp ifeq ($(NO_RECIPES),) 17533965Sjdp $$(foreach d, $$($1_$2_TOPDIRS), \ 17633965Sjdp $$(eval $$(call DeclareRecipeForModuleMakefile,$1,$2,$$d))) 17733965Sjdp endif 17833965Sjdp $1 += $2-$$($1_TARGET_SUFFIX) 17933965Sjdp $1_MODULES += $2 18033965Sjdp endif 18133965Sjdpendef 18233965Sjdp 18333965Sjdp# Declare recipes for a specific module and build phase if there are makefiles 18433965Sjdp# present for the specific combination. 18577298Sobrien# Param 1: Name of list to add targets to 18633965Sjdp# Named params: 18733965Sjdp# TARGET_SUFFIX : Suffix of target to create for recipe 18833965Sjdp# MAKE_SUBDIR : Subdir for this build phase 189# FILE_PREFIX : File prefix for this build phase 190# USE_WRAPPER : Set to true to use ModuleWrapper.gmk 191# CHECK_MODULES : List of modules to try 192# MULTIPLE_MAKEFILES : Set to true to handle makefiles for the same module and 193# phase in multiple repos 194# Exported variables: 195# $1_MODULES : All modules that had rules generated 196# $1_TARGETS : All targets generated 197define DeclareRecipesForPhase 198 $(foreach i,2 3 4 5 6 7, $(if $($i),$(strip $1)_$(strip $($i)))$(NEWLINE)) 199 $(if $(8),$(error Internal makefile error: Too many arguments to \ 200 DeclareRecipesForPhase, please update MakeHelper.gmk)) 201 202 $$(foreach m, $$($(strip $1)_CHECK_MODULES), \ 203 $$(eval $$(call DeclareRecipesForPhaseAndModule,$(strip $1),$$m))) 204 205 $(strip $1)_TARGETS := $$($(strip $1)) 206endef 207 208################################################################################ 209 210endif # _MAINSUPPORT_GMK 211