NewMakefile.gmk

changeset 559
ef6adbf511cc
parent 494
e64f2cb57d05
child 578
6e822b534678
     1.1 --- a/NewMakefile.gmk	Thu Dec 27 20:55:53 2012 +0100
     1.2 +++ b/NewMakefile.gmk	Fri Dec 28 09:51:15 2012 +0100
     1.3 @@ -23,273 +23,107 @@
     1.4  # questions.
     1.5  #
     1.6  
     1.7 -# Utilities used in this Makefile
     1.8 -BASENAME=basename
     1.9 -CAT=cat
    1.10 -CD=cd
    1.11 -CMP=cmp
    1.12 -CP=cp
    1.13 -ECHO=echo
    1.14 -MKDIR=mkdir
    1.15 -PRINTF=printf
    1.16 -PWD=pwd
    1.17 -TAR=tar
    1.18 -ifeq ($(PLATFORM),windows)
    1.19 -  ZIP=zip
    1.20 -else
    1.21 -  # store symbolic links as the link
    1.22 -  ZIP=zip -y
    1.23 -endif
    1.24 -# Insure we have a path that looks like it came from pwd
    1.25 -#   (This is mostly for Windows sake and drive letters)
    1.26 -define UnixPath # path
    1.27 -$(shell (cd "$1" && $(PWD)))
    1.28 -endef
    1.29 +# This must be the first rule
    1.30 +default:
    1.31  
    1.32 -# Current root directory
    1.33 -CURRENT_DIRECTORY := $(shell $(PWD))
    1.34 +# Inclusion of this pseudo-target will cause make to execute this file
    1.35 +# serially, regardless of -j. Recursively called makefiles will not be
    1.36 +# affected, however. This is required for correct dependency management.
    1.37 +.NOTPARALLEL:
    1.38  
    1.39 -# Build directory root
    1.40 -BUILD_DIR_ROOT = $(CURRENT_DIRECTORY)/build
    1.41 +# The shell code below will be executed on /usr/ccs/bin/make on Solaris, but not in GNU make.
    1.42 +# /usr/ccs/bin/make lacks basically every other flow control mechanism.
    1.43 +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.44  
    1.45 -# All configured Makefiles to run
    1.46 -ALL_MAKEFILES = $(wildcard $(BUILD_DIR_ROOT)/*-*/Makefile)
    1.47 -
    1.48 -# All bundles to create
    1.49 -ALL_IMAGE_DIRS = $(wildcard $(BUILD_DIR_ROOT)/*-*/images/*-image)
    1.50 -
    1.51 -# Build all the standard 'all', 'images', and 'clean' targets
    1.52 -all images clean: checks
    1.53 -	@if [ "$(ALL_MAKEFILES)" = "" ] ; then \
    1.54 -	  $(ECHO) "ERROR: No configurations to build"; exit 1; \
    1.55 -	fi
    1.56 -	@for bdir in $(dir $(ALL_MAKEFILES)) ; do \
    1.57 -	  $(ECHO) "$(CD) $${bdir} && $(MAKE) $@" ; \
    1.58 -	  $(CD) $${bdir} && $(MAKE) $@ ; \
    1.59 -	done
    1.60 -
    1.61 -# TBD: Deploy input
    1.62 -$(BUILD_DIR_ROOT)/.deploy_input:
    1.63 -	@if [ "$(ALL_MAKEFILES)" = "" ] ; then \
    1.64 -	  $(ECHO) "ERROR: No configurations to build"; exit 1; \
    1.65 -	fi
    1.66 -	@for bdir in $(dir $(ALL_MAKEFILES)) ; do \
    1.67 -	  if [ deploy/make/Makefile ] ; then \
    1.68 -	    echo "Attempting deploy build." ; \
    1.69 -	    ( \
    1.70 -	      $(RM) -r $${bdir}/deploy_input ; \
    1.71 -	      $(MKDIR) -p $${bdir}/deploy_input ; \
    1.72 -	      ( $(CD) $${bdir}/images && $(TAR) -cf - j2sdk-image j2re-image ) \
    1.73 -	        | ( $(CD) $${bdir}/deploy_input && $(TAR) -xf - ) ; \
    1.74 -	    ) ; \
    1.75 -	  fi; \
    1.76 -	done
    1.77 -	touch $@
    1.78 -
    1.79 -# TBD: Deploy images
    1.80 -deploy: $(BUILD_DIR_ROOT)/.deploy_input
    1.81 -	@if [ "$(ALL_MAKEFILES)" = "" ] ; then \
    1.82 -	  $(ECHO) "ERROR: No configurations to build"; exit 1; \
    1.83 -	fi
    1.84 -	@for bdir in $(dir $(ALL_MAKEFILES)) ; do \
    1.85 -	  if [ deploy/make/Makefile ] ; then \
    1.86 -	    echo "Attempting deploy build." ; \
    1.87 -	    ( \
    1.88 -	      $(CD) deploy/make && \
    1.89 -	      $(MAKE) \
    1.90 -	        ABS_OUTPUTDIR=$${bdir}/deploy_input \
    1.91 -	        OUTPUTDIR=$${bdir}/deploy_input \
    1.92 -	    ) ; \
    1.93 -	  fi; \
    1.94 -	done
    1.95 -
    1.96 -# TBD: Install bundles
    1.97 -install:
    1.98 -
    1.99 -# Bundle creation
   1.100 -bundles:
   1.101 -	@if [ "$(ALL_IMAGE_DIRS)" = "" ] ; then \
   1.102 -	  $(ECHO) "ERROR: No images to bundle"; exit 1; \
   1.103 -	fi
   1.104 -	@for i in $(ALL_IMAGE_DIRS) ; do \
   1.105 -          $(MKDIR) -p $${i}/../../bundles && \
   1.106 -          $(RM) $${i}/../../bundles/`$(BASENAME) $${i}`.zip && \
   1.107 -	  $(ECHO) "$(CD) $${i} && $(ZIP) -q -r ../../bundles/`$(BASENAME) $${i}`.zip ."  && \
   1.108 -	  $(CD) $${i} && $(ZIP) -q -r ../../bundles/`$(BASENAME) $${i}`.zip . ; \
   1.109 -	done
   1.110 -
   1.111 -# Clobber all the built files
   1.112 -clobber::
   1.113 -	$(RM) -r $(BUILD_DIR_ROOT)
   1.114 -
   1.115 -# Make various checks to insure the build will be successful
   1.116 -#   Possibilities:
   1.117 -#     * Check that if any closed repo is provided, they all must be.
   1.118 -#     * Check that all open repos exist, at least until we are ready for some
   1.119 -#       kind of partial build.
   1.120 -checks:
   1.121 -	@$(ECHO) "No checks yet"
   1.122 -
   1.123 -# Keep track of user targets
   1.124 -USER_TARGETS += all deploy install images clean clobber checks
   1.125 -
   1.126 -###########################################################################
   1.127 -# To help in adoption of the new configure&&make build process, a bridge
   1.128 -#   build will use the old settings to run configure and do the build.
   1.129 -
   1.130 -# Build with the configure bridge
   1.131 -bridgeBuild: bridge2configure images
   1.132 -
   1.133 -# Bridge from old Makefile ALT settings to configure options
   1.134 -bridge2configure: $(BUILD_DIR_ROOT)/.bridge2configureOpts
   1.135 -	bash ./configure $(strip $(shell $(CAT) $<))
   1.136 -
   1.137 -# Create a file with configure options created from old Makefile mechanisms.
   1.138 -$(BUILD_DIR_ROOT)/.bridge2configureOpts: $(BUILD_DIR_ROOT)/.bridge2configureOptsLatest
   1.139 -	$(RM) $@
   1.140 -	$(CP) $< $@
   1.141 -
   1.142 -# Use this file to only change when obvious things have changed
   1.143 -$(BUILD_DIR_ROOT)/.bridge2configureOptsLatest: FRC
   1.144 -	$(RM) $@.tmp
   1.145 -	$(MKDIR) -p $(BUILD_DIR_ROOT)
   1.146 -	@$(ECHO) " --with-debug-level=$(if $(DEBUG_LEVEL),$(DEBUG_LEVEL),release) " >> $@.tmp
   1.147 -ifdef ARCH_DATA_MODEL
   1.148 -	@$(ECHO) " --with-target-bits=$(ARCH_DATA_MODEL) " >> $@.tmp
   1.149 -endif
   1.150 -ifdef ALT_PARALLEL_COMPILE_JOBS
   1.151 -	@$(ECHO) " --with-num-cores=$(ALT_PARALLEL_COMPILE_JOBS) " >> $@.tmp
   1.152 -endif
   1.153 -ifdef ALT_BOOTDIR
   1.154 -	@$(ECHO) " --with-boot-jdk=$(call UnixPath,$(ALT_BOOTDIR)) " >> $@.tmp
   1.155 -endif
   1.156 -ifdef ALT_CUPS_HEADERS_PATH
   1.157 -	@$(ECHO) " --with-cups-include=$(call UnixPath,$(ALT_CUPS_HEADERS_PATH)) " >> $@.tmp
   1.158 -endif
   1.159 -ifdef ALT_FREETYPE_HEADERS_PATH
   1.160 -	@$(ECHO) " --with-freetype=$(call UnixPath,$(ALT_FREETYPE_HEADERS_PATH)/..) " >> $@.tmp
   1.161 -endif
   1.162 -	@if [ -f $@ ] ; then \
   1.163 -          if ! $(CMP) $@ $@.tmp > /dev/null ; then \
   1.164 -            $(CP) $@.tmp $@ ; \
   1.165 -          fi ; \
   1.166 -        else \
   1.167 -          $(CP) $@.tmp $@ ; \
   1.168 -        fi
   1.169 -	$(RM) $@.tmp
   1.170 -
   1.171 -# Clobber all the built files
   1.172 -clobber:: bridge2clobber
   1.173 -bridge2clobber::
   1.174 -	$(RM) $(BUILD_DIR_ROOT)/.bridge2*
   1.175 -	$(RM) $(BUILD_DIR_ROOT)/.deploy_input
   1.176 -
   1.177 -# Keep track of phony targets
   1.178 -PHONY_LIST += bridge2configure bridgeBuild bridge2clobber
   1.179 -
   1.180 -###########################################################################
   1.181 -# Sanity checks (history target)
   1.182 -#
   1.183 -
   1.184 -sanity: checks
   1.185 -
   1.186 -# Keep track of user targets
   1.187 -USER_TARGETS += sanity
   1.188 -
   1.189 -###########################################################################
   1.190 -# Javadocs
   1.191 -#
   1.192 -
   1.193 -javadocs:
   1.194 -	cd common/makefiles && $(MAKE) -f MakefileJavadoc.gmk
   1.195 -
   1.196 -# Keep track of user targets
   1.197 -USER_TARGETS += javadocs
   1.198 -
   1.199 -###########################################################################
   1.200 -# JPRT targets
   1.201 -
   1.202 -ifndef JPRT_ARCHIVE_BUNDLE
   1.203 -  JPRT_ARCHIVE_BUNDLE=/tmp/jprt_bundles/j2sdk-image.zip
   1.204 +# Assume we have GNU make, but check version.
   1.205 +ifeq (,$(findstring 3.81,$(MAKE_VERSION)))
   1.206 +    ifeq (,$(findstring 3.82,$(MAKE_VERSION)))
   1.207 +        $(error This version of GNU Make is too low ($(MAKE_VERSION)). Check your path, or upgrade to 3.81 or newer.)
   1.208 +    endif
   1.209  endif
   1.210  
   1.211 -jprt_build_product: DEBUG_LEVEL=release
   1.212 -jprt_build_product: BUILD_DIRNAME=*-release
   1.213 -jprt_build_product: jprt_build_generic
   1.214 +# Locate this Makefile
   1.215 +ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),)
   1.216 +    makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST))
   1.217 +else
   1.218 +    makefile_path:=$(lastword $(MAKEFILE_LIST))
   1.219 +endif
   1.220 +root_dir:=$(dir $(makefile_path))
   1.221  
   1.222 -jprt_build_fastdebug: DEBUG_LEVEL=fastdebug
   1.223 -jprt_build_fastdebug: BUILD_DIRNAME=*-fastdebug
   1.224 -jprt_build_fastdebug: jprt_build_generic
   1.225 +include $(root_dir)/common/makefiles/Jprt.gmk
   1.226  
   1.227 -jprt_build_debug: DEBUG_LEVEL=slowdebug
   1.228 -jprt_build_debug: BUILD_DIRNAME=*-debug
   1.229 -jprt_build_debug: jprt_build_generic
   1.230 +# ... and then we can include our helper functions
   1.231 +include $(root_dir)/common/makefiles/MakeHelpers.gmk
   1.232  
   1.233 -jprt_build_generic: $(JPRT_ARCHIVE_BUNDLE)
   1.234 +$(eval $(call ParseLogLevel))
   1.235 +$(eval $(call ParseConfAndSpec))
   1.236  
   1.237 -$(JPRT_ARCHIVE_BUNDLE): bridgeBuild bundles
   1.238 -	$(MKDIR) -p $(@D)
   1.239 -	$(RM) $@
   1.240 -	$(CP) $(BUILD_DIR_ROOT)/$(BUILD_DIRNAME)/bundles/j2sdk-image.zip $@
   1.241 +# Now determine if we have zero, one or several configurations to build.
   1.242 +ifeq ($(SPEC),)
   1.243 +    # Since we got past ParseConfAndSpec, we must be building a global target. Do nothing.
   1.244 +else
   1.245 +    ifeq ($(words $(SPEC)),1)
   1.246 +        # We are building a single configuration. This is the normal case. Execute the Main.gmk file.
   1.247 +        include $(root_dir)/common/makefiles/Main.gmk
   1.248 +    else
   1.249 +        # We are building multiple configurations.
   1.250 +        # First, find out the valid targets
   1.251 +        # Run the makefile with an arbitraty SPEC using -p -q (quiet dry-run and dump rules) to find
   1.252 +        # available PHONY targets. Use this list as valid targets to pass on to the repeated calls.
   1.253 +        all_phony_targets=$(filter-out $(global_targets), $(strip $(shell \
   1.254 +            $(MAKE) -p -q -f common/makefiles SPEC=$(firstword $(SPEC)) | \
   1.255 +            grep ^.PHONY: | head -n 1 | cut -d " " -f 2-)))
   1.256  
   1.257 -# Keep track of phony targets
   1.258 -PHONY_LIST += jprt_build_product jprt_build_fastdebug jprt_build_debug \
   1.259 -              jprt_build_generic
   1.260 +$(all_phony_targets):
   1.261 +	@$(foreach spec,$(SPEC),($(MAKE) -f NewMakefile.gmk SPEC=$(spec) $(VERBOSE) VERBOSE=$(VERBOSE) $@) &&) true
   1.262  
   1.263 -###########################################################################
   1.264 -# Help target
   1.265 +    endif
   1.266 +endif
   1.267  
   1.268 -HELP_FORMAT=%12s%s\n
   1.269 +# Here are "global" targets, i.e. targets that can be executed without specifying a single configuration.
   1.270 +# If you addd more global targets, please update the variable global_targets in MakeHelpers.
   1.271  
   1.272  help:
   1.273 -	@$(PRINTF) "# JDK Makefile\n"
   1.274 -	@$(PRINTF) "#\n"
   1.275 -	@$(PRINTF) "# Usage: make [Target]\n"
   1.276 -	@$(PRINTF) "#\n"
   1.277 -	@$(PRINTF) "#   $(HELP_FORMAT)" "Target   " "Description"
   1.278 -	@$(PRINTF) "#   $(HELP_FORMAT)" "------   " "-----------"
   1.279 -	@for i in $(USER_TARGETS) ; do \
   1.280 -	  $(MAKE) help_$${i} ; \
   1.281 -	done
   1.282 -	@$(PRINTF) "#\n"
   1.283 +	$(info )
   1.284 +	$(info OpenJDK Makefile help)
   1.285 +	$(info =====================)
   1.286 +	$(info )
   1.287 +	$(info Common make targets)
   1.288 +	$(info .  make [default]         # Compile all product in langtools, hotspot, jaxp, jaxws,)
   1.289 +	$(info .                         # corba and jdk)
   1.290 +	$(info .  make all               # Compile everything, all repos and images)
   1.291 +	$(info .  make images            # Create complete j2sdk and j2re images)
   1.292 +	$(info .  make overlay-images    # Create limited images for sparc 64 bit platforms)
   1.293 +	$(info .  make bootcycle-images  # Build images twice, second time with newly build JDK)
   1.294 +	$(info .  make install           # Install the generated images locally)
   1.295 +	$(info .  make clean             # Remove all files generated by make, but not those)
   1.296 +	$(info .                         # generated by configure)
   1.297 +	$(info .  make dist-clean        # Remove all files, including configuration)
   1.298 +	$(info .  make help              # Give some help on using make)
   1.299 +	$(info .  make test              # Run tests, default is all tests (see TEST below))
   1.300 +	$(info )
   1.301 +	$(info Targets for specific components)
   1.302 +	$(info (Component is any of langtools, corba, jaxp, jaxws, hotspot, jdk, images or overlay-images))
   1.303 +	$(info .  make <component>       # Build <component> and everything it depends on. )
   1.304 +	$(info .  make <component>-only  # Build <component> only, without dependencies. This)
   1.305 +	$(info .                         # is faster but can result in incorrect build results!)
   1.306 +	$(info .  make clean-<component> # Remove files generated by make for <component>)
   1.307 +	$(info )
   1.308 +	$(info Useful make variables)
   1.309 +	$(info .  make CONF=             # Build all configurations (note, assignment is empty))
   1.310 +	$(info .  make CONF=<substring>  # Build the configuration(s) with a name matching)
   1.311 +	$(info .                         # <substring>)
   1.312 +	$(info )
   1.313 +	$(info .  make LOG=<loglevel>    # Change the log level from warn to <loglevel>)
   1.314 +	$(info .                         # Available log levels are:)
   1.315 +	$(info .                         # 'warn' (default), 'info', 'debug' and 'trace')
   1.316 +	$(info .                         # To see executed command lines, use LOG=debug)
   1.317 +	$(info )
   1.318 +	$(info .  make JOBS=<n>          # Run <n> parallel make jobs)
   1.319 +	$(info .                         # Note that -jN does not work as expected!)
   1.320 +	$(info )
   1.321 +	$(info .  make test TEST=<test>  # Only run the given test or tests, e.g.)
   1.322 +	$(info .                         # make test TEST="jdk_lang jdk_net")
   1.323 +	$(info )
   1.324  
   1.325 -help_all:
   1.326 -	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
   1.327 -	"Build the entire jdk but not the images"
   1.328 -help_images:
   1.329 -	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
   1.330 -	"Create the jdk images for the builds"
   1.331 -help_deploy:
   1.332 -	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
   1.333 -	"Create the jdk deploy images from the jdk images"
   1.334 -help_install:
   1.335 -	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
   1.336 -	"Create the jdk install bundles from the deploy images"
   1.337 -help_clean:
   1.338 -	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
   1.339 -	"Clean and prepare for a fresh build from scratch"
   1.340 -help_clobber:
   1.341 -	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
   1.342 -	"Clean and also purge any hidden derived data"
   1.343 -help_checks:
   1.344 -	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
   1.345 -	"Perform various checks to make sure we can build"
   1.346 -help_sanity:
   1.347 -	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
   1.348 -	"Same as 'make checks'"
   1.349 -help_javadocs:
   1.350 -	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
   1.351 -	"Build the javadocs"
   1.352 -help_help:
   1.353 -	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
   1.354 -	"Print out the help messages"
   1.355 -
   1.356 -# Keep track of user targets
   1.357 -USER_TARGETS += help
   1.358 -
   1.359 -###########################################################################
   1.360 -# Phony targets
   1.361 -.PHONY: $(PHONY_LIST) $(USER_TARGETS)
   1.362 -
   1.363 -# Force target
   1.364 -FRC:
   1.365 +.PHONY: help

mercurial