"Fossies" - the Fresh Open Source Software Archive

Member "stress-ng-0.09.56/smatchify.sh" (15 Mar 2019, 2590 Bytes) of package /linux/privat/stress-ng-0.09.56.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "smatchify.sh": 0.09.49_vs_0.09.50.

    1 #!/bin/bash
    2 #
    3 # Copyright (C) 2012-2019 Canonical
    4 #
    5 # This program is free software; you can redistribute it and/or
    6 # modify it under the terms of the GNU General Public License
    7 # as published by the Free Software Foundation; either version 2
    8 # of the License, or (at your option) any later version.
    9 #
   10 # This program is distributed in the hope that it will be useful,
   11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13 # GNU General Public License for more details.
   14 #
   15 # You should have received a copy of the GNU General Public License
   16 # along with this program; if not, write to the Free Software
   17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
   18 #
   19 SMATCH_DIR=smatch
   20 SMATCH_REPO=git://repo.or.cz/smatch
   21 DEPENDENCIES="libxml2-dev llvm-dev libsqlite3-dev"
   22 
   23 INCLUDES="-I/usr/lib/gcc/i686-linux-gnu/ -I/usr/include/x86_64-linux-gnu"
   24 
   25 HERE=$(pwd)
   26 
   27 #
   28 #  Install any packages we depend on to build smatch
   29 #
   30 smatch_install_dependencies()
   31 {
   32     install=""
   33 
   34     echo "Checking for dependencies for smatch.."
   35 
   36     for d in ${DEPENDENCIES}
   37     do
   38         if [ "$(dpkg -l | grep $d)" == "" ]; then
   39             install="$install $d"
   40         fi
   41     done
   42     if [ "$install" != "" ]; then
   43         echo "Need to install:$install"
   44         sudo apt-get install $install
   45         if [ $? -ne 0 ]; then
   46             echo "Installation of packages failed"
   47             exit 1
   48         fi
   49     fi
   50 }
   51 
   52 #
   53 #  Get an up to date version of smatch
   54 #
   55 smatch_get()
   56 {
   57     if [ -d ${SMATCH_DIR} ]; then
   58         echo "Getting latest version of smatch.."
   59         cd ${SMATCH_DIR}
   60         git checkout -f master >& /dev/null
   61         git fetch origin >& /dev/null
   62         git fetch origin master >& /dev/null
   63         git reset --hard FETCH_HEAD >& /dev/null
   64         cd ${HERE}
   65     else
   66         echo "Getting smatch.."
   67         git clone ${SMATCH_REPO} ${SMATCH_DIR}
   68     fi
   69 }
   70 
   71 #
   72 #  Build smatch
   73 #
   74 smatch_build()
   75 {
   76     cd ${SMATCH_DIR}
   77     echo "Smatch: make clean.."
   78     make clean >& /dev/null
   79     echo "Smatch: make.."
   80     make > /dev/null 2>&1
   81     if [ $? -eq 0 ]; then
   82         echo "Build of smatch succeeded"
   83     else
   84         echo "Build  of smatchfailed"
   85         exit 1
   86     fi
   87     cd ${HERE}
   88 }
   89 
   90 #
   91 #  Build using smatch
   92 #
   93 smatch_check()
   94 {
   95     echo "Smatchifying.."
   96     autoreconf -ivf > /dev/null
   97     ./configure > /dev/null
   98     make clean
   99 
  100     make CHECK="${HERE}/${SMATCH_DIR}/smatch --full-path --two-passes" \
  101         CC="${HERE}/${SMATCH_DIR}/cgcc $INCLUDES" | tee smatch.log
  102 }
  103 
  104 #
  105 #  Check for errors
  106 #
  107 smatch_errors()
  108 {
  109     errors=$(grep "error: " smatch.log | wc -l)
  110     echo " "
  111     echo "Smatch found $errors errors, see smatch.log for more details."
  112 }
  113 
  114 smatch_install_dependencies
  115 smatch_get
  116 smatch_build
  117 smatch_check
  118 smatch_errors