I noticed that if I Ctrl-C while makedep is re-generating the Makefile, the Makefile will be gone.
There are two parts to this problem:
1. make deletes the output file if a rule is interrupted. - Solution: use the special .PRECIOUS target. 2. wine_fn_output_makefile overwrites the existing Makefile, because makedep is hardcoded to use the output makefile as its input. - Solution: add a -i command line options to makedep for specifying the input file name, then don't overwrite Makefile in wine_fn_output_makefile.
-- v2: configure: Don't nuke Makefile if makedep is interrupted.
From: Yuxuan Shui yshui@codeweavers.com
I noticed that if I Ctrl-C while makedep is re-generating the Makefile, the Makefile will be gone.
There are two parts to this problem:
1. make deletes the output file if a rule is interrupted. - Solution: use the special .PRECIOUS target. 2. wine_fn_output_makefile overwrites the existing Makefile, because makedep is hardcoded to use the output makefile as its input. - Solution: add a -i command line options to makedep for specifying the input file name, then don't overwrite Makefile in wine_fn_output_makefile. --- configure | 2 +- configure.ac | 2 +- tools/makedep.c | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/configure b/configure index fa1d207edff..59f29ed2ddf 100755 --- a/configure +++ b/configure @@ -24116,7 +24116,7 @@ wine_fn_output_makedep () } wine_fn_output_makefile () { - cat <<_WINE_EOF >$tmp/makefile && mv -f $tmp/makefile $1 && "$wine_makedep"$makedep_flags && return + cat <<_WINE_EOF >$tmp/makefile && "$wine_makedep"$makedep_flags -i$tmp/makefile && return # This Makefile understands the following targets: # # all (default): build wine diff --git a/configure.ac b/configure.ac index 79513e7b8d4..cb32298826e 100644 --- a/configure.ac +++ b/configure.ac @@ -3656,7 +3656,7 @@ fi AC_CONFIG_COMMANDS([Makefile], [wine_fn_output_makefile Makefile], [wine_fn_output_makefile () { - cat <<_WINE_EOF >$tmp/makefile && mv -f $tmp/makefile $[]1 && "$wine_makedep"$makedep_flags && return + cat <<_WINE_EOF >$tmp/makefile && "$wine_makedep"$makedep_flags -i$tmp/makefile && return # This Makefile understands the following targets: # # all (default): build wine diff --git a/tools/makedep.c b/tools/makedep.c index d7316cb2ae7..dd6107a90d1 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -239,6 +239,7 @@ static struct makefile **submakes;
static const char separator[] = "### Dependencies"; static const char *output_makefile_name = "Makefile"; +static const char *input_makefile_name; static const char *input_file_name; static const char *output_file_name; static const char *temp_file_name; @@ -1697,6 +1698,8 @@ static FILE *open_input_makefile( const struct makefile *make )
if (make->obj_dir) input_file_name = root_src_dir_path( obj_dir_path( make, "Makefile.in" )); + else if (input_makefile_name) + input_file_name = input_makefile_name; else input_file_name = output_makefile_name; /* always use output name for main Makefile */
@@ -3847,6 +3850,7 @@ static void output_subdirs( struct makefile *make ) output( "all:" ); output_filenames( all_targets ); output( "\n" ); + output( ".PRECIOUS: Makefile\n" ); output( "Makefile:" ); output_filenames( makefile_deps ); output( "\n" ); @@ -4599,6 +4603,9 @@ static int parse_option( const char *opt ) case 'f': if (opt[2]) output_makefile_name = opt + 2; break; + case 'i': + if (opt[2]) input_makefile_name = opt + 2; + break; case 'C': compile_commands_mode = 1; break;