Windows: fix echo for nmake
authorRichard Levitte <levitte@openssl.org>
Tue, 10 Jul 2018 12:12:33 +0000 (14:12 +0200)
committerRichard Levitte <levitte@openssl.org>
Wed, 11 Jul 2018 12:53:54 +0000 (14:53 +0200)
It seems that nmake first tries to run executables on its own, and
only pass commands to cmd if that fails.  That means it's possible to
have nmake run something like 'echo.exe' when the builtin 'echo'
command was expected, which might give us unexpected results.

To get around this, we create our own echoing script and call it
explicitly from the nmake makefile.

Fixes #6670

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/6686)

(cherry picked from commit 9abce88b4b0055d6238a838aa00360152e185f02)

Configurations/windows-makefile.tmpl
util/echo.pl [new file with mode: 0644]

index bd9868bd53f05ce7f1e1857f2c1e79e0027c25e6..4773f796d493c60ebc5ac8fa7dca71d8aefdf0a3 100644 (file)
@@ -182,6 +182,9 @@ MTOUTFLAG={- $target{mtoutflag} || "-outputresource:" -}$(OSSL_EMPTY)
 AS={- $target{as} -}
 ASFLAGS={- $target{asflags} -}
 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
+
+ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
+
 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
 
 PROCESSOR= {- $config{processor} -}
@@ -217,7 +220,7 @@ test: tests
        set OPENSSL_DEBUG_MEMORY=on
        "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
        @rem {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
-       @echo "Tests are not supported with your chosen Configure options"
+       @$(ECHO) "Tests are not supported with your chosen Configure options"
        @rem {- output_on() if !$disabled{tests}; "" -}
 
 list-tests:
@@ -225,7 +228,7 @@ list-tests:
        @set SRCTOP=$(SRCDIR)
        @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
        @rem {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
-       @echo "Tests are not supported with your chosen Configure options"
+       @$(ECHO) "Tests are not supported with your chosen Configure options"
        @rem {- output_on() if !$disabled{tests}; "" -}
 
 install: install_sw install_ssldirs install_docs
@@ -285,8 +288,8 @@ install_ssldirs:
                                         "$(OPENSSLDIR)\misc"
 
 install_dev:
-       @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
-       @echo *** Installing development files
+       @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
+       @$(ECHO) "*** Installing development files"
        @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
        @rem {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
        @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
@@ -307,8 +310,8 @@ install_dev:
 uninstall_dev:
 
 install_engines:
-       @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
-       @echo *** Installing engines
+       @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
+       @$(ECHO) "*** Installing engines"
        @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
        @if not "$(ENGINES)"=="" \
         "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
@@ -318,8 +321,8 @@ install_engines:
 uninstall_engines:
 
 install_runtime:
-       @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
-       @echo *** Installing runtime files
+       @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
+       @$(ECHO) "*** Installing runtime files"
        @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
        @if not "$(SHLIBS)"=="" \
         "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
@@ -344,14 +347,14 @@ uninstall_html_docs:
 # Building targets ###################################################
 
 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
-       @echo "Detected changed: $?"
-       @echo "Reconfiguring..."
+       @$(ECHO) "Detected changed: $?"
+       @$(ECHO) "Reconfiguring..."
        "$(PERL)" "$(SRCDIR)\Configure" reconf
-       @echo "**************************************************"
-       @echo "***                                            ***"
-       @echo "***   Please run the same make command again   ***"
-       @echo "***                                            ***"
-       @echo "**************************************************"
+       @$(ECHO) "**************************************************"
+       @$(ECHO) "***                                            ***"
+       @$(ECHO) "***   Please run the same make command again   ***"
+       @$(ECHO) "***                                            ***"
+       @$(ECHO) "**************************************************"
        @exit 1
 
 {-
diff --git a/util/echo.pl b/util/echo.pl
new file mode 100644 (file)
index 0000000..d90e521
--- /dev/null
@@ -0,0 +1,12 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+use Getopt::Std;
+
+our $opt_n = 0;
+
+getopts('n') or die "Invalid option: $!\n";
+
+print join(' ', @ARGV);
+print "\n" unless $opt_n;