view make/common/shared/Defs-windows.gmk @ 441:0a5931be9176

7152336: Enable builds on Windows with MinGW/MSYS Summary: Minimal makefile changes to enable building OpenJDK using MSYS on Windows7 Reviewed-by: ohair, tbell Contributed-by: volker.simonis@gmail.com
author tbell
date Tue, 23 Oct 2012 10:10:39 -0700
parents f90b3e014e83
children
line wrap: on
line source

#
# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

#
# Definitions for Windows.
#

# Default for COMPILER_WARNINGS_FATAL on Windows (C++ compiler warnings)
#    Level: Default is 3, 0 means none, 4 is the most but may be unreliable
#    Some makefiles may have set this to 0 to turn off warnings completely,
#    which also effectively creates a COMPILER_WARNINGS_FATAL=false situation.
#    Windows 64bit platforms are less likely to be warning free.
#    Historically, Windows 32bit builds should be mostly warning free.
ifndef COMPILER_WARNING_LEVEL
  COMPILER_WARNING_LEVEL=3
endif
ifndef COMPILER_WARNINGS_FATAL
  COMPILER_WARNINGS_FATAL=false
endif

# Windows should use parallel compilation for best build times
ifndef COMPILE_APPROACH
  COMPILE_APPROACH = normal
endif

# Indication that we are doing an incremental build.
#    This may trigger the creation of make depend files.
#    (This may not be working on windows yet, always force to false.)
override INCREMENTAL_BUILD = false

# WARNING: This is extremely touch stuff, between CYGWIN vs. MKS and all
#          variations of MKS and CYGWIN releases, and 32bit vs 64bit,
#          this file can give you nightmares.
#
# Notes:
#   Keep all paths in the windows "mixed" style except CYGWIN UNXIXCOMMAND_PATH.
#   Use of PrefixPath is critical, some variables must end with / (see NOTE).
#   Use of quotes is critical due to possible spaces in paths coming from
#     the environment variables, be careful.
#   First convert \ to / with subst, keep it quoted due to blanks, then
#     use cygpath -s or dosname -s to get the short non-blank name.
#   If the MKS is old and doesn't have a dosname -s, you will be forced
#     to set ALT variables with the short non-space directory names.
#     If dosname doesn't appear to work, we won't use it.
#     The dosname utility also wants to accept stdin if it is not supplied
#     any path on the command line, this is really dangerous when using
#     make variables that can easily become empty, so I use:
#        echo $1 | dosname -s     instead of    dosname -s $1
#     to prevent dosname from hanging up the make process when $1 is empty.
#     The cygpath utility does not have this problem.
#   The ALT values should never really have spaces or use \.
#   Suspect these environment variables to have spaces and/or \ characters:
#     SYSTEMROOT, SystemRoot, WINDIR, windir, PROGRAMFILES, ProgramFiles,
#     VC71COMNTOOLS, 
#     MSVCDIR, MSVCDir.
#     So use $(subst \,/,) on them first adding quotes and placing them in
#         their own variable assigned with :=, then use FullPath.
#

# Use FullPath to get C:/ style non-spaces path. Never ends with a /!
ifdef USING_CYGWIN
# We assume cygpath is available in the search path
#    NOTE: Use of 'pwd' with CYGWIN will not get you a mixed style path!
CYGPATH_CMD=cygpath -a -s -m
define FullPath
$(shell $(CYGPATH_CMD) $1 2> $(DEV_NULL))
endef
define OptFullPath
$(shell if [ "$1" != "" -a -d "$1" ]; then $(CYGPATH_CMD) "$1"; else echo "$1"; fi)
endef
else
ifdef USING_MSYS
DOSPATH_CMD:=$(shell cd $(JDK_TOPDIR) 2> $(DEV_NULL) && pwd)/make/tools/msys_build_scripts/dospath.sh
define FullPath
$(subst \,/,$(shell $(DOSPATH_CMD) $1))
endef
define OptFullPath
$(shell if [ "$1" != "" -a -d "$1" ]; then (cd $1 && pwd); else echo "$1"; fi)
endef
else
# Temporary until we upgrade to MKS 8.7, MKS pwd returns mixed mode path
define FullPath
$(shell cd $1 2> $(DEV_NULL) && pwd)
endef
define OptFullPath
$(shell if [ "$1" != "" -a -d "$1" ]; then (cd $1 && pwd); else echo "$1"; fi)
endef
endif
endif

# System drive
ifdef SYSTEMDRIVE
  _system_drive =$(SYSTEMDRIVE)
else
  ifdef SystemDrive
    _system_drive =$(SystemDrive)
  endif
endif
_system_drive:=$(call CheckValue,_system_drive,C:)

# UNIXCOMMAND_PATH: path to where the most common Unix commands are.
#  NOTE: Must end with / so that it could be empty, allowing PATH usage.
#        With cygwin, use this as is; don't use FullPath on it.
ifdef ALT_UNIXCOMMAND_PATH
  ifdef USING_CYGWIN
    UNIXCOMMAND_PATH       :=$(call PrefixPath,$(ALT_UNIXCOMMAND_PATH))
  else
    xALT_UNIXCOMMAND_PATH  :="$(subst \,/,$(ALT_UNIXCOMMAND_PATH))"
    fxALT_UNIXCOMMAND_PATH :=$(call FullPath,$(xALT_UNIXCOMMAND_PATH))
    UNIXCOMMAND_PATH       :=$(call PrefixPath,$(fxALT_UNIXCOMMAND_PATH))
  endif
else
  ifdef USING_CYGWIN
    UNIXCOMMAND_PATH :=$(call PrefixPath,/usr/bin)
  else
    ifdef USING_MSYS
      UNIXCOMMAND_PATH :=$(call PrefixPath,/bin)
    else
      ifdef ROOTDIR
        xROOTDIR :="$(subst \,/,$(ROOTDIR))"
        _rootdir :=$(call FullPath,$(xROOTDIR))
      else
        xROOTDIR :="$(_system_drive)/mksnt"
        _rootdir :=$(call FullPath,$(xROOTDIR))
      endif
      ifneq ($(_rootdir),)
        UNIXCOMMAND_PATH :=$(call PrefixPath,$(_rootdir)/mksnt)
      endif
    endif # USING_MSYS
  endif # USING_CYGWIN
endif
UNIXCOMMAND_PATH:=$(call AltCheckSpaces,UNIXCOMMAND_PATH)
export UNIXCOMMAND_PATH

# Get version of MKS or CYGWIN
ifdef USING_MKS
  _MKS_VER :=$(shell $(MKSINFO) 2>&1 | $(GREP) Release | $(TAIL) -1 | $(SED) -e 's@.*\(Release.*\)@\1@')
  MKS_VER  :=$(call GetVersion,$(_MKS_VER))
  # At this point, we can re-define FullPath to use DOSNAME_CMD
  CHECK_MKS87:=$(call CheckVersions,$(MKS_VER),8.7)
  TRY_DOSNAME:=false
  ifeq ($(CHECK_MKS87),same)
    TRY_DOSNAME:=true
  endif
  # Newer should be ok
  ifeq ($(CHECK_MKS87),newer)
    TRY_DOSNAME:=true
  endif
  ifeq ($(TRY_DOSNAME),true)
    ifeq ($(shell $(UNIXCOMMAND_PATH)dosname -s $(_system_drive)/ 2> $(DEV_NULL)),$(_system_drive)/)
      _DOSNAME=$(UNIXCOMMAND_PATH)dosname
      DOSNAME_CMD:=$(_DOSNAME) -s
define FullPath
$(subst //,/,$(shell echo $1 | $(DOSNAME_CMD) 2> $(DEV_NULL)))
endef
    endif # test dosname -s
  endif # TRY_DOSNAME
endif # MKS

# We try to get references to what we need via the default component
#    environment variables, or what was used historically.

# Process Windows values into FullPath values, these paths may have \ chars

# Program Files directory
ifndef SHORTPROGRAMFILES
  ifdef PROGRAMFILES
    xPROGRAMFILES      :="$(subst \,/,$(PROGRAMFILES))"
  else
    ifeq ($(ARCH_DATA_MODEL), 32)
      xPROGRAMFILES    :="$(_system_drive)/Program Files"
    else
      xPROGRAMFILES    :="$(_system_drive)/Program Files (x86)"
    endif
  endif
  ifeq ($(ARCH_DATA_MODEL), 32)
    SHORTPROGRAMFILES  :=$(call FullPath,$(xPROGRAMFILES))
  else
    ifdef PROGRAMW6432
      xPROGRAMW6432    :="$(subst \,/,$(PROGRAMW6432))"
    else
      xPROGRAMW6432    :="$(_system_drive)/Program Files"
    endif
    SHORTPROGRAMFILES  :=$(call FullPath,$(xPROGRAMW6432))
  endif
  ifneq ($(word 1,$(SHORTPROGRAMFILES)),$(SHORTPROGRAMFILES))
    SHORTPROGRAMFILES  :=
  endif
  export SHORTPROGRAMFILES
endif

# Location on system where jdk installs might be
ifneq ($(SHORTPROGRAMFILES),)
  USRJDKINSTANCES_PATH =$(SHORTPROGRAMFILES)/Java
else
  USRJDKINSTANCES_PATH =$(_system_drive)/
endif

# SLASH_JAVA: location of all network accessable files
ifndef SLASH_JAVA
  ifdef ALT_SLASH_JAVA
    xALT_SLASH_JAVA :="$(subst \,/,$(ALT_SLASH_JAVA))"
    SLASH_JAVA      :=$(call FullPath,$(xALT_SLASH_JAVA))
  else
    ifdef ALT_JDK_JAVA_DRIVE
      SLASH_JAVA  =$(JDK_JAVA_DRIVE)
    else
      SLASH_JAVA  =J:
    endif
  endif
  SLASH_JAVA:=$(call AltCheckSpaces,SLASH_JAVA)
  SLASH_JAVA:=$(call AltCheckValue,SLASH_JAVA)
  export SLASH_JAVA
endif

# JDK_DEVTOOLS_DIR: common path for all the java devtools
ifndef JDK_DEVTOOLS_DIR
  ifdef ALT_JDK_DEVTOOLS_DIR
    xALT_JDK_DEVTOOLS_DIR :="$(subst \,/,$(ALT_JDK_DEVTOOLS_DIR))"
    JDK_DEVTOOLS_DIR      :=$(call FullPath,$(xALT_JDK_DEVTOOLS_DIR))
  else
    JDK_DEVTOOLS_DIR =$(SLASH_JAVA)/devtools
  endif
  JDK_DEVTOOLS_DIR:=$(call AltCheckSpaces,JDK_DEVTOOLS_DIR)
  JDK_DEVTOOLS_DIR:=$(call AltCheckValue,JDK_DEVTOOLS_DIR)
  export JDK_DEVTOOLS_DIR
endif

# DEVTOOLS_PATH: for other tools required for building (such as zip, etc.)
#  NOTE: Must end with / so that it could be empty, allowing PATH usage.
ifndef DEVTOOLS_PATH
  # DEVTOOLS_PATH: for other tools required for building (such as zip, etc.)
  #  NOTE: Must end with / so that it could be empty, allowing PATH usage.
  ifdef ALT_DEVTOOLS_PATH
    xALT_DEVTOOLS_PATH  :="$(subst \,/,$(ALT_DEVTOOLS_PATH))"
    fxALT_DEVTOOLS_PATH :=$(call FullPath,$(xALT_DEVTOOLS_PATH))
    DEVTOOLS_PATH       :=$(call PrefixPath,$(fxALT_DEVTOOLS_PATH))
  else
    ifdef USING_CYGWIN
      DEVTOOLS_PATH :=$(UNIXCOMMAND_PATH)
    else
      ifdef USING_MSYS
        DEVTOOLS_PATH :=$(UNIXCOMMAND_PATH)
      else
        xDEVTOOLS_PATH  :="$(_system_drive)/utils"
        fxDEVTOOLS_PATH :=$(call FullPath,$(xDEVTOOLS_PATH))
        DEVTOOLS_PATH  :=$(call PrefixPath,$(fxDEVTOOLS_PATH))
      endif # USING_MSYS
    endif # USING_CYGWIN
  endif
  DEVTOOLS_PATH:=$(call AltCheckSpaces,DEVTOOLS_PATH)
  export DEVTOOLS_PATH
endif

# _BOOTDIR1: First choice for a Bootstrap JDK, previous released JDK.
# _BOOTDIR2: Second choice
ifndef ALT_BOOTDIR
  _BOOTDIR1  =$(_system_drive)/jdk$(PREVIOUS_JDK_VERSION)
  _BOOTDIR2  =$(USRJDKINSTANCES_PATH)/jdk$(PREVIOUS_JDK_VERSION)
endif

# Import JDK images allow for partial builds, components not built are
#    imported (or copied from) these import areas when needed.

# BUILD_JDK_IMPORT_PATH: location of JDK install trees to import for
#   multiple platforms, e.g. windows-i586, solaris-sparc, linux-586, etc.
ifndef BUILD_JDK_IMPORT_PATH
  ifdef ALT_BUILD_JDK_IMPORT_PATH
    BUILD_JDK_IMPORT_PATH  :=$(call FullPath,$(ALT_BUILD_JDK_IMPORT_PATH))
  else
    BUILD_JDK_IMPORT_PATH   = $(PROMOTED_BUILD_BINARIES)
  endif
  BUILD_JDK_IMPORT_PATH:=$(call AltCheckSpaces,BUILD_JDK_IMPORT_PATH)
  BUILD_JDK_IMPORT_PATH:=$(call AltCheckValue,BUILD_JDK_IMPORT_PATH)
  export BUILD_JDK_IMPORT_PATH
endif

# JDK_IMPORT_PATH: location of previously built JDK (this version) to import
ifndef JDK_IMPORT_PATH
  ifdef ALT_JDK_IMPORT_PATH
    JDK_IMPORT_PATH  :=$(call FullPath,$(ALT_JDK_IMPORT_PATH))
  else
    JDK_IMPORT_PATH   = $(BUILD_JDK_IMPORT_PATH)/$(PLATFORM)-$(ARCH)$(_JDK_IMPORT_VARIANT)
  endif
  JDK_IMPORT_PATH:=$(call AltCheckSpaces,JDK_IMPORT_PATH)
  JDK_IMPORT_PATH:=$(call AltCheckValue,JDK_IMPORT_PATH)
  export JDK_IMPORT_PATH
endif