*** empty log message ***
[make.git] / make.h
blob5c0d4c771cc52ae268f149fcc224120680508551
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 #include <time.h>
44 #include <errno.h>
46 #ifndef errno
47 extern int errno;
48 #endif
50 #ifndef isblank
51 #define isblank(c) ((c) == ' ' || (c) == '\t')
52 #endif
54 #ifdef HAVE_UNISTD_H
55 #include <unistd.h>
56 #ifdef _POSIX_VERSION
57 #define POSIX
58 #endif
59 #endif
61 /* Some systems define _POSIX_VERSION but are not really POSIX.1. */
62 #if (defined (butterfly) || \
63 (defined (__mips) && defined (_SYSTYPE_SVR3)) || \
64 (defined (sequent) && defined (i386)))
65 #undef POSIX
66 #endif
68 #if !defined (HAVE_SYS_SIGLIST) && defined (HAVE__SYS_SIGLIST)
69 #define sys_siglist _sys_siglist
70 #define HAVE_SYS_SIGLIST /* Now we have it. */
72 /* It was declared in <signal.h>, with who knows what type.
73 Don't declare it again and risk conflicting. */
74 #define SYS_SIGLIST_DECLARED
75 #endif
77 #ifdef HAVE_SYS_SIGLIST
78 #ifndef SYS_SIGLIST_DECLARED
79 extern char *sys_siglist[];
80 #endif
81 #else
82 #include "signame.h"
83 #endif
85 /* Some systems do not define NSIG in <signal.h>. */
86 #ifndef NSIG
87 #ifdef _NSIG
88 #define NSIG _NSIG
89 #else
90 #define NSIG 32
91 #endif
92 #endif
94 #ifndef RETSIGTYPE
95 #define RETSIGTYPE void
96 #endif
98 #ifndef sigmask
99 #define sigmask(sig) (1 << ((sig) - 1))
100 #endif
102 #ifdef HAVE_LIMITS_H
103 #include <limits.h>
104 #endif
105 #ifdef HAVE_SYS_PARAM_H
106 #include <sys/param.h>
107 #endif
109 #ifndef PATH_MAX
110 #ifndef POSIX
111 #define PATH_MAX MAXPATHLEN
112 #endif /* Not POSIX. */
113 #endif /* No PATH_MAX. */
114 #ifndef MAXPATHLEN
115 #define MAXPATHLEN 1024
116 #endif /* No MAXPATHLEN. */
118 #ifdef PATH_MAX
119 #define GET_PATH_MAX PATH_MAX
120 #define PATH_VAR(var) char var[PATH_MAX]
121 #else
122 #define NEED_GET_PATH_MAX
123 extern unsigned int get_path_max ();
124 #define GET_PATH_MAX (get_path_max ())
125 #define PATH_VAR(var) char *var = (char *) alloca (GET_PATH_MAX)
126 #endif
128 #ifdef STAT_MACROS_BROKEN
129 #ifdef S_ISREG
130 #undef S_ISREG
131 #endif
132 #ifdef S_ISDIR
133 #undef S_ISDIR
134 #endif
135 #endif /* STAT_MACROS_BROKEN. */
137 #ifndef S_ISREG
138 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
139 #endif
140 #ifndef S_ISDIR
141 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
142 #endif
145 #if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__))
146 #include <stdlib.h>
147 #include <string.h>
148 #define ANSI_STRING
149 #else /* No standard headers. */
151 #ifdef HAVE_STRING_H
152 #include <string.h>
153 #define ANSI_STRING
154 #else
155 #include <strings.h>
156 #endif
157 #ifdef HAVE_MEMORY_H
158 #include <memory.h>
159 #endif
161 extern char *malloc (), *realloc ();
162 extern void free ();
164 extern void qsort ();
165 extern void abort (), exit ();
167 #endif /* Standard headers. */
169 #ifdef ANSI_STRING
171 #ifndef index
172 #define index(s, c) strchr((s), (c))
173 #endif
174 #ifndef rindex
175 #define rindex(s, c) strrchr((s), (c))
176 #endif
178 #ifndef bcmp
179 #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
180 #endif
181 #ifndef bzero
182 #define bzero(s, n) memset ((s), 0, (n))
183 #endif
184 #ifndef bcopy
185 #define bcopy(s, d, n) memcpy ((d), (s), (n))
186 #endif
188 #else /* Not ANSI_STRING. */
190 #ifndef bcmp
191 extern int bcmp ();
192 #endif
193 #ifndef bzero
194 extern void bzero ();
195 #endif
196 #ifndef bcopy
197 extern void bcopy ();
198 #endif
200 #endif /* ANSI_STRING. */
201 #undef ANSI_STRING
204 #ifdef __GNUC__
205 #undef alloca
206 #define alloca(n) __builtin_alloca (n)
207 #else /* Not GCC. */
208 #ifdef HAVE_ALLOCA_H
209 #include <alloca.h>
210 #else /* Not HAVE_ALLOCA_H. */
211 #ifndef _AIX
212 extern char *alloca ();
213 #endif /* Not AIX. */
214 #endif /* HAVE_ALLOCA_H. */
215 #endif /* GCC. */
217 #ifndef iAPX286
218 #define streq(a, b) \
219 ((a) == (b) || \
220 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
221 #else
222 /* Buggy compiler can't handle this. */
223 #define streq(a, b) (strcmp ((a), (b)) == 0)
224 #endif
226 /* Add to VAR the hashing value of C, one character in a name. */
227 #define HASH(var, c) \
228 ((var += (c)), (var = ((var) << 7) + ((var) >> 20)))
230 #if defined(__GNUC__) || defined(ENUM_BITFIELDS)
231 #define ENUM_BITFIELD(bits) :bits
232 #else
233 #define ENUM_BITFIELD(bits)
234 #endif
236 extern void die ();
237 extern void message (), fatal (), error ();
238 extern void makefile_error (), makefile_fatal ();
239 extern void pfatal_with_name (), perror_with_name ();
240 extern char *savestring (), *concat ();
241 extern char *xmalloc (), *xrealloc ();
242 extern char *find_next_token (), *next_token (), *end_of_token ();
243 extern void collapse_continuations (), remove_comments ();
244 extern char *sindex (), *lindex ();
245 extern int alpha_compare ();
246 extern void print_spaces ();
247 extern struct dep *copy_dep_chain ();
248 extern char *find_percent ();
250 #ifndef NO_ARCHIVES
251 extern int ar_name ();
252 extern void ar_parse_name ();
253 extern int ar_touch ();
254 extern time_t ar_member_date ();
255 #endif
257 extern void dir_load ();
258 extern int dir_file_exists_p (), file_exists_p (), file_impossible_p ();
259 extern void file_impossible ();
260 extern char *dir_name ();
262 extern void define_default_variables ();
263 extern void set_default_suffixes (), install_default_implicit_rules ();
264 extern void convert_to_pattern (), count_implicit_rule_limits ();
265 extern void create_pattern_rule ();
267 extern void build_vpath_lists (), construct_vpath_list ();
268 extern int vpath_search ();
270 extern void construct_include_path ();
271 extern void uniquize_deps ();
273 extern int update_goal_chain ();
274 extern void notice_finished_file ();
276 extern void user_access (), make_access (), child_access ();
279 #ifdef HAVE_VFORK_H
280 #include <vfork.h>
281 #endif
283 #if !defined (__GNU_LIBRARY__) && !defined (POSIX)
285 #ifdef HAVE_SIGSETMASK
286 extern int sigsetmask ();
287 extern int sigblock ();
288 #endif
289 extern int kill ();
290 extern int atoi ();
291 extern long int atol ();
292 extern int unlink (), stat (), fstat ();
293 extern int pipe (), close (), read (), write (), open ();
294 extern long int lseek ();
296 #endif /* Not GNU C library or POSIX. */
298 #ifdef HAVE_GETCWD
299 extern char *getcwd ();
300 #else
301 extern char *getwd ();
302 #define getcwd(buf, len) getwd (buf)
303 #endif
305 extern char **environ;
307 extern char *reading_filename;
308 extern unsigned int *reading_lineno_ptr;
310 extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag;
311 extern int debug_flag, print_data_base_flag, question_flag, touch_flag;
312 extern int env_overrides, no_builtin_rules_flag, print_version_flag;
313 extern int print_directory_flag, warn_undefined_variables_flag;
315 extern unsigned int job_slots;
316 extern double max_load_average;
318 extern char *program;
319 extern char *starting_directory;
320 extern unsigned int makelevel;
322 extern unsigned int commands_started;
324 extern int handling_fatal_signal;
327 #define DEBUGPR(msg) \
328 do if (debug_flag) { print_spaces (depth); printf (msg, file->name); \
329 fflush (stdout); } while (0)