common/makefiles/Makefile

changeset 494
e64f2cb57d05
parent 478
2ba6f4da4bf3
child 559
ef6adbf511cc
     1.1 --- a/common/makefiles/Makefile	Wed Oct 24 13:11:42 2012 -0700
     1.2 +++ b/common/makefiles/Makefile	Fri Oct 26 14:29:57 2012 -0700
     1.3 @@ -24,13 +24,24 @@
     1.4  #
     1.5  
     1.6  # This must be the first rule
     1.7 -default: all
     1.8 +all:
     1.9  
    1.10  # Inclusion of this pseudo-target will cause make to execute this file
    1.11  # serially, regardless of -j. Recursively called makefiles will not be
    1.12  # affected, however. This is required for correct dependency management.
    1.13  .NOTPARALLEL:
    1.14  
    1.15 +# The shell code below will be executed on /usr/ccs/bin/make on Solaris, but not in GNU make.
    1.16 +# /usr/ccs/bin/make lacks basically every other flow control mechanism.
    1.17 +TEST_FOR_NON_GNUMAKE:sh=echo You are not using GNU make/gmake, this is a requirement. Check your path. 1>&2 && exit 1
    1.18 +
    1.19 +# Assume we have GNU make, but check version.
    1.20 +ifeq (,$(findstring 3.81,$(MAKE_VERSION)))
    1.21 +    ifeq (,$(findstring 3.82,$(MAKE_VERSION)))
    1.22 +        $(error This version of GNU Make is too low ($(MAKE_VERSION)). Check your path, or upgrade to 3.81 or newer.)
    1.23 +    endif
    1.24 +endif
    1.25 +
    1.26  # Locate this Makefile
    1.27  ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),)
    1.28      makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST))
    1.29 @@ -43,202 +54,32 @@
    1.30  include $(dir $(makefile_path))/MakeHelpers.gmk
    1.31  
    1.32  $(eval $(call ParseLogLevel))
    1.33 -$(eval $(call SetupLogging))
    1.34  $(eval $(call ParseConfAndSpec))
    1.35  
    1.36 -ifneq ($(words $(SPEC)),1)
    1.37 -### We have multiple configurations to build, call make repeatedly
    1.38 -all clean dist-clean:
    1.39 -langtools corba jaxp jaxws hotspot jdk images overlay-images install:
    1.40 -langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only images-only overlay-images-only install-only:
    1.41 -clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images:
    1.42 +# Now determine if we have zero, one or several configurations to build.
    1.43 +ifeq ($(SPEC),)
    1.44 +    # Since we got past ParseConfAndSpec, we must be building a global target. Do nothing.
    1.45 +else
    1.46 +    ifeq ($(words $(SPEC)),1)
    1.47 +        # We are building a single configuration. This is the normal case. Execute the Main.gmk file.
    1.48 +        include $(dir $(makefile_path))/Main.gmk
    1.49 +    else
    1.50 +        # We are building multiple configurations.
    1.51 +        # First, find out the valid targets
    1.52 +        # Run the makefile with an arbitraty SPEC using -p -q (quiet dry-run and dump rules) to find
    1.53 +        # available PHONY targets. Use this list as valid targets to pass on to the repeated calls.
    1.54 +        all_phony_targets=$(filter-out $(global_targets), $(strip $(shell \
    1.55 +            $(MAKE) -p -q -f  $(makefile_path) SPEC=$(firstword $(SPEC)) | \
    1.56 +            grep ^.PHONY: | head -n 1 | cut -d " " -f 2-)))
    1.57 +
    1.58 +$(all_phony_targets):
    1.59  	@$(foreach spec,$(SPEC),($(MAKE) -f $(makefile_path) SPEC=$(spec) $(VERBOSE) VERBOSE=$(VERBOSE) $@) &&) true
    1.60  
    1.61 -.PHONY: all clean dist-clean
    1.62 -.PHONY: langtools corba jaxp jaxws hotspot jdk images overlay-images install
    1.63 -.PHONY: langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only images-only overlay-images-only install-only
    1.64 -.PHONY: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images
    1.65 -
    1.66 -else
    1.67 -### This is the main part of the Makefile, for the normal case with SPEC specifying a single existing spec.gmk file.
    1.68 -
    1.69 -# Now load the spec
    1.70 -include $(SPEC)
    1.71 -
    1.72 -# Load the vital tools for all the makefiles. 
    1.73 -include $(SRC_ROOT)/common/makefiles/MakeBase.gmk
    1.74 -
    1.75 -### Clean up from previous run
    1.76 -
    1.77 -# Remove any build.log from a previous run, if they exist
    1.78 -ifneq (,$(BUILD_LOG))
    1.79 -    ifneq (,$(BUILD_LOG_PREVIOUS))
    1.80 -        # Rotate old log
    1.81 -        $(shell $(RM) $(BUILD_LOG_PREVIOUS) 2> /dev/null)
    1.82 -        $(shell $(MV) $(BUILD_LOG) $(BUILD_LOG_PREVIOUS) 2> /dev/null)
    1.83 -    else
    1.84 -        $(shell $(RM) $(BUILD_LOG) 2> /dev/null)
    1.85      endif
    1.86  endif
    1.87 -# Remove any javac server logs and port files. This
    1.88 -# prevents a new make run to reuse the previous servers.
    1.89 -ifneq (,$(SJAVAC_SERVER_DIR))
    1.90 -    $(shell $(MKDIR) -p $(SJAVAC_SERVER_DIR) && $(RM) -rf $(SJAVAC_SERVER_DIR)/*)
    1.91 -endif
    1.92 -# Clean out any notifications from the previous build.
    1.93 -$(shell $(FIND) $(OUTPUT_ROOT) -name "_the.*.notify" $(FIND_DELETE))
    1.94 -
    1.95 -# Reset the build timers.
    1.96 -$(eval $(call ResetTimers))
    1.97 -
    1.98 -# Setup number of jobs to use. -jN is unfortunately not available for us to parse from the command line,
    1.99 -# hence this workaround.
   1.100 -ifeq ($(JOBS),)
   1.101 -    JOBS=$(NUM_CORES)
   1.102 -endif
   1.103 -MAKE_ARGS:=$(MAKE_ARGS) -j$(JOBS)
   1.104 -
   1.105 -### Main targets
   1.106 -
   1.107 -all: jdk
   1.108 -	@$(if $(SJAVAC_SERVER_DIR),$(RM) -rf $(SJAVAC_SERVER_DIR)/*.port)
   1.109 -	@$(call AtRootMakeEnd)
   1.110 -.PHONY: all
   1.111 -
   1.112 -langtools: start-make langtools-only
   1.113 -langtools-only:
   1.114 -	@$(call MakeStart,langtools,all)
   1.115 -	@($(CD) $(LANGTOOLS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS))
   1.116 -	@$(call MakeFinish,langtools,all)
   1.117 -
   1.118 -corba: langtools corba-only
   1.119 -corba-only:
   1.120 -	@$(call MakeStart,corba,all)
   1.121 -	@($(CD) $(CORBA_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS))
   1.122 -	@$(call MakeFinish,corba,all)
   1.123 -
   1.124 -jaxp: langtools jaxp-only
   1.125 -jaxp-only:
   1.126 -	@$(call MakeStart,jaxp,all)
   1.127 -	@($(CD) $(JAXP_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS))
   1.128 -	@$(call MakeFinish,jaxp,all)
   1.129 -
   1.130 -jaxws: langtools jaxp jaxws-only
   1.131 -jaxws-only:
   1.132 -	@$(call MakeStart,jaxws,all)
   1.133 -	@($(CD) $(JAXWS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS))
   1.134 -	@$(call MakeFinish,jaxws,all)
   1.135 -
   1.136 -hotspot: langtools hotspot-only
   1.137 -hotspot-only:
   1.138 -	@$(call MakeStart,hotspot,all)
   1.139 -	@($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f HotspotWrapper.gmk)
   1.140 -	@$(call MakeFinish,hotspot,all)
   1.141 -
   1.142 -jdk: langtools corba jaxp jaxws hotspot jdk-only
   1.143 -jdk-only:
   1.144 -	@$(call MakeStart,jdk,all)
   1.145 -	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) $(JDK_TARGET))
   1.146 -	@$(call MakeFinish,jdk,all)
   1.147 -
   1.148 -images: source-tips start-make jdk langtools corba jaxp jaxws hotspot images-only
   1.149 -images-only:
   1.150 -	@$(call MakeStart,jdk-images,$@)
   1.151 -	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) images)
   1.152 -	@$(call MakeFinish,jdk-images,$@)
   1.153 -	@$(if $(SJAVAC_SERVER_DIR),$(RM) -rf $(SJAVAC_SERVER_DIR)/*.port)
   1.154 -	@$(call AtRootMakeEnd)
   1.155 -
   1.156 -overlay-images: source-tips start-make jdk langtools corba jaxp jaxws hotspot overlay-images-only
   1.157 -overlay-images-only:
   1.158 -	@$(call MakeStart,jdk-overlay-images,$@)
   1.159 -	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) overlay-images)
   1.160 -	@$(call MakeFinish,jdk-overlay-images,$@)
   1.161 -	@$(if $(SJAVAC_SERVER_DIR),$(RM) -rf $(SJAVAC_SERVER_DIR)/*.port)
   1.162 -	@$(call AtRootMakeEnd)
   1.163 -
   1.164 -install: source-tips start-make jdk langtools corba jaxp jaxws hotspot install-only
   1.165 -install-only:
   1.166 -	@$(call MakeStart,jdk-images,$@)
   1.167 -	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) install)
   1.168 -	@$(call MakeFinish,jdk-images,$@)
   1.169 -	@$(if $(SJAVAC_SERVER_DIR),$(RM) -rf $(SJAVAC_SERVER_DIR)/*.port)
   1.170 -	@$(call AtRootMakeEnd)
   1.171 -
   1.172 -docs: start-make jdk docs-only
   1.173 -docs-only:
   1.174 -	@$(call MakeStart,docs,$@)
   1.175 -	@($(CD) $(SRC_ROOT)/common/makefiles/javadoc && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs)
   1.176 -	@$(call MakeFinish,docs,$@)
   1.177 -	@$(if $(SJAVAC_SERVER_DIR),$(RM) -rf $(SJAVAC_SERVER_DIR)/*.port)
   1.178 -	@$(call AtRootMakeEnd)
   1.179 -
   1.180 -
   1.181 -.PHONY: langtools corba jaxp jaxws hotspot jdk images install
   1.182 -.PHONY: langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only images-only install-only
   1.183 -
   1.184 -start-make:
   1.185 -	@$(call AtRootMakeStart)
   1.186 -.PHONY: start-make
   1.187 -
   1.188 -bootcycle-images:
   1.189 -	@$(ECHO) Boot cycle build step 1: Building the JDK image normally
   1.190 -	@($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) SPEC=$(SPEC) images)
   1.191 -	@$(ECHO) Boot cycle build step 2: Building a new JDK image using previously built image
   1.192 -	@($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) SPEC=$(dir $(SPEC))bootcycle-spec.gmk images)
   1.193 -
   1.194 -test: start-make
   1.195 -	@$(call MakeStart,test,$(if $(TEST),$(TEST),all))
   1.196 -	@($(CD) $(SRC_ROOT)/test && $(BUILD_LOG_WRAPPER) $(MAKE) MAKEFLAGS= -j1 PRODUCT_HOME=$(OUTPUT_ROOT)/jdk JPRT_JAVA_HOME=$(OUTPUT_ROOT)/jdk ALT_OUTPUTDIR=$(OUTPUT_ROOT) $(TEST)) || true
   1.197 -	@$(call MakeFinish,test,$(if $(TEST),$(TEST),all))
   1.198 -	@$(call AtRootMakeEnd)
   1.199 -.PHONY: test
   1.200 -
   1.201 -
   1.202 -# Stores the tips for each repository. This file is be used when constructing the jdk image and can be
   1.203 -# used to track the exact sources used to build that image.
   1.204 -source-tips: $(OUTPUT_ROOT)/source_tips
   1.205 -$(OUTPUT_ROOT)/source_tips: FRC
   1.206 -	@$(MKDIR) -p $(@D)
   1.207 -	@$(RM) $@
   1.208 -	@$(call GetSourceTips)
   1.209 -
   1.210 -
   1.211 -# Remove everything, except the output from configure.
   1.212 -clean: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images clean-bootcycle-build
   1.213 -	@($(CD) $(OUTPUT_ROOT) && $(RM) -r tmp source_tips build.log*)
   1.214 -	@$(ECHO) Cleaned everything except the build configuration.
   1.215 -.PHONY: clean
   1.216 -
   1.217 -# Remove everything, you have to rerun configure.
   1.218 -dist-clean:
   1.219 -	@$(RM) -r $(OUTPUT_ROOT)
   1.220 -	@$(ECHO) Cleaned everything, you will have to re-run configure.
   1.221 -.PHONY: dist-clean
   1.222 -
   1.223 -clean-langtools:
   1.224 -	$(call CleanComponent,langtools)
   1.225 -clean-corba:
   1.226 -	$(call CleanComponent,corba)
   1.227 -clean-jaxp:
   1.228 -	$(call CleanComponent,jaxp)
   1.229 -clean-jaxws:
   1.230 -	$(call CleanComponent,jaxws)
   1.231 -clean-hotspot:
   1.232 -	$(call CleanComponent,hotspot)
   1.233 -clean-jdk:
   1.234 -	$(call CleanComponent,jdk)
   1.235 -clean-images:
   1.236 -	$(call CleanComponent,images)
   1.237 -clean-bootcycle-build:
   1.238 -	$(call CleanComponent,bootcycle-build)
   1.239 -
   1.240 -.PHONY: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images
   1.241 -
   1.242 -endif
   1.243  
   1.244  # Here are "global" targets, i.e. targets that can be executed without specifying a single configuration.
   1.245 -# If you addd more global targets, please update the fatal-error macro.
   1.246 +# If you addd more global targets, please update the variable global_targets in MakeHelpers.
   1.247  
   1.248  help:
   1.249  	$(info )
   1.250 @@ -258,7 +99,7 @@
   1.251  	$(info .  make test              # Run tests, default is all tests (see TEST below))
   1.252  	$(info )
   1.253  	$(info Targets for specific components)
   1.254 -	$(info (Component is any of langtools, corba, jaxp, jaxws, hotspot, jdk or images))
   1.255 +	$(info (Component is any of langtools, corba, jaxp, jaxws, hotspot, jdk, images or overlay-images))
   1.256  	$(info .  make <component>       # Build <component> and everything it depends on. )
   1.257  	$(info .  make <component>-only  # Build <component> only, without dependencies. This)
   1.258  	$(info .                         # is faster but can result in incorrect build results!)
   1.259 @@ -272,7 +113,7 @@
   1.260  	$(info .  make LOG=<loglevel>    # Change the log level from warn to <loglevel>)
   1.261  	$(info .                         # Available log levels are:)
   1.262  	$(info .                         # 'warn' (default), 'info', 'debug' and 'trace')
   1.263 -	$(info .                         # To see executed command lines, use LOG=info)
   1.264 +	$(info .                         # To see executed command lines, use LOG=debug)
   1.265  	$(info )
   1.266  	$(info .  make JOBS=<n>          # Run <n> parallel make jobs)
   1.267  	$(info .                         # Note that -jN does not work as expected!)
   1.268 @@ -280,5 +121,11 @@
   1.269  	$(info .  make test TEST=<test>  # Only run the given test or tests, e.g.)
   1.270  	$(info .                         # make test TEST="jdk_lang jdk_net")
   1.271  	$(info )
   1.272 -.PHONY: help
   1.273 -FRC: # Force target
   1.274 +
   1.275 +configure:
   1.276 +	@$(SHELL) $(root_dir)/configure $(CONFIGURE_ARGS)
   1.277 +	@echo ====================================================
   1.278 +	@echo "Note: This is a non-recommended way of running configure."
   1.279 +	@echo "Instead, run 'sh configure' in the top-level directory"
   1.280 +
   1.281 +.PHONY: help configure

mercurial