New translation files.
[make.git] / make.h
blob7a3e536942be61c099d2b798c987003347fa56b4
1 /* Miscellaneous global declarations and portability cruft for GNU Make.
2 Copyright (C) 1988,89,90,91,92,93,94,95,96,97,99 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, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 /* AIX requires this to be the first thing in the file. */
21 #if defined (_AIX) && !defined (__GNUC__)
22 #pragma alloca
23 #endif
25 /* We use <config.h> instead of "config.h" so that a compilation
26 using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
27 (which it would do because make.h was found in $srcdir). */
28 #include <config.h>
29 #undef HAVE_CONFIG_H
30 #define HAVE_CONFIG_H 1
33 /* Use prototypes if available. */
34 #if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
35 # undef PARAMS
36 # define PARAMS(protos) protos
37 #else /* Not C++ or ANSI C. */
38 # undef PARAMS
39 # define PARAMS(protos) ()
40 #endif /* C++ or ANSI C. */
43 #include "gettext.h"
44 #define _(Text) gettext (Text)
45 #define N_(Text) gettext_noop (Text)
47 #if !HAVE_SETLOCALE
48 # define setlocale(Category, Locale) /* empty */
49 #endif
52 #ifdef CRAY
53 /* This must happen before #include <signal.h> so
54 that the declaration therein is changed. */
55 # define signal bsdsignal
56 #endif
58 /* If we're compiling for the dmalloc debugger, turn off string inlining. */
59 #if defined(HAVE_DMALLOC_H) && defined(__GNUC__)
60 # define __NO_STRING_INLINES
61 #endif
63 #define _GNU_SOURCE 1
64 #include <sys/types.h>
65 #include <sys/stat.h>
66 #include <signal.h>
67 #include <stdio.h>
68 #include <ctype.h>
69 #ifdef HAVE_SYS_TIMEB_H
70 /* SCO 3.2 "devsys 4.2" has a prototype for `ftime' in <time.h> that bombs
71 unless <sys/timeb.h> has been included first. Does every system have a
72 <sys/timeb.h>? If any does not, configure should check for it. */
73 # include <sys/timeb.h>
74 #endif
75 #include <time.h>
76 #include <errno.h>
78 #ifndef errno
79 extern int errno;
80 #endif
82 /* A shortcut for EINTR checking. Note you should be careful when negating
83 this! That might not mean what you want if EINTR is not available. */
84 #ifdef EINTR
85 # define EINTR_SET (errno == EINTR)
86 #else
87 # define EINTR_SET (0)
88 #endif
90 #ifndef isblank
91 # define isblank(c) ((c) == ' ' || (c) == '\t')
92 #endif
94 #ifdef HAVE_UNISTD_H
95 # include <unistd.h>
96 /* Ultrix's unistd.h always defines _POSIX_VERSION, but you only get
97 POSIX.1 behavior with `cc -YPOSIX', which predefines POSIX itself! */
98 # if defined (_POSIX_VERSION) && !defined (ultrix) && !defined (VMS)
99 # define POSIX 1
100 # endif
101 #endif
103 /* Some systems define _POSIX_VERSION but are not really POSIX.1. */
104 #if (defined (butterfly) || defined (__arm) || (defined (__mips) && defined (_SYSTYPE_SVR3)) || (defined (sequent) && defined (i386)))
105 # undef POSIX
106 #endif
108 #if !defined (POSIX) && defined (_AIX) && defined (_POSIX_SOURCE)
109 # define POSIX 1
110 #endif
112 #ifndef RETSIGTYPE
113 # define RETSIGTYPE void
114 #endif
116 #ifndef sigmask
117 # define sigmask(sig) (1 << ((sig) - 1))
118 #endif
120 #ifdef HAVE_LIMITS_H
121 # include <limits.h>
122 #endif
123 #ifdef HAVE_SYS_PARAM_H
124 # include <sys/param.h>
125 #endif
127 #ifndef PATH_MAX
128 # ifndef POSIX
129 # define PATH_MAX MAXPATHLEN
130 # endif
131 #endif
132 #ifndef MAXPATHLEN
133 # define MAXPATHLEN 1024
134 #endif
136 #ifdef PATH_MAX
137 # define GET_PATH_MAX PATH_MAX
138 # define PATH_VAR(var) char var[PATH_MAX]
139 #else
140 # define NEED_GET_PATH_MAX 1
141 # define GET_PATH_MAX (get_path_max ())
142 # define PATH_VAR(var) char *var = (char *) alloca (GET_PATH_MAX)
143 extern unsigned int get_path_max PARAMS ((void));
144 #endif
146 #ifndef CHAR_BIT
147 # define CHAR_BIT 8
148 #endif
150 /* Nonzero if the integer type T is signed. */
151 #define INTEGER_TYPE_SIGNED(t) ((t) -1 < 0)
153 /* The minimum and maximum values for the integer type T.
154 Use ~ (t) 0, not -1, for portability to 1's complement hosts. */
155 #define INTEGER_TYPE_MINIMUM(t) \
156 (! INTEGER_TYPE_SIGNED (t) ? (t) 0 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))
157 #define INTEGER_TYPE_MAXIMUM(t) (~ (t) 0 - INTEGER_TYPE_MINIMUM (t))
159 #ifndef CHAR_MAX
160 # define CHAR_MAX INTEGER_TYPE_MAXIMUM (char)
161 #endif
163 #ifdef STAT_MACROS_BROKEN
164 # ifdef S_ISREG
165 # undef S_ISREG
166 # endif
167 # ifdef S_ISDIR
168 # undef S_ISDIR
169 # endif
170 #endif /* STAT_MACROS_BROKEN. */
172 #ifndef S_ISREG
173 # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
174 #endif
175 #ifndef S_ISDIR
176 # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
177 #endif
179 #ifdef VMS
180 # include <types.h>
181 # include <unixlib.h>
182 # include <unixio.h>
183 # include <perror.h>
184 #endif
186 #ifndef __attribute__
187 /* This feature is available in gcc versions 2.5 and later. */
188 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
189 # define __attribute__(x)
190 # endif
191 /* The __-protected variants of `format' and `printf' attributes
192 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
193 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
194 # define __format__ format
195 # define __printf__ printf
196 # endif
197 #endif
199 #if defined (STDC_HEADERS) || defined (__GNU_LIBRARY__)
200 # include <stdlib.h>
201 # include <string.h>
202 # define ANSI_STRING 1
203 #else /* No standard headers. */
204 # ifdef HAVE_STRING_H
205 # include <string.h>
206 # define ANSI_STRING 1
207 # else
208 # include <strings.h>
209 # endif
210 # ifdef HAVE_MEMORY_H
211 # include <memory.h>
212 # endif
213 # ifdef HAVE_STDLIB_H
214 # include <stdlib.h>
215 # else
216 extern char *malloc PARAMS ((int));
217 extern char *realloc PARAMS ((char *, int));
218 extern void free PARAMS ((char *));
220 extern void abort PARAMS ((void)) __attribute__ ((noreturn));
221 extern void exit PARAMS ((int)) __attribute__ ((noreturn));
222 # endif /* HAVE_STDLIB_H. */
224 #endif /* Standard headers. */
226 #ifdef ANSI_STRING
228 # ifndef bcmp
229 # define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
230 # endif
231 # ifndef bzero
232 # define bzero(s, n) memset ((s), 0, (n))
233 # endif
234 # if defined(HAVE_MEMMOVE) && !defined(bcopy)
235 # define bcopy(s, d, n) memmove ((d), (s), (n))
236 # endif
238 #else /* Not ANSI_STRING. */
240 # ifndef HAVE_STRCHR
241 # define strchr(s, c) index((s), (c))
242 # define strrchr(s, c) rindex((s), (c))
243 # endif
245 # ifndef bcmp
246 extern int bcmp PARAMS ((const char *, const char *, int));
247 # endif
248 # ifndef bzero
249 extern void bzero PARAMS ((char *, int));
250 #endif
251 # ifndef bcopy
252 extern void bcopy PARAMS ((const char *b1, char *b2, int));
253 # endif
255 #endif /* ANSI_STRING. */
256 #undef ANSI_STRING
258 /* SCO Xenix has a buggy macro definition in <string.h>. */
259 #undef strerror
261 #if !defined(ANSI_STRING) && !defined(__DECC)
262 extern char *strerror PARAMS ((int errnum));
263 #endif
265 #ifdef __GNUC__
266 # undef alloca
267 # define alloca(n) __builtin_alloca (n)
268 #else /* Not GCC. */
269 # ifdef HAVE_ALLOCA_H
270 # include <alloca.h>
271 # else /* Not HAVE_ALLOCA_H. */
272 # ifndef _AIX
273 extern char *alloca ();
274 # endif /* Not AIX. */
275 # endif /* HAVE_ALLOCA_H. */
276 #endif /* GCC. */
278 #ifdef ST_MTIM_NSEC
279 # if HAVE_INTTYPES_H
280 # include <inttypes.h>
281 # endif
282 # define FILE_TIMESTAMP uintmax_t
283 #else
284 # define FILE_TIMESTAMP time_t
285 #endif
287 /* ISDIGIT offers the following features:
288 - Its arg may be any int or unsigned int; it need not be an unsigned char.
289 - It's guaranteed to evaluate its argument exactly once.
290 NOTE! Make relies on this behavior, don't change it!
291 - It's typically faster.
292 Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
293 only '0' through '9' are digits. Prefer ISDIGIT to isdigit() unless
294 it's important to use the locale's definition of `digit' even when the
295 host does not conform to Posix. */
296 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
298 #ifndef iAPX286
299 # define streq(a, b) \
300 ((a) == (b) || \
301 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
302 # ifdef HAVE_CASE_INSENSITIVE_FS
303 /* This is only used on Windows/DOS platforms, so we assume strcmpi(). */
304 # define strieq(a, b) \
305 ((a) == (b) \
306 || (tolower((unsigned char)*(a)) == tolower((unsigned char)*(b)) \
307 && (*(a) == '\0' || !strcmpi ((a) + 1, (b) + 1))))
308 # else
309 # define strieq(a, b) streq(a, b)
310 # endif
311 #else
312 /* Buggy compiler can't handle this. */
313 # define streq(a, b) (strcmp ((a), (b)) == 0)
314 # define strieq(a, b) (strcmp ((a), (b)) == 0)
315 #endif
316 #define strneq(a, b, l) (strncmp ((a), (b), (l)) == 0)
317 #ifdef VMS
318 extern int strcmpi (const char *,const char *);
319 #endif
321 /* Add to VAR the hashing value of C, one character in a name. */
322 #define HASH(var, c) \
323 ((var += (c)), (var = ((var) << 7) + ((var) >> 20)))
324 #ifdef HAVE_CASE_INSENSITIVE_FS /* Fold filenames */
325 # define HASHI(var, c) \
326 ((var += tolower((unsigned char)(c))), (var = ((var) << 7) + ((var) >> 20)))
327 #else
328 # define HASHI(var, c) HASH(var,c)
329 #endif
331 #if defined(__GNUC__) || defined(ENUM_BITFIELDS)
332 # define ENUM_BITFIELD(bits) :bits
333 #else
334 # define ENUM_BITFIELD(bits)
335 #endif
337 #if defined(__MSDOS__) || defined(WINDOWS32)
338 # define PATH_SEPARATOR_CHAR ';'
339 #else
340 # if defined(VMS)
341 # define PATH_SEPARATOR_CHAR ','
342 # else
343 # define PATH_SEPARATOR_CHAR ':'
344 # endif
345 #endif
347 #ifdef WINDOWS32
348 # include <fcntl.h>
349 # include <malloc.h>
350 # define pipe(p) _pipe(p, 512, O_BINARY)
351 # define kill(pid,sig) w32_kill(pid,sig)
353 extern void sync_Path_environment(void);
354 extern int kill(int pid, int sig);
355 extern int safe_stat(char *file, struct stat *sb);
356 extern char *end_of_token_w32(char *s, char stopchar);
357 extern int find_and_set_default_shell(char *token);
359 /* indicates whether or not we have Bourne shell */
360 extern int no_default_sh_exe;
362 /* is default_shell unixy? */
363 extern int unixy_shell;
364 #endif /* WINDOWS32 */
366 struct floc
368 char *filenm;
369 unsigned long lineno;
371 #define NILF ((struct floc *)0)
374 /* Fancy processing for variadic functions in both ANSI and pre-ANSI
375 compilers. */
376 #if defined __STDC__ && __STDC__
377 extern void message (int prefix, const char *fmt, ...)
378 __attribute__ ((__format__ (__printf__, 2, 3)));
379 extern void error (const struct floc *flocp, const char *fmt, ...)
380 __attribute__ ((__format__ (__printf__, 2, 3)));
381 extern void fatal (const struct floc *flocp, const char *fmt, ...)
382 __attribute__ ((noreturn, __format__ (__printf__, 2, 3)));
383 #else
384 extern void message ();
385 extern void error ();
386 extern void fatal ();
387 #endif
389 extern void die PARAMS ((int)) __attribute__ ((noreturn));
390 extern void log_working_directory PARAMS ((int));
391 extern void pfatal_with_name PARAMS ((char *)) __attribute__ ((noreturn));
392 extern void perror_with_name PARAMS ((char *, char *));
393 extern char *savestring PARAMS ((const char *, unsigned int));
394 extern char *concat PARAMS ((char *, char *, char *));
395 extern char *xmalloc PARAMS ((unsigned int));
396 extern char *xrealloc PARAMS ((char *, unsigned int));
397 extern char *xstrdup PARAMS ((const char *));
398 extern char *find_next_token PARAMS ((char **, unsigned int *));
399 extern char *next_token PARAMS ((char *));
400 extern char *end_of_token PARAMS ((char *));
401 extern void collapse_continuations PARAMS ((char *));
402 extern void remove_comments PARAMS((char *));
403 extern char *sindex PARAMS ((const char *, unsigned int, \
404 const char *, unsigned int));
405 extern char *lindex PARAMS ((const char *, const char *, int));
406 extern int alpha_compare PARAMS ((const void *, const void *));
407 extern void print_spaces PARAMS ((unsigned int));
408 extern char *find_char_unquote PARAMS ((char *, char *, int));
409 extern char *find_percent PARAMS ((char *));
410 extern FILE *open_tmpfile PARAMS ((char **, const char *));
412 #ifndef NO_ARCHIVES
413 extern int ar_name PARAMS ((char *));
414 extern void ar_parse_name PARAMS ((char *, char **, char **));
415 extern int ar_touch PARAMS ((char *));
416 extern time_t ar_member_date PARAMS ((char *));
417 #endif
419 extern int dir_file_exists_p PARAMS ((char *, char *));
420 extern int file_exists_p PARAMS ((char *));
421 extern int file_impossible_p PARAMS ((char *));
422 extern void file_impossible PARAMS ((char *));
423 extern char *dir_name PARAMS ((char *));
425 extern void define_default_variables PARAMS ((void));
426 extern void set_default_suffixes PARAMS ((void));
427 extern void install_default_suffix_rules PARAMS ((void));
428 extern void install_default_implicit_rules PARAMS ((void));
430 extern void build_vpath_lists PARAMS ((void));
431 extern void construct_vpath_list PARAMS ((char *pattern, char *dirpath));
432 extern int vpath_search PARAMS ((char **file, FILE_TIMESTAMP *mtime_ptr));
433 extern int gpath_search PARAMS ((char *file, int len));
435 extern void construct_include_path PARAMS ((char **arg_dirs));
437 extern void user_access PARAMS ((void));
438 extern void make_access PARAMS ((void));
439 extern void child_access PARAMS ((void));
441 #ifdef HAVE_VFORK_H
442 # include <vfork.h>
443 #endif
445 /* We omit these declarations on non-POSIX systems which define _POSIX_VERSION,
446 because such systems often declare them in header files anyway. */
448 #if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION) && !defined(WINDOWS32)
450 extern long int atol ();
451 # ifndef VMS
452 extern long int lseek ();
453 # endif
455 #endif /* Not GNU C library or POSIX. */
457 #ifdef HAVE_GETCWD
458 # if !defined(VMS) && !defined(__DECC)
459 extern char *getcwd ();
460 #endif
461 #else
462 extern char *getwd ();
463 # define getcwd(buf, len) getwd (buf)
464 #endif
466 extern const struct floc *reading_file;
468 extern char **environ;
470 extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag;
471 extern int print_data_base_flag, question_flag, touch_flag;
472 extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag;
473 extern int print_version_flag, print_directory_flag;
474 extern int warn_undefined_variables_flag, posix_pedantic, not_parallel;
475 extern int clock_skew_detected;
477 /* can we run commands via 'sh -c xxx' or must we use batch files? */
478 extern int batch_mode_shell;
480 extern unsigned int job_slots;
481 extern int job_fds[2];
482 extern int job_rfd;
483 #ifndef NO_FLOAT
484 extern double max_load_average;
485 #else
486 extern int max_load_average;
487 #endif
489 extern char *program;
490 extern char *starting_directory;
491 extern unsigned int makelevel;
492 extern char *version_string, *remote_description;
494 extern unsigned int commands_started;
496 extern int handling_fatal_signal;
499 #ifndef MIN
500 #define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
501 #endif
502 #ifndef MAX
503 #define MAX(_a,_b) ((_a)>(_b)?(_a):(_b))
504 #endif
506 #ifdef VMS
507 # ifndef EXIT_FAILURE
508 # define EXIT_FAILURE 3
509 # endif
510 # ifndef EXIT_SUCCESS
511 # define EXIT_SUCCESS 1
512 # endif
513 # ifndef EXIT_TROUBLE
514 # define EXIT_TROUBLE 2
515 # endif
516 #else
517 # ifndef EXIT_FAILURE
518 # define EXIT_FAILURE 2
519 # endif
520 # ifndef EXIT_SUCCESS
521 # define EXIT_SUCCESS 0
522 # endif
523 # ifndef EXIT_TROUBLE
524 # define EXIT_TROUBLE 1
525 # endif
526 #endif
528 /* Set up heap debugging library dmalloc. */
530 #ifdef HAVE_DMALLOC_H
531 #include <dmalloc.h>
532 #endif