Changeset 59310bf for automake/ylwrap


Ignore:
Timestamp:
Jul 28, 2017, 2:26:14 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
79dbb79
Parents:
a2e0687
Message:

automake directory must copy files, use --copy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • automake/ylwrap

    ra2e0687 r59310bf  
    22# ylwrap - wrapper for lex/yacc invocations.
    33
    4 scriptversion=2011-08-25.18; # UTC
    5 
    6 # Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005,
    7 # 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
     4scriptversion=2013-01-12.17; # UTC
     5
     6# Copyright (C) 1996-2014 Free Software Foundation, Inc.
    87#
    98# Written by Tom Tromey <tromey@cygnus.com>.
     
    3130# <automake-patches@gnu.org>.
    3231
     32get_dirname ()
     33{
     34  case $1 in
     35    */*|*\\*) printf '%s\n' "$1" | sed -e 's|\([\\/]\)[^\\/]*$|\1|';;
     36    # Otherwise,  we want the empty string (not ".").
     37  esac
     38}
     39
     40# guard FILE
     41# ----------
     42# The CPP macro used to guard inclusion of FILE.
     43guard ()
     44{
     45  printf '%s\n' "$1"                                                    \
     46    | sed                                                               \
     47        -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'   \
     48        -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'                        \
     49        -e 's/__*/_/g'
     50}
     51
     52# quote_for_sed [STRING]
     53# ----------------------
     54# Return STRING (or stdin) quoted to be used as a sed pattern.
     55quote_for_sed ()
     56{
     57  case $# in
     58    0) cat;;
     59    1) printf '%s\n' "$1";;
     60  esac \
     61    | sed -e 's|[][\\.*]|\\&|g'
     62}
     63
    3364case "$1" in
    3465  '')
    35     echo "$0: No files given.  Try \`$0 --help' for more information." 1>&2
     66    echo "$0: No files given.  Try '$0 --help' for more information." 1>&2
    3667    exit 1
    3768    ;;
     
    6697
    6798# The input.
    68 input="$1"
     99input=$1
    69100shift
    70 case "$input" in
     101# We'll later need for a correct munging of "#line" directives.
     102input_sub_rx=`get_dirname "$input" | quote_for_sed`
     103case $input in
    71104  [\\/]* | ?:[\\/]*)
    72105    # Absolute path; do nothing.
     
    74107  *)
    75108    # Relative path.  Make it absolute.
    76     input="`pwd`/$input"
    77     ;;
    78 esac
    79 
    80 pairlist=
    81 while test "$#" -ne 0; do
    82   if test "$1" = "--"; then
     109    input=`pwd`/$input
     110    ;;
     111esac
     112input_rx=`get_dirname "$input" | quote_for_sed`
     113
     114# Since DOS filename conventions don't allow two dots,
     115# the DOS version of Bison writes out y_tab.c instead of y.tab.c
     116# and y_tab.h instead of y.tab.h. Test to see if this is the case.
     117y_tab_nodot=false
     118if test -f y_tab.c || test -f y_tab.h; then
     119  y_tab_nodot=true
     120fi
     121
     122# The parser itself, the first file, is the destination of the .y.c
     123# rule in the Makefile.
     124parser=$1
     125
     126# A sed program to s/FROM/TO/g for all the FROM/TO so that, for
     127# instance, we rename #include "y.tab.h" into #include "parse.h"
     128# during the conversion from y.tab.c to parse.c.
     129sed_fix_filenames=
     130
     131# Also rename header guards, as Bison 2.7 for instance uses its header
     132# guard in its implementation file.
     133sed_fix_header_guards=
     134
     135while test $# -ne 0; do
     136  if test x"$1" = x"--"; then
    83137    shift
    84138    break
    85139  fi
    86   pairlist="$pairlist $1"
     140  from=$1
     141  # Handle y_tab.c and y_tab.h output by DOS
     142  if $y_tab_nodot; then
     143    case $from in
     144      "y.tab.c") from=y_tab.c;;
     145      "y.tab.h") from=y_tab.h;;
     146    esac
     147  fi
    87148  shift
     149  to=$1
     150  shift
     151  sed_fix_filenames="${sed_fix_filenames}s|"`quote_for_sed "$from"`"|$to|g;"
     152  sed_fix_header_guards="${sed_fix_header_guards}s|"`guard "$from"`"|"`guard "$to"`"|g;"
    88153done
    89154
    90155# The program to run.
    91 prog="$1"
     156prog=$1
    92157shift
    93158# Make any relative path in $prog absolute.
    94 case "$prog" in
     159case $prog in
    95160  [\\/]* | ?:[\\/]*) ;;
    96   *[\\/]*) prog="`pwd`/$prog" ;;
    97 esac
    98 
    99 # FIXME: add hostname here for parallel makes that run commands on
    100 # other machines.  But that might take us over the 14-char limit.
     161  *[\\/]*) prog=`pwd`/$prog ;;
     162esac
     163
    101164dirname=ylwrap$$
    102165do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret'
     
    116179
    117180if test $ret -eq 0; then
    118   set X $pairlist
    119   shift
    120   first=yes
    121   # Since DOS filename conventions don't allow two dots,
    122   # the DOS version of Bison writes out y_tab.c instead of y.tab.c
    123   # and y_tab.h instead of y.tab.h. Test to see if this is the case.
    124   y_tab_nodot="no"
    125   if test -f y_tab.c || test -f y_tab.h; then
    126     y_tab_nodot="yes"
    127   fi
    128 
    129   # The directory holding the input.
    130   input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'`
    131   # Quote $INPUT_DIR so we can use it in a regexp.
    132   # FIXME: really we should care about more than `.' and `\'.
    133   input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'`
    134 
    135   while test "$#" -ne 0; do
    136     from="$1"
    137     # Handle y_tab.c and y_tab.h output by DOS
    138     if test $y_tab_nodot = "yes"; then
    139       if test $from = "y.tab.c"; then
    140         from="y_tab.c"
    141       else
    142         if test $from = "y.tab.h"; then
    143           from="y_tab.h"
    144         fi
    145       fi
    146     fi
     181  for from in *
     182  do
     183    to=`printf '%s\n' "$from" | sed "$sed_fix_filenames"`
    147184    if test -f "$from"; then
    148185      # If $2 is an absolute path name, then just use that,
    149       # otherwise prepend `../'.
    150       case "$2" in
    151         [\\/]* | ?:[\\/]*) target="$2";;
    152         *) target="../$2";;
     186      # otherwise prepend '../'.
     187      case $to in
     188        [\\/]* | ?:[\\/]*) target=$to;;
     189        *) target=../$to;;
    153190      esac
    154191
    155       # We do not want to overwrite a header file if it hasn't
    156       # changed.  This avoid useless recompilations.  However the
    157       # parser itself (the first file) should always be updated,
    158       # because it is the destination of the .y.c rule in the
    159       # Makefile.  Divert the output of all other files to a temporary
    160       # file so we can compare them to existing versions.
    161       if test $first = no; then
    162         realtarget="$target"
    163         target="tmp-`echo $target | sed s/.*[\\/]//g`"
     192      # Do not overwrite unchanged header files to avoid useless
     193      # recompilations.  Always update the parser itself: it is the
     194      # destination of the .y.c rule in the Makefile.  Divert the
     195      # output of all other files to a temporary file so we can
     196      # compare them to existing versions.
     197      if test $from != $parser; then
     198        realtarget=$target
     199        target=tmp-`printf '%s\n' "$target" | sed 's|.*[\\/]||g'`
    164200      fi
    165       # Edit out `#line' or `#' directives.
    166       #
    167       # We don't want the resulting debug information to point at
    168       # an absolute srcdir; it is better for it to just mention the
    169       # .y file with no path.
    170       #
    171       # We want to use the real output file name, not yy.lex.c for
    172       # instance.
    173       #
    174       # We want the include guards to be adjusted too.
    175       FROM=`echo "$from" | sed \
    176             -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
    177             -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
    178       TARGET=`echo "$2" | sed \
    179             -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
    180             -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
    181 
    182       sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
    183           -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
    184 
    185       # Check whether header files must be updated.
    186       if test $first = no; then
     201
     202      # Munge "#line" or "#" directives.  Don't let the resulting
     203      # debug information point at an absolute srcdir.  Use the real
     204      # output file name, not yy.lex.c for instance.  Adjust the
     205      # include guards too.
     206      sed -e "/^#/!b"                           \
     207          -e "s|$input_rx|$input_sub_rx|"       \
     208          -e "$sed_fix_filenames"               \
     209          -e "$sed_fix_header_guards"           \
     210        "$from" >"$target" || ret=$?
     211
     212      # Check whether files must be updated.
     213      if test "$from" != "$parser"; then
    187214        if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
    188           echo "$2" is unchanged
     215          echo "$to is unchanged"
    189216          rm -f "$target"
    190217        else
    191           echo updating "$2"
     218          echo "updating $to"
    192219          mv -f "$target" "$realtarget"
    193220        fi
    194221      fi
    195222    else
    196       # A missing file is only an error for the first file.  This
    197       # is a blatant hack to let us support using "yacc -d".  If -d
    198       # is not specified, we don't want an error when the header
    199       # file is "missing".
    200       if test $first = yes; then
     223      # A missing file is only an error for the parser.  This is a
     224      # blatant hack to let us support using "yacc -d".  If -d is not
     225      # specified, don't fail when the header file is "missing".
     226      if test "$from" = "$parser"; then
    201227        ret=1
    202228      fi
    203229    fi
    204     shift
    205     shift
    206     first=no
    207230  done
    208 else
    209   ret=$?
    210231fi
    211232
Note: See TracChangeset for help on using the changeset viewer.