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