1169689Skan/* genmddeps.c - creates a makefile dependency fragment for the md file.
2169689Skan   Copyright (C) 2004 Free Software Foundation, Inc.
3169689Skan
4169689SkanThis program is free software; you can redistribute it and/or modify it
5169689Skanunder the terms of the GNU General Public License as published by the
6169689SkanFree Software Foundation; either version 2, or (at your option) any
7169689Skanlater version.
8169689Skan
9169689SkanThis program is distributed in the hope that it will be useful,
10169689Skanbut WITHOUT ANY WARRANTY; without even the implied warranty of
11169689SkanMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12169689SkanGNU General Public License for more details.
13169689Skan
14169689SkanYou should have received a copy of the GNU General Public License
15169689Skanalong with this program; if not, write to the Free Software
16169689SkanFoundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
17169689Skan
18169689Skan#include "bconfig.h"
19169689Skan#include "system.h"
20169689Skan#include "coretypes.h"
21169689Skan#include "tm.h"
22169689Skan#include "rtl.h"
23169689Skan#include "gensupport.h"
24169689Skan#include "errors.h"
25169689Skan
26169689Skan
27169689Skanstruct filedep
28169689Skan{
29169689Skan  struct filedep *next;
30169689Skan  const char *pathname;
31169689Skan};
32169689Skan
33169689Skanstatic struct filedep *deps, **last = &deps;
34169689Skan
35169689Skanstatic void
36169689Skanadd_filedep (const char *pathname)
37169689Skan{
38169689Skan  struct filedep *n = XNEW (struct filedep);
39169689Skan  n->pathname = pathname;
40169689Skan  *last = n;
41169689Skan  last = &n->next;
42169689Skan}
43169689Skan
44169689Skanint
45169689Skanmain (int argc, char **argv)
46169689Skan{
47169689Skan  struct filedep *d;
48169689Skan
49169689Skan  progname = "genmddeps";
50169689Skan  include_callback = add_filedep;
51169689Skan
52169689Skan  if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
53169689Skan    return (FATAL_EXIT_CODE);
54169689Skan
55169689Skan  *last = NULL;
56169689Skan
57169689Skan  /* Output a variable containing all of the include files.  */
58169689Skan  fputs ("MD_INCLUDES =", stdout);
59169689Skan  for (d = deps; d ; d = d->next)
60169689Skan    printf (" \\\n\t%s", d->pathname);
61169689Skan  putchar ('\n');
62169689Skan
63169689Skan  /* Output make targets for these includes with empty actions.  This
64169689Skan     will guard against make errors when includes are removed.  */
65169689Skan  for (d = deps; d ; d = d->next)
66169689Skan    printf ("\n%s:\n", d->pathname);
67169689Skan
68169689Skan  fflush (stdout);
69169689Skan  return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
70169689Skan}
71