PORTNAME and LINUX_ELF defines in interface Makefiles - Mailing list pgsql-hackers

From Kristofer A. E. Peterson
Subject PORTNAME and LINUX_ELF defines in interface Makefiles
Date
Msg-id 353CD2AC.7FCA790@taconic.net
Whole thread Raw
Responses Re: [HACKERS] PORTNAME and LINUX_ELF defines in interface Makefiles
List pgsql-hackers
I have had problems with LINUX_ELF and/or PORTNAME *not* being defined
and shared libraries *not* being compiled. I would like to make the
following observations, based on the Makefiles generated for a linux
system, with elf, and with glibc v2.06.

The configure command line was:

[/usr/src/postgresql-6.3.2/src]$ ./configure  --host=i586-pc-linux
--prefix=/usr/local/pgsql --enable-locale --with-tcl --with-perl
--with-x --enable-hba

Using the following command, executed from the src directory:

[/usr/src/postgresql-6.3.2/src]$ grep -l "\(PORTNAME\)\|\(LINUX_ELF\)"
`find -regex ".*/.*Makefile\(.custom\|.global\)?"`

I found that the only Makefiles that mention the PORTNAME or LINUX_ELF
defines were the following:

./interfaces/ecpg/lib/Makefile
./interfaces/libpgtcl/Makefile
./interfaces/libpq/Makefile
./interfaces/libpq++/Makefile
./Makefile.custom

Since I created Makefile.custom myself, the other four Makefiles are the
ones to be investigated.

Of the four Makefiles, three of them (libpgtcl, ecpg, libpq) used the
following lines to determine whether a shared library should be build.
(under Linux)

ifeq ($(PORTNAME), linux)
  ifdef LINUX_ELF
    install-shlib-dep := install-shlib
    shlib := libpq.so.$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
    LDFLAGS_SL = -shared -soname libpq.so.$(SO_MAJOR_VERSION)
    CFLAGS += $(CFLAGS_SL)
  endif
endif

while the other Makefile (libpq++), had the following lines:

ifeq ($(PORTNAME), linux)
  INSTALL-SHLIB-DEP := install-shlib
  SHLIB := libpq++.so.1
  LDFLAGS_SL = -shared -soname $(SHLIB)
  CFLAGS += $(CFLAGS_SL)
endif

The key thing to note is that all four Makefiles require PORTNAME to be
set to 'linux' to compile a shared library, and three of them,
(libpgtcl, ecpg, libpq), also requre LINUX_ELF to be defined, whereas
the other Makefile (libpq++) does not check for this.

In addition, the following define appeared in only three out of the four
Makefiles, the same three that checked for LINUX_ELF to be defined,
(libpq, libpgtcl, ecpg). (Coincidence? I think not.)

PORTNAME=linux

In the Makefile for libpq++, PORTNAME was never defined.

So what this boils down to is, compiling out of the box, libpgtcl.so,
libecpg.so, and libpq.so, will *not* be made because LINUX_ELF is *not*
defined anywhere. However, libpq++.so will *not* be made because
PORTNAME is *not* defined or equal to 'linux'.

As a quick fix, create the file Makefile.custom in the src directory,
(place where Makefile.global lives), and put the following two lines in
it.

LINUX_ELF=true
PORTNAME='linux'

Since Makefile.custom is included by Makefile.global, and thus by every
Makefile in the tree, the interface Makefiles will be happy and make
their shared libraries.

In the future, I would suggest the these two defines be placed into
Makefile.global by the configure program (autoconf). Furthermore, the
Makefiles for libpgtcl, libecpg, and libpq should *not* define PORTNAME,
rather they should rely on PORTNAME being defined in Makefile.global.
The Makefile for libpq++ should to be changed to check for LINUX_ELF
being defined in addition to checking PORTNAME='linux'.

The checks for LINUX_ELF are probably a hold over to the days when
people compiled PostGreSQL on a.out linux boxes with funky, gnarly
shared library support. Perhaps people still do, and if they do,
LINUX_ELF should stay.

I have not played around with autoconf, so I don't know off hand what
would have to be changed to fix this, although I'll take a look if no
one else wants to.

Anyways, if you made it here, I hope you've found something entertaining
and useful. :)

- Kris

PS - I don't know if the other ports have similar Makefile problems, I
have noticed that for BSD libecpg, libpgtcl, and libpq are built shared,
but not libpq++.

pgsql-hackers by date:

Previous
From: The Hermit Hacker
Date:
Subject: Re: [HACKERS] configure guessing platform
Next
From: The Hermit Hacker
Date:
Subject: Re: [HACKERS] PORTNAME and LINUX_ELF defines in interface Makefiles