make/main.c

2814 lines
78 KiB
C
Raw Normal View History

1994-03-23 14:12:55 +00:00
/* Argument parsing and main program of GNU Make.
Copyright (C) 1988, 1989, 1990, 1991, 1994, 1995, 1996, 1997, 1998, 1999,
2002 Free Software Foundation, Inc.
1992-01-29 23:54:36 +00:00
This file is part of GNU Make.
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 Foundation; either version 2, or (at your option)
any later version.
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.
You should have received a copy of the GNU General Public License
along with GNU Make; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
1992-01-29 23:54:36 +00:00
#include "make.h"
#include "dep.h"
#include "filedef.h"
1992-01-29 23:54:36 +00:00
#include "variable.h"
#include "job.h"
#include "commands.h"
1998-10-03 05:39:55 +00:00
#include "rule.h"
#include "debug.h"
1992-05-09 04:28:28 +00:00
#include "getopt.h"
1995-03-24 23:39:24 +00:00
#include <assert.h>
#ifdef _AMIGA
# include <dos/dos.h>
# include <proto/dos.h>
#endif
1997-04-07 07:21:16 +00:00
#ifdef WINDOWS32
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
#include <windows.h>
#include "pathstuff.h"
#endif
#if defined(MAKE_JOBSERVER) && defined(HAVE_FCNTL_H)
# include <fcntl.h>
#endif
#ifdef _AMIGA
int __stack = 20000; /* Make sure we have 20K of stack space */
#endif
1992-01-29 23:54:36 +00:00
extern void init_dir PARAMS ((void));
extern void remote_setup PARAMS ((void));
extern void remote_cleanup PARAMS ((void));
extern RETSIGTYPE fatal_error_signal PARAMS ((int sig));
1992-01-29 23:54:36 +00:00
extern void print_variable_data_base PARAMS ((void));
extern void print_dir_data_base PARAMS ((void));
extern void print_rule_data_base PARAMS ((void));
extern void print_file_data_base PARAMS ((void));
extern void print_vpath_data_base PARAMS ((void));
1992-01-29 23:54:36 +00:00
1998-10-03 05:39:55 +00:00
#if defined HAVE_WAITPID || defined HAVE_WAIT3
# define HAVE_WAIT_NOHANG
#endif
1992-06-11 04:58:20 +00:00
#ifndef HAVE_UNISTD_H
1992-01-29 23:54:36 +00:00
extern int chdir ();
1992-06-11 04:58:20 +00:00
#endif
#ifndef STDC_HEADERS
# ifndef sun /* Sun has an incorrect decl in a header. */
1998-10-03 05:39:55 +00:00
extern void exit PARAMS ((int)) __attribute__ ((noreturn));
# endif
1992-01-29 23:54:36 +00:00
extern double atof ();
#endif
1998-10-03 05:39:55 +00:00
static void print_data_base PARAMS ((void));
static void print_version PARAMS ((void));
static void decode_switches PARAMS ((int argc, char **argv, int env));
static void decode_env_switches PARAMS ((char *envar, unsigned int len));
static void define_makeflags PARAMS ((int all, int makefile));
static char *quote_for_env PARAMS ((char *out, char *in));
static void initialize_global_hash_tables PARAMS ((void));
1993-06-25 19:47:20 +00:00
1992-01-29 23:54:36 +00:00
/* The structure that describes an accepted command switch. */
struct command_switch
{
int c; /* The switch character. */
1993-04-14 18:20:33 +00:00
1992-05-09 04:28:28 +00:00
enum /* Type of the value. */
1992-01-29 23:54:36 +00:00
{
1992-05-09 04:28:28 +00:00
flag, /* Turn int flag on. */
flag_off, /* Turn int flag off. */
string, /* One string per switch. */
positive_int, /* A positive integer. */
floating, /* A floating-point number (double). */
1993-05-22 20:20:16 +00:00
ignore /* Ignored. */
1992-01-29 23:54:36 +00:00
} type;
char *value_ptr; /* Pointer to the value-holding variable. */
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. */
char *noarg_value; /* Pointer to value used if no argument is given. */
char *default_value;/* Pointer to default value. */
1992-05-09 04:28:28 +00:00
char *long_name; /* Long option name. */
1992-01-29 23:54:36 +00:00
};
/* True if C is a switch value that corresponds to a short option. */
#define short_option(c) ((c) <= CHAR_MAX)
1992-01-29 23:54:36 +00:00
/* The structure used to hold the list of strings given
in command switches of a type that takes string arguments. */
struct stringlist
{
char **list; /* Nil-terminated list of strings. */
unsigned int idx; /* Index into above. */
unsigned int max; /* Number of pointers allocated. */
};
/* The recognized command switches. */
/* 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;
/* Print debugging info (--debug). */
1992-01-29 23:54:36 +00:00
static struct stringlist *db_flags;
2000-01-23 07:05:16 +00:00
static int debug_flag = 0;
int db_level = 0;
1992-01-29 23:54:36 +00:00
1997-04-07 07:21:16 +00:00
#ifdef WINDOWS32
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
/* Suspend make in main for a short time to allow debugger to attach */
int suspend_flag = 0;
#endif
1992-01-29 23:54:36 +00: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;
/* Nonzero means do not use any of the builtin rules (-r) / variables (-R). */
1992-01-29 23:54:36 +00:00
int no_builtin_rules_flag = 0;
int no_builtin_variables_flag = 0;
1992-01-29 23:54:36 +00:00
/* Nonzero means keep going even if remaking some file fails (-k). */
int keep_going_flag;
int default_keep_going_flag = 0;
1993-04-07 20:40:35 +00:00
/* Nonzero means print directory before starting and when done (-w). */
1992-01-29 23:54:36 +00:00
int print_directory_flag = 0;
1993-04-07 20:40:35 +00: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-29 23:54:36 +00:00
/* Nonzero means print version information. */
int print_version_flag = 0;
/* List of makefiles given with -f switches. */
static struct stringlist *makefiles = 0;
/* Number of job slots (commands that can be run at once). */
unsigned int job_slots = 1;
unsigned int default_job_slots = 1;
/* Value of job_slots that means no limit. */
1992-01-29 23:54:36 +00:00
static unsigned int inf_jobs = 0;
/* File descriptors for the jobs pipe. */
static struct stringlist *jobserver_fds = 0;
int job_fds[2] = { -1, -1 };
int job_rfd = -1;
1992-01-29 23:54:36 +00: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-09 18:02:06 +00:00
#ifndef NO_FLOAT
1992-01-29 23:54:36 +00: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-09 18:02:06 +00:00
#else
int max_load_average = -1;
int default_load_average = -1;
#endif
1992-01-29 23:54:36 +00:00
1993-06-08 00:08:45 +00:00
/* List of directories given with -C switches. */
1992-01-29 23:54:36 +00: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-22 20:20:16 +00:00
/* If nonzero, we should just print usage and exit. */
static int print_usage_flag = 0;
1993-06-25 19:47:20 +00:00
/* If nonzero, we should print a warning message
for each reference to an undefined variable. */
int warn_undefined_variables_flag;
/* If nonzero, always build all targets, regardless of whether
they appear out of date or not. */
int always_make_flag = 0;
1992-05-11 05:28:52 +00: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_("\
-f FILE, --file=FILE, --makefile=FILE\n\
Read FILE as a makefile.\n"),
N_("\
-h, --help Print this message and exit.\n"),
N_("\
-i, --ignore-errors Ignore errors from commands.\n"),
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_("\
-n, --just-print, --dry-run, --recon\n\
Don't actually run any commands; just print them.\n"),
N_("\
-o FILE, --old-file=FILE, --assume-old=FILE\n\
Consider FILE to be very old and don't remake it.\n"),
N_("\
-p, --print-data-base Print make's internal database.\n"),
N_("\
-q, --question Run no commands; exit status says if up to date.\n"),
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_("\
-s, --silent, --quiet Don't echo commands.\n"),
N_("\
-S, --no-keep-going, --stop\n\
Turns off -k.\n"),
N_("\
-t, --touch Touch targets instead of remaking them.\n"),
N_("\
-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
};
1992-01-29 23:54:36 +00:00
/* The table of command switches. */
1993-04-14 18:20:33 +00:00
static const struct command_switch switches[] =
1992-01-29 23:54:36 +00:00
{
{ 'b', ignore, 0, 0, 0, 0, 0, 0, 0 },
{ 'B', flag, (char *) &always_make_flag, 1, 1, 0, 0, 0, "always-make" },
{ 'C', string, (char *) &directories, 0, 0, 0, 0, 0, "directory" },
{ 'd', flag, (char *) &debug_flag, 1, 1, 0, 0, 0, 0 },
{ CHAR_MAX+1, string, (char *) &db_flags, 1, 1, 0, "basic", 0, "debug" },
1997-04-07 07:21:16 +00:00
#ifdef WINDOWS32
{ 'D', flag, (char *) &suspend_flag, 1, 1, 0, 0, 0, "suspend-for-debug" },
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
#endif
1992-05-09 04:28:28 +00:00
{ 'e', flag, (char *) &env_overrides, 1, 1, 0, 0, 0,
"environment-overrides", },
{ 'f', string, (char *) &makefiles, 0, 0, 0, 0, 0, "file" },
{ 'h', flag, (char *) &print_usage_flag, 0, 0, 0, 0, 0, "help" },
1992-05-09 04:28:28 +00:00
{ 'i', flag, (char *) &ignore_errors_flag, 1, 1, 0, 0, 0,
"ignore-errors" },
1993-01-08 21:48:11 +00:00
{ 'I', string, (char *) &include_directories, 1, 1, 0, 0, 0,
"include-dir" },
{ 'j', positive_int, (char *) &job_slots, 1, 1, 0, (char *) &inf_jobs,
(char *) &default_job_slots, "jobs" },
2000-01-23 07:05:16 +00:00
{ CHAR_MAX+2, string, (char *) &jobserver_fds, 1, 1, 0, 0, 0,
"jobserver-fds" },
{ 'k', flag, (char *) &keep_going_flag, 1, 1, 0, 0,
(char *) &default_keep_going_flag, "keep-going" },
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-09 18:02:06 +00:00
#ifndef NO_FLOAT
1992-01-29 23:54:36 +00:00
{ 'l', floating, (char *) &max_load_average, 1, 1, 0,
1992-05-09 04:28:28 +00:00
(char *) &default_load_average, (char *) &default_load_average,
"load-average" },
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-09 18:02:06 +00:00
#else
{ 'l', positive_int, (char *) &max_load_average, 1, 1, 0,
(char *) &default_load_average, (char *) &default_load_average,
"load-average" },
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-09 18:02:06 +00:00
#endif
{ 'm', ignore, 0, 0, 0, 0, 0, 0, 0 },
{ 'n', flag, (char *) &just_print_flag, 1, 1, 1, 0, 0, "just-print" },
{ 'o', string, (char *) &old_files, 0, 0, 0, 0, 0, "old-file" },
1992-05-09 04:28:28 +00:00
{ 'p', flag, (char *) &print_data_base_flag, 1, 1, 0, 0, 0,
"print-data-base" },
{ 'q', flag, (char *) &question_flag, 1, 1, 1, 0, 0, "question" },
1992-05-09 04:28:28 +00:00
{ 'r', flag, (char *) &no_builtin_rules_flag, 1, 1, 0, 0, 0,
"no-builtin-rules" },
{ 'R', flag, (char *) &no_builtin_variables_flag, 1, 1, 0, 0, 0,
"no-builtin-variables" },
{ 's', flag, (char *) &silent_flag, 1, 1, 0, 0, 0, "silent" },
{ 'S', flag_off, (char *) &keep_going_flag, 1, 1, 0, 0,
(char *) &default_keep_going_flag, "no-keep-going" },
{ 't', flag, (char *) &touch_flag, 1, 1, 1, 0, 0, "touch" },
{ 'v', flag, (char *) &print_version_flag, 1, 1, 0, 0, 0, "version" },
1992-05-09 04:28:28 +00:00
{ 'w', flag, (char *) &print_directory_flag, 1, 1, 0, 0, 0,
"print-directory" },
2000-01-23 07:05:16 +00:00
{ CHAR_MAX+3, flag, (char *) &inhibit_print_directory_flag, 1, 1, 0, 0, 0,
"no-print-directory" },
{ 'W', string, (char *) &new_files, 0, 0, 0, 0, 0, "what-if" },
2000-01-23 07:05:16 +00:00
{ CHAR_MAX+4, flag, (char *) &warn_undefined_variables_flag, 1, 1, 0, 0, 0,
"warn-undefined-variables" },
1992-05-09 04:28:28 +00:00
{ '\0', }
1992-01-29 23:54:36 +00:00
};
1992-05-11 05:28:52 +00:00
/* Secondary long names for options. */
1992-01-29 23:54:36 +00:00
1992-05-11 05:28:52 +00:00
static struct option long_option_aliases[] =
{
{ "quiet", no_argument, 0, 's' },
1992-09-15 20:10:46 +00:00
{ "stop", no_argument, 0, 'S' },
1992-12-09 22:10:14 +00:00
{ "new-file", required_argument, 0, 'W' },
1992-05-11 05:28:52 +00:00
{ "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-01-29 23:54:36 +00:00
/* List of goal targets. */
1992-01-29 23:54:36 +00:00
static struct dep *goals, *lastgoal;
/* 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 05:28:52 +00:00
1992-01-29 23:54:36 +00:00
/* The name we were invoked with. */
char *program;
/* Our current directory before processing any -C options. */
char *directory_before_chdir;
1993-02-04 18:23:19 +00:00
/* Our current directory after processing all -C options. */
char *starting_directory;
1992-01-29 23:54:36 +00:00
/* Value of the MAKELEVEL variable at startup (or 0). */
unsigned int makelevel;
/* First file defined in the makefile whose name does not
start with `.'. This is the default to remake if the
command line does not specify. */
struct file *default_goal_file;
/* 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;
/* Nonzero if we have seen the magic `.POSIX' target.
This turns on pedantic compliance with POSIX.2. */
int posix_pedantic;
1997-08-18 18:11:04 +00:00
/* Nonzero if we have seen the `.NOTPARALLEL' target.
This turns off parallel builds for this invocation of make. */
int not_parallel;
1997-08-18 18:11:04 +00: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;
1992-01-29 23:54:36 +00:00
/* Mask of signals that are being caught with fatal_error_signal. */
1992-04-30 22:17:12 +00:00
#ifdef POSIX
sigset_t fatal_signal_set;
#else
# ifdef HAVE_SIGSETMASK
1992-01-29 23:54:36 +00:00
int fatal_signal_mask;
# endif
1992-04-30 22:17:12 +00:00
#endif
1992-01-29 23:54:36 +00:00
#if !defined HAVE_BSD_SIGNAL && !defined bsd_signal
# if !defined HAVE_SIGACTION
# define bsd_signal signal
# else
typedef RETSIGTYPE (*bsd_signal_ret_t) ();
static bsd_signal_ret_t
bsd_signal (sig, func)
int sig;
bsd_signal_ret_t func;
{
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
static void
initialize_global_hash_tables ()
{
init_hash_global_variable_set ();
init_hash_files ();
hash_init_directories ();
hash_init_function_table ();
}
1993-06-02 20:51:28 +00:00
static struct file *
enter_command_line_file (name)
char *name;
{
if (name[0] == '\0')
fatal (NILF, _("empty string invalid as file name"));
1993-06-08 00:08:45 +00:00
if (name[0] == '~')
{
char *expanded = tilde_expand (name);
if (expanded != 0)
name = expanded; /* Memory leak; I don't care. */
}
1993-06-02 20:51:28 +00: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. */
while (name[0] == '.' && name[1] == '/' && name[2] != '\0')
{
name += 2;
while (*name == '/')
/* Skip following slashes: ".//foo" is "foo", not "/foo". */
++name;
}
1993-06-02 20:51:28 +00:00
if (*name == '\0')
{
/* It was all slashes! Move back to the dot and truncate
it after the first slash, so it becomes just "./". */
do
--name;
while (name[0] != '.');
name[2] = '\0';
}
return enter_file (xstrdup (name));
1993-06-02 20:51:28 +00:00
}
/* Toggle -d on receipt of SIGUSR1. */
static RETSIGTYPE
debug_signal_handler (sig)
int sig;
{
db_level = db_level ? DB_NONE : DB_BASIC;
}
static void
decode_debug_flags ()
{
char **pp;
2000-01-23 07:05:16 +00:00
if (debug_flag)
db_level = DB_ALL;
if (!db_flags)
return;
for (pp=db_flags->list; *pp; ++pp)
{
const char *p = *pp;
while (1)
{
switch (tolower (p[0]))
{
case 'a':
db_level |= DB_ALL;
break;
case 'b':
db_level |= DB_BASIC;
break;
case 'i':
2000-01-23 07:05:16 +00:00
db_level |= DB_BASIC | DB_IMPLICIT;
break;
case 'j':
db_level |= DB_JOBS;
break;
case 'm':
2000-01-23 07:05:16 +00:00
db_level |= DB_BASIC | DB_MAKEFILES;
break;
case 'v':
db_level |= DB_BASIC | DB_VERBOSE;
break;
default:
fatal (NILF, _("unknown debug level specification `%s'"), p);
}
while (*(++p) != '\0')
if (*p == ',' || *p == ' ')
break;
if (*p == '\0')
break;
++p;
}
}
}
1997-04-07 07:21:16 +00:00
#ifdef WINDOWS32
/*
* HANDLE runtime exceptions by avoiding a requestor on the GUI. Capture
* exception and print it to stderr instead.
*
* If ! DB_VERBOSE, just print a simple message and exit.
* If DB_VERBOSE, print a more verbose message.
1997-04-07 07:21:16 +00:00
* If compiled for DEBUG, let exception pass through to GUI so that
* debuggers can attach.
*/
LONG WINAPI
handle_runtime_exceptions( struct _EXCEPTION_POINTERS *exinfo )
{
PEXCEPTION_RECORD exrec = exinfo->ExceptionRecord;
LPSTR cmdline = GetCommandLine();
LPSTR prg = strtok(cmdline, " ");
CHAR errmsg[1024];
#ifdef USE_EVENT_LOG
HANDLE hEventSource;
LPTSTR lpszStrings[1];
#endif
if (! ISDB (DB_VERBOSE))
1997-04-07 07:21:16 +00:00
{
sprintf(errmsg,
_("%s: Interrupt/Exception caught (code = 0x%x, addr = 0x%x)\n"),
prg, exrec->ExceptionCode, exrec->ExceptionAddress);
1997-04-07 07:21:16 +00:00
fprintf(stderr, errmsg);
exit(255);
}
sprintf(errmsg,
_("\nUnhandled exception filter called from program %s\nExceptionCode = %x\nExceptionFlags = %x\nExceptionAddress = %x\n"),
prg, exrec->ExceptionCode, exrec->ExceptionFlags,
1997-04-07 07:21:16 +00:00
exrec->ExceptionAddress);
if (exrec->ExceptionCode == EXCEPTION_ACCESS_VIOLATION
&& exrec->NumberParameters >= 2)
sprintf(&errmsg[strlen(errmsg)],
(exrec->ExceptionInformation[0]
? _("Access violation: write operation at address %x\n")
: _("Access violation: read operation at address %x\n")),
1997-04-07 07:21:16 +00:00
exrec->ExceptionInformation[1]);
/* turn this on if we want to put stuff in the event log too */
#ifdef USE_EVENT_LOG
hEventSource = RegisterEventSource(NULL, "GNU Make");
lpszStrings[0] = errmsg;
if (hEventSource != NULL)
{
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);
}
#endif
/* Write the error to stderr too */
fprintf(stderr, errmsg);
#ifdef DEBUG
return EXCEPTION_CONTINUE_SEARCH;
#else
exit(255);
1998-07-30 20:54:47 +00: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
* be invoked from any drive, and we don't want to propogate /bin/sh
* 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
find_and_set_default_shell(char *token)
{
int sh_found = 0;
char* search_token;
PATH_VAR(sh_path);
extern char *default_shell;
if (!token)
search_token = default_shell;
else
search_token = token;
if (!no_default_sh_exe &&
(token == NULL || !strcmp(search_token, default_shell))) {
/* no new information, path already set or known */
sh_found = 1;
} else if (file_exists_p(search_token)) {
/* 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));
1998-07-30 20:54:47 +00:00
sh_found = 1;
} else {
char *p;
struct variable *v = lookup_variable ("Path", 4);
/*
* Search Path for shell
*/
if (v && v->value) {
char *ep;
p = v->value;
ep = strchr(p, PATH_SEPARATOR_CHAR);
while (ep && *ep) {
*ep = '\0';
if (dir_file_exists_p(p, search_token)) {
sprintf(sh_path, "%s/%s", p, search_token);
default_shell = xstrdup(w32ify(sh_path,0));
1998-07-30 20:54:47 +00:00
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);
}
/* be sure to check last element of Path */
if (p && *p && dir_file_exists_p(p, search_token)) {
sprintf(sh_path, "%s/%s", p, search_token);
default_shell = xstrdup(w32ify(sh_path,0));
1998-07-30 20:54:47 +00:00
sh_found = 1;
}
if (sh_found)
DB (DB_VERBOSE,
(_("find_and_set_shell path search set default_shell = %s\n"),
default_shell));
1998-07-30 20:54:47 +00:00
}
}
/* naive test */
if (!unixy_shell && sh_found &&
(strstr(default_shell, "sh") || strstr(default_shell, "SH"))) {
unixy_shell = 1;
batch_mode_shell = 0;
}
#ifdef BATCH_MODE_ONLY_SHELL
batch_mode_shell = 1;
1997-04-07 07:21:16 +00:00
#endif
1998-07-30 20:54:47 +00:00
return (sh_found);
1997-04-07 07:21:16 +00:00
}
#endif /* WINDOWS32 */
#ifdef __MSDOS__
static void
msdos_return_to_initial_directory ()
{
if (directory_before_chdir)
chdir (directory_before_chdir);
}
#endif
extern char *mktemp ();
extern int mkstemp ();
FILE *
open_tmpfile(name, template)
char **name;
const char *template;
{
int fd;
#if defined HAVE_MKSTEMP || defined HAVE_MKTEMP
# define TEMPLATE_LEN strlen (template)
#else
# define TEMPLATE_LEN L_tmpnam
#endif
*name = xmalloc (TEMPLATE_LEN + 1);
strcpy (*name, template);
#if defined HAVE_MKSTEMP && defined HAVE_FDOPEN
/* It's safest to use mkstemp(), if we can. */
fd = mkstemp (*name);
if (fd == -1)
return 0;
return fdopen (fd, "w");
#else
# ifdef HAVE_MKTEMP
(void) mktemp (*name);
# else
(void) tmpnam (*name);
# endif
# ifdef HAVE_FDOPEN
/* Can't use mkstemp(), but guard against a race condition. */
fd = open (*name, O_CREAT|O_EXCL|O_WRONLY, 0600);
if (fd == -1)
return 0;
return fdopen (fd, "w");
# else
/* Not secure, but what can we do? */
return fopen (*name, "w");
# endif
#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-09 18:02:06 +00:00
#ifndef _AMIGA
1992-01-29 23:54:36 +00:00
int
main (argc, argv, envp)
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-09 18:02:06 +00:00
#else
int main (int argc, char ** argv)
#endif
1992-01-29 23:54:36 +00:00
{
1998-07-30 20:54:47 +00:00
static char *stdin_nm = 0;
1992-01-29 23:54:36 +00:00
register struct file *f;
register unsigned int i;
char **p;
struct dep *read_makefiles;
PATH_VAR (current_directory);
1997-04-07 07:21:16 +00:00
#ifdef WINDOWS32
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
char *unix_path = NULL;
1997-04-07 07:21:16 +00:00
char *windows32_path = NULL;
SetUnhandledExceptionFilter(handle_runtime_exceptions);
1998-07-30 20:54:47 +00:00
/* start off assuming we have no shell */
unixy_shell = 0;
no_default_sh_exe = 1;
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
#endif
1992-01-29 23:54:36 +00:00
default_goal_file = 0;
1998-10-03 05:39:55 +00:00
reading_file = 0;
1997-04-07 07:21:16 +00:00
#if defined (__MSDOS__) && !defined (_POSIX_SOURCE)
/* Request the most powerful version of `system', to
make up for the dumb default shell. */
__system_flags = (__system_redirect
| __system_use_shell
| __system_allow_multiple_cmds
| __system_allow_long_cmds
| __system_handle_null_commands
| __system_emulate_chdir);
#endif
/* Set up gettext/internationalization support. */
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
1992-04-30 22:17:12 +00:00
#ifdef POSIX
sigemptyset (&fatal_signal_set);
1992-05-01 15:39:36 +00:00
#define ADD_SIG(sig) sigaddset (&fatal_signal_set, sig)
1992-04-30 22:17:12 +00:00
#else
1992-07-05 00:52:48 +00:00
#ifdef HAVE_SIGSETMASK
1992-01-29 23:54:36 +00:00
fatal_signal_mask = 0;
1992-04-30 22:17:12 +00:00
#define ADD_SIG(sig) fatal_signal_mask |= sigmask (sig)
#else
#define ADD_SIG(sig)
#endif
#endif
1992-01-29 23:54:36 +00:00
#define FATAL_SIG(sig) \
if (bsd_signal (sig, fatal_error_signal) == SIG_IGN) \
bsd_signal (sig, SIG_IGN); \
1992-01-29 23:54:36 +00:00
else \
1992-04-30 22:17:12 +00:00
ADD_SIG (sig);
1992-01-29 23:54:36 +00: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-09 18:02:06 +00:00
#ifdef SIGHUP
1992-01-29 23:54:36 +00: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-09 18:02:06 +00:00
#endif
#ifdef SIGQUIT
1992-01-29 23:54:36 +00: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-09 18:02:06 +00:00
#endif
1992-01-29 23:54:36 +00:00
FATAL_SIG (SIGINT);
1992-06-05 01:04:07 +00:00
FATAL_SIG (SIGTERM);
#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
1992-01-29 23:54:36 +00:00
#ifdef SIGDANGER
FATAL_SIG (SIGDANGER);
1992-06-05 01:04:07 +00:00
#endif
1992-01-29 23:54:36 +00:00
#ifdef SIGXCPU
FATAL_SIG (SIGXCPU);
#endif
#ifdef SIGXFSZ
FATAL_SIG (SIGXFSZ);
#endif
#undef FATAL_SIG
1998-10-03 05:39:55 +00: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
(void) bsd_signal (SIGCHLD, SIG_DFL);
1998-10-03 05:39:55 +00:00
# endif
# if defined SIGCLD && SIGCLD != SIGCHLD
(void) bsd_signal (SIGCLD, SIG_DFL);
1998-10-03 05:39:55 +00:00
# endif
#endif
1992-01-29 23:54:36 +00:00
/* Make sure stdout is line-buffered. */
#ifdef HAVE_SETVBUF
# ifdef SETVBUF_REVERSED
setvbuf (stdout, _IOLBF, xmalloc (BUFSIZ), BUFSIZ);
# else /* setvbuf not reversed. */
1992-06-11 20:05:40 +00:00
/* Some buggy systems lose if we pass 0 instead of allocating ourselves. */
setvbuf (stdout, (char *) 0, _IOLBF, BUFSIZ);
# endif /* setvbuf reversed. */
#elif HAVE_SETLINEBUF
setlinebuf (stdout);
1992-06-11 04:58:20 +00:00
#endif /* setlinebuf missing. */
1992-01-29 23:54:36 +00:00
/* Figure out where this program lives. */
if (argv[0] == 0)
argv[0] = "";
if (argv[0][0] == '\0')
program = "make";
else
1992-01-29 23:54:36 +00:00
{
#ifdef VMS
program = strrchr (argv[0], ']');
#else
program = strrchr (argv[0], '/');
#endif
#ifdef __MSDOS__
if (program == 0)
program = strrchr (argv[0], '\\');
1997-04-07 07:21:16 +00:00
else
{
/* Some weird environments might pass us argv[0] with
both kinds of slashes; we must find the rightmost. */
char *p = strrchr (argv[0], '\\');
1997-04-07 07:21:16 +00:00
if (p && p > program)
program = p;
}
if (program == 0 && argv[0][1] == ':')
program = argv[0] + 1;
#endif
1992-01-29 23:54:36 +00:00
if (program == 0)
program = argv[0];
else
++program;
}
1994-02-16 21:13:16 +00:00
/* Set up to access user data (files). */
user_access ();
initialize_global_hash_tables ();
1992-01-29 23:54:36 +00:00
/* Figure out where we are. */
1997-04-07 07:21:16 +00:00
#ifdef WINDOWS32
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
if (getcwd_fs (current_directory, GET_PATH_MAX) == 0)
#else
1992-06-11 04:58:20 +00:00
if (getcwd (current_directory, GET_PATH_MAX) == 0)
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
#endif
1992-01-29 23:54:36 +00:00
{
1992-07-05 00:52:48 +00:00
#ifdef HAVE_GETCWD
1992-01-29 23:54:36 +00:00
perror_with_name ("getcwd: ", "");
#else
1998-10-03 05:39:55 +00:00
error (NILF, "getwd: %s", current_directory);
1992-01-29 23:54:36 +00:00
#endif
current_directory[0] = '\0';
1993-03-08 18:49:51 +00:00
directory_before_chdir = 0;
1992-01-29 23:54:36 +00:00
}
1993-03-08 18:49:51 +00:00
else
directory_before_chdir = xstrdup (current_directory);
1997-04-07 07:21:16 +00:00
#ifdef __MSDOS__
/* Make sure we will return to the initial directory, come what may. */
atexit (msdos_return_to_initial_directory);
#endif
1992-01-29 23:54:36 +00:00
/* Initialize the special variables. */
define_variable (".VARIABLES", 10, "", o_default, 0)->special = 1;
/* define_variable (".TARGETS", 8, "", o_default, 0); */
1992-01-29 23:54:36 +00:00
/* Read in variables from the environment. It is important that this be
1997-04-07 07:21:16 +00:00
done before $(MAKE) is figured out so its definitions will not be
from the environment. */
1992-01-29 23:54:36 +00: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-09 18:02:06 +00:00
#ifndef _AMIGA
1992-01-29 23:54:36 +00:00
for (i = 0; envp[i] != 0; ++i)
{
1998-07-30 20:54:47 +00:00
int do_not_define;
1992-01-29 23:54:36 +00:00
register char *ep = envp[i];
1998-07-30 20:54:47 +00:00
/* by default, everything gets defined and exported */
do_not_define = 0;
1993-08-11 20:04:39 +00:00
while (*ep != '=')
1998-07-30 20:54:47 +00:00
++ep;
1997-04-07 07:21:16 +00:00
#ifdef WINDOWS32
if (!unix_path && strneq(envp[i], "PATH=", 5))
1997-04-07 07:21:16 +00:00
unix_path = ep+1;
1998-07-30 20:54:47 +00:00
else if (!windows32_path && !strnicmp(envp[i], "Path=", 5)) {
do_not_define = 1; /* it gets defined after loop exits */
1997-04-07 07:21:16 +00:00
windows32_path = ep+1;
1998-07-30 20:54:47 +00:00
}
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
#endif
1993-12-15 22:49:45 +00:00
/* The result of pointer arithmetic is cast to unsigned int for
machines where ptrdiff_t is a different size that doesn't widen
the same. */
1998-07-30 20:54:47 +00:00
if (!do_not_define)
define_variable (envp[i], (unsigned int) (ep - envp[i]),
ep + 1, o_env, 1)
1993-08-11 20:04:39 +00:00
/* Force exportation of every variable culled from the environment.
We used to rely on target_environment's v_default code to do this.
But that does not work for the case where an environment variable
is redefined in a makefile with `override'; it should then still
be exported, because it was originally in the environment. */
->export = v_export;
1992-01-29 23:54:36 +00:00
}
1997-04-07 07:21:16 +00:00
#ifdef WINDOWS32
1998-07-30 20:54:47 +00:00
/*
* Make sure that this particular spelling of 'Path' is available
*/
if (windows32_path)
define_variable("Path", 4, windows32_path, o_env, 1)->export = v_export;
else if (unix_path)
define_variable("Path", 4, unix_path, o_env, 1)->export = v_export;
else
define_variable("Path", 4, "", o_env, 1)->export = v_export;
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
/*
* PATH defaults to Path iff PATH not found and Path is found.
*/
1997-04-07 07:21:16 +00:00
if (!unix_path && windows32_path)
define_variable("PATH", 4, windows32_path, o_env, 1)->export = v_export;
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00: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-09 18:02:06 +00:00
#else /* For Amiga, read the ENV: device, ignoring all dirs */
{
BPTR env, file, old;
char buffer[1024];
int len;
__aligned struct FileInfoBlock fib;
env = Lock ("ENV:", ACCESS_READ);
if (env)
{
old = CurrentDir (DupLock(env));
Examine (env, &fib);
while (ExNext (env, &fib))
{
if (fib.fib_DirEntryType < 0) /* File */
{
/* Define an empty variable. It will be filled in
variable_lookup(). Makes startup quite a bit
faster. */
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-09 18:02:06 +00:00
define_variable (fib.fib_FileName,
strlen (fib.fib_FileName),
"", o_env, 1)->export = v_export;
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-09 18:02:06 +00:00
}
}
UnLock (env);
UnLock(CurrentDir(old));
}
}
#endif
1992-01-29 23:54:36 +00:00
/* Decode the switches. */
1993-01-07 00:34:28 +00:00
decode_env_switches ("MAKEFLAGS", 9);
1993-08-11 06:54:23 +00:00
#if 0
/* People write things like:
MFLAGS="CC=gcc -pipe" "CFLAGS=-g"
and we set the -p, -i and -e switches. Doesn't seem quite right. */
1993-01-07 00:34:28 +00:00
decode_env_switches ("MFLAGS", 6);
1993-08-11 06:54:23 +00:00
#endif
1993-01-07 00:34:28 +00:00
decode_switches (argc, argv, 0);
1997-04-07 07:21:16 +00:00
#ifdef WINDOWS32
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
if (suspend_flag) {
fprintf(stderr, "%s (pid = %d)\n", argv[0], GetCurrentProcessId());
fprintf(stderr, _("%s is suspending for 30 seconds..."), argv[0]);
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
Sleep(30 * 1000);
fprintf(stderr, _("done sleep(30). Continuing.\n"));
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
}
#endif
1992-01-29 23:54:36 +00:00
decode_debug_flags ();
1992-01-29 23:54:36 +00:00
/* Print version information. */
if (print_version_flag || print_data_base_flag || db_level)
1992-01-29 23:54:36 +00:00
print_version ();
1993-05-14 21:50:11 +00:00
/* `make --version' is supposed to just print the version and exit. */
if (print_version_flag)
1993-05-22 20:20:16 +00:00
die (0);
1993-05-14 21:50:11 +00:00
1999-08-22 17:50:57 +00:00
#ifndef VMS
1992-12-09 22:10:14 +00:00
/* Set the "MAKE_COMMAND" variable to the name we were invoked with.
1992-01-29 23:54:36 +00: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-09 22:10:14 +00:00
find it in the current directory.) */
1997-04-07 07:21:16 +00:00
#ifdef WINDOWS32
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00: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().
*/
if (strpbrk(argv[0], "/:\\") ||
strstr(argv[0], "..") ||
strneq(argv[0], "//", 2))
argv[0] = xstrdup(w32ify(argv[0],1));
1997-04-07 07:21:16 +00:00
#else /* WINDOWS32 */
1999-08-22 17:50:57 +00:00
#ifdef __MSDOS__
if (strchr (argv[0], '\\'))
{
char *p;
argv[0] = xstrdup (argv[0]);
for (p = argv[0]; *p; p++)
if (*p == '\\')
*p = '/';
}
1999-09-15 22:23:35 +00: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
&& (argv[0][0] != '/' && (argv[0][0] == '\0' || argv[0][1] != ':')))
argv[0] = concat (current_directory, "/", argv[0]);
1999-08-22 17:50:57 +00:00
#else /* !__MSDOS__ */
1992-01-29 23:54:36 +00:00
if (current_directory[0] != '\0'
&& argv[0] != 0 && argv[0][0] != '/' && strchr (argv[0], '/') != 0)
1992-01-29 23:54:36 +00:00
argv[0] = concat (current_directory, "/", argv[0]);
1999-08-22 17:50:57 +00:00
#endif /* !__MSDOS__ */
1997-04-07 07:21:16 +00:00
#endif /* WINDOWS32 */
#endif
1992-01-29 23:54:36 +00:00
/* The extra indirection through $(MAKE_COMMAND) is done
for hysterical raisins. */
1993-01-07 00:34:28 +00:00
(void) define_variable ("MAKE_COMMAND", 12, argv[0], o_default, 0);
(void) define_variable ("MAKE", 4, "$(MAKE_COMMAND)", o_default, 1);
1992-01-29 23:54:36 +00: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
variable definitions. */
for (cv = command_variables; cv != 0; cv = cv->next)
{
v = cv->variable;
len += 2 * strlen (v->name);
if (! v->recursive)
++len;
++len;
len += 2 * strlen (v->value);
++len;
}
/* Now allocate a buffer big enough and fill it. */
1995-02-06 22:37:36 +00:00
p = value = (char *) alloca (len);
for (cv = command_variables; cv != 0; cv = cv->next)
{
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. */
/* Define an unchangeable variable with a name that no POSIX.2
makefile could validly use for its own variable. */
(void) define_variable ("-*-command-variables-*-", 23,
value, o_automatic, 0);
/* 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. */
(void) define_variable ("MAKEOVERRIDES", 13,
"${-*-command-variables-*-}", o_env, 1);
}
1992-01-29 23:54:36 +00:00
1993-01-07 00:34:28 +00:00
/* If there were -C flags, move ourselves about. */
1992-01-29 23:54:36 +00:00
if (directories != 0)
for (i = 0; directories->list[i] != 0; ++i)
{
char *dir = directories->list[i];
1993-06-08 00:08:45 +00:00
if (dir[0] == '~')
{
char *expanded = tilde_expand (dir);
if (expanded != 0)
dir = expanded;
}
1992-01-29 23:54:36 +00:00
if (chdir (dir) < 0)
pfatal_with_name (dir);
1993-06-08 00:08:45 +00:00
if (dir != directories->list[i])
free (dir);
1992-01-29 23:54:36 +00:00
}
1997-04-07 07:21:16 +00:00
#ifdef WINDOWS32
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00: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.
*/
1998-07-30 20:54:47 +00:00
no_default_sh_exe = !find_and_set_default_shell(NULL);
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
1997-04-07 07:21:16 +00:00
#endif /* WINDOWS32 */
1992-01-29 23:54:36 +00:00
/* Figure out the level of recursion. */
{
struct variable *v = lookup_variable (MAKELEVEL_NAME, MAKELEVEL_LENGTH);
if (v != 0 && v->value[0] != '\0' && v->value[0] != '-')
1992-01-29 23:54:36 +00:00
makelevel = (unsigned int) atoi (v->value);
else
makelevel = 0;
}
1992-09-30 23:21:22 +00: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-02 22:48:17 +00:00
1993-04-07 20:40:35 +00:00
/* Let the user disable that with --no-print-directory. */
if (inhibit_print_directory_flag)
print_directory_flag = 0;
/* If -R was given, set -r too (doesn't make sense otherwise!) */
if (no_builtin_variables_flag)
no_builtin_rules_flag = 1;
1992-01-29 23:54:36 +00:00
/* Construct the list of include directories to search. */
construct_include_path (include_directories == 0 ? (char **) 0
: include_directories->list);
1993-02-04 18:23:19 +00:00
/* Figure out where we are now, after chdir'ing. */
if (directories == 0)
/* We didn't move, so we're still in the same place. */
starting_directory = current_directory;
else
{
1997-04-07 07:21:16 +00:00
#ifdef WINDOWS32
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
if (getcwd_fs (current_directory, GET_PATH_MAX) == 0)
#else
1993-02-04 18:23:19 +00:00
if (getcwd (current_directory, GET_PATH_MAX) == 0)
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
#endif
1993-02-04 18:23:19 +00:00
{
#ifdef HAVE_GETCWD
perror_with_name ("getcwd: ", "");
#else
1998-10-03 05:39:55 +00:00
error (NILF, "getwd: %s", current_directory);
1993-02-04 18:23:19 +00:00
#endif
starting_directory = 0;
}
else
starting_directory = current_directory;
}
1998-07-30 20:54:47 +00:00
(void) define_variable ("CURDIR", 6, current_directory, o_default, 0);
1992-01-29 23:54:36 +00:00
/* Read any stdin makefiles into temporary files. */
if (makefiles != 0)
{
register unsigned int i;
for (i = 0; i < makefiles->idx; ++i)
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;
2000-04-22 02:11:17 +00:00
char *template, *tmpdir;
1992-01-29 23:54:36 +00:00
if (stdin_nm)
fatal (NILF, _("Makefile from standard input specified twice."));
#ifdef VMS
2000-04-22 02:11:17 +00:00
# define DEFAULT_TMPDIR "sys$scratch:"
#else
2000-04-22 02:11:17 +00:00
# ifdef P_tmpdir
# define DEFAULT_TMPDIR P_tmpdir
# else
# define DEFAULT_TMPDIR "/tmp"
# endif
#endif
#define DEFAULT_TMPFILE "GmXXXXXX"
if (((tmpdir = getenv ("TMPDIR")) == NULL || *tmpdir == '\0')
#if defined __MSDOS__ || defined(WINDOWS32)
/* These are also used commonly on these platforms. */
&& ((tmpdir = getenv ("TEMP")) == NULL || *tmpdir == '\0')
&& ((tmpdir = getenv ("TMP")) == NULL || *tmpdir == '\0')
#endif
2000-04-22 02:11:17 +00:00
)
tmpdir = DEFAULT_TMPDIR;
template = (char *) alloca (strlen (tmpdir)
+ sizeof (DEFAULT_TMPFILE) + 1);
strcpy (template, tmpdir);
#ifdef HAVE_DOS_PATHS
2000-04-22 02:11:17 +00:00
if (strchr ("/\\", template[strlen (template) - 1]) == NULL)
strcat (template, "/");
#else
# ifndef VMS
2000-04-22 02:11:17 +00:00
if (template[strlen (template) - 1] != '/')
strcat (template, "/");
# endif /* !VMS */
#endif /* !HAVE_DOS_PATHS */
1998-07-30 20:54:47 +00:00
2000-04-22 02:11:17 +00:00
strcat (template, DEFAULT_TMPFILE);
outfile = open_tmpfile (&stdin_nm, template);
1992-01-29 23:54:36 +00:00
if (outfile == 0)
pfatal_with_name (_("fopen (temporary file)"));
1992-01-29 23:54:36 +00:00
while (!feof (stdin))
{
char buf[2048];
1999-08-19 04:43:46 +00:00
unsigned int n = fread (buf, 1, sizeof (buf), stdin);
1992-01-29 23:54:36 +00:00
if (n > 0 && fwrite (buf, 1, n, outfile) != n)
pfatal_with_name (_("fwrite (temporary file)"));
1992-01-29 23:54:36 +00:00
}
(void) fclose (outfile);
/* Replace the name that read_all_makefiles will
see with the name of the temporary file. */
makefiles->list[i] = xstrdup (stdin_nm);
1992-01-29 23:54:36 +00:00
/* Make sure the temporary file will not be remade. */
1998-07-30 20:54:47 +00:00
f = enter_file (stdin_nm);
1992-01-29 23:54:36 +00:00
f->updated = 1;
f->update_status = 0;
1992-08-26 21:47:38 +00:00
f->command_state = cs_finished;
1998-07-30 20:54:47 +00:00
/* Can't be intermediate, or it'll be removed too early for
make re-exec. */
f->intermediate = 0;
f->dontcare = 0;
1992-01-29 23:54:36 +00:00
}
}
#if defined(MAKE_JOBSERVER) || !defined(HAVE_WAIT_NOHANG)
/* Set up to handle children dying. This must be done before
reading in the makefiles so that `shell' function calls will work.
If we don't have a hanging wait we have to fall back to old, broken
functionality here and rely on the signal handler and counting
children.
If we're using the jobs pipe we need a signal handler so that
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.
If none of these are true, we don't need a signal handler at all. */
1998-10-03 05:39:55 +00:00
{
extern RETSIGTYPE child_handler PARAMS ((int sig));
# if defined SIGCHLD
bsd_signal (SIGCHLD, child_handler);
1998-10-03 05:39:55 +00:00
# endif
# if defined SIGCLD && SIGCLD != SIGCHLD
bsd_signal (SIGCLD, child_handler);
1998-10-03 05:39:55 +00:00
# endif
}
1992-01-29 23:54:36 +00:00
#endif
/* Let the user send us SIGUSR1 to toggle the -d flag during the run. */
#ifdef SIGUSR1
bsd_signal (SIGUSR1, debug_signal_handler);
#endif
1992-01-29 23:54:36 +00:00
/* Define the initial list of suffixes for old-style rules. */
set_default_suffixes ();
1993-10-14 22:23:39 +00: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-29 23:54:36 +00:00
/* Define some internal and special variables. */
define_automatic_variables ();
/* Set up the MAKEFLAGS and MFLAGS variables
so makefiles can look at them. */
define_makeflags (0, 0);
1998-07-30 20:54:47 +00:00
/* Define the default variables. */
define_default_variables ();
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
1998-07-30 20:54:47 +00:00
/* Read all the makefiles. */
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
1998-07-30 20:54:47 +00:00
default_file = enter_file (".DEFAULT");
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
1998-07-30 20:54:47 +00:00
read_makefiles
= read_all_makefiles (makefiles == 0 ? (char **) 0 : makefiles->list);
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
1998-07-30 20:54:47 +00:00
#ifdef WINDOWS32
/* look one last time after reading all Makefiles */
if (no_default_sh_exe)
no_default_sh_exe = !find_and_set_default_shell(NULL);
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
if (no_default_sh_exe && job_slots != 1) {
error (NILF, _("Do not specify -j or --jobs if sh.exe is not available."));
error (NILF, _("Resetting make for single job mode."));
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
job_slots = 1;
}
1997-04-07 07:21:16 +00:00
#endif /* WINDOWS32 */
Wed May 15 10:14:14 CDT 1996 Rob Tulloh <tulloh@tivoli.com> * dir.c: WIN32 does not support inode. For now, fully qualified pathname along with st_mtime will be keys for files. Fixed problem where vpath can be confused when files are added to a directory after the directory has already been read in. The code now attempts to reread the directory if it discovers that the datestamp on the directory has changed since it was cached by make. This problem only seems to occur on WIN32 right now so it is lumped under port #ifdef WIN32. * function.c: WIN32: call subproc library (CreateProcess()) instead of fork/exec. * job.c: WIN32: Added the code to do fork/exec/waitpid style processing on WIN32 systems via calls to subproc library. * main.c: WIN32: Several things added here. First, there is code for dealing with PATH and SHELL defaults. Make tries to figure out if the user has %PATH% set in the environment and sets it to %Path% if it is not set already. Make also looks to see if sh.exe is anywhere to be found. Code path through job.c will change based on existence of a working Bourne shell. The checking for default shell is done twice: once before makefiles are read in and again after. Fall back to MSDOS style execution mode if no sh.exe is found. Also added some debug support that allows user to pause make with -D switch and attach a debugger. This is especially useful for debugging recursive calls to make where problems appear only in the sub-make. * make.h: WIN32: A few macros and header files for WIN32 support. * misc.c: WIN32: Added a function end_of_token_w32() to assist in parsing code in read.c. * read.c: WIN32: Fixes similar to MSDOS which allow colon to appear in filenames. Use of colon in filenames would otherwise confuse make. * remake.c: WIN32: Added include of io.h to eliminate compiler warnings. Added some code to default LIBDIR if it is not set on WIN32. * variable.c: WIN32: Added support for detecting Path/PATH and converting them to semicolon separated lists for make's internal use. New function sync_Path_environment() which is called in job.c and function.c before creating a new process. Caller must set Path in environment since we don't have fork() to do this for us. * vpath.c: WIN32: Added detection for filenames containing forward or backward slashes. * NMakefile: WIN32: Visual C compatible makefile for use with nmake. Use this to build GNU make the first time on Windows NT or Windows 95. * README.WIN32: WIN32: Contains some helpful notes. * build_w32.bat: WIN32: If you don't like nmake, use this the first time you build GNU make on Windows NT or Windows 95. * config.h.WIN32: WIN32 version of config.h * subproc.bat: WIN32: A bat file used to build the subproc library from the top-level NMakefile. Needed because WIndows 95 (nmake) doesn't allow you to cd in a make rule. * w32/include/dirent.h * w32/compat/dirent.c: WIN32: opendir, readdir, closedir, etc. * w32/include/pathstuff.h: WIN32: used by files needed functions defined in pathstuff.c (prototypes). * w32/include/sub_proc.h: WIN32: prototypes for subproc.lib functions. * w32/include/w32err.h: WIN32: prototypes for w32err.c. * w32/pathstuff.c: WIN32: File and Path/Path conversion functions. * w32/subproc/build.bat: WIN32: build script for subproc library if you don't wish to use nmake. * w32/subproc/NMakefile: WIN32: Visual C compatible makefile for use with nmake. Used to build subproc library. * w32/subproc/misc.c: WIN32: subproc library support code * w32/subproc/proc.h: WIN32: subproc library support code * w32/subproc/sub_proc.c: WIN32: subproc library source code * w32/subproc/w32err.c: WIN32: subproc library support code
1996-05-22 21:51:45 +00:00
1997-04-07 07:21:16 +00:00
#ifdef __MSDOS__
/* We need to know what kind of shell we will be using. */
{
extern int _is_unixy_shell (const char *_path);
1999-08-25 21:39:28 +00:00
struct variable *shv = lookup_variable ("SHELL", 5);
1997-04-07 07:21:16 +00:00
extern int unixy_shell;
extern char *default_shell;
if (shv && *shv->value)
{
char *shell_path = recursively_expand(shv);
if (shell_path && _is_unixy_shell (shell_path))
unixy_shell = 1;
else
unixy_shell = 0;
if (shell_path)
default_shell = shell_path;
}
}
#endif /* __MSDOS__ */
1993-01-07 00:34:28 +00:00
/* Decode switches again, in case the variables were set by the makefile. */
1992-01-29 23:54:36 +00:00
decode_env_switches ("MAKEFLAGS", 9);
1993-08-11 06:59:04 +00:00
#if 0
1992-01-29 23:54:36 +00:00
decode_env_switches ("MFLAGS", 6);
1993-08-11 06:59:04 +00:00
#endif
1992-01-29 23:54:36 +00:00
1999-08-25 21:39:28 +00:00
#ifdef __MSDOS__
if (job_slots != 1)
{
1999-09-06 05:21:52 +00:00
error (NILF,
_("Parallel jobs (-j) are not supported on this platform."));
error (NILF, _("Resetting to single job (-j1) mode."));
1999-08-25 21:39:28 +00:00
job_slots = 1;
}
#endif
#ifdef MAKE_JOBSERVER
/* If the jobserver-fds option is seen, make sure that -j is reasonable. */
if (jobserver_fds)
{
char *cp;
for (i=1; i < jobserver_fds->idx; ++i)
if (!streq (jobserver_fds->list[0], jobserver_fds->list[i]))
fatal (NILF, _("internal error: multiple --jobserver-fds options"));
/* Now parse the fds string and make sure it has the proper format. */
cp = jobserver_fds->list[0];
if (sscanf (cp, "%d,%d", &job_fds[0], &job_fds[1]) != 2)
fatal (NILF,
_("internal error: invalid --jobserver-fds string `%s'"), cp);
/* 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 (job_slots > 0)
error (NILF,
_("warning: -jN forced in submake: disabling jobserver mode."));
/* 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 ((job_rfd = dup (job_fds[0])) < 0)
{
if (errno != EBADF)
pfatal_with_name (_("dup jobserver"));
error (NILF,
_("warning: jobserver unavailable: using -j1. Add `+' to parent make rule."));
job_slots = 1;
}
if (job_slots > 0)
{
close (job_fds[0]);
close (job_fds[1]);
job_fds[0] = job_fds[1] = -1;
free (jobserver_fds->list);
free (jobserver_fds);
jobserver_fds = 0;
}
}
/* 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. */
if (job_slots > 1)
{
char c = '+';
if (pipe (job_fds) < 0 || (job_rfd = dup (job_fds[0])) < 0)
pfatal_with_name (_("creating jobs pipe"));
/* 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
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. */
while (--job_slots)
if (write (job_fds[1], &c, 1) != 1)
pfatal_with_name (_("init jobserver pipe"));
/* Fill in the jobserver_fds struct for our children. */
jobserver_fds = (struct stringlist *)
xmalloc (sizeof (struct stringlist));
jobserver_fds->list = (char **) xmalloc (sizeof (char *));
jobserver_fds->list[0] = xmalloc ((sizeof ("1024")*2)+1);
sprintf (jobserver_fds->list[0], "%d,%d", job_fds[0], job_fds[1]);
jobserver_fds->idx = 1;
jobserver_fds->max = 1;
}
#endif
1992-01-29 23:54:36 +00:00
/* Set up MAKEFLAGS and MFLAGS again, so they will be right. */
define_makeflags (1, 0);
/* Make each `struct dep' point at the `struct file' for the file
depended on. Also do magic for special targets. */
1992-01-29 23:54:36 +00:00
snap_deps ();
1993-10-14 22:23:39 +00: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-29 23:54:36 +00: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 ();
/* Mark files given with -o flags as very old
1993-10-27 22:14:41 +00:00
and as having been updated already, and files given with -W flags as
brand new (time-stamp as far as possible into the future). */
1992-01-29 23:54:36 +00:00
if (old_files != 0)
for (p = old_files->list; *p != 0; ++p)
{
1993-06-02 20:51:28 +00:00
f = enter_command_line_file (*p);
f->last_mtime = f->mtime_before_update = OLD_MTIME;
1992-01-29 23:54:36 +00:00
f->updated = 1;
f->update_status = 0;
1992-07-15 02:15:53 +00:00
f->command_state = cs_finished;
1992-01-29 23:54:36 +00:00
}
if (new_files != 0)
{
for (p = new_files->list; *p != 0; ++p)
{
1993-06-02 20:51:28 +00:00
f = enter_command_line_file (*p);
f->last_mtime = f->mtime_before_update = NEW_MTIME;
1992-01-29 23:54:36 +00:00
}
}
/* Initialize the remote job module. */
remote_setup ();
1992-01-29 23:54:36 +00:00
if (read_makefiles != 0)
{
/* Update any makefiles if necessary. */
1998-10-03 05:39:55 +00:00
FILE_TIMESTAMP *makefile_mtimes = 0;
1992-01-29 23:54:36 +00:00
unsigned int mm_idx = 0;
1997-04-07 07:21:16 +00:00
char **nargv = argv;
1997-09-19 19:47:55 +00:00
int nargc = argc;
int orig_db_level = db_level;
1992-01-29 23:54:36 +00:00
if (! ISDB (DB_MAKEFILES))
db_level = DB_NONE;
DB (DB_BASIC, (_("Updating makefiles....\n")));
1992-01-29 23:54:36 +00:00
/* Remove any makefiles we don't want to try to update.
Also record the current modtimes so we can compare them later. */
{
register struct dep *d, *last;
last = 0;
d = read_makefiles;
while (d != 0)
{
register struct file *f = d->file;
if (f->double_colon)
for (f = f->double_colon; f != NULL; f = f->prev)
1992-11-16 23:59:17 +00:00
{
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,
(_("Makefile `%s' might loop; not remaking it.\n"),
f->name));
1992-11-16 23:59:17 +00:00
if (last == 0)
read_makefiles = d->next;
else
last->next = d->next;
/* Free the storage. */
free ((char *) d);
1998-07-30 20:54:47 +00:00
d = last == 0 ? read_makefiles : last->next;
1992-11-16 23:59:17 +00:00
break;
}
}
1992-01-29 23:54:36 +00:00
if (f == NULL || !f->double_colon)
{
makefile_mtimes = (FILE_TIMESTAMP *)
xrealloc ((char *) makefile_mtimes,
(mm_idx + 1) * sizeof (FILE_TIMESTAMP));
1992-01-29 23:54:36 +00:00
makefile_mtimes[mm_idx++] = file_mtime_no_search (d->file);
last = d;
d = d->next;
}
}
}
1992-01-29 23:54:36 +00:00
/* Set up `MAKEFLAGS' specially while remaking makefiles. */
define_makeflags (1, 1);
switch (update_goal_chain (read_makefiles, 1))
{
case 1:
/* 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".
*/
1992-01-29 23:54:36 +00:00
case -1:
/* Did nothing. */
break;
case 2:
1992-01-29 23:54:36 +00: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;
register unsigned int i;
1997-04-07 07:21:16 +00:00
struct dep *d;
for (i = 0, d = read_makefiles; d != 0; ++i, d = d->next)
{
/* 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 07:21:16 +00:00
{
/* This makefile was updated. */
if (d->file->update_status == 0)
1997-04-07 07:21:16 +00: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. */
error (NILF, _("Failed to remake makefile `%s'."),
d->file->name);
mtime = file_mtime_no_search (d->file);
any_remade |= (mtime != NONEXISTENT_MTIME
&& mtime != makefile_mtimes[i]);
1997-04-07 07:21:16 +00:00
}
}
else
/* This makefile was not found at all. */
if (! (d->changed & RM_DONTCARE))
{
/* This is a makefile we care about. See how much. */
if (d->changed & RM_INCLUDED)
/* An included makefile. We don't need
to die, but we do want to complain. */
error (NILF,
_("Included makefile `%s' was not found."),
dep_name (d));
else
{
/* A normal makefile. We must die later. */
error (NILF, _("Makefile `%s' was not found"),
dep_name (d));
any_failed = 1;
}
}
}
1999-06-14 05:26:28 +00:00
/* Reset this to empty so we get the right error message below. */
read_makefiles = 0;
1992-01-29 23:54:36 +00:00
if (any_remade)
goto re_exec;
1999-07-08 22:32:38 +00:00
if (any_failed)
die (2);
1999-07-08 22:32:38 +00:00
break;
1992-01-29 23:54:36 +00:00
}
case 0:
1993-06-04 00:27:28 +00:00
re_exec:
1992-01-29 23:54:36 +00:00
/* Updated successfully. Re-exec ourselves. */
1993-06-04 00:27:28 +00:00
remove_intermediates (0);
if (print_data_base_flag)
print_data_base ();
log_working_directory (0);
1993-06-04 00:27:28 +00:00
1992-01-29 23:54:36 +00:00
if (makefiles != 0)
{
/* These names might have changed. */
register unsigned int i, j = 0;
for (i = 1; i < argc; ++i)
if (strneq (argv[i], "-f", 2)) /* XXX */
1993-01-25 22:16:33 +00:00
{
char *p = &argv[i][2];
if (*p == '\0')
argv[++i] = makefiles->list[j];
else
argv[i] = concat ("-f", makefiles->list[j], "");
++j;
}
1992-01-29 23:54:36 +00:00
}
1993-06-04 00:27:28 +00:00
1998-07-30 20:54:47 +00:00
/* Add -o option for the stdin temporary file, if necessary. */
if (stdin_nm)
{
1999-08-19 04:43:46 +00:00
nargv = (char **) xmalloc ((nargc + 2) * sizeof (char *));
bcopy ((char *) argv, (char *) nargv, argc * sizeof (char *));
nargv[nargc++] = concat ("-o", stdin_nm, "");
1998-07-30 20:54:47 +00:00
nargv[nargc] = 0;
}
1997-04-07 07:21:16 +00:00
1992-01-29 23:54:36 +00:00
if (directories != 0 && directories->idx > 0)
{
char bad;
1993-03-08 18:49:51 +00:00
if (directory_before_chdir != 0)
1992-01-29 23:54:36 +00:00
{
1993-03-08 18:49:51 +00:00
if (chdir (directory_before_chdir) < 0)
1992-01-29 23:54:36 +00:00
{
perror_with_name ("chdir", "");
bad = 1;
}
else
bad = 0;
}
else
bad = 1;
if (bad)
fatal (NILF, _("Couldn't change back to original directory."));
1992-01-29 23:54:36 +00:00
}
1993-06-04 00:27:28 +00: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-09 18:02:06 +00:00
#ifndef _AMIGA
1992-01-29 23:54:36 +00:00
for (p = environ; *p != 0; ++p)
if ((*p)[MAKELEVEL_LENGTH] == '='
&& strneq (*p, MAKELEVEL_NAME, MAKELEVEL_LENGTH))
1992-01-29 23:54:36 +00:00
{
1992-07-15 02:15:53 +00:00
/* The SGI compiler apparently can't understand
the concept of storing the result of a function
in something other than a local variable. */
char *sgi_loses;
sgi_loses = (char *) alloca (40);
*p = sgi_loses;
sprintf (*p, "%s=%u", MAKELEVEL_NAME, makelevel);
1992-01-29 23:54:36 +00: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-09 18:02:06 +00:00
#else /* AMIGA */
{
char buffer[256];
int len;
len = GetVar (MAKELEVEL_NAME, buffer, sizeof (buffer), GVF_GLOBAL_ONLY);
if (len != -1)
{
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-09 18:02:06 +00:00
sprintf (buffer, "%u", makelevel);
SetVar (MAKELEVEL_NAME, buffer, -1, GVF_GLOBAL_ONLY);
}
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-09 18:02:06 +00:00
}
#endif
1993-06-04 00:27:28 +00:00
if (ISDB (DB_BASIC))
1993-06-04 00:27:28 +00:00
{
char **p;
fputs (_("Re-executing:"), stdout);
1997-04-07 07:21:16 +00:00
for (p = nargv; *p != 0; ++p)
1993-06-04 00:27:28 +00:00
printf (" %s", *p);
putchar ('\n');
1993-06-04 00:27:28 +00:00
}
fflush (stdout);
fflush (stderr);
/* Close the dup'd jobserver pipe if we opened one. */
if (job_rfd >= 0)
close (job_rfd);
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-09 18:02:06 +00:00
#ifndef _AMIGA
1997-04-07 07:21:16 +00:00
exec_command (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-09 18:02:06 +00:00
#else
1997-04-07 07:21:16 +00:00
exec_command (nargv);
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-09 18:02:06 +00:00
exit (0);
#endif
1992-01-29 23:54:36 +00:00
/* NOTREACHED */
default:
#define BOGUS_UPDATE_STATUS 0
assert (BOGUS_UPDATE_STATUS);
break;
1992-01-29 23:54:36 +00:00
}
db_level = orig_db_level;
1992-01-29 23:54:36 +00:00
}
/* Set up `MAKEFLAGS' again for the normal targets. */
define_makeflags (1, 0);
1998-07-30 20:54:47 +00:00
/* If there is a temp file from reading a makefile from stdin, get rid of
it now. */
1999-08-19 04:43:46 +00:00
if (stdin_nm && unlink (stdin_nm) < 0 && errno != ENOENT)
perror_with_name (_("unlink (temporary file): "), stdin_nm);
1998-07-30 20:54:47 +00:00
1992-01-29 23:54:36 +00:00
{
int status;
/* If there were no command-line goals, use the default. */
if (goals == 0)
{
if (default_goal_file != 0)
{
goals = (struct dep *) xmalloc (sizeof (struct dep));
goals->next = 0;
goals->name = 0;
goals->ignore_mtime = 0;
1992-01-29 23:54:36 +00:00
goals->file = default_goal_file;
}
}
else
lastgoal->next = 0;
1999-04-13 02:28:27 +00:00
if (!goals)
1992-01-29 23:54:36 +00:00
{
1999-04-13 02:28:27 +00:00
if (read_makefiles == 0)
fatal (NILF, _("No targets specified and no makefile found"));
1992-01-29 23:54:36 +00:00
fatal (NILF, _("No targets"));
1992-01-29 23:54:36 +00:00
}
1999-04-13 02:28:27 +00:00
/* Update the goals. */
DB (DB_BASIC, (_("Updating goal targets....\n")));
1999-04-13 02:28:27 +00:00
switch (update_goal_chain (goals, 0))
{
case -1:
/* Nothing happened. */
case 0:
/* Updated successfully. */
2000-06-23 19:43:11 +00:00
status = MAKE_SUCCESS;
break;
case 1:
/* We are under -q and would run some commands. */
status = MAKE_TROUBLE;
1999-04-13 02:28:27 +00:00
break;
case 2:
/* Updating failed. POSIX.2 specifies exit status >1 for this;
but in VMS, there is only success and failure. */
2000-06-23 19:43:11 +00:00
status = MAKE_FAILURE;
1999-04-13 02:28:27 +00:00
break;
default:
abort ();
}
1997-08-18 18:11:04 +00:00
/* If we detected some clock skew, generate one last warning */
if (clock_skew_detected)
error (NILF,
_("warning: Clock skew detected. Your build may be incomplete."));
1997-08-18 18:11:04 +00:00
1992-01-29 23:54:36 +00:00
/* Exit. */
die (status);
}
return 0;
}
1993-01-07 00:34:28 +00:00
/* Parsing of arguments, decoding of switches. */
static char options[1 + sizeof (switches) / sizeof (switches[0]) * 3];
1993-01-07 00:34:28 +00:00
static struct option long_options[(sizeof (switches) / sizeof (switches[0])) +
(sizeof (long_option_aliases) /
sizeof (long_option_aliases[0]))];
/* Fill in the string and vector for getopt. */
1992-01-29 23:54:36 +00:00
static void
1993-01-07 00:34:28 +00:00
init_switches ()
1992-01-29 23:54:36 +00:00
{
1993-01-07 00:34:28 +00:00
register char *p;
1992-05-09 04:28:28 +00:00
register int c;
1993-01-07 00:34:28 +00:00
register unsigned int i;
1992-01-29 23:54:36 +00:00
1993-01-07 00:34:28 +00:00
if (options[0] != '\0')
/* Already done. */
return;
1992-01-29 23:54:36 +00:00
1992-05-09 04:28:28 +00:00
p = options;
/* Return switch and non-switch args in order, regardless of
POSIXLY_CORRECT. Non-switch args are returned as option 1. */
*p++ = '-';
1992-05-09 04:28:28 +00:00
for (i = 0; switches[i].c != '\0'; ++i)
{
1992-05-11 18:11:40 +00:00
long_options[i].name = (switches[i].long_name == 0 ? "" :
switches[i].long_name);
1992-05-25 23:02:13 +00:00
long_options[i].flag = 0;
1993-04-14 18:20:33 +00:00
long_options[i].val = switches[i].c;
if (short_option (switches[i].c))
1993-04-14 18:20:33 +00:00
*p++ = switches[i].c;
1992-05-09 04:28:28 +00:00
switch (switches[i].type)
{
case flag:
case flag_off:
case ignore:
long_options[i].has_arg = no_argument;
break;
case string:
case positive_int:
case floating:
if (short_option (switches[i].c))
1993-04-14 18:20:33 +00:00
*p++ = ':';
1992-05-09 04:28:28 +00:00
if (switches[i].noarg_value != 0)
{
if (short_option (switches[i].c))
1993-04-14 18:20:33 +00:00
*p++ = ':';
1992-05-09 04:28:28 +00:00
long_options[i].has_arg = optional_argument;
}
else
long_options[i].has_arg = required_argument;
break;
}
}
*p = '\0';
1992-05-11 05:28:52 +00:00
for (c = 0; c < (sizeof (long_option_aliases) /
sizeof (long_option_aliases[0]));
++c)
long_options[i++] = long_option_aliases[c];
1992-05-09 04:28:28 +00:00
long_options[i].name = 0;
1993-01-07 00:34:28 +00:00
}
static void
handle_non_switch_argument (arg, env)
char *arg;
int env;
{
/* Non-option argument. It might be a variable definition. */
struct variable *v;
if (arg[0] == '-' && arg[1] == '\0')
/* Ignore plain `-' for compatibility. */
return;
v = try_variable_definition (0, arg, o_command, 0);
if (v != 0)
{
/* It is indeed a variable definition. Record a pointer to
the variable for later use in define_makeflags. */
struct command_variable *cv
= (struct command_variable *) xmalloc (sizeof (*cv));
cv->variable = v;
cv->next = command_variables;
command_variables = cv;
}
else if (! env)
{
/* Not an option or variable definition; it must be a goal
target! Enter it as a file and add it to the dep chain of
goals. */
struct file *f = enter_command_line_file (arg);
f->cmd_target = 1;
if (goals == 0)
{
goals = (struct dep *) xmalloc (sizeof (struct dep));
lastgoal = goals;
}
else
{
1999-08-25 21:39:28 +00:00
lastgoal->next = (struct dep *) xmalloc (sizeof (struct dep));
lastgoal = lastgoal->next;
}
lastgoal->name = 0;
lastgoal->file = f;
lastgoal->ignore_mtime = 0;
1997-04-07 07:21:16 +00:00
{
/* Add this target name to the MAKECMDGOALS variable. */
struct variable *v;
char *value;
1999-08-19 04:43:46 +00:00
v = lookup_variable ("MAKECMDGOALS", 12);
1997-04-07 07:21:16 +00:00
if (v == 0)
value = f->name;
else
{
/* Paste the old and new values together */
unsigned int oldlen, newlen;
1999-08-19 04:43:46 +00:00
oldlen = strlen (v->value);
newlen = strlen (f->name);
value = (char *) alloca (oldlen + 1 + newlen + 1);
bcopy (v->value, value, oldlen);
1997-04-07 07:21:16 +00:00
value[oldlen] = ' ';
1999-08-19 04:43:46 +00:00
bcopy (f->name, &value[oldlen + 1], newlen + 1);
1997-04-07 07:21:16 +00:00
}
1999-08-19 04:43:46 +00:00
define_variable ("MAKECMDGOALS", 12, value, o_default, 0);
1997-04-07 07:21:16 +00:00
}
}
}
/* Print a nice usage method. */
static void
print_usage (bad)
int bad;
{
extern char *make_host;
const char *const *cpp;
FILE *usageto;
if (print_version_flag)
print_version ();
usageto = bad ? stderr : stdout;
fprintf (usageto, _("Usage: %s [options] [target] ...\n"), program);
for (cpp = usage; *cpp; ++cpp)
fputs (_(*cpp), usageto);
if (!remote_description || *remote_description == '\0')
fprintf (usageto, _("\nThis program built for %s\n"), make_host);
else
fprintf (usageto, _("\nThis program built for %s (%s)\n"),
make_host, remote_description);
fprintf (usageto, _("Report bugs to <bug-make@gnu.org>\n"));
}
1993-01-07 00:34:28 +00:00
/* Decode switches from ARGC and ARGV.
They came from the environment if ENV is nonzero. */
static void
decode_switches (argc, argv, env)
int argc;
char **argv;
int env;
{
int bad = 0;
1993-04-14 18:20:33 +00:00
register const struct command_switch *cs;
1993-01-07 00:34:28 +00: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. */
optind = 0;
1992-05-09 04:28:28 +00:00
while (optind < argc)
1992-01-29 23:54:36 +00:00
{
/* Parse the next argument. */
c = getopt_long (argc, argv, options, long_options, (int *) 0);
if (c == EOF)
/* End of arguments, or "--" marker seen. */
break;
else if (c == 1)
/* An argument not starting with a dash. */
handle_non_switch_argument (optarg, env);
else if (c == '?')
1992-05-09 04:28:28 +00: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;
else
for (cs = switches; cs->c != '\0'; ++cs)
1992-05-11 18:11:40 +00:00
if (cs->c == c)
{
1993-01-07 00:34:28 +00:00
/* 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;
1992-05-09 04:28:28 +00:00
switch (cs->type)
1992-01-29 23:54:36 +00:00
{
1992-05-09 04:28:28 +00:00
default:
abort ();
1992-01-29 23:54:36 +00:00
1992-05-09 04:28:28 +00:00
case ignore:
break;
1992-01-29 23:54:36 +00:00
1992-05-09 04:28:28 +00:00
case flag:
case flag_off:
1993-01-07 00:34:28 +00:00
if (doit)
*(int *) cs->value_ptr = cs->type == flag;
1992-05-09 04:28:28 +00:00
break;
1992-01-29 23:54:36 +00:00
1992-05-09 04:28:28 +00:00
case string:
1993-01-07 00:34:28 +00:00
if (!doit)
break;
1992-05-09 04:28:28 +00:00
if (optarg == 0)
optarg = cs->noarg_value;
sl = *(struct stringlist **) cs->value_ptr;
if (sl == 0)
{
sl = (struct stringlist *)
xmalloc (sizeof (struct stringlist));
sl->max = 5;
sl->idx = 0;
sl->list = (char **) xmalloc (5 * sizeof (char *));
*(struct stringlist **) cs->value_ptr = sl;
}
else if (sl->idx == sl->max - 1)
{
sl->max += 5;
sl->list = (char **)
xrealloc ((char *) sl->list,
sl->max * sizeof (char *));
}
1993-06-02 20:51:28 +00:00
sl->list[sl->idx++] = optarg;
1992-05-09 04:28:28 +00:00
sl->list[sl->idx] = 0;
break;
case positive_int:
/* See if we have an option argument; if we do require that
it's all digits, not something like "10foo". */
if (optarg == 0 && argc > optind)
{
const char *cp;
for (cp=argv[optind]; ISDIGIT (cp[0]); ++cp)
;
if (cp[0] == '\0')
optarg = argv[optind++];
}
1993-01-07 00:34:28 +00:00
if (!doit)
break;
1992-05-09 04:28:28 +00:00
if (optarg != 0)
{
int i = atoi (optarg);
const char *cp;
/* Yes, I realize we're repeating this in some cases. */
for (cp = optarg; ISDIGIT (cp[0]); ++cp)
;
if (i < 1 || cp[0] != '\0')
1992-01-29 23:54:36 +00:00
{
error (NILF, _("the `-%c' option requires a positive integral argument"),
cs->c);
1992-05-09 04:28:28 +00:00
bad = 1;
1992-01-29 23:54:36 +00:00
}
else
1992-05-09 04:28:28 +00:00
*(unsigned int *) cs->value_ptr = i;
1992-01-29 23:54:36 +00:00
}
1992-05-09 04:28:28 +00:00
else
*(unsigned int *) cs->value_ptr
= *(unsigned int *) cs->noarg_value;
break;
1992-01-29 23:54:36 +00: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-09 18:02:06 +00:00
#ifndef NO_FLOAT
1992-05-09 04:28:28 +00:00
case floating:
1993-01-07 00:34:28 +00:00
if (optarg == 0 && optind < argc
1999-08-25 21:39:28 +00:00
&& (ISDIGIT (argv[optind][0]) || argv[optind][0] == '.'))
1993-01-07 00:34:28 +00:00
optarg = argv[optind++];
if (doit)
*(double *) cs->value_ptr
1993-01-07 00:34:28 +00:00
= (optarg != 0 ? atof (optarg)
: *(double *) cs->noarg_value);
1992-01-29 23:54:36 +00: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-09 18:02:06 +00:00
#endif
1992-01-29 23:54:36 +00:00
}
1992-05-11 18:11:40 +00:00
/* We've found the switch. Stop looking. */
break;
}
1992-01-29 23:54:36 +00: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-22 20:20:16 +00:00
if (!env && (bad || print_usage_flag))
1992-05-09 04:28:28 +00:00
{
1999-08-19 04:43:46 +00:00
print_usage (bad);
die (bad ? 2 : 0);
1992-05-09 04:28:28 +00:00
}
1992-01-29 23:54:36 +00:00
}
1993-01-07 00:34:28 +00: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-29 23:54:36 +00:00
static void
decode_env_switches (envar, len)
char *envar;
unsigned int len;
{
1993-01-08 21:48:11 +00:00
char *varref = (char *) alloca (2 + len + 2);
char *value, *p;
1993-01-07 00:34:28 +00:00
int argc;
char **argv;
/* Get the variable's value. */
varref[0] = '$';
varref[1] = '(';
bcopy (envar, &varref[2], len);
varref[2 + len] = ')';
varref[2 + len + 1] = '\0';
value = variable_expand (varref);
1993-01-07 00:34:28 +00:00
/* Skip whitespace, and check for an empty value. */
value = next_token (value);
len = strlen (value);
if (len == 0)
1992-01-29 23:54:36 +00:00
return;
1993-01-07 00:34:28 +00:00
/* Allocate a vector that is definitely big enough. */
1993-02-04 18:23:19 +00:00
argv = (char **) alloca ((1 + len + 1) * sizeof (char *));
1993-01-12 19:42:13 +00:00
/* Allocate a buffer to copy the value into while we split it into words
and unquote it. We must use permanent storage for this because
decode_switches may store pointers into the passed argument words. */
p = (char *) xmalloc (2 * len);
1993-01-12 19:42:13 +00:00
/* getopt will look at the arguments starting at ARGV[1].
Prepend a spacer word. */
argv[0] = 0;
argc = 1;
argv[argc] = p;
while (*value != '\0')
{
if (*value == '\\' && value[1] != '\0')
++value; /* Skip the backslash. */
else if (isblank ((unsigned char)*value))
{
/* End of the word. */
*p++ = '\0';
argv[++argc] = p;
do
++value;
while (isblank ((unsigned char)*value));
continue;
}
*p++ = *value++;
}
*p = '\0';
argv[++argc] = 0;
if (argv[1][0] != '-' && strchr (argv[1], '=') == 0)
/* The first word doesn't start with a dash and isn't a variable
definition. Add a dash and pass it along to decode_switches. We
need permanent storage for this in case decode_switches saves
pointers into the value. */
argv[1] = concat ("-", argv[1], "");
1993-01-07 00:34:28 +00:00
/* Parse those words. */
decode_switches (argc, argv, 1);
1992-01-29 23:54:36 +00:00
}
/* Quote the string IN so that it will be interpreted as a single word with
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. */
static char *
quote_for_env (out, in)
char *out, *in;
{
while (*in != '\0')
{
if (*in == '$')
*out++ = '$';
else if (isblank ((unsigned char)*in) || *in == '\\')
*out++ = '\\';
*out++ = *in++;
}
return out;
}
1992-01-29 23:54:36 +00:00
/* Define the MAKEFLAGS and MFLAGS variables to reflect the settings of the
1993-01-08 21:48:11 +00:00
command switches. Include options with args if ALL is nonzero.
1993-01-07 00:34:28 +00:00
Don't include options with the `no_makefile' flag set if MAKEFILE. */
1992-01-29 23:54:36 +00:00
static void
1993-01-08 21:48:11 +00:00
define_makeflags (all, makefile)
int all, makefile;
1992-01-29 23:54:36 +00:00
{
static const char ref[] = "$(MAKEOVERRIDES)";
static const char posixref[] = "$(-*-command-variables-*-)";
1993-04-14 18:20:33 +00:00
register const struct command_switch *cs;
1993-01-08 21:48:11 +00:00
char *flagstring;
register char *p;
unsigned int words;
1993-12-16 20:10:36 +00:00
struct variable *v;
1993-01-08 21:48:11 +00:00
/* We will construct a linked list of `struct flag's describing
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-14 18:20:33 +00:00
const struct command_switch *cs;
1993-01-08 21:48:11 +00:00
char *arg;
};
struct flag *flags = 0;
unsigned int flagslen = 0;
#define ADD_FLAG(ARG, LEN) \
do { \
struct flag *new = (struct flag *) alloca (sizeof (struct flag)); \
1993-04-08 22:14:23 +00:00
new->cs = cs; \
1993-01-08 21:48:11 +00:00
new->arg = (ARG); \
new->next = flags; \
flags = new; \
if (new->arg == 0) \
++flagslen; /* Just a single flag letter. */ \
else \
flagslen += 1 + 1 + 1 + 1 + 3 * (LEN); /* " -x foo" */ \
if (!short_option (cs->c)) \
1993-04-07 20:40:35 +00:00
/* This switch has no single-letter version, so we use the long. */ \
flagslen += 2 + strlen (cs->long_name); \
1993-01-08 21:48:11 +00:00
} while (0)
1992-01-29 23:54:36 +00:00
for (cs = switches; cs->c != '\0'; ++cs)
if (cs->toenv && (!makefile || !cs->no_makefile))
1993-01-08 21:48:11 +00:00
switch (cs->type)
{
default:
abort ();
1992-01-29 23:54:36 +00:00
1993-01-08 21:48:11 +00:00
case ignore:
break;
1992-01-29 23:54:36 +00:00
1993-01-08 21:48:11 +00:00
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;
1992-01-29 23:54:36 +00:00
1993-01-08 21:48:11 +00:00
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))
1993-01-25 22:16:33 +00:00
ADD_FLAG ("", 0); /* Optional value omitted; see below. */
1993-01-08 21:48:11 +00:00
else if (cs->c == 'j')
/* Special case for `-j'. */
ADD_FLAG ("1", 1);
else
{
char *buf = (char *) alloca (30);
sprintf (buf, "%u", *(unsigned int *) cs->value_ptr);
ADD_FLAG (buf, strlen (buf));
}
}
break;
1992-01-29 23:54:36 +00: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-09 18:02:06 +00:00
#ifndef NO_FLOAT
1993-01-08 21:48:11 +00: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))
1993-01-25 22:16:33 +00:00
ADD_FLAG ("", 0); /* Optional value omitted; see below. */
1993-01-08 21:48:11 +00:00
else
{
char *buf = (char *) alloca (100);
1993-04-26 20:05:02 +00:00
sprintf (buf, "%g", *(double *) cs->value_ptr);
1993-01-08 21:48:11 +00:00
ADD_FLAG (buf, strlen (buf));
}
}
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-09 18:02:06 +00:00
#endif
1993-01-08 21:48:11 +00:00
case string:
if (all)
{
struct stringlist *sl = *(struct stringlist **) cs->value_ptr;
if (sl != 0)
1993-03-18 01:02:20 +00:00
{
/* Add the elements in reverse order, because
all the flags get reversed below; and the order
matters for some switches (like -I). */
register unsigned int i = sl->idx;
while (i-- > 0)
ADD_FLAG (sl->list[i], strlen (sl->list[i]));
}
1993-01-08 21:48:11 +00:00
}
break;
}
1992-01-29 23:54:36 +00:00
flagslen += 4 + sizeof posixref; /* Four more for the possible " -- ". */
1993-01-08 21:48:11 +00:00
#undef ADD_FLAG
/* Construct the value in FLAGSTRING.
We allocate enough space for a preceding dash and trailing null. */
flagstring = (char *) alloca (1 + flagslen + 1);
bzero (flagstring, 1 + flagslen + 1);
p = flagstring;
words = 1;
*p++ = '-';
while (flags != 0)
{
/* Add the flag letter or name to the string. */
if (short_option (flags->cs->c))
*p++ = flags->cs->c;
else
{
if (*p != '-')
{
*p++ = ' ';
*p++ = '-';
}
*p++ = '-';
strcpy (p, flags->cs->long_name);
p += strlen (p);
}
if (flags->arg != 0)
{
/* A flag that takes an optional argument which in this case is
omitted is specified by ARG being "". We must distinguish
because a following flag appended without an intervening " -"
is considered the arg for the first. */
if (flags->arg[0] != '\0')
1993-01-08 21:48:11 +00:00
{
/* Add its argument too. */
*p++ = !short_option (flags->cs->c) ? '=' : ' ';
p = quote_for_env (p, flags->arg);
1993-01-08 21:48:11 +00:00
}
++words;
/* Write a following space and dash, for the next flag. */
*p++ = ' ';
*p++ = '-';
}
else if (!short_option (flags->cs->c))
{
++words;
/* Long options must each go in their own word,
so we write the following space and dash. */
*p++ = ' ';
*p++ = '-';
}
flags = flags->next;
}
/* Define MFLAGS before appending variable definitions. */
if (p == &flagstring[1])
/* No flags. */
flagstring[0] = '\0';
else if (p[-1] == '-')
{
/* Kill the final space and dash. */
p -= 2;
*p = '\0';
}
else
/* Terminate the string. */
*p = '\0';
/* Since MFLAGS is not parsed for flags, there is no reason to
override any makefile redefinition. */
(void) define_variable ("MFLAGS", 6, flagstring, o_env, 1);
if (all && command_variables != 0)
{
/* Now write a reference to $(MAKEOVERRIDES), which contains all the
command-line variable definitions. */
if (p == &flagstring[1])
/* No flags written, so elide the leading dash already written. */
p = flagstring;
else
{
/* Separate the variables from the switches with a "--" arg. */
if (p[-1] != '-')
1993-04-07 20:40:35 +00:00
{
/* We did not already write a trailing " -". */
1993-04-07 20:40:35 +00:00
*p++ = ' ';
*p++ = '-';
}
/* There is a trailing " -"; fill it out to " -- ". */
*p++ = '-';
*p++ = ' ';
}
/* Copy in the string. */
if (posix_pedantic)
{
bcopy (posixref, p, sizeof posixref - 1);
p += sizeof posixref - 1;
}
else
{
bcopy (ref, p, sizeof ref - 1);
p += sizeof ref - 1;
}
1993-01-08 21:48:11 +00:00
}
else if (p == &flagstring[1])
{
words = 0;
--p;
}
else if (p[-1] == '-')
/* Kill the final space and dash. */
p -= 2;
/* Terminate the string. */
*p = '\0';
1992-01-29 23:54:36 +00:00
1993-12-16 20:10:36 +00:00
v = define_variable ("MAKEFLAGS", 9,
/* If there are switches, omit the leading dash
unless it is a single long option with two
leading dashes. */
&flagstring[(flagstring[0] == '-'
&& flagstring[1] != '-')
? 1 : 0],
1993-12-16 20:10:36 +00: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. Of course, an override or command
definition will still take precedence. */
o_file, 1);
1993-12-16 20:10:36 +00:00
if (! all)
/* The first time we are called, set MAKEFLAGS to always be exported.
We should not do this again on the second call, because that is
after reading makefiles which might have done `unexport MAKEFLAGS'. */
v->export = v_export;
1992-01-29 23:54:36 +00:00
}
/* Print version information. */
static void
print_version ()
{
1992-09-30 01:26:59 +00:00
static int printed_version = 0;
1992-01-29 23:54:36 +00:00
char *precede = print_data_base_flag ? "# " : "";
1992-09-30 01:26:59 +00:00
if (printed_version)
/* Do it only once. */
return;
/* 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
word "Copyright", so it hardly seems worth it. */
printf ("%sGNU Make %s\n\
%sCopyright (C) 2002 Free Software Foundation, Inc.\n",
precede, version_string, precede);
1992-01-29 23:54:36 +00:00
printf (_("%sThis is free software; see the source for copying conditions.\n\
1992-01-29 23:54:36 +00:00
%sThere is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\
%sPARTICULAR PURPOSE.\n"),
precede, precede, precede);
1992-01-29 23:54:36 +00:00
printed_version = 1;
/* Flush stdout so the user doesn't have to wait to see the
version information while things are thought about. */
fflush (stdout);
}
/* Print a bunch of information about this and that. */
static void
print_data_base ()
{
time_t when;
when = time ((time_t *) 0);
printf (_("\n# Make data base, printed on %s"), ctime (&when));
1992-01-29 23:54:36 +00:00
print_variable_data_base ();
print_dir_data_base ();
print_rule_data_base ();
print_file_data_base ();
print_vpath_data_base ();
when = time ((time_t *) 0);
printf (_("\n# Finished Make data base on %s\n"), ctime (&when));
1992-01-29 23:54:36 +00:00
}
/* Exit with STATUS, cleaning up as necessary. */
void
die (status)
int status;
{
static char dying = 0;
if (!dying)
{
1992-04-21 07:56:07 +00:00
int err;
1992-01-29 23:54:36 +00:00
dying = 1;
1992-09-30 01:26:59 +00:00
if (print_version_flag)
1992-01-29 23:54:36 +00:00
print_version ();
/* Wait for children to die. */
for (err = (status != 0); job_slots_used > 0; err = 0)
1992-04-29 21:15:52 +00:00
reap_children (1, err);
1992-01-29 23:54:36 +00:00
/* Let the remote job module clean up its state. */
remote_cleanup ();
1992-01-29 23:54:36 +00:00
/* Remove the intermediate files. */
remove_intermediates (0);
1993-01-12 19:42:13 +00:00
if (print_data_base_flag)
print_data_base ();
1998-07-30 20:54:47 +00:00
/* Try to move back to the original directory. This is essential on
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
of relative pathnames fail. */
if (directory_before_chdir != 0)
chdir (directory_before_chdir);
log_working_directory (0);
1992-01-29 23:54:36 +00:00
}
exit (status);
}
/* Write a message indicating that we've just entered or
left (according to ENTERING) the current directory. */
void
1992-01-29 23:54:36 +00:00
log_working_directory (entering)
int entering;
{
static int entered = 0;
/* Print nothing without the flag. Don't print the entering message
again if we already have. Don't print the leaving message if we
haven't printed the entering message. */
if (! print_directory_flag || entering == entered)
1992-01-29 23:54:36 +00:00
return;
entered = entering;
1992-01-29 23:54:36 +00:00
if (print_data_base_flag)
fputs ("# ", stdout);
/* Use entire sentences to give the translators a fighting chance. */
1992-01-29 23:54:36 +00:00
if (makelevel == 0)
if (starting_directory == 0)
if (entering)
printf (_("%s: Entering an unknown directory"), program);
else
printf (_("%s: Leaving an unknown directory"), program);
else
if (entering)
printf (_("%s: Entering directory `%s'\n"),
program, starting_directory);
else
printf (_("%s: Leaving directory `%s'\n"),
program, starting_directory);
1992-01-29 23:54:36 +00:00
else
if (starting_directory == 0)
if (entering)
printf (_("%s[%u]: Entering an unknown directory"),
program, makelevel);
else
printf (_("%s[%u]: Leaving an unknown directory"),
program, makelevel);
else
if (entering)
printf (_("%s[%u]: Entering directory `%s'\n"),
program, makelevel, starting_directory);
else
printf (_("%s[%u]: Leaving directory `%s'\n"),
program, makelevel, starting_directory);
1992-01-29 23:54:36 +00:00
}