#!/bin/sh
cat << 'EEE' > /dev/null
/* Copyright (C) 2021 Momi-g
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
EEE

set -eu
(
pdir=`pwd`	#parent, callsrc dir
cd `dirname $0`	#base $0 dir
bdir=`pwd`
cd ..
topdir=`pwd`	#configure root

cd ./src
cat Makefile.am | awk '
$0 ~ /#upd:/ {
	buf=$0
	sub(/.*#upd:/, "", buf)
	buf=buf "|tr \047\\n\047 \047 \047"
	ff=""
	buf | getline ff
#**output fd doesnt close**	>> http://www.kt.rim.or.jp/~kbk/gawk-30/gawk_7.html#SEC67
	close(buf)
#	print "res:" ff > "/dev/stderr"
	sub(/[=].*#upd:/, "= " ff "	#upd:", $0 )
}
{print $0}' > tmp.buf
buf=`diff -u tmp.buf Makefile.am||:`
[ ${#buf} = 0 ] || cp tmp.buf Makefile.am
rm tmp.buf
) || exit 1
