From 3ab5e95f2fe2358ccae0a7c1e52b1b3b910140cf Mon Sep 17 00:00:00 2001
From: Raul Infante-Sainz <infantesainz@gmail.com>
Date: Tue, 16 Apr 2019 07:42:36 +0100
Subject: Astrometry-net and all its dependencies are now in the project

With this commit, we include Astrometry-net software and one remaining
dependency of it (Swig). In principle it should work as far as we tested
all of this software in GNU/Linux, but we need to test also in Mac OS.

As a result, this commit is just for setting all the rules and
dependencies, but more tests are necessaries to ensure it works
properly, specially in Mac OS systems.
---
 reproduce/software/bibtex/astrometry-net.tex       | 25 +++++++++++
 reproduce/software/config/installation/versions.mk |  2 +
 reproduce/software/make/high-level.mk              | 51 +++++++++++++++++++---
 3 files changed, 72 insertions(+), 6 deletions(-)
 create mode 100644 reproduce/software/bibtex/astrometry-net.tex

(limited to 'reproduce')

diff --git a/reproduce/software/bibtex/astrometry-net.tex b/reproduce/software/bibtex/astrometry-net.tex
new file mode 100644
index 0000000..7e8d0be
--- /dev/null
+++ b/reproduce/software/bibtex/astrometry-net.tex
@@ -0,0 +1,25 @@
+%% Copyright (C) 2019 Raul Infante-Sainz <infantesainz@gmail.com>
+%%
+%% Copying and distribution of this file, with or without modification,
+%% are permitted in any medium without royalty provided the copyright
+%% notice and this notice are preserved.  This file is offered as-is,
+%% without any warranty.
+
+@ARTICLE{astrometrynet2010,
+       author = {{Lang}, Dustin and {Hogg}, David W. and {Mierle}, Keir and
+         {Blanton}, Michael and {Roweis}, Sam},
+        title = "{Astrometry.net: Blind Astrometric Calibration of Arbitrary Astronomical Images}",
+      journal = {\aj},
+     keywords = {astrometry, catalogs, instrumentation: miscellaneous, methods: data analysis, methods: statistical, techniques: image processing, Astrophysics - Instrumentation and Methods for Astrophysics},
+         year = "2010",
+        month = "May",
+       volume = {139},
+       number = {5},
+        pages = {1782},
+          doi = {10.1088/0004-6256/139/5/1782},
+archivePrefix = {arXiv},
+       eprint = {0910.2233},
+ primaryClass = {astro-ph.IM},
+       adsurl = {https://ui.adsabs.harvard.edu/abs/2010AJ....139.1782L},
+      adsnote = {Provided by the SAO/NASA Astrophysics Data System}
+}
diff --git a/reproduce/software/config/installation/versions.mk b/reproduce/software/config/installation/versions.mk
index 557eec2..5f686a8 100644
--- a/reproduce/software/config/installation/versions.mk
+++ b/reproduce/software/config/installation/versions.mk
@@ -17,6 +17,7 @@
 # <http://www.gnu.org/licenses/>.
 
 # C/C++ programs and libraries.
+astrometry-version         = 0.77
 atlas-version              = 3.10.3
 bash-version               = 5.0
 binutils-version           = 2.31.1
@@ -65,6 +66,7 @@ pkgconfig-version          = 0.29.2
 python-version             = 3.7.3
 readline-version           = 8.0
 sed-version                = 4.7
+swig-version               = 3.0.12
 tar-version                = 1.32
 unzip-version              = 6.0
 wget-version               = 1.20.3
diff --git a/reproduce/software/make/high-level.mk b/reproduce/software/make/high-level.mk
index 8aa9c55..932aedc 100644
--- a/reproduce/software/make/high-level.mk
+++ b/reproduce/software/make/high-level.mk
@@ -51,7 +51,7 @@ ipydir  = $(BDIR)/software/installed/version-info/python
 # successfully on Mac (only static) and GNU/Linux (shared and static). But,
 # since it takes a few hours to build, it is not currently a target.
 top-level-libraries = # atlas
-top-level-programs  = gnuastro metastore netpbm
+top-level-programs  = astrometry-net gnuastro metastore
 top-level-python    = astroquery matplotlib
 all: $(foreach p, $(top-level-libraries), $(ilidir)/$(p)) \
      $(foreach p, $(top-level-programs),  $(ibidir)/$(p)) \
@@ -114,7 +114,8 @@ include reproduce/software/make/python.mk
 # convention, but include the name/version in their tarball names with
 # another format, we'll do the modification before the download so the
 # downloaded file has our desired format.
-tarballs = $(foreach t, cfitsio-$(cfitsio-version).tar.gz                  \
+tarballs = $(foreach t, astrometry.net-$(astrometry-version).tar.gz        \
+                        cfitsio-$(cfitsio-version).tar.gz                  \
                         atlas-$(atlas-version).tar.bz2                     \
                         cairo-$(cairo-version).tar.bz2                     \
                         cmake-$(cmake-version).tar.gz                      \
@@ -138,6 +139,7 @@ tarballs = $(foreach t, cfitsio-$(cfitsio-version).tar.gz                  \
                         openmpi-$(openmpi-version).tar.gz                  \
                         openblas-$(openblas-version).tar.gz                \
                         pixman-$(pixman-version).tar.gz                    \
+                        swig-$(swig-version).tar.gz                        \
                         tiff-$(libtiff-version).tar.gz                     \
                         wcslib-$(wcslib-version).tar.bz2                   \
                       , $(tdir)/$(t) )
@@ -161,6 +163,7 @@ $(tarballs): $(tdir)/%: | $(lockdir)
 	                                 : (l==2 ? "%d00\n"           \
                                             : "%d000\n") ), $$1)}')
 	    w=https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio$$v.tar.gz
+	  elif [ $$n = astrometry  ]; then w=http://astrometry.net/downloads
 	  elif [ $$n = atlas       ]; then
 	    mergenames=0
 	    w=https://sourceforge.net/projects/math-atlas/files/Stable/$(atlas-version)/atlas$(atlas-version).tar.bz2/download
@@ -203,6 +206,7 @@ $(tarballs): $(tdir)/%: | $(lockdir)
 	    majorver=$$(echo $(openmpi-version) | sed -e 's/\./ /g' | awk '{printf("%d.%d", $$1, $$2)}')
 	    w=https://download.open-mpi.org/release/open-mpi/v$$majorver/$*
 	  elif [ $$n = pixman      ]; then w=https://www.cairographics.org/releases
+	  elif [ $$n = swig        ]; then w=https://sourceforge.net/projects/swig/files/swig/swig-$(swig-version)
 	  elif [ $$n = tiff        ]; then w=https://download.osgeo.org/libtiff
 	  elif [ $$n = wcslib      ]; then w=ftp://ftp.atnf.csiro.au/pub/software/wcslib
 	  else
@@ -495,6 +499,35 @@ $(ilidir)/wcslib: $(tdir)/wcslib-$(wcslib-version).tar.bz2 \
 # Programs
 # --------
 #
+# Astrometry-net contains a lot of programs. We need to specify the
+# installation directory and the Python executable (by default it will look
+# for /usr/bin/python)
+$(ibidir)/astrometry-net: $(tdir)/astrometry.net-$(astrometry-version).tar.gz \
+                          $(ilidir)/cairo                                     \
+                          $(ilidir)/cfitsio                                   \
+                          $(ilidir)/gsl                                       \
+                          $(ilidir)/libjpeg                                   \
+                          $(ilidir)/libpng                                    \
+                          $(ibidir)/netpbm                                    \
+                          $(ipydir)/numpy                                     \
+                          $(ibidir)/python                                    \
+                          $(ibidir)/swig                                      \
+                          $(ilidir)/wcslib
+	cd $(ddir)                                                            \
+    && if ! tar xf $<; then echo; echo "Tar error"; exit 1; fi            \
+    && cd astrometry.net-$(astrometry-version)                            \
+    && make                                                               \
+    && make py                                                            \
+    && make extra                                                         \
+    && make install INSTALL_DIR=$(idir) PYTHON_SCRIPT="$(ibdir)/python"   \
+    && cd ..                                                              \
+    && rm -rf astrometry.net-$(astrometry-version)                        \
+	&& cp $(dtexdir)/astrometry-net.tex $(ictdir)/                        \
+    && echo "Astrometry-net $(astrometry-version)" > $@
+
+
+
+
 # CMake can be built with its custom `./bootstrap' script.
 $(ibidir)/cmake: $(tdir)/cmake-$(cmake-version).tar.gz \
                  $(ibidir)/curl
@@ -664,19 +697,25 @@ $(ibidir)/netpbm: $(tdir)/netpbm-$(netpbm-version).tgz   \
     fi;                                                                    \
     cd $(ddir)                                                             \
     && unpackdir=netpbm-$(netpbm-version)                                  \
-    && echo "rm -rf $$unpackdir                                            \
-    && if ! tar xf $<; then echo; echo "Tar error"; exit 1; fi"            \
+    && rm -rf $$unpackdir                                                  \
+    && if ! tar xf $<; then echo; echo "Tar error"; exit 1; fi             \
     && cd $$unpackdir                                                      \
-    && echo "printf "$$answers" | ./configure                              \
+    && printf "$$answers" | ./configure                                    \
     && make                                                                \
     && rm -rf $(ddir)/$$unpackdir/install                                  \
-    && make package pkgdir=$(ddir)/$$unpackdir/install"                    \
+    && make package pkgdir=$(ddir)/$$unpackdir/install                     \
     && printf "$(ddir)/$$unpackdir/install\n$(idir)\n\n\nN\n\n\n\n\nN\n\n" \
               | ./installnetpbm                                            \
     && cd ..                                                               \
     && rm -rf $$unpackdir                                                  \
     && echo "Netpbm $(netpbm-version)" > $@
 
+$(ibidir)/swig: $(tdir)/swig-$(swig-version).tar.gz
+	# Option --without-pcre was a suggestion once the configure step was
+	# tried and it failed. It was not recommended but it works!
+	# pcr is a dependency of swig
+	$(call gbuild, $<, swig-$(swig-version), static, --without-pcre) \
+	&& echo "Swig $(swig-version)" > $@
 
 
 
-- 
cgit v1.2.1