Using Makefiles in projects where I can not use them

In Makefile for lazy developers, I have shared how I use Makefiles to save time running frequent tasks.

As a maintainer of a project, I can use any tool I like to get the job done, and of course, I use Makefiles in all of these projects.

As a collaborator of a project, I do not have that luxury. I depend on the owners of a project. Some projects already use an alternative, perhaps composer scripts or PHing. Occasionally I have suggested the use of Makefiles. Often the owners have stated that they prefer not to use Makefiles. Rarely the owners already have a Makefile but object to modifications.

I respect that. However, I can still use Makefiles the way I like in every single project, and as a matter of fact, I do.

In Project notes, I have shared how I keep files in a .note/ directory within the root directory of a project - without the need to check them into version control. This directory is where I put a Makefile when necessary.

I can now run

make -f .note/Makefile

to run the first target of the Makefile, but I find that this is too much work.

Instead, I have adjusted the alias I previously used from

alias m="make"

to

alias m="if [[ -f .note/Makefile ]]; then make -f .note/Makefile; else make; fi"

Now I can run

m

in every single project and still use Makefiles the way I prefer.

Do you find this article helpful?

Do you have feedback?

Do you need help with your PHP project?