From 111c8257ce17b2883a5850791a5d73021dbfa4a5 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Thu, 16 May 2024 15:24:24 +0100 Subject: [PATCH 01/42] Add installation steps for xerces and icu and change shebang Xerces and ICU seem to be common missing dependencies, so I've added them into the installation. The sheband in setup.sh now uses '/usr/bin/env bash', which should get the first instance of bash in the PATH variable. This should avoid problems with multiple installations of bash (a particular problem with homebrew) and is a portable method across systems. --- setup.sh | 98 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 79 insertions(+), 19 deletions(-) diff --git a/setup.sh b/setup.sh index cd1ba80..d2265b4 100755 --- a/setup.sh +++ b/setup.sh @@ -1,17 +1,14 @@ -#!/bin/bash +#!/usr/bin/env bash # Since system dependencies, especially on clusters, are a pain # Lets just pre-install everything (except GCC for now). -# Todo: -# --help, -h - exec > >(tee -i install.log) exec 2>&1 function install(){ ## Array of installables - declare -a install_options=("cmake" "root" "geant4" "chroma" "cry" "tensorflow" "torch" "ratpac" "nlopt") + declare -a install_options=("cmake" "root" "geant4" "chroma" "cry" "tensorflow" "torch" "ratpac" "nlopt" "xerces" "icu") declare -A install_selection for element in "${install_options[@]}" do @@ -113,6 +110,16 @@ function install(){ install_cmake fi + if [ "${install_selection[icu]}" = true ] + then + install_icu + fi + + if [ "${install_selection[xerces]}" = true ] + then + install_xerces + fi + if [ "${install_selection[root]}" = true ] then install_root @@ -170,7 +177,7 @@ function help() declare -A help_options=(["only"]="Only install the following packages" \ ["skip"]="Skip the following packages" \ ["gpu"]="Enable GPU support for tensorflow" \ - ["mac"]="Enable Mac support for tensorflow" \ + ["mac"]="Enable Mac support" \ ["noclean"]="Do not clean up after install") for element in $@ do @@ -228,20 +235,26 @@ function check_deps() bool=false fi done - # Check libraries with ldd - echo "Checking for libraries ..." + # Check libraries with ldd if not using macOS libraries=(libX11 libXpm libXft libffi libXext libQt libOpenGL) - for lb in ${libraries[@]} - do - if check_lib $lb - then - printf "%-30s%-20s\n" $lb "Installed" - else - printf "%-30s%-20s\n" $lb "NOT AVAILABLE" - bool=false - fi - done - echo "Dependencies look to be in check" + if (${options[enable_mac]}) + then + echo "MacOS install. Required libaries will not be checked." + echo "Please ensure ${libraries[@]} are installed on your system." + else + echo "Checking for libraries ..." + for lb in ${libraries[@]} + do + if check_lib $lb + then + printf "%-30s%-20s\n" $lb "Installed" + else + printf "%-30s%-20s\n" $lb "NOT AVAILABLE" + bool=false + fi + done + echo "Dependencies look to be in check" + fi $bool } @@ -294,6 +307,53 @@ function install_cmake() fi } +function install_icu() +{ + wget https://github.com/unicode-org/icu/releases/download/release-74-2/icu4c-74_2-src.tgz + tar xzf icu4c-74_2-src.tgz + cd icu/source + chmod +x runConfigureICU configure install-sh + ./configure --prefix=${options[prefix]} + make -j${options[procuse]} && make install + cd ../.. + # Check if cmake was successful, if so clean-up, otherwise exit + if test -f ${options[prefix]}/bin/icu-config + then + printf "ICU install successful\n" + else + printf "ICU install failed ... check logs\n" + exit 1 + fi + if [ "${options[cleanup]}" = true ] + then + rm -rf icu4c-74_2-src.tgz icu + fi +} + +function install_xerces() +{ + wget https://archive.apache.org/dist/xerces/c/3/sources/xerces-c-3.2.5.tar.gz + tar xzf xerces-c-3.2.5.tar.gz + cd xerces-c-3.2.5 + mkdir -p build + cd build + cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=${options[prefix]} -DCMAKE_BUILD_TYPE=Release -DICU_ROOT=${options[prefix]} .. \ + && make -j${options[procuse]} \ + && make install + # Check if build was successful, if so clean-up, otherwise exit + if test -f ${options[prefix]}/bin/XInclude + then + printf "Xerces install successful\n" + else + printf "Xerces install failed ... check logs\n" + exit 1 + fi + if [ "${options[cleanup]}" = true ] + then + rm -rf xerces-c-3.2.5.tar.gz xerces-c-3.2.5 + fi +} + function install_root() { git clone https://github.com/root-project/root.git --depth 1 --single-branch --branch ${options[root_branch]} root_src From feb9476d3b634905b6681d47cf25bb22e5866e56 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 17 May 2024 17:33:12 +0100 Subject: [PATCH 02/42] Update various installation steps to increase portability Installs on mac were failing due to using 'dylib' instead of 'so' and a few other things. Also added an "--arm64" option for building on arm64 architecture. I wasn't able to include tensorflow for this. Added tests for every install stage. Ratpac requires some edits to be installed on macs. Here, I've made the edits using sed after ratpac is cloned. This isn't ideal. Hopefully we can make ratpac more universal so these edits aren't needed. --- setup.sh | 128 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 115 insertions(+), 13 deletions(-) diff --git a/setup.sh b/setup.sh index d2265b4..ba08aea 100755 --- a/setup.sh +++ b/setup.sh @@ -48,6 +48,7 @@ function install(){ ## Tensorflow options enable_gpu=false enable_mac=false + enable_arm64=false # for arm64 architectures (e.g. mac with silicon chip) cleanup=true boolOnly=false @@ -98,6 +99,10 @@ function install(){ then enable_mac=true fi + if [ $element == "--arm64" ] + then + enable_arm64=true + fi done # global options dictionary @@ -137,7 +142,13 @@ function install(){ if [ "${install_selection[tensorflow]}" = true ] then - install_tensorflow + if ${options[enable_arm64]} + then + echo "Tensorflow C does not support arm64. Skipping..." + echo "WARNING: Tensorflow will not be included in the installation" + else + install_tensorflow + fi fi if [ "${install_selection[torch]}" = true ] @@ -286,6 +297,7 @@ function skip_check() ## Installation commands function install_cmake() { + echo "Installing cmake..." git clone https://github.com/Kitware/CMake.git --single-branch --branch v3.22.0 cmake_src mkdir -p cmake_build cd cmake_build @@ -309,6 +321,7 @@ function install_cmake() function install_icu() { + echo "Installing ICU..." wget https://github.com/unicode-org/icu/releases/download/release-74-2/icu4c-74_2-src.tgz tar xzf icu4c-74_2-src.tgz cd icu/source @@ -332,6 +345,7 @@ function install_icu() function install_xerces() { + echo "Installing xerces..." wget https://archive.apache.org/dist/xerces/c/3/sources/xerces-c-3.2.5.tar.gz tar xzf xerces-c-3.2.5.tar.gz cd xerces-c-3.2.5 @@ -341,7 +355,7 @@ function install_xerces() && make -j${options[procuse]} \ && make install # Check if build was successful, if so clean-up, otherwise exit - if test -f ${options[prefix]}/bin/XInclude + if test -d ${options[prefix]}/include/xercesc then printf "Xerces install successful\n" else @@ -356,10 +370,16 @@ function install_xerces() function install_root() { + echo "Installing ROOT..." git clone https://github.com/root-project/root.git --depth 1 --single-branch --branch ${options[root_branch]} root_src mkdir -p root_build cd root_build - cmake -DCMAKE_INSTALL_PREFIX=${options[prefix]} -D xrootd=OFF -D roofit=OFF -D minuit2=ON\ + GLEW="" + if (${options[mac_enabled]}) + then + GLEW="-D builtin_glew=ON" + fi + cmake -DCMAKE_INSTALL_PREFIX=${options[prefix]} -D xrootd=OFF -D roofit=OFF -D minuit2=ON -D CMAKE_CXX_STANDARD=17 ${GLEW}\ ../root_src \ && make -j${options[procuse]} \ && make install @@ -380,6 +400,7 @@ function install_root() function install_geant4() { + echo "Installing Geant4..." git clone https://github.com/geant4/geant4.git --depth 1 --single-branch --branch ${options[geant_branch]} geant_src mkdir -p geant_build cd geant_build @@ -406,14 +427,24 @@ function install_geant4() function install_cry() { + echo "Installing CRY..." # Install CRY for cosmogenics curl https://nuclear.llnl.gov/simulation/cry_v1.7.tar.gz --output cry.tar.gz tar xzvf cry.tar.gz cd cry_v1.7 # Lets hack things up a bit to get a shared library - sed -i 's/^M$//' src/Makefile - sed -i '25 i \\t$(CXX) -shared $(OBJ) -o ../lib/libCRY.so' src/Makefile - sed -i 's/\-Wall/\-Wall \-fPIC/g' src/Makefile + # macs have a different format for sed + if ${options[enable_mac]} + then + sed -i '' 's/^M$//' src/Makefile + sed -i '' '25i\ + $(CXX) -shared $(OBJ) -o ../lib/libCRY.so' src/Makefile + sed -i '' 's/\-Wall/\-Wall \-fPIC/g' src/Makefile + else + sed -i 's/^M$//' src/Makefile + sed -i '25 i \\t$(CXX) -shared $(OBJ) -o ../lib/libCRY.so' src/Makefile + sed -i 's/\-Wall/\-Wall \-fPIC/g' src/Makefile + fi make -j1 # Race condition using multiple threads mkdir -p ${options[prefix]}/data/cry mv data/* ${options[prefix]}/data/cry @@ -422,6 +453,13 @@ function install_cry() mkdir -p ${options[prefix]}/include/cry cp src/*.h ${options[prefix]}/include/cry cd ../ + if test -f ${options[prefix]}/lib/libCRY.so + then + printf "CRY install successful\n" + else + printf "CRY install failed ... check logs\n" + exit 1 + fi if [ "${options[cleanup]}" = true ] then rm -r cry_v1.7 cry.tar.gz @@ -430,6 +468,7 @@ function install_cry() function install_tensorflow() { + echo "Installing Tensorflow..." # Tensorflow: https://www.tensorflow.org/install/lang_c # CPU only or GPU support, listen for the --gpu command? Also if macos? # Updated 2021-08-10 @@ -451,11 +490,22 @@ function install_tensorflow() git clone https://github.com/serizba/cppflow.git cp -r cppflow/include/cppflow ${options[prefix]}/include - rm -rf tensorflow.tar.gz cppflow + if (test -d ${options[prefix]}/include/tensorflow && test -d ${options[prefix]}/include/cppflow) + then + printf "Tensorflow install successful\n" + else + printf "Tensorflow install failed ... check logs\n" + exit 1 + fi + if [ "${options[cleanup]}" = true ] + then + rm -rf tensorflow.tar.gz cppflow + fi } function install_torch() { + echo "Installing torch..." # PyTorch library found at pytorch.org/get-started/locally # Use the GUI there to reveal the specific links # Updated 2021-08-10 @@ -476,11 +526,23 @@ function install_torch() curl $tfurl --output torch.zip unzip torch.zip -d torch cp -r torch/libtorch/* ${options[prefix]} - rm -rf torch.zip torch + if test -d ${options[prefix]}/include/torch + then + printf "Torch install successful\n" + else + printf "Torch install failed ... check logs\n" + exit 1 + fi + if [ "${options[cleanup]}" = true ] + then + rm -rf torch.zip torch + fi } function install_ratpac() { + # FIXME: need a solution to remove requirement to edit ratpac files with sed for mac installs + echo "Installing ratpac..." # Install rat-pac source ${options[prefix]}/bin/thisroot.sh source ${options[prefix]}/bin/geant4.sh @@ -493,8 +555,26 @@ function install_ratpac() rm -rf ratpac git clone ${options[ratpac_repository]} ratpac cd ratpac - make -j${options[procuse]} && source ./ratpac.sh - # Check if ratpac was successful, if so clean-up, otherwise exit + if ${options[arm64_enabled]} + then + sed -i '' 's/x86_64/arm64/g' CMakeLists.txt + fi + if ${options[mac_enabled]} + then + sed -i '' 's/.*Wno-terminate.*//g' CMakeLists.txt + sed -i '' 's/\.so/.dylib/g' config/RatpacConfig.cmake.in + sed -i '' "36 i\\ +set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${options[prefix]}/lib)\\ +include_directories(${options[prefix]}/include)" CMakeLists.txt + sed -i '' '11 i\ +#include ' src/core/include/RAT/ProcAllocator.hh + fi + # avoid using default Makefile as it lacks portability for different OSs + # make -j${options[procuse]} && source ./ratpac.sh + mkdir -p build && cd build + cmake -DXercesC_INCLUDE_DIR=${options[prefix]}/include -DXercesC_LIBRARY=${options[prefix]}/lib/libxerces-c.dylib -DCMAKE_INSTALL_PREFIX=../install .. + make && make install && cd .. && source ./ratpac.sh + # Check if ratpac was successful, otherwise exit if test -f build/bin/rat then printf "Ratpac install successful\n" @@ -502,11 +582,12 @@ function install_ratpac() printf "Ratpac install failed ... check logs\n" exit 1 fi - cd ../ + cd ../.. } function install_chroma() { + echo "Installing chroma..." # Geant-4 pybind, special chroma branch #virtualenv pyrat #source pyrat/bin/activate @@ -527,19 +608,40 @@ function install_chroma() cmake -DCMAKE_INSTALL_PREFIX=${options[prefix]} ../libzmq_src make -j${options[procuse]} install popd - rm -rf libzmq_src libzmq_build + if test -f ${options[prefix]}/lib*/libzmq.a + then + printf "Chroma install successful\n" + else + printf "Chroma install failed ... check logs\n" + exit 1 + fi + if [ "${options[cleanup]}" = true ] + then + rm -rf libzmq_src libzmq_build + fi } function install_nlopt() { + echo "Installing nlopt..." git clone https://github.com/stevengj/nlopt.git pushd nlopt cmake -DCMAKE_INSTALL_PREFIX=${options[prefix]} . -Bbuild cmake --build build --target install popd - rm -rf nlopt + if test -f ${options[prefix]}/include/nlopt.h + then + printf "Nlopt install successful\n" + else + printf "Nlopt install failed ... check logs\n" + exit 1 + fi + if [ "${options[cleanup]}" = true ] + then + rm -rf nlopt + fi } From c43dcb8ccabf5579ae62ecc3b0716723ae7922f7 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 17 May 2024 23:18:35 +0100 Subject: [PATCH 03/42] Add error handling setup.sh should now quit as soon as it runs into an error and will print a helpful message saying what part of the install failed. --- setup.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/setup.sh b/setup.sh index ba08aea..ad0d054 100755 --- a/setup.sh +++ b/setup.sh @@ -3,10 +3,19 @@ # Since system dependencies, especially on clusters, are a pain # Lets just pre-install everything (except GCC for now). + + exec > >(tee -i install.log) exec 2>&1 +handle_error() { + echo "An error occurred during the $1" + echo "The error occurred on line $2 of setup.sh" + exit 1 +} + function install(){ + trap 'handle_error "setup" $LINENO' ERR ## Array of installables declare -a install_options=("cmake" "root" "geant4" "chroma" "cry" "tensorflow" "torch" "ratpac" "nlopt" "xerces" "icu") declare -A install_selection @@ -297,6 +306,7 @@ function skip_check() ## Installation commands function install_cmake() { + trap 'handle_error "cmake install" $LINENO' ERR echo "Installing cmake..." git clone https://github.com/Kitware/CMake.git --single-branch --branch v3.22.0 cmake_src mkdir -p cmake_build @@ -321,6 +331,7 @@ function install_cmake() function install_icu() { + trap 'handle_error "ICU install" $LINENO' ERR echo "Installing ICU..." wget https://github.com/unicode-org/icu/releases/download/release-74-2/icu4c-74_2-src.tgz tar xzf icu4c-74_2-src.tgz @@ -345,6 +356,7 @@ function install_icu() function install_xerces() { + trap 'handle_error "xerces install" $LINENO' ERR echo "Installing xerces..." wget https://archive.apache.org/dist/xerces/c/3/sources/xerces-c-3.2.5.tar.gz tar xzf xerces-c-3.2.5.tar.gz @@ -370,6 +382,7 @@ function install_xerces() function install_root() { + trap 'handle_error "root install" $LINENO' ERR echo "Installing ROOT..." git clone https://github.com/root-project/root.git --depth 1 --single-branch --branch ${options[root_branch]} root_src mkdir -p root_build @@ -400,6 +413,7 @@ function install_root() function install_geant4() { + trap 'handle_error "geant4 install" $LINENO' ERR echo "Installing Geant4..." git clone https://github.com/geant4/geant4.git --depth 1 --single-branch --branch ${options[geant_branch]} geant_src mkdir -p geant_build @@ -427,6 +441,7 @@ function install_geant4() function install_cry() { + trap 'handle_error "CRY install" $LINENO' ERR echo "Installing CRY..." # Install CRY for cosmogenics curl https://nuclear.llnl.gov/simulation/cry_v1.7.tar.gz --output cry.tar.gz @@ -468,6 +483,7 @@ function install_cry() function install_tensorflow() { + trap 'handle_error "tensorflow install" $LINENO' ERR echo "Installing Tensorflow..." # Tensorflow: https://www.tensorflow.org/install/lang_c # CPU only or GPU support, listen for the --gpu command? Also if macos? @@ -505,6 +521,7 @@ function install_tensorflow() function install_torch() { + trap 'handle_error "torch install" $LINENO' ERR echo "Installing torch..." # PyTorch library found at pytorch.org/get-started/locally # Use the GUI there to reveal the specific links @@ -542,6 +559,7 @@ function install_torch() function install_ratpac() { # FIXME: need a solution to remove requirement to edit ratpac files with sed for mac installs + trap 'handle_error "ratpac install" $LINENO' ERR echo "Installing ratpac..." # Install rat-pac source ${options[prefix]}/bin/thisroot.sh @@ -587,6 +605,7 @@ include_directories(${options[prefix]}/include)" CMakeLists.txt function install_chroma() { + trap 'handle_error "chroma install" $LINENO' ERR echo "Installing chroma..." # Geant-4 pybind, special chroma branch #virtualenv pyrat @@ -625,6 +644,7 @@ function install_chroma() function install_nlopt() { + trap 'handle_error "nlopt install" $LINENO' ERR echo "Installing nlopt..." git clone https://github.com/stevengj/nlopt.git pushd nlopt From 5cec449323b4ab779f4cd95e77bd6a4540e2eba9 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Sat, 18 May 2024 14:17:23 +0100 Subject: [PATCH 04/42] Fix a syntax error --- setup.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index ad0d054..38993c0 100755 --- a/setup.sh +++ b/setup.sh @@ -9,8 +9,8 @@ exec > >(tee -i install.log) exec 2>&1 handle_error() { - echo "An error occurred during the $1" - echo "The error occurred on line $2 of setup.sh" + echo "*** An error occurred during the $1" + echo "*** The error occurred on line $2 of setup.sh" exit 1 } @@ -180,7 +180,8 @@ function install(){ install_ratpac fi - if [[ -f "$prefix/lib/libCRY.so" ]]; + trap 'handle_error "post installation tasks" $LINENO' ERR + if test -f $prefix/lib/libCRY.so then printf "export CRYLIB=$prefix/lib\n" >> $outfile printf "export CRYINCLUDE=$prefix/include/cry\n" >> $outfile From b423d06f03405929b1cb4cf3e2fcf276f5a578da Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Mon, 20 May 2024 10:32:00 +0100 Subject: [PATCH 05/42] Fix enable_mac option Was using wrong syntax for the if line that checked if we were using a mac --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 38993c0..6359bc1 100755 --- a/setup.sh +++ b/setup.sh @@ -258,7 +258,7 @@ function check_deps() done # Check libraries with ldd if not using macOS libraries=(libX11 libXpm libXft libffi libXext libQt libOpenGL) - if (${options[enable_mac]}) + if ${options[enable_mac]} then echo "MacOS install. Required libaries will not be checked." echo "Please ensure ${libraries[@]} are installed on your system." From d05f0cd1610a28956c576891605ac0828e4680dc Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Mon, 20 May 2024 14:34:22 +0100 Subject: [PATCH 06/42] Go to correct directory after xerces build --- setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.sh b/setup.sh index 6359bc1..f8b0a75 100755 --- a/setup.sh +++ b/setup.sh @@ -367,6 +367,7 @@ function install_xerces() cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=${options[prefix]} -DCMAKE_BUILD_TYPE=Release -DICU_ROOT=${options[prefix]} .. \ && make -j${options[procuse]} \ && make install + cd ../.. # Check if build was successful, if so clean-up, otherwise exit if test -d ${options[prefix]}/include/xercesc then From 84335bb065ca093ca92d5ffba328b6ce3491675b Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Mon, 20 May 2024 14:38:01 +0100 Subject: [PATCH 07/42] Add DYLD_LIBRARY_PATH to env.sh --- setup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.sh b/setup.sh index f8b0a75..6f70762 100755 --- a/setup.sh +++ b/setup.sh @@ -49,8 +49,10 @@ function install(){ mkdir -p $prefix/bin export PATH=$prefix/bin:$PATH export LD_LIBRARY_PATH=$prefix/lib:$LD_LIBRARY_PATH + export DYLD_LIBRARY_PATH=$prefix/lib:$DYLD_LIBRARY_PATH printf "export PATH=$prefix/bin:\$PATH\n" > $outfile printf "export LD_LIBRARY_PATH=$prefix/lib:\$LD_LIBRARY_PATH\n" >> $outfile + printf "export DYLD_LIBRARY_PATH=$prefix/lib:\$DYLD_LIBRARY_PATH\n" >> $outfile printf "export CC=$CC\n" >> $outfile printf "export CXX=$CXX\n" >> $outfile From fda00963f508df990d6591def56a0f1e62a60b6c Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Tue, 21 May 2024 09:59:50 +0100 Subject: [PATCH 08/42] Fix xerces install Hard-coded dylib as the default library. Now dylib is only used if a mac install is specified. --- setup.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 6f70762..6552b1e 100755 --- a/setup.sh +++ b/setup.sh @@ -594,7 +594,12 @@ include_directories(${options[prefix]}/include)" CMakeLists.txt # avoid using default Makefile as it lacks portability for different OSs # make -j${options[procuse]} && source ./ratpac.sh mkdir -p build && cd build - cmake -DXercesC_INCLUDE_DIR=${options[prefix]}/include -DXercesC_LIBRARY=${options[prefix]}/lib/libxerces-c.dylib -DCMAKE_INSTALL_PREFIX=../install .. + if ${options[mac_enabled]} + then + cmake -DXercesC_INCLUDE_DIR=${options[prefix]}/include -DXercesC_LIBRARY=${options[prefix]}/lib/libxerces-c.dylib -DCMAKE_INSTALL_PREFIX=../install .. + else + cmake -DXercesC_INCLUDE_DIR=${options[prefix]}/include -DXercesC_LIBRARY=${options[prefix]}/lib*/libxerces-c.so -DCMAKE_INSTALL_PREFIX=../install .. + fi make && make install && cd .. && source ./ratpac.sh # Check if ratpac was successful, otherwise exit if test -f build/bin/rat From 71058d312225660d7acf4429521ed2f02fe59e48 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Tue, 21 May 2024 10:37:22 +0100 Subject: [PATCH 09/42] Force xerces to install library in lib, not lib64 --- setup.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/setup.sh b/setup.sh index 6552b1e..aae60d0 100755 --- a/setup.sh +++ b/setup.sh @@ -366,7 +366,7 @@ function install_xerces() cd xerces-c-3.2.5 mkdir -p build cd build - cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=${options[prefix]} -DCMAKE_BUILD_TYPE=Release -DICU_ROOT=${options[prefix]} .. \ + cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=${options[prefix]} -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DICU_ROOT=${options[prefix]} .. \ && make -j${options[procuse]} \ && make install cd ../.. @@ -392,7 +392,7 @@ function install_root() mkdir -p root_build cd root_build GLEW="" - if (${options[mac_enabled]}) + if ${options[mac_enabled]} then GLEW="-D builtin_glew=ON" fi @@ -422,10 +422,16 @@ function install_geant4() git clone https://github.com/geant4/geant4.git --depth 1 --single-branch --branch ${options[geant_branch]} geant_src mkdir -p geant_build cd geant_build + LIBSUFFIX="so" + if ${options[enable_mac]} + then + LIBSUFFIX="dylib" + fi cmake -DCMAKE_INSTALL_PREFIX=${options[prefix]} ../geant_src -DGEANT4_BUILD_EXPAT=OFF \ -DGEANT4_BUILD_MULTITHREADED=OFF -DGEANT4_USE_QT=ON -DGEANT4_INSTALL_DATA=ON \ -DGEANT4_BUILD_TLS_MODEL=global-dynamic \ -DGEANT4_INSTALL_DATA_TIMEOUT=15000 -DGEANT4_USE_GDML=ON \ + -DXercesC_INCLUDE_DIR=${options[prefix]}/include -DXercesC_LIBRARY=${options[prefix]}/lib/libxerces-c.${LIBSUFFIX} \ && make -j${options[procuse]} \ && make install cd ../ @@ -594,15 +600,15 @@ include_directories(${options[prefix]}/include)" CMakeLists.txt # avoid using default Makefile as it lacks portability for different OSs # make -j${options[procuse]} && source ./ratpac.sh mkdir -p build && cd build - if ${options[mac_enabled]} + LIBSUFFIX="so" + if ${options[enable_mac]} then - cmake -DXercesC_INCLUDE_DIR=${options[prefix]}/include -DXercesC_LIBRARY=${options[prefix]}/lib/libxerces-c.dylib -DCMAKE_INSTALL_PREFIX=../install .. - else - cmake -DXercesC_INCLUDE_DIR=${options[prefix]}/include -DXercesC_LIBRARY=${options[prefix]}/lib*/libxerces-c.so -DCMAKE_INSTALL_PREFIX=../install .. + LIBSUFFIX="dylib" fi + cmake -DXercesC_INCLUDE_DIR=${options[prefix]}/include -DXercesC_LIBRARY=${options[prefix]}/lib/libxerces-c.${LIBSUFFIX} -DCMAKE_INSTALL_PREFIX=../install .. make && make install && cd .. && source ./ratpac.sh # Check if ratpac was successful, otherwise exit - if test -f build/bin/rat + if test -f install/bin/rat then printf "Ratpac install successful\n" else From eccc50024cc61bc06f23f2424cc19b343c5fed51 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Tue, 21 May 2024 10:40:58 +0100 Subject: [PATCH 10/42] Build ICU using c++17 --- setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.sh b/setup.sh index aae60d0..fd7d63e 100755 --- a/setup.sh +++ b/setup.sh @@ -340,6 +340,7 @@ function install_icu() tar xzf icu4c-74_2-src.tgz cd icu/source chmod +x runConfigureICU configure install-sh + export CPPFLAGS="-std=c++17" ./configure --prefix=${options[prefix]} make -j${options[procuse]} && make install cd ../.. From ec5eaee78680215f65781cce8fbf85960203797c Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Tue, 21 May 2024 10:57:20 +0100 Subject: [PATCH 11/42] Fix geant search for xerces Was using the wrong variable for finding the xerces library --- setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index fd7d63e..71699b9 100755 --- a/setup.sh +++ b/setup.sh @@ -428,11 +428,11 @@ function install_geant4() then LIBSUFFIX="dylib" fi - cmake -DCMAKE_INSTALL_PREFIX=${options[prefix]} ../geant_src -DGEANT4_BUILD_EXPAT=OFF \ + ../local/bin/cmake -DCMAKE_INSTALL_PREFIX=${options[prefix]} ../geant_src -DGEANT4_BUILD_EXPAT=OFF \ -DGEANT4_BUILD_MULTITHREADED=OFF -DGEANT4_USE_QT=ON -DGEANT4_INSTALL_DATA=ON \ -DGEANT4_BUILD_TLS_MODEL=global-dynamic \ -DGEANT4_INSTALL_DATA_TIMEOUT=15000 -DGEANT4_USE_GDML=ON \ - -DXercesC_INCLUDE_DIR=${options[prefix]}/include -DXercesC_LIBRARY=${options[prefix]}/lib/libxerces-c.${LIBSUFFIX} \ + -DXercesC_INCLUDE_DIR=${options[prefix]}/include -DXercesC_LIBRARY_RELEASE=${options[prefix]}/lib/libxerces-c.${LIBSUFFIX} \ && make -j${options[procuse]} \ && make install cd ../ From 3f43e1b04e282882074afe587509f63b5698f067 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Tue, 21 May 2024 10:59:55 +0100 Subject: [PATCH 12/42] Remove full path to cmake --- setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index 71699b9..3988a01 100755 --- a/setup.sh +++ b/setup.sh @@ -428,12 +428,12 @@ function install_geant4() then LIBSUFFIX="dylib" fi - ../local/bin/cmake -DCMAKE_INSTALL_PREFIX=${options[prefix]} ../geant_src -DGEANT4_BUILD_EXPAT=OFF \ + cmake -DCMAKE_INSTALL_PREFIX=${options[prefix]} ../geant_src -DGEANT4_BUILD_EXPAT=OFF \ -DGEANT4_BUILD_MULTITHREADED=OFF -DGEANT4_USE_QT=ON -DGEANT4_INSTALL_DATA=ON \ -DGEANT4_BUILD_TLS_MODEL=global-dynamic \ -DGEANT4_INSTALL_DATA_TIMEOUT=15000 -DGEANT4_USE_GDML=ON \ - -DXercesC_INCLUDE_DIR=${options[prefix]}/include -DXercesC_LIBRARY_RELEASE=${options[prefix]}/lib/libxerces-c.${LIBSUFFIX} \ - && make -j${options[procuse]} \ + -DXercesC_INCLUDE_DIR=${options[prefix]}/include -DXercesC_LIBRARY_RELEASE=${options[prefix]}/lib/libxerces-c.${LIBSUFFIX} + make -j${options[procuse]} \ && make install cd ../ # Check if g4 was successful, if so clean-up, otherwise exit From f9ff5da231b4a2bc2f3bef7779bc90f0012be4ad Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Tue, 21 May 2024 07:21:51 -0500 Subject: [PATCH 13/42] Fix removal of ^M from cry Makefile --- setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index fd7d63e..6cfc258 100755 --- a/setup.sh +++ b/setup.sh @@ -432,7 +432,7 @@ function install_geant4() -DGEANT4_BUILD_MULTITHREADED=OFF -DGEANT4_USE_QT=ON -DGEANT4_INSTALL_DATA=ON \ -DGEANT4_BUILD_TLS_MODEL=global-dynamic \ -DGEANT4_INSTALL_DATA_TIMEOUT=15000 -DGEANT4_USE_GDML=ON \ - -DXercesC_INCLUDE_DIR=${options[prefix]}/include -DXercesC_LIBRARY=${options[prefix]}/lib/libxerces-c.${LIBSUFFIX} \ + -DXercesC_INCLUDE_DIR=${options[prefix]}/include -DXercesC_LIBRARY_RELEASE=${options[prefix]}/lib/libxerces-c.${LIBSUFFIX} \ && make -j${options[procuse]} \ && make install cd ../ @@ -462,12 +462,12 @@ function install_cry() # macs have a different format for sed if ${options[enable_mac]} then - sed -i '' 's/^M$//' src/Makefile + sed -i '' 's/ $//' src/Makefile sed -i '' '25i\ $(CXX) -shared $(OBJ) -o ../lib/libCRY.so' src/Makefile sed -i '' 's/\-Wall/\-Wall \-fPIC/g' src/Makefile else - sed -i 's/^M$//' src/Makefile + sed -i 's/ $//' src/Makefile sed -i '25 i \\t$(CXX) -shared $(OBJ) -o ../lib/libCRY.so' src/Makefile sed -i 's/\-Wall/\-Wall \-fPIC/g' src/Makefile fi From 973d17d451f3e6efb1543bc8aff8ed01f4335d70 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Tue, 21 May 2024 14:44:52 +0100 Subject: [PATCH 14/42] Update readme with new installed packages --- README.md | 2 ++ setup.sh | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dec739c..4c0bc0c 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ you do not wish to reinstall, though do note you will have to properly link them in that case (ROOT / Geant-4). - CMake v3.22.0+ +- ICU4C 74.2 +- Xerces-C 3.2.5 - Python 3.x.x - Root 6.25+ - Geant-4 11.0 diff --git a/setup.sh b/setup.sh index ffd61c8..636ff80 100755 --- a/setup.sh +++ b/setup.sh @@ -462,12 +462,14 @@ function install_cry() # macs have a different format for sed if ${options[enable_mac]} then - sed -i '' 's/ $//' src/Makefile + sed -i '' 's/ +$//' src/Makefile sed -i '' '25i\ $(CXX) -shared $(OBJ) -o ../lib/libCRY.so' src/Makefile sed -i '' 's/\-Wall/\-Wall \-fPIC/g' src/Makefile else - sed -i 's/ $//' src/Makefile + sed -i 's/ +$//' src/Makefile sed -i '25 i \\t$(CXX) -shared $(OBJ) -o ../lib/libCRY.so' src/Makefile sed -i 's/\-Wall/\-Wall \-fPIC/g' src/Makefile fi From 687285466358a140358142ff86a3063565f484c8 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Tue, 21 May 2024 14:58:54 +0100 Subject: [PATCH 15/42] Fix xerces library variable for ratpac install --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 636ff80..d445709 100755 --- a/setup.sh +++ b/setup.sh @@ -608,7 +608,7 @@ include_directories(${options[prefix]}/include)" CMakeLists.txt then LIBSUFFIX="dylib" fi - cmake -DXercesC_INCLUDE_DIR=${options[prefix]}/include -DXercesC_LIBRARY=${options[prefix]}/lib/libxerces-c.${LIBSUFFIX} -DCMAKE_INSTALL_PREFIX=../install .. + cmake -DXercesC_INCLUDE_DIR=${options[prefix]}/include -DXercesC_LIBRARY_RELEASE=${options[prefix]}/lib/libxerces-c.${LIBSUFFIX} -DCMAKE_INSTALL_PREFIX=../install .. make && make install && cd .. && source ./ratpac.sh # Check if ratpac was successful, otherwise exit if test -f install/bin/rat From 7a483ea836cdb5f0ffd5bd530c447856e9f55ece Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 24 May 2024 11:45:44 +0100 Subject: [PATCH 16/42] Improve bash formatting Used shellcheck to help improve the shell script formatting. Mainly things like adding double quotes around expanded variables and adding '|| exit' to certain commands to catch failures. Should help catch install issues and aid future development --- setup.sh | 231 +++++++++++++++++++++++++++---------------------------- 1 file changed, 114 insertions(+), 117 deletions(-) diff --git a/setup.sh b/setup.sh index d445709..b458d40 100755 --- a/setup.sh +++ b/setup.sh @@ -3,8 +3,6 @@ # Since system dependencies, especially on clusters, are a pain # Lets just pre-install everything (except GCC for now). - - exec > >(tee -i install.log) exec 2>&1 @@ -28,12 +26,9 @@ function install(){ geant_branch="v11.1.2" ratpac_repository="https://github.com/rat-pac/ratpac-two.git" - help $@ - procuse=$(getnproc $@) + help "$@" + procuse=$(getnproc "$@") # End testing - export CC=$(command -v gcc) - export CXX=$(command -v g++) - # Check requirements; Git && GCC if ! [ -x "$(command -v gcc)" ]; then echo "gcc not installed" @@ -43,18 +38,22 @@ function install(){ echo "git not installed" exit 1 fi + CC=$(command -v gcc) + export CC + CXX=$(command -v g++) + export CXX outfile="env.sh" prefix=$(pwd -P)/local - mkdir -p $prefix/bin + mkdir -p "${prefix}"/bin export PATH=$prefix/bin:$PATH export LD_LIBRARY_PATH=$prefix/lib:$LD_LIBRARY_PATH export DYLD_LIBRARY_PATH=$prefix/lib:$DYLD_LIBRARY_PATH - printf "export PATH=$prefix/bin:\$PATH\n" > $outfile - printf "export LD_LIBRARY_PATH=$prefix/lib:\$LD_LIBRARY_PATH\n" >> $outfile - printf "export DYLD_LIBRARY_PATH=$prefix/lib:\$DYLD_LIBRARY_PATH\n" >> $outfile - printf "export CC=$CC\n" >> $outfile - printf "export CXX=$CXX\n" >> $outfile + printf 'export PATH=%s/bin:$PATH\n' "$prefix" > $outfile + printf 'export LD_LIBRARY_PATH=%s/lib:$LD_LIBRARY_PATH\n' "$prefix" >> $outfile + printf 'export DYLD_LIBRARY_PATH=%s/lib:$DYLD_LIBRARY_PATH\n' "$prefix" >> $outfile + printf 'export CC=%s\n' "$CC" >> $outfile + printf 'export CXX=%s\n' "$CXX" >> $outfile ## Tensorflow options enable_gpu=false @@ -62,55 +61,55 @@ function install(){ enable_arm64=false # for arm64 architectures (e.g. mac with silicon chip) cleanup=true boolOnly=false - - for element in $@; + + for element in "$@" do if [ "$skipping" = true ] then # Check if element in install_options - if [[ " ${install_options[@]} " =~ " ${element} " ]] - then - install_selection[$element]=false - fi + for option in "${install_options[@]}" + do + [[ "${option}" =~ ${element} ]] && install_selection[$element]=false + done fi - if [ $element == "--skip" ] + if [ "$element" == "--skip" ] then skipping=true; fi done - for element in $@; + for element in "$@" do if [ "$boolOnly" = true ] then - if [[ " ${install_options[@]} " =~ " ${element} " ]] - then - install_selection[$element]=true - fi + for option in "${install_options[@]}" + do + [[ "${option}" =~ ${element} ]] && install_selection[$element]=true + done fi - if [ $element == "--only" ] + if [ "$element" == "--only" ] then # Only will overwrite the skipping rules boolOnly=true # Set all to false - for element in "${install_options[@]}" + for el in "${install_options[@]}" do - install_selection[$element]=false + install_selection[$el]=false done fi - if [ $element == "--noclean" ] + if [ "$element" == "--noclean" ] then cleanup=false fi - if [ $element == "--gpu" ] + if [ "$element" == "--gpu" ] then enable_gpu=true fi - if [ $element == "--mac" ] + if [ "$element" == "--mac" ] then enable_mac=true fi - if [ $element == "--arm64" ] + if [ "$element" == "--arm64" ] then enable_arm64=true fi @@ -183,15 +182,15 @@ function install(){ fi trap 'handle_error "post installation tasks" $LINENO' ERR - if test -f $prefix/lib/libCRY.so + if test -f "$prefix"/lib/libCRY.so then - printf "export CRYLIB=$prefix/lib\n" >> $outfile - printf "export CRYINCLUDE=$prefix/include/cry\n" >> $outfile - printf "export CRYDATA=$prefix/data/cry\n" >> $outfile + printf 'export CRYLIB=%s/lib\n' "$prefix" >> $outfile + printf 'export CRYINCLUDE=%s/include/cry\n' "$prefix" >> $outfile + printf 'export CRYDATA=%s/data/cry\n' "$prefix" >> $outfile fi - printf "pushd $prefix/bin 2>&1 >/dev/null\nsource thisroot.sh\nsource geant4.sh\npopd 2>&1 >/dev/null\n" >> $outfile - printf "if [ -f \"$prefix/../ratpac/ratpac.sh\" ]; then\nsource $prefix/../ratpac/ratpac.sh\nfi\n" >> $outfile - printf "if [ -f \"$prefix/../pyrat/bin/activate\" ]; then\nsource $prefix/../pyrat/bin/activate\nfi\n" >> $outfile + printf 'pushd %s/bin 2>&1 >/dev/null\nsource thisroot.sh\nsource geant4.sh\npopd 2>&1 >/dev/null\n' "$prefix" >> $outfile + printf 'if [ -f "%s/../ratpac/ratpac.sh" ]; then\nsource %s/../ratpac/ratpac.sh\nfi\n' "$prefix" "$prefix" >> $outfile + printf 'if [ -f "%s/../pyrat/bin/activate" ]; then\nsource %s/../pyrat/bin/activate\nfi\n' "$prefix" "$prefix" >> $outfile echo "Done" } @@ -202,7 +201,7 @@ function help() ["gpu"]="Enable GPU support for tensorflow" \ ["mac"]="Enable Mac support" \ ["noclean"]="Do not clean up after install") - for element in $@ + for element in "$@" do if [[ $element =~ "-h" ]]; then @@ -212,7 +211,7 @@ function help() printf "\n\nOptions\n" for key in "${!help_options[@]}" do - printf "%-20s%-20s\n" --$key "${help_options[$key]}" + printf "%-20s%-20s\n" "--$key" "${help_options[$key]}" done exit 0 fi @@ -222,19 +221,19 @@ function help() function getnproc() { local nproc=1 - for element in $@ + for element in "$@" do if [[ $element =~ "-j" ]]; then - nproc=$(echo $element | sed -e 's/-j//g') + nproc=${element/-j/} fi done - echo $nproc + echo "$nproc" } function command_exists() { - if (command -v $1 > /dev/null ) + if (command -v "$1" > /dev/null ) then true else @@ -248,13 +247,13 @@ function check_deps() # Before trying to install anything, confirm a list of dependencies echo "Checking list of dependencies ..." cmds=(gcc openssl curl) - for c in ${cmds[@]} + for c in "${cmds[@]}" do - if command_exists $c + if command_exists "$c" then - printf "%-30s%-20s\n" $c "Installed" + printf "%-30s%-20s\n" "$c" "Installed" else - printf "%-30s%-20s\n" $c "NOT AVAILABLE" + printf "%-30s%-20s\n" "$c" "NOT AVAILABLE" bool=false fi done @@ -263,16 +262,16 @@ function check_deps() if ${options[enable_mac]} then echo "MacOS install. Required libaries will not be checked." - echo "Please ensure ${libraries[@]} are installed on your system." + echo "Please ensure " "${libraries[@]}" "are installed on your system." else echo "Checking for libraries ..." - for lb in ${libraries[@]} + for lb in "${libraries[@]}" do - if check_lib $lb + if check_lib "$lb" then - printf "%-30s%-20s\n" $lb "Installed" + printf "%-30s%-20s\n" "$lb" "Installed" else - printf "%-30s%-20s\n" $lb "NOT AVAILABLE" + printf "%-30s%-20s\n" "$lb" "NOT AVAILABLE" bool=false fi done @@ -284,7 +283,7 @@ function check_deps() function check_lib() { - if (ldconfig -p | grep -q $1) + if (ldconfig -p | grep -q "$1") then true else @@ -295,7 +294,7 @@ function check_lib() function skip_check() { bool=false - for elem in $@ + for elem in "$@" do if [[ $elem = "--skip-checks" ]]; then @@ -313,13 +312,13 @@ function install_cmake() echo "Installing cmake..." git clone https://github.com/Kitware/CMake.git --single-branch --branch v3.22.0 cmake_src mkdir -p cmake_build - cd cmake_build + cd cmake_build || exit 1 ../cmake_src/bootstrap --prefix=../local \ - && make -j${options[procuse]} \ + && make -j"${options[procuse]}" \ && make install cd ../ # Check if cmake was successful, if so clean-up, otherwise exit - if test -f ${options[prefix]}/bin/cmake + if test -f "${options[prefix]}"/bin/cmake then printf "Cmake install successful\n" else @@ -338,14 +337,14 @@ function install_icu() echo "Installing ICU..." wget https://github.com/unicode-org/icu/releases/download/release-74-2/icu4c-74_2-src.tgz tar xzf icu4c-74_2-src.tgz - cd icu/source + cd icu/source || exit 1 chmod +x runConfigureICU configure install-sh export CPPFLAGS="-std=c++17" - ./configure --prefix=${options[prefix]} - make -j${options[procuse]} && make install + ./configure --prefix="${options[prefix]}" + make -j"${options[procuse]}" && make install cd ../.. # Check if cmake was successful, if so clean-up, otherwise exit - if test -f ${options[prefix]}/bin/icu-config + if test -f "${options[prefix]}"/bin/icu-config then printf "ICU install successful\n" else @@ -364,15 +363,15 @@ function install_xerces() echo "Installing xerces..." wget https://archive.apache.org/dist/xerces/c/3/sources/xerces-c-3.2.5.tar.gz tar xzf xerces-c-3.2.5.tar.gz - cd xerces-c-3.2.5 + cd xerces-c-3.2.5 || exit 1 mkdir -p build - cd build - cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=${options[prefix]} -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DICU_ROOT=${options[prefix]} .. \ - && make -j${options[procuse]} \ + cd build || exit 1 + cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${options[prefix]}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DICU_ROOT="${options[prefix]}" .. \ + && make -j"${options[procuse]}" \ && make install cd ../.. # Check if build was successful, if so clean-up, otherwise exit - if test -d ${options[prefix]}/include/xercesc + if test -d "${options[prefix]}"/include/xercesc then printf "Xerces install successful\n" else @@ -389,21 +388,21 @@ function install_root() { trap 'handle_error "root install" $LINENO' ERR echo "Installing ROOT..." - git clone https://github.com/root-project/root.git --depth 1 --single-branch --branch ${options[root_branch]} root_src + git clone https://github.com/root-project/root.git --depth 1 --single-branch --branch "${options[root_branch]}" root_src mkdir -p root_build - cd root_build + cd root_build || exit 1 GLEW="" if ${options[mac_enabled]} then GLEW="-D builtin_glew=ON" fi - cmake -DCMAKE_INSTALL_PREFIX=${options[prefix]} -D xrootd=OFF -D roofit=OFF -D minuit2=ON -D CMAKE_CXX_STANDARD=17 ${GLEW}\ + cmake -DCMAKE_INSTALL_PREFIX="${options[prefix]}" -D xrootd=OFF -D roofit=OFF -D minuit2=ON -D CMAKE_CXX_STANDARD=17 "${GLEW}"\ ../root_src \ - && make -j${options[procuse]} \ + && make -j"${options[procuse]}" \ && make install cd ../ # Check if root was successful, if so clean-up, otherwise exit - if test -f ${options[prefix]}/bin/root + if test -f "${options[prefix]}"/bin/root then printf "Root install successful\n" else @@ -420,24 +419,24 @@ function install_geant4() { trap 'handle_error "geant4 install" $LINENO' ERR echo "Installing Geant4..." - git clone https://github.com/geant4/geant4.git --depth 1 --single-branch --branch ${options[geant_branch]} geant_src + git clone https://github.com/geant4/geant4.git --depth 1 --single-branch --branch "${options[geant_branch]}" geant_src mkdir -p geant_build - cd geant_build + cd geant_build || exit 1 LIBSUFFIX="so" if ${options[enable_mac]} then LIBSUFFIX="dylib" fi - cmake -DCMAKE_INSTALL_PREFIX=${options[prefix]} ../geant_src -DGEANT4_BUILD_EXPAT=OFF \ + cmake -DCMAKE_INSTALL_PREFIX="${options[prefix]}" ../geant_src -DGEANT4_BUILD_EXPAT=OFF \ -DGEANT4_BUILD_MULTITHREADED=OFF -DGEANT4_USE_QT=ON -DGEANT4_INSTALL_DATA=ON \ -DGEANT4_BUILD_TLS_MODEL=global-dynamic \ -DGEANT4_INSTALL_DATA_TIMEOUT=15000 -DGEANT4_USE_GDML=ON \ - -DXercesC_INCLUDE_DIR=${options[prefix]}/include -DXercesC_LIBRARY_RELEASE=${options[prefix]}/lib/libxerces-c.${LIBSUFFIX} - make -j${options[procuse]} \ + -DXercesC_INCLUDE_DIR="${options[prefix]}"/include -DXercesC_LIBRARY_RELEASE="${options[prefix]}"/lib/libxerces-c."${LIBSUFFIX}" + make -j"${options[procuse]}" \ && make install cd ../ # Check if g4 was successful, if so clean-up, otherwise exit - if test -f ${options[prefix]}/bin/geant4-config + if test -f "${options[prefix]}"/bin/geant4-config then printf "G4 install successful\n" else @@ -457,31 +456,29 @@ function install_cry() # Install CRY for cosmogenics curl https://nuclear.llnl.gov/simulation/cry_v1.7.tar.gz --output cry.tar.gz tar xzvf cry.tar.gz - cd cry_v1.7 + cd cry_v1.7 || exit 1 # Lets hack things up a bit to get a shared library # macs have a different format for sed if ${options[enable_mac]} then - sed -i '' 's/ -$//' src/Makefile + sed -i '' 's/$//' src/Makefile sed -i '' '25i\ $(CXX) -shared $(OBJ) -o ../lib/libCRY.so' src/Makefile sed -i '' 's/\-Wall/\-Wall \-fPIC/g' src/Makefile else - sed -i 's/ -$//' src/Makefile + sed -i 's/$//' src/Makefile sed -i '25 i \\t$(CXX) -shared $(OBJ) -o ../lib/libCRY.so' src/Makefile sed -i 's/\-Wall/\-Wall \-fPIC/g' src/Makefile fi make -j1 # Race condition using multiple threads - mkdir -p ${options[prefix]}/data/cry - mv data/* ${options[prefix]}/data/cry + mkdir -p "${options[prefix]}"/data/cry + mv data/* "${options[prefix]}"/data/cry # "Make install" - mv lib/libCRY.so ${options[prefix]}/lib - mkdir -p ${options[prefix]}/include/cry - cp src/*.h ${options[prefix]}/include/cry + mv lib/libCRY.so "${options[prefix]}"/lib + mkdir -p "${options[prefix]}"/include/cry + cp src/*.h "${options[prefix]}"/include/cry cd ../ - if test -f ${options[prefix]}/lib/libCRY.so + if test -f "${options[prefix]}"/lib/libCRY.so then printf "CRY install successful\n" else @@ -515,11 +512,11 @@ function install_tensorflow() tfurl=$macCPU fi curl $tfurl --output tensorflow.tar.gz - tar -C ${options[prefix]} -xzf tensorflow.tar.gz + tar -C "${options[prefix]}" -xzf tensorflow.tar.gz git clone https://github.com/serizba/cppflow.git - cp -r cppflow/include/cppflow ${options[prefix]}/include - if (test -d ${options[prefix]}/include/tensorflow && test -d ${options[prefix]}/include/cppflow) + cp -r cppflow/include/cppflow "${options[prefix]}"/include + if test -d "${options[prefix]}"/include/tensorflow && test -d "${options[prefix]}"/include/cppflow then printf "Tensorflow install successful\n" else @@ -555,8 +552,8 @@ function install_torch() curl $tfurl --output torch.zip unzip torch.zip -d torch - cp -r torch/libtorch/* ${options[prefix]} - if test -d ${options[prefix]}/include/torch + cp -r torch/libtorch/* "${options[prefix]}" + if test -d "${options[prefix]}"/include/torch then printf "Torch install successful\n" else @@ -575,17 +572,17 @@ function install_ratpac() trap 'handle_error "ratpac install" $LINENO' ERR echo "Installing ratpac..." # Install rat-pac - source ${options[prefix]}/bin/thisroot.sh - source ${options[prefix]}/bin/geant4.sh - if [[ -f "${options[prefix]}/lib/libCRY.so" ]]; + source "${options[prefix]}"/bin/thisroot.sh + source "${options[prefix]}"/bin/geant4.sh + if [[ -f "${options[prefix]}"/lib/libCRY.so ]]; then - export CRYLIB=${options[prefix]}/lib - export CRYINCLUDE=${options[prefix]}/include/cry - export CRYDATA=${options[prefix]}/data/cry + export CRYLIB="${options[prefix]}"/lib + export CRYINCLUDE="${options[prefix]}"/include/cry + export CRYDATA="${options[prefix]}"/data/cry fi rm -rf ratpac - git clone ${options[ratpac_repository]} ratpac - cd ratpac + git clone "${options[ratpac_repository]}" ratpac + cd ratpac || exit 1 if ${options[arm64_enabled]} then sed -i '' 's/x86_64/arm64/g' CMakeLists.txt @@ -602,13 +599,13 @@ include_directories(${options[prefix]}/include)" CMakeLists.txt fi # avoid using default Makefile as it lacks portability for different OSs # make -j${options[procuse]} && source ./ratpac.sh - mkdir -p build && cd build + mkdir -p build && (cd build || exit 1) LIBSUFFIX="so" if ${options[enable_mac]} then LIBSUFFIX="dylib" fi - cmake -DXercesC_INCLUDE_DIR=${options[prefix]}/include -DXercesC_LIBRARY_RELEASE=${options[prefix]}/lib/libxerces-c.${LIBSUFFIX} -DCMAKE_INSTALL_PREFIX=../install .. + cmake -DXercesC_INCLUDE_DIR="${options[prefix]}"/include -DXercesC_LIBRARY_RELEASE="${options[prefix]}"/lib/libxerces-c."${LIBSUFFIX}" -DCMAKE_INSTALL_PREFIX=../install .. make && make install && cd .. && source ./ratpac.sh # Check if ratpac was successful, otherwise exit if test -f install/bin/rat @@ -641,12 +638,12 @@ function install_chroma() ## For now, just install zeromq git clone --depth 1 -b v4.3.5 https://github.com/zeromq/libzmq.git libzmq_src mkdir -p libzmq_build - pushd libzmq_build - cmake -DCMAKE_INSTALL_PREFIX=${options[prefix]} ../libzmq_src - make -j${options[procuse]} install - popd + pushd libzmq_build || exit 1 + cmake -DCMAKE_INSTALL_PREFIX="${options[prefix]}" ../libzmq_src + make -j"${options[procuse]}" install + popd || exit 1 - if test -f ${options[prefix]}/lib*/libzmq.a + if test -f "${options[prefix]}"/lib*/libzmq.a then printf "Chroma install successful\n" else @@ -665,11 +662,11 @@ function install_nlopt() trap 'handle_error "nlopt install" $LINENO' ERR echo "Installing nlopt..." git clone https://github.com/stevengj/nlopt.git - pushd nlopt - cmake -DCMAKE_INSTALL_PREFIX=${options[prefix]} . -Bbuild + pushd nlopt || exit 1 + cmake -DCMAKE_INSTALL_PREFIX="${options[prefix]}" . -Bbuild cmake --build build --target install - popd - if test -f ${options[prefix]}/include/nlopt.h + popd || exit 1 + if test -f "${options[prefix]}"/include/nlopt.h then printf "Nlopt install successful\n" else @@ -684,13 +681,13 @@ function install_nlopt() ## Main function with checks -if skip_check $@ +if skip_check "$@" then - install $@ + install "$@" else if check_deps then - install $@ + install "$@" else printf "\033[31mPlease install system dependencies as indicated above.\033[0m\n" printf "\033[31mYou can skip these checks by passing the --skip-checks flag.\033[0m\n" From 14adf08c7ff1b2b71fa3a712acd102b5bc4a35b2 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 24 May 2024 12:01:13 +0100 Subject: [PATCH 17/42] Force libzmq to install in lib folder, not lib64 --- setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index b458d40..c0d9355 100755 --- a/setup.sh +++ b/setup.sh @@ -639,11 +639,11 @@ function install_chroma() git clone --depth 1 -b v4.3.5 https://github.com/zeromq/libzmq.git libzmq_src mkdir -p libzmq_build pushd libzmq_build || exit 1 - cmake -DCMAKE_INSTALL_PREFIX="${options[prefix]}" ../libzmq_src + cmake -DCMAKE_INSTALL_PREFIX="${options[prefix]}" -DCMAKE_INSTALL_LIBDIR=lib ../libzmq_src make -j"${options[procuse]}" install popd || exit 1 - if test -f "${options[prefix]}"/lib*/libzmq.a + if test -f "${options[prefix]}"/lib/libzmq.a then printf "Chroma install successful\n" else From 9a857c6d26fef257d566a932440228981dcb24b0 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 24 May 2024 12:08:13 +0100 Subject: [PATCH 18/42] Fix mac option in help function --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index c0d9355..b72e73b 100755 --- a/setup.sh +++ b/setup.sh @@ -259,7 +259,7 @@ function check_deps() done # Check libraries with ldd if not using macOS libraries=(libX11 libXpm libXft libffi libXext libQt libOpenGL) - if ${options[enable_mac]} + if [ "${options[enable_mac]}" = true ] then echo "MacOS install. Required libaries will not be checked." echo "Please ensure " "${libraries[@]}" "are installed on your system." From 0cb9378cc9598f31d9c52944d0bccaa3989c1cc7 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 24 May 2024 12:09:38 +0100 Subject: [PATCH 19/42] Fix more mac options --- setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index b72e73b..91ab36e 100755 --- a/setup.sh +++ b/setup.sh @@ -423,7 +423,7 @@ function install_geant4() mkdir -p geant_build cd geant_build || exit 1 LIBSUFFIX="so" - if ${options[enable_mac]} + if [ "${options[enable_mac]}" = true ] then LIBSUFFIX="dylib" fi @@ -459,7 +459,7 @@ function install_cry() cd cry_v1.7 || exit 1 # Lets hack things up a bit to get a shared library # macs have a different format for sed - if ${options[enable_mac]} + if [ "${options[enable_mac]}" = true ] then sed -i '' 's/$//' src/Makefile sed -i '' '25i\ @@ -601,7 +601,7 @@ include_directories(${options[prefix]}/include)" CMakeLists.txt # make -j${options[procuse]} && source ./ratpac.sh mkdir -p build && (cd build || exit 1) LIBSUFFIX="so" - if ${options[enable_mac]} + if [ "${options[enable_mac]}" = true ] then LIBSUFFIX="dylib" fi From 3dac3be237c137196da0fd5c454797e401e9716c Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 24 May 2024 13:50:47 +0100 Subject: [PATCH 20/42] Use \r in sed of cry makefile --- setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index 91ab36e..37c99f4 100755 --- a/setup.sh +++ b/setup.sh @@ -461,12 +461,12 @@ function install_cry() # macs have a different format for sed if [ "${options[enable_mac]}" = true ] then - sed -i '' 's/$//' src/Makefile + sed -i '' 's/\r$//' src/Makefile sed -i '' '25i\ $(CXX) -shared $(OBJ) -o ../lib/libCRY.so' src/Makefile sed -i '' 's/\-Wall/\-Wall \-fPIC/g' src/Makefile else - sed -i 's/$//' src/Makefile + sed -i 's/\r$//' src/Makefile sed -i '25 i \\t$(CXX) -shared $(OBJ) -o ../lib/libCRY.so' src/Makefile sed -i 's/\-Wall/\-Wall \-fPIC/g' src/Makefile fi From dee12e935f4f070128ebe7062a39b9ef421cc0df Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 24 May 2024 14:03:54 +0100 Subject: [PATCH 21/42] Adjust LD_LIBRARY_PATH on cry install This allows the testMain program to be run. --- setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.sh b/setup.sh index 37c99f4..0400190 100755 --- a/setup.sh +++ b/setup.sh @@ -470,6 +470,7 @@ function install_cry() sed -i '25 i \\t$(CXX) -shared $(OBJ) -o ../lib/libCRY.so' src/Makefile sed -i 's/\-Wall/\-Wall \-fPIC/g' src/Makefile fi + LD_LIBRARY_PATH="${options[prefix]}"/cry_v1.7/lib:"$LD_LIBRARY_PATH" make -j1 # Race condition using multiple threads mkdir -p "${options[prefix]}"/data/cry mv data/* "${options[prefix]}"/data/cry From b26e7ba85f694bc1d855d9290ec2a0d762242b28 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 24 May 2024 14:05:50 +0100 Subject: [PATCH 22/42] Adjust arm64 flags --- setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index 0400190..cd3dbc4 100755 --- a/setup.sh +++ b/setup.sh @@ -152,7 +152,7 @@ function install(){ if [ "${install_selection[tensorflow]}" = true ] then - if ${options[enable_arm64]} + if [ "${options[enable_arm64]}" = true ] then echo "Tensorflow C does not support arm64. Skipping..." echo "WARNING: Tensorflow will not be included in the installation" @@ -584,7 +584,7 @@ function install_ratpac() rm -rf ratpac git clone "${options[ratpac_repository]}" ratpac cd ratpac || exit 1 - if ${options[arm64_enabled]} + if [ "${options[arm64_enabled]}" = true ] then sed -i '' 's/x86_64/arm64/g' CMakeLists.txt fi From 9bdffc59733d38a3d8a5fd263b412a41f2259913 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 24 May 2024 14:14:06 +0100 Subject: [PATCH 23/42] Force geant4 to use lib, not lib64 --- setup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index cd3dbc4..24c1ea0 100755 --- a/setup.sh +++ b/setup.sh @@ -427,7 +427,8 @@ function install_geant4() then LIBSUFFIX="dylib" fi - cmake -DCMAKE_INSTALL_PREFIX="${options[prefix]}" ../geant_src -DGEANT4_BUILD_EXPAT=OFF \ + cmake -DCMAKE_INSTALL_PREFIX="${options[prefix]}" -DCMAKE_INSTALL_LIBDIR=lib \ + ../geant_src -DGEANT4_BUILD_EXPAT=OFF \ -DGEANT4_BUILD_MULTITHREADED=OFF -DGEANT4_USE_QT=ON -DGEANT4_INSTALL_DATA=ON \ -DGEANT4_BUILD_TLS_MODEL=global-dynamic \ -DGEANT4_INSTALL_DATA_TIMEOUT=15000 -DGEANT4_USE_GDML=ON \ From 540a255c638add9938e33c795fbac6c437817c05 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 24 May 2024 14:22:06 +0100 Subject: [PATCH 24/42] Missed a broken mac flag --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 24c1ea0..8f759b4 100755 --- a/setup.sh +++ b/setup.sh @@ -589,7 +589,7 @@ function install_ratpac() then sed -i '' 's/x86_64/arm64/g' CMakeLists.txt fi - if ${options[mac_enabled]} + if [ "${options[mac_enabled]}" = true ] then sed -i '' 's/.*Wno-terminate.*//g' CMakeLists.txt sed -i '' 's/\.so/.dylib/g' config/RatpacConfig.cmake.in From 9fd014ddaef3788e370c4b697b3826a25c230f1f Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 24 May 2024 14:29:26 +0100 Subject: [PATCH 25/42] Change cd behaviour in ratpac install --- setup.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index 8f759b4..2be65f0 100755 --- a/setup.sh +++ b/setup.sh @@ -582,9 +582,9 @@ function install_ratpac() export CRYINCLUDE="${options[prefix]}"/include/cry export CRYDATA="${options[prefix]}"/data/cry fi + cd "${options[prefix]}" || exit 1 rm -rf ratpac - git clone "${options[ratpac_repository]}" ratpac - cd ratpac || exit 1 + git clone "${options[ratpac_repository]}" ratpac && (cd ratpac || exit 1) if [ "${options[arm64_enabled]}" = true ] then sed -i '' 's/x86_64/arm64/g' CMakeLists.txt @@ -601,12 +601,14 @@ include_directories(${options[prefix]}/include)" CMakeLists.txt fi # avoid using default Makefile as it lacks portability for different OSs # make -j${options[procuse]} && source ./ratpac.sh - mkdir -p build && (cd build || exit 1) + mkdir -p build + cd build || exit 1 LIBSUFFIX="so" if [ "${options[enable_mac]}" = true ] then LIBSUFFIX="dylib" fi + pwd cmake -DXercesC_INCLUDE_DIR="${options[prefix]}"/include -DXercesC_LIBRARY_RELEASE="${options[prefix]}"/lib/libxerces-c."${LIBSUFFIX}" -DCMAKE_INSTALL_PREFIX=../install .. make && make install && cd .. && source ./ratpac.sh # Check if ratpac was successful, otherwise exit From fec147d25572fe10674fe0e27c8446c1a9510250 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 24 May 2024 14:34:28 +0100 Subject: [PATCH 26/42] More adjustments to cd behavior --- setup.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index 2be65f0..dfdb409 100755 --- a/setup.sh +++ b/setup.sh @@ -582,9 +582,9 @@ function install_ratpac() export CRYINCLUDE="${options[prefix]}"/include/cry export CRYDATA="${options[prefix]}"/data/cry fi - cd "${options[prefix]}" || exit 1 rm -rf ratpac - git clone "${options[ratpac_repository]}" ratpac && (cd ratpac || exit 1) + git clone "${options[ratpac_repository]}" ratpac + cd ratpac || exit 1 if [ "${options[arm64_enabled]}" = true ] then sed -i '' 's/x86_64/arm64/g' CMakeLists.txt @@ -608,7 +608,6 @@ include_directories(${options[prefix]}/include)" CMakeLists.txt then LIBSUFFIX="dylib" fi - pwd cmake -DXercesC_INCLUDE_DIR="${options[prefix]}"/include -DXercesC_LIBRARY_RELEASE="${options[prefix]}"/lib/libxerces-c."${LIBSUFFIX}" -DCMAKE_INSTALL_PREFIX=../install .. make && make install && cd .. && source ./ratpac.sh # Check if ratpac was successful, otherwise exit From e64fec99b9e743f5e33fae230660094b3782c0c6 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 24 May 2024 14:42:29 +0100 Subject: [PATCH 27/42] Edit mac install Escaped the $ character in one of the sed commands --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index dfdb409..24b7375 100755 --- a/setup.sh +++ b/setup.sh @@ -594,7 +594,7 @@ function install_ratpac() sed -i '' 's/.*Wno-terminate.*//g' CMakeLists.txt sed -i '' 's/\.so/.dylib/g' config/RatpacConfig.cmake.in sed -i '' "36 i\\ -set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${options[prefix]}/lib)\\ +set(CMAKE_LIBRARY_PATH \${CMAKE_LIBRARY_PATH} ${options[prefix]}/lib)\\ include_directories(${options[prefix]}/include)" CMakeLists.txt sed -i '' '11 i\ #include ' src/core/include/RAT/ProcAllocator.hh From 4cd7445ceb26eea6d7e028e9dcdddfae8d7114c8 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 24 May 2024 15:09:24 +0100 Subject: [PATCH 28/42] Change order of install Print help message and read in arguments before checking for dependencies. --- setup.sh | 94 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/setup.sh b/setup.sh index 24b7375..229583c 100755 --- a/setup.sh +++ b/setup.sh @@ -21,41 +21,10 @@ function install(){ do install_selection[$element]=true done - # Versioning - root_branch="v6-28-00-patches" - geant_branch="v11.1.2" - ratpac_repository="https://github.com/rat-pac/ratpac-two.git" - + # help message help "$@" - procuse=$(getnproc "$@") - # End testing - # Check requirements; Git && GCC - if ! [ -x "$(command -v gcc)" ]; then - echo "gcc not installed" - exit 1 - fi - if ! [ -x "$(command -v git)" ]; then - echo "git not installed" - exit 1 - fi - CC=$(command -v gcc) - export CC - CXX=$(command -v g++) - export CXX - - outfile="env.sh" - prefix=$(pwd -P)/local - mkdir -p "${prefix}"/bin - export PATH=$prefix/bin:$PATH - export LD_LIBRARY_PATH=$prefix/lib:$LD_LIBRARY_PATH - export DYLD_LIBRARY_PATH=$prefix/lib:$DYLD_LIBRARY_PATH - printf 'export PATH=%s/bin:$PATH\n' "$prefix" > $outfile - printf 'export LD_LIBRARY_PATH=%s/lib:$LD_LIBRARY_PATH\n' "$prefix" >> $outfile - printf 'export DYLD_LIBRARY_PATH=%s/lib:$DYLD_LIBRARY_PATH\n' "$prefix" >> $outfile - printf 'export CC=%s\n' "$CC" >> $outfile - printf 'export CXX=%s\n' "$CXX" >> $outfile - ## Tensorflow options + ## run options enable_gpu=false enable_mac=false enable_arm64=false # for arm64 architectures (e.g. mac with silicon chip) @@ -114,12 +83,54 @@ function install(){ enable_arm64=true fi done - # global options dictionary declare -A options=(["procuse"]=$procuse ["prefix"]=$prefix ["root_branch"]=$root_branch \ ["geant_branch"]=$geant_branch ["enable_gpu"]=$enable_gpu ["enable_mac"]=$enable_mac \ ["ratpac_repository"]=$ratpac_repository ["cleanup"]=$cleanup) + # check dependencies unless skipped + if ! skip_check "$@" + then + if ! check_deps + then + printf "\033[31mPlease install system dependencies as indicated above.\033[0m\n" + printf "\033[31mYou can skip these checks by passing the --skip-checks flag.\033[0m\n" + exit 1 + fi + fi + # Versioning + root_branch="v6-28-00-patches" + geant_branch="v11.1.2" + ratpac_repository="https://github.com/rat-pac/ratpac-two.git" + + procuse=$(getnproc "$@") + # End testing + # Check requirements; Git && GCC + if ! [ -x "$(command -v gcc)" ]; then + echo "gcc not installed" + exit 1 + fi + if ! [ -x "$(command -v git)" ]; then + echo "git not installed" + exit 1 + fi + CC=$(command -v gcc) + export CC + CXX=$(command -v g++) + export CXX + + outfile="env.sh" + prefix=$(pwd -P)/local + mkdir -p "${prefix}"/bin + export PATH=$prefix/bin:$PATH + export LD_LIBRARY_PATH=$prefix/lib:$LD_LIBRARY_PATH + export DYLD_LIBRARY_PATH=$prefix/lib:$DYLD_LIBRARY_PATH + printf 'export PATH=%s/bin:$PATH\n' "$prefix" > $outfile + printf 'export LD_LIBRARY_PATH=%s/lib:$LD_LIBRARY_PATH\n' "$prefix" >> $outfile + printf 'export DYLD_LIBRARY_PATH=%s/lib:$DYLD_LIBRARY_PATH\n' "$prefix" >> $outfile + printf 'export CC=%s\n' "$CC" >> $outfile + printf 'export CXX=%s\n' "$CXX" >> $outfile + if [ "${install_selection[cmake]}" = true ] then install_cmake @@ -683,16 +694,5 @@ function install_nlopt() } -## Main function with checks -if skip_check "$@" -then - install "$@" -else - if check_deps - then - install "$@" - else - printf "\033[31mPlease install system dependencies as indicated above.\033[0m\n" - printf "\033[31mYou can skip these checks by passing the --skip-checks flag.\033[0m\n" - fi -fi +## Main function +install "$@" \ No newline at end of file From 035cc006e223e0d9f776fa2a350173e37110db49 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 24 May 2024 15:42:56 +0100 Subject: [PATCH 29/42] Fix some issues cause by install changes Some variables weren't being set due to reordering the code. Now fixed. --- setup.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/setup.sh b/setup.sh index 229583c..24a5d2c 100755 --- a/setup.sh +++ b/setup.sh @@ -30,6 +30,11 @@ function install(){ enable_arm64=false # for arm64 architectures (e.g. mac with silicon chip) cleanup=true boolOnly=false + prefix=$(pwd -P)/local + # Versioning + root_branch="v6-28-00-patches" + geant_branch="v11.1.2" + ratpac_repository="https://github.com/rat-pac/ratpac-two.git" for element in "$@" do @@ -98,10 +103,6 @@ function install(){ exit 1 fi fi - # Versioning - root_branch="v6-28-00-patches" - geant_branch="v11.1.2" - ratpac_repository="https://github.com/rat-pac/ratpac-two.git" procuse=$(getnproc "$@") # End testing @@ -120,7 +121,6 @@ function install(){ export CXX outfile="env.sh" - prefix=$(pwd -P)/local mkdir -p "${prefix}"/bin export PATH=$prefix/bin:$PATH export LD_LIBRARY_PATH=$prefix/lib:$LD_LIBRARY_PATH @@ -321,14 +321,15 @@ function install_cmake() { trap 'handle_error "cmake install" $LINENO' ERR echo "Installing cmake..." - git clone https://github.com/Kitware/CMake.git --single-branch --branch v3.22.0 cmake_src - mkdir -p cmake_build - cd cmake_build || exit 1 - ../cmake_src/bootstrap --prefix=../local \ - && make -j"${options[procuse]}" \ - && make install - cd ../ + # git clone https://github.com/Kitware/CMake.git --single-branch --branch v3.22.0 cmake_src + # mkdir -p cmake_build + # cd cmake_build || exit 1 + # ../cmake_src/bootstrap --prefix=../local \ + # && make -j"${options[procuse]}" \ + # && make install + # cd ../ # Check if cmake was successful, if so clean-up, otherwise exit + echo "${options[prefix]}"/bin/cmake if test -f "${options[prefix]}"/bin/cmake then printf "Cmake install successful\n" From b27732f40c775f1623659629119998ac5261c219 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 24 May 2024 15:42:56 +0100 Subject: [PATCH 30/42] Fix some issues cause by install changes Some variables weren't being set due to reordering the code. Now fixed. --- setup.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/setup.sh b/setup.sh index 229583c..4bebcb4 100755 --- a/setup.sh +++ b/setup.sh @@ -30,6 +30,11 @@ function install(){ enable_arm64=false # for arm64 architectures (e.g. mac with silicon chip) cleanup=true boolOnly=false + prefix=$(pwd -P)/local + # Versioning + root_branch="v6-28-00-patches" + geant_branch="v11.1.2" + ratpac_repository="https://github.com/rat-pac/ratpac-two.git" for element in "$@" do @@ -98,10 +103,6 @@ function install(){ exit 1 fi fi - # Versioning - root_branch="v6-28-00-patches" - geant_branch="v11.1.2" - ratpac_repository="https://github.com/rat-pac/ratpac-two.git" procuse=$(getnproc "$@") # End testing @@ -120,7 +121,6 @@ function install(){ export CXX outfile="env.sh" - prefix=$(pwd -P)/local mkdir -p "${prefix}"/bin export PATH=$prefix/bin:$PATH export LD_LIBRARY_PATH=$prefix/lib:$LD_LIBRARY_PATH From 08fd96b77a0098cf3e5bd242eb392aab69a598bf Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 24 May 2024 15:49:26 +0100 Subject: [PATCH 31/42] Uncomment code Accidentally left some code commented from tests --- setup.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/setup.sh b/setup.sh index 24a5d2c..b49a78a 100755 --- a/setup.sh +++ b/setup.sh @@ -321,13 +321,13 @@ function install_cmake() { trap 'handle_error "cmake install" $LINENO' ERR echo "Installing cmake..." - # git clone https://github.com/Kitware/CMake.git --single-branch --branch v3.22.0 cmake_src - # mkdir -p cmake_build - # cd cmake_build || exit 1 - # ../cmake_src/bootstrap --prefix=../local \ - # && make -j"${options[procuse]}" \ - # && make install - # cd ../ + git clone https://github.com/Kitware/CMake.git --single-branch --branch v3.22.0 cmake_src + mkdir -p cmake_build + cd cmake_build || exit 1 + ../cmake_src/bootstrap --prefix=../local \ + && make -j"${options[procuse]}" \ + && make install + cd ../ # Check if cmake was successful, if so clean-up, otherwise exit echo "${options[prefix]}"/bin/cmake if test -f "${options[prefix]}"/bin/cmake From e76d4f3acfbe19c598febf470006ef4e5a3bdee7 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 24 May 2024 16:19:52 +0100 Subject: [PATCH 32/42] Change CPPFLAGS to CXXFLAGS ICU build was complaining -std=c++17 is only for c++ and not c. This should fix it. --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index b49a78a..3b2f8c9 100755 --- a/setup.sh +++ b/setup.sh @@ -351,7 +351,7 @@ function install_icu() tar xzf icu4c-74_2-src.tgz cd icu/source || exit 1 chmod +x runConfigureICU configure install-sh - export CPPFLAGS="-std=c++17" + export CXXFLAGS="-std=c++17" ./configure --prefix="${options[prefix]}" make -j"${options[procuse]}" && make install cd ../.. From bea8488882244375dfc791634701edf1652906e5 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Tue, 28 May 2024 17:05:17 +0100 Subject: [PATCH 33/42] Update LD_LIBRARY_PATH in cry_install --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 3b2f8c9..18464a8 100755 --- a/setup.sh +++ b/setup.sh @@ -483,7 +483,7 @@ function install_cry() sed -i '25 i \\t$(CXX) -shared $(OBJ) -o ../lib/libCRY.so' src/Makefile sed -i 's/\-Wall/\-Wall \-fPIC/g' src/Makefile fi - LD_LIBRARY_PATH="${options[prefix]}"/cry_v1.7/lib:"$LD_LIBRARY_PATH" + LD_LIBRARY_PATH="${options[prefix]}"/../cry_v1.7/lib:"$LD_LIBRARY_PATH" make -j1 # Race condition using multiple threads mkdir -p "${options[prefix]}"/data/cry mv data/* "${options[prefix]}"/data/cry From e88c204e0d2b6485417bef8f730fe0d86577ab87 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 31 May 2024 11:26:19 +0100 Subject: [PATCH 34/42] Fix write to env.sh after ratpac_install and edit help message --- setup.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/setup.sh b/setup.sh index 18464a8..6b7ac16 100755 --- a/setup.sh +++ b/setup.sh @@ -120,7 +120,7 @@ function install(){ CXX=$(command -v g++) export CXX - outfile="env.sh" + outfile="${prefix}/../env.sh" mkdir -p "${prefix}"/bin export PATH=$prefix/bin:$PATH export LD_LIBRARY_PATH=$prefix/lib:$LD_LIBRARY_PATH @@ -191,8 +191,6 @@ function install(){ then install_ratpac fi - - trap 'handle_error "post installation tasks" $LINENO' ERR if test -f "$prefix"/lib/libCRY.so then printf 'export CRYLIB=%s/lib\n' "$prefix" >> $outfile @@ -211,6 +209,7 @@ function help() ["skip"]="Skip the following packages" \ ["gpu"]="Enable GPU support for tensorflow" \ ["mac"]="Enable Mac support" \ + ["arm64"]="Enable arm64 architecure support" \ ["noclean"]="Do not clean up after install") for element in "$@" do @@ -630,7 +629,7 @@ include_directories(${options[prefix]}/include)" CMakeLists.txt printf "Ratpac install failed ... check logs\n" exit 1 fi - cd ../.. + cd .. } function install_chroma() From 94b1a980500238bd9a74fa507ed8ac23c4c3a41c Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 31 May 2024 14:17:56 +0100 Subject: [PATCH 35/42] Force nlopt to write libraries to lib and not lib64 --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 6b7ac16..26d19e1 100755 --- a/setup.sh +++ b/setup.sh @@ -677,7 +677,7 @@ function install_nlopt() echo "Installing nlopt..." git clone https://github.com/stevengj/nlopt.git pushd nlopt || exit 1 - cmake -DCMAKE_INSTALL_PREFIX="${options[prefix]}" . -Bbuild + cmake -DCMAKE_INSTALL_PREFIX="${options[prefix]}" -DCMAKE_INSTALL_LIBDIR=lib . -Bbuild cmake --build build --target install popd || exit 1 if test -f "${options[prefix]}"/include/nlopt.h From 0e69769f15486fe9fddb5882c211341e0e874e77 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Wed, 5 Jun 2024 11:01:34 +0100 Subject: [PATCH 36/42] Fix arm64 and mac options --- setup.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/setup.sh b/setup.sh index 26d19e1..b007b4d 100755 --- a/setup.sh +++ b/setup.sh @@ -91,7 +91,7 @@ function install(){ # global options dictionary declare -A options=(["procuse"]=$procuse ["prefix"]=$prefix ["root_branch"]=$root_branch \ ["geant_branch"]=$geant_branch ["enable_gpu"]=$enable_gpu ["enable_mac"]=$enable_mac \ - ["ratpac_repository"]=$ratpac_repository ["cleanup"]=$cleanup) + ["ratpac_repository"]=$ratpac_repository ["cleanup"]=$cleanup ["enable_arm64"]=$enable_arm64) # check dependencies unless skipped if ! skip_check "$@" @@ -403,7 +403,7 @@ function install_root() mkdir -p root_build cd root_build || exit 1 GLEW="" - if ${options[mac_enabled]} + if ${options[enable_mac]} then GLEW="-D builtin_glew=ON" fi @@ -596,11 +596,11 @@ function install_ratpac() rm -rf ratpac git clone "${options[ratpac_repository]}" ratpac cd ratpac || exit 1 - if [ "${options[arm64_enabled]}" = true ] + if [ "${options[enable_arm64]}" = true ] then sed -i '' 's/x86_64/arm64/g' CMakeLists.txt fi - if [ "${options[mac_enabled]}" = true ] + if [ "${options[enable_mac]}" = true ] then sed -i '' 's/.*Wno-terminate.*//g' CMakeLists.txt sed -i '' 's/\.so/.dylib/g' config/RatpacConfig.cmake.in @@ -695,4 +695,4 @@ function install_nlopt() ## Main function -install "$@" \ No newline at end of file +install "$@" From c8b185dbf608c95ddf16960ef3d2eae2977cf901 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Sat, 13 Jul 2024 11:33:36 +0700 Subject: [PATCH 37/42] Fix issue on macos where install used high memory The variable `procuse` that passes on the number of cores to use in the build was being set after options[procuse] was defined. Hence when `make -j"${options[procuse]}"` was being called, it resulted in `make -j` being executed. Not sure why this led to lots of memory usage at the build stage, but setting `procuse` at the correct point seems to have fixed things. Also updated the docs with a mention of the MacOS installation. --- README.md | 22 ++++++++++++++++++++-- setup.sh | 17 +++++++++-------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 4c0bc0c..ef062df 100644 --- a/README.md +++ b/README.md @@ -43,14 +43,32 @@ Additional options are available, including passing make commands ```bash # For linux, tensorflow can either use the cpu(default) or gpu ./setup.sh --only tensorflow --gpu -# For mac, a separate tensorflow is available -./setup.sh --only tensorflow --mac # Pass number of processors to make, and even keep downloaded files for debugging ./setup.sh -j8 --noclean # For complete information run ./setup.sh -h ``` +### MacOS +Installation is possible on MacOS using the flag `--mac`. If using Apple +Silicon (ARM64 architecture), one will also need the flag `--arm64`. The +installation *assumes a zsh shell* for macs. + +The MacOS installation is similar to the Linux installation, but uses dynamic +libraries rather than shared libraries. Some CMakeLists.txt files (including +ratpac's) are adjusted for the mac installation. Please be aware of this if +developing code and committing changes to CMakeLists.txt. Ideally, we will +remove these CMakeLists.txt edits in the future. + +On Apple Silicon, the installation of ROOT can sometimes run into issues with the +error message `read jobs pipe: Resource temporarily unavailable.`. There doesn't +seem to be a consistent permanent solution to this, but if you run the +`make && make install` command again within the `root_build` directory (maybe +more than once), the build should finish. Then continue with the installation +with setup.sh and skipping cmake, icu, xerces and root. + +Mac installation tested on Apple M1 Pro with Sonoma 14.5. + ## Usage Once installation is complete there will be a new directory structure from where `setup.sh` is run with a complete `./local` directory that contains all diff --git a/setup.sh b/setup.sh index b007b4d..e5b1283 100755 --- a/setup.sh +++ b/setup.sh @@ -88,6 +88,7 @@ function install(){ enable_arm64=true fi done + procuse=$(getnproc "$@") # global options dictionary declare -A options=(["procuse"]=$procuse ["prefix"]=$prefix ["root_branch"]=$root_branch \ ["geant_branch"]=$geant_branch ["enable_gpu"]=$enable_gpu ["enable_mac"]=$enable_mac \ @@ -104,7 +105,6 @@ function install(){ fi fi - procuse=$(getnproc "$@") # End testing # Check requirements; Git && GCC if ! [ -x "$(command -v gcc)" ]; then @@ -323,23 +323,24 @@ function install_cmake() git clone https://github.com/Kitware/CMake.git --single-branch --branch v3.22.0 cmake_src mkdir -p cmake_build cd cmake_build || exit 1 - ../cmake_src/bootstrap --prefix=../local \ - && make -j"${options[procuse]}" \ - && make install + ../cmake_src/bootstrap --prefix=../local --parallel="${options[procuse]}" + echo make -j"${options[procuse]}" + make -j"${options[procuse]}" + make install cd ../ # Check if cmake was successful, if so clean-up, otherwise exit - echo "${options[prefix]}"/bin/cmake if test -f "${options[prefix]}"/bin/cmake then - printf "Cmake install successful\n" + printf "CMake install successful\n" else - printf "Cmake install failed ... check logs\n" + printf "CMake install failed ... check logs\n" exit 1 fi if [ "${options[cleanup]}" = true ] then rm -rf cmake_src cmake_build fi + } function install_icu() @@ -611,7 +612,7 @@ include_directories(${options[prefix]}/include)" CMakeLists.txt #include ' src/core/include/RAT/ProcAllocator.hh fi # avoid using default Makefile as it lacks portability for different OSs - # make -j${options[procuse]} && source ./ratpac.sh + # make -j"${options[procuse]}" && source ./ratpac.sh mkdir -p build cd build || exit 1 LIBSUFFIX="so" From 647d8460c2fa5072f2a3ed2491646da618403414 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock <35494436+WilfS@users.noreply.github.com> Date: Wed, 17 Jul 2024 15:07:33 +0100 Subject: [PATCH 38/42] Fix bug introduced by merge with main hdf5 has been added to the install and I accidentally added a comma when adding it to the install option. Fixed now. --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 3d02526..2b0ff9f 100755 --- a/setup.sh +++ b/setup.sh @@ -15,7 +15,7 @@ handle_error() { function install(){ trap 'handle_error "setup" $LINENO' ERR ## Array of installables - declare -a install_options=("cmake" "root" "geant4" "chroma" "cry" "tensorflow" "torch" "ratpac" "nlopt" "xerces" "icu", "hdf5") + declare -a install_options=("cmake" "root" "geant4" "chroma" "cry" "tensorflow" "torch" "ratpac" "nlopt" "xerces" "icu" "hdf5") declare -A install_selection for element in "${install_options[@]}" do From 4ca6d0a29d775fd9fe05297cef5b5bbd87c96a47 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Thu, 9 Jan 2025 16:20:54 +0000 Subject: [PATCH 39/42] Update ROOT version for mac install Older versions of ROOT do not build on the latest macOS versions. Our solution is to checkout v6-34-00-patches for the mac installation. v6-28-00-patches is still used for non-mac installs. --- setup.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/setup.sh b/setup.sh index 2b0ff9f..1d185e5 100755 --- a/setup.sh +++ b/setup.sh @@ -33,6 +33,7 @@ function install(){ prefix=$(pwd -P)/local # Versioning root_branch="v6-28-00-patches" + root_branch_mac="v6-34-00-patches" geant_branch="v11.1.2" ratpac_repository="https://github.com/rat-pac/ratpac-two.git" @@ -92,7 +93,8 @@ function install(){ # global options dictionary declare -A options=(["procuse"]=$procuse ["prefix"]=$prefix ["root_branch"]=$root_branch \ ["geant_branch"]=$geant_branch ["enable_gpu"]=$enable_gpu ["enable_mac"]=$enable_mac \ - ["ratpac_repository"]=$ratpac_repository ["cleanup"]=$cleanup ["enable_arm64"]=$enable_arm64) + ["ratpac_repository"]=$ratpac_repository ["cleanup"]=$cleanup ["enable_arm64"]=$enable_arm64 \ + ["root_branch_mac"]=$root_branch_mac) # check dependencies unless skipped if ! skip_check "$@" @@ -383,7 +385,8 @@ function install_xerces() cd xerces-c-3.2.5 || exit 1 mkdir -p build cd build || exit 1 - cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${options[prefix]}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DICU_ROOT="${options[prefix]}" .. \ + #cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${options[prefix]}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DICU_ROOT="${options[prefix]}" .. \ + cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${options[prefix]}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -Dtranscoder=iconv .. \ && make -j"${options[procuse]}" \ && make install cd ../.. @@ -405,15 +408,22 @@ function install_root() { trap 'handle_error "root install" $LINENO' ERR echo "Installing ROOT..." - git clone https://github.com/root-project/root.git --depth 1 --single-branch --branch "${options[root_branch]}" root_src + if ${options[enable_mac]} + then + git clone https://github.com/root-project/root.git --depth 1 --single-branch --branch "${options[root_branch_mac]}" root_src + else + git clone https://github.com/root-project/root.git --depth 1 --single-branch --branch "${options[root_branch]}" root_src + fi mkdir -p root_build cd root_build || exit 1 GLEW="" + MINUIT="ON" if ${options[enable_mac]} then GLEW="-D builtin_glew=ON" + MINUIT="OFF" fi - cmake -DCMAKE_INSTALL_PREFIX="${options[prefix]}" -D xrootd=OFF -D roofit=OFF -D minuit2=ON -D CMAKE_CXX_STANDARD=17 "${GLEW}"\ + cmake -DCMAKE_INSTALL_PREFIX="${options[prefix]}" -D xrootd=OFF -D roofit=OFF -D minuit2="${MINUIT}" -D CMAKE_CXX_STANDARD=17 "${GLEW}"\ ../root_src \ && make -j"${options[procuse]}" \ && make install From ff5d3421db8f45fac1b8b427acebbc1e0f27563f Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 2 May 2025 15:43:27 +0100 Subject: [PATCH 40/42] Remove ICU dependency ICU is used as a transcoder by xerces-c, but is not always present by default on machines. The build now tells xerces-c to use iconv rather than ICU, which is more likely to be pre-installed. --- setup.sh | 36 +++--------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/setup.sh b/setup.sh index 1d185e5..8073c86 100755 --- a/setup.sh +++ b/setup.sh @@ -15,7 +15,7 @@ handle_error() { function install(){ trap 'handle_error "setup" $LINENO' ERR ## Array of installables - declare -a install_options=("cmake" "root" "geant4" "chroma" "cry" "tensorflow" "torch" "ratpac" "nlopt" "xerces" "icu" "hdf5") + declare -a install_options=("cmake" "root" "geant4" "chroma" "cry" "tensorflow" "torch" "ratpac" "nlopt" "xerces" "hdf5") declare -A install_selection for element in "${install_options[@]}" do @@ -34,7 +34,8 @@ function install(){ # Versioning root_branch="v6-28-00-patches" root_branch_mac="v6-34-00-patches" - geant_branch="v11.1.2" + #geant_branch="v11.1.2" + geant_branch="v11.3.2" ratpac_repository="https://github.com/rat-pac/ratpac-two.git" for element in "$@" @@ -138,11 +139,6 @@ function install(){ install_cmake fi - if [ "${install_selection[icu]}" = true ] - then - install_icu - fi - if [ "${install_selection[xerces]}" = true ] then install_xerces @@ -350,32 +346,6 @@ function install_cmake() } -function install_icu() -{ - trap 'handle_error "ICU install" $LINENO' ERR - echo "Installing ICU..." - wget https://github.com/unicode-org/icu/releases/download/release-74-2/icu4c-74_2-src.tgz - tar xzf icu4c-74_2-src.tgz - cd icu/source || exit 1 - chmod +x runConfigureICU configure install-sh - export CXXFLAGS="-std=c++17" - ./configure --prefix="${options[prefix]}" - make -j"${options[procuse]}" && make install - cd ../.. - # Check if cmake was successful, if so clean-up, otherwise exit - if test -f "${options[prefix]}"/bin/icu-config - then - printf "ICU install successful\n" - else - printf "ICU install failed ... check logs\n" - exit 1 - fi - if [ "${options[cleanup]}" = true ] - then - rm -rf icu4c-74_2-src.tgz icu - fi -} - function install_xerces() { trap 'handle_error "xerces install" $LINENO' ERR From d742d7ce92c22606b416af99d068154af24c9130 Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 2 May 2025 15:47:18 +0100 Subject: [PATCH 41/42] Revert geant4 version to default Accidentally changed the geant4 version in the last commit. This changes it back to the version used before. --- setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index 8073c86..9018ebe 100755 --- a/setup.sh +++ b/setup.sh @@ -34,8 +34,8 @@ function install(){ # Versioning root_branch="v6-28-00-patches" root_branch_mac="v6-34-00-patches" - #geant_branch="v11.1.2" - geant_branch="v11.3.2" + geant_branch="v11.1.2" + #geant_branch="v11.3.2" ratpac_repository="https://github.com/rat-pac/ratpac-two.git" for element in "$@" From 40a014d921e4dcc7b6003e60cd6653aa71ec7afa Mon Sep 17 00:00:00 2001 From: Wilf Shorrock Date: Fri, 9 May 2025 10:27:17 +0100 Subject: [PATCH 42/42] Remove xerces-c from main install The number of dependencies in ratpac-setup should be minimised. Xerces-C is normally present on most machines, so it's been removed from the main installation with the option of installing with a specific command if needed. The readme has been updated with instructions. --- README.md | 13 +++++++++---- setup.sh | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ef062df..45c491f 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,7 @@ you do not wish to reinstall, though do note you will have to properly link them in that case (ROOT / Geant-4). - CMake v3.22.0+ -- ICU4C 74.2 -- Xerces-C 3.2.5 -- Python 3.x.x +- Xerces-C 3.2.5 (not built by default) - Root 6.25+ - Geant-4 11.0 - CRY 1.7 @@ -49,6 +47,13 @@ Additional options are available, including passing make commands ./setup.sh -h ``` +### Building Xerces-C +The Xerces-C library is required by Geant4. Most machines will have Xerces-C, but not all. The library is NOT included in the default ratpac-setup build, but can be pre-built before your main installation using ratpac-setup. To build Xerces-C, use the command +``` +./setup --only xerces +``` +and then continue with the main installation. + ### MacOS Installation is possible on MacOS using the flag `--mac`. If using Apple Silicon (ARM64 architecture), one will also need the flag `--arm64`. The @@ -65,7 +70,7 @@ error message `read jobs pipe: Resource temporarily unavailable.`. There doesn't seem to be a consistent permanent solution to this, but if you run the `make && make install` command again within the `root_build` directory (maybe more than once), the build should finish. Then continue with the installation -with setup.sh and skipping cmake, icu, xerces and root. +with setup.sh, skipping cmake and root. Mac installation tested on Apple M1 Pro with Sonoma 14.5. diff --git a/setup.sh b/setup.sh index 9018ebe..e2adf01 100755 --- a/setup.sh +++ b/setup.sh @@ -16,9 +16,15 @@ function install(){ trap 'handle_error "setup" $LINENO' ERR ## Array of installables declare -a install_options=("cmake" "root" "geant4" "chroma" "cry" "tensorflow" "torch" "ratpac" "nlopt" "xerces" "hdf5") + # declare -a install_options=("cmake" "root" "geant4" "chroma" "cry" "tensorflow" "torch" "ratpac" "nlopt" "hdf5") declare -A install_selection for element in "${install_options[@]}" do + if [ "$element" == "xerces" ] + then + install_selection[$element]=false + continue + fi install_selection[$element]=true done # help message @@ -35,7 +41,7 @@ function install(){ root_branch="v6-28-00-patches" root_branch_mac="v6-34-00-patches" geant_branch="v11.1.2" - #geant_branch="v11.3.2" + # geant_branch="v11.3.2" ratpac_repository="https://github.com/rat-pac/ratpac-two.git" for element in "$@" @@ -355,7 +361,6 @@ function install_xerces() cd xerces-c-3.2.5 || exit 1 mkdir -p build cd build || exit 1 - #cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${options[prefix]}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DICU_ROOT="${options[prefix]}" .. \ cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${options[prefix]}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -Dtranscoder=iconv .. \ && make -j"${options[procuse]}" \ && make install @@ -424,12 +429,27 @@ function install_geant4() then LIBSUFFIX="dylib" fi - cmake -DCMAKE_INSTALL_PREFIX="${options[prefix]}" -DCMAKE_INSTALL_LIBDIR=lib \ + if [ -f "${options[prefix]}"/lib/libxerces-c.${LIBSUFFIX} ] + then + cmake -DCMAKE_INSTALL_PREFIX="${options[prefix]}" -DCMAKE_INSTALL_LIBDIR=lib \ ../geant_src -DGEANT4_BUILD_EXPAT=OFF \ -DGEANT4_BUILD_MULTITHREADED=OFF -DGEANT4_USE_QT=ON -DGEANT4_INSTALL_DATA=ON \ -DGEANT4_BUILD_TLS_MODEL=global-dynamic \ -DGEANT4_INSTALL_DATA_TIMEOUT=15000 -DGEANT4_USE_GDML=ON \ -DXercesC_INCLUDE_DIR="${options[prefix]}"/include -DXercesC_LIBRARY_RELEASE="${options[prefix]}"/lib/libxerces-c."${LIBSUFFIX}" + else + cmake -DCMAKE_INSTALL_PREFIX="${options[prefix]}" -DCMAKE_INSTALL_LIBDIR=lib \ + ../geant_src -DGEANT4_BUILD_EXPAT=OFF \ + -DGEANT4_BUILD_MULTITHREADED=OFF -DGEANT4_USE_QT=ON -DGEANT4_INSTALL_DATA=ON \ + -DGEANT4_BUILD_TLS_MODEL=global-dynamic \ + -DGEANT4_INSTALL_DATA_TIMEOUT=15000 -DGEANT4_USE_GDML=ON + fi + # cmake -DCMAKE_INSTALL_PREFIX="${options[prefix]}" -DCMAKE_INSTALL_LIBDIR=lib \ + # ../geant_src -DGEANT4_BUILD_EXPAT=OFF \ + # -DGEANT4_BUILD_MULTITHREADED=OFF -DGEANT4_USE_QT=ON -DGEANT4_INSTALL_DATA=ON \ + # -DGEANT4_BUILD_TLS_MODEL=global-dynamic \ + # -DGEANT4_INSTALL_DATA_TIMEOUT=15000 -DGEANT4_USE_GDML=ON \ + # -DXercesC_INCLUDE_DIR="${options[prefix]}"/include -DXercesC_LIBRARY_RELEASE="${options[prefix]}"/lib/libxerces-c."${LIBSUFFIX}" make -j"${options[procuse]}" \ && make install cd ../ @@ -605,7 +625,15 @@ include_directories(${options[prefix]}/include)" CMakeLists.txt then LIBSUFFIX="dylib" fi - cmake -DXercesC_INCLUDE_DIR="${options[prefix]}"/include -DXercesC_LIBRARY_RELEASE="${options[prefix]}"/lib/libxerces-c."${LIBSUFFIX}" -DCMAKE_INSTALL_PREFIX=../install .. + if [ -f "${options[prefix]}"/lib/libxerces-c.${LIBSUFFIX} ] + then + cmake -DCMAKE_INSTALL_PREFIX="${options[prefix]}" -DXercesC_INCLUDE_DIR="${options[prefix]}"/include -DXercesC_LIBRARY_RELEASE="${options[prefix]}"/lib/libxerces-c."${LIBSUFFIX}" .. + else + cmake -DCMAKE_INSTALL_PREFIX="${options[prefix]}" .. + fi + # cmake -DCMAKE_INSTALL_PREFIX=../install .. \ + # -DXercesC_INCLUDE_DIR="${options[prefix]}"/include -DXercesC_LIBRARY_RELEASE="${options[prefix]}"/lib/libxerces-c."${LIBSUFFIX}" \ + make && make install && cd .. && source ./ratpac.sh # Check if ratpac was successful, otherwise exit if test -f install/bin/rat