【发布时间】:2019-04-24 03:34:18
【问题描述】:
我有以下 Makefile,但它不起作用。当我打电话时
make html
我得到一个
make: *** No rule to make target `docs/index.html', needed by `html'. Stop.
错误,尽管我认为我已经定义了它。
SRCDIR = source
OUTDIR = docs
RMD = $(wildcard $(SRCDIR)/*.Rmd)
TMP = $(RMD:.Rmd=.html)
HTML = ${subst $(SRCDIR),$(OUTDIR),$(TMP)}
test:
echo $(RMD)
echo $(TMP)
echo $(HTML)
all: clean update html
html: $(HTML)
%.html: %.Rmd
echo $(HTML)
@Rscript -e "rmarkdown::render('$<', output_format = 'prettydoc::html_pretty', output_dir = './$(OUTDIR)/')"
update:
@Rscript -e "devtools::load_all(here::here()); microcosmScheme:::updateFromGoogleSheet(token = './source/googlesheets_token.rds')"
## from https://stackoverflow.com/a/26339924/632423
list:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
.PHONY: update clean cleanhtml all list
变量似乎是正确的:
15:21 $ make test
echo source/index.Rmd
source/index.Rmd
echo source/index.html
source/index.html
echo docs/index.html
docs/index.html
如果我按以下方式更改它,它可以工作,但目标指向 SRCDIR,但我希望它指向 OUTDIR:
RMD = $(wildcard $(SRCDIR)/*.Rmd)
HTML = $(RMD:.Rmd=.html)
# HTML = ${subst $(SRCDIR),$(OUTDIR),$(TMP)}
我相信这是一件小事......
【问题讨论】:
-
您没有声明
help是假的有什么原因吗? -
我有“帮助”目标吗?
-
抱歉,我的意思是
html(我经常将虚假的help目标作为我的默认目标)。 -
这正是我不想要的。但感谢您指出 =at 选项。