Index: postgis/Makefile.in
===================================================================
--- postgis/Makefile.in	(revision 5039)
+++ postgis/Makefile.in	(working copy)
@@ -13,7 +13,7 @@
 MODULE_big=postgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@
 
 # Files to be copied to the contrib/ directory
-DATA_built=postgis.sql uninstall_postgis.sql postgis_upgrade_15_minor.sql postgis_upgrade_14_to_15.sql postgis_upgrade_13_to_15.sql
+DATA_built=postgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@.sql uninstall_postgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@.sql postgis_upgrade_15_minor.sql postgis_upgrade_14_to_15.sql postgis_upgrade_13_to_15.sql
 DATA=../spatial_ref_sys.sql
 
 # SQL objects (files requiring C pre-processing)
@@ -89,16 +89,16 @@
 
 
 # Borrow the $libdir substitution from PGXS but customise by adding the version number
-%.sql: %.sql.in
-	sed 's,MODULE_PATHNAME,$$libdir/postgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@,g' $< >$@
+postgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@.sql uninstall_postgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@.sql: $(SQL_OBJS)
+	sed 's,MODULE_PATHNAME,$$libdir/postgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@,g' $(subst -@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@,,$@).in >$@
 
-postgis_upgrade_15_minor.sql: postgis.sql
+postgis_upgrade_15_minor.sql: postgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@.sql
 	$(PERL) ../utils/postgis_proc_upgrade.pl $< 1.5 > $@
 
-postgis_upgrade_14_to_15.sql: postgis.sql
+postgis_upgrade_14_to_15.sql: postgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@.sql 
 	$(PERL) ../utils/postgis_proc_upgrade.pl $< 1.4 > $@
 
-postgis_upgrade_13_to_15.sql: postgis.sql
+postgis_upgrade_13_to_15.sql: postgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@.sql
 	$(PERL) ../utils/postgis_proc_upgrade.pl $< 1.3 > $@
 
 # Generate any .sql.in files from .sql.in.c files by running them through the C pre-processor 
Index: doc/Makefile.in
===================================================================
--- doc/Makefile.in	(revision 5039)
+++ doc/Makefile.in	(working copy)
@@ -64,7 +64,7 @@
 postgis_aggs_mm.xml: ./xsl/postgis_aggs_mm.xml.xsl postgis.xml
 	$(XSLTPROC) ./xsl/postgis_aggs_mm.xml.xsl postgis.xml > $@
 
-postgis_comments.sql: ./xsl/postgis_comments.sql.xsl postgis.xml postgis_aggs_mm.xml
+postgis_comments-$(POSTGIS_MAJOR_VERSION).$(POSTGIS_MINOR_VERSION).sql: ./xsl/postgis_comments.sql.xsl postgis.xml postgis_aggs_mm.xml
 	$(XSLTPROC) ./xsl/postgis_comments.sql.xsl postgis.xml > $@
 
 postgis-out.xml: postgis.xml introduction.xml installation.xml faq.xml using_postgis_dataman.xml  using_postgis_app.xml performance_tips.xml reference.xml reference_management.xml reference_constructor.xml reference_accessor.xml reference_editor.xml reference_output.xml reference_operator.xml reference_measure.xml reference_processing.xml reference_lrs.xml reference_transaction.xml reference_misc.xml reference_exception.xml postgis_aggs_mm.xml reporting.xml release_notes.xml ../Version.config
Index: regress/Makefile.in
===================================================================
--- regress/Makefile.in	(revision 5039)
+++ regress/Makefile.in	(working copy)
@@ -95,7 +95,7 @@
 test check:
 	$(MAKE) -C ../postgis REGRESS=1 DESTDIR=$(REGRESS_INSTALLDIR) install
 	$(MAKE) -C ../loader REGRESS=1 DESTDIR=$(REGRESS_INSTALLDIR) install
-	sed 's,$$libdir,$(REGRESS_INSTALLDIR)/lib,g' ../postgis/postgis.sql > postgis.sql
+	sed 's,$$libdir,$(REGRESS_INSTALLDIR)/lib,g' ../postgis/postgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@.sql > postgis.sql
 	@USE_VERSION=$(POSTGIS_PGSQL_VERSION) ./run_test $(TESTS)
 
 cleanup:
