1234567891011121314151617181920212223242526272829303132333435363738 |
- #!/bin/sh
- CPROTO=cproto
- CPROTO_FLAGS="-I. -I./include -I./include/zori -I./include/tr -D CPROTO"
- c_files=$(find src -iname "*.c" | tr "\n" ' ')
- for each in $c_files
- do
- dir=$(dirname "$each")
- cfile=$(basename "$each")
- hdir=include${dir#src}
- bfile="${cfile%.c}"
- haid="${bfile}_proto.h"
- guard="${bfile}_proto_included"
- hfile="$hdir/$haid"
- # printf "%s: %s->%s\n" "$each" "$dir" "$hfile $guard"
- if grep -q '@generate_cproto@' $each
- then
- mkdir -p "$hdir"
- temp=$(mktemp)
- printf "Generating $hfile from $each. ${CPROTO_PATH} \n"
- # create file if it doesn't exist to avoid chicken and egg problems.
- touch "$hfile"
-
- printf "/* This file was generated by runcprotoall */\n" > "$temp"
- printf "\n#ifndef CPROTO /* Needed to protect cproto from itself. */\n#ifndef ${guard}\n" >> "$temp"
- if cproto $CPROTO_FLAGS -I"$hdir" "$each" >> "$temp"
- then
- printf "\n#endif /* ${guard} */ \n#endif /* CPROTO */" >> "$temp"
- mv -f "$temp" "$hfile"
- else
- printf "cproto failed\n"
- exit 1
- fi
- fi
- done
|