1/* Dependency generator for Makefile fragments.
2 Copyright (C) 2000-2024 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#include "cpplib.h"
27
28/* This is the data structure used by all the functions in mkdeps.cc.
29 It's quite straightforward, but should be treated as opaque. */
30
31class mkdeps;
32
33/* Create a deps buffer. */
34extern class mkdeps *deps_init (void);
35
36/* Destroy a deps buffer. */
37extern void deps_free (class mkdeps *);
38
39/* Add a set of "vpath" directories. The second argument is a colon-
40 separated list of pathnames, like you would set Make's VPATH
41 variable to. If a dependency or target name begins with any of
42 these pathnames (and the next path element is not "..") that
43 pathname is stripped off. */
44extern void deps_add_vpath (class mkdeps *, const char *);
45
46/* Add a target (appears on left side of the colon) to the deps list. Takes
47 a boolean indicating whether to quote the target for MAKE. */
48extern void deps_add_target (class mkdeps *, const char *, int);
49
50/* Sets the default target if none has been given already. An empty
51 string as the default target is interpreted as stdin. */
52extern void deps_add_default_target (class mkdeps *, const char *);
53
54/* Adds a module target. The module name and cmi name are copied. */
55extern void deps_add_module_target (struct mkdeps *, const char *module,
56 const char *cmi, bool is_header,
57 bool is_exported);
58
59/* Adds a module dependency. The module name is copied. */
60extern void deps_add_module_dep (struct mkdeps *, const char *module);
61
62/* Add a structured dependency target. */
63extern void fdeps_add_target (struct mkdeps *, const char *, bool);
64
65/* Add a dependency (appears on the right side of the colon) to the
66 deps list. Dependencies will be printed in the order that they
67 were entered with this function. By convention, the first
68 dependency entered should be the primary source file. */
69extern void deps_add_dep (class mkdeps *, const char *);
70
71/* Write out a deps buffer to a specified file. The last argument
72 is the number of columns to word-wrap at (0 means don't wrap). */
73extern void deps_write (const cpp_reader *, FILE *, unsigned int);
74
75/* Write out a deps buffer to a specified file in P1689R5 format. */
76extern void deps_write_p1689r5 (const struct mkdeps *, FILE *);
77
78/* Write out a deps buffer to a file, in a form that can be read back
79 with deps_restore. Returns nonzero on error, in which case the
80 error number will be in errno. */
81extern int deps_save (class mkdeps *, FILE *);
82
83/* Read back dependency information written with deps_save into
84 the deps buffer. The third argument may be NULL, in which case
85 the dependency information is just skipped, or it may be a filename,
86 in which case that filename is skipped. */
87extern int deps_restore (class mkdeps *, FILE *, const char *);
88
89#endif /* ! LIBCPP_MKDEPS_H */
90

source code of libcpp/include/mkdeps.h