#                                                          -*-makefile-gmake-*-
# @configure_input@ 
# on @DATE@
#

# Define libexec dir first, since it contains tools needed to compute
# following definitions
EMC2_LIBEXEC_DIR=@EMC2_LIBEXEC_DIR@

# Threads systems
#################

# List of thread flavors to build modules
BUILD_THREAD_FLAVORS=@BUILD_THREAD_FLAVORS@

# If $(threads) is not set already, try running 'flavor'; if the
# result is empty or not in $(BUILD_THREAD_FLAVORS), pick the first
# item from $(BUILD_THREAD_FLAVORS).
threads ?= $(shell echo $(BUILD_THREAD_FLAVORS) | \
	awk -v f="`${EMC2_LIBEXEC_DIR}/flavor 2>/dev/null`" '\
	{ \
	    found=$$1; \
	    split($$0,flavs); \
	    for (val in flavs) \
		if (flavs[val] == f) found=f; \
	    print found; \
	}')

# Uppercase version of flavor name for use in variables
THREADS = $(shell echo $(threads) | tr a-z- A-Z_)

HAVE_POSIX_THREADS=@HAVE_POSIX_THREADS@
HAVE_RT_PREEMPT_THREADS=@HAVE_RT_PREEMPT_THREADS@
HAVE_XENOMAI_THREADS=@HAVE_XENOMAI_THREADS@
HAVE_KERNEL_THREADS=no

POSIX_THREADS_FLAVOR_ID=@POSIX_THREADS_FLAVOR_ID@
RT_PREEMPT_THREADS_FLAVOR_ID=@RT_PREEMPT_THREADS_FLAVOR_ID@
XENOMAI_THREADS_FLAVOR_ID=@XENOMAI_THREADS_FLAVOR_ID@
THREAD_FLAVOR_ID=$($(THREADS)_THREADS_FLAVOR_ID)

POSIX_THREADS_BUILD_SYS = user-dso
RT_PREEMPT_THREADS_BUILD_SYS = user-dso
XENOMAI_THREADS_BUILD_SYS = user-dso
BUILD_SYS = $($(THREADS)_THREADS_BUILD_SYS)

# Directories
#############

prefix=@prefix@
exec_prefix=@exec_prefix@

EMC2_HOME=@EMC2_HOME@
LIB_DIR=@EMC2_HOME@/lib

RTDIR_EXT=$(threads)

#used for install stuff
#but have them here as reference
#build system only uses EMC2_RTLIB_DIR when creating rtapi.ini
EMC2_BIN_DIR=@EMC2_BIN_DIR@
EMC2_TCL_DIR=@EMC2_TCL_DIR@
EMC2_HELP_DIR=@EMC2_HELP_DIR@
EMC2_RTLIB_BASE_DIR=@EMC2_RTLIB_DIR@
EMC2_RTLIB_DIR=$(EMC2_RTLIB_BASE_DIR)/$(RTDIR_EXT)
EMC2_USER_CONFIG_DIR=~/emc2/configs
EMC2_SYSTEM_CONFIG_DIR=@EMC2_SYSTEM_CONFIG_DIR@
EMC2_NCFILES_DIR=@EMC2_NCFILES_DIR@
REALTIME=@REALTIME@
EMC2_IMAGEDIR=@EMC2_IMAGE_DIR@
GIT_VERSION=@GIT_VERSION@
GIT_CONFIG_SHA=@GIT_CONFIG_SHA@

# Standard configure directories
# do we really need these?
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
datarootdir = @datarootdir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
docdir = @docdir@
sampleconfsdir = ${datadir}/linuxcnc/examples/sample-configs
ncfilesdir = ${datadir}/linuxcnc/ncfiles
tcldir = ${prefix}/lib/tcltk/linuxcnc

# i18n variables:

package = @PACKAGE@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
localedir = @LOCALEDIR@
LANGUAGES = @LANGUAGES@

# architecture-dependent optimizations
ARCH_CFLAGS=@ARCH_CFLAGS@

# /Standard configure directories
RTOPT:=-O2 	$(ARCH_CFLAGS)
ULOPT:=-O2	$(ARCH_CFLAGS)
RUN_IN_PLACE = @RUN_IN_PLACE@
POSIX_THREADS_LDFLAGS = @POSIX_THREADS_LDFLAGS@
RT_PREEMPT_THREADS_LDFLAGS = @RT_PREEMPT_THREADS_LDFLAGS@
XENOMAI_THREADS_LDFLAGS = @XENOMAI_THREADS_LDFLAGS@
RT_LDFLAGS = $($(THREADS)_THREADS_LDFLAGS)

XENOMAI_THREADS_RTS=@XENOMAI_THREADS_RTS@
XENOMAI_KERNEL_THREADS_RTS=@XENOMAI_KERNEL_THREADS_RTS@
RTAI_KERNEL_THREADS_RTS=@RTAI_KERNEL_THREADS_RTS@

SHMDRV_KERNEL_DIRS = @SHMDRV_KERNEL_DIRS@
KERNEL_DIRS = $($(THREADS)_THREADS_KERNEL_DIRS)

XENOMAI_KERNEL_THREADS_EXTRA_SYMBOLS = @XENOMAI_KERNEL_THREADS_EXTRA_SYMBOLS@
RTAI_KERNEL_THREADS_EXTRA_SYMBOLS = @RTAI_KERNEL_THREADS_EXTRA_SYMBOLS@
KBUILD_EXTRA_SYMBOLS = $($(THREADS)_THREADS_EXTRA_SYMBOLS) \
	$(EMC2_RTLIB_DIR)/Module.symvers

POSIX_THREADS_RTFLAGS = @POSIX_THREADS_RTFLAGS@
RT_PREEMPT_THREADS_RTFLAGS = @RT_PREEMPT_THREADS_RTFLAGS@
XENOMAI_THREADS_RTFLAGS = @XENOMAI_THREADS_RTFLAGS@
THREADS_RTFLAGS = $($(THREADS)_THREADS_RTFLAGS) \
	-DTHREAD_FLAVOR_ID=$(THREAD_FLAVOR_ID)

RTFLAGS := -I. $(THREADS_RTFLAGS) \
	-DRTAPI -D_GNU_SOURCE -D_FORTIFY_SOURCE=0

KERNEL_MATH_CFLAGS = $($(THREADS)_THREADS_KERNEL_MATH_CFLAGS)

ULFLAGS = -D_GNU_SOURCE -DLOCALE_DIR=\"$(localedir)\" -DPACKAGE=\"$(package)\"

POSIX_THREADS_BUILD_SYS = @POSIX_THREADS_BUILD_SYS@
RT_PREEMPT_THREADS_BUILD_SYS = @RT_PREEMPT_THREADS_BUILD_SYS@
XENOMAI_THREADS_BUILD_SYS = @XENOMAI_THREADS_BUILD_SYS@
BUILD_SYS = $($(THREADS)_THREADS_BUILD_SYS)

MODULE_EXT = .so

CC = @CC@
CC_FOR_BUILD = @CC_FOR_BUILD@
OBJCOPY = @OBJCOPY@
LD = @LD@
CROSS_COMPILING = @CROSS_COMPILING@
PKG_CONFIG = @PKG_CONFIG@
YAPPS2 = @YAPPS2@
MANDB = @MANDB@
HIDRAW_H_USABLE = @HIDRAW_H_USABLE@

POSIX_THREADS_SOURCE = @POSIX_THREADS_SOURCE@
RT_PREEMPT_THREADS_SOURCE = @RT_PREEMPT_THREADS_SOURCE@
XENOMAI_THREADS_SOURCE = @XENOMAI_THREADS_SOURCE@
THREADS_SOURCE = $($(THREADS)_THREADS_SOURCE)

BUILD_DRIVERS = @BUILD_DRIVERS@
USE_PORTABLE_PARPORT_IO = @USE_PORTABLE_PARPORT_IO@
TARGET_PLATFORM_PC = @TARGET_PLATFORM_PC@
TARGET_PLATFORM_SOCFPGA = @TARGET_PLATFORM_SOCFPGA@
TARGET_PLATFORM_BEAGLEBONE = @TARGET_PLATFORM_BEAGLEBONE@
TARGET_PLATFORM_CHIP = @TARGET_PLATFORM_CHIP@
TARGET_PLATFORM_RASPBERRY = @TARGET_PLATFORM_RASPBERRY@
TARGET_PLATFORM_ZEDBOARD = @TARGET_PLATFORM_ZEDBOARD@
TARGET_PLATFORM_H3 = @TARGET_PLATFORM_H3@

HARDY_AMD64_WORKAROUND=@HARDY_AMD64_WORKAROUND@
PRECISE_MULTILIB_BUG=@PRECISE_MULTILIB_BUG@

USERMODE_PCI=@USERMODE_PCI@

# example programs
BUILD_EXAMPLES=@BUILD_EXAMPLES@

# emcweb UI
BUILD_EMCWEB=@BUILD_EMCWEB@

# webtalk
BUILD_WEBTALK=@BUILD_WEBTALK@

#  build uninished development code
BUILD_DEV=@BUILD_DEV@

# enable not-yet-ported NML parts
BUILD_NMLDEP=@BUILD_NMLDEP@

# shared memory kernel driver
USE_SHMDRV=@USE_SHMDRV@

# example programs
BUILD_EXAMPLES=@BUILD_EXAMPLES@


# zeroMQ messaging
CZMQ_CFLAGS=@CZMQ_CFLAGS@
CZMQ_LIBS=@CZMQ_LIBS@
USE_CZMQ=@USE_CZMQ@

# protobuf messaging
PROTOC=@PROTOC@
PROTOBUF_CFLAGS=@PROTOBUF_CFLAGS@
PROTOBUF_LIBS=@PROTOBUF_LIBS@
USE_PROTOBUF=@USE_PROTOBUF@
PROTO2JS=@PROTO2JS@

#  build protobuf Javscript bindings
BUILD_PROTO_JS=@BUILD_PROTO_JS@

# jansson JSON C library
JANSSON_CFLAGS=@JANSSON_CFLAGS@
JANSSON_LIBS=@JANSSON_LIBS@
USE_JANSSON=@USE_JANSSON@

# libwebsockets C library
LWS_CFLAGS=@LWS_CFLAGS@
LWS_LIBS=@LWS_LIBS@
USE_LWS=@USE_LWS@

# SSL library
SSL_CFLAGS=@SSL_CFLAGS@
SSL_LIBS=@SSL_LIBS@
USE_SSL=@USE_SSL@

# uriparser C library
URIPARSER_CFLAGS=@URIPARSER_CFLAGS@
URIPARSER_LIBS=@URIPARSER_LIBS@
USE_URIPARSER=@USE_URIPARSER@

# avahi-client library
AVAHI_CFLAGS=@AVAHI_CFLAGS@
AVAHI_LIBS=@AVAHI_LIBS@
USE_AVAHI=@USE_AVAHI@

# uuid-dev C library
UUID_CFLAGS=@UUID_CFLAGS@
UUID_LIBS=@UUID_LIBS@
USE_UUID=@USE_UUID@

LIBBACKTRACE = @LIBBACKTRACE@

#libudev for if USERMODE_PCI==yes
LIBUDEV_CFLAGS=@LIBUDEV_CFLAGS@
LIBUDEV_LIBS=@LIBUDEV_LIBS@

# cgroup support
LIBCGROUP_CFLAGS=@LIBCGROUP_CFLAGS@
LIBCGROUP_LIBS=@LIBCGROUP_LIBS@

# deps for xemc
CFLAGS_X = @X_CFLAGS@
XLIBS = @XAW_LIBS@
HAVE_XAW = @HAVE_XAW@

# ncurses support for keystick
KEYSTICKLIBS =  @NCURSES_LIBS@
HAVE_NCURSES = @HAVE_NCURSES@

# readline support for halcmd
READLINE_LIBS =  @READLINE_LIBS@

# flags for glib
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@

# local flags for GTK include
HAVE_GTK = @HAVE_GTK@
GTK_CFLAGS = @GTK_CFLAGS@
GTK_LIBS = @GTK_LIBS@
HAVE_GNOMEPRINT = @HAVE_GNOMEPRINT@

# tcl tk cflags, includes and libs
TCL_DBGX=@TCL_DBGX@
TK_DBGX=@TK_DBGX@
TCL_CFLAGS=@TCL_CFLAGS@ @TK_CFLAGS@
TCL_LIBS=@TCL_LIBS@ @TK_LIBS@ @LIBS@
HAVE_WORKING_BLT=@HAVE_WORKING_BLT@


AR = @AR@
ARFLAGS = cr
CXX = @CXX@
CXXFLAGS = @CXXFLAGS@
RANLIB = @RANLIB@
MSGFMT = @MSGFMT@
XGETTEXT = @XGETTEXT@

BUILD_DOCS = @BUILD_DOCS@
#BUILD_DOCS_PDF = @BUILD_DOCS_PDF@
#BUILD_DOCS_HTML = @BUILD_DOCS_HTML@
PYTHON = @PYTHON@
TCLSH = @TCLSH@
EMC2_TCL_LIB_DIR = @EMC2_TCL_LIB_DIR@
A2X_LATEX_ENCODING = @A2X_LATEX_ENCODING@

HAVE_LIBMODBUS3   = @HAVE_LIBMODBUS3@
LIBMODBUS_LIBS    = @LIBMODBUS_LIBS@
LIBMODBUS_CFLAGS  = @LIBMODBUS_CFLAGS@

HAVE_LIBUSB10   = @HAVE_LIBUSB10@
LIBUSB10_LIBS   = @LIBUSB10_LIBS@
LIBUSB10_CFLAGS = @LIBUSB10_CFLAGS@

HAVE_LTTNG_UST   = @HAVE_LTTNG_UST@
LTTNG_UST_LIBS   = @LTTNG_UST_LIBS@
LTTNG_UST_CFLAGS = @LTTNG_UST_CFLAGS@

#
# i18n
#


#### BEGIN CONFIG ####

# To disable compilation of any particular module,
# edit the following lines replacing "m" with "n".
#
# In time, we may have some fancy dohicky to set
# these options at compile time.

# usually you need rtapi,
# so you probably don't want to change this
CONFIG_RTAPI=m

# rtapi examples
CONFIG_RTAPI_EXAMPLES_EXTINT=m
CONFIG_RTAPI_EXAMPLES_FIFO=m
CONFIG_RTAPI_EXAMPLES_SEM=m
CONFIG_RTAPI_EXAMPLES_SHMEM=m
CONFIG_RTAPI_EXAMPLES_TIMER=m

# emc motion module
CONFIG_MOTMOD=m

# HAL components
CONFIG_BLOCKS=m
CONFIG_BOSS_PLC=m
CONFIG_DEBOUNCE=m
CONFIG_ENCODER=m
CONFIG_COUNTER=m
CONFIG_ENCODER_RATIO=m
CONFIG_STEPGEN=m
CONFIG_LCD=m
CONFIG_MUX_GENERIC=m
CONFIG_MATRIX_KB=m
CONFIG_FREQGEN=m
CONFIG_PWMGEN=m
CONFIG_SIGGEN=m
CONFIG_AT_PID=m
CONFIG_PID=m
CONFIG_PEPPER=m
CONFIG_SUPPLY=m
CONFIG_CLASSICLADDER_RT=m
CONFIG_TIMEDELAY=m
CONFIG_SIM_ENCODER=m
CONFIG_WEIGHTED_SUM=m
CONFIG_WATCHDOG=m
CONFIG_MODMATH=m
CONFIG_STREAMER=m
CONFIG_SAMPLER=m
CONFIG_RINGLOAD=m

# HAL drivers
CONFIG_UPARPORT=m
CONFIG_HAL_PARPORT=m
CONFIG_PROBE_PARPORT=m
CONFIG_HAL_TIRO=m
CONFIG_HAL_EVOREG=m
CONFIG_HAL_MOTENC=m
CONFIG_HAL_SKELETON=m
CONFIG_HAL_GPIO=m
CONFIG_HM2_SOC_OL=m
CONFIG_HAL_SPI=m
CONFIG_HAL_SPEAKER=m
CONFIG_HAL_STG=m
CONFIG_HAL_VTI=m
CONFIG_HAL_AX521H=m
CONFIG_HAL_PPMC=m
CONFIG_PCI_8255=m
CONFIG_HOSTMOT2=m
CONFIG_OPTO_AC5=m
CONFIG_HAL_GM=m
CONFIG_HAL_CAN=m

# Python-related
BUILD_PYTHON=@BUILD_PYTHON@
PYTHON_CPPFLAGS=@PYTHON_CPPFLAGS@
PYTHON_LIBS=@PYTHON_LIBS@
BOOST_PYTHON_LIB=@BOOST_PYTHON_LIB@
SITEPY=@SITEPY@
CYTHON=@CYTHON@

# Boost
BOOST_SERIALIZATION_LIB=@BOOST_SERIALIZATION_LIB@
BOOST_THREAD_LIB=@BOOST_THREAD_LIB@
# Later Boost versions need -lboost_system with -lboost_thread
BOOST_SYSTEM_LIB=@BOOST_SYSTEM_LIB@

#### END CONFIG ####

