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/amd64 = 64
 197 DATA_MODE/sparc = 32
 198 DATA_MODE/sparcv9 = 64
 199 DATA_MODE/ppc64 = 64
 200 DATA_MODE/aarch32 = 32
 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 -e 's|$(HS_ALT_MAKE)|$$(HS_ALT_MAKE)|' -e '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         [ -n "$(INCLUDE_TRACE)" ] && \
 284             echo && echo "INCLUDE_TRACE = $(INCLUDE_TRACE)"; \
 285         echo; \
 286         [ -n "$(SPEC)" ] && \
 287             echo "include $(SPEC)"; \
 288         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
 289         echo "include \$$(GAMMADIR)/make/excludeSrc.make"; \
 290         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
 291         ) > $@
 292 
 293 flags_vm.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
 294         @echo Creating $@ ...
 295         $(QUIETLY) ( \
 296         $(BUILDTREE_COMMENT); \
 297         echo; \
 298         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(TARGET).make"; \
 299         ) > $@
 300 
 301 ../shared_dirs.lst:  $(BUILDTREE_MAKE) $(GAMMADIR)/src/share/vm
 302         @echo Creating directory list $@
 303         $(QUIETLY) if [ -d $(HS_ALT_SRC)/share/vm ]; then \
 304           find $(HS_ALT_SRC)/share/vm/* -prune \
 305           -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
 306           \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; > $@; \
 307         fi;
 308         $(QUIETLY) find $(HS_COMMON_SRC)/share/vm/* -prune \
 309         -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
 310         \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; >> $@
 311 
 312 Makefile: $(BUILDTREE_MAKE)
 313         @echo Creating $@ ...
 314         $(QUIETLY) ( \
 315         $(BUILDTREE_COMMENT); \
 316         echo; \
 317         echo include flags.make; \
 318         echo; \
 319         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/top.make"; \
 320         ) > $@
 321 
 322 vm.make: $(BUILDTREE_MAKE)
 323         @echo Creating $@ ...
 324         $(QUIETLY) ( \
 325         $(BUILDTREE_COMMENT); \
 326         echo; \
 327         echo include flags.make; \
 328         echo include flags_vm.make; \
 329         echo; \
 330         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 331         ) > $@
 332 
 333 adlc.make: $(BUILDTREE_MAKE)
 334         @echo Creating $@ ...
 335         $(QUIETLY) ( \
 336         $(BUILDTREE_COMMENT); \
 337         echo; \
 338         echo include flags.make; \
 339         echo; \
 340         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 341         ) > $@
 342 
 343 jvmti.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 trace.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 sa.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 FORCE:
 374 
 375 .PHONY:  all FORCE