summaryrefslogtreecommitdiff
path: root/postgresql/postgresql-9.1.1.patch
blob: 2ecf3f2b482c88fe68036f8916c5bf88f704ee0b (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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
--- misc/postgresql-9.1.1/configure	2011-09-22 23:57:57.000000000 +0200
+++ misc/build/postgresql-9.1.1/configure	2011-12-13 09:11:00.793031355 +0100
@@ -718,6 +718,7 @@
 with_selinux
 with_openssl
 with_bonjour
+with_mozldap
 with_ldap
 with_pam
 krb_srvtab
@@ -836,6 +837,7 @@
 with_krb_srvnam
 with_pam
 with_ldap
+with_mozldap
 with_bonjour
 with_openssl
 with_selinux
@@ -1533,6 +1535,7 @@
                           [postgres]
   --with-pam              build with PAM support
   --with-ldap             build with LDAP support
+  --with-mozldap          build with Mozilla LDAP support
   --with-bonjour          build with Bonjour support
   --with-openssl          build with OpenSSL support
   --with-selinux          build with SELinux support
@@ -5432,6 +5435,42 @@
 $as_echo "$with_ldap" >&6; }
 
 
+{ $as_echo "$as_me:$LINENO: checking whether to build with Mozilla LDAP support" >&5
+$as_echo_n "checking whether to build with Mozilla LDAP support... " >&6; }
+
+
+
+# Check whether --with-mozldap was given.
+if test "${with_mozldap+set}" = set; then
+  withval=$with_mozldap;
+  case $withval in
+    yes)
+
+cat >>confdefs.h <<\_ACEOF
+#define USE_MOZLDAP 1
+_ACEOF
+
+      ;;
+    no)
+      :
+      ;;
+    *)
+      { { $as_echo "$as_me:$LINENO: error: no argument expected for --with-mozldap option" >&5
+$as_echo "$as_me: error: no argument expected for --with-mozldap option" >&2;}
+   { (exit 1); exit 1; }; }
+      ;;
+  esac
+
+else
+  with_mozldap=no
+
+fi
+
+
+{ $as_echo "$as_me:$LINENO: result: $with_mozldap" >&5
+$as_echo "$with_mozldap" >&6; }
+
+
 
 #
 # Bonjour
@@ -13584,7 +13623,7 @@
 fi
 
 if test "$with_ldap" = yes ; then
-  if test "$PORTNAME" != "win32"; then
+  if test "$with_mozldap" != "yes"; then
 
 for ac_header in ldap.h
 do
@@ -13742,24 +13781,30 @@
 
   else
 
-for ac_header in winldap.h
+for ac_header in mozilla/ldap/ldap.h
 do
 as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
 $as_echo_n "checking for $ac_header... " >&6; }
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
   $as_echo_n "(cached) " >&6
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
 else
-  cat >conftest.$ac_ext <<_ACEOF
+  # Is the header compilable?
+{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
+$as_echo_n "checking $ac_header usability... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 $ac_includes_default
-#include <windows.h>
-
-
 #include <$ac_header>
 _ACEOF
 rm -f conftest.$ac_objext
@@ -13780,20 +13825,101 @@
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  eval "$as_ac_Header=yes"
+  ac_header_compiler=yes
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	eval "$as_ac_Header=no"
+	ac_header_compiler=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
+$as_echo_n "checking $ac_header presence... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## ---------------------------------------- ##
+## Report this to pgsql-bugs@postgresql.org ##
+## ---------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  $as_echo_n "(cached) " >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
 fi
 ac_res=`eval 'as_val=${'$as_ac_Header'}
 		 $as_echo "$as_val"'`
 	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
+
+fi
 as_val=`eval 'as_val=${'$as_ac_Header'}
 		 $as_echo "$as_val"'`
    if test "x$as_val" = x""yes; then
@@ -13802,8 +13928,8 @@
 _ACEOF
 
 else
-  { { $as_echo "$as_me:$LINENO: error: header file <winldap.h> is required for LDAP" >&5
-$as_echo "$as_me: error: header file <winldap.h> is required for LDAP" >&2;}
+  { { $as_echo "$as_me:$LINENO: error: header file <mozilla/ldap/ldap.h> is required for LDAP" >&5
+$as_echo "$as_me: error: header file <mozilla/ldap/ldap.h> is required for LDAP" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
@@ -23348,7 +23474,7 @@
 # We can test for libldap_r only after we know PTHREAD_LIBS
 if test "$with_ldap" = yes ; then
   _LIBS="$LIBS"
-  if test "$PORTNAME" != "win32"; then
+  if test "$with_mozldap" != "yes"; then
 
 { $as_echo "$as_me:$LINENO: checking for ldap_bind in -lldap" >&5
 $as_echo_n "checking for ldap_bind in -lldap... " >&6; }
@@ -23516,13 +23642,13 @@
     fi
   else
 
-{ $as_echo "$as_me:$LINENO: checking for ldap_bind in -lwldap32" >&5
-$as_echo_n "checking for ldap_bind in -lwldap32... " >&6; }
-if test "${ac_cv_lib_wldap32_ldap_bind+set}" = set; then
+{ $as_echo "$as_me:$LINENO: checking for ldap_bind in -lldap50" >&5
+$as_echo_n "checking for ldap_bind in -lldap50... " >&6; }
+if test "${ac_cv_lib_ldap50_ldap_bind+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lwldap32  $LIBS"
+LIBS="-lldap50 $PTHREAD_CFLAGS $PTHREAD_LIBS $EXTRA_LDAP_LIBS $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -23566,12 +23692,12 @@
 	 test "$cross_compiling" = yes ||
 	 $as_test_x conftest$ac_exeext
        }; then
-  ac_cv_lib_wldap32_ldap_bind=yes
+  ac_cv_lib_ldap50_ldap_bind=yes
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	ac_cv_lib_wldap32_ldap_bind=no
+	ac_cv_lib_ldap50_ldap_bind=no
 fi
 
 rm -rf conftest.dSYM
@@ -23579,23 +23705,23 @@
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_wldap32_ldap_bind" >&5
-$as_echo "$ac_cv_lib_wldap32_ldap_bind" >&6; }
-if test "x$ac_cv_lib_wldap32_ldap_bind" = x""yes; then
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_ldap50_ldap_bind" >&5
+$as_echo "$ac_cv_lib_ldap50_ldap_bind" >&6; }
+if test "x$ac_cv_lib_ldap50_ldap_bind" = x""yes; then
   cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBWLDAP32 1
+#define HAVE_LIBLDAP50 1
 _ACEOF
 
-  LIBS="-lwldap32 $LIBS"
+  LIBS="-lldap50 $LIBS"
 
 else
-  { { $as_echo "$as_me:$LINENO: error: library 'wldap32' is required for LDAP" >&5
-$as_echo "$as_me: error: library 'wldap32' is required for LDAP" >&2;}
+  { { $as_echo "$as_me:$LINENO: error: library 'ldap50' is required for Mozilla LDAP" >&5
+$as_echo "$as_me: error: library 'ldap50' is required for Mozilla LDAP" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
-    LDAP_LIBS_FE="-lwldap32"
-    LDAP_LIBS_BE="-lwldap32"
+    LDAP_LIBS_FE="-lldap50"
+    LDAP_LIBS_BE="-lldap50"
   fi
   LIBS="$_LIBS"
 fi
--- misc/postgresql-9.1.1/configure.in	2011-09-22 23:57:57.000000000 +0200
+++ misc/build/postgresql-9.1.1/configure.in	2011-12-13 09:10:29.081068467 +0100
@@ -662,6 +662,13 @@
 AC_MSG_RESULT([$with_ldap])
 AC_SUBST(with_ldap)
 
+AC_MSG_CHECKING([whether to build with Mozilla LDAP support])
+PGAC_ARG_BOOL(with, mozldap, no,
+              [build with Mozilla LDAP support],
+              [AC_DEFINE([USE_MOZLDAP], 1, [Define to 1 to build with Mozilla LDAP support. (--with-mozldap)])])
+AC_MSG_RESULT([$with_mozldap])
+AC_SUBST(with_mozldap)
+
 
 #
 # Bonjour
@@ -1077,15 +1084,12 @@
 fi
 
 if test "$with_ldap" = yes ; then
-  if test "$PORTNAME" != "win32"; then
+  if test "$with_mozldap" != "yes"; then
      AC_CHECK_HEADERS(ldap.h, [],
                       [AC_MSG_ERROR([header file <ldap.h> is required for LDAP])])
   else
-     AC_CHECK_HEADERS(winldap.h, [],
-                      [AC_MSG_ERROR([header file <winldap.h> is required for LDAP])],
-                      [AC_INCLUDES_DEFAULT
-#include <windows.h>
-                      ])
+     AC_CHECK_HEADERS(mozilla/ldap/ldap.h, [],
+                      [AC_MSG_ERROR([header file <mozilla/ldap/ldap.h> is required for LDAP])])
   fi
 fi
 
@@ -1498,7 +1502,7 @@
 # We can test for libldap_r only after we know PTHREAD_LIBS
 if test "$with_ldap" = yes ; then
   _LIBS="$LIBS"
-  if test "$PORTNAME" != "win32"; then
+  if test "$with_mozldap" != "yes"; then
     AC_CHECK_LIB(ldap, ldap_bind, [],
 		 [AC_MSG_ERROR([library 'ldap' is required for LDAP])],
 		 [$EXTRA_LDAP_LIBS])
@@ -1513,9 +1517,11 @@
       LDAP_LIBS_FE="-lldap $EXTRA_LDAP_LIBS"
     fi
   else
-    AC_CHECK_LIB(wldap32, ldap_bind, [], [AC_MSG_ERROR([library 'wldap32' is required for LDAP])])
-    LDAP_LIBS_FE="-lwldap32"
-    LDAP_LIBS_BE="-lwldap32"
+    AC_CHECK_LIB(ldap50, ldap_bind, [],
+		 [AC_MSG_ERROR([library 'ldap50' is required for Mozilla LDAP])],
+		 [$PTHREAD_CFLAGS $PTHREAD_LIBS $EXTRA_LDAP_LIBS])
+    LDAP_LIBS_FE="-lldap50"
+    LDAP_LIBS_BE="-lldap50"
   fi
   LIBS="$_LIBS"
 fi
--- misc/postgresql-9.1.1/src/backend/libpq/auth.c	2011-09-22 23:57:57.000000000 +0200
+++ misc/build/postgresql-9.1.1/src/backend/libpq/auth.c	2011-12-13 09:09:19.687090167 +0100
@@ -93,22 +93,11 @@
  *----------------------------------------------------------------
  */
 #ifdef USE_LDAP
-#ifndef WIN32
-/* We use a deprecated function to keep the codepath the same as win32. */
 #define LDAP_DEPRECATED 1
-#include <ldap.h>
+#ifdef USE_MOZLDAP
+#include <mozilla/ldap/ldap.h>
 #else
-#include <winldap.h>
-
-/* Correct header from the Platform SDK */
-typedef
-ULONG		(*__ldap_start_tls_sA) (
-												IN PLDAP ExternalHandle,
-												OUT PULONG ServerReturnValue,
-												OUT LDAPMessage **result,
-										   IN PLDAPControlA * ServerControls,
-											IN PLDAPControlA * ClientControls
-);
+#include <ldap.h>
 #endif
 
 static int	CheckLDAPAuth(Port *port);
--- misc/postgresql-9.1.1/src/include/pg_config.h.in	2011-09-22 23:57:57.000000000 +0200
+++ misc/build/postgresql-9.1.1/src/include/pg_config.h.in	2011-12-13 09:11:04.000000000 +0100
@@ -293,6 +293,9 @@
 /* Define to 1 if you have the `ldap' library (-lldap). */
 #undef HAVE_LIBLDAP
 
+/* Define to 1 if you have the `ldap50' library (-lldap50). */
+#undef HAVE_LIBLDAP50
+
 /* Define to 1 if you have the `ldap_r' library (-lldap_r). */
 #undef HAVE_LIBLDAP_R
 
@@ -314,9 +317,6 @@
 /* Define to 1 if you have the `ssleay32' library (-lssleay32). */
 #undef HAVE_LIBSSLEAY32
 
-/* Define to 1 if you have the `wldap32' library (-lwldap32). */
-#undef HAVE_LIBWLDAP32
-
 /* Define to 1 if you have the `xml2' library (-lxml2). */
 #undef HAVE_LIBXML2
 
@@ -351,6 +351,9 @@
 /* Define to 1 if the system has the type `MINIDUMP_TYPE'. */
 #undef HAVE_MINIDUMP_TYPE
 
+/* Define to 1 if you have the <mozilla/ldap/ldap.h> header file. */
+#undef HAVE_MOZILLA_LDAP_LDAP_H
+
 /* Define to 1 if you have the <netinet/in.h> header file. */
 #undef HAVE_NETINET_IN_H
 
@@ -659,9 +662,6 @@
 /* Define to 1 if you have the <wctype.h> header file. */
 #undef HAVE_WCTYPE_H
 
-/* Define to 1 if you have the <winldap.h> header file. */
-#undef HAVE_WINLDAP_H
-
 /* Define to the appropriate snprintf format for 64-bit ints. */
 #undef INT64_FORMAT
 
@@ -785,6 +785,9 @@
    (--with-libxslt) */
 #undef USE_LIBXSLT
 
+/* Define to 1 to build with Mozilla LDAP support. (--with-mozldap) */
+#undef USE_MOZLDAP
+
 /* Define to select named POSIX semaphores. */
 #undef USE_NAMED_POSIX_SEMAPHORES
 
--- misc/postgresql-9.1.1/src/interfaces/libpq/Makefile	2011-09-22 23:57:57.000000000 +0200
+++ misc/build/postgresql-9.1.1/src/interfaces/libpq/Makefile	2011-12-13 09:09:19.690090248 +0100
@@ -142,3 +142,6 @@
 
 maintainer-clean: distclean maintainer-clean-lib
 	rm -f libpq-dist.rc
+
+libpq-flags.mk:
+	@printf '%s\n' 'LIBPQ_DEP_LIBS+=$(SHLIB_LINK)' > '$@'
--- misc/postgresql-9.1.1/src/interfaces/libpq/fe-connect.c	2011-09-22 23:57:57.000000000 +0200
+++ misc/build/postgresql-9.1.1/src/interfaces/libpq/fe-connect.c	2011-12-13 09:09:19.692090304 +0100
@@ -60,14 +60,13 @@
 #endif
 
 #ifdef USE_LDAP
-#ifdef WIN32
-#include <winldap.h>
+#ifdef USE_MOZLDAP
+#include <mozilla/ldap/ldap.h>
 #else
-/* OpenLDAP deprecates RFC 1823, but we want standard conformance */
 #define LDAP_DEPRECATED 1
 #include <ldap.h>
-typedef struct timeval LDAP_TIMEVAL;
 #endif
+typedef struct timeval LDAP_TIMEVAL;
 static int ldapServiceLookup(const char *purl, PQconninfoOption *options,
 				  PQExpBuffer errorMessage);
 #endif
--- misc/postgresql-9.1.1/src/interfaces/libpq/win32.mak	2011-09-22 23:57:57.000000000 +0200
+++ misc/build/postgresql-9.1.1/src/interfaces/libpq/win32.mak	2011-12-13 09:09:19.694090358 +0100
@@ -11,18 +11,19 @@
 
 # CPU="i386" or CPU environment of nmake.exe (AMD64 or IA64)
 
-!IF ("$(CPU)" == "")||("$(CPU)" == "i386")
-CPU=i386
+!IF ("$(CPU)" == "")||("$(CPU)" == "I")
+MACHINE=i386
 !MESSAGE Building the Win32 static library...
 !MESSAGE
-!ELSEIF ("$(CPU)" == "IA64")||("$(CPU)" == "AMD64")
+!ELSEIF ("$(CPU)" == "X")
+MACHINE=AMD64
 ADD_DEFINES=/D "WIN64" /Wp64 /GS
 ADD_SECLIB=bufferoverflowU.lib
 !MESSAGE Building the Win64 static library...
 !MESSAGE
 !ELSE
 !MESSAGE Please check a CPU=$(CPU) ?
-!MESSAGE CPU=i386 or AMD64 or IA64
+!MESSAGE CPU=I or X
 !ERROR Make aborted.
 !ENDIF
 
@@ -54,7 +55,7 @@
 !ENDIF
 
 !IF "$(KFW_LIB_PATH)" == ""
-KFW_LIB_PATH=C:\kfw-2.6.5\lib\$(CPU)
+KFW_LIB_PATH=C:\kfw-2.6.5\lib\$(MACHINE)
 !MESSAGE Using default Kerberos Library directory: $(KFW_LIB_PATH)
 !ENDIF
 
@@ -67,18 +68,11 @@
 CPP=cl.exe
 RSC=rc.exe
 
-!IFDEF DEBUG
-OUTDIR=.\Debug
-INTDIR=.\Debug
-CPP_OBJS=.\Debug/
-!ELSE
-OUTDIR=.\Release
-INTDIR=.\Release
-CPP_OBJS=.\Release/
-!ENDIF
-
+OUTDIR=.
+INTDIR=.
+CPP_OBJS=./
 
-ALL : config "$(OUTDIR)\$(OUTFILENAME).lib" "$(OUTDIR)\$(OUTFILENAME).dll"
+ALL : config "$(OUTDIR)\$(OUTFILENAME).lib"
 
 CLEAN :
 	-@erase "$(INTDIR)\getaddrinfo.obj"
@@ -178,7 +172,7 @@
 "$(OUTDIR)" :
     if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
 
-CPP_PROJ=/nologo /W3 /EHsc $(OPT) /I "..\..\include" /I "..\..\include\port\win32" /I "..\..\include\port\win32_msvc" /I "..\..\port" /I. /I "$(SSL_INC)" \
+CPP_PROJ=/nologo /W3 /EHsc $(OPT) /I "..\..\include" /I "..\..\include\port\win32" /I "..\..\include\port\win32_msvc" /I "..\..\port" /I. $(SOLARINC) \
  /D "FRONTEND" $(DEBUGDEF) \
  /D "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\libpq.pch" \
  /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c  \
@@ -189,6 +183,15 @@
 SSL_LIBS=ssleay32.lib libeay32.lib gdi32.lib
 !ENDIF
 
+!IFDEF USE_LDAP
+CPP_PROJ=$(CPP_PROJ) /D USE_LDAP
+LDAP_LIBS=wldap32.lib
+!ENDIF
+
+!IFDEF USE_MOZLDAP
+CPP_PROJ=$(CPP_PROJ) /D USE_MOZLDAP
+!ENDIF
+
 !IFDEF USE_KFW
 CPP_PROJ=$(CPP_PROJ) /D KRB5
 KFW_LIBS=krb5_32.lib comerr32.lib gssapi32.lib
@@ -203,9 +206,9 @@
 RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libpq.res"
 
 LINK32=link.exe
-LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib shfolder.lib wsock32.lib ws2_32.lib secur32.lib $(SSL_LIBS)  $(KFW_LIB) $(ADD_SECLIB) \
+LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib shfolder.lib wsock32.lib ws2_32.lib secur32.lib $(SSL_LIBS) $(LDAP_LIBS) $(KFW_LIB) $(ADD_SECLIB) \
  /nologo /subsystem:windows /dll $(LOPT) /incremental:no \
- /pdb:"$(OUTDIR)\libpqdll.pdb" /machine:$(CPU) \
+ /pdb:"$(OUTDIR)\libpqdll.pdb" /machine:$(MACHINE) \
  /out:"$(OUTDIR)\$(OUTFILENAME).dll"\
  /implib:"$(OUTDIR)\$(OUTFILENAME)dll.lib"  \
  /libpath:"$(SSL_LIB_PATH)" /libpath:"$(KFW_LIB_PATH)" \
@@ -222,7 +225,7 @@
 <<
 
 "$(INTDIR)\libpq.res" : "$(INTDIR)" libpq-dist.rc
-	$(RSC) $(RSC_PROJ) libpq-dist.rc
+	$(RSC) $(SOLARINC) $(RSC_PROJ) libpq-dist.rc
 
 
 "$(OUTDIR)\$(OUTFILENAME).dll" : "$(OUTDIR)" "$(INTDIR)\libpq.res"