1*e4b17023SJohn Marino /* genmddeps.c - creates a makefile dependency fragment for the md file.
2*e4b17023SJohn Marino Copyright (C) 2004, 2007, 2010 Free Software Foundation, Inc.
3*e4b17023SJohn Marino
4*e4b17023SJohn Marino This program is free software; you can redistribute it and/or modify it
5*e4b17023SJohn Marino under the terms of the GNU General Public License as published by the
6*e4b17023SJohn Marino Free Software Foundation; either version 3, or (at your option) any
7*e4b17023SJohn Marino later version.
8*e4b17023SJohn Marino
9*e4b17023SJohn Marino This program is distributed in the hope that it will be useful,
10*e4b17023SJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of
11*e4b17023SJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12*e4b17023SJohn Marino GNU General Public License for more details.
13*e4b17023SJohn Marino
14*e4b17023SJohn Marino You should have received a copy of the GNU General Public License
15*e4b17023SJohn Marino along with this program; see the file COPYING3. If not see
16*e4b17023SJohn Marino <http://www.gnu.org/licenses/>. */
17*e4b17023SJohn Marino
18*e4b17023SJohn Marino #include "bconfig.h"
19*e4b17023SJohn Marino #include "system.h"
20*e4b17023SJohn Marino #include "coretypes.h"
21*e4b17023SJohn Marino #include "errors.h"
22*e4b17023SJohn Marino #include "read-md.h"
23*e4b17023SJohn Marino
24*e4b17023SJohn Marino
25*e4b17023SJohn Marino struct filedep
26*e4b17023SJohn Marino {
27*e4b17023SJohn Marino struct filedep *next;
28*e4b17023SJohn Marino const char *pathname;
29*e4b17023SJohn Marino };
30*e4b17023SJohn Marino
31*e4b17023SJohn Marino static struct filedep *deps, **last = &deps;
32*e4b17023SJohn Marino
33*e4b17023SJohn Marino static void
add_filedep(const char * pathname)34*e4b17023SJohn Marino add_filedep (const char *pathname)
35*e4b17023SJohn Marino {
36*e4b17023SJohn Marino struct filedep *n = XNEW (struct filedep);
37*e4b17023SJohn Marino n->pathname = pathname;
38*e4b17023SJohn Marino *last = n;
39*e4b17023SJohn Marino last = &n->next;
40*e4b17023SJohn Marino }
41*e4b17023SJohn Marino
42*e4b17023SJohn Marino int
main(int argc,char ** argv)43*e4b17023SJohn Marino main (int argc, char **argv)
44*e4b17023SJohn Marino {
45*e4b17023SJohn Marino struct filedep *d;
46*e4b17023SJohn Marino
47*e4b17023SJohn Marino progname = "genmddeps";
48*e4b17023SJohn Marino include_callback = add_filedep;
49*e4b17023SJohn Marino
50*e4b17023SJohn Marino if (!read_md_files (argc, argv, NULL, NULL))
51*e4b17023SJohn Marino return FATAL_EXIT_CODE;
52*e4b17023SJohn Marino
53*e4b17023SJohn Marino *last = NULL;
54*e4b17023SJohn Marino
55*e4b17023SJohn Marino /* Output a variable containing all of the include files. */
56*e4b17023SJohn Marino fputs ("MD_INCLUDES =", stdout);
57*e4b17023SJohn Marino for (d = deps; d ; d = d->next)
58*e4b17023SJohn Marino printf (" \\\n\t%s", d->pathname);
59*e4b17023SJohn Marino putchar ('\n');
60*e4b17023SJohn Marino
61*e4b17023SJohn Marino /* Output make targets for these includes with empty actions. This
62*e4b17023SJohn Marino will guard against make errors when includes are removed. */
63*e4b17023SJohn Marino for (d = deps; d ; d = d->next)
64*e4b17023SJohn Marino printf ("\n%s:\n", d->pathname);
65*e4b17023SJohn Marino
66*e4b17023SJohn Marino fflush (stdout);
67*e4b17023SJohn Marino return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
68*e4b17023SJohn Marino }
69