Search code examples
makefilebuildjekyllgnu-make

Makefile don't find rule


I'm in a Jekyll project with the following makefile:

project = jekyll-template-repository

e:          execute
execute:
            bundle
            build


r:          run
run:
            jekyll serve -l -o -b /$(project)


b:          build
build:      clean
            jekyll build

c:          clean
clean:
            jekyll clean

And when I run make execute, it throw me the error make: build: Command not found

I suppose it is trying to execute it as a common bash command, however I would like to call the build rule I wrote forward in the file. Is there some special syntax required to point to other make rules when they aren't right after another rule :?


Solution

  • You can't "call" rules in a makefile. Rules aren't functions. You can depend on a target, in which case that target will be made up to date before this target can be considered up to date.

    Each recipe of a rule is, indeed, a shell script. It's not ever a list of other targets.

    You can write:

    execute: build
    

    then it will first execute the build target's recipe (assuming it's not up to date), then after that it will execute the recipe for the execute target.