0
我正在寻找为什么sub-make不能按预期工作的解释。我需要sub-make,因为我需要在将文件复制到目标目录之前运行一些检查。Makefile - 为什么这个子工作不起作用?
下面的作品,但我没有足够的空间复制前做我的检查:
SRC_DIR=../src/
TRG_DIR=../../../trg/
target1.PREREQUISITES = file11.sth file12.sth file13.sth
target2.PREREQUISITES = file21.sth file22.sth file23.sth
copyToLocalTraining : $(TRG_DIR)file21.sth
@echo $(SRC_DIR)file21.sth
@echo $(TRG_DIR)file21.sth
$(TRG_DIR)% : $(SRC_DIR)%
@echo cp -fp $^ [email protected]
@echo ls -ltr $? [email protected]
.IGNORE:
.SUFFIXES: .sfx .sth
及以下不工作:
SRC_DIR=../src/
TRG_DIR=../../../trg/
target1.PREREQUISITES = file11.sth file12.sth file13.sth
target2.PREREQUISITES = file21.sth file22.sth file23.sth
copyToLocalTraining :
@echo "My Checks Here"
$(MAKE) $(TRG_DIR)file21.sth
$(TRG_DIR)% : $(SRC_DIR)%
@echo cp -fp $^ [email protected]
@echo ls -ltr $? [email protected]
.IGNORE:
.SUFFIXES: .sfx .sth
没有规则,使目标../../../trg/file21.sth
我介绍了一个中间步骤,看看我是否能够正常工作,但它不会:
SRC_DIR=../src/
TRG_DIR=../../../trg/
target1.PREREQUISITES = file11.sth file12.sth file13.sth
target2.PREREQUISITES = file21.sth file22.sth file23.sth
copyToLocalTraining :
@echo "My Checks Here"
$(MAKE) intermediateStep
intermediateStep : $(TRG_DIR)file21.sth
$(TRG_DIR)% : $(SRC_DIR)%
@echo cp -fp $^ [email protected]
@echo ls -ltr $? [email protected]
.IGNORE:
.SUFFIXES: .sfx .sth
我得到:没有规则,使目标intermediateStep
我无法复制您的结果;你的第二个makefile似乎工作。我建议你检查一下以确保'../ src/file21.sth'存在,然后用各种makefile尝试'make ../../../ trg/file21.sth'。 – Beta
同样在这里,不能重现这一点。它是GNU吗?你只有一个'Makefile'吗?没有'makefile'? –
我的makefile实际上叫做'maketest',我把它叫做'make -f maketest'。我在同一个目录中有另一个'make site',但我并不期望他们会干涉。 source ** file21.sth确实存在**,并确认这是第一个生成文件块在这里张贴的作品。我将在我的iMac中尝试一下,看它是否表现相同。 –