Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a configuration file for gnu make?

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. ~/.makerc).

Does such file exist for gnu make?

like image 758
devemouse Avatar asked May 18 '11 19:05

devemouse


Video Answer


2 Answers

Well, yes and no --- normally you would use an include file. Put your common configuration items together in a file, say common.mk and add

include common.mk

at the top of your makefile. If the flag doesn't have a matching way to configure it from inside the make file, you can use a function

function mk {
    make -j4 $*
}
like image 92
Charlie Martin Avatar answered Sep 28 '22 04:09

Charlie Martin


Have a read about the $(MAKEFLAGS) variable:

export MAKEFLAGS=j4

However this will likely interfere with recursive-make-based builds (not that sensible people are using recursive make anyway!), by interfering with GNU make's ability to communicate with its sub-makes.

So the more sensible approach is probably a wrapper script or an alias or shell function.

like image 33
John Marshall Avatar answered Sep 28 '22 05:09

John Marshall