ENABLE_AVX ?= 0
USE_EXTERNAL_TRIO ?= 0

LIBS_ICONV := -liconv
LIBS_WINMM := -lwinmm

BUILD = $(shell $(CC_FOR_BUILD) -dumpmachine)

CONF_ARGS = --build=$(BUILD) --host=$(HOST)

ifeq ($(ENABLE_AVX), 0)
	CONF_ARGS += --disable-avx
else
	CONF_ARGS += --enable-avx
endif

ifeq ($(PLATFORM), Windows)
	DEFS += -DWIN32 -DMDFN_PSS_STYLE=2 -DUNICODE=1 -D_UNICODE=1 \
		-D_LFS64_LARGEFILE=1
	FLAGS += -fno-aggressive-loop-optimizations
	LIBS += $(LIBS_WINMM)
else
	DEFS += -DMDFN_PSS_STYLE=1
	FLAGS_DEPS += $(CFLAGS_PTHREAD)
	FLAGS_STATIC += $(CFLAGS_PTHREAD)
	FLAGS += $(CFLAGS_PTHREAD)
	LIBS += $(CFLAGS_PTHREAD)
endif

ifneq ($(PLATFORM), Linux)
	LIBS += $(LIBS_ICONV)
endif

ifeq ($(USE_EXTERNAL_TRIO), 0)
	CFLAGS_TRIO := -I$(SRCDIR)/trio
	LIBS_TRIO :=
	MKDIRS += trio
	SRCS_TRIO := trio/trio.c trio/trionan.c trio/triostr.c
	OBJS_TRIO := $(patsubst %,$(OBJDIR)/%,$(SRCS_TRIO:.c=.o))
else
	override REQUIRES_PRIVATE += libtrio
	CFLAGS_TRIO = $(shell $(PKG_CONFIG) --cflags libtrio)
	LIBS_TRIO = $(shell $(PKG_CONFIG) --libs libtrio)
	OBJS_TRIO :=
endif
