matching a list of files with GNU make
This is the first time that I use GNU make to try to do something a bit less basic. I'd like the default target of a Makefile to look for any one of a number of matching filenames, a naming scheme for what I consider to be root tex files, expressed like this:
#!/usr/bin/env bash
# this is just a sketch, I know this is inaccurate
# and simplified by make's standard...
# mainfiles := main letter report course
mainfiles=(main letter report course)
_readable(){
if ([ -f "$1" ] && [ -r "$1" ]); then
return 0
fi
return 1
}
# how to make all of these existing targets using GNU make?
# all: $(patsubst %, %.tex, $$(mainfiles))
all() {
for base in $mainfiles[@]; do
if _readable "${base}.tex"; then
latexmk -pdfxe "${base}.tex"
fi
done
}
# clean:
# latexmk -c
clean(){
latexmk -c
}
I'm unsure how to turn this into a makefile.
edit:
@G-Man pointed out that my question was unclear at best. Indeed I was in a hurry, and I don't exactly know what I want. I guess want to be lazy, and use :make
instead of the fancy autocompile plugins from vim.
The point is that I used to edit a JOBNAME
variable in a generic Makefile that relies on latexmk for all of my (la|xe|lua)tex projects. When I open either of the non-existing files main.tex letter.tex course.tex etc in vim, I have it trigger an autocommand to read in a corresponding skeleton file, copy over my generic Makefile and run git init
if there's no .git
folder. Usually I only have one of those .tex
files in a folder, but there could be more of them.
I want a makefile because of a precompilation step (using mylatexformat), some more granular cleaning commands and something like a FILTER = 2>&1 | sed -n '/^(Running|Package|Beginning|Underfull)/p;/^! /,$$p'
that I can prepend to the compiler commands. The precompilation step, for example, checks @if ((
grep -c endofdump $(TMP)/$(JOBNAME).tex== 1 )); then ...
.
My question is to be understood in a lazy attempt to avoid having to specify JOBNAME
, so that any of the files main.tex letter.tex course.tex etc are treated with the same dependencies, possibly an rsync and a precompilation step that perform checks, and a compilation step that requires $JOBNAME.pdf
to be made.
I use curly braces in ${mainfiles[@]}
for what I think is good practice. I included the -f
and -r
test because I assume that make checks this, too.
Anyway, @meuh's answer was helpful, but I revisited my use of make, in that I think it remains a better choice to just edit JOBNAME
because of flexibility and future use. I now change it with the power of vim (see my vim repo on github)
make
|
show 1 more comment
This is the first time that I use GNU make to try to do something a bit less basic. I'd like the default target of a Makefile to look for any one of a number of matching filenames, a naming scheme for what I consider to be root tex files, expressed like this:
#!/usr/bin/env bash
# this is just a sketch, I know this is inaccurate
# and simplified by make's standard...
# mainfiles := main letter report course
mainfiles=(main letter report course)
_readable(){
if ([ -f "$1" ] && [ -r "$1" ]); then
return 0
fi
return 1
}
# how to make all of these existing targets using GNU make?
# all: $(patsubst %, %.tex, $$(mainfiles))
all() {
for base in $mainfiles[@]; do
if _readable "${base}.tex"; then
latexmk -pdfxe "${base}.tex"
fi
done
}
# clean:
# latexmk -c
clean(){
latexmk -c
}
I'm unsure how to turn this into a makefile.
edit:
@G-Man pointed out that my question was unclear at best. Indeed I was in a hurry, and I don't exactly know what I want. I guess want to be lazy, and use :make
instead of the fancy autocompile plugins from vim.
The point is that I used to edit a JOBNAME
variable in a generic Makefile that relies on latexmk for all of my (la|xe|lua)tex projects. When I open either of the non-existing files main.tex letter.tex course.tex etc in vim, I have it trigger an autocommand to read in a corresponding skeleton file, copy over my generic Makefile and run git init
if there's no .git
folder. Usually I only have one of those .tex
files in a folder, but there could be more of them.
I want a makefile because of a precompilation step (using mylatexformat), some more granular cleaning commands and something like a FILTER = 2>&1 | sed -n '/^(Running|Package|Beginning|Underfull)/p;/^! /,$$p'
that I can prepend to the compiler commands. The precompilation step, for example, checks @if ((
grep -c endofdump $(TMP)/$(JOBNAME).tex== 1 )); then ...
.
My question is to be understood in a lazy attempt to avoid having to specify JOBNAME
, so that any of the files main.tex letter.tex course.tex etc are treated with the same dependencies, possibly an rsync and a precompilation step that perform checks, and a compilation step that requires $JOBNAME.pdf
to be made.
I use curly braces in ${mainfiles[@]}
for what I think is good practice. I included the -f
and -r
test because I assume that make checks this, too.
Anyway, @meuh's answer was helpful, but I revisited my use of make, in that I think it remains a better choice to just edit JOBNAME
because of flexibility and future use. I now change it with the power of vim (see my vim repo on github)
make
So basically you want to have amake
rule which applies to all existing files out of a list of file names, correct?
– nohillside
Sep 20 at 18:43
2
That isbash
, notmake
. Can you explain what you want to do? Just creating something form TeX files should be straight forward.
– RalfFriedl
Sep 20 at 18:44
(1) Are you trying to generatemain.pdf
,letter.pdf
,report.pdf
, andcourse.pdf
from the corresponding.tex
files? Are you talking about usingmake
because you don’t want to runlatexmk
over and over again on a.tex
file that hasn’t changed? What do you want to do about files that don’t exist? We can’t read your mind, and people who are highly knowledgeable aboutmake
might know little or nothing aboutlatexmk
. Please explain (in English sentences) what you are trying to accomplish in your question. … (Cont’d)
– G-Man
Sep 24 at 23:26
(Cont’d) … (Please do not respond in comments; edit your question to make it clearer and more complete.) … (Cont’d)
– G-Man
Sep 24 at 23:26
(Cont’d) … (2) I understand that you are, essentially, using the above bash script as pseudo-code to describe the functionality that you want. But, for future reference, (2a) you can sayif [ -f "$1" ] && [ -r "$1" ]
(you don’t need the parentheses), (2b)if [ -r "$1" ]
is probably good enough (unless you’re concerned that you might someday have a directory or a dangling symbolic link calledmain.tex
), (2c) you can say"$base.tex"
(you don’t need the curly braces here), and (2d) you need curly braces in${mainfiles[@]}
.
– G-Man
Sep 24 at 23:26
|
show 1 more comment
This is the first time that I use GNU make to try to do something a bit less basic. I'd like the default target of a Makefile to look for any one of a number of matching filenames, a naming scheme for what I consider to be root tex files, expressed like this:
#!/usr/bin/env bash
# this is just a sketch, I know this is inaccurate
# and simplified by make's standard...
# mainfiles := main letter report course
mainfiles=(main letter report course)
_readable(){
if ([ -f "$1" ] && [ -r "$1" ]); then
return 0
fi
return 1
}
# how to make all of these existing targets using GNU make?
# all: $(patsubst %, %.tex, $$(mainfiles))
all() {
for base in $mainfiles[@]; do
if _readable "${base}.tex"; then
latexmk -pdfxe "${base}.tex"
fi
done
}
# clean:
# latexmk -c
clean(){
latexmk -c
}
I'm unsure how to turn this into a makefile.
edit:
@G-Man pointed out that my question was unclear at best. Indeed I was in a hurry, and I don't exactly know what I want. I guess want to be lazy, and use :make
instead of the fancy autocompile plugins from vim.
The point is that I used to edit a JOBNAME
variable in a generic Makefile that relies on latexmk for all of my (la|xe|lua)tex projects. When I open either of the non-existing files main.tex letter.tex course.tex etc in vim, I have it trigger an autocommand to read in a corresponding skeleton file, copy over my generic Makefile and run git init
if there's no .git
folder. Usually I only have one of those .tex
files in a folder, but there could be more of them.
I want a makefile because of a precompilation step (using mylatexformat), some more granular cleaning commands and something like a FILTER = 2>&1 | sed -n '/^(Running|Package|Beginning|Underfull)/p;/^! /,$$p'
that I can prepend to the compiler commands. The precompilation step, for example, checks @if ((
grep -c endofdump $(TMP)/$(JOBNAME).tex== 1 )); then ...
.
My question is to be understood in a lazy attempt to avoid having to specify JOBNAME
, so that any of the files main.tex letter.tex course.tex etc are treated with the same dependencies, possibly an rsync and a precompilation step that perform checks, and a compilation step that requires $JOBNAME.pdf
to be made.
I use curly braces in ${mainfiles[@]}
for what I think is good practice. I included the -f
and -r
test because I assume that make checks this, too.
Anyway, @meuh's answer was helpful, but I revisited my use of make, in that I think it remains a better choice to just edit JOBNAME
because of flexibility and future use. I now change it with the power of vim (see my vim repo on github)
make
This is the first time that I use GNU make to try to do something a bit less basic. I'd like the default target of a Makefile to look for any one of a number of matching filenames, a naming scheme for what I consider to be root tex files, expressed like this:
#!/usr/bin/env bash
# this is just a sketch, I know this is inaccurate
# and simplified by make's standard...
# mainfiles := main letter report course
mainfiles=(main letter report course)
_readable(){
if ([ -f "$1" ] && [ -r "$1" ]); then
return 0
fi
return 1
}
# how to make all of these existing targets using GNU make?
# all: $(patsubst %, %.tex, $$(mainfiles))
all() {
for base in $mainfiles[@]; do
if _readable "${base}.tex"; then
latexmk -pdfxe "${base}.tex"
fi
done
}
# clean:
# latexmk -c
clean(){
latexmk -c
}
I'm unsure how to turn this into a makefile.
edit:
@G-Man pointed out that my question was unclear at best. Indeed I was in a hurry, and I don't exactly know what I want. I guess want to be lazy, and use :make
instead of the fancy autocompile plugins from vim.
The point is that I used to edit a JOBNAME
variable in a generic Makefile that relies on latexmk for all of my (la|xe|lua)tex projects. When I open either of the non-existing files main.tex letter.tex course.tex etc in vim, I have it trigger an autocommand to read in a corresponding skeleton file, copy over my generic Makefile and run git init
if there's no .git
folder. Usually I only have one of those .tex
files in a folder, but there could be more of them.
I want a makefile because of a precompilation step (using mylatexformat), some more granular cleaning commands and something like a FILTER = 2>&1 | sed -n '/^(Running|Package|Beginning|Underfull)/p;/^! /,$$p'
that I can prepend to the compiler commands. The precompilation step, for example, checks @if ((
grep -c endofdump $(TMP)/$(JOBNAME).tex== 1 )); then ...
.
My question is to be understood in a lazy attempt to avoid having to specify JOBNAME
, so that any of the files main.tex letter.tex course.tex etc are treated with the same dependencies, possibly an rsync and a precompilation step that perform checks, and a compilation step that requires $JOBNAME.pdf
to be made.
I use curly braces in ${mainfiles[@]}
for what I think is good practice. I included the -f
and -r
test because I assume that make checks this, too.
Anyway, @meuh's answer was helpful, but I revisited my use of make, in that I think it remains a better choice to just edit JOBNAME
because of flexibility and future use. I now change it with the power of vim (see my vim repo on github)
make
make
edited Dec 16 at 11:59
Rui F Ribeiro
38.9k1479129
38.9k1479129
asked Sep 20 at 18:39
Bart
296
296
So basically you want to have amake
rule which applies to all existing files out of a list of file names, correct?
– nohillside
Sep 20 at 18:43
2
That isbash
, notmake
. Can you explain what you want to do? Just creating something form TeX files should be straight forward.
– RalfFriedl
Sep 20 at 18:44
(1) Are you trying to generatemain.pdf
,letter.pdf
,report.pdf
, andcourse.pdf
from the corresponding.tex
files? Are you talking about usingmake
because you don’t want to runlatexmk
over and over again on a.tex
file that hasn’t changed? What do you want to do about files that don’t exist? We can’t read your mind, and people who are highly knowledgeable aboutmake
might know little or nothing aboutlatexmk
. Please explain (in English sentences) what you are trying to accomplish in your question. … (Cont’d)
– G-Man
Sep 24 at 23:26
(Cont’d) … (Please do not respond in comments; edit your question to make it clearer and more complete.) … (Cont’d)
– G-Man
Sep 24 at 23:26
(Cont’d) … (2) I understand that you are, essentially, using the above bash script as pseudo-code to describe the functionality that you want. But, for future reference, (2a) you can sayif [ -f "$1" ] && [ -r "$1" ]
(you don’t need the parentheses), (2b)if [ -r "$1" ]
is probably good enough (unless you’re concerned that you might someday have a directory or a dangling symbolic link calledmain.tex
), (2c) you can say"$base.tex"
(you don’t need the curly braces here), and (2d) you need curly braces in${mainfiles[@]}
.
– G-Man
Sep 24 at 23:26
|
show 1 more comment
So basically you want to have amake
rule which applies to all existing files out of a list of file names, correct?
– nohillside
Sep 20 at 18:43
2
That isbash
, notmake
. Can you explain what you want to do? Just creating something form TeX files should be straight forward.
– RalfFriedl
Sep 20 at 18:44
(1) Are you trying to generatemain.pdf
,letter.pdf
,report.pdf
, andcourse.pdf
from the corresponding.tex
files? Are you talking about usingmake
because you don’t want to runlatexmk
over and over again on a.tex
file that hasn’t changed? What do you want to do about files that don’t exist? We can’t read your mind, and people who are highly knowledgeable aboutmake
might know little or nothing aboutlatexmk
. Please explain (in English sentences) what you are trying to accomplish in your question. … (Cont’d)
– G-Man
Sep 24 at 23:26
(Cont’d) … (Please do not respond in comments; edit your question to make it clearer and more complete.) … (Cont’d)
– G-Man
Sep 24 at 23:26
(Cont’d) … (2) I understand that you are, essentially, using the above bash script as pseudo-code to describe the functionality that you want. But, for future reference, (2a) you can sayif [ -f "$1" ] && [ -r "$1" ]
(you don’t need the parentheses), (2b)if [ -r "$1" ]
is probably good enough (unless you’re concerned that you might someday have a directory or a dangling symbolic link calledmain.tex
), (2c) you can say"$base.tex"
(you don’t need the curly braces here), and (2d) you need curly braces in${mainfiles[@]}
.
– G-Man
Sep 24 at 23:26
So basically you want to have a
make
rule which applies to all existing files out of a list of file names, correct?– nohillside
Sep 20 at 18:43
So basically you want to have a
make
rule which applies to all existing files out of a list of file names, correct?– nohillside
Sep 20 at 18:43
2
2
That is
bash
, not make
. Can you explain what you want to do? Just creating something form TeX files should be straight forward.– RalfFriedl
Sep 20 at 18:44
That is
bash
, not make
. Can you explain what you want to do? Just creating something form TeX files should be straight forward.– RalfFriedl
Sep 20 at 18:44
(1) Are you trying to generate
main.pdf
, letter.pdf
, report.pdf
, and course.pdf
from the corresponding .tex
files? Are you talking about using make
because you don’t want to run latexmk
over and over again on a .tex
file that hasn’t changed? What do you want to do about files that don’t exist? We can’t read your mind, and people who are highly knowledgeable about make
might know little or nothing about latexmk
. Please explain (in English sentences) what you are trying to accomplish in your question. … (Cont’d)– G-Man
Sep 24 at 23:26
(1) Are you trying to generate
main.pdf
, letter.pdf
, report.pdf
, and course.pdf
from the corresponding .tex
files? Are you talking about using make
because you don’t want to run latexmk
over and over again on a .tex
file that hasn’t changed? What do you want to do about files that don’t exist? We can’t read your mind, and people who are highly knowledgeable about make
might know little or nothing about latexmk
. Please explain (in English sentences) what you are trying to accomplish in your question. … (Cont’d)– G-Man
Sep 24 at 23:26
(Cont’d) … (Please do not respond in comments; edit your question to make it clearer and more complete.) … (Cont’d)
– G-Man
Sep 24 at 23:26
(Cont’d) … (Please do not respond in comments; edit your question to make it clearer and more complete.) … (Cont’d)
– G-Man
Sep 24 at 23:26
(Cont’d) … (2) I understand that you are, essentially, using the above bash script as pseudo-code to describe the functionality that you want. But, for future reference, (2a) you can say
if [ -f "$1" ] && [ -r "$1" ]
(you don’t need the parentheses), (2b) if [ -r "$1" ]
is probably good enough (unless you’re concerned that you might someday have a directory or a dangling symbolic link called main.tex
), (2c) you can say "$base.tex"
(you don’t need the curly braces here), and (2d) you need curly braces in ${mainfiles[@]}
.– G-Man
Sep 24 at 23:26
(Cont’d) … (2) I understand that you are, essentially, using the above bash script as pseudo-code to describe the functionality that you want. But, for future reference, (2a) you can say
if [ -f "$1" ] && [ -r "$1" ]
(you don’t need the parentheses), (2b) if [ -r "$1" ]
is probably good enough (unless you’re concerned that you might someday have a directory or a dangling symbolic link called main.tex
), (2c) you can say "$base.tex"
(you don’t need the curly braces here), and (2d) you need curly braces in ${mainfiles[@]}
.– G-Man
Sep 24 at 23:26
|
show 1 more comment
2 Answers
2
active
oldest
votes
This is not a particularly good use of make, as there are no dependencies, but perhaps you are going to add them later, so here is a possible start:
MAINFILES = main letter report course
T = $(addsuffix .tex,$(MAINFILES))
default: ${T}
${T}:
@if [ -f "$@" -a -r "$@" ]; then latexmk -pdfxe "$@"; else :;fi
clean:
latexmk -c
.PHONY: ${T} clean
The default target is main.tex
etc. To build that file or the others there are no dependencies, so the one-line shell script is run to do the test for file existence and readability, then the wanted command is run. The else
part is so that make does not stop with an error if the file does not exist.
There is a complication needing a .PHONY
target, otherwise when the files exist make will see there is no dependency and will do nothing.
This applies to the clean target too, in case you have a file called clean
in the directory.
Won't that re-make every target, even if it's already up to date?
– Toby Speight
Sep 28 at 7:36
@TobySpeight I agree, but that seems to be what the OP wants, and is what the script version does. As I said, there are no dependencies.
– meuh
Sep 28 at 7:42
add a comment |
It sounds like you just need a simple Makefile that knows how to make PDF from TeX:
all: $(patsubst %.tex,%.pdf,$(wildcard *.tex))
%.pdf: %.tex
latexmk -pdfxe $<
.PHONY: all
.DELETE_ON_ERROR:
Thanks, but I'd like to traverse directories and I want only the source files from my list to be compiled, which then creates its .pdf equivalent in the same directory. There could be *.tex files that are meant to be included in the source of the root file, or standalone files that are compiled manually only once.
– Bart
Sep 27 at 17:54
That's fairly easy to arrange - just change the$(wildcard *.tex)
in theall
rule to match the files you're interested in - probably using$(shell find ...)
, I expect.
– Toby Speight
Sep 28 at 7:35
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f470369%2fmatching-a-list-of-files-with-gnu-make%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is not a particularly good use of make, as there are no dependencies, but perhaps you are going to add them later, so here is a possible start:
MAINFILES = main letter report course
T = $(addsuffix .tex,$(MAINFILES))
default: ${T}
${T}:
@if [ -f "$@" -a -r "$@" ]; then latexmk -pdfxe "$@"; else :;fi
clean:
latexmk -c
.PHONY: ${T} clean
The default target is main.tex
etc. To build that file or the others there are no dependencies, so the one-line shell script is run to do the test for file existence and readability, then the wanted command is run. The else
part is so that make does not stop with an error if the file does not exist.
There is a complication needing a .PHONY
target, otherwise when the files exist make will see there is no dependency and will do nothing.
This applies to the clean target too, in case you have a file called clean
in the directory.
Won't that re-make every target, even if it's already up to date?
– Toby Speight
Sep 28 at 7:36
@TobySpeight I agree, but that seems to be what the OP wants, and is what the script version does. As I said, there are no dependencies.
– meuh
Sep 28 at 7:42
add a comment |
This is not a particularly good use of make, as there are no dependencies, but perhaps you are going to add them later, so here is a possible start:
MAINFILES = main letter report course
T = $(addsuffix .tex,$(MAINFILES))
default: ${T}
${T}:
@if [ -f "$@" -a -r "$@" ]; then latexmk -pdfxe "$@"; else :;fi
clean:
latexmk -c
.PHONY: ${T} clean
The default target is main.tex
etc. To build that file or the others there are no dependencies, so the one-line shell script is run to do the test for file existence and readability, then the wanted command is run. The else
part is so that make does not stop with an error if the file does not exist.
There is a complication needing a .PHONY
target, otherwise when the files exist make will see there is no dependency and will do nothing.
This applies to the clean target too, in case you have a file called clean
in the directory.
Won't that re-make every target, even if it's already up to date?
– Toby Speight
Sep 28 at 7:36
@TobySpeight I agree, but that seems to be what the OP wants, and is what the script version does. As I said, there are no dependencies.
– meuh
Sep 28 at 7:42
add a comment |
This is not a particularly good use of make, as there are no dependencies, but perhaps you are going to add them later, so here is a possible start:
MAINFILES = main letter report course
T = $(addsuffix .tex,$(MAINFILES))
default: ${T}
${T}:
@if [ -f "$@" -a -r "$@" ]; then latexmk -pdfxe "$@"; else :;fi
clean:
latexmk -c
.PHONY: ${T} clean
The default target is main.tex
etc. To build that file or the others there are no dependencies, so the one-line shell script is run to do the test for file existence and readability, then the wanted command is run. The else
part is so that make does not stop with an error if the file does not exist.
There is a complication needing a .PHONY
target, otherwise when the files exist make will see there is no dependency and will do nothing.
This applies to the clean target too, in case you have a file called clean
in the directory.
This is not a particularly good use of make, as there are no dependencies, but perhaps you are going to add them later, so here is a possible start:
MAINFILES = main letter report course
T = $(addsuffix .tex,$(MAINFILES))
default: ${T}
${T}:
@if [ -f "$@" -a -r "$@" ]; then latexmk -pdfxe "$@"; else :;fi
clean:
latexmk -c
.PHONY: ${T} clean
The default target is main.tex
etc. To build that file or the others there are no dependencies, so the one-line shell script is run to do the test for file existence and readability, then the wanted command is run. The else
part is so that make does not stop with an error if the file does not exist.
There is a complication needing a .PHONY
target, otherwise when the files exist make will see there is no dependency and will do nothing.
This applies to the clean target too, in case you have a file called clean
in the directory.
answered Sep 20 at 19:17
meuh
31.4k11854
31.4k11854
Won't that re-make every target, even if it's already up to date?
– Toby Speight
Sep 28 at 7:36
@TobySpeight I agree, but that seems to be what the OP wants, and is what the script version does. As I said, there are no dependencies.
– meuh
Sep 28 at 7:42
add a comment |
Won't that re-make every target, even if it's already up to date?
– Toby Speight
Sep 28 at 7:36
@TobySpeight I agree, but that seems to be what the OP wants, and is what the script version does. As I said, there are no dependencies.
– meuh
Sep 28 at 7:42
Won't that re-make every target, even if it's already up to date?
– Toby Speight
Sep 28 at 7:36
Won't that re-make every target, even if it's already up to date?
– Toby Speight
Sep 28 at 7:36
@TobySpeight I agree, but that seems to be what the OP wants, and is what the script version does. As I said, there are no dependencies.
– meuh
Sep 28 at 7:42
@TobySpeight I agree, but that seems to be what the OP wants, and is what the script version does. As I said, there are no dependencies.
– meuh
Sep 28 at 7:42
add a comment |
It sounds like you just need a simple Makefile that knows how to make PDF from TeX:
all: $(patsubst %.tex,%.pdf,$(wildcard *.tex))
%.pdf: %.tex
latexmk -pdfxe $<
.PHONY: all
.DELETE_ON_ERROR:
Thanks, but I'd like to traverse directories and I want only the source files from my list to be compiled, which then creates its .pdf equivalent in the same directory. There could be *.tex files that are meant to be included in the source of the root file, or standalone files that are compiled manually only once.
– Bart
Sep 27 at 17:54
That's fairly easy to arrange - just change the$(wildcard *.tex)
in theall
rule to match the files you're interested in - probably using$(shell find ...)
, I expect.
– Toby Speight
Sep 28 at 7:35
add a comment |
It sounds like you just need a simple Makefile that knows how to make PDF from TeX:
all: $(patsubst %.tex,%.pdf,$(wildcard *.tex))
%.pdf: %.tex
latexmk -pdfxe $<
.PHONY: all
.DELETE_ON_ERROR:
Thanks, but I'd like to traverse directories and I want only the source files from my list to be compiled, which then creates its .pdf equivalent in the same directory. There could be *.tex files that are meant to be included in the source of the root file, or standalone files that are compiled manually only once.
– Bart
Sep 27 at 17:54
That's fairly easy to arrange - just change the$(wildcard *.tex)
in theall
rule to match the files you're interested in - probably using$(shell find ...)
, I expect.
– Toby Speight
Sep 28 at 7:35
add a comment |
It sounds like you just need a simple Makefile that knows how to make PDF from TeX:
all: $(patsubst %.tex,%.pdf,$(wildcard *.tex))
%.pdf: %.tex
latexmk -pdfxe $<
.PHONY: all
.DELETE_ON_ERROR:
It sounds like you just need a simple Makefile that knows how to make PDF from TeX:
all: $(patsubst %.tex,%.pdf,$(wildcard *.tex))
%.pdf: %.tex
latexmk -pdfxe $<
.PHONY: all
.DELETE_ON_ERROR:
answered Sep 27 at 10:33
Toby Speight
5,26311031
5,26311031
Thanks, but I'd like to traverse directories and I want only the source files from my list to be compiled, which then creates its .pdf equivalent in the same directory. There could be *.tex files that are meant to be included in the source of the root file, or standalone files that are compiled manually only once.
– Bart
Sep 27 at 17:54
That's fairly easy to arrange - just change the$(wildcard *.tex)
in theall
rule to match the files you're interested in - probably using$(shell find ...)
, I expect.
– Toby Speight
Sep 28 at 7:35
add a comment |
Thanks, but I'd like to traverse directories and I want only the source files from my list to be compiled, which then creates its .pdf equivalent in the same directory. There could be *.tex files that are meant to be included in the source of the root file, or standalone files that are compiled manually only once.
– Bart
Sep 27 at 17:54
That's fairly easy to arrange - just change the$(wildcard *.tex)
in theall
rule to match the files you're interested in - probably using$(shell find ...)
, I expect.
– Toby Speight
Sep 28 at 7:35
Thanks, but I'd like to traverse directories and I want only the source files from my list to be compiled, which then creates its .pdf equivalent in the same directory. There could be *.tex files that are meant to be included in the source of the root file, or standalone files that are compiled manually only once.
– Bart
Sep 27 at 17:54
Thanks, but I'd like to traverse directories and I want only the source files from my list to be compiled, which then creates its .pdf equivalent in the same directory. There could be *.tex files that are meant to be included in the source of the root file, or standalone files that are compiled manually only once.
– Bart
Sep 27 at 17:54
That's fairly easy to arrange - just change the
$(wildcard *.tex)
in the all
rule to match the files you're interested in - probably using $(shell find ...)
, I expect.– Toby Speight
Sep 28 at 7:35
That's fairly easy to arrange - just change the
$(wildcard *.tex)
in the all
rule to match the files you're interested in - probably using $(shell find ...)
, I expect.– Toby Speight
Sep 28 at 7:35
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f470369%2fmatching-a-list-of-files-with-gnu-make%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
So basically you want to have a
make
rule which applies to all existing files out of a list of file names, correct?– nohillside
Sep 20 at 18:43
2
That is
bash
, notmake
. Can you explain what you want to do? Just creating something form TeX files should be straight forward.– RalfFriedl
Sep 20 at 18:44
(1) Are you trying to generate
main.pdf
,letter.pdf
,report.pdf
, andcourse.pdf
from the corresponding.tex
files? Are you talking about usingmake
because you don’t want to runlatexmk
over and over again on a.tex
file that hasn’t changed? What do you want to do about files that don’t exist? We can’t read your mind, and people who are highly knowledgeable aboutmake
might know little or nothing aboutlatexmk
. Please explain (in English sentences) what you are trying to accomplish in your question. … (Cont’d)– G-Man
Sep 24 at 23:26
(Cont’d) … (Please do not respond in comments; edit your question to make it clearer and more complete.) … (Cont’d)
– G-Man
Sep 24 at 23:26
(Cont’d) … (2) I understand that you are, essentially, using the above bash script as pseudo-code to describe the functionality that you want. But, for future reference, (2a) you can say
if [ -f "$1" ] && [ -r "$1" ]
(you don’t need the parentheses), (2b)if [ -r "$1" ]
is probably good enough (unless you’re concerned that you might someday have a directory or a dangling symbolic link calledmain.tex
), (2c) you can say"$base.tex"
(you don’t need the curly braces here), and (2d) you need curly braces in${mainfiles[@]}
.– G-Man
Sep 24 at 23:26