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