1#!/bin/sh -
2#	$Id$
3#
4# Build the automatically generated rep & repmgr message files.
5
6header=/tmp/__db_a
7source=/tmp/__db_b
8
9trap 'rm -f /tmp/__db_[ab]; exit 1' 1 2 3 13 15
10trap 'rm -f /tmp/__db_[ab]; exit 0' 0
11
12DIR="rep repmgr"
13
14# Build DB's message marshaling/unmarshaling routines.
15for i in $DIR; do
16	for f in ../$i/*.src; do
17		subsystem=`basename $f .src`
18		awk -f gen_msg.awk \
19		    -v header_file=$header \
20		    -v source_file=$source < $f
21
22		f=../dbinc_auto/${subsystem}_auto.h
23		cmp $header $f > /dev/null 2>&1 ||
24		    (echo "Building $f" &&
25		    rm -f $f && cp $header $f && chmod 444 $f)
26		f=../$i/${subsystem}_auto.c
27		cmp $source $f > /dev/null 2>&1 ||
28		    (echo "Building $f" &&
29		    rm -f $f && cp $source $f && chmod 444 $f)
30	done
31done
32