[1/2] makedep: Add support for multiple object file extensions.

Francois Gouget fgouget at free.fr
Sun Jun 28 06:28:37 CDT 2009


This is useful to generate dependencies for crossbuilds.
---
 tools/makedep.c |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/tools/makedep.c b/tools/makedep.c
index 4194073..f9836f1 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -67,6 +67,8 @@ static const char *top_obj_dir;
 static const char *OutputFileName = "Makefile";
 static const char *Separator = "### Dependencies";
 static const char *ProgramName;
+static char *ObjExtensions = NULL;
+static int ObjExtensionsCount;
 static int input_line;
 
 static const char Usage[] =
@@ -857,7 +859,14 @@ static int output_src( FILE *file, INCL_FILE *pFile, int *column )
         }
         else
         {
-            *column += fprintf( file, "%s.o: %s", obj, pFile->filename );
+            int i;
+            char* ext=ObjExtensions;
+            for (i=0; i< ObjExtensionsCount; i++)
+            {
+                *column += fprintf( file, "%s.%s ", obj, ext );
+                ext+=strlen(ext)+1;
+            }
+            *column += fprintf( file, ": %s", pFile->filename );
         }
     }
     free( obj );
@@ -973,6 +982,15 @@ static void parse_option( const char *opt )
         if (opt[2]) Separator = opt + 2;
         else Separator = NULL;
         break;
+    case 'o':
+        if (opt[2]) ObjExtensions = strdup(opt + 2);
+        else
+        {
+            if (ObjExtensions)
+                free( ObjExtensions );
+            ObjExtensions = NULL;
+        }
+        break;
     default:
         fprintf( stderr, "Unknown option '%s'\n", opt );
         fprintf( stderr, Usage, ProgramName );
@@ -988,6 +1006,7 @@ int main( int argc, char *argv[] )
 {
     INCL_FILE *pFile;
     INCL_PATH *path, *next;
+    char* s;
     int i, j;
 
     ProgramName = argv[0];
@@ -1008,6 +1027,19 @@ int main( int argc, char *argv[] )
     if (src_dir && !strcmp( src_dir, "." )) src_dir = NULL;
     if (top_src_dir && top_obj_dir && !strcmp( top_src_dir, top_obj_dir )) top_src_dir = NULL;
 
+    /* check and prepare the object files extension list */
+    if (!ObjExtensions)
+        ObjExtensions = strdup( "o" );
+    s = ObjExtensions;
+    ObjExtensionsCount = 0;
+    while (s && *s)
+    {
+        ObjExtensionsCount++;
+        s = strchr( s, ':' );
+        if (s)
+            *s++ = '\0';
+    }
+
     /* get rid of absolute paths that don't point into the source dir */
     LIST_FOR_EACH_ENTRY_SAFE( path, next, &paths, INCL_PATH, entry )
     {
-- 
1.6.3.1




More information about the wine-patches mailing list