Skip to content

Commit

Permalink
Makes build scripts SH compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
argiopetech committed Sep 22, 2014
1 parent 702f9d4 commit 639fe19
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 34 deletions.
34 changes: 16 additions & 18 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
#!/bin/bash
#!/bin/sh

# Get the number of CPUs on the system
# This is not portable
if [[ ! $MULTICPUS ]]; then
if [ ! "$NCPUS" ]; then
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
MULTICPUS=`grep -c ^processor /proc/cpuinfo`
elif [[ "$unamestr" == 'Darwin' ]]; then
if [ "$unamestr" == 'Linux' ]; then
NCPUS=`grep -c ^processor /proc/cpuinfo`
elif [ "$unamestr" == 'Darwin' ] || [ "$unamestr" == 'FreeBSD' ]; then
NCPUS=`sysctl -n hw.ncpu`
export CC=`which clang`
export CXX=`which clang++`
else
NCPUS=1
fi
fi

BASE=`dirname ${0}`
OWD=$PWD
BASE=`dirname "${0}"`

pushd $BASE
cd $BASE

if [[ -e ".git" ]]; then
if [ -e ".git" ]; then
# Setup submodules
git submodule init
git submodule update
else
if [[ ! -e "yaml-cpp/CMakeLists.txt" ]]; then
if [ ! -e "yaml-cpp/CMakeLists.txt" ]; then
# Manually clone yaml-cpp, removing the directory first
rm -r yaml-cpp
git clone https://github.com/argiopetech/yaml-cpp.git --depth 1
Expand All @@ -33,17 +32,16 @@ fi

cp cmake/yaml-cpp-CMakeLists.txt yaml-cpp/CMakeLists.txt

pushd ./BUILD
if [[ $PREFIX ]]; then
cmake -DCMAKE_BUILD_TYPE="RELEASE" -DCMAKE_INSTALL_PREFIX=${PREFIX} ..
cd ./BUILD
if [ "$PREFIX" ]; then
cmake -DCMAKE_BUILD_TYPE="RELEASE" -DCMAKE_INSTALL_PREFIX=$PREFIX ..
else
cmake -DCMAKE_BUILD_TYPE="RELEASE" -DCMAKE_INSTALL_PREFIX='/usr/local' ..
fi
make -j${MULTICPUS}
make -j"$NCPUS"

if [[ $? == 0 && ! $NO_INSTALL ]]; then
if [ "$?" == 0 ] && [ ! "$NO_INSTALL" ]; then
make install
fi;

popd
popd
cd "$OWD"
30 changes: 14 additions & 16 deletions debug_build.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
#!/bin/bash
#!/bin/sh

# Get the number of CPUs on the system
# This is not portable
if [[ ! $MULTICPUS ]]; then
if [ ! "$NCPUS" ]; then
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
MULTICPUS=`grep -c ^processor /proc/cpuinfo`
elif [[ "$unamestr" == 'Darwin' ]]; then
if [ "$unamestr" == 'Linux' ]; then
NCPUS=`grep -c ^processor /proc/cpuinfo`
elif [ "$unamestr" == 'Darwin' ] || [ "$unamestr" == 'FreeBSD' ]; then
NCPUS=`sysctl -n hw.ncpu`
export CC=`which clang`
export CXX=`which clang++`
else
NCPUS=1
fi
fi

BASE=`dirname ${0}`
OWD=$PWD
BASE=`dirname "${0}"`

pushd $BASE
cd $BASE

if [[ -e ".git" ]]; then
if [ -e ".git" ]; then
# Setup submodules
git submodule init
git submodule update
else
if [[ ! -e "yaml-cpp/CMakeLists.txt" ]]; then
if [ ! -e "yaml-cpp/CMakeLists.txt" ]; then
# Manually clone yaml-cpp, removing the directory first
rm -r yaml-cpp
git clone https://github.com/argiopetech/yaml-cpp.git --depth 1
Expand All @@ -33,13 +32,12 @@ fi

cp cmake/yaml-cpp-CMakeLists.txt yaml-cpp/CMakeLists.txt

pushd ./BUILD
cd ./BUILD
cmake -DCMAKE_BUILD_TYPE="RELWITHDEBINFO" -DCMAKE_INSTALL_PREFIX='.' ..
make -j${MULTICPUS}
make -j"$NCPUS"

if [[ $? == 0 && ! $NO_INSTALL ]]; then
if [ "$?" == 0 ] && [ ! "$NO_INSTALL" ]; then
make install
fi;

popd
popd
cd "$OWD"

0 comments on commit 639fe19

Please sign in to comment.