2012-04-29 2 views
1

상위 디렉토리를 "../bin"으로 참조하려고하는 샘플 프로젝트의 makefile이 있습니다. 이것은 "make install"을 실행할 때 작동하지 않는 것 같습니다. 내가 오류는 다음과 같습니다Makefile - 부모 디렉토리 참조 문제

cp: cannot stat `/bin/build/*': No such file or directory 

프로젝트의 레이아웃은 다음과 같습니다

/빈

/SRC/메이크

(그래서 메이크 파일을 실행할 때, 현재 디렉토리는/src /입니다)

상위 디렉토리를 참조하는 것으로 나타납니다. ".."가 잘못되었습니다. {CURDIR} 변수를 사용하여 현재 디렉토리를 참조 할 수 있다는 것을 알고 있지만/bin /이 올바르게 참조되도록 부모 디렉토리를 참조하는 적절한 변수 또는 방법을 알아야합니다. 나는 makefile을 움직여이 문제를 해결할 수있을 것이라고 생각하지만, 미래의 사용을 위해 이것을 수행하는 실제 방법을 알고 싶다.

makefile은 내가 GNU는 12

덕분에 리눅스 민트에 3.81를 확인 사용하고

# The name of the extension. 
extension_name := xulschoolhello 

# The UUID of the extension. 
extension_uuid := [email protected] 

# 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!" 

(문제 아르는 ##### 문제 ###### 강조)과 같다 .

@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/ 

답변

0

난 당신이 대상 폴더, $(profile_location)이 존재하고 쓰기 가능한지 확인하려고한다고 생각합니다. 또한 줄 끝이 올바른 Linux 형식 (\ n)인지 확인하십시오. 나는 다른 어떤 오류도 발견 할 수 없다.

+0

문제가되지 않는 것 같습니다. chmod'd $ (profile_location)와 같은 오류가 발생합니다. 라인 엔딩도 좋습니다. – Bryan

+0

그건 그냥 이상한 ... Cp 대신'$ (build_dir)'과'$ (profile_location)'에 echo를 할 수 있습니까? 또한 여기에 오류를 입력했거나 터미널에서 복사 했습니까? 조심스럽게 보면 인용문에 약간의 불일치가 있습니다 ... 어쩌면 이것이 단서 일 수 있습니다. –

+0

출력은 터미널에서 직선이며, 이상하게 보일 수도 있지만 확실하지는 않습니다. 질문의 끝 부분에 요청한 출력을 추가했습니다. – Bryan

0

../bin이 메이크 파일의 위치와 관련이 있지만 실행되는 위치와 관련이 없으면 어떻게 될까요? 깨끗하게 작동한다면, 그럴 수있는 신호입니다. 일부 컴파일러 옵션을 찾아 자세한 출력을 내린 다음 거기에 "pwd"문을 넣어서 어떻게 해석되는지 확인하십시오.

+0

makefile과 내가 실행중인 곳이 모두 동일합니다 (src 디렉토리). "cp"명령 전에 "pwd"권한을 올바르게 실행하면 현재 디렉토리가 project/src임을 정확하게 나타냅니다. – Bryan

+0

아마도 cp 명령의 build_dir에/*가있는 디렉토리에는 디렉토리가 들어 있지 않습니다. cp 명령의 -R은 재귀 적입니다. 대신에 build_dir을 넣으면 작동합니다. –

+0

제거하려고했습니다. 재귀 옵션뿐만 아니라 제거 "/ *"하지만 둘 다 효과. – Bryan