[libtpcmisc] shared PIC libs

Tom Callaway spot at fedoraproject.org
Mon Aug 8 18:28:06 UTC 2011


commit 7759786026ced8f44b9042d1f180d4f74f387f6d
Author: Tom "spot" Callaway <tcallawa at redhat.com>
Date:   Mon Aug 8 14:27:56 2011 -0400

    shared PIC libs

 libtpcmisc-shared.patch |   76 +++++++++++++++++++++++++++++++++++++++++++++++
 libtpcmisc.spec         |   37 ++++++++++++++++++----
 2 files changed, 106 insertions(+), 7 deletions(-)
---
diff --git a/libtpcmisc-shared.patch b/libtpcmisc-shared.patch
new file mode 100644
index 0000000..33e2396
--- /dev/null
+++ b/libtpcmisc-shared.patch
@@ -0,0 +1,76 @@
+diff -up libtpcmisc/include/memory_handler.h.shared libtpcmisc/include/memory_handler.h
+--- libtpcmisc/include/memory_handler.h.shared	2010-03-24 07:53:57.000000000 -0400
++++ libtpcmisc/include/memory_handler.h	2011-08-08 14:11:39.726676115 -0400
+@@ -8,6 +8,7 @@
+ #define DEBUG_BUFFER_BORDER 256
+ /*#define DEBUG_MEMORY*/
+ #define DEBUG_BUFFER_VALUE 69
++#define DEBUG 0
+ 
+ int init_memory_handler();
+ void* allocate_memory( int size );
+diff -up libtpcmisc/Makefile.shared libtpcmisc/Makefile
+--- libtpcmisc/Makefile.shared	2010-10-27 08:49:40.000000000 -0400
++++ libtpcmisc/Makefile	2011-08-08 14:12:39.759914041 -0400
+@@ -42,9 +42,12 @@ SOURCES 	= substitutions.c backup.c idcr
+                   petunits.c datetime.c memory_handler.c libtpcmiscv.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 -O2 ${INCLUDE} ${ANSI}
++CFLAGS 		= -std=gnu99 -s -Wall -O2 ${INCLUDE} ${ANSI} -fPIC -DPIC
+ LIBS 		= ${LDFLAGS} -ltpcmisc -L.
+ ZIP		= zip
+ PRVERS		= progvers -opt=-b
+@@ -61,14 +64,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} -lm
++	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)
+@@ -84,8 +93,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 ${SHLIBARCHIVE}
+ 
+ execinstall: ${LIBEXEC}
+ 	${ADDDATE} -i=${LIBRARY}.version -o=${PET_BIN} -nodate -copy ${LIBEXEC}
+diff -up libtpcmisc/memory_handler.c.shared libtpcmisc/memory_handler.c
+--- libtpcmisc/memory_handler.c.shared	2010-03-24 07:53:57.000000000 -0400
++++ libtpcmisc/memory_handler.c	2011-08-08 14:11:39.726676115 -0400
+@@ -60,9 +60,6 @@
+ 
+ #include "include/memory_handler.h"
+ 
+-extern int DEBUG;
+-
+-
+ /** Structure for one-way list to keep track of used memory */
+ struct Memory_handler {
+    /** Pointer to next structure */
diff --git a/libtpcmisc.spec b/libtpcmisc.spec
index c575bbf..4bf4ce8 100644
--- a/libtpcmisc.spec
+++ b/libtpcmisc.spec
@@ -1,13 +1,12 @@
-# Only creates static libraries! :/
-
 Name:           libtpcmisc
 Version:        1.4.8
-Release:        3%{?dist}
+Release:        4%{?dist}
 Summary:        Miscellaneous PET functions
 
 License:        LGPLv2+
 URL:            http://www.turkupetcentre.net/software/libdoc/%{name}/index.html
 Source0:        http://www.turkupetcentre.net/software/libsrc/%{name}_1_4_8_src.zip
+Patch0:         %{name}-shared.patch
 
 BuildRequires:  doxygen dos2unix graphviz
 
@@ -21,15 +20,22 @@ data processing.
 
 %package        devel
 Summary:        Development files for %{name}
-Provides:       %{name}-static = %{version}-%{release}
 Requires:       %{name}%{?_isa} = %{version}-%{release}
 
 %description    devel
 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 -b .shared
 sed -i "/^CFLAGS/d" Makefile
 
 # Fix encodings and line endings.
@@ -39,8 +45,8 @@ iconv -f ISO_8859-1 -t utf8 -o History.new History && mv -f History.new History
 
 %build
 # c99 standard since they use declarations in the for loops
-export CFLAGS="%{optflags} -std=c99"
-export CXXFLAGS="%{optflags}"
+export CFLAGS="%{optflags} -std=c99 -fPIC -DPIC -D_POSIX_C_SOURCE=200112L"
+export CXXFLAGS="%{optflags} -fPIC -DPIC"
 make %{?_smp_mflags}
 
 # Build doxygen documentation
@@ -56,18 +62,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
 %{_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.4.8-4
+- build shared libraries with PIC
+- put static lib in subpackage
+
 * Mon Aug 01 2011 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 1.4.8-3
 - Add graphviz to BR
 


More information about the scm-commits mailing list