1 2MODULE_big = ip4r 3 4ifndef NO_EXTENSION 5EXTENSION= ip4r 6SRC_SQL = ip4r--2.4.sql \ 7 ip4r--2.2--2.4.sql \ 8 ip4r--2.1--2.2.sql \ 9 ip4r--2.0--2.1.sql \ 10 ip4r--unpackaged2.1--2.1.sql \ 11 ip4r--unpackaged2.0--2.0.sql \ 12 ip4r--unpackaged1--2.0.sql 13DATA = $(addprefix scripts/, $(SRC_SQL)) 14REGRESS = ip4r $(REGRESS_$(MAJORVERSION)) 15REGRESS_11 := ip4r-v11 16REGRESS_12 := $(REGRESS_11) 17else 18DATA_built = ip4r.sql 19EXTRA_CLEAN += ip4r.sql.in sql/ip4r-legacy.sql expected/ip4r-legacy.out 20REGRESS = ip4r-legacy 21endif 22 23objdir = src 24 25DOCS = README.ip4r 26OBJS_C = ip4r_module.o ip4r.o ip6r.o ipaddr.o iprange.o raw_io.o 27OBJS = $(addprefix src/, $(OBJS_C)) 28INCS = ipr.h ipr_internal.h 29 30HEADERS = src/ipr.h 31 32# if VPATH is not already set, but the makefile is not in the current 33# dir, then assume a vpath build using the makefile's directory as 34# source. PGXS will set $(srcdir) accordingly. 35ifndef VPATH 36ifneq ($(realpath $(CURDIR)),$(realpath $(dir $(firstword $(MAKEFILE_LIST))))) 37VPATH := $(dir $(firstword $(MAKEFILE_LIST))) 38endif 39endif 40 41ifndef NO_PGXS 42PG_CONFIG ?= pg_config 43PGXS = $(shell $(PG_CONFIG) --pgxs) 44include $(PGXS) 45else 46subdir = contrib/ip4r 47top_builddir = ../.. 48include $(top_builddir)/src/Makefile.global 49include $(top_srcdir)/contrib/contrib-global.mk 50endif 51 52ifeq ($(filter-out 7.% 8.0 8.1 8.2 8.3, $(MAJORVERSION)),) 53$(error unsupported PostgreSQL version) 54endif 55 56$(OBJS): $(addprefix $(srcdir)/src/, $(INCS)) 57 58# for a vpath build, we need src/ to exist in the build dir before 59# building any objects. 60ifdef VPATH 61all: vpath-mkdirs 62.PHONY: vpath-mkdirs 63$(OBJS): | vpath-mkdirs 64 65vpath-mkdirs: 66 $(MKDIR_P) $(objdir) 67endif # VPATH 68 69ifndef EXTENSION 70 71ifeq ($(filter-out 8.4, $(MAJORVERSION)),) 72 73ip4r.sql.in: $(srcdir)/scripts/ip4r--2.4.sql $(srcdir)/tools/legacy.sed 74 sed -f $(srcdir)/tools/legacy.sed $< | sed -e '/^DO /,/^[$$]/d' >$@ 75 76else 77 78ip4r.sql.in: $(srcdir)/scripts/ip4r--2.4.sql $(srcdir)/tools/legacy.sed 79 sed -f $(srcdir)/tools/legacy.sed $< >$@ 80 81endif 82 83# regression test doesn't like the idea of having to build files in 84# the sql/ subdir, and looks for that only in $(srcdir). So disable 85# legacy regression tests in vpath build. 86ifndef VPATH 87sql/ip4r-legacy.sql: sql/ip4r.sql tools/legacy-r.sed 88 sed -f tools/legacy-r.sed $< >$@ 89 90expected/ip4r-legacy.out: expected/ip4r.out tools/legacy-r.sed 91 sed -f tools/legacy-r.sed $< | sed -e '/^\\i /,+1d' >$@ 92 93installcheck: sql/ip4r-legacy.sql expected/ip4r-legacy.out 94else 95installcheck: 96 @echo regression tests are disabled in legacy vpath build 97endif # VPATH 98 99else 100ifeq ($(filter-out 8.% 9.0, $(MAJORVERSION)),) 101$(error extension build not supported in versions before 9.1, use NO_EXTENSION=1) 102endif 103endif 104 105