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

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

mercurial