Codebase list brewtarget / 3daf349e-cd83-4298-b98e-f862876cbb9d/main configure
3daf349e-cd83-4298-b98e-f862876cbb9d/main

Tree @3daf349e-cd83-4298-b98e-f862876cbb9d/main (Download .tar.gz)

configure @3daf349e-cd83-4298-b98e-f862876cbb9d/mainraw · history · blame

#!/bin/bash

# stop when sth failed
set -e

PREFIX=""
CMAKEOPTIONS="-DDO_RELEASE_BUILD=ON"

function printUsageAndExit {
   echo -e "Usage\n" \
           "   Options:\n" \
           "      -m T   Set mac arch (\"i386;ppc\" for universal binary)\n" \
           "      -p T   Set prefix to T.\n" \
           "      -t     Update translation files (*.ts).\n" \
           "      -v     Verbose compilation.\n" \
           "      -h     Print this help message.\n";
   exit 0;
}

# Ensures cmake exists.
function findCMake {

   if [ -z $(which cmake) ]
   then
      echo "ERROR: cmake not installed";
      exit 1;
   fi

}

findCMake;

# Get options.
while getopts "m:p:t:h:v" option
do
   case $option in
      m) CMAKEOPTIONS="$CMAKEOPTIONS -DCMAKE_OSX_ARCHITECTURES=$OPTARG";;
      p) PREFIX="$OPTARG";;
      t) CMAKEOPTIONS="$CMAKEOPTIONS -DUPDATE_TRANSLATIONS=ON";;
      v) CMAKEOPTIONS="$CMAKEOPTIONS -DCMAKE_VERBOSE_MAKEFILE=TRUE";;
      h) printUsageAndExit ;;
   esac
done

# Cmake defaults CMAKE_INSTALL_PREFIX=/usr/local.
# This is not good for debian, so try to detect debian/ubuntu.
grep -i ubuntu /etc/issue > /dev/null 2> /dev/null || grep -i debian /etc/issue > /dev/null 2> /dev/null
if [ $? == 0 ]
then
   PREFIX=/usr;
fi

echo "Prefix: $PREFIX";

# If we have a prefix...
if [ -n "$PREFIX" ]
then
   #...define the prefix.
   CMAKEOPTIONS="$CMAKEOPTIONS -DCMAKE_INSTALL_PREFIX=$PREFIX";
fi

echo "CMAKEOPTIONS: $CMAKEOPTIONS";

# Create dir only if needed
mkdir build || true

# Do all the building in build/
cd build/
cmake $CMAKEOPTIONS ../

# Tell the user what to do (if everything went well...)
echo ""
echo ""
echo -e "\tNow, cd to build/ and run \"make\""
echo ""