为什么可执行文件不接收Makefile中的导出变量?

kin*_*er1 4 linux export makefile

我有一个makefile,我将导出将由可执行文件接收的变量,但令人惊讶的是,可执行文件未接收导出的值.

请帮我.

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
Run Code Online (Sandbox Code Playgroud)

time-interval-measurement-test是一个可执行文件(C程序),它应该接收导出的变量,但它没有得到.请帮我.

Pat*_* B. 5

如果我没弄错,Makefile中的每一行都是一个单独的shell进程.因此shell导出不适用于多个进程:一种方法是将它们放在一行中:

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
Run Code Online (Sandbox Code Playgroud)

或者使用'\'进行换行符转义

test:
        [..]
        EF_ERRTRACK_START=3 \
        EF_ERRTRACK_END=5 \
        ./time-interval-measurement-test
Run Code Online (Sandbox Code Playgroud)

就像那样,ENV变量可用于./time-interval-measrument