1

我有一个来自示例项目的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/
4

3 回答 3

0

我认为您应该尝试检查目标文件夹 , 是否$(profile_location)存在并且它是可写的。此外,请确保行尾具有正确的 Linux 格式 (\n)。我目前无法发现任何其他错误。

于 2012-04-29T20:04:44.453 回答
0

如果它正在运行以使 ../bin 相对于 makefile 所在的位置,而不是它正在运行的位置,该怎么办?如果 make clean 有效,那么这是一个可能是这种情况的迹象。寻找一些编译器选项以提供详细的输出,然后在其中放置一个“pwd”语句以查看它是如何解析的。

于 2012-04-29T20:06:07.730 回答
0

不是直接的答案,但是当尝试使用 GNU Make 4.2.1 在命令中引用父目录时,我发现我必须转义正斜杠......

backup:
    @tar -czvpf ..\/$(PROGRAM)-`date +'%Y%m%d%H%M'`.tar.gz $(FILES)
于 2021-08-10T23:35:26.397 回答