From 69313eb17ed6e57c1cebe448cd2947665b89b783 Mon Sep 17 00:00:00 2001
From: Raul Infante-Sainz <infantesainz@gmail.com>
Date: Mon, 27 May 2019 13:29:29 +0100
Subject: Added Imfit into the project

With this commit, `imfit' has been included into the project. As described
in the official webpage (http://www.mpe.mpg.de/~erwin/code/imfit/):

  Imfit is a program for fitting astronomical images -- especially images
  of galaxies, though it can in principle be used for fitting other
  sources.

This program uses the `scons' program to build itself (not the traditional
GNU `configure' and `make' system). I have tested it by using an example
that can be found in the `examples' directory of the decompressed
tarball. It works fine without any error on my Mac OS system.
---
 .file-metadata                                     | Bin 6829 -> 6975 bytes
 reproduce/software/config/installation/TARGETS.mk  |   2 +-
 reproduce/software/config/installation/versions.mk |   1 +
 reproduce/software/make/high-level.mk              |  30 +++++++++++++++++++++
 4 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/.file-metadata b/.file-metadata
index 72269a2..bfd6676 100644
Binary files a/.file-metadata and b/.file-metadata differ
diff --git a/reproduce/software/config/installation/TARGETS.mk b/reproduce/software/config/installation/TARGETS.mk
index 5bccf97..2b61109 100644
--- a/reproduce/software/config/installation/TARGETS.mk
+++ b/reproduce/software/config/installation/TARGETS.mk
@@ -36,7 +36,7 @@
 
 
 # Programs and libraries.
-top-level-programs  = gnuastro scons
+top-level-programs  = gnuastro imfit
 
 # Python libraries/modules.
 top-level-python    = astropy
diff --git a/reproduce/software/config/installation/versions.mk b/reproduce/software/config/installation/versions.mk
index fa3c5e8..0783a5f 100644
--- a/reproduce/software/config/installation/versions.mk
+++ b/reproduce/software/config/installation/versions.mk
@@ -82,6 +82,7 @@ gnuastro-version = 0.9
 gsl-version = 2.5
 hdf5-version = 1.10.5
 imagemagick-version = 7.0.8-46
+imfit-version = 1.6.1
 libffi-version = 3.2.1
 libjpeg-version = v9b
 libpng-version = 1.6.37
diff --git a/reproduce/software/make/high-level.mk b/reproduce/software/make/high-level.mk
index 14c4a2a..ae0a857 100644
--- a/reproduce/software/make/high-level.mk
+++ b/reproduce/software/make/high-level.mk
@@ -119,6 +119,7 @@ tarballs = $(foreach t, astrometry.net-$(astrometrynet-version).tar.gz \
                         gsl-$(gsl-version).tar.gz \
                         hdf5-$(hdf5-version).tar.gz \
                         imagemagick-$(imagemagick-version).tar.xz \
+                        imfit-$(imfit-version).tar.gz \
                         install-tl-unx.tar.gz \
                         jpegsrc.$(libjpeg-version).tar.gz \
                         lapack-$(lapack-version).tar.gz \
@@ -182,6 +183,9 @@ $(tarballs): $(tdir)/%: | $(lockdir)
 	  elif [ $$n = imagemagick ]; then
 	    mergenames=0
 	    w=https://www.imagemagick.org/download/releases/ImageMagick-$(imagemagick-version).tar.xz
+	  elif [ $$n = imfit       ]; then
+	    mergenames=0
+	    w=http://www.mpe.mpg.de/~erwin/resources/imfit/imfit-$(imfit-version)-source.tar.gz
 	  elif [ $$n = install     ]; then w=http://mirror.ctan.org/systems/texlive/tlnet
 	  elif [ $$n = jpegsrc     ]; then w=http://ijg.org/files
 	  elif [ $$n = lapack      ]; then w=http://www.netlib.org/lapack
@@ -612,6 +616,32 @@ $(ibidir)/imagemagick: $(tdir)/imagemagick-$(imagemagick-version).tar.xz \
 		       --without-x --disable-openmp, V=1) \
 	&& echo "ImageMagick $(imagemagick-version)" > $@
 
+# `imfit doesn't use the traditional `configure' and `make' to install it.
+# Instead of that, it uses `scons'. As a consecuence, the installation is
+# manually done by decompressing the tarball, and running `scons' with the
+# necessary flags. After that, each compiled program (`imfit', `imfit-mcmc'
+# and `makeimage') is copied into the installation directory.'
+$(ibidir)/imfit: $(tdir)/imfit-$(imfit-version).tar.gz \
+                 $(ibidir)/cfitsio \
+                 $(ibidir)/fftw \
+                 $(ibidir)/gsl \
+                 $(ibidir)/scons
+	cd $(ddir) \
+	&& unpackdir=imfit-$(imfit-version) \
+	&& rm -rf $$unpackdir \
+	&& if ! tar xf $<; then echo; echo "Tar error"; exit 1; fi \
+	&& cd $$unpackdir \
+	&& scons --no-openmp --no-nlopt \
+	         --header-path=$(idir)/inlcude --lib-path=$(idir)/lib imfit \
+	&& cp imfit $(ibdir) \
+	&& scons --no-openmp --no-nlopt --header-path=$(idir)/inlcude \
+	         --lib-path=$(idir)/lib imfit-mcmc \
+	&& cp imfit-mcmc $(ibdir) \
+	&& scons --no-openmp --no-nlopt --header-path=$(idir)/inlcude \
+		 --lib-path=$(idir)/lib makeimage \
+	&& cp makeimage $(ibdir) \
+	&& echo "Imfit $(imfit-version)" > $@
+
 # 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
-- 
cgit v1.2.1