Re: Should contrib modules install .h files? - Mailing list pgsql-hackers
From | Andrew Gierth |
---|---|
Subject | Re: Should contrib modules install .h files? |
Date | |
Msg-id | 874lhho071.fsf@news-spur.riddles.org.uk Whole thread Raw |
In response to | Re: Should contrib modules install .h files? (Andrew Gierth <andrew@tao11.riddles.org.uk>) |
Responses |
Re: Should contrib modules install .h files?
|
List | pgsql-hackers |
>>>>> "Andrew" == Andrew Gierth <andrew@tao11.riddles.org.uk> writes: Andrew> OK, I'm working on an updated patch and here it is. This installs to $(includedir_server)/$(MODULEDIR)/$MODULE/file.h (e.g. include/server/extension/hstore/hstore.h for an actual example), and errors if HEADERS_xxx is defined for anything that's not a module listed in MODULES or MODULE_big. -- Andrew (irc:RhodiumToad) diff --git a/contrib/hstore/Makefile b/contrib/hstore/Makefile index ab7fef3979..46d26f8052 100644 --- a/contrib/hstore/Makefile +++ b/contrib/hstore/Makefile @@ -11,6 +11,8 @@ DATA = hstore--1.4.sql hstore--1.4--1.5.sql \ hstore--unpackaged--1.0.sql PGFILEDESC = "hstore - key/value pair data type" +HEADERS = hstore.h + REGRESS = hstore ifdef USE_PGXS diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk index bfae02f90c..3e7817931e 100644 --- a/src/makefiles/pgxs.mk +++ b/src/makefiles/pgxs.mk @@ -38,6 +38,10 @@ # SCRIPTS -- script files (not binaries) to install into $PREFIX/bin # SCRIPTS_built -- script files (not binaries) to install into $PREFIX/bin, # which need to be built first +# HEADERS -- files to install into $(includedir_server)/$MODULEDIR/$MODULE_big +# HEADERS_$(MODULE) -- files to install into +# $(includedir_server)/$MODULEDIR/$MODULE; the value of $MODULE must be +# listed in MODULES or MODULE_big # REGRESS -- list of regression test cases (without suffix) # REGRESS_OPTS -- additional switches to pass to pg_regress # NO_INSTALLCHECK -- don't define an installcheck target, useful e.g. if @@ -94,13 +98,16 @@ endif ifdef MODULEDIR datamoduledir := $(MODULEDIR) docmoduledir := $(MODULEDIR) +incmoduledir := $(MODULEDIR) else ifdef EXTENSION datamoduledir := extension docmoduledir := extension +incmoduledir := extension else datamoduledir := contrib docmoduledir := contrib +incmoduledir := contrib endif endif @@ -108,6 +115,41 @@ ifdef PG_CPPFLAGS override CPPFLAGS := $(PG_CPPFLAGS) $(CPPFLAGS) endif +HEADER_alldirs := $(patsubst HEADERS_%,%,$(filter HEADERS_%, $(.VARIABLES))) + +# HEADERS is an error in the absence of MODULE_big to provide a dir name +ifdef MODULE_big +HEADER_dirs := $(MODULE_big) +ifdef HEADERS +HEADERS_$(MODULE_big) := $(HEADERS) +endif +else +ifdef HEADERS +$(error HEADERS requires MODULE_big to be set) +endif +HEADER_dirs := $(filter $(MODULES),$(HEADER_alldirs)) +endif + +# HEADERS_foo requires that "foo" is in MODULES as a sanity check +ifneq ($(filter-out $(HEADER_dirs),$(HEADER_alldirs)),) +$(error $(patsubst %,HEADERS_%,$(filter-out $(HEADER_dirs),$(HEADER_alldirs))) defined with no module) +endif + +# Functions for generating install/uninstall commands; the blank lines +# before the "endef" are required, don't lose them +# $(call install_headers,dir,headers) +define install_headers +$(MKDIR_P) '$(DESTDIR)$(includedir_server)/$(incmoduledir)/$(1)/' +$(INSTALL_DATA) $(addprefix $(srcdir)/, $(2)) '$(DESTDIR)$(includedir_server)/$(incmoduledir)/$(1)/' + +endef +# $(call uninstall_headers,dir,headers) +define uninstall_headers +rm -f $(addprefix '$(DESTDIR)$(includedir_server)/$(incmoduledir)/$(1)'/, $(notdir $(2))) + +endef + + all: $(PROGRAM) $(DATA_built) $(SCRIPTS_built) $(addsuffix $(DLSUFFIX), $(MODULES)) $(addsuffix .control, $(EXTENSION)) ifeq ($(with_llvm), yes) @@ -154,6 +196,9 @@ endif # SCRIPTS ifdef SCRIPTS_built $(INSTALL_SCRIPT) $(SCRIPTS_built) '$(DESTDIR)$(bindir)/' endif # SCRIPTS_built +ifneq ($(strip $(HEADER_dirs)),) + $(foreach dir,$(HEADER_dirs),$(call install_headers,$(dir),$(HEADERS_$(dir)))) +endif # HEADERS ifdef MODULE_big ifeq ($(with_llvm), yes) $(call install_llvm_module,$(MODULE_big),$(OBJS)) @@ -218,6 +263,9 @@ endif ifdef SCRIPTS_built rm -f $(addprefix '$(DESTDIR)$(bindir)'/, $(SCRIPTS_built)) endif +ifneq ($(strip $(HEADER_dirs)),) + $(foreach dir,$(HEADER_dirs),$(call uninstall_headers,$(dir),$(HEADERS_$(dir)))) +endif # HEADERS ifdef MODULE_big ifeq ($(with_llvm), yes)
pgsql-hackers by date: