Alexandre Julliard : makefiles: Generate explicit build rules for resource files from makedep.

Alexandre Julliard julliard at winehq.org
Tue Oct 15 13:27:10 CDT 2013


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Oct 15 00:14:51 2013 +0200

makefiles: Generate explicit build rules for resource files from makedep.

---

 Make.rules.in                 |   15 +----------
 programs/winetest/Makefile.in |    3 +-
 tools/makedep.c               |   52 ++++++++++++++++++++++++++++++++++++++--
 3 files changed, 53 insertions(+), 17 deletions(-)

diff --git a/Make.rules.in b/Make.rules.in
index 06dea78..ee51208 100644
--- a/Make.rules.in
+++ b/Make.rules.in
@@ -36,7 +36,7 @@ CROSSOBJS = $(OBJS:.o=.cross.o)
 
 # Implicit rules
 
-.SUFFIXES: .rc .res .idl .tlb .h .ok .man.in .man _c.c _i.c _p.c _s.c _r.res _t.res .cross.o .po .mo @MAINTAINER_MODE@ .sfd .ttf .svg .ico .bmp
+.SUFFIXES: .idl .tlb .h .ok .man.in .man _c.c _i.c _p.c _s.c _r.res _t.res .cross.o .po .mo @MAINTAINER_MODE@ .sfd .ttf .svg .ico .bmp
 
 .c.o:
 	$(CC) -c $(ALLCFLAGS) -o $@ $<
@@ -47,9 +47,6 @@ CROSSOBJS = $(OBJS:.o=.cross.o)
 .c.cross.o:
 	$(CROSSCC) -c $(INCLUDES) $(DEFS) -DWINE_CROSSTEST $(CPPFLAGS) $(CFLAGS) -o $@ $<
 
-.rc.res:
-	$(WRC) $(RCFLAGS) -o $@ $<
-
 .idl.h:
 	$(WIDL) $(IDLFLAGS) -h -o $@ $<
 
@@ -131,7 +128,7 @@ $(IMPORTLIB:%=lib%.cross.a): $(MAINSPEC) $(IMPLIB_SRCS:.c=.cross.o)
 
 # Rules for dependencies
 
-DEPEND_SRCS = $(C_SRCS) $(OBJC_SRCS) $(RC_SRCS) $(MC_SRCS) \
+DEPEND_SRCS = $(C_SRCS) $(OBJC_SRCS) $(RC_SRCS) $(MC_SRCS) $(PO_SRCS:.rc=.pot) \
               $(IDL_H_SRCS) $(IDL_C_SRCS) $(IDL_I_SRCS) $(IDL_P_SRCS) $(IDL_S_SRCS) \
               $(IDL_GEN_C_SRCS) $(IDL_R_SRCS:.idl=_r.res) $(IDL_TLB_SRCS) $(IDL_TLB_SRCS:.idl=.tlb) \
               $(BISON_SRCS) $(LEX_SRCS) $(EXTRA_OBJS)
@@ -210,14 +207,6 @@ install install-lib install-dev uninstall::
 
 .PHONY: install install-lib install-dev uninstall
 
-# Rules for resources
-
-rsrc.pot: $(WRC)
-	$(WRC) $(RCFLAGS) -O pot -o $@ $(PO_SRCS)
-
-$(RC_SRCS:.rc=.res): $(WRC)
-$(PO_SRCS:.rc=.res): $(ALL_MO_FILES)
-
 # Misc. rules
 
 $(IDL_GEN_HEADERS) $(IDL_GEN_C_SRCS) $(IDL_TLB_SRCS:.idl=.tlb) $(IDL_TLB_RES) $(IDL_R_SRCS:.idl=_r.res): $(WIDL)
diff --git a/programs/winetest/Makefile.in b/programs/winetest/Makefile.in
index 898e995..6865e93 100644
--- a/programs/winetest/Makefile.in
+++ b/programs/winetest/Makefile.in
@@ -25,6 +25,7 @@ build.rc: dummy
 build.nfo:
 	-$(CC) -v 2>$@
 
-build.res: build.nfo
+build.res: build.rc build.nfo
+	$(WRC) $(RCFLAGS) -o $@ build.rc
 
 @MAKE_PROG_RULES@
diff --git a/tools/makedep.c b/tools/makedep.c
index db92d53..dcf7414 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -96,6 +96,7 @@ static const char Usage[] =
 static void fatal_error( const char *msg, ... ) __attribute__ ((__format__ (__printf__, 1, 2)));
 static void fatal_perror( const char *msg, ... ) __attribute__ ((__format__ (__printf__, 1, 2)));
 static int output( const char *format, ... ) __attribute__ ((__format__ (__printf__, 1, 2)));
+static char *strmake( const char* fmt, ... ) __attribute__ ((__format__ (__printf__, 1, 2)));
 
 /*******************************************************************
  *         fatal_error
@@ -341,6 +342,24 @@ static struct incl_file *find_include_file( const char *name )
 }
 
 /*******************************************************************
+ *         find_target_src_file
+ *
+ * Check if we have a source file as a target for the specified source with a different extension.
+ */
+static struct incl_file *find_target_src_file( const char *name, const char *ext )
+{
+    struct incl_file *ret;
+    char *p, *match = xmalloc( strlen( name ) + strlen( ext ) + 1 );
+
+    strcpy( match, name );
+    if ((p = get_extension( match ))) strcpy( p, ext );
+    else strcat( match, ext );
+    ret = find_src_file( match );
+    free( match );
+    return ret;
+}
+
+/*******************************************************************
  *         add_include
  *
  * Add an include file if it doesn't already exists.
@@ -858,6 +877,7 @@ static void parse_file( struct incl_file *source, int src )
     /* don't try to open certain types of files */
     if (strendswith( source->name, ".tlb" ) ||
         strendswith( source->name, ".res" ) ||
+        strendswith( source->name, ".pot" ) ||
         strendswith( source->name, ".x" ))
     {
         source->filename = xstrdup( source->name );
@@ -926,7 +946,7 @@ static void output_include( struct incl_file *pFile, struct incl_file *owner, in
 static void output_sources(void)
 {
     struct incl_file *source;
-    int i, column, mc_srcs = 0;
+    int i, column, po_srcs = 0, mc_srcs = 0;
 
     LIST_FOR_EACH_ENTRY( source, &sources, struct incl_file, entry )
     {
@@ -962,7 +982,19 @@ static void output_sources(void)
         }
         else if (!strcmp( ext, "rc" ))  /* resource file */
         {
-            column += output( "rsrc.pot %s.res: %s", obj, source->filename );
+            if (find_target_src_file( source->name, ".pot" ))
+            {
+                output( "%s.res: $(WRC) $(ALL_MO_FILES) %s\n", obj, source->filename );
+                output( "\t$(WRC) $(RCFLAGS) -o $@ %s\n", source->filename );
+                column += output( "%s.res rsrc.pot:", obj );
+                po_srcs++;
+            }
+            else
+            {
+                output( "%s.res: $(WRC) %s\n", obj, source->filename );
+                output( "\t$(WRC) $(RCFLAGS) -o $@ %s\n", source->filename );
+                column += output( "%s.res:", obj );
+            }
         }
         else if (!strcmp( ext, "mc" ))  /* message file */
         {
@@ -1004,7 +1036,7 @@ static void output_sources(void)
 
             column += output( ": %s", source->filename );
         }
-        else if (!strcmp( ext, "tlb" ) || !strcmp( ext, "res" ))
+        else if (!strcmp( ext, "tlb" ) || !strcmp( ext, "res" ) || !strcmp( ext, "pot" ))
         {
             continue;  /* nothing to do for typelib files */
         }
@@ -1024,6 +1056,20 @@ static void output_sources(void)
 
     /* rules for files that depend on multiple sources */
 
+    if (po_srcs)
+    {
+        column = output( "rsrc.pot: $(WRC)" );
+        LIST_FOR_EACH_ENTRY( source, &sources, struct incl_file, entry )
+            if (strendswith( source->name, ".rc" ) && find_target_src_file( source->name, ".pot" ))
+                output_filename( source->filename, &column );
+        output( "\n" );
+        column = output( "\t$(WRC) $(RCFLAGS) -O pot -o $@" );
+        LIST_FOR_EACH_ENTRY( source, &sources, struct incl_file, entry )
+            if (strendswith( source->name, ".rc" ) && find_target_src_file( source->name, ".pot" ))
+                output_filename( source->filename, &column );
+        output( "\n" );
+    }
+
     if (mc_srcs)
     {
         column = output( "msg.pot: $(WMC)" );




More information about the wine-cvs mailing list