사용하면 nmake
현재 필요한 작업을 수행하는 다음 메이크 파일이 있습니다. mycmd
(실행중인 프로그램) .inp
파일 을 가져와 파일을 생성 .out
합니다. .inp
필요한만큼 파일을 만들 수 있으며 makefile은 변경할 필요가 없습니다. 그것들을 모두 찾아 모든 관련 .out
파일을 만듭니다.
#####################################################################################
# A SUFFIXES declaration is required in order to later use the rule with target .inp.out
#####################################################################################
.SUFFIXES: .inp
#####################################################################################
# Here, NMAKE will expand *.inp in the prereq list for all, into the list of *.inp
# files in the directory, and then it will start a new NMAKE instance, specifying the
# goals to build all those files.
#####################################################################################
all: *.inp
$(MAKE) $(**:.inp=.out)
#####################################################################################
# $(*B) represents the current target's base name minus the path and the file extension
#####################################################################################
.inp.out:
mycmd -i $(*B).inp -o $(*B).out
내 질문은, 내가 어떻게 더 그래서이 메이크을 향상 않습니다되고 난, 예를 들어, 집합에 대한 실행 수 .inp
, 파일 그렇게하지 *.inp
만 말 ABC*.inp
?
makefile에 대한 간단한 수정이 작동합니다. 새 $(pattern)
매크로 추가 :
.SUFFIXES: .inp
pattern = * # new macro; defaults to *
all: $(pattern).inp # use it!
@$(MAKE) -nologo $(**:.inp=.out)
.inp.out: # dummy stub for testing
@echo mycmd -i $(*B).inp -o $(*B).out
@type NUL > $(*B).out
그런 다음 명령 줄에서 pattern
. 예 : nmake -nologo pattern=ABC*
.
업데이트 : makefile의 명령 줄 :
$(MAKE) $(**:.inp=.out)
문자열 이 너무 길면 fatal error U1095: expanded command line
...로 실패 합니다. 내 시스템에서 이것은 대략 32800 자에서 발생합니다.too long
$**
!
시작 부분 ( 여기 참조 )에 느낌표를 추가하는 것은 작동하지 않는 것 같습니다. 아마도 간단한 $**
. 두 가지 해결 방법은 다음과 같습니다.
!call set a=$** & call nmake %%a:.inp=.out%%
또는:
!for %a in ($**) do nmake -nologo %~na.out
둘 다 원본보다 약 2 배 느리고 아무것도하지 않는 mycmd
스텁이 있습니다. (여기서 for
루프 $**
는 단일 항목 이기 때문에 실제로 루프가 아닙니다 .)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다