Use pg_config in Makefile as well
authorChristoph Berg <christoph.berg@credativ.de>
Wed, 20 Jun 2018 09:58:31 +0000 (11:58 +0200)
committerChristoph Berg <christoph.berg@credativ.de>
Wed, 20 Jun 2018 09:58:31 +0000 (11:58 +0200)
Modify Makefile to use pg_config just like Makefile.contrib does.

In passing, set LIBS to $(libpq_pgport) to avoid linking pg_filedump
against all libs the server links to, we just need pgport.

Makefile
Makefile.contrib
README.pg_filedump

index 719d56709d5c77fba08ffc0c6c4712487748f6dd..66dfede060440a267df72fe1afcdc6d49677ba65 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,35 +3,18 @@
 # note this must match version macros in pg_filedump.h
 FD_VERSION=10.0
 
-# If working with a PG source directory, point PGSQL_INCLUDE_DIR to its
-# src/include subdirectory.  If working with an installed tree, point to
-# the server include subdirectory, eg /usr/local/include/postgresql/server
-PG_CONFIG=pg_config
-PGSQL_CFLAGS=$(shell $(PG_CONFIG) --cflags)
-PGSQL_INCLUDE_DIR=$(shell $(PG_CONFIG) --includedir-server)
-PGSQL_LDFLAGS=$(shell $(PG_CONFIG) --ldflags)
-PGSQL_LIB_DIR=$(shell $(PG_CONFIG) --libdir)
-PGSQL_BIN_DIR=$(shell $(PG_CONFIG) --bindir)
+PROGRAM = pg_filedump
+OBJS = pg_filedump.o decode.o stringinfo.o pg_lzcompress.o
 
-DISTFILES= README.pg_filedump Makefile Makefile.contrib \
-       pg_filedump.h pg_filedump.c decode.h decode.c stringinfo.c pg_lzcompress.c
-
-all: pg_filedump
-
-pg_filedump: pg_filedump.o decode.o stringinfo.o pg_lzcompress.o
-       ${CC} ${PGSQL_LDFLAGS} ${LDFLAGS} -o pg_filedump pg_filedump.o decode.o stringinfo.o pg_lzcompress.o -L${PGSQL_LIB_DIR} -lpgport
-
-pg_filedump.o: pg_filedump.c
-       ${CC} ${PGSQL_CFLAGS} ${CFLAGS} -I${PGSQL_INCLUDE_DIR} pg_filedump.c -c
+PG_CONFIG = pg_config
+PGXS := $(shell $(PG_CONFIG) --pgxs)
+include $(PGXS)
 
-decode.o: decode.c
-       ${CC} ${PGSQL_CFLAGS} ${CFLAGS} -I${PGSQL_INCLUDE_DIR} decode.c -c
+# avoid linking against all libs that the server links against (xml, selinux, ...)
+LIBS = $(libpq_pgport)
 
-stringinfo.o: stringinfo.c
-       ${CC} ${PGSQL_CFLAGS} ${CFLAGS} -I${PGSQL_INCLUDE_DIR} stringinfo.c -c
-
-pg_lzcompress.o: pg_lzcompress.c
-       ${CC} ${PGSQL_CFLAGS} ${CFLAGS} -I${PGSQL_INCLUDE_DIR} pg_lzcompress.c -c
+DISTFILES= README.pg_filedump Makefile Makefile.contrib \
+       pg_filedump.h pg_filedump.c decode.h decode.c stringinfo.c pg_lzcompress.c
 
 dist:
        rm -rf pg_filedump-${FD_VERSION} pg_filedump-${FD_VERSION}.tar.gz
@@ -40,9 +23,3 @@ dist:
        tar cfz pg_filedump-${FD_VERSION}.tar.gz pg_filedump-${FD_VERSION}
        rm -rf pg_filedump-${FD_VERSION}
 
-install: pg_filedump
-       mkdir -p $(DESTDIR)$(PGSQL_BIN_DIR)
-       install pg_filedump $(DESTDIR)$(PGSQL_BIN_DIR)
-
-clean:
-       rm -f *.o pg_filedump
index 8a36100a44efc8d96080460af1a212c56c129ccb..9668b93ebe26a5fd1588ffa5051a1f50bc180ef0 100644 (file)
@@ -13,3 +13,6 @@ else
        include $(top_builddir)/src/Makefile.global
        include $(top_srcdir)/contrib/contrib-global.mk
 endif
+
+# avoid linking against all libs that the server links against (xml, selinux, ...)
+LIBS = $(libpq_pgport)
index b3b24fab2ef43444ea497fb12904a181c50bfda3..37eff73f0595c11cafd00349819c3d5f9aaec1d5 100644 (file)
@@ -40,19 +40,18 @@ PostgreSQL source tree or complete install tree (with include files)
 of the appropriate PostgreSQL major version.
 
 There are two makefiles included in this package.  Makefile is a standalone
-makefile for pg_filedump.  Alter its PGSQL_INCLUDE_DIR variable to point to
-the PostgreSQL include files.  Makefile.contrib can be used if this package
+makefile for pg_filedump.  Makefile.contrib can be used if this package
 was untarred in the contrib directory of a PostgreSQL build tree.
 
   make
-  make install (if using Makefile.contrib)
+  make install
 
 It is also possible to use Makefile.contrib without being in the contrib
 directory:
 
   make -f Makefile.contrib USE_PGXS=1
 
-This method requires that the pg_config program be in your PATH, but should
+Both methods require that the pg_config program be in your PATH, but should
 not require any manual adjustments of the Makefile.