Shared admin folder
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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