summaryrefslogtreecommitdiff
path: root/ngx_postgres-1.0/config
blob: 4b4caa40a108a87533c5e0942849b376233cf008 (plain)
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <libpq-fe.h>"
ngx_feature_test="(void) PQconndefaults();"

if [ -n "$LIBPQ_INC" -o -n "$LIBPQ_LIB" ]; then
    # specified by LIBPQ_INC and LIBPQ_LIB
    ngx_feature="libpq library in directories specified by LIBPQ_INC ($LIBPQ_INC) and LIBPQ_LIB ($LIBPQ_LIB)"
    ngx_feature_path="$LIBPQ_INC"
    if [ $NGX_RPATH = YES ]; then
        ngx_feature_libs="-R$LIBPQ_LIB -L$LIBPQ_LIB -lpq"
    else
        ngx_feature_libs="-L$LIBPQ_LIB -lpq"
    fi
    . auto/feature
else
    if [ -z "$PG_CONFIG" ]; then
        PG_CONFIG=pg_config
    fi

    if type $PG_CONFIG >/dev/null 2>&1; then
        # based on information from pg_config
        ngx_feature="libpq library (via $PG_CONFIG)"
        ngx_feature_path="`$PG_CONFIG --includedir`"
        if [ $NGX_RPATH = YES ]; then
            ngx_feature_libs="-R`$PG_CONFIG --libdir` -L`$PG_CONFIG --libdir` -lpq"
        else
            ngx_feature_libs="-L`$PG_CONFIG --libdir` -lpq"
        fi
        . auto/feature
    fi

    # auto-discovery
    if [ $ngx_found = no ]; then
        # system-wide
        ngx_feature="libpq library"
        ngx_feature_path=
        ngx_feature_libs="-lpq"
        . auto/feature
    fi

    if [ $ngx_found = no ]; then
        # Debian
        ngx_feature="libpq library in /usr/../postgresql/"
        ngx_feature_path="/usr/include/postgresql"
        . auto/feature
    fi

    if [ $ngx_found = no ]; then
        # FreeBSD
        ngx_feature="libpq library in /usr/local/"
        ngx_feature_path="/usr/local/include"
        if [ $NGX_RPATH = YES ]; then
            ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lpq"
        else
            ngx_feature_libs="-L/usr/local/lib -lpq"
        fi
        . auto/feature
    fi

    if [ $ngx_found = no ]; then
        # OpenBSD
        ngx_feature="libpq library in /usr/local/../postgresql/"
        ngx_feature_path="/usr/local/include/postgresql"
        if [ $NGX_RPATH = YES ]; then
            ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lpq"
        else
            ngx_feature_libs="-L/usr/local/lib -lpq"
        fi
        . auto/feature
    fi

    if [ $ngx_found = no ]; then
        # NetBSD
        ngx_feature="libpq library in /usr/pkg/"
        ngx_feature_path="/usr/pkg/include"
        if [ $NGX_RPATH = YES ]; then
            ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lpq"
        else
            ngx_feature_libs="-L/usr/pkg/lib -lpq"
        fi
        . auto/feature
    fi

    if [ $ngx_found = no ]; then
        # MacPorts
        ngx_feature="libpq library in /opt/local/"
        ngx_feature_path="/opt/local/include"
        if [ $NGX_RPATH = YES ]; then
            ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lpq"
        else
            ngx_feature_libs="-L/opt/local/lib -lpq"
        fi
        . auto/feature
    fi
fi

if [ $ngx_found = no ]; then
   cat << END
 $0: error: ngx_postgres addon was unable to find the libpq library.
END
   exit 1
fi

ngx_version=`grep nginx_version src/core/nginx.h | sed -e 's/^.* \(.*\)$/\1/'`

if [ -z "$ngx_version" ]; then
   cat << END
 $0: error: ngx_postgres addon was unable to detect version of nginx.
END
   exit 1
fi

# work-around for versions of nginx older than nginx-0.9.0
if [ $ngx_version -ge 9000 ]; then
    ngx_feature_name="NGX_POSTGRES_LIBRARY_VERSION"
    ngx_feature_run=value
else
    ngx_feature_name="NGX_POSTGRES_LIBRARY_VERSION_DETECTED"
    ngx_feature_run=no
fi

lib_version=90100
ngx_feature="libpq library version 9.1"
ngx_feature_test="printf(\"%d\", PQlibVersion())"
. auto/feature

if [ $ngx_found = no ]; then
    lib_version=90000
    ngx_feature="libpq library version 9.0"
    ngx_feature_test="(void) PQescapeLiteral(NULL, NULL, 0);
                      printf(\"$lib_version\")"
    . auto/feature
fi

if [ $ngx_found = no ]; then
    lib_version=80400
    ngx_feature="libpq library version 8.4"
    ngx_feature_test="PQinitOpenSSL(0, 0);
                      printf(\"$lib_version\")"
    . auto/feature
fi

if [ $ngx_found = no ]; then
    lib_version=80300
    ngx_feature="libpq library version 8.3"
    ngx_feature_test="(void) PQconnectionNeedsPassword(NULL);
                      printf(\"$lib_version\")"
    . auto/feature
fi

if [ $ngx_found = no ]; then
    lib_version=80200
    ngx_feature="libpq library version 8.2"
    ngx_feature_test="(void) PQsendDescribePortal(NULL, NULL);
                      printf(\"$lib_version\")"
    . auto/feature
fi

if [ $ngx_found = no ]; then
    lib_version=80104
    ngx_feature="libpq library version 8.1.4"
    ngx_feature_test="(void) PQescapeByteaConn(NULL, NULL, 0, 0);
                      (void) PQregisterThreadLock(NULL);
                      printf(\"$lib_version\")"
    . auto/feature
fi

if [ $ngx_found = no ]; then
    lib_version=80100
    ngx_feature="libpq library version 8.1.0"
    ngx_feature_test="(void) PQregisterThreadLock(NULL);
                      printf(\"$lib_version\")"
    . auto/feature
fi

if [ $ngx_found = no ]; then
    lib_version=80008
    ngx_feature="libpq library version 8.0.8"
    ngx_feature_test="(void) PQescapeByteaConn(NULL, NULL, 0, 0);
                      (void) PQcancel(NULL, NULL, 0);
                      printf(\"$lib_version\")"
    . auto/feature
fi

if [ $ngx_found = no ]; then
    lib_version=80000
    ngx_feature="libpq library version 8.0.0"
    ngx_feature_test="(void) PQcancel(NULL, NULL, 0);
                      printf(\"$lib_version\")"
    . auto/feature
fi

if [ $ngx_found = no ]; then
   cat << END
 $0: error: ngx_postgres addon was unable to detect version of the libpq library.
END
   exit 1
fi

# work-around for versions of nginx older than nginx-0.9.0
if [ $ngx_version -lt 9000 ]; then
    have=NGX_POSTGRES_LIBRARY_VERSION value=$lib_version . auto/define
fi

ngx_addon_name=ngx_postgres

HTTP_MODULES="$HTTP_MODULES ngx_postgres_module"

CORE_INCS="$CORE_INCS $ngx_feature_path"
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"

NGX_ADDON_SRCS="$NGX_ADDON_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_ADDON_DEPS="$NGX_ADDON_DEPS $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/ngx_postgres_ddebug.h $ngx_addon_dir/src/resty_dbd_stream.h"

have=NGX_POSTGRES_MODULE . auto/have