每次都会执行Makefile中的pdftk

时间:2014-10-29 20:17:29

标签: makefile gnu-make pdftk

当使用pdftk提取Makefile中的页面时,无论前提条件pdf文件是否发生更改,都会执行pdftk命令。

document.tex:

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

制作pdf档案:

pdflatex document.tex

生成文件:

all: document page-one

document: document.tex
        pdflatex $<

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

每次我做

make all

执行pdftk命令。如果父文档发生更改,我只想提取页面。有任何想法吗?最终,pdflatex命令也会出现在Makefile中,但为了突出显示问题,我将其删除了。

修改

请注意,为了清楚起见,我更改了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'.

1 个答案:

答案 0 :(得分: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