Wed, 14 Nov 2012 10:16:45 -0800
8001941: build-infra: --disable-precompiled-headers does not seem to work
Summary: With this fix the flag will do what it advertises
Reviewed-by: ohair, tbell
Contributed-by: erik.joelsson@oracle.com
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 if test -f "$WIN_SDK_BASE/SetEnv.Cmd"; then
52 AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
53 VS_ENV_CMD="$WIN_SDK_BASE/SetEnv.Cmd"
54 if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
55 VS_ENV_ARGS="/x86"
56 else
57 VS_ENV_ARGS="/x64"
58 fi
59 else
60 AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
61 AC_MSG_NOTICE([Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring])
62 fi
63 fi
64 fi
65 ])
67 AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE],
68 [
69 if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
70 VCVARSFILE="vc/bin/vcvars32.bat"
71 else
72 VCVARSFILE="vc/bin/amd64/vcvars64.bat"
73 fi
75 VS_ENV_CMD=""
76 VS_ENV_ARGS=""
77 if test "x$with_toolsdir" != x; then
78 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$with_toolsdir/../..], [--with-tools-dir])
79 fi
81 if test "x$with_toolsdir" != x && test "x$VS_ENV_CMD" = x; then
82 # Having specified an argument which is incorrect will produce an instant failure;
83 # we should not go on looking
84 AC_MSG_NOTICE([The path given by --with-tools-dir does not contain a valid Visual Studio installation])
85 AC_MSG_NOTICE([Please point to the VC/bin directory within the Visual Studio installation])
86 AC_MSG_ERROR([Cannot locate a valid Visual Studio installation])
87 fi
89 if test "x$ProgramW6432" != x; then
90 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$ProgramW6432/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
91 fi
92 if test "x$PROGRAMW6432" != x; then
93 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$PROGRAMW6432/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
94 fi
95 if test "x$PROGRAMFILES" != x; then
96 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$PROGRAMFILES/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
97 fi
98 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([C:/Program Files/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
99 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
101 if test "x$VS100COMNTOOLS" != x; then
102 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$VS100COMNTOOLS/../..], [VS100COMNTOOLS variable])
103 fi
104 if test "x$PROGRAMFILES" != x; then
105 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$PROGRAMFILES/Microsoft Visual Studio 10.0], [well-known name])
106 fi
107 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([C:/Program Files/Microsoft Visual Studio 10.0], [well-known name])
108 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([C:/Program Files (x86)/Microsoft Visual Studio 10.0], [well-known name])
109 ])
111 # Check if the VS env variables were setup prior to running configure.
112 # If not, then find vcvarsall.bat and run it automatically, and integrate
113 # the set env variables into the spec file.
114 AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV],
115 [
116 # Store path to cygwin link.exe to help excluding it when searching for
117 # VS linker. This must be done before changing the PATH when looking for VS.
118 AC_PATH_PROG(CYGWIN_LINK, link)
119 if test "x$CYGWIN_LINK" != x; then
120 AC_MSG_CHECKING([if the first found link.exe is actually the Cygwin link tool])
121 "$CYGWIN_LINK" --version > /dev/null
122 if test $? -eq 0 ; then
123 AC_MSG_RESULT([yes])
124 else
125 AC_MSG_RESULT([no])
126 # This might be the VS linker. Don't exclude it later on.
127 CYGWIN_LINK=""
128 fi
129 fi
131 # First-hand choice is to locate and run the vsvars bat file.
132 TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE
133 if test "x$VS_ENV_CMD" != x; then
134 # We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file.
135 BASIC_FIXUP_EXECUTABLE(VS_ENV_CMD)
137 # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat
138 AC_MSG_NOTICE([Trying to extract Visual Studio environment variables])
139 cd $OUTPUT_ROOT
140 # FIXME: The code betweeen ---- was inlined from a separate script and is not properly adapted
141 # to autoconf standards.
143 #----
145 # Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment)
146 # but calculate the difference in Cygwin environment before/after running it and then
147 # apply the diff.
149 if test "x$OPENJDK_BUILD_OS_ENV" = xwindows.cygwin; then
150 _vs10varsall=`cygpath -a -m -s "$VS_ENV_CMD"`
151 _dosvs10varsall=`cygpath -a -w -s $_vs10varsall`
152 _dosbash=`cygpath -a -w -s \`which bash\`.*`
153 else
154 _dosvs10varsall=`cmd //c echo $VS_ENV_CMD`
155 _dosbash=`cmd //c echo \`which bash\``
156 fi
158 # generate the set of exported vars before/after the vs10 setup
159 $ECHO "@echo off" > localdevenvtmp.bat
160 $ECHO "$_dosbash -c \"export -p\" > localdevenvtmp.export0" >> localdevenvtmp.bat
161 $ECHO "call $_dosvs10varsall $VS_ENV_ARGS" >> localdevenvtmp.bat
162 $ECHO "$_dosbash -c \"export -p\" > localdevenvtmp.export1" >> localdevenvtmp.bat
164 # Now execute the newly created bat file.
165 # The | cat is to stop SetEnv.Cmd to mess with system colors on msys
166 cmd /c localdevenvtmp.bat | cat
168 # apply the diff (less some non-vs10 vars named by "!")
169 $SORT localdevenvtmp.export0 | $GREP -v "!" > localdevenvtmp.export0.sort
170 $SORT localdevenvtmp.export1 | $GREP -v "!" > localdevenvtmp.export1.sort
171 $COMM -1 -3 localdevenvtmp.export0.sort localdevenvtmp.export1.sort > localdevenv.sh
173 # cleanup
174 $RM localdevenvtmp*
175 #----
176 cd $CURDIR
177 if test ! -s $OUTPUT_ROOT/localdevenv.sh; then
178 AC_MSG_RESULT([no])
179 AC_MSG_NOTICE([Could not succesfully extract the envionment variables needed for the VS setup.])
180 AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
181 AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
182 AC_MSG_ERROR([Cannot continue])
183 fi
185 # Now set all paths and other env variables. This will allow the rest of
186 # the configure script to find and run the compiler in the proper way.
187 AC_MSG_NOTICE([Setting extracted environment variables])
188 . $OUTPUT_ROOT/localdevenv.sh
189 else
190 # We did not find a vsvars bat file, let's hope we are run from a VS command prompt.
191 AC_MSG_NOTICE([Cannot locate a valid Visual Studio installation, checking current environment])
192 fi
194 # At this point, we should have corrent variables in the environment, or we can't continue.
195 AC_MSG_CHECKING([for Visual Studio variables])
197 if test "x$VCINSTALLDIR" != x || test "x$WindowsSDKDir" != x || test "x$WINDOWSSDKDIR" != x; then
198 if test "x$INCLUDE" = x || test "x$LIB" = x; then
199 AC_MSG_RESULT([present but broken])
200 AC_MSG_ERROR([Your VC command prompt seems broken, INCLUDE and/or LIB is missing.])
201 else
202 AC_MSG_RESULT([ok])
203 VS_INCLUDE="$INCLUDE"
204 VS_LIB="$LIB"
205 VS_PATH="$PATH"
206 AC_SUBST(VS_INCLUDE)
207 AC_SUBST(VS_LIB)
208 AC_SUBST(VS_PATH)
209 fi
210 else
211 AC_MSG_RESULT([not found])
213 if test "x$VS_ENV_CMD" = x; then
214 AC_MSG_NOTICE([Cannot locate a valid Visual Studio or Windows SDK installation on disk,])
215 AC_MSG_NOTICE([nor is this script run from a Visual Studio command prompt.])
216 else
217 AC_MSG_NOTICE([Running the extraction script failed.])
218 fi
219 AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
220 AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
221 AC_MSG_ERROR([Cannot continue])
222 fi
224 AC_MSG_CHECKING([for msvcr100.dll])
225 AC_ARG_WITH(msvcr-dll, [AS_HELP_STRING([--with-msvcr-dll],
226 [copy this msvcr100.dll into the built JDK (Windows only) @<:@probed@:>@])])
227 if test "x$with_msvcr_dll" != x; then
228 MSVCR_DLL="$with_msvcr_dll"
229 else
230 if test "x$VCINSTALLDIR" != x; then
231 if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
232 MSVCR_DLL=`find "$VCINSTALLDIR" -name msvcr100.dll | grep x64 | head --lines 1`
233 else
234 MSVCR_DLL=`find "$VCINSTALLDIR" -name msvcr100.dll | grep x86 | grep -v ia64 | grep -v x64 | head --lines 1`
235 if test "x$MSVCR_DLL" = x; then
236 MSVCR_DLL=`find "$VCINSTALLDIR" -name msvcr100.dll | head --lines 1`
237 fi
238 fi
239 if test "x$MSVCR_DLL" != x; then
240 AC_MSG_NOTICE([msvcr100.dll found in VCINSTALLDIR: $VCINSTALLDIR])
241 else
242 AC_MSG_NOTICE([Warning: msvcr100.dll not found in VCINSTALLDIR: $VCINSTALLDIR])
243 fi
244 fi
245 if test "x$MSVCR_DLL" = x; then
246 if test -f "$SYSTEMROOT/system32/msvcr100.dll"; then
247 AC_MSG_NOTICE([msvcr100.dll found in $SYSTEMROOT/system32])
248 MSVCR_DLL="$SYSTEMROOT/system32/msvcr100.dll"
249 fi
250 fi
251 fi
252 if test "x$MSVCR_DLL" = x; then
253 AC_MSG_RESULT([no])
254 AC_MSG_ERROR([Could not find msvcr100.dll !])
255 fi
256 AC_MSG_RESULT([$MSVCR_DLL])
257 BASIC_FIXUP_PATH(MSVCR_DLL)
258 ])