
SHELL:=$(shell sh -c "command -v bash")

ifeq ($(ROOT),)
$(error ROOT is undefined)
endif

ifneq ($(wildcard $(ROOT)/deps/readies),)
READIES:=$(ROOT)/deps/readies
else ifneq ($(wildcard $(ROOT)/opt/readies),)
READIES:=$(ROOT)/opt/readies
else
$(error Cannot find readies root)
endif

MK:=$(READIES)/mk

MK.pyver ?= 2
MK.getpy=getpy$(MK.pyver)

ifneq ($(shell { CHECK=1 $(READIES)/bin/$(MK.getpy); echo -n $$?; }),0)
ifneq ($(filter setup,$(MAKECMDGOALS)),)
MK.nobindir:=1
else
$(error It seems build prerequisites have not been installed: please run 'sudo make setup'.)
endif
__NO_PYTHON=1
endif

MK_ALL_TARGETS:=bindirs build
DEFAULT_TARGETS:=bindirs

SUDO:=$(shell [ $$( command -v sudo >/dev/null 2>&1; echo $$? ) = 0 ] && echo sudo)
USER:=$(shell whoami)

include $(MK)/functions
include $(MK)/common.defs

ifneq ($(__NO_PYTHON),1)

include $(MK)/platform.defs

ifeq ($(OS),macosx)
include $(MK)/macosx.defs
endif

include $(MK)/git.defs
include $(MK)/variant.defs
include $(MK)/bindirs.defs
include $(MK)/nproc.defs

endif # __NO_PYTHON