summaryrefslogtreecommitdiff
path: root/test/rpcgen_wrapper.sh
blob: fe582d57bd33ef1ae8431409882a4422d35830fc (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
#!/bin/sh
# libevent rpcgen_wrapper.sh
# Transforms event_rpcgen.py failure into success for make, only if
# regress.gen.c and regress.gen.h already exist in $srcdir.  This
# is needed for "make distcheck" to pass the read-only $srcdir build,
# as with read-only sources fresh from tarball, regress.gen.[ch] will
# be correct in $srcdir but unwritable.  This previously triggered
# Makefile.am to create stub regress.gen.c and regress.gen.h in the
# distcheck _build directory, which were then detected as leftover
# files in the build tree after distclean, breaking distcheck.
# Note that regress.gen.[ch] are not in fresh git clones, making
# working Python a requirement for make distcheck of a git tree.

exit_updated() {
#    echo "Updated ${srcdir}/regress.gen.c and ${srcdir}/regress.gen.h"
    exit 0
}

exit_reuse() {
    echo "event_rpcgen.py failed, ${srcdir}/regress.gen.\[ch\] will be reused." >&2
    exit 0
}

exit_failed() {
    echo "Could not generate regress.gen.\[ch\] using event_rpcgen.sh" >&2
    exit 1
}
srcdir=$1
srcdir=${srcdir:-.}

${srcdir}/../event_rpcgen.py --quiet ${srcdir}/regress.rpc \
               test/regress.gen.h test/regress.gen.c

case "$?" in
 0)
    exit_updated
    ;;
 *)
    test -r ${srcdir}/regress.gen.c -a -r ${srcdir}/regress.gen.h && \
	exit_reuse
    exit_failed
    ;;
esac