summaryrefslogtreecommitdiff
path: root/alias-macro.pl
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2009-08-11 12:05:21 +0100
committerReuben Thomas <rrt@sc3d.org>2009-08-11 12:05:21 +0100
commit70a5fdcedd670ff21d39e7d872bc7180e7afbd6d (patch)
tree7b0f33b29a514ca6f58362ba4024954c06ddb694 /alias-macro.pl
parentb456074a0da5f319a512c043e6c5102e078923f4 (diff)
downloadautoconf-archive-70a5fdcedd670ff21d39e7d872bc7180e7afbd6d.tar.gz
Add script to add AU_ALIAS call to a macro.
Diffstat (limited to 'alias-macro.pl')
-rwxr-xr-xalias-macro.pl32
1 files changed, 32 insertions, 0 deletions
diff --git a/alias-macro.pl b/alias-macro.pl
new file mode 100755
index 0000000..5fa107e
--- /dev/null
+++ b/alias-macro.pl
@@ -0,0 +1,32 @@
+#! /usr/bin/env perl
+# alias-macro
+# Alias an autoconf-archive macro
+# Usage: alias-macro FROM TO
+
+use strict;
+use warnings;
+
+my ($old_file, $new_file) = @ARGV;
+
+# Extract names from file names
+my $old_name = $old_file;
+$old_name =~ s/\..*$//;
+my $uc_old_name = uc($old_name);
+$old_name = lc($old_name);
+my $new_name = $new_file;
+$new_name =~ s/\..*$//;
+my $uc_new_name = uc($new_name);
+$new_name = lc($new_name);
+
+# Check new name exists
+die "could not find `$new_file'\n" unless -e $new_file;
+
+# Read file
+open IN, $old_file or die "could not read `$old_file'\n";
+my $text = do { local $/, <IN> };
+
+# Alias the macro
+my $old_text = $text;
+$old_text =~ s/^AC_DEFUN\(\[$uc_old_name/AU_ALIAS([$uc_old_name], [$uc_new_name])\nAC_DEFUN([$uc_old_name/m;
+open OUTFILE, ">$old_file" or die "could not write `$old_file'";
+print OUTFILE $old_text;