Skip to content

Commit 3555c6b

Browse files
committed
Added makefile target to create source distribution
1 parent 5e9d596 commit 3555c6b

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

Makefile

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,26 @@
77
#
88

99
PG_CONFIG ?= pg_config
10+
EXTENSION = pg_repack
1011

11-
# Pull out the version number from pg_config
12+
.PHONY: dist/$(EXTENSION)-$(EXTVERSION).zip
13+
14+
# Pull out PostgreSQL version number from pg_config
1215
VERSION := $(shell $(PG_CONFIG) --version | awk '{print $$2}')
1316
ifeq ("$(VERSION)","")
1417
$(error pg_config not found)
1518
endif
1619

17-
# version as a number, e.g. 9.1.4 -> 901
20+
# PostgreSQL version as a number, e.g. 9.1.4 -> 901
1821
INTVERSION := $(shell echo $$(($$(echo $(VERSION) | sed 's/\([[:digit:]]\{1,\}\)\.\([[:digit:]]\{1,\}\).*/\1*100+\2/'))))
1922

23+
# The version number of the library
24+
EXTVERSION = $(shell grep '"version":' META.json | head -1 \
25+
| sed -e 's/[ ]*"version":[ ]*"\(.*\)",/\1/')
26+
2027
# We support PostgreSQL 8.3 and later.
2128
ifeq ($(shell echo $$(($(INTVERSION) < 803))),1)
22-
$(error pg_repack requires PostgreSQL 8.3 or later. This is $(VERSION))
29+
$(error $(EXTENSION) requires PostgreSQL 8.3 or later. This is $(VERSION))
2330
endif
2431

2532

@@ -36,3 +43,9 @@ check installcheck:
3643
$(MAKE) -C $$dir $@ || CHECKERR=$$?; \
3744
done; \
3845
exit $$CHECKERR
46+
47+
# Prepare the package for PGXN submission
48+
package: $(EXTENSION)-$(EXTVERSION).zip
49+
50+
$(EXTENSION)-$(EXTVERSION).zip:
51+
git archive --format zip --prefix=$(EXTENSION)-$(EXTVERSION)/ --output $@ master

0 commit comments

Comments
 (0)