blob: 9dd781b2f7e428fe4547437b833a42f0e5c4917a [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001#
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#
41SUN_MAKE_TEST:sh = echo "ERROR: PLEASE USE GNU VERSION OF MAKE"; exit 33
42
43ifndef JDK_TOPDIR
44 JDK_TOPDIR=$(BUILDDIR)/..
45endif
46ifndef JDK_MAKE_SHARED_DIR
47 JDK_MAKE_SHARED_DIR=$(JDK_TOPDIR)/make/common/shared
48endif
49
50include $(JDK_MAKE_SHARED_DIR)/Platform.gmk
51
52TOPDIR=$(BUILDDIR)/..
53
54include $(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#
61ifndef SHARE_SRC
62 SHARE_SRC = $(JDK_TOPDIR)/src/share
63endif
64
65# Files that cannot be included in the OpenJDK distribution are
66# collected under a parent directory which contains just those files.
67ifndef CLOSED_SRC
68 CLOSED_SRC = $(JDK_TOPDIR)/src/closed
69endif
70
71# If we have no closed directory, force it to an openjdk build
72CLOSED_SRC_DIR_EXISTS := $(shell \
73 if [ -d $(CLOSED_SRC) ] ; then \
74 echo true; \
75 else \
76 echo false; \
77 fi)
78ifeq ($(CLOSED_SRC_DIR_EXISTS), false)
79 OPENJDK = true
80endif
81
82# Check for strange explicit settings (change to empty or true)
83ifdef 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
93endif
94
95# Define where closed directories are
96ifdef OPENJDK
97 CLOSED_SRC =
98 CLOSED_SHARE_SRC =
99else
100 ifndef CLOSED_SHARE_SRC
101 CLOSED_SHARE_SRC = $(CLOSED_SRC)/share
102 endif
103endif
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
149BINARY_PLUGS_JARNAME = rt-closed.jar
150
151ifdef 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
171endif # OPENJDK
172
173# Default output directory
174ifdef OPENJDK
175_OUTPUTDIR=$(JDK_TOPDIR)/build/$(PLATFORM)-$(ARCH)$(OPENJDK_SUFFIX)
176else
177_OUTPUTDIR=$(JDK_TOPDIR)/build/$(PLATFORM)-$(ARCH)
178endif
179
180
181#
182# Get platform definitions
183#
184
185include $(JDK_TOPDIR)/make/common/Defs-$(PLATFORM).gmk
186
187#
188# Freetype logic is applicable to OpenJDK only
189#
190ifdef OPENJDK
191
192#if we use system lib we do not need to copy it to build tree
193USING_SYSTEM_FT_LIB=false
194
195ifeq ($(PLATFORM), windows)
196 DEVTOOLS_FT_DIR=$(JDK_DEVTOOLS_DIR)/win32/freetype-$(ARCH)
197endif
198ifeq ($(PLATFORM), linux)
199 DEVTOOLS_FT_DIR=$(JDK_DEVTOOLS_DIR)/$(PLATFORM)/freetype-$(ARCH)
200endif
201ifeq ($(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)
205endif
206
207DEVTOOLS_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
240endif
241
242#
243# Localizations for the different parts of the product beyond English
244#
245
246JRE_LOCALES = de es fr it ja ko sv zh_CN zh_TW zh_HK
247PLUGIN_LOCALES = de es fr it ja ko sv zh_CN zh_TW zh_HK
248JDK_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#
254JRE_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#
262ifdef PACKAGE
263# put JAVALIB first, but do not lose any platform specific values....
264 LDLIBS_COMMON = $(JAVALIB)
265endif # PACKAGE
266
267#
268# Libraries that must appear ahead of libc.so on the link command line
269#
270ifdef 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
280endif # PROGRAM
281
282LDLIBS_COMMON += $(EXTRA_LIBS)
283
284#
285# Default is to build, not import native binaries
286#
287ifndef IMPORT_NATIVE_BINARIES
288 IMPORT_NATIVE_BINARIES=false
289endif
290# If importing libraries in, no incremental builds
291ifeq ($(IMPORT_NATIVE_BINARIES),true)
292 INCREMENTAL_BUILD=false
293endif
294
295# for generated libraries
296LIBDIR = $(OUTPUTDIR)/lib
297ABS_LIBDIR = $(ABS_OUTPUTDIR)/lib
298# Optional place to save the windows .lib files
299LIBFILES_DIR = $(OUTPUTDIR)/libfiles
300# for ext jre files
301EXTDIR = $(LIBDIR)/ext
302# for generated include files
303INCLUDEDIR = $(OUTPUTDIR)/include
304# for generated class files
305CLASSBINDIR = $(OUTPUTDIR)/classes
306DEMOCLASSDIR = $(OUTPUTDIR)/democlasses
307# for generated tool class files
308BUILDTOOLCLASSDIR = $(OUTPUTDIR)/btclasses
309# for build tool jar files
310BUILDTOOLJARDIR = $(OUTPUTDIR)/btjars
311ABS_BUILDTOOLJARDIR = $(ABS_OUTPUTDIR)/btjars
312# for generated java source files
313GENSRCDIR = $(OUTPUTDIR)/gensrc
314# for generated C source files (not javah)
315GENNATIVESRCDIR = $(OUTPUTDIR)/gennativesrc
316# for imported source files
317IMPORTSRCDIR = $(OUTPUTDIR)/impsrc
318# for imported documents
319IMPORTDOCDIR = $(OUTPUTDIR)/impdoc
320# for generated demo
321DEMODIR = $(OUTPUTDIR)/demo
322# for sample code
323SAMPLEDIR = $(OUTPUTDIR)/sample
324# for generated documentation
325DOCSDIR = $(OUTPUTDIR)/docs$(DOCSDIRSUFFIX)
326DOCSDIRSUFFIX =
327
328# The MESSAGE, WARNING and ERROR files are used to store sanityck and
329# SCCS check messages, warnings and errors.
330ifndef ERROR_FILE
331 ERROR_FILE = $(OUTPUTDIR)/sanityCheckErrors.txt
332endif
333ifndef WARNING_FILE
334 WARNING_FILE = $(OUTPUTDIR)/sanityCheckWarnings.txt
335endif
336ifndef MESSAGE_FILE
337 MESSAGE_FILE = $(OUTPUTDIR)/sanityCheckMessages.txt
338endif
339
340JDK_IMAGE_DIR = $(ABS_OUTPUTDIR)/j2sdk-image
341JRE_IMAGE_DIR = $(ABS_OUTPUTDIR)/j2re-image
342
343#where the demo source can be found
344DEMOSRCDIR = $(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
354UNIQUE_LOCATION_STRING = tmp
355
356ifneq ($(PRODUCT),)
357 UNIQUE_LOCATION_STRING += /$(PRODUCT)
358endif
359
360ifneq ($(PACKAGE),)
361 UNIQUE_LOCATION_STRING += /$(PACKAGE)
362endif
363
364ifneq ($(PROGRAM),)
365 UNIQUE_LOCATION_STRING += /$(PROGRAM)
366endif
367
368ifneq ($(LIBRARY),)
369 ifneq ($(LIBRARY_OUTPUT),)
370 UNIQUE_LOCATION_STRING += /$(LIBRARY_OUTPUT)
371 else
372 UNIQUE_LOCATION_STRING += /$(LIBRARY)
373 endif
374endif
375
376ifneq ($(THREADDIR),)
377 UNIQUE_LOCATION_STRING += /$(THREADDIR)
378endif
379
380# the use of += above makes a space separated list which we need to
381# remove for filespecs.
382#
383NULLSTRING :=
384ONESPACE := $(NULLSTRING) # space before this comment is required.
385UNIQUE_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.
390override TEMPDIR = $(OUTPUTDIR)/$(UNIQUE_PATH)
391override ABS_TEMPDIR = $(ABS_OUTPUTDIR)/$(UNIQUE_PATH)
392
393# This must be created right away for pattern rules in Sanity.gmk to work.
394dummy1:=$(shell $(MKDIR) -p $(TEMPDIR))
395dummy2:=$(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.
400ifneq ($(ARCH_DATA_MODEL), 32)
401 OBJDIRNAME = obj$(ARCH_DATA_MODEL)$(OBJDIRNAME_SUFFIX)
402else
403 OBJDIRNAME = obj$(OBJDIRNAME_SUFFIX)
404endif
405OBJDIR = $(TEMPDIR)/$(OBJDIRNAME)
406
407# CLASSHDRDIR is where the generated C Class Header files go.
408CLASSHDRDIR = $(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#
414ifndef CLASSDESTDIR
415CLASSDESTDIR = $(CLASSBINDIR)
416endif
417
418INCLUDES = -I. -I$(CLASSHDRDIR) \
419 $(patsubst %,-I%,$(subst $(CLASSPATH_SEPARATOR), ,$(VPATH.h))) $(OTHER_INCLUDES)
420OTHER_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
432VPATH0.java = $(GENSRCDIR)$(CLASSPATH_SEPARATOR)$(PLATFORM_SRC)/classes$(CLASSPATH_SEPARATOR)$(SHARE_SRC)/classes
433ifdef OPENJDK
434 VPATH.java = $(VPATH0.java)
435else
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)
447endif
448vpath %.java $(VPATH.java)
449vpath %.class $(CLASSBINDIR)
450vpath %.$(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#
458VPATH.h = $(PLATFORM_SRC)/javavm/export$(CLASSPATH_SEPARATOR)$(SHARE_SRC)/javavm/export$(CLASSPATH_SEPARATOR)$(SHARE_SRC)/javavm/include$(CLASSPATH_SEPARATOR)$(PLATFORM_SRC)/javavm/include
459vpath %.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#
465ifndef LIB_LOCATION
466 LIB_LOCATION = $(LIBDIR)/$(LIBARCH)
467endif
468
469#
470# Java header and stub variables
471#
472CLASSHDRS = $(patsubst %,$(CLASSHDRDIR)/%.h,$(subst .,_,$(CLASSES.export)))
473CLASSSTUBOBJS = classstubs.$(OBJECT_SUFFIX)
474STUBPREAMBLE = $(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#
480SOURCEPATH = $(VPATH.java)
481PKG = $(shell $(EXPR) $(PACKAGE) : '\([a-z]*\)')
482PKGDIR = $(subst .,/,$(PACKAGE))
483
484#
485# The java/javac/jdk variables (JAVAC_CMD, JAVA_CMD, etc.)
486#
487include $(JDK_MAKE_SHARED_DIR)/Defs-java.gmk
488
489#
490# Set opt level to ALT_OPT if set otherwise _OPT
491#
492POPT = $(_OPT$(ALT_OPT))$(ALT_OPT)
493
494#
495# Convenient macros
496#
497
498# Prepare $@ target, remove old one and making sure directory exists
499define prep-target
500$(MKDIR) -p $(@D)
501$(RM) $@
502endef
503
504# Simple install of $< file to $@
505define install-file
506$(prep-target)
507$(CP) $< $@
508endef
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)
512HOTSPOT_LOG_NAME = hotspot.log
513define java-vm-cleanup
514if [ -w $(HOTSPOT_LOG_NAME) ] ; then $(RM) $(HOTSPOT_LOG_NAME); fi
515endef
516
517# Default make settings for processing SUBDIRS with clobber or clean names
518SUBDIRS_MAKEFLAGS-clobber = INCREMENTAL_BUILD=false
519SUBDIRS_MAKEFLAGS-clean = INCREMENTAL_BUILD=false
520
521# Current directory
522CURRENT_DIRECTORY := $(shell $(PWD))
523
524# If no timing wanted, we need to define these as empty
525ifdef NO_TIMING
526
527TIMING_ID:=NA
528
529define TIMING_start
530t=0:0:0:0
531endef
532
533define TIMING_end
534time_used=0
535endef
536
537else # NO_TIMING
538
539# Default timing id
540TIMING_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.
544define TIMING_start
545$1=`$(DATE) +%j:%H:%M:%S`
546endef
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"
553define TIMING_end
554begTime="$${$1}"; \
555timing_id="$${$2}"; \
556endTime=`$(DATE) +%j:%H:%M:%S`; \
557d1=`$(ECHO) $${begTime} | $(CUT) -d':' -f1 | $(SED) -e 's@^0*@@'`; \
558if [ "$${d1}" = "" ] ; then d1=0; fi; \
559h1=`$(ECHO) $${begTime} | $(CUT) -d':' -f2 | $(SED) -e 's@^0*@@'`; \
560if [ "$${h1}" = "" ] ; then h1=0; fi; \
561m1=`$(ECHO) $${begTime} | $(CUT) -d':' -f3 | $(SED) -e 's@^0*@@'`; \
562if [ "$${m1}" = "" ] ; then m1=0; fi; \
563s1=`$(ECHO) $${begTime} | $(CUT) -d':' -f4 | $(SED) -e 's@^0*@@'`; \
564if [ "$${s1}" = "" ] ; then s1=0; fi; \
565d2=`$(ECHO) $${endTime} | $(CUT) -d':' -f1 | $(SED) -e 's@^0*@@'`; \
566if [ "$${d2}" = "" ] ; then d2=0; fi; \
567h2=`$(ECHO) $${endTime} | $(CUT) -d':' -f2 | $(SED) -e 's@^0*@@'`; \
568if [ "$${h2}" = "" ] ; then h2=0; fi; \
569m2=`$(ECHO) $${endTime} | $(CUT) -d':' -f3 | $(SED) -e 's@^0*@@'`; \
570if [ "$${m2}" = "" ] ; then m2=0; fi; \
571s2=`$(ECHO) $${endTime} | $(CUT) -d':' -f4 | $(SED) -e 's@^0*@@'`; \
572if [ "$${s2}" = "" ] ; then s2=0; fi; \
573t1_secs=`$(EXPR) $${d1} '*' 60 '*' 60 '*' 24 '+' $${h1} '*' 60 '*' 60 \
574 '+' $${m1} '*' 60 '+' $${s1}`; \
575t2_secs=`$(EXPR) $${d2} '*' 60 '*' 60 '*' 24 '+' $${h2} '*' 60 '*' 60 \
576 '+' $${m2} '*' 60 '+' $${s2}`; \
577total_seconds=`$(EXPR) $${t2_secs} '-' $${t1_secs}`; \
578if [ "$${total_seconds}" -lt 0 ] ; then total_seconds=0; fi; \
579t_hour=`$(EXPR) $${total_seconds} '/' '(' 60 '*' 60 ')'`h; \
580t_min=`$(EXPR) '(' $${total_seconds} '%' '(' 60 '*' 60 ')' ')' '/' 60`m; \
581t_sec=`$(EXPR) $${total_seconds} '%' 60`s; \
582time_used=$${t_sec}; \
583if [ "$${t_hour}" != "0h" ] ; then \
584time_used=$${t_hour}$${t_min}$${t_sec}; \
585elif [ "$${t_min}" != "0m" ] ; then \
586time_used=$${t_min}$${t_sec}; \
587else \
588time_used=$${t_sec}; \
589fi; \
590$(PRINTF) " Timing: %05d seconds or %s for %s\n" \
591 $${total_seconds} $${time_used} $${timing_id}
592endef
593
594endif # 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
599define 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 ; \
616done
617@$(ECHO) "Done Processing SUBDIRS: $(SUBDIRS)"
618endef
619
620# Given a OTHERSUBDIRS list, cd into them and make them (extra loop define)
621# OTHERSUBDIRS_MAKEFLAGS Make settings for a subdir make
622define 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 ; \
638done
639@$(ECHO) "Done Processing OTHERSUBDIRS: $(OTHERSUBDIRS)"
640endef
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#
646CFLAGS_$(VARIANT)/BYFILE = $(CFLAGS_$(VARIANT)/$(@F)) \
647 $(CFLAGS_$(VARIANT)$(CFLAGS_$(VARIANT)/$(@F)))
648CXXFLAGS_$(VARIANT)/BYFILE = $(CXXFLAGS_$(VARIANT)/$(@F)) \
649 $(CXXFLAGS_$(VARIANT)$(CXXFLAGS_$(VARIANT)/$(@F)))
650
651#
652# Tool flags
653#
654ASFLAGS = $(ASFLAGS_$(VARIANT)) $(ASFLAGS_COMMON) $(OTHER_ASFLAGS)
655CFLAGS = $(CFLAGS_$(VARIANT)/BYFILE) $(CFLAGS_COMMON) $(OTHER_CFLAGS)
656CXXFLAGS = $(CXXFLAGS_$(VARIANT)/BYFILE) $(CXXFLAGS_COMMON) $(OTHER_CXXFLAGS)
657CPPFLAGS = $(CPPFLAGS_$(VARIANT)) $(CPPFLAGS_COMMON) $(OTHER_CPPFLAGS) \
658 $(DEFINES) $(OPTIONS:%=-D%)
659LDFLAGS = $(LDFLAGS_$(VARIANT)) $(LDFLAGS_COMMON) $(OTHER_LDFLAGS)
660LDLIBS = $(OTHER_LDLIBS) $(LDLIBS_$(VARIANT)) $(LDLIBS_COMMON)
661LINTFLAGS = $(LINTFLAGS_$(VARIANT)) $(LINTFLAGS_COMMON) \
662 $(OTHER_LINTFLAGS)
663
664# this should be moved into Defs-<platform>.gmk.....
665ifeq ($(PLATFORM), windows)
666 VERSION_DEFINES = -DRELEASE="\"$(RELEASE)\""
667else
668 VERSION_DEFINES = -DRELEASE='"$(RELEASE)"'
669endif
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.
681define 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")
689endef
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
703ifdef INSANE
704 export INSANE
705endif
706
707ifdef ALT_COPYRIGHT_YEAR
708 COPYRIGHT_YEAR = $(ALT_COPYRIGHT_YEAR)
709else
710 COPYRIGHT_YEAR = $(shell $(DATE) '+%Y')
711endif
712
713# Install of imported file (JDK_IMPORT_PATH, or some other external location)
714define install-import-file
715@$(ECHO) "ASSEMBLY_IMPORT: $@"
716$(install-file)
717endef
718
719.PHONY: all build clean clobber