1 #!/bin/sh 2 3 # 4 # Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 # 7 # This code is free software; you can redistribute it and/or modify it 8 # under the terms of the GNU General Public License version 2 only, as 9 # published by the Free Software Foundation. Oracle designates this 10 # particular file as subject to the "Classpath" exception as provided 11 # by Oracle in the LICENSE file that accompanied this code. 12 # 13 # This code is distributed in the hope that it will be useful, but WITHOUT 14 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 # version 2 for more details (a copy is included in the LICENSE file that 17 # accompanied this code). 18 # 19 # You should have received a copy of the GNU General Public License version 20 # 2 along with this work; if not, write to the Free Software Foundation, 21 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 # 23 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 24 # or visit www.oracle.com if you need additional information or have any 25 # questions. 26 # 27 28 29 ############################################################################# 30 # 31 # Generic build profile.sh for all platforms, works in bash, sh, and ksh. 32 # 33 # Copy this file to your own area, and edit it to suit your needs. 34 # 35 # Ideally you either won't need to set the ALT_* variables because the 36 # build system will find what it needs through system provided paths 37 # or environment variables, or you have installed the component in the 38 # recommended default path. 39 # 40 # If you find yourself forced to set an ALT_* environment variable and 41 # suspect we could have figured it out automatically, please let us know. 42 # 43 # Most ALT_* directory defaults are based on being in the parent directory in 44 # ALT_SLASH_JAVA, so it's possible to create for example a "C:/jdk6" 45 # directory, assign that to ALT_SLASH_JAVA, and place all the components 46 # in that directory. This could also minimize the ALT_* environment 47 # variables you need to set. 48 # 49 ######## 50 # 51 # Assumes basic unix utilities are in the PATH already (uname, hostname, etc.). 52 # 53 # On Windows, assumes PROCESSOR_IDENTIFIER, VS100COMNTOOLS, 54 # SYSTEMROOT (or SystemRoot), COMPUTERNAME (or hostname works), and 55 # USERNAME is defined in the environment. 56 # This profile does not rely on using vcvars32.bat and 64bit Setup.bat. 57 # Uses CYGWIN cygpath to make sure paths are space-free. 58 # 59 # The JDK Makefiles may change in the future, making some of these 60 # settings unnecessary or redundant. 61 # 62 # This is a working example, but may or may not work on all systems. 63 # 64 ############################################################################# 65 # 66 # WARNING: This file will clobber the value of some environment variables. 67 # 68 # Sets up these environment variables for doing JDK builds: 69 # USERNAME 70 # COMPUTERNAME 71 # PATH 72 # Windows Only: 73 # LIB 74 # INCLUDE 75 # PS1 76 # SHELL 77 # 78 # Attempts to set these variables for the JDK builds: 79 # ALT_COMPILER_PATH 80 # ALT_BOOTDIR 81 # Windows Only: 82 # ALT_UNIXCOMMAND_PATH 83 # ALT_DXSDK_PATH 84 # ALT_MSVCRNN_DLL_PATH 85 # 86 ############################################################################# 87 # 88 # Keep in mind that at this point, we are running in some kind of shell 89 # (sh, ksh, or bash). We don't know if it's solaris, linux, or windows 90 # CYGWIN. We need to figure that out. 91 92 # Find user name 93 if [ "${USERNAME}" = "" ] ; then 94 USERNAME="${LOGNAME}" 95 fi 96 if [ "${USERNAME}" = "" ] ; then 97 USERNAME="${USER}" 98 fi 99 export USERNAME 100 101 # Find machine name 102 if [ "${COMPUTERNAME}" = "" ] ; then 103 COMPUTERNAME="$(hostname)" 104 fi 105 export COMPUTERNAME 106 107 # Boot jdk 108 bootjdk=jdk1.6.0 109 importjdk=jdk1.7.0 110 111 # Uses 'uname -s', but only expect SunOS or Linux, assume Windows otherwise. 112 osname=$(uname -s) 113 if [ "${osname}" = SunOS ] ; then 114 115 # System place where JDK installed images are stored? 116 jdk_instances=/usr/jdk/instances 117 118 # Get the Sun Studio compilers (and latest patches for them too) 119 if [ "${ALT_COMPILER_PATH}" = "" ] ; then 120 ALT_COMPILER_PATH=/opt/SUNWspro/bin 121 export ALT_COMPILER_PATH 122 fi 123 if [ ! -d ${ALT_COMPILER_PATH} ] ; then 124 echo "WARNING: Cannot access ALT_COMPILER_PATH=${ALT_COMPILER_PATH}" 125 fi 126 127 # Place compiler path early in PATH to avoid 'cc' conflicts. 128 path4sdk=${ALT_COMPILER_PATH}:/usr/ccs/bin:/usr/ccs/lib:/usr/bin:/bin:/usr/sfw/bin 129 130 # Make sure these are unset 131 unset JAVA_HOME 132 unset LD_LIBRARY_PATH 133 134 # Build in C locale 135 LANG=C 136 export LANG 137 LC_ALL=C 138 export LC_ALL 139 140 umask 002 141 142 elif [ "${osname}" = Linux ] ; then 143 144 # System place where JDK installed images are stored? 145 jdk_instances=/opt/java 146 147 # Use compilers from /usr/bin 148 path4sdk=/usr/bin:/bin:/usr/sbin:/sbin 149 150 # Make sure these are unset 151 unset JAVA_HOME 152 unset LD_LIBRARY_PATH 153 154 # Build in C locale 155 LANG=C 156 export LANG 157 LC_ALL=C 158 export LC_ALL 159 160 umask 002 161 162 else 163 164 # System place where JDK installed images are stored? 165 jdk_instances="C:" 166 167 # Windows: Differs on CYGWIN and the compiler available. 168 # Also, blanks in pathnames gives make headaches, so anything placed 169 # in any ALT_* variable should be the short windows DOS names. 170 171 # Check CYGWIN (should have already been done) 172 # Assumption here is that you are in a shell window via cygwin. 173 proc_arch=`echo "${PROCESSOR_IDENTIFIER}" | expand | cut -d' ' -f1 | sed -e 's@x86@X86@g' -e 's@Intel64@X64@g' -e 's@em64t@X64@g' -e 's@EM64T@X64@g' -e 's@amd64@X64@g' -e 's@AMD64@X64@g' -e 's@ia64@IA64@g'` 174 if [ "${proc_arch}" = "X64" ] ; then 175 windows_arch=amd64 176 else 177 windows_arch=i586 178 fi 179 180 repo=`hg root | sed -e 's@\\\\@/@g'` 181 # We need to check if we are running a CYGWIN shell 182 if [ "$(echo ${osname} | fgrep Cygwin)" != "" -a -f /bin/cygpath ] ; then 183 # For CYGWIN, uname will have "Cygwin" in it, and /bin/cygpath should exist 184 # Utility to convert to short pathnames without spaces 185 cygpath="/usr/bin/cygpath -a -m -s" 186 cygpathp="/usr/bin/cygpath -p" 187 # Most unix utilities are in the /usr/bin 188 unixcommand_path="/usr/bin" 189 # Make the prompt tell you CYGWIN 190 export PS1="CYGWIN:${COMPUTERNAME}:${USERNAME}[\!] " 191 elif [ "$(echo ${osname} | fgrep MINGW)" != "" ] ; then 192 # Utility to convert to short pathnames without spaces 193 cygpath="${repo}/make/tools/msys_build_scripts/dospath.sh" 194 if [ ! -f ${cygpath} ] ; then 195 echo "ERROR: Cannot find cygpath or equivalent on this machine" 196 exit 1 197 fi 198 # Utility to fix a path to MinGW/MSYS format - the equivalent of 'cygpath -p' 199 for tfile in "${repo}/make/scripts/fixpath.pl" "${repo}/../make/scripts/fixpath.pl"; do 200 if [ -f ${tfile} ] ; then 201 cygpathp="/bin/perl ${tfile} -m" 202 fi 203 done; 204 if [ -z "${cygpathp}" ] ; then 205 echo "ERROR: Cannot find make/scripts/fixpath.pl on this machine" 206 exit 1 207 fi 208 unixcommand_path="/usr/bin" 209 else 210 echo "ERROR: Cannot find CYGWIN or MinGW/MSYS on this machine" 211 exit 1 212 fi 213 if [ "${ALT_UNIXCOMMAND_PATH}" != "" ] ; then 214 unixcommand_path=${ALT_UNIXCOMMAND_PATH} 215 fi 216 217 # Default shell 218 export SHELL="${unixcommand_path}/sh" 219 220 # Setup path system (verify this is right) 221 if [ "${SystemRoot}" != "" ] ; then 222 sys_root=$(${cygpath} "${SystemRoot}") 223 elif [ "${SYSTEMROOT}" != "" ] ; then 224 sys_root=$(${cygpath} "${SYSTEMROOT}") 225 else 226 sys_root=$(${cygpath} "C:/WINNT") 227 fi 228 if [ ! -d "${sys_root}" ] ; then 229 echo "WARNING: No system root found at: ${sys_root}" 230 fi 231 232 # Build a : separated path making sure each segment is acceptable to ${osname} 233 path4sdk="${unixcommand_path}:"`${cygpathp} "${sys_root}/system32;${sys_root};${sys_root}/System32/Wbem"` 234 235 # Compiler setup (nasty part) 236 # NOTE: You can use vcvars32.bat to set PATH, LIB, and INCLUDE. 237 # NOTE: CYGWIN has a link.exe too, make sure the compilers are first 238 239 # Use supplied vsvars.sh 240 if [ -f "${repo}/make/scripts/vsvars.sh" ] ; then 241 eval `sh ${repo}/make/scripts/vsvars.sh -v10` 242 elif [ -f "${repo}/../make/scripts/vsvars.sh" ] ; then 243 eval `sh ${repo}/../make/scripts/vsvars.sh -v10` 244 else 245 echo "WARNING: No make/scripts/vsvars.sh file found" 246 fi 247 248 fi 249 250 # Get the previous JDK to be used to bootstrap the build 251 if [ "${ALT_BOOTDIR}" = "" ] ; then 252 ALT_BOOTDIR=${jdk_instances}/${bootjdk} 253 export ALT_BOOTDIR 254 fi 255 if [ ! -d ${ALT_BOOTDIR} ] ; then 256 echo "WARNING: Cannot access ALT_BOOTDIR=${ALT_BOOTDIR}" 257 fi 258 259 # Get the import JDK to be used to get hotspot VM if not built 260 if [ "${ALT_JDK_IMPORT_PATH}" = "" -a -d ${jdk_instances}/${importjdk} ] ; then 261 ALT_JDK_IMPORT_PATH=${jdk_instances}/${importjdk} 262 export ALT_JDK_IMPORT_PATH 263 fi 264 265 # Export PATH setting 266 PATH="${path4sdk}" 267 export PATH 268 269 # Export variables required for Zero 270 if [ "${SHARK_BUILD}" = true ] ; then 271 ZERO_BUILD=true 272 export ZERO_BUILD 273 fi 274 if [ "${ZERO_BUILD}" = true ] ; then 275 # ZERO_LIBARCH is the name of the architecture-specific 276 # subdirectory under $JAVA_HOME/jre/lib 277 arch=$(uname -m) 278 case "${arch}" in 279 x86_64) ZERO_LIBARCH=amd64 ;; 280 i?86) ZERO_LIBARCH=i386 ;; 281 sparc64) ZERO_LIBARCH=sparcv9 ;; 282 arm*) ZERO_LIBARCH=arm ;; 283 *) ZERO_LIBARCH="$(arch)" 284 esac 285 export ZERO_LIBARCH 286 287 # ARCH_DATA_MODEL is the number of bits in a pointer 288 case "${ZERO_LIBARCH}" in 289 i386|ppc|s390|sparc|arm) 290 ARCH_DATA_MODEL=32 291 ;; 292 amd64|ppc64|s390x|sparcv9|ia64|alpha) 293 ARCH_DATA_MODEL=64 294 ;; 295 *) 296 echo "ERROR: Unable to determine ARCH_DATA_MODEL for ${ZERO_LIBARCH}" 297 exit 1 298 esac 299 export ARCH_DATA_MODEL 300 301 # ZERO_ENDIANNESS is the endianness of the processor 302 case "${ZERO_LIBARCH}" in 303 i386|amd64|ia64) 304 ZERO_ENDIANNESS=little 305 ;; 306 ppc*|s390*|sparc*|alpha) 307 ZERO_ENDIANNESS=big 308 ;; 309 *) 310 echo "ERROR: Unable to determine ZERO_ENDIANNESS for ${ZERO_LIBARCH}" 311 exit 1 312 esac 313 export ZERO_ENDIANNESS 314 315 # ZERO_ARCHDEF is used to enable architecture-specific code 316 case "${ZERO_LIBARCH}" in 317 i386) ZERO_ARCHDEF=IA32 ;; 318 ppc*) ZERO_ARCHDEF=PPC ;; 319 s390*) ZERO_ARCHDEF=S390 ;; 320 sparc*) ZERO_ARCHDEF=SPARC ;; 321 *) ZERO_ARCHDEF=$(echo "${ZERO_LIBARCH}" | tr a-z A-Z) 322 esac 323 export ZERO_ARCHDEF 324 325 # ZERO_ARCHFLAG tells the compiler which mode to build for 326 case "${ZERO_LIBARCH}" in 327 s390) 328 ZERO_ARCHFLAG="-m31" 329 ;; 330 *) 331 ZERO_ARCHFLAG="-m${ARCH_DATA_MODEL}" 332 esac 333 export ZERO_ARCHFLAG 334 335 # LIBFFI_CFLAGS and LIBFFI_LIBS tell the compiler how to compile and 336 # link against libffi 337 pkgconfig=$(which pkg-config 2>/dev/null) 338 if [ -x "${pkgconfig}" ] ; then 339 if [ "${LIBFFI_CFLAGS}" = "" ] ; then 340 LIBFFI_CFLAGS=$("${pkgconfig}" --cflags libffi) 341 fi 342 if [ "${LIBFFI_LIBS}" = "" ] ; then 343 LIBFFI_LIBS=$("${pkgconfig}" --libs libffi) 344 fi 345 fi 346 if [ "${LIBFFI_LIBS}" = "" ] ; then 347 LIBFFI_LIBS="-lffi" 348 fi 349 export LIBFFI_CFLAGS 350 export LIBFFI_LIBS 351 352 # LLVM_CFLAGS, LLVM_LDFLAGS and LLVM_LIBS tell the compiler how to 353 # compile and link against LLVM 354 if [ "${SHARK_BUILD}" = true ] ; then 355 if [ "${LLVM_CONFIG}" = "" ] ; then 356 LLVM_CONFIG=$(which llvm-config 2>/dev/null) 357 fi 358 if [ ! -x "${LLVM_CONFIG}" ] ; then 359 echo "ERROR: Unable to locate llvm-config" 360 exit 1 361 fi 362 llvm_components="jit engine nativecodegen" 363 364 unset LLVM_CFLAGS 365 for flag in $("${LLVM_CONFIG}" --cxxflags $llvm_components); do 366 if echo "${flag}" | grep -q '^-[ID]'; then 367 if [ "${flag}" != "-D_DEBUG" ] ; then 368 if [ "${LLVM_CFLAGS}" != "" ] ; then 369 LLVM_CFLAGS="${LLVM_CFLAGS} " 370 fi 371 LLVM_CFLAGS="${LLVM_CFLAGS}${flag}" 372 fi 373 fi 374 done 375 llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//') 376 LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}" 377 378 unset LLVM_LDFLAGS 379 for flag in $("${LLVM_CONFIG}" --ldflags $llvm_components); do 380 if echo "${flag}" | grep -q '^-L'; then 381 if [ "${LLVM_LDFLAGS}" != "" ] ; then 382 LLVM_LDFLAGS="${LLVM_LDFLAGS} " 383 fi 384 LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}" 385 fi 386 done 387 388 unset LLVM_LIBS 389 for flag in $("${LLVM_CONFIG}" --libs $llvm_components); do 390 if echo "${flag}" | grep -q '^-l'; then 391 if [ "${LLVM_LIBS}" != "" ] ; then 392 LLVM_LIBS="${LLVM_LIBS} " 393 fi 394 LLVM_LIBS="${LLVM_LIBS}${flag}" 395 fi 396 done 397 398 export LLVM_CFLAGS 399 export LLVM_LDFLAGS 400 export LLVM_LIBS 401 fi 402 fi 403 404 # Export variables for system zlib 405 # ZLIB_CFLAGS and ZLIB_LIBS tell the compiler how to compile and 406 # link against zlib 407 pkgconfig=$(which pkg-config 2>/dev/null) 408 if [ -x "${pkgconfig}" ] ; then 409 if [ "${ZLIB_CFLAGS}" = "" ] ; then 410 ZLIB_CFLAGS=$("${pkgconfig}" --cflags zlib) 411 fi 412 if [ "${ZLIB_LIBS}" = "" ] ; then 413 ZLIB_LIBS=$("${pkgconfig}" --libs zlib) 414 fi 415 fi 416 if [ "${ZLIB_LIBS}" = "" ] ; then 417 ZLIB_LIBS="-lz" 418 fi 419 export ZLIB_CFLAGS 420 export ZLIB_LIBS 421