Alexandre Julliard : makedep: Don't add dependencies for system headers.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Aug 1 12:43:41 CDT 2006


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Aug  1 12:27:22 2006 +0200

makedep: Don't add dependencies for system headers.

---

 Make.rules.in   |    2 +-
 tools/makedep.c |   57 ++++++++++++++++++++++++++++++++++++++++++-------------
 2 files changed, 45 insertions(+), 14 deletions(-)

diff --git a/Make.rules.in b/Make.rules.in
index ee8754b..6ba20df 100644
--- a/Make.rules.in
+++ b/Make.rules.in
@@ -203,7 +203,7 @@ # Rules for dependencies
 	cd `dirname $@` && $(MAKE) depend
 
 depend: $(IDL_SRCS:.idl=.h) $(SUBDIRS:%=%/__depend__)
-	$(MAKEDEP) $(INCLUDES) -C$(SRCDIR) $(C_SRCS) $(C_SRCS16) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(IDL_SRCS) $(EXTRA_SRCS)
+	$(MAKEDEP) -C$(SRCDIR) -S$(TOPSRCDIR) -T$(TOPOBJDIR) $(INCLUDES) $(C_SRCS) $(C_SRCS16) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(IDL_SRCS) $(EXTRA_SRCS)
 
 .PHONY: depend $(SUBDIRS:%=%/__depend__)
 
diff --git a/tools/makedep.c b/tools/makedep.c
index fa3555b..dd12380 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -60,7 +60,9 @@ typedef struct _INCL_PATH
 
 static struct list paths = LIST_INIT(paths);
 
-static const char *SrcDir = NULL;
+static const char *src_dir;
+static const char *top_src_dir;
+static const char *top_obj_dir;
 static const char *OutputFileName = "Makefile";
 static const char *Separator = "### Dependencies";
 static const char *ProgramName;
@@ -71,6 +73,8 @@ static const char Usage[] =
     "Options:\n"
     "   -Idir   Search for include files in directory 'dir'\n"
     "   -Cdir   Search for source files in directory 'dir'\n"
+    "   -Sdir   Set the top source directory\n"
+    "   -Sdir   Set the top object directory\n"
     "   -fxxx   Store output in file 'xxx' (default: Makefile)\n"
     "   -sxxx   Use 'xxx' as separator (default: \"### Dependencies\")\n";
 
@@ -299,10 +303,10 @@ static FILE *open_src_file( INCL_FILE *p
         return file;
     }
     /* now try in source dir */
-    if (SrcDir)
+    if (src_dir)
     {
-        pFile->filename = xmalloc( strlen(SrcDir) + strlen(pFile->name) + 2 );
-        strcpy( pFile->filename, SrcDir );
+        pFile->filename = xmalloc( strlen(src_dir) + strlen(pFile->name) + 2 );
+        strcpy( pFile->filename, src_dir );
         strcat( pFile->filename, "/" );
         strcat( pFile->filename, pFile->name );
         file = fopen( pFile->filename, "r" );
@@ -580,8 +584,13 @@ static void parse_option( const char *op
         if (opt[2]) add_include_path( opt + 2 );
         break;
     case 'C':
-        if (opt[2]) SrcDir = opt + 2;
-        else SrcDir = NULL;
+        src_dir = opt + 2;
+        break;
+    case 'S':
+        top_src_dir = opt + 2;
+        break;
+    case 'T':
+        top_obj_dir = opt + 2;
         break;
     case 'f':
         if (opt[2]) OutputFileName = opt + 2;
@@ -604,18 +613,40 @@ static void parse_option( const char *op
 int main( int argc, char *argv[] )
 {
     INCL_FILE *pFile;
+    INCL_PATH *path, *next;
+    int i, j;
 
     ProgramName = argv[0];
-    while (argc > 1)
+
+    i = 1;
+    while (i < argc)
     {
-        if (*argv[1] == '-') parse_option( argv[1] );
-        else
+        if (argv[i][0] == '-')
+        {
+            parse_option( argv[i] );
+            for (j = i; j < argc; j++) argv[j] = argv[j+1];
+            argc--;
+        }
+        else i++;
+    }
+
+    /* get rid of absolute paths that don't point into the source dir */
+    LIST_FOR_EACH_ENTRY_SAFE( path, next, &paths, INCL_PATH, entry )
+    {
+        if (path->name[0] != '/') continue;
+        if (top_src_dir)
         {
-            pFile = add_src_file( argv[1] );
-            parse_file( pFile, 1 );
+            if (!strncmp( path->name, top_src_dir, strlen(top_src_dir) )) continue;
+            if (path->name[strlen(top_src_dir)] == '/') continue;
         }
-        argc--;
-        argv++;
+        list_remove( &path->entry );
+        free( path );
+    }
+
+    for (i = 1; i < argc; i++)
+    {
+        pFile = add_src_file( argv[i] );
+        parse_file( pFile, 1 );
     }
     LIST_FOR_EACH_ENTRY( pFile, &includes, INCL_FILE, entry ) parse_file( pFile, 0 );
     if (!list_empty( &sources )) output_dependencies();




More information about the wine-cvs mailing list