source: trunk/extensions/postgis/Makefile.in @ 9043

Last change on this file since 9043 was 9043, checked in by pramsey, 4 years ago

Change how we calculate minor versions suitable for extension upgrade.

File size: 5.9 KB
Line 
1include ../upgradeable_versions.mk
2
3EXTENSION     = postgis
4EXTVERSION    = @POSTGIS_LIB_VERSION@
5MINORVERSION  = @POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@
6
7MICRO_NUMBER  = $(shell echo $(EXTVERSION) | sed "s/[0-9]\.[0-9]\.\([0-9]*\)[a-zA-Z]*[0-9]*/\1/")
8PREREL_NUMBER = $(shell echo $(EXTVERSION) | \
9                        sed "s/[0-9]\.[0-9]\.\(.*\)/\1/" | \
10                        grep "[a-zA-Z]" | \
11                        sed "s/[0-9][a-zA-Z]\([0-9]*\)[a-zA-Z]*/\1/")
12MICRO_PREV    = $(shell if test "$(MICRO_NUMBER)x" != "x"; then expr $(MICRO_NUMBER) - 1; fi)
13PREREL_PREV   = $(shell if test "$(PREREL_NUMBER)x" != "x"; then expr $(PREREL_NUMBER) - 1; fi)
14
15PREREL_PREFIX = $(shell echo $(EXTVERSION) | \
16                        sed "s/[0-9]\.[0-9]\.\(.*\)/\1/" | \
17                        grep "[a-zA-Z]" | \
18                        sed "s/\([0-9][a-zA-Z]*\)[0-9]*/\1/")
19
20DATA         = $(filter-out $(wildcard sql/*--*.sql),$(wildcard sql/*.sql))
21
22#DOCS         = $(wildcard ../../doc/html/*.html)
23PG_CONFIG    = pg_config
24
25PG91         = $(shell $(PG_CONFIG) --version | grep -qE " 8\.| 9\.0" && echo no || echo yes)
26SQL_BITS     = $(wildcard sql_bits/*.sql)
27EXTRA_CLEAN += ${SQL_BITS} sql/*.sql
28
29
30ifeq ($(PG91),yes)
31sql/$(EXTENSION).sql: sql_bits/postgis.sql sql_bits/postgis_comments.sql sql_bits/rtpostgis.sql sql_bits/raster_comments.sql sql_bits/spatial_ref_sys.sql
32        cat $^ > $@
33       
34all: sql/$(EXTENSION)--$(EXTVERSION).sql sql_minor_upgrade
35
36sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql
37        cp $< $@
38
39sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql: sql_bits/rtpostgis--unpackaged.sql sql_bits/postgis--unpackaged.sql
40        cat $^ > $@
41
42#strip BEGIN/COMMIT since these are not allowed in extensions
43sql_bits/spatial_ref_sys.sql: ../../spatial_ref_sys.sql
44        sed -e 's/BEGIN;//g' -e 's/COMMIT;//g'  $< > $@
45
46#strip BEGIN/COMMIT since these are not allowed in extensions
47sql_bits/postgis.sql: ../../postgis/postgis.sql
48        sed -e 's/BEGIN;//g' -e 's/COMMIT;//g'  $< > $@
49
50sql_bits/postgis_comments.sql: ../../doc/postgis_comments.sql
51        cp $< $@
52
53#strip BEGIN/COMMIT since these are not allowed in extensions
54sql_bits/rtpostgis.sql: ../../raster/rt_pg/rtpostgis.sql
55        sed -e 's/BEGIN;//g' -e 's/COMMIT;//g'  $< > $@
56
57# we need to also drop this temporary function from the extension
58# for casts that are being dropped we need to drop them
59# from extension only if they are in the existension so we use our postgis_extension_drop..
60# so that it will silently fail if cast is not in extension
61sql_bits/rtpostgis_upgrade_20_minor.sql: ../../raster/rt_pg/rtpostgis_upgrade_20_minor.sql
62        sed -e 's/BEGIN;//g' -e 's/COMMIT;//g' \
63                -e 's/DROP FUNCTION _rename_raster_tables();/ALTER EXTENSION ${EXTENSION} DROP FUNCTION _rename_raster_tables();DROP FUNCTION _rename_raster_tables();/g' \
64                -e 's/DROP FUNCTION _drop_st_samealignment();/ALTER EXTENSION ${EXTENSION} DROP FUNCTION _drop_st_samealignment();DROP FUNCTION _drop_st_samealignment();/g' \
65                -e 's/DROP CAST\(.*\)/SELECT postgis_extension_drop_if_exists('\''$(EXTENSION)'\'', '\''DROP CAST \1'\'');DROP CAST \1/' \
66        $< > $@
67
68#can't use the one built because can't drop the postgis_version function
69#leave out all casts, operators, types, tables, schemas
70# sql_bits/postgis_upgrade_minor.sql: ../../postgis/postgis.sql
71#                sed -e '/^\(CREATE\|ALTER\) \(CAST\|OPERATOR\|TYPE\|TABLE\|SCHEMA\|DOMAIN\|TRIGGER\).*;/d' \
72#                       -e '/^\(CREATE\|ALTER\) \(CAST\|OPERATOR\|TYPE\|TABLE\|SCHEMA\|DOMAIN\|TRIGGER\)/,/\;/d' \
73#                       -e 's/BEGIN;//g' -e 's/COMMIT;//g' \
74#                $< > $@
75#don't drop casts just yet since we don't have provision to remove from extension yet
76#need to also drop temeporary functions from extenions since it gets auto-added
77sql_bits/postgis_upgrade_minor.sql: ../../postgis/postgis_upgrade_20_minor.sql
78                 sed -e 's/BEGIN;//g' -e 's/COMMIT;//g' \
79                 -e '/^\(DROP\|CREATE\) \(CAST\).*;/d' \
80                 -e '/^\(DROP\|CREATE\) \(CAST\)/,/\;/d' \
81                 -e 's/DROP FUNCTION postgis_major_version_check();/ALTER EXTENSION ${EXTENSION} DROP FUNCTION postgis_major_version_check();DROP FUNCTION postgis_major_version_check();/g' \
82                 $< > $@
83
84
85sql_bits/raster_comments.sql: ../../doc/raster_comments.sql
86        cp $< $@
87
88sql_bits/postgis_raster_upgrade_minor.sql: ../postgis_extension_helper.sql sql_bits/remove_from_extension.sql.in ../../postgis/postgis_drop_before.sql.in.c  sql_bits/postgis_upgrade_minor.sql         sql_bits/rtpostgis_upgrade_20_minor.sql  ../../doc/raster_comments.sql  ../../doc/postgis_comments.sql ../postgis_extension_helper_uninstall.sql
89        cat $^ > $@
90
91# sql_bits/rtpostgis--unpackaged.sql:  ../../raster/rt_pg/rtpostgis.sql 
92#       sed -e 's/^[\t]*//' \
93#               -e :a -e '$!N; s/,\n/,/; ta' \
94#       $< > $@
95#remove leading white space and tabs
96#remove line break from a line if it ends in ,
97
98sql_bits/rtpostgis-filtered.sql:  ../../raster/rt_pg/rtpostgis.sql
99                sed \
100                -e 's/^[\t]*//' \
101                $< > $@
102
103sql_bits/rtpostgis--unpackaged.sql:  ../../raster/rt_pg/rtpostgis.sql
104                sed \
105                -e 's/^[\t]*//' \
106                -e '$!N; s/(\n/(/g' \
107                -e '/^CREATE \(OR REPLACE FUNCTION\|TRIGGER\|TYPE\|TABLE\|VIEW\)/!d;' \
108                -e 's/OR REPLACE//g' \
109                -e 's/CREATE\(.*\)/ALTER EXTENSION $(EXTENSION) ADD\1;/' \
110                -e 's/DEFAULT [^()]\+//g' \
111                -e 's/\(BEFORE\|AS\|RETURNS\)\(.*\)/;/' \
112                -e 's/(;/;/' \
113                -e 's/\\(;/;/' \
114                -e 's/;;/;/g' $< > $@
115
116sql_bits/postgis--unpackaged.sql:   ../../postgis/postgis.sql
117        sed -e '/^CREATE \(OR REPLACE\|TRIGGER\|TYPE\|TABLE\|VIEW\)/!d;' \
118                -e 's/OR REPLACE//g' \
119                -e 's/CREATE\(.*\)/ALTER EXTENSION $(EXTENSION) ADD\1;/' \
120                -e 's/DEFAULT [\.0-9a-zA-Z]\+//g' \
121                -e 's/\(BEFORE\|AS\|RETURNS\)\(.*\)/;/' \
122                -e 's/(;/;/' \
123                -e 's/\\(;/;/' \
124                -e 's/;;/;/g' $< > $@
125
126sql_minor_upgrade: sql_bits/postgis_upgrade_minor.sql sql_bits/postgis_raster_upgrade_minor.sql
127        for OLD_VERSION in $(UPGRADEABLE_VERSIONS); do \
128          cat $< > sql/$(EXTENSION)--$$OLD_VERSION--$(EXTVERSION).sql; \
129        done
130
131DATA = $(wildcard sql/*--*.sql) sql/$(EXTENSION)--$(EXTVERSION).sql
132EXTRA_CLEAN += sql/$(EXTENSION)--$(EXTVERSION).sql
133endif
134
135PGXS := $(shell $(PG_CONFIG) --pgxs)
136include $(PGXS)
Note: See TracBrowser for help on using the repository browser.