forked from timescale/pg_prometheus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
87 lines (66 loc) · 2.38 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
87
PG_CONFIG = pg_config
EXTENSION = pg_prometheus
SQL_FILES = sql/prometheus.sql
EXT_VERSION = $(shell cat pg_prometheus.control | grep 'default' | sed "s/^.*'\(.*\)'$\/\1/g")
EXT_SQL_FILE = sql/$(EXTENSION)--$(EXT_VERSION).sql
DATA = $(EXT_SQL_FILE)
MODULE_big = $(EXTENSION)
SRCS = \
src/prom.c \
src/parse.c \
src/utils.c
OBJS = $(SRCS:.c=.o)
DEPS = $(SRCS:.c=.d)
MKFILE_PATH := $(abspath $(MAKEFILE_LIST))
CURRENT_DIR = $(dir $(MKFILE_PATH))
TEST_PGPORT ?= 5432
TEST_PGHOST ?= localhost
TEST_PGUSER ?= postgres
TESTS = $(sort $(wildcard test/sql/*.sql))
USE_MODULE_DB=true
REGRESS = $(patsubst test/sql/%.sql,%,$(TESTS))
REGRESS_OPTS = \
--inputdir=test \
--outputdir=test \
--host=$(TEST_PGHOST) \
--port=$(TEST_PGPORT) \
--user=$(TEST_PGUSER) \
--load-language=plpgsql \
--load-extension=$(EXTENSION)
PGXS := $(shell $(PG_CONFIG) --pgxs)
EXTRA_CLEAN = $(EXT_SQL_FILE) $(DEPS)
DOCKER_IMAGE_NAME=pg_prometheus
ORGANIZATION=timescale
GIT_VERSION=$(shell git describe --always | sed 's|v\(.*\)|\1|')
GIT_BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
include $(PGXS)
override CFLAGS += -DINCLUDE_PACKAGE_SUPPORT=0 -MMD
override pg_regress_clean_files = test/results/ test/regression.diffs test/regression.out tmp_check/ log/
-include $(DEPS)
all: $(EXT_SQL_FILE)
$(EXT_SQL_FILE): $(SQL_FILES)
@cat $^ > $@
check-sql-files:
@echo $(SQL_FILES)
install: $(EXT_SQL_FILE)
package: clean $(EXT_SQL_FILE)
@mkdir -p package/lib
@mkdir -p package/extension
$(install_sh) -m 755 $(EXTENSION).so 'package/lib/$(EXTENSION).so'
$(install_sh) -m 644 $(EXTENSION).control 'package/extension/'
$(install_sh) -m 644 $(EXT_SQL_FILE) 'package/extension/'
docker-image: Dockerfile
docker build -t $(ORGANIZATION)/$(DOCKER_IMAGE_NAME) .
docker tag $(ORGANIZATION)/$(EXTENSION):latest $(ORGANIZATION)/$(EXTENSION):${GIT_VERSION}
docker tag $(ORGANIZATION)/$(EXTENSION):latest $(ORGANIZATION)/$(EXTENSION):${GIT_BRANCH}
docker tag $(ORGANIZATION)/$(EXTENSION):latest $(ORGANIZATION)/$(EXTENSION):${EXT_VERSION}
docker-push: docker-image
docker push $(ORGANIZATION)/$(EXTENSION):latest
docker push $(ORGANIZATION)/$(EXTENSION):${GIT_VERSION}
docker push $(ORGANIZATION)/$(EXTENSION):${GIT_BRANCH}
docker push $(ORGANIZATION)/$(EXTENSION):${EXT_VERSION}
typedef.list: clean $(OBJS)
./scripts/generate_typedef.sh
pgindent: typedef.list
pgindent --typedef=typedef.list
.PHONY: check-sql-files all docker-image