| 1 | /* Dependency generator for Makefile fragments. |
| 2 | Copyright (C) 2000-2025 Free Software Foundation, Inc. |
| 3 | Contributed by Zack Weinberg, Mar 2000 |
| 4 | |
| 5 | This program is free software; you can redistribute it and/or modify it |
| 6 | under the terms of the GNU General Public License as published by the |
| 7 | Free Software Foundation; either version 3, or (at your option) any |
| 8 | later version. |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along 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 | |
| 31 | class mkdeps; |
| 32 | |
| 33 | /* Create a deps buffer. */ |
| 34 | extern class mkdeps *deps_init (void); |
| 35 | |
| 36 | /* Destroy a deps buffer. */ |
| 37 | extern 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. */ |
| 44 | extern 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. */ |
| 48 | extern 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. */ |
| 52 | extern void deps_add_default_target (class mkdeps *, const char *); |
| 53 | |
| 54 | /* Adds a module target. The module name and cmi name are copied. */ |
| 55 | extern void deps_add_module_target (struct mkdeps *, const char *module, |
| 56 | const char *cmi, bool , |
| 57 | bool is_exported); |
| 58 | |
| 59 | /* Adds a module dependency. The module name is copied. */ |
| 60 | extern void deps_add_module_dep (struct mkdeps *, const char *module); |
| 61 | |
| 62 | /* Add a structured dependency target. */ |
| 63 | extern 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. */ |
| 69 | extern 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). */ |
| 73 | extern void deps_write (const cpp_reader *, FILE *, unsigned int); |
| 74 | |
| 75 | /* Write out a deps buffer to a specified file in P1689R5 format. */ |
| 76 | extern 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. */ |
| 81 | extern 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. */ |
| 87 | extern int deps_restore (class mkdeps *, FILE *, const char *); |
| 88 | |
| 89 | #endif /* ! LIBCPP_MKDEPS_H */ |
| 90 | |