Thread

  1. linux, bsd, i386-solaris and univel shared libraries.

    Darren King <darrenk@insightdist.com> — 1998-04-23T20:25:39Z

    For the linux, bsd, i386-solaris and univel ports, ...
    
    If I were to try to make foo$(DLSUFFIX) from bar.c and bah.c, I would
    think the general sequence of events would be:
    
    1. $(CC) $(CFLAGS_SL) -o bar.o bar.c
    2. $(CC) $(CFLAGS_SL) -o bah.o bah.c
    3. $(LD) $(LDFLAGS_SL) -r -o foo.o bar.o bah.o
    4. $(LD) $(LDFLAGS_SL) -o foo$(DLSUFFIX) foo.o
    
    Could someone for each port tell me what $(CFLAGS_SL) and $(LDFLAGS_SL)
    are needed for each of these steps?
    
    I have reworked the libpq Makefile to make a shared libpq for aix and
    I'd like to move the libpq port-specific code to the port Makefiles
    without breaking it.
    
    Any help from others with shared library knowledge on these ports would
    be greatly appreciated.
    
    darrenk
    
    
  2. Re: [HACKERS] linux, bsd, i386-solaris and univel shared libraries.

    Michael Meskes <meskes@topsystem.de> — 1998-04-24T09:18:27Z

    Darren King writes:
    > 
    > For the linux, bsd, i386-solaris and univel ports, ...
    > 
    > If I were to try to make foo$(DLSUFFIX) from bar.c and bah.c, I would
    > think the general sequence of events would be:
    > 
    > 1. $(CC) $(CFLAGS_SL) -o bar.o bar.c
    > 2. $(CC) $(CFLAGS_SL) -o bah.o bah.c
    > 3. $(LD) $(LDFLAGS_SL) -r -o foo.o bar.o bah.o
    > 4. $(LD) $(LDFLAGS_SL) -o foo$(DLSUFFIX) foo.o
    > 
    > Could someone for each port tell me what $(CFLAGS_SL) and $(LDFLAGS_SL)
    > are needed for each of these steps?
    
    Linux:
    
    CFLAGS_SL: -fpic
    LDFLAGS_SL: -shared -soname foo$(DLSUFFIX_WITH_MAJOR_VERSION_NUMBER)
    
    I hope I didn't miss anything.
    
    Michael 
    
    -- 
    Dr. Michael Meskes, Project-Manager    | topsystem Systemhaus GmbH
    meskes@topsystem.de                    | Europark A2, Adenauerstr. 20
    meskes@debian.org                      | 52146 Wuerselen
    Go SF49ers! Go Rhein Fire!             | Tel: (+49) 2405/4670-44
    Use Debian GNU/Linux!                  | Fax: (+49) 2405/4670-10
    
    
  3. Re: [HACKERS] linux, bsd, i386-solaris and univel shared libraries.

    Alen Zekulic <azekulic@fesb.hr> — 1998-04-24T11:28:10Z

    On Fri, Apr 24, 1998 at 11:18:27 +0200, Michael Meskes wrote:
    
    > Darren King writes:
    > > 
    > > For the linux, bsd, i386-solaris and univel ports, ...
    > > 
    > > If I were to try to make foo$(DLSUFFIX) from bar.c and bah.c, I would
    > > think the general sequence of events would be:
    > > 
    > > 1. $(CC) $(CFLAGS_SL) -o bar.o bar.c
    > > 2. $(CC) $(CFLAGS_SL) -o bah.o bah.c
    > > 3. $(LD) $(LDFLAGS_SL) -r -o foo.o bar.o bah.o
    > > 4. $(LD) $(LDFLAGS_SL) -o foo$(DLSUFFIX) foo.o
    > > 
    > > Could someone for each port tell me what $(CFLAGS_SL) and $(LDFLAGS_SL)
    > > are needed for each of these steps?
    > 
    > Linux:
    > 
    > CFLAGS_SL: -fpic
                  ^^^^
    The shared library must be compiled with `-fPIC', and the static version
    must not be. In other words, each `*.c' file is compiled twice.
    
    > LDFLAGS_SL: -shared -soname foo$(DLSUFFIX_WITH_MAJOR_VERSION_NUMBER)
    > 
    > I hope I didn't miss anything.
    
    Take a look at the debian policy manual :-)).
    
    Here is the patch against the `ecpg/lib/Makefile.in'.
    
    ======================Makefile.in.patch===============================
    --- Makefile.in.old	Wed Apr 22 13:36:00 1998
    +++ Makefile.in	Fri Apr 24 12:59:34 1998
    @@ -22,3 +22,2 @@
         LDFLAGS_SL = -shared -soname libecpg.so.$(SO_MAJOR_VERSION)
    -    CFLAGS += $(CFLAGS_SL)
       endif
    @@ -48,4 +47,4 @@
     
    -$(shlib): ecpglib.o typename.o
    -	$(LD) $(LDFLAGS_SL) -o $@ ecpglib.o typename.o 
    +$(shlib): ecpglib.sho typename.sho
    +	$(LD) $(LDFLAGS_SL) -o $@ ecpglib.sho typename.sho
     	ln -sf $@ libecpg.so
    @@ -53,3 +52,3 @@
     clean:
    -	rm -f *.o *.a core a.out *~ $(shlib) libecpg.so
    +	rm -f *.o *.sho *.a core a.out *~ $(shlib) libecpg.so
     
    @@ -71,4 +70,9 @@
     ecpglib.o : ecpglib.c ../include/ecpglib.h ../include/ecpgtype.h
    -	$(CC) $(CFLAGS) -I../include $(PQ_INCLUDE) -c ecpglib.c
    +	$(CC) $(CFLAGS) -I../include $(PQ_INCLUDE) -c $< -o $@
     typename.o : typename.c ../include/ecpgtype.h
    -	$(CC) $(CFLAGS) -I../include $(PQ_INCLUDE) -c typename.c
    +	$(CC) $(CFLAGS) -I../include $(PQ_INCLUDE) -c $< -o $@
    +
    +ecpglib.sho : ecpglib.c ../include/ecpglib.h ../include/ecpgtype.h
    +	$(CC) $(CFLAGS) $(CFLAGS_SL) -I../include $(PQ_INCLUDE) -c $< -o $@
    +typename.sho : typename.c ../include/ecpgtype.h
    +	$(CC) $(CFLAGS) $(CFLAGS_SL) -I../include $(PQ_INCLUDE) -c $< -o $@
    ======================Makefile.in.patch===============================
    
    Regards,
    
    -- Alen
    
    ----------------------------------------------------------------------
    Alen Zekulic <azekulic@debian.org>
    Key fingerprint = 47 82 56 37 1D 94 94 F8  16 C1 D8 33 1D 9D 61 73
    
    
  4. Re: [HACKERS] linux, bsd, i386-solaris and univel shared libraries.

    Michael Meskes <meskes@topsystem.de> — 1998-04-24T11:33:05Z

    Alen Zekulic writes:
    > > CFLAGS_SL: -fpic
    >               ^^^^
    > The shared library must be compiled with `-fPIC', and the static version
    > must not be. In other words, each `*.c' file is compiled twice.
    
    Normaly yes. But I didn't see this in any PostgreSQL makefile. I think using
    -fPIC still creates a working static library. It does generate less
    efficient code though.
    
    > Take a look at the debian policy manual :-)).
    
    :-)
    
    > Here is the patch against the `ecpg/lib/Makefile.in'.
    
    Applied to my source. I think we should add a similar patch to
    libpq/Makefile and whatever else creates shared libs.
    
    Michael
    
    -- 
    Dr. Michael Meskes, Project-Manager    | topsystem Systemhaus GmbH
    meskes@topsystem.de                    | Europark A2, Adenauerstr. 20
    meskes@debian.org                      | 52146 Wuerselen
    Go SF49ers! Go Rhein Fire!             | Tel: (+49) 2405/4670-44
    Use Debian GNU/Linux!                  | Fax: (+49) 2405/4670-10