1996-10-23 18:59:13 +02:00
|
|
|
/*
|
|
|
|
* Generate include file dependencies
|
|
|
|
*
|
2013-12-24 11:37:52 +01:00
|
|
|
* Copyright 1996, 2013 Alexandre Julliard
|
2002-03-10 00:29:33 +01: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 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1996-10-23 18:59:13 +02:00
|
|
|
*/
|
|
|
|
|
2002-04-26 21:05:15 +02:00
|
|
|
#include "config.h"
|
2003-03-20 22:08:28 +01:00
|
|
|
#define NO_LIBWINE_PORT
|
2002-04-26 21:05:15 +02:00
|
|
|
#include "wine/port.h"
|
|
|
|
|
2006-08-01 12:16:29 +02:00
|
|
|
#include <assert.h>
|
1996-10-23 18:59:13 +02:00
|
|
|
#include <ctype.h>
|
2006-08-01 12:13:57 +02:00
|
|
|
#include <errno.h>
|
1996-10-23 18:59:13 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2004-04-07 06:00:16 +02:00
|
|
|
#include <stdarg.h>
|
2013-12-28 11:47:15 +01:00
|
|
|
#include <signal.h>
|
1996-10-23 18:59:13 +02:00
|
|
|
#include <string.h>
|
2002-08-17 20:28:43 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2006-08-01 12:13:57 +02:00
|
|
|
#include "wine/list.h"
|
1996-10-23 18:59:13 +02:00
|
|
|
|
2014-04-11 16:55:51 +02:00
|
|
|
enum incl_type
|
|
|
|
{
|
|
|
|
INCL_NORMAL, /* #include "foo.h" */
|
|
|
|
INCL_SYSTEM, /* #include <foo.h> */
|
|
|
|
INCL_IMPORT, /* idl import "foo.idl" */
|
2015-11-05 06:25:35 +01:00
|
|
|
INCL_IMPORTLIB, /* idl importlib "foo.tlb" */
|
2014-04-11 16:55:51 +02:00
|
|
|
INCL_CPP_QUOTE, /* idl cpp_quote("#include \"foo.h\"") */
|
|
|
|
INCL_CPP_QUOTE_SYSTEM /* idl cpp_quote("#include <foo.h>") */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct dependency
|
|
|
|
{
|
|
|
|
int line; /* source line where this header is included */
|
|
|
|
enum incl_type type; /* type of include */
|
|
|
|
char *name; /* header name */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct file
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
char *name; /* full file name relative to cwd */
|
|
|
|
void *args; /* custom arguments for makefile rule */
|
|
|
|
unsigned int flags; /* flags (see below) */
|
|
|
|
unsigned int deps_count; /* files in use */
|
|
|
|
unsigned int deps_size; /* total allocated size */
|
|
|
|
struct dependency *deps; /* all header dependencies */
|
|
|
|
};
|
|
|
|
|
2013-10-14 10:51:37 +02:00
|
|
|
struct incl_file
|
1996-10-23 18:59:13 +02:00
|
|
|
{
|
2006-08-01 12:13:57 +02:00
|
|
|
struct list entry;
|
2014-04-11 16:55:51 +02:00
|
|
|
struct file *file;
|
1996-10-23 18:59:13 +02:00
|
|
|
char *name;
|
|
|
|
char *filename;
|
2006-09-10 22:04:42 +02:00
|
|
|
char *sourcename; /* source file name for generated headers */
|
2013-10-14 10:51:37 +02:00
|
|
|
struct incl_file *included_by; /* file that included this one */
|
2000-11-06 06:32:59 +01:00
|
|
|
int included_line; /* line where this file was included */
|
2015-11-05 06:25:35 +01:00
|
|
|
enum incl_type type; /* type of include */
|
2013-10-14 10:51:37 +02:00
|
|
|
struct incl_file *owner;
|
2014-01-04 12:25:56 +01:00
|
|
|
unsigned int files_count; /* files in use */
|
|
|
|
unsigned int files_size; /* total allocated size */
|
|
|
|
struct incl_file **files;
|
2013-10-14 10:51:37 +02:00
|
|
|
};
|
1996-10-23 18:59:13 +02:00
|
|
|
|
2014-04-11 16:55:51 +02:00
|
|
|
#define FLAG_GENERATED 0x000001 /* generated file */
|
|
|
|
#define FLAG_INSTALL 0x000002 /* file to install */
|
2014-02-05 13:44:51 +01:00
|
|
|
#define FLAG_IDL_PROXY 0x000100 /* generates a proxy (_p.c) file */
|
|
|
|
#define FLAG_IDL_CLIENT 0x000200 /* generates a client (_c.c) file */
|
|
|
|
#define FLAG_IDL_SERVER 0x000400 /* generates a server (_s.c) file */
|
|
|
|
#define FLAG_IDL_IDENT 0x000800 /* generates an ident (_i.c) file */
|
|
|
|
#define FLAG_IDL_REGISTER 0x001000 /* generates a registration (_r.res) file */
|
|
|
|
#define FLAG_IDL_TYPELIB 0x002000 /* generates a typelib (.tlb) file */
|
|
|
|
#define FLAG_IDL_REGTYPELIB 0x004000 /* generates a registered typelib (_t.res) file */
|
|
|
|
#define FLAG_IDL_HEADER 0x008000 /* generates a header (.h) file */
|
|
|
|
#define FLAG_RC_PO 0x010000 /* rc file contains translations */
|
|
|
|
#define FLAG_C_IMPLIB 0x020000 /* file is part of an import library */
|
2014-02-18 15:53:14 +01:00
|
|
|
#define FLAG_SFD_FONTS 0x040000 /* sfd file generated bitmap fonts */
|
2013-11-04 17:39:30 +01:00
|
|
|
|
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
unsigned int flag;
|
|
|
|
const char *ext;
|
|
|
|
} idl_outputs[] =
|
|
|
|
{
|
2013-12-24 21:12:08 +01:00
|
|
|
{ FLAG_IDL_TYPELIB, ".tlb" },
|
|
|
|
{ FLAG_IDL_REGTYPELIB, "_t.res" },
|
|
|
|
{ FLAG_IDL_CLIENT, "_c.c" },
|
|
|
|
{ FLAG_IDL_IDENT, "_i.c" },
|
|
|
|
{ FLAG_IDL_PROXY, "_p.c" },
|
|
|
|
{ FLAG_IDL_SERVER, "_s.c" },
|
|
|
|
{ FLAG_IDL_REGISTER, "_r.res" },
|
|
|
|
{ FLAG_IDL_HEADER, ".h" }
|
2013-11-04 17:39:30 +01:00
|
|
|
};
|
|
|
|
|
2016-03-01 09:20:33 +01:00
|
|
|
#define HASH_SIZE 997
|
2014-04-11 16:55:51 +02:00
|
|
|
|
|
|
|
static struct list files[HASH_SIZE];
|
1996-10-23 18:59:13 +02:00
|
|
|
|
2013-11-09 18:57:00 +01:00
|
|
|
struct strarray
|
|
|
|
{
|
|
|
|
unsigned int count; /* strings in use */
|
|
|
|
unsigned int size; /* total allocated size */
|
|
|
|
const char **str;
|
|
|
|
};
|
|
|
|
|
2013-12-24 11:37:52 +01:00
|
|
|
static const struct strarray empty_strarray;
|
|
|
|
|
2015-11-10 04:03:52 +01:00
|
|
|
enum install_rules { INSTALL_LIB, INSTALL_DEV, NB_INSTALL_RULES };
|
|
|
|
|
2014-04-02 14:09:42 +02:00
|
|
|
/* variables common to all makefiles */
|
|
|
|
static struct strarray linguas;
|
|
|
|
static struct strarray dll_flags;
|
|
|
|
static struct strarray target_flags;
|
|
|
|
static struct strarray msvcrt_flags;
|
|
|
|
static struct strarray extra_cflags;
|
|
|
|
static struct strarray cpp_flags;
|
|
|
|
static struct strarray unwind_flags;
|
|
|
|
static struct strarray libs;
|
|
|
|
static struct strarray cmdline_vars;
|
2016-02-29 07:06:42 +01:00
|
|
|
static struct strarray disabled_dirs;
|
2014-04-02 14:09:42 +02:00
|
|
|
static const char *root_src_dir;
|
|
|
|
static const char *tools_dir;
|
|
|
|
static const char *tools_ext;
|
|
|
|
static const char *exe_ext;
|
|
|
|
static const char *dll_ext;
|
|
|
|
static const char *man_ext;
|
|
|
|
static const char *crosstarget;
|
|
|
|
static const char *fontforge;
|
|
|
|
static const char *convert;
|
|
|
|
static const char *rsvg;
|
|
|
|
static const char *icotool;
|
2015-11-12 15:19:24 +01:00
|
|
|
static const char *dlltool;
|
2016-02-25 09:46:56 +01:00
|
|
|
static const char *msgfmt;
|
2016-02-26 07:13:00 +01:00
|
|
|
static const char *ln_s;
|
2014-04-02 14:09:42 +02:00
|
|
|
|
2014-04-09 10:12:44 +02:00
|
|
|
struct makefile
|
|
|
|
{
|
|
|
|
struct strarray vars;
|
2015-11-11 07:02:57 +01:00
|
|
|
struct strarray include_paths;
|
2014-04-09 10:12:44 +02:00
|
|
|
struct strarray define_args;
|
2015-10-27 04:13:26 +01:00
|
|
|
struct strarray programs;
|
2015-10-29 06:43:54 +01:00
|
|
|
struct strarray scripts;
|
2014-04-09 10:12:44 +02:00
|
|
|
struct strarray appmode;
|
|
|
|
struct strarray imports;
|
2016-01-11 08:05:51 +01:00
|
|
|
struct strarray subdirs;
|
2014-04-09 12:35:24 +02:00
|
|
|
struct strarray delayimports;
|
|
|
|
struct strarray extradllflags;
|
2015-10-29 06:32:45 +01:00
|
|
|
struct strarray install_lib;
|
|
|
|
struct strarray install_dev;
|
2014-04-10 13:50:37 +02:00
|
|
|
struct list sources;
|
2014-04-11 17:03:54 +02:00
|
|
|
struct list includes;
|
2014-04-09 10:12:44 +02:00
|
|
|
const char *base_dir;
|
|
|
|
const char *src_dir;
|
2014-04-10 10:03:03 +02:00
|
|
|
const char *obj_dir;
|
2014-04-09 10:12:44 +02:00
|
|
|
const char *top_src_dir;
|
|
|
|
const char *top_obj_dir;
|
|
|
|
const char *parent_dir;
|
2014-04-09 12:35:24 +02:00
|
|
|
const char *module;
|
|
|
|
const char *testdll;
|
2015-11-12 14:08:03 +01:00
|
|
|
const char *sharedlib;
|
2014-04-09 12:35:24 +02:00
|
|
|
const char *staticlib;
|
2016-02-16 08:53:59 +01:00
|
|
|
const char *staticimplib;
|
2014-04-09 12:35:24 +02:00
|
|
|
const char *importlib;
|
2016-02-29 07:06:42 +01:00
|
|
|
int disabled;
|
2014-04-09 10:12:44 +02:00
|
|
|
int use_msvcrt;
|
2014-04-09 12:35:24 +02:00
|
|
|
int is_win16;
|
2016-01-11 08:05:51 +01:00
|
|
|
struct makefile **submakes;
|
2014-04-09 10:12:44 +02:00
|
|
|
};
|
|
|
|
|
2014-04-10 13:41:23 +02:00
|
|
|
static struct makefile *top_makefile;
|
2014-04-02 14:09:42 +02:00
|
|
|
|
2016-02-25 09:08:12 +01:00
|
|
|
static const char separator[] = "### Dependencies";
|
2015-10-23 10:42:44 +02:00
|
|
|
static const char *output_makefile_name = "Makefile";
|
2013-10-14 11:11:07 +02:00
|
|
|
static const char *input_file_name;
|
2013-12-28 11:47:15 +01:00
|
|
|
static const char *output_file_name;
|
|
|
|
static const char *temp_file_name;
|
2013-11-08 21:11:59 +01:00
|
|
|
static int relative_dir_mode;
|
2006-08-01 12:16:29 +02:00
|
|
|
static int input_line;
|
2013-12-28 11:48:03 +01:00
|
|
|
static int output_column;
|
2013-10-14 11:11:07 +02:00
|
|
|
static FILE *output_file;
|
1996-10-23 18:59:13 +02:00
|
|
|
|
|
|
|
static const char Usage[] =
|
2016-01-11 08:05:51 +01:00
|
|
|
"Usage: makedep [options] [directories]\n"
|
1996-10-23 18:59:13 +02:00
|
|
|
"Options:\n"
|
2014-01-14 21:16:40 +01:00
|
|
|
" -R from to Compute the relative path between two directories\n"
|
2015-11-13 10:56:41 +01:00
|
|
|
" -fxxx Store output in file 'xxx' (default: Makefile)\n";
|
1996-10-23 18:59:13 +02:00
|
|
|
|
|
|
|
|
2013-10-14 11:11:07 +02: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)));
|
2013-12-28 11:48:03 +01:00
|
|
|
static void output( const char *format, ... ) __attribute__ ((__format__ (__printf__, 1, 2)));
|
2013-10-15 00:14:51 +02:00
|
|
|
static char *strmake( const char* fmt, ... ) __attribute__ ((__format__ (__printf__, 1, 2)));
|
2013-10-14 11:11:07 +02:00
|
|
|
|
2004-04-07 06:00:16 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* fatal_error
|
|
|
|
*/
|
|
|
|
static void fatal_error( const char *msg, ... )
|
|
|
|
{
|
|
|
|
va_list valist;
|
|
|
|
va_start( valist, msg );
|
2013-10-14 11:11:07 +02: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 06:00:16 +02:00
|
|
|
vfprintf( stderr, msg, valist );
|
|
|
|
va_end( valist );
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-14 11:11:07 +02: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 );
|
2013-11-04 17:39:30 +01:00
|
|
|
fprintf( stderr, " error: " );
|
2013-10-14 11:11:07 +02:00
|
|
|
}
|
2013-11-04 17:39:30 +01:00
|
|
|
else fprintf( stderr, "makedep: error: " );
|
|
|
|
vfprintf( stderr, msg, valist );
|
2013-10-14 11:11:07 +02:00
|
|
|
perror( " " );
|
|
|
|
va_end( valist );
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-28 11:47:15 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* cleanup_files
|
|
|
|
*/
|
|
|
|
static void cleanup_files(void)
|
|
|
|
{
|
|
|
|
if (temp_file_name) unlink( temp_file_name );
|
|
|
|
if (output_file_name) unlink( output_file_name );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* exit_on_signal
|
|
|
|
*/
|
|
|
|
static void exit_on_signal( int sig )
|
|
|
|
{
|
|
|
|
exit( 1 ); /* this will call the atexit functions */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-10-23 18:59:13 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* xmalloc
|
|
|
|
*/
|
2006-08-01 12:16:29 +02:00
|
|
|
static void *xmalloc( size_t size )
|
1996-10-23 18:59:13 +02:00
|
|
|
{
|
|
|
|
void *res;
|
|
|
|
if (!(res = malloc (size ? size : 1)))
|
2013-10-14 11:11:07 +02:00
|
|
|
fatal_error( "Virtual memory exhausted.\n" );
|
1996-10-23 18:59:13 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-01 12:16:29 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* xrealloc
|
|
|
|
*/
|
2006-09-10 22:04:42 +02:00
|
|
|
static void *xrealloc (void *ptr, size_t size)
|
2006-08-01 12:16:29 +02:00
|
|
|
{
|
|
|
|
void *res;
|
|
|
|
assert( size );
|
|
|
|
if (!(res = realloc( ptr, size )))
|
2013-10-14 11:11:07 +02:00
|
|
|
fatal_error( "Virtual memory exhausted.\n" );
|
2006-08-01 12:16:29 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
1996-10-23 18:59:13 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* xstrdup
|
|
|
|
*/
|
|
|
|
static char *xstrdup( const char *str )
|
|
|
|
{
|
|
|
|
char *res = strdup( str );
|
2013-10-14 11:11:07 +02:00
|
|
|
if (!res) fatal_error( "Virtual memory exhausted.\n" );
|
1996-10-23 18:59:13 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-01 12:37:18 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* strmake
|
|
|
|
*/
|
2006-09-10 22:04:42 +02:00
|
|
|
static char *strmake( const char* fmt, ... )
|
2006-08-01 12:37:18 +02: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;
|
2015-11-10 04:21:21 +01:00
|
|
|
else return xrealloc( p, n + 1 );
|
2006-08-01 12:37:18 +02:00
|
|
|
free(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-10 22:04:42 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* strendswith
|
|
|
|
*/
|
|
|
|
static int strendswith( const char* str, const char* end )
|
|
|
|
{
|
2015-11-10 04:21:21 +01:00
|
|
|
size_t l = strlen( str );
|
|
|
|
size_t m = strlen( end );
|
2006-09-10 22:04:42 +02:00
|
|
|
|
|
|
|
return l >= m && strcmp(str + l - m, end) == 0;
|
|
|
|
}
|
|
|
|
|
2013-10-14 11:11:07 +02:00
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output
|
|
|
|
*/
|
2013-12-28 11:48:03 +01:00
|
|
|
static void output( const char *format, ... )
|
2013-10-14 11:11:07 +02:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
va_list valist;
|
|
|
|
|
|
|
|
va_start( valist, format );
|
|
|
|
ret = vfprintf( output_file, format, valist );
|
|
|
|
va_end( valist );
|
|
|
|
if (ret < 0) fatal_perror( "output" );
|
2013-12-28 11:48:03 +01:00
|
|
|
if (format[0] && format[strlen(format) - 1] == '\n') output_column = 0;
|
|
|
|
else output_column += ret;
|
2013-10-14 11:11:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-09 18:57:00 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* strarray_add
|
|
|
|
*/
|
|
|
|
static void strarray_add( struct strarray *array, const char *str )
|
|
|
|
{
|
|
|
|
if (array->count == array->size)
|
|
|
|
{
|
|
|
|
if (array->size) array->size *= 2;
|
|
|
|
else array->size = 16;
|
|
|
|
array->str = xrealloc( array->str, sizeof(array->str[0]) * array->size );
|
|
|
|
}
|
|
|
|
array->str[array->count++] = str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-24 11:37:52 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* strarray_addall
|
|
|
|
*/
|
2013-12-28 19:52:33 +01:00
|
|
|
static void strarray_addall( struct strarray *array, struct strarray added )
|
2013-12-24 11:37:52 +01:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2013-12-28 19:52:33 +01:00
|
|
|
for (i = 0; i < added.count; i++) strarray_add( array, added.str[i] );
|
2013-12-24 11:37:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-12 21:10:55 +01:00
|
|
|
/*******************************************************************
|
2014-04-10 13:15:13 +02:00
|
|
|
* strarray_exists
|
2013-12-12 21:10:55 +01:00
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static int strarray_exists( const struct strarray *array, const char *str )
|
2013-12-12 21:10:55 +01:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2014-04-10 13:15:13 +02:00
|
|
|
for (i = 0; i < array->count; i++) if (!strcmp( array->str[i], str )) return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* strarray_add_uniq
|
|
|
|
*/
|
|
|
|
static void strarray_add_uniq( struct strarray *array, const char *str )
|
|
|
|
{
|
|
|
|
if (!strarray_exists( array, str )) strarray_add( array, str );
|
2013-12-12 21:10:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-02 14:10:45 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* strarray_get_value
|
|
|
|
*
|
|
|
|
* Find a value in a name/value pair string array.
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static const char *strarray_get_value( const struct strarray *array, const char *name )
|
2014-04-02 14:10:45 +02:00
|
|
|
{
|
2016-03-29 05:27:17 +02:00
|
|
|
int pos, res, min = 0, max = array->count / 2 - 1;
|
2014-04-02 14:10:45 +02:00
|
|
|
|
2016-03-29 05:27:17 +02:00
|
|
|
while (min <= max)
|
|
|
|
{
|
|
|
|
pos = (min + max) / 2;
|
|
|
|
if (!(res = strcmp( array->str[pos * 2], name ))) return array->str[pos * 2 + 1];
|
|
|
|
if (res < 0) min = pos + 1;
|
|
|
|
else max = pos - 1;
|
|
|
|
}
|
2014-04-02 14:10:45 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* strarray_set_value
|
|
|
|
*
|
|
|
|
* Define a value in a name/value pair string array.
|
|
|
|
*/
|
|
|
|
static void strarray_set_value( struct strarray *array, const char *name, const char *value )
|
|
|
|
{
|
2016-03-29 05:27:17 +02:00
|
|
|
int i, pos, res, min = 0, max = array->count / 2 - 1;
|
2014-04-02 14:10:45 +02:00
|
|
|
|
2016-03-29 05:27:17 +02:00
|
|
|
while (min <= max)
|
2014-04-02 14:10:45 +02:00
|
|
|
{
|
2016-03-29 05:27:17 +02:00
|
|
|
pos = (min + max) / 2;
|
|
|
|
if (!(res = strcmp( array->str[pos * 2], name )))
|
|
|
|
{
|
|
|
|
/* redefining a variable replaces the previous value */
|
|
|
|
array->str[pos * 2 + 1] = value;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (res < 0) min = pos + 1;
|
|
|
|
else max = pos - 1;
|
2014-04-02 14:10:45 +02:00
|
|
|
}
|
2016-03-29 05:27:17 +02:00
|
|
|
strarray_add( array, NULL );
|
|
|
|
strarray_add( array, NULL );
|
|
|
|
for (i = array->count - 1; i > min * 2 + 1; i--) array->str[i] = array->str[i - 2];
|
|
|
|
array->str[min * 2] = name;
|
|
|
|
array->str[min * 2 + 1] = value;
|
2014-04-02 14:10:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-14 11:11:07 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* output_filename
|
|
|
|
*/
|
2013-12-28 11:48:03 +01:00
|
|
|
static void output_filename( const char *name )
|
2013-10-14 11:11:07 +02:00
|
|
|
{
|
2013-12-28 11:48:03 +01:00
|
|
|
if (output_column + strlen(name) + 1 > 100)
|
2013-10-14 11:11:07 +02:00
|
|
|
{
|
2013-12-28 11:48:03 +01:00
|
|
|
output( " \\\n" );
|
|
|
|
output( " " );
|
2013-10-14 11:11:07 +02:00
|
|
|
}
|
2013-12-28 11:48:03 +01:00
|
|
|
else if (output_column) output( " " );
|
|
|
|
output( "%s", name );
|
2013-12-24 11:37:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output_filenames
|
|
|
|
*/
|
2013-12-28 19:52:33 +01:00
|
|
|
static void output_filenames( struct strarray array )
|
2013-12-24 11:37:52 +01:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2013-12-28 19:52:33 +01:00
|
|
|
for (i = 0; i < array.count; i++) output_filename( array.str[i] );
|
2013-10-14 11:11:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-11 02:38:56 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* get_extension
|
|
|
|
*/
|
|
|
|
static char *get_extension( char *filename )
|
|
|
|
{
|
|
|
|
char *ext = strrchr( filename, '.' );
|
|
|
|
if (ext && strchr( ext, '/' )) ext = NULL;
|
|
|
|
return ext;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-15 20:29:09 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* replace_extension
|
|
|
|
*/
|
2013-12-24 11:27:35 +01:00
|
|
|
static char *replace_extension( const char *name, const char *old_ext, const char *new_ext )
|
2013-10-15 20:29:09 +02:00
|
|
|
{
|
2013-12-24 11:27:35 +01:00
|
|
|
char *ret;
|
2015-11-10 04:21:21 +01:00
|
|
|
size_t name_len = strlen( name );
|
|
|
|
size_t ext_len = strlen( old_ext );
|
2013-12-24 11:27:35 +01:00
|
|
|
|
|
|
|
if (name_len >= ext_len && !strcmp( name + name_len - ext_len, old_ext )) name_len -= ext_len;
|
|
|
|
ret = xmalloc( name_len + strlen( new_ext ) + 1 );
|
|
|
|
memcpy( ret, name, name_len );
|
|
|
|
strcpy( ret + name_len, new_ext );
|
2013-10-15 20:29:09 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-11 03:54:46 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* replace_filename
|
|
|
|
*/
|
|
|
|
static char *replace_filename( const char *path, const char *name )
|
|
|
|
{
|
|
|
|
const char *p;
|
|
|
|
char *ret;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
if (!path) return xstrdup( name );
|
|
|
|
if (!(p = strrchr( path, '/' ))) return xstrdup( name );
|
|
|
|
len = p - path + 1;
|
|
|
|
ret = xmalloc( len + strlen( name ) + 1 );
|
|
|
|
memcpy( ret, path, len );
|
|
|
|
strcpy( ret + len, name );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-24 11:37:52 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* strarray_replace_extension
|
|
|
|
*/
|
|
|
|
static struct strarray strarray_replace_extension( const struct strarray *array,
|
|
|
|
const char *old_ext, const char *new_ext )
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
struct strarray ret;
|
|
|
|
|
|
|
|
ret.count = ret.size = array->count;
|
|
|
|
ret.str = xmalloc( sizeof(ret.str[0]) * ret.size );
|
|
|
|
for (i = 0; i < array->count; i++) ret.str[i] = replace_extension( array->str[i], old_ext, new_ext );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-17 17:10:28 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* replace_substr
|
|
|
|
*/
|
2015-11-10 04:21:21 +01:00
|
|
|
static char *replace_substr( const char *str, const char *start, size_t len, const char *replace )
|
2013-12-17 17:10:28 +01:00
|
|
|
{
|
2015-11-10 04:21:21 +01:00
|
|
|
size_t pos = start - str;
|
2013-12-17 17:10:28 +01:00
|
|
|
char *ret = xmalloc( pos + strlen(replace) + strlen(start + len) + 1 );
|
|
|
|
memcpy( ret, str, pos );
|
|
|
|
strcpy( ret + pos, replace );
|
|
|
|
strcat( ret + pos, start + len );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-08 21:11:59 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* get_relative_path
|
|
|
|
*
|
|
|
|
* Determine where the destination path is located relative to the 'from' path.
|
|
|
|
*/
|
|
|
|
static char *get_relative_path( const char *from, const char *dest )
|
|
|
|
{
|
|
|
|
const char *start;
|
|
|
|
char *ret, *p;
|
|
|
|
unsigned int dotdots = 0;
|
|
|
|
|
|
|
|
/* a path of "." is equivalent to an empty path */
|
|
|
|
if (!strcmp( from, "." )) from = "";
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
while (*from == '/') from++;
|
|
|
|
while (*dest == '/') dest++;
|
|
|
|
start = dest; /* save start of next path element */
|
|
|
|
if (!*from) break;
|
|
|
|
|
|
|
|
while (*from && *from != '/' && *from == *dest) { from++; dest++; }
|
|
|
|
if ((!*from || *from == '/') && (!*dest || *dest == '/')) continue;
|
|
|
|
|
|
|
|
/* count remaining elements in 'from' */
|
|
|
|
do
|
|
|
|
{
|
|
|
|
dotdots++;
|
|
|
|
while (*from && *from != '/') from++;
|
|
|
|
while (*from == '/') from++;
|
|
|
|
}
|
|
|
|
while (*from);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!start[0] && !dotdots) return NULL; /* empty path */
|
|
|
|
|
|
|
|
ret = xmalloc( 3 * dotdots + strlen( start ) + 1 );
|
|
|
|
for (p = ret; dotdots; dotdots--, p += 3) memcpy( p, "../", 3 );
|
|
|
|
|
|
|
|
if (start[0]) strcpy( p, start );
|
|
|
|
else p[-1] = 0; /* remove trailing slash */
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-10 11:10:55 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* concat_paths
|
|
|
|
*/
|
|
|
|
static char *concat_paths( const char *base, const char *path )
|
|
|
|
{
|
2014-04-11 14:24:53 +02:00
|
|
|
if (!base || !base[0]) return xstrdup( path && path[0] ? path : "." );
|
2014-04-09 12:32:54 +02:00
|
|
|
if (!path || !path[0]) return xstrdup( base );
|
2014-03-10 11:10:55 +01:00
|
|
|
if (path[0] == '/') return xstrdup( path );
|
|
|
|
return strmake( "%s/%s", base, path );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-28 15:08:28 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* base_dir_path
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static char *base_dir_path( const struct makefile *make, const char *path )
|
2014-01-28 15:08:28 +01:00
|
|
|
{
|
2014-04-09 10:12:44 +02:00
|
|
|
return concat_paths( make->base_dir, path );
|
2014-01-28 15:08:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-10 10:03:03 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* obj_dir_path
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static char *obj_dir_path( const struct makefile *make, const char *path )
|
2014-04-10 10:03:03 +02:00
|
|
|
{
|
|
|
|
return concat_paths( make->obj_dir, path );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-10 12:47:19 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* src_dir_path
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static char *src_dir_path( const struct makefile *make, const char *path )
|
2014-01-10 12:47:19 +01:00
|
|
|
{
|
2014-04-10 10:03:03 +02:00
|
|
|
if (make->src_dir) return concat_paths( make->src_dir, path );
|
2014-04-10 13:41:23 +02:00
|
|
|
return obj_dir_path( make, path );
|
2014-01-10 12:47:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* top_obj_dir_path
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static char *top_obj_dir_path( const struct makefile *make, const char *path )
|
2014-01-10 12:47:19 +01:00
|
|
|
{
|
2014-04-09 10:12:44 +02:00
|
|
|
return concat_paths( make->top_obj_dir, path );
|
2014-01-10 12:47:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
2016-03-31 07:39:32 +02:00
|
|
|
* top_src_dir_path
|
2014-01-10 12:47:19 +01:00
|
|
|
*/
|
2016-03-31 07:39:32 +02:00
|
|
|
static char *top_src_dir_path( const struct makefile *make, const char *path )
|
2014-01-10 12:47:19 +01:00
|
|
|
{
|
2014-04-09 10:12:44 +02:00
|
|
|
if (make->top_src_dir) return concat_paths( make->top_src_dir, path );
|
2014-04-10 13:41:23 +02:00
|
|
|
return top_obj_dir_path( make, path );
|
2014-01-10 12:47:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-11 14:24:53 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* root_dir_path
|
|
|
|
*/
|
|
|
|
static char *root_dir_path( const char *path )
|
|
|
|
{
|
|
|
|
return concat_paths( root_src_dir, path );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-13 14:44:26 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* tools_dir_path
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static char *tools_dir_path( const struct makefile *make, const char *path )
|
2014-01-13 14:44:26 +01:00
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
if (tools_dir) return top_obj_dir_path( make, strmake( "%s/tools/%s", tools_dir, path ));
|
|
|
|
return top_obj_dir_path( make, strmake( "tools/%s", path ));
|
2014-01-13 14:44:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-13 15:04:30 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* tools_path
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static char *tools_path( const struct makefile *make, const char *name )
|
2014-01-13 15:04:30 +01:00
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
return strmake( "%s/%s%s", tools_dir_path( make, name ), name, tools_ext );
|
2014-01-13 15:04:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-01 12:16:29 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* get_line
|
|
|
|
*/
|
|
|
|
static char *get_line( FILE *file )
|
|
|
|
{
|
|
|
|
static char *buffer;
|
2015-11-10 04:21:21 +01:00
|
|
|
static size_t size;
|
2006-08-01 12:16:29 +02:00
|
|
|
|
|
|
|
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 19:06:31 +02:00
|
|
|
if (!fgets( buffer + size - 1, size + 1, file )) break;
|
2006-08-01 12:16:29 +02: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 19:06:31 +02:00
|
|
|
if (!fgets( p, size - (p - buffer), file )) return buffer;
|
2006-08-01 12:16:29 +02:00
|
|
|
input_line++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-11 16:55:51 +02:00
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* hash_filename
|
|
|
|
*/
|
|
|
|
static unsigned int hash_filename( const char *name )
|
|
|
|
{
|
2016-03-01 09:20:33 +01:00
|
|
|
/* FNV-1 hash */
|
2016-03-02 00:53:58 +01:00
|
|
|
unsigned int ret = 2166136261u;
|
2016-03-01 09:20:33 +01:00
|
|
|
while (*name) ret = (ret * 16777619) ^ *name++;
|
2014-04-11 16:55:51 +02:00
|
|
|
return ret % HASH_SIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* add_file
|
|
|
|
*/
|
|
|
|
static struct file *add_file( const char *name )
|
|
|
|
{
|
|
|
|
struct file *file = xmalloc( sizeof(*file) );
|
|
|
|
memset( file, 0, sizeof(*file) );
|
|
|
|
file->name = xstrdup( name );
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* add_dependency
|
|
|
|
*/
|
|
|
|
static void add_dependency( struct file *file, const char *name, enum incl_type type )
|
|
|
|
{
|
|
|
|
/* enforce some rules for the Wine tree */
|
|
|
|
|
|
|
|
if (!memcmp( name, "../", 3 ))
|
|
|
|
fatal_error( "#include directive with relative path not allowed\n" );
|
|
|
|
|
|
|
|
if (!strcmp( name, "config.h" ))
|
|
|
|
{
|
|
|
|
if (strendswith( file->name, ".h" ))
|
|
|
|
fatal_error( "config.h must not be included by a header file\n" );
|
|
|
|
if (file->deps_count)
|
|
|
|
fatal_error( "config.h must be included before anything else\n" );
|
|
|
|
}
|
|
|
|
else if (!strcmp( name, "wine/port.h" ))
|
|
|
|
{
|
|
|
|
if (strendswith( file->name, ".h" ))
|
|
|
|
fatal_error( "wine/port.h must not be included by a header file\n" );
|
|
|
|
if (!file->deps_count) fatal_error( "config.h must be included before wine/port.h\n" );
|
|
|
|
if (file->deps_count > 1)
|
|
|
|
fatal_error( "wine/port.h must be included before everything except config.h\n" );
|
|
|
|
if (strcmp( file->deps[0].name, "config.h" ))
|
|
|
|
fatal_error( "config.h must be included before wine/port.h\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (file->deps_count >= file->deps_size)
|
|
|
|
{
|
|
|
|
file->deps_size *= 2;
|
|
|
|
if (file->deps_size < 16) file->deps_size = 16;
|
|
|
|
file->deps = xrealloc( file->deps, file->deps_size * sizeof(*file->deps) );
|
|
|
|
}
|
|
|
|
file->deps[file->deps_count].line = input_line;
|
|
|
|
file->deps[file->deps_count].type = type;
|
|
|
|
file->deps[file->deps_count].name = xstrdup( name );
|
|
|
|
file->deps_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-16 17:19:07 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* find_src_file
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static struct incl_file *find_src_file( const struct makefile *make, const char *name )
|
2006-10-16 17:19:07 +02:00
|
|
|
{
|
2013-10-14 10:51:37 +02:00
|
|
|
struct incl_file *file;
|
2006-10-16 17:19:07 +02:00
|
|
|
|
2014-04-10 13:50:37 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( file, &make->sources, struct incl_file, entry )
|
2006-10-16 17:19:07 +02:00
|
|
|
if (!strcmp( name, file->name )) return file;
|
|
|
|
return NULL;
|
|
|
|
}
|
1996-10-23 18:59:13 +02:00
|
|
|
|
2010-03-16 13:27:51 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* find_include_file
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static struct incl_file *find_include_file( const struct makefile *make, const char *name )
|
2010-03-16 13:27:51 +01:00
|
|
|
{
|
2013-10-14 10:51:37 +02:00
|
|
|
struct incl_file *file;
|
2010-03-16 13:27:51 +01:00
|
|
|
|
2014-04-11 17:03:54 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( file, &make->includes, struct incl_file, entry )
|
2010-03-16 13:27:51 +01:00
|
|
|
if (!strcmp( name, file->name )) return file;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1996-10-23 18:59:13 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* add_include
|
|
|
|
*
|
|
|
|
* Add an include file if it doesn't already exists.
|
|
|
|
*/
|
2014-04-11 17:03:54 +02:00
|
|
|
static struct incl_file *add_include( struct makefile *make, struct incl_file *parent,
|
2015-11-05 06:25:35 +01:00
|
|
|
const char *name, int line, enum incl_type type )
|
1996-10-23 18:59:13 +02:00
|
|
|
{
|
2013-10-14 10:51:37 +02:00
|
|
|
struct incl_file *include;
|
1996-10-23 18:59:13 +02:00
|
|
|
|
2014-01-04 12:25:56 +01:00
|
|
|
if (parent->files_count >= parent->files_size)
|
|
|
|
{
|
|
|
|
parent->files_size *= 2;
|
|
|
|
if (parent->files_size < 16) parent->files_size = 16;
|
|
|
|
parent->files = xrealloc( parent->files, parent->files_size * sizeof(*parent->files) );
|
|
|
|
}
|
2004-04-07 06:00:16 +02:00
|
|
|
|
2014-04-11 17:03:54 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( include, &make->includes, struct incl_file, entry )
|
2006-08-01 12:13:57 +02:00
|
|
|
if (!strcmp( name, include->name )) goto found;
|
|
|
|
|
2013-10-14 10:51:37 +02:00
|
|
|
include = xmalloc( sizeof(*include) );
|
|
|
|
memset( include, 0, sizeof(*include) );
|
2006-08-01 12:13:57 +02:00
|
|
|
include->name = xstrdup(name);
|
2014-01-04 12:25:56 +01:00
|
|
|
include->included_by = parent;
|
2014-04-11 16:55:51 +02:00
|
|
|
include->included_line = line;
|
2015-11-05 06:25:35 +01:00
|
|
|
include->type = type;
|
2014-04-11 17:03:54 +02:00
|
|
|
list_add_tail( &make->includes, &include->entry );
|
2006-08-01 12:13:57 +02:00
|
|
|
found:
|
2014-01-04 12:25:56 +01:00
|
|
|
parent->files[parent->files_count++] = include;
|
2006-08-01 12:13:57 +02:00
|
|
|
return include;
|
1996-10-23 18:59:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-05 12:15:07 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* add_generated_source
|
|
|
|
*
|
|
|
|
* Add a generated source file to the list.
|
|
|
|
*/
|
2014-04-10 13:41:23 +02:00
|
|
|
static struct incl_file *add_generated_source( struct makefile *make,
|
|
|
|
const char *name, const char *filename )
|
2014-02-05 12:15:07 +01:00
|
|
|
{
|
|
|
|
struct incl_file *file;
|
|
|
|
|
2014-04-10 13:50:37 +02:00
|
|
|
if ((file = find_src_file( make, name ))) return file; /* we already have it */
|
2014-02-05 12:15:07 +01:00
|
|
|
file = xmalloc( sizeof(*file) );
|
|
|
|
memset( file, 0, sizeof(*file) );
|
2014-04-11 16:55:51 +02:00
|
|
|
file->file = add_file( name );
|
2014-02-05 12:15:07 +01:00
|
|
|
file->name = xstrdup( name );
|
2014-04-10 13:41:23 +02:00
|
|
|
file->filename = obj_dir_path( make, filename ? filename : name );
|
2014-04-11 16:55:51 +02:00
|
|
|
file->file->flags = FLAG_GENERATED;
|
2014-04-10 13:50:37 +02:00
|
|
|
list_add_tail( &make->sources, &file->entry );
|
2014-02-05 12:15:07 +01:00
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-05 12:48:16 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* parse_include_directive
|
|
|
|
*/
|
2014-04-11 16:55:51 +02:00
|
|
|
static void parse_include_directive( struct file *source, char *str )
|
2013-11-05 12:48:16 +01:00
|
|
|
{
|
|
|
|
char quote, *include, *p = str;
|
|
|
|
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (*p != '\"' && *p != '<' ) return;
|
|
|
|
quote = *p++;
|
|
|
|
if (quote == '<') quote = '>';
|
|
|
|
include = p;
|
|
|
|
while (*p && (*p != quote)) p++;
|
|
|
|
if (!*p) fatal_error( "malformed include directive '%s'\n", str );
|
|
|
|
*p = 0;
|
2014-04-11 16:55:51 +02:00
|
|
|
add_dependency( source, include, (quote == '>') ? INCL_SYSTEM : INCL_NORMAL );
|
2013-11-05 12:48:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* parse_pragma_directive
|
|
|
|
*/
|
2014-04-11 16:55:51 +02:00
|
|
|
static void parse_pragma_directive( struct file *source, char *str )
|
2013-11-05 12:48:16 +01:00
|
|
|
{
|
|
|
|
char *flag, *p = str;
|
|
|
|
|
|
|
|
if (!isspace( *p )) return;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
p = strtok( p, " \t" );
|
|
|
|
if (strcmp( p, "makedep" )) return;
|
|
|
|
|
|
|
|
while ((flag = strtok( NULL, " \t" )))
|
|
|
|
{
|
|
|
|
if (!strcmp( flag, "depend" ))
|
|
|
|
{
|
2014-04-11 16:55:51 +02:00
|
|
|
while ((p = strtok( NULL, " \t" ))) add_dependency( source, p, INCL_NORMAL );
|
2013-11-05 12:48:16 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-02-05 13:44:51 +01:00
|
|
|
else if (!strcmp( flag, "install" )) source->flags |= FLAG_INSTALL;
|
|
|
|
|
2013-11-05 12:48:16 +01:00
|
|
|
if (strendswith( source->name, ".idl" ))
|
|
|
|
{
|
|
|
|
if (!strcmp( flag, "header" )) source->flags |= FLAG_IDL_HEADER;
|
|
|
|
else if (!strcmp( flag, "proxy" )) source->flags |= FLAG_IDL_PROXY;
|
|
|
|
else if (!strcmp( flag, "client" )) source->flags |= FLAG_IDL_CLIENT;
|
|
|
|
else if (!strcmp( flag, "server" )) source->flags |= FLAG_IDL_SERVER;
|
|
|
|
else if (!strcmp( flag, "ident" )) source->flags |= FLAG_IDL_IDENT;
|
|
|
|
else if (!strcmp( flag, "typelib" )) source->flags |= FLAG_IDL_TYPELIB;
|
|
|
|
else if (!strcmp( flag, "register" )) source->flags |= FLAG_IDL_REGISTER;
|
2013-12-24 20:01:53 +01:00
|
|
|
else if (!strcmp( flag, "regtypelib" )) source->flags |= FLAG_IDL_REGTYPELIB;
|
2013-11-05 12:48:16 +01:00
|
|
|
}
|
|
|
|
else if (strendswith( source->name, ".rc" ))
|
|
|
|
{
|
|
|
|
if (!strcmp( flag, "po" )) source->flags |= FLAG_RC_PO;
|
|
|
|
}
|
2014-02-05 12:15:07 +01:00
|
|
|
else if (strendswith( source->name, ".sfd" ))
|
|
|
|
{
|
|
|
|
if (!strcmp( flag, "font" ))
|
|
|
|
{
|
2014-02-18 15:53:14 +01:00
|
|
|
struct strarray *array = source->args;
|
|
|
|
|
|
|
|
if (!array)
|
|
|
|
{
|
|
|
|
source->args = array = xmalloc( sizeof(*array) );
|
|
|
|
*array = empty_strarray;
|
|
|
|
source->flags |= FLAG_SFD_FONTS;
|
|
|
|
}
|
|
|
|
strarray_add( array, xstrdup( strtok( NULL, "" )));
|
2014-02-05 12:15:07 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-11-11 11:23:38 +01:00
|
|
|
else if (!strcmp( flag, "implib" )) source->flags |= FLAG_C_IMPLIB;
|
2013-11-05 12:48:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* parse_cpp_directive
|
|
|
|
*/
|
2014-04-11 16:55:51 +02:00
|
|
|
static void parse_cpp_directive( struct file *source, char *str )
|
2013-11-05 12:48:16 +01:00
|
|
|
{
|
|
|
|
while (*str && isspace(*str)) str++;
|
|
|
|
if (*str++ != '#') return;
|
|
|
|
while (*str && isspace(*str)) str++;
|
|
|
|
|
|
|
|
if (!strncmp( str, "include", 7 ))
|
|
|
|
parse_include_directive( source, str + 7 );
|
|
|
|
else if (!strncmp( str, "import", 6 ) && strendswith( source->name, ".m" ))
|
|
|
|
parse_include_directive( source, str + 6 );
|
|
|
|
else if (!strncmp( str, "pragma", 6 ))
|
|
|
|
parse_pragma_directive( source, str + 6 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-10-23 18:59:13 +02:00
|
|
|
/*******************************************************************
|
2003-04-11 02:38:56 +02:00
|
|
|
* parse_idl_file
|
1996-10-23 18:59:13 +02:00
|
|
|
*/
|
2014-04-11 16:55:51 +02:00
|
|
|
static void parse_idl_file( struct file *source, FILE *file )
|
1996-10-23 18:59:13 +02:00
|
|
|
{
|
2006-08-01 12:16:29 +02:00
|
|
|
char *buffer, *include;
|
2000-11-06 06:32:59 +01:00
|
|
|
|
2013-10-14 11:11:07 +02:00
|
|
|
input_line = 0;
|
2006-09-10 22:04:42 +02:00
|
|
|
|
2006-08-01 12:16:29 +02:00
|
|
|
while ((buffer = get_line( file )))
|
2000-11-06 06:32:59 +01:00
|
|
|
{
|
2003-06-20 23:31:13 +02:00
|
|
|
char quote;
|
2003-04-11 02:38:56 +02:00
|
|
|
char *p = buffer;
|
|
|
|
while (*p && isspace(*p)) p++;
|
2003-06-20 23:31:13 +02:00
|
|
|
|
2015-11-05 06:25:35 +01:00
|
|
|
if (!strncmp( p, "importlib", 9 ))
|
|
|
|
{
|
|
|
|
p += 9;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (*p++ != '(') continue;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (*p++ != '"') continue;
|
|
|
|
include = p;
|
|
|
|
while (*p && (*p != '"')) p++;
|
|
|
|
if (!*p) fatal_error( "malformed importlib directive\n" );
|
|
|
|
*p = 0;
|
|
|
|
add_dependency( source, include, INCL_IMPORTLIB );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2003-06-20 23:31:13 +02:00
|
|
|
if (!strncmp( p, "import", 6 ))
|
|
|
|
{
|
|
|
|
p += 6;
|
|
|
|
while (*p && isspace(*p)) p++;
|
2006-09-10 22:04:42 +02:00
|
|
|
if (*p != '"') continue;
|
|
|
|
include = ++p;
|
|
|
|
while (*p && (*p != '"')) p++;
|
2013-10-14 11:11:07 +02:00
|
|
|
if (!*p) fatal_error( "malformed import directive\n" );
|
2006-09-10 22:04:42 +02:00
|
|
|
*p = 0;
|
2014-04-11 16:55:51 +02:00
|
|
|
add_dependency( source, include, INCL_IMPORT );
|
2006-09-10 22:04:42 +02:00
|
|
|
continue;
|
2003-06-20 23:31:13 +02:00
|
|
|
}
|
2006-09-10 22:04:42 +02:00
|
|
|
|
2014-04-11 16:55:51 +02:00
|
|
|
/* check for #include inside cpp_quote */
|
|
|
|
if (!strncmp( p, "cpp_quote", 9 ))
|
2003-06-20 23:31:13 +02:00
|
|
|
{
|
2006-09-10 22:04:42 +02:00
|
|
|
p += 9;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (*p++ != '(') continue;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (*p++ != '"') continue;
|
2003-06-20 23:31:13 +02: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 22:04:42 +02: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 11:11:07 +02:00
|
|
|
fatal_error( "malformed #include directive inside cpp_quote\n" );
|
2006-09-10 22:04:42 +02:00
|
|
|
if (quote == '"') p--; /* remove backslash */
|
|
|
|
*p = 0;
|
2014-04-11 16:55:51 +02:00
|
|
|
add_dependency( source, include, (quote == '>') ? INCL_CPP_QUOTE_SYSTEM : INCL_CPP_QUOTE );
|
2006-09-10 22:04:42 +02:00
|
|
|
continue;
|
2003-06-20 23:31:13 +02:00
|
|
|
}
|
|
|
|
|
2014-04-11 16:55:51 +02:00
|
|
|
parse_cpp_directive( source, p );
|
2000-11-06 06:32:59 +01:00
|
|
|
}
|
2003-04-11 02:38:56 +02:00
|
|
|
}
|
2000-11-06 06:32:59 +01:00
|
|
|
|
2003-04-11 02:38:56 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* parse_c_file
|
|
|
|
*/
|
2014-04-11 16:55:51 +02:00
|
|
|
static void parse_c_file( struct file *source, FILE *file )
|
2003-04-11 02:38:56 +02:00
|
|
|
{
|
2013-11-05 12:48:16 +01:00
|
|
|
char *buffer;
|
1996-10-23 18:59:13 +02:00
|
|
|
|
2006-08-01 12:16:29 +02:00
|
|
|
input_line = 0;
|
|
|
|
while ((buffer = get_line( file )))
|
1996-10-23 18:59:13 +02:00
|
|
|
{
|
2014-04-11 16:55:51 +02:00
|
|
|
parse_cpp_directive( source, buffer );
|
1996-10-23 18:59:13 +02:00
|
|
|
}
|
2003-04-11 02:38:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-26 15:02:03 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* parse_rc_file
|
|
|
|
*/
|
2014-04-11 16:55:51 +02:00
|
|
|
static void parse_rc_file( struct file *source, FILE *file )
|
2006-12-26 15:02:03 +01: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 11:11:07 +02:00
|
|
|
fatal_error( "malformed makedep comment\n" );
|
2006-12-26 15:02:03 +01:00
|
|
|
*p = 0;
|
2014-04-11 16:55:51 +02:00
|
|
|
add_dependency( source, include, (quote == '>') ? INCL_SYSTEM : INCL_NORMAL );
|
2013-11-05 12:48:16 +01:00
|
|
|
continue;
|
2006-12-26 15:02:03 +01:00
|
|
|
}
|
2013-11-05 12:48:16 +01:00
|
|
|
|
2014-04-11 16:55:51 +02:00
|
|
|
parse_cpp_directive( source, buffer );
|
2006-12-26 15:02:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-18 11:34:03 +01:00
|
|
|
/*******************************************************************
|
2013-12-12 20:04:53 +01:00
|
|
|
* parse_in_file
|
2013-11-18 11:34:03 +01:00
|
|
|
*/
|
2014-04-11 16:55:51 +02:00
|
|
|
static void parse_in_file( struct file *source, FILE *file )
|
2013-11-18 11:34:03 +01:00
|
|
|
{
|
|
|
|
char *p, *buffer;
|
|
|
|
|
|
|
|
/* make sure it gets rebuilt when the version changes */
|
2014-04-11 16:55:51 +02:00
|
|
|
add_dependency( source, "config.h", INCL_SYSTEM );
|
2013-11-18 11:34:03 +01:00
|
|
|
|
2014-04-11 16:55:51 +02:00
|
|
|
if (!strendswith( source->name, ".man.in" )) return; /* not a man page */
|
2013-12-12 20:04:53 +01:00
|
|
|
|
2013-11-18 11:34:03 +01:00
|
|
|
input_line = 0;
|
|
|
|
while ((buffer = get_line( file )))
|
|
|
|
{
|
|
|
|
if (strncmp( buffer, ".TH", 3 )) continue;
|
|
|
|
if (!(p = strtok( buffer, " \t" ))) continue; /* .TH */
|
|
|
|
if (!(p = strtok( NULL, " \t" ))) continue; /* program name */
|
|
|
|
if (!(p = strtok( NULL, " \t" ))) continue; /* man section */
|
2014-02-05 12:15:07 +01:00
|
|
|
source->args = xstrdup( p );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* parse_sfd_file
|
|
|
|
*/
|
2014-04-11 16:55:51 +02:00
|
|
|
static void parse_sfd_file( struct file *source, FILE *file )
|
2014-02-05 12:15:07 +01:00
|
|
|
{
|
|
|
|
char *p, *eol, *buffer;
|
|
|
|
|
|
|
|
input_line = 0;
|
|
|
|
while ((buffer = get_line( file )))
|
|
|
|
{
|
|
|
|
if (strncmp( buffer, "UComments:", 10 )) continue;
|
|
|
|
p = buffer + 10;
|
|
|
|
while (*p == ' ') p++;
|
|
|
|
if (p[0] == '"' && p[1] && buffer[strlen(buffer) - 1] == '"')
|
|
|
|
{
|
|
|
|
p++;
|
|
|
|
buffer[strlen(buffer) - 1] = 0;
|
|
|
|
}
|
|
|
|
while ((eol = strstr( p, "+AAoA" )))
|
|
|
|
{
|
|
|
|
*eol = 0;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (*p++ == '#')
|
|
|
|
{
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (!strncmp( p, "pragma", 6 )) parse_pragma_directive( source, p + 6 );
|
|
|
|
}
|
|
|
|
p = eol + 5;
|
|
|
|
}
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (*p++ != '#') return;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (!strncmp( p, "pragma", 6 )) parse_pragma_directive( source, p + 6 );
|
2013-11-18 11:34:03 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-02 07:53:42 +01:00
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
const char *ext;
|
|
|
|
void (*parse)( struct file *file, FILE *f );
|
|
|
|
} parse_functions[] =
|
|
|
|
{
|
|
|
|
{ ".c", parse_c_file },
|
|
|
|
{ ".h", parse_c_file },
|
|
|
|
{ ".inl", parse_c_file },
|
|
|
|
{ ".l", parse_c_file },
|
|
|
|
{ ".m", parse_c_file },
|
|
|
|
{ ".rh", parse_c_file },
|
|
|
|
{ ".x", parse_c_file },
|
|
|
|
{ ".y", parse_c_file },
|
|
|
|
{ ".idl", parse_idl_file },
|
|
|
|
{ ".rc", parse_rc_file },
|
|
|
|
{ ".in", parse_in_file },
|
|
|
|
{ ".sfd", parse_sfd_file }
|
|
|
|
};
|
|
|
|
|
2014-04-11 16:55:51 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* load_file
|
|
|
|
*/
|
|
|
|
static struct file *load_file( const char *name )
|
|
|
|
{
|
|
|
|
struct file *file;
|
|
|
|
FILE *f;
|
2015-11-02 07:53:42 +01:00
|
|
|
unsigned int i, hash = hash_filename( name );
|
2014-04-11 16:55:51 +02:00
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( file, &files[hash], struct file, entry )
|
|
|
|
if (!strcmp( name, file->name )) return file;
|
|
|
|
|
|
|
|
if (!(f = fopen( name, "r" ))) return NULL;
|
|
|
|
|
|
|
|
file = add_file( name );
|
2016-03-01 09:20:33 +01:00
|
|
|
list_add_tail( &files[hash], &file->entry );
|
2014-04-11 16:55:51 +02:00
|
|
|
input_file_name = file->name;
|
|
|
|
input_line = 0;
|
|
|
|
|
2015-11-02 07:53:42 +01:00
|
|
|
for (i = 0; i < sizeof(parse_functions) / sizeof(parse_functions[0]); i++)
|
|
|
|
{
|
|
|
|
if (!strendswith( name, parse_functions[i].ext )) continue;
|
|
|
|
parse_functions[i].parse( file, f );
|
|
|
|
break;
|
|
|
|
}
|
2014-04-11 16:55:51 +02:00
|
|
|
|
|
|
|
fclose( f );
|
|
|
|
input_file_name = NULL;
|
|
|
|
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
2015-11-11 07:01:43 +01:00
|
|
|
* open_include_path_file
|
|
|
|
*
|
|
|
|
* Open a file from a directory on the include path.
|
2014-04-11 16:55:51 +02:00
|
|
|
*/
|
2015-11-11 07:01:43 +01:00
|
|
|
static struct file *open_include_path_file( const struct makefile *make, const char *dir,
|
|
|
|
const char *name, char **filename )
|
2014-04-11 16:55:51 +02:00
|
|
|
{
|
2015-11-11 07:01:43 +01:00
|
|
|
char *src_path = base_dir_path( make, concat_paths( dir, name ));
|
|
|
|
struct file *ret = load_file( src_path );
|
2014-04-11 16:55:51 +02:00
|
|
|
|
2015-11-11 07:01:43 +01:00
|
|
|
if (ret) *filename = src_dir_path( make, concat_paths( dir, name ));
|
2014-04-11 16:55:51 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-11 03:54:46 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* open_file_same_dir
|
|
|
|
*
|
|
|
|
* Open a file in the same directory as the parent.
|
|
|
|
*/
|
|
|
|
static struct file *open_file_same_dir( const struct incl_file *parent, const char *name, char **filename )
|
|
|
|
{
|
|
|
|
char *src_path = replace_filename( parent->file->name, name );
|
|
|
|
struct file *ret = load_file( src_path );
|
|
|
|
|
|
|
|
if (ret) *filename = replace_filename( parent->filename, name );
|
|
|
|
free( src_path );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-11 16:55:51 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* open_local_file
|
|
|
|
*
|
|
|
|
* Open a file in the source directory of the makefile.
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static struct file *open_local_file( const struct makefile *make, const char *path, char **filename )
|
2014-04-11 16:55:51 +02:00
|
|
|
{
|
|
|
|
char *src_path = root_dir_path( base_dir_path( make, path ));
|
|
|
|
struct file *ret = load_file( src_path );
|
|
|
|
|
|
|
|
/* if not found, try parent dir */
|
|
|
|
if (!ret && make->parent_dir)
|
|
|
|
{
|
|
|
|
free( src_path );
|
|
|
|
path = strmake( "%s/%s", make->parent_dir, path );
|
|
|
|
src_path = root_dir_path( base_dir_path( make, path ));
|
|
|
|
ret = load_file( src_path );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret) *filename = src_dir_path( make, path );
|
|
|
|
free( src_path );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* open_global_file
|
|
|
|
*
|
|
|
|
* Open a file in the top-level source directory.
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static struct file *open_global_file( const struct makefile *make, const char *path, char **filename )
|
2014-04-11 16:55:51 +02:00
|
|
|
{
|
|
|
|
char *src_path = root_dir_path( path );
|
|
|
|
struct file *ret = load_file( src_path );
|
|
|
|
|
2016-03-31 07:39:32 +02:00
|
|
|
if (ret) *filename = top_src_dir_path( make, path );
|
2014-04-11 16:55:51 +02:00
|
|
|
free( src_path );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* open_global_header
|
|
|
|
*
|
|
|
|
* Open a file in the global include source directory.
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static struct file *open_global_header( const struct makefile *make, const char *path, char **filename )
|
2014-04-11 16:55:51 +02:00
|
|
|
{
|
|
|
|
return open_global_file( make, strmake( "include/%s", path ), filename );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* open_src_file
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static struct file *open_src_file( const struct makefile *make, struct incl_file *pFile )
|
2014-04-11 16:55:51 +02:00
|
|
|
{
|
|
|
|
struct file *file = open_local_file( make, pFile->name, &pFile->filename );
|
|
|
|
|
|
|
|
if (!file) fatal_perror( "open %s", pFile->name );
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* open_include_file
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static struct file *open_include_file( const struct makefile *make, struct incl_file *pFile )
|
2014-04-11 16:55:51 +02:00
|
|
|
{
|
|
|
|
struct file *file = NULL;
|
2015-11-11 03:54:46 +01:00
|
|
|
char *filename;
|
2014-04-11 16:55:51 +02:00
|
|
|
unsigned int i, len;
|
|
|
|
|
|
|
|
errno = ENOENT;
|
|
|
|
|
|
|
|
/* check for generated bison header */
|
|
|
|
|
|
|
|
if (strendswith( pFile->name, ".tab.h" ) &&
|
|
|
|
(file = open_local_file( make, replace_extension( pFile->name, ".tab.h", ".y" ), &filename )))
|
|
|
|
{
|
|
|
|
pFile->sourcename = filename;
|
|
|
|
pFile->filename = obj_dir_path( make, pFile->name );
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check for corresponding idl file in source dir */
|
|
|
|
|
|
|
|
if (strendswith( pFile->name, ".h" ) &&
|
|
|
|
(file = open_local_file( make, replace_extension( pFile->name, ".h", ".idl" ), &filename )))
|
|
|
|
{
|
|
|
|
pFile->sourcename = filename;
|
|
|
|
pFile->filename = obj_dir_path( make, pFile->name );
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
2015-11-05 06:25:35 +01:00
|
|
|
/* check for corresponding tlb file in source dir */
|
|
|
|
|
|
|
|
if (strendswith( pFile->name, ".tlb" ) &&
|
|
|
|
(file = open_local_file( make, replace_extension( pFile->name, ".tlb", ".idl" ), &filename )))
|
|
|
|
{
|
|
|
|
pFile->sourcename = filename;
|
|
|
|
pFile->filename = obj_dir_path( make, pFile->name );
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
2014-04-11 16:55:51 +02:00
|
|
|
/* now try in source dir */
|
|
|
|
if ((file = open_local_file( make, pFile->name, &pFile->filename ))) return file;
|
|
|
|
|
|
|
|
/* check for corresponding idl file in global includes */
|
|
|
|
|
|
|
|
if (strendswith( pFile->name, ".h" ) &&
|
|
|
|
(file = open_global_header( make, replace_extension( pFile->name, ".h", ".idl" ), &filename )))
|
|
|
|
{
|
|
|
|
pFile->sourcename = filename;
|
|
|
|
pFile->filename = top_obj_dir_path( make, strmake( "include/%s", pFile->name ));
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check for corresponding .in file in global includes (for config.h.in) */
|
|
|
|
|
|
|
|
if (strendswith( pFile->name, ".h" ) &&
|
|
|
|
(file = open_global_header( make, replace_extension( pFile->name, ".h", ".h.in" ), &filename )))
|
|
|
|
{
|
|
|
|
pFile->sourcename = filename;
|
|
|
|
pFile->filename = top_obj_dir_path( make, strmake( "include/%s", pFile->name ));
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check for corresponding .x file in global includes */
|
|
|
|
|
|
|
|
if (strendswith( pFile->name, "tmpl.h" ) &&
|
|
|
|
(file = open_global_header( make, replace_extension( pFile->name, ".h", ".x" ), &filename )))
|
|
|
|
{
|
|
|
|
pFile->sourcename = filename;
|
|
|
|
pFile->filename = top_obj_dir_path( make, strmake( "include/%s", pFile->name ));
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
2015-11-05 06:25:35 +01:00
|
|
|
/* check for corresponding .tlb file in global includes */
|
|
|
|
|
|
|
|
if (strendswith( pFile->name, ".tlb" ) &&
|
|
|
|
(file = open_global_header( make, replace_extension( pFile->name, ".tlb", ".idl" ), &filename )))
|
|
|
|
{
|
|
|
|
pFile->sourcename = filename;
|
|
|
|
pFile->filename = top_obj_dir_path( make, strmake( "include/%s", pFile->name ));
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
2014-04-11 16:55:51 +02:00
|
|
|
/* check in global includes source dir */
|
|
|
|
|
|
|
|
if ((file = open_global_header( make, pFile->name, &pFile->filename ))) return file;
|
|
|
|
|
|
|
|
/* check in global msvcrt includes */
|
|
|
|
if (make->use_msvcrt &&
|
|
|
|
(file = open_global_header( make, strmake( "msvcrt/%s", pFile->name ), &pFile->filename )))
|
|
|
|
return file;
|
|
|
|
|
|
|
|
/* now search in include paths */
|
2015-11-11 07:02:57 +01:00
|
|
|
for (i = 0; i < make->include_paths.count; i++)
|
2014-04-11 16:55:51 +02:00
|
|
|
{
|
2015-11-11 07:02:57 +01:00
|
|
|
const char *dir = make->include_paths.str[i];
|
2014-04-11 16:55:51 +02:00
|
|
|
const char *prefix = make->top_src_dir ? make->top_src_dir : make->top_obj_dir;
|
|
|
|
|
|
|
|
if (prefix)
|
|
|
|
{
|
|
|
|
len = strlen( prefix );
|
|
|
|
if (!strncmp( dir, prefix, len ) && (!dir[len] || dir[len] == '/'))
|
|
|
|
{
|
|
|
|
while (dir[len] == '/') len++;
|
|
|
|
file = open_global_file( make, concat_paths( dir + len, pFile->name ), &pFile->filename );
|
|
|
|
if (file) return file;
|
|
|
|
}
|
|
|
|
if (make->top_src_dir) continue; /* ignore paths that don't point to the top source dir */
|
|
|
|
}
|
|
|
|
if (*dir != '/')
|
|
|
|
{
|
2015-11-11 07:01:43 +01:00
|
|
|
if ((file = open_include_path_file( make, dir, pFile->name, &pFile->filename )))
|
2014-04-11 16:55:51 +02:00
|
|
|
return file;
|
|
|
|
}
|
|
|
|
}
|
2015-11-05 06:25:35 +01:00
|
|
|
if (pFile->type == INCL_SYSTEM) return NULL; /* ignore system files we cannot find */
|
2014-04-11 16:55:51 +02:00
|
|
|
|
|
|
|
/* try in src file directory */
|
2015-11-11 03:54:46 +01:00
|
|
|
if ((file = open_file_same_dir( pFile->included_by, pFile->name, &pFile->filename ))) return file;
|
2014-04-11 16:55:51 +02:00
|
|
|
|
|
|
|
fprintf( stderr, "%s:%d: error: ", pFile->included_by->file->name, pFile->included_line );
|
|
|
|
perror( pFile->name );
|
|
|
|
pFile = pFile->included_by;
|
|
|
|
while (pFile && pFile->included_by)
|
|
|
|
{
|
|
|
|
const char *parent = pFile->included_by->sourcename;
|
|
|
|
if (!parent) parent = pFile->included_by->file->name;
|
|
|
|
fprintf( stderr, "%s:%d: note: %s was first included here\n",
|
|
|
|
parent, pFile->included_line, pFile->name );
|
|
|
|
pFile = pFile->included_by;
|
|
|
|
}
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* add_all_includes
|
|
|
|
*/
|
2014-04-11 17:03:54 +02:00
|
|
|
static void add_all_includes( struct makefile *make, struct incl_file *parent, struct file *file )
|
2014-04-11 16:55:51 +02:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
parent->files_count = 0;
|
|
|
|
parent->files_size = file->deps_count;
|
|
|
|
parent->files = xmalloc( parent->files_size * sizeof(*parent->files) );
|
|
|
|
for (i = 0; i < file->deps_count; i++)
|
|
|
|
{
|
|
|
|
switch (file->deps[i].type)
|
|
|
|
{
|
|
|
|
case INCL_NORMAL:
|
|
|
|
case INCL_IMPORT:
|
2015-11-05 06:25:35 +01:00
|
|
|
add_include( make, parent, file->deps[i].name, file->deps[i].line, INCL_NORMAL );
|
|
|
|
break;
|
|
|
|
case INCL_IMPORTLIB:
|
|
|
|
add_include( make, parent, file->deps[i].name, file->deps[i].line, INCL_IMPORTLIB );
|
2014-04-11 16:55:51 +02:00
|
|
|
break;
|
|
|
|
case INCL_SYSTEM:
|
2015-11-05 06:25:35 +01:00
|
|
|
add_include( make, parent, file->deps[i].name, file->deps[i].line, INCL_SYSTEM );
|
2014-04-11 16:55:51 +02:00
|
|
|
break;
|
|
|
|
case INCL_CPP_QUOTE:
|
|
|
|
case INCL_CPP_QUOTE_SYSTEM:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-11 02:38:56 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* parse_file
|
|
|
|
*/
|
2014-04-10 13:41:23 +02:00
|
|
|
static void parse_file( struct makefile *make, struct incl_file *source, int src )
|
2003-04-11 02:38:56 +02:00
|
|
|
{
|
2015-11-05 06:25:35 +01:00
|
|
|
struct file *file = src ? open_src_file( make, source ) : open_include_file( make, source );
|
2006-10-16 17:19:07 +02:00
|
|
|
|
2003-04-11 02:38:56 +02:00
|
|
|
if (!file) return;
|
2014-04-11 16:55:51 +02:00
|
|
|
|
|
|
|
source->file = file;
|
|
|
|
source->files_count = 0;
|
|
|
|
source->files_size = file->deps_count;
|
|
|
|
source->files = xmalloc( source->files_size * sizeof(*source->files) );
|
|
|
|
|
|
|
|
if (source->sourcename)
|
|
|
|
{
|
|
|
|
if (strendswith( source->sourcename, ".idl" ))
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2015-11-05 06:25:35 +01:00
|
|
|
if (strendswith( source->name, ".tlb" )) return; /* typelibs don't include anything */
|
|
|
|
|
2014-04-11 16:55:51 +02:00
|
|
|
/* generated .h file always includes these */
|
2015-11-05 06:25:35 +01:00
|
|
|
add_include( make, source, "rpc.h", 0, INCL_NORMAL );
|
|
|
|
add_include( make, source, "rpcndr.h", 0, INCL_NORMAL );
|
2014-04-11 16:55:51 +02:00
|
|
|
for (i = 0; i < file->deps_count; i++)
|
|
|
|
{
|
|
|
|
switch (file->deps[i].type)
|
|
|
|
{
|
|
|
|
case INCL_IMPORT:
|
|
|
|
if (strendswith( file->deps[i].name, ".idl" ))
|
2014-04-11 17:03:54 +02:00
|
|
|
add_include( make, source, replace_extension( file->deps[i].name, ".idl", ".h" ),
|
2015-11-05 06:25:35 +01:00
|
|
|
file->deps[i].line, INCL_NORMAL );
|
2014-04-11 16:55:51 +02:00
|
|
|
else
|
2015-11-05 06:25:35 +01:00
|
|
|
add_include( make, source, file->deps[i].name, file->deps[i].line, INCL_NORMAL );
|
2014-04-11 16:55:51 +02:00
|
|
|
break;
|
|
|
|
case INCL_CPP_QUOTE:
|
2015-11-05 06:25:35 +01:00
|
|
|
add_include( make, source, file->deps[i].name, file->deps[i].line, INCL_NORMAL );
|
2014-04-11 16:55:51 +02:00
|
|
|
break;
|
|
|
|
case INCL_CPP_QUOTE_SYSTEM:
|
2015-11-05 06:25:35 +01:00
|
|
|
add_include( make, source, file->deps[i].name, file->deps[i].line, INCL_SYSTEM );
|
2014-04-11 16:55:51 +02:00
|
|
|
break;
|
|
|
|
case INCL_NORMAL:
|
|
|
|
case INCL_SYSTEM:
|
2015-11-05 06:25:35 +01:00
|
|
|
case INCL_IMPORTLIB:
|
2014-04-11 16:55:51 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (strendswith( source->sourcename, ".y" ))
|
|
|
|
return; /* generated .tab.h doesn't include anything */
|
|
|
|
}
|
|
|
|
|
2014-04-11 17:03:54 +02:00
|
|
|
add_all_includes( make, source, file );
|
1996-10-23 18:59:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-10 14:26:25 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* add_src_file
|
|
|
|
*
|
|
|
|
* Add a source file to the list.
|
|
|
|
*/
|
2014-04-10 13:41:23 +02:00
|
|
|
static struct incl_file *add_src_file( struct makefile *make, const char *name )
|
2007-12-10 14:26:25 +01:00
|
|
|
{
|
2013-10-14 10:51:37 +02:00
|
|
|
struct incl_file *file;
|
2007-12-10 14:26:25 +01:00
|
|
|
|
2014-04-10 13:50:37 +02:00
|
|
|
if ((file = find_src_file( make, name ))) return file; /* we already have it */
|
2007-12-10 14:26:25 +01:00
|
|
|
file = xmalloc( sizeof(*file) );
|
|
|
|
memset( file, 0, sizeof(*file) );
|
|
|
|
file->name = xstrdup(name);
|
2014-04-10 13:50:37 +02:00
|
|
|
list_add_tail( &make->sources, &file->entry );
|
2014-04-10 13:41:23 +02:00
|
|
|
parse_file( make, file, 1 );
|
2007-12-10 14:26:25 +01:00
|
|
|
return file;
|
2013-11-04 17:39:30 +01:00
|
|
|
}
|
2013-10-15 13:15:06 +02:00
|
|
|
|
2013-11-04 17:39:30 +01:00
|
|
|
|
2015-10-23 10:42:44 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* open_input_makefile
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static FILE *open_input_makefile( const struct makefile *make )
|
2015-10-23 10:42:44 +02:00
|
|
|
{
|
|
|
|
FILE *ret;
|
|
|
|
|
|
|
|
if (make->base_dir)
|
2015-11-13 10:56:41 +01:00
|
|
|
input_file_name = root_dir_path( base_dir_path( make, strmake( "%s.in", output_makefile_name )));
|
|
|
|
else
|
|
|
|
input_file_name = output_makefile_name; /* always use output name for main Makefile */
|
2015-10-23 10:42:44 +02:00
|
|
|
|
|
|
|
input_line = 0;
|
2015-11-11 04:05:12 +01:00
|
|
|
if (!(ret = fopen( input_file_name, "r" ))) fatal_perror( "open" );
|
2015-10-23 10:42:44 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-17 17:10:28 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* get_make_variable
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static const char *get_make_variable( const struct makefile *make, const char *name )
|
2013-12-17 17:10:28 +01:00
|
|
|
{
|
2015-11-10 04:07:37 +01:00
|
|
|
const char *ret;
|
2014-04-02 14:10:45 +02:00
|
|
|
|
2014-04-02 14:10:45 +02:00
|
|
|
if ((ret = strarray_get_value( &cmdline_vars, name ))) return ret;
|
2014-04-09 10:12:44 +02:00
|
|
|
if ((ret = strarray_get_value( &make->vars, name ))) return ret;
|
2014-04-10 13:41:23 +02:00
|
|
|
if (top_makefile && (ret = strarray_get_value( &top_makefile->vars, name ))) return ret;
|
2013-12-17 17:10:28 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* get_expanded_make_variable
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static char *get_expanded_make_variable( const struct makefile *make, const char *name )
|
2013-12-17 17:10:28 +01:00
|
|
|
{
|
2015-11-10 04:07:37 +01:00
|
|
|
const char *var;
|
|
|
|
char *p, *end, *expand, *tmp;
|
2013-12-17 17:10:28 +01:00
|
|
|
|
2015-11-10 04:07:37 +01:00
|
|
|
var = get_make_variable( make, name );
|
|
|
|
if (!var) return NULL;
|
2013-12-17 17:10:28 +01:00
|
|
|
|
2015-11-10 04:07:37 +01:00
|
|
|
p = expand = xstrdup( var );
|
2013-12-17 17:10:28 +01:00
|
|
|
while ((p = strchr( p, '$' )))
|
|
|
|
{
|
|
|
|
if (p[1] == '(')
|
|
|
|
{
|
|
|
|
if (!(end = strchr( p + 2, ')' ))) fatal_error( "syntax error in '%s'\n", expand );
|
|
|
|
*end++ = 0;
|
|
|
|
if (strchr( p + 2, ':' )) fatal_error( "pattern replacement not supported for '%s'\n", p + 2 );
|
2014-04-10 13:41:23 +02:00
|
|
|
var = get_make_variable( make, p + 2 );
|
2013-12-17 17:10:28 +01:00
|
|
|
tmp = replace_substr( expand, p, end - p, var ? var : "" );
|
2015-10-26 06:39:06 +01:00
|
|
|
/* switch to the new string */
|
|
|
|
p = tmp + (p - expand);
|
|
|
|
free( expand );
|
|
|
|
expand = tmp;
|
2013-12-17 17:10:28 +01:00
|
|
|
}
|
2014-01-04 20:33:57 +01:00
|
|
|
else if (p[1] == '{') /* don't expand ${} variables */
|
|
|
|
{
|
|
|
|
if (!(end = strchr( p + 2, '}' ))) fatal_error( "syntax error in '%s'\n", expand );
|
|
|
|
p = end + 1;
|
|
|
|
}
|
2013-12-17 17:10:28 +01:00
|
|
|
else if (p[1] == '$')
|
|
|
|
{
|
2015-10-26 06:39:06 +01:00
|
|
|
p += 2;
|
2013-12-17 17:10:28 +01:00
|
|
|
}
|
|
|
|
else fatal_error( "syntax error in '%s'\n", expand );
|
|
|
|
}
|
2013-12-26 19:25:57 +01:00
|
|
|
|
|
|
|
/* consider empty variables undefined */
|
|
|
|
p = expand;
|
|
|
|
while (*p && isspace(*p)) p++;
|
|
|
|
if (*p) return expand;
|
|
|
|
free( expand );
|
|
|
|
return NULL;
|
2013-12-17 17:10:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* get_expanded_make_var_array
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static struct strarray get_expanded_make_var_array( const struct makefile *make, const char *name )
|
2013-12-17 17:10:28 +01:00
|
|
|
{
|
2013-12-24 11:37:52 +01:00
|
|
|
struct strarray ret = empty_strarray;
|
2013-12-17 17:10:28 +01:00
|
|
|
char *value, *token;
|
|
|
|
|
2014-04-10 13:41:23 +02:00
|
|
|
if ((value = get_expanded_make_variable( make, name )))
|
2013-12-17 17:10:28 +01:00
|
|
|
for (token = strtok( value, " \t" ); token; token = strtok( NULL, " \t" ))
|
|
|
|
strarray_add( &ret, token );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-27 04:13:26 +01:00
|
|
|
/*******************************************************************
|
2016-02-23 07:03:50 +01:00
|
|
|
* get_expanded_file_local_var
|
2015-10-27 04:13:26 +01:00
|
|
|
*/
|
2016-02-23 07:03:50 +01:00
|
|
|
static struct strarray get_expanded_file_local_var( const struct makefile *make, const char *file,
|
|
|
|
const char *name )
|
2015-10-27 04:13:26 +01:00
|
|
|
{
|
2016-02-23 07:03:50 +01:00
|
|
|
char *p, *var = strmake( "%s_%s", file, name );
|
2015-10-27 04:13:26 +01:00
|
|
|
|
|
|
|
for (p = var; *p; p++) if (!isalnum( *p )) *p = '_';
|
2016-02-23 07:03:50 +01:00
|
|
|
return get_expanded_make_var_array( make, var );
|
2015-10-27 04:13:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-26 19:25:57 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* set_make_variable
|
|
|
|
*/
|
|
|
|
static int set_make_variable( struct strarray *array, const char *assignment )
|
|
|
|
{
|
|
|
|
char *p, *name;
|
|
|
|
|
|
|
|
p = name = xstrdup( assignment );
|
|
|
|
while (isalnum(*p) || *p == '_') p++;
|
|
|
|
if (name == p) return 0; /* not a variable */
|
|
|
|
if (isspace(*p))
|
|
|
|
{
|
|
|
|
*p++ = 0;
|
|
|
|
while (isspace(*p)) p++;
|
|
|
|
}
|
|
|
|
if (*p != '=') return 0; /* not an assignment */
|
|
|
|
*p++ = 0;
|
|
|
|
while (isspace(*p)) p++;
|
|
|
|
|
2014-04-02 14:10:45 +02:00
|
|
|
strarray_set_value( array, name, p );
|
2013-12-26 19:25:57 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-17 17:10:28 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* parse_makefile
|
|
|
|
*/
|
2016-02-25 09:08:12 +01:00
|
|
|
static struct makefile *parse_makefile( const char *path )
|
2013-12-17 17:10:28 +01:00
|
|
|
{
|
|
|
|
char *buffer;
|
|
|
|
FILE *file;
|
2014-04-10 13:41:23 +02:00
|
|
|
struct makefile *make = xmalloc( sizeof(*make) );
|
2013-12-17 17:10:28 +01:00
|
|
|
|
2014-04-10 13:41:23 +02:00
|
|
|
memset( make, 0, sizeof(*make) );
|
|
|
|
if (path)
|
|
|
|
{
|
|
|
|
make->top_obj_dir = get_relative_path( path, "" );
|
|
|
|
make->base_dir = path;
|
|
|
|
if (!strcmp( make->base_dir, "." )) make->base_dir = NULL;
|
|
|
|
}
|
|
|
|
|
2015-10-23 10:42:44 +02:00
|
|
|
file = open_input_makefile( make );
|
2013-12-17 17:10:28 +01:00
|
|
|
while ((buffer = get_line( file )))
|
|
|
|
{
|
2016-02-25 09:08:12 +01:00
|
|
|
if (!strncmp( buffer, separator, strlen(separator) )) break;
|
2013-12-26 19:25:57 +01:00
|
|
|
if (*buffer == '\t') continue; /* command */
|
|
|
|
while (isspace( *buffer )) buffer++;
|
|
|
|
if (*buffer == '#') continue; /* comment */
|
2014-04-10 13:41:23 +02:00
|
|
|
set_make_variable( &make->vars, buffer );
|
2013-12-17 17:10:28 +01:00
|
|
|
}
|
|
|
|
fclose( file );
|
|
|
|
input_file_name = NULL;
|
2014-04-10 13:41:23 +02:00
|
|
|
return make;
|
2013-12-17 17:10:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-26 19:27:59 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* add_generated_sources
|
|
|
|
*/
|
2014-04-10 13:41:23 +02:00
|
|
|
static void add_generated_sources( struct makefile *make )
|
2013-12-26 19:27:59 +01:00
|
|
|
{
|
|
|
|
struct incl_file *source, *next, *file;
|
|
|
|
|
2014-04-10 13:50:37 +02:00
|
|
|
LIST_FOR_EACH_ENTRY_SAFE( source, next, &make->sources, struct incl_file, entry )
|
2013-12-26 19:27:59 +01:00
|
|
|
{
|
2014-04-11 16:55:51 +02:00
|
|
|
if (source->file->flags & FLAG_IDL_CLIENT)
|
2013-12-26 19:27:59 +01:00
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
file = add_generated_source( make, replace_extension( source->name, ".idl", "_c.c" ), NULL );
|
2014-04-11 16:55:51 +02:00
|
|
|
add_dependency( file->file, replace_extension( source->name, ".idl", ".h" ), INCL_NORMAL );
|
2014-04-11 17:03:54 +02:00
|
|
|
add_all_includes( make, file, file->file );
|
2013-12-26 19:27:59 +01:00
|
|
|
}
|
2014-04-11 16:55:51 +02:00
|
|
|
if (source->file->flags & FLAG_IDL_SERVER)
|
2013-12-26 19:27:59 +01:00
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
file = add_generated_source( make, replace_extension( source->name, ".idl", "_s.c" ), NULL );
|
2014-04-11 16:55:51 +02:00
|
|
|
add_dependency( file->file, "wine/exception.h", INCL_NORMAL );
|
|
|
|
add_dependency( file->file, replace_extension( source->name, ".idl", ".h" ), INCL_NORMAL );
|
2014-04-11 17:03:54 +02:00
|
|
|
add_all_includes( make, file, file->file );
|
2013-12-26 19:27:59 +01:00
|
|
|
}
|
2014-04-11 16:55:51 +02:00
|
|
|
if (source->file->flags & FLAG_IDL_IDENT)
|
2013-12-26 19:27:59 +01:00
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
file = add_generated_source( make, replace_extension( source->name, ".idl", "_i.c" ), NULL );
|
2014-04-11 16:55:51 +02:00
|
|
|
add_dependency( file->file, "rpc.h", INCL_NORMAL );
|
|
|
|
add_dependency( file->file, "rpcndr.h", INCL_NORMAL );
|
|
|
|
add_dependency( file->file, "guiddef.h", INCL_NORMAL );
|
2014-04-11 17:03:54 +02:00
|
|
|
add_all_includes( make, file, file->file );
|
2013-12-26 19:27:59 +01:00
|
|
|
}
|
2014-04-11 16:55:51 +02:00
|
|
|
if (source->file->flags & FLAG_IDL_PROXY)
|
2013-12-26 19:27:59 +01:00
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
file = add_generated_source( make, "dlldata.o", "dlldata.c" );
|
2014-04-11 16:55:51 +02:00
|
|
|
add_dependency( file->file, "objbase.h", INCL_NORMAL );
|
|
|
|
add_dependency( file->file, "rpcproxy.h", INCL_NORMAL );
|
2014-04-11 17:03:54 +02:00
|
|
|
add_all_includes( make, file, file->file );
|
2014-04-10 13:41:23 +02:00
|
|
|
file = add_generated_source( make, replace_extension( source->name, ".idl", "_p.c" ), NULL );
|
2014-04-11 16:55:51 +02:00
|
|
|
add_dependency( file->file, "objbase.h", INCL_NORMAL );
|
|
|
|
add_dependency( file->file, "rpcproxy.h", INCL_NORMAL );
|
|
|
|
add_dependency( file->file, "wine/exception.h", INCL_NORMAL );
|
|
|
|
add_dependency( file->file, replace_extension( source->name, ".idl", ".h" ), INCL_NORMAL );
|
2014-04-11 17:03:54 +02:00
|
|
|
add_all_includes( make, file, file->file );
|
2013-12-26 19:27:59 +01:00
|
|
|
}
|
2015-11-05 06:25:35 +01:00
|
|
|
if (source->file->flags & FLAG_IDL_TYPELIB)
|
|
|
|
{
|
|
|
|
add_generated_source( make, replace_extension( source->name, ".idl", ".tlb" ), NULL );
|
|
|
|
}
|
2014-04-11 16:55:51 +02:00
|
|
|
if (source->file->flags & FLAG_IDL_REGTYPELIB)
|
2013-12-26 19:27:59 +01:00
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
add_generated_source( make, replace_extension( source->name, ".idl", "_t.res" ), NULL );
|
2013-12-26 19:27:59 +01:00
|
|
|
}
|
2014-04-11 16:55:51 +02:00
|
|
|
if (source->file->flags & FLAG_IDL_REGISTER)
|
2013-12-26 19:27:59 +01:00
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
add_generated_source( make, replace_extension( source->name, ".idl", "_r.res" ), NULL );
|
2013-12-26 19:27:59 +01:00
|
|
|
}
|
2015-11-05 06:25:35 +01:00
|
|
|
if (source->file->flags & FLAG_IDL_HEADER)
|
|
|
|
{
|
|
|
|
add_generated_source( make, replace_extension( source->name, ".idl", ".h" ), NULL );
|
|
|
|
}
|
2015-11-04 06:57:37 +01:00
|
|
|
if (!source->file->flags && strendswith( source->name, ".idl" ))
|
|
|
|
{
|
|
|
|
add_generated_source( make, replace_extension( source->name, ".idl", ".h" ), NULL );
|
|
|
|
}
|
2015-11-02 08:03:16 +01:00
|
|
|
if (strendswith( source->name, ".x" ))
|
|
|
|
{
|
|
|
|
add_generated_source( make, replace_extension( source->name, ".x", ".h" ), NULL );
|
|
|
|
}
|
2013-12-26 19:27:59 +01:00
|
|
|
if (strendswith( source->name, ".y" ))
|
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
file = add_generated_source( make, replace_extension( source->name, ".y", ".tab.c" ), NULL );
|
2014-01-04 12:25:56 +01:00
|
|
|
/* steal the includes list from the source file */
|
|
|
|
file->files_count = source->files_count;
|
|
|
|
file->files_size = source->files_size;
|
|
|
|
file->files = source->files;
|
|
|
|
source->files_count = source->files_size = 0;
|
|
|
|
source->files = NULL;
|
2013-12-26 19:27:59 +01:00
|
|
|
}
|
|
|
|
if (strendswith( source->name, ".l" ))
|
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
file = add_generated_source( make, replace_extension( source->name, ".l", ".yy.c" ), NULL );
|
2014-01-04 12:25:56 +01:00
|
|
|
/* steal the includes list from the source file */
|
|
|
|
file->files_count = source->files_count;
|
|
|
|
file->files_size = source->files_size;
|
|
|
|
file->files = source->files;
|
|
|
|
source->files_count = source->files_size = 0;
|
|
|
|
source->files = NULL;
|
2013-12-26 19:27:59 +01:00
|
|
|
}
|
2016-02-16 08:53:59 +01:00
|
|
|
if (source->file->flags & FLAG_C_IMPLIB)
|
|
|
|
{
|
|
|
|
if (!make->staticimplib && make->importlib && *dll_ext)
|
2016-03-25 07:31:54 +01:00
|
|
|
make->staticimplib = strmake( "lib%s.a", make->importlib );
|
2016-02-16 08:53:59 +01:00
|
|
|
}
|
2016-03-01 06:21:01 +01:00
|
|
|
if (strendswith( source->name, ".po" ))
|
|
|
|
{
|
|
|
|
if (!make->disabled)
|
|
|
|
strarray_add_uniq( &linguas, replace_extension( source->name, ".po", "" ));
|
|
|
|
}
|
2013-12-26 19:27:59 +01:00
|
|
|
}
|
2015-11-10 04:07:37 +01:00
|
|
|
if (make->testdll)
|
2013-12-26 19:27:59 +01:00
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
file = add_generated_source( make, "testlist.o", "testlist.c" );
|
2014-04-11 16:55:51 +02:00
|
|
|
add_dependency( file->file, "wine/test.h", INCL_NORMAL );
|
2014-04-11 17:03:54 +02:00
|
|
|
add_all_includes( make, file, file->file );
|
2013-12-26 19:27:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-14 21:20:25 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* create_dir
|
|
|
|
*/
|
|
|
|
static void create_dir( const char *dir )
|
|
|
|
{
|
|
|
|
char *p, *path;
|
|
|
|
|
|
|
|
p = path = xstrdup( dir );
|
|
|
|
while ((p = strchr( p, '/' )))
|
|
|
|
{
|
|
|
|
*p = 0;
|
|
|
|
if (mkdir( path, 0755 ) == -1 && errno != EEXIST) fatal_perror( "mkdir %s", path );
|
|
|
|
*p++ = '/';
|
|
|
|
while (*p == '/') p++;
|
|
|
|
}
|
|
|
|
if (mkdir( path, 0755 ) == -1 && errno != EEXIST) fatal_perror( "mkdir %s", path );
|
|
|
|
free( path );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-25 10:00:36 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* create_file_directories
|
|
|
|
*
|
|
|
|
* Create the base directories of all the files.
|
|
|
|
*/
|
|
|
|
static void create_file_directories( const struct makefile *make, struct strarray files )
|
|
|
|
{
|
|
|
|
struct strarray subdirs = empty_strarray;
|
|
|
|
unsigned int i;
|
|
|
|
char *dir;
|
|
|
|
|
|
|
|
for (i = 0; i < files.count; i++)
|
|
|
|
{
|
|
|
|
if (!strchr( files.str[i], '/' )) continue;
|
|
|
|
dir = base_dir_path( make, files.str[i] );
|
|
|
|
*strrchr( dir, '/' ) = 0;
|
|
|
|
strarray_add_uniq( &subdirs, dir );
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < subdirs.count; i++) create_dir( subdirs.str[i] );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-10 10:03:03 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* output_filenames_obj_dir
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static void output_filenames_obj_dir( const struct makefile *make, struct strarray array )
|
2014-04-10 10:03:03 +02:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2014-04-10 13:41:23 +02:00
|
|
|
for (i = 0; i < array.count; i++) output_filename( obj_dir_path( make, array.str[i] ));
|
2014-04-10 10:03:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-10-23 18:59:13 +02:00
|
|
|
/*******************************************************************
|
2015-11-05 06:25:35 +01:00
|
|
|
* get_dependencies
|
1996-10-23 18:59:13 +02:00
|
|
|
*/
|
2015-11-05 06:25:35 +01:00
|
|
|
static void get_dependencies( struct strarray *deps, struct incl_file *file, struct incl_file *source )
|
1996-10-23 18:59:13 +02:00
|
|
|
{
|
2015-11-05 06:25:35 +01:00
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (!file->filename) return;
|
1996-10-23 18:59:13 +02:00
|
|
|
|
2015-11-05 06:25:35 +01:00
|
|
|
if (file != source)
|
|
|
|
{
|
|
|
|
if (file->owner == source) return; /* already processed */
|
|
|
|
if (file->type == INCL_IMPORTLIB &&
|
|
|
|
!(source->file->flags & (FLAG_IDL_TYPELIB | FLAG_IDL_REGTYPELIB)))
|
|
|
|
return; /* library is imported only when building a typelib */
|
|
|
|
file->owner = source;
|
|
|
|
strarray_add( deps, file->filename );
|
|
|
|
}
|
|
|
|
for (i = 0; i < file->files_count; i++) get_dependencies( deps, file->files[i], source );
|
1996-10-23 18:59:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-13 06:17:18 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* get_local_dependencies
|
|
|
|
*
|
|
|
|
* Get the local dependencies of a given target.
|
|
|
|
*/
|
|
|
|
static struct strarray get_local_dependencies( const struct makefile *make, const char *name,
|
|
|
|
struct strarray targets )
|
|
|
|
{
|
|
|
|
unsigned int i;
|
2016-02-23 07:03:50 +01:00
|
|
|
struct strarray deps = get_expanded_file_local_var( make, name, "DEPS" );
|
2015-11-13 06:17:18 +01:00
|
|
|
|
|
|
|
for (i = 0; i < deps.count; i++)
|
|
|
|
{
|
|
|
|
if (strarray_exists( &targets, deps.str[i] ))
|
|
|
|
deps.str[i] = obj_dir_path( make, deps.str[i] );
|
|
|
|
else
|
|
|
|
deps.str[i] = src_dir_path( make, deps.str[i] );
|
|
|
|
}
|
|
|
|
return deps;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-23 06:57:11 +01:00
|
|
|
/*******************************************************************
|
2016-03-25 07:19:53 +01:00
|
|
|
* get_static_lib
|
2016-02-23 06:57:11 +01:00
|
|
|
*
|
2016-03-25 07:19:53 +01:00
|
|
|
* Check if makefile builds the named static library and return the full lib path.
|
2016-02-23 06:57:11 +01:00
|
|
|
*/
|
2016-03-25 07:19:53 +01:00
|
|
|
static const char *get_static_lib( const struct makefile *make, const char *name )
|
2016-02-23 06:57:11 +01:00
|
|
|
{
|
2016-03-25 07:19:53 +01:00
|
|
|
if (!make->staticlib) return NULL;
|
|
|
|
if (strncmp( make->staticlib, "lib", 3 )) return NULL;
|
|
|
|
if (strncmp( make->staticlib + 3, name, strlen(name) )) return NULL;
|
|
|
|
if (strcmp( make->staticlib + 3 + strlen(name), ".a" )) return NULL;
|
|
|
|
return base_dir_path( make, make->staticlib );
|
2016-02-23 06:57:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* add_default_libraries
|
|
|
|
*/
|
|
|
|
static struct strarray add_default_libraries( const struct makefile *make, struct strarray *deps )
|
|
|
|
{
|
|
|
|
struct strarray ret = empty_strarray;
|
|
|
|
struct strarray all_libs = empty_strarray;
|
|
|
|
unsigned int i, j;
|
|
|
|
|
|
|
|
strarray_add( &all_libs, "-lwine_port" );
|
|
|
|
strarray_addall( &all_libs, get_expanded_make_var_array( make, "EXTRALIBS" ));
|
|
|
|
strarray_addall( &all_libs, libs );
|
|
|
|
|
|
|
|
for (i = 0; i < all_libs.count; i++)
|
|
|
|
{
|
2016-03-25 07:19:53 +01:00
|
|
|
const char *lib = NULL;
|
|
|
|
|
2016-02-23 06:57:11 +01:00
|
|
|
if (!strncmp( all_libs.str[i], "-l", 2 ))
|
|
|
|
{
|
|
|
|
const char *name = all_libs.str[i] + 2;
|
|
|
|
|
|
|
|
for (j = 0; j < top_makefile->subdirs.count; j++)
|
|
|
|
{
|
|
|
|
const struct makefile *submake = top_makefile->submakes[j];
|
|
|
|
|
2016-03-25 07:19:53 +01:00
|
|
|
if ((lib = get_static_lib( submake, name ))) break;
|
2016-02-23 06:57:11 +01:00
|
|
|
}
|
|
|
|
}
|
2016-03-25 07:19:53 +01:00
|
|
|
|
|
|
|
if (lib)
|
|
|
|
{
|
|
|
|
lib = top_obj_dir_path( make, lib );
|
|
|
|
strarray_add( deps, lib );
|
|
|
|
strarray_add( &ret, lib );
|
|
|
|
}
|
|
|
|
else strarray_add( &ret, all_libs.str[i] );
|
2016-02-23 06:57:11 +01:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-16 08:53:59 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* add_import_libs
|
|
|
|
*/
|
|
|
|
static struct strarray add_import_libs( const struct makefile *make, struct strarray *deps,
|
|
|
|
struct strarray imports, int cross )
|
|
|
|
{
|
|
|
|
struct strarray ret = empty_strarray;
|
|
|
|
unsigned int i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < imports.count; i++)
|
|
|
|
{
|
|
|
|
const char *name = imports.str[i];
|
2016-03-25 07:19:53 +01:00
|
|
|
const char *lib = NULL;
|
2016-02-16 08:53:59 +01:00
|
|
|
|
|
|
|
for (j = 0; j < top_makefile->subdirs.count; j++)
|
|
|
|
{
|
|
|
|
const struct makefile *submake = top_makefile->submakes[j];
|
|
|
|
|
|
|
|
if (submake->importlib && !strcmp( submake->importlib, name ))
|
|
|
|
{
|
2016-03-26 06:57:39 +01:00
|
|
|
if (cross || !*dll_ext || submake->staticimplib)
|
|
|
|
lib = base_dir_path( submake, strmake( "lib%s.a", name ));
|
2016-03-25 07:31:54 +01:00
|
|
|
else
|
2016-03-26 06:57:39 +01:00
|
|
|
strarray_add( deps, top_obj_dir_path( make,
|
|
|
|
strmake( "%s/lib%s.def", submake->base_dir, name )));
|
2016-02-16 08:53:59 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-03-25 07:19:53 +01:00
|
|
|
if ((lib = get_static_lib( submake, name ))) break;
|
|
|
|
}
|
2016-02-16 08:53:59 +01:00
|
|
|
|
2016-03-25 07:19:53 +01:00
|
|
|
if (lib)
|
|
|
|
{
|
2016-03-26 06:57:39 +01:00
|
|
|
if (cross) lib = replace_extension( lib, ".a", ".cross.a" );
|
2016-03-25 07:19:53 +01:00
|
|
|
lib = top_obj_dir_path( make, lib );
|
|
|
|
strarray_add( deps, lib );
|
|
|
|
strarray_add( &ret, lib );
|
2016-02-16 08:53:59 +01:00
|
|
|
}
|
2016-03-25 07:19:53 +01:00
|
|
|
else strarray_add( &ret, strmake( "-l%s", name ));
|
2016-02-16 08:53:59 +01:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-23 12:21:47 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* get_default_imports
|
|
|
|
*/
|
|
|
|
static struct strarray get_default_imports( const struct makefile *make )
|
|
|
|
{
|
|
|
|
struct strarray ret = empty_strarray;
|
|
|
|
|
|
|
|
if (strarray_exists( &make->extradllflags, "-nodefaultlibs" )) return ret;
|
|
|
|
if (strarray_exists( &make->appmode, "-mno-cygwin" )) strarray_add( &ret, "msvcrt" );
|
|
|
|
if (make->is_win16) strarray_add( &ret, "kernel" );
|
|
|
|
strarray_add( &ret, "kernel32" );
|
|
|
|
strarray_add( &ret, "ntdll" );
|
|
|
|
strarray_add( &ret, "winecrt0" );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-29 06:32:45 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* add_install_rule
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static void add_install_rule( const struct makefile *make, struct strarray *install_rules,
|
2015-11-10 04:03:52 +01:00
|
|
|
const char *target, const char *file, const char *dest )
|
2015-10-29 06:32:45 +01:00
|
|
|
{
|
|
|
|
if (strarray_exists( &make->install_lib, target ))
|
|
|
|
{
|
2015-11-10 04:03:52 +01:00
|
|
|
strarray_add( &install_rules[INSTALL_LIB], file );
|
|
|
|
strarray_add( &install_rules[INSTALL_LIB], dest );
|
2015-10-29 06:32:45 +01:00
|
|
|
}
|
|
|
|
else if (strarray_exists( &make->install_dev, target ))
|
|
|
|
{
|
2015-11-10 04:03:52 +01:00
|
|
|
strarray_add( &install_rules[INSTALL_DEV], file );
|
|
|
|
strarray_add( &install_rules[INSTALL_DEV], dest );
|
2015-10-29 06:32:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-02 07:53:42 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* get_include_install_path
|
|
|
|
*
|
|
|
|
* Determine the installation path for a given include file.
|
|
|
|
*/
|
|
|
|
static const char *get_include_install_path( const char *name )
|
|
|
|
{
|
|
|
|
if (!strncmp( name, "wine/", 5 )) return name + 5;
|
|
|
|
if (!strncmp( name, "msvcrt/", 7 )) return name;
|
|
|
|
return strmake( "windows/%s", name );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-12 14:08:03 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* get_shared_library_name
|
|
|
|
*
|
|
|
|
* Determine possible names for a shared library with a version number.
|
|
|
|
*/
|
|
|
|
static struct strarray get_shared_lib_names( const char *libname )
|
|
|
|
{
|
|
|
|
struct strarray ret = empty_strarray;
|
|
|
|
const char *ext, *p;
|
|
|
|
char *name, *first, *second;
|
|
|
|
size_t len = 0;
|
|
|
|
|
|
|
|
strarray_add( &ret, libname );
|
|
|
|
|
|
|
|
for (p = libname; (p = strchr( p, '.' )); p++)
|
|
|
|
if ((len = strspn( p + 1, "0123456789." ))) break;
|
|
|
|
|
|
|
|
if (!len) return ret;
|
|
|
|
ext = p + 1 + len;
|
|
|
|
if (*ext && ext[-1] == '.') ext--;
|
|
|
|
|
|
|
|
/* keep only the first group of digits */
|
|
|
|
name = xstrdup( libname );
|
|
|
|
first = name + (p - libname);
|
|
|
|
if ((second = strchr( first + 1, '.' )))
|
|
|
|
{
|
|
|
|
strcpy( second, ext );
|
|
|
|
strarray_add( &ret, xstrdup( name ));
|
|
|
|
}
|
|
|
|
/* now remove all digits */
|
|
|
|
strcpy( first, ext );
|
|
|
|
strarray_add( &ret, name );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-06 06:54:13 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* output_symlink_rule
|
|
|
|
*
|
|
|
|
* Output a rule to create a symlink.
|
|
|
|
*/
|
|
|
|
static void output_symlink_rule( const char *src_name, const char *link_name )
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
output( "\trm -f %s && ", link_name );
|
|
|
|
|
|
|
|
/* dest path with a directory needs special handling if ln -s isn't supported */
|
|
|
|
if (strcmp( ln_s, "ln -s" ) && ((name = strrchr( link_name, '/' ))))
|
|
|
|
{
|
|
|
|
char *dir = xstrdup( link_name );
|
|
|
|
dir[name - link_name] = 0;
|
|
|
|
output( "cd %s && %s %s %s\n", *dir ? dir : "/", ln_s, src_name, name + 1 );
|
|
|
|
free( dir );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
output( "%s %s %s\n", ln_s, src_name, link_name );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-29 06:32:45 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* output_install_rules
|
|
|
|
*
|
|
|
|
* Rules are stored as a (file,dest) pair of values.
|
|
|
|
* The first char of dest indicates the type of install.
|
|
|
|
*/
|
2015-11-12 14:43:02 +01:00
|
|
|
static struct strarray output_install_rules( const struct makefile *make, struct strarray files,
|
|
|
|
const char *target, struct strarray *phony_targets )
|
2015-10-29 06:32:45 +01:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
char *install_sh;
|
2015-11-12 14:43:02 +01:00
|
|
|
struct strarray uninstall = empty_strarray;
|
2015-10-29 06:32:45 +01:00
|
|
|
struct strarray targets = empty_strarray;
|
|
|
|
|
2015-11-12 14:43:02 +01:00
|
|
|
if (!files.count) return uninstall;
|
2015-10-29 06:32:45 +01:00
|
|
|
|
|
|
|
for (i = 0; i < files.count; i += 2)
|
2016-04-04 06:59:54 +02:00
|
|
|
{
|
|
|
|
const char *file = files.str[i];
|
|
|
|
switch (*files.str[i + 1])
|
|
|
|
{
|
|
|
|
case 'd': /* data file */
|
|
|
|
case 'p': /* program file */
|
|
|
|
case 's': /* script */
|
|
|
|
strarray_add_uniq( &targets, obj_dir_path( make, file ));
|
|
|
|
break;
|
|
|
|
case 't': /* script in tools dir */
|
|
|
|
strarray_add_uniq( &targets, tools_dir_path( make, file ));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-10-29 06:32:45 +01:00
|
|
|
|
|
|
|
output( "install %s::", target );
|
2016-04-04 06:59:54 +02:00
|
|
|
output_filenames( targets );
|
2015-10-29 06:32:45 +01:00
|
|
|
output( "\n" );
|
|
|
|
|
2016-03-31 07:39:32 +02:00
|
|
|
install_sh = top_src_dir_path( make, "tools/install-sh" );
|
2015-10-29 06:32:45 +01:00
|
|
|
for (i = 0; i < files.count; i += 2)
|
|
|
|
{
|
|
|
|
const char *file = files.str[i];
|
2016-04-04 06:59:54 +02:00
|
|
|
const char *dest = strmake( "$(DESTDIR)%s", files.str[i + 1] + 1 );
|
2015-10-29 06:32:45 +01:00
|
|
|
|
2016-04-04 06:59:54 +02:00
|
|
|
switch (*files.str[i + 1])
|
2015-10-29 06:32:45 +01:00
|
|
|
{
|
|
|
|
case 'd': /* data file */
|
2016-04-04 06:59:54 +02:00
|
|
|
output( "\t%s -m 644 $(INSTALL_DATA_FLAGS) %s %s\n",
|
|
|
|
install_sh, obj_dir_path( make, file ), dest );
|
2015-10-29 06:32:45 +01:00
|
|
|
break;
|
|
|
|
case 'D': /* data file in source dir */
|
2016-04-04 06:59:54 +02:00
|
|
|
output( "\t%s -m 644 $(INSTALL_DATA_FLAGS) %s %s\n",
|
|
|
|
install_sh, src_dir_path( make, file ), dest );
|
2015-10-29 06:32:45 +01:00
|
|
|
break;
|
|
|
|
case 'p': /* program file */
|
2016-04-04 06:59:54 +02:00
|
|
|
output( "\tSTRIPPROG=\"$(STRIP)\" %s $(INSTALL_PROGRAM_FLAGS) %s %s\n",
|
|
|
|
install_sh, obj_dir_path( make, file ), dest );
|
2015-10-29 06:32:45 +01:00
|
|
|
break;
|
|
|
|
case 's': /* script */
|
2016-04-04 06:59:54 +02:00
|
|
|
output( "\t%s $(INSTALL_SCRIPT_FLAGS) %s %s\n",
|
|
|
|
install_sh, obj_dir_path( make, file ), dest );
|
2015-10-29 06:32:45 +01:00
|
|
|
break;
|
|
|
|
case 'S': /* script in source dir */
|
2016-04-04 06:59:54 +02:00
|
|
|
output( "\t%s $(INSTALL_SCRIPT_FLAGS) %s %s\n",
|
|
|
|
install_sh, src_dir_path( make, file ), dest );
|
|
|
|
break;
|
|
|
|
case 't': /* script in tools dir */
|
|
|
|
output( "\t%s $(INSTALL_SCRIPT_FLAGS) %s %s\n",
|
|
|
|
install_sh, tools_dir_path( make, file ), dest );
|
2015-10-29 06:32:45 +01:00
|
|
|
break;
|
2015-10-29 10:06:35 +01:00
|
|
|
case 'y': /* symlink */
|
2016-05-06 06:54:13 +02:00
|
|
|
output_symlink_rule( file, dest );
|
2015-10-29 10:06:35 +01:00
|
|
|
break;
|
2015-10-29 06:32:45 +01:00
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
}
|
2016-04-04 06:59:54 +02:00
|
|
|
strarray_add( &uninstall, dest );
|
2015-10-29 06:32:45 +01:00
|
|
|
}
|
|
|
|
|
2015-11-12 14:43:02 +01:00
|
|
|
strarray_add_uniq( phony_targets, "install" );
|
|
|
|
strarray_add_uniq( phony_targets, target );
|
|
|
|
return uninstall;
|
2015-10-29 06:32:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-26 07:10:06 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* output_importlib_symlinks
|
|
|
|
*/
|
|
|
|
static struct strarray output_importlib_symlinks( const struct makefile *parent,
|
|
|
|
const struct makefile *make )
|
|
|
|
{
|
|
|
|
struct strarray ret = empty_strarray;
|
2016-05-06 06:54:13 +02:00
|
|
|
const char *lib, *dst;
|
2016-02-26 07:10:06 +01:00
|
|
|
|
|
|
|
if (!make->module) return ret;
|
|
|
|
if (!make->importlib) return ret;
|
2016-02-29 07:06:42 +01:00
|
|
|
if (make->is_win16 && make->disabled) return ret;
|
2016-02-26 07:10:06 +01:00
|
|
|
if (strncmp( make->base_dir, "dlls/", 5 )) return ret;
|
|
|
|
if (!strcmp( make->module, make->importlib )) return ret;
|
|
|
|
if (!strchr( make->importlib, '.' ) &&
|
|
|
|
!strncmp( make->module, make->importlib, strlen( make->importlib )) &&
|
|
|
|
!strcmp( make->module + strlen( make->importlib ), ".dll" ))
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
lib = strmake( "lib%s.%s", make->importlib, *dll_ext ? "def" : "a" );
|
2016-05-06 06:54:13 +02:00
|
|
|
dst = concat_paths( obj_dir_path( parent, "dlls" ), lib );
|
|
|
|
output( "%s: %s\n", dst, base_dir_path( make, lib ));
|
|
|
|
output_symlink_rule( concat_paths( make->base_dir + strlen("dlls/"), lib ), dst );
|
|
|
|
strarray_add( &ret, dst );
|
2016-02-26 07:10:06 +01:00
|
|
|
|
|
|
|
if (crosstarget && !make->is_win16)
|
|
|
|
{
|
|
|
|
lib = strmake( "lib%s.cross.a", make->importlib );
|
2016-05-06 06:54:13 +02:00
|
|
|
dst = concat_paths( obj_dir_path( parent, "dlls" ), lib );
|
|
|
|
output( "%s: %s\n", dst, base_dir_path( make, lib ));
|
|
|
|
output_symlink_rule( concat_paths( make->base_dir + strlen("dlls/"), lib ), dst );
|
|
|
|
strarray_add( &ret, dst );
|
2016-02-26 07:10:06 +01:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-25 07:36:02 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* output_po_files
|
|
|
|
*/
|
|
|
|
static void output_po_files( const struct makefile *make )
|
|
|
|
{
|
|
|
|
const char *po_dir = src_dir_path( make, "po" );
|
|
|
|
struct strarray pot_files = empty_strarray;
|
|
|
|
struct incl_file *source;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < make->subdirs.count; i++)
|
|
|
|
{
|
|
|
|
struct makefile *submake = make->submakes[i];
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( source, &submake->sources, struct incl_file, entry )
|
|
|
|
{
|
|
|
|
if (strendswith( source->name, ".rc" ) && (source->file->flags & FLAG_RC_PO))
|
|
|
|
{
|
|
|
|
char *pot_file = replace_extension( source->name, ".rc", ".pot" );
|
|
|
|
char *pot_path = base_dir_path( submake, pot_file );
|
|
|
|
output( "%s: tools/wrc include dummy\n", pot_path );
|
|
|
|
output( "\t@cd %s && $(MAKE) %s\n", base_dir_path( submake, "" ), pot_file );
|
|
|
|
strarray_add( &pot_files, pot_path );
|
|
|
|
}
|
|
|
|
else if (strendswith( source->name, ".mc" ))
|
|
|
|
{
|
|
|
|
char *pot_file = replace_extension( source->name, ".mc", ".pot" );
|
|
|
|
char *pot_path = base_dir_path( submake, pot_file );
|
|
|
|
output( "%s: tools/wmc include dummy\n", pot_path );
|
|
|
|
output( "\t@cd %s && $(MAKE) %s\n", base_dir_path( submake, "" ), pot_file );
|
|
|
|
strarray_add( &pot_files, pot_path );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (linguas.count)
|
|
|
|
{
|
|
|
|
for (i = 0; i < linguas.count; i++)
|
|
|
|
output_filename( strmake( "%s/%s.po", po_dir, linguas.str[i] ));
|
|
|
|
output( ": %s/wine.pot\n", po_dir );
|
|
|
|
output( "\tmsgmerge --previous -q $@ %s/wine.pot | msgattrib --no-obsolete -o $@.new && mv $@.new $@\n",
|
|
|
|
po_dir );
|
2016-03-01 06:30:24 +01:00
|
|
|
output( "po:" );
|
|
|
|
for (i = 0; i < linguas.count; i++)
|
|
|
|
output_filename( strmake( "%s/%s.po", po_dir, linguas.str[i] ));
|
|
|
|
output( "\n" );
|
2016-02-25 07:36:02 +01:00
|
|
|
}
|
|
|
|
output( "%s/wine.pot:", po_dir );
|
|
|
|
output_filenames( pot_files );
|
|
|
|
output( "\n" );
|
|
|
|
output( "\tmsgcat -o $@" );
|
|
|
|
output_filenames( pot_files );
|
|
|
|
output( "\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-09-28 19:43:24 +02:00
|
|
|
/*******************************************************************
|
2013-10-14 11:11:07 +02:00
|
|
|
* output_sources
|
1997-09-28 19:43:24 +02:00
|
|
|
*/
|
2016-01-11 10:19:18 +01:00
|
|
|
static struct strarray output_sources( const struct makefile *make )
|
1997-09-28 19:43:24 +02:00
|
|
|
{
|
2013-10-14 11:11:07 +02:00
|
|
|
struct incl_file *source;
|
2015-10-29 10:06:35 +01:00
|
|
|
unsigned int i, j;
|
2013-12-30 20:07:02 +01:00
|
|
|
struct strarray object_files = empty_strarray;
|
|
|
|
struct strarray crossobj_files = empty_strarray;
|
|
|
|
struct strarray res_files = empty_strarray;
|
2013-12-24 11:37:52 +01:00
|
|
|
struct strarray clean_files = empty_strarray;
|
2015-11-12 14:43:02 +01:00
|
|
|
struct strarray uninstall_files = empty_strarray;
|
2014-01-14 11:49:42 +01:00
|
|
|
struct strarray mo_files = empty_strarray;
|
2014-02-10 10:55:18 +01:00
|
|
|
struct strarray ok_files = empty_strarray;
|
2015-11-13 06:17:18 +01:00
|
|
|
struct strarray in_files = empty_strarray;
|
2013-12-27 14:26:37 +01:00
|
|
|
struct strarray dlldata_files = empty_strarray;
|
2013-12-30 20:23:16 +01:00
|
|
|
struct strarray c2man_files = empty_strarray;
|
2013-12-30 20:14:45 +01:00
|
|
|
struct strarray implib_objs = empty_strarray;
|
2013-12-26 21:51:38 +01:00
|
|
|
struct strarray includes = empty_strarray;
|
2013-12-28 11:41:45 +01:00
|
|
|
struct strarray phony_targets = empty_strarray;
|
2015-10-27 04:13:26 +01:00
|
|
|
struct strarray all_targets = empty_strarray;
|
2015-11-10 04:03:52 +01:00
|
|
|
struct strarray install_rules[NB_INSTALL_RULES];
|
2015-10-28 02:56:21 +01:00
|
|
|
char *ldrpath_local = get_expanded_make_variable( make, "LDRPATH_LOCAL" );
|
|
|
|
char *ldrpath_install = get_expanded_make_variable( make, "LDRPATH_INSTALL" );
|
2013-11-09 18:57:00 +01:00
|
|
|
|
2015-11-10 04:03:52 +01:00
|
|
|
for (i = 0; i < NB_INSTALL_RULES; i++) install_rules[i] = empty_strarray;
|
|
|
|
|
2014-01-14 11:49:42 +01:00
|
|
|
for (i = 0; i < linguas.count; i++)
|
2014-04-10 13:41:23 +02:00
|
|
|
strarray_add( &mo_files, strmake( "%s/%s.mo", top_obj_dir_path( make, "po" ), linguas.str[i] ));
|
2014-01-14 11:49:42 +01:00
|
|
|
|
2015-10-23 07:49:36 +02:00
|
|
|
strarray_add( &phony_targets, "all" );
|
2014-04-10 13:41:23 +02:00
|
|
|
strarray_add( &includes, strmake( "-I%s", obj_dir_path( make, "" )));
|
2014-04-09 10:12:44 +02:00
|
|
|
if (make->src_dir) strarray_add( &includes, strmake( "-I%s", make->src_dir ));
|
2014-04-10 13:41:23 +02:00
|
|
|
if (make->parent_dir) strarray_add( &includes, strmake( "-I%s", src_dir_path( make, make->parent_dir )));
|
2015-11-11 07:02:57 +01:00
|
|
|
strarray_add( &includes, strmake( "-I%s", top_obj_dir_path( make, "include" )));
|
2016-03-31 07:39:32 +02:00
|
|
|
if (make->top_src_dir)
|
|
|
|
strarray_add( &includes, strmake( "-I%s", top_src_dir_path( make, "include" )));
|
|
|
|
if (make->use_msvcrt)
|
|
|
|
strarray_add( &includes, strmake( "-I%s", top_src_dir_path( make, "include/msvcrt" )));
|
2015-11-11 07:02:57 +01:00
|
|
|
for (i = 0; i < make->include_paths.count; i++)
|
|
|
|
strarray_add( &includes, strmake( "-I%s", obj_dir_path( make, make->include_paths.str[i] )));
|
2013-11-19 13:03:55 +01:00
|
|
|
|
2014-04-10 13:50:37 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( source, &make->sources, struct incl_file, entry )
|
1997-09-28 19:43:24 +02:00
|
|
|
{
|
2015-11-05 06:25:35 +01:00
|
|
|
struct strarray dependencies = empty_strarray;
|
2014-01-07 12:20:25 +01:00
|
|
|
struct strarray extradefs;
|
2013-10-14 11:11:07 +02: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 23:39:39 +02:00
|
|
|
*ext++ = 0;
|
2013-10-14 11:11:07 +02:00
|
|
|
|
2016-02-23 07:03:50 +01:00
|
|
|
extradefs = get_expanded_file_local_var( make, obj, "EXTRADEFS" );
|
2015-11-05 06:25:35 +01:00
|
|
|
get_dependencies( &dependencies, source, source );
|
2014-01-07 12:20:25 +01:00
|
|
|
|
2000-10-23 23:39:39 +02:00
|
|
|
if (!strcmp( ext, "y" )) /* yacc file */
|
1997-09-28 19:43:24 +02:00
|
|
|
{
|
2010-03-16 13:27:51 +01:00
|
|
|
/* add source file dependency for parallel makes */
|
|
|
|
char *header = strmake( "%s.tab.h", obj );
|
2013-11-09 18:57:00 +01:00
|
|
|
|
2014-04-11 17:03:54 +02:00
|
|
|
if (find_include_file( make, header ))
|
2013-10-14 19:52:52 +02:00
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s: %s\n", obj_dir_path( make, header ), source->filename );
|
2014-01-14 11:45:54 +01:00
|
|
|
output( "\t$(BISON) -p %s_ -o %s.tab.c -d %s\n",
|
2014-04-10 13:41:23 +02:00
|
|
|
obj, obj_dir_path( make, obj ), source->filename );
|
|
|
|
output( "%s.tab.c: %s %s\n", obj_dir_path( make, obj ),
|
|
|
|
source->filename, obj_dir_path( make, header ));
|
2014-04-10 10:03:03 +02:00
|
|
|
strarray_add( &clean_files, header );
|
2013-10-14 19:52:52 +02:00
|
|
|
}
|
2014-01-08 16:04:33 +01:00
|
|
|
else output( "%s.tab.c: %s\n", obj, source->filename );
|
2013-10-14 19:52:52 +02:00
|
|
|
|
2014-01-14 11:45:54 +01:00
|
|
|
output( "\t$(BISON) -p %s_ -o $@ %s\n", obj, source->filename );
|
1997-09-28 19:43:24 +02:00
|
|
|
}
|
2013-12-11 21:18:53 +01:00
|
|
|
else if (!strcmp( ext, "x" )) /* template file */
|
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s.h: %s%s %s\n", obj_dir_path( make, obj ),
|
|
|
|
tools_dir_path( make, "make_xftmpl" ), tools_ext, source->filename );
|
|
|
|
output( "\t%s%s -H -o $@ %s\n",
|
|
|
|
tools_dir_path( make, "make_xftmpl" ), tools_ext, source->filename );
|
2015-11-02 08:03:16 +01:00
|
|
|
if (source->file->flags & FLAG_INSTALL)
|
|
|
|
{
|
2015-11-10 04:03:52 +01:00
|
|
|
strarray_add( &install_rules[INSTALL_DEV], source->name );
|
|
|
|
strarray_add( &install_rules[INSTALL_DEV],
|
2015-11-02 08:03:16 +01:00
|
|
|
strmake( "D$(includedir)/%s", get_include_install_path( source->name ) ));
|
2015-11-10 04:03:52 +01:00
|
|
|
strarray_add( &install_rules[INSTALL_DEV], strmake( "%s.h", obj ));
|
|
|
|
strarray_add( &install_rules[INSTALL_DEV],
|
2015-11-02 08:03:16 +01:00
|
|
|
strmake( "d$(includedir)/%s.h", get_include_install_path( obj ) ));
|
|
|
|
}
|
2013-12-11 21:18:53 +01:00
|
|
|
}
|
2000-10-23 23:39:39 +02:00
|
|
|
else if (!strcmp( ext, "l" )) /* lex file */
|
1997-09-28 19:43:24 +02:00
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s.yy.c: %s\n", obj_dir_path( make, obj ), source->filename );
|
2014-01-14 11:45:54 +01:00
|
|
|
output( "\t$(FLEX) -o$@ %s\n", source->filename );
|
1997-09-28 19:43:24 +02:00
|
|
|
}
|
2000-10-23 23:39:39 +02:00
|
|
|
else if (!strcmp( ext, "rc" )) /* resource file */
|
1997-09-28 19:43:24 +02:00
|
|
|
{
|
2014-01-14 11:49:42 +01:00
|
|
|
strarray_add( &res_files, strmake( "%s.res", obj ));
|
2016-02-25 07:36:02 +01:00
|
|
|
output( "%s.res: %s\n", obj_dir_path( make, obj ), source->filename );
|
2014-08-23 17:04:52 +02:00
|
|
|
output( "\t%s -o $@", tools_path( make, "wrc" ) );
|
2014-04-09 12:35:24 +02:00
|
|
|
if (make->is_win16) output_filename( "-m16" );
|
2014-04-02 14:09:42 +02:00
|
|
|
else output_filenames( target_flags );
|
2014-01-14 11:49:42 +01:00
|
|
|
output_filename( "--nostdinc" );
|
|
|
|
output_filenames( includes );
|
2014-04-09 10:12:44 +02:00
|
|
|
output_filenames( make->define_args );
|
2014-01-14 11:49:42 +01:00
|
|
|
output_filenames( extradefs );
|
2014-04-11 16:55:51 +02:00
|
|
|
if (mo_files.count && (source->file->flags & FLAG_RC_PO))
|
2013-10-15 00:14:51 +02:00
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filename( strmake( "--po-dir=%s", top_obj_dir_path( make, "po" )));
|
2014-08-23 17:04:52 +02:00
|
|
|
output_filename( source->filename );
|
2013-12-26 21:51:38 +01:00
|
|
|
output( "\n" );
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s.res:", obj_dir_path( make, obj ));
|
2014-01-14 11:49:42 +01:00
|
|
|
output_filenames( mo_files );
|
|
|
|
output( "\n" );
|
2013-10-15 00:14:51 +02:00
|
|
|
}
|
2014-08-23 17:04:52 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
output_filename( source->filename );
|
|
|
|
output( "\n" );
|
|
|
|
}
|
2016-02-25 07:36:02 +01:00
|
|
|
if (source->file->flags & FLAG_RC_PO)
|
|
|
|
{
|
|
|
|
strarray_add( &clean_files, strmake( "%s.pot", obj ));
|
|
|
|
output( "%s.pot: %s\n", obj_dir_path( make, obj ), source->filename );
|
|
|
|
output( "\t%s -O pot -o $@", tools_path( make, "wrc" ) );
|
|
|
|
if (make->is_win16) output_filename( "-m16" );
|
|
|
|
else output_filenames( target_flags );
|
|
|
|
output_filename( "--nostdinc" );
|
|
|
|
output_filenames( includes );
|
|
|
|
output_filenames( make->define_args );
|
|
|
|
output_filenames( extradefs );
|
|
|
|
output_filename( source->filename );
|
|
|
|
output( "\n" );
|
|
|
|
output( "%s.pot ", obj_dir_path( make, obj ));
|
|
|
|
}
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s.res:", obj_dir_path( make, obj ));
|
2016-02-25 07:36:02 +01:00
|
|
|
output_filename( tools_path( make, "wrc" ));
|
2015-11-05 06:25:35 +01:00
|
|
|
output_filenames( dependencies );
|
|
|
|
output( "\n" );
|
2000-10-23 23:39:39 +02:00
|
|
|
}
|
2000-11-06 06:32:59 +01:00
|
|
|
else if (!strcmp( ext, "mc" )) /* message file */
|
2000-10-23 23:39:39 +02:00
|
|
|
{
|
2013-12-30 20:07:02 +01:00
|
|
|
strarray_add( &res_files, strmake( "%s.res", obj ));
|
2016-02-25 07:36:02 +01:00
|
|
|
strarray_add( &clean_files, strmake( "%s.pot", obj ));
|
|
|
|
output( "%s.res: %s\n", obj_dir_path( make, obj ), source->filename );
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "\t%s -U -O res -o $@ %s", tools_path( make, "wmc" ), source->filename );
|
2014-01-14 11:49:42 +01:00
|
|
|
if (mo_files.count)
|
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filename( strmake( "--po-dir=%s", top_obj_dir_path( make, "po" )));
|
2014-01-14 11:49:42 +01:00
|
|
|
output( "\n" );
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s.res:", obj_dir_path( make, obj ));
|
2014-01-14 11:49:42 +01:00
|
|
|
output_filenames( mo_files );
|
|
|
|
}
|
2016-02-25 07:36:02 +01:00
|
|
|
output( "\n" );
|
|
|
|
output( "%s.pot: %s\n", obj_dir_path( make, obj ), source->filename );
|
|
|
|
output( "\t%s -O pot -o $@ %s", tools_path( make, "wmc" ), source->filename );
|
|
|
|
output( "\n" );
|
|
|
|
output( "%s.pot %s.res:", obj_dir_path( make, obj ), obj_dir_path( make, obj ));
|
|
|
|
output_filename( tools_path( make, "wmc" ));
|
2015-11-05 06:25:35 +01:00
|
|
|
output_filenames( dependencies );
|
|
|
|
output( "\n" );
|
1997-09-28 19:43:24 +02:00
|
|
|
}
|
2003-04-11 02:38:56 +02:00
|
|
|
else if (!strcmp( ext, "idl" )) /* IDL file */
|
|
|
|
{
|
2013-12-24 11:37:52 +01:00
|
|
|
struct strarray targets = empty_strarray;
|
|
|
|
char *dest;
|
2006-10-16 17:19:07 +02:00
|
|
|
|
2015-11-04 06:57:37 +01:00
|
|
|
if (!source->file->flags) source->file->flags |= FLAG_IDL_HEADER | FLAG_INSTALL;
|
|
|
|
if (find_include_file( make, strmake( "%s.h", obj ))) source->file->flags |= FLAG_IDL_HEADER;
|
2006-10-16 17:19:07 +02:00
|
|
|
|
2013-11-04 17:39:30 +01:00
|
|
|
for (i = 0; i < sizeof(idl_outputs) / sizeof(idl_outputs[0]); i++)
|
2008-04-24 22:13:57 +02:00
|
|
|
{
|
2014-04-11 16:55:51 +02:00
|
|
|
if (!(source->file->flags & idl_outputs[i].flag)) continue;
|
2013-12-24 11:37:52 +01:00
|
|
|
dest = strmake( "%s%s", obj, idl_outputs[i].ext );
|
2014-04-10 13:50:37 +02:00
|
|
|
if (!find_src_file( make, dest )) strarray_add( &clean_files, dest );
|
2013-12-24 11:37:52 +01:00
|
|
|
strarray_add( &targets, dest );
|
2013-10-15 12:30:54 +02:00
|
|
|
}
|
2014-04-11 16:55:51 +02:00
|
|
|
if (source->file->flags & FLAG_IDL_PROXY) strarray_add( &dlldata_files, source->name );
|
2015-11-04 06:57:37 +01:00
|
|
|
if (source->file->flags & FLAG_INSTALL)
|
|
|
|
{
|
2015-11-10 04:03:52 +01:00
|
|
|
strarray_add( &install_rules[INSTALL_DEV], xstrdup( source->name ));
|
|
|
|
strarray_add( &install_rules[INSTALL_DEV],
|
2015-11-04 06:57:37 +01:00
|
|
|
strmake( "D$(includedir)/%s.idl", get_include_install_path( obj ) ));
|
|
|
|
if (source->file->flags & FLAG_IDL_HEADER)
|
|
|
|
{
|
2015-11-10 04:03:52 +01:00
|
|
|
strarray_add( &install_rules[INSTALL_DEV], strmake( "%s.h", obj ));
|
|
|
|
strarray_add( &install_rules[INSTALL_DEV],
|
2015-11-04 06:57:37 +01:00
|
|
|
strmake( "d$(includedir)/%s.h", get_include_install_path( obj ) ));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!targets.count) continue;
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filenames_obj_dir( make, targets );
|
|
|
|
output( ": %s\n", tools_path( make, "widl" ));
|
2014-08-23 17:04:52 +02:00
|
|
|
output( "\t%s -o $@", tools_path( make, "widl" ) );
|
2014-04-02 14:09:42 +02:00
|
|
|
output_filenames( target_flags );
|
2014-01-07 10:56:15 +01:00
|
|
|
output_filenames( includes );
|
2014-04-09 10:12:44 +02:00
|
|
|
output_filenames( make->define_args );
|
2014-01-07 12:20:25 +01:00
|
|
|
output_filenames( extradefs );
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filenames( get_expanded_make_var_array( make, "EXTRAIDLFLAGS" ));
|
2014-08-23 17:04:52 +02:00
|
|
|
output_filename( source->filename );
|
2013-12-26 21:51:38 +01:00
|
|
|
output( "\n" );
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filenames_obj_dir( make, targets );
|
2014-01-08 16:04:33 +01:00
|
|
|
output( ": %s", source->filename );
|
2015-11-05 06:25:35 +01:00
|
|
|
output_filenames( dependencies );
|
|
|
|
output( "\n" );
|
2003-04-11 02:38:56 +02:00
|
|
|
}
|
2013-12-12 20:04:53 +01:00
|
|
|
else if (!strcmp( ext, "in" )) /* .in file or man page */
|
2013-11-18 11:34:03 +01:00
|
|
|
{
|
2014-04-11 16:55:51 +02:00
|
|
|
if (strendswith( obj, ".man" ) && source->file->args)
|
2013-11-18 11:34:03 +01:00
|
|
|
{
|
2015-10-29 10:06:35 +01:00
|
|
|
struct strarray symlinks;
|
2013-12-24 11:27:35 +01:00
|
|
|
char *dir, *dest = replace_extension( obj, ".man", "" );
|
2013-11-18 11:34:03 +01:00
|
|
|
char *lang = strchr( dest, '.' );
|
2014-04-11 16:55:51 +02:00
|
|
|
char *section = source->file->args;
|
2013-11-18 11:34:03 +01:00
|
|
|
if (lang)
|
|
|
|
{
|
|
|
|
*lang++ = 0;
|
2015-10-29 06:32:45 +01:00
|
|
|
dir = strmake( "$(mandir)/%s/man%s", lang, section );
|
2013-11-18 11:34:03 +01:00
|
|
|
}
|
2015-10-29 06:32:45 +01:00
|
|
|
else dir = strmake( "$(mandir)/man%s", section );
|
2015-11-10 04:03:52 +01:00
|
|
|
add_install_rule( make, install_rules, dest, xstrdup(obj),
|
|
|
|
strmake( "d%s/%s.%s", dir, dest, section ));
|
2016-02-23 07:03:50 +01:00
|
|
|
symlinks = get_expanded_file_local_var( make, dest, "SYMLINKS" );
|
2015-11-02 07:53:42 +01:00
|
|
|
for (i = 0; i < symlinks.count; i++)
|
2015-11-10 04:03:52 +01:00
|
|
|
add_install_rule( make, install_rules, symlinks.str[i],
|
|
|
|
strmake( "%s.%s", dest, section ),
|
2015-11-02 07:53:42 +01:00
|
|
|
strmake( "y%s/%s.%s", dir, symlinks.str[i], section ));
|
2013-11-18 11:34:03 +01:00
|
|
|
free( dest );
|
2013-12-26 13:24:26 +01:00
|
|
|
free( dir );
|
2013-11-18 11:34:03 +01:00
|
|
|
}
|
2015-11-13 06:17:18 +01:00
|
|
|
strarray_add( &in_files, xstrdup(obj) );
|
2015-11-10 10:28:28 +01:00
|
|
|
strarray_add( &all_targets, xstrdup(obj) );
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s: %s\n", obj_dir_path( make, obj ), source->filename );
|
2015-11-11 03:56:23 +01:00
|
|
|
output( "\t$(SED_CMD) %s >$@ || (rm -f $@ && false)\n", source->filename );
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s:", obj_dir_path( make, obj ));
|
2015-11-05 06:25:35 +01:00
|
|
|
output_filenames( dependencies );
|
|
|
|
output( "\n" );
|
2015-11-13 07:16:16 +01:00
|
|
|
add_install_rule( make, install_rules, obj, xstrdup( obj ),
|
|
|
|
strmake( "d$(datadir)/wine/%s", obj ));
|
2013-11-18 11:34:03 +01:00
|
|
|
}
|
2013-12-26 20:02:42 +01:00
|
|
|
else if (!strcmp( ext, "sfd" )) /* font file */
|
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
char *ttf_file = src_dir_path( make, strmake( "%s.ttf", obj ));
|
2014-04-09 10:12:44 +02:00
|
|
|
if (fontforge && !make->src_dir)
|
2013-12-26 20:02:42 +01:00
|
|
|
{
|
2014-02-05 13:44:51 +01:00
|
|
|
output( "%s: %s\n", ttf_file, source->filename );
|
2014-01-10 12:47:19 +01:00
|
|
|
output( "\t%s -script %s %s $@\n",
|
2016-03-31 07:39:32 +02:00
|
|
|
fontforge, top_src_dir_path( make, "fonts/genttf.ff" ), source->filename );
|
2014-04-11 16:55:51 +02:00
|
|
|
if (!(source->file->flags & FLAG_SFD_FONTS)) output( "all: %s\n", ttf_file );
|
2013-12-26 20:02:42 +01:00
|
|
|
}
|
2014-04-11 16:55:51 +02:00
|
|
|
if (source->file->flags & FLAG_INSTALL)
|
2014-02-05 13:44:51 +01:00
|
|
|
{
|
2015-11-10 04:03:52 +01:00
|
|
|
strarray_add( &install_rules[INSTALL_LIB], strmake( "%s.ttf", obj ));
|
|
|
|
strarray_add( &install_rules[INSTALL_LIB], strmake( "D$(fontdir)/%s.ttf", obj ));
|
2014-02-05 13:44:51 +01:00
|
|
|
}
|
2014-04-11 16:55:51 +02:00
|
|
|
if (source->file->flags & FLAG_SFD_FONTS)
|
2014-02-18 15:53:14 +01:00
|
|
|
{
|
2014-04-11 16:55:51 +02:00
|
|
|
struct strarray *array = source->file->args;
|
2014-02-18 15:53:14 +01:00
|
|
|
|
|
|
|
for (i = 0; i < array->count; i++)
|
|
|
|
{
|
|
|
|
char *font = strtok( xstrdup(array->str[i]), " \t" );
|
|
|
|
char *args = strtok( NULL, "" );
|
|
|
|
|
2014-04-10 10:03:03 +02:00
|
|
|
strarray_add( &all_targets, xstrdup( font ));
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s: %s %s\n", obj_dir_path( make, font ),
|
|
|
|
tools_path( make, "sfnt2fon" ), ttf_file );
|
|
|
|
output( "\t%s -o $@ %s %s\n", tools_path( make, "sfnt2fon" ), ttf_file, args );
|
2015-11-10 04:03:52 +01:00
|
|
|
strarray_add( &install_rules[INSTALL_LIB], xstrdup(font) );
|
|
|
|
strarray_add( &install_rules[INSTALL_LIB], strmake( "d$(fontdir)/%s", font ));
|
2014-02-18 15:53:14 +01:00
|
|
|
}
|
|
|
|
}
|
2014-02-05 12:15:07 +01:00
|
|
|
}
|
2013-12-26 19:56:16 +01:00
|
|
|
else if (!strcmp( ext, "svg" )) /* svg file */
|
|
|
|
{
|
2014-04-09 10:12:44 +02:00
|
|
|
if (convert && rsvg && icotool && !make->src_dir)
|
2013-12-26 19:56:16 +01:00
|
|
|
{
|
2017-07-14 11:58:54 +02:00
|
|
|
static const char * const images[] = { "bmp", "cur", "ico", NULL };
|
|
|
|
|
|
|
|
for (i = 0; images[i]; i++)
|
|
|
|
if (find_include_file( make, strmake( "%s.%s", obj, images[i] ))) break;
|
|
|
|
|
|
|
|
if (images[i])
|
|
|
|
{
|
|
|
|
output( "%s.%s: %s\n", src_dir_path( make, obj ), images[i], source->filename );
|
|
|
|
output( "\tCONVERT=\"%s\" ICOTOOL=\"%s\" RSVG=\"%s\" %s %s $@\n", convert, icotool, rsvg,
|
|
|
|
top_src_dir_path( make, "tools/buildimage" ), source->filename );
|
|
|
|
}
|
2013-12-26 19:56:16 +01:00
|
|
|
}
|
|
|
|
}
|
2016-03-01 06:21:01 +01:00
|
|
|
else if (!strcmp( ext, "po" )) /* po file */
|
|
|
|
{
|
|
|
|
output( "%s.mo: %s\n", obj_dir_path( make, obj ), source->filename );
|
|
|
|
output( "\t%s -o $@ %s\n", msgfmt, source->filename );
|
|
|
|
strarray_add( &all_targets, strmake( "%s.mo", obj ));
|
|
|
|
}
|
2013-12-26 19:27:59 +01:00
|
|
|
else if (!strcmp( ext, "res" ))
|
2008-04-24 22:13:57 +02:00
|
|
|
{
|
2013-12-30 20:07:02 +01:00
|
|
|
strarray_add( &res_files, source->name );
|
2015-11-05 06:25:35 +01:00
|
|
|
}
|
|
|
|
else if (!strcmp( ext, "tlb" ))
|
|
|
|
{
|
|
|
|
strarray_add( &all_targets, source->name );
|
2008-04-24 22:13:57 +02:00
|
|
|
}
|
2015-11-02 07:53:42 +01:00
|
|
|
else if (!strcmp( ext, "h" ) || !strcmp( ext, "rh" ) || !strcmp( ext, "inl" )) /* header file */
|
|
|
|
{
|
|
|
|
if (source->file->flags & FLAG_GENERATED)
|
|
|
|
{
|
|
|
|
strarray_add( &all_targets, source->name );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-11-10 04:03:52 +01:00
|
|
|
strarray_add( &install_rules[INSTALL_DEV], source->name );
|
|
|
|
strarray_add( &install_rules[INSTALL_DEV],
|
2015-11-02 07:53:42 +01:00
|
|
|
strmake( "D$(includedir)/%s", get_include_install_path( source->name ) ));
|
|
|
|
}
|
|
|
|
}
|
1997-09-28 19:43:24 +02:00
|
|
|
else
|
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
int need_cross = make->testdll ||
|
2014-04-11 16:55:51 +02:00
|
|
|
(source->file->flags & FLAG_C_IMPLIB) ||
|
2014-04-10 13:41:23 +02:00
|
|
|
(make->module && make->staticlib);
|
2014-01-01 21:27:22 +01:00
|
|
|
|
2014-04-11 16:55:51 +02:00
|
|
|
if ((source->file->flags & FLAG_GENERATED) &&
|
2014-04-10 10:03:03 +02:00
|
|
|
(!make->testdll || !strendswith( source->filename, "testlist.c" )))
|
2014-02-10 10:55:18 +01:00
|
|
|
strarray_add( &clean_files, source->filename );
|
2014-04-11 16:55:51 +02:00
|
|
|
if (source->file->flags & FLAG_C_IMPLIB) strarray_add( &implib_objs, strmake( "%s.o", obj ));
|
2014-01-01 21:27:22 +01:00
|
|
|
strarray_add( &object_files, strmake( "%s.o", obj ));
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s.o: %s\n", obj_dir_path( make, obj ), source->filename );
|
2014-01-01 21:27:22 +01:00
|
|
|
output( "\t$(CC) -c -o $@ %s", source->filename );
|
|
|
|
output_filenames( includes );
|
2014-04-09 10:12:44 +02:00
|
|
|
output_filenames( make->define_args );
|
2014-01-07 12:20:25 +01:00
|
|
|
output_filenames( extradefs );
|
2016-02-23 05:01:53 +01:00
|
|
|
if (make->module || make->staticlib || make->sharedlib || make->testdll)
|
2014-04-02 14:09:42 +02:00
|
|
|
{
|
|
|
|
output_filenames( dll_flags );
|
2014-04-09 10:12:44 +02:00
|
|
|
if (make->use_msvcrt) output_filenames( msvcrt_flags );
|
2014-04-02 14:09:42 +02:00
|
|
|
}
|
|
|
|
output_filenames( extra_cflags );
|
|
|
|
output_filenames( cpp_flags );
|
2014-01-14 11:45:54 +01:00
|
|
|
output_filename( "$(CFLAGS)" );
|
2014-01-01 21:27:22 +01:00
|
|
|
output( "\n" );
|
|
|
|
if (crosstarget && need_cross)
|
2013-11-11 11:23:38 +01:00
|
|
|
{
|
2013-12-30 20:07:02 +01:00
|
|
|
strarray_add( &crossobj_files, strmake( "%s.cross.o", obj ));
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s.cross.o: %s\n", obj_dir_path( make, obj ), source->filename );
|
2013-12-28 11:48:03 +01:00
|
|
|
output( "\t$(CROSSCC) -c -o $@ %s", source->filename );
|
2013-12-28 19:52:33 +01:00
|
|
|
output_filenames( includes );
|
2014-04-09 10:12:44 +02:00
|
|
|
output_filenames( make->define_args );
|
2014-01-07 12:20:25 +01:00
|
|
|
output_filenames( extradefs );
|
2016-04-04 15:16:29 +02:00
|
|
|
if (make->use_msvcrt) output_filenames( msvcrt_flags );
|
2014-01-07 10:56:15 +01:00
|
|
|
output_filename( "-DWINE_CROSSTEST" );
|
2014-04-02 14:09:42 +02:00
|
|
|
output_filenames( cpp_flags );
|
2017-07-08 11:20:21 +02:00
|
|
|
output_filename( "$(CROSSCFLAGS)" );
|
2013-12-26 21:51:38 +01:00
|
|
|
output( "\n" );
|
2013-11-11 11:23:38 +01:00
|
|
|
}
|
2014-04-11 16:55:51 +02:00
|
|
|
if (make->testdll && !strcmp( ext, "c" ) && !(source->file->flags & FLAG_GENERATED))
|
2013-11-16 11:57:14 +01:00
|
|
|
{
|
2014-02-10 10:55:18 +01:00
|
|
|
strarray_add( &ok_files, strmake( "%s.ok", obj ));
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s.ok:\n", obj_dir_path( make, obj ));
|
2014-01-10 12:53:15 +01:00
|
|
|
output( "\t%s $(RUNTESTFLAGS) -T %s -M %s -p %s%s %s && touch $@\n",
|
2016-03-31 07:39:32 +02:00
|
|
|
top_src_dir_path( make, "tools/runtest" ), top_obj_dir_path( make, "" ),
|
|
|
|
make->testdll, replace_extension( make->testdll, ".dll", "_test.exe" ),
|
|
|
|
dll_ext, obj );
|
2013-11-16 11:57:14 +01:00
|
|
|
}
|
2014-04-11 16:55:51 +02:00
|
|
|
if (!strcmp( ext, "c" ) && !(source->file->flags & FLAG_GENERATED))
|
2013-12-30 20:23:16 +01:00
|
|
|
strarray_add( &c2man_files, source->filename );
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s.o", obj_dir_path( make, obj ));
|
|
|
|
if (crosstarget && need_cross) output( " %s.cross.o", obj_dir_path( make, obj ));
|
2013-12-28 11:48:03 +01:00
|
|
|
output( ":" );
|
2015-11-05 06:25:35 +01:00
|
|
|
output_filenames( dependencies );
|
|
|
|
output( "\n" );
|
1997-09-28 19:43:24 +02:00
|
|
|
}
|
2013-10-14 11:11:07 +02:00
|
|
|
free( obj );
|
1997-09-28 19:43:24 +02:00
|
|
|
}
|
2013-10-14 20:18:18 +02:00
|
|
|
|
|
|
|
/* rules for files that depend on multiple sources */
|
|
|
|
|
2013-12-27 14:26:37 +01:00
|
|
|
if (dlldata_files.count)
|
2013-10-15 12:35:11 +02:00
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s: %s %s\n", obj_dir_path( make, "dlldata.c" ),
|
|
|
|
tools_path( make, "widl" ), src_dir_path( make, "Makefile.in" ));
|
|
|
|
output( "\t%s --dlldata-only -o $@", tools_path( make, "widl" ));
|
2013-12-28 19:52:33 +01:00
|
|
|
output_filenames( dlldata_files );
|
2013-10-15 12:35:11 +02:00
|
|
|
output( "\n" );
|
|
|
|
}
|
2013-10-15 12:39:42 +02:00
|
|
|
|
2014-04-09 12:35:24 +02:00
|
|
|
if (make->module && !make->staticlib)
|
2013-12-30 20:08:13 +01:00
|
|
|
{
|
|
|
|
struct strarray all_libs = empty_strarray;
|
2016-02-16 08:53:59 +01:00
|
|
|
struct strarray dep_libs = empty_strarray;
|
2014-04-10 13:41:23 +02:00
|
|
|
char *module_path = obj_dir_path( make, make->module );
|
2014-01-10 12:47:19 +01:00
|
|
|
char *spec_file = NULL;
|
2013-12-30 20:08:13 +01:00
|
|
|
|
2014-04-10 13:41:23 +02:00
|
|
|
if (!make->appmode.count)
|
|
|
|
spec_file = src_dir_path( make, replace_extension( make->module, ".dll", ".spec" ));
|
2016-02-16 08:53:59 +01:00
|
|
|
strarray_addall( &all_libs, add_import_libs( make, &dep_libs, make->delayimports, 0 ));
|
|
|
|
strarray_addall( &all_libs, add_import_libs( make, &dep_libs, make->imports, 0 ));
|
2016-02-23 12:21:47 +01:00
|
|
|
add_import_libs( make, &dep_libs, get_default_imports( make ), 0 ); /* dependencies only */
|
2016-02-23 06:57:11 +01:00
|
|
|
strarray_addall( &all_libs, add_default_libraries( make, &dep_libs ));
|
2013-12-30 20:08:13 +01:00
|
|
|
|
2014-04-02 14:09:42 +02:00
|
|
|
if (*dll_ext)
|
2013-12-30 20:08:13 +01:00
|
|
|
{
|
2016-02-24 05:17:37 +01:00
|
|
|
for (i = 0; i < make->delayimports.count; i++)
|
|
|
|
strarray_add( &all_libs, strmake( "-Wb,-d%s", make->delayimports.str[i] ));
|
2014-04-09 12:35:24 +02:00
|
|
|
strarray_add( &all_targets, strmake( "%s%s", make->module, dll_ext ));
|
|
|
|
strarray_add( &all_targets, strmake( "%s.fake", make->module ));
|
2015-11-10 04:03:52 +01:00
|
|
|
add_install_rule( make, install_rules, make->module, strmake( "%s%s", make->module, dll_ext ),
|
2015-10-30 06:15:45 +01:00
|
|
|
strmake( "p$(dlldir)/%s%s", make->module, dll_ext ));
|
2015-11-10 04:03:52 +01:00
|
|
|
add_install_rule( make, install_rules, make->module, strmake( "%s.fake", make->module ),
|
2015-10-30 06:15:45 +01:00
|
|
|
strmake( "d$(fakedlldir)/%s", make->module ));
|
2014-04-10 10:03:03 +02:00
|
|
|
output( "%s%s %s.fake:", module_path, dll_ext, module_path );
|
2013-12-30 20:08:13 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-24 05:17:37 +01:00
|
|
|
strarray_add( &all_libs, "-lwine" );
|
2014-04-09 12:35:24 +02:00
|
|
|
strarray_add( &all_targets, make->module );
|
2015-11-10 04:03:52 +01:00
|
|
|
add_install_rule( make, install_rules, make->module, make->module,
|
2015-10-30 06:15:45 +01:00
|
|
|
strmake( "p$(%s)/%s", spec_file ? "dlldir" : "bindir", make->module ));
|
2014-04-10 10:03:03 +02:00
|
|
|
output( "%s:", module_path );
|
2013-12-30 20:08:13 +01:00
|
|
|
}
|
|
|
|
if (spec_file) output_filename( spec_file );
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filenames_obj_dir( make, object_files );
|
|
|
|
output_filenames_obj_dir( make, res_files );
|
2016-02-16 08:53:59 +01:00
|
|
|
output_filenames( dep_libs );
|
2016-03-28 05:27:32 +02:00
|
|
|
output_filename( tools_path( make, "winebuild" ));
|
|
|
|
output_filename( tools_path( make, "winegcc" ));
|
2013-12-30 20:08:13 +01:00
|
|
|
output( "\n" );
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "\t%s -o $@", tools_path( make, "winegcc" ));
|
|
|
|
output_filename( strmake( "-B%s", tools_dir_path( make, "winebuild" )));
|
|
|
|
if (tools_dir) output_filename( strmake( "--sysroot=%s", top_obj_dir_path( make, "" )));
|
2014-04-02 14:09:42 +02:00
|
|
|
output_filenames( target_flags );
|
|
|
|
output_filenames( unwind_flags );
|
2013-12-30 20:08:13 +01:00
|
|
|
if (spec_file)
|
|
|
|
{
|
|
|
|
output( " -shared %s", spec_file );
|
2014-04-09 12:35:24 +02:00
|
|
|
output_filenames( make->extradllflags );
|
2013-12-30 20:08:13 +01:00
|
|
|
}
|
2014-04-09 10:12:44 +02:00
|
|
|
else output_filenames( make->appmode );
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filenames_obj_dir( make, object_files );
|
|
|
|
output_filenames_obj_dir( make, res_files );
|
2013-12-30 20:08:13 +01:00
|
|
|
output_filenames( all_libs );
|
|
|
|
output_filename( "$(LDFLAGS)" );
|
|
|
|
output( "\n" );
|
2013-12-30 20:14:45 +01:00
|
|
|
|
2014-04-09 12:35:24 +02:00
|
|
|
if (spec_file && make->importlib)
|
2013-12-30 20:14:45 +01:00
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
char *importlib_path = obj_dir_path( make, strmake( "lib%s", make->importlib ));
|
2016-03-25 07:31:54 +01:00
|
|
|
if (*dll_ext && !implib_objs.count)
|
2013-12-30 20:14:45 +01:00
|
|
|
{
|
2014-04-09 12:35:24 +02:00
|
|
|
strarray_add( &clean_files, strmake( "lib%s.def", make->importlib ));
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s.def: %s %s\n", importlib_path, tools_path( make, "winebuild" ), spec_file );
|
|
|
|
output( "\t%s -w --def -o $@ --export %s", tools_path( make, "winebuild" ), spec_file );
|
2014-04-02 14:09:42 +02:00
|
|
|
output_filenames( target_flags );
|
2014-04-09 12:35:24 +02:00
|
|
|
if (make->is_win16) output_filename( "-m16" );
|
2013-12-30 20:14:45 +01:00
|
|
|
output( "\n" );
|
2015-11-10 04:03:52 +01:00
|
|
|
add_install_rule( make, install_rules, make->importlib,
|
|
|
|
strmake( "lib%s.def", make->importlib ),
|
2015-10-30 06:15:45 +01:00
|
|
|
strmake( "d$(dlldir)/lib%s.def", make->importlib ));
|
2013-12-30 20:14:45 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-04-09 12:35:24 +02:00
|
|
|
strarray_add( &clean_files, strmake( "lib%s.a", make->importlib ));
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s.a: %s %s", importlib_path, tools_path( make, "winebuild" ), spec_file );
|
|
|
|
output_filenames_obj_dir( make, implib_objs );
|
2013-12-30 20:14:45 +01:00
|
|
|
output( "\n" );
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "\t%s -w --implib -o $@ --export %s", tools_path( make, "winebuild" ), spec_file );
|
2014-04-02 14:09:42 +02:00
|
|
|
output_filenames( target_flags );
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filenames_obj_dir( make, implib_objs );
|
2013-12-30 20:14:45 +01:00
|
|
|
output( "\n" );
|
2015-11-10 04:03:52 +01:00
|
|
|
add_install_rule( make, install_rules, make->importlib,
|
|
|
|
strmake( "lib%s.a", make->importlib ),
|
2015-10-30 06:15:45 +01:00
|
|
|
strmake( "d$(dlldir)/lib%s.a", make->importlib ));
|
2013-12-30 20:14:45 +01:00
|
|
|
}
|
2014-04-09 12:35:24 +02:00
|
|
|
if (crosstarget && !make->is_win16)
|
2013-12-30 20:14:45 +01:00
|
|
|
{
|
|
|
|
struct strarray cross_files = strarray_replace_extension( &implib_objs, ".o", ".cross.o" );
|
2014-04-09 12:35:24 +02:00
|
|
|
strarray_add( &clean_files, strmake( "lib%s.cross.a", make->importlib ));
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s.cross.a: %s %s", importlib_path, tools_path( make, "winebuild" ), spec_file );
|
|
|
|
output_filenames_obj_dir( make, cross_files );
|
2013-12-30 20:14:45 +01:00
|
|
|
output( "\n" );
|
2014-01-13 15:04:30 +01:00
|
|
|
output( "\t%s -b %s -w --implib -o $@ --export %s",
|
2014-04-10 13:41:23 +02:00
|
|
|
tools_path( make, "winebuild" ), crosstarget, spec_file );
|
|
|
|
output_filenames_obj_dir( make, cross_files );
|
2013-12-30 20:14:45 +01:00
|
|
|
output( "\n" );
|
|
|
|
}
|
|
|
|
}
|
2013-12-30 20:23:16 +01:00
|
|
|
|
|
|
|
if (spec_file)
|
|
|
|
{
|
2014-03-10 11:13:44 +01:00
|
|
|
if (c2man_files.count)
|
2013-12-30 20:23:16 +01:00
|
|
|
{
|
|
|
|
output( "manpages::\n" );
|
2016-03-31 07:39:32 +02:00
|
|
|
output( "\t%s -w %s", top_src_dir_path( make, "tools/c2man.pl" ), spec_file );
|
|
|
|
output_filename( strmake( "-R%s", top_src_dir_path( make, "" )));
|
|
|
|
output_filename( strmake( "-I%s", top_src_dir_path( make, "include" )));
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filename( strmake( "-o %s/man%s",
|
|
|
|
top_obj_dir_path( make, "documentation" ), man_ext ));
|
2013-12-30 20:23:16 +01:00
|
|
|
output_filenames( c2man_files );
|
|
|
|
output( "\n" );
|
|
|
|
output( "htmlpages::\n" );
|
2016-03-31 07:39:32 +02:00
|
|
|
output( "\t%s -Th -w %s", top_src_dir_path( make, "tools/c2man.pl" ), spec_file );
|
|
|
|
output_filename( strmake( "-R%s", top_src_dir_path( make, "" )));
|
|
|
|
output_filename( strmake( "-I%s", top_src_dir_path( make, "include" )));
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filename( strmake( "-o %s",
|
|
|
|
top_obj_dir_path( make, "documentation/html" )));
|
2013-12-30 20:23:16 +01:00
|
|
|
output_filenames( c2man_files );
|
|
|
|
output( "\n" );
|
|
|
|
output( "sgmlpages::\n" );
|
2016-03-31 07:39:32 +02:00
|
|
|
output( "\t%s -Ts -w %s", top_src_dir_path( make, "tools/c2man.pl" ), spec_file );
|
|
|
|
output_filename( strmake( "-R%s", top_src_dir_path( make, "" )));
|
|
|
|
output_filename( strmake( "-I%s", top_src_dir_path( make, "include" )));
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filename( strmake( "-o %s",
|
|
|
|
top_obj_dir_path( make, "documentation/api-guide" )));
|
2013-12-30 20:23:16 +01:00
|
|
|
output_filenames( c2man_files );
|
|
|
|
output( "\n" );
|
|
|
|
output( "xmlpages::\n" );
|
2016-03-31 07:39:32 +02:00
|
|
|
output( "\t%s -Tx -w %s", top_src_dir_path( make, "tools/c2man.pl" ), spec_file );
|
|
|
|
output_filename( strmake( "-R%s", top_src_dir_path( make, "" )));
|
|
|
|
output_filename( strmake( "-I%s", top_src_dir_path( make, "include" )));
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filename( strmake( "-o %s",
|
|
|
|
top_obj_dir_path( make, "documentation/api-guide-xml" )));
|
2013-12-30 20:23:16 +01:00
|
|
|
output_filenames( c2man_files );
|
|
|
|
output( "\n" );
|
|
|
|
strarray_add( &phony_targets, "manpages" );
|
|
|
|
strarray_add( &phony_targets, "htmlpages" );
|
|
|
|
strarray_add( &phony_targets, "sgmlpages" );
|
|
|
|
strarray_add( &phony_targets, "xmlpages" );
|
|
|
|
}
|
|
|
|
else output( "manpages htmlpages sgmlpages xmlpages::\n" );
|
|
|
|
}
|
2015-10-30 06:15:45 +01:00
|
|
|
else if (*dll_ext)
|
|
|
|
{
|
|
|
|
char *binary = replace_extension( make->module, ".exe", "" );
|
2016-04-04 06:59:54 +02:00
|
|
|
add_install_rule( make, install_rules, binary, "wineapploader",
|
|
|
|
strmake( "t$(bindir)/%s", binary ));
|
2015-10-30 06:15:45 +01:00
|
|
|
}
|
2013-12-30 20:08:13 +01:00
|
|
|
}
|
|
|
|
|
2014-04-09 12:35:24 +02:00
|
|
|
if (make->staticlib)
|
2013-12-30 20:17:36 +01:00
|
|
|
{
|
2014-04-09 12:35:24 +02:00
|
|
|
strarray_add( &all_targets, make->staticlib );
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s:", obj_dir_path( make, make->staticlib ));
|
|
|
|
output_filenames_obj_dir( make, object_files );
|
2015-11-11 03:56:23 +01:00
|
|
|
output( "\n\trm -f $@\n" );
|
2013-12-30 20:17:36 +01:00
|
|
|
output( "\t$(AR) $(ARFLAGS) $@" );
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filenames_obj_dir( make, object_files );
|
2013-12-30 20:17:36 +01:00
|
|
|
output( "\n\t$(RANLIB) $@\n" );
|
2016-04-04 07:06:10 +02:00
|
|
|
add_install_rule( make, install_rules, make->staticlib, make->staticlib,
|
|
|
|
strmake( "d$(dlldir)/%s", make->staticlib ));
|
2014-04-09 12:35:24 +02:00
|
|
|
if (crosstarget && make->module)
|
2013-12-30 20:17:36 +01:00
|
|
|
{
|
2014-04-09 12:35:24 +02:00
|
|
|
char *name = replace_extension( make->staticlib, ".a", ".cross.a" );
|
2013-12-30 20:17:36 +01:00
|
|
|
|
|
|
|
strarray_add( &all_targets, name );
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s:", obj_dir_path( make, name ));
|
|
|
|
output_filenames_obj_dir( make, crossobj_files );
|
2015-11-11 03:56:23 +01:00
|
|
|
output( "\n\trm -f $@\n" );
|
2013-12-30 20:17:36 +01:00
|
|
|
output( "\t%s-ar $(ARFLAGS) $@", crosstarget );
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filenames_obj_dir( make, crossobj_files );
|
2013-12-30 20:17:36 +01:00
|
|
|
output( "\n\t%s-ranlib $@\n", crosstarget );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-12 14:08:03 +01:00
|
|
|
if (make->sharedlib)
|
|
|
|
{
|
|
|
|
char *basename, *p;
|
|
|
|
struct strarray names = get_shared_lib_names( make->sharedlib );
|
|
|
|
struct strarray all_libs = empty_strarray;
|
2016-02-23 06:57:11 +01:00
|
|
|
struct strarray dep_libs = empty_strarray;
|
2015-11-12 14:08:03 +01:00
|
|
|
|
|
|
|
basename = xstrdup( make->sharedlib );
|
|
|
|
if ((p = strchr( basename, '.' ))) *p = 0;
|
|
|
|
|
2016-02-23 06:57:11 +01:00
|
|
|
strarray_addall( &dep_libs, get_local_dependencies( make, basename, in_files ));
|
2016-02-23 07:03:50 +01:00
|
|
|
strarray_addall( &all_libs, get_expanded_file_local_var( make, basename, "LDFLAGS" ));
|
2016-02-23 06:57:11 +01:00
|
|
|
strarray_addall( &all_libs, add_default_libraries( make, &dep_libs ));
|
2015-11-12 14:08:03 +01:00
|
|
|
|
|
|
|
output( "%s:", obj_dir_path( make, make->sharedlib ));
|
|
|
|
output_filenames_obj_dir( make, object_files );
|
2016-02-23 06:57:11 +01:00
|
|
|
output_filenames( dep_libs );
|
2015-11-12 14:08:03 +01:00
|
|
|
output( "\n" );
|
|
|
|
output( "\t$(CC) -o $@" );
|
|
|
|
output_filenames_obj_dir( make, object_files );
|
|
|
|
output_filenames( all_libs );
|
|
|
|
output_filename( "$(LDFLAGS)" );
|
|
|
|
output( "\n" );
|
2015-11-12 15:01:28 +01:00
|
|
|
add_install_rule( make, install_rules, make->sharedlib, make->sharedlib,
|
|
|
|
strmake( "p$(libdir)/%s", make->sharedlib ));
|
2015-11-12 14:08:03 +01:00
|
|
|
for (i = 1; i < names.count; i++)
|
|
|
|
{
|
|
|
|
output( "%s: %s\n", obj_dir_path( make, names.str[i] ), obj_dir_path( make, names.str[i-1] ));
|
2016-05-06 06:54:13 +02:00
|
|
|
output_symlink_rule( obj_dir_path( make, names.str[i-1] ), obj_dir_path( make, names.str[i] ));
|
2015-11-12 15:01:28 +01:00
|
|
|
add_install_rule( make, install_rules, names.str[i], names.str[i-1],
|
|
|
|
strmake( "y$(libdir)/%s", names.str[i] ));
|
2015-11-12 14:08:03 +01:00
|
|
|
}
|
|
|
|
strarray_addall( &all_targets, names );
|
|
|
|
}
|
|
|
|
|
2015-11-12 15:19:24 +01:00
|
|
|
if (make->importlib && !make->module) /* stand-alone import lib (for libwine) */
|
|
|
|
{
|
|
|
|
char *def_file = replace_extension( make->importlib, ".a", ".def" );
|
|
|
|
|
|
|
|
if (!strncmp( def_file, "lib", 3 )) def_file += 3;
|
|
|
|
output( "%s: %s\n", obj_dir_path( make, make->importlib ), src_dir_path( make, def_file ));
|
|
|
|
output( "\t%s -l $@ -d %s\n", dlltool, src_dir_path( make, def_file ));
|
|
|
|
add_install_rule( make, install_rules, make->importlib, make->importlib,
|
|
|
|
strmake( "d$(libdir)/%s", make->importlib ));
|
|
|
|
strarray_add( &all_targets, make->importlib );
|
|
|
|
}
|
|
|
|
|
2014-04-09 12:35:24 +02:00
|
|
|
if (make->testdll)
|
2013-10-15 12:39:42 +02:00
|
|
|
{
|
2014-04-09 12:35:24 +02:00
|
|
|
char *testmodule = replace_extension( make->testdll, ".dll", "_test.exe" );
|
|
|
|
char *stripped = replace_extension( make->testdll, ".dll", "_test-stripped.exe" );
|
2014-04-10 10:03:03 +02:00
|
|
|
char *testres = replace_extension( make->testdll, ".dll", "_test.res" );
|
2016-02-16 08:53:59 +01:00
|
|
|
struct strarray dep_libs = empty_strarray;
|
|
|
|
struct strarray all_libs = add_import_libs( make, &dep_libs, make->imports, 0 );
|
2013-12-30 20:19:33 +01:00
|
|
|
|
2016-02-23 12:21:47 +01:00
|
|
|
add_import_libs( make, &dep_libs, get_default_imports( make ), 0 ); /* dependencies only */
|
2015-10-27 04:13:26 +01:00
|
|
|
strarray_addall( &all_libs, libs );
|
2014-04-02 14:09:42 +02:00
|
|
|
strarray_add( &all_targets, strmake( "%s%s", testmodule, dll_ext ));
|
|
|
|
strarray_add( &clean_files, strmake( "%s%s", stripped, dll_ext ));
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s%s:\n", obj_dir_path( make, testmodule ), dll_ext );
|
|
|
|
output( "\t%s -o $@", tools_path( make, "winegcc" ));
|
|
|
|
output_filename( strmake( "-B%s", tools_dir_path( make, "winebuild" )));
|
|
|
|
if (tools_dir) output_filename( strmake( "--sysroot=%s", top_obj_dir_path( make, "" )));
|
2014-04-02 14:09:42 +02:00
|
|
|
output_filenames( target_flags );
|
|
|
|
output_filenames( unwind_flags );
|
2014-04-09 10:12:44 +02:00
|
|
|
output_filenames( make->appmode );
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filenames_obj_dir( make, object_files );
|
|
|
|
output_filenames_obj_dir( make, res_files );
|
2013-12-30 20:19:33 +01:00
|
|
|
output_filenames( all_libs );
|
|
|
|
output_filename( "$(LDFLAGS)" );
|
|
|
|
output( "\n" );
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s%s:\n", obj_dir_path( make, stripped ), dll_ext );
|
|
|
|
output( "\t%s -o $@", tools_path( make, "winegcc" ));
|
|
|
|
output_filename( strmake( "-B%s", tools_dir_path( make, "winebuild" )));
|
|
|
|
if (tools_dir) output_filename( strmake( "--sysroot=%s", top_obj_dir_path( make, "" )));
|
2014-04-02 14:09:42 +02:00
|
|
|
output_filenames( target_flags );
|
|
|
|
output_filenames( unwind_flags );
|
2014-01-01 21:38:30 +01:00
|
|
|
output_filename( strmake( "-Wb,-F,%s", testmodule ));
|
2014-04-09 10:12:44 +02:00
|
|
|
output_filenames( make->appmode );
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filenames_obj_dir( make, object_files );
|
|
|
|
output_filenames_obj_dir( make, res_files );
|
2013-12-30 20:19:33 +01:00
|
|
|
output_filenames( all_libs );
|
|
|
|
output_filename( "$(LDFLAGS)" );
|
|
|
|
output( "\n" );
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s%s %s%s:", obj_dir_path( make, testmodule ), dll_ext,
|
|
|
|
obj_dir_path( make, stripped ), dll_ext );
|
|
|
|
output_filenames_obj_dir( make, object_files );
|
|
|
|
output_filenames_obj_dir( make, res_files );
|
2016-02-16 08:53:59 +01:00
|
|
|
output_filenames( dep_libs );
|
2016-03-28 05:27:32 +02:00
|
|
|
output_filename( tools_path( make, "winebuild" ));
|
|
|
|
output_filename( tools_path( make, "winegcc" ));
|
2013-12-30 20:19:33 +01:00
|
|
|
output( "\n" );
|
|
|
|
|
2016-02-29 07:06:42 +01:00
|
|
|
if (!make->disabled)
|
|
|
|
output( "all: %s/%s\n", top_obj_dir_path( make, "programs/winetest" ), testres );
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s/%s: %s%s\n", top_obj_dir_path( make, "programs/winetest" ), testres,
|
|
|
|
obj_dir_path( make, stripped ), dll_ext );
|
2014-04-10 10:03:03 +02:00
|
|
|
output( "\techo \"%s TESTRES \\\"%s%s\\\"\" | %s -o $@\n",
|
2014-04-10 13:41:23 +02:00
|
|
|
testmodule, obj_dir_path( make, stripped ), dll_ext, tools_path( make, "wrc" ));
|
2013-12-30 20:19:33 +01:00
|
|
|
|
|
|
|
if (crosstarget)
|
|
|
|
{
|
2014-04-09 12:35:24 +02:00
|
|
|
char *crosstest = replace_extension( make->testdll, ".dll", "_crosstest.exe" );
|
2013-12-30 20:19:33 +01:00
|
|
|
|
2016-02-16 08:53:59 +01:00
|
|
|
dep_libs = empty_strarray;
|
|
|
|
all_libs = add_import_libs( make, &dep_libs, make->imports, 1 );
|
2016-02-23 12:21:47 +01:00
|
|
|
add_import_libs( make, &dep_libs, get_default_imports( make ), 1 ); /* dependencies only */
|
2016-02-16 08:53:59 +01:00
|
|
|
strarray_addall( &all_libs, libs );
|
2013-12-30 20:19:33 +01:00
|
|
|
strarray_add( &clean_files, crosstest );
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "%s:", obj_dir_path( make, crosstest ));
|
|
|
|
output_filenames_obj_dir( make, crossobj_files );
|
|
|
|
output_filenames_obj_dir( make, res_files );
|
2016-02-16 08:53:59 +01:00
|
|
|
output_filenames( dep_libs );
|
2016-03-28 05:27:32 +02:00
|
|
|
output_filename( tools_path( make, "winebuild" ));
|
|
|
|
output_filename( tools_path( make, "winegcc" ));
|
2013-12-30 20:19:33 +01:00
|
|
|
output( "\n" );
|
2014-04-10 13:41:23 +02:00
|
|
|
output( "\t%s -o $@ -b %s", tools_path( make, "winegcc" ), crosstarget );
|
|
|
|
output_filename( strmake( "-B%s", tools_dir_path( make, "winebuild" )));
|
|
|
|
if (tools_dir) output_filename( strmake( "--sysroot=%s", top_obj_dir_path( make, "" )));
|
2014-01-13 14:44:26 +01:00
|
|
|
output_filename( "--lib-suffix=.cross.a" );
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filenames_obj_dir( make, crossobj_files );
|
|
|
|
output_filenames_obj_dir( make, res_files );
|
2013-12-30 20:19:33 +01:00
|
|
|
output_filenames( all_libs );
|
|
|
|
output_filename( "$(LDFLAGS)" );
|
|
|
|
output( "\n" );
|
2016-02-29 07:06:42 +01:00
|
|
|
if (!make->disabled)
|
|
|
|
{
|
|
|
|
output( "%s: %s\n", obj_dir_path( make, "crosstest" ), obj_dir_path( make, crosstest ));
|
|
|
|
strarray_add( &phony_targets, obj_dir_path( make, "crosstest" ));
|
|
|
|
if (make->obj_dir) output( "crosstest: %s\n", obj_dir_path( make, "crosstest" ));
|
|
|
|
}
|
2013-12-30 20:19:33 +01:00
|
|
|
}
|
|
|
|
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filenames_obj_dir( make, ok_files );
|
2014-04-09 12:35:24 +02:00
|
|
|
output( ": %s%s ../%s%s\n", testmodule, dll_ext, make->testdll, dll_ext );
|
2016-02-29 07:06:42 +01:00
|
|
|
if (!make->disabled)
|
|
|
|
{
|
|
|
|
output( "check test:" );
|
|
|
|
output_filenames_obj_dir( make, ok_files );
|
|
|
|
output( "\n" );
|
|
|
|
strarray_add( &phony_targets, "check" );
|
|
|
|
strarray_add( &phony_targets, "test" );
|
|
|
|
}
|
2013-12-13 20:37:26 +01:00
|
|
|
output( "testclean::\n" );
|
2015-11-11 03:56:23 +01:00
|
|
|
output( "\trm -f" );
|
2014-04-10 13:41:23 +02:00
|
|
|
output_filenames_obj_dir( make, ok_files );
|
2013-10-15 12:39:42 +02:00
|
|
|
output( "\n" );
|
2013-12-28 19:52:33 +01:00
|
|
|
strarray_addall( &clean_files, ok_files );
|
2013-12-28 11:41:45 +01:00
|
|
|
strarray_add( &phony_targets, "testclean" );
|
2013-11-09 18:57:00 +01:00
|
|
|
}
|
|
|
|
|
2015-10-27 04:13:26 +01:00
|
|
|
for (i = 0; i < make->programs.count; i++)
|
|
|
|
{
|
2015-10-29 06:32:45 +01:00
|
|
|
char *program_installed = NULL;
|
2015-10-27 04:13:26 +01:00
|
|
|
char *program = strmake( "%s%s", make->programs.str[i], exe_ext );
|
2015-11-13 06:17:18 +01:00
|
|
|
struct strarray deps = get_local_dependencies( make, make->programs.str[i], in_files );
|
2016-02-23 07:03:50 +01:00
|
|
|
struct strarray all_libs = get_expanded_file_local_var( make, make->programs.str[i], "LDFLAGS" );
|
|
|
|
struct strarray objs = get_expanded_file_local_var( make, make->programs.str[i], "OBJS" );
|
|
|
|
struct strarray symlinks = get_expanded_file_local_var( make, make->programs.str[i], "SYMLINKS" );
|
2015-10-27 04:13:26 +01:00
|
|
|
|
|
|
|
if (!objs.count) objs = object_files;
|
2016-02-23 06:57:11 +01:00
|
|
|
strarray_addall( &all_libs, add_default_libraries( make, &deps ));
|
|
|
|
|
2015-10-27 04:13:26 +01:00
|
|
|
output( "%s:", obj_dir_path( make, program ) );
|
|
|
|
output_filenames_obj_dir( make, objs );
|
2015-11-13 06:17:18 +01:00
|
|
|
output_filenames( deps );
|
2015-10-27 04:13:26 +01:00
|
|
|
output( "\n" );
|
|
|
|
output( "\t$(CC) -o $@" );
|
|
|
|
output_filenames_obj_dir( make, objs );
|
2015-10-28 02:56:21 +01:00
|
|
|
|
|
|
|
if (strarray_exists( &all_libs, "-lwine" ))
|
|
|
|
{
|
|
|
|
strarray_add( &all_libs, strmake( "-L%s", top_obj_dir_path( make, "libs/wine" )));
|
|
|
|
if (ldrpath_local && ldrpath_install)
|
|
|
|
{
|
2015-10-29 06:32:45 +01:00
|
|
|
program_installed = strmake( "%s-installed%s", make->programs.str[i], exe_ext );
|
2015-10-28 02:56:21 +01:00
|
|
|
output_filename( ldrpath_local );
|
|
|
|
output_filenames( all_libs );
|
|
|
|
output_filename( "$(LDFLAGS)" );
|
|
|
|
output( "\n" );
|
|
|
|
output( "%s:", obj_dir_path( make, program_installed ) );
|
|
|
|
output_filenames_obj_dir( make, objs );
|
2015-11-13 06:17:18 +01:00
|
|
|
output_filenames( deps );
|
2015-10-28 02:56:21 +01:00
|
|
|
output( "\n" );
|
|
|
|
output( "\t$(CC) -o $@" );
|
|
|
|
output_filenames_obj_dir( make, objs );
|
|
|
|
output_filename( ldrpath_install );
|
|
|
|
strarray_add( &all_targets, program_installed );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-27 04:13:26 +01:00
|
|
|
output_filenames( all_libs );
|
|
|
|
output_filename( "$(LDFLAGS)" );
|
|
|
|
output( "\n" );
|
|
|
|
strarray_add( &all_targets, program );
|
2015-10-29 06:32:45 +01:00
|
|
|
|
2016-05-06 06:54:13 +02:00
|
|
|
for (j = 0; j < symlinks.count; j++)
|
2015-10-29 10:06:35 +01:00
|
|
|
{
|
2016-05-06 06:54:13 +02:00
|
|
|
output( "%s: %s\n", obj_dir_path( make, symlinks.str[j] ), obj_dir_path( make, program ));
|
|
|
|
output_symlink_rule( obj_dir_path( make, program ), obj_dir_path( make, symlinks.str[j] ));
|
2015-10-29 10:06:35 +01:00
|
|
|
}
|
2016-05-06 06:54:13 +02:00
|
|
|
strarray_addall( &all_targets, symlinks );
|
2015-10-29 10:06:35 +01:00
|
|
|
|
2015-11-10 04:03:52 +01:00
|
|
|
add_install_rule( make, install_rules, program, program_installed ? program_installed : program,
|
2015-10-29 06:32:45 +01:00
|
|
|
strmake( "p$(bindir)/%s", program ));
|
2015-10-29 10:06:35 +01:00
|
|
|
for (j = 0; j < symlinks.count; j++)
|
2015-11-10 04:03:52 +01:00
|
|
|
add_install_rule( make, install_rules, symlinks.str[j], program,
|
2015-10-29 10:06:35 +01:00
|
|
|
strmake( "y$(bindir)/%s%s", symlinks.str[j], exe_ext ));
|
2015-10-27 04:13:26 +01:00
|
|
|
}
|
|
|
|
|
2015-10-29 06:43:54 +01:00
|
|
|
for (i = 0; i < make->scripts.count; i++)
|
2015-11-10 04:03:52 +01:00
|
|
|
add_install_rule( make, install_rules, make->scripts.str[i], make->scripts.str[i],
|
2015-10-29 06:43:54 +01:00
|
|
|
strmake( "S$(bindir)/%s", make->scripts.str[i] ));
|
|
|
|
|
2016-02-29 07:06:42 +01:00
|
|
|
if (!make->disabled)
|
2013-12-30 20:08:13 +01:00
|
|
|
{
|
2016-02-29 07:06:42 +01:00
|
|
|
if (all_targets.count)
|
|
|
|
{
|
|
|
|
output( "all:" );
|
|
|
|
output_filenames_obj_dir( make, all_targets );
|
|
|
|
output( "\n" );
|
|
|
|
}
|
|
|
|
strarray_addall( &uninstall_files, output_install_rules( make, install_rules[INSTALL_LIB],
|
|
|
|
"install-lib", &phony_targets ));
|
|
|
|
strarray_addall( &uninstall_files, output_install_rules( make, install_rules[INSTALL_DEV],
|
|
|
|
"install-dev", &phony_targets ));
|
|
|
|
if (uninstall_files.count)
|
|
|
|
{
|
|
|
|
output( "uninstall::\n" );
|
|
|
|
output( "\trm -f" );
|
|
|
|
output_filenames( uninstall_files );
|
|
|
|
output( "\n" );
|
|
|
|
strarray_add_uniq( &phony_targets, "uninstall" );
|
|
|
|
}
|
2015-11-12 14:43:02 +01:00
|
|
|
}
|
2015-10-29 06:32:45 +01:00
|
|
|
|
2013-12-30 20:07:02 +01:00
|
|
|
strarray_addall( &clean_files, object_files );
|
|
|
|
strarray_addall( &clean_files, crossobj_files );
|
|
|
|
strarray_addall( &clean_files, res_files );
|
2013-12-30 20:08:13 +01:00
|
|
|
strarray_addall( &clean_files, all_targets );
|
2014-04-10 13:41:23 +02:00
|
|
|
strarray_addall( &clean_files, get_expanded_make_var_array( make, "EXTRA_TARGETS" ));
|
2013-12-30 20:07:02 +01:00
|
|
|
|
2016-01-11 10:41:18 +01:00
|
|
|
if (make->subdirs.count)
|
|
|
|
{
|
2016-02-26 07:10:06 +01:00
|
|
|
struct strarray build_deps = empty_strarray;
|
2016-01-11 13:02:28 +01:00
|
|
|
struct strarray makefile_deps = empty_strarray;
|
2016-02-26 10:06:25 +01:00
|
|
|
struct strarray distclean_files = get_expanded_make_var_array( make, "CONFIGURE_TARGETS" );
|
2016-01-11 13:02:28 +01:00
|
|
|
|
2016-02-26 10:06:25 +01:00
|
|
|
strarray_add( &distclean_files, obj_dir_path( make, output_makefile_name ));
|
|
|
|
if (!make->src_dir) strarray_add( &distclean_files, obj_dir_path( make, ".gitignore" ));
|
2016-01-11 10:41:18 +01:00
|
|
|
for (i = 0; i < make->subdirs.count; i++)
|
|
|
|
{
|
2016-02-26 07:10:06 +01:00
|
|
|
const struct makefile *submake = make->submakes[i];
|
|
|
|
|
2016-03-31 07:39:32 +02:00
|
|
|
strarray_add( &makefile_deps, top_src_dir_path( make, base_dir_path( submake,
|
|
|
|
strmake ( "%s.in", output_makefile_name ))));
|
2016-02-26 07:10:06 +01:00
|
|
|
strarray_add( &distclean_files, base_dir_path( submake, output_makefile_name ));
|
|
|
|
if (!make->src_dir) strarray_add( &distclean_files, base_dir_path( submake, ".gitignore" ));
|
|
|
|
if (submake->testdll) strarray_add( &distclean_files, base_dir_path( submake, "testlist.c" ));
|
|
|
|
strarray_addall( &build_deps, output_importlib_symlinks( make, submake ));
|
2016-01-11 10:41:18 +01:00
|
|
|
}
|
2016-01-11 13:02:28 +01:00
|
|
|
output( "Makefile:" );
|
|
|
|
output_filenames( makefile_deps );
|
|
|
|
output( "\n" );
|
2016-01-11 10:41:18 +01:00
|
|
|
output( "distclean::\n");
|
|
|
|
output( "\trm -f" );
|
|
|
|
output_filenames( distclean_files );
|
|
|
|
output( "\n" );
|
|
|
|
strarray_add( &phony_targets, "distclean" );
|
2016-02-25 07:36:02 +01:00
|
|
|
|
2016-02-26 07:10:06 +01:00
|
|
|
if (build_deps.count)
|
|
|
|
{
|
|
|
|
output( "__builddeps__:" );
|
|
|
|
output_filenames( build_deps );
|
|
|
|
output( "\n" );
|
|
|
|
strarray_addall( &clean_files, build_deps );
|
|
|
|
}
|
2016-02-25 07:36:02 +01:00
|
|
|
if (get_expanded_make_variable( make, "GETTEXTPO_LIBS" )) output_po_files( make );
|
2016-01-11 10:41:18 +01:00
|
|
|
}
|
|
|
|
|
2016-02-25 09:46:56 +01:00
|
|
|
if (clean_files.count)
|
|
|
|
{
|
|
|
|
output( "%s::\n", obj_dir_path( make, "clean" ));
|
|
|
|
output( "\trm -f" );
|
|
|
|
output_filenames_obj_dir( make, clean_files );
|
|
|
|
output( "\n" );
|
|
|
|
if (make->obj_dir) output( "__clean__: %s\n", obj_dir_path( make, "clean" ));
|
|
|
|
strarray_add( &phony_targets, obj_dir_path( make, "clean" ));
|
|
|
|
}
|
|
|
|
|
2013-12-28 11:41:45 +01:00
|
|
|
if (phony_targets.count)
|
|
|
|
{
|
2013-12-28 11:48:03 +01:00
|
|
|
output( ".PHONY:" );
|
2013-12-28 19:52:33 +01:00
|
|
|
output_filenames( phony_targets );
|
2013-12-28 11:41:45 +01:00
|
|
|
output( "\n" );
|
|
|
|
}
|
|
|
|
|
2016-02-26 10:06:25 +01:00
|
|
|
if (!make->base_dir)
|
|
|
|
strarray_addall( &clean_files, get_expanded_make_var_array( make, "CONFIGURE_TARGETS" ));
|
2013-12-13 20:37:26 +01:00
|
|
|
return clean_files;
|
1997-09-28 19:43:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-12 14:43:15 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* create_temp_file
|
|
|
|
*/
|
2013-12-28 11:47:15 +01:00
|
|
|
static FILE *create_temp_file( const char *orig )
|
2009-01-12 14:43:15 +01:00
|
|
|
{
|
2013-12-13 20:37:26 +01:00
|
|
|
char *name = xmalloc( strlen(orig) + 13 );
|
2009-01-12 14:43:15 +01:00
|
|
|
unsigned int i, id = getpid();
|
|
|
|
int fd;
|
|
|
|
FILE *ret = NULL;
|
|
|
|
|
|
|
|
for (i = 0; i < 100; i++)
|
|
|
|
{
|
2013-12-13 20:37:26 +01:00
|
|
|
sprintf( name, "%s.tmp%08x", orig, id );
|
2009-02-22 20:39:52 +01:00
|
|
|
if ((fd = open( name, O_RDWR | O_CREAT | O_EXCL, 0666 )) != -1)
|
2009-01-12 14:43:15 +01:00
|
|
|
{
|
|
|
|
ret = fdopen( fd, "w" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (errno != EEXIST) break;
|
|
|
|
id += 7777;
|
|
|
|
}
|
2013-12-13 20:37:26 +01:00
|
|
|
if (!ret) fatal_error( "failed to create output file for '%s'\n", orig );
|
2013-12-28 11:47:15 +01:00
|
|
|
temp_file_name = name;
|
2009-01-12 14:43:15 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-13 20:37:26 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* rename_temp_file
|
|
|
|
*/
|
2013-12-28 11:47:15 +01:00
|
|
|
static void rename_temp_file( const char *dest )
|
2013-12-13 20:37:26 +01:00
|
|
|
{
|
2013-12-28 11:47:15 +01:00
|
|
|
int ret = rename( temp_file_name, dest );
|
2013-12-13 20:37:26 +01:00
|
|
|
if (ret == -1 && errno == EEXIST)
|
|
|
|
{
|
|
|
|
/* rename doesn't overwrite on windows */
|
|
|
|
unlink( dest );
|
2013-12-28 11:47:15 +01:00
|
|
|
ret = rename( temp_file_name, dest );
|
2013-12-13 20:37:26 +01:00
|
|
|
}
|
2013-12-28 11:47:15 +01:00
|
|
|
if (ret == -1) fatal_error( "failed to rename output file to '%s'\n", dest );
|
|
|
|
temp_file_name = NULL;
|
2013-12-13 20:37:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-10 10:55:18 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* are_files_identical
|
|
|
|
*/
|
|
|
|
static int are_files_identical( FILE *file1, FILE *file2 )
|
|
|
|
{
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
char buffer1[8192], buffer2[8192];
|
|
|
|
int size1 = fread( buffer1, 1, sizeof(buffer1), file1 );
|
|
|
|
int size2 = fread( buffer2, 1, sizeof(buffer2), file2 );
|
|
|
|
if (size1 != size2) return 0;
|
|
|
|
if (!size1) return feof( file1 ) && feof( file2 );
|
|
|
|
if (memcmp( buffer1, buffer2, size1 )) return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* rename_temp_file_if_changed
|
|
|
|
*/
|
|
|
|
static void rename_temp_file_if_changed( const char *dest )
|
|
|
|
{
|
|
|
|
FILE *file1, *file2;
|
|
|
|
int do_rename = 1;
|
|
|
|
|
|
|
|
if ((file1 = fopen( dest, "r" )))
|
|
|
|
{
|
|
|
|
if ((file2 = fopen( temp_file_name, "r" )))
|
|
|
|
{
|
|
|
|
do_rename = !are_files_identical( file1, file2 );
|
|
|
|
fclose( file2 );
|
|
|
|
}
|
|
|
|
fclose( file1 );
|
|
|
|
}
|
|
|
|
if (!do_rename)
|
|
|
|
{
|
|
|
|
unlink( temp_file_name );
|
|
|
|
temp_file_name = NULL;
|
|
|
|
}
|
|
|
|
else rename_temp_file( dest );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-01 06:30:24 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* output_linguas
|
|
|
|
*/
|
|
|
|
static void output_linguas( const struct makefile *make )
|
|
|
|
{
|
|
|
|
const char *dest = base_dir_path( make, "LINGUAS" );
|
|
|
|
struct incl_file *source;
|
|
|
|
|
|
|
|
output_file = create_temp_file( dest );
|
|
|
|
|
|
|
|
output( "# Automatically generated by make depend; DO NOT EDIT!!\n" );
|
|
|
|
LIST_FOR_EACH_ENTRY( source, &make->sources, struct incl_file, entry )
|
|
|
|
if (strendswith( source->name, ".po" ))
|
|
|
|
output( "%s\n", replace_extension( source->name, ".po", "" ));
|
|
|
|
|
|
|
|
if (fclose( output_file )) fatal_perror( "write" );
|
|
|
|
output_file = NULL;
|
|
|
|
rename_temp_file_if_changed( dest );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-10 10:55:18 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* output_testlist
|
|
|
|
*/
|
2016-01-11 10:19:18 +01:00
|
|
|
static void output_testlist( const struct makefile *make )
|
2014-02-10 10:55:18 +01:00
|
|
|
{
|
2016-01-11 10:19:18 +01:00
|
|
|
const char *dest = base_dir_path( make, "testlist.c" );
|
|
|
|
struct strarray files = empty_strarray;
|
|
|
|
struct incl_file *source;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( source, &make->sources, struct incl_file, entry )
|
|
|
|
{
|
|
|
|
if (source->file->flags & FLAG_GENERATED) continue;
|
|
|
|
if (!strendswith( source->name, ".c" )) continue;
|
|
|
|
strarray_add( &files, replace_extension( source->name, ".c", "" ));
|
|
|
|
}
|
2014-02-10 10:55:18 +01:00
|
|
|
|
|
|
|
output_file = create_temp_file( dest );
|
|
|
|
|
|
|
|
output( "/* Automatically generated by make depend; DO NOT EDIT!! */\n\n" );
|
|
|
|
output( "#define WIN32_LEAN_AND_MEAN\n" );
|
|
|
|
output( "#include <windows.h>\n\n" );
|
|
|
|
output( "#define STANDALONE\n" );
|
|
|
|
output( "#include \"wine/test.h\"\n\n" );
|
|
|
|
|
|
|
|
for (i = 0; i < files.count; i++) output( "extern void func_%s(void);\n", files.str[i] );
|
|
|
|
output( "\n" );
|
|
|
|
output( "const struct test winetest_testlist[] =\n" );
|
|
|
|
output( "{\n" );
|
|
|
|
for (i = 0; i < files.count; i++) output( " { \"%s\", func_%s },\n", files.str[i], files.str[i] );
|
|
|
|
output( " { 0, 0 }\n" );
|
|
|
|
output( "};\n" );
|
|
|
|
|
|
|
|
if (fclose( output_file )) fatal_perror( "write" );
|
|
|
|
output_file = NULL;
|
|
|
|
rename_temp_file_if_changed( dest );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-13 20:37:26 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* output_gitignore
|
|
|
|
*/
|
2014-02-10 10:55:18 +01:00
|
|
|
static void output_gitignore( const char *dest, struct strarray files )
|
2013-12-13 20:37:26 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2013-12-28 11:47:15 +01:00
|
|
|
output_file = create_temp_file( dest );
|
2013-12-13 20:37:26 +01:00
|
|
|
|
|
|
|
output( "# Automatically generated by make depend; DO NOT EDIT!!\n" );
|
2014-02-10 10:55:18 +01:00
|
|
|
for (i = 0; i < files.count; i++)
|
2013-12-13 20:37:26 +01:00
|
|
|
{
|
2014-02-10 10:55:18 +01:00
|
|
|
if (!strchr( files.str[i], '/' )) output( "/" );
|
|
|
|
output( "%s\n", files.str[i] );
|
2013-12-13 20:37:26 +01:00
|
|
|
}
|
|
|
|
|
2013-12-28 11:47:15 +01:00
|
|
|
if (fclose( output_file )) fatal_perror( "write" );
|
2013-12-13 20:37:26 +01:00
|
|
|
output_file = NULL;
|
2013-12-28 11:47:15 +01:00
|
|
|
rename_temp_file( dest );
|
2013-12-13 20:37:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-23 07:49:36 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* output_top_variables
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static void output_top_variables( const struct makefile *make )
|
2015-10-23 07:49:36 +02:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
struct strarray *vars = &top_makefile->vars;
|
|
|
|
|
|
|
|
if (!make->base_dir) return; /* don't output variables in the top makefile */
|
|
|
|
|
|
|
|
output( "# Automatically generated by make depend; DO NOT EDIT!!\n\n" );
|
|
|
|
output( "all:\n\n" );
|
|
|
|
for (i = 0; i < vars->count; i += 2)
|
2016-01-11 08:05:51 +01:00
|
|
|
{
|
|
|
|
if (!strcmp( vars->str[i], "SUBDIRS" )) continue; /* not inherited */
|
2015-10-23 07:49:36 +02:00
|
|
|
output( "%s = %s\n", vars->str[i], get_make_variable( make, vars->str[i] ));
|
2016-01-11 08:05:51 +01:00
|
|
|
}
|
2015-10-23 07:49:36 +02:00
|
|
|
output( "\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-10-23 18:59:13 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* output_dependencies
|
|
|
|
*/
|
2015-11-10 04:07:37 +01:00
|
|
|
static void output_dependencies( const struct makefile *make )
|
1996-10-23 18:59:13 +02:00
|
|
|
{
|
2016-01-11 10:19:18 +01:00
|
|
|
struct strarray targets, ignore_files = empty_strarray;
|
2015-10-23 08:03:11 +02:00
|
|
|
char buffer[1024];
|
2015-10-23 07:49:36 +02:00
|
|
|
FILE *src_file;
|
2016-01-11 08:05:51 +01:00
|
|
|
int found = 0;
|
1996-10-23 18:59:13 +02:00
|
|
|
|
2016-02-25 10:00:36 +01:00
|
|
|
if (make->base_dir) create_dir( make->base_dir );
|
|
|
|
|
2015-10-23 10:42:44 +02:00
|
|
|
output_file_name = base_dir_path( make, output_makefile_name );
|
2015-10-23 08:03:11 +02:00
|
|
|
output_file = create_temp_file( output_file_name );
|
|
|
|
output_top_variables( make );
|
2009-01-12 14:43:15 +01:00
|
|
|
|
2015-10-23 08:03:11 +02:00
|
|
|
/* copy the contents of the source makefile */
|
2015-10-23 10:42:44 +02:00
|
|
|
src_file = open_input_makefile( make );
|
2016-01-11 08:05:51 +01:00
|
|
|
while (fgets( buffer, sizeof(buffer), src_file ) && !found)
|
|
|
|
{
|
2015-10-23 08:03:11 +02:00
|
|
|
if (fwrite( buffer, 1, strlen(buffer), output_file ) != strlen(buffer)) fatal_perror( "write" );
|
2016-01-11 08:05:51 +01:00
|
|
|
found = !strncmp( buffer, separator, strlen(separator) );
|
|
|
|
}
|
2015-10-23 08:03:11 +02:00
|
|
|
if (fclose( src_file )) fatal_perror( "close" );
|
2015-10-23 10:42:44 +02:00
|
|
|
input_file_name = NULL;
|
2013-10-14 11:11:07 +02:00
|
|
|
|
2016-01-11 08:05:51 +01:00
|
|
|
if (!found) output( "\n%s (everything below this line is auto-generated; DO NOT EDIT!!)\n", separator );
|
2016-01-11 10:19:18 +01:00
|
|
|
targets = output_sources( make );
|
2013-10-14 11:11:07 +02:00
|
|
|
|
|
|
|
fclose( output_file );
|
|
|
|
output_file = NULL;
|
2015-10-23 08:03:11 +02:00
|
|
|
rename_temp_file( output_file_name );
|
2013-12-13 20:37:26 +01:00
|
|
|
|
2014-02-10 10:55:18 +01:00
|
|
|
strarray_add( &ignore_files, ".gitignore" );
|
|
|
|
strarray_add( &ignore_files, "Makefile" );
|
2016-01-11 10:19:18 +01:00
|
|
|
if (make->testdll)
|
|
|
|
{
|
|
|
|
output_testlist( make );
|
|
|
|
strarray_add( &ignore_files, "testlist.c" );
|
|
|
|
}
|
2016-03-01 06:30:24 +01:00
|
|
|
if (make->base_dir && !strcmp( make->base_dir, "po" ))
|
|
|
|
{
|
|
|
|
output_linguas( make );
|
|
|
|
strarray_add( &ignore_files, "LINGUAS" );
|
|
|
|
}
|
2014-02-10 10:55:18 +01:00
|
|
|
strarray_addall( &ignore_files, targets );
|
2016-02-26 10:06:25 +01:00
|
|
|
if (!make->src_dir) output_gitignore( base_dir_path( make, ".gitignore" ), ignore_files );
|
2015-10-23 08:03:11 +02:00
|
|
|
|
2016-02-25 10:00:36 +01:00
|
|
|
create_file_directories( make, targets );
|
|
|
|
|
2015-10-23 08:03:11 +02:00
|
|
|
output_file_name = NULL;
|
2013-12-17 17:10:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
2016-01-11 08:05:51 +01:00
|
|
|
* load_sources
|
2013-12-17 17:10:28 +01:00
|
|
|
*/
|
2016-01-11 08:05:51 +01:00
|
|
|
static void load_sources( struct makefile *make )
|
2013-12-17 17:10:28 +01:00
|
|
|
{
|
|
|
|
static const char *source_vars[] =
|
|
|
|
{
|
|
|
|
"C_SRCS",
|
|
|
|
"OBJC_SRCS",
|
|
|
|
"RC_SRCS",
|
|
|
|
"MC_SRCS",
|
2013-12-31 18:15:17 +01:00
|
|
|
"IDL_SRCS",
|
2013-12-17 17:10:28 +01:00
|
|
|
"BISON_SRCS",
|
|
|
|
"LEX_SRCS",
|
2015-11-02 07:53:42 +01:00
|
|
|
"HEADER_SRCS",
|
2013-12-17 17:10:28 +01:00
|
|
|
"XTEMPLATE_SRCS",
|
2013-12-26 19:56:16 +01:00
|
|
|
"SVG_SRCS",
|
2013-12-26 20:02:42 +01:00
|
|
|
"FONT_SRCS",
|
2013-12-17 17:10:28 +01:00
|
|
|
"IN_SRCS",
|
2016-03-01 06:21:01 +01:00
|
|
|
"PO_SRCS",
|
2013-12-17 17:10:28 +01:00
|
|
|
"MANPAGES",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
const char **var;
|
|
|
|
unsigned int i;
|
|
|
|
struct strarray value;
|
|
|
|
struct incl_file *file;
|
|
|
|
|
2014-04-09 12:32:54 +02:00
|
|
|
if (root_src_dir)
|
|
|
|
{
|
|
|
|
make->top_src_dir = concat_paths( make->top_obj_dir, root_src_dir );
|
|
|
|
make->src_dir = concat_paths( make->top_src_dir, make->base_dir );
|
|
|
|
}
|
2014-04-10 13:41:23 +02:00
|
|
|
strarray_set_value( &make->vars, "top_builddir", top_obj_dir_path( make, "" ));
|
2016-03-31 07:39:32 +02:00
|
|
|
strarray_set_value( &make->vars, "top_srcdir", top_src_dir_path( make, "" ));
|
2014-04-10 13:41:23 +02:00
|
|
|
strarray_set_value( &make->vars, "srcdir", src_dir_path( make, "" ));
|
2014-04-09 10:12:44 +02:00
|
|
|
|
2014-04-10 13:41:23 +02:00
|
|
|
make->parent_dir = get_expanded_make_variable( make, "PARENTSRC" );
|
|
|
|
make->module = get_expanded_make_variable( make, "MODULE" );
|
|
|
|
make->testdll = get_expanded_make_variable( make, "TESTDLL" );
|
2015-11-12 14:08:03 +01:00
|
|
|
make->sharedlib = get_expanded_make_variable( make, "SHAREDLIB" );
|
2014-04-10 13:41:23 +02:00
|
|
|
make->staticlib = get_expanded_make_variable( make, "STATICLIB" );
|
|
|
|
make->importlib = get_expanded_make_variable( make, "IMPORTLIB" );
|
2014-04-09 12:35:24 +02:00
|
|
|
|
2015-10-27 04:13:26 +01:00
|
|
|
make->programs = get_expanded_make_var_array( make, "PROGRAMS" );
|
2015-10-29 06:43:54 +01:00
|
|
|
make->scripts = get_expanded_make_var_array( make, "SCRIPTS" );
|
2014-04-10 13:41:23 +02:00
|
|
|
make->appmode = get_expanded_make_var_array( make, "APPMODE" );
|
|
|
|
make->imports = get_expanded_make_var_array( make, "IMPORTS" );
|
|
|
|
make->delayimports = get_expanded_make_var_array( make, "DELAYIMPORTS" );
|
|
|
|
make->extradllflags = get_expanded_make_var_array( make, "EXTRADLLFLAGS" );
|
2015-10-29 06:32:45 +01:00
|
|
|
make->install_lib = get_expanded_make_var_array( make, "INSTALL_LIB" );
|
|
|
|
make->install_dev = get_expanded_make_var_array( make, "INSTALL_DEV" );
|
2014-04-09 12:35:24 +02:00
|
|
|
|
|
|
|
if (make->module && strendswith( make->module, ".a" )) make->staticlib = make->module;
|
2014-04-09 10:12:44 +02:00
|
|
|
|
2016-02-29 07:06:42 +01:00
|
|
|
make->disabled = make->base_dir && strarray_exists( &disabled_dirs, make->base_dir );
|
2014-04-10 13:15:13 +02:00
|
|
|
make->is_win16 = strarray_exists( &make->extradllflags, "-m16" );
|
|
|
|
make->use_msvcrt = strarray_exists( &make->appmode, "-mno-cygwin" );
|
|
|
|
|
2014-04-09 10:12:44 +02:00
|
|
|
for (i = 0; i < make->imports.count && !make->use_msvcrt; i++)
|
2015-11-04 11:21:58 +01:00
|
|
|
make->use_msvcrt = !strncmp( make->imports.str[i], "msvcr", 5 ) ||
|
|
|
|
!strcmp( make->imports.str[i], "ucrtbase" );
|
2014-04-09 10:12:44 +02:00
|
|
|
|
2016-04-04 07:06:10 +02:00
|
|
|
if (make->module && !make->install_lib.count && !make->install_dev.count)
|
|
|
|
{
|
|
|
|
if (make->importlib) strarray_add( &make->install_dev, make->importlib );
|
|
|
|
if (make->staticlib) strarray_add( &make->install_dev, make->staticlib );
|
|
|
|
else strarray_add( &make->install_lib, make->module );
|
|
|
|
}
|
2015-10-29 06:32:45 +01:00
|
|
|
|
2015-11-11 07:02:57 +01:00
|
|
|
make->include_paths = empty_strarray;
|
2014-04-09 10:12:44 +02:00
|
|
|
make->define_args = empty_strarray;
|
|
|
|
strarray_add( &make->define_args, "-D__WINESRC__" );
|
2014-01-07 10:56:15 +01:00
|
|
|
|
2014-04-10 13:41:23 +02:00
|
|
|
value = get_expanded_make_var_array( make, "EXTRAINCL" );
|
2013-12-17 17:10:28 +01:00
|
|
|
for (i = 0; i < value.count; i++)
|
|
|
|
if (!strncmp( value.str[i], "-I", 2 ))
|
2015-11-11 07:02:57 +01:00
|
|
|
strarray_add_uniq( &make->include_paths, value.str[i] + 2 );
|
2014-01-07 10:56:15 +01:00
|
|
|
else
|
2014-04-09 10:12:44 +02:00
|
|
|
strarray_add_uniq( &make->define_args, value.str[i] );
|
2014-04-10 13:41:23 +02:00
|
|
|
strarray_addall( &make->define_args, get_expanded_make_var_array( make, "EXTRADEFS" ));
|
2013-12-17 17:10:28 +01:00
|
|
|
|
2014-04-10 13:50:37 +02:00
|
|
|
list_init( &make->sources );
|
2014-04-11 17:03:54 +02:00
|
|
|
list_init( &make->includes );
|
2013-12-17 17:10:28 +01:00
|
|
|
|
|
|
|
for (var = source_vars; *var; var++)
|
|
|
|
{
|
2014-04-10 13:41:23 +02:00
|
|
|
value = get_expanded_make_var_array( make, *var );
|
|
|
|
for (i = 0; i < value.count; i++) add_src_file( make, value.str[i] );
|
2013-12-17 17:10:28 +01:00
|
|
|
}
|
|
|
|
|
2014-04-10 13:41:23 +02:00
|
|
|
add_generated_sources( make );
|
2013-12-26 19:27:59 +01:00
|
|
|
|
2014-04-10 13:41:23 +02:00
|
|
|
value = get_expanded_make_var_array( make, "EXTRA_OBJS" );
|
2013-12-26 19:27:59 +01:00
|
|
|
for (i = 0; i < value.count; i++)
|
|
|
|
{
|
|
|
|
/* default to .c for unknown extra object files */
|
|
|
|
if (strendswith( value.str[i], ".o" ))
|
2014-04-10 13:41:23 +02:00
|
|
|
add_generated_source( make, value.str[i], replace_extension( value.str[i], ".o", ".c" ) );
|
2013-12-26 19:27:59 +01:00
|
|
|
else
|
2014-04-10 13:41:23 +02:00
|
|
|
add_generated_source( make, value.str[i], NULL );
|
2013-12-26 19:27:59 +01:00
|
|
|
}
|
|
|
|
|
2014-04-11 17:03:54 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( file, &make->includes, struct incl_file, entry ) parse_file( make, file, 0 );
|
1996-10-23 18:59:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-26 19:26:37 +01:00
|
|
|
/*******************************************************************
|
|
|
|
* parse_makeflags
|
|
|
|
*/
|
|
|
|
static void parse_makeflags( const char *flags )
|
|
|
|
{
|
|
|
|
const char *p = flags;
|
|
|
|
char *var, *buffer = xmalloc( strlen(flags) + 1 );
|
|
|
|
|
|
|
|
while (*p)
|
|
|
|
{
|
|
|
|
while (isspace(*p)) p++;
|
|
|
|
var = buffer;
|
|
|
|
while (*p && !isspace(*p))
|
|
|
|
{
|
|
|
|
if (*p == '\\' && p[1]) p++;
|
|
|
|
*var++ = *p++;
|
|
|
|
}
|
|
|
|
*var = 0;
|
|
|
|
if (var > buffer) set_make_variable( &cmdline_vars, buffer );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-10-23 18:59:13 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* parse_option
|
|
|
|
*/
|
2013-12-26 19:26:29 +01:00
|
|
|
static int parse_option( const char *opt )
|
1996-10-23 18:59:13 +02:00
|
|
|
{
|
2013-12-26 19:26:29 +01:00
|
|
|
if (opt[0] != '-')
|
|
|
|
{
|
|
|
|
if (strchr( opt, '=' )) return set_make_variable( &cmdline_vars, opt );
|
|
|
|
return 0;
|
|
|
|
}
|
1996-10-23 18:59:13 +02:00
|
|
|
switch(opt[1])
|
|
|
|
{
|
|
|
|
case 'f':
|
2015-10-23 10:42:44 +02:00
|
|
|
if (opt[2]) output_makefile_name = opt + 2;
|
|
|
|
break;
|
2013-11-08 21:11:59 +01:00
|
|
|
case 'R':
|
|
|
|
relative_dir_mode = 1;
|
|
|
|
break;
|
1996-10-23 18:59:13 +02:00
|
|
|
default:
|
2013-10-14 11:11:07 +02:00
|
|
|
fprintf( stderr, "Unknown option '%s'\n%s", opt, Usage );
|
1996-10-23 18:59:13 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
2013-12-26 19:26:29 +01:00
|
|
|
return 1;
|
1996-10-23 18:59:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* main
|
|
|
|
*/
|
|
|
|
int main( int argc, char *argv[] )
|
|
|
|
{
|
2013-12-26 19:26:37 +01:00
|
|
|
const char *makeflags = getenv( "MAKEFLAGS" );
|
2006-08-01 12:27:22 +02:00
|
|
|
int i, j;
|
1996-10-23 18:59:13 +02:00
|
|
|
|
2013-12-26 19:26:37 +01:00
|
|
|
if (makeflags) parse_makeflags( makeflags );
|
|
|
|
|
2006-08-01 12:27:22 +02:00
|
|
|
i = 1;
|
|
|
|
while (i < argc)
|
1996-10-23 18:59:13 +02:00
|
|
|
{
|
2013-12-26 19:26:29 +01:00
|
|
|
if (parse_option( argv[i] ))
|
2006-08-01 12:27:22 +02:00
|
|
|
{
|
|
|
|
for (j = i; j < argc; j++) argv[j] = argv[j+1];
|
|
|
|
argc--;
|
|
|
|
}
|
|
|
|
else i++;
|
|
|
|
}
|
|
|
|
|
2013-11-08 21:11:59 +01:00
|
|
|
if (relative_dir_mode)
|
|
|
|
{
|
|
|
|
char *relpath;
|
|
|
|
|
|
|
|
if (argc != 3)
|
|
|
|
{
|
2015-11-11 04:05:56 +01:00
|
|
|
fprintf( stderr, "Option -R needs two directories\n%s", Usage );
|
2013-11-08 21:11:59 +01:00
|
|
|
exit( 1 );
|
|
|
|
}
|
|
|
|
relpath = get_relative_path( argv[1], argv[2] );
|
|
|
|
printf( "%s\n", relpath ? relpath : "." );
|
|
|
|
exit( 0 );
|
|
|
|
}
|
|
|
|
|
2013-12-28 11:47:15 +01:00
|
|
|
atexit( cleanup_files );
|
|
|
|
signal( SIGTERM, exit_on_signal );
|
|
|
|
signal( SIGINT, exit_on_signal );
|
|
|
|
#ifdef SIGHUP
|
|
|
|
signal( SIGHUP, exit_on_signal );
|
|
|
|
#endif
|
|
|
|
|
2014-04-11 16:55:51 +02:00
|
|
|
for (i = 0; i < HASH_SIZE; i++) list_init( &files[i] );
|
|
|
|
|
2016-02-25 09:08:12 +01:00
|
|
|
top_makefile = parse_makefile( NULL );
|
2014-04-10 13:41:23 +02:00
|
|
|
|
|
|
|
target_flags = get_expanded_make_var_array( top_makefile, "TARGETFLAGS" );
|
|
|
|
msvcrt_flags = get_expanded_make_var_array( top_makefile, "MSVCRTFLAGS" );
|
|
|
|
dll_flags = get_expanded_make_var_array( top_makefile, "DLLFLAGS" );
|
|
|
|
extra_cflags = get_expanded_make_var_array( top_makefile, "EXTRACFLAGS" );
|
|
|
|
cpp_flags = get_expanded_make_var_array( top_makefile, "CPPFLAGS" );
|
|
|
|
unwind_flags = get_expanded_make_var_array( top_makefile, "UNWINDFLAGS" );
|
|
|
|
libs = get_expanded_make_var_array( top_makefile, "LIBS" );
|
|
|
|
|
|
|
|
root_src_dir = get_expanded_make_variable( top_makefile, "srcdir" );
|
|
|
|
tools_dir = get_expanded_make_variable( top_makefile, "TOOLSDIR" );
|
|
|
|
tools_ext = get_expanded_make_variable( top_makefile, "TOOLSEXT" );
|
|
|
|
exe_ext = get_expanded_make_variable( top_makefile, "EXEEXT" );
|
|
|
|
man_ext = get_expanded_make_variable( top_makefile, "api_manext" );
|
2014-04-02 14:09:42 +02:00
|
|
|
dll_ext = (exe_ext && !strcmp( exe_ext, ".exe" )) ? "" : ".so";
|
2014-04-10 13:41:23 +02:00
|
|
|
crosstarget = get_expanded_make_variable( top_makefile, "CROSSTARGET" );
|
|
|
|
fontforge = get_expanded_make_variable( top_makefile, "FONTFORGE" );
|
|
|
|
convert = get_expanded_make_variable( top_makefile, "CONVERT" );
|
|
|
|
rsvg = get_expanded_make_variable( top_makefile, "RSVG" );
|
|
|
|
icotool = get_expanded_make_variable( top_makefile, "ICOTOOL" );
|
2015-11-12 15:19:24 +01:00
|
|
|
dlltool = get_expanded_make_variable( top_makefile, "DLLTOOL" );
|
2016-02-25 09:46:56 +01:00
|
|
|
msgfmt = get_expanded_make_variable( top_makefile, "MSGFMT" );
|
2016-02-26 07:13:00 +01:00
|
|
|
ln_s = get_expanded_make_variable( top_makefile, "LN_S" );
|
2014-04-02 14:09:42 +02:00
|
|
|
|
2014-04-09 12:32:54 +02:00
|
|
|
if (root_src_dir && !strcmp( root_src_dir, "." )) root_src_dir = NULL;
|
2014-04-02 14:09:42 +02:00
|
|
|
if (tools_dir && !strcmp( tools_dir, "." )) tools_dir = NULL;
|
2015-10-27 04:13:26 +01:00
|
|
|
if (!exe_ext) exe_ext = "";
|
2014-04-02 14:09:42 +02:00
|
|
|
if (!tools_ext) tools_ext = "";
|
|
|
|
if (!man_ext) man_ext = "3w";
|
|
|
|
|
2016-01-11 08:05:51 +01:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2016-02-29 07:06:42 +01:00
|
|
|
disabled_dirs = get_expanded_make_var_array( top_makefile, "DISABLED_SUBDIRS" );
|
2016-01-11 08:05:51 +01:00
|
|
|
top_makefile->subdirs = get_expanded_make_var_array( top_makefile, "SUBDIRS" );
|
|
|
|
top_makefile->submakes = xmalloc( top_makefile->subdirs.count * sizeof(*top_makefile->submakes) );
|
|
|
|
|
|
|
|
for (i = 0; i < top_makefile->subdirs.count; i++)
|
2016-02-25 09:08:12 +01:00
|
|
|
top_makefile->submakes[i] = parse_makefile( top_makefile->subdirs.str[i] );
|
2016-01-11 08:05:51 +01:00
|
|
|
|
|
|
|
load_sources( top_makefile );
|
|
|
|
for (i = 0; i < top_makefile->subdirs.count; i++)
|
|
|
|
load_sources( top_makefile->submakes[i] );
|
|
|
|
|
|
|
|
for (i = 0; i < top_makefile->subdirs.count; i++)
|
|
|
|
output_dependencies( top_makefile->submakes[i] );
|
|
|
|
|
|
|
|
output_dependencies( top_makefile );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
{
|
2016-02-25 09:08:12 +01:00
|
|
|
struct makefile *make = parse_makefile( argv[i] );
|
2016-01-11 08:05:51 +01:00
|
|
|
load_sources( make );
|
|
|
|
output_dependencies( make );
|
|
|
|
}
|
1996-10-23 18:59:13 +02:00
|
|
|
return 0;
|
|
|
|
}
|