-
Notifications
You must be signed in to change notification settings - Fork 27
/
Makefile
138 lines (122 loc) · 5.82 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
EXTENSION = q3c
EXTVERSION := $(shell grep default_version $(EXTENSION).control | \
sed -e "s/default_version[[:space:]]*=[[:space:]]*'\([^']*\)'/\1/")
# Note the filename is different from README.md
# because of the requirement to have unique filenames
# we create q3c.md out of README.md when compiling
# the extension
DOCS = q3c.md
OBJS = dump.o q3c.o q3c_poly.o q3cube.o
MODULE_big = q3c
DATA = $(wildcard scripts/*sql)
PG_CONFIG = pg_config
SHLIB_LINK += $(filter -lm, $(LIBS))
EXTRA_CLEAN = dump.c prepare prepare.o gen_data.o \
results/join.out results/cone.out results/ellipse.out \
results/version.out results/poly.out results/area.out \
gen_data
ifeq ($(Q3C_NOOPT),1)
OPT = -O0
else
OPT = -O3
endif
#DEBUG = -O0 -g3 -ggdb -DQ3C_DEBUG
PG_CPPFLAGS = $(DEBUG) $(OPT) -D_GNU_SOURCE -D__STDC_FORMAT_MACROS -DQ3C_VERSION='"'$(EXTVERSION)'"'
CPPFLAGS = $(CPPFLAGS) -D$(Q3CVERSION)
ifeq (, $(shell which $(PG_CONFIG)))
$(error "No pg_config in $(PATH)! Exiting...")
endif
PGXS := $(shell $(PG_CONFIG) --pgxs)
ifeq (, $(wildcard $(PGXS)))
$(error "The $(PGXS) file not found. Check your PG installation. Exiting...")
endif
include $(PGXS)
PGVERNEW := $(shell if [ $(MAJORVERSION) -ge 12 ] ; then echo N ; else echo O ; fi )
ifeq ($(PGVERNEW), N)
PG_LIBS += -L$(shell $(PG_CONFIG) --pkglibdir)
LIBS := $(filter-out -lpam -lxml2 -lxslt -lselinux -ledit -lgssapi_krb5, $(LIBS))
MYBINLIBS := $(LIBS) $(PG_LIBS) -lm
else
MYBINLIBS := $(PG_LIBS) -lm
endif
readme:
cp README.md q3c.md
dump.c: prepare readme
./prepare
prepare: prepare.o q3cube.o q3c_poly.o
$(CC) $? $(CFLAGS) $(PG_LIBS) $(PG_LDFLAGS) $(LDFLAGS) $(MYBINLIBS) -o $@
gen_data: gen_data.c
$(CC) $< $(CPPFLAGS) $(LDFLAGS) -lm -o $@
test: gen_data
dropdb --if-exists q3c_test
createdb q3c_test
psql q3c_test -c "CREATE TABLE test (ra double precision, dec double precision)"
psql q3c_test -c "CREATE TABLE test1 (ra double precision, dec double precision)"
psql q3c_test -c "CREATE TABLE test_pm0 (ra double precision, dec double precision, pmra real, pmdec real, epoch real)"
psql q3c_test -c "CREATE TABLE test_pm1 (ra double precision, dec double precision, pmra real, pmdec real, epoch real)"
psql q3c_test -c "CREATE TABLE test_small (ra double precision, dec double precision)"
./gen_data 1 1000000 | psql q3c_test -c "COPY test FROM STDIN WITH DELIMITER ' '"
./gen_data 2 1000000 | psql q3c_test -c "COPY test1 FROM STDIN WITH DELIMITER ' '"
./gen_data 3 100000 | psql q3c_test -c "COPY test_small FROM STDIN WITH DELIMITER ' '"
./gen_data 4 1000000 --withpm --pmscale=0 --randomepoch | psql q3c_test -c "COPY test_pm0 FROM STDIN WITH DELIMITER ' '"
./gen_data 5 1000000 --withpm --pmscale=1000 --epoch=2015 | psql q3c_test -c "COPY test_pm1 FROM STDIN WITH DELIMITER ' '"
psql q3c_test -c 'CREATE EXTENSION q3c'
psql q3c_test -c 'CREATE INDEX q3c_idx1 ON test1 (q3c_ang2ipix(ra,dec))'
psql q3c_test -c 'CREATE INdex ON test_pm0 (q3c_ang2ipix(ra,dec))'
psql q3c_test -c 'CREATE INDEX on test_pm1 (q3c_ang2ipix(ra,dec))'
psql q3c_test -c 'CREATE INDEX q3c_idx ON test (q3c_ang2ipix(ra,dec))'
psql q3c_test -c 'CREATE INDEX q3c_idx_small ON test_small (q3c_ang2ipix(ra,dec))'
psql q3c_test -c 'ANALYZE test'
psql q3c_test -c 'ANALYZE test1'
psql q3c_test -c 'ANALYZE test_pm0'
psql q3c_test -c 'ANALYZE test_pm1'
psql q3c_test -c 'ANALYZE test_small'
mkdir -p results
cat sql/misc.sql | psql q3c_test > results/misc.out 2>&1
diff results/misc.out expected/misc.expected
cat sql/ang2ipix.sql | psql q3c_test > results/ang2ipix.out 2>&1
diff results/ang2ipix.out expected/ang2ipix.expected
cat sql/cone.sql | psql q3c_test > results/cone.out 2>&1
diff results/cone.out expected/cone.expected
cat sql/cone_join_rev.sql | psql q3c_test > results/cone.out
diff results/cone.out expected/cone.expected
cat sql/ellipse.sql | psql q3c_test > results/ellipse.out
diff results/ellipse.out expected/ellipse.expected
cat sql/join.sql | psql q3c_test > results/join.out
diff results/join.out expected/join.expected
cat sql/join_ellipse.sql | psql q3c_test > results/join_ellipse.out
diff results/join_ellipse.out expected/join.expected
cat sql/join_pm1.sql | psql q3c_test > results/join_pm1.out
diff results/join_pm1.out expected/join_pm1.expected
cat sql/join_pm2.sql | psql q3c_test > results/join_pm2.out
diff results/join_pm2.out expected/join_pm2.expected
cat sql/poly.sql | psql q3c_test > results/poly.out
diff results/poly.out expected/poly.expected
cat sql/poly1.sql | psql q3c_test > results/poly1.out
diff results/poly1.out expected/poly.expected
cat sql/version.sql | psql q3c_test > results/version.out
diff results/version.out expected/version.expected
cat sql/area.sql | psql q3c_test > results/area.out 2>&1
diff results/area.out expected/area.expected
cat sql/errors.sql | psql q3c_test > results/errors.out 2>&1
diff results/errors.out expected/errors.expected
dropdb q3c_test
createdb q3c_test
psql q3c_test -c 'CREATE EXTENSION q3c VERSION "1.6.0"'
psql q3c_test -c 'ALTER EXTENSION q3c UPDATE TO "1.7.0"'
psql q3c_test -c 'ALTER EXTENSION q3c UPDATE TO "1.8.0"'
psql q3c_test -c 'ALTER EXTENSION q3c UPDATE TO "2.0.0"'
dropdb q3c_test
createdb q3c_test
psql q3c_test -c "CREATE TABLE test (ra double precision, dec double precision)"
psql q3c_test -c "CREATE TABLE test1 (ra double precision, dec double precision)"
./gen_data 1 1000000 | psql q3c_test -c "COPY test FROM STDIN WITH DELIMITER ' '"
./gen_data 2 1000000 | psql q3c_test -c "COPY test1 FROM STDIN WITH DELIMITER ' '"
psql q3c_test -c 'CREATE schema tests'
psql q3c_test -c 'CREATE EXTENSION q3c schema tests'
psql q3c_test -c 'set search_path to public,tests; CREATE INDEX q3c_idx1 ON test1 (q3c_ang2ipix(ra,dec))'
psql q3c_test -c 'ANALYZE test'
psql q3c_test -c 'ANALYZE test1'
cat sql/relocation.sql | psql q3c_test > results/relocation.out
diff results/relocation.out expected/relocation.expected
dropdb q3c_test