-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
112 lines (88 loc) · 3.28 KB
/
Copy pathMakefile
File metadata and controls
112 lines (88 loc) · 3.28 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
.DEFAULT_GOAL := help
BUILD_DOCS ?= 1
USE_GRAPHICS ?= 1
TMUX_FILE := $(HOME)/.tmux.conf
TMUX_REAL_PATH := $(shell readlink -f $(TMUX_FILE))
TMUX_MOUNT := $(shell if [ -f $(TMUX_REAL_PATH) ]; then echo "-v $(TMUX_REAL_PATH):/root/.tmux.conf:Z" ; fi)
CONTAINER_CMD = podman
CONTAINER_NAME = programmingfromthegroundup
FILES_TO_MOUNT = -v ./docs:/pgu/docs:Z \
-v ./src:/pgu/src:Z \
-v ./entrypoint/shell.sh:/usr/local/bin/shell.sh:Z \
-v ./entrypoint/format.sh:/usr/local/bin/format.sh:Z \
-v ./entrypoint/pdf.sh:/usr/local/bin/pdf.sh:Z \
-v ./entrypoint/epub.sh:/usr/local/bin/epub.sh:Z \
-v ./entrypoint/html.sh:/usr/local/bin/html.sh:Z \
-v ./entrypoint/dotfiles/.extrabashrc:/root/.extrabashrc:Z \
$(TMUX_MOUNT)
OUTPUT_DIR_TO_MOUNT = -v ./output/:/output/:Z
USE_X = -e DISPLAY=$(DISPLAY) \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--security-opt label=type:container_runtime_t
WAYLAND_FLAGS_FOR_CONTAINER = -e "WAYLAND_DISPLAY=${WAYLAND_DISPLAY}" \
-e "XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR}" \
-v "${XDG_RUNTIME_DIR}:${XDG_RUNTIME_DIR}"
.PHONY: all
all: shell ## Build the image and get a shell in it
.PHONY: image
image: ## Build podman image to run the examples
# build the container
$(CONTAINER_CMD) build \
--build-arg BUILD_DOCS=$(BUILD_DOCS) \
--build-arg USE_GRAPHICS=$(USE_GRAPHICS) \
-t $(CONTAINER_NAME) \
.
.PHONY: shell
shell: format ## Get Shell into a ephermeral container made from the image
$(CONTAINER_CMD) run -it --rm \
--entrypoint /bin/bash \
$(FILES_TO_MOUNT) \
$(OUTPUT_DIR_TO_MOUNT) \
$(USE_X) \
$(WAYLAND_FLAGS_FOR_CONTAINER) \
$(CONTAINER_NAME) \
/usr/local/bin/shell.sh
.PHONY: format
format: image ## Format the C code
$(CONTAINER_CMD) run -it --rm \
--entrypoint /bin/bash \
$(FILES_TO_MOUNT) \
$(OUTPUT_DIR_TO_MOUNT) \
$(USE_X) \
$(CONTAINER_NAME) \
/usr/local/bin/format.sh
.PHONY: docs
docs: html pdf epub ## Build the book in HTML, PDF, and EPUB form
.PHONY: html
html: image ## Build the book in HTML form
$(CONTAINER_CMD) run -it --rm \
--entrypoint /bin/bash \
$(FILES_TO_MOUNT) \
$(OUTPUT_DIR_TO_MOUNT) \
$(CONTAINER_NAME) \
/usr/local/bin/html.sh
.PHONY: pdf
pdf: image ## Build the book in PDF form
$(CONTAINER_CMD) run -it --rm \
--entrypoint /bin/bash \
$(FILES_TO_MOUNT) \
$(OUTPUT_DIR_TO_MOUNT) \
$(CONTAINER_NAME) \
/usr/local/bin/pdf.sh
.PHONY: epub
epub: image ## Build the book in EPUB form
$(CONTAINER_CMD) run -it --rm \
--entrypoint /bin/bash \
$(FILES_TO_MOUNT) \
$(OUTPUT_DIR_TO_MOUNT) \
$(CONTAINER_NAME) \
/usr/local/bin/epub.sh
.PHONY: image-export
image-export: ## export the OCI image to a timestamped tar in the repo root
$(CONTAINER_CMD) save $(CONTAINER_NAME) -o $(CONTAINER_NAME)-$(shell date +%m-%d-%Y_%H-%M-%S).tar
.PHONY: image-import
image-import: ## import an OCI image tar: make image-import FILE=foo.tar
$(CONTAINER_CMD) load -i $(FILE)
.PHONY: help
help:
@grep --extended-regexp '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'