Reorder Makefile to default for Extension build
authorCΓ©dric Villemain <cedric@2ndquadrant.fr>
Mon, 12 Aug 2013 14:38:01 +0000 (16:38 +0200)
committerCΓ©dric Villemain <cedric@2ndquadrant.fr>
Mon, 12 Aug 2013 14:38:01 +0000 (16:38 +0200)
So it is easier to remove Extension support later

Makefile

index 857c6b184c6a0c0e485ad561eed5a40a8a6a5b0c..1d6d3cdbd81c7a86415c630b0cb89cd83dabcc60 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,35 +5,40 @@ EXTCOMMENT   = examine and manage the os buffer cache
 MODULES      = $(EXTENSION)
 MODULEDIR    = $(EXTENSION)
 DOCS         = README.rst
+DATA_built   = $(EXTENSION)--$(EXTVERSION).sql $(EXTENSION)--unpackaged--$(EXTVERSION).sql
+REGRESS      = $(EXTENSION).ext
+EXTRA_CLEAN  = $(EXTENSION).control
 
 PG_CONFIG    = pg_config
-BUILD_EXTENSION = $(shell $(PG_CONFIG) --version | grep -qE "8\.|9\.0" && echo no || echo yes)
 
-# Default (no Extension support)
-DATA         = $(EXTENSION).sql uninstall_$(EXTENSION).sql
-REGRESS      = $(EXTENSION)
-pgext_files   := $(DOCS) $(DATA)
+BUILD_EXTENSION = $(shell $(PG_CONFIG) --version | grep -qE "8\.|9\.0" && echo no || echo yes)
 
-ifeq ($(BUILD_EXTENSION),yes)
-DATA        = $(EXTENSION)--unpackaged--$(EXTVERSION).sql $(EXTENSION)--$(EXTVERSION).sql
-REGRESS     = $(EXTENSION).ext
-EXTRA_CLEAN = $(DATA) $(EXTENSION).control
-pgext_files  := $(DOCS)
+ifeq ($(BUILD_EXTENSION),no)
+DATA_built  =
+DATA        = $(EXTENSION).sql uninstall_$(EXTENSION).sql
+REGRESS     = $(EXTENSION)
+EXTRA_CLEAN =
 endif
 
 PGXS := $(shell $(PG_CONFIG) --pgxs)
 include $(PGXS)
 
-# Build some more files for extension support:
+# Build some more files for extension support:
 ifeq ($(BUILD_EXTENSION),yes)
-# this copy the extension.sql to extension--version.sql
-$(EXTENSION)--$(EXTVERSION).sql: $(EXTENSION).sql
-       cp $< $@
+# pgxs is included after variable definition and before targets, so the
+# PostgreSQL default target is used (all:)
 
-# this build the extension--unpackaged--version.sql from uninstall_extension.sql
+# build the extension--unpackaged--version.sql from uninstall_extension.sql
+# this assumes that the extension was installed via sql script instead of
+# CREATE EXTENSION.
+# This won't upgrade from a previous version to the current one.
 $(EXTENSION)--unpackaged--$(EXTVERSION).sql: uninstall_$(EXTENSION).sql
        sed 's/DROP /ALTER EXTENSION $(EXTENSION) ADD /' $< > $@
 
+# this copy the extension.sql to extension--version.sql
+$(EXTENSION)--$(EXTVERSION).sql: $(EXTENSION).sql
+       cp $< $@
+
 # this build extension.control from extension.control.in
 $(EXTENSION).control: $(EXTENSION).control.in
        sed 's/EXTVERSION/$(EXTVERSION)/;s/EXTENSION/$(EXTENSION)/;s/EXTCOMMENT/$(EXTCOMMENT)/' $< > $@
@@ -89,7 +94,6 @@ endif # DOCS
 
 endif
 
-
 dist:
        git archive --prefix=$(EXTENSION)-$(EXTVERSION)/ -o ../$(EXTENSION)_$(EXTVERSION).orig.tar.gz HEAD