#!/bin/bash

if [ -d CVS ]; then
	echo "Dont run $0 in your working copy!"
	echo "First make a copy of the sources with cvs export"
	exit 1
fi

text() {
  cat <<eND
+-------------------------------------------------------------------------+
|              (S)imple (U)nix (E)vents vers. 0.2.1 beta                  |
| Copyright (c) Andrey Vikt. Stolyarov <crocodil_AT_croco.net> 2003-2005. |
| ----------------------------------------------------------------------- |
| This is free software.  Permission is granted to everyone to use, copy  |
|        or modify this software under the terms and conditions of        |
|                 GNU LESSER GENERAL PUBLIC LICENSE, v. 2.1               |
| as published by Free Software Foundation  (see the file gnu_lgpl.txt)   |
|                                                                         |
| Please visit http://www.croco.net/software/sue for a fresh copy of SUE. |
| ----------------------------------------------------------------------- |
|   This code is provided strictly and exclusively on the "AS IS" basis.  |
| !!! THERE IS NO WARRANTY OF ANY KIND, NEITHER EXPRESSED NOR IMPLIED !!! |
+-------------------------------------------------------------------------+
eND
}

text_cpp() {
  text | sed 's/^/\/\/ /g'
}
text_lisp() {
  text | sed 's/^/; /g'
}
text_refal() {
  text | sed 's/^/\* /g'
}
text_make() {
  text | sed 's/^/# /g'
}

# $1 - filename   $2 - function
add_text() {
  TEMP=/tmp/intelib_$$_tmp
  eval $2 > $TEMP
  echo -e -n "\\n\\n\\n\\n" >> $TEMP
  cat $1 >> $TEMP 
  mv $TEMP $1
}

rm -rf TODO

for F in `find -name '*.[ch]pp'` ; do
  add_text $F text_cpp
done

for F in `find -name '*.lsp'` ; do
  add_text $F text_lisp
done

for F in `find -name '*.ref'` ; do
  add_text $F text_refal
done

for F in `find -name 'Makefile'` ; do
  add_text $F text_make
done


cat <<eND

    All done.
    Don't forget to delete $0 and to add the license file.

eND
