From 7a0d4bf2df6c78015b9dd3ec42cfb23d41252ffb Mon Sep 17 00:00:00 2001
From: Raul Infante-Sainz <infantesainz@gmail.com>
Date: Wed, 12 Jun 2019 14:21:10 +0100
Subject: Imfit and libcurl: manually adding rpath on GNU/Linux systems

While trying to debug the installation of Imfit, we found out
that libcurl doesn't have rpath and is thus linking with the
host system's libraries. So rpath is now manually added to the
build of libcurl. We also found out that Imfit executables
don't have rpath, so it was added to them too.
---
 reproduce/software/make/basic.mk      |  6 +++++-
 reproduce/software/make/high-level.mk | 17 +++++++++++++----
 2 files changed, 18 insertions(+), 5 deletions(-)

(limited to 'reproduce/software')

diff --git a/reproduce/software/make/basic.mk b/reproduce/software/make/basic.mk
index b21e7b0..f8963bc 100644
--- a/reproduce/software/make/basic.mk
+++ b/reproduce/software/make/basic.mk
@@ -726,7 +726,8 @@ $(ibidir)/openssl: $(tdir)/openssl-$(openssl-version).tar.gz \
 # this project is avoid dependency on the host as much as possible.
 $(ibidir)/curl: $(tdir)/curl-$(curl-version).tar.gz \
                 $(ibidir)/coreutils \
-                $(ibidir)/openssl #Coreutils: only so cURL is built after it.
+                $(ibidir)/openssl \
+                $(needpatchelf)
 	$(call gbuild, $<, curl-$(curl-version), , \
 	               LIBS="-pthread" \
 	               --with-zlib=$(ildir) \
@@ -744,6 +745,9 @@ $(ibidir)/curl: $(tdir)/curl-$(curl-version).tar.gz \
 	               --disable-ldaps \
 	               --disable-ldap \
 	               --without-nss, V=1) \
+	&& if [ "x$(needpatchelf)" != x ]; then \
+	     $(ibdir)/patchelf --set-rpath $(ildir) $(ildir)/libcurl.so; \
+	   fi
 	&& echo "cURL $(curl-version)" > $@
 
 
diff --git a/reproduce/software/make/high-level.mk b/reproduce/software/make/high-level.mk
index 2ea3534..2924077 100644
--- a/reproduce/software/make/high-level.mk
+++ b/reproduce/software/make/high-level.mk
@@ -158,7 +158,7 @@ $(tarballs): $(tdir)/%: | $(lockdir)
 	                              : (l==3 ? "%d0\n" \
 	                                 : (l==2 ? "%d00\n" \
                                             : "%d000\n") ), $$1)}')
-	    w=https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio$$v.tar.gz
+	    w=https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-$(cfitsio-version).tar.gz
 	  elif [ $$n = astrometry  ]; then w=http://astrometry.net/downloads
 	  elif [ $$n = atlas       ]; then
 	    mergenames=0
@@ -643,19 +643,28 @@ $(ibidir)/imfit: $(tdir)/imfit-$(imfit-version).tar.gz \
 	&& if ! tar xf $<; then echo; echo "Tar error"; exit 1; fi \
 	&& cd $$unpackdir \
 	&& sed -i 's|/usr/local|$(idir)|g' SConstruct \
-	&& scons --no-openmp  --no-nlopt\
+	&& sed -i 's|/usr/include|$(idir)/include|g' SConstruct \
+	&& sed -i 's|.append(|.insert(0,|g' SConstruct \
+	&& scons --no-openmp  --no-nlopt \
 	         --cc=$(ibdir)/gcc --cpp=$(ibdir)/g++ \
 	         --header-path=$(idir)/include --lib-path=$(idir)/lib imfit \
 	&& cp imfit $(ibdir) \
 	&& scons --no-openmp  --no-nlopt\
 	         --cc=$(ibdir)/gcc --cpp=$(ibdir)/g++ \
-	         --header-path=$(idir)/include --lib-path=$(idir)/lib imfit-mcmc \
+	         --header-path=$(idir)/include --lib-path=$(idir)/lib \
+                 imfit-mcmc \
 	&& cp imfit-mcmc $(ibdir) \
 	&& scons --no-openmp  --no-nlopt\
 	         --cc=$(ibdir)/gcc --cpp=$(ibdir)/g++ \
-	         --header-path=$(idir)/include --lib-path=$(idir)/lib makeimage \
+	         --header-path=$(idir)/include --lib-path=$(idir)/lib \
+                 makeimage \
 	&& cp makeimage $(ibdir) \
 	&& cp $(dtexdir)/imfit.tex $(ictdir)/ \
+	&& if [ "x$(on_mac_os)" != xyes ]; then \
+	     for p in imfit imfit-mcmc makeimage; do \
+	         patchelf --set-rpath $(ildir) $(ibdir)/$$p; \
+	     done; \
+	   fi \
 	&& echo "Imfit $(imfit-version) \citep{imfit2015}" > $@
 
 # Netpbm is a prerequisite of Astrometry-net, it contains a lot of programs.
-- 
cgit v1.2.1