#
# Updated 6.16.93  variable "MAKE" is default was environment override
# For make 3.63 and above


$description = "The following test creates a makefile to verify\n"
              ."test the origin function.";

$details = "This is a test of the origin function in gnu make. \n"
          ."This function will report on where a variable was\n"
          ."defined per the following list:\n"
          ."'undefined'            never defined\n"
          ."'default'              default definition\n"
          ."'environment'          environment var without -e\n"
          ."'environment override' environment var with    -e\n"
          ."'file'                 defined in makefile\n"
          ."'command line'         defined on the command line\n"
          ."'override'             defined by override in makefile\n"
          ."'automatic'            Automatic variable\n";


open(MAKEFILE,"> $makefile");

# The Contents of the MAKEFILE ...

print MAKEFILE "foo := bletch garf\n"
              ."auto_var = udef CC HOME MAKE foo CFLAGS WHITE @ \n"
              ."av = \$(foreach var, \$(auto_var), \$(origin \$(var)) ) \n"
              ."override WHITE := BLACK\n"
              ."all: auto\n"             
              ."\t\@echo \$(origin undefined)\n"
              ."\t\@echo \$(origin CC) \n"
              ."\t\@echo \$(origin HOME) \n"
              ."\t\@echo \$(origin MAKE)\n"
              ."\t\@echo \$(origin foo)\n"
              ."\t\@echo \$(origin CFLAGS)\n"
              ."\t\@echo \$(origin WHITE)\n"
              ."\t\@echo \$(origin @)\n"
              ."auto : \n"
              ."\t\@echo \$(av) \n";




# END of Contents of MAKEFILE

close(MAKEFILE);

&run_make_with_options($makefile,
                      "-e WHITE=WHITE CFLAGS=",
                      &get_logfile);

# Create the answer to what should be produced by this Makefile
$answer = "undefined default environment default file command line override automatic\n"
         ."undefined\n"
         ."default\n"
         ."environment\n"
         ."default\n"
         ."file\n"
         ."command line\n"
         ."override\n"
         ."automatic\n";


&compare_output($answer,&get_logfile(1));

1;






