[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] build: generalize etc/prefix-gnulib-mk
From: |
Jim Meyering |
Subject: |
[PATCH] build: generalize etc/prefix-gnulib-mk |
Date: |
Sat, 21 Jan 2012 22:48:07 +0100 |
I mentioned that I'm using etc/prefix-gnulib-mk also from
cppi, as an experiment. In doing that, I had to factor out
at least the hard-coded "libbison" in etc/prefix-gnulib-mk.
It also hard-coded the "lib/" prefix and the file name,
${prefix}gnulib.mk. I factored those out, too.
This is a no-semantic-change commit.
>From 28d216d092f16914eff70fd66a1215e9c082ad49 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 21 Jan 2012 22:43:09 +0100
Subject: [PATCH] build: generalize etc/prefix-gnulib-mk
This script hard-coded "libbison" and lib/gnulib.mk.
Adjust the script to require a --lib-name=$gnulib_name option
and a FILE argument like lib/$gnulib_mk.
Also add support for --help and --version.
* etc/prefix-gnulib-mk: Generalize.
* bootstrap.conf (bootstrap_post_import_hook): Update its invocation.
---
bootstrap.conf | 2 +-
etc/prefix-gnulib-mk | 76 +++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 73 insertions(+), 5 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index e47b550..599b778 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -66,7 +66,7 @@ gnulib_tool_option_extras='--symlink
--makefile-name=gnulib.mk'
bootstrap_post_import_hook()
{
# Massage lib/gnulib.mk before using it later in the bootstrapping process.
- etc/prefix-gnulib-mk lib/$gnulib_mk
+ etc/prefix-gnulib-mk --lib-name=$gnulib_name lib/$gnulib_mk
# Ensure that ChangeLog exists, for automake.
test -f ChangeLog || touch ChangeLog
diff --git a/etc/prefix-gnulib-mk b/etc/prefix-gnulib-mk
index 4debcb9..81c0924 100755
--- a/etc/prefix-gnulib-mk
+++ b/etc/prefix-gnulib-mk
@@ -2,8 +2,46 @@
use strict;
use IO::File;
+use Getopt::Long;
+use File::Basename; # for dirname
-my $prefix = "lib/";
+my $VERSION = '2012-01-21 17:13'; # UTC
+(my $ME = $0) =~ s|.*/||;
+
+my $prefix;
+my $lib_name;
+
+sub usage ($)
+{
+ my ($exit_code) = @_;
+ my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR);
+ if ($exit_code != 0)
+ {
+ print $STREAM "Try '$ME --help' for more information.\n";
+ }
+ else
+ {
+ print $STREAM <<EOF;
+Usage: $ME --lib-name=NAME FILE
+ or: $ME [--help|--version]
+Rewrite a gnulib-tool-generated FILE like lib/gnulib.mk to work with
+automake's subdir-objects.
+
+OPTIONS:
+
+This option must be specified:
+
+ --lib-name=NAME library name, often "lib\$project"
+
+The following are optional:
+
+ --help display this help and exit
+ --version output version information and exit
+
+EOF
+ }
+ exit $exit_code;
+}
# contents ($FILE_NAME)
# ---------------------
@@ -71,7 +109,7 @@ sub prefix_assignment ($$)
# Variables which name depend on the location: libbison_a_SOURCES =>
# lib_libbison_a_SOURCES.
- $lhs_and_assign_op =~ s/(libbison)/lib_$1/g;
+ $lhs_and_assign_op =~ s/($lib_name)/lib_$1/g;
return $lhs_and_assign_op . $rhs;
}
@@ -131,8 +169,33 @@ sub process ($)
print $out $contents;
}
-process ("${prefix}gnulib.mk")
-
+{
+ GetOptions
+ (
+ 'lib-name=s' => \$lib_name,
+ help => sub { usage 0 },
+ version => sub { print "$ME version $VERSION\n"; exit },
+ ) or usage 1;
+
+ my $fail = 0;
+ defined $lib_name
+ or (warn "$ME: no library name; use --lib-name=NAME\n"), $fail = 1;
+
+ # There must be exactly one argument.
+ @ARGV == 0
+ and (warn "$ME: missing FILE argument\n"), $fail = 1;
+ 1 < @ARGV
+ and (warn "$ME: too many arguments:\n", join ("\n", @ARGV), "\n"),
+ $fail = 1;
+ $fail
+ and usage 1;
+
+ my $file = $ARGV[0];
+ $prefix = (dirname $file) . '/';
+ warn "prefix=$prefix\n";
+
+ process $file;
+}
### Setup "GNU" style for perl-mode and cperl-mode.
## Local Variables:
@@ -149,4 +212,9 @@ process ("${prefix}gnulib.mk")
## cperl-extra-newline-before-brace: t
## cperl-merge-trailing-else: nil
## cperl-continued-statement-offset: 2
+## eval: (add-hook 'write-file-hooks 'time-stamp)
+## time-stamp-start: "my $VERSION = '"
+## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
+## time-stamp-time-zone: "UTC"
+## time-stamp-end: "'; # UTC"
## End:
--
1.7.9.rc2.2.g183d6
- [PATCH] build: generalize etc/prefix-gnulib-mk,
Jim Meyering <=