Обсуждение: BUG #3818: Cross compilation problems

Поиск
Список
Период
Сортировка

BUG #3818: Cross compilation problems

От
"Richard Evans"
Дата:
The following bug has been logged online:

Bug reference:      3818
Logged by:          Richard Evans
Email address:      richard.evans@blueallegro.net
PostgreSQL version: 8.3beta
Operating system:   Linux/windows
Description:        Cross compilation problems
Details:

I've been investigating cross-compiling for mingw32 on a linux build system.
 I used the current snapshot since it has a fix for the gettimeofday problem
with new mingw installs.

Mostly it worked, but there were a few problems which I think can all be
fixed in the configure script:

1. The configure script does not check for cross-compile installs of ar,
dlltool, dllwrap and windres. It manages to find the cross compile gcc
(mingw32-gcc in my install), but does not check for mingw32-dlltool, etc.
You work round this by setting AR= DLLTOOL= and DLLWRAP= on the make line
but ideally it should be done in the configure stage.

2. The Makefile in pgevent/bin refers to dllwrap directly, not $(DLLWRAP).

3. Several makefiles use windres directly; there is no $(WINDRES) variable
which can be set.

4. The zic problem in make install - see bug #1311.  Simple solution here is
to have a configure option which allows the use of the build systems own zic
command.

I may try coming up with some patches to configure to check for dlltool, etc
but I haven't edited configure files before.

Once I worked round these problems I was able to cross compile a working
postgres for mingw32 on a linux host.

Re: BUG #3818: Cross compilation problems

От
Magnus Hagander
Дата:
Richard Evans wrote:
> The following bug has been logged online:
>
> Bug reference:      3818
> Logged by:          Richard Evans
> Email address:      richard.evans@blueallegro.net
> PostgreSQL version: 8.3beta
> Operating system:   Linux/windows
> Description:        Cross compilation problems
> Details:
>
> I've been investigating cross-compiling for mingw32 on a linux build system.
>  I used the current snapshot since it has a fix for the gettimeofday problem
> with new mingw installs.

Out of curiosity, why?


> Mostly it worked, but there were a few problems which I think can all be
> fixed in the configure script:
>
> 1. The configure script does not check for cross-compile installs of ar,
> dlltool, dllwrap and windres. It manages to find the cross compile gcc
> (mingw32-gcc in my install), but does not check for mingw32-dlltool, etc.
> You work round this by setting AR= DLLTOOL= and DLLWRAP= on the make line
> but ideally it should be done in the configure stage.
>
> 2. The Makefile in pgevent/bin refers to dllwrap directly, not $(DLLWRAP).

This is a definite oversight, so I've fixed this in HEAD.


> 3. Several makefiles use windres directly; there is no $(WINDRES) variable
> which can be set.
>
> 4. The zic problem in make install - see bug #1311.  Simple solution here is
> to have a configure option which allows the use of the build systems own zic
> command.
>
> I may try coming up with some patches to configure to check for dlltool, etc
> but I haven't edited configure files before.

The rest of this is definitely not 8.3 material. But if you come up with
patches for 8.4, I'm sure we'd be interested ;-) If you have any
specific questions about the autoconf stuff (or any other parts of it),
just post it to -hackers.


> Once I worked round these problems I was able to cross compile a working
> postgres for mingw32 on a linux host.

Cool!

//Magnus

Re: BUG #3818: Cross compilation problems

От
Tom Lane
Дата:
Magnus Hagander <magnus@hagander.net> writes:
> Richard Evans wrote:
>> 4. The zic problem in make install - see bug #1311.  Simple solution here is
>> to have a configure option which allows the use of the build systems own zic
>> command.

> The rest of this is definitely not 8.3 material. But if you come up with
> patches for 8.4, I'm sure we'd be interested ;-)

--with-system-tzdata already solves the zic problem.

            regards, tom lane

Re: BUG #3818: Cross compilation problems

От
Richard Evans
Дата:
If the target system does not have system tzdata, (mingw for example),
you still need to run zic during the cross compile process.  I just
thought that using the build systems own zic was the simplest way to do
this.

In my tests I edited the Makefile in src/timezone and changed ./zic to
just zic and it seemed to work fine.

Richard


> Magnus Hagander <magnus@hagander.net> writes:
>
>> Richard Evans wrote:
>>
>>> 4. The zic problem in make install - see bug #1311.  Simple solution here is
>>> to have a configure option which allows the use of the build systems own zic
>>> command.
>>>
>
>
>> The rest of this is definitely not 8.3 material. But if you come up with
>> patches for 8.4, I'm sure we'd be interested ;-)
>>
>
> --with-system-tzdata already solves the zic problem.
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>
>

Re: BUG #3818: Cross compilation problems

От
Richard Evans
Дата:
Richard Evans wrote:
>> The following bug has been logged online:
>>
>> Bug reference:      3818
>> Logged by:          Richard Evans
>> Email address:      richard.evans@blueallegro.net
>> PostgreSQL version: 8.3beta
>> Operating system:   Linux/windows
>> Description:        Cross compilation problems
>> Details:
>>
>> I've been investigating cross-compiling for mingw32 on a linux build system.
>>  I used the current snapshot since it has a fix for the gettimeofday problem
>> with new mingw installs.
>>
>
> Out of curiosity, why?
>
I want to set up a build system on a single linux host to build for a
number of different targets - linux and win32 at least.
>
>
>> Mostly it worked, but there were a few problems which I think can all be
>> fixed in the configure script:
>>
>> 1. The configure script does not check for cross-compile installs of ar,
>> dlltool, dllwrap and windres. It manages to find the cross compile gcc
>> (mingw32-gcc in my install), but does not check for mingw32-dlltool, etc.
>> You work round this by setting AR= DLLTOOL= and DLLWRAP= on the make line
>> but ideally it should be done in the configure stage.
>>
>> 2. The Makefile in pgevent/bin refers to dllwrap directly, not $(DLLWRAP).
>>
>
> This is a definite oversight, so I've fixed this in HEAD.
>
>
>
>> 3. Several makefiles use windres directly; there is no $(WINDRES) variable
>> which can be set.
>>
>> 4. The zic problem in make install - see bug #1311.  Simple solution here is
>> to have a configure option which allows the use of the build systems own zic
>> command.
>>
>> I may try coming up with some patches to configure to check for dlltool, etc
>> but I haven't edited configure files before.
>>
>
> The rest of this is definitely not 8.3 material. But if you come up with
> patches for 8.4, I'm sure we'd be interested ;-) If you have any
> specific questions about the autoconf stuff (or any other parts of it),
> just post it to -hackers.
>
>
>
>> Once I worked round these problems I was able to cross compile a working
>> postgres for mingw32 on a linux host.
>>
>
> Cool!
>
> //Magnus
>
>

Re: BUG #3818: Cross compilation problems

От
Tom Lane
Дата:
Richard Evans <richard.evans@blueallegro.net> writes:
>> --with-system-tzdata already solves the zic problem.

> If the target system does not have system tzdata, (mingw for example),
> you still need to run zic during the cross compile process.

No, you just need to physically copy a tzdata tree onto the target at
some point.  If you're assuming that the host system has a compatible
zic, then it surely has got some installed tzdata files too.

            regards, tom lane

Re: BUG #3818: Cross compilation problems

От
Bruce Momjian
Дата:
Richard, would you send us patches for the cross compile variables you
needed changed?  Thanks.

---------------------------------------------------------------------------

Richard Evans wrote:
>
> The following bug has been logged online:
>
> Bug reference:      3818
> Logged by:          Richard Evans
> Email address:      richard.evans@blueallegro.net
> PostgreSQL version: 8.3beta
> Operating system:   Linux/windows
> Description:        Cross compilation problems
> Details:
>
> I've been investigating cross-compiling for mingw32 on a linux build system.
>  I used the current snapshot since it has a fix for the gettimeofday problem
> with new mingw installs.
>
> Mostly it worked, but there were a few problems which I think can all be
> fixed in the configure script:
>
> 1. The configure script does not check for cross-compile installs of ar,
> dlltool, dllwrap and windres. It manages to find the cross compile gcc
> (mingw32-gcc in my install), but does not check for mingw32-dlltool, etc.
> You work round this by setting AR= DLLTOOL= and DLLWRAP= on the make line
> but ideally it should be done in the configure stage.
>
> 2. The Makefile in pgevent/bin refers to dllwrap directly, not $(DLLWRAP).
>
> 3. Several makefiles use windres directly; there is no $(WINDRES) variable
> which can be set.
>
> 4. The zic problem in make install - see bug #1311.  Simple solution here is
> to have a configure option which allows the use of the build systems own zic
> command.
>
> I may try coming up with some patches to configure to check for dlltool, etc
> but I haven't edited configure files before.
>
> Once I worked round these problems I was able to cross compile a working
> postgres for mingw32 on a linux host.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>        subscribe-nomail command to majordomo@postgresql.org so that your
>        message can get through to the mailing list cleanly

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://postgres.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Re: BUG #3818: Cross compilation problems

От
Richard Evans
Дата:
Sorry about the delay on this.  Just managed to find some time to look
into it again.

I've made a couple of patches, for 8.3.3 and 8.2.9, which enable cross
compilation for windows (mingw32) from a unix platform.

The changes are in these areas:

1. configure.in detecting the target system versions of dllwrap,
dlltool, windres and ar
2. in various makefiles, checking BUILDOS not PORTNAME when deciding
whether to use 'pwd -W' or just 'pwd'
3. Using the local system's 'zic' command when cross compiling, adding a
--with-zic option to  configure.in in case zic is not in the path (on my
fedora 9 system it is in /usr/sbin/zic).
4. Some path  tweaks in the make files to allow the cross compile build
to occur outside the the source directory.
5. Working round a binutils-2.18 bug in windres when the rc file has /
or \ in the path

If I apply the patches and run autoconf then I can do a full cross
compile and install (to a distribution dir) for 8.3.3 and 8.2.9 using a
configure like:

 PATH=/usr/local/xc/bin:$PATH ../postgresql-8.3.3/configure
--host=mingw32 --without-zlib \
     --prefix=somedir  --libdir=somedir/bin --with-zic=/usr/sbin/zic

I have my cross compilation tool set in /usr/local/xc; I set libdir so
that the dlls end up in the bin dir which makes running on windows
easier ...

I've also tested native builds on a mingw32 system using the patched files.

Hope this helps.

Richard
> Richard, would you send us patches for the cross compile variables you
> needed changed?  Thanks.
>
> ---------------------------------------------------------------------------
>
> Richard Evans wrote:
>
>> The following bug has been logged online:
>>
>> Bug reference:      3818
>> Logged by:          Richard Evans
>> Email address:      richard.evans@blueallegro.net
>> PostgreSQL version: 8.3beta
>> Operating system:   Linux/windows
>> Description:        Cross compilation problems
>> Details:
>>
>> I've been investigating cross-compiling for mingw32 on a linux build system.
>>  I used the current snapshot since it has a fix for the gettimeofday problem
>> with new mingw installs.
>>
>> Mostly it worked, but there were a few problems which I think can all be
>> fixed in the configure script:
>>
>> 1. The configure script does not check for cross-compile installs of ar,
>> dlltool, dllwrap and windres. It manages to find the cross compile gcc
>> (mingw32-gcc in my install), but does not check for mingw32-dlltool, etc.
>> You work round this by setting AR= DLLTOOL= and DLLWRAP= on the make line
>> but ideally it should be done in the configure stage.
>>
>> 2. The Makefile in pgevent/bin refers to dllwrap directly, not $(DLLWRAP).
>>
>> 3. Several makefiles use windres directly; there is no $(WINDRES) variable
>> which can be set.
>>
>> 4. The zic problem in make install - see bug #1311.  Simple solution here is
>> to have a configure option which allows the use of the build systems own zic
>> command.
>>
>> I may try coming up with some patches to configure to check for dlltool, etc
>> but I haven't edited configure files before.
>>
>> Once I worked round these problems I was able to cross compile a working
>> postgres for mingw32 on a linux host.
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 1: if posting/reading through Usenet, please send an appropriate
>>        subscribe-nomail command to majordomo@postgresql.org so that your
>>        message can get through to the mailing list cleanly
>>
>
>
Only in postgresql-8.2.9x: autom4te.cache
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.2.9/configure.in postgresql-8.2.9x/configure.in
*** postgresql-8.2.9/configure.in    2008-06-09 01:34:32.000000000 +0100
--- postgresql-8.2.9x/configure.in    2008-08-09 20:31:29.000000000 +0100
***************
*** 599,604 ****
--- 599,633 ----
  AC_PATH_PROG(TAR, tar)
  PGAC_CHECK_STRIP

+ #
+ # Additional tools for win32
+ #
+ if test "$PORTNAME" = "win32"; then
+   AC_CHECK_TOOL(DLLWRAP, dllwrap, :)
+   AC_CHECK_TOOL(DLLTOOL, dlltool, :)
+   AC_CHECK_TOOL(WINDRES, windres, :)
+ fi
+
+ AC_CHECK_TOOL(AR, ar, :)
+
+ #
+ # zic if cross-compiling
+ #
+ if test "$build_os" != "$host_os"; then
+   PGAC_ARG_REQ(with, zic, [  --with-zic=path         set location of zic tool],
+              [ZIC=$withval],
+              [ZIC=:])
+
+   if test "$ZIC" = ":"; then
+     AC_PATH_TOOL(ZIC, zic, :)
+   fi
+
+   if test "$ZIC" = ":"; then
+     AC_MSG_ERROR([zic is required for cross-compilation.
+ Use --with-zic to set the location.])
+   fi
+ fi
+
  if test -z "$YACC"; then
    AC_CHECK_PROGS(YACC, ['bison -y'])

diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.2.9/src/bin/pgevent/Makefile
postgresql-8.2.9x/src/bin/pgevent/Makefile
*** postgresql-8.2.9/src/bin/pgevent/Makefile    2006-07-15 04:33:14.000000000 +0100
--- postgresql-8.2.9x/src/bin/pgevent/Makefile    2008-08-09 19:50:50.000000000 +0100
***************
*** 21,31 ****

  install: all install-lib

! pgevent.dll: $(OBJS) pgevent.def
!     dllwrap --def pgevent.def -o $(NAME) $(OBJS)

! pgmsgevent.o: pgmsgevent.rc win32ver.rc
!     windres pgmsgevent.rc -o pgmsgevent.o --include-dir=$(top_builddir)/src/include

  all-lib: $(NAME)

--- 21,36 ----

  install: all install-lib

! pgevent.dll: $(OBJS) $(srcdir)/pgevent.def
!     $(DLLWRAP) --def $(srcdir)/pgevent.def -o $(NAME) $(OBJS)

! # windres from binutils 2.18 can segfault if the input file name contains / or \.  For safety,
! # copy to the local directory.
!
! pgmsgevent.o: $(srcdir)/pgmsgevent.rc win32ver.rc
!     cp $(srcdir)/pgmsgevent.rc localpgmsgevent.rc
!     $(WINDRES) localpgmsgevent.rc -o pgmsgevent.o --include-dir=$(top_srcdir)/src/include
--include-dir=$(top_builddir)/src/include--include-dir=$(srcdir) 
!     rm -f localpgmsgevent.rc

  all-lib: $(NAME)

diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.2.9/src/interfaces/ecpg/Makefile
postgresql-8.2.9x/src/interfaces/ecpg/Makefile
*** postgresql-8.2.9/src/interfaces/ecpg/Makefile    2006-08-19 14:42:40.000000000 +0100
--- postgresql-8.2.9x/src/interfaces/ecpg/Makefile    2008-08-09 19:49:47.000000000 +0100
***************
*** 8,14 ****
      $(MAKE) -C ecpglib $@
      $(MAKE) -C compatlib $@
      $(MAKE) -C preproc $@
-     $(MAKE) -C test $@

  clean distclean maintainer-clean:
      -$(MAKE) -C include $@
--- 8,13 ----
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.2.9/src/interfaces/ecpg/test/Makefile
postgresql-8.2.9x/src/interfaces/ecpg/test/Makefile
*** postgresql-8.2.9/src/interfaces/ecpg/test/Makefile    2006-09-08 14:32:26.000000000 +0100
--- postgresql-8.2.9x/src/interfaces/ecpg/test/Makefile    2008-08-09 19:43:46.000000000 +0100
***************
*** 17,23 ****
  NOLOCALE += --no-locale
  endif

! ifneq ($(PORTNAME),win32)
  abs_builddir := $(shell pwd)
  else
  abs_builddir := $(shell pwd -W)
--- 17,23 ----
  NOLOCALE += --no-locale
  endif

! ifneq ($(BUILDOS),mingw32)
  abs_builddir := $(shell pwd)
  else
  abs_builddir := $(shell pwd -W)
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.2.9/src/interfaces/libpq/Makefile
postgresql-8.2.9x/src/interfaces/libpq/Makefile
*** postgresql-8.2.9/src/interfaces/libpq/Makefile    2008-04-16 15:24:38.000000000 +0100
--- postgresql-8.2.9x/src/interfaces/libpq/Makefile    2008-08-09 19:11:03.000000000 +0100
***************
*** 20,26 ****
  SO_MINOR_VERSION= 0
  DLTYPE= library

! override CPPFLAGS :=  -DFRONTEND -DUNSAFE_STAT_OK -I$(srcdir) $(CPPFLAGS) -I$(top_builddir)/src/port
  ifneq ($(PORTNAME), win32)
  override CFLAGS += $(PTHREAD_CFLAGS)
  endif
--- 20,26 ----
  SO_MINOR_VERSION= 0
  DLTYPE= library

! override CPPFLAGS :=  -DFRONTEND -DUNSAFE_STAT_OK -I$(srcdir) $(CPPFLAGS) -I$(top_srcdir)/src/port
-I$(top_builddir)/src/port
  ifneq ($(PORTNAME), win32)
  override CFLAGS += $(PTHREAD_CFLAGS)
  endif
***************
*** 42,51 ****

  ifeq ($(PORTNAME), win32)
  OBJS += win32.o libpqrc.o
! DLL_DEFFILE=libpqdll.def

  libpqrc.o: libpq.rc
!     windres -i libpq.rc -o libpqrc.o

  ifeq ($(enable_thread_safety), yes)
  OBJS += pthread-win32.o
--- 42,51 ----

  ifeq ($(PORTNAME), win32)
  OBJS += win32.o libpqrc.o
! DLL_DEFFILE=$(srcdir)/libpqdll.def

  libpqrc.o: libpq.rc
!     $(WINDRES) -i $(srcdir)/libpq.rc -o libpqrc.o

  ifeq ($(enable_thread_safety), yes)
  OBJS += pthread-win32.o
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.2.9/src/Makefile.global.in
postgresql-8.2.9x/src/Makefile.global.in
*** postgresql-8.2.9/src/Makefile.global.in    2006-10-08 18:15:33.000000000 +0100
--- postgresql-8.2.9x/src/Makefile.global.in    2008-08-09 19:15:02.000000000 +0100
***************
*** 230,235 ****
--- 230,239 ----
  LDOUT = -o
  RANLIB = @RANLIB@
  X = @EXEEXT@
+ AR = @AR@
+ DLLTOOL = @DLLTOOL@
+ DLLWRAP = @DLLWRAP@
+ WINDRES = @WINDRES@

  # Perl

***************
*** 256,261 ****
--- 260,267 ----
  PL_TESTDB = pl_regression
  CONTRIB_TESTDB = contrib_regression

+ ZIC = @ZIC@
+
  # Installation.

  INSTALL    = $(SHELL) $(top_srcdir)/config/install-sh -c
***************
*** 294,299 ****
--- 300,307 ----
  # Additional platform-specific settings
  #

+ BUILDOS = @build_os@
+
  # Name of the "template"
  PORTNAME= @PORTNAME@

***************
*** 457,467 ****
  ifneq (,$(PGAPPICON))
  PGICOSTR=$(subst /,\/,IDI_ICON ICON \"$(top_builddir)/src/port/$(PGAPPICON).ico\")
  endif
! win32ver.rc: $(top_builddir)/src/port/win32ver.rc
!     sed -e 's;FILEDESC;$(PGFILEDESC);' -e 's;VFT_APP;$(PGFTYPE);' -e 's;_ICO_;$(PGICOSTR);' -e 's;\(VERSION.*\),0
*$$;\1,'`date'+%y%j' | sed 's/^0*//'`';' $(top_builddir)/src/port/win32ver.rc > win32ver.rc 
! win32ver.o: $(top_builddir)/src/port/win32ver.rc
!     sed -e 's;FILEDESC;$(PGFILEDESC);' -e 's;VFT_APP;$(PGFTYPE);' -e 's;_ICO_;$(PGICOSTR);' -e 's;\(VERSION.*\),0
*$$;\1,'`date'+%y%j' | sed 's/^0*//'`';' $(top_builddir)/src/port/win32ver.rc > win32ver.rc 
!     windres -i win32ver.rc -o win32ver.o --include-dir=$(top_builddir)/src/include
      rm -f win32ver.rc
  endif

--- 465,475 ----
  ifneq (,$(PGAPPICON))
  PGICOSTR=$(subst /,\/,IDI_ICON ICON \"$(top_builddir)/src/port/$(PGAPPICON).ico\")
  endif
! win32ver.rc: $(top_srcdir)/src/port/win32ver.rc
!     sed -e 's;FILEDESC;$(PGFILEDESC);' -e 's;VFT_APP;$(PGFTYPE);' -e 's;_ICO_;$(PGICOSTR);' -e 's;\(VERSION.*\),0
*$$;\1,'`date'+%y%j' | sed 's/^0*//'`';' $(top_srcdir)/src/port/win32ver.rc > win32ver.rc 
! win32ver.o: $(top_srcdir)/src/port/win32ver.rc
!     sed -e 's;FILEDESC;$(PGFILEDESC);' -e 's;VFT_APP;$(PGFTYPE);' -e 's;_ICO_;$(PGICOSTR);' -e 's;\(VERSION.*\),0
*$$;\1,'`date'+%y%j' | sed 's/^0*//'`';' $(top_srcdir)/src/port/win32ver.rc > win32ver.rc 
!     $(WINDRES) -i win32ver.rc -o win32ver.o --include-dir=$(top_builddir)/src/include --include-dir=$(srcdir)
      rm -f win32ver.rc
  endif

diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.2.9/src/makefiles/Makefile.win32
postgresql-8.2.9x/src/makefiles/Makefile.win32
*** postgresql-8.2.9/src/makefiles/Makefile.win32    2006-06-23 00:50:35.000000000 +0100
--- postgresql-8.2.9x/src/makefiles/Makefile.win32    2008-08-09 19:16:56.000000000 +0100
***************
*** 3,10 ****
--- 3,17 ----
  # Use replacement include files for those missing on Win32
  override CPPFLAGS+="-I$(top_srcdir)/src/include/port/win32"

+ ifndef DLLTOOL
  DLLTOOL= dlltool
+ endif
+ ifndef DLLWRAP
  DLLWRAP= dllwrap
+ endif
+ ifndef WINDRES
+ WINDRES = windres
+ endif
  ifdef PGXS
  BE_DLLLIBS= -L$(libdir) -lpostgres
  else
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.2.9/src/pl/plperl/GNUmakefile
postgresql-8.2.9x/src/pl/plperl/GNUmakefile
*** postgresql-8.2.9/src/pl/plperl/GNUmakefile    2006-07-21 01:24:04.000000000 +0100
--- postgresql-8.2.9x/src/pl/plperl/GNUmakefile    2008-08-09 19:20:26.000000000 +0100
***************
*** 53,59 ****
  # test script can find them.  See comments in src/test/regress/GNUmakefile.
  ifdef VPATH

! ifneq ($(PORTNAME),win32)
  abs_srcdir := $(shell cd $(srcdir) && pwd)
  abs_builddir := $(shell pwd)
  else
--- 53,59 ----
  # test script can find them.  See comments in src/test/regress/GNUmakefile.
  ifdef VPATH

! ifneq ($(BUILDOS),mingw32)
  abs_srcdir := $(shell cd $(srcdir) && pwd)
  abs_builddir := $(shell pwd)
  else
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.2.9/src/pl/plpython/Makefile
postgresql-8.2.9x/src/pl/plpython/Makefile
*** postgresql-8.2.9/src/pl/plpython/Makefile    2006-07-21 01:24:04.000000000 +0100
--- postgresql-8.2.9x/src/pl/plpython/Makefile    2008-08-09 19:20:03.000000000 +0100
***************
*** 72,78 ****
  # test script can find them.  See comments in src/test/regress/GNUmakefile.
  ifdef VPATH

! ifneq ($(PORTNAME),win32)
  abs_srcdir := $(shell cd $(srcdir) && pwd)
  abs_builddir := $(shell pwd)
  else
--- 72,78 ----
  # test script can find them.  See comments in src/test/regress/GNUmakefile.
  ifdef VPATH

! ifneq ($(BUILDOS),mingw32)
  abs_srcdir := $(shell cd $(srcdir) && pwd)
  abs_builddir := $(shell pwd)
  else
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.2.9/src/pl/tcl/Makefile postgresql-8.2.9x/src/pl/tcl/Makefile
*** postgresql-8.2.9/src/pl/tcl/Makefile    2006-07-21 01:24:04.000000000 +0100
--- postgresql-8.2.9x/src/pl/tcl/Makefile    2008-08-09 19:19:38.000000000 +0100
***************
*** 56,62 ****
  # test script can find them.  See comments in src/test/regress/GNUmakefile.
  ifdef VPATH

! ifneq ($(PORTNAME),win32)
  abs_srcdir := $(shell cd $(srcdir) && pwd)
  abs_builddir := $(shell pwd)
  else
--- 56,62 ----
  # test script can find them.  See comments in src/test/regress/GNUmakefile.
  ifdef VPATH

! ifneq ($(BUILDOS),mingw32)
  abs_srcdir := $(shell cd $(srcdir) && pwd)
  abs_builddir := $(shell pwd)
  else
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.2.9/src/test/regress/GNUmakefile
postgresql-8.2.9x/src/test/regress/GNUmakefile
*** postgresql-8.2.9/src/test/regress/GNUmakefile    2006-07-21 01:24:04.000000000 +0100
--- postgresql-8.2.9x/src/test/regress/GNUmakefile    2008-08-09 19:21:34.000000000 +0100
***************
*** 91,97 ****

  all: $(input_files) $(output_files)

! ifneq ($(PORTNAME),win32)
  abs_srcdir := $(shell cd $(srcdir) && pwd)
  abs_builddir := $(shell pwd)
  else
--- 91,97 ----

  all: $(input_files) $(output_files)

! ifneq ($(BUILDOS),mingw32)
  abs_srcdir := $(shell cd $(srcdir) && pwd)
  abs_builddir := $(shell pwd)
  else
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.2.9/src/timezone/Makefile
postgresql-8.2.9x/src/timezone/Makefile
*** postgresql-8.2.9/src/timezone/Makefile    2007-03-14 17:38:15.000000000 +0000
--- postgresql-8.2.9x/src/timezone/Makefile    2008-08-09 19:22:58.000000000 +0100
***************
*** 29,34 ****
--- 29,40 ----
  # for POSIX-style timezone specs
  POSIXRULES = US/Eastern

+ # ZIC is set when cross compiling
+
+ ifeq (,$(ZIC))
+ ZIC=./zic
+ endif
+
  all: SUBSYS.o submake-libpgport zic

  SUBSYS.o: $(OBJS)
***************
*** 38,44 ****
      $(CC) $(CFLAGS) $(ZICOBJS) $(LDFLAGS) $(LIBS) -o $@$(X)

  install: all installdirs
!     ./zic -d '$(DESTDIR)$(datadir)/timezone' -p '$(POSIXRULES)' $(TZDATAFILES)
      $(MAKE) -C tznames $@

  installdirs:
--- 44,50 ----
      $(CC) $(CFLAGS) $(ZICOBJS) $(LDFLAGS) $(LIBS) -o $@$(X)

  install: all installdirs
!     $(ZIC) -d '$(DESTDIR)$(datadir)/timezone' -p '$(POSIXRULES)' $(TZDATAFILES)
      $(MAKE) -C tznames $@

  installdirs:
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.3.3/configure.in test/configure.in
*** postgresql-8.3.3/configure.in    2008-06-09 01:38:40.000000000 +0100
--- test/configure.in    2008-08-09 20:32:33.000000000 +0100
***************
*** 619,624 ****
--- 619,642 ----
  AC_SUBST(with_system_tzdata)

  #
+ # zic if cross-compiling
+ #
+ if test "$build_os" != "$host_os" -a -z "$with_system_tzdata"; then
+   PGAC_ARG_REQ(with, zic, [  --with-zic=path         set location of zic tool],
+              [ZIC=$withval],
+              [ZIC=:])
+
+   if test "$ZIC" = ":"; then
+     AC_PATH_TOOL(ZIC, zic, :)
+   fi
+
+   if test "$ZIC" = ":"; then
+     AC_MSG_ERROR([zic is required for cross-compilation.
+ Use --with-zic to set the location.])
+   fi
+ fi
+
+ #
  # Zlib
  #
  PGAC_ARG_BOOL(with, zlib, yes,
***************
*** 677,682 ****
--- 695,708 ----
  AC_PROG_RANLIB
  PGAC_CHECK_STRIP

+ if test "$PORTNAME" = "win32"; then
+   AC_CHECK_TOOL(DLLWRAP, dllwrap, :)
+   AC_CHECK_TOOL(DLLTOOL, dlltool, :)
+   AC_CHECK_TOOL(WINDRES, windres, :)
+ fi
+
+ AC_CHECK_TOOL(AR, ar, :)
+
  AC_PATH_PROG(TAR, tar)
  AC_PROG_LN_S
  AC_PROG_AWK
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.3.3/src/bin/pgevent/Makefile test/src/bin/pgevent/Makefile
*** postgresql-8.3.3/src/bin/pgevent/Makefile    2008-01-01 19:45:55.000000000 +0000
--- test/src/bin/pgevent/Makefile    2008-08-09 14:56:10.000000000 +0100
***************
*** 21,31 ****

  install: all install-lib

! pgevent.dll: $(OBJS) pgevent.def
!     $(DLLWRAP) --def pgevent.def -o $(NAME) $(OBJS)

! pgmsgevent.o: pgmsgevent.rc win32ver.rc
!     windres pgmsgevent.rc -o pgmsgevent.o --include-dir=$(top_builddir)/src/include

  all-lib: $(NAME)

--- 21,36 ----

  install: all install-lib

! pgevent.dll: $(OBJS) $(srcdir)/pgevent.def
!     $(DLLWRAP) --def $(srcdir)/pgevent.def -o $(NAME) $(OBJS)

! # windres from binutils 2.18 can segfault if the input file name contains / or \.  For safety,
! # copy to the local directory.
!
! pgmsgevent.o: $(srcdir)/pgmsgevent.rc win32ver.rc
!     cp $(srcdir)/pgmsgevent.rc localpgmsgevent.rc
!     $(WINDRES) localpgmsgevent.rc -o pgmsgevent.o --include-dir=$(top_srcdir)/src/include
--include-dir=$(top_builddir)/src/include--include-dir=$(srcdir) 
!     rm -f localpgmsgevent.rc

  all-lib: $(NAME)

diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.3.3/src/interfaces/ecpg/compatlib/Makefile
test/src/interfaces/ecpg/compatlib/Makefile
*** postgresql-8.3.3/src/interfaces/ecpg/compatlib/Makefile    2008-01-01 19:45:59.000000000 +0000
--- test/src/interfaces/ecpg/compatlib/Makefile    2008-08-08 21:17:38.000000000 +0100
***************
*** 31,37 ****
  OBJS= informix.o $(filter snprintf.o, $(LIBOBJS))

  ifeq ($(PORTNAME), win32)
! DLL_DEFFILE=libecpg_compatdll.def
  endif

  all: def-files all-lib
--- 31,37 ----
  OBJS= informix.o $(filter snprintf.o, $(LIBOBJS))

  ifeq ($(PORTNAME), win32)
! DLL_DEFFILE=$(srcdir)/libecpg_compatdll.def
  endif

  all: def-files all-lib
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.3.3/src/interfaces/ecpg/ecpglib/Makefile
test/src/interfaces/ecpg/ecpglib/Makefile
*** postgresql-8.3.3/src/interfaces/ecpg/ecpglib/Makefile    2008-03-21 16:10:10.000000000 +0000
--- test/src/interfaces/ecpg/ecpglib/Makefile    2008-08-08 21:17:08.000000000 +0100
***************
*** 39,45 ****
  ifeq ($(PORTNAME), win32)
  # Link to shfolder.dll instead of shell32.dll
  SHLIB_LINK += -lshfolder
! DLL_DEFFILE=libecpgdll.def
  endif

  all: def-files all-lib
--- 39,45 ----
  ifeq ($(PORTNAME), win32)
  # Link to shfolder.dll instead of shell32.dll
  SHLIB_LINK += -lshfolder
! DLL_DEFFILE=$(srcdir)/libecpgdll.def
  endif

  all: def-files all-lib
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.3.3/src/interfaces/ecpg/pgtypeslib/Makefile
test/src/interfaces/ecpg/pgtypeslib/Makefile
*** postgresql-8.3.3/src/interfaces/ecpg/pgtypeslib/Makefile    2008-01-01 19:45:59.000000000 +0000
--- test/src/interfaces/ecpg/pgtypeslib/Makefile    2008-08-08 21:16:38.000000000 +0100
***************
*** 32,38 ****
      $(filter rint.o snprintf.o, $(LIBOBJS))

  ifeq ($(PORTNAME), win32)
! DLL_DEFFILE=libpgtypesdll.def
  endif

  all: def-files all-lib
--- 32,38 ----
      $(filter rint.o snprintf.o, $(LIBOBJS))

  ifeq ($(PORTNAME), win32)
! DLL_DEFFILE=$(srcdir)/libpgtypesdll.def
  endif

  all: def-files all-lib
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.3.3/src/interfaces/ecpg/test/Makefile
test/src/interfaces/ecpg/test/Makefile
*** postgresql-8.3.3/src/interfaces/ecpg/test/Makefile    2007-08-14 11:01:53.000000000 +0100
--- test/src/interfaces/ecpg/test/Makefile    2008-08-08 20:31:05.000000000 +0100
***************
*** 20,26 ****
  NOLOCALE += --no-locale
  endif

! ifneq ($(PORTNAME),win32)
  abs_builddir := $(shell pwd)
  else
  abs_builddir := $(shell pwd -W)
--- 20,26 ----
  NOLOCALE += --no-locale
  endif

! ifneq ($(BUILDOS),mingw32)
  abs_builddir := $(shell pwd)
  else
  abs_builddir := $(shell pwd -W)
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.3.3/src/interfaces/libpq/Makefile
test/src/interfaces/libpq/Makefile
*** postgresql-8.3.3/src/interfaces/libpq/Makefile    2008-04-16 15:21:22.000000000 +0100
--- test/src/interfaces/libpq/Makefile    2008-08-08 21:15:57.000000000 +0100
***************
*** 20,26 ****
  SO_MINOR_VERSION= 1
  DLTYPE= library

! override CPPFLAGS :=  -DFRONTEND -DUNSAFE_STAT_OK -I$(srcdir) $(CPPFLAGS) -I$(top_builddir)/src/port
  ifneq ($(PORTNAME), win32)
  override CFLAGS += $(PTHREAD_CFLAGS)
  endif
--- 20,26 ----
  SO_MINOR_VERSION= 1
  DLTYPE= library

! override CPPFLAGS :=  -DFRONTEND -DUNSAFE_STAT_OK -I$(srcdir) $(CPPFLAGS) -I$(top_srcdir)/src/port
-I$(top_builddir)/src/port
  ifneq ($(PORTNAME), win32)
  override CFLAGS += $(PTHREAD_CFLAGS)
  endif
***************
*** 42,51 ****

  ifeq ($(PORTNAME), win32)
  OBJS += win32.o pgsleep.o libpqrc.o
! DLL_DEFFILE=libpqdll.def

  libpqrc.o: libpq.rc
!     windres -i libpq.rc -o libpqrc.o

  ifeq ($(enable_thread_safety), yes)
  OBJS += pthread-win32.o
--- 42,51 ----

  ifeq ($(PORTNAME), win32)
  OBJS += win32.o pgsleep.o libpqrc.o
! DLL_DEFFILE=$(srcdir)/libpqdll.def

  libpqrc.o: libpq.rc
!     $(WINDRES) -i $(srcdir)/libpq.rc -o libpqrc.o

  ifeq ($(enable_thread_safety), yes)
  OBJS += pthread-win32.o
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.3.3/src/Makefile.global.in test/src/Makefile.global.in
*** postgresql-8.3.3/src/Makefile.global.in    2007-11-13 00:13:19.000000000 +0000
--- test/src/Makefile.global.in    2008-08-09 10:52:15.000000000 +0100
***************
*** 238,243 ****
--- 238,247 ----
  LDOUT = -o
  RANLIB = @RANLIB@
  X = @EXEEXT@
+ AR = @AR@
+ DLLTOOL = @DLLTOOL@
+ DLLWRAP = @DLLWRAP@
+ WINDRES = @WINDRES@

  # Perl

***************
*** 264,269 ****
--- 268,275 ----
  PL_TESTDB = pl_regression
  CONTRIB_TESTDB = contrib_regression

+ ZIC = @ZIC@
+
  # Installation.

  INSTALL    = $(SHELL) $(top_srcdir)/config/install-sh -c
***************
*** 302,307 ****
--- 308,315 ----
  # Additional platform-specific settings
  #

+ BUILDOS = @build_os@
+
  # Name of the "template"
  PORTNAME= @PORTNAME@

***************
*** 465,475 ****
  ifneq (,$(PGAPPICON))
  PGICOSTR=$(subst /,\/,IDI_ICON ICON \"$(top_builddir)/src/port/$(PGAPPICON).ico\")
  endif
! win32ver.rc: $(top_builddir)/src/port/win32ver.rc
!     sed -e 's;FILEDESC;$(PGFILEDESC);' -e 's;VFT_APP;$(PGFTYPE);' -e 's;_ICO_;$(PGICOSTR);' -e 's;\(VERSION.*\),0
*$$;\1,'`date'+%y%j' | sed 's/^0*//'`';' $(top_builddir)/src/port/win32ver.rc > win32ver.rc 
! win32ver.o: $(top_builddir)/src/port/win32ver.rc
!     sed -e 's;FILEDESC;$(PGFILEDESC);' -e 's;VFT_APP;$(PGFTYPE);' -e 's;_ICO_;$(PGICOSTR);' -e 's;\(VERSION.*\),0
*$$;\1,'`date'+%y%j' | sed 's/^0*//'`';' $(top_builddir)/src/port/win32ver.rc > win32ver.rc 
!     windres -i win32ver.rc -o win32ver.o --include-dir=$(top_builddir)/src/include
      rm -f win32ver.rc
  endif

--- 473,483 ----
  ifneq (,$(PGAPPICON))
  PGICOSTR=$(subst /,\/,IDI_ICON ICON \"$(top_builddir)/src/port/$(PGAPPICON).ico\")
  endif
! win32ver.rc: $(top_srcdir)/src/port/win32ver.rc
!     sed -e 's;FILEDESC;$(PGFILEDESC);' -e 's;VFT_APP;$(PGFTYPE);' -e 's;_ICO_;$(PGICOSTR);' -e 's;\(VERSION.*\),0
*$$;\1,'`date'+%y%j' | sed 's/^0*//'`';' $(top_srcdir)/src/port/win32ver.rc > win32ver.rc 
! win32ver.o: $(top_srcdir)/src/port/win32ver.rc
!     sed -e 's;FILEDESC;$(PGFILEDESC);' -e 's;VFT_APP;$(PGFTYPE);' -e 's;_ICO_;$(PGICOSTR);' -e 's;\(VERSION.*\),0
*$$;\1,'`date'+%y%j' | sed 's/^0*//'`';' $(top_srcdir)/src/port/win32ver.rc > win32ver.rc 
!     $(WINDRES) -i win32ver.rc -o win32ver.o --include-dir=$(top_builddir)/src/include --include-dir=$(srcdir)
      rm -f win32ver.rc
  endif

diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.3.3/src/makefiles/Makefile.win32
test/src/makefiles/Makefile.win32
*** postgresql-8.3.3/src/makefiles/Makefile.win32    2007-08-21 14:32:33.000000000 +0100
--- test/src/makefiles/Makefile.win32    2008-08-08 21:07:09.000000000 +0100
***************
*** 3,10 ****
  # Use replacement include files for those missing on Win32
  override CPPFLAGS+="-I$(top_srcdir)/src/include/port/win32"

! DLLTOOL= dlltool
! DLLWRAP= dllwrap
  ifdef PGXS
  BE_DLLLIBS= -L$(libdir) -lpostgres
  else
--- 3,17 ----
  # Use replacement include files for those missing on Win32
  override CPPFLAGS+="-I$(top_srcdir)/src/include/port/win32"

! ifndef DLLTOOL
! DLLTOOL = dlltool
! endif
! ifndef DLLWRAP
! DLLWRAP = dllwrap
! endif
! ifndef WINDRES
! WINDRES = windres
! endif
  ifdef PGXS
  BE_DLLLIBS= -L$(libdir) -lpostgres
  else
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.3.3/src/pl/plperl/GNUmakefile test/src/pl/plperl/GNUmakefile
*** postgresql-8.3.3/src/pl/plperl/GNUmakefile    2007-12-01 15:30:09.000000000 +0000
--- test/src/pl/plperl/GNUmakefile    2008-08-08 20:31:05.000000000 +0100
***************
*** 56,62 ****
  # test script can find them.  See comments in src/test/regress/GNUmakefile.
  ifdef VPATH

! ifneq ($(PORTNAME),win32)
  abs_srcdir := $(shell cd $(srcdir) && pwd)
  abs_builddir := $(shell pwd)
  else
--- 56,62 ----
  # test script can find them.  See comments in src/test/regress/GNUmakefile.
  ifdef VPATH

! ifneq ($(BUILDOS),mingw32)
  abs_srcdir := $(shell cd $(srcdir) && pwd)
  abs_builddir := $(shell pwd)
  else
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.3.3/src/pl/plpython/Makefile test/src/pl/plpython/Makefile
*** postgresql-8.3.3/src/pl/plpython/Makefile    2007-02-10 04:26:24.000000000 +0000
--- test/src/pl/plpython/Makefile    2008-08-08 20:31:05.000000000 +0100
***************
*** 72,78 ****
  # test script can find them.  See comments in src/test/regress/GNUmakefile.
  ifdef VPATH

! ifneq ($(PORTNAME),win32)
  abs_srcdir := $(shell cd $(srcdir) && pwd)
  abs_builddir := $(shell pwd)
  else
--- 72,78 ----
  # test script can find them.  See comments in src/test/regress/GNUmakefile.
  ifdef VPATH

! ifneq ($(BUILDOS),mingw32)
  abs_srcdir := $(shell cd $(srcdir) && pwd)
  abs_builddir := $(shell pwd)
  else
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.3.3/src/pl/tcl/Makefile test/src/pl/tcl/Makefile
*** postgresql-8.3.3/src/pl/tcl/Makefile    2006-07-21 01:24:04.000000000 +0100
--- test/src/pl/tcl/Makefile    2008-08-08 20:31:05.000000000 +0100
***************
*** 56,62 ****
  # test script can find them.  See comments in src/test/regress/GNUmakefile.
  ifdef VPATH

! ifneq ($(PORTNAME),win32)
  abs_srcdir := $(shell cd $(srcdir) && pwd)
  abs_builddir := $(shell pwd)
  else
--- 56,62 ----
  # test script can find them.  See comments in src/test/regress/GNUmakefile.
  ifdef VPATH

! ifneq ($(BUILDOS),mingw32)
  abs_srcdir := $(shell cd $(srcdir) && pwd)
  abs_builddir := $(shell pwd)
  else
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.3.3/src/test/regress/GNUmakefile
test/src/test/regress/GNUmakefile
*** postgresql-8.3.3/src/test/regress/GNUmakefile    2008-01-01 19:46:00.000000000 +0000
--- test/src/test/regress/GNUmakefile    2008-08-08 20:31:05.000000000 +0100
***************
*** 97,103 ****
  ofile_list := $(subst .source,, $(notdir $(wildcard $(top_srcdir)/$(subdir)/output/*.source)))
  output_files := $(foreach file, $(ofile_list), expected/$(file).out)

! ifneq ($(PORTNAME),win32)
  abs_srcdir := $(shell cd $(srcdir) && pwd)
  abs_builddir := $(shell pwd)
  else
--- 97,103 ----
  ofile_list := $(subst .source,, $(notdir $(wildcard $(top_srcdir)/$(subdir)/output/*.source)))
  output_files := $(foreach file, $(ofile_list), expected/$(file).out)

! ifneq ($(BUILDOS),mingw32)
  abs_srcdir := $(shell cd $(srcdir) && pwd)
  abs_builddir := $(shell pwd)
  else
diff -c -r -x libpq.rc -x '*~' -x configure postgresql-8.3.3/src/timezone/Makefile test/src/timezone/Makefile
*** postgresql-8.3.3/src/timezone/Makefile    2007-08-25 21:29:25.000000000 +0100
--- test/src/timezone/Makefile    2008-08-08 20:31:05.000000000 +0100
***************
*** 27,32 ****
--- 27,38 ----
  # for POSIX-style timezone specs
  POSIXRULES = US/Eastern

+ # ZIC is set when cross compiling
+
+ ifeq (,$(ZIC))
+ ZIC=./zic
+ endif
+
  # use system timezone data?
  ifneq (,$(with_system_tzdata))
  override CPPFLAGS += '-DSYSTEMTZDIR="$(with_system_tzdata)"'
***************
*** 46,52 ****

  install: all installdirs
  ifeq (,$(with_system_tzdata))
!     ./zic -d '$(DESTDIR)$(datadir)/timezone' -p '$(POSIXRULES)' $(TZDATAFILES)
  endif
      $(MAKE) -C tznames $@

--- 52,58 ----

  install: all installdirs
  ifeq (,$(with_system_tzdata))
!     $(ZIC) -d '$(DESTDIR)$(datadir)/timezone' -p '$(POSIXRULES)' $(TZDATAFILES)
  endif
      $(MAKE) -C tznames $@


Re: BUG #3818: Cross compilation problems

От
Alvaro Herrera
Дата:
Richard Evans wrote:

> 1. configure.in detecting the target system versions of dllwrap,
> dlltool, windres and ar
> 2. in various makefiles, checking BUILDOS not PORTNAME when deciding
> whether to use 'pwd -W' or just 'pwd'
> 3. Using the local system's 'zic' command when cross compiling, adding a
> --with-zic option to  configure.in in case zic is not in the path (on my
> fedora 9 system it is in /usr/sbin/zic).
> 4. Some path  tweaks in the make files to allow the cross compile build
> to occur outside the the source directory.
> 5. Working round a binutils-2.18 bug in windres when the rc file has /
> or \ in the path

I think part (4) makes plenty of sense just to enable VPATH building.  I
guess nobody has tried VPATH on cygwin.

I can't comment on the rest of the changes, but most of them seem to be
reasonable.  I think the "pwd" stuff should be done in a makefile
template.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

Re: BUG #3818: Cross compilation problems

От
Peter Eisentraut
Дата:
Am Saturday, 9. August 2008 schrieb Richard Evans:
> I've made a couple of patches, for 8.3.3 and 8.2.9, which enable cross
> compilation for windows (mingw32) from a unix platform.

This looks good, with a couple of tweaks.  I don't think we are going to be
making these kinds of changes in the 8.2 and 8.3 branches, so I suggest you
prepare a patch for 8.4.  Some of the makefiles have changed, so a bit of
work might be involved.

> 2. in various makefiles, checking BUILDOS not PORTNAME when deciding
> whether to use 'pwd -W' or just 'pwd'

I was wondering, what is the difference between these?  And couldn't we just
use $(CURDIR) instead?

> 5. Working round a binutils-2.18 bug in windres when the rc file has /
> or \ in the path

What is the status of this bug?  Shouldn't it be fixed instead?

Re: BUG #3818: Cross compilation problems

От
Richard Evans
Дата:
> Am Saturday, 9. August 2008 schrieb Richard Evans:
 >> I've made a couple of patches, for 8.3.3 and 8.2.9, which enable cross
 >> compilation for windows (mingw32) from a unix platform.
 >
 > This looks good, with a couple of tweaks.  I don't think we are going
to be
 > making these kinds of changes in the 8.2 and 8.3 branches, so I
suggest you
 > prepare a patch for 8.4.  Some of the makefiles have changed, so a
bit of
 > work might be involved.

This is from the source repository?  I'll take a look.

 >
 >> 2. in various makefiles, checking BUILDOS not PORTNAME when deciding
 >> whether to use 'pwd -W' or just 'pwd'
 >
 > I was wondering, what is the difference between these?  And couldn't
we just
 > use $(CURDIR) instead?

I'm not sure why the makefiles need the current directory. pwd -W is
specific to mingw, I think it gives the directory in windows format.  It
has to be changed for cross compilation otherwise you get errors.

 >
 >> 5. Working round a binutils-2.18 bug in windres when the rc file has /
 >> or \ in the path
 >
 > What is the status of this bug?  Shouldn't it be fixed instead?
 >

The bug is fixed in the binutils source repository, so presumably will
be fixed in 2.19.  But it seems better to support the current version
rather than wait for the next.

Richard

Re: BUG #3818: Cross compilation problems

От
Peter Eisentraut
Дата:
Richard Evans wrote:
> I'm not sure why the makefiles need the current directory. pwd -W is
> specific to mingw, I think it gives the directory in windows format.  It
> has to be changed for cross compilation otherwise you get errors.

What does $(CURDIR) resolve to on mingw?  Try the following makefile:

default:
        @echo $(shell pwd)
        @echo $(shell pwd -W)
        @echo $(CURDIR)

Re: BUG #3818: Cross compilation problems

От
Richard Evans
Дата:
Running make inside the msys shell, I get:

/c/misc/mingw/bin
c:/misc/mingw/bin
/c/misc/mingw/bin

running inside a plain DOS command window, I get:

/mingw/bin
c:/misc/mingw/bin
/mingw/bin

Msys/mingw have these funny 'system' mounts.  However it looks like that
/pwd -W/ gives the most sensible output in both cases.  Must be why it's
there.

Richard

> Richard Evans wrote:
>
>> I'm not sure why the makefiles need the current directory. pwd -W is
>> specific to mingw, I think it gives the directory in windows format.  It
>> has to be changed for cross compilation otherwise you get errors.
>>
>
> What does $(CURDIR) resolve to on mingw?  Try the following makefile:
>
> default:
>         @echo $(shell pwd)
>         @echo $(shell pwd -W)
>         @echo $(CURDIR)
>
>

Re: BUG #3818: Cross compilation problems

От
Bruce Momjian
Дата:
Where are we on this?

---------------------------------------------------------------------------

Richard Evans wrote:
> Running make inside the msys shell, I get:
>
> /c/misc/mingw/bin
> c:/misc/mingw/bin
> /c/misc/mingw/bin
>
> running inside a plain DOS command window, I get:
>
> /mingw/bin
> c:/misc/mingw/bin
> /mingw/bin
>
> Msys/mingw have these funny 'system' mounts.  However it looks like that
> /pwd -W/ gives the most sensible output in both cases.  Must be why it's
> there.
>
> Richard
>
> > Richard Evans wrote:
> >
> >> I'm not sure why the makefiles need the current directory. pwd -W is
> >> specific to mingw, I think it gives the directory in windows format.  It
> >> has to be changed for cross compilation otherwise you get errors.
> >>
> >
> > What does $(CURDIR) resolve to on mingw?  Try the following makefile:
> >
> > default:
> >         @echo $(shell pwd)
> >         @echo $(shell pwd -W)
> >         @echo $(CURDIR)
> >
> >

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Re: BUG #3818: Cross compilation problems

От
Peter Eisentraut
Дата:
On Sunday 07 December 2008 01:02:05 Bruce Momjian wrote:
> Where are we on this?

Some of this has been fixed.  But a lot of the code has been moved around
between 8.3 and 8.4, so we can't just take take the patches as is.  If
Richard is still interested, I suggest he try out 8.4 and then submit any
remaining desired changes.

Re: BUG #3818: Cross compilation problems

От
Richard Evans
Дата:
I've taken a look at the current development snapshot ane made a new
patch.  This is against the snapshot source dated 2008-12-30.

I have omitted the workround for the bug in binutils 2.18 since 2.19 is
now available and fixes the problem.

I tested the cross compilation for mingw32 using gcc 4.3.2 and binutils
2.19, with the latest mingw runtime and w32api from mingw.org.

I verified that the build works on a Windows 2000 system.

If the patch goes in, I can provide some notes on the cross compilation
process.

Richard
> On Sunday 07 December 2008 01:02:05 Bruce Momjian wrote:
>
>> Where are we on this?
>>
>
> Some of this has been fixed.  But a lot of the code has been moved around
> between 8.3 and 8.4, so we can't just take take the patches as is.  If
> Richard is still interested, I suggest he try out 8.4 and then submit any
> remaining desired changes.
>
>
diff -c -r -x '*~' -x configure postgresql-snapshot/configure.in pg2/configure.in
*** postgresql-snapshot/configure.in    2008-12-11 07:34:07.000000000 +0000
--- pg2/configure.in    2008-12-29 14:06:23.000000000 +0000
***************
*** 766,771 ****
--- 766,789 ----
  AC_SUBST(with_system_tzdata)

  #
+ # zic if cross-compiling
+ #
+ if test "$build_os" != "$host_os" -a -z "$with_system_tzdata"; then
+   PGAC_ARG_REQ(with, zic, [ZIC], [set location of zic tool],
+              [ZIC=$withval],
+              [ZIC=:])
+
+   if test "$ZIC" = ":"; then
+     AC_PATH_TOOL(ZIC, zic, :)
+   fi
+
+   if test "$ZIC" = ":"; then
+     AC_MSG_ERROR([zic is required for cross-compilation.
+ Use --with-zic to set the location.])
+   fi
+ fi
+
+ #
  # Zlib
  #
  PGAC_ARG_BOOL(with, zlib, yes,
diff -c -r -x '*~' -x configure postgresql-snapshot/src/bin/pgevent/Makefile pg2/src/bin/pgevent/Makefile
*** postgresql-snapshot/src/bin/pgevent/Makefile    2008-12-07 08:36:22.000000000 +0000
--- pg2/src/bin/pgevent/Makefile    2008-12-29 14:06:23.000000000 +0000
***************
*** 21,31 ****

  install: all install-lib

! pgevent.dll: $(OBJS) pgevent.def
!     $(DLLWRAP) --def pgevent.def -o $(NAME) $(OBJS)

  pgmsgevent.o: pgmsgevent.rc win32ver.rc
!     $(WINDRES) pgmsgevent.rc -o pgmsgevent.o --include-dir=$(top_builddir)/src/include

  all-lib: $(NAME)

--- 21,31 ----

  install: all install-lib

! pgevent.dll: $(OBJS) $(srcdir)/pgevent.def
!     $(DLLWRAP) --def $(srcdir)/pgevent.def -o $(NAME) $(OBJS)

  pgmsgevent.o: pgmsgevent.rc win32ver.rc
!     $(WINDRES) $(srcdir)/pgmsgevent.rc -o pgmsgevent.o  --include-dir=$(top_srcdir)/src/include
--include-dir=$(top_builddir)/src/include--include-dir=$(srcdir) --include-dir=$(top_builddir)/$(subdir) 

  all-lib: $(NAME)

diff -c -r -x '*~' -x configure postgresql-snapshot/src/interfaces/ecpg/test/Makefile
pg2/src/interfaces/ecpg/test/Makefile
*** postgresql-snapshot/src/interfaces/ecpg/test/Makefile    2008-12-01 11:37:37.000000000 +0000
--- pg2/src/interfaces/ecpg/test/Makefile    2008-12-29 14:06:23.000000000 +0000
***************
*** 16,22 ****
  NOLOCALE += --no-locale
  endif

! ifneq ($(PORTNAME),win32)
  abs_builddir := $(shell pwd)
  else
  abs_builddir := $(shell pwd -W)
--- 16,22 ----
  NOLOCALE += --no-locale
  endif

! ifneq ($(BUILDOS),mingw32)
  abs_builddir := $(shell pwd)
  else
  abs_builddir := $(shell pwd -W)
diff -c -r -x '*~' -x configure postgresql-snapshot/src/interfaces/libpq/Makefile pg2/src/interfaces/libpq/Makefile
*** postgresql-snapshot/src/interfaces/libpq/Makefile    2008-12-07 08:36:22.000000000 +0000
--- pg2/src/interfaces/libpq/Makefile    2008-12-29 14:06:23.000000000 +0000
***************
*** 19,25 ****
  SO_MAJOR_VERSION= 5
  SO_MINOR_VERSION= 2

! override CPPFLAGS :=  -DFRONTEND -DUNSAFE_STAT_OK -I$(srcdir) $(CPPFLAGS) -I$(top_builddir)/src/port
  ifneq ($(PORTNAME), win32)
  override CFLAGS += $(PTHREAD_CFLAGS)
  endif
--- 19,25 ----
  SO_MAJOR_VERSION= 5
  SO_MINOR_VERSION= 2

! override CPPFLAGS :=  -DFRONTEND -DUNSAFE_STAT_OK -I$(srcdir) $(CPPFLAGS) -I$(top_srcdir)/src/port
-I$(top_builddir)/src/port
  ifneq ($(PORTNAME), win32)
  override CFLAGS += $(PTHREAD_CFLAGS)
  endif
diff -c -r -x '*~' -x configure postgresql-snapshot/src/Makefile.global.in pg2/src/Makefile.global.in
*** postgresql-snapshot/src/Makefile.global.in    2008-12-11 07:34:07.000000000 +0000
--- pg2/src/Makefile.global.in    2008-12-29 14:06:23.000000000 +0000
***************
*** 270,275 ****
--- 270,277 ----
  PL_TESTDB = pl_regression
  CONTRIB_TESTDB = contrib_regression

+ ZIC = @ZIC@
+
  # Installation.

  INSTALL    = $(SHELL) $(top_srcdir)/config/install-sh -c
***************
*** 319,324 ****
--- 321,328 ----
  # Additional platform-specific settings
  #

+ BUILDOS = @build_os@
+
  # Name of the "template"
  PORTNAME= @PORTNAME@

diff -c -r -x '*~' -x configure postgresql-snapshot/src/makefiles/Makefile.win32 pg2/src/makefiles/Makefile.win32
*** postgresql-snapshot/src/makefiles/Makefile.win32    2008-12-07 08:36:22.000000000 +0000
--- pg2/src/makefiles/Makefile.win32    2008-12-29 14:06:23.000000000 +0000
***************
*** 67,70 ****
      sed -e 's;FILEDESC;$(PGFILEDESC);' -e 's;VFT_APP;$(PGFTYPE);' -e 's;_ICO_;$(PGICOSTR);' -e 's;\(VERSION.*\),0
*$$;\1,'`date'+%y%j' | sed 's/^0*//'`';' $< >$@ 

  win32ver.o: win32ver.rc
!     $(WINDRES) -i $< -o $@ --include-dir=$(top_builddir)/src/include
--- 67,70 ----
      sed -e 's;FILEDESC;$(PGFILEDESC);' -e 's;VFT_APP;$(PGFTYPE);' -e 's;_ICO_;$(PGICOSTR);' -e 's;\(VERSION.*\),0
*$$;\1,'`date'+%y%j' | sed 's/^0*//'`';' $< >$@ 

  win32ver.o: win32ver.rc
!     $(WINDRES) -i $< -o $@ --include-dir=$(top_builddir)/src/include --include-dir=$(srcdir)
diff -c -r -x '*~' -x configure postgresql-snapshot/src/Makefile.shlib pg2/src/Makefile.shlib
*** postgresql-snapshot/src/Makefile.shlib    2008-12-11 07:34:07.000000000 +0000
--- pg2/src/Makefile.shlib    2008-12-29 16:14:41.000000000 +0000
***************
*** 406,420 ****

  # Cygwin or Win32 case

- DLL_DEFFILE = lib$(NAME)dll.def
-
  # If SHLIB_EXPORTS is set, the rules below will build a .def file from
  # that.  Else we build a temporary one here.
  ifeq (,$(SHLIB_EXPORTS))
  exports_file = $(DLL_DEFFILE)

  $(exports_file): $(OBJS)
      $(DLLTOOL) --export-all $(DLLTOOL_DEFFLAGS) --output-def $@ $^
  endif

  $(shlib): $(OBJS) $(DLL_DEFFILE)
--- 406,421 ----

  # Cygwin or Win32 case

  # If SHLIB_EXPORTS is set, the rules below will build a .def file from
  # that.  Else we build a temporary one here.
  ifeq (,$(SHLIB_EXPORTS))
+ DLL_DEFFILE = lib$(NAME)dll.def
  exports_file = $(DLL_DEFFILE)

  $(exports_file): $(OBJS)
      $(DLLTOOL) --export-all $(DLLTOOL_DEFFLAGS) --output-def $@ $^
+ else
+ DLL_DEFFILE = $(srcdir)/lib$(NAME)dll.def
  endif

  $(shlib): $(OBJS) $(DLL_DEFFILE)
diff -c -r -x '*~' -x configure postgresql-snapshot/src/timezone/Makefile pg2/src/timezone/Makefile
*** postgresql-snapshot/src/timezone/Makefile    2008-02-19 15:29:58.000000000 +0000
--- pg2/src/timezone/Makefile    2008-12-29 14:06:23.000000000 +0000
***************
*** 27,32 ****
--- 27,38 ----
  # for POSIX-style timezone specs
  POSIXRULES = US/Eastern

+ # ZIC is set when cross compiling
+
+ ifeq (,$(ZIC))
+ ZIC=./zic
+ endif
+
  # use system timezone data?
  ifneq (,$(with_system_tzdata))
  override CPPFLAGS += '-DSYSTEMTZDIR="$(with_system_tzdata)"'
***************
*** 43,49 ****

  install: all installdirs
  ifeq (,$(with_system_tzdata))
!     ./zic -d '$(DESTDIR)$(datadir)/timezone' -p '$(POSIXRULES)' $(TZDATAFILES)
  endif
      $(MAKE) -C tznames $@

--- 49,55 ----

  install: all installdirs
  ifeq (,$(with_system_tzdata))
!     $(ZIC) -d '$(DESTDIR)$(datadir)/timezone' -p '$(POSIXRULES)' $(TZDATAFILES)
  endif
      $(MAKE) -C tznames $@


Re: BUG #3818: Cross compilation problems

От
Peter Eisentraut
Дата:
On Tuesday 30 December 2008 17:49:16 Richard Evans wrote:
> I've taken a look at the current development snapshot ane made a new
> patch.  This is against the snapshot source dated 2008-12-30.

Half of this patch appears to attempt to fix not cross-compilation problems,
but out-of-tree builds (vpath builds).  Considering that other developers
regularly exercise this, it looks a bit suspicious.  Can you clarify your
intent?

Re: BUG #3818: Cross compilation problems

От
Alvaro Herrera
Дата:
Peter Eisentraut wrote:
> On Tuesday 30 December 2008 17:49:16 Richard Evans wrote:
> > I've taken a look at the current development snapshot ane made a new
> > patch.  This is against the snapshot source dated 2008-12-30.
>
> Half of this patch appears to attempt to fix not cross-compilation problems,
> but out-of-tree builds (vpath builds).  Considering that other developers
> regularly exercise this, it looks a bit suspicious.  Can you clarify your
> intent?

Hmm, but does anyone test the VPATH build on mingw?  It looks like the
rules being modified are part of that port exclusively.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Re: BUG #3818: Cross compilation problems

От
Richard Evans
Дата:
Yes, that's true.  There are also some changes to support general
cross-compilation.

Some more details:

configure.in: if you not using system timezone data,
src/timezone/Makefile builds a zic executable and then runs it to
generate tzdata files.  If you are cross compiling this won't work so I
added an option to identify the build system's zic command and use that
instead.  You need this for a mingw32 cross compile since there is no
system tzdata on Windows.  tzdata files are architecture independent.

The alternative would be to build a host system zic alongside or instead
of the target system zic but that seemed more complex since the
configure script would need to set up for local and target compilation.

src/bin/pgevent/Makefile: fix source and include path for vpath mingw32
compilation.

src/interfaces/ecpg/test/Makefile: use pwd -W if the build system is
mingw32, as opposed to the target system being win32.

src/interfaces/libpq/Makefile: fix include path for vpath mingw32
compilation (to find pthread-win32.h).

src/Makefile.global.in: set ZIC and BUILD_OS variables (the latter to
test for cross-compilation).

src/makefiles/Makefile.win32: fix windres include path for vpath mingw32
compilation.

src/Makefile.shlib: fix value of DLL_DEFFILE so that .def file is
generated in the build tree, not the source tree.

src/timezone/Makefile: use system zic command when cross-compiling

Richard
> Peter Eisentraut wrote:
>
>> On Tuesday 30 December 2008 17:49:16 Richard Evans wrote:
>>
>>> I've taken a look at the current development snapshot ane made a new
>>> patch.  This is against the snapshot source dated 2008-12-30.
>>>
>> Half of this patch appears to attempt to fix not cross-compilation problems,
>> but out-of-tree builds (vpath builds).  Considering that other developers
>> regularly exercise this, it looks a bit suspicious.  Can you clarify your
>> intent?
>>
>
> Hmm, but does anyone test the VPATH build on mingw?  It looks like the
> rules being modified are part of that port exclusively.
>
>

Re: BUG #3818: Cross compilation problems

От
Peter Eisentraut
Дата:
Richard Evans wrote:
> I've taken a look at the current development snapshot ane made a new
> patch.  This is against the snapshot source dated 2008-12-30.

This is now committed.