1 #
   2 # Copyright 1997-2008 Sun Microsystems, Inc.  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.  Sun designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Sun in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  22 # CA 95054 USA or visit www.sun.com if you need additional information or
  23 # have any questions.
  24 #
  25 
  26 #
  27 # Shared platform (OS/ARCH) variable settings for the JDK builds.
  28 #
  29 # Includes basic system requirements, versions of utilities required,
  30 #   suffixes on files, and basic defaults attributed to the build platform.
  31 #
  32 
  33 #
  34 # Assumes some basic unix system utilities (e.g. uname) are in the search path
  35 #   in order to figure out the system.
  36 #
  37 
  38 ifndef PLATFORM_SHARED
  39 
  40 PLATFORM_SHARED=done
  41 
  42 # Possible Input variables:
  43 #     ARCH_DATA_MODEL             32 or 64, default to 32
  44 #     USER, LOGNAME               user name (runs logname, or id if not set)
  45 #     PROCESSOR_IDENTIFIER        windows only: needed in environment
  46 #
  47 # (Also gets input by running the utilities uname, logname, isainfo, or id.)
  48 #
  49 # Variables set by this file:
  50 #     SYSTEM_UNAME                what 'uname' says this system is
  51 #     USER                        login name of user (minus blanks)
  52 #     PLATFORM                    windows, solaris, or linux
  53 #     VARIANT                     OPT or DBG, OPT is the default
  54 #     TEMP_DISK                   /tmp or C:/temp
  55 #     ARCH_DATA_MODEL             32 or 64
  56 #     ARCH                        sparc, sparcv9, i586, amd64, or ia64
  57 #     ARCH_FAMILY                 sparc or i586
  58 #     ARCHPROP                    sparc or x86
  59 #     ARCH_VM_SUBDIR              jre/bin, jre/lib/sparc, etc.
  60 #     LIBARCH                     sparc, sparcv9, i386, amd64, or ia64
  61 #     DEV_NULL                    destination of /dev/null, NUL or /dev/NULL
  62 #     CLASSPATH_SEPARATOR         separator in classpath, ; or :
  63 #     LIB_PREFIX                  dynamic or static library prefix, lib or empty
  64 #     LIB_SUFFIX                  static library file suffix, .lib or .a?
  65 #     LIBRARY_SUFFIX              dynamic library file suffix, .dll or .so
  66 #     OBJECT_SUFFIX               object file suffix, .o or .obj
  67 #     EXE_SUFFIX                  executable file suffix, .exe or empty
  68 #     BUNDLE_FILE_SUFFIX          suffix for bundles: .tar or .tar.gz
  69 #     ISA_DIR                     solaris only: /sparcv9 or /amd64
  70 #     LIBARCH32                   solaris only: sparc or i386
  71 #     LIBARCH64                   solaris only: sparcv9 or amd64
  72 #     USING_CYGWIN                windows only: true or false
  73 #     ISHIELD_TEMP_MIN            windows only: minimum disk space in temp area
  74 
  75 SYSTEM_UNAME := $(shell uname)
  76 
  77 #
  78 # Prune out all known SCM (Source Code Management) directories
  79 # so they will not be included when copying directory trees
  80 # or packaging up .jar files, etc.  This applies to all workspaces.
  81 #
  82 SCM_DIRs = .hg .svn CVS RCS SCCS Codemgr_wsdata deleted_files .hgignore .hgtags
  83 # When changing SCM_DIRs also change SCM_DIRS_rexp and SCM_DIRS_prune:
  84 SCM_DIRS_rexp = ".hg|.svn|CVS|RCS|SCCS|Codemgr_wsdata|deleted_files|.hgignore|.hgtags"
  85 SCM_DIRS_prune = \( -name .hg -o -name .svn -o -name CVS -o -name RCS -o -name SCCS -o -name Codemgr_wsdata -o -name deleted_files -o -name .hgignore -o -name .hgtags \) -prune
  86 
  87 # Don't define this unless it's not defined
  88 ifndef VARIANT
  89   VARIANT=OPT
  90 endif
  91 
  92 # Platform settings specific to Solaris
  93 ifeq ($(SYSTEM_UNAME), SunOS)
  94   PLATFORM = solaris
  95   # Solaris sparc build can be either 32-bit or 64-bit.
  96   #   Default to 32, but allow explicit setting to 32 or 64.
  97   ifndef ARCH_DATA_MODEL
  98     ARCH_DATA_MODEL=32
  99   endif
 100   ifeq ($(ARCH_DATA_MODEL), 32)
 101     processor := $(shell uname -p)
 102     archExpr = case "$(processor)" in  \
 103                 i[3-9]86) \
 104                     echo i586 \
 105                     ;; \
 106                 sparc*)  \
 107                     echo sparc \
 108                     ;; \
 109                 *) \
 110                     echo $(processor)  \
 111                     ;; \
 112         esac
 113     ARCH        := $(shell $(archExpr))
 114   else
 115     ARCH := $(shell isainfo -n)
 116     # ISA_DIR is used to locate 64-bit specific libraries which are generally
 117     # in the same general place as other libraries under the ./$(ARCH) directory
 118     ISA_DIR = /$(ARCH)
 119   endif
 120   # Need to maintain the jre/lib/i386 location for 32-bit Intel
 121   ifeq ($(ARCH), i586)
 122      ARCH_FAMILY = $(ARCH)
 123      LIBARCH     = i386
 124      # Value of Java os.arch property
 125      ARCHPROP    = x86
 126   else
 127      ifeq ($(ARCH), amd64)
 128         ARCH_FAMILY = i586
 129      else
 130         ARCH_FAMILY = sparc
 131      endif
 132      LIBARCH  = $(ARCH)
 133      # Value of Java os.arch property
 134      ARCHPROP = $(LIBARCH)
 135   endif
 136   # The two LIBARCH names
 137   ifeq ($(ARCH_FAMILY), sparc)
 138     LIBARCH32 = sparc
 139     LIBARCH64 = sparcv9
 140   else
 141     LIBARCH32 = i386
 142     LIBARCH64 = amd64
 143   endif
 144   # Suffix for file bundles used in previous release
 145   BUNDLE_FILE_SUFFIX=.tar
 146   # How much RAM does this machine have:
 147   MB_OF_MEMORY=$(shell /etc/prtconf | fgrep 'Memory size:' | expand | cut -d' ' -f3)
 148 endif
 149 
 150 # Platform settings specific to Linux
 151 ifeq ($(SYSTEM_UNAME), Linux)
 152   PLATFORM = linux
 153   # Arch and OS name/version
 154   mach := $(shell uname -m)
 155   archExpr = case "$(mach)" in \
 156                 i[3-9]86) \
 157                     echo i586 \
 158                     ;; \
 159                 ia64) \
 160                     echo ia64 \
 161                     ;; \
 162                 x86_64) \
 163                     echo amd64 \
 164                     ;; \
 165                 sparc*) \
 166                     echo sparc \
 167                     ;; \
 168                 *) \
 169                     echo $(mach) \
 170                     ;; \
 171       esac
 172   ARCH        := $(shell $(archExpr) )
 173   ARCH_FAMILY := $(ARCH)
 174 
 175   # Linux builds may be 32-bit or 64-bit data model.
 176   ifeq ($(ARCH), sparc)
 177     # Linux sparc build can be either 32-bit or 64-bit.
 178     #   Default to 32, but allow explicit setting to 32 or 64.
 179     ifndef ARCH_DATA_MODEL
 180       ARCH_DATA_MODEL=32
 181     endif
 182     ifeq ($(ARCH_DATA_MODEL), 32)
 183       ARCH=sparc
 184     else
 185       ARCH=sparcv9
 186     endif
 187   else
 188     # i586 is 32-bit, amd64 is 64-bit
 189     ifndef ARCH_DATA_MODEL
 190       ifeq ($(ARCH), i586)
 191         ARCH_DATA_MODEL=32
 192       else
 193         ARCH_DATA_MODEL=64
 194       endif
 195     endif
 196   endif
 197 
 198   # Need to maintain the jre/lib/i386 location for 32-bit Intel
 199   ifeq ($(ARCH), i586)
 200     LIBARCH = i386
 201   else
 202     LIBARCH = $(ARCH)
 203   endif
 204 
 205   # Value of Java os.arch property
 206   ARCHPROP  = $(LIBARCH)
 207 
 208   # Suffix for file bundles used in previous release
 209   BUNDLE_FILE_SUFFIX=.tar.gz
 210   # How much RAM does this machine have:
 211   MB_OF_MEMORY := $(shell free -m | fgrep Mem: | awk '{print $$2;}' )
 212 endif
 213 
 214 # Windows with and without CYGWIN will be slightly different
 215 ifeq ($(SYSTEM_UNAME), Windows_NT)
 216   PLATFORM = windows
 217 endif
 218 ifneq (,$(findstring CYGWIN,$(SYSTEM_UNAME)))
 219   PLATFORM = windows
 220   USING_CYGWIN = true
 221   export USING_CYGWIN
 222 endif
 223 
 224 # Platform settings specific to Windows
 225 ifeq ($(PLATFORM), windows)
 226   # Windows builds default to the appropriate for the underlaying
 227   # architecture.
 228   # Temporary disk area
 229   TEMP_DISK=C:/temp
 230   # GNU Make or MKS overrides $(PROCESSOR_ARCHITECTURE) to always
 231   # return "x86". Use the first word of $(PROCESSOR_IDENTIFIER) instead.
 232   PROC_ARCH:=$(word 1, $(PROCESSOR_IDENTIFIER))
 233   PROC_ARCH:=$(subst x86,X86,$(PROC_ARCH))
 234   PROC_ARCH:=$(subst Intel64,X64,$(PROC_ARCH))
 235   PROC_ARCH:=$(subst em64t,X64,$(PROC_ARCH))
 236   PROC_ARCH:=$(subst EM64T,X64,$(PROC_ARCH))
 237   PROC_ARCH:=$(subst amd64,X64,$(PROC_ARCH))
 238   PROC_ARCH:=$(subst AMD64,X64,$(PROC_ARCH))
 239   PROC_ARCH:=$(subst ia64,IA64,$(PROC_ARCH))
 240   ifndef ARCH_DATA_MODEL
 241     ifeq ($(PROC_ARCH),IA64)
 242       ARCH_DATA_MODEL=64
 243     else
 244       ifeq ($(PROC_ARCH),X64)
 245         ARCH_DATA_MODEL=64
 246       else
 247         ARCH_DATA_MODEL=32
 248       endif
 249     endif
 250   endif
 251   export ARCH_DATA_MODEL
 252   ifeq ($(ARCH_DATA_MODEL), 64)
 253     # If the user wants to perform a cross compile build then they must
 254     # - set ARCH_DATA_MODEL=64 and either
 255     #      + set ARCH to ia64 or amd64, or
 256     ifeq ($(PROC_ARCH),X64)
 257       ARCH=amd64
 258     else
 259       ifeq ($(PROC_ARCH),IA64)
 260         ARCH=ia64
 261       endif
 262     endif
 263     LIBARCH=$(ARCH)
 264     # Value of Java os.arch property
 265     ARCHPROP=$(LIBARCH)
 266   else
 267     # LIBARCH is used to preserve the jre/lib/i386 directory name for 32-bit intel
 268     ARCH=i586
 269     LIBARCH=i386
 270     # Value of Java os.arch property
 271     ARCHPROP=x86
 272   endif
 273   ARCH_FAMILY = $(ARCH)
 274   # Where is unwanted output to be delivered?
 275   DEV_NULL = NUL
 276   export DEV_NULL
 277   # Classpath separator
 278   CLASSPATH_SEPARATOR = ;
 279   # The suffix used for object file (.o for unix .obj for windows)
 280   OBJECT_SUFFIX = obj
 281   # The suffix applied to executables (.exe for windows, nothing for solaris)
 282   EXE_SUFFIX = .exe
 283   # The prefix applied to library files (lib for solaris, nothing for windows)
 284   LIB_PREFIX=
 285   LIBRARY_SUFFIX = dll
 286   LIB_SUFFIX     = lib
 287   # User name determination (set _USER)
 288   ifndef USER
 289     ifdef USERNAME
 290       _USER := $(USERNAME)
 291     else
 292       ifdef LOGNAME
 293         _USER := $(LOGNAME)
 294       else
 295         _USER := $(shell id -un)
 296       endif
 297     endif
 298   else
 299     _USER:=$(USER)
 300   endif
 301   # Location of client/server directories
 302   ARCH_VM_SUBDIR=jre/bin
 303   # Suffix for file bundles used in previous release
 304   BUNDLE_FILE_SUFFIX=.tar
 305   # ISHIELD_TEMP_MIN is the difference of an empty C:\TEMP vs. one after a
 306   #     bundles build on windows.
 307   ISHIELD_TEMP_MIN=250000
 308   # How much RAM does this machine have:
 309   ifeq ($(JDK_HAS_MEM_INFO),)
 310     ifeq ($(USING_CYGWIN),true)
 311       # CYGWIN has the 'free' utility
 312       _MB_OF_MEMORY := \
 313            $(shell free -m | grep Mem: | awk '{print $$2;}' )
 314     else
 315       # Windows 2000 has the mem utility, but two memory areas
 316       #    extended memory is what is beyond 1024M
 317       _B_OF_EXT_MEMORY := \
 318            $(shell mem 2> $(DEV_NULL) | \
 319                    grep 'total contiguous extended memory' | awk '{print $$1;}')
 320       ifeq ($(_B_OF_EXT_MEMORY),)
 321           _B_OF_MEMORY := \
 322            $(shell mem 2> $(DEV_NULL) | \
 323                    grep 'total conventional memory' | awk '{print $$1;}')
 324       else
 325         _B_OF_MEMORY := \
 326            $(shell expr 1048576 '+' $(_B_OF_EXT_MEMORY) 2> $(DEV_NULL))
 327       endif
 328       ifeq ($(_B_OF_MEMORY),)
 329         # Windows 2003 has the systeminfo utility use it if mem doesn't work
 330         _MB_OF_MEMORY := \
 331             $(shell systeminfo 2> $(DEV_NULL) | \
 332                     grep 'Total Physical Memory:' | \
 333                     awk '{print $$4;}' | sed -e 's@,@@')
 334       else
 335         _MB_OF_MEMORY := $(shell expr $(_B_OF_MEMORY) '/' 1024 2> $(DEV_NULL))
 336       endif
 337     endif
 338     ifeq ($(shell expr $(_MB_OF_MEMORY) '+' 0 2> $(DEV_NULL)), $(_MB_OF_MEMORY))
 339       MB_OF_MEMORY := $(_MB_OF_MEMORY)
 340     else
 341       MB_OF_MEMORY := 512
 342     endif
 343   endif
 344 endif
 345 
 346 # Unix type settings (same for all unix platforms)
 347 ifneq ($(PLATFORM), windows)
 348   # Temporary disk area
 349   TEMP_DISK=/tmp
 350   # Where is unwanted output to be delivered?
 351   DEV_NULL = /dev/null
 352   export DEV_NULL
 353   # Character used between entries in classpath 
 354   CLASSPATH_SEPARATOR = :
 355   # suffix used for object file (.o for unix .obj for windows)
 356   OBJECT_SUFFIX = o
 357   # The suffix applied to runtime libraries
 358   LIBRARY_SUFFIX = so
 359   # The suffix applied to link libraries
 360   LIB_SUFFIX = so
 361   # The suffix applied to executables (.exe for windows, nothing for solaris)
 362   EXE_SUFFIX =
 363   # The prefix applied to library files (lib for solaris, nothing for windows)
 364   LIB_PREFIX = lib
 365   # User name determination (set _USER)
 366   ifndef USER
 367     ifdef LOGNAME
 368       _USER := $(LOGNAME)
 369     else
 370       _USER := $(shell logname)
 371     endif
 372   else
 373     _USER:=$(USER)
 374   endif
 375   # Location of client/server directories
 376   ARCH_VM_SUBDIR=jre/lib/$(LIBARCH)
 377 endif
 378 
 379 # Machines with 512Mb or less of real memory are considered low memory
 380 #    build machines and adjustments will be made to prevent excessing
 381 #    system swapping during the build.
 382 #    If we don't know, assume 512. Subtract 128 from MB for VM MAX.
 383 #    Don't set VM max over 1024-128=896.
 384 ifeq ($(JDK_HAS_MEM_INFO),)
 385   JDK_HAS_MEM_INFO=true
 386   export JDK_HAS_MEM_INFO
 387   ifneq ($(MB_OF_MEMORY),)
 388     LOW_MEMORY_MACHINE := $(shell \
 389       if [ $(MB_OF_MEMORY) -le 512 ] ; then \
 390         echo "true"; \
 391       else \
 392         echo "false"; \
 393       fi)
 394     MAX_VM_MEMORY := $(shell \
 395       if [ $(MB_OF_MEMORY) -le 1024 ] ; then \
 396         expr $(MB_OF_MEMORY) '-' 128 2> $(DEV_NULL) ; \
 397       else \
 398         echo "896"; \
 399       fi)
 400     MIN_VM_MEMORY := $(shell \
 401       if [ $(MAX_VM_MEMORY) -le 128 ] ; then \
 402         expr $(MAX_VM_MEMORY) '-' 8 2> $(DEV_NULL) ; \
 403       else \
 404         echo "128"; \
 405       fi)
 406   else
 407     MB_OF_MEMORY       := unknown
 408     LOW_MEMORY_MACHINE := true
 409     MAX_VM_MEMORY      := 384
 410     MIN_VM_MEMORY      := 128
 411   endif
 412   export MB_OF_MEMORY
 413   export LOW_MEMORY_MACHINE
 414   export MAX_VM_MEMORY
 415   export MIN_VM_MEMORY
 416 endif
 417 
 418 # If blanks in the username, use the first 4 words and pack them together
 419 _USER1:=$(subst ', ,$(_USER))
 420 _USER2:=$(subst ", ,$(_USER1))
 421 USER:=$(word 1,$(_USER2))$(word 2,$(_USER2))$(word 3,$(_USER2))$(word 4,$(_USER2))
 422 export USER
 423 
 424 export PLATFORM
 425 endif
 426