1 /* Miscellaneous global declarations and portability cruft for GNU Make.
2 Copyright (C) 1988, 89, 90, 91, 92, 93, 94 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 /* This must happen before #include <signal.h> so
33 that the declaration therein is changed. */
34 #define signal bsdsignal
38 #include <sys/types.h>
43 #ifdef HAVE_SYS_TIMEB_H
44 /* SCO 3.2 "devsys 4.2" has a prototype for `ftime' in <time.h> that bombs
45 unless <sys/timeb.h> has been included first. Does every system have a
46 <sys/timeb.h>? If any does not, configure should check for it. */
47 #include <sys/timeb.h>
57 #define isblank(c) ((c) == ' ' || (c) == '\t')
67 /* Some systems define _POSIX_VERSION but are not really POSIX.1. */
68 #if (defined (butterfly) || \
69 (defined (__mips) && defined (_SYSTYPE_SVR3)) || \
70 (defined (sequent) && defined (i386)))
74 #if !defined (POSIX) && defined (_AIX) && defined (_POSIX_SOURCE)
78 #if !defined (HAVE_SYS_SIGLIST) && defined (HAVE__SYS_SIGLIST)
79 #define sys_siglist _sys_siglist
80 #define HAVE_SYS_SIGLIST /* Now we have it. */
82 /* It was declared in <signal.h>, with who knows what type.
83 Don't declare it again and risk conflicting. */
84 #define SYS_SIGLIST_DECLARED
87 #ifdef HAVE_SYS_SIGLIST
88 #ifndef SYS_SIGLIST_DECLARED
89 extern char *sys_siglist
[];
95 /* Some systems do not define NSIG in <signal.h>. */
105 #define RETSIGTYPE void
109 #define sigmask(sig) (1 << ((sig) - 1))
115 #ifdef HAVE_SYS_PARAM_H
116 #include <sys/param.h>
121 #define PATH_MAX MAXPATHLEN
122 #endif /* Not POSIX. */
123 #endif /* No PATH_MAX. */
125 #define MAXPATHLEN 1024
126 #endif /* No MAXPATHLEN. */
129 #define GET_PATH_MAX PATH_MAX
130 #define PATH_VAR(var) char var[PATH_MAX]
132 #define NEED_GET_PATH_MAX
133 extern unsigned int get_path_max ();
134 #define GET_PATH_MAX (get_path_max ())
135 #define PATH_VAR(var) char *var = (char *) alloca (GET_PATH_MAX)
138 #ifdef STAT_MACROS_BROKEN
145 #endif /* STAT_MACROS_BROKEN. */
148 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
151 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
155 #if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__))
159 #else /* No standard headers. */
171 extern char *malloc (), *realloc ();
174 extern void qsort ();
175 extern void abort (), exit ();
177 #endif /* Standard headers. */
182 #define index(s, c) strchr((s), (c))
185 #define rindex(s, c) strrchr((s), (c))
189 #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
192 #define bzero(s, n) memset ((s), 0, (n))
195 #define bcopy(s, d, n) memcpy ((d), (s), (n))
198 #else /* Not ANSI_STRING. */
204 extern void bzero ();
207 extern void bcopy ();
210 #endif /* ANSI_STRING. */
213 /* SCO Xenix has a buggy macro definition in <string.h>. */
217 extern char *strerror ();
223 #define alloca(n) __builtin_alloca (n)
227 #else /* Not HAVE_ALLOCA_H. */
229 extern char *alloca ();
230 #endif /* Not AIX. */
231 #endif /* HAVE_ALLOCA_H. */
235 #define streq(a, b) \
237 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
239 /* Buggy compiler can't handle this. */
240 #define streq(a, b) (strcmp ((a), (b)) == 0)
243 /* Add to VAR the hashing value of C, one character in a name. */
244 #define HASH(var, c) \
245 ((var += (c)), (var = ((var) << 7) + ((var) >> 20)))
247 #if defined(__GNUC__) || defined(ENUM_BITFIELDS)
248 #define ENUM_BITFIELD(bits) :bits
250 #define ENUM_BITFIELD(bits)
254 extern void message (), fatal (), error ();
255 extern void makefile_error (), makefile_fatal ();
256 extern void pfatal_with_name (), perror_with_name ();
257 extern char *savestring (), *concat ();
258 extern char *xmalloc (), *xrealloc ();
259 extern char *find_next_token (), *next_token (), *end_of_token ();
260 extern void collapse_continuations (), remove_comments ();
261 extern char *sindex (), *lindex ();
262 extern int alpha_compare ();
263 extern void print_spaces ();
264 extern struct dep
*copy_dep_chain ();
265 extern char *find_char_unquote (), *find_percent ();
268 extern int ar_name ();
269 extern void ar_parse_name ();
270 extern int ar_touch ();
271 extern time_t ar_member_date ();
274 extern void dir_load ();
275 extern int dir_file_exists_p (), file_exists_p (), file_impossible_p ();
276 extern void file_impossible ();
277 extern char *dir_name ();
279 extern void define_default_variables ();
280 extern void set_default_suffixes (), install_default_suffix_rules ();
281 extern void install_default_implicit_rules (), count_implicit_rule_limits ();
282 extern void convert_to_pattern (), create_pattern_rule ();
284 extern void build_vpath_lists (), construct_vpath_list ();
285 extern int vpath_search ();
287 extern void construct_include_path ();
288 extern void uniquize_deps ();
290 extern int update_goal_chain ();
291 extern void notice_finished_file ();
293 extern void user_access (), make_access (), child_access ();
300 #if !defined (__GNU_LIBRARY__) && !defined (POSIX)
302 #ifdef HAVE_SIGSETMASK
303 extern int sigsetmask ();
304 extern int sigblock ();
308 extern long int atol ();
309 extern int unlink (), stat (), fstat ();
310 extern int pipe (), close (), read (), write (), open ();
311 extern long int lseek ();
313 #endif /* Not GNU C library or POSIX. */
316 extern char *getcwd ();
318 extern char *getwd ();
319 #define getcwd(buf, len) getwd (buf)
322 extern char **environ
;
324 extern char *reading_filename
;
325 extern unsigned int *reading_lineno_ptr
;
327 extern int just_print_flag
, silent_flag
, ignore_errors_flag
, keep_going_flag
;
328 extern int debug_flag
, print_data_base_flag
, question_flag
, touch_flag
;
329 extern int env_overrides
, no_builtin_rules_flag
, print_version_flag
;
330 extern int print_directory_flag
, warn_undefined_variables_flag
;
332 extern unsigned int job_slots
;
333 extern double max_load_average
;
335 extern char *program
;
336 extern char *starting_directory
;
337 extern unsigned int makelevel
;
338 extern char *version_string
, *remote_description
;
340 extern unsigned int commands_started
;
342 extern int handling_fatal_signal
;
345 #define DEBUGPR(msg) \
346 do if (debug_flag) { print_spaces (depth); printf (msg, file->name); \
347 fflush (stdout); } while (0)