Makefile

Sun, 09 Mar 2008 15:47:58 -0700

author
ohair
date
Sun, 09 Mar 2008 15:47:58 -0700
changeset 7
d6b08bdb9a54
parent 6
d83470fdf495
child 10
cbc8ad9dd0e0
permissions
-rw-r--r--

6649672: Adjustments to OUTPUTDIR default and mkdirs to avoid empty directory clutter
Summary: Cleanup of OUTPUTDIR handling
Reviewed-by: xdono

     1 #
     2 # Copyright 1995-2007 Sun Microsystems, Inc.  All Rights Reserved.
     3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4 #
     5 # This code is free software; you can redistribute it and/or modify it
     6 # under the terms of the GNU General Public License version 2 only, as
     7 # published by the Free Software Foundation.  Sun designates this
     8 # particular file as subject to the "Classpath" exception as provided
     9 # by Sun in the LICENSE file that accompanied this code.
    10 #
    11 # This code is distributed in the hope that it will be useful, but WITHOUT
    12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14 # version 2 for more details (a copy is included in the LICENSE file that
    15 # accompanied this code).
    16 #
    17 # You should have received a copy of the GNU General Public License version
    18 # 2 along with this work; if not, write to the Free Software Foundation,
    19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20 #
    21 # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    22 # CA 95054 USA or visit www.sun.com if you need additional information or
    23 # have any questions.
    24 #
    26 BUILD_PARENT_DIRECTORY=.
    28 ifndef TOPDIR
    29   TOPDIR:=$(shell \
    30     if [ -r ./j2se/make/Makefile -o -r ./jdk/make/Makefile ]; then \
    31       echo "."; \
    32     else \
    33       echo "../.."; \
    34     fi)
    35 endif
    37 ifndef CONTROL_TOPDIR
    38   CONTROL_TOPDIR=$(TOPDIR)/control
    39   CONTROL_TOPDIR:=$(shell \
    40     if [ -r $(TOPDIR)/control/make/Makefile ]; then \
    41       echo "$(TOPDIR)/control"; \
    42     else \
    43       echo "$(TOPDIR)"; \
    44     fi)
    45 endif
    47 # Openjdk sources (only used if SKIP_OPENJDK_BUILD!=true)
    48 OPENJDK_SOURCETREE=$(TOPDIR)/openjdk
    49 OPENJDK_BUILDDIR:=$(shell \
    50   if [ -r $(OPENJDK_SOURCETREE)/control/make/Makefile ]; then \
    51     echo "$(OPENJDK_SOURCETREE)/control/make"; \
    52   elif [ -r $(OPENJDK_SOURCETREE)/Makefile ]; then \
    53     echo "$(OPENJDK_SOURCETREE)"; \
    54   else \
    55     echo "."; \
    56   fi)
    58 ifndef JDK_TOPDIR
    59   JDK_TOPDIR=$(TOPDIR)/jdk
    60 endif
    61 ifndef JDK_MAKE_SHARED_DIR
    62   JDK_MAKE_SHARED_DIR=$(JDK_TOPDIR)/make/common/shared
    63 endif
    65 include $(JDK_MAKE_SHARED_DIR)/Defs-control.gmk
    67 include ./make/Defs-internal.gmk
    69 all::
    70 	@$(ECHO) $(PLATFORM) $(ARCH) $(RELEASE) build started: `$(DATE) '+%y-%m-%d %H:%M'`
    71 	$(MKDIR) -p $(OUTPUTDIR)
    73 # Rules for sanity checks
    74 include ./make/sanity-rules.gmk
    76 dev : dev-build
    78 dev-build:
    79 	$(MAKE) DEV_ONLY=true all
    80 dev-sanity:
    81 	$(MAKE) DEV_ONLY=true sanity
    82 dev-clobber:
    83 	$(MAKE) DEV_ONLY=true clobber
    85 # Rules for various components
    86 include ./make/hotspot-rules.gmk
    87 include ./make/langtools-rules.gmk
    88 include ./make/corba-rules.gmk
    89 include ./make/jaxp-rules.gmk
    90 include ./make/jaxws-rules.gmk
    91 include ./make/jdk-rules.gmk
    92 include ./make/install-rules.gmk
    93 include ./make/sponsors-rules.gmk
    94 include ./make/deploy-rules.gmk
    96 all:: setup build
    98 setup: openjdk_check
    99 	$(MKDIR) -p $(OUTPUTDIR)/j2sdk-image
   101 # Check on whether we really can build the openjdk, need source etc.
   102 openjdk_check: FRC
   103 ifneq ($(SKIP_OPENJDK_BUILD), true)
   104 	@$(ECHO) " "
   105 	@$(ECHO) "================================================="
   106 	@if [ ! -r $(OPENJDK_BUILDDIR)/Makefile ] ; then \
   107 	    $(ECHO) "ERROR: No openjdk source tree available at: $(OPENJDK_BUILDDIR)"; \
   108 	    exit 1; \
   109 	else \
   110 	    $(ECHO) "OpenJDK will be built after JDK is built"; \
   111 	    $(ECHO) "  OPENJDK_BUILDDIR=$(OPENJDK_BUILDDIR)"; \
   112 	fi
   113 	@$(ECHO) "================================================="
   114 	@$(ECHO) " "
   115 endif
   117 build:: sanity 
   119 clobber::
   121 ifeq ($(BUILD_LANGTOOLS), true)
   122   build:: langtools
   123   clobber:: langtools-clobber
   124 endif
   126 ifeq ($(BUILD_CORBA), true)
   127   build:: corba
   128   clobber:: corba-clobber
   129 endif
   131 ifeq ($(BUILD_JAXP), true)
   132   build:: jaxp
   133   clobber:: jaxp-clobber
   134 endif
   136 ifeq ($(BUILD_JAXWS), true)
   137   build:: jaxws
   138   clobber:: jaxws-clobber
   139 endif
   141 ifeq ($(BUILD_HOTSPOT), true)
   142   build:: $(HOTSPOT) 
   143   clobber:: hotspot-clobber
   144 endif
   146 ifeq ($(BUILD_JDK), true)
   147   build:: $(JDK_JAVA_EXE)
   148   clobber:: jdk-clobber
   149 endif
   151 ifeq ($(BUILD_DEPLOY), true)
   152   build:: $(DEPLOY)
   153   clobber:: deploy-clobber
   154 endif
   156 #
   157 # Generic debug build, fastdebug or debug. Needs special handling.
   158 #  Note that debug builds do NOT do INSTALL steps, but must be done
   159 #  after the product build and before the INSTALL step of the product build.
   160 #
   161 #   DEBUG_NAME is fastdebug or debug
   162 #   ALT_OUTPUTDIR is changed to have -debug or -fastdebug suffix
   163 #   The resulting j2sdk-image is used by the install makefiles to create a
   164 #     debug install bundle jdk-*-debug-** bundle (tar or zip) 
   165 #     which will install in the debug or fastdebug subdirectory of the
   166 #     normal product install area.
   167 #     The install process needs to know what the DEBUG_NAME is, so
   168 #     look for INSTALL_DEBUG_NAME in the install rules.
   169 #
   171 COMMON_DEBUG_FLAGS= \
   172 	DEBUG_NAME=$(DEBUG_NAME) \
   173 	ALT_OUTPUTDIR=$(ABS_OUTPUTDIR)-$(DEBUG_NAME) \
   174 	NO_DOCS=true
   176 product_build: setup
   177 	@$(ECHO) $@ build started: `$(DATE) '+%y-%m-%d %H:%M'`
   178 	$(MAKE) SKIP_FASTDEBUG_BUILD=true SKIP_DEBUG_BUILD=true all
   179 	@$(ECHO) $@ build finished: `$(DATE) '+%y-%m-%d %H:%M'`
   181 generic_debug_build:
   182 	@$(ECHO) $@ build started: `$(DATE) '+%y-%m-%d %H:%M'`
   183 	$(MAKE) $(COMMON_DEBUG_FLAGS) setup build
   184 	@$(ECHO) $@ build finished: `$(DATE) '+%y-%m-%d %H:%M'`
   186 debug_build: setup
   187 	$(MAKE) DEBUG_NAME=debug generic_debug_build
   189 fastdebug_build: setup
   190 	$(MAKE) DEBUG_NAME=fastdebug generic_debug_build
   192 ifeq ($(SKIP_FASTDEBUG_BUILD), false)
   193   all:: fastdebug_build
   194 endif
   196 ifeq ($(SKIP_DEBUG_BUILD), false)
   197   all:: debug_build
   198 endif
   200 ifeq ($(BUILD_JDK), true)
   201   ifeq ($(BUNDLE_RULES_AVAILABLE), true)
   202     all:: openjdk-binary-plugs-bundles
   203   endif
   204 endif
   206 ifeq ($(BUILD_INSTALL), true)
   207   all :: $(INSTALL)
   208   clobber:: install-clobber
   209 endif
   211 ifeq ($(BUILD_SPONSORS), true)
   212   all :: $(SPONSORS)
   213   clobber:: sponsors-clobber
   214 endif
   216 ifneq ($(SKIP_COMPARE_IMAGES), true)
   217   all :: compare-image
   218 endif
   220 ifneq ($(SKIP_OPENJDK_BUILD), true)
   221   all :: openjdk_build
   222 endif
   224 # If we have bundle rules, we have a chance here to do a complete cycle
   225 #   build, of production and open build.
   226 # FIXUP: We should create the openjdk source bundle and build that?
   227 #   But how do we reliable create or get at a formal openjdk source tree?
   228 #   The one we have needs to be trimmed of built bits and closed dirs.
   229 #   The repositories might not be available.
   230 #   The openjdk source bundle is probably not available.
   232 ifneq ($(SKIP_OPENJDK_BUILD), true)
   233   ifeq ($(BUILD_JDK), true)
   234     ifeq ($(BUNDLE_RULES_AVAILABLE), true)
   236 OPENJDK_PLUGS=$(ABS_OUTPUTDIR)/$(OPENJDK_BINARY_PLUGS_INAME)
   237 OPENJDK_OUTPUTDIR=$(ABS_OUTPUTDIR)/open-output
   238 OPENJDK_BUILD_NAME \
   239   = openjdk-$(JDK_MINOR_VERSION)-$(BUILD_NUMBER)-$(PLATFORM)-$(ARCH)-$(BUNDLE_DATE)
   240 OPENJDK_BUILD_BINARY_ZIP=$(ABS_BIN_BUNDLEDIR)/$(OPENJDK_BUILD_NAME).zip
   241 BUILT_IMAGE=$(ABS_OUTPUTDIR)/j2sdk-image
   242 ifeq ($(PLATFORM)$(ARCH_DATA_MODEL),solaris64)
   243   OPENJDK_BOOTDIR=$(BOOTDIR)
   244   OPENJDK_IMPORTJDK=$(JDK_IMPORT_PATH)
   245 else
   246   OPENJDK_BOOTDIR=$(BUILT_IMAGE)
   247   OPENJDK_IMPORTJDK=$(BUILT_IMAGE)
   248 endif
   250 openjdk_build:
   251 	@$(ECHO) " "
   252 	@$(ECHO) "================================================="
   253 	@$(ECHO) "Starting openjdk build"
   254 	@$(ECHO) " Using: ALT_JDK_DEVTOOLS_DIR=$(JDK_DEVTOOLS_DIR)"
   255 	@$(ECHO) "================================================="
   256 	@$(ECHO) " "
   257 	$(RM) -r $(OPENJDK_OUTPUTDIR)
   258 	$(MKDIR) -p $(OPENJDK_OUTPUTDIR)
   259 	($(CD) $(OPENJDK_BUILDDIR) && $(MAKE) \
   260 	  OPENJDK=true \
   261 	  ALT_JDK_DEVTOOLS_DIR=$(JDK_DEVTOOLS_DIR) \
   262 	  ALT_OUTPUTDIR=$(OPENJDK_OUTPUTDIR) \
   263 	  ALT_BINARY_PLUGS_PATH=$(OPENJDK_PLUGS) \
   264 	  ALT_BOOTDIR=$(OPENJDK_BOOTDIR) \
   265 	  ALT_JDK_IMPORT_PATH=$(OPENJDK_IMPORTJDK) \
   266 		product_build )
   267 	$(RM) $(OPENJDK_BUILD_BINARY_ZIP)
   268 	( $(CD) $(OPENJDK_OUTPUTDIR)/j2sdk-image && \
   269 	  $(ZIPEXE) -q -r $(OPENJDK_BUILD_BINARY_ZIP) .)
   270 	$(RM) -r $(OPENJDK_OUTPUTDIR)
   271 	@$(ECHO) " "
   272 	@$(ECHO) "================================================="
   273 	@$(ECHO) "Finished openjdk build"
   274 	@$(ECHO) " Binary Bundle: $(OPENJDK_BUILD_BINARY_ZIP)"
   275 	@$(ECHO) "================================================="
   276 	@$(ECHO) " "
   278     endif
   279   endif
   280 endif
   282 clobber::
   283 	$(RM) -r $(OUTPUTDIR)/*
   284 	$(RM) -r $(OUTPUTDIR)-debug/*
   285 	$(RM) -r $(OUTPUTDIR)-fastdebug/*
   286 	-($(RMDIR) -p $(OUTPUTDIR) > $(DEV_NULL) 2>&1; $(TRUE))
   288 clean: clobber
   290 all:: 
   291 	@$(ECHO) Control build finished: `$(DATE) '+%y-%m-%d %H:%M'`
   293 #
   294 # Quick jdk verification build
   295 #
   296 jdk_only:
   297 	$(MAKE) SKIP_FASTDEBUG_BUILD=true BUILD_HOTSPOT=false all
   300 #
   301 # Quick jdk verification fastdebug build
   302 #
   303 jdk_fastdebug_only:
   304 	$(MAKE) DEBUG_NAME=fastdebug BUILD_HOTSPOT=false BUILD_DEPLOY=false \
   305 	    BUILD_INSTALL=false BUILD_SPONSORS=false generic_debug_build
   307 #
   308 # Quick deploy verification fastdebug build
   309 #
   310 deploy_fastdebug_only:
   311 	$(MAKE) \
   312 	    DEBUG_NAME=fastdebug \
   313 	    BUILD_HOTSPOT=false \
   314 	    BUILD_JDK=false \
   315 	    BUILD_LANGTOOLS=false \
   316 	    BUILD_CORBA=false \
   317 	    BUILD_JAXP=false \
   318 	    BUILD_JAXWS=false \
   319 	    BUILD_INSTALL=false \
   320 	    BUILD_SPONSORS=false \
   321 	    generic_debug_build
   323 #
   324 # Product build (skip debug builds)
   325 #
   326 product_only:
   327 	$(MAKE) SKIP_FASTDEBUG_BUILD=true all
   329 #
   330 # Check target
   331 #
   333 check: variable_check
   335 #
   336 # Help target
   337 #
   338 help: intro_help target_help variable_help notes_help examples_help
   340 # Intro help message
   341 intro_help:
   342 	@$(ECHO) "\
   343 Makefile for the JDK builds (all the JDK). \n\
   344 "
   346 # Target help
   347 target_help:
   348 	@$(ECHO) "\
   349 --- Common Targets ---  \n\
   350 all               -- build the core JDK (default target) \n\
   351 help              -- Print out help information \n\
   352 check             -- Check make variable values for correctness \n\
   353 sanity            -- Perform detailed sanity checks on system and settings \n\
   354 fastdebug_build   -- build the core JDK in 'fastdebug' mode (-g -O) \n\
   355 debug_build       -- build the core JDK in 'debug' mode (-g) \n\
   356 clean             -- remove all built and imported files \n\
   357 clobber           -- same as clean \n\
   358 "
   360 # Variable help (only common ones used by this Makefile)
   361 variable_help: variable_help_intro variable_list variable_help_end
   362 variable_help_intro:
   363 	@$(ECHO) "--- Common Variables ---"
   364 variable_help_end:
   365 	@$(ECHO) " "
   367 # One line descriptions for the variables
   368 OUTPUTDIR.desc             = Output directory
   369 PARALLEL_COMPILE_JOBS.desc = Solaris/Linux parallel compile run count
   370 SLASH_JAVA.desc            = Root of all build tools, e.g. /java or J:
   371 BOOTDIR.desc               = JDK used to boot the build
   372 JDK_IMPORT_PATH.desc       = JDK used to import components of the build
   373 COMPILER_PATH.desc         = Compiler install directory
   374 CACERTS_FILE.desc          = Location of certificates file
   375 DEVTOOLS_PATH.desc         = Directory containing zip and gnumake
   376 CUPS_HEADERS_PATH.desc     = Include directory location for CUPS header files
   377 DXSDK_PATH.desc            = Root directory of DirectX SDK
   378 MSDEVTOOLS_PATH.desc       = Root directory of VC++ tools (e.g. rc.exe)
   379 MSVCRT_DLL_PATH.desc       = Directory containing mscvrt.dll
   381 # Make variables to print out (description and value)
   382 VARIABLE_PRINTVAL_LIST +=       \
   383     OUTPUTDIR                   \
   384     PARALLEL_COMPILE_JOBS       \
   385     SLASH_JAVA                  \
   386     BOOTDIR                     \
   387     JDK_IMPORT_PATH             \
   388     COMPILER_PATH               \
   389     CACERTS_FILE                \
   390     DEVTOOLS_PATH
   392 # Make variables that should refer to directories that exist
   393 VARIABLE_CHECKDIR_LIST +=       \
   394     SLASH_JAVA                  \
   395     BOOTDIR                     \
   396     JDK_IMPORT_PATH             \
   397     COMPILER_PATH               \
   398     DEVTOOLS_PATH 
   400 # Make variables that should refer to files that exist
   401 VARIABLE_CHECKFIL_LIST +=       \
   402     CACERTS_FILE
   404 # Some are windows specific
   405 ifeq ($(PLATFORM), windows)
   407 VARIABLE_PRINTVAL_LIST +=       \
   408     DXSDK_PATH                  \
   409     MSDEVTOOLS_PATH             \
   410     MSVCRT_DLL_PATH
   412 VARIABLE_CHECKDIR_LIST +=       \
   413     DXSDK_PATH                  \
   414     MSDEVTOOLS_PATH             \
   415     MSVCRT_DLL_PATH
   417 endif
   419 # For pattern rules below, so all are treated the same
   420 DO_PRINTVAL_LIST=$(VARIABLE_PRINTVAL_LIST:%=%.printval)
   421 DO_CHECKDIR_LIST=$(VARIABLE_CHECKDIR_LIST:%=%.checkdir)
   422 DO_CHECKFIL_LIST=$(VARIABLE_CHECKFIL_LIST:%=%.checkfil)
   424 # Complete variable check
   425 variable_check: $(DO_CHECKDIR_LIST) $(DO_CHECKFIL_LIST)
   426 variable_list: $(DO_PRINTVAL_LIST) variable_check
   428 # Pattern rule for printing out a variable
   429 %.printval:
   430 	@$(ECHO) "  ALT_$* - $($*.desc)"
   431 	@$(ECHO) "  \t $*=$($*)"
   433 # Pattern rule for checking to see if a variable with a directory exists
   434 %.checkdir:
   435 	@if [ ! -d $($*) ] ; then \
   436 	    $(ECHO) "WARNING: $* does not exist, try $(MAKE) sanity"; \
   437 	fi
   439 # Pattern rule for checking to see if a variable with a file exists
   440 %.checkfil:
   441 	@if [ ! -f $($*) ] ; then \
   442 	    $(ECHO) "WARNING: $* does not exist, try $(MAKE) sanity"; \
   443 	fi
   445 # Misc notes on help
   446 notes_help:
   447 	@$(ECHO) "\
   448 --- Notes --- \n\
   449 - All builds use same output directory unless overridden with \n\
   450  \t ALT_OUTPUTDIR=<dir>, changing from product to fastdebug you may want \n\
   451  \t to use the clean target first. \n\
   452 - JDK_IMPORT_PATH must refer to a compatible build, not all past promoted \n\
   453  \t builds or previous release JDK builds will work. \n\
   454 - The fastest builds have been when the sources and the BOOTDIR are on \n\
   455  \t local disk. \n\
   456 "
   458 examples_help:
   459 	@$(ECHO) "\
   460 --- Examples --- \n\
   461   $(MAKE) fastdebug_build \n\
   462   $(MAKE) ALT_OUTPUTDIR=/tmp/foobar all \n\
   463   $(MAKE) ALT_OUTPUTDIR=/tmp/foobar fastdebug_build \n\
   464   $(MAKE) ALT_OUTPUTDIR=/tmp/foobar all \n\
   465   $(MAKE) ALT_BOOTDIR=/opt/java/jdk1.5.0 \n\
   466   $(MAKE) ALT_JDK_IMPORT_PATH=/opt/java/jdk1.6.0 \n\
   467 "
   469 ################################################################
   470 # Source and binary plug bundling
   471 ################################################################
   472 ifeq ($(BUNDLE_RULES_AVAILABLE), true)
   473   include $(BUNDLE_RULES)
   474 endif
   476 ################################################################
   477 # Cycle build. Build the jdk, use it to build the jdk again.
   478 ################################################################
   480 ABS_BOOTDIR_OUTPUTDIR=$(ABS_OUTPUTDIR)/bootjdk
   482 boot_cycle:
   483 	$(MAKE) ALT_OUTPUTDIR=$(ABS_BOOTDIR_OUTPUTDIR) product_build
   484 	$(MAKE) ALT_BOOTDIR=$(ABS_BOOTDIR_OUTPUTDIR)/j2sdk-image product_build
   486 ################################################################
   487 # JPRT rule to build
   488 ################################################################
   490 include ./make/jprt.gmk
   492 ################################################################
   493 #  PHONY
   494 ################################################################
   496 .PHONY: all build what clobber insane \
   497 	fastdebug_build debug_build product_build setup \
   498         dev dev-build dev-sanity dev-clobber
   500 # FIXUP: Old j2se targets
   501 j2se_fastdebug_only: jdk_fastdebug_only
   502 j2se_only: jdk_only
   504 # Force target
   505 FRC:

mercurial