EXTENSION = collection
EXTVERSION = 2.1.3

PGFILEDESC = "pgcollection - collection data type for PostgreSQL"

DOCS = pgcollection.md

MODULE_big = $(EXTENSION)
OBJS = src/collection.o \
		src/collection_io.o \
		src/collection_userfuncs.o \
		src/collection_subs.o \
		src/collection_parse.o \
		src/collection_common.o \
		src/icollection.o \
		src/icollection_io.o \
		src/icollection_userfuncs.o \
		src/icollection_subs.o \
		src/icollection_parse.o

REGRESS = basics subscript iteration srf persistence inout_params mixed_types stress edge_cases array_interop typemod comments
REGRESS_OPTS = --inputdir=test --outputdir=test --load-extension=collection

EXTRA_CLEAN = test/results/ test/regression.diffs test/regression.out \
		pgcollection-$(EXTVERSION).zip include/$(EXTENSION)_config.h

DATA = $(wildcard sql/*.sql)
DATA_built = $(EXTENSION).control

PG_CPPFLAGS += -I./include/

# Suppress fallthrough warnings from uthash macros
PG_CPPFLAGS += -Wno-implicit-fallthrough

# enable a bloom filter to speed up finds
PG_CPPFLAGS += -DHASH_BLOOM=16

# Full RELRO + immediate binding: keeps the GOT and const method tables
# read-only after load.
PG_LDFLAGS += -Wl,-z,relro,-z,now

PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

META.json: META.json.in
	sed 's,EXTVERSION,$(EXTVERSION),g; s,EXTNAME,$(EXTENSION),g' $< > $@;

include/$(EXTENSION)_config.h: include/$(EXTENSION)_config.h.in META.json
	sed 's,EXTVERSION,$(EXTVERSION),g; s,EXTNAME,$(EXTENSION),g;' $< > $@;

$(EXTENSION).control: $(EXTENSION).control.in
	sed 's,EXTVERSION,$(EXTVERSION),g; s,EXTNAME,$(EXTENSION),g' $< > $@;

src/collection.o: include/$(EXTENSION)_config.h

dist:
	git archive --format zip --prefix=pgcollection-$(EXTVERSION)/ -o pgcollection-$(EXTVERSION).zip HEAD
