From: Tanzinul Islam Date: Thu, 10 Dec 2020 14:53:07 +0000 (+0000) Subject: Generate dependency information X-Git-Tag: openssl-3.0.0-alpha15~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=16f2a44435fccbd7466b0659220c765a17e5d0c0;p=thirdparty%2Fopenssl.git Generate dependency information The Clang-based `bcc32c.exe` doesn't implement the `-Hp` option, so we have to use [`cpp32.exe`][1] instead. Therefore, change the dependency- emitting command to use `$(CPP)` instead of `$(CC)`, which which also uncovered the [existing bug of `2>&1` before `> $dep`][2]. Also C++Builder's `make.exe` doesn't implement `2>&1` in its command runner, so wrap the whole line in a `cmd /C`. [1]: http://docwiki.embarcadero.com/RADStudio/Sydney/en/CPP32.EXE,_the_C_Compiler_Preprocessor [2]: https://ss64.com/nt/syntax-redirection.html Reviewed-by: Richard Levitte Reviewed-by: Dmitry Belyavskiy (Merged from https://github.com/openssl/openssl/pull/13540) --- diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf index 4d42c7fae81..f5e5754b3a6 100644 --- a/Configurations/10-main.conf +++ b/Configurations/10-main.conf @@ -1275,9 +1275,10 @@ my %targets = ( inherit_from => [ "BASE_Windows" ], template => 1, CC => "cl", - CPP => '$(CC) /EP /C', + CPP => '"$(CC)" /EP /C', CFLAGS => "/W3 /wd4090 /nologo", coutflag => "/Fo", + cpp_depend_flags => "/Zs /showIncludes", LD => "link", LDFLAGS => "/nologo /debug", ldoutflag => "/out:", diff --git a/Configurations/50-cppbuilder.conf b/Configurations/50-cppbuilder.conf index 40b89b403ee..7ca972956a4 100644 --- a/Configurations/50-cppbuilder.conf +++ b/Configurations/50-cppbuilder.conf @@ -5,6 +5,7 @@ my %targets = ( bn_ops => "BN_LLONG", thread_scheme => "winthreads", cc => "bcc32c", + CPP => "cpp32 -oCON -Sc -Sr", defines => add("WIN32_LEAN_AND_MEAN", "OPENSSL_SYS_WIN32", "L_ENDIAN", "DSO_WIN32", "_stricmp=stricmp", "_strnicmp=strnicmp", "_malloca=malloc", @@ -17,6 +18,7 @@ my %targets = ( bin_cflags => "-tWC", lib_cflags => shared("-tWD -D_WINDLL -D_DLL"), coutflag => "-o", + cpp_depend_flags => "-Hp", LD => "ilink32", LDFLAGS => picker(default => "-ap -x -Gn -q", debug => '-j"$(BDS)\lib\win32c\debug" ' . diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl index 521f72d7b7b..bcb092d045b 100644 --- a/Configurations/windows-makefile.tmpl +++ b/Configurations/windows-makefile.tmpl @@ -226,7 +226,7 @@ libdir={- file_name_is_absolute($libdir) ##### User defined commands and flags ################################ CC="{- $config{CC} -}" -CPP="{- $config{CPP} -}" +CPP={- $config{CPP} -} CPPFLAGS={- our $cppflags1 = join(" ", (map { "-D".$_} @{$config{CPPDEFINES}}), (map { " -I".$_} @{$config{CPPINCLUDES}}), @@ -836,7 +836,7 @@ $obj: $deps \$(CC) $cflags $defs -c \$(COUTFLAG)\$\@ $srcs EOF $recipe .= <<"EOF" unless $disabled{makedepend}; - \$(CC) $cflags $defs /Zs /showIncludes $srcs 2>&1 > $dep + cmd /C "\$(CPP) $cflags $defs $target{cpp_depend_flags} $srcs > $dep 2>&1" EOF return $recipe; } diff --git a/Configure b/Configure index e36c5d93aaa..76c27bacb8f 100755 --- a/Configure +++ b/Configure @@ -1533,10 +1533,10 @@ unless ($disabled{asm}) { # Check for makedepend capabilities. if (!$disabled{makedepend}) { - if ($config{target} =~ /^(VC|vms)-/) { - # For VC- and vms- targets, there's nothing more to do here. The + if ($config{target} =~ /^(VC|BC|vms)-/) { + # For VC-, BC- and vms- targets, there's nothing more to do here. The # functionality is hard coded in the corresponding build files for - # cl (Windows) and CC/DECC (VMS). + # cl/cpp32 (Windows) and CC/DECC (VMS). } elsif (($predefined_C{__GNUC__} // -1) >= 3 && !($predefined_C{__APPLE_CC__} && !$predefined_C{__clang__})) { # We know that GNU C version 3 and up as well as all clang diff --git a/util/add-depends.pl b/util/add-depends.pl index 1a87cdd3649..6fdc5e5ef48 100644 --- a/util/add-depends.pl +++ b/util/add-depends.pl @@ -161,8 +161,7 @@ my %procedures = ( }, 'VC' => sub { - # For the moment, we only support Visual C on native Windows, or - # compatible compilers. With those, the flags /Zs /showIncludes + # On Windows, with Microsoft Visual C the flags /Zs /showIncludes # give us the necessary output to be able to create dependencies # that nmake (or any 'make' implementation) should be able to read, # with a bit of help. The output we're interested in looks like @@ -170,6 +169,15 @@ my %procedures = ( # # Note: including file: {whatever header file} # + # With Embarcadero C++Builder's preprocessor (cpp32.exe) the -Hp + # flag gives us the preprocessed output annotated with the following + # note whenever a #include file is read: + # + # Including ->->{whatever header file} + # + # where each "->" indicates the nesting level of the #include. The + # logic here is otherwise the same as the 'VC' case. + # # Since there's no object file name at all in that information, # we must construct it ourselves. @@ -180,13 +188,14 @@ my %procedures = ( # warnings, so we simply discard anything that doesn't start with # the Note: - if (/^Note: including file: */) { + if (/^Note: including file: */ or /^Including (->)*/) { (my $tail = $') =~ s/\s*\R$//; # VC gives us absolute paths for all include files, so to # remove system header dependencies, we need to check that - # they don't match $abs_srcdir or $abs_blddir. - $tail = canonpath($tail); + # they don't match $abs_srcdir or $abs_blddir. C++Builder gives + # us relative paths when possible, so convert to absolute paths. + $tail = rel2abs($tail); unless (defined $depconv_cache{$tail}) { my $dep = $tail;