As a rule of thumb: Anything that you indent (the "recipe") as part of a target is going to be executed in the shell.
What you did in your example is like typing "include makefile_a" in your terminal, which fails as bash doesn't know what to do with it. Conversely, "include" is a make directive that needs to sit outside of a target. If you want to conditionally include a makefile only when a certain target is being built, you can try: ifeq ($(MAKECMDGOALS),a) include makefile_a endif This finds out if the current goal (as in: if you typed 'make a' into your shell) is 'a' and then includes 'makefile_a'. Do note that this only works for the target you supply - 'MAKECMDGOALS' does not reflect the target make is building at the time, but only the one you supplied as a goal. -David On 16/06/2020 06:00, Budi wrote: > a: > include makefile_a > > Fail as said. > > On 6/16/20, Philip Guenther <[email protected]> wrote: >> On Mon, Jun 15, 2020 at 5:16 PM Budi <[email protected]> wrote: >> >>> How can we have make's 'include' command in makefile not to precede >>> the first/default target in the actual processes? >>> I found it always processed the earliest, how to solve this? >>> >> Can you describe the problem you're trying to solve, and then describe what >> you're doing that works and contrast it to what doesn't work but that you >> would like to work? >>
