Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 8d845d9fec753ecdb61ad65787eaf8ec7a311eb0
      
https://github.com/Perl/perl5/commit/8d845d9fec753ecdb61ad65787eaf8ec7a311eb0
  Author: Bram <perl...@wizbit.be>
  Date:   2022-09-05 (Mon, 05 Sep 2022)

  Changed paths:
    M win32/GNUmakefile
    M win32/Makefile

  Log Message:
  -----------
  win32: use tmp file when creating config.sh

When `config_sh.PL` failed then it created an empty '..\config.sh' file.
This is unwanted since if make is then re-run it detects a '..\config.sh'
file and skips the target which leads to completely different errors.

After adding a `die "Foobar";` in win32/config_sh.PL:

        $ gmake INST_TOP=... CCHOME=...
        ...
        ..\miniperl.exe -I..\lib config_sh.PL ... > ..\config.sh
        Foobar at config_sh.PL line 5.
        gmake: *** [GNUmakefile:1175: ..\config.sh] Error 255

Re-running the make command:

        $ gmake INST_TOP=... CCHOME=...
        ..\miniperl.exe -I..\lib ..\configpm --chdir=..
        Use of uninitialized value $t in string eq at ..\configpm line 345.
        ...
        written lib/Config.pod
        updated lib/Config.pm
        updated lib/Config_heavy.pl
        syntax error at lib/Config_heavy.pl line 165, near "x;"
        Compilation failed in require at ..\configpm line 1144.
        gmake: *** [GNUmakefile:1190: ..\lib\Config.pm] Error 255

When `gmake` was re-run it started with the '$(CONFIGPM)' target instead
of the '..\config.sh' target.

The fix: instead of creating '..\config.sh' it now first creates
         '..\config.sh.tmp' and then renames[^1] it to '..\config.sh'

Tested the GNUmakefile on Windows 10 using GNU Make v4.2.1,
I did *not* test the Makefile (no nmake installed).

[^1]: `rename` on windows only takes a path in the first argument.
      That is: `rename ..\config.sh.tmp config.sh` can be considered
      the same as `move ..\config.sh.tmp ..\config.sh`.


Reply via email to