From 335f05386ff8712da2f29a504a4fa42050580b79 Mon Sep 17 00:00:00 2001
From: Raul Infante-Sainz <infantesainz@gmail.com>
Date: Tue, 16 Apr 2019 07:08:00 +0100
Subject: Netpbm and its dependencies are now included

With this commit, the installation of `netpbm' has been included. This
software has a crazy dialogue installation that we override by giving to
it the answers (they differs on GNU/Linux and Mac OS systems). `libxml2'
also has been built (a remaining dependency of `netpbm').

In this commit, `libpng' version has been downgraded because it is
required by `netpbm'.

The motivation of installing `netpbm' is that it is a dependency of
Astrometry-net software.
---
 reproduce/software/config/installation/versions.mk |  7 ++-
 reproduce/software/make/high-level.mk              | 61 ++++++++++++++++++----
 2 files changed, 55 insertions(+), 13 deletions(-)

(limited to 'reproduce/software')

diff --git a/reproduce/software/config/installation/versions.mk b/reproduce/software/config/installation/versions.mk
index 81acacf..557eec2 100644
--- a/reproduce/software/config/installation/versions.mk
+++ b/reproduce/software/config/installation/versions.mk
@@ -45,9 +45,9 @@ isl-version                = 0.18
 libbsd-version             = 0.9.1
 libffi-version             = 3.2.1
 libjpeg-version            = v9b
-libpng-version             = 1.6.36
 libtiff-version            = 4.0.10
 libtool-version            = 2.4.6
+libxml2-version            = 2.9.9
 lzip-version               = 1.20
 m4-version                 = 1.4.18
 make-version               = 4.2.90
@@ -55,6 +55,7 @@ metastore-version          = 1.1.2-23-fa9170b
 mpfr-version               = 4.0.2
 mpc-version                = 1.1.0
 ncurses-version            = 6.1
+netpbm-version             = 10.47.72
 openblas-version           = 0.3.5
 openmpi-version            = 4.0.1
 openssl-version            = 1.1.1a
@@ -77,10 +78,12 @@ zlib-version               = 1.2.11
 #
 # When updating the version of these libraries, please look into the build
 # rule first: In one way or another, the version string becomes necessary
-# during their build and must be accounted for.
+# during their build and must be accounted for. In particular:
+#  `libpng' is downgraded because `netpbm' requires `libpng' version < 1.5
 bzip2-version              = 1.0.6
 lapack-version             = 3.8.0
 libgit2-version            = 0.26.0
+libpng-version             = 1.4.22
 wcslib-version             = 6.2
 
 # Python packages
diff --git a/reproduce/software/make/high-level.mk b/reproduce/software/make/high-level.mk
index 04b6cac..8aa9c55 100644
--- a/reproduce/software/make/high-level.mk
+++ b/reproduce/software/make/high-level.mk
@@ -50,9 +50,9 @@ ipydir  = $(BDIR)/software/installed/version-info/python
 # high level software depend on it. The current rule for ATLAS is tested
 # 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 = cairo pixman # atlas
+top-level-libraries = # atlas
+top-level-programs  = gnuastro metastore netpbm
 top-level-python    = astroquery matplotlib
-top-level-programs  = gnuastro metastore
 all: $(foreach p, $(top-level-libraries), $(ilidir)/$(p)) \
      $(foreach p, $(top-level-programs),  $(ibidir)/$(p)) \
      $(foreach p, $(top-level-python),    $(ipydir)/$(p)) \
@@ -132,7 +132,9 @@ tarballs = $(foreach t, cfitsio-$(cfitsio-version).tar.gz                  \
                         libbsd-$(libbsd-version).tar.xz                    \
                         libpng-$(libpng-version).tar.xz                    \
                         libgit2-$(libgit2-version).tar.gz                  \
+                        libxml2-$(libxml2-version).tar.gz                  \
                         metastore-$(metastore-version).tar.gz              \
+                        netpbm-$(netpbm-version).tar.gz                    \
                         openmpi-$(openmpi-version).tar.gz                  \
                         openblas-$(openblas-version).tar.gz                \
                         pixman-$(pixman-version).tar.gz                    \
@@ -188,7 +190,11 @@ $(tarballs): $(tdir)/%: | $(lockdir)
 	  elif [ $$n = libgit      ]; then
 	    mergenames=0
 	    w=https://github.com/libgit2/libgit2/archive/v$(libgit2-version).tar.gz
+	  elif [ $$n = libxml      ]; then w=ftp://xmlsoft.org/libxml2
 	  elif [ $$n = metastore   ]; then w=http://akhlaghi.org/src
+	  elif [ $$n = netpbm      ]; then
+	    mergenames=0
+		w=https://sourceforge.net/projects/netpbm/files/super_stable/$(netpbm-version)/netpbm-$(netpbm-version).tgz/download
 	  elif [ $$n = openblas    ]; then
 	    mergenames=0
 	    w=https://github.com/xianyi/OpenBLAS/archive/v$(openblas-version).tar.gz
@@ -309,6 +315,17 @@ $(ilidir)/libpng: $(tdir)/libpng-$(libpng-version).tar.xz
 	$(call gbuild, $<, libpng-$(libpng-version), static) \
 	&& echo "Libpng $(libpng-version)" > $@
 
+$(ilidir)/libxml2: $(tdir)/libxml2-$(libxml2-version).tar.gz
+       # The libxml2 tarball also contains Python bindings which are built and
+       # installed to a system directory by default. If you don't need the Python
+       # bindings, the easiest solution is to compile without Python support:
+       # ./configure --without-python
+       # If you really need the Python bindings, try the
+       # --with-python-install-dir=DIR option
+       $(call gbuild, $<, libxml2-$(libxml2-version), static, \
+                      --without-python)                       \
+       && echo "Libxml2 $(libxml2-version)" > $@
+
 $(ilidir)/pixman: $(tdir)/pixman-$(pixman-version).tar.gz
        $(call gbuild, $<, pixman-$(pixman-version), static) \
        && echo "Pixman $(pixman-version)" > $@
@@ -628,15 +645,37 @@ endif
 	&& cp $(dtexdir)/gnuastro.tex $(ictdir)/                 \
 	&& echo "GNU Astronomy Utilities $(gnuastro-version) \citep{gnuastro}" > $@
 
-
-
-
-
-
-
-
-
-
+# Netpbm is a prerequisite of Astrometry-net, it contains a lot of programs.
+# This program has a crazy dialogue installation which is override using the
+# printf statment. Each `\n' is a new question that the installation process
+# ask to the user. We give all answers with a pipe to the scripts (configure
+# and install). The questions are different depending on the system (tested
+# on GNU/Linux and Mac OS).
+$(ibidir)/netpbm: $(tdir)/netpbm-$(netpbm-version).tgz   \
+                  $(ilidir)/libjpeg                      \
+                  $(ilidir)/libpng                       \
+                  $(ilidir)/libtiff                      \
+                  $(ilidir)/libxml2                      \
+                  $(ibidir)/unzip
+	if [ x$(on_mac_os) = xyes ]; then                                      \
+      answers='\n\n\n\n\n\n\n\n\n\n\n\nnone\n\n\n';                        \
+    else                                                                   \
+      answers='\n\n\n\ny\n\n\n\n\n\n\n\n\n\n\n\n\n';                       \
+    fi;                                                                    \
+    cd $(ddir)                                                             \
+    && unpackdir=netpbm-$(netpbm-version)                                  \
+    && echo "rm -rf $$unpackdir                                            \
+    && if ! tar xf $<; then echo; echo "Tar error"; exit 1; fi"            \
+    && cd $$unpackdir                                                      \
+    && echo "printf "$$answers" | ./configure                              \
+    && make                                                                \
+    && rm -rf $(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)" > $@
 
 
 
-- 
cgit v1.2.1