2016-05-19 14:23:20 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
function msg_err {
|
2016-11-08 05:04:04 -05:00
|
|
|
printf "\033[31;1m** \033[0m%s\n" "$@"
|
2016-05-19 14:23:20 -04:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function msg {
|
2016-11-08 05:04:04 -05:00
|
|
|
printf "\033[32;1m** \033[0m%s\n" "$@"
|
2016-05-19 14:23:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function main
|
|
|
|
{
|
|
|
|
[[ -d ./.git ]] && {
|
2016-11-08 05:04:04 -05:00
|
|
|
msg "Fetching submodules"
|
2016-05-19 14:23:20 -04:00
|
|
|
git submodule update --init --recursive || msg_err "Failed to clone submodules"
|
|
|
|
}
|
|
|
|
|
2016-11-08 05:04:04 -05:00
|
|
|
[[ -d ./build ]] && {
|
|
|
|
if [[ "$1" == "-f" ]]; then
|
|
|
|
msg "Removing existing build dir (-f)"
|
|
|
|
rm -rf ./build >/dev/null || msg_err "Failed to remove existing build dir"
|
|
|
|
else
|
|
|
|
msg_err "A build dir already exists (pass -f to replace)"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-05-19 14:23:20 -04:00
|
|
|
mkdir ./build || msg_err "Failed to create build dir"
|
|
|
|
cd ./build || msg_err "Failed to enter build dir"
|
|
|
|
|
2017-01-09 20:09:27 -05:00
|
|
|
local build_ipc_msg="ON"
|
2016-11-08 05:04:04 -05:00
|
|
|
local enable_alsa="ON"
|
2017-09-15 23:51:22 -04:00
|
|
|
local enable_pulseaudio="ON"
|
2016-11-08 05:04:04 -05:00
|
|
|
local enable_i3="ON"
|
|
|
|
local enable_network="ON"
|
|
|
|
local enable_mpd="ON"
|
2016-12-19 23:33:07 -05:00
|
|
|
local enable_curl="ON"
|
2016-05-19 14:23:20 -04:00
|
|
|
|
2016-11-08 05:04:04 -05:00
|
|
|
msg "Setting build options"
|
2016-05-19 14:23:20 -04:00
|
|
|
|
2018-05-20 04:30:33 -04:00
|
|
|
read -r -p "$(msg "Use GCC even if Clang is installed -------------------------------- [y/N]: ")" -n 1 p && echo
|
|
|
|
[[ "${p^^}" != "Y" ]] && try_to_use_clang="ON"
|
2018-02-08 21:23:51 -05:00
|
|
|
read -r -p "$(msg "Include support for \"internal/i3\" (requires i3) ------------------- [y/N]: ")" -n 1 p && echo
|
2016-11-08 05:04:04 -05:00
|
|
|
[[ "${p^^}" != "Y" ]] && enable_i3="OFF"
|
2018-05-20 04:30:33 -04:00
|
|
|
read -r -p "$(msg "Include support for \"internal/alsa\" (requires alsalib) ------------ [y/N]: ")" -n 1 p && echo
|
2016-11-08 05:04:04 -05:00
|
|
|
[[ "${p^^}" != "Y" ]] && enable_alsa="OFF"
|
2018-02-08 21:23:51 -05:00
|
|
|
read -r -p "$(msg "Include support for \"internal/pulseaudio\" (requires libpulse) ----- [y/N]: ")" -n 1 p && echo
|
2017-09-15 23:51:22 -04:00
|
|
|
[[ "${p^^}" != "Y" ]] && enable_pulseaudio="OFF"
|
2018-02-08 21:23:51 -05:00
|
|
|
read -r -p "$(msg "Include support for \"internal/network\" (requires wireless_tools) -- [y/N]: ")" -n 1 p && echo
|
2016-11-08 05:04:04 -05:00
|
|
|
[[ "${p^^}" != "Y" ]] && enable_network="OFF"
|
2018-02-08 21:23:51 -05:00
|
|
|
read -r -p "$(msg "Include support for \"internal/mpd\" (requires libmpdclient) -------- [y/N]: ")" -n 1 p && echo
|
2016-11-08 05:04:04 -05:00
|
|
|
[[ "${p^^}" != "Y" ]] && enable_mpd="OFF"
|
2018-02-08 21:23:51 -05:00
|
|
|
read -r -p "$(msg "Include support for \"internal/github\" (requires libcurl) ---------- [y/N]: ")" -n 1 p && echo
|
2016-12-19 23:33:07 -05:00
|
|
|
[[ "${p^^}" != "Y" ]] && enable_curl="OFF"
|
2018-02-08 21:23:51 -05:00
|
|
|
read -r -p "$(msg "Build \"polybar-msg\" used to send ipc messages --------------------- [y/N]: ")" -n 1 p && echo
|
2017-01-09 20:09:27 -05:00
|
|
|
[[ "${p^^}" != "Y" ]] && build_ipc_msg="OFF"
|
2016-05-19 14:23:20 -04:00
|
|
|
|
2016-11-08 05:04:04 -05:00
|
|
|
local cxx="c++"
|
|
|
|
local cc="cc"
|
2016-05-19 14:23:20 -04:00
|
|
|
|
2018-05-20 04:30:33 -04:00
|
|
|
if [[ "${try_to_use_clang}" == "ON" ]]; then
|
|
|
|
if command -v clang++ >/dev/null; then
|
|
|
|
msg "Using compiler: clang++/clang"
|
|
|
|
cxx="clang++"
|
|
|
|
cc="clang"
|
|
|
|
elif command -v g++ >/dev/null; then
|
|
|
|
msg "Using compiler: g++/gcc"
|
|
|
|
cxx="g++"
|
|
|
|
cc="gcc"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
cxx="g++"
|
|
|
|
cc="gcc"
|
2016-05-19 14:23:20 -04:00
|
|
|
fi
|
2016-11-08 05:04:04 -05:00
|
|
|
|
|
|
|
msg "Executing cmake command"
|
|
|
|
cmake \
|
|
|
|
-DCMAKE_C_COMPILER="${cc}" \
|
|
|
|
-DCMAKE_CXX_COMPILER="${cxx}" \
|
|
|
|
-DENABLE_ALSA:BOOL="${enable_alsa}" \
|
2017-09-15 23:51:22 -04:00
|
|
|
-DENABLE_PULSEAUDIO:BOOL="${enable_pulseaudio}"\
|
2016-11-08 05:04:04 -05:00
|
|
|
-DENABLE_I3:BOOL="${enable_i3}" \
|
|
|
|
-DENABLE_MPD:BOOL="${enable_mpd}" \
|
|
|
|
-DENABLE_NETWORK:BOOL="${enable_network}" \
|
2016-12-19 23:33:07 -05:00
|
|
|
-DENABLE_CURL:BOOL="${enable_curl}" \
|
2017-01-09 20:09:27 -05:00
|
|
|
-DBUILD_IPC_MSG:BOOL="${build_ipc_msg}" \
|
2016-11-08 05:04:04 -05:00
|
|
|
.. || msg_err "Failed to generate build... read output to get a hint of what went wrong"
|
|
|
|
|
|
|
|
msg "Building project"
|
|
|
|
make || msg_err "Failed to build project"
|
|
|
|
|
|
|
|
read -r -p "$(msg "Execute 'sudo make install'? [Y/n] ")" -n 1 p && echo
|
|
|
|
[[ "${p^^}" == "Y" ]] && {
|
|
|
|
sudo make install || msg_err "Failed to install executables..."
|
|
|
|
}
|
|
|
|
|
|
|
|
read -r -p "$(msg "Install example configuration? [Y/n]: ")" -n 1 p && echo
|
|
|
|
[[ "${p^^}" == "Y" ]] && {
|
|
|
|
make userconfig || msg_err "Failed to install user configuration..."
|
|
|
|
}
|
|
|
|
|
|
|
|
msg "Build complete!"
|
|
|
|
|
|
|
|
exit 0
|
2016-05-19 14:23:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|