genmddeps.c 1.8 KB

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