duke@1: # ohair@240: # Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. duke@1: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: # duke@1: # This code is free software; you can redistribute it and/or modify it duke@1: # under the terms of the GNU General Public License version 2 only, as ohair@158: # published by the Free Software Foundation. Oracle designates this duke@1: # particular file as subject to the "Classpath" exception as provided ohair@158: # by Oracle in the LICENSE file that accompanied this code. duke@1: # duke@1: # This code is distributed in the hope that it will be useful, but WITHOUT duke@1: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: # version 2 for more details (a copy is included in the LICENSE file that duke@1: # accompanied this code). duke@1: # duke@1: # You should have received a copy of the GNU General Public License version duke@1: # 2 along with this work; if not, write to the Free Software Foundation, duke@1: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: # ohair@158: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@158: # or visit www.oracle.com if you need additional information or have any ohair@158: # questions. duke@1: # duke@1: duke@1: # duke@1: # duke@1: # Rules shared by all Java makefiles. duke@1: # ohair@114: duke@1: # Make sure the default rule is all duke@1: rules_default_rule: all duke@1: duke@1: # duke@1: # Directory set up. (Needed by deploy workspace) duke@1: # ohair@194: $(CLASSDESTDIR) $(OUTPUTDIR) $(TEMPDIR) $(EXTDIR): duke@1: $(MKDIR) -p $@ duke@1: duke@1: # duke@1: # All source tree areas for java/properties files duke@1: # duke@1: ALL_CLASSES_SRC = $(SHARE_SRC)/classes $(PLATFORM_SRC)/classes duke@1: duke@1: # duke@1: # If AUTO_FILES_PROPERTIES_DIRS used, automatically find properties files duke@1: # duke@1: ifdef AUTO_FILES_PROPERTIES_DIRS ohair@118: AUTO_FILES_PROPERTIES_FILTERS1 = $(SCM_DIRs) 'X-*' '*-X-*' ',*' ohair@118: AUTO_FILES_PROPERTIES_FILTERS1 += $(AUTO_PROPERTIES_PRUNE) ohair@118: FILES_properties_find_filters1 = $(AUTO_FILES_PROPERTIES_FILTERS1:%=-name % -prune -o) ohair@118: FILES_properties_auto1 := \ ohair@118: $(shell \ ohair@118: for dir in $(ALL_CLASSES_SRC) ; do \ ohair@118: if [ -d $$dir ] ; then \ ohair@118: ( $(CD) $$dir; \ ohair@118: for sdir in $(AUTO_FILES_PROPERTIES_DIRS); do \ ohair@118: if [ -d $$sdir ] ; then \ ohair@118: $(FIND) $$sdir $(FILES_properties_find_filters1) \ ohair@118: -name '*.properties' -print ; \ ohair@118: fi ; \ ohair@118: done \ ohair@118: ); \ ohair@118: fi; \ ohair@118: done \ ohair@118: ) duke@1: else duke@1: FILES_properties_auto1 = duke@1: endif # AUTO_FILES_PROPERTIES_DIRS duke@1: duke@1: # Add any automatically found properties files to the properties file list duke@1: FILES_properties += $(FILES_properties_auto1) duke@1: duke@1: # duke@1: # Get Resources help duke@1: # duke@1: include $(TOPDIR)/make/common/internal/Resources.gmk duke@1: duke@1: # duke@1: # Compiling .java files. duke@1: # duke@1: duke@1: # duke@1: # Automatically add to FILES_java if AUTO_FILES_JAVA_DIRS is defined duke@1: # duke@1: # There are two basic types of sources, normal source files and the duke@1: # generated ones. The Normal sources will be located in: duke@1: # $(ALL_CLASSES_SRC) duke@1: # The generated sources, which might show up late to dinner, are at: duke@1: # $(GENSRCDIR) duke@1: # and since they could be generated late, we need to be careful that duke@1: # we look for these sources late and not use the ':=' assignment which duke@1: # might miss their generation. duke@1: duke@1: ifdef AUTO_FILES_JAVA_DIRS ohair@118: # Filter out these files or directories ohair@118: AUTO_FILES_JAVA_SOURCE_FILTERS1 = $(SCM_DIRs) 'X-*' '*-X-*' '*-template.java' ',*' ohair@118: AUTO_FILES_JAVA_SOURCE_FILTERS2 = ohair@118: AUTO_FILES_JAVA_SOURCE_FILTERS1 += $(AUTO_JAVA_PRUNE) ohair@118: AUTO_FILES_JAVA_SOURCE_FILTERS2 += $(AUTO_JAVA_PRUNE) duke@1: ohair@118: # First list is the normal sources that should always be there, ohair@118: # by using the ':=', which means we do this processing once. ohair@118: FILES_java_find_filters1 = $(AUTO_FILES_JAVA_SOURCE_FILTERS1:%=-name % -prune -o) ohair@118: FILES_java_auto1 := \ ohair@118: $(shell \ ohair@118: for dir in $(ALL_CLASSES_SRC) ; do \ ohair@118: if [ -d $$dir ] ; then \ ohair@118: ( $(CD) $$dir; \ ohair@118: for sdir in $(AUTO_FILES_JAVA_DIRS); do \ ohair@118: if [ -d $$sdir ] ; then \ ohair@118: $(FIND) $$sdir $(FILES_java_find_filters1) \ ohair@118: -name '*.java' -print ; \ ohair@118: fi ; \ ohair@118: done \ ohair@118: ); \ ohair@118: fi; \ ohair@118: done \ ohair@118: ) duke@1: # Second list is the generated sources that should be rare, but will likely duke@1: # show up late and we need to look for them at the last minute, so we duke@1: # cannot use the ':=' assigment here. But if this gets expanded multiple duke@1: # times, the if tests should make them relatively cheap. ohair@118: FILES_java_find_filters2 = $(AUTO_FILES_JAVA_SOURCE_FILTERS2:%=-name % -prune -o) ohair@118: FILES_java_auto2 = \ ohair@118: $(shell \ ohair@118: for dir in $(GENSRCDIR); do \ ohair@118: if [ -d $$dir ] ; then \ ohair@118: ( $(CD) $$dir; \ ohair@118: for sdir in $(AUTO_FILES_JAVA_DIRS); do \ ohair@118: if [ -d $$sdir ] ; then \ ohair@118: $(FIND) $$sdir $(FILES_java_find_filters2) \ ohair@118: -name '*.java' -print ; \ ohair@118: fi ; \ ohair@118: done \ ohair@118: ); \ ohair@118: fi; \ ohair@118: done \ ohair@118: ) duke@1: else duke@1: FILES_java_auto1 = duke@1: FILES_java_auto2 = duke@1: endif duke@1: duke@1: # Add all found java sources to FILES_java macro (if AUTO_FILES_JAVA_DIRS used) duke@1: FILES_java += $(FILES_java_auto1) $(FILES_java_auto2) duke@1: duke@1: # File that will hold java source names that need compiling duke@1: JAVA_SOURCE_LIST=$(TEMPDIR)/.classes.list duke@1: duke@1: # Add a java source to the list duke@1: define add-java-file duke@1: $(ECHO) "$?" >> $(JAVA_SOURCE_LIST) duke@1: endef duke@1: duke@1: $(CLASSDESTDIR)/%.class: $(GENSRCDIR)/%.java duke@1: @$(add-java-file) duke@1: $(CLASSDESTDIR)/%.class: $(PLATFORM_SRC)/classes/%.java duke@1: @$(add-java-file) duke@1: $(CLASSDESTDIR)/%.class: $(SHARE_SRC)/classes/%.java duke@1: @$(add-java-file) duke@1: duke@1: # List of class files needed duke@1: FILES_class = $(FILES_java:%.java=$(CLASSDESTDIR)/%.class) duke@1: duke@1: # Construct list of java sources we need to compile duke@1: source_list_prime: duke@1: @$(MKDIR) -p $(TEMPDIR) duke@1: # Note that we slip resources in so that compiled properties files get created: duke@1: $(JAVA_SOURCE_LIST) : source_list_prime resources $(FILES_class) duke@1: @$(TOUCH) $@ duke@1: duke@1: .delete.classlist: duke@1: @$(RM) $(JAVA_SOURCE_LIST) duke@1: duke@1: # Make sure all newer sources are compiled (in a batch) duke@1: classes : $(CLASSES_INIT) .delete.classlist .compile.classlist duke@1: ohair@56: # Use this javac option to force it to favor the sourcepath file classes ohair@56: # rather than any bootclasspath classes. ohair@56: JAVAC_PREFER_SOURCE = -Xprefer:source ohair@56: duke@1: .compile.classlist : $(JAVA_SOURCE_LIST) duke@1: @$(MKDIR) -p $(CLASSDESTDIR) ohair@114: if [ -s $(JAVA_SOURCE_LIST) ] ; then \ ohair@118: $(CAT) $(JAVA_SOURCE_LIST); \ ohair@56: $(JAVAC_CMD) $(JAVAC_PREFER_SOURCE) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \ duke@1: fi duke@1: @$(java-vm-cleanup) duke@1: duke@1: clobber clean:: duke@1: $(RM) $(JAVA_SOURCE_LIST) duke@1: duke@1: ifndef DONT_CLOBBER_CLASSES duke@1: ifndef PACKAGE duke@1: DONT_CLOBBER_CLASSES = true duke@1: else duke@1: DONT_CLOBBER_CLASSES = false duke@1: endif duke@1: endif duke@1: duke@1: packages.clean: duke@1: ifeq ($(DONT_CLOBBER_CLASSES),false) duke@1: ifdef AUTO_FILES_JAVA_DIRS ohair@114: $(RM) -r $(patsubst %, $(CLASSDESTDIR)/%, $(AUTO_FILES_JAVA_DIRS)) duke@1: else duke@1: $(RM) -r $(CLASSDESTDIR)/$(PKGDIR) duke@1: endif duke@1: endif duke@1: duke@1: classes.clean: packages.clean duke@1: $(RM) $(JAVA_SOURCE_LIST) duke@1: ohair@194: clean clobber:: classes.clean .delete.classlist duke@1: duke@1: # duke@1: # Default dependencies duke@1: # duke@1: duke@1: all: build duke@1: ohair@194: build: classes duke@1: duke@1: default: all duke@1: duke@1: .PHONY: all build clean clobber \ duke@1: .delete.classlist classes .compile.classlist classes.clean \ duke@1: batch_compile duke@1: