1 #
2 # Copyright (c) 2006, 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 # The common definitions for hotspot builds.
26
27 # Optionally include SPEC file generated by configure.
28 ifneq ($(SPEC),)
29 include $(SPEC)
30 endif
31
32 ifeq ($(LOG_LEVEL),warn)
33 LOG_INFO := > /dev/null
34 else
35 LOG_INFO :=
36 endif
37
38 # Directory paths and user name
39 # Unless GAMMADIR is set on the command line, search upward from
40 # the current directory for a parent directory containing "src/share/vm".
41 # If that fails, look for $GAMMADIR in the environment.
42 # When the tree of subdirs is built, this setting is stored in each flags.make.
43 GAMMADIR := $(shell until ([ -d dev ]&&echo $${GAMMADIR:-/GAMMADIR/}) || ([ -d src/share/vm ]&&pwd); do cd ..; done)
44 HS_SRC_DIR=$(GAMMADIR)/src
45 HS_MAKE_DIR=$(GAMMADIR)/make
46 HS_BUILD_DIR=$(GAMMADIR)/build
47
48 ifeq ($(USER),)
49 USER=$(USERNAME)
50 endif
51
52 ifeq ($(HS_ALT_MAKE),)
53 ifneq ($(OPENJDK),true)
54 HS_ALT_MAKE=$(GAMMADIR)/make/closed
55 else
56 HS_ALT_MAKE=NO_SUCH_PATH
57 endif
58 endif
59
60 #
61 # Include alternate defs.make if it exists
62 #
63 -include $(HS_ALT_MAKE)/defs.make
64
65 # Default to verbose build logs (show all compile lines):
66 MAKE_VERBOSE=y
67
68 # Make macros for install files or preparing targets
69 CD=cd
70 CP=cp
71 ECHO=echo
72 GREP=grep
73 MKDIR=mkdir
74 MV=mv
75 PWD=pwd
76 RM=rm -f
77 SED=sed
78 TAR=tar
79 ZIPEXE=zip
80
81 define install-file
82 @$(MKDIR) -p $(@D)
83 @$(RM) $@
84 $(CP) $< $@
85 endef
86
87 # MacOS X strongly discourages 'cp -r' and provides 'cp -R' instead.
88 # May need to have a MacOS X specific definition of install-dir
89 # sometime in the future.
90 define install-dir
91 @$(MKDIR) -p $(@D)
92 @$(RM) -r $@
93 $(CP) -r $< $@
94 endef
95
96 define prep-target
97 @$(MKDIR) -p $(@D)
98 @$(RM) $@
99 endef
100
101 # Default values for JVM_VARIANT* variables if configure hasn't set
102 # it already.
103 ifeq ($(JVM_VARIANTS),)
104 ifeq ($(ZERO_BUILD), true)
105 ifeq ($(SHARK_BUILD), true)
106 JVM_VARIANTS:=zeroshark
107 JVM_VARIANT_ZEROSHARK:=true
108 else
109 JVM_VARIANTS:=zero
110 JVM_VARIANT_ZERO:=true
111 endif
112 else
113 # A default is needed
114 ifeq ($(BUILD_CLIENT_ONLY), true)
115 JVM_VARIANTS:=client
116 JVM_VARIANT_CLIENT:=true
117 endif
118 # Further defaults are platform and arch specific
119 endif
120 endif
121
122 # hotspot version definitions
123 include $(GAMMADIR)/make/jdk_version
124
125 # JDK_PREVIOUS_VERSION is only needed to facilitate standalone builds
126 ifeq ($(JDK_PREVIOUS_VERSION),)
127 JDK_PREVIOUS_VERSION=$(STANDALONE_JDK_PREVIOUS_VERSION)
128 endif
129 # Java versions needed
130 ifeq ($(VERSION_MAJOR),)
131 VERSION_MAJOR=$(STANDALONE_JDK_MAJOR_VER)
132 endif
133 ifeq ($(VERSION_MINOR),)
134 VERSION_MINOR=$(STANDALONE_JDK_MINOR_VER)
135 endif
136 ifeq ($(VERSION_SECURITY),)
137 VERSION_SECURITY=$(STANDALONE_JDK_SECURITY_VER)
138 endif
139 ifeq ($(VERSION_PATCH),)
140 VERSION_PATCH=$(STANDALONE_JDK_PATCH_VER)
141 endif
142 ifeq ($(VERSION_BUILD),)
143 VERSION_BUILD=0
144 endif
145 ifeq ($(VERSION_SHORT),)
146 VERSION_SHORT=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_SECURITY)
147 endif
148 ifeq ($(VERSION_STRING),)
149 # Note that this is an extremely rough and incorrect approximation of a correct version string.
150 VERSION_STRING=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_SECURITY)-internal
151 endif
152
153 ifneq ($(HOTSPOT_RELEASE_VERSION),)
154 # Allow old command-line overrides
155 HOTSPOT_VERSION_STRING := $(HOTSPOT_RELEASE_VERSION)
156 else
157 # Normally get from surrounding JDK build
158 HOTSPOT_VERSION_STRING := $(VERSION_STRING)
159 endif
160
161 ifneq ($(HOTSPOT_BUILD_VERSION),)
162 # If old command-lines variable exists, append to version string
163 HOTSPOT_VERSION_STRING := $(HOTSPOT_VERSION_STRING)-$(HOTSPOT_BUILD_VERSION)
164 else
165 ifeq ($(SPEC),)
166 # If building standalone, add -internal.
167 HOTSPOT_VERSION_STRING := $(HOTSPOT_VERSION_STRING)-internal
168 endif
169 endif
170
171 # Windows should have OS predefined
172 ifeq ($(OS),)
173 OS := $(shell uname -s)
174 ifneq ($(findstring BSD,$(OS)),)
175 OS=bsd
176 endif
177 ifeq ($(OS), Darwin)
178 OS=bsd
179 endif
180 HOST := $(shell uname -n)
181 endif
182
183 # If not SunOS, not Linux not BSD and not AIX, assume Windows
184 ifneq ($(OS), Linux)
185 ifneq ($(OS), SunOS)
186 ifneq ($(OS), bsd)
187 ifneq ($(OS), AIX)
188 OSNAME=windows
189 else
190 OSNAME=aix
191 endif
192 else
193 OSNAME=bsd
194 endif
195 else
196 OSNAME=solaris
197 endif
198 else
199 OSNAME=linux
200 endif
201
202 # Determinations of default make arguments and platform specific settings
203 MAKE_ARGS=
204
205 # ARCH_DATA_MODEL==64 is equivalent to LP64=1
206 ifeq ($(ARCH_DATA_MODEL), 64)
207 ifndef LP64
208 LP64 := 1
209 endif
210 endif
211
212 # Defaults set for product build
213 EXPORT_SUBDIR=
214
215 # Change default /java path if requested
216 ifneq ($(ALT_SLASH_JAVA),)
217 SLASH_JAVA=$(ALT_SLASH_JAVA)
218 endif
219
220 # Default OUTPUTDIR
221 OUTPUTDIR=$(HS_BUILD_DIR)/$(OSNAME)
222 ifneq ($(ALT_OUTPUTDIR),)
223 OUTPUTDIR=$(ALT_OUTPUTDIR)
224 endif
225
226 # Find latest promoted JDK area
227 JDK_IMPORT_PATH=$(SLASH_JAVA)/re/j2se/$(VERSION_STRING)/promoted/latest/binaries/$(PLATFORM)
228 ifneq ($(ALT_JDK_IMPORT_PATH),)
229 JDK_IMPORT_PATH=$(ALT_JDK_IMPORT_PATH)
230 endif
231
232 # Other parts of JDK build may require an import JDK that can be executed
233 # on the build host. For cross-compile builds we also need an import JDK
234 # that matches the target arch, so for that we set ALT_JDK_TARGET_IMPORT_PATH
235 ifneq ($(ALT_JDK_TARGET_IMPORT_PATH),)
236 JDK_IMPORT_PATH=$(ALT_JDK_TARGET_IMPORT_PATH)
237 endif
238
239 # Find JDK used for javac compiles
240 BOOTDIR=$(SLASH_JAVA)/re/j2se/$(JDK_PREVIOUS_VERSION)/latest/binaries/$(PLATFORM)
241 ifneq ($(ALT_BOOTDIR),)
242 BOOTDIR=$(ALT_BOOTDIR)
243 endif
244
245 # Select name of the export directory and honor ALT overrides
246 EXPORT_PATH=$(OUTPUTDIR)/export-$(PLATFORM)$(EXPORT_SUBDIR)
247 ifneq ($(ALT_EXPORT_PATH),)
248 EXPORT_PATH=$(ALT_EXPORT_PATH)
249 endif
250
251 # Default jdk image if one is created for you with create_jdk
252 JDK_IMAGE_DIR=$(OUTPUTDIR)/jdk-$(PLATFORM)
253 ifneq ($(ALT_JDK_IMAGE_DIR),)
254 JDK_IMAGE_DIR=$(ALT_JDK_IMAGE_DIR)
255 endif
256
257 # The platform dependent defs.make defines platform specific variable such
258 # as ARCH, EXPORT_LIST etc. We must place the include here after BOOTDIR is defined.
259 include $(GAMMADIR)/make/$(OSNAME)/makefiles/defs.make
260
261 # We are trying to put platform specific defintions
262 # files to make/$(OSNAME)/makefiles dictory. However
263 # some definitions are common for both linux and solaris,
264 # so we put them here.
265 ifneq ($(OSNAME),windows)
266 ABS_OUTPUTDIR := $(shell mkdir -p $(OUTPUTDIR); $(CD) $(OUTPUTDIR); $(PWD))
267 ABS_BOOTDIR := $(shell $(CD) $(BOOTDIR); $(PWD))
268 ABS_GAMMADIR := $(shell $(CD) $(GAMMADIR); $(PWD))
269 ABS_OS_MAKEFILE := $(shell $(CD) $(HS_MAKE_DIR)/$(OSNAME); $(PWD))/Makefile
270
271 # uname, HotSpot source directory, build directory and JDK use different names
272 # for CPU architectures.
273 # ARCH - uname output
274 # SRCARCH - where to find HotSpot cpu and os_cpu source files
275 # BUILDARCH - build directory
276 # LIBARCH - directory name in JDK/JRE
277
278 # Use uname output for SRCARCH, but deal with platform differences. If ARCH
279 # is not explicitly listed below, it is treated as x86.
280 SRCARCH ?= $(ARCH/$(filter sparc sparc64 ia64 amd64 x86_64 ppc ppc64 aarch64 zero,$(ARCH)))
281 ARCH/ = x86
282 ARCH/sparc = sparc
283 ARCH/sparc64= sparc
284 ARCH/ia64 = ia64
285 ARCH/amd64 = x86
286 ARCH/x86_64 = x86
287 ARCH/ppc64 = ppc
288 ARCH/ppc = ppc
289 ARCH/aarch64= aarch64
290 ARCH/zero = zero
291
292 # BUILDARCH is usually the same as SRCARCH, except for sparcv9
293 BUILDARCH ?= $(SRCARCH)
294 ifeq ($(BUILDARCH), x86)
295 ifdef LP64
296 BUILDARCH = amd64
297 else
298 BUILDARCH = i486
299 endif
300 endif
301 ifeq ($(BUILDARCH), sparc)
302 ifdef LP64
303 BUILDARCH = sparcv9
304 endif
305 endif
306 ifeq ($(BUILDARCH), ppc)
307 ifdef LP64
308 BUILDARCH = ppc64
309 endif
310 endif
311
312 # LIBARCH is 1:1 mapping from BUILDARCH
313 LIBARCH ?= $(LIBARCH/$(BUILDARCH))
314 LIBARCH/i486 = i386
315 LIBARCH/amd64 = amd64
316 LIBARCH/sparc = sparc
317 LIBARCH/sparcv9 = sparcv9
318 LIBARCH/ia64 = ia64
319 LIBARCH/ppc64 = ppc64
320 LIBARCH/aarch64 = aarch64
321 LIBARCH/zero = $(ZERO_LIBARCH)
322
323 LP64_ARCH = sparcv9 amd64 ia64 ppc64 aarch64 zero
324 endif
325
326 # Required make macro settings for all platforms
327 MAKE_ARGS += BOOTDIR=$(ABS_BOOTDIR)
328 MAKE_ARGS += OUTPUTDIR=$(ABS_OUTPUTDIR)
329 MAKE_ARGS += GAMMADIR=$(ABS_GAMMADIR)
330 MAKE_ARGS += MAKE_VERBOSE=$(MAKE_VERBOSE)
331 MAKE_ARGS += VERSION_STRING=$(VERSION_STRING)
332
333 MAKE_ARGS += BOOT_JDK_SOURCETARGET="$(BOOT_JDK_SOURCETARGET)"
334
335 # Various export sub directories
336 EXPORT_INCLUDE_DIR = $(EXPORT_PATH)/include
337 EXPORT_DOCS_DIR = $(EXPORT_PATH)/docs
338 EXPORT_LIB_DIR = $(EXPORT_PATH)/lib
339 EXPORT_BIN_DIR = $(EXPORT_PATH)/bin
340 EXPORT_LIB_ARCH_DIR = $(EXPORT_LIB_DIR)/$(LIBARCH)
341
342 # non-universal macosx builds need to appear universal
343 ifeq ($(OS_VENDOR), Darwin)
344 ifneq ($(MACOSX_UNIVERSAL), true)
345 EXPORT_LIB_ARCH_DIR = $(EXPORT_LIB_DIR)
346 endif
347 endif
348
349 # Common export list of files
350 EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jvmti.h
351 EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jvmticmlr.h
352 EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jni.h
353 EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/$(JDK_INCLUDE_SUBDIR)/jni_md.h
354 EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jmm.h
355
356 .PHONY: $(HS_ALT_MAKE)/defs.make