Formerly file.h.~6~
[make.git] / make.h
blob2581cd8c150f35c7cb6963ca33d9eb6c2c06a485
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 /* 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>
47 #include <time.h>
48 #include <errno.h>
50 #ifndef errno
51 extern int errno;
52 #endif
54 #ifndef isblank
55 #define isblank(c) ((c) == ' ' || (c) == '\t')
56 #endif
58 #ifdef HAVE_UNISTD_H
59 #include <unistd.h>
60 #ifdef _POSIX_VERSION
61 #define POSIX
62 #endif
63 #endif
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)))
69 #undef POSIX
70 #endif
72 #if !defined (POSIX) && defined (_AIX) && defined (_POSIX_SOURCE)
73 #define POSIX
74 #endif
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
83 #endif
85 #ifdef HAVE_SYS_SIGLIST
86 #ifndef SYS_SIGLIST_DECLARED
87 extern char *sys_siglist[];
88 #endif
89 #else
90 #include "signame.h"
91 #endif
93 /* Some systems do not define NSIG in <signal.h>. */
94 #ifndef NSIG
95 #ifdef _NSIG
96 #define NSIG _NSIG
97 #else
98 #define NSIG 32
99 #endif
100 #endif
102 #ifndef RETSIGTYPE
103 #define RETSIGTYPE void
104 #endif
106 #ifndef sigmask
107 #define sigmask(sig) (1 << ((sig) - 1))
108 #endif
110 #ifdef HAVE_LIMITS_H
111 #include <limits.h>
112 #endif
113 #ifdef HAVE_SYS_PARAM_H
114 #include <sys/param.h>
115 #endif
117 #ifndef PATH_MAX
118 #ifndef POSIX
119 #define PATH_MAX MAXPATHLEN
120 #endif /* Not POSIX. */
121 #endif /* No PATH_MAX. */
122 #ifndef MAXPATHLEN
123 #define MAXPATHLEN 1024
124 #endif /* No MAXPATHLEN. */
126 #ifdef PATH_MAX
127 #define GET_PATH_MAX PATH_MAX
128 #define PATH_VAR(var) char var[PATH_MAX]
129 #else
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)
134 #endif
136 #ifdef STAT_MACROS_BROKEN
137 #ifdef S_ISREG
138 #undef S_ISREG
139 #endif
140 #ifdef S_ISDIR
141 #undef S_ISDIR
142 #endif
143 #endif /* STAT_MACROS_BROKEN. */
145 #ifndef S_ISREG
146 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
147 #endif
148 #ifndef S_ISDIR
149 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
150 #endif
153 #if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__))
154 #include <stdlib.h>
155 #include <string.h>
156 #define ANSI_STRING
157 #else /* No standard headers. */
159 #ifdef HAVE_STRING_H
160 #include <string.h>
161 #define ANSI_STRING
162 #else
163 #include <strings.h>
164 #endif
165 #ifdef HAVE_MEMORY_H
166 #include <memory.h>
167 #endif
169 extern char *malloc (), *realloc ();
170 extern void free ();
172 extern void qsort ();
173 extern void abort (), exit ();
175 #endif /* Standard headers. */
177 #ifdef ANSI_STRING
179 #ifndef index
180 #define index(s, c) strchr((s), (c))
181 #endif
182 #ifndef rindex
183 #define rindex(s, c) strrchr((s), (c))
184 #endif
186 #ifndef bcmp
187 #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
188 #endif
189 #ifndef bzero
190 #define bzero(s, n) memset ((s), 0, (n))
191 #endif
192 #ifndef bcopy
193 #define bcopy(s, d, n) memcpy ((d), (s), (n))
194 #endif
196 #else /* Not ANSI_STRING. */
198 #ifndef bcmp
199 extern int bcmp ();
200 #endif
201 #ifndef bzero
202 extern void bzero ();
203 #endif
204 #ifndef bcopy
205 extern void bcopy ();
206 #endif
208 #endif /* ANSI_STRING. */
209 #undef ANSI_STRING
212 #ifdef __GNUC__
213 #undef alloca
214 #define alloca(n) __builtin_alloca (n)
215 #else /* Not GCC. */
216 #ifdef HAVE_ALLOCA_H
217 #include <alloca.h>
218 #else /* Not HAVE_ALLOCA_H. */
219 #ifndef _AIX
220 extern char *alloca ();
221 #endif /* Not AIX. */
222 #endif /* HAVE_ALLOCA_H. */
223 #endif /* GCC. */
225 #ifndef iAPX286
226 #define streq(a, b) \
227 ((a) == (b) || \
228 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
229 #else
230 /* Buggy compiler can't handle this. */
231 #define streq(a, b) (strcmp ((a), (b)) == 0)
232 #endif
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
240 #else
241 #define ENUM_BITFIELD(bits)
242 #endif
244 extern void die ();
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 ();
258 #ifndef NO_ARCHIVES
259 extern int ar_name ();
260 extern void ar_parse_name ();
261 extern int ar_touch ();
262 extern time_t ar_member_date ();
263 #endif
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 ();
287 #ifdef HAVE_VFORK_H
288 #include <vfork.h>
289 #endif
291 #if !defined (__GNU_LIBRARY__) && !defined (POSIX)
293 #ifdef HAVE_SIGSETMASK
294 extern int sigsetmask ();
295 extern int sigblock ();
296 #endif
297 extern int kill ();
298 extern int atoi ();
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. */
306 #ifdef HAVE_GETCWD
307 extern char *getcwd ();
308 #else
309 extern char *getwd ();
310 #define getcwd(buf, len) getwd (buf)
311 #endif
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)