1 /* Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993
2 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 /* SCO 3.2 "devsys 4.2" has a prototype for `ftime' in <time.h> that bombs
44 unless <sys/timeb.h> has been included first. Does every system have a
45 <sys/timeb.h>? If any does not, configure should check for it. */
46 #include <sys/timeb.h>
55 #define isblank(c) ((c) == ' ' || (c) == '\t')
65 /* Some systems define _POSIX_VERSION but are not really POSIX.1. */
66 #if (defined (butterfly) || \
67 (defined (__mips) && defined (_SYSTYPE_SVR3)) || \
68 (defined (sequent) && defined (i386)))
72 #if !defined (POSIX) && defined (_AIX) && defined (_POSIX_SOURCE)
76 #if !defined (HAVE_SYS_SIGLIST) && defined (HAVE__SYS_SIGLIST)
77 #define sys_siglist _sys_siglist
78 #define HAVE_SYS_SIGLIST /* Now we have it. */
80 /* It was declared in <signal.h>, with who knows what type.
81 Don't declare it again and risk conflicting. */
82 #define SYS_SIGLIST_DECLARED
85 #ifdef HAVE_SYS_SIGLIST
86 #ifndef SYS_SIGLIST_DECLARED
87 extern char *sys_siglist
[];
93 /* Some systems do not define NSIG in <signal.h>. */
103 #define RETSIGTYPE void
107 #define sigmask(sig) (1 << ((sig) - 1))
113 #ifdef HAVE_SYS_PARAM_H
114 #include <sys/param.h>
119 #define PATH_MAX MAXPATHLEN
120 #endif /* Not POSIX. */
121 #endif /* No PATH_MAX. */
123 #define MAXPATHLEN 1024
124 #endif /* No MAXPATHLEN. */
127 #define GET_PATH_MAX PATH_MAX
128 #define PATH_VAR(var) char var[PATH_MAX]
130 #define NEED_GET_PATH_MAX
131 extern unsigned int get_path_max ();
132 #define GET_PATH_MAX (get_path_max ())
133 #define PATH_VAR(var) char *var = (char *) alloca (GET_PATH_MAX)
136 #ifdef STAT_MACROS_BROKEN
143 #endif /* STAT_MACROS_BROKEN. */
146 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
149 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
153 #if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__))
157 #else /* No standard headers. */
169 extern char *malloc (), *realloc ();
172 extern void qsort ();
173 extern void abort (), exit ();
175 #endif /* Standard headers. */
180 #define index(s, c) strchr((s), (c))
183 #define rindex(s, c) strrchr((s), (c))
187 #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
190 #define bzero(s, n) memset ((s), 0, (n))
193 #define bcopy(s, d, n) memcpy ((d), (s), (n))
196 #else /* Not ANSI_STRING. */
202 extern void bzero ();
205 extern void bcopy ();
208 #endif /* ANSI_STRING. */
214 #define alloca(n) __builtin_alloca (n)
218 #else /* Not HAVE_ALLOCA_H. */
220 extern char *alloca ();
221 #endif /* Not AIX. */
222 #endif /* HAVE_ALLOCA_H. */
226 #define streq(a, b) \
228 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
230 /* Buggy compiler can't handle this. */
231 #define streq(a, b) (strcmp ((a), (b)) == 0)
234 /* Add to VAR the hashing value of C, one character in a name. */
235 #define HASH(var, c) \
236 ((var += (c)), (var = ((var) << 7) + ((var) >> 20)))
238 #if defined(__GNUC__) || defined(ENUM_BITFIELDS)
239 #define ENUM_BITFIELD(bits) :bits
241 #define ENUM_BITFIELD(bits)
245 extern void message (), fatal (), error ();
246 extern void makefile_error (), makefile_fatal ();
247 extern void pfatal_with_name (), perror_with_name ();
248 extern char *savestring (), *concat ();
249 extern char *xmalloc (), *xrealloc ();
250 extern char *find_next_token (), *next_token (), *end_of_token ();
251 extern void collapse_continuations (), remove_comments ();
252 extern char *sindex (), *lindex ();
253 extern int alpha_compare ();
254 extern void print_spaces ();
255 extern struct dep
*copy_dep_chain ();
256 extern char *find_percent ();
259 extern int ar_name ();
260 extern void ar_parse_name ();
261 extern int ar_touch ();
262 extern time_t ar_member_date ();
265 extern void dir_load ();
266 extern int dir_file_exists_p (), file_exists_p (), file_impossible_p ();
267 extern void file_impossible ();
268 extern char *dir_name ();
270 extern void define_default_variables ();
271 extern void set_default_suffixes (), install_default_suffix_rules ();
272 extern void install_default_implicit_rules (), count_implicit_rule_limits ();
273 extern void convert_to_pattern (), create_pattern_rule ();
275 extern void build_vpath_lists (), construct_vpath_list ();
276 extern int vpath_search ();
278 extern void construct_include_path ();
279 extern void uniquize_deps ();
281 extern int update_goal_chain ();
282 extern void notice_finished_file ();
284 extern void user_access (), make_access (), child_access ();
291 #if !defined (__GNU_LIBRARY__) && !defined (POSIX)
293 #ifdef HAVE_SIGSETMASK
294 extern int sigsetmask ();
295 extern int sigblock ();
299 extern long int atol ();
300 extern int unlink (), stat (), fstat ();
301 extern int pipe (), close (), read (), write (), open ();
302 extern long int lseek ();
304 #endif /* Not GNU C library or POSIX. */
307 extern char *getcwd ();
309 extern char *getwd ();
310 #define getcwd(buf, len) getwd (buf)
313 extern char **environ
;
315 extern char *reading_filename
;
316 extern unsigned int *reading_lineno_ptr
;
318 extern int just_print_flag
, silent_flag
, ignore_errors_flag
, keep_going_flag
;
319 extern int debug_flag
, print_data_base_flag
, question_flag
, touch_flag
;
320 extern int env_overrides
, no_builtin_rules_flag
, print_version_flag
;
321 extern int print_directory_flag
, warn_undefined_variables_flag
;
323 extern unsigned int job_slots
;
324 extern double max_load_average
;
326 extern char *program
;
327 extern char *starting_directory
;
328 extern unsigned int makelevel
;
329 extern char *version_string
, *remote_description
;
331 extern unsigned int commands_started
;
333 extern int handling_fatal_signal
;
336 #define DEBUGPR(msg) \
337 do if (debug_flag) { print_spaces (depth); printf (msg, file->name); \
338 fflush (stdout); } while (0)