at master 5.0 kB view raw
1#!@runtimeShell@ 2set -euo pipefail 3 4# This replacement script for the pg_config binary is based on the original pg_config 5# shell script, which was removed from PostgreSQL's codebase in 2004: 6# https://github.com/postgres/postgres/commit/cc07f8cfe73f56fce1ddda4ea25d7b0b6c4f0ae9 7# 8# The main reason for removal was the ability to relocate an existing installation, which 9# is exactly the one feature that we are trying to work around in nixpkgs. 10# Going back to a shell script is much better for cross compiling. 11# 12# This file is a combination of the following two files: 13# https://github.com/postgres/postgres/blob/7510ac6203bc8e3c56eae95466feaeebfc1b4f31/src/bin/pg_config/pg_config.sh 14# https://github.com/postgres/postgres/blob/master/src/bin/pg_config/pg_config.c 15 16source @pg_config.env@ 17 18help=" 19pg_config provides information about the installed version of PostgreSQL. 20 21Usage: 22 pg_config [OPTION]... 23 24Options: 25 --bindir show location of user executables 26 --docdir show location of documentation files 27 --htmldir show location of HTML documentation files 28 --includedir show location of C header files of the client 29 interfaces 30 --pkgincludedir show location of other C header files 31 --includedir-server show location of C header files for the server 32 --libdir show location of object code libraries 33 --pkglibdir show location of dynamically loadable modules 34 --localedir show location of locale support files 35 --mandir show location of manual pages 36 --sharedir show location of architecture-independent support files 37 --sysconfdir show location of system-wide configuration files 38 --pgxs show location of extension makefile 39 --configure show options given to \"configure\" script when 40 PostgreSQL was built 41 --cc show CC value used when PostgreSQL was built 42 --cppflags show CPPFLAGS value used when PostgreSQL was built 43 --cflags show CFLAGS value used when PostgreSQL was built 44 --cflags_sl show CFLAGS_SL value used when PostgreSQL was built 45 --ldflags show LDFLAGS value used when PostgreSQL was built 46 --ldflags_ex show LDFLAGS_EX value used when PostgreSQL was built 47 --ldflags_sl show LDFLAGS_SL value used when PostgreSQL was built 48 --libs show LIBS value used when PostgreSQL was built 49 --version show the PostgreSQL version 50 -?, --help show this help, then exit 51 52With no arguments, all known items are shown. 53 54Report bugs to <${PACKAGE_BUGREPORT}>. 55${PACKAGE_NAME} home page: <${PACKAGE_URL}>" 56 57show=() 58 59for opt; do 60 case "$opt" in 61 --bindir) show+=("$PGBINDIR") ;; 62 --docdir) show+=("$DOCDIR") ;; 63 --htmldir) show+=("$HTMLDIR") ;; 64 --includedir) show+=("$INCLUDEDIR") ;; 65 --pkgincludedir) show+=("$PKGINCLUDEDIR") ;; 66 --includedir-server) show+=("$INCLUDEDIRSERVER") ;; 67 --libdir) show+=("$LIBDIR") ;; 68 --pkglibdir) show+=("$PKGLIBDIR") ;; 69 --localedir) show+=("$LOCALEDIR") ;; 70 --mandir) show+=("$MANDIR") ;; 71 --sharedir) show+=("$PGSHAREDIR") ;; 72 --sysconfdir) show+=("$SYSCONFDIR") ;; 73 --pgxs) show+=("$PGXS") ;; 74 --configure) show+=("$CONFIGURE_ARGS") ;; 75 --cc) show+=("$CC") ;; 76 --cppflags) show+=("$CPPFLAGS") ;; 77 --cflags) show+=("$CFLAGS") ;; 78 --cflags_sl) show+=("$CFLAGS_SL") ;; 79 --ldflags) show+=("$LDFLAGS") ;; 80 --ldflags_ex) show+=("$LDFLAGS_EX") ;; 81 --ldflags_sl) show+=("$LDFLAGS_SL") ;; 82 --libs) show+=("$LIBS") ;; 83 --version) show+=("PostgreSQL $PG_VERSION") ;; 84 --help|-\?) echo "$help" 85 exit 0 ;; 86 *) >&2 echo "pg_config: invalid argument: $opt" 87 >&2 echo "Try \"pg_config --help\" for more information." 88 exit 1 ;; 89 esac 90done 91 92if [ ${#show[@]} -gt 0 ]; then 93 printf '%s\n' "${show[@]}" 94 exit 0 95fi 96 97# no arguments -> print everything 98cat <<EOF 99BINDIR = $PGBINDIR 100DOCDIR = $DOCDIR 101HTMLDIR = $HTMLDIR 102INCLUDEDIR = $INCLUDEDIR 103PKGINCLUDEDIR = $PKGINCLUDEDIR 104INCLUDEDIR-SERVER = $INCLUDEDIRSERVER 105LIBDIR = $LIBDIR 106PKGLIBDIR = $PKGLIBDIR 107LOCALEDIR = $LOCALEDIR 108MANDIR = $MANDIR 109SHAREDIR = $PGSHAREDIR 110SYSCONFDIR = $SYSCONFDIR 111PGXS = $PGXS 112CONFIGURE = $CONFIGURE_ARGS 113CC = $CC 114CPPFLAGS = $CPPFLAGS 115CFLAGS = $CFLAGS 116CFLAGS_SL = $CFLAGS_SL 117LDFLAGS = $LDFLAGS 118LDFLAGS_EX = $LDFLAGS_EX 119LDFLAGS_SL = $LDFLAGS_SL 120LIBS = $LIBS 121VERSION = PostgreSQL $PG_VERSION 122EOF