make/common/Defs.gmk

Wed, 02 Sep 2009 09:20:17 -0700

author
ohair
date
Wed, 02 Sep 2009 09:20:17 -0700
changeset 114
1c130e7b7a2e
parent 1
55540e827aef
child 158
91006f157c46
permissions
-rw-r--r--

6875240: Reduce Makefile build time by limiting repeated exec's (mostly for cygwin building)
Reviewed-by: jjg, iris

duke@1 1 #
ohair@114 2 # Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved.
duke@1 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 #
duke@1 5 # This code is free software; you can redistribute it and/or modify it
duke@1 6 # under the terms of the GNU General Public License version 2 only, as
duke@1 7 # published by the Free Software Foundation. Sun designates this
duke@1 8 # particular file as subject to the "Classpath" exception as provided
duke@1 9 # by Sun in the LICENSE file that accompanied this code.
duke@1 10 #
duke@1 11 # This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 # version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 # accompanied this code).
duke@1 16 #
duke@1 17 # You should have received a copy of the GNU General Public License version
duke@1 18 # 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 #
duke@1 21 # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@1 22 # CA 95054 USA or visit www.sun.com if you need additional information or
duke@1 23 # have any questions.
duke@1 24 #
duke@1 25
duke@1 26 #
duke@1 27 # Common variables used by all the Java makefiles. This file should
duke@1 28 # not contain rules.
duke@1 29 #
duke@1 30
duke@1 31 #
duke@1 32 # On Solaris, the 'make' utility from Sun will not work with these makefiles.
duke@1 33 # This little rule is only understood by Sun's make, and is harmless
duke@1 34 # when seen by the GNU make tool. If using Sun's make, this causes the
duke@1 35 # make command to fail.
duke@1 36 #
duke@1 37 SUN_MAKE_TEST:sh = echo "ERROR: PLEASE USE GNU VERSION OF MAKE"; exit 33
duke@1 38
duke@1 39 include $(BUILDDIR)/common/shared/Platform.gmk
duke@1 40
duke@1 41 TOPDIR=$(BUILDDIR)/..
duke@1 42
duke@1 43 include $(TOPDIR)/make/common/CancelImplicits.gmk
duke@1 44
duke@1 45 # Historically PLATFORM_SRC used to be src/$(PLATFORM), but we switched it to
duke@1 46 # src/solaris so if you want to build on Linux you didn't need a src/linux
duke@1 47 # directory. In an ideal world it would be called src/genunix but we are not
duke@1 48 # there yet.
duke@1 49 #
duke@1 50 ifndef SHARE_SRC
duke@1 51 SHARE_SRC = $(TOPDIR)/src/share
duke@1 52 endif
duke@1 53
duke@1 54 _OUTPUTDIR=$(TOPDIR)/build/$(PLATFORM)-$(ARCH)
duke@1 55
duke@1 56 #
duke@1 57 # Get platform definitions
duke@1 58 #
duke@1 59
duke@1 60 include $(TOPDIR)/make/common/Defs-$(PLATFORM).gmk
duke@1 61
duke@1 62 #
duke@1 63 # Localizations for the different parts of the product beyond English
duke@1 64 #
duke@1 65
duke@1 66 JRE_LOCALES = de es fr it ja ko sv zh_CN zh_TW zh_HK
duke@1 67 PLUGIN_LOCALES = de es fr it ja ko sv zh_CN zh_TW zh_HK
duke@1 68 JDK_LOCALES = ja zh_CN
duke@1 69
duke@1 70 #
duke@1 71 # A list of locales we support but don't have resource files.
duke@1 72 # This is defined to optimize the search of resource bundles.
duke@1 73 #
duke@1 74 JRE_NONEXIST_LOCALES = en en_US de_DE es_ES fr_FR it_IT ja_JP ko_KR sv_SE zh
duke@1 75
duke@1 76 #
duke@1 77 # All libraries except libjava and libjvm itself link against libjvm and
duke@1 78 # libjava, the latter for its exported common utilities. libjava only links
duke@1 79 # against libjvm. Programs' makefiles take their own responsibility for
duke@1 80 # adding other libs.
duke@1 81 #
duke@1 82 ifdef PACKAGE
duke@1 83 # put JAVALIB first, but do not lose any platform specific values....
duke@1 84 LDLIBS_COMMON = $(JAVALIB)
duke@1 85 endif # PACKAGE
duke@1 86
duke@1 87 #
duke@1 88 # Libraries that must appear ahead of libc.so on the link command line
duke@1 89 #
duke@1 90 ifdef PROGRAM
duke@1 91
duke@1 92 ifeq ($(PLATFORM), solaris)
duke@1 93 LDLIBS_COMMON = -lthread -ldl
duke@1 94 endif
duke@1 95
duke@1 96 ifeq ($(PLATFORM), linux)
duke@1 97 LDLIBS_COMMON = -ldl
duke@1 98 endif
duke@1 99
duke@1 100 endif # PROGRAM
duke@1 101
duke@1 102 LDLIBS_COMMON += $(EXTRA_LIBS)
duke@1 103
duke@1 104 #
duke@1 105 # Default is to build, not import native binaries
duke@1 106 #
duke@1 107 ifndef IMPORT_NATIVE_BINARIES
duke@1 108 IMPORT_NATIVE_BINARIES=false
duke@1 109 endif
duke@1 110 # If importing libraries in, no incremental builds
duke@1 111 ifeq ($(IMPORT_NATIVE_BINARIES),true)
duke@1 112 INCREMENTAL_BUILD=false
duke@1 113 endif
duke@1 114
duke@1 115 # for generated libraries
duke@1 116 LIBDIR = $(OUTPUTDIR)/lib
duke@1 117 ABS_LIBDIR = $(ABS_OUTPUTDIR)/lib
duke@1 118 # Optional place to save the windows .lib files
duke@1 119 LIBFILES_DIR = $(OUTPUTDIR)/libfiles
duke@1 120 # for ext jre files
duke@1 121 EXTDIR = $(LIBDIR)/ext
duke@1 122 # for generated include files
duke@1 123 INCLUDEDIR = $(OUTPUTDIR)/include
duke@1 124 # for generated class files
duke@1 125 CLASSBINDIR = $(OUTPUTDIR)/classes
duke@1 126 DEMOCLASSDIR = $(OUTPUTDIR)/democlasses
duke@1 127 # for generated tool class files
duke@1 128 BUILDTOOLCLASSDIR = $(OUTPUTDIR)/btclasses
duke@1 129 # for build tool jar files
duke@1 130 BUILDTOOLJARDIR = $(OUTPUTDIR)/btjars
duke@1 131 ABS_BUILDTOOLJARDIR = $(ABS_OUTPUTDIR)/btjars
duke@1 132 # for generated java source files
duke@1 133 GENSRCDIR = $(OUTPUTDIR)/gensrc
duke@1 134 # for generated C source files (not javah)
duke@1 135 GENNATIVESRCDIR = $(OUTPUTDIR)/gennativesrc
duke@1 136 # for imported source files
duke@1 137 IMPORTSRCDIR = $(OUTPUTDIR)/impsrc
duke@1 138 # for imported documents
duke@1 139 IMPORTDOCDIR = $(OUTPUTDIR)/impdoc
duke@1 140 # for generated demo
duke@1 141 DEMODIR = $(OUTPUTDIR)/demo
duke@1 142 # for sample code
duke@1 143 SAMPLEDIR = $(OUTPUTDIR)/sample
duke@1 144 # for generated documentation
duke@1 145 DOCSDIR = $(OUTPUTDIR)/docs$(DOCSDIRSUFFIX)
duke@1 146 DOCSDIRSUFFIX =
duke@1 147
duke@1 148 # An attempt is made to generate unique enough directories for the
duke@1 149 # generated files to not have name collisisons. Most build units
duke@1 150 # defines PRODUCT (except Release.gmk), but then they may or may
duke@1 151 # not define PACKAGE, THREADIR (only HPI uses this), PROGRAM, and
duke@1 152 # LIBRARY. This code chunk attempts to generate a unique
duke@1 153 # OBJDIR/CLASSHDRDIR for each build unit based on which of those
duke@1 154 # values are set within each build unit.
duke@1 155
duke@1 156 UNIQUE_LOCATION_STRING = tmp
duke@1 157
duke@1 158 ifneq ($(PRODUCT),)
duke@1 159 UNIQUE_LOCATION_STRING += /$(PRODUCT)
duke@1 160 endif
duke@1 161
duke@1 162 ifneq ($(PACKAGE),)
duke@1 163 UNIQUE_LOCATION_STRING += /$(PACKAGE)
duke@1 164 endif
duke@1 165
duke@1 166 ifneq ($(PROGRAM),)
duke@1 167 UNIQUE_LOCATION_STRING += /$(PROGRAM)
duke@1 168 endif
duke@1 169
duke@1 170 ifneq ($(LIBRARY),)
duke@1 171 ifneq ($(LIBRARY_OUTPUT),)
duke@1 172 UNIQUE_LOCATION_STRING += /$(LIBRARY_OUTPUT)
duke@1 173 else
duke@1 174 UNIQUE_LOCATION_STRING += /$(LIBRARY)
duke@1 175 endif
duke@1 176 endif
duke@1 177
duke@1 178 ifneq ($(THREADDIR),)
duke@1 179 UNIQUE_LOCATION_STRING += /$(THREADDIR)
duke@1 180 endif
duke@1 181
duke@1 182 # the use of += above makes a space separated list which we need to
duke@1 183 # remove for filespecs.
duke@1 184 #
duke@1 185 NULLSTRING :=
duke@1 186 ONESPACE := $(NULLSTRING) # space before this comment is required.
duke@1 187 UNIQUE_PATH = $(subst $(ONESPACE),,$(UNIQUE_LOCATION_STRING))
duke@1 188
duke@1 189 # TEMPDIR is a unique general purpose directory
duke@1 190 # need to use 'override' because GNU Make on Linux exports the wrong
duke@1 191 # value.
duke@1 192 override TEMPDIR = $(OUTPUTDIR)/$(UNIQUE_PATH)
duke@1 193 override ABS_TEMPDIR = $(ABS_OUTPUTDIR)/$(UNIQUE_PATH)
duke@1 194
duke@1 195 # This must be created right away for pattern rules in Sanity.gmk to work.
duke@1 196 dummy1:=$(shell $(MKDIR) -p $(TEMPDIR))
duke@1 197 dummy2:=$(shell $(MKDIR) -p $(TEMP_DISK))
duke@1 198
duke@1 199 # OBJDIRNAME is the name of the directory where the object code is to
duke@1 200 # be placed. It's name depends on whether the data model architecture
duke@1 201 # is 32-bit or not.
duke@1 202 ifneq ($(ARCH_DATA_MODEL), 32)
duke@1 203 OBJDIRNAME = obj$(ARCH_DATA_MODEL)$(OBJDIRNAME_SUFFIX)
duke@1 204 else
duke@1 205 OBJDIRNAME = obj$(OBJDIRNAME_SUFFIX)
duke@1 206 endif
duke@1 207 OBJDIR = $(TEMPDIR)/$(OBJDIRNAME)
duke@1 208
duke@1 209 # CLASSHDRDIR is where the generated C Class Header files go.
duke@1 210 CLASSHDRDIR = $(TEMPDIR)/CClassHeaders
duke@1 211
duke@1 212 #
duke@1 213 # CLASSDESTDIR can be used to specify the directory where generated classes
duke@1 214 # are to be placed. The default is CLASSBINDIR.
duke@1 215 #
duke@1 216 ifndef CLASSDESTDIR
duke@1 217 CLASSDESTDIR = $(CLASSBINDIR)
duke@1 218 endif
duke@1 219
duke@1 220 INCLUDES = -I. -I$(CLASSHDRDIR) \
duke@1 221 $(patsubst %,-I%,$(subst $(CLASSPATH_SEPARATOR), ,$(VPATH.h))) $(OTHER_INCLUDES)
duke@1 222 OTHER_CPPFLAGS = $(INCLUDES)
duke@1 223
duke@1 224
duke@1 225 #
duke@1 226 # vpaths. These are the default locations searched for source files.
duke@1 227 # GNUmakefiles of individual areas often override the default settings.
duke@1 228 # There are no longer default vpath entries for C and assembler files
duke@1 229 # so we can ensure that libraries don't get their hands on JVM files.
duke@1 230 #
duke@1 231 # We define an intermediate variable for Java files because
duke@1 232 # we use its value later to help define $SOURCEPATH
duke@1 233
duke@1 234 VPATH0.java = $(GENSRCDIR)$(CLASSPATH_SEPARATOR)$(PLATFORM_SRC)/classes$(CLASSPATH_SEPARATOR)$(SHARE_SRC)/classes
duke@1 235 VPATH.java = $(VPATH0.java)
duke@1 236 vpath %.java $(VPATH.java)
duke@1 237 vpath %.class $(CLASSBINDIR)
duke@1 238 vpath %.$(OBJECT_SUFFIX) $(OBJDIR)
duke@1 239
duke@1 240 #
duke@1 241 # VPATH.h is used elsewhere to generate include flags. By default,
duke@1 242 # anyone has access to the include files that the JVM area exports,
duke@1 243 # namely jni.h, jvm.h, and jni_utils.h, plus their platform-specific
duke@1 244 # relatives.
duke@1 245 #
duke@1 246 ifeq ($(PLATFORM), windows)
duke@1 247 VPATH.h = $(BOOTDIR)/include;$(BOOTDIR)/include/$(PLATFORM_INCLUDE_NAME)
duke@1 248 else
duke@1 249 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 250 endif
duke@1 251 vpath %.h $(VPATH.h)
duke@1 252
duke@1 253 #
duke@1 254 # Used in two ways: helps link against libjava.so. Also if overridden
duke@1 255 # determines where your shared library is installed.
duke@1 256 #
duke@1 257 ifndef LIB_LOCATION
duke@1 258 LIB_LOCATION = $(LIBDIR)/$(LIBARCH)
duke@1 259 endif
duke@1 260
duke@1 261 #
duke@1 262 # Java header and stub variables
duke@1 263 #
duke@1 264 CLASSHDRS = $(patsubst %,$(CLASSHDRDIR)/%.h,$(subst .,_,$(CLASSES.export)))
duke@1 265 CLASSSTUBOBJS = classstubs.$(OBJECT_SUFFIX)
duke@1 266 STUBPREAMBLE = $(INCLUDEDIR)/StubPreamble.h
duke@1 267
duke@1 268 #
duke@1 269 # Classpath seen by javac (different from the one seen by the VM
duke@1 270 # running javac), and useful variables.
duke@1 271 #
duke@1 272 SOURCEPATH = $(VPATH.java)
duke@1 273 PKG = $(shell $(EXPR) $(PACKAGE) : '\([a-z]*\)')
duke@1 274 PKGDIR = $(subst .,/,$(PACKAGE))
duke@1 275
duke@1 276 #
duke@1 277 # The java/javac/jdk variables (JAVAC_CMD, JAVA_CMD, etc.)
duke@1 278 #
duke@1 279 include $(BUILDDIR)/common/shared/Defs-java.gmk
duke@1 280
duke@1 281 #
duke@1 282 # Set opt level to ALT_OPT if set otherwise _OPT
duke@1 283 #
duke@1 284 POPT = $(_OPT$(ALT_OPT))$(ALT_OPT)
duke@1 285
duke@1 286 #
duke@1 287 # Convenient macros
duke@1 288 #
duke@1 289
duke@1 290 # Prepare $@ target, remove old one and making sure directory exists
duke@1 291 define prep-target
duke@1 292 $(MKDIR) -p $(@D)
duke@1 293 $(RM) $@
duke@1 294 endef
duke@1 295
duke@1 296 # Simple install of $< file to $@
duke@1 297 define install-file
duke@1 298 $(prep-target)
duke@1 299 $(CP) $< $@
duke@1 300 endef
duke@1 301
duke@1 302 # Cleanup rule for after debug java run (hotspot.log file is left around)
duke@1 303 # (This could be an old leftover file in a read-only area, use the @- prefix)
duke@1 304 HOTSPOT_LOG_NAME = hotspot.log
duke@1 305 define java-vm-cleanup
duke@1 306 if [ -w $(HOTSPOT_LOG_NAME) ] ; then $(RM) $(HOTSPOT_LOG_NAME); fi
duke@1 307 endef
duke@1 308
duke@1 309 # Default make settings for processing SUBDIRS with clobber or clean names
duke@1 310 SUBDIRS_MAKEFLAGS-clobber = INCREMENTAL_BUILD=false
duke@1 311 SUBDIRS_MAKEFLAGS-clean = INCREMENTAL_BUILD=false
duke@1 312
duke@1 313 # Given a SUBDIRS list, cd into them and make them
duke@1 314 # SUBDIRS_MAKEFLAGS Make settings for a subdir make
duke@1 315 # SUBDIRS_MAKEFLAGS-$@ Make settings specific to this target
duke@1 316 define SUBDIRS-loop
duke@1 317 @for i in DUMMY $(SUBDIRS) ; do \
duke@1 318 if [ "$$i" != "DUMMY" ] ; then \
ohair@114 319 $(MAKE) -C $${i} $@ \
ohair@114 320 $(SUBDIRS_MAKEFLAGS) \
ohair@114 321 $(SUBDIRS_MAKEFLAGS-$@) \
ohair@114 322 FULL_VERSION=$(FULL_VERSION) \
ohair@114 323 RELEASE=$(RELEASE) || exit 1; \
duke@1 324 fi ; \
duke@1 325 done
duke@1 326 endef
duke@1 327
duke@1 328 # Given a OTHERSUBDIRS list, cd into them and make them (extra loop define)
duke@1 329 # OTHERSUBDIRS_MAKEFLAGS Make settings for a subdir make
duke@1 330 define OTHERSUBDIRS-loop
duke@1 331 @for i in DUMMY $(OTHERSUBDIRS) ; do \
duke@1 332 if [ "$$i" != "DUMMY" ] ; then \
ohair@114 333 $(MAKE) -C $${i} $@ \
ohair@114 334 $(OTHERSUBDIRS_MAKEFLAGS) \
ohair@114 335 FULL_VERSION=$(FULL_VERSION) \
ohair@114 336 RELEASE=$(RELEASE) || exit 1; \
duke@1 337 fi ; \
duke@1 338 done
duke@1 339 endef
duke@1 340
duke@1 341 #
duke@1 342 # Create BYFILE OPT and DBG settings, if CFLAGS_OPT/foobar.o is set then it is
duke@1 343 # used for this file, otherwise the default settings are used.
duke@1 344 #
duke@1 345 CFLAGS_$(VARIANT)/BYFILE = $(CFLAGS_$(VARIANT)/$(@F)) \
duke@1 346 $(CFLAGS_$(VARIANT)$(CFLAGS_$(VARIANT)/$(@F)))
duke@1 347 CXXFLAGS_$(VARIANT)/BYFILE = $(CXXFLAGS_$(VARIANT)/$(@F)) \
duke@1 348 $(CXXFLAGS_$(VARIANT)$(CXXFLAGS_$(VARIANT)/$(@F)))
duke@1 349
duke@1 350 #
duke@1 351 # Tool flags
duke@1 352 #
duke@1 353 ASFLAGS = $(ASFLAGS_$(VARIANT)) $(ASFLAGS_COMMON) $(OTHER_ASFLAGS)
duke@1 354 CFLAGS = $(CFLAGS_$(VARIANT)/BYFILE) $(CFLAGS_COMMON) $(OTHER_CFLAGS)
duke@1 355 CXXFLAGS = $(CXXFLAGS_$(VARIANT)/BYFILE) $(CXXFLAGS_COMMON) $(OTHER_CXXFLAGS)
duke@1 356 CPPFLAGS = $(CPPFLAGS_$(VARIANT)) $(CPPFLAGS_COMMON) $(OTHER_CPPFLAGS) \
duke@1 357 $(DEFINES) $(OPTIONS:%=-D%)
duke@1 358 LDFLAGS = $(LDFLAGS_$(VARIANT)) $(LDFLAGS_COMMON) $(OTHER_LDFLAGS)
duke@1 359 LDLIBS = $(OTHER_LDLIBS) $(LDLIBS_$(VARIANT)) $(LDLIBS_COMMON)
duke@1 360 LINTFLAGS = $(LINTFLAGS_$(VARIANT)) $(LINTFLAGS_COMMON) \
duke@1 361 $(OTHER_LINTFLAGS)
duke@1 362
duke@1 363 # this should be moved into Defs-<platform>.gmk.....
duke@1 364 ifeq ($(PLATFORM), windows)
duke@1 365 VERSION_DEFINES = -DRELEASE="\"$(RELEASE)\""
duke@1 366 else
duke@1 367 VERSION_DEFINES = -DRELEASE='"$(RELEASE)"'
duke@1 368 endif
duke@1 369
ohair@114 370 # Prevent the use of many default suffix rules we do not need
ohair@114 371 .SUFFIXES:
ohair@114 372 .SUFFIXES: .c .o .h .obj .cpp .hpp .java .class
duke@1 373
ohair@114 374 # Make sure we are all insane
duke@1 375 ifdef INSANE
duke@1 376 export INSANE
duke@1 377 endif
duke@1 378
ohair@114 379 # Make sure we have the current year
ohair@114 380 ifndef COPYRIGHT_YEAR
ohair@114 381 ifdef ALT_COPYRIGHT_YEAR
ohair@114 382 COPYRIGHT_YEAR := $(ALT_COPYRIGHT_YEAR)
ohair@114 383 else
ohair@114 384 COPYRIGHT_YEAR := $(shell $(DATE) '+%Y')
ohair@114 385 endif
ohair@114 386 export COPYRIGHT_YEAR
duke@1 387 endif
duke@1 388
duke@1 389 # Install of imported file (JDK_IMPORT_PATH, or some other external location)
duke@1 390 define install-import-file
duke@1 391 @$(ECHO) "ASSEMBLY_IMPORT: $@"
duke@1 392 $(install-file)
duke@1 393 endef
duke@1 394
duke@1 395 .PHONY: all build clean clobber

mercurial