| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#ifndef MAKE_H |
| 23 |
#define MAKE_H |
| 24 |
|
| 25 |
#include <config.h> |
| 26 |
#undef HAVE_CONFIG_H |
| 27 |
#define HAVE_CONFIG_H 1 |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
#define _GNU_SOURCE 1 |
| 33 |
|
| 34 |
|
| 35 |
#if HAVE_ALLOCA_H |
| 36 |
# include <alloca.h> |
| 37 |
#else |
| 38 |
# ifdef _AIX |
| 39 |
#pragma alloca |
| 40 |
# else |
| 41 |
# if !defined(__GNUC__) && !defined(WINDOWS32) |
| 42 |
# ifndef alloca |
| 43 |
char *alloca (); |
| 44 |
# endif |
| 45 |
# endif |
| 46 |
# endif |
| 47 |
#endif |
| 48 |
|
| 49 |
|
| 50 |
#ifdef CRAY |
| 51 |
|
| 52 |
|
| 53 |
# define signal bsdsignal |
| 54 |
#endif |
| 55 |
|
| 56 |
|
| 57 |
#if defined(HAVE_DMALLOC_H) && defined(__GNUC__) |
| 58 |
# define __NO_STRING_INLINES |
| 59 |
#endif |
| 60 |
|
| 61 |
#include <sys/types.h> |
| 62 |
#include <sys/stat.h> |
| 63 |
#include <signal.h> |
| 64 |
#include <stdio.h> |
| 65 |
#include <ctype.h> |
| 66 |
#ifdef HAVE_SYS_TIMEB_H |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
# include <sys/timeb.h> |
| 71 |
#endif |
| 72 |
|
| 73 |
#if TIME_WITH_SYS_TIME |
| 74 |
# include <sys/time.h> |
| 75 |
# include <time.h> |
| 76 |
#else |
| 77 |
# if HAVE_SYS_TIME_H |
| 78 |
# include <sys/time.h> |
| 79 |
# else |
| 80 |
# include <time.h> |
| 81 |
# endif |
| 82 |
#endif |
| 83 |
|
| 84 |
#include <errno.h> |
| 85 |
|
| 86 |
#ifndef errno |
| 87 |
extern int errno; |
| 88 |
#endif |
| 89 |
|
| 90 |
#ifndef isblank |
| 91 |
# define isblank(c) ((c) == ' ' || (c) == '\t') |
| 92 |
#endif |
| 93 |
|
| 94 |
#ifdef HAVE_UNISTD_H |
| 95 |
# include <unistd.h> |
| 96 |
|
| 97 |
|
| 98 |
# if defined (_POSIX_VERSION) && !defined (ultrix) && !defined (VMS) |
| 99 |
# define POSIX 1 |
| 100 |
# endif |
| 101 |
#endif |
| 102 |
|
| 103 |
|
| 104 |
#if (defined (butterfly) || defined (__arm) || (defined (__mips) && defined (_SYSTYPE_SVR3)) || (defined (sequent) && defined (i386))) |
| 105 |
# undef POSIX |
| 106 |
#endif |
| 107 |
|
| 108 |
#if !defined (POSIX) && defined (_AIX) && defined (_POSIX_SOURCE) |
| 109 |
# define POSIX 1 |
| 110 |
#endif |
| 111 |
|
| 112 |
#ifndef RETSIGTYPE |
| 113 |
# define RETSIGTYPE void |
| 114 |
#endif |
| 115 |
|
| 116 |
#ifndef sigmask |
| 117 |
# define sigmask(sig) (1 << ((sig) - 1)) |
| 118 |
#endif |
| 119 |
|
| 120 |
#ifndef HAVE_SA_RESTART |
| 121 |
# define SA_RESTART 0 |
| 122 |
#endif |
| 123 |
|
| 124 |
#ifdef HAVE_LIMITS_H |
| 125 |
# include <limits.h> |
| 126 |
#endif |
| 127 |
#ifdef HAVE_SYS_PARAM_H |
| 128 |
# include <sys/param.h> |
| 129 |
#endif |
| 130 |
|
| 131 |
#ifndef PATH_MAX |
| 132 |
# ifndef POSIX |
| 133 |
# define PATH_MAX MAXPATHLEN |
| 134 |
# endif |
| 135 |
#endif |
| 136 |
#ifndef MAXPATHLEN |
| 137 |
# define MAXPATHLEN 1024 |
| 138 |
#endif |
| 139 |
|
| 140 |
#ifdef PATH_MAX |
| 141 |
# define GET_PATH_MAX PATH_MAX |
| 142 |
|
| 143 |
#else |
| 144 |
# define NEED_GET_PATH_MAX 1 |
| 145 |
# define GET_PATH_MAX (get_path_max ()) |
| 146 |
|
| 147 |
unsigned int get_path_max (void); |
| 148 |
#endif |
| 149 |
|
| 150 |
#ifndef CHAR_BIT |
| 151 |
# define CHAR_BIT 8 |
| 152 |
#endif |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
#define INTEGER_TYPE_MINIMUM(t) \ |
| 157 |
(! INTEGER_TYPE_SIGNED (t) ? (t) 0 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)) |
| 158 |
#define INTEGER_TYPE_MAXIMUM(t) (~ (t) 0 - INTEGER_TYPE_MINIMUM (t)) |
| 159 |
|
| 160 |
#ifndef CHAR_MAX |
| 161 |
# define CHAR_MAX INTEGER_TYPE_MAXIMUM (char) |
| 162 |
#endif |
| 163 |
|
| 164 |
#ifdef STAT_MACROS_BROKEN |
| 165 |
# ifdef S_ISREG |
| 166 |
# undef S_ISREG |
| 167 |
# endif |
| 168 |
# ifdef S_ISDIR |
| 169 |
# undef S_ISDIR |
| 170 |
# endif |
| 171 |
#endif |
| 172 |
|
| 173 |
#ifndef S_ISREG |
| 174 |
# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) |
| 175 |
#endif |
| 176 |
#ifndef S_ISDIR |
| 177 |
# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) |
| 178 |
#endif |
| 179 |
|
| 180 |
#ifndef __attribute__ |
| 181 |
|
| 182 |
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ |
| 183 |
# define __attribute__(x) |
| 184 |
# endif |
| 185 |
|
| 186 |
|
| 187 |
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) |
| 188 |
# define __format__ format |
| 189 |
# define __printf__ printf |
| 190 |
# endif |
| 191 |
#endif |
| 192 |
|
| 193 |
|
| 194 |
#if defined (STDC_HEADERS) || defined (__GNU_LIBRARY__) |
| 195 |
# include <stdlib.h> |
| 196 |
# include <string.h> |
| 197 |
# define ANSI_STRING 1 |
| 198 |
#else |
| 199 |
# ifdef HAVE_STRING_H |
| 200 |
# include <string.h> |
| 201 |
# define ANSI_STRING 1 |
| 202 |
# else |
| 203 |
# include <strings.h> |
| 204 |
# endif |
| 205 |
# ifdef HAVE_MEMORY_H |
| 206 |
# include <memory.h> |
| 207 |
# endif |
| 208 |
# ifdef HAVE_STDLIB_H |
| 209 |
# include <stdlib.h> |
| 210 |
# else |
| 211 |
void *malloc (int); |
| 212 |
void *realloc (void *, int); |
| 213 |
void free (void *); |
| 214 |
|
| 215 |
void abort (void) __attribute__ ((noreturn)); |
| 216 |
void exit (int) __attribute__ ((noreturn)); |
| 217 |
# endif |
| 218 |
|
| 219 |
#endif |
| 220 |
|
| 221 |
|
| 222 |
#ifndef EXIT_SUCCESS |
| 223 |
# define EXIT_SUCCESS 0 |
| 224 |
#endif |
| 225 |
#ifndef EXIT_FAILURE |
| 226 |
# define EXIT_FAILURE 1 |
| 227 |
#endif |
| 228 |
|
| 229 |
#ifndef ANSI_STRING |
| 230 |
|
| 231 |
|
| 232 |
#undef strerror |
| 233 |
#if !defined(__DECC) |
| 234 |
char *strerror (int errnum); |
| 235 |
#endif |
| 236 |
|
| 237 |
#endif |
| 238 |
#undef ANSI_STRING |
| 239 |
|
| 240 |
#if HAVE_INTTYPES_H |
| 241 |
# include <inttypes.h> |
| 242 |
#endif |
| 243 |
#define FILE_TIMESTAMP uintmax_t |
| 244 |
|
| 245 |
#if !defined(HAVE_STRSIGNAL) |
| 246 |
char *strsignal (int signum); |
| 247 |
#endif |
| 248 |
|
| 249 |
|
| 250 |
#define streq(a, b) \ |
| 251 |
((a) == (b) || \ |
| 252 |
(*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1)))) |
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
#ifdef HAVE_CASE_INSENSITIVE_FS |
| 258 |
# define patheq(a, b) \ |
| 259 |
((a) == (b) \ |
| 260 |
|| (tolower((unsigned char)*(a)) == tolower((unsigned char)*(b)) \ |
| 261 |
&& (*(a) == '\0' || !strcasecmp ((a) + 1, (b) + 1)))) |
| 262 |
#else |
| 263 |
# define patheq(a, b) streq(a, b) |
| 264 |
#endif |
| 265 |
|
| 266 |
#define strneq(a, b, l) (strncmp ((a), (b), (l)) == 0) |
| 267 |
|
| 268 |
#if defined(__GNUC__) || defined(ENUM_BITFIELDS) |
| 269 |
# define ENUM_BITFIELD(bits) :bits |
| 270 |
#else |
| 271 |
# define ENUM_BITFIELD(bits) |
| 272 |
#endif |
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
#if HAVE_LOCALE_H |
| 277 |
# include <locale.h> |
| 278 |
#else |
| 279 |
# define setlocale(category, locale) |
| 280 |
#endif |
| 281 |
|
| 282 |
#include <gettext.h> |
| 283 |
|
| 284 |
#define _(msgid) gettext (msgid) |
| 285 |
#define N_(msgid) gettext_noop (msgid) |
| 286 |
#define S_(msg1,msg2,num) ngettext (msg1,msg2,num) |
| 287 |
|
| 288 |
|
| 289 |
#ifndef PATH_SEPARATOR_CHAR |
| 290 |
# if defined(HAVE_DOS_PATHS) |
| 291 |
# define PATH_SEPARATOR_CHAR ';' |
| 292 |
# elif defined(VMS) |
| 293 |
# define PATH_SEPARATOR_CHAR ',' |
| 294 |
# else |
| 295 |
# define PATH_SEPARATOR_CHAR ':' |
| 296 |
# endif |
| 297 |
#endif |
| 298 |
|
| 299 |
|
| 300 |
#if defined(HAVE_DIRECT_H) |
| 301 |
# include <direct.h> |
| 302 |
#endif |
| 303 |
|
| 304 |
#ifdef WINDOWS32 |
| 305 |
# include <fcntl.h> |
| 306 |
# include <malloc.h> |
| 307 |
# define pipe(_p) _pipe((_p), 512, O_BINARY) |
| 308 |
# define kill(_pid,_sig) w32_kill((_pid),(_sig)) |
| 309 |
|
| 310 |
void sync_Path_environment (void); |
| 311 |
int w32_kill (pid_t pid, int sig); |
| 312 |
char *end_of_token_w32 (const char *s, char stopchar); |
| 313 |
int find_and_set_default_shell (const char *token); |
| 314 |
|
| 315 |
|
| 316 |
extern int no_default_sh_exe; |
| 317 |
|
| 318 |
|
| 319 |
extern int unixy_shell; |
| 320 |
#endif |
| 321 |
|
| 322 |
#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) |
| 323 |
# define SET_STACK_SIZE |
| 324 |
#endif |
| 325 |
#ifdef SET_STACK_SIZE |
| 326 |
# include <sys/resource.h> |
| 327 |
extern struct rlimit stack_limit; |
| 328 |
#endif |
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
#if HAVE_STDARG_H || HAVE_VARARGS_H |
| 334 |
# if HAVE_VPRINTF || HAVE_DOPRNT |
| 335 |
# define USE_VARIADIC 1 |
| 336 |
# endif |
| 337 |
#endif |
| 338 |
|
| 339 |
void die (int); |
| 340 |
void pfatal_with_name (const char *); |
| 341 |
void perror_with_name (const char *, const char *); |
| 342 |
void *xmalloc (size_t); |
| 343 |
void *xcalloc (size_t); |
| 344 |
void *xrealloc (void *, size_t); |
| 345 |
char *xstrdup (const char *); |
| 346 |
char *xstrndup (const char *, size_t); |
| 347 |
|
| 348 |
char *next_token (const char *); |
| 349 |
char *end_of_token (const char *); |
| 350 |
void collapse_continuations (char *); |
| 351 |
char *lindex (const char *, const char *, int); |
| 352 |
int alpha_compare (const void *, const void *); |
| 353 |
void print_spaces (unsigned int); |
| 354 |
char *find_percent (char *); |
| 355 |
const char *find_percent_cached (const char **); |
| 356 |
FILE *open_tmpfile (char **, const char *); |
| 357 |
|
| 358 |
#ifndef NO_ARCHIVES |
| 359 |
int ar_name (const char *); |
| 360 |
void ar_parse_name (const char *, char **, char **); |
| 361 |
int ar_touch (const char *); |
| 362 |
int ar_member_date (const char *, time_t *); |
| 363 |
|
| 364 |
|
| 365 |
#endif |
| 366 |
|
| 367 |
int dir_file_exists_p (const char *, const char *); |
| 368 |
int file_exists_p (const char *); |
| 369 |
int file_impossible_p (const char *); |
| 370 |
void file_impossible (const char *); |
| 371 |
const char *dir_name (const char *); |
| 372 |
void hash_init_directories (void); |
| 373 |
|
| 374 |
void define_default_variables (void); |
| 375 |
void set_default_suffixes (void); |
| 376 |
void install_default_suffix_rules (void); |
| 377 |
void install_default_implicit_rules (void); |
| 378 |
|
| 379 |
void build_vpath_lists (void); |
| 380 |
void construct_vpath_list (char *pattern, char *dirpath); |
| 381 |
const char *vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr, |
| 382 |
unsigned int* vpath_index, unsigned int* path_index); |
| 383 |
int gpath_search (const char *file, size_t len); |
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
extern void construct_include_path (const char **arg_dirs); |
| 389 |
|
| 390 |
void user_access (void); |
| 391 |
void make_access (void); |
| 392 |
void child_access (void); |
| 393 |
|
| 394 |
char *strip_whitespace (const char **begpp, const char **endpp); |
| 395 |
|
| 396 |
|
| 397 |
void strcache_init (void); |
| 398 |
void strcache_print_stats (const char *prefix); |
| 399 |
int strcache_iscached (const char *str); |
| 400 |
const char *strcache_add (const char *str); |
| 401 |
|
| 402 |
#ifdef HAVE_VFORK_H |
| 403 |
# include <vfork.h> |
| 404 |
#endif |
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
#if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION) && !defined(WINDOWS32) |
| 410 |
|
| 411 |
long int atol (); |
| 412 |
# ifndef VMS |
| 413 |
long int lseek (); |
| 414 |
# endif |
| 415 |
|
| 416 |
#endif |
| 417 |
|
| 418 |
#ifdef HAVE_GETCWD |
| 419 |
#else |
| 420 |
char *getwd (); |
| 421 |
# define getcwd(buf, len) getwd (buf) |
| 422 |
#endif |
| 423 |
|
| 424 |
#if !HAVE_STRCASECMP |
| 425 |
# if HAVE_STRICMP |
| 426 |
# define strcasecmp stricmp |
| 427 |
# elif HAVE_STRCMPI |
| 428 |
# define strcasecmp strcmpi |
| 429 |
# else |
| 430 |
|
| 431 |
int strcasecmp (const char *s1, const char *s2); |
| 432 |
# endif |
| 433 |
#endif |
| 434 |
|
| 435 |
#if !HAVE_STRNCASECMP |
| 436 |
# if HAVE_STRNICMP |
| 437 |
# define strncasecmp strnicmp |
| 438 |
# elif HAVE_STRNCMPI |
| 439 |
# define strncasecmp strncmpi |
| 440 |
# else |
| 441 |
|
| 442 |
int strncasecmp (const char *s1, const char *s2, int n); |
| 443 |
# endif |
| 444 |
#endif |
| 445 |
|
| 446 |
extern char **environ; |
| 447 |
|
| 448 |
extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag; |
| 449 |
extern int print_data_base_flag, question_flag, touch_flag, always_make_flag; |
| 450 |
extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag; |
| 451 |
extern int print_version_flag, print_directory, check_symlink_flag; |
| 452 |
extern int warn_undefined_variables_flag, posix_pedantic, not_parallel; |
| 453 |
extern int second_expansion, clock_skew_detected, rebuilding_makefiles; |
| 454 |
extern int one_shell; |
| 455 |
|
| 456 |
|
| 457 |
extern int batch_mode_shell; |
| 458 |
|
| 459 |
|
| 460 |
#define RECIPEPREFIX_NAME ".RECIPEPREFIX" |
| 461 |
#define RECIPEPREFIX_DEFAULT '\t' |
| 462 |
extern char cmd_prefix; |
| 463 |
|
| 464 |
extern unsigned int job_slots; |
| 465 |
extern int job_fds[2]; |
| 466 |
extern int job_rfd; |
| 467 |
#ifndef NO_FLOAT |
| 468 |
extern double max_load_average; |
| 469 |
#else |
| 470 |
extern int max_load_average; |
| 471 |
#endif |
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
extern char *argv0; |
| 476 |
|
| 477 |
|
| 478 |
extern const char * const *global_argv; |
| 479 |
|
| 480 |
extern char *starting_directory; |
| 481 |
|
| 482 |
|
| 483 |
extern char *directory_before_chdir; |
| 484 |
|
| 485 |
|
| 486 |
extern unsigned int makelevel; |
| 487 |
|
| 488 |
|
| 489 |
extern pid_t makeparent_pid; |
| 490 |
|
| 491 |
|
| 492 |
extern char *makeparent_target; |
| 493 |
|
| 494 |
extern char *version_string, *remote_description, *make_host; |
| 495 |
|
| 496 |
extern unsigned int commands_started; |
| 497 |
|
| 498 |
extern int handling_fatal_signal; |
| 499 |
|
| 500 |
|
| 501 |
#ifndef MIN |
| 502 |
#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) |
| 503 |
#endif |
| 504 |
#ifndef MAX |
| 505 |
#define MAX(_a,_b) ((_a)>(_b)?(_a):(_b)) |
| 506 |
#endif |
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
#ifdef HAVE_DMALLOC_H |
| 511 |
#include <dmalloc.h> |
| 512 |
#endif |
| 513 |
|
| 514 |
#ifndef initialize_main |
| 515 |
# ifdef __EMX__ |
| 516 |
# define initialize_main(pargc, pargv) \ |
| 517 |
{ _wildcard(pargc, pargv); _response(pargc, pargv); } |
| 518 |
# else |
| 519 |
# define initialize_main(pargc, pargv) |
| 520 |
# endif |
| 521 |
#endif |
| 522 |
|
| 523 |
#ifdef __EMX__ |
| 524 |
# if !defined chdir |
| 525 |
# define chdir _chdir2 |
| 526 |
# endif |
| 527 |
# if !defined getcwd |
| 528 |
# define getcwd _getcwd2 |
| 529 |
# endif |
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
# ifdef NO_CHDIR2 |
| 535 |
# warning NO_CHDIR2: usage of drive letters restricted |
| 536 |
# undef chdir |
| 537 |
# undef getcwd |
| 538 |
# endif |
| 539 |
#endif |
| 540 |
|
| 541 |
#ifndef initialize_main |
| 542 |
# define initialize_main(pargc, pargv) |
| 543 |
#endif |
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
#define EINTRLOOP(_v,_c) while (((_v)=_c)==-1 && errno==EINTR) |
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
#endif |