Repository navigation
Expand file tree
/
Copy pathconfig
More file actions
167 lines (148 loc) · 6.45 KB
/
Copy pathconfig
File metadata and controls
167 lines (148 loc) · 6.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
ngx_addon_name=ngx_postgres_module
# Finding libpq, in this order:
#
# 1. LIBPQ_INC and LIBPQ_LIB, when the person building says where it is
# 2. pg_config, which is the answer on any system that has a PostgreSQL
# client installed -- including FreeBSD, where the ports tree puts it
# under the package prefix and the guesses below would miss it
# 3. the compiler's own search path
# 4. the places the usual systems put it
#
# Every PQ function this module calls has been in libpq since 8.0, so there
# is no version to detect. Upstream had six probes for 9.1 through 9.6
# here; none of them ever ran, because they were all guarded by
# "if [ $ngx_found = no ]" after the search above had already set it to yes,
# and the version they would have found was written into a variable nothing
# reads. The error message that followed -- "unable to detect version of
# the libpq library" -- could therefore never appear either.
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <libpq-fe.h>"
ngx_feature_test="(void) PQconndefaults();"
ngx_postgres_libs() {
if [ "$NGX_RPATH" = YES ]; then
echo "-R$1 -L$1 -lpq"
else
echo "-L$1 -lpq"
fi
}
if [ -n "$LIBPQ_INC" ] || [ -n "$LIBPQ_LIB" ]; then
ngx_feature="libpq library in LIBPQ_INC ($LIBPQ_INC) and LIBPQ_LIB ($LIBPQ_LIB)"
ngx_feature_path="$LIBPQ_INC"
ngx_feature_libs=$(ngx_postgres_libs "$LIBPQ_LIB")
. auto/feature
else
if [ -z "$PG_CONFIG" ]; then
PG_CONFIG=pg_config
fi
if type "$PG_CONFIG" > /dev/null 2>&1; then
ngx_feature="libpq library (via $PG_CONFIG)"
ngx_feature_path="$($PG_CONFIG --includedir)"
ngx_feature_libs=$(ngx_postgres_libs "$($PG_CONFIG --libdir)")
. auto/feature
fi
if [ $ngx_found = no ]; then
ngx_feature="libpq library"
ngx_feature_path=
ngx_feature_libs="-lpq"
. auto/feature
fi
if [ $ngx_found = no ]; then
# Debian and its relatives
ngx_feature="libpq library in /usr/include/postgresql"
ngx_feature_path="/usr/include/postgresql"
ngx_feature_libs="-lpq"
. auto/feature
fi
if [ $ngx_found = no ]; then
# FreeBSD, when pg_config is not on the path
ngx_feature="libpq library in /usr/local"
ngx_feature_path="/usr/local/include"
ngx_feature_libs=$(ngx_postgres_libs /usr/local/lib)
. auto/feature
fi
if [ $ngx_found = no ]; then
# OpenBSD
ngx_feature="libpq library in /usr/local/include/postgresql"
ngx_feature_path="/usr/local/include/postgresql"
ngx_feature_libs=$(ngx_postgres_libs /usr/local/lib)
. auto/feature
fi
if [ $ngx_found = no ]; then
# NetBSD
ngx_feature="libpq library in /usr/pkg"
ngx_feature_path="/usr/pkg/include"
ngx_feature_libs=$(ngx_postgres_libs /usr/pkg/lib)
. auto/feature
fi
if [ $ngx_found = no ]; then
# MacPorts
ngx_feature="libpq library in /opt/local"
ngx_feature_path="/opt/local/include"
ngx_feature_libs=$(ngx_postgres_libs /opt/local/lib)
. auto/feature
fi
fi
if [ $ngx_found = no ]; then
cat << END
$0: error: ngx_postgres_module requires libpq. Install a PostgreSQL client,
or say where it is:
LIBPQ_INC=/path/include LIBPQ_LIB=/path/lib ./configure --add-module=...
or point it at a pg_config:
PG_CONFIG=/path/bin/pg_config ./configure --add-module=...
END
exit 1
fi
NGX_POSTGRES_SRCS=" \
$ngx_addon_dir/src/ngx_postgres_escape.c \
$ngx_addon_dir/src/ngx_postgres_handler.c \
$ngx_addon_dir/src/ngx_postgres_keepalive.c \
$ngx_addon_dir/src/ngx_postgres_module.c \
$ngx_addon_dir/src/ngx_postgres_output.c \
$ngx_addon_dir/src/ngx_postgres_processor.c \
$ngx_addon_dir/src/ngx_postgres_rewrite.c \
$ngx_addon_dir/src/ngx_postgres_upstream.c \
$ngx_addon_dir/src/ngx_postgres_util.c \
$ngx_addon_dir/src/ngx_postgres_variable.c \
"
NGX_POSTGRES_DEPS=" \
$ngx_addon_dir/src/ngx_postgres_ddebug.h \
$ngx_addon_dir/src/ngx_postgres_escape.h \
$ngx_addon_dir/src/ngx_postgres_handler.h \
$ngx_addon_dir/src/ngx_postgres_keepalive.h \
$ngx_addon_dir/src/ngx_postgres_module.h \
$ngx_addon_dir/src/ngx_postgres_output.h \
$ngx_addon_dir/src/ngx_postgres_processor.h \
$ngx_addon_dir/src/ngx_postgres_rewrite.h \
$ngx_addon_dir/src/ngx_postgres_upstream.h \
$ngx_addon_dir/src/ngx_postgres_util.h \
$ngx_addon_dir/src/ngx_postgres_variable.h \
$ngx_addon_dir/src/resty_dbd_stream.h \
"
if [ -n "$ngx_module_link" ]; then
ngx_module_type=HTTP
ngx_module_name=$ngx_addon_name
ngx_module_srcs="$NGX_POSTGRES_SRCS"
ngx_module_deps="$NGX_POSTGRES_DEPS"
ngx_module_incs="$ngx_feature_path"
# libpq belongs to this module alone, so it goes on this module's line
# and not into CORE_LIBS, where it would be linked into every other
# dynamic module of the same build as well.
ngx_module_libs="$ngx_feature_libs"
. auto/module
# auto/module keeps ngx_module_incs and ngx_module_libs per module only
# for a dynamic build. A module compiled into the binary takes the
# global lists, so they have to be added here.
if [ "$ngx_module_link" != DYNAMIC ]; then
CORE_INCS="$CORE_INCS $ngx_feature_path"
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
fi
else
HTTP_MODULES="$HTTP_MODULES $ngx_addon_name"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $NGX_POSTGRES_SRCS"
NGX_ADDON_DEPS="$NGX_ADDON_DEPS $NGX_POSTGRES_DEPS"
CORE_INCS="$CORE_INCS $ngx_feature_path"
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
fi
# Other modules check for this, ngx_rds_json among them.
have=NGX_POSTGRES_MODULE . auto/have