forked from decibel/cat_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
87 lines (68 loc) · 3.02 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
B = sql
testdeps: $(wildcard test/*.sql test/helpers/*.sql) # Be careful not to include directories in this
include pgxntool/base.mk
LT95 = $(call test, $(MAJORVER), -lt, 95)
LT93 = $(call test, $(MAJORVER), -lt, 93)
$B:
@mkdir -p $@
versioned_in = $(wildcard sql/*--*--*.sql.in)
versioned_out = $(subst sql/,$B/,$(subst .sql.in,.sql,$(versioned_in)))
all: $B/cat_tools.sql $(versioned_out)
installcheck: $B/cat_tools.sql $(versioned_out)
EXTRA_CLEAN += $B/cat_tools.sql $(versioned_out)
# TODO: refactor the version stuff into a function
#
# This initially creates [email protected] before moving it into place atomically. That's
# important to make the use of .PRECIOUS safe, which is necessary for
# watch-make not to freak out.
#
# Actually, that doesn't even fix it. TODO: Figure out why this breaks watch-make.
#
# Make sure not to insert blank lines here; everything needs to be part of the cat_tools.sql recipe!
#.PRECIOUS: $B/cat_tools.sql
$B/%.sql: sql/%.sql.in pgxntool/safesed
(echo @generated@ && cat $< && echo @generated@) | sed -e 's#@generated@#-- GENERATED FILE! DO NOT EDIT! See $<#' > [email protected]
ifeq ($(LT95),yes)
pgxntool/safesed [email protected] -E -e 's/(.*)-- SED: REQUIRES 9.5!/-- Requires 9.5: \1/'
else
pgxntool/safesed [email protected] -E -e 's/(.*)-- SED: PRIOR TO 9.5!/-- Not used prior to 9.5: \1/'
endif
ifeq ($(LT93),yes)
pgxntool/safesed [email protected] -E -e 's/(.*)-- SED: REQUIRES 9.3!/-- Requires 9.3: \1/'
else
pgxntool/safesed [email protected] -E -e 's/(.*)-- SED: PRIOR TO 9.3!/-- Not used prior to 9.3: \1/'
endif
mv [email protected] $@
# Support for upgrade test
#
# TODO: Instead of all of this stuff figure out how to pass something to
# pg_regress that will alter the behavior of the test instead.
TEST_BUILD_DIR = test/.build
testdeps: $(TEST_BUILD_DIR)/dep.mk $(TEST_BUILD_DIR)/active.sql
-include $(TEST_BUILD_DIR)/dep.mk
# Ensure dep.mk exists.
$(TEST_BUILD_DIR)/dep.mk: $(TEST_BUILD_DIR)
echo 'TEST_LOAD_SOURCE = new' > $(TEST_BUILD_DIR)/dep.mk
.PHONY: set-test-new
set-test-new: $(TEST_BUILD_DIR)
echo 'TEST_LOAD_SOURCE = new' > $(TEST_BUILD_DIR)/dep.mk
.PHONY: test-upgrade
set-test-upgrade: $(TEST_BUILD_DIR)
echo 'TEST_LOAD_SOURCE = upgrade' > $(TEST_BUILD_DIR)/dep.mk
$(TEST_BUILD_DIR)/active.sql: $(TEST_BUILD_DIR)/dep.mk $(TEST_BUILD_DIR)/$(TEST_LOAD_SOURCE).sql
ln -sf $(TEST_LOAD_SOURCE).sql $@
$(TEST_BUILD_DIR)/upgrade.sql: test/load_upgrade.sql $(TEST_BUILD_DIR) old_version
(echo @generated@ && cat $< && echo @generated@) | sed -e 's#@generated@#-- GENERATED FILE! DO NOT EDIT! See $<#' > $@
$(TEST_BUILD_DIR)/new.sql: test/load_new.sql $(TEST_BUILD_DIR)
(echo @generated@ && cat $< && echo @generated@) | sed -e 's#@generated@#-- GENERATED FILE! DO NOT EDIT! See $<#' > $@
# TODO: figure out vpath
EXTRA_CLEAN += $(TEST_BUILD_DIR)/
$(TEST_BUILD_DIR):
[ -d $@ ] || mkdir -p $@
.PHONY: old_version
old_version: $(DESTDIR)$(datadir)/extension/cat_tools--0.2.0.sql
$(DESTDIR)$(datadir)/extension/cat_tools--0.2.0.sql:
pgxn install --unstable 'cat_tools=0.2.0'
.PHONY: clean_old_version
clean_old_version:
pgxn uninstall --unstable 'cat_tools=0.2.0'