make/common/Rules.gmk

Thu, 17 Jun 2010 16:27:56 -0700

author
mikejwre
date
Thu, 17 Jun 2010 16:27:56 -0700
changeset 171
95db968660e7
parent 158
91006f157c46
child 194
0f60cf26c5b5
permissions
-rw-r--r--

Added tag jdk7-b98 for changeset 3b99409057e4

     1 #
     2 # Copyright (c) 1995, 2009, Oracle and/or its affiliates. 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.  Oracle designates this
     8 # particular file as subject to the "Classpath" exception as provided
     9 # by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22 # or visit www.oracle.com if you need additional information or have any
    23 # questions.
    24 #
    26 #
    27 #
    28 # Rules shared by all Java makefiles.
    29 #
    31 # Make sure the default rule is all
    32 rules_default_rule: all
    34 #
    35 # Directory set up.  (Needed by deploy workspace)
    36 # 
    37 $(CLASSDESTDIR) $(CLASSHDRDIR) $(OBJDIR) $(OUTPUTDIR) $(BINDIR) $(LIBDIR) $(LIBDIR)/$(LIBARCH) $(TEMPDIR) $(EXTDIR):
    38 	$(MKDIR) -p $@ 
    40 #
    41 # All source tree areas for java/properties files 
    42 #
    43 ALL_CLASSES_SRC = $(SHARE_SRC)/classes $(PLATFORM_SRC)/classes
    45 #
    46 # If AUTO_FILES_PROPERTIES_DIRS used, automatically find properties files
    47 #
    48 ifdef AUTO_FILES_PROPERTIES_DIRS
    49   AUTO_FILES_PROPERTIES_FILTERS1  = $(SCM_DIRs) 'X-*' '*-X-*' ',*'
    50   AUTO_FILES_PROPERTIES_FILTERS1 += $(AUTO_PROPERTIES_PRUNE)
    51   FILES_properties_find_filters1 = $(AUTO_FILES_PROPERTIES_FILTERS1:%=-name % -prune -o)
    52   FILES_properties_auto1 := \
    53      $(shell \
    54         for dir in $(ALL_CLASSES_SRC) ; do \
    55           if [ -d $$dir ] ; then \
    56             ( $(CD) $$dir; \
    57               for sdir in $(AUTO_FILES_PROPERTIES_DIRS); do \
    58                 if [ -d $$sdir ] ; then \
    59                   $(FIND) $$sdir $(FILES_properties_find_filters1) \
    60                                  -name '*.properties' -print ; \
    61                 fi ; \
    62               done \
    63             ); \
    64           fi; \
    65         done \
    66       )
    67 else
    68   FILES_properties_auto1 =
    69 endif # AUTO_FILES_PROPERTIES_DIRS
    71 # Add any automatically found properties files to the properties file list
    72 FILES_properties += $(FILES_properties_auto1)
    74 #
    75 # Get Resources help
    76 #
    77 include $(TOPDIR)/make/common/internal/Resources.gmk
    79 #
    80 # Compiling .java files.
    81 #
    83 #
    84 # Automatically add to FILES_java if AUTO_FILES_JAVA_DIRS is defined
    85 #
    86 #    There are two basic types of sources, normal source files and the
    87 #    generated ones. The Normal sources will be located in:
    88 #         $(ALL_CLASSES_SRC)
    89 #    The generated sources, which might show up late to dinner, are at:
    90 #         $(GENSRCDIR)
    91 #    and since they could be generated late, we need to be careful that
    92 #    we look for these sources late and not use the ':=' assignment which
    93 #    might miss their generation.
    95 ifdef AUTO_FILES_JAVA_DIRS
    96   # Filter out these files or directories
    97   AUTO_FILES_JAVA_SOURCE_FILTERS1  = $(SCM_DIRs) 'X-*' '*-X-*' '*-template.java' ',*'
    98   AUTO_FILES_JAVA_SOURCE_FILTERS2  = 
    99   AUTO_FILES_JAVA_SOURCE_FILTERS1 += $(AUTO_JAVA_PRUNE)
   100   AUTO_FILES_JAVA_SOURCE_FILTERS2 += $(AUTO_JAVA_PRUNE)
   102   # First list is the normal sources that should always be there,
   103   #   by using the ':=', which means we do this processing once.
   104   FILES_java_find_filters1 = $(AUTO_FILES_JAVA_SOURCE_FILTERS1:%=-name % -prune -o)
   105   FILES_java_auto1 := \
   106      $(shell \
   107         for dir in $(ALL_CLASSES_SRC) ; do \
   108           if [ -d $$dir ] ; then \
   109             ( $(CD) $$dir; \
   110               for sdir in $(AUTO_FILES_JAVA_DIRS); do \
   111                 if [ -d $$sdir ] ; then \
   112                   $(FIND) $$sdir $(FILES_java_find_filters1) \
   113                                  -name '*.java' -print ; \
   114                 fi ; \
   115               done \
   116             ); \
   117           fi; \
   118         done \
   119       )
   120   # Second list is the generated sources that should be rare, but will likely
   121   #   show up late and we need to look for them at the last minute, so we
   122   #   cannot use the ':=' assigment here. But if this gets expanded multiple
   123   #   times, the if tests should make them relatively cheap.
   124   FILES_java_find_filters2 = $(AUTO_FILES_JAVA_SOURCE_FILTERS2:%=-name % -prune -o)
   125   FILES_java_auto2 = \
   126      $(shell \
   127         for dir in $(GENSRCDIR); do \
   128           if [ -d $$dir ] ; then \
   129             ( $(CD) $$dir; \
   130               for sdir in $(AUTO_FILES_JAVA_DIRS); do \
   131                 if [ -d $$sdir ] ; then \
   132                   $(FIND) $$sdir $(FILES_java_find_filters2) \
   133                                  -name '*.java' -print ; \
   134                 fi ; \
   135               done \
   136             ); \
   137           fi; \
   138         done \
   139       )
   140 else
   141   FILES_java_auto1 =
   142   FILES_java_auto2 =
   143 endif
   145 # Add all found java sources to FILES_java macro (if AUTO_FILES_JAVA_DIRS used)
   146 FILES_java += $(FILES_java_auto1) $(FILES_java_auto2)
   148 # File that will hold java source names that need compiling
   149 JAVA_SOURCE_LIST=$(TEMPDIR)/.classes.list
   151 # Add a java source to the list
   152 define add-java-file
   153 $(ECHO) "$?" >> $(JAVA_SOURCE_LIST)
   154 endef
   156 $(CLASSDESTDIR)/%.class: $(GENSRCDIR)/%.java
   157 	@$(add-java-file)
   158 $(CLASSDESTDIR)/%.class: $(PLATFORM_SRC)/classes/%.java
   159 	@$(add-java-file)
   160 $(CLASSDESTDIR)/%.class: $(SHARE_SRC)/classes/%.java
   161 	@$(add-java-file)
   163 # List of class files needed
   164 FILES_class = $(FILES_java:%.java=$(CLASSDESTDIR)/%.class)
   166 # Got to include exported files.
   167 FILES_class += $(FILES_export:%.java=$(CLASSDESTDIR)/%.class)
   169 # Construct list of java sources we need to compile
   170 source_list_prime:
   171 	@$(MKDIR) -p $(TEMPDIR)
   172 # Note that we slip resources in so that compiled properties files get created:
   173 $(JAVA_SOURCE_LIST) : source_list_prime resources $(FILES_class)
   174 	@$(TOUCH) $@
   176 .delete.classlist:
   177 	@$(RM) $(JAVA_SOURCE_LIST)
   179 # Make sure all newer sources are compiled (in a batch)
   180 classes : $(CLASSES_INIT) .delete.classlist .compile.classlist
   182 # Use this javac option to force it to favor the sourcepath file classes
   183 #   rather than any bootclasspath classes.
   184 JAVAC_PREFER_SOURCE = -Xprefer:source
   186 .compile.classlist : $(JAVA_SOURCE_LIST)
   187 	@$(MKDIR) -p $(CLASSDESTDIR)
   188 	if [ -s $(JAVA_SOURCE_LIST) ] ; then \
   189 	  $(CAT) $(JAVA_SOURCE_LIST); \
   190 	  $(JAVAC_CMD) $(JAVAC_PREFER_SOURCE) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \
   191 	fi
   192 	@$(java-vm-cleanup)
   194 clobber clean::
   195 	$(RM) $(JAVA_SOURCE_LIST)
   197 ifndef DONT_CLOBBER_CLASSES
   198   ifndef PACKAGE
   199     DONT_CLOBBER_CLASSES = true
   200   else
   201     DONT_CLOBBER_CLASSES = false
   202   endif
   203 endif
   205 packages.clean:
   206 ifeq ($(DONT_CLOBBER_CLASSES),false)
   207   ifdef AUTO_FILES_JAVA_DIRS
   208 	$(RM) -r $(patsubst %, $(CLASSDESTDIR)/%, $(AUTO_FILES_JAVA_DIRS))
   209   else
   210 	$(RM) -r $(CLASSDESTDIR)/$(PKGDIR)
   211   endif
   212 endif
   214 classes.clean: packages.clean
   215 	$(RM) $(JAVA_SOURCE_LIST)
   217 #
   218 # C and C++ make dependencies
   219 #
   220 include $(TOPDIR)/make/common/internal/NativeCompileRules.gmk
   222 #
   223 # Running Javah to generate stuff into CClassHeaders.
   224 #
   226 ifdef FILES_export
   228 CLASSES.export  = $(subst /,.,$(FILES_export:%.java=%))
   229 CLASSES.export += $(subst /,.,$(FILES_export2:%.java=%))
   230 CLASSES.export += $(subst /,.,$(FILES_export3:%.java=%))
   231 CLASSES_export  = $(FILES_export:%.java=$(CLASSDESTDIR)/%.class)
   232 CLASSES_export += $(FILES_export2:%.java=$(CLASSDESTDIR)/%.class)
   233 CLASSES_export += $(FILES_export3:%.java=$(CLASSDESTDIR)/%.class)
   235 # Fix when deploy workspace makefiles don't depend on this name
   236 #CLASSHDR_DOTFILE=$(CLASSHDRDIR)/.classheaders
   238 CLASSHDR_DOTFILE=$(OBJDIR)/.class.headers.$(ARCH)
   240 classheaders: classes $(CLASSHDR_DOTFILE)
   242 $(CLASSHDR_DOTFILE): $(CLASSES_export)
   243 	$(prep-target)
   244 	$(JAVAH_CMD) -d $(CLASSHDRDIR)/ \
   245 		$(CLASSES.export) $(subst $$,\$$,$(EXPORTED_inner))
   246 	@$(java-vm-cleanup)
   247 	@$(TOUCH) $@
   249 classheaders.clean:
   250 	$(RM) -r $(CLASSHDRDIR) $(CLASSHDR_DOTFILE)
   252 else # FILES_export
   254 classheaders: classes
   256 classheaders.clean: 
   258 endif # FILES_export
   260 clean clobber:: classheaders.clean classes.clean .delete.classlist
   262 # 
   263 # Default dependencies
   264 #
   266 all: build
   268 build: classheaders
   270 default: all
   272 .PHONY: all build clean clobber \
   273         .delete.classlist classes .compile.classlist classes.clean \
   274 	 classheaders classheaders.clean \
   275 	 batch_compile

mercurial