1
  • I wanted to have every Env have its own Makefile (local, dev, production).

  • So I created 3 directories and a Makefile for every Directory.

  • Then creates a common MakeFile which includes all other child Makefiles as :

makefile

  • I was able to include my child commands in Parent file but the issue is
    • If I ran make local , it executes all commands inside Makefile.local
    • But instead I want each command must be ran individual
    • When mentioned like make local local_command or even make local_command , local_command must be executed only.
Jérôme
  • 11,201
  • 5
  • 47
  • 85
user5594493
  • 910
  • 2
  • 8
  • 24

1 Answers1

0

You likely want something like:

TOP_LEVEL_TARGS := dev local prod

$(TOP_LEVEL_TARGS):
    make -f config/local/Makefile.$@ $(filter-out $(TOP_LEVEL_TARGS), $(MAKECMDGOALS))

This will invoke a sub-make with all the command goals of the original make commands (minus the top level targets).

blackghost
  • 1,672
  • 9
  • 22