Follow up to rev 34073: Since "-b files:0" is no longer necessary to
[obnox/wireshark/wip.git] / tools / make-tapreg-dotc
1 #! /bin/sh
2
3 #
4 # $Id$
5 #
6
7 #
8 # The first argument is the output filename.
9 #
10
11 outfile="$1"
12 shift
13
14 #
15 # The second argument is the directory in which the source files live.
16 #
17 srcdir="$1"
18 shift
19
20 #
21 # All subsequent arguments are the files to scan.
22 #
23 rm -f ${outfile}-tmp
24 echo '/* Do not modify this file.  */' >${outfile}-tmp
25 echo '/* It is created automatically by the Makefile.  */' >>${outfile}-tmp
26 echo '#include "register.h"' >>${outfile}-tmp
27
28 #
29 # Build code to call all the tap listener registration routines.
30 #
31 echo 'void register_all_tap_listeners(void){' >>${outfile}-tmp
32 echo '' >>${outfile}-tmp
33 for f in "$@"
34 do
35         if [ -f $f ]
36         then
37                 srcfile=$f
38         else
39                 srcfile=$srcdir/$f
40         fi
41         grep '^register_tap_listener_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';' | sed -e 's/(.*//'
42 done | while read func; do
43         echo "  { extern void $func(void);" >>${outfile}-tmp
44         echo "    $func();}" >>${outfile}-tmp
45 done 
46 echo '}' >>${outfile}-tmp
47 echo '' >>${outfile}-tmp
48
49 mv ${outfile}-tmp ${outfile}