summaryrefslogtreecommitdiff
path: root/mcon
diff options
context:
space:
mode:
authorAaron Crane <arc@cpan.org>2017-10-23 18:13:51 +0100
committerAaron Crane <arc@cpan.org>2017-10-23 18:13:51 +0100
commit4522d060c8e2be12b054d1e883f66879cc610a77 (patch)
tree8184467eaac7fdd38f64966c5772226cdf17ee09 /mcon
parent06e93d9d534a84de9902164cc75d9b98bfadc452 (diff)
New "-X exclusions-file" option for mconfig
Packages can use this option to list symbols that shouldn't bring in the corresponding units. For example, Perl need not provide support for BSD index(3) as an alternative to C89 strchr(3), but "index" is the name of a Perl builtin, so that string in the source files is misunderstood by metaconfig as an attempt to use the BSD function. With this change, Perl can deal with this situation by adding "index" (and "rindex") to an exclusion list.
Diffstat (limited to 'mcon')
-rwxr-xr-xmcon/man/mconfig.SH11
-rwxr-xr-xmcon/mconfig.SH5
-rw-r--r--mcon/pl/depend.pl3
-rw-r--r--mcon/pl/wanted.pl19
4 files changed, 37 insertions, 1 deletions
diff --git a/mcon/man/mconfig.SH b/mcon/man/mconfig.SH
index f205fb7..ba415e2 100755
--- a/mcon/man/mconfig.SH
+++ b/mcon/man/mconfig.SH
@@ -528,6 +528,17 @@ option permanently.
.TP
.B \-V
Print version number and exit.
+.TP
+\fB\-X\fI file\fR
+When examining the source files, ignore any symbols listed in the \fIfile\fR.
+This is useful in situations where a particular unit is known not to be needed
+for your package's portability targets, but your source files nevertheless
+contain occurrences of words that look to \fImetaconfig\fR like symbols defined
+in that unit. (For example, you might need the word "index" in a source file,
+but not need the unit that determines whether \fIstrcpy\fR or \fIindex\fR
+should be used.)
+The \fIfile\fR can contain blank lines, comment lines introduced with '#', and
+lines containing a single symbol.
'''
''' T u t o r i a l
'''
diff --git a/mcon/mconfig.SH b/mcon/mconfig.SH
index c9c295f..7f89325 100755
--- a/mcon/mconfig.SH
+++ b/mcon/mconfig.SH
@@ -68,8 +68,10 @@ chop($date = `date`);
&profile; # Read ~/.dist_profile
use Getopt::Std;
-&usage unless getopts("dhkmostvwGMVL:");
+&usage unless getopts("dhkmostvwGMVL:X:");
+my %excluded_symbol;
+read_exclusions($opt_X) if defined $opt_X;
$MC = $opt_L if $opt_L; # May override public library path
$MC = &tilda_expand($MC); # ~name expansion
chop($WD = `pwd`); # Working directory
@@ -164,6 +166,7 @@ Usage: metaconfig [-dhkmostvwGMV] [-L dir]
-L : specify main units repository.
-M : activate production of confmagic.h.
-V : print version number and exits.
+ -X FILE : read symbol exclusions from FILE
EOH
exit 1;
}
diff --git a/mcon/pl/depend.pl b/mcon/pl/depend.pl
index fc88f1a..e31eded 100644
--- a/mcon/pl/depend.pl
+++ b/mcon/pl/depend.pl
@@ -52,6 +52,9 @@ sub p_wanted {
$cmaster{$_} = undef; # Asks for look-up in C files
$cwanted{$_} = "$active" if $active; # Shell symbols to activate
}
+
+ delete @cmaster{keys %excluded_symbol};
+ delete @cwanted{keys %excluded_symbol};
}
# Process the ?INIT: lines
diff --git a/mcon/pl/wanted.pl b/mcon/pl/wanted.pl
index 20d218c..6a44039 100644
--- a/mcon/pl/wanted.pl
+++ b/mcon/pl/wanted.pl
@@ -39,6 +39,25 @@
;#
;# The manifake() routine has to be provided externally.
;#
+sub read_exclusions {
+ my ($filename) = @_;
+ print "Reading exclusions from $filename...\n" unless $opt_s;
+ open(EXCLUSIONS, "< $filename\0") || die "Can't read $filename: $!\n";
+ local $_;
+ while (<EXCLUSIONS>) {
+ if (/^\s*#|^\s*$/) {
+ # comment or blank line, ignore
+ }
+ elsif (/^\s*(\w+)\s*$/) {
+ $excluded_symbol{$1} = 1;
+ }
+ else {
+ die "$filename:$.: unrecognised line\n";
+ }
+ }
+ close(EXCLUSIONS) || die "Can't close $filename: $!\n";
+}
+
# Build a wanted file from the files held in @SHlist and @clist arrays
sub build_wanted {
# If wanted file is already there, parse it to map obsolete if -o option