[libtpcimgio/f15] shared PIC library

Tom Callaway spot at fedoraproject.org
Mon Aug 8 18:30:45 UTC 2011


commit cfcd15bff4b19a84c687308be3e14a22abbd68d7
Author: Tom "spot" Callaway <tcallawa at redhat.com>
Date:   Mon Aug 8 14:30:34 2011 -0400

    shared PIC library

 libtpcimgio-shared.patch |   52 ++++++++++++++++++++++++++++++++++++++++++++++
 libtpcimgio.spec         |   35 ++++++++++++++++++++++++++----
 2 files changed, 82 insertions(+), 5 deletions(-)
---
diff --git a/libtpcimgio-shared.patch b/libtpcimgio-shared.patch
new file mode 100644
index 0000000..631ea25
--- /dev/null
+++ b/libtpcimgio-shared.patch
@@ -0,0 +1,52 @@
+diff -up libtpcimgio/Makefile.shared libtpcimgio/Makefile
+--- libtpcimgio/Makefile.shared	2010-09-18 07:05:53.000000000 -0400
++++ libtpcimgio/Makefile	2011-08-08 13:50:36.906876738 -0400
+@@ -70,9 +70,12 @@ SOURCES 	= ecat63r.c ecat63w.c ecat63p.c
+ 		  sifio.c sif.c weight.c libtpcimgiov.c
+ OBJECTS 	= ${SOURCES:.c=.o}
+ LIBARCHIVE	= ${LIBRARY}.a
++SHLIBSHORT	= ${LIBRARY}.so
++SHLIBMAJOR	= ${SHLIBSHORT}.0
++SHLIBARCHIVE	= ${SHLIBMAJOR}.0.0
+ DOXYGEN		= doxygen
+ CC		= gcc
+-CFLAGS 		= -std=gnu99 -s -Wall ${ANSI} -O2 ${INCLUDE}
++CFLAGS 		= -std=gnu99 -s -Wall ${ANSI} -O2 ${INCLUDE} -fPIC -DPIC
+ LDFLAGS         = -L.
+ LIBS 		= ${LDFLAGS} -ltpcimgio -ltpcmisc -lm
+ ZIP		= zip
+@@ -92,14 +95,20 @@ endif
+ LIBEXEC 	= ${LIBRARY}${EXT}
+ 
+ # ------------- Compilation: --------------------------------------------------#
+-compile: ${LIBARCHIVE} ${LIBEXEC}
++compile: ${LIBARCHIVE} ${SHLIBARCHIVE} ${LIBEXEC}
+ 
+-# Compile library
++# Compile static library
+ ${LIBARCHIVE}: ${OBJECTS}
+ 	${AR} -rvs ${LIBARCHIVE} ${OBJECTS}
+ 
++# Compile shared library
++${SHLIBARCHIVE}: ${OBJECTS}
++	${CC} -shared -o $@ ${OBJECTS} -Wl,-soname=${SHLIBMAJOR}
++	ln -s ${SHLIBARCHIVE} ${SHLIBMAJOR}
++	ln -s ${SHLIBARCHIVE} ${SHLIBSHORT}
++
+ # Compile executable
+-${LIBEXEC}: ${LIBARCHIVE} ${LIBRARY}.c
++${LIBEXEC}: ${SHLIBARCHIVE} ${LIBRARY}.c
+ 	${CC} ${LIBRARY}.c -o ${LIBEXEC} ${CFLAGS} ${LIBS}
+ ifneq ($(OS),Windows_NT)
+ 	 chmod a+x ${LIBEXEC}
+@@ -119,8 +128,9 @@ ${LIBRARY}.version: ${LIBEXEC}
+ # ------------- Installation: -------------------------------------------------#
+ install: libversion libinstall execinstall
+ 
+-libinstall: ${LIBARCHIVE}
++libinstall: ${LIBARCHIVE} ${SHAREDLIBARCHIVE}
+ 	${ADDDATE} -i=${LIBRARY}.version -o=${PET_LIB} -nodate -copy ${LIBARCHIVE}
++	${ADDDATE} -i=${LIBRARY}.version -o=${PET_LIB} -nodate -copy ${SHAREDLIBARCHIVE}
+ 
+ execinstall: ${LIBEXEC}
+ 	${ADDDATE} -i=${LIBRARY}.version -o=${PET_BIN} -nodate -copy ${LIBEXEC}
diff --git a/libtpcimgio.spec b/libtpcimgio.spec
index 4be2a27..94e1e71 100644
--- a/libtpcimgio.spec
+++ b/libtpcimgio.spec
@@ -1,12 +1,13 @@
 Name:           libtpcimgio
 Version:        1.5.10
-Release:        3%{?dist}
+Release:        4%{?dist}
 Summary:        Turku PET Centre for image file input and output procedures
 
 License:        LGPLv2+
 URL:            http://www.turkupetcentre.net/software/libdoc/%{name}/index.html
 Source0:        http://www.turkupetcentre.net/software/libsrc/%{name}_1_5_10_src.zip
 Patch0:         %{name}-add-header.patch
+Patch1:         %{name}-shared.patch
 BuildRequires:  libtpcmisc-devel
 BuildRequires:  doxygen dos2unix
 BuildRequires:  graphviz
@@ -21,7 +22,6 @@ partly interfile formats.
 
 %package        devel
 Summary:        Development files for %{name}
-Provides:       %{name}-static = %{version}-%{release}
 Requires:       %{name}%{?_isa} = %{version}-%{release}
 
 %description    devel
@@ -29,9 +29,16 @@ The %{name}-devel package contains libraries and header files for
 developing applications that use %{name}.
 
 
+%package        static
+Summary:        Static libraries for %{name}
+
+%description    static
+This package contains static libraries for %{name}.
+
 %prep
 %setup -q -n %{name}
 %patch0 -p1
+%patch1 -p1 -b .shared
 sed -i "/^CFLAGS/d" Makefile
 
 # Fix encodings and line endings.
@@ -44,9 +51,10 @@ iconv -f ISO_8859-1 -t utf8 -o History.new History && mv -f History.new History
 # includedirs since it doesn't find them on their own
 # the _XOPEN_SOURCE for timezone declaration
 # undefine STRICT_ANSI since c99 sets it, and it conflicts with the strings.h declaration
+# PIC for shared objects
 
-export CFLAGS="%{optflags} -std=c99 -Iinclude/ -I%{_includedir}/libtpcmisc/ -D_XOPEN_SOURCE -U__STRICT_ANSI__"
-export CXXFLAGS="%{optflags}"
+export CFLAGS="%{optflags} -std=c99 -Iinclude/ -I%{_includedir}/libtpcmisc/ -D_XOPEN_SOURCE -U__STRICT_ANSI__ -fPIC -DPIC"
+export CXXFLAGS="%{optflags} -fPIC -DPIC"
 make %{?_smp_mflags}
 
 # Build doxygen documentation
@@ -62,18 +70,35 @@ install -d $RPM_BUILD_ROOT%{_bindir}
 
 install -p -m 0755 %{name} -t $RPM_BUILD_ROOT%{_bindir}/
 install -p -m 0644 %{name}.a -t $RPM_BUILD_ROOT%{_libdir}/
+install -p -m 0755 %{name}.so.0.0.0 -t $RPM_BUILD_ROOT%{_libdir}/
 install -p -m 0644 include/*.h $RPM_BUILD_ROOT%{_includedir}/%{name}/
 
+pushd $RPM_BUILD_ROOT%{_libdir}/
+ln -s %{name}.so.0.0.0 %{name}.so.0
+ln -s %{name}.so.0.0.0 %{name}.so
+popd
+
+%post -p /sbin/ldconfig
+%postun -p /sbin/ldconfig
+
 %files
 %doc History Readme TODO
 %{_bindir}/%{name}
+%{_libdir}/%{name}.so.*
 
 %files devel
 %doc doc/%{name}/*
-%{_libdir}/%{name}.a
+%{_libdir}/%{name}.so
 %{_includedir}/*
 
+%files static
+%{_libdir}/%{name}.a
+
 %changelog
+* Mon Aug 08 2011 Tom Callaway <spot at fedoraproject.org> - 1.5.10-4
+- compile with -fPIC so that xmedcon can use it in shared libs later
+- build shared libs, put static libs in separate subpackage
+
 * Mon Aug 01 2011 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 1.5.10-3
 - Add graphviz to BR
 


More information about the scm-commits mailing list