aboutsummaryrefslogtreecommitdiff
path: root/reproduce/software/shell/configure.sh
diff options
context:
space:
mode:
Diffstat (limited to 'reproduce/software/shell/configure.sh')
-rwxr-xr-xreproduce/software/shell/configure.sh311
1 files changed, 190 insertions, 121 deletions
diff --git a/reproduce/software/shell/configure.sh b/reproduce/software/shell/configure.sh
index 4887816..19c14ac 100755
--- a/reproduce/software/shell/configure.sh
+++ b/reproduce/software/shell/configure.sh
@@ -2,9 +2,9 @@
#
# Necessary preparations/configurations for the reproducible project.
#
-# Copyright (C) 2018-2025 Mohammad Akhlaghi <mohammad@akhlaghi.org>
-# Copyright (C) 2021-2025 Raul Infante-Sainz <infantesainz@gmail.com>
-# Copyright (C) 2022-2025 Pedram Ashofteh Ardakani <pedramardakani@pm.me>
+# Copyright (C) 2018-2026 Mohammad Akhlaghi <mohammad@akhlaghi.org>
+# Copyright (C) 2021-2026 Raul Infante-Sainz <infantesainz@gmail.com>
+# Copyright (C) 2022-2026 Pedram Ashofteh Ardakani <pedramardakani@pm.me>
#
# This script is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -228,7 +228,7 @@ empty_build_tmp() {
# accidentally delete the whole root partition (or a least the '/home'
# partition of the user).
if ! [ x"$( ls -A $tmpblddir )" = x ]; then
- rm -r "$tmpblddir"/*
+ rm -rf "$tmpblddir"/*
fi
rm -r "$tmpblddir"
}
@@ -375,16 +375,23 @@ if [ $built_container = 0 ]; then
fi
# On macOS, the way of obtaining the number of cores is different
- # between Intel or Apple M1 CPUs. Here we disinguish between Apple
- # M1 or others.
- maccputype=$(sysctl -n machdep.cpu.brand_string)
- if [ x"$maccputype" = x"Apple M1" ]; then
- address_size_physical=$(sysctl -n machdep.cpu.thread_count)
- address_size_virtual=$(sysctl -n machdep.cpu.logical_per_package)
- else
- address_size_physical=$(sysctl -n machdep.cpu.address_bits.physical)
- address_size_virtual=$(sysctl -n machdep.cpu.address_bits.virtual)
- fi
+ # between Intel or Apple Silicon CPUs. Here we distinguish between
+ # Apple Silicon (any "Apple M*" brand string, e.g. M1, M1 Pro, M1
+ # Max, M2, M2 Pro, ...) and Intel-based Macs. Note that the Apple
+ # Silicon group can be in the formats of "Apple M1" or "Apple M1
+ # Pro", so we use a prefix match via a 'case' pattern to include
+ # both in one check.
+ maccputype=$(sysctl -n machdep.cpu.brand_string 2>/dev/null)
+ case "$maccputype" in
+ "Apple M"*)
+ address_size_physical=$(sysctl -n machdep.cpu.thread_count)
+ address_size_virtual=$(sysctl -n machdep.cpu.logical_per_package)
+ ;;
+ *)
+ address_size_physical=$(sysctl -n machdep.cpu.address_bits.physical)
+ address_size_virtual=$(sysctl -n machdep.cpu.address_bits.virtual)
+ ;;
+ esac
address_sizes="$address_size_physical bits physical, "
address_sizes+="$address_size_virtual bits virtual"
else
@@ -781,6 +788,25 @@ fi
+# Older C standard versions
+# -------------------------
+#
+# Some basic packages require an old standard of C compilation; for their
+# list, see the 'Not working with C23' list in '../config/versions.conf'.
+# Here, we first try 'gnu17', but if that fails on the host compiler, we
+# fall back to 'gnu99'.
+if [ $built_container = 0 ]; then
+ printf "int main(void){; return 0;}\n" > $testsource
+ if gcc -std=gnu17 $testsource -o $testprog 2> /dev/null; then
+ std_c_old="gnu17"
+ else std_c_old="gnu99"
+ fi
+ rm $testsource $testprog
+fi
+
+
+
+
# Fortran compiler
# ----------------
#
@@ -856,33 +882,6 @@ fi
-# See if the linker accepts -Wl,-rpath-link
-# -----------------------------------------
-#
-# '-rpath-link' is used to write the information of the linked shared
-# library into the shared object (library or program). But some versions of
-# LLVM's linker don't accept it an can cause problems.
-#
-# IMPORTANT NOTE: This test has to be done **AFTER** the definition of
-# 'instdir', otherwise, it is going to be used as an empty string.
-if [ $built_container = 0 ]; then
- cat > $testsource <<EOF
-#include <stdio.h>
-#include <stdlib.h>
-int main(void) {return EXIT_SUCCESS;}
-EOF
- if $CC $testsource -o$testprog -Wl,-rpath-link 2>/dev/null \
- > /dev/null; then
- export rpath_command="-Wl,-rpath-link=$instdir/lib"
- else
- export rpath_command=""
- fi
-
- # Delete the temporary directory for compiler checking.
- rm -f $testprog $testsource
- rm -r $compilertestdir
- elapsed_time_from_prev_step compiler-rpath
-fi
@@ -1146,6 +1145,20 @@ EOF
echo " ** Please select another directory."
echo ""
else
+ # Set the '.build' and '.local' symbolic links (and delete
+ # possibly existing symbolic links). These commands are also
+ # present in the top-level 'project' script, but they are only
+ # invoked when '--build-dir' is called. When it is not called
+ # (the user wants to insert the directories interactively: the
+ # scenario here), the links need to be created from
+ # scratch. Furthermore, in case the given directory to
+ # '--build-dir' has problems (fails to pass the sanity checks
+ # above), the symbolic links also need to be recreated.
+ rm -f .build .local
+ ln -s $bdir .build
+ ln -s $bdir/software/installed .local
+
+ # Inform the user
echo " -- Build directory set to ($instring): '$bdir'"
fi
done
@@ -1329,11 +1342,17 @@ elapsed_time_from_prev_step software-dir
# complete the configuration, we may also need to download the source code
# of some necessary software packages (including the downloaders). So we
# need to check the host's available tool for downloading at this step.
+#
+# NOTE: it is important that the name of the programs are not recorded to
+# be absolute (for example 'wget' instead of '/usr/bin/wget'). This is
+# because we build both 'wget' and 'curl' within 'basic.mk'. After they are
+# built, Maneage's built software have higher precedence in 'PATH'. So
+# without an absolute address, our own built software will be used as soon
+# as they are installed/available.
if [ $rewritelconfig = yes ]; then
- if type wget > /dev/null 2>/dev/null; then
- # 'which' isn't in POSIX, so we are using 'command -v' instead.
- name=$(command -v wget)
+ # First look for wget on the host.
+ if type wget > /dev/null 2>/dev/null; then
# See if the host wget has the '--no-use-server-timestamps' option
# (for example wget 1.12 doesn't have it). If not, we'll have to
@@ -1350,13 +1369,16 @@ if [ $rewritelconfig = yes ]; then
# By default Wget keeps the remote file's timestamp, so we'll have
# to disable it manually.
- downloader="$name $wgetts -O";
+ downloader="wget $wgetts -O";
+
+ # In case Wget doesn't exist, try cURL.
elif type curl > /dev/null 2>/dev/null; then
- name=$(command -v curl)
# - cURL doesn't keep the remote file's timestamp by default.
# - With the '-L' option, we tell cURL to follow redirects.
- downloader="$name -L -o"
+ downloader="curl -L -o"
+
+ # Neither Wget or cURL could be found.
else
cat <<EOF
@@ -1396,6 +1418,55 @@ elapsed_time_from_prev_step downloader
+# Libraries necessary for the system's shell
+# ------------------------------------------
+#
+# In some cases (mostly the programs that Maneage doesn't yet build by
+# itself), the programs may call the system's shell, not Maneage's
+# shell. After we close-off the system environment from Maneage, this will
+# cause a crash! To avoid such cases, we need to find the locations of the
+# libraries that the shell needs and temporarily add them to the library
+# search path.
+#
+# About the 'grep -v "(0x[^)]*)"' term (from bug 66847, see [1]): On some
+# systems [2], the output of 'ldd /bin/sh' includes a line for the vDSO [3]
+# that is different to the formats that are assumed, prior to this commit,
+# by the algorithm in 'configure.sh' when evaluating the variable
+# 'sys_library_sh_path'. This leads to a fatal syntax error in (at least)
+# 'ncurses', because the option using 'sys_library_sh_path' contains an
+# unquoted RAM address in parentheses. Even if the address were quoted, it
+# would still be incorrect. This 'grep' command excludes candidate host
+# path strings that look like RAM addresses to address the problem.
+#
+# [1] https://savannah.nongnu.org/bugs/index.php?66847
+# [2] https://stackoverflow.com/questions/34428037/how-to-interpret-the-output-of-the-ldd-program
+# [3] man vdso
+if [ $built_container = 0 ]; then
+ if [ x"$on_mac_os" = xyes ]; then
+ sys_library_sh_path=$(otool -L /bin/sh \
+ | awk '/\/lib/{print $1}' \
+ | sed 's#/[^/]*$##' \
+ | sort \
+ | uniq \
+ | awk '{if (NR==1) printf "%s", $1; \
+ else printf ":%s", $1}')
+ else
+ sys_library_sh_path=$(ldd /bin/sh \
+ | awk '{if($3!="") print $3}' \
+ | sed 's#/[^/]*$##' \
+ | grep -v "(0x[^)]*)" \
+ | sort \
+ | uniq \
+ | awk '{if (NR==1) printf "%s", $1; \
+ else printf ":%s", $1}')
+ fi
+ elapsed_time_from_prev_step sys-library-sh-path
+fi
+
+
+
+
+
# When no local configuration existed, write the parameters into the local
# configuration file.
sdir=$bdir/software
@@ -1415,6 +1486,7 @@ if [ $rewritelconfig = yes ]; then
-e's|@sys_cpath[@]|'"$sys_cpath"'|' \
-e's|@downloader[@]|'"$downloader"'|' \
-e's|@groupname[@]|'"$maneage_group_name"'|' \
+ -e's|@sys_library_sh_path[@]|'"$sys_library_sh_path"'|' \
$lconfin >> $lconf
fi
elapsed_time_from_prev_step LOCAL-write
@@ -1486,6 +1558,41 @@ fi
+# See if the linker accepts -Wl,-rpath-link
+# -----------------------------------------
+#
+# '-rpath-link' is used to write the information of the linked shared
+# library into the shared object (library or program). But some versions of
+# LLVM's linker don't accept it an can cause problems.
+#
+# IMPORTANT NOTE: This test has to be done **AFTER** the definition of
+# 'instdir'. Otherwise, the rpath-link value set within rpath_command in
+# the case of a successful test compile (if $CC ...) will be "/lib",
+# i.e. the host system root /lib directory, instead of the maneage library
+# directory.
+if [ $built_container = 0 ]; then
+ cat > $testsource <<EOF
+#include <stdio.h>
+#include <stdlib.h>
+int main(void) {return EXIT_SUCCESS;}
+EOF
+ if $CC $testsource -o$testprog -Wl,-rpath-link 2>/dev/null \
+ > /dev/null; then
+ export rpath_command="-Wl,-rpath-link=$instdir/lib"
+ else
+ export rpath_command=""
+ fi
+
+ # Delete the temporary directory for compiler checking.
+ rm -f $testprog $testsource
+ rm -r $compilertestdir
+ elapsed_time_from_prev_step compiler-rpath
+fi
+
+
+
+
+
# Software building directory (possibly in RAM)
# ---------------------------------------------
#
@@ -1666,53 +1773,6 @@ fi
-# Libraries necessary for the system's shell
-# ------------------------------------------
-#
-# In some cases (mostly the programs that Maneage doesn't yet build by
-# itself), the programs may call the system's shell, not Maneage's
-# shell. After we close-off the system environment from Maneage, this will
-# cause a crash! To avoid such cases, we need to find the locations of the
-# libraries that the shell needs and temporarily add them to the library
-# search path.
-#
-# About the 'grep -v "(0x[^)]*)"' term (from bug 66847, see [1]): On some
-# systems [2], the output of 'ldd /bin/sh' includes a line for the vDSO [3]
-# that is different to the formats that are assumed, prior to this commit,
-# by the algorithm in 'configure.sh' when evaluating the variable
-# 'sys_library_sh_path'. This leads to a fatal syntax error in (at least)
-# 'ncurses', because the option using 'sys_library_sh_path' contains an
-# unquoted RAM address in parentheses. Even if the address were quoted, it
-# would still be incorrect. This 'grep command excludes candidate host path
-# strings that look like RAM addresses to address the problem.
-#
-# [1] https://savannah.nongnu.org/bugs/index.php?66847
-# [2] https://stackoverflow.com/questions/34428037/how-to-interpret-the-output-of-the-ldd-program
-# [3] man vdso
-if [ $built_container = 0 ]; then
- if [ x"$on_mac_os" = xyes ]; then
- sys_library_sh_path=$(otool -L /bin/sh \
- | awk '/\/lib/{print $1}' \
- | sed 's#/[^/]*$##' \
- | sort \
- | uniq \
- | awk '{if (NR==1) printf "%s", $1; \
- else printf ":%s", $1}')
- else
- sys_library_sh_path=$(ldd /bin/sh \
- | awk '{if($3!="") print $3}' \
- | sed 's#/[^/]*$##' \
- | grep -v "(0x[^)]*)" \
- | sort \
- | uniq \
- | awk '{if (NR==1) printf "%s", $1; \
- else printf ":%s", $1}')
- fi
- elapsed_time_from_prev_step sys-library-sh-path
-fi
-
-
-
# Find Zenodo URL for software downloading
# ----------------------------------------
@@ -1733,30 +1793,37 @@ fi
# an example, the directory part of the URL for all the other software are
# the same). This is not done if the options '--debug' or `--offline` are
# used.
-zenodourl=""
-user_backup_urls=""
-zenodocheck="$bdir"/software/zenodo-check.html
-if [ $built_container = 0 ]; then
- if [ x$debug = x ] && [ x$offline = x ]; then
- if $downloader $zenodocheck \
- https://doi.org/10.5281/zenodo.3883409; then
- zenodourl=$(sed -n -e'/coreutils/p' $zenodocheck \
- | sed -n -e'/http/p' \
- | tr ' ' '\n' \
- | grep http \
- | sed -e 's/href="//' -e 's|/coreutils| |' \
- | awk 'NR==1{print $1}')
- fi
- fi
- rm -f $zenodocheck
-
- # Add the Zenodo URL to the user's given back software URLs. Since the
- # user can specify 'user_backup_urls' (not yet implemented as an option
- # in './project'), we'll give preference to their specified servers,
- # then add the Zenodo URL afterwards.
- user_backup_urls="$user_backup_urls $zenodourl"
- elapsed_time_from_prev_step zenodo-url
-fi
+#
+# NOTE on commented region below (starting with '##'): As described [1],
+# Zenodo's upload strategy does not allow a repository with more than one
+# hundred files. So until the solution there has been implemented, this
+# step has been commented.
+#
+# [1] https://savannah.nongnu.org/task/?16621
+## zenodourl=""
+## user_backup_urls=""
+## zenodocheck="$bdir"/software/zenodo-check.html
+## if [ $built_container = 0 ]; then
+## if [ x$debug = x ] && [ x$offline = x ]; then
+## if $downloader $zenodocheck \
+## https://doi.org/10.5281/zenodo.3883409; then
+## zenodourl=$(sed -n -e'/coreutils/p' $zenodocheck \
+## | sed -n -e'/http/p' \
+## | tr ' ' '\n' \
+## | grep http \
+## | sed -e 's/href="//' -e 's|/coreutils| |' \
+## | awk 'NR==1{print $1}')
+## fi
+## fi
+## rm -f $zenodocheck
+##
+## # Add the Zenodo URL to the user's given back software URLs. Since the
+## # user can specify 'user_backup_urls' (not yet implemented as an option
+## # in './project'), we'll give preference to their specified servers,
+## # then add the Zenodo URL afterwards.
+## user_backup_urls="$user_backup_urls $zenodourl"
+## elapsed_time_from_prev_step zenodo-url
+## fi
@@ -1816,6 +1883,7 @@ if [ $quiet = 0 ]; then echo "Building/validating software: basic"; fi
numthreads=$numthreads \
needs_ldl=$needs_ldl \
on_mac_os=$on_mac_os \
+ std_c_old=$std_c_old \
host_cc=$host_cc \
-j$numthreads
elapsed_time_from_prev_step make-software-basic
@@ -1874,9 +1942,10 @@ ______________________________________________________
!!!!!!!!!!!!!!! Warning !!!!!!!!!!!!!!!!
TeX Live couldn't be installed during the configuration (probably because
-there were downloading problems). TeX Live is only necessary in making the
-final PDF (which is only done after all the analysis has been complete). It
-is not used at all during the analysis.
+there were downloading problems, or you used the '--offline' option). TeX
+Live is only necessary in making the final PDF (which is only done after
+all the analysis has been complete). It is not used at all during the
+analysis.
Therefore, if you don't need the final PDF, and just want to do the
analysis, you can safely ignore this warning and continue.