summaryrefslogtreecommitdiff
path: root/dist/s_prototypes
blob: 73f7be371eae56df0e18794ce5c987bb37e8cff2 (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
69
70
71
72
73
74
75
76
77
78
79
#! /bin/sh

# Build a list of internal function and variable prototypes.
t=__wt.$$
trap 'rm -f $t; exit 0' 0 1 2 3 13 15

# proto --
#	extract public functions.
proto()
{
	sed -n \
	    -e '/^__wt_[a-z]/!{' \
		-e h \
		-e d \
	    -e '}' \
	    -e x \
	    -e '/^static/d' \
	    -e x \
	    -e ': loop' \
	    -e H \
	    -e n \
	    -e '/;/b end' \
	    -e '/^{/!b loop' \
	    -e ': end' \
	    -e x \
	    -e 's/ =.*$//' \
	    -e '/#/!s/\n/ /g' \
	    -e 's/\* /\*/g' \
	    -e 's/  */ /g' \
	    -e 's/^/extern /' \
	    -e 's/WT_GCC_FUNC_/WT_GCC_FUNC_DECL_/g' \
	    -e '# If a line ends in #endif, appending a semicolon will result' \
	    -e '# in an illegal expression, force an appended newline using' \
	    -e '# the H command because substitute may not allow newline in' \
	    -e '# the RHS of the expression.' \
	    -e '/#endif$/{' \
		-e x \
		-e 's/.*//' \
		-e H \
		-e x \
	    -e '}' \
	    -e 's/$/;/' \
	    -e p < $1
}

# proto --
#	generate the list of prototypes given a file list
externs()
{
(cat <<EOF
/* DO NOT EDIT: automatically built by dist/s_prototypes. */

EOF
	for i in $l; do
		proto ../$i
	done) > $t
	cmp $t $f > /dev/null 2>&1 ||
	    (echo "Building $f" && rm -f $f && cp $t $f)
}

f=../src/include/extern_win.h
l=`sed \
    -e '/os_win/!d' \
    -e 's/[	 ].*$//' filelist`
externs

f=../src/include/extern_posix.h
l=`sed \
    -e '/os_posix/!d' \
    -e 's/[	 ].*$//' filelist`
externs

f=../src/include/extern.h
l=`sed \
    -e '/^[a-z]/!d' \
    -e '/os_posix/d' \
    -e '/os_win/d' \
    -e 's/[	 ].*$//' filelist`
externs