1#
2# Copyright (c) 1999, 2015, Oracle and/or its affiliates. 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.
8#
9# This code is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12# version 2 for more details (a copy is included in the LICENSE file that
13# accompanied this code).
14#
15# You should have received a copy of the GNU General Public License version
16# 2 along with this work; if not, write to the Free Software Foundation,
17# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18#
19# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20# or visit www.oracle.com if you need additional information or have any
21# questions.
22#
23#
24
25# This makefile creates a build tree and lights off a build.
26# You can go back into the build tree and perform rebuilds or
27# incremental builds as desired. Be sure to reestablish
28# environment variable settings for LD_LIBRARY_PATH and JAVA_HOME.
29
30# The make process now relies on java and javac. These can be
31# specified either implicitly on the PATH, by setting the
32# (JDK-inherited) ALT_BOOTDIR environment variable to full path to a
33# JDK in which bin/java and bin/javac are present and working (e.g.,
34# /usr/local/java/jdk1.3/solaris), or via the (JDK-inherited)
35# default BOOTDIR path value. Note that one of ALT_BOOTDIR
36# or BOOTDIR has to be set. We do *not* search javac, javah, rmic etc.
37# from the PATH.
38#
39# One can set ALT_BOOTDIR or BOOTDIR to point to a jdk that runs on
40# an architecture that differs from the target architecture, as long
41# as the bootstrap jdk runs under the same flavor of OS as the target
42# (i.e., if the target is linux, point to a jdk that runs on a linux
43# box).  In order to use such a bootstrap jdk, set the make variable
44# REMOTE to the desired remote command mechanism, e.g.,
45#
46#    make REMOTE="rsh -l me myotherlinuxbox"
47
48# Along with VM, Serviceability Agent (SA) is built for SA/JDI binding.
49# JDI binding on SA produces two binaries:
50#  1. sa-jdi.jar       - This is built before building libjvm.so
51#                        Please refer to ./makefiles/sa.make
52#  2. libsa.so         - Native library for SA - This is built after
53#                        libjsig.so (signal interposition library)
54#                        Please refer to ./makefiles/vm.make
55# If $(GAMMADIR)/agent dir is not present, SA components are not built.
56
57ifeq ($(GAMMADIR),)
58include ../../make/defs.make
59else
60include $(GAMMADIR)/make/defs.make
61endif
62include $(GAMMADIR)/make/$(OSNAME)/makefiles/rules.make
63
64ifndef CC_INTERP
65  ifndef FORCE_TIERED
66    FORCE_TIERED=1
67  endif
68endif
69# C1 is not ported on ppc64, so we cannot build a tiered VM:
70# Notice: after 8046471 ARCH will be 'ppc' for top-level ppc64 builds but
71# 'ppc64' for HotSpot-only ppc64 builds. Need to detect both variants here!
72ifneq (,$(findstring $(ARCH), ppc ppc64))
73  ifeq ($(ARCH_DATA_MODEL), 64)
74    FORCE_TIERED=0
75  endif
76endif
77
78ifdef LP64
79  ifeq ("$(filter $(LP64_ARCH),$(BUILDARCH))","")
80    _JUNK_ := $(shell echo >&2 \
81       $(OSNAME) $(ARCH) "*** ERROR: this platform does not support 64-bit compilers!")
82	@exit 1
83  endif
84endif
85
86# we need to set up LP64 correctly to satisfy sanity checks in adlc
87ifneq ("$(filter $(LP64_ARCH),$(BUILDARCH))","")
88  MFLAGS += " LP64=1 "
89endif
90
91# pass USE_SUNCC further, through MFLAGS
92ifdef USE_SUNCC
93  MFLAGS += " USE_SUNCC=1 "
94endif
95
96# The following renders pathnames in generated Makefiles valid on
97# machines other than the machine containing the build tree.
98#
99# For example, let's say my build tree lives on /files12 on
100# exact.east.sun.com.  This logic will cause GAMMADIR to begin with
101# /net/exact/files12/...
102#
103# We only do this on SunOS variants, for a couple of reasons:
104#  * It is extremely rare that source trees exist on other systems
105#  * It has been claimed that the Linux automounter is flakey, so
106#    changing GAMMADIR in a way that exercises the automounter could
107#    prove to be a source of unreliability in the build process.
108# Obviously, this Makefile is only relevant on SunOS boxes to begin
109# with, but the SunOS conditionalization will make it easier to
110# combine Makefiles in the future (assuming we ever do that).
111
112ifeq ($(OSNAME),solaris)
113
114  #   prepend current directory to relative pathnames.
115  NEW_GAMMADIR :=                                    \
116    $(shell echo $(GAMMADIR) |                       \
117      sed -e "s=^\([^/].*\)=$(shell pwd)/\1="        \
118     )
119  unexport NEW_GAMMADIR
120
121  # If NEW_GAMMADIR doesn't already start with "/net/":
122  ifeq ($(strip $(filter /net/%,$(NEW_GAMMADIR))),)
123    #   prepend /net/$(HOST)
124    #   remove /net/$(HOST) if name already began with /home/
125    #   remove /net/$(HOST) if name already began with /java/
126    #   remove /net/$(HOST) if name already began with /lab/
127    NEW_GAMMADIR :=                                     \
128         $(shell echo $(NEW_GAMMADIR) |                 \
129                 sed -e "s=^\(.*\)=/net/$(HOST)\1="     \
130                     -e "s=^/net/$(HOST)/home/=/home/=" \
131                     -e "s=^/net/$(HOST)/java/=/java/=" \
132                     -e "s=^/net/$(HOST)/lab/=/lab/="   \
133          )
134    # Don't use the new value for GAMMADIR unless a file with the new
135    # name actually exists.
136    ifneq ($(wildcard $(NEW_GAMMADIR)),)
137      GAMMADIR := $(NEW_GAMMADIR)
138    endif
139  endif
140
141endif
142
143# BUILDARCH is set to "zero" for Zero builds.  VARIANTARCH
144# is used to give the build directories meaningful names.
145VARIANTARCH = $(subst i386,i486,$(ZERO_LIBARCH))
146
147# There is a (semi-) regular correspondence between make targets and actions:
148#
149#       Target          Tree Type       Build Dir
150#
151#       debug           compiler2       <os>_<arch>_compiler2/debug
152#       fastdebug       compiler2       <os>_<arch>_compiler2/fastdebug
153#       optimized       compiler2       <os>_<arch>_compiler2/optimized
154#       product         compiler2       <os>_<arch>_compiler2/product
155#
156#       debug1          compiler1       <os>_<arch>_compiler1/debug
157#       fastdebug1      compiler1       <os>_<arch>_compiler1/fastdebug
158#       optimized1      compiler1       <os>_<arch>_compiler1/optimized
159#       product1        compiler1       <os>_<arch>_compiler1/product
160#
161#       debugcore       core            <os>_<arch>_core/debug
162#       fastdebugcore   core            <os>_<arch>_core/fastdebug
163#       optimizedcore   core            <os>_<arch>_core/optimized
164#       productcore     core            <os>_<arch>_core/product
165#
166#       debugzero       zero            <os>_<arch>_zero/debug
167#       fastdebugzero   zero            <os>_<arch>_zero/fastdebug
168#       optimizedzero   zero            <os>_<arch>_zero/optimized
169#       productzero     zero            <os>_<arch>_zero/product
170#
171#       debugshark      shark           <os>_<arch>_shark/debug
172#       fastdebugshark  shark           <os>_<arch>_shark/fastdebug
173#       optimizedshark  shark           <os>_<arch>_shark/optimized
174#       productshark    shark           <os>_<arch>_shark/product
175#
176#       fastdebugminimal1 minimal1      <os>_<arch>_minimal1/fastdebug
177#       productminimal1   minimal1      <os>_<arch>_minimal1/product
178#
179# What you get with each target:
180#
181# debug*     - debug compile with asserts enabled
182# fastdebug* - optimized compile, but with asserts enabled
183# optimized* - optimized compile, no asserts
184# product*   - the shippable thing:  optimized compile, no asserts, -DPRODUCT
185
186# This target list needs to be coordinated with the usage message
187# in the build.sh script:
188TARGETS           = debug fastdebug optimized product
189
190ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
191  SUBDIR_DOCS     = $(OSNAME)_$(VARIANTARCH)_docs
192else
193  SUBDIR_DOCS     = $(OSNAME)_$(BUILDARCH)_docs
194endif
195SUBDIRS_C1        = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler1/,$(TARGETS))
196SUBDIRS_C2        = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler2/,$(TARGETS))
197SUBDIRS_TIERED    = $(addprefix $(OSNAME)_$(BUILDARCH)_tiered/,$(TARGETS))
198SUBDIRS_CORE      = $(addprefix $(OSNAME)_$(BUILDARCH)_core/,$(TARGETS))
199SUBDIRS_ZERO      = $(addprefix $(OSNAME)_$(VARIANTARCH)_zero/,$(TARGETS))
200SUBDIRS_SHARK     = $(addprefix $(OSNAME)_$(VARIANTARCH)_shark/,$(TARGETS))
201SUBDIRS_MINIMAL1  = $(addprefix $(OSNAME)_$(BUILDARCH)_minimal1/,$(TARGETS))
202
203TARGETS_C2        = $(TARGETS)
204TARGETS_C1        = $(addsuffix 1,$(TARGETS))
205TARGETS_TIERED    = $(addsuffix tiered,$(TARGETS))
206TARGETS_CORE      = $(addsuffix core,$(TARGETS))
207TARGETS_ZERO      = $(addsuffix zero,$(TARGETS))
208TARGETS_SHARK     = $(addsuffix shark,$(TARGETS))
209TARGETS_MINIMAL1 =  $(addsuffix minimal1,$(TARGETS))
210
211BUILDTREE_MAKE    = $(GAMMADIR)/make/$(OSNAME)/makefiles/buildtree.make
212BUILDTREE_VARS    = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OSNAME) SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH)
213BUILDTREE_VARS   += HOTSPOT_RELEASE_VERSION=$(HOTSPOT_RELEASE_VERSION) HOTSPOT_BUILD_VERSION=$(HOTSPOT_BUILD_VERSION) JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION)
214BUILDTREE_VARS   += ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS) OBJCOPY=$(OBJCOPY) STRIP_POLICY=$(STRIP_POLICY) ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES) ZIPEXE=$(ZIPEXE)
215
216BUILDTREE         = $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_VARS)
217
218#-------------------------------------------------------------------------------
219
220# Could make everything by default, but that would take a while.
221all:
222	@echo "Try '$(MAKE) <target> ...'  where <target> is one or more of"
223	@echo "  $(TARGETS_C2)"
224	@echo "  $(TARGETS_C1)"
225	@echo "  $(TARGETS_CORE)"
226	@echo "  $(TARGETS_ZERO)"
227	@echo "  $(TARGETS_SHARK)"
228	@echo "  $(TARGETS_MINIMAL1)"
229
230checks: check_j2se_version
231
232# jvmti.make requires XSLT (J2SE 1.4.x or newer):
233XSLT_CHECK	= $(REMOTE) $(RUN.JAVAP) javax.xml.transform.TransformerFactory
234# If not found then fail fast.
235check_j2se_version:
236	$(QUIETLY) $(XSLT_CHECK) > /dev/null 2>&1; \
237	if [ $$? -ne 0 ]; then \
238	  $(REMOTE) $(RUN.JAVA) -version; \
239	  echo "*** An XSLT processor (J2SE 1.4.x or newer) is required" \
240	  "to bootstrap this build" 1>&2; \
241	  exit 1; \
242	fi
243
244$(SUBDIRS_TIERED): $(BUILDTREE_MAKE)
245	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
246	$(BUILDTREE) VARIANT=tiered
247
248$(SUBDIRS_C2): $(BUILDTREE_MAKE)
249ifeq ($(FORCE_TIERED),1)
250	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
251		$(BUILDTREE) VARIANT=tiered FORCE_TIERED=1
252else
253	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
254		$(BUILDTREE) VARIANT=compiler2
255endif
256
257$(SUBDIRS_C1): $(BUILDTREE_MAKE)
258	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
259	$(BUILDTREE) VARIANT=compiler1
260
261$(SUBDIRS_CORE): $(BUILDTREE_MAKE)
262	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
263	$(BUILDTREE) VARIANT=core
264
265$(SUBDIRS_ZERO): $(BUILDTREE_MAKE) platform_zero
266	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
267	$(BUILDTREE) VARIANT=zero VARIANTARCH=$(VARIANTARCH)
268
269$(SUBDIRS_SHARK): $(BUILDTREE_MAKE) platform_zero
270	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
271	$(BUILDTREE) VARIANT=shark VARIANTARCH=$(VARIANTARCH)
272
273$(SUBDIRS_MINIMAL1): $(BUILDTREE_MAKE)
274	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
275	$(BUILDTREE) VARIANT=minimal1
276
277
278platform_zero: $(GAMMADIR)/make/$(OSNAME)/platform_zero.in
279	$(SED) 's/@ZERO_ARCHDEF@/$(ZERO_ARCHDEF)/g;s/@ZERO_LIBARCH@/$(ZERO_LIBARCH)/g;' < $< > $@
280
281# Define INSTALL=y at command line to automatically copy JVM into JAVA_HOME
282
283$(TARGETS_C2):  $(SUBDIRS_C2)
284	cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS)
285ifdef INSTALL
286	cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) install
287endif
288
289$(TARGETS_TIERED):  $(SUBDIRS_TIERED)
290	cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS)
291ifdef INSTALL
292	cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS) install
293endif
294
295$(TARGETS_C1):  $(SUBDIRS_C1)
296	cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS)
297ifdef INSTALL
298	cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS) install
299endif
300
301$(TARGETS_CORE):  $(SUBDIRS_CORE)
302	cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS)
303ifdef INSTALL
304	cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) install
305endif
306
307$(TARGETS_ZERO):  $(SUBDIRS_ZERO)
308	cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS)
309ifdef INSTALL
310	cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS) install
311endif
312
313$(TARGETS_SHARK):  $(SUBDIRS_SHARK)
314	cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS)
315ifdef INSTALL
316	cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS) install
317endif
318
319$(TARGETS_MINIMAL1):  $(SUBDIRS_MINIMAL1)
320	cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS)
321ifdef INSTALL
322	cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS) install
323endif
324
325# Just build the tree, and nothing else:
326tree:      $(SUBDIRS_C2)
327tree1:     $(SUBDIRS_C1)
328treecore:  $(SUBDIRS_CORE)
329treezero:  $(SUBDIRS_ZERO)
330treeshark: $(SUBDIRS_SHARK)
331treeminimal1: $(SUBDIRS_MINIMAL1)
332
333# Doc target.  This is the same for all build options.
334#     Hence create a docs directory beside ...$(ARCH)_[...]
335# We specify 'BUILD_FLAVOR=product' so that the proper
336# ENABLE_FULL_DEBUG_SYMBOLS value is used.
337docs: checks
338	$(QUIETLY) mkdir -p $(SUBDIR_DOCS)
339	$(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/makefiles/jvmti.make $(MFLAGS) $(BUILDTREE_VARS) JvmtiOutDir=$(SUBDIR_DOCS) BUILD_FLAVOR=product jvmtidocs
340
341# Synonyms for win32-like targets.
342compiler2:  debug product
343
344compiler1:  debug1 product1
345
346core: debugcore productcore
347
348zero: debugzero productzero
349
350shark: debugshark productshark
351
352warn_jvmg_deprecated:
353	echo "Warning: The jvmg target has been replaced with debug"
354	echo "Warning: Please update your usage"
355
356jvmg: warn_jvmg_deprecated debug
357
358jvmg1: warn_jvmg_deprecated debug1
359
360jvmgcore: warn_jvmg_deprecated debugcore
361
362jvmgzero: warn_jvmg_deprecated debugzero
363
364jvmgshark: warn_jvmg_deprecated debugshark
365
366clean_docs:
367	rm -rf $(SUBDIR_DOCS)
368
369clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark clean_minimal1:
370	rm -rf $(OSNAME)_$(BUILDARCH)_$(subst clean_,,$@)
371
372clean:  clean_compiler2 clean_compiler1 clean_core clean_zero clean_shark clean_minimal1 clean_docs
373
374include $(GAMMADIR)/make/cscope.make
375
376#
377# Include alternate Makefile if it exists.
378#
379-include $(HS_ALT_MAKE)/$(OSNAME)/Makefile.make
380
381#-------------------------------------------------------------------------------
382
383.PHONY: $(TARGETS_C2) $(TARGETS_C1) $(TARGETS_CORE) $(TARGETS_ZERO) $(TARGETS_SHARK) $(TARGETS_MINIMAL1)
384.PHONY: tree tree1 treecore treezero treeshark
385.PHONY: all compiler1 compiler2 core zero shark
386.PHONY: clean clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark docs clean_docs
387.PHONY: checks check_os_version check_j2se_version
388.PHONY: $(HS_ALT_MAKE)/$(OSNAME)/Makefile.make
389