← Documents Documentation/tools/rtla/Makefile GitHub 원문 ↗

Linux 6.18.37 · Kernel Tools

RTLA manual page Makefile

RTLA RST 문서를 rst2man으로 section 1 man page로 만들고 설치·제거하는 Makefile의 변수와 target을 설명합니다.

Source pathDocumentation/tools/rtla/Makefile
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

Makefile:1-53

RTLA RST 문서를 rst2man으로 section 1 man page로 만들고 설치·제거하는 Makefile의 변수와 target을 설명합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 # SPDX-License-Identifier: GPL-2.0-only
2 # Based on bpftool's Documentation Makefile
3
4 INSTALL ?= install
5 RM ?= rm -f
6 RMDIR ?= rmdir --ignore-fail-on-non-empty
7
8 PREFIX ?= /usr/share
9 MANDIR ?= $(PREFIX)/man
10 MAN1DIR = $(MANDIR)/man1
11
12 MAN1_RST = $(wildcard rtla*.rst)
13
14 _DOC_MAN1 = $(patsubst %.rst,%.1,$(MAN1_RST))
15 DOC_MAN1 = $(addprefix $(OUTPUT),$(_DOC_MAN1))
16
17 RST2MAN_DEP := $(shell command -v rst2man 2>/dev/null)
18 RST2MAN_OPTS += --verbose
19
20 TEST_RST2MAN = $(shell sh -c "rst2man --version > /dev/null 2>&1 || echo n")
21
22 $(OUTPUT)%.1: %.rst
23 ifndef RST2MAN_DEP
24 $(info ********************************************)
25 $(info ** NOTICE: rst2man not found)
26 $(info **)
27 $(info ** Consider installing the latest rst2man from your)
28 $(info ** distribution, e.g., 'dnf install python3-docutils' on Fedora,)
29 $(info ** or from source:)
30 $(info **)
31 $(info ** https://docutils.sourceforge.io/docs/dev/repository.html )
32 $(info **)
33 $(info ********************************************)
34 $(error NOTICE: rst2man required to generate man pages)
35 endif
36 rst2man $(RST2MAN_OPTS) $< > $@
37
38 man1: $(DOC_MAN1)
39 man: man1
40
41 clean:
42 $(RM) $(DOC_MAN1)
43
44 install: man
45 $(INSTALL) -d -m 755 $(DESTDIR)$(MAN1DIR)
46 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(MAN1DIR)
47
48 uninstall:
49 $(RM) $(addprefix $(DESTDIR)$(MAN1DIR)/,$(_DOC_MAN1))
50 $(RMDIR) $(DESTDIR)$(MAN1DIR)
51
52 .PHONY: man man1 clean install uninstall
53 .DEFAULT_GOAL := man
54

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Install 경로와 man-page 목록

1-20

이 GPL-2.0-only Makefile은 bpftool Documentation Makefile을 바탕으로 한다. `INSTALL`, `RM`, `RMDIR`은 각각 install, file 제거, 비어 있지 않으면 실패하지 않는 directory 제거 command를 기본값으로 둔다.

기본 prefix는 `/usr/share`, man directory는 `$(PREFIX)/man`, section 1 directory는 `$(MANDIR)/man1`이다. `MAN1_RST`는 `rtla*.rst`를 찾고 `_DOC_MAN1`은 `.rst` suffix를 `.1`로 바꾸며 `DOC_MAN1`은 각 결과에 `$(OUTPUT)` prefix를 붙인다.

`RST2MAN_DEP`는 `rst2man` command path를 찾고 `RST2MAN_OPTS`에는 `--verbose`를 더한다. `TEST_RST2MAN`은 version command가 실패하면 `n`을 반환하도록 정의되어 있다.

Make 변수
변수값 또는 역할
PREFIX / MANDIR / MAN1DIR/usr/share 아래 man/man1 경로
MAN1_RSTrtla*.rst wildcard
_DOC_MAN1RST 이름을 .1로 변환
DOC_MAN1OUTPUT prefix가 붙은 결과 목록
RST2MAN_DEPrst2man executable 확인

source RST에서 output man1 file을 계산한다.

# SPDX-License-Identifier: GPL-2.0-only
# Based on bpftool's Documentation Makefile

INSTALL		?= install
RM		?= rm -f
RMDIR		?= rmdir --ignore-fail-on-non-empty

PREFIX		?= /usr/share
MANDIR		?= $(PREFIX)/man
MAN1DIR		= $(MANDIR)/man1

MAN1_RST	= $(wildcard rtla*.rst)

_DOC_MAN1	= $(patsubst %.rst,%.1,$(MAN1_RST))
DOC_MAN1	= $(addprefix $(OUTPUT),$(_DOC_MAN1))

RST2MAN_DEP	:= $(shell command -v rst2man 2>/dev/null)
RST2MAN_OPTS	+= --verbose

TEST_RST2MAN = $(shell sh -c "rst2man --version > /dev/null 2>&1 || echo n")

rst2man 확인과 변환 rule

21-37

pattern rule `$(OUTPUT)%.1: %.rst`는 RST file을 section 1 man page로 변환한다. `rst2man`을 찾지 못하면 distribution package나 docutils source에서 최신 version을 설치하라는 notice를 출력하고 build를 error로 중단한다.

dependency가 있으면 `rst2man $(RST2MAN_OPTS) $< > $@`를 실행해 첫 prerequisite인 RST를 target man page로 변환한다. redirection과 Make automatic variable 표기는 원문 그대로 보존된다.

Man page build
rtla*.rstCheck rst2man
rst2man missingPrint install noticeStop with error
rst2man foundrst2man --verbose$(OUTPUT)%.1

dependency 확인 뒤 RST를 output .1 file로 변환한다.


$(OUTPUT)%.1: %.rst
ifndef RST2MAN_DEP
	$(info ********************************************)
	$(info ** NOTICE: rst2man not found)
	$(info **)
	$(info ** Consider installing the latest rst2man from your)
	$(info ** distribution, e.g., 'dnf install python3-docutils' on Fedora,)
	$(info ** or from source:)
	$(info **)
	$(info **  https://docutils.sourceforge.io/docs/dev/repository.html )
	$(info **)
	$(info ********************************************)
	$(error NOTICE: rst2man required to generate man pages)
endif
	rst2man $(RST2MAN_OPTS) $< > $@

Build, install, uninstall target

38-53

`man1`은 모든 `DOC_MAN1`을 build하고 `man`은 `man1`에 의존한다. `clean`은 생성된 man page를 제거한다.

`install`은 먼저 `man`을 build하고 `$(DESTDIR)$(MAN1DIR)`을 mode 755로 만든 뒤 man page를 mode 644로 설치한다. `uninstall`은 설치된 file을 제거하고 비어 있으면 man1 directory도 제거한다.

`man`, `man1`, `clean`, `install`, `uninstall`은 `.PHONY` target이며 기본 goal은 `man`이다.

Make target
Target동작
man1 / mansection 1 man page build
cleangenerated man page 제거
installdirectory 755, file 644로 설치
uninstall설치 file과 빈 directory 제거
defaultman

manual page lifecycle을 구성한다.

man1: $(DOC_MAN1)
man: man1

clean:
	$(RM) $(DOC_MAN1)

install: man
	$(INSTALL) -d -m 755 $(DESTDIR)$(MAN1DIR)
	$(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(MAN1DIR)

uninstall:
	$(RM) $(addprefix $(DESTDIR)$(MAN1DIR)/,$(_DOC_MAN1))
	$(RMDIR) $(DESTDIR)$(MAN1DIR)

.PHONY: man man1 clean install uninstall
.DEFAULT_GOAL := man