langtools/make/Makefile
changeset 21887 8dc93a1c9782
parent 7847 5d1dad3342a3
child 22448 a85fbad9d687
equal deleted inserted replaced
21718:74a5882faf79 21887:8dc93a1c9782
     1 #
     1 #
     2 # Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
     2 # Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4 #
     4 #
     5 # This code is free software; you can redistribute it and/or modify it
     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
     6 # under the terms of the GNU General Public License version 2 only, as
     7 # published by the Free Software Foundation.  Oracle designates this
     7 # published by the Free Software Foundation.  Oracle designates this
    21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    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 # Makefile for langtools: wrapper around Ant build.xml file
    26 # Locate this Makefile
       
    27 ifeq ($(filter /%, $(lastword $(MAKEFILE_LIST))), )
       
    28   makefile_path := $(CURDIR)/$(lastword $(MAKEFILE_LIST))
       
    29 else
       
    30   makefile_path := $(lastword $(MAKEFILE_LIST))
       
    31 endif
       
    32 repo_dir := $(patsubst %/make/Makefile, %, $(makefile_path))
    27 
    33 
    28 #
    34 # What is the name of this subsystem (langtools, corba, etc)?
    29 # On Solaris, the standard 'make' utility will not work with these makefiles.
    35 subsystem_name := $(notdir $(repo_dir))
    30 #    This little rule is only understood by Solaris make, and is harmless
       
    31 #    when seen by the GNU make tool. If using Solaris make, this causes the
       
    32 #    make command to fail.
       
    33 #
       
    34 SUN_MAKE_TEST:sh = @echo "ERROR: PLEASE USE GNU VERSION OF MAKE"; exit 33
       
    35 
    36 
    36 #
    37 # Try to locate top-level makefile
    37 # Minimal platform defs
    38 top_level_makefile := $(repo_dir)/../Makefile
    38 # Need FullPath because we can't rely on gnumake abspath, until we use v3.81
    39 ifneq ($(wildcard $(top_level_makefile)), )
    39 #
    40   $(info Will run $(subsystem_name) target on top-level Makefile)
    40 
    41   $(info WARNING: This is a non-recommended way of building!)
    41 SYSTEM_UNAME := $(shell uname)
    42   $(info ===================================================)
    42 
       
    43 # Where is unwanted output to be delivered?
       
    44 # On Windows, MKS uses the special file "NUL", cygwin uses the customary unix file.
       
    45 ifeq ($(SYSTEM_UNAME), Windows_NT)
       
    46 DEV_NULL = NUL
       
    47 else
    43 else
    48 DEV_NULL = /dev/null 
    44   $(info Cannot locate top-level Makefile. Is this repo not checked out as part of a complete forest?)
       
    45   $(error Build from top-level Makefile instead)
    49 endif
    46 endif
    50 
    47 
    51 ifneq (,$(findstring CYGWIN,$(SYSTEM_UNAME)))
    48 all:
    52 USING_CYGWIN = true
    49 	@$(MAKE) -f $(top_level_makefile) $(subsystem_name)
    53 endif
       
    54 
       
    55 ifdef USING_CYGWIN
       
    56 define FullPath
       
    57 $(shell cygpath -a -s -m $1 2> $(DEV_NULL))
       
    58 endef
       
    59 else
       
    60 define FullPath
       
    61 $(shell cd $1 2> $(DEV_NULL) && pwd)
       
    62 endef
       
    63 endif
       
    64 
       
    65 #
       
    66 # Makefile args
       
    67 #
       
    68 
       
    69 ifdef QUIET
       
    70   ANT_OPTIONS += -quiet
       
    71 endif
       
    72 
       
    73 ifdef VERBOSE
       
    74   ANT_OPTIONS += -verbose -debug
       
    75 endif
       
    76 
       
    77 ifdef JDK_VERSION
       
    78   ANT_OPTIONS += -Djdk.version=$(JDK_VERSION)
       
    79 endif 
       
    80 
       
    81 ifdef FULL_VERSION
       
    82   ANT_OPTIONS += -Dfull.version='$(FULL_VERSION)' # will contain spaces
       
    83 endif 
       
    84 
       
    85 ifdef MILESTONE
       
    86 ifneq ($(MILESTONE),fcs)
       
    87   ANT_OPTIONS += -Dmilestone=$(MILESTONE)
       
    88 else
       
    89   ANT_OPTIONS += -Drelease=$(JDK_VERSION)
       
    90 endif
       
    91 endif
       
    92 
       
    93 ifdef BUILD_NUMBER
       
    94   ANT_OPTIONS += -Dbuild.number=$(BUILD_NUMBER)
       
    95 else
       
    96   ifdef JDK_BUILD_NUMBER
       
    97     ANT_OPTIONS += -Dbuild.number=$(JDK_BUILD_NUMBER)
       
    98   endif
       
    99 endif
       
   100 
       
   101 ifeq ($(VARIANT), DBG)
       
   102   ANT_OPTIONS += -Djavac.debug=true
       
   103 else
       
   104   ifeq ($(VARIANT), OPT)
       
   105     ANT_OPTIONS += -Djavac.debug=false
       
   106   endif
       
   107 endif
       
   108 
       
   109 ifeq ($(DEBUG_CLASSFILES), true)
       
   110   ANT_OPTIONS += -Djavac.debug=true
       
   111   ANT_OPTIONS += -Ddebug.classfiles=true
       
   112 endif
       
   113 
       
   114 # Note: jdk/make/common/Defs.gmk uses LANGUAGE_VERSION (-source NN)
       
   115 # and the somewhat misnamed CLASS_VERSION (-target NN)
       
   116 ifdef TARGET_CLASS_VERSION
       
   117   ANT_OPTIONS += -Djavac.target=$(TARGET_CLASS_VERSION)
       
   118 else
       
   119   ifdef JAVAC_TARGET_ARG 
       
   120     ANT_OPTIONS += -Djavac.target=$(JAVAC_TARGET_ARG)
       
   121   endif
       
   122 endif 
       
   123 
       
   124 ifdef SOURCE_LANGUAGE_VERSION
       
   125   ANT_OPTIONS += -Djavac.source=$(SOURCE_LANGUAGE_VERSION)
       
   126 else
       
   127   ifdef JAVAC_SOURCE_ARG 
       
   128     ANT_OPTIONS += -Djavac.source=$(JAVAC_SOURCE_ARG)
       
   129   endif
       
   130 endif 
       
   131 
       
   132 ifdef ALT_BOOTDIR
       
   133   ANT_OPTIONS += -Dboot.java.home=$(ALT_BOOTDIR)
       
   134   ANT_JAVA_HOME = JAVA_HOME=$(ALT_BOOTDIR)
       
   135 endif
       
   136 
       
   137 # To facilitate bootstrapping, much of langtools can be compiled with (just)
       
   138 # a boot JDK. However, some source files need to be compiled against 
       
   139 # new JDK API. In a bootstrap build, an import JDK may not be available,
       
   140 # so build.xml can also build against the source files in a jdk repo,
       
   141 # in which case it will automatically generate stub files for the new JDK API.
       
   142 ifdef JDK_TOPDIR
       
   143   ANT_OPTIONS += -Dimport.jdk=$(JDK_TOPDIR)
       
   144 else 
       
   145   ifdef ALT_JDK_TOPDIR
       
   146     ANT_OPTIONS += -Dimport.jdk=$(ALT_JDK_TOPDIR)
       
   147   else 
       
   148     ifdef ALT_JDK_IMPORT_PATH
       
   149       ANT_OPTIONS += -Dimport.jdk=$(ALT_JDK_IMPORT_PATH)
       
   150     endif
       
   151   endif
       
   152 endif
       
   153 
       
   154 ifdef ALT_OUTPUTDIR
       
   155   OUTPUTDIR = $(ALT_OUTPUTDIR)
       
   156   ANT_OPTIONS += -Dbuild.dir=$(ALT_OUTPUTDIR)/build
       
   157   ANT_OPTIONS += -Ddist.dir=$(ALT_OUTPUTDIR)/dist
       
   158 else
       
   159   OUTPUTDIR = ..
       
   160 endif
       
   161 #ABS_OUTPUTDIR = $(abspath $(OUTPUTDIR))
       
   162 ABS_OUTPUTDIR = $(call FullPath,$(OUTPUTDIR))
       
   163 
       
   164 ANT_TMPDIR = $(ABS_OUTPUTDIR)/build/ant-tmp
       
   165 ANT_OPTS = ANT_OPTS=-Djava.io.tmpdir='$(ANT_TMPDIR)'
       
   166 
       
   167 ifdef FINDBUGS_HOME
       
   168   ANT_OPTIONS += -Dfindbugs.home=$(FINDBUGS_HOME)
       
   169 endif
       
   170 
       
   171 ifdef ANT_HOME
       
   172   ANT = $(ANT_HOME)/bin/ant
       
   173   ifneq ($(shell test -x $(ANT) && echo OK), OK)
       
   174     $(error $(ANT) not found -- please update ANT_HOME)
       
   175   endif
       
   176 else
       
   177   ANT = ant
       
   178   ifneq ($(shell test -x "`which $(ANT)`" && echo OK), OK)
       
   179     $(error 'ant' not found -- please set ANT_HOME or put 'ant' on your PATH)
       
   180   endif
       
   181 endif
       
   182 
       
   183 # Default target and expected 'do everything' target
       
   184 all: build
       
   185 
       
   186 # Standard make clobber target
       
   187 clobber: clean
       
   188 
       
   189 # All ant targets of interest
       
   190 ANT_TARGETS = build clean sanity post-sanity diagnostics build-all-tools  # for now
       
   191 
       
   192 # Create diagnostics log (careful, ant 1.8.0 -diagnostics always does an exit 1)
       
   193 $(OUTPUTDIR)/build/ant-diagnostics.log:
       
   194 	@mkdir -p $(OUTPUTDIR)/build $(ANT_TMPDIR)
       
   195 	@$(RM) $@
       
   196 	$(ANT_JAVA_HOME) $(ANT_OPTS) $(ANT) -diagnostics > $@ ; \
       
   197 	  $(ANT_JAVA_HOME) $(ANT_OPTS) $(ANT) -version >> $@
       
   198 
       
   199 # Create a make target for each
       
   200 $(ANT_TARGETS): $(OUTPUTDIR)/build/ant-diagnostics.log
       
   201 	@ mkdir -p $(OUTPUTDIR)/build $(ANT_TMPDIR)
       
   202 	$(ANT_JAVA_HOME) $(ANT_OPTS) $(ANT) $(ANT_OPTIONS) $@
       
   203 
       
   204 #-------------------------------------------------------------------
       
   205 #
       
   206 # Targets for Oracle's internal JPRT build system
       
   207 
       
   208 CD = cd
       
   209 ZIP = zip
       
   210 
       
   211 JPRT_ARCHIVE_BUNDLE=$(ABS_OUTPUTDIR)/$(JPRT_BUILD_FLAVOR)-bundle.zip
       
   212 
       
   213 jprt_build_product jprt_build_debug jprt_build_fastdebug: all
       
   214 	( $(CD) $(OUTPUTDIR) && \
       
   215 	  $(ZIP) -q -r $(JPRT_ARCHIVE_BUNDLE) build dist )
       
   216 
       
   217 #-------------------------------------------------------------------
       
   218 
       
   219 # Declare these phony (not filenames)
       
   220 .PHONY: $(ANT_TARGETS) all clobber \
       
   221 	jprt_build_product jprt_build_debug jprt_build_fastdebug