-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
86 lines (62 loc) · 2.69 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
79
80
81
82
83
84
85
86
ARCHS := x86_64 arm aarch64 powerpc mips mipsel
TARGETS := $(addprefix build-, $(ARCHS))
PYTHON_TARGETS := $(addprefix build-with-python-, $(ARCHS))
ALL_TARGETS := $(TARGETS) $(PYTHON_TARGETS)
PACK_TARGETS := $(addprefix pack-, $(ARCHS))
PYTHON_PACK_TARGETS := $(addprefix pack-with-python-, $(ARCHS))
ALL_PACK_TARGETS := $(PACK_TARGETS) $(PYTHON_PACK_TARGETS)
SUBMODULE_PACKAGES := $(wildcard src/submodule_packages/*)
BUILD_PACKAGES_DIR := "build/packages"
.PHONY: clean help download_packages build build-docker-image $(ALL_TARGETS) $(ALL_PACK_TARGETS)
.NOTPARALLEL: build pack
help:
@echo "Usage:"
@echo " make build"
@echo ""
@for target in $(ALL_TARGETS); do \
echo " $$target"; \
done
@echo ""
@echo " make clean"
build/build-docker-image.stamp: Dockerfile
mkdir -p build
docker buildx build --tag gdb-static .
touch build/build-docker-image.stamp
build-docker-image: build/build-docker-image.stamp
build/download-packages.stamp: build/build-docker-image.stamp src/compilation/download_packages.sh
mkdir -p $(BUILD_PACKAGES_DIR)
docker run --user $(shell id -u):$(shell id -g) \
--rm --volume .:/app/gdb gdb-static env TERM=xterm-256color \
/app/gdb/src/compilation/download_packages.sh /app/gdb/$(BUILD_PACKAGES_DIR)/
touch build/download-packages.stamp
build/symlink-git-packages.stamp: $(SUBMODULE_PACKAGES)
mkdir -p $(BUILD_PACKAGES_DIR)
ln -sf $(addprefix /app/gdb/, $(SUBMODULE_PACKAGES)) $(BUILD_PACKAGES_DIR)/
symlink-git-packages: build/symlink-git-packages.stamp
download-packages: build/download-packages.stamp
build: $(ALL_TARGETS)
$(TARGETS): build-%:
@$(MAKE) _build-$*
$(PYTHON_TARGETS): build-with-python-%:
@WITH_PYTHON="--with-python" $(MAKE) _build-$*
_build-%: symlink-git-packages download-packages build-docker-image
mkdir -p build
docker run --user $(shell id -u):$(shell id -g) \
--rm --volume .:/app/gdb gdb-static env TERM=xterm-256color \
/app/gdb/src/compilation/build.sh $* /app/gdb/build/ /app/gdb/src $(WITH_PYTHON)
pack: $(ALL_PACK_TARGETS)
$(PACK_TARGETS): pack-%:
@$(MAKE) _pack-$*
$(PYTHON_PACK_TARGETS): pack-with-python-%:
@TAR_EXT="with-python-" ARTIFACT_EXT="_with_python" $(MAKE) _pack-$*
_pack-%: build-%
if [ ! -f "build/artifacts/gdb-static-$(TAR_EXT)$*.tar.gz" ]; then \
tar -czf "build/artifacts/gdb-static-$(TAR_EXT)$*.tar.gz" -C "build/artifacts/$*$(ARTIFACT_EXT)" .; \
fi
clean-git-packages:
git submodule foreach '[[ ! "$$sm_path" == src/submodule_packages/* ]] || git clean -xffd'
clean: clean-git-packages
rm -rf build
# Kill and remove all containers of image gdb-static
docker ps -a | grep -P "^[a-f0-9]+\s+gdb-static\s+" | awk '{print $$1}' | xargs docker rm -f 2>/dev/null || true
docker rmi -f gdb-static 2>/dev/null || true