
맨 아래에서 makefile을 실행하면 오류가 발생합니다.
make: *** No rule to make target 'xhtml/%.html', needed by 'manifold/01_doehmer_syntax_pre.zip'. Stop.
target 규칙이 있기 때문에 이 오류를 이해할 수 없습니다 xhtml/%.html
. 이 규칙은 왜 중요하지 않습니까?
파일이 포함된 폴더에서 이것을 실행합니다 01_doehmer_aspekte.docx
.
BINDIR:=~/TEIC-XSLT/bin
PROFDIR:=/mnt/c/Users/niels-oliver.walkows/OneDrive/Dokumente/Luxemburg/Melusinapress/Transformationen/xslt/TEIC/profiles
MANUSCRIPTFILE:=$(shell ls *.docx)
MANUSCRIPTNAME:=$(shell basename ${MANUSCRIPTFILE} .docx)
.PHONY : all clean
all: manifold/${MANUSCRIPTNAME}.zip
tei/%.xml: %.docx
mkdir -p tei
${BINDIR}/docxtotei --profiledir=${PROFDIR} --profile=melusina $< $@
xhtml/%.html: tei/%.xml
mkdir -p xhtml
${BINDIR}/teitohtml --profiledir=${PROFDIR} --profile=melusina $< $@
cp -r tei/media xhtml/
manifold/${MANUSCRIPTNAME}.zip: xhtml/%.html
mkdir -p manifold
touch manifold/manifest.yml
cp -r tei/media manifold/
cp -r xhtml/*.html manifold/
cd manifold && zip -r ${MANUSCRIPTNAME}.zip manifest.yml media *.html
rm -rf manifold/media manifold/${MANUSCRIPTNAME}.html
test:
echo "${MANUSCRIPTFILE}"
echo "${MANUSCRIPTNAME}"
clean:
rm -rf tei xhtml manifold
답변1
목표를 정의하면 xhtml/%.html
단일 파일에 대한 레시피가 생성되는 것이 아니라이 패턴과 일치하는 모든 파일, 즉 접미사가 붙은 모든 파일(예: xhtml/
) 입니다 ..html
xhtml/foobar.html
예를 들어 다음과 같은 목표를 세울 때:
xhtml/%.html: xml/%.xml
xsltproc magic.xsl $< > $@
xml/foobar.xml:
echo '<?xml version="1.0"?><a><b><c some="attr">Lorep Ipsum</c><c some="other">Dorlor si amet</c></b></a></xml>' >$@
이제 우리는 실행 make xhtml/foobar.html
하고 만들기를 결정할 수 xhtml/foobar.html
있으며 따라서 먼저 우리가 가지고 있는 레시피를 xml/foobar.xml
만들기 위해 노력할 것입니다 .xml/foobar.xml
는 %
"임의의 텍스트 허용"으로 읽을 수 있으며 make
나중에 사용할 수 있도록 이 임의의 텍스트를 기억합니다. 그래서 를 실행하면 make xhtml/foobar.html
" 임의의 텍스트"로 make
인식하고 , 마치 작성한 것처럼 목표를 기억하고 평가합니다 .foobar
foobar
xhtml/foobar.html: xml/foobar.xml
종속성으로 넣으면 xhtml/%.html
목표의 임의 부분을 참조하는 것입니다. 마찬가지로, 을 만들 규칙을 찾을 수 없기 make xhtml/hello.html
때문에 실패합니다 .make
xml/hello.xml
Makefile에서 make
레시피에 도달 하면 manifold/${MANUSCRIPTNAME}.zip: xhtml/%.html
정적 파일 이름이기 때문에 목표에서 임의의 부분을 찾을 수 없습니다. 결과적으로 를 대체할 수 있는 것이 없으며 %
이는 단지 오류로 간주될 뿐이라고 생각합니다.
나는 당신이 무엇을 대체하고 싶은지 모르지만 %
(그래서 만들지는 않습니다) 다음과 같이 코드를 개선할 수 있다고 생각합니다.
manifold/$(MANUSCRIPTNAME).zip: manifold/%.zip: xhtml/%.html
:
이제 이 줄에는 두 개가 있습니다 . 새로운 중간 구성 요소는 파일 이름에서 make
합리적인 값을 읽는 방법을 알려줍니다.%
또는 다음을 넣을 수 있습니다.
# as your first recipe
default: manifold/$(MANUSCRIPTNAME).zip
# and then
manifold/%.zip: xhtml/%.html
[...your recipe...]
또는:
.DEFAULT_GOAL: manifold/$(MANUSCRIPTNAME).zip
manifold/%.zip: xhtml/%.html
[...your recipe...]
하지만 마지막은 GNU Make 전용이라고 생각합니다.
make
추신: 역참조하는 것이 매우 이상하다고 생각합니다 ${}
. 일반적으로 나는 $()
-constructs를 사용할 것으로 예상합니다.