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中嘗試一下,看它是否表現相同。 –