2

a user-defined GNU make function (즉, a recursively expanded makefile variable)을 서브 메이크로 내 보내야합니다. 그러나 make는 그러한 모든 변수를 단순히 확장 된 변수로 확장하여 쓸모 없게 만듭니다. "parent.make"의서브 메이크에 재귀 메이크 파일 변수 내보내기

내용 : -f 부모을 "실행

$(info child testing myfunc: $(call myfunc,child)) 
nullrule: ; @true 

:

"child.make "의
export myfunc = my arg is $1 
$(info parent testing myfunc: $(call myfunc,parent)) 
all: ; $(MAKE) -f child.make 

내용 여기

은 예입니다. make "는 다음 출력을 생성합니다.

parent testing myfunc: my arg is parent 
make -f child.make 
child testing myfunc: my arg is 

부모는 myfunc를 "내 arg is"를 포함하는 간단한 확장 변수로 내 보냅니다. sub-make는 함수로 쓸모 없게 만듭니다.

답변

0

나는이 귀하의 요구 사항을 만족시킬 수 있는지 확실하지 않습니다, 그러나 여기 간다 :

parent.make :

export myfunc1 = my arg is $1 
export myfunc2 = $(value myfunc1) 
$(info parent testing myfunc1: $(call myfunc1,parent)) 
all: ; $(MAKE) -f child.make 

child.make :

$(info child testing myfunc2: $(call myfunc2,child)) 
nullrule: ; @true 

편집 :
좋아, 어때?

child.make :

myfunc1=$(myfunc2) 

$(info child testing myfunc1: $(call myfunc1,child)) 
nullrule: ; @true 

편집 :

하지 너무 빨리. 이것 좀보세요 :

parent.make :

myfunc_base = my arg is $1 

export myfunc = $(value myfunc_base) 

$(info parent testing myfunc: $(call myfunc_base,parent)) 
all: ; @$(MAKE) -f child.make 

child.make :

$(info child testing myfunc: $(call myfunc,child)) 
nullrule: ; @$(MAKE) -f grandchild.make 

grandchild.make이 전혀 수정없이 작동

$(info grandchild testing myfunc: $(call myfunc,grandchild)) 
nullrule: ; @true 

child.make 또는 grandchild.make. parent.makemyfunc 대신 myfunc_base으로 전화해야합니다. 문제가 있다면 주위에 방법이 있습니다. 어쩌면 하나 이상입니다.

하나의 가능성, 우리는로 정의를 이동이 실제로는 전혀 호출되지 않습니다 parent 호출 어떤 :

grandparent.make :

myfunc_base = my arg is $1 

export myfunc = $(value myfunc_base) 

all: ; @$(MAKE) -f child.make 

부모를.합니다

$(info parent testing myfunc: $(call myfunc,parent)) 
all: ; @$(MAKE) -f child.make 

myfunc의 정의 parent.make에 정의 된 다른 일을해야 할 수 있기 때문에 나는이 가능한하지 않을 수 있습니다 알고 있습니다. 이것이 당신의 상황에 어울리는 지보십시오. 다른 방법이있을 수 있습니다 ...

+0

그건 멋진 트릭입니다. 그러나 부모와 자식 모두 같은 이름을 사용하여 함수를 참조 할 수 있어야하므로 현재의 문제는 실제로 해결되지 않습니다. (이것은 기존의, 절대적이고, 거대하고, 복잡한 make 설정에 있습니다). 내 폴백 옵션은 이러한 파일을 별도의 파일로 정의하고 모든 서브 프로세스 인스턴스에 해당 파일을 포함시키는 것입니다.하지만 이는 이상적인 것보다 적습니다. – mtoossi

+0

편집과 관련하여 이것은 실제적이지 않습니다. 많은 기능이 있으며 각각에 대해 2 개의 추가 라인을 추가하는 것은 너무 장황합니다. 또한, 여러 단계의 하위 실행 make가 여러 단계로 복잡해지면서 더욱 복잡해졌습니다. 어쨌든, 이것이 유일하게 사용 가능한 옵션이기 때문에 귀하의 답변을 수락 할 것입니다! – mtoossi

3

공용 변수와 함수를 상위 메이크 파일과 하위 메이크 파일 모두에 포함 된 별도의 메이크 파일에 넣을 수없는 이유가 있습니까?