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