1996-10-23 16:59:13 +00:00
|
|
|
/*
|
|
|
|
* Generate include file dependencies
|
|
|
|
*
|
|
|
|
* Copyright 1996 Alexandre Julliard
|
2002-03-09 23:29:33 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1996-10-23 16:59:13 +00:00
|
|
|
*/
|
|
|
|
|
2002-04-26 19:05:15 +00:00
|
|
|
#include "config.h"
|
2003-03-20 21:08:28 +00:00
|
|
|
#define NO_LIBWINE_PORT
|
2002-04-26 19:05:15 +00:00
|
|
|
#include "wine/port.h"
|
|
|
|
|
2006-08-01 10:16:29 +00:00
|
|
|
#include <assert.h>
|
1996-10-23 16:59:13 +00:00
|
|
|
#include <ctype.h>
|
2006-08-01 10:13:57 +00:00
|
|
|
#include <errno.h>
|
1996-10-23 16:59:13 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2004-04-07 04:00:16 +00:00
|
|
|
#include <stdarg.h>
|
1996-10-23 16:59:13 +00:00
|
|
|
#include <string.h>
|
2002-08-17 18:28:43 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2006-08-01 10:13:57 +00:00
|
|
|
#include "wine/list.h"
|
1996-10-23 16:59:13 +00:00
|
|
|
|
|
|
|
/* Max first-level includes per file */
|
2002-02-15 19:57:27 +00:00
|
|
|
#define MAX_INCLUDES 200
|
1996-10-23 16:59:13 +00:00
|
|
|
|
2013-10-14 08:51:37 +00:00
|
|
|
struct incl_file
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
2006-08-01 10:13:57 +00:00
|
|
|
struct list entry;
|
1996-10-23 16:59:13 +00:00
|
|
|
char *name;
|
|
|
|
char *filename;
|
2006-09-10 20:04:42 +00:00
|
|
|
char *sourcename; /* source file name for generated headers */
|
2013-10-14 08:51:37 +00:00
|
|
|
struct incl_file *included_by; /* file that included this one */
|
2000-11-06 05:32:59 +00:00
|
|
|
int included_line; /* line where this file was included */
|
2002-02-15 19:57:27 +00:00
|
|
|
int system; /* is it a system include (#include <name>) */
|
2013-10-14 08:51:37 +00:00
|
|
|
struct incl_file *owner;
|
|
|
|
struct incl_file *files[MAX_INCLUDES];
|
|
|
|
};
|
1996-10-23 16:59:13 +00:00
|
|
|
|
2006-08-01 10:13:57 +00:00
|
|
|
static struct list sources = LIST_INIT(sources);
|
|
|
|
static struct list includes = LIST_INIT(includes);
|
1996-10-23 16:59:13 +00:00
|
|
|
|
2013-10-14 08:51:37 +00:00
|
|
|
struct object_extension
|
2009-06-30 08:25:05 +00:00
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
const char *extension;
|
2013-10-14 08:51:37 +00:00
|
|
|
};
|
2009-06-30 08:25:05 +00:00
|
|
|
|
|
|
|
static struct list object_extensions = LIST_INIT(object_extensions);
|
|
|
|
|
2013-10-14 08:51:37 +00:00
|
|
|
struct incl_path
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
2006-08-01 10:13:57 +00:00
|
|
|
struct list entry;
|
|
|
|
const char *name;
|
2013-10-14 08:51:37 +00:00
|
|
|
};
|
1996-10-23 16:59:13 +00:00
|
|
|
|
2006-08-01 10:13:57 +00:00
|
|
|
static struct list paths = LIST_INIT(paths);
|
1996-10-23 16:59:13 +00:00
|
|
|
|
2006-08-01 10:27:22 +00:00
|
|
|
static const char *src_dir;
|
|
|
|
static const char *top_src_dir;
|
|
|
|
static const char *top_obj_dir;
|
1996-10-23 16:59:13 +00:00
|
|
|
static const char *OutputFileName = "Makefile";
|
|
|
|
static const char *Separator = "### Dependencies";
|
2013-10-14 09:11:07 +00:00
|
|
|
static const char *input_file_name;
|
2006-08-01 10:16:29 +00:00
|
|
|
static int input_line;
|
2013-10-14 09:11:07 +00:00
|
|
|
static FILE *output_file;
|
1996-10-23 16:59:13 +00:00
|
|
|
|
|
|
|
static const char Usage[] =
|
2013-10-14 09:11:07 +00:00
|
|
|
"Usage: makedep [options] [files]\n"
|
1996-10-23 16:59:13 +00:00
|
|
|
"Options:\n"
|
|
|
|
" -Idir Search for include files in directory 'dir'\n"
|
|
|
|
" -Cdir Search for source files in directory 'dir'\n"
|
2006-08-01 10:27:22 +00:00
|
|
|
" -Sdir Set the top source directory\n"
|
2008-06-13 03:09:38 +00:00
|
|
|
" -Tdir Set the top object directory\n"
|
1996-10-23 16:59:13 +00:00
|
|
|
" -fxxx Store output in file 'xxx' (default: Makefile)\n"
|
|
|
|
" -sxxx Use 'xxx' as separator (default: \"### Dependencies\")\n";
|
|
|
|
|
|
|
|
|
2013-10-14 09:11:07 +00:00
|
|
|
#ifndef __GNUC__
|
|
|
|
#define __attribute__(x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
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)));
|
2013-10-14 22:14:51 +00:00
|
|
|
static char *strmake( const char* fmt, ... ) __attribute__ ((__format__ (__printf__, 1, 2)));
|
2013-10-14 09:11:07 +00:00
|
|
|
|
2004-04-07 04:00:16 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* fatal_error
|
|
|
|
*/
|
|
|
|
static void fatal_error( const char *msg, ... )
|
|
|
|
{
|
|
|
|
va_list valist;
|
|
|
|
va_start( valist, msg );
|
2013-10-14 09:11:07 +00:00
|
|
|
if (input_file_name)
|
|
|
|
{
|
|
|
|
fprintf( stderr, "%s:", input_file_name );
|
|
|
|
if (input_line) fprintf( stderr, "%d:", input_line );
|
|
|
|
fprintf( stderr, " error: " );
|
|
|
|
}
|
|
|
|
else fprintf( stderr, "makedep: error: " );
|
2004-04-07 04:00:16 +00:00
|
|
|
vfprintf( stderr, msg, valist );
|
|
|
|
va_end( valist );
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-14 09:11:07 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* fatal_perror
|
|
|
|
*/
|
|
|
|
static void fatal_perror( const char *msg, ... )
|
|
|
|
{
|
|
|
|
va_list valist;
|
|
|
|
va_start( valist, msg );
|
|
|
|
if (input_file_name)
|
|
|
|
{
|
|
|
|
fprintf( stderr, "%s:", input_file_name );
|
|
|
|
if (input_line) fprintf( stderr, "%d:", input_line );
|
|
|
|
fprintf( stderr, " error:" );
|
|
|
|
}
|
|
|
|
else fprintf( stderr, "makedep: error:" );
|
|
|
|
perror( " " );
|
|
|
|
va_end( valist );
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-10-23 16:59:13 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* xmalloc
|
|
|
|
*/
|
2006-08-01 10:16:29 +00:00
|
|
|
static void *xmalloc( size_t size )
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
|
|
|
void *res;
|
|
|
|
if (!(res = malloc (size ? size : 1)))
|
2013-10-14 09:11:07 +00:00
|
|
|
fatal_error( "Virtual memory exhausted.\n" );
|
1996-10-23 16:59:13 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-01 10:16:29 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* xrealloc
|
|
|
|
*/
|
2006-09-10 20:04:42 +00:00
|
|
|
static void *xrealloc (void *ptr, size_t size)
|
2006-08-01 10:16:29 +00:00
|
|
|
{
|
|
|
|
void *res;
|
|
|
|
assert( size );
|
|
|
|
if (!(res = realloc( ptr, size )))
|
2013-10-14 09:11:07 +00:00
|
|
|
fatal_error( "Virtual memory exhausted.\n" );
|
2006-08-01 10:16:29 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
1996-10-23 16:59:13 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* xstrdup
|
|
|
|
*/
|
|
|
|
static char *xstrdup( const char *str )
|
|
|
|
{
|
|
|
|
char *res = strdup( str );
|
2013-10-14 09:11:07 +00:00
|
|
|
if (!res) fatal_error( "Virtual memory exhausted.\n" );
|
1996-10-23 16:59:13 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-01 10:37:18 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* strmake
|
|
|
|
*/
|
2006-09-10 20:04:42 +00:00
|
|
|
static char *strmake( const char* fmt, ... )
|
2006-08-01 10:37:18 +00:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-10 20:04:42 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* strendswith
|
|
|
|
*/
|
|
|
|
static int strendswith( const char* str, const char* end )
|
|
|
|
{
|
|
|
|
int l = strlen(str);
|
|
|
|
int m = strlen(end);
|
|
|
|
|
|
|
|
return l >= m && strcmp(str + l - m, end) == 0;
|
|
|
|
}
|
|
|
|
|
2013-10-14 09:11:07 +00:00
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output
|
|
|
|
*/
|
|
|
|
static int output( const char *format, ... )
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
va_list valist;
|
|
|
|
|
|
|
|
va_start( valist, format );
|
|
|
|
ret = vfprintf( output_file, format, valist );
|
|
|
|
va_end( valist );
|
|
|
|
if (ret < 0) fatal_perror( "output" );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output_filename
|
|
|
|
*/
|
|
|
|
static void output_filename( const char *name, int *column )
|
|
|
|
{
|
|
|
|
if (*column + strlen(name) + 1 > 100)
|
|
|
|
{
|
|
|
|
output( " \\\n" );
|
|
|
|
*column = 0;
|
|
|
|
}
|
|
|
|
*column += output( " %s", name );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-11 00:38:56 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* get_extension
|
|
|
|
*/
|
|
|
|
static char *get_extension( char *filename )
|
|
|
|
{
|
|
|
|
char *ext = strrchr( filename, '.' );
|
|
|
|
if (ext && strchr( ext, '/' )) ext = NULL;
|
|
|
|
return ext;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-01 10:16:29 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* get_line
|
|
|
|
*/
|
|
|
|
static char *get_line( FILE *file )
|
|
|
|
{
|
|
|
|
static char *buffer;
|
|
|
|
static unsigned int size;
|
|
|
|
|
|
|
|
if (!size)
|
|
|
|
{
|
|
|
|
size = 1024;
|
|
|
|
buffer = xmalloc( size );
|
|
|
|
}
|
|
|
|
if (!fgets( buffer, size, file )) return NULL;
|
|
|
|
input_line++;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
char *p = buffer + strlen(buffer);
|
|
|
|
/* if line is larger than buffer, resize buffer */
|
|
|
|
while (p == buffer + size - 1 && p[-1] != '\n')
|
|
|
|
{
|
|
|
|
buffer = xrealloc( buffer, size * 2 );
|
2010-04-02 17:06:31 +00:00
|
|
|
if (!fgets( buffer + size - 1, size + 1, file )) break;
|
2006-08-01 10:16:29 +00:00
|
|
|
p = buffer + strlen(buffer);
|
|
|
|
size *= 2;
|
|
|
|
}
|
|
|
|
if (p > buffer && p[-1] == '\n')
|
|
|
|
{
|
|
|
|
*(--p) = 0;
|
|
|
|
if (p > buffer && p[-1] == '\r') *(--p) = 0;
|
|
|
|
if (p > buffer && p[-1] == '\\')
|
|
|
|
{
|
|
|
|
*(--p) = 0;
|
|
|
|
/* line ends in backslash, read continuation line */
|
2010-04-02 17:06:31 +00:00
|
|
|
if (!fgets( p, size - (p - buffer), file )) return buffer;
|
2006-08-01 10:16:29 +00:00
|
|
|
input_line++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-30 08:25:05 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* add_object_extension
|
|
|
|
*
|
|
|
|
* Add an extension for object files.
|
|
|
|
*/
|
|
|
|
static void add_object_extension( const char *ext )
|
|
|
|
{
|
2013-10-14 08:51:37 +00:00
|
|
|
struct object_extension *object_extension = xmalloc( sizeof(*object_extension) );
|
2009-06-30 08:25:05 +00:00
|
|
|
list_add_tail( &object_extensions, &object_extension->entry );
|
|
|
|
object_extension->extension = ext;
|
|
|
|
}
|
|
|
|
|
1996-10-23 16:59:13 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* add_include_path
|
|
|
|
*
|
|
|
|
* Add a directory to the include path.
|
|
|
|
*/
|
|
|
|
static void add_include_path( const char *name )
|
|
|
|
{
|
2013-10-14 08:51:37 +00:00
|
|
|
struct incl_path *path = xmalloc( sizeof(*path) );
|
2006-08-01 10:13:57 +00:00
|
|
|
list_add_tail( &paths, &path->entry );
|
1996-10-23 16:59:13 +00:00
|
|
|
path->name = name;
|
|
|
|
}
|
|
|
|
|
2006-10-16 15:19:07 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* find_src_file
|
|
|
|
*/
|
2013-10-14 08:51:37 +00:00
|
|
|
static struct incl_file *find_src_file( const char *name )
|
2006-10-16 15:19:07 +00:00
|
|
|
{
|
2013-10-14 08:51:37 +00:00
|
|
|
struct incl_file *file;
|
2006-10-16 15:19:07 +00:00
|
|
|
|
2013-10-14 08:51:37 +00:00
|
|
|
LIST_FOR_EACH_ENTRY( file, &sources, struct incl_file, entry )
|
2006-10-16 15:19:07 +00:00
|
|
|
if (!strcmp( name, file->name )) return file;
|
|
|
|
return NULL;
|
|
|
|
}
|
1996-10-23 16:59:13 +00:00
|
|
|
|
2010-03-16 12:27:51 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* find_include_file
|
|
|
|
*/
|
2013-10-14 08:51:37 +00:00
|
|
|
static struct incl_file *find_include_file( const char *name )
|
2010-03-16 12:27:51 +00:00
|
|
|
{
|
2013-10-14 08:51:37 +00:00
|
|
|
struct incl_file *file;
|
2010-03-16 12:27:51 +00:00
|
|
|
|
2013-10-14 08:51:37 +00:00
|
|
|
LIST_FOR_EACH_ENTRY( file, &includes, struct incl_file, entry )
|
2010-03-16 12:27:51 +00:00
|
|
|
if (!strcmp( name, file->name )) return file;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-10-14 22:14:51 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
1996-10-23 16:59:13 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* add_include
|
|
|
|
*
|
|
|
|
* Add an include file if it doesn't already exists.
|
|
|
|
*/
|
2013-10-14 09:11:07 +00:00
|
|
|
static struct incl_file *add_include( struct incl_file *pFile, const char *name, int system )
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
2013-10-14 08:51:37 +00:00
|
|
|
struct incl_file *include;
|
2004-04-07 04:00:16 +00:00
|
|
|
char *ext;
|
1996-10-23 16:59:13 +00:00
|
|
|
int pos;
|
|
|
|
|
|
|
|
for (pos = 0; pos < MAX_INCLUDES; pos++) if (!pFile->files[pos]) break;
|
|
|
|
if (pos >= MAX_INCLUDES)
|
2013-10-14 09:11:07 +00:00
|
|
|
fatal_error( "too many included files, please fix MAX_INCLUDES\n" );
|
2004-04-07 04:00:16 +00:00
|
|
|
|
|
|
|
/* enforce some rules for the Wine tree */
|
|
|
|
|
|
|
|
if (!memcmp( name, "../", 3 ))
|
2013-10-14 09:11:07 +00:00
|
|
|
fatal_error( "#include directive with relative path not allowed\n" );
|
2004-04-07 04:00:16 +00:00
|
|
|
|
|
|
|
if (!strcmp( name, "config.h" ))
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
2004-04-07 04:00:16 +00:00
|
|
|
if ((ext = strrchr( pFile->filename, '.' )) && !strcmp( ext, ".h" ))
|
2013-10-14 09:11:07 +00:00
|
|
|
fatal_error( "config.h must not be included by a header file\n" );
|
2004-04-07 04:00:16 +00:00
|
|
|
if (pos)
|
2013-10-14 09:11:07 +00:00
|
|
|
fatal_error( "config.h must be included before anything else\n" );
|
2004-04-07 04:00:16 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp( name, "wine/port.h" ))
|
|
|
|
{
|
|
|
|
if ((ext = strrchr( pFile->filename, '.' )) && !strcmp( ext, ".h" ))
|
2013-10-14 09:11:07 +00:00
|
|
|
fatal_error( "wine/port.h must not be included by a header file\n" );
|
|
|
|
if (!pos) fatal_error( "config.h must be included before wine/port.h\n" );
|
2004-04-07 04:00:16 +00:00
|
|
|
if (pos > 1)
|
2013-10-14 09:11:07 +00:00
|
|
|
fatal_error( "wine/port.h must be included before everything except config.h\n" );
|
2004-04-07 04:00:16 +00:00
|
|
|
if (strcmp( pFile->files[0]->name, "config.h" ))
|
2013-10-14 09:11:07 +00:00
|
|
|
fatal_error( "config.h must be included before wine/port.h\n" );
|
1996-10-23 16:59:13 +00:00
|
|
|
}
|
|
|
|
|
2013-10-14 08:51:37 +00:00
|
|
|
LIST_FOR_EACH_ENTRY( include, &includes, struct incl_file, entry )
|
2006-08-01 10:13:57 +00:00
|
|
|
if (!strcmp( name, include->name )) goto found;
|
|
|
|
|
2013-10-14 08:51:37 +00:00
|
|
|
include = xmalloc( sizeof(*include) );
|
|
|
|
memset( include, 0, sizeof(*include) );
|
2006-08-01 10:13:57 +00:00
|
|
|
include->name = xstrdup(name);
|
|
|
|
include->included_by = pFile;
|
2013-10-14 09:11:07 +00:00
|
|
|
include->included_line = input_line;
|
2006-09-10 20:04:42 +00:00
|
|
|
include->system = system;
|
2006-08-01 10:13:57 +00:00
|
|
|
list_add_tail( &includes, &include->entry );
|
|
|
|
found:
|
|
|
|
pFile->files[pos] = include;
|
|
|
|
return include;
|
1996-10-23 16:59:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* open_src_file
|
|
|
|
*/
|
2013-10-14 08:51:37 +00:00
|
|
|
static FILE *open_src_file( struct incl_file *pFile )
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
|
|
|
FILE *file;
|
|
|
|
|
2002-12-11 01:30:14 +00:00
|
|
|
/* first try name as is */
|
|
|
|
if ((file = fopen( pFile->name, "r" )))
|
|
|
|
{
|
|
|
|
pFile->filename = xstrdup( pFile->name );
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
/* now try in source dir */
|
2006-08-01 10:27:22 +00:00
|
|
|
if (src_dir)
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
2006-08-01 10:37:18 +00:00
|
|
|
pFile->filename = strmake( "%s/%s", src_dir, pFile->name );
|
2002-12-11 01:30:14 +00:00
|
|
|
file = fopen( pFile->filename, "r" );
|
1996-10-23 16:59:13 +00:00
|
|
|
}
|
2013-10-14 09:11:07 +00:00
|
|
|
if (!file) fatal_perror( "open %s", pFile->name );
|
1996-10-23 16:59:13 +00:00
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* open_include_file
|
|
|
|
*/
|
2013-10-14 08:51:37 +00:00
|
|
|
static FILE *open_include_file( struct incl_file *pFile )
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
|
|
|
FILE *file = NULL;
|
2006-08-01 10:37:18 +00:00
|
|
|
char *filename, *p;
|
2013-10-14 08:51:37 +00:00
|
|
|
struct incl_path *path;
|
1996-10-23 16:59:13 +00:00
|
|
|
|
2006-08-01 10:13:57 +00:00
|
|
|
errno = ENOENT;
|
|
|
|
|
2006-09-10 20:04:42 +00:00
|
|
|
/* check for generated bison header */
|
|
|
|
|
|
|
|
if (strendswith( pFile->name, ".tab.h" ))
|
|
|
|
{
|
|
|
|
if (src_dir)
|
|
|
|
filename = strmake( "%s/%.*s.y", src_dir, strlen(pFile->name) - 6, pFile->name );
|
|
|
|
else
|
|
|
|
filename = strmake( "%.*s.y", strlen(pFile->name) - 6, pFile->name );
|
|
|
|
|
|
|
|
if ((file = fopen( filename, "r" )))
|
|
|
|
{
|
|
|
|
pFile->sourcename = filename;
|
|
|
|
pFile->filename = xstrdup( pFile->name );
|
|
|
|
/* don't bother to parse it */
|
|
|
|
fclose( file );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
free( filename );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check for generated message resource */
|
|
|
|
|
|
|
|
if (strendswith( pFile->name, ".mc.rc" ))
|
|
|
|
{
|
|
|
|
if (src_dir)
|
|
|
|
filename = strmake( "%s/%s", src_dir, pFile->name );
|
|
|
|
else
|
|
|
|
filename = xstrdup( pFile->name );
|
|
|
|
|
|
|
|
filename[strlen(filename) - 3] = 0;
|
|
|
|
|
|
|
|
if ((file = fopen( filename, "r" )))
|
|
|
|
{
|
|
|
|
pFile->sourcename = filename;
|
|
|
|
pFile->filename = xstrdup( pFile->name );
|
|
|
|
/* don't bother to parse it */
|
|
|
|
fclose( file );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
free( filename );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check for corresponding idl file in source dir */
|
|
|
|
|
|
|
|
if (strendswith( pFile->name, ".h" ))
|
|
|
|
{
|
|
|
|
if (src_dir)
|
|
|
|
filename = strmake( "%s/%.*s.idl", src_dir, strlen(pFile->name) - 2, pFile->name );
|
|
|
|
else
|
|
|
|
filename = strmake( "%.*s.idl", strlen(pFile->name) - 2, pFile->name );
|
|
|
|
|
|
|
|
if ((file = fopen( filename, "r" )))
|
|
|
|
{
|
|
|
|
pFile->sourcename = filename;
|
|
|
|
pFile->filename = xstrdup( pFile->name );
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
free( filename );
|
|
|
|
}
|
|
|
|
|
2006-08-01 10:37:18 +00:00
|
|
|
/* first try name as is */
|
|
|
|
if ((file = fopen( pFile->name, "r" )))
|
|
|
|
{
|
|
|
|
pFile->filename = xstrdup( pFile->name );
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now try in source dir */
|
|
|
|
if (src_dir)
|
|
|
|
{
|
|
|
|
filename = strmake( "%s/%s", src_dir, pFile->name );
|
|
|
|
if ((file = fopen( filename, "r" ))) goto found;
|
|
|
|
free( filename );
|
|
|
|
}
|
|
|
|
|
2006-09-10 20:04:42 +00:00
|
|
|
/* check for corresponding idl file in global includes */
|
|
|
|
|
|
|
|
if (strendswith( pFile->name, ".h" ))
|
|
|
|
{
|
|
|
|
if (top_src_dir)
|
|
|
|
filename = strmake( "%s/include/%.*s.idl",
|
|
|
|
top_src_dir, strlen(pFile->name) - 2, pFile->name );
|
|
|
|
else if (top_obj_dir)
|
|
|
|
filename = strmake( "%s/include/%.*s.idl",
|
|
|
|
top_obj_dir, strlen(pFile->name) - 2, pFile->name );
|
|
|
|
else
|
|
|
|
filename = NULL;
|
|
|
|
|
|
|
|
if (filename && (file = fopen( filename, "r" )))
|
|
|
|
{
|
|
|
|
pFile->sourcename = filename;
|
|
|
|
pFile->filename = strmake( "%s/include/%s", top_obj_dir, pFile->name );
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
free( filename );
|
|
|
|
}
|
|
|
|
|
2011-05-05 13:02:25 +00:00
|
|
|
/* check for corresponding .x file in global includes */
|
|
|
|
|
|
|
|
if (strendswith( pFile->name, "tmpl.h" ))
|
|
|
|
{
|
|
|
|
if (top_src_dir)
|
|
|
|
filename = strmake( "%s/include/%.*s.x",
|
|
|
|
top_src_dir, strlen(pFile->name) - 2, pFile->name );
|
|
|
|
else if (top_obj_dir)
|
|
|
|
filename = strmake( "%s/include/%.*s.x",
|
|
|
|
top_obj_dir, strlen(pFile->name) - 2, pFile->name );
|
|
|
|
else
|
|
|
|
filename = NULL;
|
|
|
|
|
|
|
|
if (filename && (file = fopen( filename, "r" )))
|
|
|
|
{
|
|
|
|
pFile->sourcename = filename;
|
|
|
|
pFile->filename = strmake( "%s/include/%s", top_obj_dir, pFile->name );
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
free( filename );
|
|
|
|
}
|
|
|
|
|
2006-08-01 10:37:18 +00:00
|
|
|
/* 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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now search in include paths */
|
2013-10-14 08:51:37 +00:00
|
|
|
LIST_FOR_EACH_ENTRY( path, &paths, struct incl_path, entry )
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
2006-08-01 10:37:18 +00:00
|
|
|
filename = strmake( "%s/%s", path->name, pFile->name );
|
|
|
|
if ((file = fopen( filename, "r" ))) goto found;
|
1996-10-23 16:59:13 +00:00
|
|
|
free( filename );
|
|
|
|
}
|
2006-08-01 10:37:18 +00:00
|
|
|
if (pFile->system) return NULL; /* ignore system files we cannot find */
|
2002-02-15 19:57:27 +00:00
|
|
|
|
2000-12-13 21:27:26 +00:00
|
|
|
/* try in src file directory */
|
2006-08-01 10:37:18 +00:00
|
|
|
if ((p = strrchr(pFile->included_by->filename, '/')))
|
2000-12-13 21:27:26 +00:00
|
|
|
{
|
2006-08-01 10:37:18 +00:00
|
|
|
int l = p - pFile->included_by->filename + 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" ))) goto found;
|
|
|
|
free( filename );
|
2000-12-13 21:27:26 +00:00
|
|
|
}
|
|
|
|
|
2011-09-28 10:55:16 +00:00
|
|
|
fprintf( stderr, "%s:%d: error: ", pFile->included_by->filename, pFile->included_line );
|
2006-08-01 10:37:18 +00:00
|
|
|
perror( pFile->name );
|
2011-09-28 10:55:16 +00:00
|
|
|
pFile = pFile->included_by;
|
|
|
|
while (pFile && pFile->included_by)
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
2006-09-10 20:04:42 +00:00
|
|
|
const char *parent = pFile->included_by->sourcename;
|
|
|
|
if (!parent) parent = pFile->included_by->name;
|
2011-09-28 10:55:16 +00:00
|
|
|
fprintf( stderr, "%s:%d: note: %s was first included here\n",
|
|
|
|
parent, pFile->included_line, pFile->name );
|
2006-08-01 10:37:18 +00:00
|
|
|
pFile = pFile->included_by;
|
1996-10-23 16:59:13 +00:00
|
|
|
}
|
2006-08-01 10:37:18 +00:00
|
|
|
exit(1);
|
|
|
|
|
|
|
|
found:
|
|
|
|
pFile->filename = filename;
|
1996-10-23 16:59:13 +00:00
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
2003-04-11 00:38:56 +00:00
|
|
|
* parse_idl_file
|
2006-09-10 20:04:42 +00:00
|
|
|
*
|
|
|
|
* If for_h_file is non-zero, it means we are not interested in the idl file
|
|
|
|
* itself, but only in the contents of the .h file that will be generated from it.
|
1996-10-23 16:59:13 +00:00
|
|
|
*/
|
2013-10-14 08:51:37 +00:00
|
|
|
static void parse_idl_file( struct incl_file *pFile, FILE *file, int for_h_file )
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
2006-08-01 10:16:29 +00:00
|
|
|
char *buffer, *include;
|
2000-11-06 05:32:59 +00:00
|
|
|
|
2013-10-14 09:11:07 +00:00
|
|
|
input_line = 0;
|
2006-09-10 20:04:42 +00:00
|
|
|
if (for_h_file)
|
|
|
|
{
|
|
|
|
/* generated .h file always includes these */
|
2013-10-14 09:11:07 +00:00
|
|
|
add_include( pFile, "rpc.h", 1 );
|
|
|
|
add_include( pFile, "rpcndr.h", 1 );
|
2006-09-10 20:04:42 +00:00
|
|
|
}
|
|
|
|
|
2006-08-01 10:16:29 +00:00
|
|
|
while ((buffer = get_line( file )))
|
2000-11-06 05:32:59 +00:00
|
|
|
{
|
2003-06-20 21:31:13 +00:00
|
|
|
char quote;
|
2003-04-11 00:38:56 +00:00
|
|
|
char *p = buffer;
|
|
|
|
while (*p && isspace(*p)) p++;
|
2003-06-20 21:31:13 +00:00
|
|
|
|
|
|
|
if (!strncmp( p, "import", 6 ))
|
|
|
|
{
|
|
|
|
p += 6;
|
|
|
|
while (*p && isspace(*p)) p++;
|
2006-09-10 20:04:42 +00:00
|
|
|
if (*p != '"') continue;
|
|
|
|
include = ++p;
|
|
|
|
while (*p && (*p != '"')) p++;
|
2013-10-14 09:11:07 +00:00
|
|
|
if (!*p) fatal_error( "malformed import directive\n" );
|
2006-09-10 20:04:42 +00:00
|
|
|
*p = 0;
|
|
|
|
if (for_h_file && strendswith( include, ".idl" )) strcpy( p - 4, ".h" );
|
2013-10-14 09:11:07 +00:00
|
|
|
add_include( pFile, include, 0 );
|
2006-09-10 20:04:42 +00:00
|
|
|
continue;
|
2003-06-20 21:31:13 +00:00
|
|
|
}
|
2006-09-10 20:04:42 +00:00
|
|
|
|
|
|
|
if (for_h_file) /* only check for #include inside cpp_quote */
|
2003-06-20 21:31:13 +00:00
|
|
|
{
|
2006-09-10 20:04:42 +00:00
|
|
|
if (strncmp( p, "cpp_quote", 9 )) continue;
|
|
|
|
p += 9;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (*p++ != '(') continue;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (*p++ != '"') continue;
|
2003-06-20 21:31:13 +00:00
|
|
|
if (*p++ != '#') continue;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (strncmp( p, "include", 7 )) continue;
|
|
|
|
p += 7;
|
|
|
|
while (*p && isspace(*p)) p++;
|
2006-09-10 20:04:42 +00:00
|
|
|
if (*p == '\\' && p[1] == '"')
|
|
|
|
{
|
|
|
|
p += 2;
|
|
|
|
quote = '"';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (*p++ != '<' ) continue;
|
|
|
|
quote = '>';
|
|
|
|
}
|
|
|
|
include = p;
|
|
|
|
while (*p && (*p != quote)) p++;
|
|
|
|
if (!*p || (quote == '"' && p[-1] != '\\'))
|
2013-10-14 09:11:07 +00:00
|
|
|
fatal_error( "malformed #include directive inside cpp_quote\n" );
|
2006-09-10 20:04:42 +00:00
|
|
|
if (quote == '"') p--; /* remove backslash */
|
|
|
|
*p = 0;
|
2013-10-14 09:11:07 +00:00
|
|
|
add_include( pFile, include, (quote == '>') );
|
2006-09-10 20:04:42 +00:00
|
|
|
continue;
|
2003-06-20 21:31:13 +00:00
|
|
|
}
|
|
|
|
|
2006-09-10 20:04:42 +00:00
|
|
|
/* check for normal #include */
|
|
|
|
if (*p++ != '#') continue;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (strncmp( p, "include", 7 )) continue;
|
|
|
|
p += 7;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (*p != '\"' && *p != '<' ) continue;
|
2003-06-20 21:31:13 +00:00
|
|
|
quote = *p++;
|
|
|
|
if (quote == '<') quote = '>';
|
2003-04-11 00:38:56 +00:00
|
|
|
include = p;
|
2003-06-20 21:31:13 +00:00
|
|
|
while (*p && (*p != quote)) p++;
|
2013-10-14 09:11:07 +00:00
|
|
|
if (!*p) fatal_error( "malformed #include directive\n" );
|
2003-04-11 00:38:56 +00:00
|
|
|
*p = 0;
|
2013-10-14 09:11:07 +00:00
|
|
|
add_include( pFile, include, (quote == '>') );
|
2000-11-06 05:32:59 +00:00
|
|
|
}
|
2003-04-11 00:38:56 +00:00
|
|
|
}
|
2000-11-06 05:32:59 +00:00
|
|
|
|
2003-04-11 00:38:56 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* parse_c_file
|
|
|
|
*/
|
2013-10-14 08:51:37 +00:00
|
|
|
static void parse_c_file( struct incl_file *pFile, FILE *file )
|
2003-04-11 00:38:56 +00:00
|
|
|
{
|
2006-08-01 10:16:29 +00:00
|
|
|
char *buffer, *include;
|
1996-10-23 16:59:13 +00:00
|
|
|
|
2006-08-01 10:16:29 +00:00
|
|
|
input_line = 0;
|
|
|
|
while ((buffer = get_line( file )))
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
2002-02-15 19:57:27 +00:00
|
|
|
char quote;
|
1996-10-23 16:59:13 +00:00
|
|
|
char *p = buffer;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (*p++ != '#') continue;
|
|
|
|
while (*p && isspace(*p)) p++;
|
2012-12-21 01:02:20 +00:00
|
|
|
if (!strncmp( p, "include", 7 )) p += 7;
|
|
|
|
else if (!strncmp( p, "import", 6 )) p += 6;
|
|
|
|
else continue;
|
1996-10-23 16:59:13 +00:00
|
|
|
while (*p && isspace(*p)) p++;
|
2002-02-15 19:57:27 +00:00
|
|
|
if (*p != '\"' && *p != '<' ) continue;
|
|
|
|
quote = *p++;
|
|
|
|
if (quote == '<') quote = '>';
|
1996-10-23 16:59:13 +00:00
|
|
|
include = p;
|
2002-02-15 19:57:27 +00:00
|
|
|
while (*p && (*p != quote)) p++;
|
2013-10-14 09:11:07 +00:00
|
|
|
if (!*p) fatal_error( "malformed #include directive\n" );
|
1996-10-23 16:59:13 +00:00
|
|
|
*p = 0;
|
2013-10-14 09:11:07 +00:00
|
|
|
add_include( pFile, include, (quote == '>') );
|
1996-10-23 16:59:13 +00:00
|
|
|
}
|
2003-04-11 00:38:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-26 14:02:03 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* parse_rc_file
|
|
|
|
*/
|
2013-10-14 08:51:37 +00:00
|
|
|
static void parse_rc_file( struct incl_file *pFile, FILE *file )
|
2006-12-26 14:02:03 +00:00
|
|
|
{
|
|
|
|
char *buffer, *include;
|
|
|
|
|
|
|
|
input_line = 0;
|
|
|
|
while ((buffer = get_line( file )))
|
|
|
|
{
|
|
|
|
char quote;
|
|
|
|
char *p = buffer;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
|
|
|
|
if (p[0] == '/' && p[1] == '*') /* check for magic makedep comment */
|
|
|
|
{
|
|
|
|
p += 2;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (strncmp( p, "@makedep:", 9 )) continue;
|
|
|
|
p += 9;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
quote = '"';
|
|
|
|
if (*p == quote)
|
|
|
|
{
|
|
|
|
include = ++p;
|
|
|
|
while (*p && *p != quote) p++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
include = p;
|
|
|
|
while (*p && !isspace(*p) && *p != '*') p++;
|
|
|
|
}
|
|
|
|
if (!*p)
|
2013-10-14 09:11:07 +00:00
|
|
|
fatal_error( "malformed makedep comment\n" );
|
2006-12-26 14:02:03 +00:00
|
|
|
*p = 0;
|
|
|
|
}
|
|
|
|
else /* check for #include */
|
|
|
|
{
|
|
|
|
if (*p++ != '#') continue;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (strncmp( p, "include", 7 )) continue;
|
|
|
|
p += 7;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (*p != '\"' && *p != '<' ) continue;
|
|
|
|
quote = *p++;
|
|
|
|
if (quote == '<') quote = '>';
|
|
|
|
include = p;
|
|
|
|
while (*p && (*p != quote)) p++;
|
2013-10-14 09:11:07 +00:00
|
|
|
if (!*p) fatal_error( "malformed #include directive\n" );
|
2006-12-26 14:02:03 +00:00
|
|
|
*p = 0;
|
|
|
|
}
|
2013-10-14 09:11:07 +00:00
|
|
|
add_include( pFile, include, (quote == '>') );
|
2006-12-26 14:02:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-16 15:19:07 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* parse_generated_idl
|
|
|
|
*/
|
2013-10-14 08:51:37 +00:00
|
|
|
static void parse_generated_idl( struct incl_file *source )
|
2006-10-16 15:19:07 +00:00
|
|
|
{
|
|
|
|
char *header, *basename;
|
|
|
|
|
|
|
|
basename = xstrdup( source->name );
|
|
|
|
basename[strlen(basename) - 4] = 0;
|
|
|
|
header = strmake( "%s.h", basename );
|
|
|
|
source->filename = xstrdup( source->name );
|
|
|
|
|
|
|
|
if (strendswith( source->name, "_c.c" ))
|
|
|
|
{
|
2013-10-14 09:11:07 +00:00
|
|
|
add_include( source, header, 0 );
|
2006-10-16 15:19:07 +00:00
|
|
|
}
|
|
|
|
else if (strendswith( source->name, "_i.c" ))
|
|
|
|
{
|
2013-10-14 09:11:07 +00:00
|
|
|
add_include( source, "rpc.h", 1 );
|
|
|
|
add_include( source, "rpcndr.h", 1 );
|
|
|
|
add_include( source, "guiddef.h", 1 );
|
2006-10-16 15:19:07 +00:00
|
|
|
}
|
|
|
|
else if (strendswith( source->name, "_p.c" ))
|
|
|
|
{
|
2013-10-14 09:11:07 +00:00
|
|
|
add_include( source, "objbase.h", 1 );
|
|
|
|
add_include( source, "rpcproxy.h", 1 );
|
|
|
|
add_include( source, "wine/exception.h", 1 );
|
|
|
|
add_include( source, header, 0 );
|
2006-10-16 15:19:07 +00:00
|
|
|
}
|
|
|
|
else if (strendswith( source->name, "_s.c" ))
|
|
|
|
{
|
2013-10-14 09:11:07 +00:00
|
|
|
add_include( source, "wine/exception.h", 1 );
|
|
|
|
add_include( source, header, 0 );
|
2006-10-16 15:19:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
free( header );
|
|
|
|
free( basename );
|
|
|
|
}
|
|
|
|
|
2003-04-11 00:38:56 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* parse_file
|
|
|
|
*/
|
2013-10-14 10:12:26 +00:00
|
|
|
static void parse_file( struct incl_file *source, int src )
|
2003-04-11 00:38:56 +00:00
|
|
|
{
|
|
|
|
FILE *file;
|
|
|
|
|
2006-10-16 15:19:07 +00:00
|
|
|
/* special case for source files generated from idl */
|
2013-10-14 10:12:26 +00:00
|
|
|
if (strendswith( source->name, "_c.c" ) ||
|
|
|
|
strendswith( source->name, "_i.c" ) ||
|
|
|
|
strendswith( source->name, "_p.c" ) ||
|
|
|
|
strendswith( source->name, "_s.c" ))
|
|
|
|
{
|
|
|
|
parse_generated_idl( source );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp( source->name, "dlldata.o" ))
|
|
|
|
{
|
|
|
|
source->filename = xstrdup( "dlldata.c" );
|
|
|
|
add_include( source, "objbase.h", 1 );
|
|
|
|
add_include( source, "rpcproxy.h", 1 );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp( source->name, "testlist.o" ))
|
2006-10-16 15:19:07 +00:00
|
|
|
{
|
2013-10-14 10:12:26 +00:00
|
|
|
source->filename = xstrdup( "testlist.c" );
|
|
|
|
add_include( source, "wine/test.h", 1 );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strendswith( source->name, ".o" ))
|
|
|
|
{
|
|
|
|
/* default to .c for unknown extra object files */
|
|
|
|
source->filename = xstrdup( source->name );
|
|
|
|
source->filename[strlen(source->filename) - 1] = 'c';
|
2008-04-24 21:43:04 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-05 13:02:25 +00:00
|
|
|
/* don't try to open certain types of files */
|
2013-10-14 10:12:26 +00:00
|
|
|
if (strendswith( source->name, ".tlb" ) ||
|
|
|
|
strendswith( source->name, ".res" ) ||
|
2013-10-14 22:14:51 +00:00
|
|
|
strendswith( source->name, ".pot" ) ||
|
2013-10-14 10:12:26 +00:00
|
|
|
strendswith( source->name, ".x" ))
|
2008-04-24 21:43:04 +00:00
|
|
|
{
|
2013-10-14 10:12:26 +00:00
|
|
|
source->filename = xstrdup( source->name );
|
2006-10-16 15:19:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-14 10:12:26 +00:00
|
|
|
file = src ? open_src_file( source ) : open_include_file( source );
|
2003-04-11 00:38:56 +00:00
|
|
|
if (!file) return;
|
2013-10-14 10:12:26 +00:00
|
|
|
input_file_name = source->filename;
|
|
|
|
|
|
|
|
if (source->sourcename && strendswith( source->sourcename, ".idl" ))
|
|
|
|
parse_idl_file( source, file, 1 );
|
|
|
|
else if (strendswith( source->filename, ".idl" ))
|
|
|
|
parse_idl_file( source, file, 0 );
|
|
|
|
else if (strendswith( source->filename, ".c" ) ||
|
|
|
|
strendswith( source->filename, ".m" ) ||
|
|
|
|
strendswith( source->filename, ".h" ) ||
|
|
|
|
strendswith( source->filename, ".l" ) ||
|
|
|
|
strendswith( source->filename, ".y" ))
|
|
|
|
parse_c_file( source, file );
|
|
|
|
else if (strendswith( source->filename, ".rc" ))
|
|
|
|
parse_rc_file( source, file );
|
1996-11-02 14:24:07 +00:00
|
|
|
fclose(file);
|
2013-10-14 09:11:07 +00:00
|
|
|
input_file_name = NULL;
|
1996-10-23 16:59:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-10 13:26:25 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* add_src_file
|
|
|
|
*
|
|
|
|
* Add a source file to the list.
|
|
|
|
*/
|
2013-10-14 08:51:37 +00:00
|
|
|
static struct incl_file *add_src_file( const char *name )
|
2007-12-10 13:26:25 +00:00
|
|
|
{
|
2013-10-14 08:51:37 +00:00
|
|
|
struct incl_file *file;
|
2007-12-10 13:26:25 +00:00
|
|
|
|
|
|
|
if (find_src_file( name )) return NULL; /* we already have it */
|
|
|
|
file = xmalloc( sizeof(*file) );
|
|
|
|
memset( file, 0, sizeof(*file) );
|
|
|
|
file->name = xstrdup(name);
|
|
|
|
list_add_tail( &sources, &file->entry );
|
|
|
|
parse_file( file, 1 );
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-10-23 16:59:13 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* output_include
|
|
|
|
*/
|
2013-10-14 09:11:07 +00:00
|
|
|
static void output_include( struct incl_file *pFile, struct incl_file *owner, int *column )
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (pFile->owner == owner) return;
|
2002-02-15 19:57:27 +00:00
|
|
|
if (!pFile->filename) return;
|
1996-10-23 16:59:13 +00:00
|
|
|
pFile->owner = owner;
|
2013-10-14 09:11:07 +00:00
|
|
|
output_filename( pFile->filename, column );
|
1996-10-23 16:59:13 +00:00
|
|
|
for (i = 0; i < MAX_INCLUDES; i++)
|
2013-10-14 09:11:07 +00:00
|
|
|
if (pFile->files[i]) output_include( pFile->files[i], owner, column );
|
1996-10-23 16:59:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-09-28 17:43:24 +00:00
|
|
|
/*******************************************************************
|
2013-10-14 09:11:07 +00:00
|
|
|
* output_sources
|
1997-09-28 17:43:24 +00:00
|
|
|
*/
|
2013-10-14 09:11:07 +00:00
|
|
|
static void output_sources(void)
|
1997-09-28 17:43:24 +00:00
|
|
|
{
|
2013-10-14 09:11:07 +00:00
|
|
|
struct incl_file *source;
|
2013-10-14 22:14:51 +00:00
|
|
|
int i, column, po_srcs = 0, mc_srcs = 0;
|
2013-10-14 09:11:07 +00:00
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( source, &sources, struct incl_file, entry )
|
1997-09-28 17:43:24 +00:00
|
|
|
{
|
2013-10-14 09:11:07 +00:00
|
|
|
char *obj = xstrdup( source->name );
|
|
|
|
char *ext = get_extension( obj );
|
|
|
|
|
|
|
|
if (!ext) fatal_error( "unsupported file type %s\n", source->name );
|
2000-10-23 21:39:39 +00:00
|
|
|
*ext++ = 0;
|
2013-10-14 09:11:07 +00:00
|
|
|
column = 0;
|
|
|
|
|
2000-10-23 21:39:39 +00:00
|
|
|
if (!strcmp( ext, "y" )) /* yacc file */
|
1997-09-28 17:43:24 +00:00
|
|
|
{
|
2010-03-16 12:27:51 +00:00
|
|
|
/* add source file dependency for parallel makes */
|
|
|
|
char *header = strmake( "%s.tab.h", obj );
|
2013-10-14 17:52:52 +00:00
|
|
|
if (find_include_file( header ))
|
|
|
|
{
|
|
|
|
output( "%s.tab.h: %s\n", obj, source->filename );
|
|
|
|
output( "\t$(BISON) $(BISONFLAGS) -p %s_ -o %s.tab.c -d %s\n",
|
|
|
|
obj, obj, source->filename );
|
|
|
|
output( "%s.tab.c: %s %s\n", obj, source->filename, header );
|
|
|
|
}
|
|
|
|
else output( "%s.tab.c: %s\n", obj, source->filename );
|
|
|
|
|
|
|
|
output( "\t$(BISON) $(BISONFLAGS) -p %s_ -o $@ %s\n", obj, source->filename );
|
2013-10-14 09:11:07 +00:00
|
|
|
column += output( "%s.tab.o: %s.tab.c", obj, obj );
|
2013-10-14 17:52:52 +00:00
|
|
|
free( header );
|
1997-09-28 17:43:24 +00:00
|
|
|
}
|
2000-10-23 21:39:39 +00:00
|
|
|
else if (!strcmp( ext, "l" )) /* lex file */
|
1997-09-28 17:43:24 +00:00
|
|
|
{
|
2013-10-14 17:49:29 +00:00
|
|
|
output( "%s.yy.c: %s\n", obj, source->filename );
|
|
|
|
output( "\t$(FLEX) $(LEXFLAGS) -o$@ %s\n", source->filename );
|
2013-10-14 09:11:07 +00:00
|
|
|
column += output( "%s.yy.o: %s.yy.c", obj, obj );
|
1997-09-28 17:43:24 +00:00
|
|
|
}
|
2000-10-23 21:39:39 +00:00
|
|
|
else if (!strcmp( ext, "rc" )) /* resource file */
|
1997-09-28 17:43:24 +00:00
|
|
|
{
|
2013-10-14 22:14:51 +00:00
|
|
|
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 );
|
|
|
|
}
|
2000-10-23 21:39:39 +00:00
|
|
|
}
|
2000-11-06 05:32:59 +00:00
|
|
|
else if (!strcmp( ext, "mc" )) /* message file */
|
2000-10-23 21:39:39 +00:00
|
|
|
{
|
2013-10-14 18:18:18 +00:00
|
|
|
output( "%s.res: $(WMC) $(ALL_MO_FILES) %s\n", obj, source->filename );
|
|
|
|
output( "\t$(WMC) -U -O res $(PORCFLAGS) -o $@ %s\n", source->filename );
|
|
|
|
mc_srcs++;
|
|
|
|
column += output( "msg.pot %s.res:", obj );
|
1997-09-28 17:43:24 +00:00
|
|
|
}
|
2003-04-11 00:38:56 +00:00
|
|
|
else if (!strcmp( ext, "idl" )) /* IDL file */
|
|
|
|
{
|
2013-10-15 10:30:54 +00:00
|
|
|
char *targets[8];
|
|
|
|
int nb_targets = 0;
|
|
|
|
char ending[] = "_?.c";
|
|
|
|
const char *suffix;
|
|
|
|
char *header = strmake( "%s.h", obj );
|
2006-10-16 15:19:07 +00:00
|
|
|
|
2013-10-15 10:30:54 +00:00
|
|
|
if (find_target_src_file( source->name, ".tlb" ))
|
|
|
|
{
|
|
|
|
output( "%s.tlb %s_t.res: $(WIDL)\n", obj, obj );
|
|
|
|
output( "\t$(WIDL) $(TARGETFLAGS) $(IDLFLAGS) -t -o $@ %s\n", source->filename );
|
|
|
|
targets[nb_targets++] = strmake( "%s.tlb", obj );
|
|
|
|
targets[nb_targets++] = strmake( "%s_t.res", obj );
|
|
|
|
}
|
|
|
|
|
|
|
|
for (suffix = "cips"; *suffix; suffix++)
|
2008-04-24 20:13:57 +00:00
|
|
|
{
|
2013-10-15 10:30:54 +00:00
|
|
|
ending[1] = *suffix;
|
|
|
|
if (!find_target_src_file( source->name, ending )) continue;
|
|
|
|
output( "%s%s: $(WIDL)\n", obj, ending );
|
|
|
|
output( "\t$(WIDL) $(IDLFLAGS) -%c -o $@ %s\n",
|
|
|
|
*suffix == 'i' ? 'u' : *suffix, source->filename );
|
|
|
|
targets[nb_targets++] = strmake( "%s%s", obj, ending );
|
2008-04-24 20:13:57 +00:00
|
|
|
}
|
2006-10-16 15:19:07 +00:00
|
|
|
|
2013-10-15 10:30:54 +00:00
|
|
|
if (find_target_src_file( source->name, "_r.res" ))
|
2008-04-24 20:13:57 +00:00
|
|
|
{
|
2013-10-15 10:30:54 +00:00
|
|
|
output( "%s_r.res: $(WIDL)\n", obj );
|
|
|
|
output( "\t$(WIDL) $(IDLFLAGS) -r -o $@ %s\n", source->filename );
|
|
|
|
targets[nb_targets++] = strmake( "%s_r.res", obj );
|
2008-04-24 20:13:57 +00:00
|
|
|
}
|
2010-11-30 10:54:41 +00:00
|
|
|
|
2013-10-15 10:30:54 +00:00
|
|
|
if (!nb_targets || find_include_file( header ))
|
|
|
|
{
|
|
|
|
output( "%s.h: $(WIDL)\n", obj );
|
|
|
|
output( "\t$(WIDL) $(IDLFLAGS) -h -o $@ %s\n", source->filename );
|
|
|
|
targets[nb_targets++] = header;
|
|
|
|
}
|
|
|
|
else free( header );
|
2010-11-30 10:54:41 +00:00
|
|
|
|
2013-10-15 10:30:54 +00:00
|
|
|
for (i = 0; i < nb_targets; i++)
|
|
|
|
{
|
|
|
|
column += output( "%s%c", targets[i], i < nb_targets - 1 ? ' ' : ':' );
|
|
|
|
free( targets[i] );
|
|
|
|
}
|
|
|
|
column += output( " %s", source->filename );
|
2003-04-11 00:38:56 +00:00
|
|
|
}
|
2013-10-14 22:14:51 +00:00
|
|
|
else if (!strcmp( ext, "tlb" ) || !strcmp( ext, "res" ) || !strcmp( ext, "pot" ))
|
2008-04-24 20:13:57 +00:00
|
|
|
{
|
2013-10-14 09:11:07 +00:00
|
|
|
continue; /* nothing to do for typelib files */
|
2008-04-24 20:13:57 +00:00
|
|
|
}
|
1997-09-28 17:43:24 +00:00
|
|
|
else
|
|
|
|
{
|
2013-10-14 08:51:37 +00:00
|
|
|
struct object_extension *ext;
|
|
|
|
LIST_FOR_EACH_ENTRY( ext, &object_extensions, struct object_extension, entry )
|
2013-10-14 09:11:07 +00:00
|
|
|
column += output( "%s.%s ", obj, ext->extension );
|
|
|
|
column += output( ": %s", source->filename );
|
1997-09-28 17:43:24 +00:00
|
|
|
}
|
2013-10-14 09:11:07 +00:00
|
|
|
free( obj );
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_INCLUDES; i++)
|
|
|
|
if (source->files[i]) output_include( source->files[i], source, &column );
|
|
|
|
output( "\n" );
|
1997-09-28 17:43:24 +00:00
|
|
|
}
|
2013-10-14 18:18:18 +00:00
|
|
|
|
|
|
|
/* rules for files that depend on multiple sources */
|
|
|
|
|
2013-10-14 22:14:51 +00:00
|
|
|
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" );
|
|
|
|
}
|
|
|
|
|
2013-10-14 18:18:18 +00:00
|
|
|
if (mc_srcs)
|
|
|
|
{
|
|
|
|
column = output( "msg.pot: $(WMC)" );
|
|
|
|
LIST_FOR_EACH_ENTRY( source, &sources, struct incl_file, entry )
|
|
|
|
if (strendswith( source->name, ".mc" )) output_filename( source->filename, &column );
|
|
|
|
output( "\n" );
|
|
|
|
column = output( "\t$(WMC) -O pot -o $@" );
|
|
|
|
LIST_FOR_EACH_ENTRY( source, &sources, struct incl_file, entry )
|
|
|
|
if (strendswith( source->name, ".mc" )) output_filename( source->filename, &column );
|
|
|
|
output( "\n" );
|
|
|
|
}
|
1997-09-28 17:43:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-12 13:43:15 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* create_temp_file
|
|
|
|
*/
|
|
|
|
static FILE *create_temp_file( char **tmp_name )
|
|
|
|
{
|
|
|
|
char *name = xmalloc( strlen(OutputFileName) + 13 );
|
|
|
|
unsigned int i, id = getpid();
|
|
|
|
int fd;
|
|
|
|
FILE *ret = NULL;
|
|
|
|
|
|
|
|
for (i = 0; i < 100; i++)
|
|
|
|
{
|
|
|
|
sprintf( name, "%s.tmp%08x", OutputFileName, id );
|
2009-02-22 19:39:52 +00:00
|
|
|
if ((fd = open( name, O_RDWR | O_CREAT | O_EXCL, 0666 )) != -1)
|
2009-01-12 13:43:15 +00:00
|
|
|
{
|
|
|
|
ret = fdopen( fd, "w" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (errno != EEXIST) break;
|
|
|
|
id += 7777;
|
|
|
|
}
|
2013-10-14 09:11:07 +00:00
|
|
|
if (!ret) fatal_error( "failed to create output file for '%s'\n", OutputFileName );
|
2009-01-12 13:43:15 +00:00
|
|
|
*tmp_name = name;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-10-23 16:59:13 +00:00
|
|
|
/*******************************************************************
|
|
|
|
* output_dependencies
|
|
|
|
*/
|
|
|
|
static void output_dependencies(void)
|
|
|
|
{
|
2009-01-12 13:43:15 +00:00
|
|
|
char *tmp_name = NULL;
|
1996-10-23 16:59:13 +00:00
|
|
|
|
2013-10-14 09:11:07 +00:00
|
|
|
if (Separator && ((output_file = fopen( OutputFileName, "r" ))))
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
2009-01-12 13:43:15 +00:00
|
|
|
char buffer[1024];
|
|
|
|
FILE *tmp_file = create_temp_file( &tmp_name );
|
2010-03-16 12:14:21 +00:00
|
|
|
int found = 0;
|
2009-01-12 13:43:15 +00:00
|
|
|
|
2013-10-14 09:11:07 +00:00
|
|
|
while (fgets( buffer, sizeof(buffer), output_file ) && !found)
|
2006-09-22 07:25:49 +00:00
|
|
|
{
|
2009-01-12 13:43:15 +00:00
|
|
|
if (fwrite( buffer, 1, strlen(buffer), tmp_file ) != strlen(buffer))
|
2013-10-14 09:11:07 +00:00
|
|
|
fatal_error( "failed to write to %s\n", tmp_name );
|
2010-03-16 12:14:21 +00:00
|
|
|
found = !strncmp( buffer, Separator, strlen(Separator) );
|
2006-09-22 07:25:49 +00:00
|
|
|
}
|
2013-10-14 09:11:07 +00:00
|
|
|
fclose( output_file );
|
|
|
|
output_file = tmp_file;
|
|
|
|
if (!found && list_head(&sources)) output( "\n%s\n", Separator );
|
1996-10-23 16:59:13 +00:00
|
|
|
}
|
2009-01-12 13:43:15 +00:00
|
|
|
else
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
2013-10-14 09:11:07 +00:00
|
|
|
if (!(output_file = fopen( OutputFileName, Separator ? "a" : "w" )))
|
|
|
|
fatal_perror( "%s", OutputFileName );
|
1996-10-23 16:59:13 +00:00
|
|
|
}
|
2013-10-14 09:11:07 +00:00
|
|
|
|
|
|
|
output_sources();
|
|
|
|
|
|
|
|
fclose( output_file );
|
|
|
|
output_file = NULL;
|
2009-01-12 13:43:15 +00:00
|
|
|
|
|
|
|
if (tmp_name)
|
|
|
|
{
|
2009-08-22 05:57:47 +00:00
|
|
|
int ret = rename( tmp_name, OutputFileName );
|
|
|
|
if (ret == -1 && errno == EEXIST)
|
|
|
|
{
|
|
|
|
/* rename doesn't overwrite on windows */
|
|
|
|
unlink( OutputFileName );
|
|
|
|
ret = rename( tmp_name, OutputFileName );
|
|
|
|
}
|
|
|
|
if (ret == -1)
|
2009-01-12 13:43:15 +00:00
|
|
|
{
|
|
|
|
unlink( tmp_name );
|
2013-10-14 09:11:07 +00:00
|
|
|
fatal_error( "failed to rename output file to '%s'\n", OutputFileName );
|
2009-01-12 13:43:15 +00:00
|
|
|
}
|
|
|
|
free( tmp_name );
|
|
|
|
}
|
1996-10-23 16:59:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* parse_option
|
|
|
|
*/
|
|
|
|
static void parse_option( const char *opt )
|
|
|
|
{
|
|
|
|
switch(opt[1])
|
|
|
|
{
|
|
|
|
case 'I':
|
|
|
|
if (opt[2]) add_include_path( opt + 2 );
|
|
|
|
break;
|
|
|
|
case 'C':
|
2006-08-01 10:27:22 +00:00
|
|
|
src_dir = opt + 2;
|
|
|
|
break;
|
|
|
|
case 'S':
|
|
|
|
top_src_dir = opt + 2;
|
|
|
|
break;
|
|
|
|
case 'T':
|
|
|
|
top_obj_dir = opt + 2;
|
1996-10-23 16:59:13 +00:00
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
if (opt[2]) OutputFileName = opt + 2;
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
if (opt[2]) Separator = opt + 2;
|
|
|
|
else Separator = NULL;
|
|
|
|
break;
|
2009-06-30 08:25:05 +00:00
|
|
|
case 'x':
|
|
|
|
if (opt[2]) add_object_extension( opt + 2 );
|
|
|
|
break;
|
1996-10-23 16:59:13 +00:00
|
|
|
default:
|
2013-10-14 09:11:07 +00:00
|
|
|
fprintf( stderr, "Unknown option '%s'\n%s", opt, Usage );
|
1996-10-23 16:59:13 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* main
|
|
|
|
*/
|
|
|
|
int main( int argc, char *argv[] )
|
|
|
|
{
|
2013-10-14 08:51:37 +00:00
|
|
|
struct incl_file *pFile;
|
|
|
|
struct incl_path *path, *next;
|
2006-08-01 10:27:22 +00:00
|
|
|
int i, j;
|
1996-10-23 16:59:13 +00:00
|
|
|
|
2006-08-01 10:27:22 +00:00
|
|
|
i = 1;
|
|
|
|
while (i < argc)
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
2006-08-01 10:27:22 +00:00
|
|
|
if (argv[i][0] == '-')
|
|
|
|
{
|
|
|
|
parse_option( argv[i] );
|
|
|
|
for (j = i; j < argc; j++) argv[j] = argv[j+1];
|
|
|
|
argc--;
|
|
|
|
}
|
|
|
|
else i++;
|
|
|
|
}
|
|
|
|
|
2006-08-01 10:37:18 +00:00
|
|
|
/* 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;
|
|
|
|
|
2009-06-30 08:25:05 +00:00
|
|
|
/* set the default extension list for object files */
|
|
|
|
if (list_empty( &object_extensions ))
|
|
|
|
add_object_extension( "o" );
|
|
|
|
|
2006-08-01 10:27:22 +00:00
|
|
|
/* get rid of absolute paths that don't point into the source dir */
|
2013-10-14 08:51:37 +00:00
|
|
|
LIST_FOR_EACH_ENTRY_SAFE( path, next, &paths, struct incl_path, entry )
|
2006-08-01 10:27:22 +00:00
|
|
|
{
|
|
|
|
if (path->name[0] != '/') continue;
|
|
|
|
if (top_src_dir)
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
2007-03-01 14:21:39 +00:00
|
|
|
if (!strncmp( path->name, top_src_dir, strlen(top_src_dir) ) &&
|
|
|
|
path->name[strlen(top_src_dir)] == '/') continue;
|
1996-10-23 16:59:13 +00:00
|
|
|
}
|
2006-08-01 10:27:22 +00:00
|
|
|
list_remove( &path->entry );
|
|
|
|
free( path );
|
|
|
|
}
|
|
|
|
|
2013-10-14 10:12:26 +00:00
|
|
|
for (i = 1; i < argc; i++) add_src_file( argv[i] );
|
|
|
|
|
2013-10-14 08:51:37 +00:00
|
|
|
LIST_FOR_EACH_ENTRY( pFile, &includes, struct incl_file, entry ) parse_file( pFile, 0 );
|
2006-09-22 07:25:49 +00:00
|
|
|
output_dependencies();
|
1996-10-23 16:59:13 +00:00
|
|
|
return 0;
|
|
|
|
}
|