wireshark/make-reg-dotc
Guy Harris 7568df46e6 For some unknown reason, having a big "for" loop in the Makefile to scan
all the "packet-XXX.c" files doesn't work with some "make"s; they seem
to pass only the first few names in the list to the shell, for some
reason.

Therefore, we use a script to generate the "register.c" file, and run
that script from the Makefile.

svn path=/trunk/; revision=930
1999-10-27 01:46:14 +00:00

27 lines
853 B
Bash
Executable file

#! /bin/sh
#
# The first argument is the directory in which the source files live.
#
srcdir="$1"
shift
#
# All subsequent arguments are the files to scan.
#
rm -f register.c-tmp
echo '/* Do not modify this file. */' >register.c-tmp
echo '/* It is created automatically by the Makefile. */'>>register.c-tmp
echo '#include "register.h"' >>register.c-tmp
echo 'void register_all_protocols(void) {' >>register.c-tmp
for f in "$@"
do
grep '^proto_register_[a-z_0-9A-Z]* *(' $srcdir/$f 2>/dev/null
done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>register.c-tmp
for f in "$@"
do
grep '^void proto_register_[a-z_0-9A-Z]* *(' $srcdir/$f 2>/dev/null
done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>register.c-tmp
echo '}' >>register.c-tmp
mv register.c-tmp register.c