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