[lrslib] Initial import.

Jerry James jjames at fedoraproject.org
Fri Mar 2 15:50:55 UTC 2012


commit cedfb60bcf5453fecc49f7b73ee787f78fa6a997
Author: Jerry James <loganjerry at gmail.com>
Date:   Fri Mar 2 08:50:49 2012 -0700

    Initial import.

 .gitignore         |    2 +
 lrslib-fixes.patch |  127 ++++++++++++++++++++++++++++++++++++++++
 lrslib.spec        |  164 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 sources            |    2 +
 4 files changed, 295 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e69de29..0fd736b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/lrslib-042c.tar.gz
+/lrslib-man.tar.xz
diff --git a/lrslib-fixes.patch b/lrslib-fixes.patch
new file mode 100644
index 0000000..928f5e5
--- /dev/null
+++ b/lrslib-fixes.patch
@@ -0,0 +1,127 @@
+--- ./lrsgmp.c.orig	2009-09-10 12:40:50.000000000 -0600
++++ ./lrsgmp.c	2009-09-10 12:40:50.000000000 -0600
+@@ -7,6 +7,7 @@
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <string.h>
+ #include "lrsgmp.h"
+ 
+ long lrs_digits;		/* max permitted no. of digits   */
+--- ./2gnash.c.orig	2009-09-10 12:40:50.000000000 -0600
++++ ./2gnash.c	2009-09-10 12:40:50.000000000 -0600
+@@ -8,6 +8,7 @@
+        #include <stdlib.h>
+        #include <unistd.h>
+        #include <stdio.h>
++       #include <fcntl.h>
+ 
+        int main(int argc, char *argv[])
+ 	       {
+@@ -27,14 +28,16 @@
+ 		      if(cpid[l-1] == 0) {
+ 			 //forked threads
+ 			// n= sprintf(buffer, "lrs %s > out%i", argv[l], l);
++                         int n = sprintf(buffer, "out%i", l);
++			 int fd = creat(buffer, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
++                         dup2(fd, 1);
+                          if(l==1) {
+-                              int n= sprintf(buffer, "gnash %s %s > out%i", argv[1], argv[2], l);
++                              execlp("lrs-nash", "lrs-nash", argv[1], argv[2], NULL);
+                          }
+                          else     {
+-                              int n= sprintf(buffer, "gnash %s %s > out%i", argv[2], argv[1], l);
++                              execlp("lrs-nash", "lrs-nash", argv[2], argv[1], NULL);
+                          }
+ 
+-			 int i=system(buffer);
+                           _exit(0);
+ 		      }
+ 		  }
+@@ -44,24 +47,24 @@
+ 		      if(w == cpid[j-1]) {
+ 			  // this child finished first
+                           if(j==1)
+-			      printf("gnash %s %s   finished first\n", argv[1], argv[2]);
++			      printf("lrs-nash %s %s   finished first\n", argv[1], argv[2]);
+                           else {
+-			      printf("gnash %s %s   finished first\n", argv[2], argv[1]);
++			      printf("lrs-nash %s %s   finished first\n", argv[2], argv[1]);
+ 			      printf("player numbers will be reversed in output\n");
+                                }
++                           int n = sprintf(buffer, "out%i", j);
+                            if(argc == 4) {
+ 			       printf("output file: %s\n", argv[3]);
+-			       int n = sprintf(buffer, "/bin/mv -f out%i %s", j, argv[3]);
++                               rename(buffer, argv[3]);
+                            }
+                            else  {
+-			        printf("output file: out\n", argv[2], argv[1]);
+-			        int n = sprintf(buffer, "/bin/mv -f out%i out", j);
++			        printf("output file: out\n");
++                                rename(buffer, "out");
+                            }
+-			  int i = system(buffer);
+ 		      } else {
+ 			 // printf("terminating lrs of file %s\n", argv[j]);
+-			  int n = sprintf(buffer, "/bin/rm -f out%i", j);
+-			  int i = system(buffer);
++                          int n = sprintf(buffer, "out%i", j);
++                          unlink(buffer);
+ 		      }
+ 		  }
+                   printf("the other process will be ");   /*...will be killed */
+--- ./lrslong.c.orig	2009-09-10 12:40:50.000000000 -0600
++++ ./lrslong.c	2009-09-10 12:40:50.000000000 -0600
+@@ -7,6 +7,7 @@
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <string.h>
+ #include "lrslong.h"
+ 
+ long digits;
+--- ./buffer.c.orig	2009-09-10 12:40:52.000000000 -0600
++++ ./buffer.c	2009-09-10 12:40:52.000000000 -0600
+@@ -70,7 +70,7 @@ main(int argc, char *argv[])
+ /* getline from KR P.32 */
+ int Getline(void)
+ {
+-	int c,i;
++	int c=EOF,i;
+ 	extern int maxline;
+         extern char *line;
+ 
+--- ./lrslib.html.orig	2009-09-10 12:40:50.000000000 -0600
++++ ./lrslib.html	2009-09-10 12:40:50.000000000 -0600
+@@ -145,7 +145,7 @@ of the driver, and does basic setup func
+ some information about version numer or lrslib and which arithmetic package
+ is used. FALSE is returned in case of failure.</font></blockquote>
+ 
+-<p><br><font color="#990000">lrs_dat&nbsp; *lrs_alloc_dat (char *name);&nbsp;&nbsp;&nbsp;
++<p><br><font color="#990000">lrs_dat&nbsp; *lrs_alloc_dat (const char *name);&nbsp;&nbsp;&nbsp;
+ /* allocate for lrs_dat structure "name"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+ */</font>
+ <br>&nbsp;
+--- ./lrslib.h.orig	2010-07-07 01:58:36.000000000 -0600
++++ ./lrslib.h	2010-07-07 01:58:36.000000000 -0600
+@@ -218,7 +218,7 @@ extern lrs_dic *PBnew;    /* we will sav
+ long lrs_main (int argc, char *argv[]);    /* lrs driver, argv[1]=input file, [argc-1]=output file */
+ long redund_main (int argc, char *argv[]); /* redund driver, argv[1]=input file, [2]=output file */
+ 
+-lrs_dat *lrs_alloc_dat (char *name);	/* allocate for lrs_dat structure "name"       */
++lrs_dat *lrs_alloc_dat (const char *name);	/* allocate for lrs_dat structure "name"       */
+ lrs_dic *lrs_alloc_dic (lrs_dat * Q);	/* allocate for lrs_dic structure corr. to Q   */
+ 
+ void lrs_estimate (lrs_dic * P, lrs_dat * Q);	/* get estimates only                          */
+--- ./lrslib.c.orig	2010-07-07 01:48:44.000000000 -0600
++++ ./lrslib.c	2010-07-07 01:48:44.000000000 -0600
+@@ -558,7 +558,7 @@ lrs_close (char *name)
+ /* allocate and initialize lrs_dat */
+ /***********************************/
+ lrs_dat *
+-lrs_alloc_dat (char *name)
++lrs_alloc_dat (const char *name)
+ {
+   lrs_dat *Q;
+   long i;
diff --git a/lrslib.spec b/lrslib.spec
new file mode 100644
index 0000000..bc63e92
--- /dev/null
+++ b/lrslib.spec
@@ -0,0 +1,164 @@
+Name:           lrslib
+Version:        4.2c
+Release:        3%{?dist}
+Summary:        Reverse search for vertex enumeration/convex hull problems
+
+%global upver 0%(echo %{version} | sed 's/\\.//')
+
+License:        GPLv2+
+URL:            http://cgm.cs.mcgill.ca/~avis/C/lrs.html
+Source0:        http://cgm.cs.mcgill.ca/~avis/C/%{name}/%{name}-%{upver}.tar.gz
+# These man pages were written by Jerry James.  Text from the sources was used,
+# therefore the man pages have the same copyright and license as the sources.
+Source1:        %{name}-man.tar.xz
+# This patch was sent upstream on 31 May 2011.  It fixes some miscellaneous
+# bugs and adapts to the naming scheme we choose for installation.
+Patch0:         %{name}-fixes.patch
+
+BuildRequires:  gmp-devel
+
+%description
+%{name} is a self-contained ANSI C implementation as a callable library
+of the reverse search algorithm for vertex enumeration/convex hull
+problems and comes with a choice of three arithmetic packages.  Input
+file formats are compatible with Komei Fukuda's cdd package (cddlib).
+All computations are done exactly in either multiple precision or fixed
+integer arithmetic.  Output is not stored in memory, so even problems
+with very large output sizes can sometimes be solved.
+
+%package devel
+Summary:        Header files and libraries for developing with %{name}
+Requires:       %{name}%{?_isa} = %{version}-%{release}
+Requires:       gmp-devel%{?_isa}
+
+%description devel
+Header files and libraries for developing with %{name}.
+
+%package utils
+Summary:        Sample programs that use %{name}
+Requires:       %{name}%{?_isa} = %{version}-%{release}
+
+%description utils
+Sample programs that use %{name}.
+
+%prep
+%setup -q -n %{name}-%{upver}
+%setup -q -n %{name}-%{upver} -T -D -a 1
+%patch0
+
+# Fix the FSF's address
+for f in COPYING lrsgmp.h lrslib.{c,h} lrslong.h lrsmp.{c,h}; do
+  sed -i.orig \
+    's/675 Mass Ave, Cambridge, MA 02139/51 Franklin Street, Suite 500, Boston, MA  02110-1335/' \
+    $f
+  touch -r $f.orig $f
+  rm -f $f.orig
+done
+
+%build
+# The Makefile is too primitive to use.  For one thing, it only builds
+# binaries, not libraries.  We do our own thing here.
+
+# Extract the version numbers to be used for the shared libraries.
+%global ver %(echo %{version} | sed -r 's/([\\\.[:digit:]]*)[[:alpha:]]/\\\1/')
+%global sover %(echo %{version} | cut -d. -f1)
+
+CFLAGS="${RPM_OPT_FLAGS} -DTIMES -DSIGNALS"
+if [ %{__isa_bits} = "64" ]; then
+  CFLAGS+=" -DB64"
+fi
+
+# Build the GMP version of the library
+gcc $CFLAGS -DGMP -fPIC -shared -o liblrsgmp.so.%{ver} \
+    -Wl,-soname,liblrsgmp.so.%{sover} lrslib.c lrsgmp.c -lgmp
+ln -s liblrsgmp.so.%{ver} liblrsgmp.so.%{sover}
+ln -s liblrsgmp.so.%{sover} liblrsgmp.so
+
+# Build the integer version of the library
+gcc $CFLAGS -DLONG -fPIC -shared -o liblrslong.so.%{ver} \
+    -Wl,-soname,liblrslong.so.%{sover} lrslib.c lrslong.c
+ln -s liblrslong.so.%{ver} liblrslong.so.%{sover}
+ln -s liblrslong.so.%{sover} liblrslong.so
+
+# Build the multi-precision version of the library
+gcc $CFLAGS -DLRSMP -fPIC -shared -o liblrsmp.so.%{ver} \
+    -Wl,-soname,liblrsmp.so.%{sover} lrslib.c lrsmp.c
+ln -s liblrsmp.so.%{ver} liblrsmp.so.%{sover}
+ln -s liblrsmp.so.%{sover} liblrsmp.so
+
+# Build the binaries against the GMP version of the library, except rat2float
+gcc $CFLAGS -DGMP lrs.c -o lrs -L. -llrsgmp
+gcc $CFLAGS -DGMP redund.c -o lrs-redund -L. -llrsgmp
+gcc $CFLAGS -DGMP nash.c -o lrs-nash -L. -llrsgmp -lgmp
+gcc $CFLAGS -DGMP fourier.c -o lrs-fourier -L. -llrsgmp -lgmp
+gcc $CFLAGS -DGMP setupnash.c -o lrs-setupnash -L. -llrsgmp
+gcc $CFLAGS -DGMP setupnash2.c -o lrs-setupnash2 -L. -llrsgmp
+gcc $CFLAGS -DLRSMP rat2float.c -o lrs-rat2float -L. -llrsmp
+gcc $CFLAGS float2rat.c -o lrs-float2rat
+gcc $CFLAGS buffer.c -o lrs-buffer
+gcc $CFLAGS 2gnash.c -o lrs-2gnash
+
+%install
+# Install the libraries
+mkdir -p $RPM_BUILD_ROOT%{_libdir}
+cp -a liblrs*.so* $RPM_BUILD_ROOT%{_libdir}
+
+# Install the binaries
+mkdir -p $RPM_BUILD_ROOT%{_bindir}
+cp -p lrs lrs-* $RPM_BUILD_ROOT%{_bindir}
+
+# Install the header files, but alter them to reflect 32-/64-bitness and fix
+# up the include directives.
+mkdir -p $RPM_BUILD_ROOT%{_includedir}/%{name}
+if [ %{__isa_bits} = "64" ]; then
+  sed -r -e 's|"(lrs.*\.h)"|<lrslib/\1>|' \
+      -e "s|#include ARITH|#define B64\\n#include ARITH|" \
+      lrslib.h > $RPM_BUILD_ROOT%{_includedir}/%{name}/lrslib.h
+else
+  sed -r 's|"(lrs.*\.h)"|<lrslib/\1>|' lrslib.h > \
+      $RPM_BUILD_ROOT%{_includedir}/%{name}/lrslib.h
+fi
+touch -r lrslib.h $RPM_BUILD_ROOT%{_includedir}/%{name}/lrslib.h
+
+sed -e 's|"gmp.h"|<gmp.h>|' lrsgmp.h > \
+    $RPM_BUILD_ROOT%{_includedir}/%{name}/lrsgmp.h
+touch -r lrsgmp.h $RPM_BUILD_ROOT%{_includedir}/%{name}/lrsgmp.h
+
+cp -p lrslong.h lrsmp.h $RPM_BUILD_ROOT%{_includedir}/%{name}
+
+# Install the man pages
+mkdir -p $RPM_BUILD_ROOT%{_mandir}/man1
+cd man
+for f in *.1; do
+  sed "s/@VERSION@/%{upver}/" $f > $RPM_BUILD_ROOT%{_mandir}/man1/$f
+  touch -r $f $RPM_BUILD_ROOT%{_mandir}/man1/$f
+done
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%doc COPYING readme
+%{_libdir}/*.so.*
+
+%files devel
+%doc lrslib.html chdemo.c lpdemo.c vedemo.c
+%{_includedir}/%{name}
+%{_libdir}/*.so
+
+%files utils
+%{_bindir}/lrs*
+%{_mandir}/man1/lrs*
+
+%changelog
+* Tue Feb 14 2012 Jerry James <loganjerry at gmail.com> - 4.2c-3
+- Change subpackage structure based on review
+
+* Wed Aug 24 2011 Jerry James <loganjerry at gmail.com> - 4.2c-2
+- Use %%{name} more liberally.
+- Use %%global instead of %%define.
+- Add man pages.
+
+* Wed Jul 20 2011 Jerry James <loganjerry at gmail.com> - 4.2c-1
+- Initial RPM
diff --git a/sources b/sources
index e69de29..4814bf3 100644
--- a/sources
+++ b/sources
@@ -0,0 +1,2 @@
+0503707c4e17506d480f913602f401c0  lrslib-042c.tar.gz
+6d96329a9bd4d8101402444d71482084  lrslib-man.tar.xz


More information about the scm-commits mailing list