我有一个包含以下内容的makefile:
OSM_BUNDLER_DEP_DIR=osm-bundler-read-only/osm-bundler/software
OSM_BUNDLER_DEPS=$(OSM_BUNDLER_DEP_DIR)/pmvs/bin/pmvs2
CMVS_DIR=CMVS-PMVS/build/main
PMVS_EXE=$(CMVS_DIR)/pmvs2
OSM_BUNDLER_PMVS_DIR=$(OSM_BUNDLER_DEP_DIR)/pmvs/bin
all: $(OSM_BUNDLER_DEPS)
$(OSM_BUNDLER_PMVS_DIR)/pmvs2: $(PMVS_EXE) $(OSM_BUNDER_PMVS_DIR)
cp $(PMVS_EXE) $(OSM_BUNDLER_PMVS_DIR)
$(OSM_BUNDLER_PMVS_DIR): $(OSM_BUNDLER_DEP_DIR)
mkdir -p $(OSM_BUNDLER_PMVS_DIR)
$(OSM_BUNDLER_DEP_DIR): osm-bundler-read-only
mkdir osm-bundler-read-only/osm-bundler/software
osm-bundler-read-only:
svn checkout http://osm-bundler.googlecode.com/svn/trunk/ osm-bundler-read-only
我希望make
能够识别$(PATH_TO_ANOTHER_DIRECTORY)必须存在才能执行$(PATH_TO_ANOTHER_DIRECTORY)/subpackage
的配方。相反,它会尝试执行规则$(PATH_TO_ANOTHER_DIRECTORY)
的配方,而不先执行$(PATH_TO_ANOTHER_DIRECTORY)
的配方,从而导致错误。有趣的是,我可以执行规则来手动创建目录,一切正常:
me@localhost:~/workdir> # make does not recognize dependency
me@localhost:~/workdir> make
cp CMVS-PMVS/build/main/pmvs2 osm-bundler-read-only/osm-bundler/software/pmvs/bin
cp: cannot create regular file ‘osm-bundler-read-only/osm-bundler/software/pmvs/bin’: No such file or directory
make: *** [osm-bundler-read-only/osm-bundler/software/pmvs/bin/pmvs2] Error 1
me@localhost:~/workdir> # Specifying the dependency works
me@localhost:~/workdir> make osm-bundler-read-only/osm-bundler/software/pmvs/bin
mkdir -p osm-bundler-read-only/osm-bundler/software/pmvs/bin
me@localhost:~/workdir> # Now it executes fine
me@localhost:~/workdir> make
cp CMVS-PMVS/build/main/pmvs2 osm-bundler-read-only/osm-bundler/software/pmvs/bin
我做错了什么?