MainSupport.gmk revision 2301:db49e4e492e0
138032Speter# 238032Speter# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. 338032Speter# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4157001Sgshapiro# 538032Speter# This code is free software; you can redistribute it and/or modify it 638032Speter# under the terms of the GNU General Public License version 2 only, as 738032Speter# published by the Free Software Foundation. Oracle designates this 838032Speter# particular file as subject to the "Classpath" exception as provided 938032Speter# by Oracle in the LICENSE file that accompanied this code. 1038032Speter# 1138032Speter# This code is distributed in the hope that it will be useful, but WITHOUT 1238032Speter# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1338032Speter# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1490792Sgshapiro# version 2 for more details (a copy is included in the LICENSE file that 1590792Sgshapiro# accompanied this code). 1690792Sgshapiro# 1790792Sgshapiro# You should have received a copy of the GNU General Public License version 1890792Sgshapiro# 2 along with this work; if not, write to the Free Software Foundation, 1990792Sgshapiro# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2038032Speter# 2138032Speter# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22132943Sgshapiro# or visit www.oracle.com if you need additional information or have any 23132943Sgshapiro# questions. 2438032Speter# 2538032Speter 2638032Speter################################################################################ 2790792Sgshapiro# This file contains helper functions for Main.gmk. 2890792Sgshapiro################################################################################ 2990792Sgshapiro 3090792Sgshapiroifndef _MAINSUPPORT_GMK 3190792Sgshapiro_MAINSUPPORT_GMK := 1 3290792Sgshapiro 3338032Speter# Run the tests specified by $1, with PRODUCT_HOME specified by $2 3490792Sgshapiro# JT_JAVA is picked up by the jtreg launcher and used to run Jtreg itself. 3538032Speterdefine RunTests 3638032Speter ($(CD) $(SRC_ROOT)/test && $(MAKE) $(MAKE_ARGS) -j1 -k MAKEFLAGS= \ 3738032Speter JT_HOME=$(JT_HOME) PRODUCT_HOME=$(strip $2) \ 3838032Speter TEST_IMAGE_DIR=$(TEST_IMAGE_DIR) \ 3938032Speter ALT_OUTPUTDIR=$(OUTPUT_ROOT) TEST_JOBS=$(TEST_JOBS) \ 40132943Sgshapiro JT_JAVA=$(BOOT_JDK) \ 41132943Sgshapiro JOBS=$(JOBS) $1) || true 4238032Speterendef 4338032Speter 4464562Sgshapirodefine CleanDocs 4590792Sgshapiro @$(PRINTF) "Cleaning docs ..." 4690792Sgshapiro @$(PRINTF) "\n" $(LOG_DEBUG) 4764562Sgshapiro $(RM) -r $(SUPPORT_OUTPUTDIR)/docs 4890792Sgshapiro $(RM) -r $(SUPPORT_OUTPUTDIR)/javadoc 4964562Sgshapiro $(RM) -r $(IMAGES_OUTPUTDIR)/docs 5038032Speter @$(PRINTF) " done\n" 5138032Speterendef 5264562Sgshapiro 5364562Sgshapiro# Cleans the dir given as $1 5490792Sgshapirodefine CleanDir 5538032Speter @$(PRINTF) "Cleaning $(strip $1) build artifacts ..." 5638032Speter @$(PRINTF) "\n" $(LOG_DEBUG) 5738032Speter ($(CD) $(OUTPUT_ROOT) && $(RM) -r $1) 5864562Sgshapiro @$(PRINTF) " done\n" 5964562Sgshapiroendef 6064562Sgshapiro 6164562Sgshapirodefine CleanSupportDir 6238032Speter @$(PRINTF) "Cleaning $(strip $1) build artifacts ..." 6338032Speter @$(PRINTF) "\n" $(LOG_DEBUG) 6438032Speter $(RM) -r $(SUPPORT_OUTPUTDIR)/$(strip $1) 6590792Sgshapiro @$(PRINTF) " done\n" 6690792Sgshapiroendef 6790792Sgshapiro 6890792Sgshapirodefine CleanTest 6990792Sgshapiro @$(PRINTF) "Cleaning test $(strip $1) ..." 7090792Sgshapiro @$(PRINTF) "\n" $(LOG_DEBUG) 7190792Sgshapiro $(RM) -r $(SUPPORT_OUTPUTDIR)/test/$(strip $(subst -,/,$1)) 7290792Sgshapiro # Remove as much of the test directory structure as is empty 7338032Speter $(RMDIR) -p $(dir $(SUPPORT_OUTPUTDIR)/test/$(strip $(subst -,/,$1))) 2> /dev/null || true 7490792Sgshapiro @$(PRINTF) " done\n" 7590792Sgshapiroendef 7690792Sgshapiro 7790792Sgshapirodefine Clean-gensrc 7890792Sgshapiro @$(PRINTF) "Cleaning gensrc $(if $1,for $(strip $1) )..." 7990792Sgshapiro @$(PRINTF) "\n" $(LOG_DEBUG) 8090792Sgshapiro $(RM) -r $(SUPPORT_OUTPUTDIR)/gensrc/$(strip $1) 8190792Sgshapiro @$(PRINTF) " done\n" 8290792Sgshapiroendef 8390792Sgshapiro 8490792Sgshapirodefine Clean-java 8590792Sgshapiro @$(PRINTF) "Cleaning java $(if $1,for $(strip $1) )..." 8690792Sgshapiro @$(PRINTF) "\n" $(LOG_DEBUG) 8790792Sgshapiro $(RM) -r $(JDK_OUTPUTDIR)/modules/$(strip $1) 8890792Sgshapiro $(RM) -r $(SUPPORT_OUTPUTDIR)/special_classes/$(strip $1) 8990792Sgshapiro $(PRINTF) " done\n" 9038032Speter $(PRINTF) "Cleaning headers $(if $1,for $(strip $1)) ..." 9138032Speter $(RM) -r $(SUPPORT_OUTPUTDIR)/headers/$(strip $1) 9238032Speter @$(PRINTF) " done\n" 9338032Speterendef 9438032Speter 9538032Speterdefine Clean-native 9638032Speter @$(PRINTF) "Cleaning native $(if $1,for $(strip $1) )..." 9738032Speter @$(PRINTF) "\n" $(LOG_DEBUG) 9838032Speter $(RM) -r $(SUPPORT_OUTPUTDIR)/native/$(strip $1) 9938032Speter $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1) 10038032Speter $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_cmds/$(strip $1) 10138032Speter @$(PRINTF) " done\n" 10238032Speterendef 10338032Speter 10438032Speterdefine Clean-include 10538032Speter @$(PRINTF) "Cleaning include $(if $1,for $(strip $1) )..." 106132943Sgshapiro @$(PRINTF) "\n" $(LOG_DEBUG) 10764562Sgshapiro $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_include/$(strip $1) 10838032Speter @$(PRINTF) " done\n" 10964562Sgshapiroendef 11038032Speter 11164562Sgshapirodefine CleanModule 11238032Speter $(call Clean-gensrc, $1) 11338032Speter $(call Clean-java, $1) 11438032Speter $(call Clean-native, $1) 11564562Sgshapiro $(call Clean-include, $1) 11638032Speterendef 11738032Speter 11838032Speter 11964562Sgshapiro################################################################################ 12038032Speter 12138032SpeterMAKE_TOPDIR_LIST := $(JDK_TOPDIR) $(CORBA_TOPDIR) $(LANGTOOLS_TOPDIR) \ 12238032Speter $(HOTSPOT_TOPDIR) 12338032SpeterMAKE_MAKEDIR_LIST := make 12438032Speter 12538032Speter# Helper macro for DeclareRecipesForPhase 126132943Sgshapiro# Declare a recipe for calling the module and phase specific makefile. 12738032Speter# If there are multiple makefiles to call, create a rule for each topdir 12838032Speter# that contains a makefile with the target $module-$suffix-$repodir, 12938032Speter# (i.e: java.base-gensrc-jdk) 13038032Speter# Normally there is only one makefile, and the target will just be 13164562Sgshapiro# $module-$suffix 13238032Speter# Param 1: Name of list to add targets to 13338032Speter# Param 2: Module name 13438032Speter# Param 3: Topdir 13538032Speterdefine DeclareRecipeForModuleMakefile 13638032Speter ifeq ($$($1_MULTIPLE_MAKEFILES), true) 13764562Sgshapiro $2-$$($1_TARGET_SUFFIX): $2-$$($1_TARGET_SUFFIX)-$$(notdir $3) 13838032Speter 13938032Speter $2-$$($1_TARGET_SUFFIX)-$$(notdir $3): 14038032Speter else 14138032Speter $2-$$($1_TARGET_SUFFIX): 14238032Speter endif 14338032Speter ifeq ($$($1_USE_WRAPPER), true) 14438032Speter +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \ 14538032Speter -f ModuleWrapper.gmk \ 14638032Speter $$(addprefix -I, $$(wildcard $$(addprefix $3/, $(MAKE_MAKEDIR_LIST)) \ 14738032Speter $$(addsuffix /$$($1_MAKE_SUBDIR), $$(addprefix $3/, $(MAKE_MAKEDIR_LIST))))) \ 14864562Sgshapiro MODULE=$2 MAKEFILE_PREFIX=$$($1_FILE_PREFIX)) 14938032Speter else 15038032Speter +($(CD) $$(dir $$(firstword $$(wildcard $$(patsubst %, \ 15164562Sgshapiro $3/%/$$($1_MAKE_SUBDIR)/$$($1_FILE_PREFIX)-$2.gmk, $(MAKE_MAKEDIR_LIST))))) \ 15238032Speter && $(MAKE) $(MAKE_ARGS) \ 15338032Speter -f $$($1_FILE_PREFIX)-$2.gmk \ 15438032Speter $$(addprefix -I, $$(wildcard $$(addprefix $3/, $(MAKE_MAKEDIR_LIST)) \ 15538032Speter $$(addsuffix /$$($1_MAKE_SUBDIR), $$(addprefix $3/, $(MAKE_MAKEDIR_LIST))))) \ 15664562Sgshapiro MODULE=$2) 15738032Speter endif 15838032Speter 15990792Sgshapiroendef 16038032Speter 16138032Speter# Helper macro for DeclareRecipesForPhase 16264562Sgshapiro# Param 1: Name of list to add targets to 16338032Speter# Param 2: Module name 16438032Speterdefine DeclareRecipesForPhaseAndModule 16538032Speter $1_$2_TOPDIRS := $$(strip $$(sort $$(foreach d, $(MAKE_TOPDIR_LIST), \ 16638032Speter $$(patsubst $$d/%, $$d, $$(filter $$d/%, \ 167141858Sgshapiro $$(wildcard $$(patsubst %, %/$$($1_MAKE_SUBDIR)/$$($1_FILE_PREFIX)-$2.gmk, \ 16838032Speter $$(foreach s, $(MAKE_MAKEDIR_LIST), \ 16990792Sgshapiro $$(addsuffix /$$s, $(MAKE_TOPDIR_LIST)))))))))) 17090792Sgshapiro 171157001Sgshapiro # Only declare recipes if there are makefiles to call 17264562Sgshapiro ifneq ($$($1_$2_TOPDIRS), ) 17338032Speter # Add the top dir specific target to target list regardless of if recipe 17464562Sgshapiro # generation is disabled. 17538032Speter ifeq ($$($1_MULTIPLE_MAKEFILES), true) 17638032Speter $$(foreach d, $$($1_$2_TOPDIRS), \ 17738032Speter $$(eval $1 += $2-$$($1_TARGET_SUFFIX)-$$(notdir $$d))) 17838032Speter endif 17964562Sgshapiro ifeq ($(NO_RECIPES),) 18038032Speter $$(foreach d, $$($1_$2_TOPDIRS), \ 18138032Speter $$(eval $$(call DeclareRecipeForModuleMakefile,$1,$2,$$d))) 18238032Speter endif 18390792Sgshapiro $1 += $2-$$($1_TARGET_SUFFIX) 18438032Speter $1_MODULES += $2 18564562Sgshapiro endif 18638032Speterendef 18738032Speter 18838032Speter# Declare recipes for a specific module and build phase if there are makefiles 18938032Speter# present for the specific combination. 19038032Speter# Param 1: Name of list to add targets to 19138032Speter# Named params: 19238032Speter# TARGET_SUFFIX : Suffix of target to create for recipe 19364562Sgshapiro# MAKE_SUBDIR : Subdir for this build phase 19438032Speter# FILE_PREFIX : File prefix for this build phase 19538032Speter# USE_WRAPPER : Set to true to use ModuleWrapper.gmk 19664562Sgshapiro# CHECK_MODULES : List of modules to try 19766494Sgshapiro# MULTIPLE_MAKEFILES : Set to true to handle makefiles for the same module and 19838032Speter# phase in multiple repos 19938032Speter# Exported variables: 20038032Speter# $1_MODULES : All modules that had rules generated 20138032Speter# $1_TARGETS : All targets generated 20264562Sgshapirodefine DeclareRecipesForPhase 20338032Speter $(foreach i,2 3 4 5 6 7, $(if $($i),$(strip $1)_$(strip $($i)))$(NEWLINE)) 20464562Sgshapiro $(if $(8),$(error Internal makefile error: Too many arguments to \ 20538032Speter DeclareRecipesForPhase, please update MakeHelper.gmk)) 20664562Sgshapiro 20764562Sgshapiro $$(foreach m, $$($(strip $1)_CHECK_MODULES), \ 20864562Sgshapiro $$(eval $$(call DeclareRecipesForPhaseAndModule,$(strip $1),$$m))) 20964562Sgshapiro 210 $(strip $1)_TARGETS := $$($(strip $1)) 211endef 212 213################################################################################ 214 215endif # _MAINSUPPORT_GMK 216