Generate warning text
authorRichard Levitte <levitte@openssl.org>
Mon, 25 Jan 2016 20:19:59 +0000 (21:19 +0100)
committerRichard Levitte <levitte@openssl.org>
Mon, 25 Jan 2016 20:19:59 +0000 (21:19 +0100)
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>
12 files changed:
Configure
Makefile.in
apps/CA.pl.in
apps/Makefile.in
crypto/include/internal/bf_conf.h.in
crypto/include/internal/bn_conf.h.in
crypto/include/internal/des_conf.h.in
crypto/include/internal/rc4_conf.h.in
include/openssl/opensslconf.h.in
tools/Makefile.in
tools/c_rehash.in
util/dofile.pl

index 2e88a731853818c658f3c643830a4b37036a0690..d5637401c47b95eabf6c2fb8653d9c1a800a3ac7 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -1752,7 +1752,7 @@ sub run_dofile()
     my $out = shift;
 
     # should we remove $out ?
-    system("$config{perl} -I. -Mconfigdata util/dofile.pl <$in >$out.new");
+    system("$config{perl} -I. -Mconfigdata util/dofile.pl -o\"Configure\" $in > $out.new");
     exit 1 if $? != 0;
     rename("$out.new", $out) || die "Can't rename $out.new, $!";
 }
index e875f43bdc22dc721217acfc3872e4c321514619..7db430d4bef4f838cc94dd8084e934ced2642ac3 100644 (file)
@@ -1,6 +1,7 @@
 ##
 ## Makefile for OpenSSL
 ##
+## {- join("\n## ", @autowarntext) -}
 
 VERSION={- $config{version} -}
 MAJOR={- $config{major} -}
index b54df5efa95ebb0c6ca982e872461ab576d3e7ad..52a97d7345034cb5b0b7ba0f8d3cf6209d9ddb81 100644 (file)
@@ -1,8 +1,8 @@
 #!{- $config{perl} -}
 #
 # Wrapper around the ca to make it easier to use
-# Edit CA.pl.in not CA.pl!
-
+#
+# {- join("\n# ", @autowarntext) -}
 
 use strict;
 use warnings;
index 290dff6ba5348dfe7353f14c2b92e54d907e04f2..8d2433b5c3d10aa09e21cea714047d7846a86ccd 100644 (file)
@@ -140,7 +140,7 @@ progs.h: progs.pl Makefile
        $(RM) openssl.o
 
 CA.pl: CA.pl.in
-       $(PERL) -I$(TOP) -Mconfigdata $(TOP)/util/dofile.pl < CA.pl.in > CA.pl.new
+       $(PERL) -I$(TOP) -Mconfigdata $(TOP)/util/dofile.pl -oapps/Makefile CA.pl.in > CA.pl.new
        mv CA.pl.new CA.pl
 
 
index 5b6e5e71909ce3be2124dd07ebd97a99deca816b..552faae98e072c921ab5cc3e22ffee48319ce89d 100644 (file)
@@ -1,3 +1,4 @@
+{- join("\n",map { "/* $_ */" } @autowarntext) -}
 /* ====================================================================
  * Copyright (c) 2016 The OpenSSL Project.  All rights reserved.
  *
index a75e964300972cb064ce61c21c03926e108cdf4d..5ebd55d522ee6186fbd3cd937ee3e28729f44c65 100644 (file)
@@ -1,3 +1,4 @@
+{- join("\n",map { "/* $_ */" } @autowarntext) -}
 /* ====================================================================
  * Copyright (c) 2016 The OpenSSL Project.  All rights reserved.
  *
index 43ab5eb99c3992264f8ccad6b72a816f09a54b1b..2c4369bd78af343a1705d4d20a02fce8dc7055f4 100644 (file)
@@ -1,3 +1,4 @@
+{- join("\n",map { "/* $_ */" } @autowarntext) -}
 /* ====================================================================
  * Copyright (c) 2016 The OpenSSL Project.  All rights reserved.
  *
index 5f23357fbf97ab0e779f2e49e09a3ef7be00501e..b5b2bd3fc0a05f232fb32af9c8a44aa0ebeaf04f 100644 (file)
@@ -1,3 +1,4 @@
+{- join("\n",map { "/* $_ */" } @autowarntext) -}
 /* ====================================================================
  * Copyright (c) 2016 The OpenSSL Project.  All rights reserved.
  *
index 3d7137e8f619892e0cd31c2cd6f9cee22caabaee..f54043acddbaf0a05138e5da68bb7ec03235b1e5 100644 (file)
@@ -1,5 +1,5 @@
 /* opensslconf.h */
-/* WARNING: Generated automatically from opensslconf.h.in by Configure. */
+{- join("\n",map { "/* $_ */" } @autowarntext) -}
 
 #ifdef  __cplusplus
 extern "C" {
index b52b45f7d3b8c62c752a81425a53cf8ddd81bf56..d0c5ca26620e03be70dd8a6ae09b2e4282d9889a 100644 (file)
@@ -59,7 +59,7 @@ clean:
 errors:
 
 c_rehash: c_rehash.in
-       $(PERL) -I$(TOP) -Mconfigdata $(TOP)/util/dofile.pl < c_rehash.in > c_rehash.new
+       $(PERL) -I$(TOP) -Mconfigdata $(TOP)/util/dofile.pl -otools/Makefile c_rehash.in > c_rehash.new
        mv c_rehash.new c_rehash
 
 # DO NOT DELETE THIS LINE -- make depend depends on it.
index 912618c2300e10422f369bb24e6286b64496e0c3..dc66a9d9625872a2eeb28ad364f2af5546721b84 100644 (file)
@@ -1,5 +1,7 @@
 #!{- $config{perl} -}
 
+# {- join("\n# ", @autowarntext) -}
+
 # Perl c_rehash script, scan all files in a directory
 # and add symbolic links to their hash values.
 
index a6b0905a58ab9d4cab7b889f9764f1d61f627653..780759b97c455a13de3f555922944a6ddf930731 100644 (file)
@@ -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 => [ "{-", "-}" ],