-
Notifications
You must be signed in to change notification settings - Fork 8
/
GNUmakefile
87 lines (70 loc) · 2.94 KB
/
GNUmakefile
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_consul/GNUmakefile
# Maintainer vars
CONTRIB_DIR=contrib
CPR_DIR=${CONTRIB_DIR}/cpr
# BEGIN: pgxs vars
MODULE_big = pg_consul
OBJS = $(patsubst %.cpp,%.o,$(wildcard src/*.cpp))
EXTENSION = pg_consul
EXTVERSION = $(shell grep -m 1 '[[:space:]]\{8\}"version":' META.json | \
sed -e 's/[[:space:]]*"version":[[:space:]]*"\([^"]*\)",\{0,1\}/\1/')
DATA = $(wildcard sql/*--*.sql)
DOCS = $(wildcard doc/*.md)
PGFILEDESC = "pg_consul - SQL API to consul"
TESTS = $(wildcard test/sql/*.sql)
REGRESS = $(patsubst test/sql/%.sql,%,$(TESTS))
REGRESS_OPTS = --inputdir=test --load-extension=pg_consul
export PG_REGRESS_DIFF_OPTS=-u
PG_CPPFLAGS+=-pedantic -Wall
PG_CPPFLAGS+=-Wno-deprecated-register -Wno-unused-local-typedef
PG_CPPFLAGS+=-I./include
PG_CPPFLAGS+=-std=c++14
#PG_CPPFLAGS+=-fno-exceptions
SHLIB_LINK=-std=c++14 -stdlib=libc++ -lcurl
EXTRA_CLEAN = playground/*.o \
playground/consul-kv \
playground/consul-status
PG_CONFIG ?= pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
# FIXME(seanc@): This is a terrible pgxs hack. In order to link a PostgreSQL
# shared object, use clang++ (or what is hopefully clang++ and not g++) as
# the linker. Ideally it would be possible to specify this as a paramter to
# pgxs, something like PGXS_LD. This variable needs to be overwritten after
# PGXS is included.
CXX=clang++
CC=${CXX}
all: sql/$(EXTENSION)--$(EXTVERSION).sql
consul consul1::
mkdir -p $(shell pwd)/.consul1-data
consul agent -server -bootstrap-expect=1 -data-dir=$(shell pwd)/.consul1-data -dc=pgc1 -node=server1 -bind=127.0.0.1
CONSUL2_IP=$(shell ifconfig en0 | grep inet | awk '{print $$2}')
consul2::
mkdir -p $(shell pwd)/.consul2-data
consul agent -server -data-dir=$(shell pwd)/.consul2-data -dc=pgc1 -node=server2 -bind=$(CONSUL2_IP) -client=$(CONSUL2_IP) -retry-join=127.0.0.1
consul3::
mkdir -p $(shell pwd)/.consul3-data
consul agent -server -bootstrap -data-dir=$(shell pwd)/.consul3-data -dc=pgc1 -node=server3 -bind=127.0.0.1
sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql
cp $< $@
.PHONY: results
results:
rsync -avP --include='*.out$' --delete results/ expected/
dist:
git archive --format zip --prefix=$(EXTENSION)-$(EXTVERSION)/ -o $(EXTENSION)-$(EXTVERSION).zip HEAD
## BEGIN: Maintainer targets
output:
printf "DATA: %s\n" "${DATA}"
printf "MODULES: %s\n" "${MODULES}"
printf "MODULES_big: %s\n" "$(MODULE_big)"
printf "REGRESS: %s\n" "$(REGRESS)"
printf "docdir: %s\n" "$(docdir)"
printf "srcdir: %s\n" "$(srcdir)"
psql::
psql -U ${USER} -d contrib_regression
# import-cpr.sh is used to copy in curl sources into src/. Noone should need
# to call this other than the maintainer.
import-cpr.sh::
echo mkdir -p include/cpr > $@
find ${CPR_DIR}/include -type f | awk '{print "cp " $$1 " include/cpr/`basename " $$1 "`"}' >> $@
find ${CPR_DIR}/cpr -type f -name '*.cpp' | awk '{print "cp " $$1 " src/`dirname " $$1 " | perl -p -e \"s#/#\\n#g\" | tail -1 | perl -p -e \"s#\\n#-#g\"`-`basename " $$1 "`"}' >> $@