make/make.h

639 lines
17 KiB
C
Raw Normal View History

1994-03-23 14:53:21 +00:00
/* Miscellaneous global declarations and portability cruft for GNU Make.
2012-01-16 02:29:20 +00:00
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
2012 Free Software Foundation, Inc.
1992-01-20 19:14:46 +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 3 of the License, or (at your option) any later
version.
1992-01-20 19:14:46 +00:00
GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
1992-01-20 19:14:46 +00:00
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
1992-01-20 19:14:46 +00:00
1993-08-12 21:19:12 +00:00
/* We use <config.h> instead of "config.h" so that a compilation
using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
(which it would do because make.h was found in $srcdir). */
#include <config.h>
1998-10-03 05:39:55 +00:00
#undef HAVE_CONFIG_H
#define HAVE_CONFIG_H 1
1992-12-20 22:57:06 +00:00
/* Specify we want GNU source code. This must be defined before any
system headers are included. */
#define _GNU_SOURCE 1
/* AIX requires this to be the first thing in the file. */
#if HAVE_ALLOCA_H
# include <alloca.h>
#else
# ifdef _AIX
#pragma alloca
# else
# if !defined(__GNUC__) && !defined(WINDOWS32)
# ifndef alloca /* predefined by HP cc +Olibcalls */
char *alloca ();
# endif
# endif
# endif
#endif
/* Disable assert() unless we're a maintainer.
Some asserts are compute-intensive. */
#ifndef MAKE_MAINTAINER_MODE
# define NDEBUG 1
#endif
1998-10-03 05:39:55 +00:00
#ifdef CRAY
1992-09-02 21:53:59 +00:00
/* This must happen before #include <signal.h> so
that the declaration therein is changed. */
1998-10-03 05:39:55 +00:00
# define signal bsdsignal
1992-09-02 21:53:59 +00:00
#endif
/* If we're compiling for the dmalloc debugger, turn off string inlining. */
#if defined(HAVE_DMALLOC_H) && defined(__GNUC__)
# define __NO_STRING_INLINES
#endif
1992-01-20 19:14:46 +00:00
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include <stdio.h>
#include <ctype.h>
1993-10-28 00:09:14 +00:00
#ifdef HAVE_SYS_TIMEB_H
1993-10-14 19:08:38 +00:00
/* SCO 3.2 "devsys 4.2" has a prototype for `ftime' in <time.h> that bombs
unless <sys/timeb.h> has been included first. */
1998-10-03 05:39:55 +00:00
# include <sys/timeb.h>
1993-10-28 00:09:14 +00:00
#endif
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
1992-07-01 00:52:39 +00:00
#include <errno.h>
1998-10-03 05:39:55 +00:00
#ifndef errno
1992-07-01 00:52:39 +00:00
extern int errno;
#endif
1992-06-11 05:30:34 +00:00
1998-10-03 05:39:55 +00:00
#ifndef isblank
# define isblank(c) ((c) == ' ' || (c) == '\t')
1993-04-14 17:34:15 +00:00
#endif
1998-10-03 05:39:55 +00:00
#ifdef HAVE_UNISTD_H
# include <unistd.h>
/* Ultrix's unistd.h always defines _POSIX_VERSION, but you only get
POSIX.1 behavior with `cc -YPOSIX', which predefines POSIX itself! */
1998-10-03 05:39:55 +00:00
# if defined (_POSIX_VERSION) && !defined (ultrix) && !defined (VMS)
# define POSIX 1
# endif
1992-06-11 05:30:34 +00:00
#endif
1992-01-20 19:14:46 +00:00
1993-07-08 23:51:22 +00:00
/* Some systems define _POSIX_VERSION but are not really POSIX.1. */
#if (defined (butterfly) || defined (__arm) || (defined (__mips) && defined (_SYSTYPE_SVR3)) || (defined (sequent) && defined (i386)))
1998-10-03 05:39:55 +00:00
# undef POSIX
1993-05-14 20:40:38 +00:00
#endif
1993-09-17 04:49:17 +00:00
#if !defined (POSIX) && defined (_AIX) && defined (_POSIX_SOURCE)
1998-10-03 05:39:55 +00:00
# define POSIX 1
1993-09-17 04:49:17 +00:00
#endif
1998-10-03 05:39:55 +00:00
#ifndef RETSIGTYPE
# define RETSIGTYPE void
1992-01-20 19:14:46 +00:00
#endif
1998-10-03 05:39:55 +00:00
#ifndef sigmask
# define sigmask(sig) (1 << ((sig) - 1))
1992-01-20 19:14:46 +00:00
#endif
#ifndef HAVE_SA_RESTART
# define SA_RESTART 0
#endif
1998-10-03 05:39:55 +00:00
#ifdef HAVE_LIMITS_H
# include <limits.h>
1992-01-20 19:14:46 +00:00
#endif
1998-10-03 05:39:55 +00:00
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
1992-06-11 05:30:34 +00:00
#endif
1998-10-03 05:39:55 +00:00
#ifndef PATH_MAX
# ifndef POSIX
# define PATH_MAX MAXPATHLEN
# endif
#endif
1992-01-20 19:14:46 +00:00
#ifndef MAXPATHLEN
1998-10-03 05:39:55 +00:00
# define MAXPATHLEN 1024
#endif
1992-06-11 05:30:34 +00:00
1998-10-03 05:39:55 +00:00
#ifdef PATH_MAX
# define GET_PATH_MAX PATH_MAX
# define PATH_VAR(var) char var[PATH_MAX]
1992-01-20 19:14:46 +00:00
#else
1998-10-03 05:39:55 +00:00
# define NEED_GET_PATH_MAX 1
# define GET_PATH_MAX (get_path_max ())
# define PATH_VAR(var) char *var = alloca (GET_PATH_MAX)
unsigned int get_path_max (void);
1992-01-20 19:14:46 +00:00
#endif
1997-04-07 07:21:16 +00:00
#ifndef CHAR_BIT
1998-10-03 05:39:55 +00:00
# define CHAR_BIT 8
1997-04-07 07:21:16 +00:00
#endif
#ifndef USHRT_MAX
# define USHRT_MAX 65535
#endif
/* Nonzero if the integer type T is signed.
Use <= to avoid GCC warnings about always-false expressions. */
#define INTEGER_TYPE_SIGNED(t) ((t) -1 <= 0)
1997-04-07 07:21:16 +00:00
/* The minimum and maximum values for the integer type T.
Use ~ (t) 0, not -1, for portability to 1's complement hosts. */
#define INTEGER_TYPE_MINIMUM(t) \
(! INTEGER_TYPE_SIGNED (t) ? (t) 0 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))
#define INTEGER_TYPE_MAXIMUM(t) (~ (t) 0 - INTEGER_TYPE_MINIMUM (t))
#ifndef CHAR_MAX
# define CHAR_MAX INTEGER_TYPE_MAXIMUM (char)
#endif
1998-10-03 05:39:55 +00:00
#ifdef STAT_MACROS_BROKEN
# ifdef S_ISREG
# undef S_ISREG
# endif
# ifdef S_ISDIR
# undef S_ISDIR
# endif
#endif /* STAT_MACROS_BROKEN. */
1992-01-20 19:14:46 +00:00
1998-10-03 05:39:55 +00:00
#ifndef S_ISREG
# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
1992-01-20 19:14:46 +00:00
#endif
1998-10-03 05:39:55 +00:00
#ifndef S_ISDIR
# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
1992-01-20 19:14:46 +00:00
#endif
#ifdef VMS
1998-10-03 05:39:55 +00:00
# include <types.h>
# include <unixlib.h>
# include <unixio.h>
# include <perror.h>
/* Needed to use alloca on VMS. */
# include <builtins.h>
#endif
1992-01-20 19:14:46 +00:00
1998-10-03 05:39:55 +00:00
#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
# define __attribute__(x)
# endif
/* The __-protected variants of `format' and `printf' attributes
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
# define __format__ format
# define __printf__ printf
# endif
1992-01-20 19:14:46 +00:00
#endif
#define UNUSED __attribute__ ((unused))
1992-01-20 19:14:46 +00:00
1998-10-03 05:39:55 +00:00
#if defined (STDC_HEADERS) || defined (__GNU_LIBRARY__)
# include <stdlib.h>
# include <string.h>
# define ANSI_STRING 1
#else /* No standard headers. */
# ifdef HAVE_STRING_H
# include <string.h>
# define ANSI_STRING 1
# else
# include <strings.h>
# endif
# ifdef HAVE_MEMORY_H
# include <memory.h>
# endif
# ifdef HAVE_STDLIB_H
# include <stdlib.h>
# else
void *malloc (int);
void *realloc (void *, int);
void free (void *);
1992-01-20 19:14:46 +00:00
void abort (void) __attribute__ ((noreturn));
void exit (int) __attribute__ ((noreturn));
1998-10-03 05:39:55 +00:00
# endif /* HAVE_STDLIB_H. */
1992-07-26 22:30:45 +00:00
1998-10-03 05:39:55 +00:00
#endif /* Standard headers. */
1992-01-20 19:14:46 +00:00
/* These should be in stdlib.h. Make sure we have them. */
#ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
#endif
#ifndef EXIT_FAILURE
# define EXIT_FAILURE 1
#endif
#ifndef ANSI_STRING
1993-04-12 20:51:32 +00:00
1994-02-04 21:28:53 +00:00
/* SCO Xenix has a buggy macro definition in <string.h>. */
1998-10-03 05:39:55 +00:00
#undef strerror
#if !defined(__DECC)
char *strerror (int errnum);
1994-02-04 21:28:53 +00:00
#endif
#endif /* !ANSI_STRING. */
#undef ANSI_STRING
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#if HAVE_STDINT_H
# include <stdint.h>
#endif
#define FILE_TIMESTAMP uintmax_t
#if !defined(HAVE_STRSIGNAL)
char *strsignal (int signum);
#endif
1999-08-25 21:39:28 +00:00
/* ISDIGIT offers the following features:
- Its arg may be any int or unsigned int; it need not be an unsigned char.
- It's guaranteed to evaluate its argument exactly once.
NOTE! Make relies on this behavior, don't change it!
- It's typically faster.
POSIX 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
1999-08-25 21:39:28 +00:00
only '0' through '9' are digits. Prefer ISDIGIT to isdigit() unless
it's important to use the locale's definition of `digit' even when the
host does not conform to POSIX. */
1999-08-25 21:39:28 +00:00
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
/* Test if two strings are equal. Is this worthwhile? Should be profiled. */
#define streq(a, b) \
1998-10-03 05:39:55 +00:00
((a) == (b) || \
(*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
/* Test if two strings are equal, but match case-insensitively on systems
which have case-insensitive filesystems. Should only be used for
filenames! */
#ifdef HAVE_CASE_INSENSITIVE_FS
# define patheq(a, b) \
((a) == (b) \
|| (tolower((unsigned char)*(a)) == tolower((unsigned char)*(b)) \
&& (*(a) == '\0' || !strcasecmp ((a) + 1, (b) + 1))))
1992-01-20 19:14:46 +00:00
#else
# define patheq(a, b) streq(a, b)
1992-01-20 19:14:46 +00:00
#endif
#define strneq(a, b, l) (strncmp ((a), (b), (l)) == 0)
1992-01-20 19:14:46 +00:00
#if defined(__GNUC__) || defined(ENUM_BITFIELDS)
1998-10-03 05:39:55 +00:00
# define ENUM_BITFIELD(bits) :bits
1992-01-20 19:14:46 +00:00
#else
1998-10-03 05:39:55 +00:00
# define ENUM_BITFIELD(bits)
1992-01-20 19:14:46 +00:00
#endif
/* Handle gettext and locales. */
#if HAVE_LOCALE_H
# include <locale.h>
#else
# define setlocale(category, locale)
#endif
#include <gettext.h>
#define _(msgid) gettext (msgid)
#define N_(msgid) gettext_noop (msgid)
#define S_(msg1,msg2,num) ngettext (msg1,msg2,num)
/* Handle other OSs.
To overcome an issue parsing paths in a DOS/Windows environment when
built in a unix based environment, override the PATH_SEPARATOR_CHAR
definition unless being built for Cygwin. */
#if defined(HAVE_DOS_PATHS) && !defined(__CYGWIN__)
# undef PATH_SEPARATOR_CHAR
# define PATH_SEPARATOR_CHAR ';'
#elif !defined(PATH_SEPARATOR_CHAR)
# if defined (VMS)
# define PATH_SEPARATOR_CHAR ','
# else
# define PATH_SEPARATOR_CHAR ':'
# endif
1997-08-27 20:30:54 +00:00
#endif
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 is needed for getcwd() and chdir(), on some W32 systems. */
#if defined(HAVE_DIRECT_H)
# include <direct.h>
#endif
1997-04-07 07:21:16 +00:00
#ifdef WINDOWS32
1998-10-03 05:39:55 +00:00
# include <fcntl.h>
# include <malloc.h>
# define pipe(_p) _pipe((_p), 512, O_BINARY)
# define kill(_pid,_sig) w32_kill((_pid),(_sig))
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
void sync_Path_environment (void);
int w32_kill (pid_t pid, int sig);
char *end_of_token_w32 (const char *s, char stopchar);
int find_and_set_default_shell (const char *token);
1998-07-30 20:54:47 +00:00
/* indicates whether or not we have Bourne shell */
extern int no_default_sh_exe;
/* is default_shell unixy? */
extern int unixy_shell;
#endif /* WINDOWS32 */
1998-10-03 05:39:55 +00:00
#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
# define SET_STACK_SIZE
#endif
#ifdef SET_STACK_SIZE
# include <sys/resource.h>
extern struct rlimit stack_limit;
#endif
1998-10-03 05:39:55 +00:00
struct floc
{
const char *filenm;
1998-10-03 05:39:55 +00:00
unsigned long lineno;
};
#define NILF ((struct floc *)0)
#define STRING_SIZE_TUPLE(_s) (_s), (sizeof (_s)-1)
/* We have to have stdarg.h or varargs.h AND v*printf or doprnt to use
variadic versions of these functions. */
#if HAVE_STDARG_H || HAVE_VARARGS_H
# if HAVE_VPRINTF || HAVE_DOPRNT
# define USE_VARIADIC 1
# endif
#endif
#if HAVE_ANSI_COMPILER && USE_VARIADIC && HAVE_STDARG_H
const char *concat (unsigned int, ...);
void message (int prefix, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
void error (const struct floc *flocp, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
void fatal (const struct floc *flocp, const char *fmt, ...)
1998-10-03 05:39:55 +00:00
__attribute__ ((noreturn, __format__ (__printf__, 2, 3)));
#else
const char *concat ();
void message ();
void error ();
void fatal ();
#endif
void die (int) __attribute__ ((noreturn));
void log_working_directory (int);
void pfatal_with_name (const char *) __attribute__ ((noreturn));
void perror_with_name (const char *, const char *);
void *xmalloc (unsigned int);
void *xcalloc (unsigned int);
void *xrealloc (void *, unsigned int);
char *xstrdup (const char *);
char *xstrndup (const char *, unsigned int);
char *find_next_token (const char **, unsigned int *);
char *next_token (const char *);
char *end_of_token (const char *);
void collapse_continuations (char *);
char *lindex (const char *, const char *, int);
int alpha_compare (const void *, const void *);
void print_spaces (unsigned int);
char *find_percent (char *);
const char *find_percent_cached (const char **);
FILE *open_tmpfile (char **, const char *);
1998-10-03 05:39:55 +00:00
#ifndef NO_ARCHIVES
int ar_name (const char *);
void ar_parse_name (const char *, char **, char **);
int ar_touch (const char *);
time_t ar_member_date (const char *);
typedef long int (*ar_member_func_t) (int desc, const char *mem, int truncated,
long int hdrpos, long int datapos,
long int size, long int date, int uid,
int gid, int mode, const void *arg);
long int ar_scan (const char *archive, ar_member_func_t function, const void *arg);
int ar_name_equal (const char *name, const char *mem, int truncated);
#ifndef VMS
int ar_member_touch (const char *arname, const char *memname);
#endif
1998-10-03 05:39:55 +00:00
#endif
int dir_file_exists_p (const char *, const char *);
int file_exists_p (const char *);
int file_impossible_p (const char *);
void file_impossible (const char *);
const char *dir_name (const char *);
void hash_init_directories (void);
1998-10-03 05:39:55 +00:00
void define_default_variables (void);
void set_default_suffixes (void);
void install_default_suffix_rules (void);
void install_default_implicit_rules (void);
1998-10-03 05:39:55 +00:00
void build_vpath_lists (void);
void construct_vpath_list (char *pattern, char *dirpath);
const char *vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr,
unsigned int* vpath_index, unsigned int* path_index);
int gpath_search (const char *file, unsigned int len);
1998-10-03 05:39:55 +00:00
void construct_include_path (const char **arg_dirs);
1998-10-03 05:39:55 +00:00
void user_access (void);
void make_access (void);
void child_access (void);
1998-10-03 05:39:55 +00:00
void close_stdout (void);
char *strip_whitespace (const char **begpp, const char **endpp);
/* String caching */
void strcache_init (void);
void strcache_print_stats (const char *prefix);
int strcache_iscached (const char *str);
const char *strcache_add (const char *str);
const char *strcache_add_len (const char *str, unsigned int len);
int strcache_setbufsize (unsigned int size);
/* Guile support */
int setup_guile (void);
1998-10-03 05:39:55 +00:00
#ifdef HAVE_VFORK_H
# include <vfork.h>
1992-06-11 05:30:34 +00:00
#endif
1992-01-20 19:14:46 +00:00
/* We omit these declarations on non-POSIX systems which define _POSIX_VERSION,
1997-08-18 18:11:04 +00:00
because such systems often declare them in header files anyway. */
1997-04-07 07:21:16 +00:00
#if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION) && !defined(WINDOWS32)
1992-01-20 19:14:46 +00:00
long int atol ();
1998-10-03 05:39:55 +00:00
# ifndef VMS
long int lseek ();
1998-10-03 05:39:55 +00:00
# endif
1993-04-12 20:51:32 +00:00
1998-10-03 05:39:55 +00:00
#endif /* Not GNU C library or POSIX. */
1992-01-20 19:14:46 +00:00
1998-10-03 05:39:55 +00:00
#ifdef HAVE_GETCWD
2000-01-22 05:43:03 +00:00
# if !defined(VMS) && !defined(__DECC)
char *getcwd ();
# endif
1992-01-20 19:14:46 +00:00
#else
char *getwd ();
1998-10-03 05:39:55 +00:00
# define getcwd(buf, len) getwd (buf)
1992-06-11 05:30:34 +00:00
#endif
1992-01-20 19:14:46 +00:00
#if !HAVE_STRCASECMP
# if HAVE_STRICMP
# define strcasecmp stricmp
# elif HAVE_STRCMPI
# define strcasecmp strcmpi
# else
/* Create our own, in misc.c */
2010-07-20 13:12:06 +00:00
int strcasecmp (const char *s1, const char *s2);
# endif
#endif
#if !HAVE_STRNCASECMP
# if HAVE_STRNICMP
# define strncasecmp strnicmp
# elif HAVE_STRNCMPI
# define strncasecmp strncmpi
# else
/* Create our own, in misc.c */
2010-07-20 13:12:06 +00:00
int strncasecmp (const char *s1, const char *s2, int n);
# endif
#endif
1998-10-03 05:39:55 +00:00
extern const struct floc *reading_file;
extern const struct floc **expanding_var;
1992-01-20 19:14:46 +00:00
1998-10-03 05:39:55 +00:00
extern char **environ;
1992-01-20 19:14:46 +00:00
extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag;
extern int print_data_base_flag, question_flag, touch_flag, always_make_flag;
extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag;
extern int print_version_flag, print_directory_flag, check_symlink_flag;
extern int warn_undefined_variables_flag, trace_flag, posix_pedantic;
extern int not_parallel, second_expansion, clock_skew_detected;
extern int rebuilding_makefiles, one_shell;
1992-01-20 19:14:46 +00:00
1998-07-30 20:54:47 +00:00
/* can we run commands via 'sh -c xxx' or must we use batch files? */
extern int batch_mode_shell;
/* Resetting the command script introduction prefix character. */
#define RECIPEPREFIX_NAME ".RECIPEPREFIX"
#define RECIPEPREFIX_DEFAULT '\t'
extern char cmd_prefix;
1992-01-20 19:14:46 +00:00
extern unsigned int job_slots;
extern int job_fds[2];
extern int 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 NO_FLOAT
1992-01-20 19:14:46 +00:00
extern double max_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
extern int max_load_average;
#endif
1992-01-20 19:14:46 +00:00
extern char *program;
1993-02-04 18:23:27 +00:00
extern char *starting_directory;
1992-01-20 19:14:46 +00:00
extern unsigned int makelevel;
extern char *version_string, *remote_description, *make_host;
1993-02-04 18:23:27 +00:00
1993-01-25 23:30:16 +00:00
extern unsigned int commands_started;
1992-01-20 19:14:46 +00:00
1993-05-06 21:30:40 +00:00
extern int handling_fatal_signal;
1992-01-20 19:14:46 +00:00
1998-10-03 05:39:55 +00:00
#ifndef MIN
#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
#endif
#ifndef MAX
#define MAX(_a,_b) ((_a)>(_b)?(_a):(_b))
#endif
#ifdef VMS
2000-06-23 19:43:11 +00:00
# define MAKE_SUCCESS 1
# define MAKE_TROUBLE 2
# define MAKE_FAILURE 3
#else
2000-06-23 19:43:11 +00:00
# define MAKE_SUCCESS 0
# define MAKE_TROUBLE 1
# define MAKE_FAILURE 2
#endif
/* Set up heap debugging library dmalloc. */
#ifdef HAVE_DMALLOC_H
#include <dmalloc.h>
#endif
#ifndef initialize_main
# ifdef __EMX__
# define initialize_main(pargc, pargv) \
{ _wildcard(pargc, pargv); _response(pargc, pargv); }
# else
# define initialize_main(pargc, pargv)
# endif
#endif
#ifdef __EMX__
# if !defined chdir
# define chdir _chdir2
# endif
# if !defined getcwd
# define getcwd _getcwd2
# endif
/* NO_CHDIR2 causes make not to use _chdir2() and _getcwd2() instead of
chdir() and getcwd(). This avoids some error messages for the
make testsuite but restricts the drive letter support. */
# ifdef NO_CHDIR2
# warning NO_CHDIR2: usage of drive letters restricted
# undef chdir
# undef getcwd
# endif
#endif
#ifndef initialize_main
# define initialize_main(pargc, pargv)
#endif
/* Some systems (like Solaris, PTX, etc.) do not support the SA_RESTART flag
properly according to POSIX. So, we try to wrap common system calls with
checks for EINTR. Note that there are still plenty of system calls that
can fail with EINTR but this, reportedly, gets the vast majority of
failure cases. If you still experience failures you'll need to either get
a system where SA_RESTART works, or you need to avoid -j. */
#define EINTRLOOP(_v,_c) while (((_v)=_c)==-1 && errno==EINTR)
2003-03-25 02:46:42 +00:00
/* While system calls that return integers are pretty consistent about
returning -1 on failure and setting errno in that case, functions that
return pointers are not always so well behaved. Sometimes they return
NULL for expected behavior: one good example is readdir() which returns
NULL at the end of the directory--and _doesn't_ reset errno. So, we have
to do it ourselves here. */
#define ENULLLOOP(_v,_c) do { errno = 0; (_v) = _c; } \
while((_v)==0 && errno==EINTR)