Defs.gmk 22.0 KB
Newer Older
D
duke 已提交
1
#
X
xdono 已提交
2
# Copyright 1995-2008 Sun Microsystems, Inc.  All Rights Reserved.
D
duke 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
# 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.
#

#
# Common variables used by all the Java makefiles.  This file should
# not contain rules.
#

# WARNING: This file is shared with other workspaces.
#          So when it includes other files, it must use JDK_TOPDIR.
#

35 36 37 38 39 40 41
# Check for strange explicit settings (change to empty or true)
ifdef OPENJDK
  ifneq ($(OPENJDK),true)
    x:=$(error "OPENJDK (if defined) can only be set to true")
  endif
endif

D
duke 已提交
42 43 44 45 46 47 48 49 50
#
# On Solaris, the 'make' utility from Sun will not work with these makefiles.
#    This little rule is only understood by Sun's make, and is harmless
#    when seen by the GNU make tool. If using Sun's make, this causes the
#    make command to fail.
#
SUN_MAKE_TEST:sh = echo "ERROR: PLEASE USE GNU VERSION OF MAKE"; exit 33

ifndef JDK_TOPDIR
51 52 53 54 55 56 57 58 59
  ifdef BUILDDIR
    JDK_TOPDIR=$(BUILDDIR)/..
  else
    JDK_TOPDIR:=$(error "ERROR: Cannot define top of jdk repository")
  endif
endif
ifndef BUILDDIR
  # Hack, due to deploy repository using this file.
  BUILDDIR=$(JDK_TOPDIR)/make
D
duke 已提交
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
endif
ifndef JDK_MAKE_SHARED_DIR
  JDK_MAKE_SHARED_DIR=$(JDK_TOPDIR)/make/common/shared
endif

include $(JDK_MAKE_SHARED_DIR)/Platform.gmk

TOPDIR=$(BUILDDIR)/..

include $(JDK_TOPDIR)/make/common/CancelImplicits.gmk

# Historically PLATFORM_SRC used to be src/$(PLATFORM), but we switched it to
# src/solaris so if you want to build on Linux you didn't need a src/linux
# directory.  In an ideal world it would be called src/genunix but we are not
# there yet.
#
ifndef SHARE_SRC
77
  SHARE_SRC    = $(BUILDDIR)/../src/share
D
duke 已提交
78 79 80 81 82
endif

# Files that cannot be included in the OpenJDK distribution are
# collected under a parent directory which contains just those files.
ifndef CLOSED_SRC
83
  CLOSED_SRC  = $(BUILDDIR)/../src/closed
D
duke 已提交
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
endif

# If we have no closed directory, force it to an openjdk build
CLOSED_SRC_DIR_EXISTS := $(shell \
  if [ -d $(CLOSED_SRC) ] ; then \
    echo true; \
  else \
    echo false; \
  fi)
ifeq ($(CLOSED_SRC_DIR_EXISTS), false)
  OPENJDK = true
endif

# Define where closed directories are
ifdef OPENJDK
  CLOSED_SRC =
  CLOSED_SHARE_SRC =
else
  ifndef CLOSED_SHARE_SRC
    CLOSED_SHARE_SRC    = $(CLOSED_SRC)/share
  endif
endif

# If OPENJDK is defined, we may still need to use some native libraries that
# exist only as part of the closed source. If the closed sources are not
# available, the libraries must have been pre-built. Since these libraries
# and the JDK internal interfaces to these are reasonably stable this is not
# a significant problem. But we do need to provide a way to locate them,
# including a way to point to a new one when there have been changes.
#
# If you have a formal binary plugs download, set ALT_BINARY_PLUGS_PATH
# to the location.
# (Optionally you can set ALT_CLOSED_JDK_IMPORT_PATH to point to the latest
#  build JDK, or last promotion for this JDK version, but will not work
#  on windows).
#
# As the OPENJDK is built, the binary plugs are used instead of building the
# libraries.
# Individual Makefiles that specify USE_BINARY_PLUG_LIBRARY, will get
# the binary plug copy (or a copy from a built JDK).
#
# See common/internal/BinaryPlugs.gmk for more information.
#
# Usage notes:
#
#   ALT_BINARY_PLUGS_JARFILE is probably rarely needed. It can be used
#   to identify the exact jar file to be used for all closed classes..
#  
#   ALT_BINARY_PLUGS_PATH points to a directory containing precisely the
#   binaries needed to build. 
#  
#   ALT_BUILD_BINARY_PLUGS_PATH points to a directory containing binary plug dirs 
#   multiple architectures named using the standard conventions
#   This is useful for build scripts that need to build multiple architectures
#   of the OpenJDK.
#   
#   ALT_CLOSED_JDK_IMPORT_PATH points to the top-level of a specific platform
#   JDK image.
#  
#   The precedence is that
#     1. ALT_BINARY_PLUGS_JARFILE overrides any other location of the classes
#     2. ALT_BINARY_PLUGS_PATH overrides all locations of classes and libraries
#     3. ALT_BUILD_BINARY_PLUGS_PATH is used to find a ALT_BINARY_PLUGS_PATH
#     4. ALT_CLOSED_JDK_IMPORT_PATH is used to locate classes and libraries
148 149 150 151 152
#   Note: If any of the ALT_ variables are modified here, it is assumed
#         that the build should be done with IMPORT_BINARY_PLUGS=true as
#         well.  Otherwise the default will be IMPORT_BINARY_PLUGS=false.
#         Lastly, setting IMPORT_BINARY_PLUGS=false on the command line
#         will override this logic, and plugs will not be imported.
D
duke 已提交
153 154 155 156 157 158 159 160 161 162
#

# Always needed, defines the name of the imported/exported jarfile
BINARY_PLUGS_JARNAME = rt-closed.jar

ifdef OPENJDK
  ifdef ALT_CLOSED_JDK_IMPORT_PATH
    CLOSED_JDK_IMPORT_PATH = $(ALT_CLOSED_JDK_IMPORT_PATH)
    BINARY_PLUGS_PATH = $(CLOSED_JDK_IMPORT_PATH)
    BINARY_PLUGS_JARFILE = $(CLOSED_JDK_IMPORT_PATH)/jre/lib/rt.jar
163
    IMPORT_BINARY_PLUGS=true
D
duke 已提交
164 165 166
  endif
  ifdef ALT_BUILD_BINARY_PLUGS_PATH
    BUILD_BINARY_PLUGS_PATH = $(ALT_BUILD_BINARY_PLUGS_PATH)
167
    IMPORT_BINARY_PLUGS=true
D
duke 已提交
168 169 170 171 172 173 174 175
  else
    BUILD_BINARY_PLUGS_PATH = $(SLASH_JAVA)/re/jdk/$(JDK_VERSION)/promoted/latest/openjdk/binaryplugs
  endif
  BINARY_PLUGS_PATH = $(BUILD_BINARY_PLUGS_PATH)/$(PLATFORM)-$(ARCH)
  BINARY_PLUGS_JARFILE = $(BINARY_PLUGS_PATH)/jre/lib/$(BINARY_PLUGS_JARNAME)
  ifdef ALT_BINARY_PLUGS_PATH
    BINARY_PLUGS_PATH  = $(ALT_BINARY_PLUGS_PATH)
    BINARY_PLUGS_JARFILE = $(BINARY_PLUGS_PATH)/jre/lib/$(BINARY_PLUGS_JARNAME)
176
    IMPORT_BINARY_PLUGS=true
D
duke 已提交
177 178 179
  endif
  ifdef ALT_BINARY_PLUGS_JARFILE
    BINARY_PLUGS_JARFILE = $(ALT_BINARY_PLUGS_JARFILE)
180
    IMPORT_BINARY_PLUGS=true
D
duke 已提交
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
  endif
endif # OPENJDK

#
# Get platform definitions
#

include $(JDK_TOPDIR)/make/common/Defs-$(PLATFORM).gmk

#
# Freetype logic is applicable to OpenJDK only
#
ifdef OPENJDK

#if we use system lib we do not need to copy it to build tree
USING_SYSTEM_FT_LIB=false

ifeq ($(PLATFORM), windows)
  DEVTOOLS_FT_DIR=$(JDK_DEVTOOLS_DIR)/win32/freetype-$(ARCH)
endif
ifeq ($(PLATFORM), linux)
  DEVTOOLS_FT_DIR=$(JDK_DEVTOOLS_DIR)/$(PLATFORM)/freetype-$(ARCH)
endif
ifeq ($(PLATFORM), solaris)
  # historically for Solaris we have slightly different devtools 
  # naming conventions
  DEVTOOLS_FT_DIR=$(JDK_DEVTOOLS_DIR)/$(ARCH_FAMILY)/freetype-$(ARCH)
endif

DEVTOOLS_FT_DIR_EXISTS = $(shell \
  if [ -f $(DEVTOOLS_FT_DIR)/include/ft2build.h ] ; then \
    echo true; \
  else \
    echo false; \
  fi)

  ifdef ALT_FREETYPE_LIB_PATH
    FREETYPE_LIB_PATH = $(ALT_FREETYPE_LIB_PATH)
  else
    ifeq ($(DEVTOOLS_FT_DIR_EXISTS), true)
      FREETYPE_LIB_PATH = $(DEVTOOLS_FT_DIR)/lib
    else
      FREETYPE_LIB_PATH = /usr/lib
      USING_SYSTEM_FT_LIB=true
    endif
  endif 

  ifdef ALT_FREETYPE_HEADERS_PATH
    FREETYPE_HEADERS_PATH = $(ALT_FREETYPE_HEADERS_PATH)
  else
    ifeq ($(DEVTOOLS_FT_DIR_EXISTS), true)
      FREETYPE_HEADERS_PATH = $(DEVTOOLS_FT_DIR)/include
    else
      FREETYPE_HEADERS_PATH = /usr/include
    endif
  endif
endif

239 240 241 242 243 244
#
# zlib version
#
ZLIB_VERSION = 1.2.3


D
duke 已提交
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
#
# Localizations for the different parts of the product beyond English
#

JRE_LOCALES   = de es fr it ja ko sv zh_CN zh_TW zh_HK
PLUGIN_LOCALES = de es fr it ja ko sv zh_CN zh_TW zh_HK
JDK_LOCALES  = ja zh_CN

#
# A list of locales we support but don't have resource files.
# This is defined to optimize the search of resource bundles.
#
JRE_NONEXIST_LOCALES = en en_US de_DE es_ES fr_FR it_IT ja_JP ko_KR sv_SE zh

#
# All libraries except libjava and libjvm itself link against libjvm and
# libjava, the latter for its exported common utilities.  libjava only links
# against libjvm.  Programs' makefiles take their own responsibility for
# adding other libs.
#
ifdef PACKAGE
# put JAVALIB first, but do not lose any platform specific values....
  LDLIBS_COMMON = $(JAVALIB)
endif # PACKAGE

#
# Libraries that must appear ahead of libc.so on the link command line
#
ifdef PROGRAM

  ifeq ($(PLATFORM), solaris)
    LDLIBS_COMMON = -lthread -ldl
  endif

  ifeq ($(PLATFORM), linux)
    LDLIBS_COMMON = -ldl
  endif

endif # PROGRAM

LDLIBS_COMMON += $(EXTRA_LIBS)

#
# Default is to build, not import native binaries
#
ifndef IMPORT_NATIVE_BINARIES
  IMPORT_NATIVE_BINARIES=false
endif
# If importing libraries in, no incremental builds
ifeq ($(IMPORT_NATIVE_BINARIES),true)
 INCREMENTAL_BUILD=false
endif

# for generated libraries
LIBDIR              = $(OUTPUTDIR)/lib
ABS_LIBDIR          = $(ABS_OUTPUTDIR)/lib
# Optional place to save the windows .lib files
LIBFILES_DIR        = $(OUTPUTDIR)/libfiles
# for ext jre files
EXTDIR              = $(LIBDIR)/ext
# for generated include files
INCLUDEDIR          = $(OUTPUTDIR)/include
# for generated class files
CLASSBINDIR         = $(OUTPUTDIR)/classes
DEMOCLASSDIR        = $(OUTPUTDIR)/democlasses
310 311 312
# for modules
MODULES_DIR         = $(OUTPUTDIR)/modules
ABS_MODULES_DIR     = $(ABS_OUTPUTDIR)/modules
D
duke 已提交
313 314 315 316 317
# for generated tool class files
BUILDTOOLCLASSDIR   = $(OUTPUTDIR)/btclasses
# for build tool jar files
BUILDTOOLJARDIR     = $(OUTPUTDIR)/btjars
ABS_BUILDTOOLJARDIR = $(ABS_OUTPUTDIR)/btjars
318 319
# for generated tool class files
BUILDTOOLBINDIR     = $(OUTPUTDIR)/btbins
D
duke 已提交
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
# for generated java source files
GENSRCDIR           = $(OUTPUTDIR)/gensrc
# for generated C source files (not javah)
GENNATIVESRCDIR     = $(OUTPUTDIR)/gennativesrc
# for imported source files
IMPORTSRCDIR        = $(OUTPUTDIR)/impsrc
# for imported documents
IMPORTDOCDIR        = $(OUTPUTDIR)/impdoc
# for generated demo
DEMODIR             = $(OUTPUTDIR)/demo
# for sample code
SAMPLEDIR           = $(OUTPUTDIR)/sample
# for generated documentation
DOCSDIR             = $(OUTPUTDIR)/docs$(DOCSDIRSUFFIX)
DOCSDIRSUFFIX       =

# The MESSAGE, WARNING and ERROR files are used to store sanityck and 
# SCCS check messages, warnings and errors. 
ifndef ERROR_FILE
  ERROR_FILE   = $(OUTPUTDIR)/sanityCheckErrors.txt
endif
ifndef WARNING_FILE
  WARNING_FILE = $(OUTPUTDIR)/sanityCheckWarnings.txt
endif
ifndef MESSAGE_FILE
  MESSAGE_FILE = $(OUTPUTDIR)/sanityCheckMessages.txt
endif

JDK_IMAGE_DIR = $(ABS_OUTPUTDIR)/j2sdk-image
JRE_IMAGE_DIR = $(ABS_OUTPUTDIR)/j2re-image

#where the demo source can be found
DEMOSRCDIR          = $(SHARE_SRC)/demo

# An attempt is made to generate unique enough directories for the
# generated files to not have name collisisons. Most build units
# defines PRODUCT (except Release.gmk), but then they may or may 
# not define PACKAGE, THREADIR (only HPI uses this), PROGRAM, and 
# LIBRARY. This code chunk attempts to generate a unique 
# OBJDIR/CLASSHDRDIR for each build unit based on which of those 
# values are set within each build unit.

UNIQUE_LOCATION_STRING = tmp

ifneq ($(PRODUCT),)
  UNIQUE_LOCATION_STRING += /$(PRODUCT)
endif

ifneq ($(PACKAGE),)
  UNIQUE_LOCATION_STRING += /$(PACKAGE)
endif

ifneq ($(PROGRAM),)
  UNIQUE_LOCATION_STRING += /$(PROGRAM)
endif

ifneq ($(LIBRARY),)
  ifneq ($(LIBRARY_OUTPUT),)
    UNIQUE_LOCATION_STRING += /$(LIBRARY_OUTPUT)
  else
    UNIQUE_LOCATION_STRING += /$(LIBRARY)
  endif
endif

ifneq ($(THREADDIR),)
  UNIQUE_LOCATION_STRING += /$(THREADDIR)
endif

388 389 390
#
# Build units may or may not define MODULE.  Default to "other".
#
391 392 393 394 395 396 397 398
# MODULE variable defines the lowest-level module name that
# might or might not be the name of the modules created in
# the modules build (see make/modules/modules.config and
# modules.group).
#
MODULES_TEMPDIR     = $(OUTPUTDIR)/tmp/modules
ABS_MODULES_TEMPDIR = $(ABS_OUTPUTDIR)/tmp/modules

399 400 401
ifndef MODULE
  MODULE = other
endif
402
override MODULE_DEST_DIR = $(MODULES_TEMPDIR)/$(MODULE)
403

D
duke 已提交
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481
# the use of += above makes a space separated list which we need to 
# remove for filespecs.
#
NULLSTRING :=
ONESPACE := $(NULLSTRING) # space before this comment is required.
UNIQUE_PATH = $(subst $(ONESPACE),,$(UNIQUE_LOCATION_STRING))

# TEMPDIR is a unique general purpose directory
# need to use 'override' because GNU Make on Linux exports the wrong
# value.
override TEMPDIR      = $(OUTPUTDIR)/$(UNIQUE_PATH)
override ABS_TEMPDIR  = $(ABS_OUTPUTDIR)/$(UNIQUE_PATH)

# This must be created right away for pattern rules in Sanity.gmk to work.
dummy1:=$(shell $(MKDIR) -p $(TEMPDIR))
dummy2:=$(shell $(MKDIR) -p $(TEMP_DISK))

# OBJDIRNAME is the name of the directory where the object code is to
#   be placed. It's name depends on whether the data model architecture 
#   is 32-bit or not.
ifneq ($(ARCH_DATA_MODEL), 32)
  OBJDIRNAME  = obj$(ARCH_DATA_MODEL)$(OBJDIRNAME_SUFFIX)
else
  OBJDIRNAME  = obj$(OBJDIRNAME_SUFFIX)
endif
OBJDIR      = $(TEMPDIR)/$(OBJDIRNAME)

# CLASSHDRDIR is where the generated C Class Header files go.
CLASSHDRDIR = $(TEMPDIR)/CClassHeaders

#
# CLASSDESTDIR can be used to specify the directory where generated classes
# are to be placed. The default is CLASSBINDIR.
#
ifndef CLASSDESTDIR
CLASSDESTDIR = $(CLASSBINDIR)
endif

INCLUDES = -I. -I$(CLASSHDRDIR) \
	$(patsubst %,-I%,$(subst $(CLASSPATH_SEPARATOR), ,$(VPATH.h))) $(OTHER_INCLUDES)
OTHER_CPPFLAGS = $(INCLUDES)


#
# vpaths.  These are the default locations searched for source files.
# GNUmakefiles of individual areas often override the default settings.
# There are no longer default vpath entries for C and assembler files
# so we can ensure that libraries don't get their hands on JVM files.
#
# We define an intermediate variable for Java files because
# we use its value later to help define $SOURCEPATH

VPATH0.java = $(GENSRCDIR)$(CLASSPATH_SEPARATOR)$(PLATFORM_SRC)/classes$(CLASSPATH_SEPARATOR)$(SHARE_SRC)/classes
ifdef OPENJDK
  VPATH.java = $(VPATH0.java)
else
  #
  # If filenames are duplicated between open/closed workspaces, prefer
  # the closed files.
  #
  # Source ordering is important: some targets depend on closed files
  # replacing open ones, and thus the closed file sources must be found
  # before the open ones.
  #
  # Don't reorder without consulting the teams that depend on this behavior.
  #
  VPATH.java = $(CLOSED_PLATFORM_SRC)/classes$(CLASSPATH_SEPARATOR)$(CLOSED_SHARE_SRC)/classes$(CLASSPATH_SEPARATOR)$(VPATH0.java)
endif
vpath %.java $(VPATH.java)
vpath %.class $(CLASSBINDIR)
vpath %.$(OBJECT_SUFFIX) $(OBJDIR)

#
# VPATH.h is used elsewhere to generate include flags.  By default, 
# anyone has access to the include files that the JVM area exports,
# namely jni.h, jvm.h, and jni_utils.h, plus their platform-specific
# relatives.
#
482
VPATH.h =   $(PLATFORM_SRC)/javavm/export$(CLASSPATH_SEPARATOR)$(SHARE_SRC)/javavm/export
D
duke 已提交
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512
vpath %.h   $(VPATH.h)

#
# Used in two ways: helps link against libjava.so. Also if overridden
# determines where your shared library is installed.
#
ifndef LIB_LOCATION
  LIB_LOCATION    =  $(LIBDIR)/$(LIBARCH)
endif

#
# Java header and stub variables
#
CLASSHDRS     = $(patsubst %,$(CLASSHDRDIR)/%.h,$(subst .,_,$(CLASSES.export)))
CLASSSTUBOBJS = classstubs.$(OBJECT_SUFFIX)
STUBPREAMBLE  = $(INCLUDEDIR)/StubPreamble.h

#
# Classpath seen by javac (different from the one seen by the VM
# running javac), and useful variables.
#
SOURCEPATH	= $(VPATH.java)
PKG		= $(shell $(EXPR) $(PACKAGE) : '\([a-z]*\)')
PKGDIR		= $(subst .,/,$(PACKAGE))

#
# The java/javac/jdk variables (JAVAC_CMD, JAVA_CMD, etc.)
#
include $(JDK_MAKE_SHARED_DIR)/Defs-java.gmk

513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529
#
# Macros to find the module that $@ belongs to
#

UNIQUE_PATH_PATTERN = $(subst /,.,$(UNIQUE_PATH))
MODULE_PATH_PATTERN = -e 's%.*\/classes\/%classes\/%' \
		      -e 's%.*\/$(UNIQUE_PATH_PATTERN)\/%classes\/%' \
		      -e 's%.*\/lib\/%lib\/%' \
	              -e 's%.*\/bin\/%bin\/%' \
	              -e 's%.*\/include\/%include\/%' \
		      -e 's%.*\/demo\/%demo\/%' \
		      -e 's%.*\/sample\/%sample\/%'

# Install a file to its module
define install-module-file
dest=`echo $(@D)/ | $(SED) $(MODULE_PATH_PATTERN)` ; \
$(MKDIR) -p $(MODULE_DEST_DIR)/$$dest; \
530
$(CP) -f $@ $(MODULE_DEST_DIR)/$$dest
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
endef

# Install all files from the directory to its module
define install-module-dir
dest=`echo $(@D)/ | $(SED) $(MODULE_PATH_PATTERN)` ; \
$(MKDIR) -p $(MODULE_DEST_DIR)/$$dest; \
$(CP) -rf $(@D)/* $(MODULE_DEST_DIR)/$$dest
endef

# chmod the file in its module
define chmod-module-file
dest=`echo $@ | $(SED) $(MODULE_PATH_PATTERN)` ; \
$(CHMOD) $1 $(MODULE_DEST_DIR)/$$dest
endef

# install a sym link in its module
define install-module-sym-link
dest=`echo $@ | $(SED) $(MODULE_PATH_PATTERN)` ; \
549
$(LN) -sf $1 $(MODULE_DEST_DIR)/$$dest
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564
endef


# Run MAKE $@ for a launcher:
#   $(call make-launcher, name, mainclass, java-args, main-args)
define make-launcher
$(CD) $(BUILDDIR)/launchers && \
$(MAKE) -f Makefile.launcher \
        MODULE=$(MODULE) \
        PROGRAM=$(strip $1) \
        MAIN_CLASS=$(strip $2) \
        MAIN_JAVA_ARGS="$(strip $3)" \
        MAIN_ARGS="$(strip $4)"
endef

D
duke 已提交
565 566 567 568 569 570 571 572 573 574 575 576 577 578
#
# Convenient macros
#

# Prepare $@ target, remove old one and making sure directory exists
define prep-target
$(MKDIR) -p $(@D)
$(RM) $@
endef

# Simple install of $< file to $@
define install-file
$(prep-target)
$(CP) $< $@
579
@$(install-module-file)
580 581 582 583
endef

define chmod-file
$(CHMOD) $1 $@
584
@$(call chmod-module-file, $1)
585 586 587 588
endef

define install-sym-link
$(LN) -s $1 $@
589
@$(call install-module-sym-link, $1)
590 591 592 593 594 595 596 597 598 599 600
endef

#
# Marcos for files not belonging to any module 
define install-non-module-file
$(prep-target)
$(CP) $< $@
endef

define install-manifest-file
$(install-non-module-file)
D
duke 已提交
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634
endef

# Cleanup rule for after debug java run (hotspot.log file is left around)
#   (This could be an old leftover file in a read-only area, use the @- prefix)
HOTSPOT_LOG_NAME = hotspot.log
define java-vm-cleanup
if [ -w $(HOTSPOT_LOG_NAME) ] ; then $(RM) $(HOTSPOT_LOG_NAME); fi
endef

# Current directory
CURRENT_DIRECTORY := $(shell $(PWD))

#
# Create BYFILE OPT and DBG settings, if CFLAGS_OPT/foobar.o is set then it is
#    used for this file, otherwise the default settings are used.
#
CFLAGS_$(VARIANT)/BYFILE    = $(CFLAGS_$(VARIANT)/$(@F)) \
                              $(CFLAGS_$(VARIANT)$(CFLAGS_$(VARIANT)/$(@F)))
CXXFLAGS_$(VARIANT)/BYFILE  = $(CXXFLAGS_$(VARIANT)/$(@F)) \
                              $(CXXFLAGS_$(VARIANT)$(CXXFLAGS_$(VARIANT)/$(@F)))

#
# Tool flags
#
ASFLAGS         = $(ASFLAGS_$(VARIANT)) $(ASFLAGS_COMMON) $(OTHER_ASFLAGS)
CFLAGS          = $(CFLAGS_$(VARIANT)/BYFILE)   $(CFLAGS_COMMON) $(OTHER_CFLAGS)
CXXFLAGS        = $(CXXFLAGS_$(VARIANT)/BYFILE) $(CXXFLAGS_COMMON) $(OTHER_CXXFLAGS)
CPPFLAGS        = $(CPPFLAGS_$(VARIANT)) $(CPPFLAGS_COMMON) $(OTHER_CPPFLAGS) \
		  $(DEFINES) $(OPTIONS:%=-D%)
LDFLAGS         = $(LDFLAGS_$(VARIANT)) $(LDFLAGS_COMMON) $(OTHER_LDFLAGS)
LDLIBS          = $(OTHER_LDLIBS) $(LDLIBS_$(VARIANT)) $(LDLIBS_COMMON)
LINTFLAGS       = $(LINTFLAGS_$(VARIANT)) $(LINTFLAGS_COMMON) \
		  $(OTHER_LINTFLAGS)

635
VERSION_DEFINES = -DRELEASE='"$(RELEASE)"'
D
duke 已提交
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675

# Note: As a rule, GNU Make rules should not appear in any of the 
# Defs*.gmk files. These were added for Kestrel-Solaris and do address
# a TeamWare bug. They should be moved elsewhere for Merlin.
# 
#  Override gnumake built-in rules which do sccs get operations badly.
#  (They put the checked out code in the current directory, not in the
#  directory of the original file.) 
# Since this is a symptom of a teamware failure, complain and die on the spot.

# This message immediately goes to stdout and the build terminates.
define SCCS-trouble
$(error  \
"ERROR: File $@ referenced while building in $(CURRENT_DIRECTORY) \
 is out of date with respect to its SCCS file $<. \
 This can happen from an unresolved Teamware conflict, a file movement, or \
 a failure in which SCCS files are updated but the 'sccs get' was not done. \
 You should double check for other out of date files in your workspace. \
 Or run: cd $(TOPDIR) && $(MAKE) sccs_get")
endef

%:: s.%
	@$(SCCS-trouble)
%:: SCCS/s.%
	@$(SCCS-trouble)
	@$(ECHO) "         is out of date with respect to its SCCS file." >> $(WARNING_FILE)
	@$(ECHO) "         This file may be from an unresolved Teamware conflict." >> $(WARNING_FILE)
	@$(ECHO) "         This is also a symptom of a Teamware bringover/putback failure" >> $(WARNING_FILE)
	@$(ECHO) "         in which SCCS files are updated but not checked out." >> $(WARNING_FILE)
	@$(ECHO) "         Check for other out of date files in your workspace." >> $(WARNING_FILE)
	@$(ECHO) "" >> $(WARNING_FILE)
	@#exit 666

ifdef INSANE
  export INSANE
endif

ifdef ALT_COPYRIGHT_YEAR
  COPYRIGHT_YEAR = $(ALT_COPYRIGHT_YEAR)
else
676
  COPYRIGHT_YEAR := $(shell $(DATE) '+%Y')
D
duke 已提交
677 678 679
endif

# Install of imported file (JDK_IMPORT_PATH, or some other external location)
680
define install-importonly-file
D
duke 已提交
681
@$(ECHO) "ASSEMBLY_IMPORT: $@"
682 683 684 685 686 687 688 689 690 691 692 693 694 695
$(prep-target)
$(CP) $< $@
@if [ "$(PLATFORM)" = "linux" -a "$(@F)" = "libjvm.so" ] ; then     \
  if [ -x /usr/sbin/selinuxenabled ] ; then                         \
    /usr/sbin/selinuxenabled;                                       \
    if [ $$? = 0 ] ; then                                           \
      $(ECHO) "/usr/bin/chcon -t textrel_shlib_t $@";               \
      /usr/bin/chcon -t textrel_shlib_t $@;                         \
      if [ $$? != 0 ]; then                                         \
        echo "ERROR: Cannot chcon $@";                              \
      fi;                                                           \
    fi;                                                             \
  fi;                                                               \
fi
D
duke 已提交
696 697
endef

698 699
define install-import-file
$(install-importonly-file)
700
@$(install-module-file)
701 702
endef

D
duke 已提交
703
.PHONY: all build clean clobber