hotspot编译

"AA=="1",==", /usr/bin/make -s VERBOSE="-s" LOG_LEVEL="warn" -R -I /home/mazhi/workspace/openjdk/make/common "-f" /home/mazhi/workspace/openjdk/hotspot"/make/"linux"/Makefile checks" /usr/bin/make -s VERBOSE="-s" LOG_LEVEL="warn" -R -I /home/mazhi/workspace/openjdk/make/common -f /home/mazhi/workspace/openjdk/hotspot/make/linux/makefiles/buildtree.make GAMMADIR=/home/mazhi/workspace/openjdk/hotspot OS_FAMILY=linux SRCARCH=x86 BUILDARCH=amd64 LIBARCH=amd64 HOTSPOT_RELEASE_VERSION=25.0-b70 HOTSPOT_BUILD_VERSION= JRE_RELEASE_VERSION=1.8.0-internal-mazhi_2019_07_30_03_59-b00 ENABLE_FULL_DEBUG_SYMBOLS=1 OBJCOPY=/usr/bin/objcopy STRIP_POLICY=min_strip ZIP_DEBUGINFO_FILES=1 ZIPEXE=zip "VARIANT=compiler2

"fuck==="/home/mazhi/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/hotspot

",=="/home/mazhi/workspace/openjdk/hotspot/make/linux/Makefile

",===" LP64=1 BOOTDIR=/home/mazhi/workspace/jdk1.7.0_72 OUTPUTDIR=/home/mazhi/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/hotspot GAMMADIR=/home/mazhi/workspace/openjdk/hotspot MAKE_VERBOSE=y HOTSPOT_RELEASE_VERSION=25.0-b70 JRE_RELEASE_VERSION=1.8.0-internal-mazhi_2019_07_30_03_59-b00 HOTSPOT_BUILD_VERSION=

",=="

/usr/bin/make -f /home/mazhi/workspace/openjdk/hotspot/make/linux/Makefile  LP64=1 BOOTDIR=/home/mazhi/workspace/jdk1.7.0_72 OUTPUTDIR=/home/mazhi/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/hotspot GAMMADIR=/home/mazhi/workspace/openjdk/hotspot MAKE_VERBOSE=y HOTSPOT_RELEASE_VERSION=25.0-b70 JRE_RELEASE_VERSION=1.8.0-internal-mazhi_2019_07_30_03_59-b00 HOTSPOT_BUILD_VERSION=

/usr/bin/make -s VERBOSE="-s" LOG_LEVEL="warn" -R -I /home/mazhi/workspace/openjdk/make/common

BUILD_DIR=/home/mazhi/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/hotspot/linux_amd64_compiler2

BUILD_FLAVOR= VM_TARGET= generic_build2

ALT_OUTPUTDIR=/home/mazhi/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/hotspot

/usr/bin/make -s VERBOSE="-s" LOG_LEVEL="warn" -R -I /home/mazhi/workspace/openjdk/make/common BUILD_DIR=/home/mazhi/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/hotspot/linux_amd64_compiler2 BUILD_FLAVOR= VM_TARGET= generic_build2 ALT_OUTPUTDIR=/home/mazhi/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/hotspot

cd /home/mazhi/workspace/openjdk/hotspot/make &&

/usr/bin/make -s VERBOSE="-s" LOG_LEVEL="warn" -R -I /home/mazhi/workspace/openjdk/make/common

-j1

jvmg

docs

export_debug

STATIC_CXX=true

SPEC=/home/mazhi/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/hotspot-spec.gmk

BASE_SPEC=/home/mazhi/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/spec.gmk

cd /home/mazhi/workspace/openjdk/hotspot/make && /usr/bin/make -s VERBOSE="-s" LOG_LEVEL="warn" -R -I /home/mazhi/workspace/openjdk/make/common -j1 jvmg docs export_debug STATIC_CXX=true SPEC=/home/mazhi/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/hotspot-spec.gmk BASE_SPEC=/home/mazhi/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/spec.gmk

mazhi@ubuntu:~/workspace/openjdk/make$ /bin/bash /home/mazhi/workspace/openjdk/common/bin/logger.sh /home/mazhi/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/build.log

/usr/bin/make -s VERBOSE="-s" LOG_LEVEL="warn" -R -I /home/mazhi/workspace/openjdk/make/common "SPEC=/home/mazhi/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/spec.gmk" -j4 -f HotspotWrapper.gmk

"=====AA======"/home/mazhi/workspace/openjdk/langtools "========" /bin/bash /home/mazhi/workspace/openjdk/common/bin/logger.sh /home/mazhi/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/build.log
"=====BB======" /usr/bin/make -s VERBOSE="-s" LOG_LEVEL="warn" -R -I /home/mazhi/workspace/openjdk/make/common "==" "SPEC=/home/mazhi/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/spec.gmk" -j4

@($(CD) $(LANGTOOLS_TOPDIR)/make && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildLangtools.gmk) 命令格式对应的具体命令如下:

cd /home/mazhi/workspace/openjdk/langtools/make && 

/bin/bash /home/mazhi/workspace/openjdk/common/bin/logger.sh /home/mazhi/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/build.log   

/usr/bin/make -s VERBOSE="-s" LOG_LEVEL="warn" -R -I /home/mazhi/workspace/openjdk/make/common   

"SPEC=/home/mazhi/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/spec.gmk" -j4 

bash ./configure --with-target-bits=64 --with-boot-jdk=/home/mazhi/workspace/jdk1.7.0_72 --with-debug-level=slowdebug --enable-debug-symbols ZIP_DEBUGINFO_FILES=0

参考文章:https://blog.csdn.net/tjiyu/article/details/53725247

https://blog.csdn.net/dviewer/article/details/77972217 

_JAVA_LAUNCHER_DEBUG=1 配置环境变量 

2、在HotSpot虚拟机中,对象的内存中存储的布局可分为3块:对象头、实例数据、对齐填充

 

mazhi@ubuntu:~/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/jdk$ java -cp .:/home/mazhi/workspace/project/TestHotspot/bin com.test01.Test01

启动时会调用到home/mazhi/workspace/openjdk/jdk/src/share/bin/main.c

启动HSDB的命令:

~/workspace/openjdk/build/linux-x86_64-normal-server-slowdebug/jdk/lib$ java -cp ./sa-jdi.jar sun.jvm.hotspot.HSDB

如果无法连接时输入下面的命令:

echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

在/home/mazhi/workspace/openjdk路径下有configure文件,其内容如下:

#!/bin/bash

# This is a thin wrapper which will call the real configure script, and
# make sure that is called using bash.

this_script_dir=`dirname $0`
bash $this_script_dir/common/autoconf/configure "$@"

其中$@表示所有参数、$#表示所有参数的个数

则$this_script/common/autoconf/configure文件的内容如下:

#!/bin/bash


if test "x$BASH_VERSION" = x; then
  echo This script needs bash to run.
  echo It is recommended to use the configure script in the source tree root instead.
  exit 1
fi

CONFIGURE_COMMAND_LINE="$@" // 所有参数列表
conf_script_dir=`dirname $0`

if [ "$CUSTOM_CONFIG_DIR" = "" ]; then
  conf_custom_script_dir="$conf_script_dir/../../jdk/make/closed/autoconf"
else
  conf_custom_script_dir=$CUSTOM_CONFIG_DIR
fi

###
### Test that the generated configure is up-to-date
###

run_autogen_or_fail() {
  if test "x`which autoconf 2> /dev/null`" = x; then
    echo "Cannot locate autoconf, unable to correct situation."
    echo "Please install autoconf and run 'bash autogen.sh' to update the generated files."
    echo "Error: Cannot continue" 1>&2
    exit 1
  else
    echo "Running autogen.sh to correct the situation"
    bash $conf_script_dir/autogen.sh
  fi
}

check_autoconf_timestamps() {
  for file in $conf_script_dir/configure.ac $conf_script_dir/*.m4 ; do
    if test $file -nt $conf_script_dir/generated-configure.sh; then
      echo "Warning: The configure source files is newer than the generated files."
      run_autogen_or_fail
    fi
  done

  if test -e $conf_custom_script_dir/generated-configure.sh; then
    # If custom source configure is available, make sure it is up-to-date as well.
    for file in $conf_script_dir/configure.ac $conf_script_dir/*.m4 $conf_custom_script_dir/*.m4; do
      if test $file -nt $conf_custom_script_dir/generated-configure.sh; then
        echo "Warning: The configure source files is newer than the custom generated files."
        run_autogen_or_fail
      fi
    done
  fi
}

check_hg_updates() {
  if test "x`which hg 2> /dev/null`" != x; then
    conf_updated_autoconf_files=`cd $conf_script_dir && hg status -mard 2> /dev/null | grep autoconf`
    if test "x$conf_updated_autoconf_files" != x; then
      echo "Configure source code has been updated, checking time stamps"
      check_autoconf_timestamps
    fi

    if test -e $conf_custom_script_dir; then
      # If custom source configure is available, make sure it is up-to-date as well.
      conf_custom_updated_autoconf_files=`cd $conf_custom_script_dir && hg status -mard 2> /dev/null | grep autoconf`
      if test "x$conf_custom_updated_autoconf_files" != x; then
        echo "Configure custom source code has been updated, checking time stamps"
        check_autoconf_timestamps
      fi
    fi
  fi
}

# Check for local changes
check_hg_updates

if test -e $conf_custom_script_dir/generated-configure.sh; then
  # Test if open configure is newer than custom configure, if so, custom needs to
  # be regenerated. This test is required to ensure consistency with custom source.
  conf_open_configure_timestamp=`grep DATE_WHEN_GENERATED= $conf_script_dir/generated-configure.sh  | cut -d"=" -f 2`
  conf_custom_configure_timestamp=`grep DATE_WHEN_GENERATED= $conf_custom_script_dir/generated-configure.sh  | cut -d"=" -f 2`
  if test $conf_open_configure_timestamp -gt $conf_custom_configure_timestamp; then
    echo "Warning: The generated configure file contains changes not present in the custom generated file."
    run_autogen_or_fail
  fi
fi

# Autoconf calls the configure script recursively sometimes.
# Don't start logging twice in that case
if test "x$conf_debug_configure" = xtrue; then
  conf_debug_configure=recursive
fi
###
### Process command-line arguments
###
conf_processed_arguments=()
conf_openjdk_target=

for conf_option
do
  case $conf_option in
    --openjdk-target=*)
      conf_openjdk_target=`expr "X$conf_option" : '[^=]*=(.*)'`
      continue ;;
    --debug-configure)
      if test "x$conf_debug_configure" != xrecursive; then
        conf_debug_configure=true
        export conf_debug_configure
      fi
      continue ;;
    *)
      conf_processed_arguments=("${conf_processed_arguments[@]}" "$conf_option") ;;
  esac

  case $conf_option in
    -build | --build | --buil | --bui | --bu |-build=* | --build=* | --buil=* | --bui=* | --bu=*)
      conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
    -target | --target | --targe | --targ | --tar | --ta | --t | -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
      conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
    -host | --host | --hos | --ho | -host=* | --host=* | --hos=* | --ho=*)
      conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
    -help | --help | --hel | --he | -h)
      conf_print_help=true ;;
  esac
done

if test "x$conf_legacy_crosscompile" != "x"; then
  if test "x$conf_openjdk_target" != "x"; then
    echo "Error: Specifying --openjdk-target together with autoconf"
    echo "legacy cross-compilation flags is not supported."
    echo "You specified: --openjdk-target=$conf_openjdk_target and $conf_legacy_crosscompile."
    echo "The recommended use is just --openjdk-target."
    exit 1
  else
    echo "Warning: You are using legacy autoconf cross-compilation flags."
    echo "It is recommended that you use --openjdk-target instead."
    echo ""
  fi
fi

if test "x$conf_openjdk_target" != "x"; then
  conf_build_platform=`sh $conf_script_dir/build-aux/config.guess`
  conf_processed_arguments=("--build=$conf_build_platform" "--host=$conf_openjdk_target" "--target=$conf_openjdk_target" "${conf_processed_arguments[@]}")
fi

# Make configure exit with error on invalid options as default.
# Can be overridden by --disable-option-checking, since we prepend our argument
# and later options override earlier.
conf_processed_arguments=("--enable-option-checking=fatal" "${conf_processed_arguments[@]}")

###
### Call the configure script
###
if test -e $conf_custom_script_dir/generated-configure.sh; then
  # Custom source configure available; run that instead
  echo Running custom generated-configure.sh
  conf_script_to_run=$conf_custom_script_dir/generated-configure.sh
else
  echo Running generated-configure.sh
  conf_script_to_run=$conf_script_dir/generated-configure.sh
fi

if test "x$conf_debug_configure" != x; then
  # Turn on shell debug output if requested (initial or recursive)
  set -x
fi

if test "x$conf_debug_configure" = xtrue; then
  # Turn on logging, but don't turn on twice when called recursive
  conf_debug_logfile=./debug-configure.log
  (exec 3>&1 ; (. $conf_script_to_run "${conf_processed_arguments[@]}" 2>&1 1>&3 ) | tee -a $conf_debug_logfile 1>&2 ; exec 3>&-) | tee -a $conf_debug_logfile
else
  ( . $conf_script_to_run "${conf_processed_arguments[@]}" )
fi

conf_result_code=$?
###
### Post-processing
###

if test $conf_result_code -eq 0; then
  if test "x$conf_print_help" = xtrue; then
    cat <<EOT

Additional (non-autoconf) OpenJDK Options:
  --openjdk-target=TARGET cross-compile with TARGET as target platform
                          (i.e. the one you will run the resulting binary on).
                          Equivalent to --host=TARGET --target=TARGET
                          --build=<current platform>
  --debug-configure       Run the configure script with additional debug
                          logging enabled.

Please be aware that, when cross-compiling, the OpenJDK configure script will
generally use 'target' where autoconf traditionally uses 'host'.
EOT
  fi
else
  echo configure exiting with result code $conf_result_code
fi

exit $conf_result_code

在/home/mazhi/workspace/openjdk/hotspot/make/linux/路径下的Makefiile文件的内容如下:

# This makefile creates a build tree and lights off a build.
# You can go back into the build tree and perform rebuilds or
# incremental builds as desired. Be sure to reestablish
# environment variable settings for LD_LIBRARY_PATH and JAVA_HOME.

# The make process now relies on java and javac. These can be
# specified either implicitly on the PATH, by setting the
# (JDK-inherited) ALT_BOOTDIR environment variable to full path to a
# JDK in which bin/java and bin/javac are present and working (e.g.,
# /usr/local/java/jdk1.3/solaris), or via the (JDK-inherited)
# default BOOTDIR path value. Note that one of ALT_BOOTDIR
# or BOOTDIR has to be set. We do *not* search javac, javah, rmic etc.
# from the PATH.
#
# One can set ALT_BOOTDIR or BOOTDIR to point to a jdk that runs on
# an architecture that differs from the target architecture, as long
# as the bootstrap jdk runs under the same flavor of OS as the target
# (i.e., if the target is linux, point to a jdk that runs on a linux
# box).  In order to use such a bootstrap jdk, set the make variable
# REMOTE to the desired remote command mechanism, e.g.,
#
#    make REMOTE="rsh -l me myotherlinuxbox"

# Along with VM, Serviceability Agent (SA) is built for SA/JDI binding.
# JDI binding on SA produces two binaries:
#  1. sa-jdi.jar       - This is built before building libjvm.so
#                        Please refer to ./makefiles/sa.make
#  2. libsa.so         - Native library for SA - This is built after
#                        libjsig.so (signal interposition library)
#                        Please refer to ./makefiles/vm.make
# If $(GAMMADIR)/agent dir is not present, SA components are not built.

ifeq ($(GAMMADIR),)
include ../../make/defs.make
else
include $(GAMMADIR)/make/defs.make
endif
include $(GAMMADIR)/make/$(OSNAME)/makefiles/rules.make

ifndef CC_INTERP
  ifndef FORCE_TIERED
    FORCE_TIERED=1
  endif
endif

ifdef LP64
  ifeq ("$(filter $(LP64_ARCH),$(BUILDARCH))","")
    _JUNK_ := $(shell echo >&2 
       $(OSNAME) $(ARCH) "*** ERROR: this platform does not support 64-bit compilers!")
	@exit 1
  endif
endif

# we need to set up LP64 correctly to satisfy sanity checks in adlc
ifneq ("$(filter $(LP64_ARCH),$(BUILDARCH))","")
  MFLAGS += " LP64=1 "
endif

# pass USE_SUNCC further, through MFLAGS
ifdef USE_SUNCC
  MFLAGS += " USE_SUNCC=1 "
endif

# The following renders pathnames in generated Makefiles valid on
# machines other than the machine containing the build tree.
#
# For example, let's say my build tree lives on /files12 on
# exact.east.sun.com.  This logic will cause GAMMADIR to begin with
# /net/exact/files12/...
#
# We only do this on SunOS variants, for a couple of reasons:
#  * It is extremely rare that source trees exist on other systems
#  * It has been claimed that the Linux automounter is flakey, so
#    changing GAMMADIR in a way that exercises the automounter could
#    prove to be a source of unreliability in the build process.
# Obviously, this Makefile is only relevant on SunOS boxes to begin
# with, but the SunOS conditionalization will make it easier to
# combine Makefiles in the future (assuming we ever do that).

ifeq ($(OSNAME),solaris)

  #   prepend current directory to relative pathnames.
  NEW_GAMMADIR :=                                    
    $(shell echo $(GAMMADIR) |                       
      sed -e "s=^([^/].*)=$(shell pwd)/1="        
     )
  unexport NEW_GAMMADIR

  # If NEW_GAMMADIR doesn't already start with "/net/":
  ifeq ($(strip $(filter /net/%,$(NEW_GAMMADIR))),)
    #   prepend /net/$(HOST)
    #   remove /net/$(HOST) if name already began with /home/
    #   remove /net/$(HOST) if name already began with /java/
    #   remove /net/$(HOST) if name already began with /lab/
    NEW_GAMMADIR :=                                     
         $(shell echo $(NEW_GAMMADIR) |                 
                 sed -e "s=^(.*)=/net/$(HOST)1="     
                     -e "s=^/net/$(HOST)/home/=/home/=" 
                     -e "s=^/net/$(HOST)/java/=/java/=" 
                     -e "s=^/net/$(HOST)/lab/=/lab/="   
          )
    # Don't use the new value for GAMMADIR unless a file with the new
    # name actually exists.
    ifneq ($(wildcard $(NEW_GAMMADIR)),)
      GAMMADIR := $(NEW_GAMMADIR)
    endif
  endif

endif

# BUILDARCH is set to "zero" for Zero builds.  VARIANTARCH
# is used to give the build directories meaningful names.
VARIANTARCH = $(subst i386,i486,$(ZERO_LIBARCH))

# There is a (semi-) regular correspondence between make targets and actions:
#
#       Target          Tree Type       Build Dir
#
#       debug           compiler2       <os>_<arch>_compiler2/debug
#       fastdebug       compiler2       <os>_<arch>_compiler2/fastdebug
#       optimized       compiler2       <os>_<arch>_compiler2/optimized
#       product         compiler2       <os>_<arch>_compiler2/product
#
#       debug1          compiler1       <os>_<arch>_compiler1/debug
#       fastdebug1      compiler1       <os>_<arch>_compiler1/fastdebug
#       optimized1      compiler1       <os>_<arch>_compiler1/optimized
#       product1        compiler1       <os>_<arch>_compiler1/product
#
#       debugcore       core            <os>_<arch>_core/debug
#       fastdebugcore   core            <os>_<arch>_core/fastdebug
#       optimizedcore   core            <os>_<arch>_core/optimized
#       productcore     core            <os>_<arch>_core/product
#
#       debugzero       zero            <os>_<arch>_zero/debug
#       fastdebugzero   zero            <os>_<arch>_zero/fastdebug
#       optimizedzero   zero            <os>_<arch>_zero/optimized
#       productzero     zero            <os>_<arch>_zero/product
#
#       debugshark      shark           <os>_<arch>_shark/debug
#       fastdebugshark  shark           <os>_<arch>_shark/fastdebug
#       optimizedshark  shark           <os>_<arch>_shark/optimized
#       productshark    shark           <os>_<arch>_shark/product
#
#       fastdebugminimal1 minimal1      <os>_<arch>_minimal1/fastdebug
#       productminimal1   minimal1      <os>_<arch>_minimal1/product
#
# What you get with each target:
#
# debug*     - debug compile with asserts enabled
# fastdebug* - optimized compile, but with asserts enabled
# optimized* - optimized compile, no asserts
# product*   - the shippable thing:  optimized compile, no asserts, -DPRODUCT

# This target list needs to be coordinated with the usage message
# in the build.sh script:
TARGETS           = debug fastdebug optimized product

ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
  SUBDIR_DOCS     = $(OSNAME)_$(VARIANTARCH)_docs
else
  SUBDIR_DOCS     = $(OSNAME)_$(BUILDARCH)_docs
endif
SUBDIRS_C1        = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler1/,$(TARGETS))
SUBDIRS_C2        = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler2/,$(TARGETS))
SUBDIRS_TIERED    = $(addprefix $(OSNAME)_$(BUILDARCH)_tiered/,$(TARGETS))
SUBDIRS_CORE      = $(addprefix $(OSNAME)_$(BUILDARCH)_core/,$(TARGETS))
SUBDIRS_ZERO      = $(addprefix $(OSNAME)_$(VARIANTARCH)_zero/,$(TARGETS))
SUBDIRS_SHARK     = $(addprefix $(OSNAME)_$(VARIANTARCH)_shark/,$(TARGETS))
SUBDIRS_MINIMAL1  = $(addprefix $(OSNAME)_$(BUILDARCH)_minimal1/,$(TARGETS))

TARGETS_C2        = $(TARGETS)
TARGETS_C1        = $(addsuffix 1,$(TARGETS))
TARGETS_TIERED    = $(addsuffix tiered,$(TARGETS))
TARGETS_CORE      = $(addsuffix core,$(TARGETS))
TARGETS_ZERO      = $(addsuffix zero,$(TARGETS))
TARGETS_SHARK     = $(addsuffix shark,$(TARGETS))
TARGETS_MINIMAL1 =  $(addsuffix minimal1,$(TARGETS))

BUILDTREE_MAKE    = $(GAMMADIR)/make/$(OSNAME)/makefiles/buildtree.make
BUILDTREE_VARS    = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OSNAME) SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH)
BUILDTREE_VARS   += HOTSPOT_RELEASE_VERSION=$(HOTSPOT_RELEASE_VERSION) HOTSPOT_BUILD_VERSION=$(HOTSPOT_BUILD_VERSION) JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION)
BUILDTREE_VARS   += ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS) OBJCOPY=$(OBJCOPY) STRIP_POLICY=$(STRIP_POLICY) ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES) ZIPEXE=$(ZIPEXE)

BUILDTREE         = $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_VARS)

#-------------------------------------------------------------------------------

# Could make everything by default, but that would take a while.
all:
	@echo "Try '$(MAKE) <target> ...'  where <target> is one or more of"
	@echo "  $(TARGETS_C2)"
	@echo "  $(TARGETS_C1)"
	@echo "  $(TARGETS_CORE)"
	@echo "  $(TARGETS_ZERO)"
	@echo "  $(TARGETS_SHARK)"
	@echo "  $(TARGETS_MINIMAL1)"

checks: check_os_version check_j2se_version

# We do not want people accidentally building on old systems (e.g. Linux 2.2.x,
# Solaris 2.5.1, 2.6).
# Disable this check by setting DISABLE_HOTSPOT_OS_VERSION_CHECK=ok.

SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 3%
OS_VERSION := $(shell uname -r)
EMPTY_IF_NOT_SUPPORTED = $(filter $(SUPPORTED_OS_VERSION),$(OS_VERSION))

check_os_version:
ifeq ($(DISABLE_HOTSPOT_OS_VERSION_CHECK)$(EMPTY_IF_NOT_SUPPORTED),)
	$(QUIETLY) >&2 echo "*** This OS is not supported:" `uname -a`; exit 1;
endif

# jvmti.make requires XSLT (J2SE 1.4.x or newer):
XSLT_CHECK	= $(REMOTE) $(RUN.JAVAP) javax.xml.transform.TransformerFactory
# If not found then fail fast.
check_j2se_version:
	$(QUIETLY) $(XSLT_CHECK) > /dev/null 2>&1; 
	if [ $$? -ne 0 ]; then 
	  $(REMOTE) $(RUN.JAVA) -version; 
	  echo "*** An XSLT processor (J2SE 1.4.x or newer) is required" 
	  "to bootstrap this build" 1>&2; 
	  exit 1; 
	fi

$(SUBDIRS_TIERED): $(BUILDTREE_MAKE)
	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
	$(BUILDTREE) VARIANT=tiered

$(SUBDIRS_C2): $(BUILDTREE_MAKE)
ifeq ($(FORCE_TIERED),1)
	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
		$(BUILDTREE) VARIANT=tiered FORCE_TIERED=1
else
	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
		$(BUILDTREE) VARIANT=compiler2
endif

$(SUBDIRS_C1): $(BUILDTREE_MAKE)
	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
	$(BUILDTREE) VARIANT=compiler1

$(SUBDIRS_CORE): $(BUILDTREE_MAKE)
	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
	$(BUILDTREE) VARIANT=core

$(SUBDIRS_ZERO): $(BUILDTREE_MAKE) platform_zero
	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
	$(BUILDTREE) VARIANT=zero VARIANTARCH=$(VARIANTARCH)

$(SUBDIRS_SHARK): $(BUILDTREE_MAKE) platform_zero
	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
	$(BUILDTREE) VARIANT=shark VARIANTARCH=$(VARIANTARCH)

$(SUBDIRS_MINIMAL1): $(BUILDTREE_MAKE)
	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
	$(BUILDTREE) VARIANT=minimal1


platform_zero: $(GAMMADIR)/make/$(OSNAME)/platform_zero.in
	$(SED) 's/@ZERO_ARCHDEF@/$(ZERO_ARCHDEF)/g;s/@ZERO_LIBARCH@/$(ZERO_LIBARCH)/g;' < $< > $@

# Define INSTALL=y at command line to automatically copy JVM into JAVA_HOME

$(TARGETS_C2):  $(SUBDIRS_C2)
	cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS)
ifdef INSTALL
	cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) install
endif

$(TARGETS_TIERED):  $(SUBDIRS_TIERED)
	cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS)
ifdef INSTALL
	cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS) install
endif

$(TARGETS_C1):  $(SUBDIRS_C1)
	cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS)
ifdef INSTALL
	cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS) install
endif

$(TARGETS_CORE):  $(SUBDIRS_CORE)
	cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS)
ifdef INSTALL
	cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) install
endif

$(TARGETS_ZERO):  $(SUBDIRS_ZERO)
	cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS)
ifdef INSTALL
	cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS) install
endif

$(TARGETS_SHARK):  $(SUBDIRS_SHARK)
	cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS)
ifdef INSTALL
	cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS) install
endif

$(TARGETS_MINIMAL1):  $(SUBDIRS_MINIMAL1)
	cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS)
ifdef INSTALL
	cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS) install
endif

# Just build the tree, and nothing else:
tree:      $(SUBDIRS_C2)
tree1:     $(SUBDIRS_C1)
treecore:  $(SUBDIRS_CORE)
treezero:  $(SUBDIRS_ZERO)
treeshark: $(SUBDIRS_SHARK)
treeminimal1: $(SUBDIRS_MINIMAL1)

# Doc target.  This is the same for all build options.
#     Hence create a docs directory beside ...$(ARCH)_[...]
# We specify 'BUILD_FLAVOR=product' so that the proper
# ENABLE_FULL_DEBUG_SYMBOLS value is used.
docs: checks
	$(QUIETLY) mkdir -p $(SUBDIR_DOCS)
	$(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/makefiles/jvmti.make $(MFLAGS) $(BUILDTREE_VARS) JvmtiOutDir=$(SUBDIR_DOCS) BUILD_FLAVOR=product jvmtidocs

# Synonyms for win32-like targets.
compiler2:  debug product

compiler1:  debug1 product1

core: debugcore productcore

zero: debugzero productzero

shark: debugshark productshark

warn_jvmg_deprecated:
	echo "Warning: The jvmg target has been replaced with debug"
	echo "Warning: Please update your usage"

jvmg: warn_jvmg_deprecated debug

jvmg1: warn_jvmg_deprecated debug1

jvmgcore: warn_jvmg_deprecated debugcore

jvmgzero: warn_jvmg_deprecated debugzero

jvmgshark: warn_jvmg_deprecated debugshark

clean_docs:
	rm -rf $(SUBDIR_DOCS)

clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark clean_minimal1:
	rm -rf $(OSNAME)_$(BUILDARCH)_$(subst clean_,,$@)

clean:  clean_compiler2 clean_compiler1 clean_core clean_zero clean_shark clean_minimal1 clean_docs

include $(GAMMADIR)/make/cscope.make

#
# Include alternate Makefile if it exists.
#
-include $(HS_ALT_MAKE)/$(OSNAME)/Makefile.make

#-------------------------------------------------------------------------------

.PHONY: $(TARGETS_C2) $(TARGETS_C1) $(TARGETS_CORE) $(TARGETS_ZERO) $(TARGETS_SHARK) $(TARGETS_MINIMAL1)
.PHONY: tree tree1 treecore treezero treeshark
.PHONY: all compiler1 compiler2 core zero shark
.PHONY: clean clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark docs clean_docs
.PHONY: checks check_os_version check_j2se_version
.PHONY: $(HS_ALT_MAKE)/$(OSNAME)/Makefile.make

  

/home/mazhi/workspace/openjdk/Makefile

# This must be the first rule
default:

# Inclusion of this pseudo-target will cause make to execute this file
# serially, regardless of -j. Recursively called makefiles will not be
# affected, however. This is required for correct dependency management.
.NOTPARALLEL:

# The shell code below will be executed on /usr/ccs/bin/make on Solaris, but not in GNU make.
# /usr/ccs/bin/make lacks basically every other flow control mechanism.
TEST_FOR_NON_GNUMAKE:sh=echo You are not using GNU make/gmake, this is a requirement. Check your path. 1>&2 && exit 1

# Assume we have GNU make, but check version.
ifeq ($(strip $(foreach v, 3.81% 3.82% 4.%, $(filter $v, $(MAKE_VERSION)))), )
  $(error This version of GNU Make is too low ($(MAKE_VERSION)). Check your path, or upgrade to 3.81 or newer.)
endif

# Locate this Makefile
ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),)
  makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST))
else
  makefile_path:=$(lastword $(MAKEFILE_LIST))
endif
root_dir:=$(dir $(makefile_path))

# ... and then we can include our helper functions
include $(root_dir)/make/MakeHelpers.gmk

$(eval $(call ParseLogLevel))
$(eval $(call ParseConfAndSpec))

# Now determine if we have zero, one or several configurations to build.
ifeq ($(SPEC),)
  # Since we got past ParseConfAndSpec, we must be building a global target. Do nothing.
else
  ifeq ($(words $(SPEC)),1)
    # We are building a single configuration. This is the normal case. Execute the Main.gmk file.
    include $(root_dir)/make/Main.gmk
  else
    # We are building multiple configurations.
    # First, find out the valid targets
    # Run the makefile with an arbitrary SPEC using -p -q (quiet dry-run and dump rules) to find
    # available PHONY targets. Use this list as valid targets to pass on to the repeated calls.
    all_phony_targets=$(filter-out $(global_targets) bundles bundles-only final-images-only, $(strip $(shell 
        cd $(root_dir) && $(MAKE) -p -q FRC SPEC=$(firstword $(SPEC)) | 
        grep ^.PHONY: | head -n 1 | cut -d " " -f 2-)))

    $(all_phony_targets):
	@$(foreach spec,$(SPEC),(cd $(root_dir) && $(MAKE) SPEC=$(spec) 
	    $(VERBOSE) VERBOSE=$(VERBOSE) LOG_LEVEL=$(LOG_LEVEL) $@) &&) true

    .PHONY: $(all_phony_targets)

  endif
endif

# Include this after a potential spec file has been included so that the bundles target
# has access to the spec variables.
include $(root_dir)/make/Jprt.gmk

# Here are "global" targets, i.e. targets that can be executed without specifying a single configuration.
# If you addd more global targets, please update the variable global_targets in MakeHelpers.

help:
	$(info )
	$(info OpenJDK Makefile help)
	$(info =====================)
	$(info )
	$(info Common make targets)
	$(info .  make [default]         # Compile all product in langtools, hotspot, jaxp, jaxws,)
	$(info .                         # corba and jdk)
	$(info .  make all               # Compile everything, all repos and images)
	$(info .  make images            # Create complete j2sdk and j2re images)
	$(info .  make docs              # Create javadocs)
	$(info .  make overlay-images    # Create limited images for sparc 64 bit platforms)
	$(info .  make profiles          # Create complete j2re compact profile images)
	$(info .  make bootcycle-images  # Build images twice, second time with newly build JDK)
	$(info .  make install           # Install the generated images locally)
	$(info .  make clean             # Remove all files generated by make, but not those)
	$(info .                         # generated by configure)
	$(info .  make dist-clean        # Remove all files, including configuration)
	$(info .  make help              # Give some help on using make)
	$(info .  make test              # Run tests, default is all tests (see TEST below))
	$(info )
	$(info Targets for specific components)
	$(info (Component is any of langtools, corba, jaxp, jaxws, hotspot, jdk, nashorn, images, overlay-images, docs or test))
	$(info .  make <component>       # Build <component> and everything it depends on. )
	$(info .  make <component>-only  # Build <component> only, without dependencies. This)
	$(info .                         # is faster but can result in incorrect build results!)
	$(info .  make clean-<component> # Remove files generated by make for <component>)
	$(info )
	$(info Useful make variables)
	$(info .  make CONF=             # Build all configurations (note, assignment is empty))
	$(info .  make CONF=<substring>  # Build the configuration(s) with a name matching)
	$(info .                         # <substring>)
	$(info )
	$(info .  make LOG=<loglevel>    # Change the log level from warn to <loglevel>)
	$(info .                         # Available log levels are:)
	$(info .                         # 'warn' (default), 'info', 'debug' and 'trace')
	$(info .                         # To see executed command lines, use LOG=debug)
	$(info )
	$(info .  make JOBS=<n>          # Run <n> parallel make jobs)
	$(info .                         # Note that -jN does not work as expected!)
	$(info )
	$(info .  make test TEST=<test>  # Only run the given test or tests, e.g.)
	$(info .                         # make test TEST="jdk_lang jdk_net")
	$(info )

.PHONY: help

  

  

原文地址:https://www.cnblogs.com/mazhimazhi/p/10967763.html