英文:
My makefile only executes the first prerequisite?
问题
当我运行make时,它正确地执行第一个先决条件".m4a"文件,但然后停止不继续。我已经检查过,$(OBJ) 似乎包含了所有的文件,所以我不明白为什么它停止?
.SUFFIXES : .txt .m4a
SOURCES := $(wildcard *.m4a)
OBJ := $(subst m4a,txt,$(SOURCES))
WS = whisper
WG = wordgrinder
FLAGS = --device cuda:1 --model small
.PHONY: test clean imported
all : $(OBJ)
$(OBJ): $(SOURCES)
@echo $(WS) $(FLAGS) ./$<
@echo $(WG) --convert $(subst m4a,txt, $< ) $(subst m4a,wg, $< )
clean :
rm *~ *.json *.srt *.tsv *.vtt
imported:
mv odt/*.odt odt/imported/
test: $(SOURCES)
@echo $(OBJ)
@echo PREREQUISITES: $^
编辑:添加了make
和make test
的输出
make
whisper --device cuda:1 --model small ./Nigel_00001.m4a
wordgrinder --convert Nigel_00001.txt Nigel_00001.wg
whisper --device cuda:1 --model small ./Nigel_00001.m4a
wordgrinder --convert Nigel_00001.txt Nigel_00001.wg
make test
Nigel_00001.txt Olivier_00001.txt
PREREQUISITES: Nigel_00001.m4a Olivier_00001.m4a
英文:
When I run make, it correctly does the first prerequisite ".m4a" file, but then it stops and doesn't proceed. I've checked and the $(OBJ) does seem to have all the files in there, so I can't understand why it stops?
.SUFFIXES : .txt .m4a
SOURCES := $(wildcard *.m4a)
OBJ := $(subst m4a,txt,$(SOURCES))
WS = whisper
WG = wordgrinder
FLAGS = --device cuda:1 --model small
.PHONY: test clean imported
all : $(OBJ)
$(OBJ): $(SOURCES)
@echo $(WS) $(FLAGS) ./$<
@echo $(WG) --convert $(subst m4a,txt, $< ) $(subst m4a,wg, $< )
clean :
rm *~ *.json *.srt *.tsv *.vtt
imported:
mv odt/*.odt odt/imported/
test: $(SOURCES)
@echo $(OBJ)
@echo PREREQUISITES: $^
EDIT: Added the output of make
and make test
make
whisper --device cuda:1 --model small ./Nigel_00001.m4a
wordgrinder --convert Nigel_00001.txt Nigel_00001.wg
whisper --device cuda:1 --model small ./Nigel_00001.m4a
wordgrinder --convert Nigel_00001.txt Nigel_00001.wg
make test
Nigel_00001.txt Olivier_00001.txt
PREREQUISITES: Nigel_00001.m4a Olivier_00001.m4a
答案1
得分: 0
You've told Make to use the first prerequisite - that's what $<
means.
It looks like you wanted a pattern rule, perhaps this:
%.txt: %.m4a
$(WS) $(FLAGS) $<
$(WG) --convert $@ $(subst m4a,wg, $< )
Or perhaps even a pair of pattern rules:
%.wg: %.m4a
$(WS) $(FLAGS) $<
%.txt: %.wg
$(WG) --convert $@ $<
英文:
You've told Make to use the first prerequisite - that's what $<
means.
It looks like you wanted a pattern rule, perhaps this:
%.txt: %.m4a
$(WS) $(FLAGS) $<
$(WG) --convert $@ $(subst m4a,wg, $< )
Or perhaps even a pair of pattern rules:
%.wg: %.m4a
$(WS) $(FLAGS) $<
%.txt: %.wg
$(WG) --convert $@ $<
答案2
得分: 0
这是您要翻译的部分:
It would be very helpful if you showed (cut and paste) the output you see, in your question. I'm pretty sure that it's not the case it only runs one instance of the recipe. Instead I think what happens is that it runs the commands once for each source file but it always uses the same filename.
That's because this rule is wrong:
$(OBJ): $(SOURCES)
@echo $(WS) $(FLAGS) ./$<
@echo $(WG) --convert $(subst m4a,txt, $< ) $(subst m4a,wg, $< )
After expansion the first line is (giving some sample filenames):
foo.m4a bar.m4a baz.m4a : foo.txt bar.txt baz.txt
You appear to want make to do something like take the first target and match it up with the first prerequisite, the second target matched up with the second prerequisite, etc. but that's not how make works. The recipe above is identical to writing this:
foo.m4a : foo.txt bar.txt baz.txt
...
bar.m4a : foo.txt bar.txt baz.txt
...
bar.m4a : foo.txt bar.txt baz.txt
...
You can see that this isn't what you want, because for every recipe the value of `$<` will be the same file: `foo.txt`.
You want to use a pattern rule:
%.txt : %.m4a
@echo $(WS) $(FLAGS) ./$<
@echo $(WG) --convert $@ $*.wg
Also just a note, you shouldn't be using `subst` here. That will substitute _all_ instances of that string. So if your file is `from4all.m4a` then `$(subst m4a,txt,...)` will give you `frotxtll.txt` which is wrong. You should be using `patsubst`: `$(patsubst %.m4a,%.txt,...)`
英文:
It would be very helpful if you showed (cut and paste) the output you see, in your question. I'm pretty sure that it's not the case it only runs one instance of the recipe. Instead I think what happens is that it runs the commands once for each source file but it always uses the same filename.
That's because this rule is wrong:
$(OBJ): $(SOURCES)
@echo $(WS) $(FLAGS) ./$<
@echo $(WG) --convert $(subst m4a,txt, $< ) $(subst m4a,wg, $< )
After expansion the first line is (giving some sample filenames):
foo.m4a bar.m4a baz.m4a : foo.txt bar.txt baz.txt
You appear to want make to do something like take the first target and match it up with the first prerequisite, the second target matched up with the second prerequisite, etc. but that's not how make works. The recipe above is identical to writing this:
foo.m4a : foo.txt bar.txt baz.txt
...
bar.m4a : foo.txt bar.txt baz.txt
...
bar.m4a : foo.txt bar.txt baz.txt
...
You can see that this isn't what you want, because for every recipe the value of $<
will be the same file: foo.txt
.
You want to use a pattern rule:
%.txt : %.m4a
@echo $(WS) $(FLAGS) ./$<
@echo $(WG) --convert $@ $*.wg
Also just a note, you shouldn't be using subst
here. That will substitute all instances of that string. So if your file is from4all.m4a
then $(subst m4a,txt,...)
will give you frotxtll.txt
which is wrong. You should be using patsubst
: $(patsubst %.m4a,%.txt,...)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论