forked from kinvolk/bpf-exercises
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
34 lines (23 loc) · 832 Bytes
/
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
DOCKER_IMAGE=kinvolk/bpf-exercises
SUDO=$(shell docker info >/dev/null 2>&1 || echo "sudo -E")
EXERCISES=$(wildcard exercise-*)
BUILD_TARGETS=$(patsubst %,build-%,$(EXERCISES))
RUN_TARGETS=$(patsubst %,run-%,$(EXERCISES))
default:
@echo "Please choose a target"
@exit 1
.PHONY: default
container:
$(SUDO) docker build -t $(DOCKER_IMAGE) .
.PHONY: container
run-container:
$(SUDO) docker run --rm --privileged -ti -v $(PWD):/bpf-exercises $(DOCKER_IMAGE) bash
.PHONY: run-container
$(BUILD_TARGETS):
$(SUDO) docker run --rm --privileged -ti -v $(PWD):/bpf-exercises $(DOCKER_IMAGE) \
bash -c 'cd $(@:build-%=%) && make build'
.PHONY: $(BUILD_TARGETS)
$(RUN_TARGETS):
$(SUDO) docker run --rm --privileged -ti -v $(PWD):/bpf-exercises $(DOCKER_IMAGE) \
bash -c 'cd $(@:run-%=%) && make run'
.PHONY: $(RUN_TARGETS)