2014-10-29 5 views
1

при использовании pdftk для извлечения страниц в файле Makefile команда pdftk всегда выполняется независимо от того, изменился ли файл pdf предварительного просмотра или нет.pdftk в Makefile каждый раз запускается при выполнении

document.tex:

\documentclass[10pt]{article} 
\begin{document} 
Page one 
\newpage 
Page two 
\end{document} 

Сделать файл PDF:

pdflatex document.tex 

Makefile:

all: document page-one 

document: document.tex 
     pdflatex $< 

page-one: document 
     pdftk A=$<.pdf cat A1 output PageOne.pdf 

Каждый раз, когда я

make all 

Выполняется команда pdftk. Я бы хотел только извлечь страницу, если родительский документ изменился. Есть идеи? В конечном итоге команда pdflatex также войдет в Makefile, но для того, чтобы выделить проблему, я ее оставил.

Edit:

Пожалуйста, обратите внимание, что я изменил Makefile для ясности. И вот два прогона по запросу.

Первый запуск производит

$ make -dRr page-one 
GNU Make 3.81 
Copyright (C) 2006 Free Software Foundation, Inc. 
This is free software; see the source for copying conditions. 
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A 
PARTICULAR PURPOSE. 

This program built for x86_64-pc-linux-gnu 
Reading makefiles... 
Reading makefile `Makefile'... 
Updating makefiles.... 
Considering target file `Makefile'. 
    Looking for an implicit rule for `Makefile'. 
    No implicit rule found for `Makefile'. 
    Finished prerequisites of target file `Makefile'. 
No need to remake target `Makefile'. 
Updating goal targets.... 
Considering target file `page-one'. 
File `page-one' does not exist. 
    Considering target file `document'. 
    File `document' does not exist. 
    Considering target file `document.tex'. 
    Looking for an implicit rule for `document.tex'. 
    No implicit rule found for `document.tex'. 
    Finished prerequisites of target file `document.tex'. 
    No need to remake target `document.tex'. 
    Finished prerequisites of target file `document'. 
    Must remake target `document'. 
pdflatex document.tex 
Putting child 0x0198c5c0 (document) PID 4347 on the chain. 
Live child 0x0198c5c0 (document) PID 4347 
This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) 
entering extended mode 
(./document.tex 
LaTeX2e <2009/09/24> 
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh 
yphenation, ngerman, german, german-x-2009-06-19, ngerman-x-2009-06-19, loaded, 

(/usr/share/texmf-texlive/tex/latex/base/article.cls 
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class 
(/usr/share/texmf-texlive/tex/latex/base/size10.clo)) (./document.aux) [1{/var/ 
lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] [2] (./document.aux))</usr/shar 
e/texmf-texlive/fonts/type1/public/amsfonts/cm/cmr10.pfb> 
Output written on document.pdf (2 pages, 13250 bytes). 
Transcript written on document.log. 
Reaping winning child 0x0198c5c0 PID 4347 
Removing child 0x0198c5c0 PID 4347 from chain. 
    Successfully remade target file `document'. 
Finished prerequisites of target file `page-one'. 
Must remake target `page-one'. 
pdftk A=document.pdf cat A1 output PageOne.pdf 
Putting child 0x0198ea40 (page-one) PID 4348 on the chain. 
Live child 0x0198ea40 (page-one) PID 4348 
Reaping winning child 0x0198ea40 PID 4348 
Removing child 0x0198ea40 PID 4348 from chain. 
Successfully remade target file `page-one'. 

И второй раз:

$ make -dRr page-one 
GNU Make 3.81 
Copyright (C) 2006 Free Software Foundation, Inc. 
This is free software; see the source for copying conditions. 
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A 
PARTICULAR PURPOSE. 

This program built for x86_64-pc-linux-gnu 
Reading makefiles... 
Reading makefile `Makefile'... 
Updating makefiles.... 
Considering target file `Makefile'. 
    Looking for an implicit rule for `Makefile'. 
    No implicit rule found for `Makefile'. 
    Finished prerequisites of target file `Makefile'. 
No need to remake target `Makefile'. 
Updating goal targets.... 
Considering target file `page-one'. 
File `page-one' does not exist. 
    Considering target file `document'. 
    File `document' does not exist. 
    Considering target file `document.tex'. 
    Looking for an implicit rule for `document.tex'. 
    No implicit rule found for `document.tex'. 
    Finished prerequisites of target file `document.tex'. 
    No need to remake target `document.tex'. 
    Finished prerequisites of target file `document'. 
    Must remake target `document'. 
pdflatex document.tex 
Putting child 0x019ef5c0 (document) PID 4398 on the chain. 
Live child 0x019ef5c0 (document) PID 4398 
This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) 
entering extended mode 
(./document.tex 
LaTeX2e <2009/09/24> 
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh 
yphenation, ngerman, german, german-x-2009-06-19, ngerman-x-2009-06-19, loaded. 

(/usr/share/texmf-texlive/tex/latex/base/article.cls 
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class 
(/usr/share/texmf-texlive/tex/latex/base/size10.clo)) (./document.aux) [1{/var/ 
lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] [2] (./document.aux))</usr/shar 
e/texmf-texlive/fonts/type1/public/amsfonts/cm/cmr10.pfb> 
Output written on document.pdf (2 pages, 13250 bytes). 
Transcript written on document.log. 
Reaping winning child 0x019ef5c0 PID 4398 
Removing child 0x019ef5c0 PID 4398 from chain. 
    Successfully remade target file `document'. 
Finished prerequisites of target file `page-one'. 
Must remake target `page-one'. 
pdftk A=document.pdf cat A1 output PageOne.pdf 
Putting child 0x019f1a40 (page-one) PID 4399 on the chain. 
Live child 0x019f1a40 (page-one) PID 4399 
Reaping winning child 0x019f1a40 PID 4399 
Removing child 0x019f1a40 PID 4399 from chain. 
Successfully remade target file `page-one'. 
+0

Что 'делает -d' (' сделать -dRr', если это работает поможет сократить выход существенно), скажем, когда вы запускаете его в одном из случаев, когда вы считаете, что он не должен запускаться 'pdftk'? –

ответ

0

Чтобы получить этот Makefile работать, вы должны указать существующие цели, то есть. реальные имена файлов (включая суффикс). Кроме того, вы создаете файл с именем PageOne.pdf, но проверяете файл с именем page-one, который не может быть найден.
Это более или менее то, что вы писали выше:

... 
Considering target file `page-one'. 
File `page-one' does not exist. 
Considering target file `document'. 
File `document' does not exist.` 
... 

Работающий Makefile будет выглядеть

all: document.pdf page-one.pdf 

document.pdf: document.tex 
    pdflatex $< 

page-one.pdf: document.pdf 
    pdftk A=$< cat A1 output page-one.pdf 
+0

Большое спасибо Якоб. – Milton