<'
#
# Copyright (c) 2011-2012, 2014, 2017, 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 Tue Jan 11 2011
#

# check arguments
if {[llength $argv] != 6} {
  error "expected argument: components input names idls terse skelopts"
}
lassign $argv components input names idls terse skelopts

set inputs '[join [list {*}$input {*}$names] {' '}]'

# generate copyright notice (if any)
if {![catch {dotgen input notice} text]} {
  puts #[join [split $text "\n"] "\n#"]
}
'>
ACLOCAL_AMFLAGS=	-I autoconf

# IDL source files
idldir=		$(datadir)/idl/<"[[lindex $components 0] name]">
nobase_dist_idl_DATA= <"$idls">

pkgconfigdir=	$(libdir)/pkgconfig
pkgconfig_DATA=
<'foreach c $components {'>
<'  switch [$c class] {'>
<'    interface {'>
pkgconfig_DATA+= <"[$c name]-libgenom3.pc">
<'    }'>
<'    component {'>
pkgconfig_DATA+= <"[$c name]-genom3.pc">
<'    }'>
<'  }'>
<'}'>

# we don't want generated templates in the distribution
#
DIST_SUBDIRS=		codels
SUBDIRS=		${DIST_SUBDIRS}

<'if {"component" in [lmap c $components {$c class}]} {'>
# recursion into templates directories configured with --with-templates
#
SUBDIRS+=		${AG_TEMPLATES_SUBDIRS}

distclean-local:
	-rm -rf ${AG_TEMPLATES_SUBDIRS}
<'}'>

# a rule to invoke skeleton merge mode
#
merge: merge-interactive
merge-%:
	cd ${top_srcdir} && ${GENOM3} <"[dotgen genom cmdline]"> \
	  skeleton <"[join $skelopts { }]"> -m $* <"$inputs">
<'if {!$terse} {'>

# documentation
dist_doc_DATA=	README.html README.adoc

%.html: %.adoc
	$(ASCIIDOCTOR) $(ASCIIDOCTOR_ARGS) -b html5 -o $@ $<
<'}'>
