source: trunk/openjdk/jdk/make/jdk_generic_profile.sh

Last change on this file was 278, checked in by dmik, 14 years ago

trunk: Merged in openjdk6 b22 from branches/vendor/oracle.

File size: 14.1 KB
Line 
1#!/bin/sh
2
3#
4# Copyright (c) 2007, 2010, 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, 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# Windows Only:
82# ALT_UNIXCOMMAND_PATH
83# ALT_MSDEVTOOLS_PATH
84# ALT_DXSDK_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
93if [ "${USERNAME}" = "" ] ; then
94 USERNAME="${LOGNAME}"
95fi
96if [ "${USERNAME}" = "" ] ; then
97 USERNAME="${USER}"
98fi
99export USERNAME
100
101# Find machine name
102if [ "${COMPUTERNAME}" = "" ] ; then
103 COMPUTERNAME="$(hostname)"
104fi
105export COMPUTERNAME
106
107# Boot jdk
108bootjdk=jdk1.6.0
109importjdk=jdk1.7.0
110
111# Uses 'uname -s', but only expect SunOS or Linux, assume Windows otherwise.
112osname=$(uname -s)
113if [ "${osname}" = SunOS ] ; then
114
115 # System place where JDK installed images are stored?
116 jdk_instances=/usr/jdk/instances
117
118 # Get the SS11 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
142elif [ "${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
162else
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 if [ "$(echo ${PROCESSOR_IDENTIFIER} | fgrep AMD64)" != "" ] ; then
174 windows_arch=amd64
175 else
176 windows_arch=i586
177 fi
178 # We need to check if we are running a CYGWIN shell
179 if [ "$(uname -a | fgrep Cygwin)" != "" -a -f /bin/cygpath ] ; then
180 # For CYGWIN, uname will have "Cygwin" in it, and /bin/cygpath should exist
181 # Utility to convert to short pathnames without spaces
182 cygpath="/usr/bin/cygpath -a -m -s"
183 # Most unix utilities are in the /usr/bin
184 unixcommand_path="/usr/bin"
185 # Make the prompt tell you CYGWIN
186 export PS1="CYGWIN:${COMPUTERNAME}:${USERNAME}[\!] "
187 else
188 echo "ERROR: Cannot find CYGWIN on this machine"
189 exit 1
190 fi
191 if [ "${ALT_UNIXCOMMAND_PATH}" != "" ] ; then
192 unixcommand_path=${ALT_UNIXCOMMAND_PATH}
193 fi
194
195 # Default shell
196 export SHELL="${unixcommand_path}/sh"
197
198 # Setup path system (verify this is right)
199 if [ "${SystemRoot}" != "" ] ; then
200 sys_root=$(${cygpath} "${SystemRoot}")
201 elif [ "${SYSTEMROOT}" != "" ] ; then
202 sys_root=$(${cygpath} "${SYSTEMROOT}")
203 else
204 sys_root=$(${cygpath} "C:/WINNT")
205 fi
206 path4sdk="${unixcommand_path};${sys_root}/system32;${sys_root};${sys_root}/System32/Wbem"
207 if [ ! -d "${sys_root}" ] ; then
208 echo "WARNING: No system root found at: ${sys_root}"
209 fi
210
211 # Compiler setup (nasty part)
212 # NOTE: You can use vcvars32.bat to set PATH, LIB, and INCLUDE.
213 # NOTE: CYGWIN has a link.exe too, make sure the compilers are first
214 if [ "${windows_arch}" = i586 ] ; then
215 # 32bit Windows compiler settings
216 # VisualStudio .NET 2003 VC++ 7.1 (VS71COMNTOOLS should be defined)
217 vs_root=$(${cygpath} "${VS71COMNTOOLS}/../..")
218 # Fill in PATH, LIB, and INCLUDE (unset all others to make sure)
219 msdev_root="${vs_root}/Common7/Tools"
220 msdevtools_path="${msdev_root}/bin"
221 vc7_root="${vs_root}/Vc7"
222 compiler_path="${vc7_root}/bin"
223 platform_sdk="${vc7_root}/PlatformSDK"
224
225 # LIB and INCLUDE must use ; as a separator
226 include4sdk="${vc7_root}/atlmfc/include"
227 include4sdk="${include4sdk};${vc7_root}/include"
228 include4sdk="${include4sdk};${platform_sdk}/include/prerelease"
229 include4sdk="${include4sdk};${platform_sdk}/include"
230 include4sdk="${include4sdk};${vs_root}/SDK/v1.1/include"
231 lib4sdk="${lib4sdk};${vc7_root}/lib"
232 lib4sdk="${lib4sdk};${platform_sdk}/lib/prerelease"
233 lib4sdk="${lib4sdk};${platform_sdk}/lib"
234 lib4sdk="${lib4sdk};${vs_root}/SDK/v1.1/lib"
235 # Search path and DLL locating path
236 # WARNING: CYGWIN has a link.exe too, make sure compilers are first
237 path4sdk="${vs_root}/Common7/Tools/bin;${path4sdk}"
238 path4sdk="${vs_root}/SDK/v1.1/bin;${path4sdk}"
239 path4sdk="${vs_root}/Common7/Tools;${path4sdk}"
240 path4sdk="${vs_root}/Common7/Tools/bin/prerelease;${path4sdk}"
241 path4sdk="${vs_root}/Common7/IDE;${path4sdk}"
242 path4sdk="${compiler_path};${path4sdk}"
243 elif [ "${windows_arch}" = amd64 ] ; then
244 # AMD64 64bit Windows compiler settings
245 if [ "${MSSDK}" != "" ] ; then
246 platform_sdk=${MSSDK}
247 else
248 platform_sdk=$(${cygpath} "C:/Program Files/Microsoft Platform SDK/")
249 fi
250 if [ "${ALT_COMPILER_PATH}" != "" ] ; then
251 compiler_path=${ALT_COMPILER_PATH}
252 if [ "${MSSDK}" = "" ] ; then
253 platform_sdk=${ALT_COMPILER_PATH}/../../../..
254 fi
255 else
256 compiler_path="${platform_sdk}/Bin/win64/x86/AMD64"
257 fi
258 if [ "${ALT_MSDEVTOOLS_PATH}" != "" ] ; then
259 msdevtools_path=${ALT_MSDEVTOOLS_PATH}
260 else
261 msdevtools_path="${platform_sdk}/Bin/win64/x86/AMD64"
262 fi
263 msdevtools_path="${compiler_path}"
264 # LIB and INCLUDE must use ; as a separator
265 include4sdk="${platform_sdk}/Include"
266 include4sdk="${include4sdk};${platform_sdk}/Include/crt/sys"
267 include4sdk="${include4sdk};${platform_sdk}/Include/mfc"
268 include4sdk="${include4sdk};${platform_sdk}/Include/atl"
269 include4sdk="${include4sdk};${platform_sdk}/Include/crt"
270 lib4sdk="${platform_sdk}/Lib/AMD64"
271 lib4sdk="${lib4sdk};${platform_sdk}/Lib/AMD64/atlmfc"
272 # Search path and DLL locating path
273 # WARNING: CYGWIN has a link.exe too, make sure compilers are first
274 path4sdk="${platform_sdk}/bin;${path4sdk}"
275 path4sdk="${compiler_path};${path4sdk}"
276 fi
277 # Export LIB and INCLUDE
278 unset lib
279 unset Lib
280 LIB="${lib4sdk}"
281 export LIB
282 unset include
283 unset Include
284 INCLUDE="${include4sdk}"
285 export INCLUDE
286
287 # Turn all \\ into /, remove duplicates and trailing /
288 slash_path="$(echo ${path4sdk} | sed -e 's@\\\\@/@g' -e 's@//@/@g' -e 's@/$@@' -e 's@/;@;@g')"
289 path4sdk="${slash_path}"
290
291 # Convert path4sdk to cygwin style
292 path4sdk="$(/usr/bin/cygpath -p ${path4sdk})"
293
294fi
295
296# Get the previous JDK to be used to bootstrap the build
297if [ "${ALT_BOOTDIR}" = "" ] ; then
298 ALT_BOOTDIR=${jdk_instances}/${bootjdk}
299 export ALT_BOOTDIR
300fi
301if [ ! -d ${ALT_BOOTDIR} ] ; then
302 echo "WARNING: Cannot access ALT_BOOTDIR=${ALT_BOOTDIR}"
303fi
304
305# Get the import JDK to be used to get hotspot VM if not built
306if [ "${ALT_JDK_IMPORT_PATH}" = "" -a -d ${jdk_instances}/${importjdk} ] ; then
307 ALT_JDK_IMPORT_PATH=${jdk_instances}/${importjdk}
308 export ALT_JDK_IMPORT_PATH
309fi
310
311# Export PATH setting
312PATH="${path4sdk}"
313export PATH
314
315# Export variables required for Zero
316if [ "${SHARK_BUILD}" = true ] ; then
317 ZERO_BUILD=true
318 export ZERO_BUILD
319fi
320if [ "${ZERO_BUILD}" = true ] ; then
321 # ZERO_LIBARCH is the name of the architecture-specific
322 # subdirectory under $JAVA_HOME/jre/lib
323 arch=$(uname -m)
324 case "${arch}" in
325 x86_64) ZERO_LIBARCH=amd64 ;;
326 i?86) ZERO_LIBARCH=i386 ;;
327 sparc64) ZERO_LIBARCH=sparcv9 ;;
328 arm*) ZERO_LIBARCH=arm ;;
329 *) ZERO_LIBARCH="$(arch)"
330 esac
331 export ZERO_LIBARCH
332
333 # ARCH_DATA_MODEL is the number of bits in a pointer
334 case "${ZERO_LIBARCH}" in
335 i386|ppc|s390|sparc|arm)
336 ARCH_DATA_MODEL=32
337 ;;
338 amd64|ppc64|s390x|sparcv9|ia64|alpha)
339 ARCH_DATA_MODEL=64
340 ;;
341 *)
342 echo "ERROR: Unable to determine ARCH_DATA_MODEL for ${ZERO_LIBARCH}"
343 exit 1
344 esac
345 export ARCH_DATA_MODEL
346
347 # ZERO_ENDIANNESS is the endianness of the processor
348 case "${ZERO_LIBARCH}" in
349 i386|amd64|ia64)
350 ZERO_ENDIANNESS=little
351 ;;
352 ppc*|s390*|sparc*|alpha)
353 ZERO_ENDIANNESS=big
354 ;;
355 *)
356 echo "ERROR: Unable to determine ZERO_ENDIANNESS for ${ZERO_LIBARCH}"
357 exit 1
358 esac
359 export ZERO_ENDIANNESS
360
361 # ZERO_ARCHDEF is used to enable architecture-specific code
362 case "${ZERO_LIBARCH}" in
363 i386) ZERO_ARCHDEF=IA32 ;;
364 ppc*) ZERO_ARCHDEF=PPC ;;
365 s390*) ZERO_ARCHDEF=S390 ;;
366 sparc*) ZERO_ARCHDEF=SPARC ;;
367 *) ZERO_ARCHDEF=$(echo "${ZERO_LIBARCH}" | tr a-z A-Z)
368 esac
369 export ZERO_ARCHDEF
370
371 # ZERO_ARCHFLAG tells the compiler which mode to build for
372 case "${ZERO_LIBARCH}" in
373 s390)
374 ZERO_ARCHFLAG="-m31"
375 ;;
376 *)
377 ZERO_ARCHFLAG="-m${ARCH_DATA_MODEL}"
378 esac
379 export ZERO_ARCHFLAG
380
381 # LIBFFI_CFLAGS and LIBFFI_LIBS tell the compiler how to compile and
382 # link against libffi
383 pkgconfig=$(which pkg-config 2>/dev/null)
384 if [ -x "${pkgconfig}" ] ; then
385 if [ "${LIBFFI_CFLAGS}" = "" ] ; then
386 LIBFFI_CFLAGS=$("${pkgconfig}" --cflags libffi)
387 fi
388 if [ "${LIBFFI_LIBS}" = "" ] ; then
389 LIBFFI_LIBS=$("${pkgconfig}" --libs libffi)
390 fi
391 fi
392 if [ "${LIBFFI_LIBS}" = "" ] ; then
393 LIBFFI_LIBS="-lffi"
394 fi
395 export LIBFFI_CFLAGS
396 export LIBFFI_LIBS
397
398 # LLVM_CFLAGS, LLVM_LDFLAGS and LLVM_LIBS tell the compiler how to
399 # compile and link against LLVM
400 if [ "${SHARK_BUILD}" = true ] ; then
401 if [ "${LLVM_CONFIG}" = "" ] ; then
402 LLVM_CONFIG=$(which llvm-config 2>/dev/null)
403 fi
404 if [ ! -x "${LLVM_CONFIG}" ] ; then
405 echo "ERROR: Unable to locate llvm-config"
406 exit 1
407 fi
408 llvm_components="jit engine nativecodegen"
409
410 unset LLVM_CFLAGS
411 for flag in $("${LLVM_CONFIG}" --cxxflags $llvm_components); do
412 if echo "${flag}" | grep -q '^-[ID]'; then
413 if [ "${flag}" != "-D_DEBUG" ] ; then
414 if [ "${LLVM_CFLAGS}" != "" ] ; then
415 LLVM_CFLAGS="${LLVM_CFLAGS} "
416 fi
417 LLVM_CFLAGS="${LLVM_CFLAGS}${flag}"
418 fi
419 fi
420 done
421 llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//')
422 LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}"
423
424 unset LLVM_LDFLAGS
425 for flag in $("${LLVM_CONFIG}" --ldflags $llvm_components); do
426 if echo "${flag}" | grep -q '^-L'; then
427 if [ "${LLVM_LDFLAGS}" != "" ] ; then
428 LLVM_LDFLAGS="${LLVM_LDFLAGS} "
429 fi
430 LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}"
431 fi
432 done
433
434 unset LLVM_LIBS
435 for flag in $("${LLVM_CONFIG}" --libs $llvm_components); do
436 if echo "${flag}" | grep -q '^-l'; then
437 if [ "${LLVM_LIBS}" != "" ] ; then
438 LLVM_LIBS="${LLVM_LIBS} "
439 fi
440 LLVM_LIBS="${LLVM_LIBS}${flag}"
441 fi
442 done
443
444 export LLVM_CFLAGS
445 export LLVM_LDFLAGS
446 export LLVM_LIBS
447 fi
448fi
Note: See TracBrowser for help on using the repository browser.