1 /* Miscellaneous global declarations and portability cruft for GNU Make.
2 Copyright (C) 1988-2022 Free Software Foundation, Inc.
3 This file is part of GNU Make.
5 GNU Make is free software; you can redistribute it and/or modify it under the
6 terms of the GNU General Public License as published by the Free Software
7 Foundation; either version 3 of the License, or (at your option) any later
10 GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License along with
15 this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* We use <config.h> instead of "config.h" so that a compilation
18 using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
19 (which it would do because makeint.h was found in $srcdir). */
22 #define HAVE_CONFIG_H 1
24 /* Specify we want GNU source code. This must be defined before any
25 system headers are included. */
29 /* AIX requires this to be the first thing in the file. */
36 # if !defined(__GNUC__) && !defined(WINDOWS32)
37 # ifndef alloca /* predefined by HP cc +Olibcalls */
44 /* Some versions of GCC (e.g., 10.x) set the warn_unused_result attribute on
45 __builtin_alloca. This causes alloca(0) to fail and is not easily worked
46 around so avoid it via the preprocessor.
47 See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98055 */
49 #if defined (__has_builtin)
50 # if __has_builtin (__builtin_alloca)
51 # define free_alloca()
53 # define free_alloca() alloca (0)
56 # define free_alloca() alloca (0)
59 /* Disable assert() unless we're a maintainer.
60 Some asserts are compute-intensive. */
61 #ifndef MAKE_MAINTAINER_MODE
65 /* Include the externally-visible content.
66 Be sure to use the local one, and not one installed on the system.
67 Define GMK_BUILDING_MAKE for proper selection of dllexport/dllimport
68 declarations for MS-Windows. */
70 # define GMK_BUILDING_MAKE
75 /* This must happen before #include <signal.h> so
76 that the declaration therein is changed. */
77 # define signal bsdsignal
80 /* If we're compiling for the dmalloc debugger, turn off string inlining. */
81 #if defined(HAVE_DMALLOC_H) && defined(__GNUC__)
82 # define __NO_STRING_INLINES
86 #include <sys/types.h>
92 #ifdef HAVE_SYS_TIMEB_H
93 /* SCO 3.2 "devsys 4.2" has a prototype for 'ftime' in <time.h> that bombs
94 unless <sys/timeb.h> has been included first. */
95 # include <sys/timeb.h>
98 # include <sys/time.h>
109 /* In strict ANSI mode, VMS compilers should not be defining the
110 VMS macro. Define it here instead of a bulk edit for the correct code.
119 /* Ultrix's unistd.h always defines _POSIX_VERSION, but you only get
120 POSIX.1 behavior with 'cc -YPOSIX', which predefines POSIX itself! */
121 # if defined (_POSIX_VERSION) && !defined (ultrix) && !defined (VMS)
126 /* Some systems define _POSIX_VERSION but are not really POSIX.1. */
127 #if (defined (butterfly) || (defined (__mips) && defined (_SYSTYPE_SVR3)) || (defined (sequent) && defined (i386)))
131 #if !defined (POSIX) && defined (_AIX) && defined (_POSIX_SOURCE)
136 # define sigmask(sig) (1 << ((sig) - 1))
139 #ifndef HAVE_SA_RESTART
140 # define SA_RESTART 0
150 #ifdef HAVE_SYS_PARAM_H
151 # include <sys/param.h>
156 # define PATH_MAX MAXPATHLEN
158 /* Some systems (HURD) have fully dynamic pathnames with no maximum.
159 Ideally we'd support this but it will take some work. */
160 # define PATH_MAX 4096
165 # define GET_PATH_MAX PATH_MAX
166 # define PATH_VAR(var) char var[PATH_MAX+1]
168 # define NEED_GET_PATH_MAX 1
169 # define GET_PATH_MAX (get_path_max ())
170 # define PATH_VAR(var) char *var = alloca (GET_PATH_MAX+1)
171 unsigned int get_path_max (void);
179 # define USHRT_MAX 65535
182 /* Nonzero if the integer type T is signed.
183 Use <= to avoid GCC warnings about always-false expressions. */
184 #define INTEGER_TYPE_SIGNED(t) ((t) -1 <= 0)
186 /* The minimum and maximum values for the integer type T.
187 Use ~ (t) 0, not -1, for portability to 1's complement hosts. */
188 #define INTEGER_TYPE_MINIMUM(t) \
189 (! INTEGER_TYPE_SIGNED (t) ? (t) 0 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))
190 #define INTEGER_TYPE_MAXIMUM(t) (~ (t) 0 - INTEGER_TYPE_MINIMUM (t))
193 # define CHAR_MAX INTEGER_TYPE_MAXIMUM (char)
196 #ifdef STAT_MACROS_BROKEN
203 #endif /* STAT_MACROS_BROKEN. */
206 # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
209 # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
215 # include <unixlib.h>
218 /* Needed to use alloca on VMS. */
219 # include <builtins.h>
221 extern int vms_use_mcr_command;
222 extern int vms_always_use_cmd_file;
223 extern int vms_gnv_shell;
224 extern int vms_comma_separator;
225 extern int vms_legacy_behavior;
226 extern int vms_unix_simulation;
229 #if !defined(__attribute__) && (__GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__)
230 /* Don't use __attribute__ if it's not supported. */
231 # define ATTRIBUTE(x)
233 # define ATTRIBUTE(x) __attribute__ (x)
236 /* The __-protected variants of 'format' and 'printf' attributes
237 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
238 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
239 # define __format__ format
240 # define __printf__ printf
243 #define UNUSED ATTRIBUTE ((unused))
244 #define NORETURN ATTRIBUTE ((noreturn))
246 #if defined (STDC_HEADERS) || defined (__GNU_LIBRARY__)
249 # define ANSI_STRING 1
250 #else /* No standard headers. */
251 # ifdef HAVE_STRING_H
253 # define ANSI_STRING 1
255 # include <strings.h>
257 # ifdef HAVE_MEMORY_H
260 # ifdef HAVE_STDLIB_H
264 void *realloc (void *, int);
267 void abort (void) NORETURN;
268 void exit (int) NORETURN;
269 # endif /* HAVE_STDLIB_H. */
271 #endif /* Standard headers. */
273 /* These should be in stdlib.h. Make sure we have them. */
275 # define EXIT_SUCCESS 0
278 # define EXIT_FAILURE 1
283 /* SCO Xenix has a buggy macro definition in <string.h>. */
286 char *strerror (int errnum);
289 #endif /* !ANSI_STRING. */
293 # include <inttypes.h>
299 #if defined _MSC_VER || defined __MINGW32__
300 # define MK_PRI64_PREFIX "I64"
302 # define MK_PRI64_PREFIX "ll"
305 # define PRIdMAX MK_PRI64_PREFIX "d"
308 # define PRIuMAX MK_PRI64_PREFIX "u"
311 # define SCNdMAX PRIdMAX
313 #define FILE_TIMESTAMP uintmax_t
315 #if !defined(HAVE_STRSIGNAL)
316 char *strsignal (int signum);
319 #if !defined(HAVE_UMASK)
321 extern mode_t umask (mode_t);
324 /* ISDIGIT offers the following features:
325 - Its arg may be any int or unsigned int; it need not be an unsigned char.
326 - It's guaranteed to evaluate its argument exactly once.
327 NOTE! Make relies on this behavior, don't change it!
328 - It's typically faster.
329 POSIX 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
330 only '0' through '9' are digits. Prefer ISDIGIT to isdigit() unless
331 it's important to use the locale's definition of 'digit' even when the
332 host does not conform to POSIX. */
333 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
335 /* Test if two strings are equal. Is this worthwhile? Should be profiled. */
336 #define streq(a, b) \
338 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
340 /* Test if two strings are equal, but match case-insensitively on systems
341 which have case-insensitive filesystems. Should only be used for
343 #ifdef HAVE_CASE_INSENSITIVE_FS
344 # define patheq(a, b) \
346 || (tolower((unsigned char)*(a)) == tolower((unsigned char)*(b)) \
347 && (*(a) == '\0' || !strcasecmp ((a) + 1, (b) + 1))))
349 # define patheq(a, b) streq(a, b)
352 #define strneq(a, b, l) (strncmp ((a), (b), (l)) == 0)
354 #if defined(ENUM_BITFIELDS) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
355 # define ENUM_BITFIELD(bits) :bits
357 # define ENUM_BITFIELD(bits)
360 /* Handle gettext and locales. */
365 # define setlocale(category, locale)
370 #define _(msgid) gettext (msgid)
371 #define N_(msgid) gettext_noop (msgid)
372 #define S_(msg1,msg2,num) ngettext (msg1,msg2,num)
374 /* This is needed for getcwd() and chdir(), on some W32 systems. */
375 #if defined(HAVE_DIRECT_H)
382 # define pipe(_p) _pipe((_p), 512, O_BINARY)
383 # define kill(_pid,_sig) w32_kill((_pid),(_sig))
384 /* MSVC and Watcom C don't have ftruncate. */
385 # if defined(_MSC_VER) || defined(__WATCOMC__)
386 # define ftruncate(_fd,_len) _chsize(_fd,_len)
388 /* MinGW64 doesn't have _S_ISDIR. */
390 # define _S_ISDIR(m) S_ISDIR(m)
393 void sync_Path_environment (void);
394 int w32_kill (pid_t pid, int sig);
395 int find_and_set_default_shell (const char *token);
397 /* indicates whether or not we have Bourne shell */
398 extern int no_default_sh_exe;
400 /* is default_shell unixy? */
401 extern int unixy_shell;
403 /* We don't have a preferred fixed value for LOCALEDIR. */
405 # define LOCALEDIR NULL
408 /* Include only the minimal stuff from windows.h. */
409 # define WIN32_LEAN_AND_MEAN
410 #endif /* WINDOWS32 */
412 /* ALL_SET() evaluates the second argument twice. */
413 #define ANY_SET(_v,_m) (((_v)&(_m)) != 0)
414 #define NONE_SET(_v,_m) (! ANY_SET ((_v),(_m)))
415 #define ALL_SET(_v,_m) (((_v)&(_m)) == (_m))
417 #define MAP_NUL 0x0001
418 #define MAP_BLANK 0x0002 /* space, TAB */
419 #define MAP_NEWLINE 0x0004
420 #define MAP_COMMENT 0x0008
421 #define MAP_SEMI 0x0010
422 #define MAP_EQUALS 0x0020
423 #define MAP_COLON 0x0040
424 #define MAP_VARSEP 0x0080
425 #define MAP_PIPE 0x0100
426 #define MAP_DOT 0x0200
427 #define MAP_COMMA 0x0400
429 /* These are the valid characters for a user-defined function. */
430 #define MAP_USERFUNC 0x2000
431 /* This means not only a '$', but skip the variable reference. */
432 #define MAP_VARIABLE 0x4000
433 /* The set of characters which are directory separators is OS-specific. */
434 #define MAP_DIRSEP 0x8000
437 # define MAP_VMSCOMMA MAP_COMMA
439 # define MAP_VMSCOMMA 0x0000
442 #define MAP_SPACE (MAP_BLANK|MAP_NEWLINE)
445 To overcome an issue parsing paths in a DOS/Windows environment when
446 built in a unix based environment, override the PATH_SEPARATOR_CHAR
447 definition unless being built for Cygwin. */
448 #if defined(HAVE_DOS_PATHS) && !defined(__CYGWIN__)
449 # undef PATH_SEPARATOR_CHAR
450 # define PATH_SEPARATOR_CHAR ';'
451 # define MAP_PATHSEP MAP_SEMI
452 #elif !defined(PATH_SEPARATOR_CHAR)
454 # define PATH_SEPARATOR_CHAR (vms_comma_separator ? ',' : ':')
455 # define MAP_PATHSEP (vms_comma_separator ? MAP_COMMA : MAP_SEMI)
457 # define PATH_SEPARATOR_CHAR ':'
458 # define MAP_PATHSEP MAP_COLON
460 #elif PATH_SEPARATOR_CHAR == ':'
461 # define MAP_PATHSEP MAP_COLON
462 #elif PATH_SEPARATOR_CHAR == ';'
463 # define MAP_PATHSEP MAP_SEMI
464 #elif PATH_SEPARATOR_CHAR == ','
465 # define MAP_PATHSEP MAP_COMMA
467 # error "Unknown PATH_SEPARATOR_CHAR"
470 #define STOP_SET(_v,_m) ANY_SET(stopchar_map[(unsigned char)(_v)],(_m))
472 /* True if C is a directory separator on the current system. */
473 #define ISDIRSEP(c) STOP_SET((c),MAP_DIRSEP)
474 /* True if C is whitespace but not newline. */
475 #define ISBLANK(c) STOP_SET((c),MAP_BLANK)
476 /* True if C is whitespace including newlines. */
477 #define ISSPACE(c) STOP_SET((c),MAP_SPACE)
478 /* True if C is nul or whitespace (including newline). */
479 #define END_OF_TOKEN(c) STOP_SET((c),MAP_SPACE|MAP_NUL)
480 /* Move S past all whitespace (including newlines). */
481 #define NEXT_TOKEN(s) while (ISSPACE (*(s))) ++(s)
483 /* We can't run setrlimit when using posix_spawn. */
484 #if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) && !defined(USE_POSIX_SPAWN)
485 # define SET_STACK_SIZE
487 #ifdef SET_STACK_SIZE
488 # include <sys/resource.h>
489 extern struct rlimit stack_limit;
494 #define NILF ((floc *)0)
496 /* Number of characters in a string constant. Does NOT include the \0 byte. */
497 #define CSTRLEN(_s) (sizeof (_s)-1)
499 /* Only usable when NOT calling a macro: only use it for local functions. */
500 #define STRING_SIZE_TUPLE(_s) (_s), CSTRLEN(_s)
502 /* The number of bytes needed to represent the largest signed and unsigned
503 integers as a string.
504 Does NOT include space for \0 so be sure to add it if needed.
505 Math suggested by Edward Welbourne <edward.welbourne@qt.io> */
506 #define INTSTR_LENGTH (53 * sizeof(uintmax_t) / 22 + 3)
508 #define DEFAULT_TTYNAME "true"
510 # define TTYNAME(_f) ttyname (_f)
512 # define TTYNAME(_f) DEFAULT_TTYNAME
516 # define DEFAULT_TMPDIR "/sys$scratch/"
517 #elif defined(P_tmpdir)
518 # define DEFAULT_TMPDIR P_tmpdir
520 # define DEFAULT_TMPDIR "/tmp"
528 /* Specify the location of elements read from makefiles. */
532 unsigned long lineno;
533 unsigned long offset;
536 const char *concat (unsigned int, ...);
537 void message (int prefix, size_t length, const char *fmt, ...)
538 ATTRIBUTE ((__format__ (__printf__, 3, 4)));
539 void error (const floc *flocp, size_t length, const char *fmt, ...)
540 ATTRIBUTE ((__format__ (__printf__, 3, 4)));
541 void fatal (const floc *flocp, size_t length, const char *fmt, ...)
542 ATTRIBUTE ((noreturn, __format__ (__printf__, 3, 4)));
543 void out_of_memory (void) NORETURN;
545 /* When adding macros to this list be sure to update the value of
546 XGETTEXT_OPTIONS in the po/Makevars file. */
547 #define O(_t,_a,_f) _t((_a), 0, (_f))
548 #define OS(_t,_a,_f,_s) _t((_a), strlen (_s), (_f), (_s))
549 #define OSS(_t,_a,_f,_s1,_s2) _t((_a), strlen (_s1) + strlen (_s2), \
551 #define OSSS(_t,_a,_f,_s1,_s2,_s3) _t((_a), strlen (_s1) + strlen (_s2) + strlen (_s3), \
552 (_f), (_s1), (_s2), (_s3))
553 #define ON(_t,_a,_f,_n) _t((_a), INTSTR_LENGTH, (_f), (_n))
554 #define ONN(_t,_a,_f,_n1,_n2) _t((_a), INTSTR_LENGTH*2, (_f), (_n1), (_n2))
556 #define OSN(_t,_a,_f,_s,_n) _t((_a), strlen (_s) + INTSTR_LENGTH, \
558 #define ONS(_t,_a,_f,_n,_s) _t((_a), INTSTR_LENGTH + strlen (_s), \
561 void decode_env_switches (const char*, size_t line);
562 void temp_stdin_unlink (void);
563 void die (int) NORETURN;
564 void pfatal_with_name (const char *) NORETURN;
565 void perror_with_name (const char *, const char *);
566 #define xstrlen(_s) ((_s)==NULL ? 0 : strlen (_s))
567 unsigned int make_toui (const char*, const char**);
568 char *make_lltoa (long long, char *);
569 char *make_ulltoa (unsigned long long, char *);
570 void make_seed (unsigned int);
571 unsigned int make_rand (void);
572 pid_t make_pid (void);
573 void *xmalloc (size_t);
574 void *xcalloc (size_t);
575 void *xrealloc (void *, size_t);
576 char *xstrdup (const char *);
577 char *xstrndup (const char *, size_t);
578 char *find_next_token (const char **, size_t *);
579 char *next_token (const char *);
580 char *end_of_token (const char *);
581 void collapse_continuations (char *);
582 char *lindex (const char *, const char *, int);
583 int alpha_compare (const void *, const void *);
584 void print_spaces (unsigned int);
585 char *find_percent (char *);
586 const char *find_percent_cached (const char **);
587 const char *get_tmpdir (void);
588 int get_tmpfd (char **);
589 FILE *get_tmpfile (char **);
590 ssize_t writebuf (int, const void *, size_t);
591 ssize_t readbuf (int, void *, size_t);
594 void *memrchr(const void *, int, size_t);
598 int ar_name (const char *);
599 void ar_parse_name (const char *, char **, char **);
600 int ar_touch (const char *);
601 time_t ar_member_date (const char *);
603 typedef intmax_t (*ar_member_func_t) (int desc, const char *mem, int truncated,
604 long int hdrpos, long int datapos,
605 long int size, intmax_t date, int uid,
606 int gid, unsigned int mode,
609 intmax_t ar_scan (const char *archive, ar_member_func_t function,
611 int ar_name_equal (const char *name, const char *mem, int truncated);
613 int ar_member_touch (const char *arname, const char *memname);
617 int dir_file_exists_p (const char *, const char *);
618 int file_exists_p (const char *);
619 int file_impossible_p (const char *);
620 void file_impossible (const char *);
621 const char *dir_name (const char *);
622 void print_dir_data_base (void);
623 void dir_setup_glob (glob_t *);
624 void hash_init_directories (void);
626 void define_default_variables (void);
627 void undefine_default_variables (void);
628 void set_default_suffixes (void);
629 void install_default_suffix_rules (void);
630 void install_default_implicit_rules (void);
632 void build_vpath_lists (void);
633 void construct_vpath_list (char *pattern, char *dirpath);
634 const char *vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr,
635 unsigned int* vpath_index, unsigned int* path_index);
636 int gpath_search (const char *file, size_t len);
638 void construct_include_path (const char **arg_dirs);
640 char *strip_whitespace (const char **begpp, const char **endpp);
642 void show_goal_error (void);
645 void strcache_init (void);
646 void strcache_print_stats (const char *prefix);
647 int strcache_iscached (const char *str);
648 const char *strcache_add (const char *str);
649 const char *strcache_add_len (const char *str, size_t len);
652 int guile_gmake_setup (const floc *flocp);
654 /* Loadable object support. Sets to the strcached name of the loaded file. */
655 typedef int (*load_func_t)(const floc *flocp);
656 int load_file (const floc *flocp, struct file *file, int noerror);
657 int unload_file (const char *name);
659 /* Maintainer mode support */
660 #ifdef MAKE_MAINTAINER_MODE
661 # define SPIN(_s) spin (_s)
662 void spin (const char* suffix);
663 # define DBG(_f) dbg _f
664 void dbg (const char *fmt, ...);
667 /* Never put this code into Git or a release. */
668 # define DBG(_f) compile-error
671 /* We omit these declarations on non-POSIX systems which define _POSIX_VERSION,
672 because such systems often declare them in header files anyway. */
674 #if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION) && !defined(WINDOWS32)
681 # if !defined(VMS) && !defined(__DECC)
686 # define getcwd(buf, len) getwd (buf)
689 #endif /* Not GNU C library or POSIX. */
693 # define strcasecmp stricmp
695 # define strcasecmp strcmpi
697 /* Create our own, in misc.c */
698 int strcasecmp (const char *s1, const char *s2);
702 #if !HAVE_STRNCASECMP
704 # define strncasecmp strnicmp
706 # define strncasecmp strncmpi
708 /* Create our own, in misc.c */
709 int strncasecmp (const char *s1, const char *s2, size_t n);
714 /* Create our own, in misc.c */
715 void *mempcpy (void *dest, const void *src, size_t n);
719 /* Create our own, in misc.c */
720 char *stpcpy (char *dest, const char *src);
723 #define OUTPUT_SYNC_NONE 0
724 #define OUTPUT_SYNC_LINE 1
725 #define OUTPUT_SYNC_TARGET 2
726 #define OUTPUT_SYNC_RECURSE 3
728 /* Non-GNU systems may not declare this in unistd.h. */
729 extern char **environ;
731 extern const floc *reading_file;
732 extern const floc **expanding_var;
734 extern unsigned short stopchar_map[];
736 extern int just_print_flag, run_silent, ignore_errors_flag, keep_going_flag;
737 extern int print_data_base_flag, question_flag, touch_flag, always_make_flag;
738 extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag;
739 extern int print_version_flag, print_directory, check_symlink_flag;
740 extern int warn_undefined_variables_flag, posix_pedantic;
741 extern int not_parallel, second_expansion, clock_skew_detected;
742 extern int rebuilding_makefiles, one_shell, output_sync, verify_flag;
743 extern unsigned long command_count;
745 extern const char *default_shell;
747 /* can we run commands via 'sh -c xxx' or must we use batch files? */
748 extern int batch_mode_shell;
750 #define GNUMAKEFLAGS_NAME "GNUMAKEFLAGS"
751 #define MAKEFLAGS_NAME "MAKEFLAGS"
753 /* Resetting the command script introduction prefix character. */
754 #define RECIPEPREFIX_NAME ".RECIPEPREFIX"
755 #define RECIPEPREFIX_DEFAULT '\t'
756 extern char cmd_prefix;
758 #define JOBSERVER_AUTH_OPT "jobserver-auth"
760 extern char *jobserver_auth;
761 extern unsigned int job_slots;
762 extern double max_load_average;
764 extern const char *program;
767 const char *vms_command (const char *argv0);
768 const char *vms_progname (const char *argv0);
771 # define _exit(foo) vms_exit(foo)
772 # define exit(foo) vms_exit(foo)
774 extern char *program_name;
777 set_program_name (const char *arv0);
780 need_vms_symbol (void);
783 create_foreign_command (const char *command, const char *image);
786 vms_export_dcl_symbol (const char *name, const char *value);
789 vms_putenv_symbol (const char *string);
792 vms_restore_symbol (const char *string);
796 void remote_setup (void);
797 void remote_cleanup (void);
798 int start_remote_job_p (int);
799 int start_remote_job (char **, char **, int, int *, pid_t *, int *);
800 int remote_status (int *, int *, int *, int);
801 void block_remote_children (void);
802 void unblock_remote_children (void);
803 int remote_kill (pid_t id, int sig);
804 void print_variable_data_base (void);
805 void print_vpath_data_base (void);
807 extern char *starting_directory;
808 extern unsigned int makelevel;
809 extern char *version_string, *remote_description, *make_host;
811 extern unsigned int commands_started;
813 extern volatile sig_atomic_t handling_fatal_signal;
816 #define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
819 #define MAX(_a,_b) ((_a)>(_b)?(_a):(_b))
822 #define MAKE_SUCCESS 0
823 #define MAKE_TROUBLE 1
824 #define MAKE_FAILURE 2
826 /* Set up heap debugging library dmalloc. */
828 #ifdef HAVE_DMALLOC_H
832 #ifndef initialize_main
834 # define initialize_main(pargc, pargv) \
835 { _wildcard(pargc, pargv); _response(pargc, pargv); }
837 # define initialize_main(pargc, pargv)
843 # define chdir _chdir2
846 # define getcwd _getcwd2
849 /* NO_CHDIR2 causes make not to use _chdir2() and _getcwd2() instead of
850 chdir() and getcwd(). This avoids some error messages for the
851 make testsuite but restricts the drive letter support. */
853 # warning NO_CHDIR2: usage of drive letters restricted
859 #ifndef initialize_main
860 # define initialize_main(pargc, pargv)
864 /* Some systems (like Solaris, PTX, etc.) do not support the SA_RESTART flag
865 properly according to POSIX. So, we try to wrap common system calls with
866 checks for EINTR. Note that there are still plenty of system calls that
867 can fail with EINTR but this, reportedly, gets the vast majority of
868 failure cases. If you still experience failures you'll need to either get
869 a system where SA_RESTART works, or you need to avoid -j. */
871 #define EINTRLOOP(_v,_c) while (((_v)=_c)==-1 && errno==EINTR)
873 /* While system calls that return integers are pretty consistent about
874 returning -1 on failure and setting errno in that case, functions that
875 return pointers are not always so well behaved. Sometimes they return
876 NULL for expected behavior: one good example is readdir() which returns
877 NULL at the end of the directory--and _doesn't_ reset errno. So, we have
878 to do it ourselves here. */
880 #define ENULLLOOP(_v,_c) do { errno = 0; (_v) = _c; } \
881 while((_v)==0 && errno==EINTR)