Thread: Re: [pgsql-hackers-win32] build annoyences

Re: [pgsql-hackers-win32] build annoyences

From
Bruce Momjian
Date:
Michiel Ephraim wrote:
> On Tuesday 20 April 2004 00:32, Bruce Momjian wrote:
> > Michiel Ephraim wrote:
> > > dear hackers-win32 list,
> > >
> > > When building today's CVS version for win32, i found a few little things
> > > which stopped a clean "gmake && gmake install". Most of them are missing
> > > .exe extensions in the makefiles.
> > >
> > > A diff is attached to this mail. Changes to
> > > "src/makefiles/Makefile.win32" were only necessary for cross-compilation.
> > >
> > > My setup is
> > >     compiler: mingw32-gcc (GCC) 3.3.1 (mingw special 20030804-1)
> > >     host: FreeBSD euph4 5.2-RELEASE
> > >     configure options used: --host=mingw32 --prefix=/opt/postgres-mingw32
> > > --without-readline --without-zlib
> > >
> > > The gcc is setup as a cross-compiler for mingw32, and is simply installed
> > > from ports.
> >
> > Interesting.  I am confused why others didn't need these changes.  In
> > psql's Makefile I see:
> >
> >     psql: $(OBJS) $(libpq_builddir)/libpq.a
> >             $(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@
> >     ...
> >
> >     install: all installdirs
> >             $(INSTALL_PROGRAM) psql$(X) $(DESTDIR)$(bindir)/psql$(X)
> >
> > Why do other compilers output .exe from CC?  Is it because you are
> > cross-compiling?  Also, why did you need to change the #include in
> > snprintf?
>
> Hi Bruce,
>
> Thanks for the response.
>
> Most likely you are right about the cross-compiling. In that case the compiler
> doesn't add the .exe by itself. Actually in one case, there was already a
> $(X) in the link line. So, I guess, it doesn't hurt.

Yes, I see that backend/Makefile already had the $(X) for link lines so
it seems it is necessary.  I applied the attached patch that adds $(X)
to the other links.

I don't think we have a lot of folks using a mingw compiler on Unix
systems, yet.  :-)

Thanks.


--
  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/bin/initdb/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/initdb/Makefile,v
retrieving revision 1.35
diff -c -c -r1.35 Makefile
*** src/bin/initdb/Makefile    23 Dec 2003 21:56:20 -0000    1.35
--- src/bin/initdb/Makefile    26 Apr 2004 17:36:56 -0000
***************
*** 20,26 ****
  all: submake-libpq submake-libpgport initdb

  initdb: $(OBJS) $(libpq_builddir)/libpq.a
!     $(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@

  install: all installdirs
      $(INSTALL_PROGRAM) initdb$(X) $(DESTDIR)$(bindir)/initdb$(X)
--- 20,26 ----
  all: submake-libpq submake-libpgport initdb

  initdb: $(OBJS) $(libpq_builddir)/libpq.a
!     $(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)

  install: all installdirs
      $(INSTALL_PROGRAM) initdb$(X) $(DESTDIR)$(bindir)/initdb$(X)
Index: src/bin/pg_controldata/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_controldata/Makefile,v
retrieving revision 1.5
diff -c -c -r1.5 Makefile
*** src/bin/pg_controldata/Makefile    10 Feb 2004 23:24:13 -0000    1.5
--- src/bin/pg_controldata/Makefile    26 Apr 2004 17:36:56 -0000
***************
*** 17,23 ****
  all: submake-libpgport pg_controldata

  pg_controldata: $(OBJS)
!     $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LIBS) -o $@

  pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
      rm -f $@ && $(LN_S) $< .
--- 17,23 ----
  all: submake-libpgport pg_controldata

  pg_controldata: $(OBJS)
!     $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LIBS) -o $@$(X)

  pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
      rm -f $@ && $(LN_S) $< .
Index: src/bin/pg_dump/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_dump/Makefile,v
retrieving revision 1.44
diff -c -c -r1.44 Makefile
*** src/bin/pg_dump/Makefile    7 Feb 2004 07:20:12 -0000    1.44
--- src/bin/pg_dump/Makefile    26 Apr 2004 17:36:56 -0000
***************
*** 25,37 ****
  all: submake-libpq submake-libpgport submake-backend pg_dump pg_restore pg_dumpall

  pg_dump: pg_dump.o common.o pg_dump_sort.o $(OBJS) $(libpq_builddir)/libpq.a
!     $(CC) $(CFLAGS) pg_dump.o common.o pg_dump_sort.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@

  pg_restore: pg_restore.o $(OBJS) $(libpq_builddir)/libpq.a
!     $(CC) $(CFLAGS) pg_restore.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@

  pg_dumpall: pg_dumpall.o dumputils.o $(libpq_builddir)/libpq.a
!     $(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@

  .PHONY: submake-backend
  submake-backend:
--- 25,37 ----
  all: submake-libpq submake-libpgport submake-backend pg_dump pg_restore pg_dumpall

  pg_dump: pg_dump.o common.o pg_dump_sort.o $(OBJS) $(libpq_builddir)/libpq.a
!     $(CC) $(CFLAGS) pg_dump.o common.o pg_dump_sort.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)

  pg_restore: pg_restore.o $(OBJS) $(libpq_builddir)/libpq.a
!     $(CC) $(CFLAGS) pg_restore.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)

  pg_dumpall: pg_dumpall.o dumputils.o $(libpq_builddir)/libpq.a
!     $(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)

  .PHONY: submake-backend
  submake-backend:
Index: src/bin/pg_resetxlog/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_resetxlog/Makefile,v
retrieving revision 1.6
diff -c -c -r1.6 Makefile
*** src/bin/pg_resetxlog/Makefile    5 Mar 2004 01:11:04 -0000    1.6
--- src/bin/pg_resetxlog/Makefile    26 Apr 2004 17:36:56 -0000
***************
*** 20,26 ****
  all: submake-libpgport pg_resetxlog

  pg_resetxlog: $(OBJS)
!     $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LIBS) -o $@

  dirmod.c: % : $(top_srcdir)/src/port/%
      rm -f $@ && $(LN_S) $< .
--- 20,26 ----
  all: submake-libpgport pg_resetxlog

  pg_resetxlog: $(OBJS)
!     $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LIBS) -o $@$(X)

  dirmod.c: % : $(top_srcdir)/src/port/%
      rm -f $@ && $(LN_S) $< .
Index: src/bin/psql/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/psql/Makefile,v
retrieving revision 1.42
diff -c -c -r1.42 Makefile
*** src/bin/psql/Makefile    22 Apr 2004 14:33:45 -0000    1.42
--- src/bin/psql/Makefile    26 Apr 2004 17:36:56 -0000
***************
*** 27,33 ****
  all: submake-libpq submake-libpgport psql

  psql: $(OBJS) $(libpq_builddir)/libpq.a
!     $(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@

  help.o: $(srcdir)/sql_help.h

--- 27,33 ----
  all: submake-libpq submake-libpgport psql

  psql: $(OBJS) $(libpq_builddir)/libpq.a
!     $(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)

  help.o: $(srcdir)/sql_help.h

Index: src/bin/scripts/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/scripts/Makefile,v
retrieving revision 1.25
diff -c -c -r1.25 Makefile
*** src/bin/scripts/Makefile    29 Nov 2003 19:52:07 -0000    1.25
--- src/bin/scripts/Makefile    26 Apr 2004 17:36:56 -0000
***************
*** 20,26 ****
  all: submake-libpq submake-backend $(PROGRAMS)

  %: %.o
!     $(CC) $(CFLAGS) $^ $(libpq) $(LDFLAGS) $(LIBS) -o $@

  createdb: createdb.o common.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
  createlang: createlang.o common.o print.o mbprint.o
--- 20,26 ----
  all: submake-libpq submake-backend $(PROGRAMS)

  %: %.o
!     $(CC) $(CFLAGS) $^ $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)

  createdb: createdb.o common.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
  createlang: createlang.o common.o print.o mbprint.o
Index: src/interfaces/ecpg/preproc/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/preproc/Makefile,v
retrieving revision 1.101
diff -c -c -r1.101 Makefile
*** src/interfaces/ecpg/preproc/Makefile    25 Apr 2004 20:57:32 -0000    1.101
--- src/interfaces/ecpg/preproc/Makefile    26 Apr 2004 17:36:57 -0000
***************
*** 26,32 ****
  all: submake-libpgport ecpg

  ecpg: $(OBJS)
!     $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) $(PTHREAD_LIBS) -o $@

  # pgc is compiled as part of preproc
  preproc.o: $(srcdir)/pgc.c
--- 26,32 ----
  all: submake-libpgport ecpg

  ecpg: $(OBJS)
!     $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) $(PTHREAD_LIBS) -o $@$(X)

  # pgc is compiled as part of preproc
  preproc.o: $(srcdir)/pgc.c