0N/A#
2362N/A# Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
0N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A#
0N/A# This code is free software; you can redistribute it and/or modify it
0N/A# under the terms of the GNU General Public License version 2 only, as
2362N/A# published by the Free Software Foundation. Oracle designates this
0N/A# particular file as subject to the "Classpath" exception as provided
2362N/A# by Oracle in the LICENSE file that accompanied this code.
0N/A#
0N/A# This code is distributed in the hope that it will be useful, but WITHOUT
0N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A# version 2 for more details (a copy is included in the LICENSE file that
0N/A# accompanied this code).
0N/A#
0N/A# You should have received a copy of the GNU General Public License version
0N/A# 2 along with this work; if not, write to the Free Software Foundation,
0N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A#
2362N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A# or visit www.oracle.com if you need additional information or have any
2362N/A# questions.
0N/A#
0N/A
0N/A#
0N/A#
0N/A# Rules shared by all Java makefiles.
0N/A#
0N/A# Used to apply to source file $<, checks code conventions, issues warnings.
0N/Adefine check-conventions
0N/A if [ "$(CONVENTION_WATCH)" = "true" ] ; then \
0N/A if [ "`$(CAT) -n -v -t $< | $(EGREP) -v '\@\(\#\)' | $(EGREP) '\^[MLI]'`" != "" ] ; then \
0N/A $(ECHO) "WARNING: File contains tabs, ^M, or ^L characters: $<"; \
0N/A if [ "$(CONVENTION_DETAILS)" = "true" ] ; then \
0N/A $(CAT) -n -v -t $< | $(EGREP) -v '\@\(\#\)' | $(EGREP) '\^[MLI]' ; \
0N/A fi; \
0N/A fi; \
0N/A fi
0N/Aendef
0N/A
0N/A# Make sure the default rule is all
0N/Arules_default_rule: all
0N/A
0N/A#
0N/A# Directory set up. (Needed by deploy workspace)
0N/A#
0N/A$(CLASSDESTDIR) $(CLASSHDRDIR) $(OBJDIR) $(OUTPUTDIR) $(BINDIR) $(LIBDIR) $(LIBDIR)/$(LIBARCH) $(TEMPDIR) $(EXTDIR):
0N/A $(MKDIR) -p $@
0N/A
0N/A#
0N/A# All source tree areas for java/properties files (a few may be closed)
0N/A#
4632N/Aifeq ($(PLATFORM), macosx)
4632N/A ifdef OPENJDK
4632N/A ALL_CLASSES_SRC = $(call JavaSrcDirList,,classes)
4632N/A else
4632N/A # TODO(cpc): maybe we should modify JavaSrcDirList macro instead...
4632N/A ALL_CLASSES_SRC = \
4632N/A $(CLOSED_SHARE_SRC)/classes $(CLOSED_PLATFORM_SRC)/classes \
4632N/A $(call JavaSrcDirList,,classes)
4632N/A endif
0N/Aelse
4632N/A ifdef OPENJDK
4632N/A ALL_CLASSES_SRC = $(SHARE_SRC)/classes $(PLATFORM_SRC)/classes
4632N/A else
4632N/A ALL_CLASSES_SRC = \
4632N/A $(CLOSED_SHARE_SRC)/classes $(CLOSED_PLATFORM_SRC)/classes \
4632N/A $(SHARE_SRC)/classes $(PLATFORM_SRC)/classes
4632N/A endif
0N/Aendif
0N/A
0N/A#
0N/A# If AUTO_FILES_PROPERTIES_DIRS used, automatically find properties files
0N/A#
0N/Aifdef AUTO_FILES_PROPERTIES_DIRS
1776N/A AUTO_FILES_PROPERTIES_FILTERS1 = $(SCM_DIRs) ',*'
0N/A AUTO_FILES_PROPERTIES_FILTERS1 += $(AUTO_PROPERTIES_PRUNE)
0N/A FILES_properties_find_filters1 = $(AUTO_FILES_PROPERTIES_FILTERS1:%=-name % -prune -o)
0N/A FILES_properties_auto1 := \
0N/A $(shell \
0N/A for dir in $(ALL_CLASSES_SRC) ; do \
0N/A if [ -d $$dir ] ; then \
0N/A ( $(CD) $$dir; \
0N/A for sdir in $(AUTO_FILES_PROPERTIES_DIRS); do \
0N/A if [ -d $$sdir ] ; then \
0N/A $(FIND) $$sdir $(FILES_properties_find_filters1) \
0N/A -name '*.properties' -print ; \
0N/A fi ; \
0N/A done \
0N/A ); \
0N/A fi; \
0N/A done \
0N/A )
0N/Aelse
0N/A FILES_properties_auto1 =
0N/Aendif # AUTO_FILES_PROPERTIES_DIRS
0N/A
0N/A# Add any automatically found properties files to the properties file list
0N/AFILES_properties += $(FILES_properties_auto1)
0N/A
0N/A#
0N/A# Get Resources help
0N/A#
0N/Ainclude $(JDK_TOPDIR)/make/common/internal/Resources.gmk
0N/A
0N/A#
0N/A# Compiling .java files.
0N/A#
0N/A
0N/A#
0N/A# Automatically add to FILES_java if AUTO_FILES_JAVA_DIRS is defined
0N/A#
0N/A# There are two basic types of sources, normal source files and the
0N/A# generated ones. The Normal sources will be located in:
0N/A# $(ALL_CLASSES_SRC)
0N/A# The generated sources, which might show up late to dinner, are at:
0N/A# $(GENSRCDIR)
0N/A# and since they could be generated late, we need to be careful that
0N/A# we look for these sources late and not use the ':=' assignment which
0N/A# might miss their generation.
0N/A
0N/Aifdef AUTO_FILES_JAVA_DIRS
0N/A # Filter out these files or directories
1776N/A AUTO_FILES_JAVA_SOURCE_FILTERS1 = $(SCM_DIRs) ',*'
0N/A AUTO_FILES_JAVA_SOURCE_FILTERS2 =
0N/A AUTO_FILES_JAVA_SOURCE_FILTERS1 += $(AUTO_JAVA_PRUNE)
0N/A AUTO_FILES_JAVA_SOURCE_FILTERS2 += $(AUTO_JAVA_PRUNE)
0N/A
0N/A # First list is the normal sources that should always be there,
0N/A # by using the ':=', which means we do this processing once.
0N/A FILES_java_find_filters1 = $(AUTO_FILES_JAVA_SOURCE_FILTERS1:%=-name % -prune -o)
0N/A FILES_java_auto1 := \
0N/A $(shell \
0N/A for dir in $(ALL_CLASSES_SRC) ; do \
0N/A if [ -d $$dir ] ; then \
0N/A ( $(CD) $$dir; \
0N/A for sdir in $(AUTO_FILES_JAVA_DIRS); do \
0N/A if [ -d $$sdir ] ; then \
0N/A $(FIND) $$sdir $(FILES_java_find_filters1) \
0N/A -name '*.java' -print ; \
0N/A fi ; \
0N/A done \
0N/A ); \
0N/A fi; \
0N/A done \
0N/A )
0N/A # Second list is the generated sources that should be rare, but will likely
0N/A # show up late and we need to look for them at the last minute, so we
0N/A # cannot use the ':=' assigment here. But if this gets expanded multiple
0N/A # times, the if tests should make them relatively cheap.
0N/A FILES_java_find_filters2 = $(AUTO_FILES_JAVA_SOURCE_FILTERS2:%=-name % -prune -o)
0N/A FILES_java_auto2 = \
0N/A $(shell \
0N/A for dir in $(GENSRCDIR); do \
0N/A if [ -d $$dir ] ; then \
0N/A ( $(CD) $$dir; \
0N/A for sdir in $(AUTO_FILES_JAVA_DIRS); do \
0N/A if [ -d $$sdir ] ; then \
0N/A $(FIND) $$sdir $(FILES_java_find_filters2) \
0N/A -name '*.java' -print ; \
0N/A fi ; \
0N/A done \
0N/A ); \
0N/A fi; \
0N/A done \
0N/A )
0N/Aelse
0N/A FILES_java_auto1 =
0N/A FILES_java_auto2 =
0N/Aendif
0N/A
0N/A# Add all found java sources to FILES_java macro (if AUTO_FILES_JAVA_DIRS used)
0N/AFILES_java += $(FILES_java_auto1) $(FILES_java_auto2)
0N/A
0N/A# File that will hold java source names that need compiling
0N/AJAVA_SOURCE_LIST=$(TEMPDIR)/.classes.list
0N/A
0N/A# Add a java source to the list
0N/Adefine add-java-file
0N/A$(ECHO) "$?" >> $(JAVA_SOURCE_LIST)
0N/A$(check-conventions)
0N/Aendef
0N/A
0N/Aifdef DEMOS
0N/A$(CLASSDESTDIR)/%.class: $(SOURCEPATH)/%.java
0N/A @$(add-java-file)
0N/A#Redirect zh_HK java files to tmp directory which created from zh_TW
0N/A#$(CLASSDESTDIR)/%_zh_HK.class: $(JDK_L10N_TMP_OUTPUTDIR)/%_zh_HK.java
0N/A# @$(add-java-file)
0N/Aelse
0N/A
0N/A#
0N/A# Rules for closed files
0N/A#
0N/A# If filenames are duplicated between open/closed workspaces, prefer
0N/A# the closed files.
0N/A#
0N/A# Rule ordering in this Makefile is important: some targets depend
0N/A# on closed files replacing open ones, and thus the closed file rules
0N/A# must be found before the open ones.
0N/A#
0N/A# Don't reorder without consulting teams that depend on this behavior.
0N/A#
0N/Aifndef OPENJDK
0N/A$(CLASSDESTDIR)/%.class: $(CLOSED_PLATFORM_SRC)/classes/%.java
0N/A @$(add-java-file)
0N/A$(CLASSDESTDIR)/%.class: $(CLOSED_SHARE_SRC)/classes/%.java
0N/A @$(add-java-file)
0N/Aendif
0N/A
0N/A$(CLASSDESTDIR)/%.class: $(GENSRCDIR)/%.java
0N/A @$(add-java-file)
4632N/A
4632N/Aifeq ($(PLATFORM), macosx)
4632N/A# TODO(cpc): need to document why this is necessary...
4632N/A$(CLASSDESTDIR)/%.class: $(JDK_TOPDIR)/src/macosx/classes/%.java
4632N/A @$(add-java-file)
4632N/Aendif
0N/A$(CLASSDESTDIR)/%.class: $(PLATFORM_SRC)/classes/%.java
0N/A @$(add-java-file)
4632N/A
0N/A$(CLASSDESTDIR)/%.class: $(SHARE_SRC)/classes/%.java
0N/A @$(add-java-file)
0N/A
0N/A#Redirect zh_HK java files to tmp directory which created from zh_TW
0N/A$(CLASSDESTDIR)/%_zh_HK.class: $(JDK_L10N_TMP_OUTPUTDIR)/%_zh_HK.java
0N/A @$(add-java-file)
0N/Aendif
0N/A
0N/A# List of class files needed
0N/AFILES_class = $(FILES_java:%.java=$(CLASSDESTDIR)/%.class)
0N/A
0N/A# Got to include exported files.
0N/AFILES_class += $(FILES_export:%.java=$(CLASSDESTDIR)/%.class)
0N/A
0N/A# Construct list of java sources we need to compile
0N/Asource_list_prime:
0N/A @$(MKDIR) -p $(TEMPDIR)
0N/A# Note that we slip resources in so that compiled properties files get created:
0N/A$(JAVA_SOURCE_LIST) : source_list_prime resources $(FILES_class)
0N/A @$(TOUCH) $@
0N/A
0N/A.delete.classlist:
0N/A @$(RM) $(JAVA_SOURCE_LIST)
0N/A
0N/A# Make sure all newer sources are compiled (in a batch)
0N/Aclasses : $(CLASSES_INIT) .delete.classlist .compile.classlist
0N/A
0N/A.compile.classlist : $(JAVA_SOURCE_LIST)
0N/A @$(MKDIR) -p $(CLASSDESTDIR)
173N/A @$(RM) $<.filtered
173N/A @$(CAT) $< | $(NAWK) 'length>0' | $(SORT) -u > $<.filtered
173N/A @if [ `$(CAT) $<.filtered | $(WC) -l` -ge 1 ] ; then \
173N/A $(ECHO) "# Java sources to be compiled: (listed in file $<)"; \
173N/A $(CAT) $<.filtered; \
0N/A $(ECHO) "# Running javac:"; \
173N/A $(ECHO) $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered; \
173N/A $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered; \
0N/A fi
0N/A @$(java-vm-cleanup)
0N/A
0N/Aclobber clean::
0N/A $(RM) $(JAVA_SOURCE_LIST)
0N/A
0N/Aifndef DONT_CLOBBER_CLASSES
0N/A ifndef PACKAGE
0N/A DONT_CLOBBER_CLASSES = true
0N/A else
0N/A DONT_CLOBBER_CLASSES = false
0N/A endif
0N/Aendif
0N/A
0N/Apackages.clean:
0N/Aifeq ($(DONT_CLOBBER_CLASSES),false)
0N/A ifdef AUTO_FILES_JAVA_DIRS
0N/A @for sdir in $(AUTO_FILES_JAVA_DIRS); do \
0N/A $(ECHO) "$(RM) -r $(CLASSDESTDIR)/$$sdir"; \
0N/A $(RM) -r $(CLASSDESTDIR)/$$sdir; \
0N/A done
0N/A else
0N/A $(RM) -r $(CLASSDESTDIR)/$(PKGDIR)
0N/A endif
0N/Aendif
0N/A
0N/Aifdef DEMOS
0N/Aclasses.clean:
0N/A $(RM) -r $(DEMODST) $(CLASSDESTDIR)
0N/Aelse
0N/Aclasses.clean: packages.clean
0N/A $(RM) $(JAVA_SOURCE_LIST)
0N/Aendif
0N/A
0N/A#
0N/A# C and C++ make dependencies
0N/A#
0N/Ainclude $(JDK_TOPDIR)/make/common/internal/NativeCompileRules.gmk
0N/A
0N/A#
0N/A# Running Javah to generate stuff into CClassHeaders.
0N/A#
0N/A
0N/Aifdef FILES_export
0N/A
0N/ACLASSES.export = $(subst /,.,$(FILES_export:%.java=%))
0N/ACLASSES.export += $(subst /,.,$(FILES_export2:%.java=%))
0N/ACLASSES.export += $(subst /,.,$(FILES_export3:%.java=%))
0N/ACLASSES_export = $(FILES_export:%.java=$(CLASSDESTDIR)/%.class)
0N/ACLASSES_export += $(FILES_export2:%.java=$(CLASSDESTDIR)/%.class)
0N/ACLASSES_export += $(FILES_export3:%.java=$(CLASSDESTDIR)/%.class)
0N/A
0N/A# Fix when deploy workspace makefiles don't depend on this name
0N/A#CLASSHDR_DOTFILE=$(CLASSHDRDIR)/.classheaders
0N/A
0N/ACLASSHDR_DOTFILE=$(OBJDIR)/.class.headers.$(ARCH)
0N/A
0N/Aclassheaders: classes $(CLASSHDR_DOTFILE)
0N/A
0N/A$(CLASSHDR_DOTFILE): $(CLASSES_export)
0N/A $(prep-target)
0N/A @$(ECHO) "# Running javah:"
0N/A $(JAVAH_CMD) -d $(CLASSHDRDIR)/ \
0N/A $(CLASSES.export) $(subst $$,\$$,$(EXPORTED_inner))
0N/A @$(java-vm-cleanup)
0N/A @$(TOUCH) $@
0N/A
0N/Aclassheaders.clean:
0N/A $(RM) $(CLASSHDR_DOTFILE)
0N/A $(RM) -r $(CLASSHDRDIR)
0N/A
0N/Aelse # FILES_export
0N/A
0N/Aclassheaders: classes
0N/A
0N/Aclassheaders.clean:
0N/A
0N/Aendif # FILES_export
0N/A
0N/Aclean clobber:: classheaders.clean classes.clean .delete.classlist
0N/A
0N/A#
0N/A# Default dependencies
0N/A#
0N/A
0N/Aall: build
0N/A
0N/Abuild: classheaders
0N/A
0N/Adefault: all
0N/A
0N/A.PHONY: all build clean clobber \
0N/A .delete.classlist classes .compile.classlist classes.clean \
0N/A classheaders classheaders.clean \
0N/A batch_compile
0N/A