3 #------------------------------------------------------------------
5 # Name: build_uboonedaq_datatypes.sh
7 # Purpose: Build debug and prof flavors of uboonedaq_datatypes
10 # Created: 25-Jun-2015 H. Greenlee
12 #------------------------------------------------------------------
14 echo "uboonedaq_datatypes version: $VERSION"
15 echo "Qualifier: $QUAL"
16 echo "build type: $BUILDTYPE"
17 echo "workspace: $WORKSPACE"
19 # Make a workspace without colons.
21 export WORKSPACE2=`echo $WORKSPACE | tr : -`
22 echo "workspace 2: $WORKSPACE2"
25 # Get number of cores to use.
27 if [ `uname` = Darwin ]; then
28 #ncores=`sysctl -n hw.ncpu`
29 #ncores=$(( $ncores / 4 ))
32 ncores=`cat /proc/cpuinfo 2>/dev/null | grep -c -e '^processor'`
34 if [ $ncores -lt 1 ]; then
37 echo "Building using $ncores cores."
39 # Interpret build type.
42 if [ $BUILDTYPE = debug ]; then
44 elif [ $BUILDTYPE = prof ]; then
47 echo "Unknown build type $BUILDTYPE"
51 # Environment setup, uses /grid/fermiapp or cvmfs.
53 if [ -f /grid/fermiapp/products/uboone/setup_uboone.sh ]; then
54 source /grid/fermiapp/products/uboone/setup_uboone.sh || exit 1
55 elif [ -f /cvmfs/uboone.opensciencegrid.org/products/setup_uboone.sh ]; then
56 if [ -x /cvmfs/grid.cern.ch/util/cvmfs-uptodate ]; then
57 /cvmfs/grid.cern.ch/util/cvmfs-uptodate /cvmfs/uboone.opensciencegrid.org/products
59 source /cvmfs/uboone.opensciencegrid.org/products/setup_uboone.sh || exit 1
61 echo "No setup file found."
65 # Use system git on macos.
67 if ! uname | grep -q Darwin; then
71 # Set up working area.
74 rm -rf $WORKSPACE2/temp || exit 1
75 mkdir -p $WORKSPACE2/temp || exit 1
76 mkdir -p $WORKSPACE/copyBack || exit 1
77 rm -f $WORKSPACE/copyBack/* || exit 1
78 cd $WORKSPACE2/temp || exit 1
79 export UBOONEDAQ_HOME_DIR=`pwd`
81 # Check for supported combination of base qualifier and OS.
82 if [[ `uname -s` == Darwin ]] && [[ $QUAL == e* ]]; then
83 echo "${QUAL} build not supported on `uname -s`"
84 echo "${QUAL} build not supported on `uname -s`" > $WORKSPACE/copyBack/skipping_build
98 # Make source area and check out sources.
102 git clone http://cdcvs.fnal.gov/projects/uboonedaq-datatypes
103 #git clone https://github.com/hgreenlee/uboonedaq_datatypes
104 #mv uboonedaq_datatypes uboonedaq-datatypes
105 cd uboonedaq-datatypes
107 # Make sure repository is up to date and check out desired tag.
111 git checkout $VERSION
113 # Initialize build area.
115 cd ${UBOONEDAQ_HOME_DIR}/build
116 source ${UBOONEDAQ_HOME_DIR}/srcs/uboonedaq-datatypes/projects/ups/setup_for_development $opt ${QUAL}:offline
120 if [[ $QUAL =~ ^c ]]; then
121 env CC=clang CXX=clang++ FC=gfortran cmake -DCMAKE_INSTALL_PREFIX="${UBOONEDAQ_HOME_DIR}/install" -DCMAKE_BUILD_TYPE=${CETPKG_TYPE} "${CETPKG_SOURCE}"
123 env CC=gcc CXX=g++ FC=gfortran cmake -DCMAKE_INSTALL_PREFIX="${UBOONEDAQ_HOME_DIR}/install" -DCMAKE_BUILD_TYPE=${CETPKG_TYPE} "${CETPKG_SOURCE}"
130 if [ $stat -ne 0 ]; then
135 if [ $stat -ne 0 ]; then
140 # Make distribution tarball
142 cd ${UBOONEDAQ_HOME_DIR}/install
143 dot_version=`echo $VERSION | sed -e 's/_offline//' | sed -e 's/_/\./g' | sed -e 's/^v//'`
144 subdir=`echo $CET_SUBDIR | sed -e 's/\./-/g'`
145 #qual=`echo $CETPKG_QUAL | sed -e 's/:offline//' | sed -e 's/:/-/g'`
146 qual=`echo $CETPKG_QUAL | sed -e 's/:/-/g'`
147 tarballname=uboonedaq_datatypes-${dot_version}-${subdir}-${qual}.tar.bz2
148 echo "Making ${tarballname}"
149 tar cjf ${UBOONEDAQ_HOME_DIR}/${tarballname} uboonedaq_datatypes
153 mv ${UBOONEDAQ_HOME_DIR}/${tarballname} $WORKSPACE/copyBack/ || exit 1
154 ls -l $WORKSPACE/copyBack/
155 cd $WORKSPACE2 || exit 1
156 rm -rf $WORKSPACE2/temp || exit 1