#! /bin/sh

. sh/tmp.sh

echo "\
/* automatically generated */ 
#ifndef STRINGS_HH
#define STRINGS_HH

"

tmp_file=$TMP/babychess.sh.write-strings.$$

cat $* | grep '[^a-z0-9]str_[a-z0-9]' | 
sed 's,^.*[^a-z]\(str_[a-z_0-9][a-z_0-9]*\).*$,\1,g' | sort -u >$tmp_file

<$tmp_file awk '
{ print "#define ", $0, FNR }
'

echo "
extern const char *string_list[]; 

#endif /* ! STRINGS_HH */

#ifdef STRINGS_DEFINE

const char *string_list[]={
NULL,"

<$tmp_file sed 's|^str_\(.*\)$|"\1",|g' 

echo "
};

#endif /* STRINGS_DEFINE */"


