common/makefiles/Makefile
changeset 13697 5262b00bc10c
parent 13132 bd88bb8dd3af
child 14111 2a82ecb35fc7
equal deleted inserted replaced
13694:ffe6bce5a521 13697:5262b00bc10c
    24 #
    24 #
    25 
    25 
    26 # This must be the first rule
    26 # This must be the first rule
    27 default: all
    27 default: all
    28 
    28 
       
    29 # Inclusion of this pseudo-target will cause make to execute this file
       
    30 # serially, regardless of -j. Recursively called makefiles will not be
       
    31 # affected, however. This is required for correct dependency management.
       
    32 .NOTPARALLEL:
       
    33 
    29 # Locate this Makefile
    34 # Locate this Makefile
    30 ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),)
    35 ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),)
    31     makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST))
    36     makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST))
    32 else
    37 else
    33     makefile_path:=$(lastword $(MAKEFILE_LIST))
    38     makefile_path:=$(lastword $(MAKEFILE_LIST))
    39 
    44 
    40 $(eval $(call ParseLogLevel))
    45 $(eval $(call ParseLogLevel))
    41 $(eval $(call SetupLogging))
    46 $(eval $(call SetupLogging))
    42 $(eval $(call ParseConfAndSpec))
    47 $(eval $(call ParseConfAndSpec))
    43 
    48 
    44 # Setup number of jobs to use. -jN is unfortunately not available for us to parse from the command line,
       
    45 # hence this workaround.
       
    46 ifeq ($(JOBS),)
       
    47     JOBS=$(NUM_CORES)
       
    48 endif
       
    49 
       
    50 ifneq ($(words $(SPEC)),1)
    49 ifneq ($(words $(SPEC)),1)
    51 ### We have multiple configurations to build, call make repeatedly
    50 ### We have multiple configurations to build, call make repeatedly
    52 all jdk hotspot jaxws jaxp corba langtools install images clean dist-clean:
    51 all clean dist-clean:
    53 	@$(foreach spec,$(SPEC),($(MAKE) -f $(makefile_path) SPEC=$(spec) $(VERBOSE) VERBOSE=$(VERBOSE) $@ $(MAKE_ARGS)) &&) true
    52 langtools corba jaxp jaxws hotspot jdk images overlay-images install:
    54 
    53 langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only images-only overlay-images-only install-only:
    55 .PHONY: all jdk hotspot jaxws jaxp corba langtools install images clean dist-clean
    54 clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images:
       
    55 	@$(foreach spec,$(SPEC),($(MAKE) -f $(makefile_path) SPEC=$(spec) $(VERBOSE) VERBOSE=$(VERBOSE) $@) &&) true
       
    56 
       
    57 .PHONY: all clean dist-clean
       
    58 .PHONY: langtools corba jaxp jaxws hotspot jdk images overlay-images install
       
    59 .PHONY: langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only images-only overlay-images-only install-only
       
    60 .PHONY: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images
    56 
    61 
    57 else
    62 else
    58 ### This is the main part of the Makefile, for the normal case with SPEC specifying a single existing spec.gmk file.
    63 ### This is the main part of the Makefile, for the normal case with SPEC specifying a single existing spec.gmk file.
    59 
    64 
    60 # Now load the spec
    65 # Now load the spec
    75         $(shell $(RM) $(BUILD_LOG) 2> /dev/null)
    80         $(shell $(RM) $(BUILD_LOG) 2> /dev/null)
    76     endif
    81     endif
    77 endif
    82 endif
    78 # Remove any javac server logs and port files. This
    83 # Remove any javac server logs and port files. This
    79 # prevents a new make run to reuse the previous servers.
    84 # prevents a new make run to reuse the previous servers.
    80 ifneq (,$(JAVAC_SERVERS))
    85 ifneq (,$(SJAVAC_SERVER_DIR))
    81     $(shell mkdir -p $(JAVAC_SERVERS) && rm -rf $(JAVAC_SERVERS)/*)
    86     $(shell $(MKDIR) -p $(SJAVAC_SERVER_DIR) && $(RM) -rf $(SJAVAC_SERVER_DIR)/*)
    82 endif
    87 endif
    83 # Clean out any notifications from the previous build.
    88 # Clean out any notifications from the previous build.
    84 $(shell find $(OUTPUT_ROOT) -name "_the.*.notify" $(FIND_DELETE))
    89 $(shell $(FIND) $(OUTPUT_ROOT) -name "_the.*.notify" $(FIND_DELETE))
    85 
    90 
    86 # Reset the build timers.
    91 # Reset the build timers.
    87 $(eval $(call ResetTimers))
    92 $(eval $(call ResetTimers))
    88 
    93 
       
    94 # Setup number of jobs to use. -jN is unfortunately not available for us to parse from the command line,
       
    95 # hence this workaround.
       
    96 ifeq ($(JOBS),)
       
    97     JOBS=$(NUM_CORES)
       
    98 endif
       
    99 MAKE_ARGS:=$(MAKE_ARGS) -j$(JOBS)
       
   100 
    89 ### Main targets
   101 ### Main targets
    90 
   102 
    91 all: jdk
   103 all: jdk
    92 	@$(if $(JAVAC_SERVERS),rm -rf $(JAVAC_SERVERS)/*.port)
   104 	@$(if $(SJAVAC_SERVER_DIR),$(RM) -rf $(SJAVAC_SERVER_DIR)/*.port)
    93 	@$(call AtRootMakeEnd)
   105 	@$(call AtRootMakeEnd)
       
   106 .PHONY: all
    94 
   107 
    95 langtools: start-make langtools-only
   108 langtools: start-make langtools-only
    96 langtools-only:
   109 langtools-only:
    97 	@$(call MakeStart,langtools,all)
   110 	@$(call MakeStart,langtools,all)
    98 	@($(CD) $(LANGTOOLS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS))
   111 	@($(CD) $(LANGTOOLS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS))
    99 	@$(call MakeFinish,langtools,all)
   112 	@$(call MakeFinish,langtools,all)
   100 
   113 
   101 corba: langtools corba-only
   114 corba: langtools corba-only
   102 corba-only:
   115 corba-only:
   103 	@$(call MakeStart,corba,all)
   116 	@$(call MakeStart,corba,all)
   104 	@($(CD) $(CORBA_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS))
   117 	@($(CD) $(CORBA_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS))
   105 	@$(call MakeFinish,corba,all)
   118 	@$(call MakeFinish,corba,all)
   106 
   119 
   107 jaxp: langtools jaxp-only
   120 jaxp: langtools jaxp-only
   108 jaxp-only:
   121 jaxp-only:
   109 	@$(call MakeStart,jaxp,all)
   122 	@$(call MakeStart,jaxp,all)
   110 	@($(CD) $(JAXP_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS))
   123 	@($(CD) $(JAXP_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS))
   111 	@$(call MakeFinish,jaxp,all)
   124 	@$(call MakeFinish,jaxp,all)
   112 
   125 
   113 jaxws: langtools jaxp jaxws-only
   126 jaxws: langtools jaxp jaxws-only
   114 jaxws-only:
   127 jaxws-only:
   115 	@$(call MakeStart,jaxws,all)
   128 	@$(call MakeStart,jaxws,all)
   116 	@($(CD) $(JAXWS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS))
   129 	@($(CD) $(JAXWS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS))
   117 	@$(call MakeFinish,jaxws,all)
   130 	@$(call MakeFinish,jaxws,all)
   118 
   131 
   119 hotspot: langtools hotspot-only
   132 hotspot: langtools hotspot-only
   120 hotspot-only:
   133 hotspot-only:
   121 	@$(call MakeStart,hotspot,all)
   134 	@$(call MakeStart,hotspot,all)
   122 	@($(CD) $(HOTSPOT_TOPDIR)/make && $(BUILD_LOG_WRAPPER) $(MAKE) -j1 $(HOTSPOT_MAKE_ARGS) $(MAKE_ARGS))
   135 	@($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f HotspotWrapper.gmk)
   123 	@$(call MakeFinish,hotspot,all)
   136 	@$(call MakeFinish,hotspot,all)
   124 
   137 
   125 jdk: langtools corba jaxp jaxws hotspot jdk-only
   138 jdk: langtools corba jaxp jaxws hotspot jdk-only
   126 jdk-only:
   139 jdk-only:
   127 	@$(call MakeStart,jdk,all)
   140 	@$(call MakeStart,jdk,all)
   128 	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS))
   141 	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) $(JDK_TARGET))
   129 	@$(call MakeFinish,jdk,all)
   142 	@$(call MakeFinish,jdk,all)
   130 
   143 
   131 images: source-tips start-make jdk langtools corba jaxp jaxws hotspot images-only
   144 images: source-tips start-make jdk langtools corba jaxp jaxws hotspot images-only
   132 images-only:
   145 images-only:
   133 	@$(call MakeStart,jdk-images,$@)
   146 	@$(call MakeStart,jdk-images,$@)
   134 	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(JDK_MAKE_ARGS) $(MAKE_ARGS) images)
   147 	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) images)
   135 	@$(call MakeFinish,jdk-images,$@)
   148 	@$(call MakeFinish,jdk-images,$@)
   136 	@$(if $(JAVAC_SERVERS),rm -rf $(JAVAC_SERVERS)/*.port)
   149 	@$(if $(SJAVAC_SERVER_DIR),$(RM) -rf $(SJAVAC_SERVER_DIR)/*.port)
       
   150 	@$(call AtRootMakeEnd)
       
   151 
       
   152 overlay-images: source-tips start-make jdk langtools corba jaxp jaxws hotspot overlay-images-only
       
   153 overlay-images-only:
       
   154 	@$(call MakeStart,jdk-overlay-images,$@)
       
   155 	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) overlay-images)
       
   156 	@$(call MakeFinish,jdk-overlay-images,$@)
       
   157 	@$(if $(SJAVAC_SERVER_DIR),$(RM) -rf $(SJAVAC_SERVER_DIR)/*.port)
   137 	@$(call AtRootMakeEnd)
   158 	@$(call AtRootMakeEnd)
   138 
   159 
   139 install: source-tips start-make jdk langtools corba jaxp jaxws hotspot install-only
   160 install: source-tips start-make jdk langtools corba jaxp jaxws hotspot install-only
   140 install-only:
   161 install-only:
   141 	@$(call MakeStart,jdk-images,$@)
   162 	@$(call MakeStart,jdk-images,$@)
   142 	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(JDK_MAKE_ARGS) $(MAKE_ARGS) install)
   163 	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) install)
   143 	@$(call MakeFinish,jdk-images,$@)
   164 	@$(call MakeFinish,jdk-images,$@)
   144 	@$(if $(JAVAC_SERVERS),rm -rf $(JAVAC_SERVERS)/*.port)
   165 	@$(if $(SJAVAC_SERVER_DIR),$(RM) -rf $(SJAVAC_SERVER_DIR)/*.port)
   145 	@$(call AtRootMakeEnd)
   166 	@$(call AtRootMakeEnd)
       
   167 
       
   168 docs: start-make jdk docs-only
       
   169 docs-only:
       
   170 	@$(call MakeStart,docs,$@)
       
   171 	@($(CD) $(SRC_ROOT)/common/makefiles/javadoc && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs)
       
   172 	@$(call MakeFinish,docs,$@)
       
   173 	@$(if $(SJAVAC_SERVER_DIR),$(RM) -rf $(SJAVAC_SERVER_DIR)/*.port)
       
   174 	@$(call AtRootMakeEnd)
       
   175 
       
   176 
       
   177 .PHONY: langtools corba jaxp jaxws hotspot jdk images install
       
   178 .PHONY: langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only images-only install-only
   146 
   179 
   147 start-make:
   180 start-make:
   148 	@$(call AtRootMakeStart)
   181 	@$(call AtRootMakeStart)
   149 
   182 .PHONY: start-make
   150 .PHONY: jdk hotspot jaxws jaxp corba langtools install images start-make
   183 
       
   184 bootcycle-images:
       
   185 	@$(ECHO) Boot cycle build step 1: Building the JDK image normally
       
   186 	@($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) SPEC=$(SPEC) images)
       
   187 	@$(ECHO) Boot cycle build step 2: Building a new JDK image using previously built image
       
   188 	@($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) SPEC=$(dir $(SPEC))bootcycle-spec.gmk images)
   151 
   189 
   152 test: start-make
   190 test: start-make
   153 	@$(call MakeStart,test,$(if $(TEST),$(TEST),all))
   191 	@$(call MakeStart,test,$(if $(TEST),$(TEST),all))
   154 	@($(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
   192 	@($(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
   155 	@$(call MakeFinish,test,$(if $(TEST),$(TEST),all))
   193 	@$(call MakeFinish,test,$(if $(TEST),$(TEST),all))
   165 	@$(RM) $@
   203 	@$(RM) $@
   166 	@$(call GetSourceTips)
   204 	@$(call GetSourceTips)
   167 
   205 
   168 
   206 
   169 # Remove everything, except the output from configure.
   207 # Remove everything, except the output from configure.
   170 clean:
   208 clean: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images clean-bootcycle-build
   171 	@(cd $(OUTPUT_ROOT) && $(RM) -r `$(LS) $(OUTPUT_ROOT) | grep -v spec.gmk | grep -v spec.sh | grep -v Makefile | grep -v config.status | grep -v config.log | grep -v config.h | grep -v configure-arguments | grep -v "localdevenv.*" | grep -v uncygdrive.exe`)
   209 	@($(CD) $(OUTPUT_ROOT) && $(RM) -r tmp source_tips build.log*)
   172 	@$(ECHO) Cleaned everything except the build configuration.
   210 	@$(ECHO) Cleaned everything except the build configuration.
   173 .PHONY: clean
   211 .PHONY: clean
   174 
   212 
   175 # Remove everything, you have to rerun configure.
   213 # Remove everything, you have to rerun configure.
   176 dist-clean:
   214 dist-clean:
   177 	@$(RM) -r $(OUTPUT_ROOT)
   215 	@$(RM) -r $(OUTPUT_ROOT)
   178 	@$(ECHO) Cleaned everything, you will have to re-run configure.
   216 	@$(ECHO) Cleaned everything, you will have to re-run configure.
   179 .PHONY: dist-clean
   217 .PHONY: dist-clean
   180 
   218 
       
   219 clean-langtools:
       
   220 	$(call CleanComponent,langtools)
       
   221 clean-corba:
       
   222 	$(call CleanComponent,corba)
       
   223 clean-jaxp:
       
   224 	$(call CleanComponent,jaxp)
       
   225 clean-jaxws:
       
   226 	$(call CleanComponent,jaxws)
       
   227 clean-hotspot:
       
   228 	$(call CleanComponent,hotspot)
   181 clean-jdk:
   229 clean-jdk:
   182 	@(cd $(OUTPUT_ROOT) && $(RM) -r `$(LS) $(OUTPUT_ROOT) | grep -v spec.gmk | grep -v spec.sh | grep -v Makefile | grep -v config.status | grep -v config.log |  grep -v config.h | grep -v configure-arguments | \
   230 	$(call CleanComponent,jdk)
   183                                grep -v langtools | grep -v corba | grep -v jaxp | grep -v jaxws | grep -v hotspot`)
   231 clean-images:
   184 	@$(ECHO) "Cleaned jdk build artifacts (but not langtools,corba,jaxp,jaxws,hotspot nor the build configuration)"
   232 	$(call CleanComponent,images)
   185 .PHONY: clean
   233 clean-bootcycle-build:
       
   234 	$(call CleanComponent,bootcycle-build)
       
   235 
       
   236 .PHONY: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images
   186 
   237 
   187 endif
   238 endif
   188 
   239 
   189 # Here are "global" targets, i.e. targets that can be executed without specifying a single configuration.
   240 # Here are "global" targets, i.e. targets that can be executed without specifying a single configuration.
   190 # If you addd more global targets, please update the fatal-error macro.
   241 # If you addd more global targets, please update the fatal-error macro.
   193 	$(info )
   244 	$(info )
   194 	$(info OpenJDK Makefile help)
   245 	$(info OpenJDK Makefile help)
   195 	$(info =====================)
   246 	$(info =====================)
   196 	$(info )
   247 	$(info )
   197 	$(info Common make targets)
   248 	$(info Common make targets)
   198 	$(info .  make [all]            # Compile all code but do not create images)
   249 	$(info .  make [all]             # Compile all code but do not create images)
   199 	$(info .  make images           # Create complete j2sdk and j2re images)
   250 	$(info .  make images            # Create complete j2sdk and j2re images)
   200 	$(info .  make install          # Install the generated images locally)
   251 	$(info .  make overlay-images    # Create limited images for sparc 64 bit platforms)
   201 	$(info .  make clean            # Remove all files generated by make, but not those generated by configure)
   252 	$(info .  make bootcycle-images  # Build images twice, second time with newly build JDK)
   202 	$(info .  make dist-clean       # Remove all files generated by both make and configure)
   253 	$(info .  make install           # Install the generated images locally)
   203 	$(info .  make help             # Give some help on using make)
   254 	$(info .  make clean             # Remove all files generated by make, but not those)
   204 	$(info .  make test             # Run tests, default is all tests (see TEST below))
   255 	$(info .                         # generated by configure)
       
   256 	$(info .  make dist-clean        # Remove all files, including configuration)
       
   257 	$(info .  make help              # Give some help on using make)
       
   258 	$(info .  make test              # Run tests, default is all tests (see TEST below))
       
   259 	$(info )
       
   260 	$(info Targets for specific components)
       
   261 	$(info (Component is any of langtools, corba, jaxp, jaxws, hotspot, jdk or images))
       
   262 	$(info .  make <component>       # Build <component> and everything it depends on. )
       
   263 	$(info .  make <component>-only  # Build <component> only, without dependencies. This)
       
   264 	$(info .                         # is faster but can result in incorrect build results!)
       
   265 	$(info .  make clean-<component> # Remove files generated by make for <component>)
   205 	$(info )
   266 	$(info )
   206 	$(info Useful make variables)
   267 	$(info Useful make variables)
   207 	$(info .  make CONF=            # Build all configurations (note, assignment is empty))
   268 	$(info .  make CONF=             # Build all configurations (note, assignment is empty))
   208 	$(info .  make CONF=<substring> # Build the configuration(s) with a name matching the given substring)
   269 	$(info .  make CONF=<substring>  # Build the configuration(s) with a name matching)
   209 	$(info )
   270 	$(info .                         # <substring>)
   210 	$(info .  make LOG=<loglevel>   # Change loglevel from warn (default) to the given loglevel)
   271 	$(info )
   211 	$(info .                        # Available loglevels are: warn, info, debug and trace)
   272 	$(info .  make LOG=<loglevel>    # Change the log level from warn to <loglevel>)
   212 	$(info .                        # To see executed command lines, use LOG=info)
   273 	$(info .                         # Available log levels are:)
   213 	$(info )
   274 	$(info .                         # 'warn' (default), 'info', 'debug' and 'trace')
   214 	$(info .  make test TEST=<test> # Only run the given test or tests, e.g.)
   275 	$(info .                         # To see executed command lines, use LOG=info)
   215 	$(info .                        # make test TEST="jdk_lang jdk_net")
   276 	$(info )
       
   277 	$(info .  make JOBS=<n>          # Run <n> parallel make jobs)
       
   278 	$(info .                         # Note that -jN does not work as expected!)
       
   279 	$(info )
       
   280 	$(info .  make test TEST=<test>  # Only run the given test or tests, e.g.)
       
   281 	$(info .                         # make test TEST="jdk_lang jdk_net")
   216 	$(info )
   282 	$(info )
   217 .PHONY: help
   283 .PHONY: help
   218 FRC: # Force target
   284 FRC: # Force target