2011-02-17 16 views
17

Aşağıdaki makefile tarafından oluşturulan dosyaları foo1 ve foo3 görmeyi umuyorum. Ancak sadece foo3 bir dosya oluşturulur. Bana göre konserve make-foo make tarafından kolayca göz ardı edilir. Hedeflerin foo1 ve foo2 (boş tarif) hata ayıklama sonucu aynıdır.GNU Make konserve tarifi neden çalışmıyor?

# 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] 

Koşu yapmak:

[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 eksik:

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

cevap

28

Sana define satırın sonunda = istemediğimi düşünüyorum. Bu makefile burada benim için çalışıyor:

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

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

Örnek:

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

GNU make manual= sadece iyi olması gerektiğini belirtmek gibi görünüyor, ama onu orada varsa senin gibi, ben farklı davranışlar olsun.

Düzenleme: sadece sordum:

GNU make differences in multiline variable declarations

burada neler üzerinde bazı açıklama almak için ... Ben bırakarak `=` benim için de sorun sabit teyit edebiliriz

+2

. Muhtemelen tek başıma bulamadığım bir konu. Teşekkürler ! Devam sorusunu da büyük bir ilgiyle takip ediyorum. – user272735

+2

@ user272735, sorununuzu çözdüğünü duyduğumuza sevindim. Sorduğum takip sorusu çok fazla aşk almıyor ... –