aboutsummaryrefslogtreecommitdiffstats
path: root/make-reg-dotc
blob: 2c70aefba76ca12de4d5500d611c84e094724490 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#! /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

#
# Build code to call all the protocol registration routines.
#
echo 'void register_all_protocols(void) {' >>register.c-tmp
for f in "$@"
do
	if [ -f $f ]
	then
		srcfile=$f
	else
		srcfile=$srcdir/$f
	fi
	grep '^proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/  {extern void \1 (void); \1 ();}/' >>register.c-tmp
for f in "$@"
do
	if [ -f $f ]
	then
		srcfile=$f
	else
		srcfile=$srcdir/$f
	fi
	grep '^void proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/  {extern void \1 (void); \1 ();}/' >>register.c-tmp
echo '}' >>register.c-tmp

#
# Build code to call all the protocol handoff registration routines.
#
echo 'void register_all_protocol_handoffs(void) {' >>register.c-tmp
for f in "$@"
do
	if [ -f $f ]
	then
		srcfile=$f
	else
		srcfile=$srcdir/$f
	fi
	grep '^proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/  {extern void \1 (void); \1 ();}/' >>register.c-tmp
for f in "$@"
do
	if [ -f $f ]
	then
		srcfile=$f
	else
		srcfile=$srcdir/$f
	fi
	grep '^void proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
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