下面是我的
Makefile
,我想从.adoc
生成PDF:
SHELL := /bin/bash
.DEFAULT_GOAL := all
# version and build for the target
VERSION := 1.0.0
BUILD := `git rev-parse HEAD`
# source directory
SRCDIR := ${CURDIR}/src
# create output directory
OUTDIR := ${CURDIR}/build
MAKE_OUTDIR = $(shell mkdir -p $(OUTDIR))
.PHONY: all build-html build-pdf clean
build: $(MAKE_OUTDIR) build-html build-pdf
build-html:
@$(foreach file, $(wildcard $(SRCDIR)/*.adoc), asciidoctor \
-r asciidoctor-diagram \
-o $(OUTDIR)/html/$(file%.*)_$(VERSION) $(file);)
build-pdf:
@$(foreach file, $(wildcard $(SRCDIR)/*.adoc), asciidoctor-pdf \
-r asciidoctor-diagram \
-o $(OUTDIR)/html/$(file%.*)_$(VERSION) $(file);)
clean:
@rm -rf $(OUTDIR)
问题是输出文件名只是
_1_0_0
(版本)...并且基本文件名没有被提取。我错过了什么?
这是我解决问题的方法:
build-html:
@$(foreach file, $(wildcard $(SRCDIR)/*.adoc), asciidoctor \
-r asciidoctor-diagram \
-o $(OUTDIR)/html/$(shell basename -s .adoc $(file))_$(VERSION).html $(file);)
我也使用正则表达式...但在我看来命令太长了。