duke@1: # duke@1: # Copyright 1995-2007 Sun Microsystems, Inc. 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 duke@1: # published by the Free Software Foundation. Sun designates this duke@1: # particular file as subject to the "Classpath" exception as provided duke@1: # by Sun 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: # duke@1: # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@1: # CA 95054 USA or visit www.sun.com if you need additional information or duke@1: # have any questions. duke@1: # duke@1: duke@1: # duke@1: # Common variables used by all the Java makefiles. This file should duke@1: # not contain rules. duke@1: # duke@1: duke@1: # duke@1: # On Solaris, the 'make' utility from Sun will not work with these makefiles. duke@1: # This little rule is only understood by Sun's make, and is harmless duke@1: # when seen by the GNU make tool. If using Sun's make, this causes the duke@1: # make command to fail. duke@1: # duke@1: SUN_MAKE_TEST:sh = echo "ERROR: PLEASE USE GNU VERSION OF MAKE"; exit 33 duke@1: duke@1: include $(BUILDDIR)/common/shared/Platform.gmk duke@1: duke@1: TOPDIR=$(BUILDDIR)/.. duke@1: duke@1: include $(TOPDIR)/make/common/CancelImplicits.gmk duke@1: duke@1: # Historically PLATFORM_SRC used to be src/$(PLATFORM), but we switched it to duke@1: # src/solaris so if you want to build on Linux you didn't need a src/linux duke@1: # directory. In an ideal world it would be called src/genunix but we are not duke@1: # there yet. duke@1: # duke@1: ifndef SHARE_SRC duke@1: SHARE_SRC = $(TOPDIR)/src/share duke@1: endif duke@1: duke@1: _OUTPUTDIR=$(TOPDIR)/build/$(PLATFORM)-$(ARCH) duke@1: duke@1: # duke@1: # Get platform definitions duke@1: # duke@1: duke@1: include $(TOPDIR)/make/common/Defs-$(PLATFORM).gmk duke@1: duke@1: # duke@1: # Localizations for the different parts of the product beyond English duke@1: # duke@1: duke@1: JRE_LOCALES = de es fr it ja ko sv zh_CN zh_TW zh_HK duke@1: PLUGIN_LOCALES = de es fr it ja ko sv zh_CN zh_TW zh_HK duke@1: JDK_LOCALES = ja zh_CN duke@1: duke@1: # duke@1: # A list of locales we support but don't have resource files. duke@1: # This is defined to optimize the search of resource bundles. duke@1: # duke@1: JRE_NONEXIST_LOCALES = en en_US de_DE es_ES fr_FR it_IT ja_JP ko_KR sv_SE zh duke@1: duke@1: # duke@1: # All libraries except libjava and libjvm itself link against libjvm and duke@1: # libjava, the latter for its exported common utilities. libjava only links duke@1: # against libjvm. Programs' makefiles take their own responsibility for duke@1: # adding other libs. duke@1: # duke@1: ifdef PACKAGE duke@1: # put JAVALIB first, but do not lose any platform specific values.... duke@1: LDLIBS_COMMON = $(JAVALIB) duke@1: endif # PACKAGE duke@1: duke@1: # duke@1: # Libraries that must appear ahead of libc.so on the link command line duke@1: # duke@1: ifdef PROGRAM duke@1: duke@1: ifeq ($(PLATFORM), solaris) duke@1: LDLIBS_COMMON = -lthread -ldl duke@1: endif duke@1: duke@1: ifeq ($(PLATFORM), linux) duke@1: LDLIBS_COMMON = -ldl duke@1: endif duke@1: duke@1: endif # PROGRAM duke@1: duke@1: LDLIBS_COMMON += $(EXTRA_LIBS) duke@1: duke@1: # duke@1: # Default is to build, not import native binaries duke@1: # duke@1: ifndef IMPORT_NATIVE_BINARIES duke@1: IMPORT_NATIVE_BINARIES=false duke@1: endif duke@1: # If importing libraries in, no incremental builds duke@1: ifeq ($(IMPORT_NATIVE_BINARIES),true) duke@1: INCREMENTAL_BUILD=false duke@1: endif duke@1: duke@1: # for generated libraries duke@1: LIBDIR = $(OUTPUTDIR)/lib duke@1: ABS_LIBDIR = $(ABS_OUTPUTDIR)/lib duke@1: # Optional place to save the windows .lib files duke@1: LIBFILES_DIR = $(OUTPUTDIR)/libfiles duke@1: # for ext jre files duke@1: EXTDIR = $(LIBDIR)/ext duke@1: # for generated include files duke@1: INCLUDEDIR = $(OUTPUTDIR)/include duke@1: # for generated class files duke@1: CLASSBINDIR = $(OUTPUTDIR)/classes duke@1: DEMOCLASSDIR = $(OUTPUTDIR)/democlasses duke@1: # for generated tool class files duke@1: BUILDTOOLCLASSDIR = $(OUTPUTDIR)/btclasses duke@1: # for build tool jar files duke@1: BUILDTOOLJARDIR = $(OUTPUTDIR)/btjars duke@1: ABS_BUILDTOOLJARDIR = $(ABS_OUTPUTDIR)/btjars duke@1: # for generated java source files duke@1: GENSRCDIR = $(OUTPUTDIR)/gensrc duke@1: # for generated C source files (not javah) duke@1: GENNATIVESRCDIR = $(OUTPUTDIR)/gennativesrc duke@1: # for imported source files duke@1: IMPORTSRCDIR = $(OUTPUTDIR)/impsrc duke@1: # for imported documents duke@1: IMPORTDOCDIR = $(OUTPUTDIR)/impdoc duke@1: # for generated demo duke@1: DEMODIR = $(OUTPUTDIR)/demo duke@1: # for sample code duke@1: SAMPLEDIR = $(OUTPUTDIR)/sample duke@1: # for generated documentation duke@1: DOCSDIR = $(OUTPUTDIR)/docs$(DOCSDIRSUFFIX) duke@1: DOCSDIRSUFFIX = duke@1: duke@1: # An attempt is made to generate unique enough directories for the duke@1: # generated files to not have name collisisons. Most build units duke@1: # defines PRODUCT (except Release.gmk), but then they may or may duke@1: # not define PACKAGE, THREADIR (only HPI uses this), PROGRAM, and duke@1: # LIBRARY. This code chunk attempts to generate a unique duke@1: # OBJDIR/CLASSHDRDIR for each build unit based on which of those duke@1: # values are set within each build unit. duke@1: duke@1: UNIQUE_LOCATION_STRING = tmp duke@1: duke@1: ifneq ($(PRODUCT),) duke@1: UNIQUE_LOCATION_STRING += /$(PRODUCT) duke@1: endif duke@1: duke@1: ifneq ($(PACKAGE),) duke@1: UNIQUE_LOCATION_STRING += /$(PACKAGE) duke@1: endif duke@1: duke@1: ifneq ($(PROGRAM),) duke@1: UNIQUE_LOCATION_STRING += /$(PROGRAM) duke@1: endif duke@1: duke@1: ifneq ($(LIBRARY),) duke@1: ifneq ($(LIBRARY_OUTPUT),) duke@1: UNIQUE_LOCATION_STRING += /$(LIBRARY_OUTPUT) duke@1: else duke@1: UNIQUE_LOCATION_STRING += /$(LIBRARY) duke@1: endif duke@1: endif duke@1: duke@1: ifneq ($(THREADDIR),) duke@1: UNIQUE_LOCATION_STRING += /$(THREADDIR) duke@1: endif duke@1: duke@1: # the use of += above makes a space separated list which we need to duke@1: # remove for filespecs. duke@1: # duke@1: NULLSTRING := duke@1: ONESPACE := $(NULLSTRING) # space before this comment is required. duke@1: UNIQUE_PATH = $(subst $(ONESPACE),,$(UNIQUE_LOCATION_STRING)) duke@1: duke@1: # TEMPDIR is a unique general purpose directory duke@1: # need to use 'override' because GNU Make on Linux exports the wrong duke@1: # value. duke@1: override TEMPDIR = $(OUTPUTDIR)/$(UNIQUE_PATH) duke@1: override ABS_TEMPDIR = $(ABS_OUTPUTDIR)/$(UNIQUE_PATH) duke@1: duke@1: # This must be created right away for pattern rules in Sanity.gmk to work. duke@1: dummy1:=$(shell $(MKDIR) -p $(TEMPDIR)) duke@1: dummy2:=$(shell $(MKDIR) -p $(TEMP_DISK)) duke@1: duke@1: # OBJDIRNAME is the name of the directory where the object code is to duke@1: # be placed. It's name depends on whether the data model architecture duke@1: # is 32-bit or not. duke@1: ifneq ($(ARCH_DATA_MODEL), 32) duke@1: OBJDIRNAME = obj$(ARCH_DATA_MODEL)$(OBJDIRNAME_SUFFIX) duke@1: else duke@1: OBJDIRNAME = obj$(OBJDIRNAME_SUFFIX) duke@1: endif duke@1: OBJDIR = $(TEMPDIR)/$(OBJDIRNAME) duke@1: duke@1: # CLASSHDRDIR is where the generated C Class Header files go. duke@1: CLASSHDRDIR = $(TEMPDIR)/CClassHeaders duke@1: duke@1: # duke@1: # CLASSDESTDIR can be used to specify the directory where generated classes duke@1: # are to be placed. The default is CLASSBINDIR. duke@1: # duke@1: ifndef CLASSDESTDIR duke@1: CLASSDESTDIR = $(CLASSBINDIR) duke@1: endif duke@1: duke@1: INCLUDES = -I. -I$(CLASSHDRDIR) \ duke@1: $(patsubst %,-I%,$(subst $(CLASSPATH_SEPARATOR), ,$(VPATH.h))) $(OTHER_INCLUDES) duke@1: OTHER_CPPFLAGS = $(INCLUDES) duke@1: duke@1: duke@1: # duke@1: # vpaths. These are the default locations searched for source files. duke@1: # GNUmakefiles of individual areas often override the default settings. duke@1: # There are no longer default vpath entries for C and assembler files duke@1: # so we can ensure that libraries don't get their hands on JVM files. duke@1: # duke@1: # We define an intermediate variable for Java files because duke@1: # we use its value later to help define $SOURCEPATH duke@1: duke@1: VPATH0.java = $(GENSRCDIR)$(CLASSPATH_SEPARATOR)$(PLATFORM_SRC)/classes$(CLASSPATH_SEPARATOR)$(SHARE_SRC)/classes duke@1: VPATH.java = $(VPATH0.java) duke@1: vpath %.java $(VPATH.java) duke@1: vpath %.class $(CLASSBINDIR) duke@1: vpath %.$(OBJECT_SUFFIX) $(OBJDIR) duke@1: duke@1: # duke@1: # VPATH.h is used elsewhere to generate include flags. By default, duke@1: # anyone has access to the include files that the JVM area exports, duke@1: # namely jni.h, jvm.h, and jni_utils.h, plus their platform-specific duke@1: # relatives. duke@1: # duke@1: ifeq ($(PLATFORM), windows) duke@1: VPATH.h = $(BOOTDIR)/include;$(BOOTDIR)/include/$(PLATFORM_INCLUDE_NAME) duke@1: else duke@1: VPATH.h = $(PLATFORM_SRC)/javavm/export$(CLASSPATH_SEPARATOR)$(SHARE_SRC)/javavm/export$(CLASSPATH_SEPARATOR)$(SHARE_SRC)/javavm/include$(CLASSPATH_SEPARATOR)$(PLATFORM_SRC)/javavm/include duke@1: endif duke@1: vpath %.h $(VPATH.h) duke@1: duke@1: # duke@1: # Used in two ways: helps link against libjava.so. Also if overridden duke@1: # determines where your shared library is installed. duke@1: # duke@1: ifndef LIB_LOCATION duke@1: LIB_LOCATION = $(LIBDIR)/$(LIBARCH) duke@1: endif duke@1: duke@1: # duke@1: # Java header and stub variables duke@1: # duke@1: CLASSHDRS = $(patsubst %,$(CLASSHDRDIR)/%.h,$(subst .,_,$(CLASSES.export))) duke@1: CLASSSTUBOBJS = classstubs.$(OBJECT_SUFFIX) duke@1: STUBPREAMBLE = $(INCLUDEDIR)/StubPreamble.h duke@1: duke@1: # duke@1: # Classpath seen by javac (different from the one seen by the VM duke@1: # running javac), and useful variables. duke@1: # duke@1: SOURCEPATH = $(VPATH.java) duke@1: PKG = $(shell $(EXPR) $(PACKAGE) : '\([a-z]*\)') duke@1: PKGDIR = $(subst .,/,$(PACKAGE)) duke@1: duke@1: # duke@1: # The java/javac/jdk variables (JAVAC_CMD, JAVA_CMD, etc.) duke@1: # duke@1: include $(BUILDDIR)/common/shared/Defs-java.gmk duke@1: duke@1: # duke@1: # Set opt level to ALT_OPT if set otherwise _OPT duke@1: # duke@1: POPT = $(_OPT$(ALT_OPT))$(ALT_OPT) duke@1: duke@1: # duke@1: # Convenient macros duke@1: # duke@1: duke@1: # Prepare $@ target, remove old one and making sure directory exists duke@1: define prep-target duke@1: $(MKDIR) -p $(@D) duke@1: $(RM) $@ duke@1: endef duke@1: duke@1: # Simple install of $< file to $@ duke@1: define install-file duke@1: $(prep-target) duke@1: $(CP) $< $@ duke@1: endef duke@1: duke@1: # Cleanup rule for after debug java run (hotspot.log file is left around) duke@1: # (This could be an old leftover file in a read-only area, use the @- prefix) duke@1: HOTSPOT_LOG_NAME = hotspot.log duke@1: define java-vm-cleanup duke@1: if [ -w $(HOTSPOT_LOG_NAME) ] ; then $(RM) $(HOTSPOT_LOG_NAME); fi duke@1: endef duke@1: duke@1: # Default make settings for processing SUBDIRS with clobber or clean names duke@1: SUBDIRS_MAKEFLAGS-clobber = INCREMENTAL_BUILD=false duke@1: SUBDIRS_MAKEFLAGS-clean = INCREMENTAL_BUILD=false duke@1: duke@1: # Current directory duke@1: CURRENT_DIRECTORY := $(shell $(PWD)) duke@1: duke@1: # If no timing wanted, we need to define these as empty duke@1: ifdef NO_TIMING duke@1: duke@1: TIMING_ID:=NA duke@1: duke@1: define TIMING_start duke@1: t=0:0:0:0 duke@1: endef duke@1: duke@1: define TIMING_end duke@1: time_used=0 duke@1: endef duke@1: duke@1: else # NO_TIMING duke@1: duke@1: # Default timing id duke@1: TIMING_ID:=$(shell $(BASENAME) $(CURRENT_DIRECTORY)) duke@1: duke@1: # Timing start (must be used in same shell, e.g. same command line) duke@1: # Defines the shell variable $1 to have the start time. duke@1: define TIMING_start duke@1: $1=`$(DATE) +%j:%H:%M:%S` duke@1: endef duke@1: duke@1: # Timing end (must be used in same shell, e.g. same command line) duke@1: # Expects shell variable $1 to have been defined as the start time. duke@1: # Expects shell variable $2 to have timing id string duke@1: # Sets total_seconds shell variable as the total seconds used. duke@1: # Sets time_used shell variable to contain format "%dh%dm%ds" duke@1: define TIMING_end duke@1: begTime="$${$1}"; \ duke@1: timing_id="$${$2}"; \ duke@1: endTime=`$(DATE) +%j:%H:%M:%S`; \ duke@1: d1=`$(ECHO) $${begTime} | $(CUT) -d':' -f1 | $(SED) -e 's@^0*@@'`; \ duke@1: if [ "$${d1}" = "" ] ; then d1=0; fi; \ duke@1: h1=`$(ECHO) $${begTime} | $(CUT) -d':' -f2 | $(SED) -e 's@^0*@@'`; \ duke@1: if [ "$${h1}" = "" ] ; then h1=0; fi; \ duke@1: m1=`$(ECHO) $${begTime} | $(CUT) -d':' -f3 | $(SED) -e 's@^0*@@'`; \ duke@1: if [ "$${m1}" = "" ] ; then m1=0; fi; \ duke@1: s1=`$(ECHO) $${begTime} | $(CUT) -d':' -f4 | $(SED) -e 's@^0*@@'`; \ duke@1: if [ "$${s1}" = "" ] ; then s1=0; fi; \ duke@1: d2=`$(ECHO) $${endTime} | $(CUT) -d':' -f1 | $(SED) -e 's@^0*@@'`; \ duke@1: if [ "$${d2}" = "" ] ; then d2=0; fi; \ duke@1: h2=`$(ECHO) $${endTime} | $(CUT) -d':' -f2 | $(SED) -e 's@^0*@@'`; \ duke@1: if [ "$${h2}" = "" ] ; then h2=0; fi; \ duke@1: m2=`$(ECHO) $${endTime} | $(CUT) -d':' -f3 | $(SED) -e 's@^0*@@'`; \ duke@1: if [ "$${m2}" = "" ] ; then m2=0; fi; \ duke@1: s2=`$(ECHO) $${endTime} | $(CUT) -d':' -f4 | $(SED) -e 's@^0*@@'`; \ duke@1: if [ "$${s2}" = "" ] ; then s2=0; fi; \ duke@1: t1_secs=`$(EXPR) $${d1} '*' 60 '*' 60 '*' 24 '+' $${h1} '*' 60 '*' 60 \ duke@1: '+' $${m1} '*' 60 '+' $${s1}`; \ duke@1: t2_secs=`$(EXPR) $${d2} '*' 60 '*' 60 '*' 24 '+' $${h2} '*' 60 '*' 60 \ duke@1: '+' $${m2} '*' 60 '+' $${s2}`; \ duke@1: total_seconds=`$(EXPR) $${t2_secs} '-' $${t1_secs}`; \ duke@1: if [ "$${total_seconds}" -lt 0 ] ; then total_seconds=0; fi; \ duke@1: t_hour=`$(EXPR) $${total_seconds} '/' '(' 60 '*' 60 ')'`h; \ duke@1: t_min=`$(EXPR) '(' $${total_seconds} '%' '(' 60 '*' 60 ')' ')' '/' 60`m; \ duke@1: t_sec=`$(EXPR) $${total_seconds} '%' 60`s; \ duke@1: time_used=$${t_sec}; \ duke@1: if [ "$${t_hour}" != "0h" ] ; then \ duke@1: time_used=$${t_hour}$${t_min}$${t_sec}; \ duke@1: elif [ "$${t_min}" != "0m" ] ; then \ duke@1: time_used=$${t_min}$${t_sec}; \ duke@1: else \ duke@1: time_used=$${t_sec}; \ duke@1: fi; \ duke@1: $(PRINTF) " Timing: %05d seconds or %s for %s\n" \ duke@1: $${total_seconds} $${time_used} $${timing_id} duke@1: endef duke@1: duke@1: endif # NO_TIMING duke@1: duke@1: # Given a SUBDIRS list, cd into them and make them duke@1: # SUBDIRS_MAKEFLAGS Make settings for a subdir make duke@1: # SUBDIRS_MAKEFLAGS-$@ Make settings specific to this target duke@1: define SUBDIRS-loop duke@1: @$(ECHO) "Begin Processing SUBDIRS: $(SUBDIRS)" duke@1: @for i in DUMMY $(SUBDIRS) ; do \ duke@1: if [ "$$i" != "DUMMY" ] ; then \ duke@1: $(ECHO) ">>>Recursively making "$$i" "$@" @ `$(DATE)` ..."; \ duke@1: timing_id="$(TIMING_ID)-`$(BASENAME) $${i}`"; \ duke@1: $(call TIMING_start,startTime); \ duke@1: curDir=$(CURRENT_DIRECTORY); \ duke@1: $(CD) $$i; $(MAKE) $@ TIMING_ID=$${timing_id} \ duke@1: $(SUBDIRS_MAKEFLAGS) \ duke@1: $(SUBDIRS_MAKEFLAGS-$@) \ duke@1: FULL_VERSION=$(FULL_VERSION) \ duke@1: RELEASE=$(RELEASE) || exit 1; \ duke@1: $(CD) $${curDir}; \ duke@1: $(call TIMING_end,startTime,timing_id); \ duke@1: $(ECHO) "<<>>Recursively making "$$i" "$@" @ `$(DATE)` ..."; \ duke@1: timing_id="$(TIMING_ID)-`$(BASENAME) $${i}`"; \ duke@1: $(call TIMING_start,startTime); \ duke@1: curDir=$(CURRENT_DIRECTORY); \ duke@1: $(CD) $$i; $(MAKE) $@ TIMING_ID=$${timing_id} \ duke@1: $(OTHERSUBDIRS_MAKEFLAGS) \ duke@1: FULL_VERSION=$(FULL_VERSION) \ duke@1: RELEASE=$(RELEASE) || exit 1; \ duke@1: $(CD) $${curDir}; \ duke@1: $(call TIMING_end,startTime,timing_id); \ duke@1: $(ECHO) "<<.gmk..... duke@1: ifeq ($(PLATFORM), windows) duke@1: VERSION_DEFINES = -DRELEASE="\"$(RELEASE)\"" duke@1: else duke@1: VERSION_DEFINES = -DRELEASE='"$(RELEASE)"' duke@1: endif duke@1: duke@1: # Note: As a rule, GNU Make rules should not appear in any of the duke@1: # Defs*.gmk files. These were added for Kestrel-Solaris and do address duke@1: # a TeamWare bug. They should be moved elsewhere for Merlin. duke@1: # duke@1: # Override gnumake built-in rules which do sccs get operations badly. duke@1: # (They put the checked out code in the current directory, not in the duke@1: # directory of the original file.) duke@1: # Since this is a symptom of a teamware failure, complain and die on the spot. duke@1: duke@1: # This message immediately goes to stdout and the build terminates. duke@1: define SCCS-trouble duke@1: $(error \ duke@1: "ERROR: File $@ referenced while building in $(CURRENT_DIRECTORY) \ duke@1: is out of date with respect to its SCCS file $<. \ duke@1: This can happen from an unresolved Teamware conflict, a file movement, or \ duke@1: a failure in which SCCS files are updated but the 'sccs get' was not done. \ duke@1: You should double check for other out of date files in your workspace. \ duke@1: Or run: cd $(TOPDIR) && $(MAKE) sccs_get") duke@1: endef duke@1: duke@1: %:: s.% duke@1: @$(SCCS-trouble) duke@1: %:: SCCS/s.% duke@1: @$(SCCS-trouble) duke@1: @$(ECHO) " is out of date with respect to its SCCS file." >> $(WARNING_FILE) duke@1: @$(ECHO) " This file may be from an unresolved Teamware conflict." >> $(WARNING_FILE) duke@1: @$(ECHO) " This is also a symptom of a Teamware bringover/putback failure" >> $(WARNING_FILE) duke@1: @$(ECHO) " in which SCCS files are updated but not checked out." >> $(WARNING_FILE) duke@1: @$(ECHO) " Check for other out of date files in your workspace." >> $(WARNING_FILE) duke@1: @$(ECHO) "" >> $(WARNING_FILE) duke@1: @#exit 666 duke@1: duke@1: ifdef INSANE duke@1: export INSANE duke@1: endif duke@1: duke@1: ifdef ALT_COPYRIGHT_YEAR duke@1: COPYRIGHT_YEAR = $(ALT_COPYRIGHT_YEAR) duke@1: else duke@1: COPYRIGHT_YEAR = $(shell $(DATE) '+%Y') duke@1: endif duke@1: duke@1: # Install of imported file (JDK_IMPORT_PATH, or some other external location) duke@1: define install-import-file duke@1: @$(ECHO) "ASSEMBLY_IMPORT: $@" duke@1: $(install-file) duke@1: endef duke@1: duke@1: .PHONY: all build clean clobber