"Fossies" - the Fresh Open Source Software Archive

Member "snort3_extra-3.0.3-1/configure_cmake.sh" (23 Sep 2020, 5355 Bytes) of package /linux/misc/snort3_extra-3.0.3-1.tar.gz:


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 latest Fossies "Diffs" side-by-side code changes report for "configure_cmake.sh": 1.0.0-beta2_vs_3.0.3-1.

    1 #!/bin/sh
    2 # Convenience wrapper for easily viewing/setting options that
    3 # the project's CMake scripts will recognize
    4 
    5 set -e
    6 command="$0 $*"
    7 
    8 # check for `cmake` command
    9 type cmake > /dev/null 2>&1 || {
   10     echo "\
   11 This package requires CMake, please install it first, then you may
   12 use this configure script to access CMake equivalent functionality.\
   13 " >&2;
   14     exit 1;
   15 }
   16 
   17 usage="\
   18 Usage: $0 [OPTION]... [VAR=VALUE]...
   19 
   20         --builddir=   The build directory
   21         --generator=  run cmake --help for a list of generators
   22         --prefix=     Snort++ installation prefix
   23 
   24 Optional Features:
   25     --build-type=[Debug|Release|RelWithDebInfo|MinSizeRel]
   26                             set cmake build type (defaults to RelWithDebInfo if neither
   27                             CFLAGS nor CXXFLAGS are set)
   28     --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   29     --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
   30     --enable-code-coverage  Whether to enable code coverage support
   31     --enable-debug          enable debugging options (bugreports and developers
   32                             only)
   33     --disable-gdb           disable gdb debugging information
   34     --enable-address-sanitizer
   35                             enable address sanitizer support
   36     --enable-thread-sanitizer
   37                             enable thread sanitizer support
   38     --enable-ub-sanitizer
   39                             enable undefined behavior sanitizer support
   40 "
   41 
   42 sourcedir="$( cd "$( dirname "$0" )" && pwd )"
   43 
   44 # Function to append a CMake cache entry definition to the
   45 # CMakeCacheEntries variable
   46 #   $1 is the cache entry variable name
   47 #   $2 is the cache entry variable type
   48 #   $3 is the cache entry variable value
   49 append_cache_entry () {
   50     CMakeCacheEntries="$CMakeCacheEntries -D $1:$2=$3"
   51 }
   52 
   53 # set defaults
   54 builddir=build
   55 prefix=/usr/local/snort
   56 CMakeCacheEntries=""
   57 append_cache_entry CMAKE_INSTALL_PREFIX PATH   $prefix
   58 build_type=""
   59 [ -z "$CFLAGS" ] && [ -z "$CXXFLAGS" ] && build_type="RelWithDebInfo"
   60 
   61 # parse arguments
   62 while [ $# -ne 0 ]; do
   63     case "$1" in
   64         -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
   65         *) optarg= ;;
   66     esac
   67 
   68     case "$1" in
   69         --help|-h)
   70             echo "${usage}" 1>&2
   71             exit 1
   72             ;;
   73         --builddir=*)
   74             builddir=$optarg
   75             ;;
   76         --define=*)
   77             CMakeCacheEntries="$CMakeCacheEntries -D$optarg"
   78             ;;
   79         --generator=*)
   80             CMakeGenerator="$optarg"
   81             ;;
   82         --prefix=*)
   83             prefix=$optarg
   84             append_cache_entry CMAKE_INSTALL_PREFIX PATH $optarg
   85             ;;
   86         --enable-code-coverage)
   87             append_cache_entry ENABLE_CODE_COVERAGE     BOOL true
   88             ;;
   89         --disable-code-coverage)
   90             append_cache_entry ENABLE_CODE_COVERAGE     BOOL false
   91             ;;
   92         --enable-debug)
   93             append_cache_entry ENABLE_DEBUG             BOOL true
   94             ;;
   95         --disable-debug)
   96             append_cache_entry ENABLE_DEBUG             BOOL false
   97             ;;
   98         --enable-gdb)
   99             append_cache_entry ENABLE_GDB               BOOL true
  100             ;;
  101         --disable-gdb)
  102             append_cache_entry ENABLE_GDB               BOOL false
  103             ;;
  104         --enable-address-sanitizer)
  105             append_cache_entry ENABLE_ADDRESS_SANITIZER BOOL true
  106             ;;
  107         --disable-address-sanitizer)
  108             append_cache_entry ENABLE_ADDRESS_SANITIZER BOOL false
  109             ;;
  110         --enable-thread-sanitizer)
  111             append_cache_entry ENABLE_THREAD_SANITIZER  BOOL true
  112             ;;
  113         --disable-thread-sanitizer)
  114             append_cache_entry ENABLE_THREAD_SANITIZER  BOOL false
  115             ;;
  116         --enable-ub-sanitizer)
  117             append_cache_entry ENABLE_UB_SANITIZER  BOOL true
  118             ;;
  119         --disable-ub-sanitizer)
  120             append_cache_entry ENABLE_UB_SANITIZER  BOOL false
  121             ;;
  122         --build-type=*)
  123             if [ $optarg = "Debug" ] || [ $optarg = "Release" ] ||
  124             [ $optarg = "RelWithDebInfo" ] || [ $optarg = "MinSizeRel" ]; then
  125                 build_type=$optarg
  126             else
  127                 echo "Invalid build type '$optarg'. Try $0 --help to see available build types."
  128                 exit 1
  129             fi
  130             ;;
  131         *)
  132             echo "Invalid option '$1'.  Try $0 --help to see available options."
  133             exit 1
  134             ;;
  135     esac
  136     shift
  137 done
  138 
  139 if [ -d $builddir ]; then
  140     # If build directory exists, check if it has a CMake cache
  141     if [ -f $builddir/CMakeCache.txt ]; then
  142         # If the CMake cache exists, delete it so that this configuration
  143         # is not tainted by a previous one
  144         rm -f $builddir/CMakeCache.txt
  145     fi
  146 else
  147     # Create build directory
  148     mkdir -p $builddir
  149 fi
  150 
  151 echo "Build Directory : $builddir"
  152 echo "Source Directory: $sourcedir"
  153 cd $builddir
  154 
  155 [ "$CMakeGenerator" ] && gen="-G $CMakeGenerator"
  156 
  157 cmake $gen \
  158     -DCMAKE_CXX_FLAGS:STRING="$CXXFLAGS $CPPFLAGS" \
  159     -DCMAKE_C_FLAGS:STRING="$CFLAGS $CPPFLAGS" \
  160     -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
  161     -DCMAKE_BUILD_TYPE:STRING=$build_type \
  162     $CMakeCacheEntries $sourcedir
  163 
  164 echo "# This is the command used to configure this build" > config.status
  165 echo $command >> config.status
  166 chmod u+x config.status
  167