1c43e99fdSEd Maste#!/bin/sh
2c43e99fdSEd Maste# libevent rpcgen_wrapper.sh
3c43e99fdSEd Maste# Transforms event_rpcgen.py failure into success for make, only if
4c43e99fdSEd Maste# regress.gen.c and regress.gen.h already exist in $srcdir.  This
5c43e99fdSEd Maste# is needed for "make distcheck" to pass the read-only $srcdir build,
6c43e99fdSEd Maste# as with read-only sources fresh from tarball, regress.gen.[ch] will
7c43e99fdSEd Maste# be correct in $srcdir but unwritable.  This previously triggered
8c43e99fdSEd Maste# Makefile.am to create stub regress.gen.c and regress.gen.h in the
9c43e99fdSEd Maste# distcheck _build directory, which were then detected as leftover
10c43e99fdSEd Maste# files in the build tree after distclean, breaking distcheck.
11c43e99fdSEd Maste# Note that regress.gen.[ch] are not in fresh git clones, making
12c43e99fdSEd Maste# working Python a requirement for make distcheck of a git tree.
13c43e99fdSEd Maste
14c43e99fdSEd Masteexit_updated() {
15c43e99fdSEd Maste#    echo "Updated ${srcdir}/regress.gen.c and ${srcdir}/regress.gen.h"
16c43e99fdSEd Maste    exit 0
17c43e99fdSEd Maste}
18c43e99fdSEd Maste
19c43e99fdSEd Masteexit_reuse() {
20c43e99fdSEd Maste    echo "event_rpcgen.py failed, ${srcdir}/regress.gen.\[ch\] will be reused." >&2
21c43e99fdSEd Maste    exit 0
22c43e99fdSEd Maste}
23c43e99fdSEd Maste
24c43e99fdSEd Masteexit_failed() {
25c43e99fdSEd Maste    echo "Could not generate regress.gen.\[ch\] using event_rpcgen.sh" >&2
26c43e99fdSEd Maste    exit 1
27c43e99fdSEd Maste}
28c43e99fdSEd Mastesrcdir=$1
29c43e99fdSEd Mastesrcdir=${srcdir:-.}
30c43e99fdSEd Maste
31*b50261e2SCy Schubert${srcdir}/../event_rpcgen.py --quiet ${srcdir}/regress.rpc \
32c43e99fdSEd Maste               test/regress.gen.h test/regress.gen.c
33c43e99fdSEd Maste
34c43e99fdSEd Mastecase "$?" in
35c43e99fdSEd Maste 0)
36c43e99fdSEd Maste    exit_updated
37c43e99fdSEd Maste    ;;
38c43e99fdSEd Maste *)
39c43e99fdSEd Maste    test -r ${srcdir}/regress.gen.c -a -r ${srcdir}/regress.gen.h && \
40c43e99fdSEd Maste	exit_reuse
41c43e99fdSEd Maste    exit_failed
42c43e99fdSEd Maste    ;;
43c43e99fdSEd Masteesac
44