Formerly commands.c.~20~
[make.git] / make.h
blobdfacb84b561dce4d39988ab0f94a00919cbc4693
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 /* 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). */
27 #include <config.h>
28 #undef HAVE_CONFIG_H
29 #define HAVE_CONFIG_H
31 #ifdef CRAY
32 /* This must happen before #include <signal.h> so
33 that the declaration therein is changed. */
34 #define signal bsdsignal
35 #endif
37 #define _GNU_SOURCE
38 #include <sys/types.h>
39 #include <sys/stat.h>
40 #include <signal.h>
41 #include <stdio.h>
42 #include <ctype.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>
48 #endif
49 #include <time.h>
50 #include <errno.h>
52 #ifndef errno
53 extern int errno;
54 #endif
56 #ifndef isblank
57 #define isblank(c) ((c) == ' ' || (c) == '\t')
58 #endif
60 #ifdef HAVE_UNISTD_H
61 #include <unistd.h>
62 #ifdef _POSIX_VERSION
63 #define POSIX
64 #endif
65 #endif
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)))
71 #undef POSIX
72 #endif
74 #if !defined (POSIX) && defined (_AIX) && defined (_POSIX_SOURCE)
75 #define POSIX
76 #endif
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
85 #endif
87 #ifdef HAVE_SYS_SIGLIST
88 #ifndef SYS_SIGLIST_DECLARED
89 extern char *sys_siglist[];
90 #endif
91 #else
92 #include "signame.h"
93 #endif
95 /* Some systems do not define NSIG in <signal.h>. */
96 #ifndef NSIG
97 #ifdef _NSIG
98 #define NSIG _NSIG
99 #else
100 #define NSIG 32
101 #endif
102 #endif
104 #ifndef RETSIGTYPE
105 #define RETSIGTYPE void
106 #endif
108 #ifndef sigmask
109 #define sigmask(sig) (1 << ((sig) - 1))
110 #endif
112 #ifdef HAVE_LIMITS_H
113 #include <limits.h>
114 #endif
115 #ifdef HAVE_SYS_PARAM_H
116 #include <sys/param.h>
117 #endif
119 #ifndef PATH_MAX
120 #ifndef POSIX
121 #define PATH_MAX MAXPATHLEN
122 #endif /* Not POSIX. */
123 #endif /* No PATH_MAX. */
124 #ifndef MAXPATHLEN
125 #define MAXPATHLEN 1024
126 #endif /* No MAXPATHLEN. */
128 #ifdef PATH_MAX
129 #define GET_PATH_MAX PATH_MAX
130 #define PATH_VAR(var) char var[PATH_MAX]
131 #else
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)
136 #endif
138 #ifdef STAT_MACROS_BROKEN
139 #ifdef S_ISREG
140 #undef S_ISREG
141 #endif
142 #ifdef S_ISDIR
143 #undef S_ISDIR
144 #endif
145 #endif /* STAT_MACROS_BROKEN. */
147 #ifndef S_ISREG
148 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
149 #endif
150 #ifndef S_ISDIR
151 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
152 #endif
155 #if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__))
156 #include <stdlib.h>
157 #include <string.h>
158 #define ANSI_STRING
159 #else /* No standard headers. */
161 #ifdef HAVE_STRING_H
162 #include <string.h>
163 #define ANSI_STRING
164 #else
165 #include <strings.h>
166 #endif
167 #ifdef HAVE_MEMORY_H
168 #include <memory.h>
169 #endif
171 extern char *malloc (), *realloc ();
172 extern void free ();
174 extern void qsort ();
175 extern void abort (), exit ();
177 #endif /* Standard headers. */
179 #ifdef ANSI_STRING
181 #ifndef index
182 #define index(s, c) strchr((s), (c))
183 #endif
184 #ifndef rindex
185 #define rindex(s, c) strrchr((s), (c))
186 #endif
188 #ifndef bcmp
189 #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
190 #endif
191 #ifndef bzero
192 #define bzero(s, n) memset ((s), 0, (n))
193 #endif
194 #ifndef bcopy
195 #define bcopy(s, d, n) memcpy ((d), (s), (n))
196 #endif
198 #else /* Not ANSI_STRING. */
200 #ifndef bcmp
201 extern int bcmp ();
202 #endif
203 #ifndef bzero
204 extern void bzero ();
205 #endif
206 #ifndef bcopy
207 extern void bcopy ();
208 #endif
210 #endif /* ANSI_STRING. */
211 #undef ANSI_STRING
214 #ifdef __GNUC__
215 #undef alloca
216 #define alloca(n) __builtin_alloca (n)
217 #else /* Not GCC. */
218 #ifdef HAVE_ALLOCA_H
219 #include <alloca.h>
220 #else /* Not HAVE_ALLOCA_H. */
221 #ifndef _AIX
222 extern char *alloca ();
223 #endif /* Not AIX. */
224 #endif /* HAVE_ALLOCA_H. */
225 #endif /* GCC. */
227 #ifndef iAPX286
228 #define streq(a, b) \
229 ((a) == (b) || \
230 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
231 #else
232 /* Buggy compiler can't handle this. */
233 #define streq(a, b) (strcmp ((a), (b)) == 0)
234 #endif
236 /* Add to VAR the hashing value of C, one character in a name. */
237 #define HASH(var, c) \
238 ((var += (c)), (var = ((var) << 7) + ((var) >> 20)))
240 #if defined(__GNUC__) || defined(ENUM_BITFIELDS)
241 #define ENUM_BITFIELD(bits) :bits
242 #else
243 #define ENUM_BITFIELD(bits)
244 #endif
246 extern void die ();
247 extern void message (), fatal (), error ();
248 extern void makefile_error (), makefile_fatal ();
249 extern void pfatal_with_name (), perror_with_name ();
250 extern char *savestring (), *concat ();
251 extern char *xmalloc (), *xrealloc ();
252 extern char *find_next_token (), *next_token (), *end_of_token ();
253 extern void collapse_continuations (), remove_comments ();
254 extern char *sindex (), *lindex ();
255 extern int alpha_compare ();
256 extern void print_spaces ();
257 extern struct dep *copy_dep_chain ();
258 extern char *find_percent ();
260 #ifndef NO_ARCHIVES
261 extern int ar_name ();
262 extern void ar_parse_name ();
263 extern int ar_touch ();
264 extern time_t ar_member_date ();
265 #endif
267 extern void dir_load ();
268 extern int dir_file_exists_p (), file_exists_p (), file_impossible_p ();
269 extern void file_impossible ();
270 extern char *dir_name ();
272 extern void define_default_variables ();
273 extern void set_default_suffixes (), install_default_suffix_rules ();
274 extern void install_default_implicit_rules (), count_implicit_rule_limits ();
275 extern void convert_to_pattern (), create_pattern_rule ();
277 extern void build_vpath_lists (), construct_vpath_list ();
278 extern int vpath_search ();
280 extern void construct_include_path ();
281 extern void uniquize_deps ();
283 extern int update_goal_chain ();
284 extern void notice_finished_file ();
286 extern void user_access (), make_access (), child_access ();
289 #ifdef HAVE_VFORK_H
290 #include <vfork.h>
291 #endif
293 #if !defined (__GNU_LIBRARY__) && !defined (POSIX)
295 #ifdef HAVE_SIGSETMASK
296 extern int sigsetmask ();
297 extern int sigblock ();
298 #endif
299 extern int kill ();
300 extern int atoi ();
301 extern long int atol ();
302 extern int unlink (), stat (), fstat ();
303 extern int pipe (), close (), read (), write (), open ();
304 extern long int lseek ();
306 #endif /* Not GNU C library or POSIX. */
308 #ifdef HAVE_GETCWD
309 extern char *getcwd ();
310 #else
311 extern char *getwd ();
312 #define getcwd(buf, len) getwd (buf)
313 #endif
315 extern char **environ;
317 extern char *reading_filename;
318 extern unsigned int *reading_lineno_ptr;
320 extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag;
321 extern int debug_flag, print_data_base_flag, question_flag, touch_flag;
322 extern int env_overrides, no_builtin_rules_flag, print_version_flag;
323 extern int print_directory_flag, warn_undefined_variables_flag;
325 extern unsigned int job_slots;
326 extern double max_load_average;
328 extern char *program;
329 extern char *starting_directory;
330 extern unsigned int makelevel;
331 extern char *version_string, *remote_description;
333 extern unsigned int commands_started;
335 extern int handling_fatal_signal;
338 #define DEBUGPR(msg) \
339 do if (debug_flag) { print_spaces (depth); printf (msg, file->name); \
340 fflush (stdout); } while (0)