]>
git.saurik.com Git - bison.git/blob - etc/prefix-gnulib-mk
1bff69bc70238c4be96ca02d0686647e2c507c58
8 # contents ($FILE_NAME)
9 # ---------------------
13 local $/; # Turn on slurp-mode.
14 my $f = new IO
::File
"< $file" or die "$file";
15 my $contents = $f->getline or die "$file";
22 # Do not prefix special words such as variable dereferences. Also,
23 # "Makefile" is really "Makefile", since precisely there is no
29 unless m{^\$\(\w+\)} || $_ eq "Makefile";
34 # prefix_words ($TEXT)
35 # --------------------
39 s{(\S+)}{prefix_word($1)}gem;
44 # prefix_assignment ($LHS-AND-ASSIGN-OP, $RHS)
45 # --------------------------------------------
46 sub prefix_assignment
($$)
48 my ($lhs_and_assign_op, $rhs) = @_;
51 # Some variables are initialized by gnulib.mk, and we don't want
52 # that. Change '=' to '+='.
53 if ($lhs_and_assign_op =~ /^(SUBDIRS|EXTRA_DIST|BUILT_SOURCES|SUFFIXES|MOSTLYCLEANFILES|CLEANFILES|DISTCLEANFILES|MAINTAINERCLEANFILES|AM_CFLAGS|AM_CPPFLAGS|AM_GNU_GETTEXT) =/)
55 $lhs_and_assign_op =~ s/=/+=/;
57 # We don't want to inherit gnulib's AUTOMAKE_OPTIONS, comment them.
58 elsif ($lhs_and_assign_op =~ /^AUTOMAKE_OPTIONS =/)
60 $lhs_and_assign_op =~ s/^/# /;
62 # Don't touch suffixes.
63 elsif ($lhs_and_assign_op =~ /^SUFFIXES /)
66 # The words are (probably) paths to files in lib/: prefix them.
69 $rhs = prefix_words
($rhs)
72 # Variables which name depend on the location: libbison_a_SOURCES =>
73 # lib_libbison_a_SOURCES.
74 $lhs_and_assign_op =~ s/(libbison)/lib_$1/g;
76 return $lhs_and_assign_op . $rhs;
81 # $CONTENTS is a Makefile content. Post-process it so that each file-name
82 # is prefixed with $prefix (e.g., "lib/").
84 # Relies heavily on the regularity of the file generated by gnulib-tool.
90 # Prefix all the occurrence of files in rules. If there is nothing
91 # after in the :, it's probably a phony target, or a suffix rule.
93 s
{^([-\w
/]+\
.[-\w
.]+ *: *\S
.*)$}
94 {prefix_words
($1)}gem
;
96 # Prefix files in variables.
97 s
{^([\w
.]+\s
*\
+?=)(.*)$}
98 {prefix_assignment
($1, $2)}gem
;
100 # These three guys escape all the other regular rules.
101 s{(charset\.alias|ref-add\.sed|ref-del\.sed)}{$prefix$1}g;
102 # Unfortunately, as a result we sometimes have lib/lib.
103 s{($prefix){2}}{$1}g;
105 # $(srcdir) is actually $(top_srcdir)/lib.
106 s{\$\(srcdir\)}{\$(top_srcdir)/lib}g;
108 # Sometimes, t-$@ is used instead of $@-t, which, of course, does
109 # not work when we have a $@ with a directory in it.
112 # Some AC_SUBST patterns remain and would better be Make macros.
113 s{\@(MKDIR_P)\@}{\$($1)}g;
115 # Adjust paths in mkdir.
116 s{(\$\(MKDIR_P\))\s*(\w+)}{$1 $prefix$2}g;
126 my ($bak) = "$file.bak";
127 rename ($file, $bak) or die;
128 my $contents = contents
($bak);
129 $contents = prefix
($contents);
130 my $out = new IO
::File
(">$file") or die;
131 print $out $contents;
134 process
("${prefix}gnulib.mk")
137 ### Setup "GNU" style for perl-mode and cperl-mode.
139 ## perl-indent-level: 2
140 ## perl-continued-statement-offset: 2
141 ## perl-continued-brace-offset: 0
142 ## perl-brace-offset: 0
143 ## perl-brace-imaginary-offset: 0
144 ## perl-label-offset: -2
145 ## cperl-indent-level: 2
146 ## cperl-brace-offset: 0
147 ## cperl-continued-brace-offset: 0
148 ## cperl-label-offset: -2
149 ## cperl-extra-newline-before-brace: t
150 ## cperl-merge-trailing-else: nil
151 ## cperl-continued-statement-offset: 2