Alexandre Julliard : makefiles: Avoid running config.status when not necessary.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Oct 23 09:57:28 CDT 2015


Module: wine
Branch: master
Commit: e0b1e8154dccd8a238a7cf6afb8e96520248ebd7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e0b1e8154dccd8a238a7cf6afb8e96520248ebd7

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Oct 23 17:42:44 2015 +0900

makefiles: Avoid running config.status when not necessary.

If it doesn't contain substitutions, we can use Makefile.in directly.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 aclocal.m4           | 17 ++++++++++++++---
 configure            | 23 +++++++++++++++++------
 configure.ac         |  6 +++---
 tools/make_makefiles |  4 ++++
 tools/makedep.c      | 48 +++++++++++++++++++++++++++++++++++++++---------
 5 files changed, 77 insertions(+), 21 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index 13bab9b..e236c92 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -225,13 +225,24 @@ wine_fn_has_flag ()
 
 wine_fn_depend_rules ()
 {
-    wine_fn_append_rule \
+    if wine_fn_has_flag config
+    then
+        wine_fn_append_rule \
 "$ac_dir/Makefile: $srcdir/$ac_dir/Makefile.in Makefile config.status \$(MAKEDEP)
-	@./config.status --file $ac_dir/Makefile && \$(MAKEDEP) $ac_dir
+	@./config.status --file $ac_dir/Makefile && \$(MAKEDEP) -iMakefile $ac_dir
 depend: $ac_dir/depend
 .PHONY: $ac_dir/depend
 $ac_dir/depend: \$(MAKEDEP) dummy
-	@./config.status --file $ac_dir/Makefile && \$(MAKEDEP) $ac_dir"
+	@./config.status --file $ac_dir/Makefile && \$(MAKEDEP) -iMakefile $ac_dir"
+    else
+        wine_fn_append_rule \
+"$ac_dir/Makefile: $srcdir/$ac_dir/Makefile.in Makefile \$(MAKEDEP)
+	\$(MAKEDEP) $ac_dir
+depend: $ac_dir/depend
+.PHONY: $ac_dir/depend
+$ac_dir/depend: \$(MAKEDEP) dummy
+	\$(MAKEDEP) $ac_dir"
+    fi
 }
 
 wine_fn_pot_rules ()
diff --git a/configure b/configure
index 38c3c6c..8d17086 100755
--- a/configure
+++ b/configure
@@ -7389,13 +7389,24 @@ wine_fn_has_flag ()
 
 wine_fn_depend_rules ()
 {
-    wine_fn_append_rule \
+    if wine_fn_has_flag config
+    then
+        wine_fn_append_rule \
 "$ac_dir/Makefile: $srcdir/$ac_dir/Makefile.in Makefile config.status \$(MAKEDEP)
-	@./config.status --file $ac_dir/Makefile && \$(MAKEDEP) $ac_dir
+	@./config.status --file $ac_dir/Makefile && \$(MAKEDEP) -iMakefile $ac_dir
 depend: $ac_dir/depend
 .PHONY: $ac_dir/depend
 $ac_dir/depend: \$(MAKEDEP) dummy
-	@./config.status --file $ac_dir/Makefile && \$(MAKEDEP) $ac_dir"
+	@./config.status --file $ac_dir/Makefile && \$(MAKEDEP) -iMakefile $ac_dir"
+    else
+        wine_fn_append_rule \
+"$ac_dir/Makefile: $srcdir/$ac_dir/Makefile.in Makefile \$(MAKEDEP)
+	\$(MAKEDEP) $ac_dir
+depend: $ac_dir/depend
+.PHONY: $ac_dir/depend
+$ac_dir/depend: \$(MAKEDEP) dummy
+	\$(MAKEDEP) $ac_dir"
+    fi
 }
 
 wine_fn_pot_rules ()
@@ -18010,9 +18021,9 @@ wine_fn_config_makefile documentation enable_documentation clean
 wine_fn_config_makefile fonts enable_fonts clean,install-lib
 wine_fn_config_makefile include enable_include clean,install-dev
 wine_fn_config_makefile libs/port enable_libs_port
-wine_fn_config_makefile libs/wine enable_libs_wine clean,install-dev,install-lib
+wine_fn_config_makefile libs/wine enable_libs_wine clean,config,install-dev,install-lib
 wine_fn_config_makefile libs/wpp enable_libs_wpp
-wine_fn_config_makefile loader enable_loader clean,install-lib,manpage
+wine_fn_config_makefile loader enable_loader clean,config,install-lib,manpage
 wine_fn_config_program arp enable_arp install
 wine_fn_config_program aspnet_regiis enable_aspnet_regiis install
 wine_fn_config_program attrib enable_attrib install,po
@@ -18090,7 +18101,7 @@ wine_fn_config_program winemenubuilder enable_winemenubuilder install
 wine_fn_config_program winemine enable_winemine install,installbin,manpage,po
 wine_fn_config_program winemsibuilder enable_winemsibuilder install
 wine_fn_config_program winepath enable_winepath install,installbin,manpage
-wine_fn_config_program winetest enable_winetest clean
+wine_fn_config_program winetest enable_winetest clean,config
 wine_fn_config_program winevdm enable_win16 install
 wine_fn_config_program winhelp.exe16 enable_win16 install
 wine_fn_config_program winhlp32 enable_winhlp32 install,po
diff --git a/configure.ac b/configure.ac
index 88efdc9..bfcf319 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3494,9 +3494,9 @@ WINE_CONFIG_MAKEFILE([documentation],,[clean])
 WINE_CONFIG_MAKEFILE([fonts],,[clean,install-lib])
 WINE_CONFIG_MAKEFILE([include],,[clean,install-dev])
 WINE_CONFIG_MAKEFILE([libs/port])
-WINE_CONFIG_MAKEFILE([libs/wine],,[clean,install-dev,install-lib])
+WINE_CONFIG_MAKEFILE([libs/wine],,[clean,config,install-dev,install-lib])
 WINE_CONFIG_MAKEFILE([libs/wpp])
-WINE_CONFIG_MAKEFILE([loader],,[clean,install-lib,manpage])
+WINE_CONFIG_MAKEFILE([loader],,[clean,config,install-lib,manpage])
 WINE_CONFIG_PROGRAM(arp,,[install])
 WINE_CONFIG_PROGRAM(aspnet_regiis,,[install])
 WINE_CONFIG_PROGRAM(attrib,,[install,po])
@@ -3574,7 +3574,7 @@ WINE_CONFIG_PROGRAM(winemenubuilder,,[install])
 WINE_CONFIG_PROGRAM(winemine,,[install,installbin,manpage,po])
 WINE_CONFIG_PROGRAM(winemsibuilder,,[install])
 WINE_CONFIG_PROGRAM(winepath,,[install,installbin,manpage])
-WINE_CONFIG_PROGRAM(winetest,,[clean])
+WINE_CONFIG_PROGRAM(winetest,,[clean,config])
 WINE_CONFIG_PROGRAM(winevdm,enable_win16,[install])
 WINE_CONFIG_PROGRAM(winhelp.exe16,enable_win16,[install])
 WINE_CONFIG_PROGRAM(winhlp32,,[install,po])
diff --git a/tools/make_makefiles b/tools/make_makefiles
index f0b40c0..266f33a 100755
--- a/tools/make_makefiles
+++ b/tools/make_makefiles
@@ -282,6 +282,10 @@ sub parse_makefile($)
         {
             die "Variable $1 in $file.in is obsolete";
         }
+        if (/\@[A-Z_]+\@/)  # config.status substitution variable
+        {
+            ${$make{"=flags"}}{"config"} = 1;
+        }
     }
 
     if ($file =~ /^programs\/([^\/]+)\/Makefile/)
diff --git a/tools/makedep.c b/tools/makedep.c
index 104711e..c81a57e 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -171,7 +171,8 @@ struct makefile
 
 static struct makefile *top_makefile;
 
-static const char *makefile_name = "Makefile";
+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;
@@ -184,7 +185,8 @@ static const char Usage[] =
     "Usage: makedep [options] directories\n"
     "Options:\n"
     "   -R from to  Compute the relative path between two directories\n"
-    "   -fxxx       Store output in file 'xxx' (default: Makefile)\n";
+    "   -fxxx       Store output in file 'xxx' (default: Makefile)\n"
+    "   -ixxx       Read input from file 'xxx' (default: Makefile.in)\n";
 
 
 #ifndef __GNUC__
@@ -1460,6 +1462,28 @@ static struct incl_file *add_src_file( struct makefile *make, const char *name )
 
 
 /*******************************************************************
+ *         open_input_makefile
+ */
+static FILE *open_input_makefile( struct makefile *make )
+{
+    FILE *ret;
+
+    if (make->base_dir)
+        input_file_name = base_dir_path( make, input_makefile_name );
+    else
+        input_file_name = output_makefile_name;  /* always use output name for main Makefile */
+
+    input_line = 0;
+    if (!(ret = fopen( input_file_name, "r" )))
+    {
+        input_file_name = root_dir_path( input_file_name );
+        if (!(ret = fopen( input_file_name, "r" ))) fatal_perror( "open" );
+    }
+    return ret;
+}
+
+
+/*******************************************************************
  *         get_make_variable
  */
 static char *get_make_variable( struct makefile *make, const char *name )
@@ -1578,10 +1602,7 @@ static struct makefile *parse_makefile( const char *path, const char *separator
         if (!strcmp( make->base_dir, "." )) make->base_dir = NULL;
     }
 
-    input_file_name = base_dir_path( make, makefile_name );
-    if (!(file = fopen( input_file_name, "r" ))) fatal_perror( "open" );
-
-    input_line = 0;
+    file = open_input_makefile( make );
     while ((buffer = get_line( file )))
     {
         if (separator && !strncmp( buffer, separator, strlen(separator) )) break;
@@ -2538,15 +2559,16 @@ static void output_dependencies( struct makefile *make )
     char buffer[1024];
     FILE *src_file;
 
-    output_file_name = base_dir_path( make, makefile_name );
+    output_file_name = base_dir_path( make, output_makefile_name );
     output_file = create_temp_file( output_file_name );
     output_top_variables( make );
 
     /* copy the contents of the source makefile */
-    if (!(src_file = fopen( output_file_name, "r" ))) fatal_perror( "open" );
+    src_file = open_input_makefile( make );
     while (fgets( buffer, sizeof(buffer), src_file ))
         if (fwrite( buffer, 1, strlen(buffer), output_file ) != strlen(buffer)) fatal_perror( "write" );
     if (fclose( src_file )) fatal_perror( "close" );
+    input_file_name = NULL;
 
     targets = output_sources( make, &testlist_files );
 
@@ -2640,6 +2662,9 @@ static void update_makefile( const char *path )
     list_init( &make->sources );
     list_init( &make->includes );
 
+    /* FIXME: target dir has to exist to allow locating srcdir-relative include files */
+    if (make->base_dir) create_dir( make->base_dir );
+
     for (var = source_vars; *var; var++)
     {
         value = get_expanded_make_var_array( make, *var );
@@ -2700,7 +2725,10 @@ static int parse_option( const char *opt )
     switch(opt[1])
     {
     case 'f':
-        if (opt[2]) makefile_name = opt + 2;
+        if (opt[2]) output_makefile_name = opt + 2;
+        break;
+    case 'i':
+        if (opt[2]) input_makefile_name = opt + 2;
         break;
     case 'R':
         relative_dir_mode = 1;
@@ -2762,6 +2790,8 @@ int main( int argc, char *argv[] )
 
     for (i = 0; i < HASH_SIZE; i++) list_init( &files[i] );
 
+    if (!input_makefile_name) input_makefile_name = strmake( "%s.in", output_makefile_name );
+
     top_makefile = parse_makefile( NULL, "# End of common header" );
 
     linguas      = get_expanded_make_var_array( top_makefile, "LINGUAS" );




More information about the wine-cvs mailing list