summaryrefslogtreecommitdiffstats
path: root/util/dofile.pl
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2016-01-25 21:19:59 +0100
committerRichard Levitte <levitte@openssl.org>2016-01-25 21:19:59 +0100
commit9ab6fc5936be62f6fee1c433938eae4c89aa23da (patch)
tree0f0177f9d404741116b0c65c157db32c10410a35 /util/dofile.pl
parent52cdc9970de5f0e884d829d8dfa23c89c51527f9 (diff)
Generate warning text
Now that we're using templates, we should warn people not to edit the resulting file. We do it through util/dofile.pl, which is enhanced with an option to tell what file it was called from. We also change the calls so the template files are on the command line instead of being redirected through standard input. That way, we can display something like this (example taken from include/openssl/opensslconf.h): /* WARNING: do not edit! */ /* Generated by Configure from include/openssl/opensslconf.h.in */ Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'util/dofile.pl')
-rw-r--r--util/dofile.pl16
1 files changed, 16 insertions, 0 deletions
diff --git a/util/dofile.pl b/util/dofile.pl
index a6b0905a58..780759b97c 100644
--- a/util/dofile.pl
+++ b/util/dofile.pl
@@ -8,6 +8,8 @@
use strict;
use warnings;
+use Getopt::Std;
+
# Because we know that Text::Template isn't a core Perl module, we use
# a fallback in case it's not installed on the system
use File::Basename;
@@ -74,6 +76,19 @@ sub broken {
undef;
}
+# Check options ######################################################
+
+my %opts = ();
+
+# -o ORIGINATOR
+# declares ORIGINATOR as the originating script.
+getopt('o', \%opts);
+
+my @autowarntext = ("WARNING: do not edit!",
+ "Generated"
+ . (defined($opts{o}) ? " by ".$opts{o} : "")
+ . (scalar(@ARGV) > 0 ? " from ".join(", ",@ARGV) : ""));
+
# Template reading ###################################################
# Read in all the templates into $text, while keeping track of each
@@ -100,6 +115,7 @@ $template->fill_in(OUTPUT => \*STDOUT,
HASH => { config => \%config,
target => \%target,
withargs => \%withargs,
+ autowarntext => \@autowarntext,
quotify1 => \&quotify1,
quotify_l => \&quotify_l },
DELIMITERS => [ "{-", "-}" ],