#!/bin/sh

# This file is part of Anastasis
# Copyright (C) 2026 Anastasis SARL
#
# ANASTASIS 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, or (at your option) any later version.
#
# ANASTASIS 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
# ANASTASIS; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>

set -eu

if [ $# -lt 1 ]; then
  echo "Usage: $0 SQLFILES..." >&2
  exit 1
fi

cat <<'EOF'
--
-- This file is part of Anastasis
-- Copyright (C) 2020--2026 Anastasis SARL
--
-- ANASTASIS 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, or (at your option) any later version.
--
-- ANASTASIS 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
-- ANASTASIS; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
--
EOF

for x in $@; do
  echo -- generated from $x
  # Remove SQL comments and empty lines
  cat $x | sed -e "s/--.*//" | awk 'NF'
done
