Newer
Older
Martin Beseda
committed
#!/bin/sh
clear
export BOOST_ROOT=${PWD}../../external_dependencies/boost
export LIB4NEURO_INCLUDE_DIR=${PWD}/../../include
Martin Beseda
committed
# Should we build the examples? (yes/no)
BUILD_EXAMPLES=yes
# Should we build the unit-tests? (yes/no)
BUILD_TESTS=yes
# Should we build the lib4neuro library? (yes)
BUILD_LIB=yes
# C++ compiler
CXX_COMPILER="g++"
C_COMPILER="gcc"
#**********************DO NOT CHANGE BEYOND THIS LINE****************************************
if [ -z ${DEPENDENCIES_LINK_TYPE} ]; then DEPENDENCIES_LINK_TYPE=static; fi
if [ -z ${CLEAN_AFTER} ]; then CLEAN_AFTER=yes; fi
Martin Beseda
committed
if [ ${DEPENDENCIES_LINK_TYPE} = "shared" ]
then
LINK_TYPE=shared
fi
if [ ${CLEAN_AFTER} = "no" ]
BUILD_ERROR_OCCURED=0
Martin Beseda
committed
RED='\033[0;31m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
WHITE='\033[1;37m'
NC='\033[0m' # No Color
Martin Beseda
committed
echo -e "Building the '${CYAN}lib4neuro${NC}' project for ${WHITE}Debug${NC}"
Martin Beseda
committed
BUILD_SOMETHING=no
BUILD_SOMETHING_LIB=no
if [ ${BUILD_LIB} = "yes" ]
Martin Beseda
committed
then
echo "${CYAN}lib4neuro${NC} build type: ${WHITE}Debug${NC}"
echo "${CYAN}lib4neuro${NC} build architecture: ${WHITE}x64${NC}"
echo "${CYAN}lib4neuro${NC} will be built in '${YELLOW}build/lib/${NC}'"
BUILD_SOMETHING=yes
BUILD_SOMETHING_LIB=yes
fi
if [ ${BUILD_TESTS} = "yes" ]
Martin Beseda
committed
then
Martin Beseda
committed
echo -e "${CYAN}lib4neuro${NC} unit tests will be built in '${YELLOW}build/unit-tests${NC}'"
Martin Beseda
committed
BUILD_SOMETHING=yes
BUILD_SOMETHING_LIB=yes
fi
if [ ${BUILD_EXAMPLES} = "yes" ]
Martin Beseda
committed
then
Martin Beseda
committed
echo -e "${CYAN}lib4neuro${NC} examples will be built in '${YELLOW}build/examples${NC}'"
Martin Beseda
committed
BUILD_SOMETHING=yes
BUILD_SOMETHING_LIB=yes
fi
rm -rf ../../external_dependencies/boost/*
rm -rf ../../external_dependencies/exprtk/*
Martin Beseda
committed
# Should we build the lib4neuro library? (yes)
if [ ${BUILD_SOMETHING_LIB} = "yes" -a ${BUILD_ERROR_OCCURED} = "0" ]
Martin Beseda
committed
then
if [ ${BUILD_LIB} = "yes" ]
Martin Beseda
committed
then
./linux_clean_lib.sh
fi
if [ ${BUILD_EXAMPLES} = "yes" ]
Martin Beseda
committed
then
./linux_clean_examples.sh
fi
if [ ${BUILD_TESTS} = "yes" ]
Martin Beseda
committed
then
./linux_clean_tests.sh
fi
Martin Beseda
committed
echo -e "Building the '${CYAN}lib4neuro${NC}' project for ${WHITE}Debug${NC} (preparing makefiles)"
Martin Beseda
committed
Martin Beseda
committed
cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=${CXX_COMPILER} -DCMAKE_C_COMPILER=${C_COMPILER} -DBOOST_LIBRARYDIR=${BOOST_LIBRARYDIR} -DBOOST_INCLUDEDIR=${BOOST_INCLUDEDIR} -DBUILD_TESTS=${BUILD_TESTS} -DBUILD_EXAMPLES=${BUILD_EXAMPLES} -DBUILD_LIB=${BUILD_LIB} -DDEPENDENCIES_LINK_TYPE=${LINK_TYPE} -S . -B build || { echo -e "${RED}Makefile preparation finished with errors${NC}!"; BUILD_ERROR_OCCURED=1; }
Martin Beseda
committed
echo -e "Building the '${CYAN}lib4neuro${NC}' project for ${WHITE}Debug${NC} (building)"
cmake --build build --config Debug -- -j ${N_CORES} && echo -e "${GREEN}Build complete${NC}." || { echo -e "${RED}Build finished with errors${NC}!"; BUILD_ERROR_OCCURED=1; }
Martin Beseda
committed
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
cd build_scripts/linux
fi
if [ ${CLEAN_AF} = "yes" ]
then
if [ ${BUILD_LIB} = "yes" ]
then
./linux_clean_after_lib.sh
fi
if [ ${BUILD_EXAMPLES} = "yes" ]
then
pwd
./linux_clean_after_examples.sh
fi
if [ ${BUILD_TESTS} = "yes" ]
then
./linux_clean_after_tests.sh
fi
if [ ${BUILD_SOMETHING_LIB} = "yes" ]
then
./linux_clean_garbage.sh
fi
Martin Beseda
committed
echo -e "${RED}Build encountered some errors!${NC}"