basics_windows.m4 revision 2107:89769a2f1511
1258945Sroberto#
2280849Scy# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
3258945Sroberto# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4258945Sroberto#
5258945Sroberto# This code is free software; you can redistribute it and/or modify it
6258945Sroberto# under the terms of the GNU General Public License version 2 only, as
7258945Sroberto# published by the Free Software Foundation.  Oracle designates this
8258945Sroberto# particular file as subject to the "Classpath" exception as provided
9258945Sroberto# by Oracle in the LICENSE file that accompanied this code.
10258945Sroberto#
11258945Sroberto# This code is distributed in the hope that it will be useful, but WITHOUT
12258945Sroberto# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13258945Sroberto# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14258945Sroberto# version 2 for more details (a copy is included in the LICENSE file that
15258945Sroberto# accompanied this code).
16258945Sroberto#
17258945Sroberto# You should have received a copy of the GNU General Public License version
18280849Scy# 2 along with this work; if not, write to the Free Software Foundation,
19258945Sroberto# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20258945Sroberto#
21258945Sroberto# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22258945Sroberto# or visit www.oracle.com if you need additional information or have any
23258945Sroberto# questions.
24258945Sroberto#
25258945Sroberto
26258945SrobertoAC_DEFUN([BASIC_WINDOWS_REWRITE_AS_UNIX_PATH],
27258945Sroberto[
28258945Sroberto  windows_path="[$]$1"
29258945Sroberto  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
30258945Sroberto    unix_path=`$CYGPATH -u "$windows_path"`
31258945Sroberto    $1="$unix_path"
32258945Sroberto  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
33258945Sroberto    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
34280849Scy    $1="$unix_path"
35258945Sroberto  fi
36258945Sroberto])
37258945Sroberto
38258945SrobertoAC_DEFUN([BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH],
39258945Sroberto[
40258945Sroberto  unix_path="[$]$1"
41258945Sroberto  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
42258945Sroberto    windows_path=`$CYGPATH -m "$unix_path"`
43258945Sroberto    $1="$windows_path"
44258945Sroberto  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
45258945Sroberto    windows_path=`cmd //c echo $unix_path`
46258945Sroberto    $1="$windows_path"
47258945Sroberto  fi
48258945Sroberto])
49258945Sroberto
50258945Sroberto# Helper function which possibly converts a path using DOS-style short mode.
51258945Sroberto# If so, the updated path is stored in $new_path.
52258945Sroberto# $1: The path to check
53258945SrobertoAC_DEFUN([BASIC_MAKE_WINDOWS_SPACE_SAFE_CYGWIN],
54258945Sroberto[
55258945Sroberto  input_path="$1"
56258945Sroberto  # Check if we need to convert this using DOS-style short mode. If the path
57258945Sroberto  # contains just simple characters, use it. Otherwise (spaces, weird characters),
58258945Sroberto  # take no chances and rewrite it.
59258945Sroberto  # Note: m4 eats our [], so we need to use @<:@ and @:>@ instead.
60258945Sroberto  has_forbidden_chars=`$ECHO "$input_path" | $GREP @<:@^-._/a-zA-Z0-9@:>@`
61258945Sroberto  if test "x$has_forbidden_chars" != x; then
62258945Sroberto    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
63258945Sroberto    shortmode_path=`$CYGPATH -s -m -a "$input_path"`
64258945Sroberto    path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
65258945Sroberto    if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
66258945Sroberto      # Going to short mode and back again did indeed matter. Since short mode is
67258945Sroberto      # case insensitive, let's make it lowercase to improve readability.
68258945Sroberto      shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
69258945Sroberto      # Now convert it back to Unix-style (cygpath)
70258945Sroberto      input_path=`$CYGPATH -u "$shortmode_path"`
71258945Sroberto      new_path="$input_path"
72258945Sroberto    fi
73280849Scy  fi
74280849Scy
75280849Scy  test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/`
76280849Scy  if test "x$test_cygdrive_prefix" = x; then
77258945Sroberto    # As a simple fix, exclude /usr/bin since it's not a real path.
78258945Sroberto    if test "x`$ECHO $1 | $GREP ^/usr/bin/`" = x; then
79258945Sroberto      # The path is in a Cygwin special directory (e.g. /home). We need this converted to
80258945Sroberto      # a path prefixed by /cygdrive for fixpath to work.
81258945Sroberto      new_path="$CYGWIN_ROOT_PATH$input_path"
82258945Sroberto    fi
83258945Sroberto  fi
84258945Sroberto])
85258945Sroberto
86258945Sroberto# Helper function which possibly converts a path using DOS-style short mode.
87258945Sroberto# If so, the updated path is stored in $new_path.
88258945Sroberto# $1: The path to check
89258945SrobertoAC_DEFUN([BASIC_MAKE_WINDOWS_SPACE_SAFE_MSYS],
90258945Sroberto[
91258945Sroberto  input_path="$1"
92258945Sroberto  # Check if we need to convert this using DOS-style short mode. If the path
93258945Sroberto  # contains just simple characters, use it. Otherwise (spaces, weird characters),
94258945Sroberto  # take no chances and rewrite it.
95258945Sroberto  # Note: m4 eats our [], so we need to use @<:@ and @:>@ instead.
96258945Sroberto  has_forbidden_chars=`$ECHO "$input_path" | $GREP @<:@^-_/:a-zA-Z0-9@:>@`
97258945Sroberto  if test "x$has_forbidden_chars" != x; then
98258945Sroberto    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
99258945Sroberto    new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
100258945Sroberto  fi
101258945Sroberto])
102258945Sroberto
103258945Sroberto# FIXME: The BASIC_FIXUP_*_CYGWIN/MSYS is most likely too convoluted
104258945Sroberto# and could probably be heavily simplified. However, all changes in this
105258945Sroberto# area tend to need lot of testing in different scenarios, and in lack of
106258945Sroberto# proper unit testing, cleaning this up has not been deemed worth the effort
107258945Sroberto# at the moment.
108258945Sroberto
109258945SrobertoAC_DEFUN([BASIC_FIXUP_PATH_CYGWIN],
110258945Sroberto[
111258945Sroberto  # Input might be given as Windows format, start by converting to
112258945Sroberto  # unix format.
113258945Sroberto  path="[$]$1"
114258945Sroberto  new_path=`$CYGPATH -u "$path"`
115258945Sroberto
116258945Sroberto  # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
117258945Sroberto  # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
118258945Sroberto  # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
119258945Sroberto  # "foo.exe" is OK but "foo" is an error.
120258945Sroberto  #
121258945Sroberto  # This test is therefore slightly more accurate than "test -f" to check for file precense.
122258945Sroberto  # It is also a way to make sure we got the proper file name for the real test later on.
123258945Sroberto  test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null`
124258945Sroberto  if test "x$test_shortpath" = x; then
125258945Sroberto    AC_MSG_NOTICE([The path of $1, which resolves as "$path", is invalid.])
126258945Sroberto    AC_MSG_ERROR([Cannot locate the the path of $1])
127258945Sroberto  fi
128258945Sroberto
129258945Sroberto  # Call helper function which possibly converts this using DOS-style short mode.
130258945Sroberto  # If so, the updated path is stored in $new_path.
131258945Sroberto  BASIC_MAKE_WINDOWS_SPACE_SAFE_CYGWIN([$new_path])
132258945Sroberto
133258945Sroberto  if test "x$path" != "x$new_path"; then
134258945Sroberto    $1="$new_path"
135258945Sroberto    AC_MSG_NOTICE([Rewriting $1 to "$new_path"])
136258945Sroberto  fi
137258945Sroberto])
138258945Sroberto
139258945SrobertoAC_DEFUN([BASIC_FIXUP_PATH_MSYS],
140258945Sroberto[
141258945Sroberto  path="[$]$1"
142258945Sroberto  has_colon=`$ECHO $path | $GREP ^.:`
143258945Sroberto  new_path="$path"
144258945Sroberto  if test "x$has_colon" = x; then
145258945Sroberto    # Not in mixed or Windows style, start by that.
146258945Sroberto    new_path=`cmd //c echo $path`
147258945Sroberto  fi
148258945Sroberto
149258945Sroberto  BASIC_MAKE_WINDOWS_SPACE_SAFE_MSYS([$new_path])
150258945Sroberto  BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(new_path)
151258945Sroberto  if test "x$path" != "x$new_path"; then
152258945Sroberto    $1="$new_path"
153258945Sroberto    AC_MSG_NOTICE([Rewriting $1 to "$new_path"])
154258945Sroberto  fi
155258945Sroberto
156258945Sroberto  # Save the first 10 bytes of this path to the storage, so fixpath can work.
157258945Sroberto  all_fixpath_prefixes=("${all_fixpath_prefixes@<:@@@:>@}" "${new_path:0:10}")
158258945Sroberto])
159258945Sroberto
160258945SrobertoAC_DEFUN([BASIC_FIXUP_EXECUTABLE_CYGWIN],
161258945Sroberto[
162293423Sdelphij  # First separate the path from the arguments. This will split at the first
163258945Sroberto  # space.
164258945Sroberto  complete="[$]$1"
165258945Sroberto  path="${complete%% *}"
166258945Sroberto  tmp="$complete EOL"
167258945Sroberto  arguments="${tmp#* }"
168258945Sroberto
169258945Sroberto  # Input might be given as Windows format, start by converting to
170258945Sroberto  # unix format.
171258945Sroberto  new_path=`$CYGPATH -u "$path"`
172258945Sroberto
173258945Sroberto  # Now try to locate executable using which
174258945Sroberto  new_path=`$WHICH "$new_path" 2> /dev/null`
175258945Sroberto  # bat and cmd files are not always considered executable in cygwin causing which
176258945Sroberto  # to not find them
177258945Sroberto  if test "x$new_path" = x \
178258945Sroberto      && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \
179258945Sroberto      && test "x`$LS \"$path\" 2>/dev/null`" != x; then
180258945Sroberto    new_path=`$CYGPATH -u "$path"`
181258945Sroberto  fi
182258945Sroberto  if test "x$new_path" = x; then
183258945Sroberto    # Oops. Which didn't find the executable.
184258945Sroberto    # The splitting of arguments from the executable at a space might have been incorrect,
185258945Sroberto    # since paths with space are more likely in Windows. Give it another try with the whole
186258945Sroberto    # argument.
187258945Sroberto    path="$complete"
188258945Sroberto    arguments="EOL"
189258945Sroberto    new_path=`$CYGPATH -u "$path"`
190280849Scy    new_path=`$WHICH "$new_path" 2> /dev/null`
191280849Scy    # bat and cmd files are not always considered executable in cygwin causing which
192280849Scy    # to not find them
193258945Sroberto    if test "x$new_path" = x \
194258945Sroberto        && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \
195258945Sroberto        && test "x`$LS \"$path\" 2>/dev/null`" != x; then
196258945Sroberto      new_path=`$CYGPATH -u "$path"`
197258945Sroberto    fi
198258945Sroberto    if test "x$new_path" = x; then
199258945Sroberto      # It's still not found. Now this is an unrecoverable error.
200258945Sroberto      AC_MSG_NOTICE([The path of $1, which resolves as "$complete", is not found.])
201258945Sroberto      has_space=`$ECHO "$complete" | $GREP " "`
202258945Sroberto      if test "x$has_space" != x; then
203258945Sroberto        AC_MSG_NOTICE([You might be mixing spaces in the path and extra arguments, which is not allowed.])
204258945Sroberto      fi
205280849Scy      AC_MSG_ERROR([Cannot locate the the path of $1])
206258945Sroberto    fi
207258945Sroberto  fi
208280849Scy
209258945Sroberto  # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
210258945Sroberto  # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
211258945Sroberto  # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
212258945Sroberto  # "foo.exe" is OK but "foo" is an error.
213258945Sroberto  #
214258945Sroberto  # This test is therefore slightly more accurate than "test -f" to check for file presence.
215258945Sroberto  # It is also a way to make sure we got the proper file name for the real test later on.
216258945Sroberto  test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null`
217258945Sroberto  if test "x$test_shortpath" = x; then
218280849Scy    # Short path failed, file does not exist as specified.
219258945Sroberto    # Try adding .exe or .cmd
220258945Sroberto    if test -f "${new_path}.exe"; then
221258945Sroberto      input_to_shortpath="${new_path}.exe"
222258945Sroberto    elif test -f "${new_path}.cmd"; then
223258945Sroberto      input_to_shortpath="${new_path}.cmd"
224258945Sroberto    else
225258945Sroberto      AC_MSG_NOTICE([The path of $1, which resolves as "$new_path", is invalid.])
226258945Sroberto      AC_MSG_NOTICE([Neither "$new_path" nor "$new_path.exe/cmd" can be found])
227258945Sroberto      AC_MSG_ERROR([Cannot locate the the path of $1])
228258945Sroberto    fi
229258945Sroberto  else
230258945Sroberto    input_to_shortpath="$new_path"
231258945Sroberto  fi
232258945Sroberto
233258945Sroberto  # Call helper function which possibly converts this using DOS-style short mode.
234258945Sroberto  # If so, the updated path is stored in $new_path.
235258945Sroberto  new_path="$input_to_shortpath"
236258945Sroberto  BASIC_MAKE_WINDOWS_SPACE_SAFE_CYGWIN([$input_to_shortpath])
237258945Sroberto  # remove trailing .exe if any
238258945Sroberto  new_path="${new_path/%.exe/}"
239258945Sroberto])
240258945Sroberto
241258945SrobertoAC_DEFUN([BASIC_FIXUP_EXECUTABLE_MSYS],
242258945Sroberto[
243258945Sroberto  # First separate the path from the arguments. This will split at the first
244258945Sroberto  # space.
245258945Sroberto  complete="[$]$1"
246258945Sroberto  path="${complete%% *}"
247258945Sroberto  tmp="$complete EOL"
248258945Sroberto  arguments="${tmp#* }"
249258945Sroberto
250258945Sroberto  # Input might be given as Windows format, start by converting to
251280849Scy  # unix format.
252258945Sroberto  new_path="$path"
253258945Sroberto  BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(new_path)
254258945Sroberto
255258945Sroberto  # Now try to locate executable using which
256258945Sroberto  new_path=`$WHICH "$new_path" 2> /dev/null`
257258945Sroberto
258258945Sroberto  if test "x$new_path" = x; then
259258945Sroberto    # Oops. Which didn't find the executable.
260258945Sroberto    # The splitting of arguments from the executable at a space might have been incorrect,
261258945Sroberto    # since paths with space are more likely in Windows. Give it another try with the whole
262258945Sroberto    # argument.
263258945Sroberto    path="$complete"
264258945Sroberto    arguments="EOL"
265258945Sroberto    new_path="$path"
266258945Sroberto    BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(new_path)
267258945Sroberto
268258945Sroberto    new_path=`$WHICH "$new_path" 2> /dev/null`
269258945Sroberto    # bat and cmd files are not always considered executable in MSYS causing which
270258945Sroberto    # to not find them
271258945Sroberto    if test "x$new_path" = x \
272258945Sroberto        && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \
273258945Sroberto        && test "x`$LS \"$path\" 2>/dev/null`" != x; then
274258945Sroberto      new_path="$path"
275258945Sroberto      BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(new_path)
276258945Sroberto    fi
277258945Sroberto
278258945Sroberto    if test "x$new_path" = x; then
279258945Sroberto      # It's still not found. Now this is an unrecoverable error.
280258945Sroberto      AC_MSG_NOTICE([The path of $1, which resolves as "$complete", is not found.])
281258945Sroberto      has_space=`$ECHO "$complete" | $GREP " "`
282258945Sroberto      if test "x$has_space" != x; then
283258945Sroberto        AC_MSG_NOTICE([You might be mixing spaces in the path and extra arguments, which is not allowed.])
284258945Sroberto      fi
285258945Sroberto      AC_MSG_ERROR([Cannot locate the the path of $1])
286258945Sroberto    fi
287258945Sroberto  fi
288258945Sroberto
289258945Sroberto  # Now new_path has a complete unix path to the binary
290258945Sroberto  if test "x`$ECHO $new_path | $GREP ^/bin/`" != x; then
291258945Sroberto    # Keep paths in /bin as-is, but remove trailing .exe if any
292258945Sroberto    new_path="${new_path/%.exe/}"
293258945Sroberto    # Do not save /bin paths to all_fixpath_prefixes!
294258945Sroberto  else
295258945Sroberto    # Not in mixed or Windows style, start by that.
296258945Sroberto    new_path=`cmd //c echo $new_path`
297258945Sroberto    BASIC_MAKE_WINDOWS_SPACE_SAFE_MSYS([$new_path])
298258945Sroberto    # Output is in $new_path
299258945Sroberto    BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(new_path)
300258945Sroberto    # remove trailing .exe if any
301258945Sroberto    new_path="${new_path/%.exe/}"
302258945Sroberto
303258945Sroberto    # Save the first 10 bytes of this path to the storage, so fixpath can work.
304258945Sroberto    all_fixpath_prefixes=("${all_fixpath_prefixes@<:@@@:>@}" "${new_path:0:10}")
305280849Scy  fi
306280849Scy])
307258945Sroberto
308258945Sroberto# Setup basic configuration paths, and platform-specific stuff related to PATHs.
309258945SrobertoAC_DEFUN([BASIC_CHECK_PATHS_WINDOWS],
310280849Scy[
311258945Sroberto  SRC_ROOT_LENGTH=`$THEPWDCMD -L|$WC -m`
312258945Sroberto  if test $SRC_ROOT_LENGTH -gt 100; then
313258945Sroberto    AC_MSG_ERROR([Your base path is too long. It is $SRC_ROOT_LENGTH characters long, but only 100 is supported])
314258945Sroberto  fi
315258945Sroberto
316280849Scy  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
317258945Sroberto    AC_MSG_CHECKING([cygwin release])
318258945Sroberto    CYGWIN_VERSION=`$UNAME -r`
319258945Sroberto    AC_MSG_RESULT([$CYGWIN_VERSION])
320258945Sroberto    WINDOWS_ENV_VENDOR='cygwin'
321258945Sroberto    WINDOWS_ENV_VERSION="$CYGWIN_VERSION"
322258945Sroberto
323258945Sroberto    CYGWIN_VERSION_OLD=`$ECHO $CYGWIN_VERSION | $GREP -e '^1\.[0-6]'`
324258945Sroberto    if test "x$CYGWIN_VERSION_OLD" != x; then
325258945Sroberto      AC_MSG_NOTICE([Your cygwin is too old. You are running $CYGWIN_VERSION, but at least cygwin 1.7 is required. Please upgrade.])
326258945Sroberto      AC_MSG_ERROR([Cannot continue])
327258945Sroberto    fi
328258945Sroberto    if test "x$CYGPATH" = x; then
329258945Sroberto      AC_MSG_ERROR([Something is wrong with your cygwin installation since I cannot find cygpath.exe in your path])
330258945Sroberto    fi
331258945Sroberto    AC_MSG_CHECKING([cygwin root directory as unix-style path])
332258945Sroberto    # The cmd output ends with Windows line endings (CR/LF), the grep command will strip that away
333258945Sroberto    cygwin_winpath_root=`cd / ; cmd /c cd | $GREP ".*"`
334258945Sroberto    # Force cygpath to report the proper root by including a trailing space, and then stripping it off again.
335258945Sroberto    CYGWIN_ROOT_PATH=`$CYGPATH -u "$cygwin_winpath_root " | $CUT -f 1 -d " "`
336258945Sroberto    AC_MSG_RESULT([$CYGWIN_ROOT_PATH])
337258945Sroberto    WINDOWS_ENV_ROOT_PATH="$CYGWIN_ROOT_PATH"
338258945Sroberto    test_cygdrive_prefix=`$ECHO $CYGWIN_ROOT_PATH | $GREP ^/cygdrive/`
339258945Sroberto    if test "x$test_cygdrive_prefix" = x; then
340258945Sroberto      AC_MSG_ERROR([Your cygdrive prefix is not /cygdrive. This is currently not supported. Change with mount -c.])
341258945Sroberto    fi
342258945Sroberto  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
343258945Sroberto    AC_MSG_CHECKING([msys release])
344258945Sroberto    MSYS_VERSION=`$UNAME -r`
345258945Sroberto    AC_MSG_RESULT([$MSYS_VERSION])
346258945Sroberto
347258945Sroberto    WINDOWS_ENV_VENDOR='msys'
348258945Sroberto    WINDOWS_ENV_VERSION="$MSYS_VERSION"
349258945Sroberto
350258945Sroberto    AC_MSG_CHECKING([msys root directory as unix-style path])
351258945Sroberto    # The cmd output ends with Windows line endings (CR/LF), the grep command will strip that away
352258945Sroberto    MSYS_ROOT_PATH=`cd / ; cmd /c cd | $GREP ".*"`
353258945Sroberto    BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(MSYS_ROOT_PATH)
354258945Sroberto    AC_MSG_RESULT([$MSYS_ROOT_PATH])
355258945Sroberto    WINDOWS_ENV_ROOT_PATH="$MSYS_ROOT_PATH"
356258945Sroberto  else
357258945Sroberto    AC_MSG_ERROR([Unknown Windows environment. Neither cygwin nor msys was detected.])
358258945Sroberto  fi
359258945Sroberto
360258945Sroberto  # Test if windows or unix (cygwin/msys) find is first in path.
361258945Sroberto  AC_MSG_CHECKING([what kind of 'find' is first on the PATH])
362258945Sroberto  FIND_BINARY_OUTPUT=`find --version 2>&1`
363258945Sroberto  if test "x`echo $FIND_BINARY_OUTPUT | $GREP GNU`" != x; then
364258945Sroberto    AC_MSG_RESULT([unix style])
365258945Sroberto  elif test "x`echo $FIND_BINARY_OUTPUT | $GREP FIND`" != x; then
366258945Sroberto    AC_MSG_RESULT([Windows])
367258945Sroberto    AC_MSG_NOTICE([Your path contains Windows tools (C:\Windows\system32) before your unix (cygwin or msys) tools.])
368258945Sroberto    AC_MSG_NOTICE([This will not work. Please correct and make sure /usr/bin (or similar) is first in path.])
369258945Sroberto    AC_MSG_ERROR([Cannot continue])
370258945Sroberto  else
371258945Sroberto    AC_MSG_RESULT([unknown])
372258945Sroberto    AC_MSG_WARN([It seems that your find utility is non-standard.])
373258945Sroberto  fi
374258945Sroberto])
375258945Sroberto
376258945SrobertoAC_DEFUN_ONCE([BASIC_COMPILE_FIXPATH],
377258945Sroberto[
378258945Sroberto  # When using cygwin or msys, we need a wrapper binary that renames
379258945Sroberto  # /cygdrive/c/ arguments into c:/ arguments and peeks into
380258945Sroberto  # @files and rewrites these too! This wrapper binary is
381258945Sroberto  # called fixpath.
382258945Sroberto  FIXPATH=
383258945Sroberto  if test "x$OPENJDK_BUILD_OS" = xwindows; then
384258945Sroberto    AC_MSG_CHECKING([if fixpath can be created])
385258945Sroberto    FIXPATH_SRC="$SRC_ROOT/common/src/fixpath.c"
386258945Sroberto    FIXPATH_BIN="$CONFIGURESUPPORT_OUTPUTDIR/bin/fixpath.exe"
387258945Sroberto    FIXPATH_DIR="$CONFIGURESUPPORT_OUTPUTDIR/fixpath"
388258945Sroberto    if test "x$OPENJDK_BUILD_OS_ENV" = xwindows.cygwin; then
389258945Sroberto      # Important to keep the .exe suffix on Cygwin for Hotspot makefiles
390258945Sroberto      FIXPATH="$FIXPATH_BIN -c"
391258945Sroberto    elif test "x$OPENJDK_BUILD_OS_ENV" = xwindows.msys; then
392258945Sroberto      # Take all collected prefixes and turn them into a -m/c/foo@/c/bar@... command line
393258945Sroberto      # @ was chosen as separator to minimize risk of other tools messing around with it
394258945Sroberto      all_unique_prefixes=`echo "${all_fixpath_prefixes@<:@@@:>@}" \
395258945Sroberto          | tr ' ' '\n' | $GREP '^/./' | $SORT | $UNIQ`
396258945Sroberto      fixpath_argument_list=`echo $all_unique_prefixes  | tr ' ' '@'`
397258945Sroberto      FIXPATH="$FIXPATH_BIN -m$fixpath_argument_list"
398258945Sroberto    fi
399258945Sroberto    FIXPATH_SRC_W="$FIXPATH_SRC"
400258945Sroberto    FIXPATH_BIN_W="$FIXPATH_BIN"
401258945Sroberto    BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([FIXPATH_SRC_W])
402258945Sroberto    BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([FIXPATH_BIN_W])
403258945Sroberto    $RM -rf $FIXPATH_BIN $FIXPATH_DIR
404258945Sroberto    $MKDIR -p $FIXPATH_DIR $CONFIGURESUPPORT_OUTPUTDIR/bin
405258945Sroberto    cd $FIXPATH_DIR
406258945Sroberto    $CC $FIXPATH_SRC_W -Fe$FIXPATH_BIN_W > $FIXPATH_DIR/fixpath1.log 2>&1
407258945Sroberto    cd $CURDIR
408258945Sroberto
409258945Sroberto    if test ! -x $FIXPATH_BIN; then
410258945Sroberto      AC_MSG_RESULT([no])
411258945Sroberto      cat $FIXPATH_DIR/fixpath1.log
412258945Sroberto      AC_MSG_ERROR([Could not create $FIXPATH_BIN])
413258945Sroberto    fi
414258945Sroberto    AC_MSG_RESULT([yes])
415258945Sroberto    AC_MSG_CHECKING([if fixpath.exe works])
416258945Sroberto    cd $FIXPATH_DIR
417258945Sroberto    $FIXPATH $CC $FIXPATH_SRC -Fe$FIXPATH_DIR/fixpath2.exe \
418258945Sroberto        > $FIXPATH_DIR/fixpath2.log 2>&1
419258945Sroberto    cd $CURDIR
420258945Sroberto    if test ! -x $FIXPATH_DIR/fixpath2.exe; then
421258945Sroberto      AC_MSG_RESULT([no])
422258945Sroberto      cat $FIXPATH_DIR/fixpath2.log
423258945Sroberto      AC_MSG_ERROR([fixpath did not work!])
424258945Sroberto    fi
425258945Sroberto    AC_MSG_RESULT([yes])
426258945Sroberto
427258945Sroberto    FIXPATH_DETACH_FLAG="--detach"
428258945Sroberto  fi
429258945Sroberto
430258945Sroberto  AC_SUBST(FIXPATH)
431258945Sroberto  AC_SUBST(FIXPATH_DETACH_FLAG)
432258945Sroberto])
433258945Sroberto