1 #
   2 # Copyright (c) 2000, 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 # Usage:
  26 #
  27 # $(MAKE) -f buildtree.make ARCH=arch BUILDARCH=buildarch LIBARCH=libarch
  28 #         GAMMADIR=dir OS_FAMILY=os VARIANT=variant
  29 #
  30 # The macros ARCH, GAMMADIR, OS_FAMILY and VARIANT must be defined in the
  31 # environment or on the command-line:
  32 #
  33 # ARCH          - sparc, i486, ... HotSpot cpu and os_cpu source directory
  34 # BUILDARCH     - build directory
  35 # LIBARCH       - the corresponding directory in JDK/JRE
  36 # GAMMADIR      - top of workspace
  37 # OS_FAMILY     - operating system
  38 # VARIANT       - core, compiler1, compiler2, or tiered
  39 # VERSION_STRING - the JDK version string as specified by JEP-223
  40 # HOTSPOT_VERSION_STRING - the same as VERSION_STRING, unless overridden by a standalone build
  41 #
  42 # Builds the directory trees with makefiles plus some convenience files in
  43 # each directory:
  44 #
  45 # Makefile      - for "make foo"
  46 # flags.make    - with macro settings
  47 # vm.make       - to support making "$(MAKE) -v vm.make" in makefiles
  48 # adlc.make     -
  49 # trace.make    - generate tracing event and type definitions
  50 # jvmti.make    - generate JVMTI bindings from the spec (JSR-163)
  51 #
  52 # The makefiles are split this way so that "make foo" will run faster by not
  53 # having to read the dependency files for the vm.
  54 
  55 -include $(SPEC)
  56 include $(GAMMADIR)/make/scm.make
  57 include $(GAMMADIR)/make/defs.make
  58 include $(GAMMADIR)/make/altsrc.make
  59 
  60 
  61 # 'gmake MAKE_VERBOSE=y' or 'gmake QUIETLY=' gives all the gory details.
  62 QUIETLY$(MAKE_VERBOSE)  = @
  63 
  64 ### maye ARCH_XXX instead?
  65 ifdef USE_GCC
  66 PLATFORM_FILE   = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH).gcc
  67 GCC_LIB         = /usr/local/lib
  68 else
  69 PLATFORM_FILE   = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH)
  70 GCC_LIB         =
  71 endif
  72 
  73 ifdef FORCE_TIERED
  74 ifeq            ($(VARIANT),tiered)
  75 PLATFORM_DIR    = $(OS_FAMILY)_$(BUILDARCH)_compiler2
  76 else
  77 PLATFORM_DIR    = $(OS_FAMILY)_$(BUILDARCH)_$(VARIANT)
  78 endif
  79 else
  80 PLATFORM_DIR    = $(OS_FAMILY)_$(BUILDARCH)_$(VARIANT)
  81 endif
  82 
  83 #
  84 # We do two levels of exclusion in the shared directory.
  85 # TOPLEVEL excludes are pruned, they are not recursively searched,
  86 # but lower level directories can be named without fear of collision.
  87 # ALWAYS excludes are excluded at any level in the directory tree.
  88 #
  89 
  90 ALWAYS_EXCLUDE_DIRS     = $(SCM_DIRS)
  91 
  92 ifeq            ($(VARIANT),tiered)
  93 TOPLEVEL_EXCLUDE_DIRS   = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name agent
  94 else
  95 ifeq            ($(VARIANT),compiler2)
  96 TOPLEVEL_EXCLUDE_DIRS   = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name c1 -o -name agent
  97 else
  98 # compiler1 and core use the same exclude list
  99 TOPLEVEL_EXCLUDE_DIRS   = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name opto -o -name libadt -o -name agent
 100 endif
 101 endif
 102 
 103 # Get things from the platform file.
 104 COMPILER        = $(shell sed -n 's/^compiler[  ]*=[    ]*//p' $(PLATFORM_FILE))
 105 
 106 SIMPLE_DIRS     = \
 107         $(PLATFORM_DIR)/generated/dependencies \
 108         $(PLATFORM_DIR)/generated/adfiles \
 109         $(PLATFORM_DIR)/generated/jvmtifiles \
 110         $(PLATFORM_DIR)/generated/tracefiles
 111 
 112 TARGETS      = debug fastdebug optimized product
 113 SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS))
 114 
 115 # For dependencies and recursive makes.
 116 BUILDTREE_MAKE  = $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
 117 
 118 BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make trace.make dtrace.make
 119 
 120 BUILDTREE_VARS  = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
 121         ARCH=$(ARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
 122 
 123 # Define variables to be set in flags.make.
 124 # Default values are set in make/defs.make.
 125 
 126 # Set BUILD_USER from system-dependent hints:  $LOGNAME, $(whoami)
 127 ifndef HOTSPOT_BUILD_USER
 128   HOTSPOT_BUILD_USER := $(shell echo $$LOGNAME)
 129 endif
 130 ifndef HOTSPOT_BUILD_USER
 131   HOTSPOT_BUILD_USER := $(shell whoami)
 132 endif
 133 # Define HOTSPOT_VM_DISTRO based on settings in make/openjdk_distro
 134 # or make/hotspot_distro.
 135 ifndef HOTSPOT_VM_DISTRO
 136   ifeq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
 137     include $(GAMMADIR)/make/hotspot_distro
 138   else
 139     include $(GAMMADIR)/make/openjdk_distro
 140   endif
 141 endif
 142 
 143 # if hotspot-only build and/or OPENJDK isn't passed down, need to set OPENJDK
 144 ifndef OPENJDK
 145   ifneq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
 146     OPENJDK=true
 147   endif
 148 endif
 149 
 150 BUILDTREE_VARS += HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) VERSION_STRING=$(VERSION_STRING)
 151 
 152 BUILDTREE       = \
 153         $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_TARGETS) $(BUILDTREE_VARS)
 154 
 155 BUILDTREE_COMMENT       = echo "\# Generated by $(BUILDTREE_MAKE)"
 156 
 157 all:  $(SUBMAKE_DIRS)
 158 
 159 # Run make in each subdirectory recursively.
 160 $(SUBMAKE_DIRS): $(SIMPLE_DIRS) FORCE
 161         $(QUIETLY) [ -d $@ ] || { mkdir -p $@; }
 162         +$(QUIETLY) cd $@ && $(BUILDTREE) TARGET=$(@F)
 163         $(QUIETLY) touch $@
 164 
 165 $(SIMPLE_DIRS):
 166         $(QUIETLY) mkdir -p $@
 167 
 168 # Convenience macro which takes a source relative path, applies $(1) to the
 169 # absolute path, and then replaces $(GAMMADIR) in the result with a
 170 # literal "$(GAMMADIR)/" suitable for inclusion in a Makefile.
 171 gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2)))
 172 
 173 # This bit is needed to enable local rebuilds.
 174 # Unless the makefile itself sets LP64, any environmental
 175 # setting of LP64 will interfere with the build.
 176 LP64_SETTING/32 = LP64 = \#empty
 177 LP64_SETTING/64 = LP64 = 1
 178 
 179 DATA_MODE/i486 = 32
 180 DATA_MODE/sparc = 32
 181 DATA_MODE/sparcv9 = 64
 182 DATA_MODE/amd64 = 64
 183 
 184 DATA_MODE = $(DATA_MODE/$(BUILDARCH))
 185 
 186 flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
 187         @echo $(LOG_INFO) Creating $@ ...
 188         $(QUIETLY) ( \
 189         $(BUILDTREE_COMMENT); \
 190         echo; \
 191         echo "Platform_file = $(PLATFORM_FILE)" | sed 's|$(GAMMADIR)|$$(GAMMADIR)|'; \
 192         sed -n '/=/s/^ */Platform_/p' < $(PLATFORM_FILE); \
 193         echo; \
 194         echo "GAMMADIR = $(GAMMADIR)"; \
 195         echo "SYSDEFS = \$$(Platform_sysdefs)"; \
 196         echo "SRCARCH = $(ARCH)"; \
 197         echo "BUILDARCH = $(BUILDARCH)"; \
 198         echo "LIBARCH = $(LIBARCH)"; \
 199         echo "TARGET = $(TARGET)"; \
 200         echo "HOTSPOT_VERSION_STRING = $(HOTSPOT_VERSION_STRING)"; \
 201         echo "VERSION_STRING = $(VERSION_STRING)"; \
 202         echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \
 203         echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \
 204         echo "OPENJDK = $(OPENJDK)"; \
 205         echo "$(LP64_SETTING/$(DATA_MODE))"; \
 206         echo; \
 207         echo "# Used for platform dispatching"; \
 208         echo "TARGET_DEFINES  = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \
 209         echo "TARGET_DEFINES += -DTARGET_ARCH_\$$(Platform_arch)"; \
 210         echo "TARGET_DEFINES += -DTARGET_ARCH_MODEL_\$$(Platform_arch_model)"; \
 211         echo "TARGET_DEFINES += -DTARGET_OS_ARCH_\$$(Platform_os_arch)"; \
 212         echo "TARGET_DEFINES += -DTARGET_OS_ARCH_MODEL_\$$(Platform_os_arch_model)"; \
 213         echo "TARGET_DEFINES += -DTARGET_COMPILER_\$$(Platform_compiler)"; \
 214         echo "CFLAGS += \$$(TARGET_DEFINES)"; \
 215         echo; \
 216         echo "Src_Dirs_V = \\"; \
 217         sed 's/$$/ \\/;s|$(GAMMADIR)|$$(GAMMADIR)|' ../shared_dirs.lst; \
 218         echo "$(call gamma-path,altsrc,cpu/$(ARCH)/vm) \\"; \
 219         echo "$(call gamma-path,commonsrc,cpu/$(ARCH)/vm) \\"; \
 220         echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(ARCH)/vm) \\"; \
 221         echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(ARCH)/vm) \\"; \
 222         echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
 223         echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
 224         echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
 225         echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
 226         echo; \
 227         echo "Src_Dirs_I = \\"; \
 228         echo "$(call gamma-path,altsrc,share/vm/prims) \\"; \
 229         echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \
 230         echo "$(call gamma-path,altsrc,share/vm) \\"; \
 231         echo "$(call gamma-path,commonsrc,share/vm) \\"; \
 232         echo "$(call gamma-path,altsrc,share/vm/precompiled) \\"; \
 233         echo "$(call gamma-path,commonsrc,share/vm/precompiled) \\"; \
 234         echo "$(call gamma-path,altsrc,cpu/$(ARCH)/vm) \\"; \
 235         echo "$(call gamma-path,commonsrc,cpu/$(ARCH)/vm) \\"; \
 236         echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(ARCH)/vm) \\"; \
 237         echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(ARCH)/vm) \\"; \
 238         echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
 239         echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
 240         echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
 241         echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
 242         [ -n "$(CFLAGS_BROWSE)" ] && \
 243             echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \
 244         [ -n "$(ENABLE_FULL_DEBUG_SYMBOLS)" ] && \
 245             echo && echo "ENABLE_FULL_DEBUG_SYMBOLS = $(ENABLE_FULL_DEBUG_SYMBOLS)"; \
 246         [ -n "$(OBJCOPY)" ] && \
 247             echo && echo "OBJCOPY = $(OBJCOPY)"; \
 248         [ -n "$(STRIP_POLICY)" ] && \
 249             echo && echo "STRIP_POLICY = $(STRIP_POLICY)"; \
 250         [ -n "$(ZIP_DEBUGINFO_FILES)" ] && \
 251             echo && echo "ZIP_DEBUGINFO_FILES = $(ZIP_DEBUGINFO_FILES)"; \
 252         [ -n "$(ZIPEXE)" ] && \
 253             echo && echo "ZIPEXE = $(ZIPEXE)"; \
 254         [ -n "$(HS_ALT_MAKE)" ] && \
 255             echo && echo "HS_ALT_MAKE = $(HS_ALT_MAKE)"; \
 256         [ -n "$(HOTSPOT_EXTRA_SYSDEFS)" ] && \
 257             echo && \
 258             echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \
 259             echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \
 260         echo; \
 261         [ -n "$(SPEC)" ] && \
 262             echo "include $(SPEC)"; \
 263         echo "CP ?= cp"; \
 264         echo "MV ?= mv"; \
 265         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
 266         echo "include \$$(GAMMADIR)/make/excludeSrc.make"; \
 267         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
 268         ) > $@
 269 
 270 flags_vm.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
 271         @echo $(LOG_INFO) Creating $@ ...
 272         $(QUIETLY) ( \
 273         $(BUILDTREE_COMMENT); \
 274         echo; \
 275         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(TARGET).make"; \
 276         ) > $@
 277 
 278 ../shared_dirs.lst:  $(BUILDTREE_MAKE) $(GAMMADIR)/src/share/vm
 279         @echo $(LOG_INFO) Creating directory list $@
 280         $(QUIETLY) if [ -d $(HS_ALT_SRC)/share/vm ]; then \
 281           find $(HS_ALT_SRC)/share/vm/* -prune \
 282           -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
 283           \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; > $@; \
 284         fi;
 285         $(QUIETLY) find $(HS_COMMON_SRC)/share/vm/* -prune \
 286         -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
 287         \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; >> $@
 288 
 289 Makefile: $(BUILDTREE_MAKE)
 290         @echo $(LOG_INFO) Creating $@ ...
 291         $(QUIETLY) ( \
 292         $(BUILDTREE_COMMENT); \
 293         echo; \
 294         echo include flags.make; \
 295         echo; \
 296         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/top.make"; \
 297         ) > $@
 298 
 299 vm.make: $(BUILDTREE_MAKE)
 300         @echo $(LOG_INFO) Creating $@ ...
 301         $(QUIETLY) ( \
 302         $(BUILDTREE_COMMENT); \
 303         echo; \
 304         echo include flags.make; \
 305         echo include flags_vm.make; \
 306         echo; \
 307         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 308         ) > $@
 309 
 310 adlc.make: $(BUILDTREE_MAKE)
 311         @echo $(LOG_INFO) Creating $@ ...
 312         $(QUIETLY) ( \
 313         $(BUILDTREE_COMMENT); \
 314         echo; \
 315         echo include flags.make; \
 316         echo; \
 317         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 318         ) > $@
 319 
 320 jvmti.make: $(BUILDTREE_MAKE)
 321         @echo $(LOG_INFO) Creating $@ ...
 322         $(QUIETLY) ( \
 323         $(BUILDTREE_COMMENT); \
 324         echo; \
 325         echo include flags.make; \
 326         echo; \
 327         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 328         ) > $@
 329 
 330 trace.make: $(BUILDTREE_MAKE)
 331         @echo $(LOG_INFO) Creating $@ ...
 332         $(QUIETLY) ( \
 333         $(BUILDTREE_COMMENT); \
 334         echo; \
 335         echo include flags.make; \
 336         echo; \
 337         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 338         ) > $@
 339 
 340 dtrace.make: $(BUILDTREE_MAKE)
 341         @echo $(LOG_INFO) Creating $@ ...
 342         $(QUIETLY) ( \
 343         $(BUILDTREE_COMMENT); \
 344         echo; \
 345         echo include flags.make; \
 346         echo; \
 347         echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
 348         ) > $@
 349 
 350 FORCE:
 351 
 352 .PHONY:  all FORCE
 353 
 354 .NOTPARALLEL: