diff --git a/Makefile b/Makefile index 03bc0e6..52dbba5 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ INSTALL_PREFIX ?= dist # Internal variables override CFLAGS = -Wall -Wextra -Werror -pedantic -Isrc override LIBFLAGS = -fPIC -override ABS_INSTALL_PREFIX != readlink -f $(INSTALL_PREFIX) +override ABS_INSTALL_PREFIX := $(shell mkdir -p $(INSTALL_PREFIX) && realpath $(INSTALL_PREFIX)) override CSTD := -std=gnu11 override CXXSTD := -std=gnu++11 override KERNEL := $(shell uname -s) diff --git a/build b/build index 8d16d0e..e36c12d 100755 --- a/build +++ b/build @@ -6,7 +6,7 @@ BOLD="\033[1m" NC="\033[0m" # No Color BUILD_TYPE="Debug" -ACCEPTED_BUILD_TYPES=("RelWithDebInfo" "Debug" "Release") +ACCEPTED_BUILD_TYPES=("Debug" "RelWithDebInfo" "Release") KERNEL="$(uname -s)" ARGS="" @@ -15,6 +15,15 @@ join_array_elements() { echo "$*" } +contains() { + local item="$1"; shift + local e + for e; do + [[ "$e" == "$item" ]] && return 0 + done + return 1 +} + print_usage() { echo -e "Usage: build [-b build_type] ..." echo -e " Options:" @@ -40,10 +49,7 @@ while [[ $# > 0 ]];do esac done -# Compare build type against array -# From this: https://www.baeldung.com/linux/check-bash-array-contains-value#using-anifcondition-with-aregex-pattern -build_regex="\<${BUILD_TYPE}\>" -if [[ ! ${ACCEPTED_BUILD_TYPES[@]} =~ $build_regex ]]; then +if ! contains ${BUILD_TYPE} "${ACCEPTED_BUILD_TYPES[@]}"; then echo -e "${RED}${BOLD}Unknown build type: ${BUILD_TYPE}${NC}\n" print_usage exit 1