Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdf16323

Browse files
committed
Provide for contrib and pgxs modules to install include files.
This allows out-of-tree PLs and similar code to get access todefinitions needed to work with extension data types.The following existing modules now install headers: contrib/cube,contrib/hstore, contrib/isn, contrib/ltree, contrib/seg.Discussion:https://postgr.es/m/87y3euomjh.fsf%40news-spur.riddles.org.uk
1 parentf3eb76b commitdf16323

File tree

8 files changed

+130
-2
lines changed

8 files changed

+130
-2
lines changed

‎contrib/cube/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ DATA = cube--1.2.sql cube--1.2--1.3.sql cube--1.3--1.4.sql \
99
cube--unpackaged--1.0.sql
1010
PGFILEDESC = "cube - multidimensional cube data type"
1111

12+
HEADERS = cubedata.h
13+
1214
REGRESS = cube
1315

1416
EXTRA_CLEAN = y.tab.c y.tab.h

‎contrib/hstore/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ DATA = hstore--1.4.sql hstore--1.4--1.5.sql \
1111
hstore--unpackaged--1.0.sql
1212
PGFILEDESC = "hstore - key/value pair data type"
1313

14+
HEADERS = hstore.h
15+
1416
REGRESS = hstore
1517

1618
ifdefUSE_PGXS

‎contrib/isn/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ DATA = isn--1.1.sql isn--1.1--1.2.sql \
77
isn--1.0--1.1.sql isn--unpackaged--1.0.sql
88
PGFILEDESC = "isn - data types for international product numbering standards"
99

10+
# the other .h files are data tables, we don't install those
11+
HEADERS_isn = isn.h
12+
1013
REGRESS = isn
1114

1215
ifdefUSE_PGXS

‎contrib/ltree/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ EXTENSION = ltree
99
DATA = ltree--1.1.sql ltree--1.0--1.1.sql ltree--unpackaged--1.0.sql
1010
PGFILEDESC = "ltree - hierarchical label data type"
1111

12+
HEADERS = ltree.h
13+
1214
REGRESS = ltree
1315

1416
ifdefUSE_PGXS

‎contrib/seg/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ DATA = seg--1.1.sql seg--1.1--1.2.sql seg--1.2--1.3.sql \
88
seg--1.0--1.1.sql seg--unpackaged--1.0.sql
99
PGFILEDESC = "seg - line segment data type"
1010

11+
HEADERS = segdata.h
12+
1113
REGRESS = seg
1214

1315
EXTRA_CLEAN = y.tab.c y.tab.h

‎doc/src/sgml/extend.sgml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,13 +1100,15 @@ include $(PGXS)
11001100
and include the global <acronym>PGXS</acronym> makefile.
11011101
Here is an example that builds an extension module named
11021102
<literal>isbn_issn</literal>, consisting of a shared library containing
1103-
some C code, an extension control file, a SQL script, and a documentation
1104-
text file:
1103+
some C code, an extension control file, a SQL script, an include file
1104+
(only needed if other modules might need to access the extension functions
1105+
without going via SQL), and a documentation text file:
11051106
<programlisting>
11061107
MODULES = isbn_issn
11071108
EXTENSION = isbn_issn
11081109
DATA = isbn_issn--1.0.sql
11091110
DOCS = README.isbn_issn
1111+
HEADERS_isbn_issn = isbn_issn.h
11101112

11111113
PG_CONFIG = pg_config
11121114
PGXS := $(shell $(PG_CONFIG) --pgxs)
@@ -1220,6 +1222,28 @@ include $(PGXS)
12201222
</listitem>
12211223
</varlistentry>
12221224

1225+
<varlistentry>
1226+
<term><varname>HEADERS</varname></term>
1227+
<listitem>
1228+
<para>
1229+
files to install under
1230+
<literal><replaceable>prefix</replaceable>/include/server/$MODULEDIR/$MODULE_big</literal>
1231+
</para>
1232+
</listitem>
1233+
</varlistentry>
1234+
1235+
<varlistentry>
1236+
<term><varname>HEADERS_$MODULE</varname></term>
1237+
<listitem>
1238+
<para>
1239+
files to install under
1240+
<literal><replaceable>prefix</replaceable>/include/server/$MODULEDIR/$MODULE</literal>,
1241+
where <literal>$MODULE</literal> must be a module name used
1242+
in <literal>MODULES</literal> or <literal>MODULE_big</literal>
1243+
</para>
1244+
</listitem>
1245+
</varlistentry>
1246+
12231247
<varlistentry>
12241248
<term><varname>SCRIPTS</varname></term>
12251249
<listitem>

‎src/makefiles/pgxs.mk

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
# SCRIPTS -- script files (not binaries) to install into $PREFIX/bin
3939
# SCRIPTS_built -- script files (not binaries) to install into $PREFIX/bin,
4040
# which need to be built first
41+
# HEADERS -- files to install into $(includedir_server)/$MODULEDIR/$MODULE_big
42+
# HEADERS_$(MODULE) -- files to install into
43+
# $(includedir_server)/$MODULEDIR/$MODULE; the value of $MODULE must be
44+
# listed in MODULES or MODULE_big
4145
# REGRESS -- list of regression test cases (without suffix)
4246
# REGRESS_OPTS -- additional switches to pass to pg_regress
4347
# NO_INSTALLCHECK -- don't define an installcheck target, useful e.g. if
@@ -94,20 +98,60 @@ endif
9498
ifdefMODULEDIR
9599
datamoduledir :=$(MODULEDIR)
96100
docmoduledir :=$(MODULEDIR)
101+
incmoduledir :=$(MODULEDIR)
97102
else
98103
ifdefEXTENSION
99104
datamoduledir := extension
100105
docmoduledir := extension
106+
incmoduledir := extension
101107
else
102108
datamoduledir := contrib
103109
docmoduledir := contrib
110+
incmoduledir := contrib
104111
endif
105112
endif
106113

107114
ifdefPG_CPPFLAGS
108115
overrideCPPFLAGS :=$(PG_CPPFLAGS)$(CPPFLAGS)
109116
endif
110117

118+
HEADER_alldirs :=$(patsubst HEADERS_%,%,$(filter HEADERS_%,$(.VARIABLES)))
119+
120+
# HEADERS is an error in the absence of MODULE_big to provide a dir name
121+
ifdefMODULE_big
122+
ifdefHEADERS
123+
HEADER_dirs :=$(MODULE_big)
124+
HEADERS_$(MODULE_big) =$(HEADERS)
125+
else
126+
HEADER_dirs :=$(filter$(MODULE_big),$(HEADER_alldirs))
127+
endif
128+
else
129+
ifdefHEADERS
130+
$(error HEADERS requires MODULE_big to be set)
131+
endif
132+
HEADER_dirs :=$(filter$(MODULES),$(HEADER_alldirs))
133+
endif
134+
135+
# HEADERS_foo requires that "foo" is in MODULES as a sanity check
136+
ifneq ($(filter-out$(HEADER_dirs),$(HEADER_alldirs)),)
137+
$(error $(patsubst %,HEADERS_%,$(filter-out $(HEADER_dirs),$(HEADER_alldirs))) defined with no module)
138+
endif
139+
140+
# Functions for generating install/uninstall commands; the blank lines
141+
# before the "endef" are required, don't lose them
142+
# $(call install_headers,dir,headers)
143+
defineinstall_headers
144+
$(MKDIR_P) '$(DESTDIR)$(includedir_server)/$(incmoduledir)/$(1)/'
145+
$(INSTALL_DATA)$(addprefix$(srcdir)/,$(2)) '$(DESTDIR)$(includedir_server)/$(incmoduledir)/$(1)/'
146+
147+
endef
148+
# $(call uninstall_headers,dir,headers)
149+
defineuninstall_headers
150+
rm -f$(addprefix '$(DESTDIR)$(includedir_server)/$(incmoduledir)/$(1)'/,$(notdir$(2)))
151+
152+
endef
153+
154+
111155
all:$(PROGRAM)$(DATA_built)$(SCRIPTS_built)$(addsuffix$(DLSUFFIX),$(MODULES))$(addsuffix .control,$(EXTENSION))
112156

113157
ifeq ($(with_llvm), yes)
@@ -154,6 +198,9 @@ endif # SCRIPTS
154198
ifdefSCRIPTS_built
155199
$(INSTALL_SCRIPT) $(SCRIPTS_built) '$(DESTDIR)$(bindir)/'
156200
endif# SCRIPTS_built
201+
ifneq ($(strip$(HEADER_dirs)),)
202+
$(foreach dir,$(HEADER_dirs),$(if $(HEADERS_$(dir)),$(call install_headers,$(dir),$(HEADERS_$(dir)))))
203+
endif# HEADERS
157204
ifdefMODULE_big
158205
ifeq ($(with_llvm), yes)
159206
$(call install_llvm_module,$(MODULE_big),$(OBJS))
@@ -218,6 +265,9 @@ endif
218265
ifdefSCRIPTS_built
219266
rm -f $(addprefix '$(DESTDIR)$(bindir)'/, $(SCRIPTS_built))
220267
endif
268+
ifneq ($(strip$(HEADER_dirs)),)
269+
$(foreach dir,$(HEADER_dirs),$(if $(HEADERS_$(dir)),$(call uninstall_headers,$(dir),$(HEADERS_$(dir)))))
270+
endif# HEADERS
221271

222272
ifdefMODULE_big
223273
ifeq ($(with_llvm), yes)

‎src/tools/msvc/Install.pm

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,49 @@ sub CopySubdirFiles
554554
}
555555
}
556556

557+
{
558+
$flist ='';
559+
if ($mf =~/^HEADERS\s*=\s*(.*)$/m) {$flist .=$1 }
560+
my@modlist = ();
561+
my%fmodlist = ();
562+
while ($mf =~/^HEADERS_([^\s=]+)\s*=\s*(.*)$/mg) {$fmodlist{$1} .=$2 }
563+
564+
if ($mf =~/^MODULE_big\s*=\s*(.*)$/m)
565+
{
566+
push@modlist,$1;
567+
if ($flistne'')
568+
{
569+
$fmodlist{$1} =$flist;
570+
$flist ='';
571+
}
572+
}
573+
elsif ($mf =~/^MODULES\s*=\s*(.*)$/m)
574+
{
575+
push@modlist,split /\s+/,$1;
576+
}
577+
578+
croak"HEADERS requires MODULE_big in$subdir$module"
579+
if$flistne'';
580+
581+
foreachmy$mod (keys%fmodlist)
582+
{
583+
croak"HEADERS_$mod for unknown module in$subdir$module"
584+
unlessgrep {$_eq$mod }@modlist;
585+
$flist = ParseAndCleanRule($fmodlist{$mod},$mf);
586+
EnsureDirectories($target,
587+
"include","include/server",
588+
"include/server/$moduledir",
589+
"include/server/$moduledir/$mod");
590+
foreachmy$f (split /\s+/,$flist)
591+
{
592+
lcopy("$subdir/$module/$f",
593+
"$target/include/server/$moduledir/$mod/" . basename($f))
594+
|| croak("Could not copy file$f in$subdir$module");
595+
print'.';
596+
}
597+
}
598+
}
599+
557600
$flist ='';
558601
if ($mf =~/^DOCS\s*=\s*(.*)$/mg) {$flist .=$1 }
559602
if ($flistne'')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp