1994-03-23 22:12:55 +08:00
|
|
|
|
/* Argument parsing and main program of GNU Make.
|
2014-09-01 01:11:08 +08:00
|
|
|
|
Copyright (C) 1988-2014 Free Software Foundation, Inc.
|
1992-01-30 07:54:36 +08:00
|
|
|
|
This file is part of GNU Make.
|
|
|
|
|
|
2006-02-12 03:02:21 +08:00
|
|
|
|
GNU Make is free software; you can redistribute it and/or modify it under the
|
|
|
|
|
terms of the GNU General Public License as published by the Free Software
|
2007-07-05 03:35:15 +08:00
|
|
|
|
Foundation; either version 3 of the License, or (at your option) any later
|
|
|
|
|
version.
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2006-02-12 03:02:21 +08:00
|
|
|
|
GNU Make 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 General Public License for more details.
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2006-02-12 03:02:21 +08:00
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
2007-07-05 03:35:15 +08:00
|
|
|
|
this program. If not, see <http://www.gnu.org/licenses/>. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2013-01-21 00:01:01 +08:00
|
|
|
|
#include "makeint.h"
|
1996-03-20 22:57:41 +08:00
|
|
|
|
#include "filedef.h"
|
2013-09-22 12:48:05 +08:00
|
|
|
|
#include "dep.h"
|
1992-01-30 07:54:36 +08:00
|
|
|
|
#include "variable.h"
|
|
|
|
|
#include "job.h"
|
1996-03-20 22:57:41 +08:00
|
|
|
|
#include "commands.h"
|
1998-10-03 13:39:55 +08:00
|
|
|
|
#include "rule.h"
|
1999-11-22 14:15:35 +08:00
|
|
|
|
#include "debug.h"
|
1992-05-09 12:28:28 +08:00
|
|
|
|
#include "getopt.h"
|
1999-11-22 14:15:35 +08:00
|
|
|
|
|
1995-03-25 07:39:24 +08:00
|
|
|
|
#include <assert.h>
|
1996-05-14 02:40:11 +08:00
|
|
|
|
#ifdef _AMIGA
|
1999-07-08 14:49:52 +08:00
|
|
|
|
# include <dos/dos.h>
|
|
|
|
|
# include <proto/dos.h>
|
1996-05-14 02:40:11 +08:00
|
|
|
|
#endif
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#ifdef WINDOWS32
|
2011-11-14 08:42:49 +08:00
|
|
|
|
# include <windows.h>
|
|
|
|
|
# include <io.h>
|
|
|
|
|
# include "pathstuff.h"
|
|
|
|
|
# include "sub_proc.h"
|
2011-11-16 05:12:53 +08:00
|
|
|
|
# include "w32err.h"
|
1996-05-23 05:51:45 +08:00
|
|
|
|
#endif
|
2003-03-25 07:14:15 +08:00
|
|
|
|
#ifdef __EMX__
|
|
|
|
|
# include <sys/types.h>
|
|
|
|
|
# include <sys/wait.h>
|
|
|
|
|
#endif
|
2003-07-19 10:46:25 +08:00
|
|
|
|
#ifdef HAVE_FCNTL_H
|
1999-04-25 12:30:55 +08:00
|
|
|
|
# include <fcntl.h>
|
|
|
|
|
#endif
|
1996-05-14 02:40:11 +08:00
|
|
|
|
|
|
|
|
|
#ifdef _AMIGA
|
|
|
|
|
int __stack = 20000; /* Make sure we have 20K of stack space */
|
|
|
|
|
#endif
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2006-04-07 09:43:44 +08:00
|
|
|
|
void init_dir (void);
|
|
|
|
|
void remote_setup (void);
|
|
|
|
|
void remote_cleanup (void);
|
|
|
|
|
RETSIGTYPE fatal_error_signal (int sig);
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2006-04-07 09:43:44 +08:00
|
|
|
|
void print_variable_data_base (void);
|
|
|
|
|
void print_dir_data_base (void);
|
|
|
|
|
void print_rule_data_base (void);
|
|
|
|
|
void print_vpath_data_base (void);
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2007-03-20 11:02:26 +08:00
|
|
|
|
void verify_file_data_base (void);
|
|
|
|
|
|
1998-10-03 13:39:55 +08:00
|
|
|
|
#if defined HAVE_WAITPID || defined HAVE_WAIT3
|
|
|
|
|
# define HAVE_WAIT_NOHANG
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
#ifndef HAVE_UNISTD_H
|
2006-04-07 09:43:44 +08:00
|
|
|
|
int chdir ();
|
1992-06-11 12:58:20 +08:00
|
|
|
|
#endif
|
2013-01-20 13:55:57 +08:00
|
|
|
|
#ifndef STDC_HEADERS
|
|
|
|
|
# ifndef sun /* Sun has an incorrect decl in a header. */
|
2006-04-07 09:43:44 +08:00
|
|
|
|
void exit (int) __attribute__ ((noreturn));
|
1999-07-08 14:49:52 +08:00
|
|
|
|
# endif
|
2006-04-07 09:43:44 +08:00
|
|
|
|
double atof ();
|
1992-01-30 07:54:36 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2006-04-07 09:43:44 +08:00
|
|
|
|
static void clean_jobserver (int status);
|
|
|
|
|
static void print_data_base (void);
|
|
|
|
|
static void print_version (void);
|
2014-04-26 05:10:47 +08:00
|
|
|
|
static void decode_switches (int argc, const char **argv, int env);
|
|
|
|
|
static void decode_env_switches (const char *envar, unsigned int len);
|
2013-09-16 12:12:09 +08:00
|
|
|
|
static struct variable *define_makeflags (int all, int makefile);
|
2007-03-20 11:02:26 +08:00
|
|
|
|
static char *quote_for_env (char *out, const char *in);
|
2006-04-07 09:43:44 +08:00
|
|
|
|
static void initialize_global_hash_tables (void);
|
2002-07-11 14:38:57 +08:00
|
|
|
|
|
1993-06-26 03:47:20 +08:00
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* The structure that describes an accepted command switch. */
|
|
|
|
|
|
|
|
|
|
struct command_switch
|
|
|
|
|
{
|
2013-01-20 13:55:57 +08:00
|
|
|
|
int c; /* The switch character. */
|
1993-04-15 02:20:33 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
enum /* Type of the value. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
{
|
2013-01-20 13:55:57 +08:00
|
|
|
|
flag, /* Turn int flag on. */
|
|
|
|
|
flag_off, /* Turn int flag off. */
|
2013-11-24 16:21:40 +08:00
|
|
|
|
string, /* One string per invocation. */
|
|
|
|
|
strlist, /* One string per switch. */
|
2013-01-20 13:55:57 +08:00
|
|
|
|
filename, /* A string containing a file name. */
|
|
|
|
|
positive_int, /* A positive integer. */
|
|
|
|
|
floating, /* A floating-point number (double). */
|
|
|
|
|
ignore /* Ignored. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
} type;
|
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
void *value_ptr; /* Pointer to the value-holding variable. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
unsigned int env:1; /* Can come from MAKEFLAGS. */
|
|
|
|
|
unsigned int toenv:1; /* Should be put in MAKEFLAGS. */
|
|
|
|
|
unsigned int no_makefile:1; /* Don't propagate when remaking makefiles. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
const void *noarg_value; /* Pointer to value used if no arg given. */
|
|
|
|
|
const void *default_value; /* Pointer to default value. */
|
1992-05-09 12:28:28 +08:00
|
|
|
|
|
2014-04-26 05:10:47 +08:00
|
|
|
|
const char *long_name; /* Long option name. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
};
|
|
|
|
|
|
1999-09-01 01:02:31 +08:00
|
|
|
|
/* True if C is a switch value that corresponds to a short option. */
|
|
|
|
|
|
|
|
|
|
#define short_option(c) ((c) <= CHAR_MAX)
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
|
|
|
|
/* The structure used to hold the list of strings given
|
2013-11-24 16:21:40 +08:00
|
|
|
|
in command switches of a type that takes strlist arguments. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
|
|
|
|
struct stringlist
|
|
|
|
|
{
|
2013-01-20 13:55:57 +08:00
|
|
|
|
const char **list; /* Nil-terminated list of strings. */
|
|
|
|
|
unsigned int idx; /* Index into above. */
|
|
|
|
|
unsigned int max; /* Number of pointers allocated. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* The recognized command switches. */
|
|
|
|
|
|
2013-06-22 11:59:38 +08:00
|
|
|
|
/* Nonzero means do extra verification (that may slow things down). */
|
|
|
|
|
|
|
|
|
|
int verify_flag;
|
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* Nonzero means do not print commands to be executed (-s). */
|
|
|
|
|
|
|
|
|
|
int silent_flag;
|
|
|
|
|
|
|
|
|
|
/* Nonzero means just touch the files
|
|
|
|
|
that would appear to need remaking (-t) */
|
|
|
|
|
|
|
|
|
|
int touch_flag;
|
|
|
|
|
|
|
|
|
|
/* Nonzero means just print what commands would need to be executed,
|
|
|
|
|
don't actually execute them (-n). */
|
|
|
|
|
|
|
|
|
|
int just_print_flag;
|
|
|
|
|
|
1999-11-22 14:15:35 +08:00
|
|
|
|
/* Print debugging info (--debug). */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2013-04-17 07:51:29 +08:00
|
|
|
|
static struct stringlist *db_flags = 0;
|
2000-01-23 15:05:16 +08:00
|
|
|
|
static int debug_flag = 0;
|
1999-11-27 16:09:42 +08:00
|
|
|
|
|
1999-11-22 14:15:35 +08:00
|
|
|
|
int db_level = 0;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2013-04-16 01:22:51 +08:00
|
|
|
|
/* Synchronize output (--output-sync). */
|
|
|
|
|
|
2013-11-24 16:21:40 +08:00
|
|
|
|
char *output_sync_option = 0;
|
2013-04-16 01:22:51 +08:00
|
|
|
|
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#ifdef WINDOWS32
|
1996-05-23 05:51:45 +08:00
|
|
|
|
/* Suspend make in main for a short time to allow debugger to attach */
|
|
|
|
|
|
|
|
|
|
int suspend_flag = 0;
|
|
|
|
|
#endif
|
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* Environment variables override makefile definitions. */
|
|
|
|
|
|
|
|
|
|
int env_overrides = 0;
|
|
|
|
|
|
|
|
|
|
/* Nonzero means ignore status codes returned by commands
|
|
|
|
|
executed to remake files. Just treat them all as successful (-i). */
|
|
|
|
|
|
|
|
|
|
int ignore_errors_flag = 0;
|
|
|
|
|
|
|
|
|
|
/* Nonzero means don't remake anything, just print the data base
|
|
|
|
|
that results from reading the makefile (-p). */
|
|
|
|
|
|
|
|
|
|
int print_data_base_flag = 0;
|
|
|
|
|
|
|
|
|
|
/* Nonzero means don't remake anything; just return a nonzero status
|
|
|
|
|
if the specified targets are not up to date (-q). */
|
|
|
|
|
|
|
|
|
|
int question_flag = 0;
|
|
|
|
|
|
1999-07-08 14:49:52 +08:00
|
|
|
|
/* Nonzero means do not use any of the builtin rules (-r) / variables (-R). */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
|
|
|
|
int no_builtin_rules_flag = 0;
|
1999-07-08 14:49:52 +08:00
|
|
|
|
int no_builtin_variables_flag = 0;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
|
|
|
|
/* Nonzero means keep going even if remaking some file fails (-k). */
|
|
|
|
|
|
|
|
|
|
int keep_going_flag;
|
|
|
|
|
int default_keep_going_flag = 0;
|
|
|
|
|
|
2005-02-28 15:48:22 +08:00
|
|
|
|
/* Nonzero means check symlink mtimes. */
|
|
|
|
|
|
|
|
|
|
int check_symlink_flag = 0;
|
|
|
|
|
|
1993-04-08 04:40:35 +08:00
|
|
|
|
/* Nonzero means print directory before starting and when done (-w). */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
|
|
|
|
int print_directory_flag = 0;
|
|
|
|
|
|
1993-04-08 04:40:35 +08:00
|
|
|
|
/* Nonzero means ignore print_directory_flag and never print the directory.
|
|
|
|
|
This is necessary because print_directory_flag is set implicitly. */
|
|
|
|
|
|
|
|
|
|
int inhibit_print_directory_flag = 0;
|
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* Nonzero means print version information. */
|
|
|
|
|
|
|
|
|
|
int print_version_flag = 0;
|
|
|
|
|
|
|
|
|
|
/* List of makefiles given with -f switches. */
|
|
|
|
|
|
|
|
|
|
static struct stringlist *makefiles = 0;
|
|
|
|
|
|
2009-06-08 01:40:06 +08:00
|
|
|
|
/* Size of the stack when we started. */
|
|
|
|
|
|
|
|
|
|
#ifdef SET_STACK_SIZE
|
|
|
|
|
struct rlimit stack_limit;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* Number of job slots (commands that can be run at once). */
|
|
|
|
|
|
|
|
|
|
unsigned int job_slots = 1;
|
|
|
|
|
unsigned int default_job_slots = 1;
|
2005-05-03 21:57:20 +08:00
|
|
|
|
static unsigned int master_job_slots = 0;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1999-04-25 12:30:55 +08:00
|
|
|
|
/* Value of job_slots that means no limit. */
|
1999-08-23 13:35:14 +08:00
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
static unsigned int inf_jobs = 0;
|
1999-04-25 12:30:55 +08:00
|
|
|
|
|
|
|
|
|
/* File descriptors for the jobs pipe. */
|
|
|
|
|
|
2013-11-24 16:21:40 +08:00
|
|
|
|
char *jobserver_fds = 0;
|
1999-08-23 13:35:14 +08:00
|
|
|
|
|
1999-04-25 12:30:55 +08:00
|
|
|
|
int job_fds[2] = { -1, -1 };
|
1999-08-13 15:36:26 +08:00
|
|
|
|
int job_rfd = -1;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
Support --output-sync on MS-Windows.
w32/compat/posixfcn.c: New file, with emulations of Posix
functions and Posix functionality for MS-Windows.
w32/subproc/sub_proc.c: Include io.h.
(process_noinherit): New function, forces a file descriptor to not
be inherited by child processes.
(process_easy): Accept two additional arguments, and use them to
set up the standard output and standard error handles of the child
process.
w32/include/sub_proc.h (process_easy): Adjust prototype.
(process_noinherit): Add prototype.
read.c [WINDOWS32]: Include windows.h and sub_proc.h.
makeint.h (LOCALEDIR) [WINDOWS32}: Define to NULL if not
defined. This is needed because the MS-Windows build doesn't have
a canonical place for LOCALEDIR.
(WIN32_LEAN_AND_MEAN) [WINDOWS32]: Define, to avoid getting from
windows.h header too much stuff that could conflict with the code.
main.c <sync_mutex>: New static variable.
<switches>: Add support for "--sync-mutex" switch.
(decode_output_sync_flags): Decode the --sync-mutex= switch.
(prepare_mutex_handle_string) [WINDOWS32]: New function.
(main): Add "output-sync" to .FEATURES.
job.h (CLOSE_ON_EXEC) [WINDOWS32]: Define to call
process_noinherit.
(F_GETFD, F_SETLKW, F_WRLCK, F_UNLCK, struct flock) [WINDOWS32]:
New macros.
(RECORD_SYNC_MUTEX): New macro, a no-op for Posix platforms.
(sync_handle_t): New typedef.
job.c <sync_handle>: Change type to sync_handle_t.
(FD_NOT_EMPTY): Seek to the file's end. Suggested by Frank
Heckenbach <f.heckenbach@fh-soft.de>.
(pump_from_tmp_fd) [WINDOWS32]: Switch to_fd to binary mode for
the duration of this function, and then change back before
returning.
(start_job_command) [WINDOWS32]: Support output_sync mode on
MS-Windows. Use a system-wide mutex instead of locking
stdout/stderr. Call process_easy with two additional arguments:
child->outfd and child->errfd.
(exec_command) [WINDOWS32]: Pass two additional arguments, both
-1, to process_easy, to adjust for the changed function signature.
function.c (windows32_openpipe) [WINDOWS32]: This function now
returns an int, which is -1 if it fails and zero otherwise. It
also calls 'error' instead of 'fatal', to avoid exiting
prematurely.
(func_shell_base) [WINDOWS32]: Call perror_with_name if
windows32_openpipe fails, now that it always returns. This avoids
a compiler warning that error_prefix is not used in the MS-Windows
build.
config.h.W32.template (OUTPUT_SYNC): Define.
build_w32.bat: Add w32/compat/posixfcn.c to compilation and
linking commands.
From Frank Heckenbach <f.heckenbach@fh-soft.de>:
job.c (sync_output): Don't discard the output if
acquire_semaphore fails; instead, dump the output unsynchronized.
2013-04-27 19:20:49 +08:00
|
|
|
|
/* Handle for the mutex used on Windows to synchronize output of our
|
|
|
|
|
children under -O. */
|
|
|
|
|
|
2013-11-24 16:21:40 +08:00
|
|
|
|
char *sync_mutex = 0;
|
Support --output-sync on MS-Windows.
w32/compat/posixfcn.c: New file, with emulations of Posix
functions and Posix functionality for MS-Windows.
w32/subproc/sub_proc.c: Include io.h.
(process_noinherit): New function, forces a file descriptor to not
be inherited by child processes.
(process_easy): Accept two additional arguments, and use them to
set up the standard output and standard error handles of the child
process.
w32/include/sub_proc.h (process_easy): Adjust prototype.
(process_noinherit): Add prototype.
read.c [WINDOWS32]: Include windows.h and sub_proc.h.
makeint.h (LOCALEDIR) [WINDOWS32}: Define to NULL if not
defined. This is needed because the MS-Windows build doesn't have
a canonical place for LOCALEDIR.
(WIN32_LEAN_AND_MEAN) [WINDOWS32]: Define, to avoid getting from
windows.h header too much stuff that could conflict with the code.
main.c <sync_mutex>: New static variable.
<switches>: Add support for "--sync-mutex" switch.
(decode_output_sync_flags): Decode the --sync-mutex= switch.
(prepare_mutex_handle_string) [WINDOWS32]: New function.
(main): Add "output-sync" to .FEATURES.
job.h (CLOSE_ON_EXEC) [WINDOWS32]: Define to call
process_noinherit.
(F_GETFD, F_SETLKW, F_WRLCK, F_UNLCK, struct flock) [WINDOWS32]:
New macros.
(RECORD_SYNC_MUTEX): New macro, a no-op for Posix platforms.
(sync_handle_t): New typedef.
job.c <sync_handle>: Change type to sync_handle_t.
(FD_NOT_EMPTY): Seek to the file's end. Suggested by Frank
Heckenbach <f.heckenbach@fh-soft.de>.
(pump_from_tmp_fd) [WINDOWS32]: Switch to_fd to binary mode for
the duration of this function, and then change back before
returning.
(start_job_command) [WINDOWS32]: Support output_sync mode on
MS-Windows. Use a system-wide mutex instead of locking
stdout/stderr. Call process_easy with two additional arguments:
child->outfd and child->errfd.
(exec_command) [WINDOWS32]: Pass two additional arguments, both
-1, to process_easy, to adjust for the changed function signature.
function.c (windows32_openpipe) [WINDOWS32]: This function now
returns an int, which is -1 if it fails and zero otherwise. It
also calls 'error' instead of 'fatal', to avoid exiting
prematurely.
(func_shell_base) [WINDOWS32]: Call perror_with_name if
windows32_openpipe fails, now that it always returns. This avoids
a compiler warning that error_prefix is not used in the MS-Windows
build.
config.h.W32.template (OUTPUT_SYNC): Define.
build_w32.bat: Add w32/compat/posixfcn.c to compilation and
linking commands.
From Frank Heckenbach <f.heckenbach@fh-soft.de>:
job.c (sync_output): Don't discard the output if
acquire_semaphore fails; instead, dump the output unsynchronized.
2013-04-27 19:20:49 +08:00
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* Maximum load average at which multiple jobs will be run.
|
|
|
|
|
Negative values mean unlimited, while zero means limit to
|
|
|
|
|
zero load (which could be useful to start infinite jobs remotely
|
|
|
|
|
but one at a time locally). */
|
Thu May 9 13:54:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* GNUmakefile (globfiles): Add AmigaDOS support files.
(distfiles): Add $(amigafiles).
(amigafiles): New variable.
Thu Nov 7 10:18:16 1995 Aaron Digulla <digulla@fh-konstanz.de>
* Added Amiga support in commands.c, dir.c, function.c,
job.c, main.c, make.h, read.c, remake.c
* commands.c: Amiga has neither SIGHUP nor SIGQUIT
* dir.c: Amiga has filenames with Upper- and Lowercase,
but "FileName" is the same as "filename". Added strieq()
which is use to compare filenames. This is like streq()
on all other systems. Also there is no such thing as
"." under AmigaDOS.
* function.c: On Amiga, the environment is not passed as envp,
there are no pipes and Amiga can't fork. Use my own function
to create a new child.
* job.c: default_shell is "" (The system automatically chooses
a shell for me). Have to use the same workaround as MSDOS for
running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't
known on Amiga. Cloned code to run children from MSDOS. Own
version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga.
* main.c: Force stack to 20000 bytes. Read environment from ENV:
device. On Amiga, exec_command() does return, so I exit()
afterwards.
* make.h: Added strieq() to compare filenames.
* read.c: Amiga needs special extension to have passwd. Only
one include-dir. "Makefile" and "makefile" are the same.
Added "SMakefile". Added special code to handle device names (xxx:)
and "./" in rules.
* remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib"
instead of "lib%s.a".
* main.c, rule.c, variable.c: Avoid floats at all costs.
* vpath.c: Get rid of as many alloca()s as possible.
1996-05-10 02:02:06 +08:00
|
|
|
|
#ifndef NO_FLOAT
|
1992-01-30 07:54:36 +08:00
|
|
|
|
double max_load_average = -1.0;
|
|
|
|
|
double default_load_average = -1.0;
|
Thu May 9 13:54:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* GNUmakefile (globfiles): Add AmigaDOS support files.
(distfiles): Add $(amigafiles).
(amigafiles): New variable.
Thu Nov 7 10:18:16 1995 Aaron Digulla <digulla@fh-konstanz.de>
* Added Amiga support in commands.c, dir.c, function.c,
job.c, main.c, make.h, read.c, remake.c
* commands.c: Amiga has neither SIGHUP nor SIGQUIT
* dir.c: Amiga has filenames with Upper- and Lowercase,
but "FileName" is the same as "filename". Added strieq()
which is use to compare filenames. This is like streq()
on all other systems. Also there is no such thing as
"." under AmigaDOS.
* function.c: On Amiga, the environment is not passed as envp,
there are no pipes and Amiga can't fork. Use my own function
to create a new child.
* job.c: default_shell is "" (The system automatically chooses
a shell for me). Have to use the same workaround as MSDOS for
running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't
known on Amiga. Cloned code to run children from MSDOS. Own
version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga.
* main.c: Force stack to 20000 bytes. Read environment from ENV:
device. On Amiga, exec_command() does return, so I exit()
afterwards.
* make.h: Added strieq() to compare filenames.
* read.c: Amiga needs special extension to have passwd. Only
one include-dir. "Makefile" and "makefile" are the same.
Added "SMakefile". Added special code to handle device names (xxx:)
and "./" in rules.
* remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib"
instead of "lib%s.a".
* main.c, rule.c, variable.c: Avoid floats at all costs.
* vpath.c: Get rid of as many alloca()s as possible.
1996-05-10 02:02:06 +08:00
|
|
|
|
#else
|
|
|
|
|
int max_load_average = -1;
|
|
|
|
|
int default_load_average = -1;
|
|
|
|
|
#endif
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1993-06-08 08:08:45 +08:00
|
|
|
|
/* List of directories given with -C switches. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
|
|
|
|
static struct stringlist *directories = 0;
|
|
|
|
|
|
|
|
|
|
/* List of include directories given with -I switches. */
|
|
|
|
|
|
|
|
|
|
static struct stringlist *include_directories = 0;
|
|
|
|
|
|
|
|
|
|
/* List of files given with -o switches. */
|
|
|
|
|
|
|
|
|
|
static struct stringlist *old_files = 0;
|
|
|
|
|
|
|
|
|
|
/* List of files given with -W switches. */
|
|
|
|
|
|
|
|
|
|
static struct stringlist *new_files = 0;
|
1993-05-23 04:20:16 +08:00
|
|
|
|
|
2009-10-25 08:46:52 +08:00
|
|
|
|
/* List of strings to be eval'd. */
|
|
|
|
|
static struct stringlist *eval_strings = 0;
|
|
|
|
|
|
1993-05-23 04:20:16 +08:00
|
|
|
|
/* If nonzero, we should just print usage and exit. */
|
|
|
|
|
|
|
|
|
|
static int print_usage_flag = 0;
|
1993-06-26 03:47:20 +08:00
|
|
|
|
|
|
|
|
|
/* If nonzero, we should print a warning message
|
|
|
|
|
for each reference to an undefined variable. */
|
|
|
|
|
|
|
|
|
|
int warn_undefined_variables_flag;
|
2002-08-08 08:11:19 +08:00
|
|
|
|
|
|
|
|
|
/* If nonzero, always build all targets, regardless of whether
|
|
|
|
|
they appear out of date or not. */
|
|
|
|
|
|
2005-06-26 02:57:28 +08:00
|
|
|
|
static int always_make_set = 0;
|
2002-08-08 08:11:19 +08:00
|
|
|
|
int always_make_flag = 0;
|
2004-05-17 03:16:52 +08:00
|
|
|
|
|
|
|
|
|
/* If nonzero, we're in the "try to rebuild makefiles" phase. */
|
|
|
|
|
|
|
|
|
|
int rebuilding_makefiles = 0;
|
|
|
|
|
|
2004-11-29 07:11:23 +08:00
|
|
|
|
/* Remember the original value of the SHELL variable, from the environment. */
|
|
|
|
|
|
2004-12-06 02:09:31 +08:00
|
|
|
|
struct variable shell_var;
|
2004-11-29 07:11:23 +08:00
|
|
|
|
|
2006-11-19 04:53:44 +08:00
|
|
|
|
/* This character introduces a command: it's the first char on the line. */
|
|
|
|
|
|
|
|
|
|
char cmd_prefix = '\t';
|
|
|
|
|
|
1992-05-11 13:28:52 +08:00
|
|
|
|
|
2002-08-08 13:39:17 +08:00
|
|
|
|
/* The usage output. We write it this way to make life easier for the
|
|
|
|
|
translators, especially those trying to translate to right-to-left
|
|
|
|
|
languages like Hebrew. */
|
|
|
|
|
|
|
|
|
|
static const char *const usage[] =
|
|
|
|
|
{
|
|
|
|
|
N_("Options:\n"),
|
|
|
|
|
N_("\
|
|
|
|
|
-b, -m Ignored for compatibility.\n"),
|
|
|
|
|
N_("\
|
|
|
|
|
-B, --always-make Unconditionally make all targets.\n"),
|
|
|
|
|
N_("\
|
|
|
|
|
-C DIRECTORY, --directory=DIRECTORY\n\
|
|
|
|
|
Change to DIRECTORY before doing anything.\n"),
|
|
|
|
|
N_("\
|
|
|
|
|
-d Print lots of debugging information.\n"),
|
|
|
|
|
N_("\
|
|
|
|
|
--debug[=FLAGS] Print various types of debugging information.\n"),
|
|
|
|
|
N_("\
|
|
|
|
|
-e, --environment-overrides\n\
|
|
|
|
|
Environment variables override makefiles.\n"),
|
|
|
|
|
N_("\
|
2009-10-25 08:46:52 +08:00
|
|
|
|
--eval=STRING Evaluate STRING as a makefile statement.\n"),
|
|
|
|
|
N_("\
|
2002-08-08 13:39:17 +08:00
|
|
|
|
-f FILE, --file=FILE, --makefile=FILE\n\
|
|
|
|
|
Read FILE as a makefile.\n"),
|
|
|
|
|
N_("\
|
|
|
|
|
-h, --help Print this message and exit.\n"),
|
|
|
|
|
N_("\
|
2007-11-05 05:54:00 +08:00
|
|
|
|
-i, --ignore-errors Ignore errors from recipes.\n"),
|
2002-08-08 13:39:17 +08:00
|
|
|
|
N_("\
|
|
|
|
|
-I DIRECTORY, --include-dir=DIRECTORY\n\
|
|
|
|
|
Search DIRECTORY for included makefiles.\n"),
|
|
|
|
|
N_("\
|
|
|
|
|
-j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg.\n"),
|
|
|
|
|
N_("\
|
|
|
|
|
-k, --keep-going Keep going when some targets can't be made.\n"),
|
|
|
|
|
N_("\
|
|
|
|
|
-l [N], --load-average[=N], --max-load[=N]\n\
|
|
|
|
|
Don't start multiple jobs unless load is below N.\n"),
|
|
|
|
|
N_("\
|
2005-02-28 15:48:22 +08:00
|
|
|
|
-L, --check-symlink-times Use the latest mtime between symlinks and target.\n"),
|
|
|
|
|
N_("\
|
2002-08-08 13:39:17 +08:00
|
|
|
|
-n, --just-print, --dry-run, --recon\n\
|
2007-11-05 05:54:00 +08:00
|
|
|
|
Don't actually run any recipe; just print them.\n"),
|
2002-08-08 13:39:17 +08:00
|
|
|
|
N_("\
|
|
|
|
|
-o FILE, --old-file=FILE, --assume-old=FILE\n\
|
|
|
|
|
Consider FILE to be very old and don't remake it.\n"),
|
|
|
|
|
N_("\
|
2013-04-16 01:22:51 +08:00
|
|
|
|
-O[TYPE], --output-sync[=TYPE]\n\
|
|
|
|
|
Synchronize output of parallel jobs by TYPE.\n"),
|
2002-08-08 13:39:17 +08:00
|
|
|
|
N_("\
|
2013-04-15 04:31:18 +08:00
|
|
|
|
-p, --print-data-base Print make's internal database.\n"),
|
|
|
|
|
N_("\
|
2007-11-05 05:54:00 +08:00
|
|
|
|
-q, --question Run no recipe; exit status says if up to date.\n"),
|
2002-08-08 13:39:17 +08:00
|
|
|
|
N_("\
|
|
|
|
|
-r, --no-builtin-rules Disable the built-in implicit rules.\n"),
|
|
|
|
|
N_("\
|
|
|
|
|
-R, --no-builtin-variables Disable the built-in variable settings.\n"),
|
|
|
|
|
N_("\
|
2007-11-05 05:54:00 +08:00
|
|
|
|
-s, --silent, --quiet Don't echo recipes.\n"),
|
2002-08-08 13:39:17 +08:00
|
|
|
|
N_("\
|
|
|
|
|
-S, --no-keep-going, --stop\n\
|
|
|
|
|
Turns off -k.\n"),
|
|
|
|
|
N_("\
|
|
|
|
|
-t, --touch Touch targets instead of remaking them.\n"),
|
|
|
|
|
N_("\
|
2013-09-12 16:07:52 +08:00
|
|
|
|
--trace Print tracing information.\n"),
|
2010-08-30 07:05:26 +08:00
|
|
|
|
N_("\
|
2002-08-08 13:39:17 +08:00
|
|
|
|
-v, --version Print the version number of make and exit.\n"),
|
|
|
|
|
N_("\
|
|
|
|
|
-w, --print-directory Print the current directory.\n"),
|
|
|
|
|
N_("\
|
|
|
|
|
--no-print-directory Turn off -w, even if it was turned on implicitly.\n"),
|
|
|
|
|
N_("\
|
|
|
|
|
-W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE\n\
|
|
|
|
|
Consider FILE to be infinitely new.\n"),
|
|
|
|
|
N_("\
|
|
|
|
|
--warn-undefined-variables Warn when an undefined variable is referenced.\n"),
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
|
2013-05-22 14:14:19 +08:00
|
|
|
|
/* The table of command switches.
|
|
|
|
|
Order matters here: this is the order MAKEFLAGS will be constructed.
|
|
|
|
|
So be sure all simple flags (single char, no argument) come first. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1993-04-15 02:20:33 +08:00
|
|
|
|
static const struct command_switch switches[] =
|
1992-01-30 07:54:36 +08:00
|
|
|
|
{
|
2002-08-08 13:39:17 +08:00
|
|
|
|
{ 'b', ignore, 0, 0, 0, 0, 0, 0, 0 },
|
2006-11-19 04:53:44 +08:00
|
|
|
|
{ 'B', flag, &always_make_set, 1, 1, 0, 0, 0, "always-make" },
|
|
|
|
|
{ 'd', flag, &debug_flag, 1, 1, 0, 0, 0, 0 },
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#ifdef WINDOWS32
|
2006-11-19 04:53:44 +08:00
|
|
|
|
{ 'D', flag, &suspend_flag, 1, 1, 0, 0, 0, "suspend-for-debug" },
|
|
|
|
|
#endif
|
|
|
|
|
{ 'e', flag, &env_overrides, 1, 1, 0, 0, 0, "environment-overrides", },
|
|
|
|
|
{ 'h', flag, &print_usage_flag, 0, 0, 0, 0, 0, "help" },
|
|
|
|
|
{ 'i', flag, &ignore_errors_flag, 1, 1, 0, 0, 0, "ignore-errors" },
|
|
|
|
|
{ 'k', flag, &keep_going_flag, 1, 1, 0, 0, &default_keep_going_flag,
|
|
|
|
|
"keep-going" },
|
|
|
|
|
{ 'L', flag, &check_symlink_flag, 1, 1, 0, 0, 0, "check-symlink-times" },
|
2002-08-08 13:39:17 +08:00
|
|
|
|
{ 'm', ignore, 0, 0, 0, 0, 0, 0, 0 },
|
2006-11-19 04:53:44 +08:00
|
|
|
|
{ 'n', flag, &just_print_flag, 1, 1, 1, 0, 0, "just-print" },
|
2013-04-15 04:31:18 +08:00
|
|
|
|
{ 'p', flag, &print_data_base_flag, 1, 1, 0, 0, 0, "print-data-base" },
|
2006-11-19 04:53:44 +08:00
|
|
|
|
{ 'q', flag, &question_flag, 1, 1, 1, 0, 0, "question" },
|
|
|
|
|
{ 'r', flag, &no_builtin_rules_flag, 1, 1, 0, 0, 0, "no-builtin-rules" },
|
|
|
|
|
{ 'R', flag, &no_builtin_variables_flag, 1, 1, 0, 0, 0,
|
2005-02-28 15:48:22 +08:00
|
|
|
|
"no-builtin-variables" },
|
2006-11-19 04:53:44 +08:00
|
|
|
|
{ 's', flag, &silent_flag, 1, 1, 0, 0, 0, "silent" },
|
|
|
|
|
{ 'S', flag_off, &keep_going_flag, 1, 1, 0, 0, &default_keep_going_flag,
|
|
|
|
|
"no-keep-going" },
|
|
|
|
|
{ 't', flag, &touch_flag, 1, 1, 1, 0, 0, "touch" },
|
|
|
|
|
{ 'v', flag, &print_version_flag, 1, 1, 0, 0, 0, "version" },
|
|
|
|
|
{ 'w', flag, &print_directory_flag, 1, 1, 0, 0, 0, "print-directory" },
|
2013-05-22 14:14:19 +08:00
|
|
|
|
|
|
|
|
|
/* These options take arguments. */
|
|
|
|
|
{ 'C', filename, &directories, 0, 0, 0, 0, 0, "directory" },
|
|
|
|
|
{ 'f', filename, &makefiles, 0, 0, 0, 0, 0, "file" },
|
|
|
|
|
{ 'I', filename, &include_directories, 1, 1, 0, 0, 0,
|
|
|
|
|
"include-dir" },
|
|
|
|
|
{ 'j', positive_int, &job_slots, 1, 1, 0, &inf_jobs, &default_job_slots,
|
|
|
|
|
"jobs" },
|
|
|
|
|
#ifndef NO_FLOAT
|
|
|
|
|
{ 'l', floating, &max_load_average, 1, 1, 0, &default_load_average,
|
|
|
|
|
&default_load_average, "load-average" },
|
|
|
|
|
#else
|
|
|
|
|
{ 'l', positive_int, &max_load_average, 1, 1, 0, &default_load_average,
|
|
|
|
|
&default_load_average, "load-average" },
|
|
|
|
|
#endif
|
|
|
|
|
{ 'o', filename, &old_files, 0, 0, 0, 0, 0, "old-file" },
|
|
|
|
|
{ 'O', string, &output_sync_option, 1, 1, 0, "target", 0, "output-sync" },
|
|
|
|
|
{ 'W', filename, &new_files, 0, 0, 0, 0, 0, "what-if" },
|
|
|
|
|
|
|
|
|
|
/* These are long-style options. */
|
2013-11-24 16:21:40 +08:00
|
|
|
|
{ CHAR_MAX+1, strlist, &db_flags, 1, 1, 0, "basic", 0, "debug" },
|
2013-05-22 14:14:19 +08:00
|
|
|
|
{ CHAR_MAX+2, string, &jobserver_fds, 1, 1, 0, 0, 0, "jobserver-fds" },
|
2013-09-12 16:07:52 +08:00
|
|
|
|
{ CHAR_MAX+3, flag, &trace_flag, 1, 1, 0, 0, 0, "trace" },
|
2006-11-19 04:53:44 +08:00
|
|
|
|
{ CHAR_MAX+4, flag, &inhibit_print_directory_flag, 1, 1, 0, 0, 0,
|
2005-02-28 15:48:22 +08:00
|
|
|
|
"no-print-directory" },
|
2006-11-19 04:53:44 +08:00
|
|
|
|
{ CHAR_MAX+5, flag, &warn_undefined_variables_flag, 1, 1, 0, 0, 0,
|
2005-02-28 15:48:22 +08:00
|
|
|
|
"warn-undefined-variables" },
|
2013-11-24 16:21:40 +08:00
|
|
|
|
{ CHAR_MAX+6, strlist, &eval_strings, 1, 0, 0, 0, 0, "eval" },
|
2013-05-22 14:14:19 +08:00
|
|
|
|
{ CHAR_MAX+7, string, &sync_mutex, 1, 1, 0, 0, 0, "sync-mutex" },
|
2005-07-12 12:35:13 +08:00
|
|
|
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }
|
1992-01-30 07:54:36 +08:00
|
|
|
|
};
|
|
|
|
|
|
1992-05-11 13:28:52 +08:00
|
|
|
|
/* Secondary long names for options. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1992-05-11 13:28:52 +08:00
|
|
|
|
static struct option long_option_aliases[] =
|
|
|
|
|
{
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{ "quiet", no_argument, 0, 's' },
|
|
|
|
|
{ "stop", no_argument, 0, 'S' },
|
|
|
|
|
{ "new-file", required_argument, 0, 'W' },
|
|
|
|
|
{ "assume-new", required_argument, 0, 'W' },
|
|
|
|
|
{ "assume-old", required_argument, 0, 'o' },
|
|
|
|
|
{ "max-load", optional_argument, 0, 'l' },
|
|
|
|
|
{ "dry-run", no_argument, 0, 'n' },
|
|
|
|
|
{ "recon", no_argument, 0, 'n' },
|
|
|
|
|
{ "makefile", required_argument, 0, 'f' },
|
1992-05-11 13:28:52 +08:00
|
|
|
|
};
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1994-09-09 13:37:40 +08:00
|
|
|
|
/* List of goal targets. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1994-09-09 13:37:40 +08:00
|
|
|
|
static struct dep *goals, *lastgoal;
|
1994-09-09 14:45:51 +08:00
|
|
|
|
|
|
|
|
|
/* List of variables which were defined on the command line
|
|
|
|
|
(or, equivalently, in MAKEFLAGS). */
|
|
|
|
|
|
|
|
|
|
struct command_variable
|
|
|
|
|
{
|
|
|
|
|
struct command_variable *next;
|
|
|
|
|
struct variable *variable;
|
|
|
|
|
};
|
|
|
|
|
static struct command_variable *command_variables;
|
1992-05-11 13:28:52 +08:00
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* The name we were invoked with. */
|
|
|
|
|
|
2014-07-12 18:01:18 +08:00
|
|
|
|
#ifdef WINDOWS32
|
|
|
|
|
/* On MS-Windows, we chop off the .exe suffix in 'main', so this
|
|
|
|
|
cannot be 'const'. */
|
|
|
|
|
char *program;
|
|
|
|
|
#else
|
2014-04-26 05:10:47 +08:00
|
|
|
|
const char *program;
|
2014-07-12 18:01:18 +08:00
|
|
|
|
#endif
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1994-07-26 07:33:26 +08:00
|
|
|
|
/* Our current directory before processing any -C options. */
|
|
|
|
|
|
|
|
|
|
char *directory_before_chdir;
|
|
|
|
|
|
1993-02-05 02:23:19 +08:00
|
|
|
|
/* Our current directory after processing all -C options. */
|
|
|
|
|
|
|
|
|
|
char *starting_directory;
|
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* Value of the MAKELEVEL variable at startup (or 0). */
|
|
|
|
|
|
|
|
|
|
unsigned int makelevel;
|
|
|
|
|
|
2009-06-04 14:30:27 +08:00
|
|
|
|
/* Pointer to the value of the .DEFAULT_GOAL special variable.
|
|
|
|
|
The value will be the name of the goal to remake if the command line
|
|
|
|
|
does not override it. It can be set by the makefile, or else it's
|
|
|
|
|
the first target defined in the makefile whose name does not start
|
|
|
|
|
with '.'. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2009-06-04 14:30:27 +08:00
|
|
|
|
struct variable * default_goal_var;
|
2005-02-28 06:24:30 +08:00
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* Pointer to structure for the file .DEFAULT
|
|
|
|
|
whose commands are used for any file that has none of its own.
|
|
|
|
|
This is zero if the makefiles do not define .DEFAULT. */
|
|
|
|
|
|
|
|
|
|
struct file *default_file;
|
1994-09-30 09:04:54 +08:00
|
|
|
|
|
2012-03-04 08:24:20 +08:00
|
|
|
|
/* Nonzero if we have seen the magic '.POSIX' target.
|
1994-09-30 09:04:54 +08:00
|
|
|
|
This turns on pedantic compliance with POSIX.2. */
|
|
|
|
|
|
|
|
|
|
int posix_pedantic;
|
1997-08-19 02:11:04 +08:00
|
|
|
|
|
2005-10-24 21:01:39 +08:00
|
|
|
|
/* Nonzero if we have seen the '.SECONDEXPANSION' target.
|
|
|
|
|
This turns on secondary expansion of prerequisites. */
|
|
|
|
|
|
|
|
|
|
int second_expansion;
|
|
|
|
|
|
2010-07-12 13:23:19 +08:00
|
|
|
|
/* Nonzero if we have seen the '.ONESHELL' target.
|
|
|
|
|
This causes the entire recipe to be handed to SHELL
|
|
|
|
|
as a single string, potentially containing newlines. */
|
|
|
|
|
|
|
|
|
|
int one_shell;
|
|
|
|
|
|
2013-05-06 08:19:00 +08:00
|
|
|
|
/* One of OUTPUT_SYNC_* if the "--output-sync" option was given. This
|
|
|
|
|
attempts to synchronize the output of parallel jobs such that the results
|
|
|
|
|
of each job stay together. */
|
2013-04-15 03:38:07 +08:00
|
|
|
|
|
2013-05-13 13:30:24 +08:00
|
|
|
|
int output_sync = OUTPUT_SYNC_NONE;
|
|
|
|
|
|
2013-09-12 16:07:52 +08:00
|
|
|
|
/* Nonzero if the "--trace" option was given. */
|
2013-05-13 13:30:24 +08:00
|
|
|
|
|
2013-09-12 16:07:52 +08:00
|
|
|
|
int trace_flag = 0;
|
2013-04-15 03:38:07 +08:00
|
|
|
|
|
2012-03-04 08:24:20 +08:00
|
|
|
|
/* Nonzero if we have seen the '.NOTPARALLEL' target.
|
1999-11-17 15:33:47 +08:00
|
|
|
|
This turns off parallel builds for this invocation of make. */
|
|
|
|
|
|
|
|
|
|
int not_parallel;
|
|
|
|
|
|
1997-08-19 02:11:04 +08:00
|
|
|
|
/* Nonzero if some rule detected clock skew; we keep track so (a) we only
|
|
|
|
|
print one warning about it during the run, and (b) we can print a final
|
|
|
|
|
warning at the end of the run. */
|
|
|
|
|
|
|
|
|
|
int clock_skew_detected;
|
2013-06-22 12:22:08 +08:00
|
|
|
|
|
|
|
|
|
/* Map of possible stop characters for searching strings. */
|
|
|
|
|
#ifndef UCHAR_MAX
|
|
|
|
|
# define UCHAR_MAX 255
|
|
|
|
|
#endif
|
|
|
|
|
unsigned short stopchar_map[UCHAR_MAX + 1] = {0};
|
|
|
|
|
|
2013-09-22 05:24:59 +08:00
|
|
|
|
/* If output-sync is enabled we'll collect all the output generated due to
|
|
|
|
|
options, while reading makefiles, etc. */
|
|
|
|
|
|
|
|
|
|
struct output make_sync;
|
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
|
|
|
|
/* Mask of signals that are being caught with fatal_error_signal. */
|
1992-05-01 06:17:12 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
#ifdef POSIX
|
1992-05-01 06:17:12 +08:00
|
|
|
|
sigset_t fatal_signal_set;
|
|
|
|
|
#else
|
2013-01-20 13:55:57 +08:00
|
|
|
|
# ifdef HAVE_SIGSETMASK
|
1992-01-30 07:54:36 +08:00
|
|
|
|
int fatal_signal_mask;
|
2002-05-10 11:15:07 +08:00
|
|
|
|
# endif
|
1992-05-01 06:17:12 +08:00
|
|
|
|
#endif
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2010-07-19 15:10:53 +08:00
|
|
|
|
#if !HAVE_DECL_BSD_SIGNAL && !defined bsd_signal
|
2001-06-01 11:56:50 +08:00
|
|
|
|
# if !defined HAVE_SIGACTION
|
|
|
|
|
# define bsd_signal signal
|
|
|
|
|
# else
|
2009-06-09 23:35:38 +08:00
|
|
|
|
typedef RETSIGTYPE (*bsd_signal_ret_t) (int);
|
2002-05-10 11:15:07 +08:00
|
|
|
|
|
|
|
|
|
static bsd_signal_ret_t
|
2002-10-15 05:54:04 +08:00
|
|
|
|
bsd_signal (int sig, bsd_signal_ret_t func)
|
2001-06-01 11:56:50 +08:00
|
|
|
|
{
|
|
|
|
|
struct sigaction act, oact;
|
|
|
|
|
act.sa_handler = func;
|
|
|
|
|
act.sa_flags = SA_RESTART;
|
|
|
|
|
sigemptyset (&act.sa_mask);
|
|
|
|
|
sigaddset (&act.sa_mask, sig);
|
|
|
|
|
if (sigaction (sig, &act, &oact) != 0)
|
|
|
|
|
return SIG_ERR;
|
|
|
|
|
return oact.sa_handler;
|
|
|
|
|
}
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-07-11 14:38:57 +08:00
|
|
|
|
static void
|
2002-10-15 05:54:04 +08:00
|
|
|
|
initialize_global_hash_tables (void)
|
2002-07-11 14:38:57 +08:00
|
|
|
|
{
|
|
|
|
|
init_hash_global_variable_set ();
|
2006-02-10 13:29:00 +08:00
|
|
|
|
strcache_init ();
|
2002-07-11 14:38:57 +08:00
|
|
|
|
init_hash_files ();
|
|
|
|
|
hash_init_directories ();
|
|
|
|
|
hash_init_function_table ();
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-22 12:22:08 +08:00
|
|
|
|
/* This character map locate stop chars when parsing GNU makefiles.
|
|
|
|
|
Each element is true if we should stop parsing on that character. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
initialize_stopchar_map ()
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
stopchar_map[(int)'\0'] = MAP_NUL;
|
|
|
|
|
stopchar_map[(int)'#'] = MAP_COMMENT;
|
|
|
|
|
stopchar_map[(int)';'] = MAP_SEMI;
|
|
|
|
|
stopchar_map[(int)'='] = MAP_EQUALS;
|
|
|
|
|
stopchar_map[(int)':'] = MAP_COLON;
|
|
|
|
|
stopchar_map[(int)'%'] = MAP_PERCENT;
|
|
|
|
|
stopchar_map[(int)'|'] = MAP_PIPE;
|
2013-10-06 04:10:30 +08:00
|
|
|
|
stopchar_map[(int)'.'] = MAP_DOT | MAP_USERFUNC;
|
2013-06-22 12:22:08 +08:00
|
|
|
|
stopchar_map[(int)','] = MAP_COMMA;
|
|
|
|
|
stopchar_map[(int)'$'] = MAP_VARIABLE;
|
|
|
|
|
|
2013-10-06 04:10:30 +08:00
|
|
|
|
stopchar_map[(int)'-'] = MAP_USERFUNC;
|
|
|
|
|
stopchar_map[(int)'_'] = MAP_USERFUNC;
|
|
|
|
|
|
2014-02-03 06:28:46 +08:00
|
|
|
|
stopchar_map[(int)'/'] = MAP_DIRSEP;
|
2013-06-22 12:22:08 +08:00
|
|
|
|
#if defined(VMS)
|
2014-02-03 06:28:46 +08:00
|
|
|
|
stopchar_map[(int)']'] = MAP_DIRSEP;
|
2013-06-22 12:22:08 +08:00
|
|
|
|
#elif defined(HAVE_DOS_PATHS)
|
2014-02-03 06:28:46 +08:00
|
|
|
|
stopchar_map[(int)'\\'] = MAP_DIRSEP;
|
2013-06-22 12:22:08 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
for (i = 1; i <= UCHAR_MAX; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (isblank(i))
|
|
|
|
|
stopchar_map[i] = MAP_BLANK;
|
|
|
|
|
if (isspace(i))
|
|
|
|
|
stopchar_map[i] |= MAP_SPACE;
|
2013-10-06 04:10:30 +08:00
|
|
|
|
if (isalnum(i))
|
|
|
|
|
stopchar_map[i] = MAP_USERFUNC;
|
2013-06-22 12:22:08 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-20 11:02:26 +08:00
|
|
|
|
static const char *
|
2014-04-26 05:10:47 +08:00
|
|
|
|
expand_command_line_file (const char *name)
|
1993-06-03 04:51:28 +08:00
|
|
|
|
{
|
2007-03-20 11:02:26 +08:00
|
|
|
|
const char *cp;
|
|
|
|
|
char *expanded = 0;
|
|
|
|
|
|
1995-10-11 02:59:08 +08:00
|
|
|
|
if (name[0] == '\0')
|
2013-11-24 11:23:52 +08:00
|
|
|
|
O (fatal, NILF, _("empty string invalid as file name"));
|
1995-10-11 02:59:08 +08:00
|
|
|
|
|
1993-06-08 08:08:45 +08:00
|
|
|
|
if (name[0] == '~')
|
|
|
|
|
{
|
2007-03-20 11:02:26 +08:00
|
|
|
|
expanded = tilde_expand (name);
|
2014-04-26 05:10:47 +08:00
|
|
|
|
if (expanded && expanded[0] != '\0')
|
2013-01-20 13:55:57 +08:00
|
|
|
|
name = expanded;
|
1993-06-08 08:08:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
1993-06-03 04:51:28 +08:00
|
|
|
|
/* This is also done in parse_file_seq, so this is redundant
|
|
|
|
|
for names read from makefiles. It is here for names passed
|
|
|
|
|
on the command line. */
|
2014-04-26 05:10:47 +08:00
|
|
|
|
while (name[0] == '.' && name[1] == '/')
|
1993-06-03 04:51:28 +08:00
|
|
|
|
{
|
|
|
|
|
name += 2;
|
2014-04-26 05:10:47 +08:00
|
|
|
|
while (name[0] == '/')
|
2013-01-20 13:55:57 +08:00
|
|
|
|
/* Skip following slashes: ".//foo" is "foo", not "/foo". */
|
|
|
|
|
++name;
|
1993-06-03 04:51:28 +08:00
|
|
|
|
}
|
1995-11-26 09:37:07 +08:00
|
|
|
|
|
2014-04-26 05:10:47 +08:00
|
|
|
|
if (name[0] == '\0')
|
1993-06-03 04:51:28 +08:00
|
|
|
|
{
|
2014-04-26 05:10:47 +08:00
|
|
|
|
/* Nothing else but one or more "./", maybe plus slashes! */
|
|
|
|
|
name = "./";
|
1993-06-03 04:51:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2007-03-20 11:02:26 +08:00
|
|
|
|
cp = strcache_add (name);
|
|
|
|
|
|
2014-04-26 05:10:47 +08:00
|
|
|
|
free (expanded);
|
2007-03-20 11:02:26 +08:00
|
|
|
|
|
|
|
|
|
return cp;
|
1993-06-03 04:51:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
1995-01-26 14:29:18 +08:00
|
|
|
|
/* Toggle -d on receipt of SIGUSR1. */
|
|
|
|
|
|
2004-03-22 23:11:48 +08:00
|
|
|
|
#ifdef SIGUSR1
|
1995-01-26 14:29:18 +08:00
|
|
|
|
static RETSIGTYPE
|
2004-02-24 21:50:19 +08:00
|
|
|
|
debug_signal_handler (int sig UNUSED)
|
1995-01-26 14:29:18 +08:00
|
|
|
|
{
|
1999-11-27 16:09:42 +08:00
|
|
|
|
db_level = db_level ? DB_NONE : DB_BASIC;
|
|
|
|
|
}
|
2004-03-22 23:11:48 +08:00
|
|
|
|
#endif
|
1999-11-27 16:09:42 +08:00
|
|
|
|
|
|
|
|
|
static void
|
2002-10-15 05:54:04 +08:00
|
|
|
|
decode_debug_flags (void)
|
1999-11-27 16:09:42 +08:00
|
|
|
|
{
|
2007-03-20 11:02:26 +08:00
|
|
|
|
const char **pp;
|
1999-11-27 16:09:42 +08:00
|
|
|
|
|
2000-01-23 15:05:16 +08:00
|
|
|
|
if (debug_flag)
|
|
|
|
|
db_level = DB_ALL;
|
|
|
|
|
|
2013-06-22 11:59:38 +08:00
|
|
|
|
if (db_flags)
|
|
|
|
|
for (pp=db_flags->list; *pp; ++pp)
|
|
|
|
|
{
|
|
|
|
|
const char *p = *pp;
|
1999-11-27 16:09:42 +08:00
|
|
|
|
|
2013-06-22 11:59:38 +08:00
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
switch (tolower (p[0]))
|
|
|
|
|
{
|
|
|
|
|
case 'a':
|
|
|
|
|
db_level |= DB_ALL;
|
|
|
|
|
break;
|
|
|
|
|
case 'b':
|
|
|
|
|
db_level |= DB_BASIC;
|
|
|
|
|
break;
|
|
|
|
|
case 'i':
|
|
|
|
|
db_level |= DB_BASIC | DB_IMPLICIT;
|
|
|
|
|
break;
|
|
|
|
|
case 'j':
|
|
|
|
|
db_level |= DB_JOBS;
|
|
|
|
|
break;
|
|
|
|
|
case 'm':
|
|
|
|
|
db_level |= DB_BASIC | DB_MAKEFILES;
|
|
|
|
|
break;
|
2013-09-15 09:01:10 +08:00
|
|
|
|
case 'n':
|
|
|
|
|
db_level = 0;
|
|
|
|
|
break;
|
2013-06-22 11:59:38 +08:00
|
|
|
|
case 'v':
|
|
|
|
|
db_level |= DB_BASIC | DB_VERBOSE;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2013-11-24 11:23:52 +08:00
|
|
|
|
OS (fatal, NILF,
|
|
|
|
|
_("unknown debug level specification '%s'"), p);
|
2013-06-22 11:59:38 +08:00
|
|
|
|
}
|
1999-11-27 16:09:42 +08:00
|
|
|
|
|
2013-06-22 11:59:38 +08:00
|
|
|
|
while (*(++p) != '\0')
|
|
|
|
|
if (*p == ',' || *p == ' ')
|
2013-09-15 09:01:10 +08:00
|
|
|
|
{
|
|
|
|
|
++p;
|
|
|
|
|
break;
|
|
|
|
|
}
|
1999-11-27 16:09:42 +08:00
|
|
|
|
|
2013-06-22 11:59:38 +08:00
|
|
|
|
if (*p == '\0')
|
1999-11-27 16:09:42 +08:00
|
|
|
|
break;
|
2013-06-22 11:59:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
1999-11-27 16:09:42 +08:00
|
|
|
|
|
2013-06-22 11:59:38 +08:00
|
|
|
|
if (db_level)
|
|
|
|
|
verify_flag = 1;
|
2013-09-15 09:01:10 +08:00
|
|
|
|
|
|
|
|
|
if (! db_level)
|
|
|
|
|
debug_flag = 0;
|
1995-01-26 14:29:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-16 01:22:51 +08:00
|
|
|
|
static void
|
|
|
|
|
decode_output_sync_flags (void)
|
|
|
|
|
{
|
2013-11-24 16:21:40 +08:00
|
|
|
|
if (output_sync_option)
|
2013-04-16 01:22:51 +08:00
|
|
|
|
{
|
2013-11-24 16:21:40 +08:00
|
|
|
|
if (streq (output_sync_option, "none"))
|
2013-04-28 13:19:19 +08:00
|
|
|
|
output_sync = OUTPUT_SYNC_NONE;
|
2013-11-24 16:21:40 +08:00
|
|
|
|
else if (streq (output_sync_option, "line"))
|
2013-05-06 08:19:00 +08:00
|
|
|
|
output_sync = OUTPUT_SYNC_LINE;
|
2013-11-24 16:21:40 +08:00
|
|
|
|
else if (streq (output_sync_option, "target"))
|
2013-04-16 01:22:51 +08:00
|
|
|
|
output_sync = OUTPUT_SYNC_TARGET;
|
2013-11-24 16:21:40 +08:00
|
|
|
|
else if (streq (output_sync_option, "recurse"))
|
2013-05-06 08:19:00 +08:00
|
|
|
|
output_sync = OUTPUT_SYNC_RECURSE;
|
2013-04-16 01:22:51 +08:00
|
|
|
|
else
|
2013-11-24 16:21:40 +08:00
|
|
|
|
OS (fatal, NILF,
|
|
|
|
|
_("unknown output-sync type '%s'"), output_sync_option);
|
2013-04-16 01:22:51 +08:00
|
|
|
|
}
|
Support --output-sync on MS-Windows.
w32/compat/posixfcn.c: New file, with emulations of Posix
functions and Posix functionality for MS-Windows.
w32/subproc/sub_proc.c: Include io.h.
(process_noinherit): New function, forces a file descriptor to not
be inherited by child processes.
(process_easy): Accept two additional arguments, and use them to
set up the standard output and standard error handles of the child
process.
w32/include/sub_proc.h (process_easy): Adjust prototype.
(process_noinherit): Add prototype.
read.c [WINDOWS32]: Include windows.h and sub_proc.h.
makeint.h (LOCALEDIR) [WINDOWS32}: Define to NULL if not
defined. This is needed because the MS-Windows build doesn't have
a canonical place for LOCALEDIR.
(WIN32_LEAN_AND_MEAN) [WINDOWS32]: Define, to avoid getting from
windows.h header too much stuff that could conflict with the code.
main.c <sync_mutex>: New static variable.
<switches>: Add support for "--sync-mutex" switch.
(decode_output_sync_flags): Decode the --sync-mutex= switch.
(prepare_mutex_handle_string) [WINDOWS32]: New function.
(main): Add "output-sync" to .FEATURES.
job.h (CLOSE_ON_EXEC) [WINDOWS32]: Define to call
process_noinherit.
(F_GETFD, F_SETLKW, F_WRLCK, F_UNLCK, struct flock) [WINDOWS32]:
New macros.
(RECORD_SYNC_MUTEX): New macro, a no-op for Posix platforms.
(sync_handle_t): New typedef.
job.c <sync_handle>: Change type to sync_handle_t.
(FD_NOT_EMPTY): Seek to the file's end. Suggested by Frank
Heckenbach <f.heckenbach@fh-soft.de>.
(pump_from_tmp_fd) [WINDOWS32]: Switch to_fd to binary mode for
the duration of this function, and then change back before
returning.
(start_job_command) [WINDOWS32]: Support output_sync mode on
MS-Windows. Use a system-wide mutex instead of locking
stdout/stderr. Call process_easy with two additional arguments:
child->outfd and child->errfd.
(exec_command) [WINDOWS32]: Pass two additional arguments, both
-1, to process_easy, to adjust for the changed function signature.
function.c (windows32_openpipe) [WINDOWS32]: This function now
returns an int, which is -1 if it fails and zero otherwise. It
also calls 'error' instead of 'fatal', to avoid exiting
prematurely.
(func_shell_base) [WINDOWS32]: Call perror_with_name if
windows32_openpipe fails, now that it always returns. This avoids
a compiler warning that error_prefix is not used in the MS-Windows
build.
config.h.W32.template (OUTPUT_SYNC): Define.
build_w32.bat: Add w32/compat/posixfcn.c to compilation and
linking commands.
From Frank Heckenbach <f.heckenbach@fh-soft.de>:
job.c (sync_output): Don't discard the output if
acquire_semaphore fails; instead, dump the output unsynchronized.
2013-04-27 19:20:49 +08:00
|
|
|
|
|
|
|
|
|
if (sync_mutex)
|
2013-11-24 16:21:40 +08:00
|
|
|
|
RECORD_SYNC_MUTEX (sync_mutex);
|
2013-04-16 01:22:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#ifdef WINDOWS32
|
Support --output-sync on MS-Windows.
w32/compat/posixfcn.c: New file, with emulations of Posix
functions and Posix functionality for MS-Windows.
w32/subproc/sub_proc.c: Include io.h.
(process_noinherit): New function, forces a file descriptor to not
be inherited by child processes.
(process_easy): Accept two additional arguments, and use them to
set up the standard output and standard error handles of the child
process.
w32/include/sub_proc.h (process_easy): Adjust prototype.
(process_noinherit): Add prototype.
read.c [WINDOWS32]: Include windows.h and sub_proc.h.
makeint.h (LOCALEDIR) [WINDOWS32}: Define to NULL if not
defined. This is needed because the MS-Windows build doesn't have
a canonical place for LOCALEDIR.
(WIN32_LEAN_AND_MEAN) [WINDOWS32]: Define, to avoid getting from
windows.h header too much stuff that could conflict with the code.
main.c <sync_mutex>: New static variable.
<switches>: Add support for "--sync-mutex" switch.
(decode_output_sync_flags): Decode the --sync-mutex= switch.
(prepare_mutex_handle_string) [WINDOWS32]: New function.
(main): Add "output-sync" to .FEATURES.
job.h (CLOSE_ON_EXEC) [WINDOWS32]: Define to call
process_noinherit.
(F_GETFD, F_SETLKW, F_WRLCK, F_UNLCK, struct flock) [WINDOWS32]:
New macros.
(RECORD_SYNC_MUTEX): New macro, a no-op for Posix platforms.
(sync_handle_t): New typedef.
job.c <sync_handle>: Change type to sync_handle_t.
(FD_NOT_EMPTY): Seek to the file's end. Suggested by Frank
Heckenbach <f.heckenbach@fh-soft.de>.
(pump_from_tmp_fd) [WINDOWS32]: Switch to_fd to binary mode for
the duration of this function, and then change back before
returning.
(start_job_command) [WINDOWS32]: Support output_sync mode on
MS-Windows. Use a system-wide mutex instead of locking
stdout/stderr. Call process_easy with two additional arguments:
child->outfd and child->errfd.
(exec_command) [WINDOWS32]: Pass two additional arguments, both
-1, to process_easy, to adjust for the changed function signature.
function.c (windows32_openpipe) [WINDOWS32]: This function now
returns an int, which is -1 if it fails and zero otherwise. It
also calls 'error' instead of 'fatal', to avoid exiting
prematurely.
(func_shell_base) [WINDOWS32]: Call perror_with_name if
windows32_openpipe fails, now that it always returns. This avoids
a compiler warning that error_prefix is not used in the MS-Windows
build.
config.h.W32.template (OUTPUT_SYNC): Define.
build_w32.bat: Add w32/compat/posixfcn.c to compilation and
linking commands.
From Frank Heckenbach <f.heckenbach@fh-soft.de>:
job.c (sync_output): Don't discard the output if
acquire_semaphore fails; instead, dump the output unsynchronized.
2013-04-27 19:20:49 +08:00
|
|
|
|
|
2013-09-22 05:37:59 +08:00
|
|
|
|
#ifndef NO_OUTPUT_SYNC
|
2013-05-17 21:24:13 +08:00
|
|
|
|
|
Support --output-sync on MS-Windows.
w32/compat/posixfcn.c: New file, with emulations of Posix
functions and Posix functionality for MS-Windows.
w32/subproc/sub_proc.c: Include io.h.
(process_noinherit): New function, forces a file descriptor to not
be inherited by child processes.
(process_easy): Accept two additional arguments, and use them to
set up the standard output and standard error handles of the child
process.
w32/include/sub_proc.h (process_easy): Adjust prototype.
(process_noinherit): Add prototype.
read.c [WINDOWS32]: Include windows.h and sub_proc.h.
makeint.h (LOCALEDIR) [WINDOWS32}: Define to NULL if not
defined. This is needed because the MS-Windows build doesn't have
a canonical place for LOCALEDIR.
(WIN32_LEAN_AND_MEAN) [WINDOWS32]: Define, to avoid getting from
windows.h header too much stuff that could conflict with the code.
main.c <sync_mutex>: New static variable.
<switches>: Add support for "--sync-mutex" switch.
(decode_output_sync_flags): Decode the --sync-mutex= switch.
(prepare_mutex_handle_string) [WINDOWS32]: New function.
(main): Add "output-sync" to .FEATURES.
job.h (CLOSE_ON_EXEC) [WINDOWS32]: Define to call
process_noinherit.
(F_GETFD, F_SETLKW, F_WRLCK, F_UNLCK, struct flock) [WINDOWS32]:
New macros.
(RECORD_SYNC_MUTEX): New macro, a no-op for Posix platforms.
(sync_handle_t): New typedef.
job.c <sync_handle>: Change type to sync_handle_t.
(FD_NOT_EMPTY): Seek to the file's end. Suggested by Frank
Heckenbach <f.heckenbach@fh-soft.de>.
(pump_from_tmp_fd) [WINDOWS32]: Switch to_fd to binary mode for
the duration of this function, and then change back before
returning.
(start_job_command) [WINDOWS32]: Support output_sync mode on
MS-Windows. Use a system-wide mutex instead of locking
stdout/stderr. Call process_easy with two additional arguments:
child->outfd and child->errfd.
(exec_command) [WINDOWS32]: Pass two additional arguments, both
-1, to process_easy, to adjust for the changed function signature.
function.c (windows32_openpipe) [WINDOWS32]: This function now
returns an int, which is -1 if it fails and zero otherwise. It
also calls 'error' instead of 'fatal', to avoid exiting
prematurely.
(func_shell_base) [WINDOWS32]: Call perror_with_name if
windows32_openpipe fails, now that it always returns. This avoids
a compiler warning that error_prefix is not used in the MS-Windows
build.
config.h.W32.template (OUTPUT_SYNC): Define.
build_w32.bat: Add w32/compat/posixfcn.c to compilation and
linking commands.
From Frank Heckenbach <f.heckenbach@fh-soft.de>:
job.c (sync_output): Don't discard the output if
acquire_semaphore fails; instead, dump the output unsynchronized.
2013-04-27 19:20:49 +08:00
|
|
|
|
/* This is called from start_job_command when it detects that
|
|
|
|
|
output_sync option is in effect. The handle to the synchronization
|
|
|
|
|
mutex is passed, as a string, to sub-makes via the --sync-mutex
|
|
|
|
|
command-line argument. */
|
|
|
|
|
void
|
|
|
|
|
prepare_mutex_handle_string (sync_handle_t handle)
|
|
|
|
|
{
|
|
|
|
|
if (!sync_mutex)
|
|
|
|
|
{
|
|
|
|
|
/* Prepare the mutex handle string for our children. */
|
2013-11-24 16:21:40 +08:00
|
|
|
|
/* 2 hex digits per byte + 2 characters for "0x" + null. */
|
|
|
|
|
sync_mutex = xmalloc ((2 * sizeof (sync_handle_t)) + 2 + 1);
|
2013-11-27 23:57:01 +08:00
|
|
|
|
sprintf (sync_mutex, "0x%Ix", handle);
|
Support --output-sync on MS-Windows.
w32/compat/posixfcn.c: New file, with emulations of Posix
functions and Posix functionality for MS-Windows.
w32/subproc/sub_proc.c: Include io.h.
(process_noinherit): New function, forces a file descriptor to not
be inherited by child processes.
(process_easy): Accept two additional arguments, and use them to
set up the standard output and standard error handles of the child
process.
w32/include/sub_proc.h (process_easy): Adjust prototype.
(process_noinherit): Add prototype.
read.c [WINDOWS32]: Include windows.h and sub_proc.h.
makeint.h (LOCALEDIR) [WINDOWS32}: Define to NULL if not
defined. This is needed because the MS-Windows build doesn't have
a canonical place for LOCALEDIR.
(WIN32_LEAN_AND_MEAN) [WINDOWS32]: Define, to avoid getting from
windows.h header too much stuff that could conflict with the code.
main.c <sync_mutex>: New static variable.
<switches>: Add support for "--sync-mutex" switch.
(decode_output_sync_flags): Decode the --sync-mutex= switch.
(prepare_mutex_handle_string) [WINDOWS32]: New function.
(main): Add "output-sync" to .FEATURES.
job.h (CLOSE_ON_EXEC) [WINDOWS32]: Define to call
process_noinherit.
(F_GETFD, F_SETLKW, F_WRLCK, F_UNLCK, struct flock) [WINDOWS32]:
New macros.
(RECORD_SYNC_MUTEX): New macro, a no-op for Posix platforms.
(sync_handle_t): New typedef.
job.c <sync_handle>: Change type to sync_handle_t.
(FD_NOT_EMPTY): Seek to the file's end. Suggested by Frank
Heckenbach <f.heckenbach@fh-soft.de>.
(pump_from_tmp_fd) [WINDOWS32]: Switch to_fd to binary mode for
the duration of this function, and then change back before
returning.
(start_job_command) [WINDOWS32]: Support output_sync mode on
MS-Windows. Use a system-wide mutex instead of locking
stdout/stderr. Call process_easy with two additional arguments:
child->outfd and child->errfd.
(exec_command) [WINDOWS32]: Pass two additional arguments, both
-1, to process_easy, to adjust for the changed function signature.
function.c (windows32_openpipe) [WINDOWS32]: This function now
returns an int, which is -1 if it fails and zero otherwise. It
also calls 'error' instead of 'fatal', to avoid exiting
prematurely.
(func_shell_base) [WINDOWS32]: Call perror_with_name if
windows32_openpipe fails, now that it always returns. This avoids
a compiler warning that error_prefix is not used in the MS-Windows
build.
config.h.W32.template (OUTPUT_SYNC): Define.
build_w32.bat: Add w32/compat/posixfcn.c to compilation and
linking commands.
From Frank Heckenbach <f.heckenbach@fh-soft.de>:
job.c (sync_output): Don't discard the output if
acquire_semaphore fails; instead, dump the output unsynchronized.
2013-04-27 19:20:49 +08:00
|
|
|
|
define_makeflags (1, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-22 05:37:59 +08:00
|
|
|
|
#endif /* NO_OUTPUT_SYNC */
|
2013-05-17 21:24:13 +08:00
|
|
|
|
|
1997-04-07 15:21:16 +08:00
|
|
|
|
/*
|
|
|
|
|
* HANDLE runtime exceptions by avoiding a requestor on the GUI. Capture
|
|
|
|
|
* exception and print it to stderr instead.
|
|
|
|
|
*
|
1999-11-27 16:09:42 +08:00
|
|
|
|
* If ! DB_VERBOSE, just print a simple message and exit.
|
|
|
|
|
* If DB_VERBOSE, print a more verbose message.
|
1997-04-07 15:21:16 +08:00
|
|
|
|
* If compiled for DEBUG, let exception pass through to GUI so that
|
|
|
|
|
* debuggers can attach.
|
|
|
|
|
*/
|
|
|
|
|
LONG WINAPI
|
2013-05-17 14:29:46 +08:00
|
|
|
|
handle_runtime_exceptions (struct _EXCEPTION_POINTERS *exinfo)
|
1997-04-07 15:21:16 +08:00
|
|
|
|
{
|
|
|
|
|
PEXCEPTION_RECORD exrec = exinfo->ExceptionRecord;
|
2013-05-17 14:29:46 +08:00
|
|
|
|
LPSTR cmdline = GetCommandLine ();
|
|
|
|
|
LPSTR prg = strtok (cmdline, " ");
|
1997-04-07 15:21:16 +08:00
|
|
|
|
CHAR errmsg[1024];
|
|
|
|
|
#ifdef USE_EVENT_LOG
|
|
|
|
|
HANDLE hEventSource;
|
|
|
|
|
LPTSTR lpszStrings[1];
|
|
|
|
|
#endif
|
|
|
|
|
|
1999-11-27 16:09:42 +08:00
|
|
|
|
if (! ISDB (DB_VERBOSE))
|
1997-04-07 15:21:16 +08:00
|
|
|
|
{
|
2013-05-17 14:29:46 +08:00
|
|
|
|
sprintf (errmsg,
|
|
|
|
|
_("%s: Interrupt/Exception caught (code = 0x%lx, addr = 0x%p)\n"),
|
|
|
|
|
prg, exrec->ExceptionCode, exrec->ExceptionAddress);
|
|
|
|
|
fprintf (stderr, errmsg);
|
|
|
|
|
exit (255);
|
1997-04-07 15:21:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-05-17 14:29:46 +08:00
|
|
|
|
sprintf (errmsg,
|
|
|
|
|
_("\nUnhandled exception filter called from program %s\nExceptionCode = %lx\nExceptionFlags = %lx\nExceptionAddress = 0x%p\n"),
|
|
|
|
|
prg, exrec->ExceptionCode, exrec->ExceptionFlags,
|
|
|
|
|
exrec->ExceptionAddress);
|
1997-04-07 15:21:16 +08:00
|
|
|
|
|
|
|
|
|
if (exrec->ExceptionCode == EXCEPTION_ACCESS_VIOLATION
|
|
|
|
|
&& exrec->NumberParameters >= 2)
|
2013-05-17 14:29:46 +08:00
|
|
|
|
sprintf (&errmsg[strlen(errmsg)],
|
|
|
|
|
(exrec->ExceptionInformation[0]
|
|
|
|
|
? _("Access violation: write operation at address 0x%p\n")
|
|
|
|
|
: _("Access violation: read operation at address 0x%p\n")),
|
|
|
|
|
(PVOID)exrec->ExceptionInformation[1]);
|
1997-04-07 15:21:16 +08:00
|
|
|
|
|
|
|
|
|
/* turn this on if we want to put stuff in the event log too */
|
|
|
|
|
#ifdef USE_EVENT_LOG
|
2013-05-17 14:29:46 +08:00
|
|
|
|
hEventSource = RegisterEventSource (NULL, "GNU Make");
|
1997-04-07 15:21:16 +08:00
|
|
|
|
lpszStrings[0] = errmsg;
|
|
|
|
|
|
|
|
|
|
if (hEventSource != NULL)
|
|
|
|
|
{
|
2013-05-17 14:29:46 +08:00
|
|
|
|
ReportEvent (hEventSource, /* handle of event source */
|
|
|
|
|
EVENTLOG_ERROR_TYPE, /* event type */
|
|
|
|
|
0, /* event category */
|
|
|
|
|
0, /* event ID */
|
|
|
|
|
NULL, /* current user's SID */
|
|
|
|
|
1, /* strings in lpszStrings */
|
|
|
|
|
0, /* no bytes of raw data */
|
|
|
|
|
lpszStrings, /* array of error strings */
|
|
|
|
|
NULL); /* no raw data */
|
|
|
|
|
|
|
|
|
|
(VOID) DeregisterEventSource (hEventSource);
|
1997-04-07 15:21:16 +08:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Write the error to stderr too */
|
2013-05-17 14:29:46 +08:00
|
|
|
|
fprintf (stderr, errmsg);
|
1997-04-07 15:21:16 +08:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
|
|
|
#else
|
2013-05-17 14:29:46 +08:00
|
|
|
|
exit (255);
|
1998-07-31 04:54:47 +08:00
|
|
|
|
return (255); /* not reached */
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* On WIN32 systems we don't have the luxury of a /bin directory that
|
|
|
|
|
* is mapped globally to every drive mounted to the system. Since make could
|
2013-04-30 21:37:03 +08:00
|
|
|
|
* be invoked from any drive, and we don't want to propagate /bin/sh
|
1998-07-31 04:54:47 +08:00
|
|
|
|
* to every single drive. Allow ourselves a chance to search for
|
|
|
|
|
* a value for default shell here (if the default path does not exist).
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int
|
2007-03-20 11:02:26 +08:00
|
|
|
|
find_and_set_default_shell (const char *token)
|
1998-07-31 04:54:47 +08:00
|
|
|
|
{
|
|
|
|
|
int sh_found = 0;
|
2007-03-20 11:02:26 +08:00
|
|
|
|
char *atoken = 0;
|
2014-04-26 05:10:47 +08:00
|
|
|
|
const char *search_token;
|
2004-09-21 20:07:12 +08:00
|
|
|
|
char *tokend;
|
1998-07-31 04:54:47 +08:00
|
|
|
|
PATH_VAR(sh_path);
|
2014-04-26 05:10:47 +08:00
|
|
|
|
extern const char *default_shell;
|
1998-07-31 04:54:47 +08:00
|
|
|
|
|
|
|
|
|
if (!token)
|
|
|
|
|
search_token = default_shell;
|
|
|
|
|
else
|
2014-04-26 05:10:47 +08:00
|
|
|
|
search_token = atoken = xstrdup (token);
|
2004-09-21 20:07:12 +08:00
|
|
|
|
|
|
|
|
|
/* If the user explicitly requests the DOS cmd shell, obey that request.
|
|
|
|
|
However, make sure that's what they really want by requiring the value
|
|
|
|
|
of SHELL either equal, or have a final path element of, "cmd" or
|
|
|
|
|
"cmd.exe" case-insensitive. */
|
|
|
|
|
tokend = search_token + strlen (search_token) - 3;
|
|
|
|
|
if (((tokend == search_token
|
|
|
|
|
|| (tokend > search_token
|
|
|
|
|
&& (tokend[-1] == '/' || tokend[-1] == '\\')))
|
2007-05-09 10:01:53 +08:00
|
|
|
|
&& !strcasecmp (tokend, "cmd"))
|
2004-09-21 20:07:12 +08:00
|
|
|
|
|| ((tokend - 4 == search_token
|
|
|
|
|
|| (tokend - 4 > search_token
|
|
|
|
|
&& (tokend[-5] == '/' || tokend[-5] == '\\')))
|
2013-05-17 14:29:46 +08:00
|
|
|
|
&& !strcasecmp (tokend - 4, "cmd.exe")))
|
|
|
|
|
{
|
|
|
|
|
batch_mode_shell = 1;
|
|
|
|
|
unixy_shell = 0;
|
|
|
|
|
sprintf (sh_path, "%s", search_token);
|
|
|
|
|
default_shell = xstrdup (w32ify (sh_path, 0));
|
|
|
|
|
DB (DB_VERBOSE, (_("find_and_set_shell() setting default_shell = %s\n"),
|
|
|
|
|
default_shell));
|
|
|
|
|
sh_found = 1;
|
|
|
|
|
}
|
|
|
|
|
else if (!no_default_sh_exe
|
|
|
|
|
&& (token == NULL || !strcmp (search_token, default_shell)))
|
|
|
|
|
{
|
|
|
|
|
/* no new information, path already set or known */
|
|
|
|
|
sh_found = 1;
|
|
|
|
|
}
|
2013-06-22 21:16:56 +08:00
|
|
|
|
else if (_access (search_token, 0) == 0)
|
2013-05-17 14:29:46 +08:00
|
|
|
|
{
|
|
|
|
|
/* search token path was found */
|
|
|
|
|
sprintf (sh_path, "%s", search_token);
|
|
|
|
|
default_shell = xstrdup (w32ify (sh_path, 0));
|
|
|
|
|
DB (DB_VERBOSE, (_("find_and_set_shell() setting default_shell = %s\n"),
|
|
|
|
|
default_shell));
|
|
|
|
|
sh_found = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
char *p;
|
|
|
|
|
struct variable *v = lookup_variable (STRING_SIZE_TUPLE ("PATH"));
|
1998-07-31 04:54:47 +08:00
|
|
|
|
|
2013-05-17 14:29:46 +08:00
|
|
|
|
/* Search Path for shell */
|
|
|
|
|
if (v && v->value)
|
|
|
|
|
{
|
|
|
|
|
char *ep;
|
1998-07-31 04:54:47 +08:00
|
|
|
|
|
2013-05-17 14:29:46 +08:00
|
|
|
|
p = v->value;
|
|
|
|
|
ep = strchr (p, PATH_SEPARATOR_CHAR);
|
|
|
|
|
|
|
|
|
|
while (ep && *ep)
|
|
|
|
|
{
|
|
|
|
|
*ep = '\0';
|
|
|
|
|
|
2013-09-14 13:04:04 +08:00
|
|
|
|
sprintf (sh_path, "%s/%s", p, search_token);
|
2013-06-22 21:16:56 +08:00
|
|
|
|
if (_access (sh_path, 0) == 0)
|
2013-05-17 14:29:46 +08:00
|
|
|
|
{
|
|
|
|
|
default_shell = xstrdup (w32ify (sh_path, 0));
|
|
|
|
|
sh_found = 1;
|
|
|
|
|
*ep = PATH_SEPARATOR_CHAR;
|
|
|
|
|
|
|
|
|
|
/* terminate loop */
|
|
|
|
|
p += strlen (p);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*ep = PATH_SEPARATOR_CHAR;
|
|
|
|
|
p = ++ep;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ep = strchr (p, PATH_SEPARATOR_CHAR);
|
|
|
|
|
}
|
1998-07-31 04:54:47 +08:00
|
|
|
|
|
2013-05-17 14:29:46 +08:00
|
|
|
|
/* be sure to check last element of Path */
|
2013-09-14 13:04:04 +08:00
|
|
|
|
if (p && *p)
|
|
|
|
|
{
|
|
|
|
|
sprintf (sh_path, "%s/%s", p, search_token);
|
|
|
|
|
if (_access (sh_path, 0) == 0)
|
|
|
|
|
{
|
|
|
|
|
default_shell = xstrdup (w32ify (sh_path, 0));
|
|
|
|
|
sh_found = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-05-17 14:29:46 +08:00
|
|
|
|
|
|
|
|
|
if (sh_found)
|
|
|
|
|
DB (DB_VERBOSE,
|
|
|
|
|
(_("find_and_set_shell() path search set default_shell = %s\n"),
|
|
|
|
|
default_shell));
|
|
|
|
|
}
|
1998-07-31 04:54:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* naive test */
|
2013-05-17 14:29:46 +08:00
|
|
|
|
if (!unixy_shell && sh_found
|
|
|
|
|
&& (strstr (default_shell, "sh") || strstr (default_shell, "SH")))
|
|
|
|
|
{
|
|
|
|
|
unixy_shell = 1;
|
|
|
|
|
batch_mode_shell = 0;
|
|
|
|
|
}
|
1998-07-31 04:54:47 +08:00
|
|
|
|
|
|
|
|
|
#ifdef BATCH_MODE_ONLY_SHELL
|
|
|
|
|
batch_mode_shell = 1;
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#endif
|
1998-07-31 04:54:47 +08:00
|
|
|
|
|
2014-04-26 05:38:08 +08:00
|
|
|
|
free (atoken);
|
2007-03-20 11:02:26 +08:00
|
|
|
|
|
1998-07-31 04:54:47 +08:00
|
|
|
|
return (sh_found);
|
1997-04-07 15:21:16 +08:00
|
|
|
|
}
|
|
|
|
|
#endif /* WINDOWS32 */
|
|
|
|
|
|
2006-11-19 04:53:44 +08:00
|
|
|
|
#ifdef __MSDOS__
|
1997-04-07 15:21:16 +08:00
|
|
|
|
static void
|
2002-10-15 05:54:04 +08:00
|
|
|
|
msdos_return_to_initial_directory (void)
|
1997-04-07 15:21:16 +08:00
|
|
|
|
{
|
|
|
|
|
if (directory_before_chdir)
|
|
|
|
|
chdir (directory_before_chdir);
|
|
|
|
|
}
|
2006-11-19 04:53:44 +08:00
|
|
|
|
#endif /* __MSDOS__ */
|
1997-04-07 15:21:16 +08:00
|
|
|
|
|
2002-10-15 05:54:04 +08:00
|
|
|
|
#ifdef _AMIGA
|
1992-01-30 07:54:36 +08:00
|
|
|
|
int
|
2002-10-15 05:54:04 +08:00
|
|
|
|
main (int argc, char **argv)
|
Thu May 9 13:54:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* GNUmakefile (globfiles): Add AmigaDOS support files.
(distfiles): Add $(amigafiles).
(amigafiles): New variable.
Thu Nov 7 10:18:16 1995 Aaron Digulla <digulla@fh-konstanz.de>
* Added Amiga support in commands.c, dir.c, function.c,
job.c, main.c, make.h, read.c, remake.c
* commands.c: Amiga has neither SIGHUP nor SIGQUIT
* dir.c: Amiga has filenames with Upper- and Lowercase,
but "FileName" is the same as "filename". Added strieq()
which is use to compare filenames. This is like streq()
on all other systems. Also there is no such thing as
"." under AmigaDOS.
* function.c: On Amiga, the environment is not passed as envp,
there are no pipes and Amiga can't fork. Use my own function
to create a new child.
* job.c: default_shell is "" (The system automatically chooses
a shell for me). Have to use the same workaround as MSDOS for
running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't
known on Amiga. Cloned code to run children from MSDOS. Own
version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga.
* main.c: Force stack to 20000 bytes. Read environment from ENV:
device. On Amiga, exec_command() does return, so I exit()
afterwards.
* make.h: Added strieq() to compare filenames.
* read.c: Amiga needs special extension to have passwd. Only
one include-dir. "Makefile" and "makefile" are the same.
Added "SMakefile". Added special code to handle device names (xxx:)
and "./" in rules.
* remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib"
instead of "lib%s.a".
* main.c, rule.c, variable.c: Avoid floats at all costs.
* vpath.c: Get rid of as many alloca()s as possible.
1996-05-10 02:02:06 +08:00
|
|
|
|
#else
|
2002-10-15 05:54:04 +08:00
|
|
|
|
int
|
|
|
|
|
main (int argc, char **argv, char **envp)
|
Thu May 9 13:54:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* GNUmakefile (globfiles): Add AmigaDOS support files.
(distfiles): Add $(amigafiles).
(amigafiles): New variable.
Thu Nov 7 10:18:16 1995 Aaron Digulla <digulla@fh-konstanz.de>
* Added Amiga support in commands.c, dir.c, function.c,
job.c, main.c, make.h, read.c, remake.c
* commands.c: Amiga has neither SIGHUP nor SIGQUIT
* dir.c: Amiga has filenames with Upper- and Lowercase,
but "FileName" is the same as "filename". Added strieq()
which is use to compare filenames. This is like streq()
on all other systems. Also there is no such thing as
"." under AmigaDOS.
* function.c: On Amiga, the environment is not passed as envp,
there are no pipes and Amiga can't fork. Use my own function
to create a new child.
* job.c: default_shell is "" (The system automatically chooses
a shell for me). Have to use the same workaround as MSDOS for
running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't
known on Amiga. Cloned code to run children from MSDOS. Own
version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga.
* main.c: Force stack to 20000 bytes. Read environment from ENV:
device. On Amiga, exec_command() does return, so I exit()
afterwards.
* make.h: Added strieq() to compare filenames.
* read.c: Amiga needs special extension to have passwd. Only
one include-dir. "Makefile" and "makefile" are the same.
Added "SMakefile". Added special code to handle device names (xxx:)
and "./" in rules.
* remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib"
instead of "lib%s.a".
* main.c, rule.c, variable.c: Avoid floats at all costs.
* vpath.c: Get rid of as many alloca()s as possible.
1996-05-10 02:02:06 +08:00
|
|
|
|
#endif
|
1992-01-30 07:54:36 +08:00
|
|
|
|
{
|
1998-07-31 04:54:47 +08:00
|
|
|
|
static char *stdin_nm = 0;
|
2004-05-17 03:16:52 +08:00
|
|
|
|
int makefile_status = MAKE_SUCCESS;
|
2013-01-20 13:55:57 +08:00
|
|
|
|
struct dep *read_files;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
PATH_VAR (current_directory);
|
2005-06-26 02:57:28 +08:00
|
|
|
|
unsigned int restarts = 0;
|
2013-09-22 05:24:59 +08:00
|
|
|
|
unsigned int syncing = 0;
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#ifdef WINDOWS32
|
1996-05-23 05:51:45 +08:00
|
|
|
|
char *unix_path = NULL;
|
1997-04-07 15:21:16 +08:00
|
|
|
|
char *windows32_path = NULL;
|
|
|
|
|
|
2013-05-17 14:29:46 +08:00
|
|
|
|
SetUnhandledExceptionFilter (handle_runtime_exceptions);
|
1998-07-31 04:54:47 +08:00
|
|
|
|
|
|
|
|
|
/* start off assuming we have no shell */
|
|
|
|
|
unixy_shell = 0;
|
|
|
|
|
no_default_sh_exe = 1;
|
1996-05-23 05:51:45 +08:00
|
|
|
|
#endif
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2013-09-22 05:24:59 +08:00
|
|
|
|
output_init (&make_sync);
|
|
|
|
|
|
2013-06-22 12:22:08 +08:00
|
|
|
|
initialize_stopchar_map();
|
|
|
|
|
|
2005-02-16 13:03:42 +08:00
|
|
|
|
#ifdef SET_STACK_SIZE
|
|
|
|
|
/* Get rid of any avoidable limit on stack size. */
|
|
|
|
|
{
|
|
|
|
|
struct rlimit rlim;
|
|
|
|
|
|
|
|
|
|
/* Set the stack limit huge so that alloca does not fail. */
|
2009-06-08 01:40:06 +08:00
|
|
|
|
if (getrlimit (RLIMIT_STACK, &rlim) == 0
|
|
|
|
|
&& rlim.rlim_cur > 0 && rlim.rlim_cur < rlim.rlim_max)
|
2005-02-16 13:03:42 +08:00
|
|
|
|
{
|
2009-06-08 01:40:06 +08:00
|
|
|
|
stack_limit = rlim;
|
2005-02-16 13:03:42 +08:00
|
|
|
|
rlim.rlim_cur = rlim.rlim_max;
|
|
|
|
|
setrlimit (RLIMIT_STACK, &rlim);
|
|
|
|
|
}
|
2009-06-08 01:40:06 +08:00
|
|
|
|
else
|
|
|
|
|
stack_limit.rlim_cur = 0;
|
2005-02-16 13:03:42 +08:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-03-25 07:14:15 +08:00
|
|
|
|
/* Needed for OS/2 */
|
2012-01-16 06:41:53 +08:00
|
|
|
|
initialize_main (&argc, &argv);
|
2003-03-25 07:14:15 +08:00
|
|
|
|
|
2013-06-22 11:59:38 +08:00
|
|
|
|
#ifdef MAKE_MAINTAINER_MODE
|
|
|
|
|
/* In maintainer mode we always enable verification. */
|
|
|
|
|
verify_flag = 1;
|
|
|
|
|
#endif
|
1995-11-26 09:37:07 +08:00
|
|
|
|
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#if defined (__MSDOS__) && !defined (_POSIX_SOURCE)
|
2012-03-04 08:24:20 +08:00
|
|
|
|
/* Request the most powerful version of 'system', to
|
1997-04-07 15:21:16 +08:00
|
|
|
|
make up for the dumb default shell. */
|
|
|
|
|
__system_flags = (__system_redirect
|
2013-01-20 13:55:57 +08:00
|
|
|
|
| __system_use_shell
|
|
|
|
|
| __system_allow_multiple_cmds
|
|
|
|
|
| __system_allow_long_cmds
|
|
|
|
|
| __system_handle_null_commands
|
|
|
|
|
| __system_emulate_chdir);
|
1997-04-07 15:21:16 +08:00
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2000-01-22 16:57:17 +08:00
|
|
|
|
/* Set up gettext/internationalization support. */
|
|
|
|
|
setlocale (LC_ALL, "");
|
2010-07-09 19:10:04 +08:00
|
|
|
|
/* The cast to void shuts up compiler warnings on systems that
|
|
|
|
|
disable NLS. */
|
|
|
|
|
(void)bindtextdomain (PACKAGE, LOCALEDIR);
|
|
|
|
|
(void)textdomain (PACKAGE);
|
2000-01-22 16:57:17 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
#ifdef POSIX
|
1992-05-01 06:17:12 +08:00
|
|
|
|
sigemptyset (&fatal_signal_set);
|
2013-01-20 13:55:57 +08:00
|
|
|
|
#define ADD_SIG(sig) sigaddset (&fatal_signal_set, sig)
|
1992-05-01 06:17:12 +08:00
|
|
|
|
#else
|
2013-01-20 13:55:57 +08:00
|
|
|
|
#ifdef HAVE_SIGSETMASK
|
1992-01-30 07:54:36 +08:00
|
|
|
|
fatal_signal_mask = 0;
|
2013-01-20 13:55:57 +08:00
|
|
|
|
#define ADD_SIG(sig) fatal_signal_mask |= sigmask (sig)
|
1992-05-01 06:17:12 +08:00
|
|
|
|
#else
|
2013-01-20 13:55:57 +08:00
|
|
|
|
#define ADD_SIG(sig) (void)sig
|
1992-05-01 06:17:12 +08:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
#define FATAL_SIG(sig) \
|
|
|
|
|
if (bsd_signal (sig, fatal_error_signal) == SIG_IGN) \
|
|
|
|
|
bsd_signal (sig, SIG_IGN); \
|
|
|
|
|
else \
|
1992-05-01 06:17:12 +08:00
|
|
|
|
ADD_SIG (sig);
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
Thu May 9 13:54:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* GNUmakefile (globfiles): Add AmigaDOS support files.
(distfiles): Add $(amigafiles).
(amigafiles): New variable.
Thu Nov 7 10:18:16 1995 Aaron Digulla <digulla@fh-konstanz.de>
* Added Amiga support in commands.c, dir.c, function.c,
job.c, main.c, make.h, read.c, remake.c
* commands.c: Amiga has neither SIGHUP nor SIGQUIT
* dir.c: Amiga has filenames with Upper- and Lowercase,
but "FileName" is the same as "filename". Added strieq()
which is use to compare filenames. This is like streq()
on all other systems. Also there is no such thing as
"." under AmigaDOS.
* function.c: On Amiga, the environment is not passed as envp,
there are no pipes and Amiga can't fork. Use my own function
to create a new child.
* job.c: default_shell is "" (The system automatically chooses
a shell for me). Have to use the same workaround as MSDOS for
running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't
known on Amiga. Cloned code to run children from MSDOS. Own
version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga.
* main.c: Force stack to 20000 bytes. Read environment from ENV:
device. On Amiga, exec_command() does return, so I exit()
afterwards.
* make.h: Added strieq() to compare filenames.
* read.c: Amiga needs special extension to have passwd. Only
one include-dir. "Makefile" and "makefile" are the same.
Added "SMakefile". Added special code to handle device names (xxx:)
and "./" in rules.
* remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib"
instead of "lib%s.a".
* main.c, rule.c, variable.c: Avoid floats at all costs.
* vpath.c: Get rid of as many alloca()s as possible.
1996-05-10 02:02:06 +08:00
|
|
|
|
#ifdef SIGHUP
|
1992-01-30 07:54:36 +08:00
|
|
|
|
FATAL_SIG (SIGHUP);
|
Thu May 9 13:54:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* GNUmakefile (globfiles): Add AmigaDOS support files.
(distfiles): Add $(amigafiles).
(amigafiles): New variable.
Thu Nov 7 10:18:16 1995 Aaron Digulla <digulla@fh-konstanz.de>
* Added Amiga support in commands.c, dir.c, function.c,
job.c, main.c, make.h, read.c, remake.c
* commands.c: Amiga has neither SIGHUP nor SIGQUIT
* dir.c: Amiga has filenames with Upper- and Lowercase,
but "FileName" is the same as "filename". Added strieq()
which is use to compare filenames. This is like streq()
on all other systems. Also there is no such thing as
"." under AmigaDOS.
* function.c: On Amiga, the environment is not passed as envp,
there are no pipes and Amiga can't fork. Use my own function
to create a new child.
* job.c: default_shell is "" (The system automatically chooses
a shell for me). Have to use the same workaround as MSDOS for
running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't
known on Amiga. Cloned code to run children from MSDOS. Own
version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga.
* main.c: Force stack to 20000 bytes. Read environment from ENV:
device. On Amiga, exec_command() does return, so I exit()
afterwards.
* make.h: Added strieq() to compare filenames.
* read.c: Amiga needs special extension to have passwd. Only
one include-dir. "Makefile" and "makefile" are the same.
Added "SMakefile". Added special code to handle device names (xxx:)
and "./" in rules.
* remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib"
instead of "lib%s.a".
* main.c, rule.c, variable.c: Avoid floats at all costs.
* vpath.c: Get rid of as many alloca()s as possible.
1996-05-10 02:02:06 +08:00
|
|
|
|
#endif
|
|
|
|
|
#ifdef SIGQUIT
|
1992-01-30 07:54:36 +08:00
|
|
|
|
FATAL_SIG (SIGQUIT);
|
Thu May 9 13:54:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* GNUmakefile (globfiles): Add AmigaDOS support files.
(distfiles): Add $(amigafiles).
(amigafiles): New variable.
Thu Nov 7 10:18:16 1995 Aaron Digulla <digulla@fh-konstanz.de>
* Added Amiga support in commands.c, dir.c, function.c,
job.c, main.c, make.h, read.c, remake.c
* commands.c: Amiga has neither SIGHUP nor SIGQUIT
* dir.c: Amiga has filenames with Upper- and Lowercase,
but "FileName" is the same as "filename". Added strieq()
which is use to compare filenames. This is like streq()
on all other systems. Also there is no such thing as
"." under AmigaDOS.
* function.c: On Amiga, the environment is not passed as envp,
there are no pipes and Amiga can't fork. Use my own function
to create a new child.
* job.c: default_shell is "" (The system automatically chooses
a shell for me). Have to use the same workaround as MSDOS for
running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't
known on Amiga. Cloned code to run children from MSDOS. Own
version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga.
* main.c: Force stack to 20000 bytes. Read environment from ENV:
device. On Amiga, exec_command() does return, so I exit()
afterwards.
* make.h: Added strieq() to compare filenames.
* read.c: Amiga needs special extension to have passwd. Only
one include-dir. "Makefile" and "makefile" are the same.
Added "SMakefile". Added special code to handle device names (xxx:)
and "./" in rules.
* remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib"
instead of "lib%s.a".
* main.c, rule.c, variable.c: Avoid floats at all costs.
* vpath.c: Get rid of as many alloca()s as possible.
1996-05-10 02:02:06 +08:00
|
|
|
|
#endif
|
1992-01-30 07:54:36 +08:00
|
|
|
|
FATAL_SIG (SIGINT);
|
1992-06-05 09:04:07 +08:00
|
|
|
|
FATAL_SIG (SIGTERM);
|
|
|
|
|
|
2000-06-07 13:43:37 +08:00
|
|
|
|
#ifdef __MSDOS__
|
|
|
|
|
/* Windows 9X delivers FP exceptions in child programs to their
|
|
|
|
|
parent! We don't want Make to die when a child divides by zero,
|
|
|
|
|
so we work around that lossage by catching SIGFPE. */
|
|
|
|
|
FATAL_SIG (SIGFPE);
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
#ifdef SIGDANGER
|
1992-01-30 07:54:36 +08:00
|
|
|
|
FATAL_SIG (SIGDANGER);
|
1992-06-05 09:04:07 +08:00
|
|
|
|
#endif
|
1992-01-30 07:54:36 +08:00
|
|
|
|
#ifdef SIGXCPU
|
|
|
|
|
FATAL_SIG (SIGXCPU);
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef SIGXFSZ
|
|
|
|
|
FATAL_SIG (SIGXFSZ);
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
#undef FATAL_SIG
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1998-10-03 13:39:55 +08:00
|
|
|
|
/* Do not ignore the child-death signal. This must be done before
|
|
|
|
|
any children could possibly be created; otherwise, the wait
|
|
|
|
|
functions won't work on systems with the SVR4 ECHILD brain
|
|
|
|
|
damage, if our invoker is ignoring this signal. */
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_WAIT_NOHANG
|
|
|
|
|
# if defined SIGCHLD
|
2001-06-01 11:56:50 +08:00
|
|
|
|
(void) bsd_signal (SIGCHLD, SIG_DFL);
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# endif
|
|
|
|
|
# if defined SIGCLD && SIGCLD != SIGCHLD
|
2001-06-01 11:56:50 +08:00
|
|
|
|
(void) bsd_signal (SIGCLD, SIG_DFL);
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-09-14 13:04:04 +08:00
|
|
|
|
output_init (NULL);
|
2013-06-29 09:57:59 +08:00
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* Figure out where this program lives. */
|
|
|
|
|
|
|
|
|
|
if (argv[0] == 0)
|
2014-04-26 05:10:47 +08:00
|
|
|
|
argv[0] = (char *)"";
|
1992-01-30 07:54:36 +08:00
|
|
|
|
if (argv[0][0] == '\0')
|
|
|
|
|
program = "make";
|
1995-11-26 09:37:07 +08:00
|
|
|
|
else
|
1992-01-30 07:54:36 +08:00
|
|
|
|
{
|
1999-10-15 15:00:58 +08:00
|
|
|
|
program = strrchr (argv[0], '/');
|
2003-03-25 07:14:15 +08:00
|
|
|
|
#if defined(__MSDOS__) || defined(__EMX__)
|
1994-07-26 07:33:26 +08:00
|
|
|
|
if (program == 0)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
program = strrchr (argv[0], '\\');
|
1997-04-07 15:21:16 +08:00
|
|
|
|
else
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
/* Some weird environments might pass us argv[0] with
|
|
|
|
|
both kinds of slashes; we must find the rightmost. */
|
|
|
|
|
char *p = strrchr (argv[0], '\\');
|
|
|
|
|
if (p && p > program)
|
|
|
|
|
program = p;
|
|
|
|
|
}
|
1997-04-07 15:21:16 +08:00
|
|
|
|
if (program == 0 && argv[0][1] == ':')
|
2013-01-20 13:55:57 +08:00
|
|
|
|
program = argv[0] + 1;
|
2005-02-26 09:41:48 +08:00
|
|
|
|
#endif
|
|
|
|
|
#ifdef WINDOWS32
|
|
|
|
|
if (program == 0)
|
|
|
|
|
{
|
|
|
|
|
/* Extract program from full path */
|
2005-07-04 11:50:59 +08:00
|
|
|
|
program = strrchr (argv[0], '\\');
|
|
|
|
|
if (program)
|
2005-02-26 09:41:48 +08:00
|
|
|
|
{
|
2013-07-22 05:52:13 +08:00
|
|
|
|
int argv0_len = strlen (program);
|
2005-07-04 11:50:59 +08:00
|
|
|
|
if (argv0_len > 4 && streq (&program[argv0_len - 4], ".exe"))
|
|
|
|
|
/* Remove .exe extension */
|
|
|
|
|
program[argv0_len - 4] = '\0';
|
2005-02-26 09:41:48 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
1994-07-26 07:33:26 +08:00
|
|
|
|
#endif
|
1992-01-30 07:54:36 +08:00
|
|
|
|
if (program == 0)
|
2014-09-01 01:11:08 +08:00
|
|
|
|
#ifdef VMS
|
|
|
|
|
program = vms_progname(argv[0]);
|
|
|
|
|
#else
|
2013-01-20 13:55:57 +08:00
|
|
|
|
program = argv[0];
|
2014-09-01 01:11:08 +08:00
|
|
|
|
#endif
|
1992-01-30 07:54:36 +08:00
|
|
|
|
else
|
2013-01-20 13:55:57 +08:00
|
|
|
|
++program;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
1994-02-17 05:13:16 +08:00
|
|
|
|
/* Set up to access user data (files). */
|
|
|
|
|
user_access ();
|
|
|
|
|
|
2002-07-11 14:38:57 +08:00
|
|
|
|
initialize_global_hash_tables ();
|
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* Figure out where we are. */
|
|
|
|
|
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#ifdef WINDOWS32
|
1996-05-23 05:51:45 +08:00
|
|
|
|
if (getcwd_fs (current_directory, GET_PATH_MAX) == 0)
|
|
|
|
|
#else
|
1992-06-11 12:58:20 +08:00
|
|
|
|
if (getcwd (current_directory, GET_PATH_MAX) == 0)
|
1996-05-23 05:51:45 +08:00
|
|
|
|
#endif
|
1992-01-30 07:54:36 +08:00
|
|
|
|
{
|
2013-01-20 13:55:57 +08:00
|
|
|
|
#ifdef HAVE_GETCWD
|
2005-05-09 00:50:58 +08:00
|
|
|
|
perror_with_name ("getcwd", "");
|
1992-01-30 07:54:36 +08:00
|
|
|
|
#else
|
2013-11-24 11:23:52 +08:00
|
|
|
|
OS (error, NILF, "getwd: %s", current_directory);
|
1992-01-30 07:54:36 +08:00
|
|
|
|
#endif
|
|
|
|
|
current_directory[0] = '\0';
|
1993-03-09 02:49:51 +08:00
|
|
|
|
directory_before_chdir = 0;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
}
|
1993-03-09 02:49:51 +08:00
|
|
|
|
else
|
1999-07-21 13:53:23 +08:00
|
|
|
|
directory_before_chdir = xstrdup (current_directory);
|
2012-01-16 06:41:53 +08:00
|
|
|
|
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#ifdef __MSDOS__
|
|
|
|
|
/* Make sure we will return to the initial directory, come what may. */
|
|
|
|
|
atexit (msdos_return_to_initial_directory);
|
|
|
|
|
#endif
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2002-08-01 21:16:57 +08:00
|
|
|
|
/* Initialize the special variables. */
|
2009-10-25 08:46:52 +08:00
|
|
|
|
define_variable_cname (".VARIABLES", "", o_default, 0)->special = 1;
|
|
|
|
|
/* define_variable_cname (".TARGETS", "", o_default, 0)->special = 1; */
|
|
|
|
|
define_variable_cname (".RECIPEPREFIX", "", o_default, 0)->special = 1;
|
2010-07-06 14:37:42 +08:00
|
|
|
|
define_variable_cname (".SHELLFLAGS", "-c", o_default, 0);
|
2005-04-08 20:51:20 +08:00
|
|
|
|
|
2010-07-01 15:16:00 +08:00
|
|
|
|
/* Set up .FEATURES
|
2011-11-14 08:42:49 +08:00
|
|
|
|
Use a separate variable because define_variable_cname() is a macro and
|
|
|
|
|
some compilers (MSVC) don't like conditionals in macros. */
|
2010-07-06 14:37:42 +08:00
|
|
|
|
{
|
|
|
|
|
const char *features = "target-specific order-only second-expansion"
|
2010-08-14 10:50:14 +08:00
|
|
|
|
" else-if shortest-stem undefine oneshell"
|
2006-02-14 23:42:17 +08:00
|
|
|
|
#ifndef NO_ARCHIVES
|
2010-07-06 14:37:42 +08:00
|
|
|
|
" archives"
|
2006-02-14 23:42:17 +08:00
|
|
|
|
#endif
|
2005-04-08 20:51:20 +08:00
|
|
|
|
#ifdef MAKE_JOBSERVER
|
2010-07-06 14:37:42 +08:00
|
|
|
|
" jobserver"
|
2005-04-08 20:51:20 +08:00
|
|
|
|
#endif
|
2013-09-22 05:37:59 +08:00
|
|
|
|
#ifndef NO_OUTPUT_SYNC
|
Support --output-sync on MS-Windows.
w32/compat/posixfcn.c: New file, with emulations of Posix
functions and Posix functionality for MS-Windows.
w32/subproc/sub_proc.c: Include io.h.
(process_noinherit): New function, forces a file descriptor to not
be inherited by child processes.
(process_easy): Accept two additional arguments, and use them to
set up the standard output and standard error handles of the child
process.
w32/include/sub_proc.h (process_easy): Adjust prototype.
(process_noinherit): Add prototype.
read.c [WINDOWS32]: Include windows.h and sub_proc.h.
makeint.h (LOCALEDIR) [WINDOWS32}: Define to NULL if not
defined. This is needed because the MS-Windows build doesn't have
a canonical place for LOCALEDIR.
(WIN32_LEAN_AND_MEAN) [WINDOWS32]: Define, to avoid getting from
windows.h header too much stuff that could conflict with the code.
main.c <sync_mutex>: New static variable.
<switches>: Add support for "--sync-mutex" switch.
(decode_output_sync_flags): Decode the --sync-mutex= switch.
(prepare_mutex_handle_string) [WINDOWS32]: New function.
(main): Add "output-sync" to .FEATURES.
job.h (CLOSE_ON_EXEC) [WINDOWS32]: Define to call
process_noinherit.
(F_GETFD, F_SETLKW, F_WRLCK, F_UNLCK, struct flock) [WINDOWS32]:
New macros.
(RECORD_SYNC_MUTEX): New macro, a no-op for Posix platforms.
(sync_handle_t): New typedef.
job.c <sync_handle>: Change type to sync_handle_t.
(FD_NOT_EMPTY): Seek to the file's end. Suggested by Frank
Heckenbach <f.heckenbach@fh-soft.de>.
(pump_from_tmp_fd) [WINDOWS32]: Switch to_fd to binary mode for
the duration of this function, and then change back before
returning.
(start_job_command) [WINDOWS32]: Support output_sync mode on
MS-Windows. Use a system-wide mutex instead of locking
stdout/stderr. Call process_easy with two additional arguments:
child->outfd and child->errfd.
(exec_command) [WINDOWS32]: Pass two additional arguments, both
-1, to process_easy, to adjust for the changed function signature.
function.c (windows32_openpipe) [WINDOWS32]: This function now
returns an int, which is -1 if it fails and zero otherwise. It
also calls 'error' instead of 'fatal', to avoid exiting
prematurely.
(func_shell_base) [WINDOWS32]: Call perror_with_name if
windows32_openpipe fails, now that it always returns. This avoids
a compiler warning that error_prefix is not used in the MS-Windows
build.
config.h.W32.template (OUTPUT_SYNC): Define.
build_w32.bat: Add w32/compat/posixfcn.c to compilation and
linking commands.
From Frank Heckenbach <f.heckenbach@fh-soft.de>:
job.c (sync_output): Don't discard the output if
acquire_semaphore fails; instead, dump the output unsynchronized.
2013-04-27 19:20:49 +08:00
|
|
|
|
" output-sync"
|
|
|
|
|
#endif
|
2005-04-08 20:51:20 +08:00
|
|
|
|
#ifdef MAKE_SYMLINKS
|
2010-07-06 14:37:42 +08:00
|
|
|
|
" check-symlink"
|
2012-10-29 15:05:21 +08:00
|
|
|
|
#endif
|
|
|
|
|
#ifdef HAVE_GUILE
|
|
|
|
|
" guile"
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef MAKE_LOAD
|
|
|
|
|
" load"
|
2005-04-08 20:51:20 +08:00
|
|
|
|
#endif
|
2010-07-06 14:37:42 +08:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
define_variable_cname (".FEATURES", features, o_default, 0);
|
|
|
|
|
}
|
2002-08-01 21:16:57 +08:00
|
|
|
|
|
2012-01-16 06:41:53 +08:00
|
|
|
|
/* Configure GNU Guile support */
|
2012-10-29 15:05:21 +08:00
|
|
|
|
guile_gmake_setup (NILF);
|
2012-01-16 06:41:53 +08:00
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* Read in variables from the environment. It is important that this be
|
1997-04-07 15:21:16 +08:00
|
|
|
|
done before $(MAKE) is figured out so its definitions will not be
|
|
|
|
|
from the environment. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
Thu May 9 13:54:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* GNUmakefile (globfiles): Add AmigaDOS support files.
(distfiles): Add $(amigafiles).
(amigafiles): New variable.
Thu Nov 7 10:18:16 1995 Aaron Digulla <digulla@fh-konstanz.de>
* Added Amiga support in commands.c, dir.c, function.c,
job.c, main.c, make.h, read.c, remake.c
* commands.c: Amiga has neither SIGHUP nor SIGQUIT
* dir.c: Amiga has filenames with Upper- and Lowercase,
but "FileName" is the same as "filename". Added strieq()
which is use to compare filenames. This is like streq()
on all other systems. Also there is no such thing as
"." under AmigaDOS.
* function.c: On Amiga, the environment is not passed as envp,
there are no pipes and Amiga can't fork. Use my own function
to create a new child.
* job.c: default_shell is "" (The system automatically chooses
a shell for me). Have to use the same workaround as MSDOS for
running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't
known on Amiga. Cloned code to run children from MSDOS. Own
version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga.
* main.c: Force stack to 20000 bytes. Read environment from ENV:
device. On Amiga, exec_command() does return, so I exit()
afterwards.
* make.h: Added strieq() to compare filenames.
* read.c: Amiga needs special extension to have passwd. Only
one include-dir. "Makefile" and "makefile" are the same.
Added "SMakefile". Added special code to handle device names (xxx:)
and "./" in rules.
* remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib"
instead of "lib%s.a".
* main.c, rule.c, variable.c: Avoid floats at all costs.
* vpath.c: Get rid of as many alloca()s as possible.
1996-05-10 02:02:06 +08:00
|
|
|
|
#ifndef _AMIGA
|
2006-04-10 06:09:24 +08:00
|
|
|
|
{
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; envp[i] != 0; ++i)
|
|
|
|
|
{
|
2013-09-30 09:57:22 +08:00
|
|
|
|
struct variable *v;
|
2014-04-26 05:10:47 +08:00
|
|
|
|
const char *ep = envp[i];
|
2013-09-30 09:57:22 +08:00
|
|
|
|
/* By default, export all variables culled from the environment. */
|
|
|
|
|
enum variable_export export = v_export;
|
|
|
|
|
unsigned int len;
|
1998-07-31 04:54:47 +08:00
|
|
|
|
|
2013-06-22 12:22:08 +08:00
|
|
|
|
while (! STOP_SET (*ep, MAP_EQUALS))
|
2006-04-10 06:09:24 +08:00
|
|
|
|
++ep;
|
2013-09-30 09:57:22 +08:00
|
|
|
|
|
|
|
|
|
/* If there's no equals sign it's a malformed environment. Ignore. */
|
|
|
|
|
if (*ep == '\0')
|
|
|
|
|
continue;
|
|
|
|
|
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#ifdef WINDOWS32
|
2011-11-14 08:42:49 +08:00
|
|
|
|
if (!unix_path && strneq (envp[i], "PATH=", 5))
|
2006-04-10 06:09:24 +08:00
|
|
|
|
unix_path = ep+1;
|
2013-05-17 14:29:46 +08:00
|
|
|
|
else if (!strnicmp (envp[i], "Path=", 5))
|
|
|
|
|
{
|
|
|
|
|
if (!windows32_path)
|
|
|
|
|
windows32_path = ep+1;
|
2013-09-30 09:57:22 +08:00
|
|
|
|
/* PATH gets defined after the loop exits. */
|
|
|
|
|
continue;
|
2013-05-17 14:29:46 +08:00
|
|
|
|
}
|
1996-05-23 05:51:45 +08:00
|
|
|
|
#endif
|
2013-09-30 09:57:22 +08:00
|
|
|
|
|
|
|
|
|
/* Length of the variable name, and skip the '='. */
|
|
|
|
|
len = ep++ - envp[i];
|
|
|
|
|
|
|
|
|
|
/* If this is MAKE_RESTARTS, check to see if the "already printed
|
|
|
|
|
the enter statement" flag is set. */
|
|
|
|
|
if (len == 13 && strneq (envp[i], "MAKE_RESTARTS", 13))
|
2006-04-10 06:09:24 +08:00
|
|
|
|
{
|
2013-09-30 09:57:22 +08:00
|
|
|
|
if (*ep == '-')
|
2006-04-10 06:09:24 +08:00
|
|
|
|
{
|
2013-09-30 09:57:22 +08:00
|
|
|
|
OUTPUT_TRACED ();
|
|
|
|
|
++ep;
|
2006-04-10 06:09:24 +08:00
|
|
|
|
}
|
2013-09-30 09:57:22 +08:00
|
|
|
|
restarts = (unsigned int) atoi (ep);
|
|
|
|
|
export = v_noexport;
|
|
|
|
|
}
|
2005-06-26 02:57:28 +08:00
|
|
|
|
|
2013-09-30 09:57:22 +08:00
|
|
|
|
v = define_variable (envp[i], len, ep, o_env, 1);
|
|
|
|
|
|
|
|
|
|
/* POSIX says the value of SHELL set in the makefile won't change the
|
|
|
|
|
value of SHELL given to subprocesses. */
|
|
|
|
|
if (streq (v->name, "SHELL"))
|
|
|
|
|
{
|
|
|
|
|
#ifndef __MSDOS__
|
|
|
|
|
export = v_noexport;
|
|
|
|
|
#endif
|
2014-04-26 05:10:47 +08:00
|
|
|
|
shell_var.name = xstrdup ("SHELL");
|
2013-09-30 09:57:22 +08:00
|
|
|
|
shell_var.length = 5;
|
|
|
|
|
shell_var.value = xstrdup (ep);
|
2006-04-10 06:09:24 +08:00
|
|
|
|
}
|
2013-09-30 09:57:22 +08:00
|
|
|
|
|
|
|
|
|
v->export = export;
|
2006-04-10 06:09:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#ifdef WINDOWS32
|
2005-04-08 20:51:20 +08:00
|
|
|
|
/* If we didn't find a correctly spelled PATH we define PATH as
|
2013-04-30 21:37:03 +08:00
|
|
|
|
* either the first misspelled value or an empty string
|
1996-05-23 05:51:45 +08:00
|
|
|
|
*/
|
2005-04-08 20:51:20 +08:00
|
|
|
|
if (!unix_path)
|
2009-10-25 08:46:52 +08:00
|
|
|
|
define_variable_cname ("PATH", windows32_path ? windows32_path : "",
|
|
|
|
|
o_env, 1)->export = v_export;
|
1996-05-23 05:51:45 +08:00
|
|
|
|
#endif
|
Thu May 9 13:54:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* GNUmakefile (globfiles): Add AmigaDOS support files.
(distfiles): Add $(amigafiles).
(amigafiles): New variable.
Thu Nov 7 10:18:16 1995 Aaron Digulla <digulla@fh-konstanz.de>
* Added Amiga support in commands.c, dir.c, function.c,
job.c, main.c, make.h, read.c, remake.c
* commands.c: Amiga has neither SIGHUP nor SIGQUIT
* dir.c: Amiga has filenames with Upper- and Lowercase,
but "FileName" is the same as "filename". Added strieq()
which is use to compare filenames. This is like streq()
on all other systems. Also there is no such thing as
"." under AmigaDOS.
* function.c: On Amiga, the environment is not passed as envp,
there are no pipes and Amiga can't fork. Use my own function
to create a new child.
* job.c: default_shell is "" (The system automatically chooses
a shell for me). Have to use the same workaround as MSDOS for
running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't
known on Amiga. Cloned code to run children from MSDOS. Own
version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga.
* main.c: Force stack to 20000 bytes. Read environment from ENV:
device. On Amiga, exec_command() does return, so I exit()
afterwards.
* make.h: Added strieq() to compare filenames.
* read.c: Amiga needs special extension to have passwd. Only
one include-dir. "Makefile" and "makefile" are the same.
Added "SMakefile". Added special code to handle device names (xxx:)
and "./" in rules.
* remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib"
instead of "lib%s.a".
* main.c, rule.c, variable.c: Avoid floats at all costs.
* vpath.c: Get rid of as many alloca()s as possible.
1996-05-10 02:02:06 +08:00
|
|
|
|
#else /* For Amiga, read the ENV: device, ignoring all dirs */
|
|
|
|
|
{
|
2013-01-20 13:55:57 +08:00
|
|
|
|
BPTR env, file, old;
|
|
|
|
|
char buffer[1024];
|
|
|
|
|
int len;
|
|
|
|
|
__aligned struct FileInfoBlock fib;
|
|
|
|
|
|
|
|
|
|
env = Lock ("ENV:", ACCESS_READ);
|
|
|
|
|
if (env)
|
2013-05-28 01:52:15 +08:00
|
|
|
|
{
|
2013-05-17 14:29:46 +08:00
|
|
|
|
old = CurrentDir (DupLock (env));
|
2013-01-20 13:55:57 +08:00
|
|
|
|
Examine (env, &fib);
|
|
|
|
|
|
|
|
|
|
while (ExNext (env, &fib))
|
2013-05-28 01:52:15 +08:00
|
|
|
|
{
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (fib.fib_DirEntryType < 0) /* File */
|
2013-05-28 01:52:15 +08:00
|
|
|
|
{
|
2013-01-20 13:55:57 +08:00
|
|
|
|
/* Define an empty variable. It will be filled in
|
2013-05-28 01:52:15 +08:00
|
|
|
|
variable_lookup(). Makes startup quite a bit faster. */
|
|
|
|
|
define_variable (fib.fib_FileName,
|
|
|
|
|
strlen (fib.fib_FileName),
|
|
|
|
|
"", o_env, 1)->export = v_export;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-01-20 13:55:57 +08:00
|
|
|
|
UnLock (env);
|
2013-05-17 14:29:46 +08:00
|
|
|
|
UnLock (CurrentDir (old));
|
2013-05-28 01:52:15 +08:00
|
|
|
|
}
|
Thu May 9 13:54:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* GNUmakefile (globfiles): Add AmigaDOS support files.
(distfiles): Add $(amigafiles).
(amigafiles): New variable.
Thu Nov 7 10:18:16 1995 Aaron Digulla <digulla@fh-konstanz.de>
* Added Amiga support in commands.c, dir.c, function.c,
job.c, main.c, make.h, read.c, remake.c
* commands.c: Amiga has neither SIGHUP nor SIGQUIT
* dir.c: Amiga has filenames with Upper- and Lowercase,
but "FileName" is the same as "filename". Added strieq()
which is use to compare filenames. This is like streq()
on all other systems. Also there is no such thing as
"." under AmigaDOS.
* function.c: On Amiga, the environment is not passed as envp,
there are no pipes and Amiga can't fork. Use my own function
to create a new child.
* job.c: default_shell is "" (The system automatically chooses
a shell for me). Have to use the same workaround as MSDOS for
running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't
known on Amiga. Cloned code to run children from MSDOS. Own
version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga.
* main.c: Force stack to 20000 bytes. Read environment from ENV:
device. On Amiga, exec_command() does return, so I exit()
afterwards.
* make.h: Added strieq() to compare filenames.
* read.c: Amiga needs special extension to have passwd. Only
one include-dir. "Makefile" and "makefile" are the same.
Added "SMakefile". Added special code to handle device names (xxx:)
and "./" in rules.
* remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib"
instead of "lib%s.a".
* main.c, rule.c, variable.c: Avoid floats at all costs.
* vpath.c: Get rid of as many alloca()s as possible.
1996-05-10 02:02:06 +08:00
|
|
|
|
}
|
|
|
|
|
#endif
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
|
|
|
|
/* Decode the switches. */
|
2013-05-13 14:48:04 +08:00
|
|
|
|
decode_env_switches (STRING_SIZE_TUPLE ("GNUMAKEFLAGS"));
|
2013-09-30 01:15:00 +08:00
|
|
|
|
|
|
|
|
|
/* Clear GNUMAKEFLAGS to avoid duplication. */
|
|
|
|
|
define_variable_cname ("GNUMAKEFLAGS", "", o_env, 0);
|
|
|
|
|
|
2005-06-26 02:57:28 +08:00
|
|
|
|
decode_env_switches (STRING_SIZE_TUPLE ("MAKEFLAGS"));
|
2013-05-13 14:48:04 +08:00
|
|
|
|
|
2013-09-22 05:24:59 +08:00
|
|
|
|
/* In output sync mode we need to sync any output generated by reading the
|
|
|
|
|
makefiles, such as in $(info ...) or stderr from $(shell ...) etc. */
|
|
|
|
|
|
|
|
|
|
syncing = make_sync.syncout = (output_sync == OUTPUT_SYNC_LINE
|
|
|
|
|
|| output_sync == OUTPUT_SYNC_TARGET);
|
|
|
|
|
OUTPUT_SET (&make_sync);
|
|
|
|
|
|
1993-08-11 14:54:23 +08:00
|
|
|
|
#if 0
|
|
|
|
|
/* People write things like:
|
2007-03-20 11:02:26 +08:00
|
|
|
|
MFLAGS="CC=gcc -pipe" "CFLAGS=-g"
|
1993-08-11 14:54:23 +08:00
|
|
|
|
and we set the -p, -i and -e switches. Doesn't seem quite right. */
|
2005-06-26 02:57:28 +08:00
|
|
|
|
decode_env_switches (STRING_SIZE_TUPLE ("MFLAGS"));
|
1993-08-11 14:54:23 +08:00
|
|
|
|
#endif
|
2009-10-25 08:46:52 +08:00
|
|
|
|
|
2014-04-26 05:10:47 +08:00
|
|
|
|
decode_switches (argc, (const char **)argv, 0);
|
2009-10-25 08:46:52 +08:00
|
|
|
|
|
2014-09-14 13:03:19 +08:00
|
|
|
|
/* Set a variable specifying whether stdout/stdin is hooked to a TTY. */
|
|
|
|
|
#ifdef HAVE_ISATTY
|
|
|
|
|
if (isatty (fileno (stdout)))
|
2014-09-15 21:30:40 +08:00
|
|
|
|
if (! lookup_variable (STRING_SIZE_TUPLE ("MAKE_TERMOUT")))
|
|
|
|
|
define_variable_cname ("MAKE_TERMOUT", TTYNAME (fileno (stdout)),
|
|
|
|
|
o_default, 0)->export = v_export;
|
2014-09-14 13:03:19 +08:00
|
|
|
|
|
|
|
|
|
if (isatty (fileno (stderr)))
|
2014-09-15 21:30:40 +08:00
|
|
|
|
if (! lookup_variable (STRING_SIZE_TUPLE ("MAKE_TERMERR")))
|
|
|
|
|
define_variable_cname ("MAKE_TERMERR", TTYNAME (fileno (stderr)),
|
|
|
|
|
o_default, 0)->export = v_export;
|
2014-09-14 13:03:19 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2013-09-22 05:24:59 +08:00
|
|
|
|
/* Reset in case the switches changed our minds. */
|
|
|
|
|
syncing = (output_sync == OUTPUT_SYNC_LINE
|
|
|
|
|
|| output_sync == OUTPUT_SYNC_TARGET);
|
|
|
|
|
|
|
|
|
|
if (make_sync.syncout && ! syncing)
|
|
|
|
|
output_close (&make_sync);
|
|
|
|
|
|
|
|
|
|
make_sync.syncout = syncing;
|
|
|
|
|
OUTPUT_SET (&make_sync);
|
|
|
|
|
|
2013-09-16 03:05:18 +08:00
|
|
|
|
/* Figure out the level of recursion. */
|
|
|
|
|
{
|
|
|
|
|
struct variable *v = lookup_variable (STRING_SIZE_TUPLE (MAKELEVEL_NAME));
|
|
|
|
|
if (v && v->value[0] != '\0' && v->value[0] != '-')
|
|
|
|
|
makelevel = (unsigned int) atoi (v->value);
|
|
|
|
|
else
|
|
|
|
|
makelevel = 0;
|
|
|
|
|
}
|
|
|
|
|
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#ifdef WINDOWS32
|
2013-05-17 14:29:46 +08:00
|
|
|
|
if (suspend_flag)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "%s (pid = %ld)\n", argv[0], GetCurrentProcessId ());
|
|
|
|
|
fprintf (stderr, _("%s is suspending for 30 seconds..."), argv[0]);
|
|
|
|
|
Sleep (30 * 1000);
|
|
|
|
|
fprintf (stderr, _("done sleep(30). Continuing.\n"));
|
|
|
|
|
}
|
1996-05-23 05:51:45 +08:00
|
|
|
|
#endif
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2005-06-26 02:57:28 +08:00
|
|
|
|
/* Set always_make_flag if -B was given and we've not restarted already. */
|
|
|
|
|
always_make_flag = always_make_set && (restarts == 0);
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2013-09-14 13:04:04 +08:00
|
|
|
|
/* Print version information, and exit. */
|
|
|
|
|
if (print_version_flag)
|
2005-06-26 02:57:28 +08:00
|
|
|
|
{
|
|
|
|
|
print_version ();
|
2014-08-25 04:06:15 +08:00
|
|
|
|
die (MAKE_SUCCESS);
|
2005-06-26 02:57:28 +08:00
|
|
|
|
}
|
1993-05-15 05:50:11 +08:00
|
|
|
|
|
2013-09-14 13:04:04 +08:00
|
|
|
|
if (ISDB (DB_BASIC))
|
|
|
|
|
print_version ();
|
|
|
|
|
|
1999-08-23 01:50:57 +08:00
|
|
|
|
#ifndef VMS
|
1992-12-10 06:10:14 +08:00
|
|
|
|
/* Set the "MAKE_COMMAND" variable to the name we were invoked with.
|
1992-01-30 07:54:36 +08:00
|
|
|
|
(If it is a relative pathname with a slash, prepend our directory name
|
|
|
|
|
so the result will run the same program regardless of the current dir.
|
|
|
|
|
If it is a name with no slash, we can only hope that PATH did not
|
1992-12-10 06:10:14 +08:00
|
|
|
|
find it in the current directory.) */
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#ifdef WINDOWS32
|
1996-05-23 05:51:45 +08:00
|
|
|
|
/*
|
|
|
|
|
* Convert from backslashes to forward slashes for
|
|
|
|
|
* programs like sh which don't like them. Shouldn't
|
|
|
|
|
* matter if the path is one way or the other for
|
|
|
|
|
* CreateProcess().
|
|
|
|
|
*/
|
2013-05-17 14:29:46 +08:00
|
|
|
|
if (strpbrk (argv[0], "/:\\") || strstr (argv[0], "..")
|
|
|
|
|
|| strneq (argv[0], "//", 2))
|
|
|
|
|
argv[0] = xstrdup (w32ify (argv[0], 1));
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#else /* WINDOWS32 */
|
2003-03-25 07:14:15 +08:00
|
|
|
|
#if defined (__MSDOS__) || defined (__EMX__)
|
1999-08-23 01:50:57 +08:00
|
|
|
|
if (strchr (argv[0], '\\'))
|
|
|
|
|
{
|
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
|
|
argv[0] = xstrdup (argv[0]);
|
|
|
|
|
for (p = argv[0]; *p; p++)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (*p == '\\')
|
|
|
|
|
*p = '/';
|
1999-08-23 01:50:57 +08:00
|
|
|
|
}
|
1999-09-16 06:23:35 +08:00
|
|
|
|
/* If argv[0] is not in absolute form, prepend the current
|
|
|
|
|
directory. This can happen when Make is invoked by another DJGPP
|
|
|
|
|
program that uses a non-absolute name. */
|
|
|
|
|
if (current_directory[0] != '\0'
|
|
|
|
|
&& argv[0] != 0
|
2004-02-23 14:25:54 +08:00
|
|
|
|
&& (argv[0][0] != '/' && (argv[0][0] == '\0' || argv[0][1] != ':'))
|
2006-11-19 04:53:44 +08:00
|
|
|
|
# ifdef __EMX__
|
2004-02-23 14:25:54 +08:00
|
|
|
|
/* do not prepend cwd if argv[0] contains no '/', e.g. "make" */
|
|
|
|
|
&& (strchr (argv[0], '/') != 0 || strchr (argv[0], '\\') != 0)
|
|
|
|
|
# endif
|
|
|
|
|
)
|
2009-09-17 01:07:01 +08:00
|
|
|
|
argv[0] = xstrdup (concat (3, current_directory, "/", argv[0]));
|
1999-08-23 01:50:57 +08:00
|
|
|
|
#else /* !__MSDOS__ */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
if (current_directory[0] != '\0'
|
2006-11-19 04:53:44 +08:00
|
|
|
|
&& argv[0] != 0 && argv[0][0] != '/' && strchr (argv[0], '/') != 0
|
|
|
|
|
#ifdef HAVE_DOS_PATHS
|
|
|
|
|
&& (argv[0][0] != '\\' && (!argv[0][0] || argv[0][1] != ':'))
|
|
|
|
|
&& strchr (argv[0], '\\') != 0
|
|
|
|
|
#endif
|
|
|
|
|
)
|
2009-09-17 01:07:01 +08:00
|
|
|
|
argv[0] = xstrdup (concat (3, current_directory, "/", argv[0]));
|
1999-08-23 01:50:57 +08:00
|
|
|
|
#endif /* !__MSDOS__ */
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#endif /* WINDOWS32 */
|
1994-07-26 07:33:26 +08:00
|
|
|
|
#endif
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2013-09-19 07:29:28 +08:00
|
|
|
|
/* We may move, but until we do, here we are. */
|
|
|
|
|
starting_directory = current_directory;
|
|
|
|
|
|
2013-09-16 03:05:18 +08:00
|
|
|
|
#ifdef MAKE_JOBSERVER
|
|
|
|
|
/* If the jobserver-fds option is seen, make sure that -j is reasonable.
|
|
|
|
|
This can't be usefully set in the makefile, and we want to verify the
|
|
|
|
|
FDs are valid before any other aspect of make has a chance to start
|
|
|
|
|
using them for something else. */
|
|
|
|
|
|
|
|
|
|
if (jobserver_fds)
|
|
|
|
|
{
|
2013-11-24 16:21:40 +08:00
|
|
|
|
/* Make sure the jobserver option has the proper format. */
|
|
|
|
|
const char *cp = jobserver_fds;
|
2013-09-16 03:05:18 +08:00
|
|
|
|
|
|
|
|
|
#ifdef WINDOWS32
|
|
|
|
|
if (! open_jobserver_semaphore (cp))
|
|
|
|
|
{
|
|
|
|
|
DWORD err = GetLastError ();
|
2013-11-24 11:23:52 +08:00
|
|
|
|
const char *estr = map_windows32_error_to_string (err);
|
|
|
|
|
fatal (NILF, strlen (cp) + INTSTR_LENGTH + strlen (estr),
|
|
|
|
|
_("internal error: unable to open jobserver semaphore '%s': (Error %ld: %s)"),
|
|
|
|
|
cp, err, estr);
|
2013-09-16 03:05:18 +08:00
|
|
|
|
}
|
|
|
|
|
DB (DB_JOBS, (_("Jobserver client (semaphore %s)\n"), cp));
|
|
|
|
|
#else
|
|
|
|
|
if (sscanf (cp, "%d,%d", &job_fds[0], &job_fds[1]) != 2)
|
2013-11-24 11:23:52 +08:00
|
|
|
|
OS (fatal, NILF,
|
|
|
|
|
_("internal error: invalid --jobserver-fds string '%s'"), cp);
|
2013-09-16 03:05:18 +08:00
|
|
|
|
|
|
|
|
|
DB (DB_JOBS,
|
|
|
|
|
(_("Jobserver client (fds %d,%d)\n"), job_fds[0], job_fds[1]));
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* The combination of a pipe + !job_slots means we're using the
|
|
|
|
|
jobserver. If !job_slots and we don't have a pipe, we can start
|
|
|
|
|
infinite jobs. If we see both a pipe and job_slots >0 that means the
|
|
|
|
|
user set -j explicitly. This is broken; in this case obey the user
|
|
|
|
|
(ignore the jobserver pipe for this make) but print a message.
|
|
|
|
|
If we've restarted, we already printed this the first time. */
|
|
|
|
|
|
|
|
|
|
if (job_slots > 0)
|
|
|
|
|
{
|
|
|
|
|
if (! restarts)
|
2013-11-24 11:23:52 +08:00
|
|
|
|
O (error, NILF,
|
|
|
|
|
_("warning: -jN forced in submake: disabling jobserver mode."));
|
2013-09-16 03:05:18 +08:00
|
|
|
|
}
|
|
|
|
|
#ifndef WINDOWS32
|
2013-09-22 05:37:59 +08:00
|
|
|
|
#ifdef HAVE_FCNTL
|
|
|
|
|
# define FD_OK(_f) ((fcntl ((_f), F_GETFD) != -1) || (errno != EBADF))
|
|
|
|
|
#else
|
|
|
|
|
# define FD_OK(_f) 1
|
|
|
|
|
#endif
|
2013-09-16 03:05:18 +08:00
|
|
|
|
/* Create a duplicate pipe, that will be closed in the SIGCHLD
|
|
|
|
|
handler. If this fails with EBADF, the parent has closed the pipe
|
|
|
|
|
on us because it didn't think we were a submake. If so, print a
|
|
|
|
|
warning then default to -j1. */
|
|
|
|
|
else if (!FD_OK (job_fds[0]) || !FD_OK (job_fds[1])
|
|
|
|
|
|| (job_rfd = dup (job_fds[0])) < 0)
|
|
|
|
|
{
|
|
|
|
|
if (errno != EBADF)
|
|
|
|
|
pfatal_with_name (_("dup jobserver"));
|
|
|
|
|
|
2013-11-24 11:23:52 +08:00
|
|
|
|
O (error, NILF,
|
|
|
|
|
_("warning: jobserver unavailable: using -j1. Add '+' to parent make rule."));
|
2013-09-16 03:05:18 +08:00
|
|
|
|
job_slots = 1;
|
|
|
|
|
job_fds[0] = job_fds[1] = -1;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (job_slots > 0)
|
|
|
|
|
{
|
|
|
|
|
#ifdef WINDOWS32
|
|
|
|
|
free_jobserver_semaphore ();
|
|
|
|
|
#else
|
|
|
|
|
if (job_fds[0] >= 0)
|
|
|
|
|
close (job_fds[0]);
|
|
|
|
|
if (job_fds[1] >= 0)
|
|
|
|
|
close (job_fds[1]);
|
|
|
|
|
#endif
|
|
|
|
|
job_fds[0] = job_fds[1] = -1;
|
2013-11-24 16:21:40 +08:00
|
|
|
|
|
2013-09-16 03:05:18 +08:00
|
|
|
|
free (jobserver_fds);
|
|
|
|
|
jobserver_fds = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
1994-09-09 13:37:40 +08:00
|
|
|
|
/* The extra indirection through $(MAKE_COMMAND) is done
|
|
|
|
|
for hysterical raisins. */
|
2014-09-01 01:11:08 +08:00
|
|
|
|
#ifdef VMS
|
|
|
|
|
define_variable_cname("MAKE_COMMAND", vms_command(argv[0]), o_default, 0);
|
|
|
|
|
#else
|
2009-10-25 08:46:52 +08:00
|
|
|
|
define_variable_cname ("MAKE_COMMAND", argv[0], o_default, 0);
|
2014-09-01 01:11:08 +08:00
|
|
|
|
#endif
|
2009-10-25 08:46:52 +08:00
|
|
|
|
define_variable_cname ("MAKE", "$(MAKE_COMMAND)", o_default, 1);
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1994-09-27 06:37:10 +08:00
|
|
|
|
if (command_variables != 0)
|
|
|
|
|
{
|
|
|
|
|
struct command_variable *cv;
|
|
|
|
|
struct variable *v;
|
|
|
|
|
unsigned int len = 0;
|
|
|
|
|
char *value, *p;
|
|
|
|
|
|
|
|
|
|
/* Figure out how much space will be taken up by the command-line
|
2013-01-20 13:55:57 +08:00
|
|
|
|
variable definitions. */
|
1994-09-27 06:37:10 +08:00
|
|
|
|
for (cv = command_variables; cv != 0; cv = cv->next)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
v = cv->variable;
|
|
|
|
|
len += 2 * strlen (v->name);
|
|
|
|
|
if (! v->recursive)
|
|
|
|
|
++len;
|
|
|
|
|
++len;
|
|
|
|
|
len += 2 * strlen (v->value);
|
|
|
|
|
++len;
|
|
|
|
|
}
|
1994-09-27 06:37:10 +08:00
|
|
|
|
|
|
|
|
|
/* Now allocate a buffer big enough and fill it. */
|
2006-04-10 06:09:24 +08:00
|
|
|
|
p = value = alloca (len);
|
1994-09-27 06:37:10 +08:00
|
|
|
|
for (cv = command_variables; cv != 0; cv = cv->next)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
v = cv->variable;
|
|
|
|
|
p = quote_for_env (p, v->name);
|
|
|
|
|
if (! v->recursive)
|
|
|
|
|
*p++ = ':';
|
|
|
|
|
*p++ = '=';
|
|
|
|
|
p = quote_for_env (p, v->value);
|
|
|
|
|
*p++ = ' ';
|
|
|
|
|
}
|
|
|
|
|
p[-1] = '\0'; /* Kill the final space and terminate. */
|
1994-09-27 06:37:10 +08:00
|
|
|
|
|
1994-10-01 16:07:35 +08:00
|
|
|
|
/* Define an unchangeable variable with a name that no POSIX.2
|
2013-01-20 13:55:57 +08:00
|
|
|
|
makefile could validly use for its own variable. */
|
2009-10-25 08:46:52 +08:00
|
|
|
|
define_variable_cname ("-*-command-variables-*-", value, o_automatic, 0);
|
1994-10-01 16:07:35 +08:00
|
|
|
|
|
|
|
|
|
/* Define the variable; this will not override any user definition.
|
|
|
|
|
Normally a reference to this variable is written into the value of
|
|
|
|
|
MAKEFLAGS, allowing the user to override this value to affect the
|
|
|
|
|
exported value of MAKEFLAGS. In POSIX-pedantic mode, we cannot
|
|
|
|
|
allow the user's setting of MAKEOVERRIDES to affect MAKEFLAGS, so
|
|
|
|
|
a reference to this hidden variable is written instead. */
|
2009-10-25 08:46:52 +08:00
|
|
|
|
define_variable_cname ("MAKEOVERRIDES", "${-*-command-variables-*-}",
|
|
|
|
|
o_env, 1);
|
1994-09-27 06:37:10 +08:00
|
|
|
|
}
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1993-01-07 08:34:28 +08:00
|
|
|
|
/* If there were -C flags, move ourselves about. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
if (directories != 0)
|
2006-04-10 06:09:24 +08:00
|
|
|
|
{
|
|
|
|
|
unsigned int i;
|
|
|
|
|
for (i = 0; directories->list[i] != 0; ++i)
|
2004-11-29 09:35:13 +08:00
|
|
|
|
{
|
2007-03-20 11:02:26 +08:00
|
|
|
|
const char *dir = directories->list[i];
|
2006-04-10 06:09:24 +08:00
|
|
|
|
#ifdef WINDOWS32
|
|
|
|
|
/* WINDOWS32 chdir() doesn't work if the directory has a trailing '/'
|
|
|
|
|
But allow -C/ just in case someone wants that. */
|
|
|
|
|
{
|
2010-07-09 19:10:04 +08:00
|
|
|
|
char *p = (char *)dir + strlen (dir) - 1;
|
2006-04-10 06:09:24 +08:00
|
|
|
|
while (p > dir && (p[0] == '/' || p[0] == '\\'))
|
|
|
|
|
--p;
|
|
|
|
|
p[1] = '\0';
|
|
|
|
|
}
|
2004-11-29 09:35:13 +08:00
|
|
|
|
#endif
|
2006-04-10 06:09:24 +08:00
|
|
|
|
if (chdir (dir) < 0)
|
|
|
|
|
pfatal_with_name (dir);
|
|
|
|
|
}
|
|
|
|
|
}
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#ifdef WINDOWS32
|
1996-05-23 05:51:45 +08:00
|
|
|
|
/*
|
|
|
|
|
* THIS BLOCK OF CODE MUST COME AFTER chdir() CALL ABOVE IN ORDER
|
|
|
|
|
* TO NOT CONFUSE THE DEPENDENCY CHECKING CODE IN implicit.c.
|
|
|
|
|
*
|
|
|
|
|
* The functions in dir.c can incorrectly cache information for "."
|
|
|
|
|
* before we have changed directory and this can cause file
|
|
|
|
|
* lookups to fail because the current directory (.) was pointing
|
|
|
|
|
* at the wrong place when it was first evaluated.
|
|
|
|
|
*/
|
2013-05-17 14:29:46 +08:00
|
|
|
|
no_default_sh_exe = !find_and_set_default_shell (NULL);
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#endif /* WINDOWS32 */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1992-10-01 07:21:22 +08:00
|
|
|
|
/* Except under -s, always do -w in sub-makes and under -C. */
|
|
|
|
|
if (!silent_flag && (directories != 0 || makelevel > 0))
|
|
|
|
|
print_directory_flag = 1;
|
1992-07-03 06:48:17 +08:00
|
|
|
|
|
1993-04-08 04:40:35 +08:00
|
|
|
|
/* Let the user disable that with --no-print-directory. */
|
|
|
|
|
if (inhibit_print_directory_flag)
|
|
|
|
|
print_directory_flag = 0;
|
|
|
|
|
|
1999-07-08 14:49:52 +08:00
|
|
|
|
/* If -R was given, set -r too (doesn't make sense otherwise!) */
|
|
|
|
|
if (no_builtin_variables_flag)
|
|
|
|
|
no_builtin_rules_flag = 1;
|
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* Construct the list of include directories to search. */
|
|
|
|
|
|
2006-04-10 06:09:24 +08:00
|
|
|
|
construct_include_path (include_directories == 0
|
|
|
|
|
? 0 : include_directories->list);
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2013-09-19 07:29:28 +08:00
|
|
|
|
/* If we chdir'ed, figure out where we are now. */
|
|
|
|
|
if (directories)
|
1993-02-05 02:23:19 +08:00
|
|
|
|
{
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#ifdef WINDOWS32
|
1996-05-23 05:51:45 +08:00
|
|
|
|
if (getcwd_fs (current_directory, GET_PATH_MAX) == 0)
|
|
|
|
|
#else
|
1993-02-05 02:23:19 +08:00
|
|
|
|
if (getcwd (current_directory, GET_PATH_MAX) == 0)
|
1996-05-23 05:51:45 +08:00
|
|
|
|
#endif
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
#ifdef HAVE_GETCWD
|
|
|
|
|
perror_with_name ("getcwd", "");
|
1993-02-05 02:23:19 +08:00
|
|
|
|
#else
|
2013-11-24 11:23:52 +08:00
|
|
|
|
OS (error, NILF, "getwd: %s", current_directory);
|
1993-02-05 02:23:19 +08:00
|
|
|
|
#endif
|
2013-01-20 13:55:57 +08:00
|
|
|
|
starting_directory = 0;
|
|
|
|
|
}
|
1993-02-05 02:23:19 +08:00
|
|
|
|
else
|
2013-01-20 13:55:57 +08:00
|
|
|
|
starting_directory = current_directory;
|
1993-02-05 02:23:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-25 08:46:52 +08:00
|
|
|
|
define_variable_cname ("CURDIR", current_directory, o_file, 0);
|
1998-07-31 04:54:47 +08:00
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* Read any stdin makefiles into temporary files. */
|
|
|
|
|
|
|
|
|
|
if (makefiles != 0)
|
|
|
|
|
{
|
2006-04-10 06:09:24 +08:00
|
|
|
|
unsigned int i;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
for (i = 0; i < makefiles->idx; ++i)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (makefiles->list[i][0] == '-' && makefiles->list[i][1] == '\0')
|
|
|
|
|
{
|
|
|
|
|
/* This makefile is standard input. Since we may re-exec
|
|
|
|
|
and thus re-read the makefiles, we read standard input
|
|
|
|
|
into a temporary file and read from that. */
|
|
|
|
|
FILE *outfile;
|
2014-04-26 05:10:47 +08:00
|
|
|
|
char *template;
|
|
|
|
|
const char *tmpdir;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2000-03-27 14:54:37 +08:00
|
|
|
|
if (stdin_nm)
|
2013-11-24 11:23:52 +08:00
|
|
|
|
O (fatal, NILF,
|
|
|
|
|
_("Makefile from standard input specified twice."));
|
1996-03-20 22:57:41 +08:00
|
|
|
|
|
|
|
|
|
#ifdef VMS
|
2000-04-22 10:11:17 +08:00
|
|
|
|
# define DEFAULT_TMPDIR "sys$scratch:"
|
1996-03-20 22:57:41 +08:00
|
|
|
|
#else
|
2000-04-22 10:11:17 +08:00
|
|
|
|
# ifdef P_tmpdir
|
|
|
|
|
# define DEFAULT_TMPDIR P_tmpdir
|
|
|
|
|
# else
|
|
|
|
|
# define DEFAULT_TMPDIR "/tmp"
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
#define DEFAULT_TMPFILE "GmXXXXXX"
|
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (((tmpdir = getenv ("TMPDIR")) == NULL || *tmpdir == '\0')
|
2003-03-25 07:14:15 +08:00
|
|
|
|
#if defined (__MSDOS__) || defined (WINDOWS32) || defined (__EMX__)
|
2000-04-22 10:11:17 +08:00
|
|
|
|
/* These are also used commonly on these platforms. */
|
|
|
|
|
&& ((tmpdir = getenv ("TEMP")) == NULL || *tmpdir == '\0')
|
|
|
|
|
&& ((tmpdir = getenv ("TMP")) == NULL || *tmpdir == '\0')
|
1996-03-20 22:57:41 +08:00
|
|
|
|
#endif
|
2000-04-22 10:11:17 +08:00
|
|
|
|
)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
tmpdir = DEFAULT_TMPDIR;
|
2000-04-22 10:11:17 +08:00
|
|
|
|
|
2012-03-04 16:58:44 +08:00
|
|
|
|
template = alloca (strlen (tmpdir) + CSTRLEN (DEFAULT_TMPFILE) + 2);
|
2013-01-20 13:55:57 +08:00
|
|
|
|
strcpy (template, tmpdir);
|
2000-04-22 10:11:17 +08:00
|
|
|
|
|
2002-08-10 09:27:16 +08:00
|
|
|
|
#ifdef HAVE_DOS_PATHS
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (strchr ("/\\", template[strlen (template) - 1]) == NULL)
|
|
|
|
|
strcat (template, "/");
|
2000-04-22 10:11:17 +08:00
|
|
|
|
#else
|
2002-08-10 09:27:16 +08:00
|
|
|
|
# ifndef VMS
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (template[strlen (template) - 1] != '/')
|
|
|
|
|
strcat (template, "/");
|
2002-08-10 09:27:16 +08:00
|
|
|
|
# endif /* !VMS */
|
|
|
|
|
#endif /* !HAVE_DOS_PATHS */
|
1998-07-31 04:54:47 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
strcat (template, DEFAULT_TMPFILE);
|
2013-09-14 13:04:04 +08:00
|
|
|
|
outfile = output_tmpfile (&stdin_nm, template);
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (outfile == 0)
|
|
|
|
|
pfatal_with_name (_("fopen (temporary file)"));
|
|
|
|
|
while (!feof (stdin) && ! ferror (stdin))
|
|
|
|
|
{
|
|
|
|
|
char buf[2048];
|
|
|
|
|
unsigned int n = fread (buf, 1, sizeof (buf), stdin);
|
|
|
|
|
if (n > 0 && fwrite (buf, 1, n, outfile) != n)
|
|
|
|
|
pfatal_with_name (_("fwrite (temporary file)"));
|
|
|
|
|
}
|
|
|
|
|
fclose (outfile);
|
|
|
|
|
|
|
|
|
|
/* Replace the name that read_all_makefiles will
|
|
|
|
|
see with the name of the temporary file. */
|
2007-03-20 11:02:26 +08:00
|
|
|
|
makefiles->list[i] = strcache_add (stdin_nm);
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
/* Make sure the temporary file will not be remade. */
|
2006-04-10 06:09:24 +08:00
|
|
|
|
{
|
2007-03-20 11:02:26 +08:00
|
|
|
|
struct file *f = enter_file (strcache_add (stdin_nm));
|
2006-04-10 06:09:24 +08:00
|
|
|
|
f->updated = 1;
|
2013-07-15 07:18:21 +08:00
|
|
|
|
f->update_status = us_success;
|
2006-04-10 06:09:24 +08:00
|
|
|
|
f->command_state = cs_finished;
|
|
|
|
|
/* Can't be intermediate, or it'll be removed too early for
|
|
|
|
|
make re-exec. */
|
|
|
|
|
f->intermediate = 0;
|
|
|
|
|
f->dontcare = 0;
|
|
|
|
|
}
|
2013-01-20 13:55:57 +08:00
|
|
|
|
}
|
1992-01-30 07:54:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-25 07:14:15 +08:00
|
|
|
|
#ifndef __EMX__ /* Don't use a SIGCHLD handler for OS/2 */
|
1999-04-25 12:30:55 +08:00
|
|
|
|
#if defined(MAKE_JOBSERVER) || !defined(HAVE_WAIT_NOHANG)
|
1999-08-01 14:05:17 +08:00
|
|
|
|
/* Set up to handle children dying. This must be done before
|
2012-03-04 08:24:20 +08:00
|
|
|
|
reading in the makefiles so that 'shell' function calls will work.
|
1999-08-01 14:05:17 +08:00
|
|
|
|
|
|
|
|
|
If we don't have a hanging wait we have to fall back to old, broken
|
1999-04-25 12:30:55 +08:00
|
|
|
|
functionality here and rely on the signal handler and counting
|
|
|
|
|
children.
|
|
|
|
|
|
1999-07-24 06:46:47 +08:00
|
|
|
|
If we're using the jobs pipe we need a signal handler so that
|
1999-08-01 14:05:17 +08:00
|
|
|
|
SIGCHLD is not ignored; we need it to interrupt the read(2) of the
|
|
|
|
|
jobserver pipe in job.c if we're waiting for a token.
|
1999-07-24 06:46:47 +08:00
|
|
|
|
|
1999-08-01 14:05:17 +08:00
|
|
|
|
If none of these are true, we don't need a signal handler at all. */
|
1998-10-03 13:39:55 +08:00
|
|
|
|
{
|
2006-04-07 09:43:44 +08:00
|
|
|
|
RETSIGTYPE child_handler (int sig);
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# if defined SIGCHLD
|
2001-06-01 11:56:50 +08:00
|
|
|
|
bsd_signal (SIGCHLD, child_handler);
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# endif
|
|
|
|
|
# if defined SIGCLD && SIGCLD != SIGCHLD
|
2001-06-01 11:56:50 +08:00
|
|
|
|
bsd_signal (SIGCLD, child_handler);
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# endif
|
|
|
|
|
}
|
2003-03-25 07:14:15 +08:00
|
|
|
|
#endif
|
1992-01-30 07:54:36 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
1995-01-26 14:29:18 +08:00
|
|
|
|
/* Let the user send us SIGUSR1 to toggle the -d flag during the run. */
|
|
|
|
|
#ifdef SIGUSR1
|
2001-06-01 11:56:50 +08:00
|
|
|
|
bsd_signal (SIGUSR1, debug_signal_handler);
|
1995-01-26 14:29:18 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* Define the initial list of suffixes for old-style rules. */
|
|
|
|
|
set_default_suffixes ();
|
|
|
|
|
|
1993-10-15 06:23:39 +08:00
|
|
|
|
/* Define the file rules for the built-in suffix rules. These will later
|
|
|
|
|
be converted into pattern rules. We used to do this in
|
|
|
|
|
install_default_implicit_rules, but since that happens after reading
|
|
|
|
|
makefiles, it results in the built-in pattern rules taking precedence
|
|
|
|
|
over makefile-specified suffix rules, which is wrong. */
|
|
|
|
|
install_default_suffix_rules ();
|
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* Define some internal and special variables. */
|
|
|
|
|
define_automatic_variables ();
|
|
|
|
|
|
2013-09-16 12:12:09 +08:00
|
|
|
|
/* Set up the MAKEFLAGS and MFLAGS variables for makefiles to see.
|
|
|
|
|
Initialize it to be exported but allow the makefile to reset it. */
|
|
|
|
|
define_makeflags (0, 0)->export = v_export;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1998-07-31 04:54:47 +08:00
|
|
|
|
/* Define the default variables. */
|
|
|
|
|
define_default_variables ();
|
1996-05-23 05:51:45 +08:00
|
|
|
|
|
2007-03-20 11:02:26 +08:00
|
|
|
|
default_file = enter_file (strcache_add (".DEFAULT"));
|
1996-05-23 05:51:45 +08:00
|
|
|
|
|
2009-10-25 08:46:52 +08:00
|
|
|
|
default_goal_var = define_variable_cname (".DEFAULT_GOAL", "", o_file, 0);
|
|
|
|
|
|
|
|
|
|
/* Evaluate all strings provided with --eval.
|
|
|
|
|
Also set up the $(-*-eval-flags-*-) variable. */
|
|
|
|
|
|
|
|
|
|
if (eval_strings)
|
|
|
|
|
{
|
|
|
|
|
char *p, *value;
|
|
|
|
|
unsigned int i;
|
2012-03-04 16:58:44 +08:00
|
|
|
|
unsigned int len = (CSTRLEN ("--eval=") + 1) * eval_strings->idx;
|
2009-10-25 08:46:52 +08:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < eval_strings->idx; ++i)
|
|
|
|
|
{
|
|
|
|
|
p = xstrdup (eval_strings->list[i]);
|
|
|
|
|
len += 2 * strlen (p);
|
2013-02-25 14:38:36 +08:00
|
|
|
|
eval_buffer (p, NULL);
|
2009-10-25 08:46:52 +08:00
|
|
|
|
free (p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p = value = alloca (len);
|
|
|
|
|
for (i = 0; i < eval_strings->idx; ++i)
|
|
|
|
|
{
|
|
|
|
|
strcpy (p, "--eval=");
|
2012-03-04 16:58:44 +08:00
|
|
|
|
p += CSTRLEN ("--eval=");
|
2009-10-25 08:46:52 +08:00
|
|
|
|
p = quote_for_env (p, eval_strings->list[i]);
|
|
|
|
|
*(p++) = ' ';
|
|
|
|
|
}
|
|
|
|
|
p[-1] = '\0';
|
|
|
|
|
|
|
|
|
|
define_variable_cname ("-*-eval-flags-*-", value, o_automatic, 0);
|
|
|
|
|
}
|
2005-02-28 06:24:30 +08:00
|
|
|
|
|
|
|
|
|
/* Read all the makefiles. */
|
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
read_files = read_all_makefiles (makefiles == 0 ? 0 : makefiles->list);
|
1996-05-23 05:51:45 +08:00
|
|
|
|
|
1998-07-31 04:54:47 +08:00
|
|
|
|
#ifdef WINDOWS32
|
|
|
|
|
/* look one last time after reading all Makefiles */
|
|
|
|
|
if (no_default_sh_exe)
|
2013-05-17 14:29:46 +08:00
|
|
|
|
no_default_sh_exe = !find_and_set_default_shell (NULL);
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#endif /* WINDOWS32 */
|
1996-05-23 05:51:45 +08:00
|
|
|
|
|
2003-03-25 07:14:15 +08:00
|
|
|
|
#if defined (__MSDOS__) || defined (__EMX__)
|
1997-04-07 15:21:16 +08:00
|
|
|
|
/* We need to know what kind of shell we will be using. */
|
|
|
|
|
{
|
|
|
|
|
extern int _is_unixy_shell (const char *_path);
|
2005-06-26 02:57:28 +08:00
|
|
|
|
struct variable *shv = lookup_variable (STRING_SIZE_TUPLE ("SHELL"));
|
1997-04-07 15:21:16 +08:00
|
|
|
|
extern int unixy_shell;
|
2014-04-26 05:10:47 +08:00
|
|
|
|
extern const char *default_shell;
|
1997-04-07 15:21:16 +08:00
|
|
|
|
|
|
|
|
|
if (shv && *shv->value)
|
|
|
|
|
{
|
2013-05-17 14:29:46 +08:00
|
|
|
|
char *shell_path = recursively_expand (shv);
|
2013-01-20 13:55:57 +08:00
|
|
|
|
|
|
|
|
|
if (shell_path && _is_unixy_shell (shell_path))
|
|
|
|
|
unixy_shell = 1;
|
|
|
|
|
else
|
|
|
|
|
unixy_shell = 0;
|
|
|
|
|
if (shell_path)
|
|
|
|
|
default_shell = shell_path;
|
1997-04-07 15:21:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-03-25 07:14:15 +08:00
|
|
|
|
#endif /* __MSDOS__ || __EMX__ */
|
1997-04-07 15:21:16 +08:00
|
|
|
|
|
2013-05-13 16:29:35 +08:00
|
|
|
|
{
|
|
|
|
|
int old_builtin_rules_flag = no_builtin_rules_flag;
|
|
|
|
|
int old_builtin_variables_flag = no_builtin_variables_flag;
|
|
|
|
|
|
|
|
|
|
/* Decode switches again, for variables set by the makefile. */
|
|
|
|
|
decode_env_switches (STRING_SIZE_TUPLE ("GNUMAKEFLAGS"));
|
2013-09-30 01:15:00 +08:00
|
|
|
|
|
|
|
|
|
/* Clear GNUMAKEFLAGS to avoid duplication. */
|
|
|
|
|
define_variable_cname ("GNUMAKEFLAGS", "", o_override, 0);
|
|
|
|
|
|
2013-05-13 16:29:35 +08:00
|
|
|
|
decode_env_switches (STRING_SIZE_TUPLE ("MAKEFLAGS"));
|
1993-08-11 14:59:04 +08:00
|
|
|
|
#if 0
|
2013-05-13 16:29:35 +08:00
|
|
|
|
decode_env_switches (STRING_SIZE_TUPLE ("MFLAGS"));
|
1993-08-11 14:59:04 +08:00
|
|
|
|
#endif
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2013-09-30 01:15:00 +08:00
|
|
|
|
/* Reset in case the switches changed our mind. */
|
2013-09-22 05:24:59 +08:00
|
|
|
|
syncing = (output_sync == OUTPUT_SYNC_LINE
|
|
|
|
|
|| output_sync == OUTPUT_SYNC_TARGET);
|
|
|
|
|
|
|
|
|
|
if (make_sync.syncout && ! syncing)
|
|
|
|
|
output_close (&make_sync);
|
|
|
|
|
|
|
|
|
|
make_sync.syncout = syncing;
|
|
|
|
|
OUTPUT_SET (&make_sync);
|
|
|
|
|
|
2013-05-13 16:29:35 +08:00
|
|
|
|
/* If we've disabled builtin rules, get rid of them. */
|
|
|
|
|
if (no_builtin_rules_flag && ! old_builtin_rules_flag)
|
|
|
|
|
{
|
|
|
|
|
if (suffix_file->builtin)
|
|
|
|
|
{
|
|
|
|
|
free_dep_chain (suffix_file->deps);
|
|
|
|
|
suffix_file->deps = 0;
|
|
|
|
|
}
|
|
|
|
|
define_variable_cname ("SUFFIXES", "", o_default, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If we've disabled builtin variables, get rid of them. */
|
|
|
|
|
if (no_builtin_variables_flag && ! old_builtin_variables_flag)
|
|
|
|
|
undefine_default_variables ();
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-01 06:29:19 +08:00
|
|
|
|
#if defined (__MSDOS__) || defined (__EMX__) || defined (VMS)
|
2003-03-25 07:14:15 +08:00
|
|
|
|
if (job_slots != 1
|
|
|
|
|
# ifdef __EMX__
|
|
|
|
|
&& _osmode != OS2_MODE /* turn off -j if we are in DOS mode */
|
|
|
|
|
# endif
|
|
|
|
|
)
|
1999-08-26 05:39:28 +08:00
|
|
|
|
{
|
2013-11-24 11:23:52 +08:00
|
|
|
|
O (error, NILF,
|
|
|
|
|
_("Parallel jobs (-j) are not supported on this platform."));
|
|
|
|
|
O (error, NILF, _("Resetting to single job (-j1) mode."));
|
1999-08-26 05:39:28 +08:00
|
|
|
|
job_slots = 1;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
1999-04-25 12:30:55 +08:00
|
|
|
|
#ifdef MAKE_JOBSERVER
|
1999-08-23 13:35:14 +08:00
|
|
|
|
/* If we have >1 slot but no jobserver-fds, then we're a top-level make.
|
|
|
|
|
Set up the pipe and install the fds option for our children. */
|
1999-04-25 12:30:55 +08:00
|
|
|
|
|
1999-09-01 16:04:30 +08:00
|
|
|
|
if (job_slots > 1)
|
1999-04-25 12:30:55 +08:00
|
|
|
|
{
|
2011-11-14 08:42:49 +08:00
|
|
|
|
#ifdef WINDOWS32
|
|
|
|
|
/* sub_proc.c cannot wait for more than MAXIMUM_WAIT_OBJECTS objects
|
2013-09-14 13:04:04 +08:00
|
|
|
|
* and one of them is the job-server semaphore object. Limit the
|
2011-11-14 08:42:49 +08:00
|
|
|
|
* number of available job slots to (MAXIMUM_WAIT_OBJECTS - 1). */
|
|
|
|
|
|
|
|
|
|
if (job_slots >= MAXIMUM_WAIT_OBJECTS)
|
|
|
|
|
{
|
|
|
|
|
job_slots = MAXIMUM_WAIT_OBJECTS - 1;
|
|
|
|
|
DB (DB_JOBS, (_("Jobserver slots limited to %d\n"), job_slots));
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-17 14:29:46 +08:00
|
|
|
|
if (! create_jobserver_semaphore (job_slots - 1))
|
2011-11-14 08:42:49 +08:00
|
|
|
|
{
|
2013-05-17 14:29:46 +08:00
|
|
|
|
DWORD err = GetLastError ();
|
2013-11-24 11:23:52 +08:00
|
|
|
|
const char *estr = map_windows32_error_to_string (err);
|
2013-11-27 23:57:01 +08:00
|
|
|
|
ONS (fatal, NILF,
|
2013-11-24 11:23:52 +08:00
|
|
|
|
_("creating jobserver semaphore: (Error %ld: %s)"), err, estr);
|
2011-11-14 08:42:49 +08:00
|
|
|
|
}
|
|
|
|
|
#else
|
2012-01-29 04:19:55 +08:00
|
|
|
|
char c = '+';
|
|
|
|
|
|
1999-08-13 15:36:26 +08:00
|
|
|
|
if (pipe (job_fds) < 0 || (job_rfd = dup (job_fds[0])) < 0)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
pfatal_with_name (_("creating jobs pipe"));
|
2011-11-14 08:42:49 +08:00
|
|
|
|
#endif
|
1999-04-25 12:30:55 +08:00
|
|
|
|
|
1999-07-24 06:46:47 +08:00
|
|
|
|
/* Every make assumes that it always has one job it can run. For the
|
|
|
|
|
submakes it's the token they were given by their parent. For the
|
1999-08-24 06:15:17 +08:00
|
|
|
|
top make, we just subtract one from the number the user wants. We
|
|
|
|
|
want job_slots to be 0 to indicate we're using the jobserver. */
|
1999-07-24 06:46:47 +08:00
|
|
|
|
|
2005-05-03 21:57:20 +08:00
|
|
|
|
master_job_slots = job_slots;
|
|
|
|
|
|
2011-11-14 08:42:49 +08:00
|
|
|
|
#ifdef WINDOWS32
|
|
|
|
|
/* We're using the jobserver so set job_slots to 0. */
|
|
|
|
|
job_slots = 0;
|
|
|
|
|
#else
|
1999-07-24 06:46:47 +08:00
|
|
|
|
while (--job_slots)
|
2003-03-25 07:14:15 +08:00
|
|
|
|
{
|
|
|
|
|
int r;
|
|
|
|
|
|
|
|
|
|
EINTRLOOP (r, write (job_fds[1], &c, 1));
|
|
|
|
|
if (r != 1)
|
|
|
|
|
pfatal_with_name (_("init jobserver pipe"));
|
|
|
|
|
}
|
2011-11-14 08:42:49 +08:00
|
|
|
|
#endif
|
1999-08-23 13:35:14 +08:00
|
|
|
|
|
2013-11-24 16:21:40 +08:00
|
|
|
|
/* Fill in the jobserver_fds for our children. */
|
1999-08-23 13:35:14 +08:00
|
|
|
|
|
2011-11-14 08:42:49 +08:00
|
|
|
|
#ifdef WINDOWS32
|
2013-11-24 16:21:40 +08:00
|
|
|
|
jobserver_fds = xmalloc (MAX_PATH + 1);
|
|
|
|
|
strcpy (jobserver_fds, get_jobserver_semaphore_name ());
|
2011-11-14 08:42:49 +08:00
|
|
|
|
#else
|
2013-11-24 16:21:40 +08:00
|
|
|
|
jobserver_fds = xmalloc ((INTSTR_LENGTH * 2) + 2);
|
|
|
|
|
sprintf (jobserver_fds, "%d,%d", job_fds[0], job_fds[1]);
|
2011-11-14 08:42:49 +08:00
|
|
|
|
#endif
|
1999-04-25 12:30:55 +08:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-02-28 15:48:22 +08:00
|
|
|
|
#ifndef MAKE_SYMLINKS
|
|
|
|
|
if (check_symlink_flag)
|
|
|
|
|
{
|
2013-11-24 11:23:52 +08:00
|
|
|
|
O (error, NILF, _("Symbolic links not supported: disabling -L."));
|
2005-02-28 15:48:22 +08:00
|
|
|
|
check_symlink_flag = 0;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* Set up MAKEFLAGS and MFLAGS again, so they will be right. */
|
|
|
|
|
|
|
|
|
|
define_makeflags (1, 0);
|
|
|
|
|
|
2012-03-04 08:24:20 +08:00
|
|
|
|
/* Make each 'struct dep' point at the 'struct file' for the file
|
1994-10-25 06:57:07 +08:00
|
|
|
|
depended on. Also do magic for special targets. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
|
|
|
|
snap_deps ();
|
|
|
|
|
|
1993-10-15 06:23:39 +08:00
|
|
|
|
/* Convert old-style suffix rules to pattern rules. It is important to
|
|
|
|
|
do this before installing the built-in pattern rules below, so that
|
|
|
|
|
makefile-specified suffix rules take precedence over built-in pattern
|
|
|
|
|
rules. */
|
|
|
|
|
|
|
|
|
|
convert_to_pattern ();
|
|
|
|
|
|
|
|
|
|
/* Install the default implicit pattern rules.
|
1992-01-30 07:54:36 +08:00
|
|
|
|
This used to be done before reading the makefiles.
|
|
|
|
|
But in that case, built-in pattern rules were in the chain
|
|
|
|
|
before user-defined ones, so they matched first. */
|
|
|
|
|
|
|
|
|
|
install_default_implicit_rules ();
|
|
|
|
|
|
|
|
|
|
/* Compute implicit rule limits. */
|
|
|
|
|
|
|
|
|
|
count_implicit_rule_limits ();
|
|
|
|
|
|
|
|
|
|
/* Construct the listings of directories in VPATH lists. */
|
|
|
|
|
|
|
|
|
|
build_vpath_lists ();
|
|
|
|
|
|
2005-06-26 04:00:24 +08:00
|
|
|
|
/* Mark files given with -o flags as very old and as having been updated
|
|
|
|
|
already, and files given with -W flags as brand new (time-stamp as far
|
|
|
|
|
as possible into the future). If restarts is set we'll do -W later. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
|
|
|
|
if (old_files != 0)
|
2006-04-10 06:09:24 +08:00
|
|
|
|
{
|
2007-03-20 11:02:26 +08:00
|
|
|
|
const char **p;
|
2006-04-10 06:09:24 +08:00
|
|
|
|
for (p = old_files->list; *p != 0; ++p)
|
|
|
|
|
{
|
2007-03-20 11:02:26 +08:00
|
|
|
|
struct file *f = enter_file (*p);
|
2006-04-10 06:09:24 +08:00
|
|
|
|
f->last_mtime = f->mtime_before_update = OLD_MTIME;
|
|
|
|
|
f->updated = 1;
|
2013-07-15 07:18:21 +08:00
|
|
|
|
f->update_status = us_success;
|
2006-04-10 06:09:24 +08:00
|
|
|
|
f->command_state = cs_finished;
|
|
|
|
|
}
|
|
|
|
|
}
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2005-06-26 04:00:24 +08:00
|
|
|
|
if (!restarts && new_files != 0)
|
1992-01-30 07:54:36 +08:00
|
|
|
|
{
|
2007-03-20 11:02:26 +08:00
|
|
|
|
const char **p;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
for (p = new_files->list; *p != 0; ++p)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
struct file *f = enter_file (*p);
|
|
|
|
|
f->last_mtime = f->mtime_before_update = NEW_MTIME;
|
|
|
|
|
}
|
1992-01-30 07:54:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
1996-06-23 03:31:12 +08:00
|
|
|
|
/* Initialize the remote job module. */
|
|
|
|
|
remote_setup ();
|
|
|
|
|
|
2013-09-22 05:24:59 +08:00
|
|
|
|
/* Dump any output we've collected. */
|
|
|
|
|
|
|
|
|
|
OUTPUT_UNSET ();
|
|
|
|
|
output_close (&make_sync);
|
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (read_files != 0)
|
1992-01-30 07:54:36 +08:00
|
|
|
|
{
|
|
|
|
|
/* Update any makefiles if necessary. */
|
|
|
|
|
|
1998-10-03 13:39:55 +08:00
|
|
|
|
FILE_TIMESTAMP *makefile_mtimes = 0;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
unsigned int mm_idx = 0;
|
2014-04-26 05:10:47 +08:00
|
|
|
|
char **aargv = NULL;
|
|
|
|
|
const char **nargv;
|
2009-06-09 23:35:38 +08:00
|
|
|
|
int nargc;
|
1999-11-22 14:15:35 +08:00
|
|
|
|
int orig_db_level = db_level;
|
2013-07-15 07:18:21 +08:00
|
|
|
|
enum update_status status;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1999-11-22 14:15:35 +08:00
|
|
|
|
if (! ISDB (DB_MAKEFILES))
|
|
|
|
|
db_level = DB_NONE;
|
|
|
|
|
|
|
|
|
|
DB (DB_BASIC, (_("Updating makefiles....\n")));
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
|
|
|
|
/* Remove any makefiles we don't want to try to update.
|
2013-01-20 13:55:57 +08:00
|
|
|
|
Also record the current modtimes so we can compare them later. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
{
|
2013-01-20 13:55:57 +08:00
|
|
|
|
register struct dep *d, *last;
|
|
|
|
|
last = 0;
|
|
|
|
|
d = read_files;
|
|
|
|
|
while (d != 0)
|
|
|
|
|
{
|
|
|
|
|
struct file *f = d->file;
|
|
|
|
|
if (f->double_colon)
|
|
|
|
|
for (f = f->double_colon; f != NULL; f = f->prev)
|
|
|
|
|
{
|
|
|
|
|
if (f->deps == 0 && f->cmds != 0)
|
|
|
|
|
{
|
|
|
|
|
/* This makefile is a :: target with commands, but
|
|
|
|
|
no dependencies. So, it will always be remade.
|
|
|
|
|
This might well cause an infinite loop, so don't
|
|
|
|
|
try to remake it. (This will only happen if
|
|
|
|
|
your makefiles are written exceptionally
|
|
|
|
|
stupidly; but if you work for Athena, that's how
|
|
|
|
|
you write your makefiles.) */
|
|
|
|
|
|
|
|
|
|
DB (DB_VERBOSE,
|
2012-03-04 08:24:20 +08:00
|
|
|
|
(_("Makefile '%s' might loop; not remaking it.\n"),
|
1999-11-22 14:15:35 +08:00
|
|
|
|
f->name));
|
1992-11-17 07:59:17 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (last == 0)
|
|
|
|
|
read_files = d->next;
|
|
|
|
|
else
|
|
|
|
|
last->next = d->next;
|
1992-11-17 07:59:17 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
/* Free the storage. */
|
2006-03-17 22:24:20 +08:00
|
|
|
|
free_dep (d);
|
1992-11-17 07:59:17 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
d = last == 0 ? read_files : last->next;
|
1992-11-17 07:59:17 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (f == NULL || !f->double_colon)
|
|
|
|
|
{
|
2006-04-10 06:09:24 +08:00
|
|
|
|
makefile_mtimes = xrealloc (makefile_mtimes,
|
|
|
|
|
(mm_idx+1)
|
|
|
|
|
* sizeof (FILE_TIMESTAMP));
|
2013-01-20 13:55:57 +08:00
|
|
|
|
makefile_mtimes[mm_idx++] = file_mtime_no_search (d->file);
|
|
|
|
|
last = d;
|
|
|
|
|
d = d->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
1995-11-26 09:37:07 +08:00
|
|
|
|
}
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2012-03-04 08:24:20 +08:00
|
|
|
|
/* Set up 'MAKEFLAGS' specially while remaking makefiles. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
define_makeflags (1, 1);
|
|
|
|
|
|
2004-05-17 03:16:52 +08:00
|
|
|
|
rebuilding_makefiles = 1;
|
2013-01-20 13:55:57 +08:00
|
|
|
|
status = update_goal_chain (read_files);
|
2004-05-17 03:16:52 +08:00
|
|
|
|
rebuilding_makefiles = 0;
|
|
|
|
|
|
|
|
|
|
switch (status)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
2013-07-15 07:18:21 +08:00
|
|
|
|
case us_question:
|
2002-04-21 03:25:54 +08:00
|
|
|
|
/* The only way this can happen is if the user specified -q and asked
|
|
|
|
|
* for one of the makefiles to be remade as a target on the command
|
|
|
|
|
* line. Since we're not actually updating anything with -q we can
|
|
|
|
|
* treat this as "did nothing".
|
|
|
|
|
*/
|
1995-11-26 09:37:07 +08:00
|
|
|
|
|
2013-07-15 07:18:21 +08:00
|
|
|
|
case us_none:
|
2013-01-20 13:55:57 +08:00
|
|
|
|
/* Did nothing. */
|
|
|
|
|
break;
|
|
|
|
|
|
2013-07-15 07:18:21 +08:00
|
|
|
|
case us_failed:
|
2013-01-20 13:55:57 +08:00
|
|
|
|
/* Failed to update. Figure out if we care. */
|
|
|
|
|
{
|
|
|
|
|
/* Nonzero if any makefile was successfully remade. */
|
|
|
|
|
int any_remade = 0;
|
|
|
|
|
/* Nonzero if any makefile we care about failed
|
|
|
|
|
in updating or could not be found at all. */
|
|
|
|
|
int any_failed = 0;
|
|
|
|
|
unsigned int i;
|
1997-04-07 15:21:16 +08:00
|
|
|
|
struct dep *d;
|
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
for (i = 0, d = read_files; d != 0; ++i, d = d->next)
|
1999-07-22 12:20:14 +08:00
|
|
|
|
{
|
|
|
|
|
/* Reset the considered flag; we may need to look at the file
|
|
|
|
|
again to print an error. */
|
|
|
|
|
d->file->considered = 0;
|
|
|
|
|
|
|
|
|
|
if (d->file->updated)
|
1997-04-07 15:21:16 +08:00
|
|
|
|
{
|
1999-07-22 12:20:14 +08:00
|
|
|
|
/* This makefile was updated. */
|
2013-07-15 07:18:21 +08:00
|
|
|
|
if (d->file->update_status == us_success)
|
1997-04-07 15:21:16 +08:00
|
|
|
|
{
|
1999-07-22 12:20:14 +08:00
|
|
|
|
/* It was successfully updated. */
|
|
|
|
|
any_remade |= (file_mtime_no_search (d->file)
|
|
|
|
|
!= makefile_mtimes[i]);
|
|
|
|
|
}
|
|
|
|
|
else if (! (d->changed & RM_DONTCARE))
|
|
|
|
|
{
|
|
|
|
|
FILE_TIMESTAMP mtime;
|
|
|
|
|
/* The update failed and this makefile was not
|
|
|
|
|
from the MAKEFILES variable, so we care. */
|
2013-11-24 11:23:52 +08:00
|
|
|
|
OS (error, NILF, _("Failed to remake makefile '%s'."),
|
|
|
|
|
d->file->name);
|
1999-07-22 12:20:14 +08:00
|
|
|
|
mtime = file_mtime_no_search (d->file);
|
2000-06-13 13:22:52 +08:00
|
|
|
|
any_remade |= (mtime != NONEXISTENT_MTIME
|
1999-07-22 12:20:14 +08:00
|
|
|
|
&& mtime != makefile_mtimes[i]);
|
2004-05-17 03:16:52 +08:00
|
|
|
|
makefile_status = MAKE_FAILURE;
|
1997-04-07 15:21:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
1999-07-22 12:20:14 +08:00
|
|
|
|
else
|
|
|
|
|
/* This makefile was not found at all. */
|
|
|
|
|
if (! (d->changed & RM_DONTCARE))
|
|
|
|
|
{
|
2013-11-24 11:23:52 +08:00
|
|
|
|
const char *dnm = dep_name (d);
|
|
|
|
|
size_t l = strlen (dnm);
|
|
|
|
|
|
1999-07-22 12:20:14 +08:00
|
|
|
|
/* This is a makefile we care about. See how much. */
|
|
|
|
|
if (d->changed & RM_INCLUDED)
|
2013-11-24 11:23:52 +08:00
|
|
|
|
/* An included makefile. We don't need to die, but we
|
|
|
|
|
do want to complain. */
|
|
|
|
|
error (NILF, l,
|
|
|
|
|
_("Included makefile '%s' was not found."), dnm);
|
1999-07-22 12:20:14 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* A normal makefile. We must die later. */
|
2013-11-24 11:23:52 +08:00
|
|
|
|
error (NILF, l,
|
|
|
|
|
_("Makefile '%s' was not found"), dnm);
|
1999-07-22 12:20:14 +08:00
|
|
|
|
any_failed = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-06-14 13:26:28 +08:00
|
|
|
|
/* Reset this to empty so we get the right error message below. */
|
2013-01-20 13:55:57 +08:00
|
|
|
|
read_files = 0;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (any_remade)
|
|
|
|
|
goto re_exec;
|
|
|
|
|
if (any_failed)
|
2014-08-25 04:06:15 +08:00
|
|
|
|
die (MAKE_FAILURE);
|
1999-07-09 06:32:38 +08:00
|
|
|
|
break;
|
2013-01-20 13:55:57 +08:00
|
|
|
|
}
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2013-07-15 07:18:21 +08:00
|
|
|
|
case us_success:
|
2013-01-20 13:55:57 +08:00
|
|
|
|
re_exec:
|
|
|
|
|
/* Updated successfully. Re-exec ourselves. */
|
1993-06-04 08:27:28 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
remove_intermediates (0);
|
1993-06-04 08:27:28 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (print_data_base_flag)
|
|
|
|
|
print_data_base ();
|
1993-06-04 08:27:28 +08:00
|
|
|
|
|
2006-03-20 10:36:36 +08:00
|
|
|
|
clean_jobserver (0);
|
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (makefiles != 0)
|
|
|
|
|
{
|
|
|
|
|
/* These names might have changed. */
|
|
|
|
|
int i, j = 0;
|
|
|
|
|
for (i = 1; i < argc; ++i)
|
|
|
|
|
if (strneq (argv[i], "-f", 2)) /* XXX */
|
|
|
|
|
{
|
|
|
|
|
if (argv[i][2] == '\0')
|
2007-03-20 11:02:26 +08:00
|
|
|
|
/* This cast is OK since we never modify argv. */
|
2013-01-20 13:55:57 +08:00
|
|
|
|
argv[++i] = (char *) makefiles->list[j];
|
|
|
|
|
else
|
|
|
|
|
argv[i] = xstrdup (concat (2, "-f", makefiles->list[j]));
|
|
|
|
|
++j;
|
|
|
|
|
}
|
|
|
|
|
}
|
1993-06-04 08:27:28 +08:00
|
|
|
|
|
1998-07-31 04:54:47 +08:00
|
|
|
|
/* Add -o option for the stdin temporary file, if necessary. */
|
2009-06-09 23:35:38 +08:00
|
|
|
|
nargc = argc;
|
1998-07-31 04:54:47 +08:00
|
|
|
|
if (stdin_nm)
|
|
|
|
|
{
|
2014-04-26 05:10:47 +08:00
|
|
|
|
void *m = xmalloc ((nargc + 2) * sizeof (char *));
|
|
|
|
|
aargv = m;
|
|
|
|
|
memcpy (aargv, argv, argc * sizeof (char *));
|
|
|
|
|
aargv[nargc++] = xstrdup (concat (2, "-o", stdin_nm));
|
|
|
|
|
aargv[nargc] = 0;
|
|
|
|
|
nargv = m;
|
1998-07-31 04:54:47 +08:00
|
|
|
|
}
|
2009-06-09 23:35:38 +08:00
|
|
|
|
else
|
2014-04-26 05:10:47 +08:00
|
|
|
|
nargv = (const char**)argv;
|
1997-04-07 15:21:16 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (directories != 0 && directories->idx > 0)
|
|
|
|
|
{
|
|
|
|
|
int bad = 1;
|
|
|
|
|
if (directory_before_chdir != 0)
|
|
|
|
|
{
|
|
|
|
|
if (chdir (directory_before_chdir) < 0)
|
|
|
|
|
perror_with_name ("chdir", "");
|
|
|
|
|
else
|
|
|
|
|
bad = 0;
|
|
|
|
|
}
|
|
|
|
|
if (bad)
|
2013-11-24 11:23:52 +08:00
|
|
|
|
O (fatal, NILF,
|
|
|
|
|
_("Couldn't change back to original directory."));
|
2013-01-20 13:55:57 +08:00
|
|
|
|
}
|
1993-06-04 08:27:28 +08:00
|
|
|
|
|
2005-06-26 02:57:28 +08:00
|
|
|
|
++restarts;
|
|
|
|
|
|
2011-09-19 07:39:26 +08:00
|
|
|
|
/* If we're re-exec'ing the first make, put back the number of
|
|
|
|
|
job slots so define_makefiles() will get it right. */
|
|
|
|
|
if (master_job_slots)
|
|
|
|
|
job_slots = master_job_slots;
|
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (ISDB (DB_BASIC))
|
|
|
|
|
{
|
2014-04-26 05:10:47 +08:00
|
|
|
|
const char **p;
|
2013-01-20 13:55:57 +08:00
|
|
|
|
printf (_("Re-executing[%u]:"), restarts);
|
|
|
|
|
for (p = nargv; *p != 0; ++p)
|
|
|
|
|
printf (" %s", *p);
|
|
|
|
|
putchar ('\n');
|
|
|
|
|
}
|
2005-06-26 02:57:28 +08:00
|
|
|
|
|
Thu May 9 13:54:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* GNUmakefile (globfiles): Add AmigaDOS support files.
(distfiles): Add $(amigafiles).
(amigafiles): New variable.
Thu Nov 7 10:18:16 1995 Aaron Digulla <digulla@fh-konstanz.de>
* Added Amiga support in commands.c, dir.c, function.c,
job.c, main.c, make.h, read.c, remake.c
* commands.c: Amiga has neither SIGHUP nor SIGQUIT
* dir.c: Amiga has filenames with Upper- and Lowercase,
but "FileName" is the same as "filename". Added strieq()
which is use to compare filenames. This is like streq()
on all other systems. Also there is no such thing as
"." under AmigaDOS.
* function.c: On Amiga, the environment is not passed as envp,
there are no pipes and Amiga can't fork. Use my own function
to create a new child.
* job.c: default_shell is "" (The system automatically chooses
a shell for me). Have to use the same workaround as MSDOS for
running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't
known on Amiga. Cloned code to run children from MSDOS. Own
version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga.
* main.c: Force stack to 20000 bytes. Read environment from ENV:
device. On Amiga, exec_command() does return, so I exit()
afterwards.
* make.h: Added strieq() to compare filenames.
* read.c: Amiga needs special extension to have passwd. Only
one include-dir. "Makefile" and "makefile" are the same.
Added "SMakefile". Added special code to handle device names (xxx:)
and "./" in rules.
* remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib"
instead of "lib%s.a".
* main.c, rule.c, variable.c: Avoid floats at all costs.
* vpath.c: Get rid of as many alloca()s as possible.
1996-05-10 02:02:06 +08:00
|
|
|
|
#ifndef _AMIGA
|
2006-04-10 06:09:24 +08:00
|
|
|
|
{
|
|
|
|
|
char **p;
|
|
|
|
|
for (p = environ; *p != 0; ++p)
|
|
|
|
|
{
|
2013-09-16 12:12:09 +08:00
|
|
|
|
if (strneq (*p, MAKELEVEL_NAME "=", MAKELEVEL_LENGTH+1))
|
2006-04-10 06:09:24 +08:00
|
|
|
|
{
|
|
|
|
|
*p = alloca (40);
|
|
|
|
|
sprintf (*p, "%s=%u", MAKELEVEL_NAME, makelevel);
|
|
|
|
|
}
|
2013-09-16 12:12:09 +08:00
|
|
|
|
else if (strneq (*p, "MAKE_RESTARTS=", CSTRLEN ("MAKE_RESTARTS=")))
|
2006-04-10 06:09:24 +08:00
|
|
|
|
{
|
|
|
|
|
*p = alloca (40);
|
2013-09-19 13:15:22 +08:00
|
|
|
|
sprintf (*p, "MAKE_RESTARTS=%s%u",
|
|
|
|
|
OUTPUT_IS_TRACED () ? "-" : "", restarts);
|
2006-04-10 06:09:24 +08:00
|
|
|
|
restarts = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
Thu May 9 13:54:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* GNUmakefile (globfiles): Add AmigaDOS support files.
(distfiles): Add $(amigafiles).
(amigafiles): New variable.
Thu Nov 7 10:18:16 1995 Aaron Digulla <digulla@fh-konstanz.de>
* Added Amiga support in commands.c, dir.c, function.c,
job.c, main.c, make.h, read.c, remake.c
* commands.c: Amiga has neither SIGHUP nor SIGQUIT
* dir.c: Amiga has filenames with Upper- and Lowercase,
but "FileName" is the same as "filename". Added strieq()
which is use to compare filenames. This is like streq()
on all other systems. Also there is no such thing as
"." under AmigaDOS.
* function.c: On Amiga, the environment is not passed as envp,
there are no pipes and Amiga can't fork. Use my own function
to create a new child.
* job.c: default_shell is "" (The system automatically chooses
a shell for me). Have to use the same workaround as MSDOS for
running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't
known on Amiga. Cloned code to run children from MSDOS. Own
version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga.
* main.c: Force stack to 20000 bytes. Read environment from ENV:
device. On Amiga, exec_command() does return, so I exit()
afterwards.
* make.h: Added strieq() to compare filenames.
* read.c: Amiga needs special extension to have passwd. Only
one include-dir. "Makefile" and "makefile" are the same.
Added "SMakefile". Added special code to handle device names (xxx:)
and "./" in rules.
* remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib"
instead of "lib%s.a".
* main.c, rule.c, variable.c: Avoid floats at all costs.
* vpath.c: Get rid of as many alloca()s as possible.
1996-05-10 02:02:06 +08:00
|
|
|
|
#else /* AMIGA */
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
char buffer[256];
|
Thu May 9 13:54:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* GNUmakefile (globfiles): Add AmigaDOS support files.
(distfiles): Add $(amigafiles).
(amigafiles): New variable.
Thu Nov 7 10:18:16 1995 Aaron Digulla <digulla@fh-konstanz.de>
* Added Amiga support in commands.c, dir.c, function.c,
job.c, main.c, make.h, read.c, remake.c
* commands.c: Amiga has neither SIGHUP nor SIGQUIT
* dir.c: Amiga has filenames with Upper- and Lowercase,
but "FileName" is the same as "filename". Added strieq()
which is use to compare filenames. This is like streq()
on all other systems. Also there is no such thing as
"." under AmigaDOS.
* function.c: On Amiga, the environment is not passed as envp,
there are no pipes and Amiga can't fork. Use my own function
to create a new child.
* job.c: default_shell is "" (The system automatically chooses
a shell for me). Have to use the same workaround as MSDOS for
running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't
known on Amiga. Cloned code to run children from MSDOS. Own
version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga.
* main.c: Force stack to 20000 bytes. Read environment from ENV:
device. On Amiga, exec_command() does return, so I exit()
afterwards.
* make.h: Added strieq() to compare filenames.
* read.c: Amiga needs special extension to have passwd. Only
one include-dir. "Makefile" and "makefile" are the same.
Added "SMakefile". Added special code to handle device names (xxx:)
and "./" in rules.
* remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib"
instead of "lib%s.a".
* main.c, rule.c, variable.c: Avoid floats at all costs.
* vpath.c: Get rid of as many alloca()s as possible.
1996-05-10 02:02:06 +08:00
|
|
|
|
|
2005-06-26 02:57:28 +08:00
|
|
|
|
sprintf (buffer, "%u", makelevel);
|
|
|
|
|
SetVar (MAKELEVEL_NAME, buffer, -1, GVF_GLOBAL_ONLY);
|
1996-05-14 02:40:11 +08:00
|
|
|
|
|
2013-09-19 13:15:22 +08:00
|
|
|
|
sprintf (buffer, "%s%u", OUTPUT_IS_TRACED () ? "-" : "", restarts);
|
2005-06-26 02:57:28 +08:00
|
|
|
|
SetVar ("MAKE_RESTARTS", buffer, -1, GVF_GLOBAL_ONLY);
|
|
|
|
|
restarts = 0;
|
2013-01-20 13:55:57 +08:00
|
|
|
|
}
|
Thu May 9 13:54:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* GNUmakefile (globfiles): Add AmigaDOS support files.
(distfiles): Add $(amigafiles).
(amigafiles): New variable.
Thu Nov 7 10:18:16 1995 Aaron Digulla <digulla@fh-konstanz.de>
* Added Amiga support in commands.c, dir.c, function.c,
job.c, main.c, make.h, read.c, remake.c
* commands.c: Amiga has neither SIGHUP nor SIGQUIT
* dir.c: Amiga has filenames with Upper- and Lowercase,
but "FileName" is the same as "filename". Added strieq()
which is use to compare filenames. This is like streq()
on all other systems. Also there is no such thing as
"." under AmigaDOS.
* function.c: On Amiga, the environment is not passed as envp,
there are no pipes and Amiga can't fork. Use my own function
to create a new child.
* job.c: default_shell is "" (The system automatically chooses
a shell for me). Have to use the same workaround as MSDOS for
running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't
known on Amiga. Cloned code to run children from MSDOS. Own
version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga.
* main.c: Force stack to 20000 bytes. Read environment from ENV:
device. On Amiga, exec_command() does return, so I exit()
afterwards.
* make.h: Added strieq() to compare filenames.
* read.c: Amiga needs special extension to have passwd. Only
one include-dir. "Makefile" and "makefile" are the same.
Added "SMakefile". Added special code to handle device names (xxx:)
and "./" in rules.
* remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib"
instead of "lib%s.a".
* main.c, rule.c, variable.c: Avoid floats at all costs.
* vpath.c: Get rid of as many alloca()s as possible.
1996-05-10 02:02:06 +08:00
|
|
|
|
#endif
|
1993-06-04 08:27:28 +08:00
|
|
|
|
|
2005-06-26 02:57:28 +08:00
|
|
|
|
/* If we didn't set the restarts variable yet, add it. */
|
|
|
|
|
if (restarts)
|
|
|
|
|
{
|
|
|
|
|
char *b = alloca (40);
|
2013-09-19 13:15:22 +08:00
|
|
|
|
sprintf (b, "MAKE_RESTARTS=%s%u",
|
|
|
|
|
OUTPUT_IS_TRACED () ? "-" : "", restarts);
|
2005-06-26 02:57:28 +08:00
|
|
|
|
putenv (b);
|
|
|
|
|
}
|
1993-06-04 08:27:28 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
fflush (stdout);
|
|
|
|
|
fflush (stderr);
|
1993-06-04 08:27:28 +08:00
|
|
|
|
|
1999-09-24 02:23:33 +08:00
|
|
|
|
/* Close the dup'd jobserver pipe if we opened one. */
|
1999-09-01 16:04:30 +08:00
|
|
|
|
if (job_rfd >= 0)
|
|
|
|
|
close (job_rfd);
|
|
|
|
|
|
2003-03-25 07:14:15 +08:00
|
|
|
|
#ifdef _AMIGA
|
2013-01-20 13:55:57 +08:00
|
|
|
|
exec_command (nargv);
|
|
|
|
|
exit (0);
|
2003-03-25 07:14:15 +08:00
|
|
|
|
#elif defined (__EMX__)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
/* It is not possible to use execve() here because this
|
|
|
|
|
would cause the parent process to be terminated with
|
|
|
|
|
exit code 0 before the child process has been terminated.
|
|
|
|
|
Therefore it may be the best solution simply to spawn the
|
|
|
|
|
child process including all file handles and to wait for its
|
|
|
|
|
termination. */
|
|
|
|
|
int pid;
|
2013-07-15 07:18:21 +08:00
|
|
|
|
int r;
|
2013-09-22 03:23:05 +08:00
|
|
|
|
pid = child_execute_job (FD_STDIN, FD_STDOUT, FD_STDERR,
|
|
|
|
|
nargv, environ);
|
2013-01-20 13:55:57 +08:00
|
|
|
|
|
|
|
|
|
/* is this loop really necessary? */
|
|
|
|
|
do {
|
2013-07-15 07:18:21 +08:00
|
|
|
|
pid = wait (&r);
|
2013-01-20 13:55:57 +08:00
|
|
|
|
} while (pid <= 0);
|
|
|
|
|
/* use the exit code of the child process */
|
2013-07-15 07:18:21 +08:00
|
|
|
|
exit (WIFEXITED(r) ? WEXITSTATUS(r) : EXIT_FAILURE);
|
2013-01-20 13:55:57 +08:00
|
|
|
|
}
|
2003-03-25 07:14:15 +08:00
|
|
|
|
#else
|
2014-04-26 05:10:47 +08:00
|
|
|
|
exec_command ((char **)nargv, environ);
|
Thu May 9 13:54:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* GNUmakefile (globfiles): Add AmigaDOS support files.
(distfiles): Add $(amigafiles).
(amigafiles): New variable.
Thu Nov 7 10:18:16 1995 Aaron Digulla <digulla@fh-konstanz.de>
* Added Amiga support in commands.c, dir.c, function.c,
job.c, main.c, make.h, read.c, remake.c
* commands.c: Amiga has neither SIGHUP nor SIGQUIT
* dir.c: Amiga has filenames with Upper- and Lowercase,
but "FileName" is the same as "filename". Added strieq()
which is use to compare filenames. This is like streq()
on all other systems. Also there is no such thing as
"." under AmigaDOS.
* function.c: On Amiga, the environment is not passed as envp,
there are no pipes and Amiga can't fork. Use my own function
to create a new child.
* job.c: default_shell is "" (The system automatically chooses
a shell for me). Have to use the same workaround as MSDOS for
running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't
known on Amiga. Cloned code to run children from MSDOS. Own
version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga.
* main.c: Force stack to 20000 bytes. Read environment from ENV:
device. On Amiga, exec_command() does return, so I exit()
afterwards.
* make.h: Added strieq() to compare filenames.
* read.c: Amiga needs special extension to have passwd. Only
one include-dir. "Makefile" and "makefile" are the same.
Added "SMakefile". Added special code to handle device names (xxx:)
and "./" in rules.
* remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib"
instead of "lib%s.a".
* main.c, rule.c, variable.c: Avoid floats at all costs.
* vpath.c: Get rid of as many alloca()s as possible.
1996-05-10 02:02:06 +08:00
|
|
|
|
#endif
|
2014-04-26 05:10:47 +08:00
|
|
|
|
free (aargv);
|
|
|
|
|
break;
|
2013-01-20 13:55:57 +08:00
|
|
|
|
}
|
1999-11-22 14:15:35 +08:00
|
|
|
|
|
|
|
|
|
db_level = orig_db_level;
|
2004-03-22 23:11:48 +08:00
|
|
|
|
|
2014-04-26 05:38:08 +08:00
|
|
|
|
/* Free the makefile mtimes. */
|
|
|
|
|
free (makefile_mtimes);
|
1992-01-30 07:54:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
2012-03-04 08:24:20 +08:00
|
|
|
|
/* Set up 'MAKEFLAGS' again for the normal targets. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
define_makeflags (1, 0);
|
|
|
|
|
|
2005-06-26 02:57:28 +08:00
|
|
|
|
/* Set always_make_flag if -B was given. */
|
|
|
|
|
always_make_flag = always_make_set;
|
|
|
|
|
|
2005-06-26 04:00:24 +08:00
|
|
|
|
/* If restarts is set we haven't set up -W files yet, so do that now. */
|
|
|
|
|
if (restarts && new_files != 0)
|
|
|
|
|
{
|
2007-03-20 11:02:26 +08:00
|
|
|
|
const char **p;
|
2005-06-26 04:00:24 +08:00
|
|
|
|
for (p = new_files->list; *p != 0; ++p)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
struct file *f = enter_file (*p);
|
|
|
|
|
f->last_mtime = f->mtime_before_update = NEW_MTIME;
|
|
|
|
|
}
|
2005-06-26 04:00:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
1998-07-31 04:54:47 +08:00
|
|
|
|
/* If there is a temp file from reading a makefile from stdin, get rid of
|
|
|
|
|
it now. */
|
1999-08-19 12:43:46 +08:00
|
|
|
|
if (stdin_nm && unlink (stdin_nm) < 0 && errno != ENOENT)
|
|
|
|
|
perror_with_name (_("unlink (temporary file): "), stdin_nm);
|
1998-07-31 04:54:47 +08:00
|
|
|
|
|
2009-06-04 14:30:27 +08:00
|
|
|
|
/* If there were no command-line goals, use the default. */
|
|
|
|
|
if (goals == 0)
|
|
|
|
|
{
|
|
|
|
|
char *p;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2009-06-04 14:30:27 +08:00
|
|
|
|
if (default_goal_var->recursive)
|
|
|
|
|
p = variable_expand (default_goal_var->value);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
p = variable_buffer_output (variable_buffer, default_goal_var->value,
|
|
|
|
|
strlen (default_goal_var->value));
|
|
|
|
|
*p = '\0';
|
|
|
|
|
p = variable_buffer;
|
|
|
|
|
}
|
2005-02-28 06:24:30 +08:00
|
|
|
|
|
2009-06-04 14:30:27 +08:00
|
|
|
|
if (*p != '\0')
|
|
|
|
|
{
|
|
|
|
|
struct file *f = lookup_file (p);
|
2005-02-28 06:24:30 +08:00
|
|
|
|
|
2009-06-04 14:30:27 +08:00
|
|
|
|
/* If .DEFAULT_GOAL is a non-existent target, enter it into the
|
|
|
|
|
table and let the standard logic sort it out. */
|
|
|
|
|
if (f == 0)
|
|
|
|
|
{
|
|
|
|
|
struct nameseq *ns;
|
2005-02-28 06:24:30 +08:00
|
|
|
|
|
2013-07-22 14:19:13 +08:00
|
|
|
|
ns = PARSE_SIMPLE_SEQ (&p, struct nameseq);
|
2009-06-04 14:30:27 +08:00
|
|
|
|
if (ns)
|
|
|
|
|
{
|
|
|
|
|
/* .DEFAULT_GOAL should contain one target. */
|
|
|
|
|
if (ns->next != 0)
|
2013-11-24 11:23:52 +08:00
|
|
|
|
O (fatal, NILF,
|
|
|
|
|
_(".DEFAULT_GOAL contains more than one target"));
|
2005-02-28 06:24:30 +08:00
|
|
|
|
|
2009-06-04 14:30:27 +08:00
|
|
|
|
f = enter_file (strcache_add (ns->name));
|
2005-02-28 06:24:30 +08:00
|
|
|
|
|
2009-06-04 14:30:27 +08:00
|
|
|
|
ns->name = 0; /* It was reused by enter_file(). */
|
|
|
|
|
free_ns_chain (ns);
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-02-28 06:24:30 +08:00
|
|
|
|
|
2009-06-04 14:30:27 +08:00
|
|
|
|
if (f)
|
|
|
|
|
{
|
|
|
|
|
goals = alloc_dep ();
|
|
|
|
|
goals->file = f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
lastgoal->next = 0;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2005-02-28 06:24:30 +08:00
|
|
|
|
|
2009-06-04 14:30:27 +08:00
|
|
|
|
if (!goals)
|
|
|
|
|
{
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (read_files == 0)
|
2013-11-24 11:23:52 +08:00
|
|
|
|
O (fatal, NILF, _("No targets specified and no makefile found"));
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2013-11-24 11:23:52 +08:00
|
|
|
|
O (fatal, NILF, _("No targets"));
|
2009-06-04 14:30:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Update the goals. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2009-06-04 14:30:27 +08:00
|
|
|
|
DB (DB_BASIC, (_("Updating goal targets....\n")));
|
1999-04-13 10:28:27 +08:00
|
|
|
|
|
2009-06-04 14:30:27 +08:00
|
|
|
|
{
|
2004-05-17 03:16:52 +08:00
|
|
|
|
switch (update_goal_chain (goals))
|
1999-04-13 10:28:27 +08:00
|
|
|
|
{
|
2013-07-15 07:18:21 +08:00
|
|
|
|
case us_none:
|
1999-04-13 10:28:27 +08:00
|
|
|
|
/* Nothing happened. */
|
2013-07-15 07:18:21 +08:00
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
|
case us_success:
|
|
|
|
|
/* Keep the previous result. */
|
2000-06-24 03:43:11 +08:00
|
|
|
|
break;
|
2013-07-15 07:18:21 +08:00
|
|
|
|
case us_question:
|
2000-06-24 03:43:11 +08:00
|
|
|
|
/* We are under -q and would run some commands. */
|
2013-07-15 07:18:21 +08:00
|
|
|
|
makefile_status = MAKE_TROUBLE;
|
1999-04-13 10:28:27 +08:00
|
|
|
|
break;
|
2013-07-15 07:18:21 +08:00
|
|
|
|
case us_failed:
|
1999-04-13 10:28:27 +08:00
|
|
|
|
/* Updating failed. POSIX.2 specifies exit status >1 for this;
|
|
|
|
|
but in VMS, there is only success and failure. */
|
2013-07-15 07:18:21 +08:00
|
|
|
|
makefile_status = MAKE_FAILURE;
|
1999-04-13 10:28:27 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
1997-08-19 02:11:04 +08:00
|
|
|
|
/* If we detected some clock skew, generate one last warning */
|
|
|
|
|
if (clock_skew_detected)
|
2013-11-24 11:23:52 +08:00
|
|
|
|
O (error, NILF,
|
|
|
|
|
_("warning: Clock skew detected. Your build may be incomplete."));
|
1997-08-19 02:11:04 +08:00
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* Exit. */
|
2013-07-15 07:18:21 +08:00
|
|
|
|
die (makefile_status);
|
1992-01-30 07:54:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-06-13 06:22:07 +08:00
|
|
|
|
/* NOTREACHED */
|
2014-08-25 04:06:15 +08:00
|
|
|
|
exit (MAKE_SUCCESS);
|
1992-01-30 07:54:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
1993-01-07 08:34:28 +08:00
|
|
|
|
/* Parsing of arguments, decoding of switches. */
|
|
|
|
|
|
1994-09-07 07:13:43 +08:00
|
|
|
|
static char options[1 + sizeof (switches) / sizeof (switches[0]) * 3];
|
1993-01-07 08:34:28 +08:00
|
|
|
|
static struct option long_options[(sizeof (switches) / sizeof (switches[0])) +
|
2013-01-20 13:55:57 +08:00
|
|
|
|
(sizeof (long_option_aliases) /
|
|
|
|
|
sizeof (long_option_aliases[0]))];
|
1993-01-07 08:34:28 +08:00
|
|
|
|
|
|
|
|
|
/* Fill in the string and vector for getopt. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
static void
|
2002-10-15 05:54:04 +08:00
|
|
|
|
init_switches (void)
|
1992-01-30 07:54:36 +08:00
|
|
|
|
{
|
2004-02-24 21:50:19 +08:00
|
|
|
|
char *p;
|
|
|
|
|
unsigned int c;
|
|
|
|
|
unsigned int i;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1993-01-07 08:34:28 +08:00
|
|
|
|
if (options[0] != '\0')
|
|
|
|
|
/* Already done. */
|
|
|
|
|
return;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1992-05-09 12:28:28 +08:00
|
|
|
|
p = options;
|
1994-09-09 13:37:40 +08:00
|
|
|
|
|
|
|
|
|
/* Return switch and non-switch args in order, regardless of
|
1994-09-09 14:45:51 +08:00
|
|
|
|
POSIXLY_CORRECT. Non-switch args are returned as option 1. */
|
1994-09-09 13:37:40 +08:00
|
|
|
|
*p++ = '-';
|
|
|
|
|
|
1992-05-09 12:28:28 +08:00
|
|
|
|
for (i = 0; switches[i].c != '\0'; ++i)
|
|
|
|
|
{
|
1992-05-12 02:11:40 +08:00
|
|
|
|
long_options[i].name = (switches[i].long_name == 0 ? "" :
|
2013-01-20 13:55:57 +08:00
|
|
|
|
switches[i].long_name);
|
1992-05-26 07:02:13 +08:00
|
|
|
|
long_options[i].flag = 0;
|
1993-04-15 02:20:33 +08:00
|
|
|
|
long_options[i].val = switches[i].c;
|
1999-09-01 01:02:31 +08:00
|
|
|
|
if (short_option (switches[i].c))
|
2013-01-20 13:55:57 +08:00
|
|
|
|
*p++ = switches[i].c;
|
1992-05-09 12:28:28 +08:00
|
|
|
|
switch (switches[i].type)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
case flag:
|
|
|
|
|
case flag_off:
|
|
|
|
|
case ignore:
|
|
|
|
|
long_options[i].has_arg = no_argument;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case string:
|
2013-11-24 16:21:40 +08:00
|
|
|
|
case strlist:
|
2007-03-20 11:02:26 +08:00
|
|
|
|
case filename:
|
2013-01-20 13:55:57 +08:00
|
|
|
|
case positive_int:
|
|
|
|
|
case floating:
|
|
|
|
|
if (short_option (switches[i].c))
|
|
|
|
|
*p++ = ':';
|
|
|
|
|
if (switches[i].noarg_value != 0)
|
|
|
|
|
{
|
|
|
|
|
if (short_option (switches[i].c))
|
|
|
|
|
*p++ = ':';
|
|
|
|
|
long_options[i].has_arg = optional_argument;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
long_options[i].has_arg = required_argument;
|
|
|
|
|
break;
|
|
|
|
|
}
|
1992-05-09 12:28:28 +08:00
|
|
|
|
}
|
|
|
|
|
*p = '\0';
|
1992-05-11 13:28:52 +08:00
|
|
|
|
for (c = 0; c < (sizeof (long_option_aliases) /
|
2013-01-20 13:55:57 +08:00
|
|
|
|
sizeof (long_option_aliases[0]));
|
1992-05-11 13:28:52 +08:00
|
|
|
|
++c)
|
|
|
|
|
long_options[i++] = long_option_aliases[c];
|
1992-05-09 12:28:28 +08:00
|
|
|
|
long_options[i].name = 0;
|
1993-01-07 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-16 01:22:51 +08:00
|
|
|
|
|
|
|
|
|
/* Non-option argument. It might be a variable definition. */
|
1995-03-24 13:56:41 +08:00
|
|
|
|
static void
|
2014-04-26 05:10:47 +08:00
|
|
|
|
handle_non_switch_argument (const char *arg, int env)
|
1995-03-24 13:56:41 +08:00
|
|
|
|
{
|
|
|
|
|
struct variable *v;
|
2013-04-16 01:22:51 +08:00
|
|
|
|
|
1995-03-24 13:56:41 +08:00
|
|
|
|
if (arg[0] == '-' && arg[1] == '\0')
|
2012-03-04 08:24:20 +08:00
|
|
|
|
/* Ignore plain '-' for compatibility. */
|
1995-03-24 13:56:41 +08:00
|
|
|
|
return;
|
2013-04-16 01:22:51 +08:00
|
|
|
|
|
1999-11-17 15:33:47 +08:00
|
|
|
|
v = try_variable_definition (0, arg, o_command, 0);
|
1995-03-24 13:56:41 +08:00
|
|
|
|
if (v != 0)
|
|
|
|
|
{
|
2005-02-10 08:10:57 +08:00
|
|
|
|
/* It is indeed a variable definition. If we don't already have this
|
2013-01-20 13:55:57 +08:00
|
|
|
|
one, record a pointer to the variable for later use in
|
|
|
|
|
define_makeflags. */
|
2005-02-10 08:10:57 +08:00
|
|
|
|
struct command_variable *cv;
|
|
|
|
|
|
|
|
|
|
for (cv = command_variables; cv != 0; cv = cv->next)
|
|
|
|
|
if (cv->variable == v)
|
|
|
|
|
break;
|
|
|
|
|
|
2013-05-17 14:29:46 +08:00
|
|
|
|
if (! cv)
|
|
|
|
|
{
|
|
|
|
|
cv = xmalloc (sizeof (*cv));
|
|
|
|
|
cv->variable = v;
|
|
|
|
|
cv->next = command_variables;
|
|
|
|
|
command_variables = cv;
|
|
|
|
|
}
|
1995-03-24 13:56:41 +08:00
|
|
|
|
}
|
|
|
|
|
else if (! env)
|
|
|
|
|
{
|
|
|
|
|
/* Not an option or variable definition; it must be a goal
|
2013-01-20 13:55:57 +08:00
|
|
|
|
target! Enter it as a file and add it to the dep chain of
|
|
|
|
|
goals. */
|
2007-03-20 11:02:26 +08:00
|
|
|
|
struct file *f = enter_file (strcache_add (expand_command_line_file (arg)));
|
1995-03-24 13:56:41 +08:00
|
|
|
|
f->cmd_target = 1;
|
1995-11-26 09:37:07 +08:00
|
|
|
|
|
1995-03-24 13:56:41 +08:00
|
|
|
|
if (goals == 0)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
goals = alloc_dep ();
|
|
|
|
|
lastgoal = goals;
|
|
|
|
|
}
|
1995-03-24 13:56:41 +08:00
|
|
|
|
else
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
lastgoal->next = alloc_dep ();
|
|
|
|
|
lastgoal = lastgoal->next;
|
|
|
|
|
}
|
2006-03-17 22:24:20 +08:00
|
|
|
|
|
1995-03-24 13:56:41 +08:00
|
|
|
|
lastgoal->file = f;
|
1997-04-07 15:21:16 +08:00
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
/* Add this target name to the MAKECMDGOALS variable. */
|
2006-04-10 06:09:24 +08:00
|
|
|
|
struct variable *gv;
|
2007-03-20 11:02:26 +08:00
|
|
|
|
const char *value;
|
1997-04-07 15:21:16 +08:00
|
|
|
|
|
2006-04-10 06:09:24 +08:00
|
|
|
|
gv = lookup_variable (STRING_SIZE_TUPLE ("MAKECMDGOALS"));
|
|
|
|
|
if (gv == 0)
|
1997-04-07 15:21:16 +08:00
|
|
|
|
value = f->name;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Paste the old and new values together */
|
|
|
|
|
unsigned int oldlen, newlen;
|
2007-03-20 11:02:26 +08:00
|
|
|
|
char *vp;
|
1997-04-07 15:21:16 +08:00
|
|
|
|
|
2006-04-10 06:09:24 +08:00
|
|
|
|
oldlen = strlen (gv->value);
|
1999-08-19 12:43:46 +08:00
|
|
|
|
newlen = strlen (f->name);
|
2007-03-20 11:02:26 +08:00
|
|
|
|
vp = alloca (oldlen + 1 + newlen + 1);
|
|
|
|
|
memcpy (vp, gv->value, oldlen);
|
|
|
|
|
vp[oldlen] = ' ';
|
|
|
|
|
memcpy (&vp[oldlen + 1], f->name, newlen + 1);
|
|
|
|
|
value = vp;
|
1997-04-07 15:21:16 +08:00
|
|
|
|
}
|
2009-10-25 08:46:52 +08:00
|
|
|
|
define_variable_cname ("MAKECMDGOALS", value, o_default, 0);
|
1997-04-07 15:21:16 +08:00
|
|
|
|
}
|
1995-03-24 13:56:41 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-25 12:30:55 +08:00
|
|
|
|
/* Print a nice usage method. */
|
|
|
|
|
|
|
|
|
|
static void
|
2002-10-15 05:54:04 +08:00
|
|
|
|
print_usage (int bad)
|
1999-04-25 12:30:55 +08:00
|
|
|
|
{
|
2002-08-08 13:39:17 +08:00
|
|
|
|
const char *const *cpp;
|
1999-04-25 12:30:55 +08:00
|
|
|
|
FILE *usageto;
|
|
|
|
|
|
|
|
|
|
if (print_version_flag)
|
|
|
|
|
print_version ();
|
|
|
|
|
|
|
|
|
|
usageto = bad ? stderr : stdout;
|
|
|
|
|
|
1999-08-01 14:05:17 +08:00
|
|
|
|
fprintf (usageto, _("Usage: %s [options] [target] ...\n"), program);
|
1999-04-25 12:30:55 +08:00
|
|
|
|
|
2002-08-08 13:39:17 +08:00
|
|
|
|
for (cpp = usage; *cpp; ++cpp)
|
|
|
|
|
fputs (_(*cpp), usageto);
|
1999-10-15 15:00:58 +08:00
|
|
|
|
|
2002-07-08 21:05:02 +08:00
|
|
|
|
if (!remote_description || *remote_description == '\0')
|
2002-08-08 13:39:17 +08:00
|
|
|
|
fprintf (usageto, _("\nThis program built for %s\n"), make_host);
|
2002-07-08 21:05:02 +08:00
|
|
|
|
else
|
2002-08-08 13:39:17 +08:00
|
|
|
|
fprintf (usageto, _("\nThis program built for %s (%s)\n"),
|
|
|
|
|
make_host, remote_description);
|
2002-07-08 21:05:02 +08:00
|
|
|
|
|
2002-08-08 13:39:17 +08:00
|
|
|
|
fprintf (usageto, _("Report bugs to <bug-make@gnu.org>\n"));
|
1999-04-25 12:30:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
1993-01-07 08:34:28 +08:00
|
|
|
|
/* Decode switches from ARGC and ARGV.
|
|
|
|
|
They came from the environment if ENV is nonzero. */
|
|
|
|
|
|
|
|
|
|
static void
|
2014-04-26 05:10:47 +08:00
|
|
|
|
decode_switches (int argc, const char **argv, int env)
|
1993-01-07 08:34:28 +08:00
|
|
|
|
{
|
|
|
|
|
int bad = 0;
|
1993-04-15 02:20:33 +08:00
|
|
|
|
register const struct command_switch *cs;
|
1993-01-07 08:34:28 +08:00
|
|
|
|
register struct stringlist *sl;
|
|
|
|
|
register int c;
|
|
|
|
|
|
|
|
|
|
/* getopt does most of the parsing for us.
|
|
|
|
|
First, get its vectors set up. */
|
|
|
|
|
|
|
|
|
|
init_switches ();
|
|
|
|
|
|
|
|
|
|
/* Let getopt produce error messages for the command line,
|
|
|
|
|
but not for options from the environment. */
|
|
|
|
|
opterr = !env;
|
|
|
|
|
/* Reset getopt's state. */
|
1995-03-24 13:56:41 +08:00
|
|
|
|
optind = 0;
|
1992-05-09 12:28:28 +08:00
|
|
|
|
|
1994-09-10 15:01:10 +08:00
|
|
|
|
while (optind < argc)
|
1992-01-30 07:54:36 +08:00
|
|
|
|
{
|
2014-04-26 05:10:47 +08:00
|
|
|
|
const char *coptarg;
|
|
|
|
|
|
1995-03-08 06:31:01 +08:00
|
|
|
|
/* Parse the next argument. */
|
2014-04-26 05:10:47 +08:00
|
|
|
|
c = getopt_long (argc, (char*const*)argv, options, long_options, NULL);
|
|
|
|
|
coptarg = optarg;
|
1994-09-10 15:01:10 +08:00
|
|
|
|
if (c == EOF)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
/* End of arguments, or "--" marker seen. */
|
|
|
|
|
break;
|
1995-03-24 13:56:41 +08:00
|
|
|
|
else if (c == 1)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
/* An argument not starting with a dash. */
|
2014-04-26 05:10:47 +08:00
|
|
|
|
handle_non_switch_argument (coptarg, env);
|
1994-09-09 13:37:40 +08:00
|
|
|
|
else if (c == '?')
|
2013-01-20 13:55:57 +08:00
|
|
|
|
/* Bad option. We will print a usage message and die later.
|
|
|
|
|
But continue to parse the other options so the user can
|
|
|
|
|
see all he did wrong. */
|
|
|
|
|
bad = 1;
|
1992-05-09 12:28:28 +08:00
|
|
|
|
else
|
2013-01-20 13:55:57 +08:00
|
|
|
|
for (cs = switches; cs->c != '\0'; ++cs)
|
|
|
|
|
if (cs->c == c)
|
|
|
|
|
{
|
|
|
|
|
/* Whether or not we will actually do anything with
|
|
|
|
|
this switch. We test this individually inside the
|
|
|
|
|
switch below rather than just once outside it, so that
|
|
|
|
|
options which are to be ignored still consume args. */
|
|
|
|
|
int doit = !env || cs->env;
|
|
|
|
|
|
|
|
|
|
switch (cs->type)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
abort ();
|
|
|
|
|
|
|
|
|
|
case ignore:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case flag:
|
|
|
|
|
case flag_off:
|
|
|
|
|
if (doit)
|
|
|
|
|
*(int *) cs->value_ptr = cs->type == flag;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case string:
|
2013-11-24 16:21:40 +08:00
|
|
|
|
case strlist:
|
2013-01-20 13:55:57 +08:00
|
|
|
|
case filename:
|
|
|
|
|
if (!doit)
|
|
|
|
|
break;
|
|
|
|
|
|
2014-04-26 05:10:47 +08:00
|
|
|
|
if (! coptarg)
|
|
|
|
|
coptarg = xstrdup (cs->noarg_value);
|
|
|
|
|
else if (*coptarg == '\0')
|
2004-02-23 14:25:54 +08:00
|
|
|
|
{
|
2009-10-25 08:46:52 +08:00
|
|
|
|
char opt[2] = "c";
|
|
|
|
|
const char *op = opt;
|
|
|
|
|
|
|
|
|
|
if (short_option (cs->c))
|
|
|
|
|
opt[0] = cs->c;
|
|
|
|
|
else
|
|
|
|
|
op = cs->long_name;
|
|
|
|
|
|
2013-11-24 11:23:52 +08:00
|
|
|
|
error (NILF, strlen (op),
|
|
|
|
|
_("the '%s%s' option requires a non-empty string argument"),
|
2009-10-25 08:46:52 +08:00
|
|
|
|
short_option (cs->c) ? "-" : "--", op);
|
2004-02-23 14:25:54 +08:00
|
|
|
|
bad = 1;
|
2013-11-24 16:21:40 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cs->type == string)
|
|
|
|
|
{
|
|
|
|
|
char **val = (char **)cs->value_ptr;
|
2014-04-26 05:38:08 +08:00
|
|
|
|
free (*val);
|
2014-04-26 05:10:47 +08:00
|
|
|
|
*val = xstrdup (coptarg);
|
2013-11-24 16:21:40 +08:00
|
|
|
|
break;
|
2004-02-23 14:25:54 +08:00
|
|
|
|
}
|
1992-05-09 12:28:28 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
sl = *(struct stringlist **) cs->value_ptr;
|
|
|
|
|
if (sl == 0)
|
|
|
|
|
{
|
|
|
|
|
sl = xmalloc (sizeof (struct stringlist));
|
|
|
|
|
sl->max = 5;
|
|
|
|
|
sl->idx = 0;
|
|
|
|
|
sl->list = xmalloc (5 * sizeof (char *));
|
|
|
|
|
*(struct stringlist **) cs->value_ptr = sl;
|
|
|
|
|
}
|
|
|
|
|
else if (sl->idx == sl->max - 1)
|
|
|
|
|
{
|
|
|
|
|
sl->max += 5;
|
2010-07-19 15:10:53 +08:00
|
|
|
|
/* MSVC erroneously warns without a cast here. */
|
2013-01-20 13:55:57 +08:00
|
|
|
|
sl->list = xrealloc ((void *)sl->list,
|
2006-04-10 06:09:24 +08:00
|
|
|
|
sl->max * sizeof (char *));
|
2013-01-20 13:55:57 +08:00
|
|
|
|
}
|
2007-03-20 11:02:26 +08:00
|
|
|
|
if (cs->type == filename)
|
2014-04-26 05:10:47 +08:00
|
|
|
|
sl->list[sl->idx++] = expand_command_line_file (coptarg);
|
2007-03-20 11:02:26 +08:00
|
|
|
|
else
|
2014-04-26 05:10:47 +08:00
|
|
|
|
sl->list[sl->idx++] = xstrdup (coptarg);
|
2013-01-20 13:55:57 +08:00
|
|
|
|
sl->list[sl->idx] = 0;
|
|
|
|
|
break;
|
1992-05-09 12:28:28 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
case positive_int:
|
2000-06-07 13:43:37 +08:00
|
|
|
|
/* See if we have an option argument; if we do require that
|
|
|
|
|
it's all digits, not something like "10foo". */
|
2014-04-26 05:10:47 +08:00
|
|
|
|
if (coptarg == 0 && argc > optind)
|
2000-06-07 13:43:37 +08:00
|
|
|
|
{
|
|
|
|
|
const char *cp;
|
|
|
|
|
for (cp=argv[optind]; ISDIGIT (cp[0]); ++cp)
|
|
|
|
|
;
|
|
|
|
|
if (cp[0] == '\0')
|
2014-04-26 05:10:47 +08:00
|
|
|
|
coptarg = argv[optind++];
|
2000-06-07 13:43:37 +08:00
|
|
|
|
}
|
1993-01-07 08:34:28 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (!doit)
|
|
|
|
|
break;
|
1993-01-07 08:34:28 +08:00
|
|
|
|
|
2014-04-26 05:10:47 +08:00
|
|
|
|
if (coptarg)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
2014-04-26 05:10:47 +08:00
|
|
|
|
int i = atoi (coptarg);
|
2000-06-07 13:43:37 +08:00
|
|
|
|
const char *cp;
|
|
|
|
|
|
|
|
|
|
/* Yes, I realize we're repeating this in some cases. */
|
2014-04-26 05:10:47 +08:00
|
|
|
|
for (cp = coptarg; ISDIGIT (cp[0]); ++cp)
|
2000-06-07 13:43:37 +08:00
|
|
|
|
;
|
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (i < 1 || cp[0] != '\0')
|
|
|
|
|
{
|
2013-11-24 11:23:52 +08:00
|
|
|
|
error (NILF, 0,
|
|
|
|
|
_("the '-%c' option requires a positive integer argument"),
|
2000-06-07 13:43:37 +08:00
|
|
|
|
cs->c);
|
2013-01-20 13:55:57 +08:00
|
|
|
|
bad = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
*(unsigned int *) cs->value_ptr = i;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
*(unsigned int *) cs->value_ptr
|
|
|
|
|
= *(unsigned int *) cs->noarg_value;
|
|
|
|
|
break;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
Thu May 9 13:54:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* GNUmakefile (globfiles): Add AmigaDOS support files.
(distfiles): Add $(amigafiles).
(amigafiles): New variable.
Thu Nov 7 10:18:16 1995 Aaron Digulla <digulla@fh-konstanz.de>
* Added Amiga support in commands.c, dir.c, function.c,
job.c, main.c, make.h, read.c, remake.c
* commands.c: Amiga has neither SIGHUP nor SIGQUIT
* dir.c: Amiga has filenames with Upper- and Lowercase,
but "FileName" is the same as "filename". Added strieq()
which is use to compare filenames. This is like streq()
on all other systems. Also there is no such thing as
"." under AmigaDOS.
* function.c: On Amiga, the environment is not passed as envp,
there are no pipes and Amiga can't fork. Use my own function
to create a new child.
* job.c: default_shell is "" (The system automatically chooses
a shell for me). Have to use the same workaround as MSDOS for
running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't
known on Amiga. Cloned code to run children from MSDOS. Own
version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga.
* main.c: Force stack to 20000 bytes. Read environment from ENV:
device. On Amiga, exec_command() does return, so I exit()
afterwards.
* make.h: Added strieq() to compare filenames.
* read.c: Amiga needs special extension to have passwd. Only
one include-dir. "Makefile" and "makefile" are the same.
Added "SMakefile". Added special code to handle device names (xxx:)
and "./" in rules.
* remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib"
instead of "lib%s.a".
* main.c, rule.c, variable.c: Avoid floats at all costs.
* vpath.c: Get rid of as many alloca()s as possible.
1996-05-10 02:02:06 +08:00
|
|
|
|
#ifndef NO_FLOAT
|
2013-01-20 13:55:57 +08:00
|
|
|
|
case floating:
|
2014-04-26 05:10:47 +08:00
|
|
|
|
if (coptarg == 0 && optind < argc
|
2013-01-20 13:55:57 +08:00
|
|
|
|
&& (ISDIGIT (argv[optind][0]) || argv[optind][0] == '.'))
|
2014-04-26 05:10:47 +08:00
|
|
|
|
coptarg = argv[optind++];
|
1993-01-07 08:34:28 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (doit)
|
|
|
|
|
*(double *) cs->value_ptr
|
2014-04-26 05:10:47 +08:00
|
|
|
|
= (coptarg != 0 ? atof (coptarg)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
: *(double *) cs->noarg_value);
|
1993-01-07 08:34:28 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
break;
|
Thu May 9 13:54:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* GNUmakefile (globfiles): Add AmigaDOS support files.
(distfiles): Add $(amigafiles).
(amigafiles): New variable.
Thu Nov 7 10:18:16 1995 Aaron Digulla <digulla@fh-konstanz.de>
* Added Amiga support in commands.c, dir.c, function.c,
job.c, main.c, make.h, read.c, remake.c
* commands.c: Amiga has neither SIGHUP nor SIGQUIT
* dir.c: Amiga has filenames with Upper- and Lowercase,
but "FileName" is the same as "filename". Added strieq()
which is use to compare filenames. This is like streq()
on all other systems. Also there is no such thing as
"." under AmigaDOS.
* function.c: On Amiga, the environment is not passed as envp,
there are no pipes and Amiga can't fork. Use my own function
to create a new child.
* job.c: default_shell is "" (The system automatically chooses
a shell for me). Have to use the same workaround as MSDOS for
running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't
known on Amiga. Cloned code to run children from MSDOS. Own
version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga.
* main.c: Force stack to 20000 bytes. Read environment from ENV:
device. On Amiga, exec_command() does return, so I exit()
afterwards.
* make.h: Added strieq() to compare filenames.
* read.c: Amiga needs special extension to have passwd. Only
one include-dir. "Makefile" and "makefile" are the same.
Added "SMakefile". Added special code to handle device names (xxx:)
and "./" in rules.
* remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib"
instead of "lib%s.a".
* main.c, rule.c, variable.c: Avoid floats at all costs.
* vpath.c: Get rid of as many alloca()s as possible.
1996-05-10 02:02:06 +08:00
|
|
|
|
#endif
|
2013-01-20 13:55:57 +08:00
|
|
|
|
}
|
1995-11-26 09:37:07 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
/* We've found the switch. Stop looking. */
|
|
|
|
|
break;
|
|
|
|
|
}
|
1992-01-30 07:54:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
1995-03-24 13:56:41 +08:00
|
|
|
|
/* There are no more options according to getting getopt, but there may
|
|
|
|
|
be some arguments left. Since we have asked for non-option arguments
|
|
|
|
|
to be returned in order, this only happens when there is a "--"
|
|
|
|
|
argument to prevent later arguments from being options. */
|
|
|
|
|
while (optind < argc)
|
|
|
|
|
handle_non_switch_argument (argv[optind++], env);
|
|
|
|
|
|
1993-05-23 04:20:16 +08:00
|
|
|
|
if (!env && (bad || print_usage_flag))
|
1992-05-09 12:28:28 +08:00
|
|
|
|
{
|
1999-08-19 12:43:46 +08:00
|
|
|
|
print_usage (bad);
|
2014-08-25 04:06:15 +08:00
|
|
|
|
die (bad ? MAKE_FAILURE : MAKE_SUCCESS);
|
1992-05-09 12:28:28 +08:00
|
|
|
|
}
|
2013-04-16 01:22:51 +08:00
|
|
|
|
|
|
|
|
|
/* If there are any options that need to be decoded do it now. */
|
|
|
|
|
decode_debug_flags ();
|
|
|
|
|
decode_output_sync_flags ();
|
1992-01-30 07:54:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
1993-01-07 08:34:28 +08:00
|
|
|
|
/* Decode switches from environment variable ENVAR (which is LEN chars long).
|
|
|
|
|
We do this by chopping the value into a vector of words, prepending a
|
|
|
|
|
dash to the first word if it lacks one, and passing the vector to
|
|
|
|
|
decode_switches. */
|
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
static void
|
2014-04-26 05:10:47 +08:00
|
|
|
|
decode_env_switches (const char *envar, unsigned int len)
|
1992-01-30 07:54:36 +08:00
|
|
|
|
{
|
2006-04-10 06:09:24 +08:00
|
|
|
|
char *varref = alloca (2 + len + 2);
|
2013-11-24 16:45:02 +08:00
|
|
|
|
char *value, *p, *buf;
|
1993-01-07 08:34:28 +08:00
|
|
|
|
int argc;
|
2014-04-26 05:10:47 +08:00
|
|
|
|
const char **argv;
|
1993-01-07 08:34:28 +08:00
|
|
|
|
|
|
|
|
|
/* Get the variable's value. */
|
|
|
|
|
varref[0] = '$';
|
|
|
|
|
varref[1] = '(';
|
2006-04-10 06:09:24 +08:00
|
|
|
|
memcpy (&varref[2], envar, len);
|
1993-01-07 08:34:28 +08:00
|
|
|
|
varref[2 + len] = ')';
|
|
|
|
|
varref[2 + len + 1] = '\0';
|
1994-09-10 15:01:10 +08:00
|
|
|
|
value = variable_expand (varref);
|
1993-01-07 08:34:28 +08:00
|
|
|
|
|
|
|
|
|
/* Skip whitespace, and check for an empty value. */
|
|
|
|
|
value = next_token (value);
|
|
|
|
|
len = strlen (value);
|
|
|
|
|
if (len == 0)
|
1992-01-30 07:54:36 +08:00
|
|
|
|
return;
|
|
|
|
|
|
1993-01-07 08:34:28 +08:00
|
|
|
|
/* Allocate a vector that is definitely big enough. */
|
2006-04-10 06:09:24 +08:00
|
|
|
|
argv = alloca ((1 + len + 1) * sizeof (char *));
|
1993-01-13 03:42:13 +08:00
|
|
|
|
|
|
|
|
|
/* getopt will look at the arguments starting at ARGV[1].
|
|
|
|
|
Prepend a spacer word. */
|
|
|
|
|
argv[0] = 0;
|
|
|
|
|
argc = 1;
|
2013-11-24 16:45:02 +08:00
|
|
|
|
|
2013-11-28 08:06:45 +08:00
|
|
|
|
/* We need a buffer to copy the value into while we split it into words
|
|
|
|
|
and unquote it. Set up in case we need to prepend a dash later. */
|
|
|
|
|
buf = alloca (1 + len + 1);
|
2013-11-24 16:45:02 +08:00
|
|
|
|
buf[0] = '-';
|
|
|
|
|
p = buf+1;
|
1994-09-10 15:01:10 +08:00
|
|
|
|
argv[argc] = p;
|
|
|
|
|
while (*value != '\0')
|
|
|
|
|
{
|
1999-10-15 15:00:58 +08:00
|
|
|
|
if (*value == '\\' && value[1] != '\0')
|
2013-01-20 13:55:57 +08:00
|
|
|
|
++value; /* Skip the backslash. */
|
2000-06-07 13:43:37 +08:00
|
|
|
|
else if (isblank ((unsigned char)*value))
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
/* End of the word. */
|
|
|
|
|
*p++ = '\0';
|
|
|
|
|
argv[++argc] = p;
|
|
|
|
|
do
|
|
|
|
|
++value;
|
|
|
|
|
while (isblank ((unsigned char)*value));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
1994-09-10 15:01:10 +08:00
|
|
|
|
*p++ = *value++;
|
|
|
|
|
}
|
|
|
|
|
*p = '\0';
|
|
|
|
|
argv[++argc] = 0;
|
2013-11-28 08:06:45 +08:00
|
|
|
|
assert (p < buf + len + 2);
|
1994-09-09 13:37:40 +08:00
|
|
|
|
|
1999-10-15 15:00:58 +08:00
|
|
|
|
if (argv[1][0] != '-' && strchr (argv[1], '=') == 0)
|
1996-06-23 03:31:12 +08:00
|
|
|
|
/* The first word doesn't start with a dash and isn't a variable
|
2013-11-24 16:45:02 +08:00
|
|
|
|
definition, so add a dash. */
|
|
|
|
|
argv[1] = buf;
|
1993-01-07 08:34:28 +08:00
|
|
|
|
|
|
|
|
|
/* Parse those words. */
|
|
|
|
|
decode_switches (argc, argv, 1);
|
1992-01-30 07:54:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
1994-09-10 15:01:10 +08:00
|
|
|
|
/* Quote the string IN so that it will be interpreted as a single word with
|
1999-10-15 15:00:58 +08:00
|
|
|
|
no magic by decode_env_switches; also double dollar signs to avoid
|
|
|
|
|
variable expansion in make itself. Write the result into OUT, returning
|
|
|
|
|
the address of the next character to be written.
|
|
|
|
|
Allocating space for OUT twice the length of IN is always sufficient. */
|
1994-09-27 06:37:10 +08:00
|
|
|
|
|
|
|
|
|
static char *
|
2007-03-20 11:02:26 +08:00
|
|
|
|
quote_for_env (char *out, const char *in)
|
1994-09-10 15:01:10 +08:00
|
|
|
|
{
|
|
|
|
|
while (*in != '\0')
|
|
|
|
|
{
|
1999-10-15 15:00:58 +08:00
|
|
|
|
if (*in == '$')
|
2013-01-20 13:55:57 +08:00
|
|
|
|
*out++ = '$';
|
2000-06-07 13:43:37 +08:00
|
|
|
|
else if (isblank ((unsigned char)*in) || *in == '\\')
|
1999-10-15 15:00:58 +08:00
|
|
|
|
*out++ = '\\';
|
1994-09-10 15:01:10 +08:00
|
|
|
|
*out++ = *in++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* Define the MAKEFLAGS and MFLAGS variables to reflect the settings of the
|
1993-01-09 05:48:11 +08:00
|
|
|
|
command switches. Include options with args if ALL is nonzero.
|
2012-03-04 08:24:20 +08:00
|
|
|
|
Don't include options with the 'no_makefile' flag set if MAKEFILE. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2013-09-16 12:12:09 +08:00
|
|
|
|
static struct variable *
|
2002-10-15 05:54:04 +08:00
|
|
|
|
define_makeflags (int all, int makefile)
|
1992-01-30 07:54:36 +08:00
|
|
|
|
{
|
2009-10-25 08:46:52 +08:00
|
|
|
|
const char ref[] = "$(MAKEOVERRIDES)";
|
|
|
|
|
const char posixref[] = "$(-*-command-variables-*-)";
|
|
|
|
|
const char evalref[] = "$(-*-eval-flags-*-)";
|
|
|
|
|
const struct command_switch *cs;
|
1993-01-09 05:48:11 +08:00
|
|
|
|
char *flagstring;
|
2013-09-16 12:12:09 +08:00
|
|
|
|
char *p;
|
1993-01-09 05:48:11 +08:00
|
|
|
|
|
2012-03-04 08:24:20 +08:00
|
|
|
|
/* We will construct a linked list of 'struct flag's describing
|
1993-01-09 05:48:11 +08:00
|
|
|
|
all the flags which need to go in MAKEFLAGS. Then, once we
|
|
|
|
|
know how many there are and their lengths, we can put them all
|
|
|
|
|
together in a string. */
|
|
|
|
|
|
|
|
|
|
struct flag
|
|
|
|
|
{
|
|
|
|
|
struct flag *next;
|
1993-04-15 02:20:33 +08:00
|
|
|
|
const struct command_switch *cs;
|
2007-03-20 11:02:26 +08:00
|
|
|
|
const char *arg;
|
1993-01-09 05:48:11 +08:00
|
|
|
|
};
|
|
|
|
|
struct flag *flags = 0;
|
2013-05-22 14:14:19 +08:00
|
|
|
|
struct flag *last = 0;
|
1993-01-09 05:48:11 +08:00
|
|
|
|
unsigned int flagslen = 0;
|
2013-01-20 13:55:57 +08:00
|
|
|
|
#define ADD_FLAG(ARG, LEN) \
|
|
|
|
|
do { \
|
|
|
|
|
struct flag *new = alloca (sizeof (struct flag)); \
|
|
|
|
|
new->cs = cs; \
|
|
|
|
|
new->arg = (ARG); \
|
2013-05-22 14:14:19 +08:00
|
|
|
|
new->next = 0; \
|
|
|
|
|
if (! flags) \
|
|
|
|
|
flags = new; \
|
|
|
|
|
else \
|
|
|
|
|
last->next = new; \
|
|
|
|
|
last = new; \
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (new->arg == 0) \
|
2013-05-22 14:14:19 +08:00
|
|
|
|
/* Just a single flag letter: " -x" */ \
|
|
|
|
|
flagslen += 3; \
|
2013-01-20 13:55:57 +08:00
|
|
|
|
else \
|
2013-05-22 14:14:19 +08:00
|
|
|
|
/* " -xfoo", plus space to escape "foo". */ \
|
2013-04-16 01:22:51 +08:00
|
|
|
|
flagslen += 1 + 1 + 1 + (3 * (LEN)); \
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (!short_option (cs->c)) \
|
1993-04-08 04:40:35 +08:00
|
|
|
|
/* This switch has no single-letter version, so we use the long. */ \
|
2013-01-20 13:55:57 +08:00
|
|
|
|
flagslen += 2 + strlen (cs->long_name); \
|
1993-01-09 05:48:11 +08:00
|
|
|
|
} while (0)
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
|
|
|
|
for (cs = switches; cs->c != '\0'; ++cs)
|
|
|
|
|
if (cs->toenv && (!makefile || !cs->no_makefile))
|
1993-01-09 05:48:11 +08:00
|
|
|
|
switch (cs->type)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
case ignore:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case flag:
|
|
|
|
|
case flag_off:
|
|
|
|
|
if (!*(int *) cs->value_ptr == (cs->type == flag_off)
|
|
|
|
|
&& (cs->default_value == 0
|
|
|
|
|
|| *(int *) cs->value_ptr != *(int *) cs->default_value))
|
|
|
|
|
ADD_FLAG (0, 0);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case positive_int:
|
|
|
|
|
if (all)
|
|
|
|
|
{
|
|
|
|
|
if ((cs->default_value != 0
|
|
|
|
|
&& (*(unsigned int *) cs->value_ptr
|
|
|
|
|
== *(unsigned int *) cs->default_value)))
|
|
|
|
|
break;
|
|
|
|
|
else if (cs->noarg_value != 0
|
|
|
|
|
&& (*(unsigned int *) cs->value_ptr ==
|
|
|
|
|
*(unsigned int *) cs->noarg_value))
|
|
|
|
|
ADD_FLAG ("", 0); /* Optional value omitted; see below. */
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
char *buf = alloca (30);
|
|
|
|
|
sprintf (buf, "%u", *(unsigned int *) cs->value_ptr);
|
|
|
|
|
ADD_FLAG (buf, strlen (buf));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
Thu May 9 13:54:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* GNUmakefile (globfiles): Add AmigaDOS support files.
(distfiles): Add $(amigafiles).
(amigafiles): New variable.
Thu Nov 7 10:18:16 1995 Aaron Digulla <digulla@fh-konstanz.de>
* Added Amiga support in commands.c, dir.c, function.c,
job.c, main.c, make.h, read.c, remake.c
* commands.c: Amiga has neither SIGHUP nor SIGQUIT
* dir.c: Amiga has filenames with Upper- and Lowercase,
but "FileName" is the same as "filename". Added strieq()
which is use to compare filenames. This is like streq()
on all other systems. Also there is no such thing as
"." under AmigaDOS.
* function.c: On Amiga, the environment is not passed as envp,
there are no pipes and Amiga can't fork. Use my own function
to create a new child.
* job.c: default_shell is "" (The system automatically chooses
a shell for me). Have to use the same workaround as MSDOS for
running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't
known on Amiga. Cloned code to run children from MSDOS. Own
version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga.
* main.c: Force stack to 20000 bytes. Read environment from ENV:
device. On Amiga, exec_command() does return, so I exit()
afterwards.
* make.h: Added strieq() to compare filenames.
* read.c: Amiga needs special extension to have passwd. Only
one include-dir. "Makefile" and "makefile" are the same.
Added "SMakefile". Added special code to handle device names (xxx:)
and "./" in rules.
* remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib"
instead of "lib%s.a".
* main.c, rule.c, variable.c: Avoid floats at all costs.
* vpath.c: Get rid of as many alloca()s as possible.
1996-05-10 02:02:06 +08:00
|
|
|
|
#ifndef NO_FLOAT
|
2013-01-20 13:55:57 +08:00
|
|
|
|
case floating:
|
|
|
|
|
if (all)
|
|
|
|
|
{
|
|
|
|
|
if (cs->default_value != 0
|
|
|
|
|
&& (*(double *) cs->value_ptr
|
|
|
|
|
== *(double *) cs->default_value))
|
|
|
|
|
break;
|
|
|
|
|
else if (cs->noarg_value != 0
|
|
|
|
|
&& (*(double *) cs->value_ptr
|
|
|
|
|
== *(double *) cs->noarg_value))
|
|
|
|
|
ADD_FLAG ("", 0); /* Optional value omitted; see below. */
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
char *buf = alloca (100);
|
|
|
|
|
sprintf (buf, "%g", *(double *) cs->value_ptr);
|
|
|
|
|
ADD_FLAG (buf, strlen (buf));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
case string:
|
2013-11-24 16:21:40 +08:00
|
|
|
|
if (all)
|
|
|
|
|
{
|
|
|
|
|
p = *((char **)cs->value_ptr);
|
|
|
|
|
if (p)
|
|
|
|
|
ADD_FLAG (p, strlen (p));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case filename:
|
|
|
|
|
case strlist:
|
2013-01-20 13:55:57 +08:00
|
|
|
|
if (all)
|
|
|
|
|
{
|
|
|
|
|
struct stringlist *sl = *(struct stringlist **) cs->value_ptr;
|
|
|
|
|
if (sl != 0)
|
|
|
|
|
{
|
2013-05-22 14:14:19 +08:00
|
|
|
|
unsigned int i;
|
|
|
|
|
for (i = 0; i < sl->idx; ++i)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
ADD_FLAG (sl->list[i], strlen (sl->list[i]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
abort ();
|
|
|
|
|
}
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
#undef ADD_FLAG
|
1994-09-09 14:45:51 +08:00
|
|
|
|
|
2013-05-22 14:14:19 +08:00
|
|
|
|
/* Four more for the possible " -- ", plus variable references. */
|
|
|
|
|
flagslen += 4 + CSTRLEN (posixref) + 1 + CSTRLEN (evalref) + 1;
|
|
|
|
|
|
1994-09-09 14:45:51 +08:00
|
|
|
|
/* Construct the value in FLAGSTRING.
|
|
|
|
|
We allocate enough space for a preceding dash and trailing null. */
|
2006-04-10 06:09:24 +08:00
|
|
|
|
flagstring = alloca (1 + flagslen + 1);
|
|
|
|
|
memset (flagstring, '\0', 1 + flagslen + 1);
|
1994-09-09 14:45:51 +08:00
|
|
|
|
p = flagstring;
|
2013-05-22 14:14:19 +08:00
|
|
|
|
|
|
|
|
|
/* Start with a dash, for MFLAGS. */
|
1994-09-09 14:45:51 +08:00
|
|
|
|
*p++ = '-';
|
2013-05-22 14:14:19 +08:00
|
|
|
|
|
|
|
|
|
/* Add simple options as a group. */
|
|
|
|
|
while (flags != 0 && !flags->arg && short_option (flags->cs->c))
|
1994-09-09 14:45:51 +08:00
|
|
|
|
{
|
2013-05-22 14:14:19 +08:00
|
|
|
|
*p++ = flags->cs->c;
|
|
|
|
|
flags = flags->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now add more complex flags: ones with options and/or long names. */
|
|
|
|
|
while (flags)
|
|
|
|
|
{
|
|
|
|
|
*p++ = ' ';
|
|
|
|
|
*p++ = '-';
|
|
|
|
|
|
1994-09-09 14:45:51 +08:00
|
|
|
|
/* Add the flag letter or name to the string. */
|
1999-09-01 16:04:30 +08:00
|
|
|
|
if (short_option (flags->cs->c))
|
2013-01-20 13:55:57 +08:00
|
|
|
|
*p++ = flags->cs->c;
|
1999-09-01 16:04:30 +08:00
|
|
|
|
else
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
2013-05-22 14:14:19 +08:00
|
|
|
|
/* Long options require a double-dash. */
|
2013-01-20 13:55:57 +08:00
|
|
|
|
*p++ = '-';
|
|
|
|
|
strcpy (p, flags->cs->long_name);
|
|
|
|
|
p += strlen (p);
|
|
|
|
|
}
|
2013-05-22 14:14:19 +08:00
|
|
|
|
/* An omitted optional argument has an ARG of "". */
|
|
|
|
|
if (flags->arg && flags->arg[0] != '\0')
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
2013-05-22 14:14:19 +08:00
|
|
|
|
if (!short_option (flags->cs->c))
|
|
|
|
|
/* Long options require '='. */
|
|
|
|
|
*p++ = '=';
|
|
|
|
|
p = quote_for_env (p, flags->arg);
|
2013-01-20 13:55:57 +08:00
|
|
|
|
}
|
1994-09-09 14:45:51 +08:00
|
|
|
|
flags = flags->next;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-22 14:14:19 +08:00
|
|
|
|
/* If no flags at all, get rid of the initial dash. */
|
1995-08-11 07:58:12 +08:00
|
|
|
|
if (p == &flagstring[1])
|
1996-07-26 08:33:25 +08:00
|
|
|
|
{
|
2013-05-22 14:14:19 +08:00
|
|
|
|
flagstring[0] = '\0';
|
|
|
|
|
p = flagstring;
|
1996-07-26 08:33:25 +08:00
|
|
|
|
}
|
1995-08-11 07:58:12 +08:00
|
|
|
|
|
2013-05-22 14:14:19 +08:00
|
|
|
|
/* Define MFLAGS before appending variable definitions. Omit an initial
|
|
|
|
|
empty dash. Since MFLAGS is not parsed for flags, there is no reason to
|
1995-08-11 07:58:12 +08:00
|
|
|
|
override any makefile redefinition. */
|
2013-05-22 14:14:19 +08:00
|
|
|
|
define_variable_cname ("MFLAGS",
|
|
|
|
|
flagstring + (flagstring[0] == '-' && flagstring[1] == ' ' ? 2 : 0),
|
|
|
|
|
o_env, 1);
|
2009-10-25 08:46:52 +08:00
|
|
|
|
|
|
|
|
|
/* Write a reference to -*-eval-flags-*-, which contains all the --eval
|
|
|
|
|
flag options. */
|
|
|
|
|
if (eval_strings)
|
|
|
|
|
{
|
2013-05-22 14:14:19 +08:00
|
|
|
|
*p++ = ' ';
|
2012-03-04 16:58:44 +08:00
|
|
|
|
memcpy (p, evalref, CSTRLEN (evalref));
|
|
|
|
|
p += CSTRLEN (evalref);
|
2009-10-25 08:46:52 +08:00
|
|
|
|
}
|
1995-08-11 07:58:12 +08:00
|
|
|
|
|
2013-09-16 12:12:09 +08:00
|
|
|
|
if (all && command_variables)
|
1994-09-09 14:45:51 +08:00
|
|
|
|
{
|
2013-05-22 14:14:19 +08:00
|
|
|
|
/* Write a reference to $(MAKEOVERRIDES), which contains all the
|
|
|
|
|
command-line variable definitions. Separate the variables from the
|
|
|
|
|
switches with a "--" arg. */
|
1994-09-27 06:37:10 +08:00
|
|
|
|
|
2013-05-22 14:14:19 +08:00
|
|
|
|
strcpy (p, " -- ");
|
|
|
|
|
p += 4;
|
1994-09-27 06:37:10 +08:00
|
|
|
|
|
|
|
|
|
/* Copy in the string. */
|
1994-10-01 16:07:35 +08:00
|
|
|
|
if (posix_pedantic)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
memcpy (p, posixref, CSTRLEN (posixref));
|
|
|
|
|
p += CSTRLEN (posixref);
|
|
|
|
|
}
|
1994-10-01 16:07:35 +08:00
|
|
|
|
else
|
2013-01-20 13:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
memcpy (p, ref, CSTRLEN (ref));
|
|
|
|
|
p += CSTRLEN (ref);
|
|
|
|
|
}
|
1993-01-09 05:48:11 +08:00
|
|
|
|
}
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2013-05-22 14:14:19 +08:00
|
|
|
|
/* If there is a leading dash, omit it. */
|
|
|
|
|
if (flagstring[0] == '-')
|
2009-06-09 23:35:38 +08:00
|
|
|
|
++flagstring;
|
|
|
|
|
|
2013-05-13 14:17:29 +08:00
|
|
|
|
/* This used to use o_env, but that lost when a makefile defined MAKEFLAGS.
|
|
|
|
|
Makefiles set MAKEFLAGS to add switches, but we still want to redefine
|
|
|
|
|
its value with the full set of switches. Then we used o_file, but that
|
|
|
|
|
lost when users added -e, causing a previous MAKEFLAGS env. var. to take
|
|
|
|
|
precedence over the new one. Of course, an override or command
|
|
|
|
|
definition will still take precedence. */
|
2013-09-16 12:12:09 +08:00
|
|
|
|
return define_variable_cname ("MAKEFLAGS", flagstring,
|
|
|
|
|
env_overrides ? o_env_override : o_file, 1);
|
1992-01-30 07:54:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Print version information. */
|
|
|
|
|
|
|
|
|
|
static void
|
2002-10-15 05:54:04 +08:00
|
|
|
|
print_version (void)
|
1992-01-30 07:54:36 +08:00
|
|
|
|
{
|
1992-09-30 09:26:59 +08:00
|
|
|
|
static int printed_version = 0;
|
|
|
|
|
|
2014-04-26 05:10:47 +08:00
|
|
|
|
const char *precede = print_data_base_flag ? "# " : "";
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1992-09-30 09:26:59 +08:00
|
|
|
|
if (printed_version)
|
|
|
|
|
/* Do it only once. */
|
|
|
|
|
return;
|
|
|
|
|
|
2007-07-05 03:35:15 +08:00
|
|
|
|
printf ("%sGNU Make %s\n", precede, version_string);
|
|
|
|
|
|
|
|
|
|
if (!remote_description || *remote_description == '\0')
|
|
|
|
|
printf (_("%sBuilt for %s\n"), precede, make_host);
|
|
|
|
|
else
|
|
|
|
|
printf (_("%sBuilt for %s (%s)\n"),
|
|
|
|
|
precede, make_host, remote_description);
|
|
|
|
|
|
2002-07-08 10:26:47 +08:00
|
|
|
|
/* Print this untranslated. The coding standards recommend translating the
|
|
|
|
|
(C) to the copyright symbol, but this string is going to change every
|
|
|
|
|
year, and none of the rest of it should be translated (including the
|
2012-03-05 22:10:39 +08:00
|
|
|
|
word "Copyright"), so it hardly seems worth it. */
|
2002-07-08 10:26:47 +08:00
|
|
|
|
|
2013-09-12 16:07:52 +08:00
|
|
|
|
printf ("%sCopyright (C) 1988-2013 Free Software Foundation, Inc.\n",
|
2012-03-05 22:10:39 +08:00
|
|
|
|
precede);
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
2007-07-05 03:35:15 +08:00
|
|
|
|
printf (_("%sLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\
|
|
|
|
|
%sThis is free software: you are free to change and redistribute it.\n\
|
|
|
|
|
%sThere is NO WARRANTY, to the extent permitted by law.\n"),
|
2002-07-08 10:26:47 +08:00
|
|
|
|
precede, precede, precede);
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
|
|
|
|
printed_version = 1;
|
|
|
|
|
|
|
|
|
|
/* Flush stdout so the user doesn't have to wait to see the
|
2012-03-05 22:10:39 +08:00
|
|
|
|
version information while make thinks about things. */
|
1992-01-30 07:54:36 +08:00
|
|
|
|
fflush (stdout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Print a bunch of information about this and that. */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-03-20 10:36:36 +08:00
|
|
|
|
print_data_base ()
|
1992-01-30 07:54:36 +08:00
|
|
|
|
{
|
2013-05-22 14:51:45 +08:00
|
|
|
|
time_t when = time ((time_t *) 0);
|
|
|
|
|
|
|
|
|
|
print_version ();
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1999-07-28 14:23:37 +08:00
|
|
|
|
printf (_("\n# Make data base, printed on %s"), ctime (&when));
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
|
|
|
|
print_variable_data_base ();
|
|
|
|
|
print_dir_data_base ();
|
|
|
|
|
print_rule_data_base ();
|
|
|
|
|
print_file_data_base ();
|
|
|
|
|
print_vpath_data_base ();
|
2006-02-10 13:29:00 +08:00
|
|
|
|
strcache_print_stats ("#");
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
|
|
|
|
when = time ((time_t *) 0);
|
1999-07-28 14:23:37 +08:00
|
|
|
|
printf (_("\n# Finished Make data base on %s\n"), ctime (&when));
|
1992-01-30 07:54:36 +08:00
|
|
|
|
}
|
2006-03-20 10:36:36 +08:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
clean_jobserver (int status)
|
|
|
|
|
{
|
|
|
|
|
/* Sanity: have we written all our jobserver tokens back? If our
|
|
|
|
|
exit status is 2 that means some kind of syntax error; we might not
|
|
|
|
|
have written all our tokens so do that now. If tokens are left
|
|
|
|
|
after any other error code, that's bad. */
|
|
|
|
|
|
2011-11-14 08:42:49 +08:00
|
|
|
|
#ifdef WINDOWS32
|
2013-05-17 14:29:46 +08:00
|
|
|
|
if (has_jobserver_semaphore () && jobserver_tokens)
|
2011-11-14 08:42:49 +08:00
|
|
|
|
#else
|
2012-01-29 04:19:55 +08:00
|
|
|
|
char token = '+';
|
|
|
|
|
|
2006-03-20 10:36:36 +08:00
|
|
|
|
if (job_fds[0] != -1 && jobserver_tokens)
|
2011-11-14 08:42:49 +08:00
|
|
|
|
#endif
|
2006-03-20 10:36:36 +08:00
|
|
|
|
{
|
|
|
|
|
if (status != 2)
|
2013-11-24 11:23:52 +08:00
|
|
|
|
ON (error, NILF,
|
|
|
|
|
"INTERNAL: Exiting with %u jobserver tokens (should be 0)!",
|
|
|
|
|
jobserver_tokens);
|
2006-03-20 10:36:36 +08:00
|
|
|
|
else
|
2011-11-14 08:18:38 +08:00
|
|
|
|
/* Don't write back the "free" token */
|
|
|
|
|
while (--jobserver_tokens)
|
2006-03-20 10:36:36 +08:00
|
|
|
|
{
|
2011-11-14 08:42:49 +08:00
|
|
|
|
#ifdef WINDOWS32
|
2013-05-17 14:29:46 +08:00
|
|
|
|
if (! release_jobserver_semaphore ())
|
2011-11-14 08:42:49 +08:00
|
|
|
|
perror_with_name ("release_jobserver_semaphore", "");
|
|
|
|
|
#else
|
2006-03-20 10:36:36 +08:00
|
|
|
|
int r;
|
|
|
|
|
|
|
|
|
|
EINTRLOOP (r, write (job_fds[1], &token, 1));
|
|
|
|
|
if (r != 1)
|
|
|
|
|
perror_with_name ("write", "");
|
2011-11-14 08:42:49 +08:00
|
|
|
|
#endif
|
2006-03-20 10:36:36 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Sanity: If we're the master, were all the tokens written back? */
|
|
|
|
|
|
|
|
|
|
if (master_job_slots)
|
|
|
|
|
{
|
|
|
|
|
/* We didn't write one for ourself, so start at 1. */
|
|
|
|
|
unsigned int tcnt = 1;
|
|
|
|
|
|
2011-11-14 08:42:49 +08:00
|
|
|
|
#ifdef WINDOWS32
|
2013-05-17 14:29:46 +08:00
|
|
|
|
while (acquire_jobserver_semaphore ())
|
2011-11-14 08:42:49 +08:00
|
|
|
|
++tcnt;
|
|
|
|
|
#else
|
2006-03-20 10:36:36 +08:00
|
|
|
|
/* Close the write side, so the read() won't hang. */
|
|
|
|
|
close (job_fds[1]);
|
|
|
|
|
|
|
|
|
|
while (read (job_fds[0], &token, 1) == 1)
|
|
|
|
|
++tcnt;
|
2011-11-14 08:42:49 +08:00
|
|
|
|
#endif
|
2006-03-20 10:36:36 +08:00
|
|
|
|
|
|
|
|
|
if (tcnt != master_job_slots)
|
2013-11-24 11:23:52 +08:00
|
|
|
|
ONN (error, NILF,
|
|
|
|
|
"INTERNAL: Exiting with %u jobserver tokens available; should be %u!",
|
|
|
|
|
tcnt, master_job_slots);
|
2006-03-20 10:36:36 +08:00
|
|
|
|
|
2011-11-14 08:42:49 +08:00
|
|
|
|
#ifdef WINDOWS32
|
2013-05-17 14:29:46 +08:00
|
|
|
|
free_jobserver_semaphore ();
|
2011-11-14 08:42:49 +08:00
|
|
|
|
#else
|
2006-03-20 10:36:36 +08:00
|
|
|
|
close (job_fds[0]);
|
2011-11-14 08:42:49 +08:00
|
|
|
|
#endif
|
2009-06-09 23:35:38 +08:00
|
|
|
|
|
|
|
|
|
/* Clean out jobserver_fds so we don't pass this information to any
|
|
|
|
|
sub-makes. Also reset job_slots since it will be put on the command
|
|
|
|
|
line, not in MAKEFLAGS. */
|
|
|
|
|
job_slots = default_job_slots;
|
2014-04-26 05:38:08 +08:00
|
|
|
|
free (jobserver_fds);
|
|
|
|
|
jobserver_fds = 0;
|
2006-03-20 10:36:36 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
|
|
|
|
/* Exit with STATUS, cleaning up as necessary. */
|
|
|
|
|
|
|
|
|
|
void
|
2002-10-15 05:54:04 +08:00
|
|
|
|
die (int status)
|
1992-01-30 07:54:36 +08:00
|
|
|
|
{
|
|
|
|
|
static char dying = 0;
|
|
|
|
|
|
|
|
|
|
if (!dying)
|
|
|
|
|
{
|
1992-04-21 15:56:07 +08:00
|
|
|
|
int err;
|
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
dying = 1;
|
|
|
|
|
|
1992-09-30 09:26:59 +08:00
|
|
|
|
if (print_version_flag)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
print_version ();
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
|
|
|
|
/* Wait for children to die. */
|
2005-08-08 13:08:00 +08:00
|
|
|
|
err = (status != 0);
|
|
|
|
|
while (job_slots_used > 0)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
reap_children (1, err);
|
1992-01-30 07:54:36 +08:00
|
|
|
|
|
1996-06-23 03:31:12 +08:00
|
|
|
|
/* Let the remote job module clean up its state. */
|
|
|
|
|
remote_cleanup ();
|
|
|
|
|
|
1992-01-30 07:54:36 +08:00
|
|
|
|
/* Remove the intermediate files. */
|
|
|
|
|
remove_intermediates (0);
|
|
|
|
|
|
1993-01-13 03:42:13 +08:00
|
|
|
|
if (print_data_base_flag)
|
2013-01-20 13:55:57 +08:00
|
|
|
|
print_data_base ();
|
1993-01-13 03:42:13 +08:00
|
|
|
|
|
2013-06-22 11:59:38 +08:00
|
|
|
|
if (verify_flag)
|
|
|
|
|
verify_file_data_base ();
|
2007-03-20 11:02:26 +08:00
|
|
|
|
|
2006-03-20 10:36:36 +08:00
|
|
|
|
clean_jobserver (status);
|
2005-05-03 21:57:20 +08:00
|
|
|
|
|
2013-09-22 05:24:59 +08:00
|
|
|
|
if (output_context)
|
|
|
|
|
{
|
2014-01-12 05:10:02 +08:00
|
|
|
|
/* die() might be called in a recipe output context due to an
|
|
|
|
|
$(error ...) function. */
|
|
|
|
|
output_close (output_context);
|
|
|
|
|
|
|
|
|
|
if (output_context != &make_sync)
|
|
|
|
|
output_close (&make_sync);
|
|
|
|
|
|
2013-09-22 05:24:59 +08:00
|
|
|
|
OUTPUT_UNSET ();
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-12 16:07:52 +08:00
|
|
|
|
output_close (NULL);
|
|
|
|
|
|
1998-07-31 04:54:47 +08:00
|
|
|
|
/* Try to move back to the original directory. This is essential on
|
2013-01-20 13:55:57 +08:00
|
|
|
|
MS-DOS (where there is really only one process), and on Unix it
|
|
|
|
|
puts core files in the original directory instead of the -C
|
|
|
|
|
directory. Must wait until after remove_intermediates(), or unlinks
|
1998-07-31 04:54:47 +08:00
|
|
|
|
of relative pathnames fail. */
|
|
|
|
|
if (directory_before_chdir != 0)
|
2010-07-01 15:16:00 +08:00
|
|
|
|
{
|
|
|
|
|
/* If it fails we don't care: shut up GCC. */
|
2012-10-29 15:05:21 +08:00
|
|
|
|
int _x UNUSED;
|
2010-07-01 15:16:00 +08:00
|
|
|
|
_x = chdir (directory_before_chdir);
|
|
|
|
|
}
|
1992-01-30 07:54:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exit (status);
|
|
|
|
|
}
|