1996-07-09 08:22:35 +02:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2000-06-27 02:32:06 +02:00
|
|
|
# Makefile for src/bin/initdb
|
1996-07-09 08:22:35 +02:00
|
|
|
#
|
2018-01-03 05:30:12 +01:00
|
|
|
# Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
|
2001-02-18 19:34:02 +01:00
|
|
|
# Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
#
|
2010-09-20 22:08:53 +02:00
|
|
|
# src/bin/initdb/Makefile
|
1996-07-09 08:22:35 +02:00
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
2004-10-05 21:30:25 +02:00
|
|
|
PGFILEDESC = "initdb - initialize a new database cluster"
|
2010-05-12 13:33:10 +02:00
|
|
|
PGAPPICON=win32
|
|
|
|
|
2000-06-27 02:32:06 +02:00
|
|
|
subdir = src/bin/initdb
|
|
|
|
top_builddir = ../../..
|
2000-08-31 18:12:35 +02:00
|
|
|
include $(top_builddir)/src/Makefile.global
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2011-09-09 23:59:11 +02:00
|
|
|
override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) -I$(top_srcdir)/src/timezone $(CPPFLAGS)
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2016-08-20 21:05:25 +02:00
|
|
|
# note: we need libpq only because fe_utils does
|
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 22:26:05 +02:00
|
|
|
LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport)
|
2016-08-20 21:05:25 +02:00
|
|
|
|
2011-09-13 16:58:06 +02:00
|
|
|
# use system timezone data?
|
|
|
|
ifneq (,$(with_system_tzdata))
|
|
|
|
override CPPFLAGS += '-DSYSTEMTZDIR="$(with_system_tzdata)"'
|
|
|
|
endif
|
|
|
|
|
2013-03-17 17:06:42 +01:00
|
|
|
OBJS= initdb.o findtimezone.o localtime.o encnames.o $(WIN32RES)
|
2003-11-10 23:51:16 +01:00
|
|
|
|
2010-11-12 21:15:16 +01:00
|
|
|
all: initdb
|
2003-11-10 23:51:16 +01:00
|
|
|
|
2016-08-22 14:01:12 +02:00
|
|
|
initdb: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
|
2010-07-05 20:54:38 +02:00
|
|
|
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
|
2007-10-13 22:18:42 +02:00
|
|
|
|
2013-03-17 17:06:42 +01:00
|
|
|
# We used to pull in all of libpq to get encnames.c, but that
|
2007-10-13 22:18:42 +02:00
|
|
|
# exposes us to risks of version skew if we link to a shared library.
|
|
|
|
# Do it the hard way, instead, so that we're statically linked.
|
|
|
|
|
|
|
|
encnames.c: % : $(top_srcdir)/src/backend/utils/mb/%
|
|
|
|
rm -f $@ && $(LN_S) $< .
|
|
|
|
|
2011-09-09 23:59:11 +02:00
|
|
|
# Likewise, pull in localtime.c from src/timezones
|
|
|
|
|
|
|
|
localtime.c: % : $(top_srcdir)/src/timezone/%
|
|
|
|
rm -f $@ && $(LN_S) $< .
|
|
|
|
|
2000-06-27 02:32:06 +02:00
|
|
|
install: all installdirs
|
2005-12-09 22:19:36 +01:00
|
|
|
$(INSTALL_PROGRAM) initdb$(X) '$(DESTDIR)$(bindir)/initdb$(X)'
|
1996-11-11 14:41:36 +01:00
|
|
|
|
2000-06-27 02:32:06 +02:00
|
|
|
installdirs:
|
2009-08-27 00:24:44 +02:00
|
|
|
$(MKDIR_P) '$(DESTDIR)$(bindir)'
|
1996-12-10 04:40:23 +01:00
|
|
|
|
2000-06-27 02:32:06 +02:00
|
|
|
uninstall:
|
2005-12-09 22:19:36 +01:00
|
|
|
rm -f '$(DESTDIR)$(bindir)/initdb$(X)'
|
2000-06-27 02:32:06 +02:00
|
|
|
|
2003-11-23 22:42:13 +01:00
|
|
|
clean distclean maintainer-clean:
|
2013-03-17 17:06:42 +01:00
|
|
|
rm -f initdb$(X) $(OBJS) encnames.c localtime.c
|
2014-04-25 21:40:35 +02:00
|
|
|
rm -rf tmp_check
|
2003-12-23 22:56:21 +01:00
|
|
|
|
2004-05-11 23:57:15 +02:00
|
|
|
# ensure that changes in datadir propagate into object file
|
2003-12-23 22:56:21 +01:00
|
|
|
initdb.o: initdb.c $(top_builddir)/src/Makefile.global
|
2014-04-15 03:33:46 +02:00
|
|
|
|
2015-04-30 02:34:22 +02:00
|
|
|
check:
|
2014-04-15 03:33:46 +02:00
|
|
|
$(prove_check)
|
|
|
|
|
|
|
|
installcheck:
|
|
|
|
$(prove_installcheck)
|