Why are exported variables in the Makefile not received by the executable?

I have a makefile where I export the variables that will be received by the executable, but it is surprising that the executable does not receive the exported values.

Please help me.

31 test: 32 @ echo 33 @ echo "Testing Electric Fence." 34 @ echo "After the last test, it should print that the test has PASSED." 35 ./eftest 36 ./tstheap 3072 37 export EF_ERRTRACK_START=3 38 export EF_ERRTRACK_END=5 39 ./time-interval-measurement-test 40 @ echo 41 @ echo "Electric Fence confidence test PASSED." 42 @ echo 

time-interval-measurement-test is an executable (C program) that should receive exported variables, but it fails. Please help me.

+4
source share
2 answers

If I'm not mistaken, each line in the Makefile is a separate shell process. Thus, shell-export does not work for several processes: one way to do this is to put them on one line:

 test: @ echo @ echo "Testing Electric Fence." @ echo "After the last test, it should print that the test has PASSED." ./eftest ./tstheap 3072 EF_ERRTRACK_START=3 EF_ERRTRACK_END=5 ./time-interval-measurement-test @ echo @ echo "Electric Fence confidence test PASSED." @ echo 

or line break using '\'

 test: [..] EF_ERRTRACK_START=3 \ EF_ERRTRACK_END=5 \ ./time-interval-measurement-test 

Similar to ENV variables available for. / Time-interval-measrument

+3
source

I asked a similar question, but its not the same scenario as implementing a common makefile variable

Ideally, your exported variables should go to the child process, I wonder if your child shell is the same as the parent.

Try the following - export EF_ERRTRACK_START = 3; export EF_ERRTRACK_END = 5; ./ time-interval-measurement-test

+2
source

All Articles