-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
48 lines (40 loc) · 1.43 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
DOCKER := docker
EXT := dockerfile
SRC_DIR=docker
SOURCE := $(wildcard $(SRC_DIR)/*.$(EXT)) $(wildcard *.$(EXT))
DOCKERTYPES := $(sort $(SOURCE:.$(EXT)=))
DOCKERIMAGES := $(subst docker/,,$(subst -,_builder:,$(DOCKERTYPES)))
.PHONY: help
help:
@echo "The following are valid targets:"
@echo " docker - build all docker images"
@echo " <IMAGE> - available images ($(DOCKERTYPES))"
@echo " install - modify PATH in the ~/.profiles"
@echo " clean - remove ALL changes in examples"
@echo " dist_clean - remove sq-*-build scripts from PATH"
@echo " docker_clean - remove ALL created docker images"
@echo " clean_all - performs all clean actions"
@echo " help - get this help"
.PHONY: docker
docker: $(DOCKERTYPES)
.PHONY: $(DOCKERTYPES)
$(DOCKERTYPES):
@$(DOCKER) build $(P) -f $@.$(EXT) -t $(subst $(SRC_DIR)/,,$(word 1, $(subst -, ,$@)))_builder$(word 2, $(subst -, :,$@)) .
.PHONY: install
install:
@grep -q "source ${PWD}/scripts/profile.bash" ~/.bashrc \
|| echo source ${PWD}/scripts/profile.bash >> ~/.bashrc
.PHONY: clean
clean:
@git checkout HEAD -- examples \
|| git clean -fd -- examples
.PHONY: dist_clean
dist_clean:
@grep -q "source ${PWD}/scripts/profile.bash" ~/.bashrc \
&& sed -i '\|source ${PWD}/scripts/profile.bash|d' ~/.bashrc \
|| true
.PHONY: docker_clean
docker_clean:
@docker rmi $(DOCKERIMAGES)
.PHONY: clean_all
clean_all: clean dist_clean docker_clean