<'
#
# Copyright (c) 2012-2015,2018,2020-2023, 2025-2026 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 Sun Jan  1 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">-genom],[<"$version">],[<"$email">])
AC_PREREQ(2.62)
AC_CONFIG_HEADERS([autoconf/acheader.h])
AC_CONFIG_SRCDIR([<"$name">_ros/package.xml])
AC_CONFIG_AUX_DIR([autoconf])
AC_CONFIG_MACRO_DIR([autoconf])
AM_INIT_AUTOMAKE([foreign no-define subdir-objects])
LT_INIT([disable-static])
AC_PROG_CC
AC_PROG_CXX

dnl libs
AC_SEARCH_LIBS([timer_create], [rt])

dnl External software
AX_PTHREAD(, [AC_MSG_ERROR([pthread support not available])])
AX_BOOST_BASE([1.40],, [AC_MSG_ERROR([boost not available])])
AX_BOOST_THREAD
PKG_CHECK_MODULES(genom3, [genom3 >= 3.3])
_PKG_CONFIG(genom3, [variable=GENOM_TOOL], [genom3 >= 3.3])
AC_SUBST(genom3, [$pkg_cv_genom3])

dnl ROS
<'
set msgpkgs [dict create]
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
        roscpp >= 1.8.15
        roscpp_serialization >= 0.2.6
        actionlib >= 1.8.7
        actionlib_msgs >= 1.8.13
        std_msgs >= 0.4.11
        <"[dict keys $msgpkgs]">
])

# add boost thread dependency
ROS_CFLAGS="$ROS_CFLAGS $BOOST_CPPFLAGS"
ROS_LIBS="$ROS_LIBS $BOOST_LDFLAGS $BOOST_THREAD_LIB"

AG_FIX_ROS_LIBS([ROS_LIBS]) # clean up -l: syntax, add rpath
AG_FIX_ROS_LIBS([ROS_CFLAGS]) # remove dups
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 Codels
PKG_CHECK_MODULES(<"[$comp name]">,
  [<"[$comp name]">-genom3 >= <"[$comp version]">])

dnl Generate
AC_CONFIG_FILES([
	Makefile
])
AC_OUTPUT
