1 /* Miscellaneous global declarations and portability cruft for GNU Make.
2 Copyright (C) 1988,89,90,91,92,93,94,95,96,97 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
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 GNU Make is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNU Make; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19 /* AIX requires this to be the first thing in the file. */
20 #if defined (_AIX) && !defined (__GNUC__)
24 /* We use <config.h> instead of "config.h" so that a compilation
25 using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
26 (which it would do because make.h was found in $srcdir). */
32 /* Use prototypes if available. */
33 #if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
35 #define PARAMS(protos) protos
36 #else /* Not C++ or ANSI C. */
38 #define PARAMS(protos) ()
39 #endif /* C++ or ANSI C. */
43 /* This must happen before #include <signal.h> so
44 that the declaration therein is changed. */
45 #define signal bsdsignal
49 #include <sys/types.h>
54 #ifdef HAVE_SYS_TIMEB_H
55 /* SCO 3.2 "devsys 4.2" has a prototype for `ftime' in <time.h> that bombs
56 unless <sys/timeb.h> has been included first. Does every system have a
57 <sys/timeb.h>? If any does not, configure should check for it. */
58 #include <sys/timeb.h>
68 #define isblank(c) ((c) == ' ' || (c) == '\t')
73 /* Ultrix's unistd.h always defines _POSIX_VERSION, but you only get
74 POSIX.1 behavior with `cc -YPOSIX', which predefines POSIX itself! */
75 #if defined (_POSIX_VERSION) && !defined (ultrix) && !defined (VMS)
80 /* Some systems define _POSIX_VERSION but are not really POSIX.1. */
81 #if (defined (butterfly) || defined (__arm) || (defined (__mips) && defined (_SYSTYPE_SVR3)) || (defined (sequent) && defined (i386)))
85 #if !defined (POSIX) && defined (_AIX) && defined (_POSIX_SOURCE)
89 #if defined (HAVE_SYS_SIGLIST) && !defined (SYS_SIGLIST_DECLARED)
90 extern char *sys_siglist
[];
93 #if !defined (HAVE_SYS_SIGLIST) || !defined (HAVE_STRSIGNAL)
97 /* Some systems do not define NSIG in <signal.h>. */
107 #define RETSIGTYPE void
111 #define sigmask(sig) (1 << ((sig) - 1))
117 #ifdef HAVE_SYS_PARAM_H
118 #include <sys/param.h>
123 #define PATH_MAX MAXPATHLEN
124 #endif /* Not POSIX. */
125 #endif /* No PATH_MAX. */
127 #define MAXPATHLEN 1024
128 #endif /* No MAXPATHLEN. */
131 #define GET_PATH_MAX PATH_MAX
132 #define PATH_VAR(var) char var[PATH_MAX]
134 #define NEED_GET_PATH_MAX
135 extern unsigned int get_path_max
PARAMS ((void));
136 #define GET_PATH_MAX (get_path_max ())
137 #define PATH_VAR(var) char *var = (char *) alloca (GET_PATH_MAX)
144 /* Nonzero if the integer type T is signed. */
145 #define INTEGER_TYPE_SIGNED(t) ((t) -1 < 0)
147 /* The minimum and maximum values for the integer type T.
148 Use ~ (t) 0, not -1, for portability to 1's complement hosts. */
149 #define INTEGER_TYPE_MINIMUM(t) \
150 (! INTEGER_TYPE_SIGNED (t) ? (t) 0 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))
151 #define INTEGER_TYPE_MAXIMUM(t) (~ (t) 0 - INTEGER_TYPE_MINIMUM (t))
153 #ifdef STAT_MACROS_BROKEN
160 #endif /* STAT_MACROS_BROKEN. */
163 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
166 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
178 #if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__) || defined(VMS))
182 #else /* No standard headers. */
194 extern char *malloc
PARAMS ((int));
195 extern char *realloc
PARAMS ((char *, int));
196 extern void free
PARAMS ((char *));
198 extern void abort
PARAMS ((void));
199 extern void exit
PARAMS ((int));
201 #endif /* Standard headers. */
206 #define index(s, c) strchr((s), (c))
209 #define rindex(s, c) strrchr((s), (c))
213 #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
216 #define bzero(s, n) memset ((s), 0, (n))
218 #if defined(HAVE_MEMMOVE) && !defined(bcopy)
219 #define bcopy(s, d, n) memmove ((d), (s), (n))
222 #else /* Not ANSI_STRING. */
228 extern void bzero ();
231 extern void bcopy ();
234 #endif /* ANSI_STRING. */
237 /* SCO Xenix has a buggy macro definition in <string.h>. */
240 #if !defined(ANSI_STRING) && !defined(__DECC)
241 extern char *strerror
PARAMS ((int errnum
));
244 #ifndef __attribute__
245 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
246 # define __attribute__(x)
252 #define alloca(n) __builtin_alloca (n)
256 #else /* Not HAVE_ALLOCA_H. */
258 extern char *alloca ();
259 #endif /* Not AIX. */
260 #endif /* HAVE_ALLOCA_H. */
264 #define streq(a, b) \
266 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
267 #ifdef HAVE_CASE_INSENSITIVE_FS
268 #define strieq(a, b) \
270 (tolower(*(a)) == tolower(*(b)) && (*(a) == '\0' || !strcmpi ((a) + 1, (b) + 1))))
272 #define strieq(a, b) \
274 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
277 /* Buggy compiler can't handle this. */
278 #define streq(a, b) (strcmp ((a), (b)) == 0)
279 #define strieq(a, b) (strcmp ((a), (b)) == 0)
282 /* Add to VAR the hashing value of C, one character in a name. */
283 #define HASH(var, c) \
284 ((var += (c)), (var = ((var) << 7) + ((var) >> 20)))
285 #ifdef HAVE_CASE_INSENSITIVE_FS /* Fold filenames */
286 #define HASHI(var, c) \
287 ((var += tolower((c))), (var = ((var) << 7) + ((var) >> 20)))
289 #define HASHI(var, c) HASH(var,c)
292 #if defined(__GNUC__) || defined(ENUM_BITFIELDS)
293 #define ENUM_BITFIELD(bits) :bits
295 #define ENUM_BITFIELD(bits)
298 #if defined(__MSDOS__) || defined(WINDOWS32)
299 #define PATH_SEPARATOR_CHAR ';'
302 #define PATH_SEPARATOR_CHAR ','
304 #define PATH_SEPARATOR_CHAR ':'
311 #define pipe(p) _pipe(p, 512, O_BINARY)
312 #define kill(pid,sig) w32_kill(pid,sig)
314 extern void sync_Path_environment(void);
315 extern int kill(int pid
, int sig
);
316 extern int safe_stat(char *file
, struct stat
*sb
);
317 extern char *end_of_token_w32();
318 extern int find_and_set_default_shell(char *token
);
320 /* indicates whether or not we have Bourne shell */
321 extern int no_default_sh_exe
;
323 /* is default_shell unixy? */
324 extern int unixy_shell
;
325 #endif /* WINDOWS32 */
327 extern void die () __attribute__ ((noreturn
));
328 extern void message ();
329 extern void fatal () __attribute__ ((noreturn
));
330 extern void error ();
331 extern void log_working_directory ();
332 extern void makefile_error ();
333 extern void makefile_fatal () __attribute__ ((noreturn
));
334 extern void pfatal_with_name () __attribute__ ((noreturn
));
335 extern void perror_with_name ();
336 extern char *savestring ();
337 extern char *concat ();
338 extern char *xmalloc ();
339 extern char *xrealloc ();
340 extern char *find_next_token ();
341 extern char *next_token ();
342 extern char *end_of_token ();
343 extern void collapse_continuations ();
344 extern void remove_comments ();
345 extern char *sindex ();
346 extern char *lindex ();
347 extern int alpha_compare ();
348 extern void print_spaces ();
349 extern struct dep
*copy_dep_chain ();
350 extern char *find_char_unquote ();
351 extern char *find_percent ();
354 extern int ar_name ();
355 extern void ar_parse_name ();
356 extern int ar_touch ();
357 extern time_t ar_member_date ();
360 extern void dir_load ();
361 extern int dir_file_exists_p ();
362 extern int file_exists_p ();
363 extern int file_impossible_p ();
364 extern void file_impossible ();
365 extern char *dir_name ();
367 extern void define_default_variables ();
368 extern void set_default_suffixes ();
369 extern void install_default_suffix_rules ();
370 extern void install_default_implicit_rules ();
371 extern void count_implicit_rule_limits ();
372 extern void convert_to_pattern ();
373 extern void create_pattern_rule ();
375 extern void build_vpath_lists ();
376 extern void construct_vpath_list ();
377 extern int vpath_search ();
378 extern int gpath_search ();
380 extern void construct_include_path ();
381 extern void uniquize_deps ();
383 extern int update_goal_chain ();
384 extern void notice_finished_file ();
386 extern void user_access ();
387 extern void make_access ();
388 extern void child_access ();
394 /* We omit these declarations on non-POSIX systems which define _POSIX_VERSION,
395 because such systems often declare them in header files anyway. */
397 #if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION) && !defined(WINDOWS32)
399 extern long int atol ();
401 extern long int lseek ();
404 #endif /* Not GNU C library or POSIX. */
407 extern char *getcwd ();
409 extern char *getwd
PARAMS ((char *));
412 extern char *getwd ();
413 #define getcwd(buf, len) getwd (buf)
416 extern char **environ
;
418 extern char *reading_filename
;
419 extern unsigned int *reading_lineno_ptr
;
421 extern int just_print_flag
, silent_flag
, ignore_errors_flag
, keep_going_flag
;
422 extern int debug_flag
, print_data_base_flag
, question_flag
, touch_flag
;
423 extern int env_overrides
, no_builtin_rules_flag
, print_version_flag
;
424 extern int print_directory_flag
, warn_undefined_variables_flag
;
425 extern int posix_pedantic
;
426 extern int clock_skew_detected
;
428 /* can we run commands via 'sh -c xxx' or must we use batch files? */
429 extern int batch_mode_shell
;
431 extern unsigned int job_slots
;
433 extern double max_load_average
;
435 extern int max_load_average
;
438 extern char *program
;
439 extern char *starting_directory
;
440 extern unsigned int makelevel
;
441 extern char *version_string
, *remote_description
;
443 extern unsigned int commands_started
;
445 extern int handling_fatal_signal
;
448 #define DEBUGPR(msg) \
449 do if (debug_flag) { print_spaces (depth); printf (msg, file->name); \
450 fflush (stdout); } while (0)
453 # ifndef EXIT_FAILURE
454 # define EXIT_FAILURE 3
456 # ifndef EXIT_SUCCESS
457 # define EXIT_SUCCESS 1
459 # ifndef EXIT_TROUBLE
460 # define EXIT_TROUBLE 2
463 # ifndef EXIT_FAILURE
464 # define EXIT_FAILURE 2
466 # ifndef EXIT_SUCCESS
467 # define EXIT_SUCCESS 0
469 # ifndef EXIT_TROUBLE
470 # define EXIT_TROUBLE 1