Skip to content

Make

(자동화 플랫폼은 Make (Automation Platform) 항목 참조)

make는 소프트웨어 개발에서 유닉스 계열 운영 체제에서 주로 사용되는 프로그램 빌드 도구이다. 여러 파일들끼리의 의존성과 각 파일에 필요한 명령을 정의함으로써 프로그램을 컴파일할 수 있으며 최종 프로그램을 만들 수 있는 과정을 서술할 수 있는 표준적인 문법을 가지고 있다. 위의 구조로 기술된 파일(주로 Makefile이라는 파일명)을 Make가 해석하여 프로그램 빌드를 수행하게 된다.

Category

Options

-d
Debugging Message를 출력한다. --debug=a와 동일하다.
-C [dir]
실행할 Directory를 변경한다.
-f [file]
사용할 Makefile경로를 지정한다.
-j N
N 만큼 병렬 실행. parallel 같은 기능.
-t
파일을 다시 컴파일하지 않고 생성날짜를 갱신하고 싶을 경우 -t옵션을 사용하면 된다. Touch를 의미하는 옵션으로, 컴파일을 하지 않는 대신 파일의 생성 날짜만 최근으로 바꿔놓는다.
--debug[=options]
디버깅 정보를 출력한다. 옵션은 아래와 같다.
  • a (all) All types of debugging output are enabled. This is equivalent to using ‘-d’.
  • b (basic) Basic debugging prints each target that was found to be out-of-date, and whether the build was successful or not.
  • v (verbose) A level above ‘basic’; includes messages about which makefiles were parsed, prerequisites that did not need to be rebuilt, etc. This option also enables ‘basic’ messages.
  • i (implicit) Prints messages describing the implicit rule searches for each target. This option also enables ‘basic’ messages.
  • j (jobs) Prints messages giving details on the invocation of specific subcommands.
  • m (makefile) By default, the above messages are not enabled while trying to remake the makefiles. This option enables messages while rebuilding makefiles, too. Note that the ‘all’ option does enable this option. This option also enables ‘basic’ messages.
--print-data-base 또는 -p
Print make's internal database.
--trace
macOS (Darwin 버전, i386-apple-darwin11.3.0)에서 없는 플래그.

Error code

make의 종료 코드는 아래와 같다.

  • 0: Exit status is 'Successful'
  • 2: Make Encountered Errors
  • 1: Return response to -q (question) flag, indicating that targets require updating

Basic

Make의 기본구조는 목표(target), 의존성(dependency), 명령(command)의 세개로 이루어진 기분적인 규칙(rule)들이 계속적으로 나열되어 있다. 인코딩은 ANSI로 해야하며 명령 부분은 꼭 TAB글자로 시작해야 한다. 기본형은 아래와 같다.

<target>: <dependency>
    <command>
$ make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}' | sort -u | uniq

Operators

:=
한번 내린 명령을 계속 저장한다.
+=
추가대입한다.
?=
이미 매크로가 지정되어있을 경우 변경하지 않는다.

File include

또다른 Makefile을 포함하고 싶을 경우 아래와 같이 include를 사용하면 된다.

include config

DirectorySearch

타겟이나 종속물로 리스트된 어떤 파일이 현재 디렉토리에 존재하지 않다면 make는 VPATH에 있는 디렉토리들을 검색한다. 문법은 아래와 같다. 구분자는 콜론(:)을 사용한다.

VPATH = <PATH1>:<PATH2>:<PATH3>:...

Multiline

명령어가 한 줄을 넘어간다고 가정할 경우 \문자를 사용하여 여러 라인으로 나타낼 수 있다. C언어의 전처리기를 생각하면 된다.

OBJS = shape.o \
    rectangle.o \
    circle.o \
    line.o

See also

Favorite site

References


  1. Gnu-software-make.zip 

  2. Viper.pe.kr-make-ko.7z 

  3. Auto-Dependency_Generation-GNU_make.pdf