(root)/
make-4.4/
src/
dep.h
       1  /* Definitions of dependency data structures for GNU Make.
       2  Copyright (C) 1988-2022 Free Software Foundation, Inc.
       3  This file is part of GNU Make.
       4  
       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
       7  Foundation; either version 3 of the License, or (at your option) any later
       8  version.
       9  
      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.
      13  
      14  You should have received a copy of the GNU General Public License along with
      15  this program.  If not, see <https://www.gnu.org/licenses/>.  */
      16  
      17  
      18  /* Structure used in chains of names, for parsing and globbing.  */
      19  
      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_NOFLAG               0
      34  #define RM_NO_DEFAULT_GOAL      (1 << 0) /* Do not set default goal.  */
      35  #define RM_INCLUDED             (1 << 1) /* Search makefile search path.  */
      36  #define RM_DONTCARE             (1 << 2) /* No error if it doesn't exist.  */
      37  #define RM_NO_TILDE             (1 << 3) /* Don't expand ~ in file name.  */
      38  
      39  /* Structure representing one dependency of a file.
      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.
      42     explicit is set when implicit rule search is performed and the prerequisite
      43     does not contain %. When explicit is set the file is not intermediate.  */
      44  
      45  
      46  #define DEP(_t)                                 \
      47      NAMESEQ (_t);                               \
      48      struct file *file;                          \
      49      _t *shuf;                                   \
      50      const char *stem;                           \
      51      unsigned int flags : 8;                     \
      52      unsigned int changed : 1;                   \
      53      unsigned int ignore_mtime : 1;              \
      54      unsigned int staticpattern : 1;             \
      55      unsigned int need_2nd_expansion : 1;        \
      56      unsigned int ignore_automatic_vars : 1;     \
      57      unsigned int is_explicit : 1;               \
      58      unsigned int wait_here : 1
      59  
      60  struct dep
      61    {
      62      DEP (struct dep);
      63    };
      64  
      65  /* Structure representing one goal.
      66     The goals to be built constitute a chain of these, chained through 'next'.
      67     'stem' is not used, but it's simpler to include and ignore it.  */
      68  
      69  struct goaldep
      70    {
      71      DEP (struct goaldep);
      72      int error;
      73      floc floc;
      74    };
      75  
      76  /* Options for parsing lists of filenames.  */
      77  
      78  #define PARSEFS_NONE    0x0000
      79  #define PARSEFS_NOSTRIP 0x0001
      80  #define PARSEFS_NOAR    0x0002
      81  #define PARSEFS_NOGLOB  0x0004
      82  #define PARSEFS_EXISTS  0x0008
      83  #define PARSEFS_NOCACHE 0x0010
      84  #define PARSEFS_ONEWORD 0x0020
      85  #define PARSEFS_WAIT    0x0040
      86  
      87  #define PARSE_FILE_SEQ(_s,_t,_c,_p,_f) \
      88              (_t *)parse_file_seq ((_s),sizeof (_t),(_c),(_p),(_f))
      89  #define PARSE_SIMPLE_SEQ(_s,_t) \
      90              (_t *)parse_file_seq ((_s),sizeof (_t),MAP_NUL,NULL,PARSEFS_NONE)
      91  
      92  #ifdef VMS
      93  void *parse_file_seq ();
      94  #else
      95  void *parse_file_seq (char **stringp, size_t size,
      96                        int stopmap, const char *prefix, int flags);
      97  #endif
      98  
      99  char *tilde_expand (const char *name);
     100  
     101  #ifndef NO_ARCHIVES
     102  struct nameseq *ar_glob (const char *arname, const char *member_pattern, size_t size);
     103  #endif
     104  
     105  #define dep_name(d)       ((d)->name ? (d)->name : (d)->file->name)
     106  
     107  #define alloc_seq_elt(_t) xcalloc (sizeof (_t))
     108  void free_ns_chain (struct nameseq *n);
     109  
     110  #if defined(MAKE_MAINTAINER_MODE) && defined(__GNUC__) && !defined(__STRICT_ANSI__)
     111  /* Use inline to get real type-checking.  */
     112  #define SI static inline
     113  SI struct nameseq *alloc_ns (void)    { return alloc_seq_elt (struct nameseq); }
     114  SI struct dep *alloc_dep (void)       { return alloc_seq_elt (struct dep); }
     115  SI struct goaldep *alloc_goaldep (void) { return alloc_seq_elt (struct goaldep); }
     116  
     117  SI void free_ns (struct nameseq *n)      { free (n); }
     118  SI void free_dep (struct dep *d)         { free_ns ((struct nameseq *)d); }
     119  SI void free_goaldep (struct goaldep *g) { free_dep ((struct dep *)g); }
     120  SI void free_dep_chain (struct dep *d)   { free_ns_chain((struct nameseq *)d); }
     121  SI void free_goal_chain (struct goaldep *g) { free_dep_chain((struct dep *)g); }
     122  #else
     123  # define alloc_ns()          alloc_seq_elt (struct nameseq)
     124  # define alloc_dep()         alloc_seq_elt (struct dep)
     125  # define alloc_goaldep()     alloc_seq_elt (struct goaldep)
     126  
     127  # define free_ns(_n)         free (_n)
     128  # define free_dep(_d)        free_ns (_d)
     129  # define free_goaldep(_g)    free_dep (_g)
     130  
     131  # define free_dep_chain(_d)  free_ns_chain ((struct nameseq *)(_d))
     132  # define free_goal_chain(_g) free_ns_chain ((struct nameseq *)(_g))
     133  #endif
     134  
     135  struct dep *copy_dep_chain (const struct dep *d);
     136  
     137  struct goaldep *read_all_makefiles (const char **makefiles);
     138  void eval_buffer (char *buffer, const floc *floc);
     139  enum update_status update_goal_chain (struct goaldep *goals);