xref: /dflybsd-src/contrib/gcc-4.7/libcpp/include/mkdeps.h (revision 04febcfb30580676d3e95f58a16c5137ee478b32)
1*e4b17023SJohn Marino /* Dependency generator for Makefile fragments.
2*e4b17023SJohn Marino    Copyright (C) 2000, 2001, 2003, 2009 Free Software Foundation, Inc.
3*e4b17023SJohn Marino    Contributed by Zack Weinberg, Mar 2000
4*e4b17023SJohn Marino 
5*e4b17023SJohn Marino This program is free software; you can redistribute it and/or modify it
6*e4b17023SJohn Marino under the terms of the GNU General Public License as published by the
7*e4b17023SJohn Marino Free Software Foundation; either version 3, or (at your option) any
8*e4b17023SJohn Marino later version.
9*e4b17023SJohn Marino 
10*e4b17023SJohn Marino This program is distributed in the hope that it will be useful,
11*e4b17023SJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of
12*e4b17023SJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13*e4b17023SJohn Marino GNU General Public License for more details.
14*e4b17023SJohn Marino 
15*e4b17023SJohn Marino You should have received a copy of the GNU General Public License
16*e4b17023SJohn Marino along with this program; see the file COPYING3.  If not see
17*e4b17023SJohn Marino <http://www.gnu.org/licenses/>.
18*e4b17023SJohn Marino 
19*e4b17023SJohn Marino  In other words, you are welcome to use, share and improve this program.
20*e4b17023SJohn Marino  You are forbidden to forbid anyone else to use, share and improve
21*e4b17023SJohn Marino  what you give them.   Help stamp out software-hoarding!  */
22*e4b17023SJohn Marino 
23*e4b17023SJohn Marino #ifndef LIBCPP_MKDEPS_H
24*e4b17023SJohn Marino #define LIBCPP_MKDEPS_H
25*e4b17023SJohn Marino 
26*e4b17023SJohn Marino /* This is the data structure used by all the functions in mkdeps.c.
27*e4b17023SJohn Marino    It's quite straightforward, but should be treated as opaque.  */
28*e4b17023SJohn Marino 
29*e4b17023SJohn Marino struct deps;
30*e4b17023SJohn Marino 
31*e4b17023SJohn Marino /* Create a deps buffer.  */
32*e4b17023SJohn Marino extern struct deps *deps_init (void);
33*e4b17023SJohn Marino 
34*e4b17023SJohn Marino /* Destroy a deps buffer.  */
35*e4b17023SJohn Marino extern void deps_free (struct deps *);
36*e4b17023SJohn Marino 
37*e4b17023SJohn Marino /* Add a set of "vpath" directories. The second argument is a colon-
38*e4b17023SJohn Marino    separated list of pathnames, like you would set Make's VPATH
39*e4b17023SJohn Marino    variable to.  If a dependency or target name begins with any of
40*e4b17023SJohn Marino    these pathnames (and the next path element is not "..") that
41*e4b17023SJohn Marino    pathname is stripped off.  */
42*e4b17023SJohn Marino extern void deps_add_vpath (struct deps *, const char *);
43*e4b17023SJohn Marino 
44*e4b17023SJohn Marino /* Add a target (appears on left side of the colon) to the deps list.  Takes
45*e4b17023SJohn Marino    a boolean indicating whether to quote the target for MAKE.  */
46*e4b17023SJohn Marino extern void deps_add_target (struct deps *, const char *, int);
47*e4b17023SJohn Marino 
48*e4b17023SJohn Marino /* Sets the default target if none has been given already.  An empty
49*e4b17023SJohn Marino    string as the default target is interpreted as stdin.  */
50*e4b17023SJohn Marino extern void deps_add_default_target (struct deps *, const char *);
51*e4b17023SJohn Marino 
52*e4b17023SJohn Marino /* Add a dependency (appears on the right side of the colon) to the
53*e4b17023SJohn Marino    deps list.  Dependencies will be printed in the order that they
54*e4b17023SJohn Marino    were entered with this function.  By convention, the first
55*e4b17023SJohn Marino    dependency entered should be the primary source file.  */
56*e4b17023SJohn Marino extern void deps_add_dep (struct deps *, const char *);
57*e4b17023SJohn Marino 
58*e4b17023SJohn Marino /* Write out a deps buffer to a specified file.  The third argument
59*e4b17023SJohn Marino    is the number of columns to word-wrap at (0 means don't wrap).  */
60*e4b17023SJohn Marino extern void deps_write (const struct deps *, FILE *, unsigned int);
61*e4b17023SJohn Marino 
62*e4b17023SJohn Marino /* Write out a deps buffer to a file, in a form that can be read back
63*e4b17023SJohn Marino    with deps_restore.  Returns nonzero on error, in which case the
64*e4b17023SJohn Marino    error number will be in errno.  */
65*e4b17023SJohn Marino extern int deps_save (struct deps *, FILE *);
66*e4b17023SJohn Marino 
67*e4b17023SJohn Marino /* Read back dependency information written with deps_save into
68*e4b17023SJohn Marino    the deps buffer.  The third argument may be NULL, in which case
69*e4b17023SJohn Marino    the dependency information is just skipped, or it may be a filename,
70*e4b17023SJohn Marino    in which case that filename is skipped.  */
71*e4b17023SJohn Marino extern int deps_restore (struct deps *, FILE *, const char *);
72*e4b17023SJohn Marino 
73*e4b17023SJohn Marino /* For each dependency *except the first*, emit a dummy rule for that
74*e4b17023SJohn Marino    file, causing it to depend on nothing.  This is used to work around
75*e4b17023SJohn Marino    the intermediate-file deletion misfeature in Make, in some
76*e4b17023SJohn Marino    automatic dependency schemes.  */
77*e4b17023SJohn Marino extern void deps_phony_targets (const struct deps *, FILE *);
78*e4b17023SJohn Marino 
79*e4b17023SJohn Marino #endif /* ! LIBCPP_MKDEPS_H */
80