This repository has been archived by the owner on Sep 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrules.mk
55 lines (45 loc) · 1.96 KB
/
rules.mk
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
# This file is part of the dune-community/Dockerfiles project:
# https://github.com/dune-community/Dockerfiles
# Copyright 2017 dune-community/Dockerfiles developers and contributors. All rights reserved.
# License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
# or GPL-2.0+ (http://opensource.org/licenses/gpl-license)
# Authors:
# Rene Milk (2017)
THISDIR=$(dir $(lastword $(MAKEFILE_LIST)))
REPONAMES = $(patsubst %/,%,$(dir $(wildcard */Dockerfile.in)))
DOCKER_NOCACHE=
BUILD_CMD=$(DOCKER_SUDO) docker build ${DOCKER_NOCACHE} --rm=true ${DOCKER_QUIET}
.PHONY: push all $(REPONAMES) readme
check_client:
@$(DOCKER_SUDO) docker info > /dev/null || \
(echo "cannot connect to docker client. export DOCKER_SUDO=sudo ?" ; exit 1)
$(REPONAMES): check_client
$(eval GITREV=$(shell git describe --tags --dirty --always --long))
$(eval IMAGE=$(NAME)-$@)
$(eval REPO=dunecommunity/$(IMAGE))
$(eval DF=Dockerfile.generated.$(DEBIANVERSION))
$(eval CTX=$@_$(DEBIANVERSION)_context.tar)
tar --create --file $(CTX) -C $@/../common_context .
m4 -D BUILD_DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") \
-D IMAGE="$(IMAGE)" \
-D AUTHOR="$(AUTHOR)" \
-D GITREV=$(GITREV) \
-D DEBIANBASEDATE=20210511 \
-D DEBIANVERSION=$(DEBIANVERSION) \
-I$(THISDIR)/include -I ./include $@/Dockerfile.in > $@/$(DF)
(test -n "${DOCKER_PRUNE}" && docker system prune -f) || true
tar --append --file $(CTX) -C $@ .
cd $@ && cat ../$(CTX) | $(BUILD_CMD) \
-t $(REPO):$(GITREV) -f $(DF) -
$(DOCKER_SUDO) docker tag $(REPO):$(GITREV) $(REPO):latest
push_%:
$(DOCKER_SUDO) docker push dunecommunity/$(NAME)-$*
push: $(addprefix push_,$(REPONAMES))
all: $(REPONAMES)
readme:
m4 -d -D REPONAMES="$(REPONAMES)" -I$(THISDIR)/include -I ./include \
-D BASENAME=$(NAME) $(THISDIR)/include/readme.m4 \
> README.md
# emulate autoconf quadrigraphs to escape m4's quoting hell wrt [,]
sed -i -e 's/@<:@/[/g' -e 's/@>:@/]/g' README.md
.DEFAULT_GOAL := all