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__)
29 /* This must happen before #include <signal.h> so
30 that the declaration therein is changed. */
31 #define signal bsdsignal
35 #include <sys/types.h>
48 #define isblank(c) ((c) == ' ' || (c) == '\t')
58 /* Some systems define _POSIX_VERSION but are not really POSIX.1. */
59 #if (defined (butterfly) || \
60 (defined (__mips) && defined (_SYSTYPE_SVR3)))
64 #if !defined (HAVE_SYS_SIGLIST) && defined (HAVE__SYS_SIGLIST)
65 #define sys_siglist _sys_siglist
66 #define HAVE_SYS_SIGLIST /* Now we have it. */
68 /* It was declared in <signal.h>, with who knows what type.
69 Don't declare it again and risk conflicting. */
70 #define SYS_SIGLIST_DECLARED
73 #ifdef HAVE_SYS_SIGLIST
74 #ifndef SYS_SIGLIST_DECLARED
75 extern char *sys_siglist
[];
81 /* Some systems do not define NSIG in <signal.h>. */
91 #define RETSIGTYPE void
95 #define sigmask(sig) (1 << ((sig) - 1))
101 #ifdef HAVE_SYS_PARAM_H
102 #include <sys/param.h>
107 #define PATH_MAX MAXPATHLEN
108 #endif /* Not POSIX. */
109 #endif /* No PATH_MAX. */
111 #define MAXPATHLEN 1024
112 #endif /* No MAXPATHLEN. */
115 #define GET_PATH_MAX PATH_MAX
116 #define PATH_VAR(var) char var[PATH_MAX]
118 #define NEED_GET_PATH_MAX
119 extern unsigned int get_path_max ();
120 #define GET_PATH_MAX (get_path_max ())
121 #define PATH_VAR(var) char *var = (char *) alloca (GET_PATH_MAX)
134 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
137 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
141 #if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__))
145 #else /* No standard headers. */
157 extern char *malloc (), *realloc ();
160 extern void qsort ();
161 extern void abort (), exit ();
163 #endif /* Standard headers. */
168 #define index(s, c) strchr((s), (c))
171 #define rindex(s, c) strrchr((s), (c))
175 #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
178 #define bzero(s, n) memset ((s), 0, (n))
181 #define bcopy(s, d, n) memcpy ((d), (s), (n))
184 #else /* Not ANSI_STRING. */
190 extern void bzero ();
193 extern void bcopy ();
196 #endif /* ANSI_STRING. */
202 #define alloca(n) __builtin_alloca (n)
206 #else /* Not HAVE_ALLOCA_H. */
208 extern char *alloca ();
209 #endif /* Not AIX. */
210 #endif /* HAVE_ALLOCA_H. */
214 #define streq(a, b) \
216 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
218 /* Buggy compiler can't handle this. */
219 #define streq(a, b) (strcmp ((a), (b)) == 0)
222 /* Add to VAR the hashing value of C, one character in a name. */
223 #define HASH(var, c) \
224 ((var += (c)), (var = ((var) << 7) + ((var) >> 20)))
226 #if defined(__GNUC__) || defined(ENUM_BITFIELDS)
227 #define ENUM_BITFIELD(bits) :bits
229 #define ENUM_BITFIELD(bits)
233 extern void message (), fatal (), error ();
234 extern void makefile_error (), makefile_fatal ();
235 extern void pfatal_with_name (), perror_with_name ();
236 extern char *savestring (), *concat ();
237 extern char *xmalloc (), *xrealloc ();
238 extern char *find_next_token (), *next_token (), *end_of_token ();
239 extern void collapse_continuations (), remove_comments ();
240 extern char *sindex (), *lindex ();
241 extern int alpha_compare ();
242 extern void print_spaces ();
243 extern struct dep
*copy_dep_chain ();
244 extern char *find_percent ();
247 extern int ar_name ();
248 extern void ar_parse_name ();
249 extern int ar_touch ();
250 extern time_t ar_member_date ();
253 extern void dir_load ();
254 extern int dir_file_exists_p (), file_exists_p (), file_impossible_p ();
255 extern void file_impossible ();
256 extern char *dir_name ();
258 extern void define_default_variables ();
259 extern void set_default_suffixes (), install_default_implicit_rules ();
260 extern void convert_to_pattern (), count_implicit_rule_limits ();
261 extern void create_pattern_rule ();
263 extern void build_vpath_lists (), construct_vpath_list ();
264 extern int vpath_search ();
266 extern void construct_include_path ();
267 extern void uniquize_deps ();
269 extern int update_goal_chain ();
270 extern void notice_finished_file ();
272 extern void user_access (), make_access (), child_access ();
279 #if !defined (__GNU_LIBRARY__) && !defined (POSIX)
281 #ifdef HAVE_SIGSETMASK
282 extern int sigsetmask ();
283 extern int sigblock ();
287 extern long int atol ();
288 extern int unlink (), stat (), fstat ();
289 extern int pipe (), close (), read (), write (), open ();
290 extern long int lseek ();
292 #endif /* Not GNU C library or POSIX. */
295 extern char *getcwd ();
297 extern char *getwd ();
298 #define getcwd(buf, len) getwd (buf)
301 extern char **environ
;
303 extern char *reading_filename
;
304 extern unsigned int *reading_lineno_ptr
;
306 extern int just_print_flag
, silent_flag
, ignore_errors_flag
, keep_going_flag
;
307 extern int debug_flag
, print_data_base_flag
, question_flag
, touch_flag
;
308 extern int env_overrides
, no_builtin_rules_flag
, print_version_flag
;
309 extern int print_directory_flag
, warn_undefined_variables_flag
;
311 extern unsigned int job_slots
;
312 extern double max_load_average
;
314 extern char *program
;
315 extern char *starting_directory
;
316 extern unsigned int makelevel
;
318 extern unsigned int commands_started
;
320 extern int handling_fatal_signal
;
323 #define DEBUGPR(msg) \
324 do if (debug_flag) { print_spaces (depth); printf (msg, file->name); \
325 fflush (stdout); } while (0)