-<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/pg_config-ref.sgml,v 1.21 2005/08/09 22:47:03 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/pg_config-ref.sgml,v 1.22 2005/09/27 17:39:32 tgl Exp $ -->
 
 <refentry id="app-pgconfig">
  <refmeta>
      </listitem>
     </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>
      </listitem>
     </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>
      </listitem>
     </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>
 
 # -*-makefile-*-
-# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.219 2005/08/02 19:02:31 tgl Exp $
+# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.220 2005/09/27 17:39:32 tgl Exp $
 
 #------------------------------------------------------------------------------
 # All PostgreSQL makefiles include this file and use the variables it sets,
 # 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))" ""
 endif
 
 libdir := @libdir@
+
 pkglibdir = $(libdir)
 ifeq "$(findstring pgsql, $(pkglibdir))" ""
 ifeq "$(findstring postgres, $(pkglibdir))" ""
 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
 
 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
+
 
 ##########################################################################
 #
 
  *
  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/pg_config/pg_config.c,v 1.12 2005/08/09 22:47:03 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_config/pg_config.c,v 1.13 2005/09/27 17:39:33 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
        printf("%s\n", path);
 }
 
+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)
 {
        printf("%s\n", path);
 }
 
+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)
 {
        printf("%s\n", path);
 }
 
+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)
 {
 
 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 },
        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"));
 
        echo #define LIBDIR "" >>$@
        echo #define PKGLIBDIR "" >>$@
        echo #define LOCALEDIR "" >>$@
+       echo #define DOCDIR "" >>$@
+       echo #define MANDIR "" >>$@
 
 "$(OUTDIR)" :
     if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
 
        echo \#define LIBDIR "" >>$@
        echo \#define PKGLIBDIR "" >>$@
        echo \#define LOCALEDIR "" >>$@
+       echo \#define DOCDIR "" >>$@
+       echo \#define MANDIR "" >>$@
 
 "$(OUTDIR)" :
     if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
 
        echo #define LIBDIR "" >>$@
        echo #define PKGLIBDIR "" >>$@
        echo #define LOCALEDIR "" >>$@
+       echo #define DOCDIR "" >>$@
+       echo #define MANDIR "" >>$@
 
 "$(OUTDIR)" :
     if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
 
  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/port.h,v 1.82 2005/08/29 19:39:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/port.h,v 1.83 2005/09/27 17:39:34 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
 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);
 
 #              for use only by the backend binaries
 #
 # IDENTIFICATION
-#    $PostgreSQL: pgsql/src/port/Makefile,v 1.28 2005/08/12 19:45:14 momjian Exp $
+#    $PostgreSQL: pgsql/src/port/Makefile,v 1.29 2005/09/27 17:39:35 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
        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
 
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/port/path.c,v 1.58 2005/08/29 19:39:39 tgl Exp $
+ *       $PostgreSQL: pgsql/src/port/path.c,v 1.59 2005/09/27 17:39:35 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
        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