[53] | 1 | /* Definitions of dependency data structures for GNU Make.
|
---|
[3140] | 2 | Copyright (C) 1988-2016 Free Software Foundation, Inc.
|
---|
[53] | 3 | This file is part of GNU Make.
|
---|
| 4 |
|
---|
[503] | 5 | GNU Make is free software; you can redistribute it and/or modify it under the
|
---|
| 6 | terms of the GNU General Public License as published by the Free Software
|
---|
[1993] | 7 | Foundation; either version 3 of the License, or (at your option) any later
|
---|
| 8 | version.
|
---|
[53] | 9 |
|
---|
[503] | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
|
---|
| 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
---|
| 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
---|
[53] | 13 |
|
---|
[503] | 14 | You should have received a copy of the GNU General Public License along with
|
---|
[1993] | 15 | this program. If not, see <http://www.gnu.org/licenses/>. */
|
---|
[53] | 16 |
|
---|
| 17 |
|
---|
[3140] | 18 | /* Structure used in chains of names, for parsing and globbing. */
|
---|
[53] | 19 |
|
---|
[3140] | 20 | #define NAMESEQ(_t) \
|
---|
| 21 | _t *next; \
|
---|
| 22 | const char *name
|
---|
| 23 |
|
---|
| 24 | struct nameseq
|
---|
| 25 | {
|
---|
| 26 | NAMESEQ (struct nameseq);
|
---|
| 27 | };
|
---|
| 28 |
|
---|
| 29 | /* Flag bits for the second argument to 'read_makefile'.
|
---|
| 30 | These flags are saved in the 'flags' field of each
|
---|
| 31 | 'struct goaldep' in the chain returned by 'read_all_makefiles'. */
|
---|
| 32 |
|
---|
| 33 | #define RM_NO_DEFAULT_GOAL (1 << 0) /* Do not set default goal. */
|
---|
| 34 | #define RM_INCLUDED (1 << 1) /* Search makefile search path. */
|
---|
| 35 | #define RM_DONTCARE (1 << 2) /* No error if it doesn't exist. */
|
---|
| 36 | #define RM_NO_TILDE (1 << 3) /* Don't expand ~ in file name. */
|
---|
| 37 | #define RM_NOFLAG 0
|
---|
| 38 |
|
---|
[53] | 39 | /* Structure representing one dependency of a file.
|
---|
[3140] | 40 | Each struct file's 'deps' points to a chain of these, through 'next'.
|
---|
| 41 | 'stem' is the stem for this dep line of static pattern rule or NULL. */
|
---|
[53] | 42 |
|
---|
[3140] | 43 | #ifndef CONFIG_WITH_INCLUDEDEP
|
---|
| 44 | #define DEP(_t) \
|
---|
| 45 | NAMESEQ (_t); \
|
---|
| 46 | struct file *file; \
|
---|
| 47 | const char *stem; \
|
---|
| 48 | unsigned short flags : 8; \
|
---|
| 49 | unsigned short changed : 1; \
|
---|
| 50 | unsigned short ignore_mtime : 1; \
|
---|
| 51 | unsigned short staticpattern : 1; \
|
---|
| 52 | unsigned short need_2nd_expansion : 1
|
---|
| 53 | #else
|
---|
| 54 | # define DEP(_t) \
|
---|
| 55 | NAMESEQ (_t); \
|
---|
| 56 | struct file *file; \
|
---|
| 57 | const char *stem; \
|
---|
| 58 | unsigned short flags : 8; \
|
---|
| 59 | unsigned short changed : 1; \
|
---|
| 60 | unsigned short ignore_mtime : 1; \
|
---|
| 61 | unsigned short staticpattern : 1; \
|
---|
| 62 | unsigned short need_2nd_expansion : 1; \
|
---|
| 63 | unsigned short includedep : 1
|
---|
| 64 | #endif
|
---|
[53] | 65 |
|
---|
| 66 | struct dep
|
---|
| 67 | {
|
---|
[3140] | 68 | DEP (struct dep);
|
---|
[53] | 69 | };
|
---|
| 70 |
|
---|
[3140] | 71 | /* Structure representing one goal.
|
---|
| 72 | The goals to be built constitute a chain of these, chained through 'next'.
|
---|
| 73 | 'stem' is not used, but it's simpler to include and ignore it. */
|
---|
[53] | 74 |
|
---|
[3140] | 75 | struct goaldep
|
---|
[53] | 76 | {
|
---|
[3140] | 77 | DEP (struct goaldep);
|
---|
| 78 | unsigned short error;
|
---|
| 79 | floc floc;
|
---|
[53] | 80 | };
|
---|
| 81 |
|
---|
[3140] | 82 | /* Options for parsing lists of filenames. */
|
---|
[53] | 83 |
|
---|
[3140] | 84 | #define PARSEFS_NONE 0x0000
|
---|
| 85 | #define PARSEFS_NOSTRIP 0x0001
|
---|
| 86 | #define PARSEFS_NOAR 0x0002
|
---|
| 87 | #define PARSEFS_NOGLOB 0x0004
|
---|
| 88 | #define PARSEFS_EXISTS 0x0008
|
---|
| 89 | #define PARSEFS_NOCACHE 0x0010
|
---|
[2591] | 90 |
|
---|
[1863] | 91 | #ifndef CONFIG_WITH_ALLOC_CACHES
|
---|
[2591] | 92 | #define PARSE_FILE_SEQ(_s,_t,_c,_p,_f) \
|
---|
| 93 | (_t *)parse_file_seq ((_s),sizeof (_t),(_c),(_p),(_f))
|
---|
[3140] | 94 | #define PARSE_SIMPLE_SEQ(_s,_t) \
|
---|
| 95 | (_t *)parse_file_seq ((_s),sizeof (_t),MAP_NUL,NULL,PARSEFS_NONE)
|
---|
[1863] | 96 | #else
|
---|
[2591] | 97 | # define PARSE_FILE_SEQ(_s,_t,_c,_p,_f) \
|
---|
| 98 | (_t *)parse_file_seq ((_s),sizeof (_t),(_c),(_p),(_f), \
|
---|
| 99 | &PARSE_FILE_SEQ_IGNORE_ ## _t ## _cache)
|
---|
[3140] | 100 | # define PARSE_SIMPLE_SEQ(_s,_t) \
|
---|
| 101 | (_t *)parse_file_seq ((_s),sizeof (_t),MAP_NUL,NULL,PARSEFS_NONE, \
|
---|
| 102 | &PARSE_FILE_SEQ_IGNORE_ ## _t ## _cache)
|
---|
[2591] | 103 | # define PARSE_FILE_SEQ_IGNORE_struct
|
---|
[1863] | 104 | #endif
|
---|
[2591] | 105 |
|
---|
[3140] | 106 |
|
---|
[53] | 107 | #ifdef VMS
|
---|
[2591] | 108 | void *parse_file_seq ();
|
---|
[53] | 109 | #else
|
---|
[2591] | 110 | void *parse_file_seq (char **stringp, unsigned int size,
|
---|
[3140] | 111 | int stopmap, const char *prefix, int flags
|
---|
[2591] | 112 | IF_WITH_ALLOC_CACHES_PARAM(struct alloccache *cache));
|
---|
[53] | 113 | #endif
|
---|
[2591] | 114 |
|
---|
[903] | 115 | char *tilde_expand (const char *name);
|
---|
[53] | 116 |
|
---|
| 117 | #ifndef NO_ARCHIVES
|
---|
[903] | 118 | struct nameseq *ar_glob (const char *arname, const char *member_pattern, unsigned int size);
|
---|
[53] | 119 | #endif
|
---|
| 120 |
|
---|
[3140] | 121 | #define dep_name(d) ((d)->name ? (d)->name : (d)->file->name)
|
---|
[53] | 122 |
|
---|
[3140] | 123 | #ifndef CONFIG_WITH_ALLOC_CACHES
|
---|
[2591] | 124 |
|
---|
[3140] | 125 | #define alloc_seq_elt(_t) xcalloc (sizeof (_t))
|
---|
| 126 | void free_ns_chain (struct nameseq *n);
|
---|
| 127 |
|
---|
| 128 | #if defined(MAKE_MAINTAINER_MODE) && defined(__GNUC__)
|
---|
| 129 | /* Use inline to get real type-checking. */
|
---|
| 130 | #define SI static inline
|
---|
| 131 | SI struct nameseq *alloc_ns() { return alloc_seq_elt (struct nameseq); }
|
---|
| 132 | SI struct dep *alloc_dep() { return alloc_seq_elt (struct dep); }
|
---|
| 133 | SI struct goaldep *alloc_goaldep() { return alloc_seq_elt (struct goaldep); }
|
---|
| 134 |
|
---|
| 135 | SI void free_ns(struct nameseq *n) { free (n); }
|
---|
| 136 | SI void free_dep(struct dep *d) { free_ns ((struct nameseq *)d); }
|
---|
| 137 | SI void free_goaldep(struct goaldep *g) { free_dep ((struct dep *)g); }
|
---|
| 138 |
|
---|
| 139 | SI void free_dep_chain(struct dep *d) { free_ns_chain((struct nameseq *)d); }
|
---|
| 140 | SI void free_goal_chain(struct goaldep *g) { free_dep_chain((struct dep *)g); }
|
---|
[2591] | 141 | #else
|
---|
[3140] | 142 | # define alloc_ns() alloc_seq_elt (struct nameseq)
|
---|
| 143 | # define alloc_dep() alloc_seq_elt (struct dep)
|
---|
| 144 | # define alloc_goaldep() alloc_seq_elt (struct goaldep)
|
---|
| 145 |
|
---|
| 146 | # define free_ns(_n) free (_n)
|
---|
| 147 | # define free_dep(_d) free_ns (_d)
|
---|
| 148 | # define free_goaldep(_g) free_dep (_g)
|
---|
| 149 |
|
---|
| 150 | # define free_dep_chain(_d) free_ns_chain ((struct nameseq *)(_d))
|
---|
| 151 | # define free_goal_chain(_g) free_ns_chain ((struct nameseq *)(_g))
|
---|
[2591] | 152 | #endif
|
---|
| 153 |
|
---|
[3140] | 154 | #else /* CONFIG_WITH_ALLOC_CACHES */
|
---|
| 155 |
|
---|
| 156 | # include <k/kDefs.h>
|
---|
| 157 |
|
---|
| 158 | K_INLINE struct nameseq *alloc_ns (void) { return (struct nameseq *)alloccache_calloc (&nameseq_cache); }
|
---|
| 159 | K_INLINE void free_ns (struct nameseq *n) { alloccache_free (&nameseq_cache, n); }
|
---|
[903] | 160 | void free_ns_chain (struct nameseq *n);
|
---|
| 161 |
|
---|
[3140] | 162 | K_INLINE struct dep *alloc_dep (void) { return (struct dep *)alloccache_calloc (&dep_cache); }
|
---|
| 163 | K_INLINE void free_dep (struct dep *d) { alloccache_free (&dep_cache, d); }
|
---|
| 164 | void free_dep_chain (struct dep *d);
|
---|
| 165 |
|
---|
| 166 | K_INLINE struct goaldep *alloc_goaldep (void) { return (struct goaldep *)alloccache_calloc (&goaldep_cache); }
|
---|
| 167 | K_INLINE void free_goaldep (struct goaldep *g) { alloccache_free (&goaldep_cache, g); }
|
---|
| 168 | void free_goal_chain (struct goaldep *g);
|
---|
| 169 |
|
---|
| 170 | #endif /* CONFIG_WITH_ALLOC_CACHES */
|
---|
| 171 |
|
---|
| 172 | struct dep *copy_dep_chain (const struct dep *d);
|
---|
| 173 |
|
---|
| 174 | struct goaldep *read_all_makefiles (const char **makefiles);
|
---|
| 175 | void eval_buffer (char *buffer, const floc *floc IF_WITH_VALUE_LENGTH(COMMA char *eos));
|
---|
| 176 | enum update_status update_goal_chain (struct goaldep *goals);
|
---|
| 177 |
|
---|
[530] | 178 | #ifdef CONFIG_WITH_INCLUDEDEP
|
---|
[1797] | 179 | /* incdep.c */
|
---|
| 180 | enum incdep_op { incdep_read_it, incdep_queue, incdep_flush };
|
---|
[3140] | 181 | void eval_include_dep (const char *name, floc *f, enum incdep_op op);
|
---|
[1797] | 182 | void incdep_flush_and_term (void);
|
---|
[530] | 183 | #endif
|
---|
| 184 |
|
---|