<'
#
# Copyright (c) 2012-2013,2015,2018,2020,2023 LAAS/CNRS
# All rights reserved.
#
# Permission to use, copy, modify, and distribute this software for any purpose
# with or without   fee is hereby granted, provided   that the above  copyright
# notice and this permission notice appear in all copies.
#
# 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 Oct 18 2012
#

# check arguments
if {[llength $argv] != 2} { error "expected arguments: component types" }
lassign $argv comp types

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

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

dnl Autoconf setup
AC_INIT([<"$name">-ros-client],[<"$version">],[<"$email">])
AC_PREREQ(2.62)
AC_CONFIG_SRCDIR([<"$name">_ros/package.xml])
AC_CONFIG_MACRO_DIR([autoconf])
AM_INIT_AUTOMAKE([foreign no-define subdir-objects])


dnl External software
PKG_CHECK_MODULES(genom3, [genom3 >= 2.99.13])
_PKG_CONFIG(genom3, [variable=GENOM_TOOL], [genom3 >= 2.99.13])
AC_SUBST(genom3, [$pkg_cv_genom3])

dnl ROS
<'
set msgpkgs [dict create]
dict set msgpkgs actionlib_msgs {}
dict set msgpkgs std_msgs {}
foreach t $types {
  if {[catch {$t masquerade ros} masquerade]} continue
  dict set msgpkgs [lindex [split $masquerade /] 0] {}
}
'>
PKG_CHECK_MODULES(ROS, [
        rospack
        roslib >= 1.8.10
        actionlib_msgs >= 1.8.13
        gencpp >= 0.3.4
        genpy >= 0.3.7
        std_msgs >= 0.4.11
        <"[dict keys $msgpkgs]">
])
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)

# gencpp
AG_ROS_PKGPREFIX([gencpp_prefix], [gencpp >= 0.4])
if test -z "$gencpp_prefix"; then
  AG_ROS_PKGPREFIX([gencpp_prefix], [gencpp >= 0.3.4])
  GENCPP="$gencpp_prefix/bin/gen_cpp.py"
else
  GENCPP="$gencpp_prefix/lib/gencpp/gen_cpp.py"
fi
if ! test -x "$GENCPP"; then
  AC_MSG_ERROR([cannot find gen_cpp.py])
fi
AC_SUBST(GENCPP)

# genpy
AG_ROS_PKGPREFIX([genpy_prefix], [genpy >= 0.4])
if test -z "$genpy_prefix"; then
  AG_ROS_PKGPREFIX([genpy_prefix], [genpy >= 0.3.7])
  GENMSGPY="$genpy_prefix/bin/genmsg_py.py"
  GENSRVPY="$genpy_prefix/bin/gensrv_py.py"
else
  GENMSGPY="$genpy_prefix/lib/genpy/genmsg_py.py"
  GENSRVPY="$genpy_prefix/lib/genpy/gensrv_py.py"
fi
if ! test -x "$GENMSGPY"; then
  AC_MSG_ERROR([cannot find genmsg_py.py])
fi
if ! test -x "$GENSRVPY"; then
  AC_MSG_ERROR([cannot find gensrv_py.py])
fi
AC_SUBST(GENMSGPY)
AC_SUBST(GENSRVPY)

# 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)

# genmsg path
genmsg_path=
for pkg in <"[dict keys $msgpkgs]">; do
  p=`$PKG_CONFIG --variable=prefix $pkg`
  genmsg_path="$genmsg_path -I '$pkg:$p/share/$pkg/msg'"
done
AC_SUBST(genmsg_path)


dnl Generate
AC_CONFIG_FILES([
	Makefile
	<"$name">_ros.pc
	<"$name">_rosConfig.cmake
	<"$name">_rosConfig-version.cmake
])
AC_OUTPUT
