fixopts.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* Handle options that are passed from environment variables.
  2. Copyright (C) 2004, 2009, 2012 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3, or (at your option)
  7. any later version.
  8. GCC is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. #include "fixlib.h"
  16. te_verbose verbose_level = VERB_PROGRESS;
  17. fixinc_mode_t fixinc_mode = TESTING_OFF;
  18. #define _ENV_(v,m,n,t) char const * v = NULL;
  19. ENV_TABLE
  20. #undef _ENV_
  21. static void
  22. show_not_def (char const * vname)
  23. {
  24. static const char var_not_found[] =
  25. "fixincl ERROR: %s environment variable not defined\n"
  26. "each of these must be defined:\n";
  27. static char const not_found_var[] = "\t%s\n";
  28. fprintf (stderr, var_not_found, vname);
  29. # define _ENV_(vv,mm,nn,tt) \
  30. if (mm) fprintf (stderr, not_found_var, nn);
  31. ENV_TABLE
  32. # undef _ENV_
  33. exit (EXIT_FAILURE);
  34. }
  35. void
  36. initialize_opts (void)
  37. {
  38. #define _ENV_(v,m,n,t) { \
  39. static char const var[] = n; \
  40. v = getenv (var); \
  41. if (m && (v == NULL)) show_not_def (var); \
  42. }
  43. ENV_TABLE;
  44. #undef _ENV_
  45. if ((pz_test_mode != NULL) && (strcmp (pz_test_mode, "true") == 0))
  46. fixinc_mode = TESTING_ON;
  47. }