EXTENSION = roaringbitmap
# roaringbitmap_upgrade.sql must run last: it drops and reinstalls the extension
# to exercise the 1.2 -> 1.3 upgrade path.
TESTS        = sql/roaringbitmap.sql sql/roaringbitmap64.sql sql/roaringbitmap_upgrade.sql
REGRESS      = $(patsubst sql/%.sql,%,$(TESTS))

MODULE_big = roaringbitmap
OBJS = roaring_buffer_reader.o roaringbitmap.o roaring_group_by_source.o roaring64_buffer_reader.o roaringbitmap64.o roaring64_group_by_source.o

LOCAL_HDRS = roaring.h roaringbitmap.h roaring_buffer_reader.h \
	roaring64_buffer_reader.h roaring_group_by_source.h \
	roaring64_group_by_source.h roaring_group_by_source_common.h

# Extra flags for our sources and for the vendored CRoaring code (roaring.c is
# textually included by roaring_buffer_reader.c). The -Wno-error ones exist for
# CRoaring, not for us: on a big-endian host its view_one_portable32() is only
# referenced from the little-endian branch of
# roaring64_bitmap_portable_deserialize_frozen(), so it is legitimately unused
# there and -Werror would otherwise fail the build. Keep the diagnostic visible
# rather than silencing it, so that dead code in our own files still shows up.
$(OBJS): override CFLAGS += -march=native -std=c11 -Wno-error=maybe-uninitialized \
	-Wno-error=unused-function \
	-Wno-declaration-after-statement -Wno-missing-prototypes -Wno-missing-variable-declarations

PG_CONFIG = pg_config

DATA = $(wildcard *--*.sql)
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

# Force all objects to depend on roaring.c because roaring_buffer_reader.c pulls
# it in textually via #include "roaring.c", which Make cannot detect; without this
# rule a CRoaring upgrade leaves stale objects that link against two versions.
$(OBJS): $(LOCAL_HDRS) roaring.c
