1999-12-03 23:53:22 -05:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
#
|
2000-06-26 20:32:06 -04:00
|
|
|
# Makefile for src/bin/scripts
|
1999-12-03 23:53:22 -05:00
|
|
|
#
|
2022-01-07 19:04:57 -05:00
|
|
|
# Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
|
2001-02-18 13:34:02 -05:00
|
|
|
# Portions Copyright (c) 1994, Regents of the University of California
|
1999-12-03 23:53:22 -05:00
|
|
|
#
|
2010-09-20 16:08:53 -04:00
|
|
|
# src/bin/scripts/Makefile
|
1999-12-03 23:53:22 -05:00
|
|
|
#
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
2004-10-05 15:30:25 -04:00
|
|
|
PGFILEDESC = "PostgreSQL utility"
|
2010-05-12 07:33:10 -04:00
|
|
|
PGAPPICON=win32
|
|
|
|
|
|
2000-06-26 20:32:06 -04:00
|
|
|
subdir = src/bin/scripts
|
|
|
|
|
top_builddir = ../../..
|
2000-08-31 12:12:35 -04:00
|
|
|
include $(top_builddir)/src/Makefile.global
|
1999-12-03 23:53:22 -05:00
|
|
|
|
2017-03-23 14:16:45 -04:00
|
|
|
PROGRAMS = createdb createuser dropdb dropuser clusterdb vacuumdb reindexdb pg_isready
|
1999-12-03 23:53:22 -05:00
|
|
|
|
2016-03-24 18:27:28 -04:00
|
|
|
override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
|
Prevent accidental linking of system-supplied copies of libpq.so etc.
We were being careless in some places about the order of -L switches in
link command lines, such that -L switches referring to external directories
could come before those referring to directories within the build tree.
This made it possible to accidentally link a system-supplied library, for
example /usr/lib/libpq.so, in place of the one built in the build tree.
Hilarity ensued, the more so the older the system-supplied library is.
To fix, break LDFLAGS into two parts, a sub-variable LDFLAGS_INTERNAL
and the main LDFLAGS variable, both of which are "recursively expanded"
so that they can be incrementally adjusted by different makefiles.
Establish a policy that -L switches for directories in the build tree
must always be added to LDFLAGS_INTERNAL, while -L switches for external
directories must always be added to LDFLAGS. This is sufficient to
ensure a safe search order. For simplicity, we typically also put -l
switches for the respective libraries into those same variables.
(Traditional make usage would have us put -l switches into LIBS, but
cleaning that up is a project for another day, as there's no clear
need for it.)
This turns out to also require separating SHLIB_LINK into two variables,
SHLIB_LINK and SHLIB_LINK_INTERNAL, with a similar rule about which
switches go into which variable. And likewise for PG_LIBS.
Although this change might appear to affect external users of pgxs.mk,
I think it doesn't; they shouldn't have any need to touch the _INTERNAL
variables.
In passing, tweak src/common/Makefile so that the value of CPPFLAGS
recorded in pg_config lacks "-DFRONTEND" and the recorded value of
LDFLAGS lacks "-L../../../src/common". Both of those things are
mistakes, apparently introduced during prior code rearrangements,
as old versions of pg_config don't print them. In general we don't
want anything that's specific to the src/common subdirectory to
appear in those outputs.
This is certainly a bug fix, but in view of the lack of field
complaints, I'm unsure whether it's worth the risk of back-patching.
In any case it seems wise to see what the buildfarm makes of it first.
Discussion: https://postgr.es/m/25214.1522604295@sss.pgh.pa.us
2018-04-03 16:26:05 -04:00
|
|
|
LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport)
|
2003-03-18 17:19:47 -05:00
|
|
|
|
2010-11-12 15:15:16 -05:00
|
|
|
all: $(PROGRAMS)
|
2003-03-18 17:19:47 -05:00
|
|
|
|
2019-01-04 19:12:22 -05:00
|
|
|
createdb: createdb.o common.o $(WIN32RES) | submake-libpq submake-libpgport submake-libpgfeutils
|
|
|
|
|
createuser: createuser.o common.o $(WIN32RES) | submake-libpq submake-libpgport submake-libpgfeutils
|
|
|
|
|
dropdb: dropdb.o common.o $(WIN32RES) | submake-libpq submake-libpgport submake-libpgfeutils
|
|
|
|
|
dropuser: dropuser.o common.o $(WIN32RES) | submake-libpq submake-libpgport submake-libpgfeutils
|
|
|
|
|
clusterdb: clusterdb.o common.o $(WIN32RES) | submake-libpq submake-libpgport submake-libpgfeutils
|
Move some code from src/bin/scripts to src/fe_utils to permit reuse.
The parallel slots infrastructure (which implements client-side
multiplexing of server connections doing similar things, not
threading or multiple processes or anything like that) are moved from
src/bin/scripts/scripts_parallel.c to src/fe_utils/parallel_slot.c.
The functions consumeQueryResult() and processQueryResult() which were
previously part of src/bin/scripts/common.c are now moved into that
file as well, becoming static helper functions. This might need to be
changed in the future, but currently they're not used for anything
else.
Some other functions from src/bin/scripts/common.c are moved to to
src/fe_utils and are split up among several files. connectDatabase(),
connectMaintenanceDatabase(), and disconnectDatabase() are moved to
connect_utils.c. executeQuery(), executeCommand(), and
executeMaintenanceCommand() are move to query_utils.c.
handle_help_version_opts() is moved to option_utils.c.
Mark Dilger, reviewed by me. The larger patch series of which this is
a part has also had review from Peter Geoghegan, Andres Freund, Álvaro
Herrera, Michael Paquier, and Amul Sul, but I don't know whether any
of them have reviewed this bit specifically.
Discussion: http://postgr.es/m/12ED3DA8-25F0-4B68-937D-D907CFBF08E7@enterprisedb.com
Discussion: http://postgr.es/m/5F743835-3399-419C-8324-2D424237E999@enterprisedb.com
Discussion: http://postgr.es/m/70655DF3-33CE-4527-9A4D-DDEB582B6BA0@enterprisedb.com
2021-02-05 13:33:38 -05:00
|
|
|
vacuumdb: vacuumdb.o common.o $(WIN32RES) | submake-libpq submake-libpgport submake-libpgfeutils
|
|
|
|
|
reindexdb: reindexdb.o common.o $(WIN32RES) | submake-libpq submake-libpgport submake-libpgfeutils
|
2019-01-04 19:12:22 -05:00
|
|
|
pg_isready: pg_isready.o common.o $(WIN32RES) | submake-libpq submake-libpgport submake-libpgfeutils
|
2004-05-24 21:00:30 -04:00
|
|
|
|
2000-06-26 20:32:06 -04:00
|
|
|
install: all installdirs
|
2005-12-09 16:19:36 -05:00
|
|
|
$(INSTALL_PROGRAM) createdb$(X) '$(DESTDIR)$(bindir)'/createdb$(X)
|
|
|
|
|
$(INSTALL_PROGRAM) dropdb$(X) '$(DESTDIR)$(bindir)'/dropdb$(X)
|
|
|
|
|
$(INSTALL_PROGRAM) createuser$(X) '$(DESTDIR)$(bindir)'/createuser$(X)
|
|
|
|
|
$(INSTALL_PROGRAM) dropuser$(X) '$(DESTDIR)$(bindir)'/dropuser$(X)
|
|
|
|
|
$(INSTALL_PROGRAM) clusterdb$(X) '$(DESTDIR)$(bindir)'/clusterdb$(X)
|
|
|
|
|
$(INSTALL_PROGRAM) vacuumdb$(X) '$(DESTDIR)$(bindir)'/vacuumdb$(X)
|
|
|
|
|
$(INSTALL_PROGRAM) reindexdb$(X) '$(DESTDIR)$(bindir)'/reindexdb$(X)
|
2013-01-23 10:58:04 -05:00
|
|
|
$(INSTALL_PROGRAM) pg_isready$(X) '$(DESTDIR)$(bindir)'/pg_isready$(X)
|
1999-12-03 23:53:22 -05:00
|
|
|
|
2000-06-26 20:32:06 -04:00
|
|
|
installdirs:
|
2009-08-26 18:24:44 -04:00
|
|
|
$(MKDIR_P) '$(DESTDIR)$(bindir)'
|
1999-12-03 23:53:22 -05:00
|
|
|
|
2000-06-26 20:32:06 -04:00
|
|
|
uninstall:
|
2005-12-09 16:19:36 -05:00
|
|
|
rm -f $(addprefix '$(DESTDIR)$(bindir)'/, $(addsuffix $(X), $(PROGRAMS)))
|
2003-03-18 17:19:47 -05:00
|
|
|
|
2000-06-26 20:32:06 -04:00
|
|
|
clean distclean maintainer-clean:
|
2004-05-26 13:24:07 -04:00
|
|
|
rm -f $(addsuffix $(X), $(PROGRAMS)) $(addsuffix .o, $(PROGRAMS))
|
Move some code from src/bin/scripts to src/fe_utils to permit reuse.
The parallel slots infrastructure (which implements client-side
multiplexing of server connections doing similar things, not
threading or multiple processes or anything like that) are moved from
src/bin/scripts/scripts_parallel.c to src/fe_utils/parallel_slot.c.
The functions consumeQueryResult() and processQueryResult() which were
previously part of src/bin/scripts/common.c are now moved into that
file as well, becoming static helper functions. This might need to be
changed in the future, but currently they're not used for anything
else.
Some other functions from src/bin/scripts/common.c are moved to to
src/fe_utils and are split up among several files. connectDatabase(),
connectMaintenanceDatabase(), and disconnectDatabase() are moved to
connect_utils.c. executeQuery(), executeCommand(), and
executeMaintenanceCommand() are move to query_utils.c.
handle_help_version_opts() is moved to option_utils.c.
Mark Dilger, reviewed by me. The larger patch series of which this is
a part has also had review from Peter Geoghegan, Andres Freund, Álvaro
Herrera, Michael Paquier, and Amul Sul, but I don't know whether any
of them have reviewed this bit specifically.
Discussion: http://postgr.es/m/12ED3DA8-25F0-4B68-937D-D907CFBF08E7@enterprisedb.com
Discussion: http://postgr.es/m/5F743835-3399-419C-8324-2D424237E999@enterprisedb.com
Discussion: http://postgr.es/m/70655DF3-33CE-4527-9A4D-DDEB582B6BA0@enterprisedb.com
2021-02-05 13:33:38 -05:00
|
|
|
rm -f common.o $(WIN32RES)
|
2014-04-25 15:40:35 -04:00
|
|
|
rm -rf tmp_check
|
2014-04-14 21:33:46 -04:00
|
|
|
|
2022-03-17 06:11:21 -04:00
|
|
|
export with_icu
|
|
|
|
|
|
2015-04-29 20:34:22 -04:00
|
|
|
check:
|
2014-04-14 21:33:46 -04:00
|
|
|
$(prove_check)
|
|
|
|
|
|
|
|
|
|
installcheck:
|
|
|
|
|
$(prove_installcheck)
|