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