Thu May 9 13:20:43 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
[make.git] / make.h
blob04bc1e9ec6b1f61980eeb7717c8bccb7fe450968
1 /* Miscellaneous global declarations and portability cruft for GNU Make.
2 Copyright (C) 1988,89,90,91,92,93,94,95,96 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
32 /* Use prototypes if available. */
33 #if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
34 #undef PARAMS
35 #define PARAMS(protos) protos
36 #else /* Not C++ or ANSI C. */
37 #undef PARAMS
38 #define PARAMS(protos) ()
39 #endif /* C++ or ANSI C. */
42 #ifdef CRAY
43 /* This must happen before #include <signal.h> so
44 that the declaration therein is changed. */
45 #define signal bsdsignal
46 #endif
48 #define _GNU_SOURCE
49 #include <sys/types.h>
50 #include <sys/stat.h>
51 #include <signal.h>
52 #include <stdio.h>
53 #include <ctype.h>
54 #ifdef HAVE_SYS_TIMEB_H
55 /* SCO 3.2 "devsys 4.2" has a prototype for `ftime' in <time.h> that bombs
56 unless <sys/timeb.h> has been included first. Does every system have a
57 <sys/timeb.h>? If any does not, configure should check for it. */
58 #include <sys/timeb.h>
59 #endif
60 #include <time.h>
61 #include <errno.h>
63 #ifndef errno
64 extern int errno;
65 #endif
67 #ifndef isblank
68 #define isblank(c) ((c) == ' ' || (c) == '\t')
69 #endif
71 #ifdef HAVE_UNISTD_H
72 #include <unistd.h>
73 /* Ultrix's unistd.h always defines _POSIX_VERSION, but you only get
74 POSIX.1 behavior with `cc -YPOSIX', which predefines POSIX itself! */
75 #if defined (_POSIX_VERSION) && !defined (ultrix)
76 #define POSIX
77 #endif
78 #endif
80 /* Some systems define _POSIX_VERSION but are not really POSIX.1. */
81 #if (defined (butterfly) || defined (__arm) || (defined (__mips) && defined (_SYSTYPE_SVR3)) || (defined (sequent) && defined (i386)))
82 #undef POSIX
83 #endif
85 #if !defined (POSIX) && defined (_AIX) && defined (_POSIX_SOURCE)
86 #define POSIX
87 #endif
89 #if !defined (HAVE_SYS_SIGLIST) && defined (HAVE__SYS_SIGLIST)
90 #define sys_siglist _sys_siglist
91 #define HAVE_SYS_SIGLIST /* Now we have it. */
93 /* It was declared in <signal.h>, with who knows what type.
94 Don't declare it again and risk conflicting. */
95 #define SYS_SIGLIST_DECLARED
96 #endif
98 #ifdef HAVE_SYS_SIGLIST
99 #ifndef SYS_SIGLIST_DECLARED
100 extern char *sys_siglist[];
101 #endif
102 #else
103 #include "signame.h"
104 #endif
106 /* Some systems do not define NSIG in <signal.h>. */
107 #ifndef NSIG
108 #ifdef _NSIG
109 #define NSIG _NSIG
110 #else
111 #define NSIG 32
112 #endif
113 #endif
115 #ifndef RETSIGTYPE
116 #define RETSIGTYPE void
117 #endif
119 #ifndef sigmask
120 #define sigmask(sig) (1 << ((sig) - 1))
121 #endif
123 #ifdef HAVE_LIMITS_H
124 #include <limits.h>
125 #endif
126 #ifdef HAVE_SYS_PARAM_H
127 #include <sys/param.h>
128 #endif
130 #ifndef PATH_MAX
131 #ifndef POSIX
132 #define PATH_MAX MAXPATHLEN
133 #endif /* Not POSIX. */
134 #endif /* No PATH_MAX. */
135 #ifndef MAXPATHLEN
136 #define MAXPATHLEN 1024
137 #endif /* No MAXPATHLEN. */
139 #ifdef PATH_MAX
140 #define GET_PATH_MAX PATH_MAX
141 #define PATH_VAR(var) char var[PATH_MAX]
142 #else
143 #define NEED_GET_PATH_MAX
144 extern unsigned int get_path_max PARAMS ((void));
145 #define GET_PATH_MAX (get_path_max ())
146 #define PATH_VAR(var) char *var = (char *) alloca (GET_PATH_MAX)
147 #endif
149 #ifdef STAT_MACROS_BROKEN
150 #ifdef S_ISREG
151 #undef S_ISREG
152 #endif
153 #ifdef S_ISDIR
154 #undef S_ISDIR
155 #endif
156 #endif /* STAT_MACROS_BROKEN. */
158 #ifndef S_ISREG
159 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
160 #endif
161 #ifndef S_ISDIR
162 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
163 #endif
165 #ifdef VMS
166 #include <stdio.h>
167 #include <types.h>
168 #include <unixlib.h>
169 #include <unixio.h>
170 #include <errno.h>
171 #include <perror.h>
172 #endif
174 #if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__) || defined(VMS))
175 #include <stdlib.h>
176 #include <string.h>
177 #define ANSI_STRING
178 #else /* No standard headers. */
180 #ifdef HAVE_STRING_H
181 #include <string.h>
182 #define ANSI_STRING
183 #else
184 #include <strings.h>
185 #endif
186 #ifdef HAVE_MEMORY_H
187 #include <memory.h>
188 #endif
190 extern char *malloc PARAMS ((int));
191 extern char *realloc PARAMS ((char *, int));
192 extern void free PARAMS ((char *));
194 extern void abort PARAMS ((void));
195 extern void exit PARAMS ((int));
197 #endif /* Standard headers. */
199 #ifdef ANSI_STRING
201 #ifndef index
202 #define index(s, c) strchr((s), (c))
203 #endif
204 #ifndef rindex
205 #define rindex(s, c) strrchr((s), (c))
206 #endif
208 #ifndef bcmp
209 #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
210 #endif
211 #ifndef bzero
212 #define bzero(s, n) memset ((s), 0, (n))
213 #endif
214 #ifndef bcopy
215 #define bcopy(s, d, n) memcpy ((d), (s), (n))
216 #endif
218 #else /* Not ANSI_STRING. */
220 #ifndef bcmp
221 extern int bcmp ();
222 #endif
223 #ifndef bzero
224 extern void bzero ();
225 #endif
226 #ifndef bcopy
227 extern void bcopy ();
228 #endif
230 #endif /* ANSI_STRING. */
231 #undef ANSI_STRING
233 /* SCO Xenix has a buggy macro definition in <string.h>. */
234 #undef strerror
236 #if !defined(ANSI_STRING) && !defined(__DECC)
237 extern char *strerror PARAMS ((int errnum));
238 #endif
241 #ifdef __GNUC__
242 #undef alloca
243 #define alloca(n) __builtin_alloca (n)
244 #else /* Not GCC. */
245 #ifdef HAVE_ALLOCA_H
246 #include <alloca.h>
247 #else /* Not HAVE_ALLOCA_H. */
248 #ifndef _AIX
249 extern char *alloca ();
250 #endif /* Not AIX. */
251 #endif /* HAVE_ALLOCA_H. */
252 #endif /* GCC. */
254 #ifndef iAPX286
255 #define streq(a, b) \
256 ((a) == (b) || \
257 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
258 #else
259 /* Buggy compiler can't handle this. */
260 #define streq(a, b) (strcmp ((a), (b)) == 0)
261 #endif
263 /* Add to VAR the hashing value of C, one character in a name. */
264 #define HASH(var, c) \
265 ((var += (c)), (var = ((var) << 7) + ((var) >> 20)))
267 #if defined(__GNUC__) || defined(ENUM_BITFIELDS)
268 #define ENUM_BITFIELD(bits) :bits
269 #else
270 #define ENUM_BITFIELD(bits)
271 #endif
273 #ifdef __MSDOS__
274 #define PATH_SEPARATOR_CHAR ';'
275 #else
276 #define PATH_SEPARATOR_CHAR ':'
277 #endif
279 extern void die ();
280 extern void message ();
281 extern void fatal ();
282 extern void error ();
283 extern void log_working_directory ();
284 extern void makefile_error ();
285 extern void makefile_fatal ();
286 extern void pfatal_with_name ();
287 extern void perror_with_name ();
288 extern char *savestring ();
289 extern char *concat ();
290 extern char *xmalloc ();
291 extern char *xrealloc ();
292 extern char *find_next_token ();
293 extern char *next_token ();
294 extern char *end_of_token ();
295 extern void collapse_continuations ();
296 extern void remove_comments ();
297 extern char *sindex ();
298 extern char *lindex ();
299 extern int alpha_compare ();
300 extern void print_spaces ();
301 extern struct dep *copy_dep_chain ();
302 extern char *find_char_unquote ();
303 extern char *find_percent ();
305 #ifndef NO_ARCHIVES
306 extern int ar_name ();
307 extern void ar_parse_name ();
308 extern int ar_touch ();
309 extern time_t ar_member_date ();
310 #endif
312 extern void dir_load ();
313 extern int dir_file_exists_p ();
314 extern int file_exists_p ();
315 extern int file_impossible_p ();
316 extern void file_impossible ();
317 extern char *dir_name ();
319 extern void define_default_variables ();
320 extern void set_default_suffixes ();
321 extern void install_default_suffix_rules ();
322 extern void install_default_implicit_rules ();
323 extern void count_implicit_rule_limits ();
324 extern void convert_to_pattern ();
325 extern void create_pattern_rule ();
327 extern void build_vpath_lists ();
328 extern void construct_vpath_list ();
329 extern int vpath_search ();
331 extern void construct_include_path ();
332 extern void uniquize_deps ();
334 extern int update_goal_chain ();
335 extern void notice_finished_file ();
337 extern void user_access ();
338 extern void make_access ();
339 extern void child_access ();
341 #ifdef HAVE_VFORK_H
342 #include <vfork.h>
343 #endif
345 /* We omit these declarations on non-POSIX systems which define _POSIX_VERSION,
346 because such systems often declare the in header files anyway. */
348 #if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION)
350 extern long int atol ();
351 #ifndef VMS
352 extern long int lseek ();
353 #endif
355 #endif /* Not GNU C library or POSIX. */
357 #ifdef HAVE_GETCWD
358 extern char *getcwd ();
359 #ifdef VMS
360 extern char *getwd PARAMS ((char *));
361 #endif
362 #else
363 extern char *getwd ();
364 #define getcwd(buf, len) getwd (buf)
365 #endif
367 extern char **environ;
369 extern char *reading_filename;
370 extern unsigned int *reading_lineno_ptr;
372 extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag;
373 extern int debug_flag, print_data_base_flag, question_flag, touch_flag;
374 extern int env_overrides, no_builtin_rules_flag, print_version_flag;
375 extern int print_directory_flag, warn_undefined_variables_flag;
376 extern int posix_pedantic;
378 extern unsigned int job_slots;
379 extern double max_load_average;
381 extern char *program;
382 extern char *starting_directory;
383 extern unsigned int makelevel;
384 extern char *version_string, *remote_description;
386 extern unsigned int commands_started;
388 extern int handling_fatal_signal;
391 #define DEBUGPR(msg) \
392 do if (debug_flag) { print_spaces (depth); printf (msg, file->name); \
393 fflush (stdout); } while (0)
395 #ifdef VMS
396 # ifndef EXIT_FAILURE
397 # define EXIT_FAILURE 3
398 # endif
399 # ifndef EXIT_SUCCESS
400 # define EXIT_SUCCESS 1
401 # endif
402 # ifndef EXIT_TROUBLE
403 # define EXIT_TROUBLE 2
404 # endif
405 #else
406 # ifndef EXIT_FAILURE
407 # define EXIT_FAILURE 2
408 # endif
409 # ifndef EXIT_SUCCESS
410 # define EXIT_SUCCESS 0
411 # endif
412 # ifndef EXIT_TROUBLE
413 # define EXIT_TROUBLE 1
414 # endif
415 #endif