#!/bin/bash
#
# Generate rtapi.ini
#
# This is a template to generate a shell script to generate an
# ini-style configuration for RTAPI.  :P
#
# This is a template so that per-flavor config can be dumped from
# configure.in without this template having lots of repetition and
# pre-determining per-flavor sections.
#
# The resulting shell script generates the ini-style configuration for
# RTAPI.  This intermediate step is necessary because autoconf does a
# limited amount of shell variable expansion; for example,
# ${libexecdir} expands to ${exec_prefix}/lib rather than /usr/lib.
# Running these through this shell script completes the expansion so
# that values can be used without further processing.

#################################################
# Copyright (C) 2012, 2013  John Morris <john AT zultron DOT com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
#################################################

# Basic paths
#
# Variables used below
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
libexecdir=@libexecdir@
sysconfdir=@sysconfdir@

# Makefile.inc paths
EMC2_HOME=@EMC2_HOME@
RTLIB_DIR=@EMC2_RTLIB_DIR@
SYSTEM_CONFIG_DIR=@EMC2_SYSTEM_CONFIG_DIR@
LIBEXEC_DIR=@EMC2_LIBEXEC_DIR@
BIN_DIR=@EMC2_BIN_DIR@

# Makefile.inc parameters
USE_PORTABLE_PARPORT_IO=@USE_PORTABLE_PARPORT_IO@
TARGET_PLATFORM=@TARGET_PLATFORM@
GIT_VERSION=@GIT_VERSION@
RUN_IN_PLACE=@RUN_IN_PLACE@
PIDOF=@PIDOF@
RTAI_KERNEL_THREADS_RTS="@RTAI_KERNEL_THREADS_RTS@"
USE_SHMDRV=@USE_SHMDRV@


#################################################
# Global section
#
# Generate the [global] section of the config

cat <<EOF
# ${SYSTEM_CONFIG_DIR}/rtapi.ini
#
# LinuxCNC RTAPI system configuration
#
# Most values here will never need to be changed.  Power users may
# want to change DEBUG.

[global]
# Default DEBUG level, 0-5 for NONE, ERR, WARN, INFO, DBG, ALL
DEBUG=1

# shared memory kernel driver
USE_SHMDRV=${USE_SHMDRV}

# fixme make param
HAL_SIZE=524288

# Executables
flavor=${LIBEXEC_DIR}/flavor
rtapi_msgd=${LIBEXEC_DIR}/rtapi_msgd
linuxcnc_module_helper=${LIBEXEC_DIR}/linuxcnc_module_helper
# rtapi_app should be defined in the appropriate flavor section below

# directory paths
EMC2_HOME=${EMC2_HOME}
RTLIB_DIR=${RTLIB_DIR}
LIBEXEC_DIR=${LIBEXEC_DIR}
BIN_DIR=${BIN_DIR}

# build parameters
USE_PORTABLE_PARPORT_IO=@USE_PORTABLE_PARPORT_IO@
TARGET_PLATFORM=@TARGET_PLATFORM@
GIT_VERSION=@GIT_VERSION@
RUN_IN_PLACE=@RUN_IN_PLACE@
PIDOF=@PIDOF@

EOF

#################################################
# Flavor sections
#
# The following sections are added automatically by configure.in
# macros.


