-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (69 loc) · 2.73 KB
/
Makefile
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
APPLY_CONFIGS ?= false
CLEAN_AFTER_BUILD ?= false
ENV_FILES ?= "x86_64.json"
EXIT_AFTER_BUILD ?= false
NO_BUILD ?= false
VERBOSE ?= false
TARGET ?= x86_64
.PHONY: help
help:
@printf "Environment variables:\n"
@printf '\tAPPLY_CONFIGS: Reapply all config files. Default: false\n'
@printf "\tCLEAN_AFTER_BUILD: run 'make clean' after a build is finished. Default: false\n"
@printf "\tENV_FILES: Specify a space-deliminated list of environment files in the docker directory to apply. Default: x86_64.json\n"
@printf "\tEXIT_AFTER_BUILD: Exit the container after a build. Default: false\n"
@printf "\tNO_BUILD: Do not build any config. Default: false\n"
@printf "\tVERBOSE: Run make instead of brmake. Default: false\n"
@printf "\tTARGET: Specify the target of which to run menuconfig. Default: x86_64\n"
@printf "\n"
@printf "Targets:\n"
@printf "\tbuild: build the docker container.\n"
@printf "\tdown: Stop the dodcker container.\n"
@printf "\tkill: kill the docker container forcefully.\n"
@printf "\tmenuconfig: run menuconfig on a given target. Default: x86_64\n"
@printf "\tshell: Run the docker container, do not build anyhting, and open a shell in the docker container.\n"
@printf "\tup: Run docker compose up with the above environment variables.\n"
@printf "\tupd: Run docker compose up -d with the above environment variables.\n"
@printf "\n"
@printf "Other:\n"
@printf "x64-run: Run the x64 virtual image. Requires virbr0 and /dev/kvm to exist."
@printf "\n\n"
.PHONY: build
build:
@docker compose build
.PHONY: down
down:
@docker compose down
.PHONY: menuconfig
menuconfig:
@/bin/bash -c 'make kill && make APPLY_CONFIGS=${APPLY_CONFIGS} NO_BUILD=true upd; if [[ ${APPLY_CONFIGS} == "true" ]]; then sleep 5; fi'
@docker exec -it hardened-buildroot /bin/bash -c 'cd ~/buildroot/hardened-buildroot-external/output/${TARGET} && make menuconfig'
.PHONY: kill
kill:
docker compose kill
.PHONY: shell
shell:
@/bin/bash -c 'if [ -z $(docker container ps -aqf "name=hardened-buildroot") ]; then make APPLY_CONFIGS=${APPLY_CONFIGS} NO_BUILD=true EXIT_AFTER_BUILD=false upd; fi;'
@/bin/bash -c 'if [[ ${APPLY_CONFIGS} == "true" ]]; then sleep 5; fi'
@docker exec -it hardened-buildroot /bin/bash
.PHONY: up
up:
APPLY_CONFIGS=${APPLY_CONFIGS} \
VERBOSE=${VERBOSE} \
ENV_FILES=${ENV_FILES} \
EXIT_AFTER_BUILD=${EXIT_AFTER_BUILD} \
NO_BUILD=${NO_BUILD} \
CLEAN_AFTER_BUILD=${CLEAN_AFTER_BUILD} \
docker compose up --abort-on-container-exit
.PHONY: upd
upd:
APPLY_CONFIGS=${APPLY_CONFIGS} \
VERBOSE=${VERBOSE} \
ENV_FILES=${ENV_FILES} \
EXIT_AFTER_BUILD=${EXIT_AFTER_BUILD} \
NO_BUILD=${NO_BUILD} \
CLEAN_AFTER_BUILD=${CLEAN_AFTER_BUILD} \
docker compose up -d
.PHONY: x64-run
x64-run:
@/bin/bash hardened-buildroot-external/board/x86_64/qemu-run.sh