File: Makefile

package info (click to toggle)
docker.io 27.5.1%2Bdfsg4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 67,384 kB
  • sloc: sh: 5,847; makefile: 1,146; ansic: 664; python: 162; asm: 133
file content (49 lines) | stat: -rw-r--r-- 1,568 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
prefix = /usr/local
mandir = $(prefix)/man
INSTALL = install
INSTALL_DATA = ${INSTALL} -m 644

# By default, the man pages are generated using a copy of go-md2man built from
# the vendored sources in this directory. This behavior can be overridden by
# setting the GO_MD2MAN variable to the name/path of an existing go-md2man
# binary.
GO_MD2MAN ?= .build/go-md2man

ALL_PAGES := $(wildcard *.*.md)

# Determine which manual sections we are generating pages for
# by isolating the last part of the filename before the extension
# and eliminating duplicates.
man_section = $(lastword $(subst ., ,$(1)))
sections := $(sort $(foreach page,$(ALL_PAGES:.md=),$(call man_section,$(page))))

# Dynamically generate pattern rules for each manual section
# so make knows how to build a target like man8/dockerd.8.
define MANPAGE_template
man$(1)/%.$(1): %.$(1).md $(if $(findstring file,$(origin GO_MD2MAN)),$(GO_MD2MAN)) | man$(1)
	$(GO_MD2MAN) -in $$< -out $$@
endef
$(foreach sec,$(sections),$(eval $(call MANPAGE_template,$(sec))))

# Default target: build all man pages.
all: $(foreach page,$(ALL_PAGES:.md=),man$(call man_section,$(page))/$(page))

# Target for creating the man{1..8} directories as needed.
.PRECIOUS: man%
man%:
	-mkdir $@

.PHONY: install
install: all
	@set -ex; \
	for sec in $(sections); do \
		$(INSTALL) -d $(DESTDIR)$(mandir)/man$$sec && \
		$(INSTALL_DATA) man$$sec/* $(DESTDIR)$(mandir)/man$$sec; \
	done

.build/go-md2man: go.mod go.sum
	GO111MODULE=auto go build -o $@ github.com/cpuguy83/go-md2man/v2

.PHONY: clean
clean:
	rm -r man* .build