1 /* Miscellaneous global declarations and portability cruft for GNU Make.
2 Copyright (C) 1988,89,90,91,92,93,94,95,96 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)
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 (HAVE__SYS_SIGLIST)
90 #define sys_siglist _sys_siglist
91 #define HAVE_SYS_SIGLIST /* Now we have it. */
93 /* It was declared in <signal.h>, with who knows what type.
94 Don't declare it again and risk conflicting. */
95 #define SYS_SIGLIST_DECLARED
98 #ifdef HAVE_SYS_SIGLIST
99 #ifndef SYS_SIGLIST_DECLARED
100 extern char *sys_siglist
[];
106 /* Some systems do not define NSIG in <signal.h>. */
116 #define RETSIGTYPE void
120 #define sigmask(sig) (1 << ((sig) - 1))
126 #ifdef HAVE_SYS_PARAM_H
127 #include <sys/param.h>
132 #define PATH_MAX MAXPATHLEN
133 #endif /* Not POSIX. */
134 #endif /* No PATH_MAX. */
136 #define MAXPATHLEN 1024
137 #endif /* No MAXPATHLEN. */
140 #define GET_PATH_MAX PATH_MAX
141 #define PATH_VAR(var) char var[PATH_MAX]
143 #define NEED_GET_PATH_MAX
144 extern unsigned int get_path_max
PARAMS ((void));
145 #define GET_PATH_MAX (get_path_max ())
146 #define PATH_VAR(var) char *var = (char *) alloca (GET_PATH_MAX)
149 #ifdef STAT_MACROS_BROKEN
156 #endif /* STAT_MACROS_BROKEN. */
159 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
162 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
174 #if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__) || defined(VMS))
178 #else /* No standard headers. */
190 extern char *malloc
PARAMS ((int));
191 extern char *realloc
PARAMS ((char *, int));
192 extern void free
PARAMS ((char *));
194 extern void abort
PARAMS ((void));
195 extern void exit
PARAMS ((int));
197 #endif /* Standard headers. */
202 #define index(s, c) strchr((s), (c))
205 #define rindex(s, c) strrchr((s), (c))
209 #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
212 #define bzero(s, n) memset ((s), 0, (n))
215 #define bcopy(s, d, n) memcpy ((d), (s), (n))
218 #else /* Not ANSI_STRING. */
224 extern void bzero ();
227 extern void bcopy ();
230 #endif /* ANSI_STRING. */
233 /* SCO Xenix has a buggy macro definition in <string.h>. */
236 #if !defined(ANSI_STRING) && !defined(__DECC)
237 extern char *strerror
PARAMS ((int errnum
));
243 #define alloca(n) __builtin_alloca (n)
247 #else /* Not HAVE_ALLOCA_H. */
249 extern char *alloca ();
250 #endif /* Not AIX. */
251 #endif /* HAVE_ALLOCA_H. */
255 #define streq(a, b) \
257 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
259 #define strieq(a, b) \
261 (tolower(*(a)) == tolower(*(b)) && (*(a) == '\0' || !strcmpi ((a) + 1, (b) + 1))))
263 #define strieq(a, b) \
265 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
268 /* Buggy compiler can't handle this. */
269 #define streq(a, b) (strcmp ((a), (b)) == 0)
270 #define strieq(a, b) (strcmp ((a), (b)) == 0)
273 /* Add to VAR the hashing value of C, one character in a name. */
274 #define HASH(var, c) \
275 ((var += (c)), (var = ((var) << 7) + ((var) >> 20)))
276 #ifdef _AMIGA /* Fold filenames on #amiga */
277 #define HASHI(var, c) \
278 ((var += tolower((c))), (var = ((var) << 7) + ((var) >> 20)))
280 #define HASHI(var, c) HASH(var,c)
283 #if defined(__GNUC__) || defined(ENUM_BITFIELDS)
284 #define ENUM_BITFIELD(bits) :bits
286 #define ENUM_BITFIELD(bits)
290 #define PATH_SEPARATOR_CHAR ';'
292 #define PATH_SEPARATOR_CHAR ':'
296 extern void message ();
297 extern void fatal ();
298 extern void error ();
299 extern void log_working_directory ();
300 extern void makefile_error ();
301 extern void makefile_fatal ();
302 extern void pfatal_with_name ();
303 extern void perror_with_name ();
304 extern char *savestring ();
305 extern char *concat ();
306 extern char *xmalloc ();
307 extern char *xrealloc ();
308 extern char *find_next_token ();
309 extern char *next_token ();
310 extern char *end_of_token ();
311 extern void collapse_continuations ();
312 extern void remove_comments ();
313 extern char *sindex ();
314 extern char *lindex ();
315 extern int alpha_compare ();
316 extern void print_spaces ();
317 extern struct dep
*copy_dep_chain ();
318 extern char *find_char_unquote ();
319 extern char *find_percent ();
322 extern int ar_name ();
323 extern void ar_parse_name ();
324 extern int ar_touch ();
325 extern time_t ar_member_date ();
328 extern void dir_load ();
329 extern int dir_file_exists_p ();
330 extern int file_exists_p ();
331 extern int file_impossible_p ();
332 extern void file_impossible ();
333 extern char *dir_name ();
335 extern void define_default_variables ();
336 extern void set_default_suffixes ();
337 extern void install_default_suffix_rules ();
338 extern void install_default_implicit_rules ();
339 extern void count_implicit_rule_limits ();
340 extern void convert_to_pattern ();
341 extern void create_pattern_rule ();
343 extern void build_vpath_lists ();
344 extern void construct_vpath_list ();
345 extern int vpath_search ();
347 extern void construct_include_path ();
348 extern void uniquize_deps ();
350 extern int update_goal_chain ();
351 extern void notice_finished_file ();
353 extern void user_access ();
354 extern void make_access ();
355 extern void child_access ();
361 /* We omit these declarations on non-POSIX systems which define _POSIX_VERSION,
362 because such systems often declare the in header files anyway. */
364 #if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION)
366 extern long int atol ();
368 extern long int lseek ();
371 #endif /* Not GNU C library or POSIX. */
374 extern char *getcwd ();
376 extern char *getwd
PARAMS ((char *));
379 extern char *getwd ();
380 #define getcwd(buf, len) getwd (buf)
383 extern char **environ
;
385 extern char *reading_filename
;
386 extern unsigned int *reading_lineno_ptr
;
388 extern int just_print_flag
, silent_flag
, ignore_errors_flag
, keep_going_flag
;
389 extern int debug_flag
, print_data_base_flag
, question_flag
, touch_flag
;
390 extern int env_overrides
, no_builtin_rules_flag
, print_version_flag
;
391 extern int print_directory_flag
, warn_undefined_variables_flag
;
392 extern int posix_pedantic
;
394 extern unsigned int job_slots
;
396 extern double max_load_average
;
398 extern int max_load_average
;
401 extern char *program
;
402 extern char *starting_directory
;
403 extern unsigned int makelevel
;
404 extern char *version_string
, *remote_description
;
406 extern unsigned int commands_started
;
408 extern int handling_fatal_signal
;
411 #define DEBUGPR(msg) \
412 do if (debug_flag) { print_spaces (depth); printf (msg, file->name); \
413 fflush (stdout); } while (0)
416 # ifndef EXIT_FAILURE
417 # define EXIT_FAILURE 3
419 # ifndef EXIT_SUCCESS
420 # define EXIT_SUCCESS 1
422 # ifndef EXIT_TROUBLE
423 # define EXIT_TROUBLE 2
426 # ifndef EXIT_FAILURE
427 # define EXIT_FAILURE 2
429 # ifndef EXIT_SUCCESS
430 # define EXIT_SUCCESS 0
432 # ifndef EXIT_TROUBLE
433 # define EXIT_TROUBLE 1