1 #
   2 # Copyright (c) 2005, 2015, 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 # jfr.make      - generate jfr 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 -include $(SPEC)
  59 include $(GAMMADIR)/make/scm.make
  60 include $(GAMMADIR)/make/defs.make
  61 include $(GAMMADIR)/make/altsrc.make
  62 
  63 
  64 # 'gmake MAKE_VERBOSE=y' or 'gmake QUIETLY=' gives all the gory details.
  65 QUIETLY$(MAKE_VERBOSE)  = @
  66 
  67 ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
  68   PLATFORM_FILE = $(shell dirname $(shell dirname $(shell pwd)))/platform_zero
  69 else
  70   ifdef USE_SUNCC
  71     PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH).suncc
  72   else
  73     PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH)
  74     ALT_PLATFORM_FILE = $(HS_ALT_MAKE)/$(OS_FAMILY)/platform_$(BUILDARCH)
  75     PLATFORM_FILE := $(if $(wildcard $(ALT_PLATFORM_FILE)),$(ALT_PLATFORM_FILE),$(PLATFORM_FILE))
  76   endif
  77 endif
  78 
  79 # Allow overriding of the arch part of the directory but default
  80 # to BUILDARCH if nothing is specified
  81 ifeq ($(VARIANTARCH),)
  82   VARIANTARCH=$(BUILDARCH)
  83 endif
  84 
  85 ifdef FORCE_TIERED
  86 ifeq            ($(VARIANT),tiered)
  87 PLATFORM_DIR    = $(OS_FAMILY)_$(VARIANTARCH)_compiler2
  88 else
  89 PLATFORM_DIR    = $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT)
  90 endif
  91 else
  92 PLATFORM_DIR    = $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT)
  93 endif
  94 
  95 #
  96 # We do two levels of exclusion in the shared directory.
  97 # TOPLEVEL excludes are pruned, they are not recursively searched,
  98 # but lower level directories can be named without fear of collision.
  99 # ALWAYS excludes are excluded at any level in the directory tree.
 100 #
 101 
 102 ALWAYS_EXCLUDE_DIRS     = $(SCM_DIRS)
 103 
 104 ifeq            ($(VARIANT),tiered)
 105 TOPLEVEL_EXCLUDE_DIRS   = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name agent
 106 else
 107 ifeq            ($(VARIANT),compiler2)
 108 TOPLEVEL_EXCLUDE_DIRS   = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name c1 -o -name agent
 109 else
 110 # compiler1 and core use the same exclude list
 111 TOPLEVEL_EXCLUDE_DIRS   = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name opto -o -name libadt -o -name agent
 112 endif
 113 endif
 114 
 115 ifeq ($(ENABLE_JFR),false)
 116 ALWAYS_EXCLUDE_DIRS += -o -name jfr
 117 endif
 118 
 119 # Get things from the platform file.
 120 COMPILER        = $(shell sed -n 's/^compiler[  ]*=[    ]*//p' $(PLATFORM_FILE))
 121 
 122 SIMPLE_DIRS     = \
 123         $(PLATFORM_DIR)/generated/dependencies \
 124         $(PLATFORM_DIR)/generated/adfiles \
 125         $(PLATFORM_DIR)/generated/jvmtifiles \
 126         $(PLATFORM_DIR)/generated/jfrfiles
 127 
 128 TARGETS      = debug fastdebug optimized product
 129 SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS))
 130 
 131 # For dependencies and recursive makes.
 132 BUILDTREE_MAKE  = $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
 133 
 134 BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make jfr.make sa.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/sparc = 32
 201 DATA_MODE/sparcv9 = 64
 202 DATA_MODE/amd64 = 64
 203 DATA_MODE/ppc64 = 64
 204 DATA_MODE/aarch64 = 64
 205 
 206 DATA_MODE = $(DATA_MODE/$(BUILDARCH))
 207 
 208 ifeq ($(ENABLE_JFR), true)
 209   INCLUDE_JFR = 1
 210 else
 211   INCLUDE_JFR = 0
 212 endif
 213 
 214 
 215 flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
 216         @echo Creating $@ ...
 217         $(QUIETLY) ( \
 218         $(BUILDTREE_COMMENT); \
 219         echo; \
 220         echo "Platform_file = $(PLATFORM_FILE)" | sed -e 's|$(HS_ALT_MAKE)|$$(HS_ALT_MAKE)|' -e 's|$(GAMMADIR)|$$(GAMMADIR)|'; \
 221         sed -n '/=/s/^ */Platform_/p' < $(PLATFORM_FILE); \
 222         echo; \
 223         echo "GAMMADIR = $(GAMMADIR)"; \
 224         echo "HS_ALT_MAKE = $(HS_ALT_MAKE)"; \
 225         echo "OSNAME = $(OSNAME)"; \
 226         echo "SYSDEFS = \$$(Platform_sysdefs)"; \
 227         echo "SRCARCH = $(SRCARCH)"; \
 228         echo "BUILDARCH = $(BUILDARCH)"; \
 229         echo "LIBARCH = $(LIBARCH)"; \
 230         echo "TARGET = $(TARGET)"; \
 231         echo "HS_BUILD_VER = $(HS_BUILD_VER)"; \
 232         echo "JRE_RELEASE_VER = $(JRE_RELEASE_VERSION)"; \
 233         echo "SA_BUILD_VERSION = $(HS_BUILD_VER)"; \
 234         echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \
 235         echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \
 236         echo "VENDOR = $(COMPANY_NAME)"; \
 237         echo "VENDOR_URL = $(VENDOR_URL)"; \
 238         echo "VENDOR_URL_BUG = $(VENDOR_URL_BUG)"; \
 239         echo "VENDOR_URL_VM_BUG = $(VENDOR_URL_VM_BUG)"; \
 240         echo "OPENJDK = $(OPENJDK)"; \
 241         echo "$(LP64_SETTING/$(DATA_MODE))"; \
 242         echo; \
 243         echo "# Used for platform dispatching"; \
 244         echo "TARGET_DEFINES  = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \
 245         echo "TARGET_DEFINES += -DTARGET_ARCH_\$$(Platform_arch)"; \
 246         echo "TARGET_DEFINES += -DTARGET_ARCH_MODEL_\$$(Platform_arch_model)"; \
 247         echo "TARGET_DEFINES += -DTARGET_OS_ARCH_\$$(Platform_os_arch)"; \
 248         echo "TARGET_DEFINES += -DTARGET_OS_ARCH_MODEL_\$$(Platform_os_arch_model)"; \
 249         echo "TARGET_DEFINES += -DTARGET_COMPILER_\$$(Platform_compiler)"; \
 250         echo "CFLAGS += \$$(TARGET_DEFINES)"; \
 251         echo; \
 252         echo "Src_Dirs_V = \\"; \
 253         sed 's/$$/ \\/;s|$(GAMMADIR)|$$(GAMMADIR)|' ../shared_dirs.lst; \
 254         echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \
 255         echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \
 256         echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
 257         echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
 258         echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
 259         echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
 260         echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
 261         echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
 262         echo; \
 263         echo "Src_Dirs_I = \\"; \
 264         echo "$(call gamma-path,altsrc,share/vm/prims) \\"; \
 265         echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \
 266         echo "$(call gamma-path,altsrc,share/vm) \\"; \
 267         echo "$(call gamma-path,commonsrc,share/vm) \\"; \
 268         echo "$(call gamma-path,altsrc,share/vm/precompiled) \\"; \
 269         echo "$(call gamma-path,commonsrc,share/vm/precompiled) \\"; \
 270         echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \
 271         echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \
 272         echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
 273         echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
 274         echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
 275         echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
 276         echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
 277         echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
 278         [ -n "$(CFLAGS_BROWSE)" ] && \
 279             echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \
 280         [ -n "$(ENABLE_FULL_DEBUG_SYMBOLS)" ] && \
 281             echo && echo "ENABLE_FULL_DEBUG_SYMBOLS = $(ENABLE_FULL_DEBUG_SYMBOLS)"; \
 282         [ -n "$(OBJCOPY)" ] && \
 283             echo && echo "OBJCOPY = $(OBJCOPY)"; \
 284         [ -n "$(STRIP_POLICY)" ] && \
 285             echo && echo "STRIP_POLICY = $(STRIP_POLICY)"; \
 286         [ -n "$(ZIP_DEBUGINFO_FILES)" ] && \
 287             echo && echo "ZIP_DEBUGINFO_FILES = $(ZIP_DEBUGINFO_FILES)"; \
 288         [ -n "$(ZIPEXE)" ] && \
 289             echo && echo "ZIPEXE = $(ZIPEXE)"; \
 290         [ -n "$(HOTSPOT_EXTRA_SYSDEFS)" ] && \
 291             echo && \
 292             echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \
 293             echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \
 294         echo && echo "CFLAGS += -DINCLUDE_JFR=$(INCLUDE_JFR)"; \
 295         echo; \
 296         [ -n "$(SPEC)" ] && \
 297             echo "include $(SPEC)"; \
 298         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
 299         echo "include \$$(GAMMADIR)/make/excludeSrc.make"; \
 300         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
 301         ) > $@
 302 
 303 flags_vm.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
 304         @echo Creating $@ ...
 305         $(QUIETLY) ( \
 306         $(BUILDTREE_COMMENT); \
 307         echo; \
 308         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(TARGET).make"; \
 309         ) > $@
 310 
 311 ../shared_dirs.lst:  $(BUILDTREE_MAKE) $(GAMMADIR)/src/share/vm
 312         @echo Creating directory list $@
 313         $(QUIETLY) if [ -d $(HS_ALT_SRC)/share/vm ]; then \
 314           find $(HS_ALT_SRC)/share/vm/* -prune \
 315           -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
 316           \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; > $@; \
 317         fi;
 318         $(QUIETLY) find $(HS_COMMON_SRC)/share/vm/* -prune \
 319         -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
 320         \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; >> $@
 321 
 322 Makefile: $(BUILDTREE_MAKE)
 323         @echo Creating $@ ...
 324         $(QUIETLY) ( \
 325         $(BUILDTREE_COMMENT); \
 326         echo; \
 327         echo include flags.make; \
 328         echo; \
 329         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/top.make"; \
 330         ) > $@
 331 
 332 vm.make: $(BUILDTREE_MAKE)
 333         @echo Creating $@ ...
 334         $(QUIETLY) ( \
 335         $(BUILDTREE_COMMENT); \
 336         echo; \
 337         echo include flags.make; \
 338         echo include flags_vm.make; \
 339         echo; \
 340         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 341         ) > $@
 342 
 343 adlc.make: $(BUILDTREE_MAKE)
 344         @echo Creating $@ ...
 345         $(QUIETLY) ( \
 346         $(BUILDTREE_COMMENT); \
 347         echo; \
 348         echo include flags.make; \
 349         echo; \
 350         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 351         ) > $@
 352 
 353 jvmti.make: $(BUILDTREE_MAKE)
 354         @echo Creating $@ ...
 355         $(QUIETLY) ( \
 356         $(BUILDTREE_COMMENT); \
 357         echo; \
 358         echo include flags.make; \
 359         echo; \
 360         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 361         ) > $@
 362 
 363 jfr.make: $(BUILDTREE_MAKE)
 364         @echo Creating $@ ...
 365         $(QUIETLY) ( \
 366         $(BUILDTREE_COMMENT); \
 367         echo; \
 368         echo include flags.make; \
 369         echo; \
 370         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 371         ) > $@
 372 
 373 sa.make: $(BUILDTREE_MAKE)
 374         @echo Creating $@ ...
 375         $(QUIETLY) ( \
 376         $(BUILDTREE_COMMENT); \
 377         echo; \
 378         echo include flags.make; \
 379         echo; \
 380         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 381         ) > $@
 382 
 383 FORCE:
 384 
 385 .PHONY:  all FORCE