aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure61
-rw-r--r--reproduce/src/make/dependencies-basic.mk51
-rw-r--r--reproduce/src/make/dependencies-build-rules.mk6
3 files changed, 110 insertions, 8 deletions
diff --git a/configure b/configure
index d60a34b..cc5bd88 100755
--- a/configure
+++ b/configure
@@ -406,8 +406,52 @@ ln -s $(pwd)/reproduce/config/gnuastro .gnuastro
-# Build basic dependencies
-# ------------------------
+# See if the C compiler can build static libraries
+# ------------------------------------------------
+oprog=$ddir/static-test
+cprog=$ddir/static-test.c
+echo "#include <stdio.h>" > $cprog
+echo "int main(void) {return 0;}" >> $cprog
+if [ x$CC = x ]; then CC=gcc; fi;
+if $CC $cprog -o$oprog -static -ljunk &> /dev/null; then
+ export static_build="yes"
+else
+ export static_build="no"
+fi
+rm -f $oprog $cprog
+if [ $static_build = "no" ]; then
+ cat <<EOF
+_________________________________________________________________________
+!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!
+
+Your system's C compiler ('$CC') doesn't support building static
+libraries. Therefore the dependencies will be built dynamically. This means
+that they will depend more strongly on changes/updates in the host
+system. For high-level applications (like most research projects in natural
+sciences), this shouldn't be a significant problem.
+
+But generally, for reproducibility, its better to build static libraries
+and programs. For more on their difference (and generally an introduction
+on linking), please see the link below:
+
+https://www.gnu.org/software/gnuastro/manual/html_node/Linking.html
+
+If you have other compilers on your system, you can select a different
+compiler by setting the 'CC' environment variable before running
+'./configure'.
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+EOF
+ sleep 5
+fi
+
+
+
+
+
+# Inform the user that the build process is starting
+# -------------------------------------------------
tsec=10
cat <<EOF
@@ -425,7 +469,15 @@ pipeline. They will be installed in:
EOF
sleep $tsec
-make -f reproduce/src/make/dependencies-basic.mk #-j2
+
+
+
+
+
+# Build Basic dependencies
+# ------------------------
+make -f reproduce/src/make/dependencies-basic.mk \
+ static_build=$static_build #-j2
@@ -438,7 +490,8 @@ make -f reproduce/src/make/dependencies-basic.mk #-j2
# Makefile. To make the job easier, we'll do it in a Makefile, not a
# script. Bash and Make were the tools we need to run Makefiles, so we had
# to build them in this script. But after this, we can rely on Makefiles.
-.local/bin/make -f reproduce/src/make/dependencies.mk #-j8
+./.local/bin/make -f reproduce/src/make/dependencies.mk \
+ static_build=$static_build #-j8
diff --git a/reproduce/src/make/dependencies-basic.mk b/reproduce/src/make/dependencies-basic.mk
index 4c57e30..45a4192 100644
--- a/reproduce/src/make/dependencies-basic.mk
+++ b/reproduce/src/make/dependencies-basic.mk
@@ -134,8 +134,16 @@ $(tarballs): $(tdir)/%:
# GNU Lzip: For a static build, the `-static' flag should be given to
# LDFLAGS on the command-line (not from the environment).
$(ibdir)/lzip: $(tdir)/lzip-$(lzip-version).tar.gz
+ echo; echo $(static_build); echo;
+ifeq ($(static_build),yes)
$(call gbuild,$(subst $(tdir)/,,$<), lzip-$(lzip-version), , \
- LDFLAGS="-static")
+ LDFLAGS="-static")
+else
+ $(call gbuild,$(subst $(tdir)/,,$<), lzip-$(lzip-version))
+endif
+
+
+
# GNU Gzip.
@@ -144,24 +152,47 @@ $(ibdir)/gzip: $(tdir)/gzip-$(gzip-version).tar.lz \
$(call gbuild,$(subst $(tdir)/,,$<), gzip-$(gzip-version), static)
+
+
+
# Zlib: its `./configure' doesn't use Autoconf's configure script, it just
# accepts a direct `--static' option.
$(ildir)/libz.a: $(tdir)/zlib-$(zlib-version).tar.gz
+ifeq ($(static_build),yes)
$(call gbuild,$(subst $(tdir)/,,$<), zlib-$(zlib-version), , \
--static)
+else
+ $(call gbuild,$(subst $(tdir)/,,$<), zlib-$(zlib-version))
+endif
+
+
+
+
# XZ Utils
$(ibdir)/xz: $(tdir)/xz-$(xz-version).tar.gz
$(call gbuild,$(subst $(tdir)/,,$<), xz-$(xz-version), static)
+
+
+
+
# Bzip2: Bzip2 doesn't have a configure script.
$(ibdir)/bzip2: $(tdir)/bzip2-$(bzip2-version).tar.gz
tdir=bzip2-$(bzip2-version); \
+ if [ $(static_build) = yes ]; then \
+ makecommand="make LDFLAGS=-static"; \
+ else \
+ makecommand="make"; \
+ fi; \
cd $(ddir) && rm -rf $$tdir && tar xf $< && cd $$tdir && \
- make LDFLAGS=-static && make install PREFIX=$(idir) && \
+ $$makecommand && make install PREFIX=$(idir) && \
cd .. && rm -rf $$tdir
+
+
+
# GNU Binutils:
$(ibdir)/nm: $(tdir)/binutils-$(binutils-version).tar.lz \
$(ibdir)/lzip \
@@ -169,6 +200,10 @@ $(ibdir)/nm: $(tdir)/binutils-$(binutils-version).tar.lz \
$(call gbuild,$(subst $(tdir)/,,$<), binutils-$(binutils-version), \
static)
+
+
+
+
# GNU Tar: When built statically, tar gives a segmentation fault on
# unpacking Bash. So we'll build it dynamically.
$(ibdir)/tar: $(tdir)/tar-$(tar-version).tar.gz \
@@ -179,6 +214,10 @@ $(ibdir)/tar: $(tdir)/tar-$(tar-version).tar.gz \
$(ibdir)/nm
$(call gbuild,$(subst $(tdir)/,,$<), tar-$(tar-version))
+
+
+
+
# GNU Make: Unfortunately it needs dynamic linking in two instances: when
# loading objects (dynamically linked libraries), or when using the
# `getpwnam' function (for tilde expansion). The first can be disabled with
@@ -188,8 +227,16 @@ $(ibdir)/make: $(tdir)/make-$(make-version).tar.lz \
$(ibdir)/tar
$(call gbuild,$(subst $(tdir)/,,$<), make-$(make-version))
+
+
+
+
# GNU Bash
$(ibdir)/bash: $(tdir)/bash-$(bash-version).tar.gz \
$(ibdir)/make
+ifeq ($(static_build),yes)
$(call gbuild,$(subst $(tdir)/,,$<), bash-$(bash-version), , \
--enable-static-link)
+else
+ $(call gbuild,$(subst $(tdir)/,,$<), bash-$(bash-version))
+endif
diff --git a/reproduce/src/make/dependencies-build-rules.mk b/reproduce/src/make/dependencies-build-rules.mk
index 31e7759..49838f3 100644
--- a/reproduce/src/make/dependencies-build-rules.mk
+++ b/reproduce/src/make/dependencies-build-rules.mk
@@ -48,7 +48,9 @@
# 4: Extra configuration options.
# 5: Extra options/arguments to pass to Make.
# 6: Step to run between `make' and `make install': usually `make check'.
-gbuild = if [ $(3)x = staticx ]; then export LDFLAGS="$$LDFLAGS -static"; fi; \
+gbuild = if [ $(static_build) = yes ] && $(3)x = staticx ]; then \
+ export LDFLAGS="$$LDFLAGS -static"; \
+ fi; \
check="$(6)"; \
if [ x"$$check" = x ]; then check="echo Skipping-check"; fi; \
cd $(ddir) && rm -rf $(2) && tar xf $(tdir)/$(1) && cd $(2) && \
@@ -64,7 +66,7 @@ gbuild = if [ $(3)x = staticx ]; then export LDFLAGS="$$LDFLAGS -static"; fi; \
# CMake
# -----
-cbuild = if [ $(3)x = staticx ]; then \
+cbuild = if [ $(static_build) = yes ] && [ $(3)x = staticx ]; then \
export LDFLAGS="$$LDFLAGS -static"; \
opts="-DBUILD_SHARED_LIBS=OFF"; \
fi; \