Make Control Functions

make 에서 print 문에 해당하는 것이 info, warning, error 함수입니다. 함수 실행시 출력이 발생하지만 기본적으로 반환값은 empty 이므로 makefile 어느 곳에든지 syntax error 없이 위치시킬 수 있습니다. 따라서 makefile 을 디버깅할 때 이 함수들을 활용할 수 있습니다.

  1. info 함수는 인수로 주어지는 메시지를 stdout 으로 출력하고
  2. warning 함수는 메시지 앞부분에 파일명과 라인넘버를 추가해서 stderr 로 출력합니다.
  3. error 함수는 메시지를 stderr 로 출력함과 동시에 해당 위치에서 make 실행을 종료합니다.

$( info text... )

info, warning, error 함수를 변수에 대입해 사용할 때는 recursive 대입 연산자를 사용해야 합니다. 그렇지 않으면 대입 시점에서 메시지가 출력되게 됩니다.

INFO = $(info hello info message)          # '=' 연산자 사용

$(info 111)
$(info 222)
$(INFO)
$(info 333)
$(info 444)    

###########  실행 결과  ###########
111
222
hello info message
333
444

$( warning text... )

warning 함수는 메시지 앞부분에 파일명과 라인 넘버를 추가해서 보여줍니다.

$(info 111)
$(info 222)
$(warning hello warning message)
$(info 333)
$(info 444)

###########  실행 결과  ###########
111
222
Makefile:3: hello warning message       # 출력에 파일명과 라인 넘버가 포함된다.
333
444

$( error text... )

error 함수는 메시지 출력과 동시에 해당 위치에서 make 실행을 종료합니다.

$(info 111)
$(info 222)
$(error hello error message)
$(info 333)
$(info 444)

###########  실행 결과  ###########

111
222
Makefile:3: *** hello error message.  Stop.