1994-03-23 22:53:21 +08:00
|
|
|
|
/* Miscellaneous global declarations and portability cruft for GNU Make.
|
2019-05-19 23:57:14 +08:00
|
|
|
|
Copyright (C) 1988-2019 Free Software Foundation, Inc.
|
1992-01-21 03:14:46 +08:00
|
|
|
|
This file is part of GNU Make.
|
|
|
|
|
|
2006-02-12 03:02:21 +08:00
|
|
|
|
GNU Make is free software; you can redistribute it and/or modify it under the
|
|
|
|
|
terms of the GNU General Public License as published by the Free Software
|
2007-07-05 03:35:15 +08:00
|
|
|
|
Foundation; either version 3 of the License, or (at your option) any later
|
|
|
|
|
version.
|
1992-01-21 03:14:46 +08:00
|
|
|
|
|
2006-02-12 03:02:21 +08:00
|
|
|
|
GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
1992-01-21 03:14:46 +08:00
|
|
|
|
|
2006-02-12 03:02:21 +08:00
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
2007-07-05 03:35:15 +08:00
|
|
|
|
this program. If not, see <http://www.gnu.org/licenses/>. */
|
1992-01-21 03:14:46 +08:00
|
|
|
|
|
1993-08-13 05:19:12 +08: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
|
2013-01-21 00:01:01 +08:00
|
|
|
|
(which it would do because makeint.h was found in $srcdir). */
|
1993-08-13 05:19:12 +08:00
|
|
|
|
#include <config.h>
|
1998-10-03 13:39:55 +08:00
|
|
|
|
#undef HAVE_CONFIG_H
|
|
|
|
|
#define HAVE_CONFIG_H 1
|
1992-12-21 06:57:06 +08:00
|
|
|
|
|
2009-10-04 04:08:20 +08:00
|
|
|
|
/* Specify we want GNU source code. This must be defined before any
|
|
|
|
|
system headers are included. */
|
|
|
|
|
|
|
|
|
|
#define _GNU_SOURCE 1
|
|
|
|
|
|
2002-05-10 11:15:07 +08:00
|
|
|
|
/* AIX requires this to be the first thing in the file. */
|
2009-10-04 04:08:20 +08:00
|
|
|
|
#if HAVE_ALLOCA_H
|
|
|
|
|
# include <alloca.h>
|
|
|
|
|
#else
|
|
|
|
|
# ifdef _AIX
|
2002-05-10 11:15:07 +08:00
|
|
|
|
#pragma alloca
|
2009-10-04 04:08:20 +08:00
|
|
|
|
# else
|
2010-07-19 15:10:53 +08:00
|
|
|
|
# if !defined(__GNUC__) && !defined(WINDOWS32)
|
2010-07-13 01:16:54 +08:00
|
|
|
|
# ifndef alloca /* predefined by HP cc +Olibcalls */
|
2002-05-10 11:15:07 +08:00
|
|
|
|
char *alloca ();
|
2010-07-13 01:16:54 +08:00
|
|
|
|
# endif
|
2002-05-10 11:15:07 +08:00
|
|
|
|
# endif
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-02-21 15:30:11 +08:00
|
|
|
|
/* Disable assert() unless we're a maintainer.
|
|
|
|
|
Some asserts are compute-intensive. */
|
|
|
|
|
#ifndef MAKE_MAINTAINER_MODE
|
|
|
|
|
# define NDEBUG 1
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-01-21 02:39:54 +08:00
|
|
|
|
/* Include the externally-visible content.
|
2013-05-03 21:09:12 +08:00
|
|
|
|
Be sure to use the local one, and not one installed on the system.
|
2013-05-07 01:18:58 +08:00
|
|
|
|
Define GMK_BUILDING_MAKE for proper selection of dllexport/dllimport
|
|
|
|
|
declarations for MS-Windows. */
|
2013-05-05 05:38:53 +08:00
|
|
|
|
#ifdef WINDOWS32
|
2013-05-07 01:18:58 +08:00
|
|
|
|
# define GMK_BUILDING_MAKE
|
2013-05-05 05:38:53 +08:00
|
|
|
|
#endif
|
2013-01-21 02:39:54 +08:00
|
|
|
|
#include "gnumake.h"
|
1996-03-20 22:57:41 +08:00
|
|
|
|
|
1998-10-03 13:39:55 +08:00
|
|
|
|
#ifdef CRAY
|
1992-09-03 05:53:59 +08:00
|
|
|
|
/* This must happen before #include <signal.h> so
|
|
|
|
|
that the declaration therein is changed. */
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# define signal bsdsignal
|
1992-09-03 05:53:59 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
1999-07-21 13:53:23 +08:00
|
|
|
|
/* If we're compiling for the dmalloc debugger, turn off string inlining. */
|
|
|
|
|
#if defined(HAVE_DMALLOC_H) && defined(__GNUC__)
|
|
|
|
|
# define __NO_STRING_INLINES
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-05-12 06:35:03 +08:00
|
|
|
|
#include <stddef.h>
|
1992-01-21 03:14:46 +08:00
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <signal.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <ctype.h>
|
2011-02-21 15:30:11 +08:00
|
|
|
|
|
1993-10-28 08:09:14 +08:00
|
|
|
|
#ifdef HAVE_SYS_TIMEB_H
|
2012-03-04 08:24:20 +08:00
|
|
|
|
/* SCO 3.2 "devsys 4.2" has a prototype for 'ftime' in <time.h> that bombs
|
2011-02-21 15:30:11 +08:00
|
|
|
|
unless <sys/timeb.h> has been included first. */
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# include <sys/timeb.h>
|
1993-10-28 08:09:14 +08:00
|
|
|
|
#endif
|
2000-06-07 13:43:37 +08:00
|
|
|
|
#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 08:52:39 +08:00
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
1998-10-03 13:39:55 +08:00
|
|
|
|
#ifndef errno
|
1992-07-01 08:52:39 +08:00
|
|
|
|
extern int errno;
|
|
|
|
|
#endif
|
1992-06-11 13:30:34 +08:00
|
|
|
|
|
2014-09-14 09:20:22 +08:00
|
|
|
|
#ifdef __VMS
|
|
|
|
|
/* In strict ANSI mode, VMS compilers should not be defining the
|
|
|
|
|
VMS macro. Define it here instead of a bulk edit for the correct code.
|
|
|
|
|
*/
|
|
|
|
|
# ifndef VMS
|
|
|
|
|
# define VMS
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
1998-10-03 13:39:55 +08:00
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
|
# include <unistd.h>
|
1994-05-22 04:27:18 +08:00
|
|
|
|
/* Ultrix's unistd.h always defines _POSIX_VERSION, but you only get
|
2012-03-04 08:24:20 +08:00
|
|
|
|
POSIX.1 behavior with 'cc -YPOSIX', which predefines POSIX itself! */
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# if defined (_POSIX_VERSION) && !defined (ultrix) && !defined (VMS)
|
|
|
|
|
# define POSIX 1
|
|
|
|
|
# endif
|
1992-06-11 13:30:34 +08:00
|
|
|
|
#endif
|
1992-01-21 03:14:46 +08:00
|
|
|
|
|
1993-07-09 07:51:22 +08:00
|
|
|
|
/* Some systems define _POSIX_VERSION but are not really POSIX.1. */
|
1996-03-20 22:57:41 +08:00
|
|
|
|
#if (defined (butterfly) || defined (__arm) || (defined (__mips) && defined (_SYSTYPE_SVR3)) || (defined (sequent) && defined (i386)))
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# undef POSIX
|
1993-05-15 04:40:38 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
1993-09-17 12:49:17 +08:00
|
|
|
|
#if !defined (POSIX) && defined (_AIX) && defined (_POSIX_SOURCE)
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# define POSIX 1
|
1993-09-17 12:49:17 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
1998-10-03 13:39:55 +08:00
|
|
|
|
#ifndef RETSIGTYPE
|
|
|
|
|
# define RETSIGTYPE void
|
1992-01-21 03:14:46 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
1998-10-03 13:39:55 +08:00
|
|
|
|
#ifndef sigmask
|
|
|
|
|
# define sigmask(sig) (1 << ((sig) - 1))
|
1992-01-21 03:14:46 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2001-06-01 11:56:50 +08:00
|
|
|
|
#ifndef HAVE_SA_RESTART
|
|
|
|
|
# define SA_RESTART 0
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-03-13 14:12:07 +08:00
|
|
|
|
#ifdef HAVE_VFORK_H
|
|
|
|
|
# include <vfork.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
1998-10-03 13:39:55 +08:00
|
|
|
|
#ifdef HAVE_LIMITS_H
|
|
|
|
|
# include <limits.h>
|
1992-01-21 03:14:46 +08:00
|
|
|
|
#endif
|
1998-10-03 13:39:55 +08:00
|
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
|
|
|
|
# include <sys/param.h>
|
1992-06-11 13:30:34 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
1998-10-03 13:39:55 +08:00
|
|
|
|
#ifndef PATH_MAX
|
|
|
|
|
# ifndef POSIX
|
|
|
|
|
# define PATH_MAX MAXPATHLEN
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
1992-01-21 03:14:46 +08:00
|
|
|
|
#ifndef MAXPATHLEN
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# define MAXPATHLEN 1024
|
|
|
|
|
#endif
|
1992-06-11 13:30:34 +08:00
|
|
|
|
|
1998-10-03 13:39:55 +08:00
|
|
|
|
#ifdef PATH_MAX
|
|
|
|
|
# define GET_PATH_MAX PATH_MAX
|
2016-09-26 07:06:56 +08:00
|
|
|
|
# define PATH_VAR(var) char var[PATH_MAX+1]
|
1992-01-21 03:14:46 +08:00
|
|
|
|
#else
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# define NEED_GET_PATH_MAX 1
|
|
|
|
|
# define GET_PATH_MAX (get_path_max ())
|
2016-09-26 07:06:56 +08:00
|
|
|
|
# define PATH_VAR(var) char *var = alloca (GET_PATH_MAX+1)
|
2006-04-07 09:43:44 +08:00
|
|
|
|
unsigned int get_path_max (void);
|
1992-01-21 03:14:46 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#ifndef CHAR_BIT
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# define CHAR_BIT 8
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2010-11-07 05:56:23 +08:00
|
|
|
|
#ifndef USHRT_MAX
|
|
|
|
|
# define USHRT_MAX 65535
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-11-14 10:26:00 +08:00
|
|
|
|
/* 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 15:21:16 +08: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))
|
|
|
|
|
|
1999-09-01 01:02:31 +08:00
|
|
|
|
#ifndef CHAR_MAX
|
|
|
|
|
# define CHAR_MAX INTEGER_TYPE_MAXIMUM (char)
|
|
|
|
|
#endif
|
|
|
|
|
|
1998-10-03 13:39:55 +08: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-21 03:14:46 +08:00
|
|
|
|
|
1998-10-03 13:39:55 +08:00
|
|
|
|
#ifndef S_ISREG
|
|
|
|
|
# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
|
1992-01-21 03:14:46 +08:00
|
|
|
|
#endif
|
1998-10-03 13:39:55 +08:00
|
|
|
|
#ifndef S_ISDIR
|
|
|
|
|
# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
|
1992-01-21 03:14:46 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
1996-03-20 22:57:41 +08:00
|
|
|
|
#ifdef VMS
|
2013-05-28 01:01:48 +08:00
|
|
|
|
# include <fcntl.h>
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# include <types.h>
|
|
|
|
|
# include <unixlib.h>
|
|
|
|
|
# include <unixio.h>
|
|
|
|
|
# include <perror.h>
|
2002-08-08 08:11:19 +08:00
|
|
|
|
/* Needed to use alloca on VMS. */
|
|
|
|
|
# include <builtins.h>
|
2014-09-14 09:20:22 +08:00
|
|
|
|
|
|
|
|
|
extern int vms_use_mcr_command;
|
|
|
|
|
extern int vms_always_use_cmd_file;
|
2014-11-28 11:28:30 +08:00
|
|
|
|
extern int vms_gnv_shell;
|
|
|
|
|
extern int vms_comma_separator;
|
|
|
|
|
extern int vms_legacy_behavior;
|
|
|
|
|
extern int vms_unix_simulation;
|
1996-03-20 22:57:41 +08:00
|
|
|
|
#endif
|
1992-01-21 03:14:46 +08:00
|
|
|
|
|
1998-10-03 13:39:55 +08: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
|
2012-03-04 08:24:20 +08:00
|
|
|
|
/* The __-protected variants of 'format' and 'printf' attributes
|
1998-10-03 13:39:55 +08:00
|
|
|
|
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-21 03:14:46 +08:00
|
|
|
|
#endif
|
2004-02-24 21:50:19 +08:00
|
|
|
|
#define UNUSED __attribute__ ((unused))
|
1992-01-21 03:14:46 +08:00
|
|
|
|
|
1998-10-03 13:39:55 +08: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
|
2006-04-10 06:09:24 +08:00
|
|
|
|
void *malloc (int);
|
|
|
|
|
void *realloc (void *, int);
|
|
|
|
|
void free (void *);
|
1992-01-21 03:14:46 +08:00
|
|
|
|
|
2006-04-07 09:43:44 +08:00
|
|
|
|
void abort (void) __attribute__ ((noreturn));
|
|
|
|
|
void exit (int) __attribute__ ((noreturn));
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# endif /* HAVE_STDLIB_H. */
|
1992-07-27 06:30:45 +08:00
|
|
|
|
|
1998-10-03 13:39:55 +08:00
|
|
|
|
#endif /* Standard headers. */
|
1992-01-21 03:14:46 +08:00
|
|
|
|
|
2002-05-10 11:15:07 +08:00
|
|
|
|
/* These should be in stdlib.h. Make sure we have them. */
|
|
|
|
|
#ifndef EXIT_SUCCESS
|
|
|
|
|
# define EXIT_SUCCESS 0
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef EXIT_FAILURE
|
2006-04-10 06:09:24 +08:00
|
|
|
|
# define EXIT_FAILURE 1
|
2002-05-10 11:15:07 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2006-04-10 06:09:24 +08:00
|
|
|
|
#ifndef ANSI_STRING
|
1993-04-13 04:51:32 +08:00
|
|
|
|
|
1994-02-05 05:28:53 +08:00
|
|
|
|
/* SCO Xenix has a buggy macro definition in <string.h>. */
|
1998-10-03 13:39:55 +08:00
|
|
|
|
#undef strerror
|
2005-06-27 09:01:07 +08:00
|
|
|
|
#if !defined(__DECC)
|
2006-04-07 09:43:44 +08:00
|
|
|
|
char *strerror (int errnum);
|
1994-02-05 05:28:53 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2005-06-27 09:01:07 +08:00
|
|
|
|
#endif /* !ANSI_STRING. */
|
|
|
|
|
#undef ANSI_STRING
|
|
|
|
|
|
2000-06-13 13:22:52 +08:00
|
|
|
|
#if HAVE_INTTYPES_H
|
|
|
|
|
# include <inttypes.h>
|
1999-10-15 15:00:58 +08:00
|
|
|
|
#endif
|
2012-01-29 04:28:31 +08:00
|
|
|
|
#if HAVE_STDINT_H
|
|
|
|
|
# include <stdint.h>
|
|
|
|
|
#endif
|
2000-06-13 13:22:52 +08:00
|
|
|
|
#define FILE_TIMESTAMP uintmax_t
|
1999-10-15 15:00:58 +08:00
|
|
|
|
|
2002-04-22 07:57:24 +08:00
|
|
|
|
#if !defined(HAVE_STRSIGNAL)
|
2006-04-07 09:43:44 +08:00
|
|
|
|
char *strsignal (int signum);
|
2002-04-22 07:57:24 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2019-08-28 22:45:49 +08:00
|
|
|
|
#if !defined(HAVE_UMASK)
|
2019-09-08 02:52:38 +08:00
|
|
|
|
typedef int mode_t;
|
2019-08-28 22:45:49 +08:00
|
|
|
|
extern mode_t umask (mode_t);
|
2017-02-12 02:42:37 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
1999-08-26 05:39:28 +08: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.
|
2002-08-01 21:16:57 +08:00
|
|
|
|
POSIX 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
|
1999-08-26 05:39:28 +08:00
|
|
|
|
only '0' through '9' are digits. Prefer ISDIGIT to isdigit() unless
|
2012-03-04 08:24:20 +08:00
|
|
|
|
it's important to use the locale's definition of 'digit' even when the
|
2002-08-01 21:16:57 +08:00
|
|
|
|
host does not conform to POSIX. */
|
1999-08-26 05:39:28 +08:00
|
|
|
|
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
|
|
|
|
|
|
2010-07-01 13:59:08 +08:00
|
|
|
|
/* Test if two strings are equal. Is this worthwhile? Should be profiled. */
|
|
|
|
|
#define streq(a, b) \
|
1998-10-03 13:39:55 +08:00
|
|
|
|
((a) == (b) || \
|
|
|
|
|
(*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
|
2010-07-01 13:59:08 +08:00
|
|
|
|
|
|
|
|
|
/* 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) \
|
1999-10-15 15:00:58 +08:00
|
|
|
|
((a) == (b) \
|
|
|
|
|
|| (tolower((unsigned char)*(a)) == tolower((unsigned char)*(b)) \
|
2007-05-09 10:01:53 +08:00
|
|
|
|
&& (*(a) == '\0' || !strcasecmp ((a) + 1, (b) + 1))))
|
1992-01-21 03:14:46 +08:00
|
|
|
|
#else
|
2010-07-01 13:59:08 +08:00
|
|
|
|
# define patheq(a, b) streq(a, b)
|
1992-01-21 03:14:46 +08:00
|
|
|
|
#endif
|
2010-07-01 13:59:08 +08:00
|
|
|
|
|
1999-03-26 15:08:57 +08:00
|
|
|
|
#define strneq(a, b, l) (strncmp ((a), (b), (l)) == 0)
|
1999-03-19 12:27:56 +08:00
|
|
|
|
|
1992-01-21 03:14:46 +08:00
|
|
|
|
#if defined(__GNUC__) || defined(ENUM_BITFIELDS)
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# define ENUM_BITFIELD(bits) :bits
|
1992-01-21 03:14:46 +08:00
|
|
|
|
#else
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# define ENUM_BITFIELD(bits)
|
1992-01-21 03:14:46 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2002-05-10 11:15:07 +08:00
|
|
|
|
/* 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)
|
|
|
|
|
|
2006-10-01 13:38:38 +08:00
|
|
|
|
/* This is needed for getcwd() and chdir(), on some W32 systems. */
|
|
|
|
|
#if defined(HAVE_DIRECT_H)
|
2005-06-26 07:00:17 +08:00
|
|
|
|
# include <direct.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#ifdef WINDOWS32
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# include <fcntl.h>
|
|
|
|
|
# include <malloc.h>
|
2006-04-07 09:43:44 +08:00
|
|
|
|
# define pipe(_p) _pipe((_p), 512, O_BINARY)
|
|
|
|
|
# define kill(_pid,_sig) w32_kill((_pid),(_sig))
|
2014-10-02 01:43:12 +08:00
|
|
|
|
/* MSVC and Watcom C don't have ftruncate. */
|
2014-10-02 01:41:28 +08:00
|
|
|
|
# if defined(_MSC_VER) || defined(__WATCOMC__)
|
2013-05-05 02:03:55 +08:00
|
|
|
|
# define ftruncate(_fd,_len) _chsize(_fd,_len)
|
|
|
|
|
# endif
|
|
|
|
|
/* MinGW64 doesn't have _S_ISDIR. */
|
|
|
|
|
# ifndef _S_ISDIR
|
|
|
|
|
# define _S_ISDIR(m) S_ISDIR(m)
|
|
|
|
|
# endif
|
1996-05-23 05:51:45 +08:00
|
|
|
|
|
2006-04-07 09:43:44 +08:00
|
|
|
|
void sync_Path_environment (void);
|
2010-07-13 01:16:54 +08:00
|
|
|
|
int w32_kill (pid_t pid, int sig);
|
2007-03-20 11:02:26 +08:00
|
|
|
|
int find_and_set_default_shell (const char *token);
|
1998-07-31 04:54:47 +08:00
|
|
|
|
|
|
|
|
|
/* indicates whether or not we have Bourne shell */
|
|
|
|
|
extern int no_default_sh_exe;
|
|
|
|
|
|
|
|
|
|
/* is default_shell unixy? */
|
|
|
|
|
extern int unixy_shell;
|
Support --output-sync on MS-Windows.
w32/compat/posixfcn.c: New file, with emulations of Posix
functions and Posix functionality for MS-Windows.
w32/subproc/sub_proc.c: Include io.h.
(process_noinherit): New function, forces a file descriptor to not
be inherited by child processes.
(process_easy): Accept two additional arguments, and use them to
set up the standard output and standard error handles of the child
process.
w32/include/sub_proc.h (process_easy): Adjust prototype.
(process_noinherit): Add prototype.
read.c [WINDOWS32]: Include windows.h and sub_proc.h.
makeint.h (LOCALEDIR) [WINDOWS32}: Define to NULL if not
defined. This is needed because the MS-Windows build doesn't have
a canonical place for LOCALEDIR.
(WIN32_LEAN_AND_MEAN) [WINDOWS32]: Define, to avoid getting from
windows.h header too much stuff that could conflict with the code.
main.c <sync_mutex>: New static variable.
<switches>: Add support for "--sync-mutex" switch.
(decode_output_sync_flags): Decode the --sync-mutex= switch.
(prepare_mutex_handle_string) [WINDOWS32]: New function.
(main): Add "output-sync" to .FEATURES.
job.h (CLOSE_ON_EXEC) [WINDOWS32]: Define to call
process_noinherit.
(F_GETFD, F_SETLKW, F_WRLCK, F_UNLCK, struct flock) [WINDOWS32]:
New macros.
(RECORD_SYNC_MUTEX): New macro, a no-op for Posix platforms.
(sync_handle_t): New typedef.
job.c <sync_handle>: Change type to sync_handle_t.
(FD_NOT_EMPTY): Seek to the file's end. Suggested by Frank
Heckenbach <f.heckenbach@fh-soft.de>.
(pump_from_tmp_fd) [WINDOWS32]: Switch to_fd to binary mode for
the duration of this function, and then change back before
returning.
(start_job_command) [WINDOWS32]: Support output_sync mode on
MS-Windows. Use a system-wide mutex instead of locking
stdout/stderr. Call process_easy with two additional arguments:
child->outfd and child->errfd.
(exec_command) [WINDOWS32]: Pass two additional arguments, both
-1, to process_easy, to adjust for the changed function signature.
function.c (windows32_openpipe) [WINDOWS32]: This function now
returns an int, which is -1 if it fails and zero otherwise. It
also calls 'error' instead of 'fatal', to avoid exiting
prematurely.
(func_shell_base) [WINDOWS32]: Call perror_with_name if
windows32_openpipe fails, now that it always returns. This avoids
a compiler warning that error_prefix is not used in the MS-Windows
build.
config.h.W32.template (OUTPUT_SYNC): Define.
build_w32.bat: Add w32/compat/posixfcn.c to compilation and
linking commands.
From Frank Heckenbach <f.heckenbach@fh-soft.de>:
job.c (sync_output): Don't discard the output if
acquire_semaphore fails; instead, dump the output unsynchronized.
2013-04-27 19:20:49 +08:00
|
|
|
|
|
|
|
|
|
/* We don't have a preferred fixed value for LOCALEDIR. */
|
|
|
|
|
# ifndef LOCALEDIR
|
|
|
|
|
# define LOCALEDIR NULL
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
/* Include only the minimal stuff from windows.h. */
|
2016-03-21 12:36:55 +08:00
|
|
|
|
# define WIN32_LEAN_AND_MEAN
|
1998-07-31 04:54:47 +08:00
|
|
|
|
#endif /* WINDOWS32 */
|
1998-10-03 13:39:55 +08:00
|
|
|
|
|
2013-06-22 12:22:08 +08:00
|
|
|
|
#define ANY_SET(_v,_m) (((_v)&(_m)) != 0)
|
|
|
|
|
#define NONE_SET(_v,_m) (! ANY_SET ((_v),(_m)))
|
|
|
|
|
|
|
|
|
|
#define MAP_NUL 0x0001
|
|
|
|
|
#define MAP_BLANK 0x0002
|
2016-03-21 12:36:55 +08:00
|
|
|
|
#define MAP_NEWLINE 0x0004
|
2013-06-22 12:22:08 +08:00
|
|
|
|
#define MAP_COMMENT 0x0008
|
|
|
|
|
#define MAP_SEMI 0x0010
|
|
|
|
|
#define MAP_EQUALS 0x0020
|
|
|
|
|
#define MAP_COLON 0x0040
|
2017-08-11 19:44:32 +08:00
|
|
|
|
#define MAP_VARSEP 0x0080
|
2013-06-22 12:22:08 +08:00
|
|
|
|
#define MAP_PIPE 0x0100
|
|
|
|
|
#define MAP_DOT 0x0200
|
|
|
|
|
#define MAP_COMMA 0x0400
|
|
|
|
|
|
2013-10-06 04:10:30 +08:00
|
|
|
|
/* These are the valid characters for a user-defined function. */
|
|
|
|
|
#define MAP_USERFUNC 0x2000
|
2013-06-22 12:22:08 +08:00
|
|
|
|
/* This means not only a '$', but skip the variable reference. */
|
|
|
|
|
#define MAP_VARIABLE 0x4000
|
2014-02-03 06:28:46 +08:00
|
|
|
|
/* The set of characters which are directory separators is OS-specific. */
|
|
|
|
|
#define MAP_DIRSEP 0x8000
|
2013-06-22 12:22:08 +08:00
|
|
|
|
|
|
|
|
|
#ifdef VMS
|
|
|
|
|
# define MAP_VMSCOMMA MAP_COMMA
|
|
|
|
|
#else
|
|
|
|
|
# define MAP_VMSCOMMA 0x0000
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-03-21 12:36:55 +08:00
|
|
|
|
#define MAP_SPACE (MAP_BLANK|MAP_NEWLINE)
|
|
|
|
|
|
|
|
|
|
/* 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 ';'
|
|
|
|
|
# define MAP_PATHSEP MAP_SEMI
|
|
|
|
|
#elif !defined(PATH_SEPARATOR_CHAR)
|
|
|
|
|
# if defined (VMS)
|
|
|
|
|
# define PATH_SEPARATOR_CHAR (vms_comma_separator ? ',' : ':')
|
|
|
|
|
# define MAP_PATHSEP (vms_comma_separator ? MAP_COMMA : MAP_SEMI)
|
|
|
|
|
# else
|
|
|
|
|
# define PATH_SEPARATOR_CHAR ':'
|
|
|
|
|
# define MAP_PATHSEP MAP_COLON
|
|
|
|
|
# endif
|
|
|
|
|
#elif PATH_SEPARATOR_CHAR == ':'
|
|
|
|
|
# define MAP_PATHSEP MAP_COLON
|
|
|
|
|
#elif PATH_SEPARATOR_CHAR == ';'
|
|
|
|
|
# define MAP_PATHSEP MAP_SEMI
|
|
|
|
|
#elif PATH_SEPARATOR_CHAR == ','
|
|
|
|
|
# define MAP_PATHSEP MAP_COMMA
|
|
|
|
|
#else
|
|
|
|
|
# error "Unknown PATH_SEPARATOR_CHAR"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define STOP_SET(_v,_m) ANY_SET(stopchar_map[(unsigned char)(_v)],(_m))
|
|
|
|
|
|
|
|
|
|
#define ISBLANK(c) STOP_SET((c),MAP_BLANK)
|
|
|
|
|
#define ISSPACE(c) STOP_SET((c),MAP_SPACE)
|
|
|
|
|
#define NEXT_TOKEN(s) while (ISSPACE (*(s))) ++(s)
|
|
|
|
|
#define END_OF_TOKEN(s) while (! STOP_SET (*(s), MAP_SPACE|MAP_NUL)) ++(s)
|
2013-06-22 12:22:08 +08:00
|
|
|
|
|
2019-09-03 11:03:27 +08:00
|
|
|
|
/* We can't run setrlimit when using posix_spawn. */
|
|
|
|
|
#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) && !defined(USE_POSIX_SPAWN)
|
2009-06-08 01:40:06 +08:00
|
|
|
|
# define SET_STACK_SIZE
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef SET_STACK_SIZE
|
|
|
|
|
# include <sys/resource.h>
|
2011-05-02 20:29:09 +08:00
|
|
|
|
extern struct rlimit stack_limit;
|
2009-06-08 01:40:06 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2016-05-02 03:52:58 +08:00
|
|
|
|
#include <glob.h>
|
|
|
|
|
|
2016-05-02 07:24:20 +08:00
|
|
|
|
#define NILF ((floc *)0)
|
1998-10-03 13:39:55 +08:00
|
|
|
|
|
2013-11-24 11:23:52 +08:00
|
|
|
|
#define CSTRLEN(_s) (sizeof (_s)-1)
|
2012-03-04 16:58:44 +08:00
|
|
|
|
#define STRING_SIZE_TUPLE(_s) (_s), CSTRLEN(_s)
|
2002-07-08 10:26:47 +08:00
|
|
|
|
|
2013-11-24 11:23:52 +08:00
|
|
|
|
/* The number of bytes needed to represent the largest integer as a string. */
|
|
|
|
|
#define INTSTR_LENGTH CSTRLEN ("18446744073709551616")
|
|
|
|
|
|
2014-10-20 13:54:56 +08:00
|
|
|
|
#define DEFAULT_TTYNAME "true"
|
2014-09-14 13:03:19 +08:00
|
|
|
|
#ifdef HAVE_TTYNAME
|
|
|
|
|
# define TTYNAME(_f) ttyname (_f)
|
|
|
|
|
#else
|
2014-10-20 13:54:56 +08:00
|
|
|
|
# define TTYNAME(_f) DEFAULT_TTYNAME
|
2014-09-14 13:03:19 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
1994-07-26 07:27:48 +08:00
|
|
|
|
|
2016-05-02 07:24:20 +08:00
|
|
|
|
|
|
|
|
|
/* Specify the location of elements read from makefiles. */
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
const char *filenm;
|
|
|
|
|
unsigned long lineno;
|
|
|
|
|
unsigned long offset;
|
|
|
|
|
} floc;
|
|
|
|
|
|
2009-09-17 01:07:01 +08:00
|
|
|
|
const char *concat (unsigned int, ...);
|
2013-11-24 11:23:52 +08:00
|
|
|
|
void message (int prefix, size_t length, const char *fmt, ...)
|
|
|
|
|
__attribute__ ((__format__ (__printf__, 3, 4)));
|
2016-05-02 07:24:20 +08:00
|
|
|
|
void error (const floc *flocp, size_t length, const char *fmt, ...)
|
2013-11-24 11:23:52 +08:00
|
|
|
|
__attribute__ ((__format__ (__printf__, 3, 4)));
|
2016-05-02 07:24:20 +08:00
|
|
|
|
void fatal (const floc *flocp, size_t length, const char *fmt, ...)
|
|
|
|
|
__attribute__ ((noreturn, __format__ (__printf__, 3, 4)));
|
2017-01-03 04:46:30 +08:00
|
|
|
|
void out_of_memory () __attribute__((noreturn));
|
2013-11-24 11:23:52 +08:00
|
|
|
|
|
2016-12-18 02:16:22 +08:00
|
|
|
|
/* When adding macros to this list be sure to update the value of
|
|
|
|
|
XGETTEXT_OPTIONS in the po/Makevars file. */
|
2013-11-24 11:23:52 +08:00
|
|
|
|
#define O(_t,_a,_f) _t((_a), 0, (_f))
|
|
|
|
|
#define OS(_t,_a,_f,_s) _t((_a), strlen (_s), (_f), (_s))
|
|
|
|
|
#define OSS(_t,_a,_f,_s1,_s2) _t((_a), strlen (_s1) + strlen (_s2), \
|
|
|
|
|
(_f), (_s1), (_s2))
|
|
|
|
|
#define OSSS(_t,_a,_f,_s1,_s2,_s3) _t((_a), strlen (_s1) + strlen (_s2) + strlen (_s3), \
|
|
|
|
|
(_f), (_s1), (_s2), (_s3))
|
|
|
|
|
#define ON(_t,_a,_f,_n) _t((_a), INTSTR_LENGTH, (_f), (_n))
|
|
|
|
|
#define ONN(_t,_a,_f,_n1,_n2) _t((_a), INTSTR_LENGTH*2, (_f), (_n1), (_n2))
|
|
|
|
|
|
|
|
|
|
#define OSN(_t,_a,_f,_s,_n) _t((_a), strlen (_s) + INTSTR_LENGTH, \
|
|
|
|
|
(_f), (_s), (_n))
|
|
|
|
|
#define ONS(_t,_a,_f,_n,_s) _t((_a), INTSTR_LENGTH + strlen (_s), \
|
|
|
|
|
(_f), (_n), (_s))
|
|
|
|
|
|
2006-04-07 09:43:44 +08:00
|
|
|
|
void die (int) __attribute__ ((noreturn));
|
|
|
|
|
void pfatal_with_name (const char *) __attribute__ ((noreturn));
|
|
|
|
|
void perror_with_name (const char *, const char *);
|
2013-09-12 16:07:52 +08:00
|
|
|
|
#define xstrlen(_s) ((_s)==NULL ? 0 : strlen (_s))
|
2018-07-02 08:00:53 +08:00
|
|
|
|
void *xmalloc (size_t);
|
|
|
|
|
void *xcalloc (size_t);
|
|
|
|
|
void *xrealloc (void *, size_t);
|
2006-04-07 09:43:44 +08:00
|
|
|
|
char *xstrdup (const char *);
|
2018-07-02 08:00:53 +08:00
|
|
|
|
char *xstrndup (const char *, size_t);
|
|
|
|
|
char *find_next_token (const char **, size_t *);
|
2006-04-07 09:43:44 +08:00
|
|
|
|
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 *);
|
2007-03-20 11:02:26 +08:00
|
|
|
|
const char *find_percent_cached (const char **);
|
2017-02-12 02:42:37 +08:00
|
|
|
|
FILE *get_tmpfile (char **, const char *);
|
2018-09-16 13:04:10 +08:00
|
|
|
|
ssize_t writebuf (int, const void*, size_t);
|
|
|
|
|
ssize_t readbuf (int, void*, size_t);
|
1998-10-03 13:39:55 +08:00
|
|
|
|
|
|
|
|
|
#ifndef NO_ARCHIVES
|
2006-11-19 04:53:44 +08:00
|
|
|
|
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,
|
2013-01-21 02:39:54 +08:00
|
|
|
|
long int hdrpos, long int datapos,
|
|
|
|
|
long int size, long int date, int uid,
|
2016-05-02 03:52:58 +08:00
|
|
|
|
int gid, unsigned int mode,
|
|
|
|
|
const void *arg);
|
2006-11-19 04:53:44 +08:00
|
|
|
|
|
|
|
|
|
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 13:39:55 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2006-11-19 04:53:44 +08:00
|
|
|
|
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 *);
|
2016-05-02 03:52:58 +08:00
|
|
|
|
void print_dir_data_base (void);
|
|
|
|
|
void dir_setup_glob (glob_t *);
|
2006-04-07 09:43:44 +08:00
|
|
|
|
void hash_init_directories (void);
|
1998-10-03 13:39:55 +08:00
|
|
|
|
|
2006-04-07 09:43:44 +08:00
|
|
|
|
void define_default_variables (void);
|
2013-05-13 16:29:35 +08:00
|
|
|
|
void undefine_default_variables (void);
|
2006-04-07 09:43:44 +08:00
|
|
|
|
void set_default_suffixes (void);
|
|
|
|
|
void install_default_suffix_rules (void);
|
|
|
|
|
void install_default_implicit_rules (void);
|
1998-10-03 13:39:55 +08:00
|
|
|
|
|
2006-04-07 09:43:44 +08:00
|
|
|
|
void build_vpath_lists (void);
|
|
|
|
|
void construct_vpath_list (char *pattern, char *dirpath);
|
2009-11-13 00:42:36 +08:00
|
|
|
|
const char *vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr,
|
|
|
|
|
unsigned int* vpath_index, unsigned int* path_index);
|
2018-07-02 08:00:53 +08:00
|
|
|
|
int gpath_search (const char *file, size_t len);
|
1998-10-03 13:39:55 +08:00
|
|
|
|
|
2007-03-20 11:02:26 +08:00
|
|
|
|
void construct_include_path (const char **arg_dirs);
|
1998-10-03 13:39:55 +08:00
|
|
|
|
|
2006-04-07 09:43:44 +08:00
|
|
|
|
void user_access (void);
|
|
|
|
|
void make_access (void);
|
|
|
|
|
void child_access (void);
|
1998-10-03 13:39:55 +08:00
|
|
|
|
|
2006-04-07 09:43:44 +08:00
|
|
|
|
char *strip_whitespace (const char **begpp, const char **endpp);
|
2005-02-28 05:40:23 +08:00
|
|
|
|
|
2016-05-02 03:52:58 +08:00
|
|
|
|
void show_goal_error (void);
|
2016-04-11 05:22:57 +08:00
|
|
|
|
|
2006-02-10 13:29:00 +08:00
|
|
|
|
/* String caching */
|
2006-04-07 09:43:44 +08:00
|
|
|
|
void strcache_init (void);
|
|
|
|
|
void strcache_print_stats (const char *prefix);
|
|
|
|
|
int strcache_iscached (const char *str);
|
|
|
|
|
const char *strcache_add (const char *str);
|
2018-07-02 08:00:53 +08:00
|
|
|
|
const char *strcache_add_len (const char *str, size_t len);
|
2005-02-28 05:40:23 +08:00
|
|
|
|
|
2012-01-16 06:41:53 +08:00
|
|
|
|
/* Guile support */
|
2016-05-02 07:24:20 +08:00
|
|
|
|
int guile_gmake_setup (const floc *flocp);
|
2012-01-16 06:41:53 +08:00
|
|
|
|
|
2013-01-20 13:55:57 +08:00
|
|
|
|
/* Loadable object support. Sets to the strcached name of the loaded file. */
|
2016-05-02 07:24:20 +08:00
|
|
|
|
typedef int (*load_func_t)(const floc *flocp);
|
|
|
|
|
int load_file (const floc *flocp, const char **filename, int noerror);
|
2013-05-17 13:20:39 +08:00
|
|
|
|
void unload_file (const char *name);
|
2012-01-16 06:41:53 +08:00
|
|
|
|
|
2019-08-26 05:11:10 +08:00
|
|
|
|
/* Maintainer mode support */
|
|
|
|
|
#ifdef MAKE_MAINTAINER_MODE
|
|
|
|
|
# define SPIN(_s) spin (_s)
|
|
|
|
|
void spin (const char* suffix);
|
|
|
|
|
#else
|
|
|
|
|
# define SPIN(_s)
|
|
|
|
|
#endif
|
|
|
|
|
|
1994-05-24 06:25:30 +08:00
|
|
|
|
/* We omit these declarations on non-POSIX systems which define _POSIX_VERSION,
|
1997-08-19 02:11:04 +08:00
|
|
|
|
because such systems often declare them in header files anyway. */
|
1994-05-24 06:25:30 +08:00
|
|
|
|
|
1997-04-07 15:21:16 +08:00
|
|
|
|
#if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION) && !defined(WINDOWS32)
|
1992-01-21 03:14:46 +08:00
|
|
|
|
|
2006-04-07 09:43:44 +08:00
|
|
|
|
long int atol ();
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# ifndef VMS
|
2006-04-07 09:43:44 +08:00
|
|
|
|
long int lseek ();
|
1998-10-03 13:39:55 +08:00
|
|
|
|
# endif
|
1993-04-13 04:51:32 +08:00
|
|
|
|
|
2016-05-02 03:52:58 +08:00
|
|
|
|
# ifdef HAVE_GETCWD
|
|
|
|
|
# if !defined(VMS) && !defined(__DECC)
|
2006-04-07 09:43:44 +08:00
|
|
|
|
char *getcwd ();
|
2016-05-02 03:52:58 +08:00
|
|
|
|
# endif
|
|
|
|
|
# else
|
2006-04-07 09:43:44 +08:00
|
|
|
|
char *getwd ();
|
2016-05-02 03:52:58 +08:00
|
|
|
|
# define getcwd(buf, len) getwd (buf)
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
#endif /* Not GNU C library or POSIX. */
|
1992-01-21 03:14:46 +08:00
|
|
|
|
|
2007-05-09 10:01:53 +08: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 21:12:06 +08:00
|
|
|
|
int strcasecmp (const char *s1, const char *s2);
|
2010-07-19 15:10:53 +08:00
|
|
|
|
# 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 21:12:06 +08:00
|
|
|
|
int strncasecmp (const char *s1, const char *s2, int n);
|
2007-05-09 10:01:53 +08:00
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-05-06 08:19:00 +08:00
|
|
|
|
#define OUTPUT_SYNC_NONE 0
|
|
|
|
|
#define OUTPUT_SYNC_LINE 1
|
|
|
|
|
#define OUTPUT_SYNC_TARGET 2
|
|
|
|
|
#define OUTPUT_SYNC_RECURSE 3
|
2013-04-15 03:38:07 +08:00
|
|
|
|
|
2016-05-02 03:52:58 +08:00
|
|
|
|
/* Non-GNU systems may not declare this in unistd.h. */
|
|
|
|
|
extern char **environ;
|
|
|
|
|
|
2016-05-02 07:24:20 +08:00
|
|
|
|
extern const floc *reading_file;
|
|
|
|
|
extern const floc **expanding_var;
|
1992-01-21 03:14:46 +08:00
|
|
|
|
|
2013-06-22 12:22:08 +08:00
|
|
|
|
extern unsigned short stopchar_map[];
|
|
|
|
|
|
2019-05-13 05:01:55 +08:00
|
|
|
|
extern int just_print_flag, run_silent, ignore_errors_flag, keep_going_flag;
|
2002-08-08 08:11:19 +08:00
|
|
|
|
extern int print_data_base_flag, question_flag, touch_flag, always_make_flag;
|
1999-07-08 14:49:52 +08:00
|
|
|
|
extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag;
|
2005-02-28 15:48:22 +08:00
|
|
|
|
extern int print_version_flag, print_directory_flag, check_symlink_flag;
|
2010-08-30 07:05:26 +08:00
|
|
|
|
extern int warn_undefined_variables_flag, trace_flag, posix_pedantic;
|
|
|
|
|
extern int not_parallel, second_expansion, clock_skew_detected;
|
2013-06-22 11:59:38 +08:00
|
|
|
|
extern int rebuilding_makefiles, one_shell, output_sync, verify_flag;
|
1992-01-21 03:14:46 +08:00
|
|
|
|
|
2016-05-02 03:52:58 +08:00
|
|
|
|
extern const char *default_shell;
|
|
|
|
|
|
1998-07-31 04:54:47 +08:00
|
|
|
|
/* can we run commands via 'sh -c xxx' or must we use batch files? */
|
|
|
|
|
extern int batch_mode_shell;
|
|
|
|
|
|
2007-11-05 05:54:00 +08:00
|
|
|
|
/* Resetting the command script introduction prefix character. */
|
|
|
|
|
#define RECIPEPREFIX_NAME ".RECIPEPREFIX"
|
|
|
|
|
#define RECIPEPREFIX_DEFAULT '\t'
|
2006-11-19 04:53:44 +08:00
|
|
|
|
extern char cmd_prefix;
|
|
|
|
|
|
1992-01-21 03:14:46 +08:00
|
|
|
|
extern unsigned int job_slots;
|
|
|
|
|
extern double max_load_average;
|
|
|
|
|
|
2014-04-26 05:10:47 +08:00
|
|
|
|
extern const char *program;
|
2014-09-01 01:11:08 +08:00
|
|
|
|
|
|
|
|
|
#ifdef VMS
|
2014-09-14 09:20:22 +08:00
|
|
|
|
const char *vms_command (const char *argv0);
|
|
|
|
|
const char *vms_progname (const char *argv0);
|
|
|
|
|
|
|
|
|
|
void vms_exit (int);
|
|
|
|
|
# define _exit(foo) vms_exit(foo)
|
|
|
|
|
# define exit(foo) vms_exit(foo)
|
|
|
|
|
|
|
|
|
|
extern char *program_name;
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
set_program_name (const char *arv0);
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
need_vms_symbol (void);
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
create_foreign_command (const char *command, const char *image);
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
vms_export_dcl_symbol (const char *name, const char *value);
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
vms_putenv_symbol (const char *string);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
vms_restore_symbol (const char *string);
|
|
|
|
|
|
2014-09-01 01:11:08 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2016-05-02 03:52:58 +08:00
|
|
|
|
void remote_setup (void);
|
|
|
|
|
void remote_cleanup (void);
|
|
|
|
|
int start_remote_job_p (int);
|
2018-07-09 13:31:25 +08:00
|
|
|
|
int start_remote_job (char **, char **, int, int *, pid_t *, int *);
|
2016-05-02 03:52:58 +08:00
|
|
|
|
int remote_status (int *, int *, int *, int);
|
|
|
|
|
void block_remote_children (void);
|
|
|
|
|
void unblock_remote_children (void);
|
2018-07-02 08:00:53 +08:00
|
|
|
|
int remote_kill (pid_t id, int sig);
|
2016-05-02 03:52:58 +08:00
|
|
|
|
void print_variable_data_base (void);
|
|
|
|
|
void print_vpath_data_base (void);
|
|
|
|
|
|
1993-02-05 02:23:27 +08:00
|
|
|
|
extern char *starting_directory;
|
1992-01-21 03:14:46 +08:00
|
|
|
|
extern unsigned int makelevel;
|
2003-11-04 06:04:09 +08:00
|
|
|
|
extern char *version_string, *remote_description, *make_host;
|
1993-02-05 02:23:27 +08:00
|
|
|
|
|
1993-01-26 07:30:16 +08:00
|
|
|
|
extern unsigned int commands_started;
|
1992-01-21 03:14:46 +08:00
|
|
|
|
|
1993-05-07 05:30:40 +08:00
|
|
|
|
extern int handling_fatal_signal;
|
|
|
|
|
|
1998-10-03 13:39:55 +08:00
|
|
|
|
#ifndef MIN
|
|
|
|
|
#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef MAX
|
|
|
|
|
#define MAX(_a,_b) ((_a)>(_b)?(_a):(_b))
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-09-14 09:20:22 +08:00
|
|
|
|
#define MAKE_SUCCESS 0
|
|
|
|
|
#define MAKE_TROUBLE 1
|
|
|
|
|
#define MAKE_FAILURE 2
|
1999-07-21 13:53:23 +08:00
|
|
|
|
|
|
|
|
|
/* Set up heap debugging library dmalloc. */
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_DMALLOC_H
|
|
|
|
|
#include <dmalloc.h>
|
|
|
|
|
#endif
|
2002-09-10 15:27:28 +08:00
|
|
|
|
|
2003-03-25 07:14:15 +08:00
|
|
|
|
#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
|
|
|
|
|
|
2002-09-10 15:27:28 +08:00
|
|
|
|
|
2003-01-30 13:22:52 +08:00
|
|
|
|
/* 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. */
|
2002-09-10 15:27:28 +08:00
|
|
|
|
|
2003-01-30 13:22:52 +08:00
|
|
|
|
#define EINTRLOOP(_v,_c) while (((_v)=_c)==-1 && errno==EINTR)
|
2002-09-10 15:27:28 +08:00
|
|
|
|
|
2003-03-25 10:46:42 +08: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. */
|
|
|
|
|
|
2007-03-20 11:02:26 +08:00
|
|
|
|
#define ENULLLOOP(_v,_c) do { errno = 0; (_v) = _c; } \
|
|
|
|
|
while((_v)==0 && errno==EINTR)
|