langtools/src/share/opensource/javac/Makefile
changeset 451 59439733e87a
parent 450 be95c1c0efcf
parent 408 cc1aa0299d0d
child 452 deabc19e963e
child 634 34d4a2d5b8cb
equal deleted inserted replaced
450:be95c1c0efcf 451:59439733e87a
     1 #
       
     2 # Copyright 2006-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 #
       
    25 
       
    26 # Simple Makefile for javac
       
    27 
       
    28 BUILD = build
       
    29 BUILD_BOOTCLASSES = $(BUILD)/bootclasses
       
    30 BUILD_CLASSES = $(BUILD)/classes
       
    31 BUILD_JAVAC_SRCFILES = $(BUILD)/javac.srcfiles
       
    32 GENSRCDIR = $(BUILD)/gensrc
       
    33 DIST = dist
       
    34 DIST_JAVAC = $(DIST)
       
    35 ABS_DIST_JAVAC = $(shell cd $(DIST_JAVAC) ; pwd)
       
    36 SRC_BIN = src/bin
       
    37 SRC_CLASSES = src/share/classes
       
    38 
       
    39 #--------------------------------------------------------------------------------
       
    40 #
       
    41 # version info for generated compiler
       
    42 
       
    43 JDK_VERSION = 1.7.0
       
    44 RELEASE=$(JDK_VERSION)-opensource
       
    45 BUILD_NUMBER = b00
       
    46 USER_RELEASE_SUFFIX := $(shell echo $(USER)_`date '+%d_%b_%Y_%H_%M' | tr "A-Z" "a-z"`)
       
    47 FULL_VERSION = $(RELEASE)-$(USER_RELEASE_SUFFIX)-$(BUILD_NUMBER)
       
    48 
       
    49 #--------------------------------------------------------------------------------
       
    50 
       
    51 CAT	= /bin/cat
       
    52 CHMOD	= /bin/chmod
       
    53 CP	= /bin/cp
       
    54 MKDIR 	= /bin/mkdir
       
    55 RM 	= /bin/rm
       
    56 SED 	= /bin/sed
       
    57 
       
    58 
       
    59 SYSTEM_UNAME := $(shell uname)
       
    60 
       
    61 # Platform settings specific to Solaris
       
    62 ifeq ($(SYSTEM_UNAME), SunOS)
       
    63   # Intrinsic unix command, with backslash-escaped character interpretation
       
    64   #   (not using -e  will cause build failure when using /bin/bash)
       
    65   #   (using -e breaks something else)
       
    66   ECHO           = /usr/bin/echo
       
    67   PLATFORM       = solaris
       
    68 endif
       
    69 
       
    70 # Platform settings specific to Linux
       
    71 ifeq ($(SYSTEM_UNAME), Linux)
       
    72   # Intrinsic unix command, with backslash-escaped character interpretation
       
    73   ECHO           = echo -e
       
    74   PLATFORM       = linux
       
    75 endif
       
    76 
       
    77 
       
    78 # Set BOOTDIR to specify the JDK used to build the compiler
       
    79 ifdef	BOOTDIR
       
    80 JAR	= $(BOOTDIR)/bin/jar
       
    81 JAVA	= $(BOOTDIR)/bin/java
       
    82 JAVAC	= $(BOOTDIR)/bin/javac
       
    83 JAVADOC = $(BOOTDIR)/bin/javadoc
       
    84 else
       
    85 JAR	= jar
       
    86 JAVA	= java
       
    87 JAVAC	= javac
       
    88 JAVADOC = javadoc
       
    89 endif
       
    90 
       
    91 ifndef JTREG
       
    92 ifdef JTREG_HOME
       
    93 JTREG   = $(JTREG_HOME)/$(PLATFORM)/bin/jtreg
       
    94 else
       
    95 JTREG	= jtreg
       
    96 endif
       
    97 endif
       
    98 
       
    99 ifndef	JTREG_OPTS
       
   100 JTREG_OPTS = -s -verbose:summary
       
   101 endif
       
   102 
       
   103 ifndef	JTREG_TESTS
       
   104 JTREG_TESTS = test/tools/javac
       
   105 endif
       
   106 
       
   107 # Set this to the baseline version of JDK used for the tests
       
   108 # TESTJDKHOME = 
       
   109 
       
   110 COMPILER_SOURCE_LEVEL = 1.5
       
   111 
       
   112 #--------------------------------------------------------------------------------
       
   113 SCM_DIRS = -name .hg -o -name .svn -o -name CVS -o -name RCS -o -name SCCS
       
   114 JAVAC_SRCS = $(shell find \
       
   115         $(SRC_CLASSES)/javax/annotation/processing \
       
   116         $(SRC_CLASSES)/javax/lang/model \
       
   117         $(SRC_CLASSES)/javax/tools \
       
   118         $(SRC_CLASSES)/com/sun/source \
       
   119         $(SRC_CLASSES)/com/sun/tools/javac \
       
   120 	\( $(SCM_DIRS) -o -name \*-template.\* \) -prune -o -name \*.java -print )
       
   121 
       
   122 JAVAC_RESOURCES = $(shell ls $(SRC_CLASSES)/com/sun/tools/javac/resources/*.properties | $(SED) -e 's/-template//' )
       
   123 
       
   124 
       
   125 #--------------------------------------------------------------------------------
       
   126 
       
   127 default: build
       
   128 
       
   129 all: build docs
       
   130 
       
   131 clean:
       
   132 	$(RM) -rf $(BUILD) $(DIST)
       
   133 
       
   134 build:	sanity $(DIST_JAVAC)/lib/javac.jar $(DIST_JAVAC)/bin/javac 
       
   135 
       
   136 
       
   137 # javac.jar
       
   138 
       
   139 $(DIST_JAVAC)/lib/javac.jar: \
       
   140 		$(JAVAC_SRCS) \
       
   141 		$(patsubst $(SRC_CLASSES)/%,$(BUILD_BOOTCLASSES)/%,$(JAVAC_RESOURCES)) \
       
   142 		$(patsubst $(SRC_CLASSES)/%,$(BUILD_CLASSES)/%,$(JAVAC_RESOURCES)) 
       
   143 	@$(ECHO) $(JAVAC_SRCS) > $(BUILD_JAVAC_SRCFILES)
       
   144 	$(JAVAC) -d $(BUILD_BOOTCLASSES) -source $(COMPILER_SOURCE_LEVEL) -g:source,lines @$(BUILD_JAVAC_SRCFILES)
       
   145 	$(JAVA) -cp $(BUILD_BOOTCLASSES) com.sun.tools.javac.Main \
       
   146 		-d $(BUILD_CLASSES) -g:source,lines @$(BUILD_JAVAC_SRCFILES)
       
   147 	( $(ECHO) "Main-Class: com.sun.tools.javac.Main" ; \
       
   148 	  $(ECHO) "Built-By: $$USER" ; \
       
   149 	  $(ECHO) "Built-At: `date`" ) > $(BUILD)/javac.MF
       
   150 	$(MKDIR) -p $(DIST_JAVAC)/lib
       
   151 	$(JAR) -cmf $(BUILD)/javac.MF $(DIST_JAVAC)/lib/javac.jar -C ${BUILD_CLASSES} .
       
   152 
       
   153 
       
   154 # javac resources
       
   155 
       
   156 $(BUILD_BOOTCLASSES)/com/sun/tools/javac/resources/version.properties \
       
   157 $(BUILD_CLASSES)/com/sun/tools/javac/resources/version.properties: \
       
   158 		$(SRC_CLASSES)/com/sun/tools/javac/resources/version-template.properties
       
   159 	$(MKDIR) -p $(@D)
       
   160 	$(SED) 	-e 's/$$(JDK_VERSION)/$(JDK_VERSION)/'  \
       
   161 		-e 's/$$(FULL_VERSION)/$(FULL_VERSION)/' \
       
   162 		-e 's/$$(RELEASE)/$(RELEASE)/' \
       
   163 		< $< > $@
       
   164 
       
   165 $(BUILD_BOOTCLASSES)/com/sun/tools/javac/resources/%.properties: \
       
   166 		$(SRC_CLASSES)/com/sun/tools/javac/resources/%.properties
       
   167 	$(MKDIR) -p $(@D)
       
   168 	$(CP) $^ $@
       
   169 
       
   170 $(BUILD_CLASSES)/com/sun/tools/javac/resources/%.properties: \
       
   171 		$(SRC_CLASSES)/com/sun/tools/javac/resources/%.properties
       
   172 	$(MKDIR) -p $(@D)
       
   173 	$(CP) $^ $@
       
   174 
       
   175 
       
   176 # javac wrapper script
       
   177 
       
   178 $(DIST_JAVAC)/bin/javac: $(SRC_BIN)/javac.sh
       
   179 	$(MKDIR) -p $(@D)
       
   180 	$(CP) $^ $@
       
   181 	$(CHMOD) +x $@
       
   182 
       
   183 # javadoc
       
   184 
       
   185 JLS3_URL = http://java.sun.com/docs/books/jls/
       
   186 JLS3_CITE = <a href="$(JLS3_URL)"> \
       
   187 		The Java Language Specification, Third Edition</a>
       
   188 TAG_JLS3 = -tag 'jls3:a:See <cite>$(JLS3_CITE)</cite>:'
       
   189 
       
   190 TAGS = $(IGNORED_TAGS:%=-tag %:X) $(TAG_JLS3)
       
   191 
       
   192 docs:	
       
   193 	$(JAVADOC) -sourcepath $(SRC_CLASSES) -d $(DIST_JAVAC)/doc/api \
       
   194 	    $(TAGS) \
       
   195             -subpackages javax.annotation.processing:javax.lang.model:javax.tools:com.sun.source:com.sun.tools.javac
       
   196 
       
   197 #--------------------------------------------------------------------------------
       
   198 
       
   199 test: test-sanity $(DIST_JAVAC)/lib/javac.jar
       
   200 	$(JTREG) $(JTREG_OPTS) -noshell \
       
   201 		-jdk:$(TESTJDKHOME) \
       
   202 		-Xbootclasspath/p:$(ABS_DIST_JAVAC)/lib/javac.jar \
       
   203 		-w:$(BUILD)/jtreg/work \
       
   204 		-r:$(BUILD)/jtreg/report \
       
   205 		$(JTREG_TESTS)
       
   206 
       
   207 #--------------------------------------------------------------------------------
       
   208 
       
   209 ifndef ERROR_FILE
       
   210   ERROR_FILE   = $(BUILD)/sanityCheckErrors.txt
       
   211 endif
       
   212 
       
   213 presanity:
       
   214 	@$(RM) -f $(ERROR_FILE)
       
   215 	@$(MKDIR) -p `dirname $(ERROR_FILE)`
       
   216 
       
   217 ######################################################
       
   218 # CLASSPATH cannot be set, unless you are insane.
       
   219 ######################################################
       
   220 sane-classpath:
       
   221 ifdef CLASSPATH
       
   222 	@$(ECHO) "ERROR: Your CLASSPATH environment variable is set.  This will \n" \
       
   223 	   "      most likely cause the build to fail.  Please unset it \n" \
       
   224 	   "      and start your build again. \n" \
       
   225 	   "" >> $(ERROR_FILE)
       
   226 endif
       
   227 
       
   228 ######################################################
       
   229 # JAVA_HOME cannot be set, unless you are insane.
       
   230 ######################################################
       
   231 sane-java_home:
       
   232 ifdef JAVA_HOME
       
   233 	@$(ECHO) "ERROR: Your JAVA_HOME environment variable is set.  This will \n" \
       
   234 	   "      most likely cause the build to fail.  Please unset it \n" \
       
   235 	   "      and start your build again. \n" \
       
   236 	   "" >> $(ERROR_FILE)
       
   237 endif
       
   238 
       
   239 
       
   240 ######################################################
       
   241 # TESTJDKHOME needs to be set to run tests
       
   242 ######################################################
       
   243 sane-testjdk:
       
   244 ifndef TESTJDKHOME
       
   245 	@$(ECHO) "ERROR: TESTJDKHOME needs to be set to the baseline version \n" \
       
   246 	   "     version of JDK used to run the compiler tests.\n" \
       
   247 	   "" >> $(ERROR_FILE)
       
   248 endif
       
   249 
       
   250 
       
   251 sane-lastrule:
       
   252 	@if [ -r $(ERROR_FILE) ]; then \
       
   253 	  if [ "x$(INSANE)" = x ]; then \
       
   254 	    $(ECHO) "Exiting because of the above error(s). \n" \
       
   255 	      "">> $(ERROR_FILE); \
       
   256 	  fi ; \
       
   257 	  $(CAT) $(ERROR_FILE) ; \
       
   258 	  if [ "x$(INSANE)" = x ]; then \
       
   259 	    exit 1 ; \
       
   260 	  fi ; \
       
   261 	fi
       
   262 
       
   263 sanity \
       
   264 build-sanity: presanity sane-classpath sane-java_home sane-lastrule
       
   265 
       
   266 test-sanity: presanity sane-classpath sane-java_home sane-testjdk sane-lastrule
       
   267 
       
   268 
       
   269 
       
   270 
       
   271 #--------------------------------------------------------------------------------
       
   272 
       
   273 .PHONY: all build clean default docs prep test \
       
   274 	presanity sanity build-sanity test-sanity \
       
   275 	sane-classpath sane-java_home sane-testjdk sane-lastrule