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 # 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 -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 # Get things from the platform file.
 116 COMPILER        = $(shell sed -n 's/^compiler[  ]*=[    ]*//p' $(PLATFORM_FILE))
 117 
 118 SIMPLE_DIRS     = \
 119         $(PLATFORM_DIR)/generated/dependencies \
 120         $(PLATFORM_DIR)/generated/adfiles \
 121         $(PLATFORM_DIR)/generated/jvmtifiles \
 122         $(PLATFORM_DIR)/generated/tracefiles
 123 
 124 TARGETS      = debug fastdebug optimized product
 125 SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS))
 126 
 127 # For dependencies and recursive makes.
 128 BUILDTREE_MAKE  = $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
 129 
 130 BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make trace.make sa.make
 131 
 132 BUILDTREE_VARS  = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
 133         SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
 134 
 135 # Define variables to be set in flags.make.
 136 # Default values are set in make/defs.make.
 137 ifeq ($(HOTSPOT_BUILD_VERSION),)
 138   HS_BUILD_VER=$(HOTSPOT_RELEASE_VERSION)
 139 else
 140   HS_BUILD_VER=$(HOTSPOT_RELEASE_VERSION)-$(HOTSPOT_BUILD_VERSION)
 141 endif
 142 # Set BUILD_USER from system-dependent hints:  $LOGNAME, $(whoami)
 143 ifndef HOTSPOT_BUILD_USER
 144   HOTSPOT_BUILD_USER := $(shell echo $$LOGNAME)
 145 endif
 146 ifndef HOTSPOT_BUILD_USER
 147   HOTSPOT_BUILD_USER := $(shell whoami)
 148 endif
 149 # Define HOTSPOT_VM_DISTRO based on settings in make/openjdk_distro
 150 # or make/hotspot_distro.
 151 ifndef HOTSPOT_VM_DISTRO
 152   ifeq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
 153     include $(GAMMADIR)/make/hotspot_distro
 154   else
 155     include $(GAMMADIR)/make/openjdk_distro
 156   endif
 157 endif
 158 
 159 # if hotspot-only build and/or OPENJDK isn't passed down, need to set OPENJDK
 160 ifndef OPENJDK
 161   ifneq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
 162     OPENJDK=true
 163   endif
 164 endif
 165 
 166 BUILDTREE_VARS += HOTSPOT_RELEASE_VERSION=$(HS_BUILD_VER) HOTSPOT_BUILD_VERSION=  JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION)
 167 
 168 BUILDTREE       = \
 169         $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_TARGETS) $(BUILDTREE_VARS)
 170 
 171 BUILDTREE_COMMENT       = echo "\# Generated by $(BUILDTREE_MAKE)"
 172 
 173 all:  $(SUBMAKE_DIRS)
 174 
 175 # Run make in each subdirectory recursively.
 176 $(SUBMAKE_DIRS): $(SIMPLE_DIRS) FORCE
 177         $(QUIETLY) [ -d $@ ] || { mkdir -p $@; }
 178         $(QUIETLY) cd $@ && $(BUILDTREE) TARGET=$(@F)
 179         $(QUIETLY) touch $@
 180 
 181 $(SIMPLE_DIRS):
 182         $(QUIETLY) mkdir -p $@
 183 
 184 # Convenience macro which takes a source relative path, applies $(1) to the
 185 # absolute path, and then replaces $(GAMMADIR) in the result with a
 186 # literal "$(GAMMADIR)/" suitable for inclusion in a Makefile.
 187 gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2)))
 188 
 189 # This bit is needed to enable local rebuilds.
 190 # Unless the makefile itself sets LP64, any environmental
 191 # setting of LP64 will interfere with the build.
 192 LP64_SETTING/32 = LP64 = \#empty
 193 LP64_SETTING/64 = LP64 = 1
 194 
 195 DATA_MODE/i486 = 32
 196 DATA_MODE/sparc = 32
 197 DATA_MODE/sparcv9 = 64
 198 DATA_MODE/amd64 = 64
 199 DATA_MODE/ppc64 = 64
 200 
 201 DATA_MODE = $(DATA_MODE/$(BUILDARCH))
 202 
 203 flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
 204         @echo Creating $@ ...
 205         $(QUIETLY) ( \
 206         $(BUILDTREE_COMMENT); \
 207         echo; \
 208         echo "Platform_file = $(PLATFORM_FILE)" | sed -e 's|$(HS_ALT_MAKE)|$$(HS_ALT_MAKE)|' -e 's|$(GAMMADIR)|$$(GAMMADIR)|'; \
 209         sed -n '/=/s/^ */Platform_/p' < $(PLATFORM_FILE); \
 210         echo; \
 211         echo "GAMMADIR = $(GAMMADIR)"; \
 212         echo "HS_ALT_MAKE = $(HS_ALT_MAKE)"; \
 213         echo "OSNAME = $(OSNAME)"; \
 214         echo "SYSDEFS = \$$(Platform_sysdefs)"; \
 215         echo "SRCARCH = $(SRCARCH)"; \
 216         echo "BUILDARCH = $(BUILDARCH)"; \
 217         echo "LIBARCH = $(LIBARCH)"; \
 218         echo "TARGET = $(TARGET)"; \
 219         echo "HS_BUILD_VER = $(HS_BUILD_VER)"; \
 220         echo "JRE_RELEASE_VER = $(JRE_RELEASE_VERSION)"; \
 221         echo "SA_BUILD_VERSION = $(HS_BUILD_VER)"; \
 222         echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \
 223         echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \
 224         echo "VENDOR = $(COMPANY_NAME)"; \
 225         echo "VENDOR_URL = $(VENDOR_URL)"; \
 226         echo "VENDOR_URL_BUG = $(VENDOR_URL_BUG)"; \
 227         echo "VENDOR_URL_VM_BUG = $(VENDOR_URL_VM_BUG)"; \
 228         echo "OPENJDK = $(OPENJDK)"; \
 229         echo "$(LP64_SETTING/$(DATA_MODE))"; \
 230         echo; \
 231         echo "# Used for platform dispatching"; \
 232         echo "TARGET_DEFINES  = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \
 233         echo "TARGET_DEFINES += -DTARGET_ARCH_\$$(Platform_arch)"; \
 234         echo "TARGET_DEFINES += -DTARGET_ARCH_MODEL_\$$(Platform_arch_model)"; \
 235         echo "TARGET_DEFINES += -DTARGET_OS_ARCH_\$$(Platform_os_arch)"; \
 236         echo "TARGET_DEFINES += -DTARGET_OS_ARCH_MODEL_\$$(Platform_os_arch_model)"; \
 237         echo "TARGET_DEFINES += -DTARGET_COMPILER_\$$(Platform_compiler)"; \
 238         echo "CFLAGS += \$$(TARGET_DEFINES)"; \
 239         echo; \
 240         echo "Src_Dirs_V = \\"; \
 241         sed 's/$$/ \\/;s|$(GAMMADIR)|$$(GAMMADIR)|' ../shared_dirs.lst; \
 242         echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \
 243         echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \
 244         echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
 245         echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
 246         echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
 247         echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
 248         echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
 249         echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
 250         echo; \
 251         echo "Src_Dirs_I = \\"; \
 252         echo "$(call gamma-path,altsrc,share/vm/prims) \\"; \
 253         echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \
 254         echo "$(call gamma-path,altsrc,share/vm) \\"; \
 255         echo "$(call gamma-path,commonsrc,share/vm) \\"; \
 256         echo "$(call gamma-path,altsrc,share/vm/precompiled) \\"; \
 257         echo "$(call gamma-path,commonsrc,share/vm/precompiled) \\"; \
 258         echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \
 259         echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \
 260         echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
 261         echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
 262         echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
 263         echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
 264         echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
 265         echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
 266         [ -n "$(CFLAGS_BROWSE)" ] && \
 267             echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \
 268         [ -n "$(ENABLE_FULL_DEBUG_SYMBOLS)" ] && \
 269             echo && echo "ENABLE_FULL_DEBUG_SYMBOLS = $(ENABLE_FULL_DEBUG_SYMBOLS)"; \
 270         [ -n "$(OBJCOPY)" ] && \
 271             echo && echo "OBJCOPY = $(OBJCOPY)"; \
 272         [ -n "$(STRIP_POLICY)" ] && \
 273             echo && echo "STRIP_POLICY = $(STRIP_POLICY)"; \
 274         [ -n "$(ZIP_DEBUGINFO_FILES)" ] && \
 275             echo && echo "ZIP_DEBUGINFO_FILES = $(ZIP_DEBUGINFO_FILES)"; \
 276         [ -n "$(ZIPEXE)" ] && \
 277             echo && echo "ZIPEXE = $(ZIPEXE)"; \
 278         [ -n "$(HOTSPOT_EXTRA_SYSDEFS)" ] && \
 279             echo && \
 280             echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \
 281             echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \
 282         [ -n "$(INCLUDE_TRACE)" ] && \
 283             echo && echo "INCLUDE_TRACE = $(INCLUDE_TRACE)"; \
 284         echo; \
 285         [ -n "$(SPEC)" ] && \
 286             echo "include $(SPEC)"; \
 287         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
 288         echo "include \$$(GAMMADIR)/make/excludeSrc.make"; \
 289         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
 290         ) > $@
 291 
 292 flags_vm.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
 293         @echo Creating $@ ...
 294         $(QUIETLY) ( \
 295         $(BUILDTREE_COMMENT); \
 296         echo; \
 297         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(TARGET).make"; \
 298         ) > $@
 299 
 300 ../shared_dirs.lst:  $(BUILDTREE_MAKE) $(GAMMADIR)/src/share/vm
 301         @echo Creating directory list $@
 302         $(QUIETLY) if [ -d $(HS_ALT_SRC)/share/vm ]; then \
 303           find $(HS_ALT_SRC)/share/vm/* -prune \
 304           -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
 305           \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; > $@; \
 306         fi;
 307         $(QUIETLY) find $(HS_COMMON_SRC)/share/vm/* -prune \
 308         -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
 309         \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; >> $@
 310 
 311 Makefile: $(BUILDTREE_MAKE)
 312         @echo Creating $@ ...
 313         $(QUIETLY) ( \
 314         $(BUILDTREE_COMMENT); \
 315         echo; \
 316         echo include flags.make; \
 317         echo; \
 318         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/top.make"; \
 319         ) > $@
 320 
 321 vm.make: $(BUILDTREE_MAKE)
 322         @echo Creating $@ ...
 323         $(QUIETLY) ( \
 324         $(BUILDTREE_COMMENT); \
 325         echo; \
 326         echo include flags.make; \
 327         echo include flags_vm.make; \
 328         echo; \
 329         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 330         ) > $@
 331 
 332 adlc.make: $(BUILDTREE_MAKE)
 333         @echo Creating $@ ...
 334         $(QUIETLY) ( \
 335         $(BUILDTREE_COMMENT); \
 336         echo; \
 337         echo include flags.make; \
 338         echo; \
 339         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 340         ) > $@
 341 
 342 jvmti.make: $(BUILDTREE_MAKE)
 343         @echo Creating $@ ...
 344         $(QUIETLY) ( \
 345         $(BUILDTREE_COMMENT); \
 346         echo; \
 347         echo include flags.make; \
 348         echo; \
 349         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 350         ) > $@
 351 
 352 trace.make: $(BUILDTREE_MAKE)
 353         @echo Creating $@ ...
 354         $(QUIETLY) ( \
 355         $(BUILDTREE_COMMENT); \
 356         echo; \
 357         echo include flags.make; \
 358         echo; \
 359         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 360         ) > $@
 361 
 362 sa.make: $(BUILDTREE_MAKE)
 363         @echo Creating $@ ...
 364         $(QUIETLY) ( \
 365         $(BUILDTREE_COMMENT); \
 366         echo; \
 367         echo include flags.make; \
 368         echo; \
 369         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 370         ) > $@
 371 
 372 FORCE:
 373 
 374 .PHONY:  all FORCE