2011-12-02 4 views
1

내가 내 마음으로 분류되지만 이름 지정 방식에 어떤 종류의 구별 할 수없는 파일이 상상, 그들은 같은 디렉토리에 상주 :메이크

apple cherry celery onion 

나는 두 가지 규칙에 대해 하나 개의 조리법이 파이와 수프를위한 것.

나는 묵시적 규칙 이러한 조리법을 구현하는 경우 :

fruits:= apple cherry 
vegetables:= celery onion 

%.soup : % 
     @echo "making soup" 
     cp $< [email protected] 

%.pie : % 
     @echo "making pie" 
     cp $< [email protected] 

가 그럼 난 끔찍한 식사가 구축 될 수 있도록

:

fruits:= apple cherry 
vegetables:= celery onion 

pies:=$(addsuffix .pie,$(fruits)) 
soups:=$(addsuffix .soup,$(vegetables)) 

$(pies) : $(fruits) 
     @echo "making pie" 
     cp $< [email protected] 


$(soups) : $(vegetables) 
     @echo "making soup" 
     cp $< [email protected] 

:

> touch celery 
> make celery.pie 
making pie 
cp celery celery.pie #bleech this should not be allowed 

을하지만을 나는 명시 적 규칙을 사용하는 경우 나는 현실에 존재하지 않는 의존성을 확립해야만한다 :

> touch apple 
> make apple.pie 
make: *** No rule to make target `cherry', needed by `apple.pie'. Stop. 

파일 카테고리에 대해 어떻게 만들 수 있습니까?

답변