diff mbox

Add gctp

Message ID 20160621.083522.189628123526233508.thomas.danckaert@gmail.com
State New
Headers show

Commit Message

Thomas Danckaert June 21, 2016, 6:35 a.m. UTC
Hi Guix,

here's a new patch for gctp.  This one takes the source for gctp 2.0, and patches it to add an autotools build configuration.  I also had to add a patch to remove an override of 'sincos', which leads to an infinite recursion when calling sin/cos/sincos on my system.

Thomas
diff mbox

Patch

From 8b03b2edbaf26ed73001ab13ce2e51a3b9a4df53 Mon Sep 17 00:00:00 2001
From: Thomas Danckaert <thomas.danckaert@gmail.com>
Date: Fri, 17 Jun 2016 10:41:50 +0200
Subject: [PATCH] gnu: Add gctp.

* gnu/packages/maths.cm (gctp): New variable.
* gnu/packages/patches/gctp-autoconfiscate.patch: New file.
* gnu/packages/patches/gctp-sincos.patch: New file.
---
 gnu/packages/maths.scm                         | 38 +++++++++++++
 gnu/packages/patches/gctp-autoconfiscate.patch | 77 ++++++++++++++++++++++++++
 gnu/packages/patches/gctp-sincos.patch         | 22 ++++++++
 3 files changed, 137 insertions(+)
 create mode 100644 gnu/packages/patches/gctp-autoconfiscate.patch
 create mode 100644 gnu/packages/patches/gctp-sincos.patch

diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 3b860a9..0601619 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -42,6 +42,7 @@ 
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system r)
   #:use-module (gnu packages algebra)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages boost)
   #:use-module (gnu packages check)
@@ -408,6 +409,43 @@  plotting engine by third-party applications like Octave.")
     (license (license:fsf-free
               "http://gnuplot.cvs.sourceforge.net/gnuplot/gnuplot/Copyright"))))
 
+(define-public gctp
+  (package
+    (name "gctp")
+    (version "2.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri "http://www.nco.ncep.noaa.gov\
+/pmb/codes/nwprod/util/sorc/wgrib2.cd/grib2/gctpc20.tar.Z")
+       (sha256
+        (base32
+         "0sx69yljdy7r1v4idk7c19vlzplzqnpqf6z1p825l5w0ym1awzi1"))
+       (patches (search-patches "gctp-autoconfiscate.patch"
+                                "gctp-sincos.patch"))
+       ))
+    (native-inputs
+     `(("autoconf" ,autoconf)
+       ("automake" ,automake)
+       ("libtool" ,libtool)))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-before
+             'configure 'autogen
+           (lambda _ (zero? (system* "autoreconf" "--install")))))))
+    (synopsis "General Cartographic Transformation Package (GCTP)")
+    (description
+     "The General Cartographic Transformation Package (GCTP) is a system of
+software routines designed to permit the transformation of coordinate pairs
+from one map projection to another.  The GCTP is the standard computer
+software used by the National Mapping Division for map projection
+computations.")
+    (home-page "http://gcmd.nasa.gov/records/USGS-GCTP.html")
+    (license (license:bsd-style
+              "http://gcmd.nasa.gov/records/USGS-GCTP.html"))))
+
 (define-public hdf5
   (package
     (name "hdf5")
diff --git a/gnu/packages/patches/gctp-autoconfiscate.patch b/gnu/packages/patches/gctp-autoconfiscate.patch
new file mode 100644
index 0000000..83db0bf
--- /dev/null
+++ b/gnu/packages/patches/gctp-autoconfiscate.patch
@@ -0,0 +1,77 @@ 
+From 3f3c27f97edf864d7312e5f43daa386903b839c9 Mon Sep 17 00:00:00 2001
+From: Thomas Danckaert <thomas.danckaert@gmail.com>
+Date: Sat, 18 Jun 2016 17:58:47 +0200
+Subject: [PATCH] Minimal autotools build.
+
+---
+ Makefile.am        |  1 +
+ configure.ac       | 23 +++++++++++++++++++++++
+ source/Makefile.am | 18 ++++++++++++++++++
+ 3 files changed, 42 insertions(+)
+ create mode 100644 Makefile.am
+ create mode 100644 configure.ac
+ create mode 100644 source/Makefile.am
+
+diff --git a/Makefile.am b/Makefile.am
+new file mode 100644
+index 0000000..4b48b24
+--- /dev/null
++++ b/Makefile.am
+@@ -0,0 +1 @@
++SUBDIRS = source
+diff --git a/configure.ac b/configure.ac
+new file mode 100644
+index 0000000..e35d418
+--- /dev/null
++++ b/configure.ac
+@@ -0,0 +1,23 @@
++AC_PREREQ([2.69])
++AC_INIT([gctp], [2.0], [guix-devel@gnu.org])
++AM_INIT_AUTOMAKE(foreign)
++LT_INIT
++AC_CONFIG_SRCDIR([source/cproj.c])
++AC_CONFIG_HEADERS([config.h])
++
++# Checks for programs.
++AC_PROG_CC
++
++# Checks for libraries.
++AC_CHECK_LIB([m], [sin])
++
++# Checks for header files.
++AC_CHECK_HEADERS([stdlib.h string.h])
++
++# Checks for library functions.
++AC_CHECK_FUNCS([pow sqrt])
++
++AC_CONFIG_FILES([Makefile
++        source/Makefile])
++       #          test/test_proj/Makefile])
++AC_OUTPUT
+diff --git a/source/Makefile.am b/source/Makefile.am
+new file mode 100644
+index 0000000..6de94ae
+--- /dev/null
++++ b/source/Makefile.am
+@@ -0,0 +1,18 @@
++lib_LTLIBRARIES = libgctp.la
++
++libgctp_la_SOURCES = gctp.c alberfor.c alberinv.c alconfor.c alconinv.c azimfor.c \
++	  aziminv.c eqconfor.c eqconinv.c equifor.c equiinv.c gnomfor.c \
++	  gnominv.c goodfor.c goodinv.c gvnspfor.c gvnspinv.c hamfor.c \
++	  haminv.c imolwfor.c imolwinv.c lamazfor.c lamazinv.c merfor.c \
++	  merinv.c millfor.c millinv.c molwfor.c molwinv.c obleqfor.c  \
++	  obleqinv.c omerfor.c omerinv.c orthfor.c orthinv.c polyfor.c \
++	  polyinv.c psfor.c psinv.c robfor.c robinv.c sinfor.c sininv.c \
++	  somfor.c sominv.c sterfor.c sterinv.c stplnfor.c stplninv.c \
++	  tmfor.c tminv.c utmfor.c utminv.c vandgfor.c vandginv.c \
++	  wivfor.c wivinv.c wviifor.c wviiinv.c for_init.c inv_init.c \
++	  cproj.c report.c lamccfor.c lamccinv.c paksz.c untfz.c sphdz.c \
++	  br_gctp.c
++
++include_HEADERS = cproj.h proj.h
++
++libgctp_la_LDFLAGS = -release 2.0.0
+-- 
+2.5.0
+
diff --git a/gnu/packages/patches/gctp-sincos.patch b/gnu/packages/patches/gctp-sincos.patch
new file mode 100644
index 0000000..b188fcb
--- /dev/null
+++ b/gnu/packages/patches/gctp-sincos.patch
@@ -0,0 +1,22 @@ 
+Don't override standard math function sincos.
+
+--- a/source/cproj.c	2016-06-20 12:29:19.746105496 +0200
++++ b/source/cproj.c	2016-06-20 12:29:11.782083820 +0200
+@@ -46,7 +46,7 @@
+    than calling each function separately.  It is provided here for those
+    computer systems which don`t implement this function
+   ----------------------------------------------------*/
+-void sincos(val, sin_val, cos_val)
++/*void sincos(val, sin_val, cos_val)
+ double val;
+ double *sin_val;
+ double *cos_val;
+@@ -54,7 +54,7 @@
+ *sin_val = sin(val);
+ *cos_val = cos(val);
+ return;
+-}
++}*/
+ 
+ /* Function to eliminate roundoff errors in asin
+ ----------------------------------------------*/
-- 
2.5.0