0

I'm trying to make a make file for a static page generator, and I'm using jinja and pandoc so far, and the idea is to have a file structure as such

.
|-content
|-public
|-templates
|-Makefile
VPATH=public
TARGETS=$(find content -regex ".*(htm|md)" | sed -e "s/md$/htm/g;s/^content/public/g")
all: $(TARGETS)
 @echo fullbuild
public/%: content/%
content/%.md:
 # Pandoc script 
 pandoc -i $@ -o ${${@:.md=.htm}:content=public}
content/%.htm:
 # Jinja Script

The problem I'm having (At least I think that's it) is that according to me the syntax is

# For a final result
target: dependency
 commands
# A rule for dependency
dependency: 
 commands

My dependencies are in the content dir and my targets are in the public dir that may or may not exist yet, and almost all the files I generate will be htm files, and in that case if the target is public/some/route/to/file.htm the dependency will be any of this two content/some/route/to/file.(htm|md).

I can easily generate by walking the content dir, and changing extensions.

How should I write the rules properly, so - Make knows where to "watch" for changes every time I do a make, because right now it points that every file is up to date - How do I indicate properly the dependency of a file to it's content file.

asked May 5, 2019 at 13:37

1 Answer 1

1

This rule:

public/%: content/%

does nothing because pattern rules without recipes delete existing pattern rules, they don't define new pattern rules.

It's very simple, you should write two rules like this:

public/%.htm: content/%.md:
 # Pandoc script 
 pandoc -i $< -o $@
public/%.htm: content/%.htm
 # Jinja Script

Here's a hint: whenever you're writing a makefile recipe and you discover that you need to create a target which is different than exactly $@, unmodified, immediately stop what you're doing and back up: you've taken a wrong turn.

answered May 5, 2019 at 18:04
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.