Specify makefile with env variable

I have the following alias, which simplifies my workflow when moving from project to project:

alias mk='make -f ${ACTIVE_MAKEFILE}'

Some background: the makefiles are in a separate directory, all together, with names related to the project that they refer to. I do not keep them in the project directory because:

  1. They are my private makefiles, and I do not want to commit them to the repo
  2. I actually want to keep track of the changes, so they must be in a repo. For that I have an umbrella project.

This is working fine ... but: I lose completion. Doing mk <TAB> does not show me the available Makefile targets, so that having the alias is actually making my workflow less efficient.

I thought that instead of telling make to use a specific makefile with the -f flag, I could set an env variable to tell make just that, something like:

export MAKEFILE=my-makefile

And then the command:

make

Will automagically use my my-makefile. Since the command has not changed, autocompletion will keep working.

But either that option does not exist, or I am unable to find the name of the env variable that make is using to select the Makefile

What env variable can I set (if any) to tell make to use a specific makefile?

Answers


Two options originally suggested in comments:

  1. Have you considered creating a symlink in each directory with a fixed, uniform name (it might be called makefileor Makefile, or even delavnog.mk) that points to the relevant out-of-directory makefile? Your alias then simply uses this fixed name, and you make sure that your VCS ignores the local symlink so it isn't pushed to the central repositories?

  2. As an alternative, use a shell script (perhaps dlnmk) instead of an alias, and have that apply the rules you have to locate the makefiles for you (so the script determines the correct name and location of the makefile and then invokes make with the correct -f option). The overhead will be minuscule and you encapsulate your thinking into a script, so you don't have to think about it any more.

Of the two, I'd probably go with the script, but I write scripts at the drop of a hat. I currently have about 400 scripts in my $HOME/bin directory, and almost 900 scripts saved in the associated RCS directory — I've been doing this for a while and Git was not an option for the first twenty years or so (because it didn't exist yet).


Need Your Help

Angular column sort clicking header

javascript angularjs sorting

I'm trying to enable sorting on all the data, as I'm also doing pagination on the client side. I'm having another issue with the paging that it is only showing the first 25 records and when I change

Akka IO.TCP with Json

sockets scala tcp akka

I've written a client and server using akka.io.tcp and I'm having a problem when reading the messages sent by the client.