Home | History | Annotate | Download | only in functions
      1 #                                                                    -*-perl-*-
      2 
      3 $description = "Test the origin function.";
      4 
      5 $details = "This is a test of the origin function in gnu make.
      6 This function will report on where a variable was
      7 defined per the following list:
      8 
      9 'undefined'            never defined
     10 'default'              default definition
     11 'environment'          environment var without -e
     12 'environment override' environment var with    -e
     13 'file'                 defined in makefile
     14 'command line'         defined on the command line
     15 'override'             defined by override in makefile
     16 'automatic'            Automatic variable\n";
     17 
     18 # Set an environment variable
     19 $extraENV{MAKETEST} = 1;
     20 
     21 run_make_test('
     22 foo := bletch garf
     23 auto_var = undefined CC MAKETEST MAKE foo CFLAGS WHITE @
     24 av = $(foreach var, $(auto_var), $(origin $(var)) )
     25 override WHITE := BLACK
     26 all: auto
     27 	@echo $(origin undefined)
     28 	@echo $(origin CC)
     29 	@echo $(origin MAKETEST)
     30 	@echo $(origin MAKE)
     31 	@echo $(origin foo)
     32 	@echo $(origin CFLAGS)
     33 	@echo $(origin WHITE)
     34 	@echo $(origin @)
     35 auto :
     36 	@echo $(av)',
     37 	      '-e WHITE=WHITE CFLAGS=',
     38 	      'undefined default environment default file command line override automatic
     39 undefined
     40 default
     41 environment
     42 default
     43 file
     44 command line
     45 override
     46 automatic');
     47 
     48 # Reset an environment variable
     49 delete $extraENV{MAKETEST};
     50 
     51 1;
     52