33
44TOP := $(dir $(abspath $(lastword $(MAKEFILE_LIST ) ) ) )
55
6+ VERSION_FILE = src/bin/pg_autoctl/git-version.h
7+
8+ ifeq ("$(wildcard $(VERSION_FILE ) ) ","")
9+ DUMMY := $(shell git update-index -q --refresh)
10+ GIT_DIRTY := $(shell test -z "`git diff-index --name-only HEAD --`" || echo "-dirty")
11+ GIT_VVERSION := $(shell git describe --match "v[0-9]* " HEAD 2>/dev/null)
12+ GIT_DVERSION := $(shell echo $(GIT_VVERSION ) | awk -Fv '{print $$2"$(GIT_DIRTY ) "}')
13+ GIT_VERSION := $(shell echo $(GIT_DVERSION ) | sed -e 's/-/./g')
14+ else
15+ GIT_VERSION := $(shell awk -F '[ "]' '{print $$4}' $(VERSION_FILE ) )
16+ endif
17+
618CONTAINER_NAME = pg_auto_failover
719BUILD_CONTAINER_NAME = pg_auto_failover_build
820TEST_CONTAINER_NAME = pg_auto_failover_test
921DOCKER_RUN_OPTS = --privileged --rm
1022
1123PGVERSION ?= 14
1224
25+ BUILD_ARGS_PG11 = --build-arg PGVERSION=11 --build-arg CITUSTAG=v9.5.10
26+ BUILD_ARGS_PG12 = --build-arg PGVERSION=12 --build-arg CITUSTAG=v10.2.3
27+ BUILD_ARGS_PG13 = --build-arg PGVERSION=13 --build-arg CITUSTAG=v10.2.3
28+ BUILD_ARGS_PG14 = --build-arg PGVERSION=14 --build-arg CITUSTAG=v11.1.2
29+ BUILD_ARGS_PG15 = --build-arg PGVERSION=15 --build-arg CITUSTAG=v11.1.2
30+
1331NOSETESTS = $(shell which nosetests3 || which nosetests)
1432
1533# Tests for the monitor
@@ -132,6 +150,7 @@ all: monitor bin ;
132150
133151install : install-monitor install-bin ;
134152clean : clean-monitor clean-bin ;
153+ maintainer-clean : clean-monitor clean-version clean-bin ;
135154check : check-monitor ;
136155
137156monitor :
@@ -146,7 +165,7 @@ install-monitor: monitor
146165check-monitor : install-monitor
147166 $(MAKE ) -C src/monitor/ installcheck
148167
149- bin :
168+ bin : version
150169 $(MAKE ) -C src/bin/ all
151170
152171clean-bin :
@@ -155,6 +174,14 @@ clean-bin:
155174install-bin : bin
156175 $(MAKE ) -C src/bin/ install
157176
177+ version : $(VERSION_FILE ) ;
178+
179+ $(VERSION_FILE ) :
180+ @echo " #define GIT_VERSION \" " $(GIT_VERSION ) " \" " > $@
181+
182+ clean-version :
183+ rm -f $(VERSION_FILE )
184+
158185#
159186# make ci-test; is run on the GitHub Action workflow
160187#
@@ -227,23 +254,21 @@ build-image:
227254
228255# Citus 9.0 seems to be the most recent version of Citus with Postgres 10
229256# support, but fails to compile nowadays...
230- # build-test-pg10:
231- # docker build --build-arg PGVERSION=10 --build-arg CITUSTAG=v9.0.2 --target test -t $(TEST_CONTAINER_NAME):pg10 .
232257
233- build-test-pg11 :
234- docker build --build-arg PGVERSION=11 --build-arg CITUSTAG=v9.5.10 --target test -t $(TEST_CONTAINER_NAME ) :pg11 .
258+ build-test-pg11 : version
259+ docker build $( BUILD_ARGS_PG11 ) --target test -t $(TEST_CONTAINER_NAME ) :pg11 .
235260
236- build-test-pg12 :
237- docker build --build-arg PGVERSION=12 --build-arg CITUSTAG=v10.2.3 --target test -t $(TEST_CONTAINER_NAME ) :pg12 .
261+ build-test-pg12 : version
262+ docker build $( BUILD_ARGS_PG12 ) --target test -t $(TEST_CONTAINER_NAME ) :pg12 .
238263
239- build-test-pg13 :
240- docker build --build-arg PGVERSION=13 --build-arg CITUSTAG=v10.2.3 --target test -t $(TEST_CONTAINER_NAME ) :pg13 .
264+ build-test-pg13 : version
265+ docker build $( BUILD_ARGS_PG13 ) --target test -t $(TEST_CONTAINER_NAME ) :pg13 .
241266
242- build-test-pg14 :
243- docker build --build-arg PGVERSION=14 --build-arg CITUSTAG=v11.1.2 --target test -t $(TEST_CONTAINER_NAME ) :pg14 .
267+ build-test-pg14 : version
268+ docker build $( BUILD_ARGS_PG14 ) --target test -t $(TEST_CONTAINER_NAME ) :pg14 .
244269
245- build-test-pg15 :
246- docker build --build-arg PGVERSION=15 --build-arg CITUSTAG=v11.1.2 --target test -t $(TEST_CONTAINER_NAME ) :pg15 .
270+ build-test-pg15 : version
271+ docker build $( BUILD_ARGS_PG15 ) --target test -t $(TEST_CONTAINER_NAME ) :pg15 .
247272
248273
249274build-test-image : build-test-pg$(PGVERSION ) ;
@@ -261,23 +286,20 @@ run-test: build-test-pg$(PGVERSION)
261286 make -C /usr/src/pg_auto_failover test \
262287 PGVERSION=$(PGVERSION ) TEST=' ${TEST}'
263288
264- # build-pg10: build-test-pg10
265- # docker build --build-arg PGVERSION=10 -t $(CONTAINER_NAME):pg10 .
266-
267289build-pg11 : build-test-pg11
268- docker build --build-arg PGVERSION=11 -t $(CONTAINER_NAME ) :pg11 .
290+ docker build $( BUILD_ARGS_PG11 ) -t $(CONTAINER_NAME ) :pg11 .
269291
270292build-pg12 : build-test-pg12
271- docker build --build-arg PGVERSION=12 -t $(CONTAINER_NAME ) :pg12 .
293+ docker build $( BUILD_ARGS_PG12 ) -t $(CONTAINER_NAME ) :pg12 .
272294
273295build-pg13 : build-test-pg13
274- docker build --build-arg PGVERSION=13 -t $(CONTAINER_NAME ) :pg13 .
296+ docker build $( BUILD_ARGS_PG13 ) -t $(CONTAINER_NAME ) :pg13 .
275297
276298build-pg14 : build-test-pg14
277- docker build --build-arg PGVERSION=14 -t $(CONTAINER_NAME ) :pg14 .
299+ docker build $( BUILD_ARGS_PG14 ) -t $(CONTAINER_NAME ) :pg14 .
278300
279301build-pg15 : build-test-pg15
280- docker build --build-arg PGVERSION=15 -t $(CONTAINER_NAME ) :pg15 .
302+ docker build $( BUILD_ARGS_PG15 ) -t $(CONTAINER_NAME ) :pg15 .
281303
282304build : build-pg11 build-pg12 build-pg13 build-pg14 build-pg15 ;
283305
@@ -290,7 +312,7 @@ build-i386:
290312 docker build -t i386:latest -f Dockerfile.i386 .
291313
292314build-demo :
293- docker build -t citusdata/pg_auto_failover:demo .
315+ docker build $( BUILD_ARGS_PG14 ) -t citusdata/pg_auto_failover:demo .
294316
295317# expected to be run from within the i386 docker container
296318installcheck-i386 :
@@ -414,7 +436,7 @@ azdrop: all
414436
415437.PHONY : all clean check install docs tikz
416438.PHONY : monitor clean-monitor check-monitor install-monitor
417- .PHONY : bin clean-bin install-bin
439+ .PHONY : bin clean-bin install-bin maintainer-clean
418440.PHONY : build-test run-test spellcheck lint linting ci-test
419441.PHONY : tmux-clean cluster compose
420442.PHONY : azcluster azdrop az
0 commit comments