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