1 #
   2 # Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
   3 # Copyright 2019 Red Hat Inc.
   4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5 #
   6 # This code is free software; you can redistribute it and/or modify it
   7 # under the terms of the GNU General Public License version 2 only, as
   8 # published by the Free Software Foundation.
   9 #
  10 # This code is distributed in the hope that it will be useful, but WITHOUT
  11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13 # version 2 for more details (a copy is included in the LICENSE file that
  14 # accompanied this code).
  15 #
  16 # You should have received a copy of the GNU General Public License version
  17 # 2 along with this work; if not, write to the Free Software Foundation,
  18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19 #
  20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21 # or visit www.oracle.com if you need additional information or have any
  22 # questions.
  23 #
  24 #
  25 
  26 # Usage:
  27 #
  28 # $(MAKE) -f buildtree.make SRCARCH=srcarch BUILDARCH=buildarch LIBARCH=libarch
  29 #         GAMMADIR=dir OS_FAMILY=os VARIANT=variant
  30 #
  31 # The macros ARCH, GAMMADIR, OS_FAMILY and VARIANT must be defined in the
  32 # environment or on the command-line:
  33 #
  34 # ARCH          - sparc, i486, ... HotSpot cpu and os_cpu source directory
  35 # BUILDARCH     - build directory
  36 # LIBARCH       - the corresponding directory in JDK/JRE
  37 # GAMMADIR      - top of workspace
  38 # OS_FAMILY     - operating system
  39 # VARIANT       - core, compiler1, compiler2, or tiered
  40 # HOTSPOT_RELEASE_VERSION - <major>.<minor>-b<nn> (11.0-b07)
  41 # HOTSPOT_BUILD_VERSION   - internal, internal-$(USER_RELEASE_SUFFIX) or empty
  42 # JRE_RELEASE_VERSION     - <major>.<minor>.<micro> (1.7.0)
  43 #
  44 # Builds the directory trees with makefiles plus some convenience files in
  45 # each directory:
  46 #
  47 # Makefile      - for "make foo"
  48 # flags.make    - with macro settings
  49 # vm.make       - to support making "$(MAKE) -v vm.make" in makefiles
  50 # adlc.make     -
  51 # trace.make    - generate tracing event and type definitions
  52 # jvmti.make    - generate JVMTI bindings from the spec (JSR-163)
  53 # sa.make       - generate SA jar file and natives
  54 #
  55 # The makefiles are split this way so that "make foo" will run faster by not
  56 # having to read the dependency files for the vm.
  57 
  58 # needs to be set here since this Makefile doesn't include defs.make
  59 OS_VENDOR:=$(shell uname -s)
  60 
  61 -include $(SPEC)
  62 include $(GAMMADIR)/make/scm.make
  63 include $(GAMMADIR)/make/defs.make
  64 include $(GAMMADIR)/make/altsrc.make
  65 
  66 
  67 # 'gmake MAKE_VERBOSE=y' or 'gmake QUIETLY=' gives all the gory details.
  68 QUIETLY$(MAKE_VERBOSE)  = @
  69 
  70 ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
  71   PLATFORM_FILE = $(shell dirname $(shell dirname $(shell pwd)))/platform_zero
  72 else
  73   ifdef USE_SUNCC
  74     PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH).suncc
  75   else
  76     PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH)
  77   endif
  78 endif
  79 
  80 # Allow overriding of the arch part of the directory but default
  81 # to BUILDARCH if nothing is specified
  82 ifeq ($(VARIANTARCH),)
  83   VARIANTARCH=$(BUILDARCH)
  84 endif
  85 
  86 ifdef FORCE_TIERED
  87 ifeq            ($(VARIANT),tiered)
  88 PLATFORM_DIR    = $(OS_FAMILY)_$(VARIANTARCH)_compiler2
  89 else
  90 PLATFORM_DIR    = $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT)
  91 endif
  92 else
  93 PLATFORM_DIR    = $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT)
  94 endif
  95 
  96 #
  97 # We do two levels of exclusion in the shared directory.
  98 # TOPLEVEL excludes are pruned, they are not recursively searched,
  99 # but lower level directories can be named without fear of collision.
 100 # ALWAYS excludes are excluded at any level in the directory tree.
 101 #
 102 
 103 ALWAYS_EXCLUDE_DIRS     = $(SCM_DIRS)
 104 
 105 ifeq            ($(VARIANT),tiered)
 106 TOPLEVEL_EXCLUDE_DIRS   = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name agent
 107 else
 108 ifeq            ($(VARIANT),compiler2)
 109 TOPLEVEL_EXCLUDE_DIRS   = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name c1 -o -name agent
 110 else
 111 # compiler1 and core use the same exclude list
 112 TOPLEVEL_EXCLUDE_DIRS   = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name opto -o -name libadt -o -name agent
 113 endif
 114 endif
 115 
 116 # Get things from the platform file.
 117 COMPILER        = $(shell sed -n 's/^compiler[  ]*=[    ]*//p' $(PLATFORM_FILE))
 118 
 119 # dtracefiles is used on BSD versions that implement Dtrace (like MacOS X)
 120 SIMPLE_DIRS     = \
 121         $(PLATFORM_DIR)/generated/dependencies \
 122         $(PLATFORM_DIR)/generated/adfiles \
 123         $(PLATFORM_DIR)/generated/jvmtifiles \
 124         $(PLATFORM_DIR)/generated/tracefiles \
 125         $(PLATFORM_DIR)/generated/dtracefiles
 126 
 127 TARGETS      = debug fastdebug optimized product
 128 SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS))
 129 
 130 # For dependencies and recursive makes.
 131 BUILDTREE_MAKE  = $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
 132 
 133 # dtrace.make is used on BSD versions that implement Dtrace (like MacOS X)
 134 BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make trace.make sa.make dtrace.make
 135 
 136 BUILDTREE_VARS  = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
 137         SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
 138 
 139 # Define variables to be set in flags.make.
 140 # Default values are set in make/defs.make.
 141 ifeq ($(HOTSPOT_BUILD_VERSION),)
 142   HS_BUILD_VER=$(HOTSPOT_RELEASE_VERSION)
 143 else
 144   HS_BUILD_VER=$(HOTSPOT_RELEASE_VERSION)-$(HOTSPOT_BUILD_VERSION)
 145 endif
 146 # Set BUILD_USER from system-dependent hints:  $LOGNAME, $(whoami)
 147 ifndef HOTSPOT_BUILD_USER
 148   HOTSPOT_BUILD_USER := $(shell echo $$LOGNAME)
 149 endif
 150 ifndef HOTSPOT_BUILD_USER
 151   HOTSPOT_BUILD_USER := $(shell whoami)
 152 endif
 153 # Define HOTSPOT_VM_DISTRO based on settings in make/openjdk_distro
 154 # or make/hotspot_distro.
 155 ifndef HOTSPOT_VM_DISTRO
 156   ifeq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
 157     include $(GAMMADIR)/make/hotspot_distro
 158   else
 159     include $(GAMMADIR)/make/openjdk_distro
 160   endif
 161 endif
 162 
 163 # if hotspot-only build and/or OPENJDK isn't passed down, need to set OPENJDK
 164 ifndef OPENJDK
 165   ifneq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
 166     OPENJDK=true
 167   endif
 168 endif
 169 
 170 BUILDTREE_VARS += HOTSPOT_RELEASE_VERSION=$(HS_BUILD_VER) HOTSPOT_BUILD_VERSION=  JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION)
 171 
 172 BUILDTREE       = \
 173         $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_TARGETS) $(BUILDTREE_VARS)
 174 
 175 BUILDTREE_COMMENT       = echo "\# Generated by $(BUILDTREE_MAKE)"
 176 
 177 all:  $(SUBMAKE_DIRS)
 178 
 179 # Run make in each subdirectory recursively.
 180 $(SUBMAKE_DIRS): $(SIMPLE_DIRS) FORCE
 181         $(QUIETLY) [ -d $@ ] || { mkdir -p $@; }
 182         $(QUIETLY) cd $@ && $(BUILDTREE) TARGET=$(@F)
 183         $(QUIETLY) touch $@
 184 
 185 $(SIMPLE_DIRS):
 186         $(QUIETLY) mkdir -p $@
 187 
 188 # Convenience macro which takes a source relative path, applies $(1) to the
 189 # absolute path, and then replaces $(GAMMADIR) in the result with a
 190 # literal "$(GAMMADIR)/" suitable for inclusion in a Makefile.
 191 gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2)))
 192 
 193 # This bit is needed to enable local rebuilds.
 194 # Unless the makefile itself sets LP64, any environmental
 195 # setting of LP64 will interfere with the build.
 196 LP64_SETTING/32 = LP64 = \#empty
 197 LP64_SETTING/64 = LP64 = 1
 198 
 199 DATA_MODE/i486 = 32
 200 DATA_MODE/amd64 = 64
 201 
 202 DATA_MODE = $(DATA_MODE/$(BUILDARCH))
 203 
 204 flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
 205         @echo Creating $@ ...
 206         $(QUIETLY) ( \
 207         $(BUILDTREE_COMMENT); \
 208         echo; \
 209         echo "Platform_file = $(PLATFORM_FILE)" | sed 's|$(GAMMADIR)|$$(GAMMADIR)|'; \
 210         sed -n '/=/s/^ */Platform_/p' < $(PLATFORM_FILE); \
 211         echo; \
 212         echo "GAMMADIR = $(GAMMADIR)"; \
 213         echo "HS_ALT_MAKE = $(HS_ALT_MAKE)"; \
 214         echo "OSNAME = $(OSNAME)"; \
 215         echo "SYSDEFS = \$$(Platform_sysdefs)"; \
 216         echo "SRCARCH = $(SRCARCH)"; \
 217         echo "BUILDARCH = $(BUILDARCH)"; \
 218         echo "LIBARCH = $(LIBARCH)"; \
 219         echo "TARGET = $(TARGET)"; \
 220         echo "HS_BUILD_VER = $(HS_BUILD_VER)"; \
 221         echo "JRE_RELEASE_VER = $(JRE_RELEASE_VERSION)"; \
 222         echo "SA_BUILD_VERSION = $(HS_BUILD_VER)"; \
 223         echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \
 224         echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \
 225         echo "VENDOR = $(COMPANY_NAME)"; \
 226         echo "VENDOR_URL = $(VENDOR_URL)"; \
 227         echo "VENDOR_URL_BUG = $(VENDOR_URL_BUG)"; \
 228         echo "VENDOR_URL_VM_BUG = $(VENDOR_URL_VM_BUG)"; \
 229         echo "OPENJDK = $(OPENJDK)"; \
 230         echo "$(LP64_SETTING/$(DATA_MODE))"; \
 231         echo; \
 232         echo "# Used for platform dispatching"; \
 233         echo "TARGET_DEFINES  = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \
 234         echo "TARGET_DEFINES += -DTARGET_ARCH_\$$(Platform_arch)"; \
 235         echo "TARGET_DEFINES += -DTARGET_ARCH_MODEL_\$$(Platform_arch_model)"; \
 236         echo "TARGET_DEFINES += -DTARGET_OS_ARCH_\$$(Platform_os_arch)"; \
 237         echo "TARGET_DEFINES += -DTARGET_OS_ARCH_MODEL_\$$(Platform_os_arch_model)"; \
 238         echo "TARGET_DEFINES += -DTARGET_COMPILER_\$$(Platform_compiler)"; \
 239         echo "CFLAGS += \$$(TARGET_DEFINES)"; \
 240         echo; \
 241         echo "Src_Dirs_V = \\"; \
 242         sed 's/$$/ \\/;s|$(GAMMADIR)|$$(GAMMADIR)|' ../shared_dirs.lst; \
 243         echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \
 244         echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \
 245         echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
 246         echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
 247         echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
 248         echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
 249         echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
 250         echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
 251         echo; \
 252         echo "Src_Dirs_I = \\"; \
 253         echo "$(call gamma-path,altsrc,share/vm/prims) \\"; \
 254         echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \
 255         echo "$(call gamma-path,altsrc,share/vm) \\"; \
 256         echo "$(call gamma-path,commonsrc,share/vm) \\"; \
 257         echo "$(call gamma-path,altsrc,share/vm/precompiled) \\"; \
 258         echo "$(call gamma-path,commonsrc,share/vm/precompiled) \\"; \
 259         echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \
 260         echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \
 261         echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
 262         echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
 263         echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
 264         echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
 265         echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
 266         echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
 267         [ -n "$(CFLAGS_BROWSE)" ] && \
 268             echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \
 269         [ -n "$(ENABLE_FULL_DEBUG_SYMBOLS)" ] && \
 270             echo && echo "ENABLE_FULL_DEBUG_SYMBOLS = $(ENABLE_FULL_DEBUG_SYMBOLS)"; \
 271         [ -n "$(OBJCOPY)" ] && \
 272             echo && echo "OBJCOPY = $(OBJCOPY)"; \
 273         [ -n "$(STRIP_POLICY)" ] && \
 274             echo && echo "STRIP_POLICY = $(STRIP_POLICY)"; \
 275         [ -n "$(ZIP_DEBUGINFO_FILES)" ] && \
 276             echo && echo "ZIP_DEBUGINFO_FILES = $(ZIP_DEBUGINFO_FILES)"; \
 277         [ -n "$(ZIPEXE)" ] && \
 278             echo && echo "ZIPEXE = $(ZIPEXE)"; \
 279         [ -n "$(HOTSPOT_EXTRA_SYSDEFS)" ] && \
 280             echo && \
 281             echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \
 282             echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \
 283         echo; \
 284         [ -n "$(SPEC)" ] && \
 285             echo "include $(SPEC)"; \
 286         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
 287         echo "include \$$(GAMMADIR)/make/excludeSrc.make"; \
 288         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
 289         ) > $@
 290 
 291 flags_vm.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
 292         @echo Creating $@ ...
 293         $(QUIETLY) ( \
 294         $(BUILDTREE_COMMENT); \
 295         echo; \
 296         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(TARGET).make"; \
 297         ) > $@
 298 
 299 ../shared_dirs.lst:  $(BUILDTREE_MAKE) $(GAMMADIR)/src/share/vm
 300         @echo Creating directory list $@
 301         $(QUIETLY) if [ -d $(HS_ALT_SRC)/share/vm ]; then \
 302           find $(HS_ALT_SRC)/share/vm/* -prune \
 303           -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
 304           \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; > $@; \
 305         fi;
 306         $(QUIETLY) find $(HS_COMMON_SRC)/share/vm/* -prune \
 307         -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
 308         \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; >> $@
 309 
 310 Makefile: $(BUILDTREE_MAKE)
 311         @echo Creating $@ ...
 312         $(QUIETLY) ( \
 313         $(BUILDTREE_COMMENT); \
 314         echo; \
 315         echo include flags.make; \
 316         echo; \
 317         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/top.make"; \
 318         ) > $@
 319 
 320 vm.make: $(BUILDTREE_MAKE)
 321         @echo Creating $@ ...
 322         $(QUIETLY) ( \
 323         $(BUILDTREE_COMMENT); \
 324         echo; \
 325         echo include flags.make; \
 326         echo include flags_vm.make; \
 327         echo; \
 328         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 329         ) > $@
 330 
 331 adlc.make: $(BUILDTREE_MAKE)
 332         @echo Creating $@ ...
 333         $(QUIETLY) ( \
 334         $(BUILDTREE_COMMENT); \
 335         echo; \
 336         echo include flags.make; \
 337         echo; \
 338         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 339         ) > $@
 340 
 341 jvmti.make: $(BUILDTREE_MAKE)
 342         @echo Creating $@ ...
 343         $(QUIETLY) ( \
 344         $(BUILDTREE_COMMENT); \
 345         echo; \
 346         echo include flags.make; \
 347         echo; \
 348         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 349         ) > $@
 350 
 351 trace.make: $(BUILDTREE_MAKE)
 352         @echo Creating $@ ...
 353         $(QUIETLY) ( \
 354         $(BUILDTREE_COMMENT); \
 355         echo; \
 356         echo include flags.make; \
 357         echo; \
 358         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 359         ) > $@
 360 
 361 sa.make: $(BUILDTREE_MAKE)
 362         @echo Creating $@ ...
 363         $(QUIETLY) ( \
 364         $(BUILDTREE_COMMENT); \
 365         echo; \
 366         echo include flags.make; \
 367         echo; \
 368         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 369         ) > $@
 370 
 371 dtrace.make: $(BUILDTREE_MAKE)
 372         @echo Creating $@ ...
 373         $(QUIETLY) ( \
 374         $(BUILDTREE_COMMENT); \
 375         echo; \
 376         echo include flags.make; \
 377         echo; \
 378         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 379         ) > $@
 380 
 381 FORCE:
 382 
 383 .PHONY:  all FORCE