From 4fc935a5d47d40aac5b1ecf51aa5beaab03e8f76 Mon Sep 17 00:00:00 2001 From: Tom Lane <tgl@sss.pgh.pa.us> Date: Tue, 27 Sep 2005 17:39:35 +0000 Subject: [PATCH] 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. --- doc/src/sgml/ref/pg_config-ref.sgml | 63 +++++++++++++++++++++-- src/Makefile.global.in | 45 +++++++++++----- src/bin/pg_config/pg_config.c | 80 ++++++++++++++++++++++++++++- src/bin/pg_config/win32.mak | 2 + src/bin/psql/bcc32.mak | 2 + src/bin/psql/win32.mak | 2 + src/include/port.h | 4 +- src/port/Makefile | 4 +- src/port/path.c | 20 +++++++- 9 files changed, 203 insertions(+), 19 deletions(-) diff --git a/doc/src/sgml/ref/pg_config-ref.sgml b/doc/src/sgml/ref/pg_config-ref.sgml index daf0496290c..4eef80a3ce0 100644 --- a/doc/src/sgml/ref/pg_config-ref.sgml +++ b/doc/src/sgml/ref/pg_config-ref.sgml @@ -1,4 +1,4 @@ -<!-- $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> @@ -53,6 +53,17 @@ </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> @@ -62,12 +73,20 @@ </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> @@ -93,6 +112,44 @@ </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> diff --git a/src/Makefile.global.in b/src/Makefile.global.in index e59ef2bfb98..20d7a1d2554 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -1,5 +1,5 @@ # -*-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, @@ -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 ae1fce770df..3902f585123 100644 --- a/src/bin/pg_config/pg_config.c +++ b/src/bin/pg_config/pg_config.c @@ -17,7 +17,7 @@ * * 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 $ * *------------------------------------------------------------------------- */ @@ -52,6 +52,17 @@ show_bindir(bool all) 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) { @@ -63,6 +74,17 @@ 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) { @@ -96,6 +118,50 @@ show_pkglibdir(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) { @@ -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 0017e57851e..f00f3012550 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 fd2a1cd2679..5a6caeef6e6 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 8c4a0738ec9..62154c026f3 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 7172ce5fb53..a95ac4a85e7 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -6,7 +6,7 @@ * 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 $ * *------------------------------------------------------------------------- */ @@ -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 2b5b50a914c..e17f324c0d4 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -15,7 +15,7 @@ # 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 $ # #------------------------------------------------------------------------- @@ -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 41a505759e9..bdb6e29adf1 100644 --- a/src/port/path.c +++ b/src/port/path.c @@ -8,7 +8,7 @@ * * * 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 $ * *------------------------------------------------------------------------- */ @@ -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 -- GitLab