我有一个来自示例项目的makefile,它试图将父目录引用为“../bin”。运行“make install”时,这似乎不起作用。我得到的错误是:
cp: cannot stat `/bin/build/*': No such file or directory
项目布局如下:
/bin
/src/makefile
(所以当我运行makefile时,当前目录是/src/)
似乎用“..”引用父目录是不正确的。我知道我可以使用 {$CURDIR} 变量引用当前目录,但我需要知道正确的变量或引用父目录的方法,以便正确引用 /bin/。我想我可以通过移动makefile来解决这个问题,但我想知道这样做的真正方法以备将来使用。
makefile 看起来像这样(问题用##### 问题###### 突出显示)
# The name of the extension.
extension_name := xulschoolhello
# The UUID of the extension.
extension_uuid := helloworld@xulschool.com
# The name of the profile dir where the extension can be installed.
profile_dir := 8mtbjosv.development
# The zip application to be used.
ZIP := zip
# The target location of the build and build files.
bin_dir := ../bin ##### problem ######
# The target XPI file.
xpi_file := $(bin_dir)/$(extension_name)2.xpi
# The type of operating system this make command is running on.
os_type := $(patsubst darwin%,darwin,$(shell echo $(OSTYPE)))
# The location of the extension profile.
ifeq ($(os_type), darwin)
profile_location := \
~/Library/Application\ Support/Firefox/Profiles/$(profile_dir)/extensions/\{$(extension_uuid)\}
else
ifeq ($(os_type), linux-gnu)
profile_location := \
~/.mozilla/firefox/$(profile_dir)/extensions/
else
profile_location := \
"$(subst \,\\,$(APPDATA))\\Mozilla\\Firefox\\Profiles\\$(profile_dir)\\extensions\\{$(extension_uuid)}"
endif
endif
# The temporary location where the extension tree will be copied and built.
build_dir := $(bin_dir)/build ##### problem ######
# This builds the extension XPI file.
.PHONY: all
all: $(xpi_file)
@echo
@echo "Build finished successfully."
@echo
# This cleans all temporary files and directories created by 'make'.
.PHONY: clean
clean:
@rm -rf $(build_dir)
@rm -f $(xpi_file)
@echo "Cleanup is done."
# The sources for the XPI file.
xpi_built := install.rdf \
chrome.manifest \
$(wildcard content/*.js) \
$(wildcard content/*.xul) \
$(wildcard content/*.xml) \
$(wildcard content/*.css) \
$(wildcard skin/*.css) \
$(wildcard skin/*.png) \
$(wildcard locale/*/*.dtd) \
$(wildcard locale/*/*.properties)
$(build_dir) $(xpi_built): $(xpi_built)
# This builds everything except for the actual XPI, and then it copies it to the
# specified profile directory, allowing a quick update that requires no install.
.PHONY: install
install: $(build_dir) $(xpi_built)
@echo "Installing in profile folder: $(profile_location)"
@cp -Rf $(build_dir)/* $(profile_location) ##### problem ######
@echo "Installing in profile folder. Done!"
@echo
$(xpi_file): $(xpi_built)
@echo "Creating XPI file."
@$(ZIP) $(xpi_file) $(xpi_built)
@echo "Creating XPI file. Done!"
我在 Linux Mint 12 上使用 GNU Make 3.81。
谢谢。
的输出
@echo "Installing in profile folder: $(profile_location)"
@echo ${build_dir}
@echo ${profile_location}
是 :
Installing in profile folder: ~/.mozilla/firefox/8mtbjosv.development/extensions/
../bin/build
/home/owner/.mozilla/firefox/8mtbjosv.development/extensions/