Overwrite variable from makefile

前端 未结 2 1352
野的像风
野的像风 2021-01-12 06:10

In my makefile I have a variable FOO:

FOO = /path/to/bar

Is it possible to overwrite this variable during the makefile call? S

2条回答
  •  死守一世寂寞
    2021-01-12 06:27

    Specify them as Var=Value before you specify the target, like make FOO=/path/to/foo all.

    $ cat Makefile 
    Foo = asdf
    
    all:
        echo $(Foo)
    
    $ make all
    echo asdf
    asdf
    $ make Foo=bar all
    echo bar
    bar
    

提交回复
热议问题