1 /* Miscellaneous global declarations and portability cruft for GNU Make.
2 Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95 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')
62 /* Ultrix's unistd.h always defines _POSIX_VERSION, but you only get
63 POSIX.1 behavior with `cc -YPOSIX', which predefines POSIX itself! */
64 #if defined (_POSIX_VERSION) && !defined (ultrix)
69 /* Some systems define _POSIX_VERSION but are not really POSIX.1. */
70 #if (defined (butterfly) || defined (__arm) || \
71 (defined (__mips) && defined (_SYSTYPE_SVR3)) || \
72 (defined (sequent) && defined (i386)))
76 #if !defined (POSIX) && defined (_AIX) && defined (_POSIX_SOURCE)
80 #if !defined (HAVE_SYS_SIGLIST) && defined (HAVE__SYS_SIGLIST)
81 #define sys_siglist _sys_siglist
82 #define HAVE_SYS_SIGLIST /* Now we have it. */
84 /* It was declared in <signal.h>, with who knows what type.
85 Don't declare it again and risk conflicting. */
86 #define SYS_SIGLIST_DECLARED
89 #ifdef HAVE_SYS_SIGLIST
90 #ifndef SYS_SIGLIST_DECLARED
91 extern char *sys_siglist
[];
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 ();
136 #define GET_PATH_MAX (get_path_max ())
137 #define PATH_VAR(var) char *var = (char *) alloca (GET_PATH_MAX)
140 #ifdef STAT_MACROS_BROKEN
147 #endif /* STAT_MACROS_BROKEN. */
150 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
153 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
157 #if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__))
161 #else /* No standard headers. */
173 extern char *malloc (), *realloc ();
176 extern void abort (), exit ();
178 #endif /* Standard headers. */
183 #define index(s, c) strchr((s), (c))
186 #define rindex(s, c) strrchr((s), (c))
190 #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
193 #define bzero(s, n) memset ((s), 0, (n))
196 #define bcopy(s, d, n) memcpy ((d), (s), (n))
199 #else /* Not ANSI_STRING. */
205 extern void bzero ();
208 extern void bcopy ();
211 #endif /* ANSI_STRING. */
214 /* SCO Xenix has a buggy macro definition in <string.h>. */
218 extern char *strerror ();
224 #define alloca(n) __builtin_alloca (n)
228 #else /* Not HAVE_ALLOCA_H. */
230 extern char *alloca ();
231 #endif /* Not AIX. */
232 #endif /* HAVE_ALLOCA_H. */
236 #define streq(a, b) \
238 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
240 /* Buggy compiler can't handle this. */
241 #define streq(a, b) (strcmp ((a), (b)) == 0)
244 /* Add to VAR the hashing value of C, one character in a name. */
245 #define HASH(var, c) \
246 ((var += (c)), (var = ((var) << 7) + ((var) >> 20)))
248 #if defined(__GNUC__) || defined(ENUM_BITFIELDS)
249 #define ENUM_BITFIELD(bits) :bits
251 #define ENUM_BITFIELD(bits)
255 #define PATH_SEPARATOR_CHAR ';'
257 #define PATH_SEPARATOR_CHAR ':'
261 extern void message (), fatal (), error ();
262 extern void makefile_error (), makefile_fatal ();
263 extern void pfatal_with_name (), perror_with_name ();
264 extern char *savestring (), *concat ();
265 extern char *xmalloc (), *xrealloc ();
266 extern char *find_next_token (), *next_token (), *end_of_token ();
267 extern void collapse_continuations (), remove_comments ();
268 extern char *sindex (), *lindex ();
269 extern int alpha_compare ();
270 extern void print_spaces ();
271 extern struct dep
*copy_dep_chain ();
272 extern char *find_char_unquote (), *find_percent ();
275 extern int ar_name ();
276 extern void ar_parse_name ();
277 extern int ar_touch ();
278 extern time_t ar_member_date ();
281 extern void dir_load ();
282 extern int dir_file_exists_p (), file_exists_p (), file_impossible_p ();
283 extern void file_impossible ();
284 extern char *dir_name ();
286 extern void define_default_variables ();
287 extern void set_default_suffixes (), install_default_suffix_rules ();
288 extern void install_default_implicit_rules (), count_implicit_rule_limits ();
289 extern void convert_to_pattern (), create_pattern_rule ();
291 extern void build_vpath_lists (), construct_vpath_list ();
292 extern int vpath_search ();
294 extern void construct_include_path ();
295 extern void uniquize_deps ();
297 extern int update_goal_chain ();
298 extern void notice_finished_file ();
300 extern void user_access (), make_access (), child_access ();
307 /* We omit these declarations on non-POSIX systems which define _POSIX_VERSION,
308 because such systems often declare the in header files anyway. */
310 #if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION)
312 extern long int atol ();
313 extern long int lseek ();
315 #endif /* Not GNU C library or POSIX. */
318 extern char *getcwd ();
320 extern char *getwd ();
321 #define getcwd(buf, len) getwd (buf)
324 extern char **environ
;
326 extern char *reading_filename
;
327 extern unsigned int *reading_lineno_ptr
;
329 extern int just_print_flag
, silent_flag
, ignore_errors_flag
, keep_going_flag
;
330 extern int debug_flag
, print_data_base_flag
, question_flag
, touch_flag
;
331 extern int env_overrides
, no_builtin_rules_flag
, print_version_flag
;
332 extern int print_directory_flag
, warn_undefined_variables_flag
;
333 extern int posix_pedantic
;
335 extern unsigned int job_slots
;
336 extern double max_load_average
;
338 extern char *program
;
339 extern char *starting_directory
;
340 extern unsigned int makelevel
;
341 extern char *version_string
, *remote_description
;
343 extern unsigned int commands_started
;
345 extern int handling_fatal_signal
;
348 #define DEBUGPR(msg) \
349 do if (debug_flag) { print_spaces (depth); printf (msg, file->name); \
350 fflush (stdout); } while (0)