[patch] build issues on Win32

Поиск
Список
Период
Сортировка
От Dag-Erling Smørgrav
Тема [patch] build issues on Win32
Дата
Msg-id 86sk8845pl.fsf@ds4.des.no
обсуждение исходный текст
Ответы Re: [patch] build issues on Win32
Список pgsql-hackers
I've run across a couple of stumbling blocks when building on Win32
(specifically, XP + MinGW):

 1. PostgreSQL's private versions of inet_aton etc. can conflict with
    similar functions in other libraries (in my case, PostgreSQL's
    inet_aton conflicts with libavformat's).

 2. On Win32, PostgreSQL uses the SSPI authentication interface.  This
    interface is implemented in secur32.dll, which needs to be added to
    the linker command line.  This is apparently only an issue when
    building a static libpq.

 3. src/template/win32 sets LDFLAGS unconditionally, overriding anything
    the user may have specified in the environment or on the command
    line (such as -L/path/to/my/lib/dir).

The attached patch addresses these issues by:

 1. #defining the function names as appropriate

 2. adding -lsecur32 to LIBS in src/Makefile.global.in when PORTNAME is
    win32.

 3. adding ${LDFLAGS} at the front of the LDFLAGS redefinition in
    src/template/win32.

The patch was developed and tested on 8.3.9, because that's what my
customer uses.  I have verified that it applies cleanly (albeit with
offsets) to 8.4.2.

BTW, IWBNI there were a quick and easy way to build and install only
libpq.  I use this sequence of commands (after configure):

$ make -C src/port all
$ make -C src/backend utils/fmgroids.h
$ make -C src/backend ../../src/include/utils/fmgroids.h
$ make -C src/include all install
$ make -C src/interfaces/libpq all install
$ make -C src/bin/pg_config all install

DES
--
Dag-Erling Smørgrav - des@des.no

--- src/include/port.h.orig    2009-11-14 16:39:41.000000000 +0100
+++ src/include/port.h    2010-03-10 13:17:27.000000000 +0100
@@ -337,6 +337,7 @@
  * When necessary, these routines are provided by files in src/port/.
  */
 #ifndef HAVE_CRYPT
+#define crypt pq_crypt
 extern char *crypt(const char *key, const char *setting);
 #endif

@@ -351,44 +352,60 @@
 #endif

 #ifndef HAVE_GETOPT
+#define getopt pq_getopt
 extern int    getopt(int nargc, char *const * nargv, const char *ostr);
 #endif

 #ifndef HAVE_ISINF
+#define isinf pq_isinf
 extern int    isinf(double x);
 #endif

 #ifndef HAVE_RINT
+#define rint pq_rint
 extern double rint(double x);
 #endif

 #ifndef HAVE_INET_ATON
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#define inet_aton pq_inet_aton
 extern int    inet_aton(const char *cp, struct in_addr * addr);
 #endif

 #ifndef HAVE_STRDUP
+#define strdup pq_strdup
 extern char *strdup(const char *str);
 #endif

+#ifndef HAVE_STRLCAT
+#define strlcat pq_strlcat
+#endif
+
 #if !HAVE_DECL_STRLCAT
 extern size_t strlcat(char *dst, const char *src, size_t siz);
 #endif

+#ifndef HAVE_STRLCPY
+#define strlcpy pq_strlcpy
+#endif
+
 #if !HAVE_DECL_STRLCPY
 extern size_t strlcpy(char *dst, const char *src, size_t siz);
 #endif

 #if !defined(HAVE_RANDOM) && !defined(__BORLANDC__)
+#define random pq_random
 extern long random(void);
 #endif

 #ifndef HAVE_UNSETENV
+#define unsetenv pq_unsetenv
 extern void unsetenv(const char *name);
 #endif

 #ifndef HAVE_SRANDOM
+#define srandom pq_srandom
 extern void srandom(unsigned int seed);
 #endif

--- src/Makefile.global.in.orig    2007-11-13 01:13:19.000000000 +0100
+++ src/Makefile.global.in    2010-03-10 13:42:04.000000000 +0100
@@ -435,9 +435,10 @@
 endif

 # to make ws2_32.lib the last library, and always link with shfolder,
-# so SHGetFolderName isn't picked up from shell32.dll
+# so SHGetFolderName isn't picked up from shell32.dll.  Also link
+# with secur32 for SSPI.
 ifeq ($(PORTNAME),win32)
-LIBS += -lws2_32 -lshfolder
+LIBS += -lws2_32 -lshfolder -lsecur32
 endif

 # Not really standard libc functions, used by the backend.
--- src/template/win32.orig    2004-11-08 06:23:26.000000000 +0100
+++ src/template/win32    2010-03-10 13:40:59.000000000 +0100
@@ -1,4 +1,4 @@
 # This is required to link pg_dump because it finds pg_toupper() in
 # libpq and pgport
-LDFLAGS="-Wl,--allow-multiple-definition"
+LDFLAGS="${LDFLAGS} -Wl,--allow-multiple-definition"


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: Dyamic updates of NEW with pl/pgsql
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [patch] build issues on Win32