[PATCH resend 1/5] makedep: Add build framework for building DLLs in test directories.

Zebediah Figura z.figura12 at gmail.com
Fri Nov 24 10:36:52 CST 2017


From: Sebastian Lackner <sebastian at fds-team.de>

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
Patch resent with configure changes.

Changes from staging version:

* use .cross.res extension for cross-compiled resource
* use replace_extension() instead of defining a new function
* use phony targets in the tests makefile so that the custom DLL is always
  built
* enforce directory name the same way we do for other targets

 aclocal.m4           |  25 +++++++++
 configure            |  18 +++++++
 tools/make_makefiles |  11 +++-
 tools/makedep.c      | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 193 insertions(+), 3 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index 9364188..a711b20 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -540,6 +540,22 @@ $ac_dir/crosstest: __builddeps__ dummy
         fi
 }
 
+wine_fn_config_resource ()
+{
+    ac_dir=$[1]
+    ac_name=$[2]
+    ac_flags=$[3]
+
+    ac_clean=
+    test -n "$CROSSTARGET" && ac_clean=`expr $ac_dir/$ac_name : "\\(.*\\)\\."`_crossres.`expr $ac_name : ".*\\.\\(.*\\)"`
+    test -n "$DLLEXT" || ac_clean="$ac_dir/$ac_name"
+
+    AS_VAR_IF([enable_tests],[no],[wine_fn_disabled_rules $ac_clean; return])
+
+    wine_fn_append_file SUBDIRS $ac_dir
+    wine_fn_clean_rules $ac_clean
+}
+
 wine_fn_config_tool ()
 {
     ac_dir=$[1]
@@ -643,6 +659,15 @@ wine_fn_config_test $1 ac_name[]ac_suffix [$2]dnl
 m4_popdef([ac_suffix])dnl
 m4_popdef([ac_name])])
 
+dnl **** Create a test resource makefile from config.status ****
+dnl
+dnl Usage: WINE_CONFIG_RESOURCE(dir,flags)
+dnl
+AC_DEFUN([WINE_CONFIG_RESOURCE],[AC_REQUIRE([WINE_CONFIG_HELPERS])dnl
+m4_pushdef([ac_name],[m4_bpatsubst([$1],[.*/\([^/\]*\)$],[\1])])dnl
+wine_fn_config_resource $1 ac_name [$2]dnl
+m4_popdef([ac_name])])
+
 dnl **** Create a static lib makefile from config.status ****
 dnl
 dnl Usage: WINE_CONFIG_LIB(name,flags)
diff --git a/configure b/configure
index 83f9b30..8ad89bd 100755
--- a/configure
+++ b/configure
@@ -8036,6 +8036,24 @@ $ac_dir/crosstest: __builddeps__ dummy
         fi
 }
 
+wine_fn_config_resource ()
+{
+    ac_dir=$1
+    ac_name=$2
+    ac_flags=$3
+
+    ac_clean=
+    test -n "$CROSSTARGET" && ac_clean=`expr $ac_dir/$ac_name : "\\(.*\\)\\."`_crossres.`expr $ac_name : ".*\\.\\(.*\\)"`
+    test -n "$DLLEXT" || ac_clean="$ac_dir/$ac_name"
+
+    if test "x$enable_tests" = xno; then :
+  wine_fn_disabled_rules $ac_clean; return
+fi
+
+    wine_fn_append_file SUBDIRS $ac_dir
+    wine_fn_clean_rules $ac_clean
+}
+
 wine_fn_config_tool ()
 {
     ac_dir=$1
diff --git a/tools/make_makefiles b/tools/make_makefiles
index f57a7e2..44f0fc2 100755
--- a/tools/make_makefiles
+++ b/tools/make_makefiles
@@ -224,7 +224,7 @@ sub parse_makefile($)
         {
             die "Configure substitution is not allowed in $file" unless $file eq "Makefile";
         }
-        if (/^\s*(MODULE|IMPORTLIB|TESTDLL|PARENTSRC|APPMODE)\s*=\s*(.*)/)
+        if (/^\s*(MODULE|IMPORTLIB|TESTDLL|RESOURCE|PARENTSRC|APPMODE)\s*=\s*(.*)/)
         {
             my $var = $1;
             $make{$var} = $2;
@@ -466,6 +466,15 @@ sub update_makefiles(@)
             (my $dir = $file) =~ s/^(.*)\/Makefile/$1/;
             push @lines, "WINE_CONFIG_TEST($dir$flag_args)\n";
         }
+        elsif (defined($make{"RESOURCE"}))  # test resource
+        {
+            die "MODULE should not be defined in $file" if defined $make{"MODULE"};
+            die "STATICLIB should not be defined in $file" if defined $make{"STATICLIB"};
+            (my $dir = $file) =~ s/^(.*)\/Makefile/$1/;
+            (my $name = $dir) =~ s/^.*\/(.*)$/$1/;
+            die "Invalid RESOURCE in $file" unless $make{"RESOURCE"} eq $name;
+            push @lines, "WINE_CONFIG_RESOURCE($dir$flag_args)\n";
+        }
         elsif (defined($make{"MODULE"}) && $make{"MODULE"} =~ /\.a$/)  # import lib
         {
             die "MODULE should not be defined as static lib in $file" unless $file =~ /^dlls\//;
diff --git a/tools/makedep.c b/tools/makedep.c
index ec339e0..afa061a 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -174,6 +174,7 @@ struct makefile
     const char     *parent_dir;
     const char     *module;
     const char     *testdll;
+    const char     *resource;
     const char     *sharedlib;
     const char     *staticlib;
     const char     *staticimplib;
@@ -2345,6 +2346,7 @@ static struct strarray output_sources( const struct makefile *make )
     struct strarray includes = empty_strarray;
     struct strarray phony_targets = empty_strarray;
     struct strarray all_targets = empty_strarray;
+    struct strarray resource_dlls = get_expanded_make_var_array( make, "RC_DLLS" );
     struct strarray install_rules[NB_INSTALL_RULES];
     char *ldrpath_local   = get_expanded_make_variable( make, "LDRPATH_LOCAL" );
     char *ldrpath_install = get_expanded_make_variable( make, "LDRPATH_INSTALL" );
@@ -2642,7 +2644,7 @@ static struct strarray output_sources( const struct makefile *make )
         }
         else
         {
-            int need_cross = make->testdll ||
+            int need_cross = make->testdll || make->resource ||
                 (source->file->flags & FLAG_C_IMPLIB) ||
                 (make->module && make->staticlib);
 
@@ -2656,7 +2658,7 @@ static struct strarray output_sources( const struct makefile *make )
             output_filenames( includes );
             output_filenames( make->define_args );
             output_filenames( extradefs );
-            if (make->module || make->staticlib || make->sharedlib || make->testdll)
+            if (make->module || make->staticlib || make->sharedlib || make->testdll || make->resource)
             {
                 output_filenames( dll_flags );
                 if (make->use_msvcrt) output_filenames( msvcrt_flags );
@@ -2710,6 +2712,66 @@ static struct strarray output_sources( const struct makefile *make )
         output( "\n" );
     }
 
+    /* rules for resource dlls, call Makefile in subdirectory */
+
+    if (resource_dlls.count)
+    {
+        for (i = 0; i < resource_dlls.count; i++)
+        {
+            output( ".PHONY: %s\n", resource_dlls.str[i] );
+            output( "%s:\n", resource_dlls.str[i] );
+            output( "\t at cd %s && $(MAKE) %s%s\n", resource_dlls.str[i],
+                    resource_dlls.str[i], dll_ext );
+        }
+
+        output( "%s:", obj_dir_path( make, "resource_dlls.res" ));
+        for (i = 0; i < resource_dlls.count; i++)
+            output( " %s", resource_dlls.str[i] );
+        output( "\n" );
+        output( "\t(" );
+        for (i = 0; i < resource_dlls.count; i++)
+        {
+            if (i != 0) output( "; \\\n  " );
+            output( "echo \"%s RCDATA %s/%s%s\"", resource_dlls.str[i],
+                    resource_dlls.str[i], resource_dlls.str[i], dll_ext );
+        }
+        output( ") | %s -o $@\n", tools_path( make, "wrc" ) );
+        strarray_add( &clean_files, "resource_dlls.res" );
+        strarray_add( &object_files, "resource_dlls.res" );
+
+        if (crosstarget && (make->testdll || (make->module && make->staticlib)))
+        {
+            for (i = 0; i < resource_dlls.count; i++)
+            {
+                char *name = replace_extension( resource_dlls.str[i], ".dll", "_crossres.dll" );
+                output( ".PHONY: %s/crossres\n", resource_dlls.str[i] );
+                output( "%s/crossres:\n", resource_dlls.str[i] );
+                output( "\t at cd %s && $(MAKE) %s\n", resource_dlls.str[i], name );
+                free( name );
+            }
+
+            output( "%s:", obj_dir_path( make, "resource_dlls.cross.res" ));
+            for (i = 0; i < resource_dlls.count; i++)
+            {
+                char *name = replace_extension( resource_dlls.str[i], ".dll", "_crossres.dll" );
+                output( " %s/crossres", resource_dlls.str[i] );
+                free( name );
+            }
+            output( "\n" );
+            output( "\t(" );
+            for (i = 0; i < resource_dlls.count; i++)
+            {
+                char *name = replace_extension( resource_dlls.str[i], ".dll", "_crossres.dll" );
+                if (i != 0) output( "; \\\n  " );
+                output( "echo \"%s RCDATA %s/%s\"", resource_dlls.str[i], resource_dlls.str[i], name );
+                free( name );
+            }
+            output( ") | %s -o $@\n", tools_path( make, "wrc" ) );
+            strarray_add( &clean_files, "resource_dlls.cross.res" );
+            strarray_add( &crossobj_files, "resource_dlls.cross.res" );
+        }
+    }
+
     if (make->module && !make->staticlib)
     {
         struct strarray all_libs = empty_strarray;
@@ -3101,6 +3163,81 @@ static struct strarray output_sources( const struct makefile *make )
         add_install_rule( make, install_rules, make->scripts.str[i], make->scripts.str[i],
                           strmake( "S$(bindir)/%s", make->scripts.str[i] ));
 
+    if (make->resource)
+    {
+        char *extra_wine_flags = get_expanded_make_variable( make, "WINEFLAGS" );
+        char *extra_cross_flags = get_expanded_make_variable( make, "CROSSFLAGS" );
+        struct strarray all_libs = empty_strarray;
+        char *module_path = obj_dir_path( make, make->resource );
+        char *spec_file = NULL;
+
+        if (!make->appmode.count)
+            spec_file = src_dir_path( make, replace_extension( make->resource, ".dll", ".spec" ));
+        for (i = 0; i < make->imports.count; i++)
+            strarray_add( &all_libs, strmake( "-l%s", make->imports.str[i] ));
+        strarray_addall( &all_libs, get_expanded_make_var_array( make, "LIBS" ));
+
+        if (*dll_ext)
+        {
+            strarray_add( &all_targets, strmake( "%s%s", make->resource, dll_ext ));
+            strarray_add( &all_targets, strmake( "%s.fake", make->resource ));
+            output( "%s%s %s.fake:", module_path, dll_ext, module_path );
+        }
+        else
+        {
+            strarray_add( &all_targets, make->resource );
+            output( "%s:", module_path );
+        }
+        if (spec_file) output_filename( spec_file );
+        output_filenames_obj_dir( make, object_files );
+        output_filenames_obj_dir( make, res_files );
+        output( "\n" );
+        output( "\t%s -o $@", tools_path( make, "winegcc" ));
+        output_filename( strmake( "-B%s", tools_dir_path( make, "winebuild" )));
+        if (tools_dir) output_filename( strmake( "--sysroot=%s", top_obj_dir_path( make, "" )));
+        output_filenames( target_flags );
+        output_filenames( unwind_flags );
+        if (spec_file)
+        {
+            output( " -shared %s", spec_file );
+            output_filenames( make->extradllflags );
+        }
+        else output_filenames( make->appmode );
+        if (extra_wine_flags) output( " %s", extra_wine_flags );
+        output_filenames_obj_dir( make, object_files );
+        output_filenames_obj_dir( make, res_files );
+        output_filenames( all_libs );
+        output_filename( "$(LDFLAGS)" );
+        output( "\n" );
+
+        if (crosstarget)
+        {
+            char *crossres = replace_extension( make->resource, ".dll", "_crossres.dll" );
+
+            strarray_add( &clean_files, crossres );
+            output( "%s:", obj_dir_path( make, crossres ));
+            output_filenames_obj_dir( make, crossobj_files );
+            output_filenames_obj_dir( make, res_files );
+            output( "\n" );
+            output( "\t%s -o $@ -b %s", tools_path( make, "winegcc" ), crosstarget );
+            output_filename( strmake( "-B%s", tools_dir_path( make, "winebuild" )));
+            if (tools_dir) output_filename( strmake( "--sysroot=%s", top_obj_dir_path( make, "" )));
+            output_filename( "--lib-suffix=.cross.a" );
+            if (spec_file)
+            {
+                output( " -shared %s", spec_file );
+                output_filenames( make->extradllflags );
+            }
+            else output_filenames( make->appmode );
+            if (extra_cross_flags) output( " %s", extra_cross_flags );
+            output_filenames_obj_dir( make, crossobj_files );
+            output_filenames_obj_dir( make, res_files );
+            output_filenames( all_libs );
+            output_filename( "$(LDFLAGS)" );
+            output( "\n" );
+        }
+    }
+
     if (!make->disabled)
     {
         if (all_targets.count)
@@ -3476,6 +3613,7 @@ static void load_sources( struct makefile *make )
     make->parent_dir    = get_expanded_make_variable( make, "PARENTSRC" );
     make->module        = get_expanded_make_variable( make, "MODULE" );
     make->testdll       = get_expanded_make_variable( make, "TESTDLL" );
+    make->resource      = get_expanded_make_variable( make, "RESOURCE" );
     make->sharedlib     = get_expanded_make_variable( make, "SHAREDLIB" );
     make->staticlib     = get_expanded_make_variable( make, "STATICLIB" );
     make->importlib     = get_expanded_make_variable( make, "IMPORTLIB" );
-- 
2.7.4




More information about the wine-devel mailing list