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