Fix for Win32 linking

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Fix for Win32 linking
Дата
Msg-id 200405190422.i4J4MAv13051@candle.pha.pa.us
обсуждение исходный текст
Список pgsql-patches
Win32 can't have the same function coming from two library object files,
so we make is_absolute_path() a macro so libpq doesn't use path.o.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/include/port.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port.h,v
retrieving revision 1.32
diff -c -c -r1.32 port.h
*** src/include/port.h    17 May 2004 14:35:34 -0000    1.32
--- src/include/port.h    19 May 2004 04:18:48 -0000
***************
*** 21,27 ****
  bool set_noblock(int sock);

  /* Portable path handling for Unix/Win32 */
- extern bool is_absolute_path(const char *filename);
  extern char *first_path_separator(const char *filename);
  extern char *last_path_separator(const char *filename);
  extern void canonicalize_path(char *path);
--- 21,26 ----
***************
*** 31,36 ****
--- 30,60 ----
  extern void get_include_path(const char *my_exec_path, char *ret_path);
  extern void get_pkginclude_path(const char *my_exec_path, char *ret_path);
  extern void get_pkglib_path(const char *my_exec_path, char *ret_path);
+
+ /*
+  *    is_absolute_path
+  *
+  *     This capability is needed by libpq and initdb.c
+  *    On Win32, you can't reference the same object file that is
+  *    in two different libraries (pgport and libpq), so a macro is best.
+  */
+ #ifndef WIN32
+ #define is_absolute_path(filename) \
+ ( \
+     ((filename)[0] == '/') \
+ )
+ #else
+ #define is_absolute_path(filename) \
+ ( \
+     ((filename)[0] == '/') || \
+     (filename)[0] == '\\' || \
+     (isalpha((filename)[0]) && (filename)[1] == ':' && \
+     ((filename)[2] == '\\' || (filename)[2] == '/')) \
+ )
+ #endif
+
+
+


  /* Portable way to find binaries */
Index: src/interfaces/libpq/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/libpq/Makefile,v
retrieving revision 1.106
diff -c -c -r1.106 Makefile
*** src/interfaces/libpq/Makefile    17 May 2004 14:35:34 -0000    1.106
--- src/interfaces/libpq/Makefile    19 May 2004 04:18:49 -0000
***************
*** 30,36 ****
  OBJS=    fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
      fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \
      dllist.o md5.o ip.o wchar.o encnames.o \
!     $(filter crypt.o getaddrinfo.o inet_aton.o noblock.o pgstrcasecmp.o snprintf.o strerror.o open.o path.o thread.o,
$(LIBOBJS))
  ifeq ($(PORTNAME), win32)
  OBJS+=win32.o
  endif
--- 30,36 ----
  OBJS=    fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
      fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \
      dllist.o md5.o ip.o wchar.o encnames.o \
!     $(filter crypt.o getaddrinfo.o inet_aton.o noblock.o pgstrcasecmp.o snprintf.o strerror.o open.o thread.o,
$(LIBOBJS))
  ifeq ($(PORTNAME), win32)
  OBJS+=win32.o
  endif
***************
*** 59,65 ****
  # For port modules, this only happens if configure decides the module
  # is needed (see filter hack in OBJS, above).

! crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c open.c path.c thread.c: % :
$(top_srcdir)/src/port/%
      rm -f $@ && $(LN_S) $< .

  md5.c ip.c: % : $(backend_src)/libpq/%
--- 59,65 ----
  # For port modules, this only happens if configure decides the module
  # is needed (see filter hack in OBJS, above).

! crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c open.c thread.c: % :
$(top_srcdir)/src/port/%
      rm -f $@ && $(LN_S) $< .

  md5.c ip.c: % : $(backend_src)/libpq/%
***************
*** 85,88 ****
      rm -f $(DESTDIR)$(includedir)/libpq-fe.h $(DESTDIR)$(includedir_internal)/libpq-int.h
$(DESTDIR)$(includedir_internal)/pqexpbuffer.h

  clean distclean maintainer-clean: clean-lib
!     rm -f $(OBJS) crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c open.c path.c
thread.cdllist.c md5.c ip.c encnames.c wchar.c 
--- 85,88 ----
      rm -f $(DESTDIR)$(includedir)/libpq-fe.h $(DESTDIR)$(includedir_internal)/libpq-int.h
$(DESTDIR)$(includedir_internal)/pqexpbuffer.h

  clean distclean maintainer-clean: clean-lib
!     rm -f $(OBJS) crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c open.c thread.c
dllist.cmd5.c ip.c encnames.c wchar.c 
Index: src/port/path.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/port/path.c,v
retrieving revision 1.9
diff -c -c -r1.9 path.c
*** src/port/path.c    18 May 2004 03:36:45 -0000    1.9
--- src/port/path.c    19 May 2004 04:18:50 -0000
***************
*** 35,58 ****


  /*
-  *    is_absolute_path
-  */
- bool
- is_absolute_path(const char *filename)
- {
-     return filename[0] == '/'
- #ifdef WIN32                    /* WIN32 paths can either have forward or
-                                  * backward slashes */
-         || filename[0] == '\\'
-         || (isalpha(filename[0]) && filename[1] == ':'
-             && (filename[2] == '\\' || filename[2] == '/'))
- #endif
-         ;
- }
-
-
-
- /*
   *    first_path_separator
   */
  char *
--- 35,40 ----

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: PITR Phase 1 - partial backport to 7.3.4, 7.3.5
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Bug in CVS pg_dump against 7.0.x