<'
#
# Copyright (c) 2012-2015, 2018-2019, 2022-2023, 2025-2026 LAAS/CNRS
# All rights reserved.
#
# Redistribution  and  use  in  source  and binary  forms,  with  or  without
# modification, are permitted provided that the following conditions are met:
#
#   1. Redistributions of  source  code must retain the  above copyright
#      notice and this list of conditions.
#   2. Redistributions in binary form must reproduce the above copyright
#      notice and  this list of  conditions in the  documentation and/or
#      other materials provided with the distribution.
#
# THE SOFTWARE  IS PROVIDED "AS IS"  AND THE AUTHOR  DISCLAIMS ALL WARRANTIES
# WITH  REGARD   TO  THIS  SOFTWARE  INCLUDING  ALL   IMPLIED  WARRANTIES  OF
# MERCHANTABILITY AND  FITNESS.  IN NO EVENT  SHALL THE AUTHOR  BE LIABLE FOR
# ANY  SPECIAL, DIRECT,  INDIRECT, OR  CONSEQUENTIAL DAMAGES  OR  ANY DAMAGES
# WHATSOEVER  RESULTING FROM  LOSS OF  USE, DATA  OR PROFITS,  WHETHER  IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR  OTHER TORTIOUS ACTION, ARISING OUT OF OR
# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
#                                           Anthony Mallet on Thu Aug  2 2012
#

# check arguments
if {[llength $argv] != 1} { error "expected arguments: components" }
lassign $argv components

# name of the components
# compute package name, version, e-mail, languages
set name [$components name]
set version [$components version]
if {[catch {$components email} email]} {
  set email "nobody@example.com"
}

lang c
'>
dnl Generated by <"[dotgen genom version]">. Do not edit.

dnl Autoconf setup
AC_INIT([<"$name">-genom],[<"$version">],[<"$email">])
AC_PREREQ(2.62)
AC_CONFIG_HEADERS([autoconf/acheader.h])
AC_CONFIG_AUX_DIR([autoconf])
AC_CONFIG_MACRO_DIR([autoconf])
AM_INIT_AUTOMAKE([foreign no-define subdir-objects])

# Compilers
LT_INIT([disable-static])
AC_PROG_CXX
AX_PTHREAD(, [AC_MSG_ERROR([pthread support not available])])

dnl External software
PKG_CHECK_MODULES(genom3_ros, [genom3-ros >= 1.24])
PKG_CHECK_MODULES(genom3, [genom3 >= 3.3])
_PKG_CONFIG(genom3, [variable=GENOM_TOOL], [genom3 >= 3.3])
AC_SUBST(genom3, [$pkg_cv_genom3])

PKG_CHECK_MODULES(genom3_c_client, [genom3-c-client >= 20250116])
_PKG_CONFIG(GENOM_CLIENT_PROTOCOL, [modversion], [genom3-c-client >= 20250116])
AC_SUBST(GENOM_CLIENT_PROTOCOL, [$pkg_cv_GENOM_CLIENT_PROTOCOL])

# boost
AX_BOOST_BASE([1.40],, [AC_MSG_ERROR([boost not available])])

dnl ROS
PKG_CHECK_MODULES(ROS, [
        rospack
        roslib >= 1.8.10
        roscpp >= 1.8.15
        roscpp_serialization >= 0.2.6
        actionlib >= 1.8.7
        actionlib_msgs >= 1.8.13
        std_msgs >= 0.4.11
])

AG_FIX_ROS_LIBS([ROS_LIBS]) # clean up -l: syntax, add rpath
AG_ROS_LDFLAGS(roscpp) # check --disable-new-dtags
AG_ROS_PYPKG([rospkg roslib])
AG_ROS_PKGPREFIX([rospack_prefix], [rospack])
AG_ROS_PKGPREFIX([std_msgs_prefix], [std_msgs >= 0.4.11])


# msgmd5
AC_PATH_PROG(MSGMD5, [msgmd5], [],
                     [PATH = '<"[dotgen template dir]">/../../common/'])
if ! test -x "$MSGMD5"; then
  AC_MSG_ERROR([cannot find msgmd5])
fi
AC_SUBST(MSGMD5)

# genaction
AG_ROS_PKGPREFIX([genaction_prefix], [actionlib_msgs >= 1.9])
if test -z "$genaction_prefix"; then
  AG_ROS_PKGPREFIX([genaction_prefix], [actionlib_msgs >= 1.8.13])
  GENACTION="$genaction_prefix/share/actionlib_msgs/scripts/genaction.py"
else
  GENACTION="$genaction_prefix/lib/actionlib_msgs/genaction.py"
fi
if ! test -x "$GENACTION"; then
  AC_MSG_ERROR([cannot find genaction.py])
fi
AC_SUBST(GENACTION)


dnl Generate
AC_CONFIG_FILES([
	Makefile
<'foreach c $components {'>
        <"$name">-c-client.pc
        <"$name">-c-client-uninstalled.pc
<'}'>
])
AC_OUTPUT
