Makefile 문법법

Linux/Linux 일반 : 2010. 7. 22. 17:30
반응형

이솝 재훈이형이 쓴글 퍼옴 ㅋㅋ



이 부록은 GNU make 가 이해하는 지시어, 텍스트 조작 함수, 그리고 특수 변수들에 대해서 요약한 것이다. 다른 요약들을 보고자 한다면 See section 특수 내장 타겟 이름(Special Built-in Target Names), section 묵시적 규칙들의 카달로그(Catalogue of Implicit Rules), and section 옵션들의 요약(Summary of Options).

다음은 GNU make 가 인식하는 지시어들을 요약한 것이다:

define variable
endef
멀티-라인, 재귀적으로 확장되는 변수 하나를 정의한다. 
See section 명령들을 묶어서 정의하기(Defining Canned Command Sequences).
ifdef variable
ifndef variable
ifeq (a,b)
ifeq "a" "b"
ifeq 'a' 'b'
ifneq (a,b)
ifneq "a" "b"
ifneq 'a' 'b'
else
endif
makefile 의 조건 평가 부분. 
See section Makefile의 조건 부분(Conditional Parts of Makefiles).
include file
다른 makefile 을 포함한다. 
See section 다른 makefile 삽입(Including Other Makefiles).
override variable = value
override variable := value
override variable += value
override define variable
endef
변수 하나를 정의하고 이전의 정의를 오버라이드하다. 심지어 명령행에서의 정의까지 오버라이드한다.
See section override 지시어.
export
make 에게 차일드 프로세스들에게 디폴트로 모든 변수들을 익스포트하도록 지시.
See section 서브-make에 대한 통신 변수(Communicating Variables to a Sub-make).
export variable
export variable = value
export variable := value
export variable += value
unexport variable
make 에게 특정한 변수를 차일드 프로세스들에게 익스포트할 것인가 아닌가를 지시한다.
See section 서브-make에 대한 통신 변수(Communicating Variables to a Sub-make).
vpath pattern path
`%' 패턴과 일치하는 파일들에 대해서 검색 경로를 지정.
See section vpath 지시어.
vpath pattern
pattern 로 사전에 지정된 모든 검색 경로들을 제거.
vpath
vpath 지시어에 의해서 사전에 지정된 모든 검색 경로들을 제거.

다음은 텍스트 조작 함수들의 요약이다 (see section 텍스트 변환을 위한 함수(Functions for Transforming Text)): Here is a summary of the text manipulation functions (see section 텍스트 변환을 위한 함수(Functions for Transforming Text)):

$(subst from,to,text)
text 에서 from 를 to 로 교체.
See section 문자 대입과 분석을 위한 함수들(Functions for String Substitution and Analysis).
$(patsubst pattern,replacement,text)
text 에서 pattern 과 일치하는 것을 replacement 로 교체. 
See section 문자 대입과 분석을 위한 함수들(Functions for String Substitution and Analysis).
$(strip string)
string 로부터 여분의 공백 문자들을 제거.
See section 문자 대입과 분석을 위한 함수들(Functions for String Substitution and Analysis).
$(findstring find,text)
text 에서 find 를 찾음(locate).
See section 문자 대입과 분석을 위한 함수들(Functions for String Substitution and Analysis).
$(filter pattern...,text)
pattern 단어들중의 하나와 일치하는 text 내의 단어들을 선택. 
See section 문자 대입과 분석을 위한 함수들(Functions for String Substitution and Analysis).
$(filter-out pattern...,text)
pattern 단어들중의 하나와 일치하지 않는 단어들을 text에서 선택.
See section 문자 대입과 분석을 위한 함수들(Functions for String Substitution and Analysis).
$(sort list)
list 에 있는 단어들을 사전식으로 소팅하고 중복된 것들을 제거.
See section 문자 대입과 분석을 위한 함수들(Functions for String Substitution and Analysis).
$(dir names...)
각 파일 이름에서 디렉토리 부분을 추출.
See section 파일 이름들을 위한 함수(Functions for File Names).
$(notdir names...)
각 파일 이름에서 비-디렉토리 부분을 추출.
See section 파일 이름들을 위한 함수(Functions for File Names).
$(suffix names...)
각 파일 이름의 확장자(마지막 `.'과 다음 문자들)를 추출.
See section 파일 이름들을 위한 함수(Functions for File Names).
$(basename names...)
각 파일 이름의 몸체 이름(확장자를 뺀 이름)을 추출.
See section 파일 이름들을 위한 함수(Functions for File Names).
$(addsuffix suffix,names...)
names 에 있는 각 단어의 뒤에다 suffix 를 붙인다. 
See section 파일 이름들을 위한 함수(Functions for File Names).
$(addprefix prefix,names...)
prefix 를 names 에 있는 각 단어 앞에다 붙인다. 
See section 파일 이름들을 위한 함수(Functions for File Names).
$(join list1,list2)
두 단어들의 병렬 리스트를 묶는다.
See section 파일 이름들을 위한 함수(Functions for File Names).
$(word n,text)
text 에서 n번째 단어(시작은 1)를 추출한다.
See section 파일 이름들을 위한 함수(Functions for File Names).
$(words text)
text 에서 단어들의 개수를 계산한다.
See section 파일 이름들을 위한 함수(Functions for File Names).
$(firstword names...)
names 의 첫번째 단어를 추출한다.
See section 파일 이름들을 위한 함수(Functions for File Names).
$(wildcard pattern...)
쉘 파일 이름 패턴 (`%' 패턴이 아님) 과 일치하는 파일 이름들을 찾는다. 
See section wildcard 함수(The Function wildcard).
$(shell command)
쉘 명령을 실행하고 그것의 결과를 리턴.
See section shell 함수(The shell Function).
$(origin variable)
make 변수 variable 가 정의된 방법을 설명하는 문자열을 리턴. 
See section origin 함수(The origin Function).
$(foreach var,words,text)
words 에 있는 각 단어를 가리키는 var 로 text 를 평가하고 그 결과를 서로 붙인다.
See section foreach 함수(The foreach Function).

다음은 완전한 정보를 대신할 자동 변수들See section 자동 변수들(Automatic Variables)의 요약이다.

$@
타겟의 파일 이름.
$%
타겟이 아카이브 멤버일 때, 타겟의 멤버 이름.
$<
첫번째 종속물의 이름.
$?
타겟보다 더 새로운 모든 종속물들의 이름. 이들 사이는 스페이스들로 구분된다. 아카이브 멤버들인 종속물들의 경우 이름있는 멤버들만이 사용된다 (see section 아카이브 파일을 갱신하기 위해서 make 사용하기(Using make to Update Archive Files)).
$^
$+
모든 종속물들의 이름. 이들 사이는 공백으로 구분된다. 아카이브 멤버들인 종속물들의 경우 이름있는 멤버만이 사용된다 (see section 아카이브 파일을 갱신하기 위해서 make 사용하기(Using make to Update Archive Files)). $^의 값은 중복된 종속물들을 생략한다. 반면에 $+는 그들을 그대로 가지고 그들의 순서를 유지한다.
$*
묵시적인 규칙이 매치된 줄기 (see section 패턴 비교 방법(How Patterns Match)).
$(@D)
$(@F)
$@의 디렉토리-안에 있는-파일 부분과 디렉토리 부분.
$(*D)
$(*F)
$*의 디렉토리-안에 있는-파일 부분과 디렉토리 부분.
$(%D)
$(%F)
$%의 디렉토리-안에 있는-파일 부분과 디렉토리 부분.
$(<D)
$(<F)
$<의 디렉토리-안에 있는-파일 부분과 디렉토리 부분.
$(^D)
$(^F)
$^의 디렉토리-안에 있는-파일 부분과 디렉토리 부분.
$(+D)
$(+F)
$+의 디렉토리-안에 있는-파일 부분과 디렉토리 부분.
$(?D)
$(?F)
$?의 디렉토리-안에 있는-파일 부분과 디렉토리 부분.

다음 변수들은 GNU make에 의해서 특별하게 사용된다:

MAKEFILES
make 의 모든 실행때마다 읽히는 makefile들. 
See section MAKEFILES 변수(The Variable MAKEFILES).
VPATH
현재 디렉토리에서 찾을 수 없는 파일들에 대한 디렉토리 검색 경로.
See section VPATH: 모든 종속물에 대한 검색 패스(Search Path for All Dependencies).
SHELL
시스템의 디폴트 명령 해석기의 이름. 일반적으로 `/bin/sh'. 명령들을 실행하는 데 사용되는 쉘을 변경하기 위해서 makefile 에서SHELL 을 설정할 수 있다. See section 명령 실행(Command Execution).
MAKESHELL
MS-DOS 에서만 사용되며 make 에 의해서 사용되는 명령 해석기의 이름. 이 값은 SHELL 의 값보다 우선한다. See section 명령 실행(Command Execution).
MAKE
make 가 호출된 이름. 이 변수를 명령에서 사용하는 것은 특수한 의미가 있다. See section MAKE 변수가 작동하는 방법(How the MAKE Variable Works).
MAKELEVEL
재귀적 진입의 단계 번호 (서브-make들의).
See section 서브-make에 대한 통신 변수(Communicating Variables to a Sub-make).
MAKEFLAGS
make 에 주어진 플래그들. 플래그들을 설정하기 위해서 환경에서나 makefile 안에서 이것을 설정할 수 있다.
See section 서브-make에 대한 통신 옵션(Communicating Options to a Sub-make).
MAKECMDGOALS
make 에 대해서 명령행에서 주어진 타겟. 이 변수를 설정하는 것은 make 의 작업에 어떤 영향도 미치지 않는다. 
See section goal을 지정하는 매개변수(Arguments to Specify the Goals).
CURDIR
현재 작업 디렉토리(모든 -C 옵션들이, 있다면 처리된 후)의 경로명으로 설정된다. 이 변수를 설정하는 것은 make 의 작업에 어떤 영향도 미치지 않는다.
See section make의 재귀적 사용(Recursive Use of make).
SUFFIXES
make 가 makefile 들을 읽기 전의 접미사들의 디폴트 리스트. 
반응형

'Linux > Linux 일반' 카테고리의 다른 글

tftp 설정  (0) 2010.08.07
우분투ubuntu 8.10에서 Virtualbox USB 설정  (1) 2010.05.04
tar 압축 풀때 디렉토리 지정해서 풀기  (0) 2010.03.24
Posted by Real_G