Formerly make.h.~82~
[make.git] / make.h
blob22388f97b71892a72f0cf2063998c4be7ba6454e
1 /* Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994
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
213 /* SCO Xenix has a buggy macro definition in <string.h>. */
214 #undef strerror
216 #ifndef ANSI_STRING
217 extern char *strerror ();
218 #endif
221 #ifdef __GNUC__
222 #undef alloca
223 #define alloca(n) __builtin_alloca (n)
224 #else /* Not GCC. */
225 #ifdef HAVE_ALLOCA_H
226 #include <alloca.h>
227 #else /* Not HAVE_ALLOCA_H. */
228 #ifndef _AIX
229 extern char *alloca ();
230 #endif /* Not AIX. */
231 #endif /* HAVE_ALLOCA_H. */
232 #endif /* GCC. */
234 #ifndef iAPX286
235 #define streq(a, b) \
236 ((a) == (b) || \
237 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
238 #else
239 /* Buggy compiler can't handle this. */
240 #define streq(a, b) (strcmp ((a), (b)) == 0)
241 #endif
243 /* Add to VAR the hashing value of C, one character in a name. */
244 #define HASH(var, c) \
245 ((var += (c)), (var = ((var) << 7) + ((var) >> 20)))
247 #if defined(__GNUC__) || defined(ENUM_BITFIELDS)
248 #define ENUM_BITFIELD(bits) :bits
249 #else
250 #define ENUM_BITFIELD(bits)
251 #endif
253 extern void die ();
254 extern void message (), fatal (), error ();
255 extern void makefile_error (), makefile_fatal ();
256 extern void pfatal_with_name (), perror_with_name ();
257 extern char *savestring (), *concat ();
258 extern char *xmalloc (), *xrealloc ();
259 extern char *find_next_token (), *next_token (), *end_of_token ();
260 extern void collapse_continuations (), remove_comments ();
261 extern char *sindex (), *lindex ();
262 extern int alpha_compare ();
263 extern void print_spaces ();
264 extern struct dep *copy_dep_chain ();
265 extern char *find_percent ();
267 #ifndef NO_ARCHIVES
268 extern int ar_name ();
269 extern void ar_parse_name ();
270 extern int ar_touch ();
271 extern time_t ar_member_date ();
272 #endif
274 extern void dir_load ();
275 extern int dir_file_exists_p (), file_exists_p (), file_impossible_p ();
276 extern void file_impossible ();
277 extern char *dir_name ();
279 extern void define_default_variables ();
280 extern void set_default_suffixes (), install_default_suffix_rules ();
281 extern void install_default_implicit_rules (), count_implicit_rule_limits ();
282 extern void convert_to_pattern (), create_pattern_rule ();
284 extern void build_vpath_lists (), construct_vpath_list ();
285 extern int vpath_search ();
287 extern void construct_include_path ();
288 extern void uniquize_deps ();
290 extern int update_goal_chain ();
291 extern void notice_finished_file ();
293 extern void user_access (), make_access (), child_access ();
296 #ifdef HAVE_VFORK_H
297 #include <vfork.h>
298 #endif
300 #if !defined (__GNU_LIBRARY__) && !defined (POSIX)
302 #ifdef HAVE_SIGSETMASK
303 extern int sigsetmask ();
304 extern int sigblock ();
305 #endif
306 extern int kill ();
307 extern int atoi ();
308 extern long int atol ();
309 extern int unlink (), stat (), fstat ();
310 extern int pipe (), close (), read (), write (), open ();
311 extern long int lseek ();
313 #endif /* Not GNU C library or POSIX. */
315 #ifdef HAVE_GETCWD
316 extern char *getcwd ();
317 #else
318 extern char *getwd ();
319 #define getcwd(buf, len) getwd (buf)
320 #endif
322 extern char **environ;
324 extern char *reading_filename;
325 extern unsigned int *reading_lineno_ptr;
327 extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag;
328 extern int debug_flag, print_data_base_flag, question_flag, touch_flag;
329 extern int env_overrides, no_builtin_rules_flag, print_version_flag;
330 extern int print_directory_flag, warn_undefined_variables_flag;
332 extern unsigned int job_slots;
333 extern double max_load_average;
335 extern char *program;
336 extern char *starting_directory;
337 extern unsigned int makelevel;
338 extern char *version_string, *remote_description;
340 extern unsigned int commands_started;
342 extern int handling_fatal_signal;
345 #define DEBUGPR(msg) \
346 do if (debug_flag) { print_spaces (depth); printf (msg, file->name); \
347 fflush (stdout); } while (0)