2014-11-06 4 views
0

공간이있는 두 개의 파일에 따라 GNU Make 규칙이 있습니다. 이름을 하드 코딩하지 않으므로 공백이 포함 된 이름을 이스케이프하고 싶습니다.Makefile 종속성의 공백

GS := gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite 
DEPENDENCIES := File\ 1.pdf File\ 2.pdf 

Final.pdf: $(DEPENDENCIES) 
    # [email protected] corresponds to "Final.pdf", and $^ is an automatic variable 
    # that expands to "File" "1.pdf" "File" "2.pdf", however, I would like 
    # it to be "File 1.pdf" and "File 2.pdf" 
    # Ghostscript complains that "File" cannot be found, "2.pdf"... etc. 
    $(GS) -sOutputFile="[email protected]" $^ 

    # Now, the variable expands to "File 1.pdf File 2.pdf", which does 
    # not yield the intended result either. 
    $(GS) -sOutputFile="[email protected]" "$^" 

    # Ultimate goal is to get make to run the following command: 
    # $(GS) -sOutputFile="Final.pdf" "File 1.pdf" "File 2.pdf" 

일반 만들기를 사용하여 멀리 그것으로 얻을 수있는 방법이 있나요, 아니면 나를 위해 메이크 (또는 다른 빌드 시스템)를 생성합니다 외부 도구에 의존해야합니까? (예 : 자동 공구 또는 scons)

휴대 성은 필수 사항은 아니지만 좋은 것입니다.

+0

플랫 아웃은 이름에 공백이있는 파일을 처리 할 수 ​​있도록합니다. 이 일을 할 수는 없습니다. –

+0

make를 호출하기 전에 파일의 이름을 바꿀 유틸리티를 사용하십시오. 나는 [이 빠른 해킹] (http://www.win.tue.nl/~rp/bin/unixifn)을 사용합니다. – reinierpost

+1

autotools (특히 automake)는 makefile을 생성하기 때문에이 작업은 도움이되지 않습니다. 당신은 scons 등 완전히 다른 빌드 시스템으로 전환해야 할 것입니다. – MadScientist

답변

1

자동 변수는 파일 이름에 공백이 없으므로 $^ 또는 $<으로 사용할 수 없습니다. 그럼에도 불구하고 당신은 탈출에 공백이 포함되어있는 $(DEPENDENCIES)을 사용할 수 있습니다 : GNU와 검사

GS := gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite 
DEPENDENCIES := File\ 1.pdf File\ 2.pdf 

Final.pdf: $(DEPENDENCIES) 
    $(GS) -sOutputFile="[email protected]" $(DEPENDENCIES) 

는 3.81