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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
|
include ../upgradeable_versions.mk
EXTENSION = postgis_tiger_geocoder
EXTVERSION = @POSTGIS_LIB_VERSION@
MINORVERSION = 2011.@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@
GREP = @GREP@
PERL = @PERL@
MICRO_NUMBER = $(shell echo $(EXTVERSION) | \
$(PERL) -pe 's/\d.\d.(\d+)[a-zA-Z]*\d*/$1/'
PREREL_NUMBER = $(shell echo $(EXTVERSION) | \
$(PERL) -pe 's/\d\.\d\.(.*)/\1/' | \
$(GREP) "[a-zA-Z]" | \
$(PERL) -pe 's/\d+[a-zA-Z]+(\d+)/\1/'
MICRO_PREV = $(shell if test "$(MICRO_NUMBER)x" != "x"; then expr $(MICRO_NUMBER) - 1; fi)
PREREL_PREV = $(shell if test "$(PREREL_NUMBER)x" != "x"; then expr $(PREREL_NUMBER) - 1; fi)
PREREL_PREFIX = $(shell echo $(EXTVERSION) | \
$(PERL) -pe 's/\d\.\d\.(.*)/\1/' | \
$(GREP) "[a-zA-Z]" | \
$(PERL) -pe 's/(\d+[a-zA-Z]+)\d*/\1/'
DATA_built = \
$(EXTENSION).control \
sql/$(EXTENSION)--$(EXTVERSION).sql \
sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql \
$(NULL)
REGRESS = test-normalize_address test-upgrade
REGRESS_OPTS = --load-extension=fuzzystrmatch --load-extension=postgis --load-extension=$(EXTENSION)
PG_CONFIG = @PG_CONFIG@
SQL_BITS = $(wildcard sql_bits/*.sql)
EXTRA_CLEAN += sql/*.sql ${SQL_BITS}
#test address standardizer if also built
ifeq (@ADDRESS_STANDARDIZER@,address_standardizer)
REGRESS += test-pagc_normalize_address
REGRESS_OPTS += --load-extension=address_standardizer
endif
all: sql/$(EXTENSION)--$(EXTVERSION).sql sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql sql/$(EXTENSION)--ANY--$(EXTVERSION).sql sql/test-normalize_address.sql sql/test-pagc_normalize_address.sql expected/test-normalize_address.out expected/test-pagc_normalize_address.out sql/test-upgrade.sql expected/test-upgrade.out
expected:
mkdir -p $@
sql:
mkdir -p $@
sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql | sql
cp $< $@
expected/test-normalize_address.out: sql_bits/test_tuples_only_unaligned.sql.in ../../extras/tiger_geocoder/regress/normalize_address_regress | expected
cat $^ > $@
expected/test-pagc_normalize_address.out: sql_bits/test_tuples_only_unaligned.sql.in ../../extras/tiger_geocoder/regress/pagc_normalize_address_regress | expected
cat $^ > $@
## adding \t .. to force output to be the same as what get in regular regress in tiger folder
sql/test-normalize_address.sql: sql_bits/test_tuples_only_unaligned.sql.in ../../extras/tiger_geocoder/regress/normalize_address_regress.sql | sql
cat $^ > $@
sql/test-upgrade.sql: | sql
echo 'ALTER EXTENSION ${EXTENSION} UPDATE TO "$(EXTVERSION)next"' > $@
%.control: %.control.in Makefile
cat $< \
| sed -e 's|@EXTVERSION@|$(EXTVERSION)|g' \
> $@
expected/test-upgrade.out: sql/test-upgrade.sql | expected
cp $< $@
sql/test-pagc_normalize_address.sql: sql_bits/test_tuples_only_unaligned.sql.in ../../extras/tiger_geocoder/regress/pagc_normalize_address_regress.sql | sql
cat $^ > $@
sql/$(EXTENSION).sql: sql_bits/tiger_geocoder.sql sql_bits/mark_editable_objects.sql.in sql_bits/tiger_geocoder_comments.sql | sql
cat $^ > $@
sql/$(EXTENSION)--ANY--$(EXTVERSION).sql: ../postgis_extension_helper.sql sql_bits/remove_from_extension.sql.in sql/tiger_geocoder_upgrade_minor.sql sql_bits/mark_editable_objects.sql.in sql_bits/tiger_geocoder_comments.sql | sql
cat $^ > $@
echo "SELECT postgis_extension_drop_if_exists('${EXTENSION}', 'DROP SCHEMA tiger_data');" >> $@
cat ../postgis_extension_helper_uninstall.sql >> $@
sql/$(EXTENSION)--$(EXTVERSION)next--$(EXTVERSION).sql: sql/$(EXTENSION)--$(EXTVERSION)--$(EXTVERSION)next.sql | sql
cp $< $@
#strip BEGIN/COMMIT since these are not allowed in extensions
#strip CREATE SCHEMA since we force extension
# to create schema by setting schema to tiger_geocoder in control
#also remove tiger_data from extension if it is part of it
sql_bits/tiger_geocoder_minor.sql.in: ../../extras/tiger_geocoder/utility/set_search_path.sql \
sql_bits/upgrade_before.sql.in \
../../extras/tiger_geocoder/geocode_settings.sql \
../../extras/tiger_geocoder/tiger_loader_2017.sql \
../../extras/tiger_geocoder/utility/utmzone.sql \
../../extras/tiger_geocoder/utility/cull_null.sql \
../../extras/tiger_geocoder/utility/nullable_levenshtein.sql \
../../extras/tiger_geocoder/utility/levenshtein_ignore_case.sql \
../../extras/tiger_geocoder/normalize/end_soundex.sql \
../../extras/tiger_geocoder/normalize/count_words.sql \
../../extras/tiger_geocoder/normalize/state_extract.sql \
../../extras/tiger_geocoder/normalize/get_last_words.sql \
../../extras/tiger_geocoder/normalize/location_extract_countysub_exact.sql \
../../extras/tiger_geocoder/normalize/location_extract_countysub_fuzzy.sql \
../../extras/tiger_geocoder/normalize/location_extract_place_exact.sql \
../../extras/tiger_geocoder/normalize/location_extract_place_fuzzy.sql \
../../extras/tiger_geocoder/normalize/location_extract.sql \
../../extras/tiger_geocoder/normalize/normalize_address.sql \
../../extras/tiger_geocoder/normalize/pprint_addy.sql \
../../extras/tiger_geocoder/pagc_normalize/pagc_tables.sql \
../../extras/tiger_geocoder/pagc_normalize/pagc_normalize_address.sql \
../../extras/tiger_geocoder/geocode/other_helper_functions.sql \
../../extras/tiger_geocoder/geocode/rate_attributes.sql \
../../extras/tiger_geocoder/geocode/includes_address.sql \
../../extras/tiger_geocoder/geocode/interpolate_from_address.sql \
../../extras/tiger_geocoder/geocode/geocode_address.sql \
../../extras/tiger_geocoder/geocode/geocode_location.sql \
../../extras/tiger_geocoder/geocode/geocode_intersection.sql \
../../extras/tiger_geocoder/geocode/geocode.sql \
../../extras/tiger_geocoder/geocode/reverse_geocode.sql \
../../extras/tiger_geocoder/geocode/census_tracts_functions.sql
mkdir -p sql_bits
cat $^ > $@
#also remove tiger_data from extension if it is part of it so data gets backed up
sql_bits/tiger_geocoder.sql.in: sql_bits/norm_addy_create.sql.in \
../../extras/tiger_geocoder/utility/set_search_path.sql \
../../extras/tiger_geocoder/geocode_settings.sql \
../../extras/tiger_geocoder/tables/lookup_tables_2011.sql \
../../extras/tiger_geocoder/tiger_loader_2017.sql \
../../extras/tiger_geocoder/utility/set_search_path.sql \
../../extras/tiger_geocoder/utility/utmzone.sql \
../../extras/tiger_geocoder/utility/cull_null.sql \
../../extras/tiger_geocoder/utility/nullable_levenshtein.sql \
../../extras/tiger_geocoder/utility/levenshtein_ignore_case.sql \
../../extras/tiger_geocoder/normalize/end_soundex.sql \
../../extras/tiger_geocoder/normalize/count_words.sql \
../../extras/tiger_geocoder/normalize/state_extract.sql \
../../extras/tiger_geocoder/normalize/get_last_words.sql \
../../extras/tiger_geocoder/normalize/location_extract_countysub_exact.sql \
../../extras/tiger_geocoder/normalize/location_extract_countysub_fuzzy.sql \
../../extras/tiger_geocoder/normalize/location_extract_place_exact.sql \
../../extras/tiger_geocoder/normalize/location_extract_place_fuzzy.sql \
../../extras/tiger_geocoder/normalize/location_extract.sql \
../../extras/tiger_geocoder/normalize/normalize_address.sql \
../../extras/tiger_geocoder/normalize/pprint_addy.sql \
../../extras/tiger_geocoder/pagc_normalize/pagc_tables.sql \
../../extras/tiger_geocoder/pagc_normalize/pagc_normalize_address.sql \
../../extras/tiger_geocoder/geocode/other_helper_functions.sql \
../../extras/tiger_geocoder/geocode/rate_attributes.sql \
../../extras/tiger_geocoder/geocode/includes_address.sql \
../../extras/tiger_geocoder/geocode/interpolate_from_address.sql \
../../extras/tiger_geocoder/geocode/geocode_address.sql \
../../extras/tiger_geocoder/geocode/geocode_location.sql \
../../extras/tiger_geocoder/geocode/geocode_intersection.sql \
../../extras/tiger_geocoder/geocode/geocode.sql \
../../extras/tiger_geocoder/geocode/reverse_geocode.sql \
../../extras/tiger_geocoder/geocode/census_tracts_functions.sql \
../../extras/tiger_geocoder/topology/tiger_topology_loader.sql \
../postgis_extension_helper.sql \
sql_bits/add_search_path.sql
mkdir -p sql_bits
cat $^ > $@
echo "SELECT postgis_extension_drop_if_exists('${EXTENSION}', 'DROP SCHEMA tiger_data');" >> $@
cat ../postgis_extension_helper_uninstall.sql >> $@
sql_bits/tiger_geocoder.sql: sql_bits/tiger_geocoder.sql.in
mkdir -p sql_bits
sed -e 's/BEGIN;//g' -e 's/COMMIT;//g' -e '/^CREATE SCHEMA/d;' $< > $@
$(PERL) -pe 's/BEGIN\;//g ; s/COMMIT\;//g' $< > $@
sql_bits/add_search_path.sql: sql_bits/add_search_path.sql.in
mkdir -p sql_bits
cp $< $@
../../doc/tiger_geocoder_comments.sql:
$(MAKE) -C ../../doc comments
sql_bits/tiger_geocoder_comments.sql: ../../doc/tiger_geocoder_comments.sql
mkdir -p sql_bits
cp $< $@
#grep all lines that start with CREATE OR REPLACE FUNCTION, TRIGGER...
#then replace CREATE OR REPLACE .. with ALTER EXTENSION..;
#then remove default values and extra junk
# sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql: ../../tiger_geocoder/tiger_geocoder.sql
# sed -e '/^CREATE \(OR REPLACE\|TYPE\|TABLE\|VIEW\|CAST\)/!d;' \
# -e 's/OR REPLACE//g' \
# -e 's/CREATE\(.*\)/ALTER EXTENSION $(EXTENSION) ADD\1;/' \
# -e 's/DEFAULT [\.0-9a-zA-Z]\+//g' \
# -e 's/\(BEFORE\|WITH FUNCTION\)\(.*\)/;/' \
# -e 's/[ \t]+;/;/' \
# -e 's/(;/;/' \
# -e 's/\\(;/;/' \
# -e 's/;;/;/g' $< > $@
#hardcode for now using
#the extensions/make_unpackaged.sql script form an install
sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql: sql_bits/tiger_geocoder--unpackaged.sql.in | sql
cp $< $@
#upgrade script should have everything but table, schema, type creation/alter
#NOTE: we assume all object definitions end in ;
#first expression deletes all non-removable objects defined on same line
#second deletes all non-removable defined on multiple lines
# the end of the body of object we assume ends in ;
#aggregates are special
#they can be dropped but we need to remove
#them from the extension first
sql/tiger_geocoder_upgrade_minor.sql: sql_bits/tiger_geocoder_minor.sql.in | sql
sed -e '/^\(CREATE\|ALTER\) \(CAST\|TYPE\|TABLE\|SCHEMA\|DOMAIN\|TRIGGER\).*;/d' \
-e '/^\(CREATE\|ALTER\) \(CAST\|TYPE\|TABLE\|SCHEMA\|DOMAIN\|TRIGGER\)/,/\;/d' \
-e 's/BEGIN;//g' -e 's/COMMIT;//g' \
$< > $@
EXTDIR=$(DESTDIR)$(datadir)/$(datamoduledir)
install: install-upgrade-paths
# The "next" lines are a cludge to allow upgrading between different
# revisions of the same version
install-upgrade-paths:
tpl='$(EXTENSION)--ANY--$(EXTVERSION).sql'; \
$(INSTALL_DATA) sql/$${tpl} "$(EXTDIR)/$${tpl}"; \
ln -fs "$${tpl}" $(EXTDIR)/$(EXTENSION)--$(EXTVERSION)--$(EXTVERSION)next.sql; \
ln -fs "$${tpl}" $(EXTDIR)/$(EXTENSION)--$(EXTVERSION)next--$(EXTVERSION).sql; \
for OLD_VERSION in $(UPGRADEABLE_VERSIONS); do \
ln -fs "$${tpl}" $(EXTDIR)/$(EXTENSION)--$$OLD_VERSION--$(EXTVERSION).sql; \
done
uninstall: uninstall-upgrade-paths
INSTALLED_UPGRADE_SCRIPTS = \
$(wildcard $(EXTDIR)/*$(EXTVERSION).sql) \
$(wildcard $(EXTDIR)/*$(EXTVERSION)next.sql) \
$(NULL)
uninstall-upgrade-paths:
rm -f $(INSTALLED_UPGRADE_SCRIPTS)
#only extension files
EXTRA_CLEAN += $(wildcard expected/*--*.out)
distclean: clean
rm Makefile
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
PERL=@PERL@
|