blob: 151ecb651329f14bf669f09354c04b301f1585d3 [file] [log] [blame]
duke6e45e102007-12-01 00:00:00 +00001#!/bin/sh
2
3#
ohair3ae113d2010-12-21 18:21:26 -08004# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
duke6e45e102007-12-01 00:00:00 +00005# 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
ohair2283b9d2010-05-25 15:58:33 -07009# published by the Free Software Foundation. Oracle designates this
duke6e45e102007-12-01 00:00:00 +000010# particular file as subject to the "Classpath" exception as provided
ohair2283b9d2010-05-25 15:58:33 -070011# by Oracle in the LICENSE file that accompanied this code.
duke6e45e102007-12-01 00:00:00 +000012#
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#
ohair2283b9d2010-05-25 15:58:33 -070023# 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.
duke6e45e102007-12-01 00:00:00 +000026#
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, VS71COMNTOOLS,
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# ALT_BINARY_PLUGS_PATH
82# ALT_CLOSED_JDK_IMPORT_PATH
83# Windows Only:
84# ALT_UNIXCOMMAND_PATH
duke6e45e102007-12-01 00:00:00 +000085# ALT_DXSDK_PATH
86# ALT_MSVCRT_DLL_PATH
87# ALT_MSVCR71_DLL_PATH
88#
89#############################################################################
90#
91# Keep in mind that at this point, we are running in some kind of shell
92# (sh, ksh, or bash). We don't know if it's solaris, linux, or windows
93# CYGWIN. We need to figure that out.
94
95# Find user name
96if [ "${USERNAME}" = "" ] ; then
97 USERNAME="${LOGNAME}"
98fi
99if [ "${USERNAME}" = "" ] ; then
100 USERNAME="${USER}"
101fi
102export USERNAME
103
104# Find machine name
105if [ "${COMPUTERNAME}" = "" ] ; then
106 COMPUTERNAME="$(hostname)"
107fi
108export COMPUTERNAME
109
110# Boot jdk
111bootjdk=jdk1.6.0
112importjdk=jdk1.7.0
113
114# Uses 'uname -s', but only expect SunOS or Linux, assume Windows otherwise.
115osname=$(uname -s)
116if [ "${osname}" = SunOS ] ; then
117
118 # System place where JDK installed images are stored?
119 jdk_instances=/usr/jdk/instances
120
ohair3f083862008-06-04 09:38:18 -0700121 # Get the Sun Studio compilers (and latest patches for them too)
duke6e45e102007-12-01 00:00:00 +0000122 if [ "${ALT_COMPILER_PATH}" = "" ] ; then
123 ALT_COMPILER_PATH=/opt/SUNWspro/bin
124 export ALT_COMPILER_PATH
125 fi
126 if [ ! -d ${ALT_COMPILER_PATH} ] ; then
127 echo "WARNING: Cannot access ALT_COMPILER_PATH=${ALT_COMPILER_PATH}"
128 fi
129
130 # Place compiler path early in PATH to avoid 'cc' conflicts.
131 path4sdk=${ALT_COMPILER_PATH}:/usr/ccs/bin:/usr/ccs/lib:/usr/bin:/bin:/usr/sfw/bin
132
133 # Make sure these are unset
134 unset JAVA_HOME
135 unset LD_LIBRARY_PATH
136
137 # Build in C locale
138 LANG=C
139 export LANG
140 LC_ALL=C
141 export LC_ALL
142
143 umask 002
144
145elif [ "${osname}" = Linux ] ; then
146
147 # System place where JDK installed images are stored?
148 jdk_instances=/opt/java
149
150 # Use compilers from /usr/bin
151 path4sdk=/usr/bin:/bin:/usr/sbin:/sbin
152
153 # Make sure these are unset
154 unset JAVA_HOME
155 unset LD_LIBRARY_PATH
156
157 # Build in C locale
158 LANG=C
159 export LANG
160 LC_ALL=C
161 export LC_ALL
162
163 umask 002
164
165else
166
167 # System place where JDK installed images are stored?
168 jdk_instances="C:"
169
170 # Windows: Differs on CYGWIN and the compiler available.
171 # Also, blanks in pathnames gives make headaches, so anything placed
172 # in any ALT_* variable should be the short windows DOS names.
173
174 # Check CYGWIN (should have already been done)
175 # Assumption here is that you are in a shell window via cygwin.
ohaire2a87ec2010-06-07 12:22:21 -0700176 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'`
ohair1e16de92009-03-26 16:52:00 -0700177 if [ "${proc_arch}" = "X64" ] ; then
duke6e45e102007-12-01 00:00:00 +0000178 windows_arch=amd64
179 else
180 windows_arch=i586
181 fi
182 # We need to check if we are running a CYGWIN shell
183 if [ "$(uname -a | fgrep Cygwin)" != "" -a -f /bin/cygpath ] ; then
184 # For CYGWIN, uname will have "Cygwin" in it, and /bin/cygpath should exist
185 # Utility to convert to short pathnames without spaces
186 cygpath="/usr/bin/cygpath -a -m -s"
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 else
192 echo "ERROR: Cannot find CYGWIN on this machine"
193 exit 1
194 fi
195 if [ "${ALT_UNIXCOMMAND_PATH}" != "" ] ; then
196 unixcommand_path=${ALT_UNIXCOMMAND_PATH}
197 fi
198
199 # Default shell
200 export SHELL="${unixcommand_path}/sh"
201
202 # Setup path system (verify this is right)
203 if [ "${SystemRoot}" != "" ] ; then
204 sys_root=$(${cygpath} "${SystemRoot}")
205 elif [ "${SYSTEMROOT}" != "" ] ; then
206 sys_root=$(${cygpath} "${SYSTEMROOT}")
207 else
208 sys_root=$(${cygpath} "C:/WINNT")
209 fi
210 path4sdk="${unixcommand_path};${sys_root}/system32;${sys_root};${sys_root}/System32/Wbem"
211 if [ ! -d "${sys_root}" ] ; then
212 echo "WARNING: No system root found at: ${sys_root}"
213 fi
214
215 # Compiler setup (nasty part)
216 # NOTE: You can use vcvars32.bat to set PATH, LIB, and INCLUDE.
217 # NOTE: CYGWIN has a link.exe too, make sure the compilers are first
218 if [ "${windows_arch}" = i586 ] ; then
219 # 32bit Windows compiler settings
220 # VisualStudio .NET 2003 VC++ 7.1 (VS71COMNTOOLS should be defined)
221 vs_root=$(${cygpath} "${VS71COMNTOOLS}/../..")
222 # Fill in PATH, LIB, and INCLUDE (unset all others to make sure)
duke6e45e102007-12-01 00:00:00 +0000223 vc7_root="${vs_root}/Vc7"
224 compiler_path="${vc7_root}/bin"
225 platform_sdk="${vc7_root}/PlatformSDK"
226
227 # LIB and INCLUDE must use ; as a separator
228 include4sdk="${vc7_root}/atlmfc/include"
229 include4sdk="${include4sdk};${vc7_root}/include"
230 include4sdk="${include4sdk};${platform_sdk}/include/prerelease"
231 include4sdk="${include4sdk};${platform_sdk}/include"
232 include4sdk="${include4sdk};${vs_root}/SDK/v1.1/include"
233 lib4sdk="${lib4sdk};${vc7_root}/lib"
234 lib4sdk="${lib4sdk};${platform_sdk}/lib/prerelease"
235 lib4sdk="${lib4sdk};${platform_sdk}/lib"
236 lib4sdk="${lib4sdk};${vs_root}/SDK/v1.1/lib"
237 # Search path and DLL locating path
238 # WARNING: CYGWIN has a link.exe too, make sure compilers are first
239 path4sdk="${vs_root}/Common7/Tools/bin;${path4sdk}"
240 path4sdk="${vs_root}/SDK/v1.1/bin;${path4sdk}"
241 path4sdk="${vs_root}/Common7/Tools;${path4sdk}"
242 path4sdk="${vs_root}/Common7/Tools/bin/prerelease;${path4sdk}"
243 path4sdk="${vs_root}/Common7/IDE;${path4sdk}"
244 path4sdk="${compiler_path};${path4sdk}"
245 elif [ "${windows_arch}" = amd64 ] ; then
246 # AMD64 64bit Windows compiler settings
247 if [ "${ALT_DEPLOY_MSSDK}" != "" ] ; then
248 platform_sdk=${ALT_DEPLOY_MSSDK}
249 else
250 platform_sdk=$(${cygpath} "C:/Program Files/Microsoft Platform SDK/")
251 fi
252 if [ "${ALT_COMPILER_PATH}" != "" ] ; then
253 compiler_path=${ALT_COMPILER_PATH}
254 if [ "${ALT_DEPLOY_MSSDK}" = "" ] ; then
255 platform_sdk=${ALT_COMPILER_PATH}/../../../..
256 fi
257 else
258 compiler_path="${platform_sdk}/Bin/win64/x86/AMD64"
259 fi
duke6e45e102007-12-01 00:00:00 +0000260 # LIB and INCLUDE must use ; as a separator
261 include4sdk="${platform_sdk}/Include"
262 include4sdk="${include4sdk};${platform_sdk}/Include/crt/sys"
263 include4sdk="${include4sdk};${platform_sdk}/Include/mfc"
264 include4sdk="${include4sdk};${platform_sdk}/Include/atl"
265 include4sdk="${include4sdk};${platform_sdk}/Include/crt"
266 lib4sdk="${platform_sdk}/Lib/AMD64"
267 lib4sdk="${lib4sdk};${platform_sdk}/Lib/AMD64/atlmfc"
268 # Search path and DLL locating path
269 # WARNING: CYGWIN has a link.exe too, make sure compilers are first
270 path4sdk="${platform_sdk}/bin;${path4sdk}"
271 path4sdk="${compiler_path};${path4sdk}"
272 fi
273 # Export LIB and INCLUDE
274 unset lib
275 unset Lib
276 LIB="${lib4sdk}"
277 export LIB
278 unset include
279 unset Include
280 INCLUDE="${include4sdk}"
281 export INCLUDE
282
283 # Turn all \\ into /, remove duplicates and trailing /
284 slash_path="$(echo ${path4sdk} | sed -e 's@\\\\@/@g' -e 's@//@/@g' -e 's@/$@@' -e 's@/;@;@g')"
285 path4sdk="${slash_path}"
286
287 # Convert path4sdk to cygwin style
288 path4sdk="$(/usr/bin/cygpath -p ${path4sdk})"
289
290fi
291
292# Get the previous JDK to be used to bootstrap the build
293if [ "${ALT_BOOTDIR}" = "" ] ; then
294 ALT_BOOTDIR=${jdk_instances}/${bootjdk}
295 export ALT_BOOTDIR
296fi
297if [ ! -d ${ALT_BOOTDIR} ] ; then
298 echo "WARNING: Cannot access ALT_BOOTDIR=${ALT_BOOTDIR}"
299fi
300
301# Get the import JDK to be used to get hotspot VM if not built
302if [ "${ALT_JDK_IMPORT_PATH}" = "" -a -d ${jdk_instances}/${importjdk} ] ; then
303 ALT_JDK_IMPORT_PATH=${jdk_instances}/${importjdk}
304 export ALT_JDK_IMPORT_PATH
305fi
306
307# Get the latest JDK binary plugs or build to import pre-built binaries
308if [ "${ALT_BINARY_PLUGS_PATH}" = "" ] ; then
309 binplugs=${jdk_instances}/openjdk-binary-plugs
310 jdkplugs=${jdk_instances}/${importjdk}
311 if [ -d ${binplugs} ] ; then
312 ALT_BINARY_PLUGS_PATH=${binplugs}
313 export ALT_BINARY_PLUGS_PATH
314 elif [ "${ALT_CLOSED_JDK_IMPORT_PATH}" = "" -a -d ${jdkplugs} ] ; then
315 ALT_CLOSED_JDK_IMPORT_PATH=${jdkplugs}
316 export ALT_CLOSED_JDK_IMPORT_PATH
317 fi
318 if [ "${ALT_BINARY_PLUGS_PATH}" = "" ] ; then
319 echo "WARNING: Missing ALT_BINARY_PLUGS_PATH: ${binplugs}"
320 fi
321fi
322if [ "${ALT_BINARY_PLUGS_PATH}" != "" -a ! -d "${ALT_BINARY_PLUGS_PATH}" ] ; then
323 echo "WARNING: Cannot access ALT_BINARY_PLUGS_PATH=${ALT_BINARY_PLUGS_PATH}"
324fi
325if [ "${ALT_CLOSED_JDK_IMPORT_PATH}" != "" -a ! -d "${ALT_CLOSED_JDK_IMPORT_PATH}" ] ; then
326 echo "WARNING: Cannot access ALT_CLOSED_JDK_IMPORT_PATH=${ALT_CLOSED_JDK_IMPORT_PATH}"
327fi
328
329# Export PATH setting
330PATH="${path4sdk}"
331export PATH
332
gbenson24e3a5d2009-10-15 13:27:59 +0100333# Export variables required for Zero
gbensond05acae2010-08-13 22:26:27 +0100334if [ "${SHARK_BUILD}" = true ] ; then
335 ZERO_BUILD=true
336 export ZERO_BUILD
337fi
gbenson24e3a5d2009-10-15 13:27:59 +0100338if [ "${ZERO_BUILD}" = true ] ; then
339 # ZERO_LIBARCH is the name of the architecture-specific
340 # subdirectory under $JAVA_HOME/jre/lib
341 arch=$(uname -m)
342 case "${arch}" in
343 x86_64) ZERO_LIBARCH=amd64 ;;
344 i?86) ZERO_LIBARCH=i386 ;;
345 sparc64) ZERO_LIBARCH=sparcv9 ;;
346 arm*) ZERO_LIBARCH=arm ;;
347 *) ZERO_LIBARCH="$(arch)"
348 esac
349 export ZERO_LIBARCH
350
351 # ARCH_DATA_MODEL is the number of bits in a pointer
352 case "${ZERO_LIBARCH}" in
353 i386|ppc|s390|sparc|arm)
354 ARCH_DATA_MODEL=32
355 ;;
356 amd64|ppc64|s390x|sparcv9|ia64|alpha)
357 ARCH_DATA_MODEL=64
358 ;;
359 *)
360 echo "ERROR: Unable to determine ARCH_DATA_MODEL for ${ZERO_LIBARCH}"
361 exit 1
362 esac
363 export ARCH_DATA_MODEL
364
365 # ZERO_ENDIANNESS is the endianness of the processor
366 case "${ZERO_LIBARCH}" in
367 i386|amd64|ia64)
368 ZERO_ENDIANNESS=little
369 ;;
370 ppc*|s390*|sparc*|alpha)
371 ZERO_ENDIANNESS=big
372 ;;
373 *)
374 echo "ERROR: Unable to determine ZERO_ENDIANNESS for ${ZERO_LIBARCH}"
375 exit 1
376 esac
377 export ZERO_ENDIANNESS
378
379 # ZERO_ARCHDEF is used to enable architecture-specific code
380 case "${ZERO_LIBARCH}" in
381 i386) ZERO_ARCHDEF=IA32 ;;
382 ppc*) ZERO_ARCHDEF=PPC ;;
383 s390*) ZERO_ARCHDEF=S390 ;;
384 sparc*) ZERO_ARCHDEF=SPARC ;;
385 *) ZERO_ARCHDEF=$(echo "${ZERO_LIBARCH}" | tr a-z A-Z)
386 esac
387 export ZERO_ARCHDEF
388
389 # ZERO_ARCHFLAG tells the compiler which mode to build for
390 case "${ZERO_LIBARCH}" in
391 s390)
392 ZERO_ARCHFLAG="-m31"
393 ;;
394 *)
395 ZERO_ARCHFLAG="-m${ARCH_DATA_MODEL}"
396 esac
397 export ZERO_ARCHFLAG
398
399 # LIBFFI_CFLAGS and LIBFFI_LIBS tell the compiler how to compile and
400 # link against libffi
401 pkgconfig=$(which pkg-config 2>/dev/null)
402 if [ -x "${pkgconfig}" ] ; then
403 if [ "${LIBFFI_CFLAGS}" = "" ] ; then
404 LIBFFI_CFLAGS=$("${pkgconfig}" --cflags libffi)
405 fi
406 if [ "${LIBFFI_LIBS}" = "" ] ; then
407 LIBFFI_LIBS=$("${pkgconfig}" --libs libffi)
408 fi
409 fi
410 if [ "${LIBFFI_LIBS}" = "" ] ; then
411 LIBFFI_LIBS="-lffi"
412 fi
413 export LIBFFI_CFLAGS
414 export LIBFFI_LIBS
gbensond05acae2010-08-13 22:26:27 +0100415
416 # LLVM_CFLAGS, LLVM_LDFLAGS and LLVM_LIBS tell the compiler how to
417 # compile and link against LLVM
418 if [ "${SHARK_BUILD}" = true ] ; then
419 if [ "${LLVM_CONFIG}" = "" ] ; then
420 LLVM_CONFIG=$(which llvm-config 2>/dev/null)
421 fi
422 if [ ! -x "${LLVM_CONFIG}" ] ; then
423 echo "ERROR: Unable to locate llvm-config"
424 exit 1
425 fi
426 llvm_components="jit engine nativecodegen"
427
428 unset LLVM_CFLAGS
429 for flag in $("${LLVM_CONFIG}" --cxxflags $llvm_components); do
430 if echo "${flag}" | grep -q '^-[ID]'; then
431 if [ "${flag}" != "-D_DEBUG" ] ; then
432 if [ "${LLVM_CFLAGS}" != "" ] ; then
433 LLVM_CFLAGS="${LLVM_CFLAGS} "
434 fi
435 LLVM_CFLAGS="${LLVM_CFLAGS}${flag}"
436 fi
437 fi
438 done
439 llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//')
440 LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}"
441
442 unset LLVM_LDFLAGS
443 for flag in $("${LLVM_CONFIG}" --ldflags $llvm_components); do
444 if echo "${flag}" | grep -q '^-L'; then
445 if [ "${LLVM_LDFLAGS}" != "" ] ; then
446 LLVM_LDFLAGS="${LLVM_LDFLAGS} "
447 fi
448 LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}"
449 fi
450 done
451
452 unset LLVM_LIBS
453 for flag in $("${LLVM_CONFIG}" --libs $llvm_components); do
454 if echo "${flag}" | grep -q '^-l'; then
455 if [ "${LLVM_LIBS}" != "" ] ; then
456 LLVM_LIBS="${LLVM_LIBS} "
457 fi
458 LLVM_LIBS="${LLVM_LIBS}${flag}"
459 fi
460 done
461
462 export LLVM_CFLAGS
463 export LLVM_LDFLAGS
464 export LLVM_LIBS
465 fi
gbenson24e3a5d2009-10-15 13:27:59 +0100466fi