Formerly read.c.~57~
[make.git] / make.h
blobd987e4e46b62c72df7ede14c87b73312d7e3c44a
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 #if !defined (HAVE_SYS_SIGLIST) && defined (HAVE__SYS_SIGLIST)
59 #define sys_siglist _sys_siglist
60 #define HAVE_SYS_SIGLIST /* Now we have it. */
62 /* It was declared in <signal.h>, with who knows what type.
63 Don't declare it again and risk conflicting. */
64 #define SYS_SIGLIST_DECLARED
65 #endif
67 #ifdef HAVE_SYS_SIGLIST
68 #ifndef SYS_SIGLIST_DECLARED
69 extern char *sys_siglist[];
70 #endif
71 #else
72 #include "signame.h"
73 #endif
75 /* Some systems do not define NSIG in <signal.h>. */
76 #ifndef NSIG
77 #ifdef _NSIG
78 #define NSIG _NSIG
79 #else
80 #define NSIG 32
81 #endif
82 #endif
84 #ifndef RETSIGTYPE
85 #define RETSIGTYPE void
86 #endif
88 #ifndef sigmask
89 #define sigmask(sig) (1 << ((sig) - 1))
90 #endif
92 #ifdef HAVE_LIMITS_H
93 #include <limits.h>
94 #endif
95 #ifdef HAVE_SYS_PARAM_H
96 #include <sys/param.h>
97 #endif
99 #ifndef PATH_MAX
100 #ifndef POSIX
101 #define PATH_MAX MAXPATHLEN
102 #endif /* Not POSIX. */
103 #endif /* No PATH_MAX. */
104 #ifndef MAXPATHLEN
105 #define MAXPATHLEN 1024
106 #endif /* No MAXPATHLEN. */
108 #ifdef PATH_MAX
109 #define GET_PATH_MAX PATH_MAX
110 #define PATH_VAR(var) char var[PATH_MAX]
111 #else
112 #define NEED_GET_PATH_MAX
113 extern unsigned int get_path_max ();
114 #define GET_PATH_MAX (get_path_max ())
115 #define PATH_VAR(var) char *var = (char *) alloca (GET_PATH_MAX)
116 #endif
118 #ifdef uts
119 #ifdef S_ISREG
120 #undef S_ISREG
121 #endif
122 #ifdef S_ISDIR
123 #undef S_ISDIR
124 #endif
125 #endif /* uts. */
127 #ifndef S_ISREG
128 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
129 #endif
130 #ifndef S_ISDIR
131 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
132 #endif
135 #if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__))
136 #include <stdlib.h>
137 #include <string.h>
138 #define ANSI_STRING
139 #else /* No standard headers. */
141 #ifdef HAVE_STRING_H
142 #include <string.h>
143 #define ANSI_STRING
144 #else
145 #include <strings.h>
146 #endif
147 #ifdef HAVE_MEMORY_H
148 #include <memory.h>
149 #endif
151 extern char *malloc (), *realloc ();
152 extern void free ();
154 extern void qsort ();
155 extern void abort (), exit ();
157 #endif /* Standard headers. */
159 #ifdef ANSI_STRING
161 #ifndef index
162 #define index(s, c) strchr((s), (c))
163 #endif
164 #ifndef rindex
165 #define rindex(s, c) strrchr((s), (c))
166 #endif
168 #ifndef bcmp
169 #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
170 #endif
171 #ifndef bzero
172 #define bzero(s, n) memset ((s), 0, (n))
173 #endif
174 #ifndef bcopy
175 #define bcopy(s, d, n) memcpy ((d), (s), (n))
176 #endif
178 #else /* Not ANSI_STRING. */
180 #ifndef bcmp
181 extern int bcmp ();
182 #endif
183 #ifndef bzero
184 extern void bzero ();
185 #endif
186 #ifndef bcopy
187 extern void bcopy ();
188 #endif
190 #endif /* ANSI_STRING. */
191 #undef ANSI_STRING
194 #ifdef __GNUC__
195 #undef alloca
196 #define alloca(n) __builtin_alloca (n)
197 #else /* Not GCC. */
198 #ifdef HAVE_ALLOCA_H
199 #include <alloca.h>
200 #else /* Not HAVE_ALLOCA_H. */
201 #ifndef _AIX
202 extern char *alloca ();
203 #endif /* Not AIX. */
204 #endif /* HAVE_ALLOCA_H. */
205 #endif /* GCC. */
207 #ifndef iAPX286
208 #define streq(a, b) \
209 ((a) == (b) || \
210 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
211 #else
212 /* Buggy compiler can't handle this. */
213 #define streq(a, b) (strcmp ((a), (b)) == 0)
214 #endif
216 /* Add to VAR the hashing value of C, one character in a name. */
217 #define HASH(var, c) \
218 ((var += (c)), (var = ((var) << 7) + ((var) >> 20)))
220 #if defined(__GNUC__) || defined(ENUM_BITFIELDS)
221 #define ENUM_BITFIELD(bits) :bits
222 #else
223 #define ENUM_BITFIELD(bits)
224 #endif
226 extern void die ();
227 extern void message (), fatal (), error ();
228 extern void makefile_error (), makefile_fatal ();
229 extern void pfatal_with_name (), perror_with_name ();
230 extern char *savestring (), *concat ();
231 extern char *xmalloc (), *xrealloc ();
232 extern char *find_next_token (), *next_token (), *end_of_token ();
233 extern void collapse_continuations (), remove_comments ();
234 extern char *sindex (), *lindex ();
235 extern int alpha_compare ();
236 extern void print_spaces ();
237 extern struct dep *copy_dep_chain ();
238 extern char *find_percent ();
240 #ifndef NO_ARCHIVES
241 extern int ar_name ();
242 extern void ar_parse_name ();
243 extern int ar_touch ();
244 extern time_t ar_member_date ();
245 #endif
247 extern void dir_load ();
248 extern int dir_file_exists_p (), file_exists_p (), file_impossible_p ();
249 extern void file_impossible ();
250 extern char *dir_name ();
252 extern void define_default_variables ();
253 extern void set_default_suffixes (), install_default_implicit_rules ();
254 extern void convert_to_pattern (), count_implicit_rule_limits ();
255 extern void create_pattern_rule ();
257 extern void build_vpath_lists (), construct_vpath_list ();
258 extern int vpath_search ();
260 extern void construct_include_path ();
261 extern void uniquize_deps ();
263 extern int update_goal_chain ();
264 extern void notice_finished_file ();
266 extern void user_access (), make_access (), child_access ();
269 #ifdef HAVE_VFORK_H
270 #include <vfork.h>
271 #endif
273 #if !defined (__GNU_LIBRARY__) && !defined (POSIX)
275 #ifdef HAVE_SIGSETMASK
276 extern int sigsetmask ();
277 extern int sigblock ();
278 #endif
279 extern int kill ();
280 extern int atoi ();
281 extern long int atol ();
282 extern int unlink (), stat (), fstat ();
283 extern int pipe (), close (), read (), write (), open ();
284 extern long int lseek ();
286 #endif /* Not GNU C library or POSIX. */
288 #ifdef HAVE_GETCWD
289 extern char *getcwd ();
290 #else
291 extern char *getwd ();
292 #define getcwd(buf, len) getwd (buf)
293 #endif
295 extern char **environ;
297 extern char *reading_filename;
298 extern unsigned int *reading_lineno_ptr;
300 extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag;
301 extern int debug_flag, print_data_base_flag, question_flag, touch_flag;
302 extern int env_overrides, no_builtin_rules_flag, print_version_flag;
303 extern int print_directory_flag;
305 extern unsigned int job_slots;
306 extern double max_load_average;
308 extern char *program;
309 extern char *starting_directory;
310 extern unsigned int makelevel;
312 extern unsigned int commands_started;
315 #define DEBUGPR(msg) \
316 do if (debug_flag) { print_spaces (depth); printf (msg, file->name); \
317 fflush (stdout); } while (0)