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