common/makefiles/Makefile
changeset 14111 2a82ecb35fc7
parent 13697 5262b00bc10c
child 15053 64278cb83950
equal deleted inserted replaced
14104:8d9d430b4244 14111:2a82ecb35fc7
    22 # or visit www.oracle.com if you need additional information or have any
    22 # or visit www.oracle.com if you need additional information or have any
    23 # questions.
    23 # questions.
    24 #
    24 #
    25 
    25 
    26 # This must be the first rule
    26 # This must be the first rule
    27 default: all
    27 all:
    28 
    28 
    29 # Inclusion of this pseudo-target will cause make to execute this file
    29 # Inclusion of this pseudo-target will cause make to execute this file
    30 # serially, regardless of -j. Recursively called makefiles will not be
    30 # serially, regardless of -j. Recursively called makefiles will not be
    31 # affected, however. This is required for correct dependency management.
    31 # affected, however. This is required for correct dependency management.
    32 .NOTPARALLEL:
    32 .NOTPARALLEL:
       
    33 
       
    34 # The shell code below will be executed on /usr/ccs/bin/make on Solaris, but not in GNU make.
       
    35 # /usr/ccs/bin/make lacks basically every other flow control mechanism.
       
    36 TEST_FOR_NON_GNUMAKE:sh=echo You are not using GNU make/gmake, this is a requirement. Check your path. 1>&2 && exit 1
       
    37 
       
    38 # Assume we have GNU make, but check version.
       
    39 ifeq (,$(findstring 3.81,$(MAKE_VERSION)))
       
    40     ifeq (,$(findstring 3.82,$(MAKE_VERSION)))
       
    41         $(error This version of GNU Make is too low ($(MAKE_VERSION)). Check your path, or upgrade to 3.81 or newer.)
       
    42     endif
       
    43 endif
    33 
    44 
    34 # Locate this Makefile
    45 # Locate this Makefile
    35 ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),)
    46 ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),)
    36     makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST))
    47     makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST))
    37 else
    48 else
    41 
    52 
    42 # ... and then we can include our helper functions
    53 # ... and then we can include our helper functions
    43 include $(dir $(makefile_path))/MakeHelpers.gmk
    54 include $(dir $(makefile_path))/MakeHelpers.gmk
    44 
    55 
    45 $(eval $(call ParseLogLevel))
    56 $(eval $(call ParseLogLevel))
    46 $(eval $(call SetupLogging))
       
    47 $(eval $(call ParseConfAndSpec))
    57 $(eval $(call ParseConfAndSpec))
    48 
    58 
    49 ifneq ($(words $(SPEC)),1)
    59 # Now determine if we have zero, one or several configurations to build.
    50 ### We have multiple configurations to build, call make repeatedly
    60 ifeq ($(SPEC),)
    51 all clean dist-clean:
    61     # Since we got past ParseConfAndSpec, we must be building a global target. Do nothing.
    52 langtools corba jaxp jaxws hotspot jdk images overlay-images install:
    62 else
    53 langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only images-only overlay-images-only install-only:
    63     ifeq ($(words $(SPEC)),1)
    54 clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images:
    64         # We are building a single configuration. This is the normal case. Execute the Main.gmk file.
       
    65         include $(dir $(makefile_path))/Main.gmk
       
    66     else
       
    67         # We are building multiple configurations.
       
    68         # First, find out the valid targets
       
    69         # Run the makefile with an arbitraty SPEC using -p -q (quiet dry-run and dump rules) to find
       
    70         # available PHONY targets. Use this list as valid targets to pass on to the repeated calls.
       
    71         all_phony_targets=$(filter-out $(global_targets), $(strip $(shell \
       
    72             $(MAKE) -p -q -f  $(makefile_path) SPEC=$(firstword $(SPEC)) | \
       
    73             grep ^.PHONY: | head -n 1 | cut -d " " -f 2-)))
       
    74 
       
    75 $(all_phony_targets):
    55 	@$(foreach spec,$(SPEC),($(MAKE) -f $(makefile_path) SPEC=$(spec) $(VERBOSE) VERBOSE=$(VERBOSE) $@) &&) true
    76 	@$(foreach spec,$(SPEC),($(MAKE) -f $(makefile_path) SPEC=$(spec) $(VERBOSE) VERBOSE=$(VERBOSE) $@) &&) true
    56 
    77 
    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
       
    61 
       
    62 else
       
    63 ### This is the main part of the Makefile, for the normal case with SPEC specifying a single existing spec.gmk file.
       
    64 
       
    65 # Now load the spec
       
    66 include $(SPEC)
       
    67 
       
    68 # Load the vital tools for all the makefiles. 
       
    69 include $(SRC_ROOT)/common/makefiles/MakeBase.gmk
       
    70 
       
    71 ### Clean up from previous run
       
    72 
       
    73 # Remove any build.log from a previous run, if they exist
       
    74 ifneq (,$(BUILD_LOG))
       
    75     ifneq (,$(BUILD_LOG_PREVIOUS))
       
    76         # Rotate old log
       
    77         $(shell $(RM) $(BUILD_LOG_PREVIOUS) 2> /dev/null)
       
    78         $(shell $(MV) $(BUILD_LOG) $(BUILD_LOG_PREVIOUS) 2> /dev/null)
       
    79     else
       
    80         $(shell $(RM) $(BUILD_LOG) 2> /dev/null)
       
    81     endif
    78     endif
    82 endif
       
    83 # Remove any javac server logs and port files. This
       
    84 # prevents a new make run to reuse the previous servers.
       
    85 ifneq (,$(SJAVAC_SERVER_DIR))
       
    86     $(shell $(MKDIR) -p $(SJAVAC_SERVER_DIR) && $(RM) -rf $(SJAVAC_SERVER_DIR)/*)
       
    87 endif
       
    88 # Clean out any notifications from the previous build.
       
    89 $(shell $(FIND) $(OUTPUT_ROOT) -name "_the.*.notify" $(FIND_DELETE))
       
    90 
       
    91 # Reset the build timers.
       
    92 $(eval $(call ResetTimers))
       
    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 
       
   101 ### Main targets
       
   102 
       
   103 all: jdk
       
   104 	@$(if $(SJAVAC_SERVER_DIR),$(RM) -rf $(SJAVAC_SERVER_DIR)/*.port)
       
   105 	@$(call AtRootMakeEnd)
       
   106 .PHONY: all
       
   107 
       
   108 langtools: start-make langtools-only
       
   109 langtools-only:
       
   110 	@$(call MakeStart,langtools,all)
       
   111 	@($(CD) $(LANGTOOLS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS))
       
   112 	@$(call MakeFinish,langtools,all)
       
   113 
       
   114 corba: langtools corba-only
       
   115 corba-only:
       
   116 	@$(call MakeStart,corba,all)
       
   117 	@($(CD) $(CORBA_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS))
       
   118 	@$(call MakeFinish,corba,all)
       
   119 
       
   120 jaxp: langtools jaxp-only
       
   121 jaxp-only:
       
   122 	@$(call MakeStart,jaxp,all)
       
   123 	@($(CD) $(JAXP_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS))
       
   124 	@$(call MakeFinish,jaxp,all)
       
   125 
       
   126 jaxws: langtools jaxp jaxws-only
       
   127 jaxws-only:
       
   128 	@$(call MakeStart,jaxws,all)
       
   129 	@($(CD) $(JAXWS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS))
       
   130 	@$(call MakeFinish,jaxws,all)
       
   131 
       
   132 hotspot: langtools hotspot-only
       
   133 hotspot-only:
       
   134 	@$(call MakeStart,hotspot,all)
       
   135 	@($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f HotspotWrapper.gmk)
       
   136 	@$(call MakeFinish,hotspot,all)
       
   137 
       
   138 jdk: langtools corba jaxp jaxws hotspot jdk-only
       
   139 jdk-only:
       
   140 	@$(call MakeStart,jdk,all)
       
   141 	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) $(JDK_TARGET))
       
   142 	@$(call MakeFinish,jdk,all)
       
   143 
       
   144 images: source-tips start-make jdk langtools corba jaxp jaxws hotspot images-only
       
   145 images-only:
       
   146 	@$(call MakeStart,jdk-images,$@)
       
   147 	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) images)
       
   148 	@$(call MakeFinish,jdk-images,$@)
       
   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)
       
   158 	@$(call AtRootMakeEnd)
       
   159 
       
   160 install: source-tips start-make jdk langtools corba jaxp jaxws hotspot install-only
       
   161 install-only:
       
   162 	@$(call MakeStart,jdk-images,$@)
       
   163 	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) install)
       
   164 	@$(call MakeFinish,jdk-images,$@)
       
   165 	@$(if $(SJAVAC_SERVER_DIR),$(RM) -rf $(SJAVAC_SERVER_DIR)/*.port)
       
   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
       
   179 
       
   180 start-make:
       
   181 	@$(call AtRootMakeStart)
       
   182 .PHONY: 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)
       
   189 
       
   190 test: start-make
       
   191 	@$(call MakeStart,test,$(if $(TEST),$(TEST),all))
       
   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
       
   193 	@$(call MakeFinish,test,$(if $(TEST),$(TEST),all))
       
   194 	@$(call AtRootMakeEnd)
       
   195 .PHONY: test
       
   196 
       
   197 
       
   198 # Stores the tips for each repository. This file is be used when constructing the jdk image and can be
       
   199 # used to track the exact sources used to build that image.
       
   200 source-tips: $(OUTPUT_ROOT)/source_tips
       
   201 $(OUTPUT_ROOT)/source_tips: FRC
       
   202 	@$(MKDIR) -p $(@D)
       
   203 	@$(RM) $@
       
   204 	@$(call GetSourceTips)
       
   205 
       
   206 
       
   207 # Remove everything, except the output from configure.
       
   208 clean: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images clean-bootcycle-build
       
   209 	@($(CD) $(OUTPUT_ROOT) && $(RM) -r tmp source_tips build.log*)
       
   210 	@$(ECHO) Cleaned everything except the build configuration.
       
   211 .PHONY: clean
       
   212 
       
   213 # Remove everything, you have to rerun configure.
       
   214 dist-clean:
       
   215 	@$(RM) -r $(OUTPUT_ROOT)
       
   216 	@$(ECHO) Cleaned everything, you will have to re-run configure.
       
   217 .PHONY: dist-clean
       
   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)
       
   229 clean-jdk:
       
   230 	$(call CleanComponent,jdk)
       
   231 clean-images:
       
   232 	$(call CleanComponent,images)
       
   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
       
   237 
       
   238 endif
    79 endif
   239 
    80 
   240 # Here are "global" targets, i.e. targets that can be executed without specifying a single configuration.
    81 # Here are "global" targets, i.e. targets that can be executed without specifying a single configuration.
   241 # If you addd more global targets, please update the fatal-error macro.
    82 # If you addd more global targets, please update the variable global_targets in MakeHelpers.
   242 
    83 
   243 help:
    84 help:
   244 	$(info )
    85 	$(info )
   245 	$(info OpenJDK Makefile help)
    86 	$(info OpenJDK Makefile help)
   246 	$(info =====================)
    87 	$(info =====================)
   256 	$(info .  make dist-clean        # Remove all files, including configuration)
    97 	$(info .  make dist-clean        # Remove all files, including configuration)
   257 	$(info .  make help              # Give some help on using make)
    98 	$(info .  make help              # Give some help on using make)
   258 	$(info .  make test              # Run tests, default is all tests (see TEST below))
    99 	$(info .  make test              # Run tests, default is all tests (see TEST below))
   259 	$(info )
   100 	$(info )
   260 	$(info Targets for specific components)
   101 	$(info Targets for specific components)
   261 	$(info (Component is any of langtools, corba, jaxp, jaxws, hotspot, jdk or images))
   102 	$(info (Component is any of langtools, corba, jaxp, jaxws, hotspot, jdk, images or overlay-images))
   262 	$(info .  make <component>       # Build <component> and everything it depends on. )
   103 	$(info .  make <component>       # Build <component> and everything it depends on. )
   263 	$(info .  make <component>-only  # Build <component> only, without dependencies. This)
   104 	$(info .  make <component>-only  # Build <component> only, without dependencies. This)
   264 	$(info .                         # is faster but can result in incorrect build results!)
   105 	$(info .                         # is faster but can result in incorrect build results!)
   265 	$(info .  make clean-<component> # Remove files generated by make for <component>)
   106 	$(info .  make clean-<component> # Remove files generated by make for <component>)
   266 	$(info )
   107 	$(info )
   270 	$(info .                         # <substring>)
   111 	$(info .                         # <substring>)
   271 	$(info )
   112 	$(info )
   272 	$(info .  make LOG=<loglevel>    # Change the log level from warn to <loglevel>)
   113 	$(info .  make LOG=<loglevel>    # Change the log level from warn to <loglevel>)
   273 	$(info .                         # Available log levels are:)
   114 	$(info .                         # Available log levels are:)
   274 	$(info .                         # 'warn' (default), 'info', 'debug' and 'trace')
   115 	$(info .                         # 'warn' (default), 'info', 'debug' and 'trace')
   275 	$(info .                         # To see executed command lines, use LOG=info)
   116 	$(info .                         # To see executed command lines, use LOG=debug)
   276 	$(info )
   117 	$(info )
   277 	$(info .  make JOBS=<n>          # Run <n> parallel make jobs)
   118 	$(info .  make JOBS=<n>          # Run <n> parallel make jobs)
   278 	$(info .                         # Note that -jN does not work as expected!)
   119 	$(info .                         # Note that -jN does not work as expected!)
   279 	$(info )
   120 	$(info )
   280 	$(info .  make test TEST=<test>  # Only run the given test or tests, e.g.)
   121 	$(info .  make test TEST=<test>  # Only run the given test or tests, e.g.)
   281 	$(info .                         # make test TEST="jdk_lang jdk_net")
   122 	$(info .                         # make test TEST="jdk_lang jdk_net")
   282 	$(info )
   123 	$(info )
   283 .PHONY: help
   124 
   284 FRC: # Force target
   125 configure:
       
   126 	@$(SHELL) $(root_dir)/configure $(CONFIGURE_ARGS)
       
   127 	@echo ====================================================
       
   128 	@echo "Note: This is a non-recommended way of running configure."
       
   129 	@echo "Instead, run 'sh configure' in the top-level directory"
       
   130 
       
   131 .PHONY: help configure