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