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
32 sysctl -n hw.logicalcpu \
35 'MSYS_NT-'*|'CYGWIN_NT-'*|'MINGW'*'_NT-'*)
36 if command -v 'wmic' >/dev/null
38 wmic cpu get NumberOfLogicalProcessors/Format:List \
39 | grep -m1 '=' | cut -f2 -d'='
41 echo "${NUMBER_OF_PROCESSORS:-${_job_count}}"
51 job_count="$(_nproc)" 2>/dev/null
52 job_count="${job_count:-${_job_count}}"
54 declare -a cmake_user_opts
63 install_target='install'
68 cmake_user_opts[${#cmake_user_opts[@]}]="${1}"
74 declare -a fetch_submodules_cmd
75 for submodule_file in 'libs/crunch/inc/crn_decomp.h' \
76 'tools/unvanquished/daemonmap/tools/quake3/q3map2/main.c'
78 if ! [ -f "${project_source_dir}/${submodule_file}" ]
80 fetch_submodules_cmd=(git -C "${project_source_dir}" submodule update --init --recursive)
86 cmake_user_opts[${#cmake_user_opts[@]}]='-DBUILTIN_GTKGLEXT=ON -DBUILTIN_GTKTHEME_MOJAVE=ON'
92 "${fetch_submodules_cmd[@]}"
94 mkdir -pv "${build_dir}"
99 -D'CMAKE_INSTALL_PREFIX'="${install_dir}" \
100 -D'CMAKE_BUILD_TYPE'="${build_type}" \
101 "${cmake_user_opts[@]}" \
102 "${project_source_dir}"
105 --build "${build_dir}" \
111 --build "${build_dir}" \