xref: /netbsd-src/external/gpl3/gcc.old/dist/libcpp/include/mkdeps.h (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
136ac495dSmrg /* Dependency generator for Makefile fragments.
2*8feb0f0bSmrg    Copyright (C) 2000-2020 Free Software Foundation, Inc.
336ac495dSmrg    Contributed by Zack Weinberg, Mar 2000
436ac495dSmrg 
536ac495dSmrg This program is free software; you can redistribute it and/or modify it
636ac495dSmrg under the terms of the GNU General Public License as published by the
736ac495dSmrg Free Software Foundation; either version 3, or (at your option) any
836ac495dSmrg later version.
936ac495dSmrg 
1036ac495dSmrg This program is distributed in the hope that it will be useful,
1136ac495dSmrg but WITHOUT ANY WARRANTY; without even the implied warranty of
1236ac495dSmrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1336ac495dSmrg GNU General Public License for more details.
1436ac495dSmrg 
1536ac495dSmrg You should have received a copy of the GNU General Public License
1636ac495dSmrg along with this program; see the file COPYING3.  If not see
1736ac495dSmrg <http://www.gnu.org/licenses/>.
1836ac495dSmrg 
1936ac495dSmrg  In other words, you are welcome to use, share and improve this program.
2036ac495dSmrg  You are forbidden to forbid anyone else to use, share and improve
2136ac495dSmrg  what you give them.   Help stamp out software-hoarding!  */
2236ac495dSmrg 
2336ac495dSmrg #ifndef LIBCPP_MKDEPS_H
2436ac495dSmrg #define LIBCPP_MKDEPS_H
2536ac495dSmrg 
2636ac495dSmrg /* This is the data structure used by all the functions in mkdeps.c.
2736ac495dSmrg    It's quite straightforward, but should be treated as opaque.  */
2836ac495dSmrg 
29*8feb0f0bSmrg class mkdeps;
3036ac495dSmrg 
3136ac495dSmrg /* Create a deps buffer.  */
32*8feb0f0bSmrg extern class mkdeps *deps_init (void);
3336ac495dSmrg 
3436ac495dSmrg /* Destroy a deps buffer.  */
35*8feb0f0bSmrg extern void deps_free (class mkdeps *);
3636ac495dSmrg 
3736ac495dSmrg /* Add a set of "vpath" directories. The second argument is a colon-
3836ac495dSmrg    separated list of pathnames, like you would set Make's VPATH
3936ac495dSmrg    variable to.  If a dependency or target name begins with any of
4036ac495dSmrg    these pathnames (and the next path element is not "..") that
4136ac495dSmrg    pathname is stripped off.  */
42*8feb0f0bSmrg extern void deps_add_vpath (class mkdeps *, const char *);
4336ac495dSmrg 
4436ac495dSmrg /* Add a target (appears on left side of the colon) to the deps list.  Takes
4536ac495dSmrg    a boolean indicating whether to quote the target for MAKE.  */
46*8feb0f0bSmrg extern void deps_add_target (class mkdeps *, const char *, int);
4736ac495dSmrg 
4836ac495dSmrg /* Sets the default target if none has been given already.  An empty
4936ac495dSmrg    string as the default target is interpreted as stdin.  */
50*8feb0f0bSmrg extern void deps_add_default_target (class mkdeps *, const char *);
5136ac495dSmrg 
5236ac495dSmrg /* Add a dependency (appears on the right side of the colon) to the
5336ac495dSmrg    deps list.  Dependencies will be printed in the order that they
5436ac495dSmrg    were entered with this function.  By convention, the first
5536ac495dSmrg    dependency entered should be the primary source file.  */
56*8feb0f0bSmrg extern void deps_add_dep (class mkdeps *, const char *);
5736ac495dSmrg 
5836ac495dSmrg /* Write out a deps buffer to a specified file.  The third argument
5936ac495dSmrg    is the number of columns to word-wrap at (0 means don't wrap).  */
60*8feb0f0bSmrg extern void deps_write (const class mkdeps *, FILE *, bool, unsigned int);
6136ac495dSmrg 
6236ac495dSmrg /* Write out a deps buffer to a file, in a form that can be read back
6336ac495dSmrg    with deps_restore.  Returns nonzero on error, in which case the
6436ac495dSmrg    error number will be in errno.  */
65*8feb0f0bSmrg extern int deps_save (class mkdeps *, FILE *);
6636ac495dSmrg 
6736ac495dSmrg /* Read back dependency information written with deps_save into
6836ac495dSmrg    the deps buffer.  The third argument may be NULL, in which case
6936ac495dSmrg    the dependency information is just skipped, or it may be a filename,
7036ac495dSmrg    in which case that filename is skipped.  */
71*8feb0f0bSmrg extern int deps_restore (class mkdeps *, FILE *, const char *);
7236ac495dSmrg 
7336ac495dSmrg #endif /* ! LIBCPP_MKDEPS_H */
74