File indexing completed on 2024-03-24 16:03:39

0001 #!/bin/bash
0002 
0003 BUILD_TYPE="Release"
0004 WITH_PROFILE=""
0005 VERBOSE=""
0006 SILENCE_DEPRECATED="-DSILENCE_DEPRECATED=1"
0007 THREADS=`cat /proc/cpuinfo | grep processor | wc -l`
0008 
0009 readopt='getopts $opts opt;rc=$?;[ $rc$opt == 0? ]&&exit 1;[ $rc == 0 ]||{ shift $[OPTIND-1];false; }'
0010 opts=dhpsvn
0011 while eval $readopt
0012 do
0013     if [ $opt == "d" ]
0014     then
0015         BUILD_TYPE="DebugFull"
0016     fi
0017 
0018     if [ $opt == "h" ]
0019     then
0020         SHOW_HELP=true
0021     fi
0022 
0023     if [ $opt == "p" ]
0024     then
0025         WITH_PROFILE="-DWITH_PROFILING=On"
0026     fi
0027 
0028     if [ $opt == "s" ]
0029     then
0030         THREADS=1
0031     fi
0032 
0033     if [ $opt == "v" ]
0034     then
0035         VERBOSE="VERBOSE=1"
0036     fi
0037 
0038     if [ $opt == "n" ]
0039     then
0040         SILENCE_DEPRECATED=""
0041     fi
0042 done
0043 
0044 # Turn off profiling if compiling with debug
0045 if [ $BUILD_TYPE == "DebugFull" ]
0046 then
0047     WITH_PROFILE=""
0048 fi
0049 
0050 if (${SHOW_HELP:=false})
0051 then
0052     echo "Usage build.sh -dhpsvn"
0053     echo "  -d : Build with debugging enabled"
0054     echo "  -h : Show this help"
0055     echo "  -p : Build with profiling enabled"
0056     echo "  -s : Build with single thread"
0057     echo "  -v : Build with verbose compiler output"
0058     echo "  -n : No silencing of deprecated declarations"
0059 else
0060     rm -rf build
0061     mkdir build
0062     if [ -d "build" ]; then
0063         cd build
0064         cmake -DCMAKE_INSTALL_PREFIX=`kf5-config --prefix` .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE $WITH_PROFILE $SILENCE_DEPRECATED && make -j${THREADS} $VERBOSE && sudo make install
0065     else
0066         echo "Unable to create build directory. Build aborted\n"
0067     fi
0068 fi