michael@0: #!/bin/sh michael@0: # libevent rpcgen_wrapper.sh michael@0: # Transforms event_rpcgen.py failure into success for make, only if michael@0: # regress.gen.c and regress.gen.h already exist in $srcdir. This michael@0: # is needed for "make distcheck" to pass the read-only $srcdir build, michael@0: # as with read-only sources fresh from tarball, regress.gen.[ch] will michael@0: # be correct in $srcdir but unwritable. This previously triggered michael@0: # Makefile.am to create stub regress.gen.c and regress.gen.h in the michael@0: # distcheck _build directory, which were then detected as leftover michael@0: # files in the build tree after distclean, breaking distcheck. michael@0: # Note that regress.gen.[ch] are not in fresh git clones, making michael@0: # working Python a requirement for make distcheck of a git tree. michael@0: michael@0: exit_updated() { michael@0: echo "Updated ${srcdir}\regress.gen.c and ${srcdir}\regress.gen.h" michael@0: exit 0 michael@0: } michael@0: michael@0: exit_reuse() { michael@0: echo "event_rpcgen.py failed, ${srcdir}\regress.gen.\[ch\] will be reused." >&2 michael@0: exit 0 michael@0: } michael@0: michael@0: exit_failed() { michael@0: echo "Could not generate regress.gen.\[ch\] using event_rpcgen.sh" >&2 michael@0: exit 1 michael@0: } michael@0: michael@0: if [ -x /usr/bin/python2 ] ; then michael@0: PYTHON2=/usr/bin/python2 michael@0: elif [ "x`which python2`" != x ] ; then michael@0: PYTHON2=python2 michael@0: else michael@0: PYTHON2=python michael@0: fi michael@0: michael@0: srcdir=$1 michael@0: srcdir=${srcdir:-.} michael@0: ${PYTHON2} ${srcdir}/../event_rpcgen.py ${srcdir}/regress.rpc michael@0: case "$?" in michael@0: 0) michael@0: exit_updated michael@0: ;; michael@0: *) michael@0: test -r ${srcdir}/regress.gen.c -a -r ${srcdir}/regress.gen.h && \ michael@0: exit_reuse michael@0: exit_failed michael@0: ;; michael@0: esac