annotate make/common/Defs.gmk @ 9:48d06b4c6460

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