Using make variable in bash scripting as part of a makefile command
3
votes
1
answer
598
views
I've created a makefile command to automate a publishing workflow using Pandoc and the [Generic Preprocessor (GPP)](https://files.nothingisreal.com/software/gpp/gpp.html) . It is as follows:
TODAY = $(shell date +'%Y%m%d-%H%M')
MACROS = utils/gpp/macros.md
TEMPLATE = utils/template.docx
GPP = utils/gpp/gpp.exe
MACROS = utils/gpp/_macros.pp
METADATA = metadata.yaml
FM = content/frontmatter/*.md
MM = content/mainmatter/*.md
CONTENT = $(FM) $(MM)
default: docx
docx:
for file in $(CONTENT); do \
fifo=$$(mktemp -u); \
FIFOS+=("$$fifo"); \
cat $(MACROS) "$$file" | \
$(GPP) -DWORD -x -o "$$fifo" & \
done; \
pandoc metadata.yaml "$${FIFOS[@]}" -f markdown -t docx \
--citeproc --csl $(CSL) \
--reference-doc=$(TEMPLATE) \
--file-scope \
-o dist/$(TODAY).docx
It runs fine on the [Git terminal](https://git-scm.com/downloads) on Windows. However on my on Ubuntu 24.04 system, I'm getting a /bin/sh: 1: Syntax error: "(" unexpected
error, and it points towards the line for file in $(CONTENT); do \
. I've tried the following to no avail:
1. for file in ( $(CONTENT) ); do \
2. for file in "$(CONTENT)"; do \
Why is this happening, and how can I rectify it? (Yes, I'm aware that the GPP link has to be updated for Ubuntu but it doesn't even reach that line)
The repository is public if anyone wants to try it locally: https://github.com/khalid-hussain/editorial-project-template
Asked by Khalid Hussain
(135 rep)
Feb 12, 2025, 08:00 PM
Last activity: Feb 13, 2025, 04:54 AM
Last activity: Feb 13, 2025, 04:54 AM