diff options
Diffstat (limited to 'reproduce/software/shell')
-rwxr-xr-x | reproduce/software/shell/configure.sh | 314 | ||||
-rwxr-xr-x | reproduce/software/shell/pre-make-build.sh | 14 |
2 files changed, 172 insertions, 156 deletions
diff --git a/reproduce/software/shell/configure.sh b/reproduce/software/shell/configure.sh index fc34ca9..6ffb4ff 100755 --- a/reproduce/software/shell/configure.sh +++ b/reproduce/software/shell/configure.sh @@ -30,6 +30,20 @@ set -e +# Project-specific settings +# ------------------------- +# +# The variables defined here may be different between different +# projects. Ideally, they should be detected automatically, but we haven't +# had the chance to implement it yet (please help if you can!). Until then, +# please set them based on your project (if they differ from the core +# branch). +need_gfortran=0 + + + + + # Internal directories # -------------------- # @@ -44,9 +58,6 @@ ptconf=$cdir/LOCAL_tmp.conf poconf=$cdir/LOCAL_old.conf depverfile=$cdir/versions.conf depshafile=$cdir/checksums.conf -# --------- Delete for no Gnuastro --------- -glconf=$adir/gnuastro/gnuastro-local.conf -# ------------------------------------------ @@ -186,35 +197,93 @@ free_space_warning() +# See if we are on a Linux-based system +# -------------------------------------- +# +# Some features are tailored to GNU/Linux systems, while the BSD-based +# behavior is different. Initially we only tested macOS (hence the name of +# the variable), but as FreeBSD is also being inlucded in our tests. As +# more systems get used, we need to tailor these kinds of things better. +kernelname=$(uname -s) +if [ x$kernelname = xLinux ]; then + on_mac_os=no + + # Don't forget to add the respective C++ compiler below (leave 'cc' in + # the end). + c_compiler_list="gcc clang cc" +else + host_cc=1 + on_mac_os=yes + + # Don't forget to add the respective C++ compiler below (leave 'cc' in + # the end). + c_compiler_list="clang gcc cc" +fi + + + + + # Check for C/C++ compilers # ------------------------- # -# To build the software, we'll need some basic tools (the compilers in -# particular) to be present. -hascc=0; -if type cc > /dev/null 2>/dev/null; then - if type c++ > /dev/null 2>/dev/null; then export CC=cc; hascc=1; fi -else - if type gcc > /dev/null 2>/dev/null; then - if type g++ > /dev/null 2>/dev/null; then export CC=gcc; hascc=1; fi +# To build the software, we'll need some basic tools (the C/C++ compilers +# in particular) to be present. +has_compilers=no +for c in $c_compiler_list; do + + # Set the respective C++ compiler. + if [ x$c = xcc ]; then cplus=c++; + elif [ x$c = xgcc ]; then cplus=g++; + elif [ x$c = xclang ]; then cplus=clang++; else - if type clang > /dev/null 2>/dev/null; then - if type clang++ > /dev/null 2>/dev/null; then export CC=clang; hascc=1; fi + cat <<EOF +______________________________________________________ +!!!!!!! BUG !!!!!!! + +The respective C++ compiler executable name for the C compiler '$c' hasn't +been set! You can add it in the 'reproduce/software/shell/configure.sh' +script (just above this error message), or contact us with this web-form: + + https://savannah.nongnu.org/support/?func=additem&group=reproduce + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +EOF + exit 1 + fi + + # Check if they exist. + if type $c > /dev/null 2>/dev/null; then + export CC=$c; + if type $cplus > /dev/null 2>/dev/null; then + export CXX=$cplus + has_compilers=yes + break fi fi -fi -if [ $hascc = 0 ]; then +done +if [ x$has_compilers = xno ]; then cat <<EOF ______________________________________________________ !!!!!!! C/C++ Compiler NOT FOUND !!!!!!! -To build the project's software, the host system needs to have basic C and -C++ compilers. The executables that were checked are 'cc', 'gcc' and -'clang' for a C compiler, and 'c++', 'g++' and 'clang++' for a C++ -compiler. If you have a relevant compiler that is not checked, please get -in touch with us (with the form below) so we add it: +To build this project's software, the host system needs to have both C and +C++ compilers. The commands that were checked are listed below: + + cc, c++ Generic C/C++ compiler (possibly links to below). + gcc, g++ Part of GNU Compiler Collection (GCC). + clang, clang++ Part of LLVM compiler infrastructure. + +If your compiler is not checked, please get in touch with the web-form +below, so we add it. We will try our best to add it soon. Until then, +please install at least one of these compilers on your system to proceed. + + https://savannah.nongnu.org/support/?func=additem&group=reproduce + +NOTE: for macOS systems, the LLVM compilers that are provided in a native +Xcode install are recommended. There are known problems with GCC on macOS. - https://savannah.nongnu.org/support/?func=additem&group=reproduce !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! EOF @@ -238,10 +307,9 @@ if ! [ -d $compilertestdir ]; then mkdir $compilertestdir; fi # Check C compiler # ---------------- -gcc_works=0 testprog=$compilertestdir/test testsource=$compilertestdir/test.c -echo; echo; echo "Checking host C compiler..."; +echo; echo; echo "Checking host C compiler ('$CC')..."; cat > $testsource <<EOF #include <stdio.h> #include <stdlib.h> @@ -257,7 +325,7 @@ else ______________________________________________________ !!!!!!! C compiler doesn't work !!!!!!! -Host C compiler ('gcc') can't build a simple program. +Host C compiler ('$CC') can't build a simple program. A working C compiler is necessary for building the project's software. Please use the error message above to find a good solution and re-run the @@ -268,11 +336,6 @@ link below and we'll try to help https://savannah.nongnu.org/support/?func=additem&group=reproduce -TIP: Once you find the solution, you can use the '-e' option to use -existing configuration: - - $ ./project configure -e - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! EOF @@ -283,28 +346,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. -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 -rm -f $testprog $testsource - - - - - # See if we need the dynamic-linker (-ldl) # ---------------------------------------- # @@ -326,7 +367,7 @@ if $CC $testsource -o$testprog 2>/dev/null > /dev/null; then else needs_ldl=yes; fi -rm -f $testprog $testsource + @@ -351,25 +392,6 @@ static_build=no -# See if we are on a Linux-based system -# -------------------------------------- -# -# Some features are tailored to GNU/Linux systems, while the BSD-based -# behavior is different. Initially we only tested macOS (hence the name of -# the variable), but as FreeBSD is also being inlucded in our tests. As -# more systems get used, we need to tailor these kinds of things better. -kernelname=$(uname -s) -if [ x$kernelname = xLinux ]; then - on_mac_os=no -else - host_cc=1 - on_mac_os=yes -fi - - - - - # Print warning if the host CC is to be used. if [ x$host_cc = x1 ]; then cat <<EOF @@ -507,36 +529,40 @@ fi # ---------------- # # If GCC is ultimately build within the project, the user won't need to -# have a fortran compiler, we'll build it internally for high-level -# programs. However, when the host C compiler is to be used, the user needs -# to have a Fortran compiler available. +# have a fortran compiler: we'll build it internally for high-level +# programs with GCC. However, when the host C compiler is to be used, the +# user needs to have a Fortran compiler available. if [ $host_cc = 1 ]; then - # See if a Fortran compiler exists. - hasfc=0; - if type gfortran > /dev/null 2>/dev/null; then hasfc=1; fi - if [ $hasfc = 0 ]; then - cat <<EOF + # If a Fortran compiler is necessary, see if 'gfortran' exists and can + # be used. + if [ "x$need_gfortran" = "x1" ]; then + + # First, see if 'gfortran' exists. + hasfc=0; + if type gfortran > /dev/null 2>/dev/null; then hasfc=1; fi + if [ $hasfc = 0 ]; then + cat <<EOF ______________________________________________________ !!!!!!! Fortran Compiler NOT FOUND !!!!!!! -The project won't be building its own GCC (which includes a Fortran -compiler) on this system. If you need software that need a Fortran -compiler, it will crash with an error. Fortran is necessary for many -lower-level scientific programs, hence this warning. Currently we search -for 'gfortran'. If you have a Fortran compiler that is not checked, please -get in touch with us (with the form below) so we add it: +This project requires a Fortran compiler. However, the project won't/can't +build its own GCC on this system (GCC also builds the 'gfortran' Fortran +compiler). Please install 'gfortran' using your operating system's package +manager, then re-run this configure script to continue the configuration. - https://savannah.nongnu.org/support/?func=additem&group=reproduce +Currently the only Fortran compiler we check is 'gfortran'. If you have a +Fortran compiler that is not checked, please get in touch with us (with the +form below) so we add it: -Project's configuration will continue in 5 seconds. + https://savannah.nongnu.org/support/?func=additem&group=reproduce ______________________________________________________ EOF - sleep 5 - else + exit 1 + fi - # See if the Fortran compiler works + # Then, see if the Fortran compiler works testsource=$compilertestdir/test.f echo; echo; echo "Checking host Fortran compiler..."; echo " PRINT *, \"... Fortran Compiler works.\"" > $testsource @@ -552,25 +578,18 @@ ______________________________________________________ Host Fortran compiler ('gfortran') can't build a simple program. -A working Fortran compiler is necessary for building some of the project's -software. Please use the error message above to find a good solution and +A working Fortran compiler is necessary for this project. Please use the +error message above to find a good solution in your operating system and re-run the project configuration. If you can't find a solution, please send the error message above to the link below and we'll try to help https://savannah.nongnu.org/support/?func=additem&group=reproduce - -TIP: Once you find the solution, you can use the '-e' option to use -existing configuration: - - $ ./project configure -e - -Project's configuration will continue in 5 seconds. ______________________________________________________ EOF - sleep 5 + exit 1 fi fi fi @@ -579,17 +598,6 @@ fi -# Delete the compiler testing directory -# ------------------------------------- -# -# This directory was made above to make sure the necessary compilers can be -# run. -rm -rf $compilertestdir - - - - - # Inform the user # --------------- # @@ -623,12 +631,10 @@ EOF # (for example the user might have ran `./project configure' by mistake). printnotice=yes rewritepconfig=yes -rewritegconfig=yes -if [ -f $pconf ] || [ -f $glconf ]; then +if [ -f $pconf ]; then if [ $existing_conf = 1 ]; then printnotice=no if [ -f $pconf ]; then rewritepconfig=no; fi - if [ -f $glconf ]; then rewritegconfig=no; fi fi fi @@ -999,44 +1005,6 @@ fi -# --------- Delete for no Gnuastro --------- -# Get the version of Gnuastro that must be used. -gversion=$(awk '$1=="gnuastro-version" {print $NF}' $depverfile) - -# Gnuastro's local configuration settings -if [ $rewritegconfig = yes ]; then - create_file_with_notice $glconf - echo "# Minimum number of bytes to use HDD/SSD instead of RAM." >> $glconf - echo " minmapsize $minmapsize" >> $glconf - echo >> $glconf - echo "# Version of Gnuastro that must be used." >> $glconf - echo " onlyversion $gversion" >> $glconf -else - ingversion=$(awk '$1=="onlyversion" {print $NF}' $glconf) - if [ x$ingversion != x$gversion ]; then - cat <<EOF -______________________________________________________ -!!!!!!!!!!!!!!!!!!CONFIGURATION ERROR!!!!!!!!!!!!!!!!! - -Gnuastro's version in '$glconf' ($ingversion) doesn't match the tarball -version that this project was designed to use in '$depverfile' -($gversion). Please re-run after removing the former file: - - $ rm $glconf - $ ./project configure -e - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -EOF - exit 1 - fi -fi -# ------------------------------------------ - - - - - # Delete final configuration target # --------------------------------- # @@ -1150,12 +1118,15 @@ fi # Note: if we don't delete them first, it can happen that an extra link # will be created in each directory that points to its parent. So to be # safe, we are deleting all the links on each re-configure of the project. -rm -f .build .local .gnuastro +rm -f .build .local + ln -s $bdir .build ln -s $instdir .local ln -s $texdir tex/build ln -s $tikzdir tex/tikz + # --------- Delete for no Gnuastro --------- +rm -f .gnuastro ln -s $topdir/reproduce/analysis/config/gnuastro .gnuastro # ------------------------------------------ @@ -1267,6 +1238,43 @@ 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. +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 compiler testing directory +# ------------------------------------- +# +# This directory was made above to make sure the necessary compilers can be +# run. +rm -f $testprog $testsource +rm -rf $compilertestdir + + + + + # Paths needed by the host compiler (only for `basic.mk') # ------------------------------------------------------- # diff --git a/reproduce/software/shell/pre-make-build.sh b/reproduce/software/shell/pre-make-build.sh index 05a4143..9188fc9 100755 --- a/reproduce/software/shell/pre-make-build.sh +++ b/reproduce/software/shell/pre-make-build.sh @@ -104,9 +104,17 @@ download_tarball() { tarballurl=$url/$tarball fi - # See if it is in the input software directory. + # See if it is in the input-software directory, if so, make a link, if + # not copy it. The only issue is that the file in the input-software + # directory may actually be a link itself. So to avoid complications + # with many links, we'll use 'realpath' (if it exists) to parse the + # link and link to an actual file. if [ -f "$ddir/$tarball" ]; then - cp $ddir/$tarball $ucname + if type realpath > /dev/null 2> /dev/null; then + ln -sf "$(realpath $ddir/$tarball)" "$ucname" + else + cp $ddir/$tarball $ucname + fi else $downloadwrapper "$downloader" nolock $tarballurl $ucname \ "$bservers" @@ -118,7 +126,7 @@ download_tarball() { expectedchecksum=$(awk '/^'$progname'-checksum/{print $3}' $checksumsfile) if [ x$checksum = x$expectedchecksum ]; then mv "$ucname" "$maneagetar" else - echo "ERROR: Non-matching checksum for '$tarball'." + echo "ERROR: Non-matching checksum: $tarball" echo "Checksum should be: $expectedchecksum" echo "Checksum is: $checksum" exit 1 |