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'
17 if [ "$(uname -s)" = 'FreeBSD' ]
19 install_target='install'
25 if command -v 'nproc' >/dev/null
31 egrep "^processor" /proc/cpuinfo | wc -l
37 sysctl -n hw.logicalcpu \
40 'MSYS_NT-'*|'CYGWIN_NT-'*|'MINGW'*'_NT-'*)
41 if command -v 'wmic' >/dev/null
43 wmic cpu get NumberOfLogicalProcessors/Format:List \
44 | grep -m1 '=' | cut -f2 -d'='
46 echo "${NUMBER_OF_PROCESSORS:-${_job_count}}"
56 job_count="$(_nproc)" 2>/dev/null
57 job_count="${job_count:-${_job_count}}"
59 declare -a cmake_user_opts
68 install_target='install'
73 cmake_user_opts[${#cmake_user_opts[@]}]="${1}"
79 declare -a fetch_submodules_cmd
80 for submodule_file in 'libs/crunch/inc/crn_decomp.h' \
81 'tools/unvanquished/daemonmap/tools/quake3/q3map2/main.c'
83 if ! [ -f "${project_source_dir}/${submodule_file}" ]
85 fetch_submodules_cmd=(git -C "${project_source_dir}" submodule update --init --recursive)
91 cmake_user_opts[${#cmake_user_opts[@]}]='-DBUILTIN_GTKGLEXT=ON -DBUILTIN_GTKTHEME_MOJAVE=ON'
97 "${fetch_submodules_cmd[@]}"
99 mkdir -pv "${build_dir}"
104 -D'CMAKE_INSTALL_PREFIX'="${install_dir}" \
105 -D'CMAKE_BUILD_TYPE'="${build_type}" \
106 "${cmake_user_opts[@]}" \
107 "${project_source_dir}"
110 --build "${build_dir}" \
116 --build "${build_dir}" \