Commit ded32d51 authored by Alexandre Julliard's avatar Alexandre Julliard

makedep: Always search for includes in the standard directories, even without -I option.

parent dea28ee4
......@@ -203,7 +203,7 @@ $(SUBDIRS:%=%/__depend__): dummy
cd `dirname $@` && $(MAKE) depend
depend: $(IDL_SRCS:.idl=.h) $(SUBDIRS:%=%/__depend__)
$(MAKEDEP) -C$(SRCDIR) -S$(TOPSRCDIR) -T$(TOPOBJDIR) $(INCLUDES) $(C_SRCS) $(C_SRCS16) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(IDL_SRCS) $(EXTRA_SRCS)
$(MAKEDEP) -C$(SRCDIR) -S$(TOPSRCDIR) -T$(TOPOBJDIR) $(EXTRAINCL) $(C_SRCS) $(C_SRCS16) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(IDL_SRCS) $(EXTRA_SRCS)
.PHONY: depend $(SUBDIRS:%=%/__depend__)
......
......@@ -128,6 +128,29 @@ static char *xstrdup( const char *str )
/*******************************************************************
* strmake
*/
char *strmake( const char* fmt, ... )
{
int n;
size_t size = 100;
va_list ap;
for (;;)
{
char *p = xmalloc (size);
va_start(ap, fmt);
n = vsnprintf (p, size, fmt, ap);
va_end(ap);
if (n == -1) size *= 2;
else if ((size_t)n >= size) size = n + 1;
else return p;
free(p);
}
}
/*******************************************************************
* get_extension
*/
static char *get_extension( char *filename )
......@@ -305,10 +328,7 @@ static FILE *open_src_file( INCL_FILE *pFile )
/* now try in source dir */
if (src_dir)
{
pFile->filename = xmalloc( strlen(src_dir) + strlen(pFile->name) + 2 );
strcpy( pFile->filename, src_dir );
strcat( pFile->filename, "/" );
strcat( pFile->filename, pFile->name );
pFile->filename = strmake( "%s/%s", src_dir, pFile->name );
file = fopen( pFile->filename, "r" );
}
if (!file)
......@@ -326,43 +346,62 @@ static FILE *open_src_file( INCL_FILE *pFile )
static FILE *open_include_file( INCL_FILE *pFile )
{
FILE *file = NULL;
char *filename, *p;
INCL_PATH *path;
errno = ENOENT;
LIST_FOR_EACH_ENTRY( path, &paths, INCL_PATH, entry )
/* first try name as is */
if ((file = fopen( pFile->name, "r" )))
{
char *filename = xmalloc(strlen(path->name) + strlen(pFile->name) + 2);
strcpy( filename, path->name );
strcat( filename, "/" );
strcat( filename, pFile->name );
if ((file = fopen( filename, "r" )))
pFile->filename = xstrdup( pFile->name );
return file;
}
/* now try in source dir */
if (src_dir)
{
pFile->filename = filename;
break;
filename = strmake( "%s/%s", src_dir, pFile->name );
if ((file = fopen( filename, "r" ))) goto found;
free( filename );
}
/* now try in global includes */
if (top_obj_dir)
{
filename = strmake( "%s/include/%s", top_obj_dir, pFile->name );
if ((file = fopen( filename, "r" ))) goto found;
free( filename );
}
if (top_src_dir)
{
filename = strmake( "%s/include/%s", top_src_dir, pFile->name );
if ((file = fopen( filename, "r" ))) goto found;
free( filename );
}
if (!file && pFile->system) return NULL; /* ignore system files we cannot find */
/* try in src file directory */
if (!file)
/* now search in include paths */
LIST_FOR_EACH_ENTRY( path, &paths, INCL_PATH, entry )
{
char *p = strrchr(pFile->included_by->filename, '/');
if (p)
filename = strmake( "%s/%s", path->name, pFile->name );
if ((file = fopen( filename, "r" ))) goto found;
free( filename );
}
if (pFile->system) return NULL; /* ignore system files we cannot find */
/* try in src file directory */
if ((p = strrchr(pFile->included_by->filename, '/')))
{
int l = p - pFile->included_by->filename + 1;
char *filename = xmalloc(l + strlen(pFile->name) + 1);
filename = xmalloc(l + strlen(pFile->name) + 1);
memcpy( filename, pFile->included_by->filename, l );
strcpy( filename + l, pFile->name );
if ((file = fopen( filename, "r" ))) pFile->filename = filename;
else free( filename );
}
if ((file = fopen( filename, "r" ))) goto found;
free( filename );
}
if (!file)
{
if (pFile->included_by->system) return NULL; /* ignore if included by a system file */
perror( pFile->name );
while (pFile->included_by)
{
......@@ -371,7 +410,9 @@ static FILE *open_include_file( INCL_FILE *pFile )
pFile = pFile->included_by;
}
exit(1);
}
found:
pFile->filename = filename;
return file;
}
......@@ -630,6 +671,10 @@ int main( int argc, char *argv[] )
else i++;
}
/* ignore redundant source paths */
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;
/* get rid of absolute paths that don't point into the source dir */
LIST_FOR_EACH_ENTRY_SAFE( path, next, &paths, INCL_PATH, entry )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment