MAKEFILE_CONFIGS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))

ifeq ($(origin CC),default)
CC	= gcc
endif
ifeq ($(origin AS),default)
AS	= gcc
endif
ifeq ($(origin AR),default)
AR	= ar
endif
ifeq ($(origin ARFLAGS),default)
ARFLAGS = rcs
endif
ifeq ($(origin LD),default)
LD	= ld
endif
ifeq ($(origin CXX),default)
CXX = g++
endif
OBJCOPY ?= objcopy

SYS ?= $(shell $(CC) -dumpmachine)
export SYS

DEBUG ?=
export DEBUG

CFLAGS += -Wall -std=c11
CXXFLAGS += -Wall -std=c++14

ifeq ($(DEBUG),1)
CFLAGS += -gdwarf-2 -g3
CXXFLAGS += -gdwarf-2 -g3
CFLAGS += -DDEBUG
ASFLAGS += -DDEBUG
endif

ifeq ($(DEBUG),)
CFLAGS += -O2
CXXFLAGS += -O2
endif

ifeq ($(WERROR),1)
CFLAGS += -Werror
CXXFLAGS += -Werror
endif

ifeq ($(PROFILING),1)
CFLAGS += -DPROFILING=1
endif

MAKEFILE_CONFIGS_INCLUDED = y
include $(MAKEFILE_CONFIGS_DIR)/Makefile.Host
