On Sun, Jun 29, 2003 at 11:34:21AM +0200, Michael van Elst wrote:
>On Sat, Jun 28, 2003, Bill Campbell wrote:
>
>> I've just done some hacking on perl to add shared libraries so that
>> postgresql will build properly with perl support.  This required some
>> tweaking on the postgresql.spec file to (a) enable plperl, and (b) fix the
>> odbcinit in %post processing.
>
>For plperl you either need a shared perl library OR compile the perl
>library as position-independent code (PIC) so that you can link a
>shared perl-module.

I've built perl, adding an option ``with_shared'' to the perl.spec file.
This then adds ``-Duseshrplib="true"'' to the ./Configure, and does some
tweaking to insure that the libperl.so file is available during the build
process, and installed on %{l_prefix}/lib.  The attached patch handles this
(and enables GDBM_File which we use locally since we have a backwards
compatibility problem with many of our installed systems):

  1.  Enables gdbm.

  2.  Disables old gbm and ndbm because they were breaking when I was
      building on FreeBSD 4.8.

  3.  Uses ``-Aprepend'' to add %{l_prefix}/lib to Configure since the
      freebsd hints file hides the Dglibpth.

  4.  Adds LD_LIBRARY_PATH for %install processing if building with shared
      libraries.

  5.  Links the %archlib/CORE/libperl.so file to %{l_prefix}/lib.

These patches are working on FreeBSD, but I haven't tested them on any
other systems yet.

>I'm still trying to find out how to use unixodbc :)

It's really fairly simple.  The client program (e.g.  openoffice.org)
dynamically links to the libodbc.so library (or whatever the OS uses for
dynamic libraries).  The %{l_prefix}/etc/unixodbc/{odbc.ini,odbcist.ini}
files are used to specify databases and attributes such as user and
password.  The database requires a path to a dynamic library to reference
that particular type (e.g. myodbc, java, postgressql).

Bill
--
INTERNET:   [EMAIL PROTECTED]  Bill Campbell; Celestial Software LLC
UUCP:               camco!bill  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676
URL: http://www.celestial.com/

``The trouble with fighting for human freedom is that one spends most of
one's time defending scoundrels. For it is against scoundrels that
oppressive laws are first aimed, and oppression must be stopped at the
beginning if it is to be stopped at all.'' -- H. L. Mencken
--- perl.spec.orig	Sun Jun 29 10:28:19 2003
+++ perl.spec	Thu Jun 26 17:00:19 2003
@@ -33,7 +33,10 @@
 Group:        Language
 License:      GPL/Artistic
 Version:      5.8.0
-Release:      20030519
+Release:      20030625
+
+#   package options
+%option with_shared yes
 
 #   list of sources
 Source0:      ftp://ftp.cpan.org/pub/CPAN/src/perl-%{version}.tar.gz
@@ -61,12 +64,14 @@
 %build
     #   configure the Perl package
     %{l_shtool} subst \
+		-e '/^libswanted=.* ndbm /s; ndbm ; ;' \
         -e 's;\(.*for thislib in $libswanted.*\);libswanted=`echo " $libswanted " | sed -e "s/ bind / /g" -e "s/ iconv / /g"`\; \1;' \
         -e 's;package=perl5;package=perl;' \
         Configure
     %{l_shtool} subst \
         -e 's; */usr/local/lib;;' \
         hints/freebsd.sh hints/netbsd.sh
+	# echo 'libswanted="-lm -lc -lcrypt -lutil -L%{l_prefix}/lib -lgdbm"' >> hints/freebsd.sh
     %{l_shtool} subst \
         -e 's!/usr/local/lib!%{l_prefix}/lib!g' \
 		-e 's!-melf"!-melf";libswanted="$libswanted -lgcc"!' \
@@ -83,13 +88,24 @@
         -Dglibpth="%{l_prefix}/lib /lib /usr/lib /usr/ccs/lib" \
         -Dscriptdir="%{l_prefix}/bin" \
         -Uinstallusrbinperl \
-        -Ui_malloc -Ui_iconv -Ui_db
+%if %{with_shared} == "yes"
+		-Duseshrplib="true" \
+%endif
+		-Di_gdbm \
+		-Aprepend:libpth='%{l_prefix}/lib ' \
+		-Aprepend:glibpth='%{l_prefix}/lib ' \
+        -Ui_malloc -Ui_iconv -Ui_db -Ui_dbm -Ui_ndbm
 
     #   build the Perl package
     %{l_make} %{l_mflags} -f Makefile
 
 %install
     rm -rf $RPM_BUILD_ROOT
+%if %{with_shared} == "yes"
+	PWD=`pwd`
+	LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH"
+	export LD_LIBRARY_PATH
+%endif
 
     #   install the Perl package via standard procedure
     %{l_make} %{l_mflags} -f Makefile install
@@ -119,6 +135,10 @@
 
     #   strip binary files
     strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
+%if %{with_shared} == "yes"
+	eval `$RPM_BUILD_ROOT%{l_prefix}/bin/perl -V:archlib`
+	ln -s $archlib/CORE/libperl.so $RPM_BUILD_ROOT%{l_prefix}/lib/
+%endif
 
     #   determine installed files
     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

Reply via email to