Blame | Last modification | View Log | RSS feed
#!/bin/bashfunction colorecho{echo -e$2 "\033[33m$1\033[39m"}function errorecho{echo -e "\031[33m$1\033[39m"}function helptext(){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 argumentsif [ "$1" == "" ]; thenerrorecho "Error! No arguments supplied."echo ""helptextexit 1else# When using help, only display help and then exitif [ "$1" == "help" ]; thenhelptextexit 0fi# Print help and exit if we give a wrong first argumentif [ "$1" != "nomake" ] && [ "$1" != "all" ] && [ "$1" != "clean" ] && [ "$1" != "compress" ]; thenerrorecho "Error! Wrong configuration option selected (first argument)."echo ""helptextexit 1fistartdir=$PWD# Check for ROOT and NET-SNMP install directories and for OS typesnmpsearch="--snmp-install="rootsearch="--root-install="ossearch="--ostype="snmpdirectory=-1rootdirectory=-1osmanual=-1for var in $@docase $var in"$snmpsearch"*)snmpdirectory=${var#$snmpsearch}echo "NET-SNMP directory: $snmpdirectory";;"$rootsearch"*)rootdirectory=${var#$rootsearch}echo "ROOT directory: $rootdirectory";;"$ossearch"*)osmanual=${var#$ossearch};;*) ;;esacdone# If n ot supplied, check automatically for OS typeif [ $osmanual == -1 ]; thenostype=`uname -p`if [ "$ostype" != "x86_64" ] && [ "$ostype" != "i686" ]; thenostype=`uname -i`if [ "$ostype" != "x86_64" ] && [ "$ostype" != "i686" ]; thenostype=`uname -m`fifielseostype=$osmanualfi# Check for installation directory of ROOT - if variables not currently set, remind user to set them before running makeif [ "$1" != "clean" ] && [ "$1" != "compress" ]; thenif [ $rootdirectory != -1 ]; thenprintenv ROOTSYS > /dev/nullif [ $? != 0 ]; thencolorecho "ROOT environment variables not set. Please run \"source $rootdirectory/bin/thisroot.sh\", before using make."fielsecolorecho "Before running make, please make sure ROOT environment variables are set."fifi# Compiles the table microcontroller programif [ "$1" == "all" ]; thenif [ -d $startdir/MIKRO ]; thencd $startdir/MIKROrm -f $startdir/MIKRO/mikro_ctrlmakecd $startdirfifi# When using compress, only create a tar-ball and then exitif [ "$1" == "compress" ]; thencd $startdirif [ ! -d $startdir/camac_gui_windowed ]; thenmkdir $startdir/camac_gui_windowedmkdir $startdir/camac_gui_windowed/resultsecho "Copying source files to temporary directory $startdir/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_windowedecho "Cleaning the base directory in $startdir/camac_gui_windowed..."rm -f *.bakccd $startdir/camac_gui_windowed/inputecho "Cleaning the input directory in $startdir/camac_gui_windowed/input..."rm -f *.bakcd $startdir/camac_gui_windowed/vxi11_x86_64echo "Cleaning the 64 bit VXI11 directory in $startdir/camac_gui_windowed/vxi11_x86_64..."rm -f *.bakmake cleancd $startdir/camac_gui_windowed/vxi11_i686echo "Cleaning the 32 bit VXI11 directory in $startdir/camac_gui_windowed/vxi11_i686..."rm -f *.bakmake cleancd $startdirecho "Creating a tar-ball camac_gui_windowed.tar.gz..."tar czf $startdir/camac_gui_windowed.tar.gz ./camac_gui_windowedecho "Removing the temporary directory $startdir/camac_gui_windowed..."rm -r $startdir/camac_gui_windowedexit 0elseerrorecho "Error! Directory ./camac_gui_windowed already exists."exit 1fifi# Configure the workstation information and directory of program (0 if we find something and 1 otherwise)basedir=$(echo $startdir | sed 's/\//\\\//g')if [ "$1" == "nomake" ] || [ "$1" == "all" ]; thenif [ "$2" == "O" ] || [ "$2" == "I" ] || [ "$2" == "S" ]; then# Setting up the current working computergrep -q "#define WORKSTAT 'N'" $startdir/input/workstation.h.inif [ $? == 0 ]; thensed "s/define WORKSTAT 'N'/define WORKSTAT '$2'/" $startdir/input/workstation.h.in > $startdir/input/workstation.h.midfigrep -q "#define rootdir \"path-to-installation\"" $startdir/input/workstation.h.inif [ $? == 0 ]; thensed "s/path-to-installation/$basedir/g" $startdir/input/workstation.h.mid > $startdir/input/workstation.h.mid2rm $startdir/input/workstation.h.midfi# Check if we are connected to IJS networketnet=$(ifconfig | grep "178.172.43.")if [ "$etnet" == "" ]; thensed "s/define IJSNET 1/define IJSNET 0/" $startdir/input/workstation.h.mid2 > $startdir/workstation.hrm $startdir/input/workstation.h.mid2elsecp $startdir/input/workstation.h.mid2 $startdir/workstation.hrm $startdir/input/workstation.h.mid2fi# Setting up the OS type specific filesgrep -q "#include \"vxi11_user.h\"" $startdir/input/daqscope.C.inif [ $? == 0 ]; thensed "s/vxi11_user.h/.\/vxi11_$ostype\/vxi11_user.h/g" $startdir/input/daqscope.C.in > $startdir/daqscope.Cfigrep -q "SHLIB = \$(LIBFILE) libvxi11.a" $startdir/input/Makefile.inif [ $? == 0 ]; thenif [ "$2" == "I" ]; thensed "s/SHLIB = \$(LIBFILE) libvxi11.a/SHLIB = \$(LIBFILE) libvxi11.a -lusb/g" $startdir/input/Makefile.in > $startdir/Makefile.midfifigrep -q "CAMLIB = \$(LIBFILE)" $startdir/input/Makefile.inif [ $? == 0 ]; thenif [ "$2" == "I" ]; thensed "s/CAMLIB = \$(LIBFILE)/CAMLIB = \$(LIBFILE) -lusb/g" $startdir/Makefile.mid > $startdir/Makefile.mid2rm $startdir/Makefile.midelif [ "$2" == "O" ] || [ "$2" == "S" ]; thencp $startdir/input/Makefile.in $startdir/Makefile.mid2fifised "s/OSTYPE=none/OSTYPE=$ostype/g" $startdir/Makefile.mid2 > $startdir/Makefilerm $startdir/Makefile.mid2if [ "$2" == "O" ] || [ "$2" == "S" ]; thencp $startdir/input/daqusb.C.offline $startdir/daqusb.Ccp $startdir/input/libxxusb.h.offline $startdir/libxxusb.hcp $startdir/input/usb.h.offline $startdir/usb.helif [ "$2" == "I" ]; thencp $startdir/input/daqusb.C.online $startdir/daqusb.Ccp $startdir/input/libxxusb.h.online $startdir/libxxusb.hfiecho "#!/bin/bash" > $startdir/start.shecho "dir=\`dirname \$0\`" >> $startdir/start.shecho "" >> $startdir/start.shecho "snmpdirectory=$snmpdirectory" >> $startdir/start.shecho "rootdirectory=$rootdirectory" >> $startdir/start.shecho "" >> $startdir/start.shcat $startdir/input/start.sh.in >> $startdir/start.shchmod a+x $startdir/start.shfifi# In case we just want to set the workstation information, exit hereif [ "$1" == "nomake" ]; thenexit 0fi# 64 bit configuration rulesif [ $ostype == "x86_64" ]; thenvxidir=$startdir/vxi11_$ostypeif [ -d $vxidir ]; thencd $vxidirif [ "$1" == "clean" ]; thenmake cleancd $startdirmake cleanrm -f Makefileelseif [ "$2" == "O" ] || [ "$2" == "I" ] || [ "$2" == "S" ]; thenmakeelseerrorecho "Error! No configuration type selected (second argument)."echo ""helptextexit 1fificd $startdirelseerrorecho "No 64 bit VXI11 source folder."exit 1fi# 32 bit configuration ruleselif [ $ostype == "i686" ]; thenvxidir=$startdir/vxi11_$ostypeif [ -d $vxidir ]; thencd $vxidirif [ "$1" == "clean" ]; thenmake cleancd $startdirmake cleanrm -f Makefileelseif [ "$2" == "O" ] || [ "$2" == "I" ] || [ "$2" == "S" ]; thenmakeelseerrorecho "Error! No installation type selected (second argument)."echo ""helptextexit 1fificd $startdirelseerrorecho "No 32 bit VXI11 source folder."exit 1fielseerrorecho "No OS type information found."exit 1fifiexit 0