foreach 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # -*-perl-*-
  2. # Updated 6.16.93 variable "MAKE" is default was environment override
  3. # For make 3.63 and above
  4. $description = "The following test creates a makefile to verify
  5. test the foreach function.";
  6. $details = "This is a test of the foreach function in gnu make.
  7. This function starts with a space separated list of
  8. names and a variable. Each name in the list is subsituted
  9. into the variable and the given text evaluated. The general
  10. form of the command is $(foreach var,$list,$text). Several
  11. types of foreach loops are tested\n";
  12. open(MAKEFILE,"> $makefile");
  13. # The Contents of the MAKEFILE ...
  14. # On WIN32 systems, the user's path is found in %Path% ($Path)
  15. #
  16. $pathvar = (($port_type eq 'Windows') ? "Path" : "PATH");
  17. print MAKEFILE <<EOF;
  18. foo = bletch null \@ garf
  19. null :=
  20. space = ' '
  21. auto_var = udef space CC null $pathvar MAKE foo CFLAGS WHITE \@ <
  22. av = \$(foreach var, \$(auto_var), \$(origin \$(var)) )
  23. override WHITE := BLACK
  24. for_var = \$(addsuffix .c,foo \$(null) \$(foo) \$(space) \$(av) )
  25. fe = \$(foreach var2, \$(for_var),\$(subst .c,.o, \$(var2) ) )
  26. all: auto for2
  27. auto :
  28. \t\@echo \$(av)
  29. for2:
  30. \t\@echo \$(fe)
  31. EOF
  32. close(MAKEFILE);
  33. &run_make_with_options($makefile,
  34. "-e WHITE=WHITE CFLAGS=",
  35. &get_logfile);
  36. # Create the answer to what should be produced by this Makefile
  37. $answer = "undefined file default file environment default file command line override automatic automatic
  38. foo.o bletch.o null.o @.o garf.o .o .o undefined.o file.o default.o file.o environment.o default.o file.o command.o line.o override.o automatic.o automatic.o\n";
  39. &compare_output($answer,&get_logfile(1));
  40. 1;