summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2005-09-27 17:39:35 +0000
committerTom Lane2005-09-27 17:39:35 +0000
commit1108376d187c090daafa7c788bd42797f972eafa (patch)
tree733b8bc4f0eb12ba798c7cc9314b24c27096bef5
parent692cd1d34319093d5658982fef2eb767cec2ff8e (diff)
Fix problems with PGXS builds against an installation tree that was
relocated after installation. We can't trust the installation paths inserted into Makefile.global by configure, so instead we must get the paths from pg_config. This requires extending pg_config to support all the separately-configurable path names, but that was on TODO anyway.
-rw-r--r--doc/src/sgml/ref/pg_config-ref.sgml61
-rw-r--r--src/Makefile.global.in43
-rw-r--r--src/bin/pg_config/pg_config.c78
-rw-r--r--src/bin/pg_config/win32.mak2
-rw-r--r--src/bin/psql/bcc32.mak2
-rw-r--r--src/bin/psql/win32.mak2
-rw-r--r--src/include/port.h2
-rw-r--r--src/port/Makefile2
-rw-r--r--src/port/path.c18
9 files changed, 197 insertions, 13 deletions
diff --git a/doc/src/sgml/ref/pg_config-ref.sgml b/doc/src/sgml/ref/pg_config-ref.sgml
index 0f973800eb..1c2dd2a474 100644
--- a/doc/src/sgml/ref/pg_config-ref.sgml
+++ b/doc/src/sgml/ref/pg_config-ref.sgml
@@ -54,6 +54,17 @@
</varlistentry>
<varlistentry>
+ <term><option>--docdir</option></>
+ <listitem>
+ <para>
+ Print the location of documentation files. (This will be an empty
+ string if <literal>--without-docdir</> was specified when
+ <productname>PostgreSQL</> was built.)
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>--includedir</option></>
<listitem>
<para>
@@ -63,11 +74,19 @@
</varlistentry>
<varlistentry>
+ <term><option>--pkgincludedir</option></>
+ <listitem>
+ <para>
+ Print the location of other C header files.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>--includedir-server</option></>
<listitem>
<para>
- Print the location of C header files for server
- programming.
+ Print the location of C header files for server programming.
</para>
</listitem>
</varlistentry>
@@ -94,6 +113,44 @@
</varlistentry>
<varlistentry>
+ <term><option>--localedir</option></>
+ <listitem>
+ <para>
+ Print the location of locale support files. (This will be an empty
+ string if locale support was not configured when
+ <productname>PostgreSQL</> was built.)
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--mandir</option></>
+ <listitem>
+ <para>
+ Print the location of manual pages.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--sharedir</option></>
+ <listitem>
+ <para>
+ Print the location of architecture-independent support files.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--sysconfdir</option></>
+ <listitem>
+ <para>
+ Print the location of system-wide configuration files.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>--pgxs</option></>
<listitem>
<para>
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 4c937cdde7..166d91c15c 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -55,19 +55,20 @@ configure_args = @configure_args@
# These are set by the equivalent --xxxdir configure options. We
# append "postgresql" to some of them, if the string does not already
# contain "pgsql" or "postgres", in order to avoid directory clutter.
+#
+# In a PGXS build, we cannot use the values inserted into Makefile.global
+# by configure, since the installation tree may have been relocated.
+# Instead get the path values from pg_config.
+
+ifndef PGXS
+
+# Note that prefix and exec_prefix aren't defined in a PGXS build;
+# makefiles may only use the derived variables such as bindir.
prefix := @prefix@
exec_prefix := @exec_prefix@
bindir := @bindir@
-sbindir := @sbindir@
-
-libexecdir := @libexecdir@
-ifeq "$(findstring pgsql, $(libexecdir))" ""
-ifeq "$(findstring postgres, $(libexecdir))" ""
-override libexecdir := $(libexecdir)/postgresql
-endif
-endif
datadir := @datadir@
ifeq "$(findstring pgsql, $(datadir))" ""
@@ -84,6 +85,7 @@ endif
endif
libdir := @libdir@
+
pkglibdir = $(libdir)
ifeq "$(findstring pgsql, $(pkglibdir))" ""
ifeq "$(findstring postgres, $(pkglibdir))" ""
@@ -92,17 +94,15 @@ endif
endif
includedir := @includedir@
+
pkgincludedir = $(includedir)
ifeq "$(findstring pgsql, $(pkgincludedir))" ""
ifeq "$(findstring postgres, $(pkgincludedir))" ""
override pkgincludedir := $(pkgincludedir)/postgresql
endif
endif
-includedir_server = $(pkgincludedir)/server
-includedir_internal = $(pkgincludedir)/internal
mandir := @mandir@
-sqlmansect_dummy = l
docdir := @docdir@
# docdir can be an empty string to signify --without-docdir
@@ -116,8 +116,29 @@ endif
localedir := @localedir@
+else # PGXS case
+
+bindir := $(shell pg_config --bindir)
+datadir := $(shell pg_config --sharedir)
+sysconfdir := $(shell pg_config --sysconfdir)
+libdir := $(shell pg_config --libdir)
+pkglibdir := $(shell pg_config --pkglibdir)
+includedir := $(shell pg_config --includedir)
+pkgincludedir := $(shell pg_config --pkgincludedir)
+mandir := $(shell pg_config --mandir)
+docdir := $(shell pg_config --docdir)
+localedir := $(shell pg_config --localedir)
+
+endif # PGXS
+
+# These derived path variables aren't separately configurable.
+
+includedir_server = $(pkgincludedir)/server
+includedir_internal = $(pkgincludedir)/internal
pgxsdir = $(pkglibdir)/pgxs
+sqlmansect_dummy = l
+
##########################################################################
#
diff --git a/src/bin/pg_config/pg_config.c b/src/bin/pg_config/pg_config.c
index 72e33ea5b4..29b5b2c419 100644
--- a/src/bin/pg_config/pg_config.c
+++ b/src/bin/pg_config/pg_config.c
@@ -53,6 +53,17 @@ show_bindir(bool all)
}
static void
+show_docdir(bool all)
+{
+ char path[MAXPGPATH];
+
+ if (all)
+ printf("DOCDIR = ");
+ get_doc_path(mypath, path);
+ printf("%s\n", path);
+}
+
+static void
show_includedir(bool all)
{
char path[MAXPGPATH];
@@ -64,6 +75,17 @@ show_includedir(bool all)
}
static void
+show_pkgincludedir(bool all)
+{
+ char path[MAXPGPATH];
+
+ if (all)
+ printf("PKGINCLUDEDIR = ");
+ get_pkginclude_path(mypath, path);
+ printf("%s\n", path);
+}
+
+static void
show_includedir_server(bool all)
{
char path[MAXPGPATH];
@@ -97,6 +119,50 @@ show_pkglibdir(bool all)
}
static void
+show_localedir(bool all)
+{
+ char path[MAXPGPATH];
+
+ if (all)
+ printf("LOCALEDIR = ");
+ get_locale_path(mypath, path);
+ printf("%s\n", path);
+}
+
+static void
+show_mandir(bool all)
+{
+ char path[MAXPGPATH];
+
+ if (all)
+ printf("MANDIR = ");
+ get_man_path(mypath, path);
+ printf("%s\n", path);
+}
+
+static void
+show_sharedir(bool all)
+{
+ char path[MAXPGPATH];
+
+ if (all)
+ printf("SHAREDIR = ");
+ get_share_path(mypath, path);
+ printf("%s\n", path);
+}
+
+static void
+show_sysconfdir(bool all)
+{
+ char path[MAXPGPATH];
+
+ if (all)
+ printf("SYSCONFDIR = ");
+ get_etc_path(mypath, path);
+ printf("%s\n", path);
+}
+
+static void
show_pgxs(bool all)
{
char path[MAXPGPATH];
@@ -234,10 +300,16 @@ typedef struct
static const InfoItem info_items[] = {
{ "--bindir", show_bindir },
+ { "--docdir", show_docdir },
{ "--includedir", show_includedir },
+ { "--pkgincludedir", show_pkgincludedir },
{ "--includedir-server", show_includedir_server },
{ "--libdir", show_libdir },
{ "--pkglibdir", show_pkglibdir },
+ { "--localedir", show_localedir },
+ { "--mandir", show_mandir },
+ { "--sharedir", show_sharedir },
+ { "--sysconfdir", show_sysconfdir },
{ "--pgxs", show_pgxs },
{ "--configure", show_configure },
{ "--cc", show_cc },
@@ -260,11 +332,17 @@ help(void)
printf(_(" %s [ OPTION ... ]\n\n"), progname);
printf(_("Options:\n"));
printf(_(" --bindir show location of user executables\n"));
+ printf(_(" --docdir show location of documentation files\n"));
printf(_(" --includedir show location of C header files of the client\n"
" interfaces\n"));
+ printf(_(" --pkgincludedir show location of other C header files\n"));
printf(_(" --includedir-server show location of C header files for the server\n"));
printf(_(" --libdir show location of object code libraries\n"));
printf(_(" --pkglibdir show location of dynamically loadable modules\n"));
+ printf(_(" --localedir show location of locale support files\n"));
+ printf(_(" --mandir show location of manual pages\n"));
+ printf(_(" --sharedir show location of architecture-independent support files\n"));
+ printf(_(" --sysconfdir show location of system-wide configuration files\n"));
printf(_(" --pgxs show location of extension makefile\n"));
printf(_(" --configure show options given to \"configure\" script when\n"
" PostgreSQL was built\n"));
diff --git a/src/bin/pg_config/win32.mak b/src/bin/pg_config/win32.mak
index 0017e57851..f00f301255 100644
--- a/src/bin/pg_config/win32.mak
+++ b/src/bin/pg_config/win32.mak
@@ -39,6 +39,8 @@ CLEAN :
echo #define LIBDIR "" >>$@
echo #define PKGLIBDIR "" >>$@
echo #define LOCALEDIR "" >>$@
+ echo #define DOCDIR "" >>$@
+ echo #define MANDIR "" >>$@
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
diff --git a/src/bin/psql/bcc32.mak b/src/bin/psql/bcc32.mak
index fd2a1cd267..5a6caeef6e 100644
--- a/src/bin/psql/bcc32.mak
+++ b/src/bin/psql/bcc32.mak
@@ -159,6 +159,8 @@ LINK32_OBJS = $(LINK32_OBJS) "..\..\interfaces\libpq\Release\blibpqdll.lib"
echo \#define LIBDIR "" >>$@
echo \#define PKGLIBDIR "" >>$@
echo \#define LOCALEDIR "" >>$@
+ echo \#define DOCDIR "" >>$@
+ echo \#define MANDIR "" >>$@
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
diff --git a/src/bin/psql/win32.mak b/src/bin/psql/win32.mak
index 8c4a0738ec..62154c026f 100644
--- a/src/bin/psql/win32.mak
+++ b/src/bin/psql/win32.mak
@@ -108,6 +108,8 @@ LINK32_OBJS = $(LINK32_OBJS) "..\..\interfaces\libpq\Release\libpqdll.lib"
echo #define LIBDIR "" >>$@
echo #define PKGLIBDIR "" >>$@
echo #define LOCALEDIR "" >>$@
+ echo #define DOCDIR "" >>$@
+ echo #define MANDIR "" >>$@
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
diff --git a/src/include/port.h b/src/include/port.h
index ec977fb138..68e6ca6ff9 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -43,6 +43,8 @@ extern void get_includeserver_path(const char *my_exec_path, char *ret_path);
extern void get_lib_path(const char *my_exec_path, char *ret_path);
extern void get_pkglib_path(const char *my_exec_path, char *ret_path);
extern void get_locale_path(const char *my_exec_path, char *ret_path);
+extern void get_doc_path(const char *my_exec_path, char *ret_path);
+extern void get_man_path(const char *my_exec_path, char *ret_path);
extern void set_pglocale_pgservice(const char *argv0, const char *app);
extern bool get_home_path(char *ret_path);
extern void get_parent_directory(char *path);
diff --git a/src/port/Makefile b/src/port/Makefile
index d6b35eb434..de76b27b5a 100644
--- a/src/port/Makefile
+++ b/src/port/Makefile
@@ -81,6 +81,8 @@ pg_config_paths.h: $(top_builddir)/src/Makefile.global
echo "#define LIBDIR \"$(libdir)\"" >>$@
echo "#define PKGLIBDIR \"$(pkglibdir)\"" >>$@
echo "#define LOCALEDIR \"$(localedir)\"" >>$@
+ echo "#define DOCDIR \"$(docdir)\"" >>$@
+ echo "#define MANDIR \"$(mandir)\"" >>$@
clean distclean maintainer-clean:
rm -f libpgport.a libpgport_srv.a $(LIBOBJS) $(LIBOBJS_SRV) pg_config_paths.h
diff --git a/src/port/path.c b/src/port/path.c
index 67451e9a82..b2778c4977 100644
--- a/src/port/path.c
+++ b/src/port/path.c
@@ -538,6 +538,24 @@ get_locale_path(const char *my_exec_path, char *ret_path)
make_relative_path(ret_path, LOCALEDIR, PGBINDIR, my_exec_path);
}
+/*
+ * get_doc_path
+ */
+void
+get_doc_path(const char *my_exec_path, char *ret_path)
+{
+ make_relative_path(ret_path, DOCDIR, PGBINDIR, my_exec_path);
+}
+
+/*
+ * get_man_path
+ */
+void
+get_man_path(const char *my_exec_path, char *ret_path)
+{
+ make_relative_path(ret_path, MANDIR, PGBINDIR, my_exec_path);
+}
+
/*
* get_home_path