1 /* Definitions of dependency data structures for GNU Make.
2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
4 2010 Free Software Foundation, Inc.
5 This file is part of GNU Make.
6 
7 GNU Make is free software; you can redistribute it and/or modify it under the
8 terms of the GNU General Public License as published by the Free Software
9 Foundation; either version 3 of the License, or (at your option) any later
10 version.
11 
12 GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License along with
17 this program.  If not, see <http://www.gnu.org/licenses/>.  */
18 
19 /* Flag bits for the second argument to `read_makefile'.
20    These flags are saved in the `changed' field of each
21    `struct dep' in the chain returned by `read_all_makefiles'.  */
22 
23 #define RM_NO_DEFAULT_GOAL	(1 << 0) /* Do not set default goal.  */
24 #define RM_INCLUDED		(1 << 1) /* Search makefile search path.  */
25 #define RM_DONTCARE		(1 << 2) /* No error if it doesn't exist.  */
26 #define RM_NO_TILDE		(1 << 3) /* Don't expand ~ in file name.  */
27 #define RM_NOFLAG		0
28 
29 /* Structure representing one dependency of a file.
30    Each struct file's `deps' points to a chain of these,
31    chained through the `next'. `stem' is the stem for this
32    dep line of static pattern rule or NULL.
33 
34    Note that the first two words of this match a struct nameseq.  */
35 
36 struct dep
37   {
38     struct dep *next;
39     const char *name;
40     const char *stem;
41     struct file *file;
42     unsigned int changed : 8;
43     unsigned int ignore_mtime : 1;
44     unsigned int staticpattern : 1;
45     unsigned int need_2nd_expansion : 1;
46     unsigned int dontcare : 1;
47 
48 #ifdef CONFIG_WITH_INCLUDEDEP
49     unsigned int includedep : 1;
50 #endif
51   };
52 
53 
54 /* Structure used in chains of names, for parsing and globbing.  */
55 
56 struct nameseq
57   {
58     struct nameseq *next;
59     const char *name;
60   };
61 
62 
63 #define PARSEFS_NONE    (0x0000)
64 #define PARSEFS_NOSTRIP (0x0001)
65 #define PARSEFS_NOAR    (0x0002)
66 #define PARSEFS_NOGLOB  (0x0004)
67 #define PARSEFS_EXISTS  (0x0008)
68 #define PARSEFS_NOCACHE (0x0010)
69 
70 #ifndef CONFIG_WITH_ALLOC_CACHES
71 #define PARSE_FILE_SEQ(_s,_t,_c,_p,_f) \
72             (_t *)parse_file_seq ((_s),sizeof (_t),(_c),(_p),(_f))
73 #else
74 # define PARSE_FILE_SEQ(_s,_t,_c,_p,_f) \
75             (_t *)parse_file_seq ((_s),sizeof (_t),(_c),(_p),(_f), \
76                                   &PARSE_FILE_SEQ_IGNORE_ ## _t ## _cache)
77 # define PARSE_FILE_SEQ_IGNORE_struct
78 #endif
79 
80 #ifdef VMS
81 void *parse_file_seq ();
82 #else
83 void *parse_file_seq (char **stringp, unsigned int size,
84                       int stopchar, const char *prefix, int flags
85                       IF_WITH_ALLOC_CACHES_PARAM(struct alloccache *cache));
86 #endif
87 
88 char *tilde_expand (const char *name);
89 
90 #ifndef NO_ARCHIVES
91 struct nameseq *ar_glob (const char *arname, const char *member_pattern, unsigned int size);
92 #endif
93 
94 #define dep_name(d)     ((d)->name == 0 ? (d)->file->name : (d)->name)
95 
96 
97 #ifndef CONFIG_WITH_ALLOC_CACHES
98 #define alloc_dep()     (xcalloc (sizeof (struct dep)))
99 #define free_ns(_n)     free (_n)
100 #define free_dep(_d)    free_ns (_d)
101 #else
102 #define alloc_dep()     alloccache_calloc (&dep_cache)
103 #define free_ns(_n)     alloccache_free (&nameseq_cache, _n)
104 #define free_dep(_d)    alloccache_free (&dep_cache, _d)
105 #endif
106 
107 struct dep *copy_dep_chain (const struct dep *d);
108 void free_dep_chain (struct dep *d);
109 void free_ns_chain (struct nameseq *n);
110 struct dep *read_all_makefiles (const char **makefiles);
111 void eval_buffer (char *buffer IF_WITH_VALUE_LENGTH(COMMA char *eos));
112 int update_goal_chain (struct dep *goals);
113 
114 #ifdef CONFIG_WITH_INCLUDEDEP
115 /* incdep.c */
116 enum incdep_op { incdep_read_it, incdep_queue, incdep_flush };
117 void eval_include_dep (const char *name, struct floc *f, enum incdep_op op);
118 void incdep_flush_and_term (void);
119 #endif
120 
121