Is there a configuration file for gnu make?

前端 未结 5 960
误落风尘
误落风尘 2021-01-17 11:37

I want to tell make that it shall always use -j4 option even if I didn\'t specify it vie command line. Normally i would do this in some configuration file (i.e.

5条回答
  •  走了就别回头了
    2021-01-17 11:58

    I like the MAKEFLAGS approach suggested by John Marshall in lieu of make supporting something like an automatic .makerc project config file. However, I didn't want to have to remember to source a .env or similar environment variables beforehand (and unsetting them afterward).

    A solution to this is to put the MAKEFLAGS assignment at the top of the Makefile itself:

    #!/usr/bin/env make
    
    MAKEFLAGS=s
    
    .PHONY: foo
    foo:
        echo "hello, make"
    

    Run it:

    $ make foo
    hello, make
    

    Compared to running without the MAKEFLAGS=... line:

    $ make foo
    echo "hello, make"
    hello, make
    

提交回复
热议问题