1,31 → 1,52 |
#!/bin/bash |
|
function colorecho |
{ |
echo -e$2 "\033[33m$1\033[39m" |
} |
|
function errorecho |
{ |
echo -e "\031[33m$1\033[39m" |
} |
|
function helptext() |
{ |
echo "#------------------------------" |
echo "# Configure instructions: -----" |
echo "#------------------------------" |
echo "" |
echo "./configure [option] [type]" |
echo "" |
echo "[option] = Option for configure:" |
echo " - help = Display configure instructions." |
echo " - nomake = Only prepare system dependent files (base directory and online/offline mode)." |
echo " - all = Prepare system dependent files and make used libraries." |
echo " - clean = Clean the installation directory. Does not clean the results directory." |
echo " - compress = Compress the source code in a tar-ball." |
echo "" |
echo "[type] = Configure for use in online or offline mode (only needed in nomake and all):" |
echo " - I = Online mode." |
echo " - O = Offline mode (no connection to CAMAC, motor, voltage supply and scope)." |
echo " - S = Offline mode with scope connection (no connection to CAMAC, motor and voltage supply)." |
echo "" |
echo "#------------------------------" |
colorecho "#------------------------------" |
colorecho "# Configure instructions: -----" |
colorecho "#------------------------------" |
colorecho "" |
colorecho "./configure [option] [type] [install directories] [ostype]" |
colorecho "" |
colorecho "[option] = Option for configure:" |
colorecho " help Display configure instructions." |
colorecho " nomake Only prepare system dependent files (base directory and online/offline mode)." |
colorecho " all Prepare system dependent files and make used libraries." |
colorecho " clean Clean the installation directory. Does not clean the results directory." |
colorecho " compress Compress the source code in a tar-ball." |
colorecho "" |
colorecho "[type] = Configure for use in online or offline mode (only needed in nomake and all):" |
colorecho " I Online mode." |
colorecho " O Offline mode (no connection to CAMAC, motor, voltage supply and scope)." |
colorecho " S Offline mode with scope connection (no connection to CAMAC, motor and voltage supply)." |
colorecho "" |
colorecho "[install directories] = Directories where ROOT and NET-SNMP are installed (when running with superuser, this is important, otherwise optional):" |
colorecho " --root-install=/root/install/directory" |
colorecho " --snmp-install=/snmp/install/directory" |
colorecho "" |
colorecho "[ostype] = Specific setting for 64bit or 32bit version of OS (optional):" |
colorecho " --ostype=i686 32bit OS type" |
colorecho " --ostype=x86_64 64bit OS type" |
colorecho "" |
colorecho "Example:" |
colorecho " ./configure all I --root-install=/home/user/root --snmp-install=/home/user/snmp" |
colorecho "" |
colorecho "#------------------------------" |
} |
|
# Check for arguments |
if [ "$1" == "" ]; then |
echo "Error! No arguments supplied." |
errorecho "Error! No arguments supplied." |
echo "" |
helptext |
exit 1 |
38,7 → 59,7 |
|
# Print help and exit if we give a wrong first argument |
if [ "$1" != "nomake" ] && [ "$1" != "all" ] && [ "$1" != "clean" ] && [ "$1" != "compress" ]; then |
echo "Error! Wrong configuration option selected (first argument)." |
errorecho "Error! Wrong configuration option selected (first argument)." |
echo "" |
helptext |
exit 1 |
46,7 → 67,52 |
|
startdir=$PWD |
|
ostype=`uname -p` |
# Check for ROOT and NET-SNMP install directories and for OS type |
snmpsearch="--snmp-install=" |
rootsearch="--root-install=" |
ossearch="--ostype=" |
snmpdirectory=-1 |
rootdirectory=-1 |
osmanual=-1 |
for var in $@ |
do |
case $var in |
"$snmpsearch"*) |
snmpdirectory=${var#$snmpsearch} |
echo "NET-SNMP directory: $snmpdirectory";; |
"$rootsearch"*) |
rootdirectory=${var#$rootsearch} |
echo "ROOT directory: $rootdirectory";; |
"$ossearch"*) |
osmanual=${var#$ossearch};; |
*) ;; |
esac |
done |
|
# If n ot supplied, check automatically for OS type |
if [ $osmanual == -1 ]; then |
ostype=`uname -p` |
if [ "$ostype" != "x86_64" ] && [ "$ostype" != "i686" ]; then |
ostype=`uname -i` |
if [ "$ostype" != "x86_64" ] && [ "$ostype" != "i686" ]; then |
ostype=`uname -m` |
fi |
fi |
else |
ostype=$osmanual |
fi |
|
# Check for installation directory of ROOT - if variables not currently set, remind user to set them before running make |
if [ "$1" != "clean" ] && [ "$1" != "compress" ]; then |
if [ $rootdirectory != -1 ]; then |
printenv ROOTSYS > /dev/null |
if [ $? != 0 ]; then |
colorecho "ROOT environment variables not set. Please run \"source $rootdirectory/bin/thisroot.sh\", before using make." |
fi |
else |
colorecho "Before running make, please make sure ROOT environment variables are set." |
fi |
fi |
|
# Compiles the table microcontroller program |
if [ "$1" == "all" ]; then |
65,10 → 131,10 |
mkdir $startdir/camac_gui_windowed |
mkdir $startdir/camac_gui_windowed/results |
echo "Copying source files to temporary directory $startdir/camac_gui_windowed..." |
cp -r configure daq.h daqscope.h GuiLinkDef.h libxxusb.cpp root_include.h start.cxx windowed_test.C windowed_test.h wusbcc.h wusbxx_dll.c wusbxx_dll.h mpod/ MIKRO/ vxi11_x86_64/ vxi11_i686/ input/ ./camac_gui_windowed/ |
cp -r configure daq.h daqscope.h GuiLinkDef.h libxxusb.cpp root_include.h README start.cxx windowed_test.C windowed_test.h wusbcc.h wusbxx_dll.c wusbxx_dll.h mpod/ MIKRO/ vxi11_x86_64/ vxi11_i686/ input/ fieldpoint/ ./camac_gui_windowed/ |
cd $startdir/camac_gui_windowed |
echo "Cleaning the base directory in $startdir/camac_gui_windowed..." |
rm -f *.bak |
rm -f *.bakc |
cd $startdir/camac_gui_windowed/input |
echo "Cleaning the input directory in $startdir/camac_gui_windowed/input..." |
rm -f *.bak |
87,7 → 153,7 |
rm -r $startdir/camac_gui_windowed |
exit 0 |
else |
echo "Error! Directory ./camac_gui_windowed already exists." |
errorecho "Error! Directory ./camac_gui_windowed already exists." |
exit 1 |
fi |
fi |
97,15 → 163,26 |
|
if [ "$1" == "nomake" ] || [ "$1" == "all" ]; then |
if [ "$2" == "O" ] || [ "$2" == "I" ] || [ "$2" == "S" ]; then |
# Setting up the current working computer |
grep -q "#define WORKSTAT 'N'" $startdir/input/workstation.h.in |
if [ $? == 0 ]; then |
sed "s/define WORKSTAT 'N'/define WORKSTAT '$2'/" $startdir/input/workstation.h.in > $startdir/workstation.h.mid |
sed "s/define WORKSTAT 'N'/define WORKSTAT '$2'/" $startdir/input/workstation.h.in > $startdir/input/workstation.h.mid |
fi |
grep -q "#define rootdir \"path-to-installation\"" $startdir/input/workstation.h.in |
if [ $? == 0 ]; then |
sed "s/path-to-installation/$basedir/g" $startdir/workstation.h.mid > $startdir/workstation.h |
rm $startdir/workstation.h.mid |
sed "s/path-to-installation/$basedir/g" $startdir/input/workstation.h.mid > $startdir/input/workstation.h.mid2 |
rm $startdir/input/workstation.h.mid |
fi |
# Check if we are connected to IJS network |
etnet=$(ifconfig | grep "178.172.43.") |
if [ "$etnet" == "" ]; then |
sed "s/define IJSNET 1/define IJSNET 0/" $startdir/input/workstation.h.mid2 > $startdir/workstation.h |
rm $startdir/input/workstation.h.mid2 |
else |
cp $startdir/input/workstation.h.mid2 $startdir/workstation.h |
rm $startdir/input/workstation.h.mid2 |
fi |
# Setting up the OS type specific files |
grep -q "#include \"vxi11_user.h\"" $startdir/input/daqscope.C.in |
if [ $? == 0 ]; then |
sed "s/vxi11_user.h/.\/vxi11_$ostype\/vxi11_user.h/g" $startdir/input/daqscope.C.in > $startdir/daqscope.C |
119,23 → 196,32 |
grep -q "CAMLIB = \$(LIBFILE)" $startdir/input/Makefile.in |
if [ $? == 0 ]; then |
if [ "$2" == "I" ]; then |
sed "s/CAMLIB = \$(LIBFILE)/CAMLIB = \$(LIBFILE) -lusb/g" $startdir/Makefile.mid > $startdir/Makefile |
sed "s/CAMLIB = \$(LIBFILE)/CAMLIB = \$(LIBFILE) -lusb/g" $startdir/Makefile.mid > $startdir/Makefile.mid2 |
rm $startdir/Makefile.mid |
elif [ "$2" == "O" ] || [ "$2" == "S" ]; then |
cp $startdir/input/Makefile.in $startdir/Makefile |
cp $startdir/input/Makefile.in $startdir/Makefile.mid2 |
fi |
fi |
sed "s/OSTYPE=none/OSTYPE=$ostype/g" $startdir/Makefile.mid2 > $startdir/Makefile |
rm $startdir/Makefile.mid2 |
|
if [ "$2" == "O" ] || [ "$2" == "S" ]; then |
cp $startdir/input/daqusb.C.offline $startdir/daqusb.C |
cp $startdir/input/start.sh.offline $startdir/start.sh |
cp $startdir/input/libxxusb.h.offline $startdir/libxxusb.h |
cp $startdir/input/usb.h.offline $startdir/usb.h |
elif [ "$2" == "I" ]; then |
cp $startdir/input/daqusb.C.online $startdir/daqusb.C |
cp $startdir/input/start.sh.online $startdir/start.sh |
cp $startdir/input/libxxusb.h.online $startdir/libxxusb.h |
fi |
|
echo "#!/bin/bash" > $startdir/start.sh |
echo "dir=\`dirname \$0\`" >> $startdir/start.sh |
echo "" >> $startdir/start.sh |
echo "snmpdirectory=$snmpdirectory" >> $startdir/start.sh |
echo "rootdirectory=$rootdirectory" >> $startdir/start.sh |
echo "" >> $startdir/start.sh |
cat $startdir/input/start.sh.in >> $startdir/start.sh |
chmod a+x $startdir/start.sh |
fi |
fi |
|
158,7 → 244,7 |
if [ "$2" == "O" ] || [ "$2" == "I" ] || [ "$2" == "S" ]; then |
make |
else |
echo "Error! No configuration type selected (second argument)." |
errorecho "Error! No configuration type selected (second argument)." |
echo "" |
helptext |
exit 1 |
166,7 → 252,7 |
fi |
cd $startdir |
else |
echo "No 64 bit VXI11 source folder." |
errorecho "No 64 bit VXI11 source folder." |
exit 1 |
fi |
# 32 bit configuration rules |
183,7 → 269,7 |
if [ "$2" == "O" ] || [ "$2" == "I" ] || [ "$2" == "S" ]; then |
make |
else |
echo "Error! No installation type selected (second argument)." |
errorecho "Error! No installation type selected (second argument)." |
echo "" |
helptext |
exit 1 |
191,11 → 277,11 |
fi |
cd $startdir |
else |
echo "No 32 bit VXI11 source folder." |
errorecho "No 32 bit VXI11 source folder." |
exit 1 |
fi |
else |
echo "No OS type information found." |
errorecho "No OS type information found." |
exit 1 |
fi |
fi |