]>
git.saurik.com Git - bison.git/blob - etc/prefix-gnulib-mk
08d22f288d9433a236fff9bf3f19dc553198ccd3
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 # Do not use gl_LIBOBJS, but its prefixed version.
77 $rhs =~ s/gl_LIBOBJS/gl_PREFIXED_LIBOBJS/g;
79 return $lhs_and_assign_op . $rhs;
84 # $CONTENTS is a Makefile content. Post-process it so that each file-name
85 # is prefixed with $prefix (e.g., "lib/").
87 # Relies heavily on the regularity of the file generated by gnulib-tool.
93 # Prefix all the occurrence of files in rules. If there is nothing
94 # after in the :, it's probably a phony target, or a suffix rule.
96 s
{^([\w
.]+ *: *\w
.*)$}
97 {prefix_words
($1)}gem
;
99 # Prefix files in variables.
100 s
{^([\w
.]+\s
*\
+?=)(.*)$}
101 {prefix_assignment
($1, $2)}gem
;
103 # These three guys escape all the other regular rules.
104 s{(charset\.alias|ref-add\.sed|ref-del\.sed)}{$prefix$1}g;
105 # Unfortunately, as a result we sometimes have lib/lib.
108 # $(srcdir) is actually $(top_srcdir)/lib.
109 s{\$\(srcdir\)}{\$(top_srcdir)/lib}g;
111 # Sometimes, t-$@ is used instead of $@-t, which, of course, does
112 # not work when we have a $@ with a directory in it.
123 my ($bak) = "$file.bak";
124 rename ($file, $bak) or die;
125 my $contents = contents
($bak);
126 $contents = prefix
($contents);
127 my $out = new IO
::File
(">$file") or die;
128 print $out $contents;
131 process
("lib/gnulib.mk")
134 ### Setup "GNU" style for perl-mode and cperl-mode.
136 ## perl-indent-level: 2
137 ## perl-continued-statement-offset: 2
138 ## perl-continued-brace-offset: 0
139 ## perl-brace-offset: 0
140 ## perl-brace-imaginary-offset: 0
141 ## perl-label-offset: -2
142 ## cperl-indent-level: 2
143 ## cperl-brace-offset: 0
144 ## cperl-continued-brace-offset: 0
145 ## cperl-label-offset: -2
146 ## cperl-extra-newline-before-brace: t
147 ## cperl-merge-trailing-else: nil
148 ## cperl-continued-statement-offset: 2