From 06b7ebc3ea9be3b8e3f5835320f8f028119c9d7e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?GIRARD=20ALCINDOR=20Val=C3=A9rian?=
 <girard-alcindor@ijclab.in2p3.fr>
Date: Thu, 25 Jan 2024 23:14:45 +0100
Subject: [PATCH] Updating the build_dict.sh to be compatible with the new root
 versioning scheme (also had to git add the build_dict? Might be wrong...)

---
 NPLib/scripts/build_dict.sh | 75 +++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)
 create mode 100755 NPLib/scripts/build_dict.sh

diff --git a/NPLib/scripts/build_dict.sh b/NPLib/scripts/build_dict.sh
new file mode 100755
index 000000000..80a8a2268
--- /dev/null
+++ b/NPLib/scripts/build_dict.sh
@@ -0,0 +1,75 @@
+#!/bin/bash
+
+# This script detect the root version and call the command necessary to build 
+# a Dictionnary, rootmap and pcm file accordingly
+
+# Checking that enought argument are given
+if [ "$#" -lt 4 ]
+  then
+    echo "Dictionnary Generation in : $PWD"
+    echo "Incorrect argument number : 1.Header 2.DictName 3.Rootmap 4.LibName 5.(optional)LinkDefFile"
+    echo "Arguments are : $@"
+    exit 1
+fi
+
+# Modify the lib name according to the system
+lib_ext=.so
+system=$(uname -a)
+system="${system/%\ */}"
+if [ "$system" == "Darwin" ]
+  then
+    lib_ext=.dylib
+fi
+
+lib_name=$4
+lib_name="${lib_name%.*}"
+lib_name="$lib_name$lib_ext"
+
+# Detect the Root
+is_root=$(which root-config)
+
+# Detect the version
+if [ $is_root != "" ]; 
+  then
+    version=$(root-config --version)
+  else 
+    echo  "root-config not found"
+    exit 1
+fi
+
+# Get the Major version
+version_major_string="${version%.*}"
+# Since 6.30 they changed the numbering scheme from 6.XX/XX
+# to 6.XX.XX
+num_char=${#version_major_string}  
+if [ $num_char -gt 1 ]
+then version_major_string="${version%.*.*}"
+fi
+version_major=$(($version_major_string))
+
+# if before version 4, exit
+if [ $version_major -lt 5 ]
+  then
+    echo "Root version too old, min. version 5" 
+    exit 1
+fi
+
+# Version 5 : generate the dictionnary then the libmap
+if [ $version_major -eq 5 ]
+  then
+    # check rootcint exist
+    command -v rootcint >/dev/null 2>&1 || { printf >&2 "ERROR : rootcint binary not found.\n * For ROOT install from source check that \$ROOTSYS/bin is in your PATH\n * For Macports ROOT install consider adding /opt/local/bin to your PATH\n * For debian ROOT install consider adding /usr/bin to your PATH\n"; exit 1; }
+    rootcint -DNPMULTITHREADING=1 -f $2 -c -I../Core -I../Physics -I../../Core -I../../Physics -I../TrackReconstruction -I../../TrackReconstruction $1 $5
+fi
+
+# Version 6 or more : generate both at once
+if [ $version_major -gt 5 ]
+  then
+    # check rootcling exist
+    command -v rootcling >/dev/null 2>&1 || { printf >&2 "ERROR : rootcling binary not found.\n * For ROOT install from source check that \$ROOTSYS/bin is in your PATH\n * For Macports ROOT install consider adding /opt/local/bin to your PATH\n * For debian ROOT install consider adding /usr/bin to your PATH\n"; exit 1; }
+   rootcling -f $2 -rmf $3 -rml $lib_name -DNPMULTITHREADING=1 -I../Core -I../Physics -I../../Core -I../../Physics -I../TrackReconstruction -I../../TrackReconstruction $1 $5
+fi
+
+
+
+
-- 
GitLab