Thu, 01 Aug 2013 17:24:26 -0700
Merge
1 #
2 # Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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. Oracle designates this
8 # particular file as subject to the "Classpath" exception as provided
9 # by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 # or visit www.oracle.com if you need additional information or have any
23 # questions.
24 #
26 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT],
27 [
28 if test "x$VS_ENV_CMD" = x; then
29 VS100BASE="$1"
30 METHOD="$2"
31 BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VS100BASE)
32 if test -d "$VS100BASE"; then
33 if test -f "$VS100BASE/$VCVARSFILE"; then
34 AC_MSG_NOTICE([Found Visual Studio installation at $VS100BASE using $METHOD])
35 VS_ENV_CMD="$VS100BASE/$VCVARSFILE"
36 else
37 AC_MSG_NOTICE([Found Visual Studio installation at $VS100BASE using $METHOD])
38 AC_MSG_NOTICE([Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring])
39 fi
40 fi
41 fi
42 ])
44 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT],
45 [
46 if test "x$VS_ENV_CMD" = x; then
47 WIN_SDK_BASE="$1"
48 METHOD="$2"
49 BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(WIN_SDK_BASE)
50 if test -d "$WIN_SDK_BASE"; then
51 # There have been cases of partial or broken SDK installations. A missing
52 # lib dir is not going to work.
53 if test ! -d "$WIN_SDK_BASE/../lib"; then
54 AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
55 AC_MSG_NOTICE([Warning: Installation is broken, lib dir is missing. Ignoring])
56 elif test -f "$WIN_SDK_BASE/SetEnv.Cmd"; then
57 AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
58 VS_ENV_CMD="$WIN_SDK_BASE/SetEnv.Cmd"
59 if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
60 VS_ENV_ARGS="/x86"
61 else
62 VS_ENV_ARGS="/x64"
63 fi
64 else
65 AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
66 AC_MSG_NOTICE([Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring])
67 fi
68 fi
69 fi
70 ])
72 AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE],
73 [
74 if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
75 VCVARSFILE="vc/bin/vcvars32.bat"
76 else
77 VCVARSFILE="vc/bin/amd64/vcvars64.bat"
78 fi
80 VS_ENV_CMD=""
81 VS_ENV_ARGS=""
82 if test "x$with_toolsdir" != x; then
83 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$with_toolsdir/../..], [--with-tools-dir])
84 fi
86 if test "x$with_toolsdir" != x && test "x$VS_ENV_CMD" = x; then
87 # Having specified an argument which is incorrect will produce an instant failure;
88 # we should not go on looking
89 AC_MSG_NOTICE([The path given by --with-tools-dir does not contain a valid Visual Studio installation])
90 AC_MSG_NOTICE([Please point to the VC/bin directory within the Visual Studio installation])
91 AC_MSG_ERROR([Cannot locate a valid Visual Studio installation])
92 fi
94 if test "x$VS100COMNTOOLS" != x; then
95 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$VS100COMNTOOLS/../..], [VS100COMNTOOLS variable])
96 fi
97 if test "x$PROGRAMFILES" != x; then
98 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$PROGRAMFILES/Microsoft Visual Studio 10.0], [well-known name])
99 fi
100 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([C:/Program Files/Microsoft Visual Studio 10.0], [well-known name])
101 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([C:/Program Files (x86)/Microsoft Visual Studio 10.0], [well-known name])
103 if test "x$ProgramW6432" != x; then
104 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$ProgramW6432/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
105 fi
106 if test "x$PROGRAMW6432" != x; then
107 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$PROGRAMW6432/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
108 fi
109 if test "x$PROGRAMFILES" != x; then
110 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$PROGRAMFILES/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
111 fi
112 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([C:/Program Files/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
113 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
114 ])
116 # Check if the VS env variables were setup prior to running configure.
117 # If not, then find vcvarsall.bat and run it automatically, and integrate
118 # the set env variables into the spec file.
119 AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV],
120 [
121 # Store path to cygwin link.exe to help excluding it when searching for
122 # VS linker. This must be done before changing the PATH when looking for VS.
123 AC_PATH_PROG(CYGWIN_LINK, link)
124 if test "x$CYGWIN_LINK" != x; then
125 AC_MSG_CHECKING([if the first found link.exe is actually the Cygwin link tool])
126 "$CYGWIN_LINK" --version > /dev/null
127 if test $? -eq 0 ; then
128 AC_MSG_RESULT([yes])
129 else
130 AC_MSG_RESULT([no])
131 # This might be the VS linker. Don't exclude it later on.
132 CYGWIN_LINK=""
133 fi
134 fi
136 # First-hand choice is to locate and run the vsvars bat file.
137 TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE
138 if test "x$VS_ENV_CMD" != x; then
139 # We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file.
140 BASIC_FIXUP_EXECUTABLE(VS_ENV_CMD)
142 # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat
143 AC_MSG_NOTICE([Trying to extract Visual Studio environment variables])
144 cd $OUTPUT_ROOT
145 # FIXME: The code betweeen ---- was inlined from a separate script and is not properly adapted
146 # to autoconf standards.
148 #----
150 # Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment)
151 # but calculate the difference in Cygwin environment before/after running it and then
152 # apply the diff.
154 if test "x$OPENJDK_BUILD_OS_ENV" = xwindows.cygwin; then
155 _vs10varsall=`cygpath -a -m -s "$VS_ENV_CMD"`
156 _dosvs10varsall=`cygpath -a -w -s $_vs10varsall`
157 _dosbash=`cygpath -a -w -s \`which bash\`.*`
158 else
159 _dosvs10varsall=`cmd //c echo $VS_ENV_CMD`
160 _dosbash=`cmd //c echo \`which bash\``
161 fi
163 # generate the set of exported vars before/after the vs10 setup
164 $ECHO "@echo off" > localdevenvtmp.bat
165 $ECHO "$_dosbash -c \"export -p\" > localdevenvtmp.export0" >> localdevenvtmp.bat
166 $ECHO "call $_dosvs10varsall $VS_ENV_ARGS" >> localdevenvtmp.bat
167 $ECHO "$_dosbash -c \"export -p\" > localdevenvtmp.export1" >> localdevenvtmp.bat
169 # Now execute the newly created bat file.
170 # The | cat is to stop SetEnv.Cmd to mess with system colors on msys
171 cmd /c localdevenvtmp.bat | cat
173 # apply the diff (less some non-vs10 vars named by "!")
174 $SORT localdevenvtmp.export0 | $GREP -v "!" > localdevenvtmp.export0.sort
175 $SORT localdevenvtmp.export1 | $GREP -v "!" > localdevenvtmp.export1.sort
176 $COMM -1 -3 localdevenvtmp.export0.sort localdevenvtmp.export1.sort > localdevenv.sh
178 # cleanup
179 $RM localdevenvtmp*
180 #----
181 cd $CURDIR
182 if test ! -s $OUTPUT_ROOT/localdevenv.sh; then
183 AC_MSG_RESULT([no])
184 AC_MSG_NOTICE([Could not succesfully extract the envionment variables needed for the VS setup.])
185 AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
186 AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
187 AC_MSG_ERROR([Cannot continue])
188 fi
190 # Now set all paths and other env variables. This will allow the rest of
191 # the configure script to find and run the compiler in the proper way.
192 AC_MSG_NOTICE([Setting extracted environment variables])
193 . $OUTPUT_ROOT/localdevenv.sh
194 else
195 # We did not find a vsvars bat file, let's hope we are run from a VS command prompt.
196 AC_MSG_NOTICE([Cannot locate a valid Visual Studio installation, checking current environment])
197 fi
199 # At this point, we should have corrent variables in the environment, or we can't continue.
200 AC_MSG_CHECKING([for Visual Studio variables])
202 if test "x$VCINSTALLDIR" != x || test "x$WindowsSDKDir" != x || test "x$WINDOWSSDKDIR" != x; then
203 if test "x$INCLUDE" = x || test "x$LIB" = x; then
204 AC_MSG_RESULT([present but broken])
205 AC_MSG_ERROR([Your VC command prompt seems broken, INCLUDE and/or LIB is missing.])
206 else
207 AC_MSG_RESULT([ok])
208 # Remove any trailing \ from INCLUDE and LIB to avoid trouble in spec.gmk.
209 VS_INCLUDE=`$ECHO "$INCLUDE" | $SED 's/\\\\$//'`
210 VS_LIB=`$ECHO "$LIB" | $SED 's/\\\\$//'`
211 # Remove any paths containing # (typically F#) as that messes up make
212 PATH=`$ECHO "$PATH" | $SED 's/[[^:#]]*#[^:]*://g'`
213 VS_PATH="$PATH"
214 AC_SUBST(VS_INCLUDE)
215 AC_SUBST(VS_LIB)
216 AC_SUBST(VS_PATH)
217 fi
218 else
219 AC_MSG_RESULT([not found])
221 if test "x$VS_ENV_CMD" = x; then
222 AC_MSG_NOTICE([Cannot locate a valid Visual Studio or Windows SDK installation on disk,])
223 AC_MSG_NOTICE([nor is this script run from a Visual Studio command prompt.])
224 else
225 AC_MSG_NOTICE([Running the extraction script failed.])
226 fi
227 AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
228 AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
229 AC_MSG_ERROR([Cannot continue])
230 fi
232 AC_MSG_CHECKING([for msvcr100.dll])
233 AC_ARG_WITH(msvcr-dll, [AS_HELP_STRING([--with-msvcr-dll],
234 [copy this msvcr100.dll into the built JDK (Windows only) @<:@probed@:>@])])
235 if test "x$with_msvcr_dll" != x; then
236 MSVCR_DLL="$with_msvcr_dll"
237 else
238 if test "x$VCINSTALLDIR" != x; then
239 if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
240 MSVCR_DLL=`find "$VCINSTALLDIR" -name msvcr100.dll | grep x64 | head --lines 1`
241 else
242 MSVCR_DLL=`find "$VCINSTALLDIR" -name msvcr100.dll | grep x86 | grep -v ia64 | grep -v x64 | head --lines 1`
243 if test "x$MSVCR_DLL" = x; then
244 MSVCR_DLL=`find "$VCINSTALLDIR" -name msvcr100.dll | head --lines 1`
245 fi
246 fi
247 if test "x$MSVCR_DLL" != x; then
248 AC_MSG_NOTICE([msvcr100.dll found in VCINSTALLDIR: $VCINSTALLDIR])
249 else
250 AC_MSG_NOTICE([Warning: msvcr100.dll not found in VCINSTALLDIR: $VCINSTALLDIR])
251 fi
252 fi
253 # Try some fallback alternatives
254 if test "x$MSVCR_DLL" = x; then
255 # If visual studio express is installed, there is usually one with the debugger
256 if test "x$VS100COMNTOOLS" != x; then
257 if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
258 MSVCR_DLL=`find "$VS100COMNTOOLS/.." -name msvcr100.dll | grep -i x64 | head --lines 1`
259 AC_MSG_NOTICE([msvcr100.dll found in $VS100COMNTOOLS..: $VS100COMNTOOLS..])
260 fi
261 fi
262 fi
263 if test "x$MSVCR_DLL" = x; then
264 if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
265 # Fallback for 32bit builds, look in the windows directory.
266 if test -f "$SYSTEMROOT/system32/msvcr100.dll"; then
267 AC_MSG_NOTICE([msvcr100.dll found in $SYSTEMROOT/system32])
268 MSVCR_DLL="$SYSTEMROOT/system32/msvcr100.dll"
269 fi
270 fi
271 fi
272 fi
273 if test "x$MSVCR_DLL" = x; then
274 AC_MSG_RESULT([no])
275 AC_MSG_ERROR([Could not find msvcr100.dll !])
276 fi
277 AC_MSG_RESULT([$MSVCR_DLL])
278 BASIC_FIXUP_PATH(MSVCR_DLL)
279 ])
282 # Setup the DXSDK paths
283 AC_DEFUN([TOOLCHAIN_SETUP_DXSDK],
284 [
285 AC_ARG_WITH(dxsdk, [AS_HELP_STRING([--with-dxsdk],
286 [the DirectX SDK (Windows only) @<:@probed@:>@])])
287 AC_ARG_WITH(dxsdk-lib, [AS_HELP_STRING([--with-dxsdk-lib],
288 [the DirectX SDK lib directory (Windows only) @<:@probed@:>@])])
289 AC_ARG_WITH(dxsdk-include, [AS_HELP_STRING([--with-dxsdk-include],
290 [the DirectX SDK include directory (Windows only) @<:@probed@:>@])])
292 AC_MSG_CHECKING([for DirectX SDK])
294 if test "x$with_dxsdk" != x; then
295 dxsdk_path="$with_dxsdk"
296 elif test "x$DXSDK_DIR" != x; then
297 dxsdk_path="$DXSDK_DIR"
298 elif test -d "C:/DXSDK"; then
299 dxsdk_path="C:/DXSDK"
300 else
301 AC_MSG_ERROR([Could not find the DirectX SDK])
302 fi
303 AC_MSG_RESULT([$dxsdk_path])
304 BASIC_FIXUP_PATH(dxsdk_path)
306 AC_MSG_CHECKING([for DirectX SDK lib dir])
307 if test "x$with_dxsdk_lib" != x; then
308 DXSDK_LIB_PATH="$with_dxsdk_lib"
309 elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
310 DXSDK_LIB_PATH="$dxsdk_path/Lib/x64"
311 else
312 DXSDK_LIB_PATH="$dxsdk_path/Lib"
313 fi
314 # dsound.lib is linked to in jsoundds
315 if test ! -f "$DXSDK_LIB_PATH/dsound.lib"; then
316 AC_MSG_ERROR([Invalid DirectX SDK lib dir])
317 fi
318 AC_MSG_RESULT([$DXSDK_LIB_PATH])
319 BASIC_FIXUP_PATH(DXSDK_LIB_PATH)
321 AC_MSG_CHECKING([for DirectX SDK include dir])
322 if test "x$with_dxsdk_include" != x; then
323 DXSDK_INCLUDE_PATH="$with_dxsdk_include"
324 else
325 DXSDK_INCLUDE_PATH="$dxsdk_path/Include"
326 fi
327 # dsound.h is included in jsoundds
328 if test ! -f "$DXSDK_INCLUDE_PATH/dsound.h"; then
329 AC_MSG_ERROR([Invalid DirectX SDK lib dir])
330 fi
331 AC_MSG_RESULT([$DXSDK_INCLUDE_PATH])
332 BASIC_FIXUP_PATH(DXSDK_INCLUDE_PATH)
334 AC_SUBST(DXSDK_LIB_PATH)
335 AC_SUBST(DXSDK_INCLUDE_PATH)
336 LDFLAGS_JDK="$LDFLAGS_JDK -libpath:$DXSDK_LIB_PATH"
337 ])