source: trunk/third/gmake/make.h @ 15972

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