Is there a configuration file for gnu make?

前端 未结 5 962
误落风尘
误落风尘 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 12:22

    It doesn't exist, but you can do this by having a recursive call into make.

    For example:


    Makefile:

    -include $(HOME)/.makerc
    
    .DEFAULT_GOAL: all
    
    # This will handle a default goal if make is just called without any target
    all:
        $(MAKE) $(MAKE_OPTIONS) -f Makefile.real $(MAKECMDGOALS)
    
    # This handles all targets and passes it through
    %:
        $(MAKE) $(MAKE_OPTIONS) -f Makefile.real $(MAKECMDGOALS)
    


    $(HOME)/.makerc:

    MAKE_OPTIONS := -j4
    

提交回复
热议问题