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