-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
93 lines (71 loc) · 2.65 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
88
89
90
91
92
# Makefile
EXTENSION = pg_cld2
EXTVERSION = 1.0.0
DISTVERSION = $(EXTVERSION)
PGFILEDESC = "pg_cld2 - CLD2 language detection"
# PG_CONFIG and PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
PG_CPPFLAGS = $(shell $(PG_CONFIG) --cppflags)
PG_LIBS = $(shell $(PG_CONFIG) --libs)
PG_INCLUDEDIR_SERVER = $(shell $(PG_CONFIG) --includedir-server)
PG_INCLUDEDIR = $(shell $(PG_CONFIG) --includedir)
PG_BINDIR = $(shell $(PG_CONFIG) --bindir)
PG_PKGLIBDIR = $(shell $(PG_CONFIG) --pkglibdir)
PG_REGRESS = $(PG_PKGLIBDIR)/pgxs/src/test/regress/pg_regress
include $(PGXS)
# Directories
SQLDIR = sql
TESTDIR = test
SRCDIR = src
# Files
EXTENSION_SQL = $(SQLDIR)/pg_cld2--$(EXTVERSION).sql
EXTENSION_UNINSTALL = $(SQLDIR)/uninstall_pg_cld2.sql
EXTENSION_UNPACKAGED = $(SQLDIR)/pg_cld2--unpackaged--$(EXTVERSION).sql
DATA = $(wildcard $(SQLDIR)/*.sql) pg_cld2.control
DATA_FILENAMES = $(notdir $(wildcard $(SQLDIR)/*.sql)) pg_cld2.control
DOCS = README.md
MODULE_big = pg_cld2
OBJS = $(SRCDIR)/pg_cld2.o
# Compilation and linking flags -
# necessary for other targets managed by pgxs, not just making .o/.so
SHLIB_LINK += -L$(PG_PKGLIBDIR) -lcld2
# must be exported or it doesn't work
export SHLIB_LINK
# Test settings
REGRESS = $(notdir $(basename $(wildcard test/sql/*.sql)))
#REGRESS = tests-01
REGRESS_OPTS = --inputdir=test --outputdir=test --dbname=pg_cld2_regression --debug
BUILDDIR := $(shell pwd)
TESTDIR_ABS := $(shell pwd)/test
installcheck: all
$(MKDIR_P) test/results
TESTDIR_ABS=$(TESTDIR_ABS) $(PG_REGRESS) $(REGRESS) $(REGRESS_OPTS)
EXTRA_CLEAN = $(wildcard test/out/*.out) \
$(wildcard test/results/*) test/regression.diffs \
$(wildcard $(SRCDIR)/*.o) $(wildcard $(SRCDIR)/*.so) \
$(wildcard $(SRCDIR)/*.bc)
install: all installdirs install-data install-lib
all:
$(MAKE) -C $(SRCDIR)
$(MAKE) -C $(SRCDIR) $(MODULE_big).so
install-data: installdirs
$(INSTALL_DATA) $(DATA) '$(DESTDIR)$(datadir)/extension/'
install-lib: installdirs
$(INSTALL_SHLIB) '$(SRCDIR)/$(MODULE_big).so' '$(DESTDIR)$(pkglibdir)/'
# Regression tests
# Clean up build files
# not sure why EXTRA_CLEAN doesn't work with the default clean target
clean:
rm -fv $(EXTRA_CLEAN)
#$(MAKE) -C $(SRCDIR) clean
#rm -fv $(SRCDIR)/*.o $(SRCDIR)/*.so
#rm -rf test/out/* test/results
uninstall:
@echo $(DATA_FILENAMES)
cat $(EXTENSION_UNINSTALL) | sudo -u postgres psql postgres
rm -fv '$(DESTDIR)$(pkglibdir)/$(MODULE_big).so'
$(foreach filename, $(DATA_FILENAMES), rm -fv '$(DESTDIR)$(datadir)/extension/$(filename)';)
dist:
git archive --format zip --prefix=$(EXTENSION)-$(DISTVERSION)/ -o $(EXTENSION)-$(DISTVERSION).zip HEAD
.PHONY: all install uninstall clean test installcheck