Windows: fix echo for nmake

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)
This commit is contained in:
Richard Levitte 2018-07-10 14:12:33 +02:00
parent c9ecb13191
commit 9abce88b4b
2 changed files with 31 additions and 17 deletions

View file

@ -186,6 +186,8 @@ ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
RC={- $config{RC} -} RC={- $config{RC} -}
ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
##### Special command flags ########################################## ##### Special command flags ##########################################
COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY) COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
@ -320,9 +322,9 @@ build_apps build_tests: build_programs
# ones # ones
build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
@rem {- output_off() if $disabled{makedepend}; "" -} @rem {- output_off() if $disabled{makedepend}; "" -}
@echo "Warning: consider configuring with no-makedepend, because if" @$(ECHO) "Warning: consider configuring with no-makedepend, because if"
@echo " target system doesn't have $(PERL)," @$(ECHO) " target system doesn't have $(PERL),"
@echo " then make will fail..." @$(ECHO) " then make will fail..."
@rem {- output_on() if $disabled{makedepend}; "" -} @rem {- output_on() if $disabled{makedepend}; "" -}
test: tests test: tests
@ -337,7 +339,7 @@ test: tests
set OPENSSL_DEBUG_MEMORY=on set OPENSSL_DEBUG_MEMORY=on
"$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS) "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
@rem {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -} @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}; "" -} @rem {- output_on() if !$disabled{tests}; "" -}
list-tests: list-tests:
@ -345,7 +347,7 @@ list-tests:
@set SRCTOP=$(SRCDIR) @set SRCTOP=$(SRCDIR)
@"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
@rem {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -} @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}; "" -} @rem {- output_on() if !$disabled{tests}; "" -}
install: install_sw install_ssldirs install_docs install: install_sw install_ssldirs install_docs
@ -405,8 +407,8 @@ install_ssldirs:
"$(OPENSSLDIR)\ct_log_list.cnf" "$(OPENSSLDIR)\ct_log_list.cnf"
install_dev: install_dev:
@if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 ) @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
@echo *** Installing development files @$(ECHO) "*** Installing development files"
@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl" @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
@rem {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$config{defines}}; "" -} @rem {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$config{defines}}; "" -}
@"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \ @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
@ -425,8 +427,8 @@ install_dev:
uninstall_dev: uninstall_dev:
install_engines: install_engines:
@if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 ) @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
@echo *** Installing engines @$(ECHO) "*** Installing engines"
@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)" @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
@if not "$(ENGINES)"=="" \ @if not "$(ENGINES)"=="" \
"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)" "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
@ -436,8 +438,8 @@ install_engines:
uninstall_engines: uninstall_engines:
install_runtime: install_runtime:
@if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 ) @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
@echo *** Installing runtime files @$(ECHO) "*** Installing runtime files"
@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin" @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
@if not "$(SHLIBS)"=="" \ @if not "$(SHLIBS)"=="" \
"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin" "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
@ -462,13 +464,13 @@ uninstall_html_docs:
# Building targets ################################################### # Building targets ###################################################
configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -} configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
@echo "Detected changed: $?" @$(ECHO) "Detected changed: $?"
"$(PERL)" configdata.pm -r "$(PERL)" configdata.pm -r
@echo "**************************************************" @$(ECHO) "**************************************************"
@echo "*** ***" @$(ECHO) "*** ***"
@echo "*** Please run the same make command again ***" @$(ECHO) "*** Please run the same make command again ***"
@echo "*** ***" @$(ECHO) "*** ***"
@echo "**************************************************" @$(ECHO) "**************************************************"
@exit 1 @exit 1
reconfigure reconf: reconfigure reconf:

12
util/echo.pl Normal file
View file

@ -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;