# by default, the target system is the same as the compiling system
TARGET_SYSTEM := $(shell uname -s)
# Under MinGW, Cygwin, MSYS2, etc. on Windows,
# uname -s has the format "<name>_NT-<version>",
# e. g. "MINGW64_NT-10.0-19044" or "CYGWIN_NT-10.0".
# To simplify checking for Windows,
# we detect this format and replace it with simply "Windows".
ifneq ($(findstring NT-,$(TARGET_SYSTEM)),)
	TARGET_SYSTEM := Windows
endif

ifeq ($(TARGET_SYSTEM),Windows)
	lib_ext := dll
	foreign_ext := dll
	bin_suffix := .exe
else
	# If not Windows, assume Unix-like.
	
	ifeq ($(TARGET_SYSTEM),Darwin)
		lib_ext := dylib
		foreign_ext := bundle
	else
		lib_ext := so
		foreign_ext := so
	endif
	
	bin_suffix :=
endif

ifdef SICSTUSDIR
	sicstus = $(SICSTUSDIR)/bin/sicstus$(bin_suffix)
	splfr = $(SICSTUSDIR)/bin/splfr$(bin_suffix)
else
	sicstus := sicstus
	splfr := splfr
endif

common_splfr_flags := -larmadillo -lmlpack -lstdc++ -cxx --cxxflag=-std=c++17 --struct