我正在开发一个GNU Make文件,允许我使用一个命令编译所有的LaTeX文档。到目前为止,我一直在命令行中指定目标,但我已经厌倦了。
我的LaTex文件存储在我保存PDF文件的文件夹的子文件夹中。
我的脚本能够组合我需要的列表,但目标及其规则列表的代码只处理找到的第一个LaTeX文件。我一直在搜索几个小时,以解释如何在目标/规则部分中遍历我的文件列表。我的脚本如下:
rwildcard=${foreach d,${wildcard $1*},${call rwildcard,$d/,$2} ${filter ${subst *,%,$2},$d}}
# Sub-folder containing my LaTeX files
TEX_DIR=TeX
# Build a list of LaTeX files with the relative path included
TEX_SRCS_IN = ${call rwildcard, ${TEX_DIR}/, *.tex}
# Build a list of LaTeX files w/o paths
TEX_SRCS = $(TEX_SRCS_IN:$(TEX_DIR)/%=%)
# Build a list of PDF files that need to be generated
TEX_PDF_IN = ${foreach a, ${TEX_IN}, ${a:.tex=.pdf}}
# Then remove the path information
TEX_PDF = $(TEX_PDFIN:$(TEX_DIR)/%=%)
.PHONY: all
all: ${TEX_PDF}
${TEX_PDF} : ${TEX_SRCS_IN}
clear && \
echo "Input List=${TEX_SRCS_IN}" && \
echo "LaTeX Files=${TEX_SRCS}" && \
echo "PDFs=${TEX_PDF}" && \
cd ${TEX_DIR} && \
pdflatex ${TEX_SRCS} && \
cd ../ && \
mv $(TEX_DIR)/${TEX_PDF} .
我尝试使用$(foreach doc,$(TEX_SRCS),pdflatex $(doc)&&)作为pdflatex处理器和move命令的类似语句,也许我没有得到正确的格式化?
以下是我从上面运行得到的输出。可以看出,有6个文件,make文件始终生成第一个文件(GettingStarted.tex),但没有其他文件。 如果我删除行: .PHONY:全部 全部:$ {TEX_PDF} 然后,一旦第一个文件被创建,如果它是最新的,脚本会告诉我并停止。
user@mars:~/Desktop/Project/Docs$ make -f Makefile
clear && \
echo "Input List= TeX/GettingStarted.tex TeX/GettingStarted_inst_Project_usb_Bridge.tex TeX/GettingToUse.tex TeX/DriverGettingStarted.tex TeX/RaspberryPiGettingStarted.tex TeX/instGettingStarted.tex" && \
echo "LaTeX Files=GettingStarted.tex GettingStarted_inst_Project_usb_Bridge.tex GettingToUse.tex DriverGettingStarted.tex RaspberryPiGettingStarted.tex instGettingStarted.tex" && \
echo "PDFs=GettingStarted.pdf GettingStarted_inst_Project_usb_Bridge.pdf GettingToUse.pdf DriverGettingStarted.pdf RaspberryPiGettingStarted.pdf instGettingStarted.pdf" && \
cd TeX && \
pdflatex GettingStarted.tex GettingStarted_inst_Project_usb_Bridge.tex GettingToUse.tex DriverGettingStarted.tex RaspberryPiGettingStarted.tex instGettingStarted.tex && \
cd ../ && \
mv TeX/GettingStarted.pdf GettingStarted_inst_Project_usb_Bridge.pdf GettingToUse.pdf DriverGettingStarted.pdf RaspberryPiGettingStarted.pdf instGettingStarted.pdf .
Input List= TeX/GettingStarted.tex TeX/GettingStarted_inst_Project_usb_Bridge.tex TeX/GettingToUse.tex TeX/DriverGettingStarted.tex TeX/RaspberryPiGettingStarted.tex TeX/instGettingStarted.tex
LaTeX Files=GettingStarted.tex GettingStarted_inst_Project_usb_Bridge.tex GettingToUse.tex DriverGettingStarted.tex RaspberryPiGettingStarted.tex instGettingStarted.tex
PDFs=GettingStarted.pdf GettingStarted_inst_Project_usb_Bridge.pdf GettingToUse.pdf DriverGettingStarted.pdf RaspberryPiGettingStarted.pdf instGettingStarted.pdf
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian)
restricted \write18 enabled.
entering extended mode
(./GettingStarted.tex
LaTeX2e <2011/06/27>
Babel <3.9f> and hyphenation patterns for 2 languages loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo)) (./FillAFour.sty)
(/usr/share/texlive/texmf-dist/tex/latex/url/url.sty)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/color.sty
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/color.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/pdftex-def/pdftex.def
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)))
(/usr/share/texlive/texmf-dist/tex/latex/base/alltt.sty)
(/usr/share/texlive/texmf-dist/tex/latex/upquote/upquote.sty)
(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.def))
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hyperref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty))
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/auxhook.sty)
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty)
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/hyperref.cfg)
Package hyperref Warning: Option `a4paper' is no longer used.
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/backref.sty
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty)))
Package hyperref Message: Driver: hpdftex.
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hpdftex.def)
(./GettingStarted.aux)
(/usr/share/texlive/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texlive/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))
(./GettingStarted.out) (./GettingStarted.out)
(/usr/share/texlive/texmf-dist/tex/latex/base/omscmr.fd)
(/usr/share/texlive/texmf-dist/tex/latex/base/t1cmtt.fd) (./GettingStarted.toc
[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}]) [2]
Overfull \hbox (26.10161pt too wide) in paragraph at lines 207--207
\T1/cmtt/m/n/10 sudo apt-get install libavahi-cil-dev libavahi-compat-libdnssd1
python-dev libicu-dev
[25] [26] [27] [28] [29] [30] (./GettingStarted.aux) )
kpathsea: Running mktexpk --mfmode / --bdpi 600 --mag 1+0/600 --dpi 600 ecbi1200
mktexpk: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1+0/600; nonstopmode; input ecbi1200
This is METAFONT, Version 2.718281 (TeX Live 2013/Debian)
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/ecbi1200.mf
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exbase.mf)
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/ecbi.mf
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/extextit.mf
Ok (/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exaccess.mf
Ok) (/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/expseudo.mf
Ok) (/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exileast.mf
Ok [158] [160] [161] [162] [163] [164] [165] [166] [167] [168] [169] [170]
[171] [172] [173] [174] [175] [176] [177] [178] [179] [180] [181] [182]
[183] [184] [185] [186] [187] [188])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exilwest.mf
Ok [224] [225] [226] [227] [228] [229] [230] [231] [232] [233] [234] [235]
[236] [237] [238] [239] [240] [241] [242] [243] [244] [245] [246] [247]
[248] [249] [250] [251] [252] [253] [254] [255])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exruwest.mf
Ok [192] [193] [194] [195] [196] [197] [198] [199] [200] [201] [202] [203]
[204] [205] [206] [207] [208] [209] [210] [211] [212] [213] [214] [215]
[216] [217] [218] [219] [220] [221] [222] [223])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrueast.mf
Ok [128] [129] [130] [131] [132] [133] [134] [135] [136] [137] [138] [139]
[140] [141] [142] [143] [144] [145] [146] [147] [148] [149] [150] [151]
[152] [153] [154] [155] [156] [157])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exbraces.mf
Ok [94] [126] [23] [40] [41] [60] [124] [62] [91] [93] [92] [123] [125]
[95] [127] [32])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/expunct.mf
Ok [14] [15] [19] [20] [13] [18] [33] [39] [42] [43] [44] [46] [47] [58]
[59] [61] [96] [189] [17] [45] [16] [21] [22])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exaccent.mf
Ok [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exsign.mf
Ok [24] [34] [35] [36] [37] [64] [191] [159])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exilig.mf
Ok [25] [26] [27] [28] [29] [30] [31])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exitalp.mf
Ok [38] [63] [190])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrulett.mf
Ok [65] [66] [67] [68] [69] [70] [71] [72] [73] [74] [75] [76] [77] [78]
[79] [80] [81] [82] [83] [84] [85] [86] [87] [88] [89] [90])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exillett.mf
Ok [97] [98] [99] [100] [101] [102] [103] [104] [105] [106] [107] [108]
[109] [110] [111] [112] [113] [114] [115] [116] [117] [118] [119] [120]
[121] [122])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exidigit.mf
Ok [48] [49] [50] [51] [52] [53] [54] [55] [56] [57])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exiligtb.mf
Ok) ) ) )
(some charht values had to be adjusted by as much as 0.09164pt)
Font metrics written on ecbi1200.tfm.
Output written on ecbi1200.600gf (256 characters, 62216 bytes).
Transcript written on ecbi1200.log.
mktexpk: /tmp/texfonts/pk/ljfour/jkuserpen/ec/ecbi1200.600pk: successfully generated.
(see the transcript file for additional information) </tmp/texfonts/pk/ljfour/j
kuserpen/ec/ecbi1200.600pk>
kpathsea: Running mktexpk --mfmode / --bdpi 600 --mag 0+525/600 --dpi 525 ectt0800
mktexpk: Running mf-nowin -progname=mf \mode:=ljfour; mag:=0+525/600; nonstopmode; input ectt0800
This is METAFONT, Version 2.718281 (TeX Live 2013/Debian)
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/ecrm1200.mf
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exbase.mf)
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/ecrm.mf
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exroman.mf
Ok (/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exaccess.mf
Ok) (/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/expseudo.mf
Ok) (/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exruwest.mf
Ok [192] [193] [194] [195] [196] [197] [198] [199] [200] [201] [202] [203]
[204] [205] [206] [207] [208] [209] [210] [211] [212] [213] [214] [215]
[216] [217] [218] [219] [220] [221] [222] [223])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrlwest.mf
Ok [224] [225] [226] [227] [228] [229] [230] [231] [232] [233] [234] [235]
[236] [237] [238] [239] [240] [241] [242] [243] [244] [245] [246] [247]
[248] [249] [250] [251] [252] [253] [254] [255])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrueast.mf
Ok [128] [129] [130] [131] [132] [133] [134] [135] [136] [137] [138] [139]
[140] [141] [142] [143] [144] [145] [146] [147] [148] [149] [150] [151]
[152] [153] [154] [155] [156] [157])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrleast.mf
Ok [158] [160] [161] [162] [163] [164] [165] [166] [167] [168] [169] [170]
[171] [172] [173] [174] [175] [176] [177] [178] [179] [180] [181] [182]
[183] [184] [185] [186] [187] [188])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exbraces.mf
Ok [94] [126] [23] [40] [41] [60] [124] [62] [91] [93] [92] [123] [125]
[95] [127] [32])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/expunct.mf
Ok [14] [15] [19] [20] [13] [18] [33] [39] [42] [43] [44] [46] [47] [58]
[59] [61] [96] [189] [17] [45] [16] [21] [22])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exaccent.mf
Ok [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exsign.mf
Ok [24] [34] [35] [36] [37] [64] [191] [159])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrlig.mf
Ok [25] [26] [28] [27] [29] [30] [31])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exromp.mf
Ok [38] [63] [190])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrulett.mf
Ok [65] [66] [67] [68] [69] [70] [71] [72] [73] [74] [75] [76] [77] [78]
[79] [80] [81] [82] [83] [84] [85] [86] [87] [88] [89] [90])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrllett.mf
Ok [97] [98] [99] [100] [101] [102] [103] [104] [105] [106] [107] [108]
[109] [110] [111] [112] [113] [114] [115] [116] [117] [118] [119] [120]
[121] [122])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrdigit.mf
Ok [48] [49] [50] [51] [52] [53] [54] [55] [56] [57])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrligtb.mf
Ok) ) ) )
(some charht values had to be adjusted by as much as 0.07143pt)
Font metrics written on ecrm1200.tfm.
Output written on ecrm1200.600gf (256 characters, 60320 bytes).
Transcript written on ecrm1200.log.
mktexpk: /tmp/texfonts/pk/ljfour/jkuserpen/ec/ecrm1200.600pk: successfully generated.
</tmp/texfonts/pk/ljfour/jkuserpen/ec/ecrm1200.600pk>
kpathsea: Running mktexpk --mfmode / --bdpi 600 --mag 1+0/600 --dpi 600 ecrm1728
mktexpk: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1+0/600; nonstopmode; input ecrm1728
This is METAFONT, Version 2.718281 (TeX Live 2013/Debian)
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/ecrm1728.mf
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exbase.mf)
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/ecrm.mf
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exroman.mf
Ok (/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exaccess.mf
Ok) (/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/expseudo.mf
Ok) (/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exruwest.mf
Ok [192] [193] [194] [195] [196] [197] [198] [199] [200] [201] [202] [203]
[204] [205] [206] [207] [208] [209] [210] [211] [212] [213] [214] [215]
[216] [217] [218] [219] [220] [221] [222] [223])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrlwest.mf
Ok [224] [225] [226] [227] [228] [229] [230] [231] [232] [233] [234] [235]
[236] [237] [238] [239] [240] [241] [242] [243] [244] [245] [246] [247]
[248] [249] [250] [251] [252] [253] [254] [255])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrueast.mf
Ok [128] [129] [130] [131] [132] [133] [134] [135] [136] [137] [138] [139]
[140] [141] [142] [143] [144] [145] [146] [147] [148] [149] [150] [151]
[152] [153] [154] [155] [156] [157])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrleast.mf
Ok [158] [160] [161] [162] [163] [164] [165] [166] [167] [168] [169] [170]
[171] [172] [173] [174] [175] [176] [177] [178] [179] [180] [181] [182]
[183] [184] [185] [186] [187] [188])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exbraces.mf
Ok [94] [126] [23] [40] [41] [60] [124] [62] [91] [93] [92] [123] [125]
[95] [127] [32])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/expunct.mf
Ok [14] [15] [19] [20] [13] [18] [33] [39] [42] [43] [44] [46] [47] [58]
[59] [61] [96] [189] [17] [45] [16] [21] [22])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exaccent.mf
Ok [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exsign.mf
Ok [24] [34] [35] [36] [37] [64] [191] [159])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrlig.mf
Ok [25] [26] [28] [27] [29] [30] [31])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exromp.mf
Ok [38] [63] [190])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrulett.mf
Ok [65] [66] [67] [68] [69] [70] [71] [72] [73] [74] [75] [76] [77] [78]
[79] [80] [81] [82] [83] [84] [85] [86] [87] [88] [89] [90])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrllett.mf
Ok [97] [98] [99] [100] [101] [102] [103] [104] [105] [106] [107] [108]
[109] [110] [111] [112] [113] [114] [115] [116] [117] [118] [119] [120]
[121] [122])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrdigit.mf
Ok [48] [49] [50] [51] [52] [53] [54] [55] [56] [57])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrligtb.mf
Ok) ) ) )
(some charht values had to be adjusted by as much as 0.0972pt)
Font metrics written on ecrm1728.tfm.
Output written on ecrm1728.600gf (256 characters, 84608 bytes).
Transcript written on ecrm1728.log.
mktexpk: /tmp/texfonts/pk/ljfour/jkuserpen/ec/ecrm1728.600pk: successfully generated.
</tmp/texfonts/pk/lj
four/jkuserpen/ec/ecrm1728.600pk></usr/share/texlive/texmf-dist/fonts/type1/publ
ic/amsfonts/cm/cmmi10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/ams
fonts/cm/cmsy10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/
cm/cmsy9.pfb>
Output written on GettingStarted.pdf (30 pages, 282962 bytes).
Transcript written on GettingStarted.log.
mv: cannot stat ‘GettingStarted_inst_Project_usb_Bridge.pdf’: No such file or directory
mv: cannot stat ‘GettingToUse.pdf’: No such file or directory
mv: cannot stat ‘DriverGettingStarted.pdf’: No such file or directory
mv: cannot stat ‘RaspberryPiGettingStarted.pdf’: No such file or directory
mv: cannot stat ‘instGettingStarted.pdf’: No such file or directory
make: *** [GettingStarted_inst_Project_usb_Bridge.pdf] Error 1
user@mars:~/Desktop/Project/Docs$
在我看来.PHONY: all all: ${TEX_PDF}
行没有产生我想要的行为,但对我来说主要的问题仍然是; 仅处理第一个文件。
如何让目标及其规则列表遍历整个文件列表?
已更新
现在几乎已修复,问题在于${TEX_PDF}
的依赖关系。
现在正在制作所有文件,但依赖项计算无法正常工作。
删除${TEX_IN}
并将其留空,并更改规则中引用依赖项的方式(使用目标名称($ @)并替换扩展名)使其适用于单次运行。
将依赖项更改为$(TEX_DIR)/$(@:.pdf=.tex)
会导致每次运行所有文件。
为方便起见,我添加了一行来清理pdflatex
自动生成的文件(.out,.log,.toc和.aux)。如果不需要,可以对其进行编辑或删除。
rwildcard=${foreach d,${wildcard $1*},${call rwildcard,$d/,$2} ${filter ${subst *,%,$2},$d}}
TEX_DIR=TeX # Sub-folder containing TEX files
TEX_SRCS_IN = ${call rwildcard, ${TEX_DIR}/, *.tex} # 'TEX' List with paths
TEX_PDF_IN = ${foreach a, ${TEX_SRCS_IN}, ${a:.tex=.pdf} } # 'PDF' List with paths
TEX_PDF = $(TEX_PDF_IN:$(TEX_DIR)/%=%) # 'PDF' List without paths
.PHONY: all
all: ${TEX_PDF}
${TEX_PDF} : $(TEX_DIR)/$(@:.pdf=.tex)
cd ${TEX_DIR} && \
pdflatex $(@:.pdf=.tex) && \
rm $(@:.pdf=.out) $(@:.pdf=.log) $(@:.pdf=.toc) $(@:.pdf=.aux) && \
cd ../ && \
mv $(TEX_DIR)/$@ .
答案 0 :(得分:1)
这可能是关于make的三个最常见问题之一。在没有参数的情况下运行make
时,它只构建makefile中列出的第一个目标。如果您希望它构建多个目标,则需要在makefile的开头放置一个新目标,该目标取决于您想要构建的其他目标。
所以,在第一个目标之前添加这一行:
.PHONY: all
all: ${TEX_PDF}
ETA:
仅处理第一个文件,因为处理第一个文件的最终结果是失败:make: *** [GettingStarted_inst_Project_usb_Bridge.pdf] Error 1
。默认情况下,make会在第一次失败后停止,并且不再构建任何内容。如果您希望继续使用,可以运行make -k
。
但是,我建议你修复你的失败,然后它会继续。
问题在于规则的结束,你说:
mv $(TEX_DIR)/${TEX_PDF} .
TEX_PDF
包含一个文件列表,因此扩展为(从输出中可以看到):
mv TeX/GettingStarted.pdf GettingStarted_inst_Project_usb_Bridge.pdf GettingToUse.pdf DriverGettingStarted.pdf RaspberryPiGettingStarted.pdf instGettingStarted.pdf .
这显然不是你想要的。您只想移动您正在创建的一个文件,该文件将作为自动变量$@
提供给您。
答案 1 :(得分:1)
终于修好了。正如我所预期的那样现在正在工作。
将目标定义更改为通用格式%.pdf
,并且在子文件夹${TEX_DIR}/%.tex
中定义了相似的依赖关系。使用NO-OP命令为依赖项添加了目标/规则。
# Usage:
# From the ./Docs folder
#
# Scan the TeX folder and make all necessary PDF's
# make -f Makefile
#
# Make a specific TEX file
# make -f Makefile TEX_SRCS_IN=<filename>.tex
#
#
rwildcard=${foreach d,${wildcard $1*},${call rwildcard,$d/,$2} ${filter ${subst *,%,$2},$d}}
TEX_DIR=TeX # Sub-folder containing TEX files
TEX_SRCS_IN = ${call rwildcard, ${TEX_DIR}/, *.tex} # 'TEX' List with paths
TEX_PDF_IN = ${foreach a, ${TEX_SRCS_IN}, ${a:.tex=.pdf} } # 'PDF' List with paths
TEX_PDF = $(TEX_PDF_IN:$(TEX_DIR)/%=%) # 'PDF' List without paths
.PHONY: all
all: ${TEX_PDF}
%.pdf : ${TEX_DIR}/%.tex
cd ${TEX_DIR} && \
pdflatex $(@:.pdf=.tex) && \
rm $(@:.pdf=.out) $(@:.pdf=.log) $(@:.pdf=.toc) $(@:.pdf=.aux) && \
cd ../ && \
mv $(TEX_DIR)/$@ .
${TEX_DIR}/%.tex:
@: