origin 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # -*-perl-*-
  2. $description = "Test the origin function.";
  3. $details = "This is a test of the origin function in gnu make.
  4. This function will report on where a variable was
  5. defined per the following list:
  6. 'undefined' never defined
  7. 'default' default definition
  8. 'environment' environment var without -e
  9. 'environment override' environment var with -e
  10. 'file' defined in makefile
  11. 'command line' defined on the command line
  12. 'override' defined by override in makefile
  13. 'automatic' Automatic variable\n";
  14. # On WIN32 systems, HOME is meaningless. SystemRoot should be defined
  15. # though. With DJGPP, HOME is not guaranteed to be defined. Use DJDIR
  16. # instead.
  17. #
  18. $homevar = (($port_type eq 'Windows') ? "SystemRoot"
  19. : (($port_type eq 'DOS') ? "DJDIR"
  20. : "HOME"));
  21. open(MAKEFILE,"> $makefile");
  22. print MAKEFILE <<EOF;
  23. foo := bletch garf
  24. auto_var = udef CC $homevar MAKE foo CFLAGS WHITE \@
  25. av = \$(foreach var, \$(auto_var), \$(origin \$(var)) )
  26. override WHITE := BLACK
  27. all: auto
  28. \t\@echo \$(origin undefined)
  29. \t\@echo \$(origin CC)
  30. \t\@echo \$(origin $homevar)
  31. \t\@echo \$(origin MAKE)
  32. \t\@echo \$(origin foo)
  33. \t\@echo \$(origin CFLAGS)
  34. \t\@echo \$(origin WHITE)
  35. \t\@echo \$(origin \@)
  36. auto :
  37. \t\@echo \$(av)
  38. EOF
  39. close(MAKEFILE);
  40. &run_make_with_options($makefile,
  41. "-e WHITE=WHITE CFLAGS=",
  42. &get_logfile);
  43. # Create the answer to what should be produced by this Makefile
  44. $answer = "undefined default environment default file command line override automatic
  45. undefined
  46. default
  47. environment
  48. default
  49. file
  50. command line
  51. override
  52. automatic\n";
  53. &compare_output($answer,&get_logfile(1));
  54. 1;