Skip to content

Instantly share code, notes, and snippets.

@jeetsukumaran
Created February 18, 2010 23:00
Show Gist options
  • Save jeetsukumaran/308185 to your computer and use it in GitHub Desktop.
Save jeetsukumaran/308185 to your computer and use it in GitHub Desktop.
autoconf / build tools bootstrap and configure command
#! /bin/sh
BUILD_TYPE="release"
PROGRAM_LABEL=""
for arg in $@
do
if [[ $arg = debug ]]
then
BUILD_TYPE="debug"
elif [[ $arg = profil* ]]
then
BUILD_TYPE="prof"
elif [[ $arg = release ]]
then
BUILD_TYPE="release"
elif [[ $arg = *-v* || $arg = *--v* ]]
then
PROGRAM_LABEL="${PROGRAM_LABEL}-$(git symbolic-ref HEAD 2> /dev/null | cut -b 12-)-$(git log --pretty=format:'%h' -1)"
else
PROGRAM_LABEL="${PROGRAM_LABEL}-${arg}"
fi
done
#PROGRAM_DESC="revision: $(git symbolic-ref HEAD 2> /dev/null | cut -b 12-)-$(git log --pretty=format:'%h, %ad' -1) [$BUILD_TYPE build]"
PROGRAM_DESC="revision: $(git symbolic-ref HEAD 2> /dev/null | cut -b 12-)-$(git log --pretty=format:'%h' -1) [$BUILD_TYPE build: $(date)]"
if [[ -n $PROGRAM_LABEL ]]
then
WITH_LABEL="--with-label='$PROGRAM_LABEL'"
fi
if [[ -n $PROGRAM_DESC ]]
then
WITH_DESC="--with-desc='$PROGRAM_DESC'"
fi
COMMON_CXXFLAGS="-pedantic -Wall -Wextra -Wchar-subscripts -Wno-format-extra-args -Winit-self -Wmissing-braces -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wstrict-overflow -Wcast-align -Wconversion -Wsign-compare -Wmissing-field-initializers"
DEBUG_CXXFLAGS="$COMMON_CXXFLAGS -O0 -g"
PROFILING_CXXFLAGS="$COMMON_CXXFLAGS -O3 -pg -g"
RELEASE_CXXFLAGS="$COMMON_CXXFLAGS -O3"
DEBUG_CONFIG_OPTS="--enable-debugging --enable-asserts"
PROFILING_CONFIG_OPTS="--enable-asserts"
RELEASE_CONFIG_OPTS="--enable-asserts"
if [[ $BUILD_TYPE = "debug" ]]
then
CONFIG_OPTS=$DEBUG_CONFIG_OPTS
CXXFLAGS=$DEBUG_CXXFLAGS
elif [[ $BUILD_TYPE = "profiling" ]]
then
CONFIG_OPTS=$PROFILING_CONFIG_OPTS
CXXFLAGS=$PROFILING_CXXFLAGS
else
CONFIG_OPTS=$RELEASE_CONFIG_OPTS
CXXFLAGS=$RELEASE_CXXFLAGS
fi
CONFIG_CMD="CXXFLAGS='$CXXFLAGS' ../../configure --prefix=`pwd`/install $WITH_LABEL $WITH_DESC $CONFIG_OPTS"
echo
echo $PROGRAM_DESC
echo
WD=`pwd`
cd ../../
./bootstrap.sh
cd $WD
echo
echo $CONFIG_CMD
echo
sh -c "$CONFIG_CMD"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment