~ubuntu-branches/ubuntu/karmic/guarddog/karmic

« back to all changes in this revision

Viewing changes to admin/ylwrap

  • Committer: Bazaar Package Importer
  • Author(s): Siegfried-Angel Gevatter Pujals (RainCT)
  • Date: 2007-11-06 23:43:11 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20071106234311-eeiuy01hc66d34df
Tags: 2.6.0-1ubuntu1
* Merge from debian unstable, remaining changes:
   - Bump standards version to 3.7.2 (no changes)
   - Bump debhelper build dependency to version >>5
   - Fix kde/guarddog.desktop and add some translations
   - debian/rules: move .desktop file to /usr/share/applications;
     debian/dirs: add usr/share/applications
   - Use dh_icons (previous Ubuntu revision used dh_iconcache).
   - Modify Maintainer value to match the DebianMaintainerField
     specification.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /bin/sh
2
2
# ylwrap - wrapper for lex/yacc invocations.
3
 
# Copyright 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
 
3
 
 
4
scriptversion=2005-05-14.22
 
5
 
 
6
# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005
 
7
#   Free Software Foundation, Inc.
 
8
#
4
9
# Written by Tom Tromey <tromey@cygnus.com>.
5
10
#
6
11
# This program is free software; you can redistribute it and/or modify
15
20
#
16
21
# You should have received a copy of the GNU General Public License
17
22
# along with this program; if not, write to the Free Software
18
 
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
23
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
24
# 02110-1301, USA.
19
25
 
20
26
# As a special exception to the GNU General Public License, if you
21
27
# distribute this file as part of a program that contains a
22
28
# configuration script generated by Autoconf, you may include it under
23
29
# the same distribution terms that you use for the rest of that program.
24
30
 
25
 
# Usage:
26
 
#     ylwrap INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]...
27
 
# * INPUT is the input file
28
 
# * OUTPUT is file PROG generates
29
 
# * DESIRED is file we actually want
30
 
# * PROGRAM is program to run
31
 
# * ARGS are passed to PROG
32
 
# Any number of OUTPUT,DESIRED pairs may be used.
 
31
# This file is maintained in Automake, please report
 
32
# bugs to <bug-automake@gnu.org> or send patches to
 
33
# <automake-patches@gnu.org>.
 
34
 
 
35
case "$1" in
 
36
  '')
 
37
    echo "$0: No files given.  Try \`$0 --help' for more information." 1>&2
 
38
    exit 1
 
39
    ;;
 
40
  --basedir)
 
41
    basedir=$2
 
42
    shift 2
 
43
    ;;
 
44
  -h|--h*)
 
45
    cat <<\EOF
 
46
Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]...
 
47
 
 
48
Wrapper for lex/yacc invocations, renaming files as desired.
 
49
 
 
50
  INPUT is the input file
 
51
  OUTPUT is one file PROG generates
 
52
  DESIRED is the file we actually want instead of OUTPUT
 
53
  PROGRAM is program to run
 
54
  ARGS are passed to PROG
 
55
 
 
56
Any number of OUTPUT,DESIRED pairs may be used.
 
57
 
 
58
Report bugs to <bug-automake@gnu.org>.
 
59
EOF
 
60
    exit $?
 
61
    ;;
 
62
  -v|--v*)
 
63
    echo "ylwrap $scriptversion"
 
64
    exit $?
 
65
    ;;
 
66
esac
 
67
 
33
68
 
34
69
# The input.
35
70
input="$1"
36
71
shift
37
72
case "$input" in
38
 
 [\\/]* | ?:[\\/]*)
 
73
  [\\/]* | ?:[\\/]*)
39
74
    # Absolute path; do nothing.
40
75
    ;;
41
 
 *)
 
76
  *)
42
77
    # Relative path.  Make it absolute.
43
78
    input="`pwd`/$input"
44
79
    ;;
45
80
esac
46
81
 
47
 
# The directory holding the input.
48
 
input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'`
49
 
# Quote $INPUT_DIR so we can use it in a regexp.
50
 
# FIXME: really we should care about more than `.' and `\'.
51
 
input_rx=`echo "$input_dir" | sed -e 's,\\\\,\\\\\\\\,g' -e 's,\\.,\\\\.,g'`
52
 
 
53
 
echo "got $input_rx"
54
 
 
55
82
pairlist=
56
83
while test "$#" -ne 0; do
57
 
   if test "$1" = "--"; then
58
 
      shift
59
 
      break
60
 
   fi
61
 
   pairlist="$pairlist $1"
62
 
   shift
 
84
  if test "$1" = "--"; then
 
85
    shift
 
86
    break
 
87
  fi
 
88
  pairlist="$pairlist $1"
 
89
  shift
63
90
done
64
91
 
65
92
# The program to run.
67
94
shift
68
95
# Make any relative path in $prog absolute.
69
96
case "$prog" in
70
 
 [\\/]* | ?:[\\/]*) ;;
71
 
 *[\\/]*) prog="`pwd`/$prog" ;;
 
97
  [\\/]* | ?:[\\/]*) ;;
 
98
  *[\\/]*) prog="`pwd`/$prog" ;;
72
99
esac
73
100
 
74
101
# FIXME: add hostname here for parallel makes that run commands on
79
106
 
80
107
cd $dirname
81
108
 
82
 
$prog ${1+"$@"} "$input"
83
 
status=$?
84
 
 
85
 
if test $status -eq 0; then
86
 
   set X $pairlist
87
 
   shift
88
 
   first=yes
89
 
   # Since DOS filename conventions don't allow two dots,
90
 
   # the DOS version of Bison writes out y_tab.c instead of y.tab.c
91
 
   # and y_tab.h instead of y.tab.h. Test to see if this is the case.
92
 
   y_tab_nodot="no"
93
 
   if test -f y_tab.c || test -f y_tab.h; then
94
 
      y_tab_nodot="yes"
95
 
   fi
96
 
 
97
 
   while test "$#" -ne 0; do
98
 
      from="$1"
99
 
      # Handle y_tab.c and y_tab.h output by DOS
100
 
      if test $y_tab_nodot = "yes"; then
101
 
         if test $from = "y.tab.c"; then
102
 
            from="y_tab.c"
103
 
         else
104
 
            if test $from = "y.tab.h"; then
105
 
               from="y_tab.h"
106
 
            fi
107
 
         fi
108
 
      fi
109
 
      if test -f "$from"; then
110
 
         # If $2 is an absolute path name, then just use that,
111
 
         # otherwise prepend `../'.
112
 
         case "$2" in
113
 
           [\\/]* | ?:[\\/]*) target="$2";;
114
 
           *) target="../$2";;
115
 
         esac
116
 
 
117
 
         # Edit out `#line' or `#' directives.  We don't want the
118
 
         # resulting debug information to point at an absolute srcdir;
119
 
         # it is better for it to just mention the .y file with no
120
 
         # path.
121
 
         sed -e "/^#/ s,$input_rx,," "$from" > "$target" || status=$?
 
109
case $# in
 
110
  0) $prog "$input" ;;
 
111
  *) $prog "$@" "$input" ;;
 
112
esac
 
113
ret=$?
 
114
 
 
115
if test $ret -eq 0; then
 
116
  set X $pairlist
 
117
  shift
 
118
  first=yes
 
119
  # Since DOS filename conventions don't allow two dots,
 
120
  # the DOS version of Bison writes out y_tab.c instead of y.tab.c
 
121
  # and y_tab.h instead of y.tab.h. Test to see if this is the case.
 
122
  y_tab_nodot="no"
 
123
  if test -f y_tab.c || test -f y_tab.h; then
 
124
    y_tab_nodot="yes"
 
125
  fi
 
126
 
 
127
  # The directory holding the input.
 
128
  input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'`
 
129
  # Quote $INPUT_DIR so we can use it in a regexp.
 
130
  # FIXME: really we should care about more than `.' and `\'.
 
131
  input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'`
 
132
 
 
133
  while test "$#" -ne 0; do
 
134
    from="$1"
 
135
    # Handle y_tab.c and y_tab.h output by DOS
 
136
    if test $y_tab_nodot = "yes"; then
 
137
      if test $from = "y.tab.c"; then
 
138
        from="y_tab.c"
122
139
      else
123
 
         # A missing file is only an error for the first file.  This
124
 
         # is a blatant hack to let us support using "yacc -d".  If -d
125
 
         # is not specified, we don't want an error when the header
126
 
         # file is "missing".
127
 
         if test $first = yes; then
128
 
            status=1
129
 
         fi
130
 
      fi
131
 
      shift
132
 
      shift
133
 
      first=no
134
 
   done
 
140
        if test $from = "y.tab.h"; then
 
141
          from="y_tab.h"
 
142
        fi
 
143
      fi
 
144
    fi
 
145
    if test -f "$from"; then
 
146
      # If $2 is an absolute path name, then just use that,
 
147
      # otherwise prepend `../'.
 
148
      case "$2" in
 
149
        [\\/]* | ?:[\\/]*) target="$2";;
 
150
        *) target="../$2";;
 
151
      esac
 
152
 
 
153
      # We do not want to overwrite a header file if it hasn't
 
154
      # changed.  This avoid useless recompilations.  However the
 
155
      # parser itself (the first file) should always be updated,
 
156
      # because it is the destination of the .y.c rule in the
 
157
      # Makefile.  Divert the output of all other files to a temporary
 
158
      # file so we can compare them to existing versions.
 
159
      if test $first = no; then
 
160
        realtarget="$target"
 
161
        target="tmp-`echo $target | sed s/.*[\\/]//g`"
 
162
      fi
 
163
      # Edit out `#line' or `#' directives.
 
164
      #
 
165
      # We don't want the resulting debug information to point at
 
166
      # an absolute srcdir; it is better for it to just mention the
 
167
      # .y file with no path.
 
168
      #
 
169
      # We want to use the real output file name, not yy.lex.c for
 
170
      # instance.
 
171
      #
 
172
      # We want the include guards to be adjusted too.
 
173
      FROM=`echo "$from" | sed \
 
174
            -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
 
175
            -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
 
176
      TARGET=`echo "$2" | sed \
 
177
            -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
 
178
            -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
 
179
 
 
180
      sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
 
181
          -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
 
182
 
 
183
      # Check whether header files must be updated.
 
184
      if test $first = no; then
 
185
        if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
 
186
          echo "$2" is unchanged
 
187
          rm -f "$target"
 
188
        else
 
189
          echo updating "$2"
 
190
          mv -f "$target" "$realtarget"
 
191
        fi
 
192
      fi
 
193
    else
 
194
      # A missing file is only an error for the first file.  This
 
195
      # is a blatant hack to let us support using "yacc -d".  If -d
 
196
      # is not specified, we don't want an error when the header
 
197
      # file is "missing".
 
198
      if test $first = yes; then
 
199
        ret=1
 
200
      fi
 
201
    fi
 
202
    shift
 
203
    shift
 
204
    first=no
 
205
  done
135
206
else
136
 
   status=$?
 
207
  ret=$?
137
208
fi
138
209
 
139
210
# Remove the directory.
140
211
cd ..
141
212
rm -rf $dirname
142
213
 
143
 
exit $status
 
214
exit $ret
 
215
 
 
216
# Local Variables:
 
217
# mode: shell-script
 
218
# sh-indentation: 2
 
219
# eval: (add-hook 'write-file-hooks 'time-stamp)
 
220
# time-stamp-start: "scriptversion="
 
221
# time-stamp-format: "%:y-%02m-%02d.%02H"
 
222
# time-stamp-end: "$"
 
223
# End: