2011-02-17 2 views
17

나는 아래와 같은 메이크 파일로 만든 파일 foo1foo3을 기대하고 있습니다. 그러나 파일 foo3 만 생성됩니다. 나에게 통조림 제조법 make-foo은 make가 무시하는 것 같다. foo1foo2 (빈 제조법)의 디버그 결과는 동일합니다.왜 GNU 통조림 제조법을 만들 수 없습니까?

# why canned recipe doesn't work ? 
# http://www.gnu.org/software/make/manual/make.html#Canned-Recipes 
define make-foo = 
echo making [email protected] 
touch [email protected] 
endef 

.PHONY: all 
all: foo1 foo2 foo3 

# foo1 is not created, but why ? 
.PHONY: foo1 
foo1: 
    $(make-foo) 

# debug output similar to foo1 
.PHONY: foo2 
foo2: 

# this works 
.PHONY: foo3 
foo3: 
    echo making [email protected] 
    touch [email protected] 

실행 메이크업 :

[email protected]:/dev/shm$ make -dRr 
GNU Make 3.81 
Copyright (C) 2006 Free Software Foundation, Inc. 
This is free software; see the source for copying conditions. 
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A 
PARTICULAR PURPOSE. 

This program built for i686-pc-linux-gnu 
Reading makefiles... 
Reading makefile `makefile'... 
Updating makefiles.... 
Considering target file `makefile'. 
    Looking for an implicit rule for `makefile'. 
    No implicit rule found for `makefile'. 
    Finished prerequisites of target file `makefile'. 
No need to remake target `makefile'. 
Updating goal targets.... 
Considering target file `all'. 
File `all' does not exist. 
    Considering target file `foo1'. 
    File `foo1' does not exist. 
    Finished prerequisites of target file `foo1'. 
    Must remake target `foo1'. 
    Successfully remade target file `foo1'. 
    Considering target file `foo2'. 
    File `foo2' does not exist. 
    Finished prerequisites of target file `foo2'. 
    Must remake target `foo2'. 
    Successfully remade target file `foo2'. 
    Considering target file `foo3'. 
    File `foo3' does not exist. 
    Finished prerequisites of target file `foo3'. 
    Must remake target `foo3'. 
echo making foo3 
Putting child 0x0914c5f0 (foo3) PID 3132 on the chain. 
Live child 0x0914c5f0 (foo3) PID 3132 
making foo3 
Reaping winning child 0x0914c5f0 PID 3132 
touch foo3 
Live child 0x0914c5f0 (foo3) PID 3133 
Reaping winning child 0x0914c5f0 PID 3133 
Removing child 0x0914c5f0 PID 3133 from chain. 
    Successfully remade target file `foo3'. 
Finished prerequisites of target file `all'. 
Must remake target `all'. 
Successfully remade target file `all'. 

foo1은을 누락 :

[email protected]:/dev/shm$ ll foo* 
-rw-r--r-- 1 xxxx xxxx 0 2011-02-17 20:04 foo3 

답변

28

난 당신이 define 라인의 끝에서 =을하지 않을 생각합니다. 이 메이크 나를 위해 여기에 작동합니다

define make-foo 
echo making [email protected] 
touch [email protected] 
endef 

.PHONY: foo1 
foo1: 
    $(make-foo) 

예 :

$ make 
echo making foo1 
making foo1 
touch foo1 
$ ls 
Makefile foo1 

GNU make manual=이 잘되어야한다고 표시하는 것,하지만 난 거기가있을 경우처럼, 내가 다른 동작을 얻을.

편집이 : 난 그냥 질문 :

GNU make differences in multiline variable declarations

여기에 무슨 일이 일어나고 있는지에 대한 몇 가지 설명을 얻으려면 ... 나는 포기`=`나를 위해 또한 문제를 해결 확인할 수 있습니다

+2

. 그것은 내가 스스로 결코 발견하지 못했던 문제이다. 감사 ! 나는 계속 관심을 가지고 계속 질문을하고있다. – user272735

+2

@ user272735, 문제가 해결되었다고 듣기 좋습니다. 후속 질문은 많은 사랑을 얻지 못하는 것 같아요. –