#!/bin/sh # # $Header: /CVSROOT/tinolib/bin/gen,v 1.2 2004/08/22 23:18:48 tino Exp $ # # $Log: gen,v $ # Revision 1.2 2004/08/22 23:18:48 tino # just a sync to cvs # # Revision 1.1 2004/02/14 20:26:44 tino # Initial add cd "`dirname "$0"`" || exit cd .. || exit if [ 1 != $# ] then echo "Usage: bin/`basename "$0"` prefix" exit 1 fi mkdir "$1_inc" 2>/dev/null mkdir "$1_dir" 2>/dev/null if [ ! -d "$1_inc" -o ! -d "$1_dir" -o ! -d tmp ] then echo "cannot create directories $1_inc or $1_dir" exit 1 fi PREF="$1" TMP="tmp/$$" : incparse incparse() { echo -n "$1 " awk \ -v inc="tmp/$1.h" \ -v src="tmp/$1.c" \ -v fnl="tmp/x.fn" \ -v pref="$PREF" \ ' # Elliminate comments BEGIN { imp=0; fns=-1; } NF==1 && $1=="/*IMP*/" { fns=1; imp++; next; } $1~/^\/\*/ { comment=1; } comment && /\*\// { comment=0; next; } comment || NF==0 { next; } fns>0 && /^{/ { fns=0; if (proto) printf("%s;\n", substr(proto, 2)) > inc; proto=""; } fns>0 { proto=proto " " $0; } fns==0 && /^}/ { fns=1; } fns>0 && /^tino_/ { name=substr($1,6); sub(/\(.*$/,"",name); print name >> fnl; } fns>0 && /^static / { $1="tino_STATIC"; } { $0=gensub(/\/, pref "_\\1", "g"); } NF>0 { if (imp) print > src; else print > inc; } ' "src/$1.c" } > "tmp/x.fn" #> "$TMP.fn" #> "$TMP.h" #> "$TMP.c" for a in src/*.c do incparse "`basename "$a" .c`" done echo