How can I write a makefile to auto-detect and parallelize the build with GNU Make?

前端 未结 7 1555
悲&欢浪女
悲&欢浪女 2021-02-01 03:37

Not sure if this is possible in one Makefile alone, but I was hoping to write a Makefile in a way such that trying to build any target in the file auto-magically detects the num

7条回答
  •  清歌不尽
    2021-02-01 04:28

    If you want it to be automatic, then you can override your typical make command to be an alias to itself in your .bashrc in your home directory.

    Example:

    alias make="make -j"
    

    Or you could do something like:

    alias jmake="make -j"
    

    in the case that you don't want to override it, but want a quick and easy (and memorable) way to run make in parallel.

提交回复
热议问题