1#! /bin/sh
2#
3#   @configure_input@
4#
5#   Script for converting between windows and unix-style paths.
6#
7#   Copyright (C) 2001,2002 Free Software Foundation, Inc.
8#
9#   Author:  Stephen Brandon <stephen@brandonitconsulting.co.uk>
10#   Modified by:  Richard Frith-Macdonald <rfm@gnu.org>
11#
12#   This file is part of the GNUstep Makefile Package.
13#
14#   This library is free software; you can redistribute it and/or
15#   modify it under the terms of the GNU General Public License
16#   as published by the Free Software Foundation; either version 3
17#   of the License, or (at your option) any later version.
18#
19#   You should have received a copy of the GNU General Public
20#   License along with this library; see the file COPYING.
21#   If not, write to the Free Software Foundation,
22#   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23#
24
25#
26# Define CYGWIN to "yes" to force cygwin style path handling, or
27# to anything else for MINGW32/MSYS style path handling.
28#
29CYGWIN="@CYGWIN@"
30
31if [ ! $# -eq 2 ]; then
32  quit="yes"
33fi
34
35test "$1" = '-u' || test "$1" = '-w' || quit="yes"
36
37
38if [ "$quit" = "yes" ]; then
39  echo "Usage: $0 (-u)|(-w) filename"
40  echo "Options:"
41  echo "   -u print Unix form of filename"
42  echo "   -w print Windows form of filename"
43  exit 1
44fi
45
46operation=$1
47file=$2
48
49if [ "$operation" = "-u" ]; then
50  #
51  # convert to Unix style file name
52  #
53  if [ "$CYGWIN" = "yes" ]; then
54    #
55    # drive:directory --> /cygdrive/drive/directory
56    #
57    echo $file | \
58    tr '\\' '/' | \
59    sed 's/^\([a-zA-Z]\):\(.*\)$/\/cygdrive\/\1\2/'
60  else
61    #
62    # drive:directory --> /drive/directory
63    #
64    echo $file | \
65    tr '\\' '/' | \
66    sed 's/^\([a-zA-Z]\):\(.*\)$/\/\1\2/' | \
67    sed 's/\/\//\//'
68  fi
69else
70  #
71  # convert to Windows style file name
72  #
73  if [ "$CYGWIN" = "yes" ]; then
74    #
75    # /cygdrive/drive/directory --> drive:directory
76    #
77    echo $file | \
78    sed 's/^\(\/cygdrive\)\?\/\([a-zA-Z]\)\(\/.*\)$/\2:\3/' | \
79    tr '/' '\\'
80  else
81    #
82    # /drive/directory --> drive:directory
83    #
84    echo $file | \
85    sed 's/^\/\([a-zA-Z]\)\(\/.*\)$/\1:\2/' | \
86    tr '/' '\\'
87  fi
88fi
89
90exit 0
91
92
93