Formerly rule.c.~15~
[make.git] / make.h
blob8475efa3cc4b6b6ce2f3d57736eee78f31a61121
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)
8 any later version.
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__)
21 #pragma alloca
22 #endif
24 #include "config.h"
25 #undef HAVE_CONFIG_H
26 #define HAVE_CONFIG_H
28 #ifdef CRAY
29 /* This must happen before #include <signal.h> so
30 that the declaration therein is changed. */
31 #define signal bsdsignal
32 #endif
34 #define _GNU_SOURCE
35 #include <sys/types.h>
36 #include <sys/stat.h>
37 #include <signal.h>
38 #include <stdio.h>
39 #include <ctype.h>
40 #include <time.h>
41 #include <errno.h>
43 #ifndef errno
44 extern int errno;
45 #endif
47 #ifndef isblank
48 #define isblank(c) ((c) == ' ' || (c) == '\t')
49 #endif
51 #ifdef HAVE_UNISTD_H
52 #include <unistd.h>
53 #ifdef _POSIX_VERSION
54 #define POSIX
55 #endif
56 #endif
58 /* Some systems define _POSIX_VERSION but are not really POSIX.1. */
59 #if (defined (butterfly) || \
60 (defined (__mips) && defined (_SYSTYPE_SVR3)))
61 #undef POSIX
62 #endif
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
71 #endif
73 #ifdef HAVE_SYS_SIGLIST
74 #ifndef SYS_SIGLIST_DECLARED
75 extern char *sys_siglist[];
76 #endif
77 #else
78 #include "signame.h"
79 #endif
81 /* Some systems do not define NSIG in <signal.h>. */
82 #ifndef NSIG
83 #ifdef _NSIG
84 #define NSIG _NSIG
85 #else
86 #define NSIG 32
87 #endif
88 #endif
90 #ifndef RETSIGTYPE
91 #define RETSIGTYPE void
92 #endif
94 #ifndef sigmask
95 #define sigmask(sig) (1 << ((sig) - 1))
96 #endif
98 #ifdef HAVE_LIMITS_H
99 #include <limits.h>
100 #endif
101 #ifdef HAVE_SYS_PARAM_H
102 #include <sys/param.h>
103 #endif
105 #ifndef PATH_MAX
106 #ifndef POSIX
107 #define PATH_MAX MAXPATHLEN
108 #endif /* Not POSIX. */
109 #endif /* No PATH_MAX. */
110 #ifndef MAXPATHLEN
111 #define MAXPATHLEN 1024
112 #endif /* No MAXPATHLEN. */
114 #ifdef PATH_MAX
115 #define GET_PATH_MAX PATH_MAX
116 #define PATH_VAR(var) char var[PATH_MAX]
117 #else
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)
122 #endif
124 #ifdef uts
125 #ifdef S_ISREG
126 #undef S_ISREG
127 #endif
128 #ifdef S_ISDIR
129 #undef S_ISDIR
130 #endif
131 #endif /* uts. */
133 #ifndef S_ISREG
134 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
135 #endif
136 #ifndef S_ISDIR
137 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
138 #endif
141 #if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__))
142 #include <stdlib.h>
143 #include <string.h>
144 #define ANSI_STRING
145 #else /* No standard headers. */
147 #ifdef HAVE_STRING_H
148 #include <string.h>
149 #define ANSI_STRING
150 #else
151 #include <strings.h>
152 #endif
153 #ifdef HAVE_MEMORY_H
154 #include <memory.h>
155 #endif
157 extern char *malloc (), *realloc ();
158 extern void free ();
160 extern void qsort ();
161 extern void abort (), exit ();
163 #endif /* Standard headers. */
165 #ifdef ANSI_STRING
167 #ifndef index
168 #define index(s, c) strchr((s), (c))
169 #endif
170 #ifndef rindex
171 #define rindex(s, c) strrchr((s), (c))
172 #endif
174 #ifndef bcmp
175 #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
176 #endif
177 #ifndef bzero
178 #define bzero(s, n) memset ((s), 0, (n))
179 #endif
180 #ifndef bcopy
181 #define bcopy(s, d, n) memcpy ((d), (s), (n))
182 #endif
184 #else /* Not ANSI_STRING. */
186 #ifndef bcmp
187 extern int bcmp ();
188 #endif
189 #ifndef bzero
190 extern void bzero ();
191 #endif
192 #ifndef bcopy
193 extern void bcopy ();
194 #endif
196 #endif /* ANSI_STRING. */
197 #undef ANSI_STRING
200 #ifdef __GNUC__
201 #undef alloca
202 #define alloca(n) __builtin_alloca (n)
203 #else /* Not GCC. */
204 #ifdef HAVE_ALLOCA_H
205 #include <alloca.h>
206 #else /* Not HAVE_ALLOCA_H. */
207 #ifndef _AIX
208 extern char *alloca ();
209 #endif /* Not AIX. */
210 #endif /* HAVE_ALLOCA_H. */
211 #endif /* GCC. */
213 #ifndef iAPX286
214 #define streq(a, b) \
215 ((a) == (b) || \
216 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
217 #else
218 /* Buggy compiler can't handle this. */
219 #define streq(a, b) (strcmp ((a), (b)) == 0)
220 #endif
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
228 #else
229 #define ENUM_BITFIELD(bits)
230 #endif
232 extern void die ();
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 ();
246 #ifndef NO_ARCHIVES
247 extern int ar_name ();
248 extern void ar_parse_name ();
249 extern int ar_touch ();
250 extern time_t ar_member_date ();
251 #endif
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 ();
275 #ifdef HAVE_VFORK_H
276 #include <vfork.h>
277 #endif
279 #if !defined (__GNU_LIBRARY__) && !defined (POSIX)
281 #ifdef HAVE_SIGSETMASK
282 extern int sigsetmask ();
283 extern int sigblock ();
284 #endif
285 extern int kill ();
286 extern int atoi ();
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. */
294 #ifdef HAVE_GETCWD
295 extern char *getcwd ();
296 #else
297 extern char *getwd ();
298 #define getcwd(buf, len) getwd (buf)
299 #endif
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)