jdk/make/common/Defs.gmk
changeset 2 90ce3da70b43
child 30 7ea1edf98bfe
equal deleted inserted replaced
0:fd16c54261b3 2:90ce3da70b43
       
     1 #
       
     2 # Copyright 1995-2007 Sun Microsystems, Inc.  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.  Sun designates this
       
     8 # particular file as subject to the "Classpath" exception as provided
       
     9 # by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    22 # CA 95054 USA or visit www.sun.com if you need additional information or
       
    23 # have any questions.
       
    24 #
       
    25 
       
    26 #
       
    27 # Common variables used by all the Java makefiles.  This file should
       
    28 # not contain rules.
       
    29 #
       
    30 
       
    31 # WARNING: This file is shared with other workspaces.
       
    32 #          So when it includes other files, it must use JDK_TOPDIR.
       
    33 #
       
    34 
       
    35 #
       
    36 # On Solaris, the 'make' utility from Sun will not work with these makefiles.
       
    37 #    This little rule is only understood by Sun's make, and is harmless
       
    38 #    when seen by the GNU make tool. If using Sun's make, this causes the
       
    39 #    make command to fail.
       
    40 #
       
    41 SUN_MAKE_TEST:sh = echo "ERROR: PLEASE USE GNU VERSION OF MAKE"; exit 33
       
    42 
       
    43 ifndef JDK_TOPDIR
       
    44   JDK_TOPDIR=$(BUILDDIR)/..
       
    45 endif
       
    46 ifndef JDK_MAKE_SHARED_DIR
       
    47   JDK_MAKE_SHARED_DIR=$(JDK_TOPDIR)/make/common/shared
       
    48 endif
       
    49 
       
    50 include $(JDK_MAKE_SHARED_DIR)/Platform.gmk
       
    51 
       
    52 TOPDIR=$(BUILDDIR)/..
       
    53 
       
    54 include $(JDK_TOPDIR)/make/common/CancelImplicits.gmk
       
    55 
       
    56 # Historically PLATFORM_SRC used to be src/$(PLATFORM), but we switched it to
       
    57 # src/solaris so if you want to build on Linux you didn't need a src/linux
       
    58 # directory.  In an ideal world it would be called src/genunix but we are not
       
    59 # there yet.
       
    60 #
       
    61 ifndef SHARE_SRC
       
    62   SHARE_SRC    = $(JDK_TOPDIR)/src/share
       
    63 endif
       
    64 
       
    65 # Files that cannot be included in the OpenJDK distribution are
       
    66 # collected under a parent directory which contains just those files.
       
    67 ifndef CLOSED_SRC
       
    68   CLOSED_SRC  = $(JDK_TOPDIR)/src/closed
       
    69 endif
       
    70 
       
    71 # If we have no closed directory, force it to an openjdk build
       
    72 CLOSED_SRC_DIR_EXISTS := $(shell \
       
    73   if [ -d $(CLOSED_SRC) ] ; then \
       
    74     echo true; \
       
    75   else \
       
    76     echo false; \
       
    77   fi)
       
    78 ifeq ($(CLOSED_SRC_DIR_EXISTS), false)
       
    79   OPENJDK = true
       
    80 endif
       
    81 
       
    82 # Check for strange explicit settings (change to empty or true)
       
    83 ifdef OPENJDK
       
    84   ifeq ($(OPENJDK),false)
       
    85     # Silently treat as not defined
       
    86     OPENJDK =
       
    87   else
       
    88     ifneq ($(OPENJDK),true)
       
    89       dummy := $(warning "WARNING: OPENKJDK=$(OPENJDK) being treated as true")
       
    90       OPENJDK = true
       
    91     endif
       
    92   endif
       
    93 endif
       
    94 
       
    95 # Define where closed directories are
       
    96 ifdef OPENJDK
       
    97   CLOSED_SRC =
       
    98   CLOSED_SHARE_SRC =
       
    99 else
       
   100   ifndef CLOSED_SHARE_SRC
       
   101     CLOSED_SHARE_SRC    = $(CLOSED_SRC)/share
       
   102   endif
       
   103 endif
       
   104 
       
   105 # If OPENJDK is defined, we may still need to use some native libraries that
       
   106 # exist only as part of the closed source. If the closed sources are not
       
   107 # available, the libraries must have been pre-built. Since these libraries
       
   108 # and the JDK internal interfaces to these are reasonably stable this is not
       
   109 # a significant problem. But we do need to provide a way to locate them,
       
   110 # including a way to point to a new one when there have been changes.
       
   111 #
       
   112 # If you have a formal binary plugs download, set ALT_BINARY_PLUGS_PATH
       
   113 # to the location.
       
   114 # (Optionally you can set ALT_CLOSED_JDK_IMPORT_PATH to point to the latest
       
   115 #  build JDK, or last promotion for this JDK version, but will not work
       
   116 #  on windows).
       
   117 #
       
   118 # As the OPENJDK is built, the binary plugs are used instead of building the
       
   119 # libraries.
       
   120 # Individual Makefiles that specify USE_BINARY_PLUG_LIBRARY, will get
       
   121 # the binary plug copy (or a copy from a built JDK).
       
   122 #
       
   123 # See common/internal/BinaryPlugs.gmk for more information.
       
   124 #
       
   125 # Usage notes:
       
   126 #
       
   127 #   ALT_BINARY_PLUGS_JARFILE is probably rarely needed. It can be used
       
   128 #   to identify the exact jar file to be used for all closed classes..
       
   129 #  
       
   130 #   ALT_BINARY_PLUGS_PATH points to a directory containing precisely the
       
   131 #   binaries needed to build. 
       
   132 #  
       
   133 #   ALT_BUILD_BINARY_PLUGS_PATH points to a directory containing binary plug dirs 
       
   134 #   multiple architectures named using the standard conventions
       
   135 #   This is useful for build scripts that need to build multiple architectures
       
   136 #   of the OpenJDK.
       
   137 #   
       
   138 #   ALT_CLOSED_JDK_IMPORT_PATH points to the top-level of a specific platform
       
   139 #   JDK image.
       
   140 #  
       
   141 #   The precedence is that
       
   142 #     1. ALT_BINARY_PLUGS_JARFILE overrides any other location of the classes
       
   143 #     2. ALT_BINARY_PLUGS_PATH overrides all locations of classes and libraries
       
   144 #     3. ALT_BUILD_BINARY_PLUGS_PATH is used to find a ALT_BINARY_PLUGS_PATH
       
   145 #     4. ALT_CLOSED_JDK_IMPORT_PATH is used to locate classes and libraries
       
   146 #
       
   147 
       
   148 # Always needed, defines the name of the imported/exported jarfile
       
   149 BINARY_PLUGS_JARNAME = rt-closed.jar
       
   150 
       
   151 ifdef OPENJDK
       
   152   ifdef ALT_CLOSED_JDK_IMPORT_PATH
       
   153     CLOSED_JDK_IMPORT_PATH = $(ALT_CLOSED_JDK_IMPORT_PATH)
       
   154     BINARY_PLUGS_PATH = $(CLOSED_JDK_IMPORT_PATH)
       
   155     BINARY_PLUGS_JARFILE = $(CLOSED_JDK_IMPORT_PATH)/jre/lib/rt.jar
       
   156   endif
       
   157   ifdef ALT_BUILD_BINARY_PLUGS_PATH
       
   158     BUILD_BINARY_PLUGS_PATH = $(ALT_BUILD_BINARY_PLUGS_PATH)
       
   159   else
       
   160     BUILD_BINARY_PLUGS_PATH = $(SLASH_JAVA)/re/jdk/$(JDK_VERSION)/promoted/latest/openjdk/binaryplugs
       
   161   endif
       
   162   BINARY_PLUGS_PATH = $(BUILD_BINARY_PLUGS_PATH)/$(PLATFORM)-$(ARCH)
       
   163   BINARY_PLUGS_JARFILE = $(BINARY_PLUGS_PATH)/jre/lib/$(BINARY_PLUGS_JARNAME)
       
   164   ifdef ALT_BINARY_PLUGS_PATH
       
   165     BINARY_PLUGS_PATH  = $(ALT_BINARY_PLUGS_PATH)
       
   166     BINARY_PLUGS_JARFILE = $(BINARY_PLUGS_PATH)/jre/lib/$(BINARY_PLUGS_JARNAME)
       
   167   endif
       
   168   ifdef ALT_BINARY_PLUGS_JARFILE
       
   169     BINARY_PLUGS_JARFILE = $(ALT_BINARY_PLUGS_JARFILE)
       
   170   endif
       
   171 endif # OPENJDK
       
   172 
       
   173 # Default output directory
       
   174 ifdef OPENJDK
       
   175 _OUTPUTDIR=$(JDK_TOPDIR)/build/$(PLATFORM)-$(ARCH)$(OPENJDK_SUFFIX)
       
   176 else
       
   177 _OUTPUTDIR=$(JDK_TOPDIR)/build/$(PLATFORM)-$(ARCH)
       
   178 endif
       
   179 
       
   180 
       
   181 #
       
   182 # Get platform definitions
       
   183 #
       
   184 
       
   185 include $(JDK_TOPDIR)/make/common/Defs-$(PLATFORM).gmk
       
   186 
       
   187 #
       
   188 # Freetype logic is applicable to OpenJDK only
       
   189 #
       
   190 ifdef OPENJDK
       
   191 
       
   192 #if we use system lib we do not need to copy it to build tree
       
   193 USING_SYSTEM_FT_LIB=false
       
   194 
       
   195 ifeq ($(PLATFORM), windows)
       
   196   DEVTOOLS_FT_DIR=$(JDK_DEVTOOLS_DIR)/win32/freetype-$(ARCH)
       
   197 endif
       
   198 ifeq ($(PLATFORM), linux)
       
   199   DEVTOOLS_FT_DIR=$(JDK_DEVTOOLS_DIR)/$(PLATFORM)/freetype-$(ARCH)
       
   200 endif
       
   201 ifeq ($(PLATFORM), solaris)
       
   202   # historically for Solaris we have slightly different devtools 
       
   203   # naming conventions
       
   204   DEVTOOLS_FT_DIR=$(JDK_DEVTOOLS_DIR)/$(ARCH_FAMILY)/freetype-$(ARCH)
       
   205 endif
       
   206 
       
   207 DEVTOOLS_FT_DIR_EXISTS = $(shell \
       
   208   if [ -f $(DEVTOOLS_FT_DIR)/include/ft2build.h ] ; then \
       
   209     echo true; \
       
   210   else \
       
   211     echo false; \
       
   212   fi)
       
   213 
       
   214   ifdef ALT_FREETYPE_LIB_PATH
       
   215     FREETYPE_LIB_PATH = $(ALT_FREETYPE_LIB_PATH)
       
   216   else
       
   217     ifeq ($(DEVTOOLS_FT_DIR_EXISTS), true)
       
   218       FREETYPE_LIB_PATH = $(DEVTOOLS_FT_DIR)/lib
       
   219     else
       
   220       FREETYPE_LIB_PATH = /usr/lib
       
   221       USING_SYSTEM_FT_LIB=true
       
   222     endif
       
   223   endif 
       
   224 
       
   225   ifeq ($(PLATFORM), windows)
       
   226     FREETYPE_LIB = $(FREETYPE_LIB_PATH)/freetype.lib
       
   227   else
       
   228     FREETYPE_LIB = -L$(FREETYPE_LIB_PATH) -lfreetype
       
   229   endif
       
   230 
       
   231   ifdef ALT_FREETYPE_HEADERS_PATH
       
   232     FREETYPE_HEADERS_PATH = $(ALT_FREETYPE_HEADERS_PATH)
       
   233   else
       
   234     ifeq ($(DEVTOOLS_FT_DIR_EXISTS), true)
       
   235       FREETYPE_HEADERS_PATH = $(DEVTOOLS_FT_DIR)/include
       
   236     else
       
   237       FREETYPE_HEADERS_PATH = /usr/include
       
   238     endif
       
   239   endif
       
   240 endif
       
   241 
       
   242 #
       
   243 # Localizations for the different parts of the product beyond English
       
   244 #
       
   245 
       
   246 JRE_LOCALES   = de es fr it ja ko sv zh_CN zh_TW zh_HK
       
   247 PLUGIN_LOCALES = de es fr it ja ko sv zh_CN zh_TW zh_HK
       
   248 JDK_LOCALES  = ja zh_CN
       
   249 
       
   250 #
       
   251 # A list of locales we support but don't have resource files.
       
   252 # This is defined to optimize the search of resource bundles.
       
   253 #
       
   254 JRE_NONEXIST_LOCALES = en en_US de_DE es_ES fr_FR it_IT ja_JP ko_KR sv_SE zh
       
   255 
       
   256 #
       
   257 # All libraries except libjava and libjvm itself link against libjvm and
       
   258 # libjava, the latter for its exported common utilities.  libjava only links
       
   259 # against libjvm.  Programs' makefiles take their own responsibility for
       
   260 # adding other libs.
       
   261 #
       
   262 ifdef PACKAGE
       
   263 # put JAVALIB first, but do not lose any platform specific values....
       
   264   LDLIBS_COMMON = $(JAVALIB)
       
   265 endif # PACKAGE
       
   266 
       
   267 #
       
   268 # Libraries that must appear ahead of libc.so on the link command line
       
   269 #
       
   270 ifdef PROGRAM
       
   271 
       
   272   ifeq ($(PLATFORM), solaris)
       
   273     LDLIBS_COMMON = -lthread -ldl
       
   274   endif
       
   275 
       
   276   ifeq ($(PLATFORM), linux)
       
   277     LDLIBS_COMMON = -ldl
       
   278   endif
       
   279 
       
   280 endif # PROGRAM
       
   281 
       
   282 LDLIBS_COMMON += $(EXTRA_LIBS)
       
   283 
       
   284 #
       
   285 # Default is to build, not import native binaries
       
   286 #
       
   287 ifndef IMPORT_NATIVE_BINARIES
       
   288   IMPORT_NATIVE_BINARIES=false
       
   289 endif
       
   290 # If importing libraries in, no incremental builds
       
   291 ifeq ($(IMPORT_NATIVE_BINARIES),true)
       
   292  INCREMENTAL_BUILD=false
       
   293 endif
       
   294 
       
   295 # for generated libraries
       
   296 LIBDIR              = $(OUTPUTDIR)/lib
       
   297 ABS_LIBDIR          = $(ABS_OUTPUTDIR)/lib
       
   298 # Optional place to save the windows .lib files
       
   299 LIBFILES_DIR        = $(OUTPUTDIR)/libfiles
       
   300 # for ext jre files
       
   301 EXTDIR              = $(LIBDIR)/ext
       
   302 # for generated include files
       
   303 INCLUDEDIR          = $(OUTPUTDIR)/include
       
   304 # for generated class files
       
   305 CLASSBINDIR         = $(OUTPUTDIR)/classes
       
   306 DEMOCLASSDIR        = $(OUTPUTDIR)/democlasses
       
   307 # for generated tool class files
       
   308 BUILDTOOLCLASSDIR   = $(OUTPUTDIR)/btclasses
       
   309 # for build tool jar files
       
   310 BUILDTOOLJARDIR     = $(OUTPUTDIR)/btjars
       
   311 ABS_BUILDTOOLJARDIR = $(ABS_OUTPUTDIR)/btjars
       
   312 # for generated java source files
       
   313 GENSRCDIR           = $(OUTPUTDIR)/gensrc
       
   314 # for generated C source files (not javah)
       
   315 GENNATIVESRCDIR     = $(OUTPUTDIR)/gennativesrc
       
   316 # for imported source files
       
   317 IMPORTSRCDIR        = $(OUTPUTDIR)/impsrc
       
   318 # for imported documents
       
   319 IMPORTDOCDIR        = $(OUTPUTDIR)/impdoc
       
   320 # for generated demo
       
   321 DEMODIR             = $(OUTPUTDIR)/demo
       
   322 # for sample code
       
   323 SAMPLEDIR           = $(OUTPUTDIR)/sample
       
   324 # for generated documentation
       
   325 DOCSDIR             = $(OUTPUTDIR)/docs$(DOCSDIRSUFFIX)
       
   326 DOCSDIRSUFFIX       =
       
   327 
       
   328 # The MESSAGE, WARNING and ERROR files are used to store sanityck and 
       
   329 # SCCS check messages, warnings and errors. 
       
   330 ifndef ERROR_FILE
       
   331   ERROR_FILE   = $(OUTPUTDIR)/sanityCheckErrors.txt
       
   332 endif
       
   333 ifndef WARNING_FILE
       
   334   WARNING_FILE = $(OUTPUTDIR)/sanityCheckWarnings.txt
       
   335 endif
       
   336 ifndef MESSAGE_FILE
       
   337   MESSAGE_FILE = $(OUTPUTDIR)/sanityCheckMessages.txt
       
   338 endif
       
   339 
       
   340 JDK_IMAGE_DIR = $(ABS_OUTPUTDIR)/j2sdk-image
       
   341 JRE_IMAGE_DIR = $(ABS_OUTPUTDIR)/j2re-image
       
   342 
       
   343 #where the demo source can be found
       
   344 DEMOSRCDIR          = $(SHARE_SRC)/demo
       
   345 
       
   346 # An attempt is made to generate unique enough directories for the
       
   347 # generated files to not have name collisisons. Most build units
       
   348 # defines PRODUCT (except Release.gmk), but then they may or may 
       
   349 # not define PACKAGE, THREADIR (only HPI uses this), PROGRAM, and 
       
   350 # LIBRARY. This code chunk attempts to generate a unique 
       
   351 # OBJDIR/CLASSHDRDIR for each build unit based on which of those 
       
   352 # values are set within each build unit.
       
   353 
       
   354 UNIQUE_LOCATION_STRING = tmp
       
   355 
       
   356 ifneq ($(PRODUCT),)
       
   357   UNIQUE_LOCATION_STRING += /$(PRODUCT)
       
   358 endif
       
   359 
       
   360 ifneq ($(PACKAGE),)
       
   361   UNIQUE_LOCATION_STRING += /$(PACKAGE)
       
   362 endif
       
   363 
       
   364 ifneq ($(PROGRAM),)
       
   365   UNIQUE_LOCATION_STRING += /$(PROGRAM)
       
   366 endif
       
   367 
       
   368 ifneq ($(LIBRARY),)
       
   369   ifneq ($(LIBRARY_OUTPUT),)
       
   370     UNIQUE_LOCATION_STRING += /$(LIBRARY_OUTPUT)
       
   371   else
       
   372     UNIQUE_LOCATION_STRING += /$(LIBRARY)
       
   373   endif
       
   374 endif
       
   375 
       
   376 ifneq ($(THREADDIR),)
       
   377   UNIQUE_LOCATION_STRING += /$(THREADDIR)
       
   378 endif
       
   379 
       
   380 # the use of += above makes a space separated list which we need to 
       
   381 # remove for filespecs.
       
   382 #
       
   383 NULLSTRING :=
       
   384 ONESPACE := $(NULLSTRING) # space before this comment is required.
       
   385 UNIQUE_PATH = $(subst $(ONESPACE),,$(UNIQUE_LOCATION_STRING))
       
   386 
       
   387 # TEMPDIR is a unique general purpose directory
       
   388 # need to use 'override' because GNU Make on Linux exports the wrong
       
   389 # value.
       
   390 override TEMPDIR      = $(OUTPUTDIR)/$(UNIQUE_PATH)
       
   391 override ABS_TEMPDIR  = $(ABS_OUTPUTDIR)/$(UNIQUE_PATH)
       
   392 
       
   393 # This must be created right away for pattern rules in Sanity.gmk to work.
       
   394 dummy1:=$(shell $(MKDIR) -p $(TEMPDIR))
       
   395 dummy2:=$(shell $(MKDIR) -p $(TEMP_DISK))
       
   396 
       
   397 # OBJDIRNAME is the name of the directory where the object code is to
       
   398 #   be placed. It's name depends on whether the data model architecture 
       
   399 #   is 32-bit or not.
       
   400 ifneq ($(ARCH_DATA_MODEL), 32)
       
   401   OBJDIRNAME  = obj$(ARCH_DATA_MODEL)$(OBJDIRNAME_SUFFIX)
       
   402 else
       
   403   OBJDIRNAME  = obj$(OBJDIRNAME_SUFFIX)
       
   404 endif
       
   405 OBJDIR      = $(TEMPDIR)/$(OBJDIRNAME)
       
   406 
       
   407 # CLASSHDRDIR is where the generated C Class Header files go.
       
   408 CLASSHDRDIR = $(TEMPDIR)/CClassHeaders
       
   409 
       
   410 #
       
   411 # CLASSDESTDIR can be used to specify the directory where generated classes
       
   412 # are to be placed. The default is CLASSBINDIR.
       
   413 #
       
   414 ifndef CLASSDESTDIR
       
   415 CLASSDESTDIR = $(CLASSBINDIR)
       
   416 endif
       
   417 
       
   418 INCLUDES = -I. -I$(CLASSHDRDIR) \
       
   419 	$(patsubst %,-I%,$(subst $(CLASSPATH_SEPARATOR), ,$(VPATH.h))) $(OTHER_INCLUDES)
       
   420 OTHER_CPPFLAGS = $(INCLUDES)
       
   421 
       
   422 
       
   423 #
       
   424 # vpaths.  These are the default locations searched for source files.
       
   425 # GNUmakefiles of individual areas often override the default settings.
       
   426 # There are no longer default vpath entries for C and assembler files
       
   427 # so we can ensure that libraries don't get their hands on JVM files.
       
   428 #
       
   429 # We define an intermediate variable for Java files because
       
   430 # we use its value later to help define $SOURCEPATH
       
   431 
       
   432 VPATH0.java = $(GENSRCDIR)$(CLASSPATH_SEPARATOR)$(PLATFORM_SRC)/classes$(CLASSPATH_SEPARATOR)$(SHARE_SRC)/classes
       
   433 ifdef OPENJDK
       
   434   VPATH.java = $(VPATH0.java)
       
   435 else
       
   436   #
       
   437   # If filenames are duplicated between open/closed workspaces, prefer
       
   438   # the closed files.
       
   439   #
       
   440   # Source ordering is important: some targets depend on closed files
       
   441   # replacing open ones, and thus the closed file sources must be found
       
   442   # before the open ones.
       
   443   #
       
   444   # Don't reorder without consulting the teams that depend on this behavior.
       
   445   #
       
   446   VPATH.java = $(CLOSED_PLATFORM_SRC)/classes$(CLASSPATH_SEPARATOR)$(CLOSED_SHARE_SRC)/classes$(CLASSPATH_SEPARATOR)$(VPATH0.java)
       
   447 endif
       
   448 vpath %.java $(VPATH.java)
       
   449 vpath %.class $(CLASSBINDIR)
       
   450 vpath %.$(OBJECT_SUFFIX) $(OBJDIR)
       
   451 
       
   452 #
       
   453 # VPATH.h is used elsewhere to generate include flags.  By default, 
       
   454 # anyone has access to the include files that the JVM area exports,
       
   455 # namely jni.h, jvm.h, and jni_utils.h, plus their platform-specific
       
   456 # relatives.
       
   457 #
       
   458 VPATH.h =   $(PLATFORM_SRC)/javavm/export$(CLASSPATH_SEPARATOR)$(SHARE_SRC)/javavm/export$(CLASSPATH_SEPARATOR)$(SHARE_SRC)/javavm/include$(CLASSPATH_SEPARATOR)$(PLATFORM_SRC)/javavm/include
       
   459 vpath %.h   $(VPATH.h)
       
   460 
       
   461 #
       
   462 # Used in two ways: helps link against libjava.so. Also if overridden
       
   463 # determines where your shared library is installed.
       
   464 #
       
   465 ifndef LIB_LOCATION
       
   466   LIB_LOCATION    =  $(LIBDIR)/$(LIBARCH)
       
   467 endif
       
   468 
       
   469 #
       
   470 # Java header and stub variables
       
   471 #
       
   472 CLASSHDRS     = $(patsubst %,$(CLASSHDRDIR)/%.h,$(subst .,_,$(CLASSES.export)))
       
   473 CLASSSTUBOBJS = classstubs.$(OBJECT_SUFFIX)
       
   474 STUBPREAMBLE  = $(INCLUDEDIR)/StubPreamble.h
       
   475 
       
   476 #
       
   477 # Classpath seen by javac (different from the one seen by the VM
       
   478 # running javac), and useful variables.
       
   479 #
       
   480 SOURCEPATH	= $(VPATH.java)
       
   481 PKG		= $(shell $(EXPR) $(PACKAGE) : '\([a-z]*\)')
       
   482 PKGDIR		= $(subst .,/,$(PACKAGE))
       
   483 
       
   484 #
       
   485 # The java/javac/jdk variables (JAVAC_CMD, JAVA_CMD, etc.)
       
   486 #
       
   487 include $(JDK_MAKE_SHARED_DIR)/Defs-java.gmk
       
   488 
       
   489 #
       
   490 # Set opt level to ALT_OPT if set otherwise _OPT
       
   491 #
       
   492 POPT = $(_OPT$(ALT_OPT))$(ALT_OPT)
       
   493 
       
   494 #
       
   495 # Convenient macros
       
   496 #
       
   497 
       
   498 # Prepare $@ target, remove old one and making sure directory exists
       
   499 define prep-target
       
   500 $(MKDIR) -p $(@D)
       
   501 $(RM) $@
       
   502 endef
       
   503 
       
   504 # Simple install of $< file to $@
       
   505 define install-file
       
   506 $(prep-target)
       
   507 $(CP) $< $@
       
   508 endef
       
   509 
       
   510 # Cleanup rule for after debug java run (hotspot.log file is left around)
       
   511 #   (This could be an old leftover file in a read-only area, use the @- prefix)
       
   512 HOTSPOT_LOG_NAME = hotspot.log
       
   513 define java-vm-cleanup
       
   514 if [ -w $(HOTSPOT_LOG_NAME) ] ; then $(RM) $(HOTSPOT_LOG_NAME); fi
       
   515 endef
       
   516 
       
   517 # Default make settings for processing SUBDIRS with clobber or clean names
       
   518 SUBDIRS_MAKEFLAGS-clobber = INCREMENTAL_BUILD=false
       
   519 SUBDIRS_MAKEFLAGS-clean   = INCREMENTAL_BUILD=false
       
   520 
       
   521 # Current directory
       
   522 CURRENT_DIRECTORY := $(shell $(PWD))
       
   523 
       
   524 # If no timing wanted, we need to define these as empty
       
   525 ifdef NO_TIMING
       
   526 
       
   527 TIMING_ID:=NA
       
   528 
       
   529 define TIMING_start
       
   530 t=0:0:0:0
       
   531 endef
       
   532 
       
   533 define TIMING_end
       
   534 time_used=0
       
   535 endef
       
   536 
       
   537 else # NO_TIMING
       
   538 
       
   539 # Default timing id
       
   540 TIMING_ID:=$(shell $(BASENAME) $(CURRENT_DIRECTORY))
       
   541 
       
   542 # Timing start (must be used in same shell, e.g. same command line)
       
   543 #    Defines the shell variable $1 to have the start time.
       
   544 define TIMING_start
       
   545 $1=`$(DATE) +%j:%H:%M:%S`
       
   546 endef
       
   547 
       
   548 # Timing end (must be used in same shell, e.g. same command line)
       
   549 #    Expects shell variable $1 to have been defined as the start time.
       
   550 #    Expects shell variable $2 to have timing id string
       
   551 #    Sets total_seconds shell variable as the total seconds used.
       
   552 #    Sets time_used shell variable to contain format "%dh%dm%ds"
       
   553 define TIMING_end
       
   554 begTime="$${$1}"; \
       
   555 timing_id="$${$2}"; \
       
   556 endTime=`$(DATE) +%j:%H:%M:%S`; \
       
   557 d1=`$(ECHO) $${begTime} | $(CUT) -d':' -f1 | $(SED) -e 's@^0*@@'`; \
       
   558 if [ "$${d1}" = "" ] ; then d1=0; fi; \
       
   559 h1=`$(ECHO) $${begTime} | $(CUT) -d':' -f2 | $(SED) -e 's@^0*@@'`; \
       
   560 if [ "$${h1}" = "" ] ; then h1=0; fi; \
       
   561 m1=`$(ECHO) $${begTime} | $(CUT) -d':' -f3 | $(SED) -e 's@^0*@@'`; \
       
   562 if [ "$${m1}" = "" ] ; then m1=0; fi; \
       
   563 s1=`$(ECHO) $${begTime} | $(CUT) -d':' -f4 | $(SED) -e 's@^0*@@'`; \
       
   564 if [ "$${s1}" = "" ] ; then s1=0; fi; \
       
   565 d2=`$(ECHO) $${endTime} | $(CUT) -d':' -f1 | $(SED) -e 's@^0*@@'`; \
       
   566 if [ "$${d2}" = "" ] ; then d2=0; fi; \
       
   567 h2=`$(ECHO) $${endTime} | $(CUT) -d':' -f2 | $(SED) -e 's@^0*@@'`; \
       
   568 if [ "$${h2}" = "" ] ; then h2=0; fi; \
       
   569 m2=`$(ECHO) $${endTime} | $(CUT) -d':' -f3 | $(SED) -e 's@^0*@@'`; \
       
   570 if [ "$${m2}" = "" ] ; then m2=0; fi; \
       
   571 s2=`$(ECHO) $${endTime} | $(CUT) -d':' -f4 | $(SED) -e 's@^0*@@'`; \
       
   572 if [ "$${s2}" = "" ] ; then s2=0; fi; \
       
   573 t1_secs=`$(EXPR) $${d1} '*' 60 '*' 60 '*' 24 '+' $${h1} '*' 60 '*' 60 \
       
   574 		 '+' $${m1} '*' 60 '+' $${s1}`; \
       
   575 t2_secs=`$(EXPR) $${d2} '*' 60 '*' 60 '*' 24 '+' $${h2} '*' 60 '*' 60 \
       
   576 		 '+' $${m2} '*' 60 '+' $${s2}`; \
       
   577 total_seconds=`$(EXPR) $${t2_secs} '-' $${t1_secs}`; \
       
   578 if [ "$${total_seconds}" -lt 0 ] ; then total_seconds=0; fi; \
       
   579 t_hour=`$(EXPR) $${total_seconds} '/' '(' 60 '*' 60 ')'`h; \
       
   580 t_min=`$(EXPR) '(' $${total_seconds} '%' '(' 60 '*' 60 ')' ')' '/' 60`m; \
       
   581 t_sec=`$(EXPR) $${total_seconds} '%' 60`s; \
       
   582 time_used=$${t_sec}; \
       
   583 if [ "$${t_hour}" != "0h" ] ; then \
       
   584 time_used=$${t_hour}$${t_min}$${t_sec}; \
       
   585 elif [ "$${t_min}" != "0m" ] ; then \
       
   586 time_used=$${t_min}$${t_sec}; \
       
   587 else \
       
   588 time_used=$${t_sec}; \
       
   589 fi; \
       
   590 $(PRINTF) "  Timing: %05d seconds or %s for %s\n" \
       
   591     $${total_seconds} $${time_used} $${timing_id}
       
   592 endef
       
   593 
       
   594 endif # NO_TIMING
       
   595 
       
   596 # Given a SUBDIRS list, cd into them and make them
       
   597 #   SUBDIRS_MAKEFLAGS      Make settings for a subdir make
       
   598 #   SUBDIRS_MAKEFLAGS-$@   Make settings specific to this target
       
   599 define SUBDIRS-loop
       
   600 @$(ECHO) "Begin Processing SUBDIRS: $(SUBDIRS)"
       
   601 @for i in DUMMY $(SUBDIRS) ; do \
       
   602   if [ "$$i" != "DUMMY" ] ; then \
       
   603     $(ECHO) ">>>Recursively making "$$i" "$@" @ `$(DATE)` ..."; \
       
   604     timing_id="$(TIMING_ID)-`$(BASENAME) $${i}`"; \
       
   605     $(call TIMING_start,startTime); \
       
   606     curDir=$(CURRENT_DIRECTORY); \
       
   607     $(CD) $$i; $(MAKE) $@ TIMING_ID=$${timing_id} \
       
   608 			  $(SUBDIRS_MAKEFLAGS) \
       
   609 			  $(SUBDIRS_MAKEFLAGS-$@) \
       
   610 			  FULL_VERSION=$(FULL_VERSION) \
       
   611 			  RELEASE=$(RELEASE) || exit 1; \
       
   612 	       $(CD) $${curDir}; \
       
   613     $(call TIMING_end,startTime,timing_id); \
       
   614     $(ECHO) "<<<Finished Recursively making "$$i" "$@" @ `$(DATE)`." ; \
       
   615   fi ; \
       
   616 done
       
   617 @$(ECHO) "Done Processing SUBDIRS: $(SUBDIRS)"
       
   618 endef
       
   619 
       
   620 # Given a OTHERSUBDIRS list, cd into them and make them (extra loop define)
       
   621 #   OTHERSUBDIRS_MAKEFLAGS      Make settings for a subdir make
       
   622 define OTHERSUBDIRS-loop
       
   623 @$(ECHO) "Begin Processing OTHERSUBDIRS: $(OTHERSUBDIRS)"
       
   624 @for i in DUMMY $(OTHERSUBDIRS) ; do \
       
   625   if [ "$$i" != "DUMMY" ] ; then \
       
   626     $(ECHO) ">>>Recursively making "$$i" "$@" @ `$(DATE)` ..."; \
       
   627     timing_id="$(TIMING_ID)-`$(BASENAME) $${i}`"; \
       
   628     $(call TIMING_start,startTime); \
       
   629     curDir=$(CURRENT_DIRECTORY); \
       
   630     $(CD) $$i; $(MAKE) $@ TIMING_ID=$${timing_id} \
       
   631 		          $(OTHERSUBDIRS_MAKEFLAGS) \
       
   632 			  FULL_VERSION=$(FULL_VERSION) \
       
   633 			  RELEASE=$(RELEASE) || exit 1; \
       
   634 	       $(CD) $${curDir}; \
       
   635     $(call TIMING_end,startTime,timing_id); \
       
   636     $(ECHO) "<<<Finished Recursively making "$$i" "$@" @ `$(DATE)`." ; \
       
   637   fi ; \
       
   638 done
       
   639 @$(ECHO) "Done Processing OTHERSUBDIRS: $(OTHERSUBDIRS)"
       
   640 endef
       
   641 
       
   642 #
       
   643 # Create BYFILE OPT and DBG settings, if CFLAGS_OPT/foobar.o is set then it is
       
   644 #    used for this file, otherwise the default settings are used.
       
   645 #
       
   646 CFLAGS_$(VARIANT)/BYFILE    = $(CFLAGS_$(VARIANT)/$(@F)) \
       
   647                               $(CFLAGS_$(VARIANT)$(CFLAGS_$(VARIANT)/$(@F)))
       
   648 CXXFLAGS_$(VARIANT)/BYFILE  = $(CXXFLAGS_$(VARIANT)/$(@F)) \
       
   649                               $(CXXFLAGS_$(VARIANT)$(CXXFLAGS_$(VARIANT)/$(@F)))
       
   650 
       
   651 #
       
   652 # Tool flags
       
   653 #
       
   654 ASFLAGS         = $(ASFLAGS_$(VARIANT)) $(ASFLAGS_COMMON) $(OTHER_ASFLAGS)
       
   655 CFLAGS          = $(CFLAGS_$(VARIANT)/BYFILE)   $(CFLAGS_COMMON) $(OTHER_CFLAGS)
       
   656 CXXFLAGS        = $(CXXFLAGS_$(VARIANT)/BYFILE) $(CXXFLAGS_COMMON) $(OTHER_CXXFLAGS)
       
   657 CPPFLAGS        = $(CPPFLAGS_$(VARIANT)) $(CPPFLAGS_COMMON) $(OTHER_CPPFLAGS) \
       
   658 		  $(DEFINES) $(OPTIONS:%=-D%)
       
   659 LDFLAGS         = $(LDFLAGS_$(VARIANT)) $(LDFLAGS_COMMON) $(OTHER_LDFLAGS)
       
   660 LDLIBS          = $(OTHER_LDLIBS) $(LDLIBS_$(VARIANT)) $(LDLIBS_COMMON)
       
   661 LINTFLAGS       = $(LINTFLAGS_$(VARIANT)) $(LINTFLAGS_COMMON) \
       
   662 		  $(OTHER_LINTFLAGS)
       
   663 
       
   664 # this should be moved into Defs-<platform>.gmk.....
       
   665 ifeq ($(PLATFORM), windows)
       
   666   VERSION_DEFINES = -DRELEASE="\"$(RELEASE)\""
       
   667 else
       
   668   VERSION_DEFINES = -DRELEASE='"$(RELEASE)"'
       
   669 endif
       
   670 
       
   671 # Note: As a rule, GNU Make rules should not appear in any of the 
       
   672 # Defs*.gmk files. These were added for Kestrel-Solaris and do address
       
   673 # a TeamWare bug. They should be moved elsewhere for Merlin.
       
   674 # 
       
   675 #  Override gnumake built-in rules which do sccs get operations badly.
       
   676 #  (They put the checked out code in the current directory, not in the
       
   677 #  directory of the original file.) 
       
   678 # Since this is a symptom of a teamware failure, complain and die on the spot.
       
   679 
       
   680 # This message immediately goes to stdout and the build terminates.
       
   681 define SCCS-trouble
       
   682 $(error  \
       
   683 "ERROR: File $@ referenced while building in $(CURRENT_DIRECTORY) \
       
   684  is out of date with respect to its SCCS file $<. \
       
   685  This can happen from an unresolved Teamware conflict, a file movement, or \
       
   686  a failure in which SCCS files are updated but the 'sccs get' was not done. \
       
   687  You should double check for other out of date files in your workspace. \
       
   688  Or run: cd $(TOPDIR) && $(MAKE) sccs_get")
       
   689 endef
       
   690 
       
   691 %:: s.%
       
   692 	@$(SCCS-trouble)
       
   693 %:: SCCS/s.%
       
   694 	@$(SCCS-trouble)
       
   695 	@$(ECHO) "         is out of date with respect to its SCCS file." >> $(WARNING_FILE)
       
   696 	@$(ECHO) "         This file may be from an unresolved Teamware conflict." >> $(WARNING_FILE)
       
   697 	@$(ECHO) "         This is also a symptom of a Teamware bringover/putback failure" >> $(WARNING_FILE)
       
   698 	@$(ECHO) "         in which SCCS files are updated but not checked out." >> $(WARNING_FILE)
       
   699 	@$(ECHO) "         Check for other out of date files in your workspace." >> $(WARNING_FILE)
       
   700 	@$(ECHO) "" >> $(WARNING_FILE)
       
   701 	@#exit 666
       
   702 
       
   703 ifdef INSANE
       
   704   export INSANE
       
   705 endif
       
   706 
       
   707 ifdef ALT_COPYRIGHT_YEAR
       
   708   COPYRIGHT_YEAR = $(ALT_COPYRIGHT_YEAR)
       
   709 else
       
   710   COPYRIGHT_YEAR = $(shell $(DATE) '+%Y')
       
   711 endif
       
   712 
       
   713 # Install of imported file (JDK_IMPORT_PATH, or some other external location)
       
   714 define install-import-file
       
   715 @$(ECHO) "ASSEMBLY_IMPORT: $@"
       
   716 $(install-file)
       
   717 endef
       
   718 
       
   719 .PHONY: all build clean clobber