3 # This script is meant to be kept small and simple
4 # If you think about adding features, it's probably a bad idea
6 set -e # exit if a command fails
7 set -o pipefail # Will return the exit status of make if it fails
9 project_source_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
11 build_dir="${project_source_dir}/build${SUBDIR:+/${SUBDIR}}"
12 install_dir="${project_source_dir}/install${SUBDIR:+/${SUBDIR}}"
14 install_target='install/strip'
20 if command -v 'nproc' >/dev/null
26 egrep "^processor" /proc/cpuinfo | wc -l
31 'MSYS_NT-'*|'CYGWIN_NT-'*|'MINGW'*'_NT-'*)
32 if command -v 'wmic' >/dev/null
34 wmic cpu get NumberOfLogicalProcessors/Format:List \
35 | grep -m1 '=' | cut -f2 -d'='
37 echo "${NUMBER_OF_PROCESSORS:-${_job_count}}"
47 job_count="$(_nproc)" 2>/dev/null
48 job_count="${job_count:-${_job_count}}"
50 declare -a cmake_user_opts
59 install_target='install'
64 cmake_user_opts[${#cmake_user_opts[@]}]="${1}"
70 declare -a fetch_submodules_cmd
71 for submodule_file in 'libs/crunch/inc/crn_decomp.h' \
72 'tools/unvanquished/daemonmap/tools/quake3/q3map2/main.c'
74 if ! [ -f "${project_source_dir}/${submodule_file}" ]
76 fetch_submodules_cmd=(git -C "${project_source_dir}" submodule update --init --recursive)
82 cmake_user_opts[${#cmake_user_opts[@]}]='-DBUILTIN_GTKGLEXT=ON'
88 "${fetch_submodules_cmd[@]}"
90 mkdir -pv "${build_dir}"
95 -D'CMAKE_INSTALL_PREFIX'="${install_dir}" \
96 -D'CMAKE_BUILD_TYPE'="${build_type}" \
97 "${cmake_user_opts[@]}" \
98 "${project_source_dir}"
101 --build "${build_dir}" \
107 --build "${build_dir}" \