1996-10-23 09:59:13 -07:00
|
|
|
/*
|
|
|
|
* Generate include file dependencies
|
|
|
|
*
|
2020-09-12 02:40:00 -07:00
|
|
|
* Copyright 1996, 2013, 2020 Alexandre Julliard
|
2002-03-09 16:29:33 -07: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 05:49:52 -07:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1996-10-23 09:59:13 -07:00
|
|
|
*/
|
|
|
|
|
2002-04-26 12:05:15 -07:00
|
|
|
#include "config.h"
|
|
|
|
|
2006-08-01 03:16:29 -07:00
|
|
|
#include <assert.h>
|
1996-10-23 09:59:13 -07:00
|
|
|
#include <ctype.h>
|
2006-08-01 03:13:57 -07:00
|
|
|
#include <errno.h>
|
2020-12-01 02:25:17 -07:00
|
|
|
#include <fcntl.h>
|
1996-10-23 09:59:13 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2004-04-06 21:00:16 -07:00
|
|
|
#include <stdarg.h>
|
1996-10-23 09:59:13 -07:00
|
|
|
#include <string.h>
|
2020-12-01 02:25:17 -07:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2021-10-06 01:16:59 -07:00
|
|
|
|
2021-09-28 01:08:06 -07:00
|
|
|
#include "tools.h"
|
2006-08-01 03:13:57 -07:00
|
|
|
#include "wine/list.h"
|
1996-10-23 09:59:13 -07:00
|
|
|
|
2014-04-11 07:55:51 -07:00
|
|
|
enum incl_type
|
|
|
|
{
|
|
|
|
INCL_NORMAL, /* #include "foo.h" */
|
|
|
|
INCL_SYSTEM, /* #include <foo.h> */
|
|
|
|
INCL_IMPORT, /* idl import "foo.idl" */
|
2015-11-04 22:25:35 -07:00
|
|
|
INCL_IMPORTLIB, /* idl importlib "foo.tlb" */
|
2014-04-11 07:55:51 -07: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 01:51:37 -07:00
|
|
|
struct incl_file
|
1996-10-23 09:59:13 -07:00
|
|
|
{
|
2006-08-01 03:13:57 -07:00
|
|
|
struct list entry;
|
2022-07-28 06:32:17 -07:00
|
|
|
struct list hash_entry;
|
2014-04-11 07:55:51 -07:00
|
|
|
struct file *file;
|
1996-10-23 09:59:13 -07:00
|
|
|
char *name;
|
|
|
|
char *filename;
|
2020-09-11 00:53:23 -07:00
|
|
|
char *basename; /* base target name for generated files */
|
2006-09-10 13:04:42 -07:00
|
|
|
char *sourcename; /* source file name for generated headers */
|
2013-10-14 01:51:37 -07:00
|
|
|
struct incl_file *included_by; /* file that included this one */
|
2000-11-05 22:32:59 -07:00
|
|
|
int included_line; /* line where this file was included */
|
2015-11-04 22:25:35 -07:00
|
|
|
enum incl_type type; /* type of include */
|
2022-10-25 02:08:26 -07:00
|
|
|
unsigned int arch; /* architecture for multi-arch files, otherwise 0 */
|
2023-04-21 00:54:37 -07:00
|
|
|
unsigned int use_msvcrt:1; /* put msvcrt headers in the search path? */
|
|
|
|
unsigned int is_external:1; /* file from external library? */
|
2013-10-14 01:51:37 -07:00
|
|
|
struct incl_file *owner;
|
2014-01-04 04:25:56 -07:00
|
|
|
unsigned int files_count; /* files in use */
|
|
|
|
unsigned int files_size; /* total allocated size */
|
|
|
|
struct incl_file **files;
|
2018-02-17 01:53:42 -07:00
|
|
|
struct strarray dependencies; /* file dependencies */
|
2021-11-12 07:14:12 -07:00
|
|
|
struct strarray importlibdeps; /* importlib dependencies */
|
2013-10-14 01:51:37 -07:00
|
|
|
};
|
1996-10-23 09:59:13 -07:00
|
|
|
|
2014-04-11 07:55:51 -07:00
|
|
|
#define FLAG_GENERATED 0x000001 /* generated file */
|
|
|
|
#define FLAG_INSTALL 0x000002 /* file to install */
|
2023-08-11 01:15:22 -07:00
|
|
|
#define FLAG_TESTDLL 0x000004 /* file is part of a TESTDLL resource */
|
2014-02-05 05:44:51 -07: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 */
|
2021-11-16 02:22:51 -07:00
|
|
|
#define FLAG_IDL_TYPELIB 0x002000 /* generates a typelib (_l.res) file */
|
2014-02-05 05:44:51 -07:00
|
|
|
#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 */
|
2022-07-27 23:53:19 -07:00
|
|
|
#define FLAG_RC_HEADER 0x020000 /* rc file is a header */
|
|
|
|
#define FLAG_C_IMPLIB 0x040000 /* file is part of an import library */
|
|
|
|
#define FLAG_C_UNIX 0x080000 /* file is part of a Unix library */
|
|
|
|
#define FLAG_SFD_FONTS 0x100000 /* sfd file generated bitmap fonts */
|
2024-04-30 05:52:35 -07:00
|
|
|
#define FLAG_ARM64EC_X64 0x200000 /* use x86_64 object on ARM64EC */
|
2013-11-04 09:39:30 -07:00
|
|
|
|
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
unsigned int flag;
|
|
|
|
const char *ext;
|
|
|
|
} idl_outputs[] =
|
|
|
|
{
|
2021-11-16 02:22:51 -07:00
|
|
|
{ FLAG_IDL_TYPELIB, "_l.res" },
|
2013-12-24 13:12:08 -07:00
|
|
|
{ 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" },
|
2013-11-04 09:39:30 -07:00
|
|
|
};
|
|
|
|
|
2022-07-28 06:32:17 -07:00
|
|
|
#define HASH_SIZE 197
|
2014-04-11 07:55:51 -07:00
|
|
|
|
|
|
|
static struct list files[HASH_SIZE];
|
2022-07-28 06:32:17 -07:00
|
|
|
static struct list global_includes[HASH_SIZE];
|
1996-10-23 09:59:13 -07:00
|
|
|
|
2022-09-07 01:29:14 -07:00
|
|
|
enum install_rules { INSTALL_LIB, INSTALL_DEV, INSTALL_TEST, NB_INSTALL_RULES };
|
|
|
|
static const char *install_targets[NB_INSTALL_RULES] = { "install-lib", "install-dev", "install-test" };
|
|
|
|
static const char *install_variables[NB_INSTALL_RULES] = { "INSTALL_LIB", "INSTALL_DEV", "INSTALL_TEST" };
|
2015-11-09 20:03:52 -07:00
|
|
|
|
2023-09-30 08:38:24 -07:00
|
|
|
#define MAX_ARCHS 6
|
2022-10-24 02:42:31 -07:00
|
|
|
|
2014-04-02 05:09:42 -07:00
|
|
|
/* variables common to all makefiles */
|
2022-10-24 02:42:31 -07:00
|
|
|
static struct strarray archs;
|
2014-04-02 05:09:42 -07:00
|
|
|
static struct strarray linguas;
|
|
|
|
static struct strarray dll_flags;
|
2021-09-22 01:34:07 -07:00
|
|
|
static struct strarray unix_dllflags;
|
2014-04-02 05:09:42 -07:00
|
|
|
static struct strarray msvcrt_flags;
|
|
|
|
static struct strarray cpp_flags;
|
2019-04-30 13:42:17 -07:00
|
|
|
static struct strarray lddll_flags;
|
2014-04-02 05:09:42 -07:00
|
|
|
static struct strarray libs;
|
2018-03-04 07:36:10 -07:00
|
|
|
static struct strarray enable_tests;
|
2014-04-02 05:09:42 -07:00
|
|
|
static struct strarray cmdline_vars;
|
2020-09-14 03:48:06 -07:00
|
|
|
static struct strarray subdirs;
|
2019-05-03 01:52:51 -07:00
|
|
|
static struct strarray delay_import_libs;
|
2022-09-07 01:12:00 -07:00
|
|
|
static struct strarray top_install[NB_INSTALL_RULES];
|
2014-04-02 05:09:42 -07: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 *fontforge;
|
|
|
|
static const char *convert;
|
2018-11-30 05:26:36 -07:00
|
|
|
static const char *flex;
|
|
|
|
static const char *bison;
|
2014-04-02 05:09:42 -07:00
|
|
|
static const char *rsvg;
|
|
|
|
static const char *icotool;
|
2016-02-25 01:46:56 -07:00
|
|
|
static const char *msgfmt;
|
2016-02-25 23:13:00 -07:00
|
|
|
static const char *ln_s;
|
2018-11-30 05:26:36 -07:00
|
|
|
static const char *sed_cmd;
|
2021-09-02 04:04:43 -07:00
|
|
|
static const char *wayland_scanner;
|
2024-10-07 03:44:05 -07:00
|
|
|
static const char *sarif_converter;
|
2023-06-15 01:46:36 -07:00
|
|
|
static int so_dll_supported;
|
2023-06-15 01:27:06 -07:00
|
|
|
static int unix_lib_supported;
|
2022-10-24 02:42:31 -07:00
|
|
|
/* per-architecture global variables */
|
2023-06-15 01:27:06 -07:00
|
|
|
static const char *dll_ext[MAX_ARCHS];
|
2022-10-26 02:04:43 -07:00
|
|
|
static const char *arch_dirs[MAX_ARCHS];
|
|
|
|
static const char *arch_pe_dirs[MAX_ARCHS];
|
2022-10-25 02:03:54 -07:00
|
|
|
static const char *arch_install_dirs[MAX_ARCHS];
|
2022-10-24 02:42:31 -07:00
|
|
|
static const char *strip_progs[MAX_ARCHS];
|
2022-10-24 02:46:48 -07:00
|
|
|
static const char *debug_flags[MAX_ARCHS];
|
2022-10-24 03:12:51 -07:00
|
|
|
static const char *delay_load_flags[MAX_ARCHS];
|
2022-10-24 02:42:31 -07:00
|
|
|
static struct strarray target_flags[MAX_ARCHS];
|
2022-10-24 03:22:25 -07:00
|
|
|
static struct strarray extra_cflags[MAX_ARCHS];
|
|
|
|
static struct strarray extra_cflags_extlib[MAX_ARCHS];
|
2022-11-01 02:28:05 -07:00
|
|
|
static struct strarray disabled_dirs[MAX_ARCHS];
|
2024-04-08 15:00:24 -07:00
|
|
|
static unsigned int native_archs[MAX_ARCHS];
|
|
|
|
static unsigned int hybrid_archs[MAX_ARCHS];
|
|
|
|
static struct strarray hybrid_target_flags[MAX_ARCHS];
|
2014-04-02 05:09:42 -07:00
|
|
|
|
2014-04-09 01:12:44 -07:00
|
|
|
struct makefile
|
|
|
|
{
|
2018-02-17 01:53:42 -07:00
|
|
|
/* values determined from input makefile */
|
2014-04-09 01:12:44 -07:00
|
|
|
struct strarray vars;
|
2015-11-10 23:02:57 -07:00
|
|
|
struct strarray include_paths;
|
2018-02-17 01:53:42 -07:00
|
|
|
struct strarray include_args;
|
2014-04-09 01:12:44 -07:00
|
|
|
struct strarray define_args;
|
2022-06-29 02:06:16 -07:00
|
|
|
struct strarray unix_cflags;
|
2015-10-26 20:13:26 -07:00
|
|
|
struct strarray programs;
|
2015-10-28 22:43:54 -07:00
|
|
|
struct strarray scripts;
|
2014-04-09 01:12:44 -07:00
|
|
|
struct strarray imports;
|
2014-04-09 03:35:24 -07:00
|
|
|
struct strarray delayimports;
|
|
|
|
struct strarray extradllflags;
|
2022-09-07 01:12:00 -07:00
|
|
|
struct strarray install[NB_INSTALL_RULES];
|
2018-11-30 05:09:12 -07:00
|
|
|
struct strarray extra_targets;
|
2020-06-12 10:40:25 -07:00
|
|
|
struct strarray extra_imports;
|
2014-04-10 04:50:37 -07:00
|
|
|
struct list sources;
|
2014-04-11 08:03:54 -07:00
|
|
|
struct list includes;
|
2014-04-09 01:12:44 -07:00
|
|
|
const char *src_dir;
|
2014-04-10 01:03:03 -07:00
|
|
|
const char *obj_dir;
|
2014-04-09 01:12:44 -07:00
|
|
|
const char *parent_dir;
|
2014-04-09 03:35:24 -07:00
|
|
|
const char *module;
|
|
|
|
const char *testdll;
|
2021-10-18 02:06:55 -07:00
|
|
|
const char *extlib;
|
2014-04-09 03:35:24 -07:00
|
|
|
const char *staticlib;
|
|
|
|
const char *importlib;
|
2021-09-20 06:29:17 -07:00
|
|
|
const char *unixlib;
|
2022-02-16 08:10:08 -07:00
|
|
|
int data_only;
|
2014-04-09 03:35:24 -07:00
|
|
|
int is_win16;
|
2019-04-09 01:13:37 -07:00
|
|
|
int is_exe;
|
2022-10-26 02:03:51 -07:00
|
|
|
int disabled[MAX_ARCHS];
|
2018-02-17 01:53:42 -07:00
|
|
|
|
|
|
|
/* values generated at output time */
|
|
|
|
struct strarray in_files;
|
2020-09-09 02:46:00 -07:00
|
|
|
struct strarray pot_files;
|
2021-11-20 05:26:51 -07:00
|
|
|
struct strarray test_files;
|
2024-10-07 03:44:05 -07:00
|
|
|
struct strarray sast_files;
|
2018-02-17 01:53:42 -07:00
|
|
|
struct strarray clean_files;
|
2018-02-21 04:29:06 -07:00
|
|
|
struct strarray distclean_files;
|
2022-01-21 03:48:20 -07:00
|
|
|
struct strarray maintainerclean_files;
|
2018-02-21 04:29:06 -07:00
|
|
|
struct strarray uninstall_files;
|
2019-06-17 10:17:06 -07:00
|
|
|
struct strarray unixobj_files;
|
2020-09-11 01:18:02 -07:00
|
|
|
struct strarray font_files;
|
2020-05-14 07:40:21 -07:00
|
|
|
struct strarray debug_files;
|
2018-02-17 01:53:42 -07:00
|
|
|
struct strarray dlldata_files;
|
|
|
|
struct strarray phony_targets;
|
2018-03-04 16:20:57 -07:00
|
|
|
struct strarray dependencies;
|
2022-10-25 02:04:30 -07:00
|
|
|
struct strarray object_files[MAX_ARCHS];
|
2022-10-25 02:07:45 -07:00
|
|
|
struct strarray implib_files[MAX_ARCHS];
|
2023-03-01 06:25:40 -07:00
|
|
|
struct strarray ok_files[MAX_ARCHS];
|
2022-10-25 02:09:57 -07:00
|
|
|
struct strarray res_files[MAX_ARCHS];
|
2022-10-25 02:08:06 -07:00
|
|
|
struct strarray all_targets[MAX_ARCHS];
|
2018-02-17 01:53:42 -07:00
|
|
|
struct strarray install_rules[NB_INSTALL_RULES];
|
2014-04-09 01:12:44 -07:00
|
|
|
};
|
|
|
|
|
2014-04-10 04:41:23 -07:00
|
|
|
static struct makefile *top_makefile;
|
2022-07-27 23:53:19 -07:00
|
|
|
static struct makefile *include_makefile;
|
2020-09-14 03:48:06 -07:00
|
|
|
static struct makefile **submakes;
|
2014-04-02 05:09:42 -07:00
|
|
|
|
2016-02-25 01:08:12 -07:00
|
|
|
static const char separator[] = "### Dependencies";
|
2015-10-23 01:42:44 -07:00
|
|
|
static const char *output_makefile_name = "Makefile";
|
2013-10-14 02:11:07 -07:00
|
|
|
static const char *input_file_name;
|
2013-12-28 03:47:15 -07:00
|
|
|
static const char *output_file_name;
|
|
|
|
static const char *temp_file_name;
|
2024-06-26 01:37:46 -07:00
|
|
|
static int compile_commands_mode;
|
2020-12-11 08:05:45 -07:00
|
|
|
static int silent_rules;
|
2006-08-01 03:16:29 -07:00
|
|
|
static int input_line;
|
2013-12-28 03:48:03 -07:00
|
|
|
static int output_column;
|
2013-10-14 02:11:07 -07:00
|
|
|
static FILE *output_file;
|
1996-10-23 09:59:13 -07:00
|
|
|
|
2024-06-26 01:37:46 -07:00
|
|
|
struct compile_command
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
const char *cmd;
|
|
|
|
const char *source;
|
|
|
|
const char *obj;
|
|
|
|
struct strarray args;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct list compile_commands = LIST_INIT( compile_commands );
|
|
|
|
|
1996-10-23 09:59:13 -07:00
|
|
|
static const char Usage[] =
|
2024-06-26 01:31:27 -07:00
|
|
|
"Usage: makedep [options]\n"
|
1996-10-23 09:59:13 -07:00
|
|
|
"Options:\n"
|
2024-06-26 01:37:46 -07:00
|
|
|
" -C Generate compile_commands.json along with the makefile\n"
|
2020-12-11 08:05:45 -07:00
|
|
|
" -S Generate Automake-style silent rules\n"
|
2015-11-13 02:56:41 -07:00
|
|
|
" -fxxx Store output in file 'xxx' (default: Makefile)\n";
|
1996-10-23 09:59:13 -07:00
|
|
|
|
|
|
|
|
2013-10-14 02:11:07 -07:00
|
|
|
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 03:48:03 -07:00
|
|
|
static void output( const char *format, ... ) __attribute__ ((__format__ (__printf__, 1, 2)));
|
2013-10-14 15:14:51 -07:00
|
|
|
static char *strmake( const char* fmt, ... ) __attribute__ ((__format__ (__printf__, 1, 2)));
|
2013-10-14 02:11:07 -07:00
|
|
|
|
2004-04-06 21:00:16 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* fatal_error
|
|
|
|
*/
|
|
|
|
static void fatal_error( const char *msg, ... )
|
|
|
|
{
|
|
|
|
va_list valist;
|
|
|
|
va_start( valist, msg );
|
2013-10-14 02:11:07 -07: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-06 21:00:16 -07:00
|
|
|
vfprintf( stderr, msg, valist );
|
|
|
|
va_end( valist );
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-14 02:11:07 -07: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 09:39:30 -07:00
|
|
|
fprintf( stderr, " error: " );
|
2013-10-14 02:11:07 -07:00
|
|
|
}
|
2013-11-04 09:39:30 -07:00
|
|
|
else fprintf( stderr, "makedep: error: " );
|
|
|
|
vfprintf( stderr, msg, valist );
|
2013-10-14 02:11:07 -07:00
|
|
|
perror( " " );
|
|
|
|
va_end( valist );
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-28 03:47:15 -07: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 */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-14 02:11:07 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output
|
|
|
|
*/
|
2013-12-28 03:48:03 -07:00
|
|
|
static void output( const char *format, ... )
|
2013-10-14 02:11:07 -07: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 03:48:03 -07:00
|
|
|
if (format[0] && format[strlen(format) - 1] == '\n') output_column = 0;
|
|
|
|
else output_column += ret;
|
2013-10-14 02:11:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-02 05:10:45 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* strarray_get_value
|
|
|
|
*
|
|
|
|
* Find a value in a name/value pair string array.
|
|
|
|
*/
|
2015-11-09 20:07:37 -07:00
|
|
|
static const char *strarray_get_value( const struct strarray *array, const char *name )
|
2014-04-02 05:10:45 -07:00
|
|
|
{
|
2016-03-28 20:27:17 -07:00
|
|
|
int pos, res, min = 0, max = array->count / 2 - 1;
|
2014-04-02 05:10:45 -07:00
|
|
|
|
2016-03-28 20:27:17 -07: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 05:10:45 -07: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-28 20:27:17 -07:00
|
|
|
int i, pos, res, min = 0, max = array->count / 2 - 1;
|
2014-04-02 05:10:45 -07:00
|
|
|
|
2016-03-28 20:27:17 -07:00
|
|
|
while (min <= max)
|
2014-04-02 05:10:45 -07:00
|
|
|
{
|
2016-03-28 20:27:17 -07: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 05:10:45 -07:00
|
|
|
}
|
2016-03-28 20:27:17 -07: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 05:10:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-14 02:11:07 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_filename
|
|
|
|
*/
|
2013-12-28 03:48:03 -07:00
|
|
|
static void output_filename( const char *name )
|
2013-10-14 02:11:07 -07:00
|
|
|
{
|
2013-12-28 03:48:03 -07:00
|
|
|
if (output_column + strlen(name) + 1 > 100)
|
2013-10-14 02:11:07 -07:00
|
|
|
{
|
2013-12-28 03:48:03 -07:00
|
|
|
output( " \\\n" );
|
|
|
|
output( " " );
|
2013-10-14 02:11:07 -07:00
|
|
|
}
|
2013-12-28 03:48:03 -07:00
|
|
|
else if (output_column) output( " " );
|
|
|
|
output( "%s", name );
|
2013-12-24 03:37:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output_filenames
|
|
|
|
*/
|
2013-12-28 11:52:33 -07:00
|
|
|
static void output_filenames( struct strarray array )
|
2013-12-24 03:37:52 -07:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2013-12-28 11:52:33 -07:00
|
|
|
for (i = 0; i < array.count; i++) output_filename( array.str[i] );
|
2013-10-14 02:11:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-19 13:18:38 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_rm_filenames
|
|
|
|
*/
|
2022-10-31 04:30:07 -07:00
|
|
|
static void output_rm_filenames( struct strarray array, const char *command )
|
2018-02-19 13:18:38 -07:00
|
|
|
{
|
|
|
|
static const unsigned int max_cmdline = 30000; /* to be on the safe side */
|
|
|
|
unsigned int i, len;
|
|
|
|
|
|
|
|
if (!array.count) return;
|
2022-10-31 04:30:07 -07:00
|
|
|
output( "\t%s", command );
|
2018-02-19 13:18:38 -07:00
|
|
|
for (i = len = 0; i < array.count; i++)
|
|
|
|
{
|
|
|
|
if (len > max_cmdline)
|
|
|
|
{
|
|
|
|
output( "\n" );
|
2022-10-31 04:30:07 -07:00
|
|
|
output( "\t%s", command );
|
2018-02-19 13:18:38 -07:00
|
|
|
len = 0;
|
|
|
|
}
|
|
|
|
output_filename( array.str[i] );
|
|
|
|
len += strlen( array.str[i] ) + 1;
|
|
|
|
}
|
|
|
|
output( "\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-10 17:38:56 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* get_extension
|
|
|
|
*/
|
|
|
|
static char *get_extension( char *filename )
|
|
|
|
{
|
|
|
|
char *ext = strrchr( filename, '.' );
|
|
|
|
if (ext && strchr( ext, '/' )) ext = NULL;
|
|
|
|
return ext;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-11 11:59:13 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* get_base_name
|
|
|
|
*/
|
|
|
|
static const char *get_base_name( const char *name )
|
|
|
|
{
|
|
|
|
char *base;
|
|
|
|
if (!strchr( name, '.' )) return name;
|
2021-09-20 06:29:17 -07:00
|
|
|
base = xstrdup( name );
|
2019-11-11 11:59:13 -07:00
|
|
|
*strrchr( base, '.' ) = 0;
|
|
|
|
return base;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-10 19:54:46 -07: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-17 09:10:28 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* replace_substr
|
|
|
|
*/
|
2015-11-09 20:21:21 -07:00
|
|
|
static char *replace_substr( const char *str, const char *start, size_t len, const char *replace )
|
2013-12-17 09:10:28 -07:00
|
|
|
{
|
2015-11-09 20:21:21 -07:00
|
|
|
size_t pos = start - str;
|
2013-12-17 09:10:28 -07: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-06-24 04:39:49 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* get_root_relative_path
|
|
|
|
*
|
|
|
|
* Get relative path from obj dir to root.
|
|
|
|
*/
|
|
|
|
static const char *get_root_relative_path( struct makefile *make )
|
|
|
|
{
|
|
|
|
const char *dir = make->obj_dir;
|
|
|
|
char *ret, *p;
|
|
|
|
unsigned int dotdots = 0;
|
|
|
|
|
|
|
|
if (!dir) return ".";
|
|
|
|
while (*dir)
|
|
|
|
{
|
|
|
|
dotdots++;
|
|
|
|
while (*dir && *dir != '/') dir++;
|
|
|
|
while (*dir == '/') dir++;
|
|
|
|
}
|
|
|
|
ret = xmalloc( 3 * dotdots );
|
|
|
|
for (p = ret; dotdots; dotdots--, p += 3) memcpy( p, "../", 3 );
|
|
|
|
p[-1] = 0; /* remove trailing slash */
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-10 03:10:55 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* concat_paths
|
|
|
|
*/
|
|
|
|
static char *concat_paths( const char *base, const char *path )
|
|
|
|
{
|
2020-09-14 02:26:35 -07:00
|
|
|
int i, len;
|
|
|
|
char *ret;
|
|
|
|
|
2014-04-11 05:24:53 -07:00
|
|
|
if (!base || !base[0]) return xstrdup( path && path[0] ? path : "." );
|
2014-04-09 03:32:54 -07:00
|
|
|
if (!path || !path[0]) return xstrdup( base );
|
2014-03-10 03:10:55 -07:00
|
|
|
if (path[0] == '/') return xstrdup( path );
|
2020-09-14 02:26:35 -07:00
|
|
|
|
|
|
|
len = strlen( base );
|
|
|
|
while (len && base[len - 1] == '/') len--;
|
|
|
|
while (len && !strncmp( path, "..", 2 ) && (!path[2] || path[2] == '/'))
|
|
|
|
{
|
|
|
|
for (i = len; i > 0; i--) if (base[i - 1] == '/') break;
|
|
|
|
if (i == len - 2 && !memcmp( base + i, "..", 2 )) break; /* we can't go up if we already have ".." */
|
|
|
|
if (i != len - 1 || base[i] != '.')
|
|
|
|
{
|
|
|
|
path += 2;
|
|
|
|
while (*path == '/') path++;
|
|
|
|
}
|
|
|
|
/* else ignore "." element */
|
|
|
|
while (i > 0 && base[i - 1] == '/') i--;
|
|
|
|
len = i;
|
|
|
|
}
|
|
|
|
if (!len && base[0] != '/') return xstrdup( path[0] ? path : "." );
|
|
|
|
ret = xmalloc( len + strlen( path ) + 2 );
|
|
|
|
memcpy( ret, base, len );
|
|
|
|
ret[len++] = '/';
|
|
|
|
strcpy( ret + len, path );
|
|
|
|
return ret;
|
2014-03-10 03:10:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-06-26 01:37:46 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* escape_cstring
|
|
|
|
*/
|
|
|
|
static const char *escape_cstring( const char *str )
|
|
|
|
{
|
|
|
|
char *ret;
|
|
|
|
unsigned int i = 0, j = 0;
|
|
|
|
|
|
|
|
if (!strpbrk( str, "\\\"" )) return str;
|
|
|
|
ret = xmalloc( 2 * strlen(str) + 1 );
|
|
|
|
while (str[i])
|
|
|
|
{
|
|
|
|
if (str[i] == '\\' || str[i] == '"') ret[j++] = '\\';
|
|
|
|
ret[j++] = str[i++];
|
|
|
|
}
|
|
|
|
ret[j] = 0;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-26 02:03:51 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* is_native_arch_disabled
|
|
|
|
*
|
|
|
|
* Check if the makefile was disabled for a PE arch that matches the native arch.
|
|
|
|
*/
|
|
|
|
static int is_native_arch_disabled( struct makefile *make )
|
|
|
|
{
|
|
|
|
unsigned int arch;
|
|
|
|
|
2023-06-15 01:46:36 -07:00
|
|
|
if (archs.count == 1) return 0;
|
|
|
|
if (!so_dll_supported) return 1;
|
|
|
|
|
2022-10-26 02:03:51 -07:00
|
|
|
for (arch = 1; arch < archs.count; arch++)
|
|
|
|
if (make->disabled[arch] && !strcmp( archs.str[0], archs.str[arch] ))
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-08 15:00:24 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* get_link_arch
|
|
|
|
*/
|
2024-06-11 01:38:44 -07:00
|
|
|
static int get_link_arch( const struct makefile *make, unsigned int arch, unsigned int *link_arch )
|
2024-04-08 15:00:24 -07:00
|
|
|
{
|
|
|
|
unsigned int hybrid_arch = hybrid_archs[arch];
|
2024-06-11 01:38:44 -07:00
|
|
|
|
2024-04-08 15:00:24 -07:00
|
|
|
if (native_archs[arch]) return 0;
|
|
|
|
if (hybrid_arch && make->disabled[hybrid_arch]) hybrid_arch = 0;
|
|
|
|
if (make->disabled[arch] && !hybrid_arch) return 0;
|
|
|
|
*link_arch = hybrid_arch ? hybrid_arch : arch;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-24 02:46:48 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* is_multiarch
|
|
|
|
*
|
|
|
|
* Check if arch is one of the PE architectures in multiarch.
|
|
|
|
* Also return TRUE for native arch iff there's no PE support.
|
|
|
|
*/
|
|
|
|
static int is_multiarch( unsigned int arch )
|
|
|
|
{
|
|
|
|
return archs.count == 1 || arch;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-22 07:34:48 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* is_using_msvcrt
|
|
|
|
*
|
|
|
|
* Check if the files of a makefile use msvcrt by default.
|
|
|
|
*/
|
|
|
|
static int is_using_msvcrt( struct makefile *make )
|
|
|
|
{
|
|
|
|
return make->module || make->testdll;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-26 02:03:42 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* arch_module_name
|
|
|
|
*/
|
|
|
|
static char *arch_module_name( const char *module, unsigned int arch )
|
|
|
|
{
|
2023-06-15 01:27:06 -07:00
|
|
|
return strmake( "%s%s%s", arch_dirs[arch], module, dll_ext[arch] );
|
2022-10-26 02:03:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-26 02:03:33 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* arch_make_variable
|
|
|
|
*/
|
|
|
|
static char *arch_make_variable( const char *name, unsigned int arch )
|
|
|
|
{
|
2022-11-01 02:28:05 -07:00
|
|
|
return arch ? strmake( "$(%s_%s)", archs.str[arch], name ) : strmake( "$(%s)", name );
|
2022-10-26 02:03:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-10 01:03:03 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* obj_dir_path
|
|
|
|
*/
|
2015-11-09 20:07:37 -07:00
|
|
|
static char *obj_dir_path( const struct makefile *make, const char *path )
|
2014-04-10 01:03:03 -07:00
|
|
|
{
|
|
|
|
return concat_paths( make->obj_dir, path );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-10 04:47:19 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* src_dir_path
|
|
|
|
*/
|
2015-11-09 20:07:37 -07:00
|
|
|
static char *src_dir_path( const struct makefile *make, const char *path )
|
2014-01-10 04:47:19 -07:00
|
|
|
{
|
2014-04-10 01:03:03 -07:00
|
|
|
if (make->src_dir) return concat_paths( make->src_dir, path );
|
2014-04-10 04:41:23 -07:00
|
|
|
return obj_dir_path( make, path );
|
2014-01-10 04:47:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
2020-09-14 03:48:06 -07:00
|
|
|
* root_src_dir_path
|
2014-01-10 04:47:19 -07:00
|
|
|
*/
|
2020-09-14 03:48:06 -07:00
|
|
|
static char *root_src_dir_path( const char *path )
|
2014-04-11 05:24:53 -07:00
|
|
|
{
|
|
|
|
return concat_paths( root_src_dir, path );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-13 06:44:26 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* tools_dir_path
|
|
|
|
*/
|
2015-11-09 20:07:37 -07:00
|
|
|
static char *tools_dir_path( const struct makefile *make, const char *path )
|
2014-01-13 06:44:26 -07:00
|
|
|
{
|
2020-09-14 03:48:06 -07:00
|
|
|
if (tools_dir) return strmake( "%s/tools/%s", tools_dir, path );
|
|
|
|
return strmake( "tools/%s", path );
|
2014-01-13 06:44:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-13 07:04:30 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* tools_path
|
|
|
|
*/
|
2015-11-09 20:07:37 -07:00
|
|
|
static char *tools_path( const struct makefile *make, const char *name )
|
2014-01-13 07:04:30 -07:00
|
|
|
{
|
2014-04-10 04:41:23 -07:00
|
|
|
return strmake( "%s/%s%s", tools_dir_path( make, name ), name, tools_ext );
|
2014-01-13 07:04:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-12 02:40:00 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* strarray_addall_path
|
|
|
|
*/
|
|
|
|
static void strarray_addall_path( struct strarray *array, const char *dir, struct strarray added )
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < added.count; i++) strarray_add( array, concat_paths( dir, added.str[i] ));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-01 03:16:29 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* get_line
|
|
|
|
*/
|
|
|
|
static char *get_line( FILE *file )
|
|
|
|
{
|
|
|
|
static char *buffer;
|
2015-11-09 20:21:21 -07:00
|
|
|
static size_t size;
|
2006-08-01 03:16:29 -07: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 10:06:31 -07:00
|
|
|
if (!fgets( buffer + size - 1, size + 1, file )) break;
|
2006-08-01 03:16:29 -07: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 10:06:31 -07:00
|
|
|
if (!fgets( p, size - (p - buffer), file )) return buffer;
|
2006-08-01 03:16:29 -07:00
|
|
|
input_line++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-11 07:55:51 -07:00
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* hash_filename
|
|
|
|
*/
|
|
|
|
static unsigned int hash_filename( const char *name )
|
|
|
|
{
|
2016-03-01 01:20:33 -07:00
|
|
|
/* FNV-1 hash */
|
2016-03-01 16:53:58 -07:00
|
|
|
unsigned int ret = 2166136261u;
|
2016-03-01 01:20:33 -07:00
|
|
|
while (*name) ret = (ret * 16777619) ^ *name++;
|
2014-04-11 07:55:51 -07: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 )
|
|
|
|
{
|
|
|
|
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 08:19:07 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* find_src_file
|
|
|
|
*/
|
2015-11-09 20:07:37 -07:00
|
|
|
static struct incl_file *find_src_file( const struct makefile *make, const char *name )
|
2006-10-16 08:19:07 -07:00
|
|
|
{
|
2013-10-14 01:51:37 -07:00
|
|
|
struct incl_file *file;
|
2006-10-16 08:19:07 -07:00
|
|
|
|
2022-07-28 06:32:17 -07:00
|
|
|
if (make == include_makefile)
|
|
|
|
{
|
|
|
|
unsigned int hash = hash_filename( name );
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( file, &global_includes[hash], struct incl_file, hash_entry )
|
|
|
|
if (!strcmp( name, file->name )) return file;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-04-10 04:50:37 -07:00
|
|
|
LIST_FOR_EACH_ENTRY( file, &make->sources, struct incl_file, entry )
|
2006-10-16 08:19:07 -07:00
|
|
|
if (!strcmp( name, file->name )) return file;
|
|
|
|
return NULL;
|
|
|
|
}
|
1996-10-23 09:59:13 -07:00
|
|
|
|
2010-03-16 05:27:51 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* find_include_file
|
|
|
|
*/
|
2015-11-09 20:07:37 -07:00
|
|
|
static struct incl_file *find_include_file( const struct makefile *make, const char *name )
|
2010-03-16 05:27:51 -07:00
|
|
|
{
|
2013-10-14 01:51:37 -07:00
|
|
|
struct incl_file *file;
|
2010-03-16 05:27:51 -07:00
|
|
|
|
2014-04-11 08:03:54 -07:00
|
|
|
LIST_FOR_EACH_ENTRY( file, &make->includes, struct incl_file, entry )
|
2022-01-21 01:50:12 -07:00
|
|
|
{
|
|
|
|
const char *filename = file->filename;
|
|
|
|
if (!filename) continue;
|
|
|
|
if (make->obj_dir && strlen(make->obj_dir) < strlen(filename))
|
|
|
|
{
|
|
|
|
filename += strlen(make->obj_dir);
|
|
|
|
while (*filename == '/') filename++;
|
|
|
|
}
|
|
|
|
if (!strcmp( name, filename )) return file;
|
|
|
|
}
|
2010-03-16 05:27:51 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1996-10-23 09:59:13 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* add_include
|
|
|
|
*
|
|
|
|
* Add an include file if it doesn't already exists.
|
|
|
|
*/
|
2014-04-11 08:03:54 -07:00
|
|
|
static struct incl_file *add_include( struct makefile *make, struct incl_file *parent,
|
2015-11-04 22:25:35 -07:00
|
|
|
const char *name, int line, enum incl_type type )
|
1996-10-23 09:59:13 -07:00
|
|
|
{
|
2013-10-14 01:51:37 -07:00
|
|
|
struct incl_file *include;
|
1996-10-23 09:59:13 -07:00
|
|
|
|
2014-01-04 04:25:56 -07: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-06 21:00:16 -07:00
|
|
|
|
2014-04-11 08:03:54 -07:00
|
|
|
LIST_FOR_EACH_ENTRY( include, &make->includes, struct incl_file, entry )
|
2019-06-17 10:17:06 -07:00
|
|
|
if (!parent->use_msvcrt == !include->use_msvcrt && !strcmp( name, include->name ))
|
|
|
|
goto found;
|
2006-08-01 03:13:57 -07:00
|
|
|
|
2013-10-14 01:51:37 -07:00
|
|
|
include = xmalloc( sizeof(*include) );
|
|
|
|
memset( include, 0, sizeof(*include) );
|
2006-08-01 03:13:57 -07:00
|
|
|
include->name = xstrdup(name);
|
2014-01-04 04:25:56 -07:00
|
|
|
include->included_by = parent;
|
2014-04-11 07:55:51 -07:00
|
|
|
include->included_line = line;
|
2015-11-04 22:25:35 -07:00
|
|
|
include->type = type;
|
2019-06-17 10:17:06 -07:00
|
|
|
include->use_msvcrt = parent->use_msvcrt;
|
2014-04-11 08:03:54 -07:00
|
|
|
list_add_tail( &make->includes, &include->entry );
|
2006-08-01 03:13:57 -07:00
|
|
|
found:
|
2014-01-04 04:25:56 -07:00
|
|
|
parent->files[parent->files_count++] = include;
|
2006-08-01 03:13:57 -07:00
|
|
|
return include;
|
1996-10-23 09:59:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-05 04:15:07 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* add_generated_source
|
|
|
|
*
|
|
|
|
* Add a generated source file to the list.
|
|
|
|
*/
|
2022-10-25 02:08:26 -07:00
|
|
|
static struct incl_file *add_generated_source( struct makefile *make, const char *name,
|
|
|
|
const char *filename, unsigned int arch )
|
2014-02-05 04:15:07 -07:00
|
|
|
{
|
2022-07-28 06:30:31 -07:00
|
|
|
struct incl_file *file = xmalloc( sizeof(*file) );
|
2014-02-05 04:15:07 -07:00
|
|
|
|
2022-10-26 02:04:43 -07:00
|
|
|
name = strmake( "%s%s", arch_dirs[arch], name );
|
2014-02-05 04:15:07 -07:00
|
|
|
memset( file, 0, sizeof(*file) );
|
2014-04-11 07:55:51 -07:00
|
|
|
file->file = add_file( name );
|
2022-10-25 02:08:26 -07:00
|
|
|
file->arch = arch;
|
2014-02-05 04:15:07 -07:00
|
|
|
file->name = xstrdup( name );
|
2020-09-11 00:53:23 -07:00
|
|
|
file->basename = xstrdup( filename ? filename : name );
|
|
|
|
file->filename = obj_dir_path( make, file->basename );
|
2014-04-11 07:55:51 -07:00
|
|
|
file->file->flags = FLAG_GENERATED;
|
2022-11-22 07:34:48 -07:00
|
|
|
file->use_msvcrt = is_using_msvcrt( make );
|
2014-04-10 04:50:37 -07:00
|
|
|
list_add_tail( &make->sources, &file->entry );
|
2022-07-28 06:32:17 -07:00
|
|
|
if (make == include_makefile)
|
|
|
|
{
|
|
|
|
unsigned int hash = hash_filename( name );
|
|
|
|
list_add_tail( &global_includes[hash], &file->hash_entry );
|
|
|
|
}
|
2014-02-05 04:15:07 -07:00
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-12-08 06:53:16 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* skip_spaces
|
|
|
|
*/
|
|
|
|
static char *skip_spaces( const char *p )
|
|
|
|
{
|
|
|
|
while (*p == ' ' || *p == '\t') p++;
|
|
|
|
return (char *)p;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-05 04:48:16 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* parse_include_directive
|
|
|
|
*/
|
2014-04-11 07:55:51 -07:00
|
|
|
static void parse_include_directive( struct file *source, char *str )
|
2013-11-05 04:48:16 -07:00
|
|
|
{
|
2022-12-08 06:53:16 -07:00
|
|
|
char quote, *include, *p = skip_spaces( str );
|
2013-11-05 04:48:16 -07:00
|
|
|
|
|
|
|
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 07:55:51 -07:00
|
|
|
add_dependency( source, include, (quote == '>') ? INCL_SYSTEM : INCL_NORMAL );
|
2013-11-05 04:48:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* parse_pragma_directive
|
|
|
|
*/
|
2014-04-11 07:55:51 -07:00
|
|
|
static void parse_pragma_directive( struct file *source, char *str )
|
2013-11-05 04:48:16 -07:00
|
|
|
{
|
|
|
|
char *flag, *p = str;
|
|
|
|
|
2022-12-08 06:53:16 -07:00
|
|
|
if (*p != ' ' && *p != '\t') return;
|
|
|
|
p = strtok( skip_spaces( p ), " \t" );
|
2013-11-05 04:48:16 -07:00
|
|
|
if (strcmp( p, "makedep" )) return;
|
|
|
|
|
|
|
|
while ((flag = strtok( NULL, " \t" )))
|
|
|
|
{
|
|
|
|
if (!strcmp( flag, "depend" ))
|
|
|
|
{
|
2014-04-11 07:55:51 -07:00
|
|
|
while ((p = strtok( NULL, " \t" ))) add_dependency( source, p, INCL_NORMAL );
|
2013-11-05 04:48:16 -07:00
|
|
|
return;
|
|
|
|
}
|
2014-02-05 05:44:51 -07:00
|
|
|
else if (!strcmp( flag, "install" )) source->flags |= FLAG_INSTALL;
|
2023-08-11 01:15:22 -07:00
|
|
|
else if (!strcmp( flag, "testdll" )) source->flags |= FLAG_TESTDLL;
|
2014-02-05 05:44:51 -07:00
|
|
|
|
2013-11-05 04:48:16 -07: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 12:01:53 -07:00
|
|
|
else if (!strcmp( flag, "regtypelib" )) source->flags |= FLAG_IDL_REGTYPELIB;
|
2013-11-05 04:48:16 -07:00
|
|
|
}
|
|
|
|
else if (strendswith( source->name, ".rc" ))
|
|
|
|
{
|
2022-07-27 23:53:19 -07:00
|
|
|
if (!strcmp( flag, "header" )) source->flags |= FLAG_RC_HEADER;
|
|
|
|
else if (!strcmp( flag, "po" )) source->flags |= FLAG_RC_PO;
|
2013-11-05 04:48:16 -07:00
|
|
|
}
|
2014-02-05 04:15:07 -07:00
|
|
|
else if (strendswith( source->name, ".sfd" ))
|
|
|
|
{
|
|
|
|
if (!strcmp( flag, "font" ))
|
|
|
|
{
|
2014-02-18 07:53:14 -07: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 04:15:07 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-06-17 10:17:06 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!strcmp( flag, "implib" )) source->flags |= FLAG_C_IMPLIB;
|
|
|
|
if (!strcmp( flag, "unix" )) source->flags |= FLAG_C_UNIX;
|
2024-04-30 05:52:35 -07:00
|
|
|
if (!strcmp( flag, "arm64ec_x64" )) source->flags |= FLAG_ARM64EC_X64;
|
2019-06-17 10:17:06 -07:00
|
|
|
}
|
2013-11-05 04:48:16 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* parse_cpp_directive
|
|
|
|
*/
|
2014-04-11 07:55:51 -07:00
|
|
|
static void parse_cpp_directive( struct file *source, char *str )
|
2013-11-05 04:48:16 -07:00
|
|
|
{
|
2022-12-08 06:53:16 -07:00
|
|
|
str = skip_spaces( str );
|
2013-11-05 04:48:16 -07:00
|
|
|
if (*str++ != '#') return;
|
2022-12-08 06:53:16 -07:00
|
|
|
str = skip_spaces( str );
|
2013-11-05 04:48:16 -07:00
|
|
|
|
|
|
|
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 09:59:13 -07:00
|
|
|
/*******************************************************************
|
2003-04-10 17:38:56 -07:00
|
|
|
* parse_idl_file
|
1996-10-23 09:59:13 -07:00
|
|
|
*/
|
2014-04-11 07:55:51 -07:00
|
|
|
static void parse_idl_file( struct file *source, FILE *file )
|
1996-10-23 09:59:13 -07:00
|
|
|
{
|
2006-08-01 03:16:29 -07:00
|
|
|
char *buffer, *include;
|
2000-11-05 22:32:59 -07:00
|
|
|
|
2013-10-14 02:11:07 -07:00
|
|
|
input_line = 0;
|
2006-09-10 13:04:42 -07:00
|
|
|
|
2006-08-01 03:16:29 -07:00
|
|
|
while ((buffer = get_line( file )))
|
2000-11-05 22:32:59 -07:00
|
|
|
{
|
2003-06-20 14:31:13 -07:00
|
|
|
char quote;
|
2022-12-08 06:53:16 -07:00
|
|
|
char *p = skip_spaces( buffer );
|
2003-06-20 14:31:13 -07:00
|
|
|
|
2015-11-04 22:25:35 -07:00
|
|
|
if (!strncmp( p, "importlib", 9 ))
|
|
|
|
{
|
2022-12-08 06:53:16 -07:00
|
|
|
p = skip_spaces( p + 9 );
|
2015-11-04 22:25:35 -07:00
|
|
|
if (*p++ != '(') continue;
|
2022-12-08 06:53:16 -07:00
|
|
|
p = skip_spaces( p );
|
2015-11-04 22:25:35 -07:00
|
|
|
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 14:31:13 -07:00
|
|
|
if (!strncmp( p, "import", 6 ))
|
|
|
|
{
|
2022-12-08 06:53:16 -07:00
|
|
|
p = skip_spaces( p + 6 );
|
2006-09-10 13:04:42 -07:00
|
|
|
if (*p != '"') continue;
|
|
|
|
include = ++p;
|
|
|
|
while (*p && (*p != '"')) p++;
|
2013-10-14 02:11:07 -07:00
|
|
|
if (!*p) fatal_error( "malformed import directive\n" );
|
2006-09-10 13:04:42 -07:00
|
|
|
*p = 0;
|
2014-04-11 07:55:51 -07:00
|
|
|
add_dependency( source, include, INCL_IMPORT );
|
2006-09-10 13:04:42 -07:00
|
|
|
continue;
|
2003-06-20 14:31:13 -07:00
|
|
|
}
|
2006-09-10 13:04:42 -07:00
|
|
|
|
2014-04-11 07:55:51 -07:00
|
|
|
/* check for #include inside cpp_quote */
|
|
|
|
if (!strncmp( p, "cpp_quote", 9 ))
|
2003-06-20 14:31:13 -07:00
|
|
|
{
|
2022-12-08 06:53:16 -07:00
|
|
|
p = skip_spaces( p + 9 );
|
2006-09-10 13:04:42 -07:00
|
|
|
if (*p++ != '(') continue;
|
2022-12-08 06:53:16 -07:00
|
|
|
p = skip_spaces( p );
|
2006-09-10 13:04:42 -07:00
|
|
|
if (*p++ != '"') continue;
|
2003-06-20 14:31:13 -07:00
|
|
|
if (*p++ != '#') continue;
|
2022-12-08 06:53:16 -07:00
|
|
|
p = skip_spaces( p );
|
2003-06-20 14:31:13 -07:00
|
|
|
if (strncmp( p, "include", 7 )) continue;
|
2022-12-08 06:53:16 -07:00
|
|
|
p = skip_spaces( p + 7 );
|
2006-09-10 13:04:42 -07: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 02:11:07 -07:00
|
|
|
fatal_error( "malformed #include directive inside cpp_quote\n" );
|
2006-09-10 13:04:42 -07:00
|
|
|
if (quote == '"') p--; /* remove backslash */
|
|
|
|
*p = 0;
|
2014-04-11 07:55:51 -07:00
|
|
|
add_dependency( source, include, (quote == '>') ? INCL_CPP_QUOTE_SYSTEM : INCL_CPP_QUOTE );
|
2006-09-10 13:04:42 -07:00
|
|
|
continue;
|
2003-06-20 14:31:13 -07:00
|
|
|
}
|
|
|
|
|
2014-04-11 07:55:51 -07:00
|
|
|
parse_cpp_directive( source, p );
|
2000-11-05 22:32:59 -07:00
|
|
|
}
|
2003-04-10 17:38:56 -07:00
|
|
|
}
|
2000-11-05 22:32:59 -07:00
|
|
|
|
2003-04-10 17:38:56 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* parse_c_file
|
|
|
|
*/
|
2014-04-11 07:55:51 -07:00
|
|
|
static void parse_c_file( struct file *source, FILE *file )
|
2003-04-10 17:38:56 -07:00
|
|
|
{
|
2013-11-05 04:48:16 -07:00
|
|
|
char *buffer;
|
1996-10-23 09:59:13 -07:00
|
|
|
|
2006-08-01 03:16:29 -07:00
|
|
|
input_line = 0;
|
|
|
|
while ((buffer = get_line( file )))
|
1996-10-23 09:59:13 -07:00
|
|
|
{
|
2014-04-11 07:55:51 -07:00
|
|
|
parse_cpp_directive( source, buffer );
|
1996-10-23 09:59:13 -07:00
|
|
|
}
|
2003-04-10 17:38:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-26 07:02:03 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* parse_rc_file
|
|
|
|
*/
|
2014-04-11 07:55:51 -07:00
|
|
|
static void parse_rc_file( struct file *source, FILE *file )
|
2006-12-26 07:02:03 -07:00
|
|
|
{
|
|
|
|
char *buffer, *include;
|
|
|
|
|
|
|
|
input_line = 0;
|
|
|
|
while ((buffer = get_line( file )))
|
|
|
|
{
|
|
|
|
char quote;
|
2022-12-08 06:53:16 -07:00
|
|
|
char *p = skip_spaces( buffer );
|
2006-12-26 07:02:03 -07:00
|
|
|
|
|
|
|
if (p[0] == '/' && p[1] == '*') /* check for magic makedep comment */
|
|
|
|
{
|
2022-12-08 06:53:16 -07:00
|
|
|
p = skip_spaces( p + 2 );
|
2006-12-26 07:02:03 -07:00
|
|
|
if (strncmp( p, "@makedep:", 9 )) continue;
|
2022-12-08 06:53:16 -07:00
|
|
|
p = skip_spaces( p + 9 );
|
2006-12-26 07:02:03 -07:00
|
|
|
quote = '"';
|
|
|
|
if (*p == quote)
|
|
|
|
{
|
|
|
|
include = ++p;
|
|
|
|
while (*p && *p != quote) p++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
include = p;
|
2022-12-08 06:53:16 -07:00
|
|
|
while (*p && *p != ' ' && *p != '\t' && *p != '*') p++;
|
2006-12-26 07:02:03 -07:00
|
|
|
}
|
|
|
|
if (!*p)
|
2013-10-14 02:11:07 -07:00
|
|
|
fatal_error( "malformed makedep comment\n" );
|
2006-12-26 07:02:03 -07:00
|
|
|
*p = 0;
|
2014-04-11 07:55:51 -07:00
|
|
|
add_dependency( source, include, (quote == '>') ? INCL_SYSTEM : INCL_NORMAL );
|
2013-11-05 04:48:16 -07:00
|
|
|
continue;
|
2006-12-26 07:02:03 -07:00
|
|
|
}
|
2013-11-05 04:48:16 -07:00
|
|
|
|
2014-04-11 07:55:51 -07:00
|
|
|
parse_cpp_directive( source, buffer );
|
2006-12-26 07:02:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-18 03:34:03 -07:00
|
|
|
/*******************************************************************
|
2013-12-12 12:04:53 -07:00
|
|
|
* parse_in_file
|
2013-11-18 03:34:03 -07:00
|
|
|
*/
|
2014-04-11 07:55:51 -07:00
|
|
|
static void parse_in_file( struct file *source, FILE *file )
|
2013-11-18 03:34:03 -07:00
|
|
|
{
|
|
|
|
char *p, *buffer;
|
|
|
|
|
|
|
|
/* make sure it gets rebuilt when the version changes */
|
2014-04-11 07:55:51 -07:00
|
|
|
add_dependency( source, "config.h", INCL_SYSTEM );
|
2013-11-18 03:34:03 -07:00
|
|
|
|
2014-04-11 07:55:51 -07:00
|
|
|
if (!strendswith( source->name, ".man.in" )) return; /* not a man page */
|
2013-12-12 12:04:53 -07:00
|
|
|
|
2013-11-18 03:34:03 -07:00
|
|
|
input_line = 0;
|
|
|
|
while ((buffer = get_line( file )))
|
|
|
|
{
|
|
|
|
if (strncmp( buffer, ".TH", 3 )) continue;
|
2022-12-08 06:53:16 -07:00
|
|
|
p = skip_spaces( buffer + 3 );
|
2022-12-09 02:47:49 -07:00
|
|
|
if (!(p = strtok( p, " \t" ))) continue; /* program name */
|
|
|
|
if (!(p = strtok( NULL, " \t" ))) continue; /* man section */
|
|
|
|
source->args = xstrdup( p );
|
2014-02-05 04:15:07 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* parse_sfd_file
|
|
|
|
*/
|
2014-04-11 07:55:51 -07:00
|
|
|
static void parse_sfd_file( struct file *source, FILE *file )
|
2014-02-05 04:15:07 -07: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;
|
2022-12-08 06:53:16 -07:00
|
|
|
p = skip_spaces( p );
|
2014-02-05 04:15:07 -07:00
|
|
|
if (*p++ == '#')
|
|
|
|
{
|
2022-12-08 06:53:16 -07:00
|
|
|
p = skip_spaces( p );
|
2014-02-05 04:15:07 -07:00
|
|
|
if (!strncmp( p, "pragma", 6 )) parse_pragma_directive( source, p + 6 );
|
|
|
|
}
|
|
|
|
p = eol + 5;
|
|
|
|
}
|
2022-12-08 06:53:16 -07:00
|
|
|
p = skip_spaces( p );
|
2014-02-05 04:15:07 -07:00
|
|
|
if (*p++ != '#') return;
|
2022-12-08 06:53:16 -07:00
|
|
|
p = skip_spaces( p );
|
2014-02-05 04:15:07 -07:00
|
|
|
if (!strncmp( p, "pragma", 6 )) parse_pragma_directive( source, p + 6 );
|
2013-11-18 03:34:03 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-01 23:53:42 -07: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 07:55:51 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* load_file
|
|
|
|
*/
|
|
|
|
static struct file *load_file( const char *name )
|
|
|
|
{
|
|
|
|
struct file *file;
|
|
|
|
FILE *f;
|
2015-11-01 23:53:42 -07:00
|
|
|
unsigned int i, hash = hash_filename( name );
|
2014-04-11 07:55:51 -07: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 01:20:33 -07:00
|
|
|
list_add_tail( &files[hash], &file->entry );
|
2014-04-11 07:55:51 -07:00
|
|
|
input_file_name = file->name;
|
|
|
|
input_line = 0;
|
|
|
|
|
2022-10-16 12:51:57 -07:00
|
|
|
for (i = 0; i < ARRAY_SIZE(parse_functions); i++)
|
2015-11-01 23:53:42 -07:00
|
|
|
{
|
|
|
|
if (!strendswith( name, parse_functions[i].ext )) continue;
|
|
|
|
parse_functions[i].parse( file, f );
|
|
|
|
break;
|
|
|
|
}
|
2014-04-11 07:55:51 -07:00
|
|
|
|
|
|
|
fclose( f );
|
|
|
|
input_file_name = NULL;
|
|
|
|
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
2015-11-10 23:01:43 -07:00
|
|
|
* open_include_path_file
|
|
|
|
*
|
|
|
|
* Open a file from a directory on the include path.
|
2014-04-11 07:55:51 -07:00
|
|
|
*/
|
2015-11-10 23:01:43 -07:00
|
|
|
static struct file *open_include_path_file( const struct makefile *make, const char *dir,
|
|
|
|
const char *name, char **filename )
|
2014-04-11 07:55:51 -07:00
|
|
|
{
|
2020-09-12 02:40:00 -07:00
|
|
|
char *src_path = concat_paths( dir, name );
|
2015-11-10 23:01:43 -07:00
|
|
|
struct file *ret = load_file( src_path );
|
2014-04-11 07:55:51 -07:00
|
|
|
|
2020-09-12 02:40:00 -07:00
|
|
|
if (ret) *filename = src_path;
|
2014-04-11 07:55:51 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-10 19:54:46 -07: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 );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-21 01:49:19 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* open_same_dir_generated_file
|
|
|
|
*
|
|
|
|
* Open a generated_file in the same directory as the parent.
|
|
|
|
*/
|
|
|
|
static struct file *open_same_dir_generated_file( const struct makefile *make,
|
|
|
|
const struct incl_file *parent, struct incl_file *file,
|
|
|
|
const char *ext, const char *src_ext )
|
|
|
|
{
|
|
|
|
char *filename;
|
|
|
|
struct file *ret = NULL;
|
|
|
|
|
|
|
|
if (strendswith( file->name, ext ) &&
|
|
|
|
(ret = open_file_same_dir( parent, replace_extension( file->name, ext, src_ext ), &filename )))
|
|
|
|
{
|
|
|
|
file->sourcename = filename;
|
|
|
|
file->filename = obj_dir_path( make, replace_filename( parent->name, file->name ));
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-11 07:55:51 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* open_local_file
|
|
|
|
*
|
|
|
|
* Open a file in the source directory of the makefile.
|
|
|
|
*/
|
2015-11-09 20:07:37 -07:00
|
|
|
static struct file *open_local_file( const struct makefile *make, const char *path, char **filename )
|
2014-04-11 07:55:51 -07:00
|
|
|
{
|
2020-09-14 03:48:06 -07:00
|
|
|
char *src_path = src_dir_path( make, path );
|
2014-04-11 07:55:51 -07:00
|
|
|
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 );
|
2020-09-14 03:48:06 -07:00
|
|
|
src_path = src_dir_path( make, path );
|
2014-04-11 07:55:51 -07:00
|
|
|
ret = load_file( src_path );
|
|
|
|
}
|
|
|
|
|
2020-09-14 03:48:06 -07:00
|
|
|
if (ret) *filename = src_path;
|
2014-04-11 07:55:51 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-21 01:49:00 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* open_local_generated_file
|
|
|
|
*
|
|
|
|
* Open a generated file in the directory of the makefile.
|
|
|
|
*/
|
|
|
|
static struct file *open_local_generated_file( const struct makefile *make, struct incl_file *file,
|
|
|
|
const char *ext, const char *src_ext )
|
|
|
|
{
|
2022-07-28 06:32:17 -07:00
|
|
|
struct incl_file *include;
|
2022-01-21 01:49:00 -07:00
|
|
|
|
|
|
|
if (strendswith( file->name, ext ) &&
|
2022-07-28 06:32:17 -07:00
|
|
|
(include = find_src_file( make, replace_extension( file->name, ext, src_ext ) )))
|
2022-01-21 01:49:00 -07:00
|
|
|
{
|
2022-07-28 06:32:17 -07:00
|
|
|
file->sourcename = include->filename;
|
2022-01-21 01:49:00 -07:00
|
|
|
file->filename = obj_dir_path( make, file->name );
|
2022-07-28 06:32:17 -07:00
|
|
|
return include->file;
|
2022-01-21 01:49:00 -07:00
|
|
|
}
|
2022-07-28 06:32:17 -07:00
|
|
|
return NULL;
|
2022-01-21 01:49:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-11 07:55:51 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* open_global_file
|
|
|
|
*
|
|
|
|
* Open a file in the top-level source directory.
|
|
|
|
*/
|
2022-07-28 06:32:17 -07:00
|
|
|
static struct file *open_global_file( const char *path, char **filename )
|
2014-04-11 07:55:51 -07:00
|
|
|
{
|
2020-09-14 03:48:06 -07:00
|
|
|
char *src_path = root_src_dir_path( path );
|
2014-04-11 07:55:51 -07:00
|
|
|
struct file *ret = load_file( src_path );
|
|
|
|
|
2020-09-14 03:48:06 -07:00
|
|
|
if (ret) *filename = src_path;
|
2014-04-11 07:55:51 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* open_global_header
|
|
|
|
*
|
|
|
|
* Open a file in the global include source directory.
|
|
|
|
*/
|
2022-07-28 06:32:17 -07:00
|
|
|
static struct file *open_global_header( const char *path, char **filename )
|
2014-04-11 07:55:51 -07:00
|
|
|
{
|
2022-07-28 06:32:17 -07:00
|
|
|
struct incl_file *include = find_src_file( include_makefile, path );
|
|
|
|
|
|
|
|
if (!include) return NULL;
|
|
|
|
*filename = include->filename;
|
|
|
|
return include->file;
|
2014-04-11 07:55:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-21 01:49:00 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* open_global_generated_file
|
|
|
|
*
|
|
|
|
* Open a generated file in the top-level source directory.
|
|
|
|
*/
|
|
|
|
static struct file *open_global_generated_file( const struct makefile *make, struct incl_file *file,
|
|
|
|
const char *ext, const char *src_ext )
|
|
|
|
{
|
2022-07-28 06:32:17 -07:00
|
|
|
struct incl_file *include;
|
2022-01-21 01:49:00 -07:00
|
|
|
|
|
|
|
if (strendswith( file->name, ext ) &&
|
2022-07-28 06:32:17 -07:00
|
|
|
(include = find_src_file( include_makefile, replace_extension( file->name, ext, src_ext ) )))
|
2022-01-21 01:49:00 -07:00
|
|
|
{
|
2022-07-28 06:32:17 -07:00
|
|
|
file->sourcename = include->filename;
|
2022-01-21 01:49:00 -07:00
|
|
|
file->filename = strmake( "include/%s", file->name );
|
2022-07-28 06:32:17 -07:00
|
|
|
return include->file;
|
2022-01-21 01:49:00 -07:00
|
|
|
}
|
2022-07-28 06:32:17 -07:00
|
|
|
return NULL;
|
2022-01-21 01:49:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-11 07:55:51 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* open_src_file
|
|
|
|
*/
|
2015-11-09 20:07:37 -07:00
|
|
|
static struct file *open_src_file( const struct makefile *make, struct incl_file *pFile )
|
2014-04-11 07:55:51 -07:00
|
|
|
{
|
|
|
|
struct file *file = open_local_file( make, pFile->name, &pFile->filename );
|
|
|
|
|
|
|
|
if (!file) fatal_perror( "open %s", pFile->name );
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-12 07:14:12 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* find_importlib_module
|
|
|
|
*/
|
|
|
|
static struct makefile *find_importlib_module( const char *name )
|
|
|
|
{
|
|
|
|
unsigned int i, len;
|
|
|
|
|
|
|
|
for (i = 0; i < subdirs.count; i++)
|
|
|
|
{
|
|
|
|
if (strncmp( submakes[i]->obj_dir, "dlls/", 5 )) continue;
|
|
|
|
len = strlen(submakes[i]->obj_dir);
|
|
|
|
if (strncmp( submakes[i]->obj_dir + 5, name, len - 5 )) continue;
|
|
|
|
if (!name[len - 5] || !strcmp( name + len - 5, ".dll" )) return submakes[i];
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-11 07:55:51 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* open_include_file
|
|
|
|
*/
|
2015-11-09 20:07:37 -07:00
|
|
|
static struct file *open_include_file( const struct makefile *make, struct incl_file *pFile )
|
2014-04-11 07:55:51 -07:00
|
|
|
{
|
|
|
|
struct file *file = NULL;
|
|
|
|
unsigned int i, len;
|
|
|
|
|
|
|
|
errno = ENOENT;
|
|
|
|
|
2022-01-21 01:49:00 -07:00
|
|
|
/* check for generated files */
|
|
|
|
if ((file = open_local_generated_file( make, pFile, ".tab.h", ".y" ))) return file;
|
|
|
|
if ((file = open_local_generated_file( make, pFile, ".h", ".idl" ))) return file;
|
2022-01-21 01:50:45 -07:00
|
|
|
if (fontforge && (file = open_local_generated_file( make, pFile, ".ttf", ".sfd" ))) return file;
|
|
|
|
if (convert && rsvg && icotool)
|
|
|
|
{
|
|
|
|
if ((file = open_local_generated_file( make, pFile, ".bmp", ".svg" ))) return file;
|
|
|
|
if ((file = open_local_generated_file( make, pFile, ".cur", ".svg" ))) return file;
|
|
|
|
if ((file = open_local_generated_file( make, pFile, ".ico", ".svg" ))) return file;
|
|
|
|
}
|
2021-09-02 04:04:43 -07:00
|
|
|
if ((file = open_local_generated_file( make, pFile, "-client-protocol.h", ".xml" ))) return file;
|
2014-04-11 07:55:51 -07:00
|
|
|
|
2018-11-30 05:09:12 -07:00
|
|
|
/* check for extra targets */
|
|
|
|
if (strarray_exists( &make->extra_targets, pFile->name ))
|
|
|
|
{
|
2020-09-11 00:55:46 -07:00
|
|
|
pFile->sourcename = src_dir_path( make, pFile->name );
|
2018-11-30 05:09:12 -07:00
|
|
|
pFile->filename = obj_dir_path( make, pFile->name );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-04-11 07:55:51 -07:00
|
|
|
/* now try in source dir */
|
|
|
|
if ((file = open_local_file( make, pFile->name, &pFile->filename ))) return file;
|
|
|
|
|
2021-11-12 07:14:12 -07:00
|
|
|
/* check for global importlib (module dependency) */
|
|
|
|
if (pFile->type == INCL_IMPORTLIB && find_importlib_module( pFile->name ))
|
|
|
|
{
|
|
|
|
pFile->filename = pFile->name;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-01-21 01:49:00 -07:00
|
|
|
/* check for generated files in global includes */
|
|
|
|
if ((file = open_global_generated_file( make, pFile, ".h", ".idl" ))) return file;
|
|
|
|
if ((file = open_global_generated_file( make, pFile, ".h", ".h.in" ))) return file;
|
2014-04-11 07:55:51 -07:00
|
|
|
if (strendswith( pFile->name, "tmpl.h" ) &&
|
2022-01-21 01:49:00 -07:00
|
|
|
(file = open_global_generated_file( make, pFile, ".h", ".x" ))) return file;
|
2014-04-11 07:55:51 -07:00
|
|
|
|
|
|
|
/* check in global includes source dir */
|
2022-07-28 06:32:17 -07:00
|
|
|
if ((file = open_global_header( pFile->name, &pFile->filename ))) return file;
|
2014-04-11 07:55:51 -07:00
|
|
|
|
|
|
|
/* check in global msvcrt includes */
|
2019-06-17 10:17:06 -07:00
|
|
|
if (pFile->use_msvcrt &&
|
2022-07-28 06:32:17 -07:00
|
|
|
(file = open_global_header( strmake( "msvcrt/%s", pFile->name ), &pFile->filename )))
|
2014-04-11 07:55:51 -07:00
|
|
|
return file;
|
|
|
|
|
|
|
|
/* now search in include paths */
|
2015-11-10 23:02:57 -07:00
|
|
|
for (i = 0; i < make->include_paths.count; i++)
|
2014-04-11 07:55:51 -07:00
|
|
|
{
|
2015-11-10 23:02:57 -07:00
|
|
|
const char *dir = make->include_paths.str[i];
|
2014-04-11 07:55:51 -07:00
|
|
|
|
2020-09-14 03:48:06 -07:00
|
|
|
if (root_src_dir)
|
2014-04-11 07:55:51 -07:00
|
|
|
{
|
2020-09-14 03:48:06 -07:00
|
|
|
len = strlen( root_src_dir );
|
|
|
|
if (!strncmp( dir, root_src_dir, len ) && (!dir[len] || dir[len] == '/'))
|
2014-04-11 07:55:51 -07:00
|
|
|
{
|
|
|
|
while (dir[len] == '/') len++;
|
2022-07-28 06:32:17 -07:00
|
|
|
file = open_global_file( concat_paths( dir + len, pFile->name ), &pFile->filename );
|
2014-04-11 07:55:51 -07:00
|
|
|
}
|
|
|
|
}
|
2021-10-18 02:06:55 -07:00
|
|
|
else
|
2014-04-11 07:55:51 -07:00
|
|
|
{
|
2021-10-18 02:06:55 -07:00
|
|
|
if (*dir == '/') continue;
|
|
|
|
file = open_include_path_file( make, dir, pFile->name, &pFile->filename );
|
2014-04-11 07:55:51 -07:00
|
|
|
}
|
2021-10-18 02:06:55 -07:00
|
|
|
if (!file) continue;
|
|
|
|
pFile->is_external = 1;
|
|
|
|
return file;
|
2014-04-11 07:55:51 -07:00
|
|
|
}
|
2019-04-26 03:51:43 -07:00
|
|
|
|
2015-11-04 22:25:35 -07:00
|
|
|
if (pFile->type == INCL_SYSTEM) return NULL; /* ignore system files we cannot find */
|
2014-04-11 07:55:51 -07:00
|
|
|
|
|
|
|
/* try in src file directory */
|
2022-01-21 01:49:19 -07:00
|
|
|
if ((file = open_same_dir_generated_file( make, pFile->included_by, pFile, ".tab.h", ".y" )) ||
|
|
|
|
(file = open_same_dir_generated_file( make, pFile->included_by, pFile, ".h", ".idl" )) ||
|
|
|
|
(file = open_file_same_dir( pFile->included_by, pFile->name, &pFile->filename )))
|
2021-10-18 02:06:55 -07:00
|
|
|
{
|
|
|
|
pFile->is_external = pFile->included_by->is_external;
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (make->extlib) return NULL; /* ignore missing files in external libs */
|
2014-04-11 07:55:51 -07: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 08:03:54 -07:00
|
|
|
static void add_all_includes( struct makefile *make, struct incl_file *parent, struct file *file )
|
2014-04-11 07:55:51 -07:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < file->deps_count; i++)
|
|
|
|
{
|
|
|
|
switch (file->deps[i].type)
|
|
|
|
{
|
|
|
|
case INCL_NORMAL:
|
|
|
|
case INCL_IMPORT:
|
2015-11-04 22:25:35 -07: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 07:55:51 -07:00
|
|
|
break;
|
|
|
|
case INCL_SYSTEM:
|
2015-11-04 22:25:35 -07:00
|
|
|
add_include( make, parent, file->deps[i].name, file->deps[i].line, INCL_SYSTEM );
|
2014-04-11 07:55:51 -07:00
|
|
|
break;
|
|
|
|
case INCL_CPP_QUOTE:
|
|
|
|
case INCL_CPP_QUOTE_SYSTEM:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-10 17:38:56 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* parse_file
|
|
|
|
*/
|
2014-04-10 04:41:23 -07:00
|
|
|
static void parse_file( struct makefile *make, struct incl_file *source, int src )
|
2003-04-10 17:38:56 -07:00
|
|
|
{
|
2015-11-04 22:25:35 -07:00
|
|
|
struct file *file = src ? open_src_file( make, source ) : open_include_file( make, source );
|
2006-10-16 08:19:07 -07:00
|
|
|
|
2003-04-10 17:38:56 -07:00
|
|
|
if (!file) return;
|
2014-04-11 07:55:51 -07:00
|
|
|
|
|
|
|
source->file = file;
|
|
|
|
source->files_count = 0;
|
|
|
|
source->files_size = file->deps_count;
|
|
|
|
source->files = xmalloc( source->files_size * sizeof(*source->files) );
|
2022-06-02 15:25:16 -07:00
|
|
|
|
|
|
|
if (strendswith( file->name, ".m" )) file->flags |= FLAG_C_UNIX;
|
2019-06-17 10:17:06 -07:00
|
|
|
if (file->flags & FLAG_C_UNIX) source->use_msvcrt = 0;
|
2020-02-12 07:55:31 -07:00
|
|
|
else if (file->flags & FLAG_C_IMPLIB) source->use_msvcrt = 1;
|
2014-04-11 07:55:51 -07:00
|
|
|
|
|
|
|
if (source->sourcename)
|
|
|
|
{
|
|
|
|
if (strendswith( source->sourcename, ".idl" ))
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
/* generated .h file always includes these */
|
2015-11-04 22:25:35 -07:00
|
|
|
add_include( make, source, "rpc.h", 0, INCL_NORMAL );
|
|
|
|
add_include( make, source, "rpcndr.h", 0, INCL_NORMAL );
|
2014-04-11 07:55:51 -07: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 08:03:54 -07:00
|
|
|
add_include( make, source, replace_extension( file->deps[i].name, ".idl", ".h" ),
|
2015-11-04 22:25:35 -07:00
|
|
|
file->deps[i].line, INCL_NORMAL );
|
2014-04-11 07:55:51 -07:00
|
|
|
else
|
2015-11-04 22:25:35 -07:00
|
|
|
add_include( make, source, file->deps[i].name, file->deps[i].line, INCL_NORMAL );
|
2014-04-11 07:55:51 -07:00
|
|
|
break;
|
|
|
|
case INCL_CPP_QUOTE:
|
2015-11-04 22:25:35 -07:00
|
|
|
add_include( make, source, file->deps[i].name, file->deps[i].line, INCL_NORMAL );
|
2014-04-11 07:55:51 -07:00
|
|
|
break;
|
|
|
|
case INCL_CPP_QUOTE_SYSTEM:
|
2015-11-04 22:25:35 -07:00
|
|
|
add_include( make, source, file->deps[i].name, file->deps[i].line, INCL_SYSTEM );
|
2014-04-11 07:55:51 -07:00
|
|
|
break;
|
|
|
|
case INCL_NORMAL:
|
|
|
|
case INCL_SYSTEM:
|
2015-11-04 22:25:35 -07:00
|
|
|
case INCL_IMPORTLIB:
|
2014-04-11 07:55:51 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (strendswith( source->sourcename, ".y" ))
|
|
|
|
return; /* generated .tab.h doesn't include anything */
|
|
|
|
}
|
|
|
|
|
2014-04-11 08:03:54 -07:00
|
|
|
add_all_includes( make, source, file );
|
1996-10-23 09:59:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-10 06:26:25 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* add_src_file
|
|
|
|
*
|
|
|
|
* Add a source file to the list.
|
|
|
|
*/
|
2014-04-10 04:41:23 -07:00
|
|
|
static struct incl_file *add_src_file( struct makefile *make, const char *name )
|
2007-12-10 06:26:25 -07:00
|
|
|
{
|
2022-07-28 06:30:31 -07:00
|
|
|
struct incl_file *file = xmalloc( sizeof(*file) );
|
2007-12-10 06:26:25 -07:00
|
|
|
|
|
|
|
memset( file, 0, sizeof(*file) );
|
|
|
|
file->name = xstrdup(name);
|
2022-11-22 07:34:48 -07:00
|
|
|
file->use_msvcrt = is_using_msvcrt( make );
|
2021-10-18 02:06:55 -07:00
|
|
|
file->is_external = !!make->extlib;
|
2014-04-10 04:50:37 -07:00
|
|
|
list_add_tail( &make->sources, &file->entry );
|
2022-07-28 06:32:17 -07:00
|
|
|
if (make == include_makefile)
|
|
|
|
{
|
|
|
|
unsigned int hash = hash_filename( name );
|
|
|
|
list_add_tail( &global_includes[hash], &file->hash_entry );
|
|
|
|
}
|
2014-04-10 04:41:23 -07:00
|
|
|
parse_file( make, file, 1 );
|
2007-12-10 06:26:25 -07:00
|
|
|
return file;
|
2013-11-04 09:39:30 -07:00
|
|
|
}
|
2013-10-15 04:15:06 -07:00
|
|
|
|
2013-11-04 09:39:30 -07:00
|
|
|
|
2015-10-23 01:42:44 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* open_input_makefile
|
|
|
|
*/
|
2015-11-09 20:07:37 -07:00
|
|
|
static FILE *open_input_makefile( const struct makefile *make )
|
2015-10-23 01:42:44 -07:00
|
|
|
{
|
|
|
|
FILE *ret;
|
|
|
|
|
2020-09-14 03:48:06 -07:00
|
|
|
if (make->obj_dir)
|
2021-11-13 03:47:40 -07:00
|
|
|
input_file_name = root_src_dir_path( obj_dir_path( make, "Makefile.in" ));
|
2015-11-13 02:56:41 -07:00
|
|
|
else
|
|
|
|
input_file_name = output_makefile_name; /* always use output name for main Makefile */
|
2015-10-23 01:42:44 -07:00
|
|
|
|
|
|
|
input_line = 0;
|
2015-11-10 20:05:12 -07:00
|
|
|
if (!(ret = fopen( input_file_name, "r" ))) fatal_perror( "open" );
|
2015-10-23 01:42:44 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-17 09:10:28 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* get_make_variable
|
|
|
|
*/
|
2015-11-09 20:07:37 -07:00
|
|
|
static const char *get_make_variable( const struct makefile *make, const char *name )
|
2013-12-17 09:10:28 -07:00
|
|
|
{
|
2015-11-09 20:07:37 -07:00
|
|
|
const char *ret;
|
2014-04-02 05:10:45 -07:00
|
|
|
|
2014-04-02 05:10:45 -07:00
|
|
|
if ((ret = strarray_get_value( &cmdline_vars, name ))) return ret;
|
2014-04-09 01:12:44 -07:00
|
|
|
if ((ret = strarray_get_value( &make->vars, name ))) return ret;
|
2014-04-10 04:41:23 -07:00
|
|
|
if (top_makefile && (ret = strarray_get_value( &top_makefile->vars, name ))) return ret;
|
2013-12-17 09:10:28 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* get_expanded_make_variable
|
|
|
|
*/
|
2015-11-09 20:07:37 -07:00
|
|
|
static char *get_expanded_make_variable( const struct makefile *make, const char *name )
|
2013-12-17 09:10:28 -07:00
|
|
|
{
|
2015-11-09 20:07:37 -07:00
|
|
|
const char *var;
|
|
|
|
char *p, *end, *expand, *tmp;
|
2013-12-17 09:10:28 -07:00
|
|
|
|
2015-11-09 20:07:37 -07:00
|
|
|
var = get_make_variable( make, name );
|
|
|
|
if (!var) return NULL;
|
2013-12-17 09:10:28 -07:00
|
|
|
|
2015-11-09 20:07:37 -07:00
|
|
|
p = expand = xstrdup( var );
|
2013-12-17 09:10:28 -07: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 04:41:23 -07:00
|
|
|
var = get_make_variable( make, p + 2 );
|
2013-12-17 09:10:28 -07:00
|
|
|
tmp = replace_substr( expand, p, end - p, var ? var : "" );
|
2015-10-25 22:39:06 -07:00
|
|
|
/* switch to the new string */
|
|
|
|
p = tmp + (p - expand);
|
|
|
|
free( expand );
|
|
|
|
expand = tmp;
|
2013-12-17 09:10:28 -07:00
|
|
|
}
|
2014-01-04 12:33:57 -07: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 09:10:28 -07:00
|
|
|
else if (p[1] == '$')
|
|
|
|
{
|
2015-10-25 22:39:06 -07:00
|
|
|
p += 2;
|
2013-12-17 09:10:28 -07:00
|
|
|
}
|
|
|
|
else fatal_error( "syntax error in '%s'\n", expand );
|
|
|
|
}
|
2013-12-26 11:25:57 -07:00
|
|
|
|
|
|
|
/* consider empty variables undefined */
|
2022-12-08 06:53:16 -07:00
|
|
|
p = skip_spaces( expand );
|
2013-12-26 11:25:57 -07:00
|
|
|
if (*p) return expand;
|
|
|
|
free( expand );
|
|
|
|
return NULL;
|
2013-12-17 09:10:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* get_expanded_make_var_array
|
|
|
|
*/
|
2015-11-09 20:07:37 -07:00
|
|
|
static struct strarray get_expanded_make_var_array( const struct makefile *make, const char *name )
|
2013-12-17 09:10:28 -07:00
|
|
|
{
|
2013-12-24 03:37:52 -07:00
|
|
|
struct strarray ret = empty_strarray;
|
2013-12-17 09:10:28 -07:00
|
|
|
char *value, *token;
|
|
|
|
|
2014-04-10 04:41:23 -07:00
|
|
|
if ((value = get_expanded_make_variable( make, name )))
|
2013-12-17 09:10:28 -07:00
|
|
|
for (token = strtok( value, " \t" ); token; token = strtok( NULL, " \t" ))
|
|
|
|
strarray_add( &ret, token );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-26 20:13:26 -07:00
|
|
|
/*******************************************************************
|
2016-02-22 23:03:50 -07:00
|
|
|
* get_expanded_file_local_var
|
2015-10-26 20:13:26 -07:00
|
|
|
*/
|
2016-02-22 23:03:50 -07:00
|
|
|
static struct strarray get_expanded_file_local_var( const struct makefile *make, const char *file,
|
|
|
|
const char *name )
|
2015-10-26 20:13:26 -07:00
|
|
|
{
|
2016-02-22 23:03:50 -07:00
|
|
|
char *p, *var = strmake( "%s_%s", file, name );
|
2015-10-26 20:13:26 -07:00
|
|
|
|
|
|
|
for (p = var; *p; p++) if (!isalnum( *p )) *p = '_';
|
2016-02-22 23:03:50 -07:00
|
|
|
return get_expanded_make_var_array( make, var );
|
2015-10-26 20:13:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-01 02:28:05 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* get_expanded_arch_var
|
|
|
|
*/
|
|
|
|
static char *get_expanded_arch_var( const struct makefile *make, const char *name, int arch )
|
|
|
|
{
|
|
|
|
return get_expanded_make_variable( make, arch ? strmake( "%s_%s", archs.str[arch], name ) : name );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* get_expanded_arch_var_array
|
|
|
|
*/
|
|
|
|
static struct strarray get_expanded_arch_var_array( const struct makefile *make, const char *name, int arch )
|
|
|
|
{
|
|
|
|
return get_expanded_make_var_array( make, arch ? strmake( "%s_%s", archs.str[arch], name ) : name );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-26 11:25:57 -07: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;
|
2022-12-08 06:53:16 -07:00
|
|
|
p = skip_spaces( p );
|
2013-12-26 11:25:57 -07:00
|
|
|
}
|
|
|
|
if (*p != '=') return 0; /* not an assignment */
|
|
|
|
*p++ = 0;
|
2022-12-08 06:53:16 -07:00
|
|
|
p = skip_spaces( p );
|
2013-12-26 11:25:57 -07:00
|
|
|
|
2014-04-02 05:10:45 -07:00
|
|
|
strarray_set_value( array, name, p );
|
2013-12-26 11:25:57 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-17 09:10:28 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* parse_makefile
|
|
|
|
*/
|
2016-02-25 01:08:12 -07:00
|
|
|
static struct makefile *parse_makefile( const char *path )
|
2013-12-17 09:10:28 -07:00
|
|
|
{
|
|
|
|
char *buffer;
|
|
|
|
FILE *file;
|
2014-04-10 04:41:23 -07:00
|
|
|
struct makefile *make = xmalloc( sizeof(*make) );
|
2013-12-17 09:10:28 -07:00
|
|
|
|
2014-04-10 04:41:23 -07:00
|
|
|
memset( make, 0, sizeof(*make) );
|
2020-09-14 03:48:06 -07:00
|
|
|
make->obj_dir = path;
|
|
|
|
if (root_src_dir) make->src_dir = root_src_dir_path( make->obj_dir );
|
2022-07-27 23:53:19 -07:00
|
|
|
if (path && !strcmp( path, "include" )) include_makefile = make;
|
2014-04-10 04:41:23 -07:00
|
|
|
|
2015-10-23 01:42:44 -07:00
|
|
|
file = open_input_makefile( make );
|
2013-12-17 09:10:28 -07:00
|
|
|
while ((buffer = get_line( file )))
|
|
|
|
{
|
2016-02-25 01:08:12 -07:00
|
|
|
if (!strncmp( buffer, separator, strlen(separator) )) break;
|
2013-12-26 11:25:57 -07:00
|
|
|
if (*buffer == '\t') continue; /* command */
|
2022-12-08 06:53:16 -07:00
|
|
|
buffer = skip_spaces( buffer );
|
2013-12-26 11:25:57 -07:00
|
|
|
if (*buffer == '#') continue; /* comment */
|
2014-04-10 04:41:23 -07:00
|
|
|
set_make_variable( &make->vars, buffer );
|
2013-12-17 09:10:28 -07:00
|
|
|
}
|
|
|
|
fclose( file );
|
|
|
|
input_file_name = NULL;
|
2014-04-10 04:41:23 -07:00
|
|
|
return make;
|
2013-12-17 09:10:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-26 11:27:59 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* add_generated_sources
|
|
|
|
*/
|
2014-04-10 04:41:23 -07:00
|
|
|
static void add_generated_sources( struct makefile *make )
|
2013-12-26 11:27:59 -07:00
|
|
|
{
|
2022-10-25 02:08:26 -07:00
|
|
|
unsigned int i, arch;
|
2022-07-28 06:30:31 -07:00
|
|
|
struct incl_file *source, *next, *file, *dlldata = NULL;
|
2018-11-30 04:55:18 -07:00
|
|
|
struct strarray objs = get_expanded_make_var_array( make, "EXTRA_OBJS" );
|
2013-12-26 11:27:59 -07:00
|
|
|
|
2014-04-10 04:50:37 -07:00
|
|
|
LIST_FOR_EACH_ENTRY_SAFE( source, next, &make->sources, struct incl_file, entry )
|
2013-12-26 11:27:59 -07:00
|
|
|
{
|
2022-10-25 02:08:26 -07:00
|
|
|
for (arch = 0; arch < archs.count; arch++)
|
2013-12-26 11:27:59 -07:00
|
|
|
{
|
2022-11-22 07:34:48 -07:00
|
|
|
if (!is_multiarch( arch )) continue;
|
2022-10-25 02:08:26 -07:00
|
|
|
if (source->file->flags & FLAG_IDL_CLIENT)
|
2022-07-28 06:30:31 -07:00
|
|
|
{
|
2022-10-25 02:08:26 -07:00
|
|
|
file = add_generated_source( make, replace_extension( source->name, ".idl", "_c.c" ), NULL, arch );
|
|
|
|
add_dependency( file->file, replace_extension( source->name, ".idl", ".h" ), INCL_NORMAL );
|
|
|
|
add_all_includes( make, file, file->file );
|
|
|
|
}
|
|
|
|
if (source->file->flags & FLAG_IDL_SERVER)
|
|
|
|
{
|
|
|
|
file = add_generated_source( make, replace_extension( source->name, ".idl", "_s.c" ), NULL, arch );
|
|
|
|
add_dependency( file->file, "wine/exception.h", INCL_NORMAL );
|
|
|
|
add_dependency( file->file, replace_extension( source->name, ".idl", ".h" ), INCL_NORMAL );
|
|
|
|
add_all_includes( make, file, file->file );
|
|
|
|
}
|
|
|
|
if (source->file->flags & FLAG_IDL_IDENT)
|
|
|
|
{
|
|
|
|
file = add_generated_source( make, replace_extension( source->name, ".idl", "_i.c" ), NULL, arch );
|
|
|
|
add_dependency( file->file, "rpc.h", INCL_NORMAL );
|
|
|
|
add_dependency( file->file, "rpcndr.h", INCL_NORMAL );
|
|
|
|
add_dependency( file->file, "guiddef.h", INCL_NORMAL );
|
|
|
|
add_all_includes( make, file, file->file );
|
|
|
|
}
|
|
|
|
if (source->file->flags & FLAG_IDL_PROXY)
|
|
|
|
{
|
|
|
|
file = add_generated_source( make, replace_extension( source->name, ".idl", "_p.c" ), NULL, arch );
|
|
|
|
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 );
|
|
|
|
add_all_includes( make, file, file->file );
|
|
|
|
}
|
|
|
|
if (source->file->flags & FLAG_IDL_TYPELIB)
|
|
|
|
{
|
|
|
|
add_generated_source( make, replace_extension( source->name, ".idl", "_l.res" ), NULL, arch );
|
|
|
|
}
|
|
|
|
if (source->file->flags & FLAG_IDL_REGTYPELIB)
|
|
|
|
{
|
|
|
|
add_generated_source( make, replace_extension( source->name, ".idl", "_t.res" ), NULL, arch );
|
|
|
|
}
|
|
|
|
if (source->file->flags & FLAG_IDL_REGISTER)
|
|
|
|
{
|
|
|
|
add_generated_source( make, replace_extension( source->name, ".idl", "_r.res" ), NULL, arch );
|
2022-07-28 06:30:31 -07:00
|
|
|
}
|
2013-12-26 11:27:59 -07:00
|
|
|
}
|
2022-10-25 02:08:26 -07:00
|
|
|
|
|
|
|
/* now the arch-independent files */
|
|
|
|
|
|
|
|
if ((source->file->flags & FLAG_IDL_PROXY) && !dlldata)
|
2013-12-26 11:27:59 -07:00
|
|
|
{
|
2022-10-25 02:08:26 -07:00
|
|
|
dlldata = add_generated_source( make, "dlldata.o", "dlldata.c", 0 );
|
|
|
|
add_dependency( dlldata->file, "objbase.h", INCL_NORMAL );
|
|
|
|
add_dependency( dlldata->file, "rpcproxy.h", INCL_NORMAL );
|
|
|
|
add_all_includes( make, dlldata, dlldata->file );
|
2013-12-26 11:27:59 -07:00
|
|
|
}
|
2015-11-04 22:25:35 -07:00
|
|
|
if (source->file->flags & FLAG_IDL_HEADER)
|
|
|
|
{
|
2022-10-25 02:08:26 -07:00
|
|
|
add_generated_source( make, replace_extension( source->name, ".idl", ".h" ), NULL, 0 );
|
2015-11-04 22:25:35 -07:00
|
|
|
}
|
2015-11-03 22:57:37 -07:00
|
|
|
if (!source->file->flags && strendswith( source->name, ".idl" ))
|
|
|
|
{
|
2022-07-27 23:53:19 -07:00
|
|
|
if (!strncmp( source->name, "wine/", 5 )) continue;
|
|
|
|
source->file->flags = FLAG_IDL_HEADER | FLAG_INSTALL;
|
2022-10-25 02:08:26 -07:00
|
|
|
add_generated_source( make, replace_extension( source->name, ".idl", ".h" ), NULL, 0 );
|
2015-11-03 22:57:37 -07:00
|
|
|
}
|
2015-11-02 00:03:16 -07:00
|
|
|
if (strendswith( source->name, ".x" ))
|
|
|
|
{
|
2022-10-25 02:08:26 -07:00
|
|
|
add_generated_source( make, replace_extension( source->name, ".x", ".h" ), NULL, 0 );
|
2015-11-02 00:03:16 -07:00
|
|
|
}
|
2013-12-26 11:27:59 -07:00
|
|
|
if (strendswith( source->name, ".y" ))
|
|
|
|
{
|
2022-10-25 02:08:26 -07:00
|
|
|
file = add_generated_source( make, replace_extension( source->name, ".y", ".tab.c" ), NULL, 0 );
|
2014-01-04 04:25:56 -07: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 11:27:59 -07:00
|
|
|
}
|
|
|
|
if (strendswith( source->name, ".l" ))
|
|
|
|
{
|
2022-10-25 02:08:26 -07:00
|
|
|
file = add_generated_source( make, replace_extension( source->name, ".l", ".yy.c" ), NULL, 0 );
|
2014-01-04 04:25:56 -07: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 11:27:59 -07:00
|
|
|
}
|
2016-02-29 22:21:01 -07:00
|
|
|
if (strendswith( source->name, ".po" ))
|
|
|
|
{
|
2022-10-26 02:03:51 -07:00
|
|
|
if (!make->disabled[0])
|
2016-02-29 22:21:01 -07:00
|
|
|
strarray_add_uniq( &linguas, replace_extension( source->name, ".po", "" ));
|
|
|
|
}
|
2020-06-12 10:40:25 -07:00
|
|
|
if (strendswith( source->name, ".spec" ))
|
|
|
|
{
|
|
|
|
char *obj = replace_extension( source->name, ".spec", "" );
|
|
|
|
strarray_addall_uniq( &make->extra_imports,
|
|
|
|
get_expanded_file_local_var( make, obj, "IMPORTS" ));
|
|
|
|
}
|
2021-09-02 04:04:43 -07:00
|
|
|
if (strendswith( source->name, ".xml" ))
|
|
|
|
{
|
|
|
|
char *code_name = replace_extension( source->name , ".xml", "-protocol.c" );
|
|
|
|
char *header_name = replace_extension( source->name , ".xml", "-client-protocol.h" );
|
|
|
|
|
|
|
|
file = add_generated_source( make, code_name, NULL, 0 );
|
|
|
|
file->file->flags |= FLAG_C_UNIX;
|
|
|
|
file->use_msvcrt = 0;
|
|
|
|
file = add_generated_source( make, header_name, NULL, 0 );
|
|
|
|
file->file->flags |= FLAG_C_UNIX;
|
|
|
|
file->use_msvcrt = 0;
|
|
|
|
|
|
|
|
free( code_name );
|
|
|
|
free( header_name );
|
|
|
|
}
|
2013-12-26 11:27:59 -07:00
|
|
|
}
|
2015-11-09 20:07:37 -07:00
|
|
|
if (make->testdll)
|
2013-12-26 11:27:59 -07:00
|
|
|
{
|
2022-10-25 02:08:26 -07:00
|
|
|
for (arch = 0; arch < archs.count; arch++)
|
|
|
|
{
|
2022-11-22 07:34:48 -07:00
|
|
|
if (!is_multiarch( arch )) continue;
|
2022-10-25 02:08:26 -07:00
|
|
|
file = add_generated_source( make, "testlist.o", "testlist.c", arch );
|
|
|
|
add_dependency( file->file, "wine/test.h", INCL_NORMAL );
|
|
|
|
add_all_includes( make, file, file->file );
|
|
|
|
}
|
2013-12-26 11:27:59 -07:00
|
|
|
}
|
2018-11-30 04:55:18 -07:00
|
|
|
for (i = 0; i < objs.count; i++)
|
|
|
|
{
|
|
|
|
/* default to .c for unknown extra object files */
|
|
|
|
if (strendswith( objs.str[i], ".o" ))
|
2020-05-17 02:09:30 -07:00
|
|
|
{
|
2022-10-25 02:08:26 -07:00
|
|
|
file = add_generated_source( make, objs.str[i], replace_extension( objs.str[i], ".o", ".c" ), 0);
|
2021-09-22 01:34:07 -07:00
|
|
|
file->file->flags |= FLAG_C_UNIX;
|
|
|
|
file->use_msvcrt = 0;
|
2020-05-17 02:09:30 -07:00
|
|
|
}
|
2018-11-30 04:55:18 -07:00
|
|
|
else if (strendswith( objs.str[i], ".res" ))
|
2022-10-25 02:08:26 -07:00
|
|
|
add_generated_source( make, replace_extension( objs.str[i], ".res", ".rc" ), NULL, 0 );
|
2018-11-30 04:55:18 -07:00
|
|
|
else
|
2022-10-25 02:08:26 -07:00
|
|
|
add_generated_source( make, objs.str[i], NULL, 0 );
|
2018-11-30 04:55:18 -07:00
|
|
|
}
|
2013-12-26 11:27:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-14 13:20:25 -07: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 02:00:36 -07: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;
|
2020-09-14 03:48:06 -07:00
|
|
|
dir = obj_dir_path( make, files.str[i] );
|
2016-02-25 02:00:36 -07:00
|
|
|
*strrchr( dir, '/' ) = 0;
|
|
|
|
strarray_add_uniq( &subdirs, dir );
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < subdirs.count; i++) create_dir( subdirs.str[i] );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-10 01:03:03 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_filenames_obj_dir
|
|
|
|
*/
|
2015-11-09 20:07:37 -07:00
|
|
|
static void output_filenames_obj_dir( const struct makefile *make, struct strarray array )
|
2014-04-10 01:03:03 -07:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2014-04-10 04:41:23 -07:00
|
|
|
for (i = 0; i < array.count; i++) output_filename( obj_dir_path( make, array.str[i] ));
|
2014-04-10 01:03:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-10-23 09:59:13 -07:00
|
|
|
/*******************************************************************
|
2015-11-04 22:25:35 -07:00
|
|
|
* get_dependencies
|
1996-10-23 09:59:13 -07:00
|
|
|
*/
|
2018-02-17 01:53:42 -07:00
|
|
|
static void get_dependencies( struct incl_file *file, struct incl_file *source )
|
1996-10-23 09:59:13 -07:00
|
|
|
{
|
2015-11-04 22:25:35 -07:00
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (!file->filename) return;
|
1996-10-23 09:59:13 -07:00
|
|
|
|
2015-11-04 22:25:35 -07:00
|
|
|
if (file != source)
|
|
|
|
{
|
|
|
|
if (file->owner == source) return; /* already processed */
|
2021-11-12 07:14:12 -07:00
|
|
|
if (file->type == INCL_IMPORTLIB)
|
|
|
|
{
|
|
|
|
if (!(source->file->flags & (FLAG_IDL_TYPELIB | FLAG_IDL_REGTYPELIB)))
|
|
|
|
return; /* library is imported only when building a typelib */
|
|
|
|
strarray_add( &source->importlibdeps, file->filename );
|
|
|
|
}
|
|
|
|
else strarray_add( &source->dependencies, file->filename );
|
2015-11-04 22:25:35 -07:00
|
|
|
file->owner = source;
|
2021-09-23 05:44:50 -07:00
|
|
|
|
|
|
|
/* sanity checks */
|
2021-10-18 02:06:55 -07:00
|
|
|
if (!strcmp( file->filename, "include/config.h" ) &&
|
|
|
|
file != source->files[0] && !source->is_external)
|
2021-09-23 05:44:50 -07:00
|
|
|
{
|
|
|
|
input_file_name = source->filename;
|
|
|
|
input_line = 0;
|
|
|
|
for (i = 0; i < source->file->deps_count; i++)
|
|
|
|
{
|
|
|
|
if (!strcmp( source->file->deps[i].name, file->name ))
|
|
|
|
input_line = source->file->deps[i].line;
|
|
|
|
}
|
|
|
|
fatal_error( "%s must be included before other headers\n", file->name );
|
|
|
|
}
|
2015-11-04 22:25:35 -07:00
|
|
|
}
|
2021-09-23 05:44:50 -07:00
|
|
|
|
2018-02-17 01:53:42 -07:00
|
|
|
for (i = 0; i < file->files_count; i++) get_dependencies( file->files[i], source );
|
1996-10-23 09:59:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-12 22:17:18 -07: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-22 23:03:50 -07:00
|
|
|
struct strarray deps = get_expanded_file_local_var( make, name, "DEPS" );
|
2015-11-12 22:17:18 -07: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-22 22:57:11 -07:00
|
|
|
/*******************************************************************
|
2016-03-24 23:19:53 -07:00
|
|
|
* get_static_lib
|
2016-02-22 22:57:11 -07:00
|
|
|
*
|
2022-11-23 09:47:39 -07:00
|
|
|
* Find the makefile that builds the named static library (which may be an import lib).
|
2016-02-22 22:57:11 -07:00
|
|
|
*/
|
2022-11-23 09:47:39 -07:00
|
|
|
static struct makefile *get_static_lib( const char *name, unsigned int arch )
|
2016-02-22 22:57:11 -07:00
|
|
|
{
|
2022-11-23 09:47:39 -07:00
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < subdirs.count; i++)
|
|
|
|
{
|
|
|
|
if (submakes[i]->importlib && !strcmp( submakes[i]->importlib, name )) return submakes[i];
|
|
|
|
if (!submakes[i]->staticlib) continue;
|
|
|
|
if (submakes[i]->disabled[arch]) continue;
|
|
|
|
if (strncmp( submakes[i]->staticlib, "lib", 3 )) continue;
|
|
|
|
if (strncmp( submakes[i]->staticlib + 3, name, strlen(name) )) continue;
|
|
|
|
if (strcmp( submakes[i]->staticlib + 3 + strlen(name), ".a" )) continue;
|
|
|
|
return submakes[i];
|
|
|
|
}
|
|
|
|
return NULL;
|
2016-02-22 22:57:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-20 06:30:27 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* get_native_unix_lib
|
|
|
|
*/
|
|
|
|
static const char *get_native_unix_lib( const struct makefile *make, const char *name )
|
|
|
|
{
|
2022-11-11 04:05:04 -07:00
|
|
|
if (!make->unixlib) return NULL;
|
2021-09-20 06:30:27 -07:00
|
|
|
if (strncmp( make->unixlib, name, strlen(name) )) return NULL;
|
|
|
|
if (make->unixlib[strlen(name)] != '.') return NULL;
|
|
|
|
return obj_dir_path( make, make->unixlib );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-22 02:51:04 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* get_parent_makefile
|
|
|
|
*/
|
|
|
|
static struct makefile *get_parent_makefile( struct makefile *make )
|
|
|
|
{
|
|
|
|
char *dir, *p;
|
2022-02-01 06:58:23 -07:00
|
|
|
unsigned int i;
|
2019-04-22 02:51:04 -07:00
|
|
|
|
2020-09-14 03:48:06 -07:00
|
|
|
if (!make->obj_dir) return NULL;
|
|
|
|
dir = xstrdup( make->obj_dir );
|
2019-04-22 02:51:04 -07:00
|
|
|
if (!(p = strrchr( dir, '/' ))) return NULL;
|
|
|
|
*p = 0;
|
2020-09-14 03:48:06 -07:00
|
|
|
for (i = 0; i < subdirs.count; i++)
|
|
|
|
if (!strcmp( submakes[i]->obj_dir, dir )) return submakes[i];
|
2019-04-22 02:51:04 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-02 06:56:15 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* needs_delay_lib
|
|
|
|
*/
|
2022-10-24 03:12:51 -07:00
|
|
|
static int needs_delay_lib( const struct makefile *make, unsigned int arch )
|
2019-05-02 06:56:15 -07:00
|
|
|
{
|
2022-10-24 03:12:51 -07:00
|
|
|
if (delay_load_flags[arch]) return 0;
|
2019-05-02 06:56:15 -07:00
|
|
|
if (!make->importlib) return 0;
|
2019-05-03 01:52:51 -07:00
|
|
|
return strarray_exists( &delay_import_libs, make->importlib );
|
2019-05-02 06:56:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-22 22:57:11 -07:00
|
|
|
/*******************************************************************
|
2020-09-18 06:02:00 -07:00
|
|
|
* add_unix_libraries
|
2016-02-22 22:57:11 -07:00
|
|
|
*/
|
2021-09-21 05:42:02 -07:00
|
|
|
static struct strarray add_unix_libraries( const struct makefile *make, struct strarray *deps )
|
2016-02-22 22:57:11 -07:00
|
|
|
{
|
|
|
|
struct strarray ret = empty_strarray;
|
|
|
|
struct strarray all_libs = empty_strarray;
|
|
|
|
unsigned int i, j;
|
|
|
|
|
2021-11-23 06:40:04 -07:00
|
|
|
if (strcmp( make->unixlib, "ntdll.so" )) strarray_add( &all_libs, "-lntdll" );
|
2022-06-29 02:06:16 -07:00
|
|
|
strarray_addall( &all_libs, get_expanded_make_var_array( make, "UNIX_LIBS" ));
|
2016-02-22 22:57:11 -07:00
|
|
|
|
|
|
|
for (i = 0; i < all_libs.count; i++)
|
|
|
|
{
|
2016-03-24 23:19:53 -07:00
|
|
|
const char *lib = NULL;
|
|
|
|
|
2016-02-22 22:57:11 -07:00
|
|
|
if (!strncmp( all_libs.str[i], "-l", 2 ))
|
|
|
|
{
|
2020-09-14 03:48:06 -07:00
|
|
|
for (j = 0; j < subdirs.count; j++)
|
2021-10-25 02:04:11 -07:00
|
|
|
{
|
|
|
|
if (make == submakes[j]) continue;
|
2021-11-23 06:40:04 -07:00
|
|
|
if ((lib = get_native_unix_lib( submakes[j], all_libs.str[i] + 2 ))) break;
|
2021-10-25 02:04:11 -07:00
|
|
|
}
|
2016-02-22 22:57:11 -07:00
|
|
|
}
|
2016-03-24 23:19:53 -07:00
|
|
|
if (lib)
|
|
|
|
{
|
|
|
|
strarray_add( deps, lib );
|
|
|
|
strarray_add( &ret, lib );
|
|
|
|
}
|
|
|
|
else strarray_add( &ret, all_libs.str[i] );
|
2016-02-22 22:57:11 -07:00
|
|
|
}
|
2021-11-23 06:40:04 -07:00
|
|
|
|
|
|
|
strarray_addall( &ret, libs );
|
2016-02-22 22:57:11 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-11 03:38:31 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* is_crt_module
|
|
|
|
*/
|
|
|
|
static int is_crt_module( const char *file )
|
|
|
|
{
|
|
|
|
return !strncmp( file, "msvcr", 5 ) || !strncmp( file, "ucrt", 4 ) || !strcmp( file, "crtdll.dll" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* get_default_crt
|
|
|
|
*/
|
|
|
|
static const char *get_default_crt( const struct makefile *make )
|
|
|
|
{
|
|
|
|
if (make->module && is_crt_module( make->module )) return NULL; /* don't add crt import to crt dlls */
|
|
|
|
return !make->testdll && (!make->staticlib || make->extlib) ? "ucrtbase" : "msvcrt";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* get_crt_define
|
|
|
|
*/
|
|
|
|
static const char *get_crt_define( const struct makefile *make )
|
|
|
|
{
|
|
|
|
const char *crt_dll = NULL;
|
|
|
|
unsigned int i, version = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < make->imports.count; i++)
|
|
|
|
{
|
|
|
|
if (!is_crt_module( make->imports.str[i] )) continue;
|
|
|
|
if (crt_dll) fatal_error( "More than one C runtime DLL imported: %s and %s\n",
|
|
|
|
crt_dll, make->imports.str[i] );
|
|
|
|
crt_dll = make->imports.str[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!crt_dll)
|
|
|
|
{
|
|
|
|
if (strarray_exists( &make->extradllflags, "-nodefaultlibs" )) return "-D_MSVCR_VER=0";
|
|
|
|
if (!(crt_dll = get_default_crt( make ))) crt_dll = make->module;
|
|
|
|
}
|
|
|
|
if (!strncmp( crt_dll, "ucrt", 4 )) return "-D_UCRT";
|
|
|
|
sscanf( crt_dll, "msvcr%u", &version );
|
|
|
|
return strmake( "-D_MSVCR_VER=%u", version );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
2022-09-29 11:04:44 -07:00
|
|
|
* get_default_imports
|
2021-11-11 03:38:31 -07:00
|
|
|
*/
|
2022-09-29 11:04:44 -07:00
|
|
|
static struct strarray get_default_imports( const struct makefile *make, struct strarray imports )
|
2021-11-11 03:38:31 -07:00
|
|
|
{
|
|
|
|
struct strarray ret = empty_strarray;
|
|
|
|
const char *crt_dll = get_default_crt( make );
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < imports.count; i++)
|
2022-09-29 11:04:44 -07:00
|
|
|
if (is_crt_module( imports.str[i] ))
|
|
|
|
crt_dll = imports.str[i];
|
2021-11-11 03:38:31 -07:00
|
|
|
|
|
|
|
strarray_add( &ret, "winecrt0" );
|
|
|
|
if (crt_dll) strarray_add( &ret, crt_dll );
|
|
|
|
|
|
|
|
if (make->is_win16 && (!make->importlib || strcmp( make->importlib, "kernel" )))
|
|
|
|
strarray_add( &ret, "kernel" );
|
|
|
|
|
|
|
|
strarray_add( &ret, "kernel32" );
|
|
|
|
strarray_add( &ret, "ntdll" );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-09-29 10:53:45 -07:00
|
|
|
enum import_type
|
|
|
|
{
|
|
|
|
IMPORT_TYPE_DIRECT,
|
|
|
|
IMPORT_TYPE_DELAYED,
|
2022-09-29 11:04:44 -07:00
|
|
|
IMPORT_TYPE_DEFAULT,
|
2022-09-29 10:53:45 -07:00
|
|
|
};
|
2021-11-11 03:38:31 -07:00
|
|
|
|
2016-02-16 00:53:59 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* add_import_libs
|
|
|
|
*/
|
|
|
|
static struct strarray add_import_libs( const struct makefile *make, struct strarray *deps,
|
2022-10-24 02:40:56 -07:00
|
|
|
struct strarray imports, enum import_type type, unsigned int arch )
|
2016-02-16 00:53:59 -07:00
|
|
|
{
|
|
|
|
struct strarray ret = empty_strarray;
|
2024-06-11 01:38:44 -07:00
|
|
|
unsigned int i, link_arch;
|
2021-11-11 03:38:31 -07:00
|
|
|
|
2024-06-11 01:38:44 -07:00
|
|
|
if (!get_link_arch( make, arch, &link_arch )) return ret;
|
2024-04-08 15:00:24 -07:00
|
|
|
|
2016-02-16 00:53:59 -07:00
|
|
|
for (i = 0; i < imports.count; i++)
|
|
|
|
{
|
2021-10-25 02:05:07 -07:00
|
|
|
const char *name = imports.str[i];
|
2022-11-23 09:47:39 -07:00
|
|
|
struct makefile *submake;
|
2016-02-16 00:53:59 -07:00
|
|
|
|
2022-09-29 11:04:44 -07:00
|
|
|
/* add crt import lib only when adding the default imports libs */
|
|
|
|
if (is_crt_module( imports.str[i] ) && type != IMPORT_TYPE_DEFAULT) continue;
|
|
|
|
|
2021-10-25 02:05:07 -07:00
|
|
|
if (name[0] == '-')
|
|
|
|
{
|
|
|
|
switch (name[1])
|
|
|
|
{
|
|
|
|
case 'L': strarray_add( &ret, name ); continue;
|
|
|
|
case 'l': name += 2; break;
|
|
|
|
default: continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else name = get_base_name( name );
|
|
|
|
|
2024-06-11 01:38:44 -07:00
|
|
|
if ((submake = get_static_lib( name, link_arch )))
|
2016-02-16 00:53:59 -07:00
|
|
|
{
|
2022-11-23 09:47:39 -07:00
|
|
|
const char *ext = (type == IMPORT_TYPE_DELAYED && !delay_load_flags[arch]) ? ".delay.a" : ".a";
|
|
|
|
const char *lib = obj_dir_path( submake, strmake( "%slib%s%s", arch_dirs[arch], name, ext ));
|
2021-11-11 03:38:31 -07:00
|
|
|
strarray_add_uniq( deps, lib );
|
2016-03-24 23:19:53 -07:00
|
|
|
strarray_add( &ret, lib );
|
2016-02-16 00:53:59 -07:00
|
|
|
}
|
2016-03-24 23:19:53 -07:00
|
|
|
else strarray_add( &ret, strmake( "-l%s", name ));
|
2016-02-16 00:53:59 -07:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-28 22:32:45 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* add_install_rule
|
|
|
|
*/
|
2022-10-26 02:03:51 -07:00
|
|
|
static void add_install_rule( struct makefile *make, const char *target, unsigned int arch,
|
2018-02-17 01:53:42 -07:00
|
|
|
const char *file, const char *dest )
|
2015-10-28 22:32:45 -07:00
|
|
|
{
|
2022-09-07 01:12:00 -07:00
|
|
|
unsigned int i;
|
|
|
|
|
2022-10-26 02:03:51 -07:00
|
|
|
if (make->disabled[arch]) return;
|
|
|
|
|
2022-09-07 01:12:00 -07:00
|
|
|
for (i = 0; i < NB_INSTALL_RULES; i++)
|
2015-10-28 22:32:45 -07:00
|
|
|
{
|
2022-09-07 01:12:00 -07:00
|
|
|
if (strarray_exists( &make->install[i], target ) ||
|
|
|
|
strarray_exists( &top_install[i], make->obj_dir ) ||
|
|
|
|
strarray_exists( &top_install[i], obj_dir_path( make, target )))
|
|
|
|
{
|
|
|
|
strarray_add( &make->install_rules[i], file );
|
|
|
|
strarray_add( &make->install_rules[i], dest );
|
|
|
|
break;
|
|
|
|
}
|
2015-10-28 22:32:45 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-01 23:53:42 -07: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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-17 10:17:06 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* get_source_defines
|
|
|
|
*/
|
|
|
|
static struct strarray get_source_defines( struct makefile *make, struct incl_file *source,
|
|
|
|
const char *obj )
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
struct strarray ret = empty_strarray;
|
|
|
|
|
|
|
|
strarray_addall( &ret, make->include_args );
|
|
|
|
if (source->use_msvcrt)
|
2022-06-29 02:06:16 -07:00
|
|
|
{
|
2020-09-14 03:48:06 -07:00
|
|
|
strarray_add( &ret, strmake( "-I%s", root_src_dir_path( "include/msvcrt" )));
|
2022-06-29 02:06:16 -07:00
|
|
|
for (i = 0; i < make->include_paths.count; i++)
|
|
|
|
strarray_add( &ret, strmake( "-I%s", make->include_paths.str[i] ));
|
2022-11-22 07:34:48 -07:00
|
|
|
strarray_add( &ret, get_crt_define( make ));
|
2022-06-29 02:06:16 -07:00
|
|
|
}
|
2019-06-17 10:17:06 -07:00
|
|
|
strarray_addall( &ret, make->define_args );
|
|
|
|
strarray_addall( &ret, get_expanded_file_local_var( make, obj, "EXTRADEFS" ));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-18 02:07:02 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* remove_warning_flags
|
|
|
|
*/
|
|
|
|
static struct strarray remove_warning_flags( struct strarray flags )
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
struct strarray ret = empty_strarray;
|
|
|
|
|
|
|
|
for (i = 0; i < flags.count; i++)
|
|
|
|
if (strncmp( flags.str[i], "-W", 2 ) || !strncmp( flags.str[i], "-Wno-", 5 ))
|
|
|
|
strarray_add( &ret, flags.str[i] );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-14 07:40:21 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* get_debug_file
|
|
|
|
*/
|
2022-10-24 02:40:56 -07:00
|
|
|
static const char *get_debug_file( struct makefile *make, const char *name, unsigned int arch )
|
2020-05-14 07:40:21 -07:00
|
|
|
{
|
|
|
|
const char *debug_file = NULL;
|
2022-10-24 02:46:48 -07:00
|
|
|
if (!debug_flags[arch]) return NULL;
|
|
|
|
if (!strcmp( debug_flags[arch], "pdb" )) debug_file = strmake( "%s.pdb", get_base_name( name ));
|
|
|
|
else if (!strncmp( debug_flags[arch], "split", 5 )) debug_file = strmake( "%s.debug", name );
|
2020-05-14 07:40:21 -07:00
|
|
|
if (debug_file) strarray_add( &make->debug_files, debug_file );
|
|
|
|
return debug_file;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-11 08:05:45 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* cmd_prefix
|
|
|
|
*/
|
|
|
|
static const char *cmd_prefix( const char *cmd )
|
|
|
|
{
|
|
|
|
if (!silent_rules) return "";
|
|
|
|
return strmake( "$(quiet_%s)", cmd );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-09 00:34:05 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_winegcc_command
|
|
|
|
*/
|
2022-10-24 02:40:56 -07:00
|
|
|
static void output_winegcc_command( struct makefile *make, unsigned int arch )
|
2019-04-09 00:34:05 -07:00
|
|
|
{
|
2020-12-11 08:05:45 -07:00
|
|
|
output( "\t%s%s -o $@", cmd_prefix( "CCLD" ), tools_path( make, "winegcc" ));
|
2020-09-14 03:48:06 -07:00
|
|
|
output_filename( "--wine-objdir ." );
|
2019-09-23 04:43:18 -07:00
|
|
|
if (tools_dir)
|
|
|
|
{
|
|
|
|
output_filename( "--winebuild" );
|
|
|
|
output_filename( tools_path( make, "winebuild" ));
|
|
|
|
}
|
2022-10-24 02:42:31 -07:00
|
|
|
output_filenames( target_flags[arch] );
|
2024-04-08 15:00:24 -07:00
|
|
|
if (native_archs[arch] && !make->disabled[native_archs[arch]])
|
|
|
|
output_filenames( hybrid_target_flags[arch] );
|
2022-11-22 07:34:48 -07:00
|
|
|
if (arch) return;
|
|
|
|
output_filename( "-mno-cygwin" );
|
|
|
|
output_filenames( lddll_flags );
|
2019-04-09 00:34:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-05 21:54:13 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_symlink_rule
|
|
|
|
*
|
|
|
|
* Output a rule to create a symlink.
|
|
|
|
*/
|
2020-10-23 03:41:12 -07:00
|
|
|
static void output_symlink_rule( const char *src_name, const char *link_name, int create_dir )
|
2016-05-05 21:54:13 -07:00
|
|
|
{
|
2020-10-23 03:41:12 -07:00
|
|
|
const char *name = strrchr( link_name, '/' );
|
|
|
|
char *dir = NULL;
|
2016-05-05 21:54:13 -07:00
|
|
|
|
2020-10-23 03:41:12 -07:00
|
|
|
if (name)
|
2016-05-05 21:54:13 -07:00
|
|
|
{
|
2020-10-23 03:41:12 -07:00
|
|
|
dir = xstrdup( link_name );
|
2016-05-05 21:54:13 -07:00
|
|
|
dir[name - link_name] = 0;
|
|
|
|
}
|
2020-10-23 03:41:12 -07:00
|
|
|
|
2020-12-11 08:05:45 -07:00
|
|
|
output( "\t%s", cmd_prefix( "LN" ));
|
2020-10-23 03:41:12 -07:00
|
|
|
if (create_dir && dir && *dir) output( "%s -d %s && ", root_src_dir_path( "tools/install-sh" ), dir );
|
|
|
|
output( "rm -f %s && ", link_name );
|
|
|
|
|
|
|
|
/* dest path with a directory needs special handling if ln -s isn't supported */
|
|
|
|
if (dir && strcmp( ln_s, "ln -s" ))
|
|
|
|
output( "cd %s && %s %s %s\n", *dir ? dir : "/", ln_s, src_name, name + 1 );
|
2016-05-05 21:54:13 -07:00
|
|
|
else
|
|
|
|
output( "%s %s %s\n", ln_s, src_name, link_name );
|
2020-10-23 03:41:12 -07:00
|
|
|
|
|
|
|
free( dir );
|
2016-05-05 21:54:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-22 06:35:08 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_srcdir_symlink
|
|
|
|
*
|
|
|
|
* Output rule to create a symlink back to the source directory, for source files
|
|
|
|
* that are needed at run-time.
|
|
|
|
*/
|
|
|
|
static void output_srcdir_symlink( struct makefile *make, const char *obj )
|
|
|
|
{
|
2020-09-11 00:55:46 -07:00
|
|
|
char *src_file, *dst_file, *src_name;
|
2019-11-22 06:35:08 -07:00
|
|
|
|
|
|
|
if (!make->src_dir) return;
|
|
|
|
src_file = src_dir_path( make, obj );
|
2020-09-11 00:55:46 -07:00
|
|
|
dst_file = obj_dir_path( make, obj );
|
|
|
|
output( "%s: %s\n", dst_file, src_file );
|
|
|
|
|
|
|
|
src_name = src_file;
|
|
|
|
if (src_name[0] != '/' && make->obj_dir)
|
2024-06-24 04:39:49 -07:00
|
|
|
src_name = concat_paths( get_root_relative_path( make ), src_name );
|
2020-09-11 00:55:46 -07:00
|
|
|
|
2020-10-23 03:41:12 -07:00
|
|
|
output_symlink_rule( src_name, dst_file, 0 );
|
2022-10-25 02:08:06 -07:00
|
|
|
strarray_add( &make->all_targets[0], obj );
|
2019-11-22 06:35:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-28 22:32:45 -07:00
|
|
|
/*******************************************************************
|
2018-02-22 06:34:56 -07:00
|
|
|
* output_install_commands
|
2015-10-28 22:32:45 -07:00
|
|
|
*/
|
2020-09-14 03:48:06 -07:00
|
|
|
static void output_install_commands( struct makefile *make, struct strarray files )
|
2015-10-28 22:32:45 -07:00
|
|
|
{
|
2022-10-25 02:03:54 -07:00
|
|
|
unsigned int i, arch;
|
2020-09-14 03:48:06 -07:00
|
|
|
char *install_sh = root_src_dir_path( "tools/install-sh" );
|
2015-10-28 22:32:45 -07:00
|
|
|
|
|
|
|
for (i = 0; i < files.count; i += 2)
|
|
|
|
{
|
|
|
|
const char *file = files.str[i];
|
2016-04-03 21:59:54 -07:00
|
|
|
const char *dest = strmake( "$(DESTDIR)%s", files.str[i + 1] + 1 );
|
2022-10-25 02:03:54 -07:00
|
|
|
char type = *files.str[i + 1];
|
2015-10-28 22:32:45 -07:00
|
|
|
|
2022-10-25 02:03:54 -07:00
|
|
|
switch (type)
|
2015-10-28 22:32:45 -07:00
|
|
|
{
|
2022-10-25 02:03:54 -07:00
|
|
|
case '1': case '2': case '3': case '4': case '5':
|
|
|
|
case '6': case '7': case '8': case '9': /* arch-dependent program */
|
|
|
|
arch = type - '0';
|
2022-10-24 02:42:31 -07:00
|
|
|
output( "\tSTRIPPROG=%s %s -m 644 $(INSTALL_PROGRAM_FLAGS) %s %s\n",
|
2022-10-25 02:03:54 -07:00
|
|
|
strip_progs[arch], install_sh, obj_dir_path( make, file ), dest );
|
2019-12-18 13:05:58 -07:00
|
|
|
output( "\t%s --builtin %s\n", tools_path( make, "winebuild" ), dest );
|
2019-04-22 02:51:04 -07:00
|
|
|
break;
|
2015-10-28 22:32:45 -07:00
|
|
|
case 'd': /* data file */
|
2016-04-03 21:59:54 -07:00
|
|
|
output( "\t%s -m 644 $(INSTALL_DATA_FLAGS) %s %s\n",
|
|
|
|
install_sh, obj_dir_path( make, file ), dest );
|
2015-10-28 22:32:45 -07:00
|
|
|
break;
|
|
|
|
case 'D': /* data file in source dir */
|
2016-04-03 21:59:54 -07:00
|
|
|
output( "\t%s -m 644 $(INSTALL_DATA_FLAGS) %s %s\n",
|
|
|
|
install_sh, src_dir_path( make, file ), dest );
|
2015-10-28 22:32:45 -07:00
|
|
|
break;
|
2022-10-25 02:03:54 -07:00
|
|
|
case '0': /* native arch program file */
|
2015-10-28 22:32:45 -07:00
|
|
|
case 'p': /* program file */
|
2016-04-03 21:59:54 -07:00
|
|
|
output( "\tSTRIPPROG=\"$(STRIP)\" %s $(INSTALL_PROGRAM_FLAGS) %s %s\n",
|
|
|
|
install_sh, obj_dir_path( make, file ), dest );
|
2015-10-28 22:32:45 -07:00
|
|
|
break;
|
|
|
|
case 's': /* script */
|
2016-04-03 21:59:54 -07:00
|
|
|
output( "\t%s $(INSTALL_SCRIPT_FLAGS) %s %s\n",
|
|
|
|
install_sh, obj_dir_path( make, file ), dest );
|
2015-10-28 22:32:45 -07:00
|
|
|
break;
|
|
|
|
case 'S': /* script in source dir */
|
2016-04-03 21:59:54 -07: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",
|
2018-02-22 06:34:56 -07:00
|
|
|
install_sh, tools_dir_path( make, files.str[i] ), dest );
|
2015-10-28 22:32:45 -07:00
|
|
|
break;
|
2015-10-29 02:06:35 -07:00
|
|
|
case 'y': /* symlink */
|
2020-10-23 03:41:12 -07:00
|
|
|
output_symlink_rule( files.str[i], dest, 1 );
|
2015-10-29 02:06:35 -07:00
|
|
|
break;
|
2015-10-28 22:32:45 -07:00
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
}
|
2018-02-21 04:29:06 -07:00
|
|
|
strarray_add( &make->uninstall_files, dest );
|
2015-10-28 22:32:45 -07:00
|
|
|
}
|
2018-02-22 06:34:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output_install_rules
|
|
|
|
*
|
|
|
|
* Rules are stored as a (file,dest) pair of values.
|
|
|
|
* The first char of dest indicates the type of install.
|
|
|
|
*/
|
2022-09-07 01:12:00 -07:00
|
|
|
static void output_install_rules( struct makefile *make, enum install_rules rules )
|
2018-02-22 06:34:56 -07:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
struct strarray files = make->install_rules[rules];
|
|
|
|
struct strarray targets = empty_strarray;
|
|
|
|
|
|
|
|
if (!files.count) return;
|
|
|
|
|
|
|
|
for (i = 0; i < files.count; i += 2)
|
|
|
|
{
|
|
|
|
const char *file = files.str[i];
|
|
|
|
switch (*files.str[i + 1])
|
|
|
|
{
|
2022-10-25 02:03:54 -07:00
|
|
|
case '0': case '1': case '2': case '3': case '4':
|
|
|
|
case '5': case '6': case '7': case '8': case '9': /* arch-dependent program */
|
2018-02-22 06:34:56 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-07 01:12:00 -07:00
|
|
|
output( "%s %s::", obj_dir_path( make, "install" ), obj_dir_path( make, install_targets[rules] ));
|
2018-02-22 06:34:56 -07:00
|
|
|
output_filenames( targets );
|
|
|
|
output( "\n" );
|
2020-09-14 03:48:06 -07:00
|
|
|
output_install_commands( make, files );
|
2020-09-09 02:47:29 -07:00
|
|
|
strarray_add_uniq( &make->phony_targets, obj_dir_path( make, "install" ));
|
2022-09-07 01:12:00 -07:00
|
|
|
strarray_add_uniq( &make->phony_targets, obj_dir_path( make, install_targets[rules] ));
|
2018-02-21 04:29:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int cmp_string_length( const char **a, const char **b )
|
|
|
|
{
|
|
|
|
int paths_a = 0, paths_b = 0;
|
|
|
|
const char *p;
|
|
|
|
|
|
|
|
for (p = *a; *p; p++) if (*p == '/') paths_a++;
|
|
|
|
for (p = *b; *p; p++) if (*p == '/') paths_b++;
|
|
|
|
if (paths_b != paths_a) return paths_b - paths_a;
|
|
|
|
return strcmp( *a, *b );
|
|
|
|
}
|
|
|
|
|
2022-10-31 04:30:07 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* get_removable_dirs
|
|
|
|
*
|
|
|
|
* Retrieve a list of directories to try to remove after deleting the files.
|
|
|
|
*/
|
|
|
|
static struct strarray get_removable_dirs( struct strarray files )
|
|
|
|
{
|
|
|
|
struct strarray dirs = empty_strarray;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < files.count; i++)
|
|
|
|
{
|
|
|
|
char *dir = xstrdup( files.str[i] );
|
|
|
|
while (strchr( dir, '/' ))
|
|
|
|
{
|
|
|
|
*strrchr( dir, '/' ) = 0;
|
|
|
|
strarray_add_uniq( &dirs, xstrdup(dir) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
strarray_qsort( &dirs, cmp_string_length );
|
|
|
|
return dirs;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-21 04:29:06 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_uninstall_rules
|
|
|
|
*/
|
|
|
|
static void output_uninstall_rules( struct makefile *make )
|
|
|
|
{
|
|
|
|
static const char *dirs_order[] =
|
2024-06-24 04:57:34 -07:00
|
|
|
{ "$(includedir)", "$(mandir)", "$(datadir)" };
|
2018-02-21 04:29:06 -07:00
|
|
|
|
2022-10-31 04:30:07 -07:00
|
|
|
struct strarray uninstall_dirs;
|
2018-02-21 04:29:06 -07:00
|
|
|
unsigned int i, j;
|
|
|
|
|
|
|
|
if (!make->uninstall_files.count) return;
|
|
|
|
output( "uninstall::\n" );
|
2022-10-31 04:30:07 -07:00
|
|
|
output_rm_filenames( make->uninstall_files, "rm -f" );
|
2018-02-21 04:29:06 -07:00
|
|
|
strarray_add_uniq( &make->phony_targets, "uninstall" );
|
|
|
|
|
2020-09-14 03:48:06 -07:00
|
|
|
if (!subdirs.count) return;
|
2022-10-31 04:30:07 -07:00
|
|
|
uninstall_dirs = get_removable_dirs( make->uninstall_files );
|
2018-02-21 04:29:06 -07:00
|
|
|
output( "\t-rmdir" );
|
2022-10-16 12:51:57 -07:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dirs_order); i++)
|
2018-02-21 04:29:06 -07:00
|
|
|
{
|
2020-09-14 03:48:06 -07:00
|
|
|
for (j = 0; j < uninstall_dirs.count; j++)
|
2018-02-21 04:29:06 -07:00
|
|
|
{
|
2020-09-14 03:48:06 -07:00
|
|
|
if (!uninstall_dirs.str[j]) continue;
|
|
|
|
if (strncmp( uninstall_dirs.str[j] + strlen("$(DESTDIR)"), dirs_order[i], strlen(dirs_order[i]) ))
|
2018-02-21 04:29:06 -07:00
|
|
|
continue;
|
2020-09-14 03:48:06 -07:00
|
|
|
output_filename( uninstall_dirs.str[j] );
|
|
|
|
uninstall_dirs.str[j] = NULL;
|
2018-02-21 04:29:06 -07:00
|
|
|
}
|
|
|
|
}
|
2020-09-14 03:48:06 -07:00
|
|
|
for (j = 0; j < uninstall_dirs.count; j++)
|
|
|
|
if (uninstall_dirs.str[j]) output_filename( uninstall_dirs.str[j] );
|
2018-02-21 04:29:06 -07:00
|
|
|
output( "\n" );
|
2015-10-28 22:32:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-24 23:36:02 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_po_files
|
|
|
|
*/
|
2022-01-21 03:48:20 -07:00
|
|
|
static void output_po_files( struct makefile *make )
|
2016-02-24 23:36:02 -07:00
|
|
|
{
|
|
|
|
const char *po_dir = src_dir_path( make, "po" );
|
2020-09-12 02:40:00 -07:00
|
|
|
unsigned int i;
|
2016-02-24 23:36:02 -07:00
|
|
|
|
|
|
|
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 );
|
2020-12-11 08:05:45 -07:00
|
|
|
output( "\t%smsgmerge --previous -q $@ %s/wine.pot | msgattrib --no-obsolete -o $@.new && mv $@.new $@\n",
|
|
|
|
cmd_prefix( "MSG" ), po_dir );
|
2022-01-21 03:48:20 -07:00
|
|
|
output( "po/all:" );
|
2016-02-29 22:30:24 -07:00
|
|
|
for (i = 0; i < linguas.count; i++)
|
|
|
|
output_filename( strmake( "%s/%s.po", po_dir, linguas.str[i] ));
|
|
|
|
output( "\n" );
|
2016-02-24 23:36:02 -07:00
|
|
|
}
|
|
|
|
output( "%s/wine.pot:", po_dir );
|
2020-09-12 02:40:00 -07:00
|
|
|
output_filenames( make->pot_files );
|
2016-02-24 23:36:02 -07:00
|
|
|
output( "\n" );
|
2020-12-11 08:05:45 -07:00
|
|
|
output( "\t%smsgcat -o $@", cmd_prefix( "MSG" ));
|
2020-09-12 02:40:00 -07:00
|
|
|
output_filenames( make->pot_files );
|
2016-02-24 23:36:02 -07:00
|
|
|
output( "\n" );
|
2022-01-21 03:48:20 -07:00
|
|
|
strarray_add( &make->maintainerclean_files, strmake( "%s/wine.pot", po_dir ));
|
2016-02-24 23:36:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-09-28 10:43:24 -07:00
|
|
|
/*******************************************************************
|
2018-02-17 01:53:42 -07:00
|
|
|
* output_source_y
|
1997-09-28 10:43:24 -07:00
|
|
|
*/
|
2018-02-17 01:53:42 -07:00
|
|
|
static void output_source_y( struct makefile *make, struct incl_file *source, const char *obj )
|
1997-09-28 10:43:24 -07:00
|
|
|
{
|
2018-02-17 01:53:42 -07:00
|
|
|
char *header = strmake( "%s.tab.h", obj );
|
2013-11-09 10:57:00 -07:00
|
|
|
|
2018-02-17 01:53:42 -07:00
|
|
|
if (find_include_file( make, header ))
|
|
|
|
{
|
|
|
|
output( "%s: %s\n", obj_dir_path( make, header ), source->filename );
|
2023-11-15 02:42:20 -07:00
|
|
|
output( "\t%s%s -o %s.tab.$$$$.c --defines=$@ %s && rm -f %s.tab.$$$$.c\n",
|
2023-11-14 05:04:36 -07:00
|
|
|
cmd_prefix( "BISON" ), bison, obj_dir_path( make, obj ),
|
|
|
|
source->filename, obj_dir_path( make, obj ));
|
2018-02-17 01:53:42 -07:00
|
|
|
strarray_add( &make->clean_files, header );
|
|
|
|
}
|
2023-11-14 05:04:36 -07:00
|
|
|
output( "%s.tab.c: %s\n", obj_dir_path( make, obj ), source->filename );
|
2022-01-21 04:50:25 -07:00
|
|
|
output( "\t%s%s -o $@ %s\n", cmd_prefix( "BISON" ), bison, source->filename );
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
2014-01-14 03:49:42 -07:00
|
|
|
|
2013-11-19 05:03:55 -07:00
|
|
|
|
2018-02-17 01:53:42 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_source_l
|
|
|
|
*/
|
|
|
|
static void output_source_l( struct makefile *make, struct incl_file *source, const char *obj )
|
|
|
|
{
|
|
|
|
output( "%s.yy.c: %s\n", obj_dir_path( make, obj ), source->filename );
|
2020-12-11 08:05:45 -07:00
|
|
|
output( "\t%s%s -o$@ %s\n", cmd_prefix( "FLEX" ), flex, source->filename );
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output_source_h
|
|
|
|
*/
|
|
|
|
static void output_source_h( struct makefile *make, struct incl_file *source, const char *obj )
|
|
|
|
{
|
|
|
|
if (source->file->flags & FLAG_GENERATED)
|
2022-10-25 02:08:06 -07:00
|
|
|
strarray_add( &make->all_targets[0], source->name );
|
2022-07-27 23:53:19 -07:00
|
|
|
else if ((source->file->flags & FLAG_INSTALL) || strncmp( source->name, "wine/", 5 ))
|
2022-10-26 02:03:51 -07:00
|
|
|
add_install_rule( make, source->name, 0, source->name,
|
2018-11-27 05:16:52 -07:00
|
|
|
strmake( "D$(includedir)/wine/%s", get_include_install_path( source->name ) ));
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
2013-10-14 02:11:07 -07:00
|
|
|
|
|
|
|
|
2018-02-17 01:53:42 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_source_rc
|
|
|
|
*/
|
|
|
|
static void output_source_rc( struct makefile *make, struct incl_file *source, const char *obj )
|
|
|
|
{
|
2019-06-17 10:17:06 -07:00
|
|
|
struct strarray defines = get_source_defines( make, source, obj );
|
2022-10-25 02:09:57 -07:00
|
|
|
const char *po_dir = NULL, *res_file = strmake( "%s.res", obj );
|
|
|
|
unsigned int i, arch;
|
2014-01-07 04:20:25 -07:00
|
|
|
|
2022-07-27 23:53:19 -07:00
|
|
|
if (source->file->flags & FLAG_RC_HEADER) return;
|
2018-11-30 04:55:18 -07:00
|
|
|
if (source->file->flags & FLAG_GENERATED) strarray_add( &make->clean_files, source->name );
|
2020-09-14 03:48:06 -07:00
|
|
|
if (linguas.count && (source->file->flags & FLAG_RC_PO)) po_dir = "po";
|
2023-08-11 01:15:22 -07:00
|
|
|
if (!(source->file->flags & FLAG_TESTDLL))
|
2022-12-04 04:50:59 -07:00
|
|
|
{
|
|
|
|
for (arch = 0; arch < archs.count; arch++)
|
|
|
|
if (!make->disabled[arch]) strarray_add( &make->res_files[arch], res_file );
|
|
|
|
}
|
|
|
|
else strarray_add( &make->clean_files, res_file );
|
|
|
|
|
2020-09-14 02:26:35 -07:00
|
|
|
if (source->file->flags & FLAG_RC_PO)
|
2020-02-07 02:38:06 -07:00
|
|
|
{
|
2020-09-09 02:46:00 -07:00
|
|
|
strarray_add( &make->pot_files, strmake( "%s.pot", obj ));
|
2020-02-07 02:38:06 -07:00
|
|
|
output( "%s.pot ", obj_dir_path( make, obj ) );
|
|
|
|
}
|
2022-10-25 02:09:57 -07:00
|
|
|
output( "%s: %s", obj_dir_path( make, res_file ), source->filename );
|
2020-02-07 02:38:06 -07:00
|
|
|
output_filename( tools_path( make, "wrc" ));
|
2022-04-04 01:43:20 -07:00
|
|
|
if (make->src_dir) output_filename( "nls/locale.nls" );
|
2020-02-07 02:38:06 -07:00
|
|
|
output_filenames( source->dependencies );
|
|
|
|
output( "\n" );
|
2020-12-11 08:05:45 -07:00
|
|
|
output( "\t%s%s -u -o $@", cmd_prefix( "WRC" ), tools_path( make, "wrc" ) );
|
2018-02-17 01:53:42 -07:00
|
|
|
if (make->is_win16) output_filename( "-m16" );
|
|
|
|
output_filename( "--nostdinc" );
|
2020-02-07 02:38:06 -07:00
|
|
|
if (po_dir) output_filename( strmake( "--po-dir=%s", po_dir ));
|
2019-06-17 10:17:06 -07:00
|
|
|
output_filenames( defines );
|
2020-02-07 02:38:06 -07:00
|
|
|
output_filename( source->filename );
|
|
|
|
output( "\n" );
|
|
|
|
if (po_dir)
|
2018-02-17 01:53:42 -07:00
|
|
|
{
|
2022-10-25 02:09:57 -07:00
|
|
|
output( "%s:", obj_dir_path( make, res_file ));
|
2018-02-17 01:53:42 -07:00
|
|
|
for (i = 0; i < linguas.count; i++)
|
|
|
|
output_filename( strmake( "%s/%s.mo", po_dir, linguas.str[i] ));
|
|
|
|
output( "\n" );
|
|
|
|
}
|
|
|
|
}
|
2013-11-09 10:57:00 -07:00
|
|
|
|
2013-10-14 10:52:52 -07:00
|
|
|
|
2018-02-17 01:53:42 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_source_mc
|
|
|
|
*/
|
|
|
|
static void output_source_mc( struct makefile *make, struct incl_file *source, const char *obj )
|
|
|
|
{
|
2022-10-25 02:09:57 -07:00
|
|
|
unsigned int i, arch;
|
2020-02-06 07:05:48 -07:00
|
|
|
char *obj_path = obj_dir_path( make, obj );
|
2022-10-25 02:09:57 -07:00
|
|
|
char *res_file = strmake( "%s.res", obj );
|
2006-10-16 08:19:07 -07:00
|
|
|
|
2023-01-27 05:08:04 -07:00
|
|
|
for (arch = 0; arch < archs.count; arch++)
|
|
|
|
if (!make->disabled[arch]) strarray_add( &make->res_files[arch], res_file );
|
2020-09-09 02:46:00 -07:00
|
|
|
strarray_add( &make->pot_files, strmake( "%s.pot", obj ));
|
2020-02-06 07:05:48 -07:00
|
|
|
output( "%s.pot %s.res: %s", obj_path, obj_path, source->filename );
|
|
|
|
output_filename( tools_path( make, "wmc" ));
|
|
|
|
output_filenames( source->dependencies );
|
2022-11-15 08:56:20 -07:00
|
|
|
if (make->src_dir) output_filename( "nls/locale.nls" );
|
2020-02-06 07:05:48 -07:00
|
|
|
output( "\n" );
|
2020-12-11 08:05:45 -07:00
|
|
|
output( "\t%s%s -u -o $@ %s", cmd_prefix( "WMC" ), tools_path( make, "wmc" ), source->filename );
|
2018-02-17 01:53:42 -07:00
|
|
|
if (linguas.count)
|
|
|
|
{
|
2020-09-14 03:48:06 -07:00
|
|
|
output_filename( "--po-dir=po" );
|
2018-02-17 01:53:42 -07:00
|
|
|
output( "\n" );
|
|
|
|
output( "%s.res:", obj_dir_path( make, obj ));
|
|
|
|
for (i = 0; i < linguas.count; i++)
|
2020-09-14 03:48:06 -07:00
|
|
|
output_filename( strmake( "po/%s.mo", linguas.str[i] ));
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
|
|
|
output( "\n" );
|
|
|
|
}
|
2006-10-16 08:19:07 -07:00
|
|
|
|
2014-02-18 07:53:14 -07:00
|
|
|
|
2018-02-17 01:53:42 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_source_res
|
|
|
|
*/
|
|
|
|
static void output_source_res( struct makefile *make, struct incl_file *source, const char *obj )
|
|
|
|
{
|
2023-01-27 05:08:04 -07:00
|
|
|
if (make->disabled[source->arch]) return;
|
2022-10-25 02:09:57 -07:00
|
|
|
strarray_add( &make->res_files[source->arch], source->name );
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
2017-07-14 02:58:54 -07:00
|
|
|
|
|
|
|
|
2018-02-17 01:53:42 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_source_idl
|
|
|
|
*/
|
|
|
|
static void output_source_idl( struct makefile *make, struct incl_file *source, const char *obj )
|
|
|
|
{
|
2019-06-17 10:17:06 -07:00
|
|
|
struct strarray defines = get_source_defines( make, source, obj );
|
2022-10-25 02:08:56 -07:00
|
|
|
struct strarray headers = empty_strarray;
|
2023-01-27 05:08:04 -07:00
|
|
|
struct strarray deps = empty_strarray;
|
2022-10-25 02:08:56 -07:00
|
|
|
struct strarray multiarch_targets[MAX_ARCHS] = { empty_strarray };
|
|
|
|
const char *dest;
|
|
|
|
unsigned int i, arch;
|
2018-02-17 01:53:42 -07:00
|
|
|
|
|
|
|
if (find_include_file( make, strmake( "%s.h", obj ))) source->file->flags |= FLAG_IDL_HEADER;
|
2022-07-27 23:53:19 -07:00
|
|
|
if (!source->file->flags) return;
|
2018-02-17 01:53:42 -07:00
|
|
|
|
|
|
|
if (source->file->flags & FLAG_IDL_PROXY) strarray_add( &make->dlldata_files, source->name );
|
|
|
|
if (source->file->flags & FLAG_INSTALL)
|
|
|
|
{
|
2022-10-26 02:03:51 -07:00
|
|
|
add_install_rule( make, source->name, 0, xstrdup( source->name ),
|
2018-11-27 05:16:52 -07:00
|
|
|
strmake( "D$(includedir)/wine/%s.idl", get_include_install_path( obj ) ));
|
2018-02-17 01:53:42 -07:00
|
|
|
if (source->file->flags & FLAG_IDL_HEADER)
|
2022-10-26 02:03:51 -07:00
|
|
|
add_install_rule( make, source->name, 0, strmake( "%s.h", obj ),
|
2018-11-27 05:16:52 -07:00
|
|
|
strmake( "d$(includedir)/wine/%s.h", get_include_install_path( obj ) ));
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
2022-10-25 02:08:56 -07:00
|
|
|
if (source->file->flags & FLAG_IDL_HEADER)
|
|
|
|
{
|
|
|
|
dest = strmake( "%s.h", obj );
|
|
|
|
strarray_add( &headers, dest );
|
|
|
|
if (!find_src_file( make, dest )) strarray_add( &make->clean_files, dest );
|
|
|
|
}
|
2018-02-17 01:53:42 -07:00
|
|
|
|
2022-10-25 02:08:56 -07:00
|
|
|
for (i = 0; i < ARRAY_SIZE(idl_outputs); i++)
|
|
|
|
{
|
|
|
|
if (!(source->file->flags & idl_outputs[i].flag)) continue;
|
|
|
|
for (arch = 0; arch < archs.count; arch++)
|
|
|
|
{
|
2022-11-22 07:34:48 -07:00
|
|
|
if (!is_multiarch( arch )) continue;
|
2023-01-27 05:08:04 -07:00
|
|
|
if (make->disabled[arch]) continue;
|
2022-10-26 02:04:43 -07:00
|
|
|
dest = strmake( "%s%s%s", arch_dirs[arch], obj, idl_outputs[i].ext );
|
2022-10-25 02:08:56 -07:00
|
|
|
if (!find_src_file( make, dest )) strarray_add( &make->clean_files, dest );
|
|
|
|
strarray_add( &multiarch_targets[arch], dest );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (arch = 0; arch < archs.count; arch++)
|
|
|
|
{
|
2023-01-27 05:08:04 -07:00
|
|
|
struct strarray arch_deps = empty_strarray;
|
|
|
|
|
|
|
|
if (!arch) strarray_addall( &arch_deps, headers );
|
|
|
|
strarray_addall( &arch_deps, multiarch_targets[arch] );
|
|
|
|
if (!arch_deps.count) continue;
|
|
|
|
output_filenames_obj_dir( make, arch_deps );
|
2022-10-25 02:08:56 -07:00
|
|
|
output( ":\n" );
|
|
|
|
output( "\t%s%s -o $@", cmd_prefix( "WIDL" ), tools_path( make, "widl" ) );
|
|
|
|
output_filenames( target_flags[arch] );
|
|
|
|
output_filename( "--nostdinc" );
|
|
|
|
output_filename( "-Ldlls/\\*" );
|
|
|
|
output_filenames( defines );
|
|
|
|
output_filenames( get_expanded_make_var_array( make, "EXTRAIDLFLAGS" ));
|
|
|
|
output_filenames( get_expanded_file_local_var( make, obj, "EXTRAIDLFLAGS" ));
|
2023-11-10 03:06:26 -07:00
|
|
|
if (arch) output_filenames( get_expanded_arch_var_array( make, "EXTRAIDLFLAGS", arch ));
|
2022-10-25 02:08:56 -07:00
|
|
|
output_filename( source->filename );
|
|
|
|
output( "\n" );
|
2023-01-27 05:08:04 -07:00
|
|
|
strarray_addall( &deps, arch_deps );
|
2022-10-25 02:08:56 -07:00
|
|
|
}
|
|
|
|
|
2023-01-27 05:08:04 -07:00
|
|
|
if (deps.count)
|
|
|
|
{
|
|
|
|
output_filenames_obj_dir( make, deps );
|
|
|
|
output( ":" );
|
|
|
|
output_filename( tools_path( make, "widl" ));
|
|
|
|
output_filename( source->filename );
|
|
|
|
output_filenames( source->dependencies );
|
|
|
|
output( "\n" );
|
|
|
|
}
|
2022-10-25 02:08:56 -07:00
|
|
|
|
|
|
|
if (source->importlibdeps.count)
|
2021-11-12 07:14:12 -07:00
|
|
|
{
|
2022-10-25 02:08:56 -07:00
|
|
|
for (arch = 0; arch < archs.count; arch++)
|
|
|
|
{
|
|
|
|
if (!multiarch_targets[arch].count) continue;
|
|
|
|
output_filenames_obj_dir( make, multiarch_targets[arch] );
|
|
|
|
output( ":" );
|
|
|
|
for (i = 0; i < source->importlibdeps.count; i++)
|
|
|
|
{
|
2024-04-08 15:00:24 -07:00
|
|
|
int native_arch = native_archs[arch] ? native_archs[arch] : arch;
|
2022-10-25 02:08:56 -07:00
|
|
|
struct makefile *submake = find_importlib_module( source->importlibdeps.str[i] );
|
2024-04-08 15:00:24 -07:00
|
|
|
const char *module = strmake( "%s%s", arch_pe_dirs[native_arch], submake->module );
|
2022-10-26 02:04:43 -07:00
|
|
|
output_filename( obj_dir_path( submake, module ));
|
2022-10-25 02:08:56 -07:00
|
|
|
}
|
|
|
|
output( "\n" );
|
|
|
|
}
|
2021-11-12 07:14:12 -07:00
|
|
|
}
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output_source_x
|
|
|
|
*/
|
|
|
|
static void output_source_x( struct makefile *make, struct incl_file *source, const char *obj )
|
|
|
|
{
|
|
|
|
output( "%s.h: %s%s %s\n", obj_dir_path( make, obj ),
|
|
|
|
tools_dir_path( make, "make_xftmpl" ), tools_ext, source->filename );
|
2020-12-11 08:05:45 -07:00
|
|
|
output( "\t%s%s%s -H -o $@ %s\n", cmd_prefix( "GEN" ),
|
2018-02-17 01:53:42 -07:00
|
|
|
tools_dir_path( make, "make_xftmpl" ), tools_ext, source->filename );
|
|
|
|
if (source->file->flags & FLAG_INSTALL)
|
|
|
|
{
|
2022-10-26 02:03:51 -07:00
|
|
|
add_install_rule( make, source->name, 0, source->name,
|
2018-11-27 05:16:52 -07:00
|
|
|
strmake( "D$(includedir)/wine/%s", get_include_install_path( source->name ) ));
|
2022-10-26 02:03:51 -07:00
|
|
|
add_install_rule( make, source->name, 0, strmake( "%s.h", obj ),
|
2018-11-27 05:16:52 -07:00
|
|
|
strmake( "d$(includedir)/wine/%s.h", get_include_install_path( obj ) ));
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output_source_sfd
|
|
|
|
*/
|
|
|
|
static void output_source_sfd( struct makefile *make, struct incl_file *source, const char *obj )
|
|
|
|
{
|
|
|
|
unsigned int i;
|
2018-11-27 05:16:52 -07:00
|
|
|
char *ttf_obj = strmake( "%s.ttf", obj );
|
|
|
|
char *ttf_file = src_dir_path( make, ttf_obj );
|
2018-02-17 01:53:42 -07:00
|
|
|
|
|
|
|
if (fontforge && !make->src_dir)
|
|
|
|
{
|
|
|
|
output( "%s: %s\n", ttf_file, source->filename );
|
2020-12-11 08:05:45 -07:00
|
|
|
output( "\t%s%s -script %s %s $@\n", cmd_prefix( "GEN" ),
|
2020-09-14 03:48:06 -07:00
|
|
|
fontforge, root_src_dir_path( "fonts/genttf.ff" ), source->filename );
|
2020-09-11 01:18:02 -07:00
|
|
|
if (!(source->file->flags & FLAG_SFD_FONTS)) strarray_add( &make->font_files, ttf_obj );
|
2022-01-21 03:48:20 -07:00
|
|
|
strarray_add( &make->maintainerclean_files, ttf_obj );
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
|
|
|
if (source->file->flags & FLAG_INSTALL)
|
2019-11-22 06:35:08 -07:00
|
|
|
{
|
2024-06-24 04:44:54 -07:00
|
|
|
add_install_rule( make, source->name, 0, ttf_obj, strmake( "D$(datadir)/wine/fonts/%s", ttf_obj ));
|
2019-11-22 06:35:08 -07:00
|
|
|
output_srcdir_symlink( make, ttf_obj );
|
|
|
|
}
|
2018-11-27 05:16:52 -07:00
|
|
|
|
2018-02-17 01:53:42 -07:00
|
|
|
if (source->file->flags & FLAG_SFD_FONTS)
|
|
|
|
{
|
|
|
|
struct strarray *array = source->file->args;
|
|
|
|
|
|
|
|
for (i = 0; i < array->count; i++)
|
2008-04-24 13:13:57 -07:00
|
|
|
{
|
2018-02-17 01:53:42 -07:00
|
|
|
char *font = strtok( xstrdup(array->str[i]), " \t" );
|
|
|
|
char *args = strtok( NULL, "" );
|
|
|
|
|
2022-10-25 02:08:06 -07:00
|
|
|
strarray_add( &make->all_targets[0], xstrdup( font ));
|
2018-02-17 01:53:42 -07:00
|
|
|
output( "%s: %s %s\n", obj_dir_path( make, font ),
|
|
|
|
tools_path( make, "sfnt2fon" ), ttf_file );
|
2020-12-11 08:05:45 -07:00
|
|
|
output( "\t%s%s -q -o $@ %s %s\n", cmd_prefix( "GEN" ),
|
|
|
|
tools_path( make, "sfnt2fon" ), ttf_file, args );
|
2024-06-24 04:44:54 -07:00
|
|
|
add_install_rule( make, source->name, 0, xstrdup(font), strmake( "d$(datadir)/wine/fonts/%s", font ));
|
2015-11-04 22:25:35 -07:00
|
|
|
}
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output_source_svg
|
|
|
|
*/
|
|
|
|
static void output_source_svg( struct makefile *make, struct incl_file *source, const char *obj )
|
|
|
|
{
|
|
|
|
static const char * const images[] = { "bmp", "cur", "ico", NULL };
|
|
|
|
unsigned int i;
|
|
|
|
|
2022-01-21 03:48:20 -07:00
|
|
|
if (convert && rsvg && icotool)
|
2018-02-17 01:53:42 -07:00
|
|
|
{
|
|
|
|
for (i = 0; images[i]; i++)
|
|
|
|
if (find_include_file( make, strmake( "%s.%s", obj, images[i] ))) break;
|
|
|
|
|
|
|
|
if (images[i])
|
2015-11-04 22:25:35 -07:00
|
|
|
{
|
2018-02-17 01:53:42 -07:00
|
|
|
output( "%s.%s: %s\n", src_dir_path( make, obj ), images[i], source->filename );
|
2020-12-11 08:05:45 -07:00
|
|
|
output( "\t%sCONVERT=\"%s\" ICOTOOL=\"%s\" RSVG=\"%s\" %s %s $@\n",
|
|
|
|
cmd_prefix( "GEN" ), convert, icotool, rsvg,
|
2020-09-14 03:48:06 -07:00
|
|
|
root_src_dir_path( "tools/buildimage" ), source->filename );
|
2022-01-21 03:48:20 -07:00
|
|
|
strarray_add( &make->maintainerclean_files, strmake( "%s.%s", obj, images[i] ));
|
2008-04-24 13:13:57 -07:00
|
|
|
}
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-19 12:57:15 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_source_nls
|
|
|
|
*/
|
|
|
|
static void output_source_nls( struct makefile *make, struct incl_file *source, const char *obj )
|
|
|
|
{
|
2022-10-26 02:03:51 -07:00
|
|
|
add_install_rule( make, source->name, 0, source->name,
|
2024-06-24 04:47:08 -07:00
|
|
|
strmake( "D$(datadir)/wine/nls/%s", source->name ));
|
2019-11-22 06:35:08 -07:00
|
|
|
output_srcdir_symlink( make, strmake( "%s.nls", obj ));
|
2018-02-19 12:57:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output_source_desktop
|
|
|
|
*/
|
|
|
|
static void output_source_desktop( struct makefile *make, struct incl_file *source, const char *obj )
|
|
|
|
{
|
2022-10-26 02:03:51 -07:00
|
|
|
add_install_rule( make, source->name, 0, source->name,
|
2018-02-19 12:57:15 -07:00
|
|
|
strmake( "D$(datadir)/applications/%s", source->name ));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-17 01:53:42 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_source_po
|
|
|
|
*/
|
|
|
|
static void output_source_po( struct makefile *make, struct incl_file *source, const char *obj )
|
|
|
|
{
|
|
|
|
output( "%s.mo: %s\n", obj_dir_path( make, obj ), source->filename );
|
2020-12-11 08:05:45 -07:00
|
|
|
output( "\t%s%s -o $@ %s\n", cmd_prefix( "MSG" ), msgfmt, source->filename );
|
2022-10-25 02:08:06 -07:00
|
|
|
strarray_add( &make->all_targets[0], strmake( "%s.mo", obj ));
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output_source_in
|
|
|
|
*/
|
|
|
|
static void output_source_in( struct makefile *make, struct incl_file *source, const char *obj )
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2022-07-27 23:53:19 -07:00
|
|
|
if (make == include_makefile) return; /* ignore generated includes */
|
2018-02-17 01:53:42 -07:00
|
|
|
if (strendswith( obj, ".man" ) && source->file->args)
|
|
|
|
{
|
|
|
|
struct strarray symlinks;
|
|
|
|
char *dir, *dest = replace_extension( obj, ".man", "" );
|
|
|
|
char *lang = strchr( dest, '.' );
|
|
|
|
char *section = source->file->args;
|
|
|
|
if (lang)
|
2015-11-01 23:53:42 -07:00
|
|
|
{
|
2018-02-17 01:53:42 -07:00
|
|
|
*lang++ = 0;
|
|
|
|
dir = strmake( "$(mandir)/%s/man%s", lang, section );
|
2015-11-01 23:53:42 -07:00
|
|
|
}
|
2018-02-17 01:53:42 -07:00
|
|
|
else dir = strmake( "$(mandir)/man%s", section );
|
2022-10-26 02:03:51 -07:00
|
|
|
add_install_rule( make, dest, 0, obj, strmake( "d%s/%s.%s", dir, dest, section ));
|
2018-02-17 01:53:42 -07:00
|
|
|
symlinks = get_expanded_file_local_var( make, dest, "SYMLINKS" );
|
|
|
|
for (i = 0; i < symlinks.count; i++)
|
2022-10-26 02:03:51 -07:00
|
|
|
add_install_rule( make, symlinks.str[i], 0, strmake( "%s.%s", dest, section ),
|
2018-02-17 01:53:42 -07:00
|
|
|
strmake( "y%s/%s.%s", dir, symlinks.str[i], section ));
|
|
|
|
free( dest );
|
|
|
|
free( dir );
|
|
|
|
}
|
2022-10-26 02:03:51 -07:00
|
|
|
strarray_add( &make->in_files, obj );
|
|
|
|
strarray_add( &make->all_targets[0], obj );
|
2018-02-17 01:53:42 -07:00
|
|
|
output( "%s: %s\n", obj_dir_path( make, obj ), source->filename );
|
2020-12-11 08:05:45 -07:00
|
|
|
output( "\t%s%s %s >$@ || (rm -f $@ && false)\n", cmd_prefix( "SED" ), sed_cmd, source->filename );
|
2018-02-17 01:53:42 -07:00
|
|
|
output( "%s:", obj_dir_path( make, obj ));
|
|
|
|
output_filenames( source->dependencies );
|
|
|
|
output( "\n" );
|
2022-10-26 02:03:51 -07:00
|
|
|
add_install_rule( make, obj, 0, obj, strmake( "d$(datadir)/wine/%s", obj ));
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-17 03:46:25 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_source_spec
|
|
|
|
*/
|
|
|
|
static void output_source_spec( struct makefile *make, struct incl_file *source, const char *obj )
|
2023-08-11 01:15:22 -07:00
|
|
|
{
|
|
|
|
/* nothing to do */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output_source_testdll
|
|
|
|
*/
|
|
|
|
static void output_source_testdll( struct makefile *make, struct incl_file *source, const char *obj )
|
2018-02-17 03:46:25 -07:00
|
|
|
{
|
|
|
|
struct strarray imports = get_expanded_file_local_var( make, obj, "IMPORTS" );
|
2022-10-31 12:45:03 -07:00
|
|
|
struct strarray dll_flags = empty_strarray;
|
2022-09-29 11:04:44 -07:00
|
|
|
struct strarray default_imports = empty_strarray;
|
2022-11-01 02:28:05 -07:00
|
|
|
struct strarray all_libs, dep_libs;
|
2023-09-05 03:40:29 -07:00
|
|
|
const char *dll_name, *obj_name, *res_name, *output_rsrc, *output_file, *debug_file, *ext = ".dll";
|
2023-09-05 23:58:26 -07:00
|
|
|
struct incl_file *spec_file = find_src_file( make, strmake( "%s.spec", obj ));
|
2024-04-08 15:00:24 -07:00
|
|
|
unsigned int arch, link_arch;
|
2018-02-17 03:46:25 -07:00
|
|
|
|
|
|
|
if (!imports.count) imports = make->imports;
|
2022-10-31 12:45:03 -07:00
|
|
|
strarray_addall( &dll_flags, make->extradllflags );
|
|
|
|
strarray_addall( &dll_flags, get_expanded_file_local_var( make, obj, "EXTRADLLFLAGS" ));
|
2022-09-29 11:04:44 -07:00
|
|
|
if (!strarray_exists( &dll_flags, "-nodefaultlibs" )) default_imports = get_default_imports( make, imports );
|
2023-08-29 07:44:37 -07:00
|
|
|
if (strarray_exists( &dll_flags, "-mconsole" )) ext = ".exe";
|
2023-08-11 01:15:22 -07:00
|
|
|
|
2022-11-01 02:28:05 -07:00
|
|
|
for (arch = 0; arch < archs.count; arch++)
|
|
|
|
{
|
2024-04-08 15:00:24 -07:00
|
|
|
const char *hybrid_obj_name = NULL;
|
|
|
|
|
|
|
|
if (!is_multiarch( arch ) || !get_link_arch( make, arch, &link_arch)) continue;
|
|
|
|
|
2022-11-01 02:28:05 -07:00
|
|
|
all_libs = dep_libs = empty_strarray;
|
|
|
|
strarray_addall( &all_libs, add_import_libs( make, &dep_libs, imports, IMPORT_TYPE_DIRECT, arch ) );
|
|
|
|
strarray_addall( &all_libs, add_import_libs( make, &dep_libs, default_imports, IMPORT_TYPE_DEFAULT, arch ) );
|
2022-12-08 02:53:24 -07:00
|
|
|
if (!arch) strarray_addall( &all_libs, libs );
|
2023-08-29 07:44:37 -07:00
|
|
|
dll_name = arch_module_name( strmake( "%s%s", obj, ext ), arch );
|
2022-11-01 02:28:05 -07:00
|
|
|
obj_name = obj_dir_path( make, strmake( "%s%s.o", arch_dirs[arch], obj ));
|
2024-04-08 15:00:24 -07:00
|
|
|
if (link_arch != arch)
|
|
|
|
hybrid_obj_name = obj_dir_path( make, strmake( "%s%s.o", arch_dirs[link_arch], obj ));
|
2022-11-01 02:28:05 -07:00
|
|
|
output_file = obj_dir_path( make, dll_name );
|
2022-12-04 04:50:59 -07:00
|
|
|
output_rsrc = strmake( "%s.res", dll_name );
|
2022-11-01 02:28:05 -07:00
|
|
|
|
2022-12-04 04:50:59 -07:00
|
|
|
if (!find_src_file( make, strmake( "%s.rc", obj ) )) res_name = NULL;
|
|
|
|
else res_name = obj_dir_path( make, strmake( "%s.res", obj ) );
|
|
|
|
|
2022-11-01 02:28:05 -07:00
|
|
|
strarray_add( &make->clean_files, dll_name );
|
2022-12-04 04:50:59 -07:00
|
|
|
strarray_add( &make->res_files[arch], output_rsrc );
|
|
|
|
output( "%s:", obj_dir_path( make, output_rsrc ));
|
2022-11-01 02:28:05 -07:00
|
|
|
output_filename( output_file );
|
|
|
|
output_filename( tools_path( make, "wrc" ));
|
|
|
|
output( "\n" );
|
2023-08-29 07:44:37 -07:00
|
|
|
output( "\t%secho \"%s%s TESTDLL \\\"%s\\\"\" | %s -u -o $@\n", cmd_prefix( "WRC" ), obj, ext, output_file,
|
2022-11-01 02:28:05 -07:00
|
|
|
tools_path( make, "wrc" ));
|
2018-02-17 03:46:25 -07:00
|
|
|
|
2022-11-01 02:28:05 -07:00
|
|
|
output( "%s:", output_file );
|
2023-08-29 07:44:37 -07:00
|
|
|
if (spec_file) output_filename( spec_file->filename );
|
2022-11-01 02:28:05 -07:00
|
|
|
output_filename( obj_name );
|
2024-04-08 15:00:24 -07:00
|
|
|
if (hybrid_obj_name) output_filename( hybrid_obj_name );
|
2022-12-04 04:50:59 -07:00
|
|
|
if (res_name) output_filename( res_name );
|
2022-11-01 02:28:05 -07:00
|
|
|
output_filenames( dep_libs );
|
|
|
|
output_filename( tools_path( make, "winebuild" ));
|
|
|
|
output_filename( tools_path( make, "winegcc" ));
|
|
|
|
output( "\n" );
|
2024-04-08 15:00:24 -07:00
|
|
|
output_winegcc_command( make, link_arch );
|
2022-11-01 02:28:05 -07:00
|
|
|
output_filename( "-s" );
|
|
|
|
output_filenames( dll_flags );
|
2024-04-08 15:00:24 -07:00
|
|
|
if (link_arch) output_filenames( get_expanded_arch_var_array( make, "EXTRADLLFLAGS", link_arch ));
|
2023-08-29 07:44:37 -07:00
|
|
|
if (!strcmp( ext, ".dll" )) output_filename( "-shared" );
|
|
|
|
if (spec_file) output_filename( spec_file->filename );
|
2022-11-01 02:28:05 -07:00
|
|
|
output_filename( obj_name );
|
2024-04-08 15:00:24 -07:00
|
|
|
if (hybrid_obj_name) output_filename( hybrid_obj_name );
|
2022-12-04 04:50:59 -07:00
|
|
|
if (res_name) output_filename( res_name );
|
2024-04-08 15:00:24 -07:00
|
|
|
if ((debug_file = get_debug_file( make, dll_name, link_arch )))
|
2022-11-01 02:28:05 -07:00
|
|
|
output_filename( strmake( "-Wl,--debug-file,%s", obj_dir_path( make, debug_file )));
|
|
|
|
output_filenames( all_libs );
|
2024-04-08 15:00:24 -07:00
|
|
|
output_filename( arch_make_variable( "LDFLAGS", link_arch ));
|
2022-11-01 02:28:05 -07:00
|
|
|
output( "\n" );
|
|
|
|
}
|
2018-02-17 03:46:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-02 04:04:43 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_source_xml
|
|
|
|
*/
|
|
|
|
static void output_source_xml( struct makefile *make, struct incl_file *source, const char *obj )
|
|
|
|
{
|
|
|
|
if (wayland_scanner)
|
|
|
|
{
|
|
|
|
output( "%s-protocol.c: %s\n", obj_dir_path( make, obj ), source->filename );
|
|
|
|
output( "\t%s%s private-code %s $@\n", cmd_prefix( "GEN" ), wayland_scanner, source->filename );
|
|
|
|
output( "%s-client-protocol.h: %s\n", obj_dir_path( make, obj ), source->filename );
|
|
|
|
output( "\t%s%s client-header %s $@\n", cmd_prefix( "GEN" ), wayland_scanner, source->filename );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-17 01:53:42 -07:00
|
|
|
/*******************************************************************
|
2022-10-26 02:03:20 -07:00
|
|
|
* output_source_one_arch
|
2018-02-17 01:53:42 -07:00
|
|
|
*/
|
2022-10-26 02:03:20 -07:00
|
|
|
static void output_source_one_arch( struct makefile *make, struct incl_file *source, const char *obj,
|
|
|
|
struct strarray defines, struct strarray *targets,
|
2023-08-11 01:15:22 -07:00
|
|
|
unsigned int arch )
|
2018-02-17 01:53:42 -07:00
|
|
|
{
|
2024-04-30 05:52:35 -07:00
|
|
|
const char *obj_name, *var_cc, *var_cflags;
|
2024-10-07 03:44:05 -07:00
|
|
|
struct compile_command *cmd;
|
2024-06-26 01:37:46 -07:00
|
|
|
struct strarray cflags = empty_strarray;
|
2022-10-26 02:03:20 -07:00
|
|
|
|
2023-01-27 05:08:04 -07:00
|
|
|
if (make->disabled[arch] && !(source->file->flags & FLAG_C_IMPLIB)) return;
|
|
|
|
|
2022-10-26 02:03:20 -07:00
|
|
|
if (arch)
|
|
|
|
{
|
|
|
|
if (source->file->flags & FLAG_C_UNIX) return;
|
2022-11-22 07:34:48 -07:00
|
|
|
if (!is_using_msvcrt( make ) && !make->staticlib && !(source->file->flags & FLAG_C_IMPLIB)) return;
|
2022-10-26 02:03:20 -07:00
|
|
|
}
|
|
|
|
else if (source->file->flags & FLAG_C_UNIX)
|
|
|
|
{
|
2023-06-15 01:27:06 -07:00
|
|
|
if (!unix_lib_supported) return;
|
2022-10-26 02:03:20 -07:00
|
|
|
}
|
2023-06-15 01:46:36 -07:00
|
|
|
else if (archs.count > 1 && is_using_msvcrt( make ))
|
|
|
|
{
|
|
|
|
if (!so_dll_supported) return;
|
|
|
|
if (!(source->file->flags & FLAG_C_IMPLIB) && (!make->staticlib || make->extlib)) return;
|
|
|
|
}
|
2022-10-26 02:03:20 -07:00
|
|
|
|
2022-10-26 02:04:43 -07:00
|
|
|
obj_name = strmake( "%s%s.o", source->arch ? "" : arch_dirs[arch], obj );
|
2022-10-26 02:03:20 -07:00
|
|
|
strarray_add( targets, obj_name );
|
|
|
|
|
|
|
|
if (source->file->flags & FLAG_C_UNIX)
|
|
|
|
strarray_add( &make->unixobj_files, obj_name );
|
|
|
|
else if (source->file->flags & FLAG_C_IMPLIB)
|
|
|
|
strarray_add( &make->implib_files[arch], obj_name );
|
2023-08-11 01:15:22 -07:00
|
|
|
else if (!(source->file->flags & FLAG_TESTDLL))
|
2022-10-26 02:03:20 -07:00
|
|
|
strarray_add( &make->object_files[arch], obj_name );
|
|
|
|
else
|
|
|
|
strarray_add( &make->clean_files, obj_name );
|
|
|
|
|
2024-06-26 01:37:46 -07:00
|
|
|
if (!source->use_msvcrt) strarray_addall( &cflags, make->unix_cflags );
|
2024-04-30 05:52:35 -07:00
|
|
|
if ((source->file->flags & FLAG_ARM64EC_X64) && !strcmp( archs.str[arch], "arm64ec" ))
|
|
|
|
{
|
|
|
|
var_cc = "$(x86_64_CC)";
|
|
|
|
var_cflags = "$(x86_64_CFLAGS)";
|
2024-06-26 01:37:46 -07:00
|
|
|
strarray_add( &cflags, "-D__arm64ec_x64__" );
|
|
|
|
strarray_addall( &cflags, get_expanded_make_var_array( top_makefile, "x86_64_EXTRACFLAGS" ));
|
2024-04-30 05:52:35 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var_cc = arch_make_variable( "CC", arch );
|
|
|
|
var_cflags = arch_make_variable( "CFLAGS", arch );
|
2024-06-26 01:37:46 -07:00
|
|
|
strarray_addall( &cflags, make->extlib ? extra_cflags_extlib[arch] : extra_cflags[arch] );
|
2024-04-30 05:52:35 -07:00
|
|
|
}
|
|
|
|
|
2022-10-26 02:03:20 -07:00
|
|
|
if (!arch)
|
|
|
|
{
|
2023-02-27 03:01:23 -07:00
|
|
|
if (source->file->flags & FLAG_C_UNIX)
|
2021-09-22 01:34:07 -07:00
|
|
|
{
|
2024-06-26 01:37:46 -07:00
|
|
|
strarray_addall( &cflags, unix_dllflags );
|
2021-09-22 01:34:07 -07:00
|
|
|
}
|
2021-10-06 01:20:26 -07:00
|
|
|
else if (make->module || make->testdll)
|
2019-04-09 00:39:47 -07:00
|
|
|
{
|
2024-06-26 01:37:46 -07:00
|
|
|
strarray_addall( &cflags, dll_flags );
|
|
|
|
if (source->use_msvcrt) strarray_addall( &cflags, msvcrt_flags );
|
2023-06-15 01:27:06 -07:00
|
|
|
if (!unix_lib_supported && make->module && is_crt_module( make->module ))
|
2024-06-26 01:37:46 -07:00
|
|
|
strarray_add( &cflags, "-fno-builtin" );
|
2019-04-09 00:39:47 -07:00
|
|
|
}
|
2024-08-14 13:50:52 -07:00
|
|
|
strarray_addall( &cflags, cpp_flags );
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
2022-10-26 02:03:20 -07:00
|
|
|
else
|
2018-02-17 01:53:42 -07:00
|
|
|
{
|
2024-06-26 01:37:46 -07:00
|
|
|
if (make->module && is_crt_module( make->module )) strarray_add( &cflags, "-fno-builtin" );
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
2022-10-26 02:03:20 -07:00
|
|
|
|
2024-06-26 01:37:46 -07:00
|
|
|
output( "%s: %s\n", obj_dir_path( make, obj_name ), source->filename );
|
|
|
|
output( "\t%s%s -c -o $@ %s", cmd_prefix( "CC" ), var_cc, source->filename );
|
|
|
|
output_filenames( defines );
|
|
|
|
output_filenames( cflags );
|
2024-04-30 05:52:35 -07:00
|
|
|
output_filename( var_cflags );
|
2022-10-26 02:03:20 -07:00
|
|
|
output( "\n" );
|
|
|
|
|
2023-08-11 01:15:22 -07:00
|
|
|
if (make->testdll && strendswith( source->name, ".c" ) &&
|
|
|
|
!(source->file->flags & (FLAG_GENERATED | FLAG_TESTDLL)))
|
2022-01-19 08:18:33 -07:00
|
|
|
{
|
2022-10-26 02:03:20 -07:00
|
|
|
const char *ok_file, *test_exe;
|
|
|
|
|
2022-10-26 02:04:43 -07:00
|
|
|
ok_file = strmake( "%s%s.ok", arch_dirs[arch], obj );
|
2022-10-26 02:03:20 -07:00
|
|
|
test_exe = replace_extension( make->testdll, ".dll", "_test.exe" );
|
2023-03-01 06:25:40 -07:00
|
|
|
strarray_add( &make->ok_files[arch], ok_file );
|
2022-10-26 02:03:20 -07:00
|
|
|
output( "%s:\n", obj_dir_path( make, ok_file ));
|
2022-10-26 02:03:42 -07:00
|
|
|
output( "\t%s%s $(RUNTESTFLAGS) -T . -M %s -p %s %s && touch $@\n",
|
2022-01-19 08:18:33 -07:00
|
|
|
cmd_prefix( "TEST" ),
|
|
|
|
root_src_dir_path( "tools/runtest" ), make->testdll,
|
2022-10-26 02:03:42 -07:00
|
|
|
obj_dir_path( make, arch_module_name( test_exe, arch )), obj );
|
2022-10-26 02:03:20 -07:00
|
|
|
}
|
2024-06-26 01:37:46 -07:00
|
|
|
|
2024-10-07 03:44:05 -07:00
|
|
|
if (source->file->flags & FLAG_GENERATED) return;
|
|
|
|
|
|
|
|
/* static analysis rules */
|
|
|
|
|
|
|
|
if (sarif_converter && make->module && !make->extlib)
|
2024-06-26 01:37:46 -07:00
|
|
|
{
|
2024-10-07 03:44:05 -07:00
|
|
|
const char *sast_name = strmake( "%s%s.sarif", source->arch ? "" : arch_dirs[arch], obj );
|
|
|
|
output( "%s: %s\n", obj_dir_path( make, sast_name ), source->filename );
|
|
|
|
output( "\t%s%s -o $@ %s", cmd_prefix( "SAST" ), var_cc, source->filename );
|
|
|
|
output_filenames( defines );
|
|
|
|
output_filenames( cflags );
|
|
|
|
output_filename( "--analyze" );
|
|
|
|
output_filename( "-Xclang" );
|
|
|
|
output_filename( "-analyzer-output=sarif" );
|
|
|
|
output_filename( "$(SASTFLAGS)" );
|
|
|
|
output( "\n" );
|
|
|
|
strarray_add( &make->sast_files, sast_name );
|
|
|
|
strarray_add( targets, sast_name );
|
|
|
|
}
|
2024-06-26 01:37:46 -07:00
|
|
|
|
2024-10-07 03:44:05 -07:00
|
|
|
/* compile commands */
|
2024-06-26 01:37:46 -07:00
|
|
|
|
2024-10-07 03:44:05 -07:00
|
|
|
cmd = xmalloc( sizeof(*cmd) );
|
|
|
|
cmd->source = source->filename;
|
|
|
|
cmd->obj = obj_dir_path( make, obj_name );
|
|
|
|
cmd->args = empty_strarray;
|
|
|
|
strarray_addall( &cmd->args, defines );
|
|
|
|
strarray_addall( &cmd->args, cflags );
|
|
|
|
|
|
|
|
if ((source->file->flags & FLAG_ARM64EC_X64) && !strcmp( archs.str[arch], "arm64ec" ))
|
|
|
|
{
|
|
|
|
char *cflags = get_expanded_make_variable( make, "x86_64_CFLAGS" );
|
|
|
|
cmd->cmd = get_expanded_make_variable( make, "x86_64_CC" );
|
|
|
|
if (cflags) strarray_add( &cmd->args, cflags );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char *cflags = get_expanded_arch_var( make, "CFLAGS", arch );
|
|
|
|
cmd->cmd = get_expanded_arch_var( make, "CC", arch );
|
|
|
|
if (cflags) strarray_add( &cmd->args, cflags );
|
2024-06-26 01:37:46 -07:00
|
|
|
}
|
2024-10-07 03:44:05 -07:00
|
|
|
list_add_tail( &compile_commands, &cmd->entry );
|
2022-10-26 02:03:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output_source_default
|
|
|
|
*/
|
|
|
|
static void output_source_default( struct makefile *make, struct incl_file *source, const char *obj )
|
|
|
|
{
|
|
|
|
struct strarray defines = get_source_defines( make, source, obj );
|
|
|
|
struct strarray targets = empty_strarray;
|
|
|
|
unsigned int arch;
|
|
|
|
|
|
|
|
for (arch = 0; arch < archs.count; arch++)
|
|
|
|
if (!source->arch || source->arch == arch)
|
2023-08-11 01:15:22 -07:00
|
|
|
output_source_one_arch( make, source, obj, defines, &targets, arch );
|
2022-10-26 02:03:20 -07:00
|
|
|
|
|
|
|
if (source->file->flags & FLAG_GENERATED)
|
|
|
|
{
|
|
|
|
if (!make->testdll || !strendswith( source->filename, "testlist.c" ))
|
|
|
|
strarray_add( &make->clean_files, source->basename );
|
|
|
|
}
|
2023-08-11 01:15:22 -07:00
|
|
|
else if (source->file->flags & FLAG_TESTDLL)
|
|
|
|
{
|
|
|
|
output_source_testdll( make, source, obj );
|
|
|
|
}
|
2022-10-26 02:03:20 -07:00
|
|
|
else
|
|
|
|
{
|
2023-08-11 01:15:22 -07:00
|
|
|
if (make->testdll && strendswith( source->name, ".c" ))
|
2022-10-26 02:03:20 -07:00
|
|
|
strarray_add( &make->test_files, obj );
|
1997-09-28 10:43:24 -07:00
|
|
|
}
|
2022-10-26 02:03:20 -07:00
|
|
|
|
2023-04-21 00:54:37 -07:00
|
|
|
if (targets.count && source->dependencies.count)
|
|
|
|
{
|
|
|
|
output_filenames_obj_dir( make, targets );
|
|
|
|
output( ":" );
|
|
|
|
output_filenames( source->dependencies );
|
|
|
|
output( "\n" );
|
|
|
|
}
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* dispatch table to output rules for a single source file */
|
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
const char *ext;
|
|
|
|
void (*fn)( struct makefile *make, struct incl_file *source, const char *obj );
|
|
|
|
} output_source_funcs[] =
|
|
|
|
{
|
|
|
|
{ "y", output_source_y },
|
|
|
|
{ "l", output_source_l },
|
|
|
|
{ "h", output_source_h },
|
|
|
|
{ "rh", output_source_h },
|
|
|
|
{ "inl", output_source_h },
|
|
|
|
{ "rc", output_source_rc },
|
|
|
|
{ "mc", output_source_mc },
|
|
|
|
{ "res", output_source_res },
|
|
|
|
{ "idl", output_source_idl },
|
|
|
|
{ "sfd", output_source_sfd },
|
|
|
|
{ "svg", output_source_svg },
|
2018-02-19 12:57:15 -07:00
|
|
|
{ "nls", output_source_nls },
|
|
|
|
{ "desktop", output_source_desktop },
|
2018-02-17 01:53:42 -07:00
|
|
|
{ "po", output_source_po },
|
|
|
|
{ "in", output_source_in },
|
|
|
|
{ "x", output_source_x },
|
2018-02-17 03:46:25 -07:00
|
|
|
{ "spec", output_source_spec },
|
2021-09-02 04:04:43 -07:00
|
|
|
{ "xml", output_source_xml },
|
2018-02-17 01:53:42 -07:00
|
|
|
{ NULL, output_source_default }
|
|
|
|
};
|
2013-10-14 11:18:18 -07:00
|
|
|
|
|
|
|
|
2022-11-02 03:26:22 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_fake_module
|
|
|
|
*/
|
2023-09-05 04:21:42 -07:00
|
|
|
static void output_fake_module( struct makefile *make, const char *spec_file )
|
2022-11-02 03:26:22 -07:00
|
|
|
{
|
|
|
|
unsigned int arch = 0; /* fake modules are always native */
|
2023-09-05 04:21:42 -07:00
|
|
|
const char *name = strmake( "%s%s", arch_pe_dirs[arch], make->module );
|
2022-11-02 03:26:22 -07:00
|
|
|
|
2023-01-27 05:08:04 -07:00
|
|
|
if (make->disabled[arch]) return;
|
|
|
|
|
2022-11-02 03:26:22 -07:00
|
|
|
strarray_add( &make->all_targets[arch], name );
|
2024-06-24 04:57:34 -07:00
|
|
|
add_install_rule( make, make->module, arch, name, strmake( "d$(libdir)/wine/%s", name ));
|
2022-11-02 03:26:22 -07:00
|
|
|
|
|
|
|
output( "%s:", obj_dir_path( make, name ));
|
|
|
|
if (spec_file) output_filename( spec_file );
|
|
|
|
output_filenames_obj_dir( make, make->res_files[arch] );
|
|
|
|
output_filename( tools_path( make, "winebuild" ));
|
|
|
|
output_filename( tools_path( make, "winegcc" ));
|
|
|
|
output( "\n" );
|
|
|
|
output_winegcc_command( make, arch );
|
|
|
|
output_filename( "-Wb,--fake-module" );
|
2023-09-05 04:21:42 -07:00
|
|
|
if (!make->is_exe) output_filename( "-shared" );
|
|
|
|
if (spec_file) output_filename( spec_file );
|
2022-11-02 03:26:22 -07:00
|
|
|
output_filenames( make->extradllflags );
|
|
|
|
output_filenames_obj_dir( make, make->res_files[arch] );
|
|
|
|
output( "\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-17 01:53:42 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_module
|
|
|
|
*/
|
2022-10-24 02:40:56 -07:00
|
|
|
static void output_module( struct makefile *make, unsigned int arch )
|
2018-02-17 01:53:42 -07:00
|
|
|
{
|
2022-09-29 11:04:44 -07:00
|
|
|
struct strarray default_imports = empty_strarray;
|
2018-02-17 01:53:42 -07:00
|
|
|
struct strarray all_libs = empty_strarray;
|
|
|
|
struct strarray dep_libs = empty_strarray;
|
2021-11-17 06:30:05 -07:00
|
|
|
struct strarray imports = make->imports;
|
2022-10-26 02:04:43 -07:00
|
|
|
const char *module_name;
|
2021-11-23 07:05:48 -07:00
|
|
|
const char *debug_file;
|
2018-02-17 01:53:42 -07:00
|
|
|
char *spec_file = NULL;
|
2024-04-08 15:00:24 -07:00
|
|
|
unsigned int i, link_arch;
|
2013-12-30 12:08:13 -07:00
|
|
|
|
2023-09-05 04:07:18 -07:00
|
|
|
if (!make->is_exe)
|
|
|
|
{
|
2023-09-05 04:21:42 -07:00
|
|
|
if (make->data_only || strarray_exists( &make->extradllflags, "-Wl,--subsystem,native" ))
|
2023-09-05 04:07:18 -07:00
|
|
|
{
|
|
|
|
/* spec file is optional */
|
|
|
|
struct incl_file *spec = find_src_file( make, replace_extension( make->module, ".dll", ".spec" ));
|
|
|
|
if (spec) spec_file = spec->filename;
|
|
|
|
}
|
|
|
|
else spec_file = src_dir_path( make, replace_extension( make->module, ".dll", ".spec" ));
|
|
|
|
}
|
2021-11-17 06:30:05 -07:00
|
|
|
|
2022-02-16 08:10:08 -07:00
|
|
|
if (!make->data_only)
|
2021-11-23 06:40:04 -07:00
|
|
|
{
|
2024-06-11 01:38:44 -07:00
|
|
|
if (!get_link_arch( make, arch, &link_arch )) return;
|
|
|
|
|
2022-10-26 02:03:42 -07:00
|
|
|
module_name = arch_module_name( make->module, arch );
|
2021-11-23 06:40:04 -07:00
|
|
|
|
2022-09-29 11:04:44 -07:00
|
|
|
if (!strarray_exists( &make->extradllflags, "-nodefaultlibs" )) default_imports = get_default_imports( make, imports );
|
2022-02-16 08:10:08 -07:00
|
|
|
|
2022-10-24 02:40:56 -07:00
|
|
|
strarray_addall( &all_libs, add_import_libs( make, &dep_libs, imports, IMPORT_TYPE_DIRECT, arch ));
|
|
|
|
strarray_addall( &all_libs, add_import_libs( make, &dep_libs, make->delayimports, IMPORT_TYPE_DELAYED, arch ));
|
|
|
|
strarray_addall( &all_libs, add_import_libs( make, &dep_libs, default_imports, IMPORT_TYPE_DEFAULT, arch ) );
|
2022-12-08 02:53:24 -07:00
|
|
|
if (!arch) strarray_addall( &all_libs, libs );
|
2022-02-16 08:10:08 -07:00
|
|
|
|
2022-10-24 03:12:51 -07:00
|
|
|
if (delay_load_flags[arch])
|
2022-02-16 08:10:08 -07:00
|
|
|
{
|
|
|
|
for (i = 0; i < make->delayimports.count; i++)
|
2022-11-23 09:50:43 -07:00
|
|
|
{
|
|
|
|
struct makefile *import = get_static_lib( make->delayimports.str[i], arch );
|
|
|
|
if (import) strarray_add( &all_libs, strmake( "%s%s", delay_load_flags[arch], import->module ));
|
|
|
|
}
|
2022-02-16 08:10:08 -07:00
|
|
|
}
|
2020-05-14 05:03:40 -07:00
|
|
|
}
|
2024-06-11 01:38:44 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (native_archs[arch]) return;
|
|
|
|
if (make->disabled[arch]) return;
|
|
|
|
link_arch = arch;
|
|
|
|
|
|
|
|
module_name = strmake( "%s%s", arch_pe_dirs[arch], make->module );
|
|
|
|
}
|
2021-11-23 07:05:48 -07:00
|
|
|
|
2024-06-11 01:38:44 -07:00
|
|
|
strarray_add( &make->all_targets[link_arch], module_name );
|
2022-02-16 08:10:08 -07:00
|
|
|
if (make->data_only)
|
2024-06-11 01:38:44 -07:00
|
|
|
add_install_rule( make, make->module, link_arch, module_name,
|
2024-06-24 04:57:34 -07:00
|
|
|
strmake( "d$(libdir)/wine/%s%s", arch_pe_dirs[arch], make->module ));
|
2018-02-17 01:53:42 -07:00
|
|
|
else
|
2024-06-11 01:38:44 -07:00
|
|
|
add_install_rule( make, make->module, link_arch, module_name,
|
2022-10-26 02:04:43 -07:00
|
|
|
strmake( "%c%s%s%s", '0' + arch, arch_install_dirs[arch], make->module,
|
2023-06-15 01:27:06 -07:00
|
|
|
dll_ext[arch] ));
|
2019-04-22 02:51:04 -07:00
|
|
|
|
2021-11-23 07:05:48 -07:00
|
|
|
output( "%s:", obj_dir_path( make, module_name ));
|
2018-02-17 01:53:42 -07:00
|
|
|
if (spec_file) output_filename( spec_file );
|
2022-10-25 02:04:30 -07:00
|
|
|
output_filenames_obj_dir( make, make->object_files[arch] );
|
2024-04-08 15:00:24 -07:00
|
|
|
if (link_arch != arch) output_filenames_obj_dir( make, make->object_files[link_arch] );
|
2022-10-25 02:09:57 -07:00
|
|
|
output_filenames_obj_dir( make, make->res_files[arch] );
|
2018-02-17 01:53:42 -07:00
|
|
|
output_filenames( dep_libs );
|
|
|
|
output_filename( tools_path( make, "winebuild" ));
|
|
|
|
output_filename( tools_path( make, "winegcc" ));
|
|
|
|
output( "\n" );
|
2024-04-08 15:00:24 -07:00
|
|
|
output_winegcc_command( make, link_arch );
|
2022-10-24 02:40:56 -07:00
|
|
|
if (arch) output_filename( "-Wl,--wine-builtin" );
|
2023-09-05 04:07:18 -07:00
|
|
|
if (!make->is_exe) output_filename( "-shared" );
|
|
|
|
if (spec_file) output_filename( spec_file );
|
2019-04-09 01:13:37 -07:00
|
|
|
output_filenames( make->extradllflags );
|
2024-04-08 15:00:24 -07:00
|
|
|
if (link_arch) output_filenames( get_expanded_arch_var_array( make, "EXTRADLLFLAGS", link_arch ));
|
2022-10-25 02:04:30 -07:00
|
|
|
output_filenames_obj_dir( make, make->object_files[arch] );
|
2024-04-08 15:00:24 -07:00
|
|
|
if (link_arch != arch) output_filenames_obj_dir( make, make->object_files[link_arch] );
|
2022-10-25 02:09:57 -07:00
|
|
|
output_filenames_obj_dir( make, make->res_files[arch] );
|
2024-04-08 15:00:24 -07:00
|
|
|
debug_file = get_debug_file( make, module_name, link_arch );
|
2020-11-19 10:43:36 -07:00
|
|
|
if (debug_file) output_filename( strmake( "-Wl,--debug-file,%s", obj_dir_path( make, debug_file )));
|
2018-02-17 01:53:42 -07:00
|
|
|
output_filenames( all_libs );
|
2024-04-08 15:00:24 -07:00
|
|
|
output_filename( arch_make_variable( "LDFLAGS", link_arch ));
|
2018-02-17 01:53:42 -07:00
|
|
|
output( "\n" );
|
2021-08-11 03:26:48 -07:00
|
|
|
|
2023-09-05 04:21:42 -07:00
|
|
|
if (!make->data_only && !arch && unix_lib_supported) output_fake_module( make, spec_file );
|
2021-11-18 11:21:12 -07:00
|
|
|
}
|
2020-05-14 05:03:40 -07:00
|
|
|
|
2021-11-18 11:21:12 -07:00
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output_import_lib
|
|
|
|
*/
|
2022-10-24 02:40:56 -07:00
|
|
|
static void output_import_lib( struct makefile *make, unsigned int arch )
|
2021-11-18 11:21:12 -07:00
|
|
|
{
|
|
|
|
char *spec_file = src_dir_path( make, replace_extension( make->module, ".dll", ".spec" ));
|
2022-10-26 02:04:43 -07:00
|
|
|
const char *name = strmake( "%slib%s.a", arch_dirs[arch], make->importlib );
|
2024-04-08 15:00:24 -07:00
|
|
|
unsigned int hybrid_arch = hybrid_archs[arch];
|
|
|
|
|
|
|
|
if (native_archs[arch]) return;
|
2021-11-16 08:57:04 -07:00
|
|
|
|
2022-10-26 02:04:43 -07:00
|
|
|
strarray_add( &make->clean_files, name );
|
2022-10-24 03:12:51 -07:00
|
|
|
if (needs_delay_lib( make, arch ))
|
2021-11-19 09:07:55 -07:00
|
|
|
{
|
2022-10-26 02:04:43 -07:00
|
|
|
const char *delay_name = replace_extension( name, ".a", ".delay.a" );
|
|
|
|
strarray_add( &make->clean_files, delay_name );
|
|
|
|
output( "%s ", obj_dir_path( make, delay_name ));
|
2021-11-19 09:07:55 -07:00
|
|
|
}
|
2022-10-26 02:04:43 -07:00
|
|
|
output( "%s: %s %s", obj_dir_path( make, name ), tools_path( make, "winebuild" ), spec_file );
|
2022-10-25 02:07:45 -07:00
|
|
|
output_filenames_obj_dir( make, make->implib_files[arch] );
|
2024-04-08 15:00:24 -07:00
|
|
|
if (hybrid_arch) output_filenames_obj_dir( make, make->implib_files[hybrid_arch] );
|
2021-11-19 09:07:55 -07:00
|
|
|
output( "\n" );
|
|
|
|
output( "\t%s%s -w --implib -o $@", cmd_prefix( "BUILD" ), tools_path( make, "winebuild" ) );
|
2022-11-02 06:21:14 -07:00
|
|
|
if (!delay_load_flags[arch]) output_filename( "--without-dlltool" );
|
2024-04-08 15:00:24 -07:00
|
|
|
output_filenames( target_flags[hybrid_arch ? hybrid_arch : arch] );
|
2021-11-19 09:07:55 -07:00
|
|
|
if (make->is_win16) output_filename( "-m16" );
|
2024-04-08 15:00:24 -07:00
|
|
|
if (hybrid_arch) output_filenames( hybrid_target_flags[hybrid_arch] );
|
2021-11-19 09:07:55 -07:00
|
|
|
output_filename( "--export" );
|
|
|
|
output_filename( spec_file );
|
2022-10-25 02:07:45 -07:00
|
|
|
output_filenames_obj_dir( make, make->implib_files[arch] );
|
2024-04-08 15:00:24 -07:00
|
|
|
if (hybrid_arch) output_filenames_obj_dir( make, make->implib_files[hybrid_arch] );
|
2021-11-19 09:07:55 -07:00
|
|
|
output( "\n" );
|
2022-10-26 02:03:51 -07:00
|
|
|
|
2022-10-26 02:04:43 -07:00
|
|
|
add_install_rule( make, make->importlib, arch, name,
|
2022-10-25 02:03:54 -07:00
|
|
|
strmake( "d%slib%s.a", arch_install_dirs[arch], make->importlib ));
|
2021-11-19 09:07:55 -07:00
|
|
|
}
|
2021-11-16 08:57:04 -07:00
|
|
|
|
2021-04-26 07:40:00 -07:00
|
|
|
|
2021-11-18 11:21:12 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_unix_lib
|
|
|
|
*/
|
|
|
|
static void output_unix_lib( struct makefile *make )
|
|
|
|
{
|
|
|
|
struct strarray unix_deps = empty_strarray;
|
2022-11-11 04:05:04 -07:00
|
|
|
struct strarray unix_libs = add_unix_libraries( make, &unix_deps );
|
2022-10-25 02:03:54 -07:00
|
|
|
unsigned int arch = 0; /* unix libs are always native */
|
2013-12-30 12:23:16 -07:00
|
|
|
|
2023-01-27 05:08:04 -07:00
|
|
|
if (make->disabled[arch]) return;
|
|
|
|
|
2022-10-25 02:08:06 -07:00
|
|
|
strarray_add( &make->all_targets[arch], make->unixlib );
|
2022-10-26 02:03:51 -07:00
|
|
|
add_install_rule( make, make->module, arch, make->unixlib,
|
2022-10-25 02:03:54 -07:00
|
|
|
strmake( "p%s%s", arch_install_dirs[arch], make->unixlib ));
|
2021-11-18 11:21:12 -07:00
|
|
|
output( "%s:", obj_dir_path( make, make->unixlib ));
|
|
|
|
output_filenames_obj_dir( make, make->unixobj_files );
|
|
|
|
output_filenames( unix_deps );
|
2022-11-11 04:05:04 -07:00
|
|
|
output( "\n" );
|
|
|
|
output( "\t%s$(CC) -o $@", cmd_prefix( "CCLD" ));
|
|
|
|
output_filenames( get_expanded_make_var_array( make, "UNIXLDFLAGS" ));
|
2021-11-18 11:21:12 -07:00
|
|
|
output_filenames_obj_dir( make, make->unixobj_files );
|
|
|
|
output_filenames( unix_libs );
|
|
|
|
output_filename( "$(LDFLAGS)" );
|
|
|
|
output( "\n" );
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
|
|
|
|
2013-12-30 12:08:13 -07:00
|
|
|
|
2018-02-17 01:53:42 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_static_lib
|
|
|
|
*/
|
2022-10-24 02:40:56 -07:00
|
|
|
static void output_static_lib( struct makefile *make, unsigned int arch )
|
2018-02-17 01:53:42 -07:00
|
|
|
{
|
2022-10-26 02:04:43 -07:00
|
|
|
const char *name = strmake( "%s%s", arch_dirs[arch], make->staticlib );
|
2024-04-08 15:00:24 -07:00
|
|
|
unsigned int hybrid_arch = hybrid_archs[arch];
|
|
|
|
|
|
|
|
if (native_archs[arch]) return;
|
2018-02-17 01:53:42 -07:00
|
|
|
|
2022-10-24 02:40:56 -07:00
|
|
|
strarray_add( &make->clean_files, name );
|
|
|
|
output( "%s: %s", obj_dir_path( make, name ), tools_path( make, "winebuild" ));
|
2022-10-25 02:04:30 -07:00
|
|
|
output_filenames_obj_dir( make, make->object_files[arch] );
|
2024-04-08 15:00:24 -07:00
|
|
|
if (hybrid_arch) output_filenames_obj_dir( make, make->object_files[hybrid_arch] );
|
2022-10-24 02:40:56 -07:00
|
|
|
if (!arch) output_filenames_obj_dir( make, make->unixobj_files );
|
|
|
|
output( "\n" );
|
|
|
|
output( "\t%s%s -w --staticlib -o $@", cmd_prefix( "BUILD" ), tools_path( make, "winebuild" ));
|
2024-04-08 15:00:24 -07:00
|
|
|
output_filenames( target_flags[hybrid_arch ? hybrid_arch : arch] );
|
2022-10-25 02:04:30 -07:00
|
|
|
output_filenames_obj_dir( make, make->object_files[arch] );
|
2024-04-08 15:00:24 -07:00
|
|
|
if (hybrid_arch) output_filenames_obj_dir( make, make->object_files[hybrid_arch] );
|
2022-10-24 02:40:56 -07:00
|
|
|
if (!arch) output_filenames_obj_dir( make, make->unixobj_files );
|
|
|
|
output( "\n" );
|
|
|
|
if (!make->extlib)
|
2022-10-26 02:03:51 -07:00
|
|
|
add_install_rule( make, make->staticlib, arch, name,
|
2022-10-25 02:03:54 -07:00
|
|
|
strmake( "d%s%s", arch_install_dirs[arch], make->staticlib ));
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
2013-12-30 12:17:36 -07:00
|
|
|
|
2015-11-12 06:08:03 -07:00
|
|
|
|
2018-02-17 01:53:42 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_test_module
|
|
|
|
*/
|
2022-10-24 02:40:56 -07:00
|
|
|
static void output_test_module( struct makefile *make, unsigned int arch )
|
2018-02-17 01:53:42 -07:00
|
|
|
{
|
2022-10-26 02:03:42 -07:00
|
|
|
char *basemodule = replace_extension( make->testdll, ".dll", "" );
|
|
|
|
char *stripped = arch_module_name( strmake( "%s_test-stripped.exe", basemodule ), arch );
|
|
|
|
char *testmodule = arch_module_name( strmake( "%s_test.exe", basemodule ), arch );
|
2022-09-29 11:04:44 -07:00
|
|
|
struct strarray default_imports = get_default_imports( make, make->imports );
|
2022-10-26 02:03:42 -07:00
|
|
|
struct strarray dep_libs = empty_strarray;
|
|
|
|
struct strarray all_libs = empty_strarray;
|
2019-04-22 02:51:04 -07:00
|
|
|
struct makefile *parent = get_parent_makefile( make );
|
2020-05-14 07:40:21 -07:00
|
|
|
const char *debug_file;
|
2024-04-08 15:00:24 -07:00
|
|
|
unsigned int link_arch;
|
|
|
|
|
|
|
|
if (!get_link_arch( make, arch, &link_arch )) return;
|
2018-02-17 01:53:42 -07:00
|
|
|
|
2022-10-24 02:40:56 -07:00
|
|
|
strarray_addall( &all_libs, add_import_libs( make, &dep_libs, make->imports, IMPORT_TYPE_DIRECT, arch ) );
|
|
|
|
strarray_addall( &all_libs, add_import_libs( make, &dep_libs, default_imports, IMPORT_TYPE_DEFAULT, arch ) );
|
2022-09-29 11:04:44 -07:00
|
|
|
|
2022-10-26 02:03:42 -07:00
|
|
|
strarray_add( &make->all_targets[arch], testmodule );
|
|
|
|
strarray_add( &make->clean_files, stripped );
|
|
|
|
output( "%s:\n", obj_dir_path( make, testmodule ));
|
2024-04-08 15:00:24 -07:00
|
|
|
output_winegcc_command( make, link_arch );
|
2019-04-09 01:13:37 -07:00
|
|
|
output_filenames( make->extradllflags );
|
2022-10-25 02:04:30 -07:00
|
|
|
output_filenames_obj_dir( make, make->object_files[arch] );
|
2024-04-08 15:00:24 -07:00
|
|
|
if (link_arch != arch) output_filenames_obj_dir( make, make->object_files[link_arch] );
|
2022-10-25 02:09:57 -07:00
|
|
|
output_filenames_obj_dir( make, make->res_files[arch] );
|
2022-10-24 02:40:56 -07:00
|
|
|
if ((debug_file = get_debug_file( make, testmodule, arch )))
|
2020-11-19 10:43:36 -07:00
|
|
|
output_filename( strmake( "-Wl,--debug-file,%s", obj_dir_path( make, debug_file )));
|
2018-02-17 01:53:42 -07:00
|
|
|
output_filenames( all_libs );
|
2024-04-08 15:00:24 -07:00
|
|
|
output_filename( arch_make_variable( "LDFLAGS", link_arch ));
|
2018-02-17 01:53:42 -07:00
|
|
|
output( "\n" );
|
2022-10-26 02:03:42 -07:00
|
|
|
output( "%s:\n", obj_dir_path( make, stripped ));
|
2024-04-08 15:00:24 -07:00
|
|
|
output_winegcc_command( make, link_arch );
|
2019-04-09 00:34:05 -07:00
|
|
|
output_filename( "-s" );
|
2022-10-26 02:03:42 -07:00
|
|
|
output_filename( strmake( "-Wb,-F,%s_test.exe", basemodule ));
|
2019-04-09 01:13:37 -07:00
|
|
|
output_filenames( make->extradllflags );
|
2022-10-25 02:04:30 -07:00
|
|
|
output_filenames_obj_dir( make, make->object_files[arch] );
|
2024-04-08 15:00:24 -07:00
|
|
|
if (link_arch != arch) output_filenames_obj_dir( make, make->object_files[link_arch] );
|
2022-10-25 02:09:57 -07:00
|
|
|
output_filenames_obj_dir( make, make->res_files[arch] );
|
2018-02-17 01:53:42 -07:00
|
|
|
output_filenames( all_libs );
|
2024-04-08 15:00:24 -07:00
|
|
|
output_filename( arch_make_variable( "LDFLAGS", link_arch ));
|
2018-02-17 01:53:42 -07:00
|
|
|
output( "\n" );
|
2022-10-26 02:03:42 -07:00
|
|
|
output( "%s %s:", obj_dir_path( make, testmodule ), obj_dir_path( make, stripped ));
|
2022-10-25 02:04:30 -07:00
|
|
|
output_filenames_obj_dir( make, make->object_files[arch] );
|
2024-04-08 15:00:24 -07:00
|
|
|
if (link_arch != arch) output_filenames_obj_dir( make, make->object_files[link_arch] );
|
2022-10-25 02:09:57 -07:00
|
|
|
output_filenames_obj_dir( make, make->res_files[arch] );
|
2018-02-17 01:53:42 -07:00
|
|
|
output_filenames( dep_libs );
|
|
|
|
output_filename( tools_path( make, "winebuild" ));
|
|
|
|
output_filename( tools_path( make, "winegcc" ));
|
|
|
|
output( "\n" );
|
|
|
|
|
2022-10-26 02:04:43 -07:00
|
|
|
output( "programs/winetest/%s%s_test.res: %s\n", arch_dirs[arch], basemodule,
|
|
|
|
obj_dir_path( make, stripped ));
|
2022-10-26 02:03:42 -07:00
|
|
|
output( "\t%secho \"%s_test.exe TESTRES \\\"%s\\\"\" | %s -u -o $@\n", cmd_prefix( "WRC" ),
|
|
|
|
basemodule, obj_dir_path( make, stripped ), tools_path( make, "wrc" ));
|
2013-12-30 12:19:33 -07:00
|
|
|
|
2023-02-22 13:04:35 -07:00
|
|
|
if (make->disabled[arch] || (parent && parent->disabled[arch]))
|
|
|
|
{
|
2023-03-01 06:25:40 -07:00
|
|
|
make->ok_files[arch] = empty_strarray;
|
2023-02-22 13:04:35 -07:00
|
|
|
return;
|
|
|
|
}
|
2023-03-01 06:25:40 -07:00
|
|
|
output_filenames_obj_dir( make, make->ok_files[arch] );
|
2022-10-26 02:03:42 -07:00
|
|
|
output( ": %s", obj_dir_path( make, testmodule ));
|
2020-12-18 06:19:48 -07:00
|
|
|
if (parent)
|
|
|
|
{
|
2022-11-22 07:34:48 -07:00
|
|
|
char *parent_module = arch_module_name( make->testdll, arch );
|
2022-10-26 02:03:42 -07:00
|
|
|
output_filename( obj_dir_path( parent, parent_module ));
|
2021-09-20 06:29:17 -07:00
|
|
|
if (parent->unixlib) output_filename( obj_dir_path( parent, parent->unixlib ));
|
2020-12-18 06:19:48 -07:00
|
|
|
}
|
2020-09-12 02:40:00 -07:00
|
|
|
output( "\n" );
|
2020-09-09 02:47:29 -07:00
|
|
|
output( "%s %s:", obj_dir_path( make, "check" ), obj_dir_path( make, "test" ));
|
2023-03-01 06:25:40 -07:00
|
|
|
output_filenames_obj_dir( make, make->ok_files[arch] );
|
2018-05-28 12:42:02 -07:00
|
|
|
output( "\n" );
|
2020-09-09 02:47:29 -07:00
|
|
|
strarray_add_uniq( &make->phony_targets, obj_dir_path( make, "check" ));
|
|
|
|
strarray_add_uniq( &make->phony_targets, obj_dir_path( make, "test" ));
|
|
|
|
output( "%s::\n", obj_dir_path( make, "testclean" ));
|
2018-02-17 01:53:42 -07:00
|
|
|
output( "\trm -f" );
|
2023-03-01 06:25:40 -07:00
|
|
|
output_filenames_obj_dir( make, make->ok_files[arch] );
|
2018-02-17 01:53:42 -07:00
|
|
|
output( "\n" );
|
2023-03-01 06:25:40 -07:00
|
|
|
strarray_addall( &make->clean_files, make->ok_files[arch] );
|
2020-09-09 02:47:29 -07:00
|
|
|
strarray_add_uniq( &make->phony_targets, obj_dir_path( make, "testclean" ));
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output_programs
|
|
|
|
*/
|
|
|
|
static void output_programs( struct makefile *make )
|
|
|
|
{
|
|
|
|
unsigned int i, j;
|
2022-10-25 02:04:30 -07:00
|
|
|
unsigned int arch = 0; /* programs are always native */
|
2013-11-09 10:57:00 -07:00
|
|
|
|
2015-10-26 20:13:26 -07:00
|
|
|
for (i = 0; i < make->programs.count; i++)
|
|
|
|
{
|
2015-10-28 22:32:45 -07:00
|
|
|
char *program_installed = NULL;
|
2015-10-26 20:13:26 -07:00
|
|
|
char *program = strmake( "%s%s", make->programs.str[i], exe_ext );
|
2018-02-17 01:53:42 -07:00
|
|
|
struct strarray deps = get_local_dependencies( make, make->programs.str[i], make->in_files );
|
2016-02-22 23:03:50 -07: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-26 20:13:26 -07:00
|
|
|
|
2022-10-25 02:04:30 -07:00
|
|
|
if (!objs.count) objs = make->object_files[arch];
|
2020-04-07 11:55:04 -07:00
|
|
|
if (!strarray_exists( &all_libs, "-nodefaultlibs" ))
|
2021-11-22 10:32:35 -07:00
|
|
|
{
|
2022-06-29 02:06:16 -07:00
|
|
|
strarray_addall( &all_libs, get_expanded_make_var_array( make, "UNIX_LIBS" ));
|
2021-11-22 10:32:35 -07:00
|
|
|
strarray_addall( &all_libs, libs );
|
|
|
|
}
|
2016-02-22 22:57:11 -07:00
|
|
|
|
2015-10-26 20:13:26 -07:00
|
|
|
output( "%s:", obj_dir_path( make, program ) );
|
|
|
|
output_filenames_obj_dir( make, objs );
|
2015-11-12 22:17:18 -07:00
|
|
|
output_filenames( deps );
|
2015-10-26 20:13:26 -07:00
|
|
|
output( "\n" );
|
2022-02-16 08:10:08 -07:00
|
|
|
output( "\t%s$(CC) -o $@", cmd_prefix( "CCLD" ));
|
2015-10-26 20:13:26 -07:00
|
|
|
output_filenames_obj_dir( make, objs );
|
|
|
|
output_filenames( all_libs );
|
|
|
|
output_filename( "$(LDFLAGS)" );
|
|
|
|
output( "\n" );
|
2022-10-25 02:08:06 -07:00
|
|
|
strarray_add( &make->all_targets[arch], program );
|
2015-10-28 22:32:45 -07:00
|
|
|
|
2016-05-05 21:54:13 -07:00
|
|
|
for (j = 0; j < symlinks.count; j++)
|
2015-10-29 02:06:35 -07:00
|
|
|
{
|
2016-05-05 21:54:13 -07:00
|
|
|
output( "%s: %s\n", obj_dir_path( make, symlinks.str[j] ), obj_dir_path( make, program ));
|
2020-10-23 03:41:12 -07:00
|
|
|
output_symlink_rule( program, obj_dir_path( make, symlinks.str[j] ), 0 );
|
2015-10-29 02:06:35 -07:00
|
|
|
}
|
2022-10-25 02:08:06 -07:00
|
|
|
strarray_addall( &make->all_targets[arch], symlinks );
|
2015-10-29 02:06:35 -07:00
|
|
|
|
2022-10-26 02:03:51 -07:00
|
|
|
add_install_rule( make, program, arch, program_installed ? program_installed : program,
|
2015-10-28 22:32:45 -07:00
|
|
|
strmake( "p$(bindir)/%s", program ));
|
2015-10-29 02:06:35 -07:00
|
|
|
for (j = 0; j < symlinks.count; j++)
|
2022-10-26 02:03:51 -07:00
|
|
|
add_install_rule( make, symlinks.str[j], arch, program,
|
2015-10-29 02:06:35 -07:00
|
|
|
strmake( "y$(bindir)/%s%s", symlinks.str[j], exe_ext ));
|
2015-10-26 20:13:26 -07:00
|
|
|
}
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output_subdirs
|
|
|
|
*/
|
|
|
|
static void output_subdirs( struct makefile *make )
|
|
|
|
{
|
2020-09-12 02:40:00 -07:00
|
|
|
struct strarray all_targets = empty_strarray;
|
2018-02-17 01:53:42 -07:00
|
|
|
struct strarray makefile_deps = empty_strarray;
|
2018-02-19 13:24:59 -07:00
|
|
|
struct strarray clean_files = empty_strarray;
|
2024-10-07 03:44:05 -07:00
|
|
|
struct strarray sast_files = empty_strarray;
|
2018-02-19 13:10:14 -07:00
|
|
|
struct strarray testclean_files = empty_strarray;
|
2018-02-21 04:29:06 -07:00
|
|
|
struct strarray distclean_files = empty_strarray;
|
2022-10-31 04:30:07 -07:00
|
|
|
struct strarray distclean_dirs = empty_strarray;
|
2020-09-12 02:40:00 -07:00
|
|
|
struct strarray dependencies = empty_strarray;
|
2022-09-07 01:12:00 -07:00
|
|
|
struct strarray install_deps[NB_INSTALL_RULES] = { empty_strarray };
|
2018-03-04 14:27:23 -07:00
|
|
|
struct strarray tooldeps_deps = empty_strarray;
|
2020-09-12 02:40:00 -07:00
|
|
|
struct strarray buildtest_deps = empty_strarray;
|
2022-10-25 02:08:06 -07:00
|
|
|
unsigned int i, j, arch;
|
2018-02-17 01:53:42 -07:00
|
|
|
|
2020-09-12 02:40:00 -07:00
|
|
|
strarray_addall( &clean_files, make->clean_files );
|
2018-02-21 04:29:06 -07:00
|
|
|
strarray_addall( &distclean_files, make->distclean_files );
|
2022-10-25 02:08:06 -07:00
|
|
|
for (arch = 0; arch < archs.count; arch++) strarray_addall( &all_targets, make->all_targets[arch] );
|
2020-09-14 03:48:06 -07:00
|
|
|
for (i = 0; i < subdirs.count; i++)
|
2018-02-17 01:53:42 -07:00
|
|
|
{
|
2022-10-31 04:30:07 -07:00
|
|
|
struct strarray subclean = empty_strarray;
|
|
|
|
strarray_addall( &subclean, get_removable_dirs( submakes[i]->clean_files ));
|
|
|
|
strarray_addall( &subclean, get_removable_dirs( submakes[i]->distclean_files ));
|
2021-11-13 03:47:40 -07:00
|
|
|
strarray_add( &makefile_deps, src_dir_path( submakes[i], "Makefile.in" ));
|
2020-09-14 03:48:06 -07:00
|
|
|
strarray_addall_uniq( &make->phony_targets, submakes[i]->phony_targets );
|
|
|
|
strarray_addall_uniq( &make->uninstall_files, submakes[i]->uninstall_files );
|
|
|
|
strarray_addall_uniq( &dependencies, submakes[i]->dependencies );
|
|
|
|
strarray_addall_path( &clean_files, submakes[i]->obj_dir, submakes[i]->clean_files );
|
2024-10-07 03:44:05 -07:00
|
|
|
strarray_addall_path( &sast_files, submakes[i]->obj_dir, submakes[i]->sast_files );
|
2020-09-14 03:48:06 -07:00
|
|
|
strarray_addall_path( &distclean_files, submakes[i]->obj_dir, submakes[i]->distclean_files );
|
2022-10-31 04:30:07 -07:00
|
|
|
strarray_addall_path( &distclean_dirs, submakes[i]->obj_dir, subclean );
|
2022-01-21 03:48:20 -07:00
|
|
|
strarray_addall_path( &make->maintainerclean_files, submakes[i]->obj_dir, submakes[i]->maintainerclean_files );
|
2020-09-14 03:48:06 -07:00
|
|
|
strarray_addall_path( &make->pot_files, submakes[i]->obj_dir, submakes[i]->pot_files );
|
|
|
|
|
2022-10-25 02:08:06 -07:00
|
|
|
for (arch = 0; arch < archs.count; arch++)
|
2022-10-26 02:03:51 -07:00
|
|
|
{
|
|
|
|
if (submakes[i]->disabled[arch]) continue;
|
2022-10-25 02:08:06 -07:00
|
|
|
strarray_addall_path( &all_targets, submakes[i]->obj_dir, submakes[i]->all_targets[arch] );
|
2023-03-01 06:25:40 -07:00
|
|
|
strarray_addall_path( &testclean_files, submakes[i]->obj_dir, submakes[i]->ok_files[arch] );
|
2022-10-26 02:03:51 -07:00
|
|
|
}
|
|
|
|
if (submakes[i]->disabled[0]) continue;
|
|
|
|
|
2022-01-21 03:48:20 -07:00
|
|
|
strarray_addall_path( &all_targets, submakes[i]->obj_dir, submakes[i]->font_files );
|
2020-09-14 03:48:06 -07:00
|
|
|
if (!strcmp( submakes[i]->obj_dir, "tools" ) || !strncmp( submakes[i]->obj_dir, "tools/", 6 ))
|
|
|
|
strarray_add( &tooldeps_deps, obj_dir_path( submakes[i], "all" ));
|
|
|
|
if (submakes[i]->testdll)
|
|
|
|
strarray_add( &buildtest_deps, obj_dir_path( submakes[i], "all" ));
|
2022-09-07 01:12:00 -07:00
|
|
|
for (j = 0; j < NB_INSTALL_RULES; j++)
|
|
|
|
if (submakes[i]->install_rules[j].count)
|
|
|
|
strarray_add( &install_deps[j], obj_dir_path( submakes[i], install_targets[j] ));
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
2020-09-12 02:40:00 -07:00
|
|
|
strarray_addall( &dependencies, makefile_deps );
|
2018-02-22 10:17:46 -07:00
|
|
|
output( "all:" );
|
2020-09-12 02:40:00 -07:00
|
|
|
output_filenames( all_targets );
|
2018-02-22 10:17:46 -07:00
|
|
|
output( "\n" );
|
2018-02-17 01:53:42 -07:00
|
|
|
output( "Makefile:" );
|
|
|
|
output_filenames( makefile_deps );
|
|
|
|
output( "\n" );
|
2020-09-12 02:40:00 -07:00
|
|
|
output_filenames( dependencies );
|
2018-02-17 01:53:42 -07:00
|
|
|
output( ":\n" );
|
2022-09-07 01:12:00 -07:00
|
|
|
for (j = 0; j < NB_INSTALL_RULES; j++)
|
2018-03-04 14:27:23 -07:00
|
|
|
{
|
2022-09-07 01:12:00 -07:00
|
|
|
if (!install_deps[j].count) continue;
|
2022-09-07 01:29:14 -07:00
|
|
|
if (strcmp( install_targets[j], "install-test" ))
|
|
|
|
{
|
|
|
|
output( "install " );
|
|
|
|
strarray_add_uniq( &make->phony_targets, "install" );
|
|
|
|
}
|
|
|
|
output( "%s::", install_targets[j] );
|
2022-09-07 01:12:00 -07:00
|
|
|
output_filenames( install_deps[j] );
|
2018-03-04 14:27:23 -07:00
|
|
|
output( "\n" );
|
2022-09-07 01:12:00 -07:00
|
|
|
strarray_add_uniq( &make->phony_targets, install_targets[j] );
|
2020-09-12 02:40:00 -07:00
|
|
|
}
|
|
|
|
output_uninstall_rules( make );
|
|
|
|
if (buildtest_deps.count)
|
|
|
|
{
|
|
|
|
output( "buildtests:" );
|
|
|
|
output_filenames( buildtest_deps );
|
2018-02-26 08:38:59 -07:00
|
|
|
output( "\n" );
|
2020-09-12 02:40:00 -07:00
|
|
|
strarray_add_uniq( &make->phony_targets, "buildtests" );
|
2018-02-22 10:17:46 -07:00
|
|
|
}
|
2020-09-12 02:40:00 -07:00
|
|
|
output( "check test:" );
|
|
|
|
output_filenames( testclean_files );
|
|
|
|
output( "\n" );
|
|
|
|
strarray_add_uniq( &make->phony_targets, "check" );
|
|
|
|
strarray_add_uniq( &make->phony_targets, "test" );
|
2018-03-04 07:33:02 -07:00
|
|
|
|
2024-10-07 03:44:05 -07:00
|
|
|
if (sarif_converter)
|
|
|
|
{
|
|
|
|
if (strcmp( sarif_converter, "false" ))
|
|
|
|
{
|
|
|
|
output( "gl-code-quality-report.json:\n" );
|
|
|
|
output( "\t%s%s -t codequality -r", cmd_prefix( "SAST" ), sarif_converter );
|
|
|
|
output_filename( root_src_dir_path("") );
|
|
|
|
output_filenames( sast_files );
|
|
|
|
output_filename( "$@" );
|
|
|
|
output( "\n" );
|
|
|
|
strarray_add( &clean_files, "gl-code-quality-report.json" );
|
|
|
|
output( "gl-code-quality-report.json " );
|
|
|
|
}
|
|
|
|
output( "sast:" );
|
|
|
|
output_filenames( sast_files );
|
|
|
|
output( "\n" );
|
|
|
|
strarray_add_uniq( &make->phony_targets, "sast" );
|
|
|
|
}
|
|
|
|
|
2022-01-21 03:48:20 -07:00
|
|
|
if (get_expanded_make_variable( make, "GETTEXTPO_LIBS" )) output_po_files( make );
|
|
|
|
|
2018-02-19 13:24:59 -07:00
|
|
|
output( "clean::\n");
|
2022-10-31 04:30:07 -07:00
|
|
|
output_rm_filenames( clean_files, "rm -f" );
|
2018-02-19 13:10:14 -07:00
|
|
|
output( "testclean::\n");
|
2022-10-31 04:30:07 -07:00
|
|
|
output_rm_filenames( testclean_files, "rm -f" );
|
2018-02-17 01:53:42 -07:00
|
|
|
output( "distclean::\n");
|
2022-10-31 04:30:07 -07:00
|
|
|
output_rm_filenames( distclean_files, "rm -f" );
|
|
|
|
output_rm_filenames( distclean_dirs, "-rmdir 2>/dev/null" );
|
2022-01-21 03:48:20 -07:00
|
|
|
output( "maintainer-clean::\n");
|
2022-10-31 04:30:07 -07:00
|
|
|
output_rm_filenames( make->maintainerclean_files, "rm -f" );
|
2020-09-12 02:40:00 -07:00
|
|
|
strarray_add_uniq( &make->phony_targets, "distclean" );
|
|
|
|
strarray_add_uniq( &make->phony_targets, "testclean" );
|
2022-01-21 03:48:20 -07:00
|
|
|
strarray_add_uniq( &make->phony_targets, "maintainer-clean" );
|
2020-09-12 02:40:00 -07:00
|
|
|
|
|
|
|
if (tooldeps_deps.count)
|
2018-02-17 01:53:42 -07:00
|
|
|
{
|
2020-09-12 02:40:00 -07:00
|
|
|
output( "__tooldeps__:" );
|
|
|
|
output_filenames( tooldeps_deps );
|
2018-02-17 01:53:42 -07:00
|
|
|
output( "\n" );
|
2020-09-12 02:40:00 -07:00
|
|
|
strarray_add_uniq( &make->phony_targets, "__tooldeps__" );
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
2020-09-12 02:40:00 -07:00
|
|
|
|
|
|
|
if (make->phony_targets.count)
|
|
|
|
{
|
|
|
|
output( ".PHONY:" );
|
|
|
|
output_filenames( make->phony_targets );
|
|
|
|
output( "\n" );
|
|
|
|
}
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output_sources
|
|
|
|
*/
|
2018-02-21 04:29:06 -07:00
|
|
|
static void output_sources( struct makefile *make )
|
2018-02-17 01:53:42 -07:00
|
|
|
{
|
2020-09-12 02:40:00 -07:00
|
|
|
struct strarray all_targets = empty_strarray;
|
2018-02-17 01:53:42 -07:00
|
|
|
struct incl_file *source;
|
2022-11-01 02:28:05 -07:00
|
|
|
unsigned int i, j, arch;
|
2018-02-17 01:53:42 -07:00
|
|
|
|
2020-09-09 02:47:29 -07:00
|
|
|
strarray_add_uniq( &make->phony_targets, "all" );
|
2018-02-17 01:53:42 -07:00
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( source, &make->sources, struct incl_file, entry )
|
|
|
|
{
|
|
|
|
char *obj = xstrdup( source->name );
|
|
|
|
char *ext = get_extension( obj );
|
|
|
|
|
|
|
|
if (!ext) fatal_error( "unsupported file type %s\n", source->name );
|
|
|
|
*ext++ = 0;
|
|
|
|
|
|
|
|
for (j = 0; output_source_funcs[j].ext; j++)
|
|
|
|
if (!strcmp( ext, output_source_funcs[j].ext )) break;
|
|
|
|
|
|
|
|
output_source_funcs[j].fn( make, source, obj );
|
2018-03-04 16:20:57 -07:00
|
|
|
strarray_addall_uniq( &make->dependencies, source->dependencies );
|
2018-02-17 01:53:42 -07:00
|
|
|
}
|
|
|
|
|
2018-03-04 07:36:10 -07:00
|
|
|
/* special case for winetest: add resource files from other test dirs */
|
2020-09-14 03:48:06 -07:00
|
|
|
if (make->obj_dir && !strcmp( make->obj_dir, "programs/winetest" ))
|
2018-03-04 07:36:10 -07:00
|
|
|
{
|
2022-11-01 02:28:05 -07:00
|
|
|
for (arch = 0; arch < archs.count; arch++)
|
2022-10-26 02:03:51 -07:00
|
|
|
{
|
2022-11-01 02:28:05 -07:00
|
|
|
if (!is_multiarch( arch )) continue;
|
|
|
|
for (i = 0; i < subdirs.count; i++)
|
|
|
|
{
|
|
|
|
if (!submakes[i]->testdll) continue;
|
|
|
|
if (submakes[i]->disabled[arch]) continue;
|
|
|
|
if (enable_tests.count && !strarray_exists( &enable_tests, submakes[i]->testdll )) continue;
|
|
|
|
strarray_add( &make->res_files[arch],
|
|
|
|
strmake( "%s%s", arch_dirs[arch],
|
|
|
|
replace_extension( submakes[i]->testdll, ".dll", "_test.res" )));
|
|
|
|
}
|
2022-10-26 02:03:51 -07:00
|
|
|
}
|
2018-03-04 07:36:10 -07:00
|
|
|
}
|
|
|
|
|
2018-02-17 01:53:42 -07:00
|
|
|
if (make->dlldata_files.count)
|
|
|
|
{
|
|
|
|
output( "%s: %s %s\n", obj_dir_path( make, "dlldata.c" ),
|
|
|
|
tools_path( make, "widl" ), src_dir_path( make, "Makefile.in" ));
|
2020-12-11 08:05:45 -07:00
|
|
|
output( "\t%s%s --dlldata-only -o $@", cmd_prefix( "WIDL" ), tools_path( make, "widl" ));
|
2018-02-17 01:53:42 -07:00
|
|
|
output_filenames( make->dlldata_files );
|
|
|
|
output( "\n" );
|
|
|
|
}
|
|
|
|
|
2022-10-24 02:40:56 -07:00
|
|
|
if (make->staticlib)
|
|
|
|
{
|
2022-11-01 02:28:05 -07:00
|
|
|
for (arch = 0; arch < archs.count; arch++)
|
2023-06-15 01:46:36 -07:00
|
|
|
if (is_multiarch( arch ) || (so_dll_supported && !make->extlib))
|
|
|
|
output_static_lib( make, arch );
|
2022-10-24 02:40:56 -07:00
|
|
|
}
|
2021-11-18 11:21:12 -07:00
|
|
|
else if (make->module)
|
|
|
|
{
|
2023-06-15 01:46:36 -07:00
|
|
|
for (arch = 0; arch < archs.count; arch++)
|
|
|
|
{
|
|
|
|
if (is_multiarch( arch )) output_module( make, arch );
|
|
|
|
if (make->importlib && (is_multiarch( arch ) || !is_native_arch_disabled( make )))
|
|
|
|
output_import_lib( make, arch );
|
|
|
|
}
|
2021-11-18 11:21:12 -07:00
|
|
|
if (make->unixlib) output_unix_lib( make );
|
2023-06-15 01:27:06 -07:00
|
|
|
if (make->is_exe && !make->is_win16 && unix_lib_supported && strendswith( make->module, ".exe" ))
|
2022-10-24 02:40:56 -07:00
|
|
|
{
|
2022-11-01 02:28:05 -07:00
|
|
|
char *binary = replace_extension( make->module, ".exe", "" );
|
|
|
|
add_install_rule( make, binary, 0, "wineapploader", strmake( "t$(bindir)/%s", binary ));
|
2022-10-24 02:40:56 -07:00
|
|
|
}
|
2021-11-18 11:21:12 -07:00
|
|
|
}
|
2022-11-01 02:28:05 -07:00
|
|
|
else if (make->testdll)
|
|
|
|
{
|
|
|
|
for (arch = 0; arch < archs.count; arch++)
|
|
|
|
if (is_multiarch( arch )) output_test_module( make, arch );
|
|
|
|
}
|
2019-04-03 06:02:12 -07:00
|
|
|
else if (make->programs.count) output_programs( make );
|
2015-10-26 20:13:26 -07:00
|
|
|
|
2015-10-28 22:43:54 -07:00
|
|
|
for (i = 0; i < make->scripts.count; i++)
|
2022-10-26 02:03:51 -07:00
|
|
|
add_install_rule( make, make->scripts.str[i], 0, make->scripts.str[i],
|
2015-10-28 22:43:54 -07:00
|
|
|
strmake( "S$(bindir)/%s", make->scripts.str[i] ));
|
|
|
|
|
2020-09-09 02:47:42 -07:00
|
|
|
for (i = 0; i < make->extra_targets.count; i++)
|
|
|
|
if (strarray_exists( &make->dependencies, obj_dir_path( make, make->extra_targets.str[i] )))
|
|
|
|
strarray_add( &make->clean_files, make->extra_targets.str[i] );
|
|
|
|
else
|
2022-10-25 02:08:06 -07:00
|
|
|
strarray_add( &make->all_targets[0], make->extra_targets.str[i] );
|
2020-09-09 02:47:42 -07:00
|
|
|
|
2018-02-21 04:29:06 -07:00
|
|
|
if (!make->src_dir) strarray_add( &make->distclean_files, ".gitignore" );
|
|
|
|
strarray_add( &make->distclean_files, "Makefile" );
|
|
|
|
if (make->testdll) strarray_add( &make->distclean_files, "testlist.c" );
|
|
|
|
|
2020-09-14 03:48:06 -07:00
|
|
|
if (!make->obj_dir)
|
2018-02-21 04:29:06 -07:00
|
|
|
strarray_addall( &make->distclean_files, get_expanded_make_var_array( make, "CONFIGURE_TARGETS" ));
|
2020-09-14 03:48:06 -07:00
|
|
|
else if (!strcmp( make->obj_dir, "po" ))
|
2018-02-21 04:29:06 -07:00
|
|
|
strarray_add( &make->distclean_files, "LINGUAS" );
|
|
|
|
|
2022-10-25 02:04:30 -07:00
|
|
|
for (arch = 0; arch < archs.count; arch++)
|
|
|
|
{
|
|
|
|
strarray_addall_uniq( &make->clean_files, make->object_files[arch] );
|
2022-10-25 02:07:45 -07:00
|
|
|
strarray_addall_uniq( &make->clean_files, make->implib_files[arch] );
|
2022-10-25 02:09:57 -07:00
|
|
|
strarray_addall_uniq( &make->clean_files, make->res_files[arch] );
|
2022-10-25 02:08:06 -07:00
|
|
|
strarray_addall_uniq( &make->clean_files, make->all_targets[arch] );
|
2022-10-25 02:04:30 -07:00
|
|
|
}
|
2019-06-17 10:17:06 -07:00
|
|
|
strarray_addall( &make->clean_files, make->unixobj_files );
|
2020-09-09 02:46:00 -07:00
|
|
|
strarray_addall( &make->clean_files, make->pot_files );
|
2020-05-14 07:40:21 -07:00
|
|
|
strarray_addall( &make->clean_files, make->debug_files );
|
2024-10-07 03:44:05 -07:00
|
|
|
strarray_addall( &make->clean_files, make->sast_files );
|
2013-12-30 12:07:02 -07:00
|
|
|
|
2020-09-14 03:48:06 -07:00
|
|
|
if (make == top_makefile)
|
2016-02-25 01:46:56 -07:00
|
|
|
{
|
2020-09-12 02:40:00 -07:00
|
|
|
output_subdirs( make );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-10-25 02:08:06 -07:00
|
|
|
for (arch = 0; arch < archs.count; arch++) strarray_addall( &all_targets, make->all_targets[arch] );
|
2020-09-12 02:40:00 -07:00
|
|
|
strarray_addall( &all_targets, make->font_files );
|
|
|
|
if (all_targets.count)
|
|
|
|
{
|
|
|
|
output( "%s:", obj_dir_path( make, "all" ));
|
|
|
|
output_filenames_obj_dir( make, all_targets );
|
2016-02-25 01:46:56 -07:00
|
|
|
output( "\n" );
|
2020-09-12 02:40:00 -07:00
|
|
|
strarray_add_uniq( &make->phony_targets, obj_dir_path( make, "all" ));
|
2016-02-25 01:46:56 -07:00
|
|
|
}
|
2022-09-07 01:12:00 -07:00
|
|
|
for (i = 0; i < NB_INSTALL_RULES; i++) output_install_rules( make, i );
|
2016-02-25 01:46:56 -07:00
|
|
|
|
2020-09-12 02:40:00 -07:00
|
|
|
if (make->clean_files.count)
|
2013-12-28 03:41:45 -07:00
|
|
|
{
|
2020-09-12 02:40:00 -07:00
|
|
|
output( "%s::\n", obj_dir_path( make, "clean" ));
|
|
|
|
output( "\trm -f" );
|
|
|
|
output_filenames_obj_dir( make, make->clean_files );
|
2013-12-28 03:41:45 -07:00
|
|
|
output( "\n" );
|
2020-09-12 02:40:00 -07:00
|
|
|
strarray_add( &make->phony_targets, obj_dir_path( make, "clean" ));
|
2013-12-28 03:41:45 -07:00
|
|
|
}
|
1997-09-28 10:43:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-12 06:43:15 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* create_temp_file
|
|
|
|
*/
|
2013-12-28 03:47:15 -07:00
|
|
|
static FILE *create_temp_file( const char *orig )
|
2009-01-12 06:43:15 -07:00
|
|
|
{
|
2013-12-13 12:37:26 -07:00
|
|
|
char *name = xmalloc( strlen(orig) + 13 );
|
2009-01-12 06:43:15 -07:00
|
|
|
unsigned int i, id = getpid();
|
|
|
|
int fd;
|
|
|
|
FILE *ret = NULL;
|
|
|
|
|
|
|
|
for (i = 0; i < 100; i++)
|
|
|
|
{
|
2023-10-23 12:02:21 -07:00
|
|
|
snprintf( name, strlen(orig) + 13, "%s.tmp%08x", orig, id );
|
2009-02-22 12:39:52 -07:00
|
|
|
if ((fd = open( name, O_RDWR | O_CREAT | O_EXCL, 0666 )) != -1)
|
2009-01-12 06:43:15 -07:00
|
|
|
{
|
|
|
|
ret = fdopen( fd, "w" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (errno != EEXIST) break;
|
|
|
|
id += 7777;
|
|
|
|
}
|
2013-12-13 12:37:26 -07:00
|
|
|
if (!ret) fatal_error( "failed to create output file for '%s'\n", orig );
|
2013-12-28 03:47:15 -07:00
|
|
|
temp_file_name = name;
|
2009-01-12 06:43:15 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-13 12:37:26 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* rename_temp_file
|
|
|
|
*/
|
2013-12-28 03:47:15 -07:00
|
|
|
static void rename_temp_file( const char *dest )
|
2013-12-13 12:37:26 -07:00
|
|
|
{
|
2013-12-28 03:47:15 -07:00
|
|
|
int ret = rename( temp_file_name, dest );
|
2013-12-13 12:37:26 -07:00
|
|
|
if (ret == -1 && errno == EEXIST)
|
|
|
|
{
|
|
|
|
/* rename doesn't overwrite on windows */
|
|
|
|
unlink( dest );
|
2013-12-28 03:47:15 -07:00
|
|
|
ret = rename( temp_file_name, dest );
|
2013-12-13 12:37:26 -07:00
|
|
|
}
|
2013-12-28 03:47:15 -07:00
|
|
|
if (ret == -1) fatal_error( "failed to rename output file to '%s'\n", dest );
|
|
|
|
temp_file_name = NULL;
|
2013-12-13 12:37:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-10 02:55:18 -07: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-02-29 22:30:24 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_linguas
|
|
|
|
*/
|
|
|
|
static void output_linguas( const struct makefile *make )
|
|
|
|
{
|
2020-09-14 03:48:06 -07:00
|
|
|
const char *dest = obj_dir_path( make, "LINGUAS" );
|
2016-02-29 22:30:24 -07:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-06-26 01:37:46 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_compile_commands
|
|
|
|
*/
|
|
|
|
static void output_compile_commands( const char *dest )
|
|
|
|
{
|
|
|
|
struct compile_command *cmd;
|
|
|
|
unsigned int i;
|
|
|
|
const char *dir;
|
|
|
|
char buffer[PATH_MAX];
|
|
|
|
|
|
|
|
output_file = create_temp_file( dest );
|
|
|
|
|
|
|
|
getcwd( buffer, sizeof(buffer) );
|
|
|
|
dir = escape_cstring( buffer );
|
|
|
|
|
|
|
|
output( "[\n" );
|
|
|
|
LIST_FOR_EACH_ENTRY( cmd, &compile_commands, struct compile_command, entry )
|
|
|
|
{
|
|
|
|
output( " {\n" );
|
|
|
|
output( " \"command\": \"%s -c -o %s %s", cmd->cmd, cmd->obj, cmd->source );
|
|
|
|
for (i = 0; i < cmd->args.count; i++) output( " %s", escape_cstring( cmd->args.str[i] ));
|
|
|
|
output( "\",\n" );
|
|
|
|
output( " \"file\": \"%s\",\n", cmd->source );
|
|
|
|
output( " \"output\": \"%s\",\n", cmd->obj );
|
|
|
|
output( " \"directory\": \"%s\"\n", dir );
|
|
|
|
output( " }%s\n", list_next( &compile_commands, &cmd->entry ) ? "," : "" );
|
|
|
|
}
|
|
|
|
output( "]\n" );
|
|
|
|
|
|
|
|
if (fclose( output_file )) fatal_perror( "write" );
|
|
|
|
output_file = NULL;
|
|
|
|
rename_temp_file( dest );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-10 02:55:18 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_testlist
|
|
|
|
*/
|
2016-01-11 02:19:18 -07:00
|
|
|
static void output_testlist( const struct makefile *make )
|
2014-02-10 02:55:18 -07:00
|
|
|
{
|
2020-09-14 03:48:06 -07:00
|
|
|
const char *dest = obj_dir_path( make, "testlist.c" );
|
2016-01-11 02:19:18 -07:00
|
|
|
unsigned int i;
|
|
|
|
|
2014-02-10 02:55:18 -07: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" );
|
|
|
|
|
2021-11-20 05:26:51 -07:00
|
|
|
for (i = 0; i < make->test_files.count; i++)
|
|
|
|
output( "extern void func_%s(void);\n", make->test_files.str[i] );
|
2014-02-10 02:55:18 -07:00
|
|
|
output( "\n" );
|
|
|
|
output( "const struct test winetest_testlist[] =\n" );
|
|
|
|
output( "{\n" );
|
2021-11-20 05:26:51 -07:00
|
|
|
for (i = 0; i < make->test_files.count; i++)
|
|
|
|
output( " { \"%s\", func_%s },\n", make->test_files.str[i], make->test_files.str[i] );
|
2014-02-10 02:55:18 -07:00
|
|
|
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 12:37:26 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_gitignore
|
|
|
|
*/
|
2014-02-10 02:55:18 -07:00
|
|
|
static void output_gitignore( const char *dest, struct strarray files )
|
2013-12-13 12:37:26 -07:00
|
|
|
{
|
2022-02-01 06:58:23 -07:00
|
|
|
unsigned int i;
|
2013-12-13 12:37:26 -07:00
|
|
|
|
2013-12-28 03:47:15 -07:00
|
|
|
output_file = create_temp_file( dest );
|
2013-12-13 12:37:26 -07:00
|
|
|
|
|
|
|
output( "# Automatically generated by make depend; DO NOT EDIT!!\n" );
|
2014-02-10 02:55:18 -07:00
|
|
|
for (i = 0; i < files.count; i++)
|
2013-12-13 12:37:26 -07:00
|
|
|
{
|
2014-02-10 02:55:18 -07:00
|
|
|
if (!strchr( files.str[i], '/' )) output( "/" );
|
|
|
|
output( "%s\n", files.str[i] );
|
2013-12-13 12:37:26 -07:00
|
|
|
}
|
|
|
|
|
2013-12-28 03:47:15 -07:00
|
|
|
if (fclose( output_file )) fatal_perror( "write" );
|
2013-12-13 12:37:26 -07:00
|
|
|
output_file = NULL;
|
2013-12-28 03:47:15 -07:00
|
|
|
rename_temp_file( dest );
|
2013-12-13 12:37:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-22 22:49:36 -07:00
|
|
|
/*******************************************************************
|
2020-09-12 02:40:00 -07:00
|
|
|
* output_stub_makefile
|
2015-10-22 22:49:36 -07:00
|
|
|
*/
|
2020-09-12 02:40:00 -07:00
|
|
|
static void output_stub_makefile( struct makefile *make )
|
2015-10-22 22:49:36 -07:00
|
|
|
{
|
2020-09-12 02:40:00 -07:00
|
|
|
struct strarray targets = empty_strarray;
|
|
|
|
const char *make_var = strarray_get_value( &top_makefile->vars, "MAKE" );
|
2022-10-25 02:08:06 -07:00
|
|
|
unsigned int i, arch;
|
2020-09-12 02:40:00 -07:00
|
|
|
|
2022-10-25 02:08:06 -07:00
|
|
|
for (arch = 0; arch < archs.count; arch++)
|
|
|
|
if (make->all_targets[arch].count) strarray_add_uniq( &targets, "all" );
|
|
|
|
|
2022-09-07 01:12:00 -07:00
|
|
|
for (i = 0; i < NB_INSTALL_RULES; i++)
|
|
|
|
{
|
|
|
|
if (!make->install_rules[i].count) continue;
|
|
|
|
strarray_add_uniq( &targets, "install" );
|
|
|
|
strarray_add( &targets, install_targets[i] );
|
|
|
|
}
|
2020-09-12 02:40:00 -07:00
|
|
|
if (make->clean_files.count) strarray_add( &targets, "clean" );
|
2021-11-20 05:26:51 -07:00
|
|
|
if (make->test_files.count)
|
2016-01-11 00:05:51 -07:00
|
|
|
{
|
2020-09-12 02:40:00 -07:00
|
|
|
strarray_add( &targets, "check" );
|
|
|
|
strarray_add( &targets, "test" );
|
|
|
|
strarray_add( &targets, "testclean" );
|
2016-01-11 00:05:51 -07:00
|
|
|
}
|
2020-09-12 02:40:00 -07:00
|
|
|
|
2023-01-27 05:08:04 -07:00
|
|
|
if (!targets.count && !make->clean_files.count) return;
|
|
|
|
|
|
|
|
output_file_name = obj_dir_path( make, "Makefile" );
|
|
|
|
output_file = create_temp_file( output_file_name );
|
|
|
|
|
|
|
|
output( "# Auto-generated stub makefile; all rules forward to the top-level makefile\n\n" );
|
|
|
|
|
|
|
|
if (make_var) output( "MAKE = %s\n\n", make_var );
|
|
|
|
|
|
|
|
output( "all:\n" );
|
2020-09-12 02:40:00 -07:00
|
|
|
output_filenames( targets );
|
2020-10-11 12:35:47 -07:00
|
|
|
output_filenames( make->clean_files );
|
2020-09-12 02:40:00 -07:00
|
|
|
output( ":\n" );
|
2024-06-24 04:39:49 -07:00
|
|
|
output( "\t@cd %s && $(MAKE) %s/$@\n", get_root_relative_path( make ), make->obj_dir );
|
2020-09-12 02:40:00 -07:00
|
|
|
output( ".PHONY:" );
|
|
|
|
output_filenames( targets );
|
2015-10-22 22:49:36 -07:00
|
|
|
output( "\n" );
|
2021-11-13 03:47:40 -07:00
|
|
|
|
|
|
|
fclose( output_file );
|
|
|
|
output_file = NULL;
|
|
|
|
rename_temp_file( output_file_name );
|
2015-10-22 22:49:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-11 08:05:45 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* output_silent_rules
|
|
|
|
*/
|
|
|
|
static void output_silent_rules(void)
|
|
|
|
{
|
|
|
|
static const char *cmds[] =
|
|
|
|
{
|
|
|
|
"BISON",
|
|
|
|
"BUILD",
|
|
|
|
"CC",
|
|
|
|
"CCLD",
|
|
|
|
"FLEX",
|
|
|
|
"GEN",
|
|
|
|
"LN",
|
|
|
|
"MSG",
|
2024-10-07 03:44:05 -07:00
|
|
|
"SAST",
|
2020-12-11 08:05:45 -07:00
|
|
|
"SED",
|
|
|
|
"TEST",
|
|
|
|
"WIDL",
|
|
|
|
"WMC",
|
|
|
|
"WRC"
|
|
|
|
};
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
output( "V = 0\n" );
|
2022-10-16 12:51:57 -07:00
|
|
|
for (i = 0; i < ARRAY_SIZE(cmds); i++)
|
2020-12-11 08:05:45 -07:00
|
|
|
{
|
|
|
|
output( "quiet_%s = $(quiet_%s_$(V))\n", cmds[i], cmds[i] );
|
|
|
|
output( "quiet_%s_0 = @echo \" %-5s \" $@;\n", cmds[i], cmds[i] );
|
|
|
|
output( "quiet_%s_1 =\n", cmds[i] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-10-23 09:59:13 -07:00
|
|
|
/*******************************************************************
|
2021-11-13 03:47:40 -07:00
|
|
|
* output_top_makefile
|
1996-10-23 09:59:13 -07:00
|
|
|
*/
|
2021-11-13 03:47:40 -07:00
|
|
|
static void output_top_makefile( struct makefile *make )
|
1996-10-23 09:59:13 -07:00
|
|
|
{
|
2015-10-22 23:03:11 -07:00
|
|
|
char buffer[1024];
|
2015-10-22 22:49:36 -07:00
|
|
|
FILE *src_file;
|
2022-02-01 06:58:23 -07:00
|
|
|
unsigned int i;
|
|
|
|
int found = 0;
|
2024-06-26 02:32:20 -07:00
|
|
|
const char *makedep;
|
1996-10-23 09:59:13 -07:00
|
|
|
|
2020-09-14 03:48:06 -07:00
|
|
|
output_file_name = obj_dir_path( make, output_makefile_name );
|
2015-10-22 23:03:11 -07:00
|
|
|
output_file = create_temp_file( output_file_name );
|
2009-01-12 06:43:15 -07:00
|
|
|
|
2015-10-22 23:03:11 -07:00
|
|
|
/* copy the contents of the source makefile */
|
2015-10-23 01:42:44 -07:00
|
|
|
src_file = open_input_makefile( make );
|
2016-01-11 00:05:51 -07:00
|
|
|
while (fgets( buffer, sizeof(buffer), src_file ) && !found)
|
|
|
|
{
|
2015-10-22 23:03:11 -07:00
|
|
|
if (fwrite( buffer, 1, strlen(buffer), output_file ) != strlen(buffer)) fatal_perror( "write" );
|
2016-01-11 00:05:51 -07:00
|
|
|
found = !strncmp( buffer, separator, strlen(separator) );
|
|
|
|
}
|
2015-10-22 23:03:11 -07:00
|
|
|
if (fclose( src_file )) fatal_perror( "close" );
|
2015-10-23 01:42:44 -07:00
|
|
|
input_file_name = NULL;
|
2013-10-14 02:11:07 -07:00
|
|
|
|
2016-01-11 00:05:51 -07:00
|
|
|
if (!found) output( "\n%s (everything below this line is auto-generated; DO NOT EDIT!!)\n", separator );
|
2020-09-12 02:40:00 -07:00
|
|
|
|
2021-11-13 03:47:40 -07:00
|
|
|
if (silent_rules) output_silent_rules();
|
2024-06-26 02:32:20 -07:00
|
|
|
|
|
|
|
/* add special targets for makefile and dependencies */
|
|
|
|
|
|
|
|
output( ".INIT: Makefile\n" );
|
|
|
|
output( ".MAKEFILEDEPS:\n" );
|
|
|
|
output( ".SUFFIXES:\n" );
|
|
|
|
makedep = strmake( "%s%s",tools_dir_path( make, "makedep" ), tools_ext );
|
|
|
|
output( "Makefile: %s\n", makedep );
|
|
|
|
output( "depend: %s\n", makedep );
|
2024-06-26 01:37:46 -07:00
|
|
|
output( "\t%s%s%s\n", makedep,
|
|
|
|
compile_commands_mode ? " -C" : "",
|
2024-06-26 02:32:20 -07:00
|
|
|
silent_rules ? " -S" : "" );
|
|
|
|
strarray_add( &make->phony_targets, "depend" );
|
|
|
|
|
2021-11-13 03:47:40 -07:00
|
|
|
for (i = 0; i < subdirs.count; i++) output_sources( submakes[i] );
|
|
|
|
output_sources( make );
|
2020-11-15 10:12:43 -07:00
|
|
|
|
2013-10-14 02:11:07 -07:00
|
|
|
fclose( output_file );
|
|
|
|
output_file = NULL;
|
2015-10-22 23:03:11 -07:00
|
|
|
rename_temp_file( output_file_name );
|
2021-11-13 03:47:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* output_dependencies
|
|
|
|
*/
|
|
|
|
static void output_dependencies( struct makefile *make )
|
|
|
|
{
|
|
|
|
struct strarray ignore_files = empty_strarray;
|
|
|
|
|
|
|
|
if (make->obj_dir) create_dir( make->obj_dir );
|
|
|
|
|
|
|
|
if (make == top_makefile) output_top_makefile( make );
|
|
|
|
else output_stub_makefile( make );
|
2013-12-13 12:37:26 -07:00
|
|
|
|
2018-02-21 04:29:06 -07:00
|
|
|
strarray_addall( &ignore_files, make->distclean_files );
|
|
|
|
strarray_addall( &ignore_files, make->clean_files );
|
|
|
|
if (make->testdll) output_testlist( make );
|
2020-09-14 03:48:06 -07:00
|
|
|
if (make->obj_dir && !strcmp( make->obj_dir, "po" )) output_linguas( make );
|
|
|
|
if (!make->src_dir) output_gitignore( obj_dir_path( make, ".gitignore" ), ignore_files );
|
2015-10-22 23:03:11 -07:00
|
|
|
|
2018-02-21 04:29:06 -07:00
|
|
|
create_file_directories( make, ignore_files );
|
2016-02-25 02:00:36 -07:00
|
|
|
|
2015-10-22 23:03:11 -07:00
|
|
|
output_file_name = NULL;
|
2013-12-17 09:10:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
2016-01-11 00:05:51 -07:00
|
|
|
* load_sources
|
2013-12-17 09:10:28 -07:00
|
|
|
*/
|
2016-01-11 00:05:51 -07:00
|
|
|
static void load_sources( struct makefile *make )
|
2013-12-17 09:10:28 -07:00
|
|
|
{
|
2022-10-26 02:03:51 -07:00
|
|
|
unsigned int i, arch;
|
2013-12-17 09:10:28 -07:00
|
|
|
struct strarray value;
|
|
|
|
struct incl_file *file;
|
|
|
|
|
2020-09-14 03:48:06 -07:00
|
|
|
strarray_set_value( &make->vars, "top_srcdir", root_src_dir_path( "" ));
|
2014-04-10 04:41:23 -07:00
|
|
|
strarray_set_value( &make->vars, "srcdir", src_dir_path( make, "" ));
|
2014-04-09 01:12:44 -07:00
|
|
|
|
2014-04-10 04:41:23 -07: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" );
|
|
|
|
make->staticlib = get_expanded_make_variable( make, "STATICLIB" );
|
|
|
|
make->importlib = get_expanded_make_variable( make, "IMPORTLIB" );
|
2021-10-18 02:06:55 -07:00
|
|
|
make->extlib = get_expanded_make_variable( make, "EXTLIB" );
|
2023-06-15 01:27:06 -07:00
|
|
|
if (unix_lib_supported) make->unixlib = get_expanded_make_variable( make, "UNIXLIB" );
|
2014-04-09 03:35:24 -07:00
|
|
|
|
2015-10-26 20:13:26 -07:00
|
|
|
make->programs = get_expanded_make_var_array( make, "PROGRAMS" );
|
2015-10-28 22:43:54 -07:00
|
|
|
make->scripts = get_expanded_make_var_array( make, "SCRIPTS" );
|
2014-04-10 04:41:23 -07:00
|
|
|
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" );
|
2018-11-30 05:09:12 -07:00
|
|
|
make->extra_targets = get_expanded_make_var_array( make, "EXTRA_TARGETS" );
|
2022-09-07 01:12:00 -07:00
|
|
|
for (i = 0; i < NB_INSTALL_RULES; i++)
|
|
|
|
make->install[i] = get_expanded_make_var_array( make, install_variables[i] );
|
2014-04-09 03:35:24 -07:00
|
|
|
|
2021-10-18 02:06:55 -07:00
|
|
|
if (make->extlib) make->staticlib = make->extlib;
|
2021-10-06 01:20:26 -07:00
|
|
|
if (make->staticlib) make->module = make->staticlib;
|
2019-08-05 09:57:47 -07:00
|
|
|
|
2022-10-26 02:03:51 -07:00
|
|
|
if (make->obj_dir)
|
|
|
|
{
|
2022-11-01 02:28:05 -07:00
|
|
|
make->disabled[0] = strarray_exists( &disabled_dirs[0], make->obj_dir );
|
2022-10-26 02:03:51 -07:00
|
|
|
for (arch = 1; arch < archs.count; arch++)
|
2022-11-01 02:28:05 -07:00
|
|
|
make->disabled[arch] = make->disabled[0] || strarray_exists( &disabled_dirs[arch], make->obj_dir );
|
2022-10-26 02:03:51 -07:00
|
|
|
}
|
2021-09-20 08:03:48 -07:00
|
|
|
make->is_win16 = strarray_exists( &make->extradllflags, "-m16" );
|
2022-02-16 08:10:08 -07:00
|
|
|
make->data_only = strarray_exists( &make->extradllflags, "-Wb,--data-only" );
|
2019-04-09 01:13:37 -07:00
|
|
|
make->is_exe = strarray_exists( &make->extradllflags, "-mconsole" ) ||
|
|
|
|
strarray_exists( &make->extradllflags, "-mwindows" );
|
2014-04-10 04:15:13 -07:00
|
|
|
|
2022-09-07 01:12:00 -07:00
|
|
|
if (make->module)
|
2016-04-03 22:06:10 -07:00
|
|
|
{
|
2022-09-07 01:12:00 -07:00
|
|
|
/* add default install rules if nothing was specified */
|
|
|
|
for (i = 0; i < NB_INSTALL_RULES; i++) if (make->install[i].count) break;
|
|
|
|
if (i == NB_INSTALL_RULES)
|
|
|
|
{
|
|
|
|
if (make->importlib) strarray_add( &make->install[INSTALL_DEV], make->importlib );
|
|
|
|
if (make->staticlib) strarray_add( &make->install[INSTALL_DEV], make->staticlib );
|
|
|
|
else strarray_add( &make->install[INSTALL_LIB], make->module );
|
|
|
|
}
|
2016-04-03 22:06:10 -07:00
|
|
|
}
|
2015-10-28 22:32:45 -07:00
|
|
|
|
2015-11-10 23:02:57 -07:00
|
|
|
make->include_paths = empty_strarray;
|
2018-02-17 01:53:42 -07:00
|
|
|
make->include_args = empty_strarray;
|
2014-04-09 01:12:44 -07:00
|
|
|
make->define_args = empty_strarray;
|
2022-06-29 02:06:16 -07:00
|
|
|
make->unix_cflags = empty_strarray;
|
2021-10-18 02:06:55 -07:00
|
|
|
if (!make->extlib) strarray_add( &make->define_args, "-D__WINESRC__" );
|
2023-06-12 02:11:44 -07:00
|
|
|
strarray_add( &make->unix_cflags, "-DWINE_UNIX_LIB" );
|
2014-01-07 02:56:15 -07:00
|
|
|
|
2014-04-10 04:41:23 -07:00
|
|
|
value = get_expanded_make_var_array( make, "EXTRAINCL" );
|
2013-12-17 09:10:28 -07:00
|
|
|
for (i = 0; i < value.count; i++)
|
2022-06-29 00:33:15 -07:00
|
|
|
{
|
2013-12-17 09:10:28 -07:00
|
|
|
if (!strncmp( value.str[i], "-I", 2 ))
|
2022-06-29 00:33:15 -07:00
|
|
|
{
|
|
|
|
const char *dir = value.str[i] + 2;
|
|
|
|
if (!strncmp( dir, "./", 2 ))
|
|
|
|
{
|
|
|
|
dir += 2;
|
|
|
|
while (*dir == '/') dir++;
|
|
|
|
}
|
|
|
|
strarray_add_uniq( &make->include_paths, dir );
|
|
|
|
}
|
2021-04-08 02:43:13 -07:00
|
|
|
else if (!strncmp( value.str[i], "-D", 2 ) || !strncmp( value.str[i], "-U", 2 ))
|
2014-04-09 01:12:44 -07:00
|
|
|
strarray_add_uniq( &make->define_args, value.str[i] );
|
2022-06-29 00:33:15 -07:00
|
|
|
}
|
2014-04-10 04:41:23 -07:00
|
|
|
strarray_addall( &make->define_args, get_expanded_make_var_array( make, "EXTRADEFS" ));
|
2022-06-29 02:06:16 -07:00
|
|
|
strarray_addall_uniq( &make->unix_cflags, get_expanded_make_var_array( make, "UNIX_CFLAGS" ));
|
2013-12-17 09:10:28 -07:00
|
|
|
|
2018-02-17 01:53:42 -07:00
|
|
|
strarray_add( &make->include_args, strmake( "-I%s", obj_dir_path( make, "" )));
|
|
|
|
if (make->src_dir)
|
|
|
|
strarray_add( &make->include_args, strmake( "-I%s", make->src_dir ));
|
|
|
|
if (make->parent_dir)
|
|
|
|
strarray_add( &make->include_args, strmake( "-I%s", src_dir_path( make, make->parent_dir )));
|
2020-09-14 03:48:06 -07:00
|
|
|
strarray_add( &make->include_args, "-Iinclude" );
|
|
|
|
if (root_src_dir) strarray_add( &make->include_args, strmake( "-I%s", root_src_dir_path( "include" )));
|
2018-02-17 01:53:42 -07:00
|
|
|
|
2014-04-10 04:50:37 -07:00
|
|
|
list_init( &make->sources );
|
2014-04-11 08:03:54 -07:00
|
|
|
list_init( &make->includes );
|
2013-12-17 09:10:28 -07:00
|
|
|
|
2023-11-14 05:06:38 -07:00
|
|
|
value = get_expanded_make_var_array( make, "SOURCES" );
|
|
|
|
for (i = 0; i < value.count; i++) add_src_file( make, value.str[i] );
|
2013-12-17 09:10:28 -07:00
|
|
|
|
2014-04-10 04:41:23 -07:00
|
|
|
add_generated_sources( make );
|
2013-12-26 11:27:59 -07:00
|
|
|
|
2020-02-28 06:40:02 -07:00
|
|
|
LIST_FOR_EACH_ENTRY( file, &make->includes, struct incl_file, entry ) parse_file( make, file, 0 );
|
|
|
|
LIST_FOR_EACH_ENTRY( file, &make->sources, struct incl_file, entry ) get_dependencies( file, file );
|
|
|
|
|
2022-11-01 02:28:05 -07:00
|
|
|
for (i = 0; i < make->delayimports.count; i++)
|
|
|
|
strarray_add_uniq( &delay_import_libs, get_base_name( make->delayimports.str[i] ));
|
1996-10-23 09:59:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-26 11:26:37 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* parse_makeflags
|
|
|
|
*/
|
|
|
|
static void parse_makeflags( const char *flags )
|
|
|
|
{
|
|
|
|
const char *p = flags;
|
|
|
|
char *var, *buffer = xmalloc( strlen(flags) + 1 );
|
|
|
|
|
|
|
|
while (*p)
|
|
|
|
{
|
2022-12-08 06:53:16 -07:00
|
|
|
p = skip_spaces( p );
|
2013-12-26 11:26:37 -07:00
|
|
|
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 09:59:13 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* parse_option
|
|
|
|
*/
|
2013-12-26 11:26:29 -07:00
|
|
|
static int parse_option( const char *opt )
|
1996-10-23 09:59:13 -07:00
|
|
|
{
|
2013-12-26 11:26:29 -07:00
|
|
|
if (opt[0] != '-')
|
|
|
|
{
|
|
|
|
if (strchr( opt, '=' )) return set_make_variable( &cmdline_vars, opt );
|
|
|
|
return 0;
|
|
|
|
}
|
1996-10-23 09:59:13 -07:00
|
|
|
switch(opt[1])
|
|
|
|
{
|
|
|
|
case 'f':
|
2015-10-23 01:42:44 -07:00
|
|
|
if (opt[2]) output_makefile_name = opt + 2;
|
|
|
|
break;
|
2024-06-26 01:37:46 -07:00
|
|
|
case 'C':
|
|
|
|
compile_commands_mode = 1;
|
|
|
|
break;
|
2020-12-11 08:05:45 -07:00
|
|
|
case 'S':
|
|
|
|
silent_rules = 1;
|
|
|
|
break;
|
1996-10-23 09:59:13 -07:00
|
|
|
default:
|
2013-10-14 02:11:07 -07:00
|
|
|
fprintf( stderr, "Unknown option '%s'\n%s", opt, Usage );
|
1996-10-23 09:59:13 -07:00
|
|
|
exit(1);
|
|
|
|
}
|
2013-12-26 11:26:29 -07:00
|
|
|
return 1;
|
1996-10-23 09:59:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-08 15:00:24 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* find_pe_arch
|
|
|
|
*/
|
|
|
|
static unsigned int find_pe_arch( const char *arch )
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
for (i = 1; i < archs.count; i++) if (!strcmp( archs.str[i], arch )) return i;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-10-23 09:59:13 -07:00
|
|
|
/*******************************************************************
|
|
|
|
* main
|
|
|
|
*/
|
|
|
|
int main( int argc, char *argv[] )
|
|
|
|
{
|
2013-12-26 11:26:37 -07:00
|
|
|
const char *makeflags = getenv( "MAKEFLAGS" );
|
2022-11-01 02:28:05 -07:00
|
|
|
const char *target;
|
2024-04-08 15:00:24 -07:00
|
|
|
unsigned int i, j, arch, ec_arch;
|
1996-10-23 09:59:13 -07:00
|
|
|
|
2013-12-26 11:26:37 -07:00
|
|
|
if (makeflags) parse_makeflags( makeflags );
|
|
|
|
|
2006-08-01 03:27:22 -07:00
|
|
|
i = 1;
|
|
|
|
while (i < argc)
|
1996-10-23 09:59:13 -07:00
|
|
|
{
|
2013-12-26 11:26:29 -07:00
|
|
|
if (parse_option( argv[i] ))
|
2006-08-01 03:27:22 -07:00
|
|
|
{
|
|
|
|
for (j = i; j < argc; j++) argv[j] = argv[j+1];
|
|
|
|
argc--;
|
|
|
|
}
|
|
|
|
else i++;
|
|
|
|
}
|
|
|
|
|
2024-06-26 01:31:27 -07:00
|
|
|
if (argc > 1)
|
2013-11-08 13:11:59 -07:00
|
|
|
{
|
2024-06-26 01:31:27 -07:00
|
|
|
fprintf( stderr, "Unknown argument '%s'\n%s", argv[1], Usage );
|
|
|
|
exit(1);
|
2013-11-08 13:11:59 -07:00
|
|
|
}
|
|
|
|
|
2013-12-28 03:47:15 -07:00
|
|
|
atexit( cleanup_files );
|
2023-01-25 03:32:32 -07:00
|
|
|
init_signals( exit_on_signal );
|
2013-12-28 03:47:15 -07:00
|
|
|
|
2014-04-11 07:55:51 -07:00
|
|
|
for (i = 0; i < HASH_SIZE; i++) list_init( &files[i] );
|
2022-07-28 06:32:17 -07:00
|
|
|
for (i = 0; i < HASH_SIZE; i++) list_init( &global_includes[i] );
|
2014-04-11 07:55:51 -07:00
|
|
|
|
2016-02-25 01:08:12 -07:00
|
|
|
top_makefile = parse_makefile( NULL );
|
2014-04-10 04:41:23 -07:00
|
|
|
|
2022-10-24 02:42:31 -07:00
|
|
|
target_flags[0] = get_expanded_make_var_array( top_makefile, "TARGETFLAGS" );
|
2021-09-22 01:34:07 -07:00
|
|
|
msvcrt_flags = get_expanded_make_var_array( top_makefile, "MSVCRTFLAGS" );
|
|
|
|
dll_flags = get_expanded_make_var_array( top_makefile, "DLLFLAGS" );
|
|
|
|
unix_dllflags = get_expanded_make_var_array( top_makefile, "UNIXDLLFLAGS" );
|
|
|
|
cpp_flags = get_expanded_make_var_array( top_makefile, "CPPFLAGS" );
|
|
|
|
lddll_flags = get_expanded_make_var_array( top_makefile, "LDDLLFLAGS" );
|
|
|
|
libs = get_expanded_make_var_array( top_makefile, "LIBS" );
|
|
|
|
enable_tests = get_expanded_make_var_array( top_makefile, "ENABLE_TESTS" );
|
2022-09-07 01:12:00 -07:00
|
|
|
for (i = 0; i < NB_INSTALL_RULES; i++)
|
|
|
|
top_install[i] = get_expanded_make_var_array( top_makefile, strmake( "TOP_%s", install_variables[i] ));
|
2021-09-22 01:34:07 -07:00
|
|
|
|
|
|
|
root_src_dir = get_expanded_make_variable( top_makefile, "srcdir" );
|
2021-11-10 03:38:10 -07:00
|
|
|
tools_dir = get_expanded_make_variable( top_makefile, "toolsdir" );
|
|
|
|
tools_ext = get_expanded_make_variable( top_makefile, "toolsext" );
|
2021-09-22 01:34:07 -07:00
|
|
|
exe_ext = get_expanded_make_variable( top_makefile, "EXEEXT" );
|
2023-06-15 01:27:06 -07:00
|
|
|
dll_ext[0] = get_expanded_make_variable( top_makefile, "DLLEXT" );
|
2021-09-22 01:34:07 -07:00
|
|
|
fontforge = get_expanded_make_variable( top_makefile, "FONTFORGE" );
|
|
|
|
convert = get_expanded_make_variable( top_makefile, "CONVERT" );
|
|
|
|
flex = get_expanded_make_variable( top_makefile, "FLEX" );
|
|
|
|
bison = get_expanded_make_variable( top_makefile, "BISON" );
|
|
|
|
rsvg = get_expanded_make_variable( top_makefile, "RSVG" );
|
|
|
|
icotool = get_expanded_make_variable( top_makefile, "ICOTOOL" );
|
|
|
|
msgfmt = get_expanded_make_variable( top_makefile, "MSGFMT" );
|
|
|
|
sed_cmd = get_expanded_make_variable( top_makefile, "SED_CMD" );
|
|
|
|
ln_s = get_expanded_make_variable( top_makefile, "LN_S" );
|
2021-09-02 04:04:43 -07:00
|
|
|
wayland_scanner = get_expanded_make_variable( top_makefile, "WAYLAND_SCANNER" );
|
2024-10-07 03:44:05 -07:00
|
|
|
sarif_converter = get_expanded_make_variable( top_makefile, "SARIF_CONVERTER" );
|
2014-04-02 05:09:42 -07:00
|
|
|
|
2014-04-09 03:32:54 -07:00
|
|
|
if (root_src_dir && !strcmp( root_src_dir, "." )) root_src_dir = NULL;
|
2014-04-02 05:09:42 -07:00
|
|
|
if (tools_dir && !strcmp( tools_dir, "." )) tools_dir = NULL;
|
2015-10-26 20:13:26 -07:00
|
|
|
if (!exe_ext) exe_ext = "";
|
2023-06-15 01:27:06 -07:00
|
|
|
if (!dll_ext[0]) dll_ext[0] = "";
|
2014-04-02 05:09:42 -07:00
|
|
|
if (!tools_ext) tools_ext = "";
|
2022-10-24 02:42:31 -07:00
|
|
|
|
2023-06-15 01:27:06 -07:00
|
|
|
unix_lib_supported = !!strcmp( exe_ext, ".exe" );
|
2023-06-15 01:46:36 -07:00
|
|
|
so_dll_supported = !!dll_ext[0][0]; /* non-empty dll ext means supported */
|
2023-06-15 01:27:06 -07:00
|
|
|
|
2022-11-01 02:28:05 -07:00
|
|
|
strarray_add( &archs, get_expanded_make_variable( top_makefile, "HOST_ARCH" ));
|
|
|
|
strarray_addall( &archs, get_expanded_make_var_array( top_makefile, "PE_ARCHS" ));
|
|
|
|
|
2024-04-08 15:00:24 -07:00
|
|
|
/* check for ARM64X setup */
|
|
|
|
if ((ec_arch = find_pe_arch( "arm64ec" )) && (arch = find_pe_arch( "aarch64" )))
|
|
|
|
{
|
|
|
|
native_archs[ec_arch] = arch;
|
|
|
|
hybrid_archs[arch] = ec_arch;
|
|
|
|
strarray_add( &hybrid_target_flags[ec_arch], "-marm64x" );
|
|
|
|
}
|
|
|
|
|
2022-10-26 02:04:43 -07:00
|
|
|
arch_dirs[0] = "";
|
|
|
|
arch_pe_dirs[0] = strmake( "%s-windows/", archs.str[0] );
|
2024-06-24 04:57:34 -07:00
|
|
|
arch_install_dirs[0] = unix_lib_supported ? strmake( "$(libdir)/wine/%s-unix/", archs.str[0] ) : "$(libdir)/wine/";
|
2022-10-24 02:42:31 -07:00
|
|
|
strip_progs[0] = "\"$(STRIP)\"";
|
|
|
|
|
2022-10-25 02:03:54 -07:00
|
|
|
for (arch = 1; arch < archs.count; arch++)
|
|
|
|
{
|
2022-11-01 02:28:05 -07:00
|
|
|
target = get_expanded_arch_var( top_makefile, "TARGET", arch );
|
|
|
|
strarray_add( &target_flags[arch], "-b" );
|
|
|
|
strarray_add( &target_flags[arch], target );
|
2022-10-26 02:04:43 -07:00
|
|
|
arch_dirs[arch] = strmake( "%s-windows/", archs.str[arch] );
|
|
|
|
arch_pe_dirs[arch] = arch_dirs[arch];
|
2024-06-24 04:57:34 -07:00
|
|
|
arch_install_dirs[arch] = strmake( "$(libdir)/wine/%s", arch_dirs[arch] );
|
2024-10-17 04:03:28 -07:00
|
|
|
strip_progs[arch] = get_expanded_arch_var( top_makefile, "STRIP", arch );
|
2023-06-15 01:27:06 -07:00
|
|
|
dll_ext[arch] = "";
|
2022-10-25 02:03:54 -07:00
|
|
|
}
|
|
|
|
|
2022-10-24 02:46:48 -07:00
|
|
|
for (arch = 0; arch < archs.count; arch++)
|
|
|
|
{
|
2022-11-01 02:28:05 -07:00
|
|
|
extra_cflags[arch] = get_expanded_arch_var_array( top_makefile, "EXTRACFLAGS", arch );
|
2022-10-24 03:22:25 -07:00
|
|
|
extra_cflags_extlib[arch] = remove_warning_flags( extra_cflags[arch] );
|
2022-11-01 02:28:05 -07:00
|
|
|
disabled_dirs[arch] = get_expanded_arch_var_array( top_makefile, "DISABLED_SUBDIRS", arch );
|
2022-10-24 02:46:48 -07:00
|
|
|
if (!is_multiarch( arch )) continue;
|
2022-11-01 02:28:05 -07:00
|
|
|
delay_load_flags[arch] = get_expanded_arch_var( top_makefile, "DELAYLOADFLAG", arch );
|
|
|
|
debug_flags[arch] = get_expanded_arch_var( top_makefile, "DEBUG", arch );
|
2022-10-24 02:46:48 -07:00
|
|
|
}
|
|
|
|
|
2023-06-15 01:27:06 -07:00
|
|
|
if (unix_lib_supported)
|
2022-10-24 02:46:48 -07:00
|
|
|
{
|
2022-10-24 03:12:51 -07:00
|
|
|
delay_load_flags[0] = "-Wl,-delayload,";
|
2022-10-24 02:46:48 -07:00
|
|
|
debug_flags[0] = NULL;
|
2022-10-24 02:42:31 -07:00
|
|
|
}
|
2014-04-02 05:09:42 -07:00
|
|
|
|
2020-09-14 03:48:06 -07:00
|
|
|
top_makefile->src_dir = root_src_dir;
|
|
|
|
subdirs = get_expanded_make_var_array( top_makefile, "SUBDIRS" );
|
|
|
|
submakes = xmalloc( subdirs.count * sizeof(*submakes) );
|
2016-01-11 00:05:51 -07:00
|
|
|
|
2020-09-14 03:48:06 -07:00
|
|
|
for (i = 0; i < subdirs.count; i++) submakes[i] = parse_makefile( subdirs.str[i] );
|
2016-01-11 00:05:51 -07:00
|
|
|
|
2020-09-11 01:00:31 -07:00
|
|
|
load_sources( top_makefile );
|
2022-07-28 06:32:17 -07:00
|
|
|
load_sources( include_makefile );
|
|
|
|
for (i = 0; i < subdirs.count; i++)
|
|
|
|
if (submakes[i] != include_makefile) load_sources( submakes[i] );
|
2016-01-11 00:05:51 -07:00
|
|
|
|
2020-09-12 02:40:00 -07:00
|
|
|
output_dependencies( top_makefile );
|
2020-09-14 03:48:06 -07:00
|
|
|
for (i = 0; i < subdirs.count; i++) output_dependencies( submakes[i] );
|
2016-01-11 00:05:51 -07:00
|
|
|
|
2024-06-26 01:37:46 -07:00
|
|
|
if (compile_commands_mode) output_compile_commands( "compile_commands.json" );
|
|
|
|
|
1996-10-23 09:59:13 -07:00
|
|
|
return 0;
|
|
|
|
}
|